shiplightai 0.1.64 → 0.1.65

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/fixture.js CHANGED
@@ -134,17 +134,17 @@ To use them, write Jinja-like template syntax: {{ placeholder_name }}
134
134
  `}if(n&&n.length>0){let g=ph(n);m+=`
135
135
  `+g}return m+=`
136
136
  Based on the above information, please determine the right action to accomplish the task.
137
- `,c.push({type:"text",text:m}),c}var nn=y(()=>{"use strict";Nt()});async function gh(e){let t=e.context().pages(),i=null,n=[];for(let o=0;o<t.length;o++){let r=t[o];r===e&&(i=o);let s="(title unavailable)";try{s=await Promise.race([r.title(),new Promise((d,c)=>setTimeout(()=>c(new Error("timeout")),1e3))])}catch{}let l=`Tab ${o}: ${r.url()}`;s&&(l+=` - ${s.slice(0,50)}`),n.push(l)}let a=n.length>0?n.join(`
137
+ `,c.push({type:"text",text:m}),c}var nn=y(()=>{"use strict";Nt()});function an(e,t){return e?{prompt_tokens:e.promptTokens||e.inputTokens||0,completion_tokens:e.completionTokens||e.outputTokens||0,total_tokens:e.totalTokens||0,model:t}:null}var Rt=y(()=>{"use strict"});async function gh(e){let t=e.context().pages(),i=null,n=[];for(let o=0;o<t.length;o++){let r=t[o];r===e&&(i=o);let s="(title unavailable)";try{s=await Promise.race([r.title(),new Promise((d,c)=>setTimeout(()=>c(new Error("timeout")),1e3))])}catch{}let l=`Tab ${o}: ${r.url()}`;s&&(l+=` - ${s.slice(0,50)}`),n.push(l)}let a=n.length>0?n.join(`
138
138
  `):"";return{currentTabText:i!==null?`Current tab: ${i}
