@ycodium-ai/plugin-devices 0.2.5854 → 0.2.5891

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/assets/ui.js CHANGED
@@ -1,4 +1,4 @@
1
- var na=`/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */
1
+ var fa=`/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */
2
2
  @layer properties, theme, base, components, utilities;
3
3
  @layer properties;
4
4
  @layer utilities {
@@ -90,9 +90,6 @@ var na=`/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */
90
90
  width: 100%;
91
91
  height: 100%;
92
92
  }
93
- .h-1\\.5:where(:scope, *) {
94
- height: calc(var(--spacing, 0.25rem) * 1.5);
95
- }
96
93
  .h-9:where(:scope, *) {
97
94
  height: calc(var(--spacing, 0.25rem) * 9);
98
95
  }
@@ -361,12 +358,6 @@ var na=`/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */
361
358
  background-color: color-mix(in oklab, var(--info) 10%, transparent);
362
359
  }
363
360
  }
364
- .bg-muted:where(:scope, *) {
365
- background-color: var(--muted);
366
- }
367
- .bg-primary:where(:scope, *) {
368
- background-color: var(--primary);
369
- }
370
361
  .bg-warning:where(:scope, *) {
371
362
  background-color: var(--warning);
372
363
  }
@@ -494,6 +485,10 @@ var na=`/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */
494
485
  --tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
495
486
  box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
496
487
  }
488
+ .ring:where(:scope, *) {
489
+ --tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);
490
+ box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
491
+ }
497
492
  .outline:where(:scope, *) {
498
493
  outline-style: var(--tw-outline-style);
499
494
  outline-width: 1px;
@@ -557,7 +552,7 @@ var na=`/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */
557
552
  }
558
553
  }
559
554
  }
560
- `;var So=window.__ycodiumPluginHost.react;var{Activity:Kr,Children:Xr,Component:$r,Fragment:jr,Profiler:Zr,PureComponent:Jr,StrictMode:Qr,Suspense:Yr,__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE:el,__COMPILER_RUNTIME:al,act:tl,cache:ol,cacheSignal:rl,captureOwnerStack:ll,cloneElement:sl,createContext:Fa,createElement:ne,createRef:dl,forwardRef:He,isValidElement:nl,lazy:ul,memo:il,startTransition:fl,unstable_useCacheRefresh:cl,use:pl,useActionState:ml,useCallback:Y,useContext:Oa,useDebugValue:gl,useDeferredValue:Ll,useEffect:B,useEffectEvent:hl,useId:xl,useImperativeHandle:Il,useInsertionEffect:Cl,useLayoutEffect:Ea,useMemo:ue,useOptimistic:Sl,useReducer:vl,useRef:G,useState:g,useSyncExternalStore:Ua,useTransition:yl,version:wl}=So;var qa=Fa(null),Ne=qa.Provider;function E(){let e=Oa(qa);if(e===null)throw new Error("The devices panel has not been registered.");return e}var Ha=window.__ycodiumPluginHost.modules?.["@ycodium-ai/plugin-api/ui"];if(!Ha)throw new Error("This plugin needs a newer Ycodium app. Update the app.");var{HOST_TEAM_VIEW_PREFIX:Pl,PLUGIN_UI_BRIDGE_VERSION:Al,PLUGIN_UI_FLOATING_VIEW_PROP:Na,PLUGIN_UI_GLOBAL_KEY:Tl,PLUGIN_UI_HOST_CAPABILITIES:Bl,PLUGIN_UI_HOST_COMMAND_PALETTE_UNAVAILABLE_MESSAGE:Ml,PLUGIN_UI_HOST_UPGRADE_MESSAGE:Rl,TEAM_VIEW_KEY_PATTERN:Fl,communicationRecordStage:Ol,defineTeamView:El,isTeamViewKey:Ul,pluginUiHostHasCapability:ce}=Ha;var vo="deviceFloat",Ve="device",j=e=>`${e.hostId}\0${e.id}`;function Se(e){let a={hostId:e.hostId,deviceId:e.id,platform:e.platform};return{viewId:vo,key:j(e),title:e.name,props:{...a},sourceSize:e.platform==="ios"?{width:9,height:19.5}:{width:9,height:20},...e.platform==="android"?{cornerRatio:.14}:{}}}function Va(e){let a=e.orientation==="landscape_left"||e.orientation==="landscape_right",t=Math.max(e.width,e.height),o=Math.min(e.width,e.height);return a?{width:t,height:o}:{width:o,height:t}}var ua=new Map,ia=new Set,Ge=(e,a)=>`${e}\0${a}`;function Ga(e,a){return Ua(t=>(ia.add(t),()=>{ia.delete(t)}),()=>ua.get(Ge(e,a))??null)}function ze(e,a,t){let o=Ge(e,a);if((ua.get(o)??null)!==t){ua.set(o,t);for(let l of ia)l()}}var fa=new Set;function ca(e,a,t,o=!0){let l=`${Ge(e,a)}\0${t}`;o?fa.add(l):fa.delete(l)}function za(e){let a=new Set,t=[];for(let o of e.sessions){if(o.threadId!==e.threadId)continue;let l=e.devices.find(n=>n.hostId===o.hostId&&n.id===o.deviceId);if(l===void 0)continue;let d=j(l);if(a.add(d),e.previous===null||e.previous.has(d))continue;let s=`${Ge(e.environmentId,e.threadId)}\0${d}`;fa.delete(s)||t.push(l)}return{seen:a,opened:t}}var _e="ycodium-devices-ui";function A(e){return(a=>ne(E().ui[e],{...a,className:`${_e} ${typeof a.className=="string"?a.className:""}`}))}var S=A("Button"),z=A("Spinner"),pe=A("Switch"),_a=A("Tooltip"),Wa=A("TooltipPopup"),Ka=A("TooltipTrigger"),We=A("Menu"),Ke=A("MenuPopup"),ve=A("MenuItem"),Xa=A("MenuSeparator"),Xe=A("MenuTrigger"),$a=A("MenuRadioGroup"),ja=A("MenuRadioItem"),ae=A("Input"),Za=A("Textarea"),pa=A("Select"),ma=A("SelectTrigger"),ga=A("SelectValue"),La=A("SelectPopup"),ha=A("SelectItem"),$e=A("Collapsible"),je=A("CollapsibleTrigger"),Ze=A("CollapsiblePanel"),Ja=A("ToggleGroup"),Qa=A("Toggle"),Ya=A("Popover"),et=A("PopoverTrigger"),at=A("PopoverPopup");var{jsx:r,jsxs:f,Fragment:Z}=window.__ycodiumPluginHost.jsxRuntime;function ee(e){return f("div",{className:"flex size-full flex-col items-center justify-center gap-3 p-6 text-center",children:[e.stage==="error"?null:r(z,{size:"sm"}),f("div",{className:"space-y-1",children:[r("p",{className:"text-sm font-medium text-foreground",children:e.name}),e.description?r("p",{className:"text-xs text-muted-foreground",children:e.description}):null]}),r("p",{role:e.stage==="error"?"alert":"status",className:e.stage==="error"?"max-w-sm whitespace-pre-wrap break-words text-xs text-destructive-foreground":"max-w-sm text-xs text-muted-foreground",children:e.message}),e.children]})}var ye=class{decoder=new TextDecoder;rawDecoder=new TextDecoder("utf-8",{ignoreBOM:!0});pending="";raw="";data=[];eventName="";lastId=null;push(a){let t=[];return this.scan(a,!1,(o,l)=>{l!==void 0&&t.push(l)}),t}pushBlocks(a){let t=[];return this.scan(a,!0,(o,l)=>t.push({raw:o,event:l})),t}scan(a,t,o){let l=this.decoder.decode(a,{stream:!0}),d=this.pending+l;if(this.rawDecoder!==void 0){let n=this.rawDecoder.decode(a,{stream:!0});t&&(this.raw+=n.slice(0,n.length-l.length)),d.length>0&&(this.rawDecoder=void 0,d.charCodeAt(0)===65279&&(t&&(this.raw+=d[0]),d=d.slice(1)))}let s=0;for(let n=0;n<d.length;n++){let u=d[n];if(u!==`
555
+ `;var vo=window.__ycodiumPluginHost.react;var{Activity:$r,Children:jr,Component:Zr,Fragment:Jr,Profiler:Qr,PureComponent:Yr,StrictMode:el,Suspense:al,__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE:tl,__COMPILER_RUNTIME:ol,act:rl,cache:ll,cacheSignal:sl,captureOwnerStack:dl,cloneElement:nl,createContext:Ua,createElement:ue,createRef:ul,forwardRef:Ge,isValidElement:il,lazy:fl,memo:cl,startTransition:pl,unstable_useCacheRefresh:ml,use:gl,useActionState:Ll,useCallback:Y,useContext:qa,useDebugValue:hl,useDeferredValue:xl,useEffect:M,useEffectEvent:Il,useId:Cl,useImperativeHandle:Sl,useInsertionEffect:yl,useLayoutEffect:Ha,useMemo:ie,useOptimistic:vl,useReducer:wl,useRef:V,useState:g,useSyncExternalStore:Na,useTransition:bl,version:kl}=vo;var Ga=Ua(null),Ve=Ga.Provider;function O(){let e=qa(Ga);if(e===null)throw new Error("The devices panel has not been registered.");return e}var Va=window.__ycodiumPluginHost.modules?.["@ycodium-ai/plugin-api/ui"];if(!Va)throw new Error("This plugin needs a newer Ycodium app. Update the app.");var{HOST_TEAM_VIEW_PREFIX:Tl,PLUGIN_UI_BRIDGE_VERSION:Bl,PLUGIN_UI_FLOATING_VIEW_PROP:za,PLUGIN_UI_GLOBAL_KEY:Ml,PLUGIN_UI_HOST_CAPABILITIES:Rl,PLUGIN_UI_HOST_COMMAND_PALETTE_UNAVAILABLE_MESSAGE:Fl,PLUGIN_UI_HOST_UPGRADE_MESSAGE:El,TEAM_VIEW_KEY_PATTERN:Ol,communicationRecordStage:Ul,defineTeamView:ql,isTeamViewKey:Hl,pluginUiHostHasCapability:pe}=Va;var wo="deviceFloat",ze="device",j=e=>`${e.hostId}\0${e.id}`;function Se(e){let a={hostId:e.hostId,deviceId:e.id,platform:e.platform};return{viewId:wo,key:j(e),title:e.name,props:{...a},sourceSize:e.platform==="ios"?{width:9,height:19.5}:{width:9,height:20},...e.platform==="android"?{cornerRatio:.14}:{}}}function _a(e){let a=e.orientation==="landscape_left"||e.orientation==="landscape_right",t=Math.max(e.width,e.height),o=Math.min(e.width,e.height);return a?{width:t,height:o}:{width:o,height:t}}var ca=new Map,pa=new Set,_e=(e,a)=>`${e}\0${a}`;function Wa(e,a){return Na(t=>(pa.add(t),()=>{pa.delete(t)}),()=>ca.get(_e(e,a))??null)}function We(e,a,t){let o=_e(e,a);if((ca.get(o)??null)!==t){ca.set(o,t);for(let l of pa)l()}}var ma=new Set;function ga(e,a,t,o=!0){let l=`${_e(e,a)}\0${t}`;o?ma.add(l):ma.delete(l)}function Ka(e){let a=new Set,t=[];for(let o of e.sessions){if(o.threadId!==e.threadId)continue;let l=e.devices.find(n=>n.hostId===o.hostId&&n.id===o.deviceId);if(l===void 0)continue;let d=j(l);if(a.add(d),e.previous===null||e.previous.has(d))continue;let s=`${_e(e.environmentId,e.threadId)}\0${d}`;ma.delete(s)||t.push(l)}return{seen:a,opened:t}}var Ke="ycodium-devices-ui";function P(e){return(a=>ue(O().ui[e],{...a,className:`${Ke} ${typeof a.className=="string"?a.className:""}`}))}var y=P("Button"),Xe=P("Checkbox"),Xa=P("Meter"),z=P("Spinner"),$a=P("Switch"),ja=P("Tooltip"),Za=P("TooltipPopup"),Ja=P("TooltipTrigger"),$e=P("Menu"),je=P("MenuPopup"),ye=P("MenuItem"),Qa=P("MenuSeparator"),Ze=P("MenuTrigger"),Ya=P("MenuRadioGroup"),et=P("MenuRadioItem"),te=P("Input"),at=P("Textarea"),La=P("Select"),ha=P("SelectTrigger"),xa=P("SelectValue"),Ia=P("SelectPopup"),Ca=P("SelectItem"),Je=P("Collapsible"),Qe=P("CollapsibleTrigger"),Ye=P("CollapsiblePanel"),ve=P("ToggleGroup"),we=P("Toggle"),tt=P("Popover"),ot=P("PopoverTrigger"),rt=P("PopoverPopup");var{jsx:r,jsxs:f,Fragment:Z}=window.__ycodiumPluginHost.jsxRuntime;function ee(e){return f("div",{className:"flex size-full flex-col items-center justify-center gap-3 p-6 text-center",children:[e.stage==="error"?null:r(z,{size:"sm"}),f("div",{className:"space-y-1",children:[r("p",{className:"text-sm font-medium text-foreground",children:e.name}),e.description?r("p",{className:"text-xs text-muted-foreground",children:e.description}):null]}),r("p",{role:e.stage==="error"?"alert":"status",className:e.stage==="error"?"max-w-sm whitespace-pre-wrap break-words text-xs text-destructive-foreground":"max-w-sm text-xs text-muted-foreground",children:e.message}),e.children]})}var be=class{decoder=new TextDecoder;rawDecoder=new TextDecoder("utf-8",{ignoreBOM:!0});pending="";raw="";data=[];eventName="";lastId=null;push(a){let t=[];return this.scan(a,!1,(o,l)=>{l!==void 0&&t.push(l)}),t}pushBlocks(a){let t=[];return this.scan(a,!0,(o,l)=>t.push({raw:o,event:l})),t}scan(a,t,o){let l=this.decoder.decode(a,{stream:!0}),d=this.pending+l;if(this.rawDecoder!==void 0){let n=this.rawDecoder.decode(a,{stream:!0});t&&(this.raw+=n.slice(0,n.length-l.length)),d.length>0&&(this.rawDecoder=void 0,d.charCodeAt(0)===65279&&(t&&(this.raw+=d[0]),d=d.slice(1)))}let s=0;for(let n=0;n<d.length;n++){let u=d[n];if(u!==`
561
556
  `&&u!=="\r")continue;if(u==="\r"&&n===d.length-1)break;let i=d.slice(s,n);u==="\r"&&d[n+1]===`
562
557
  `&&n++,t&&(this.raw+=d.slice(s,n+1));let c=this.line(i);i===""&&(o(this.raw,c),this.raw=""),s=n+1}this.pending=d.slice(s)}flush(){let a=this.raw+this.pending+this.decoder.decode();return this.raw="",this.pending="",this.data=[],this.eventName="",a}line(a){if(a===""){let d=this.data.length>0?{event:this.eventName||"message",data:this.data.join(`
