@buoy-gg/focus-inspector 7.0.55 → 7.0.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/web/index.mjs CHANGED
@@ -1 +1 @@
1
- "use client";var Z=Object.defineProperty;var _e=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var He=Object.prototype.hasOwnProperty;var ze=(e,n)=>{for(var t in n)Z(e,t,{get:n[t],enumerable:true})},X=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of Be(n))!He.call(e,i)&&i!==t&&Z(e,i,{get:()=>n[i],enumerable:!(r=_e(n,i))||r.enumerable});return e},We=(e,n,t)=>(X(e,n,"default"),t&&X(t,n,"default"));typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{approxJsonSize as ee}from"@buoy-gg/shared-ui/web";var b=null,E=null,w=[],T=[],O=new Set,R=0,F=0,P=0,k=true,S=null,C=null,_=new Set,j=new Set;function x(){j.forEach(e=>{e()})}function je(e){w=w.length>=300?[...w.slice(1),e]:[...w,e]}function te(e){T=T.length>=400?[...T.slice(1),e]:[...T,e]}function Ke(e,n,t){for(let r=T.length-1;r>=0;r--){let i=T[r];if(t-i.at>250)break;if(!i.resolved&&i.tag===e)return i.resolved=true,i.movedTo=n,i.direction}return null}function ne(e,n,t){F+=1;let r=e!==null&&E!==null?Math.max(0,t-E):void 0,i={seq:F,fromTag:e,toTag:n,direction:Ke(e,n,t),at:t,dwellMs:r};je(i),n===null&&(R+=1)}function B(){C!==null&&(clearTimeout(C),C=null)}function ae(e,n=Date.now()){if(!k||!Number.isFinite(e))return;B();let t=S?.tag??b;S=null,!(t===e&&b===e)&&(ne(t,e,n),b=e,E=n,O.add(e),x())}function re(e,n=Date.now()){!k||!Number.isFinite(e)||b!==null&&e!==b||(S={tag:e,at:n},B(),C=setTimeout(()=>{if(C=null,!S)return;let t=S.tag;S=null,ne(t,null,Date.now()),b=null,E=null,x()},400))}function ie(e,n=Date.now()){if(!k)return;let t=w[w.length-1];if(t&&t.direction===null&&t.fromTag!==null&&n-t.at<=60){t.direction=e,P+=1,te({seq:P,tag:t.fromTag,direction:e,at:n,resolved:true,movedTo:t.toTag}),x();return}P+=1;let r={seq:P,tag:b,direction:e,at:n,resolved:false,movedTo:null};te(r);let i=setTimeout(()=>{_.delete(i),!r.resolved&&(r.resolved=true,r.movedTo=null,x())},250);_.add(i),x()}function H(){return{currentTag:b,presence:b!==null?"focused":F===0?"never-observed":"lost",currentSince:E,transitions:w,probes:T,visited:Array.from(O),lostCount:R,transitionCount:F,tracking:k}}function oe(){w=[],T=[],O=b!==null?new Set([b]):new Set,R=0,F=0,P=0,x()}function le(e){k!==e&&(k=e,e||(B(),S=null),x())}function Ue(){B(),_.forEach(e=>{clearTimeout(e)}),_.clear(),S=null,b=null,E=null,w=[],T=[],O=new Set,R=0,F=0,P=0,k=true,x()}function se(e){return j.add(e),()=>{j.delete(e)}}function qe(){x()}import{resolveDOMEventEmitter as $e}from"@buoy-gg/shared-ui/web/utils";var K=null,ue=false,D=[],A="idle",U=null;function Ge(){if(ue)return K;ue=true;let e=$e();return K=e.emitter,U=e.reason,K}function ce(e){let n=e?.nativeEvent;if(!n)return null;let t=n.target??n.tag;return typeof t=="number"&&Number.isFinite(t)?t:null}function de(){if(D.length>0)return;let e=Ge();if(!e){A="unavailable";return}try{D=[e.addListener("topFocus",n=>{let t=ce(n);t!==null&&ae(t)}),e.addListener("topBlur",n=>{let t=ce(n);t!==null&&re(t)})],A="listening"}catch(n){D=[],A="unavailable",U=n?.message??"addListener failed"}}function Ye(){D.forEach(e=>{try{e.remove()}catch{}}),D=[],A==="listening"&&(A="idle")}function Je(){return{status:A,reason:A==="unavailable"?U:null}}var q=false,I="web",L=false,Qe={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right"};function fe(e){let n=Qe[e.key];n&&ie(n)}function ge(){L||typeof document>"u"||(L=true,document.addEventListener("keydown",fe,true))}function Ze(){L&&(L=false,document.removeEventListener("keydown",fe,true))}function Xe(){return L}import{getDOMNodeHandle as et,getDOMPublicInstance as tt,isDOMElement as nt}from"@buoy-gg/shared-ui/web/utils";var he={};ze(he,{AccessibilityInfo:()=>ot,ActivityIndicator:()=>on,Alert:()=>un,Animated:()=>lt,AppRegistry:()=>ut,AppState:()=>ct,Appearance:()=>st,BackHandler:()=>dt,Button:()=>ln,CheckBox:()=>Ft,Clipboard:()=>ft,DeviceEventEmitter:()=>jt,Dimensions:()=>pe,Easing:()=>gt,FlatList:()=>Pt,I18nManager:()=>ht,Image:()=>Mt,ImageBackground:()=>Vt,InteractionManager:()=>mt,Keyboard:()=>pt,KeyboardAvoidingView:()=>Ct,LayoutAnimation:()=>bt,Linking:()=>vt,LogBox:()=>Wt,Modal:()=>an,NativeEventEmitter:()=>yt,NativeModules:()=>it,PanResponder:()=>wt,Picker:()=>Dt,PixelRatio:()=>Tt,Platform:()=>xt,Pressable:()=>tn,ProgressBar:()=>It,RefreshControl:()=>Lt,SafeAreaView:()=>Nt,ScrollView:()=>nn,SectionList:()=>Ot,Share:()=>St,StatusBar:()=>Rt,StyleSheet:()=>kt,Switch:()=>rn,Text:()=>Jt,TextInput:()=>Qt,Touchable:()=>_t,TouchableHighlight:()=>Xt,TouchableNativeFeedback:()=>Bt,TouchableOpacity:()=>Zt,TouchableWithoutFeedback:()=>en,UIManager:()=>At,Vibration:()=>Et,View:()=>Yt,VirtualizedList:()=>Ht,YellowBox:()=>zt,findNodeHandle:()=>sn,unstable_createElement:()=>rt,useColorScheme:()=>Kt,useLocaleContext:()=>Ut,useWindowDimensions:()=>qt});We(he,at);import*as at from"react-native-web";import{unstable_createElement as rt,NativeModules as it,AccessibilityInfo as ot,Animated as lt,Appearance as st,AppRegistry as ut,AppState as ct,BackHandler as dt,Clipboard as ft,Dimensions as pe,Easing as gt,I18nManager as ht,Keyboard as pt,InteractionManager as mt,LayoutAnimation as bt,Linking as vt,NativeEventEmitter as yt,PanResponder as wt,PixelRatio as Tt,Platform as xt,Share as St,StyleSheet as kt,UIManager as At,Vibration as Et,CheckBox as Ft,FlatList as Pt,Image as Mt,ImageBackground as Vt,KeyboardAvoidingView as Ct,Picker as Dt,ProgressBar as It,RefreshControl as Lt,SafeAreaView as Nt,SectionList as Ot,StatusBar as Rt,Touchable as _t,TouchableNativeFeedback as Bt,VirtualizedList as Ht,YellowBox as zt,LogBox as Wt,DeviceEventEmitter as jt,useColorScheme as Kt,useLocaleContext as Ut,useWindowDimensions as qt}from"react-native-web";import*as h from"react-native-web";import{createElement as $t,forwardRef as Gt}from"react";function v(e){let n=Gt((r,i)=>{let{accessibilityState:a,accessibilityValue:o,...l}=r;for(let s of["busy","checked","disabled","expanded","selected"])a?.[s]!==void 0&&l[`aria-${s}`]===void 0&&(l[`aria-${s}`]=a[s]);for(let[s,u]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))o?.[s]!==void 0&&l[`aria-${u}`]===void 0&&(l[`aria-${u}`]=o[s]);return $t(e,{...l,ref:i})}),t=e.State;return t&&Object.assign(n,{State:t}),n.displayName=e.displayName??e.name??"NativeWebView",n}var Yt=v(h.View),Jt=v(h.Text),Qt=v(h.TextInput),Zt=v(h.TouchableOpacity),Xt=v(h.TouchableHighlight),en=v(h.TouchableWithoutFeedback),tn=v(h.Pressable),nn=v(h.ScrollView),an=v(h.Modal),rn=v(h.Switch),on=v(h.ActivityIndicator),ln=v(h.Button),sn=h.findNodeHandle,un={alert(e,n,t,r){if(typeof document>"u")return;let i=document.createElement("dialog");i.dataset.buoyRoot="",i.setAttribute("aria-label",e),i.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let a=document.createElement("h2");if(a.textContent=e,a.style.cssText="font-size:18px;margin:0 0 12px",i.appendChild(a),n){let u=document.createElement("p");u.textContent=n,u.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",i.appendChild(u)}let o=document.createElement("div");o.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let l=t?.length?t:[{text:"OK"}],s=()=>{i.close?.(),i.remove()};for(let u of l){let f=document.createElement("button");f.type="button",f.textContent=u.text??"OK",f.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${u.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,f.onclick=()=>{s(),u.onPress?.()},o.appendChild(f)}i.addEventListener("cancel",u=>{u.preventDefault(),r?.cancelable!==false&&(s(),r?.onDismiss?.())}),i.appendChild(o),document.body.appendChild(i),i.showModal?i.showModal():i.setAttribute("open","")}};var cn=22,me=new Set(["View","RCTView","ScrollView","RCTScrollView","RCTScrollContentView","SafeAreaView","RCTSafeAreaView","AndroidHorizontalScrollContentView","KeyboardAvoidingView","Pressable","PlatformPressable","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","TouchableNativeFeedback","AnimatedComponent","Wrapper"]),$="TVFocusGuideView";function dn(){return typeof globalThis>"u"?null:globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__??null}function fn(){let e=dn();if(!e)return[];let n=[];try{if(e.renderers&&typeof e.renderers.forEach=="function"&&e.renderers.forEach((t,r)=>{try{let i=e.getFiberRoots?.(r);i&&i.forEach(a=>n.push(a))}catch{}}),n.length===0&&e.getFiberRoots){let t=e.getFiberRoots(1);t&&t.forEach(r=>n.push(r))}}catch{}return n}function gn(e){return e.tag===cn&&e.memoizedState!==null}function hn(e){let n=e.memoizedProps?.activityState;return n===0||n===1||e.memoizedProps?.isPageFocused===false}function G(e){return e?.memoizedProps??e?.pendingProps??null}function be(e){let n=e?.type;return n?typeof n=="string"?n:n.displayName||n.name||null:null}function ve(e){let n=e?._debugOwner||e?.return,t=0;for(;n&&t<30;){t++;let r=be(n);if(r&&!me.has(r)&&typeof n.type!="string")return r;n=n.return}return null}function ye(e){let n=tt(e);if(n)return n;if(!e)return null;let t=e;return t.canonical?.publicInstance?t.canonical.publicInstance:t.canonical&&typeof t.canonical.measure=="function"?t.canonical:typeof t.measure=="function"||typeof t.measureInWindow=="function"?t:null}function we(e){let n=et(e);if(n!==null)return n;if(e==null)return null;let t=e;if(typeof t.__nativeTag=="number")return t.__nativeTag;if(typeof t._nativeTag=="number")return t._nativeTag;if(typeof t.nativeTag=="number")return t.nativeTag;if(t.canonical){if(typeof t.canonical.__nativeTag=="number")return t.canonical.__nativeTag;if(typeof t.canonical._nativeTag=="number")return t.canonical._nativeTag;if(typeof t.canonical.nativeTag=="number")return t.canonical.nativeTag}return null}function pn(e){let n=ye(e.stateNode);if(n)return{instance:n,nativeTag:we(e.stateNode)};let t=[];e.child&&t.push(e.child);let r=0;for(;t.length>0&&r<4e3;){r++;let i=t.pop();if(!i)continue;let a=ye(i.stateNode);if(a)return{instance:a,nativeTag:we(i.stateNode)};i.child&&t.push(i.child),i.sibling&&t.push(i.sibling)}return null}function mn(e){if(typeof e.isTVSelectable=="boolean")return e.isTVSelectable;if(typeof e.focusable=="boolean")return e.focusable;if(typeof e.tvFocusable=="boolean")return e.tvFocusable}function bn(e){let n=typeof e.nextFocusUp=="number",t=typeof e.nextFocusDown=="number",r=typeof e.nextFocusLeft=="number",i=typeof e.nextFocusRight=="number";if(!(!n&&!t&&!r&&!i))return{up:n||void 0,down:t||void 0,left:r||void 0,right:i||void 0}}function Te(e){if(!e)return;let n=t=>{if(typeof t=="string")return t.trim()?t.trim().slice(0,60):void 0;if(typeof t=="number"&&Number.isFinite(t))return String(t)};return n(e.children)??n(e.title)??n(e.label)??void 0}function vn(e,n){let t=[],r=(a,o)=>{if(!a||o>n||t.length>=3)return;if(a!==e){let s=G(a);if(s&&typeof s.onPress=="function")return}let l=Te(G(a));l&&!t.includes(l)&&t.push(l),a.child&&r(a.child,o+1),a!==e&&a.sibling&&r(a.sibling,o)};e.child&&r(e.child,1);let i=t.join(" ").trim();return i?i.slice(0,60):void 0}function yn(e){return new Promise(n=>{let t=false,r=i=>{t||(t=true,n(i))};setTimeout(()=>r(null),1e3);try{typeof e.measureInWindow=="function"?e.measureInWindow((i,a,o,l)=>{r(o>0&&l>0?{x:i,y:a,width:o,height:l}:null)}):typeof e.measure=="function"?e.measure((i,a,o,l,s,u)=>{r(o>0&&l>0&&s!=null&&u!=null?{x:s,y:u,width:o,height:l}:null)}):r(null)}catch{r(null)}})}var Y=new Map;function wn(e,n,t){let r=[{fiber:e,context:n,depth:0}],i=new Set;for(;r.length>0;){let a=r.pop();if(!a)continue;let{fiber:o,depth:l}=a;if(!o||i.has(o)||l>500)continue;if(i.add(o),gn(o)||hn(o)){o.sibling&&r.push({fiber:o.sibling,context:a.context,depth:l});continue}let s=t(o,a.context);o.sibling&&r.push({fiber:o.sibling,context:a.context,depth:l}),o.child&&r.push({fiber:o.child,context:s,depth:l+1})}}function Tn(){let e=fn();if(e.length===0)return[];let n=[],t=new Set;for(let r of e)wn(r.current,{guideTag:null},(i,a)=>{let o=G(i);if(!o)return a;let l=be(i),s=l===$,u=mn(o),f=typeof o.onPress=="function"||typeof o.onLongPress=="function",c=o.hasTVPreferredFocus===true,p=bn(o);if(!(s||u===true||c||!!p||f&&u!==false||nt(i.stateNode)&&i.stateNode.matches('a[href],button,input,select,textarea,[tabindex],[contenteditable="true"]')&&!i.stateNode.matches(':disabled,[inert], [tabindex="-1"]')))return a;let d=pn(i),g=d?.nativeTag??null;if(g===null)return a;let N=s?{guideTag:g}:a;if(t.has(g)){let m=n.find(Re=>Re.node.nativeTag===g);return m&&(u!==void 0&&m.node.focusProps.focusable===void 0&&(m.node.focusProps.focusable=u),c&&(m.node.focusProps.hasTVPreferredFocus=true),p&&!m.node.focusProps.nextFocus&&(m.node.focusProps.nextFocus=p),f&&(m.node.pressable=true),!m.node.testID&&o.testID&&(m.node.testID=o.testID),s&&!m.node.guide&&(m.node.guide=xe(o),m.node.name=$)),N}t.add(g);let Q=l??"Unknown";(!l||me.has(l)||typeof i.type=="string")&&(Q=ve(i)??l??"Unknown");let Le=o.accessibilityLabel||o["aria-label"]||void 0,Ne=Te(o)??(f?vn(i,6):void 0),Oe={nativeTag:g,name:s?$:Q,owner:ve(i)??void 0,testID:o.testID||o["data-testid"]||void 0,label:Le,text:Ne,focusProps:{focusable:u,hasTVPreferredFocus:c||void 0,nextFocus:p},guide:s?xe(o):void 0,guideAncestorTag:a.guideTag??void 0,pressable:f||void 0};return d?.instance&&Y.set(g,d.instance),n.push({node:Oe,instance:d?.instance??null}),N});return n}function xe(e){return{autoFocus:e.autoFocus===true,hasDestinations:Array.isArray(e.destinations)&&e.destinations.length>0,enabled:e.enabled!==false,trap:{up:e.trapFocusUp===true,down:e.trapFocusDown===true,left:e.trapFocusLeft===true,right:e.trapFocusRight===true}}}function z(e){return Math.round(e*1e3)/1e3}var xn=400;async function Se(){Y.clear();let e=Tn();await Promise.all(e.map(async a=>{if(!a.instance)return;let o=await yn(a.instance);o&&(a.node.frame=o)}));let n=pe.get("window"),t=Math.round(n.width)||1,r=Math.round(n.height)||1,i=[];for(let a of e){let o=a.node.frame;if(o){let l=o.x+o.width/2,s=o.y+o.height/2;a.node.onScreen=s>=0&&s<=r&&l>=0&&l<=t,a.node.frame={x:z(o.x/t),y:z(o.y/r),width:z(o.width/t),height:z(o.height/r)}}if(i.push(a.node),i.length>=xn)break}return i.sort((a,o)=>{let l=a.frame?.y??2,s=o.frame?.y??2;return Math.abs(l-s)>.01?l-s:(a.frame?.x??2)-(o.frame?.x??2)}),{screen:{width:t,height:r},nodes:i,scannedAt:Date.now()}}function Sn(e){let n=Y.get(e);if(!n)return{ok:false,reason:"Unknown tag \u2014 rescan and try again."};if(typeof n.requestTVFocus!="function")return{ok:false,reason:"This element exposes no requestTVFocus()."};try{return n.requestTVFocus(),{ok:true}}catch(t){return{ok:false,reason:t?.message??"requestTVFocus() threw."}}}var ke=["up","down","left","right"];function kn(e,n){return`${e}:${n}`}function Ae(e,n,t=3,r=0){let i=new Map;for(let l of e){if(!l.resolved||l.tag===null||l.at<r)continue;let s=kn(l.tag,l.direction);l.movedTo===null?i.set(s,(i.get(s)??0)+1):i.set(s,0)}let a=new Map;for(let l of n)a.set(l.nativeTag,l);let o=[];return i.forEach((l,s)=>{if(l<t)return;let[u,f]=s.split(":"),c=Number(u),p=f;o.push({tag:c,direction:p,attempts:l,atEdge:An(a.get(c),p,n)})}),o.sort((l,s)=>s.attempts-l.attempts)}function An(e,n,t){let r=e?.frame;if(!r)return false;let i=r.x+r.width/2,a=r.y+r.height/2;for(let o of t){if(o.nativeTag===e.nativeTag||o.guide)continue;let l=o.frame;if(!l)continue;let s=l.x+l.width/2,u=l.y+l.height/2;switch(n){case"up":if(u<r.y)return false;break;case"down":if(u>r.y+r.height)return false;break;case"left":if(s<r.x)return false;break;case"right":if(s>r.x+r.width)return false;break}}return true}function En(e){if(e.length===0)return null;let n=1/0,t=1/0,r=-1/0,i=-1/0;for(let a of e)n=Math.min(n,a.x),t=Math.min(t,a.y),r=Math.max(r,a.x+a.width),i=Math.max(i,a.y+a.height);return{x:n,y:t,width:r-n,height:i-t}}function Fn(e,n,t){switch(t){case"up":return n.y<e.y;case"down":return n.y>e.y+e.height;case"left":return n.x<e.x;case"right":return n.x>e.x+e.width;default:return false}}var Pn=2;function Ee(e,n){let t=new Map;for(let a of n)t.set(a.nativeTag,a);let r=new Map;for(let a of e){let o=t.get(a.tag)?.guideAncestorTag??a.tag,l=r.get(o)??{containerTag:o,tags:new Set,directions:new Set};l.tags.add(a.tag),l.directions.add(a.direction),r.set(o,l)}let i=[];return r.forEach(a=>{if(a.directions.size<Pn)return;let o=new Set(a.tags);for(let d of n)d.guideAncestorTag===a.containerTag&&o.add(d.nativeTag);o.add(a.containerTag);let l=t.get(a.containerTag),s=l?.guide&&l.frame?l.frame:En(Array.from(o).map(d=>t.get(d)?.frame).filter(d=>!!d));if(!s)return;let u=0,f=0;for(let d of ke)n.some(g=>{if(g.guide||o.has(g.nativeTag)||!g.frame)return false;let N={x:g.frame.x+g.frame.width/2,y:g.frame.y+g.frame.height/2};return Fn(s,N,d)})&&(f+=1,a.directions.has(d)||(u+=1));if(f===0||u>0)return;let c=l?.guide,p=c!==void 0&&(c.trap.up||c.trap.down||c.trap.left||c.trap.right);i.push({tags:Array.from(a.tags).sort((d,g)=>d-g),containerTag:a.containerTag,directions:ke.filter(d=>a.directions.has(d)),guideTrapTag:p?a.containerTag:void 0})}),i}function Fe(e,n,t=0){let r=new Map;for(let a of n)r.set(a.nativeTag,a);let i=new Map;for(let a of e){let o=a.toTag;if(o===null||a.at<t)continue;let l=r.get(o),s=l?l.guide?"guide":null:n.length>0?"unknown":null;if(!s)continue;let u=i.get(o);u?(u.count+=1,u.at=a.at):i.set(o,{tag:o,reason:s,at:a.at,count:1})}return Array.from(i.values()).sort((a,o)=>o.at-a.at)}function Pe(e,n,t,r,i=0){let a=Ae(n,t,3,i);return{deadEnds:a,traps:Ee(a,t),invisibleStops:Fe(e,t,i),lostCount:r}}function Me(e,n,t,r){let i=new Set(n),a=e.filter(c=>!c.guide),o=a.filter(c=>!i.has(c.nativeTag)).map(c=>c.nativeTag),l=r.length>=12,s=new Set;for(let c of t)c.toTag!==null&&s.add(c.toTag);let u=new Map;for(let c of e)u.set(c.nativeTag,c);let f=l?o.filter(c=>{if(s.has(c))return false;let p=u.get(c);return p?.frame?a.some(d=>d.nativeTag!==c&&i.has(d.nativeTag)&&Mn(p,d)):false}):[];return{focusables:a.length,visited:a.filter(c=>i.has(c.nativeTag)).length,unvisited:o,suspectedUnreachable:f,meaningful:l}}var Ve=.12;function Mn(e,n){let t=e.frame,r=n.frame;if(!t||!r)return false;let i=t.x<r.x+r.width&&r.x<t.x+t.width,a=t.y<r.y+r.height&&r.y<t.y+t.height;return!!(i&&Math.max(t.y-(r.y+r.height),r.y-(t.y+t.height))<=Ve||a&&Math.max(t.x-(r.x+r.width),r.x-(t.x+t.width))<=Ve)}function Ce(e,n,t=[]){let r=[];for(let a of n)a.fromTag!==e||a.direction===null||r.push({at:a.at,direction:a.direction,to:a.toTag});for(let a of t)a.tag!==e||!a.resolved||a.movedTo!==null||r.push({at:a.at,direction:a.direction,to:null});r.sort((a,o)=>a.at-o.at);let i={};for(let a of r)i[a.direction]=a.to;return i}var De=1.5*1024*1024,Vn=500;q&&(de(),ge());var y=null,J=false,M=null,V=0;function Ie(){let e=new Map;for(let n of y?.nodes??[])e.set(n.nativeTag,n);return e}async function W(){if(J)return y;J=true;try{return y=await Se(),y}catch{return y}finally{J=false,qe()}}function Cn(){if(V===0)return;let{currentTag:e}=H();e!==null&&(Ie().has(e)||M===null&&(M=setTimeout(()=>{M=null,W()},Vn)))}function Dn(e,n){let t=[],r=0;for(let i=e.length-1;i>=0;i--){let a=ee(e[i],n).bytes;if(r+a>n&&t.length>0)break;t.push(e[i]),r+=a}return t.reverse(),t}function In(){let e=H(),n=y?.nodes??[],t=Je(),r=Pe(e.transitions,e.probes,n,e.lostCount,y?.scannedAt??0),i=Me(n,e.visited,e.transitions,e.probes),a=Ie(),o=ee(n,De).bytes,l=Dn(e.transitions,Math.max(64*1024,De-o)),s=r.deadEnds.filter(u=>!u.atEdge).length+r.traps.length+r.invisibleStops.length+(r.lostCount>0?1:0);return{supported:q||I==="web",platform:I,observer:t.status,observerReason:t.reason,keysListening:Xe(),tracking:e.tracking,presence:e.presence,current:e.currentTag===null?null:{tag:e.currentTag,node:a.get(e.currentTag)??null,since:e.currentSince??Date.now(),edges:Ce(e.currentTag,e.transitions,e.probes)},transitions:l,focusables:n,screen:y?.screen??null,scannedAt:y?.scannedAt??null,flags:r,coverage:i,stats:{focusables:i.focusables,visited:i.visited,transitions:e.transitionCount,flagged:s},capturedAt:Date.now()}}var Ln={version:1,getSnapshot(){return In()},subscribe(e){V+=1,V===1&&(I==="web"&&(de(),ge()),W());let n=se(()=>{Cn(),e()}),t=0,r=null,i=()=>{if(t+=1,(y?.nodes.length??0)>0||t>=100){r=null;return}W(),r=setTimeout(i,100)};return r=setTimeout(i,100),()=>{n(),r!==null&&clearTimeout(r),V=Math.max(0,V-1),V===0&&(M!==null&&(clearTimeout(M),M=null),I==="web"&&(Ye(),Ze()))}},actions:{async rescan(){return{ok:true,focusables:(await W())?.nodes.length??0}},clearHistory(){return oe(),{ok:true}},setTracking(e){return le(e?.enabled!==false),{tracking:H().tracking}},focusElement(e){let n=e?.nativeTag;return typeof n!="number"?{ok:false,reason:"nativeTag is required."}:!q&&I!=="web"?{ok:false,reason:"Not a TV build \u2014 there is no focus engine."}:Sn(n)}}};export{oe as clearHistory,Me as computeCoverage,Ae as detectDeadEnds,Pe as detectFlags,Fe as detectInvisibleStops,Ee as detectTraps,Ln as focusInspectorSyncAdapter,H as getState,Ce as observedEdges,re as recordBlur,ae as recordFocus,ie as recordKey,Ue as resetStore,Se as scanFocusables,le as setTracking,se as subscribe};
1
+ "use client";var Z=Object.defineProperty;var Re=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var He=Object.prototype.hasOwnProperty;var ze=(e,n)=>{for(var t in n)Z(e,t,{get:n[t],enumerable:true})},X=(e,n,t,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of Be(n))!He.call(e,i)&&i!==t&&Z(e,i,{get:()=>n[i],enumerable:!(a=Re(n,i))||a.enumerable});return e},Ue=(e,n,t)=>(X(e,n,"default"),t&&X(t,n,"default"));var Ln=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{approxJsonSize as ee}from"@buoy-gg/shared-ui/web";var b=null,E=null,w=[],T=[],O=new Set,_=0,F=0,P=0,k=true,S=null,C=null,R=new Set,W=new Set;function x(){W.forEach(e=>{e()})}function We(e){w=w.length>=300?[...w.slice(1),e]:[...w,e]}function te(e){T=T.length>=400?[...T.slice(1),e]:[...T,e]}function je(e,n,t){for(let a=T.length-1;a>=0;a--){let i=T[a];if(t-i.at>250)break;if(!i.resolved&&i.tag===e)return i.resolved=true,i.movedTo=n,i.direction}return null}function ne(e,n,t){F+=1;let a=e!==null&&E!==null?Math.max(0,t-E):void 0,i={seq:F,fromTag:e,toTag:n,direction:je(e,n,t),at:t,dwellMs:a};We(i),n===null&&(_+=1)}function B(){C!==null&&(clearTimeout(C),C=null)}function re(e,n=Date.now()){if(!k||!Number.isFinite(e))return;B();let t=S?.tag??b;S=null,!(t===e&&b===e)&&(ne(t,e,n),b=e,E=n,O.add(e),x())}function ae(e,n=Date.now()){!k||!Number.isFinite(e)||b!==null&&e!==b||(S={tag:e,at:n},B(),C=setTimeout(()=>{if(C=null,!S)return;let t=S.tag;S=null,ne(t,null,Date.now()),b=null,E=null,x()},400))}function ie(e,n=Date.now()){if(!k)return;let t=w[w.length-1];if(t&&t.direction===null&&t.fromTag!==null&&n-t.at<=60){t.direction=e,P+=1,te({seq:P,tag:t.fromTag,direction:e,at:n,resolved:true,movedTo:t.toTag}),x();return}P+=1;let a={seq:P,tag:b,direction:e,at:n,resolved:false,movedTo:null};te(a);let i=setTimeout(()=>{R.delete(i),!a.resolved&&(a.resolved=true,a.movedTo=null,x())},250);R.add(i),x()}function H(){return{currentTag:b,presence:b!==null?"focused":F===0?"never-observed":"lost",currentSince:E,transitions:w,probes:T,visited:Array.from(O),lostCount:_,transitionCount:F,tracking:k}}function oe(){w=[],T=[],O=b!==null?new Set([b]):new Set,_=0,F=0,P=0,x()}function le(e){k!==e&&(k=e,e||(B(),S=null),x())}function Ke(){B(),R.forEach(e=>{clearTimeout(e)}),R.clear(),S=null,b=null,E=null,w=[],T=[],O=new Set,_=0,F=0,P=0,k=true,x()}function se(e){return W.add(e),()=>{W.delete(e)}}function qe(){x()}import{resolveDOMEventEmitter as $e}from"@buoy-gg/shared-ui/web/utils";var j=null,ue=false,D=[],A="idle",K=null;function Ge(){if(ue)return j;ue=true;let e=$e();return j=e.emitter,K=e.reason,j}function ce(e){let n=e?.nativeEvent;if(!n)return null;let t=n.target??n.tag;return typeof t=="number"&&Number.isFinite(t)?t:null}function de(){if(D.length>0)return;let e=Ge();if(!e){A="unavailable";return}try{D=[e.addListener("topFocus",n=>{let t=ce(n);t!==null&&re(t)}),e.addListener("topBlur",n=>{let t=ce(n);t!==null&&ae(t)})],A="listening"}catch(n){D=[],A="unavailable",K=n?.message??"addListener failed"}}function Ye(){D.forEach(e=>{try{e.remove()}catch{}}),D=[],A==="listening"&&(A="idle")}function Je(){return{status:A,reason:A==="unavailable"?K:null}}var q=false,N="web",I=false,Qe={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right"};function fe(e){let n=Qe[e.key];n&&ie(n)}function ge(){I||typeof document>"u"||(I=true,document.addEventListener("keydown",fe,true))}function Ze(){I&&(I=false,document.removeEventListener("keydown",fe,true))}function Xe(){return I}import{getDOMNodeHandle as et,getDOMPublicInstance as tt,isDOMElement as nt}from"@buoy-gg/shared-ui/web/utils";var he={};ze(he,{AccessibilityInfo:()=>ot,ActivityIndicator:()=>on,Alert:()=>un,Animated:()=>lt,AppRegistry:()=>ut,AppState:()=>ct,Appearance:()=>st,BackHandler:()=>dt,Button:()=>ln,CheckBox:()=>Ft,Clipboard:()=>ft,DeviceEventEmitter:()=>Wt,Dimensions:()=>pe,Easing:()=>gt,FlatList:()=>Pt,I18nManager:()=>ht,Image:()=>Mt,ImageBackground:()=>Vt,InteractionManager:()=>mt,Keyboard:()=>pt,KeyboardAvoidingView:()=>Ct,LayoutAnimation:()=>bt,Linking:()=>vt,LogBox:()=>Ut,Modal:()=>rn,NativeEventEmitter:()=>yt,NativeModules:()=>it,PanResponder:()=>wt,Picker:()=>Dt,PixelRatio:()=>Tt,Platform:()=>xt,Pressable:()=>tn,ProgressBar:()=>Nt,RefreshControl:()=>It,SafeAreaView:()=>Lt,ScrollView:()=>nn,SectionList:()=>Ot,Share:()=>St,StatusBar:()=>_t,StyleSheet:()=>kt,Switch:()=>an,Text:()=>Jt,TextInput:()=>Qt,Touchable:()=>Rt,TouchableHighlight:()=>Xt,TouchableNativeFeedback:()=>Bt,TouchableOpacity:()=>Zt,TouchableWithoutFeedback:()=>en,UIManager:()=>At,Vibration:()=>Et,View:()=>Yt,VirtualizedList:()=>Ht,YellowBox:()=>zt,findNodeHandle:()=>sn,unstable_createElement:()=>at,useColorScheme:()=>jt,useLocaleContext:()=>Kt,useWindowDimensions:()=>qt});Ue(he,rt);import*as rt from"react-native-web";import{unstable_createElement as at,NativeModules as it,AccessibilityInfo as ot,Animated as lt,Appearance as st,AppRegistry as ut,AppState as ct,BackHandler as dt,Clipboard as ft,Dimensions as pe,Easing as gt,I18nManager as ht,Keyboard as pt,InteractionManager as mt,LayoutAnimation as bt,Linking as vt,NativeEventEmitter as yt,PanResponder as wt,PixelRatio as Tt,Platform as xt,Share as St,StyleSheet as kt,UIManager as At,Vibration as Et,CheckBox as Ft,FlatList as Pt,Image as Mt,ImageBackground as Vt,KeyboardAvoidingView as Ct,Picker as Dt,ProgressBar as Nt,RefreshControl as It,SafeAreaView as Lt,SectionList as Ot,StatusBar as _t,Touchable as Rt,TouchableNativeFeedback as Bt,VirtualizedList as Ht,YellowBox as zt,LogBox as Ut,DeviceEventEmitter as Wt,useColorScheme as jt,useLocaleContext as Kt,useWindowDimensions as qt}from"react-native-web";import*as h from"react-native-web";import{createElement as $t,forwardRef as Gt}from"react";function v(e){let n=Gt((a,i)=>{let{accessibilityState:r,accessibilityValue:o,...l}=a;for(let s of["busy","checked","disabled","expanded","selected"])r?.[s]!==void 0&&l[`aria-${s}`]===void 0&&(l[`aria-${s}`]=r[s]);for(let[s,u]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))o?.[s]!==void 0&&l[`aria-${u}`]===void 0&&(l[`aria-${u}`]=o[s]);return $t(e,{...l,ref:i})}),t=e.State;return t&&Object.assign(n,{State:t}),n.displayName=e.displayName??e.name??"NativeWebView",n}var Yt=v(h.View),Jt=v(h.Text),Qt=v(h.TextInput),Zt=v(h.TouchableOpacity),Xt=v(h.TouchableHighlight),en=v(h.TouchableWithoutFeedback),tn=v(h.Pressable),nn=v(h.ScrollView),rn=v(h.Modal),an=v(h.Switch),on=v(h.ActivityIndicator),ln=v(h.Button),sn=h.findNodeHandle,un={alert(e,n,t,a){if(typeof document>"u")return;let i=document.createElement("dialog");i.dataset.buoyRoot="",i.setAttribute("aria-label",e),i.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let r=document.createElement("h2");if(r.textContent=e,r.style.cssText="font-size:18px;margin:0 0 12px",i.appendChild(r),n){let u=document.createElement("p");u.textContent=n,u.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",i.appendChild(u)}let o=document.createElement("div");o.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let l=t?.length?t:[{text:"OK"}],s=()=>{i.close?.(),i.remove()};for(let u of l){let f=document.createElement("button");f.type="button",f.textContent=u.text??"OK",f.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${u.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,f.onclick=()=>{s(),u.onPress?.()},o.appendChild(f)}i.addEventListener("cancel",u=>{u.preventDefault(),a?.cancelable!==false&&(s(),a?.onDismiss?.())}),i.appendChild(o),document.body.appendChild(i),i.showModal?i.showModal():i.setAttribute("open","")}};var cn=22,me=new Set(["View","RCTView","ScrollView","RCTScrollView","RCTScrollContentView","SafeAreaView","RCTSafeAreaView","AndroidHorizontalScrollContentView","KeyboardAvoidingView","Pressable","PlatformPressable","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","TouchableNativeFeedback","AnimatedComponent","Wrapper"]),$="TVFocusGuideView";function dn(){return typeof globalThis>"u"?null:globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__??null}function fn(){let e=dn();if(!e)return[];let n=[];try{if(e.renderers&&typeof e.renderers.forEach=="function"&&e.renderers.forEach((t,a)=>{try{let i=e.getFiberRoots?.(a);i&&i.forEach(r=>n.push(r))}catch{}}),n.length===0&&e.getFiberRoots){let t=e.getFiberRoots(1);t&&t.forEach(a=>n.push(a))}}catch{}return n}function gn(e){return e.tag===cn&&e.memoizedState!==null}function hn(e){let n=e.memoizedProps?.activityState;return n===0||n===1||e.memoizedProps?.isPageFocused===false}function G(e){return e?.memoizedProps??e?.pendingProps??null}function be(e){let n=e?.type;return n?typeof n=="string"?n:n.displayName||n.name||null:null}function ve(e){let n=e?._debugOwner||e?.return,t=0;for(;n&&t<30;){t++;let a=be(n);if(a&&!me.has(a)&&typeof n.type!="string")return a;n=n.return}return null}function ye(e){let n=tt(e);if(n)return n;if(!e)return null;let t=e;return t.canonical?.publicInstance?t.canonical.publicInstance:t.canonical&&typeof t.canonical.measure=="function"?t.canonical:typeof t.measure=="function"||typeof t.measureInWindow=="function"?t:null}function we(e){let n=et(e);if(n!==null)return n;if(e==null)return null;let t=e;if(typeof t.__nativeTag=="number")return t.__nativeTag;if(typeof t._nativeTag=="number")return t._nativeTag;if(typeof t.nativeTag=="number")return t.nativeTag;if(t.canonical){if(typeof t.canonical.__nativeTag=="number")return t.canonical.__nativeTag;if(typeof t.canonical._nativeTag=="number")return t.canonical._nativeTag;if(typeof t.canonical.nativeTag=="number")return t.canonical.nativeTag}return null}function pn(e){let n=ye(e.stateNode);if(n)return{instance:n,nativeTag:we(e.stateNode)};let t=[];e.child&&t.push(e.child);let a=0;for(;t.length>0&&a<4e3;){a++;let i=t.pop();if(!i)continue;let r=ye(i.stateNode);if(r)return{instance:r,nativeTag:we(i.stateNode)};i.child&&t.push(i.child),i.sibling&&t.push(i.sibling)}return null}function mn(e){if(typeof e.isTVSelectable=="boolean")return e.isTVSelectable;if(typeof e.focusable=="boolean")return e.focusable;if(typeof e.tvFocusable=="boolean")return e.tvFocusable}function bn(e){let n=typeof e.nextFocusUp=="number",t=typeof e.nextFocusDown=="number",a=typeof e.nextFocusLeft=="number",i=typeof e.nextFocusRight=="number";if(!(!n&&!t&&!a&&!i))return{up:n||void 0,down:t||void 0,left:a||void 0,right:i||void 0}}function Te(e){if(!e)return;let n=t=>{if(typeof t=="string")return t.trim()?t.trim().slice(0,60):void 0;if(typeof t=="number"&&Number.isFinite(t))return String(t)};return n(e.children)??n(e.title)??n(e.label)??void 0}function vn(e,n){let t=[],a=(r,o)=>{if(!r||o>n||t.length>=3)return;if(r!==e){let s=G(r);if(s&&typeof s.onPress=="function")return}let l=Te(G(r));l&&!t.includes(l)&&t.push(l),r.child&&a(r.child,o+1),r!==e&&r.sibling&&a(r.sibling,o)};e.child&&a(e.child,1);let i=t.join(" ").trim();return i?i.slice(0,60):void 0}function yn(e){return new Promise(n=>{let t=false,a=i=>{t||(t=true,n(i))};setTimeout(()=>a(null),1e3);try{typeof e.measureInWindow=="function"?e.measureInWindow((i,r,o,l)=>{a(o>0&&l>0?{x:i,y:r,width:o,height:l}:null)}):typeof e.measure=="function"?e.measure((i,r,o,l,s,u)=>{a(o>0&&l>0&&s!=null&&u!=null?{x:s,y:u,width:o,height:l}:null)}):a(null)}catch{a(null)}})}var Y=new Map;function wn(e,n,t){let a=[{fiber:e,context:n,depth:0}],i=new Set;for(;a.length>0;){let r=a.pop();if(!r)continue;let{fiber:o,depth:l}=r;if(!o||i.has(o)||l>500)continue;if(i.add(o),gn(o)||hn(o)){o.sibling&&a.push({fiber:o.sibling,context:r.context,depth:l});continue}let s=t(o,r.context);o.sibling&&a.push({fiber:o.sibling,context:r.context,depth:l}),o.child&&a.push({fiber:o.child,context:s,depth:l+1})}}function Tn(){let e=fn();if(e.length===0)return[];let n=[],t=new Set;for(let a of e)wn(a.current,{guideTag:null},(i,r)=>{let o=G(i);if(!o)return r;let l=be(i),s=l===$,u=mn(o),f=typeof o.onPress=="function"||typeof o.onLongPress=="function",c=o.hasTVPreferredFocus===true,p=bn(o);if(!(s||u===true||c||!!p||f&&u!==false||nt(i.stateNode)&&i.stateNode.matches('a[href],button,input,select,textarea,[tabindex],[contenteditable="true"]')&&!i.stateNode.matches(':disabled,[inert], [tabindex="-1"]')))return r;let d=pn(i),g=d?.nativeTag??null;if(g===null)return r;let L=s?{guideTag:g}:r;if(t.has(g)){let m=n.find(_e=>_e.node.nativeTag===g);return m&&(u!==void 0&&m.node.focusProps.focusable===void 0&&(m.node.focusProps.focusable=u),c&&(m.node.focusProps.hasTVPreferredFocus=true),p&&!m.node.focusProps.nextFocus&&(m.node.focusProps.nextFocus=p),f&&(m.node.pressable=true),!m.node.testID&&o.testID&&(m.node.testID=o.testID),s&&!m.node.guide&&(m.node.guide=xe(o),m.node.name=$)),L}t.add(g);let Q=l??"Unknown";(!l||me.has(l)||typeof i.type=="string")&&(Q=ve(i)??l??"Unknown");let Ie=o.accessibilityLabel||o["aria-label"]||void 0,Le=Te(o)??(f?vn(i,6):void 0),Oe={nativeTag:g,name:s?$:Q,owner:ve(i)??void 0,testID:o.testID||o["data-testid"]||void 0,label:Ie,text:Le,focusProps:{focusable:u,hasTVPreferredFocus:c||void 0,nextFocus:p},guide:s?xe(o):void 0,guideAncestorTag:r.guideTag??void 0,pressable:f||void 0};return d?.instance&&Y.set(g,d.instance),n.push({node:Oe,instance:d?.instance??null}),L});return n}function xe(e){return{autoFocus:e.autoFocus===true,hasDestinations:Array.isArray(e.destinations)&&e.destinations.length>0,enabled:e.enabled!==false,trap:{up:e.trapFocusUp===true,down:e.trapFocusDown===true,left:e.trapFocusLeft===true,right:e.trapFocusRight===true}}}function z(e){return Math.round(e*1e3)/1e3}var xn=400;async function Se(){Y.clear();let e=Tn();await Promise.all(e.map(async r=>{if(!r.instance)return;let o=await yn(r.instance);o&&(r.node.frame=o)}));let n=pe.get("window"),t=Math.round(n.width)||1,a=Math.round(n.height)||1,i=[];for(let r of e){let o=r.node.frame;if(o){let l=o.x+o.width/2,s=o.y+o.height/2;r.node.onScreen=s>=0&&s<=a&&l>=0&&l<=t,r.node.frame={x:z(o.x/t),y:z(o.y/a),width:z(o.width/t),height:z(o.height/a)}}if(i.push(r.node),i.length>=xn)break}return i.sort((r,o)=>{let l=r.frame?.y??2,s=o.frame?.y??2;return Math.abs(l-s)>.01?l-s:(r.frame?.x??2)-(o.frame?.x??2)}),{screen:{width:t,height:a},nodes:i,scannedAt:Date.now()}}function Sn(e){let n=Y.get(e);if(!n)return{ok:false,reason:"Unknown tag \u2014 rescan and try again."};if(typeof n.requestTVFocus!="function")return{ok:false,reason:"This element exposes no requestTVFocus()."};try{return n.requestTVFocus(),{ok:true}}catch(t){return{ok:false,reason:t?.message??"requestTVFocus() threw."}}}var ke=["up","down","left","right"];function kn(e,n){return`${e}:${n}`}function Ae(e,n,t=3,a=0){let i=new Map;for(let l of e){if(!l.resolved||l.tag===null||l.at<a)continue;let s=kn(l.tag,l.direction);l.movedTo===null?i.set(s,(i.get(s)??0)+1):i.set(s,0)}let r=new Map;for(let l of n)r.set(l.nativeTag,l);let o=[];return i.forEach((l,s)=>{if(l<t)return;let[u,f]=s.split(":"),c=Number(u),p=f;o.push({tag:c,direction:p,attempts:l,atEdge:An(r.get(c),p,n)})}),o.sort((l,s)=>s.attempts-l.attempts)}function An(e,n,t){let a=e?.frame;if(!a)return false;let i=a.x+a.width/2,r=a.y+a.height/2;for(let o of t){if(o.nativeTag===e.nativeTag||o.guide)continue;let l=o.frame;if(!l)continue;let s=l.x+l.width/2,u=l.y+l.height/2;switch(n){case"up":if(u<a.y)return false;break;case"down":if(u>a.y+a.height)return false;break;case"left":if(s<a.x)return false;break;case"right":if(s>a.x+a.width)return false;break}}return true}function En(e){if(e.length===0)return null;let n=1/0,t=1/0,a=-1/0,i=-1/0;for(let r of e)n=Math.min(n,r.x),t=Math.min(t,r.y),a=Math.max(a,r.x+r.width),i=Math.max(i,r.y+r.height);return{x:n,y:t,width:a-n,height:i-t}}function Fn(e,n,t){switch(t){case"up":return n.y<e.y;case"down":return n.y>e.y+e.height;case"left":return n.x<e.x;case"right":return n.x>e.x+e.width;default:return false}}var Pn=2;function Ee(e,n){let t=new Map;for(let r of n)t.set(r.nativeTag,r);let a=new Map;for(let r of e){let o=t.get(r.tag)?.guideAncestorTag??r.tag,l=a.get(o)??{containerTag:o,tags:new Set,directions:new Set};l.tags.add(r.tag),l.directions.add(r.direction),a.set(o,l)}let i=[];return a.forEach(r=>{if(r.directions.size<Pn)return;let o=new Set(r.tags);for(let d of n)d.guideAncestorTag===r.containerTag&&o.add(d.nativeTag);o.add(r.containerTag);let l=t.get(r.containerTag),s=l?.guide&&l.frame?l.frame:En(Array.from(o).map(d=>t.get(d)?.frame).filter(d=>!!d));if(!s)return;let u=0,f=0;for(let d of ke)n.some(g=>{if(g.guide||o.has(g.nativeTag)||!g.frame)return false;let L={x:g.frame.x+g.frame.width/2,y:g.frame.y+g.frame.height/2};return Fn(s,L,d)})&&(f+=1,r.directions.has(d)||(u+=1));if(f===0||u>0)return;let c=l?.guide,p=c!==void 0&&(c.trap.up||c.trap.down||c.trap.left||c.trap.right);i.push({tags:Array.from(r.tags).sort((d,g)=>d-g),containerTag:r.containerTag,directions:ke.filter(d=>r.directions.has(d)),guideTrapTag:p?r.containerTag:void 0})}),i}function Fe(e,n,t=0){let a=new Map;for(let r of n)a.set(r.nativeTag,r);let i=new Map;for(let r of e){let o=r.toTag;if(o===null||r.at<t)continue;let l=a.get(o),s=l?l.guide?"guide":null:n.length>0?"unknown":null;if(!s)continue;let u=i.get(o);u?(u.count+=1,u.at=r.at):i.set(o,{tag:o,reason:s,at:r.at,count:1})}return Array.from(i.values()).sort((r,o)=>o.at-r.at)}function Pe(e,n,t,a,i=0){let r=Ae(n,t,3,i);return{deadEnds:r,traps:Ee(r,t),invisibleStops:Fe(e,t,i),lostCount:a}}function Me(e,n,t,a){let i=new Set(n),r=e.filter(c=>!c.guide),o=r.filter(c=>!i.has(c.nativeTag)).map(c=>c.nativeTag),l=a.length>=12,s=new Set;for(let c of t)c.toTag!==null&&s.add(c.toTag);let u=new Map;for(let c of e)u.set(c.nativeTag,c);let f=l?o.filter(c=>{if(s.has(c))return false;let p=u.get(c);return p?.frame?r.some(d=>d.nativeTag!==c&&i.has(d.nativeTag)&&Mn(p,d)):false}):[];return{focusables:r.length,visited:r.filter(c=>i.has(c.nativeTag)).length,unvisited:o,suspectedUnreachable:f,meaningful:l}}var Ve=.12;function Mn(e,n){let t=e.frame,a=n.frame;if(!t||!a)return false;let i=t.x<a.x+a.width&&a.x<t.x+t.width,r=t.y<a.y+a.height&&a.y<t.y+t.height;return!!(i&&Math.max(t.y-(a.y+a.height),a.y-(t.y+t.height))<=Ve||r&&Math.max(t.x-(a.x+a.width),a.x-(t.x+t.width))<=Ve)}function Ce(e,n,t=[]){let a=[];for(let r of n)r.fromTag!==e||r.direction===null||a.push({at:r.at,direction:r.direction,to:r.toTag});for(let r of t)r.tag!==e||!r.resolved||r.movedTo!==null||a.push({at:r.at,direction:r.direction,to:null});a.sort((r,o)=>r.at-o.at);let i={};for(let r of a)i[r.direction]=r.to;return i}var De=1.5*1024*1024,Vn=500;q&&(de(),ge());var y=null,J=false,M=null,V=0;function Ne(){let e=new Map;for(let n of y?.nodes??[])e.set(n.nativeTag,n);return e}async function U(){if(J)return y;J=true;try{return y=await Se(),y}catch{return y}finally{J=false,qe()}}function Cn(){if(V===0)return;let{currentTag:e}=H();e!==null&&(Ne().has(e)||M===null&&(M=setTimeout(()=>{M=null,U()},Vn)))}function Dn(e,n){let t=[],a=0;for(let i=e.length-1;i>=0;i--){let r=ee(e[i],n).bytes;if(a+r>n&&t.length>0)break;t.push(e[i]),a+=r}return t.reverse(),t}function Nn(){let e=H(),n=y?.nodes??[],t=Je(),a=Pe(e.transitions,e.probes,n,e.lostCount,y?.scannedAt??0),i=Me(n,e.visited,e.transitions,e.probes),r=Ne(),o=ee(n,De).bytes,l=Dn(e.transitions,Math.max(64*1024,De-o)),s=a.deadEnds.filter(u=>!u.atEdge).length+a.traps.length+a.invisibleStops.length+(a.lostCount>0?1:0);return{supported:q||N==="web",platform:N,observer:t.status,observerReason:t.reason,keysListening:Xe(),tracking:e.tracking,presence:e.presence,current:e.currentTag===null?null:{tag:e.currentTag,node:r.get(e.currentTag)??null,since:e.currentSince??Date.now(),edges:Ce(e.currentTag,e.transitions,e.probes)},transitions:l,focusables:n,screen:y?.screen??null,scannedAt:y?.scannedAt??null,flags:a,coverage:i,stats:{focusables:i.focusables,visited:i.visited,transitions:e.transitionCount,flagged:s},capturedAt:Date.now()}}var In={version:1,getSnapshot(){return Nn()},subscribe(e){V+=1,V===1&&(N==="web"&&(de(),ge()),U());let n=se(()=>{Cn(),e()}),t=0,a=null,i=()=>{if(t+=1,(y?.nodes.length??0)>0||t>=100){a=null;return}U(),a=setTimeout(i,100)};return a=setTimeout(i,100),()=>{n(),a!==null&&clearTimeout(a),V=Math.max(0,V-1),V===0&&(M!==null&&(clearTimeout(M),M=null),N==="web"&&(Ye(),Ze()))}},actions:{async rescan(){return{ok:true,focusables:(await U())?.nodes.length??0}},clearHistory(){return oe(),{ok:true}},setTracking(e){return le(e?.enabled!==false),{tracking:H().tracking}},focusElement(e){let n=e?.nativeTag;return typeof n!="number"?{ok:false,reason:"nativeTag is required."}:!q&&N!=="web"?{ok:false,reason:"Not a TV build \u2014 there is no focus engine."}:Sn(n)}}};export{oe as clearHistory,Me as computeCoverage,Ae as detectDeadEnds,Pe as detectFlags,Fe as detectInvisibleStops,Ee as detectTraps,In as focusInspectorSyncAdapter,H as getState,Ce as observedEdges,ae as recordBlur,re as recordFocus,ie as recordKey,Ke as resetStore,Se as scanFocusables,le as setTracking,se as subscribe};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/focus-inspector",
3
- "version": "7.0.55",
3
+ "version": "7.0.57",
4
4
  "description": "Observe focus transitions and discovered focusable elements in React Native TV apps. Review diagnostics in Buoy Desktop.",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -12,7 +12,7 @@
12
12
  ],
13
13
  "sideEffects": false,
14
14
  "dependencies": {
15
- "@buoy-gg/shared-ui": "^7.0.55"
15
+ "@buoy-gg/shared-ui": "^7.0.57"
16
16
  },
17
17
  "peerDependencies": {
18
18
  "react": "*"