agent-device 0.17.3 → 0.17.5
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/android-multitouch-helper/dist/{agent-device-android-multitouch-helper-0.17.3.apk → agent-device-android-multitouch-helper-0.17.5.apk} +0 -0
- package/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.17.5.apk.sha256 +1 -0
- package/android-multitouch-helper/dist/{agent-device-android-multitouch-helper-0.17.3.manifest.json → agent-device-android-multitouch-helper-0.17.5.manifest.json} +4 -4
- package/android-snapshot-helper/README.md +3 -0
- package/android-snapshot-helper/dist/{agent-device-android-snapshot-helper-0.17.3.apk → agent-device-android-snapshot-helper-0.17.5.apk} +0 -0
- package/android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.17.5.apk.sha256 +1 -0
- package/android-snapshot-helper/dist/{agent-device-android-snapshot-helper-0.17.3.manifest.json → agent-device-android-snapshot-helper-0.17.5.manifest.json} +6 -6
- package/dist/src/123.js +1 -1
- package/dist/src/2415.js +33 -32
- package/dist/src/4012.js +4 -0
- package/dist/src/6133.js +1 -1
- package/dist/src/9542.js +5 -5
- package/dist/src/apple.js +1 -1
- package/dist/src/cli-output.js +2 -1
- package/dist/src/cli.js +4 -4
- package/dist/src/index.d.ts +16 -0
- package/dist/src/session.js +8 -8
- package/dist/src/snapshot.js +2 -2
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h +4 -0
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m +8 -0
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +3 -4
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +1 -1
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +118 -10
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +2 -2
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SequenceExecution.swift +47 -3
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +0 -9
- package/package.json +1 -1
- package/server.json +2 -2
- package/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.17.3.apk.sha256 +0 -1
- package/android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.17.3.apk.sha256 +0 -1
- package/dist/src/9238.js +0 -4
package/dist/src/6133.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e;import{DEVICE_TARGETS as t,findNodeByRef as r,normalizeRef as n,PLATFORM_SELECTORS as i,centerOfRect as a,NETWORK_INCLUDE_MODES as o}from"./9616.js";import{splitSelectorFromArgs as s,findNearestHittableAncestor as l,tryParseSelectorChain as u,buildSelectorChainForNode as c,parseSelectorChain as p,findNodeByLabel as d,resolveRefLabel as m,resolveSelectorChain as f,formatSelectorFailure as h,normalizeType as g}from"./7847.js";import{AppError as y}from"./9152.js";import{STRUCTURED_BATCH_COMMAND_NAMES as b,readStructuredBatchCommandName as w,INTERNAL_COMMANDS as v,GESTURE_KINDS as x,PUBLIC_COMMANDS as S}from"./6088.js";import{intersectArea as k,isScrollableNodeLike as A}from"./4778.js";import{FIND_LOCATORS as D}from"./7556.js";import{DEFAULT_APPS_FILTER as I,assertResolvedAppsFilter as M}from"./3675.js";let L=["ref","selector","point"];function N(e){return{type:"string",...e?{description:e}:{}}}function R(e){return{type:"integer",...e?{description:e}:{}}}function O(e){return{type:"boolean",...e?{description:e}:{}}}function E(e){return{type:"object",additionalProperties:!0,...e?{description:e}:{}}}function P(e){return{...e,required:!0}}function _(e){return eu(N(e),Y)}function C(e){return eu({type:"number",...e?{description:e}:{}},Z)}function T(e,t={}){var r,n;return eu((r=e,n=t,{...R(r),...void 0===n.min?{}:{minimum:n.min},...void 0===n.max?{}:{maximum:n.max}}),(e,r)=>ee(e,r,t))}function $(e){return eu(O(e),et)}function F(e,t){return eu({type:"string",enum:e,...t?{description:t}:{}},(t,r)=>en(t,r,e))}function U(e){return eu({type:"array",items:{type:"string"},...e?{description:e}:{}},ec)}function j(e){return eu(e,(e,t)=>e[t])}function V(){return eu({oneOf:[...ep(),{type:"object",properties:{kind:{type:"string",const:"point"},x:{type:"number"},y:{type:"number"}},required:["kind","x","y"],additionalProperties:!1}],description:"UI target. This is separate from deviceTarget, which selects the device form."},(e,t)=>void 0===e[t]?void 0:function(e,t){let r=ed(e,t),n=er(r,"kind",L);switch(n){case"ref":return{kind:n,ref:X(r,"ref"),label:Y(r,"label")};case"selector":return{kind:n,selector:X(r,"selector")};case"point":return{kind:n,x:Q(r,"x"),y:Q(r,"y")}}}(e,t))}function q(e){return eu({type:"object",description:e,properties:{x:{type:"number"},y:{type:"number"}},required:["x","y"],additionalProperties:!1},(e,t)=>void 0===e[t]?void 0:J(e,t))}function G(){return{depth:T("Snapshot traversal depth.",{min:0}),scope:_("Snapshot scope selector used before resolution."),raw:$("Use raw snapshot data during selector resolution.")}}function z(){return{count:T("Number of press/click repetitions.",{min:1}),intervalMs:T("Delay between repeated press/click actions.",{min:0}),holdMs:T("Hold duration for each action.",{min:0}),jitterPx:T("Randomization radius in pixels.",{min:0}),doubleTap:$("Request a double-tap action.")}}function B(e){return function(e,r=[]){return{type:"object",properties:{session:{type:"string",description:"Agent-device session name."},platform:{type:"string",enum:i,description:"Platform selector used to resolve a device."},deviceTarget:{type:"string",enum:t,description:"Device target form. Maps to the CLI --target flag."},target:{type:"string",enum:t,description:"Alias for deviceTarget on commands without a UI target field. Interaction commands reserve target for the UI element."},device:{type:"string",description:"Device name selector."},udid:{type:"string",description:"iOS device UDID selector."},serial:{type:"string",description:"Android serial selector."},iosSimulatorDeviceSet:{type:"string",description:"iOS simulator device-set path used for device resolution."},androidDeviceAllowlist:{type:"string",description:"Android serial allowlist used for device resolution."},daemonBaseUrl:{type:"string",description:"Remote daemon base URL."},daemonAuthToken:{type:"string",description:"Remote daemon auth token."},tenant:{type:"string",description:"Remote tenant identifier."},runId:{type:"string",description:"Lease run identifier."},leaseId:{type:"string",description:"Existing lease identifier."},cwd:{type:"string",description:"Working directory for command execution."},debug:{type:"boolean",description:"Enable debug diagnostics."},...e},...r.length>0?{required:r}:{},additionalProperties:!1}}(Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.schema])),Object.entries(e).flatMap(([e,t])=>t.required?[e]:[]))}function H(e,t){let r=W(e),n=Object.fromEntries(Object.entries(t).flatMap(([e,t])=>{let n=t.read(r,e);if(t.required&&void 0===n)throw Error(`Expected ${e} to be set.`);return void 0===n?[]:[[e,n]]})),i=K(r,{readTargetAlias:!Object.hasOwn(t,"target")});return el({...i,...ei(i),...n})}function W(e){if(null==e)return{};if(!e||"object"!=typeof e||Array.isArray(e))throw Error("Expected object arguments.");return e}function K(e,r={}){return{session:Y(e,"session"),platform:en(e,"platform",i),deviceTarget:function(e,r){let n=en(e,"deviceTarget",t);if(!1===r.readTargetAlias||void 0===e.target)return n;let i=en(e,"target",t);if(void 0!==n&&i!==n)throw Error("Expected target alias to match deviceTarget when both are set.");return n??i}(e,r),device:Y(e,"device"),udid:Y(e,"udid"),serial:Y(e,"serial"),iosSimulatorDeviceSet:Y(e,"iosSimulatorDeviceSet"),androidDeviceAllowlist:Y(e,"androidDeviceAllowlist"),daemonBaseUrl:Y(e,"daemonBaseUrl"),daemonAuthToken:Y(e,"daemonAuthToken"),tenant:Y(e,"tenant"),runId:Y(e,"runId"),leaseId:Y(e,"leaseId"),cwd:Y(e,"cwd"),debug:et(e,"debug")}}function J(e,t){let r=ed(e,t);return{x:Q(r,"x"),y:Q(r,"y")}}function X(e,t){let r=e[t];if("string"!=typeof r||0===r.length)throw Error(`Expected ${t} to be a non-empty string.`);return r}function Y(e,t){let r=e[t];if(void 0!==r){if("string"!=typeof r||0===r.length)throw Error(`Expected ${t} to be a non-empty string.`);return r}}function Q(e,t){let r=e[t];if("number"!=typeof r||!Number.isFinite(r))throw Error(`Expected ${t} to be a finite number.`);return r}function Z(e,t){let r=e[t];if(void 0!==r){if("number"!=typeof r||!Number.isFinite(r))throw Error(`Expected ${t} to be a finite number.`);return r}}function ee(e,t,r={}){let n=e[t];if(void 0!==n){if(!Number.isInteger(n))throw Error(`Expected ${t} to be an integer.`);if(void 0!==r.min&&n<r.min)throw Error(`Expected ${t} to be at least ${r.min}.`);if(void 0!==r.max&&n>r.max)throw Error(`Expected ${t} to be at most ${r.max}.`);return n}}function et(e,t){let r=e[t];if(void 0!==r){if("boolean"!=typeof r)throw Error(`Expected ${t} to be a boolean.`);return r}}function er(e,t,r){let n=e[t];if("string"!=typeof n||!r.includes(n))throw Error(`Expected ${t} to be one of: ${r.join(", ")}.`);return n}function en(e,t,r){let n=e[t];if(void 0!==n){if("string"!=typeof n||!r.includes(n))throw Error(`Expected ${t} to be one of: ${r.join(", ")}.`);return n}}function ei(e){return el({session:e.session,platform:e.platform,target:e.deviceTarget,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,androidDeviceAllowlist:e.androidDeviceAllowlist,daemonBaseUrl:e.daemonBaseUrl,daemonAuthToken:e.daemonAuthToken,tenant:e.tenant,runId:e.runId,leaseId:e.leaseId,cwd:e.cwd,debug:e.debug})}function ea(e){switch(e.kind){case"ref":return{ref:e.ref,label:e.label};case"selector":return{selector:e.selector};case"point":return{x:e.x,y:e.y}}}function eo(e){return{count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap}}function es(e){return{depth:e.depth,scope:e.scope,raw:e.raw}}function el(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e))}function eu(e,t){return{schema:e,required:!1,read:t}}function ec(e,t){let r=e[t];if(void 0!==r){if(!Array.isArray(r)||r.some(e=>"string"!=typeof e))throw Error(`Expected ${t} to be an array of strings.`);return r}}function ep(){return[{type:"object",properties:{kind:{type:"string",const:"ref"},ref:{type:"string",description:"Snapshot element ref such as @e12."},label:{type:"string",description:"Optional human label for the ref."}},required:["kind","ref"],additionalProperties:!1},{type:"object",properties:{kind:{type:"string",const:"selector"},selector:{type:"string",description:"Agent-device selector expression."}},required:["kind","selector"],additionalProperties:!1}]}function ed(e,t){let r=e[t];if(!r||"object"!=typeof r||Array.isArray(r))throw Error(`Expected ${t} to be an object.`);return r}function em(e,t){return r=>ef(e,t?t(r):[],r)}function ef(e,t,r){return{command:e,positionals:t,options:function(e){var t;let r="mobile"===(t=e.deviceTarget??e.target)||"tv"===t||"desktop"===t?t:void 0;if(void 0===r&&void 0===e.target)return e;let{target:n,...i}=e;return void 0===r?i:{...i,target:r}}(r)}}function eh(e){return el({session:e.session,platform:e.platform,deviceTarget:e.target,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,androidDeviceAllowlist:e.androidDeviceAllowlist})}function eg(e){return{platform:e.platform,target:e.target,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,androidDeviceAllowlist:e.androidDeviceAllowlist}}function ey(e){return el({depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw})}function eb(e){return{depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw}}function ew(e){return el({count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap})}function ev(e){return"ref"in e&&void 0!==e.ref?el({kind:"ref",ref:e.ref,label:e.label}):"selector"in e&&void 0!==e.selector?{kind:"selector",selector:e.selector}:{kind:"point",x:e.x,y:e.y}}function ex(e){let t=eS(e);if("string"==typeof t.ref)return[t.ref,...eA(t.label)];if("string"==typeof t.selector)return[t.selector];if("point"===t.kind||void 0!==t.x||void 0!==t.y)return[String(ek(t.x,"x")),String(ek(t.y,"y"))];throw new y("INVALID_ARGS","interaction requires @ref, selector, or point target")}function eS(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new y("INVALID_ARGS","Expected target object.");let t=e.target;return t&&"object"==typeof t&&!Array.isArray(t)?t:e}function ek(e,t){if("number"!=typeof e||!Number.isFinite(e))throw new y("INVALID_ARGS",`point target requires numeric ${t}.`);return e}function eA(e){return"string"==typeof e&&e.length>0?[e]:[]}function eD(...e){return new Set(e)}function eI(e,t){return void 0!==e&&t.has(e)}function eM(e){return void 0!==e&&""!==e.trim()&&Number.isFinite(Number(e))}function eL(e){return void 0===e?void 0:Number(e)}function eN(e){return void 0===e?[]:[e]}function eR(e){return void 0===e?[]:[String(e)]}function eO(e,t){if(void 0===e||""===e)throw new y("INVALID_ARGS",t);return e}function eE(e,t){if("string"!=typeof e||0===e.length)throw new y("INVALID_ARGS",t);return e}function eP(e,t){return{...e,run:t,invoke:async(r,n)=>await t(r,e.readInput(n))}}let e_=["screenshotFullscreen","screenshotMaxSize","screenshotNoStabilize"];function eC(e){return eU({overlayRefs:e?.overlayRefs,fullscreen:e?.screenshotFullscreen,maxSize:e?.screenshotMaxSize,stabilize:!e?.screenshotNoStabilize&&void 0})}function eT(e={}){return eU({overlayRefs:e.overlayRefs,screenshotFullscreen:e.screenshotFullscreen??e.fullscreen,screenshotMaxSize:e.screenshotMaxSize??e.maxSize,screenshotNoStabilize:e.screenshotNoStabilize??(!1===e.stabilize||void 0)})}function e$(e,t){t?.screenshotFullscreen&&e.push("--fullscreen"),"number"==typeof t?.screenshotMaxSize&&e.push("--max-size",String(t.screenshotMaxSize)),t?.screenshotNoStabilize&&e.push("--no-stabilize")}function eF(e){let{args:t,flags:r,index:n}=e,i=t[n];if("--fullscreen"===i)return r.screenshotFullscreen=!0,{handled:!0,nextIndex:n};if("--no-stabilize"===i)return r.screenshotNoStabilize=!0,{handled:!0,nextIndex:n};if("--max-size"===i){let e=t[n+1],i=void 0===e?NaN:Number(e);if(!Number.isInteger(i)||i<1)throw new y("INVALID_ARGS","screenshot --max-size requires a positive integer");return r.screenshotMaxSize=i,{handled:!0,nextIndex:n+1}}return{handled:!1}}function eU(e){return Object.fromEntries(Object.entries(e).filter(e=>void 0!==e[1]))}let ej=new Set(["healthy","recovered","sparse"]),eV=new Set(["tree","queries","private-ax"]),eq=new Set(["ax-rejected","sparse-tree","budget","no-nodes","capture-failed"]);function eG(e){if(e&&"object"==typeof e){if("string"==typeof e.state&&ej.has(e.state)&&"string"==typeof e.backend&&eV.has(e.backend))return{state:e.state,backend:e.backend,reason:"string"==typeof e.reason?e.reason:void 0,reasonCode:"string"==typeof e.reasonCode&&eq.has(e.reasonCode)?e.reasonCode:void 0,effectiveDepth:"number"==typeof e.effectiveDepth?e.effectiveDepth:void 0,collapsedLeafIndexes:Array.isArray(e.collapsedLeafIndexes)?e.collapsedLeafIndexes.filter(e=>"number"==typeof e):void 0}}}function ez(e){return e?.state==="sparse"}function eB(e,t){var r;return[...function(e){if("recovered"===e.state){let t="budget"===e.reasonCode?" The primary capture ran out of its time budget (busy app or simulator); the recovered tree is authoritative for this screen.":" This usually means the app publishes an unhealthy accessibility tree — fixing the app's accessibility is the real cure. Treat screenshot as visual truth when this warning appears.";return[`Recovered this snapshot with the ${e.backend} accessibility backend`+(e.reason?` after: ${e.reason}.`:".")+t]}return"sparse"===e.state?["No snapshot backend could read this screen"+(e.reason?` (${e.reason})`:"")+". Use screenshot as visual truth and coordinate taps; retry snapshot after navigating."]:[]}(e),...void 0===(r=e).effectiveDepth?[]:[`The accessibility server rejected deeper requests; this tree is capped at depth ${r.effectiveDepth} — re-run with --depth ${r.effectiveDepth} --scope <container> for deeper content.`],...function(e,t){let r=[];for(let n of e.collapsedLeafIndexes??[]){let e=t.find(e=>e.index===n);if(!e)continue;let i=e.identifier?` (${e.identifier})`:"";r.push(`@${e.ref} [${e.type??"element"}]${i} merges many labels into a single accessibility element. The app likely marks a container as accessible, which hides every descendant from assistive tech and automation — the children cannot be addressed individually. Fix the app's accessibility (mark the rows, not the container); until then use screenshot as visual truth and coordinate taps.`)}return r}(e,t)]}function eH(e){let t=eG(e.quality);return{...e.analysis?{analysis:e.analysis}:{},...e.androidSnapshot?{androidSnapshot:e.androidSnapshot}:{},...e.freshness?{freshness:e.freshness}:{},...t?{quality:t}:{},...e.warnings?{warnings:e.warnings}:{}}}function eW(e){return{...e.androidSnapshot?{androidSnapshot:e.androidSnapshot}:{},...e.quality?{snapshotQuality:e.quality}:{},...e.warnings&&e.warnings.length>0?{warnings:e.warnings}:{}}}function eK(e){var t;let r="object"==typeof(t=e.androidSnapshot)&&null!==t?t:void 0,n=Array.isArray(e.warnings)?e.warnings.filter(e=>"string"==typeof e):void 0,i=eG(e.snapshotQuality);return eW({...r?{androidSnapshot:r}:{},...i?{quality:i}:{},...n?{warnings:n}:{}})}function eJ(e){return e?{message:e}:{}}function eX(e,t){return t?{...e,message:t}:e}function eY(e){return"string"==typeof e?.message&&e.message.length>0?e.message:null}function eQ(e){let t=e.appId??e.bundleId??e.packageName;return{session:e.session,appId:t,appBundleId:e.bundleId,package:e.packageName}}function eZ(e,t,r){return{deviceId:t,deviceName:r,..."android"===e?{serial:t}:"ios"===e?{udid:t}:{}}}function e0(e,t={}){let r=t.includeAndroidSerial??!0;return{platform:e.platform,target:e.target,device:e.name,id:e.id,..."ios"===e.platform?{device_udid:e.ios?.udid??e.id,ios_simulator_device_set:e.ios?.simulatorSetPath??null}:{},..."android"===e.platform&&r?{serial:e.android?.serial??e.id}:{}}}function e1(e){return{name:e.name,...e.sessionStateDir?{sessionStateDir:e.sessionStateDir}:{},...e.runnerLogPath?{runnerLogPath:e.runnerLogPath}:{},...e0(e.device,{includeAndroidSerial:!1}),createdAt:e.createdAt}}function e2(e){return{platform:e.platform,id:e.id,name:e.name,kind:e.kind,target:e.target,..."boolean"==typeof e.booted?{booted:e.booted}:{}}}function e5(e){return e.bundleId??e.package??e.app}function e3(e){return eX({app:e.app,appPath:e.appPath,platform:e.platform,...e.appId?{appId:e.appId}:{},...e.bundleId?{bundleId:e.bundleId}:{},...e.package?{package:e.package}:{}},`Installed: ${e5(e)}`)}function e8(e){return e.appName??e.bundleId??e.packageName??e.launchTarget}function e4(e){return eX({launchTarget:e.launchTarget,...e.appName?{appName:e.appName}:{},...e.appId?{appId:e.appId}:{},...e.bundleId?{bundleId:e.bundleId}:{},...e.packageName?{package:e.packageName}:{},...e.installablePath?{installablePath:e.installablePath}:{},...e.archivePath?{archivePath:e.archivePath}:{},...e.materializationId?{materializationId:e.materializationId}:{},...e.materializationExpiresAt?{materializationExpiresAt:e.materializationExpiresAt}:{}},`Installed: ${e8(e)}`)}function e6(e){let t=e.appName??e.appBundleId??e.session;return eX({session:e.session,...e.sessionStateDir?{sessionStateDir:e.sessionStateDir}:{},...e.runnerLogPath?{runnerLogPath:e.runnerLogPath}:{},...e.requestLogPath?{requestLogPath:e.requestLogPath}:{},...e.appName?{appName:e.appName}:{},...e.appBundleId?{appBundleId:e.appBundleId}:{},...e.startup?{startup:e.startup}:{},...e.runtime?{runtime:e.runtime}:{},...e.device?e0(e.device):{}},t?`Opened: ${t}`:"Opened")}function e9(e){return{session:e.session,...e.shutdown?{shutdown:e.shutdown}:{},...eJ(e.session?`Closed: ${e.session}`:"Closed")}}function e7(e){var t;return{nodes:e.nodes,truncated:e.truncated,...e.appName?{appName:e.appName}:{},...e.appBundleId?{appBundleId:e.appBundleId}:{},...e.visibility?{visibility:e.visibility}:{},...eW({...t=e,...t.snapshotQuality?{quality:t.snapshotQuality}:{}}),...e.unchanged?{unchanged:e.unchanged}:{}}}function te(e,t,r,n){let i=r(e[t]);if(void 0===i)throw new y("COMMAND_FAILED",n,{response:e});return i}function tt(e,t){return te(e,t,tl,`Daemon response is missing "${t}".`)}function tr(e,t){return tl(e[t])}function tn(e,t){var r;let n;return r=tl,null===(n=e[t])?null:r(n)}function ti(e,t){return te(e,t,tc,`Daemon response has invalid "${t}".`)}function ta(e,t){return function(e){return"tv"===e||"mobile"===e||"desktop"===e?e:void 0}(e[t])??"mobile"}function to(e,t){let r=e[t];if(!td(r))return;let n=ts(r,"x"),i=ts(r,"y"),a=ts(r,"width"),o=ts(r,"height");if(void 0!==n&&void 0!==i&&void 0!==a&&void 0!==o)return{x:n,y:i,width:a,height:o}}function ts(e,t){let r=e[t];return"number"==typeof r?r:void 0}function tl(e){return"string"==typeof e&&e.length>0?e:void 0}function tu(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function tc(e){return"ios"===e||"macos"===e||"android"===e||"linux"===e?e:void 0}function tp(e){return"simulator"===e||"emulator"===e||"device"===e?e:void 0}function td(e){return"object"==typeof e&&null!==e}function tm(e){let t={};for(let[r,n]of Object.entries(e))void 0!==n&&(t[r]=n);return t}function tf(e){return e.split("\n").map(e=>e.trim()).filter(e=>e.length>0)}function th(e,t){let r=tr(e,"bundleId"),n=tr(e,"package");return{app:tt(e,"app"),appPath:tt(e,"appPath"),platform:ti(e,"platform"),appId:r??n,bundleId:r,package:n,identifiers:eQ({session:t,bundleId:r,packageName:n})}}function tg(e,t){let r=tr(e,"bundleId"),n=tr(e,"packageName"),i=r??n??tr(e,"appId"),a=tr(e,"launchTarget")??n??r??i;if(!a)throw new y("COMMAND_FAILED",'Daemon response is missing "launchTarget".',{response:e});return{appName:tr(e,"appName"),appId:i,bundleId:r,packageName:n,launchTarget:a,installablePath:tr(e,"installablePath"),archivePath:tr(e,"archivePath"),materializationId:tr(e,"materializationId"),materializationExpiresAt:tr(e,"materializationExpiresAt"),identifiers:eQ({session:t,bundleId:r,packageName:n,appId:i})}}function ty(e){return{released:!0===e.released,materializationId:tt(e,"materializationId"),identifiers:{}}}function tb(e){let{record:t,platform:r,id:n,name:i,target:a}=tv(e,"name");return{platform:r,target:a,kind:te(t,"kind",tp,'Daemon response has invalid "kind".'),id:n,name:i,booted:"boolean"==typeof t.booted?t.booted:void 0,identifiers:eZ(r,n,i),...tx(r,n)}}function tw(e){let{record:t,platform:r,id:n,name:i,target:a}=tv(e,"name"),o=tt(t,"device"),s={session:i,...eZ(r,n,o)};return{name:i,createdAt:te(t,"createdAt",tu,'Daemon response is missing numeric "createdAt".'),sessionStateDir:tr(t,"sessionStateDir"),runnerLogPath:tr(t,"runnerLogPath"),device:{platform:r,target:a,id:n,name:o,identifiers:s,...tx(r,n,tn(t,"ios_simulator_device_set"))},identifiers:s}}function tv(e,t){let r=function(e){if(!td(e))throw new y("COMMAND_FAILED","Daemon returned an unexpected response shape.",{value:e});return e}(e);return{record:r,platform:ti(r,"platform"),id:tt(r,"id"),name:tt(r,t),target:ta(r,"target")}}function tx(e,t,r){return{ios:"ios"===e?{udid:t,...void 0!==r?{simulatorSetPath:r}:{}}:void 0,android:"android"===e?{serial:t}:void 0}}function tS(e){if(!td(e))return;let t=e.platform,r=tr(e,"metroHost"),n="number"==typeof e.metroPort?e.metroPort:void 0;return{platform:"ios"===t||"android"===t?t:void 0,metroHost:r,metroPort:n,bundleUrl:tr(e,"bundleUrl"),launchUrl:tr(e,"launchUrl")}}function tk(e){let t=e.platform,r=tr(e,"id"),n=tr(e,"device");if("ios"!==t&&"macos"!==t&&"android"!==t&&"linux"!==t||!r||!n)return;let i=ta(e,"target"),a=eZ(t,r,n);return{platform:t,target:i,id:r,name:n,identifiers:a,ios:"ios"===t?{udid:tr(e,"device_udid")??r,simulatorSetPath:tn(e,"ios_simulator_device_set")}:void 0,android:"android"===t?{serial:tr(e,"serial")??r}:void 0}}function tA(e){if(td(e)&&"number"==typeof e.durationMs&&"string"==typeof e.measuredAt&&"string"==typeof e.method)return{durationMs:e.durationMs,measuredAt:e.measuredAt,method:e.method,appTarget:tr(e,"appTarget"),appBundleId:tr(e,"appBundleId")}}function tD(e){return Array.isArray(e)?e:[]}function tI(e){let t=e.overlayRefs;if(!Array.isArray(t))return;let r=[];for(let e of t){if(!td(e))continue;let t=tr(e,"ref"),n=to(e,"rect"),i=to(e,"overlayRect"),a=function(e,t){let r=e[t];if(!td(r))return;let n=ts(r,"x"),i=ts(r,"y");if(void 0!==n&&void 0!==i)return{x:n,y:i}}(e,"center");t&&n&&i&&a&&r.push({ref:t,label:tr(e,"label"),rect:n,overlayRect:i,center:a})}return r}function tM(e){return tm({stateDir:e.stateDir,daemonBaseUrl:e.daemonBaseUrl,daemonAuthToken:e.daemonAuthToken,daemonTransport:e.daemonTransport,daemonServerMode:e.daemonServerMode,tenant:e.tenant,sessionIsolation:e.sessionIsolation,runId:e.runId,leaseId:e.leaseId,leaseBackend:e.leaseBackend,platform:e.platform,target:e.target,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,androidDeviceAllowlist:e.androidDeviceAllowlist,surface:e.surface,activity:e.activity,launchConsole:e.launchConsole,launchArgs:e.launchArgs,relaunch:e.relaunch,shutdown:e.shutdown,saveScript:e.saveScript,deviceHub:e.deviceHub,noRecord:e.noRecord,backMode:e.backMode,metroHost:e.metroHost,metroPort:e.metroPort,bundleUrl:e.bundleUrl,launchUrl:e.launchUrl,snapshotInteractiveOnly:e.interactiveOnly,snapshotDepth:e.depth,snapshotScope:e.scope,snapshotRaw:e.raw,snapshotForceFull:e.forceFull,...eT(e),appsFilter:e.appsFilter,kind:e.kind,out:e.out,count:e.count,fps:e.fps,quality:e.quality,hideTouches:e.hideTouches,intervalMs:e.intervalMs,delayMs:e.delayMs,holdMs:e.holdMs,jitterPx:e.jitterPx,pixels:e.pixels,doubleTap:e.doubleTap,clickButton:e.clickButton,pauseMs:e.pauseMs,pattern:e.pattern,headless:e.headless,restart:e.restart,replayUpdate:e.replayUpdate,replayBackend:e.replayBackend,replayEnv:e.replayEnv,replayShellEnv:e.replayShellEnv,failFast:e.failFast,timeoutMs:e.timeoutMs,retries:e.retries,recordVideo:e.recordVideo,artifactsDir:e.artifactsDir,reportJunit:e.reportJunit,shardAll:e.shardAll,shardSplit:e.shardSplit,findFirst:e.findFirst,findLast:e.findLast,networkInclude:e.networkInclude,batchOnError:e.batchOnError,batchMaxSteps:e.batchMaxSteps,batchSteps:e.batchSteps,verbose:e.debug})}function tL(e){return tm({requestId:e.requestId,cwd:e.cwd,sessionExplicit:void 0!==e.session,debug:e.debug,lockPolicy:e.lockPolicy,lockPlatform:e.lockPlatform,tenantId:e.tenant,runId:e.runId,leaseId:e.leaseId,leaseBackend:e.leaseBackend,leaseTtlMs:e.leaseTtlMs,sessionIsolation:e.sessionIsolation,installSource:e.installSource,retainMaterializedPaths:e.retainMaterializedPaths,materializedPathRetentionMs:e.materializedPathRetentionMs,materializationId:e.materializationId})}function tN(e){return e??"default"}function tR(e){return t=>ef(S.batch,[],{...t,batchSteps:function(e,t){if(!Array.isArray(e)||0===e.length)throw new y("INVALID_ARGS","batch requires a non-empty steps array.");return e.map((e,r)=>{var n,i,a,o,s;let l,u,c,p,d,m;return n=e,i=r+1,a=t,c=(o=u=function(e,t){if(!e||"object"!=typeof e||Array.isArray(e))throw new y("INVALID_ARGS",`Invalid batch step ${t}.`);return e}(n,i),s=i,w(o.command,s)),p=function(e,t){let r=e.input;if(!r||"object"!=typeof r||Array.isArray(r))throw new y("INVALID_ARGS",`Batch step ${t} input must be an object.`);return r}(u,i),d=function(e,t){let r=e.runtime;if(void 0!==r&&(!r||"object"!=typeof r||Array.isArray(r)))throw new y("INVALID_ARGS",`Batch step ${t} runtime must be an object.`);return r}(u,i),{...m={command:(l=a(c,p)).command,positionals:l.positionals,flags:tM(l.options),runtime:l.options.runtime},runtime:d??m.runtime}})}(t.steps,e),batchOnError:t.onError,batchMaxSteps:t.maxSteps})}let tO=function(e=b){var t;let r={steps:P(eu({type:"array",description:"Structured batch steps. Each step uses a command name and the same input object as that command tool.",items:{type:"object",properties:{command:{type:"string",enum:t=e,description:"Command name to run with structured input."},input:{type:"object",additionalProperties:!0,description:"Structured command input for the nested command. Use the matching MCP tool schema for this object."},runtime:{type:"object",additionalProperties:!0,description:"Optional per-step runtime payload."}},required:["command","input"],additionalProperties:!1}},(e,r)=>(function(e,t){if(!Array.isArray(e))throw Error("Expected steps to be an array.");return e.map((e,r)=>{var n,i,a;let o;return n=e,i=r+1,a=t,!function(e,t,r){let n=new Set(t),i=Object.keys(e).filter(e=>!n.has(e));if(i.length>0)throw Error(`${r} has unknown field(s): ${i.join(", ")}.`)}(o=function(e,t){if(!e||"object"!=typeof e||Array.isArray(e))throw Error(`Invalid batch step ${t}.`);return e}(n,i),["command","input","runtime"],`Batch step ${i}`),{command:function(e,t,r){if(r===b)return w(e.command,t);let n=e.command;if("string"!=typeof n||!r.includes(n))throw Error(`Expected command to be one of: ${r.join(", ")}.`);return n}(o,i,a),input:function(e,t){let r=e.input;if(!r||"object"!=typeof r||Array.isArray(r))throw Error(`Batch step ${t} input must be an object.`);return r}(o,i),...function(e,t){let r=e.runtime;if(void 0!==r&&(!r||"object"!=typeof r||Array.isArray(r)))throw Error(`Batch step ${t} runtime must be an object.`);return void 0===r?{}:{runtime:r}}(o,i)}})})(e[r],t))),onError:F(["stop"],"Batch failure policy."),maxSteps:T("Maximum number of steps accepted for this batch.",{min:1,max:1e3}),out:_("Optional output path for command artifacts.")};return{name:"batch",description:"Run multiple structured command steps in one daemon request.",inputSchema:B(r),readInput:e=>(function(e,t){let r=H(e,t),n=r.maxSteps??100;if(!Number.isInteger(n)||n<1||n>1e3)throw Error(`Invalid batch maxSteps: ${String(r.maxSteps)}`);if(r.steps.length>n)throw Error(`batch has ${r.steps.length} steps; max allowed is ${n}.`);return{...r}})(e,r)}}(),tE=eP(tO,(e,t)=>{var r;return e.batch.run({...ei(r=t),steps:r.steps,onError:r.onError,maxSteps:r.maxSteps,out:r.out})}),tP={batch:{usageOverride:"batch [--steps <json> | --steps-file <path>]",listUsageOverride:"batch --steps <json> | --steps-file <path>",helpDescription:"Execute multiple commands in one daemon request",summary:"Run multiple commands",allowedFlags:["steps","stepsFile","batchOnError","batchMaxSteps","out"]}},t_={batch:(e,t)=>({...eh(t),steps:t.batchSteps??[],onError:t.batchOnError,maxSteps:t.batchMaxSteps,out:t.out})};function tC(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function tT(e){let t=e[0];if(void 0===t)return null;let r=tC(t);if(null!==r)return{kind:"sleep",durationMs:r};let n=tC(e[e.length-1]);if("text"===t)return{kind:"text",text:(null!==n?e.slice(1,-1).join(" "):e.slice(1).join(" ")).trim(),timeoutMs:n};if(t.startsWith("@"))return{kind:"ref",rawRef:t,timeoutMs:n};let i=s(null!==n?e.slice(0,-1):e.slice());return i&&0===i.rest.length&&u(i.selectorExpression)?{kind:"selector",selectorExpression:i.selectorExpression,timeoutMs:n}:{kind:"text",text:(null!==n?e.slice(0,-1).join(" "):e.join(" ")).trim(),timeoutMs:n}}function t$(e,t){return e.includes(t)}function tF(e,t,r={}){let n=void 0===t?void 0:r.normalize?.(t)??t;if(void 0!==n&&t$(e,n))return n;throw new y("INVALID_ARGS",("function"==typeof r.message?r.message(t):r.message)??`Invalid value: ${t}. Use ${e.join("|")}.`)}function tU(e,t={}){return{values:e,is:t=>t$(e,t),parse:r=>tF(e,r,t)}}let tj=["app","frontmost-app","desktop","menubar"],tV=tU(tj,{normalize:e=>e.trim().toLowerCase(),message:e=>`Invalid surface: ${e}. Use ${tj.join("|")}.`});function tq(e){return tV.parse(e)}let tG=["metrics","frames","memory","cpu","trace"],tz=["sample","snapshot","start","stop","report"],tB=["profile"],tH=["xctrace","simpleperf","perfetto","android-hprof","memgraph"],tW=tU(tG),tK=tU(tz),tJ=tU(tB),tX=tU(tH),tY=tU(["android-hprof","memgraph"]),tQ="perf area must be metrics, frames, memory, cpu, or trace",tZ="perf action must be sample, snapshot, start, stop, or report",t0="perf cpu requires profile",t1="perf --kind must be xctrace, simpleperf, perfetto, android-hprof, or memgraph",t2="perf memory snapshot --kind must be android-hprof or memgraph",t5=tW.is,t3=tK.is,t8=tJ.is,t4=tX.is,t6=tY.is,t9="https://github.com/callstackincubator/agent-device/issues/558",t7="https://github.com/callstackincubator/agent-device/issues/new";function re(...e){return e}let rt=re("snapshotInteractiveOnly","snapshotDepth","snapshotScope","snapshotRaw"),rr=re("snapshotDepth","snapshotScope","snapshotRaw"),rn=re("metroProjectRoot","kind","metroKind","metroPublicBaseUrl","metroProxyBaseUrl","metroBearerToken","metroPreparePort","metroListenHost","metroStatusHost","metroStartupTimeoutMs","metroProbeTimeoutMs","metroRuntimeFile","metroNoReuseExisting","metroNoInstallDeps"),ri=re("metroHost","metroPort","bundleUrl"),ra=re("count","intervalMs","holdMs","jitterPx","doubleTap"),ro=re("replayUpdate","replayEnv"),rs=[{key:"config",names:["--config"],type:"string",usageLabel:"--config <path>",usageDescription:"Load CLI defaults from a specific config file"},{key:"remoteConfig",names:["--remote-config"],type:"string",usageLabel:"--remote-config <path>",usageDescription:"Load remote host + Metro workflow settings from a specific profile file"},{key:"stateDir",names:["--state-dir"],type:"string",usageLabel:"--state-dir <path>",usageDescription:"Daemon state directory (defaults to ~/.agent-device for packages, or a worktree-scoped dev dir from source)"},{key:"daemonBaseUrl",names:["--daemon-base-url"],type:"string",usageLabel:"--daemon-base-url <url>",usageDescription:"Explicit remote HTTP daemon base URL (skip local daemon discovery/startup)"},{key:"daemonAuthToken",names:["--daemon-auth-token"],type:"string",usageLabel:"--daemon-auth-token <token>",usageDescription:"Remote HTTP daemon auth token (sent as request token and bearer header)"},{key:"daemonTransport",names:["--daemon-transport"],type:"enum",enumValues:["auto","socket","http"],usageLabel:"--daemon-transport auto|socket|http",usageDescription:"Daemon client transport preference"},{key:"daemonServerMode",names:["--daemon-server-mode"],type:"enum",enumValues:["socket","http","dual"],usageLabel:"--daemon-server-mode socket|http|dual",usageDescription:"Daemon server mode used when spawning daemon"},{key:"tenant",names:["--tenant"],type:"string",usageLabel:"--tenant <id>",usageDescription:"Tenant scope identifier for isolated daemon sessions"},{key:"sessionIsolation",names:["--session-isolation"],type:"enum",enumValues:["none","tenant"],usageLabel:"--session-isolation none|tenant",usageDescription:"Session isolation strategy (tenant prefixes session namespace)"},{key:"runId",names:["--run-id"],type:"string",usageLabel:"--run-id <id>",usageDescription:"Run identifier used for tenant lease admission checks"},{key:"leaseId",names:["--lease-id"],type:"string",usageLabel:"--lease-id <id>",usageDescription:"Lease identifier bound to tenant/run admission scope"},{key:"leaseBackend",names:["--lease-backend"],type:"enum",enumValues:["ios-simulator","ios-instance","android-instance"],usageLabel:"--lease-backend ios-simulator|ios-instance|android-instance",usageDescription:"Lease backend for remote tenant connection admission"},{key:"force",names:["--force"],type:"boolean",usageLabel:"--force",usageDescription:"Force connection state replacement when reconnecting"},{key:"noLogin",names:["--no-login"],type:"boolean",usageLabel:"--no-login",usageDescription:"Connect: fail instead of starting implicit cloud login"},{key:"sessionLock",names:["--session-lock"],type:"enum",enumValues:["reject","strip"],usageLabel:"--session-lock reject|strip",usageDescription:"Lock bound-session device routing for this CLI invocation and nested batch steps"},{key:"sessionLocked",names:["--session-locked"],type:"boolean",usageLabel:"--session-locked",usageDescription:"Deprecated alias for --session-lock reject"},{key:"sessionLockConflicts",names:["--session-lock-conflicts"],type:"enum",enumValues:["reject","strip"],usageLabel:"--session-lock-conflicts reject|strip",usageDescription:"Deprecated alias for --session-lock"},{key:"platform",names:["--platform"],type:"enum",enumValues:["ios","macos","android","linux","apple"],usageLabel:"--platform ios|macos|android|linux|apple",usageDescription:"Platform to target (`apple` aliases the Apple automation backend)"},{key:"target",names:["--target"],type:"enum",enumValues:["mobile","tv","desktop"],usageLabel:"--target mobile|tv|desktop",usageDescription:"Device target class to match"},{key:"device",names:["--device"],type:"string",usageLabel:"--device <name>",usageDescription:"Device name to target"},{key:"udid",names:["--udid"],type:"string",usageLabel:"--udid <udid>",usageDescription:"iOS device UDID"},{key:"serial",names:["--serial"],type:"string",usageLabel:"--serial <serial>",usageDescription:"Android device serial"},{key:"surface",names:["--surface"],type:"enum",enumValues:tj,usageLabel:"--surface app|frontmost-app|desktop|menubar",usageDescription:"macOS session surface for open (defaults to app)"},{key:"headless",names:["--headless"],type:"boolean",usageLabel:"--headless",usageDescription:"Boot: launch Android emulator without a GUI window"},{key:"metroHost",names:["--metro-host"],type:"string",usageLabel:"--metro-host <host>",usageDescription:"Session-scoped Metro/debug host hint"},{key:"metroPort",names:["--metro-port"],type:"int",min:1,max:65535,usageLabel:"--metro-port <port>",usageDescription:"Session-scoped Metro/debug port hint"},{key:"metroProjectRoot",names:["--project-root"],type:"string",usageLabel:"--project-root <path>",usageDescription:"metro prepare: React Native project root (default: cwd)"},{key:"kind",names:["--kind"],type:"enum",enumValues:["auto","react-native","expo",...tH],usageLabel:"--kind <kind>",usageDescription:"Kind selector for commands that support it, such as metro prepare or perf artifact collectors"},{key:"perfTemplate",names:["--template"],type:"string",usageLabel:"--template <name>",usageDescription:"Perf xctrace template name, for example Time Profiler"},{key:"metroKind",names:["--metro-kind"],type:"enum",enumValues:["auto","react-native","expo"],usageLabel:"--metro-kind auto|react-native|expo",usageDescription:"metro prepare: detect or force the Metro launcher kind"},{key:"metroPublicBaseUrl",names:["--public-base-url"],type:"string",usageLabel:"--public-base-url <url>",usageDescription:"metro prepare: public base URL used for direct bundle hints"},{key:"metroProxyBaseUrl",names:["--proxy-base-url"],type:"string",usageLabel:"--proxy-base-url <url>",usageDescription:"metro prepare: optional bridge origin for remote Metro access"},{key:"metroBearerToken",names:["--bearer-token"],type:"string",usageLabel:"--bearer-token <token>",usageDescription:"metro prepare: host bridge bearer token (or AGENT_DEVICE_METRO_BEARER_TOKEN; falls back to AGENT_DEVICE_DAEMON_AUTH_TOKEN)"},{key:"metroPreparePort",names:["--port"],type:"int",min:1,max:65535,usageLabel:"--port <port>",usageDescription:"metro prepare: local Metro port (default: 8081)"},{key:"metroListenHost",names:["--listen-host"],type:"string",usageLabel:"--listen-host <host>",usageDescription:"metro prepare: host Metro listens on (default: 0.0.0.0)"},{key:"metroStatusHost",names:["--status-host"],type:"string",usageLabel:"--status-host <host>",usageDescription:"metro prepare: host used for local /status polling (default: 127.0.0.1)"},{key:"metroStartupTimeoutMs",names:["--startup-timeout-ms"],type:"int",min:1,usageLabel:"--startup-timeout-ms <ms>",usageDescription:"metro prepare: timeout while waiting for Metro to become ready"},{key:"metroProbeTimeoutMs",names:["--probe-timeout-ms"],type:"int",min:1,usageLabel:"--probe-timeout-ms <ms>",usageDescription:"metro prepare: timeout for /status and proxy bridge calls"},{key:"metroRuntimeFile",names:["--runtime-file"],type:"string",usageLabel:"--runtime-file <path>",usageDescription:"metro prepare: optional file path to persist the JSON result"},{key:"metroNoReuseExisting",names:["--no-reuse-existing"],type:"boolean",usageLabel:"--no-reuse-existing",usageDescription:"metro prepare: always start a fresh Metro process"},{key:"metroNoInstallDeps",names:["--no-install-deps"],type:"boolean",usageLabel:"--no-install-deps",usageDescription:"metro prepare: skip package-manager install when node_modules is missing"},{key:"bundleUrl",names:["--bundle-url"],type:"string",usageLabel:"--bundle-url <url>",usageDescription:"Session-scoped bundle URL hint"},{key:"launchUrl",names:["--launch-url"],type:"string",usageLabel:"--launch-url <url>",usageDescription:"Session-scoped deep link / launch URL hint"},{key:"iosSimulatorDeviceSet",names:["--ios-simulator-device-set"],type:"string",usageLabel:"--ios-simulator-device-set <path>",usageDescription:"Scope iOS simulator discovery/commands to this simulator device set"},{key:"deviceHub",names:["--device-hub"],type:"boolean",usageLabel:"--device-hub",usageDescription:"open: use Xcode Device Hub when surfacing Apple simulators"},{key:"androidDeviceAllowlist",names:["--android-device-allowlist"],type:"string",usageLabel:"--android-device-allowlist <serials>",usageDescription:"Comma/space separated Android serial allowlist for discovery/selection"},{key:"activity",names:["--activity"],type:"string",usageLabel:"--activity <component>",usageDescription:"Android app launch activity (package/Activity); not for URL opens"},{key:"launchConsole",names:["--launch-console"],type:"string",usageLabel:"--launch-console <path>",usageDescription:"open: capture the initial iOS simulator launch console window to a file"},{key:"launchArgs",names:["--launch-args"],type:"string",multiple:!0,usageLabel:"--launch-args <arg>",usageDescription:"open: repeatable launch argument forwarded verbatim to the platform launch command (iOS app process args; Android adb shell am start args). Linux and macOS reject the flag."},{key:"header",names:["--header"],type:"string",multiple:!0,usageLabel:"--header <name:value>",usageDescription:"install-from-source: repeatable HTTP header for URL downloads"},{key:"githubActionsArtifact",names:["--github-actions-artifact"],type:"string",usageLabel:"--github-actions-artifact <owner/repo:artifact>",usageDescription:"install-from-source: GitHub Actions artifact resolved by a remote daemon"},{key:"installSource",names:[],type:"string"},{key:"session",names:["--session"],type:"string",usageLabel:"--session <name>",usageDescription:"Named session"},{key:"count",names:["--count"],type:"int",min:1,max:200,usageLabel:"--count <n>",usageDescription:"Repeat count for press/swipe series"},{key:"fps",names:["--fps"],type:"int",min:1,max:120,usageLabel:"--fps <n>",usageDescription:"Record: target frames per second (iOS physical device runner)"},{key:"quality",names:["--quality"],type:"int",min:5,max:10,usageLabel:"--quality <5-10>",usageDescription:"Record: scale recording resolution from 5 (50%) through 10 (native resolution)"},{key:"hideTouches",names:["--hide-touches"],type:"boolean",usageLabel:"--hide-touches",usageDescription:"Record: skip touch-overlay post-processing for faster raw benchmark videos"},{key:"intervalMs",names:["--interval-ms"],type:"int",min:0,max:1e4,usageLabel:"--interval-ms <ms>",usageDescription:"Delay between press iterations"},{key:"delayMs",names:["--delay-ms"],type:"int",min:0,max:1e4,usageLabel:"--delay-ms <ms>",usageDescription:"Delay between typed characters"},{key:"holdMs",names:["--hold-ms"],type:"int",min:0,max:1e4,usageLabel:"--hold-ms <ms>",usageDescription:"Press hold duration for each iteration"},{key:"jitterPx",names:["--jitter-px"],type:"int",min:0,max:100,usageLabel:"--jitter-px <n>",usageDescription:"Deterministic coordinate jitter radius for press"},{key:"pixels",names:["--pixels"],type:"int",min:1,max:1e5,usageLabel:"--pixels <n>",usageDescription:"Scroll: explicit gesture distance in pixels"},{key:"doubleTap",names:["--double-tap"],type:"boolean",usageLabel:"--double-tap",usageDescription:"Use double-tap gesture per press iteration"},{key:"clickButton",names:["--button"],type:"enum",enumValues:["primary","secondary","middle"],usageLabel:"--button primary|secondary|middle",usageDescription:"Click: choose mouse button (middle reserved for future macOS support)"},{key:"backMode",names:["--in-app"],type:"enum",enumValues:["in-app","system"],setValue:"in-app",usageLabel:"--in-app",usageDescription:"Back: use app-provided back UI when available"},{key:"backMode",names:["--system"],type:"enum",enumValues:["in-app","system"],setValue:"system",usageLabel:"--system",usageDescription:"Back: use system back input or gesture when available"},{key:"pauseMs",names:["--pause-ms"],type:"int",min:0,max:1e4,usageLabel:"--pause-ms <ms>",usageDescription:"Delay between swipe iterations"},{key:"pattern",names:["--pattern"],type:"enum",enumValues:["one-way","ping-pong"],usageLabel:"--pattern one-way|ping-pong",usageDescription:"Swipe repeat pattern"},{key:"verbose",names:["--debug","--verbose","-v"],type:"boolean",usageLabel:"--debug, --verbose, -v",usageDescription:"Enable debug diagnostics; test --verbose prints per-test step timings without debug logs"},{key:"json",names:["--json"],type:"boolean",usageLabel:"--json",usageDescription:"JSON output"},{key:"help",names:["--help","-h"],type:"boolean",usageLabel:"--help, -h",usageDescription:"Print help and exit"},{key:"version",names:["--version","-V"],type:"boolean",usageLabel:"--version, -V",usageDescription:"Print version and exit"},{key:"snapshotDiff",names:["--diff"],type:"boolean",usageLabel:"--diff",usageDescription:"Snapshot: show structural diff against the previous session baseline"},{key:"saveScript",names:["--save-script"],type:"booleanOrString",usageLabel:"--save-script [path]",usageDescription:"Save session script (.ad) on close; optional custom output path"},{key:"networkInclude",names:["--include"],type:"enum",enumValues:["summary","headers","body","all"],usageLabel:"--include summary|headers|body|all",usageDescription:"Network: include headers, bodies, or both in output"},{key:"shutdown",names:["--shutdown"],type:"boolean",usageLabel:"--shutdown",usageDescription:"close: shutdown associated simulator/emulator after ending session"},{key:"relaunch",names:["--relaunch"],type:"boolean",usageLabel:"--relaunch",usageDescription:"open: terminate app process before launching it"},{key:"restart",names:["--restart"],type:"boolean",usageLabel:"--restart",usageDescription:"logs clear: stop active stream, clear logs, then start streaming again"},{key:"retainPaths",names:["--retain-paths"],type:"boolean",usageLabel:"--retain-paths",usageDescription:"install-from-source: keep materialized artifact paths after install"},{key:"retentionMs",names:["--retention-ms"],type:"int",min:1,usageLabel:"--retention-ms <ms>",usageDescription:"install-from-source: retention TTL for materialized artifact paths"},{key:"noRecord",names:["--no-record"],type:"boolean",usageLabel:"--no-record",usageDescription:"Do not record this action"},{key:"replayUpdate",names:["--update","-u"],type:"boolean",usageLabel:"--update, -u",usageDescription:"Replay: update selectors and rewrite replay file in place"},{key:"replayMaestro",names:["--maestro"],type:"boolean",usageLabel:"--maestro",usageDescription:`Replay: treat input as a Maestro YAML compatibility flow. Supported subset: ${(e=["app launch with Apple-platform launch arguments and Android/iOS simulator clearState","runFlow file/inline with when.platform, when.visible, when.notVisible, and limited when.true boolean/platform expressions","onFlowStart and onFlowComplete hooks","deterministic repeat.times","tapOn including optional, index, childOf, label, and absolute/percentage point taps","doubleTapOn and longPressOn","inputText, focused-field eraseText, and pasteText","openLink","visibility assertions and extendedWaitUntil","scroll and scrollUntilVisible","absolute/percentage swipe and swipe.label","screenshots","keyboard dismiss","basic pressKey, back, animation waits, and stopApp","ordered trusted runScript file/env scripts with http.post, json, and output variables"]).length>1?`${e.slice(0,-1).join(", ")}, and ${e.at(-1)}`:e[0]??""}. Unsupported syntax fails loudly with a link to ${t9}`},{key:"replayExportFormat",names:["--format"],type:"enum",enumValues:["maestro"],usageLabel:"--format maestro",usageDescription:"Replay export: output format"},{key:"replayEnv",names:["-e","--env"],type:"string",multiple:!0,usageLabel:"-e KEY=VALUE, --env KEY=VALUE",usageDescription:"Replay/Test: inject or override a ${KEY} variable for the script (repeatable)"},{key:"failFast",names:["--fail-fast"],type:"boolean",usageLabel:"--fail-fast",usageDescription:"Test: stop the suite after the first failing script; with sharding, each shard stops independently"},{key:"timeoutMs",names:["--timeout"],type:"int",min:1,usageLabel:"--timeout <ms>",usageDescription:"Prepare/Replay/Snapshot/Test: maximum wall-clock time for the command or attempt"},{key:"retries",names:["--retries"],type:"int",min:0,max:3,usageLabel:"--retries <n>",usageDescription:"Test: retry each failed script up to n additional times"},{key:"recordVideo",names:["--record-video"],type:"boolean",usageLabel:"--record-video",usageDescription:"Test: record each replay attempt to recording.mp4 in its attempt artifacts"},{key:"artifactsDir",names:["--artifacts-dir"],type:"string",usageLabel:"--artifacts-dir <path>",usageDescription:"Test: root directory for suite artifacts"},{key:"reportJunit",names:["--report-junit"],type:"string",usageLabel:"--report-junit <path>",usageDescription:"Test: write a JUnit XML report for the replay suite"},{key:"shardAll",names:["--shard-all"],type:"int",min:1,usageLabel:"--shard-all <n>",usageDescription:"Test: run the full suite on each of n devices; AD_SHARD_INDEX is zero-based"},{key:"shardSplit",names:["--shard-split"],type:"int",min:1,usageLabel:"--shard-split <n>",usageDescription:"Test: split runnable suite entries across n devices; AD_SHARD_INDEX is zero-based"},{key:"steps",names:["--steps"],type:"string",usageLabel:"--steps <json>",usageDescription:"Batch: JSON array of steps"},{key:"stepsFile",names:["--steps-file"],type:"string",usageLabel:"--steps-file <path>",usageDescription:"Batch: read steps JSON from file"},{key:"batchOnError",names:["--on-error"],type:"enum",enumValues:["stop"],usageLabel:"--on-error stop",usageDescription:"Batch: stop when a step fails"},{key:"batchMaxSteps",names:["--max-steps"],type:"int",min:1,max:1e3,usageLabel:"--max-steps <n>",usageDescription:"Batch: maximum number of allowed steps"},{key:"appsFilter",names:["--all"],type:"enum",enumValues:["user-installed","all"],setValue:"all",usageLabel:"--all",usageDescription:"Apps: include system/OEM apps"},{key:"snapshotInteractiveOnly",names:["-i"],type:"boolean",usageLabel:"-i",usageDescription:"Snapshot: interactive elements only"},{key:"snapshotDepth",names:["--depth","-d"],type:"int",min:0,usageLabel:"--depth, -d <depth>",usageDescription:"Snapshot: limit snapshot depth"},{key:"snapshotScope",names:["--scope","-s"],type:"string",usageLabel:"--scope, -s <scope>",usageDescription:"Snapshot: scope snapshot to label/identifier"},{key:"snapshotRaw",names:["--raw"],type:"boolean",usageLabel:"--raw",usageDescription:"Snapshot: raw node output"},{key:"snapshotForceFull",names:["--force-full"],type:"boolean",usageLabel:"--force-full",usageDescription:"Snapshot: re-emit the full tree even when unchanged"},{key:"findFirst",names:["--first"],type:"boolean",usageLabel:"--first",usageDescription:"Find: pick the first match when ambiguous"},{key:"findLast",names:["--last"],type:"boolean",usageLabel:"--last",usageDescription:"Find: pick the last match when ambiguous"},{key:"out",names:["--out"],type:"string",usageLabel:"--out <path>",usageDescription:"Output path"},{key:"artifact",names:["--artifact"],type:"string",usageLabel:"--artifact <path>",usageDescription:"Debug symbols: Apple crash artifact path (.ips, .crash, or .log)"},{key:"dsym",names:["--dsym"],type:"string",usageLabel:"--dsym <path>",usageDescription:"Debug symbols: matching .dSYM bundle path"},{key:"searchPath",names:["--search-path"],type:"string",usageLabel:"--search-path <dir>",usageDescription:"Debug symbols: directory to scan for matching .dSYM bundles"},{key:"overlayRefs",names:["--overlay-refs"],type:"boolean",usageLabel:"--overlay-refs",usageDescription:"Screenshot: draw current snapshot refs and target rectangles onto the saved PNG; diff screenshot: also write a separate current-screen overlay guide"},{key:"screenshotFullscreen",names:["--fullscreen"],type:"boolean",usageLabel:"--fullscreen",usageDescription:"Screenshot: capture the full screen instead of the app window"},{key:"screenshotMaxSize",names:["--max-size"],type:"int",min:1,usageLabel:"--max-size <px>",usageDescription:"Screenshot: downscale so the longest edge is at most <px>"},{key:"screenshotNoStabilize",names:["--no-stabilize"],type:"boolean",usageLabel:"--no-stabilize",usageDescription:"Screenshot: skip Android demo-mode/status-bar stabilization and settle delay for low-latency capture loops"},{key:"baseline",names:["--baseline","-b"],type:"string",usageLabel:"--baseline, -b <path>",usageDescription:"Diff screenshot: path to baseline image file"},{key:"threshold",names:["--threshold"],type:"string",usageLabel:"--threshold <0-1>",usageDescription:"Diff screenshot: color distance threshold (default 0.1)"}],rl=new Set(["json","config","remoteConfig","stateDir","daemonBaseUrl","daemonAuthToken","daemonTransport","daemonServerMode","tenant","sessionIsolation","runId","leaseId","leaseBackend","sessionLock","sessionLocked","sessionLockConflicts","help","version","verbose","platform","target","device","udid","serial","iosSimulatorDeviceSet","androidDeviceAllowlist","session","noRecord"]),ru=new Map;for(let e of rs)for(let t of e.names)ru.set(t,e);function rc(e){return ru.get(e)}function rp(){return rs}function rd(e,t,r){return{name:e,description:t,inputSchema:B(r),readInput:e=>H(e,r)}}let rm=["duration","text","ref","selector"],rf="<wifi|airplane|location> <on|off>",rh="location set <lat> <lon>",rg="animations <on|off>",ry="appearance <light|dark|toggle>",rb="faceid <match|nonmatch|enroll|unenroll>",rw="touchid <match|nonmatch|enroll|unenroll>",rv="fingerprint <match|nonmatch>",rx="clear-app-state [app-id]",rS="permission <grant|deny|reset> <camera|microphone|photos|contacts|contacts-limited|notifications|calendar|location|location-always|media-library|motion|reminders|siri> [full|limited]",rk="permission <grant|reset> <accessibility|screen-recording|input-monitoring>",rA=`macOS supports only settings ${ry} and settings ${rk}. wifi|airplane|location|animations remain unsupported on macOS.`,rD=`settings ${rf} | settings ${rh} | settings ${rg} | settings ${ry} | settings ${rb} | settings ${rw} | settings ${rv} | settings ${rx} | settings ${rS} | settings ${rk}`,rI=`settings requires ${rf}, ${rh}, ${rg}, ${ry}, ${rb}, ${rw}, ${rv}, ${rx}, ${rS}, or ${rk}`;function rM(e){let t=e.trim().toLowerCase();return"appearance"===t||"permission"===t}function rL(e){return`Unsupported macOS setting: ${e}. ${rA}`}function rN(e,t){if(void 0===e||""===e.trim())throw new y("INVALID_ARGS",`settings location set requires ${t}`);return rO(Number(e),t)}function rR(e){return{latitude:rO(e?.latitude,"latitude"),longitude:rO(e?.longitude,"longitude")}}function rO(e,t){let r="latitude"===t?-90:-180,n="latitude"===t?90:180;if("number"!=typeof e||!Number.isFinite(e)||e<r||e>n)throw new y("INVALID_ARGS",`${t} must be a number from ${r} to ${n}`);return e}let rE="settings",rP=rd(rE,"Change OS settings and app permissions.",{setting:P(_()),state:P(_()),app:_(),latitude:C(),longitude:C(),permission:_(),mode:F(["full","limited"])}),r_=eP(rP,(e,t)=>e.settings.update(t)),rC=em(S.settings,e=>{var t;return"clear-app-state"===(t=e).setting?[t.setting,...eN(t.app)]:"location"===t.setting&&"set"===t.state?[t.setting,t.state,String(t.latitude),String(t.longitude)]:"permission"===t.setting?[t.setting,t.state,t.permission,...eN(t.mode)]:[t.setting,t.state]}),rT=eD("wifi","airplane","location","animations"),r$=eD("on","off"),rF=eD("light","dark","toggle"),rU=eD("faceid","touchid"),rj=eD("match","nonmatch","enroll","unenroll"),rV=eD("match","nonmatch"),rq=eD("grant","deny","reset"),rG=eD("camera","microphone","photos","contacts","contacts-limited","notifications","calendar","location","location-always","media-library","motion","reminders","siri","accessibility","screen-recording","input-monitoring"),rz="snapshot",rB="screenshot",rH="diff",rW="wait",rK="alert",rJ=rd(rz,"Capture an accessibility snapshot.",{interactiveOnly:$(),depth:T(),scope:_(),raw:$(),forceFull:$(),timeoutMs:T("Maximum wall-clock time for the snapshot command.")}),rX=rd(rB,"Capture a screenshot.",{path:_("Output path."),overlayRefs:$(),fullscreen:$(),maxSize:T(),stabilize:$(),surface:F(tj)}),rY=rd(rH,"Diff accessibility snapshots.",{kind:P(j({type:"string",const:"snapshot"})),out:_(),interactiveOnly:$(),depth:T(),scope:_(),raw:$()}),rQ=rd(rW,"Wait for duration, text, ref, or selector.",{kind:F(rm),durationMs:T(),text:_(),ref:_(),selector:_(),timeoutMs:T(),depth:T(),scope:_(),raw:$()}),rZ=rd(rK,"Inspect or handle platform alerts.",{action:F(["get","accept","dismiss","wait"]),timeoutMs:T()}),r0=[rJ,rX,rY,rQ,rZ,rP],r1=[eP(rJ,(e,t)=>e.capture.snapshot(t)),eP(rX,(e,t)=>e.capture.screenshot(t)),eP(rY,(e,t)=>e.capture.diff(t)),eP(rQ,(e,t)=>{var r;let n;return e.command.wait((en(r=t,"kind",rm),n={...r},delete n.kind,n))}),eP(rZ,(e,t)=>e.command.alert(t)),r_],r2={[rz]:{usageOverride:"snapshot [--diff] [-i] [-d <depth>] [-s <scope>] [--raw] [--force-full] [--timeout <ms>]",helpDescription:"Capture accessibility tree or diff against the previous session baseline",allowedFlags:["snapshotDiff",...rt,"snapshotForceFull","timeoutMs"]},[rB]:{helpDescription:"Capture screenshot (macOS app sessions default to the app window; use --fullscreen for full desktop, --max-size to downscale, --overlay-refs to annotate current refs, or --no-stabilize for low-latency Android capture loops)",positionalArgs:["path?"],allowedFlags:["out","overlayRefs","screenshotFullscreen","screenshotMaxSize","screenshotNoStabilize"]},[rH]:{usageOverride:"diff snapshot | diff screenshot --baseline <path> [current.png] [--out <diff.png>] [--threshold <0-1>] [--overlay-refs]",helpDescription:"Diff accessibility snapshot or compare screenshots pixel-by-pixel",summary:"Diff snapshot or screenshot",positionalArgs:["kind","current?"],allowedFlags:[...rt,"baseline","threshold","out","overlayRefs"]},[rW]:{usageOverride:"wait <ms>|text <text>|@ref|<selector> [timeoutMs]",positionalArgs:["durationOrSelector","timeoutMs?"],allowsExtraPositionals:!0,allowedFlags:[...rr]},[rK]:{usageOverride:"alert [get|accept|dismiss|wait] [timeout]",positionalArgs:["action?","timeout?"]},[rE]:{usageOverride:rD,listUsageOverride:"settings [area] [options]",helpDescription:"Toggle OS settings, animation scales, appearance, and app permissions (macOS supports only settings appearance <light|dark|toggle> and settings permission <grant|reset> <accessibility|screen-recording|input-monitoring>; wifi|airplane|location|animations remain unsupported on macOS; mobile permission actions use the active session app)",summary:"Change OS settings and app permissions",positionalArgs:["setting","state","target?","mode?"]}},r5={snapshot:(e,t)=>({...eh(t),interactiveOnly:t.snapshotInteractiveOnly,depth:t.snapshotDepth,scope:t.snapshotScope,raw:t.snapshotRaw,forceFull:t.snapshotForceFull,timeoutMs:t.timeoutMs}),screenshot:(e,t)=>({...eh(t),path:e[0]??t.out,...eC(t)}),diff:(e,t)=>{if("snapshot"!==e[0])throw new y("INVALID_ARGS","Only diff snapshot is available through this parser.");return{...eh(t),kind:"snapshot",out:t.out,interactiveOnly:t.snapshotInteractiveOnly,depth:t.snapshotDepth,scope:t.snapshotScope,raw:t.snapshotRaw}},wait:(e,t)=>(function(e,t){let r=tT(e);if(!r)throw new y("INVALID_ARGS","wait requires <ms>, text <text>, @ref, or <selector> [timeoutMs].");let n={...eg(t),...eb(t)};if("sleep"===r.kind)return{...n,durationMs:r.durationMs};if("text"===r.kind){if(!r.text)throw new y("INVALID_ARGS","wait requires text.");return{...n,text:r.text,...r8(r.timeoutMs)}}return"ref"===r.kind?{...n,ref:r.rawRef,...r8(r.timeoutMs)}:{...n,selector:r.selectorExpression,...r8(r.timeoutMs)}})(e,t),alert:(e,t)=>({...eh(t),...function(e){if(e.length>2)throw new y("INVALID_ARGS","alert accepts at most action and timeout arguments.");return el({action:function(e){let t=e?.toLowerCase();if(void 0===t||"get"===t||"accept"===t||"dismiss"===t||"wait"===t)return t;throw new y("INVALID_ARGS","alert action must be get, accept, dismiss, or wait.")}(e[0]),timeoutMs:function(e,t){if(void 0===e)return;let r=Number(e);if(Number.isFinite(r))return r;throw new y("INVALID_ARGS",`${t} must be a finite number.`)}(e[1],"alert timeout")})}(e)}),settings:(e,t)=>(function(e,t){let r=eg(t),n=e[0],i=e[1];if(eI(n,rT)&&eI(i,r$))return{...r,setting:n,state:i};if("location"===n&&"set"===i)return{...r,setting:n,state:i,latitude:rN(e[2],"latitude"),longitude:rN(e[3],"longitude")};if("appearance"===n&&eI(i,rF)||eI(n,rU)&&eI(i,rj)||"fingerprint"===n&&eI(i,rV))return{...r,setting:n,state:i};if("permission"===n&&eI(i,rq))return{...r,setting:n,state:i,permission:function(e){if(eI(e,rG))return e;throw new y("INVALID_ARGS","settings permission requires a permission target.")}(e[2]),mode:function(e){if(void 0===e||"full"===e||"limited"===e)return e;throw new y("INVALID_ARGS","settings permission mode must be full or limited.")}(e[3])};if("clear-app-state"===n){let t="clear"===i?e[2]:i;return{...r,setting:n,state:"clear",app:t}}throw new y("INVALID_ARGS","Invalid settings arguments.")})(e,t)};r5.snapshot,r5.screenshot,r5.diff,r5.wait,r5.alert,r5.settings;let r3={snapshot:em(S.snapshot),screenshot:e=>ef(S.screenshot,eN(e.path),{...e,...eT(e)}),diff:em(S.diff,e=>[eE(e.kind,"diff requires kind")]),wait:em(S.wait,e=>(function(e){if(1!==[void 0!==e.durationMs?"durationMs":void 0,void 0!==e.text?"text":void 0,void 0!==e.ref?"ref":void 0,void 0!==e.selector?"selector":void 0].filter(Boolean).length)throw new y("INVALID_ARGS","wait command requires exactly one of durationMs, text, ref, or selector.");if(void 0!==e.durationMs)return[String(e.durationMs)];let t=eR(e.timeoutMs);if(void 0!==e.text)return["text",e.text,...t];if(void 0!==e.ref)return[e.ref,...t];let r=e.selector;if(!u(r))throw new y("INVALID_ARGS",`Invalid wait selector: ${r}`);return[r,...t]})(e)),alert:em(S.alert,e=>{var t;return[(t=e).action??"get",...eR(t.timeoutMs)]}),settings:rC};function r8(e){return null===e?{}:{timeoutMs:e}}function r4(e){return e?.clickButton??"primary"}function r6(e){return"primary"===e.button?null:"click"!==e.commandLabel?new y("INVALID_ARGS","--button is supported only for click"):"macos"!==e.platform&&"linux"!==e.platform?new y("UNSUPPORTED_OPERATION",`click --button ${e.button} is supported only on macOS and Linux`):"macos"===e.platform&&"middle"===e.button?new y("UNSUPPORTED_OPERATION","click --button middle is not supported by the macOS runner yet"):"number"==typeof e.count||"number"==typeof e.intervalMs||"number"==typeof e.holdMs||"number"==typeof e.jitterPx||!0===e.doubleTap?new y("INVALID_ARGS",`click --button ${e.button} does not support repeat or gesture modifier flags`):null}function r9(e){return"primary"===e?{}:{button:e}}r3.screenshot,r3.wait,r3.alert,r3.settings;let r7=["up","down","left","right"],ne=["left","right","left-edge","right-edge"],nt=["one-way","ping-pong"],nr=tU(ne,{message:"gesture swipe requires left, right, left-edge, or right-edge"}),nn=tU(r7,{message:e=>`Unknown direction: ${e}`});function ni(e){let t=e.direction,r="up"===t||"down"===t?e.referenceHeight:e.referenceWidth,n=nf(e.amount),i=void 0!==e.pixels?nh(e.pixels):Math.round(r*n),a=Math.max(1,Math.round(.05*r)),o=Math.max(1,Math.min(i,Math.max(1,r-2*a))),s=Math.round(o/2),l=Math.round(e.referenceWidth/2),u=Math.round(e.referenceHeight/2),c=(r,n,i,a)=>({direction:t,x1:r,y1:n,x2:i,y2:a,referenceWidth:e.referenceWidth,referenceHeight:e.referenceHeight,amount:e.amount,pixels:o});switch(t){case"up":return c(l,u-s,l,u+s);case"down":return c(l,u+s,l,u-s);case"left":return c(l-s,u,l+s,u);case"right":return c(l+s,u,l-s,u)}}function na(e){nf(e.amount),void 0!==e.pixels&&nh(e.pixels)}function no(e){return{...ni({...e,direction:function(e){switch(e){case"up":return"down";case"down":return"up";case"left":return"right";case"right":return"left"}}(e.direction)}),direction:e.direction}}function ns(e,t,r={}){let n=r.marginPx??8,[i,a,o]="left"===e?[85,15,50]:"right"===e?[15,85,50]:"left-edge"===e?[99,15,50]:[1,85,50],s=nc(t,i,o,{marginPx:n}),l=nc(t,a,o,{marginPx:n});return{preset:e,x1:s.x,y1:s.y,x2:l.x,y2:l.y,referenceWidth:t.referenceWidth,referenceHeight:t.referenceHeight}}function nl(e){return nr.parse(e)}function nu(e){let t=function(e){let t=e.filter(e=>(function(e){if(!e)return!1;let t=e.toLowerCase();return t.includes("application")||t.includes("window")})(e.type)&&nm(e.rect)).map(e=>e.rect).sort((e,t)=>(t?.width??0)*(t?.height??0)-(e?.width??0)*(e?.height??0))[0];if(t)return t;let r=e.map(e=>e.rect).filter(nm);if(0===r.length)return;let n=Math.max(...r.map(e=>e.x+e.width)),i=Math.max(...r.map(e=>e.y+e.height));if(!(n<=0)&&!(i<=0))return{x:0,y:0,width:n,height:i}}(e);if(t)return{referenceWidth:t.width,referenceHeight:t.height}}function nc(e,t,r,n={}){let i={x:Math.round(e.referenceWidth*t/100),y:Math.round(e.referenceHeight*r/100)};return void 0===n.marginPx?i:np(i,e,n.marginPx)}function np(e,t,r){return{x:ng(e.x,r,t.referenceWidth),y:ng(e.y,r,t.referenceHeight)}}function nd(e){return nn.parse(e)}function nm(e){return!!e&&e.width>0&&e.height>0}function nf(e){if(void 0===e)return .6;if(!Number.isFinite(e)||e<=0)throw new y("INVALID_ARGS","scroll amount must be a positive number");return e}function nh(e){if(!Number.isFinite(e)||e<=0)throw new y("INVALID_ARGS","scroll pixels must be a positive integer");return Math.max(1,Math.round(e))}function ng(e,t,r){let n=Math.max(t,r-t);return ny(e,t,n)}function ny(e,t,r){return Math.min(Math.round(r),Math.max(Math.round(t),Math.round(e)))}function nb(e,t,r,n){if(!Number.isFinite(e)||!Number.isInteger(e)||e<r||e>n)throw new y("INVALID_ARGS",`${t} must be an integer between ${r} and ${n}`);return e}function nw(e,t,r){return t>=e.x&&t<=e.x+e.width&&r>=e.y&&r<=e.y+e.height}function nv(e){let t=null,r=-1;for(let n of e){let e=n.width*n.height;e>r&&(t=n,r=e)}return t}function nx(e,t,r,n){return Math.max(e,r)<=Math.min(t,n)}function nS(e){let t=e.trim().toLowerCase();return!!t&&/^(vertical|horizontal)\s+scroll\s+bar(?:,?\s*\d+\s+pages?)?$/.test(t)}function nk(e,t){if(!(e?.trim().toLowerCase()??"").includes("vertical scroll bar"))return null;let r=function(e){if(!e)return null;let t=/^(\d{1,3})%$/.exec(e.trim());if(!t)return null;let r=Number(t[1]);return Number.isFinite(r)?Math.max(0,Math.min(100,r)):null}(t);return null===r?null:r<=1?{above:!1,below:!0}:r>=99?{above:!0,below:!1}:{above:!0,below:!0}}function nA(e){let t=new Map;for(let[r,n]of e.entries())t.set(n.index,r);let r=[],n=[];for(let[i,a]of e.entries()){let e=Math.max(0,a.depth??0);for(;n.length>0&&e<=n[n.length-1].depth;)n.pop();let o="number"==typeof a.parentIndex?t.get(a.parentIndex):void 0,s="number"==typeof o&&o<i?o:n[n.length-1]?.index;r.push({...a,index:i,depth:e,parentIndex:s}),n.push({depth:e,index:i})}return r}function nD(e){return new Map(e.map(e=>[e.index,e]))}function nI(e){return e.label?.trim()||e.value?.trim()||e.identifier?.trim()||""}function nM(e){if(0===e.length)return{nodes:e,hiddenCount:0,summaryLines:[]};let{byIndex:t,visibleNodeIndexes:r,offscreenNodes:n,hintedContainers:i}=nN(e),a=0===r.size?e:e.filter(e=>r.has(e.index));return{nodes:a.map(e=>(function(e,t){let r=t.get(e.index);if(!r||0===r.size)return e;let n=!!(!0===e.hiddenContentAbove||r.has("above"))||void 0,i=!!(!0===e.hiddenContentBelow||r.has("below"))||void 0;return{...e,hiddenContentAbove:n,hiddenContentBelow:i}})(e,i.directionsByContainer)),hiddenCount:0===r.size?0:e.length-a.length,summaryLines:function(e,t,r){let n=new Map;for(let i of e){let e=function(e,t,r){if(!e.rect)return null;let n=nO(e,t,r);return n?nE(e.rect,n):null}(i,t,r);if(!e)continue;let a=n.get(e)??[];a.push(i),n.set(e,a)}return["above","below"].flatMap(e=>{let t=n.get(e);if(!t||0===t.length)return[];let r=(function(e){let t=new Set,r=[];for(let n of e){let e=nI(n);!e||t.has(e)||(t.add(e),r.push(e))}return r})(t).slice(0,3).map(e=>`"${e}"`),i=1===t.length?"interactive item":"interactive items",a=r.length>0?`: ${r.join(", ")}`:"";return[`[off-screen ${e}] ${t.length} ${i}${a}`]})}(n.filter(e=>!i.coveredNodeIndexes.has(e.index)&&function(e){if(!0===e.hittable)return!0;let t=(e.type??"").toLowerCase();return t.includes("button")||t.includes("link")||t.includes("textfield")||t.includes("edittext")||t.includes("searchfield")||t.includes("checkbox")||t.includes("radio")||t.includes("switch")||t.includes("menuitem")||!!nI(e)}(e)),e,t)}}function nL(e){if(0===e.length)return new Map;let{hintedContainers:t}=nN(e);var r=t.directionsByContainer;let n=new Map;for(let[e,t]of r){let r={};t.has("above")&&(r.hiddenContentAbove=!0),t.has("below")&&(r.hiddenContentBelow=!0),(r.hiddenContentAbove||r.hiddenContentBelow)&&n.set(e,r)}return n}function nN(e){let t=nD(e),r=new Set,n=[];for(let i of e){if(nR(i,e,t)){!function(e,t,r){let n=e,i=new Set;for(;n&&!i.has(n.index);)i.add(n.index),t.add(n.index),n="number"==typeof n.parentIndex?r.get(n.parentIndex):void 0}(i,r,t);continue}n.push(i)}let i=function(e,t,r,n){let i=new Map,a=new Map,o=new Set;for(let e of t){if(!e.rect)continue;let t=nP(e,r,n);if(!t?.rect)continue;let s=nE(e.rect,t.rect);if(!s)continue;let l=i.get(t.index)??new Set;l.add(s),i.set(t.index,l);let u=a.get(t.index)??new Set;u.add(s),a.set(t.index,u),o.add(e.index)}return function(e,t,r,n,i){for(let a of e){let e=function(e){let t=nk(e.label,e.value);if(!t)return null;let r=new Set;return t.above&&r.add("above"),t.below&&r.add("below"),r.size>0?r:null}(a);if(!e||0===e.size)continue;let o=nP(a,t,r);if(!o)continue;let s=n.get(o.index)??new Set,l=i.get(o.index);for(let t of e)(!l||!(l.size>0)||l.has(t))&&s.add(t);n.set(o.index,s)}}(e,r,n,i,a),{directionsByContainer:i,coveredNodeIndexes:o}}(e,n,r,t);return{byIndex:t,visibleNodeIndexes:r,offscreenNodes:n,hintedContainers:i}}function nR(e,t,r=nD(t)){var n;if(!e.rect)return!0;let i=nO(e,t,r);return!i||(n=e.rect,nx(n.x,n.x+n.width,i.x,i.x+i.width)&&nx(n.y,n.y+n.height,i.y,i.y+i.height))}function nO(e,t,r=nD(t)){var n,i;let o=(n=e,i=r,n_(n,i,e=>!!e.rect)?.rect??null);return o||function(e,t){let r=a(t),n=e.filter(e=>{var t;return!!(t=e.rect)&&Number.isFinite(t.x)&&Number.isFinite(t.y)&&Number.isFinite(t.width)&&Number.isFinite(t.height)}),i=n.filter(e=>{let t=(e.type??"").toLowerCase();return t.includes("application")||t.includes("window")}),o=nv(i.map(e=>e.rect).filter(e=>nw(e,r.x,r.y)));if(o)return o;let s=nv(i.map(e=>e.rect));if(s)return s;let l=nv(n.map(e=>e.rect).filter(e=>nw(e,r.x,r.y)));return l||null}(t,e.rect??{x:0,y:0,width:0,height:0})}function nE(e,t){return e.y+e.height<=t.y?"above":e.y>=t.y+t.height?"below":null}function nP(e,t,r){return n_(e,r,e=>t.has(e.index))}function n_(e,t,r){let n="number"==typeof e.parentIndex?t.get(e.parentIndex):void 0,i=new Set;for(;n&&!i.has(n.index);){if(i.add(n.index),r(n)&&A(n))return n;n="number"==typeof n.parentIndex?t.get(n.parentIndex):void 0}return null}async function nC(e){let{edge:t,target:r={},scope:n,captureNodes:i}=e;try{let e=await i(n),a=function(e,t,r={}){var n,i,a;let o,s=(e??[]).map((e,t)=>({...e,ref:"ref"in e&&e.ref?e.ref:`e${t+1}`}));if(0===s.length)return{canScroll:!1,emptySnapshot:!0,signature:""};let l=nL(s),u=function(e,t,r,n){let i=new Map(e.map(e=>[e.index,e])),a=e.filter(e=>A(e)&&nG(e.rect));if(0===a.length)return null;let o=function(e,t){if(void 0===e)return null;let r=t.get(e);for(;r;){if(A(r)&&nG(r.rect))return r;r=void 0===r.parentIndex?void 0:t.get(r.parentIndex)}return null}(n.nodeIndex,i);if(o)return o;let s=n.point;if(s){let e=a.filter(e=>{var t,r;return e.rect&&(t=e.rect,(r=s).x>=t.x&&r.x<=t.x+t.width&&r.y>=t.y&&r.y<=t.y+t.height)}).sort(nj);if(e.length>0)return e.find(e=>nF(e,t.get(e.index),r))??e[0]??null}let l=a.filter(e=>nF(e,t.get(e.index),r)).sort(nV);return l.length>0?l[0]??null:a.filter(t=>nR(t,e)).sort(nV)[0]??a.sort(nV)[0]??null}(s,l,t,r),c=(u?(n=s,i=u.index,o=new Map(n.map(e=>[e.index,e])),n.filter(e=>e.index===i||function(e,t,r){let n=void 0===e.parentIndex?void 0:r.get(e.parentIndex);for(;n;){if(n.index===t)return!0;n=void 0===n.parentIndex?void 0:r.get(n.parentIndex)}return!1}(e,i,o))):s).map(e=>{let t=e.rect?["x","y","width","height"].map(t=>{var r;return r=e.rect?.[t],"number"==typeof r&&Number.isFinite(r)?r.toFixed(1):""}).join(","):"";return[String(e.index??""),String(e.parentIndex??""),String(e.type??""),String(e.label??""),String(e.value??""),t].join("|")}).join("\n");return u?{canScroll:nF(u,l.get(u.index),t),emptySnapshot:!1,signature:c,scope:[(a=u).identifier,a.label,a.value].map(e=>"string"==typeof e?e.trim():"").find(nU)}:{canScroll:!1,emptySnapshot:!1,signature:c}}(e,t,r);if(n&&a.emptySnapshot)return await nC({edge:t,target:r,captureNodes:i});return a}catch(e){var a,o,s;throw a=t,o=n,s=e,o?new y("COMMAND_FAILED",`Failed to verify scroll ${a} state for scoped container`,{scope:o,hint:`scroll ${a} could not verify the scoped scroll container. Run snapshot -i for the current screen and retry with a visible scroll target.`},s):new y("COMMAND_FAILED",`Failed to verify scroll ${a} state`,{hint:`scroll ${a} needs a snapshot showing hidden content ${"bottom"===a?"below":"above"} before it will move.`},s)}}async function nT(e){let t,{edge:r,captureState:n,scroll:i}=e,a=await n();a.scope&&(a=await n(a.scope));let o=0;for(;a.canScroll;){if(o>=40)throw new y("COMMAND_FAILED",`scroll ${r} reached the safety limit before the snapshot showed the edge`,{hint:"The scoped scroll container still reports hidden content. Use a smaller manual scroll + snapshot loop to inspect the current state."});t=await i(),o+=1,a=await n(a.scope)}return{passes:o,result:t}}function n$(e,t,r,n,i){return t&&0===r?`Already at ${t}; no hidden content ${"bottom"===t?"below":"above"} detected`:t?`Scrolled to ${t} with ${r} ${e} passes`:void 0!==i?`Scrolled ${e} by ${i}px`:void 0!==n?`Scrolled ${e} by ${n}`:`Scrolled ${e}`}function nF(e,t,r){return"bottom"===r?!0===e.hiddenContentBelow||t?.hiddenContentBelow===!0:!0===e.hiddenContentAbove||t?.hiddenContentAbove===!0}function nU(e){return e.length>0&&e.length<=80&&!/^(true|false)$/i.test(e)&&!/^\d+$/.test(e)&&!/^\d+%$/.test(e)}function nj(e,t){return nq(e.rect)-nq(t.rect)}function nV(e,t){return nq(t.rect)-nq(e.rect)}function nq(e){return e?e.width*e.height:0}function nG(e){return!!(e&&e.width>0&&e.height>0)}function nz(e,t){return{session:t.session,requestId:t.requestId,signal:t.signal??e.signal,metadata:t.metadata}}function nB(e){return e.clock?.now()??Date.now()}async function nH(e,t){e.clock?await e.clock.sleep(t):await new Promise(e=>setTimeout(e,t))}function nW(e){return e&&"object"==typeof e?e:void 0}let nK=["x","y","width","height"];function nJ(e){let t=nX(e);if(!t)return null;let r=a(t);return Number.isFinite(r.x)&&Number.isFinite(r.y)?r:null}function nX(e){if(!e)return null;let t=Number(e.x),r=Number(e.y),n=Number(e.width),i=Number(e.height);return Number.isFinite(t)&&Number.isFinite(r)&&Number.isFinite(n)&&Number.isFinite(i)&&!(n<0)&&!(i<0)?{x:t,y:r,width:n,height:i}:null}function nY(e,t){return!!e&&!!t&&nK.every(r=>.5>=Math.abs(e[r]-t[r]))}function nQ(e){return{x:nZ(e.x,e.width),y:nZ(e.y,e.height)}}function nZ(e,t){if(t<=1)return Math.floor(e);let r=Math.ceil(e);return Math.round(Math.min(Math.floor(e+t-1),Math.max(r,e+t/2)))}let n0=["tabbar","toolbar","navigationbar","bottomnavigation","bottomnavigationview","sheet","dialog","alert","popover","menu"],n1=["button","link","menuitem","tabitem","textfield","searchfield","edittext","checkbox","radio","switch","cell"];function n2(e){if(e.length<2)return e;let t=[...e],r={nodes:t,byIndex:new Map(t.map(e=>[e.index,e]))},n=!1;for(let[e,i]of t.entries()){if(!function(e){return!!n6(e.rect)&&(!!(!0===e.hittable||n3(e,n1))||!!(e.label?.trim()||e.value?.trim()||e.identifier?.trim()))}(i)||!function e(t,r,n){let i=n6(n.rect);if(!i)return null;let o=a(i);for(let a=r+1;a<t.nodes.length;a+=1){let r=t.nodes[a];if(r&&function(t,r,n,i,a){if(!t.nodes[r])return!1;let o=function(t,r,n,i){var a,o,s,l;let u=t.nodes[r];if(!u||!(!(!n6((a=u).rect)||function(e){let t=n8(e);return t.includes("application")||t.includes("window")}(a))&&n3(a,n0))||n4(o=n,s=u,l=t.byIndex)||n4(s,o,l))return null;let c=n6(u.rect);return!c||nY(i,c)||e(t,r,u)?null:c}(t,r,n,i);return!!(o&&nw(o,a.x,a.y))}(t,a,n,i,o))return r}return null}(r,e,i))continue;n=!0;let o={...i,hittable:!1,interactionBlocked:"covered",presentationHints:Array.from(new Set([...i.presentationHints??[],"covered"]))};t[e]=o,r.byIndex.set(o.index,o)}return n?t:e}function n5(e){return void 0!==e.interactionBlocked}function n3(e,t){let r=n8(e);return t.some(e=>r.includes(e))}function n8(e){return[e.type,e.role,e.subrole].map(e=>g(e??"")).join(" ")}function n4(e,t,r){let n="number"==typeof t.parentIndex?r.get(t.parentIndex):void 0,i=new Set;for(;n&&!i.has(n.index);){if(n.index===e.index)return!0;i.add(n.index),n="number"==typeof n.parentIndex?r.get(n.parentIndex):void 0}return!1}function n6(e){let t=nX(e);return t&&t.width>0&&t.height>0?t:null}let n9=["button","link","menuitem","tabitem","textfield","searchfield","securetextfield","checkbox","radio","switch","cell"];function n7(e,t){return ie(e,t).node}function ie(e,t){var r;if(n5(t))return{node:t,reason:"covered"};let n=function(e,t){let r=nX(t.rect);if(!r)return null;let n=t,i=new Set;for(;!i.has(n.ref);){i.add(n.ref);let t=e.filter(e=>{if(e.parentIndex!==n.index||!e.hittable||n5(e))return!1;let t=nX(e.rect);return!!t&&nY(t,r)});if(1!==t.length)break;n=t[0]}return n===t?null:n}(e,t);if(n?.rect&&nJ(n.rect))return{node:n,reason:"same-rect-descendant"};if([(r=t).type,r.role,r.subrole].map(e=>g(e??"")).some(it)&&t.rect&&nJ(t.rect))return{node:t,reason:"semantic-target"};let i=l(e,t);return i?.rect&&!n5(i)&&nJ(i.rect)?!function(e,t,r){var n,i;let o,s,l,u=nX(e.rect),c=nX(t.rect);if(!u||!c)return!1;let p=function(e,t){let r=a(t),n=e.filter(e=>{let t=(e.type??"").toLowerCase();return t.includes("application")||t.includes("window")}).map(e=>nX(e.rect)).filter(e=>null!==e);if(0===n.length)return null;let i=n.filter(e=>nw(e,r.x,r.y));return nv(i.length>0?i:n)}(r,u);return!!p&&(o=k(n=c,i=p),s=n.width*n.height,l=i.width*i.height,!(o<=0)&&!(s<=0)&&!(l<=0)&&!!(o/l>=.9)&&!!(o/s>=.8))&&!nY(u,c)}(t,i,e)?{node:i,reason:"hittable-ancestor"}:{node:t,reason:"overly-broad-ancestor"}:{node:t,reason:"original"}}function it(e){return"tab"===e||n9.some(t=>e.includes(t))}async function ir(e,t,r){var n;return(await ip(e,t,r.action),"point"===t.target.kind)?{kind:"point",point:{x:(n=t.target).x,y:n.y}}:"ref"===t.target.kind?await ii(e,t,t.target,r):await ia(e,t,t.target,r)}async function ii(e,t,r,i){let a=await im(e,t,r),o=a.resolved,s=i.promoteToHittableAncestor?is(a.snapshot.nodes,o.node,{action:i.action,label:`Ref ${r.ref}`}):o.node;return il(s,`Ref ${r.ref}`,i.action),function(e,t,r,i){let a=e.rect?nO(e,t):null;if(!(!e.rect||!a||nR(e,t)))throw new y("COMMAND_FAILED",`Ref ${r} is off-screen and not safe to ${i}`,{reason:"offscreen_ref",ref:n(r),rect:e.rect,viewport:a,hint:`Use scroll with the direction from the off-screen summary, take a fresh snapshot, then retry ${i} with the new ref or a selector.`})}(s,a.snapshot.nodes,r.ref,i.action),{kind:"ref",point:ig(s,`Ref ${r.ref} not found or has invalid bounds`),target:{kind:"ref",ref:`@${o.ref}`},node:s,selectorChain:c(s,e.backend.platform,{action:"fill"===i.action?"fill":"click"}),refLabel:m(s,a.snapshot.nodes)}}async function ia(e,t,r,n){let i=p(r.selector),a=await ic(e,t,n.requireInteractive),o=f(io(a.snapshot.nodes),i,{platform:e.backend.platform,requireRect:!0,requireUnique:!0,disambiguateAmbiguous:!0});if(o&&o.node.rect||!n.requireInteractive||(o=f(io((a=await ic(e,t,!1)).snapshot.nodes),i,{platform:e.backend.platform,requireRect:!0,requireUnique:!0,disambiguateAmbiguous:!0})),!o||!o.node.rect){let t=f(a.snapshot.nodes,i,{platform:e.backend.platform,requireRect:!0,requireUnique:!1});if(t?.node&&n5(t.node))throw iu({label:`Selector ${t.selector.raw}`,node:t.node,action:n.action,selector:t.selector.raw});throw new y("COMMAND_FAILED",h(i,o?.diagnostics??[],{unique:!0}))}let s=n.promoteToHittableAncestor?is(a.snapshot.nodes,o.node,{action:n.action,label:`Selector ${o.selector.raw}`}):o.node;return il(s,`Selector ${o.selector.raw}`,n.action),{kind:"selector",point:ig(s,`Selector ${o.selector.raw} resolved to invalid bounds`),target:{kind:"selector",selector:o.selector.raw},node:s,selectorChain:c(s,e.backend.platform,{action:"fill"===n.action?"fill":"click"}),refLabel:m(s,a.snapshot.nodes)}}function io(e){return e.filter(e=>!n5(e))}function is(e,t,r){let n=ie(e,t);if("covered"===n.reason)throw iu({label:r.label,node:t,action:r.action});return n.node}function il(e,t,r){if(n5(e))throw iu({label:t,node:e,action:r})}function iu(e){return new y("COMMAND_FAILED",`${e.label} is covered by another visible element and cannot ${function(e){switch(e){case"fill":return"be filled";case"focus":return"be focused";case"longPress":return"be long-pressed";default:return"be tapped"}}(e.action)} safely`,{hint:"Use a different visible target, scroll it clear of the overlay, or inspect with snapshot/screenshot before retrying.",...e.selector?{selector:e.selector}:{},ref:`@${e.node.ref}`,interactionBlocked:e.node.interactionBlocked})}async function ic(e,t,r){if(!e.backend.captureSnapshot)throw new y("UNSUPPORTED_OPERATION","snapshot is not supported by this backend");let n=t.session??"default",i=await e.sessions.get(n);if(!i)throw new y("SESSION_NOT_FOUND","No active session. Run open first.");let a=await e.backend.captureSnapshot(nz(e,t),{interactiveOnly:r}),o=a.snapshot??{nodes:a.nodes??[],truncated:a.truncated,backend:a.backend,createdAt:nB(e)};return await e.sessions.set({...i,snapshot:o}),{snapshot:o}}async function ip(e,t,r){if("macos"!==e.backend.platform)return;let n=await id(e,t);if(("desktop"===n||"menubar"===n)&&("menubar"!==n||"click"!==r&&"press"!==r))throw new y("UNSUPPORTED_OPERATION",`${r} is not supported on macOS ${n} sessions yet. Open an app session to act, or use the ${n} surface to inspect.`)}async function id(e,t){let r=await e.sessions.get(t.session??"default");return r?.metadata?.surface}async function im(e,t,r){let n=t.session??"default",i=await e.sessions.get(n);if(!i)throw new y("SESSION_NOT_FOUND","No active session. Run open first.");if(!i.snapshot)throw new y("INVALID_ARGS","No snapshot in session. Run snapshot first.");let a=r.fallbackLabel??"",o=ih(i.snapshot.nodes,r.ref,{fallbackLabel:a});if(o)return{snapshot:i.snapshot,resolved:o};let s=await ic(e,t,!0),l=ih(s.snapshot.nodes,r.ref,{fallbackLabel:a});if(!l)throw new y("COMMAND_FAILED",`Ref ${r.ref} not found or has no bounds`);return{...s,resolved:l}}function ih(e,t,i){let a=n(t);if(!a)throw new y("INVALID_ARGS",`Invalid ref: ${t}`);let o=r(e,a);if(iy(o))return{ref:a,node:o};let s=i.fallbackLabel.length>0?d(e,i.fallbackLabel):null;return iy(s)?{ref:a,node:s}:null}function ig(e,t){let r=nJ(e.rect);if(!r)throw new y("COMMAND_FAILED",t);return r}function iy(e){return!!e&&null!==nJ(e.rect)}let ib=async(e,t)=>{let r=await ir(e,t,{action:"focus",requireInteractive:!0,promoteToHittableAncestor:!1});if(!e.backend.focus)throw new y("UNSUPPORTED_OPERATION","focus is not supported by this backend");let n=nW(await e.backend.focus(nz(e,t),r.point));return{...r,...n?{backendResult:n}:{},...eJ(`Focused (${r.point.x}, ${r.point.y})`)}},iw=async(e,t)=>{let r=await ir(e,t,{action:"longPress",requireInteractive:!0,promoteToHittableAncestor:!0});if(!e.backend.longPress)throw new y("UNSUPPORTED_OPERATION","longPress is not supported by this backend");let n=void 0===t.durationMs?void 0:nb(t.durationMs,"durationMs",0,12e4),i=nW(await e.backend.longPress(nz(e,t),r.point,{durationMs:n}));return{...r,...void 0!==n?{durationMs:n}:{},...i?{backendResult:i}:{},...eJ(`Long pressed (${r.point.x}, ${r.point.y})`)}},iv=async(e,t)=>{var r,n,i,a;let o;if(!e.backend.scroll)throw new y("UNSUPPORTED_OPERATION","scroll is not supported by this backend");let s="bottom"===(r=t.direction)?{direction:"down",edge:"bottom"}:"top"===r?{direction:"up",edge:"top"}:{direction:iM(r,"scroll direction")},l=(n=t.amount,i="scroll amount",void 0===n?void 0:iN(n,i)),u=function(e,t){if(void 0!==e){if(!Number.isFinite(e)||!Number.isInteger(e)||e<=0)throw new y("INVALID_ARGS",`${t} must be a positive integer`);return e}}(t.pixels,"scroll pixels");if(void 0!==l&&void 0!==u)throw new y("INVALID_ARGS","scroll accepts either amount or pixels, not both");let c=await iA(e,t),p="viewport"===c.kind?{kind:"viewport"}:{kind:"point",point:c.point},d=e.backend.scroll,m=async()=>await d(nz(e,t),p,{direction:s.direction,...void 0!==l?{amount:l}:{},...void 0!==u?{pixels:u}:{}}),f=0;if(s.edge){let r=s.edge,n="viewport"===(a=c).kind?{}:{point:a.point,nodeIndex:"node"in a?a.node.index:void 0},i=await nT({edge:r,captureState:async i=>await iI(e,t,r,n,i),scroll:m});o=i.result,f=i.passes}else o=await m(),f=1;let h=nW(o);return{...c,direction:s.direction,...s.edge?{edge:s.edge,passes:f}:{},...void 0!==l?{amount:l}:{},...void 0!==u?{pixels:u}:{},...h?{backendResult:h}:{},...eJ(n$(s.direction,s.edge,f,l,u))}},ix=async(e,t)=>{if(!e.backend.swipe)throw new y("UNSUPPORTED_OPERATION","swipe is not supported by this backend");if(t.preset)return await iS(e,t,e.backend.swipe);let r=await iD(e,t),n=function(e,t){if(t.to)return{point:iL(t.to,"to")};let r=iM(t.direction,"swipe direction"),n=iN(t.distance??200,"swipe distance");switch(r){case"up":return{point:{x:e.x,y:e.y-n},direction:r,distance:n};case"down":return{point:{x:e.x,y:e.y+n},direction:r,distance:n};case"left":return{point:{x:e.x-n,y:e.y},direction:r,distance:n};case"right":return{point:{x:e.x+n,y:e.y},direction:r,distance:n}}}(r.point,t),i=void 0===t.durationMs?void 0:nb(t.durationMs,"durationMs",16,1e4),a=nW(await e.backend.swipe(nz(e,t),r.point,n.point,{durationMs:i}));return{kind:"swipe",from:r.point,to:n.point,...n.direction?{direction:n.direction}:{},...void 0!==n.distance?{distance:n.distance}:{},...void 0!==i?{durationMs:i}:{},...r.target?{fromTarget:r.target}:{},...a?{backendResult:a}:{},...eJ("Swiped")}};async function iS(e,t,r){let n;if(t.from||t.to||t.direction||void 0!==t.distance)throw new y("INVALID_ARGS","gesture swipe preset cannot be combined with from, to, direction, or distance");let i=nl(t.preset);await ip(e,t,"swipe");let a=ns(i,{referenceWidth:(n=iR((await ic(e,t,!1)).snapshot.nodes)).width,referenceHeight:n.height},{platform:e.backend.platform}),o=void 0===t.durationMs?void 0:nb(t.durationMs,"durationMs",16,1e4),s={x:a.x1,y:a.y1},l={x:a.x2,y:a.y2},u=nW(await r(nz(e,t),s,l,{durationMs:o}));return{kind:"swipe",from:s,to:l,preset:i,...void 0!==o?{durationMs:o}:{},fromTarget:{kind:"viewport"},...u?{backendResult:u}:{},...eJ(`Swiped ${i}`)}}let ik=async(e,t)=>{if(!e.backend.pinch)throw new y("UNSUPPORTED_OPERATION","pinch is not supported by this backend");await ip(e,t,"pinch");let r=iN(t.scale,"pinch scale"),n=t.center?await ir(e,{...t,target:t.center},{action:"pinch",requireInteractive:!1,promoteToHittableAncestor:!1}):void 0,i=nW(await e.backend.pinch(nz(e,t),{scale:r,...n?{center:n.point}:{}}));return{kind:"pinch",scale:r,...n?{center:n.point,centerTarget:n}:{},...i?{backendResult:i}:{},...eJ(`Pinched to scale ${r}`)}};async function iA(e,t){let r=t.target??{kind:"viewport"};return"viewport"===r.kind?(await ip(e,t,"scroll"),{kind:"viewport"}):await ir(e,{...t,target:r},{action:"scroll",requireInteractive:!1,promoteToHittableAncestor:!1})}async function iD(e,t){if(t.from){var r;if("x"in(r=t.from)&&"y"in r)return await ip(e,t,"swipe"),{point:iL(t.from,"from")};let n=await ir(e,{...t,target:t.from},{action:"swipe",requireInteractive:!1,promoteToHittableAncestor:!1});return{point:n.point,target:n}}if(!t.direction)throw new y("INVALID_ARGS","swipe requires from+to or a direction");return await ip(e,t,"swipe"),{point:a(iR((await ic(e,t,!1)).snapshot.nodes)),target:{kind:"viewport"}}}async function iI(e,t,r,n,i){if(!e.backend.captureSnapshot)throw new y("UNSUPPORTED_OPERATION",`scroll ${r} requires snapshot support to verify hidden content before scrolling`);let{captureSnapshot:a}=e.backend;return await nC({edge:r,target:n,scope:i,captureNodes:async r=>{let n=await a(nz(e,t),{scope:r});return n.snapshot?.nodes??n.nodes??[]}})}function iM(e,t){switch(e){case"up":case"down":case"left":case"right":return e;default:throw new y("INVALID_ARGS",`${t} must be up, down, left, or right`)}}function iL(e,t){let r=Number(e.x),n=Number(e.y);if(!Number.isFinite(r)||!Number.isFinite(n))throw new y("INVALID_ARGS",`${t} point requires finite x and y`);return{x:r,y:n}}function iN(e,t){if(!Number.isFinite(e)||e<=0)throw new y("INVALID_ARGS",`${t} must be a positive number`);return e}function iR(e){let t=e.filter(t=>nR(t,e)).map(e=>e.rect).filter(iO),r=t.length>0?t:e.map(e=>e.rect).filter(iO);if(0===r.length)throw new y("COMMAND_FAILED","Cannot infer viewport for directional swipe");let n=Math.min(...r.map(e=>e.x)),i=Math.min(...r.map(e=>e.y));return{x:n,y:i,width:Math.max(...r.map(e=>e.x+e.width))-n,height:Math.max(...r.map(e=>e.y+e.height))-i}}function iO(e){return!!(e&&e.width>0&&e.height>0)}let iE={click:"Click or tap a semantic UI target by ref, selector, or point.",press:"Press a semantic UI target by ref, selector, or point.",fill:"Fill text into a semantic UI target by ref, selector, or point.",longpress:"Long press by ref, selector, or point.",swipe:"Swipe between two points.",focus:"Focus input at coordinates.",type:"Type text in the focused field.",scroll:"Scroll in a direction or to an edge.",get:"Get element text or attributes.",is:"Assert UI state.",find:"Find an element and optionally act on it.",gesture:"Run a structured gesture."},iP={target:P(V()),button:F(["primary","secondary","middle"],"Pointer button for platforms that support mouse buttons."),...G(),...z()},i_={target:P(V()),...G(),...z()},iC={target:P(V()),text:P(_("Text to enter into the target.")),delayMs:T("Delay between typed characters.",{min:0}),...G()},iT={target:P(V()),durationMs:T("Long press duration in milliseconds.",{min:0}),...G()},i$={from:P(q("Swipe start point.")),to:P(q("Swipe end point.")),durationMs:T("Swipe duration in milliseconds.",{min:0}),count:T("Number of swipe repetitions.",{min:1}),pauseMs:T("Pause between repeated swipes.",{min:0}),pattern:F(nt)},iF={x:P(C("X coordinate.")),y:P(C("Y coordinate."))},iU={text:P(_("Text to type.")),delayMs:T("Delay between typed characters.",{min:0})},ij={direction:P(F(["up","down","left","right","top","bottom"])),amount:C("Platform scroll amount."),pixels:T("Pixel scroll amount.",{min:0})},iV={format:P(F(["text","attrs"])),target:P(eu({oneOf:ep(),description:"UI element target by snapshot ref or selector expression."},(e,t)=>{let r,n;return void 0===e[t]?void 0:"ref"===(n=er(r=ed(e,t),"kind",["ref","selector"]))?{kind:n,ref:X(r,"ref"),label:Y(r,"label")}:{kind:n,selector:X(r,"selector")}})),...G()},iq={predicate:P(F(["visible","hidden","exists","editable","selected","text"])),selector:P(_()),value:_(),...G()},iG={locator:F(D),query:P(_()),action:F(["click","focus","exists","getText","getAttrs","wait","fill","type"]),value:_(),timeoutMs:T(),first:$(),last:$(),depth:T(),raw:$()},iz={kind:P(F(x,"Gesture variant.")),direction:F(r7,"Fling direction."),preset:F(ne,"Swipe preset."),origin:q("Gesture origin point."),delta:q("Movement delta for pan or transform gestures."),distance:T("Fling distance.",{min:0}),scale:C("Pinch or transform scale."),degrees:C("Rotation in degrees."),velocity:T("Rotate gesture velocity.",{min:0}),durationMs:T("Gesture duration in milliseconds.",{min:0})},iB=[{name:"click",description:iE.click,inputSchema:B(iP),readInput:e=>H(e,iP)},{name:"press",description:iE.press,inputSchema:B(i_),readInput:e=>H(e,i_)},{name:"fill",description:iE.fill,inputSchema:B(iC),readInput:e=>H(e,iC)},iH("longpress",iT),iH("swipe",i$),iH("focus",iF),iH("type",iU),iH("scroll",ij),iH("get",iV),iH("is",iq),iH("find",iG),{name:"gesture",description:iE.gesture,inputSchema:B(iz),readInput:function(e){let t=W(e),r=K(t),n=er(t,"kind",x);return"pan"===n?{...r,kind:n,origin:J(t,"origin"),delta:J(t,"delta"),durationMs:ee(t,"durationMs",{min:0})}:"fling"===n?{...r,kind:n,direction:er(t,"direction",r7),origin:J(t,"origin"),distance:ee(t,"distance",{min:0}),durationMs:ee(t,"durationMs",{min:0})}:"swipe"===n?{...r,kind:n,preset:er(t,"preset",ne),durationMs:ee(t,"durationMs",{min:0})}:"pinch"===n?{...r,kind:n,scale:Q(t,"scale"),origin:iW(t,"origin")}:"rotate"===n?{...r,kind:n,degrees:Q(t,"degrees"),origin:iW(t,"origin"),velocity:ee(t,"velocity",{min:0})}:{...r,kind:n,origin:J(t,"origin"),delta:J(t,"delta"),scale:Q(t,"scale"),degrees:Q(t,"degrees"),durationMs:ee(t,"durationMs",{min:0})}}}];function iH(e,t){return rd(e,iE[e],t)}function iW(e,t){return void 0===e[t]?void 0:J(e,t)}let iK={gesture:function(e,t){let r=e[0],n=e.slice(1),i=eh(t);switch(r){case"pan":return{...i,kind:r,origin:{x:Number(n[0]),y:Number(n[1])},delta:{x:Number(n[2]),y:Number(n[3])},durationMs:eL(n[4])};case"fling":return{...i,kind:r,direction:n[0],origin:{x:Number(n[1]),y:Number(n[2])},distance:eL(n[3]),durationMs:eL(n[4])};case"swipe":return{...i,kind:r,preset:n[0],durationMs:eL(n[1])};case"pinch":return{...i,kind:r,scale:Number(n[0]),origin:void 0===n[1]||void 0===n[2]?void 0:{x:Number(n[1]),y:Number(n[2])}};case"rotate":return{...i,kind:r,degrees:Number(n[0]),origin:void 0===n[1]||void 0===n[2]?void 0:{x:Number(n[1]),y:Number(n[2])},velocity:eL(n[3])};case"transform":return{...i,kind:r,origin:{x:Number(n[0]),y:Number(n[1])},delta:{x:Number(n[2]),y:Number(n[3])},scale:Number(n[4]),degrees:Number(n[5]),durationMs:eL(n[6])};default:throw new y("INVALID_ARGS","gesture requires pan, fling, swipe, pinch, rotate, or transform")}}},iJ={gesture:em(S.gesture,function(e){switch(e.kind){case"pan":return["pan",String(e.origin?.x),String(e.origin?.y),String(e.delta?.x),String(e.delta?.y),...eR(e.durationMs)];case"fling":return["fling",eE(e.direction,"gesture fling requires direction"),String(e.origin?.x),String(e.origin?.y),...eR(e.distance),...eR(e.durationMs)];case"swipe":return iX(e);case"pinch":return["pinch",String(e.scale),...eR(e.origin?.x),...eR(e.origin?.y)];case"rotate":return["rotate",String(e.degrees),...eR(e.origin?.x),...eR(e.origin?.y),...eR(e.velocity)];case"transform":return["transform",String(e.origin?.x),String(e.origin?.y),String(e.delta?.x),String(e.delta?.y),String(e.scale),String(e.degrees),...eR(e.durationMs)];default:throw new y("INVALID_ARGS","gesture requires pan, fling, swipe, pinch, rotate, or transform")}}),"gesture-pan":em(S.gesture,function(e){return["pan",String(e.x),String(e.y),String(e.dx),String(e.dy),...eR(e.durationMs)]}),"gesture-fling":em(S.gesture,e=>{var t;let r;return r=void 0!==(t=e).durationMs?t.distance??180:t.distance,["fling",t.direction,String(t.x),String(t.y),...eR(r),...eR(t.durationMs)]}),"gesture-swipe":em(S.gesture,iX),"gesture-pinch":em(S.gesture,function(e){return["pinch",String(e.scale),...eR(e.x),...eR(e.y)]}),"gesture-rotate":em(S.gesture,e=>(function(e){var t=e;if(void 0===t.x&&void 0!==t.y||void 0!==t.x&&void 0===t.y)throw new y("INVALID_ARGS","gesture rotate center requires both x and y");let r=void 0===e.x||void 0===e.y?[]:[String(e.x),String(e.y)];return["rotate",String(e.degrees),...r,...eR(e.velocity)]})(e)),"gesture-transform":em(S.gesture,function(e){return["transform",String(e.x),String(e.y),String(e.dx),String(e.dy),String(e.scale),String(e.degrees),...eR(e.durationMs)]})};function iX(e){return["swipe",eE(e.preset,"gesture swipe requires preset"),...eR(e.durationMs)]}function iY(e){if(e[0]?.startsWith("@")){let t=iZ(e.slice(1));return{ref:e[0],...void 0===t?{}:{label:t}}}let t=s(e);return t?{selector:t.selectorExpression}:{x:Number(e[0]),y:Number(e[1])}}function iQ(e){let t=e[0];if(t?.startsWith("@")){let r=e.length>=3?e.slice(2).join(" "):e.slice(1).join(" ");return{kind:"ref",target:{ref:t,label:e.length>=3?iZ(e.slice(1,2)):void 0},text:r}}let r=s(e,{preferTrailingValue:!0});return r?{kind:"selector",target:{selector:r.selectorExpression},text:r.rest.join(" ")}:{kind:"point",target:{x:Number(e[0]),y:Number(e[1])},text:e.slice(2).join(" ")}}function iZ(e){return e.join(" ").trim()||void 0}let i0={click:(e,t)=>({...eh(t),...ey(t),...ew(t),target:ev(iY(e)),button:t.clickButton}),press:(e,t)=>({...eh(t),...ey(t),...ew(t),target:ev(iY(e))}),longpress:(e,t)=>{let r,n={...iY((r=function(e){if(eM(e[0])&&eM(e[1]))return{target:e.slice(0,2),...void 0!==e[2]?{durationMs:Number(e[2])}:{}};let t=e.at(-1);return e.length>1&&eM(t)?{target:e.slice(0,-1),durationMs:Number(t)}:{target:e}}(e)).target),...void 0!==r.durationMs?{durationMs:r.durationMs}:{}};return{...eh(t),...ey(t),target:ev(n),durationMs:n.durationMs}},swipe:(e,t)=>({...eh(t),from:{x:Number(e[0]),y:Number(e[1])},to:{x:Number(e[2]),y:Number(e[3])},durationMs:eL(e[4]),count:t.count,pauseMs:t.pauseMs,pattern:t.pattern}),focus:(e,t)=>({...eh(t),x:Number(e[0]),y:Number(e[1])}),type:(e,t)=>({...eh(t),text:e.join(" "),delayMs:t.delayMs}),fill:(e,t)=>{let r=iQ(e);return{...eh(t),...ey(t),target:ev(r.target),text:r.text,delayMs:t.delayMs}},scroll:(e,t)=>({...eh(t),direction:function(e){if("up"===e||"down"===e||"left"===e||"right"===e||"top"===e||"bottom"===e)return e;throw new y("INVALID_ARGS",`Unknown direction: ${String(e)}`)}(e[0]),amount:eL(e[1]),pixels:t.pixels}),get:(e,t)=>({...eh(t),...ey(t),format:function(e){if("text"===e||"attrs"===e)return e;throw new y("INVALID_ARGS","get only supports text or attrs")}(e[0]),target:ev(function(e){if(e[0]?.startsWith("@"))return{ref:e[0],label:e.slice(1).join(" ").trim()||void 0};let t=e.join(" ").trim();if(!t)throw new y("INVALID_ARGS","get requires @ref or selector expression");return{selector:t}}(e.slice(1)))})},i1={click:e=>ef(S.click,ex(e),{...e,clickButton:e.button}),press:em(S.press,e=>ex(e)),longpress:em(S.longPress,e=>{var t;return[...ex(t=e),...eR(t.durationMs)]}),swipe:em(S.swipe,function(e){return[String(e.from?.x),String(e.from?.y),String(e.to?.x),String(e.to?.y),...eR(e.durationMs)]}),focus:em(S.focus,e=>[String(e.x),String(e.y)]),type:em(S.type,e=>[e.text]),fill:em(S.fill,e=>{var t;return[...ex(t=e),t.text]}),scroll:em(S.scroll,e=>[eE(e.direction,"scroll requires direction"),...eR(e.amount)]),get:em(S.get,e=>[eE(e.format,"get requires format"),...function(e){let t=eS(e);if("string"==typeof t.ref)return[t.ref,...eA(t.label)];if("string"==typeof t.selector)return[t.selector];throw new y("INVALID_ARGS","element command requires @ref or selector target")}(e)])},i2={find:(e,t)=>(function(e,t){var r;let n={...{depth:(r=t).snapshotDepth,raw:r.snapshotRaw},...eg(t),first:t.findFirst,last:t.findLast},i=function(e){if("text"===e||"label"===e||"value"===e||"role"===e||"id"===e)return e}(e[0]),a=void 0!==i,o=a?e[1]:e[0],s=a?2:1,l=e[s];if(void 0===l)return{...n,locator:i,query:i3(o)};if("get"===l){let t=e[s+1];if("text"===t)return{...n,locator:i,query:i3(o),action:"getText"};if("attrs"===t)return{...n,locator:i,query:i3(o),action:"getAttrs"};throw new y("INVALID_ARGS","find get only supports text or attrs")}if("wait"===l)return{...n,locator:i,query:i3(o),action:"wait",timeoutMs:eL(e[s+1])};if("fill"===l||"type"===l)return{...n,locator:i,query:i3(o),action:l,value:e.slice(s+1).join(" ")};if("click"===l||"focus"===l||"exists"===l)return{...n,locator:i,query:i3(o),action:l};throw new y("INVALID_ARGS",`Unsupported find action: ${l}`)})(e,t),is:(e,t)=>(function(e,t){let r={...eb(t),...eg(t)},n=e[0],i=function(e,t={}){let r=s(e,t);if(!r)throw new y("INVALID_ARGS","is requires a selector expression");return r}(e.slice(1),{preferTrailingValue:"text"===n});if("text"===n)return{...r,predicate:n,selector:i.selectorExpression,value:i.rest.join(" ")};if("visible"===n||"hidden"===n||"exists"===n||"editable"===n||"selected"===n)return{...r,predicate:n,selector:i.selectorExpression};throw new y("INVALID_ARGS","is requires predicate: visible|hidden|exists|editable|selected|text")})(e,t)},i5={is:em(S.is,e=>{var t;return[(t=e).predicate,t.selector,..."text"===t.predicate?[t.value]:[]]}),find:e=>ef(S.find,function(e){let t=e.locator&&"any"!==e.locator?[e.locator,e.query]:[e.query];switch(e.action){case void 0:case"click":case"focus":case"exists":return e.action?[...t,e.action]:t;case"getText":return[...t,"get","text"];case"getAttrs":return[...t,"get","attrs"];case"wait":return[...t,"wait",...eR(e.timeoutMs)];case"fill":case"type":return[...t,e.action,e.value]}}(e),{...e,findFirst:e.first,findLast:e.last})};function i3(e){if(void 0===e||""===e)throw new y("INVALID_ARGS","find requires query");return e}let i8={get:{usageOverride:"get text|attrs <@ref|selector>",positionalArgs:["subcommand","target"],allowedFlags:[...rr]},find:{usageOverride:"find <locator|text> <action> [value] [--first|--last]",helpDescription:"Find by text/label/value/role/id and run action",summary:"Find an element and act",positionalArgs:["query","action","value?"],allowsExtraPositionals:!0,allowedFlags:["snapshotDepth","snapshotRaw","findFirst","findLast"]},is:{positionalArgs:["predicate","selector","value?"],allowsExtraPositionals:!0,allowedFlags:[...rr]},click:{usageOverride:"click <x y|@ref|selector>",positionalArgs:["target"],allowsExtraPositionals:!0,allowedFlags:[...ra,"clickButton",...rr]},press:{usageOverride:"press <x y|@ref|selector>",positionalArgs:["targetOrX","y?"],allowsExtraPositionals:!0,allowedFlags:[...ra,...rr]},longpress:{usageOverride:"longpress <x y|@ref|selector> [durationMs]",positionalArgs:["targetOrX","yOrDurationMs?","durationMs?"],allowsExtraPositionals:!0,allowedFlags:[...rr]},swipe:{helpDescription:"Swipe coordinates with optional repeat pattern",positionalArgs:["x1","y1","x2","y2","durationMs?"],allowedFlags:["count","pauseMs","pattern"]},gesture:{usageOverride:"gesture <pan|fling|swipe|pinch|rotate|transform> ...",listUsageOverride:"gesture <pan|fling|swipe|pinch|rotate|transform> ...",helpDescription:"Run touch gestures: pan <x> <y> <dx> <dy> [durationMs], fling <up|down|left|right> <x> <y> [distance] [durationMs], swipe <left|right|left-edge|right-edge> [durationMs], pinch <scale> [x] [y], rotate <degrees> [x] [y] [velocity], or transform <x> <y> <dx> <dy> <scale> <degrees> [durationMs]",summary:"Run pan, fling, swipe, pinch, rotate, or transform gestures",positionalArgs:["pan|fling|swipe|pinch|rotate|transform","args?"],allowsExtraPositionals:!0},focus:{positionalArgs:["x","y"]},type:{positionalArgs:["text"],allowsExtraPositionals:!0,allowedFlags:["delayMs"]},fill:{usageOverride:"fill <x> <y> <text> | fill <@ref|selector> <text>",positionalArgs:["targetOrX","yOrText","text?"],allowsExtraPositionals:!0,allowedFlags:[...rr,"delayMs"]},scroll:{usageOverride:"scroll <direction|top|bottom> [amount] [--pixels <n>]",helpDescription:"Scroll in direction, or verify hidden content and scroll toward top/bottom",summary:"Scroll in a direction or to an edge",positionalArgs:["directionOrEdge","amount?"],allowedFlags:["pixels"]}},i4=[eP(i6("click"),(e,t)=>{var r;return e.interactions.click({...ei(r=t),...ea(r.target),...es(r),...eo(r),button:r.button})}),eP(i6("press"),(e,t)=>{var r;return e.interactions.press({...ei(r=t),...ea(r.target),...es(r),...eo(r)})}),eP(i6("fill"),(e,t)=>{var r;return e.interactions.fill({...ei(r=t),...ea(r.target),...es(r),text:r.text,delayMs:r.delayMs})}),eP(i6("longpress"),(e,t)=>{var r;return e.interactions.longPress({...ei(r=t),...ea(r.target),...es(r),durationMs:r.durationMs})}),eP(i6("swipe"),(e,t)=>e.interactions.swipe(t)),eP(i6("focus"),(e,t)=>e.interactions.focus(t)),eP(i6("type"),(e,t)=>e.interactions.type(t)),eP(i6("scroll"),(e,t)=>e.interactions.scroll(t)),eP(i6("get"),(e,t)=>{var r;return e.interactions.get({...ei(r=t),...function(e){switch(e.kind){case"ref":return{ref:e.ref,label:e.label};case"selector":return{selector:e.selector}}}(r.target),...es(r),format:r.format})}),eP(i6("is"),(e,t)=>e.interactions.is(t)),eP(i6("find"),(e,t)=>e.interactions.find(t)),eP(i6("gesture"),async(e,t)=>{var r,n,i,a,o,s;switch(t.kind){case"pan":return await e.interactions.pan({...ei(r=t),x:r.origin.x,y:r.origin.y,dx:r.delta.x,dy:r.delta.y,durationMs:r.durationMs});case"fling":return await e.interactions.fling({...ei(n=t),direction:n.direction,x:n.origin.x,y:n.origin.y,distance:n.distance,durationMs:n.durationMs});case"swipe":return await e.interactions.swipeGesture({...ei(i=t),preset:i.preset,durationMs:i.durationMs});case"pinch":return await e.interactions.pinch({...ei(a=t),scale:a.scale,x:a.origin?.x,y:a.origin?.y});case"rotate":return await e.interactions.rotateGesture({...ei(o=t),degrees:o.degrees,x:o.origin?.x,y:o.origin?.y,velocity:o.velocity});case"transform":return await e.interactions.transformGesture({...ei(s=t),x:s.origin.x,y:s.origin.y,dx:s.delta.x,dy:s.delta.y,scale:s.scale,degrees:s.degrees,durationMs:s.durationMs})}})];function i6(e){let t=iB.find(t=>t.name===e);if(!t)throw Error(`Missing interaction command metadata for ${e}`);return t}function i9(e,t){if(!e||"object"!=typeof e||Array.isArray(e))throw new y("INVALID_ARGS",`${t} installSource must be an object.`);if("github-actions-artifact"!==at(e.type,`${t} installSource.type`))throw new y("INVALID_ARGS",`${t} installSource.type must be "github-actions-artifact".`);let{owner:r,repo:n}=ae(at(e.repo,`${t} installSource.repo`),`${t} installSource.repo`);return i7(r,n,e.artifact,`${t} installSource.artifact`)}function i7(e,t,r,n){var i;return"number"==typeof r||"string"==typeof(i=r)&&/^\d+$/.test(i.trim())?{kind:"github-actions-artifact",owner:e,repo:t,artifactId:function(e,t){let r="number"==typeof e?e:"string"==typeof e?Number(e):NaN;if(!Number.isInteger(r))throw new y("INVALID_ARGS",`${t} must be an integer.`);return r}(r,n)}:{kind:"github-actions-artifact",owner:e,repo:t,artifactName:at(r,n)}}function ae(e,t){let r=e.indexOf("/");if(r<=0||r===e.length-1||-1!==e.indexOf("/",r+1))throw new y("INVALID_ARGS",`${t} must use owner/repo.`);let n={owner:e.slice(0,r).trim(),repo:e.slice(r+1).trim()};if(!n.owner||!n.repo)throw new y("INVALID_ARGS",`${t} must use owner/repo.`);return n}function at(e,t){let r="string"==typeof e&&e.trim().length>0?e.trim():void 0;if(!r)throw new y("INVALID_ARGS",`${t} must be a non-empty string.`);return r}let ar=[rd("devices","List available devices.",{}),rd("boot","Boot or prepare a selected device without using CLI positional arguments.",{headless:$("Boot without showing simulator UI when supported.")}),rd("shutdown","Shutdown a selected simulator or emulator.",{}),rd("prepare","Prepare platform helper infrastructure.",{action:P(F(["ios-runner"])),timeoutMs:T("Maximum wall-clock time for the prepare command.")}),rd("apps","List installed apps.",{appsFilter:F(["user-installed","all"])}),rd("session","List active sessions or print daemon state directory.",{action:F(["list","state-dir"],"list shows active sessions; state-dir prints the resolved daemon state directory without contacting the daemon.")}),rd("open","Open an app, deep link, URL, or platform surface.",{app:_("App name, bundle id, package, or URL."),url:_("Optional URL passed with an app shell."),surface:F(tj),activity:_("Android activity name."),launchConsole:_("Launch console mode."),launchArgs:U("Launch arguments forwarded verbatim to the platform launch command."),relaunch:$("Force relaunch."),saveScript:j({oneOf:[O(),N()]}),deviceHub:$("Use Xcode Device Hub when surfacing Apple simulators."),noRecord:$("Do not record this action.")}),rd("close","Close an app or end the active session.",{app:_("Optional app to close."),shutdown:$("Shutdown the session/device where supported."),saveScript:j({oneOf:[O(),N()]})}),rd("install","Install an app binary.",{app:P(_()),appPath:P(_("Path to app binary."))}),rd("reinstall","Reinstall an app binary.",{app:P(_()),appPath:P(_("Path to app binary."))}),rd("install-from-source","Install an app from a structured source.",{source:P(j(E("Install source object."))),retainPaths:$(),retentionMs:T()}),rd("push","Deliver a push payload.",{app:P(_()),payload:P(j({oneOf:[N(),E()]}))}),rd("trigger-app-event","Trigger an app-defined event.",{event:P(_()),payload:eu(E(void 0),function(e,t){let r=e[t];if(void 0!==r){if(!r||"object"!=typeof r||Array.isArray(r))throw Error(`Expected ${t} to be an object.`);return r}})})],an=[eP(aa("devices"),(e,t)=>e.devices.list(t)),eP(aa("boot"),(e,t)=>e.devices.boot(t)),eP(aa("shutdown"),(e,t)=>e.devices.shutdown(t)),eP(aa("apps"),(e,t)=>e.apps.list(t)),eP(aa("session"),async(e,{action:t,...r})=>"state-dir"===t?{stateDir:await e.sessions.stateDir(r)}:{sessions:await e.sessions.list(r)}),eP(aa("open"),(e,t)=>e.apps.open(t)),eP(aa("close"),(e,t)=>t.app?e.apps.close(t):e.sessions.close(function(e){let{app:t,...r}=e;return r}(t))),eP(aa("install"),(e,t)=>e.apps.install(t)),eP(aa("reinstall"),(e,t)=>e.apps.reinstall(t)),eP(aa("install-from-source"),(e,t)=>e.apps.installFromSource(t)),eP(aa("push"),(e,t)=>e.apps.push(t)),eP(aa("trigger-app-event"),(e,t)=>e.apps.triggerEvent(t)),eP(aa("prepare"),(e,t)=>e.command.prepare(t))],ai={boot:{summary:"Boot target device/simulator",allowedFlags:["headless"]},shutdown:{summary:"Shutdown target simulator/emulator"},prepare:{usageOverride:"prepare ios-runner --platform ios|macos [--timeout <ms>]",listUsageOverride:"prepare ios-runner --platform ios|macos",helpDescription:"Prepare platform helper infrastructure. ios-runner builds/reuses, starts, and health-checks the XCTest runner so later Apple snapshots and interactions do not pay first-use startup cost. In CI, run it after boot/install and before replay/test; if replay/test starts a separate daemon, run clean:daemon after prepare to release the prepared runner lease. Runner build/start output is written to the session runner.log; daemon.log is for daemon lifecycle/startup issues.",summary:"Prepare platform helpers",positionalArgs:["ios-runner"],allowedFlags:["timeoutMs"]},open:{helpDescription:"Boot device/simulator; optionally launch app or deep link URL (macOS also supports --surface app|frontmost-app|desktop|menubar)",summary:"Open an app, deep link or URL, save replays",positionalArgs:["appOrUrl?","url?"],allowedFlags:["activity","launchConsole","launchArgs","deviceHub","saveScript","relaunch","surface"]},close:{positionalArgs:["app?"],allowedFlags:["saveScript","shutdown"]},reinstall:{positionalArgs:["app","path"]},install:{positionalArgs:["app","path"]},"install-from-source":{usageOverride:"install-from-source <url> | install-from-source --github-actions-artifact <owner/repo:artifact>",listUsageOverride:"install-from-source <url> | install-from-source --github-actions-artifact",helpDescription:"Install app from a URL or remote-resolved source",summary:"Install app from a source",positionalArgs:["url?"],allowedFlags:["header","githubActionsArtifact","installSource","retainPaths","retentionMs"]},apps:{helpDescription:"List user-installed apps; use --all to include system/OEM apps",summary:"List installed apps",allowedFlags:["appsFilter"],defaults:{appsFilter:I}},push:{positionalArgs:["bundleOrPackage","payloadOrJson"]},"trigger-app-event":{usageOverride:"trigger-app-event <event> [payloadJson]",positionalArgs:["event","payloadJson?"]},session:{usageOverride:"session list | session state-dir",listUsageOverride:"session list",helpDescription:"List active sessions or print the effective daemon state directory",positionalArgs:["list|state-dir?"]}};function aa(e){let t=ar.find(t=>t.name===e);if(!t)throw Error(`Missing management command metadata for ${e}`);return t}let ao={devices:(e,t)=>eh(t),apps:(e,t)=>({...eh(t),appsFilter:M(t.appsFilter)}),session:(e,t)=>({...eh(t),action:function(e){let t=e??"list";if("list"===t||"state-dir"===t)return t;throw new y("INVALID_ARGS","session only supports list or state-dir")}(e[0])}),boot:(e,t)=>({...eh(t),headless:t.headless}),shutdown:(e,t)=>eh(t),prepare:(e,t)=>({...eh(t),action:eO(e[0],"prepare requires subcommand"),timeoutMs:t.timeoutMs}),open:(e,t)=>({...eh(t),app:e[0],url:e[1],surface:t.surface,activity:t.activity,launchConsole:t.launchConsole,launchArgs:t.launchArgs,relaunch:t.relaunch,saveScript:t.saveScript,deviceHub:t.deviceHub,noRecord:t.noRecord}),close:(e,t)=>({...eh(t),app:e[0],shutdown:t.shutdown,saveScript:t.saveScript}),install:al,reinstall:al,"install-from-source":(e,t)=>({...eh(t),source:function(e,t){let r=e[0]?.trim();if(e.length>1)throw new y("INVALID_ARGS","install-from-source accepts either one <url> positional or --github-actions-artifact");let n=t.githubActionsArtifact?function(e,t="--github-actions-artifact"){let r=e.indexOf(":");if(r<=0||r===e.length-1)throw new y("INVALID_ARGS",`${t} must use owner/repo:artifact, for example thymikee/RNCLI83:6635342232`);let{owner:n,repo:i}=ae(e.slice(0,r),t);return i7(n,i,e.slice(r+1),`${t} artifact`)}(t.githubActionsArtifact):void 0,i=t.installSource;if(1!=+!!r+ +!!n+ +!!i)throw new y("INVALID_ARGS","install-from-source requires exactly one source: <url>, --github-actions-artifact, or config installSource");if(!r&&t.header&&t.header.length>0)throw new y("INVALID_ARGS","install-from-source --header is only supported for URL sources");return n||i||{kind:"url",url:r,headers:function(e){if(!e||0===e.length)return;let t={};for(let r of e){let e=r.indexOf(":");if(e<=0)throw new y("INVALID_ARGS",`Invalid --header value "${r}". Expected "name:value".`);let n=r.slice(0,e).trim(),i=r.slice(e+1).trim();if(!n)throw new y("INVALID_ARGS",`Invalid --header value "${r}". Header name cannot be empty.`);t[n]=i}return t}(t.header)}}(e,t),retainPaths:t.retainPaths,retentionMs:t.retentionMs}),push:(e,t)=>({...eh(t),app:eO(e[0],"push requires bundleOrPackage"),payload:eO(e[1],"push requires payloadOrJson")}),"trigger-app-event":(e,t)=>({...eh(t),event:eO(e[0],"trigger-app-event requires event"),payload:e[1]?function(e,t){try{let t=JSON.parse(e);if(t&&"object"==typeof t&&!Array.isArray(t))return t}catch{}throw new y("INVALID_ARGS",`${t} must be a JSON object`)}(e[1],"trigger-app-event payload"):void 0})},as={devices:em(S.devices),boot:em(S.boot),shutdown:em(S.shutdown),prepare:em(S.prepare,e=>[eE(e.action,"prepare requires subcommand")]),apps:em(S.apps),open:em(S.open,function(e){return e.app?e.url?[e.app,e.url]:[e.app]:[]}),close:em(S.close,e=>eN(e.app)),install:em(S.install,e=>au(e.app,e.appPath)),reinstall:em(S.reinstall,e=>au(e.app,e.appPath)),"install-from-source":e=>ef(v.installSource,[],{...e,installSource:e.source,retainMaterializedPaths:e.retainPaths,materializedPathRetentionMs:e.retentionMs}),push:em(S.push,e=>{var t;return[(t=e).app,"string"==typeof t.payload?t.payload:JSON.stringify(t.payload)]}),"trigger-app-event":em(S.triggerAppEvent,e=>{var t;return[(t=e).event,...t.payload?[JSON.stringify(t.payload)]:[]]})};function al(e,t,r="install"){return{...eh(t),app:eO(e[0],`${r} requires app`),appPath:eO(e[1],`${r} requires path`)}}function au(e,t){return[eE(e,"missing first positional"),eE(t,"missing second positional")]}let ac=["path","start","stop","doctor","mark","clear"],ap="logs",ad="network",am=rd(ap,"Manage session app logs.",{action:F(ac),message:_(),restart:$()}),af=rd(ad,"Show recent HTTP traffic.",{action:F(["dump","log"]),limit:T(),include:F(o)}),ah=[am,af],ag=[eP(am,(e,t)=>e.observability.logs(t)),eP(af,(e,t)=>e.observability.network(t))],ay={[ap]:{usageOverride:"logs path | logs start | logs stop | logs clear [--restart] | logs doctor | logs mark [message...]",helpDescription:"Session app log info, start/stop streaming, diagnostics, and markers",summary:"Manage session app logs",positionalArgs:["path|start|stop|clear|doctor|mark","message?"],allowsExtraPositionals:!0,allowedFlags:["restart"]},[ad]:{usageOverride:"network dump [limit] [summary|headers|body|all] [--include summary|headers|body|all] | network log [limit] [summary|headers|body|all] [--include summary|headers|body|all]",helpDescription:"Dump recent HTTP(s) traffic parsed from the session app log",summary:"Show recent HTTP traffic",positionalArgs:["dump|log","limit?","include?"],allowedFlags:["networkInclude"]}},ab={logs:(e,t)=>({...eh(t),action:function(e){if(void 0!==e)return tF(ac,e,{message:"logs requires path, start, stop, doctor, mark, or clear"})}(e[0]),message:e.slice(1).join(" ")||void 0,restart:t.restart}),network:(e,t)=>({...eh(t),action:function(e){if(void 0!==e){if("dump"===e||"log"===e)return e;throw new y("INVALID_ARGS","network requires dump or log")}}(e[0]),limit:eL(e[1]),include:t.networkInclude??function(e){if(void 0!==e)return tF(o,e,{message:"network include must be summary, headers, body, or all"})}(e[2])})},aw={logs:em(ap,e=>{var t;return[(t=e).action??"path",...eN(t.message)]}),network:e=>{var t;return ef(ad,[...(t=e).action?[t.action]:[],...eR(t.limit)],{...e,networkInclude:e.include})}},av="perf",ax=rd(av,"Show session performance, frame health, and memory diagnostics.",{area:F(tG),subject:F(tB),action:F(tz),kind:F(tH),template:_("xctrace template name, for example Time Profiler."),out:_("Output artifact path."),tracePath:_("Existing .trace path to report, defaults to the latest session trace.")}),aS=[ax],ak=[eP(ax,(e,t)=>e.observability.perf(t))],aA={[av]:{usageOverride:"perf [metrics|frames|memory] [sample|snapshot]\n agent-device perf memory sample --json\n agent-device perf memory snapshot [--kind android-hprof|memgraph] [--out <path>]\n agent-device perf cpu profile start|stop|report --kind xctrace [--template <name>] --out <path>\n agent-device perf trace start|stop --kind xctrace [--template <name>] --out <path>\n agent-device perf cpu profile start|stop|report --kind simpleperf [--out <path>]\n agent-device perf trace start|stop --kind perfetto [--out <path>]",listUsageOverride:"perf [metrics|frames|memory] | perf cpu profile start|stop|report | perf trace start|stop",helpDescription:"Show session performance metrics, focused frame/jank health, memory diagnostics artifacts, Apple xctrace artifacts, or Android native Simpleperf/Perfetto artifacts. Bare perf and metrics are aliases for perf metrics. Native perf output is agent evidence: compact state, artifact path, and size only; raw profiles/traces stay on disk.",summary:"Show performance metrics or collect native perf artifacts",positionalArgs:["area?","subjectOrAction?","action?"],allowedFlags:["kind","perfTemplate","out"]}},aD={perf:(e,t)=>{var r;return{...eh(t),...function(e,t={}){if(void 0!==e[0]&&void 0===e[1]){let r=aL(e[0],{allowUndefined:!0});if(r)return{action:r,kind:aN(t.kind),out:t.out}}let r=function(e){if(void 0===e)return;let t=e.toLowerCase();if(t5(t))return t;throw new y("INVALID_ARGS",tQ)}(e[0]);return"cpu"===r?{area:r,subject:function(e){let t=e?.toLowerCase();if(void 0!==t&&t8(t))return t;throw new y("INVALID_ARGS",t0)}(e[1]),action:aL(e[2]),kind:aN(t.kind),template:t.template,out:t.out}:"trace"===r?{area:r,action:aL(e[1]),kind:aN(t.kind),template:t.template,out:t.out}:{area:r,action:aL(e[1]),kind:aN(t.kind),out:t.out}}(e,{kind:"string"==typeof(r=t.kind)?aN(r):void 0,template:t.perfTemplate,out:t.out})}}},aI={perf:em(av,e=>{var t;let r;return"cpu"===(r=(t=e).area??(t.action?"metrics":void 0))?aM([...eN(r),...eN(t.subject),...eN(t.action),...eN(t.kind)],t):"trace"===r?aM([...eN(r),...eN(t.action),...eN(t.kind)],t):[...eN(r),...eN(t.action)]})};function aM(e,t){let r=[...e];return(t.template||t.out||t.tracePath)&&r.push(t.template??""),(t.out||t.tracePath)&&r.push(t.out??""),t.tracePath&&r.push(t.tracePath),r}function aL(e,t={}){if(void 0===e)return;let r=e.toLowerCase();if(t3(r))return r;if(!t.allowUndefined)throw new y("INVALID_ARGS",tZ)}function aN(e){if(void 0===e)return;let t=e.toLowerCase();if(t4(t))return t;throw new y("INVALID_ARGS",t1)}let aR=/\b(logbox|redbox|reload js|copy stack|component stack|call stack|runtime error|open debugger to view warnings)\b/,aO=/\b(redbox|runtime error|reload js|copy stack|component stack|call stack)\b/,aE=[/\b[\w.$<>/-]+\.(?:tsx?|jsx?):\d+(?::\d+)?\b/,/\b[\w.$<>/-]+\.(?:tsx?|jsx?)\s+\(\d+:\d+\)/],aP=[/^!,\s+/,/^(warn|warning|error):\s+/,/\b(?:possible\s+)?unhandled (?:promise )?rejection\b/],a_=["open debugger to view warnings","getsnapshot should be cached to avoid an infinite loop",'unique "key" prop',"unique 'key' prop","virtualizedlists should never be nested","failed prop type"],aC=new Set(["x","\xd7","✕","✖","⨯"]);function aT(e){if(aF(e).detected)return"Hint: React Native warning/error overlay detected. It overlays part of the app and should be handled before interacting.\nRun: agent-device react-native dismiss-overlay\nThe command verifies the overlay is gone. Run agent-device snapshot -i afterward only when you need fresh refs for the next action."}function a$(e){return aF(e)}function aF(e){var t,r,n,i,o,s,l,u,c,p;let d,m,f,h,g,y,b,w,v=(d=(t=e).map(aq).join("\n").toLowerCase(),m=aQ(t,aH),f=aQ(t,aK),h=aQ(t,az,aJ),g=aQ(t,aB),y=(r=d,aE.some(e=>e.test(r))),b=aG(d),w=(n=d,i=m,o=f,i.length>0||o.length>0||/\b(reload js|copy stack)\b/.test(n)),{dismissNodes:m,minimizeNodes:f,collapsedNodes:h,redBox:(s=d,l=y,u=w,aO.test(s)||aG(s)||l&&u),detected:(c={text:d,hasReactNativeStackFrame:y,hasOverlayControl:w,hasControllessRedBoxText:b,collapsedNodes:h,openDebuggerWarningNodes:g}).collapsedNodes.length>0||c.openDebuggerWarningNodes.length>0||c.hasControllessRedBoxText||c.hasOverlayControl&&(p=c.text,aR.test(p)||c.hasReactNativeStackFrame)}),x=v.detected?function(e){let t=a0(e.dismissNodes,aZ);if(t){let e;var r,n=t,i=(r=t,(e=a2(r)?.trim().toLowerCase())&&aW(e)?"dismiss":"close");if(!n.rect)throw Error("React Native overlay target node must have rect");return{action:i,point:a(n.rect),rect:n.rect,ref:n.ref,label:a2(n)}}let o=a0(e.collapsedNodes.filter(aX),a1);return o?.rect?{action:"close-collapsed-banner",point:function(e){var t,r;if(!e.rect)throw Error("Collapsed React Native warning node must have rect");let n=Math.min(e.rect.height,52),i=Math.min(36,Math.max(18,.45*n));return{x:Math.round((t=e.rect.x+e.rect.width-i,r=e.rect.x+1,Math.min(e.rect.x+e.rect.width-1,Math.max(r,t)))),y:Math.round(e.rect.y+n/2)}}(o),rect:o.rect,ref:o.ref,label:a2(o)}:null}(v):null;return{detected:v.detected,redBox:v.redBox,dismissNodes:v.dismissNodes,minimizeNodes:v.minimizeNodes,collapsedNodes:v.collapsedNodes,primaryAction:x}}function aU(e){return[...e.dismissNodes,...e.minimizeNodes,...e.collapsedNodes]}function aj(e){var t;return az(e.label?.trim())&&!!(t=e.rect)&&t.x<=1&&t.y<=1&&t.width>=300&&t.height>=600}function aV(e,t){let r=e.label?.trim();return!!r&&!!aj(e)&&t.some(e=>e.label?.trim()===r&&aY(e))}function aq(e){return[e.label,e.value,e.identifier,e.type,e.role].filter(Boolean).join(" ")}function aG(e){return/\buncaught\b/.test(e)&&/unable to download asset/.test(e)}function az(e){let t=e?.trim().toLowerCase();return!!t&&(a_.some(e=>t.includes(e))||aP.some(e=>e.test(t)))}function aB(e){return e.includes("open debugger to view warnings")||/^!,\s+open debugger\b/.test(e)}function aH(e){var t,r;return aW(e)||(t=e,/^close(?:\s*\([^)]*\))?$/i.test(t))||(r=e,aC.has(r))}function aW(e){return/^dismiss(?:\s*\([^)]*\))?$/i.test(e)}function aK(e){return/^minimi[sz]e(?:\b|\s|\()/i.test(e)}function aJ(e){return!e.rect||e.rect.height<=180}function aX(e){let t=a2(e)?.trim().toLowerCase()??"";return(aB(t)||/^!,\s+/.test(t))&&aY(e)}function aY(e){return!!e.rect&&e.rect.width>=120&&e.rect.height>=36&&e.rect.height<=180}function aQ(e,t,r=()=>!0){let n=[];for(let i of e)i.ref&&r(i)&&[i.label,i.value,i.identifier].map(e=>e?.trim().toLowerCase()).filter(e=>!!e).some(e=>t(e))&&n.push(i);return n}function aZ(e){var t;let r;return[+(!0===(r=[e.type,e.role,e.subrole].join(" ").toLowerCase(),/\b(button|menuitem|link)\b/.test(r))),+(!0===e.hittable),-((t=e.rect)?t.width*t.height:1/0)]}function a0(e,t){let r=e.filter(e=>e.rect);return 0===r.length?null:r.sort((e,r)=>(function(e,t){for(let r=0;r<e.length;r+=1){let n=e[r]-t[r];if(0!==n)return n}return 0})(t(r),t(e)))[0]??null}function a1(e){return[+(!0===e.hittable),e.rect?.width??0,e.rect?.y??0]}function a2(e){return e.label??e.value??e.identifier}let a5="react-native",a3=rd(a5,"Run supported React Native app automation helpers.",{action:P(F(["dismiss-overlay"]))}),a8=eP(a3,(e,t)=>e.command.reactNative(t)),a4={[a5]:{usageOverride:"react-native dismiss-overlay",listUsageOverride:"react-native dismiss-overlay",positionalArgs:["dismiss-overlay"]}},a6={"react-native":(e,t)=>({...eh(t),action:function(e){if("dismiss-overlay"===e)return e;throw new y("INVALID_ARGS","react-native supports only: dismiss-overlay")}(e[0])})},a9={"react-native":em(a5,e=>[eE(e.action,"react-native requires action")])},a7="record",oe="trace",ot=["start","stop"],or=rd(a7,"Start or stop screen recording.",{action:P(F(ot)),path:_(),fps:T(),quality:j(R()),hideTouches:$()}),on=rd(oe,"Start or stop trace capture.",{action:P(F(ot)),path:_()}),oi=[or,on],oa=[eP(or,(e,t)=>e.recording.record(t)),eP(on,(e,t)=>e.recording.trace(t))],oo={[a7]:{usageOverride:"record start [path] [--fps <n>] [--quality <5-10>] [--hide-touches] | record stop",listUsageOverride:"record start [path] | record stop",helpDescription:"Start/stop screen recording; Android recordings longer than the 180s adb screenrecord limit are returned as multiple MP4 chunks",summary:"Start or stop screen recording",positionalArgs:["start|stop","path?"],allowedFlags:["fps","quality","hideTouches"]},[oe]:{usageOverride:"trace start <path> | trace stop <path>",listUsageOverride:"trace start <path> | trace stop <path>",helpDescription:"Start/stop trace log capture; when an artifact path is requested, pass the same positional path to start and stop",summary:"Start or stop trace capture",positionalArgs:["start|stop","path?"]}},os={record:(e,t)=>({...eh(t),action:oc(e[0],a7),path:e[1],fps:t.fps,quality:t.quality,hideTouches:t.hideTouches}),trace:(e,t)=>({...eh(t),action:oc(e[0],oe),path:e[1]})},ol={record:em(a7,e=>ou(e)),trace:em(oe,e=>ou(e))};function ou(e){return[e.action,...eN(e.path)]}function oc(e,t){if("start"===e||"stop"===e)return e;throw new y("INVALID_ARGS",`${t} requires start|stop`)}let op="replay",od="test",om=rd(op,"Replay a recorded session.",{path:P(_()),update:$(),backend:_(),maestro:$(),env:U()}),of=rd(od,"Run one or more replay scripts.",{paths:P(U()),update:$(),backend:_(),maestro:$(),env:U(),failFast:$(),timeoutMs:T(),retries:T(),recordVideo:$(),artifactsDir:_(),reportJunit:_(),shardAll:T(),shardSplit:T()}),oh=[om,of],og=[eP(om,(e,t)=>e.replay.run(t)),eP(of,(e,t)=>e.replay.test(t))],oy={[op]:{usageOverride:"replay <path> | replay export <file.ad> [--format maestro] [--out <path>]",positionalArgs:["path"],allowsExtraPositionals:!0,allowedFlags:["replayMaestro","replayExportFormat",...ro,"timeoutMs","out"]},[od]:{usageOverride:"test <path-or-glob>...",listUsageOverride:"test <path-or-glob>...",helpDescription:"Run one or more replay scripts as a serial test suite",summary:"Run replay test suites",positionalArgs:["pathOrGlob"],allowsExtraPositionals:!0,allowedFlags:["replayMaestro",...ro,"failFast","timeoutMs","retries","recordVideo","artifactsDir","reportJunit","shardAll","shardSplit"]}},ob={replay:(e,t)=>({...eh(t),path:eO(e[0],"replay requires path"),update:t.replayUpdate,backend:t.replayMaestro?"maestro":void 0,env:t.replayEnv}),test:(e,t)=>({...eh(t),paths:e,update:t.replayUpdate,backend:t.replayMaestro?"maestro":void 0,env:t.replayEnv,failFast:t.failFast,timeoutMs:t.timeoutMs,retries:t.retries,recordVideo:t.recordVideo,artifactsDir:t.artifactsDir,reportJunit:t.reportJunit,shardAll:t.shardAll,shardSplit:t.shardSplit})},ow={replay:e=>ef(op,[eE(e.path,"replay requires path")],{...e,replayUpdate:e.update,replayBackend:ov(e),replayEnv:e.env,replayShellEnv:ox(process.env)}),test:e=>ef(od,e.paths??[],{...e,replayUpdate:e.update,replayBackend:ov(e),replayEnv:e.env,replayShellEnv:ox(process.env)})};function ov(e){return e.backend??(!0===e.maestro?"maestro":void 0)}function ox(e){let t={};for(let[r,n]of Object.entries(e))"string"==typeof n&&r.startsWith("AD_VAR_")&&(t[r]=n);return t}function oS(e){if(void 0===e)throw new y("INVALID_ARGS","rotate requires an orientation argument. Use portrait|portrait-upside-down|landscape-left|landscape-right.");switch(e?.trim().toLowerCase()){case"portrait":return"portrait";case"portrait-upside-down":case"upside-down":return"portrait-upside-down";case"landscape-left":case"left":return"landscape-left";case"landscape-right":case"right":return"landscape-right";default:throw new y("INVALID_ARGS",`Invalid rotation: ${e}. Use portrait|portrait-upside-down|landscape-left|landscape-right.`)}}let ok="appstate",oA="back",oD="home",oI="rotate",oM="app-switcher",oL="keyboard",oN="clipboard",oR=rd(ok,"Show foreground app or activity.",{}),oO=rd(oA,"Navigate back.",{mode:F(["in-app","system"])}),oE=rd(oD,"Go to the home screen.",{}),oP=rd(oI,"Rotate device orientation.",{orientation:P(F(["portrait","portrait-upside-down","landscape-left","landscape-right"]))}),o_=rd(oM,"Open the app switcher.",{}),oC=rd(oL,"Inspect or dismiss the keyboard.",{action:F(["status","dismiss"])}),oT=rd(oN,"Read or write clipboard text.",{action:P(F(["read","write"])),text:_()}),o$=[oR,oO,oE,oP,o_,oC,oT],oF=[eP(oR,(e,t)=>e.command.appState(t)),eP(oO,(e,t)=>e.command.back(t)),eP(oE,(e,t)=>e.command.home(t)),eP(oP,(e,t)=>e.command.rotate(t)),eP(o_,(e,t)=>e.command.appSwitcher(t)),eP(oC,(e,t)=>e.command.keyboard(t)),eP(oT,(e,t)=>e.command.clipboard(t))],oU={[ok]:{helpDescription:"Show foreground app/activity"},[oA]:{usageOverride:"back [--in-app|--system]",allowedFlags:["backMode"]},[oI]:{usageOverride:"rotate <portrait|portrait-upside-down|landscape-left|landscape-right>",helpDescription:"Rotate device orientation on iOS and Android",positionalArgs:["orientation"]},[oL]:{usageOverride:"keyboard [status|get|dismiss|enter|return]",helpDescription:"Inspect Android keyboard visibility/type or press/dismiss the device keyboard",summary:"Inspect, press, or dismiss the device keyboard",positionalArgs:["action?"]},[oN]:{usageOverride:"clipboard read | clipboard write <text>",listUsageOverride:"clipboard read | clipboard write <text>",helpDescription:"Read or write device clipboard text",positionalArgs:["read|write","text?"],allowsExtraPositionals:!0}},oj={appstate:(e,t)=>eh(t),home:(e,t)=>eh(t),"app-switcher":(e,t)=>eh(t),back:(e,t)=>({...eh(t),mode:t.backMode}),rotate:(e,t)=>({...eh(t),orientation:oS(e[0])}),keyboard:(e,t)=>({...eh(t),...function(e){if(e.length>1)throw new y("INVALID_ARGS","keyboard accepts at most one action argument.");return el({action:function(e){let t=e?.toLowerCase();if("get"===t)return"status";if(void 0===t||"status"===t||"dismiss"===t||"enter"===t||"return"===t)return t;throw new y("INVALID_ARGS","keyboard action must be status, get, dismiss, enter, or return.")}(e[0])})}(e)}),clipboard:(e,t)=>({...eh(t),...function(e){let t=e[0]?.toLowerCase();if("read"!==t&&"write"!==t)throw new y("INVALID_ARGS","clipboard requires a subcommand: read or write.");if("read"===t){if(1!==e.length)throw new y("INVALID_ARGS","clipboard read does not accept additional arguments.");return{action:t}}if(e.length<2)throw new y("INVALID_ARGS","clipboard write requires text.");return{action:t,text:e.slice(1).join(" ")}}(e)})},oV={appstate:em(ok),back:e=>{var t;return ef(oA,[],{...e,backMode:"in-app"===(t=e.mode)||"system"===t?t:void 0})},home:em(oD),rotate:em(oI,e=>[eE(e.orientation,"rotate requires orientation")]),"app-switcher":em(oM),keyboard:em(oL,e=>eN(e.action)),clipboard:em(oN,e=>{var t;return"read"===(t=e).action?["read"]:["write",t.text]})};export{rl as GLOBAL_FLAG_KEYS,ac as LOG_ACTION_VALUES,t9 as MAESTRO_COMPAT_TRACKER_URL,t7 as MAESTRO_NEW_ISSUE_URL,rn as METRO_PREPARE_FLAGS,ri as METRO_RELOAD_FLAGS,tZ as PERF_ACTION_ERROR_MESSAGE,tQ as PERF_AREA_ERROR_MESSAGE,t1 as PERF_KIND_ERROR_MESSAGE,t2 as PERF_MEMORY_KIND_ERROR_MESSAGE,t0 as PERF_SUBJECT_ERROR_MESSAGE,e_ as SCREENSHOT_ACTION_FLAG_KEYS,r7 as SCROLL_DIRECTIONS,rI as SETTINGS_INVALID_ARGS_MESSAGE,nt as SWIPE_PATTERNS,aF as analyzeReactNativeOverlay,n2 as annotateCoveredSnapshotNodes,ao as appCliReaders,as as appDaemonWriters,e$ as appendScreenshotScriptFlags,nY as areRectsApproximatelyEqual,na as assertScrollGestureInput,t_ as batchCliReaders,tP as batchCliSchemas,tE as batchCommandDefinition,tO as batchCommandMetadata,$ as booleanField,tM as buildFlags,tL as buildMeta,nM as buildMobileSnapshotPresentation,ni as buildScrollGesturePlan,no as buildSwipeGesturePlan,ns as buildSwipePresetGesturePlan,r9 as buttonTag,r5 as captureCliReaders,r2 as captureCliSchemas,r1 as captureCommandDefinitions,r0 as captureCommandMetadata,r3 as captureDaemonWriters,nC as captureScrollEdgeState,np as clampGesturePoint,ny as clampToRange,eh as commonInputFromFlags,tR as createBatchDaemonWriter,eP as defineExecutableCommand,rd as defineFieldCommandMetadata,nL as deriveMobileSnapshotHiddenContentHints,a$ as detectReactNativeOverlay,nI as displayNodeLabel,F as enumField,ib as focusCommand,aT as formatReactNativeOverlayWarning,n$ as formatScrollEdgeMessage,iK as gestureCliReaders,iJ as gestureDaemonWriters,r6 as getClickButtonValidationError,rc as getFlagDefinition,rp as getFlagDefinitions,rL as getUnsupportedMacOsSettingMessage,nu as inferGestureReferenceFrame,nk as inferVerticalScrollIndicatorDirections,T as integerField,i0 as interactionCliReaders,i8 as interactionCliSchemas,i4 as interactionCommandDefinitions,iB as interactionCommandMetadata,i1 as interactionDaemonWriters,rM as isMacOsSettingSupported,nR as isNodeVisibleInEffectiveViewport,t3 as isPerfAction,t5 as isPerfArea,t4 as isPerfKind,t6 as isPerfMemoryKind,t8 as isPerfSubject,aj as isReactNativeCollapsedWarningWrapperCandidate,aV as isReactNativeCollapsedWarningWrapperWithVisibleBanner,n5 as isSnapshotNodeInteractionBlocked,ez as isSparseSnapshotQualityVerdict,t$ as isStringMember,nS as isSystemScrollIndicatorLabel,j as jsonSchemaField,iw as longPressCommand,ai as managementCliSchemas,an as managementCommandDefinitions,ar as managementCommandMetadata,th as normalizeDeployResult,tb as normalizeDevice,tg as normalizeInstallFromSourceResult,ty as normalizeMaterializationReleaseResult,tk as normalizeOpenDevice,tS as normalizeRuntimeHints,tw as normalizeSession,nA as normalizeSnapshotTree,tA as normalizeStartupSample,nB as now,ab as observabilityCliReaders,ay as observabilityCliSchemas,ag as observabilityCommandDefinitions,ah as observabilityCommandMetadata,aw as observabilityDaemonWriters,oS as parseDeviceRotation,i9 as parseInstallSourceConfig,nd as parseScrollDirection,tq as parseSessionSurface,tF as parseStringMember,nl as parseSwipePreset,tC as parseTimeout,tT as parseWaitPositionals,tm as parsing_stripUndefined,aD as perfCliReaders,aA as perfCliSchemas,ak as perfCommandDefinitions,aS as perfCommandMetadataList,aI as perfDaemonWriters,ik as pinchCommand,nc as pointFromPercent,nQ as pointInsideRect,eW as publicSnapshotCaptureAnnotations,a6 as reactNativeCliReaders,a4 as reactNativeCliSchemas,a8 as reactNativeCommandDefinition,a3 as reactNativeCommandMetadata,a9 as reactNativeDaemonWriters,eY as readCommandMessage,iQ as readFillTargetFromPositionals,rN as readLocationCoordinate,tr as readOptionalString,aU as readReactNativeOverlayActionNodes,tt as readRequiredString,tI as readScreenshotOverlayRefs,eF as readScreenshotScriptFlag,eK as readSerializedSnapshotCaptureAnnotations,tD as readSnapshotNodes,eG as readSnapshotQualityVerdict,os as recordingCliReaders,oo as recordingCliSchemas,oa as recordingCommandDefinitions,oi as recordingCommandMetadata,ol as recordingDaemonWriters,eB as renderSnapshotQualityWarnings,ob as replayCliReaders,oy as replayCliSchemas,og as replayCommandDefinitions,oh as replayCommandMetadataList,ow as replayDaemonWriters,nb as requireIntInRange,rR as requireLocationCoordinates,P as requiredField,n7 as resolveActionableTouchNode,ie as resolveActionableTouchResolution,r4 as resolveClickButton,e5 as resolveDeployResultTarget,e8 as resolveInstallFromSourceResultTarget,ir as resolveInteractionTarget,nJ as resolveRectCenter,tN as resolveSessionName,nT as runScrollEdgePasses,eT as screenshotFlagsFromOptions,eC as screenshotOptionsFromFlags,iv as scrollCommand,i2 as selectorCliReaders,i5 as selectorDaemonWriters,e9 as serializeCloseResult,e3 as serializeDeployResult,e2 as serializeDevice,e4 as serializeInstallFromSourceResult,e6 as serializeOpenResult,e1 as serializeSessionListEntry,e7 as serializeSnapshotResult,nH as sleep,eH as snapshotCaptureAnnotationsFrom,tf as splitNonEmptyTrimmedLines,_ as stringField,N as stringSchema,eJ as successText,ix as swipeCommand,oj as systemCliReaders,oU as systemCliSchemas,oF as systemCommandDefinitions,o$ as systemCommandMetadata,oV as systemDaemonWriters,nz as toBackendContext,nW as toBackendResult,eX as withSuccessText};
|
|
1
|
+
var e;import{DEVICE_TARGETS as t,findNodeByRef as r,normalizeRef as n,PLATFORM_SELECTORS as i,centerOfRect as a,NETWORK_INCLUDE_MODES as o}from"./9616.js";import{splitSelectorFromArgs as s,findNearestHittableAncestor as l,tryParseSelectorChain as u,buildSelectorChainForNode as c,parseSelectorChain as p,findNodeByLabel as d,resolveRefLabel as m,resolveSelectorChain as f,formatSelectorFailure as h,normalizeType as g}from"./7847.js";import{AppError as y}from"./9152.js";import{STRUCTURED_BATCH_COMMAND_NAMES as b,readStructuredBatchCommandName as w,INTERNAL_COMMANDS as v,GESTURE_KINDS as x,PUBLIC_COMMANDS as S}from"./6088.js";import{intersectArea as k,isScrollableNodeLike as A}from"./4778.js";import{FIND_LOCATORS as D}from"./7556.js";import{DEFAULT_APPS_FILTER as I,assertResolvedAppsFilter as M}from"./3675.js";let L=["ref","selector","point"];function N(e){return{type:"string",...e?{description:e}:{}}}function R(e){return{type:"integer",...e?{description:e}:{}}}function O(e){return{type:"boolean",...e?{description:e}:{}}}function E(e){return{type:"object",additionalProperties:!0,...e?{description:e}:{}}}function P(e){return{...e,required:!0}}function _(e){return eu(N(e),Y)}function C(e){return eu({type:"number",...e?{description:e}:{}},Z)}function T(e,t={}){var r,n;return eu((r=e,n=t,{...R(r),...void 0===n.min?{}:{minimum:n.min},...void 0===n.max?{}:{maximum:n.max}}),(e,r)=>ee(e,r,t))}function $(e){return eu(O(e),et)}function F(e,t){return eu({type:"string",enum:e,...t?{description:t}:{}},(t,r)=>en(t,r,e))}function U(e){return eu({type:"array",items:{type:"string"},...e?{description:e}:{}},ec)}function j(e){return eu(e,(e,t)=>e[t])}function V(){return eu({oneOf:[...ep(),{type:"object",properties:{kind:{type:"string",const:"point"},x:{type:"number"},y:{type:"number"}},required:["kind","x","y"],additionalProperties:!1}],description:"UI target. This is separate from deviceTarget, which selects the device form."},(e,t)=>void 0===e[t]?void 0:function(e,t){let r=ed(e,t),n=er(r,"kind",L);switch(n){case"ref":return{kind:n,ref:X(r,"ref"),label:Y(r,"label")};case"selector":return{kind:n,selector:X(r,"selector")};case"point":return{kind:n,x:Q(r,"x"),y:Q(r,"y")}}}(e,t))}function q(e){return eu({type:"object",description:e,properties:{x:{type:"number"},y:{type:"number"}},required:["x","y"],additionalProperties:!1},(e,t)=>void 0===e[t]?void 0:J(e,t))}function G(){return{depth:T("Snapshot traversal depth.",{min:0}),scope:_("Snapshot scope selector used before resolution."),raw:$("Use raw snapshot data during selector resolution.")}}function z(){return{count:T("Number of press/click repetitions.",{min:1}),intervalMs:T("Delay between repeated press/click actions.",{min:0}),holdMs:T("Hold duration for each action.",{min:0}),jitterPx:T("Randomization radius in pixels.",{min:0}),doubleTap:$("Request a double-tap action.")}}function B(e){return function(e,r=[]){return{type:"object",properties:{session:{type:"string",description:"Agent-device session name."},platform:{type:"string",enum:i,description:"Platform selector used to resolve a device."},deviceTarget:{type:"string",enum:t,description:"Device target form. Maps to the CLI --target flag."},target:{type:"string",enum:t,description:"Alias for deviceTarget on commands without a UI target field. Interaction commands reserve target for the UI element."},device:{type:"string",description:"Device name selector."},udid:{type:"string",description:"iOS device UDID selector."},serial:{type:"string",description:"Android serial selector."},iosSimulatorDeviceSet:{type:"string",description:"iOS simulator device-set path used for device resolution."},androidDeviceAllowlist:{type:"string",description:"Android serial allowlist used for device resolution."},daemonBaseUrl:{type:"string",description:"Remote daemon base URL."},daemonAuthToken:{type:"string",description:"Remote daemon auth token."},tenant:{type:"string",description:"Remote tenant identifier."},runId:{type:"string",description:"Lease run identifier."},leaseId:{type:"string",description:"Existing lease identifier."},cwd:{type:"string",description:"Working directory for command execution."},debug:{type:"boolean",description:"Enable debug diagnostics."},...e},...r.length>0?{required:r}:{},additionalProperties:!1}}(Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.schema])),Object.entries(e).flatMap(([e,t])=>t.required?[e]:[]))}function H(e,t){let r=W(e),n=Object.fromEntries(Object.entries(t).flatMap(([e,t])=>{let n=t.read(r,e);if(t.required&&void 0===n)throw Error(`Expected ${e} to be set.`);return void 0===n?[]:[[e,n]]})),i=K(r,{readTargetAlias:!Object.hasOwn(t,"target")});return el({...i,...ei(i),...n})}function W(e){if(null==e)return{};if(!e||"object"!=typeof e||Array.isArray(e))throw Error("Expected object arguments.");return e}function K(e,r={}){return{session:Y(e,"session"),platform:en(e,"platform",i),deviceTarget:function(e,r){let n=en(e,"deviceTarget",t);if(!1===r.readTargetAlias||void 0===e.target)return n;let i=en(e,"target",t);if(void 0!==n&&i!==n)throw Error("Expected target alias to match deviceTarget when both are set.");return n??i}(e,r),device:Y(e,"device"),udid:Y(e,"udid"),serial:Y(e,"serial"),iosSimulatorDeviceSet:Y(e,"iosSimulatorDeviceSet"),androidDeviceAllowlist:Y(e,"androidDeviceAllowlist"),daemonBaseUrl:Y(e,"daemonBaseUrl"),daemonAuthToken:Y(e,"daemonAuthToken"),tenant:Y(e,"tenant"),runId:Y(e,"runId"),leaseId:Y(e,"leaseId"),cwd:Y(e,"cwd"),debug:et(e,"debug")}}function J(e,t){let r=ed(e,t);return{x:Q(r,"x"),y:Q(r,"y")}}function X(e,t){let r=e[t];if("string"!=typeof r||0===r.length)throw Error(`Expected ${t} to be a non-empty string.`);return r}function Y(e,t){let r=e[t];if(void 0!==r){if("string"!=typeof r||0===r.length)throw Error(`Expected ${t} to be a non-empty string.`);return r}}function Q(e,t){let r=e[t];if("number"!=typeof r||!Number.isFinite(r))throw Error(`Expected ${t} to be a finite number.`);return r}function Z(e,t){let r=e[t];if(void 0!==r){if("number"!=typeof r||!Number.isFinite(r))throw Error(`Expected ${t} to be a finite number.`);return r}}function ee(e,t,r={}){let n=e[t];if(void 0!==n){if(!Number.isInteger(n))throw Error(`Expected ${t} to be an integer.`);if(void 0!==r.min&&n<r.min)throw Error(`Expected ${t} to be at least ${r.min}.`);if(void 0!==r.max&&n>r.max)throw Error(`Expected ${t} to be at most ${r.max}.`);return n}}function et(e,t){let r=e[t];if(void 0!==r){if("boolean"!=typeof r)throw Error(`Expected ${t} to be a boolean.`);return r}}function er(e,t,r){let n=e[t];if("string"!=typeof n||!r.includes(n))throw Error(`Expected ${t} to be one of: ${r.join(", ")}.`);return n}function en(e,t,r){let n=e[t];if(void 0!==n){if("string"!=typeof n||!r.includes(n))throw Error(`Expected ${t} to be one of: ${r.join(", ")}.`);return n}}function ei(e){return el({session:e.session,platform:e.platform,target:e.deviceTarget,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,androidDeviceAllowlist:e.androidDeviceAllowlist,daemonBaseUrl:e.daemonBaseUrl,daemonAuthToken:e.daemonAuthToken,tenant:e.tenant,runId:e.runId,leaseId:e.leaseId,cwd:e.cwd,debug:e.debug})}function ea(e){switch(e.kind){case"ref":return{ref:e.ref,label:e.label};case"selector":return{selector:e.selector};case"point":return{x:e.x,y:e.y}}}function eo(e){return{count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap}}function es(e){return{depth:e.depth,scope:e.scope,raw:e.raw}}function el(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e))}function eu(e,t){return{schema:e,required:!1,read:t}}function ec(e,t){let r=e[t];if(void 0!==r){if(!Array.isArray(r)||r.some(e=>"string"!=typeof e))throw Error(`Expected ${t} to be an array of strings.`);return r}}function ep(){return[{type:"object",properties:{kind:{type:"string",const:"ref"},ref:{type:"string",description:"Snapshot element ref such as @e12."},label:{type:"string",description:"Optional human label for the ref."}},required:["kind","ref"],additionalProperties:!1},{type:"object",properties:{kind:{type:"string",const:"selector"},selector:{type:"string",description:"Agent-device selector expression."}},required:["kind","selector"],additionalProperties:!1}]}function ed(e,t){let r=e[t];if(!r||"object"!=typeof r||Array.isArray(r))throw Error(`Expected ${t} to be an object.`);return r}function em(e,t){return r=>ef(e,t?t(r):[],r)}function ef(e,t,r){return{command:e,positionals:t,options:function(e){var t;let r="mobile"===(t=e.deviceTarget??e.target)||"tv"===t||"desktop"===t?t:void 0;if(void 0===r&&void 0===e.target)return e;let{target:n,...i}=e;return void 0===r?i:{...i,target:r}}(r)}}function eh(e){return el({session:e.session,platform:e.platform,deviceTarget:e.target,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,androidDeviceAllowlist:e.androidDeviceAllowlist})}function eg(e){return{platform:e.platform,target:e.target,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,androidDeviceAllowlist:e.androidDeviceAllowlist}}function ey(e){return el({depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw})}function eb(e){return{depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw}}function ew(e){return el({count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap})}function ev(e){return"ref"in e&&void 0!==e.ref?el({kind:"ref",ref:e.ref,label:e.label}):"selector"in e&&void 0!==e.selector?{kind:"selector",selector:e.selector}:{kind:"point",x:e.x,y:e.y}}function ex(e){let t=eS(e);if("string"==typeof t.ref)return[t.ref,...eA(t.label)];if("string"==typeof t.selector)return[t.selector];if("point"===t.kind||void 0!==t.x||void 0!==t.y)return[String(ek(t.x,"x")),String(ek(t.y,"y"))];throw new y("INVALID_ARGS","interaction requires @ref, selector, or point target")}function eS(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new y("INVALID_ARGS","Expected target object.");let t=e.target;return t&&"object"==typeof t&&!Array.isArray(t)?t:e}function ek(e,t){if("number"!=typeof e||!Number.isFinite(e))throw new y("INVALID_ARGS",`point target requires numeric ${t}.`);return e}function eA(e){return"string"==typeof e&&e.length>0?[e]:[]}function eD(...e){return new Set(e)}function eI(e,t){return void 0!==e&&t.has(e)}function eM(e){return void 0!==e&&""!==e.trim()&&Number.isFinite(Number(e))}function eL(e){return void 0===e?void 0:Number(e)}function eN(e){return void 0===e?[]:[e]}function eR(e){return void 0===e?[]:[String(e)]}function eO(e,t){if(void 0===e||""===e)throw new y("INVALID_ARGS",t);return e}function eE(e,t){if("string"!=typeof e||0===e.length)throw new y("INVALID_ARGS",t);return e}function eP(e,t){return{...e,run:t,invoke:async(r,n)=>await t(r,e.readInput(n))}}let e_=["screenshotFullscreen","screenshotMaxSize","screenshotNoStabilize"];function eC(e){return eU({overlayRefs:e?.overlayRefs,fullscreen:e?.screenshotFullscreen,maxSize:e?.screenshotMaxSize,stabilize:!e?.screenshotNoStabilize&&void 0})}function eT(e={}){return eU({overlayRefs:e.overlayRefs,screenshotFullscreen:e.screenshotFullscreen??e.fullscreen,screenshotMaxSize:e.screenshotMaxSize??e.maxSize,screenshotNoStabilize:e.screenshotNoStabilize??(!1===e.stabilize||void 0)})}function e$(e,t){t?.screenshotFullscreen&&e.push("--fullscreen"),"number"==typeof t?.screenshotMaxSize&&e.push("--max-size",String(t.screenshotMaxSize)),t?.screenshotNoStabilize&&e.push("--no-stabilize")}function eF(e){let{args:t,flags:r,index:n}=e,i=t[n];if("--fullscreen"===i)return r.screenshotFullscreen=!0,{handled:!0,nextIndex:n};if("--no-stabilize"===i)return r.screenshotNoStabilize=!0,{handled:!0,nextIndex:n};if("--max-size"===i){let e=t[n+1],i=void 0===e?NaN:Number(e);if(!Number.isInteger(i)||i<1)throw new y("INVALID_ARGS","screenshot --max-size requires a positive integer");return r.screenshotMaxSize=i,{handled:!0,nextIndex:n+1}}return{handled:!1}}function eU(e){return Object.fromEntries(Object.entries(e).filter(e=>void 0!==e[1]))}let ej=new Set(["healthy","recovered","sparse"]),eV=new Set(["tree","queries","private-ax"]),eq=new Set(["ax-rejected","sparse-tree","budget","no-nodes","capture-failed"]);function eG(e){if(e&&"object"==typeof e){if("string"==typeof e.state&&ej.has(e.state)&&"string"==typeof e.backend&&eV.has(e.backend))return{state:e.state,backend:e.backend,reason:"string"==typeof e.reason?e.reason:void 0,reasonCode:"string"==typeof e.reasonCode&&eq.has(e.reasonCode)?e.reasonCode:void 0,effectiveDepth:"number"==typeof e.effectiveDepth?e.effectiveDepth:void 0,collapsedLeafIndexes:Array.isArray(e.collapsedLeafIndexes)?e.collapsedLeafIndexes.filter(e=>"number"==typeof e):void 0}}}function ez(e){return e?.state==="sparse"}function eB(e,t){var r;return[...function(e){if("recovered"===e.state){let t="budget"===e.reasonCode?" The primary capture ran out of its time budget (busy app or simulator); the recovered tree is authoritative for this screen.":" This usually means the app publishes an unhealthy accessibility tree — fixing the app's accessibility is the real cure. Treat screenshot as visual truth when this warning appears.";return[`Recovered this snapshot with the ${e.backend} accessibility backend`+(e.reason?` after: ${e.reason}.`:".")+t]}return"sparse"===e.state?["No snapshot backend could read this screen"+(e.reason?` (${e.reason})`:"")+". Use screenshot as visual truth and coordinate taps; retry snapshot after navigating."]:[]}(e),...void 0===(r=e).effectiveDepth?[]:[`The accessibility server rejected deeper requests; this tree is capped at depth ${r.effectiveDepth} — re-run with --depth ${r.effectiveDepth} --scope <container> for deeper content.`],...function(e,t){let r=[];for(let n of e.collapsedLeafIndexes??[]){let e=t.find(e=>e.index===n);if(!e)continue;let i=e.identifier?` (${e.identifier})`:"";r.push(`@${e.ref} [${e.type??"element"}]${i} merges many labels into a single accessibility element. The app likely marks a container as accessible, which hides every descendant from assistive tech and automation — the children cannot be addressed individually. Fix the app's accessibility (mark the rows, not the container); until then use screenshot as visual truth and coordinate taps.`)}return r}(e,t)]}function eH(e){let t=eG(e.quality);return{...e.analysis?{analysis:e.analysis}:{},...e.androidSnapshot?{androidSnapshot:e.androidSnapshot}:{},...e.freshness?{freshness:e.freshness}:{},...t?{quality:t}:{},...e.warnings?{warnings:e.warnings}:{}}}function eW(e){return{...e.androidSnapshot?{androidSnapshot:e.androidSnapshot}:{},...e.quality?{snapshotQuality:e.quality}:{},...e.warnings&&e.warnings.length>0?{warnings:e.warnings}:{}}}function eK(e){var t;let r="object"==typeof(t=e.androidSnapshot)&&null!==t?t:void 0,n=Array.isArray(e.warnings)?e.warnings.filter(e=>"string"==typeof e):void 0,i=eG(e.snapshotQuality);return eW({...r?{androidSnapshot:r}:{},...i?{quality:i}:{},...n?{warnings:n}:{}})}function eJ(e){return e?{message:e}:{}}function eX(e,t){return t?{...e,message:t}:e}function eY(e){return"string"==typeof e?.message&&e.message.length>0?e.message:null}function eQ(e){let t=e.appId??e.bundleId??e.packageName;return{session:e.session,appId:t,appBundleId:e.bundleId,package:e.packageName}}function eZ(e,t,r){return{deviceId:t,deviceName:r,..."android"===e?{serial:t}:"ios"===e?{udid:t}:{}}}function e0(e,t={}){let r=t.includeAndroidSerial??!0;return{platform:e.platform,target:e.target,device:e.name,id:e.id,..."ios"===e.platform?{device_udid:e.ios?.udid??e.id,ios_simulator_device_set:e.ios?.simulatorSetPath??null}:{},..."android"===e.platform&&r?{serial:e.android?.serial??e.id}:{}}}function e1(e){return{name:e.name,...e.sessionStateDir?{sessionStateDir:e.sessionStateDir}:{},...e.runnerLogPath?{runnerLogPath:e.runnerLogPath}:{},...e0(e.device,{includeAndroidSerial:!1}),createdAt:e.createdAt}}function e2(e){return{platform:e.platform,id:e.id,name:e.name,kind:e.kind,target:e.target,..."boolean"==typeof e.booted?{booted:e.booted}:{}}}function e5(e){return e.bundleId??e.package??e.app}function e3(e){return eX({app:e.app,appPath:e.appPath,platform:e.platform,...e.appId?{appId:e.appId}:{},...e.bundleId?{bundleId:e.bundleId}:{},...e.package?{package:e.package}:{}},`Installed: ${e5(e)}`)}function e8(e){return e.appName??e.bundleId??e.packageName??e.launchTarget}function e4(e){return eX({launchTarget:e.launchTarget,...e.appName?{appName:e.appName}:{},...e.appId?{appId:e.appId}:{},...e.bundleId?{bundleId:e.bundleId}:{},...e.packageName?{package:e.packageName}:{},...e.installablePath?{installablePath:e.installablePath}:{},...e.archivePath?{archivePath:e.archivePath}:{},...e.materializationId?{materializationId:e.materializationId}:{},...e.materializationExpiresAt?{materializationExpiresAt:e.materializationExpiresAt}:{}},`Installed: ${e8(e)}`)}function e6(e){let t=e.appName??e.appBundleId??e.session;return eX({session:e.session,...e.sessionStateDir?{sessionStateDir:e.sessionStateDir}:{},...e.runnerLogPath?{runnerLogPath:e.runnerLogPath}:{},...e.requestLogPath?{requestLogPath:e.requestLogPath}:{},...e.appName?{appName:e.appName}:{},...e.appBundleId?{appBundleId:e.appBundleId}:{},...e.startup?{startup:e.startup}:{},...e.runtime?{runtime:e.runtime}:{},...e.device?e0(e.device):{}},t?`Opened: ${t}`:"Opened")}function e9(e){return{session:e.session,...e.shutdown?{shutdown:e.shutdown}:{},...eJ(e.session?`Closed: ${e.session}`:"Closed")}}function e7(e){var t;return{nodes:e.nodes,truncated:e.truncated,...e.appName?{appName:e.appName}:{},...e.appBundleId?{appBundleId:e.appBundleId}:{},...e.visibility?{visibility:e.visibility}:{},...eW({...t=e,...t.snapshotQuality?{quality:t.snapshotQuality}:{}}),...e.unchanged?{unchanged:e.unchanged}:{},...e.snapshotDiagnostics?{snapshotDiagnostics:e.snapshotDiagnostics}:{}}}function te(e,t,r,n){let i=r(e[t]);if(void 0===i)throw new y("COMMAND_FAILED",n,{response:e});return i}function tt(e,t){return te(e,t,tl,`Daemon response is missing "${t}".`)}function tr(e,t){return tl(e[t])}function tn(e,t){var r;let n;return r=tl,null===(n=e[t])?null:r(n)}function ti(e,t){return te(e,t,tc,`Daemon response has invalid "${t}".`)}function ta(e,t){return function(e){return"tv"===e||"mobile"===e||"desktop"===e?e:void 0}(e[t])??"mobile"}function to(e,t){let r=e[t];if(!td(r))return;let n=ts(r,"x"),i=ts(r,"y"),a=ts(r,"width"),o=ts(r,"height");if(void 0!==n&&void 0!==i&&void 0!==a&&void 0!==o)return{x:n,y:i,width:a,height:o}}function ts(e,t){let r=e[t];return"number"==typeof r?r:void 0}function tl(e){return"string"==typeof e&&e.length>0?e:void 0}function tu(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function tc(e){return"ios"===e||"macos"===e||"android"===e||"linux"===e?e:void 0}function tp(e){return"simulator"===e||"emulator"===e||"device"===e?e:void 0}function td(e){return"object"==typeof e&&null!==e}function tm(e){let t={};for(let[r,n]of Object.entries(e))void 0!==n&&(t[r]=n);return t}function tf(e){return e.split("\n").map(e=>e.trim()).filter(e=>e.length>0)}function th(e,t){let r=tr(e,"bundleId"),n=tr(e,"package");return{app:tt(e,"app"),appPath:tt(e,"appPath"),platform:ti(e,"platform"),appId:r??n,bundleId:r,package:n,identifiers:eQ({session:t,bundleId:r,packageName:n})}}function tg(e,t){let r=tr(e,"bundleId"),n=tr(e,"packageName"),i=r??n??tr(e,"appId"),a=tr(e,"launchTarget")??n??r??i;if(!a)throw new y("COMMAND_FAILED",'Daemon response is missing "launchTarget".',{response:e});return{appName:tr(e,"appName"),appId:i,bundleId:r,packageName:n,launchTarget:a,installablePath:tr(e,"installablePath"),archivePath:tr(e,"archivePath"),materializationId:tr(e,"materializationId"),materializationExpiresAt:tr(e,"materializationExpiresAt"),identifiers:eQ({session:t,bundleId:r,packageName:n,appId:i})}}function ty(e){return{released:!0===e.released,materializationId:tt(e,"materializationId"),identifiers:{}}}function tb(e){let{record:t,platform:r,id:n,name:i,target:a}=tv(e,"name");return{platform:r,target:a,kind:te(t,"kind",tp,'Daemon response has invalid "kind".'),id:n,name:i,booted:"boolean"==typeof t.booted?t.booted:void 0,identifiers:eZ(r,n,i),...tx(r,n)}}function tw(e){let{record:t,platform:r,id:n,name:i,target:a}=tv(e,"name"),o=tt(t,"device"),s={session:i,...eZ(r,n,o)};return{name:i,createdAt:te(t,"createdAt",tu,'Daemon response is missing numeric "createdAt".'),sessionStateDir:tr(t,"sessionStateDir"),runnerLogPath:tr(t,"runnerLogPath"),device:{platform:r,target:a,id:n,name:o,identifiers:s,...tx(r,n,tn(t,"ios_simulator_device_set"))},identifiers:s}}function tv(e,t){let r=function(e){if(!td(e))throw new y("COMMAND_FAILED","Daemon returned an unexpected response shape.",{value:e});return e}(e);return{record:r,platform:ti(r,"platform"),id:tt(r,"id"),name:tt(r,t),target:ta(r,"target")}}function tx(e,t,r){return{ios:"ios"===e?{udid:t,...void 0!==r?{simulatorSetPath:r}:{}}:void 0,android:"android"===e?{serial:t}:void 0}}function tS(e){if(!td(e))return;let t=e.platform,r=tr(e,"metroHost"),n="number"==typeof e.metroPort?e.metroPort:void 0;return{platform:"ios"===t||"android"===t?t:void 0,metroHost:r,metroPort:n,bundleUrl:tr(e,"bundleUrl"),launchUrl:tr(e,"launchUrl")}}function tk(e){let t=e.platform,r=tr(e,"id"),n=tr(e,"device");if("ios"!==t&&"macos"!==t&&"android"!==t&&"linux"!==t||!r||!n)return;let i=ta(e,"target"),a=eZ(t,r,n);return{platform:t,target:i,id:r,name:n,identifiers:a,ios:"ios"===t?{udid:tr(e,"device_udid")??r,simulatorSetPath:tn(e,"ios_simulator_device_set")}:void 0,android:"android"===t?{serial:tr(e,"serial")??r}:void 0}}function tA(e){if(td(e)&&"number"==typeof e.durationMs&&"string"==typeof e.measuredAt&&"string"==typeof e.method)return{durationMs:e.durationMs,measuredAt:e.measuredAt,method:e.method,appTarget:tr(e,"appTarget"),appBundleId:tr(e,"appBundleId")}}function tD(e){return Array.isArray(e)?e:[]}function tI(e){let t=e.overlayRefs;if(!Array.isArray(t))return;let r=[];for(let e of t){if(!td(e))continue;let t=tr(e,"ref"),n=to(e,"rect"),i=to(e,"overlayRect"),a=function(e,t){let r=e[t];if(!td(r))return;let n=ts(r,"x"),i=ts(r,"y");if(void 0!==n&&void 0!==i)return{x:n,y:i}}(e,"center");t&&n&&i&&a&&r.push({ref:t,label:tr(e,"label"),rect:n,overlayRect:i,center:a})}return r}function tM(e){return tm({stateDir:e.stateDir,daemonBaseUrl:e.daemonBaseUrl,daemonAuthToken:e.daemonAuthToken,daemonTransport:e.daemonTransport,daemonServerMode:e.daemonServerMode,tenant:e.tenant,sessionIsolation:e.sessionIsolation,runId:e.runId,leaseId:e.leaseId,leaseBackend:e.leaseBackend,platform:e.platform,target:e.target,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,androidDeviceAllowlist:e.androidDeviceAllowlist,surface:e.surface,activity:e.activity,launchConsole:e.launchConsole,launchArgs:e.launchArgs,relaunch:e.relaunch,shutdown:e.shutdown,saveScript:e.saveScript,deviceHub:e.deviceHub,noRecord:e.noRecord,backMode:e.backMode,metroHost:e.metroHost,metroPort:e.metroPort,bundleUrl:e.bundleUrl,launchUrl:e.launchUrl,snapshotInteractiveOnly:e.interactiveOnly,snapshotDepth:e.depth,snapshotScope:e.scope,snapshotRaw:e.raw,snapshotForceFull:e.forceFull,...eT(e),appsFilter:e.appsFilter,kind:e.kind,out:e.out,count:e.count,fps:e.fps,quality:e.quality,hideTouches:e.hideTouches,intervalMs:e.intervalMs,delayMs:e.delayMs,holdMs:e.holdMs,jitterPx:e.jitterPx,pixels:e.pixels,doubleTap:e.doubleTap,clickButton:e.clickButton,pauseMs:e.pauseMs,pattern:e.pattern,headless:e.headless,restart:e.restart,replayUpdate:e.replayUpdate,replayBackend:e.replayBackend,replayEnv:e.replayEnv,replayShellEnv:e.replayShellEnv,failFast:e.failFast,timeoutMs:e.timeoutMs,retries:e.retries,recordVideo:e.recordVideo,artifactsDir:e.artifactsDir,reportJunit:e.reportJunit,shardAll:e.shardAll,shardSplit:e.shardSplit,findFirst:e.findFirst,findLast:e.findLast,networkInclude:e.networkInclude,batchOnError:e.batchOnError,batchMaxSteps:e.batchMaxSteps,batchSteps:e.batchSteps,verbose:e.debug})}function tL(e){return tm({requestId:e.requestId,cwd:e.cwd,sessionExplicit:void 0!==e.session,debug:e.debug,lockPolicy:e.lockPolicy,lockPlatform:e.lockPlatform,tenantId:e.tenant,runId:e.runId,leaseId:e.leaseId,leaseBackend:e.leaseBackend,leaseTtlMs:e.leaseTtlMs,sessionIsolation:e.sessionIsolation,installSource:e.installSource,retainMaterializedPaths:e.retainMaterializedPaths,materializedPathRetentionMs:e.materializedPathRetentionMs,materializationId:e.materializationId})}function tN(e){return e??"default"}function tR(e){return t=>ef(S.batch,[],{...t,batchSteps:function(e,t){if(!Array.isArray(e)||0===e.length)throw new y("INVALID_ARGS","batch requires a non-empty steps array.");return e.map((e,r)=>{var n,i,a,o,s;let l,u,c,p,d,m;return n=e,i=r+1,a=t,c=(o=u=function(e,t){if(!e||"object"!=typeof e||Array.isArray(e))throw new y("INVALID_ARGS",`Invalid batch step ${t}.`);return e}(n,i),s=i,w(o.command,s)),p=function(e,t){let r=e.input;if(!r||"object"!=typeof r||Array.isArray(r))throw new y("INVALID_ARGS",`Batch step ${t} input must be an object.`);return r}(u,i),d=function(e,t){let r=e.runtime;if(void 0!==r&&(!r||"object"!=typeof r||Array.isArray(r)))throw new y("INVALID_ARGS",`Batch step ${t} runtime must be an object.`);return r}(u,i),{...m={command:(l=a(c,p)).command,positionals:l.positionals,flags:tM(l.options),runtime:l.options.runtime},runtime:d??m.runtime}})}(t.steps,e),batchOnError:t.onError,batchMaxSteps:t.maxSteps})}let tO=function(e=b){var t;let r={steps:P(eu({type:"array",description:"Structured batch steps. Each step uses a command name and the same input object as that command tool.",items:{type:"object",properties:{command:{type:"string",enum:t=e,description:"Command name to run with structured input."},input:{type:"object",additionalProperties:!0,description:"Structured command input for the nested command. Use the matching MCP tool schema for this object."},runtime:{type:"object",additionalProperties:!0,description:"Optional per-step runtime payload."}},required:["command","input"],additionalProperties:!1}},(e,r)=>(function(e,t){if(!Array.isArray(e))throw Error("Expected steps to be an array.");return e.map((e,r)=>{var n,i,a;let o;return n=e,i=r+1,a=t,!function(e,t,r){let n=new Set(t),i=Object.keys(e).filter(e=>!n.has(e));if(i.length>0)throw Error(`${r} has unknown field(s): ${i.join(", ")}.`)}(o=function(e,t){if(!e||"object"!=typeof e||Array.isArray(e))throw Error(`Invalid batch step ${t}.`);return e}(n,i),["command","input","runtime"],`Batch step ${i}`),{command:function(e,t,r){if(r===b)return w(e.command,t);let n=e.command;if("string"!=typeof n||!r.includes(n))throw Error(`Expected command to be one of: ${r.join(", ")}.`);return n}(o,i,a),input:function(e,t){let r=e.input;if(!r||"object"!=typeof r||Array.isArray(r))throw Error(`Batch step ${t} input must be an object.`);return r}(o,i),...function(e,t){let r=e.runtime;if(void 0!==r&&(!r||"object"!=typeof r||Array.isArray(r)))throw Error(`Batch step ${t} runtime must be an object.`);return void 0===r?{}:{runtime:r}}(o,i)}})})(e[r],t))),onError:F(["stop"],"Batch failure policy."),maxSteps:T("Maximum number of steps accepted for this batch.",{min:1,max:1e3}),out:_("Optional output path for command artifacts.")};return{name:"batch",description:"Run multiple structured command steps in one daemon request.",inputSchema:B(r),readInput:e=>(function(e,t){let r=H(e,t),n=r.maxSteps??100;if(!Number.isInteger(n)||n<1||n>1e3)throw Error(`Invalid batch maxSteps: ${String(r.maxSteps)}`);if(r.steps.length>n)throw Error(`batch has ${r.steps.length} steps; max allowed is ${n}.`);return{...r}})(e,r)}}(),tE=eP(tO,(e,t)=>{var r;return e.batch.run({...ei(r=t),steps:r.steps,onError:r.onError,maxSteps:r.maxSteps,out:r.out})}),tP={batch:{usageOverride:"batch [--steps <json> | --steps-file <path>]",listUsageOverride:"batch --steps <json> | --steps-file <path>",helpDescription:"Execute multiple commands in one daemon request",summary:"Run multiple commands",allowedFlags:["steps","stepsFile","batchOnError","batchMaxSteps","out"]}},t_={batch:(e,t)=>({...eh(t),steps:t.batchSteps??[],onError:t.batchOnError,maxSteps:t.batchMaxSteps,out:t.out})};function tC(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function tT(e){let t=e[0];if(void 0===t)return null;let r=tC(t);if(null!==r)return{kind:"sleep",durationMs:r};let n=tC(e[e.length-1]);if("text"===t)return{kind:"text",text:(null!==n?e.slice(1,-1).join(" "):e.slice(1).join(" ")).trim(),timeoutMs:n};if(t.startsWith("@"))return{kind:"ref",rawRef:t,timeoutMs:n};let i=s(null!==n?e.slice(0,-1):e.slice());return i&&0===i.rest.length&&u(i.selectorExpression)?{kind:"selector",selectorExpression:i.selectorExpression,timeoutMs:n}:{kind:"text",text:(null!==n?e.slice(0,-1).join(" "):e.join(" ")).trim(),timeoutMs:n}}function t$(e,t){return e.includes(t)}function tF(e,t,r={}){let n=void 0===t?void 0:r.normalize?.(t)??t;if(void 0!==n&&t$(e,n))return n;throw new y("INVALID_ARGS",("function"==typeof r.message?r.message(t):r.message)??`Invalid value: ${t}. Use ${e.join("|")}.`)}function tU(e,t={}){return{values:e,is:t=>t$(e,t),parse:r=>tF(e,r,t)}}let tj=["app","frontmost-app","desktop","menubar"],tV=tU(tj,{normalize:e=>e.trim().toLowerCase(),message:e=>`Invalid surface: ${e}. Use ${tj.join("|")}.`});function tq(e){return tV.parse(e)}let tG=["metrics","frames","memory","cpu","trace"],tz=["sample","snapshot","start","stop","report"],tB=["profile"],tH=["xctrace","simpleperf","perfetto","android-hprof","memgraph"],tW=tU(tG),tK=tU(tz),tJ=tU(tB),tX=tU(tH),tY=tU(["android-hprof","memgraph"]),tQ="perf area must be metrics, frames, memory, cpu, or trace",tZ="perf action must be sample, snapshot, start, stop, or report",t0="perf cpu requires profile",t1="perf --kind must be xctrace, simpleperf, perfetto, android-hprof, or memgraph",t2="perf memory snapshot --kind must be android-hprof or memgraph",t5=tW.is,t3=tK.is,t8=tJ.is,t4=tX.is,t6=tY.is,t9="https://github.com/callstackincubator/agent-device/issues/558",t7="https://github.com/callstackincubator/agent-device/issues/new";function re(...e){return e}let rt=re("snapshotInteractiveOnly","snapshotDepth","snapshotScope","snapshotRaw"),rr=re("snapshotDepth","snapshotScope","snapshotRaw"),rn=re("metroProjectRoot","kind","metroKind","metroPublicBaseUrl","metroProxyBaseUrl","metroBearerToken","metroPreparePort","metroListenHost","metroStatusHost","metroStartupTimeoutMs","metroProbeTimeoutMs","metroRuntimeFile","metroNoReuseExisting","metroNoInstallDeps"),ri=re("metroHost","metroPort","bundleUrl"),ra=re("count","intervalMs","holdMs","jitterPx","doubleTap"),ro=re("replayUpdate","replayEnv"),rs=[{key:"config",names:["--config"],type:"string",usageLabel:"--config <path>",usageDescription:"Load CLI defaults from a specific config file"},{key:"remoteConfig",names:["--remote-config"],type:"string",usageLabel:"--remote-config <path>",usageDescription:"Load remote host + Metro workflow settings from a specific profile file"},{key:"stateDir",names:["--state-dir"],type:"string",usageLabel:"--state-dir <path>",usageDescription:"Daemon state directory (defaults to ~/.agent-device for packages, or a worktree-scoped dev dir from source)"},{key:"daemonBaseUrl",names:["--daemon-base-url"],type:"string",usageLabel:"--daemon-base-url <url>",usageDescription:"Explicit remote HTTP daemon base URL (skip local daemon discovery/startup)"},{key:"daemonAuthToken",names:["--daemon-auth-token"],type:"string",usageLabel:"--daemon-auth-token <token>",usageDescription:"Remote HTTP daemon auth token (sent as request token and bearer header)"},{key:"daemonTransport",names:["--daemon-transport"],type:"enum",enumValues:["auto","socket","http"],usageLabel:"--daemon-transport auto|socket|http",usageDescription:"Daemon client transport preference"},{key:"daemonServerMode",names:["--daemon-server-mode"],type:"enum",enumValues:["socket","http","dual"],usageLabel:"--daemon-server-mode socket|http|dual",usageDescription:"Daemon server mode used when spawning daemon"},{key:"tenant",names:["--tenant"],type:"string",usageLabel:"--tenant <id>",usageDescription:"Tenant scope identifier for isolated daemon sessions"},{key:"sessionIsolation",names:["--session-isolation"],type:"enum",enumValues:["none","tenant"],usageLabel:"--session-isolation none|tenant",usageDescription:"Session isolation strategy (tenant prefixes session namespace)"},{key:"runId",names:["--run-id"],type:"string",usageLabel:"--run-id <id>",usageDescription:"Run identifier used for tenant lease admission checks"},{key:"leaseId",names:["--lease-id"],type:"string",usageLabel:"--lease-id <id>",usageDescription:"Lease identifier bound to tenant/run admission scope"},{key:"leaseBackend",names:["--lease-backend"],type:"enum",enumValues:["ios-simulator","ios-instance","android-instance"],usageLabel:"--lease-backend ios-simulator|ios-instance|android-instance",usageDescription:"Lease backend for remote tenant connection admission"},{key:"force",names:["--force"],type:"boolean",usageLabel:"--force",usageDescription:"Force connection state replacement when reconnecting"},{key:"noLogin",names:["--no-login"],type:"boolean",usageLabel:"--no-login",usageDescription:"Connect: fail instead of starting implicit cloud login"},{key:"sessionLock",names:["--session-lock"],type:"enum",enumValues:["reject","strip"],usageLabel:"--session-lock reject|strip",usageDescription:"Lock bound-session device routing for this CLI invocation and nested batch steps"},{key:"sessionLocked",names:["--session-locked"],type:"boolean",usageLabel:"--session-locked",usageDescription:"Deprecated alias for --session-lock reject"},{key:"sessionLockConflicts",names:["--session-lock-conflicts"],type:"enum",enumValues:["reject","strip"],usageLabel:"--session-lock-conflicts reject|strip",usageDescription:"Deprecated alias for --session-lock"},{key:"platform",names:["--platform"],type:"enum",enumValues:["ios","macos","android","linux","apple"],usageLabel:"--platform ios|macos|android|linux|apple",usageDescription:"Platform to target (`apple` aliases the Apple automation backend)"},{key:"target",names:["--target"],type:"enum",enumValues:["mobile","tv","desktop"],usageLabel:"--target mobile|tv|desktop",usageDescription:"Device target class to match"},{key:"device",names:["--device"],type:"string",usageLabel:"--device <name>",usageDescription:"Device name to target"},{key:"udid",names:["--udid"],type:"string",usageLabel:"--udid <udid>",usageDescription:"iOS device UDID"},{key:"serial",names:["--serial"],type:"string",usageLabel:"--serial <serial>",usageDescription:"Android device serial"},{key:"surface",names:["--surface"],type:"enum",enumValues:tj,usageLabel:"--surface app|frontmost-app|desktop|menubar",usageDescription:"macOS session surface for open (defaults to app)"},{key:"headless",names:["--headless"],type:"boolean",usageLabel:"--headless",usageDescription:"Boot: launch Android emulator without a GUI window"},{key:"metroHost",names:["--metro-host"],type:"string",usageLabel:"--metro-host <host>",usageDescription:"Session-scoped Metro/debug host hint"},{key:"metroPort",names:["--metro-port"],type:"int",min:1,max:65535,usageLabel:"--metro-port <port>",usageDescription:"Session-scoped Metro/debug port hint"},{key:"metroProjectRoot",names:["--project-root"],type:"string",usageLabel:"--project-root <path>",usageDescription:"metro prepare: React Native project root (default: cwd)"},{key:"kind",names:["--kind"],type:"enum",enumValues:["auto","react-native","expo",...tH],usageLabel:"--kind <kind>",usageDescription:"Kind selector for commands that support it, such as metro prepare or perf artifact collectors"},{key:"perfTemplate",names:["--template"],type:"string",usageLabel:"--template <name>",usageDescription:"Perf xctrace template name, for example Time Profiler"},{key:"metroKind",names:["--metro-kind"],type:"enum",enumValues:["auto","react-native","expo"],usageLabel:"--metro-kind auto|react-native|expo",usageDescription:"metro prepare: detect or force the Metro launcher kind"},{key:"metroPublicBaseUrl",names:["--public-base-url"],type:"string",usageLabel:"--public-base-url <url>",usageDescription:"metro prepare: public base URL used for direct bundle hints"},{key:"metroProxyBaseUrl",names:["--proxy-base-url"],type:"string",usageLabel:"--proxy-base-url <url>",usageDescription:"metro prepare: optional bridge origin for remote Metro access"},{key:"metroBearerToken",names:["--bearer-token"],type:"string",usageLabel:"--bearer-token <token>",usageDescription:"metro prepare: host bridge bearer token (or AGENT_DEVICE_METRO_BEARER_TOKEN; falls back to AGENT_DEVICE_DAEMON_AUTH_TOKEN)"},{key:"metroPreparePort",names:["--port"],type:"int",min:1,max:65535,usageLabel:"--port <port>",usageDescription:"metro prepare: local Metro port (default: 8081)"},{key:"metroListenHost",names:["--listen-host"],type:"string",usageLabel:"--listen-host <host>",usageDescription:"metro prepare: host Metro listens on (default: 0.0.0.0)"},{key:"metroStatusHost",names:["--status-host"],type:"string",usageLabel:"--status-host <host>",usageDescription:"metro prepare: host used for local /status polling (default: 127.0.0.1)"},{key:"metroStartupTimeoutMs",names:["--startup-timeout-ms"],type:"int",min:1,usageLabel:"--startup-timeout-ms <ms>",usageDescription:"metro prepare: timeout while waiting for Metro to become ready"},{key:"metroProbeTimeoutMs",names:["--probe-timeout-ms"],type:"int",min:1,usageLabel:"--probe-timeout-ms <ms>",usageDescription:"metro prepare: timeout for /status and proxy bridge calls"},{key:"metroRuntimeFile",names:["--runtime-file"],type:"string",usageLabel:"--runtime-file <path>",usageDescription:"metro prepare: optional file path to persist the JSON result"},{key:"metroNoReuseExisting",names:["--no-reuse-existing"],type:"boolean",usageLabel:"--no-reuse-existing",usageDescription:"metro prepare: always start a fresh Metro process"},{key:"metroNoInstallDeps",names:["--no-install-deps"],type:"boolean",usageLabel:"--no-install-deps",usageDescription:"metro prepare: skip package-manager install when node_modules is missing"},{key:"bundleUrl",names:["--bundle-url"],type:"string",usageLabel:"--bundle-url <url>",usageDescription:"Session-scoped bundle URL hint"},{key:"launchUrl",names:["--launch-url"],type:"string",usageLabel:"--launch-url <url>",usageDescription:"Session-scoped deep link / launch URL hint"},{key:"iosSimulatorDeviceSet",names:["--ios-simulator-device-set"],type:"string",usageLabel:"--ios-simulator-device-set <path>",usageDescription:"Scope iOS simulator discovery/commands to this simulator device set"},{key:"deviceHub",names:["--device-hub"],type:"boolean",usageLabel:"--device-hub",usageDescription:"open: use Xcode Device Hub when surfacing Apple simulators"},{key:"androidDeviceAllowlist",names:["--android-device-allowlist"],type:"string",usageLabel:"--android-device-allowlist <serials>",usageDescription:"Comma/space separated Android serial allowlist for discovery/selection"},{key:"activity",names:["--activity"],type:"string",usageLabel:"--activity <component>",usageDescription:"Android app launch activity (package/Activity); not for URL opens"},{key:"launchConsole",names:["--launch-console"],type:"string",usageLabel:"--launch-console <path>",usageDescription:"open: capture the initial iOS simulator launch console window to a file"},{key:"launchArgs",names:["--launch-args"],type:"string",multiple:!0,usageLabel:"--launch-args <arg>",usageDescription:"open: repeatable launch argument forwarded verbatim to the platform launch command (iOS app process args; Android adb shell am start args). Linux and macOS reject the flag."},{key:"header",names:["--header"],type:"string",multiple:!0,usageLabel:"--header <name:value>",usageDescription:"install-from-source: repeatable HTTP header for URL downloads"},{key:"githubActionsArtifact",names:["--github-actions-artifact"],type:"string",usageLabel:"--github-actions-artifact <owner/repo:artifact>",usageDescription:"install-from-source: GitHub Actions artifact resolved by a remote daemon"},{key:"installSource",names:[],type:"string"},{key:"session",names:["--session"],type:"string",usageLabel:"--session <name>",usageDescription:"Named session"},{key:"count",names:["--count"],type:"int",min:1,max:200,usageLabel:"--count <n>",usageDescription:"Repeat count for press/swipe series"},{key:"fps",names:["--fps"],type:"int",min:1,max:120,usageLabel:"--fps <n>",usageDescription:"Record: target frames per second (iOS physical device runner)"},{key:"quality",names:["--quality"],type:"int",min:5,max:10,usageLabel:"--quality <5-10>",usageDescription:"Record: scale recording resolution from 5 (50%) through 10 (native resolution)"},{key:"hideTouches",names:["--hide-touches"],type:"boolean",usageLabel:"--hide-touches",usageDescription:"Record: skip touch-overlay post-processing for faster raw benchmark videos"},{key:"intervalMs",names:["--interval-ms"],type:"int",min:0,max:1e4,usageLabel:"--interval-ms <ms>",usageDescription:"Delay between press iterations"},{key:"delayMs",names:["--delay-ms"],type:"int",min:0,max:1e4,usageLabel:"--delay-ms <ms>",usageDescription:"Delay between typed characters"},{key:"holdMs",names:["--hold-ms"],type:"int",min:0,max:1e4,usageLabel:"--hold-ms <ms>",usageDescription:"Press hold duration for each iteration"},{key:"jitterPx",names:["--jitter-px"],type:"int",min:0,max:100,usageLabel:"--jitter-px <n>",usageDescription:"Deterministic coordinate jitter radius for press"},{key:"pixels",names:["--pixels"],type:"int",min:1,max:1e5,usageLabel:"--pixels <n>",usageDescription:"Scroll: explicit gesture distance in pixels"},{key:"doubleTap",names:["--double-tap"],type:"boolean",usageLabel:"--double-tap",usageDescription:"Use double-tap gesture per press iteration"},{key:"clickButton",names:["--button"],type:"enum",enumValues:["primary","secondary","middle"],usageLabel:"--button primary|secondary|middle",usageDescription:"Click: choose mouse button (middle reserved for future macOS support)"},{key:"backMode",names:["--in-app"],type:"enum",enumValues:["in-app","system"],setValue:"in-app",usageLabel:"--in-app",usageDescription:"Back: use app-provided back UI when available"},{key:"backMode",names:["--system"],type:"enum",enumValues:["in-app","system"],setValue:"system",usageLabel:"--system",usageDescription:"Back: use system back input or gesture when available"},{key:"pauseMs",names:["--pause-ms"],type:"int",min:0,max:1e4,usageLabel:"--pause-ms <ms>",usageDescription:"Delay between swipe iterations"},{key:"pattern",names:["--pattern"],type:"enum",enumValues:["one-way","ping-pong"],usageLabel:"--pattern one-way|ping-pong",usageDescription:"Swipe repeat pattern"},{key:"verbose",names:["--debug","--verbose","-v"],type:"boolean",usageLabel:"--debug, --verbose, -v",usageDescription:"Enable debug diagnostics; test --verbose prints per-test step timings without debug logs"},{key:"json",names:["--json"],type:"boolean",usageLabel:"--json",usageDescription:"JSON output"},{key:"help",names:["--help","-h"],type:"boolean",usageLabel:"--help, -h",usageDescription:"Print help and exit"},{key:"version",names:["--version","-V"],type:"boolean",usageLabel:"--version, -V",usageDescription:"Print version and exit"},{key:"snapshotDiff",names:["--diff"],type:"boolean",usageLabel:"--diff",usageDescription:"Snapshot: show structural diff against the previous session baseline"},{key:"saveScript",names:["--save-script"],type:"booleanOrString",usageLabel:"--save-script [path]",usageDescription:"Save session script (.ad) on close; optional custom output path"},{key:"networkInclude",names:["--include"],type:"enum",enumValues:["summary","headers","body","all"],usageLabel:"--include summary|headers|body|all",usageDescription:"Network: include headers, bodies, or both in output"},{key:"shutdown",names:["--shutdown"],type:"boolean",usageLabel:"--shutdown",usageDescription:"close: shutdown associated simulator/emulator after ending session"},{key:"relaunch",names:["--relaunch"],type:"boolean",usageLabel:"--relaunch",usageDescription:"open: terminate app process before launching it"},{key:"restart",names:["--restart"],type:"boolean",usageLabel:"--restart",usageDescription:"logs clear: stop active stream, clear logs, then start streaming again"},{key:"retainPaths",names:["--retain-paths"],type:"boolean",usageLabel:"--retain-paths",usageDescription:"install-from-source: keep materialized artifact paths after install"},{key:"retentionMs",names:["--retention-ms"],type:"int",min:1,usageLabel:"--retention-ms <ms>",usageDescription:"install-from-source: retention TTL for materialized artifact paths"},{key:"noRecord",names:["--no-record"],type:"boolean",usageLabel:"--no-record",usageDescription:"Do not record this action"},{key:"replayUpdate",names:["--update","-u"],type:"boolean",usageLabel:"--update, -u",usageDescription:"Replay: update selectors and rewrite replay file in place"},{key:"replayMaestro",names:["--maestro"],type:"boolean",usageLabel:"--maestro",usageDescription:`Replay: treat input as a Maestro YAML compatibility flow. Supported subset: ${(e=["app launch with Apple-platform launch arguments and Android/iOS simulator clearState","runFlow file/inline with when.platform, when.visible, when.notVisible, and limited when.true boolean/platform expressions","onFlowStart and onFlowComplete hooks","deterministic repeat.times","tapOn including optional, index, childOf, label, and absolute/percentage point taps","doubleTapOn and longPressOn","inputText, focused-field eraseText, and pasteText","openLink","visibility assertions and extendedWaitUntil","scroll and scrollUntilVisible","absolute/percentage swipe and swipe.label","screenshots","keyboard dismiss","basic pressKey, back, animation waits, and stopApp","ordered trusted runScript file/env scripts with http.post, json, and output variables"]).length>1?`${e.slice(0,-1).join(", ")}, and ${e.at(-1)}`:e[0]??""}. Unsupported syntax fails loudly with a link to ${t9}`},{key:"replayExportFormat",names:["--format"],type:"enum",enumValues:["maestro"],usageLabel:"--format maestro",usageDescription:"Replay export: output format"},{key:"replayEnv",names:["-e","--env"],type:"string",multiple:!0,usageLabel:"-e KEY=VALUE, --env KEY=VALUE",usageDescription:"Replay/Test: inject or override a ${KEY} variable for the script (repeatable)"},{key:"failFast",names:["--fail-fast"],type:"boolean",usageLabel:"--fail-fast",usageDescription:"Test: stop the suite after the first failing script; with sharding, each shard stops independently"},{key:"timeoutMs",names:["--timeout"],type:"int",min:1,usageLabel:"--timeout <ms>",usageDescription:"Prepare/Replay/Snapshot/Test: maximum wall-clock time for the command or attempt"},{key:"retries",names:["--retries"],type:"int",min:0,max:3,usageLabel:"--retries <n>",usageDescription:"Test: retry each failed script up to n additional times"},{key:"recordVideo",names:["--record-video"],type:"boolean",usageLabel:"--record-video",usageDescription:"Test: record each replay attempt to recording.mp4 in its attempt artifacts"},{key:"artifactsDir",names:["--artifacts-dir"],type:"string",usageLabel:"--artifacts-dir <path>",usageDescription:"Test: root directory for suite artifacts"},{key:"reportJunit",names:["--report-junit"],type:"string",usageLabel:"--report-junit <path>",usageDescription:"Test: write a JUnit XML report for the replay suite"},{key:"shardAll",names:["--shard-all"],type:"int",min:1,usageLabel:"--shard-all <n>",usageDescription:"Test: run the full suite on each of n devices; AD_SHARD_INDEX is zero-based"},{key:"shardSplit",names:["--shard-split"],type:"int",min:1,usageLabel:"--shard-split <n>",usageDescription:"Test: split runnable suite entries across n devices; AD_SHARD_INDEX is zero-based"},{key:"steps",names:["--steps"],type:"string",usageLabel:"--steps <json>",usageDescription:"Batch: JSON array of steps"},{key:"stepsFile",names:["--steps-file"],type:"string",usageLabel:"--steps-file <path>",usageDescription:"Batch: read steps JSON from file"},{key:"batchOnError",names:["--on-error"],type:"enum",enumValues:["stop"],usageLabel:"--on-error stop",usageDescription:"Batch: stop when a step fails"},{key:"batchMaxSteps",names:["--max-steps"],type:"int",min:1,max:1e3,usageLabel:"--max-steps <n>",usageDescription:"Batch: maximum number of allowed steps"},{key:"appsFilter",names:["--all"],type:"enum",enumValues:["user-installed","all"],setValue:"all",usageLabel:"--all",usageDescription:"Apps: include system/OEM apps"},{key:"snapshotInteractiveOnly",names:["-i"],type:"boolean",usageLabel:"-i",usageDescription:"Snapshot: interactive elements only"},{key:"snapshotDepth",names:["--depth","-d"],type:"int",min:0,usageLabel:"--depth, -d <depth>",usageDescription:"Snapshot: limit snapshot depth"},{key:"snapshotScope",names:["--scope","-s"],type:"string",usageLabel:"--scope, -s <scope>",usageDescription:"Snapshot: scope snapshot to label/identifier"},{key:"snapshotRaw",names:["--raw"],type:"boolean",usageLabel:"--raw",usageDescription:"Snapshot: raw node output"},{key:"snapshotForceFull",names:["--force-full"],type:"boolean",usageLabel:"--force-full",usageDescription:"Snapshot: re-emit the full tree even when unchanged"},{key:"findFirst",names:["--first"],type:"boolean",usageLabel:"--first",usageDescription:"Find: pick the first match when ambiguous"},{key:"findLast",names:["--last"],type:"boolean",usageLabel:"--last",usageDescription:"Find: pick the last match when ambiguous"},{key:"out",names:["--out"],type:"string",usageLabel:"--out <path>",usageDescription:"Output path"},{key:"artifact",names:["--artifact"],type:"string",usageLabel:"--artifact <path>",usageDescription:"Debug symbols: Apple crash artifact path (.ips, .crash, or .log)"},{key:"dsym",names:["--dsym"],type:"string",usageLabel:"--dsym <path>",usageDescription:"Debug symbols: matching .dSYM bundle path"},{key:"searchPath",names:["--search-path"],type:"string",usageLabel:"--search-path <dir>",usageDescription:"Debug symbols: directory to scan for matching .dSYM bundles"},{key:"overlayRefs",names:["--overlay-refs"],type:"boolean",usageLabel:"--overlay-refs",usageDescription:"Screenshot: draw current snapshot refs and target rectangles onto the saved PNG; diff screenshot: also write a separate current-screen overlay guide"},{key:"screenshotFullscreen",names:["--fullscreen"],type:"boolean",usageLabel:"--fullscreen",usageDescription:"Screenshot: capture the full screen instead of the app window"},{key:"screenshotMaxSize",names:["--max-size"],type:"int",min:1,usageLabel:"--max-size <px>",usageDescription:"Screenshot: downscale so the longest edge is at most <px>"},{key:"screenshotNoStabilize",names:["--no-stabilize"],type:"boolean",usageLabel:"--no-stabilize",usageDescription:"Screenshot: skip Android demo-mode/status-bar stabilization and settle delay for low-latency capture loops"},{key:"baseline",names:["--baseline","-b"],type:"string",usageLabel:"--baseline, -b <path>",usageDescription:"Diff screenshot: path to baseline image file"},{key:"threshold",names:["--threshold"],type:"string",usageLabel:"--threshold <0-1>",usageDescription:"Diff screenshot: color distance threshold (default 0.1)"}],rl=new Set(["json","config","remoteConfig","stateDir","daemonBaseUrl","daemonAuthToken","daemonTransport","daemonServerMode","tenant","sessionIsolation","runId","leaseId","leaseBackend","sessionLock","sessionLocked","sessionLockConflicts","help","version","verbose","platform","target","device","udid","serial","iosSimulatorDeviceSet","androidDeviceAllowlist","session","noRecord"]),ru=new Map;for(let e of rs)for(let t of e.names)ru.set(t,e);function rc(e){return ru.get(e)}function rp(){return rs}function rd(e,t,r){return{name:e,description:t,inputSchema:B(r),readInput:e=>H(e,r)}}let rm=["duration","text","ref","selector"],rf="<wifi|airplane|location> <on|off>",rh="location set <lat> <lon>",rg="animations <on|off>",ry="appearance <light|dark|toggle>",rb="faceid <match|nonmatch|enroll|unenroll>",rw="touchid <match|nonmatch|enroll|unenroll>",rv="fingerprint <match|nonmatch>",rx="clear-app-state [app-id]",rS="permission <grant|deny|reset> <camera|microphone|photos|contacts|contacts-limited|notifications|calendar|location|location-always|media-library|motion|reminders|siri> [full|limited]",rk="permission <grant|reset> <accessibility|screen-recording|input-monitoring>",rA=`macOS supports only settings ${ry} and settings ${rk}. wifi|airplane|location|animations remain unsupported on macOS.`,rD=`settings ${rf} | settings ${rh} | settings ${rg} | settings ${ry} | settings ${rb} | settings ${rw} | settings ${rv} | settings ${rx} | settings ${rS} | settings ${rk}`,rI=`settings requires ${rf}, ${rh}, ${rg}, ${ry}, ${rb}, ${rw}, ${rv}, ${rx}, ${rS}, or ${rk}`;function rM(e){let t=e.trim().toLowerCase();return"appearance"===t||"permission"===t}function rL(e){return`Unsupported macOS setting: ${e}. ${rA}`}function rN(e,t){if(void 0===e||""===e.trim())throw new y("INVALID_ARGS",`settings location set requires ${t}`);return rO(Number(e),t)}function rR(e){return{latitude:rO(e?.latitude,"latitude"),longitude:rO(e?.longitude,"longitude")}}function rO(e,t){let r="latitude"===t?-90:-180,n="latitude"===t?90:180;if("number"!=typeof e||!Number.isFinite(e)||e<r||e>n)throw new y("INVALID_ARGS",`${t} must be a number from ${r} to ${n}`);return e}let rE="settings",rP=rd(rE,"Change OS settings and app permissions.",{setting:P(_()),state:P(_()),app:_(),latitude:C(),longitude:C(),permission:_(),mode:F(["full","limited"])}),r_=eP(rP,(e,t)=>e.settings.update(t)),rC=em(S.settings,e=>{var t;return"clear-app-state"===(t=e).setting?[t.setting,...eN(t.app)]:"location"===t.setting&&"set"===t.state?[t.setting,t.state,String(t.latitude),String(t.longitude)]:"permission"===t.setting?[t.setting,t.state,t.permission,...eN(t.mode)]:[t.setting,t.state]}),rT=eD("wifi","airplane","location","animations"),r$=eD("on","off"),rF=eD("light","dark","toggle"),rU=eD("faceid","touchid"),rj=eD("match","nonmatch","enroll","unenroll"),rV=eD("match","nonmatch"),rq=eD("grant","deny","reset"),rG=eD("camera","microphone","photos","contacts","contacts-limited","notifications","calendar","location","location-always","media-library","motion","reminders","siri","accessibility","screen-recording","input-monitoring"),rz="snapshot",rB="screenshot",rH="diff",rW="wait",rK="alert",rJ=rd(rz,"Capture an accessibility snapshot.",{interactiveOnly:$(),depth:T(),scope:_(),raw:$(),forceFull:$(),timeoutMs:T("Maximum wall-clock time for the snapshot command.")}),rX=rd(rB,"Capture a screenshot.",{path:_("Output path."),overlayRefs:$(),fullscreen:$(),maxSize:T(),stabilize:$(),surface:F(tj)}),rY=rd(rH,"Diff accessibility snapshots.",{kind:P(j({type:"string",const:"snapshot"})),out:_(),interactiveOnly:$(),depth:T(),scope:_(),raw:$()}),rQ=rd(rW,"Wait for duration, text, ref, or selector.",{kind:F(rm),durationMs:T(),text:_(),ref:_(),selector:_(),timeoutMs:T(),depth:T(),scope:_(),raw:$()}),rZ=rd(rK,"Inspect or handle platform alerts.",{action:F(["get","accept","dismiss","wait"]),timeoutMs:T()}),r0=[rJ,rX,rY,rQ,rZ,rP],r1=[eP(rJ,(e,t)=>e.capture.snapshot(t)),eP(rX,(e,t)=>e.capture.screenshot(t)),eP(rY,(e,t)=>e.capture.diff(t)),eP(rQ,(e,t)=>{var r;let n;return e.command.wait((en(r=t,"kind",rm),n={...r},delete n.kind,n))}),eP(rZ,(e,t)=>e.command.alert(t)),r_],r2={[rz]:{usageOverride:"snapshot [--diff] [-i] [-d <depth>] [-s <scope>] [--raw] [--force-full] [--timeout <ms>]",helpDescription:"Capture accessibility tree or diff against the previous session baseline",allowedFlags:["snapshotDiff",...rt,"snapshotForceFull","timeoutMs"]},[rB]:{helpDescription:"Capture screenshot (macOS app sessions default to the app window; use --fullscreen for full desktop, --max-size to downscale, --overlay-refs to annotate current refs, or --no-stabilize for low-latency Android capture loops)",positionalArgs:["path?"],allowedFlags:["out","overlayRefs","screenshotFullscreen","screenshotMaxSize","screenshotNoStabilize"]},[rH]:{usageOverride:"diff snapshot | diff screenshot --baseline <path> [current.png] [--out <diff.png>] [--threshold <0-1>] [--overlay-refs]",helpDescription:"Diff accessibility snapshot or compare screenshots pixel-by-pixel",summary:"Diff snapshot or screenshot",positionalArgs:["kind","current?"],allowedFlags:[...rt,"baseline","threshold","out","overlayRefs"]},[rW]:{usageOverride:"wait <ms>|text <text>|@ref|<selector> [timeoutMs]",positionalArgs:["durationOrSelector","timeoutMs?"],allowsExtraPositionals:!0,allowedFlags:[...rr]},[rK]:{usageOverride:"alert [get|accept|dismiss|wait] [timeout]",positionalArgs:["action?","timeout?"]},[rE]:{usageOverride:rD,listUsageOverride:"settings [area] [options]",helpDescription:"Toggle OS settings, animation scales, appearance, and app permissions (macOS supports only settings appearance <light|dark|toggle> and settings permission <grant|reset> <accessibility|screen-recording|input-monitoring>; wifi|airplane|location|animations remain unsupported on macOS; mobile permission actions use the active session app)",summary:"Change OS settings and app permissions",positionalArgs:["setting","state","target?","mode?"]}},r5={snapshot:(e,t)=>({...eh(t),interactiveOnly:t.snapshotInteractiveOnly,depth:t.snapshotDepth,scope:t.snapshotScope,raw:t.snapshotRaw,forceFull:t.snapshotForceFull,timeoutMs:t.timeoutMs}),screenshot:(e,t)=>({...eh(t),path:e[0]??t.out,...eC(t)}),diff:(e,t)=>{if("snapshot"!==e[0])throw new y("INVALID_ARGS","Only diff snapshot is available through this parser.");return{...eh(t),kind:"snapshot",out:t.out,interactiveOnly:t.snapshotInteractiveOnly,depth:t.snapshotDepth,scope:t.snapshotScope,raw:t.snapshotRaw}},wait:(e,t)=>(function(e,t){let r=tT(e);if(!r)throw new y("INVALID_ARGS","wait requires <ms>, text <text>, @ref, or <selector> [timeoutMs].");let n={...eg(t),...eb(t)};if("sleep"===r.kind)return{...n,durationMs:r.durationMs};if("text"===r.kind){if(!r.text)throw new y("INVALID_ARGS","wait requires text.");return{...n,text:r.text,...r8(r.timeoutMs)}}return"ref"===r.kind?{...n,ref:r.rawRef,...r8(r.timeoutMs)}:{...n,selector:r.selectorExpression,...r8(r.timeoutMs)}})(e,t),alert:(e,t)=>({...eh(t),...function(e){if(e.length>2)throw new y("INVALID_ARGS","alert accepts at most action and timeout arguments.");return el({action:function(e){let t=e?.toLowerCase();if(void 0===t||"get"===t||"accept"===t||"dismiss"===t||"wait"===t)return t;throw new y("INVALID_ARGS","alert action must be get, accept, dismiss, or wait.")}(e[0]),timeoutMs:function(e,t){if(void 0===e)return;let r=Number(e);if(Number.isFinite(r))return r;throw new y("INVALID_ARGS",`${t} must be a finite number.`)}(e[1],"alert timeout")})}(e)}),settings:(e,t)=>(function(e,t){let r=eg(t),n=e[0],i=e[1];if(eI(n,rT)&&eI(i,r$))return{...r,setting:n,state:i};if("location"===n&&"set"===i)return{...r,setting:n,state:i,latitude:rN(e[2],"latitude"),longitude:rN(e[3],"longitude")};if("appearance"===n&&eI(i,rF)||eI(n,rU)&&eI(i,rj)||"fingerprint"===n&&eI(i,rV))return{...r,setting:n,state:i};if("permission"===n&&eI(i,rq))return{...r,setting:n,state:i,permission:function(e){if(eI(e,rG))return e;throw new y("INVALID_ARGS","settings permission requires a permission target.")}(e[2]),mode:function(e){if(void 0===e||"full"===e||"limited"===e)return e;throw new y("INVALID_ARGS","settings permission mode must be full or limited.")}(e[3])};if("clear-app-state"===n){let t="clear"===i?e[2]:i;return{...r,setting:n,state:"clear",app:t}}throw new y("INVALID_ARGS","Invalid settings arguments.")})(e,t)};r5.snapshot,r5.screenshot,r5.diff,r5.wait,r5.alert,r5.settings;let r3={snapshot:em(S.snapshot),screenshot:e=>ef(S.screenshot,eN(e.path),{...e,...eT(e)}),diff:em(S.diff,e=>[eE(e.kind,"diff requires kind")]),wait:em(S.wait,e=>(function(e){if(1!==[void 0!==e.durationMs?"durationMs":void 0,void 0!==e.text?"text":void 0,void 0!==e.ref?"ref":void 0,void 0!==e.selector?"selector":void 0].filter(Boolean).length)throw new y("INVALID_ARGS","wait command requires exactly one of durationMs, text, ref, or selector.");if(void 0!==e.durationMs)return[String(e.durationMs)];let t=eR(e.timeoutMs);if(void 0!==e.text)return["text",e.text,...t];if(void 0!==e.ref)return[e.ref,...t];let r=e.selector;if(!u(r))throw new y("INVALID_ARGS",`Invalid wait selector: ${r}`);return[r,...t]})(e)),alert:em(S.alert,e=>{var t;return[(t=e).action??"get",...eR(t.timeoutMs)]}),settings:rC};function r8(e){return null===e?{}:{timeoutMs:e}}function r4(e){return e?.clickButton??"primary"}function r6(e){return"primary"===e.button?null:"click"!==e.commandLabel?new y("INVALID_ARGS","--button is supported only for click"):"macos"!==e.platform&&"linux"!==e.platform?new y("UNSUPPORTED_OPERATION",`click --button ${e.button} is supported only on macOS and Linux`):"macos"===e.platform&&"middle"===e.button?new y("UNSUPPORTED_OPERATION","click --button middle is not supported by the macOS runner yet"):"number"==typeof e.count||"number"==typeof e.intervalMs||"number"==typeof e.holdMs||"number"==typeof e.jitterPx||!0===e.doubleTap?new y("INVALID_ARGS",`click --button ${e.button} does not support repeat or gesture modifier flags`):null}function r9(e){return"primary"===e?{}:{button:e}}r3.screenshot,r3.wait,r3.alert,r3.settings;let r7=["up","down","left","right"],ne=["left","right","left-edge","right-edge"],nt=["one-way","ping-pong"],nr=tU(ne,{message:"gesture swipe requires left, right, left-edge, or right-edge"}),nn=tU(r7,{message:e=>`Unknown direction: ${e}`});function ni(e){let t=e.direction,r="up"===t||"down"===t?e.referenceHeight:e.referenceWidth,n=nf(e.amount),i=void 0!==e.pixels?nh(e.pixels):Math.round(r*n),a=Math.max(1,Math.round(.05*r)),o=Math.max(1,Math.min(i,Math.max(1,r-2*a))),s=Math.round(o/2),l=Math.round(e.referenceWidth/2),u=Math.round(e.referenceHeight/2),c=(r,n,i,a)=>({direction:t,x1:r,y1:n,x2:i,y2:a,referenceWidth:e.referenceWidth,referenceHeight:e.referenceHeight,amount:e.amount,pixels:o});switch(t){case"up":return c(l,u-s,l,u+s);case"down":return c(l,u+s,l,u-s);case"left":return c(l-s,u,l+s,u);case"right":return c(l+s,u,l-s,u)}}function na(e){nf(e.amount),void 0!==e.pixels&&nh(e.pixels)}function no(e){return{...ni({...e,direction:function(e){switch(e){case"up":return"down";case"down":return"up";case"left":return"right";case"right":return"left"}}(e.direction)}),direction:e.direction}}function ns(e,t,r={}){let n=r.marginPx??8,[i,a,o]="left"===e?[85,15,50]:"right"===e?[15,85,50]:"left-edge"===e?[99,15,50]:[1,85,50],s=nc(t,i,o,{marginPx:n}),l=nc(t,a,o,{marginPx:n});return{preset:e,x1:s.x,y1:s.y,x2:l.x,y2:l.y,referenceWidth:t.referenceWidth,referenceHeight:t.referenceHeight}}function nl(e){return nr.parse(e)}function nu(e){let t=function(e){let t=e.filter(e=>(function(e){if(!e)return!1;let t=e.toLowerCase();return t.includes("application")||t.includes("window")})(e.type)&&nm(e.rect)).map(e=>e.rect).sort((e,t)=>(t?.width??0)*(t?.height??0)-(e?.width??0)*(e?.height??0))[0];if(t)return t;let r=e.map(e=>e.rect).filter(nm);if(0===r.length)return;let n=Math.max(...r.map(e=>e.x+e.width)),i=Math.max(...r.map(e=>e.y+e.height));if(!(n<=0)&&!(i<=0))return{x:0,y:0,width:n,height:i}}(e);if(t)return{referenceWidth:t.width,referenceHeight:t.height}}function nc(e,t,r,n={}){let i={x:Math.round(e.referenceWidth*t/100),y:Math.round(e.referenceHeight*r/100)};return void 0===n.marginPx?i:np(i,e,n.marginPx)}function np(e,t,r){return{x:ng(e.x,r,t.referenceWidth),y:ng(e.y,r,t.referenceHeight)}}function nd(e){return nn.parse(e)}function nm(e){return!!e&&e.width>0&&e.height>0}function nf(e){if(void 0===e)return .6;if(!Number.isFinite(e)||e<=0)throw new y("INVALID_ARGS","scroll amount must be a positive number");return e}function nh(e){if(!Number.isFinite(e)||e<=0)throw new y("INVALID_ARGS","scroll pixels must be a positive integer");return Math.max(1,Math.round(e))}function ng(e,t,r){let n=Math.max(t,r-t);return ny(e,t,n)}function ny(e,t,r){return Math.min(Math.round(r),Math.max(Math.round(t),Math.round(e)))}function nb(e,t,r,n){if(!Number.isFinite(e)||!Number.isInteger(e)||e<r||e>n)throw new y("INVALID_ARGS",`${t} must be an integer between ${r} and ${n}`);return e}function nw(e,t,r){return t>=e.x&&t<=e.x+e.width&&r>=e.y&&r<=e.y+e.height}function nv(e){let t=null,r=-1;for(let n of e){let e=n.width*n.height;e>r&&(t=n,r=e)}return t}function nx(e,t,r,n){return Math.max(e,r)<=Math.min(t,n)}function nS(e){let t=e.trim().toLowerCase();return!!t&&/^(vertical|horizontal)\s+scroll\s+bar(?:,?\s*\d+\s+pages?)?$/.test(t)}function nk(e,t){if(!(e?.trim().toLowerCase()??"").includes("vertical scroll bar"))return null;let r=function(e){if(!e)return null;let t=/^(\d{1,3})%$/.exec(e.trim());if(!t)return null;let r=Number(t[1]);return Number.isFinite(r)?Math.max(0,Math.min(100,r)):null}(t);return null===r?null:r<=1?{above:!1,below:!0}:r>=99?{above:!0,below:!1}:{above:!0,below:!0}}function nA(e){let t=new Map;for(let[r,n]of e.entries())t.set(n.index,r);let r=[],n=[];for(let[i,a]of e.entries()){let e=Math.max(0,a.depth??0);for(;n.length>0&&e<=n[n.length-1].depth;)n.pop();let o="number"==typeof a.parentIndex?t.get(a.parentIndex):void 0,s="number"==typeof o&&o<i?o:n[n.length-1]?.index;r.push({...a,index:i,depth:e,parentIndex:s}),n.push({depth:e,index:i})}return r}function nD(e){return new Map(e.map(e=>[e.index,e]))}function nI(e){return e.label?.trim()||e.value?.trim()||e.identifier?.trim()||""}function nM(e){if(0===e.length)return{nodes:e,hiddenCount:0,summaryLines:[]};let{byIndex:t,visibleNodeIndexes:r,offscreenNodes:n,hintedContainers:i}=nN(e),a=0===r.size?e:e.filter(e=>r.has(e.index));return{nodes:a.map(e=>(function(e,t){let r=t.get(e.index);if(!r||0===r.size)return e;let n=!!(!0===e.hiddenContentAbove||r.has("above"))||void 0,i=!!(!0===e.hiddenContentBelow||r.has("below"))||void 0;return{...e,hiddenContentAbove:n,hiddenContentBelow:i}})(e,i.directionsByContainer)),hiddenCount:0===r.size?0:e.length-a.length,summaryLines:function(e,t,r){let n=new Map;for(let i of e){let e=function(e,t,r){if(!e.rect)return null;let n=nO(e,t,r);return n?nE(e.rect,n):null}(i,t,r);if(!e)continue;let a=n.get(e)??[];a.push(i),n.set(e,a)}return["above","below"].flatMap(e=>{let t=n.get(e);if(!t||0===t.length)return[];let r=(function(e){let t=new Set,r=[];for(let n of e){let e=nI(n);!e||t.has(e)||(t.add(e),r.push(e))}return r})(t).slice(0,3).map(e=>`"${e}"`),i=1===t.length?"interactive item":"interactive items",a=r.length>0?`: ${r.join(", ")}`:"";return[`[off-screen ${e}] ${t.length} ${i}${a}`]})}(n.filter(e=>!i.coveredNodeIndexes.has(e.index)&&function(e){if(!0===e.hittable)return!0;let t=(e.type??"").toLowerCase();return t.includes("button")||t.includes("link")||t.includes("textfield")||t.includes("edittext")||t.includes("searchfield")||t.includes("checkbox")||t.includes("radio")||t.includes("switch")||t.includes("menuitem")||!!nI(e)}(e)),e,t)}}function nL(e){if(0===e.length)return new Map;let{hintedContainers:t}=nN(e);var r=t.directionsByContainer;let n=new Map;for(let[e,t]of r){let r={};t.has("above")&&(r.hiddenContentAbove=!0),t.has("below")&&(r.hiddenContentBelow=!0),(r.hiddenContentAbove||r.hiddenContentBelow)&&n.set(e,r)}return n}function nN(e){let t=nD(e),r=new Set,n=[];for(let i of e){if(nR(i,e,t)){!function(e,t,r){let n=e,i=new Set;for(;n&&!i.has(n.index);)i.add(n.index),t.add(n.index),n="number"==typeof n.parentIndex?r.get(n.parentIndex):void 0}(i,r,t);continue}n.push(i)}let i=function(e,t,r,n){let i=new Map,a=new Map,o=new Set;for(let e of t){if(!e.rect)continue;let t=nP(e,r,n);if(!t?.rect)continue;let s=nE(e.rect,t.rect);if(!s)continue;let l=i.get(t.index)??new Set;l.add(s),i.set(t.index,l);let u=a.get(t.index)??new Set;u.add(s),a.set(t.index,u),o.add(e.index)}return function(e,t,r,n,i){for(let a of e){let e=function(e){let t=nk(e.label,e.value);if(!t)return null;let r=new Set;return t.above&&r.add("above"),t.below&&r.add("below"),r.size>0?r:null}(a);if(!e||0===e.size)continue;let o=nP(a,t,r);if(!o)continue;let s=n.get(o.index)??new Set,l=i.get(o.index);for(let t of e)(!l||!(l.size>0)||l.has(t))&&s.add(t);n.set(o.index,s)}}(e,r,n,i,a),{directionsByContainer:i,coveredNodeIndexes:o}}(e,n,r,t);return{byIndex:t,visibleNodeIndexes:r,offscreenNodes:n,hintedContainers:i}}function nR(e,t,r=nD(t)){var n;if(!e.rect)return!0;let i=nO(e,t,r);return!i||(n=e.rect,nx(n.x,n.x+n.width,i.x,i.x+i.width)&&nx(n.y,n.y+n.height,i.y,i.y+i.height))}function nO(e,t,r=nD(t)){var n,i;let o=(n=e,i=r,n_(n,i,e=>!!e.rect)?.rect??null);return o||function(e,t){let r=a(t),n=e.filter(e=>{var t;return!!(t=e.rect)&&Number.isFinite(t.x)&&Number.isFinite(t.y)&&Number.isFinite(t.width)&&Number.isFinite(t.height)}),i=n.filter(e=>{let t=(e.type??"").toLowerCase();return t.includes("application")||t.includes("window")}),o=nv(i.map(e=>e.rect).filter(e=>nw(e,r.x,r.y)));if(o)return o;let s=nv(i.map(e=>e.rect));if(s)return s;let l=nv(n.map(e=>e.rect).filter(e=>nw(e,r.x,r.y)));return l||null}(t,e.rect??{x:0,y:0,width:0,height:0})}function nE(e,t){return e.y+e.height<=t.y?"above":e.y>=t.y+t.height?"below":null}function nP(e,t,r){return n_(e,r,e=>t.has(e.index))}function n_(e,t,r){let n="number"==typeof e.parentIndex?t.get(e.parentIndex):void 0,i=new Set;for(;n&&!i.has(n.index);){if(i.add(n.index),r(n)&&A(n))return n;n="number"==typeof n.parentIndex?t.get(n.parentIndex):void 0}return null}async function nC(e){let{edge:t,target:r={},scope:n,captureNodes:i}=e;try{let e=await i(n),a=function(e,t,r={}){var n,i,a;let o,s=(e??[]).map((e,t)=>({...e,ref:"ref"in e&&e.ref?e.ref:`e${t+1}`}));if(0===s.length)return{canScroll:!1,emptySnapshot:!0,signature:""};let l=nL(s),u=function(e,t,r,n){let i=new Map(e.map(e=>[e.index,e])),a=e.filter(e=>A(e)&&nG(e.rect));if(0===a.length)return null;let o=function(e,t){if(void 0===e)return null;let r=t.get(e);for(;r;){if(A(r)&&nG(r.rect))return r;r=void 0===r.parentIndex?void 0:t.get(r.parentIndex)}return null}(n.nodeIndex,i);if(o)return o;let s=n.point;if(s){let e=a.filter(e=>{var t,r;return e.rect&&(t=e.rect,(r=s).x>=t.x&&r.x<=t.x+t.width&&r.y>=t.y&&r.y<=t.y+t.height)}).sort(nj);if(e.length>0)return e.find(e=>nF(e,t.get(e.index),r))??e[0]??null}let l=a.filter(e=>nF(e,t.get(e.index),r)).sort(nV);return l.length>0?l[0]??null:a.filter(t=>nR(t,e)).sort(nV)[0]??a.sort(nV)[0]??null}(s,l,t,r),c=(u?(n=s,i=u.index,o=new Map(n.map(e=>[e.index,e])),n.filter(e=>e.index===i||function(e,t,r){let n=void 0===e.parentIndex?void 0:r.get(e.parentIndex);for(;n;){if(n.index===t)return!0;n=void 0===n.parentIndex?void 0:r.get(n.parentIndex)}return!1}(e,i,o))):s).map(e=>{let t=e.rect?["x","y","width","height"].map(t=>{var r;return r=e.rect?.[t],"number"==typeof r&&Number.isFinite(r)?r.toFixed(1):""}).join(","):"";return[String(e.index??""),String(e.parentIndex??""),String(e.type??""),String(e.label??""),String(e.value??""),t].join("|")}).join("\n");return u?{canScroll:nF(u,l.get(u.index),t),emptySnapshot:!1,signature:c,scope:[(a=u).identifier,a.label,a.value].map(e=>"string"==typeof e?e.trim():"").find(nU)}:{canScroll:!1,emptySnapshot:!1,signature:c}}(e,t,r);if(n&&a.emptySnapshot)return await nC({edge:t,target:r,captureNodes:i});return a}catch(e){var a,o,s;throw a=t,o=n,s=e,o?new y("COMMAND_FAILED",`Failed to verify scroll ${a} state for scoped container`,{scope:o,hint:`scroll ${a} could not verify the scoped scroll container. Run snapshot -i for the current screen and retry with a visible scroll target.`},s):new y("COMMAND_FAILED",`Failed to verify scroll ${a} state`,{hint:`scroll ${a} needs a snapshot showing hidden content ${"bottom"===a?"below":"above"} before it will move.`},s)}}async function nT(e){let t,{edge:r,captureState:n,scroll:i}=e,a=await n();a.scope&&(a=await n(a.scope));let o=0;for(;a.canScroll;){if(o>=40)throw new y("COMMAND_FAILED",`scroll ${r} reached the safety limit before the snapshot showed the edge`,{hint:"The scoped scroll container still reports hidden content. Use a smaller manual scroll + snapshot loop to inspect the current state."});t=await i(),o+=1,a=await n(a.scope)}return{passes:o,result:t}}function n$(e,t,r,n,i){return t&&0===r?`Already at ${t}; no hidden content ${"bottom"===t?"below":"above"} detected`:t?`Scrolled to ${t} with ${r} ${e} passes`:void 0!==i?`Scrolled ${e} by ${i}px`:void 0!==n?`Scrolled ${e} by ${n}`:`Scrolled ${e}`}function nF(e,t,r){return"bottom"===r?!0===e.hiddenContentBelow||t?.hiddenContentBelow===!0:!0===e.hiddenContentAbove||t?.hiddenContentAbove===!0}function nU(e){return e.length>0&&e.length<=80&&!/^(true|false)$/i.test(e)&&!/^\d+$/.test(e)&&!/^\d+%$/.test(e)}function nj(e,t){return nq(e.rect)-nq(t.rect)}function nV(e,t){return nq(t.rect)-nq(e.rect)}function nq(e){return e?e.width*e.height:0}function nG(e){return!!(e&&e.width>0&&e.height>0)}function nz(e,t){return{session:t.session,requestId:t.requestId,signal:t.signal??e.signal,metadata:t.metadata}}function nB(e){return e.clock?.now()??Date.now()}async function nH(e,t){e.clock?await e.clock.sleep(t):await new Promise(e=>setTimeout(e,t))}function nW(e){return e&&"object"==typeof e?e:void 0}let nK=["x","y","width","height"];function nJ(e){let t=nX(e);if(!t)return null;let r=a(t);return Number.isFinite(r.x)&&Number.isFinite(r.y)?r:null}function nX(e){if(!e)return null;let t=Number(e.x),r=Number(e.y),n=Number(e.width),i=Number(e.height);return Number.isFinite(t)&&Number.isFinite(r)&&Number.isFinite(n)&&Number.isFinite(i)&&!(n<0)&&!(i<0)?{x:t,y:r,width:n,height:i}:null}function nY(e,t){return!!e&&!!t&&nK.every(r=>.5>=Math.abs(e[r]-t[r]))}function nQ(e){return{x:nZ(e.x,e.width),y:nZ(e.y,e.height)}}function nZ(e,t){if(t<=1)return Math.floor(e);let r=Math.ceil(e);return Math.round(Math.min(Math.floor(e+t-1),Math.max(r,e+t/2)))}let n0=["tabbar","toolbar","navigationbar","bottomnavigation","bottomnavigationview","sheet","dialog","alert","popover","menu"],n1=["button","link","menuitem","tabitem","textfield","searchfield","edittext","checkbox","radio","switch","cell"];function n2(e){if(e.length<2)return e;let t=[...e],r={nodes:t,byIndex:new Map(t.map(e=>[e.index,e]))},n=!1;for(let[e,i]of t.entries()){if(!function(e){return!!n6(e.rect)&&(!!(!0===e.hittable||n3(e,n1))||!!(e.label?.trim()||e.value?.trim()||e.identifier?.trim()))}(i)||!function e(t,r,n){let i=n6(n.rect);if(!i)return null;let o=a(i);for(let a=r+1;a<t.nodes.length;a+=1){let r=t.nodes[a];if(r&&function(t,r,n,i,a){if(!t.nodes[r])return!1;let o=function(t,r,n,i){var a,o,s,l;let u=t.nodes[r];if(!u||!(!(!n6((a=u).rect)||function(e){let t=n8(e);return t.includes("application")||t.includes("window")}(a))&&n3(a,n0))||n4(o=n,s=u,l=t.byIndex)||n4(s,o,l))return null;let c=n6(u.rect);return!c||nY(i,c)||e(t,r,u)?null:c}(t,r,n,i);return!!(o&&nw(o,a.x,a.y))}(t,a,n,i,o))return r}return null}(r,e,i))continue;n=!0;let o={...i,hittable:!1,interactionBlocked:"covered",presentationHints:Array.from(new Set([...i.presentationHints??[],"covered"]))};t[e]=o,r.byIndex.set(o.index,o)}return n?t:e}function n5(e){return void 0!==e.interactionBlocked}function n3(e,t){let r=n8(e);return t.some(e=>r.includes(e))}function n8(e){return[e.type,e.role,e.subrole].map(e=>g(e??"")).join(" ")}function n4(e,t,r){let n="number"==typeof t.parentIndex?r.get(t.parentIndex):void 0,i=new Set;for(;n&&!i.has(n.index);){if(n.index===e.index)return!0;i.add(n.index),n="number"==typeof n.parentIndex?r.get(n.parentIndex):void 0}return!1}function n6(e){let t=nX(e);return t&&t.width>0&&t.height>0?t:null}let n9=["button","link","menuitem","tabitem","textfield","searchfield","securetextfield","checkbox","radio","switch","cell"];function n7(e,t){return ie(e,t).node}function ie(e,t){var r;if(n5(t))return{node:t,reason:"covered"};let n=function(e,t){let r=nX(t.rect);if(!r)return null;let n=t,i=new Set;for(;!i.has(n.ref);){i.add(n.ref);let t=e.filter(e=>{if(e.parentIndex!==n.index||!e.hittable||n5(e))return!1;let t=nX(e.rect);return!!t&&nY(t,r)});if(1!==t.length)break;n=t[0]}return n===t?null:n}(e,t);if(n?.rect&&nJ(n.rect))return{node:n,reason:"same-rect-descendant"};if([(r=t).type,r.role,r.subrole].map(e=>g(e??"")).some(it)&&t.rect&&nJ(t.rect))return{node:t,reason:"semantic-target"};let i=l(e,t);return i?.rect&&!n5(i)&&nJ(i.rect)?!function(e,t,r){var n,i;let o,s,l,u=nX(e.rect),c=nX(t.rect);if(!u||!c)return!1;let p=function(e,t){let r=a(t),n=e.filter(e=>{let t=(e.type??"").toLowerCase();return t.includes("application")||t.includes("window")}).map(e=>nX(e.rect)).filter(e=>null!==e);if(0===n.length)return null;let i=n.filter(e=>nw(e,r.x,r.y));return nv(i.length>0?i:n)}(r,u);return!!p&&(o=k(n=c,i=p),s=n.width*n.height,l=i.width*i.height,!(o<=0)&&!(s<=0)&&!(l<=0)&&!!(o/l>=.9)&&!!(o/s>=.8))&&!nY(u,c)}(t,i,e)?{node:i,reason:"hittable-ancestor"}:{node:t,reason:"overly-broad-ancestor"}:{node:t,reason:"original"}}function it(e){return"tab"===e||n9.some(t=>e.includes(t))}async function ir(e,t,r){var n;return(await ip(e,t,r.action),"point"===t.target.kind)?{kind:"point",point:{x:(n=t.target).x,y:n.y}}:"ref"===t.target.kind?await ii(e,t,t.target,r):await ia(e,t,t.target,r)}async function ii(e,t,r,i){let a=await im(e,t,r),o=a.resolved,s=i.promoteToHittableAncestor?is(a.snapshot.nodes,o.node,{action:i.action,label:`Ref ${r.ref}`}):o.node;return il(s,`Ref ${r.ref}`,i.action),function(e,t,r,i){let a=e.rect?nO(e,t):null;if(!(!e.rect||!a||nR(e,t)))throw new y("COMMAND_FAILED",`Ref ${r} is off-screen and not safe to ${i}`,{reason:"offscreen_ref",ref:n(r),rect:e.rect,viewport:a,hint:`Use scroll with the direction from the off-screen summary, take a fresh snapshot, then retry ${i} with the new ref or a selector.`})}(s,a.snapshot.nodes,r.ref,i.action),{kind:"ref",point:ig(s,`Ref ${r.ref} not found or has invalid bounds`),target:{kind:"ref",ref:`@${o.ref}`},node:s,selectorChain:c(s,e.backend.platform,{action:"fill"===i.action?"fill":"click"}),refLabel:m(s,a.snapshot.nodes)}}async function ia(e,t,r,n){let i=p(r.selector),a=await ic(e,t,n.requireInteractive),o=f(io(a.snapshot.nodes),i,{platform:e.backend.platform,requireRect:!0,requireUnique:!0,disambiguateAmbiguous:!0});if(o&&o.node.rect||!n.requireInteractive||(o=f(io((a=await ic(e,t,!1)).snapshot.nodes),i,{platform:e.backend.platform,requireRect:!0,requireUnique:!0,disambiguateAmbiguous:!0})),!o||!o.node.rect){let t=f(a.snapshot.nodes,i,{platform:e.backend.platform,requireRect:!0,requireUnique:!1});if(t?.node&&n5(t.node))throw iu({label:`Selector ${t.selector.raw}`,node:t.node,action:n.action,selector:t.selector.raw});throw new y("COMMAND_FAILED",h(i,o?.diagnostics??[],{unique:!0}))}let s=n.promoteToHittableAncestor?is(a.snapshot.nodes,o.node,{action:n.action,label:`Selector ${o.selector.raw}`}):o.node;return il(s,`Selector ${o.selector.raw}`,n.action),{kind:"selector",point:ig(s,`Selector ${o.selector.raw} resolved to invalid bounds`),target:{kind:"selector",selector:o.selector.raw},node:s,selectorChain:c(s,e.backend.platform,{action:"fill"===n.action?"fill":"click"}),refLabel:m(s,a.snapshot.nodes)}}function io(e){return e.filter(e=>!n5(e))}function is(e,t,r){let n=ie(e,t);if("covered"===n.reason)throw iu({label:r.label,node:t,action:r.action});return n.node}function il(e,t,r){if(n5(e))throw iu({label:t,node:e,action:r})}function iu(e){return new y("COMMAND_FAILED",`${e.label} is covered by another visible element and cannot ${function(e){switch(e){case"fill":return"be filled";case"focus":return"be focused";case"longPress":return"be long-pressed";default:return"be tapped"}}(e.action)} safely`,{hint:"Use a different visible target, scroll it clear of the overlay, or inspect with snapshot/screenshot before retrying.",...e.selector?{selector:e.selector}:{},ref:`@${e.node.ref}`,interactionBlocked:e.node.interactionBlocked})}async function ic(e,t,r){if(!e.backend.captureSnapshot)throw new y("UNSUPPORTED_OPERATION","snapshot is not supported by this backend");let n=t.session??"default",i=await e.sessions.get(n);if(!i)throw new y("SESSION_NOT_FOUND","No active session. Run open first.");let a=await e.backend.captureSnapshot(nz(e,t),{interactiveOnly:r}),o=a.snapshot??{nodes:a.nodes??[],truncated:a.truncated,backend:a.backend,createdAt:nB(e)};return await e.sessions.set({...i,snapshot:o}),{snapshot:o}}async function ip(e,t,r){if("macos"!==e.backend.platform)return;let n=await id(e,t);if(("desktop"===n||"menubar"===n)&&("menubar"!==n||"click"!==r&&"press"!==r))throw new y("UNSUPPORTED_OPERATION",`${r} is not supported on macOS ${n} sessions yet. Open an app session to act, or use the ${n} surface to inspect.`)}async function id(e,t){let r=await e.sessions.get(t.session??"default");return r?.metadata?.surface}async function im(e,t,r){let n=t.session??"default",i=await e.sessions.get(n);if(!i)throw new y("SESSION_NOT_FOUND","No active session. Run open first.");if(!i.snapshot)throw new y("INVALID_ARGS","No snapshot in session. Run snapshot first.");let a=r.fallbackLabel??"",o=ih(i.snapshot.nodes,r.ref,{fallbackLabel:a});if(o)return{snapshot:i.snapshot,resolved:o};let s=await ic(e,t,!0),l=ih(s.snapshot.nodes,r.ref,{fallbackLabel:a});if(!l)throw new y("COMMAND_FAILED",`Ref ${r.ref} not found or has no bounds`);return{...s,resolved:l}}function ih(e,t,i){let a=n(t);if(!a)throw new y("INVALID_ARGS",`Invalid ref: ${t}`);let o=r(e,a);if(iy(o))return{ref:a,node:o};let s=i.fallbackLabel.length>0?d(e,i.fallbackLabel):null;return iy(s)?{ref:a,node:s}:null}function ig(e,t){let r=nJ(e.rect);if(!r)throw new y("COMMAND_FAILED",t);return r}function iy(e){return!!e&&null!==nJ(e.rect)}let ib=async(e,t)=>{let r=await ir(e,t,{action:"focus",requireInteractive:!0,promoteToHittableAncestor:!1});if(!e.backend.focus)throw new y("UNSUPPORTED_OPERATION","focus is not supported by this backend");let n=nW(await e.backend.focus(nz(e,t),r.point));return{...r,...n?{backendResult:n}:{},...eJ(`Focused (${r.point.x}, ${r.point.y})`)}},iw=async(e,t)=>{let r=await ir(e,t,{action:"longPress",requireInteractive:!0,promoteToHittableAncestor:!0});if(!e.backend.longPress)throw new y("UNSUPPORTED_OPERATION","longPress is not supported by this backend");let n=void 0===t.durationMs?void 0:nb(t.durationMs,"durationMs",0,12e4),i=nW(await e.backend.longPress(nz(e,t),r.point,{durationMs:n}));return{...r,...void 0!==n?{durationMs:n}:{},...i?{backendResult:i}:{},...eJ(`Long pressed (${r.point.x}, ${r.point.y})`)}},iv=async(e,t)=>{var r,n,i,a;let o;if(!e.backend.scroll)throw new y("UNSUPPORTED_OPERATION","scroll is not supported by this backend");let s="bottom"===(r=t.direction)?{direction:"down",edge:"bottom"}:"top"===r?{direction:"up",edge:"top"}:{direction:iM(r,"scroll direction")},l=(n=t.amount,i="scroll amount",void 0===n?void 0:iN(n,i)),u=function(e,t){if(void 0!==e){if(!Number.isFinite(e)||!Number.isInteger(e)||e<=0)throw new y("INVALID_ARGS",`${t} must be a positive integer`);return e}}(t.pixels,"scroll pixels");if(void 0!==l&&void 0!==u)throw new y("INVALID_ARGS","scroll accepts either amount or pixels, not both");let c=await iA(e,t),p="viewport"===c.kind?{kind:"viewport"}:{kind:"point",point:c.point},d=e.backend.scroll,m=async()=>await d(nz(e,t),p,{direction:s.direction,...void 0!==l?{amount:l}:{},...void 0!==u?{pixels:u}:{}}),f=0;if(s.edge){let r=s.edge,n="viewport"===(a=c).kind?{}:{point:a.point,nodeIndex:"node"in a?a.node.index:void 0},i=await nT({edge:r,captureState:async i=>await iI(e,t,r,n,i),scroll:m});o=i.result,f=i.passes}else o=await m(),f=1;let h=nW(o);return{...c,direction:s.direction,...s.edge?{edge:s.edge,passes:f}:{},...void 0!==l?{amount:l}:{},...void 0!==u?{pixels:u}:{},...h?{backendResult:h}:{},...eJ(n$(s.direction,s.edge,f,l,u))}},ix=async(e,t)=>{if(!e.backend.swipe)throw new y("UNSUPPORTED_OPERATION","swipe is not supported by this backend");if(t.preset)return await iS(e,t,e.backend.swipe);let r=await iD(e,t),n=function(e,t){if(t.to)return{point:iL(t.to,"to")};let r=iM(t.direction,"swipe direction"),n=iN(t.distance??200,"swipe distance");switch(r){case"up":return{point:{x:e.x,y:e.y-n},direction:r,distance:n};case"down":return{point:{x:e.x,y:e.y+n},direction:r,distance:n};case"left":return{point:{x:e.x-n,y:e.y},direction:r,distance:n};case"right":return{point:{x:e.x+n,y:e.y},direction:r,distance:n}}}(r.point,t),i=void 0===t.durationMs?void 0:nb(t.durationMs,"durationMs",16,1e4),a=nW(await e.backend.swipe(nz(e,t),r.point,n.point,{durationMs:i}));return{kind:"swipe",from:r.point,to:n.point,...n.direction?{direction:n.direction}:{},...void 0!==n.distance?{distance:n.distance}:{},...void 0!==i?{durationMs:i}:{},...r.target?{fromTarget:r.target}:{},...a?{backendResult:a}:{},...eJ("Swiped")}};async function iS(e,t,r){let n;if(t.from||t.to||t.direction||void 0!==t.distance)throw new y("INVALID_ARGS","gesture swipe preset cannot be combined with from, to, direction, or distance");let i=nl(t.preset);await ip(e,t,"swipe");let a=ns(i,{referenceWidth:(n=iR((await ic(e,t,!1)).snapshot.nodes)).width,referenceHeight:n.height},{platform:e.backend.platform}),o=void 0===t.durationMs?void 0:nb(t.durationMs,"durationMs",16,1e4),s={x:a.x1,y:a.y1},l={x:a.x2,y:a.y2},u=nW(await r(nz(e,t),s,l,{durationMs:o}));return{kind:"swipe",from:s,to:l,preset:i,...void 0!==o?{durationMs:o}:{},fromTarget:{kind:"viewport"},...u?{backendResult:u}:{},...eJ(`Swiped ${i}`)}}let ik=async(e,t)=>{if(!e.backend.pinch)throw new y("UNSUPPORTED_OPERATION","pinch is not supported by this backend");await ip(e,t,"pinch");let r=iN(t.scale,"pinch scale"),n=t.center?await ir(e,{...t,target:t.center},{action:"pinch",requireInteractive:!1,promoteToHittableAncestor:!1}):void 0,i=nW(await e.backend.pinch(nz(e,t),{scale:r,...n?{center:n.point}:{}}));return{kind:"pinch",scale:r,...n?{center:n.point,centerTarget:n}:{},...i?{backendResult:i}:{},...eJ(`Pinched to scale ${r}`)}};async function iA(e,t){let r=t.target??{kind:"viewport"};return"viewport"===r.kind?(await ip(e,t,"scroll"),{kind:"viewport"}):await ir(e,{...t,target:r},{action:"scroll",requireInteractive:!1,promoteToHittableAncestor:!1})}async function iD(e,t){if(t.from){var r;if("x"in(r=t.from)&&"y"in r)return await ip(e,t,"swipe"),{point:iL(t.from,"from")};let n=await ir(e,{...t,target:t.from},{action:"swipe",requireInteractive:!1,promoteToHittableAncestor:!1});return{point:n.point,target:n}}if(!t.direction)throw new y("INVALID_ARGS","swipe requires from+to or a direction");return await ip(e,t,"swipe"),{point:a(iR((await ic(e,t,!1)).snapshot.nodes)),target:{kind:"viewport"}}}async function iI(e,t,r,n,i){if(!e.backend.captureSnapshot)throw new y("UNSUPPORTED_OPERATION",`scroll ${r} requires snapshot support to verify hidden content before scrolling`);let{captureSnapshot:a}=e.backend;return await nC({edge:r,target:n,scope:i,captureNodes:async r=>{let n=await a(nz(e,t),{scope:r});return n.snapshot?.nodes??n.nodes??[]}})}function iM(e,t){switch(e){case"up":case"down":case"left":case"right":return e;default:throw new y("INVALID_ARGS",`${t} must be up, down, left, or right`)}}function iL(e,t){let r=Number(e.x),n=Number(e.y);if(!Number.isFinite(r)||!Number.isFinite(n))throw new y("INVALID_ARGS",`${t} point requires finite x and y`);return{x:r,y:n}}function iN(e,t){if(!Number.isFinite(e)||e<=0)throw new y("INVALID_ARGS",`${t} must be a positive number`);return e}function iR(e){let t=e.filter(t=>nR(t,e)).map(e=>e.rect).filter(iO),r=t.length>0?t:e.map(e=>e.rect).filter(iO);if(0===r.length)throw new y("COMMAND_FAILED","Cannot infer viewport for directional swipe");let n=Math.min(...r.map(e=>e.x)),i=Math.min(...r.map(e=>e.y));return{x:n,y:i,width:Math.max(...r.map(e=>e.x+e.width))-n,height:Math.max(...r.map(e=>e.y+e.height))-i}}function iO(e){return!!(e&&e.width>0&&e.height>0)}let iE={click:"Click or tap a semantic UI target by ref, selector, or point.",press:"Press a semantic UI target by ref, selector, or point.",fill:"Fill text into a semantic UI target by ref, selector, or point.",longpress:"Long press by ref, selector, or point.",swipe:"Swipe between two points.",focus:"Focus input at coordinates.",type:"Type text in the focused field.",scroll:"Scroll in a direction or to an edge.",get:"Get element text or attributes.",is:"Assert UI state.",find:"Find an element and optionally act on it.",gesture:"Run a structured gesture."},iP={target:P(V()),button:F(["primary","secondary","middle"],"Pointer button for platforms that support mouse buttons."),...G(),...z()},i_={target:P(V()),...G(),...z()},iC={target:P(V()),text:P(_("Text to enter into the target.")),delayMs:T("Delay between typed characters.",{min:0}),...G()},iT={target:P(V()),durationMs:T("Long press duration in milliseconds.",{min:0}),...G()},i$={from:P(q("Swipe start point.")),to:P(q("Swipe end point.")),durationMs:T("Swipe duration in milliseconds.",{min:0}),count:T("Number of swipe repetitions.",{min:1}),pauseMs:T("Pause between repeated swipes.",{min:0}),pattern:F(nt)},iF={x:P(C("X coordinate.")),y:P(C("Y coordinate."))},iU={text:P(_("Text to type.")),delayMs:T("Delay between typed characters.",{min:0})},ij={direction:P(F(["up","down","left","right","top","bottom"])),amount:C("Platform scroll amount."),pixels:T("Pixel scroll amount.",{min:0})},iV={format:P(F(["text","attrs"])),target:P(eu({oneOf:ep(),description:"UI element target by snapshot ref or selector expression."},(e,t)=>{let r,n;return void 0===e[t]?void 0:"ref"===(n=er(r=ed(e,t),"kind",["ref","selector"]))?{kind:n,ref:X(r,"ref"),label:Y(r,"label")}:{kind:n,selector:X(r,"selector")}})),...G()},iq={predicate:P(F(["visible","hidden","exists","editable","selected","text"])),selector:P(_()),value:_(),...G()},iG={locator:F(D),query:P(_()),action:F(["click","focus","exists","getText","getAttrs","wait","fill","type"]),value:_(),timeoutMs:T(),first:$(),last:$(),depth:T(),raw:$()},iz={kind:P(F(x,"Gesture variant.")),direction:F(r7,"Fling direction."),preset:F(ne,"Swipe preset."),origin:q("Gesture origin point."),delta:q("Movement delta for pan or transform gestures."),distance:T("Fling distance.",{min:0}),scale:C("Pinch or transform scale."),degrees:C("Rotation in degrees."),velocity:T("Rotate gesture velocity.",{min:0}),durationMs:T("Gesture duration in milliseconds.",{min:0})},iB=[{name:"click",description:iE.click,inputSchema:B(iP),readInput:e=>H(e,iP)},{name:"press",description:iE.press,inputSchema:B(i_),readInput:e=>H(e,i_)},{name:"fill",description:iE.fill,inputSchema:B(iC),readInput:e=>H(e,iC)},iH("longpress",iT),iH("swipe",i$),iH("focus",iF),iH("type",iU),iH("scroll",ij),iH("get",iV),iH("is",iq),iH("find",iG),{name:"gesture",description:iE.gesture,inputSchema:B(iz),readInput:function(e){let t=W(e),r=K(t),n=er(t,"kind",x);return"pan"===n?{...r,kind:n,origin:J(t,"origin"),delta:J(t,"delta"),durationMs:ee(t,"durationMs",{min:0})}:"fling"===n?{...r,kind:n,direction:er(t,"direction",r7),origin:J(t,"origin"),distance:ee(t,"distance",{min:0}),durationMs:ee(t,"durationMs",{min:0})}:"swipe"===n?{...r,kind:n,preset:er(t,"preset",ne),durationMs:ee(t,"durationMs",{min:0})}:"pinch"===n?{...r,kind:n,scale:Q(t,"scale"),origin:iW(t,"origin")}:"rotate"===n?{...r,kind:n,degrees:Q(t,"degrees"),origin:iW(t,"origin"),velocity:ee(t,"velocity",{min:0})}:{...r,kind:n,origin:J(t,"origin"),delta:J(t,"delta"),scale:Q(t,"scale"),degrees:Q(t,"degrees"),durationMs:ee(t,"durationMs",{min:0})}}}];function iH(e,t){return rd(e,iE[e],t)}function iW(e,t){return void 0===e[t]?void 0:J(e,t)}let iK={gesture:function(e,t){let r=e[0],n=e.slice(1),i=eh(t);switch(r){case"pan":return{...i,kind:r,origin:{x:Number(n[0]),y:Number(n[1])},delta:{x:Number(n[2]),y:Number(n[3])},durationMs:eL(n[4])};case"fling":return{...i,kind:r,direction:n[0],origin:{x:Number(n[1]),y:Number(n[2])},distance:eL(n[3]),durationMs:eL(n[4])};case"swipe":return{...i,kind:r,preset:n[0],durationMs:eL(n[1])};case"pinch":return{...i,kind:r,scale:Number(n[0]),origin:void 0===n[1]||void 0===n[2]?void 0:{x:Number(n[1]),y:Number(n[2])}};case"rotate":return{...i,kind:r,degrees:Number(n[0]),origin:void 0===n[1]||void 0===n[2]?void 0:{x:Number(n[1]),y:Number(n[2])},velocity:eL(n[3])};case"transform":return{...i,kind:r,origin:{x:Number(n[0]),y:Number(n[1])},delta:{x:Number(n[2]),y:Number(n[3])},scale:Number(n[4]),degrees:Number(n[5]),durationMs:eL(n[6])};default:throw new y("INVALID_ARGS","gesture requires pan, fling, swipe, pinch, rotate, or transform")}}},iJ={gesture:em(S.gesture,function(e){switch(e.kind){case"pan":return["pan",String(e.origin?.x),String(e.origin?.y),String(e.delta?.x),String(e.delta?.y),...eR(e.durationMs)];case"fling":return["fling",eE(e.direction,"gesture fling requires direction"),String(e.origin?.x),String(e.origin?.y),...eR(e.distance),...eR(e.durationMs)];case"swipe":return iX(e);case"pinch":return["pinch",String(e.scale),...eR(e.origin?.x),...eR(e.origin?.y)];case"rotate":return["rotate",String(e.degrees),...eR(e.origin?.x),...eR(e.origin?.y),...eR(e.velocity)];case"transform":return["transform",String(e.origin?.x),String(e.origin?.y),String(e.delta?.x),String(e.delta?.y),String(e.scale),String(e.degrees),...eR(e.durationMs)];default:throw new y("INVALID_ARGS","gesture requires pan, fling, swipe, pinch, rotate, or transform")}}),"gesture-pan":em(S.gesture,function(e){return["pan",String(e.x),String(e.y),String(e.dx),String(e.dy),...eR(e.durationMs)]}),"gesture-fling":em(S.gesture,e=>{var t;let r;return r=void 0!==(t=e).durationMs?t.distance??180:t.distance,["fling",t.direction,String(t.x),String(t.y),...eR(r),...eR(t.durationMs)]}),"gesture-swipe":em(S.gesture,iX),"gesture-pinch":em(S.gesture,function(e){return["pinch",String(e.scale),...eR(e.x),...eR(e.y)]}),"gesture-rotate":em(S.gesture,e=>(function(e){var t=e;if(void 0===t.x&&void 0!==t.y||void 0!==t.x&&void 0===t.y)throw new y("INVALID_ARGS","gesture rotate center requires both x and y");let r=void 0===e.x||void 0===e.y?[]:[String(e.x),String(e.y)];return["rotate",String(e.degrees),...r,...eR(e.velocity)]})(e)),"gesture-transform":em(S.gesture,function(e){return["transform",String(e.x),String(e.y),String(e.dx),String(e.dy),String(e.scale),String(e.degrees),...eR(e.durationMs)]})};function iX(e){return["swipe",eE(e.preset,"gesture swipe requires preset"),...eR(e.durationMs)]}function iY(e){if(e[0]?.startsWith("@")){let t=iZ(e.slice(1));return{ref:e[0],...void 0===t?{}:{label:t}}}let t=s(e);return t?{selector:t.selectorExpression}:{x:Number(e[0]),y:Number(e[1])}}function iQ(e){let t=e[0];if(t?.startsWith("@")){let r=e.length>=3?e.slice(2).join(" "):e.slice(1).join(" ");return{kind:"ref",target:{ref:t,label:e.length>=3?iZ(e.slice(1,2)):void 0},text:r}}let r=s(e,{preferTrailingValue:!0});return r?{kind:"selector",target:{selector:r.selectorExpression},text:r.rest.join(" ")}:{kind:"point",target:{x:Number(e[0]),y:Number(e[1])},text:e.slice(2).join(" ")}}function iZ(e){return e.join(" ").trim()||void 0}let i0={click:(e,t)=>({...eh(t),...ey(t),...ew(t),target:ev(iY(e)),button:t.clickButton}),press:(e,t)=>({...eh(t),...ey(t),...ew(t),target:ev(iY(e))}),longpress:(e,t)=>{let r,n={...iY((r=function(e){if(eM(e[0])&&eM(e[1]))return{target:e.slice(0,2),...void 0!==e[2]?{durationMs:Number(e[2])}:{}};let t=e.at(-1);return e.length>1&&eM(t)?{target:e.slice(0,-1),durationMs:Number(t)}:{target:e}}(e)).target),...void 0!==r.durationMs?{durationMs:r.durationMs}:{}};return{...eh(t),...ey(t),target:ev(n),durationMs:n.durationMs}},swipe:(e,t)=>({...eh(t),from:{x:Number(e[0]),y:Number(e[1])},to:{x:Number(e[2]),y:Number(e[3])},durationMs:eL(e[4]),count:t.count,pauseMs:t.pauseMs,pattern:t.pattern}),focus:(e,t)=>({...eh(t),x:Number(e[0]),y:Number(e[1])}),type:(e,t)=>({...eh(t),text:e.join(" "),delayMs:t.delayMs}),fill:(e,t)=>{let r=iQ(e);return{...eh(t),...ey(t),target:ev(r.target),text:r.text,delayMs:t.delayMs}},scroll:(e,t)=>({...eh(t),direction:function(e){if("up"===e||"down"===e||"left"===e||"right"===e||"top"===e||"bottom"===e)return e;throw new y("INVALID_ARGS",`Unknown direction: ${String(e)}`)}(e[0]),amount:eL(e[1]),pixels:t.pixels}),get:(e,t)=>({...eh(t),...ey(t),format:function(e){if("text"===e||"attrs"===e)return e;throw new y("INVALID_ARGS","get only supports text or attrs")}(e[0]),target:ev(function(e){if(e[0]?.startsWith("@"))return{ref:e[0],label:e.slice(1).join(" ").trim()||void 0};let t=e.join(" ").trim();if(!t)throw new y("INVALID_ARGS","get requires @ref or selector expression");return{selector:t}}(e.slice(1)))})},i1={click:e=>ef(S.click,ex(e),{...e,clickButton:e.button}),press:em(S.press,e=>ex(e)),longpress:em(S.longPress,e=>{var t;return[...ex(t=e),...eR(t.durationMs)]}),swipe:em(S.swipe,function(e){return[String(e.from?.x),String(e.from?.y),String(e.to?.x),String(e.to?.y),...eR(e.durationMs)]}),focus:em(S.focus,e=>[String(e.x),String(e.y)]),type:em(S.type,e=>[e.text]),fill:em(S.fill,e=>{var t;return[...ex(t=e),t.text]}),scroll:em(S.scroll,e=>[eE(e.direction,"scroll requires direction"),...eR(e.amount)]),get:em(S.get,e=>[eE(e.format,"get requires format"),...function(e){let t=eS(e);if("string"==typeof t.ref)return[t.ref,...eA(t.label)];if("string"==typeof t.selector)return[t.selector];throw new y("INVALID_ARGS","element command requires @ref or selector target")}(e)])},i2={find:(e,t)=>(function(e,t){var r;let n={...{depth:(r=t).snapshotDepth,raw:r.snapshotRaw},...eg(t),first:t.findFirst,last:t.findLast},i=function(e){if("text"===e||"label"===e||"value"===e||"role"===e||"id"===e)return e}(e[0]),a=void 0!==i,o=a?e[1]:e[0],s=a?2:1,l=e[s];if(void 0===l)return{...n,locator:i,query:i3(o)};if("get"===l){let t=e[s+1];if("text"===t)return{...n,locator:i,query:i3(o),action:"getText"};if("attrs"===t)return{...n,locator:i,query:i3(o),action:"getAttrs"};throw new y("INVALID_ARGS","find get only supports text or attrs")}if("wait"===l)return{...n,locator:i,query:i3(o),action:"wait",timeoutMs:eL(e[s+1])};if("fill"===l||"type"===l)return{...n,locator:i,query:i3(o),action:l,value:e.slice(s+1).join(" ")};if("click"===l||"focus"===l||"exists"===l)return{...n,locator:i,query:i3(o),action:l};throw new y("INVALID_ARGS",`Unsupported find action: ${l}`)})(e,t),is:(e,t)=>(function(e,t){let r={...eb(t),...eg(t)},n=e[0],i=function(e,t={}){let r=s(e,t);if(!r)throw new y("INVALID_ARGS","is requires a selector expression");return r}(e.slice(1),{preferTrailingValue:"text"===n});if("text"===n)return{...r,predicate:n,selector:i.selectorExpression,value:i.rest.join(" ")};if("visible"===n||"hidden"===n||"exists"===n||"editable"===n||"selected"===n)return{...r,predicate:n,selector:i.selectorExpression};throw new y("INVALID_ARGS","is requires predicate: visible|hidden|exists|editable|selected|text")})(e,t)},i5={is:em(S.is,e=>{var t;return[(t=e).predicate,t.selector,..."text"===t.predicate?[t.value]:[]]}),find:e=>ef(S.find,function(e){let t=e.locator&&"any"!==e.locator?[e.locator,e.query]:[e.query];switch(e.action){case void 0:case"click":case"focus":case"exists":return e.action?[...t,e.action]:t;case"getText":return[...t,"get","text"];case"getAttrs":return[...t,"get","attrs"];case"wait":return[...t,"wait",...eR(e.timeoutMs)];case"fill":case"type":return[...t,e.action,e.value]}}(e),{...e,findFirst:e.first,findLast:e.last})};function i3(e){if(void 0===e||""===e)throw new y("INVALID_ARGS","find requires query");return e}let i8={get:{usageOverride:"get text|attrs <@ref|selector>",positionalArgs:["subcommand","target"],allowedFlags:[...rr]},find:{usageOverride:"find <locator|text> <action> [value] [--first|--last]",helpDescription:"Find by text/label/value/role/id and run action",summary:"Find an element and act",positionalArgs:["query","action","value?"],allowsExtraPositionals:!0,allowedFlags:["snapshotDepth","snapshotRaw","findFirst","findLast"]},is:{positionalArgs:["predicate","selector","value?"],allowsExtraPositionals:!0,allowedFlags:[...rr]},click:{usageOverride:"click <x y|@ref|selector>",positionalArgs:["target"],allowsExtraPositionals:!0,allowedFlags:[...ra,"clickButton",...rr]},press:{usageOverride:"press <x y|@ref|selector>",positionalArgs:["targetOrX","y?"],allowsExtraPositionals:!0,allowedFlags:[...ra,...rr]},longpress:{usageOverride:"longpress <x y|@ref|selector> [durationMs]",positionalArgs:["targetOrX","yOrDurationMs?","durationMs?"],allowsExtraPositionals:!0,allowedFlags:[...rr]},swipe:{helpDescription:"Swipe coordinates with optional repeat pattern",positionalArgs:["x1","y1","x2","y2","durationMs?"],allowedFlags:["count","pauseMs","pattern"]},gesture:{usageOverride:"gesture <pan|fling|swipe|pinch|rotate|transform> ...",listUsageOverride:"gesture <pan|fling|swipe|pinch|rotate|transform> ...",helpDescription:"Run touch gestures: pan <x> <y> <dx> <dy> [durationMs], fling <up|down|left|right> <x> <y> [distance] [durationMs], swipe <left|right|left-edge|right-edge> [durationMs], pinch <scale> [x] [y], rotate <degrees> [x] [y] [velocity], or transform <x> <y> <dx> <dy> <scale> <degrees> [durationMs]",summary:"Run pan, fling, swipe, pinch, rotate, or transform gestures",positionalArgs:["pan|fling|swipe|pinch|rotate|transform","args?"],allowsExtraPositionals:!0},focus:{positionalArgs:["x","y"]},type:{positionalArgs:["text"],allowsExtraPositionals:!0,allowedFlags:["delayMs"]},fill:{usageOverride:"fill <x> <y> <text> | fill <@ref|selector> <text>",positionalArgs:["targetOrX","yOrText","text?"],allowsExtraPositionals:!0,allowedFlags:[...rr,"delayMs"]},scroll:{usageOverride:"scroll <direction|top|bottom> [amount] [--pixels <n>]",helpDescription:"Scroll in direction, or verify hidden content and scroll toward top/bottom",summary:"Scroll in a direction or to an edge",positionalArgs:["directionOrEdge","amount?"],allowedFlags:["pixels"]}},i4=[eP(i6("click"),(e,t)=>{var r;return e.interactions.click({...ei(r=t),...ea(r.target),...es(r),...eo(r),button:r.button})}),eP(i6("press"),(e,t)=>{var r;return e.interactions.press({...ei(r=t),...ea(r.target),...es(r),...eo(r)})}),eP(i6("fill"),(e,t)=>{var r;return e.interactions.fill({...ei(r=t),...ea(r.target),...es(r),text:r.text,delayMs:r.delayMs})}),eP(i6("longpress"),(e,t)=>{var r;return e.interactions.longPress({...ei(r=t),...ea(r.target),...es(r),durationMs:r.durationMs})}),eP(i6("swipe"),(e,t)=>e.interactions.swipe(t)),eP(i6("focus"),(e,t)=>e.interactions.focus(t)),eP(i6("type"),(e,t)=>e.interactions.type(t)),eP(i6("scroll"),(e,t)=>e.interactions.scroll(t)),eP(i6("get"),(e,t)=>{var r;return e.interactions.get({...ei(r=t),...function(e){switch(e.kind){case"ref":return{ref:e.ref,label:e.label};case"selector":return{selector:e.selector}}}(r.target),...es(r),format:r.format})}),eP(i6("is"),(e,t)=>e.interactions.is(t)),eP(i6("find"),(e,t)=>e.interactions.find(t)),eP(i6("gesture"),async(e,t)=>{var r,n,i,a,o,s;switch(t.kind){case"pan":return await e.interactions.pan({...ei(r=t),x:r.origin.x,y:r.origin.y,dx:r.delta.x,dy:r.delta.y,durationMs:r.durationMs});case"fling":return await e.interactions.fling({...ei(n=t),direction:n.direction,x:n.origin.x,y:n.origin.y,distance:n.distance,durationMs:n.durationMs});case"swipe":return await e.interactions.swipeGesture({...ei(i=t),preset:i.preset,durationMs:i.durationMs});case"pinch":return await e.interactions.pinch({...ei(a=t),scale:a.scale,x:a.origin?.x,y:a.origin?.y});case"rotate":return await e.interactions.rotateGesture({...ei(o=t),degrees:o.degrees,x:o.origin?.x,y:o.origin?.y,velocity:o.velocity});case"transform":return await e.interactions.transformGesture({...ei(s=t),x:s.origin.x,y:s.origin.y,dx:s.delta.x,dy:s.delta.y,scale:s.scale,degrees:s.degrees,durationMs:s.durationMs})}})];function i6(e){let t=iB.find(t=>t.name===e);if(!t)throw Error(`Missing interaction command metadata for ${e}`);return t}function i9(e,t){if(!e||"object"!=typeof e||Array.isArray(e))throw new y("INVALID_ARGS",`${t} installSource must be an object.`);if("github-actions-artifact"!==at(e.type,`${t} installSource.type`))throw new y("INVALID_ARGS",`${t} installSource.type must be "github-actions-artifact".`);let{owner:r,repo:n}=ae(at(e.repo,`${t} installSource.repo`),`${t} installSource.repo`);return i7(r,n,e.artifact,`${t} installSource.artifact`)}function i7(e,t,r,n){var i;return"number"==typeof r||"string"==typeof(i=r)&&/^\d+$/.test(i.trim())?{kind:"github-actions-artifact",owner:e,repo:t,artifactId:function(e,t){let r="number"==typeof e?e:"string"==typeof e?Number(e):NaN;if(!Number.isInteger(r))throw new y("INVALID_ARGS",`${t} must be an integer.`);return r}(r,n)}:{kind:"github-actions-artifact",owner:e,repo:t,artifactName:at(r,n)}}function ae(e,t){let r=e.indexOf("/");if(r<=0||r===e.length-1||-1!==e.indexOf("/",r+1))throw new y("INVALID_ARGS",`${t} must use owner/repo.`);let n={owner:e.slice(0,r).trim(),repo:e.slice(r+1).trim()};if(!n.owner||!n.repo)throw new y("INVALID_ARGS",`${t} must use owner/repo.`);return n}function at(e,t){let r="string"==typeof e&&e.trim().length>0?e.trim():void 0;if(!r)throw new y("INVALID_ARGS",`${t} must be a non-empty string.`);return r}let ar=[rd("devices","List available devices.",{}),rd("boot","Boot or prepare a selected device without using CLI positional arguments.",{headless:$("Boot without showing simulator UI when supported.")}),rd("shutdown","Shutdown a selected simulator or emulator.",{}),rd("prepare","Prepare platform helper infrastructure.",{action:P(F(["ios-runner"])),timeoutMs:T("Maximum wall-clock time for the prepare command.")}),rd("apps","List installed apps.",{appsFilter:F(["user-installed","all"])}),rd("session","List active sessions or print daemon state directory.",{action:F(["list","state-dir"],"list shows active sessions; state-dir prints the resolved daemon state directory without contacting the daemon.")}),rd("open","Open an app, deep link, URL, or platform surface.",{app:_("App name, bundle id, package, or URL."),url:_("Optional URL passed with an app shell."),surface:F(tj),activity:_("Android activity name."),launchConsole:_("Launch console mode."),launchArgs:U("Launch arguments forwarded verbatim to the platform launch command."),relaunch:$("Force relaunch."),saveScript:j({oneOf:[O(),N()]}),deviceHub:$("Use Xcode Device Hub when surfacing Apple simulators."),noRecord:$("Do not record this action.")}),rd("close","Close an app or end the active session.",{app:_("Optional app to close."),shutdown:$("Shutdown the session/device where supported."),saveScript:j({oneOf:[O(),N()]})}),rd("install","Install an app binary.",{app:P(_()),appPath:P(_("Path to app binary."))}),rd("reinstall","Reinstall an app binary.",{app:P(_()),appPath:P(_("Path to app binary."))}),rd("install-from-source","Install an app from a structured source.",{source:P(j(E("Install source object."))),retainPaths:$(),retentionMs:T()}),rd("push","Deliver a push payload.",{app:P(_()),payload:P(j({oneOf:[N(),E()]}))}),rd("trigger-app-event","Trigger an app-defined event.",{event:P(_()),payload:eu(E(void 0),function(e,t){let r=e[t];if(void 0!==r){if(!r||"object"!=typeof r||Array.isArray(r))throw Error(`Expected ${t} to be an object.`);return r}})})],an=[eP(aa("devices"),(e,t)=>e.devices.list(t)),eP(aa("boot"),(e,t)=>e.devices.boot(t)),eP(aa("shutdown"),(e,t)=>e.devices.shutdown(t)),eP(aa("apps"),(e,t)=>e.apps.list(t)),eP(aa("session"),async(e,{action:t,...r})=>"state-dir"===t?{stateDir:await e.sessions.stateDir(r)}:{sessions:await e.sessions.list(r)}),eP(aa("open"),(e,t)=>e.apps.open(t)),eP(aa("close"),(e,t)=>t.app?e.apps.close(t):e.sessions.close(function(e){let{app:t,...r}=e;return r}(t))),eP(aa("install"),(e,t)=>e.apps.install(t)),eP(aa("reinstall"),(e,t)=>e.apps.reinstall(t)),eP(aa("install-from-source"),(e,t)=>e.apps.installFromSource(t)),eP(aa("push"),(e,t)=>e.apps.push(t)),eP(aa("trigger-app-event"),(e,t)=>e.apps.triggerEvent(t)),eP(aa("prepare"),(e,t)=>e.command.prepare(t))],ai={boot:{summary:"Boot target device/simulator",allowedFlags:["headless"]},shutdown:{summary:"Shutdown target simulator/emulator"},prepare:{usageOverride:"prepare ios-runner --platform ios|macos [--timeout <ms>]",listUsageOverride:"prepare ios-runner --platform ios|macos",helpDescription:"Prepare platform helper infrastructure. ios-runner builds/reuses, starts, and health-checks the XCTest runner so later Apple snapshots and interactions do not pay first-use startup cost. In CI, run it after boot/install and before replay/test; if replay/test starts a separate daemon, run clean:daemon after prepare to release the prepared runner lease. Runner build/start output is written to the session runner.log; daemon.log is for daemon lifecycle/startup issues.",summary:"Prepare platform helpers",positionalArgs:["ios-runner"],allowedFlags:["timeoutMs"]},open:{helpDescription:"Boot device/simulator; optionally launch app or deep link URL (macOS also supports --surface app|frontmost-app|desktop|menubar)",summary:"Open an app, deep link or URL, save replays",positionalArgs:["appOrUrl?","url?"],allowedFlags:["activity","launchConsole","launchArgs","deviceHub","saveScript","relaunch","surface"]},close:{positionalArgs:["app?"],allowedFlags:["saveScript","shutdown"]},reinstall:{positionalArgs:["app","path"]},install:{positionalArgs:["app","path"]},"install-from-source":{usageOverride:"install-from-source <url> | install-from-source --github-actions-artifact <owner/repo:artifact>",listUsageOverride:"install-from-source <url> | install-from-source --github-actions-artifact",helpDescription:"Install app from a URL or remote-resolved source",summary:"Install app from a source",positionalArgs:["url?"],allowedFlags:["header","githubActionsArtifact","installSource","retainPaths","retentionMs"]},apps:{helpDescription:"List user-installed apps; use --all to include system/OEM apps",summary:"List installed apps",allowedFlags:["appsFilter"],defaults:{appsFilter:I}},push:{positionalArgs:["bundleOrPackage","payloadOrJson"]},"trigger-app-event":{usageOverride:"trigger-app-event <event> [payloadJson]",positionalArgs:["event","payloadJson?"]},session:{usageOverride:"session list | session state-dir",listUsageOverride:"session list",helpDescription:"List active sessions or print the effective daemon state directory",positionalArgs:["list|state-dir?"]}};function aa(e){let t=ar.find(t=>t.name===e);if(!t)throw Error(`Missing management command metadata for ${e}`);return t}let ao={devices:(e,t)=>eh(t),apps:(e,t)=>({...eh(t),appsFilter:M(t.appsFilter)}),session:(e,t)=>({...eh(t),action:function(e){let t=e??"list";if("list"===t||"state-dir"===t)return t;throw new y("INVALID_ARGS","session only supports list or state-dir")}(e[0])}),boot:(e,t)=>({...eh(t),headless:t.headless}),shutdown:(e,t)=>eh(t),prepare:(e,t)=>({...eh(t),action:eO(e[0],"prepare requires subcommand"),timeoutMs:t.timeoutMs}),open:(e,t)=>({...eh(t),app:e[0],url:e[1],surface:t.surface,activity:t.activity,launchConsole:t.launchConsole,launchArgs:t.launchArgs,relaunch:t.relaunch,saveScript:t.saveScript,deviceHub:t.deviceHub,noRecord:t.noRecord}),close:(e,t)=>({...eh(t),app:e[0],shutdown:t.shutdown,saveScript:t.saveScript}),install:al,reinstall:al,"install-from-source":(e,t)=>({...eh(t),source:function(e,t){let r=e[0]?.trim();if(e.length>1)throw new y("INVALID_ARGS","install-from-source accepts either one <url> positional or --github-actions-artifact");let n=t.githubActionsArtifact?function(e,t="--github-actions-artifact"){let r=e.indexOf(":");if(r<=0||r===e.length-1)throw new y("INVALID_ARGS",`${t} must use owner/repo:artifact, for example thymikee/RNCLI83:6635342232`);let{owner:n,repo:i}=ae(e.slice(0,r),t);return i7(n,i,e.slice(r+1),`${t} artifact`)}(t.githubActionsArtifact):void 0,i=t.installSource;if(1!=+!!r+ +!!n+ +!!i)throw new y("INVALID_ARGS","install-from-source requires exactly one source: <url>, --github-actions-artifact, or config installSource");if(!r&&t.header&&t.header.length>0)throw new y("INVALID_ARGS","install-from-source --header is only supported for URL sources");return n||i||{kind:"url",url:r,headers:function(e){if(!e||0===e.length)return;let t={};for(let r of e){let e=r.indexOf(":");if(e<=0)throw new y("INVALID_ARGS",`Invalid --header value "${r}". Expected "name:value".`);let n=r.slice(0,e).trim(),i=r.slice(e+1).trim();if(!n)throw new y("INVALID_ARGS",`Invalid --header value "${r}". Header name cannot be empty.`);t[n]=i}return t}(t.header)}}(e,t),retainPaths:t.retainPaths,retentionMs:t.retentionMs}),push:(e,t)=>({...eh(t),app:eO(e[0],"push requires bundleOrPackage"),payload:eO(e[1],"push requires payloadOrJson")}),"trigger-app-event":(e,t)=>({...eh(t),event:eO(e[0],"trigger-app-event requires event"),payload:e[1]?function(e,t){try{let t=JSON.parse(e);if(t&&"object"==typeof t&&!Array.isArray(t))return t}catch{}throw new y("INVALID_ARGS",`${t} must be a JSON object`)}(e[1],"trigger-app-event payload"):void 0})},as={devices:em(S.devices),boot:em(S.boot),shutdown:em(S.shutdown),prepare:em(S.prepare,e=>[eE(e.action,"prepare requires subcommand")]),apps:em(S.apps),open:em(S.open,function(e){return e.app?e.url?[e.app,e.url]:[e.app]:[]}),close:em(S.close,e=>eN(e.app)),install:em(S.install,e=>au(e.app,e.appPath)),reinstall:em(S.reinstall,e=>au(e.app,e.appPath)),"install-from-source":e=>ef(v.installSource,[],{...e,installSource:e.source,retainMaterializedPaths:e.retainPaths,materializedPathRetentionMs:e.retentionMs}),push:em(S.push,e=>{var t;return[(t=e).app,"string"==typeof t.payload?t.payload:JSON.stringify(t.payload)]}),"trigger-app-event":em(S.triggerAppEvent,e=>{var t;return[(t=e).event,...t.payload?[JSON.stringify(t.payload)]:[]]})};function al(e,t,r="install"){return{...eh(t),app:eO(e[0],`${r} requires app`),appPath:eO(e[1],`${r} requires path`)}}function au(e,t){return[eE(e,"missing first positional"),eE(t,"missing second positional")]}let ac=["path","start","stop","doctor","mark","clear"],ap="logs",ad="network",am=rd(ap,"Manage session app logs.",{action:F(ac),message:_(),restart:$()}),af=rd(ad,"Show recent HTTP traffic.",{action:F(["dump","log"]),limit:T(),include:F(o)}),ah=[am,af],ag=[eP(am,(e,t)=>e.observability.logs(t)),eP(af,(e,t)=>e.observability.network(t))],ay={[ap]:{usageOverride:"logs path | logs start | logs stop | logs clear [--restart] | logs doctor | logs mark [message...]",helpDescription:"Session app log info, start/stop streaming, diagnostics, and markers",summary:"Manage session app logs",positionalArgs:["path|start|stop|clear|doctor|mark","message?"],allowsExtraPositionals:!0,allowedFlags:["restart"]},[ad]:{usageOverride:"network dump [limit] [summary|headers|body|all] [--include summary|headers|body|all] | network log [limit] [summary|headers|body|all] [--include summary|headers|body|all]",helpDescription:"Dump recent HTTP(s) traffic parsed from the session app log",summary:"Show recent HTTP traffic",positionalArgs:["dump|log","limit?","include?"],allowedFlags:["networkInclude"]}},ab={logs:(e,t)=>({...eh(t),action:function(e){if(void 0!==e)return tF(ac,e,{message:"logs requires path, start, stop, doctor, mark, or clear"})}(e[0]),message:e.slice(1).join(" ")||void 0,restart:t.restart}),network:(e,t)=>({...eh(t),action:function(e){if(void 0!==e){if("dump"===e||"log"===e)return e;throw new y("INVALID_ARGS","network requires dump or log")}}(e[0]),limit:eL(e[1]),include:t.networkInclude??function(e){if(void 0!==e)return tF(o,e,{message:"network include must be summary, headers, body, or all"})}(e[2])})},aw={logs:em(ap,e=>{var t;return[(t=e).action??"path",...eN(t.message)]}),network:e=>{var t;return ef(ad,[...(t=e).action?[t.action]:[],...eR(t.limit)],{...e,networkInclude:e.include})}},av="perf",ax=rd(av,"Show session performance, frame health, and memory diagnostics.",{area:F(tG),subject:F(tB),action:F(tz),kind:F(tH),template:_("xctrace template name, for example Time Profiler."),out:_("Output artifact path."),tracePath:_("Existing .trace path to report, defaults to the latest session trace.")}),aS=[ax],ak=[eP(ax,(e,t)=>e.observability.perf(t))],aA={[av]:{usageOverride:"perf [metrics|frames|memory] [sample|snapshot]\n agent-device perf memory sample --json\n agent-device perf memory snapshot [--kind android-hprof|memgraph] [--out <path>]\n agent-device perf cpu profile start|stop|report --kind xctrace [--template <name>] --out <path>\n agent-device perf trace start|stop --kind xctrace [--template <name>] --out <path>\n agent-device perf cpu profile start|stop|report --kind simpleperf [--out <path>]\n agent-device perf trace start|stop --kind perfetto [--out <path>]",listUsageOverride:"perf [metrics|frames|memory] | perf cpu profile start|stop|report | perf trace start|stop",helpDescription:"Show session performance metrics, focused frame/jank health, memory diagnostics artifacts, Apple xctrace artifacts, or Android native Simpleperf/Perfetto artifacts. Bare perf and metrics are aliases for perf metrics. Native perf output is agent evidence: compact state, artifact path, and size only; raw profiles/traces stay on disk.",summary:"Show performance metrics or collect native perf artifacts",positionalArgs:["area?","subjectOrAction?","action?"],allowedFlags:["kind","perfTemplate","out"]}},aD={perf:(e,t)=>{var r;return{...eh(t),...function(e,t={}){if(void 0!==e[0]&&void 0===e[1]){let r=aL(e[0],{allowUndefined:!0});if(r)return{action:r,kind:aN(t.kind),out:t.out}}let r=function(e){if(void 0===e)return;let t=e.toLowerCase();if(t5(t))return t;throw new y("INVALID_ARGS",tQ)}(e[0]);return"cpu"===r?{area:r,subject:function(e){let t=e?.toLowerCase();if(void 0!==t&&t8(t))return t;throw new y("INVALID_ARGS",t0)}(e[1]),action:aL(e[2]),kind:aN(t.kind),template:t.template,out:t.out}:"trace"===r?{area:r,action:aL(e[1]),kind:aN(t.kind),template:t.template,out:t.out}:{area:r,action:aL(e[1]),kind:aN(t.kind),out:t.out}}(e,{kind:"string"==typeof(r=t.kind)?aN(r):void 0,template:t.perfTemplate,out:t.out})}}},aI={perf:em(av,e=>{var t;let r;return"cpu"===(r=(t=e).area??(t.action?"metrics":void 0))?aM([...eN(r),...eN(t.subject),...eN(t.action),...eN(t.kind)],t):"trace"===r?aM([...eN(r),...eN(t.action),...eN(t.kind)],t):[...eN(r),...eN(t.action)]})};function aM(e,t){let r=[...e];return(t.template||t.out||t.tracePath)&&r.push(t.template??""),(t.out||t.tracePath)&&r.push(t.out??""),t.tracePath&&r.push(t.tracePath),r}function aL(e,t={}){if(void 0===e)return;let r=e.toLowerCase();if(t3(r))return r;if(!t.allowUndefined)throw new y("INVALID_ARGS",tZ)}function aN(e){if(void 0===e)return;let t=e.toLowerCase();if(t4(t))return t;throw new y("INVALID_ARGS",t1)}let aR=/\b(logbox|redbox|reload js|copy stack|component stack|call stack|runtime error|open debugger to view warnings)\b/,aO=/\b(redbox|runtime error|reload js|copy stack|component stack|call stack)\b/,aE=[/\b[\w.$<>/-]+\.(?:tsx?|jsx?):\d+(?::\d+)?\b/,/\b[\w.$<>/-]+\.(?:tsx?|jsx?)\s+\(\d+:\d+\)/],aP=[/^!,\s+/,/^(warn|warning|error):\s+/,/\b(?:possible\s+)?unhandled (?:promise )?rejection\b/],a_=["open debugger to view warnings","getsnapshot should be cached to avoid an infinite loop",'unique "key" prop',"unique 'key' prop","virtualizedlists should never be nested","failed prop type"],aC=new Set(["x","\xd7","✕","✖","⨯"]);function aT(e){if(aF(e).detected)return"Hint: React Native warning/error overlay detected. It overlays part of the app and should be handled before interacting.\nRun: agent-device react-native dismiss-overlay\nThe command verifies the overlay is gone. Run agent-device snapshot -i afterward only when you need fresh refs for the next action."}function a$(e){return aF(e)}function aF(e){var t,r,n,i,o,s,l,u,c,p;let d,m,f,h,g,y,b,w,v=(d=(t=e).map(aq).join("\n").toLowerCase(),m=aQ(t,aH),f=aQ(t,aK),h=aQ(t,az,aJ),g=aQ(t,aB),y=(r=d,aE.some(e=>e.test(r))),b=aG(d),w=(n=d,i=m,o=f,i.length>0||o.length>0||/\b(reload js|copy stack)\b/.test(n)),{dismissNodes:m,minimizeNodes:f,collapsedNodes:h,redBox:(s=d,l=y,u=w,aO.test(s)||aG(s)||l&&u),detected:(c={text:d,hasReactNativeStackFrame:y,hasOverlayControl:w,hasControllessRedBoxText:b,collapsedNodes:h,openDebuggerWarningNodes:g}).collapsedNodes.length>0||c.openDebuggerWarningNodes.length>0||c.hasControllessRedBoxText||c.hasOverlayControl&&(p=c.text,aR.test(p)||c.hasReactNativeStackFrame)}),x=v.detected?function(e){let t=a0(e.dismissNodes,aZ);if(t){let e;var r,n=t,i=(r=t,(e=a2(r)?.trim().toLowerCase())&&aW(e)?"dismiss":"close");if(!n.rect)throw Error("React Native overlay target node must have rect");return{action:i,point:a(n.rect),rect:n.rect,ref:n.ref,label:a2(n)}}let o=a0(e.collapsedNodes.filter(aX),a1);return o?.rect?{action:"close-collapsed-banner",point:function(e){var t,r;if(!e.rect)throw Error("Collapsed React Native warning node must have rect");let n=Math.min(e.rect.height,52),i=Math.min(36,Math.max(18,.45*n));return{x:Math.round((t=e.rect.x+e.rect.width-i,r=e.rect.x+1,Math.min(e.rect.x+e.rect.width-1,Math.max(r,t)))),y:Math.round(e.rect.y+n/2)}}(o),rect:o.rect,ref:o.ref,label:a2(o)}:null}(v):null;return{detected:v.detected,redBox:v.redBox,dismissNodes:v.dismissNodes,minimizeNodes:v.minimizeNodes,collapsedNodes:v.collapsedNodes,primaryAction:x}}function aU(e){return[...e.dismissNodes,...e.minimizeNodes,...e.collapsedNodes]}function aj(e){var t;return az(e.label?.trim())&&!!(t=e.rect)&&t.x<=1&&t.y<=1&&t.width>=300&&t.height>=600}function aV(e,t){let r=e.label?.trim();return!!r&&!!aj(e)&&t.some(e=>e.label?.trim()===r&&aY(e))}function aq(e){return[e.label,e.value,e.identifier,e.type,e.role].filter(Boolean).join(" ")}function aG(e){return/\buncaught\b/.test(e)&&/unable to download asset/.test(e)}function az(e){let t=e?.trim().toLowerCase();return!!t&&(a_.some(e=>t.includes(e))||aP.some(e=>e.test(t)))}function aB(e){return e.includes("open debugger to view warnings")||/^!,\s+open debugger\b/.test(e)}function aH(e){var t,r;return aW(e)||(t=e,/^close(?:\s*\([^)]*\))?$/i.test(t))||(r=e,aC.has(r))}function aW(e){return/^dismiss(?:\s*\([^)]*\))?$/i.test(e)}function aK(e){return/^minimi[sz]e(?:\b|\s|\()/i.test(e)}function aJ(e){return!e.rect||e.rect.height<=180}function aX(e){let t=a2(e)?.trim().toLowerCase()??"";return(aB(t)||/^!,\s+/.test(t))&&aY(e)}function aY(e){return!!e.rect&&e.rect.width>=120&&e.rect.height>=36&&e.rect.height<=180}function aQ(e,t,r=()=>!0){let n=[];for(let i of e)i.ref&&r(i)&&[i.label,i.value,i.identifier].map(e=>e?.trim().toLowerCase()).filter(e=>!!e).some(e=>t(e))&&n.push(i);return n}function aZ(e){var t;let r;return[+(!0===(r=[e.type,e.role,e.subrole].join(" ").toLowerCase(),/\b(button|menuitem|link)\b/.test(r))),+(!0===e.hittable),-((t=e.rect)?t.width*t.height:1/0)]}function a0(e,t){let r=e.filter(e=>e.rect);return 0===r.length?null:r.sort((e,r)=>(function(e,t){for(let r=0;r<e.length;r+=1){let n=e[r]-t[r];if(0!==n)return n}return 0})(t(r),t(e)))[0]??null}function a1(e){return[+(!0===e.hittable),e.rect?.width??0,e.rect?.y??0]}function a2(e){return e.label??e.value??e.identifier}let a5="react-native",a3=rd(a5,"Run supported React Native app automation helpers.",{action:P(F(["dismiss-overlay"]))}),a8=eP(a3,(e,t)=>e.command.reactNative(t)),a4={[a5]:{usageOverride:"react-native dismiss-overlay",listUsageOverride:"react-native dismiss-overlay",positionalArgs:["dismiss-overlay"]}},a6={"react-native":(e,t)=>({...eh(t),action:function(e){if("dismiss-overlay"===e)return e;throw new y("INVALID_ARGS","react-native supports only: dismiss-overlay")}(e[0])})},a9={"react-native":em(a5,e=>[eE(e.action,"react-native requires action")])},a7="record",oe="trace",ot=["start","stop"],or=rd(a7,"Start or stop screen recording.",{action:P(F(ot)),path:_(),fps:T(),quality:j(R()),hideTouches:$()}),on=rd(oe,"Start or stop trace capture.",{action:P(F(ot)),path:_()}),oi=[or,on],oa=[eP(or,(e,t)=>e.recording.record(t)),eP(on,(e,t)=>e.recording.trace(t))],oo={[a7]:{usageOverride:"record start [path] [--fps <n>] [--quality <5-10>] [--hide-touches] | record stop",listUsageOverride:"record start [path] | record stop",helpDescription:"Start/stop screen recording; Android recordings longer than the 180s adb screenrecord limit are returned as multiple MP4 chunks",summary:"Start or stop screen recording",positionalArgs:["start|stop","path?"],allowedFlags:["fps","quality","hideTouches"]},[oe]:{usageOverride:"trace start <path> | trace stop <path>",listUsageOverride:"trace start <path> | trace stop <path>",helpDescription:"Start/stop trace log capture; when an artifact path is requested, pass the same positional path to start and stop",summary:"Start or stop trace capture",positionalArgs:["start|stop","path?"]}},os={record:(e,t)=>({...eh(t),action:oc(e[0],a7),path:e[1],fps:t.fps,quality:t.quality,hideTouches:t.hideTouches}),trace:(e,t)=>({...eh(t),action:oc(e[0],oe),path:e[1]})},ol={record:em(a7,e=>ou(e)),trace:em(oe,e=>ou(e))};function ou(e){return[e.action,...eN(e.path)]}function oc(e,t){if("start"===e||"stop"===e)return e;throw new y("INVALID_ARGS",`${t} requires start|stop`)}let op="replay",od="test",om=rd(op,"Replay a recorded session.",{path:P(_()),update:$(),backend:_(),maestro:$(),env:U()}),of=rd(od,"Run one or more replay scripts.",{paths:P(U()),update:$(),backend:_(),maestro:$(),env:U(),failFast:$(),timeoutMs:T(),retries:T(),recordVideo:$(),artifactsDir:_(),reportJunit:_(),shardAll:T(),shardSplit:T()}),oh=[om,of],og=[eP(om,(e,t)=>e.replay.run(t)),eP(of,(e,t)=>e.replay.test(t))],oy={[op]:{usageOverride:"replay <path> | replay export <file.ad> [--format maestro] [--out <path>]",positionalArgs:["path"],allowsExtraPositionals:!0,allowedFlags:["replayMaestro","replayExportFormat",...ro,"timeoutMs","out"]},[od]:{usageOverride:"test <path-or-glob>...",listUsageOverride:"test <path-or-glob>...",helpDescription:"Run one or more replay scripts as a serial test suite",summary:"Run replay test suites",positionalArgs:["pathOrGlob"],allowsExtraPositionals:!0,allowedFlags:["replayMaestro",...ro,"failFast","timeoutMs","retries","recordVideo","artifactsDir","reportJunit","shardAll","shardSplit"]}},ob={replay:(e,t)=>({...eh(t),path:eO(e[0],"replay requires path"),update:t.replayUpdate,backend:t.replayMaestro?"maestro":void 0,env:t.replayEnv}),test:(e,t)=>({...eh(t),paths:e,update:t.replayUpdate,backend:t.replayMaestro?"maestro":void 0,env:t.replayEnv,failFast:t.failFast,timeoutMs:t.timeoutMs,retries:t.retries,recordVideo:t.recordVideo,artifactsDir:t.artifactsDir,reportJunit:t.reportJunit,shardAll:t.shardAll,shardSplit:t.shardSplit})},ow={replay:e=>ef(op,[eE(e.path,"replay requires path")],{...e,replayUpdate:e.update,replayBackend:ov(e),replayEnv:e.env,replayShellEnv:ox(process.env)}),test:e=>ef(od,e.paths??[],{...e,replayUpdate:e.update,replayBackend:ov(e),replayEnv:e.env,replayShellEnv:ox(process.env)})};function ov(e){return e.backend??(!0===e.maestro?"maestro":void 0)}function ox(e){let t={};for(let[r,n]of Object.entries(e))"string"==typeof n&&r.startsWith("AD_VAR_")&&(t[r]=n);return t}function oS(e){if(void 0===e)throw new y("INVALID_ARGS","rotate requires an orientation argument. Use portrait|portrait-upside-down|landscape-left|landscape-right.");switch(e?.trim().toLowerCase()){case"portrait":return"portrait";case"portrait-upside-down":case"upside-down":return"portrait-upside-down";case"landscape-left":case"left":return"landscape-left";case"landscape-right":case"right":return"landscape-right";default:throw new y("INVALID_ARGS",`Invalid rotation: ${e}. Use portrait|portrait-upside-down|landscape-left|landscape-right.`)}}let ok="appstate",oA="back",oD="home",oI="rotate",oM="app-switcher",oL="keyboard",oN="clipboard",oR=rd(ok,"Show foreground app or activity.",{}),oO=rd(oA,"Navigate back.",{mode:F(["in-app","system"])}),oE=rd(oD,"Go to the home screen.",{}),oP=rd(oI,"Rotate device orientation.",{orientation:P(F(["portrait","portrait-upside-down","landscape-left","landscape-right"]))}),o_=rd(oM,"Open the app switcher.",{}),oC=rd(oL,"Inspect or dismiss the keyboard.",{action:F(["status","dismiss"])}),oT=rd(oN,"Read or write clipboard text.",{action:P(F(["read","write"])),text:_()}),o$=[oR,oO,oE,oP,o_,oC,oT],oF=[eP(oR,(e,t)=>e.command.appState(t)),eP(oO,(e,t)=>e.command.back(t)),eP(oE,(e,t)=>e.command.home(t)),eP(oP,(e,t)=>e.command.rotate(t)),eP(o_,(e,t)=>e.command.appSwitcher(t)),eP(oC,(e,t)=>e.command.keyboard(t)),eP(oT,(e,t)=>e.command.clipboard(t))],oU={[ok]:{helpDescription:"Show foreground app/activity"},[oA]:{usageOverride:"back [--in-app|--system]",allowedFlags:["backMode"]},[oI]:{usageOverride:"rotate <portrait|portrait-upside-down|landscape-left|landscape-right>",helpDescription:"Rotate device orientation on iOS and Android",positionalArgs:["orientation"]},[oL]:{usageOverride:"keyboard [status|get|dismiss|enter|return]",helpDescription:"Inspect Android keyboard visibility/type or press/dismiss the device keyboard",summary:"Inspect, press, or dismiss the device keyboard",positionalArgs:["action?"]},[oN]:{usageOverride:"clipboard read | clipboard write <text>",listUsageOverride:"clipboard read | clipboard write <text>",helpDescription:"Read or write device clipboard text",positionalArgs:["read|write","text?"],allowsExtraPositionals:!0}},oj={appstate:(e,t)=>eh(t),home:(e,t)=>eh(t),"app-switcher":(e,t)=>eh(t),back:(e,t)=>({...eh(t),mode:t.backMode}),rotate:(e,t)=>({...eh(t),orientation:oS(e[0])}),keyboard:(e,t)=>({...eh(t),...function(e){if(e.length>1)throw new y("INVALID_ARGS","keyboard accepts at most one action argument.");return el({action:function(e){let t=e?.toLowerCase();if("get"===t)return"status";if(void 0===t||"status"===t||"dismiss"===t||"enter"===t||"return"===t)return t;throw new y("INVALID_ARGS","keyboard action must be status, get, dismiss, enter, or return.")}(e[0])})}(e)}),clipboard:(e,t)=>({...eh(t),...function(e){let t=e[0]?.toLowerCase();if("read"!==t&&"write"!==t)throw new y("INVALID_ARGS","clipboard requires a subcommand: read or write.");if("read"===t){if(1!==e.length)throw new y("INVALID_ARGS","clipboard read does not accept additional arguments.");return{action:t}}if(e.length<2)throw new y("INVALID_ARGS","clipboard write requires text.");return{action:t,text:e.slice(1).join(" ")}}(e)})},oV={appstate:em(ok),back:e=>{var t;return ef(oA,[],{...e,backMode:"in-app"===(t=e.mode)||"system"===t?t:void 0})},home:em(oD),rotate:em(oI,e=>[eE(e.orientation,"rotate requires orientation")]),"app-switcher":em(oM),keyboard:em(oL,e=>eN(e.action)),clipboard:em(oN,e=>{var t;return"read"===(t=e).action?["read"]:["write",t.text]})};export{rl as GLOBAL_FLAG_KEYS,ac as LOG_ACTION_VALUES,t9 as MAESTRO_COMPAT_TRACKER_URL,t7 as MAESTRO_NEW_ISSUE_URL,rn as METRO_PREPARE_FLAGS,ri as METRO_RELOAD_FLAGS,tZ as PERF_ACTION_ERROR_MESSAGE,tQ as PERF_AREA_ERROR_MESSAGE,t1 as PERF_KIND_ERROR_MESSAGE,t2 as PERF_MEMORY_KIND_ERROR_MESSAGE,t0 as PERF_SUBJECT_ERROR_MESSAGE,e_ as SCREENSHOT_ACTION_FLAG_KEYS,r7 as SCROLL_DIRECTIONS,rI as SETTINGS_INVALID_ARGS_MESSAGE,nt as SWIPE_PATTERNS,aF as analyzeReactNativeOverlay,n2 as annotateCoveredSnapshotNodes,ao as appCliReaders,as as appDaemonWriters,e$ as appendScreenshotScriptFlags,nY as areRectsApproximatelyEqual,na as assertScrollGestureInput,t_ as batchCliReaders,tP as batchCliSchemas,tE as batchCommandDefinition,tO as batchCommandMetadata,$ as booleanField,tM as buildFlags,tL as buildMeta,nM as buildMobileSnapshotPresentation,ni as buildScrollGesturePlan,no as buildSwipeGesturePlan,ns as buildSwipePresetGesturePlan,r9 as buttonTag,r5 as captureCliReaders,r2 as captureCliSchemas,r1 as captureCommandDefinitions,r0 as captureCommandMetadata,r3 as captureDaemonWriters,nC as captureScrollEdgeState,np as clampGesturePoint,ny as clampToRange,eh as commonInputFromFlags,tR as createBatchDaemonWriter,eP as defineExecutableCommand,rd as defineFieldCommandMetadata,nL as deriveMobileSnapshotHiddenContentHints,a$ as detectReactNativeOverlay,nI as displayNodeLabel,F as enumField,ib as focusCommand,aT as formatReactNativeOverlayWarning,n$ as formatScrollEdgeMessage,iK as gestureCliReaders,iJ as gestureDaemonWriters,r6 as getClickButtonValidationError,rc as getFlagDefinition,rp as getFlagDefinitions,rL as getUnsupportedMacOsSettingMessage,nu as inferGestureReferenceFrame,nk as inferVerticalScrollIndicatorDirections,T as integerField,i0 as interactionCliReaders,i8 as interactionCliSchemas,i4 as interactionCommandDefinitions,iB as interactionCommandMetadata,i1 as interactionDaemonWriters,rM as isMacOsSettingSupported,nR as isNodeVisibleInEffectiveViewport,t3 as isPerfAction,t5 as isPerfArea,t4 as isPerfKind,t6 as isPerfMemoryKind,t8 as isPerfSubject,aj as isReactNativeCollapsedWarningWrapperCandidate,aV as isReactNativeCollapsedWarningWrapperWithVisibleBanner,n5 as isSnapshotNodeInteractionBlocked,ez as isSparseSnapshotQualityVerdict,t$ as isStringMember,nS as isSystemScrollIndicatorLabel,j as jsonSchemaField,iw as longPressCommand,ai as managementCliSchemas,an as managementCommandDefinitions,ar as managementCommandMetadata,th as normalizeDeployResult,tb as normalizeDevice,tg as normalizeInstallFromSourceResult,ty as normalizeMaterializationReleaseResult,tk as normalizeOpenDevice,tS as normalizeRuntimeHints,tw as normalizeSession,nA as normalizeSnapshotTree,tA as normalizeStartupSample,nB as now,ab as observabilityCliReaders,ay as observabilityCliSchemas,ag as observabilityCommandDefinitions,ah as observabilityCommandMetadata,aw as observabilityDaemonWriters,oS as parseDeviceRotation,i9 as parseInstallSourceConfig,nd as parseScrollDirection,tq as parseSessionSurface,tF as parseStringMember,nl as parseSwipePreset,tC as parseTimeout,tT as parseWaitPositionals,tm as parsing_stripUndefined,aD as perfCliReaders,aA as perfCliSchemas,ak as perfCommandDefinitions,aS as perfCommandMetadataList,aI as perfDaemonWriters,ik as pinchCommand,nc as pointFromPercent,nQ as pointInsideRect,eW as publicSnapshotCaptureAnnotations,a6 as reactNativeCliReaders,a4 as reactNativeCliSchemas,a8 as reactNativeCommandDefinition,a3 as reactNativeCommandMetadata,a9 as reactNativeDaemonWriters,eY as readCommandMessage,iQ as readFillTargetFromPositionals,rN as readLocationCoordinate,tr as readOptionalString,aU as readReactNativeOverlayActionNodes,tt as readRequiredString,tI as readScreenshotOverlayRefs,eF as readScreenshotScriptFlag,eK as readSerializedSnapshotCaptureAnnotations,tD as readSnapshotNodes,eG as readSnapshotQualityVerdict,os as recordingCliReaders,oo as recordingCliSchemas,oa as recordingCommandDefinitions,oi as recordingCommandMetadata,ol as recordingDaemonWriters,eB as renderSnapshotQualityWarnings,ob as replayCliReaders,oy as replayCliSchemas,og as replayCommandDefinitions,oh as replayCommandMetadataList,ow as replayDaemonWriters,nb as requireIntInRange,rR as requireLocationCoordinates,P as requiredField,n7 as resolveActionableTouchNode,ie as resolveActionableTouchResolution,r4 as resolveClickButton,e5 as resolveDeployResultTarget,e8 as resolveInstallFromSourceResultTarget,ir as resolveInteractionTarget,nJ as resolveRectCenter,tN as resolveSessionName,nT as runScrollEdgePasses,eT as screenshotFlagsFromOptions,eC as screenshotOptionsFromFlags,iv as scrollCommand,i2 as selectorCliReaders,i5 as selectorDaemonWriters,e9 as serializeCloseResult,e3 as serializeDeployResult,e2 as serializeDevice,e4 as serializeInstallFromSourceResult,e6 as serializeOpenResult,e1 as serializeSessionListEntry,e7 as serializeSnapshotResult,nH as sleep,eH as snapshotCaptureAnnotationsFrom,tf as splitNonEmptyTrimmedLines,_ as stringField,N as stringSchema,eJ as successText,ix as swipeCommand,oj as systemCliReaders,oU as systemCliSchemas,oF as systemCommandDefinitions,o$ as systemCommandMetadata,oV as systemDaemonWriters,nz as toBackendContext,nW as toBackendResult,eX as withSuccessText};
|