@buoy-gg/highlight-updates 7.0.69 → 7.0.71

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.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.collectDOMElements=collectDOMElements;exports.domElementName=domElementName;exports.watchDOMChanges=watchDOMChanges;var _utils=require("@buoy-gg/shared-ui/utils");const INTERACTIVE_ROLES=new Set(["button","link","menuitem","tab","switch","checkbox","radio","option","textbox","slider"]);const SKIP_TAGS=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE","SVG","PATH","HEAD","META","LINK"]);const MAX_TEXT=80;function isReactContainer(e){for(const t in e){if(t.startsWith("__reactContainer$")||t==="_reactRootContainer")return true}return false}function isHidden(e){if(e.hidden||e.getAttribute("aria-hidden")==="true")return true;const t=getComputedStyle(e);return t.display==="none"||t.visibility==="hidden"}function hasClick(e){const t=e;return typeof t.$$click==="function"||typeof t.onclick==="function"||e.tabIndex>=0&&e.hasAttribute("tabindex")}function ownText(e){let t="";for(const o of Array.from(e.childNodes))if(o.nodeType===3)t+=o.textContent??"";t=t.replace(/\s+/g," ").trim();return t||void 0}function allText(e,t){const o=(e.innerText??e.textContent??"").replace(/\s+/g," ").trim();if(!o)return void 0;return t||o.length<=MAX_TEXT?o:`${o.slice(0,MAX_TEXT)}\u2026`}function collectDOMElements(e={}){if(typeof document==="undefined"||!document.body)return[];const t=[];const o=(n,u,h)=>{if(SKIP_TAGS.has(n.tagName.toUpperCase())||isReactContainer(n)||isHidden(n))return;const d=h||n.hasAttribute("data-buoy-root");const r=n.tagName.toLowerCase();const i=n.getAttribute("role")??void 0;const s=r==="button"||r==="a"&&n.hasAttribute("href")||r==="input"||r==="textarea"||r==="select"||i!==void 0&&INTERACTIVE_ROLES.has(i)||hasClick(n);const f=n.getAttribute("data-testid")??void 0;const b=n.getAttribute("aria-label")??void 0;const l=s?allText(n,!!e.fullText):u?void 0:ownText(n);if(s||f||b||l){const a={"data-testid":f,"aria-label":b,role:i,id:n.id||void 0};if(s&&r!=="input"&&r!=="textarea"&&r!=="select")a.onClick=()=>n.click();const c=(0,_utils.getDOMControlProps)(n,a);if(i==="switch"||i==="checkbox"){const p=n.getAttribute("aria-checked")==="true";c.value=p;c.onValueChange=y=>{if(Boolean(y)!==(n.getAttribute("aria-checked")==="true"))n.click()};delete c.onPress}if(n.disabled)delete c.onPress;t.push({element:n,props:c,text:l,buoy:d})}for(const a of Array.from(n.children)){if(a instanceof HTMLElement)o(a,u||s,d)}};o(document.body,false,false);return t}function domElementName(e){const t=globalThis[Symbol.for("buoy.dom.componentName")];try{const o=t?.(e);if(o)return o}catch{}return e.tagName.toLowerCase()}function watchDOMChanges(){if(typeof MutationObserver==="undefined"||typeof document==="undefined")return()=>0;let e=0;const t=new MutationObserver(()=>{e+=1});t.observe(document.body,{subtree:true,childList:true,characterData:true,attributes:true});return()=>{t.disconnect();return e}}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.describeScreen=describeScreen;exports.hitTest=hitTest;exports.readMaps=readMaps;exports.resolveTouchTarget=resolveTouchTarget;exports.tapElement=tapElement;exports.waitFor=waitFor;var _utils=require("@buoy-gg/shared-ui/utils");var _reactNative=require("react-native");var _tapMatch=require("./tapMatch");const HostComponent=5;const OffscreenComponent=22;const INTERNAL_NAMES=new Set(["View","RCTView","ScrollView","RCTScrollView","RCTScrollContentView","SafeAreaView","RCTSafeAreaView","AndroidHorizontalScrollContentView","KeyboardAvoidingView","Pressable","PlatformPressable","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","TouchableNativeFeedback","AnimatedComponent","Wrapper"]);function getReactDevToolsHook(){if(typeof global==="undefined")return null;return global.__REACT_DEVTOOLS_GLOBAL_HOOK__??null}let commitCount=0;let commitCounterInstalled=false;function ensureCommitCounter(){if(commitCounterInstalled)return;const e=getReactDevToolsHook();if(!e)return;const t=e.onCommitFiberRoot;e.onCommitFiberRoot=function(...n){commitCount++;return typeof t==="function"?t.apply(e,n):void 0};commitCounterInstalled=true}const TAP_SETTLE_MS=250;function makeChromeCheck(){const e=new Map;return t=>{const n=[];let r=t;let s=0;let i=false;while(r&&s<400){const l=e.get(r);if(l!==void 0){i=l;break}if(getProps(r)?.__buoyDevToolsRoot){i=true;e.set(r,true);break}n.push(r);r=r.return;s++}for(const l of n)e.set(l,i);return i}}function getAllFiberRoots(){const e=getReactDevToolsHook();if(!e)return[];const t=[];try{if(e.renderers&&typeof e.renderers.forEach==="function"){e.renderers.forEach((n,r)=>{try{const s=e.getFiberRoots?.(r);if(s)s.forEach(i=>t.push(i))}catch{}})}if(t.length===0&&e.getFiberRoots){const n=e.getFiberRoots(1);if(n)n.forEach(r=>t.push(r))}}catch{}return t}function isHiddenOffscreen(e){return e.tag===OffscreenComponent&&e.memoizedState!==null}let includeHiddenScreens=false;let prunedHiddenScreens=0;let fullVisibleText=false;function withHiddenScreens(e,t){const n=includeHiddenScreens;includeHiddenScreens=e;try{return t()}finally{includeHiddenScreens=n}}function isNotShowingScreen(e){const t=e.memoizedProps;if(!t)return false;if(t["aria-hidden"]===true&&(t.activityState!==void 0||"shouldFreeze"in t))return true;if(t.isFocused===false&&(t.routeKey!==void 0||"freezeContents"in t))return true;return false}function isInactiveScreen(e){const t=e.memoizedProps?.activityState;if(t===0||t===1)return true;if(e.memoizedProps?.isPageFocused===false)return true;if(!includeHiddenScreens&&isNotShowingScreen(e)){prunedHiddenScreens++;return true}return false}function traverseFiberTree(e,t,n=0,r=new Set){if(!e||r.has(e)||n>500)return;r.add(e);if(isHiddenOffscreen(e)||isInactiveScreen(e)){if(e.sibling)traverseFiberTree(e.sibling,t,n,r);return}t(e);if(e.child)traverseFiberTree(e.child,t,n+1,r);if(e.sibling)traverseFiberTree(e.sibling,t,n,r)}function getPublicInstance(e){const t=(0,_utils.getDOMPublicInstance)(e);if(t)return t;if(!e)return null;const n=e;if(n.canonical?.publicInstance)return n.canonical.publicInstance;if(n.canonical&&typeof n.canonical.measure==="function"){return n.canonical}if(typeof n.measure==="function"||typeof n.measureInWindow==="function"){return n}return null}function getNativeTag(e){const t=(0,_utils.getDOMNodeHandle)(e);if(t!==null)return t;if(e==null)return null;const n=e;if(typeof n.__nativeTag==="number")return n.__nativeTag;if(typeof n._nativeTag==="number")return n._nativeTag;if(typeof n.nativeTag==="number")return n.nativeTag;if(n.canonical){if(typeof n.canonical.__nativeTag==="number")return n.canonical.__nativeTag;if(typeof n.canonical._nativeTag==="number")return n.canonical._nativeTag;if(typeof n.canonical.nativeTag==="number")return n.canonical.nativeTag}return null}function findHostInstance(e){const t=getPublicInstance(e.stateNode);if(t){return{instance:t,nativeTag:getNativeTag(e.stateNode),stateNode:e.stateNode}}const n=[];if(e.child)n.push(e.child);let r=0;while(n.length>0&&r<4e3){r++;const s=n.pop();if(!s)continue;const i=getPublicInstance(s.stateNode);if(i)return{instance:i,nativeTag:getNativeTag(s.stateNode),stateNode:s.stateNode};if(s.child)n.push(s.child);if(s.sibling)n.push(s.sibling)}return null}function findScrollAncestor(e){let t=e;let n=0;while(t&&n++<200){const r=t.stateNode;if(r&&typeof r.scrollTo==="function"){const s=typeof r.getNativeScrollRef==="function"&&r.getNativeScrollRef()||null;const i=typeof r.getInnerViewNode==="function"&&r.getInnerViewNode()||typeof r.getScrollableNode==="function"&&r.getScrollableNode()||r;return{instance:r,nativeRef:s,innerNode:i}}t=t.return}return null}async function scrollIntoView(e,t,n,r){try{if((0,_utils.isDOMElement)(n)){n.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"});await new Promise(c=>setTimeout(c,16));return true}const s=findScrollAncestor(e);if(!s)return false;const i=t;let l=null;const o=c=>new Promise(a=>{let f=false;const d=m=>{if(f)return;f=true;a(m)};const g=setTimeout(()=>d(null),600);try{c(m=>{clearTimeout(g);d(m)})}catch{clearTimeout(g);d(null)}});if(s.nativeRef&&typeof i.measureLayout==="function"){l=await o(c=>i.measureLayout(s.nativeRef,(a,f)=>c(f),()=>c(null)))}if(l==null){const c=(0,_reactNative.findNodeHandle)(t);const a=typeof s.innerNode==="number"?s.innerNode:(0,_reactNative.findNodeHandle)(s.innerNode);if(c!=null&&a!=null){l=await o(f=>_reactNative.UIManager.measureLayout(c,a,()=>f(null),(d,g)=>f(g)))}}if(l==null)return false;s.instance.scrollTo({y:Math.max(0,l-r),animated:false});await new Promise(c=>setTimeout(c,120));return true}catch{return false}}function getComponentName(e){const t=e?.type;if(!t)return null;if(typeof t==="string")return t;return t.displayName||t.name||null}function getOwningComponentName(e){let t=e?._debugOwner||e?.return;let n=0;while(t&&n<30){n++;const r=getComponentName(t);if(r&&!INTERNAL_NAMES.has(r)&&typeof t.type!=="string"){return r}t=t.return}return null}function getProps(e){return(0,_utils.getDOMControlProps)(e?.stateNode,e?.memoizedProps??e?.pendingProps??null)}function flattenText(e,t=0){if(typeof e==="string")return e;if(typeof e==="number"&&Number.isFinite(e))return String(e);if(Array.isArray(e)&&t<4){const n=[];for(const r of e){const s=flattenText(r,t+1);if(s)n.push(s)}return n.length>0?n.join(""):void 0}return void 0}function normalizeVisibleText(e){return e.replace(/\s+/g," ").trim()}function getVisibleText(e){if(!e)return void 0;const t=n=>{const r=flattenText(n);if(r===void 0)return void 0;const s=normalizeVisibleText(r);return s?fullVisibleText?s:s.slice(0,80):void 0};return t(e.children)??t(e.title)??t(e.label)??t(e.placeholder)??void 0}function collectDescendantText(e,t){const n=[];const r=(i,l)=>{if(!i||l>t||n.length>=4)return;if(i!==e){const c=getProps(i);if(c&&(typeof c.onPress==="function"||typeof c.onLongPress==="function"))return}const o=getVisibleText(getProps(i));if(o&&!n.includes(o))n.push(o);if(i.child)r(i.child,l+1);if(i!==e&&i.sibling)r(i.sibling,l)};if(e.child)r(e.child,1);const s=n.join(" ").trim();return s?s.slice(0,80):void 0}function findPressHandler(e){let t=e;let n=0;let r=null;let s=null;while(t&&n<25&&!(r&&s)){const i=getProps(t);if(i){if(!r&&typeof i.onPress==="function")r=i.onPress;if(!s&&typeof i.onLongPress==="function")s=i.onLongPress}t=t.return;n++}if(r)return{handler:r,kind:"onPress",longPress:s??void 0};return s?{handler:s,kind:"onLongPress"}:null}function measureInstance(e){return new Promise(t=>{let n=false;const r=s=>{if(n)return;n=true;t(s)};setTimeout(()=>r(null),1e3);try{if(typeof e.measureInWindow==="function"){e.measureInWindow((s,i,l,o)=>{if(l>0&&o>0)r({x:s,y:i,width:l,height:o});else r(null)})}else if(typeof e.measure==="function"){e.measure((s,i,l,o,c,a)=>{if(l>0&&o>0&&c!=null&&a!=null){r({x:c,y:a,width:l,height:o})}else{r(null)}})}else{r(null)}}catch{r(null)}})}const SPINNER_HOSTS=new Set(["RCTActivityIndicatorView","AndroidProgressBar"]);function collectCandidates(){const e=getAllFiberRoots();if(e.length===0)return[];const t=[];const n=new Map;const r=new Map;const s=makeChromeCheck();for(const i of e){traverseFiberTree(i.current,l=>{const o=getProps(l);if(!o)return;const c=typeof o.onPress==="function"||typeof o.onLongPress==="function";const a=typeof o.onValueChange==="function";const f=typeof o.onChangeText==="function";const d=o.testID||void 0;const g=o.accessibilityLabel||void 0;const m=o.accessibilityRole||o.role||void 0;let p=getVisibleText(o);const v=m==="button"||m==="link"||m==="menuitem"||m==="tab"||m==="switch"||m==="checkbox";const y=typeof l.type==="string"&&SPINNER_HOSTS.has(l.type)&&o.animating!==false;if(!c&&!a&&!f&&!d&&!g&&!p&&!v&&!y){return}let x=null;let I=null;let P=null;if(a){const N=o.value;const D=typeof N==="number"||typeof o.minimumValue==="number";I={handler:o.onValueChange,kind:D?"slider":"toggle",current:N,min:typeof o.minimumValue==="number"?o.minimumValue:void 0,max:typeof o.maximumValue==="number"?o.maximumValue:void 0}}else if(f){P={handler:o.onChangeText,current:typeof o.value==="string"?o.value:void 0}}else{x=findPressHandler(l)}const u=getComponentName(l);let h=u??"Unknown";if(!u||INTERNAL_NAMES.has(u)||typeof l.type==="string"){h=getOwningComponentName(l)??u??"Unknown"}const T=findHostInstance(l);if(!T&&!d)return;if(!p&&!g&&c){p=collectDescendantText(l,6)}const b=T?.instance??null;const C=T?.nativeTag??null;const w=(b?n.get(b):void 0)??(C!=null?r.get(C):void 0);if(w){if(!w.press&&x)w.press=x;else if(w.press&&x?.longPress&&!w.press.longPress){w.press.longPress=x.longPress}if(!w.valueControl&&I)w.valueControl=I;if(!w.textControl&&P)w.textControl=P;if(!w.testID&&d)w.testID=d;if(!w.label&&g)w.label=g;if(!w.text&&p)w.text=p;if(b&&!n.has(b))n.set(b,w);if(C!=null&&!r.has(C))r.set(C,w);return}const S={nativeTag:C,name:h,role:m??(y?"progressbar":void 0),testID:d,label:g,text:p,instance:b,stateNode:T?.stateNode??null,fiber:l,press:x,valueControl:I,textControl:P,rect:null,buoy:s(l)};t.push(S);if(b)n.set(b,S);if(C!=null)r.set(C,S)})}return t}function explicitlyTargets(e,t){if(t.nativeTag!=null)return e.nativeTag===t.nativeTag;if(t.testID&&e.testID)return e.testID.toLowerCase()===t.testID.toLowerCase();return false}function appCandidates(e){const t=collectCandidates();if(e.includeBuoy)return t;return t.filter(n=>!n.buoy||explicitlyTargets(n,e))}async function measureCandidates(e){await Promise.all(e.map(async t=>{if(t.instance)t.rect=await measureInstance(t.instance)}))}const LIST_WRAPPERS=/^(FlatList|SectionList|VirtualizedSectionList|VirtualizedList|Animated\(.*\)|AnimatedComponent.*)$/;async function collectLists(e,t){const n=[];const r=makeChromeCheck();for(const i of getAllFiberRoots()){traverseFiberTree(i.current,l=>{if(getComponentName(l)!=="VirtualizedList")return;const o=l.memoizedProps;if(!o||typeof o.getItemCount!=="function")return;if(!e&&r(l))return;let c;try{c=Number(o.getItemCount(o.data))}catch{return}if(!Number.isFinite(c)||c<=0)return;const a=[];const f=(m,p)=>{for(let v=m?.child;v;v=v.sibling){const y=getComponentName(v);if(y==="VirtualizedList")continue;if(y==="CellRenderer"){a.push(v);continue}if(p<40)f(v,p+1)}};f(l,0);let d=l;let g=getOwningComponentName(d);for(let m=0;m<6&&g&&LIST_WRAPPERS.test(g);m++){d=d._debugOwner||d.return;g=getOwningComponentName(d)}n.push({owner:g,items:c,cells:a})})}const s=[];for(const i of n){const l=await Promise.all(i.cells.map(async c=>{const a=findHostInstance(c);return a?measureInstance(a.instance):null}));const o=l.filter(t).length;if(o>0&&i.items>o)s.push({owner:i.owner,items:i.items,listed:o})}return s}async function describeScreen(e={}){const t=includeHiddenScreens;const n=fullVisibleText;includeHiddenScreens=!!e.includeHidden;fullVisibleText=!!e.fullText;try{return await describeScreenInner(e)}finally{includeHiddenScreens=t;fullVisibleText=n}}async function describeScreenInner(e){prunedHiddenScreens=0;const t=collectCandidates();const n=prunedHiddenScreens;const r=e.includeBuoy?t:t.filter(f=>!f.buoy);const s=t.length-r.length;await measureCandidates(r);const i=_reactNative.Dimensions.get("window");const l=Math.round(i.width)||1;const o=Math.round(i.height)||1;const c=[];for(const f of r){const d=f.rect;if(!d&&!f.testID)continue;let g;let m;if(d){const y=d.x+d.width/2;const x=d.y+d.height/2;if(x<-o*.1||x>o*1.1||y<-l*.1||y>l*1.1){continue}g={x:round2(y/l),y:round2(x/o)};m={x:round2(d.x/l),y:round2(d.y/o),width:round2(d.width/l),height:round2(d.height/o)}}const p=f.valueControl?f.valueControl.kind:f.textControl?"text":void 0;const v=f.valueControl?f.valueControl.current:f.textControl?.current;c.push({nativeTag:f.nativeTag,name:f.name,role:f.role,testID:f.testID,label:f.label,text:f.text,interactive:!!(f.press||f.valueControl||f.textControl),longPressable:f.press&&(f.press.kind==="onLongPress"||f.press.longPress)?true:void 0,control:p,value:v,tap:g,frame:m})}c.sort((f,d)=>{const g=f.tap?.y??2;const m=d.tap?.y??2;if(Math.abs(g-m)>.02)return g-m;return(f.tap?.x??2)-(d.tap?.x??2)});const a=await collectLists(!!e.includeBuoy,f=>{if(!f)return false;const d=f.x+f.width/2;return f.y<=o*1.1&&f.y+f.height>=-o*.1&&d>=-l*.1&&d<=l*1.1});return{screen:{width:l,height:o},count:c.length,elements:c,...s>0?{hiddenBuoy:s}:{},...n>0?{hiddenScreens:n}:{},...a.length?{lists:a}:{}}}function round2(e){return Math.round(e*100)/100}function fieldsOf(e){return{nativeTag:e.nativeTag,testID:e.testID,label:e.label,text:e.text,name:e.name}}function matchScore(e,t){return(0,_tapMatch.scoreTapMatch)(fieldsOf(e),t)}function tapPoint(e,t,n){if(!e||!t||!n)return void 0;return{x:(e.x+e.width/2)/t,y:(e.y+e.height/2)/n}}function makeSyntheticPressEvent(e){const t=e?e.x+e.width/2:0;const n=e?e.y+e.height/2:0;const r={locationX:e?e.width/2:0,locationY:e?e.height/2:0,pageX:t,pageY:n,timestamp:0,target:null,identifier:1,touches:[],changedTouches:[]};return{nativeEvent:r,persist:()=>{},preventDefault:()=>{},stopPropagation:()=>{},isDefaultPrevented:()=>false,isPropagationStopped:()=>false,target:null,currentTarget:null,type:"press",timeStamp:0}}async function tapElement(e){const t=withHiddenScreens(!!e.includeHidden,()=>appCandidates(e));if(t.length===0){return{tapped:false,reason:"No React fiber roots / elements found on screen."}}const n=t.map(u=>({c:u,score:matchScore(u,e)})).filter(u=>u.score>0).sort((u,h)=>h.score-u.score);const r=u=>!!(u.press||u.valueControl||u.textControl);if(n.length===0&&!e.includeHidden){const u=withHiddenScreens(true,()=>appCandidates(e)).map(h=>({c:h,score:matchScore(h,e)})).filter(h=>h.score>0);if(u.length>0){return{tapped:false,reason:"That element is only on a screen that isn't showing (another tab, or a screen under the current one). Navigate to it first, or pass includeHidden:true if you really mean the hidden one."}}}if(n.length===0){return{tapped:false,reason:"No element matched. Call describe_screen to see available elements (match by testID, text, or name).",candidates:t.filter(r).slice(0,12).map(u=>({nativeTag:u.nativeTag,name:u.name,testID:u.testID,text:u.text}))}}const s=_reactNative.Dimensions.get("window");const i=s.width||1;const l=s.height||1;const o=n.slice(0,15);await Promise.all(o.map(async u=>{if(u.c.instance&&!u.c.rect)u.c.rect=await measureInstance(u.c.instance)}));for(const u of o){u.score=(0,_tapMatch.scoreTapMatch)({...fieldsOf(u.c),tap:tapPoint(u.c.rect,i,l)},e)}o.sort((u,h)=>h.score-u.score);const c=o.find(u=>r(u.c))??n.find(u=>r(u.c))??o[0];const a=c.c;const f=(u,h)=>u.press&&u.press.handler===h.press?.handler||u.valueControl&&u.valueControl.handler===h.valueControl?.handler||u.textControl&&u.textControl.handler===h.textControl?.handler;const d=o.filter(u=>u!==c&&r(u.c)&&u.score===c.score).filter(u=>!f(u.c,a)).filter((u,h,T)=>T.findIndex(b=>f(b.c,u.c))===h).slice(0,3).map(u=>({nativeTag:u.c.nativeTag,name:u.c.name,testID:u.c.testID,text:u.c.text,tap:tapPoint(u.c.rect,i,l)}));const g=e.nativeTag==null&&!(e.testID&&!e.query);if(g&&d.length>0){const u=[a,...d.map(h=>o.find(T=>T.c.nativeTag===h.nativeTag)?.c).filter(Boolean)];return{tapped:false,reason:`"${e.query}" matches ${u.length} different controls equally well, so nothing was tapped. Tap one by its nativeTag.`,candidates:u.map(h=>({nativeTag:h.nativeTag,name:h.name,testID:h.testID,text:h.text}))}}const m=o[0];if(g&&m&&m!==c&&!r(m.c)&&m.score>=90&&c.score<m.score-40){return{tapped:false,reason:`The best match for "${e.query}" is "${m.c.text??m.c.label??m.c.name}", which has no JS press handler (it may be native, like a tab bar button). The closest pressable match, "${a.text??a.label??a.name}", is a much weaker match, so nothing was tapped. Use navigate, or tap a specific element by nativeTag.`,candidates:[{nativeTag:a.nativeTag,name:a.name,testID:a.testID,text:a.text}]}}if(!r(a)){return{tapped:false,reason:`Matched "${a.name}"${a.text?` ("${a.text}")`:""} but it has no onPress / onValueChange / onChangeText handler (e.g. a react-native-gesture-handler GestureDetector). This element can't be driven in JS.`,matched:{nativeTag:a.nativeTag,name:a.name,testID:a.testID,label:a.label,text:a.text,via:"onPress"}}}if(a.instance&&!a.rect)a.rect=await measureInstance(a.instance);let p=false;const v=a.rect==null||!(0,_tapMatch.isRectCenterOnScreen)(a.rect,i,l);if(v&&e.scrollIntoView!==false&&a.instance){p=await scrollIntoView(a.fiber,a.instance,a.stateNode,80);if(p)a.rect=await measureInstance(a.instance)}const y={nativeTag:a.nativeTag,name:a.name,testID:a.testID,label:a.label,text:a.text};ensureCommitCounter();const x=commitCount;const I=Date.now();const P=async u=>{await new Promise(h=>setTimeout(h,TAP_SETTLE_MS));return{tapped:true,scrolled:p,matched:u,effect:{commits:commitCount-x,observedMs:Date.now()-I},...d.length?{alsoMatched:d}:{}}};try{if(a.press){if(e.longPress){const h=a.press.kind==="onLongPress"?a.press.handler:a.press.longPress;if(!h){return{tapped:false,scrolled:p,reason:`Matched "${a.name}"${a.text?` ("${a.text}")`:""} but it has no onLongPress handler \u2014 call tap_element without longPress to tap it normally.`,matched:{...y,via:"onPress"}}}h(makeSyntheticPressEvent(a.rect));return await P({...y,via:"onLongPress"})}a.press.handler(makeSyntheticPressEvent(a.rect));return await P({...y,via:a.press.kind})}if(a.valueControl){const h=a.valueControl;let T;if(h.kind==="toggle"){T=typeof e.value==="boolean"?e.value:!h.current}else{const b=h.min??0;const C=h.max??1;if(typeof e.value==="number"){T=Math.min(C,Math.max(b,e.value))}else{T=h.current===C?b:C}}h.handler(T);return await P({...y,via:"onValueChange",value:T})}const u=e.text??(typeof e.value==="string"?e.value:"");a.textControl.handler(u);return await P({...y,via:"onChangeText",value:u})}catch(u){return{tapped:false,scrolled:p,reason:`handler threw: ${u instanceof Error?u.message:String(u)}`,matched:{...y,via:a.press?a.press.kind:a.valueControl?"onValueChange":"onChangeText"}}}}const WAIT_DEFAULT_MS=5e3;const WAIT_MAX_MS=3e4;const WAIT_MIN_POLL_MS=50;const WAIT_DEFAULT_POLL_MS=150;async function waitFor(e){const t=e.nativeTag!=null||!!String(e.testID??"").trim()||!!String(e.query??"").trim();if(!t){return{ok:false,waitedMs:0,polls:0,reason:"Nothing to wait for \u2014 pass nativeTag, testID or query."}}const n=Math.min(Math.max(e.timeoutMs??WAIT_DEFAULT_MS,0),WAIT_MAX_MS);const r=Math.max(e.pollMs??WAIT_DEFAULT_POLL_MS,WAIT_MIN_POLL_MS);const s=e.gone===true;const i=Date.now();let l=0;for(;;){l+=1;const{hit:o,closest:c}=await findOnScreen(e);if(s?!o:!!o){return{ok:true,waitedMs:Date.now()-i,polls:l,matched:o??void 0}}if(Date.now()-i>=n){const a=c?.length?c:void 0;const f=s?`Still on screen after ${n}ms.`:a?`Not on screen after ${n}ms \u2014 ${a.length===1?"one element":`${a.length} elements`} matched but ${a.some(d=>d.onScreen)?"not well enough":"none is visible"}. See \`closest\`; do not retry with different words, call describeScreen.`:`Not on screen after ${n}ms, and nothing matched those words at all. Call describeScreen to see what is there.`;return{ok:false,waitedMs:Date.now()-i,polls:l,reason:f,matched:o??void 0,closest:a}}await new Promise(a=>setTimeout(a,r))}}async function findOnScreen(e){const t=appCandidates(e).map(o=>({c:o,score:matchScore(o,e)})).filter(o=>o.score>0).sort((o,c)=>c.score-o.score).slice(0,8);if(t.length===0)return{hit:null,closest:void 0};await measureCandidates(t.map(o=>o.c));const n=_reactNative.Dimensions.get("window");const r=Math.round(n.width)||1;const s=Math.round(n.height)||1;let i=null;for(const{c:o}of t){if(!(0,_tapMatch.isRectCenterOnScreen)(o.rect,r,s))continue;i={nativeTag:o.nativeTag,name:o.name,testID:o.testID,label:o.label,text:o.text,interactive:!!(o.press||o.valueControl||o.textControl)};break}const l=t.slice(0,3).map(({c:o})=>({name:o.name,testID:o.testID,text:o.text,onScreen:(0,_tapMatch.isRectCenterOnScreen)(o.rect,r,s)}));return{hit:i,closest:l}}function isBuoyChrome(e){let t=e;let n=0;while(t&&n<400){if(getProps(t)?.__buoyDevToolsRoot)return true;t=t.return;n++}return false}function preferHandlerOwner(e,t){const n=getProps(e.fiber);if(typeof n?.onPress==="function"||typeof n?.onValueChange==="function"||typeof n?.onChangeText==="function"){return e}let r=null;let s=e.fiber?.return;let i=0;while(s&&i<25){if(typeof getProps(s)?.onPress==="function"){r=s;break}s=s.return;i++}if(!r)return e;let l=r;for(let o=0;o<6&&l;o++){const c=t.get(l);if(c)return c;l=l.return}return e}function resolveTouchTarget(e){const t=collectCandidates();if(t.length===0)return null;const n=new Map;for(const o of t)n.set(o.fiber,o);const r=t.find(o=>o.nativeTag===e);let s=null;if(!r){for(const o of getAllFiberRoots()){traverseFiberTree(o.current,c=>{if(s)return;if(c.stateNode&&getNativeTag(c.stateNode)===e){s=c}});if(s)break}}let i=r??null;if(!i&&s){let o=s;let c=0;let a=null;while(o&&c<25){const f=n.get(o);if(f){if(f.press||f.valueControl||f.textControl){i=f;break}if(!a)a=f}o=o.return;c++}if(!i)i=a}if(!i)return null;i=preferHandlerOwner(i,n);if(!i.press&&!i.valueControl&&!i.textControl)return null;if(isBuoyChrome(i.fiber))return null;const l=i.valueControl?i.valueControl.kind:i.textControl?"text":"press";return{nativeTag:i.nativeTag,name:i.name,role:i.role,testID:i.testID,label:i.label,text:i.text,control:l,value:i.valueControl?i.valueControl.current:i.textControl?i.textControl.current:void 0}}function fiberForTag(e){let t=null;for(const n of getAllFiberRoots()){traverseFiberTree(n.current,r=>{if(!t&&r.stateNode&&getNativeTag(r.stateNode)===e)t=r});if(t)break}return t}function rootHostFibers(){const e=[];for(const t of getAllFiberRoots()){let n=t.current?.child;let r=0;while(n&&r++<200){if(n.tag===HostComponent&&n.stateNode){e.push(n);break}n=n.child}}return e}function fabricFiberAt(e,t){const n=global.nativeFabricUIManager;if(!n||typeof n.findNodeAtPoint!=="function")return null;const r=rootHostFibers().filter(s=>s.stateNode?.node);if(!r.length)return null;return new Promise(s=>{const i=setTimeout(()=>s(null),1e3);let l=r.length;let o=null;r.forEach((c,a)=>{try{n.findNodeAtPoint(c.stateNode.node,e,t,f=>{if(f&&(!o||a>=o.i))o={i:a,fiber:f};if(--l===0){clearTimeout(i);s(o?.fiber??null)}})}catch{if(--l===0){clearTimeout(i);s(o?.fiber??null)}}})})}function paperFiberAt(e,t){const n=_reactNative.UIManager?.findSubviewIn;if(typeof n!=="function")return null;const r=rootHostFibers()[0];const s=r?getNativeTag(r.stateNode)??(0,_reactNative.findNodeHandle)(r.stateNode):null;if(s==null)return null;return new Promise(i=>{const l=setTimeout(()=>i(null),1e3);try{n.call(_reactNative.UIManager,s,[e,t],o=>{clearTimeout(l);i(typeof o==="number"?fiberForTag(o):null)})}catch{clearTimeout(l);i(null)}})}function visibleHostFibers(){const e=[];const t=new Set;const n=s=>{const i=[];const l=(o,c)=>{for(let a=o;a&&i.length<5e3;a=a.sibling){if(t.has(a)||c>500)continue;if(isHiddenOffscreen(a)||isInactiveScreen(a))continue;if(a.tag===HostComponent&&a.stateNode)i.push(a);else if(a.child)l(a.child,c+1)}};if(s.child)l(s.child,0);return i};const r=(s,i)=>{if(t.has(s)||i>500)return;t.add(s);e.push(s);sortByZ(n(s)).forEach(l=>r(l,i+1))};for(const s of getAllFiberRoots())sortByZ(n(s.current)).forEach(i=>r(i,0));return e}function sortByZ(e){const t=e.map(n=>{const r=Number(flatStyle(getProps(n)?.style).zIndex);return Number.isFinite(r)?r:0});return e.map((n,r)=>({h:n,i:r})).sort((n,r)=>t[n.i]-t[r.i]||n.i-r.i).map(({h:n})=>n)}function flatStyle(e,t=0){if(!e||typeof e!=="object"||t>10)return{};if(Array.isArray(e))return Object.assign({},...e.map(n=>flatStyle(n,t+1)));return e}const SCROLL_HOSTS=new Set(["RCTScrollView","AndroidHorizontalScrollView","RCTScrollContentView"]);function clipsChildren(e){if(typeof e.type==="string"&&SCROLL_HOSTS.has(e.type)&&e.type!=="RCTScrollContentView")return true;const t=flatStyle(getProps(e)?.style).overflow;return t==="hidden"||t==="scroll"}function passesTouchesThrough(e){let t=getProps(e)?.pointerEvents??getProps(e)?.style?.pointerEvents;if(t==="none")return"all";let n=e.return;let r=0;while(n&&r++<200){const s=getProps(n)?.pointerEvents??getProps(n)?.style?.pointerEvents;if(s==="none")return"all";if(s==="box-only"&&n.tag===HostComponent)return"all";n=n.return}return t==="box-none"?"self":null}async function measuredFiberAt(e,t,n){const r=await Promise.all(n.map(o=>{const c=getPublicInstance(o.stateNode);return c?measureInstance(c):Promise.resolve(null)}));const s=new Map;n.forEach((o,c)=>s.set(o,r[c]));const i=o=>!!o&&e>=o.x&&e<=o.x+o.width&&t>=o.y&&t<=o.y+o.height;const l=o=>{for(let c=o.return,a=0;c&&a<300;c=c.return,a++){if(c.tag===HostComponent&&s.has(c)&&clipsChildren(c)&&!i(s.get(c)))return true}return false};for(let o=n.length-1;o>=0;o--){if(!i(r[o])||passesTouchesThrough(n[o])||l(n[o]))continue;return n[o]}return null}function domFiberAt(e,t){const n=global.document;const r=global.window;if(!n?.elementFromPoint||!r)return null;let s=n.elementFromPoint(e*r.innerWidth,t*r.innerHeight);while(s){const i=Object.keys(s).find(l=>l.startsWith("__reactFiber$"));if(i)return s[i];s=s.parentElement}return null}async function hitTest(e){const t=Math.min(1,Math.max(0,Number(e?.x)));const n=Math.min(1,Math.max(0,Number(e?.y)));if(!Number.isFinite(t)||!Number.isFinite(n))return{found:false,method:"none",reason:"x and y must be numbers from 0 to 1."};const r=_reactNative.Dimensions.get("window");const s=t*r.width;const i=n*r.height;let l="none";let o=null;const c=domFiberAt(t,n);if(c){l="dom";o=c}else{const p=fabricFiberAt(s,i);if(p){l="fabric";o=await p}else{const y=paperFiberAt(s,i);if(y){l="paper";o=await y}}const v=visibleHostFibers();if(!o||!new Set(v).has(o)){o=await measuredFiberAt(s,i,v);l="measured"}}if(!o)return{found:false,method:l};const a=getProps(o)??{};const f=getNativeTag(o.stateNode);const d=[];let g=o;let m=0;while(g&&m++<80&&d.length<6){const p=getComponentName(g);if(p&&typeof g.type!=="string"&&!INTERNAL_NAMES.has(p)&&d[d.length-1]!==p)d.push(p);g=g.return}return{found:true,method:l,buoy:isBuoyChrome(o),view:{name:getComponentName(o)??"Unknown",nativeTag:f,testID:a.testID||void 0,label:a.accessibilityLabel||a["aria-label"]||void 0,text:getVisibleText(a)},path:d,target:f!=null?resolveTouchTarget(f):null}}async function readMaps(){const e=[];for(const s of getAllFiberRoots()){traverseFiberTree(s.current,i=>{const l=i.stateNode;if(i.tag===1&&l&&typeof l.getCamera==="function"&&!isBuoyChrome(i))e.push(i)})}const t=_reactNative.Dimensions.get("window");const n=s=>Promise.race([s,new Promise(i=>setTimeout(()=>i(null),1e3))]);const r=await Promise.all(e.slice(0,5).map(async s=>{try{const i=await n(Promise.resolve(s.stateNode.getCamera()));if(!i)return null;const l=findHostInstance(s);const o=l?await measureInstance(l.instance):null;const c=getProps(s)??{};return{name:getComponentName(s)??"Map",testID:typeof c.testID==="string"?c.testID:void 0,frame:o&&t.width&&t.height?{x:round2(o.x/t.width),y:round2(o.y/t.height),width:round2(o.width/t.width),height:round2(o.height/t.height)}:void 0,camera:{heading:typeof i.heading==="number"?i.heading:void 0,pitch:typeof i.pitch==="number"?i.pitch:void 0,altitude:typeof i.altitude==="number"?i.altitude:void 0,zoom:typeof i.zoom==="number"?i.zoom:void 0,center:i.center}}}catch{return null}}));return{maps:r.filter(s=>!!s)}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.describeScreen=describeScreen;exports.hitTest=hitTest;exports.readMaps=readMaps;exports.resolveTouchTarget=resolveTouchTarget;exports.tapElement=tapElement;exports.waitFor=waitFor;var _utils=require("@buoy-gg/shared-ui/utils");var _reactNative=require("react-native");var _tapMatch=require("./tapMatch");var _domScreenElements=require("./domScreenElements");const HostComponent=5;const OffscreenComponent=22;const INTERNAL_NAMES=new Set(["View","RCTView","ScrollView","RCTScrollView","RCTScrollContentView","SafeAreaView","RCTSafeAreaView","AndroidHorizontalScrollContentView","KeyboardAvoidingView","Pressable","PlatformPressable","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","TouchableNativeFeedback","AnimatedComponent","Wrapper"]);function getReactDevToolsHook(){if(typeof global==="undefined")return null;return global.__REACT_DEVTOOLS_GLOBAL_HOOK__??null}let commitCount=0;let commitCounterInstalled=false;function ensureCommitCounter(){if(commitCounterInstalled)return;const e=getReactDevToolsHook();if(!e)return;const t=e.onCommitFiberRoot;e.onCommitFiberRoot=function(...n){commitCount++;return typeof t==="function"?t.apply(e,n):void 0};commitCounterInstalled=true}const TAP_SETTLE_MS=250;function makeChromeCheck(){const e=new Map;return t=>{const n=[];let r=t;let i=0;let s=false;while(r&&i<400){const a=e.get(r);if(a!==void 0){s=a;break}if(getProps(r)?.__buoyDevToolsRoot){s=true;e.set(r,true);break}n.push(r);r=r.return;i++}for(const a of n)e.set(a,s);return s}}function getAllFiberRoots(){const e=getReactDevToolsHook();if(!e)return[];const t=[];try{if(e.renderers&&typeof e.renderers.forEach==="function"){e.renderers.forEach((n,r)=>{try{const i=e.getFiberRoots?.(r);if(i)i.forEach(s=>t.push(s))}catch{}})}if(t.length===0&&e.getFiberRoots){const n=e.getFiberRoots(1);if(n)n.forEach(r=>t.push(r))}}catch{}return t}function isHiddenOffscreen(e){return e.tag===OffscreenComponent&&e.memoizedState!==null}let includeHiddenScreens=false;let prunedHiddenScreens=0;let fullVisibleText=false;function withHiddenScreens(e,t){const n=includeHiddenScreens;includeHiddenScreens=e;try{return t()}finally{includeHiddenScreens=n}}function isNotShowingScreen(e){const t=e.memoizedProps;if(!t)return false;if(t["aria-hidden"]===true&&(t.activityState!==void 0||"shouldFreeze"in t))return true;if(t.isFocused===false&&(t.routeKey!==void 0||"freezeContents"in t))return true;return false}function isInactiveScreen(e){const t=e.memoizedProps?.activityState;if(t===0||t===1)return true;if(e.memoizedProps?.isPageFocused===false)return true;if(!includeHiddenScreens&&isNotShowingScreen(e)){prunedHiddenScreens++;return true}return false}function traverseFiberTree(e,t,n=0,r=new Set){if(!e||r.has(e)||n>500)return;r.add(e);if(isHiddenOffscreen(e)||isInactiveScreen(e)){if(e.sibling)traverseFiberTree(e.sibling,t,n,r);return}t(e);if(e.child)traverseFiberTree(e.child,t,n+1,r);if(e.sibling)traverseFiberTree(e.sibling,t,n,r)}function getPublicInstance(e){const t=(0,_utils.getDOMPublicInstance)(e);if(t)return t;if(!e)return null;const n=e;if(n.canonical?.publicInstance)return n.canonical.publicInstance;if(n.canonical&&typeof n.canonical.measure==="function"){return n.canonical}if(typeof n.measure==="function"||typeof n.measureInWindow==="function"){return n}return null}function getNativeTag(e){const t=(0,_utils.getDOMNodeHandle)(e);if(t!==null)return t;if(e==null)return null;const n=e;if(typeof n.__nativeTag==="number")return n.__nativeTag;if(typeof n._nativeTag==="number")return n._nativeTag;if(typeof n.nativeTag==="number")return n.nativeTag;if(n.canonical){if(typeof n.canonical.__nativeTag==="number")return n.canonical.__nativeTag;if(typeof n.canonical._nativeTag==="number")return n.canonical._nativeTag;if(typeof n.canonical.nativeTag==="number")return n.canonical.nativeTag}return null}function findHostInstance(e){const t=getPublicInstance(e.stateNode);if(t){return{instance:t,nativeTag:getNativeTag(e.stateNode),stateNode:e.stateNode}}const n=[];if(e.child)n.push(e.child);let r=0;while(n.length>0&&r<4e3){r++;const i=n.pop();if(!i)continue;const s=getPublicInstance(i.stateNode);if(s)return{instance:s,nativeTag:getNativeTag(i.stateNode),stateNode:i.stateNode};if(i.child)n.push(i.child);if(i.sibling)n.push(i.sibling)}return null}function findScrollAncestor(e){let t=e;let n=0;while(t&&n++<200){const r=t.stateNode;if(r&&typeof r.scrollTo==="function"){const i=typeof r.getNativeScrollRef==="function"&&r.getNativeScrollRef()||null;const s=typeof r.getInnerViewNode==="function"&&r.getInnerViewNode()||typeof r.getScrollableNode==="function"&&r.getScrollableNode()||r;return{instance:r,nativeRef:i,innerNode:s}}t=t.return}return null}async function scrollIntoView(e,t,n,r){try{if((0,_utils.isDOMElement)(n)){n.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"});await new Promise(u=>setTimeout(u,16));return true}const i=findScrollAncestor(e);if(!i)return false;const s=t;let a=null;const o=u=>new Promise(l=>{let c=false;const d=m=>{if(c)return;c=true;l(m)};const g=setTimeout(()=>d(null),600);try{u(m=>{clearTimeout(g);d(m)})}catch{clearTimeout(g);d(null)}});if(i.nativeRef&&typeof s.measureLayout==="function"){a=await o(u=>s.measureLayout(i.nativeRef,(l,c)=>u(c),()=>u(null)))}if(a==null){const u=(0,_reactNative.findNodeHandle)(t);const l=typeof i.innerNode==="number"?i.innerNode:(0,_reactNative.findNodeHandle)(i.innerNode);if(u!=null&&l!=null){a=await o(c=>_reactNative.UIManager.measureLayout(u,l,()=>c(null),(d,g)=>c(g)))}}if(a==null)return false;i.instance.scrollTo({y:Math.max(0,a-r),animated:false});await new Promise(u=>setTimeout(u,120));return true}catch{return false}}function getComponentName(e){const t=e?.type;if(!t)return null;if(typeof t==="string")return t;return t.displayName||t.name||null}function getOwningComponentName(e){let t=e?._debugOwner||e?.return;let n=0;while(t&&n<30){n++;const r=getComponentName(t);if(r&&!INTERNAL_NAMES.has(r)&&typeof t.type!=="string"){return r}t=t.return}return null}function getProps(e){return(0,_utils.getDOMControlProps)(e?.stateNode,e?.memoizedProps??e?.pendingProps??null)}function flattenText(e,t=0){if(typeof e==="string")return e;if(typeof e==="number"&&Number.isFinite(e))return String(e);if(Array.isArray(e)&&t<4){const n=[];for(const r of e){const i=flattenText(r,t+1);if(i)n.push(i)}return n.length>0?n.join(""):void 0}return void 0}function normalizeVisibleText(e){return e.replace(/\s+/g," ").trim()}function getVisibleText(e){if(!e)return void 0;const t=n=>{const r=flattenText(n);if(r===void 0)return void 0;const i=normalizeVisibleText(r);return i?fullVisibleText?i:i.slice(0,80):void 0};return t(e.children)??t(e.title)??t(e.label)??t(e.placeholder)??void 0}function collectDescendantText(e,t){const n=[];const r=(s,a)=>{if(!s||a>t||n.length>=4)return;if(s!==e){const u=getProps(s);if(u&&(typeof u.onPress==="function"||typeof u.onLongPress==="function"))return}const o=getVisibleText(getProps(s));if(o&&!n.includes(o))n.push(o);if(s.child)r(s.child,a+1);if(s!==e&&s.sibling)r(s.sibling,a)};if(e.child)r(e.child,1);const i=n.join(" ").trim();return i?i.slice(0,80):void 0}function findPressHandler(e){let t=e;let n=0;let r=null;let i=null;while(t&&n<25&&!(r&&i)){const s=getProps(t);if(s){if(!r&&typeof s.onPress==="function")r=s.onPress;if(!i&&typeof s.onLongPress==="function")i=s.onLongPress}t=t.return;n++}if(r)return{handler:r,kind:"onPress",longPress:i??void 0};return i?{handler:i,kind:"onLongPress"}:null}function measureInstance(e){return new Promise(t=>{let n=false;const r=i=>{if(n)return;n=true;t(i)};setTimeout(()=>r(null),1e3);try{if(typeof e.measureInWindow==="function"){e.measureInWindow((i,s,a,o)=>{if(a>0&&o>0)r({x:i,y:s,width:a,height:o});else r(null)})}else if(typeof e.measure==="function"){e.measure((i,s,a,o,u,l)=>{if(a>0&&o>0&&u!=null&&l!=null){r({x:u,y:l,width:a,height:o})}else{r(null)}})}else{r(null)}}catch{r(null)}})}const SPINNER_HOSTS=new Set(["RCTActivityIndicatorView","AndroidProgressBar"]);function collectCandidates(){const e=getAllFiberRoots();const t=[];const n=new Map;const r=new Map;const i=makeChromeCheck();for(const s of e){traverseFiberTree(s.current,a=>{const o=getProps(a);if(!o)return;const u=typeof o.onPress==="function"||typeof o.onLongPress==="function";const l=typeof o.onValueChange==="function";const c=typeof o.onChangeText==="function";const d=o.testID||void 0;const g=o.accessibilityLabel||void 0;const m=o.accessibilityRole||o.role||void 0;let w=getVisibleText(o);const y=m==="button"||m==="link"||m==="menuitem"||m==="tab"||m==="switch"||m==="checkbox";const v=typeof a.type==="string"&&SPINNER_HOSTS.has(a.type)&&o.animating!==false;if(!u&&!l&&!c&&!d&&!g&&!w&&!y&&!v){return}let T=null;let P=null;let I=null;if(l){const N=o.value;const S=typeof N==="number"||typeof o.minimumValue==="number";P={handler:o.onValueChange,kind:S?"slider":"toggle",current:N,min:typeof o.minimumValue==="number"?o.minimumValue:void 0,max:typeof o.maximumValue==="number"?o.maximumValue:void 0}}else if(c){I={handler:o.onChangeText,current:typeof o.value==="string"?o.value:void 0}}else{T=findPressHandler(a)}const C=getComponentName(a);let f=C??"Unknown";if(!C||INTERNAL_NAMES.has(C)||typeof a.type==="string"){f=getOwningComponentName(a)??C??"Unknown"}const h=findHostInstance(a);if(!h&&!d)return;if(!w&&!g&&u){w=collectDescendantText(a,6)}const b=h?.instance??null;const x=h?.nativeTag??null;const p=(b?n.get(b):void 0)??(x!=null?r.get(x):void 0);if(p){if(!p.press&&T)p.press=T;else if(p.press&&T?.longPress&&!p.press.longPress){p.press.longPress=T.longPress}if(!p.valueControl&&P)p.valueControl=P;if(!p.textControl&&I)p.textControl=I;if(!p.testID&&d)p.testID=d;if(!p.label&&g)p.label=g;if(!p.text&&w)p.text=w;if(b&&!n.has(b))n.set(b,p);if(x!=null&&!r.has(x))r.set(x,p);return}const D={nativeTag:x,name:f,role:m??(v?"progressbar":void 0),testID:d,label:g,text:w,instance:b,stateNode:h?.stateNode??null,fiber:a,press:T,valueControl:P,textControl:I,rect:null,buoy:i(a)};t.push(D);if(b)n.set(b,D);if(x!=null)r.set(x,D)})}t.push(...collectDOMCandidates());return t}function collectDOMCandidates(){return(0,_domScreenElements.collectDOMElements)({fullText:fullVisibleText}).map(({element:e,props:t,text:n,buoy:r})=>{const i=typeof t.onValueChange==="function"?{handler:t.onValueChange,kind:typeof t.value==="number"?"slider":"toggle",current:t.value,min:t.minimumValue,max:t.maximumValue}:null;const s=!i&&typeof t.onChangeText==="function"?{handler:t.onChangeText,current:t.value}:null;const a=!i&&!s&&typeof t.onPress==="function"?{handler:t.onPress,kind:"onPress"}:null;return{nativeTag:(0,_utils.getDOMNodeHandle)(e),name:(0,_domScreenElements.domElementName)(e),role:t.accessibilityRole,testID:t.testID,label:t.accessibilityLabel,text:n,instance:(0,_utils.getDOMPublicInstance)(e),stateNode:e,fiber:null,buoy:r,press:a,valueControl:i,textControl:s,rect:null}})}function explicitlyTargets(e,t){if(t.nativeTag!=null)return e.nativeTag===t.nativeTag;if(t.testID&&e.testID)return e.testID.toLowerCase()===t.testID.toLowerCase();return false}function appCandidates(e){const t=collectCandidates();if(e.includeBuoy)return t;return t.filter(n=>!n.buoy||explicitlyTargets(n,e))}async function measureCandidates(e){await Promise.all(e.map(async t=>{if(t.instance)t.rect=await measureInstance(t.instance)}))}const LIST_WRAPPERS=/^(FlatList|SectionList|VirtualizedSectionList|VirtualizedList|Animated\(.*\)|AnimatedComponent.*)$/;async function collectLists(e,t){const n=[];const r=makeChromeCheck();for(const s of getAllFiberRoots()){traverseFiberTree(s.current,a=>{if(getComponentName(a)!=="VirtualizedList")return;const o=a.memoizedProps;if(!o||typeof o.getItemCount!=="function")return;if(!e&&r(a))return;let u;try{u=Number(o.getItemCount(o.data))}catch{return}if(!Number.isFinite(u)||u<=0)return;const l=[];const c=(m,w)=>{for(let y=m?.child;y;y=y.sibling){const v=getComponentName(y);if(v==="VirtualizedList")continue;if(v==="CellRenderer"){l.push(y);continue}if(w<40)c(y,w+1)}};c(a,0);let d=a;let g=getOwningComponentName(d);for(let m=0;m<6&&g&&LIST_WRAPPERS.test(g);m++){d=d._debugOwner||d.return;g=getOwningComponentName(d)}n.push({owner:g,items:u,cells:l})})}const i=[];for(const s of n){const a=await Promise.all(s.cells.map(async u=>{const l=findHostInstance(u);return l?measureInstance(l.instance):null}));const o=a.filter(t).length;if(o>0&&s.items>o)i.push({owner:s.owner,items:s.items,listed:o})}return i}async function describeScreen(e={}){const t=includeHiddenScreens;const n=fullVisibleText;includeHiddenScreens=!!e.includeHidden;fullVisibleText=!!e.fullText;try{return await describeScreenInner(e)}finally{includeHiddenScreens=t;fullVisibleText=n}}async function describeScreenInner(e){prunedHiddenScreens=0;const t=collectCandidates();const n=prunedHiddenScreens;const r=e.includeBuoy?t:t.filter(c=>!c.buoy);const i=t.length-r.length;await measureCandidates(r);const s=_reactNative.Dimensions.get("window");const a=Math.round(s.width)||1;const o=Math.round(s.height)||1;const u=[];for(const c of r){const d=c.rect;if(!d&&!c.testID)continue;let g;let m;if(d){const v=d.x+d.width/2;const T=d.y+d.height/2;if(T<-o*.1||T>o*1.1||v<-a*.1||v>a*1.1){continue}g={x:round2(v/a),y:round2(T/o)};m={x:round2(d.x/a),y:round2(d.y/o),width:round2(d.width/a),height:round2(d.height/o)}}const w=c.valueControl?c.valueControl.kind:c.textControl?"text":void 0;const y=c.valueControl?c.valueControl.current:c.textControl?.current;u.push({nativeTag:c.nativeTag,name:c.name,role:c.role,testID:c.testID,label:c.label,text:c.text,interactive:!!(c.press||c.valueControl||c.textControl),longPressable:c.press&&(c.press.kind==="onLongPress"||c.press.longPress)?true:void 0,control:w,value:y,tap:g,frame:m})}u.sort((c,d)=>{const g=c.tap?.y??2;const m=d.tap?.y??2;if(Math.abs(g-m)>.02)return g-m;return(c.tap?.x??2)-(d.tap?.x??2)});const l=await collectLists(!!e.includeBuoy,c=>{if(!c)return false;const d=c.x+c.width/2;return c.y<=o*1.1&&c.y+c.height>=-o*.1&&d>=-a*.1&&d<=a*1.1});return{screen:{width:a,height:o},count:u.length,elements:u,...i>0?{hiddenBuoy:i}:{},...n>0?{hiddenScreens:n}:{},...l.length?{lists:l}:{}}}function round2(e){return Math.round(e*100)/100}function fieldsOf(e){return{nativeTag:e.nativeTag,testID:e.testID,label:e.label,text:e.text,name:e.name}}function matchScore(e,t){return(0,_tapMatch.scoreTapMatch)(fieldsOf(e),t)}function tapPoint(e,t,n){if(!e||!t||!n)return void 0;return{x:(e.x+e.width/2)/t,y:(e.y+e.height/2)/n}}function makeSyntheticPressEvent(e){const t=e?e.x+e.width/2:0;const n=e?e.y+e.height/2:0;const r={locationX:e?e.width/2:0,locationY:e?e.height/2:0,pageX:t,pageY:n,timestamp:0,target:null,identifier:1,touches:[],changedTouches:[]};return{nativeEvent:r,persist:()=>{},preventDefault:()=>{},stopPropagation:()=>{},isDefaultPrevented:()=>false,isPropagationStopped:()=>false,target:null,currentTarget:null,type:"press",timeStamp:0}}async function tapElement(e){const t=withHiddenScreens(!!e.includeHidden,()=>appCandidates(e));if(t.length===0){return{tapped:false,reason:"Nothing on screen to tap: no React elements and no page elements were found."}}const n=t.map(f=>({c:f,score:matchScore(f,e)})).filter(f=>f.score>0).sort((f,h)=>h.score-f.score);const r=f=>!!(f.press||f.valueControl||f.textControl);if(n.length===0&&!e.includeHidden){const f=withHiddenScreens(true,()=>appCandidates(e)).map(h=>({c:h,score:matchScore(h,e)})).filter(h=>h.score>0);if(f.length>0){return{tapped:false,reason:"That element is only on a screen that isn't showing (another tab, or a screen under the current one). Navigate to it first, or pass includeHidden:true if you really mean the hidden one."}}}if(n.length===0){return{tapped:false,reason:"No element matched. Call describe_screen to see available elements (match by testID, text, or name).",candidates:t.filter(r).slice(0,12).map(f=>({nativeTag:f.nativeTag,name:f.name,testID:f.testID,text:f.text}))}}const i=_reactNative.Dimensions.get("window");const s=i.width||1;const a=i.height||1;const o=n.slice(0,15);await Promise.all(o.map(async f=>{if(f.c.instance&&!f.c.rect)f.c.rect=await measureInstance(f.c.instance)}));for(const f of o){f.score=(0,_tapMatch.scoreTapMatch)({...fieldsOf(f.c),tap:tapPoint(f.c.rect,s,a)},e)}o.sort((f,h)=>h.score-f.score);const u=o.find(f=>r(f.c))??n.find(f=>r(f.c))??o[0];const l=u.c;const c=(f,h)=>f.press&&f.press.handler===h.press?.handler||f.valueControl&&f.valueControl.handler===h.valueControl?.handler||f.textControl&&f.textControl.handler===h.textControl?.handler;const d=o.filter(f=>f!==u&&r(f.c)&&f.score===u.score).filter(f=>!c(f.c,l)).filter((f,h,b)=>b.findIndex(x=>c(x.c,f.c))===h).slice(0,3).map(f=>({nativeTag:f.c.nativeTag,name:f.c.name,testID:f.c.testID,text:f.c.text,tap:tapPoint(f.c.rect,s,a)}));const g=e.nativeTag==null&&!(e.testID&&!e.query);if(g&&d.length>0){const f=[l,...d.map(h=>o.find(b=>b.c.nativeTag===h.nativeTag)?.c).filter(Boolean)];return{tapped:false,reason:`"${e.query}" matches ${f.length} different controls equally well, so nothing was tapped. Tap one by its nativeTag.`,candidates:f.map(h=>({nativeTag:h.nativeTag,name:h.name,testID:h.testID,text:h.text}))}}const m=o[0];if(g&&m&&m!==u&&!r(m.c)&&m.score>=90&&u.score<m.score-40){return{tapped:false,reason:`The best match for "${e.query}" is "${m.c.text??m.c.label??m.c.name}", which has no JS press handler (it may be native, like a tab bar button). The closest pressable match, "${l.text??l.label??l.name}", is a much weaker match, so nothing was tapped. Use navigate, or tap a specific element by nativeTag.`,candidates:[{nativeTag:l.nativeTag,name:l.name,testID:l.testID,text:l.text}]}}if(!r(l)){return{tapped:false,reason:`Matched "${l.name}"${l.text?` ("${l.text}")`:""} but it has no onPress / onValueChange / onChangeText handler (e.g. a react-native-gesture-handler GestureDetector). This element can't be driven in JS.`,matched:{nativeTag:l.nativeTag,name:l.name,testID:l.testID,label:l.label,text:l.text,via:"onPress"}}}if(l.instance&&!l.rect)l.rect=await measureInstance(l.instance);let w=false;const y=l.rect==null||!(0,_tapMatch.isRectCenterOnScreen)(l.rect,s,a);if(y&&e.scrollIntoView!==false&&l.instance){w=await scrollIntoView(l.fiber,l.instance,l.stateNode,80);if(w)l.rect=await measureInstance(l.instance)}const v={nativeTag:l.nativeTag,name:l.name,testID:l.testID,label:l.label,text:l.text};ensureCommitCounter();const T=commitCount;const P=l.fiber===null&&(0,_utils.isDOMElement)(l.stateNode)?(0,_domScreenElements.watchDOMChanges)():null;const I=Date.now();const C=async f=>{await new Promise(h=>setTimeout(h,TAP_SETTLE_MS));return{tapped:true,scrolled:w,matched:f,effect:{commits:P?P():commitCount-T,observedMs:Date.now()-I},...d.length?{alsoMatched:d}:{}}};try{if(l.press){if(e.longPress){const h=l.press.kind==="onLongPress"?l.press.handler:l.press.longPress;if(!h){return{tapped:false,scrolled:w,reason:`Matched "${l.name}"${l.text?` ("${l.text}")`:""} but it has no onLongPress handler \u2014 call tap_element without longPress to tap it normally.`,matched:{...v,via:"onPress"}}}h(makeSyntheticPressEvent(l.rect));return await C({...v,via:"onLongPress"})}l.press.handler(makeSyntheticPressEvent(l.rect));return await C({...v,via:l.press.kind})}if(l.valueControl){const h=l.valueControl;let b;if(h.kind==="toggle"){b=typeof e.value==="boolean"?e.value:!h.current}else{const x=h.min??0;const p=h.max??1;if(typeof e.value==="number"){b=Math.min(p,Math.max(x,e.value))}else{b=h.current===p?x:p}}h.handler(b);return await C({...v,via:"onValueChange",value:b})}const f=e.text??(typeof e.value==="string"?e.value:"");l.textControl.handler(f);return await C({...v,via:"onChangeText",value:f})}catch(f){P?.();return{tapped:false,scrolled:w,reason:`handler threw: ${f instanceof Error?f.message:String(f)}`,matched:{...v,via:l.press?l.press.kind:l.valueControl?"onValueChange":"onChangeText"}}}}const WAIT_DEFAULT_MS=5e3;const WAIT_MAX_MS=3e4;const WAIT_MIN_POLL_MS=50;const WAIT_DEFAULT_POLL_MS=150;async function waitFor(e){const t=e.nativeTag!=null||!!String(e.testID??"").trim()||!!String(e.query??"").trim();if(!t){return{ok:false,waitedMs:0,polls:0,reason:"Nothing to wait for \u2014 pass nativeTag, testID or query."}}const n=Math.min(Math.max(e.timeoutMs??WAIT_DEFAULT_MS,0),WAIT_MAX_MS);const r=Math.max(e.pollMs??WAIT_DEFAULT_POLL_MS,WAIT_MIN_POLL_MS);const i=e.gone===true;const s=Date.now();let a=0;for(;;){a+=1;const{hit:o,closest:u}=await findOnScreen(e);if(i?!o:!!o){return{ok:true,waitedMs:Date.now()-s,polls:a,matched:o??void 0}}if(Date.now()-s>=n){const l=u?.length?u:void 0;const c=i?`Still on screen after ${n}ms.`:l?`Not on screen after ${n}ms \u2014 ${l.length===1?"one element":`${l.length} elements`} matched but ${l.some(d=>d.onScreen)?"not well enough":"none is visible"}. See \`closest\`; do not retry with different words, call describeScreen.`:`Not on screen after ${n}ms, and nothing matched those words at all. Call describeScreen to see what is there.`;return{ok:false,waitedMs:Date.now()-s,polls:a,reason:c,matched:o??void 0,closest:l}}await new Promise(l=>setTimeout(l,r))}}async function findOnScreen(e){const t=appCandidates(e).map(o=>({c:o,score:matchScore(o,e)})).filter(o=>o.score>0).sort((o,u)=>u.score-o.score).slice(0,8);if(t.length===0)return{hit:null,closest:void 0};await measureCandidates(t.map(o=>o.c));const n=_reactNative.Dimensions.get("window");const r=Math.round(n.width)||1;const i=Math.round(n.height)||1;let s=null;for(const{c:o}of t){if(!(0,_tapMatch.isRectCenterOnScreen)(o.rect,r,i))continue;s={nativeTag:o.nativeTag,name:o.name,testID:o.testID,label:o.label,text:o.text,interactive:!!(o.press||o.valueControl||o.textControl)};break}const a=t.slice(0,3).map(({c:o})=>({name:o.name,testID:o.testID,text:o.text,onScreen:(0,_tapMatch.isRectCenterOnScreen)(o.rect,r,i)}));return{hit:s,closest:a}}function isBuoyChrome(e){let t=e;let n=0;while(t&&n<400){if(getProps(t)?.__buoyDevToolsRoot)return true;t=t.return;n++}return false}function preferHandlerOwner(e,t){const n=getProps(e.fiber);if(typeof n?.onPress==="function"||typeof n?.onValueChange==="function"||typeof n?.onChangeText==="function"){return e}let r=null;let i=e.fiber?.return;let s=0;while(i&&s<25){if(typeof getProps(i)?.onPress==="function"){r=i;break}i=i.return;s++}if(!r)return e;let a=r;for(let o=0;o<6&&a;o++){const u=t.get(a);if(u)return u;a=a.return}return e}function resolveTouchTarget(e){const t=collectCandidates();if(t.length===0)return null;const n=new Map;for(const o of t)n.set(o.fiber,o);const r=t.find(o=>o.nativeTag===e);let i=null;if(!r){for(const o of getAllFiberRoots()){traverseFiberTree(o.current,u=>{if(i)return;if(u.stateNode&&getNativeTag(u.stateNode)===e){i=u}});if(i)break}}let s=r??null;if(!s&&i){let o=i;let u=0;let l=null;while(o&&u<25){const c=n.get(o);if(c){if(c.press||c.valueControl||c.textControl){s=c;break}if(!l)l=c}o=o.return;u++}if(!s)s=l}if(!s)return null;s=preferHandlerOwner(s,n);if(!s.press&&!s.valueControl&&!s.textControl)return null;if(isBuoyChrome(s.fiber))return null;const a=s.valueControl?s.valueControl.kind:s.textControl?"text":"press";return{nativeTag:s.nativeTag,name:s.name,role:s.role,testID:s.testID,label:s.label,text:s.text,control:a,value:s.valueControl?s.valueControl.current:s.textControl?s.textControl.current:void 0}}function fiberForTag(e){let t=null;for(const n of getAllFiberRoots()){traverseFiberTree(n.current,r=>{if(!t&&r.stateNode&&getNativeTag(r.stateNode)===e)t=r});if(t)break}return t}function rootHostFibers(){const e=[];for(const t of getAllFiberRoots()){let n=t.current?.child;let r=0;while(n&&r++<200){if(n.tag===HostComponent&&n.stateNode){e.push(n);break}n=n.child}}return e}function fabricFiberAt(e,t){const n=global.nativeFabricUIManager;if(!n||typeof n.findNodeAtPoint!=="function")return null;const r=rootHostFibers().filter(i=>i.stateNode?.node);if(!r.length)return null;return new Promise(i=>{const s=setTimeout(()=>i(null),1e3);let a=r.length;let o=null;r.forEach((u,l)=>{try{n.findNodeAtPoint(u.stateNode.node,e,t,c=>{if(c&&(!o||l>=o.i))o={i:l,fiber:c};if(--a===0){clearTimeout(s);i(o?.fiber??null)}})}catch{if(--a===0){clearTimeout(s);i(o?.fiber??null)}}})})}function paperFiberAt(e,t){const n=_reactNative.UIManager?.findSubviewIn;if(typeof n!=="function")return null;const r=rootHostFibers()[0];const i=r?getNativeTag(r.stateNode)??(0,_reactNative.findNodeHandle)(r.stateNode):null;if(i==null)return null;return new Promise(s=>{const a=setTimeout(()=>s(null),1e3);try{n.call(_reactNative.UIManager,i,[e,t],o=>{clearTimeout(a);s(typeof o==="number"?fiberForTag(o):null)})}catch{clearTimeout(a);s(null)}})}function visibleHostFibers(){const e=[];const t=new Set;const n=i=>{const s=[];const a=(o,u)=>{for(let l=o;l&&s.length<5e3;l=l.sibling){if(t.has(l)||u>500)continue;if(isHiddenOffscreen(l)||isInactiveScreen(l))continue;if(l.tag===HostComponent&&l.stateNode)s.push(l);else if(l.child)a(l.child,u+1)}};if(i.child)a(i.child,0);return s};const r=(i,s)=>{if(t.has(i)||s>500)return;t.add(i);e.push(i);sortByZ(n(i)).forEach(a=>r(a,s+1))};for(const i of getAllFiberRoots())sortByZ(n(i.current)).forEach(s=>r(s,0));return e}function sortByZ(e){const t=e.map(n=>{const r=Number(flatStyle(getProps(n)?.style).zIndex);return Number.isFinite(r)?r:0});return e.map((n,r)=>({h:n,i:r})).sort((n,r)=>t[n.i]-t[r.i]||n.i-r.i).map(({h:n})=>n)}function flatStyle(e,t=0){if(!e||typeof e!=="object"||t>10)return{};if(Array.isArray(e))return Object.assign({},...e.map(n=>flatStyle(n,t+1)));return e}const SCROLL_HOSTS=new Set(["RCTScrollView","AndroidHorizontalScrollView","RCTScrollContentView"]);function clipsChildren(e){if(typeof e.type==="string"&&SCROLL_HOSTS.has(e.type)&&e.type!=="RCTScrollContentView")return true;const t=flatStyle(getProps(e)?.style).overflow;return t==="hidden"||t==="scroll"}function passesTouchesThrough(e){let t=getProps(e)?.pointerEvents??getProps(e)?.style?.pointerEvents;if(t==="none")return"all";let n=e.return;let r=0;while(n&&r++<200){const i=getProps(n)?.pointerEvents??getProps(n)?.style?.pointerEvents;if(i==="none")return"all";if(i==="box-only"&&n.tag===HostComponent)return"all";n=n.return}return t==="box-none"?"self":null}async function measuredFiberAt(e,t,n){const r=await Promise.all(n.map(o=>{const u=getPublicInstance(o.stateNode);return u?measureInstance(u):Promise.resolve(null)}));const i=new Map;n.forEach((o,u)=>i.set(o,r[u]));const s=o=>!!o&&e>=o.x&&e<=o.x+o.width&&t>=o.y&&t<=o.y+o.height;const a=o=>{for(let u=o.return,l=0;u&&l<300;u=u.return,l++){if(u.tag===HostComponent&&i.has(u)&&clipsChildren(u)&&!s(i.get(u)))return true}return false};for(let o=n.length-1;o>=0;o--){if(!s(r[o])||passesTouchesThrough(n[o])||a(n[o]))continue;return n[o]}return null}function domFiberAt(e,t){const n=global.document;const r=global.window;if(!n?.elementFromPoint||!r)return null;let i=n.elementFromPoint(e*r.innerWidth,t*r.innerHeight);while(i){const s=Object.keys(i).find(a=>a.startsWith("__reactFiber$"));if(s)return i[s];i=i.parentElement}return null}function domPageHit(e,t){const n=global.document;const r=global.window;if(!n?.elementFromPoint||!r)return null;const i=n.elementFromPoint(e*r.innerWidth,t*r.innerHeight);if(!i)return null;for(let c=i;c;c=c.parentElement){if(Object.keys(c).some(d=>d.startsWith("__reactFiber$")||d.startsWith("__reactContainer$")))return null}const s=!!i.closest("[data-buoy-root]");const a=collectDOMCandidates();const o=a.find(c=>c.stateNode===i);let u;for(let c=i;c&&!u;c=c.parentElement){u=a.find(d=>d.stateNode===c&&(d.press||d.valueControl||d.textControl))}const l=[];for(let c=i;c&&l.length<6;c=c.parentElement){const d=(0,_domScreenElements.domElementName)(c);if(d!==c.tagName.toLowerCase()&&l[l.length-1]!==d)l.push(d)}return{found:true,method:"dom",buoy:s,view:{name:(0,_domScreenElements.domElementName)(i),nativeTag:(0,_utils.getDOMNodeHandle)(i),testID:o?.testID,label:o?.label,text:o?.text},path:l,target:u&&!s?{nativeTag:u.nativeTag,name:u.name,role:u.role,testID:u.testID,label:u.label,text:u.text,control:u.valueControl?u.valueControl.kind:u.textControl?"text":"press",value:u.valueControl?u.valueControl.current:u.textControl?.current}:null}}async function hitTest(e){const t=Math.min(1,Math.max(0,Number(e?.x)));const n=Math.min(1,Math.max(0,Number(e?.y)));if(!Number.isFinite(t)||!Number.isFinite(n))return{found:false,method:"none",reason:"x and y must be numbers from 0 to 1."};const r=_reactNative.Dimensions.get("window");const i=t*r.width;const s=n*r.height;let a="none";let o=null;const u=domFiberAt(t,n);const l=u?null:domPageHit(t,n);if(l)return l;if(u){a="dom";o=u}else{const y=fabricFiberAt(i,s);if(y){a="fabric";o=await y}else{const T=paperFiberAt(i,s);if(T){a="paper";o=await T}}const v=visibleHostFibers();if(!o||!new Set(v).has(o)){o=await measuredFiberAt(i,s,v);a="measured"}}if(!o)return{found:false,method:a};const c=getProps(o)??{};const d=getNativeTag(o.stateNode);const g=[];let m=o;let w=0;while(m&&w++<80&&g.length<6){const y=getComponentName(m);if(y&&typeof m.type!=="string"&&!INTERNAL_NAMES.has(y)&&g[g.length-1]!==y)g.push(y);m=m.return}return{found:true,method:a,buoy:isBuoyChrome(o),view:{name:getComponentName(o)??"Unknown",nativeTag:d,testID:c.testID||void 0,label:c.accessibilityLabel||c["aria-label"]||void 0,text:getVisibleText(c)},path:g,target:d!=null?resolveTouchTarget(d):null}}async function readMaps(){const e=[];for(const i of getAllFiberRoots()){traverseFiberTree(i.current,s=>{const a=s.stateNode;if(s.tag===1&&a&&typeof a.getCamera==="function"&&!isBuoyChrome(s))e.push(s)})}const t=_reactNative.Dimensions.get("window");const n=i=>Promise.race([i,new Promise(s=>setTimeout(()=>s(null),1e3))]);const r=await Promise.all(e.slice(0,5).map(async i=>{try{const s=await n(Promise.resolve(i.stateNode.getCamera()));if(!s)return null;const a=findHostInstance(i);const o=a?await measureInstance(a.instance):null;const u=getProps(i)??{};return{name:getComponentName(i)??"Map",testID:typeof u.testID==="string"?u.testID:void 0,frame:o&&t.width&&t.height?{x:round2(o.x/t.width),y:round2(o.y/t.height),width:round2(o.width/t.width),height:round2(o.height/t.height)}:void 0,camera:{heading:typeof s.heading==="number"?s.heading:void 0,pitch:typeof s.pitch==="number"?s.pitch:void 0,altitude:typeof s.altitude==="number"?s.altitude:void 0,zoom:typeof s.zoom==="number"?s.zoom:void 0,center:s.center}}}catch{return null}}));return{maps:r.filter(i=>!!i)}}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.highlightUpdatesSyncAdapter=void 0;var _HighlightUpdatesController=_interopRequireDefault(require("../highlight-updates/utils/HighlightUpdatesController"));var _componentSource=require("../highlight-updates/utils/componentSource");var _RenderTracker=require("../highlight-updates/utils/RenderTracker");var _screenElements=require("../highlight-updates/utils/screenElements");var _touchCapture=require("../highlight-updates/utils/touchCapture");var _CommitProfiler=require("../highlight-updates/utils/CommitProfiler");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ensureInitialized(){if(!_HighlightUpdatesController.default.isInitialized()){_HighlightUpdatesController.default.initialize()}}function toWireCause(e){if(!e)return void 0;const{hookChanges:t,...r}=e;return r}function toWireRender(e){const{renderHistory:t,lastRenderCause:r,...n}=e;return{...n,lastRenderCause:toWireCause(r),historyCount:t?.length??0}}function jsonSafeRender(e){try{JSON.stringify(e);return e}catch{return{...e,lastRenderCause:toWireCause(e.lastRenderCause),renderHistory:e.renderHistory?.map(t=>({...t,capturedProps:void 0,capturedState:void 0,cause:toWireCause(t.cause)??t.cause}))}}}function beginMeasurement(){if(!_CommitProfiler.CommitProfiler.isSupported()){return{ok:false,reason:"render capture needs a dev build with the React DevTools hook available"}}_CommitProfiler.CommitProfiler.startCapture({detail:true});return{ok:true}}function endMeasurement(){return{summary:_CommitProfiler.CommitProfiler.stopCapture()}}const highlightUpdatesSyncAdapter=exports.highlightUpdatesSyncAdapter={version:3,getSnapshot:()=>({enabled:_HighlightUpdatesController.default.isEnabled(),frozen:_HighlightUpdatesController.default.getFrozen(),highlightsSuppressed:_HighlightUpdatesController.default.getHighlightsSuppressed(),renders:_RenderTracker.RenderTracker.getRenders().map(toWireRender),trackerState:_RenderTracker.RenderTracker.getState()}),subscribe:e=>{const t=_HighlightUpdatesController.default.subscribe(e);const r=_HighlightUpdatesController.default.subscribeToFreeze(e);const n=_RenderTracker.RenderTracker.subscribe(e);const a=_RenderTracker.RenderTracker.subscribeToState(e);return()=>{t();r();n();a()}},actions:{getComponentSource:async e=>{try{return await(0,_componentSource.getComponentSource)(e)}catch(t){return{found:false,reason:`Could not read the component's source: ${t instanceof Error?t.message:String(t)}`}}},beginMeasurement:()=>beginMeasurement(),endMeasurement:()=>endMeasurement(),getRenderDetail:e=>{const{nativeTag:t}=e??{};if(t==null){return{found:false,reason:"missing nativeTag"}}const r=_RenderTracker.RenderTracker.getRender(String(t));if(!r)return{found:false,reason:"unknown nativeTag"};return{found:true,nativeTag:t,render:jsonSafeRender(r)}},toggle:()=>{ensureInitialized();_HighlightUpdatesController.default.toggle()},setEnabled:e=>{ensureInitialized();_HighlightUpdatesController.default.setEnabled(e.enabled)},toggleFreeze:()=>{_HighlightUpdatesController.default.toggleFreeze()},clearRenderCounts:()=>{_HighlightUpdatesController.default.clearRenderCounts()},setSpotlight:e=>{_HighlightUpdatesController.default.setSpotlight(e.nativeTag)},locateComponent:e=>{ensureInitialized();return _HighlightUpdatesController.default.locateComponent(e??{})},setSilentTracking:e=>{ensureInitialized();_HighlightUpdatesController.default.setSilentTracking(e.enabled??false)},describeScreen:e=>(0,_screenElements.describeScreen)(e??{}),tapElement:e=>(0,_screenElements.tapElement)(e??{}),waitFor:e=>(0,_screenElements.waitFor)(e??{}),hitTest:e=>(0,_screenElements.hitTest)(e??{x:.5,y:.5}),readMaps:()=>(0,_screenElements.readMaps)(),startTouchCapture:()=>(0,_touchCapture.startTouchCapture)(),stopTouchCapture:()=>{(0,_touchCapture.stopTouchCapture)();return(0,_touchCapture.getTouchCaptureStatus)()},clearTouchCapture:()=>{(0,_touchCapture.clearTouchCapture)();return{ok:true}},readTouchCapture:e=>(0,_touchCapture.readTouchCapture)(e?.sinceSeq??0)}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.highlightUpdatesSyncAdapter=void 0;var _HighlightUpdatesController=_interopRequireDefault(require("../highlight-updates/utils/HighlightUpdatesController"));var _componentSource=require("../highlight-updates/utils/componentSource");var _RenderTracker=require("../highlight-updates/utils/RenderTracker");var _screenElements=require("../highlight-updates/utils/screenElements");var _touchCapture=require("../highlight-updates/utils/touchCapture");var _CommitProfiler=require("../highlight-updates/utils/CommitProfiler");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ensureInitialized(){if(!_HighlightUpdatesController.default.isInitialized()){_HighlightUpdatesController.default.initialize()}}function toWireCause(e){if(!e)return void 0;const{hookChanges:t,...r}=e;return r}function toWireRender(e){const{renderHistory:t,lastRenderCause:r,...n}=e;return{...n,lastRenderCause:toWireCause(r),historyCount:t?.length??0}}function jsonSafeRender(e){try{JSON.stringify(e);return e}catch{return{...e,lastRenderCause:toWireCause(e.lastRenderCause),renderHistory:e.renderHistory?.map(t=>({...t,capturedProps:void 0,capturedState:void 0,cause:toWireCause(t.cause)??t.cause}))}}}function frameworkCapture(){const e=globalThis[Symbol.for("buoy.framework.renderCapture")];return e&&typeof e.start==="function"&&e.isSupported()?e:null}let measuring=null;function beginMeasurement(){if(_CommitProfiler.CommitProfiler.isSupported()){_CommitProfiler.CommitProfiler.startCapture({detail:true});measuring="react";return{ok:true}}const e=frameworkCapture();if(e){e.start();measuring=e;return{ok:true}}return{ok:false,reason:"render capture needs a dev build with the React DevTools hook available"}}function endMeasurement(){const e=measuring;measuring=null;if(e&&e!=="react")return{summary:e.stop()};return{summary:_CommitProfiler.CommitProfiler.stopCapture()}}const highlightUpdatesSyncAdapter=exports.highlightUpdatesSyncAdapter={version:3,getSnapshot:()=>({enabled:_HighlightUpdatesController.default.isEnabled(),frozen:_HighlightUpdatesController.default.getFrozen(),highlightsSuppressed:_HighlightUpdatesController.default.getHighlightsSuppressed(),renders:_RenderTracker.RenderTracker.getRenders().map(toWireRender),trackerState:_RenderTracker.RenderTracker.getState()}),subscribe:e=>{const t=_HighlightUpdatesController.default.subscribe(e);const r=_HighlightUpdatesController.default.subscribeToFreeze(e);const n=_RenderTracker.RenderTracker.subscribe(e);const a=_RenderTracker.RenderTracker.subscribeToState(e);return()=>{t();r();n();a()}},actions:{getComponentSource:async e=>{try{return await(0,_componentSource.getComponentSource)(e)}catch(t){return{found:false,reason:`Could not read the component's source: ${t instanceof Error?t.message:String(t)}`}}},beginMeasurement:()=>beginMeasurement(),endMeasurement:()=>endMeasurement(),getRenderDetail:e=>{const{nativeTag:t}=e??{};if(t==null){return{found:false,reason:"missing nativeTag"}}const r=_RenderTracker.RenderTracker.getRender(String(t));if(!r)return{found:false,reason:"unknown nativeTag"};return{found:true,nativeTag:t,render:jsonSafeRender(r)}},toggle:()=>{ensureInitialized();_HighlightUpdatesController.default.toggle()},setEnabled:e=>{ensureInitialized();_HighlightUpdatesController.default.setEnabled(e.enabled)},toggleFreeze:()=>{_HighlightUpdatesController.default.toggleFreeze()},clearRenderCounts:()=>{_HighlightUpdatesController.default.clearRenderCounts()},setSpotlight:e=>{_HighlightUpdatesController.default.setSpotlight(e.nativeTag)},locateComponent:e=>{ensureInitialized();return _HighlightUpdatesController.default.locateComponent(e??{})},setSilentTracking:e=>{ensureInitialized();_HighlightUpdatesController.default.setSilentTracking(e.enabled??false)},describeScreen:e=>(0,_screenElements.describeScreen)(e??{}),tapElement:e=>(0,_screenElements.tapElement)(e??{}),waitFor:e=>(0,_screenElements.waitFor)(e??{}),hitTest:e=>(0,_screenElements.hitTest)(e??{x:.5,y:.5}),readMaps:()=>(0,_screenElements.readMaps)(),startTouchCapture:()=>(0,_touchCapture.startTouchCapture)(),stopTouchCapture:()=>{(0,_touchCapture.stopTouchCapture)();return(0,_touchCapture.getTouchCaptureStatus)()},clearTouchCapture:()=>{(0,_touchCapture.clearTouchCapture)();return{ok:true}},readTouchCapture:e=>(0,_touchCapture.readTouchCapture)(e?.sinceSeq??0)}};
@@ -0,0 +1 @@
1
+ "use strict";import{getDOMControlProps as T}from"@buoy-gg/shared-ui/utils";const g=new Set(["button","link","menuitem","tab","switch","checkbox","radio","option","textbox","slider"]);const A=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE","SVG","PATH","HEAD","META","LINK"]);const l=80;function C(e){for(const t in e){if(t.startsWith("__reactContainer$")||t==="_reactRootContainer")return true}return false}function k(e){if(e.hidden||e.getAttribute("aria-hidden")==="true")return true;const t=getComputedStyle(e);return t.display==="none"||t.visibility==="hidden"}function E(e){const t=e;return typeof t.$$click==="function"||typeof t.onclick==="function"||e.tabIndex>=0&&e.hasAttribute("tabindex")}function w(e){let t="";for(const o of Array.from(e.childNodes))if(o.nodeType===3)t+=o.textContent??"";t=t.replace(/\s+/g," ").trim();return t||void 0}function S(e,t){const o=(e.innerText??e.textContent??"").replace(/\s+/g," ").trim();if(!o)return void 0;return t||o.length<=l?o:`${o.slice(0,l)}\u2026`}export function collectDOMElements(e={}){if(typeof document==="undefined"||!document.body)return[];const t=[];const o=(n,s,p)=>{if(A.has(n.tagName.toUpperCase())||C(n)||k(n))return;const d=p||n.hasAttribute("data-buoy-root");const r=n.tagName.toLowerCase();const i=n.getAttribute("role")??void 0;const u=r==="button"||r==="a"&&n.hasAttribute("href")||r==="input"||r==="textarea"||r==="select"||i!==void 0&&g.has(i)||E(n);const f=n.getAttribute("data-testid")??void 0;const b=n.getAttribute("aria-label")??void 0;const h=u?S(n,!!e.fullText):s?void 0:w(n);if(u||f||b||h){const c={"data-testid":f,"aria-label":b,role:i,id:n.id||void 0};if(u&&r!=="input"&&r!=="textarea"&&r!=="select")c.onClick=()=>n.click();const a=T(n,c);if(i==="switch"||i==="checkbox"){const y=n.getAttribute("aria-checked")==="true";a.value=y;a.onValueChange=x=>{if(Boolean(x)!==(n.getAttribute("aria-checked")==="true"))n.click()};delete a.onPress}if(n.disabled)delete a.onPress;t.push({element:n,props:a,text:h,buoy:d})}for(const c of Array.from(n.children)){if(c instanceof HTMLElement)o(c,s||u,d)}};o(document.body,false,false);return t}export function domElementName(e){const t=globalThis[Symbol.for("buoy.dom.componentName")];try{const o=t?.(e);if(o)return o}catch{}return e.tagName.toLowerCase()}export function watchDOMChanges(){if(typeof MutationObserver==="undefined"||typeof document==="undefined")return()=>0;let e=0;const t=new MutationObserver(()=>{e+=1});t.observe(document.body,{subtree:true,childList:true,characterData:true,attributes:true});return()=>{t.disconnect();return e}}
@@ -1 +1 @@
1
- "use strict";import{getDOMControlProps as ge,getDOMNodeHandle as pe,getDOMPublicInstance as ye,isDOMElement as we}from"@buoy-gg/shared-ui/utils";import{Dimensions as L,UIManager as H,findNodeHandle as O}from"react-native";import{isRectCenterOnScreen as z,scoreTapMatch as ee}from"./tapMatch";const F=5;const ve=22;const $=new Set(["View","RCTView","ScrollView","RCTScrollView","RCTScrollContentView","SafeAreaView","RCTSafeAreaView","AndroidHorizontalScrollContentView","KeyboardAvoidingView","Pressable","PlatformPressable","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","TouchableNativeFeedback","AnimatedComponent","Wrapper"]);function te(){if(typeof global==="undefined")return null;return global.__REACT_DEVTOOLS_GLOBAL_HOOK__??null}let W=0;let ne=false;function Te(){if(ne)return;const e=te();if(!e)return;const t=e.onCommitFiberRoot;e.onCommitFiberRoot=function(...n){W++;return typeof t==="function"?t.apply(e,n):void 0};ne=true}const be=250;function oe(){const e=new Map;return t=>{const n=[];let r=t;let s=0;let i=false;while(r&&s<400){const a=e.get(r);if(a!==void 0){i=a;break}if(v(r)?.__buoyDevToolsRoot){i=true;e.set(r,true);break}n.push(r);r=r.return;s++}for(const a of n)e.set(a,i);return i}}function D(){const e=te();if(!e)return[];const t=[];try{if(e.renderers&&typeof e.renderers.forEach==="function"){e.renderers.forEach((n,r)=>{try{const s=e.getFiberRoots?.(r);if(s)s.forEach(i=>t.push(i))}catch{}})}if(t.length===0&&e.getFiberRoots){const n=e.getFiberRoots(1);if(n)n.forEach(r=>t.push(r))}}catch{}return t}function re(e){return e.tag===ve&&e.memoizedState!==null}let _=false;let B=0;let R=false;function ie(e,t){const n=_;_=e;try{return t()}finally{_=n}}function xe(e){const t=e.memoizedProps;if(!t)return false;if(t["aria-hidden"]===true&&(t.activityState!==void 0||"shouldFreeze"in t))return true;if(t.isFocused===false&&(t.routeKey!==void 0||"freezeContents"in t))return true;return false}function se(e){const t=e.memoizedProps?.activityState;if(t===0||t===1)return true;if(e.memoizedProps?.isPageFocused===false)return true;if(!_&&xe(e)){B++;return true}return false}function N(e,t,n=0,r=new Set){if(!e||r.has(e)||n>500)return;r.add(e);if(re(e)||se(e)){if(e.sibling)N(e.sibling,t,n,r);return}t(e);if(e.child)N(e.child,t,n+1,r);if(e.sibling)N(e.sibling,t,n,r)}function U(e){const t=ye(e);if(t)return t;if(!e)return null;const n=e;if(n.canonical?.publicInstance)return n.canonical.publicInstance;if(n.canonical&&typeof n.canonical.measure==="function"){return n.canonical}if(typeof n.measure==="function"||typeof n.measureInWindow==="function"){return n}return null}function A(e){const t=pe(e);if(t!==null)return t;if(e==null)return null;const n=e;if(typeof n.__nativeTag==="number")return n.__nativeTag;if(typeof n._nativeTag==="number")return n._nativeTag;if(typeof n.nativeTag==="number")return n.nativeTag;if(n.canonical){if(typeof n.canonical.__nativeTag==="number")return n.canonical.__nativeTag;if(typeof n.canonical._nativeTag==="number")return n.canonical._nativeTag;if(typeof n.canonical.nativeTag==="number")return n.canonical.nativeTag}return null}function j(e){const t=U(e.stateNode);if(t){return{instance:t,nativeTag:A(e.stateNode),stateNode:e.stateNode}}const n=[];if(e.child)n.push(e.child);let r=0;while(n.length>0&&r<4e3){r++;const s=n.pop();if(!s)continue;const i=U(s.stateNode);if(i)return{instance:i,nativeTag:A(s.stateNode),stateNode:s.stateNode};if(s.child)n.push(s.child);if(s.sibling)n.push(s.sibling)}return null}function Ce(e){let t=e;let n=0;while(t&&n++<200){const r=t.stateNode;if(r&&typeof r.scrollTo==="function"){const s=typeof r.getNativeScrollRef==="function"&&r.getNativeScrollRef()||null;const i=typeof r.getInnerViewNode==="function"&&r.getInnerViewNode()||typeof r.getScrollableNode==="function"&&r.getScrollableNode()||r;return{instance:r,nativeRef:s,innerNode:i}}t=t.return}return null}async function Pe(e,t,n,r){try{if(we(n)){n.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"});await new Promise(c=>setTimeout(c,16));return true}const s=Ce(e);if(!s)return false;const i=t;let a=null;const o=c=>new Promise(l=>{let f=false;const d=m=>{if(f)return;f=true;l(m)};const g=setTimeout(()=>d(null),600);try{c(m=>{clearTimeout(g);d(m)})}catch{clearTimeout(g);d(null)}});if(s.nativeRef&&typeof i.measureLayout==="function"){a=await o(c=>i.measureLayout(s.nativeRef,(l,f)=>c(f),()=>c(null)))}if(a==null){const c=O(t);const l=typeof s.innerNode==="number"?s.innerNode:O(s.innerNode);if(c!=null&&l!=null){a=await o(f=>H.measureLayout(c,l,()=>f(null),(d,g)=>f(g)))}}if(a==null)return false;s.instance.scrollTo({y:Math.max(0,a-r),animated:false});await new Promise(c=>setTimeout(c,120));return true}catch{return false}}function M(e){const t=e?.type;if(!t)return null;if(typeof t==="string")return t;return t.displayName||t.name||null}function q(e){let t=e?._debugOwner||e?.return;let n=0;while(t&&n<30){n++;const r=M(t);if(r&&!$.has(r)&&typeof t.type!=="string"){return r}t=t.return}return null}function v(e){return ge(e?.stateNode,e?.memoizedProps??e?.pendingProps??null)}function le(e,t=0){if(typeof e==="string")return e;if(typeof e==="number"&&Number.isFinite(e))return String(e);if(Array.isArray(e)&&t<4){const n=[];for(const r of e){const s=le(r,t+1);if(s)n.push(s)}return n.length>0?n.join(""):void 0}return void 0}function Ie(e){return e.replace(/\s+/g," ").trim()}function G(e){if(!e)return void 0;const t=n=>{const r=le(n);if(r===void 0)return void 0;const s=Ie(r);return s?R?s:s.slice(0,80):void 0};return t(e.children)??t(e.title)??t(e.label)??t(e.placeholder)??void 0}function Se(e,t){const n=[];const r=(i,a)=>{if(!i||a>t||n.length>=4)return;if(i!==e){const c=v(i);if(c&&(typeof c.onPress==="function"||typeof c.onLongPress==="function"))return}const o=G(v(i));if(o&&!n.includes(o))n.push(o);if(i.child)r(i.child,a+1);if(i!==e&&i.sibling)r(i.sibling,a)};if(e.child)r(e.child,1);const s=n.join(" ").trim();return s?s.slice(0,80):void 0}function Ne(e){let t=e;let n=0;let r=null;let s=null;while(t&&n<25&&!(r&&s)){const i=v(t);if(i){if(!r&&typeof i.onPress==="function")r=i.onPress;if(!s&&typeof i.onLongPress==="function")s=i.onLongPress}t=t.return;n++}if(r)return{handler:r,kind:"onPress",longPress:s??void 0};return s?{handler:s,kind:"onLongPress"}:null}function k(e){return new Promise(t=>{let n=false;const r=s=>{if(n)return;n=true;t(s)};setTimeout(()=>r(null),1e3);try{if(typeof e.measureInWindow==="function"){e.measureInWindow((s,i,a,o)=>{if(a>0&&o>0)r({x:s,y:i,width:a,height:o});else r(null)})}else if(typeof e.measure==="function"){e.measure((s,i,a,o,c,l)=>{if(a>0&&o>0&&c!=null&&l!=null){r({x:c,y:l,width:a,height:o})}else{r(null)}})}else{r(null)}}catch{r(null)}})}const De=new Set(["RCTActivityIndicatorView","AndroidProgressBar"]);function K(){const e=D();if(e.length===0)return[];const t=[];const n=new Map;const r=new Map;const s=oe();for(const i of e){N(i.current,a=>{const o=v(a);if(!o)return;const c=typeof o.onPress==="function"||typeof o.onLongPress==="function";const l=typeof o.onValueChange==="function";const f=typeof o.onChangeText==="function";const d=o.testID||void 0;const g=o.accessibilityLabel||void 0;const m=o.accessibilityRole||o.role||void 0;let p=G(o);const T=m==="button"||m==="link"||m==="menuitem"||m==="tab"||m==="switch"||m==="checkbox";const y=typeof a.type==="string"&&De.has(a.type)&&o.animating!==false;if(!c&&!l&&!f&&!d&&!g&&!p&&!T&&!y){return}let C=null;let V=null;let S=null;if(l){const Q=o.value;const me=typeof Q==="number"||typeof o.minimumValue==="number";V={handler:o.onValueChange,kind:me?"slider":"toggle",current:Q,min:typeof o.minimumValue==="number"?o.minimumValue:void 0,max:typeof o.maximumValue==="number"?o.maximumValue:void 0}}else if(f){S={handler:o.onChangeText,current:typeof o.value==="string"?o.value:void 0}}else{C=Ne(a)}const u=M(a);let h=u??"Unknown";if(!u||$.has(u)||typeof a.type==="string"){h=q(a)??u??"Unknown"}const b=j(a);if(!b&&!d)return;if(!p&&!g&&c){p=Se(a,6)}const x=b?.instance??null;const P=b?.nativeTag??null;const w=(x?n.get(x):void 0)??(P!=null?r.get(P):void 0);if(w){if(!w.press&&C)w.press=C;else if(w.press&&C?.longPress&&!w.press.longPress){w.press.longPress=C.longPress}if(!w.valueControl&&V)w.valueControl=V;if(!w.textControl&&S)w.textControl=S;if(!w.testID&&d)w.testID=d;if(!w.label&&g)w.label=g;if(!w.text&&p)w.text=p;if(x&&!n.has(x))n.set(x,w);if(P!=null&&!r.has(P))r.set(P,w);return}const E={nativeTag:P,name:h,role:m??(y?"progressbar":void 0),testID:d,label:g,text:p,instance:x,stateNode:b?.stateNode??null,fiber:a,press:C,valueControl:V,textControl:S,rect:null,buoy:s(a)};t.push(E);if(x)n.set(x,E);if(P!=null)r.set(P,E)})}return t}function _e(e,t){if(t.nativeTag!=null)return e.nativeTag===t.nativeTag;if(t.testID&&e.testID)return e.testID.toLowerCase()===t.testID.toLowerCase();return false}function J(e){const t=K();if(e.includeBuoy)return t;return t.filter(n=>!n.buoy||_e(n,e))}async function ae(e){await Promise.all(e.map(async t=>{if(t.instance)t.rect=await k(t.instance)}))}const Me=/^(FlatList|SectionList|VirtualizedSectionList|VirtualizedList|Animated\(.*\)|AnimatedComponent.*)$/;async function ke(e,t){const n=[];const r=oe();for(const i of D()){N(i.current,a=>{if(M(a)!=="VirtualizedList")return;const o=a.memoizedProps;if(!o||typeof o.getItemCount!=="function")return;if(!e&&r(a))return;let c;try{c=Number(o.getItemCount(o.data))}catch{return}if(!Number.isFinite(c)||c<=0)return;const l=[];const f=(m,p)=>{for(let T=m?.child;T;T=T.sibling){const y=M(T);if(y==="VirtualizedList")continue;if(y==="CellRenderer"){l.push(T);continue}if(p<40)f(T,p+1)}};f(a,0);let d=a;let g=q(d);for(let m=0;m<6&&g&&Me.test(g);m++){d=d._debugOwner||d.return;g=q(d)}n.push({owner:g,items:c,cells:l})})}const s=[];for(const i of n){const a=await Promise.all(i.cells.map(async c=>{const l=j(c);return l?k(l.instance):null}));const o=a.filter(t).length;if(o>0&&i.items>o)s.push({owner:i.owner,items:i.items,listed:o})}return s}export async function describeScreen(e={}){const t=_;const n=R;_=!!e.includeHidden;R=!!e.fullText;try{return await Ve(e)}finally{_=t;R=n}}async function Ve(e){B=0;const t=K();const n=B;const r=e.includeBuoy?t:t.filter(f=>!f.buoy);const s=t.length-r.length;await ae(r);const i=L.get("window");const a=Math.round(i.width)||1;const o=Math.round(i.height)||1;const c=[];for(const f of r){const d=f.rect;if(!d&&!f.testID)continue;let g;let m;if(d){const y=d.x+d.width/2;const C=d.y+d.height/2;if(C<-o*.1||C>o*1.1||y<-a*.1||y>a*1.1){continue}g={x:I(y/a),y:I(C/o)};m={x:I(d.x/a),y:I(d.y/o),width:I(d.width/a),height:I(d.height/o)}}const p=f.valueControl?f.valueControl.kind:f.textControl?"text":void 0;const T=f.valueControl?f.valueControl.current:f.textControl?.current;c.push({nativeTag:f.nativeTag,name:f.name,role:f.role,testID:f.testID,label:f.label,text:f.text,interactive:!!(f.press||f.valueControl||f.textControl),longPressable:f.press&&(f.press.kind==="onLongPress"||f.press.longPress)?true:void 0,control:p,value:T,tap:g,frame:m})}c.sort((f,d)=>{const g=f.tap?.y??2;const m=d.tap?.y??2;if(Math.abs(g-m)>.02)return g-m;return(f.tap?.x??2)-(d.tap?.x??2)});const l=await ke(!!e.includeBuoy,f=>{if(!f)return false;const d=f.x+f.width/2;return f.y<=o*1.1&&f.y+f.height>=-o*.1&&d>=-a*.1&&d<=a*1.1});return{screen:{width:a,height:o},count:c.length,elements:c,...s>0?{hiddenBuoy:s}:{},...n>0?{hiddenScreens:n}:{},...l.length?{lists:l}:{}}}function I(e){return Math.round(e*100)/100}function ce(e){return{nativeTag:e.nativeTag,testID:e.testID,label:e.label,text:e.text,name:e.name}}function X(e,t){return ee(ce(e),t)}function ue(e,t,n){if(!e||!t||!n)return void 0;return{x:(e.x+e.width/2)/t,y:(e.y+e.height/2)/n}}function fe(e){const t=e?e.x+e.width/2:0;const n=e?e.y+e.height/2:0;const r={locationX:e?e.width/2:0,locationY:e?e.height/2:0,pageX:t,pageY:n,timestamp:0,target:null,identifier:1,touches:[],changedTouches:[]};return{nativeEvent:r,persist:()=>{},preventDefault:()=>{},stopPropagation:()=>{},isDefaultPrevented:()=>false,isPropagationStopped:()=>false,target:null,currentTarget:null,type:"press",timeStamp:0}}export async function tapElement(e){const t=ie(!!e.includeHidden,()=>J(e));if(t.length===0){return{tapped:false,reason:"No React fiber roots / elements found on screen."}}const n=t.map(u=>({c:u,score:X(u,e)})).filter(u=>u.score>0).sort((u,h)=>h.score-u.score);const r=u=>!!(u.press||u.valueControl||u.textControl);if(n.length===0&&!e.includeHidden){const u=ie(true,()=>J(e)).map(h=>({c:h,score:X(h,e)})).filter(h=>h.score>0);if(u.length>0){return{tapped:false,reason:"That element is only on a screen that isn't showing (another tab, or a screen under the current one). Navigate to it first, or pass includeHidden:true if you really mean the hidden one."}}}if(n.length===0){return{tapped:false,reason:"No element matched. Call describe_screen to see available elements (match by testID, text, or name).",candidates:t.filter(r).slice(0,12).map(u=>({nativeTag:u.nativeTag,name:u.name,testID:u.testID,text:u.text}))}}const s=L.get("window");const i=s.width||1;const a=s.height||1;const o=n.slice(0,15);await Promise.all(o.map(async u=>{if(u.c.instance&&!u.c.rect)u.c.rect=await k(u.c.instance)}));for(const u of o){u.score=ee({...ce(u.c),tap:ue(u.c.rect,i,a)},e)}o.sort((u,h)=>h.score-u.score);const c=o.find(u=>r(u.c))??n.find(u=>r(u.c))??o[0];const l=c.c;const f=(u,h)=>u.press&&u.press.handler===h.press?.handler||u.valueControl&&u.valueControl.handler===h.valueControl?.handler||u.textControl&&u.textControl.handler===h.textControl?.handler;const d=o.filter(u=>u!==c&&r(u.c)&&u.score===c.score).filter(u=>!f(u.c,l)).filter((u,h,b)=>b.findIndex(x=>f(x.c,u.c))===h).slice(0,3).map(u=>({nativeTag:u.c.nativeTag,name:u.c.name,testID:u.c.testID,text:u.c.text,tap:ue(u.c.rect,i,a)}));const g=e.nativeTag==null&&!(e.testID&&!e.query);if(g&&d.length>0){const u=[l,...d.map(h=>o.find(b=>b.c.nativeTag===h.nativeTag)?.c).filter(Boolean)];return{tapped:false,reason:`"${e.query}" matches ${u.length} different controls equally well, so nothing was tapped. Tap one by its nativeTag.`,candidates:u.map(h=>({nativeTag:h.nativeTag,name:h.name,testID:h.testID,text:h.text}))}}const m=o[0];if(g&&m&&m!==c&&!r(m.c)&&m.score>=90&&c.score<m.score-40){return{tapped:false,reason:`The best match for "${e.query}" is "${m.c.text??m.c.label??m.c.name}", which has no JS press handler (it may be native, like a tab bar button). The closest pressable match, "${l.text??l.label??l.name}", is a much weaker match, so nothing was tapped. Use navigate, or tap a specific element by nativeTag.`,candidates:[{nativeTag:l.nativeTag,name:l.name,testID:l.testID,text:l.text}]}}if(!r(l)){return{tapped:false,reason:`Matched "${l.name}"${l.text?` ("${l.text}")`:""} but it has no onPress / onValueChange / onChangeText handler (e.g. a react-native-gesture-handler GestureDetector). This element can't be driven in JS.`,matched:{nativeTag:l.nativeTag,name:l.name,testID:l.testID,label:l.label,text:l.text,via:"onPress"}}}if(l.instance&&!l.rect)l.rect=await k(l.instance);let p=false;const T=l.rect==null||!z(l.rect,i,a);if(T&&e.scrollIntoView!==false&&l.instance){p=await Pe(l.fiber,l.instance,l.stateNode,80);if(p)l.rect=await k(l.instance)}const y={nativeTag:l.nativeTag,name:l.name,testID:l.testID,label:l.label,text:l.text};Te();const C=W;const V=Date.now();const S=async u=>{await new Promise(h=>setTimeout(h,be));return{tapped:true,scrolled:p,matched:u,effect:{commits:W-C,observedMs:Date.now()-V},...d.length?{alsoMatched:d}:{}}};try{if(l.press){if(e.longPress){const h=l.press.kind==="onLongPress"?l.press.handler:l.press.longPress;if(!h){return{tapped:false,scrolled:p,reason:`Matched "${l.name}"${l.text?` ("${l.text}")`:""} but it has no onLongPress handler \u2014 call tap_element without longPress to tap it normally.`,matched:{...y,via:"onPress"}}}h(fe(l.rect));return await S({...y,via:"onLongPress"})}l.press.handler(fe(l.rect));return await S({...y,via:l.press.kind})}if(l.valueControl){const h=l.valueControl;let b;if(h.kind==="toggle"){b=typeof e.value==="boolean"?e.value:!h.current}else{const x=h.min??0;const P=h.max??1;if(typeof e.value==="number"){b=Math.min(P,Math.max(x,e.value))}else{b=h.current===P?x:P}}h.handler(b);return await S({...y,via:"onValueChange",value:b})}const u=e.text??(typeof e.value==="string"?e.value:"");l.textControl.handler(u);return await S({...y,via:"onChangeText",value:u})}catch(u){return{tapped:false,scrolled:p,reason:`handler threw: ${u instanceof Error?u.message:String(u)}`,matched:{...y,via:l.press?l.press.kind:l.valueControl?"onValueChange":"onChangeText"}}}}const Ae=5e3;const Le=3e4;const Fe=50;const Re=150;export async function waitFor(e){const t=e.nativeTag!=null||!!String(e.testID??"").trim()||!!String(e.query??"").trim();if(!t){return{ok:false,waitedMs:0,polls:0,reason:"Nothing to wait for \u2014 pass nativeTag, testID or query."}}const n=Math.min(Math.max(e.timeoutMs??Ae,0),Le);const r=Math.max(e.pollMs??Re,Fe);const s=e.gone===true;const i=Date.now();let a=0;for(;;){a+=1;const{hit:o,closest:c}=await Ee(e);if(s?!o:!!o){return{ok:true,waitedMs:Date.now()-i,polls:a,matched:o??void 0}}if(Date.now()-i>=n){const l=c?.length?c:void 0;const f=s?`Still on screen after ${n}ms.`:l?`Not on screen after ${n}ms \u2014 ${l.length===1?"one element":`${l.length} elements`} matched but ${l.some(d=>d.onScreen)?"not well enough":"none is visible"}. See \`closest\`; do not retry with different words, call describeScreen.`:`Not on screen after ${n}ms, and nothing matched those words at all. Call describeScreen to see what is there.`;return{ok:false,waitedMs:Date.now()-i,polls:a,reason:f,matched:o??void 0,closest:l}}await new Promise(l=>setTimeout(l,r))}}async function Ee(e){const t=J(e).map(o=>({c:o,score:X(o,e)})).filter(o=>o.score>0).sort((o,c)=>c.score-o.score).slice(0,8);if(t.length===0)return{hit:null,closest:void 0};await ae(t.map(o=>o.c));const n=L.get("window");const r=Math.round(n.width)||1;const s=Math.round(n.height)||1;let i=null;for(const{c:o}of t){if(!z(o.rect,r,s))continue;i={nativeTag:o.nativeTag,name:o.name,testID:o.testID,label:o.label,text:o.text,interactive:!!(o.press||o.valueControl||o.textControl)};break}const a=t.slice(0,3).map(({c:o})=>({name:o.name,testID:o.testID,text:o.text,onScreen:z(o.rect,r,s)}));return{hit:i,closest:a}}function Y(e){let t=e;let n=0;while(t&&n<400){if(v(t)?.__buoyDevToolsRoot)return true;t=t.return;n++}return false}function He(e,t){const n=v(e.fiber);if(typeof n?.onPress==="function"||typeof n?.onValueChange==="function"||typeof n?.onChangeText==="function"){return e}let r=null;let s=e.fiber?.return;let i=0;while(s&&i<25){if(typeof v(s)?.onPress==="function"){r=s;break}s=s.return;i++}if(!r)return e;let a=r;for(let o=0;o<6&&a;o++){const c=t.get(a);if(c)return c;a=a.return}return e}export function resolveTouchTarget(e){const t=K();if(t.length===0)return null;const n=new Map;for(const o of t)n.set(o.fiber,o);const r=t.find(o=>o.nativeTag===e);let s=null;if(!r){for(const o of D()){N(o.current,c=>{if(s)return;if(c.stateNode&&A(c.stateNode)===e){s=c}});if(s)break}}let i=r??null;if(!i&&s){let o=s;let c=0;let l=null;while(o&&c<25){const f=n.get(o);if(f){if(f.press||f.valueControl||f.textControl){i=f;break}if(!l)l=f}o=o.return;c++}if(!i)i=l}if(!i)return null;i=He(i,n);if(!i.press&&!i.valueControl&&!i.textControl)return null;if(Y(i.fiber))return null;const a=i.valueControl?i.valueControl.kind:i.textControl?"text":"press";return{nativeTag:i.nativeTag,name:i.name,role:i.role,testID:i.testID,label:i.label,text:i.text,control:a,value:i.valueControl?i.valueControl.current:i.textControl?i.textControl.current:void 0}}function Oe(e){let t=null;for(const n of D()){N(n.current,r=>{if(!t&&r.stateNode&&A(r.stateNode)===e)t=r});if(t)break}return t}function de(){const e=[];for(const t of D()){let n=t.current?.child;let r=0;while(n&&r++<200){if(n.tag===F&&n.stateNode){e.push(n);break}n=n.child}}return e}function ze(e,t){const n=global.nativeFabricUIManager;if(!n||typeof n.findNodeAtPoint!=="function")return null;const r=de().filter(s=>s.stateNode?.node);if(!r.length)return null;return new Promise(s=>{const i=setTimeout(()=>s(null),1e3);let a=r.length;let o=null;r.forEach((c,l)=>{try{n.findNodeAtPoint(c.stateNode.node,e,t,f=>{if(f&&(!o||l>=o.i))o={i:l,fiber:f};if(--a===0){clearTimeout(i);s(o?.fiber??null)}})}catch{if(--a===0){clearTimeout(i);s(o?.fiber??null)}}})})}function $e(e,t){const n=H?.findSubviewIn;if(typeof n!=="function")return null;const r=de()[0];const s=r?A(r.stateNode)??O(r.stateNode):null;if(s==null)return null;return new Promise(i=>{const a=setTimeout(()=>i(null),1e3);try{n.call(H,s,[e,t],o=>{clearTimeout(a);i(typeof o==="number"?Oe(o):null)})}catch{clearTimeout(a);i(null)}})}function We(){const e=[];const t=new Set;const n=s=>{const i=[];const a=(o,c)=>{for(let l=o;l&&i.length<5e3;l=l.sibling){if(t.has(l)||c>500)continue;if(re(l)||se(l))continue;if(l.tag===F&&l.stateNode)i.push(l);else if(l.child)a(l.child,c+1)}};if(s.child)a(s.child,0);return i};const r=(s,i)=>{if(t.has(s)||i>500)return;t.add(s);e.push(s);he(n(s)).forEach(a=>r(a,i+1))};for(const s of D())he(n(s.current)).forEach(i=>r(i,0));return e}function he(e){const t=e.map(n=>{const r=Number(Z(v(n)?.style).zIndex);return Number.isFinite(r)?r:0});return e.map((n,r)=>({h:n,i:r})).sort((n,r)=>t[n.i]-t[r.i]||n.i-r.i).map(({h:n})=>n)}function Z(e,t=0){if(!e||typeof e!=="object"||t>10)return{};if(Array.isArray(e))return Object.assign({},...e.map(n=>Z(n,t+1)));return e}const Be=new Set(["RCTScrollView","AndroidHorizontalScrollView","RCTScrollContentView"]);function Ue(e){if(typeof e.type==="string"&&Be.has(e.type)&&e.type!=="RCTScrollContentView")return true;const t=Z(v(e)?.style).overflow;return t==="hidden"||t==="scroll"}function je(e){let t=v(e)?.pointerEvents??v(e)?.style?.pointerEvents;if(t==="none")return"all";let n=e.return;let r=0;while(n&&r++<200){const s=v(n)?.pointerEvents??v(n)?.style?.pointerEvents;if(s==="none")return"all";if(s==="box-only"&&n.tag===F)return"all";n=n.return}return t==="box-none"?"self":null}async function qe(e,t,n){const r=await Promise.all(n.map(o=>{const c=U(o.stateNode);return c?k(c):Promise.resolve(null)}));const s=new Map;n.forEach((o,c)=>s.set(o,r[c]));const i=o=>!!o&&e>=o.x&&e<=o.x+o.width&&t>=o.y&&t<=o.y+o.height;const a=o=>{for(let c=o.return,l=0;c&&l<300;c=c.return,l++){if(c.tag===F&&s.has(c)&&Ue(c)&&!i(s.get(c)))return true}return false};for(let o=n.length-1;o>=0;o--){if(!i(r[o])||je(n[o])||a(n[o]))continue;return n[o]}return null}function Ge(e,t){const n=global.document;const r=global.window;if(!n?.elementFromPoint||!r)return null;let s=n.elementFromPoint(e*r.innerWidth,t*r.innerHeight);while(s){const i=Object.keys(s).find(a=>a.startsWith("__reactFiber$"));if(i)return s[i];s=s.parentElement}return null}export async function hitTest(e){const t=Math.min(1,Math.max(0,Number(e?.x)));const n=Math.min(1,Math.max(0,Number(e?.y)));if(!Number.isFinite(t)||!Number.isFinite(n))return{found:false,method:"none",reason:"x and y must be numbers from 0 to 1."};const r=L.get("window");const s=t*r.width;const i=n*r.height;let a="none";let o=null;const c=Ge(t,n);if(c){a="dom";o=c}else{const p=ze(s,i);if(p){a="fabric";o=await p}else{const y=$e(s,i);if(y){a="paper";o=await y}}const T=We();if(!o||!new Set(T).has(o)){o=await qe(s,i,T);a="measured"}}if(!o)return{found:false,method:a};const l=v(o)??{};const f=A(o.stateNode);const d=[];let g=o;let m=0;while(g&&m++<80&&d.length<6){const p=M(g);if(p&&typeof g.type!=="string"&&!$.has(p)&&d[d.length-1]!==p)d.push(p);g=g.return}return{found:true,method:a,buoy:Y(o),view:{name:M(o)??"Unknown",nativeTag:f,testID:l.testID||void 0,label:l.accessibilityLabel||l["aria-label"]||void 0,text:G(l)},path:d,target:f!=null?resolveTouchTarget(f):null}}export async function readMaps(){const e=[];for(const s of D()){N(s.current,i=>{const a=i.stateNode;if(i.tag===1&&a&&typeof a.getCamera==="function"&&!Y(i))e.push(i)})}const t=L.get("window");const n=s=>Promise.race([s,new Promise(i=>setTimeout(()=>i(null),1e3))]);const r=await Promise.all(e.slice(0,5).map(async s=>{try{const i=await n(Promise.resolve(s.stateNode.getCamera()));if(!i)return null;const a=j(s);const o=a?await k(a.instance):null;const c=v(s)??{};return{name:M(s)??"Map",testID:typeof c.testID==="string"?c.testID:void 0,frame:o&&t.width&&t.height?{x:I(o.x/t.width),y:I(o.y/t.height),width:I(o.width/t.width),height:I(o.height/t.height)}:void 0,camera:{heading:typeof i.heading==="number"?i.heading:void 0,pitch:typeof i.pitch==="number"?i.pitch:void 0,altitude:typeof i.altitude==="number"?i.altitude:void 0,zoom:typeof i.zoom==="number"?i.zoom:void 0,center:i.center}}}catch{return null}}));return{maps:r.filter(s=>!!s)}}
1
+ "use strict";import{getDOMControlProps as be,getDOMNodeHandle as O,getDOMPublicInstance as ne,isDOMElement as oe}from"@buoy-gg/shared-ui/utils";import{Dimensions as F,UIManager as H,findNodeHandle as z}from"react-native";import{isRectCenterOnScreen as $,scoreTapMatch as re}from"./tapMatch";import{collectDOMElements as Te,domElementName as W,watchDOMChanges as xe}from"./domScreenElements";const E=5;const Ce=22;const B=new Set(["View","RCTView","ScrollView","RCTScrollView","RCTScrollContentView","SafeAreaView","RCTSafeAreaView","AndroidHorizontalScrollContentView","KeyboardAvoidingView","Pressable","PlatformPressable","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","TouchableNativeFeedback","AnimatedComponent","Wrapper"]);function ie(){if(typeof global==="undefined")return null;return global.__REACT_DEVTOOLS_GLOBAL_HOOK__??null}let U=0;let le=false;function Pe(){if(le)return;const e=ie();if(!e)return;const t=e.onCommitFiberRoot;e.onCommitFiberRoot=function(...n){U++;return typeof t==="function"?t.apply(e,n):void 0};le=true}const Ie=250;function se(){const e=new Map;return t=>{const n=[];let r=t;let i=0;let l=false;while(r&&i<400){const a=e.get(r);if(a!==void 0){l=a;break}if(T(r)?.__buoyDevToolsRoot){l=true;e.set(r,true);break}n.push(r);r=r.return;i++}for(const a of n)e.set(a,l);return l}}function N(){const e=ie();if(!e)return[];const t=[];try{if(e.renderers&&typeof e.renderers.forEach==="function"){e.renderers.forEach((n,r)=>{try{const i=e.getFiberRoots?.(r);if(i)i.forEach(l=>t.push(l))}catch{}})}if(t.length===0&&e.getFiberRoots){const n=e.getFiberRoots(1);if(n)n.forEach(r=>t.push(r))}}catch{}return t}function ae(e){return e.tag===Ce&&e.memoizedState!==null}let _=false;let j=0;let A=false;function ue(e,t){const n=_;_=e;try{return t()}finally{_=n}}function Se(e){const t=e.memoizedProps;if(!t)return false;if(t["aria-hidden"]===true&&(t.activityState!==void 0||"shouldFreeze"in t))return true;if(t.isFocused===false&&(t.routeKey!==void 0||"freezeContents"in t))return true;return false}function ce(e){const t=e.memoizedProps?.activityState;if(t===0||t===1)return true;if(e.memoizedProps?.isPageFocused===false)return true;if(!_&&Se(e)){j++;return true}return false}function D(e,t,n=0,r=new Set){if(!e||r.has(e)||n>500)return;r.add(e);if(ae(e)||ce(e)){if(e.sibling)D(e.sibling,t,n,r);return}t(e);if(e.child)D(e.child,t,n+1,r);if(e.sibling)D(e.sibling,t,n,r)}function q(e){const t=ne(e);if(t)return t;if(!e)return null;const n=e;if(n.canonical?.publicInstance)return n.canonical.publicInstance;if(n.canonical&&typeof n.canonical.measure==="function"){return n.canonical}if(typeof n.measure==="function"||typeof n.measureInWindow==="function"){return n}return null}function L(e){const t=O(e);if(t!==null)return t;if(e==null)return null;const n=e;if(typeof n.__nativeTag==="number")return n.__nativeTag;if(typeof n._nativeTag==="number")return n._nativeTag;if(typeof n.nativeTag==="number")return n.nativeTag;if(n.canonical){if(typeof n.canonical.__nativeTag==="number")return n.canonical.__nativeTag;if(typeof n.canonical._nativeTag==="number")return n.canonical._nativeTag;if(typeof n.canonical.nativeTag==="number")return n.canonical.nativeTag}return null}function G(e){const t=q(e.stateNode);if(t){return{instance:t,nativeTag:L(e.stateNode),stateNode:e.stateNode}}const n=[];if(e.child)n.push(e.child);let r=0;while(n.length>0&&r<4e3){r++;const i=n.pop();if(!i)continue;const l=q(i.stateNode);if(l)return{instance:l,nativeTag:L(i.stateNode),stateNode:i.stateNode};if(i.child)n.push(i.child);if(i.sibling)n.push(i.sibling)}return null}function De(e){let t=e;let n=0;while(t&&n++<200){const r=t.stateNode;if(r&&typeof r.scrollTo==="function"){const i=typeof r.getNativeScrollRef==="function"&&r.getNativeScrollRef()||null;const l=typeof r.getInnerViewNode==="function"&&r.getInnerViewNode()||typeof r.getScrollableNode==="function"&&r.getScrollableNode()||r;return{instance:r,nativeRef:i,innerNode:l}}t=t.return}return null}async function Ne(e,t,n,r){try{if(oe(n)){n.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"});await new Promise(u=>setTimeout(u,16));return true}const i=De(e);if(!i)return false;const l=t;let a=null;const o=u=>new Promise(s=>{let c=false;const d=m=>{if(c)return;c=true;s(m)};const g=setTimeout(()=>d(null),600);try{u(m=>{clearTimeout(g);d(m)})}catch{clearTimeout(g);d(null)}});if(i.nativeRef&&typeof l.measureLayout==="function"){a=await o(u=>l.measureLayout(i.nativeRef,(s,c)=>u(c),()=>u(null)))}if(a==null){const u=z(t);const s=typeof i.innerNode==="number"?i.innerNode:z(i.innerNode);if(u!=null&&s!=null){a=await o(c=>H.measureLayout(u,s,()=>c(null),(d,g)=>c(g)))}}if(a==null)return false;i.instance.scrollTo({y:Math.max(0,a-r),animated:false});await new Promise(u=>setTimeout(u,120));return true}catch{return false}}function M(e){const t=e?.type;if(!t)return null;if(typeof t==="string")return t;return t.displayName||t.name||null}function K(e){let t=e?._debugOwner||e?.return;let n=0;while(t&&n<30){n++;const r=M(t);if(r&&!B.has(r)&&typeof t.type!=="string"){return r}t=t.return}return null}function T(e){return be(e?.stateNode,e?.memoizedProps??e?.pendingProps??null)}function fe(e,t=0){if(typeof e==="string")return e;if(typeof e==="number"&&Number.isFinite(e))return String(e);if(Array.isArray(e)&&t<4){const n=[];for(const r of e){const i=fe(r,t+1);if(i)n.push(i)}return n.length>0?n.join(""):void 0}return void 0}function _e(e){return e.replace(/\s+/g," ").trim()}function J(e){if(!e)return void 0;const t=n=>{const r=fe(n);if(r===void 0)return void 0;const i=_e(r);return i?A?i:i.slice(0,80):void 0};return t(e.children)??t(e.title)??t(e.label)??t(e.placeholder)??void 0}function Me(e,t){const n=[];const r=(l,a)=>{if(!l||a>t||n.length>=4)return;if(l!==e){const u=T(l);if(u&&(typeof u.onPress==="function"||typeof u.onLongPress==="function"))return}const o=J(T(l));if(o&&!n.includes(o))n.push(o);if(l.child)r(l.child,a+1);if(l!==e&&l.sibling)r(l.sibling,a)};if(e.child)r(e.child,1);const i=n.join(" ").trim();return i?i.slice(0,80):void 0}function ke(e){let t=e;let n=0;let r=null;let i=null;while(t&&n<25&&!(r&&i)){const l=T(t);if(l){if(!r&&typeof l.onPress==="function")r=l.onPress;if(!i&&typeof l.onLongPress==="function")i=l.onLongPress}t=t.return;n++}if(r)return{handler:r,kind:"onPress",longPress:i??void 0};return i?{handler:i,kind:"onLongPress"}:null}function k(e){return new Promise(t=>{let n=false;const r=i=>{if(n)return;n=true;t(i)};setTimeout(()=>r(null),1e3);try{if(typeof e.measureInWindow==="function"){e.measureInWindow((i,l,a,o)=>{if(a>0&&o>0)r({x:i,y:l,width:a,height:o});else r(null)})}else if(typeof e.measure==="function"){e.measure((i,l,a,o,u,s)=>{if(a>0&&o>0&&u!=null&&s!=null){r({x:u,y:s,width:a,height:o})}else{r(null)}})}else{r(null)}}catch{r(null)}})}const Ve=new Set(["RCTActivityIndicatorView","AndroidProgressBar"]);function X(){const e=N();const t=[];const n=new Map;const r=new Map;const i=se();for(const l of e){D(l.current,a=>{const o=T(a);if(!o)return;const u=typeof o.onPress==="function"||typeof o.onLongPress==="function";const s=typeof o.onValueChange==="function";const c=typeof o.onChangeText==="function";const d=o.testID||void 0;const g=o.accessibilityLabel||void 0;const m=o.accessibilityRole||o.role||void 0;let w=J(o);const y=m==="button"||m==="link"||m==="menuitem"||m==="tab"||m==="switch"||m==="checkbox";const v=typeof a.type==="string"&&Ve.has(a.type)&&o.animating!==false;if(!u&&!s&&!c&&!d&&!g&&!w&&!y&&!v){return}let x=null;let S=null;let V=null;if(s){const te=o.value;const ve=typeof te==="number"||typeof o.minimumValue==="number";S={handler:o.onValueChange,kind:ve?"slider":"toggle",current:te,min:typeof o.minimumValue==="number"?o.minimumValue:void 0,max:typeof o.maximumValue==="number"?o.maximumValue:void 0}}else if(c){V={handler:o.onChangeText,current:typeof o.value==="string"?o.value:void 0}}else{x=ke(a)}const I=M(a);let f=I??"Unknown";if(!I||B.has(I)||typeof a.type==="string"){f=K(a)??I??"Unknown"}const h=G(a);if(!h&&!d)return;if(!w&&!g&&u){w=Me(a,6)}const b=h?.instance??null;const C=h?.nativeTag??null;const p=(b?n.get(b):void 0)??(C!=null?r.get(C):void 0);if(p){if(!p.press&&x)p.press=x;else if(p.press&&x?.longPress&&!p.press.longPress){p.press.longPress=x.longPress}if(!p.valueControl&&S)p.valueControl=S;if(!p.textControl&&V)p.textControl=V;if(!p.testID&&d)p.testID=d;if(!p.label&&g)p.label=g;if(!p.text&&w)p.text=w;if(b&&!n.has(b))n.set(b,p);if(C!=null&&!r.has(C))r.set(C,p);return}const R={nativeTag:C,name:f,role:m??(v?"progressbar":void 0),testID:d,label:g,text:w,instance:b,stateNode:h?.stateNode??null,fiber:a,press:x,valueControl:S,textControl:V,rect:null,buoy:i(a)};t.push(R);if(b)n.set(b,R);if(C!=null)r.set(C,R)})}t.push(...de());return t}function de(){return Te({fullText:A}).map(({element:e,props:t,text:n,buoy:r})=>{const i=typeof t.onValueChange==="function"?{handler:t.onValueChange,kind:typeof t.value==="number"?"slider":"toggle",current:t.value,min:t.minimumValue,max:t.maximumValue}:null;const l=!i&&typeof t.onChangeText==="function"?{handler:t.onChangeText,current:t.value}:null;const a=!i&&!l&&typeof t.onPress==="function"?{handler:t.onPress,kind:"onPress"}:null;return{nativeTag:O(e),name:W(e),role:t.accessibilityRole,testID:t.testID,label:t.accessibilityLabel,text:n,instance:ne(e),stateNode:e,fiber:null,buoy:r,press:a,valueControl:i,textControl:l,rect:null}})}function Le(e,t){if(t.nativeTag!=null)return e.nativeTag===t.nativeTag;if(t.testID&&e.testID)return e.testID.toLowerCase()===t.testID.toLowerCase();return false}function Y(e){const t=X();if(e.includeBuoy)return t;return t.filter(n=>!n.buoy||Le(n,e))}async function he(e){await Promise.all(e.map(async t=>{if(t.instance)t.rect=await k(t.instance)}))}const Fe=/^(FlatList|SectionList|VirtualizedSectionList|VirtualizedList|Animated\(.*\)|AnimatedComponent.*)$/;async function Ae(e,t){const n=[];const r=se();for(const l of N()){D(l.current,a=>{if(M(a)!=="VirtualizedList")return;const o=a.memoizedProps;if(!o||typeof o.getItemCount!=="function")return;if(!e&&r(a))return;let u;try{u=Number(o.getItemCount(o.data))}catch{return}if(!Number.isFinite(u)||u<=0)return;const s=[];const c=(m,w)=>{for(let y=m?.child;y;y=y.sibling){const v=M(y);if(v==="VirtualizedList")continue;if(v==="CellRenderer"){s.push(y);continue}if(w<40)c(y,w+1)}};c(a,0);let d=a;let g=K(d);for(let m=0;m<6&&g&&Fe.test(g);m++){d=d._debugOwner||d.return;g=K(d)}n.push({owner:g,items:u,cells:s})})}const i=[];for(const l of n){const a=await Promise.all(l.cells.map(async u=>{const s=G(u);return s?k(s.instance):null}));const o=a.filter(t).length;if(o>0&&l.items>o)i.push({owner:l.owner,items:l.items,listed:o})}return i}export async function describeScreen(e={}){const t=_;const n=A;_=!!e.includeHidden;A=!!e.fullText;try{return await Ee(e)}finally{_=t;A=n}}async function Ee(e){j=0;const t=X();const n=j;const r=e.includeBuoy?t:t.filter(c=>!c.buoy);const i=t.length-r.length;await he(r);const l=F.get("window");const a=Math.round(l.width)||1;const o=Math.round(l.height)||1;const u=[];for(const c of r){const d=c.rect;if(!d&&!c.testID)continue;let g;let m;if(d){const v=d.x+d.width/2;const x=d.y+d.height/2;if(x<-o*.1||x>o*1.1||v<-a*.1||v>a*1.1){continue}g={x:P(v/a),y:P(x/o)};m={x:P(d.x/a),y:P(d.y/o),width:P(d.width/a),height:P(d.height/o)}}const w=c.valueControl?c.valueControl.kind:c.textControl?"text":void 0;const y=c.valueControl?c.valueControl.current:c.textControl?.current;u.push({nativeTag:c.nativeTag,name:c.name,role:c.role,testID:c.testID,label:c.label,text:c.text,interactive:!!(c.press||c.valueControl||c.textControl),longPressable:c.press&&(c.press.kind==="onLongPress"||c.press.longPress)?true:void 0,control:w,value:y,tap:g,frame:m})}u.sort((c,d)=>{const g=c.tap?.y??2;const m=d.tap?.y??2;if(Math.abs(g-m)>.02)return g-m;return(c.tap?.x??2)-(d.tap?.x??2)});const s=await Ae(!!e.includeBuoy,c=>{if(!c)return false;const d=c.x+c.width/2;return c.y<=o*1.1&&c.y+c.height>=-o*.1&&d>=-a*.1&&d<=a*1.1});return{screen:{width:a,height:o},count:u.length,elements:u,...i>0?{hiddenBuoy:i}:{},...n>0?{hiddenScreens:n}:{},...s.length?{lists:s}:{}}}function P(e){return Math.round(e*100)/100}function me(e){return{nativeTag:e.nativeTag,testID:e.testID,label:e.label,text:e.text,name:e.name}}function Z(e,t){return re(me(e),t)}function ge(e,t,n){if(!e||!t||!n)return void 0;return{x:(e.x+e.width/2)/t,y:(e.y+e.height/2)/n}}function pe(e){const t=e?e.x+e.width/2:0;const n=e?e.y+e.height/2:0;const r={locationX:e?e.width/2:0,locationY:e?e.height/2:0,pageX:t,pageY:n,timestamp:0,target:null,identifier:1,touches:[],changedTouches:[]};return{nativeEvent:r,persist:()=>{},preventDefault:()=>{},stopPropagation:()=>{},isDefaultPrevented:()=>false,isPropagationStopped:()=>false,target:null,currentTarget:null,type:"press",timeStamp:0}}export async function tapElement(e){const t=ue(!!e.includeHidden,()=>Y(e));if(t.length===0){return{tapped:false,reason:"Nothing on screen to tap: no React elements and no page elements were found."}}const n=t.map(f=>({c:f,score:Z(f,e)})).filter(f=>f.score>0).sort((f,h)=>h.score-f.score);const r=f=>!!(f.press||f.valueControl||f.textControl);if(n.length===0&&!e.includeHidden){const f=ue(true,()=>Y(e)).map(h=>({c:h,score:Z(h,e)})).filter(h=>h.score>0);if(f.length>0){return{tapped:false,reason:"That element is only on a screen that isn't showing (another tab, or a screen under the current one). Navigate to it first, or pass includeHidden:true if you really mean the hidden one."}}}if(n.length===0){return{tapped:false,reason:"No element matched. Call describe_screen to see available elements (match by testID, text, or name).",candidates:t.filter(r).slice(0,12).map(f=>({nativeTag:f.nativeTag,name:f.name,testID:f.testID,text:f.text}))}}const i=F.get("window");const l=i.width||1;const a=i.height||1;const o=n.slice(0,15);await Promise.all(o.map(async f=>{if(f.c.instance&&!f.c.rect)f.c.rect=await k(f.c.instance)}));for(const f of o){f.score=re({...me(f.c),tap:ge(f.c.rect,l,a)},e)}o.sort((f,h)=>h.score-f.score);const u=o.find(f=>r(f.c))??n.find(f=>r(f.c))??o[0];const s=u.c;const c=(f,h)=>f.press&&f.press.handler===h.press?.handler||f.valueControl&&f.valueControl.handler===h.valueControl?.handler||f.textControl&&f.textControl.handler===h.textControl?.handler;const d=o.filter(f=>f!==u&&r(f.c)&&f.score===u.score).filter(f=>!c(f.c,s)).filter((f,h,b)=>b.findIndex(C=>c(C.c,f.c))===h).slice(0,3).map(f=>({nativeTag:f.c.nativeTag,name:f.c.name,testID:f.c.testID,text:f.c.text,tap:ge(f.c.rect,l,a)}));const g=e.nativeTag==null&&!(e.testID&&!e.query);if(g&&d.length>0){const f=[s,...d.map(h=>o.find(b=>b.c.nativeTag===h.nativeTag)?.c).filter(Boolean)];return{tapped:false,reason:`"${e.query}" matches ${f.length} different controls equally well, so nothing was tapped. Tap one by its nativeTag.`,candidates:f.map(h=>({nativeTag:h.nativeTag,name:h.name,testID:h.testID,text:h.text}))}}const m=o[0];if(g&&m&&m!==u&&!r(m.c)&&m.score>=90&&u.score<m.score-40){return{tapped:false,reason:`The best match for "${e.query}" is "${m.c.text??m.c.label??m.c.name}", which has no JS press handler (it may be native, like a tab bar button). The closest pressable match, "${s.text??s.label??s.name}", is a much weaker match, so nothing was tapped. Use navigate, or tap a specific element by nativeTag.`,candidates:[{nativeTag:s.nativeTag,name:s.name,testID:s.testID,text:s.text}]}}if(!r(s)){return{tapped:false,reason:`Matched "${s.name}"${s.text?` ("${s.text}")`:""} but it has no onPress / onValueChange / onChangeText handler (e.g. a react-native-gesture-handler GestureDetector). This element can't be driven in JS.`,matched:{nativeTag:s.nativeTag,name:s.name,testID:s.testID,label:s.label,text:s.text,via:"onPress"}}}if(s.instance&&!s.rect)s.rect=await k(s.instance);let w=false;const y=s.rect==null||!$(s.rect,l,a);if(y&&e.scrollIntoView!==false&&s.instance){w=await Ne(s.fiber,s.instance,s.stateNode,80);if(w)s.rect=await k(s.instance)}const v={nativeTag:s.nativeTag,name:s.name,testID:s.testID,label:s.label,text:s.text};Pe();const x=U;const S=s.fiber===null&&oe(s.stateNode)?xe():null;const V=Date.now();const I=async f=>{await new Promise(h=>setTimeout(h,Ie));return{tapped:true,scrolled:w,matched:f,effect:{commits:S?S():U-x,observedMs:Date.now()-V},...d.length?{alsoMatched:d}:{}}};try{if(s.press){if(e.longPress){const h=s.press.kind==="onLongPress"?s.press.handler:s.press.longPress;if(!h){return{tapped:false,scrolled:w,reason:`Matched "${s.name}"${s.text?` ("${s.text}")`:""} but it has no onLongPress handler \u2014 call tap_element without longPress to tap it normally.`,matched:{...v,via:"onPress"}}}h(pe(s.rect));return await I({...v,via:"onLongPress"})}s.press.handler(pe(s.rect));return await I({...v,via:s.press.kind})}if(s.valueControl){const h=s.valueControl;let b;if(h.kind==="toggle"){b=typeof e.value==="boolean"?e.value:!h.current}else{const C=h.min??0;const p=h.max??1;if(typeof e.value==="number"){b=Math.min(p,Math.max(C,e.value))}else{b=h.current===p?C:p}}h.handler(b);return await I({...v,via:"onValueChange",value:b})}const f=e.text??(typeof e.value==="string"?e.value:"");s.textControl.handler(f);return await I({...v,via:"onChangeText",value:f})}catch(f){S?.();return{tapped:false,scrolled:w,reason:`handler threw: ${f instanceof Error?f.message:String(f)}`,matched:{...v,via:s.press?s.press.kind:s.valueControl?"onValueChange":"onChangeText"}}}}const Re=5e3;const Oe=3e4;const He=50;const ze=150;export async function waitFor(e){const t=e.nativeTag!=null||!!String(e.testID??"").trim()||!!String(e.query??"").trim();if(!t){return{ok:false,waitedMs:0,polls:0,reason:"Nothing to wait for \u2014 pass nativeTag, testID or query."}}const n=Math.min(Math.max(e.timeoutMs??Re,0),Oe);const r=Math.max(e.pollMs??ze,He);const i=e.gone===true;const l=Date.now();let a=0;for(;;){a+=1;const{hit:o,closest:u}=await $e(e);if(i?!o:!!o){return{ok:true,waitedMs:Date.now()-l,polls:a,matched:o??void 0}}if(Date.now()-l>=n){const s=u?.length?u:void 0;const c=i?`Still on screen after ${n}ms.`:s?`Not on screen after ${n}ms \u2014 ${s.length===1?"one element":`${s.length} elements`} matched but ${s.some(d=>d.onScreen)?"not well enough":"none is visible"}. See \`closest\`; do not retry with different words, call describeScreen.`:`Not on screen after ${n}ms, and nothing matched those words at all. Call describeScreen to see what is there.`;return{ok:false,waitedMs:Date.now()-l,polls:a,reason:c,matched:o??void 0,closest:s}}await new Promise(s=>setTimeout(s,r))}}async function $e(e){const t=Y(e).map(o=>({c:o,score:Z(o,e)})).filter(o=>o.score>0).sort((o,u)=>u.score-o.score).slice(0,8);if(t.length===0)return{hit:null,closest:void 0};await he(t.map(o=>o.c));const n=F.get("window");const r=Math.round(n.width)||1;const i=Math.round(n.height)||1;let l=null;for(const{c:o}of t){if(!$(o.rect,r,i))continue;l={nativeTag:o.nativeTag,name:o.name,testID:o.testID,label:o.label,text:o.text,interactive:!!(o.press||o.valueControl||o.textControl)};break}const a=t.slice(0,3).map(({c:o})=>({name:o.name,testID:o.testID,text:o.text,onScreen:$(o.rect,r,i)}));return{hit:l,closest:a}}function Q(e){let t=e;let n=0;while(t&&n<400){if(T(t)?.__buoyDevToolsRoot)return true;t=t.return;n++}return false}function We(e,t){const n=T(e.fiber);if(typeof n?.onPress==="function"||typeof n?.onValueChange==="function"||typeof n?.onChangeText==="function"){return e}let r=null;let i=e.fiber?.return;let l=0;while(i&&l<25){if(typeof T(i)?.onPress==="function"){r=i;break}i=i.return;l++}if(!r)return e;let a=r;for(let o=0;o<6&&a;o++){const u=t.get(a);if(u)return u;a=a.return}return e}export function resolveTouchTarget(e){const t=X();if(t.length===0)return null;const n=new Map;for(const o of t)n.set(o.fiber,o);const r=t.find(o=>o.nativeTag===e);let i=null;if(!r){for(const o of N()){D(o.current,u=>{if(i)return;if(u.stateNode&&L(u.stateNode)===e){i=u}});if(i)break}}let l=r??null;if(!l&&i){let o=i;let u=0;let s=null;while(o&&u<25){const c=n.get(o);if(c){if(c.press||c.valueControl||c.textControl){l=c;break}if(!s)s=c}o=o.return;u++}if(!l)l=s}if(!l)return null;l=We(l,n);if(!l.press&&!l.valueControl&&!l.textControl)return null;if(Q(l.fiber))return null;const a=l.valueControl?l.valueControl.kind:l.textControl?"text":"press";return{nativeTag:l.nativeTag,name:l.name,role:l.role,testID:l.testID,label:l.label,text:l.text,control:a,value:l.valueControl?l.valueControl.current:l.textControl?l.textControl.current:void 0}}function Be(e){let t=null;for(const n of N()){D(n.current,r=>{if(!t&&r.stateNode&&L(r.stateNode)===e)t=r});if(t)break}return t}function ye(){const e=[];for(const t of N()){let n=t.current?.child;let r=0;while(n&&r++<200){if(n.tag===E&&n.stateNode){e.push(n);break}n=n.child}}return e}function Ue(e,t){const n=global.nativeFabricUIManager;if(!n||typeof n.findNodeAtPoint!=="function")return null;const r=ye().filter(i=>i.stateNode?.node);if(!r.length)return null;return new Promise(i=>{const l=setTimeout(()=>i(null),1e3);let a=r.length;let o=null;r.forEach((u,s)=>{try{n.findNodeAtPoint(u.stateNode.node,e,t,c=>{if(c&&(!o||s>=o.i))o={i:s,fiber:c};if(--a===0){clearTimeout(l);i(o?.fiber??null)}})}catch{if(--a===0){clearTimeout(l);i(o?.fiber??null)}}})})}function je(e,t){const n=H?.findSubviewIn;if(typeof n!=="function")return null;const r=ye()[0];const i=r?L(r.stateNode)??z(r.stateNode):null;if(i==null)return null;return new Promise(l=>{const a=setTimeout(()=>l(null),1e3);try{n.call(H,i,[e,t],o=>{clearTimeout(a);l(typeof o==="number"?Be(o):null)})}catch{clearTimeout(a);l(null)}})}function qe(){const e=[];const t=new Set;const n=i=>{const l=[];const a=(o,u)=>{for(let s=o;s&&l.length<5e3;s=s.sibling){if(t.has(s)||u>500)continue;if(ae(s)||ce(s))continue;if(s.tag===E&&s.stateNode)l.push(s);else if(s.child)a(s.child,u+1)}};if(i.child)a(i.child,0);return l};const r=(i,l)=>{if(t.has(i)||l>500)return;t.add(i);e.push(i);we(n(i)).forEach(a=>r(a,l+1))};for(const i of N())we(n(i.current)).forEach(l=>r(l,0));return e}function we(e){const t=e.map(n=>{const r=Number(ee(T(n)?.style).zIndex);return Number.isFinite(r)?r:0});return e.map((n,r)=>({h:n,i:r})).sort((n,r)=>t[n.i]-t[r.i]||n.i-r.i).map(({h:n})=>n)}function ee(e,t=0){if(!e||typeof e!=="object"||t>10)return{};if(Array.isArray(e))return Object.assign({},...e.map(n=>ee(n,t+1)));return e}const Ge=new Set(["RCTScrollView","AndroidHorizontalScrollView","RCTScrollContentView"]);function Ke(e){if(typeof e.type==="string"&&Ge.has(e.type)&&e.type!=="RCTScrollContentView")return true;const t=ee(T(e)?.style).overflow;return t==="hidden"||t==="scroll"}function Je(e){let t=T(e)?.pointerEvents??T(e)?.style?.pointerEvents;if(t==="none")return"all";let n=e.return;let r=0;while(n&&r++<200){const i=T(n)?.pointerEvents??T(n)?.style?.pointerEvents;if(i==="none")return"all";if(i==="box-only"&&n.tag===E)return"all";n=n.return}return t==="box-none"?"self":null}async function Xe(e,t,n){const r=await Promise.all(n.map(o=>{const u=q(o.stateNode);return u?k(u):Promise.resolve(null)}));const i=new Map;n.forEach((o,u)=>i.set(o,r[u]));const l=o=>!!o&&e>=o.x&&e<=o.x+o.width&&t>=o.y&&t<=o.y+o.height;const a=o=>{for(let u=o.return,s=0;u&&s<300;u=u.return,s++){if(u.tag===E&&i.has(u)&&Ke(u)&&!l(i.get(u)))return true}return false};for(let o=n.length-1;o>=0;o--){if(!l(r[o])||Je(n[o])||a(n[o]))continue;return n[o]}return null}function Ye(e,t){const n=global.document;const r=global.window;if(!n?.elementFromPoint||!r)return null;let i=n.elementFromPoint(e*r.innerWidth,t*r.innerHeight);while(i){const l=Object.keys(i).find(a=>a.startsWith("__reactFiber$"));if(l)return i[l];i=i.parentElement}return null}function Ze(e,t){const n=global.document;const r=global.window;if(!n?.elementFromPoint||!r)return null;const i=n.elementFromPoint(e*r.innerWidth,t*r.innerHeight);if(!i)return null;for(let c=i;c;c=c.parentElement){if(Object.keys(c).some(d=>d.startsWith("__reactFiber$")||d.startsWith("__reactContainer$")))return null}const l=!!i.closest("[data-buoy-root]");const a=de();const o=a.find(c=>c.stateNode===i);let u;for(let c=i;c&&!u;c=c.parentElement){u=a.find(d=>d.stateNode===c&&(d.press||d.valueControl||d.textControl))}const s=[];for(let c=i;c&&s.length<6;c=c.parentElement){const d=W(c);if(d!==c.tagName.toLowerCase()&&s[s.length-1]!==d)s.push(d)}return{found:true,method:"dom",buoy:l,view:{name:W(i),nativeTag:O(i),testID:o?.testID,label:o?.label,text:o?.text},path:s,target:u&&!l?{nativeTag:u.nativeTag,name:u.name,role:u.role,testID:u.testID,label:u.label,text:u.text,control:u.valueControl?u.valueControl.kind:u.textControl?"text":"press",value:u.valueControl?u.valueControl.current:u.textControl?.current}:null}}export async function hitTest(e){const t=Math.min(1,Math.max(0,Number(e?.x)));const n=Math.min(1,Math.max(0,Number(e?.y)));if(!Number.isFinite(t)||!Number.isFinite(n))return{found:false,method:"none",reason:"x and y must be numbers from 0 to 1."};const r=F.get("window");const i=t*r.width;const l=n*r.height;let a="none";let o=null;const u=Ye(t,n);const s=u?null:Ze(t,n);if(s)return s;if(u){a="dom";o=u}else{const y=Ue(i,l);if(y){a="fabric";o=await y}else{const x=je(i,l);if(x){a="paper";o=await x}}const v=qe();if(!o||!new Set(v).has(o)){o=await Xe(i,l,v);a="measured"}}if(!o)return{found:false,method:a};const c=T(o)??{};const d=L(o.stateNode);const g=[];let m=o;let w=0;while(m&&w++<80&&g.length<6){const y=M(m);if(y&&typeof m.type!=="string"&&!B.has(y)&&g[g.length-1]!==y)g.push(y);m=m.return}return{found:true,method:a,buoy:Q(o),view:{name:M(o)??"Unknown",nativeTag:d,testID:c.testID||void 0,label:c.accessibilityLabel||c["aria-label"]||void 0,text:J(c)},path:g,target:d!=null?resolveTouchTarget(d):null}}export async function readMaps(){const e=[];for(const i of N()){D(i.current,l=>{const a=l.stateNode;if(l.tag===1&&a&&typeof a.getCamera==="function"&&!Q(l))e.push(l)})}const t=F.get("window");const n=i=>Promise.race([i,new Promise(l=>setTimeout(()=>l(null),1e3))]);const r=await Promise.all(e.slice(0,5).map(async i=>{try{const l=await n(Promise.resolve(i.stateNode.getCamera()));if(!l)return null;const a=G(i);const o=a?await k(a.instance):null;const u=T(i)??{};return{name:M(i)??"Map",testID:typeof u.testID==="string"?u.testID:void 0,frame:o&&t.width&&t.height?{x:P(o.x/t.width),y:P(o.y/t.height),width:P(o.width/t.width),height:P(o.height/t.height)}:void 0,camera:{heading:typeof l.heading==="number"?l.heading:void 0,pitch:typeof l.pitch==="number"?l.pitch:void 0,altitude:typeof l.altitude==="number"?l.altitude:void 0,zoom:typeof l.zoom==="number"?l.zoom:void 0,center:l.center}}}catch{return null}}));return{maps:r.filter(i=>!!i)}}
@@ -1 +1 @@
1
- "use strict";import r from"../highlight-updates/utils/HighlightUpdatesController";import{getComponentSource as d}from"../highlight-updates/utils/componentSource";import{RenderTracker as s}from"../highlight-updates/utils/RenderTracker";import{describeScreen as l,readMaps as p,hitTest as g,tapElement as f,waitFor as h}from"../highlight-updates/utils/screenElements";import{clearTouchCapture as b,getTouchCaptureStatus as m,readTouchCapture as C,startTouchCapture as S,stopTouchCapture as T}from"../highlight-updates/utils/touchCapture";import{CommitProfiler as u}from"../highlight-updates/utils/CommitProfiler";function a(){if(!r.isInitialized()){r.initialize()}}function i(e){if(!e)return void 0;const{hookChanges:t,...n}=e;return n}function R(e){const{renderHistory:t,lastRenderCause:n,...o}=e;return{...o,lastRenderCause:i(n),historyCount:t?.length??0}}function k(e){try{JSON.stringify(e);return e}catch{return{...e,lastRenderCause:i(e.lastRenderCause),renderHistory:e.renderHistory?.map(t=>({...t,capturedProps:void 0,capturedState:void 0,cause:i(t.cause)??t.cause}))}}}function y(){if(!u.isSupported()){return{ok:false,reason:"render capture needs a dev build with the React DevTools hook available"}}u.startCapture({detail:true});return{ok:true}}function z(){return{summary:u.stopCapture()}}export const highlightUpdatesSyncAdapter={version:3,getSnapshot:()=>({enabled:r.isEnabled(),frozen:r.getFrozen(),highlightsSuppressed:r.getHighlightsSuppressed(),renders:s.getRenders().map(R),trackerState:s.getState()}),subscribe:e=>{const t=r.subscribe(e);const n=r.subscribeToFreeze(e);const o=s.subscribe(e);const c=s.subscribeToState(e);return()=>{t();n();o();c()}},actions:{getComponentSource:async e=>{try{return await d(e)}catch(t){return{found:false,reason:`Could not read the component's source: ${t instanceof Error?t.message:String(t)}`}}},beginMeasurement:()=>y(),endMeasurement:()=>z(),getRenderDetail:e=>{const{nativeTag:t}=e??{};if(t==null){return{found:false,reason:"missing nativeTag"}}const n=s.getRender(String(t));if(!n)return{found:false,reason:"unknown nativeTag"};return{found:true,nativeTag:t,render:k(n)}},toggle:()=>{a();r.toggle()},setEnabled:e=>{a();r.setEnabled(e.enabled)},toggleFreeze:()=>{r.toggleFreeze()},clearRenderCounts:()=>{r.clearRenderCounts()},setSpotlight:e=>{r.setSpotlight(e.nativeTag)},locateComponent:e=>{a();return r.locateComponent(e??{})},setSilentTracking:e=>{a();r.setSilentTracking(e.enabled??false)},describeScreen:e=>l(e??{}),tapElement:e=>f(e??{}),waitFor:e=>h(e??{}),hitTest:e=>g(e??{x:.5,y:.5}),readMaps:()=>p(),startTouchCapture:()=>S(),stopTouchCapture:()=>{T();return m()},clearTouchCapture:()=>{b();return{ok:true}},readTouchCapture:e=>C(e?.sinceSeq??0)}};
1
+ "use strict";import r from"../highlight-updates/utils/HighlightUpdatesController";import{getComponentSource as d}from"../highlight-updates/utils/componentSource";import{RenderTracker as s}from"../highlight-updates/utils/RenderTracker";import{describeScreen as p,readMaps as f,hitTest as g,tapElement as m,waitFor as b}from"../highlight-updates/utils/screenElements";import{clearTouchCapture as h,getTouchCaptureStatus as C,readTouchCapture as S,startTouchCapture as T,stopTouchCapture as k}from"../highlight-updates/utils/touchCapture";import{CommitProfiler as i}from"../highlight-updates/utils/CommitProfiler";function a(){if(!r.isInitialized()){r.initialize()}}function c(e){if(!e)return void 0;const{hookChanges:t,...n}=e;return n}function y(e){const{renderHistory:t,lastRenderCause:n,...u}=e;return{...u,lastRenderCause:c(n),historyCount:t?.length??0}}function R(e){try{JSON.stringify(e);return e}catch{return{...e,lastRenderCause:c(e.lastRenderCause),renderHistory:e.renderHistory?.map(t=>({...t,capturedProps:void 0,capturedState:void 0,cause:c(t.cause)??t.cause}))}}}function z(){const e=globalThis[Symbol.for("buoy.framework.renderCapture")];return e&&typeof e.start==="function"&&e.isSupported()?e:null}let o=null;function w(){if(i.isSupported()){i.startCapture({detail:true});o="react";return{ok:true}}const e=z();if(e){e.start();o=e;return{ok:true}}return{ok:false,reason:"render capture needs a dev build with the React DevTools hook available"}}function v(){const e=o;o=null;if(e&&e!=="react")return{summary:e.stop()};return{summary:i.stopCapture()}}export const highlightUpdatesSyncAdapter={version:3,getSnapshot:()=>({enabled:r.isEnabled(),frozen:r.getFrozen(),highlightsSuppressed:r.getHighlightsSuppressed(),renders:s.getRenders().map(y),trackerState:s.getState()}),subscribe:e=>{const t=r.subscribe(e);const n=r.subscribeToFreeze(e);const u=s.subscribe(e);const l=s.subscribeToState(e);return()=>{t();n();u();l()}},actions:{getComponentSource:async e=>{try{return await d(e)}catch(t){return{found:false,reason:`Could not read the component's source: ${t instanceof Error?t.message:String(t)}`}}},beginMeasurement:()=>w(),endMeasurement:()=>v(),getRenderDetail:e=>{const{nativeTag:t}=e??{};if(t==null){return{found:false,reason:"missing nativeTag"}}const n=s.getRender(String(t));if(!n)return{found:false,reason:"unknown nativeTag"};return{found:true,nativeTag:t,render:R(n)}},toggle:()=>{a();r.toggle()},setEnabled:e=>{a();r.setEnabled(e.enabled)},toggleFreeze:()=>{r.toggleFreeze()},clearRenderCounts:()=>{r.clearRenderCounts()},setSpotlight:e=>{r.setSpotlight(e.nativeTag)},locateComponent:e=>{a();return r.locateComponent(e??{})},setSilentTracking:e=>{a();r.setSilentTracking(e.enabled??false)},describeScreen:e=>p(e??{}),tapElement:e=>m(e??{}),waitFor:e=>b(e??{}),hitTest:e=>g(e??{x:.5,y:.5}),readMaps:()=>f(),startTouchCapture:()=>T(),stopTouchCapture:()=>{k();return C()},clearTouchCapture:()=>{h();return{ok:true}},readTouchCapture:e=>S(e?.sinceSeq??0)}};
@@ -0,0 +1,20 @@
1
+ export interface DOMElementInfo {
2
+ element: HTMLElement;
3
+ /** Props in the fiber walk's vocabulary (testID, accessibilityLabel, onPress, …). */
4
+ props: any;
5
+ text?: string;
6
+ /** Under a Buoy root (data-buoy-root). */
7
+ buoy: boolean;
8
+ }
9
+ /** Elements outside React's roots that carry a signal: a control, an id, a label or text. */
10
+ export declare function collectDOMElements(options?: {
11
+ fullText?: boolean;
12
+ }): DOMElementInfo[];
13
+ /** A name for the element: the framework's component name when one is registered, else its tag. */
14
+ export declare function domElementName(element: HTMLElement): string;
15
+ /**
16
+ * DOM changes in the settle window after a tap, for pages without React
17
+ * commits to count. One batch of mutations counts as one change.
18
+ */
19
+ export declare function watchDOMChanges(): () => number;
20
+ //# sourceMappingURL=domScreenElements.d.ts.map