563
- `),id:this.lastId}:void 0;return this.data=[],this.eventName="",d}if(a.startsWith(":"))return;let t=a.indexOf(":"),o=t===-1?a:a.slice(0,t),l=t===-1?"":a.slice(t+1);l.startsWith(" ")&&(l=l.slice(1)),o==="data"?this.data.push(l):o==="event"?this.eventName=l:o==="id"&&!l.includes("\0")&&(this.lastId=l)}};async function Je(e,a,t){let o=e.body;if(!o)throw new Error("The response has no body to stream.");let l=o.getReader(),d=()=>{l.cancel().catch(()=>{})};if(t?.aborted)return d();t?.addEventListener("abort",d,{once:!0});try{for(;;){let{done:s,value:n}=await l.read();if(s||t?.aborted)return;a(n)}}catch(s){if(t?.aborted)return;throw s}finally{t?.removeEventListener("abort",d)}}function Qe(e,a,t){let o=e;if(a+t.length>e.length){let l=e.length;for(;l<a+t.length;)l*=2;o=new Uint8Array(l),o.set(e.subarray(0,a))}return o.set(t,a),o}async function tt(e,a,t){if(!e.ok)throw await e.body?.cancel().catch(()=>{}),new Error(`Event stream failed (${e.status}).`);let o=new ye;await Je(e,l=>{for(let d of o.push(l))a(d)},t)}var me=e=>e==="ios"?"/vendor/serve-sim":"/vendor/serve-emu";var yo=1e3,wo=500,Ye=(e,a,t)=>`${me(e.platform)}${a}${t?`?${new URLSearchParams(t).toString()}`:""}`,ot=async(e,a,t)=>{let o=await e.transport.fetch(a,t?{signal:t}:void 0);if(!o.ok)throw new Error(`${o.status} ${o.statusText}`);return await o.json()},J=e=>typeof e=="object"&&e!==null,X=(e,a)=>typeof e=="number"&&Number.isFinite(e)?e:a,bo=e=>{let a=e[0],t=J(a)&&J(a.frame)?a.frame:null,o=Math.max(1,X(t?.width,1)),l=Math.max(1,X(t?.height,1)),d=[],s=(n,u)=>{if(d.length>=wo||!J(n)||!J(n.frame))return;let i=n.frame,c=X(i.width,0),L=X(i.height,0);!(Math.abs(c-o)<.5&&Math.abs(L-l)<.5)&&c>0&&L>0&&d.push({id:typeof n.AXUniqueId=="string"?n.AXUniqueId:u,label:typeof n.AXLabel=="string"?n.AXLabel:"",role:typeof n.type=="string"?n.type:"",x:X(i.x,0)/o,y:X(i.y,0)/l,width:c/o,height:L/l}),(Array.isArray(n.children)?n.children:[]).forEach((p,h)=>s(p,`${u}.${h}`))};return e.forEach((n,u)=>s(n,String(u))),d},rt=e=>J(e)&&typeof e.error=="string"?e.error:"Unexpected accessibility payload.";async function st(e,a){if(e.platform==="ios"){let u=await ot(e,Ye(e,`/helper/${encodeURIComponent(e.deviceId)}/ax`),a);return Array.isArray(u)?{elements:bo(u),errors:[]}:{elements:[],errors:[rt(u)]}}let t=await ot(e,Ye(e,"/api/accessibility",{device:e.deviceId}),a);if(!J(t)||!Array.isArray(t.nodes))return{elements:[],errors:[rt(t)]};let o=t.nodes.filter(u=>J(u)&&J(u.bounds)),l=o[0]?.bounds,d=Math.max(1,X(l?.right,1)),s=Math.max(1,X(l?.bottom,1));return{elements:o.slice(1).flatMap(u=>{let i=u.bounds,c=X(i.left,0),L=X(i.top,0),v=(X(i.right,c)-c)/d,C=(X(i.bottom,L)-L)/s,p=typeof u.text=="string"?u.text:"",h=typeof u.contentDescription=="string"?u.contentDescription:"",T=p||h;if(v>=.95&&C>=.9)return[];if(!T&&u.clickable!==!0)return[];let m=typeof u.className=="string"?u.className:"";return[{id:String(u.id??""),label:T,role:m.split(".").at(-1)??"",x:c/d,y:L/s,width:v,height:C}]}),errors:[]}}var dt=(e,a,t)=>{let o=new AbortController,l=null,d=()=>{e.transport.fetch(a,{signal:o.signal}).then(s=>tt(s,n=>{try{t(JSON.parse(n.data))}catch{}},o.signal)).catch(()=>{}).finally(()=>{o.signal.aborted||(l=setTimeout(d,yo))})};return d(),()=>{o.abort(),l!==null&&clearTimeout(l)}};function nt(e,a){return e.platform!=="ios"?()=>{}:dt(e,Ye(e,"/appstate",{device:e.deviceId}),t=>{if(J(t)){if(t.bundleId===null||t.bundleId===""){a(null);return}typeof t.bundleId=="string"&&a({id:t.bundleId,...typeof t.pid=="number"?{pid:t.pid}:{},...typeof t.isReactNative=="boolean"?{isReactNative:t.isReactNative}:{}})}})}var lt=e=>!J(e)||typeof e.id!="number"?null:{id:e.id,timestamp:typeof e.timestamp=="string"?e.timestamp:"",kind:typeof e.kind=="string"?e.kind:"",summary:typeof e.summary=="string"?e.summary:typeof e.msg=="string"?e.msg:""};function ut(e,a){return e.platform!=="ios"?()=>{}:dt(e,Ye(e,"/api/event-log/events",{device:e.deviceId,limit:"100"}),t=>{if(!J(t))return;if(Array.isArray(t.events)){a(t.events.flatMap(l=>lt(l)??[]),!0);return}let o=lt(t.event);o&&a([o],!1)})}function D(){return{t:E().i18n.usePluginTranslation()}}var ko=1397050709,xa=16,Do=1;function aa(e){if(e.length<4)return"avc1.42E01E";let a=t=>t.toString(16).padStart(2,"0");return`avc1.${a(e[1])}${a(e[2])}${a(e[3])}`}function it(e){let a=new Uint8Array(e);if(a.byteLength>xa){let t=new DataView(e,0,xa);if(t.getUint32(0,!1)===ko&&t.getUint8(4)===1){let o=t.getBigUint64(8,!1);return{data:a.subarray(xa),isKey:(t.getUint8(5)&Do)!==0,timestamp:o<=BigInt(Number.MAX_SAFE_INTEGER)?Number(o):null}}}return{data:a,isKey:null,timestamp:null}}var ft=e=>{try{return JSON.parse(e)?.type==="video-session"}catch{return!1}};function ct(e){let a=!1,t=null,o=e.length,l=0;for(;l+2<o;){if(e[l]===0&&e[l+1]===0){let d=0;if(e[l+2]===1?d=3:l+3<o&&e[l+2]===0&&e[l+3]===1&&(d=4),d){let s=e[l+d]&31;s===7&&!t&&(t=e.subarray(l+d)),s===5&&(a=!0),l+=d+1;continue}}l++}return{isKey:a,sps:t}}var Po={1:"description",2:"keyframe",3:"delta",4:"seed"},ea=class{buffer=new Uint8Array(64*1024);length=0;push(a){this.buffer=Qe(this.buffer,this.length,a),this.length+=a.length;let t=[],o=0;for(;this.length-o>=4;){let d=new DataView(this.buffer.buffer,this.buffer.byteOffset+o,4).getUint32(0,!1);if(this.length-o-4<d)break;if(d>=1){let s=Po[this.buffer[o+4]];s&&t.push({type:s,payload:this.buffer.slice(o+5,o+4+d)})}o+=4+d}return o>0&&(this.buffer.copyWithin(0,o,this.length),this.length-=o),t}reset(){this.length=0}};var Ao={Enter:40,Escape:41,Backspace:42,Tab:43,Space:44,Minus:45,Equal:46,BracketLeft:47,BracketRight:48,Backslash:49,Semicolon:51,Quote:52,Backquote:53,Comma:54,Period:55,Slash:56,Delete:76,ArrowRight:79,ArrowLeft:80,ArrowDown:81,ArrowUp:82,ControlLeft:224,ShiftLeft:225,AltLeft:226,MetaLeft:227,ControlRight:228,ShiftRight:229,AltRight:230,MetaRight:231};function pt(e){return/^Key[A-Z]$/.test(e)?4+(e.charCodeAt(3)-65):/^Digit[1-9]$/.test(e)?30+(e.charCodeAt(5)-49):e==="Digit0"?39:Ao[e]??null}var mt={ArrowUp:19,ArrowDown:20,ArrowLeft:21,ArrowRight:22,Tab:61,Enter:66,Backspace:67,Delete:112,Home:122,End:123,PageUp:92,PageDown:93};function Ia(e){if(e.stopped)return;let a=d=>{e.configuring=!1,e.connecting(d),e.scheduleRetry("input",()=>Ia(e))},t;try{t=e.transport.connect(`${e.vendor}/ws?device=${e.device}&frame-meta=1`)}catch(d){e.events.onInputConnected(!1,d.message),a(d.message);return}e.socket=t;let o=[],l=!1;t.onopen=()=>{e.stopped||e.socket!==t||(e.connecting(),e.events.onInputConnected(!0))},t.onmessage=d=>{if(e.stopped||e.socket!==t)return;if(typeof d.data=="string"){ft(d.data)&&(e.closeDecoder(),e.configuring=!1,o=[],l=!1,e.connecting());return}let s=it(d.data),n=!e.videoDecoder||e.videoDecoder.state!=="configured",i=s.isKey===null||s.isKey&&n?ct(s.data):null,c=s.isKey??i?.isKey??!1,L={isKey:c,data:s.data,timestamp:s.timestamp};if(e.configuring){o.push(L);return}if(i?.sps&&n){e.configuring=!0,o=[L];let v=e.decoderEpoch,C=()=>!e.stopped&&e.socket===t;e.configureDecoder({codec:aa(i.sps)},C).then(p=>{if(!C()||v!==e.decoderEpoch)return;e.configuring=!1,e.awaitingKeyframe=!0;let h=o;if(o=[],!!p){for(let T of h)e.decode(T.isKey,T.data,T.timestamp);e.awaitingKeyframe&&e.requestKeyframe()}});return}if(n){!c&&!l&&(l=!0,e.requestKeyframe());return}e.decode(c,s.data,s.timestamp)},t.onclose=d=>{e.socket===t&&(e.socket=null,e.closeDecoder(),!e.stopped&&(e.events.onInputConnected(!1,d.reason||`closed ${d.code}`),a(d.reason||void 0)))},t.onerror=()=>t.close()}function gt(e){return{sendTouch(a,t,o){let l=a==="begin"?"down":a==="move"?"move":"up";e.send(JSON.stringify({type:"touch",action:l,x:t,y:o}))},sendKey(a,t){if(t!=="down")return;if(a.key==="Escape")return e.send(JSON.stringify({type:"back"}));let o=mt[a.key];if(o!==void 0)return e.send(JSON.stringify({type:"key",keycode:o}));a.key.length===1&&!a.metaKey&&!a.ctrlKey&&e.send(JSON.stringify({type:"text",text:a.key}))},pressButton(a){let t=a==="appSwitcher"?"recents":a;(t==="home"||t==="back"||t==="recents"||t==="power")&&e.send(JSON.stringify({type:t}))},rotate(){},setOrientation(){}}}function Lt(e){return{present(a,t,o){let l=e.getContext("2d");return l?((e.width!==t||e.height!==o)&&(e.width=t,e.height=o),l.drawImage(a,0,0,t,o),!0):!1}}}var To=13,ht=10,xt=45,Bo=16*1024*1024,It=new TextEncoder,Ct=new TextDecoder;function vt(e){if(!e)return null;let a=/boundary=(?:"([^"]+)"|([^;\s]+))/i.exec(e),t=a?.[1]??a?.[2];return t?t.startsWith("--")?t:`--${t}`:null}function St(e,a,t,o){let l=o-a.length;for(let d=t;d<=l;d++){if(e[d]!==a[0])continue;let s=1;for(;s<a.length&&e[d+s]===a[s];)s++;if(s===a.length)return d}return-1}var ta=class{delimiter;buffer=new Uint8Array(64*1024);length=0;pos=0;state="boundary";contentLength=null;scanFrom=0;constructor(a){this.delimiter=a?It.encode(a):null}push(a){this.append(a);let t=[];for(;;){if(this.state==="done"){this.pos=this.length=0;break}if(this.state==="boundary"){if(!this.readBoundary())break}else if(this.state==="headers"){if(!this.readHeaders())break}else{let o=this.readBody();if(!o)break;o.length>0&&t.push(o)}}if(this.length-this.pos>Bo)throw new Error("MJPEG part is too large.");return this.pos>0&&(this.buffer.copyWithin(0,this.pos,this.length),this.length-=this.pos,this.scanFrom=Math.max(0,this.scanFrom-this.pos),this.pos=0),t}append(a){this.buffer=Qe(this.buffer,this.length,a),this.length+=a.length}lineEnd(a){return this.buffer.subarray(0,this.length).indexOf(ht,a)}readBoundary(){let a=this.buffer;if(!this.delimiter)for(;;){let s=this.lineEnd(this.pos);if(s===-1)return!1;let n=Ct.decode(a.subarray(this.pos,s)).trim();if(this.pos=s+1,n.startsWith("--"))return this.delimiter=It.encode(n),this.state="headers",!0}let t=this.delimiter,o=St(a,t,this.pos,this.length);if(o===-1)return this.pos=Math.max(this.pos,this.length-t.length+1),!1;let l=o+t.length;if(l+2>this.length)return this.pos=o,!1;if(a[l]===xt&&a[l+1]===xt)return this.state="done",!0;let d=this.lineEnd(l);return d===-1?(this.pos=o,!1):(this.pos=d+1,this.state="headers",!0)}readHeaders(){let a=this.pos,t=null;for(;;){let o=this.lineEnd(a);if(o===-1)return!1;let l=Ct.decode(this.buffer.subarray(a,o)).replace(/\r$/,"");if(a=o+1,l==="")break;let d=l.indexOf(":");if(d>0&&l.slice(0,d).trim().toLowerCase()==="content-length"){let s=Number.parseInt(l.slice(d+1).trim(),10);Number.isFinite(s)&&s>=0&&(t=s)}}return this.pos=a,this.contentLength=t,this.scanFrom=a,this.state="body",!0}readBody(){if(this.contentLength!==null){if(this.length-this.pos<this.contentLength)return null;let o=this.buffer.slice(this.pos,this.pos+this.contentLength);return this.pos+=this.contentLength,this.state="boundary",o}let a=this.delimiter,t=Math.max(this.scanFrom,this.pos+1);for(;;){let o=St(this.buffer,a,t,this.length);if(o===-1)return this.scanFrom=Math.max(this.pos,this.length-a.length),null;if(this.buffer[o-1]!==ht){t=o+1;continue}let l=o-1;l>this.pos&&this.buffer[l-1]===To&&l--;let d=this.buffer.slice(this.pos,Math.max(l,this.pos));return this.pos=o,this.state="boundary",d}}};async function Mo(e,a,t){let o=new ta(vt(e.headers.get("content-type")));await Je(e,l=>{for(let d of o.push(l))a(d)},t)}function we(e){e.stopped||e.mjpeg||(e.mjpeg=!0,e.controller?.abort(),e.controller=null,e.closeDecoder(),e.connecting(),e.events.onMjpegFallback?.(),yt(e))}var Ca=e=>`${e.vendor}/helper/${e.device}/stream.mjpeg`;async function yt(e){let a=e.generation,t=++e.videoGeneration,o=new AbortController;e.controller=o;let l=()=>!e.stopped&&e.generation===a&&e.videoGeneration===t&&e.controller===o,d=null,s=!1,n=async()=>{s=!0;try{for(;d;){let i=d;d=null;try{let c=await e.createBitmap(new Blob([i],{type:"image/jpeg"}));try{l()&&e.paint(c,c.width,c.height)}finally{c.close()}}catch{}}}finally{s=!1}},u;try{let i=await e.transport.fetch(Ca(e),{signal:o.signal});if(!l()){await i.body?.cancel();return}if(!i.ok||!i.body)throw new Error(`stream ${i.status}`);if(await Mo(i,c=>{l()&&(d=c,s||n())},o.signal),!l())return;u="Device stream ended."}catch(i){if(!l())return;u=i.message}l()&&(e.controller=null,o.abort(),e.connecting(u),e.scheduleRetry("video",()=>{yt(e)}))}var Ro=1e3,Sa=15e3,Fo=16667,Oo=8,Eo=e=>typeof e=="object"&&e!==null&&"present"in e;function bt(e){let{transport:a,platform:t,events:o}=e,l=Eo(e.output)?e.output:Lt(e.output),d=n=>e.globals?.[n]??globalThis[n],s={platform:t,transport:a,events:o,preferMjpeg:e.preferMjpeg===!0,vendor:me(t),device:encodeURIComponent(e.deviceId),stopped:!0,generation:0,videoGeneration:0,decoderEpoch:0,socket:null,controller:null,primeController:null,videoDecoder:null,timestamp:0,awaitingKeyframe:!0,screen:null,firstFrame:!1,configuring:!1,mjpeg:!1,frameTimer:null,videoReadTimer:null,retryTimers:new Map,webCodecs(){let n=d("VideoDecoder"),u=d("EncodedVideoChunk");return n&&u?{VideoDecoder:n,EncodedVideoChunk:u}:null},createBitmap(n){let u=d("createImageBitmap");return u?u(n):Promise.reject(new Error("createImageBitmap is unavailable."))},setStatus(n,u){s.stopped||o.onStatus(n,u)},fail(n){s.stopped||(s.stop(),o.onInputConnected(!1,n),o.onStatus("error",n))},connecting(n){s.firstFrame=!1,s.frameTimer===null&&(s.frameTimer=setTimeout(()=>s.fail("No video received from the device. Reconnect to try again."),Sa)),s.setStatus("connecting",n)},paint(n,u,i){if(!s.stopped){if(t==="android"&&(s.screen?.width!==u||s.screen.height!==i)&&(s.screen={width:u,height:i,orientation:u>i?"landscape_left":"portrait"},o.onScreen(s.screen)),!l.present(n,u,i)){s.fail("Could not display the device stream. Reconnect to try again.");return}s.firstFrame||(s.firstFrame=!0,s.frameTimer!==null&&clearTimeout(s.frameTimer),s.frameTimer=null,s.setStatus("streaming"))}},closeDecoder(){s.decoderEpoch++,s.configuring=!1;try{s.videoDecoder?.close()}catch{}s.videoDecoder=null,s.awaitingKeyframe=!0},recoverDecoder(){t==="ios"?we(s):(s.closeDecoder(),s.connecting("Video decoder restarted."),s.requestKeyframe())},async configureDecoder(n,u=()=>!s.stopped){let i=s.webCodecs();if(!i)return!1;let c=s.decoderEpoch,L={...n,optimizeForLatency:!0},v=await i.VideoDecoder.isConfigSupported(L).catch(()=>({supported:!1}));if(!u()||c!==s.decoderEpoch)return!1;if(!v.supported)return t==="android"&&s.fail(`This browser cannot decode ${n.codec}.`),!1;try{return(!s.videoDecoder||s.videoDecoder.state==="closed")&&(s.videoDecoder=Uo(s,i)),s.videoDecoder.configure(L),!0}catch(C){return t==="android"&&s.fail(`Video decoder: ${C.message}`),!1}},decode(n,u,i){let c=s.videoDecoder,L=s.webCodecs();if(!(!c||c.state!=="configured"||!L)){if(s.awaitingKeyframe){if(!n)return;s.awaitingKeyframe=!1}if(c.decodeQueueSize>Oo){s.recoverDecoder();return}try{c.decode(new L.EncodedVideoChunk({type:n?"key":"delta",timestamp:i??s.timestamp,data:u})),s.timestamp+=Fo}catch{s.recoverDecoder()}}},requestKeyframe(){t==="android"&&s.socket?.readyState===1&&s.socket.send(JSON.stringify({type:"reset-video",ack:!1}))},scheduleRetry(n,u){s.stopped||s.retryTimers.has(n)||s.retryTimers.set(n,setTimeout(()=>{s.retryTimers.delete(n),u()},Ro))},send(n){!s.stopped&&s.socket?.readyState===1&&s.socket.send(n)},stop(){if(s.stopped)return;s.stopped=!0,s.generation++,s.videoGeneration++,s.mjpeg=!1,s.frameTimer!==null&&clearTimeout(s.frameTimer),s.frameTimer=null,s.videoReadTimer!==null&&clearTimeout(s.videoReadTimer),s.videoReadTimer=null;for(let u of s.retryTimers.values())clearTimeout(u);s.retryTimers.clear(),s.primeController?.abort(),s.primeController=null,s.controller?.abort(),s.controller=null;let n=s.socket;s.socket=null,n?.close(),s.closeDecoder()}};return s}function Uo(e,a){let t=e.videoGeneration,o=()=>e.platform!=="ios"||t===e.videoGeneration,l=new a.VideoDecoder({output:d=>{try{e.videoDecoder===l&&o()&&e.paint(d,d.displayWidth,d.displayHeight)}finally{d.close()}},error:()=>{e.stopped||e.videoDecoder!==l||!o()||e.recoverDecoder()}});return l}var qo=3,Ho=4,No=6,kt=7,Vo=13,Go=130,zo=2e3,_o=new TextEncoder,Wo=new TextDecoder,oa=["portrait","landscape_left","portrait_upside_down","landscape_right"],Ko=new Set(oa);function ge(e,a){let t=_o.encode(JSON.stringify(a)),o=new Uint8Array(1+t.length);return o[0]=e,o.set(t,1),o}function Xo(e){if(typeof e!="object"||e===null)return null;let{width:a,height:t,orientation:o,screenId:l}=e;if(typeof a!="number"||!Number.isFinite(a)||a<=0||typeof t!="number"||!Number.isFinite(t)||t<=0||typeof o!="string"||!Ko.has(o))return null;let d={width:a,height:t,orientation:o};return typeof l=="number"?{...d,screenId:l}:d}function Dt(e,a){At(e),a?Pt(e):we(e)}async function Pt(e){let a=e.generation,t=++e.videoGeneration,o=new ea,l=new AbortController;e.controller=l;let d=()=>!e.stopped&&e.generation===a&&e.videoGeneration===t&&e.controller===l,s;try{let n=await e.transport.fetch(`${e.vendor}/helper/${e.device}/stream.avcc`,{signal:l.signal});if(!d()){await n.body?.cancel();return}if(!n.ok||!n.body)throw new Error(`stream ${n.status}`);let u=n.body.getReader();for(;;){let i=setTimeout(()=>{d()&&e.fail("Device stream stopped receiving video. Reconnect to try again.")},Sa);e.videoReadTimer=i;let c;try{c=await u.read()}finally{clearTimeout(i),e.videoReadTimer===i&&(e.videoReadTimer=null)}let{done:L,value:v}=c;if(!d())return;if(L)break;for(let C of o.push(v))switch(C.type){case"seed":e.createBitmap(new Blob([C.payload],{type:"image/jpeg"})).then(p=>{try{d()&&e.paint(p,p.width,p.height)}finally{p.close()}}).catch(()=>{});break;case"description":{e.awaitingKeyframe=!0;let p=await e.configureDecoder({codec:aa(C.payload),description:C.payload},d);if(!d())return;if(!p){if(await u.cancel().catch(()=>{}),!d())return;we(e);return}break}case"keyframe":case"delta":e.decode(C.type==="keyframe",C.payload);break}}}catch(n){if(!d())return;s=n.message}d()&&(e.controller=null,l.abort(),e.closeDecoder(),e.connecting(s),e.scheduleRetry("video",()=>{Pt(e)}))}async function $o(e,a){let t=new AbortController;e.primeController=t;let o=setTimeout(()=>t.abort(),zo);try{let l=await e.transport.fetch(Ca(e),{signal:t.signal});if(e.stopped||e.generation!==a)return;await l.body?.getReader().read()}catch{}finally{clearTimeout(o),t.abort(),e.primeController===t&&(e.primeController=null)}}async function At(e){if(e.stopped)return;let a=e.generation;if(await $o(e,a),e.stopped||e.generation!==a)return;let t=()=>e.scheduleRetry("input",()=>{At(e)}),o;try{o=e.transport.connect(`${e.vendor}/helper/ws?device=${e.device}`)}catch(l){e.events.onInputConnected(!1,l.message),t();return}e.socket=o,o.onopen=()=>{e.stopped||e.socket!==o||(o.send(ge(Vo,{enabled:!1})),e.events.onInputConnected(!0))},o.onmessage=l=>{if(e.stopped||e.socket!==o||typeof l.data=="string")return;let d=new Uint8Array(l.data);if(!(d.length<1||d[0]!==Go))try{let s=Xo(JSON.parse(Wo.decode(d.subarray(1))));s&&(e.screen=s,e.events.onScreen(s))}catch{}},o.onclose=l=>{e.socket===o&&(e.socket=null,!e.stopped&&(e.events.onInputConnected(!1,l.reason||(l.code===1006?"input socket refused":`closed ${l.code}`)),t()))},o.onerror=()=>o.close()}function jo(e,a,t){let o=e.screen;if(!o||o.width>o.height)return{x:a,y:t};switch(o.orientation){case"landscape_left":return{x:t,y:1-a};case"landscape_right":return{x:1-t,y:a};case"portrait_upside_down":return{x:1-a,y:1-t};default:return{x:a,y:t}}}function Tt(e){return{sendTouch(a,t,o){e.send(ge(qo,{type:a,...jo(e,t,o)}))},sendKey(a,t){let o=pt(a.code);o!==null&&e.send(ge(No,{type:t,usage:o}))},pressButton(a){let t=a==="home"?"home":a==="appSwitcher"?"app_switcher":a==="power"?"lock":null;t&&e.send(ge(Ho,{button:t}))},rotate(){let a=e.screen?.orientation??"portrait",t=oa[(oa.indexOf(a)+1)%oa.length];e.send(ge(kt,{orientation:t}))},setOrientation(a){e.send(ge(kt,{orientation:a}))}}}function Bt(e){let a=bt(e),t=e.platform==="ios"?Tt(a):gt(a);return{start:()=>{if(!a.stopped)return;a.stopped=!1,a.generation++,a.configuring=!1,a.connecting();let l=a.webCodecs()!==null&&!(e.platform==="ios"&&a.preferMjpeg);e.platform==="ios"?Dt(a,l):l?Ia(a):a.fail("This browser cannot decode the Android stream (WebCodecs unavailable).")},stop:a.stop,isMjpeg:()=>a.mjpeg,...t}}var Zo=56,Jo=2e3;function Qo(e,a,t,o=0){let l=Math.max(0,a-o);if(l===0||t===0)return{width:0,height:0};let d={width:t*e,height:t};return d.width<=l?d:{width:l,height:l/e}}function Yo(e,a){if(!a)return e==="ios"?9/19.5:9/20;let t=a.orientation==="landscape_left"||a.orientation==="landscape_right",o=Math.max(a.width,a.height),l=Math.min(a.width,a.height);return t?o/l:l/o}function er(e,a){if(e!=="ios"||!a||a.width>a.height)return 0;switch(a.orientation){case"landscape_left":return 90;case"landscape_right":return-90;case"portrait_upside_down":return 180;default:return 0}}var ar=()=>typeof navigator<"u"&&/iPhone|iPad|iPod/.test(navigator.userAgent);function ra(e){let{t:a}=D(),t=G(null),o=G(null),[l,d]=g("connecting"),[s,n]=g(),[u,i]=g(!1),[c,L]=g(null),[v,C]=g({connected:!1}),{onHandle:p,onStreaming:h,onScreen:T,transport:m,platform:y,deviceId:R}=e;B(()=>T?.(c),[T,c]),B(()=>{let I=t.current;if(!I)return;let k=Bt({transport:m,platform:y,deviceId:R,output:I,preferMjpeg:ar(),events:{onStatus:(O,N)=>{d(O),n(N),O==="streaming"&&i(!0),h(O==="streaming")},onScreen:L,onInputConnected:(O,N)=>{C({connected:O,...N?{detail:N}:{}}),p({pressButton:k.pressButton,rotate:k.rotate,inputConnected:O})}}});return o.current=k,C({connected:!1}),k.start(),p({pressButton:k.pressButton,rotate:k.rotate,inputConnected:!1}),()=>{k.stop(),o.current=null,p(null),h(!1),i(!1),L(null)}},[R,p,h,y,m]);let F=G(null),[_,P]=g({width:0,height:0});B(()=>{let I=F.current;if(!I)return;let k=()=>{let N=I.getBoundingClientRect();P(de=>de.width===N.width&&de.height===N.height?de:{width:N.width,height:N.height})};k();let O=new ResizeObserver(k);return O.observe(I),()=>O.disconnect()},[]);let b=e.withControls?Zo:0,U=ue(()=>Qo(Yo(y,c),_.width,_.height,b),[_,b,y,c]),W=er(y,c),q=W===90||W===-90?{width:U.height,height:U.width,left:(U.width-U.height)/2,top:(U.height-U.width)/2,transform:`rotate(${W}deg)`}:{width:U.width,height:U.height,...W?{transform:`rotate(${W}deg)`}:{}},[K,$]=g([]);B(()=>{if(!e.axOverlay)return;let I=null,k=null,O=!1,N=async()=>{I=new AbortController;try{let de=await st({transport:m,platform:y,deviceId:R},I.signal);O||$(de.elements)}catch{}O||(k=setTimeout(()=>{N()},Jo))};return N(),()=>{O=!0,I?.abort(),k&&clearTimeout(k),$([])}},[R,y,e.axOverlay,m]);let V=G(!1),x=I=>{let k=I.currentTarget.getBoundingClientRect(),O=(I.clientX-k.left)/k.width,N=(I.clientY-k.top)/k.height;return{x:Math.min(1,Math.max(0,O)),y:Math.min(1,Math.max(0,N))}},H=I=>{if(!V.current)return;V.current=!1;let{x:k,y:O}=x(I);o.current?.sendTouch("end",k,O)};return f("div",{ref:F,className:"relative flex size-full min-h-0 min-w-0 items-center justify-center overflow-hidden",style:b?{paddingRight:b}:void 0,tabIndex:0,role:"application","aria-label":a(y==="ios"?"stream.iosScreen":"stream.androidScreen"),onKeyDown:I=>{I.target===I.currentTarget&&(I.metaKey&&!["r","R"].includes(I.key)||(I.preventDefault(),o.current?.sendKey(I.nativeEvent,"down")))},onKeyUp:I=>{I.target===I.currentTarget&&o.current?.sendKey(I.nativeEvent,"up")},children:[f("div",{className:"relative touch-none select-none",style:{width:U.width,height:U.height},onPointerDown:I=>{I.currentTarget.setPointerCapture(I.pointerId),I.currentTarget.parentElement?.focus(),V.current=!0;let{x:k,y:O}=x(I);o.current?.sendTouch("begin",k,O)},onPointerMove:I=>{if(!V.current)return;let{x:k,y:O}=x(I);o.current?.sendTouch("move",k,O)},onPointerUp:H,onPointerCancel:H,children:[r("canvas",{ref:t,className:"absolute top-0 left-0",style:q}),K.length>0?r("div",{className:"pointer-events-none absolute inset-0","aria-hidden":!0,children:K.map(I=>r("div",{className:"absolute border border-info/80 bg-info/10",style:{left:`${I.x*100}%`,top:`${I.y*100}%`,width:`${I.width*100}%`,height:`${I.height*100}%`},children:I.label?r("span",{className:"absolute -top-3.5 left-0 max-w-full truncate rounded-sm bg-info px-1 text-ui-2xs leading-3.5 text-white",children:I.label}):null},I.id))}):null]}),l==="streaming"&&!v.connected?r("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex justify-center p-2",children:r("span",{className:"rounded-md bg-background/85 px-2 py-1 text-xs text-muted-foreground",children:v.detail?a("stream.inputLostDetail",{detail:v.detail}):a("stream.inputLost")})}):null,l==="connecting"&&u?r("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex justify-center p-2",children:r("span",{className:"rounded-md bg-background/85 px-2 py-1 text-xs text-muted-foreground",children:a("stream.connecting")})}):null,l==="error"||l!=="streaming"&&!u?r("div",{className:"absolute inset-0 bg-background",children:r(ee,{name:e.deviceName,description:e.deviceDescription,stage:l==="error"?"error":"connecting",message:l==="error"?s??a("stream.failed"):a("stream.connecting"),children:l==="error"?r(S,{size:"sm",variant:"outline",onClick:()=>{o.current?.stop(),o.current?.start()},children:a("stream.reconnect")}):null})}):null]})}var tr={hosts:[],hostStatuses:{},devices:[],sessions:[],bootingDevices:[],revision:0};function Le(e){let t=E().commands.useSubscription("state",{},{environmentId:e});return{state:t.data??tr,loaded:t.data!==null,error:t.error,unavailable:t.isUnavailable}}function te(){let e=E();return Y((a,t,o={})=>e.commands.invoke(a,o,{environmentId:t}),[e])}var he="local",la=class extends Error{code;constructor(a,t,o){super(t,o),this.name="DeviceError",this.code=a}};var Mt="hub";function sa(e){let a=E(),[t,o]=g({status:"connecting"});return B(()=>{let l=a.network;if(!ce(a,"network")||l===void 0){o({status:"failed",message:null});return}let d=!1;return o({status:"connecting"}),l.client(e).then(s=>{d||o({status:"ready",transport:{fetch:(n,u)=>s.fetch(Mt,n,{...u,instance:he}),connect:n=>s.connect(Mt,n,{instance:he})}})},s=>{d||o({status:"failed",message:s instanceof Error?s.message:String(s)})}),()=>{d=!0}},[a,e]),t}var Rt=()=>{};function Ft(e){let{environmentId:a,threadId:t,hostId:o,deviceId:l,platform:d}=e,s=e[Na],n=E(),{t:u}=D(),{state:i,loaded:c}=Le(a),L=sa(a),v=ue(()=>({environmentId:a,threadId:t}),[a,t]),C=i.devices.find(y=>y.hostId===o&&y.id===l),p=i.sessions.some(y=>y.threadId===t&&y.hostId===o&&y.deviceId===l);B(()=>{c&&!p&&n.floating?.close(v,s.key)},[n,s.key,c,p,v]),B(()=>(s.setOpenInPanel(()=>{ze(a,t,s.key),n.floating?.openPanel(v,Ve),n.floating?.close(v,s.key)}),()=>s.setOpenInPanel(null)),[n,a,s,v,t]);let h=Y(y=>s.reportSourceSize(y===null?null:Va(y)),[s]),T=C?.name??l,m=C?.version??d;return L.status!=="ready"?r(ee,{name:T,description:m,stage:L.status==="failed"?"error":"connecting",message:L.status==="failed"?L.message??u("workspace.needsNewerApp"):u("stream.connecting")}):r(ra,{transport:L.transport,platform:d,deviceId:l,deviceName:T,deviceDescription:m,axOverlay:!1,withControls:!1,onHandle:Rt,onStreaming:Rt,onScreen:h})}var da=(...e)=>e.filter((a,t,o)=>!!a&&a.trim()!==""&&o.indexOf(a)===t).join(" ").trim();var Ot=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var Et=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,t,o)=>o?o.toUpperCase():t.toLowerCase());var va=e=>{let a=Et(e);return a.charAt(0).toUpperCase()+a.slice(1)};var Ut={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var qt=e=>{for(let a in e)if(a.startsWith("aria-")||a==="role"||a==="title")return!0;return!1};var Ht=He(({color:e="currentColor",size:a=24,strokeWidth:t=2,absoluteStrokeWidth:o,className:l="",children:d,iconNode:s,...n},u)=>ne("svg",{ref:u,...Ut,width:a,height:a,stroke:e,strokeWidth:o?Number(t)*24/Number(a):t,className:da("lucide",l),...!d&&!qt(n)&&{"aria-hidden":"true"},...n},[...s.map(([i,c])=>ne(i,c)),...Array.isArray(d)?d:[d]]));var w=(e,a)=>{let t=He(({className:o,...l},d)=>ne(Ht,{ref:d,iconNode:a,className:da(`lucide-${Ot(va(e))}`,`lucide-${e}`,o),...l}));return t.displayName=va(e),t};var or=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],be=w("camera",or);var rr=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],ke=w("chevron-down",rr);var lr=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],De=w("chevron-left",lr);var sr=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],oe=w("ellipsis",sr);var dr=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],re=w("house",dr);var nr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Pe=w("info",nr);var ur=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],Ae=w("moon",ur);var ir=[["path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4",key:"daa4of"}],["rect",{width:"10",height:"7",x:"12",y:"13",rx:"2",key:"1nb8gs"}]],Te=w("picture-in-picture-2",ir);var fr=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Be=w("power",fr);var cr=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],xe=w("rotate-ccw",cr);var pr=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Me=w("rotate-cw",pr);var mr=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],Re=w("sliders-horizontal",mr);var gr=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Ie=w("smartphone",gr);var Lr=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Fe=w("square",Lr);var hr=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],Oe=w("sun",hr);var xr=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],Ee=w("type",xr);var Ir=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Q=w("x",Ir);function Cr(e,a){let t=o=>a(o==="hub"?"versions.hubName":"versions.agentName");return e.status==="starting"?a("panel.startingHost"):e.status!=="installing"?e.message??"":e.tool&&e.toVersion?e.fromVersion?a("panel.updatingTool",{tool:t(e.tool),from:e.fromVersion,to:e.toVersion}):a("panel.installingTool",{tool:t(e.tool),to:e.toVersion}):a("panel.installing")}function ya(){let{t:e}=D();return a=>Cr(a,e)}function Nt(e){let{t:a}=D(),t=ya(),[o,l]=g(!1),d=e.detail;return!d||d.status==="ready"||d.status==="idle"?null:d.status==="failed"?f("div",{role:"alert",className:"flex items-start gap-2 border-b bg-destructive/5 px-3 py-2 text-xs",children:[f("div",{className:"min-w-0 flex-1 space-y-0.5",children:[r("p",{className:"font-medium text-destructive-foreground",children:a("panel.hostFailed")}),d.message?r("p",{className:"whitespace-pre-wrap break-words text-muted-foreground",children:d.message}):null]}),f(S,{size:"xs",variant:"outline",disabled:o,onClick:()=>{l(!0),e.onRetry().finally(()=>l(!1))},children:[o?r(z,{size:"xs"}):r(Me,{}),a(o?"panel.retrying":"panel.retry")]})]}):f("div",{role:"status",className:"flex items-center gap-2 border-b px-3 py-2 text-xs text-muted-foreground",children:[r(z,{size:"xs"}),r("span",{className:"min-w-0 flex-1",children:t(d)})]})}var wa=["hub","agent"],ba=e=>e!==void 0&&!e.installedVersions.includes(e.requiredVersion);function Vt(e){let{t:a}=D(),t=te(),o=E(),[l,d]=g(null),[s,n]=g(null),[u,i]=g(!1),c=e.host?.tools,L=e.busy||l!==null,v=p=>{d(p),n(null),i(!1),(p==="check"?t("inspect",e.environmentId):t("updateTool",e.environmentId,{tool:p})).then(()=>i(p==="check")).catch(()=>{n(a(p==="check"?"versions.checkFailed":"versions.updateFailed")),p!=="check"&&o.notify(a("versions.updateFailed"),"error")}).finally(()=>d(null))},C=p=>p??a("versions.none");return f(Ya,{children:[f(et,{render:r(S,{size:"xs",variant:"ghost","aria-label":a("versions.title")}),children:[r(Pe,{}),a("versions.title"),wa.some(p=>ba(c?.[p]))?r("span",{className:"size-1.5 rounded-full bg-warning","aria-hidden":!0}):null]}),r(at,{side:"bottom",align:"start",className:"w-80",children:f("div",{className:"space-y-3 text-xs",children:[wa.map(p=>{let h=c?.[p];return f("section",{className:"space-y-1",children:[r("h4",{className:"font-medium text-foreground",children:a(p==="hub"?"versions.hubName":"versions.agentName")}),f("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-muted-foreground",children:[r("dt",{children:a("versions.required")}),r("dd",{className:"font-mono",children:C(h?.requiredVersion)}),r("dt",{children:a("versions.installed")}),r("dd",{className:"font-mono",children:h&&h.installedVersions.length>0?h.installedVersions.join(", "):a("versions.none")}),r("dt",{children:a("versions.running")}),r("dd",{className:"font-mono",children:C(h?.runningVersion)})]}),ba(h)?f(S,{size:"xs",variant:"outline",disabled:L,onClick:()=>v(p),children:[l===p?r(z,{size:"xs"}):null,a("versions.updateTo",{version:h?.requiredVersion??""})]}):null]},p)}),c===void 0?r("p",{className:"text-muted-foreground",children:a("versions.unknown")}):null,wa.some(p=>ba(c?.[p]))?r("p",{className:"text-muted-foreground",children:a("versions.pendingPolicy")}):null,s?r("p",{role:"alert",className:"text-destructive-foreground",children:s}):null,f("div",{className:"flex items-center justify-between gap-2 border-t pt-2",children:[r("p",{role:"status",className:"text-muted-foreground",children:a(u?"versions.checked":"versions.checkHint")}),f(S,{size:"xs",variant:"ghost",disabled:L,onClick:()=>v("check"),children:[l==="check"?r(z,{size:"xs"}):null,a("versions.check")]})]})]})})]})}var ka=[{api:"35",name:"Android 15"},{api:"30",name:"Android 11"}],Gt=ka[0].api;var Ue=e=>e>=1073741824?`${(e/1073741824).toFixed(2)} GB`:`${(e/1048576).toFixed(1)} MB`;function zt(e){let{phase:a,receivedBytes:t,totalBytes:o,bytesPerSecond:l}=e,d=a==="download"&&t!==void 0&&o?{received:t,total:o}:null,s=d&&l?(d.total-d.received)/l:null;return{titleKey:`environment.stages.${a??"starting"}`,component:e.component??"",percent:d?Math.floor(d.received/d.total*100):null,transferred:d?{done:Ue(d.received),total:Ue(d.total)}:null,speed:d&&l?Ue(l):null,minutesLeft:s===null?null:Math.ceil(s/60),slow:s!==null&&s>1200}}var _t=e=>e.source==="private"&&e.ready;function Wt(e){return e.supported?e.freeBytes!==null&&e.freeBytes<e.requiredFreeBytes?"environment.notEnoughSpace":null:e.reasonCode?`environment.reasons.${e.reasonCode}`:"environment.unsupported"}function Kt(e,a){return e.cacheBytes>0||a==="android"&&e.deviceDataBytes>0}function Xt(e){let{t:a}=D(),t=zt(e.progress),o=[t.transferred?a("environment.transferred",t.transferred):null,t.speed?a("environment.speed",{speed:t.speed}):null,t.minutesLeft===null?null:a("environment.timeLeft",{minutes:String(t.minutesLeft)})].filter(l=>l!==null);return f("div",{role:"status",className:"space-y-2",children:[f("p",{className:"flex items-center gap-2 font-medium text-foreground",children:[r(z,{size:"xs"}),a(t.titleKey,{component:t.component})]}),t.percent===null?null:r("div",{role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t.percent,className:"h-1.5 overflow-hidden rounded-full bg-muted",children:r("div",{className:"h-full rounded-full bg-primary",style:{width:`${t.percent}%`}})}),o.length>0?r("p",{children:o.join(" \xB7 ")}):null,t.slow?r("p",{className:"text-warning-foreground",children:a("environment.slowDownload")}):null,r("p",{children:a("environment.continues")}),r(S,{size:"sm",variant:"outline",disabled:e.cancelling,onClick:e.onCancel,children:a("environment.cancel")})]})}function $t(e){let{t:a}=D(),t=te(),o=E(),d=o.commands.useSubscription("environmentProgress",{},{environmentId:e.environmentId}).data,[s,n]=g(!1),[u,i]=g("android"),[c,L]=g(""),[v,C]=g(""),[p,h]=g(null),[T,m]=g(!1),[y,R]=g(!1),[F,_]=g(!1),[P,b]=g(null),[U,W]=g(!1),[fe,q]=g(!1),[K,$]=g(void 0),V=d?.status==="working",x=P!==null||V,H=d&&d.id!==K?d:null;B(()=>{(V||H?.status==="failed")&&n(!0),H?.status==="done"&&H.plan?.platform===u&&h(H.plan)},[H,u,V]);let I=()=>{h(null),m(!1),R(!1),_(!1),q(!1),$(d?.id)},k=async(M,xo={})=>{b(M),W(!1),q(!1),$(d?.id);try{let Io=await t(M,e.environmentId,{platform:u,directory:c,version:v,...xo});M==="cleanupEnvironment"?h(await t("environmentPlan",e.environmentId,{platform:u,directory:c,version:v})):M!=="prepareEnvironment"&&h(Io),q(M==="cleanupEnvironment")}catch{W(!0),o.notify(a("environment.failed"),"error")}finally{b(null)}},O=p?Wt(p):null,N=M=>M===null?a("environment.unknownSize"):Ue(M),de=p!==null&&_t(p);return f($e,{open:s,onOpenChange:n,className:"w-full text-left",children:[r(je,{render:r(S,{variant:"outline",size:"sm",className:"w-full"}),children:a("environment.title")}),r(Ze,{children:f("div",{className:"space-y-3 rounded-md border p-3 text-xs",children:[V?r(Xt,{progress:d,cancelling:P==="cancelEnvironment",onCancel:()=>{b("cancelEnvironment"),t("cancelEnvironment",e.environmentId,{}).catch(()=>{W(!0),o.notify(a("environment.failed"),"error")}).finally(()=>b(null))}}):f(Z,{children:[r("p",{children:a("environment.description")}),e.iosSupported?r("div",{className:"flex gap-2",children:["android","ios"].map(M=>r(S,{size:"sm",variant:u===M?"default":"outline",disabled:x,onClick:()=>{i(M),C(""),I()},children:a(M==="ios"?"panel.platformIos":"panel.platformAndroid")},M))}):null,f("label",{className:"block space-y-1",children:[r("span",{children:a("environment.directory")}),r(ae,{value:c,disabled:x,onChange:M=>{L(M.target.value),I()},placeholder:a("environment.defaultDirectory")})]}),r("p",{children:a("environment.directoryHint")}),u==="android"?f("div",{className:"space-y-1",children:[r("span",{children:a("environment.androidVersion")}),r("div",{className:"flex flex-wrap gap-2",children:ka.map(M=>r(S,{size:"sm",variant:(v||Gt)===M.api?"default":"outline",disabled:x,onClick:()=>{C(M.api),I()},children:a("environment.androidVersionOption",{name:M.name,api:M.api})},M.api))})]}):f("label",{className:"block space-y-1",children:[r("span",{children:a("environment.iosVersion")}),r(ae,{value:v,disabled:x,onChange:M=>{C(M.target.value),I()},placeholder:a("environment.iosVersionPlaceholder")})]}),r(S,{size:"sm",variant:"outline",disabled:x,onClick:()=>{k("environmentPlan")},children:a("environment.inspect")}),p?f("div",{className:"space-y-2",children:[f("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 break-all",children:[r("dt",{children:a("environment.source")}),r("dd",{children:a(`environment.sources.${p.source}`)}),r("dt",{children:a("environment.version")}),r("dd",{children:p.version||a("environment.versionRequired")}),r("dt",{children:a("environment.location")}),r("dd",{children:p.root}),p.existingSdkRoot?f(Z,{children:[r("dt",{children:a("environment.existingSdk")}),r("dd",{children:p.existingSdkRoot})]}):null,r("dt",{children:a("environment.download")}),r("dd",{children:p.downloadBytes===0?a("environment.nothingToDownload"):N(p.downloadBytes)}),r("dt",{children:a("environment.free")}),r("dd",{children:N(p.freeBytes)}),r("dt",{children:a("environment.required")}),r("dd",{children:N(p.requiredFreeBytes)})]}),p.source==="external"?r("p",{children:a("environment.external")}):null,p.reasonCode&&p.supported?r("p",{role:"status",children:a(`environment.reasons.${p.reasonCode}`)}):null,r("a",{className:"underline",href:p.guidanceUrl,target:"_blank",rel:"noreferrer",children:a("environment.guide")}),u==="ios"?r("p",{children:a("environment.appleOwnership")}):r("p",{children:a("environment.privateOwnership")}),de?r("p",{role:"status",className:"font-medium text-foreground",children:a("environment.ready")}):f(Z,{children:[r("ul",{children:p.licenses.map(M=>r("li",{children:r("a",{className:"underline",href:M.url,target:"_blank",rel:"noreferrer",children:a(u==="ios"?"environment.appleLicense":"environment.androidLicense")})},M.url))}),f("label",{className:"flex items-center gap-2",children:[r(pe,{checked:T,disabled:x,onCheckedChange:m}),r("span",{children:a("environment.acceptLicense")})]}),u==="ios"?f("label",{className:"flex items-center gap-2",children:[r(pe,{checked:y,disabled:x,onCheckedChange:R}),r("span",{children:a("environment.confirmApple")})]}):null,O?r("p",{role:"alert",className:"font-medium text-warning-foreground",children:a(O)}):null,r(S,{size:"sm",disabled:x||!p.supported||!T||u==="ios"&&(!y||!v)||p.freeBytes===null||p.freeBytes<p.requiredFreeBytes,onClick:()=>{k("prepareEnvironment",{acceptLicenses:T,confirmAppleInstall:y})},children:a("environment.prepare")})]}),Kt(p,u)?f("div",{className:"space-y-2 border-t pt-2",children:[r("p",{children:a("environment.retention")}),r(S,{size:"sm",variant:"outline",disabled:x||p.cacheBytes===0,onClick:()=>{k("cleanupEnvironment",{category:"cache",confirm:!0})},children:a("environment.cleanCache",{size:N(p.cacheBytes)})}),u==="android"?f(Z,{children:[r("p",{children:a("environment.deviceData",{size:N(p.deviceDataBytes)})}),f("label",{className:"flex items-center gap-2",children:[r(pe,{checked:F,disabled:x,onCheckedChange:_}),r("span",{children:a("environment.confirmData")})]}),r(S,{size:"sm",variant:"destructive",disabled:x||!F||p.deviceDataBytes===0,onClick:()=>{k("cleanupEnvironment",{category:"devices",confirm:F})},children:a("environment.cleanDevices")})]}):null]}):null]}):null]}),P!==null&&!V?f("p",{role:"status",className:"flex items-center gap-2",children:[r(z,{size:"xs"}),a("environment.working")]}):null,U?r("p",{role:"alert",className:"text-destructive-foreground",children:a("environment.failed")}):null,H?.status==="failed"?f("div",{role:"alert",className:"space-y-1 text-destructive-foreground",children:[r("p",{children:a("environment.prepareFailed")}),H.message?r("p",{className:"whitespace-pre-wrap break-words text-muted-foreground",children:H.message}):null]}):null,H?.status==="cancelled"?r("p",{role:"status",children:a("environment.cancelled")}):null,fe?r("p",{role:"status",children:a("environment.cleaned")}):null]})})]})}var jt=["small","default","large","extra-large"],Sr=e=>jt.includes(e);function Zt(e){let{t:a}=D(),{handle:t,controls:o}=e,l=o.detail?.settings,d=!t?.inputConnected,s=l?.appearance==="dark"?"light":"dark",n=u=>a(u==="small"?"rail.textSmall":u==="default"?"rail.textDefault":u==="large"?"rail.textLarge":"rail.textExtraLarge");return r("aside",{"aria-label":a("rail.label"),className:"pointer-events-none absolute inset-y-0 right-0 z-10 flex w-14 flex-col items-center justify-center gap-2 overflow-y-auto py-3 pr-2",children:f("div",{className:"pointer-events-auto flex shrink-0 flex-col items-center gap-1 rounded-full border border-border/50 bg-background/80 p-2 shadow-sm",children:[r(le,{label:a("rail.home"),disabled:d,onClick:()=>t?.pressButton("home"),children:r(re,{})}),e.platform==="android"?f(Z,{children:[r(le,{label:a("rail.back"),disabled:d,onClick:()=>t?.pressButton("back"),children:r(De,{})}),r(le,{label:a("rail.recents"),disabled:d,onClick:()=>t?.pressButton("recents"),children:r(Fe,{})}),f(We,{children:[r(Xe,{render:r(S,{size:"icon-sm",variant:"ghost","aria-label":a("rail.rotate"),disabled:o.disabled}),children:r(xe,{})}),f(Ke,{side:"left",children:[r(ve,{onClick:()=>{o.act({type:"setOrientation",value:"portrait"})},children:a("rail.portrait")}),r(ve,{onClick:()=>{o.act({type:"setOrientation",value:"landscape_left"})},children:a("rail.landscape")})]})]})]}):r(le,{label:a("rail.rotate"),disabled:d,onClick:()=>t?.rotate(),children:r(xe,{})}),r(vr,{}),r(le,{label:a(s==="dark"?"rail.toDark":"rail.toLight"),disabled:o.disabled||!l?.appearance,onClick:()=>{o.act({type:"setAppearance",value:s})},children:l?.appearance==="dark"?r(Oe,{}):r(Ae,{})}),f(We,{children:[r(Xe,{render:r(S,{size:"icon-sm",variant:"ghost","aria-label":a("rail.textSize"),title:a("rail.textSize"),disabled:o.disabled||!l?.textSize}),children:r(Ee,{})}),r(Ke,{side:"left",children:r($a,{value:l?.textSize??"",onValueChange:u=>{Sr(u)&&o.act({type:"setTextSize",value:u})},children:jt.map(u=>r(ja,{value:u,children:n(u)},u))})})]}),r(le,{label:a("rail.tools"),pressed:e.toolsOpen,onClick:e.onTools,children:r(Re,{})}),r(le,{label:e.screenshotPending?a("rail.capturing"):a("rail.screenshot"),disabled:!e.streaming||e.screenshotPending,onClick:e.onScreenshot,children:r(be,{})}),e.onFloat?r(le,{label:a("rail.float"),onClick:e.onFloat,children:r(Te,{})}):null,f(We,{children:[r(Xe,{render:r(S,{size:"icon-sm",variant:"ghost","aria-label":a("rail.more"),title:a("rail.more")}),children:r(oe,{})}),f(Ke,{side:"left",align:"end",children:[f(ve,{onClick:e.onClose,children:[r(Q,{}),a("rail.closePanel")]}),r(Xa,{}),f(ve,{variant:"destructive",onClick:e.onPowerOff,children:[r(Be,{}),a("rail.powerOff")]})]})]})]})})}function vr(){return r("div",{"aria-hidden":!0,className:"my-1 h-px w-5 shrink-0 bg-border/70"})}function le(e){return f(_a,{children:[r(Ka,{render:r(S,{size:"icon-sm",variant:e.pressed?"secondary":"ghost","aria-label":e.label,"aria-pressed":e.pressed,disabled:e.disabled,onClick:e.onClick}),children:e.children}),r(Wa,{side:"left",children:e.label})]})}var Da=(e,a)=>new la("invalid-input",`Invalid ${e}: ${a}.`);var Jt=4096,Qt=["light","dark"],Yt=["small","default","large","extra-large"];var eo=["clear","tinted"],ao=["none","grayscale","red-green","green-red","blue-yellow"],to=["portrait","landscape_left","portrait_upside_down","landscape_right"],oo=["camera","microphone","photos","contacts","calendar","reminders","location","notifications","motion","media-library","faceid"];var yr=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);var ro=e=>{let a=typeof e=="string"?{aps:{alert:e}}:e;if(!yr(a))throw Da("push payload","expected a string or an object");let t;try{t=JSON.stringify(a)}catch{t=void 0}if(t===void 0)throw Da("push payload","could not be encoded as JSON");if(new TextEncoder().encode(t).length>Jt)throw Da("push payload",`larger than ${String(Jt)} bytes`);return t};var wr=new Set(["setAppearance","setTextSize","setToggle","setLiquidGlass","setColorFilter","setLocation","clearLocation","setPermission","openUrl","launchApp","relaunchApp","terminateApp","sendPush"]),br=new Set(["setAppearance","setTextSize","setToggle","setOrientation","setLocation","setPermission","openUrl","launchApp","relaunchApp","terminateApp"]),kr=new Set(["reduceMotion","increaseContrast","reduceTransparency","showBorders","voiceOver"]),Dr=new Set(["reduceMotion","networkEnabled"]),Pa=(e,a)=>(e==="ios"?wr:br).has(a.type)?a.type==="setToggle"?(e==="ios"?kr:Dr).has(a.setting):!0:!1;function ie(e){return f("section",{className:"flex flex-col gap-2 border-b px-3 py-2.5",children:[r("h3",{className:"text-xs font-medium text-muted-foreground",children:e.title}),e.children]})}function se(e){return f("div",{className:"flex min-h-7 items-center justify-between gap-3",children:[r("span",{className:"shrink-0 text-xs text-muted-foreground",children:e.label}),r("div",{className:"flex min-w-0 items-center justify-end",children:e.children})]})}function Aa(e){return r(se,{label:e.label,children:r(pe,{"aria-label":e.label,checked:e.checked??!1,disabled:e.disabled||e.checked===void 0,onCheckedChange:a=>{e.onChange(a)}})})}function Ta(e){return r(Ja,{"aria-label":e.label,variant:"outline",value:e.value===void 0?[]:[e.value],disabled:e.disabled||e.value===void 0,onValueChange:a=>{let t=e.options.find(o=>o.value===a[0]);t&&e.onChange(t.value)},children:e.options.map(a=>r(Qa,{size:"xs",value:a.value,children:a.label},a.value))})}function qe(e){let a=e.options.find(t=>t.value===e.value);return f(pa,{value:e.value,disabled:e.disabled,onValueChange:t=>{let o=e.options.find(l=>l.value===t);o&&o.value!==e.value&&e.onChange(o.value)},children:[r(ma,{size:"xs",className:e.width??"w-40","aria-label":e.ariaLabel,children:r(ga,{children:a?a.label:r("span",{className:"text-muted-foreground",children:e.placeholder})})}),r(La,{align:"end",alignItemWithTrigger:!1,children:e.options.map(t=>r(ha,{value:t.value,children:t.label},t.value))})]})}function Ba(e){let[a,t]=g(""),o=a.trim()||e.fallback||"",l=()=>{o&&e.onSubmit(o).then(()=>t(""))};return f("form",{className:"flex gap-1.5",onSubmit:d=>{d.preventDefault(),l()},children:[r(ae,{size:"compact",className:"min-w-0 flex-1 font-mono",placeholder:e.placeholder,"aria-label":e.placeholder,value:a,disabled:e.disabled,onChange:d=>t(d.target.value)}),r(S,{type:"submit",size:"xs",variant:"outline",disabled:e.disabled||!o,children:e.action})]})}var lo=[{key:"tools.location.sanFrancisco",latitude:37.7749,longitude:-122.4194},{key:"tools.location.newYork",latitude:40.7128,longitude:-74.006},{key:"tools.location.london",latitude:51.5074,longitude:-.1278},{key:"tools.location.stockholm",latitude:59.3293,longitude:18.0686},{key:"tools.location.tokyo",latitude:35.6762,longitude:139.6503}];function no(e){let{t:a}=D(),[t,o]=g(e.current?String(e.current.latitude):""),[l,d]=g(e.current?String(e.current.longitude):""),s={latitude:Number(t),longitude:Number(l)},n=t.trim()!==""&&l.trim()!==""&&Math.abs(s.latitude)<=90&&Math.abs(s.longitude)<=180,u=(i,c)=>e.act({type:"setLocation",latitude:i,longitude:c});return f(ie,{title:a("tools.location.title"),children:[f("div",{className:"flex gap-1.5",children:[r(ae,{size:"compact",className:"min-w-0 flex-1 font-mono",placeholder:a("tools.location.latitude"),"aria-label":a("tools.location.latitude"),inputMode:"decimal",value:t,disabled:e.disabled,onChange:i=>o(i.target.value)}),r(ae,{size:"compact",className:"min-w-0 flex-1 font-mono",placeholder:a("tools.location.longitude"),"aria-label":a("tools.location.longitude"),inputMode:"decimal",value:l,disabled:e.disabled,onChange:i=>d(i.target.value)})]}),f("div",{className:"flex flex-wrap items-center gap-1.5",children:[f(pa,{value:null,disabled:e.disabled,onValueChange:i=>{let c=lo.find(L=>L.key===i);c&&(o(String(c.latitude)),d(String(c.longitude)),u(c.latitude,c.longitude))},children:[r(ma,{size:"xs",className:"w-32","aria-label":a("tools.location.preset"),children:r(ga,{children:r("span",{className:"text-muted-foreground",children:a("tools.location.presetPlaceholder")})})}),r(La,{align:"start",alignItemWithTrigger:!1,children:lo.map(i=>r(ha,{value:i.key,children:a(i.key)},i.key))})]}),r(S,{size:"xs",variant:"outline",disabled:e.disabled||!n,onClick:()=>{u(s.latitude,s.longitude)},children:a("tools.location.set")}),e.canClear?r(S,{size:"xs",variant:"ghost",disabled:e.disabled,onClick:()=>{o(""),d(""),e.act({type:"clearLocation"})},children:a("tools.location.clear")}):null]}),e.current?r("p",{role:"status",className:"text-xs text-muted-foreground",children:a("tools.location.current",{latitude:e.current.latitude,longitude:e.current.longitude})}):null]})}var Pr={camera:"tools.permissions.camera",microphone:"tools.permissions.microphone",photos:"tools.permissions.photos",contacts:"tools.permissions.contacts",calendar:"tools.permissions.calendar",reminders:"tools.permissions.reminders",location:"tools.permissions.location",notifications:"tools.permissions.notifications",motion:"tools.permissions.motion","media-library":"tools.permissions.mediaLibrary",faceid:"tools.permissions.faceId"},Ar=new Set(["camera","microphone","photos","contacts","calendar","location","notifications","motion"]);function uo(e){let{t:a}=D(),t=e.platform==="ios",[o,l]=g(""),[d,s]=g("camera"),n=o.trim()||e.defaultAppId,u=oo.filter(c=>t||Ar.has(c)).map(c=>({value:c,label:a(!t&&c==="motion"?"tools.permissions.activity":Pr[c])})),i=c=>{e.act({type:"setPermission",appId:n,permission:d,decision:c})};return f(ie,{title:a("tools.permissions.title"),children:[r(ae,{size:"compact",className:"font-mono",placeholder:e.defaultAppId||a("tools.permissions.appId"),"aria-label":a("tools.permissions.appId"),value:o,disabled:e.disabled,onChange:c=>l(c.target.value)}),f("div",{className:"flex flex-wrap items-center gap-1.5",children:[r(qe,{ariaLabel:a("tools.permissions.permission"),value:d,options:u,placeholder:a("tools.unknown"),disabled:e.disabled,onChange:c=>(s(c),Promise.resolve())}),r(S,{size:"xs",variant:"outline",disabled:e.disabled||!n,onClick:()=>i("grant"),children:a("tools.permissions.grant")}),r(S,{size:"xs",variant:"outline",disabled:e.disabled||!n,onClick:()=>i("revoke"),children:a("tools.permissions.revoke")}),t?r(S,{size:"xs",variant:"ghost",disabled:e.disabled||!n,onClick:()=>i("reset"),children:a("tools.permissions.reset")}):null]})]})}var Tr=e=>{let a=e;try{let t=JSON.parse(e);typeof t=="object"&&t!==null&&!Array.isArray(t)&&(a=t)}catch{}try{return ro(a),a}catch{return null}};function io(e){let{t:a}=D(),[t,o]=g(""),l=t.trim(),d=l?Tr(l):null,s=e.appId;return f(ie,{title:a("tools.push.title"),children:[r(Za,{size:"sm",rows:4,className:"font-mono",placeholder:a("tools.push.placeholder"),"aria-label":a("tools.push.placeholder"),value:t,disabled:e.disabled||!s,onChange:n=>o(n.target.value)}),f("div",{className:"flex items-center gap-2",children:[r(S,{size:"xs",variant:"outline",disabled:e.disabled||!s||d===null,onClick:()=>{s&&d!==null&&e.act({type:"sendPush",appId:s,payload:d})},children:a("tools.push.send")}),s?l&&d===null?r("p",{className:"text-xs text-destructive-foreground",children:a("tools.push.invalid")}):null:r("p",{className:"text-xs text-muted-foreground",children:a("tools.push.needsApp")})]})]})}var so=100;function fo(e){let{t:a}=D(),[t,o]=g(!1),[l,d]=g([]),{transport:s,platform:n,deviceId:u}=e;return B(()=>{if(!t)return;let i=ut({transport:s,platform:n,deviceId:u},(c,L)=>{d(v=>{let C=L?[...c]:[...v,...c];return C.length>so?C.slice(-so):C})});return()=>{i(),d([])}},[t,s,n,u]),f($e,{open:t,onOpenChange:o,children:[f(je,{className:"flex w-full items-center gap-1.5 border-b px-3 py-2.5 text-left text-xs font-medium text-muted-foreground",children:[a("tools.eventLog.title"),r(ke,{className:`ml-auto size-3.5 transition-transform ${t?"rotate-180":""}`})]}),r(Ze,{children:r("ol",{className:"max-h-64 overflow-y-auto px-3 py-2 font-mono text-ui-2xs leading-relaxed",children:l.length===0?r("li",{className:"text-muted-foreground",children:a("tools.eventLog.empty")}):l.map(i=>f("li",{className:"flex gap-2",children:[r("span",{className:"shrink-0 text-muted-foreground",children:i.timestamp.slice(11,19)}),r("span",{className:"truncate",children:i.summary})]},i.id))})})]})}var Br=640,Mr={light:"tools.settings.light",dark:"tools.settings.dark"},Rr={small:"tools.settings.textSmall",default:"tools.settings.textDefault",large:"tools.settings.textLarge","extra-large":"tools.settings.textExtraLarge"},Fr={clear:"tools.settings.glassClear",tinted:"tools.settings.glassTinted"},Or={none:"tools.settings.filterNone",grayscale:"tools.settings.filterGrayscale","red-green":"tools.settings.filterRedGreen","green-red":"tools.settings.filterGreenRed","blue-yellow":"tools.settings.filterBlueYellow"},Er={portrait:"tools.settings.orientationPortrait",landscape_left:"tools.settings.orientationLandscapeLeft",portrait_upside_down:"tools.settings.orientationUpsideDown",landscape_right:"tools.settings.orientationLandscapeRight"},Ur=[{setting:"reduceMotion",labelKey:"tools.settings.reduceMotion"},{setting:"increaseContrast",labelKey:"tools.settings.increaseContrast"},{setting:"reduceTransparency",labelKey:"tools.settings.reduceTransparency"},{setting:"showBorders",labelKey:"tools.settings.showBorders"},{setting:"voiceOver",labelKey:"tools.settings.voiceOver"},{setting:"networkEnabled",labelKey:"tools.settings.network"}];function co(e){let{t:a}=D(),{device:t,controls:o}=e,{detail:l,pending:d,error:s,foregroundApp:n,disabled:u,act:i}=o,c=l?.settings,L=t.platform==="ios",v=G(null),[C,p]=g(!0);Ea(()=>{let m=v.current?.parentElement;if(!m)return;let y=()=>p(m.clientWidth<Br);y();let R=new ResizeObserver(y);return R.observe(m),()=>R.disconnect()},[]),B(()=>o.followDevice(),[o.followDevice]);let h=Yt.map(m=>({value:m,label:a(Rr[m])})),T=Ur.filter(m=>Pa(t.platform,{type:"setToggle",setting:m.setting,value:!0}));return f("aside",{ref:v,"aria-label":a("tools.title"),className:`flex min-h-0 flex-col border-l bg-background text-sm ${C?"absolute inset-y-0 right-0 z-10 w-full max-w-72 shadow-lg":"w-72 shrink-0"}`,children:[f("div",{className:"flex h-9 shrink-0 items-center gap-2 border-b px-3",children:[r("span",{className:"font-medium",children:a("tools.title")}),d?r(z,{size:"sm"}):null,r(S,{size:"icon-xs",variant:"ghost-muted","aria-label":a("tools.close"),className:"ml-auto",onClick:e.onClose,children:r(Q,{})})]}),f("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[s?r("p",{role:"alert",className:"border-b bg-destructive/10 px-3 py-2 text-xs text-destructive-foreground",children:s}):null,l===null&&!s?f("div",{className:"flex items-center gap-2 px-3 py-3 text-xs text-muted-foreground",children:[r(z,{size:"sm"}),a("tools.reading")]}):null,f(ie,{title:a("tools.app.title"),children:[r(se,{label:a("tools.app.foreground"),children:r("span",{className:"truncate font-mono text-xs",children:n?.id??a("tools.app.none")})}),n?f("div",{className:"flex gap-1.5",children:[r(S,{size:"xs",variant:"outline",disabled:u,onClick:()=>{i({type:"terminateApp",appId:n.id})},children:a("tools.app.terminate")}),r(S,{size:"xs",variant:"outline",disabled:u,onClick:()=>{i({type:"relaunchApp",appId:n.id})},children:a("tools.app.relaunch")})]}):null,r(Ba,{placeholder:a("tools.app.urlPlaceholder"),action:a("tools.app.open"),disabled:u,onSubmit:m=>i({type:"openUrl",url:m})}),r(Ba,{placeholder:a(L?"tools.app.bundleIdPlaceholder":"tools.app.packagePlaceholder"),action:a("tools.app.launch"),disabled:u,fallback:n?.id,onSubmit:m=>i({type:"launchApp",appId:m})})]}),f(ie,{title:a(L?"tools.settings.titleIos":"tools.settings.titleAndroid"),children:[r(se,{label:a("tools.settings.appearance"),children:r(Ta,{label:a("tools.settings.appearance"),value:c?.appearance,options:Qt.map(m=>({value:m,label:a(Mr[m])})),disabled:u,onChange:m=>i({type:"setAppearance",value:m})})}),r(se,{label:a("tools.settings.textSize"),children:r(qe,{ariaLabel:a("tools.settings.textSize"),value:c?.textSize??null,options:h,placeholder:a("tools.unknown"),disabled:u,onChange:m=>i({type:"setTextSize",value:m})})}),L?f(Z,{children:[r(se,{label:a("tools.settings.liquidGlass"),children:r(Ta,{label:a("tools.settings.liquidGlass"),value:c?.liquidGlass,options:eo.map(m=>({value:m,label:a(Fr[m])})),disabled:u,onChange:m=>i({type:"setLiquidGlass",value:m})})}),r(se,{label:a("tools.settings.colorFilter"),children:r(qe,{ariaLabel:a("tools.settings.colorFilter"),value:c?.colorFilter??null,options:ao.map(m=>({value:m,label:a(Or[m])})),placeholder:a("tools.unknown"),disabled:u,onChange:m=>i({type:"setColorFilter",value:m})})})]}):r(se,{label:a("tools.settings.orientation"),children:r(qe,{ariaLabel:a("tools.settings.orientation"),value:null,options:to.map(m=>({value:m,label:a(Er[m])})),placeholder:a("tools.settings.rotateTo"),disabled:u,onChange:m=>i({type:"setOrientation",value:m})})}),T.map(m=>r(Aa,{label:a(m.labelKey),checked:c?.[m.setting],disabled:u,onChange:y=>i({type:"setToggle",setting:m.setting,value:y})},m.setting))]}),r(ie,{title:a("tools.accessibility.title"),children:r(Aa,{label:a("tools.accessibility.overlay"),checked:e.axOverlay,disabled:!1,onChange:m=>(e.onAxOverlayChange(m),Promise.resolve())})}),r(no,{current:o.location,canClear:Pa(t.platform,{type:"clearLocation"}),disabled:u,act:i}),r(uo,{platform:t.platform,defaultAppId:n?.id??"",disabled:u,act:i}),L?r(io,{appId:n?.id,disabled:u,act:i}):null,L?r(fo,{transport:e.transport,platform:t.platform,deviceId:t.id}):null]})]})}var qr=2e4,Ma=class extends Error{status;constructor(a){super(`Screenshot capture failed (${a}). Try again.`),this.status=a}};async function po(e,a,t,o){let l=AbortSignal.timeout(qr),d=await e.fetch(`${me(a)}/api/screenshot?device=${encodeURIComponent(t)}`,{method:"POST",signal:o?AbortSignal.any([o,l]):l});if(!d.ok)throw new Ma(d.status);let s=await d.blob();if(!s.size)throw new Error("The device returned an empty screenshot. Try again.");return s.type?s:new Blob([s],{type:"image/png"})}var Hr=3e3,Ra=e=>e instanceof Error?e.message:String(e);function mo(e){let{environmentId:a,device:t}=e,o=te(),l=E(),{t:d}=D(),[s,n]=g(null),[u,i]=g(null),[c,L]=g(!1),[v,C]=g(null),p=G(!1),h=G(0),T=G(!1),m={hostId:t.hostId,deviceId:t.id},y=P=>o("detail",a,m).then(b=>{h.current===P&&(n(b),C(null))},b=>{h.current===P&&(n(null),C(Ra(b)))});B(()=>{let P=++h.current;return y(P),()=>{h.current++}},[a,t.hostId,t.id]);let R=async P=>{if(p.current||s===null)return!1;p.current=!0;let b=++h.current;L(!0),C(null);try{let U=await o("action",a,{...m,...P});return h.current===b?n(U):await y(++h.current),P.type==="setLocation"?i({latitude:P.latitude,longitude:P.longitude}):P.type==="clearLocation"&&i(null),!0}catch(U){return h.current===b&&C(Ra(U)),l.notify(d("rail.actionFailed"),"error",Ra(U)),!1}finally{p.current=!1,L(!1)}},F=G(()=>{});F.current=()=>{if(p.current||T.current)return;T.current=!0;let P=++h.current;o("detail",a,m).then(b=>{h.current===P&&n(b)},()=>{}).finally(()=>{T.current=!1})};let _=Y(()=>{F.current();let P=setInterval(()=>F.current(),Hr);return()=>clearInterval(P)},[]);return{detail:s,location:u,pending:c,error:v,act:R,followDevice:_,disabled:c||s===null,foregroundApp:e.foreground===void 0?s?.foregroundApp??null:e.foreground}}var Nr=()=>typeof window<"u"&&"ReactNativeWebView"in window;function go(e){let{t:a}=D(),t=E(),o=sa(e.environmentId),[l,d]=g(null),[s,n]=g(!1),[u,i]=g(!1),[c,L]=g(!1),[v,C]=g(),[p,h]=g(!1),[T,m]=g(null),[y,R]=g(null),F=G(null),_=G(null),P=o.status==="ready"?o.transport:null,b=mo({environmentId:e.environmentId,device:e.device,foreground:v}),U=Y(q=>d(q),[]),W=Y(q=>n(q),[]);B(()=>{if(!P)return;let q=nt({transport:P,platform:e.device.platform,deviceId:e.device.id},C);return()=>{q(),C(void 0)}},[e.device.id,e.device.platform,P]),B(()=>()=>{F.current?.abort(),_.current&&URL.revokeObjectURL(_.current)},[]);let fe=()=>{if(!P||F.current)return;let q=new AbortController;F.current=q,h(!0),m(null),po(P,e.device.platform,e.device.id,q.signal).then(K=>{if(q.signal.aborted)return;_.current&&URL.revokeObjectURL(_.current);let $=URL.createObjectURL(K);if(_.current=$,Nr()){R($);return}let V=document.createElement("a");V.href=$,V.download=`${e.device.name.replace(/[^a-z0-9-]/gi,"-")}-${Date.now()}.png`,document.body.append(V),V.click(),V.remove()}).catch(K=>{q.signal.aborted||(m(K instanceof Error?K.message:a("workspace.screenshotFailed")),t.notify(a("workspace.screenshotFailed"),"error",K instanceof Error?K.message:void 0))}).finally(()=>{F.current===q&&(F.current=null,h(!1))})};return o.status!=="ready"?r(ee,{name:e.device.name,description:e.device.version,stage:o.status==="failed"?"error":"connecting",message:o.status==="failed"?o.message??a("workspace.needsNewerApp"):a("stream.connecting"),children:r(S,{size:"sm",variant:"outline",onClick:e.onBack,children:a("workspace.allDevices")})}):f("div",{className:"relative flex min-h-0 min-w-0 flex-1",children:[f("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:[T||b.error&&!u?r("p",{role:"alert",className:"px-3 py-2 text-xs text-destructive-foreground",children:T??b.error}):null,f("div",{className:"relative min-h-0 flex-1",children:[r(ra,{transport:o.transport,platform:e.device.platform,deviceId:e.device.id,deviceName:e.device.name,deviceDescription:e.device.version,axOverlay:c,withControls:!0,onHandle:U,onStreaming:W}),r(Zt,{platform:e.device.platform,handle:l,streaming:s,controls:b,screenshotPending:p,onScreenshot:fe,toolsOpen:u,onTools:()=>i(!u),onClose:e.onClose,onPowerOff:e.onPowerOff,onFloat:e.onFloat})]})]}),u?r(co,{device:e.device,controls:b,transport:o.transport,axOverlay:c,onAxOverlayChange:L,onClose:()=>i(!1)}):null,y?f("div",{className:"absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 bg-background/95 p-4",children:[r("img",{src:y,alt:a("workspace.screenshotAlt"),className:"max-h-[80%] max-w-full object-contain"}),r("p",{className:"text-xs text-muted-foreground",children:a("workspace.screenshotSaveHint")}),f(S,{size:"sm",variant:"outline",onClick:()=>R(null),children:[r(Q,{}),a("workspace.closeBrowser")]})]}):null]})}var Ce=e=>e instanceof Error?e.message:String(e);function Lo(e){let{environmentId:a,threadId:t}=e,{t:o}=D(),{state:l,loaded:d,error:s,unavailable:n}=Le(a),u=te(),[i,c]=g(null),[L,v]=g(null),C=Ga(a,t),p=x=>ze(a,t,x),h=E(),T=ce(h,"floating"),m=()=>{c(null),u("refresh",a).catch(x=>{c(Ce(x)),h.notify(o("panel.refreshFailed"),"error",Ce(x))})};B(()=>{!d||n||u("refresh",a).catch(()=>{})},[a,d,u,n]);let y=ue(()=>l.sessions.filter(x=>x.threadId===t),[l.sessions,t]),R=Gr(y,C),F=R?l.devices.find(x=>x.hostId===R.hostId&&x.id===R.deviceId):void 0,_=F&&R?Se(F):null;B(()=>{h.floating?.present({environmentId:a,threadId:t},_)}),B(()=>()=>h.floating?.present({environmentId:a,threadId:t},null),[h,a,t]);let P=ue(()=>zr(l),[l]),b=l.hostStatuses[he],U=b?.status==="ready",W=b?.status==="installing"||b?.status==="starting",fe=ya(),q=l.bootingDevices.filter(x=>x.threadId===t),K=l.hosts.flatMap(x=>x.platforms.filter(H=>!H.available)),$=async x=>{c(null),v(x),ca(a,t,j(x));try{await u("open",a,{threadId:t,hostId:x.hostId,deviceId:x.id,platform:x.platform}),p(j(x))}catch(H){ca(a,t,j(x),!1),c(Ce(H)),h.notify(o("panel.openFailed"),"error",Ce(H))}finally{v(null)}},V=x=>{R&&(c(null),u("close",a,{threadId:t,hostId:R.hostId,deviceId:R.deviceId,shutdown:x}).then(()=>p(null)).catch(H=>{c(Ce(H)),h.notify(o("panel.closeFailed"),"error",Ce(H))}))};return n?r(ee,{name:o("panel.title"),stage:"error",message:o("panel.unavailable")}):f("div",{className:"flex size-full min-h-0 flex-col",children:[q.length>0?r("div",{role:"status",className:"border-b px-3 py-2 text-xs text-muted-foreground",children:o("panel.booting",{names:q.map(x=>x.name).join(", ")})}):null,W&&!F?null:r(Nt,{detail:b,onRetry:()=>u("refresh",a).catch(()=>{})}),i||s?f("div",{role:"alert",className:"flex items-start gap-2 border-b bg-destructive/5 px-3 py-2 text-xs text-destructive-foreground",children:[r("p",{className:"min-w-0 flex-1 whitespace-pre-wrap break-words",children:i??s}),i?r(S,{size:"icon-xs",variant:"ghost","aria-label":o("panel.dismissError"),onClick:()=>c(null),children:r(Q,{className:"size-3"})}):null]}):null,r("div",{className:"relative flex min-h-0 flex-1",children:F&&R?r(go,{environmentId:a,device:F,onBack:()=>p(""),onFloat:T?()=>h.floating?.open({environmentId:a,threadId:t},{...Se(F),reason:"user"}):void 0,onPowerOff:()=>V(!0),onClose:()=>V(!1)},`${a}\0${j(F)}`):L||W||!d?r(ee,{name:L?.name??o("panel.title"),...L?{description:L.version}:{},stage:"opening",message:L?L.booted?o("panel.opening"):o("panel.starting"):W&&b?fe(b):o("panel.finding")}):r(Vr,{environmentId:a,host:l.hosts.find(x=>x.id===he),grouped:P,hostReady:U,hostFailed:b?.status==="failed",unavailableReasons:K,showNoAvdHint:U&&!l.devices.some(x=>x.platform==="android")&&!K.some(x=>x.platform==="android"),pendingKey:L?j(L):null,onOpen:x=>{$(x)},onRefresh:m})})]})}function Vr(e){let{t:a}=D(),t=e.grouped.length===0;return r("div",{className:"flex size-full flex-col overflow-y-auto px-4 py-6 text-sm text-muted-foreground",children:f("div",{className:`mx-auto flex w-full max-w-xl flex-col gap-5 ${t?"items-center text-center":""}`,children:[r($t,{environmentId:e.environmentId,iosSupported:!e.unavailableReasons.some(o=>o.reasonCode==="ios-needs-macos")},e.environmentId),t?f(Z,{children:[r(Ie,{className:"size-6 opacity-60"}),r("p",{className:"max-w-sm",children:e.hostFailed?a("panel.hubFailed"):a("panel.empty")})]}):null,e.hostReady?e.grouped.map(o=>f("section",{className:"w-full space-y-2 text-left",children:[f("h3",{className:"flex items-center gap-2 font-medium",children:[r(Ie,{className:"size-4 shrink-0"}),o.platform==="ios"?a("panel.platformIos"):a("panel.platformAndroid")]}),r("ul",{className:"divide-y rounded-md border",children:o.devices.map(l=>r("li",{children:f(S,{variant:"ghost",className:"h-auto min-h-11 w-full justify-between gap-3 rounded-none px-3 py-2 text-left font-normal",disabled:e.pendingKey!==null,onClick:()=>e.onOpen(l),children:[f("span",{className:"min-w-0 flex-1",children:[r("span",{className:"block truncate text-foreground",children:l.name}),f("span",{className:"block text-xs",children:[l.version,","," ",l.booted?a("panel.running"):a("panel.stopped")]})]}),e.pendingKey===j(l)?r(z,{size:"xs"}):r("span",{className:"text-xs",children:l.booted?a("panel.open"):a("panel.start")})]})},j(l)))})]},o.platform)):null,e.unavailableReasons.map(o=>r("p",{className:"max-w-sm text-xs",children:o.reasonCode?a(`unavailable.${o.reasonCode}`,{root:o.sdkRoot??""}):o.reason},`${o.platform}:${o.reasonCode}`)),e.showNoAvdHint?r("p",{className:"max-w-sm text-xs",children:a("panel.noAvd")}):null,f("div",{className:`flex flex-wrap items-center gap-2 ${t?"self-center":"self-start"}`,children:[r(S,{variant:t?"outline":"ghost",size:"sm",onClick:e.onRefresh,children:a("panel.refresh")}),r(Vt,{environmentId:e.environmentId,host:e.host,busy:!1})]})]})})}function Gr(e,a){if(a!==""){if(a!==null){let t=e.find(o=>j({hostId:o.hostId,id:o.deviceId})===a);if(t)return t}return e.toSorted((t,o)=>o.openedAt.localeCompare(t.openedAt))[0]}}function zr(e){let a=[];for(let t of["ios","android"]){let o=e.devices.filter(l=>l.platform===t).toSorted((l,d)=>Number(d.booted)-Number(l.booted)||l.name.localeCompare(d.name));o.length>0&&a.push({platform:t,devices:o})}return a}function ho({environmentId:e,threadId:a}){let t=E(),{state:o,loaded:l}=Le(e),d=G(null);return B(()=>{if(!l||!ce(t,"floating"))return;let s=`${e}\0${a}`,n=d.current?.key===s?d.current.seen:null,{seen:u,opened:i}=za({environmentId:e,threadId:a,previous:n,sessions:o.sessions,devices:o.devices});d.current={key:s,seen:u};for(let c of i)t.floating?.open({environmentId:e,threadId:a},{...Se(c),reason:"agent",panelId:Ve})},[t,e,l,o.devices,o.sessions,a]),null}function _r(e){return{panels:{device:function(t){return f(Ne,{value:e,children:[r("style",{children:na}),r("div",{className:`${_e} flex h-full min-h-0 flex-1 flex-col`,children:r(Lo,{environmentId:t.environmentId,threadId:t.threadId})})]})}},views:{deviceFloat:function(t){return f(Ne,{value:e,children:[r("style",{children:na}),r("div",{className:`${_e} relative size-full`,children:r(Ft,{...t})})]})},deviceSessions:function(t){return r(Ne,{value:e,children:r(ho,{environmentId:t.environmentId,threadId:t.threadId})})}}}}export{_r as default};
558
+ `),id:this.lastId}:void 0;return this.data=[],this.eventName="",d}if(a.startsWith(":"))return;let t=a.indexOf(":"),o=t===-1?a:a.slice(0,t),l=t===-1?"":a.slice(t+1);l.startsWith(" ")&&(l=l.slice(1)),o==="data"?this.data.push(l):o==="event"?this.eventName=l:o==="id"&&!l.includes("\0")&&(this.lastId=l)}};async function ea(e,a,t){let o=e.body;if(!o)throw new Error("The response has no body to stream.");let l=o.getReader(),d=()=>{l.cancel().catch(()=>{})};if(t?.aborted)return d();t?.addEventListener("abort",d,{once:!0});try{for(;;){let{done:s,value:n}=await l.read();if(s||t?.aborted)return;a(n)}}catch(s){if(t?.aborted)return;throw s}finally{t?.removeEventListener("abort",d)}}function aa(e,a,t){let o=e;if(a+t.length>e.length){let l=e.length;for(;l<a+t.length;)l*=2;o=new Uint8Array(l),o.set(e.subarray(0,a))}return o.set(t,a),o}async function lt(e,a,t){if(!e.ok)throw await e.body?.cancel().catch(()=>{}),new Error(`Event stream failed (${e.status}).`);let o=new be;await ea(e,l=>{for(let d of o.push(l))a(d)},t)}var me=e=>e==="ios"?"/vendor/serve-sim":"/vendor/serve-emu";var bo=1e3,ko=500,ta=(e,a,t)=>`${me(e.platform)}${a}${t?`?${new URLSearchParams(t).toString()}`:""}`,st=async(e,a,t)=>{let o=await e.transport.fetch(a,t?{signal:t}:void 0);if(!o.ok)throw new Error(`${o.status} ${o.statusText}`);return await o.json()},J=e=>typeof e=="object"&&e!==null,X=(e,a)=>typeof e=="number"&&Number.isFinite(e)?e:a,Do=e=>{let a=e[0],t=J(a)&&J(a.frame)?a.frame:null,o=Math.max(1,X(t?.width,1)),l=Math.max(1,X(t?.height,1)),d=[],s=(n,u)=>{if(d.length>=ko||!J(n)||!J(n.frame))return;let i=n.frame,c=X(i.width,0),L=X(i.height,0);!(Math.abs(c-o)<.5&&Math.abs(L-l)<.5)&&c>0&&L>0&&d.push({id:typeof n.AXUniqueId=="string"?n.AXUniqueId:u,label:typeof n.AXLabel=="string"?n.AXLabel:"",role:typeof n.type=="string"?n.type:"",x:X(i.x,0)/o,y:X(i.y,0)/l,width:c/o,height:L/l}),(Array.isArray(n.children)?n.children:[]).forEach((p,h)=>s(p,`${u}.${h}`))};return e.forEach((n,u)=>s(n,String(u))),d},dt=e=>J(e)&&typeof e.error=="string"?e.error:"Unexpected accessibility payload.";async function ut(e,a){if(e.platform==="ios"){let u=await st(e,ta(e,`/helper/${encodeURIComponent(e.deviceId)}/ax`),a);return Array.isArray(u)?{elements:Do(u),errors:[]}:{elements:[],errors:[dt(u)]}}let t=await st(e,ta(e,"/api/accessibility",{device:e.deviceId}),a);if(!J(t)||!Array.isArray(t.nodes))return{elements:[],errors:[dt(t)]};let o=t.nodes.filter(u=>J(u)&&J(u.bounds)),l=o[0]?.bounds,d=Math.max(1,X(l?.right,1)),s=Math.max(1,X(l?.bottom,1));return{elements:o.slice(1).flatMap(u=>{let i=u.bounds,c=X(i.left,0),L=X(i.top,0),S=(X(i.right,c)-c)/d,C=(X(i.bottom,L)-L)/s,p=typeof u.text=="string"?u.text:"",h=typeof u.contentDescription=="string"?u.contentDescription:"",B=p||h;if(S>=.95&&C>=.9)return[];if(!B&&u.clickable!==!0)return[];let m=typeof u.className=="string"?u.className:"";return[{id:String(u.id??""),label:B,role:m.split(".").at(-1)??"",x:c/d,y:L/s,width:S,height:C}]}),errors:[]}}var it=(e,a,t)=>{let o=new AbortController,l=null,d=()=>{e.transport.fetch(a,{signal:o.signal}).then(s=>lt(s,n=>{try{t(JSON.parse(n.data))}catch{}},o.signal)).catch(()=>{}).finally(()=>{o.signal.aborted||(l=setTimeout(d,bo))})};return d(),()=>{o.abort(),l!==null&&clearTimeout(l)}};function ft(e,a){return e.platform!=="ios"?()=>{}:it(e,ta(e,"/appstate",{device:e.deviceId}),t=>{if(J(t)){if(t.bundleId===null||t.bundleId===""){a(null);return}typeof t.bundleId=="string"&&a({id:t.bundleId,...typeof t.pid=="number"?{pid:t.pid}:{},...typeof t.isReactNative=="boolean"?{isReactNative:t.isReactNative}:{}})}})}var nt=e=>!J(e)||typeof e.id!="number"?null:{id:e.id,timestamp:typeof e.timestamp=="string"?e.timestamp:"",kind:typeof e.kind=="string"?e.kind:"",summary:typeof e.summary=="string"?e.summary:typeof e.msg=="string"?e.msg:""};function ct(e,a){return e.platform!=="ios"?()=>{}:it(e,ta(e,"/api/event-log/events",{device:e.deviceId,limit:"100"}),t=>{if(!J(t))return;if(Array.isArray(t.events)){a(t.events.flatMap(l=>nt(l)??[]),!0);return}let o=nt(t.event);o&&a([o],!1)})}function A(){return{t:O().i18n.usePluginTranslation()}}var Po=1397050709,Sa=16,Ao=1;function ra(e){if(e.length<4)return"avc1.42E01E";let a=t=>t.toString(16).padStart(2,"0");return`avc1.${a(e[1])}${a(e[2])}${a(e[3])}`}function pt(e){let a=new Uint8Array(e);if(a.byteLength>Sa){let t=new DataView(e,0,Sa);if(t.getUint32(0,!1)===Po&&t.getUint8(4)===1){let o=t.getBigUint64(8,!1);return{data:a.subarray(Sa),isKey:(t.getUint8(5)&Ao)!==0,timestamp:o<=BigInt(Number.MAX_SAFE_INTEGER)?Number(o):null}}}return{data:a,isKey:null,timestamp:null}}var mt=e=>{try{return JSON.parse(e)?.type==="video-session"}catch{return!1}};function gt(e){let a=!1,t=null,o=e.length,l=0;for(;l+2<o;){if(e[l]===0&&e[l+1]===0){let d=0;if(e[l+2]===1?d=3:l+3<o&&e[l+2]===0&&e[l+3]===1&&(d=4),d){let s=e[l+d]&31;s===7&&!t&&(t=e.subarray(l+d)),s===5&&(a=!0),l+=d+1;continue}}l++}return{isKey:a,sps:t}}var To={1:"description",2:"keyframe",3:"delta",4:"seed"},oa=class{buffer=new Uint8Array(64*1024);length=0;push(a){this.buffer=aa(this.buffer,this.length,a),this.length+=a.length;let t=[],o=0;for(;this.length-o>=4;){let d=new DataView(this.buffer.buffer,this.buffer.byteOffset+o,4).getUint32(0,!1);if(this.length-o-4<d)break;if(d>=1){let s=To[this.buffer[o+4]];s&&t.push({type:s,payload:this.buffer.slice(o+5,o+4+d)})}o+=4+d}return o>0&&(this.buffer.copyWithin(0,o,this.length),this.length-=o),t}reset(){this.length=0}};var Bo={Enter:40,Escape:41,Backspace:42,Tab:43,Space:44,Minus:45,Equal:46,BracketLeft:47,BracketRight:48,Backslash:49,Semicolon:51,Quote:52,Backquote:53,Comma:54,Period:55,Slash:56,Delete:76,ArrowRight:79,ArrowLeft:80,ArrowDown:81,ArrowUp:82,ControlLeft:224,ShiftLeft:225,AltLeft:226,MetaLeft:227,ControlRight:228,ShiftRight:229,AltRight:230,MetaRight:231};function Lt(e){return/^Key[A-Z]$/.test(e)?4+(e.charCodeAt(3)-65):/^Digit[1-9]$/.test(e)?30+(e.charCodeAt(5)-49):e==="Digit0"?39:Bo[e]??null}var ht={ArrowUp:19,ArrowDown:20,ArrowLeft:21,ArrowRight:22,Tab:61,Enter:66,Backspace:67,Delete:112,Home:122,End:123,PageUp:92,PageDown:93};function ya(e){if(e.stopped)return;let a=d=>{e.configuring=!1,e.connecting(d),e.scheduleRetry("input",()=>ya(e))},t;try{t=e.transport.connect(`${e.vendor}/ws?device=${e.device}&frame-meta=1`)}catch(d){e.events.onInputConnected(!1,d.message),a(d.message);return}e.socket=t;let o=[],l=!1;t.onopen=()=>{e.stopped||e.socket!==t||(e.connecting(),e.events.onInputConnected(!0))},t.onmessage=d=>{if(e.stopped||e.socket!==t)return;if(typeof d.data=="string"){mt(d.data)&&(e.closeDecoder(),e.configuring=!1,o=[],l=!1,e.connecting());return}let s=pt(d.data),n=!e.videoDecoder||e.videoDecoder.state!=="configured",i=s.isKey===null||s.isKey&&n?gt(s.data):null,c=s.isKey??i?.isKey??!1,L={isKey:c,data:s.data,timestamp:s.timestamp};if(e.configuring){o.push(L);return}if(i?.sps&&n){e.configuring=!0,o=[L];let S=e.decoderEpoch,C=()=>!e.stopped&&e.socket===t;e.configureDecoder({codec:ra(i.sps)},C).then(p=>{if(!C()||S!==e.decoderEpoch)return;e.configuring=!1,e.awaitingKeyframe=!0;let h=o;if(o=[],!!p){for(let B of h)e.decode(B.isKey,B.data,B.timestamp);e.awaitingKeyframe&&e.requestKeyframe()}});return}if(n){!c&&!l&&(l=!0,e.requestKeyframe());return}e.decode(c,s.data,s.timestamp)},t.onclose=d=>{e.socket===t&&(e.socket=null,e.closeDecoder(),!e.stopped&&(e.events.onInputConnected(!1,d.reason||`closed ${d.code}`),a(d.reason||void 0)))},t.onerror=()=>t.close()}function xt(e){return{sendTouch(a,t,o){let l=a==="begin"?"down":a==="move"?"move":"up";e.send(JSON.stringify({type:"touch",action:l,x:t,y:o}))},sendKey(a,t){if(t!=="down")return;if(a.key==="Escape")return e.send(JSON.stringify({type:"back"}));let o=ht[a.key];if(o!==void 0)return e.send(JSON.stringify({type:"key",keycode:o}));a.key.length===1&&!a.metaKey&&!a.ctrlKey&&e.send(JSON.stringify({type:"text",text:a.key}))},pressButton(a){let t=a==="appSwitcher"?"recents":a;(t==="home"||t==="back"||t==="recents"||t==="power")&&e.send(JSON.stringify({type:t}))},rotate(){},setOrientation(){}}}function It(e){return{present(a,t,o){let l=e.getContext("2d");return l?((e.width!==t||e.height!==o)&&(e.width=t,e.height=o),l.drawImage(a,0,0,t,o),!0):!1}}}var Mo=13,Ct=10,St=45,Ro=16*1024*1024,yt=new TextEncoder,vt=new TextDecoder;function bt(e){if(!e)return null;let a=/boundary=(?:"([^"]+)"|([^;\s]+))/i.exec(e),t=a?.[1]??a?.[2];return t?t.startsWith("--")?t:`--${t}`:null}function wt(e,a,t,o){let l=o-a.length;for(let d=t;d<=l;d++){if(e[d]!==a[0])continue;let s=1;for(;s<a.length&&e[d+s]===a[s];)s++;if(s===a.length)return d}return-1}var la=class{delimiter;buffer=new Uint8Array(64*1024);length=0;pos=0;state="boundary";contentLength=null;scanFrom=0;constructor(a){this.delimiter=a?yt.encode(a):null}push(a){this.append(a);let t=[];for(;;){if(this.state==="done"){this.pos=this.length=0;break}if(this.state==="boundary"){if(!this.readBoundary())break}else if(this.state==="headers"){if(!this.readHeaders())break}else{let o=this.readBody();if(!o)break;o.length>0&&t.push(o)}}if(this.length-this.pos>Ro)throw new Error("MJPEG part is too large.");return this.pos>0&&(this.buffer.copyWithin(0,this.pos,this.length),this.length-=this.pos,this.scanFrom=Math.max(0,this.scanFrom-this.pos),this.pos=0),t}append(a){this.buffer=aa(this.buffer,this.length,a),this.length+=a.length}lineEnd(a){return this.buffer.subarray(0,this.length).indexOf(Ct,a)}readBoundary(){let a=this.buffer;if(!this.delimiter)for(;;){let s=this.lineEnd(this.pos);if(s===-1)return!1;let n=vt.decode(a.subarray(this.pos,s)).trim();if(this.pos=s+1,n.startsWith("--"))return this.delimiter=yt.encode(n),this.state="headers",!0}let t=this.delimiter,o=wt(a,t,this.pos,this.length);if(o===-1)return this.pos=Math.max(this.pos,this.length-t.length+1),!1;let l=o+t.length;if(l+2>this.length)return this.pos=o,!1;if(a[l]===St&&a[l+1]===St)return this.state="done",!0;let d=this.lineEnd(l);return d===-1?(this.pos=o,!1):(this.pos=d+1,this.state="headers",!0)}readHeaders(){let a=this.pos,t=null;for(;;){let o=this.lineEnd(a);if(o===-1)return!1;let l=vt.decode(this.buffer.subarray(a,o)).replace(/\r$/,"");if(a=o+1,l==="")break;let d=l.indexOf(":");if(d>0&&l.slice(0,d).trim().toLowerCase()==="content-length"){let s=Number.parseInt(l.slice(d+1).trim(),10);Number.isFinite(s)&&s>=0&&(t=s)}}return this.pos=a,this.contentLength=t,this.scanFrom=a,this.state="body",!0}readBody(){if(this.contentLength!==null){if(this.length-this.pos<this.contentLength)return null;let o=this.buffer.slice(this.pos,this.pos+this.contentLength);return this.pos+=this.contentLength,this.state="boundary",o}let a=this.delimiter,t=Math.max(this.scanFrom,this.pos+1);for(;;){let o=wt(this.buffer,a,t,this.length);if(o===-1)return this.scanFrom=Math.max(this.pos,this.length-a.length),null;if(this.buffer[o-1]!==Ct){t=o+1;continue}let l=o-1;l>this.pos&&this.buffer[l-1]===Mo&&l--;let d=this.buffer.slice(this.pos,Math.max(l,this.pos));return this.pos=o,this.state="boundary",d}}};async function Fo(e,a,t){let o=new la(bt(e.headers.get("content-type")));await ea(e,l=>{for(let d of o.push(l))a(d)},t)}function ke(e){e.stopped||e.mjpeg||(e.mjpeg=!0,e.controller?.abort(),e.controller=null,e.closeDecoder(),e.connecting(),e.events.onMjpegFallback?.(),kt(e))}var va=e=>`${e.vendor}/helper/${e.device}/stream.mjpeg`;async function kt(e){let a=e.generation,t=++e.videoGeneration,o=new AbortController;e.controller=o;let l=()=>!e.stopped&&e.generation===a&&e.videoGeneration===t&&e.controller===o,d=null,s=!1,n=async()=>{s=!0;try{for(;d;){let i=d;d=null;try{let c=await e.createBitmap(new Blob([i],{type:"image/jpeg"}));try{l()&&e.paint(c,c.width,c.height)}finally{c.close()}}catch{}}}finally{s=!1}},u;try{let i=await e.transport.fetch(va(e),{signal:o.signal});if(!l()){await i.body?.cancel();return}if(!i.ok||!i.body)throw new Error(`stream ${i.status}`);if(await Fo(i,c=>{l()&&(d=c,s||n())},o.signal),!l())return;u="Device stream ended."}catch(i){if(!l())return;u=i.message}l()&&(e.controller=null,o.abort(),e.connecting(u),e.scheduleRetry("video",()=>{kt(e)}))}var Eo=1e3,wa=15e3,Oo=16667,Uo=8,qo=e=>typeof e=="object"&&e!==null&&"present"in e;function Pt(e){let{transport:a,platform:t,events:o}=e,l=qo(e.output)?e.output:It(e.output),d=n=>e.globals?.[n]??globalThis[n],s={platform:t,transport:a,events:o,preferMjpeg:e.preferMjpeg===!0,vendor:me(t),device:encodeURIComponent(e.deviceId),stopped:!0,generation:0,videoGeneration:0,decoderEpoch:0,socket:null,controller:null,primeController:null,videoDecoder:null,timestamp:0,awaitingKeyframe:!0,screen:null,firstFrame:!1,configuring:!1,mjpeg:!1,frameTimer:null,videoReadTimer:null,retryTimers:new Map,webCodecs(){let n=d("VideoDecoder"),u=d("EncodedVideoChunk");return n&&u?{VideoDecoder:n,EncodedVideoChunk:u}:null},createBitmap(n){let u=d("createImageBitmap");return u?u(n):Promise.reject(new Error("createImageBitmap is unavailable."))},setStatus(n,u){s.stopped||o.onStatus(n,u)},fail(n){s.stopped||(s.stop(),o.onInputConnected(!1,n),o.onStatus("error",n))},connecting(n){s.firstFrame=!1,s.frameTimer===null&&(s.frameTimer=setTimeout(()=>s.fail("No video received from the device. Reconnect to try again."),wa)),s.setStatus("connecting",n)},paint(n,u,i){if(!s.stopped){if(t==="android"&&(s.screen?.width!==u||s.screen.height!==i)&&(s.screen={width:u,height:i,orientation:u>i?"landscape_left":"portrait"},o.onScreen(s.screen)),!l.present(n,u,i)){s.fail("Could not display the device stream. Reconnect to try again.");return}s.firstFrame||(s.firstFrame=!0,s.frameTimer!==null&&clearTimeout(s.frameTimer),s.frameTimer=null,s.setStatus("streaming"))}},closeDecoder(){s.decoderEpoch++,s.configuring=!1;try{s.videoDecoder?.close()}catch{}s.videoDecoder=null,s.awaitingKeyframe=!0},recoverDecoder(){t==="ios"?ke(s):(s.closeDecoder(),s.connecting("Video decoder restarted."),s.requestKeyframe())},async configureDecoder(n,u=()=>!s.stopped){let i=s.webCodecs();if(!i)return!1;let c=s.decoderEpoch,L={...n,optimizeForLatency:!0},S=await i.VideoDecoder.isConfigSupported(L).catch(()=>({supported:!1}));if(!u()||c!==s.decoderEpoch)return!1;if(!S.supported)return t==="android"&&s.fail(`This browser cannot decode ${n.codec}.`),!1;try{return(!s.videoDecoder||s.videoDecoder.state==="closed")&&(s.videoDecoder=Ho(s,i)),s.videoDecoder.configure(L),!0}catch(C){return t==="android"&&s.fail(`Video decoder: ${C.message}`),!1}},decode(n,u,i){let c=s.videoDecoder,L=s.webCodecs();if(!(!c||c.state!=="configured"||!L)){if(s.awaitingKeyframe){if(!n)return;s.awaitingKeyframe=!1}if(c.decodeQueueSize>Uo){s.recoverDecoder();return}try{c.decode(new L.EncodedVideoChunk({type:n?"key":"delta",timestamp:i??s.timestamp,data:u})),s.timestamp+=Oo}catch{s.recoverDecoder()}}},requestKeyframe(){t==="android"&&s.socket?.readyState===1&&s.socket.send(JSON.stringify({type:"reset-video",ack:!1}))},scheduleRetry(n,u){s.stopped||s.retryTimers.has(n)||s.retryTimers.set(n,setTimeout(()=>{s.retryTimers.delete(n),u()},Eo))},send(n){!s.stopped&&s.socket?.readyState===1&&s.socket.send(n)},stop(){if(s.stopped)return;s.stopped=!0,s.generation++,s.videoGeneration++,s.mjpeg=!1,s.frameTimer!==null&&clearTimeout(s.frameTimer),s.frameTimer=null,s.videoReadTimer!==null&&clearTimeout(s.videoReadTimer),s.videoReadTimer=null;for(let u of s.retryTimers.values())clearTimeout(u);s.retryTimers.clear(),s.primeController?.abort(),s.primeController=null,s.controller?.abort(),s.controller=null;let n=s.socket;s.socket=null,n?.close(),s.closeDecoder()}};return s}function Ho(e,a){let t=e.videoGeneration,o=()=>e.platform!=="ios"||t===e.videoGeneration,l=new a.VideoDecoder({output:d=>{try{e.videoDecoder===l&&o()&&e.paint(d,d.displayWidth,d.displayHeight)}finally{d.close()}},error:()=>{e.stopped||e.videoDecoder!==l||!o()||e.recoverDecoder()}});return l}var No=3,Go=4,Vo=6,At=7,zo=13,_o=130,Wo=2e3,Ko=new TextEncoder,Xo=new TextDecoder,sa=["portrait","landscape_left","portrait_upside_down","landscape_right"],$o=new Set(sa);function ge(e,a){let t=Ko.encode(JSON.stringify(a)),o=new Uint8Array(1+t.length);return o[0]=e,o.set(t,1),o}function jo(e){if(typeof e!="object"||e===null)return null;let{width:a,height:t,orientation:o,screenId:l}=e;if(typeof a!="number"||!Number.isFinite(a)||a<=0||typeof t!="number"||!Number.isFinite(t)||t<=0||typeof o!="string"||!$o.has(o))return null;let d={width:a,height:t,orientation:o};return typeof l=="number"?{...d,screenId:l}:d}function Tt(e,a){Mt(e),a?Bt(e):ke(e)}async function Bt(e){let a=e.generation,t=++e.videoGeneration,o=new oa,l=new AbortController;e.controller=l;let d=()=>!e.stopped&&e.generation===a&&e.videoGeneration===t&&e.controller===l,s;try{let n=await e.transport.fetch(`${e.vendor}/helper/${e.device}/stream.avcc`,{signal:l.signal});if(!d()){await n.body?.cancel();return}if(!n.ok||!n.body)throw new Error(`stream ${n.status}`);let u=n.body.getReader();for(;;){let i=setTimeout(()=>{d()&&e.fail("Device stream stopped receiving video. Reconnect to try again.")},wa);e.videoReadTimer=i;let c;try{c=await u.read()}finally{clearTimeout(i),e.videoReadTimer===i&&(e.videoReadTimer=null)}let{done:L,value:S}=c;if(!d())return;if(L)break;for(let C of o.push(S))switch(C.type){case"seed":e.createBitmap(new Blob([C.payload],{type:"image/jpeg"})).then(p=>{try{d()&&e.paint(p,p.width,p.height)}finally{p.close()}}).catch(()=>{});break;case"description":{e.awaitingKeyframe=!0;let p=await e.configureDecoder({codec:ra(C.payload),description:C.payload},d);if(!d())return;if(!p){if(await u.cancel().catch(()=>{}),!d())return;ke(e);return}break}case"keyframe":case"delta":e.decode(C.type==="keyframe",C.payload);break}}}catch(n){if(!d())return;s=n.message}d()&&(e.controller=null,l.abort(),e.closeDecoder(),e.connecting(s),e.scheduleRetry("video",()=>{Bt(e)}))}async function Zo(e,a){let t=new AbortController;e.primeController=t;let o=setTimeout(()=>t.abort(),Wo);try{let l=await e.transport.fetch(va(e),{signal:t.signal});if(e.stopped||e.generation!==a)return;await l.body?.getReader().read()}catch{}finally{clearTimeout(o),t.abort(),e.primeController===t&&(e.primeController=null)}}async function Mt(e){if(e.stopped)return;let a=e.generation;if(await Zo(e,a),e.stopped||e.generation!==a)return;let t=()=>e.scheduleRetry("input",()=>{Mt(e)}),o;try{o=e.transport.connect(`${e.vendor}/helper/ws?device=${e.device}`)}catch(l){e.events.onInputConnected(!1,l.message),t();return}e.socket=o,o.onopen=()=>{e.stopped||e.socket!==o||(o.send(ge(zo,{enabled:!1})),e.events.onInputConnected(!0))},o.onmessage=l=>{if(e.stopped||e.socket!==o||typeof l.data=="string")return;let d=new Uint8Array(l.data);if(!(d.length<1||d[0]!==_o))try{let s=jo(JSON.parse(Xo.decode(d.subarray(1))));s&&(e.screen=s,e.events.onScreen(s))}catch{}},o.onclose=l=>{e.socket===o&&(e.socket=null,!e.stopped&&(e.events.onInputConnected(!1,l.reason||(l.code===1006?"input socket refused":`closed ${l.code}`)),t()))},o.onerror=()=>o.close()}function Jo(e,a,t){let o=e.screen;if(!o||o.width>o.height)return{x:a,y:t};switch(o.orientation){case"landscape_left":return{x:t,y:1-a};case"landscape_right":return{x:1-t,y:a};case"portrait_upside_down":return{x:1-a,y:1-t};default:return{x:a,y:t}}}function Rt(e){return{sendTouch(a,t,o){e.send(ge(No,{type:a,...Jo(e,t,o)}))},sendKey(a,t){let o=Lt(a.code);o!==null&&e.send(ge(Vo,{type:t,usage:o}))},pressButton(a){let t=a==="home"?"home":a==="appSwitcher"?"app_switcher":a==="power"?"lock":null;t&&e.send(ge(Go,{button:t}))},rotate(){let a=e.screen?.orientation??"portrait",t=sa[(sa.indexOf(a)+1)%sa.length];e.send(ge(At,{orientation:t}))},setOrientation(a){e.send(ge(At,{orientation:a}))}}}function Ft(e){let a=Pt(e),t=e.platform==="ios"?Rt(a):xt(a);return{start:()=>{if(!a.stopped)return;a.stopped=!1,a.generation++,a.configuring=!1,a.connecting();let l=a.webCodecs()!==null&&!(e.platform==="ios"&&a.preferMjpeg);e.platform==="ios"?Tt(a,l):l?ya(a):a.fail("This browser cannot decode the Android stream (WebCodecs unavailable).")},stop:a.stop,isMjpeg:()=>a.mjpeg,...t}}var Qo=56,Yo=2e3;function er(e,a,t,o=0){let l=Math.max(0,a-o);if(l===0||t===0)return{width:0,height:0};let d={width:t*e,height:t};return d.width<=l?d:{width:l,height:l/e}}function ar(e,a){if(!a)return e==="ios"?9/19.5:9/20;let t=a.orientation==="landscape_left"||a.orientation==="landscape_right",o=Math.max(a.width,a.height),l=Math.min(a.width,a.height);return t?o/l:l/o}function tr(e,a){if(e!=="ios"||!a||a.width>a.height)return 0;switch(a.orientation){case"landscape_left":return 90;case"landscape_right":return-90;case"portrait_upside_down":return 180;default:return 0}}var or=()=>typeof navigator<"u"&&/iPhone|iPad|iPod/.test(navigator.userAgent);function da(e){let{t:a}=A(),t=V(null),o=V(null),[l,d]=g("connecting"),[s,n]=g(),[u,i]=g(!1),[c,L]=g(null),[S,C]=g({connected:!1}),{onHandle:p,onStreaming:h,onScreen:B,transport:m,platform:v,deviceId:R}=e;M(()=>B?.(c),[B,c]),M(()=>{let I=t.current;if(!I)return;let D=Ft({transport:m,platform:v,deviceId:R,output:I,preferMjpeg:or(),events:{onStatus:(E,N)=>{d(E),n(N),E==="streaming"&&i(!0),h(E==="streaming")},onScreen:L,onInputConnected:(E,N)=>{C({connected:E,...N?{detail:N}:{}}),p({pressButton:D.pressButton,rotate:D.rotate,inputConnected:E})}}});return o.current=D,C({connected:!1}),D.start(),p({pressButton:D.pressButton,rotate:D.rotate,inputConnected:!1}),()=>{D.stop(),o.current=null,p(null),h(!1),i(!1),L(null)}},[R,p,h,v,m]);let F=V(null),[_,T]=g({width:0,height:0});M(()=>{let I=F.current;if(!I)return;let D=()=>{let N=I.getBoundingClientRect();T(ne=>ne.width===N.width&&ne.height===N.height?ne:{width:N.width,height:N.height})};D();let E=new ResizeObserver(D);return E.observe(I),()=>E.disconnect()},[]);let k=e.withControls?Qo:0,U=ie(()=>er(ar(v,c),_.width,_.height,k),[_,k,v,c]),W=tr(v,c),q=W===90||W===-90?{width:U.height,height:U.width,left:(U.width-U.height)/2,top:(U.height-U.width)/2,transform:`rotate(${W}deg)`}:{width:U.width,height:U.height,...W?{transform:`rotate(${W}deg)`}:{}},[K,$]=g([]);M(()=>{if(!e.axOverlay)return;let I=null,D=null,E=!1,N=async()=>{I=new AbortController;try{let ne=await ut({transport:m,platform:v,deviceId:R},I.signal);E||$(ne.elements)}catch{}E||(D=setTimeout(()=>{N()},Yo))};return N(),()=>{E=!0,I?.abort(),D&&clearTimeout(D),$([])}},[R,v,e.axOverlay,m]);let G=V(!1),x=I=>{let D=I.currentTarget.getBoundingClientRect(),E=(I.clientX-D.left)/D.width,N=(I.clientY-D.top)/D.height;return{x:Math.min(1,Math.max(0,E)),y:Math.min(1,Math.max(0,N))}},H=I=>{if(!G.current)return;G.current=!1;let{x:D,y:E}=x(I);o.current?.sendTouch("end",D,E)};return f("div",{ref:F,className:"relative flex size-full min-h-0 min-w-0 items-center justify-center overflow-hidden",style:k?{paddingRight:k}:void 0,tabIndex:0,role:"application","aria-label":a(v==="ios"?"stream.iosScreen":"stream.androidScreen"),onKeyDown:I=>{I.target===I.currentTarget&&(I.metaKey&&!["r","R"].includes(I.key)||(I.preventDefault(),o.current?.sendKey(I.nativeEvent,"down")))},onKeyUp:I=>{I.target===I.currentTarget&&o.current?.sendKey(I.nativeEvent,"up")},children:[f("div",{className:"relative touch-none select-none",style:{width:U.width,height:U.height},onPointerDown:I=>{I.currentTarget.setPointerCapture(I.pointerId),I.currentTarget.parentElement?.focus(),G.current=!0;let{x:D,y:E}=x(I);o.current?.sendTouch("begin",D,E)},onPointerMove:I=>{if(!G.current)return;let{x:D,y:E}=x(I);o.current?.sendTouch("move",D,E)},onPointerUp:H,onPointerCancel:H,children:[r("canvas",{ref:t,className:"absolute top-0 left-0",style:q}),K.length>0?r("div",{className:"pointer-events-none absolute inset-0","aria-hidden":!0,children:K.map(I=>r("div",{className:"absolute border border-info/80 bg-info/10",style:{left:`${I.x*100}%`,top:`${I.y*100}%`,width:`${I.width*100}%`,height:`${I.height*100}%`},children:I.label?r("span",{className:"absolute -top-3.5 left-0 max-w-full truncate rounded-sm bg-info px-1 text-ui-2xs leading-3.5 text-white",children:I.label}):null},I.id))}):null]}),l==="streaming"&&!S.connected?r("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex justify-center p-2",children:r("span",{className:"rounded-md bg-background/85 px-2 py-1 text-xs text-muted-foreground",children:S.detail?a("stream.inputLostDetail",{detail:S.detail}):a("stream.inputLost")})}):null,l==="connecting"&&u?r("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex justify-center p-2",children:r("span",{className:"rounded-md bg-background/85 px-2 py-1 text-xs text-muted-foreground",children:a("stream.connecting")})}):null,l==="error"||l!=="streaming"&&!u?r("div",{className:"absolute inset-0 bg-background",children:r(ee,{name:e.deviceName,description:e.deviceDescription,stage:l==="error"?"error":"connecting",message:l==="error"?s??a("stream.failed"):a("stream.connecting"),children:l==="error"?r(y,{size:"sm",variant:"outline",onClick:()=>{o.current?.stop(),o.current?.start()},children:a("stream.reconnect")}):null})}):null]})}var rr={hosts:[],hostStatuses:{},devices:[],sessions:[],bootingDevices:[],revision:0};function Le(e){let t=O().commands.useSubscription("state",{},{environmentId:e});return{state:t.data??rr,loaded:t.data!==null,error:t.error,unavailable:t.isUnavailable}}function oe(){let e=O();return Y((a,t,o={})=>e.commands.invoke(a,o,{environmentId:t}),[e])}var he="local",na=class extends Error{code;constructor(a,t,o){super(t,o),this.name="DeviceError",this.code=a}};var Et="hub";function ua(e){let a=O(),[t,o]=g({status:"connecting"});return M(()=>{let l=a.network;if(!pe(a,"network")||l===void 0){o({status:"failed",message:null});return}let d=!1;return o({status:"connecting"}),l.client(e).then(s=>{d||o({status:"ready",transport:{fetch:(n,u)=>s.fetch(Et,n,{...u,instance:he}),connect:n=>s.connect(Et,n,{instance:he})}})},s=>{d||o({status:"failed",message:s instanceof Error?s.message:String(s)})}),()=>{d=!0}},[a,e]),t}var Ot=()=>{};function Ut(e){let{environmentId:a,threadId:t,hostId:o,deviceId:l,platform:d}=e,s=e[za],n=O(),{t:u}=A(),{state:i,loaded:c}=Le(a),L=ua(a),S=ie(()=>({environmentId:a,threadId:t}),[a,t]),C=i.devices.find(v=>v.hostId===o&&v.id===l),p=i.sessions.some(v=>v.threadId===t&&v.hostId===o&&v.deviceId===l);M(()=>{c&&!p&&n.floating?.close(S,s.key)},[n,s.key,c,p,S]),M(()=>(s.setOpenInPanel(()=>{We(a,t,s.key),n.floating?.openPanel(S,ze),n.floating?.close(S,s.key)}),()=>s.setOpenInPanel(null)),[n,a,s,S,t]);let h=Y(v=>s.reportSourceSize(v===null?null:_a(v)),[s]),B=C?.name??u(d==="ios"?"tools.settings.titleIos":"tools.settings.titleAndroid"),m=C?.version??d;return L.status!=="ready"?r(ee,{name:B,description:m,stage:L.status==="failed"?"error":"connecting",message:L.status==="failed"?L.message??u("workspace.needsNewerApp"):u("stream.connecting")}):r(da,{transport:L.transport,platform:d,deviceId:l,deviceName:B,deviceDescription:m,axOverlay:!1,withControls:!1,onHandle:Ot,onStreaming:Ot,onScreen:h})}var ia=(...e)=>e.filter((a,t,o)=>!!a&&a.trim()!==""&&o.indexOf(a)===t).join(" ").trim();var qt=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var Ht=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,t,o)=>o?o.toUpperCase():t.toLowerCase());var ba=e=>{let a=Ht(e);return a.charAt(0).toUpperCase()+a.slice(1)};var Nt={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var Gt=e=>{for(let a in e)if(a.startsWith("aria-")||a==="role"||a==="title")return!0;return!1};var Vt=Ge(({color:e="currentColor",size:a=24,strokeWidth:t=2,absoluteStrokeWidth:o,className:l="",children:d,iconNode:s,...n},u)=>ue("svg",{ref:u,...Nt,width:a,height:a,stroke:e,strokeWidth:o?Number(t)*24/Number(a):t,className:ia("lucide",l),...!d&&!Gt(n)&&{"aria-hidden":"true"},...n},[...s.map(([i,c])=>ue(i,c)),...Array.isArray(d)?d:[d]]));var b=(e,a)=>{let t=Ge(({className:o,...l},d)=>ue(Vt,{ref:d,iconNode:a,className:ia(`lucide-${qt(ba(e))}`,`lucide-${e}`,o),...l}));return t.displayName=ba(e),t};var lr=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],De=b("camera",lr);var sr=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Pe=b("chevron-down",sr);var dr=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Ae=b("chevron-left",dr);var nr=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],re=b("ellipsis",nr);var ur=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],le=b("house",ur);var ir=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Te=b("info",ir);var fr=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],Be=b("moon",fr);var cr=[["path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4",key:"daa4of"}],["rect",{width:"10",height:"7",x:"12",y:"13",rx:"2",key:"1nb8gs"}]],Me=b("picture-in-picture-2",cr);var pr=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Re=b("power",pr);var mr=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],xe=b("rotate-ccw",mr);var gr=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Fe=b("rotate-cw",gr);var Lr=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],Ee=b("sliders-horizontal",Lr);var hr=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Ie=b("smartphone",hr);var xr=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Oe=b("square",xr);var Ir=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],Ue=b("sun",Ir);var Cr=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],qe=b("type",Cr);var Sr=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Q=b("x",Sr);function yr(e,a){let t=o=>a(o==="hub"?"versions.hubName":"versions.agentName");return e.status==="starting"?a("panel.startingHost"):e.status!=="installing"?e.message??"":e.tool&&e.toVersion?e.fromVersion?a("panel.updatingTool",{tool:t(e.tool),from:e.fromVersion,to:e.toVersion}):a("panel.installingTool",{tool:t(e.tool),to:e.toVersion}):a("panel.installing")}function ka(){let{t:e}=A();return a=>yr(a,e)}function zt(e){let{t:a}=A(),t=ka(),[o,l]=g(!1),d=e.detail;return!d||d.status==="ready"||d.status==="idle"?null:d.status==="failed"?f("div",{role:"alert",className:"flex items-start gap-2 border-b bg-destructive/5 px-3 py-2 text-xs",children:[f("div",{className:"min-w-0 flex-1 space-y-0.5",children:[r("p",{className:"font-medium text-destructive-foreground",children:a("panel.hostFailed")}),d.message?r("p",{className:"whitespace-pre-wrap break-words text-muted-foreground",children:d.message}):null]}),f(y,{size:"xs",variant:"outline",disabled:o,onClick:()=>{l(!0),e.onRetry().finally(()=>l(!1))},children:[o?r(z,{size:"xs"}):r(Fe,{}),a(o?"panel.retrying":"panel.retry")]})]}):f("div",{role:"status",className:"flex items-center gap-2 border-b px-3 py-2 text-xs text-muted-foreground",children:[r(z,{size:"xs"}),r("span",{className:"min-w-0 flex-1",children:t(d)})]})}var Da=["hub","agent"],Pa=e=>e!==void 0&&!e.installedVersions.includes(e.requiredVersion);function _t(e){let{t:a}=A(),t=oe(),o=O(),[l,d]=g(null),[s,n]=g(null),[u,i]=g(!1),c=e.host?.tools,L=e.busy||l!==null,S=p=>{d(p),n(null),i(!1),(p==="check"?t("inspect",e.environmentId):t("updateTool",e.environmentId,{tool:p})).then(()=>i(p==="check")).catch(()=>{n(a(p==="check"?"versions.checkFailed":"versions.updateFailed")),p!=="check"&&o.notify(a("versions.updateFailed"),"error")}).finally(()=>d(null))},C=p=>p??a("versions.none");return f(tt,{children:[f(ot,{render:r(y,{size:"xs",variant:"ghost","aria-label":a("versions.title")}),children:[r(Te,{}),a("versions.title"),Da.some(p=>Pa(c?.[p]))?r("span",{className:"size-1.5 rounded-full bg-warning","aria-hidden":!0}):null]}),r(rt,{side:"bottom",align:"start",className:"w-80",children:f("div",{className:"space-y-3 text-xs",children:[Da.map(p=>{let h=c?.[p];return f("section",{className:"space-y-1",children:[r("h4",{className:"font-medium text-foreground",children:a(p==="hub"?"versions.hubName":"versions.agentName")}),f("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-muted-foreground",children:[r("dt",{children:a("versions.required")}),r("dd",{className:"font-mono",children:C(h?.requiredVersion)}),r("dt",{children:a("versions.installed")}),r("dd",{className:"font-mono",children:h&&h.installedVersions.length>0?h.installedVersions.join(", "):a("versions.none")}),r("dt",{children:a("versions.running")}),r("dd",{className:"font-mono",children:C(h?.runningVersion)})]}),Pa(h)?f(y,{size:"xs",variant:"outline",disabled:L,onClick:()=>S(p),children:[l===p?r(z,{size:"xs"}):null,a("versions.updateTo",{version:h?.requiredVersion??""})]}):null]},p)}),c===void 0?r("p",{className:"text-muted-foreground",children:a("versions.unknown")}):null,Da.some(p=>Pa(c?.[p]))?r("p",{className:"text-muted-foreground",children:a("versions.pendingPolicy")}):null,s?r("p",{role:"alert",className:"text-destructive-foreground",children:s}):null,f("div",{className:"flex items-center justify-between gap-2 border-t pt-2",children:[r("p",{role:"status",className:"text-muted-foreground",children:a(u?"versions.checked":"versions.checkHint")}),f(y,{size:"xs",variant:"ghost",disabled:L,onClick:()=>S("check"),children:[l==="check"?r(z,{size:"xs"}):null,a("versions.check")]})]})]})})]})}var Aa=[{api:"35",name:"Android 15"},{api:"30",name:"Android 11"}],Wt=Aa[0].api;var He=e=>e>=1073741824?`${(e/1073741824).toFixed(2)} GB`:`${(e/1048576).toFixed(1)} MB`;function Kt(e){let{phase:a,receivedBytes:t,totalBytes:o,bytesPerSecond:l}=e,d=a==="download"&&t!==void 0&&o?{received:t,total:o}:null,s=d&&l?(d.total-d.received)/l:null;return{titleKey:`environment.stages.${a??"starting"}`,component:e.component??"",percent:d?Math.floor(d.received/d.total*100):null,transferred:d?{done:He(d.received),total:He(d.total)}:null,speed:d&&l?He(l):null,minutesLeft:s===null?null:Math.ceil(s/60),slow:s!==null&&s>1200}}var Xt=e=>e.source==="private"&&e.ready;function $t(e){return e.supported?e.freeBytes!==null&&e.freeBytes<e.requiredFreeBytes?"environment.notEnoughSpace":null:e.reasonCode?`environment.reasons.${e.reasonCode}`:"environment.unsupported"}function jt(e,a){return e.cacheBytes>0||a==="android"&&e.deviceDataBytes>0}function Zt(e){let{t:a}=A(),t=Kt(e.progress),o=a(t.titleKey,{component:t.component}),l=[t.transferred?a("environment.transferred",t.transferred):null,t.speed?a("environment.speed",{speed:t.speed}):null,t.minutesLeft===null?null:a("environment.timeLeft",{minutes:String(t.minutesLeft)})].filter(d=>d!==null);return f("div",{role:"status",className:"space-y-2",children:[f("p",{className:"flex items-center gap-2 font-medium text-foreground",children:[r(z,{size:"xs"}),o]}),t.percent===null?null:r(Xa,{shape:"bar","aria-label":o,used:t.percent,limit:100,warnAt:1.1}),l.length>0?r("p",{className:"flex flex-wrap gap-x-3 gap-y-0.5",children:l.map(d=>r("span",{children:d},d))}):null,t.slow?r("p",{className:"text-warning-foreground",children:a("environment.slowDownload")}):null,r("p",{children:a("environment.continues")}),r(y,{size:"sm",variant:"outline",disabled:e.cancelling,onClick:e.onCancel,children:a("environment.cancel")})]})}function Jt(e){let{t:a}=A(),t=oe(),o=O(),d=o.commands.useSubscription("environmentProgress",{},{environmentId:e.environmentId}).data,[s,n]=g(!1),[u,i]=g("android"),[c,L]=g(""),[S,C]=g(""),[p,h]=g(null),[B,m]=g(!1),[v,R]=g(!1),[F,_]=g(!1),[T,k]=g(null),[U,W]=g(!1),[ce,q]=g(!1),[K,$]=g(void 0),G=d?.status==="working",x=T!==null||G,H=d&&d.id!==K?d:null;M(()=>{(G||H?.status==="failed")&&n(!0),H?.status==="done"&&H.plan?.platform===u&&h(H.plan)},[H,u,G]);let I=()=>{h(null),m(!1),R(!1),_(!1),q(!1),$(d?.id)},D=async(w,ae={})=>{k(w),W(!1),q(!1),$(d?.id);try{let So=await t(w,e.environmentId,{platform:u,directory:c,version:S,...ae});w==="cleanupEnvironment"?h(await t("environmentPlan",e.environmentId,{platform:u,directory:c,version:S})):w!=="prepareEnvironment"&&h(So),q(w==="cleanupEnvironment")}catch{W(!0),o.notify(a("environment.failed"),"error")}finally{k(null)}},E=p?$t(p):null,N=w=>w===null?a("environment.unknownSize"):He(w),ne=p!==null&&Xt(p);return f(Je,{open:s,onOpenChange:n,className:"w-full text-left",children:[r(Qe,{render:r(y,{variant:"outline",size:"sm",className:"w-full"}),children:a("environment.title")}),r(Ye,{children:f("div",{className:"space-y-3 rounded-md border p-3 text-xs",children:[G?r(Zt,{progress:d,cancelling:T==="cancelEnvironment",onCancel:()=>{k("cancelEnvironment"),t("cancelEnvironment",e.environmentId,{}).catch(()=>{W(!0),o.notify(a("environment.failed"),"error")}).finally(()=>k(null))}}):f(Z,{children:[r("p",{children:a("environment.description")}),e.iosSupported?r(ve,{variant:"segmented",disabled:x,value:[u],onValueChange:w=>{let ae=w[0];(ae==="android"||ae==="ios")&&(i(ae),C(""),I())},children:["android","ios"].map(w=>r(we,{value:w,size:"segmented",children:a(w==="ios"?"panel.platformIos":"panel.platformAndroid")},w))}):null,f("label",{className:"block space-y-1",children:[r("span",{children:a("environment.directory")}),r(te,{value:c,disabled:x,onChange:w=>{L(w.target.value),I()},placeholder:a("environment.defaultDirectory")})]}),r("p",{children:a("environment.directoryHint")}),u==="android"?f("div",{className:"space-y-1",children:[r("span",{children:a("environment.androidVersion")}),r(ve,{variant:"segmented",className:"flex-wrap",disabled:x,value:[S||Wt],onValueChange:w=>{let ae=w[0];ae&&(C(ae),I())},children:Aa.map(w=>r(we,{value:w.api,size:"segmented",children:a("environment.androidVersionOption",{name:w.name,api:w.api})},w.api))})]}):f("label",{className:"block space-y-1",children:[r("span",{children:a("environment.iosVersion")}),r(te,{value:S,disabled:x,onChange:w=>{C(w.target.value),I()},placeholder:a("environment.iosVersionPlaceholder")})]}),r(y,{size:"sm",variant:"outline",disabled:x,onClick:()=>{D("environmentPlan")},children:a("environment.inspect")}),p?f("div",{className:"space-y-2",children:[f("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 break-all",children:[r("dt",{children:a("environment.source")}),r("dd",{children:a(`environment.sources.${p.source}`)}),r("dt",{children:a("environment.version")}),r("dd",{children:p.version||a("environment.versionRequired")}),r("dt",{children:a("environment.location")}),r("dd",{children:p.root}),p.existingSdkRoot?f(Z,{children:[r("dt",{children:a("environment.existingSdk")}),r("dd",{children:p.existingSdkRoot})]}):null,r("dt",{children:a("environment.download")}),r("dd",{children:p.downloadBytes===0?a("environment.nothingToDownload"):N(p.downloadBytes)}),r("dt",{children:a("environment.free")}),r("dd",{children:N(p.freeBytes)}),r("dt",{children:a("environment.required")}),r("dd",{children:N(p.requiredFreeBytes)})]}),p.source==="external"?r("p",{children:a("environment.external")}):null,p.reasonCode&&p.supported?r("p",{role:"status",children:a(`environment.reasons.${p.reasonCode}`)}):null,r("a",{className:"underline",href:p.guidanceUrl,target:"_blank",rel:"noreferrer",children:a("environment.guide")}),u==="ios"?r("p",{children:a("environment.appleOwnership")}):r("p",{children:a("environment.privateOwnership")}),ne?r("p",{role:"status",className:"font-medium text-foreground",children:a("environment.ready")}):f(Z,{children:[r("ul",{children:p.licenses.map(w=>r("li",{children:r("a",{className:"underline",href:w.url,target:"_blank",rel:"noreferrer",children:a(u==="ios"?"environment.appleLicense":"environment.androidLicense")})},w.url))}),f("label",{className:"flex items-center gap-2",children:[r(Xe,{checked:B,disabled:x,onCheckedChange:w=>m(!!w)}),r("span",{children:a("environment.acceptLicense")})]}),u==="ios"?f("label",{className:"flex items-center gap-2",children:[r(Xe,{checked:v,disabled:x,onCheckedChange:w=>R(!!w)}),r("span",{children:a("environment.confirmApple")})]}):null,E?r("p",{role:"alert",className:"font-medium text-warning-foreground",children:a(E)}):null,r(y,{size:"sm",disabled:x||!p.supported||!B||u==="ios"&&(!v||!S)||p.freeBytes===null||p.freeBytes<p.requiredFreeBytes,onClick:()=>{D("prepareEnvironment",{acceptLicenses:B,confirmAppleInstall:v})},children:a("environment.prepare")})]}),jt(p,u)?f("div",{className:"space-y-2 border-t pt-2",children:[r("p",{children:a("environment.retention")}),r(y,{size:"sm",variant:"outline",disabled:x||p.cacheBytes===0,onClick:()=>{D("cleanupEnvironment",{category:"cache",confirm:!0})},children:a("environment.cleanCache",{size:N(p.cacheBytes)})}),u==="android"?f(Z,{children:[r("p",{children:a("environment.deviceData",{size:N(p.deviceDataBytes)})}),f("label",{className:"flex items-center gap-2",children:[r(Xe,{checked:F,disabled:x,onCheckedChange:w=>_(!!w)}),r("span",{children:a("environment.confirmData")})]}),r(y,{size:"sm",variant:"destructive",disabled:x||!F||p.deviceDataBytes===0,onClick:()=>{D("cleanupEnvironment",{category:"devices",confirm:F})},children:a("environment.cleanDevices")})]}):null]}):null]}):null]}),T!==null&&!G?f("p",{role:"status",className:"flex items-center gap-2",children:[r(z,{size:"xs"}),a("environment.working")]}):null,U?r("p",{role:"alert",className:"text-destructive-foreground",children:a("environment.failed")}):null,H?.status==="failed"?f("div",{role:"alert",className:"space-y-1 text-destructive-foreground",children:[r("p",{children:a("environment.prepareFailed")}),H.message?r("p",{className:"whitespace-pre-wrap break-words text-muted-foreground",children:H.message}):null]}):null,H?.status==="cancelled"?r("p",{role:"status",children:a("environment.cancelled")}):null,ce?r("p",{role:"status",children:a("environment.cleaned")}):null]})})]})}var Qt=["small","default","large","extra-large"],vr=e=>Qt.includes(e);function Yt(e){let{t:a}=A(),{handle:t,controls:o}=e,l=o.detail?.settings,d=!t?.inputConnected,s=l?.appearance==="dark"?"light":"dark",n=u=>a(u==="small"?"rail.textSmall":u==="default"?"rail.textDefault":u==="large"?"rail.textLarge":"rail.textExtraLarge");return r("aside",{"aria-label":a("rail.label"),className:"pointer-events-none absolute inset-y-0 right-0 z-10 flex w-14 flex-col items-center justify-center gap-2 overflow-y-auto py-3 pr-2",children:f("div",{className:"pointer-events-auto flex shrink-0 flex-col items-center gap-1 rounded-full border border-border/50 bg-background/80 p-2 shadow-sm",children:[r(se,{label:a("rail.home"),disabled:d,onClick:()=>t?.pressButton("home"),children:r(le,{})}),e.platform==="android"?f(Z,{children:[r(se,{label:a("rail.back"),disabled:d,onClick:()=>t?.pressButton("back"),children:r(Ae,{})}),r(se,{label:a("rail.recents"),disabled:d,onClick:()=>t?.pressButton("recents"),children:r(Oe,{})}),f($e,{children:[r(Ze,{render:r(y,{size:"icon-sm",variant:"ghost","aria-label":a("rail.rotate"),disabled:o.disabled}),children:r(xe,{})}),f(je,{side:"left",children:[r(ye,{onClick:()=>{o.act({type:"setOrientation",value:"portrait"})},children:a("rail.portrait")}),r(ye,{onClick:()=>{o.act({type:"setOrientation",value:"landscape_left"})},children:a("rail.landscape")})]})]})]}):r(se,{label:a("rail.rotate"),disabled:d,onClick:()=>t?.rotate(),children:r(xe,{})}),r(wr,{}),r(se,{label:a(s==="dark"?"rail.toDark":"rail.toLight"),disabled:o.disabled||!l?.appearance,onClick:()=>{o.act({type:"setAppearance",value:s})},children:l?.appearance==="dark"?r(Ue,{}):r(Be,{})}),f($e,{children:[r(Ze,{render:r(y,{size:"icon-sm",variant:"ghost","aria-label":a("rail.textSize"),disabled:o.disabled||!l?.textSize}),children:r(qe,{})}),r(je,{side:"left",children:r(Ya,{value:l?.textSize??"",onValueChange:u=>{vr(u)&&o.act({type:"setTextSize",value:u})},children:Qt.map(u=>r(et,{value:u,children:n(u)},u))})})]}),r(se,{label:a("rail.tools"),pressed:e.toolsOpen,onClick:e.onTools,children:r(Ee,{})}),r(se,{label:e.screenshotPending?a("rail.capturing"):a("rail.screenshot"),disabled:!e.streaming||e.screenshotPending,onClick:e.onScreenshot,children:r(De,{})}),e.onFloat?r(se,{label:a("rail.float"),onClick:e.onFloat,children:r(Me,{})}):null,f($e,{children:[r(Ze,{render:r(y,{size:"icon-sm",variant:"ghost","aria-label":a("rail.more")}),children:r(re,{})}),f(je,{side:"left",align:"end",children:[f(ye,{onClick:e.onClose,children:[r(Q,{}),a("rail.closePanel")]}),r(Qa,{}),f(ye,{variant:"destructive",onClick:e.onPowerOff,children:[r(Re,{}),a("rail.powerOff")]})]})]})]})})}function wr(){return r("div",{"aria-hidden":!0,className:"my-1 h-px w-5 shrink-0 bg-border/70"})}function se(e){return f(ja,{children:[r(Ja,{render:r(y,{size:"icon-sm",variant:e.pressed?"secondary":"ghost","aria-label":e.label,"aria-pressed":e.pressed,disabled:e.disabled,onClick:e.onClick}),children:e.children}),r(Za,{side:"left",children:e.label})]})}var Ta=(e,a)=>new na("invalid-input",`Invalid ${e}: ${a}.`);var eo=4096,ao=["light","dark"],to=["small","default","large","extra-large"];var oo=["clear","tinted"],ro=["none","grayscale","red-green","green-red","blue-yellow"],lo=["portrait","landscape_left","portrait_upside_down","landscape_right"],so=["camera","microphone","photos","contacts","calendar","reminders","location","notifications","motion","media-library","faceid"];var br=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);var no=e=>{let a=typeof e=="string"?{aps:{alert:e}}:e;if(!br(a))throw Ta("push payload","expected a string or an object");let t;try{t=JSON.stringify(a)}catch{t=void 0}if(t===void 0)throw Ta("push payload","could not be encoded as JSON");if(new TextEncoder().encode(t).length>eo)throw Ta("push payload",`larger than ${String(eo)} bytes`);return t};var kr=new Set(["setAppearance","setTextSize","setToggle","setLiquidGlass","setColorFilter","setLocation","clearLocation","setPermission","openUrl","launchApp","relaunchApp","terminateApp","sendPush"]),Dr=new Set(["setAppearance","setTextSize","setToggle","setOrientation","setLocation","setPermission","openUrl","launchApp","relaunchApp","terminateApp"]),Pr=new Set(["reduceMotion","increaseContrast","reduceTransparency","showBorders","voiceOver"]),Ar=new Set(["reduceMotion","networkEnabled"]),Ba=(e,a)=>(e==="ios"?kr:Dr).has(a.type)?a.type==="setToggle"?(e==="ios"?Pr:Ar).has(a.setting):!0:!1;function fe(e){return f("section",{className:"flex flex-col gap-2 border-b px-3 py-2.5",children:[r("h3",{className:"text-xs font-medium text-muted-foreground",children:e.title}),e.children]})}function de(e){return f("div",{className:"flex min-h-7 items-center justify-between gap-3",children:[r("span",{className:"shrink-0 text-xs text-muted-foreground",children:e.label}),r("div",{className:"flex min-w-0 items-center justify-end",children:e.children})]})}function Ma(e){return r(de,{label:e.label,children:r($a,{"aria-label":e.label,checked:e.checked??!1,disabled:e.disabled||e.checked===void 0,onCheckedChange:a=>{e.onChange(a)}})})}function Ra(e){return r(ve,{"aria-label":e.label,variant:"outline",value:e.value===void 0?[]:[e.value],disabled:e.disabled||e.value===void 0,onValueChange:a=>{let t=e.options.find(o=>o.value===a[0]);t&&e.onChange(t.value)},children:e.options.map(a=>r(we,{size:"xs",value:a.value,children:a.label},a.value))})}function Ne(e){let a=e.options.find(t=>t.value===e.value);return f(La,{value:e.value,disabled:e.disabled,onValueChange:t=>{let o=e.options.find(l=>l.value===t);o&&o.value!==e.value&&e.onChange(o.value)},children:[r(ha,{size:"xs",className:e.width??"w-40","aria-label":e.ariaLabel,children:r(xa,{children:a?a.label:r("span",{className:"text-muted-foreground",children:e.placeholder})})}),r(Ia,{align:"end",alignItemWithTrigger:!1,children:e.options.map(t=>r(Ca,{value:t.value,children:t.label},t.value))})]})}function Fa(e){let[a,t]=g(""),o=a.trim()||e.fallback||"",l=()=>{o&&e.onSubmit(o).then(()=>t(""))};return f("form",{className:"flex gap-1.5",onSubmit:d=>{d.preventDefault(),l()},children:[r(te,{size:"compact",className:"min-w-0 flex-1 font-mono",placeholder:e.placeholder,"aria-label":e.placeholder,value:a,disabled:e.disabled,onChange:d=>t(d.target.value)}),r(y,{type:"submit",size:"xs",variant:"outline",disabled:e.disabled||!o,children:e.action})]})}var uo=[{key:"tools.location.sanFrancisco",latitude:37.7749,longitude:-122.4194},{key:"tools.location.newYork",latitude:40.7128,longitude:-74.006},{key:"tools.location.london",latitude:51.5074,longitude:-.1278},{key:"tools.location.stockholm",latitude:59.3293,longitude:18.0686},{key:"tools.location.tokyo",latitude:35.6762,longitude:139.6503}];function fo(e){let{t:a}=A(),[t,o]=g(e.current?String(e.current.latitude):""),[l,d]=g(e.current?String(e.current.longitude):""),s={latitude:Number(t),longitude:Number(l)},n=t.trim()!==""&&l.trim()!==""&&Math.abs(s.latitude)<=90&&Math.abs(s.longitude)<=180,u=(i,c)=>e.act({type:"setLocation",latitude:i,longitude:c});return f(fe,{title:a("tools.location.title"),children:[f("div",{className:"flex gap-1.5",children:[r(te,{size:"compact",className:"min-w-0 flex-1 font-mono",placeholder:a("tools.location.latitude"),"aria-label":a("tools.location.latitude"),inputMode:"decimal",value:t,disabled:e.disabled,onChange:i=>o(i.target.value)}),r(te,{size:"compact",className:"min-w-0 flex-1 font-mono",placeholder:a("tools.location.longitude"),"aria-label":a("tools.location.longitude"),inputMode:"decimal",value:l,disabled:e.disabled,onChange:i=>d(i.target.value)})]}),f("div",{className:"flex flex-wrap items-center gap-1.5",children:[f(La,{value:null,disabled:e.disabled,onValueChange:i=>{let c=uo.find(L=>L.key===i);c&&(o(String(c.latitude)),d(String(c.longitude)),u(c.latitude,c.longitude))},children:[r(ha,{size:"xs",className:"w-32","aria-label":a("tools.location.preset"),children:r(xa,{children:r("span",{className:"text-muted-foreground",children:a("tools.location.presetPlaceholder")})})}),r(Ia,{align:"start",alignItemWithTrigger:!1,children:uo.map(i=>r(Ca,{value:i.key,children:a(i.key)},i.key))})]}),r(y,{size:"xs",variant:"outline",disabled:e.disabled||!n,onClick:()=>{u(s.latitude,s.longitude)},children:a("tools.location.set")}),e.canClear?r(y,{size:"xs",variant:"ghost",disabled:e.disabled,onClick:()=>{o(""),d(""),e.act({type:"clearLocation"})},children:a("tools.location.clear")}):null]}),e.current?r("p",{role:"status",className:"text-xs text-muted-foreground",children:a("tools.location.current",{latitude:e.current.latitude,longitude:e.current.longitude})}):null]})}var Tr={camera:"tools.permissions.camera",microphone:"tools.permissions.microphone",photos:"tools.permissions.photos",contacts:"tools.permissions.contacts",calendar:"tools.permissions.calendar",reminders:"tools.permissions.reminders",location:"tools.permissions.location",notifications:"tools.permissions.notifications",motion:"tools.permissions.motion","media-library":"tools.permissions.mediaLibrary",faceid:"tools.permissions.faceId"},Br=new Set(["camera","microphone","photos","contacts","calendar","location","notifications","motion"]);function co(e){let{t:a}=A(),t=e.platform==="ios",[o,l]=g(""),[d,s]=g("camera"),n=o.trim()||e.defaultAppId,u=so.filter(c=>t||Br.has(c)).map(c=>({value:c,label:a(!t&&c==="motion"?"tools.permissions.activity":Tr[c])})),i=c=>{e.act({type:"setPermission",appId:n,permission:d,decision:c})};return f(fe,{title:a("tools.permissions.title"),children:[r(te,{size:"compact",className:"font-mono",placeholder:e.defaultAppId||a("tools.permissions.appId"),"aria-label":a("tools.permissions.appId"),value:o,disabled:e.disabled,onChange:c=>l(c.target.value)}),f("div",{className:"flex flex-wrap items-center gap-1.5",children:[r(Ne,{ariaLabel:a("tools.permissions.permission"),value:d,options:u,placeholder:a("tools.unknown"),disabled:e.disabled,onChange:c=>(s(c),Promise.resolve())}),r(y,{size:"xs",variant:"outline",disabled:e.disabled||!n,onClick:()=>i("grant"),children:a("tools.permissions.grant")}),r(y,{size:"xs",variant:"outline",disabled:e.disabled||!n,onClick:()=>i("revoke"),children:a("tools.permissions.revoke")}),t?r(y,{size:"xs",variant:"ghost",disabled:e.disabled||!n,onClick:()=>i("reset"),children:a("tools.permissions.reset")}):null]})]})}var Mr=e=>{let a=e;try{let t=JSON.parse(e);typeof t=="object"&&t!==null&&!Array.isArray(t)&&(a=t)}catch{}try{return no(a),a}catch{return null}};function po(e){let{t:a}=A(),[t,o]=g(""),l=t.trim(),d=l?Mr(l):null,s=e.appId;return f(fe,{title:a("tools.push.title"),children:[r(at,{size:"sm",rows:4,className:"font-mono",placeholder:a("tools.push.placeholder"),"aria-label":a("tools.push.placeholder"),value:t,disabled:e.disabled||!s,onChange:n=>o(n.target.value)}),f("div",{className:"flex items-center gap-2",children:[r(y,{size:"xs",variant:"outline",disabled:e.disabled||!s||d===null,onClick:()=>{s&&d!==null&&e.act({type:"sendPush",appId:s,payload:d})},children:a("tools.push.send")}),s?l&&d===null?r("p",{className:"text-xs text-destructive-foreground",children:a("tools.push.invalid")}):null:r("p",{className:"text-xs text-muted-foreground",children:a("tools.push.needsApp")})]})]})}var io=100;function mo(e){let{t:a}=A(),[t,o]=g(!1),[l,d]=g([]),{transport:s,platform:n,deviceId:u}=e;return M(()=>{if(!t)return;let i=ct({transport:s,platform:n,deviceId:u},(c,L)=>{d(S=>{let C=L?[...c]:[...S,...c];return C.length>io?C.slice(-io):C})});return()=>{i(),d([])}},[t,s,n,u]),f(Je,{open:t,onOpenChange:o,children:[f(Qe,{className:"flex w-full items-center gap-1.5 border-b px-3 py-2.5 text-left text-xs font-medium text-muted-foreground",children:[a("tools.eventLog.title"),r(Pe,{className:`ml-auto size-3.5 transition-transform ${t?"rotate-180":""}`})]}),r(Ye,{children:r("ol",{className:"max-h-64 overflow-y-auto px-3 py-2 font-mono text-ui-2xs leading-relaxed",children:l.length===0?r("li",{className:"text-muted-foreground",children:a("tools.eventLog.empty")}):l.map(i=>f("li",{className:"flex gap-2",children:[r("span",{className:"shrink-0 text-muted-foreground",children:i.timestamp.slice(11,19)}),r("span",{className:"truncate",children:i.summary})]},i.id))})})]})}var Rr=640,Fr={light:"tools.settings.light",dark:"tools.settings.dark"},Er={small:"tools.settings.textSmall",default:"tools.settings.textDefault",large:"tools.settings.textLarge","extra-large":"tools.settings.textExtraLarge"},Or={clear:"tools.settings.glassClear",tinted:"tools.settings.glassTinted"},Ur={none:"tools.settings.filterNone",grayscale:"tools.settings.filterGrayscale","red-green":"tools.settings.filterRedGreen","green-red":"tools.settings.filterGreenRed","blue-yellow":"tools.settings.filterBlueYellow"},qr={portrait:"tools.settings.orientationPortrait",landscape_left:"tools.settings.orientationLandscapeLeft",portrait_upside_down:"tools.settings.orientationUpsideDown",landscape_right:"tools.settings.orientationLandscapeRight"},Hr=[{setting:"reduceMotion",labelKey:"tools.settings.reduceMotion"},{setting:"increaseContrast",labelKey:"tools.settings.increaseContrast"},{setting:"reduceTransparency",labelKey:"tools.settings.reduceTransparency"},{setting:"showBorders",labelKey:"tools.settings.showBorders"},{setting:"voiceOver",labelKey:"tools.settings.voiceOver"},{setting:"networkEnabled",labelKey:"tools.settings.network"}];function go(e){let{t:a}=A(),{device:t,controls:o}=e,{detail:l,pending:d,error:s,foregroundApp:n,disabled:u,act:i}=o,c=l?.settings,L=t.platform==="ios",S=V(null),[C,p]=g(!0);Ha(()=>{let m=S.current?.parentElement;if(!m)return;let v=()=>p(m.clientWidth<Rr);v();let R=new ResizeObserver(v);return R.observe(m),()=>R.disconnect()},[]),M(()=>o.followDevice(),[o.followDevice]);let h=to.map(m=>({value:m,label:a(Er[m])})),B=Hr.filter(m=>Ba(t.platform,{type:"setToggle",setting:m.setting,value:!0}));return f("aside",{ref:S,"aria-label":a("tools.title"),className:`flex min-h-0 flex-col border-l bg-background text-sm ${C?"absolute inset-y-0 right-0 z-10 w-full max-w-72 shadow-lg":"w-72 shrink-0"}`,children:[f("div",{className:"flex h-9 shrink-0 items-center gap-2 border-b px-3",children:[r("span",{className:"font-medium",children:a("tools.title")}),d?r(z,{size:"sm"}):null,r(y,{size:"icon-xs",variant:"ghost-muted","aria-label":a("tools.close"),className:"ml-auto",onClick:e.onClose,children:r(Q,{})})]}),f("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[s?r("p",{role:"alert",className:"border-b bg-destructive/10 px-3 py-2 text-xs text-destructive-foreground",children:s}):null,l===null&&!s?f("div",{className:"flex items-center gap-2 px-3 py-3 text-xs text-muted-foreground",children:[r(z,{size:"sm"}),a("tools.reading")]}):null,f(fe,{title:a("tools.app.title"),children:[r(de,{label:a("tools.app.foreground"),children:r("span",{className:"truncate font-mono text-xs",children:n?.id??a("tools.app.none")})}),n?f("div",{className:"flex gap-1.5",children:[r(y,{size:"xs",variant:"outline",disabled:u,onClick:()=>{i({type:"terminateApp",appId:n.id})},children:a("tools.app.terminate")}),r(y,{size:"xs",variant:"outline",disabled:u,onClick:()=>{i({type:"relaunchApp",appId:n.id})},children:a("tools.app.relaunch")})]}):null,r(Fa,{placeholder:a("tools.app.urlPlaceholder"),action:a("tools.app.open"),disabled:u,onSubmit:m=>i({type:"openUrl",url:m})}),r(Fa,{placeholder:a(L?"tools.app.bundleIdPlaceholder":"tools.app.packagePlaceholder"),action:a("tools.app.launch"),disabled:u,fallback:n?.id,onSubmit:m=>i({type:"launchApp",appId:m})})]}),f(fe,{title:a(L?"tools.settings.titleIos":"tools.settings.titleAndroid"),children:[r(de,{label:a("tools.settings.appearance"),children:r(Ra,{label:a("tools.settings.appearance"),value:c?.appearance,options:ao.map(m=>({value:m,label:a(Fr[m])})),disabled:u,onChange:m=>i({type:"setAppearance",value:m})})}),r(de,{label:a("tools.settings.textSize"),children:r(Ne,{ariaLabel:a("tools.settings.textSize"),value:c?.textSize??null,options:h,placeholder:a("tools.unknown"),disabled:u,onChange:m=>i({type:"setTextSize",value:m})})}),L?f(Z,{children:[r(de,{label:a("tools.settings.liquidGlass"),children:r(Ra,{label:a("tools.settings.liquidGlass"),value:c?.liquidGlass,options:oo.map(m=>({value:m,label:a(Or[m])})),disabled:u,onChange:m=>i({type:"setLiquidGlass",value:m})})}),r(de,{label:a("tools.settings.colorFilter"),children:r(Ne,{ariaLabel:a("tools.settings.colorFilter"),value:c?.colorFilter??null,options:ro.map(m=>({value:m,label:a(Ur[m])})),placeholder:a("tools.unknown"),disabled:u,onChange:m=>i({type:"setColorFilter",value:m})})})]}):r(de,{label:a("tools.settings.orientation"),children:r(Ne,{ariaLabel:a("tools.settings.orientation"),value:null,options:lo.map(m=>({value:m,label:a(qr[m])})),placeholder:a("tools.settings.rotateTo"),disabled:u,onChange:m=>i({type:"setOrientation",value:m})})}),B.map(m=>r(Ma,{label:a(m.labelKey),checked:c?.[m.setting],disabled:u,onChange:v=>i({type:"setToggle",setting:m.setting,value:v})},m.setting))]}),r(fe,{title:a("tools.accessibility.title"),children:r(Ma,{label:a("tools.accessibility.overlay"),checked:e.axOverlay,disabled:!1,onChange:m=>(e.onAxOverlayChange(m),Promise.resolve())})}),r(fo,{current:o.location,canClear:Ba(t.platform,{type:"clearLocation"}),disabled:u,act:i}),r(co,{platform:t.platform,defaultAppId:n?.id??"",disabled:u,act:i}),L?r(po,{appId:n?.id,disabled:u,act:i}):null,L?r(mo,{transport:e.transport,platform:t.platform,deviceId:t.id}):null]})]})}var Nr=2e4,Ea=class extends Error{status;constructor(a){super(`Screenshot capture failed (${a}). Try again.`),this.status=a}};async function Lo(e,a,t,o){let l=AbortSignal.timeout(Nr),d=await e.fetch(`${me(a)}/api/screenshot?device=${encodeURIComponent(t)}`,{method:"POST",signal:o?AbortSignal.any([o,l]):l});if(!d.ok)throw new Ea(d.status);let s=await d.blob();if(!s.size)throw new Error("The device returned an empty screenshot. Try again.");return s.type?s:new Blob([s],{type:"image/png"})}var Gr=3e3,Oa=e=>e instanceof Error?e.message:String(e);function ho(e){let{environmentId:a,device:t}=e,o=oe(),l=O(),{t:d}=A(),[s,n]=g(null),[u,i]=g(null),[c,L]=g(!1),[S,C]=g(null),p=V(!1),h=V(0),B=V(!1),m={hostId:t.hostId,deviceId:t.id},v=T=>o("detail",a,m).then(k=>{h.current===T&&(n(k),C(null))},k=>{h.current===T&&(n(null),C(Oa(k)))});M(()=>{let T=++h.current;return v(T),()=>{h.current++}},[a,t.hostId,t.id]);let R=async T=>{if(p.current||s===null)return!1;p.current=!0;let k=++h.current;L(!0),C(null);try{let U=await o("action",a,{...m,...T});return h.current===k?n(U):await v(++h.current),T.type==="setLocation"?i({latitude:T.latitude,longitude:T.longitude}):T.type==="clearLocation"&&i(null),!0}catch(U){return h.current===k&&C(Oa(U)),l.notify(d("rail.actionFailed"),"error",Oa(U)),!1}finally{p.current=!1,L(!1)}},F=V(()=>{});F.current=()=>{if(p.current||B.current)return;B.current=!0;let T=++h.current;o("detail",a,m).then(k=>{h.current===T&&n(k)},()=>{}).finally(()=>{B.current=!1})};let _=Y(()=>{F.current();let T=setInterval(()=>F.current(),Gr);return()=>clearInterval(T)},[]);return{detail:s,location:u,pending:c,error:S,act:R,followDevice:_,disabled:c||s===null,foregroundApp:e.foreground===void 0?s?.foregroundApp??null:e.foreground}}var Vr=()=>typeof window<"u"&&"ReactNativeWebView"in window;function xo(e){let{t:a}=A(),t=O(),o=ua(e.environmentId),[l,d]=g(null),[s,n]=g(!1),[u,i]=g(!1),[c,L]=g(!1),[S,C]=g(),[p,h]=g(!1),[B,m]=g(null),[v,R]=g(null),F=V(null),_=V(null),T=o.status==="ready"?o.transport:null,k=ho({environmentId:e.environmentId,device:e.device,foreground:S}),U=Y(q=>d(q),[]),W=Y(q=>n(q),[]);M(()=>{if(!T)return;let q=ft({transport:T,platform:e.device.platform,deviceId:e.device.id},C);return()=>{q(),C(void 0)}},[e.device.id,e.device.platform,T]),M(()=>()=>{F.current?.abort(),_.current&&URL.revokeObjectURL(_.current)},[]);let ce=()=>{if(!T||F.current)return;let q=new AbortController;F.current=q,h(!0),m(null),Lo(T,e.device.platform,e.device.id,q.signal).then(K=>{if(q.signal.aborted)return;_.current&&URL.revokeObjectURL(_.current);let $=URL.createObjectURL(K);if(_.current=$,Vr()){R($);return}let G=document.createElement("a");G.href=$,G.download=`${e.device.name.replace(/[^a-z0-9-]/gi,"-")}-${Date.now()}.png`,document.body.append(G),G.click(),G.remove()}).catch(K=>{q.signal.aborted||(m(K instanceof Error?K.message:a("workspace.screenshotFailed")),t.notify(a("workspace.screenshotFailed"),"error",K instanceof Error?K.message:void 0))}).finally(()=>{F.current===q&&(F.current=null,h(!1))})};return o.status!=="ready"?r(ee,{name:e.device.name,description:e.device.version,stage:o.status==="failed"?"error":"connecting",message:o.status==="failed"?o.message??a("workspace.needsNewerApp"):a("stream.connecting"),children:r(y,{size:"sm",variant:"outline",onClick:e.onBack,children:a("workspace.allDevices")})}):f("div",{className:"relative flex min-h-0 min-w-0 flex-1",children:[f("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:[B||k.error&&!u?r("p",{role:"alert",className:"px-3 py-2 text-xs text-destructive-foreground",children:B??k.error}):null,f("div",{className:"relative min-h-0 flex-1",children:[r(da,{transport:o.transport,platform:e.device.platform,deviceId:e.device.id,deviceName:e.device.name,deviceDescription:e.device.version,axOverlay:c,withControls:!0,onHandle:U,onStreaming:W}),r(Yt,{platform:e.device.platform,handle:l,streaming:s,controls:k,screenshotPending:p,onScreenshot:ce,toolsOpen:u,onTools:()=>i(!u),onClose:e.onClose,onPowerOff:e.onPowerOff,onFloat:e.onFloat})]})]}),u?r(go,{device:e.device,controls:k,transport:o.transport,axOverlay:c,onAxOverlayChange:L,onClose:()=>i(!1)}):null,v?f("div",{className:"absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 bg-background/95 p-4",children:[r("img",{src:v,alt:a("workspace.screenshotAlt"),className:"max-h-[80%] max-w-full object-contain"}),r("p",{className:"text-xs text-muted-foreground",children:a("workspace.screenshotSaveHint")}),f(y,{size:"sm",variant:"outline",onClick:()=>R(null),children:[r(Q,{}),a("workspace.closeBrowser")]})]}):null]})}var Ce=e=>e instanceof Error?e.message:String(e);function Io(e){let{environmentId:a,threadId:t}=e,{t:o}=A(),{state:l,loaded:d,error:s,unavailable:n}=Le(a),u=oe(),[i,c]=g(null),[L,S]=g(null),C=Wa(a,t),p=x=>We(a,t,x),h=O(),B=pe(h,"floating"),m=()=>{c(null),u("refresh",a).catch(x=>{c(Ce(x)),h.notify(o("panel.refreshFailed"),"error",Ce(x))})};M(()=>{!d||n||u("refresh",a).catch(()=>{})},[a,d,u,n]);let v=ie(()=>l.sessions.filter(x=>x.threadId===t),[l.sessions,t]),R=_r(v,C),F=R?l.devices.find(x=>x.hostId===R.hostId&&x.id===R.deviceId):void 0,_=F&&R?Se(F):null;M(()=>{h.floating?.present({environmentId:a,threadId:t},_)}),M(()=>()=>h.floating?.present({environmentId:a,threadId:t},null),[h,a,t]);let T=ie(()=>Wr(l),[l]),k=l.hostStatuses[he],U=k?.status==="ready",W=k?.status==="installing"||k?.status==="starting",ce=ka(),q=l.bootingDevices.filter(x=>x.threadId===t),K=l.hosts.flatMap(x=>x.platforms.filter(H=>!H.available)),$=async x=>{c(null),S(x),ga(a,t,j(x));try{await u("open",a,{threadId:t,hostId:x.hostId,deviceId:x.id,platform:x.platform}),p(j(x))}catch(H){ga(a,t,j(x),!1),c(Ce(H)),h.notify(o("panel.openFailed"),"error",Ce(H))}finally{S(null)}},G=x=>{R&&(c(null),u("close",a,{threadId:t,hostId:R.hostId,deviceId:R.deviceId,shutdown:x}).then(()=>p(null)).catch(H=>{c(Ce(H)),h.notify(o("panel.closeFailed"),"error",Ce(H))}))};return n?r(ee,{name:o("panel.title"),stage:"error",message:o("panel.unavailable")}):f("div",{className:"flex size-full min-h-0 flex-col",children:[q.length>0?r("div",{role:"status",className:"border-b px-3 py-2 text-xs text-muted-foreground",children:o("panel.booting",{names:q.map(x=>x.name).join(", ")})}):null,W&&!F?null:r(zt,{detail:k,onRetry:()=>u("refresh",a).catch(()=>{})}),i||s?f("div",{role:"alert",className:"flex items-start gap-2 border-b bg-destructive/5 px-3 py-2 text-xs text-destructive-foreground",children:[r("p",{className:"min-w-0 flex-1 whitespace-pre-wrap break-words",children:i??s}),i?r(y,{size:"icon-xs",variant:"ghost","aria-label":o("panel.dismissError"),onClick:()=>c(null),children:r(Q,{className:"size-3"})}):null]}):null,r("div",{className:"relative flex min-h-0 flex-1",children:F&&R?r(xo,{environmentId:a,device:F,onBack:()=>p(""),onFloat:B?()=>h.floating?.open({environmentId:a,threadId:t},{...Se(F),reason:"user"}):void 0,onPowerOff:()=>G(!0),onClose:()=>G(!1)},`${a}\0${j(F)}`):L||W||!d?r(ee,{name:L?.name??o("panel.title"),...L?{description:L.version}:{},stage:"opening",message:L?L.booted?o("panel.opening"):o("panel.starting"):W&&k?ce(k):o("panel.finding")}):r(zr,{environmentId:a,host:l.hosts.find(x=>x.id===he),grouped:T,hostReady:U,hostFailed:k?.status==="failed",unavailableReasons:K,showNoAvdHint:U&&!l.devices.some(x=>x.platform==="android")&&!K.some(x=>x.platform==="android"),pendingKey:L?j(L):null,onOpen:x=>{$(x)},onRefresh:m})})]})}function zr(e){let{t:a}=A(),t=e.grouped.length===0;return r("div",{className:"flex size-full flex-col overflow-y-auto px-4 py-6 text-sm text-muted-foreground",children:f("div",{className:`mx-auto flex w-full max-w-xl flex-col gap-5 ${t?"items-center text-center":""}`,children:[r(Jt,{environmentId:e.environmentId,iosSupported:!e.unavailableReasons.some(o=>o.reasonCode==="ios-needs-macos")},e.environmentId),t?f(Z,{children:[r(Ie,{className:"size-6 opacity-60"}),r("p",{className:"max-w-sm",children:e.hostFailed?a("panel.hubFailed"):a("panel.empty")})]}):null,e.hostReady?e.grouped.map(o=>f("section",{className:"w-full space-y-2 text-left",children:[f("h3",{className:"flex items-center gap-2 font-medium",children:[r(Ie,{className:"size-4 shrink-0"}),o.platform==="ios"?a("panel.platformIos"):a("panel.platformAndroid")]}),r("ul",{className:"divide-y rounded-md border",children:o.devices.map(l=>r("li",{children:f(y,{variant:"ghost",className:"h-auto min-h-11 w-full justify-between gap-3 rounded-none px-3 py-2 text-left font-normal",disabled:e.pendingKey!==null,onClick:()=>e.onOpen(l),children:[f("span",{className:"min-w-0 flex-1",children:[r("span",{className:"block truncate text-foreground",children:l.name}),f("span",{className:"block text-xs",children:[l.version,","," ",l.booted?a("panel.running"):a("panel.stopped")]})]}),e.pendingKey===j(l)?r(z,{size:"xs"}):r("span",{className:"text-xs",children:l.booted?a("panel.open"):a("panel.start")})]})},j(l)))})]},o.platform)):null,e.unavailableReasons.map(o=>r("p",{className:"max-w-sm text-xs",children:o.reasonCode?a(`unavailable.${o.reasonCode}`,{root:o.sdkRoot??""}):o.reason},`${o.platform}:${o.reasonCode}`)),e.showNoAvdHint?r("p",{className:"max-w-sm text-xs",children:a("panel.noAvd")}):null,f("div",{className:`flex flex-wrap items-center gap-2 ${t?"self-center":"self-start"}`,children:[r(y,{variant:t?"outline":"ghost",size:"sm",onClick:e.onRefresh,children:a("panel.refresh")}),r(_t,{environmentId:e.environmentId,host:e.host,busy:!1})]})]})})}function _r(e,a){if(a!==""){if(a!==null){let t=e.find(o=>j({hostId:o.hostId,id:o.deviceId})===a);if(t)return t}return e.toSorted((t,o)=>o.openedAt.localeCompare(t.openedAt))[0]}}function Wr(e){let a=[];for(let t of["ios","android"]){let o=e.devices.filter(l=>l.platform===t).toSorted((l,d)=>Number(d.booted)-Number(l.booted)||l.name.localeCompare(d.name));o.length>0&&a.push({platform:t,devices:o})}return a}function Co({environmentId:e,threadId:a}){let t=O(),{state:o,loaded:l}=Le(e),d=V(null);return M(()=>{if(!l||!pe(t,"floating"))return;let s=`${e}\0${a}`,n=d.current?.key===s?d.current.seen:null,{seen:u,opened:i}=Ka({environmentId:e,threadId:a,previous:n,sessions:o.sessions,devices:o.devices});d.current={key:s,seen:u};for(let c of i)t.floating?.open({environmentId:e,threadId:a},{...Se(c),reason:"agent",panelId:ze})},[t,e,l,o.devices,o.sessions,a]),null}function Kr(e){return{panels:{device:function(t){return f(Ve,{value:e,children:[r("style",{children:fa}),r("div",{className:`${Ke} flex h-full min-h-0 flex-1 flex-col`,children:r(Io,{environmentId:t.environmentId,threadId:t.threadId})})]})}},views:{deviceFloat:function(t){return f(Ve,{value:e,children:[r("style",{children:fa}),r("div",{className:`${Ke} relative size-full`,children:r(Ut,{...t})})]})},deviceSessions:function(t){return r(Ve,{value:e,children:r(Co,{environmentId:t.environmentId,threadId:t.threadId})})}}}}export{Kr as default};
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import * as NodePath9 from "node:path";
3
3
  import { definePlugin, PLUGIN_PROXY_DIRECT } from "@ycodium-ai/plugin-api";
4
4
 
5
5
  // ../../packages/plugin-api/src/version.ts
6
- var PLUGIN_API_VERSION = 183;
6
+ var PLUGIN_API_VERSION = 185;
7
7
 
8
8
  // src/types.ts
9
9
  var DEVICE_PLATFORMS = ["ios", "android"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/plugin-devices",
3
- "version": "0.2.5854",
3
+ "version": "0.2.5891",
4
4
  "description": "Lets agents drive iOS Simulators and Android Emulators on this machine.",
5
5
  "keywords": [
6
6
  "android",
@@ -34,7 +34,7 @@
34
34
  "tailwindcss": "^4.0.0",
35
35
  "typescript": "~6.0.3",
36
36
  "vite-plus": "0.2.2",
37
- "@ycodium-ai/plugin-api": "0.2.5854",
37
+ "@ycodium-ai/plugin-api": "0.2.5891",
38
38
  "ycodium-sse-stream": "0.0.0"
39
39
  },
40
40
  "ycodium": {
@@ -9,7 +9,7 @@ Use the Devices plugin to run a mobile app on an emulator or simulator on the ma
9
9
 
10
10
  ## Find the tools
11
11
 
12
- The plugin provides `devices_device_list`, `devices_device_open`, `devices_device_screenshot`, and `devices_device_close`. Your harness may add its usual MCP server prefix. If the plugin was enabled during the conversation and these names are missing, use `ycodium_plugin_tools` with `pluginId: "devices"` and call the returned tools through `ycodium_plugin_call`.
12
+ The plugin provides `devices_device_list`, `devices_device_open`, `devices_device_screenshot`, and `devices_device_close`. Your harness may add its usual MCP server prefix. If these names are missing from your direct tool list or the plugin was enabled during the conversation, use `ycodium_tools` with `pluginId: "devices"` and call the returned tools through `ycodium_call`.
13
13
 
14
14
  Everything else goes through the `agent-device` command that `devices_device_open` returns.
15
15