139
- `:"",tabsText:a}}async function fh(e,t){let{currentTabText:i,tabsText:n}=await gh(e);return{elementsText:t,currentUrl:e.url(),currentTitle:await e.title(),currentTabText:i,tabsText:n}}async function an(e,t){let{page:i,domService:n,agentServices:a}=e,o=typeof t=="boolean"?{useCleanScreenshot:t}:t||{},r=a.getInteractiveClassNames(),s=a.getIframeFallbackDomains(),{domState:l,screenshotBase64:d,slicedScreenshotsBase64:c}=await n.getClickableElementsWithScreenshot(i,{interactiveClassNames:r,playwrightFrameFallbackDomains:s,useCleanScreenshot:o.useCleanScreenshot,useSlicedScreenshots:o.useSlicedScreenshots,resizeSlicedScreenshots:o.resizeSlicedScreenshots,useAccessibilityTree:o.useAccessibilityTree,actionIntent:o.actionIntent}),u=l.elementTree.clickableElementsToString(),m=await fh(i,u);return c&&(m.slicedScreenshotsBase64=c),{domTree:u,screenshotBase64:d,slicedScreenshotsBase64:c,domState:l,pageContext:m}}var Rt=y(()=>{"use strict"});function on(e,t){return e?{prompt_tokens:e.promptTokens||e.inputTokens||0,completion_tokens:e.completionTokens||e.outputTokens||0,total_tokens:e.totalTokens||0,model:t}:null}var Ft=y(()=>{"use strict"});import{z as se}from"zod";var lt,F,Se=y(()=>{"use strict";lt=class{constructor(){this.tools=new Map}register(e){if(this.tools.has(e.name))throw new Error(`Tool '${e.name}' is already registered`);let t={name:e.name,description:e.description,schema:e.schema,execute:e.execute,usesElementIndex:e.usesElementIndex??!1,availability:{openai:e.availability?.openai??!0,mcp:e.availability?.mcp??!0}};this.tools.set(e.name,t)}get(e){return this.tools.get(e)}has(e){return this.tools.has(e)}getToolNames(){return Array.from(this.tools.keys())}getTools(){return Array.from(this.tools.values())}async execute(e,t,i){let n=this.tools.get(e);if(!n)throw new Error(`Tool not found: ${e}`);try{let a=t?.description,o={...t};delete o.description;let r=n.schema.parse(o),s={...i,actionDescription:a};return await n.execute(r,s)}catch(a){if(a instanceof se.ZodError){let o=a.issues.map(r=>`${r.path.join(".")}: ${r.message}`).join(", ");return{success:!1,error:`Invalid arguments for tool '${e}': ${o}`,actionEntity:{action_description:t?.description||`${e} (validation failed)`,action_data:{action_name:e,kwargs:t},feedback:`Validation error: ${o}`}}}throw a}}clear(){this.tools.clear()}size(){return this.tools.size}buildActionUnionSchema(){let e=this.getTools().filter(t=>t.availability.openai);return this.buildUnionSchemaFromTools(e)}buildActionUnionSchemaForTools(e,t=!1){let i=new Set(e),n=this.getTools().filter(a=>i.has(a.name));return this.buildUnionSchemaFromTools(n,t)}buildUnionSchemaFromTools(e,t=!1){if(e.length===0)return se.object({done:se.any()});let i=e.map(r=>{let s=r.schema;if(t&&s instanceof se.ZodObject){let l=s._def.shape();s=se.object({...l,description:se.string().describe("Semantic, human-readable description of the action")})}if(s instanceof se.ZodObject){let l=s._def.shape();Object.keys(l).length===0&&(s=se.object({_empty:se.boolean().optional()}))}return se.object({[r.name]:s})});if(i.length===1)return i[0];let[n,a,...o]=i;return se.union([n,a,...o])}},F=new lt});async function H(e,t){if(t<0)return;let{page:i,domService:n}=e;return(e.domState||await n.getClickableElements(i)).selectorMap.get(t)}function wh(e){let t=e.split("/").filter(a=>a);if(t.length===0)return"*";let i=t[t.length-1],n=i.match(/^(\w+)(?:\[(\d+)\])?$/);if(n){let[,a,o]=n;return o?`${a}:nth-of-type(${o})`:a}return i}function bh(e,t=!0){try{let i=wh(e.xpath);if(e.attributes.class&&t){let a=/^[a-zA-Z_][a-zA-Z0-9_-]*$/,o=e.attributes.class.split(/\s+/);for(let r of o)r.trim()&&a.test(r)&&(i+=`.${r}`)}let n=new Set(["id","name","type","placeholder","aria-label","aria-labelledby","aria-describedby","role","for","autocomplete","required","readonly","alt","title","target"]);t&&["data-id","data-qa","data-cy","data-testid","data-handlepos"].forEach(a=>n.add(a));for(let[a,o]of Object.entries(e.attributes)){if(a==="class"||!a.trim()||!n.has(a))continue;let r=a.replace(/:/g,"\\:");if(o==="")i+=`[${r}]`;else if(/["'<>`\n\r\t]/.test(o)){let s=o;o.includes(`
139
+ `:"",tabsText:a}}async function fh(e,t){let{currentTabText:i,tabsText:n}=await gh(e);return{elementsText:t,currentUrl:e.url(),currentTitle:await e.title(),currentTabText:i,tabsText:n}}async function on(e,t){let{page:i,domService:n,agentServices:a}=e,o=typeof t=="boolean"?{useCleanScreenshot:t}:t||{},r=a.getInteractiveClassNames(),s=a.getIframeFallbackDomains(),{domState:l,screenshotBase64:d,slicedScreenshotsBase64:c}=await n.getClickableElementsWithScreenshot(i,{interactiveClassNames:r,playwrightFrameFallbackDomains:s,useCleanScreenshot:o.useCleanScreenshot,useSlicedScreenshots:o.useSlicedScreenshots,resizeSlicedScreenshots:o.resizeSlicedScreenshots,useAccessibilityTree:o.useAccessibilityTree,actionIntent:o.actionIntent}),u=l.elementTree.clickableElementsToString(),m=await fh(i,u);return c&&(m.slicedScreenshotsBase64=c),{domTree:u,screenshotBase64:d,slicedScreenshotsBase64:c,domState:l,pageContext:m}}var Ft=y(()=>{"use strict"});import{z as se}from"zod";var lt,F,Se=y(()=>{"use strict";lt=class{constructor(){this.tools=new Map}register(e){if(this.tools.has(e.name))throw new Error(`Tool '${e.name}' is already registered`);let t={name:e.name,description:e.description,schema:e.schema,execute:e.execute,usesElementIndex:e.usesElementIndex??!1,availability:{openai:e.availability?.openai??!0,mcp:e.availability?.mcp??!0}};this.tools.set(e.name,t)}get(e){return this.tools.get(e)}has(e){return this.tools.has(e)}getToolNames(){return Array.from(this.tools.keys())}getTools(){return Array.from(this.tools.values())}async execute(e,t,i){let n=this.tools.get(e);if(!n)throw new Error(`Tool not found: ${e}`);try{let a=t?.description,o={...t};delete o.description;let r=n.schema.parse(o),s={...i,actionDescription:a};return await n.execute(r,s)}catch(a){if(a instanceof se.ZodError){let o=a.issues.map(r=>`${r.path.join(".")}: ${r.message}`).join(", ");return{success:!1,error:`Invalid arguments for tool '${e}': ${o}`,actionEntity:{action_description:t?.description||`${e} (validation failed)`,action_data:{action_name:e,kwargs:t},feedback:`Validation error: ${o}`}}}throw a}}clear(){this.tools.clear()}size(){return this.tools.size}buildActionUnionSchema(){let e=this.getTools().filter(t=>t.availability.openai);return this.buildUnionSchemaFromTools(e)}buildActionUnionSchemaForTools(e,t=!1){let i=new Set(e),n=this.getTools().filter(a=>i.has(a.name));return this.buildUnionSchemaFromTools(n,t)}buildUnionSchemaFromTools(e,t=!1){if(e.length===0)return se.object({done:se.any()});let i=e.map(r=>{let s=r.schema;if(t&&s instanceof se.ZodObject){let l=s._def.shape();s=se.object({...l,description:se.string().describe("Semantic, human-readable description of the action")})}if(s instanceof se.ZodObject){let l=s._def.shape();Object.keys(l).length===0&&(s=se.object({_empty:se.boolean().optional()}))}return se.object({[r.name]:s})});if(i.length===1)return i[0];let[n,a,...o]=i;return se.union([n,a,...o])}},F=new lt});async function H(e,t){if(t<0)return;let{page:i,domService:n}=e;return(e.domState||await n.getClickableElements(i)).selectorMap.get(t)}function wh(e){let t=e.split("/").filter(a=>a);if(t.length===0)return"*";let i=t[t.length-1],n=i.match(/^(\w+)(?:\[(\d+)\])?$/);if(n){let[,a,o]=n;return o?`${a}:nth-of-type(${o})`:a}return i}function bh(e,t=!0){try{let i=wh(e.xpath);if(e.attributes.class&&t){let a=/^[a-zA-Z_][a-zA-Z0-9_-]*$/,o=e.attributes.class.split(/\s+/);for(let r of o)r.trim()&&a.test(r)&&(i+=`.${r}`)}let n=new Set(["id","name","type","placeholder","aria-label","aria-labelledby","aria-describedby","role","for","autocomplete","required","readonly","alt","title","target"]);t&&["data-id","data-qa","data-cy","data-testid","data-handlepos"].forEach(a=>n.add(a));for(let[a,o]of Object.entries(e.attributes)){if(a==="class"||!a.trim()||!n.has(a))continue;let r=a.replace(/:/g,"\\:");if(o==="")i+=`[${r}]`;else if(/["'<>`\n\r\t]/.test(o)){let s=o;o.includes(`
140
140
  `)&&(s=o.split(`
141
- `)[0]),s=s.replace(/\s+/g," ").trim();let l=s.replace(/"/g,'\\"');i+=`[${r}*="${l}"]`}else i+=`[${r}="${o}"]`}return i}catch{return`${e.tagName||"*"}[highlight_index='${e.highlightIndex}']`}}function yh(e){let t=e.attributes;if(t.title)return`iframe[title="${t.title.replace(/"/g,'\\"')}"]`;if(t.id)return`iframe#${t.id}`;if(t.name)return`iframe[name="${t.name.replace(/"/g,'\\"')}"]`;if(t.src){try{let i=new URL(t.src);if(i.protocol==="chrome-extension:")return`iframe[src^="${i.origin}"]`}catch{}return`iframe[src="${t.src.replace(/"/g,'\\"')}"]`}return bh(e,!1)}function $a(e){let t=[],i=e;for(;i&&i.parent!==null;){let o=i.parent;t.push(o),i=o}t.reverse();let n=[],a=t.filter(o=>o.tagName==="iframe");for(let o of a){let r=yh(o);h.debug("[frame-path] iframe attrs:",JSON.stringify(o.attributes),"\u2192",r),n.push(r)}return n}async function O(e,t){let i=null,n=$a(t);return t.xpath&&(i=await $t(e,t.xpath,n,t.shadowHostXPaths??[])),{locator:i||void 0,xpath:i?void 0:t.xpath,frame_path:n}}var G=y(()=>{"use strict";Ue();N()});import{generateText as xh,Output as vh}from"ai";import{z as rn}from"zod";function _h(e){let t=e.toLowerCase();return[/\b(type|enter|input|fill|write|set)\b/,/\b(text|value|field|box)\b.*\b(to|with|as)\b/,/\b(username|password|email|search|query)\b/].some(i=>i.test(t))?"input":[/\bscroll\b/,/\b(scroll|swipe)\s*(up|down|left|right)\b/,/\b(page|move)\s*(down|up)\b/].some(i=>i.test(t))?"scroll":[/\b(click|tap|press|select|choose|pick|check|toggle)\b/,/\b(open|close|submit|confirm|cancel|dismiss)\b/,/\b(button|link|menu|dropdown|checkbox|radio)\b/].some(i=>i.test(t))?"click":"all"}function kh(e){if(!e)return null;if(e instanceof URL)return e.href;if(typeof e=="object"&&e.href)return String(e.href);if(typeof e=="object"&&typeof e.toString=="function"){let t=e.toString();if(t.startsWith("http://")||t.startsWith("https://"))return t}return typeof e=="string"&&(e.startsWith("http://")||e.startsWith("https://"))?e:null}function Sh(e){return e.map(t=>({role:t.role,content:Array.isArray(t.content)?t.content.map(i=>{if(i.type==="image"){let n=i.image,a=kh(n);if(a)return{type:"image",file:a};let o=typeof n=="string"?n:"";return{type:"image",file:o.startsWith("data:")?o:`data:image/png;base64,${o}`}}return{type:"text",text:i.text}}):t.content}))}async function cs(e,t,i={}){let{page:n,agentServices:a}=t,o=a.getModel(),r=i.temperature??0,s=a.retrieveKnowledges(e).catch(V=>(b.log(`Failed to retrieve knowledges: ${V.message}`),[])),l=a.isSlicedScreenshotsEnabled(),d=a.isResizeSlicedScreenshotsEnabled(),c=a.isKnowledgeImagesEnabled(),u=a.isAccessibilityTreeEnabled(),m=a.isActionIntentFilteringEnabled(),g=m?_h(e):"all";m&&g!=="all"&&b.log(`Action intent filtering: detected '${g}' intent from statement`);let{screenshotBase64:w,domState:v,pageContext:x}=await an(t,{useSlicedScreenshots:l,resizeSlicedScreenshots:d,useAccessibilityTree:u,actionIntent:g});t.domState=v;let p=new Ui(F).getToolDefinitions().map(V=>{let Qe=V.function;return`${Qe.name}: ${Qe.description}
141
+ `)[0]),s=s.replace(/\s+/g," ").trim();let l=s.replace(/"/g,'\\"');i+=`[${r}*="${l}"]`}else i+=`[${r}="${o}"]`}return i}catch{return`${e.tagName||"*"}[highlight_index='${e.highlightIndex}']`}}function yh(e){let t=e.attributes;if(t.title)return`iframe[title="${t.title.replace(/"/g,'\\"')}"]`;if(t.id)return`iframe#${t.id}`;if(t.name)return`iframe[name="${t.name.replace(/"/g,'\\"')}"]`;if(t.src){try{let i=new URL(t.src);if(i.protocol==="chrome-extension:")return`iframe[src^="${i.origin}"]`}catch{}return`iframe[src="${t.src.replace(/"/g,'\\"')}"]`}return bh(e,!1)}function $a(e){let t=[],i=e;for(;i&&i.parent!==null;){let o=i.parent;t.push(o),i=o}t.reverse();let n=[],a=t.filter(o=>o.tagName==="iframe");for(let o of a){let r=yh(o);h.debug("[frame-path] iframe attrs:",JSON.stringify(o.attributes),"\u2192",r),n.push(r)}return n}async function O(e,t){let i=null,n=$a(t);return t.xpath&&(i=await $t(e,t.xpath,n,t.shadowHostXPaths??[])),{locator:i||void 0,xpath:i?void 0:t.xpath,frame_path:n}}var G=y(()=>{"use strict";Ue();N()});import{generateText as xh,Output as vh}from"ai";import{z as rn}from"zod";function _h(e){let t=e.toLowerCase();return[/\b(type|enter|input|fill|write|set)\b/,/\b(text|value|field|box)\b.*\b(to|with|as)\b/,/\b(username|password|email|search|query)\b/].some(i=>i.test(t))?"input":[/\bscroll\b/,/\b(scroll|swipe)\s*(up|down|left|right)\b/,/\b(page|move)\s*(down|up)\b/].some(i=>i.test(t))?"scroll":[/\b(click|tap|press|select|choose|pick|check|toggle)\b/,/\b(open|close|submit|confirm|cancel|dismiss)\b/,/\b(button|link|menu|dropdown|checkbox|radio)\b/].some(i=>i.test(t))?"click":"all"}function kh(e){if(!e)return null;if(e instanceof URL)return e.href;if(typeof e=="object"&&e.href)return String(e.href);if(typeof e=="object"&&typeof e.toString=="function"){let t=e.toString();if(t.startsWith("http://")||t.startsWith("https://"))return t}return typeof e=="string"&&(e.startsWith("http://")||e.startsWith("https://"))?e:null}function Sh(e){return e.map(t=>({role:t.role,content:Array.isArray(t.content)?t.content.map(i=>{if(i.type==="image"){let n=i.image,a=kh(n);if(a)return{type:"image",file:a};let o=typeof n=="string"?n:"";return{type:"image",file:o.startsWith("data:")?o:`data:image/png;base64,${o}`}}return{type:"text",text:i.text}}):t.content}))}async function cs(e,t,i={}){let{page:n,agentServices:a}=t,o=a.getModel(),r=i.temperature??0,s=a.retrieveKnowledges(e).catch(V=>(b.log(`Failed to retrieve knowledges: ${V.message}`),[])),l=a.isSlicedScreenshotsEnabled(),d=a.isResizeSlicedScreenshotsEnabled(),c=a.isKnowledgeImagesEnabled(),u=a.isAccessibilityTreeEnabled(),m=a.isActionIntentFilteringEnabled(),g=m?_h(e):"all";m&&g!=="all"&&b.log(`Action intent filtering: detected '${g}' intent from statement`);let{screenshotBase64:w,domState:v,pageContext:x}=await on(t,{useSlicedScreenshots:l,resizeSlicedScreenshots:d,useAccessibilityTree:u,actionIntent:g});t.domState=v;let p=new Ui(F).getToolDefinitions().map(V=>{let Qe=V.function;return`${Qe.name}: ${Qe.description}
142
142
  Parameters: ${JSON.stringify(Qe.parameters,null,2)}`}).join(`
143
143
 
144
- `),f=ss(p),S=await s,_=ls(x,e,t.variables,t.executionHistory,S.length>0?S:void 0,w,l,void 0,c,t.sensitiveKeys),k=[];i.chatHistory&&i.chatHistory.length>0&&i.chatHistory.forEach(V=>{V.role==="user"?k.push({role:"user",content:V.content}):V.role==="assistant"&&k.push({role:"assistant",content:V.content})}),k.push({role:"user",content:_});let E=Sh(k),I=F.buildActionUnionSchema(),C=rn.object({thought:rn.string().describe("Step by step reasoning of your decision making process").optional().default(""),description:rn.string().describe("Detailed description of the action to be performed").optional().default(""),action:I,completes_instruction:rn.boolean().describe("Whether this action completes the given instruction").optional().default(!0)}),$=Array.isArray(_)?_.filter(V=>V.type==="image").length:0,U=we(o,$),z=await xh({model:fe(o),system:f,messages:k,temperature:r,output:vh.object({schema:C}),providerOptions:U}),xe=z.reasoningText;h.info(`Action Generation Reasoning: ${xe}`);let j=z.output,X=JSON.stringify(j,null,2);h.info(`Generate Action Raw Output: ${X}`);let ve=[],Be=on(z.usage,o);Be&&ve.push(Be);let Ie={systemPrompt:f,userPrompt:E,rawLlmResponse:X,tokenUsages:ve},Ce=j.thought||"",Pe=j.description||"",B=j.action||{},Y=j.completes_instruction||!1;if(!B||Object.keys(B).length===0)return{status:"error",reasoning:Ce||Pe||"No action generated",goalAccomplished:Y,error:"Agent did not generate any action",debugInfo:Ie};let J=Object.keys(B)[0];if(J==="done")return{status:"error",reasoning:Ce||Pe||"Task marked as done",goalAccomplished:Y,error:"Agent indicated task is done without generating an action",debugInfo:Ie};if(J==="perform_accurate_operation")return await rt(e,t,i);if(!Y){let V="Can't complete the instruction in one action";return{status:"error",reasoning:Ce||Pe||V,goalAccomplished:!1,error:V,debugInfo:Ie}}let re=B[J]||{},gr={};if(typeof re.element_index=="number"){let V=re.element_index;if(V<0)return{status:"error",reasoning:Ce||Pe||"No action generated",goalAccomplished:Y,error:"Agent did not generate any action",debugInfo:Ie};let Qe=v.selectorMap.get(V);Qe&&(gr=await O(n,Qe))}let fr=Pe;return J==="verify"&&(fr=e,re.statement=e),{status:"success",actionEntity:{...gr,action_description:fr||Ce||`${J}(${JSON.stringify(re)})`,action_data:{action_name:J,kwargs:re}},reasoning:Ce||Pe,goalAccomplished:Y,debugInfo:Ie}}var sn=y(()=>{"use strict";Gi();st();nn();Rt();Ft();Se();ee();ke();G();N()});import{generateText as Eh,Output as Th}from"ai";import{z as ln}from"zod";function Ah(e){if(!e)return null;if(e instanceof URL)return e.href;if(typeof e=="object"&&e.href)return String(e.href);if(typeof e=="object"&&typeof e.toString=="function"){let t=e.toString();if(t.startsWith("http://")||t.startsWith("https://"))return t}return typeof e=="string"&&(e.startsWith("http://")||e.startsWith("https://"))?e:null}async function La(e,t,i={}){return i.usePureVision?rt(e,t,i):cs(e,t,i)}function Ih(){let e=new Date,t=e.toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"America/Los_Angeles"}),i=e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,timeZoneName:"short",timeZone:"America/Los_Angeles"});return{dateString:t,timeString:i}}function Ch(){return`# Role
144
+ `),f=ss(p),S=await s,_=ls(x,e,t.variables,t.executionHistory,S.length>0?S:void 0,w,l,void 0,c,t.sensitiveKeys),k=[];i.chatHistory&&i.chatHistory.length>0&&i.chatHistory.forEach(V=>{V.role==="user"?k.push({role:"user",content:V.content}):V.role==="assistant"&&k.push({role:"assistant",content:V.content})}),k.push({role:"user",content:_});let E=Sh(k),I=F.buildActionUnionSchema(),C=rn.object({thought:rn.string().describe("Step by step reasoning of your decision making process").optional().default(""),description:rn.string().describe("Detailed description of the action to be performed").optional().default(""),action:I,completes_instruction:rn.boolean().describe("Whether this action completes the given instruction").optional().default(!0)}),$=Array.isArray(_)?_.filter(V=>V.type==="image").length:0,U=we(o,$),z=await xh({model:fe(o),system:f,messages:k,temperature:r,output:vh.object({schema:C}),providerOptions:U}),xe=z.reasoningText;h.info(`Action Generation Reasoning: ${xe}`);let j=z.output,X=JSON.stringify(j,null,2);h.info(`Generate Action Raw Output: ${X}`);let ve=[],Be=an(z.usage,o);Be&&ve.push(Be);let Ie={systemPrompt:f,userPrompt:E,rawLlmResponse:X,tokenUsages:ve},Ce=j.thought||"",Pe=j.description||"",B=j.action||{},Y=j.completes_instruction||!1;if(!B||Object.keys(B).length===0)return{status:"error",reasoning:Ce||Pe||"No action generated",goalAccomplished:Y,error:"Agent did not generate any action",debugInfo:Ie};let J=Object.keys(B)[0];if(J==="done")return{status:"error",reasoning:Ce||Pe||"Task marked as done",goalAccomplished:Y,error:"Agent indicated task is done without generating an action",debugInfo:Ie};if(J==="perform_accurate_operation")return await rt(e,t,i);if(!Y){let V="Can't complete the instruction in one action";return{status:"error",reasoning:Ce||Pe||V,goalAccomplished:!1,error:V,debugInfo:Ie}}let re=B[J]||{},gr={};if(typeof re.element_index=="number"){let V=re.element_index;if(V<0)return{status:"error",reasoning:Ce||Pe||"No action generated",goalAccomplished:Y,error:"Agent did not generate any action",debugInfo:Ie};let Qe=v.selectorMap.get(V);Qe&&(gr=await O(n,Qe))}let fr=Pe;return J==="verify"&&(fr=e,re.statement=e),{status:"success",actionEntity:{...gr,action_description:fr||Ce||`${J}(${JSON.stringify(re)})`,action_data:{action_name:J,kwargs:re}},reasoning:Ce||Pe,goalAccomplished:Y,debugInfo:Ie}}var sn=y(()=>{"use strict";Gi();st();nn();Rt();Ft();Se();ee();ke();G();N()});import{generateText as Eh,Output as Th}from"ai";import{z as ln}from"zod";function Ah(e){if(!e)return null;if(e instanceof URL)return e.href;if(typeof e=="object"&&e.href)return String(e.href);if(typeof e=="object"&&typeof e.toString=="function"){let t=e.toString();if(t.startsWith("http://")||t.startsWith("https://"))return t}return typeof e=="string"&&(e.startsWith("http://")||e.startsWith("https://"))?e:null}async function La(e,t,i={}){return i.usePureVision?rt(e,t,i):cs(e,t,i)}function Ih(){let e=new Date,t=e.toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"America/Los_Angeles"}),i=e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,timeZoneName:"short",timeZone:"America/Los_Angeles"});return{dateString:t,timeString:i}}function Ch(){return`# Role
145
145
  You are an experienced QA person for web applications.
146
146
  You are tasked to verify the validity of a given statement based on the screenshot and element tree of a web page.
147
- `}async function ds(e,t,i={}){let{page:n,executionHistory:a}=t,o=t.agentServices.getModel();try{let r=t.agentServices.isSlicedScreenshotsEnabled(),s=t.agentServices.isResizeSlicedScreenshotsEnabled(),l=t.agentServices.isKnowledgeImagesEnabled(),d=t.agentServices.isAccessibilityTreeEnabled(),{domTree:c,screenshotBase64:u,slicedScreenshotsBase64:m,domState:g,pageContext:w}=await an(t,{useCleanScreenshot:i.useCleanScreenshotForAssertion,useSlicedScreenshots:r,resizeSlicedScreenshots:s,useAccessibilityTree:d});t.domState=g;let v="";a&&a.length>0&&(v=`
147
+ `}async function ds(e,t,i={}){let{page:n,executionHistory:a}=t,o=t.agentServices.getModel();try{let r=t.agentServices.isSlicedScreenshotsEnabled(),s=t.agentServices.isResizeSlicedScreenshotsEnabled(),l=t.agentServices.isKnowledgeImagesEnabled(),d=t.agentServices.isAccessibilityTreeEnabled(),{domTree:c,screenshotBase64:u,slicedScreenshotsBase64:m,domState:g,pageContext:w}=await on(t,{useCleanScreenshot:i.useCleanScreenshotForAssertion,useSlicedScreenshots:r,resizeSlicedScreenshots:s,useAccessibilityTree:d});t.domState=g;let v="";a&&a.length>0&&(v=`
148
148
  # Previous actions in this session:
149
149
  ${a.map(([B,Y],J)=>`${J+1}. Action: ${B}
150
150
  Result: ${Y}`).join(`
@@ -178,7 +178,7 @@ ${v}
178
178
 
179
179
  Today is ${x}. Current local time is ${p}.
180
180
  Based on the above information, please determine if the statement is true.
181
- `,k=await t.agentServices.retrieveKnowledges(e),E=[{type:"text",text:f}],I=0;if(r&&m&&m.length>0)for(let B of m)E.push({type:"image",image:B}),I++;else E.push({type:"image",image:u}),I=1;if(k&&k.length>0){let B=tn(k,l);E.push(...B)}E.push({type:"text",text:_});let C=k?rs(k,l):0,$=I+C,U=we(o,$),z=Ch(),xe=await Eh({model:fe(o),system:z,messages:[{role:"user",content:E}],output:Th.object({schema:Mh}),temperature:0,providerOptions:U}),{conclusion:j,explanation:X}=xe.output,ve=JSON.stringify(xe.output,null,2),Be=[],Ie=on(xe.usage,o);Ie&&Be.push(Ie);let Ce=[{role:"user",content:E.map(B=>{if(B.type==="text")return{type:"text",text:B.text};if(B.type==="image"){let Y=B.image,J=Ah(Y);if(J)return{type:"image",file:J};let re=typeof Y=="string"?Y:"";return{type:"image",file:re.startsWith("data:")?re:`data:image/png;base64,${re}`}}return{type:"text",text:"[unknown content type]"}})}],Pe={systemPrompt:z,userPrompt:Ce,rawLlmResponse:ve,screenshotWithSom:u,tokenUsages:Be,retrievedKnowledges:k&&k.length>0?k:void 0,elementTree:c};return{success:j==="true",explanation:X,debugInfo:Pe}}catch(r){return{success:!1,error:r.message}}}var Mh,cn=y(()=>{"use strict";sn();st();Rt();Ft();Nt();ke();Mh=ln.object({screenshotDescription:ln.string().describe(`Description of the screenshot content, listing out key elements along with their Set of Mark indices,
181
+ `,k=await t.agentServices.retrieveKnowledges(e),E=[{type:"text",text:f}],I=0;if(r&&m&&m.length>0)for(let B of m)E.push({type:"image",image:B}),I++;else E.push({type:"image",image:u}),I=1;if(k&&k.length>0){let B=tn(k,l);E.push(...B)}E.push({type:"text",text:_});let C=k?rs(k,l):0,$=I+C,U=we(o,$),z=Ch(),xe=await Eh({model:fe(o),system:z,messages:[{role:"user",content:E}],output:Th.object({schema:Mh}),temperature:0,providerOptions:U}),{conclusion:j,explanation:X}=xe.output,ve=JSON.stringify(xe.output,null,2),Be=[],Ie=an(xe.usage,o);Ie&&Be.push(Ie);let Ce=[{role:"user",content:E.map(B=>{if(B.type==="text")return{type:"text",text:B.text};if(B.type==="image"){let Y=B.image,J=Ah(Y);if(J)return{type:"image",file:J};let re=typeof Y=="string"?Y:"";return{type:"image",file:re.startsWith("data:")?re:`data:image/png;base64,${re}`}}return{type:"text",text:"[unknown content type]"}})}],Pe={systemPrompt:z,userPrompt:Ce,rawLlmResponse:ve,screenshotWithSom:u,tokenUsages:Be,retrievedKnowledges:k&&k.length>0?k:void 0,elementTree:c};return{success:j==="true",explanation:X,debugInfo:Pe}}catch(r){return{success:!1,error:r.message}}}var Mh,cn=y(()=>{"use strict";sn();st();Rt();Ft();Nt();ke();Mh=ln.object({screenshotDescription:ln.string().describe(`Description of the screenshot content, listing out key elements along with their Set of Mark indices,
182
182
  and a description of their location: formatting example: [12] A red button with text "Submit", next to [11]
183
183
  [45] A modal dialog titled "Confirmation",
184
184
  in the center of the screen`),explanation:ln.string().describe("Step by step reasoning explaining your conclusion about the statement"),conclusion:ln.enum(["true","false","unknown"]).describe("Whether the statement is true, false, or unknown if you cannot make a conclusion")})});async function hs(){let{default:e}=await import("sharp");return e}async function Da(e,t){let i=await hs(),n=await i(e).metadata(),a=n.width||0,o=n.height||0;if(a===0||o===0)throw new Error("Invalid image dimensions");let r=o,s=0,l=Math.floor((a-r)/2),d=Math.max(0,a-r),c=(w,v)=>{let x=i(e).extract({left:w,top:0,width:v,height:r});return t?.resize&&(x=x.resize(us,us)),x.png().toBuffer()},[u,m,g]=await Promise.all([c(s,Math.min(r,a)),c(l,Math.min(r,a-l)),c(d,Math.min(r,a-d))]);return[u,m,g]}async function ms(e){let t=(await hs())(e),i=await t.metadata(),n=i.width||0,a=i.height||0;if(n===0||a===0)throw new Error("Invalid image dimensions");let{data:o}=await t.grayscale().raw().toBuffer({resolveWithObject:!0}),r=[];for(let s=0;s<a;s++){r[s]=[];for(let l=0;l<n;l++)r[s][l]=o[s*n+l]}return{pixels:r,width:n,height:a}}var us,Ht=y(()=>{"use strict";us=768});function ps(e){return e?Wt.has(e):!1}function gs(e){return ct.has(e)}function fs(e){return e.filter(t=>ct.has(t.type))}var Wt,ct,dn,un,Bt=y(()=>{"use strict";Wt=new Set(["button","link","textbox","checkbox","radio","combobox","listbox","menuitem","menuitemcheckbox","menuitemradio","option","tab","switch","slider","spinbutton","searchbox","scrollbar","treeitem","gridcell"]),ct=new Set(["click","mousedown","mouseup","dblclick","pointerdown","pointerup","touchstart","touchend"]),dn=["[onclick]","[onmousedown]","[ontouchstart]","div","span","li","tr","td","[role]",'[class*="btn"]','[class*="button"]','[class*="click"]',"[data-action]","[data-click]"],un=500});function ws(e,t){return e.length>t?e.slice(0,t)+"...":e}var Ut=y(()=>{"use strict"});var bs,ys,Gt=y(()=>{"use strict";bs=["title","type","checked","name","role","value","placeholder","data-date-format","alt","aria-label","aria-expanded","data-state","aria-checked","data-id","data-testid","data-test-id","data-handlepos","data-item-id"],ys={"react-flow__(\\S+)":"$1"}});var xs,Kt,be,dt=y(()=>{"use strict";Ut();Gt();xs=class{constructor(e,t=null){this.isVisible=e,this.parent=t}},Kt=class extends xs{constructor(e,t,i=null){super(t,i),this.text=e,this.type="TEXT_NODE"}hasParentWithHighlightIndex(){let e=this.parent;for(;e!==null;){if(e.highlightIndex!==null)return!0;e=e.parent}return!1}isParentInViewport(){return this.parent===null?!1:this.parent.isInViewport}isParentTopElement(){return this.parent===null?!1:this.parent.isTopElement}},be=class hn extends xs{constructor(t,i,n,a,o,r=!1,s=!1,l=!1,d=!1,c=!1,u=!1,m=null,g=null,w=null,v=null,x=[],p=null){super(o,p),this.tagName=t,this.xpath=i,this.attributes=n,this.children=a,this.isInteractive=r,this.isScrollable=s,this.markAsClickable=l,this.isTopElement=d,this.isInViewport=c,this.shadowRoot=u,this.highlightIndex=m,this.viewportCoordinates=g,this.pageCoordinates=w,this.viewportInfo=v,this.isNew=null,this.shadowHostXPaths=x}getAllTextTillNextClickableElement(t=-1){let i=[],n=(a,o)=>{if(!(t!==-1&&o>t)&&!(a instanceof hn&&a!==this&&a.highlightIndex!==null)){if(a instanceof Kt)i.push(a.text);else if(a instanceof hn)for(let r of a.children)n(r,o+1)}};return n(this,0),i.join(`
@@ -4432,7 +4432,7 @@ Date: ${m.date}
4432
4432
  Body:
4433
4433
  ${m.body}`,w=await Zm(g,a,t.model);h.info(`Extracted content: ${w}`),w&&w!=="NOT_FOUND"&&u.push({content:w,email_subject:m.subject,email_from:m.from,email_date:m.date})}if(u.length>0){let m=u[0],g=`$email_${t.extraction_type}`;t.extraction_type==="custom"?g="$email_extracted_content":t.extraction_type==="activation_link"?g="$email_magic_link":t.extraction_type==="verification_code"&&(g="$email_otp_code");let w=(new Date().getTime()-o.getTime())/1e3;return h.info(`Successfully extracted content after ${s} attempts in ${w.toFixed(1)} seconds`),{data:m.content,result_variable:g,status:"success",message:`Successfully extracted content from email: ${m.email_subject.substring(0,50)}... (attempts: ${s})`}}else h.info(`Found emails but no extractable content in attempt ${s}`)}else h.info(`No emails found in attempt ${s}`)}catch(d){h.warn(`Error in polling attempt ${s}: ${d.message}`)}if(new Date(Date.now()+n*1e3)>=r){h.info("Not enough time for another polling attempt");break}h.info(`Waiting ${n} seconds before next attempt...`),await new Promise(d=>setTimeout(d,n*1e3))}let l=(new Date().getTime()-o.getTime())/1e3;return{data:void 0,status:"error",message:`No emails with extractable content found after ${s} attempts over ${l.toFixed(1)} seconds`}}catch(a){return h.error(`Error extracting email content: ${a.message}`),{data:void 0,status:"error",message:`Error extracting email content: ${a.message}`}}}var oo=y(()=>{"use strict";ke();N()});import{z as Ae}from"zod";function sc(e){switch(e){case"verification_code":return"email_otp_code";case"activation_link":return"email_magic_link";case"custom":return"email_extracted_content";default:return"email_content"}}function cc(e,t){e.register({name:"extract_email_content",description:"Extract verification codes, magic links, or custom content from emails received via Mailgun. Polls the Mailgun inbox for matching emails and uses AI to extract the requested content.",schema:Qm,async execute(i,n){let{forward_email:a,extraction_type:o,prompt:r,filter_from_email:s,filter_to_email:l,filter_subject:d,filter_body_contains:c,timeout:u}=i,{page:m,agentServices:g}=n;h.info(`[extract_email_content] Extracting ${o} from ${a}`);try{let w={action_description:`Extract ${o} from email`,action_data:{action_name:"extract_email_content",kwargs:{forward_email:a,extraction_type:o,prompt:r,filter_from_email:s,filter_to_email:l,filter_subject:d,filter_body_contains:c,timeout:u}}};await t.execute(m,w,g);let v=sc(o);return{success:!0,actionEntity:w,message:`Extracted ${o} and saved to $${v}`}}catch(w){return{success:!1,error:w.message,actionEntity:{action_description:`Extract ${o} from email (failed)`,action_data:{action_name:"extract_email_content",kwargs:{forward_email:a,extraction_type:o,prompt:r,filter_from_email:s,filter_to_email:l,filter_subject:d,filter_body_contains:c,timeout:u}},feedback:w.message}}}}})}var lc,Qm,ro=y(()=>{"use strict";oo();N();Q();lc=class{getMailgunConfig(){let e=W().env||{};if(e.MAILGUN_API_KEY)return{apiKey:e.MAILGUN_API_KEY,domain:e.MAILGUN_DOMAIN||""}}async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=this.getMailgunConfig();if(!a)throw new Error("Mailgun configuration not provided. Please configure MAILGUN_API_KEY and MAILGUN_DOMAIN in SDK config.");let o=n.kwargs,r=i.getModel?.()||"gemini-2.5-pro",s=await rc(a,{model:r,forward_email:o.forward_email,extraction_type:o.extraction_type,prompt:o.prompt,filters:{from_email:o.filter_from_email,to_email:o.filter_to_email,subject:o.filter_subject,body_contains:o.filter_body_contains},timeout:o.timeout});if(s.status==="success"&&s.data){let l=s.result_variable?.replace(/^\$/,"")||sc(o.extraction_type);i.variableStore.set(l,s.data),h.info(`[extract_email_content] Extracted and saved to ${l}`)}else throw new Error(s.message||"Failed to extract email content")}transpile(e){let t=e.action_data?.kwargs||{};return['await agent.execAction("extract_email_content", page, {',` action_data: { kwargs: ${JSON.stringify(t)} },`,"});"]}},Qm=Ae.object({forward_email:Ae.string().describe("Email address where emails are forwarded to (Mailgun inbox)"),extraction_type:Ae.enum(["verification_code","activation_link","custom"]).describe("Type of content to extract: verification_code for OTP codes, activation_link for magic links, custom for custom prompts"),prompt:Ae.string().optional().describe("Custom extraction prompt (required when extraction_type is custom)"),filter_from_email:Ae.string().optional().describe("Filter emails by sender address"),filter_to_email:Ae.string().optional().describe("Filter emails by recipient address"),filter_subject:Ae.string().optional().describe("Filter emails by subject (partial match)"),filter_body_contains:Ae.string().optional().describe("Filter emails by body content (partial match)"),timeout:Ae.number().optional().describe("Timeout in seconds for polling (default: 60)")})});async function ye(){if(Un)return Un;let e=(await Promise.resolve().then(()=>(wt(),ft))).default;return Un=new e,Un}async function Gn(e){let t=await ye(),i=t.getAction("click"),n=t.getAction("hover"),a=t.getAction("right_click"),o=t.getAction("double_click");return Ol(e,i),Ml(e,n),ml(e,a),Ul(e,o),"Click, hover, double-click, right-click, or drag elements"}async function Kn(e){let t=await ye(),i=t.getAction("go_to_url"),n=t.getAction("go_back"),a=t.getAction("reload_page");return Tl(e,i),El(e,n),ul(e,a),"Navigate to URLs, go back, or reload the page"}async function jn(e){let t=await ye(),i=t.getAction("clear_input"),n=t.getAction("input_text"),a=t.getAction("press");return Ll(e,i),Cl(e,n),cl(e,a),"Type text into inputs, clear input values, or press keyboard keys"}async function zn(e){let t=await ye(),i=t.getAction("scroll_on_element"),n=t.getAction("scroll_to_text"),a=t.getAction("scroll");return Gs(e,i),zs(e,n),fl(e,a),"Scroll the page or scroll to specific text/elements"}async function Vn(e){let t=await ye(),i=t.getAction("close_tab"),n=t.getAction("switch_tab");return Fl(e,i),el(e,n),"Switch between browser tabs or close tabs"}async function Xn(e){let t=await ye(),i=t.getAction("upload_file"),n=t.getAction("wait_for_download_complete");return al(e,i),Fs(e,n),"Upload files or wait for downloads to complete"}async function Yn(e){let t=await ye(),i=t.getAction("get_dropdown_options"),n=t.getAction("select_dropdown_option"),a=t.getAction("set_date_for_native_date_picker");return kl(e,i),Ys(e,n),qs(e,a),"Get dropdown options, select dropdown values, or set date for native date picker input"}async function Jn(e){let t=await ye(),i=t.getAction("wait"),n=t.getAction("save_variable"),a=t.getAction("done");return sl(e,i),gl(e,n),Wl(e,a),oc(e),"Wait for conditions, save variables, or complete tasks"}async function qn(e){let t=(await ye()).getAction("generate_2fa_code");yl(e,t);let i=new lc;return(await Promise.resolve().then(()=>(wt(),ft))).default.registerAction("extract_email_content",i),cc(e,i),"Generate 2FA codes or extract email/activation codes"}async function Zn(e){let t=await ye(),i=t.getAction("verify"),n=t.getAction("ai_extract"),a=t.getAction("ai_wait_until");return jl(e,i),Vl(e,n),Ws(e,a),"Perform AI-powered assertions, extractions, or wait conditions"}async function dc(e){let[t,i,n,a,o,r,s,l,d,c]=await Promise.all([Gn(e),Kn(e),jn(e),zn(e),Vn(e),Xn(e),Yn(e),Jn(e),qn(e),Zn(e)]);return{mouse:t,navigation:i,input:n,scroll:a,tabs:o,files:r,forms:s,utility:l,auth:d,ai:c}}function uc(e){return[`- Mouse: ${e.mouse}`,`- Navigation: ${e.navigation}`,`- Input: ${e.input}`,`- Scroll: ${e.scroll}`,`- Tabs: ${e.tabs}`,`- Files: ${e.files}`,`- Forms: ${e.forms}`,`- Utility: ${e.utility}`,`- Auth: ${e.auth}`,`- AI: ${e.ai}`].join(`
4434
4434
  `)}var Un,so=y(()=>{"use strict";ao();ro();Xt();Yt();qt();Zt();Qt();ei();ti();ni();ai();oi();ri();si();li();di();ui();hi();mi();pi();gi();fi();wi();bi();yi();xi();vi();_i();ki();Un=null});async function hc(){await tp}function mc(){return F}function pc(e=!0){let t=new lt;return e&&(Gn(t),Kn(t),jn(t),zn(t),Vn(t),Xn(t),Yn(t),qn(t),Jn(t),Zn(t)),t}async function gc(){let e=new lt,t=await dc(e),i=uc(t);return{registry:e,capabilities:t,summary:i}}function fc(){return["- Mouse: Click, hover, double-click, right-click or drag on elements","- Navigation: Navigate to URLs, go back, or reload the page","- Input: Type text into inputs, clear input fields, or press keyboard keys","- Scroll: Scroll the page or scroll to specific text/elements","- Tabs: Switch between browser tabs or close tabs","- Files: Upload files or wait for downloads to complete","- Forms: Get dropdown options or select dropdown values","- Utility: Wait for conditions, save variables, or complete tasks","- Auth: Generate 2FA codes or extract email/activation codes","- AI: Perform AI-powered verifications, extractions, or wait conditions"].join(`
4435
- `)}var ep,tp,wc=y(()=>{"use strict";so();Se();ep=[Gn(F),Kn(F),jn(F),zn(F),Vn(F),Xn(F),Yn(F),Jn(F),Zn(F),qn(F)],tp=Promise.all(ep)});function yc(e){return e.getTools().map(t=>({name:t.name,description:t.description,inputSchema:Bi(t.schema)}))}var bc,xc=y(()=>{"use strict";Ct();bc=class{constructor(e,t){this.registry=e,this.getContext=t}getToolDefinitions(){return this.registry.getTools().filter(e=>e.availability.mcp).map(e=>({name:e.name,description:e.description,inputSchema:Bi(e.schema)}))}getToolDefinitionsFiltered(e){let t=new Set(e);return this.registry.getTools().filter(i=>t.has(i.name)&&i.availability.mcp).map(i=>({name:i.name,description:i.description,inputSchema:Bi(i.schema)}))}async createServer(e="web-sdk-tools"){throw new Error("MCP server creation not yet implemented. Install and configure an MCP SDK like @modelcontextprotocol/sdk")}async executeTool(e,t){let i=await this.getContext(),n=await this.registry.execute(e,t,i);return{content:[{type:"text",text:n.success?n.message||"Tool executed successfully":n.error||"Tool execution failed"}]}}getToolCount(){return this.registry.size()}getToolNames(){return this.registry.getToolNames()}}});var vc=y(()=>{"use strict"});function _c(){let e=process.env.SHIPLIGHT_REGISTRY_URL;return e?e.replace(/\/$/,""):null}async function yt(e){let t=_c();if(!t)return null;try{let i=await fetch(`${t}/browsers`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)});return i.ok?(await i.json()).id??null:null}catch{return null}}async function xt(e){if(!e)return;let t=_c();if(t)try{await fetch(`${t}/browsers/${encodeURIComponent(e)}`,{method:"DELETE"})}catch{}}var lo=y(()=>{"use strict"});import{z as T}from"zod";import"yaml";import"uuid";import"yaml";import"uuid";function ia(e,t){if(!e||typeof e!="string")return e;let i=t instanceof Map?Object.fromEntries(t):t,n=o=>{let r=o.startsWith("$")?o.slice(1):o,s=i[r]??i[`$${r}`];return s!=null?String(s):void 0},a=e;return a=a.replace(/\{\{\s*\$?([^}]+?)\s*\}\}/g,(o,r)=>{let s=n(r.trim());return s!==void 0?s:o}),a=a.replace(/<secret>\$?([\w-]+)<\/secret>/g,(o,r)=>{let s=n(r);return s!==void 0?s:o}),a=a.replace(/\$\{([^}]+)\}/g,(o,r)=>{let s=n(r.trim());return s!==void 0?s:o}),a=a.replace(/\$([a-zA-Z_]\w*)/g,(o,r)=>{let s=n(r);return s!==void 0?s:o}),a}var ip,ea,np,ap,op,rp,sp,lp,cp,dp,Xe,vt,Sc,up,Qn,Ai,Zk,Qk,ta,Ec,Tc,Ac,Mc,Mi,co,uo,hp,kc,mp,Ti,pp,gp,fp,ne,wp,bp,tS,hS,_t=y(()=>{"use strict";me();ip="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36",ea=112,np=1920,ap=1080,op=1920,rp=1080-ea,sp=1280,lp=720,cp=500,dp=500,Xe="Desktop Chrome",vt=(e=>(e.Chromium="chromium",e.Firefox="firefox",e.Webkit="webkit",e))(vt||{}),Sc={"Blackberry PlayBook":{name:"Blackberry PlayBook",userAgent:"Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML like Gecko) Version/26.0 Safari/536.2+",screen:{width:600,height:1024},viewport:{width:600,height:1024},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"BlackBerry Z30":{name:"BlackBerry Z30",userAgent:"Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/26.0 Mobile Safari/537.10+",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note 3":{name:"Galaxy Note 3",userAgent:"Mozilla/5.0 (Linux; U; Android 4.3; en-us; SM-N900T Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note II":{name:"Galaxy Note II",userAgent:"Mozilla/5.0 (Linux; U; Android 4.1; en-us; GT-N7100 Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S III":{name:"Galaxy S III",userAgent:"Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S5":{name:"Galaxy S5",userAgent:"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S8":{name:"Galaxy S8",userAgent:"Mozilla/5.0 (Linux; Android 7.0; SM-G950U Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:740},viewport:{width:360,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S9+":{name:"Galaxy S9+",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; SM-G965U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:320,height:658},viewport:{width:320,height:658},deviceScaleFactor:4.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S24":{name:"Galaxy S24",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-S921U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:780},viewport:{width:360,height:780},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy A55":{name:"Galaxy A55",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-A556B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:480,height:1040},viewport:{width:480,height:1040},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S4":{name:"Galaxy Tab S4",userAgent:"Mozilla/5.0 (Linux; Android 8.1.0; SM-T837A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:712,height:1138},viewport:{width:712,height:1138},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S9":{name:"Galaxy Tab S9",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-X710) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:640,height:1024},viewport:{width:640,height:1024},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"iPad (gen 5)":{name:"iPad (gen 5)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 6)":{name:"iPad (gen 6)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 7)":{name:"iPad (gen 7)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:810,height:1080},viewport:{width:810,height:1080},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 11)":{name:"iPad (gen 11)",userAgent:"Mozilla/5.0 (iPad; CPU OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/604.1",screen:{width:656,height:944},viewport:{width:656,height:944},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Mini":{name:"iPad Mini",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Pro 11":{name:"iPad Pro 11",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:834,height:1194},viewport:{width:834,height:1194},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6":{name:"iPhone 6",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6 Plus":{name:"iPhone 6 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7":{name:"iPhone 7",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7 Plus":{name:"iPhone 7 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8":{name:"iPhone 8",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8 Plus":{name:"iPhone 8 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE":{name:"iPhone SE",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/14E304 Safari/602.1",screen:{width:320,height:568},viewport:{width:320,height:568},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE (3rd gen)":{name:"iPhone SE (3rd gen)",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/602.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone X":{name:"iPhone X",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:812},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone XR":{name:"iPhone XR",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:896},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11":{name:"iPhone 11",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro":{name:"iPhone 11 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:635},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro Max":{name:"iPhone 11 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12":{name:"iPhone 12",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro":{name:"iPhone 12 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro Max":{name:"iPhone 12 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Mini":{name:"iPhone 12 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13":{name:"iPhone 13",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro":{name:"iPhone 13 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro Max":{name:"iPhone 13 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Mini":{name:"iPhone 13 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14":{name:"iPhone 14",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Plus":{name:"iPhone 14 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro":{name:"iPhone 14 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:660},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro Max":{name:"iPhone 14 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15":{name:"iPhone 15",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Plus":{name:"iPhone 15 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro":{name:"iPhone 15 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro Max":{name:"iPhone 15 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Kindle Fire HDX":{name:"Kindle Fire HDX",userAgent:"Mozilla/5.0 (Linux; U; en-us; KFAPWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"LG Optimus L70":{name:"LG Optimus L70",userAgent:"Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; LGMS323 Build/KOT49I.MS32310c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:1.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 550":{name:"Microsoft Lumia 550",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 550) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 950":{name:"Microsoft Lumia 950",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:4,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 10":{name:"Nexus 10",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 10 Build/MOB31T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 4":{name:"Nexus 4",userAgent:"Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5":{name:"Nexus 5",userAgent:"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5X":{name:"Nexus 5X",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR4.170623.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6":{name:"Nexus 6",userAgent:"Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F26U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6P":{name:"Nexus 6P",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 6P Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 7":{name:"Nexus 7",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MOB30X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:600,height:960},viewport:{width:600,height:960},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia Lumia 520":{name:"Nokia Lumia 520",userAgent:"Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 520)",screen:{width:320,height:533},viewport:{width:320,height:533},deviceScaleFactor:1.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia N9":{name:"Nokia N9",userAgent:"Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13",screen:{width:480,height:854},viewport:{width:480,height:854},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Pixel 2":{name:"Pixel 2",userAgent:"Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:731},viewport:{width:411,height:731},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 2 XL":{name:"Pixel 2 XL",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:823},viewport:{width:411,height:823},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 3":{name:"Pixel 3",userAgent:"Mozilla/5.0 (Linux; Android 9; Pixel 3 Build/PQ1A.181105.017.A1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:786},viewport:{width:393,height:786},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4":{name:"Pixel 4",userAgent:"Mozilla/5.0 (Linux; Android 10; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:353,height:745},viewport:{width:353,height:745},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4a (5G)":{name:"Pixel 4a (5G)",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 4a (5G)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:892},viewport:{width:412,height:765},deviceScaleFactor:2.63,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 5":{name:"Pixel 5",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:851},viewport:{width:393,height:727},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 7":{name:"Pixel 7",userAgent:"Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:915},viewport:{width:412,height:839},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Moto G4":{name:"Moto G4",userAgent:"Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Desktop Chrome HiDPI":{name:"Desktop Chrome HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge HiDPI":{name:"Desktop Edge HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Firefox HiDPI":{name:"Desktop Firefox HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"},"Desktop Safari":{name:"Desktop Safari",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Safari/605.1.15",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"webkit"},"Desktop Chrome":{name:"Desktop Chrome",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome Medium Resolution":{name:"Desktop Chrome Medium Resolution",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome (Branded)":{name:"Desktop Chrome (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Chrome Medium Resolution (Branded)":{name:"Desktop Chrome Medium Resolution (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Edge":{name:"Desktop Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge (Branded)":{name:"Desktop Edge (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Edge Medium Resolution (Branded)":{name:"Desktop Edge Medium Resolution (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Firefox":{name:"Desktop Firefox",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"}},up={desktop:["Desktop Chrome","Desktop Chrome Medium Resolution","Desktop Chrome (Branded)","Desktop Chrome Medium Resolution (Branded)","Desktop Edge (Branded)","Desktop Edge Medium Resolution (Branded)","Desktop Safari"],mobile:["iPhone 15 Pro Max","iPhone 15 Pro","iPhone 15 Plus","iPhone 15","iPhone 14 Pro Max","iPhone 14 Pro","iPhone 14 Plus","iPhone 14","iPhone 13 Pro Max","iPhone 13 Pro","iPhone 13","iPhone 13 Mini","iPhone 12 Pro Max","iPhone 12 Pro","iPhone 12","iPhone 12 Mini","iPhone 11 Pro Max","iPhone 11 Pro","iPhone 11","iPhone XR","iPhone X","iPhone SE (3rd gen)","iPhone SE","iPhone 8 Plus","iPhone 8","iPhone 7 Plus","iPhone 7","iPhone 6 Plus","iPhone 6","Galaxy S24","Galaxy A55","Galaxy S9+","Galaxy S8","Galaxy S5","Galaxy Note 3","Galaxy Note II","Galaxy S III","Pixel 7","Pixel 5","Pixel 4a (5G)","Pixel 4","Pixel 3","Pixel 2 XL","Pixel 2","Nexus 6P","Nexus 6","Nexus 5X","Nexus 5","Nexus 4","Moto G4","LG Optimus L70","Microsoft Lumia 950","Microsoft Lumia 550","Nokia Lumia 520","Nokia N9","BlackBerry Z30"]},Qn=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),up[e].map(n=>Sc[n]).filter(n=>n.defaultBrowserType&&i.includes(n.defaultBrowserType))},Ai=e=>Sc[e],Zk={desktop:{label:"Desktop",type:"desktop",devices:Qn("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:Qn("mobile")}},Qk={desktop:{label:"Desktop",type:"desktop",devices:Qn("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:Qn("mobile",!0)}},ta=(e,t=!1)=>{let i={userAgent:ip,viewport:{width:op,height:rp},isMobile:!1,hasTouch:!1};if(!e||e===Xe)return i;let n=Ai(e);if(!n)return i;let{width:a,height:o}=n.viewport,r=Math.max(cp/a,1),s=Math.max(dp/o,1),l=Math.max(r,s),d={width:Math.round(a*l),height:Math.round(o*l)};return{userAgent:n.userAgent,viewport:t?d:n.viewport,isMobile:n.isMobile,hasTouch:n.hasTouch}},Ec=e=>{let t={width:np,height:ap};if(!e||e===Xe)return t;let i=ta(e);return i.viewport?{width:i.viewport.width,height:i.viewport.height+ea}:t},Tc=e=>{let t={width:sp,height:lp};if(!e||e===Xe)return t;let i=ta(e);return i.viewport?{width:i.viewport.width,height:i.viewport.height}:t},Ac=e=>!e||e===Xe?void 0:Ai(e)?.channel,Mc=e=>!e||e===Xe?"chromium":Ai(e)?.defaultBrowserType??"chromium",Mi=(e=>(e.PASSWORD="password",e.OAUTH2="oauth2",e.SSO="sso",e.API="api",e))(Mi||{}),co=(e=>(e.SMS="sms",e.EMAIL="email",e.TOTP="totp",e))(co||{});uo=class Ic{constructor(){Aa(this,"data",{}),Aa(this,"sensitive",new Set)}get(t){return this.data[t]}set(t,i,n=!1){this.data[t]=i,n?this.sensitive.add(t):this.sensitive.has(t)&&this.sensitive.delete(t)}getAll(){return{...this.data}}isSensitive(t){return this.sensitive.has(t)}getAllSensitiveKeys(){return new Set(this.sensitive)}delete(t){return this.sensitive.delete(t),delete this.data[t]}clear(){this.data={},this.sensitive.clear()}has(t){return t in this.data}get size(){return Object.keys(this.data).length}merge(t){for(let[i,n]of Object.entries(t.getAll()))this.set(i,n,t.isSensitive(i))}toJSON(){return{data:{...this.data},sensitiveKeys:Array.from(this.sensitive)}}static fromJSON(t){let i=new Ic;if(t.data){let n=new Set(t.sensitiveKeys||[]);for(let[a,o]of Object.entries(t.data))i.set(a,o,n.has(a))}return i}},hp=T.enum(["JS_CODE","AI_MODE"]),kc=T.object({type:hp,expression:T.string()}),mp=T.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),Ti=T.object({uid:T.string(),type:mp,comment:T.string().optional()}),pp=T.object({action_data:T.object({action_name:T.string(),kwargs:T.record(T.any()).optional(),args:T.array(T.any()).optional()}),action_description:T.string().optional(),url:T.string().optional(),xpath:T.string().nullable().optional(),locator:T.string().nullable().optional(),css_selector:T.string().nullable().optional(),unique_selector:T.string().nullable().optional(),element_index:T.number().nullable().optional(),frame_path:T.array(T.any()).optional(),artifacts:T.record(T.any()).optional(),feedback:T.string().optional(),original_browser_use_action:T.any().optional()}).passthrough(),gp=Ti.extend({type:T.literal("DRAFT"),description:T.string()}),fp=Ti.extend({type:T.literal("ACTION"),description:T.string(),action_entity:pp.optional(),locator:T.string().optional(),use_pure_vision:T.boolean().optional()}),ne=T.lazy(()=>T.union([gp,fp,Ti.extend({type:T.literal("STEP"),description:T.string().optional().default(""),statements:T.array(ne),reference_id:T.number().optional(),template_path:T.string().optional(),template_params:T.record(T.string()).optional()}),Ti.extend({type:T.literal("IF_ELSE"),description:T.string().optional(),condition:kc,then:T.array(ne),else:T.array(ne).optional()}),Ti.extend({type:T.literal("WHILE_LOOP"),description:T.string().optional(),condition:kc,body:T.array(ne),timeout_ms:T.number().optional()})])),wp=T.object({name:T.string(),statements:T.array(ne),teardown:T.array(ne).optional(),skip:T.union([T.boolean(),T.string()]).optional(),timeout:T.number().optional(),fail:T.union([T.boolean(),T.string()]).optional(),only:T.boolean().optional(),slow:T.boolean().optional()}),bp=T.object({tests:T.array(wp).min(1),beforeAll:T.array(ne).optional(),afterAll:T.array(ne).optional(),beforeEach:T.array(ne).optional(),afterEach:T.array(ne).optional()}),tS=T.object({comment:T.string().optional(),version:T.string().optional(),goal:T.string().optional(),url:T.string().optional(),baseURL:T.string().optional(),final_feedback:T.string().optional(),completed:T.boolean().optional(),success:T.boolean().optional(),statements:T.array(ne).optional(),teardown:T.array(ne).optional(),last_modified_at:T.string().optional(),testGroup:bp.optional()}).refine(e=>e.testGroup!==void 0?e.goal===void 0&&(e.statements===void 0||e.statements.length===0):e.goal!==void 0,{message:"TestFlow must have either goal/statements (single test) or testGroup (suite), not both"}),hS=1024*1024});import Ye from"fs";import yp from"os";import Ii from"path";import{chromium as Cc,firefox as xp,webkit as vp}from"playwright";async function _p(e,t){let i=JSON.parse(Ye.readFileSync(t,"utf-8"));i.cookies?.length&&await e.addCookies(i.cookies)}var Pc,$c=y(()=>{"use strict";lo();_t();Te();bt();N();Pc=class{constructor(e={}){e.testDir&&(this.testDir=e.testDir,this.videoBasePath=Ii.join(e.testDir,"videos"),this.statesBasePath=Ii.join(e.testDir,"states"),this.downloadsBasePath=Ii.join(e.testDir,"downloads"),Ye.mkdirSync(this.videoBasePath,{recursive:!0}),Ye.mkdirSync(this.statesBasePath,{recursive:!0}),Ye.mkdirSync(this.downloadsBasePath,{recursive:!0})),this.terminationTimeout=e.terminationTimeout??null,this.defaultHeadless=e.headless??!1,this.additionalArgs=e.additionalArgs??[]}async launchBrowser(e={}){let t=e.debugPort,i=e.headless??this.defaultHeadless,n=Mc(e.deviceName),a=Ac(e.deviceName),o=n===vt.Chromium,r=!!e.extensionPath;h.info(`[BrowserManager] Launching ${n} browser for device: ${e.deviceName||"default"}${t?` on port ${t}`:""}`);let s={headless:i};if(o){r&&i&&(h.warn("[BrowserManager] Extension requested in headless mode; forcing headed mode to load extension."),i=!1,s.headless=!1);let k=[];(e.enableCamera||e.enableMicrophone)&&(k.push("--use-fake-device-for-media-stream","--use-fake-ui-for-media-stream"),e.enableMicrophone&&e.fakeAudioCapturePath&&(k.push(`--use-file-for-fake-audio-capture=${e.fakeAudioCapturePath}`),h.info(`[BrowserManager] Using fake audio capture file: ${e.fakeAudioCapturePath}`)));let E=r&&e.extensionPath?[`--disable-extensions-except=${e.extensionPath}`,`--load-extension=${e.extensionPath}`]:[];s.args=[...Yl(t,e.disableSecurity??!0,i),...k,...E,...this.additionalArgs],a&&(s.channel=a,h.debug(`[BrowserManager] Launching browser with channel: ${a}`))}let l=ta(e.deviceName),d=Tc(e.deviceName),c={acceptDownloads:!0,...l,timezoneId:e.timezoneId||"America/Los_Angeles",locale:e.locale||"en-US"};e.viewport&&(c.viewport=e.viewport,c.screen=e.viewport),e.isMobile!==void 0&&(c.isMobile=e.isMobile),e.hasTouch!==void 0&&(c.hasTouch=e.hasTouch),e.userAgent&&(c.userAgent=e.userAgent),e.colorScheme&&(c.colorScheme=e.colorScheme),e.geolocation&&(c.geolocation=e.geolocation,c.permissions=[...c.permissions||[],"geolocation"]);let u=r&&o?e.localStorageStatePath:void 0;e.localStorageStatePath&&!u&&(c.storageState=e.localStorageStatePath),e.recordVideo&&this.videoBasePath&&(c.recordVideo={dir:this.videoBasePath,size:{width:d.width,height:d.height}}),e.proxy&&(c.proxy=e.proxy),e.extraHTTPHeaders&&Object.keys(e.extraHTTPHeaders).length>0&&(c.extraHTTPHeaders=e.extraHTTPHeaders);let m,g,w,v=!1;if(o&&(r||e.userDataDir)){if(e.userDataDir)w=e.userDataDir;else{let E=this.testDir||Ye.mkdtempSync(Ii.join(yp.tmpdir(),"shiplight-"));w=Ii.join(E,`ext-profile-${Date.now()}`),Ye.mkdirSync(w,{recursive:!0}),v=!0}let k={...s,...c};g=await Cc.launchPersistentContext(w,k),u&&(await _p(g,u),h.info(`[BrowserManager] Loaded storage state into persistent context from ${u}`)),m=g.browser(),h.info(`[BrowserManager] Launched persistent context${e.extensionPath?` for extension at ${e.extensionPath}`:` with profile at ${w}`}`)}else{switch(n){case vt.Firefox:m=await xp.launch(s);break;case vt.Webkit:m=await vp.launch(s);break;case vt.Chromium:default:m=await Cc.launch(s);break}g=await m.newContext(c)}if(g.addInitScript(De),o){let k=["clipboard-read","clipboard-write"];e.enableCamera&&k.push("camera"),e.enableMicrophone&&k.push("microphone");try{await g.grantPermissions(k),h.info(`[BrowserManager] Granted permissions: ${k.join(", ")}`)}catch(E){h.warn("[BrowserManager] Failed to grant permissions:",E)}}else(e.enableCamera||e.enableMicrophone)&&h.warn("[BrowserManager] Camera/microphone enabled but browser is not Chromium; ignoring.");if(e.cookies&&e.cookies.length>0){let k=(Date.now()+31536e6)/1e3,E=e.cookies.map(I=>({...I,expires:k}));await g.addCookies(E),h.info(`[BrowserManager] Added ${e.cookies.length} cookies to browser context with expires=${k}`)}let x=e.viewport,p=x?{width:x.width,height:x.height+ea}:Ec(e.deviceName);if(h.info(`[BrowserManager] windowSize=${JSON.stringify(p)}`),o){let k=async E=>{try{await Wn(E,p.width,p.height),x&&await E.setViewportSize(x)}catch(I){h.warn("[BrowserManager] Failed to set window bounds via CDP:",I)}};for(let E of g.pages())await k(E);g.on("page",k)}let f="";if(o&&t!==void 0)try{f=await Hn(t)}catch(k){h.warn("[BrowserManager] Failed to get CDP WebSocket URL:",k)}let S=null;f&&(S=await yt({cdpUrl:f,label:`agent ${e.deviceName??n}`,pid:process.pid}),S&&h.info(`[BrowserManager] Registered browser with dev-box registry id=${S}`));let _={debugPort:t,browser:m,context:g,startTime:new Date,timeout:null,browserWsUrl:f,downloadsBasePath:this.downloadsBasePath,browserType:n,userDataDir:w,isTempUserDataDir:v,registryId:S};if(this.terminationTimeout!==null){let k=setTimeout(()=>{h.info(`[BrowserManager] Browser auto-terminated after ${this.terminationTimeout}ms`),this.terminateBrowser(_).catch(E=>h.error("[BrowserManager] Error terminating browser:",E))},this.terminationTimeout);_.timeout=k}return _}async terminateBrowser(e){if(e.timeout&&clearTimeout(e.timeout),await xt(e.registryId??null),await e.context.close(),await e.browser.close(),e.isTempUserDataDir&&e.userDataDir)try{Ye.rmSync(e.userDataDir,{recursive:!0,force:!0})}catch(t){h.warn("[BrowserManager] Failed to clean up temp user data dir:",e.userDataDir,t)}}getVideoBasePath(){return this.videoBasePath}getStatesBasePath(){return this.statesBasePath}getDownloadsBasePath(){return this.downloadsBasePath}}});import{execFileSync as kp}from"child_process";import*as Lc from"fs";import*as Dc from"path";function Sp(e){let t=kp("ps",["-axo","pid=,ppid=,args="],{encoding:"utf-8"}),i=[];for(let o of t.split(`
4435
+ `)}var ep,tp,wc=y(()=>{"use strict";so();Se();ep=[Gn(F),Kn(F),jn(F),zn(F),Vn(F),Xn(F),Yn(F),Jn(F),Zn(F),qn(F)],tp=Promise.all(ep)});function yc(e){return e.getTools().map(t=>({name:t.name,description:t.description,inputSchema:Bi(t.schema)}))}var bc,xc=y(()=>{"use strict";Ct();bc=class{constructor(e,t){this.registry=e,this.getContext=t}getToolDefinitions(){return this.registry.getTools().filter(e=>e.availability.mcp).map(e=>({name:e.name,description:e.description,inputSchema:Bi(e.schema)}))}getToolDefinitionsFiltered(e){let t=new Set(e);return this.registry.getTools().filter(i=>t.has(i.name)&&i.availability.mcp).map(i=>({name:i.name,description:i.description,inputSchema:Bi(i.schema)}))}async createServer(e="web-sdk-tools"){throw new Error("MCP server creation not yet implemented. Install and configure an MCP SDK like @modelcontextprotocol/sdk")}async executeTool(e,t){let i=await this.getContext(),n=await this.registry.execute(e,t,i);return{content:[{type:"text",text:n.success?n.message||"Tool executed successfully":n.error||"Tool execution failed"}]}}getToolCount(){return this.registry.size()}getToolNames(){return this.registry.getToolNames()}}});var vc=y(()=>{"use strict"});function _c(){let e=process.env.SHIPLIGHT_REGISTRY_URL;return e?e.replace(/\/$/,""):null}async function yt(e){let t=_c();if(!t)return null;try{let i=await fetch(`${t}/browsers`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)});return i.ok?(await i.json()).id??null:null}catch{return null}}async function xt(e){if(!e)return;let t=_c();if(t)try{await fetch(`${t}/browsers/${encodeURIComponent(e)}`,{method:"DELETE"})}catch{}}var lo=y(()=>{"use strict"});import"uuid";import{z as T}from"zod";import"yaml";import"uuid";import"yaml";function ea(e,t){if(!e||typeof e!="string")return e;let i=t instanceof Map?Object.fromEntries(t):t,n=o=>{let r=o.startsWith("$")?o.slice(1):o,s=i[r]??i[`$${r}`];return s!=null?String(s):void 0},a=e;return a=a.replace(/\{\{\s*\$?([^}]+?)\s*\}\}/g,(o,r)=>{let s=n(r.trim());return s!==void 0?s:o}),a=a.replace(/<secret>\$?([\w-]+)<\/secret>/g,(o,r)=>{let s=n(r);return s!==void 0?s:o}),a=a.replace(/\$\{([^}]+)\}/g,(o,r)=>{let s=n(r.trim());return s!==void 0?s:o}),a=a.replace(/\$([a-zA-Z_]\w*)/g,(o,r)=>{let s=n(r);return s!==void 0?s:o}),a}var ip,ta,np,ap,op,rp,sp,lp,cp,dp,Xe,vt,Sc,up,Qn,Ai,Zk,Qk,ia,Ec,Tc,Ac,Mc,Mi,co,uo,hp,kc,mp,Ti,pp,gp,fp,ne,wp,bp,nS,pS,_t=y(()=>{"use strict";me();ip="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36",ta=112,np=1920,ap=1080,op=1920,rp=1080-ta,sp=1280,lp=720,cp=500,dp=500,Xe="Desktop Chrome",vt=(e=>(e.Chromium="chromium",e.Firefox="firefox",e.Webkit="webkit",e))(vt||{}),Sc={"Blackberry PlayBook":{name:"Blackberry PlayBook",userAgent:"Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML like Gecko) Version/26.0 Safari/536.2+",screen:{width:600,height:1024},viewport:{width:600,height:1024},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"BlackBerry Z30":{name:"BlackBerry Z30",userAgent:"Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/26.0 Mobile Safari/537.10+",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note 3":{name:"Galaxy Note 3",userAgent:"Mozilla/5.0 (Linux; U; Android 4.3; en-us; SM-N900T Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note II":{name:"Galaxy Note II",userAgent:"Mozilla/5.0 (Linux; U; Android 4.1; en-us; GT-N7100 Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S III":{name:"Galaxy S III",userAgent:"Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S5":{name:"Galaxy S5",userAgent:"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S8":{name:"Galaxy S8",userAgent:"Mozilla/5.0 (Linux; Android 7.0; SM-G950U Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:740},viewport:{width:360,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S9+":{name:"Galaxy S9+",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; SM-G965U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:320,height:658},viewport:{width:320,height:658},deviceScaleFactor:4.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S24":{name:"Galaxy S24",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-S921U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:780},viewport:{width:360,height:780},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy A55":{name:"Galaxy A55",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-A556B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:480,height:1040},viewport:{width:480,height:1040},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S4":{name:"Galaxy Tab S4",userAgent:"Mozilla/5.0 (Linux; Android 8.1.0; SM-T837A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:712,height:1138},viewport:{width:712,height:1138},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S9":{name:"Galaxy Tab S9",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-X710) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:640,height:1024},viewport:{width:640,height:1024},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"iPad (gen 5)":{name:"iPad (gen 5)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 6)":{name:"iPad (gen 6)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 7)":{name:"iPad (gen 7)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:810,height:1080},viewport:{width:810,height:1080},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 11)":{name:"iPad (gen 11)",userAgent:"Mozilla/5.0 (iPad; CPU OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/604.1",screen:{width:656,height:944},viewport:{width:656,height:944},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Mini":{name:"iPad Mini",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Pro 11":{name:"iPad Pro 11",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:834,height:1194},viewport:{width:834,height:1194},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6":{name:"iPhone 6",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6 Plus":{name:"iPhone 6 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7":{name:"iPhone 7",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7 Plus":{name:"iPhone 7 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8":{name:"iPhone 8",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8 Plus":{name:"iPhone 8 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE":{name:"iPhone SE",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/14E304 Safari/602.1",screen:{width:320,height:568},viewport:{width:320,height:568},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE (3rd gen)":{name:"iPhone SE (3rd gen)",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/602.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone X":{name:"iPhone X",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:812},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone XR":{name:"iPhone XR",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:896},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11":{name:"iPhone 11",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro":{name:"iPhone 11 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:635},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro Max":{name:"iPhone 11 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12":{name:"iPhone 12",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro":{name:"iPhone 12 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro Max":{name:"iPhone 12 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Mini":{name:"iPhone 12 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13":{name:"iPhone 13",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro":{name:"iPhone 13 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro Max":{name:"iPhone 13 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Mini":{name:"iPhone 13 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14":{name:"iPhone 14",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Plus":{name:"iPhone 14 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro":{name:"iPhone 14 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:660},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro Max":{name:"iPhone 14 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15":{name:"iPhone 15",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Plus":{name:"iPhone 15 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro":{name:"iPhone 15 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro Max":{name:"iPhone 15 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Kindle Fire HDX":{name:"Kindle Fire HDX",userAgent:"Mozilla/5.0 (Linux; U; en-us; KFAPWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"LG Optimus L70":{name:"LG Optimus L70",userAgent:"Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; LGMS323 Build/KOT49I.MS32310c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:1.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 550":{name:"Microsoft Lumia 550",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 550) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 950":{name:"Microsoft Lumia 950",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:4,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 10":{name:"Nexus 10",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 10 Build/MOB31T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 4":{name:"Nexus 4",userAgent:"Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5":{name:"Nexus 5",userAgent:"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5X":{name:"Nexus 5X",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR4.170623.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6":{name:"Nexus 6",userAgent:"Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F26U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6P":{name:"Nexus 6P",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 6P Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 7":{name:"Nexus 7",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MOB30X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:600,height:960},viewport:{width:600,height:960},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia Lumia 520":{name:"Nokia Lumia 520",userAgent:"Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 520)",screen:{width:320,height:533},viewport:{width:320,height:533},deviceScaleFactor:1.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia N9":{name:"Nokia N9",userAgent:"Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13",screen:{width:480,height:854},viewport:{width:480,height:854},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Pixel 2":{name:"Pixel 2",userAgent:"Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:731},viewport:{width:411,height:731},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 2 XL":{name:"Pixel 2 XL",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:823},viewport:{width:411,height:823},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 3":{name:"Pixel 3",userAgent:"Mozilla/5.0 (Linux; Android 9; Pixel 3 Build/PQ1A.181105.017.A1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:786},viewport:{width:393,height:786},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4":{name:"Pixel 4",userAgent:"Mozilla/5.0 (Linux; Android 10; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:353,height:745},viewport:{width:353,height:745},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4a (5G)":{name:"Pixel 4a (5G)",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 4a (5G)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:892},viewport:{width:412,height:765},deviceScaleFactor:2.63,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 5":{name:"Pixel 5",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:851},viewport:{width:393,height:727},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 7":{name:"Pixel 7",userAgent:"Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:915},viewport:{width:412,height:839},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Moto G4":{name:"Moto G4",userAgent:"Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Desktop Chrome HiDPI":{name:"Desktop Chrome HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge HiDPI":{name:"Desktop Edge HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Firefox HiDPI":{name:"Desktop Firefox HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"},"Desktop Safari":{name:"Desktop Safari",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Safari/605.1.15",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"webkit"},"Desktop Chrome":{name:"Desktop Chrome",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome Medium Resolution":{name:"Desktop Chrome Medium Resolution",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome (Branded)":{name:"Desktop Chrome (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Chrome Medium Resolution (Branded)":{name:"Desktop Chrome Medium Resolution (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Edge":{name:"Desktop Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge (Branded)":{name:"Desktop Edge (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Edge Medium Resolution (Branded)":{name:"Desktop Edge Medium Resolution (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Firefox":{name:"Desktop Firefox",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"}},up={desktop:["Desktop Chrome","Desktop Chrome Medium Resolution","Desktop Chrome (Branded)","Desktop Chrome Medium Resolution (Branded)","Desktop Edge (Branded)","Desktop Edge Medium Resolution (Branded)","Desktop Safari"],mobile:["iPhone 15 Pro Max","iPhone 15 Pro","iPhone 15 Plus","iPhone 15","iPhone 14 Pro Max","iPhone 14 Pro","iPhone 14 Plus","iPhone 14","iPhone 13 Pro Max","iPhone 13 Pro","iPhone 13","iPhone 13 Mini","iPhone 12 Pro Max","iPhone 12 Pro","iPhone 12","iPhone 12 Mini","iPhone 11 Pro Max","iPhone 11 Pro","iPhone 11","iPhone XR","iPhone X","iPhone SE (3rd gen)","iPhone SE","iPhone 8 Plus","iPhone 8","iPhone 7 Plus","iPhone 7","iPhone 6 Plus","iPhone 6","Galaxy S24","Galaxy A55","Galaxy S9+","Galaxy S8","Galaxy S5","Galaxy Note 3","Galaxy Note II","Galaxy S III","Pixel 7","Pixel 5","Pixel 4a (5G)","Pixel 4","Pixel 3","Pixel 2 XL","Pixel 2","Nexus 6P","Nexus 6","Nexus 5X","Nexus 5","Nexus 4","Moto G4","LG Optimus L70","Microsoft Lumia 950","Microsoft Lumia 550","Nokia Lumia 520","Nokia N9","BlackBerry Z30"]},Qn=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),up[e].map(n=>Sc[n]).filter(n=>n.defaultBrowserType&&i.includes(n.defaultBrowserType))},Ai=e=>Sc[e],Zk={desktop:{label:"Desktop",type:"desktop",devices:Qn("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:Qn("mobile")}},Qk={desktop:{label:"Desktop",type:"desktop",devices:Qn("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:Qn("mobile",!0)}},ia=(e,t=!1)=>{let i={userAgent:ip,viewport:{width:op,height:rp},isMobile:!1,hasTouch:!1};if(!e||e===Xe)return i;let n=Ai(e);if(!n)return i;let{width:a,height:o}=n.viewport,r=Math.max(cp/a,1),s=Math.max(dp/o,1),l=Math.max(r,s),d={width:Math.round(a*l),height:Math.round(o*l)};return{userAgent:n.userAgent,viewport:t?d:n.viewport,isMobile:n.isMobile,hasTouch:n.hasTouch}},Ec=e=>{let t={width:np,height:ap};if(!e||e===Xe)return t;let i=ia(e);return i.viewport?{width:i.viewport.width,height:i.viewport.height+ta}:t},Tc=e=>{let t={width:sp,height:lp};if(!e||e===Xe)return t;let i=ia(e);return i.viewport?{width:i.viewport.width,height:i.viewport.height}:t},Ac=e=>!e||e===Xe?void 0:Ai(e)?.channel,Mc=e=>!e||e===Xe?"chromium":Ai(e)?.defaultBrowserType??"chromium",Mi=(e=>(e.PASSWORD="password",e.OAUTH2="oauth2",e.SSO="sso",e.API="api",e))(Mi||{}),co=(e=>(e.SMS="sms",e.EMAIL="email",e.TOTP="totp",e))(co||{}),uo=class Ic{constructor(){Aa(this,"data",{}),Aa(this,"sensitive",new Set)}get(t){return this.data[t]}set(t,i,n=!1){this.data[t]=i,n?this.sensitive.add(t):this.sensitive.has(t)&&this.sensitive.delete(t)}getAll(){return{...this.data}}isSensitive(t){return this.sensitive.has(t)}getAllSensitiveKeys(){return new Set(this.sensitive)}delete(t){return this.sensitive.delete(t),delete this.data[t]}clear(){this.data={},this.sensitive.clear()}has(t){return t in this.data}get size(){return Object.keys(this.data).length}merge(t){for(let[i,n]of Object.entries(t.getAll()))this.set(i,n,t.isSensitive(i))}toJSON(){return{data:{...this.data},sensitiveKeys:Array.from(this.sensitive)}}static fromJSON(t){let i=new Ic;if(t.data){let n=new Set(t.sensitiveKeys||[]);for(let[a,o]of Object.entries(t.data))i.set(a,o,n.has(a))}return i}},hp=T.enum(["JS_CODE","AI_MODE"]),kc=T.object({type:hp,expression:T.string()}),mp=T.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),Ti=T.object({uid:T.string(),type:mp,comment:T.string().optional()}),pp=T.object({action_data:T.object({action_name:T.string(),kwargs:T.record(T.any()).optional(),args:T.array(T.any()).optional()}),action_description:T.string().optional(),url:T.string().optional(),xpath:T.string().nullable().optional(),locator:T.string().nullable().optional(),css_selector:T.string().nullable().optional(),unique_selector:T.string().nullable().optional(),element_index:T.number().nullable().optional(),frame_path:T.array(T.any()).optional(),artifacts:T.record(T.any()).optional(),feedback:T.string().optional(),original_browser_use_action:T.any().optional()}).passthrough(),gp=Ti.extend({type:T.literal("DRAFT"),description:T.string()}),fp=Ti.extend({type:T.literal("ACTION"),description:T.string(),action_entity:pp.optional(),locator:T.string().optional(),use_pure_vision:T.boolean().optional()}),ne=T.lazy(()=>T.union([gp,fp,Ti.extend({type:T.literal("STEP"),description:T.string().optional().default(""),statements:T.array(ne),reference_id:T.number().optional(),template_path:T.string().optional(),template_params:T.record(T.string()).optional()}),Ti.extend({type:T.literal("IF_ELSE"),description:T.string().optional(),condition:kc,then:T.array(ne),else:T.array(ne).optional()}),Ti.extend({type:T.literal("WHILE_LOOP"),description:T.string().optional(),condition:kc,body:T.array(ne),timeout_ms:T.number().optional()})])),wp=T.object({name:T.string(),statements:T.array(ne),teardown:T.array(ne).optional(),skip:T.union([T.boolean(),T.string()]).optional(),timeout:T.number().optional(),fail:T.union([T.boolean(),T.string()]).optional(),only:T.boolean().optional(),slow:T.boolean().optional()}),bp=T.object({tests:T.array(wp).min(1),beforeAll:T.array(ne).optional(),afterAll:T.array(ne).optional(),beforeEach:T.array(ne).optional(),afterEach:T.array(ne).optional()}),nS=T.object({comment:T.string().optional(),version:T.string().optional(),goal:T.string().optional(),url:T.string().optional(),baseURL:T.string().optional(),final_feedback:T.string().optional(),completed:T.boolean().optional(),success:T.boolean().optional(),statements:T.array(ne).optional(),teardown:T.array(ne).optional(),last_modified_at:T.string().optional(),testGroup:bp.optional()}).refine(e=>e.testGroup!==void 0?e.goal===void 0&&(e.statements===void 0||e.statements.length===0):e.goal!==void 0,{message:"TestFlow must have either goal/statements (single test) or testGroup (suite), not both"}),pS=1024*1024});import Ye from"fs";import yp from"os";import Ii from"path";import{chromium as Cc,firefox as xp,webkit as vp}from"playwright";async function _p(e,t){let i=JSON.parse(Ye.readFileSync(t,"utf-8"));i.cookies?.length&&await e.addCookies(i.cookies)}var Pc,$c=y(()=>{"use strict";lo();_t();Te();bt();N();Pc=class{constructor(e={}){e.testDir&&(this.testDir=e.testDir,this.videoBasePath=Ii.join(e.testDir,"videos"),this.statesBasePath=Ii.join(e.testDir,"states"),this.downloadsBasePath=Ii.join(e.testDir,"downloads"),Ye.mkdirSync(this.videoBasePath,{recursive:!0}),Ye.mkdirSync(this.statesBasePath,{recursive:!0}),Ye.mkdirSync(this.downloadsBasePath,{recursive:!0})),this.terminationTimeout=e.terminationTimeout??null,this.defaultHeadless=e.headless??!1,this.additionalArgs=e.additionalArgs??[]}async launchBrowser(e={}){let t=e.debugPort,i=e.headless??this.defaultHeadless,n=Mc(e.deviceName),a=Ac(e.deviceName),o=n===vt.Chromium,r=!!e.extensionPath;h.info(`[BrowserManager] Launching ${n} browser for device: ${e.deviceName||"default"}${t?` on port ${t}`:""}`);let s={headless:i};if(o){r&&i&&(h.warn("[BrowserManager] Extension requested in headless mode; forcing headed mode to load extension."),i=!1,s.headless=!1);let k=[];(e.enableCamera||e.enableMicrophone)&&(k.push("--use-fake-device-for-media-stream","--use-fake-ui-for-media-stream"),e.enableMicrophone&&e.fakeAudioCapturePath&&(k.push(`--use-file-for-fake-audio-capture=${e.fakeAudioCapturePath}`),h.info(`[BrowserManager] Using fake audio capture file: ${e.fakeAudioCapturePath}`)));let E=r&&e.extensionPath?[`--disable-extensions-except=${e.extensionPath}`,`--load-extension=${e.extensionPath}`]:[];s.args=[...Yl(t,e.disableSecurity??!0,i),...k,...E,...this.additionalArgs],a&&(s.channel=a,h.debug(`[BrowserManager] Launching browser with channel: ${a}`))}let l=ia(e.deviceName),d=Tc(e.deviceName),c={acceptDownloads:!0,...l,timezoneId:e.timezoneId||"America/Los_Angeles",locale:e.locale||"en-US"};e.viewport&&(c.viewport=e.viewport,c.screen=e.viewport),e.isMobile!==void 0&&(c.isMobile=e.isMobile),e.hasTouch!==void 0&&(c.hasTouch=e.hasTouch),e.userAgent&&(c.userAgent=e.userAgent),e.colorScheme&&(c.colorScheme=e.colorScheme),e.geolocation&&(c.geolocation=e.geolocation,c.permissions=[...c.permissions||[],"geolocation"]);let u=r&&o?e.localStorageStatePath:void 0;e.localStorageStatePath&&!u&&(c.storageState=e.localStorageStatePath),e.recordVideo&&this.videoBasePath&&(c.recordVideo={dir:this.videoBasePath,size:{width:d.width,height:d.height}}),e.proxy&&(c.proxy=e.proxy),e.extraHTTPHeaders&&Object.keys(e.extraHTTPHeaders).length>0&&(c.extraHTTPHeaders=e.extraHTTPHeaders);let m,g,w,v=!1;if(o&&(r||e.userDataDir)){if(e.userDataDir)w=e.userDataDir;else{let E=this.testDir||Ye.mkdtempSync(Ii.join(yp.tmpdir(),"shiplight-"));w=Ii.join(E,`ext-profile-${Date.now()}`),Ye.mkdirSync(w,{recursive:!0}),v=!0}let k={...s,...c};g=await Cc.launchPersistentContext(w,k),u&&(await _p(g,u),h.info(`[BrowserManager] Loaded storage state into persistent context from ${u}`)),m=g.browser(),h.info(`[BrowserManager] Launched persistent context${e.extensionPath?` for extension at ${e.extensionPath}`:` with profile at ${w}`}`)}else{switch(n){case vt.Firefox:m=await xp.launch(s);break;case vt.Webkit:m=await vp.launch(s);break;case vt.Chromium:default:m=await Cc.launch(s);break}g=await m.newContext(c)}if(g.addInitScript(De),o){let k=["clipboard-read","clipboard-write"];e.enableCamera&&k.push("camera"),e.enableMicrophone&&k.push("microphone");try{await g.grantPermissions(k),h.info(`[BrowserManager] Granted permissions: ${k.join(", ")}`)}catch(E){h.warn("[BrowserManager] Failed to grant permissions:",E)}}else(e.enableCamera||e.enableMicrophone)&&h.warn("[BrowserManager] Camera/microphone enabled but browser is not Chromium; ignoring.");if(e.cookies&&e.cookies.length>0){let k=(Date.now()+31536e6)/1e3,E=e.cookies.map(I=>({...I,expires:k}));await g.addCookies(E),h.info(`[BrowserManager] Added ${e.cookies.length} cookies to browser context with expires=${k}`)}let x=e.viewport,p=x?{width:x.width,height:x.height+ta}:Ec(e.deviceName);if(h.info(`[BrowserManager] windowSize=${JSON.stringify(p)}`),o){let k=async E=>{try{await Wn(E,p.width,p.height),x&&await E.setViewportSize(x)}catch(I){h.warn("[BrowserManager] Failed to set window bounds via CDP:",I)}};for(let E of g.pages())await k(E);g.on("page",k)}let f="";if(o&&t!==void 0)try{f=await Hn(t)}catch(k){h.warn("[BrowserManager] Failed to get CDP WebSocket URL:",k)}let S=null;f&&(S=await yt({cdpUrl:f,label:`agent ${e.deviceName??n}`,pid:process.pid}),S&&h.info(`[BrowserManager] Registered browser with dev-box registry id=${S}`));let _={debugPort:t,browser:m,context:g,startTime:new Date,timeout:null,browserWsUrl:f,downloadsBasePath:this.downloadsBasePath,browserType:n,userDataDir:w,isTempUserDataDir:v,registryId:S};if(this.terminationTimeout!==null){let k=setTimeout(()=>{h.info(`[BrowserManager] Browser auto-terminated after ${this.terminationTimeout}ms`),this.terminateBrowser(_).catch(E=>h.error("[BrowserManager] Error terminating browser:",E))},this.terminationTimeout);_.timeout=k}return _}async terminateBrowser(e){if(e.timeout&&clearTimeout(e.timeout),await xt(e.registryId??null),await e.context.close(),await e.browser.close(),e.isTempUserDataDir&&e.userDataDir)try{Ye.rmSync(e.userDataDir,{recursive:!0,force:!0})}catch(t){h.warn("[BrowserManager] Failed to clean up temp user data dir:",e.userDataDir,t)}}getVideoBasePath(){return this.videoBasePath}getStatesBasePath(){return this.statesBasePath}getDownloadsBasePath(){return this.downloadsBasePath}}});import{execFileSync as kp}from"child_process";import*as Lc from"fs";import*as Dc from"path";function Sp(e){let t=kp("ps",["-axo","pid=,ppid=,args="],{encoding:"utf-8"}),i=[];for(let o of t.split(`
4436
4436
  `)){let r=o.trimStart().match(/^(\d+)\s+(\d+)\s+(.*)$/);r&&i.push({pid:parseInt(r[1],10),ppid:parseInt(r[2],10),args:r[3]})}let n=new Set([e]),a=!0;for(;a;){a=!1;for(let o of i)!n.has(o.pid)&&n.has(o.ppid)&&(n.add(o.pid),a=!0)}for(let o of i){if(o.pid===e||!n.has(o.pid)||!/chrome|chromium/i.test(o.args))continue;let r=o.args.match(/--user-data-dir=([^\s]+)/);if(r)return r[1]}return null}async function Ep(e,t){let i=Dc.join(e,"DevToolsActivePort"),n=Date.now()+t;for(;Date.now()<n;){try{let a=Lc.readFileSync(i,"utf-8").trim(),[o,r]=a.split(`
4437
4437
  `),s=parseInt(o,10);if(Number.isFinite(s)&&s>0&&typeof r=="string"&&r.startsWith("/"))return{port:s,wsPath:r}}catch{}await new Promise(a=>setTimeout(a,100))}throw new Error(`Timed out waiting for ${i} \u2014 Chromium never exposed DevTools`)}async function na(e,t=3e4){let i=Sp(e);if(!i)throw new Error(`No Chromium descendant of pid ${e} with --user-data-dir found. Did you launch with --remote-debugging-port=0 and is the browser still running?`);let{port:n,wsPath:a}=await Ep(i,t);return`ws://127.0.0.1:${n}${a}`}var Oc=y(()=>{"use strict"});var Nc,Rc=y(()=>{"use strict";_t();Nc=e=>{if(!e||e===Xe)return"desktop";let t=Ai(e);return t&&t.isMobile?"mobile":"desktop"}});var Tp,Fc=y(()=>{"use strict";Tp=(e=>(e.Desktop="desktop",e.Mobile="mobile",e))(Tp||{})});async function Hc(e,t){let i=Object.getPrototypeOf(async()=>{}).constructor,n=`
4438
4438
  return await (${t});
@@ -4492,7 +4492,7 @@ ${m.join(`
4492
4492
 
4493
4493
  `,u.some(g=>g)){b.log(`Locator validation on unsigned-in page failed (some passed when should fail). Results: ${JSON.stringify(u)}`),b.log(`Validation logs:
4494
4494
  ${m.join(`
4495
- `)}`);continue}}return b.log("Generated validation locators passed dual validation"),c}catch(c){b.log(`Failed to generate validation expressions (attempt ${d+1}/${s}): ${c.message}`)}return b.log("Failed to generate valid locators after max retries"),null}finally{o&&await o.close()}}var Ap,Mp,oa=y(()=>{"use strict";ee();Te();Ap=5e3,Mp=1e4});var Wc,go=y(()=>{"use strict";Wc=class{constructor(e){this.currentPage=null,this.currentIndex=-1,this.context=e,this.initialize()}initialize(){this.context.on("page",async t=>{await this.handleNewPage(t)});let e=this.context.pages();e.length>0&&(this.currentPage=e[0],this.currentIndex=0);for(let t of e)this.setupPageListeners(t)}async handleNewPage(e){try{this.setupPageListeners(e);let t=this.context.pages().indexOf(e);await this.setCurrentPage(e,t)}catch{}}setupPageListeners(e){e.on("close",async()=>{await this.handlePageClose(e)})}async handlePageClose(e){try{if(this.currentPage===e){let t=this.context.pages(),i=t.slice().reverse().find(n=>!n.isClosed());i&&await this.setCurrentPage(i,t.indexOf(i))}}catch{}}async setCurrentPage(e,t){let i=this.currentPage!==e;this.currentPage=e,this.currentIndex=t,i&&await e.bringToFront()}async switchToPage(e){let t=this.context.pages();if(e<0||e>=t.length)throw new Error(`Invalid page index: ${e}. Available pages: 0-${t.length-1}`);let i=t[e];if(i.isClosed())throw new Error(`Page at index ${e} is closed`);return await this.setCurrentPage(i,e),i}async closePage(e){let t=this.context.pages();if(e<0||e>=t.length)throw new Error(`Invalid page index: ${e}. Available pages: 0-${t.length-1}`);let i=t[e];if(i.isClosed())throw new Error(`Page at index ${e} is already closed`);await i.close()}getCurrentPage(){return this.currentPage}getCurrentIndex(){return this.currentIndex}getAllPages(){return this.context.pages()}getPageCount(){return this.context.pages().length}}});async function Bc(e,t=3e3,i=1e3){try{await Ee(e,t,i)}catch{}}async function Uc(e,t,i){let n=i*1e3,a=100,o=Date.now();for(;!t.downloadStatus||t.downloadStatus.status==="inProgress";){if(Date.now()-o>n){let r;throw t.downloadStatus?r=`Timed out after ${n}ms waiting for download to complete`:r="No download in progress or completed",h.error(r),new Error(r)}await e.waitForTimeout(a)}if(t.downloadStatus.status==="failed"){let r=`Download failed: ${t.downloadStatus.error||"Unknown error"}`;throw h.error(r),new Error(r)}t.agentNote=`Download completed: ${t.downloadStatus.filename}`}async function Gc(e,t,i,n=60,a){let o=Math.min(n,300),r=Math.max(10,o/10)*1e3,s=Date.now()+o*1e3;for(h.info(`Waiting for condition: "${t}" (timeout: ${o}s)`);;){let l=Date.now();try{if(await i(e,t,a))return h.info(`Condition met: "${t}"`),!0}catch(c){h.warn(`Error evaluating condition: ${c.message}`)}if(Date.now()>s)return h.warn(`Timeout waiting for condition: "${t}"`),!1;let d=r-(Date.now()-l);d>0&&await e.waitForTimeout(d)}}var ra=y(()=>{"use strict";Te();N()});import*as Kc from"fs";import*as $i from"path";import{generateSync as Ip,createGuardrails as Cp}from"otplib";function jc(e){return e.url()===":"}var Pp,sa,fo=y(()=>{"use strict";go();_t();ra();Te();N();Pp=Cp({MIN_SECRET_BYTES:1});sa=class{constructor(e){this.context=e,this.testDataFileNames=[],this.extensionEnabled=!1}setTestDataDownloader(e,t){this.testDataDownloader=e,this.testDataFileNames=t??[]}setupPageTracking(e){this.tabManager=new Wc(e)}async switchTab(e){if(!this.tabManager)throw new Error("Tab manager not initialized");return await this.tabManager.switchToPage(e)}async closeTab(e){if(!this.tabManager)throw new Error("Tab manager not initialized");await this.tabManager.closePage(e)}getCurrentPage(){return this.tabManager?this.tabManager.getCurrentPage():null}validatePage(e){let t=this.getCurrentPage();if(t&&t!==e&&!t.isClosed())return h.info(`[validatePage] Page changed, switching to ${t.url()}`),t;if(e.isClosed()){let i=e.context().pages().filter(n=>!n.isClosed());if(i.length>0){let n=i[i.length-1];return h.info(`[validatePage] Page closed, switching to ${n.url()}`),n}h.error("[validatePage] No valid pages found")}return e}replaceVariables(e){return ia(e,this.context.variableStore.getAll())}getTestDataFileNames(){return this.testDataFileNames}getTestDataFilePath(e){let t=this.context.testDataDir||process.cwd();return $i.join(t,e)}async downloadTestDataFiles(e){if(e.length===0){h.debug("[AgentServices] No file paths provided for download");return}let t=this.context.testDataDir||process.cwd(),i=e.filter(n=>{let a=$i.basename(n),o=$i.join(t,a),r=Kc.existsSync(o);return r&&h.debug(`[AgentServices] File already exists locally: ${a}`),!r});if(i.length===0){h.debug("[AgentServices] All files exist locally, no download needed");return}if(!this.testDataDownloader){h.debug("[AgentServices] No test data downloader configured, assuming files are pre-populated");return}h.info(`[AgentServices] Downloading ${i.length} test data files: ${i.join(", ")}`),await this.testDataDownloader(i,t)}async waitForDownloadComplete(e,t){return Uc(e,this.context,t)}getRecentDownloadedFilePath(){return this.context.downloadStatus?this.context.downloadStatus.status!=="completed"?(h.debug(`Download is ${this.context.downloadStatus.status}, not completed`),null):this.context.downloadStatus.filePath?(h.info(`Retrieved recent download path: ${this.context.downloadStatus.filePath}`),this.context.downloadStatus.filePath):(h.warn("Download completed but file path is missing"),null):(h.debug("No download found"),null)}addSensitive(e,t){this.context.variableStore.set(e,t,!0)}saveVariable(e,t){let i=e.startsWith("$")?e.slice(1):e;this.context.variableStore.set(i,t),h.debug(`Saved variable: ${i} = ${JSON.stringify(t)}`),this.context.agentNote=`A new value is saved to the variable "${i}".`}addNote(e){!e||e.trim()===""||(this.context.agentNote?this.context.agentNote+=`
4495
+ `)}`);continue}}return b.log("Generated validation locators passed dual validation"),c}catch(c){b.log(`Failed to generate validation expressions (attempt ${d+1}/${s}): ${c.message}`)}return b.log("Failed to generate valid locators after max retries"),null}finally{o&&await o.close()}}var Ap,Mp,oa=y(()=>{"use strict";ee();Te();Ap=5e3,Mp=1e4});var Wc,go=y(()=>{"use strict";Wc=class{constructor(e){this.currentPage=null,this.currentIndex=-1,this.context=e,this.initialize()}initialize(){this.context.on("page",async t=>{await this.handleNewPage(t)});let e=this.context.pages();e.length>0&&(this.currentPage=e[0],this.currentIndex=0);for(let t of e)this.setupPageListeners(t)}async handleNewPage(e){try{this.setupPageListeners(e);let t=this.context.pages().indexOf(e);await this.setCurrentPage(e,t)}catch{}}setupPageListeners(e){e.on("close",async()=>{await this.handlePageClose(e)})}async handlePageClose(e){try{if(this.currentPage===e){let t=this.context.pages(),i=t.slice().reverse().find(n=>!n.isClosed());i&&await this.setCurrentPage(i,t.indexOf(i))}}catch{}}async setCurrentPage(e,t){let i=this.currentPage!==e;this.currentPage=e,this.currentIndex=t,i&&await e.bringToFront()}async switchToPage(e){let t=this.context.pages();if(e<0||e>=t.length)throw new Error(`Invalid page index: ${e}. Available pages: 0-${t.length-1}`);let i=t[e];if(i.isClosed())throw new Error(`Page at index ${e} is closed`);return await this.setCurrentPage(i,e),i}async closePage(e){let t=this.context.pages();if(e<0||e>=t.length)throw new Error(`Invalid page index: ${e}. Available pages: 0-${t.length-1}`);let i=t[e];if(i.isClosed())throw new Error(`Page at index ${e} is already closed`);await i.close()}getCurrentPage(){return this.currentPage}getCurrentIndex(){return this.currentIndex}getAllPages(){return this.context.pages()}getPageCount(){return this.context.pages().length}}});async function Bc(e,t=3e3,i=1e3){try{await Ee(e,t,i)}catch{}}async function Uc(e,t,i){let n=i*1e3,a=100,o=Date.now();for(;!t.downloadStatus||t.downloadStatus.status==="inProgress";){if(Date.now()-o>n){let r;throw t.downloadStatus?r=`Timed out after ${n}ms waiting for download to complete`:r="No download in progress or completed",h.error(r),new Error(r)}await e.waitForTimeout(a)}if(t.downloadStatus.status==="failed"){let r=`Download failed: ${t.downloadStatus.error||"Unknown error"}`;throw h.error(r),new Error(r)}t.agentNote=`Download completed: ${t.downloadStatus.filename}`}async function Gc(e,t,i,n=60,a){let o=Math.min(n,300),r=Math.max(10,o/10)*1e3,s=Date.now()+o*1e3;for(h.info(`Waiting for condition: "${t}" (timeout: ${o}s)`);;){let l=Date.now();try{if(await i(e,t,a))return h.info(`Condition met: "${t}"`),!0}catch(c){h.warn(`Error evaluating condition: ${c.message}`)}if(Date.now()>s)return h.warn(`Timeout waiting for condition: "${t}"`),!1;let d=r-(Date.now()-l);d>0&&await e.waitForTimeout(d)}}var ra=y(()=>{"use strict";Te();N()});import*as Kc from"fs";import*as $i from"path";import{generateSync as Ip,createGuardrails as Cp}from"otplib";function jc(e){return e.url()===":"}var Pp,sa,fo=y(()=>{"use strict";go();_t();ra();Te();N();Pp=Cp({MIN_SECRET_BYTES:1});sa=class{constructor(e){this.context=e,this.testDataFileNames=[],this.extensionEnabled=!1}setTestDataDownloader(e,t){this.testDataDownloader=e,this.testDataFileNames=t??[]}setupPageTracking(e){this.tabManager=new Wc(e)}async switchTab(e){if(!this.tabManager)throw new Error("Tab manager not initialized");return await this.tabManager.switchToPage(e)}async closeTab(e){if(!this.tabManager)throw new Error("Tab manager not initialized");await this.tabManager.closePage(e)}getCurrentPage(){return this.tabManager?this.tabManager.getCurrentPage():null}validatePage(e){let t=this.getCurrentPage();if(t&&t!==e&&!t.isClosed())return h.info(`[validatePage] Page changed, switching to ${t.url()}`),t;if(e.isClosed()){let i=e.context().pages().filter(n=>!n.isClosed());if(i.length>0){let n=i[i.length-1];return h.info(`[validatePage] Page closed, switching to ${n.url()}`),n}h.error("[validatePage] No valid pages found")}return e}replaceVariables(e){return ea(e,this.context.variableStore.getAll())}getTestDataFileNames(){return this.testDataFileNames}getTestDataFilePath(e){let t=this.context.testDataDir||process.cwd();return $i.join(t,e)}async downloadTestDataFiles(e){if(e.length===0){h.debug("[AgentServices] No file paths provided for download");return}let t=this.context.testDataDir||process.cwd(),i=e.filter(n=>{let a=$i.basename(n),o=$i.join(t,a),r=Kc.existsSync(o);return r&&h.debug(`[AgentServices] File already exists locally: ${a}`),!r});if(i.length===0){h.debug("[AgentServices] All files exist locally, no download needed");return}if(!this.testDataDownloader){h.debug("[AgentServices] No test data downloader configured, assuming files are pre-populated");return}h.info(`[AgentServices] Downloading ${i.length} test data files: ${i.join(", ")}`),await this.testDataDownloader(i,t)}async waitForDownloadComplete(e,t){return Uc(e,this.context,t)}getRecentDownloadedFilePath(){return this.context.downloadStatus?this.context.downloadStatus.status!=="completed"?(h.debug(`Download is ${this.context.downloadStatus.status}, not completed`),null):this.context.downloadStatus.filePath?(h.info(`Retrieved recent download path: ${this.context.downloadStatus.filePath}`),this.context.downloadStatus.filePath):(h.warn("Download completed but file path is missing"),null):(h.debug("No download found"),null)}addSensitive(e,t){this.context.variableStore.set(e,t,!0)}saveVariable(e,t){let i=e.startsWith("$")?e.slice(1):e;this.context.variableStore.set(i,t),h.debug(`Saved variable: ${i} = ${JSON.stringify(t)}`),this.context.agentNote=`A new value is saved to the variable "${i}".`}addNote(e){!e||e.trim()===""||(this.context.agentNote?this.context.agentNote+=`
4496
4496
  ${e.trim()}`:this.context.agentNote=e.trim())}readVariable(e){let t=e.startsWith("$")?e.slice(1):e,i=this.context.variableStore.get(t);return h.debug(`Read variable: ${t} = ${JSON.stringify(i)}`),i}async generate2faCode(e){try{let t=Ip({secret:e,guardrails:Pp});return h.info(`Generated 2FA code: ${t}`),t}catch(t){throw h.error(`Failed to generate 2FA code: ${t.message}`),new Error(`Failed to generate 2FA code: ${t.message}`)}}async getDOMText(e){return await e.evaluate(()=>document.body.innerText)}async waitUntilStable(e,t){return Ee(e,t)}setPage(e){this.context.setPage?(h.info("[AgentServices] Calling setPage callback"),this.context.setPage(e)):h.debug("[AgentServices] setPage callback not configured")}getModel(){if(!this.context.model)throw new Error("No LLM model configured. An LLM model is required for AI-powered actions (login, verify, ai_extract, ai_wait_until, etc.). Set GOOGLE_API_KEY or ANTHROPIC_API_KEY in your MCP server configuration.");return this.context.model}getComputerUseModel(){return this.context.computer_use_model}get variableStore(){return this.context.variableStore}getDownloadDir(){return this.context.downloadDir}getActionSettings(){return this.context.organizationSettings?.action_code_conversion_settings||{}}getInteractiveClassNames(){return this.context.organizationSettings?.agent_settings?.interactive_class_names||[]}getIframeFallbackDomains(){return this.context.organizationSettings?.agent_settings?.iframe_fallback_domains||[]}isUseCleanScreenshotForAssertion(){return this.context.organizationSettings?.use_clean_screenshot_for_assertion??!0}isKnowledgeImagesEnabled(){return this.context.organizationSettings?.agent_settings?.enable_knowledge_images||!1}isSlicedScreenshotsEnabled(){return this.context.organizationSettings?.agent_settings?.use_sliced_screenshots||!1}isResizeSlicedScreenshotsEnabled(){return this.context.organizationSettings?.agent_settings?.resize_sliced_screenshots||!1}isAccessibilityTreeEnabled(){return this.context.organizationSettings?.agent_settings?.use_accessibility_tree||!1}isActionIntentFilteringEnabled(){return this.context.organizationSettings?.agent_settings?.use_action_intent_filtering||!1}isDomTreeTsEnabled(){let e=process.env.USE_DOM_TREE_TS;return e!==void 0?e==="true"||e==="1":this.context.organizationSettings?.agent_settings?.use_dom_tree_ts||!1}setExtensionEnabled(e){this.extensionEnabled=e}getDomServiceOptions(){return{useDomTreeTs:this.isDomTreeTsEnabled(),domTreeRoot:this.extensionEnabled?"document":"body"}}setKnowledgeRetriever(e){this.knowledgeRetriever=e}hasKnowledgeRetriever(){return this.knowledgeRetriever!==void 0}async retrieveKnowledges(e,t,i,n){if(!this.knowledgeRetriever)return h.debug("[AgentServices] No knowledge retriever configured"),[];try{let a=await this.knowledgeRetriever(e,t,i,n);return h.debug(`[AgentServices] Retrieved ${a.length} knowledges for statement`),a}catch(a){return h.warn(`[AgentServices] Failed to retrieve knowledges: ${a.message}`),[]}}}});var wo,la,bo=y(()=>{"use strict";wo=(e=>(e.Started="started",e.Action="action",e.Completion="completion",e.Error="error",e.Aborted="aborted",e.Keepalive="keepalive",e))(wo||{}),la=class extends Error{constructor(e){super(e),this.name="AgentTaskFailedError",this.details=e}}});var zc={};et(zc,{LoginType:()=>Mi,checkLocators:()=>Ci,createUnsignedInContext:()=>mo,generateAndValidateLoginLocators:()=>aa,generateValidationLocators:()=>po,validateLogin:()=>Pi,validateLoginLocators:()=>ho});var Vc=y(()=>{"use strict";oa();ee();_t();Te();bt();N();Q();ht();me()});import*as K from"fs";import*as q from"path";function Lp(e){try{let t=e.toString(),i,n=t.indexOf("=>");if(n!==-1){let s=t.slice(n+2).trim();if(s.startsWith("{")){let l=s.lastIndexOf("}");i=s.slice(1,l)}else return s.trim()}else{let s=t.indexOf("{"),l=t.lastIndexOf("}");s!==-1&&l>s&&(i=t.slice(s+1,l))}if(!i)return;let a=i.split(`
4497
4497
  `),o=a.filter(s=>s.trim().length>0);if(o.length===0)return;let r=Math.min(...o.map(s=>s.match(/^(\s*)/)?.[1].length??0));return a.map(s=>s.slice(r)).join(`
4498
4498
  `).trim()}catch{return}}function kt(e,t){let i={};for(let[n,a]of Object.entries(e))i[n]=t.has(n)?"*****":a;return i}var $p,Dp,Op,yo,Xc=y(()=>{"use strict";Vt();Ke();oa();ee();fo();ra();bo();ii();N();$p=1;Dp=3,Op=40;yo=class{constructor(e){this.context=e,this._newActionEntities=new Map,this.agentServices=new sa(e),this.agentServices.agent=this,this.context.tokenUsages||(this.context.tokenUsages=[])}getNewActionEntities(){return this._newActionEntities}getAgentNote(){return this.context.agentNote||void 0}async getActionHandler(){if(!this._actionHandler){let{default:e}=await Promise.resolve().then(()=>(wt(),ft));this._actionHandler=new e}return this._actionHandler}async execAction(e,t,i){let n=(await this.getActionHandler()).getAction(e);if(!n)throw new Error(`Unknown action: ${e}`);await n.execute(t,i,this.agentServices)}async dismissModalIfPresent(e,t){try{let i=await this.execute(e,`TASK: Check if there is an INTRUSIVE POPUP blocking the page, and dismiss it if present.
@@ -4529,9 +4529,7 @@ If the page is not signed in, sign in with the OAuth provider "${l.provider_name
4529
4529
  `}t.additional_prompt&&(s+=`
4530
4530
  Additional instructions: ${t.additional_prompt}
4531
4531
  `);try{b.log("Level 3: Attempting agent-based login"),b.log(`Login prompt:
4532
- ${s}`);let l=this.agentServices.knowledgeRetriever,d=!1;this.agentServices.hasKnowledgeRetriever()&&l&&(b.log("Setting up login knowledge retriever..."),this.agentServices.setKnowledgeRetriever(async(v,x,p,f)=>await l(v,x,p,"login")),d=!0,b.log("Login knowledge retriever configured"));let c;try{if(c=await this.run(e,s,"login"),!c.success)return b.log("Level 3 FAILED: Agent login failed"),h.info("Login: Failed"),{success:!1,page:e}}finally{d&&l&&(this.agentServices.setKnowledgeRetriever(l),b.log("Restored original knowledge retriever"))}let u=await e.context().storageState(),m;if(a)b.log("Skipping validation locator generation (AI verification mode enabled)");else if(t.num_verification_exprs!==0)try{b.log("Generating validation locators for future login verification...");let v=await aa(e,t.site_url,{verification_hint:t.verification_hint,num_verification_exprs:t.num_verification_exprs},async(x,p)=>this.run(x,p),async x=>this.getDOMText(x));v?(m=v,b.log(`Generated ${m.length} validation locator(s): ${JSON.stringify(m)}`)):b.log("Failed to generate validation locators, login will still succeed")}catch(v){b.log(`Error generating validation locators: ${v.message}`)}else b.log("Skipping validation locator generation (num_verification_exprs=0)");b.log("Level 3 SUCCESS: Agent login succeeded"),h.info("Login: Agent login succeeded");let g=c.actions||[],w=g.length>0?g:i?.cached_actions;return{success:!0,page:e,storage_state:u,cached_actions:w,validation_exprs:m}}catch(l){return b.error(`Agent login failed: ${l.message}`),h.info("Login: Failed"),{success:!1,page:e}}}async executeCachedLogin(e,t,i){let n=(await Promise.resolve().then(()=>(wt(),ft))).default,a=new n;for(let o=0;o<t.length;o++){let r=t[o];b.log(`Executing cached action ${o+1}/${t.length}: ${r.action_description||r.action_data?.action_name}`);try{if(!r.action_data){b.log(`Action ${o+1} missing action_data, skipping`);continue}await a.execute(e,r,this.agentServices),await this.waitUntilStable(e,5e3)}catch(s){return b.error(`Cached action ${o+1} failed: ${s.message}`),{success:!1}}}return i?.aiVerificationStatement?(b.log("Verifying cached login result with AI verification statement"),await this.evaluate(e,i.aiVerificationStatement)?{success:!0}:{success:!1}):i?.validationExprs&&i.validationExprs.length>0?await Pi(e,i.validationExprs)?{success:!0}:{success:!1}:(b.log("Cached login cannot be verified: missing AI verification statement and validation expressions"),{success:!1})}getCompletedExecutionHistory(){if(!this.context.executionHistory||this.context.executionHistory.length===0)return[];let e=this.context.executionHistory[this.context.executionHistory.length-1];return!e[1]||e[1].trim()===""?this.context.executionHistory.slice(0,-1):this.context.executionHistory}addToExecutionHistory(e,t){this.context.executionHistory||(this.context.executionHistory=[]),this.context.executionHistory.push([e,t])}async createStepResult(e,t,i,n){if(this.context.stepTracking&&!this.context.stepTracking.results[t]){this.context.stepTracking.currentStepId=t,this.context.stepTracking.onStepChange&&this.context.stepTracking.onStepChange(t);try{e=this.agentServices.validatePage(e),await this.waitUntilStable(e);let a={description:i,startTime:Date.now(),artifacts:[],type:n,code:i};if(this.context.stepTracking.artifactsDir){let o=q.join(this.context.stepTracking.artifactsDir,t.replace(/\./g,"-"));K.mkdirSync(o,{recursive:!0});let r=q.join(o,"screenshot.png");e=this.agentServices.validatePage(e),await e.screenshot({type:"png",path:r}),a.screenshot=r}a.contextBefore=this.snapshotVariables(),this.context.stepTracking.results[t]=a}catch(a){h.warn(`createStepResult failed for step ${t}: ${a}`),this.context.stepTracking.results[t]={description:i,startTime:Date.now(),artifacts:[],contextBefore:this.snapshotVariables()}}}}snapshotVariables(){return kt(this.context.variableStore.getAll(),this.context.variableStore.getAllSensitiveKeys())}saveDebugInfoToFiles(e,t,i,n=0){let a={};if(!this.context.stepTracking?.artifactsDir)return h.debug("[saveDebugInfoToFiles] No artifacts directory configured, skipping debug info save"),a;let o=q.join(this.context.stepTracking.artifactsDir,e.replace(/\./g,"-"));try{if(K.mkdirSync(o,{recursive:!0}),t.systemPrompt){let r=q.join(o,`system_prompt_${n}.txt`);K.writeFileSync(r,t.systemPrompt),a.system_prompt_path=r,h.debug(`[saveDebugInfoToFiles] Saved system prompt to: ${r}`)}if(t.userPrompt)if(typeof t.userPrompt=="string"){let r=q.join(o,`user_prompt_${n}.txt`);K.writeFileSync(r,t.userPrompt),a.user_prompt_path=r,h.debug(`[saveDebugInfoToFiles] Saved user prompt to: ${r}`)}else{let r=t.userPrompt.map(d=>Array.isArray(d.content)?{...d,content:d.content.map(c=>c.type==="image"&&c.file?.startsWith("data:")?{...c,file:"[base64 image data stripped]"}:c)}:d),s=q.join(o,`messages_${n}.json`),l={system:t.systemPrompt,messages:r};K.writeFileSync(s,JSON.stringify(l,null,2)),a.messages_path=s,h.debug(`[saveDebugInfoToFiles] Saved messages to: ${s}`)}if(t.rawLlmResponse){let r=i?i.replace(/[\/\\:]/g,"-"):"llm",s=q.join(o,`${r}_response_${n}.txt`);K.writeFileSync(s,t.rawLlmResponse),a.response_path=s,h.debug(`[saveDebugInfoToFiles] Saved LLM response to: ${s}`)}if(t.screenshotWithSom){let r=q.join(o,`screenshot_${n}.png`);K.writeFileSync(r,Buffer.from(t.screenshotWithSom,"base64")),a.screenshot_path=r,h.debug(`[saveDebugInfoToFiles] Saved SOM screenshot to: ${r}`)}if(t.reasoningContent){let r=q.join(o,`reasoning_${n}.txt`);K.writeFileSync(r,t.reasoningContent),a.reasoning_path=r,h.debug(`[saveDebugInfoToFiles] Saved reasoning to: ${r}`)}h.debug(`[saveDebugInfoToFiles] Saved ${Object.keys(a).length} artifacts for step ${e}`)}catch(r){h.error(`[saveDebugInfoToFiles] Failed to save debug info for step ${e}:`,r)}return a}async updateStepResult(e,t,i,n,a){if(!this.context.stepTracking)return;let o=this.context.stepTracking.results[e];if(o){if(t&&(o.status=t,o.contextAfter=this.snapshotVariables(),this.context.stepTracking.currentStepId=void 0,this.context.stepTracking.onStepChange&&this.context.stepTracking.onStepChange(void 0)),i!==void 0&&(o.message=i),n&&o.artifacts.push(n),a){let r=a.tokenUsages?.[0]?.model,s=o.artifacts.length,l=this.saveDebugInfoToFiles(e,a,r,s);Object.keys(l).length>0&&o.artifacts.push(l)}o.duration=Date.now()-o.startTime,this.context.stepTracking.onStepComplete&&this.context.stepTracking.onStepComplete(e,o)}}async writeExecutionResults(e,t){try{if(await K.promises.mkdir(e,{recursive:!0}),this.context.stepTracking?.results&&Object.keys(this.context.stepTracking.results).length>0){let i=q.join(e,"test-results.json");await K.promises.writeFile(i,JSON.stringify(this.context.stepTracking.results,null,2)),h.debug(`Test results written to: ${i}`)}if(t?.tokenUsages&&this.context.tokenUsages&&this.context.tokenUsages.length>0){let i=q.join(e,"token-usages.json");await K.promises.writeFile(i,JSON.stringify(this.context.tokenUsages,null,2)),h.debug(`Token usages written to: ${i}`)}if(this.context.aiActionDetails&&this.context.aiActionDetails.length>0){let i=q.join(e,"ai-actions.json");await K.promises.writeFile(i,JSON.stringify(this.context.aiActionDetails,null,2)),h.debug(`AI action details written to: ${i}`)}}catch(i){throw h.error("Failed to write execution results:",i),i}}}});function Np(){let e=new Date,t=new Intl.DateTimeFormat("en-US",{timeZone:"America/Los_Angeles",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(e),i=t.find(p=>p.type==="year").value,n=t.find(p=>p.type==="month").value,a=t.find(p=>p.type==="day").value,o=t.find(p=>p.type==="hour").value,r=t.find(p=>p.type==="minute").value,s=t.find(p=>p.type==="second").value,l=String(e.getMilliseconds()).padStart(3,"0"),d=`${i}-${n}-${a}T${o}:${r}:${s}.${l}`,c=e.toISOString().slice(0,-1),u=Date.parse(d+"Z"),m=Date.parse(c+"Z"),g=Math.round((m-u)/(1e3*60)),w=String(Math.floor(Math.abs(g)/60)).padStart(2,"0"),v=String(Math.abs(g)%60).padStart(2,"0"),x=g<=0?"+":"-";return`${i}-${n}-${a}T${o}:${r}:${s}.${l}${x}${w}:${v}`}function xo(e){let t=e.variableStore;return t.has("currentTime")||t.set("currentTime",Np()),{model:e.model,computer_use_model:e.computer_use_model,variableStore:t,organizationId:e.organizationId,organizationSettings:e.organizationSettings,executionHistory:e.executionHistory||[],testDataDir:e.testDataDir,downloadDir:e.downloadDir,useNativeGenerator:e.useNativeGenerator,autoDismissModal:e.autoDismissModal,tokenUsages:[],aiActionDetails:[]}}var Yc=y(()=>{"use strict"});var Jc={};et(Jc,{ActionHandler:()=>Dn,ActionHelper:()=>Si,Agent:()=>yo,AgentServices:()=>sa,AgentStepEventTypes:()=>wo,AgentTaskFailedError:()=>la,BrowserManager:()=>Pc,DEFAULT_EVENT_LISTENER_LIMIT:()=>un,DomService:()=>le,EVENT_LISTENER_CANDIDATE_SELECTORS:()=>dn,HistoryTreeProcessor:()=>Ps,INIT_SCRIPT:()=>De,INTERACTION_EVENT_TYPES:()=>ct,INTERACTIVE_ROLES:()=>Wt,LogLevel:()=>Na,LoginType:()=>Mi,MCPToolProvider:()=>bc,OpenAIToolProvider:()=>Ui,SDK_VERSION:()=>Fp,ToolRegistry:()=>lt,TwoFactorAuthType:()=>co,VariableStore:()=>uo,WebAgent:()=>yo,configureSdk:()=>Sr,createAgent:()=>Rp,createAgentContext:()=>xo,createToolRegistry:()=>pc,createToolRegistryWithCapabilities:()=>gc,discoverChromiumCdpUrl:()=>na,ensureToolsRegistered:()=>hc,evaluateStatement:()=>ze,executeStep:()=>je,exportMCPTools:()=>yc,filterInteractionListeners:()=>fs,generateActionStep:()=>gt,getActionEntityLocatorInfo:()=>O,getBrowserCdpUrl:()=>Hn,getCapabilitySummary:()=>fc,getFramePath:()=>$a,getModel:()=>fe,getPageInfo:()=>Zl,getPageWsUrl:()=>ql,getPlatformFromDeviceName:()=>Nc,getProviderOptions:()=>we,getSdkConfig:()=>W,getToolRegistry:()=>mc,injectUserFunction:()=>ka,isInteractionEventType:()=>gs,isInteractiveRole:()=>ps,loadKnowledgeMappings:()=>Cr,loadKnowledges:()=>Ir,loadUserFunctions:()=>Ar,logger:()=>h,newBrowserContext:()=>Jl,parseSSEStream:()=>_r,parseSdkLogLevelFromEnv:()=>Er,pickBestLocator:()=>$t,pickBestLocatorForElement:()=>Vi,pickBestLocators:()=>Rr,registerBrowser:()=>yt,replaceVariables:()=>ia,runTask:()=>Ve,setWindowBounds:()=>Wn,toolRegistry:()=>F,unregisterBrowser:()=>xt});function Rp(e){let t=new uo,i=new Set(e.sensitiveKeys||[]);if(e.variables)for(let[a,o]of Object.entries(e.variables))t.set(a,o,i.has(a));let n=xo({model:e.model,variableStore:t,testDataDir:e.testDataDir,downloadDir:e.downloadDir});return new yo(n)}var Fp,vo=y(()=>{"use strict";kr();Mr();Pr();wc();xc();vc();so();ao();ro();oo();$c();Oc();Rc();Fc();lo();Xc();Vt();cn();sn();Gi();st();qi();Qi();nt();Zi();nn();Rt();Ft();Se();Ct();Nt();_n();Ke();Ht();Bt();dt();Ut();Gt();oa();ee();fo();go();_t();ra();Te();bt();ke();Dt();at();Ot();Ge();bo();io();mn();pn();gn();fn();wn();bn();yn();xn();vn();kn();Sn();Xt();Yt();qt();Zt();Qt();ei();ti();ni();ai();oi();ri();si();li();di();ui();hi();mi();pi();gi();fi();wi();bi();yi();xi();vi();_i();jt();ki();Pn();ii();G();Ue();N();Q();ht();Ln();R();Yc();me();Fp="1.0.0"});import{z as A}from"zod";var ko,ca,So,Je,Eo,To,Ao,te,Mo,Li,da,Io=y(()=>{"use strict";ko=A.enum(["JS_CODE","AI_MODE"]),ca=A.object({type:ko,expression:A.string()}),So=A.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),Je=A.object({uid:A.string(),type:So,comment:A.string().optional()}),Eo=A.object({action_data:A.object({action_name:A.string(),kwargs:A.record(A.any()).optional(),args:A.array(A.any()).optional()}),action_description:A.string().optional(),url:A.string().optional(),xpath:A.string().nullable().optional(),locator:A.string().nullable().optional(),css_selector:A.string().nullable().optional(),unique_selector:A.string().nullable().optional(),element_index:A.number().nullable().optional(),frame_path:A.array(A.any()).optional(),artifacts:A.record(A.any()).optional(),feedback:A.string().optional(),original_browser_use_action:A.any().optional()}).passthrough(),To=Je.extend({type:A.literal("DRAFT"),description:A.string()}),Ao=Je.extend({type:A.literal("ACTION"),description:A.string(),action_entity:Eo.optional(),locator:A.string().optional(),use_pure_vision:A.boolean().optional()}),te=A.lazy(()=>A.union([To,Ao,Je.extend({type:A.literal("STEP"),description:A.string().optional().default(""),statements:A.array(te),reference_id:A.number().optional(),template_path:A.string().optional(),template_params:A.record(A.string()).optional()}),Je.extend({type:A.literal("IF_ELSE"),description:A.string().optional(),condition:ca,then:A.array(te),else:A.array(te).optional()}),Je.extend({type:A.literal("WHILE_LOOP"),description:A.string().optional(),condition:ca,body:A.array(te),timeout_ms:A.number().optional()})])),Mo=A.object({name:A.string(),statements:A.array(te),teardown:A.array(te).optional(),skip:A.union([A.boolean(),A.string()]).optional(),timeout:A.number().optional(),fail:A.union([A.boolean(),A.string()]).optional(),only:A.boolean().optional(),slow:A.boolean().optional()}),Li=A.object({tests:A.array(Mo).min(1),beforeAll:A.array(te).optional(),afterAll:A.array(te).optional(),beforeEach:A.array(te).optional(),afterEach:A.array(te).optional()}),da=A.object({comment:A.string().optional(),version:A.string().optional(),goal:A.string().optional(),url:A.string().optional(),baseURL:A.string().optional(),final_feedback:A.string().optional(),completed:A.boolean().optional(),success:A.boolean().optional(),statements:A.array(te).optional(),teardown:A.array(te).optional(),last_modified_at:A.string().optional(),testGroup:Li.optional()}).refine(e=>e.testGroup!==void 0?e.goal===void 0&&(e.statements===void 0||e.statements.length===0):e.goal!==void 0,{message:"TestFlow must have either goal/statements (single test) or testGroup (suite), not both"})});import{stringify as Oi,parse as ua,parseAllDocuments as Bp,parseDocument as Up,Document as Gp,isMap as Et,isSeq as de}from"yaml";import{v4 as ce}from"uuid";function Po(e,t){let i={...t?.test_case_id!==void 0?{test_case_id:t.test_case_id}:{},...t?.name?{name:t.name}:{},goal:e.goal??"",url:e.url,base_url:e.baseURL,...t?.timeout!==void 0?{timeout:t.timeout}:{},...t?.settings&&Object.keys(t.settings).length>0?{settings:t.settings}:{},statements:(e.statements??[]).map(ae)};return e.final_feedback&&(i.final_feedback=e.final_feedback),e.teardown&&e.teardown.length>0&&(i.teardown=e.teardown.map(ae)),i}function ed(e,t){if(e.testGroup)return $o(e,t);let i=Po(e,t),n=new Gp(i);return e.comment&&(n.commentBefore=e.comment),qc(n,e.statements??[]),e.teardown&&qc(n,e.teardown,"teardown"),n.toString(Tt)}function qc(e,t,i="statements"){let n=e.contents;if(!n||!Et(n))return;let a=n.get(i,!0);de(a)&&Di(a,t)}function Di(e,t){for(let i=0;i<Math.min(e.items.length,t.length);i++){let n=t[i],a=e.items[i];if(i>0&&(a.spaceBefore=!0),n.comment&&(i===0?e.commentBefore=n.comment:a.commentBefore=n.comment),Et(a)){let o=a;if(n.type==="STEP"){let r=o.get("statements",!0);de(r)&&Di(r,n.statements)}else if(n.type==="IF_ELSE"){let r=o.get("THEN",!0);de(r)&&Di(r,n.then);let s=o.get("ELSE",!0);de(s)&&n.else&&Di(s,n.else)}else if(n.type==="WHILE_LOOP"){let r=o.get("DO",!0);de(r)&&Di(r,n.body)}}}}function $o(e,t){let i=e.testGroup;if(!i)throw new Error("suiteToYaml requires a TestFlow with testGroup");let n={};t?.test_case_id!==void 0&&(n.test_case_id=t.test_case_id),t?.name&&(n.name=t.name),t?.tags&&t.tags.length>0&&(n.tags=t.tags),t?.use&&Object.keys(t.use).length>0&&(n.use=t.use),t?.settings&&Object.keys(t.settings).length>0&&(n.settings=t.settings);let a={};return e.baseURL&&(a.base_url=e.baseURL),i.beforeAll&&i.beforeAll.length>0&&(a.beforeAll=i.beforeAll.map(ae)),i.beforeEach&&i.beforeEach.length>0&&(a.beforeEach=i.beforeEach.map(ae)),i.afterEach&&i.afterEach.length>0&&(a.afterEach=i.afterEach.map(ae)),i.afterAll&&i.afterAll.length>0&&(a.afterAll=i.afterAll.map(ae)),a.tests=i.tests.map(o=>{let r={name:o.name};return o.skip!==void 0&&(r.skip=o.skip),o.timeout!==void 0&&(r.timeout=o.timeout),o.fail!==void 0&&(r.fail=o.fail),o.only!==void 0&&(r.only=o.only),o.slow!==void 0&&(r.slow=o.slow),r.statements=o.statements.map(ae),o.teardown&&o.teardown.length>0&&(r.teardown=o.teardown.map(ae)),r}),n.suite=a,Oi(n,Tt)}function td(e){return e.map(t=>Oi(t,Tt)).join(`---
4533
- `)}function ae(e){switch(e.type){case"DRAFT":return Kp(e);case"ACTION":return id(e);case"STEP":return zp(e);case"IF_ELSE":return Vp(e);case"WHILE_LOOP":return Xp(e)}}function Kp(e){return{intent:e.description}}function id(e){let t=e.action_entity?.action_data?.action_name??e.action_entity?.action?.action_name,i=e.action_entity?.action_data?.kwargs??e.action_entity?.action?.kwargs;if(t==="verify"){let s=i?.statement;if(typeof s=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath){let l=i?.code;return typeof l=="string"?{VERIFY:s,js:l}:{VERIFY:s}}}if(t==="go_to_url"){let s=i?.url;if(typeof s=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath){let l={URL:s};return i?.new_tab===!0&&(l.new_tab=!0),typeof i?.timeout_seconds=="number"&&(l.timeout_seconds=i.timeout_seconds),l}}if(t==="js_action"){let s=i?.code;if(typeof s=="string"&&e.description)return{intent:e.description,js:s}}if(t==="ai_wait_until"){let s=i?.condition;if(typeof s=="string"){let l={WAIT_UNTIL:s};return typeof i?.timeout_seconds=="number"&&i.timeout_seconds!==60&&(l.timeout_seconds=i.timeout_seconds),l}}if(t==="wait"){let s=i?.seconds,d={WAIT:e.description||`Wait ${s}s`};return typeof s=="number"&&(d.seconds=s),d}if(t==="js_code"){let s=i?.code;if(typeof s=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath)return{CODE:s}}if(!e.action_entity)return{intent:e.description};let n=e.action_entity.action_data??e.action_entity.action;if(!n)return{intent:e.description};let a={intent:e.description,action:n.action_name},o=e.locator??e.action_entity.locator;o&&(a.locator=o);let r=e.action_entity.xpath;if(r&&(a.xpath=r),e.use_pure_vision&&(a.use_pure_vision=!0),n.kwargs&&Object.keys(n.kwargs).length>0)for(let[s,l]of Object.entries(n.kwargs))a[s]=l;return n.args&&n.args.length>0&&(a.args=n.args),a}function nd(e,t,i){let n={uid:"",type:"ACTION",description:t||e.action_description||"",action_entity:e,locator:i},a=id(n);if(typeof a=="object"&&a!==null){let o={...a};return delete o.intent,delete o.VERIFY,delete o.WAIT_UNTIL,delete o.WAIT,delete o.statement,Object.keys(o).length>0?Oi(o,Tt).trim():""}return Oi(a,Tt).trim()}function ad(e){let t=ua(e);if(!t||typeof t!="object")throw new Error("Invalid YAML: expected an object");if("VERIFY"in t){let c=String(t.VERIFY),u=typeof t.js=="string"?t.js:void 0;return{description:c,actionEntity:{action_description:c,action_data:{action_name:"verify",kwargs:{statement:c,...u?{code:u}:{}}}}}}if("URL"in t){let c=String(t.URL),u={url:c};return t.new_tab===!0&&(u.new_tab=!0),typeof t.timeout_seconds=="number"&&(u.timeout_seconds=t.timeout_seconds),{description:`Navigate to ${c}`,actionEntity:{action_description:`Navigate to ${c}`,action_data:{action_name:"go_to_url",kwargs:u}}}}if("CODE"in t){let c=String(t.CODE);return{description:c,actionEntity:{action_description:c,action_data:{action_name:"js_code",kwargs:{code:c}}}}}if("WAIT_UNTIL"in t){let c=String(t.WAIT_UNTIL),u={condition:c};return typeof t.timeout_seconds=="number"&&(u.timeout_seconds=t.timeout_seconds),{description:`Wait until ${c}`,actionEntity:{action_description:`Wait until ${c}`,action_data:{action_name:"ai_wait_until",kwargs:u}}}}if("WAIT"in t){let c=String(t.WAIT),u={};return typeof t.seconds=="number"&&(u.seconds=t.seconds),{description:c,actionEntity:{action_description:c,action_data:{action_name:"wait",kwargs:u}}}}let i=typeof t.intent=="string"?t.intent:void 0,n=typeof t.action=="string"?t.action:void 0,a=typeof t.locator=="string"?t.locator:void 0,o=typeof t.xpath=="string"?t.xpath:void 0,r=Array.isArray(t.frame_path)?t.frame_path:void 0,s=Array.isArray(t.args)?t.args:void 0,l={};for(let[c,u]of Object.entries(t))jp.has(c)||(l[c]=u);return!n&&t.js?{description:i,actionEntity:{action_description:i||"",action_data:{action_name:"js_action",kwargs:{code:t.js}}}}:n?{actionEntity:{action_description:i||"",action_data:{action_name:n,kwargs:l,...s&&s.length>0?{args:s}:{}},...a?{locator:a}:{},...o?{xpath:o}:{},...r?{frame_path:r}:{}},description:i,locator:a}:{description:i,actionEntity:{action_description:i||""}}}function zp(e){if(e.template_path){let i={template:e.template_path};return e.template_params&&Object.keys(e.template_params).length>0&&(i.params=e.template_params),i}let t={STEP:e.description,statements:e.statements.map(ae)};return e.reference_id!==void 0&&(t.reference_id=e.reference_id),t}function Vp(e){let t={IF:od(e.condition),THEN:e.then.map(ae)};return e.else&&e.else.length>0&&(t.ELSE=e.else.map(ae)),t}function Xp(e){let t={WHILE:od(e.condition),DO:e.body.map(ae)};return e.timeout_ms!==void 0&&(t.timeout_ms=e.timeout_ms),t}function od(e){return e.type==="JS_CODE"?`js:${e.expression}`:e.expression}function rd(e){let t=Bp(e),i;if(t.length>1||t.length===1&&!Array.isArray(t[0]?.toJSON()))i=t.map((n,a)=>n.errors.length>0?{__parseError:`Document ${a+1}: ${n.errors[0].message}`}:n.toJSON());else{let n;try{n=ua(e)}catch(a){throw new Error(`Invalid YAML: ${a instanceof Error?a.message:String(a)}`)}if(!Array.isArray(n))throw new Error("Expected a YAML array or multi-document YAML (separated by ---)");i=n}return i.map((n,a)=>{try{if(n&&typeof n=="object"&&"__parseError"in n)return{error:n.__parseError};if(!n||typeof n!="object")return{error:`Item ${a+1}: expected an object`};let o=n,r=typeof o.name=="string"&&o.name.trim()||void 0,s=typeof o.goal=="string"?o.goal.trim():"";if(!s)return{error:`Item ${a+1}: missing "goal" field`};if(Array.isArray(o.statements))try{let l=Oi(o,Tt),d=qe(l);return{name:r,goal:d.goal??s,testFlow:d}}catch{}return{name:r,goal:s}}catch(o){return{error:`Item ${a+1}: ${o instanceof Error?o.message:String(o)}`}}})}function sd(e){try{let t=ua(e);if(!t||typeof t!="object")return{};let i={};return typeof t.test_case_id=="number"&&Number.isFinite(t.test_case_id)&&(i.test_case_id=t.test_case_id),typeof t.template_id=="number"&&Number.isFinite(t.template_id)&&(i.template_id=t.template_id),typeof t.name=="string"&&t.name.trim()&&(i.name=t.name.trim()),typeof t.timeout=="number"&&Number.isFinite(t.timeout)&&(i.timeout=t.timeout),t.settings&&typeof t.settings=="object"&&!Array.isArray(t.settings)&&(i.settings=t.settings),i}catch{return{}}}function Co(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Co);let t=e,i=Object.keys(t);if(i.length===1){let a=i[0];if(a.startsWith("{ ")&&a.endsWith(" }")&&t[a]===null)return`{{${a.slice(2,-2)}}}`}let n={};for(let[a,o]of Object.entries(t))n[a]=Co(o);return n}function qe(e){if(e.length>Zc)throw new Error(`YAML input too large (${e.length} bytes, max ${Zc})`);let t=Co(ua(e));if(!t||typeof t!="object")throw new Error("Invalid YAML: expected an object at root level");if(t.suite)return Yp(t);let i={version:"1.3.0",goal:t.goal,url:t.url,baseURL:t.base_url,statements:oe(t.statements??[])};t.final_feedback&&(i.final_feedback=t.final_feedback),t.teardown&&Array.isArray(t.teardown)&&(i.teardown=oe(t.teardown));let n=da.safeParse(i);if(!n.success)throw new Error(`Invalid TestFlow after YAML conversion: ${JSON.stringify(n.error.errors)}`);let a=n.data;return Lo(e,a),a}function Yp(e){let t=e.suite;if(!t||typeof t!="object")throw new Error("Invalid suite: expected an object");let i=t.tests;if(!Array.isArray(i)||i.length===0)throw new Error('Suite must have a non-empty "tests" array');let a={tests:i.map(s=>{if(!s.name)throw new Error('Each test in a suite must have a "name" field');if(!Array.isArray(s.statements)||s.statements.length===0)throw new Error(`Suite test "${s.name}" must have a non-empty "statements" array`);let l={name:s.name,statements:oe(s.statements)};return Array.isArray(s.teardown)&&s.teardown.length>0&&(l.teardown=oe(s.teardown)),s.skip!==void 0&&(l.skip=s.skip),typeof s.timeout=="number"&&(l.timeout=s.timeout),s.fail!==void 0&&(l.fail=s.fail),s.only===!0&&(l.only=!0),s.slow===!0&&(l.slow=!0),l})};Array.isArray(t.beforeAll)&&t.beforeAll.length>0&&(a.beforeAll=oe(t.beforeAll)),Array.isArray(t.afterAll)&&t.afterAll.length>0&&(a.afterAll=oe(t.afterAll)),Array.isArray(t.beforeEach)&&t.beforeEach.length>0&&(a.beforeEach=oe(t.beforeEach)),Array.isArray(t.afterEach)&&t.afterEach.length>0&&(a.afterEach=oe(t.afterEach));let o=Li.safeParse(a);if(!o.success)throw new Error(`Invalid TestGroup: ${JSON.stringify(o.error.errors)}`);return{version:"1.3.0",baseURL:t.base_url||void 0,testGroup:o.data}}function oe(e){if(!Array.isArray(e))throw new Error("Expected an array of statements");return e.map(Jp)}function Jp(e){if(typeof e=="string")throw new Error(`Plain string statements are not supported. Use an object with a "desc" key instead. Example: { "desc": "${e}" }`);if(typeof e!="object"||e===null)throw new Error(`Invalid statement: expected object, got ${typeof e}`);let t=e;if("IF"in t)return qp(t);if("WHILE"in t)return Zp(t);if("STEP"in t)return Qp(t);if("VERIFY"in t){let i=t.VERIFY,n={statement:typeof i=="string"?i:String(i)};return typeof t.js=="string"&&(n.code=t.js),{uid:ce(),type:"ACTION",description:String(i),action_entity:{action_description:String(i),action_data:{action_name:"verify",kwargs:n}}}}if("URL"in t){let i=t.URL,n=t.new_tab===!0?!0:void 0,a=typeof t.timeout_seconds=="number"?t.timeout_seconds:void 0,o={url:typeof i=="string"?i:String(i)};return n&&(o.new_tab=!0),a!==void 0&&(o.timeout_seconds=a),{uid:ce(),type:"ACTION",description:`Navigate to ${i}`,action_entity:{action_description:`Navigate to ${i}`,action_data:{action_name:"go_to_url",kwargs:o}}}}if("WAIT_UNTIL"in t){let i=t.WAIT_UNTIL,n=typeof t.timeout_seconds=="number"?t.timeout_seconds:60;return{uid:ce(),type:"ACTION",description:`Wait until: ${i}`,action_entity:{action_description:`Wait until: ${i}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:typeof i=="string"?i:String(i),timeout_seconds:n}}}}}if("WAIT"in t){let i=t.WAIT,n=typeof t.seconds=="number"?t.seconds:3;return{uid:ce(),type:"ACTION",description:typeof i=="string"?i:`Wait ${n}s`,action_entity:{action_description:typeof i=="string"?i:`Wait ${n}s`,action_data:{action_name:"wait",kwargs:{seconds:n}}}}}if("CODE"in t){let i=t.CODE;if(i==null)throw new Error('CODE statement has no code. Use "CODE: |" followed by indented code on the next line.');return{uid:ce(),type:"ACTION",description:"Code block",action_entity:{action_description:"Code block",action_data:{action_name:"js_code",kwargs:{code:typeof i=="string"?i:String(i)}}}}}if("js"in t&&("intent"in t||"desc"in t)&&!("VERIFY"in t)&&t.action!=="verify"){let i=t.js,n=typeof t.intent=="string"?t.intent:typeof t.desc=="string"?t.desc:"";return{uid:ce(),type:"ACTION",description:n,action_entity:{action_description:n,action_data:{action_name:"js_action",kwargs:{code:typeof i=="string"?i:String(i)}}}}}if("call"in t&&typeof t.call=="string"){let{call:i,...n}=t;return Qc({...n,action:"function",functionName:i})}if("action"in t)return Qc(t);if("intent"in t&&typeof t.intent=="string"||"desc"in t&&typeof t.desc=="string")return{uid:ce(),type:"DRAFT",description:typeof t.intent=="string"?t.intent:t.desc};throw new Error(`Cannot infer statement type from object: ${JSON.stringify(t)}`)}function ld(e){if(typeof e!="string")throw new Error(`Condition must be a string, got ${typeof e}`);return e.startsWith("js:")?{type:"JS_CODE",expression:e.slice(3)}:{type:"AI_MODE",expression:e}}function qp(e){let t=ld(e.IF),i=e.THEN;if(!Array.isArray(i))throw new Error("IF_ELSE requires a THEN array");let n={uid:ce(),type:"IF_ELSE",condition:t,then:oe(i)};return"ELSE"in e&&Array.isArray(e.ELSE)&&(n.else=oe(e.ELSE)),n}function Zp(e){let t=ld(e.WHILE),i=e.DO;if(!Array.isArray(i))throw new Error("WHILE_LOOP requires a DO array");let n={uid:ce(),type:"WHILE_LOOP",condition:t,body:oe(i)};return typeof e.timeout_ms=="number"&&(n.timeout_ms=e.timeout_ms),n}function Qp(e){let t=typeof e.STEP=="string"?e.STEP:"";if(!Array.isArray(e.statements))throw new Error("STEP requires a statements array");let i={uid:ce(),type:"STEP",description:t,statements:oe(e.statements)};if(typeof e.reference_id=="number"&&(i.reference_id=e.reference_id),typeof e.template_path=="string"&&(i.template_path=e.template_path),e.template_params&&typeof e.template_params=="object"&&!Array.isArray(e.template_params)){let n=e.template_params,a={};for(let[o,r]of Object.entries(n))a[o]=String(r);i.template_params=a}return i}function Qc(e){let t=typeof e.action=="string"?e.action:String(e.action),i=typeof e.intent=="string"?e.intent:typeof e.desc=="string"?e.desc:"",n=typeof e.locator=="string"?e.locator:void 0,a=typeof e.xpath=="string"?e.xpath:void 0,o=typeof e.use_pure_vision=="boolean"?e.use_pure_vision:void 0,r={};for(let[d,c]of Object.entries(e))eg.has(d)||(r[d]=c);t==="verify"&&typeof r.js=="string"&&(r.code=r.js,delete r.js);let s={action_description:i,action_data:{action_name:t,kwargs:Object.keys(r).length>0?r:{}}};n&&(s.locator=n),a&&(s.xpath=a);let l={uid:ce(),type:"ACTION",description:i,action_entity:s};return o&&(l.use_pure_vision=!0),l}function Lo(e,t){let i;try{i=Up(e)}catch{return}let n=i.contents;if(!n||!Et(n))return;if(i.commentBefore)t.comment=i.commentBefore;else{let l=n.items?.[0];l?.key&&l.key.commentBefore&&(t.comment=l.key.commentBefore)}let a=n,o=a.get("statements",!0);de(o)&&t.statements&&St(o,t.statements);let r=a.get("teardown",!0);de(r)&&t.teardown&&St(r,t.teardown)}function St(e,t){e.commentBefore&&t.length>0&&(t[0].comment=e.commentBefore);for(let i=0;i<Math.min(e.items.length,t.length);i++){let n=e.items[i];n.commentBefore&&!(i===0&&e.commentBefore)&&(t[i].comment=n.commentBefore);let a=t[i];if(a.type==="STEP"&&Et(n)){let o=n.get("statements",!0);de(o)&&St(o,a.statements)}else if(a.type==="IF_ELSE"&&Et(n)){let o=n.get("THEN",!0);de(o)&&St(o,a.then);let r=n.get("ELSE",!0);de(r)&&a.else&&St(r,a.else)}else if(a.type==="WHILE_LOOP"&&Et(n)){let o=n.get("DO",!0);de(o)&&St(o,a.body)}}}var Tt,jp,Zc,eg,ha=y(()=>{"use strict";Io();Tt={lineWidth:120,defaultKeyType:"PLAIN",defaultStringType:"PLAIN"};jp=new Set(["intent","action","locator","xpath","frame_path","args"]);Zc=1024*1024;eg=new Set(["action","intent","desc","locator","xpath","use_pure_vision"])});import{parse as tg,stringify as ig}from"yaml";function Do(e,t){let i=[];t.version!=="1.0"&&i.push(`Unsupported patch version: ${t.version}`),(!Array.isArray(t.operations)||t.operations.length===0)&&i.push("Patch must have at least one operation");for(let n=0;n<t.operations.length;n++){let a=t.operations[n],o=`operations[${n}]`;switch(a.reason||i.push(`${o}: missing reason`),a.op){case"remove":{(typeof a.index!="number"||a.index<0||a.index>=e.length)&&i.push(`${o}: index ${a.index} out of bounds (0..${e.length-1})`);break}case"modify":{(typeof a.index!="number"||a.index<0||a.index>=e.length)&&i.push(`${o}: index ${a.index} out of bounds (0..${e.length-1})`),(a.statement===void 0||a.statement===null)&&i.push(`${o}: missing statement`);break}case"insert":{(typeof a.index!="number"||a.index<0||a.index>=e.length)&&i.push(`${o}: index ${a.index} out of bounds (0..${e.length-1})`),a.position!=="before"&&a.position!=="after"&&i.push(`${o}: position must be 'before' or 'after'`),(a.statement===void 0||a.statement===null)&&i.push(`${o}: missing statement`);break}default:i.push(`${o}: unknown operation type "${a.op}"`)}}return{valid:i.length===0,errors:i}}function Oo(e,t){let i=Do(e,t);if(!i.valid)throw new Error(`Invalid patch: ${i.errors.join("; ")}`);let n=[...e],a=t.operations.map((s,l)=>({...s,originalOrder:l})),o={remove:0,modify:1,insert:2},r=[...a].sort((s,l)=>s.index!==l.index?l.index-s.index:o[s.op]-o[l.op]);for(let s of r)switch(s.op){case"remove":n.splice(s.index,1);break;case"modify":n[s.index]=s.statement;break;case"insert":s.position==="before"?n.splice(s.index,0,s.statement):n.splice(s.index+1,0,s.statement);break}return n}function cd(e,t){let i=tg(e);if(!i||typeof i!="object")throw new Error("Invalid YAML: expected an object at root level");let n=i.statements;if(!Array.isArray(n))throw new Error('YAML must have a "statements" array');let a=Oo(n,t);i.statements=a;let o=ig(i,{lineWidth:120,defaultKeyType:"PLAIN",defaultStringType:"PLAIN"});return qe(o),{modifiedYaml:o,modifiedStatements:a}}var dd=y(()=>{"use strict";ha()});function No(e){for(let t of e){if(t.type==="STEP"){let n=t;if(n.reference_id||n.template_path)return!0}let i=Me(t);for(let n of i)if(No(n.statements))return!0}return!1}function md(e){let t=new Set;function i(n){for(let a of n){if(a.type==="STEP"){let r=a;r.reference_id&&t.add(r.reference_id)}let o=Me(a);for(let r of o)i(r.statements)}}return i(e),Array.from(t)}function fd(e){if(!e?.statements||!Array.isArray(e.statements))return{};let t={};return He(e.statements,"main",t),e.teardown&&Array.isArray(e.teardown)&&He(e.teardown,"teardown",t),t}function Oe(e,t,i){let n=e+".",a=t.filter(([c])=>c===e||c.startsWith(n));if(a.length===0)return[];let o=[],r=new Set;for(let[c]of a){let u=c===e?"":c.slice(n.length);if(!u)continue;let m=u.split(".")[0];r.has(m)||r.add(m)}let s=Array.from(r);s.sort((c,u)=>{let m=/^\d+$/.test(c)?parseInt(c,10):-1,g=/^\d+$/.test(u)?parseInt(u,10):-1;return m>=0&&g>=0?m-g:c==="then"&&u==="else"?-1:c==="else"&&u==="then"||c==="body"?1:u==="body"?-1:c.localeCompare(u)});function l(c){return i[c]}function d(c){let u=c.match(/^(IF|WHILE)\s+([\s\S]+)$/);return{type:"AI_MODE",expression:(u?u[2].trim():c)||"true"}}for(let c of s){let u=e?`${e}.${c}`:c,m=l(u),g=m?.description??"",w=u;if(c==="then"){let _=`${e}.then`,k=`${e}.else`,E=Oe(_,t,i),I=Oe(k,t,i),C=l(e),$=C?d(C.description):{type:"JS_CODE",expression:"true"};o.push({uid:e,type:"IF_ELSE",condition:$,then:E,...I.length>0?{else:I}:{}});continue}if(c==="else")continue;if(c==="body"){let _=`${e}.body`,k=Oe(_,t,i),E=l(e),I=E?d(E.description):{type:"JS_CODE",expression:"true"};o.push({uid:e,type:"WHILE_LOOP",condition:I,body:k});continue}let v=`${e}.${c}`,x=t.some(([_])=>_.startsWith(v+".then.")||_===v+".then"),p=t.some(([_])=>_.startsWith(v+".else.")||_===v+".else"),f=t.some(([_])=>_.startsWith(v+".body.")||_===v+".body"),S=t.filter(([_])=>{if(!_.startsWith(v+"."))return!1;let E=_.slice(v.length+1).split(".")[0];return/^\d+$/.test(E)&&E!=="then"&&E!=="else"&&E!=="body"});if(x||p){let _=v+".then",k=v+".else",E=Oe(_,t,i),I=Oe(k,t,i),C=m?d(g):{type:"JS_CODE",expression:"true"};o.push({uid:u,type:"IF_ELSE",condition:C,then:E,...I.length>0?{else:I}:{}})}else if(f){let _=v+".body",k=Oe(_,t,i),E=m?d(g):{type:"JS_CODE",expression:"true"};o.push({uid:u,type:"WHILE_LOOP",condition:E,body:k})}else if(S.length>0){let _=Oe(v,t,i);o.push({uid:u,type:"STEP",description:g||"Group",statements:_})}else o.push({uid:u,type:"ACTION",description:g||"Action",action_entity:m?.action_entity})}return o}function wd(e){let t=Object.entries(e),i=n=>{let a=n+".";return t.some(([r])=>r===n||r.startsWith(a))?Oe(n,t,e):[]};return{before:i("before"),main:i("main"),teardown:i("teardown"),after:i("after")}}var Me,ie,Ne,Re,Fe,Ni,ud,hd,ng,ag,pd,gd,He,ma=y(()=>{"use strict";Me=e=>{let t=[];switch(e.type){case"STEP":e.statements&&t.push({key:"statements",statements:e.statements});break;case"IF_ELSE":e.then&&t.push({key:"then",statements:e.then}),e.else&&t.push({key:"else",statements:e.else});break;case"WHILE_LOOP":e.body&&t.push({key:"body",statements:e.body});break}return t},ie=(e,t,i=void 0,n="root")=>{for(let a=0;a<e.length;a++){let o=e[a],r=o.uid;if(r===t)return{stableId:r,path:[a],statement:o,parent:i,containerKey:n,index:a};let s=Me(o);for(let l of s){let d=ie(l.statements,t,o,l.key);if(d)return{...d,path:[a,l.key,...d.path]}}}return null},Ne=(e,t,i)=>{let n=ie(e,t);if(!n)return null;let{statement:a,parent:o,containerKey:r,index:s}=n,l=null;switch(a.type){case"DRAFT":case"ACTION":l=Re(e,n)||Fe(e,n);break;case"STEP":if(a.statements&&a.statements.length>0)return a.statements[0];l=Re(e,n)||Fe(e,n);break;case"IF_ELSE":if(i===!0&&a.then&&a.then.length>0)return a.then[0];if(i===!1&&a.else&&a.else.length>0)return a.else[0];l=Re(e,n)||Fe(e,n);break;case"WHILE_LOOP":if(i===!0&&a.body&&a.body.length>0)return a.body[0];l=Re(e,n)||Fe(e,n);break;default:l=Re(e,n)||Fe(e,n);break}if(o&&o.type==="WHILE_LOOP"&&r==="body"){if(!l)return o;let d=ie(e,l.uid);if(!d||d.parent!==o)return o}return l},Re=(e,t)=>{if(!t.parent)return e[t.index+1]||null;let n=Me(t.parent).find(a=>a.key===t.containerKey);return n&&t.index+1<n.statements.length?n.statements[t.index+1]:null},Fe=(e,t)=>{if(!t.parent)return null;let i=t.parent.uid,n=ie(e,i);return n?Re(e,n)||Fe(e,n):null},Ni=e=>{let t=[],i=n=>{for(let a of n){t.push(a);let o=Me(a);for(let r of o)i(r.statements)}};return i(e),t},ud=e=>{switch(e.type){case"DRAFT":case"ACTION":return!0;case"STEP":return!0;case"IF_ELSE":case"WHILE_LOOP":return!0;default:return!1}},hd=(e,t,i)=>{if(!ie(e,t))return null;if(i===null){let s=[],l=t;for(;l!==null&&ie(e,l);)if(s.push(l),l=Ne(e,l)?.uid||null,s.length>1e3)return null;return s}if(!ie(e,i))return null;if(t===i)return[];let o=[],r=t;for(;r&&r!==i;){let s=ie(e,r);if(!s)break;if(o.push(r),s.statement.type==="IF_ELSE"){let l=ng(s.statement,i);l?r=Ne(e,r,l==="then")?.uid||null:r=Ne(e,r)?.uid||null}else s.statement.type==="WHILE_LOOP"?ag(s.statement,i)?r=Ne(e,r,!0)?.uid||null:r=Ne(e,r,!1)?.uid||null:r=Ne(e,r)?.uid||null;if(o.length>1e3)return null}return r===i?o:null},ng=(e,t)=>{if(e.type!=="IF_ELSE")return null;let i=e;return i.then&&ie(i.then,t)?"then":i.else&&ie(i.else,t)?"else":null},ag=(e,t)=>{if(e.type!=="WHILE_LOOP")return!1;let i=e;return!!(i.body&&ie(i.body,t))};pd=e=>e.startsWith("ai_")?!0:["js_code","function","assert","verify","wait_for_download_complete","extract_activation_code","extract_email_content"].includes(e),gd=e=>!["js_code","function","assert","ai_assert","verify","ai_extract","ai_wait_until","upload_file","login","extract_activation_code","extract_email_content","ai_step"].includes(e),He=(e,t,i)=>{e.forEach((n,a)=>{let o=`${t}.${a}`;n.type==="DRAFT"?i[o]={description:n.description||"Draft",action_entity:void 0}:n.type==="ACTION"?i[o]={description:n.description||"Action",action_entity:n.action_entity,locator:n.locator}:n.type==="STEP"&&n.statements?He(n.statements,o,i):n.type==="IF_ELSE"?(i[o]={description:"IF "+(n.condition?.expression||""),action_entity:void 0},n.then&&He(n.then,`${o}.then`,i),n.else&&He(n.else,`${o}.else`,i)):n.type==="WHILE_LOOP"&&(i[o]={description:"WHILE "+(n.condition?.expression||""),action_entity:void 0},n.body&&He(n.body,`${o}.body`,i))})}});function Fo(e){let t=0,i=0;for(let n of e)if(n.type==="DRAFT")i++;else if(n.type==="ACTION"){let a=n.action_entity?.action_data?.action_name??"";Ro.has(a)||t++}return{action:t,draft:i}}function rg(e){try{return new Function(`return async function() { ${e} }`),null}catch(t){return t.message}}function xd(e){try{return new Function(`return async function() { return (${e}) }`),null}catch(t){return t.message}}function sg(e){let t=e.split(/\r?\n/).map(a=>a.trim()).filter(a=>a.length>0&&!a.startsWith("//")).length,i=e.match(/\bawait\b/g),n=i?i.length:0;return t<=bd&&n<=yd?null:`${t} non-blank line(s), ${n} await(s) \u2014 limits are ${bd} lines and ${yd} awaits. The js: field is a cache for one natural-language intent, not a place for multi-step logic. Break this into multiple statements \u2014 one VERIFY or intent+js per UI interaction or assertion \u2014 so each step is visible in the debugger and self-healable.`}function vd(e,t){let i=t?.coverageThreshold??og,n=[],a=[],o;try{o=qe(e)}catch(m){return{valid:!1,errors:[`Invalid YAML: ${m.message}`],warnings:[],stats:{total:0,action:0,draft:0,coverage:0}}}o.goal||n.push('Missing required field: "goal"'),o.statements?.length||n.push('Missing required field: "statements"');let r=[...Ni(o.statements??[]),...o.teardown?Ni(o.teardown):[]],{action:s,draft:l}=Fo(r),d="Hint: in YAML double-quoted strings, backslashes are escape characters \u2014 use \\\\/ instead of \\/ for regex, or use single quotes.";for(let m of r){let g=m;if(g.reference_id!==void 0){let w=g.description||m.uid;n.push(`Unresolved cloud template reference on statement "${w}" (reference_id: ${g.reference_id}). Local YAML tests cannot use reference_id \u2014 inline the template statements or use the local "template:" key instead.`)}if(m.type==="ACTION"){let w=m,v=w.action_entity?.action_data?.action_name??"";if(v==="js_code"||v==="js_action"||v==="verify"||v==="ai_assert"){let x=w.action_entity?.action_data?.kwargs?.code;if(typeof x=="string"){let p=rg(x);if(p){let f=w.description||v;n.push(`Invalid JS in "${f}": ${p}. ${d}`)}else if(v==="verify"||v==="js_action"){let f=sg(x);if(f){let S=w.description||v;n.push(`JS cache for "${S}" is too complex: ${f}`)}}}}}if(m.type==="IF_ELSE"){let w=m;if(w.condition.type==="JS_CODE"){let v=xd(w.condition.expression);v&&n.push(`Invalid JS in IF condition "${w.condition.expression}": ${v}. ${d}`)}}if(m.type==="WHILE_LOOP"){let w=m;if(w.condition.type==="JS_CODE"){let v=xd(w.condition.expression);v&&n.push(`Invalid JS in WHILE condition "${w.condition.expression}": ${v}. ${d}`)}}}let c=s+l,u=c>0?Math.round(s/c*100):0;return c>0&&u/100<i&&a.push(`Low action coverage: ${s}/${c} statements (${u}%) are enriched with action/js. ${l} draft statement(s) still need enrichment. Use MCP tools (act, get_locators) to convert drafts to actions.`),{valid:n.length===0,errors:n,warnings:a,stats:{total:c,action:s,draft:l,coverage:u}}}var og,bd,yd,Ro,_d=y(()=>{"use strict";ha();ma();og=.5,bd=5,yd=3,Ro=new Set(["verify","ai_assert","done","go_to_url","ai_wait_until","wait","js_code"])});function kd(){return{version:"1.0",entries:{}}}function Sd(e,t){return{action_entity:e,updated_at:new Date().toISOString(),updated_by:{source:"runner",test_run_id:t}}}function Ed(e,t){let i=t?.entries[e.uid],n=i?.action_entity??e.action_entity;return e.locator&&n?{...n,locator:e.locator}:i?i.action_entity:e.action_entity?e.action_entity:null}function Td(e,t,i,n){return e.entries[t]={action_entity:i,updated_at:new Date().toISOString(),updated_by:n},e}function Ad(e,t){let i=e??{version:"1.0",entries:{}};for(let[n,a]of t)i.entries[n]=a;return i}function Md(e){return e?Object.keys(e.entries).length===0:!0}function Id(e){return e?Object.keys(e.entries).length:0}function Cd(e,t){if(!t||Object.keys(t.entries).length===0)return e;let i=Ho(e.statements??[],t),n=e.teardown?Ho(e.teardown,t):void 0;return{...e,statements:i,teardown:n}}function Ho(e,t){return e.map(i=>lg(i,t))}function lg(e,t){if(e.type==="ACTION"){let a=e,o=t.entries[a.uid];return o?{...a,action_entity:o.action_entity}:a}let i=Me(e);if(i.length===0)return e;let n={};for(let a of i)n[a.key]=Ho(a.statements,t);return{...e,...n}}var Pd=y(()=>{"use strict";ma()});import{v4 as cg}from"uuid";function Bo(e){let t=e.match(/\.getByRole\(['"]([^'"]+)['"]/);if(t&&t[1]){let p=e.match(/\.filter\(\{\s*hasText:\s*['"]([^'"]*(?:\\.[^'"]*)*)['"]\s*\}\)/);if(p&&p[1]){let S=p[1].replace(/\\(.)/g,"$1");return`${t[1]} element with text "${S}"`}let f=e.match(/\.filter\(\{\s*hasText:\s*(\/.*?\/[gimuy]*)\s*\}\)/);if(f&&f[1]){let S=f[1].replace(/^\/|\/$/g,""),_=S.length>30?`${S.substring(0,27)}...`:S;return`${t[1]} element with text matching "${_}"`}return`${t[1]} element`}let i=e.match(/\.filter\(\{\s*hasText:\s*['"]([^'"]*(?:\\.[^'"]*)*)['"]\s*\}\)/);if(i&&i[1]){let p=At(e),f=i[1].replace(/\\(.)/g,"$1");return`${p} with text "${f}"`}let n=e.match(/\.filter\(\{\s*hasText:\s*(\/.*?\/[gimuy]*)\s*\}\)/);if(n&&n[1])return`${At(e)} with text matching ${n[1]}`;let a=e.match(/\.filter\(\{\s*has:\s*[^}]+getByText\('((?:[^'\\]|\\.)*)'(?:,\s*\{[^}]*\})?\)/);if(a&&a[1]){let p=At(e),f=a[1].replace(/\\(.)/g,"$1");return`${p} containing "${f}"`}let o=e.match(/\.filter\(\{\s*has:\s*[^}]+getByText\("((?:[^"\\]|\\.)*)"(?:,\s*\{[^}]*\})?\)/);if(o&&o[1]){let p=At(e),f=o[1].replace(/\\(.)/g,"$1");return`${p} containing "${f}"`}let r=e.match(/\.filter\(\{\s*hasNot:\s*[^}]+getByText\('((?:[^'\\]|\\.)*)'(?:,\s*\{[^}]*\})?\)/);if(r&&r[1]){let p=At(e),f=r[1].replace(/\\(.)/g,"$1");return`${p} not containing "${f}"`}let s=e.match(/\.filter\(\{\s*hasNot:\s*[^}]+getByText\("((?:[^"\\]|\\.)*)"(?:,\s*\{[^}]*\})?\)/);if(s&&s[1]){let p=At(e),f=s[1].replace(/\\(.)/g,"$1");return`${p} not containing "${f}"`}let l=e.match(/name:\s*'((?:[^'\\]|\\.)*)'/);if(l&&l[1])return`"${l[1].replace(/\\(.)/g,"$1")}"`;let d=e.match(/name:\s*"((?:[^"\\]|\\.)*)"/);if(d&&d[1])return`"${d[1].replace(/\\(.)/g,"$1")}"`;let c=e.match(/getByText\('((?:[^'\\]|\\.)*)'(?:,\s*\{[^}]*\})?\)/);if(c&&c[1])return`"${c[1].replace(/\\(.)/g,"$1")}"`;let u=e.match(/getByText\("((?:[^"\\]|\\.)*)"(?:,\s*\{[^}]*\})?\)/);if(u&&u[1])return`"${u[1].replace(/\\(.)/g,"$1")}"`;let m=e.match(/getByPlaceholder\('((?:[^'\\]|\\.)*)'(?:,\s*\{[^}]*\})?\)/);if(m&&m[1])return`input with placeholder "${m[1].replace(/\\(.)/g,"$1")}"`;let g=e.match(/getByPlaceholder\("((?:[^"\\]|\\.)*)"(?:,\s*\{[^}]*\})?\)/);if(g&&g[1])return`input with placeholder "${g[1].replace(/\\(.)/g,"$1")}"`;let w=e.match(/getByLabel\('((?:[^'\\]|\\.)*)'(?:,\s*\{[^}]*\})?\)/);if(w&&w[1])return`"${w[1].replace(/\\(.)/g,"$1")}"`;let v=e.match(/getByLabel\("((?:[^"\\]|\\.)*)"(?:,\s*\{[^}]*\})?\)/);if(v&&v[1])return`"${v[1].replace(/\\(.)/g,"$1")}"`;let x=e.match(/getByRole\(['"]([^'"]+)['"]/);return x&&x[1]?`${x[1]} element`:e.length>50?`${e.substring(0,47)}...`:e}function Uo(e,t){if(!e||!t)return null;let i=t.replace(/^ref=/,""),n=e.split(`
4534
- `);for(let a of n){if(!a.includes(`[ref=${i}]`))continue;let s=a.replace(/\s+\[[^\]]+\](?:\s*\[[^\]]+\])*.*$/,"").trim().replace(/^[-–—]\s*/,"").trim().replace(/\\"/g,'"');return s.length>0?s:null}return null}function Go(e,t=""){let i=e.match(/page\d*\.(.+?)\.(click|fill|press|check|uncheck|hover|selectOption|dragTo|dblclick|screenshot|setInputFiles|locator|frameLocator)/);if(i&&i[1])return i[1].trim();let n=e.match(/page\d*\.locator\(([^)]+)\)/);if(n&&n[1])return`locator(${n[1]})`;let a=e.match(/page\d*\.frameLocator\(([^)]+)\)/);return a&&a[1]?`frameLocator(${a[1]})`:t}function At(e){let t=e.match(/^locator\(['"]([^'"]+)['"]\)/);if(t&&t[1]){let a=t[1],o=a.match(/^([a-zA-Z][\w-]*)/);return o?o[1]:a.length>20?`${a.substring(0,17)}...`:a}let i=e.match(/getByRole\(['"]([^'"]+)['"]/);if(i&&i[1])return i[1];let n=e.match(/getByTestId\(['"]([^'"]+)['"]/);return n&&n[1]?`element with testId "${n[1]}"`:"element"}function Wo(e){let t=e.match(/\.fill\(['"]([^'"]*)['"]\)/);if(t&&t[1]!==void 0)return t[1];let i=e.match(/\.press\(['"]([^'"]+)['"]\)/);if(i&&i[1])return i[1];let n=e.match(/\.selectOption\(['"]([^'"]+)['"]\)/);return n&&n[1]?n[1]:""}function dg(e){let t=e.match(/button:\s*['"]([^'"]+)['"]/);return t?t[1]:void 0}function ug(e){let t=e.match(/modifiers:\s*\[([^\]]+)\]/);if(t&&t[1])return t[1].split(",").map(i=>i.trim().replace(/['"]/g,""))}function Ld(e,t){let i=e.name||"unknown",n=Go(t,e.selector||""),a=e.ariaSnapshot??e.arIAaSnapshot??"",o=e.ref,r=/getByTestId\s*\(/.test(n),l=(o&&a&&r?Uo(a,o):null)??Bo(n),d,c,u={};switch(i){case"click":{let m=dg(t),g=ug(t);m==="right"?(d="right_click_on_element",c=`Right click on ${l}`):(d="click_element",c=`Click on ${l}`),u={index:0},m&&m!=="left"&&(u.button=m),g&&(u.modifiers=g);break}case"fill":{let m=e.text||e.value||Wo(t)||"";d="fill",c=m?`Fill ${l} with '${m}'`:`Fill ${l}`,u={value:m,index:0};break}case"press":{let m=e.key||Wo(t)||"";d="press",c=`Press '${m}' on ${l}`,u={keyComb:m,index:0};break}case"selectOption":{let m=e.options?.[0]||Wo(t)||"";d="select_dropdown_option",c=`Select '${m}' from ${l}`,u={text:m,index:0};break}case"check":d="click_element",c=`Check ${l}`,u={index:0};break;case"uncheck":d="click_element",c=`Uncheck ${l}`,u={index:0};break;case"setInputFiles":{let m=e.files||[];d="upload_file",c=m.length>0?`Upload file(s) to ${l}`:`Upload file to ${l}`,u={paths:m,index:0};break}case"navigate":case"goto":d="go_to_url",c=`Navigate to ${e.url||"URL"}`,u={url:e.url||"",new_tab:!1};break;case"dblclick":d="double_click_on_element",c=`Double click on ${l}`,u={index:0};break;case"hover":d="hover",c=`Hover over ${l}`,u={index:0};break;case"wheel":case"scroll":d="scroll",c=`Scroll on ${l}`,u={x:e.deltaX||0,y:e.deltaY||0,index:e.selector?0:-1};break;case"dragTo":d="drag_drop",c=`Drag ${l} to target`,u={index:0};break;case"screenshot":d="wait",c="Take screenshot",u={seconds:.5};break;case"wait":d="wait",c=`Wait for ${e.timeout||1e3}ms`,u={seconds:(e.timeout||1e3)/1e3};break;default:d="click_element",c=`${i} on ${l}`,u={index:0};break}return{locator:n,xpath:e.xpath||"",css_selector:e.css_selector||"",unique_selector:e.selector||e.css_selector||"",frame_path:e.frame_path||[],action_data:{action_name:d,args:[],kwargs:u},action_description:c,url:"",feedback:""}}var $d,Dd=y(()=>{"use strict";$d=()=>cg()});var Ko,jo,Od,Nd=y(()=>{"use strict";Ko=(e=>(e.DRAFT="DRAFT",e.STEP="STEP",e.ACTION="ACTION",e.IF_ELSE="IF_ELSE",e.WHILE_LOOP="WHILE_LOOP",e))(Ko||{}),jo=(e=>(e.JS_CODE="JS_CODE",e.AI_MODE="AI_MODE",e))(jo||{}),Od=18e4});function Rd(e){return e?e.startsWith(ue)?"android":e.startsWith(he)?"ios":"web":"web"}function Fd(e){return e?e.startsWith(ue)||e.startsWith(he):!1}function Hd(e){return!!e&&e.startsWith(ue)}function Wd(e){return!!e&&e.startsWith(he)}function Bd(e){return e.startsWith(ue)?e.slice(ue.length):e.startsWith(he)?e.slice(he.length):e}function Ud(e){return`${ue}${e}`}function Gd(e){return`${he}${e}`}function pa(e){return e?e.startsWith("http://")||e.startsWith("https://"):!1}function Kd(e){return e?!pa(e):!1}function zo(e){return e?pa(e)?["web"]:["android","ios"]:["web","android","ios"]}function jd(e,t){if(!t)return!0;let i=zo(t);return e==="desktop"||e==="mobile"?i.includes("web"):i.includes(e)}var ue,he,ga=y(()=>{"use strict";ue="android:",he="ios:"});function zd(e){return e.startsWith(he)?e:`${he}${e}`}function Vd(e){let t=e.iosVersion?` (iOS ${e.iosVersion})`:"";return e.deviceType==="simulator"?`${e.name}${t} - Simulator`:`${e.name}${t}`}function Xd(e){return!!(/^[0-9a-fA-F]{40}$/.test(e)||/^[0-9a-fA-F]{8}-[0-9a-fA-F]{16}$/.test(e))}var Yd=y(()=>{"use strict";ga()});var Vo,fa,Xo,Yo,Jo,qo,Zo,Qo,er,tr,Ze,ir,Ri,nr,ar,Mt,Jd,Fi,qd,Zd,wa,Qd,eu,tu,iu,nu=y(()=>{"use strict";Vo="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36",fa=112,Xo=1920,Yo=1080,Jo=1920,qo=1080-fa,Zo=1280,Qo=720,er=500,tr=500,Ze="Desktop Chrome",ir=(e=>(e.Chromium="chromium",e.Firefox="firefox",e.Webkit="webkit",e))(ir||{}),Ri={"Blackberry PlayBook":{name:"Blackberry PlayBook",userAgent:"Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML like Gecko) Version/26.0 Safari/536.2+",screen:{width:600,height:1024},viewport:{width:600,height:1024},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"BlackBerry Z30":{name:"BlackBerry Z30",userAgent:"Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/26.0 Mobile Safari/537.10+",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note 3":{name:"Galaxy Note 3",userAgent:"Mozilla/5.0 (Linux; U; Android 4.3; en-us; SM-N900T Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note II":{name:"Galaxy Note II",userAgent:"Mozilla/5.0 (Linux; U; Android 4.1; en-us; GT-N7100 Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S III":{name:"Galaxy S III",userAgent:"Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S5":{name:"Galaxy S5",userAgent:"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S8":{name:"Galaxy S8",userAgent:"Mozilla/5.0 (Linux; Android 7.0; SM-G950U Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:740},viewport:{width:360,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S9+":{name:"Galaxy S9+",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; SM-G965U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:320,height:658},viewport:{width:320,height:658},deviceScaleFactor:4.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S24":{name:"Galaxy S24",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-S921U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:780},viewport:{width:360,height:780},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy A55":{name:"Galaxy A55",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-A556B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:480,height:1040},viewport:{width:480,height:1040},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S4":{name:"Galaxy Tab S4",userAgent:"Mozilla/5.0 (Linux; Android 8.1.0; SM-T837A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:712,height:1138},viewport:{width:712,height:1138},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S9":{name:"Galaxy Tab S9",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-X710) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:640,height:1024},viewport:{width:640,height:1024},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"iPad (gen 5)":{name:"iPad (gen 5)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 6)":{name:"iPad (gen 6)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 7)":{name:"iPad (gen 7)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:810,height:1080},viewport:{width:810,height:1080},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 11)":{name:"iPad (gen 11)",userAgent:"Mozilla/5.0 (iPad; CPU OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/604.1",screen:{width:656,height:944},viewport:{width:656,height:944},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Mini":{name:"iPad Mini",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Pro 11":{name:"iPad Pro 11",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:834,height:1194},viewport:{width:834,height:1194},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6":{name:"iPhone 6",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6 Plus":{name:"iPhone 6 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7":{name:"iPhone 7",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7 Plus":{name:"iPhone 7 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8":{name:"iPhone 8",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8 Plus":{name:"iPhone 8 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE":{name:"iPhone SE",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/14E304 Safari/602.1",screen:{width:320,height:568},viewport:{width:320,height:568},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE (3rd gen)":{name:"iPhone SE (3rd gen)",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/602.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone X":{name:"iPhone X",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:812},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone XR":{name:"iPhone XR",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:896},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11":{name:"iPhone 11",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro":{name:"iPhone 11 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:635},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro Max":{name:"iPhone 11 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12":{name:"iPhone 12",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro":{name:"iPhone 12 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro Max":{name:"iPhone 12 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Mini":{name:"iPhone 12 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13":{name:"iPhone 13",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro":{name:"iPhone 13 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro Max":{name:"iPhone 13 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Mini":{name:"iPhone 13 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14":{name:"iPhone 14",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Plus":{name:"iPhone 14 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro":{name:"iPhone 14 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:660},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro Max":{name:"iPhone 14 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15":{name:"iPhone 15",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Plus":{name:"iPhone 15 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro":{name:"iPhone 15 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro Max":{name:"iPhone 15 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Kindle Fire HDX":{name:"Kindle Fire HDX",userAgent:"Mozilla/5.0 (Linux; U; en-us; KFAPWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"LG Optimus L70":{name:"LG Optimus L70",userAgent:"Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; LGMS323 Build/KOT49I.MS32310c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:1.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 550":{name:"Microsoft Lumia 550",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 550) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 950":{name:"Microsoft Lumia 950",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:4,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 10":{name:"Nexus 10",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 10 Build/MOB31T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 4":{name:"Nexus 4",userAgent:"Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5":{name:"Nexus 5",userAgent:"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5X":{name:"Nexus 5X",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR4.170623.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6":{name:"Nexus 6",userAgent:"Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F26U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6P":{name:"Nexus 6P",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 6P Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 7":{name:"Nexus 7",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MOB30X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:600,height:960},viewport:{width:600,height:960},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia Lumia 520":{name:"Nokia Lumia 520",userAgent:"Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 520)",screen:{width:320,height:533},viewport:{width:320,height:533},deviceScaleFactor:1.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia N9":{name:"Nokia N9",userAgent:"Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13",screen:{width:480,height:854},viewport:{width:480,height:854},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Pixel 2":{name:"Pixel 2",userAgent:"Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:731},viewport:{width:411,height:731},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 2 XL":{name:"Pixel 2 XL",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:823},viewport:{width:411,height:823},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 3":{name:"Pixel 3",userAgent:"Mozilla/5.0 (Linux; Android 9; Pixel 3 Build/PQ1A.181105.017.A1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:786},viewport:{width:393,height:786},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4":{name:"Pixel 4",userAgent:"Mozilla/5.0 (Linux; Android 10; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:353,height:745},viewport:{width:353,height:745},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4a (5G)":{name:"Pixel 4a (5G)",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 4a (5G)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:892},viewport:{width:412,height:765},deviceScaleFactor:2.63,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 5":{name:"Pixel 5",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:851},viewport:{width:393,height:727},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 7":{name:"Pixel 7",userAgent:"Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:915},viewport:{width:412,height:839},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Moto G4":{name:"Moto G4",userAgent:"Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Desktop Chrome HiDPI":{name:"Desktop Chrome HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge HiDPI":{name:"Desktop Edge HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Firefox HiDPI":{name:"Desktop Firefox HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"},"Desktop Safari":{name:"Desktop Safari",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Safari/605.1.15",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"webkit"},"Desktop Chrome":{name:"Desktop Chrome",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome Medium Resolution":{name:"Desktop Chrome Medium Resolution",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome (Branded)":{name:"Desktop Chrome (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Chrome Medium Resolution (Branded)":{name:"Desktop Chrome Medium Resolution (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Edge":{name:"Desktop Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge (Branded)":{name:"Desktop Edge (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Edge Medium Resolution (Branded)":{name:"Desktop Edge Medium Resolution (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Firefox":{name:"Desktop Firefox",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"}},nr=(e=>(e.Desktop="desktop",e.Mobile="mobile",e))(nr||{}),ar={desktop:["Desktop Chrome","Desktop Chrome Medium Resolution","Desktop Chrome (Branded)","Desktop Chrome Medium Resolution (Branded)","Desktop Edge (Branded)","Desktop Edge Medium Resolution (Branded)","Desktop Safari"],mobile:["iPhone 15 Pro Max","iPhone 15 Pro","iPhone 15 Plus","iPhone 15","iPhone 14 Pro Max","iPhone 14 Pro","iPhone 14 Plus","iPhone 14","iPhone 13 Pro Max","iPhone 13 Pro","iPhone 13","iPhone 13 Mini","iPhone 12 Pro Max","iPhone 12 Pro","iPhone 12","iPhone 12 Mini","iPhone 11 Pro Max","iPhone 11 Pro","iPhone 11","iPhone XR","iPhone X","iPhone SE (3rd gen)","iPhone SE","iPhone 8 Plus","iPhone 8","iPhone 7 Plus","iPhone 7","iPhone 6 Plus","iPhone 6","Galaxy S24","Galaxy A55","Galaxy S9+","Galaxy S8","Galaxy S5","Galaxy Note 3","Galaxy Note II","Galaxy S III","Pixel 7","Pixel 5","Pixel 4a (5G)","Pixel 4","Pixel 3","Pixel 2 XL","Pixel 2","Nexus 6P","Nexus 6","Nexus 5X","Nexus 5","Nexus 4","Moto G4","LG Optimus L70","Microsoft Lumia 950","Microsoft Lumia 550","Nokia Lumia 520","Nokia N9","BlackBerry Z30"]},Mt=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),ar[e].map(n=>Ri[n]).filter(n=>n.defaultBrowserType&&i.includes(n.defaultBrowserType))},Jd=()=>Object.keys(Ri),Fi=e=>Ri[e],qd={desktop:{label:"Desktop",type:"desktop",devices:Mt("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:Mt("mobile")}},Zd={desktop:{label:"Desktop",type:"desktop",devices:Mt("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:Mt("mobile",!0)}},wa=(e,t=!1)=>{let i={userAgent:Vo,viewport:{width:Jo,height:qo},isMobile:!1,hasTouch:!1};if(!e||e===Ze)return i;let n=Fi(e);if(!n)return i;let{width:a,height:o}=n.viewport,r=Math.max(er/a,1),s=Math.max(tr/o,1),l=Math.max(r,s),d={width:Math.round(a*l),height:Math.round(o*l)};return{userAgent:n.userAgent,viewport:t?d:n.viewport,isMobile:n.isMobile,hasTouch:n.hasTouch}},Qd=e=>{let t={width:Xo,height:Yo};if(!e||e===Ze)return t;let i=wa(e);return i.viewport?{width:i.viewport.width,height:i.viewport.height+fa}:t},eu=e=>{let t={width:Zo,height:Qo};if(!e||e===Ze)return t;let i=wa(e);return i.viewport?{width:i.viewport.width,height:i.viewport.height}:t},tu=e=>!e||e===Ze?void 0:Fi(e)?.channel,iu=e=>!e||e===Ze?"chromium":Fi(e)?.defaultBrowserType??"chromium"});var or,rr,au=y(()=>{"use strict";or=(e=>(e.PASSWORD="password",e.OAUTH2="oauth2",e.SSO="sso",e.API="api",e))(or||{}),rr=(e=>(e.SMS="sms",e.EMAIL="email",e.TOTP="totp",e))(rr||{})});function ou(e,t){if(!e||typeof e!="string")return e;let i=t instanceof Map?Object.fromEntries(t):t,n=o=>{let r=o.startsWith("$")?o.slice(1):o,s=i[r]??i[`$${r}`];return s!=null?String(s):void 0},a=e;return a=a.replace(/\{\{\s*\$?([^}]+?)\s*\}\}/g,(o,r)=>{let s=n(r.trim());return s!==void 0?s:o}),a=a.replace(/<secret>\$?([\w-]+)<\/secret>/g,(o,r)=>{let s=n(r);return s!==void 0?s:o}),a=a.replace(/\$\{([^}]+)\}/g,(o,r)=>{let s=n(r.trim());return s!==void 0?s:o}),a=a.replace(/\$([a-zA-Z_]\w*)/g,(o,r)=>{let s=n(r);return s!==void 0?s:o}),a}var ru=y(()=>{"use strict"});var su,lu=y(()=>{"use strict";su=class{version;goal;url;constructor(e,t){this.version=e,this.goal=t.goal,this.url=t.url}generatePrelude(){let e=`// version ${this.version}
4532
+ ${s}`);let l=this.agentServices.knowledgeRetriever,d=!1;this.agentServices.hasKnowledgeRetriever()&&l&&(b.log("Setting up login knowledge retriever..."),this.agentServices.setKnowledgeRetriever(async(v,x,p,f)=>await l(v,x,p,"login")),d=!0,b.log("Login knowledge retriever configured"));let c;try{if(c=await this.run(e,s,"login"),!c.success)return b.log("Level 3 FAILED: Agent login failed"),h.info("Login: Failed"),{success:!1,page:e}}finally{d&&l&&(this.agentServices.setKnowledgeRetriever(l),b.log("Restored original knowledge retriever"))}let u=await e.context().storageState(),m;if(a)b.log("Skipping validation locator generation (AI verification mode enabled)");else if(t.num_verification_exprs!==0)try{b.log("Generating validation locators for future login verification...");let v=await aa(e,t.site_url,{verification_hint:t.verification_hint,num_verification_exprs:t.num_verification_exprs},async(x,p)=>this.run(x,p),async x=>this.getDOMText(x));v?(m=v,b.log(`Generated ${m.length} validation locator(s): ${JSON.stringify(m)}`)):b.log("Failed to generate validation locators, login will still succeed")}catch(v){b.log(`Error generating validation locators: ${v.message}`)}else b.log("Skipping validation locator generation (num_verification_exprs=0)");b.log("Level 3 SUCCESS: Agent login succeeded"),h.info("Login: Agent login succeeded");let g=c.actions||[],w=g.length>0?g:i?.cached_actions;return{success:!0,page:e,storage_state:u,cached_actions:w,validation_exprs:m}}catch(l){return b.error(`Agent login failed: ${l.message}`),h.info("Login: Failed"),{success:!1,page:e}}}async executeCachedLogin(e,t,i){let n=(await Promise.resolve().then(()=>(wt(),ft))).default,a=new n;for(let o=0;o<t.length;o++){let r=t[o];b.log(`Executing cached action ${o+1}/${t.length}: ${r.action_description||r.action_data?.action_name}`);try{if(!r.action_data){b.log(`Action ${o+1} missing action_data, skipping`);continue}await a.execute(e,r,this.agentServices),await this.waitUntilStable(e,5e3)}catch(s){return b.error(`Cached action ${o+1} failed: ${s.message}`),{success:!1}}}return i?.aiVerificationStatement?(b.log("Verifying cached login result with AI verification statement"),await this.evaluate(e,i.aiVerificationStatement)?{success:!0}:{success:!1}):i?.validationExprs&&i.validationExprs.length>0?await Pi(e,i.validationExprs)?{success:!0}:{success:!1}:(b.log("Cached login cannot be verified: missing AI verification statement and validation expressions"),{success:!1})}getCompletedExecutionHistory(){if(!this.context.executionHistory||this.context.executionHistory.length===0)return[];let e=this.context.executionHistory[this.context.executionHistory.length-1];return!e[1]||e[1].trim()===""?this.context.executionHistory.slice(0,-1):this.context.executionHistory}addToExecutionHistory(e,t){this.context.executionHistory||(this.context.executionHistory=[]),this.context.executionHistory.push([e,t])}async createStepResult(e,t,i,n){if(this.context.stepTracking&&!this.context.stepTracking.results[t]){this.context.stepTracking.currentStepId=t,this.context.stepTracking.onStepChange&&this.context.stepTracking.onStepChange(t);try{e=this.agentServices.validatePage(e),await this.waitUntilStable(e);let a={description:i,startTime:Date.now(),artifacts:[],type:n,code:i};if(this.context.stepTracking.artifactsDir){let o=q.join(this.context.stepTracking.artifactsDir,t.replace(/\./g,"-"));K.mkdirSync(o,{recursive:!0});let r=q.join(o,"screenshot.png");e=this.agentServices.validatePage(e),await e.screenshot({type:"png",path:r}),a.screenshot=r}a.contextBefore=this.snapshotVariables(),this.context.stepTracking.results[t]=a}catch(a){h.warn(`createStepResult failed for step ${t}: ${a}`),this.context.stepTracking.results[t]={description:i,startTime:Date.now(),artifacts:[],contextBefore:this.snapshotVariables()}}}}snapshotVariables(){return kt(this.context.variableStore.getAll(),this.context.variableStore.getAllSensitiveKeys())}saveDebugInfoToFiles(e,t,i,n=0){let a={};if(!this.context.stepTracking?.artifactsDir)return h.debug("[saveDebugInfoToFiles] No artifacts directory configured, skipping debug info save"),a;let o=q.join(this.context.stepTracking.artifactsDir,e.replace(/\./g,"-"));try{if(K.mkdirSync(o,{recursive:!0}),t.systemPrompt){let r=q.join(o,`system_prompt_${n}.txt`);K.writeFileSync(r,t.systemPrompt),a.system_prompt_path=r,h.debug(`[saveDebugInfoToFiles] Saved system prompt to: ${r}`)}if(t.userPrompt)if(typeof t.userPrompt=="string"){let r=q.join(o,`user_prompt_${n}.txt`);K.writeFileSync(r,t.userPrompt),a.user_prompt_path=r,h.debug(`[saveDebugInfoToFiles] Saved user prompt to: ${r}`)}else{let r=t.userPrompt.map(d=>Array.isArray(d.content)?{...d,content:d.content.map(c=>c.type==="image"&&c.file?.startsWith("data:")?{...c,file:"[base64 image data stripped]"}:c)}:d),s=q.join(o,`messages_${n}.json`),l={system:t.systemPrompt,messages:r};K.writeFileSync(s,JSON.stringify(l,null,2)),a.messages_path=s,h.debug(`[saveDebugInfoToFiles] Saved messages to: ${s}`)}if(t.rawLlmResponse){let r=i?i.replace(/[\/\\:]/g,"-"):"llm",s=q.join(o,`${r}_response_${n}.txt`);K.writeFileSync(s,t.rawLlmResponse),a.response_path=s,h.debug(`[saveDebugInfoToFiles] Saved LLM response to: ${s}`)}if(t.screenshotWithSom){let r=q.join(o,`screenshot_${n}.png`);K.writeFileSync(r,Buffer.from(t.screenshotWithSom,"base64")),a.screenshot_path=r,h.debug(`[saveDebugInfoToFiles] Saved SOM screenshot to: ${r}`)}if(t.reasoningContent){let r=q.join(o,`reasoning_${n}.txt`);K.writeFileSync(r,t.reasoningContent),a.reasoning_path=r,h.debug(`[saveDebugInfoToFiles] Saved reasoning to: ${r}`)}h.debug(`[saveDebugInfoToFiles] Saved ${Object.keys(a).length} artifacts for step ${e}`)}catch(r){h.error(`[saveDebugInfoToFiles] Failed to save debug info for step ${e}:`,r)}return a}async updateStepResult(e,t,i,n,a){if(!this.context.stepTracking)return;let o=this.context.stepTracking.results[e];if(o){if(t&&(o.status=t,o.contextAfter=this.snapshotVariables(),this.context.stepTracking.currentStepId=void 0,this.context.stepTracking.onStepChange&&this.context.stepTracking.onStepChange(void 0)),i!==void 0&&(o.message=i),n&&o.artifacts.push(n),a){let r=a.tokenUsages?.[0]?.model,s=o.artifacts.length,l=this.saveDebugInfoToFiles(e,a,r,s);Object.keys(l).length>0&&o.artifacts.push(l)}o.duration=Date.now()-o.startTime,this.context.stepTracking.onStepComplete&&this.context.stepTracking.onStepComplete(e,o)}}async writeExecutionResults(e,t){try{if(await K.promises.mkdir(e,{recursive:!0}),this.context.stepTracking?.results&&Object.keys(this.context.stepTracking.results).length>0){let i=q.join(e,"test-results.json");await K.promises.writeFile(i,JSON.stringify(this.context.stepTracking.results,null,2)),h.debug(`Test results written to: ${i}`)}if(t?.tokenUsages&&this.context.tokenUsages&&this.context.tokenUsages.length>0){let i=q.join(e,"token-usages.json");await K.promises.writeFile(i,JSON.stringify(this.context.tokenUsages,null,2)),h.debug(`Token usages written to: ${i}`)}if(this.context.aiActionDetails&&this.context.aiActionDetails.length>0){let i=q.join(e,"ai-actions.json");await K.promises.writeFile(i,JSON.stringify(this.context.aiActionDetails,null,2)),h.debug(`AI action details written to: ${i}`)}}catch(i){throw h.error("Failed to write execution results:",i),i}}}});function Np(){let e=new Date,t=new Intl.DateTimeFormat("en-US",{timeZone:"America/Los_Angeles",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(e),i=t.find(p=>p.type==="year").value,n=t.find(p=>p.type==="month").value,a=t.find(p=>p.type==="day").value,o=t.find(p=>p.type==="hour").value,r=t.find(p=>p.type==="minute").value,s=t.find(p=>p.type==="second").value,l=String(e.getMilliseconds()).padStart(3,"0"),d=`${i}-${n}-${a}T${o}:${r}:${s}.${l}`,c=e.toISOString().slice(0,-1),u=Date.parse(d+"Z"),m=Date.parse(c+"Z"),g=Math.round((m-u)/(1e3*60)),w=String(Math.floor(Math.abs(g)/60)).padStart(2,"0"),v=String(Math.abs(g)%60).padStart(2,"0"),x=g<=0?"+":"-";return`${i}-${n}-${a}T${o}:${r}:${s}.${l}${x}${w}:${v}`}function xo(e){let t=e.variableStore;return t.has("currentTime")||t.set("currentTime",Np()),{model:e.model,computer_use_model:e.computer_use_model,variableStore:t,organizationId:e.organizationId,organizationSettings:e.organizationSettings,executionHistory:e.executionHistory||[],testDataDir:e.testDataDir,downloadDir:e.downloadDir,useNativeGenerator:e.useNativeGenerator,autoDismissModal:e.autoDismissModal,tokenUsages:[],aiActionDetails:[]}}var Yc=y(()=>{"use strict"});var Jc={};et(Jc,{ActionHandler:()=>Dn,ActionHelper:()=>Si,Agent:()=>yo,AgentServices:()=>sa,AgentStepEventTypes:()=>wo,AgentTaskFailedError:()=>la,BrowserManager:()=>Pc,DEFAULT_EVENT_LISTENER_LIMIT:()=>un,DomService:()=>le,EVENT_LISTENER_CANDIDATE_SELECTORS:()=>dn,HistoryTreeProcessor:()=>Ps,INIT_SCRIPT:()=>De,INTERACTION_EVENT_TYPES:()=>ct,INTERACTIVE_ROLES:()=>Wt,LogLevel:()=>Na,LoginType:()=>Mi,MCPToolProvider:()=>bc,OpenAIToolProvider:()=>Ui,SDK_VERSION:()=>Fp,ToolRegistry:()=>lt,TwoFactorAuthType:()=>co,VariableStore:()=>uo,WebAgent:()=>yo,configureSdk:()=>Sr,createAgent:()=>Rp,createAgentContext:()=>xo,createToolRegistry:()=>pc,createToolRegistryWithCapabilities:()=>gc,discoverChromiumCdpUrl:()=>na,ensureToolsRegistered:()=>hc,evaluateStatement:()=>ze,executeStep:()=>je,exportMCPTools:()=>yc,filterInteractionListeners:()=>fs,generateActionStep:()=>gt,getActionEntityLocatorInfo:()=>O,getBrowserCdpUrl:()=>Hn,getCapabilitySummary:()=>fc,getFramePath:()=>$a,getModel:()=>fe,getPageInfo:()=>Zl,getPageWsUrl:()=>ql,getPlatformFromDeviceName:()=>Nc,getProviderOptions:()=>we,getSdkConfig:()=>W,getToolRegistry:()=>mc,injectUserFunction:()=>ka,isInteractionEventType:()=>gs,isInteractiveRole:()=>ps,loadKnowledgeMappings:()=>Cr,loadKnowledges:()=>Ir,loadUserFunctions:()=>Ar,logger:()=>h,newBrowserContext:()=>Jl,parseSSEStream:()=>_r,parseSdkLogLevelFromEnv:()=>Er,pickBestLocator:()=>$t,pickBestLocatorForElement:()=>Vi,pickBestLocators:()=>Rr,registerBrowser:()=>yt,replaceVariables:()=>ea,runTask:()=>Ve,setWindowBounds:()=>Wn,toolRegistry:()=>F,unregisterBrowser:()=>xt});function Rp(e){let t=new uo,i=new Set(e.sensitiveKeys||[]);if(e.variables)for(let[a,o]of Object.entries(e.variables))t.set(a,o,i.has(a));let n=xo({model:e.model,variableStore:t,testDataDir:e.testDataDir,downloadDir:e.downloadDir});return new yo(n)}var Fp,vo=y(()=>{"use strict";kr();Mr();Pr();wc();xc();vc();so();ao();ro();oo();$c();Oc();Rc();Fc();lo();Xc();Vt();cn();sn();Gi();st();qi();Qi();nt();Zi();nn();Rt();Ft();Se();Ct();Nt();_n();Ke();Ht();Bt();dt();Ut();Gt();oa();ee();fo();go();_t();ra();Te();bt();ke();Dt();at();Ot();Ge();bo();io();mn();pn();gn();fn();wn();bn();yn();xn();vn();kn();Sn();Xt();Yt();qt();Zt();Qt();ei();ti();ni();ai();oi();ri();si();li();di();ui();hi();mi();pi();gi();fi();wi();bi();yi();xi();vi();_i();jt();ki();Pn();ii();G();Ue();N();Q();ht();Ln();R();Yc();me();Fp="1.0.0"});var qc,Zc=y(()=>{"use strict";qc=class{version;goal;url;constructor(e,t){this.version=e,this.goal=t.goal,this.url=t.url}generatePrelude(){let e=`// version ${this.version}
4535
4533
  `,t=this.goal,i=this.url;e+=`// Navigate to the specified URL
4536
4534
  const targetUrl = process.env.PLAYWRIGHT_STARTING_URL || '${i}';
4537
4535
  if (targetUrl !== null) {
@@ -4545,4 +4543,7 @@ await page.waitForTimeout(2000);
4545
4543
  `,e+=` // Goal:
4546
4544
  `;let n=t.trim().split(`
4547
4545
  `);for(let a of n)e+=` // ${a}
4548
- `;return e}generatePostlude(){return""}}});function cu(e){if(!e)return"desktop";for(let t of hg)if(t.test(e))return"mobile";return"desktop"}var hg,du=y(()=>{"use strict";hg=[/iphone/i,/ipad/i,/android/i,/pixel/i,/galaxy/i,/mobile/i,/nexus/i,/blackberry/i,/kindle/i]});var uu,mu=y(()=>{"use strict";uu=class hu{data={};sensitive=new Set;get(t){return this.data[t]}set(t,i,n=!1){this.data[t]=i,n?this.sensitive.add(t):this.sensitive.has(t)&&this.sensitive.delete(t)}getAll(){return{...this.data}}isSensitive(t){return this.sensitive.has(t)}getAllSensitiveKeys(){return new Set(this.sensitive)}delete(t){return this.sensitive.delete(t),delete this.data[t]}clear(){this.data={},this.sensitive.clear()}has(t){return t in this.data}get size(){return Object.keys(this.data).length}merge(t){for(let[i,n]of Object.entries(t.getAll()))this.set(i,n,t.isSensitive(i))}toJSON(){return{data:{...this.data},sensitiveKeys:Array.from(this.sensitive)}}static fromJSON(t){let i=new hu;if(t.data){let n=new Set(t.sensitiveKeys||[]);for(let[a,o]of Object.entries(t.data))i.set(a,o,n.has(a))}return i}}});function pu(e,t=mg()){return{copilot:e?.models?.copilot||t.COPILOT_MODEL||xa,webagent:e?.models?.webagent||t.WEB_AGENT_MODEL||dr,computer_use:e?.models?.computer_use||t.COMPUTER_USE_MODEL||ur}}function gu(e){if(e){if(e.WEB_AGENT_MODEL)return e.WEB_AGENT_MODEL;if(e.GOOGLE_API_KEY)return ba;if(e.ANTHROPIC_API_KEY)return sr;if(e.OPENAI_API_KEY)return lr;if(e.SHIPLIGHT_API_TOKEN)return xa}}function fu(e){if(e){if(e.COMPUTER_USE_MODEL)return e.COMPUTER_USE_MODEL;if(e.GOOGLE_API_KEY)return ya;if(e.OPENAI_API_KEY)return cr}}var sr,ba,lr,ya,cr,xa,dr,ur,mg,wu=y(()=>{"use strict";sr="claude-haiku-4-5",ba="gemini-3.1-flash-lite-preview",lr="gpt-5.4-mini",ya="gemini-3-flash-preview",cr="gpt-5.4",xa="claude-sonnet-4-6",dr=ba,ur=ya,mg=()=>typeof process<"u"?process.env:{}});var hr,bu=y(()=>{"use strict";hr=(e=>(e.INITIALIZING="initializing",e.READY="ready",e.PROCESSING="processing",e.STOPPING="stopping",e.WAITING_USER="waiting_user",e.COMPLETED="completed",e.FAILED="failed",e))(hr||{})});function yu(e){let t=e.trim();if(!t||t.startsWith("List of devices"))return null;let i=t.split(/\s+/);if(i.length<2)return null;let n=i[0],a=i[1],o="usb";return n.startsWith("emulator-")?o="emulator":n.includes(":")&&(o="wifi"),{id:n,state:a,connectionType:o}}function xu(e){return e.startsWith(ue)?e:`${ue}${e}`}function vu(e){return e.model?`${e.model} (${e.id})`:e.connectionType==="emulator"?`Android Emulator (${e.id})`:e.id}var _u=y(()=>{"use strict";ga()});var mr={};et(mr,{ADDRESS_BAR_HEIGHT:()=>fa,ANDROID_DEVICE_PREFIX:()=>ue,ActionEntitySchema:()=>Eo,ActionSchema:()=>Ao,AgentStatus:()=>hr,BaseStatementSchema:()=>Je,BrowserType:()=>ir,ConditionSchema:()=>ca,ConditionType:()=>jo,ConditionTypeSchema:()=>ko,DEFAULT_ANTHROPIC_MODEL:()=>sr,DEFAULT_COMPUTER_USE_MODEL:()=>ur,DEFAULT_COPILOT_MODEL:()=>xa,DEFAULT_DEVICE_NAME:()=>Ze,DEFAULT_GEMINI_COMPUTER_USE_MODEL:()=>ya,DEFAULT_GOOGLE_MODEL:()=>ba,DEFAULT_OPENAI_COMPUTER_USE_MODEL:()=>cr,DEFAULT_OPENAI_MODEL:()=>lr,DEFAULT_WEBAGENT_MODEL:()=>dr,DEFAULT_WHILE_LOOP_TIMEOUT_MS:()=>Od,DEVICE_CATEGORIES:()=>ar,DeviceType:()=>nr,DraftSchema:()=>To,IOS_DEVICE_PREFIX:()=>he,LoginType:()=>or,MIN_WINDOW_HEIGHT:()=>tr,MIN_WINDOW_WIDTH:()=>er,NON_INTENT_ACTIONS:()=>Ro,NodeJSCodeCommon:()=>su,PLAYWRIGHT_DEVICES:()=>Ri,RECORD_VIDEO_HEIGHT:()=>Qo,RECORD_VIDEO_WIDTH:()=>Zo,StatementSchema:()=>te,StatementType:()=>Ko,StatementTypeSchema:()=>So,TestFlowSchema:()=>da,TestGroupEntrySchema:()=>Mo,TestGroupSchema:()=>Li,TwoFactorAuthType:()=>rr,UI_DEVICE_CATEGORIES:()=>qd,UI_DEVICE_CATEGORIES_ELECTRON:()=>Zd,USER_AGENT:()=>Vo,VIEWPORT_HEIGHT:()=>qo,VIEWPORT_WIDTH:()=>Jo,VariableStore:()=>uu,WINDOW_HEIGHT:()=>Yo,WINDOW_WIDTH:()=>Xo,actionEntityToYaml:()=>nd,actionStepsMapToTestFlowSections:()=>wd,allowPureVisionAction:()=>gd,applyPatchToYaml:()=>Oo,applyPatchToYamlString:()=>cd,collectActionSteps:()=>He,convertPlaywrightActionToEntity:()=>Ld,countIntentStatements:()=>Fo,createAndroidDeviceName:()=>Ud,createEmptyStore:()=>kd,createIOSDeviceName:()=>Gd,createRunnerStoreEntry:()=>Sd,extractActionStepsFromTestFlow:()=>fd,extractAndAttachComments:()=>Lo,extractDeviceIdentifier:()=>Bd,extractElementDescription:()=>Bo,extractElementDescriptionFromAriaSnapshot:()=>Uo,extractLocatorFromCode:()=>Go,extractYamlMetadata:()=>sd,findNextAfterContainer:()=>Fe,findNextSibling:()=>Re,findNextStatement:()=>Ne,findPathBetweenStatements:()=>hd,findStatementPathById:()=>ie,generateUid:()=>$d,getAllDeviceNames:()=>Jd,getAllReferenceIds:()=>md,getAllStatementsInOrder:()=>Ni,getAndroidDeviceDisplayName:()=>vu,getBrowserWindowSize:()=>Qd,getCompatiblePlatforms:()=>zo,getDeviceBrowserType:()=>iu,getDeviceByName:()=>Fi,getDeviceChannel:()=>tu,getDeviceOptions:()=>wa,getDevicesByCategory:()=>Mt,getIOSDeviceDisplayName:()=>Vd,getLoginConfigPlatform:()=>cu,getRecordVideoSize:()=>eu,getStatementContainers:()=>Me,getStoreSize:()=>Id,getTestPlatformFromDeviceName:()=>Rd,hasReferenceIds:()=>No,isAndroidDevice:()=>Hd,isAppPackage:()=>Kd,isDynamicAction:()=>pd,isExecutableStatement:()=>ud,isIOSDevice:()=>Wd,isNativeDevice:()=>Fd,isPhysicalDeviceUDID:()=>Xd,isPlatformCompatibleWithUrl:()=>jd,isStoreEmpty:()=>Md,isWebUrl:()=>pa,mergeActionEntitiesIntoTestFlow:()=>Cd,mergeStoreUpdates:()=>Ad,parseAdbDeviceLine:()=>yu,parseYamlArrayItems:()=>rd,replaceVariables:()=>ou,resolveActionEntity:()=>Ed,resolveComputerUseModelFromEnv:()=>fu,resolveModels:()=>pu,resolveWebAgentModelFromEnv:()=>gu,suiteToYaml:()=>$o,testFlowToYaml:()=>ed,testFlowToYamlObject:()=>Po,toAndroidDeviceName:()=>xu,toIOSDeviceName:()=>zd,updateStoreEntry:()=>Td,validatePatch:()=>Do,validateTestYaml:()=>vd,yamlObjectsToString:()=>td,yamlToActionEntity:()=>ad,yamlToTestFlow:()=>qe});var pr=y(()=>{"use strict";dd();_d();ha();Io();Pd();Dd();ma();Nd();Yd();nu();au();ru();lu();du();mu();wu();bu();_u();ga()});import*as We from"path";import*as Tu from"fs";import{test as pg,expect as fA,chromium as gg}from"@playwright/test";import*as Z from"fs";import*as tt from"path";import{randomUUID as wr}from"crypto";import{tmpdir as br}from"os";function yr(e){return[`--disable-extensions-except=${e}`,`--load-extension=${e}`,"--no-first-run","--disable-default-apps"]}function xr(e){if(!Z.existsSync(e))return console.warn(`[fixture] extensionStorageState file not found: ${e}`),null;let t;try{t=JSON.parse(Z.readFileSync(e,"utf-8"))}catch(o){throw new Error(`[fixture] Failed to parse extensionStorageState at ${e}: ${o}`)}let i=t;if(!Array.isArray(i.cookies))return null;let n=(Date.now()+365*24*60*60*1e3)/1e3,a=i.cookies.filter(o=>o&&typeof o=="object"&&typeof o.name=="string"&&typeof o.domain=="string");return a.length<i.cookies.length&&console.warn(`[fixture] Skipped ${i.cookies.length-a.length} malformed cookies (missing name or domain)`),a.map(o=>({...o,expires:n}))}function vr(e){if(e){let i=tt.resolve(process.cwd(),e),n=tt.join(br(),`ext-profile-${wr()}`);if(Z.existsSync(i)){try{Z.cpSync(i,n,{recursive:!0})}catch(o){try{Z.rmSync(n,{recursive:!0,force:!0})}catch(r){console.warn("[fixture] Failed to clean up partial profile copy:",n,r)}throw new Error(`[fixture] Failed to copy extension profile from ${i}: ${o}`)}let a=tt.join(n,"SingletonLock");Z.existsSync(a)&&Z.rmSync(a,{force:!0})}else Z.mkdirSync(n,{recursive:!0});return n}let t=tt.join(br(),`ext-profile-${wr()}`);return Z.mkdirSync(t,{recursive:!0}),t}vo();import f1 from"dotenv";var Hp="__shiplightDotenvCache__";function Wp(){return globalThis[Hp]}function _o(){let e=Wp();return e===void 0?process.env:e}async function fg(e){let i=await import(We.resolve(process.cwd(),e.auth)),n=i.login||i.default;if(typeof n!="function")throw new Error(`auth module "${e.auth}" must export a login(args) function that returns a storageState file path`);let a=await n(e.args||{});if(typeof a!="string")throw new Error(`auth module "${e.auth}" login() must return a storageState file path (got ${typeof a})`);return a}function ku(e){return!(!e||e==="off")}function Au(e,t){return!e||e==="off"?!1:e==="on"?!0:e==="retain-on-failure"?t.status!==t.expectedStatus:e==="on-first-retry"?t.retry>0:typeof e=="object"&&e!==null&&"mode"in e?Au(e.mode,t):!0}async function Su(e,t,i){let n=Au(t,i);for(let a of e)try{if(n){let o=await a.path();await i.attach("video",{path:o,contentType:"video/webm"})}else await a.delete()}catch(o){console.warn("[fixture] Failed to process video:",o)}}var va;async function Eu(){return va||(va=await Promise.resolve().then(()=>(vo(),Jc)),va)}var wg=new Set(["get","set","getAll","has","__variableStore"]);function bg(e){let t={__variableStore:e,get(i){return e.get(i)},set(i,n,a=!1){e.set(i,n,a)},getAll(){return e.getAll()}};return new Proxy(t,{get(i,n,a){if(n in i)return Reflect.get(i,n,a);if(typeof n=="string")return i.get(n)},set(i,n,a){return typeof n!="string"||wg.has(n)?Reflect.set(i,n,a):(i.set(n,a),!0)},has(i,n){return n in i?!0:typeof n=="string"?e.has?.(n)??!1:!1}})}var yg=["GOOGLE_API_KEY","ANTHROPIC_API_KEY","OPENAI_API_KEY","OPENAI_BASE_URL","ANTHROPIC_MODELS_USE_VERTEXAI","GOOGLE_GENAI_USE_VERTEXAI","GOOGLE_CLOUD_PROJECT","GOOGLE_CLOUD_LOCATION","MAILGUN_API_KEY","MAILGUN_DOMAIN","SHIPLIGHT_API_TOKEN","SHIPLIGHT_API_URL"];function xg(e=_o()){let t={};for(let i of yg)t[i]=e[i]??"";return t}var xA=pg.extend({account:[void 0,{option:!0}],autoDismissModal:[!1,{option:!0}],extensionDir:[void 0,{option:!0}],userDataDir:[void 0,{option:!0}],extensionStorageState:[void 0,{option:!0}],launchOptions:async({launchOptions:e},t)=>{if(!process.env.SHIPLIGHT_REGISTRY_URL){await t(e);return}let i=e?.args??[],n={...e,args:[...i,"--remote-debugging-port=0"]};await t(n)},browser:async({browser:e},t)=>{let i=null;if(process.env.SHIPLIGHT_REGISTRY_URL)try{let n=await na(process.pid),a=process.env.TEST_WORKER_INDEX??"?";i=await yt({cdpUrl:n,label:`shiplight test w${a}`,pid:process.pid})}catch{}await t(e),await xt(i)},context:async({browser:e,account:t,extensionDir:i,userDataDir:n,extensionStorageState:a},o,r)=>{if(i||n){if(t||r.project.use.auth)throw new Error('Cannot use both "extensionDir"/"userDataDir" and "auth" \u2014 persistent context tests manage their own context. Use extensionStorageState for authentication instead.');let l=r.project.use?.browserName;l&&l!=="chromium"&&console.warn(`[fixture] Persistent context requires Chromium but project is configured for "${l}". Forcing Chromium.`);let d=process.env.PLAYWRIGHT_HEADLESS==="true";i&&d&&console.warn("[fixture] PLAYWRIGHT_HEADLESS=true with extensionDir \u2014 Chrome extensions will not function in headless mode.");let c=vr(n),u=i?yr(We.resolve(process.cwd(),i)):[],m={...r.project.use},{storageState:g,account:w,extensionDir:v,userDataDir:x,extensionStorageState:p,autoDismissModal:f,video:S,..._}=m,k=ku(S)?{dir:r.outputDir}:void 0,E;try{if(E=await gg.launchPersistentContext(c,{..._,headless:d,args:u,viewport:_.viewport??{width:1280,height:720},...k?{recordVideo:k}:{}}),a){let I=We.resolve(process.cwd(),a),C=xr(I);C&&await E.addCookies(C)}await o(E)}finally{let I=E?.pages().map(C=>C.video()).filter(C=>C!==null)??[];if(await E?.close().catch(C=>{console.warn("[fixture] Failed to close persistent context:",C)}),await Su(I,S,r),!n)try{Tu.rmSync(c,{recursive:!0,force:!0})}catch(C){console.warn("[fixture] Failed to clean up temp profile dir:",c,C)}}}else{let l={...r.project.use},d=r.project.use,c=d.auth?{auth:d.auth,args:d.args}:t;if(c){if(!c.auth)throw new Error("Auth is declared but missing the script path. Provide auth in playwright.config.ts: use: { auth: './auth.login.ts' }");l.storageState=await fg(c)}let u=l.video;ku(u)&&!l.recordVideo&&(l.recordVideo={dir:r.outputDir});let m=await e.newContext(l);m.addInitScript(De);try{await o(m)}finally{let g=m.pages().map(w=>w.video()).filter(w=>w!==null);await m.close(),await Su(g,u,r)}}},page:async({context:e},t)=>{let i=await e.newPage();await t(i)},testContext:async({},e,t)=>{let{VariableStore:i}=await Eu(),n=new i,a=t.project.use.variables;if(a)for(let[r,s]of Object.entries(a))typeof s=="string"?n.set(r,s,!1):s&&typeof s=="object"&&"value"in s&&n.set(r,s.value,s.sensitive===!0);let o=bg(n);global.testContext=o,global.$=o,global.ctx=o,await e(o),delete global.testContext,delete global.$,delete global.ctx},$:async({testContext:e},t)=>{await t(e)},ctx:async({testContext:e},t)=>{await t(e)},agent:async({page:e,testContext:t,autoDismissModal:i},n,a)=>{let{WebAgent:o,createAgentContext:r,configureSdk:s,parseSdkLogLevelFromEnv:l}=await Eu(),d=l();s({env:xg(),...d!==void 0&&{logLevel:d}});let{resolveWebAgentModelFromEnv:c,resolveComputerUseModelFromEnv:u}=await Promise.resolve().then(()=>(pr(),mr)),m=_o(),g=c(m);if(!g)throw new Error("No AI model configured. Set WEB_AGENT_MODEL, GOOGLE_API_KEY, ANTHROPIC_API_KEY, OPENAI_API_KEY, or SHIPLIGHT_API_TOKEN in your .env file (or in the runner environment for CI).");let w=u(m),v=t.__variableStore,x=r({model:g,computer_use_model:w,variableStore:v,autoDismissModal:i}),p=We.join(a.outputDir,"artifacts");x.stepTracking={results:{},artifactsDir:p};let f=new o(x),S=e.context();f.agentServices.setupPageTracking(S);for(let _ of S.pages())f.setupDownloadTracking(_),f.setupDialogHandling(_);S.on("page",_=>{f.setupDownloadTracking(_),f.setupDialogHandling(_)}),global.agent=f,await n(f),delete global.agent;try{let _=a.outputDir;await f.writeExecutionResults(_);let k=We.join(_,"test-results.json");await(await import("fs/promises")).stat(k).catch(()=>null)&&await a.attach("shiplight-results",{path:k,contentType:"application/json"})}catch(_){console.error("[Shiplight] Failed to attach step results:",_)}try{let _=f.getNewActionEntities();if(_.size>0&&a.status==="passed"){let{createEmptyStore:k,createRunnerStoreEntry:E}=await Promise.resolve().then(()=>(pr(),mr)),I=await import("fs/promises"),C=k();for(let[U,z]of _)C.entries[U]=E(z,0);let $=We.join(a.outputDir,"new-action-entities.json");await I.writeFile($,JSON.stringify(C,null,2)),await a.attach("shiplight-new-action-entities",{path:$,contentType:"application/json"}),console.log(`[Shiplight] ${_.size} healed action entit${_.size===1?"y":"ies"} saved`)}}catch(_){console.warn("[Shiplight] Failed to persist new action entities:",_)}}});export{yg as SDK_ENV_ALLOWLIST,xg as buildSdkEnv,bg as createTestContext,fA as expect,fg as resolveAuthState,xA as test};
4546
+ `;return e}generatePostlude(){return""}}});function Qc(e){if(!e)return"desktop";for(let t of Bp)if(t.test(e))return"mobile";return"desktop"}var Bp,ed=y(()=>{"use strict";Bp=[/iphone/i,/ipad/i,/android/i,/pixel/i,/galaxy/i,/mobile/i,/nexus/i,/blackberry/i,/kindle/i]});function td(e,t){if(!e||typeof e!="string")return e;let i=t instanceof Map?Object.fromEntries(t):t,n=o=>{let r=o.startsWith("$")?o.slice(1):o,s=i[r]??i[`$${r}`];return s!=null?String(s):void 0},a=e;return a=a.replace(/\{\{\s*\$?([^}]+?)\s*\}\}/g,(o,r)=>{let s=n(r.trim());return s!==void 0?s:o}),a=a.replace(/<secret>\$?([\w-]+)<\/secret>/g,(o,r)=>{let s=n(r);return s!==void 0?s:o}),a=a.replace(/\$\{([^}]+)\}/g,(o,r)=>{let s=n(r.trim());return s!==void 0?s:o}),a=a.replace(/\$([a-zA-Z_]\w*)/g,(o,r)=>{let s=n(r);return s!==void 0?s:o}),a}var id=y(()=>{"use strict"});import{v4 as Up}from"uuid";function So(e){let t=e.match(/\.getByRole\(['"]([^'"]+)['"]/);if(t&&t[1]){let p=e.match(/\.filter\(\{\s*hasText:\s*['"]([^'"]*(?:\\.[^'"]*)*)['"]\s*\}\)/);if(p&&p[1]){let S=p[1].replace(/\\(.)/g,"$1");return`${t[1]} element with text "${S}"`}let f=e.match(/\.filter\(\{\s*hasText:\s*(\/.*?\/[gimuy]*)\s*\}\)/);if(f&&f[1]){let S=f[1].replace(/^\/|\/$/g,""),_=S.length>30?`${S.substring(0,27)}...`:S;return`${t[1]} element with text matching "${_}"`}return`${t[1]} element`}let i=e.match(/\.filter\(\{\s*hasText:\s*['"]([^'"]*(?:\\.[^'"]*)*)['"]\s*\}\)/);if(i&&i[1]){let p=St(e),f=i[1].replace(/\\(.)/g,"$1");return`${p} with text "${f}"`}let n=e.match(/\.filter\(\{\s*hasText:\s*(\/.*?\/[gimuy]*)\s*\}\)/);if(n&&n[1])return`${St(e)} with text matching ${n[1]}`;let a=e.match(/\.filter\(\{\s*has:\s*[^}]+getByText\('((?:[^'\\]|\\.)*)'(?:,\s*\{[^}]*\})?\)/);if(a&&a[1]){let p=St(e),f=a[1].replace(/\\(.)/g,"$1");return`${p} containing "${f}"`}let o=e.match(/\.filter\(\{\s*has:\s*[^}]+getByText\("((?:[^"\\]|\\.)*)"(?:,\s*\{[^}]*\})?\)/);if(o&&o[1]){let p=St(e),f=o[1].replace(/\\(.)/g,"$1");return`${p} containing "${f}"`}let r=e.match(/\.filter\(\{\s*hasNot:\s*[^}]+getByText\('((?:[^'\\]|\\.)*)'(?:,\s*\{[^}]*\})?\)/);if(r&&r[1]){let p=St(e),f=r[1].replace(/\\(.)/g,"$1");return`${p} not containing "${f}"`}let s=e.match(/\.filter\(\{\s*hasNot:\s*[^}]+getByText\("((?:[^"\\]|\\.)*)"(?:,\s*\{[^}]*\})?\)/);if(s&&s[1]){let p=St(e),f=s[1].replace(/\\(.)/g,"$1");return`${p} not containing "${f}"`}let l=e.match(/name:\s*'((?:[^'\\]|\\.)*)'/);if(l&&l[1])return`"${l[1].replace(/\\(.)/g,"$1")}"`;let d=e.match(/name:\s*"((?:[^"\\]|\\.)*)"/);if(d&&d[1])return`"${d[1].replace(/\\(.)/g,"$1")}"`;let c=e.match(/getByText\('((?:[^'\\]|\\.)*)'(?:,\s*\{[^}]*\})?\)/);if(c&&c[1])return`"${c[1].replace(/\\(.)/g,"$1")}"`;let u=e.match(/getByText\("((?:[^"\\]|\\.)*)"(?:,\s*\{[^}]*\})?\)/);if(u&&u[1])return`"${u[1].replace(/\\(.)/g,"$1")}"`;let m=e.match(/getByPlaceholder\('((?:[^'\\]|\\.)*)'(?:,\s*\{[^}]*\})?\)/);if(m&&m[1])return`input with placeholder "${m[1].replace(/\\(.)/g,"$1")}"`;let g=e.match(/getByPlaceholder\("((?:[^"\\]|\\.)*)"(?:,\s*\{[^}]*\})?\)/);if(g&&g[1])return`input with placeholder "${g[1].replace(/\\(.)/g,"$1")}"`;let w=e.match(/getByLabel\('((?:[^'\\]|\\.)*)'(?:,\s*\{[^}]*\})?\)/);if(w&&w[1])return`"${w[1].replace(/\\(.)/g,"$1")}"`;let v=e.match(/getByLabel\("((?:[^"\\]|\\.)*)"(?:,\s*\{[^}]*\})?\)/);if(v&&v[1])return`"${v[1].replace(/\\(.)/g,"$1")}"`;let x=e.match(/getByRole\(['"]([^'"]+)['"]/);return x&&x[1]?`${x[1]} element`:e.length>50?`${e.substring(0,47)}...`:e}function Eo(e,t){if(!e||!t)return null;let i=t.replace(/^ref=/,""),n=e.split(`
4547
+ `);for(let a of n){if(!a.includes(`[ref=${i}]`))continue;let s=a.replace(/\s+\[[^\]]+\](?:\s*\[[^\]]+\])*.*$/,"").trim().replace(/^[-–—]\s*/,"").trim().replace(/\\"/g,'"');return s.length>0?s:null}return null}function To(e,t=""){let i=e.match(/page\d*\.(.+?)\.(click|fill|press|check|uncheck|hover|selectOption|dragTo|dblclick|screenshot|setInputFiles|locator|frameLocator)/);if(i&&i[1])return i[1].trim();let n=e.match(/page\d*\.locator\(([^)]+)\)/);if(n&&n[1])return`locator(${n[1]})`;let a=e.match(/page\d*\.frameLocator\(([^)]+)\)/);return a&&a[1]?`frameLocator(${a[1]})`:t}function St(e){let t=e.match(/^locator\(['"]([^'"]+)['"]\)/);if(t&&t[1]){let a=t[1],o=a.match(/^([a-zA-Z][\w-]*)/);return o?o[1]:a.length>20?`${a.substring(0,17)}...`:a}let i=e.match(/getByRole\(['"]([^'"]+)['"]/);if(i&&i[1])return i[1];let n=e.match(/getByTestId\(['"]([^'"]+)['"]/);return n&&n[1]?`element with testId "${n[1]}"`:"element"}function ko(e){let t=e.match(/\.fill\(['"]([^'"]*)['"]\)/);if(t&&t[1]!==void 0)return t[1];let i=e.match(/\.press\(['"]([^'"]+)['"]\)/);if(i&&i[1])return i[1];let n=e.match(/\.selectOption\(['"]([^'"]+)['"]\)/);return n&&n[1]?n[1]:""}function Gp(e){let t=e.match(/button:\s*['"]([^'"]+)['"]/);return t?t[1]:void 0}function Kp(e){let t=e.match(/modifiers:\s*\[([^\]]+)\]/);if(t&&t[1])return t[1].split(",").map(i=>i.trim().replace(/['"]/g,""))}function ad(e,t){let i=e.name||"unknown",n=To(t,e.selector||""),a=e.ariaSnapshot??e.arIAaSnapshot??"",o=e.ref,r=/getByTestId\s*\(/.test(n),l=(o&&a&&r?Eo(a,o):null)??So(n),d,c,u={};switch(i){case"click":{let m=Gp(t),g=Kp(t);m==="right"?(d="right_click_on_element",c=`Right click on ${l}`):(d="click_element",c=`Click on ${l}`),u={index:0},m&&m!=="left"&&(u.button=m),g&&(u.modifiers=g);break}case"fill":{let m=e.text||e.value||ko(t)||"";d="fill",c=m?`Fill ${l} with '${m}'`:`Fill ${l}`,u={value:m,index:0};break}case"press":{let m=e.key||ko(t)||"";d="press",c=`Press '${m}' on ${l}`,u={keyComb:m,index:0};break}case"selectOption":{let m=e.options?.[0]||ko(t)||"";d="select_dropdown_option",c=`Select '${m}' from ${l}`,u={text:m,index:0};break}case"check":d="click_element",c=`Check ${l}`,u={index:0};break;case"uncheck":d="click_element",c=`Uncheck ${l}`,u={index:0};break;case"setInputFiles":{let m=e.files||[];d="upload_file",c=m.length>0?`Upload file(s) to ${l}`:`Upload file to ${l}`,u={paths:m,index:0};break}case"navigate":case"goto":d="go_to_url",c=`Navigate to ${e.url||"URL"}`,u={url:e.url||"",new_tab:!1};break;case"dblclick":d="double_click_on_element",c=`Double click on ${l}`,u={index:0};break;case"hover":d="hover",c=`Hover over ${l}`,u={index:0};break;case"wheel":case"scroll":d="scroll",c=`Scroll on ${l}`,u={x:e.deltaX||0,y:e.deltaY||0,index:e.selector?0:-1};break;case"dragTo":d="drag_drop",c=`Drag ${l} to target`,u={index:0};break;case"screenshot":d="wait",c="Take screenshot",u={seconds:.5};break;case"wait":d="wait",c=`Wait for ${e.timeout||1e3}ms`,u={seconds:(e.timeout||1e3)/1e3};break;default:d="click_element",c=`${i} on ${l}`,u={index:0};break}return{locator:n,xpath:e.xpath||"",css_selector:e.css_selector||"",unique_selector:e.selector||e.css_selector||"",frame_path:e.frame_path||[],action_data:{action_name:d,args:[],kwargs:u},action_description:c,url:"",feedback:""}}var nd,od=y(()=>{"use strict";nd=()=>Up()});import{z as A}from"zod";var Ao,ca,Mo,Je,Io,Co,Po,te,$o,Li,da,Lo=y(()=>{"use strict";Ao=A.enum(["JS_CODE","AI_MODE"]),ca=A.object({type:Ao,expression:A.string()}),Mo=A.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),Je=A.object({uid:A.string(),type:Mo,comment:A.string().optional()}),Io=A.object({action_data:A.object({action_name:A.string(),kwargs:A.record(A.any()).optional(),args:A.array(A.any()).optional()}),action_description:A.string().optional(),url:A.string().optional(),xpath:A.string().nullable().optional(),locator:A.string().nullable().optional(),css_selector:A.string().nullable().optional(),unique_selector:A.string().nullable().optional(),element_index:A.number().nullable().optional(),frame_path:A.array(A.any()).optional(),artifacts:A.record(A.any()).optional(),feedback:A.string().optional(),original_browser_use_action:A.any().optional()}).passthrough(),Co=Je.extend({type:A.literal("DRAFT"),description:A.string()}),Po=Je.extend({type:A.literal("ACTION"),description:A.string(),action_entity:Io.optional(),locator:A.string().optional(),use_pure_vision:A.boolean().optional()}),te=A.lazy(()=>A.union([Co,Po,Je.extend({type:A.literal("STEP"),description:A.string().optional().default(""),statements:A.array(te),reference_id:A.number().optional(),template_path:A.string().optional(),template_params:A.record(A.string()).optional()}),Je.extend({type:A.literal("IF_ELSE"),description:A.string().optional(),condition:ca,then:A.array(te),else:A.array(te).optional()}),Je.extend({type:A.literal("WHILE_LOOP"),description:A.string().optional(),condition:ca,body:A.array(te),timeout_ms:A.number().optional()})])),$o=A.object({name:A.string(),statements:A.array(te),teardown:A.array(te).optional(),skip:A.union([A.boolean(),A.string()]).optional(),timeout:A.number().optional(),fail:A.union([A.boolean(),A.string()]).optional(),only:A.boolean().optional(),slow:A.boolean().optional()}),Li=A.object({tests:A.array($o).min(1),beforeAll:A.array(te).optional(),afterAll:A.array(te).optional(),beforeEach:A.array(te).optional(),afterEach:A.array(te).optional()}),da=A.object({comment:A.string().optional(),version:A.string().optional(),goal:A.string().optional(),url:A.string().optional(),baseURL:A.string().optional(),final_feedback:A.string().optional(),completed:A.boolean().optional(),success:A.boolean().optional(),statements:A.array(te).optional(),teardown:A.array(te).optional(),last_modified_at:A.string().optional(),testGroup:Li.optional()}).refine(e=>e.testGroup!==void 0?e.goal===void 0&&(e.statements===void 0||e.statements.length===0):e.goal!==void 0,{message:"TestFlow must have either goal/statements (single test) or testGroup (suite), not both"})});import{stringify as Oi,parse as ua,parseAllDocuments as jp,parseDocument as zp,Document as Vp,isMap as Tt,isSeq as de}from"yaml";import{v4 as ce}from"uuid";function Oo(e,t){let i={...t?.test_case_id!==void 0?{test_case_id:t.test_case_id}:{},...t?.name?{name:t.name}:{},goal:e.goal??"",url:e.url,base_url:e.baseURL,...t?.timeout!==void 0?{timeout:t.timeout}:{},...t?.settings&&Object.keys(t.settings).length>0?{settings:t.settings}:{},statements:(e.statements??[]).map(ae)};return e.final_feedback&&(i.final_feedback=e.final_feedback),e.teardown&&e.teardown.length>0&&(i.teardown=e.teardown.map(ae)),i}function cd(e,t){if(e.testGroup)return No(e,t);let i=Oo(e,t),n=new Vp(i);return e.comment&&(n.commentBefore=e.comment),rd(n,e.statements??[]),e.teardown&&rd(n,e.teardown,"teardown"),n.toString(At)}function rd(e,t,i="statements"){let n=e.contents;if(!n||!Tt(n))return;let a=n.get(i,!0);de(a)&&Di(a,t)}function Di(e,t){for(let i=0;i<Math.min(e.items.length,t.length);i++){let n=t[i],a=e.items[i];if(i>0&&(a.spaceBefore=!0),n.comment&&(i===0?e.commentBefore=n.comment:a.commentBefore=n.comment),Tt(a)){let o=a;if(n.type==="STEP"){let r=o.get("statements",!0);de(r)&&Di(r,n.statements)}else if(n.type==="IF_ELSE"){let r=o.get("THEN",!0);de(r)&&Di(r,n.then);let s=o.get("ELSE",!0);de(s)&&n.else&&Di(s,n.else)}else if(n.type==="WHILE_LOOP"){let r=o.get("DO",!0);de(r)&&Di(r,n.body)}}}}function No(e,t){let i=e.testGroup;if(!i)throw new Error("suiteToYaml requires a TestFlow with testGroup");let n={};t?.test_case_id!==void 0&&(n.test_case_id=t.test_case_id),t?.name&&(n.name=t.name),t?.tags&&t.tags.length>0&&(n.tags=t.tags),t?.use&&Object.keys(t.use).length>0&&(n.use=t.use),t?.settings&&Object.keys(t.settings).length>0&&(n.settings=t.settings);let a={};return e.baseURL&&(a.base_url=e.baseURL),i.beforeAll&&i.beforeAll.length>0&&(a.beforeAll=i.beforeAll.map(ae)),i.beforeEach&&i.beforeEach.length>0&&(a.beforeEach=i.beforeEach.map(ae)),i.afterEach&&i.afterEach.length>0&&(a.afterEach=i.afterEach.map(ae)),i.afterAll&&i.afterAll.length>0&&(a.afterAll=i.afterAll.map(ae)),a.tests=i.tests.map(o=>{let r={name:o.name};return o.skip!==void 0&&(r.skip=o.skip),o.timeout!==void 0&&(r.timeout=o.timeout),o.fail!==void 0&&(r.fail=o.fail),o.only!==void 0&&(r.only=o.only),o.slow!==void 0&&(r.slow=o.slow),r.statements=o.statements.map(ae),o.teardown&&o.teardown.length>0&&(r.teardown=o.teardown.map(ae)),r}),n.suite=a,Oi(n,At)}function dd(e){return e.map(t=>Oi(t,At)).join(`---
4548
+ `)}function ae(e){switch(e.type){case"DRAFT":return Xp(e);case"ACTION":return ud(e);case"STEP":return Jp(e);case"IF_ELSE":return qp(e);case"WHILE_LOOP":return Zp(e)}}function Xp(e){return{intent:e.description}}function ud(e){let t=e.action_entity?.action_data?.action_name??e.action_entity?.action?.action_name,i=e.action_entity?.action_data?.kwargs??e.action_entity?.action?.kwargs;if(t==="verify"){let s=i?.statement;if(typeof s=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath){let l=i?.code;return typeof l=="string"?{VERIFY:s,js:l}:{VERIFY:s}}}if(t==="go_to_url"){let s=i?.url;if(typeof s=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath){let l={URL:s};return i?.new_tab===!0&&(l.new_tab=!0),typeof i?.timeout_seconds=="number"&&(l.timeout_seconds=i.timeout_seconds),l}}if(t==="js_action"){let s=i?.code;if(typeof s=="string"&&e.description)return{intent:e.description,js:s}}if(t==="ai_wait_until"){let s=i?.condition;if(typeof s=="string"){let l={WAIT_UNTIL:s};return typeof i?.timeout_seconds=="number"&&i.timeout_seconds!==60&&(l.timeout_seconds=i.timeout_seconds),l}}if(t==="wait"){let s=i?.seconds,d={WAIT:e.description||`Wait ${s}s`};return typeof s=="number"&&(d.seconds=s),d}if(t==="js_code"){let s=i?.code;if(typeof s=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath)return{CODE:s}}if(!e.action_entity)return{intent:e.description};let n=e.action_entity.action_data??e.action_entity.action;if(!n)return{intent:e.description};let a={intent:e.description,action:n.action_name},o=e.locator??e.action_entity.locator;o&&(a.locator=o);let r=e.action_entity.xpath;if(r&&(a.xpath=r),e.use_pure_vision&&(a.use_pure_vision=!0),n.kwargs&&Object.keys(n.kwargs).length>0)for(let[s,l]of Object.entries(n.kwargs))a[s]=l;return n.args&&n.args.length>0&&(a.args=n.args),a}function hd(e,t,i){let n={uid:"",type:"ACTION",description:t||e.action_description||"",action_entity:e,locator:i},a=ud(n);if(typeof a=="object"&&a!==null){let o={...a};return delete o.intent,delete o.VERIFY,delete o.WAIT_UNTIL,delete o.WAIT,delete o.statement,Object.keys(o).length>0?Oi(o,At).trim():""}return Oi(a,At).trim()}function md(e){let t=ua(e);if(!t||typeof t!="object")throw new Error("Invalid YAML: expected an object");if("VERIFY"in t){let c=String(t.VERIFY),u=typeof t.js=="string"?t.js:void 0;return{description:c,actionEntity:{action_description:c,action_data:{action_name:"verify",kwargs:{statement:c,...u?{code:u}:{}}}}}}if("URL"in t){let c=String(t.URL),u={url:c};return t.new_tab===!0&&(u.new_tab=!0),typeof t.timeout_seconds=="number"&&(u.timeout_seconds=t.timeout_seconds),{description:`Navigate to ${c}`,actionEntity:{action_description:`Navigate to ${c}`,action_data:{action_name:"go_to_url",kwargs:u}}}}if("CODE"in t){let c=String(t.CODE);return{description:c,actionEntity:{action_description:c,action_data:{action_name:"js_code",kwargs:{code:c}}}}}if("WAIT_UNTIL"in t){let c=String(t.WAIT_UNTIL),u={condition:c};return typeof t.timeout_seconds=="number"&&(u.timeout_seconds=t.timeout_seconds),{description:`Wait until ${c}`,actionEntity:{action_description:`Wait until ${c}`,action_data:{action_name:"ai_wait_until",kwargs:u}}}}if("WAIT"in t){let c=String(t.WAIT),u={};return typeof t.seconds=="number"&&(u.seconds=t.seconds),{description:c,actionEntity:{action_description:c,action_data:{action_name:"wait",kwargs:u}}}}let i=typeof t.intent=="string"?t.intent:void 0,n=typeof t.action=="string"?t.action:void 0,a=typeof t.locator=="string"?t.locator:void 0,o=typeof t.xpath=="string"?t.xpath:void 0,r=Array.isArray(t.frame_path)?t.frame_path:void 0,s=Array.isArray(t.args)?t.args:void 0,l={};for(let[c,u]of Object.entries(t))Yp.has(c)||(l[c]=u);return!n&&t.js?{description:i,actionEntity:{action_description:i||"",action_data:{action_name:"js_action",kwargs:{code:t.js}}}}:n?{actionEntity:{action_description:i||"",action_data:{action_name:n,kwargs:l,...s&&s.length>0?{args:s}:{}},...a?{locator:a}:{},...o?{xpath:o}:{},...r?{frame_path:r}:{}},description:i,locator:a}:{description:i,actionEntity:{action_description:i||""}}}function Jp(e){if(e.template_path){let i={template:e.template_path};return e.template_params&&Object.keys(e.template_params).length>0&&(i.params=e.template_params),i}let t={STEP:e.description,statements:e.statements.map(ae)};return e.reference_id!==void 0&&(t.reference_id=e.reference_id),t}function qp(e){let t={IF:pd(e.condition),THEN:e.then.map(ae)};return e.else&&e.else.length>0&&(t.ELSE=e.else.map(ae)),t}function Zp(e){let t={WHILE:pd(e.condition),DO:e.body.map(ae)};return e.timeout_ms!==void 0&&(t.timeout_ms=e.timeout_ms),t}function pd(e){return e.type==="JS_CODE"?`js:${e.expression}`:e.expression}function gd(e){let t=jp(e),i;if(t.length>1||t.length===1&&!Array.isArray(t[0]?.toJSON()))i=t.map((n,a)=>n.errors.length>0?{__parseError:`Document ${a+1}: ${n.errors[0].message}`}:n.toJSON());else{let n;try{n=ua(e)}catch(a){throw new Error(`Invalid YAML: ${a instanceof Error?a.message:String(a)}`)}if(!Array.isArray(n))throw new Error("Expected a YAML array or multi-document YAML (separated by ---)");i=n}return i.map((n,a)=>{try{if(n&&typeof n=="object"&&"__parseError"in n)return{error:n.__parseError};if(!n||typeof n!="object")return{error:`Item ${a+1}: expected an object`};let o=n,r=typeof o.name=="string"&&o.name.trim()||void 0,s=typeof o.goal=="string"?o.goal.trim():"";if(!s)return{error:`Item ${a+1}: missing "goal" field`};if(Array.isArray(o.statements))try{let l=Oi(o,At),d=qe(l);return{name:r,goal:d.goal??s,testFlow:d}}catch{}return{name:r,goal:s}}catch(o){return{error:`Item ${a+1}: ${o instanceof Error?o.message:String(o)}`}}})}function fd(e){try{let t=ua(e);if(!t||typeof t!="object")return{};let i={};return typeof t.test_case_id=="number"&&Number.isFinite(t.test_case_id)&&(i.test_case_id=t.test_case_id),typeof t.template_id=="number"&&Number.isFinite(t.template_id)&&(i.template_id=t.template_id),typeof t.name=="string"&&t.name.trim()&&(i.name=t.name.trim()),typeof t.timeout=="number"&&Number.isFinite(t.timeout)&&(i.timeout=t.timeout),t.settings&&typeof t.settings=="object"&&!Array.isArray(t.settings)&&(i.settings=t.settings),i}catch{return{}}}function Do(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Do);let t=e,i=Object.keys(t);if(i.length===1){let a=i[0];if(a.startsWith("{ ")&&a.endsWith(" }")&&t[a]===null)return`{{${a.slice(2,-2)}}}`}let n={};for(let[a,o]of Object.entries(t))n[a]=Do(o);return n}function qe(e){if(e.length>sd)throw new Error(`YAML input too large (${e.length} bytes, max ${sd})`);let t=Do(ua(e));if(!t||typeof t!="object")throw new Error("Invalid YAML: expected an object at root level");if(t.suite)return Qp(t);let i={version:"1.3.0",goal:t.goal,url:t.url,baseURL:t.base_url,statements:oe(t.statements??[])};t.final_feedback&&(i.final_feedback=t.final_feedback),t.teardown&&Array.isArray(t.teardown)&&(i.teardown=oe(t.teardown));let n=da.safeParse(i);if(!n.success)throw new Error(`Invalid TestFlow after YAML conversion: ${JSON.stringify(n.error.errors)}`);let a=n.data;return Ro(e,a),a}function Qp(e){let t=e.suite;if(!t||typeof t!="object")throw new Error("Invalid suite: expected an object");let i=t.tests;if(!Array.isArray(i)||i.length===0)throw new Error('Suite must have a non-empty "tests" array');let a={tests:i.map(s=>{if(!s.name)throw new Error('Each test in a suite must have a "name" field');if(!Array.isArray(s.statements)||s.statements.length===0)throw new Error(`Suite test "${s.name}" must have a non-empty "statements" array`);let l={name:s.name,statements:oe(s.statements)};return Array.isArray(s.teardown)&&s.teardown.length>0&&(l.teardown=oe(s.teardown)),s.skip!==void 0&&(l.skip=s.skip),typeof s.timeout=="number"&&(l.timeout=s.timeout),s.fail!==void 0&&(l.fail=s.fail),s.only===!0&&(l.only=!0),s.slow===!0&&(l.slow=!0),l})};Array.isArray(t.beforeAll)&&t.beforeAll.length>0&&(a.beforeAll=oe(t.beforeAll)),Array.isArray(t.afterAll)&&t.afterAll.length>0&&(a.afterAll=oe(t.afterAll)),Array.isArray(t.beforeEach)&&t.beforeEach.length>0&&(a.beforeEach=oe(t.beforeEach)),Array.isArray(t.afterEach)&&t.afterEach.length>0&&(a.afterEach=oe(t.afterEach));let o=Li.safeParse(a);if(!o.success)throw new Error(`Invalid TestGroup: ${JSON.stringify(o.error.errors)}`);return{version:"1.3.0",baseURL:t.base_url||void 0,testGroup:o.data}}function oe(e){if(!Array.isArray(e))throw new Error("Expected an array of statements");return e.map(eg)}function eg(e){if(typeof e=="string")throw new Error(`Plain string statements are not supported. Use an object with a "desc" key instead. Example: { "desc": "${e}" }`);if(typeof e!="object"||e===null)throw new Error(`Invalid statement: expected object, got ${typeof e}`);let t=e;if("IF"in t)return tg(t);if("WHILE"in t)return ig(t);if("STEP"in t)return ng(t);if("VERIFY"in t){let i=t.VERIFY,n={statement:typeof i=="string"?i:String(i)};return typeof t.js=="string"&&(n.code=t.js),{uid:ce(),type:"ACTION",description:String(i),action_entity:{action_description:String(i),action_data:{action_name:"verify",kwargs:n}}}}if("URL"in t){let i=t.URL,n=t.new_tab===!0?!0:void 0,a=typeof t.timeout_seconds=="number"?t.timeout_seconds:void 0,o={url:typeof i=="string"?i:String(i)};return n&&(o.new_tab=!0),a!==void 0&&(o.timeout_seconds=a),{uid:ce(),type:"ACTION",description:`Navigate to ${i}`,action_entity:{action_description:`Navigate to ${i}`,action_data:{action_name:"go_to_url",kwargs:o}}}}if("WAIT_UNTIL"in t){let i=t.WAIT_UNTIL,n=typeof t.timeout_seconds=="number"?t.timeout_seconds:60;return{uid:ce(),type:"ACTION",description:`Wait until: ${i}`,action_entity:{action_description:`Wait until: ${i}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:typeof i=="string"?i:String(i),timeout_seconds:n}}}}}if("WAIT"in t){let i=t.WAIT,n=typeof t.seconds=="number"?t.seconds:3;return{uid:ce(),type:"ACTION",description:typeof i=="string"?i:`Wait ${n}s`,action_entity:{action_description:typeof i=="string"?i:`Wait ${n}s`,action_data:{action_name:"wait",kwargs:{seconds:n}}}}}if("CODE"in t){let i=t.CODE;if(i==null)throw new Error('CODE statement has no code. Use "CODE: |" followed by indented code on the next line.');return{uid:ce(),type:"ACTION",description:"Code block",action_entity:{action_description:"Code block",action_data:{action_name:"js_code",kwargs:{code:typeof i=="string"?i:String(i)}}}}}if("js"in t&&("intent"in t||"desc"in t)&&!("VERIFY"in t)&&t.action!=="verify"){let i=t.js,n=typeof t.intent=="string"?t.intent:typeof t.desc=="string"?t.desc:"";return{uid:ce(),type:"ACTION",description:n,action_entity:{action_description:n,action_data:{action_name:"js_action",kwargs:{code:typeof i=="string"?i:String(i)}}}}}if("call"in t&&typeof t.call=="string"){let{call:i,...n}=t;return ld({...n,action:"function",functionName:i})}if("action"in t)return ld(t);if("intent"in t&&typeof t.intent=="string"||"desc"in t&&typeof t.desc=="string")return{uid:ce(),type:"DRAFT",description:typeof t.intent=="string"?t.intent:t.desc};throw new Error(`Cannot infer statement type from object: ${JSON.stringify(t)}`)}function wd(e){if(typeof e!="string")throw new Error(`Condition must be a string, got ${typeof e}`);return e.startsWith("js:")?{type:"JS_CODE",expression:e.slice(3)}:{type:"AI_MODE",expression:e}}function tg(e){let t=wd(e.IF),i=e.THEN;if(!Array.isArray(i))throw new Error("IF_ELSE requires a THEN array");let n={uid:ce(),type:"IF_ELSE",condition:t,then:oe(i)};return"ELSE"in e&&Array.isArray(e.ELSE)&&(n.else=oe(e.ELSE)),n}function ig(e){let t=wd(e.WHILE),i=e.DO;if(!Array.isArray(i))throw new Error("WHILE_LOOP requires a DO array");let n={uid:ce(),type:"WHILE_LOOP",condition:t,body:oe(i)};return typeof e.timeout_ms=="number"&&(n.timeout_ms=e.timeout_ms),n}function ng(e){let t=typeof e.STEP=="string"?e.STEP:"";if(!Array.isArray(e.statements))throw new Error("STEP requires a statements array");let i={uid:ce(),type:"STEP",description:t,statements:oe(e.statements)};if(typeof e.reference_id=="number"&&(i.reference_id=e.reference_id),typeof e.template_path=="string"&&(i.template_path=e.template_path),e.template_params&&typeof e.template_params=="object"&&!Array.isArray(e.template_params)){let n=e.template_params,a={};for(let[o,r]of Object.entries(n))a[o]=String(r);i.template_params=a}return i}function ld(e){let t=typeof e.action=="string"?e.action:String(e.action),i=typeof e.intent=="string"?e.intent:typeof e.desc=="string"?e.desc:"",n=typeof e.locator=="string"?e.locator:void 0,a=typeof e.xpath=="string"?e.xpath:void 0,o=typeof e.use_pure_vision=="boolean"?e.use_pure_vision:void 0,r={};for(let[d,c]of Object.entries(e))ag.has(d)||(r[d]=c);t==="verify"&&typeof r.js=="string"&&(r.code=r.js,delete r.js);let s={action_description:i,action_data:{action_name:t,kwargs:Object.keys(r).length>0?r:{}}};n&&(s.locator=n),a&&(s.xpath=a);let l={uid:ce(),type:"ACTION",description:i,action_entity:s};return o&&(l.use_pure_vision=!0),l}function Ro(e,t){let i;try{i=zp(e)}catch{return}let n=i.contents;if(!n||!Tt(n))return;if(i.commentBefore)t.comment=i.commentBefore;else{let l=n.items?.[0];l?.key&&l.key.commentBefore&&(t.comment=l.key.commentBefore)}let a=n,o=a.get("statements",!0);de(o)&&t.statements&&Et(o,t.statements);let r=a.get("teardown",!0);de(r)&&t.teardown&&Et(r,t.teardown)}function Et(e,t){e.commentBefore&&t.length>0&&(t[0].comment=e.commentBefore);for(let i=0;i<Math.min(e.items.length,t.length);i++){let n=e.items[i];n.commentBefore&&!(i===0&&e.commentBefore)&&(t[i].comment=n.commentBefore);let a=t[i];if(a.type==="STEP"&&Tt(n)){let o=n.get("statements",!0);de(o)&&Et(o,a.statements)}else if(a.type==="IF_ELSE"&&Tt(n)){let o=n.get("THEN",!0);de(o)&&Et(o,a.then);let r=n.get("ELSE",!0);de(r)&&a.else&&Et(r,a.else)}else if(a.type==="WHILE_LOOP"&&Tt(n)){let o=n.get("DO",!0);de(o)&&Et(o,a.body)}}}var At,Yp,sd,ag,ha=y(()=>{"use strict";Lo();At={lineWidth:120,defaultKeyType:"PLAIN",defaultStringType:"PLAIN"};Yp=new Set(["intent","action","locator","xpath","frame_path","args"]);sd=1024*1024;ag=new Set(["action","intent","desc","locator","xpath","use_pure_vision"])});import{parse as og,stringify as rg}from"yaml";function Fo(e,t){let i=[];t.version!=="1.0"&&i.push(`Unsupported patch version: ${t.version}`),(!Array.isArray(t.operations)||t.operations.length===0)&&i.push("Patch must have at least one operation");for(let n=0;n<t.operations.length;n++){let a=t.operations[n],o=`operations[${n}]`;switch(a.reason||i.push(`${o}: missing reason`),a.op){case"remove":{(typeof a.index!="number"||a.index<0||a.index>=e.length)&&i.push(`${o}: index ${a.index} out of bounds (0..${e.length-1})`);break}case"modify":{(typeof a.index!="number"||a.index<0||a.index>=e.length)&&i.push(`${o}: index ${a.index} out of bounds (0..${e.length-1})`),(a.statement===void 0||a.statement===null)&&i.push(`${o}: missing statement`);break}case"insert":{(typeof a.index!="number"||a.index<0||a.index>=e.length)&&i.push(`${o}: index ${a.index} out of bounds (0..${e.length-1})`),a.position!=="before"&&a.position!=="after"&&i.push(`${o}: position must be 'before' or 'after'`),(a.statement===void 0||a.statement===null)&&i.push(`${o}: missing statement`);break}default:i.push(`${o}: unknown operation type "${a.op}"`)}}return{valid:i.length===0,errors:i}}function Ho(e,t){let i=Fo(e,t);if(!i.valid)throw new Error(`Invalid patch: ${i.errors.join("; ")}`);let n=[...e],a=t.operations.map((s,l)=>({...s,originalOrder:l})),o={remove:0,modify:1,insert:2},r=[...a].sort((s,l)=>s.index!==l.index?l.index-s.index:o[s.op]-o[l.op]);for(let s of r)switch(s.op){case"remove":n.splice(s.index,1);break;case"modify":n[s.index]=s.statement;break;case"insert":s.position==="before"?n.splice(s.index,0,s.statement):n.splice(s.index+1,0,s.statement);break}return n}function bd(e,t){let i=og(e);if(!i||typeof i!="object")throw new Error("Invalid YAML: expected an object at root level");let n=i.statements;if(!Array.isArray(n))throw new Error('YAML must have a "statements" array');let a=Ho(n,t);i.statements=a;let o=rg(i,{lineWidth:120,defaultKeyType:"PLAIN",defaultStringType:"PLAIN"});return qe(o),{modifiedYaml:o,modifiedStatements:a}}var yd=y(()=>{"use strict";ha()});function Wo(e){for(let t of e){if(t.type==="STEP"){let n=t;if(n.reference_id||n.template_path)return!0}let i=Me(t);for(let n of i)if(Wo(n.statements))return!0}return!1}function _d(e){let t=new Set;function i(n){for(let a of n){if(a.type==="STEP"){let r=a;r.reference_id&&t.add(r.reference_id)}let o=Me(a);for(let r of o)i(r.statements)}}return i(e),Array.from(t)}function Ed(e){if(!e?.statements||!Array.isArray(e.statements))return{};let t={};return He(e.statements,"main",t),e.teardown&&Array.isArray(e.teardown)&&He(e.teardown,"teardown",t),t}function Oe(e,t,i){let n=e+".",a=t.filter(([c])=>c===e||c.startsWith(n));if(a.length===0)return[];let o=[],r=new Set;for(let[c]of a){let u=c===e?"":c.slice(n.length);if(!u)continue;let m=u.split(".")[0];r.has(m)||r.add(m)}let s=Array.from(r);s.sort((c,u)=>{let m=/^\d+$/.test(c)?parseInt(c,10):-1,g=/^\d+$/.test(u)?parseInt(u,10):-1;return m>=0&&g>=0?m-g:c==="then"&&u==="else"?-1:c==="else"&&u==="then"||c==="body"?1:u==="body"?-1:c.localeCompare(u)});function l(c){return i[c]}function d(c){let u=c.match(/^(IF|WHILE)\s+([\s\S]+)$/);return{type:"AI_MODE",expression:(u?u[2].trim():c)||"true"}}for(let c of s){let u=e?`${e}.${c}`:c,m=l(u),g=m?.description??"",w=u;if(c==="then"){let _=`${e}.then`,k=`${e}.else`,E=Oe(_,t,i),I=Oe(k,t,i),C=l(e),$=C?d(C.description):{type:"JS_CODE",expression:"true"};o.push({uid:e,type:"IF_ELSE",condition:$,then:E,...I.length>0?{else:I}:{}});continue}if(c==="else")continue;if(c==="body"){let _=`${e}.body`,k=Oe(_,t,i),E=l(e),I=E?d(E.description):{type:"JS_CODE",expression:"true"};o.push({uid:e,type:"WHILE_LOOP",condition:I,body:k});continue}let v=`${e}.${c}`,x=t.some(([_])=>_.startsWith(v+".then.")||_===v+".then"),p=t.some(([_])=>_.startsWith(v+".else.")||_===v+".else"),f=t.some(([_])=>_.startsWith(v+".body.")||_===v+".body"),S=t.filter(([_])=>{if(!_.startsWith(v+"."))return!1;let E=_.slice(v.length+1).split(".")[0];return/^\d+$/.test(E)&&E!=="then"&&E!=="else"&&E!=="body"});if(x||p){let _=v+".then",k=v+".else",E=Oe(_,t,i),I=Oe(k,t,i),C=m?d(g):{type:"JS_CODE",expression:"true"};o.push({uid:u,type:"IF_ELSE",condition:C,then:E,...I.length>0?{else:I}:{}})}else if(f){let _=v+".body",k=Oe(_,t,i),E=m?d(g):{type:"JS_CODE",expression:"true"};o.push({uid:u,type:"WHILE_LOOP",condition:E,body:k})}else if(S.length>0){let _=Oe(v,t,i);o.push({uid:u,type:"STEP",description:g||"Group",statements:_})}else o.push({uid:u,type:"ACTION",description:g||"Action",action_entity:m?.action_entity})}return o}function Td(e){let t=Object.entries(e),i=n=>{let a=n+".";return t.some(([r])=>r===n||r.startsWith(a))?Oe(n,t,e):[]};return{before:i("before"),main:i("main"),teardown:i("teardown"),after:i("after")}}var Me,ie,Ne,Re,Fe,Ni,xd,vd,sg,lg,kd,Sd,He,ma=y(()=>{"use strict";Me=e=>{let t=[];switch(e.type){case"STEP":e.statements&&t.push({key:"statements",statements:e.statements});break;case"IF_ELSE":e.then&&t.push({key:"then",statements:e.then}),e.else&&t.push({key:"else",statements:e.else});break;case"WHILE_LOOP":e.body&&t.push({key:"body",statements:e.body});break}return t},ie=(e,t,i=void 0,n="root")=>{for(let a=0;a<e.length;a++){let o=e[a],r=o.uid;if(r===t)return{stableId:r,path:[a],statement:o,parent:i,containerKey:n,index:a};let s=Me(o);for(let l of s){let d=ie(l.statements,t,o,l.key);if(d)return{...d,path:[a,l.key,...d.path]}}}return null},Ne=(e,t,i)=>{let n=ie(e,t);if(!n)return null;let{statement:a,parent:o,containerKey:r,index:s}=n,l=null;switch(a.type){case"DRAFT":case"ACTION":l=Re(e,n)||Fe(e,n);break;case"STEP":if(a.statements&&a.statements.length>0)return a.statements[0];l=Re(e,n)||Fe(e,n);break;case"IF_ELSE":if(i===!0&&a.then&&a.then.length>0)return a.then[0];if(i===!1&&a.else&&a.else.length>0)return a.else[0];l=Re(e,n)||Fe(e,n);break;case"WHILE_LOOP":if(i===!0&&a.body&&a.body.length>0)return a.body[0];l=Re(e,n)||Fe(e,n);break;default:l=Re(e,n)||Fe(e,n);break}if(o&&o.type==="WHILE_LOOP"&&r==="body"){if(!l)return o;let d=ie(e,l.uid);if(!d||d.parent!==o)return o}return l},Re=(e,t)=>{if(!t.parent)return e[t.index+1]||null;let n=Me(t.parent).find(a=>a.key===t.containerKey);return n&&t.index+1<n.statements.length?n.statements[t.index+1]:null},Fe=(e,t)=>{if(!t.parent)return null;let i=t.parent.uid,n=ie(e,i);return n?Re(e,n)||Fe(e,n):null},Ni=e=>{let t=[],i=n=>{for(let a of n){t.push(a);let o=Me(a);for(let r of o)i(r.statements)}};return i(e),t},xd=e=>{switch(e.type){case"DRAFT":case"ACTION":return!0;case"STEP":return!0;case"IF_ELSE":case"WHILE_LOOP":return!0;default:return!1}},vd=(e,t,i)=>{if(!ie(e,t))return null;if(i===null){let s=[],l=t;for(;l!==null&&ie(e,l);)if(s.push(l),l=Ne(e,l)?.uid||null,s.length>1e3)return null;return s}if(!ie(e,i))return null;if(t===i)return[];let o=[],r=t;for(;r&&r!==i;){let s=ie(e,r);if(!s)break;if(o.push(r),s.statement.type==="IF_ELSE"){let l=sg(s.statement,i);l?r=Ne(e,r,l==="then")?.uid||null:r=Ne(e,r)?.uid||null}else s.statement.type==="WHILE_LOOP"?lg(s.statement,i)?r=Ne(e,r,!0)?.uid||null:r=Ne(e,r,!1)?.uid||null:r=Ne(e,r)?.uid||null;if(o.length>1e3)return null}return r===i?o:null},sg=(e,t)=>{if(e.type!=="IF_ELSE")return null;let i=e;return i.then&&ie(i.then,t)?"then":i.else&&ie(i.else,t)?"else":null},lg=(e,t)=>{if(e.type!=="WHILE_LOOP")return!1;let i=e;return!!(i.body&&ie(i.body,t))};kd=e=>e.startsWith("ai_")?!0:["js_code","function","assert","verify","wait_for_download_complete","extract_activation_code","extract_email_content"].includes(e),Sd=e=>!["js_code","function","assert","ai_assert","verify","ai_extract","ai_wait_until","upload_file","login","extract_activation_code","extract_email_content","ai_step"].includes(e),He=(e,t,i)=>{e.forEach((n,a)=>{let o=`${t}.${a}`;n.type==="DRAFT"?i[o]={description:n.description||"Draft",action_entity:void 0}:n.type==="ACTION"?i[o]={description:n.description||"Action",action_entity:n.action_entity,locator:n.locator}:n.type==="STEP"&&n.statements?He(n.statements,o,i):n.type==="IF_ELSE"?(i[o]={description:"IF "+(n.condition?.expression||""),action_entity:void 0},n.then&&He(n.then,`${o}.then`,i),n.else&&He(n.else,`${o}.else`,i)):n.type==="WHILE_LOOP"&&(i[o]={description:"WHILE "+(n.condition?.expression||""),action_entity:void 0},n.body&&He(n.body,`${o}.body`,i))})}});function Uo(e){let t=0,i=0;for(let n of e)if(n.type==="DRAFT")i++;else if(n.type==="ACTION"){let a=n.action_entity?.action_data?.action_name??"";Bo.has(a)||t++}return{action:t,draft:i}}function dg(e){try{return new Function(`return async function() { ${e} }`),null}catch(t){return t.message}}function Id(e){try{return new Function(`return async function() { return (${e}) }`),null}catch(t){return t.message}}function ug(e){let t=e.split(/\r?\n/).map(o=>o.trim()).filter(o=>o.length>0&&!o.startsWith("//")),i=t.length,n=t.join(`
4549
+ `).match(/\bawait\b/g),a=n?n.length:0;return i<=Ad&&a<=Md?null:`${i} non-blank line(s), ${a} await(s) \u2014 limits are ${Ad} lines and ${Md} awaits. The js: field is a cache for one natural-language intent, not a place for multi-step logic. Break this into multiple statements \u2014 one VERIFY or intent+js per UI interaction or assertion \u2014 so each step is visible in the debugger and self-healable.`}function Cd(e,t){let i=t?.coverageThreshold??cg,n=[],a=[],o;try{o=qe(e)}catch(m){return{valid:!1,errors:[`Invalid YAML: ${m.message}`],warnings:[],stats:{total:0,action:0,draft:0,coverage:0}}}o.goal||n.push('Missing required field: "goal"'),o.statements?.length||n.push('Missing required field: "statements"');let r=[...Ni(o.statements??[]),...o.teardown?Ni(o.teardown):[]],{action:s,draft:l}=Uo(r),d="Hint: in YAML double-quoted strings, backslashes are escape characters \u2014 use \\\\/ instead of \\/ for regex, or use single quotes.";for(let m of r){let g=m;if(g.reference_id!==void 0){let w=g.description||m.uid;n.push(`Unresolved cloud template reference on statement "${w}" (reference_id: ${g.reference_id}). Local YAML tests cannot use reference_id \u2014 inline the template statements or use the local "template:" key instead.`)}if(m.type==="ACTION"){let w=m,v=w.action_entity?.action_data?.action_name??"";if(v==="js_code"||v==="js_action"||v==="verify"||v==="ai_assert"){let x=w.action_entity?.action_data?.kwargs?.code;if(typeof x=="string"){let p=dg(x);if(p){let f=w.description||v;n.push(`Invalid JS in "${f}": ${p}. ${d}`)}else if(v==="verify"||v==="js_action"){let f=ug(x);if(f){let S=w.description||v;n.push(`JS cache for "${S}" is too complex: ${f}`)}}}}}if(m.type==="IF_ELSE"){let w=m;if(w.condition.type==="JS_CODE"){let v=Id(w.condition.expression);v&&n.push(`Invalid JS in IF condition "${w.condition.expression}": ${v}. ${d}`)}}if(m.type==="WHILE_LOOP"){let w=m;if(w.condition.type==="JS_CODE"){let v=Id(w.condition.expression);v&&n.push(`Invalid JS in WHILE condition "${w.condition.expression}": ${v}. ${d}`)}}}let c=s+l,u=c>0?Math.round(s/c*100):0;return c>0&&u/100<i&&a.push(`Low action coverage: ${s}/${c} statements (${u}%) are enriched with action/js. ${l} draft statement(s) still need enrichment. Use MCP tools (act, get_locators) to convert drafts to actions.`),{valid:n.length===0,errors:n,warnings:a,stats:{total:c,action:s,draft:l,coverage:u}}}var cg,Ad,Md,Bo,Pd=y(()=>{"use strict";ha();ma();cg=.5,Ad=5,Md=3,Bo=new Set(["verify","ai_assert","done","go_to_url","ai_wait_until","wait","js_code"])});function $d(e){return e?e.startsWith(ue)?"android":e.startsWith(he)?"ios":"web":"web"}function Ld(e){return e?e.startsWith(ue)||e.startsWith(he):!1}function Dd(e){return!!e&&e.startsWith(ue)}function Od(e){return!!e&&e.startsWith(he)}function Nd(e){return e.startsWith(ue)?e.slice(ue.length):e.startsWith(he)?e.slice(he.length):e}function Rd(e){return`${ue}${e}`}function Fd(e){return`${he}${e}`}function pa(e){return e?e.startsWith("http://")||e.startsWith("https://"):!1}function Hd(e){return e?!pa(e):!1}function Go(e){return e?pa(e)?["web"]:["android","ios"]:["web","android","ios"]}function Wd(e,t){if(!t)return!0;let i=Go(t);return e==="desktop"||e==="mobile"?i.includes("web"):i.includes(e)}var ue,he,ga=y(()=>{"use strict";ue="android:",he="ios:"});function Bd(e){return e.startsWith(he)?e:`${he}${e}`}function Ud(e){let t=e.iosVersion?` (iOS ${e.iosVersion})`:"";return e.deviceType==="simulator"?`${e.name}${t} - Simulator`:`${e.name}${t}`}function Gd(e){return!!(/^[0-9a-fA-F]{40}$/.test(e)||/^[0-9a-fA-F]{8}-[0-9a-fA-F]{16}$/.test(e))}var Kd=y(()=>{"use strict";ga()});var Ko,fa,jo,zo,Vo,Xo,Yo,Jo,qo,Zo,Ze,Qo,Ri,er,tr,Mt,jd,Fi,zd,Vd,wa,Xd,Yd,Jd,qd,Zd=y(()=>{"use strict";Ko="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36",fa=112,jo=1920,zo=1080,Vo=1920,Xo=1080-fa,Yo=1280,Jo=720,qo=500,Zo=500,Ze="Desktop Chrome",Qo=(e=>(e.Chromium="chromium",e.Firefox="firefox",e.Webkit="webkit",e))(Qo||{}),Ri={"Blackberry PlayBook":{name:"Blackberry PlayBook",userAgent:"Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML like Gecko) Version/26.0 Safari/536.2+",screen:{width:600,height:1024},viewport:{width:600,height:1024},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"BlackBerry Z30":{name:"BlackBerry Z30",userAgent:"Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/26.0 Mobile Safari/537.10+",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note 3":{name:"Galaxy Note 3",userAgent:"Mozilla/5.0 (Linux; U; Android 4.3; en-us; SM-N900T Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note II":{name:"Galaxy Note II",userAgent:"Mozilla/5.0 (Linux; U; Android 4.1; en-us; GT-N7100 Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S III":{name:"Galaxy S III",userAgent:"Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S5":{name:"Galaxy S5",userAgent:"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S8":{name:"Galaxy S8",userAgent:"Mozilla/5.0 (Linux; Android 7.0; SM-G950U Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:740},viewport:{width:360,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S9+":{name:"Galaxy S9+",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; SM-G965U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:320,height:658},viewport:{width:320,height:658},deviceScaleFactor:4.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S24":{name:"Galaxy S24",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-S921U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:780},viewport:{width:360,height:780},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy A55":{name:"Galaxy A55",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-A556B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:480,height:1040},viewport:{width:480,height:1040},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S4":{name:"Galaxy Tab S4",userAgent:"Mozilla/5.0 (Linux; Android 8.1.0; SM-T837A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:712,height:1138},viewport:{width:712,height:1138},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S9":{name:"Galaxy Tab S9",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-X710) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:640,height:1024},viewport:{width:640,height:1024},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"iPad (gen 5)":{name:"iPad (gen 5)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 6)":{name:"iPad (gen 6)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 7)":{name:"iPad (gen 7)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:810,height:1080},viewport:{width:810,height:1080},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 11)":{name:"iPad (gen 11)",userAgent:"Mozilla/5.0 (iPad; CPU OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/604.1",screen:{width:656,height:944},viewport:{width:656,height:944},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Mini":{name:"iPad Mini",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Pro 11":{name:"iPad Pro 11",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:834,height:1194},viewport:{width:834,height:1194},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6":{name:"iPhone 6",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6 Plus":{name:"iPhone 6 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7":{name:"iPhone 7",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7 Plus":{name:"iPhone 7 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8":{name:"iPhone 8",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8 Plus":{name:"iPhone 8 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE":{name:"iPhone SE",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/14E304 Safari/602.1",screen:{width:320,height:568},viewport:{width:320,height:568},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE (3rd gen)":{name:"iPhone SE (3rd gen)",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/602.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone X":{name:"iPhone X",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:812},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone XR":{name:"iPhone XR",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:896},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11":{name:"iPhone 11",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro":{name:"iPhone 11 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:635},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro Max":{name:"iPhone 11 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12":{name:"iPhone 12",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro":{name:"iPhone 12 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro Max":{name:"iPhone 12 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Mini":{name:"iPhone 12 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13":{name:"iPhone 13",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro":{name:"iPhone 13 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro Max":{name:"iPhone 13 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Mini":{name:"iPhone 13 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14":{name:"iPhone 14",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Plus":{name:"iPhone 14 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro":{name:"iPhone 14 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:660},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro Max":{name:"iPhone 14 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15":{name:"iPhone 15",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Plus":{name:"iPhone 15 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro":{name:"iPhone 15 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro Max":{name:"iPhone 15 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Kindle Fire HDX":{name:"Kindle Fire HDX",userAgent:"Mozilla/5.0 (Linux; U; en-us; KFAPWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"LG Optimus L70":{name:"LG Optimus L70",userAgent:"Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; LGMS323 Build/KOT49I.MS32310c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:1.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 550":{name:"Microsoft Lumia 550",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 550) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 950":{name:"Microsoft Lumia 950",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:4,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 10":{name:"Nexus 10",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 10 Build/MOB31T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 4":{name:"Nexus 4",userAgent:"Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5":{name:"Nexus 5",userAgent:"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5X":{name:"Nexus 5X",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR4.170623.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6":{name:"Nexus 6",userAgent:"Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F26U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6P":{name:"Nexus 6P",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 6P Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 7":{name:"Nexus 7",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MOB30X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:600,height:960},viewport:{width:600,height:960},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia Lumia 520":{name:"Nokia Lumia 520",userAgent:"Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 520)",screen:{width:320,height:533},viewport:{width:320,height:533},deviceScaleFactor:1.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia N9":{name:"Nokia N9",userAgent:"Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13",screen:{width:480,height:854},viewport:{width:480,height:854},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Pixel 2":{name:"Pixel 2",userAgent:"Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:731},viewport:{width:411,height:731},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 2 XL":{name:"Pixel 2 XL",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:823},viewport:{width:411,height:823},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 3":{name:"Pixel 3",userAgent:"Mozilla/5.0 (Linux; Android 9; Pixel 3 Build/PQ1A.181105.017.A1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:786},viewport:{width:393,height:786},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4":{name:"Pixel 4",userAgent:"Mozilla/5.0 (Linux; Android 10; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:353,height:745},viewport:{width:353,height:745},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4a (5G)":{name:"Pixel 4a (5G)",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 4a (5G)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:892},viewport:{width:412,height:765},deviceScaleFactor:2.63,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 5":{name:"Pixel 5",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:851},viewport:{width:393,height:727},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 7":{name:"Pixel 7",userAgent:"Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:915},viewport:{width:412,height:839},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Moto G4":{name:"Moto G4",userAgent:"Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Desktop Chrome HiDPI":{name:"Desktop Chrome HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge HiDPI":{name:"Desktop Edge HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Firefox HiDPI":{name:"Desktop Firefox HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"},"Desktop Safari":{name:"Desktop Safari",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Safari/605.1.15",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"webkit"},"Desktop Chrome":{name:"Desktop Chrome",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome Medium Resolution":{name:"Desktop Chrome Medium Resolution",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome (Branded)":{name:"Desktop Chrome (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Chrome Medium Resolution (Branded)":{name:"Desktop Chrome Medium Resolution (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Edge":{name:"Desktop Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge (Branded)":{name:"Desktop Edge (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Edge Medium Resolution (Branded)":{name:"Desktop Edge Medium Resolution (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Firefox":{name:"Desktop Firefox",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"}},er=(e=>(e.Desktop="desktop",e.Mobile="mobile",e))(er||{}),tr={desktop:["Desktop Chrome","Desktop Chrome Medium Resolution","Desktop Chrome (Branded)","Desktop Chrome Medium Resolution (Branded)","Desktop Edge (Branded)","Desktop Edge Medium Resolution (Branded)","Desktop Safari"],mobile:["iPhone 15 Pro Max","iPhone 15 Pro","iPhone 15 Plus","iPhone 15","iPhone 14 Pro Max","iPhone 14 Pro","iPhone 14 Plus","iPhone 14","iPhone 13 Pro Max","iPhone 13 Pro","iPhone 13","iPhone 13 Mini","iPhone 12 Pro Max","iPhone 12 Pro","iPhone 12","iPhone 12 Mini","iPhone 11 Pro Max","iPhone 11 Pro","iPhone 11","iPhone XR","iPhone X","iPhone SE (3rd gen)","iPhone SE","iPhone 8 Plus","iPhone 8","iPhone 7 Plus","iPhone 7","iPhone 6 Plus","iPhone 6","Galaxy S24","Galaxy A55","Galaxy S9+","Galaxy S8","Galaxy S5","Galaxy Note 3","Galaxy Note II","Galaxy S III","Pixel 7","Pixel 5","Pixel 4a (5G)","Pixel 4","Pixel 3","Pixel 2 XL","Pixel 2","Nexus 6P","Nexus 6","Nexus 5X","Nexus 5","Nexus 4","Moto G4","LG Optimus L70","Microsoft Lumia 950","Microsoft Lumia 550","Nokia Lumia 520","Nokia N9","BlackBerry Z30"]},Mt=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),tr[e].map(n=>Ri[n]).filter(n=>n.defaultBrowserType&&i.includes(n.defaultBrowserType))},jd=()=>Object.keys(Ri),Fi=e=>Ri[e],zd={desktop:{label:"Desktop",type:"desktop",devices:Mt("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:Mt("mobile")}},Vd={desktop:{label:"Desktop",type:"desktop",devices:Mt("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:Mt("mobile",!0)}},wa=(e,t=!1)=>{let i={userAgent:Ko,viewport:{width:Vo,height:Xo},isMobile:!1,hasTouch:!1};if(!e||e===Ze)return i;let n=Fi(e);if(!n)return i;let{width:a,height:o}=n.viewport,r=Math.max(qo/a,1),s=Math.max(Zo/o,1),l=Math.max(r,s),d={width:Math.round(a*l),height:Math.round(o*l)};return{userAgent:n.userAgent,viewport:t?d:n.viewport,isMobile:n.isMobile,hasTouch:n.hasTouch}},Xd=e=>{let t={width:jo,height:zo};if(!e||e===Ze)return t;let i=wa(e);return i.viewport?{width:i.viewport.width,height:i.viewport.height+fa}:t},Yd=e=>{let t={width:Yo,height:Jo};if(!e||e===Ze)return t;let i=wa(e);return i.viewport?{width:i.viewport.width,height:i.viewport.height}:t},Jd=e=>!e||e===Ze?void 0:Fi(e)?.channel,qd=e=>!e||e===Ze?"chromium":Fi(e)?.defaultBrowserType??"chromium"});var ir,nr,Qd=y(()=>{"use strict";ir=(e=>(e.PASSWORD="password",e.OAUTH2="oauth2",e.SSO="sso",e.API="api",e))(ir||{}),nr=(e=>(e.SMS="sms",e.EMAIL="email",e.TOTP="totp",e))(nr||{})});function eu(){return{version:"1.0",entries:{}}}function tu(e,t){return{action_entity:e,updated_at:new Date().toISOString(),updated_by:{source:"runner",test_run_id:t}}}function iu(e,t){let i=t?.entries[e.uid],n=i?.action_entity??e.action_entity;return e.locator&&n?{...n,locator:e.locator}:i?i.action_entity:e.action_entity?e.action_entity:null}function nu(e,t,i,n){return e.entries[t]={action_entity:i,updated_at:new Date().toISOString(),updated_by:n},e}function au(e,t){let i=e??{version:"1.0",entries:{}};for(let[n,a]of t)i.entries[n]=a;return i}function ou(e){return e?Object.keys(e.entries).length===0:!0}function ru(e){return e?Object.keys(e.entries).length:0}function su(e,t){if(!t||Object.keys(t.entries).length===0)return e;let i=ar(e.statements??[],t),n=e.teardown?ar(e.teardown,t):void 0;return{...e,statements:i,teardown:n}}function ar(e,t){return e.map(i=>hg(i,t))}function hg(e,t){if(e.type==="ACTION"){let a=e,o=t.entries[a.uid];return o?{...a,action_entity:o.action_entity}:a}let i=Me(e);if(i.length===0)return e;let n={};for(let a of i)n[a.key]=ar(a.statements,t);return{...e,...n}}var lu=y(()=>{"use strict";ma()});var or,rr,cu,du=y(()=>{"use strict";or=(e=>(e.DRAFT="DRAFT",e.STEP="STEP",e.ACTION="ACTION",e.IF_ELSE="IF_ELSE",e.WHILE_LOOP="WHILE_LOOP",e))(or||{}),rr=(e=>(e.JS_CODE="JS_CODE",e.AI_MODE="AI_MODE",e))(rr||{}),cu=18e4});var uu,mu=y(()=>{"use strict";uu=class hu{data={};sensitive=new Set;get(t){return this.data[t]}set(t,i,n=!1){this.data[t]=i,n?this.sensitive.add(t):this.sensitive.has(t)&&this.sensitive.delete(t)}getAll(){return{...this.data}}isSensitive(t){return this.sensitive.has(t)}getAllSensitiveKeys(){return new Set(this.sensitive)}delete(t){return this.sensitive.delete(t),delete this.data[t]}clear(){this.data={},this.sensitive.clear()}has(t){return t in this.data}get size(){return Object.keys(this.data).length}merge(t){for(let[i,n]of Object.entries(t.getAll()))this.set(i,n,t.isSensitive(i))}toJSON(){return{data:{...this.data},sensitiveKeys:Array.from(this.sensitive)}}static fromJSON(t){let i=new hu;if(t.data){let n=new Set(t.sensitiveKeys||[]);for(let[a,o]of Object.entries(t.data))i.set(a,o,n.has(a))}return i}}});function pu(e,t=mg()){return{copilot:e?.models?.copilot||t.COPILOT_MODEL||xa,webagent:e?.models?.webagent||t.WEB_AGENT_MODEL||dr,computer_use:e?.models?.computer_use||t.COMPUTER_USE_MODEL||ur}}function gu(e){if(e){if(e.WEB_AGENT_MODEL)return e.WEB_AGENT_MODEL;if(e.GOOGLE_API_KEY)return ba;if(e.ANTHROPIC_API_KEY)return sr;if(e.OPENAI_API_KEY)return lr;if(e.SHIPLIGHT_API_TOKEN)return xa}}function fu(e){if(e){if(e.COMPUTER_USE_MODEL)return e.COMPUTER_USE_MODEL;if(e.GOOGLE_API_KEY)return ya;if(e.OPENAI_API_KEY)return cr}}var sr,ba,lr,ya,cr,xa,dr,ur,mg,wu=y(()=>{"use strict";sr="claude-haiku-4-5",ba="gemini-3.1-flash-lite-preview",lr="gpt-5.4-mini",ya="gemini-3-flash-preview",cr="gpt-5.4",xa="claude-sonnet-4-6",dr=ba,ur=ya,mg=()=>typeof process<"u"?process.env:{}});var hr,bu=y(()=>{"use strict";hr=(e=>(e.INITIALIZING="initializing",e.READY="ready",e.PROCESSING="processing",e.STOPPING="stopping",e.WAITING_USER="waiting_user",e.COMPLETED="completed",e.FAILED="failed",e))(hr||{})});function yu(e){let t=e.trim();if(!t||t.startsWith("List of devices"))return null;let i=t.split(/\s+/);if(i.length<2)return null;let n=i[0],a=i[1],o="usb";return n.startsWith("emulator-")?o="emulator":n.includes(":")&&(o="wifi"),{id:n,state:a,connectionType:o}}function xu(e){return e.startsWith(ue)?e:`${ue}${e}`}function vu(e){return e.model?`${e.model} (${e.id})`:e.connectionType==="emulator"?`Android Emulator (${e.id})`:e.id}var _u=y(()=>{"use strict";ga()});var mr={};et(mr,{ADDRESS_BAR_HEIGHT:()=>fa,ANDROID_DEVICE_PREFIX:()=>ue,ActionEntitySchema:()=>Io,ActionSchema:()=>Po,AgentStatus:()=>hr,BaseStatementSchema:()=>Je,BrowserType:()=>Qo,ConditionSchema:()=>ca,ConditionType:()=>rr,ConditionTypeSchema:()=>Ao,DEFAULT_ANTHROPIC_MODEL:()=>sr,DEFAULT_COMPUTER_USE_MODEL:()=>ur,DEFAULT_COPILOT_MODEL:()=>xa,DEFAULT_DEVICE_NAME:()=>Ze,DEFAULT_GEMINI_COMPUTER_USE_MODEL:()=>ya,DEFAULT_GOOGLE_MODEL:()=>ba,DEFAULT_OPENAI_COMPUTER_USE_MODEL:()=>cr,DEFAULT_OPENAI_MODEL:()=>lr,DEFAULT_WEBAGENT_MODEL:()=>dr,DEFAULT_WHILE_LOOP_TIMEOUT_MS:()=>cu,DEVICE_CATEGORIES:()=>tr,DeviceType:()=>er,DraftSchema:()=>Co,IOS_DEVICE_PREFIX:()=>he,LoginType:()=>ir,MIN_WINDOW_HEIGHT:()=>Zo,MIN_WINDOW_WIDTH:()=>qo,NON_INTENT_ACTIONS:()=>Bo,NodeJSCodeCommon:()=>qc,PLAYWRIGHT_DEVICES:()=>Ri,RECORD_VIDEO_HEIGHT:()=>Jo,RECORD_VIDEO_WIDTH:()=>Yo,StatementSchema:()=>te,StatementType:()=>or,StatementTypeSchema:()=>Mo,TestFlowSchema:()=>da,TestGroupEntrySchema:()=>$o,TestGroupSchema:()=>Li,TwoFactorAuthType:()=>nr,UI_DEVICE_CATEGORIES:()=>zd,UI_DEVICE_CATEGORIES_ELECTRON:()=>Vd,USER_AGENT:()=>Ko,VIEWPORT_HEIGHT:()=>Xo,VIEWPORT_WIDTH:()=>Vo,VariableStore:()=>uu,WINDOW_HEIGHT:()=>zo,WINDOW_WIDTH:()=>jo,actionEntityToYaml:()=>hd,actionStepsMapToTestFlowSections:()=>Td,allowPureVisionAction:()=>Sd,applyPatchToYaml:()=>Ho,applyPatchToYamlString:()=>bd,collectActionSteps:()=>He,convertPlaywrightActionToEntity:()=>ad,countIntentStatements:()=>Uo,createAndroidDeviceName:()=>Rd,createEmptyStore:()=>eu,createIOSDeviceName:()=>Fd,createRunnerStoreEntry:()=>tu,extractActionStepsFromTestFlow:()=>Ed,extractAndAttachComments:()=>Ro,extractDeviceIdentifier:()=>Nd,extractElementDescription:()=>So,extractElementDescriptionFromAriaSnapshot:()=>Eo,extractLocatorFromCode:()=>To,extractYamlMetadata:()=>fd,findNextAfterContainer:()=>Fe,findNextSibling:()=>Re,findNextStatement:()=>Ne,findPathBetweenStatements:()=>vd,findStatementPathById:()=>ie,generateUid:()=>nd,getAllDeviceNames:()=>jd,getAllReferenceIds:()=>_d,getAllStatementsInOrder:()=>Ni,getAndroidDeviceDisplayName:()=>vu,getBrowserWindowSize:()=>Xd,getCompatiblePlatforms:()=>Go,getDeviceBrowserType:()=>qd,getDeviceByName:()=>Fi,getDeviceChannel:()=>Jd,getDeviceOptions:()=>wa,getDevicesByCategory:()=>Mt,getIOSDeviceDisplayName:()=>Ud,getLoginConfigPlatform:()=>Qc,getRecordVideoSize:()=>Yd,getStatementContainers:()=>Me,getStoreSize:()=>ru,getTestPlatformFromDeviceName:()=>$d,hasReferenceIds:()=>Wo,isAndroidDevice:()=>Dd,isAppPackage:()=>Hd,isDynamicAction:()=>kd,isExecutableStatement:()=>xd,isIOSDevice:()=>Od,isNativeDevice:()=>Ld,isPhysicalDeviceUDID:()=>Gd,isPlatformCompatibleWithUrl:()=>Wd,isStoreEmpty:()=>ou,isWebUrl:()=>pa,mergeActionEntitiesIntoTestFlow:()=>su,mergeStoreUpdates:()=>au,parseAdbDeviceLine:()=>yu,parseYamlArrayItems:()=>gd,replaceVariables:()=>td,resolveActionEntity:()=>iu,resolveComputerUseModelFromEnv:()=>fu,resolveModels:()=>pu,resolveWebAgentModelFromEnv:()=>gu,suiteToYaml:()=>No,testFlowToYaml:()=>cd,testFlowToYamlObject:()=>Oo,toAndroidDeviceName:()=>xu,toIOSDeviceName:()=>Bd,updateStoreEntry:()=>nu,validatePatch:()=>Fo,validateTestYaml:()=>Cd,yamlObjectsToString:()=>dd,yamlToActionEntity:()=>md,yamlToTestFlow:()=>qe});var pr=y(()=>{"use strict";Zc();ed();id();od();yd();Pd();ha();Lo();Kd();Zd();Qd();lu();ma();du();mu();wu();bu();_u();ga()});import*as We from"path";import*as Tu from"fs";import{test as pg,expect as fA,chromium as gg}from"@playwright/test";import*as Z from"fs";import*as tt from"path";import{randomUUID as wr}from"crypto";import{tmpdir as br}from"os";function yr(e){return[`--disable-extensions-except=${e}`,`--load-extension=${e}`,"--no-first-run","--disable-default-apps"]}function xr(e){if(!Z.existsSync(e))return console.warn(`[fixture] extensionStorageState file not found: ${e}`),null;let t;try{t=JSON.parse(Z.readFileSync(e,"utf-8"))}catch(o){throw new Error(`[fixture] Failed to parse extensionStorageState at ${e}: ${o}`)}let i=t;if(!Array.isArray(i.cookies))return null;let n=(Date.now()+365*24*60*60*1e3)/1e3,a=i.cookies.filter(o=>o&&typeof o=="object"&&typeof o.name=="string"&&typeof o.domain=="string");return a.length<i.cookies.length&&console.warn(`[fixture] Skipped ${i.cookies.length-a.length} malformed cookies (missing name or domain)`),a.map(o=>({...o,expires:n}))}function vr(e){if(e){let i=tt.resolve(process.cwd(),e),n=tt.join(br(),`ext-profile-${wr()}`);if(Z.existsSync(i)){try{Z.cpSync(i,n,{recursive:!0})}catch(o){try{Z.rmSync(n,{recursive:!0,force:!0})}catch(r){console.warn("[fixture] Failed to clean up partial profile copy:",n,r)}throw new Error(`[fixture] Failed to copy extension profile from ${i}: ${o}`)}let a=tt.join(n,"SingletonLock");Z.existsSync(a)&&Z.rmSync(a,{force:!0})}else Z.mkdirSync(n,{recursive:!0});return n}let t=tt.join(br(),`ext-profile-${wr()}`);return Z.mkdirSync(t,{recursive:!0}),t}vo();import f1 from"dotenv";var Hp="__shiplightDotenvCache__";function Wp(){return globalThis[Hp]}function _o(){let e=Wp();return e===void 0?process.env:e}async function fg(e){let i=await import(We.resolve(process.cwd(),e.auth)),n=i.login||i.default;if(typeof n!="function")throw new Error(`auth module "${e.auth}" must export a login(args) function that returns a storageState file path`);let a=await n(e.args||{});if(typeof a!="string")throw new Error(`auth module "${e.auth}" login() must return a storageState file path (got ${typeof a})`);return a}function ku(e){return!(!e||e==="off")}function Au(e,t){return!e||e==="off"?!1:e==="on"?!0:e==="retain-on-failure"?t.status!==t.expectedStatus:e==="on-first-retry"?t.retry>0:typeof e=="object"&&e!==null&&"mode"in e?Au(e.mode,t):!0}async function Su(e,t,i){let n=Au(t,i);for(let a of e)try{if(n){let o=await a.path();await i.attach("video",{path:o,contentType:"video/webm"})}else await a.delete()}catch(o){console.warn("[fixture] Failed to process video:",o)}}var va;async function Eu(){return va||(va=await Promise.resolve().then(()=>(vo(),Jc)),va)}var wg=new Set(["get","set","getAll","has","__variableStore"]);function bg(e){let t={__variableStore:e,get(i){return e.get(i)},set(i,n,a=!1){e.set(i,n,a)},getAll(){return e.getAll()}};return new Proxy(t,{get(i,n,a){if(n in i)return Reflect.get(i,n,a);if(typeof n=="string")return i.get(n)},set(i,n,a){return typeof n!="string"||wg.has(n)?Reflect.set(i,n,a):(i.set(n,a),!0)},has(i,n){return n in i?!0:typeof n=="string"?e.has?.(n)??!1:!1}})}var yg=["GOOGLE_API_KEY","ANTHROPIC_API_KEY","OPENAI_API_KEY","OPENAI_BASE_URL","ANTHROPIC_MODELS_USE_VERTEXAI","GOOGLE_GENAI_USE_VERTEXAI","GOOGLE_CLOUD_PROJECT","GOOGLE_CLOUD_LOCATION","MAILGUN_API_KEY","MAILGUN_DOMAIN","SHIPLIGHT_API_TOKEN","SHIPLIGHT_API_URL"];function xg(e=_o()){let t={};for(let i of yg)t[i]=e[i]??"";return t}var xA=pg.extend({account:[void 0,{option:!0}],autoDismissModal:[!1,{option:!0}],extensionDir:[void 0,{option:!0}],userDataDir:[void 0,{option:!0}],extensionStorageState:[void 0,{option:!0}],launchOptions:async({launchOptions:e},t)=>{if(!process.env.SHIPLIGHT_REGISTRY_URL){await t(e);return}let i=e?.args??[],n={...e,args:[...i,"--remote-debugging-port=0"]};await t(n)},browser:async({browser:e},t)=>{let i=null;if(process.env.SHIPLIGHT_REGISTRY_URL)try{let n=await na(process.pid),a=process.env.TEST_WORKER_INDEX??"?";i=await yt({cdpUrl:n,label:`shiplight test w${a}`,pid:process.pid})}catch{}await t(e),await xt(i)},context:async({browser:e,account:t,extensionDir:i,userDataDir:n,extensionStorageState:a},o,r)=>{if(i||n){if(t||r.project.use.auth)throw new Error('Cannot use both "extensionDir"/"userDataDir" and "auth" \u2014 persistent context tests manage their own context. Use extensionStorageState for authentication instead.');let l=r.project.use?.browserName;l&&l!=="chromium"&&console.warn(`[fixture] Persistent context requires Chromium but project is configured for "${l}". Forcing Chromium.`);let d=process.env.PLAYWRIGHT_HEADLESS==="true";i&&d&&console.warn("[fixture] PLAYWRIGHT_HEADLESS=true with extensionDir \u2014 Chrome extensions will not function in headless mode.");let c=vr(n),u=i?yr(We.resolve(process.cwd(),i)):[],m={...r.project.use},{storageState:g,account:w,extensionDir:v,userDataDir:x,extensionStorageState:p,autoDismissModal:f,video:S,..._}=m,k=ku(S)?{dir:r.outputDir}:void 0,E;try{if(E=await gg.launchPersistentContext(c,{..._,headless:d,args:u,viewport:_.viewport??{width:1280,height:720},...k?{recordVideo:k}:{}}),a){let I=We.resolve(process.cwd(),a),C=xr(I);C&&await E.addCookies(C)}await o(E)}finally{let I=E?.pages().map(C=>C.video()).filter(C=>C!==null)??[];if(await E?.close().catch(C=>{console.warn("[fixture] Failed to close persistent context:",C)}),await Su(I,S,r),!n)try{Tu.rmSync(c,{recursive:!0,force:!0})}catch(C){console.warn("[fixture] Failed to clean up temp profile dir:",c,C)}}}else{let l={...r.project.use},d=r.project.use,c=d.auth?{auth:d.auth,args:d.args}:t;if(c){if(!c.auth)throw new Error("Auth is declared but missing the script path. Provide auth in playwright.config.ts: use: { auth: './auth.login.ts' }");l.storageState=await fg(c)}let u=l.video;ku(u)&&!l.recordVideo&&(l.recordVideo={dir:r.outputDir});let m=await e.newContext(l);m.addInitScript(De);try{await o(m)}finally{let g=m.pages().map(w=>w.video()).filter(w=>w!==null);await m.close(),await Su(g,u,r)}}},page:async({context:e},t)=>{let i=await e.newPage();await t(i)},testContext:async({},e,t)=>{let{VariableStore:i}=await Eu(),n=new i,a=t.project.use.variables;if(a)for(let[r,s]of Object.entries(a))typeof s=="string"?n.set(r,s,!1):s&&typeof s=="object"&&"value"in s&&n.set(r,s.value,s.sensitive===!0);let o=bg(n);global.testContext=o,global.$=o,global.ctx=o,await e(o),delete global.testContext,delete global.$,delete global.ctx},$:async({testContext:e},t)=>{await t(e)},ctx:async({testContext:e},t)=>{await t(e)},agent:async({page:e,testContext:t,autoDismissModal:i},n,a)=>{let{WebAgent:o,createAgentContext:r,configureSdk:s,parseSdkLogLevelFromEnv:l}=await Eu(),d=l();s({env:xg(),...d!==void 0&&{logLevel:d}});let{resolveWebAgentModelFromEnv:c,resolveComputerUseModelFromEnv:u}=await Promise.resolve().then(()=>(pr(),mr)),m=_o(),g=c(m);if(!g)throw new Error("No AI model configured. Set WEB_AGENT_MODEL, GOOGLE_API_KEY, ANTHROPIC_API_KEY, OPENAI_API_KEY, or SHIPLIGHT_API_TOKEN in your .env file (or in the runner environment for CI).");let w=u(m),v=t.__variableStore,x=r({model:g,computer_use_model:w,variableStore:v,autoDismissModal:i}),p=We.join(a.outputDir,"artifacts");x.stepTracking={results:{},artifactsDir:p};let f=new o(x),S=e.context();f.agentServices.setupPageTracking(S);for(let _ of S.pages())f.setupDownloadTracking(_),f.setupDialogHandling(_);S.on("page",_=>{f.setupDownloadTracking(_),f.setupDialogHandling(_)}),global.agent=f,await n(f),delete global.agent;try{let _=a.outputDir;await f.writeExecutionResults(_);let k=We.join(_,"test-results.json");await(await import("fs/promises")).stat(k).catch(()=>null)&&await a.attach("shiplight-results",{path:k,contentType:"application/json"})}catch(_){console.error("[Shiplight] Failed to attach step results:",_)}try{let _=f.getNewActionEntities();if(_.size>0&&a.status==="passed"){let{createEmptyStore:k,createRunnerStoreEntry:E}=await Promise.resolve().then(()=>(pr(),mr)),I=await import("fs/promises"),C=k();for(let[U,z]of _)C.entries[U]=E(z,0);let $=We.join(a.outputDir,"new-action-entities.json");await I.writeFile($,JSON.stringify(C,null,2)),await a.attach("shiplight-new-action-entities",{path:$,contentType:"application/json"}),console.log(`[Shiplight] ${_.size} healed action entit${_.size===1?"y":"ies"} saved`)}}catch(_){console.warn("[Shiplight] Failed to persist new action entities:",_)}}});export{yg as SDK_ENV_ALLOWLIST,xg as buildSdkEnv,bg as createTestContext,fA as expect,fg as resolveAuthState,xA as test};