@ycodium-ai/plugin-devices 0.2.3710 → 0.2.3799

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
@@ -54,9 +54,6 @@ var ta=`/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */
54
54
  .my-1:where(:scope, *) {
55
55
  margin-block: calc(var(--spacing, 0.25rem) * 1);
56
56
  }
57
- .my-auto:where(:scope, *) {
58
- margin-block: auto;
59
- }
60
57
  .ml-auto:where(:scope, *) {
61
58
  margin-left: auto;
62
59
  }
@@ -156,9 +153,6 @@ var ta=`/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */
156
153
  .min-w-0:where(:scope, *) {
157
154
  min-width: calc(var(--spacing, 0.25rem) * 0);
158
155
  }
159
- .min-w-40:where(:scope, *) {
160
- min-width: calc(var(--spacing, 0.25rem) * 40);
161
- }
162
156
  .flex-1:where(:scope, *) {
163
157
  flex: 1;
164
158
  }
@@ -471,6 +465,9 @@ var ta=`/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */
471
465
  .text-muted-foreground:where(:scope, *) {
472
466
  color: var(--contrast-muted-foreground);
473
467
  }
468
+ .text-warning-foreground:where(:scope, *) {
469
+ color: var(--warning-foreground);
470
+ }
474
471
  .text-white:where(:scope, *) {
475
472
  color: var(--color-white, #fff);
476
473
  }
@@ -551,7 +548,7 @@ var ta=`/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */
551
548
  }
552
549
  }
553
550
  }
554
- `;var oo=window.__ycodiumPluginHost.react;var{Activity:wr,Children:br,Component:kr,Fragment:Dr,Profiler:Pr,PureComponent:Ar,StrictMode:Tr,Suspense:Br,__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE:Mr,__COMPILER_RUNTIME:Rr,act:Fr,cache:Ur,cacheSignal:Or,captureOwnerStack:Er,cloneElement:qr,createContext:ba,createElement:le,createRef:Hr,forwardRef:Re,isValidElement:Nr,lazy:Gr,memo:Vr,startTransition:zr,unstable_useCacheRefresh:_r,use:Wr,useActionState:Kr,useCallback:se,useContext:ka,useDebugValue:Xr,useDeferredValue:$r,useEffect:A,useEffectEvent:jr,useId:Zr,useImperativeHandle:Jr,useInsertionEffect:Qr,useLayoutEffect:Da,useMemo:de,useOptimistic:Yr,useReducer:el,useRef:q,useState:h,useSyncExternalStore:Pa,useTransition:al,version:tl}=oo;var Aa=ba(null),Fe=Aa.Provider;function O(){let e=ka(Aa);if(e===null)throw new Error("The devices panel has not been registered.");return e}var Ta=window.__ycodiumPluginHost.modules?.["@ycodium-ai/plugin-api/ui"];if(!Ta)throw new Error("This plugin needs a newer Ycodium app. Update the app.");var{HOST_TEAM_VIEW_PREFIX:sl,PLUGIN_UI_BRIDGE_VERSION:dl,PLUGIN_UI_FLOATING_VIEW_PROP:Ba,PLUGIN_UI_GLOBAL_KEY:ul,PLUGIN_UI_HOST_CAPABILITIES:nl,PLUGIN_UI_HOST_COMMAND_PALETTE_UNAVAILABLE_MESSAGE:il,PLUGIN_UI_HOST_UPGRADE_MESSAGE:fl,TEAM_VIEW_KEY_PATTERN:cl,communicationRecordStage:pl,defineTeamView:ml,isTeamViewKey:gl,pluginUiHostHasCapability:ne}=Ta;var ro="deviceFloat",Ue="device",_=e=>`${e.hostId}\0${e.id}`;function he(e){let a={hostId:e.hostId,deviceId:e.id,platform:e.platform};return{viewId:ro,key:_(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 Ma(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 oa=new Map,ra=new Set,Oe=(e,a)=>`${e}\0${a}`;function Ra(e,a){return Pa(t=>(ra.add(t),()=>{ra.delete(t)}),()=>oa.get(Oe(e,a))??null)}function Ee(e,a,t){let o=Oe(e,a);if((oa.get(o)??null)!==t){oa.set(o,t);for(let l of ra)l()}}var la=new Set;function sa(e,a,t,o=!0){let l=`${Oe(e,a)}\0${t}`;o?la.add(l):la.delete(l)}function Fa(e){let a=new Set,t=[];for(let o of e.sessions){if(o.threadId!==e.threadId)continue;let l=e.devices.find(u=>u.hostId===o.hostId&&u.id===o.deviceId);if(l===void 0)continue;let d=_(l);if(a.add(d),e.previous===null||e.previous.has(d))continue;let s=`${Oe(e.environmentId,e.threadId)}\0${d}`;la.delete(s)||t.push(l)}return{seen:a,opened:t}}var qe="ycodium-devices-ui";function k(e){return(a=>le(O().ui[e],{...a,className:`${qe} ${typeof a.className=="string"?a.className:""}`}))}var C=k("Button"),H=k("Spinner"),ie=k("Switch"),Ua=k("Tooltip"),Oa=k("TooltipPopup"),Ea=k("TooltipTrigger"),He=k("Menu"),Ne=k("MenuPopup"),xe=k("MenuItem"),qa=k("MenuSeparator"),Ge=k("MenuTrigger"),Ha=k("MenuRadioGroup"),Na=k("MenuRadioItem"),Y=k("Input"),Ga=k("Textarea"),da=k("Select"),ua=k("SelectTrigger"),na=k("SelectValue"),ia=k("SelectPopup"),fa=k("SelectItem"),Ve=k("Collapsible"),ze=k("CollapsibleTrigger"),_e=k("CollapsiblePanel"),Va=k("ToggleGroup"),za=k("Toggle"),_a=k("Popover"),Wa=k("PopoverTrigger"),Ka=k("PopoverPopup");var{jsx:r,jsxs:f,Fragment:Z}=window.__ycodiumPluginHost.jsxRuntime;function J(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(H,{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 We=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 u=this.rawDecoder.decode(a,{stream:!0});t&&(this.raw+=u.slice(0,u.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 u=0;u<d.length;u++){let n=d[u];if(n!==`
551
+ `;var so=window.__ycodiumPluginHost.react;var{Activity:Dr,Children:Pr,Component:Ar,Fragment:Tr,Profiler:Br,PureComponent:Mr,StrictMode:Rr,Suspense:Fr,__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE:Ur,__COMPILER_RUNTIME:Or,act:Er,cache:qr,cacheSignal:Hr,captureOwnerStack:Nr,cloneElement:Gr,createContext:ka,createElement:le,createRef:Vr,forwardRef:Re,isValidElement:zr,lazy:_r,memo:Wr,startTransition:Kr,unstable_useCacheRefresh:Xr,use:$r,useActionState:jr,useCallback:se,useContext:Da,useDebugValue:Zr,useDeferredValue:Jr,useEffect:T,useEffectEvent:Qr,useId:Yr,useImperativeHandle:el,useInsertionEffect:al,useLayoutEffect:Pa,useMemo:de,useOptimistic:tl,useReducer:ol,useRef:q,useState:h,useSyncExternalStore:Aa,useTransition:rl,version:ll}=so;var Ta=ka(null),Fe=Ta.Provider;function E(){let e=Da(Ta);if(e===null)throw new Error("The devices panel has not been registered.");return e}var Ba=window.__ycodiumPluginHost.modules?.["@ycodium-ai/plugin-api/ui"];if(!Ba)throw new Error("This plugin needs a newer Ycodium app. Update the app.");var{HOST_TEAM_VIEW_PREFIX:nl,PLUGIN_UI_BRIDGE_VERSION:il,PLUGIN_UI_FLOATING_VIEW_PROP:Ma,PLUGIN_UI_GLOBAL_KEY:fl,PLUGIN_UI_HOST_CAPABILITIES:cl,PLUGIN_UI_HOST_COMMAND_PALETTE_UNAVAILABLE_MESSAGE:pl,PLUGIN_UI_HOST_UPGRADE_MESSAGE:ml,TEAM_VIEW_KEY_PATTERN:gl,communicationRecordStage:Ll,defineTeamView:hl,isTeamViewKey:xl,pluginUiHostHasCapability:ne}=Ba;var uo="deviceFloat",Ue="device",_=e=>`${e.hostId}\0${e.id}`;function he(e){let a={hostId:e.hostId,deviceId:e.id,platform:e.platform};return{viewId:uo,key:_(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 Ra(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 oa=new Map,ra=new Set,Oe=(e,a)=>`${e}\0${a}`;function Fa(e,a){return Aa(t=>(ra.add(t),()=>{ra.delete(t)}),()=>oa.get(Oe(e,a))??null)}function Ee(e,a,t){let o=Oe(e,a);if((oa.get(o)??null)!==t){oa.set(o,t);for(let l of ra)l()}}var la=new Set;function sa(e,a,t,o=!0){let l=`${Oe(e,a)}\0${t}`;o?la.add(l):la.delete(l)}function Ua(e){let a=new Set,t=[];for(let o of e.sessions){if(o.threadId!==e.threadId)continue;let l=e.devices.find(u=>u.hostId===o.hostId&&u.id===o.deviceId);if(l===void 0)continue;let d=_(l);if(a.add(d),e.previous===null||e.previous.has(d))continue;let s=`${Oe(e.environmentId,e.threadId)}\0${d}`;la.delete(s)||t.push(l)}return{seen:a,opened:t}}var qe="ycodium-devices-ui";function k(e){return(a=>le(E().ui[e],{...a,className:`${qe} ${typeof a.className=="string"?a.className:""}`}))}var I=k("Button"),H=k("Spinner"),ie=k("Switch"),Oa=k("Tooltip"),Ea=k("TooltipPopup"),qa=k("TooltipTrigger"),He=k("Menu"),Ne=k("MenuPopup"),xe=k("MenuItem"),Ha=k("MenuSeparator"),Ge=k("MenuTrigger"),Na=k("MenuRadioGroup"),Ga=k("MenuRadioItem"),Q=k("Input"),Va=k("Textarea"),da=k("Select"),ua=k("SelectTrigger"),na=k("SelectValue"),ia=k("SelectPopup"),fa=k("SelectItem"),Ve=k("Collapsible"),ze=k("CollapsibleTrigger"),_e=k("CollapsiblePanel"),za=k("ToggleGroup"),_a=k("Toggle"),Wa=k("Popover"),Ka=k("PopoverTrigger"),Xa=k("PopoverPopup");var{jsx:r,jsxs:f,Fragment:Z}=window.__ycodiumPluginHost.jsxRuntime;function J(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(H,{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 We=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 u=this.rawDecoder.decode(a,{stream:!0});t&&(this.raw+=u.slice(0,u.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 u=0;u<d.length;u++){let n=d[u];if(n!==`
555
552
  `&&n!=="\r")continue;if(n==="\r"&&u===d.length-1)break;let i=d.slice(s,u);n==="\r"&&d[u+1]===`
556
553
  `&&u++,t&&(this.raw+=d.slice(s,u+1));let c=this.line(i);i===""&&(o(this.raw,c),this.raw=""),s=u+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(`
557
- `),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 Ke(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:u}=await l.read();if(s||t?.aborted)return;a(u)}}catch(s){if(t?.aborted)return;throw s}finally{t?.removeEventListener("abort",d)}}async function Xa(e,a,t){if(!e.ok)throw await e.body?.cancel().catch(()=>{}),new Error(`Event stream failed (${e.status}).`);let o=new We;await Ke(e,l=>{for(let d of o.push(l))a(d)},t)}var fe=e=>e==="ios"?"/vendor/serve-sim":"/vendor/serve-emu";var lo=1e3,so=500,Xe=(e,a,t)=>`${fe(e.platform)}${a}${t?`?${new URLSearchParams(t).toString()}`:""}`,$a=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()},W=e=>typeof e=="object"&&e!==null,z=(e,a)=>typeof e=="number"&&Number.isFinite(e)?e:a,uo=e=>{let a=e[0],t=W(a)&&W(a.frame)?a.frame:null,o=Math.max(1,z(t?.width,1)),l=Math.max(1,z(t?.height,1)),d=[],s=(u,n)=>{if(d.length>=so||!W(u)||!W(u.frame))return;let i=u.frame,c=z(i.width,0),m=z(i.height,0);!(Math.abs(c-o)<.5&&Math.abs(m-l)<.5)&&c>0&&m>0&&d.push({id:typeof u.AXUniqueId=="string"?u.AXUniqueId:n,label:typeof u.AXLabel=="string"?u.AXLabel:"",role:typeof u.type=="string"?u.type:"",x:z(i.x,0)/o,y:z(i.y,0)/l,width:c/o,height:m/l}),(Array.isArray(u.children)?u.children:[]).forEach((w,v)=>s(w,`${n}.${v}`))};return e.forEach((u,n)=>s(u,String(n))),d},ja=e=>W(e)&&typeof e.error=="string"?e.error:"Unexpected accessibility payload.";async function Ja(e,a){if(e.platform==="ios"){let n=await $a(e,Xe(e,`/helper/${encodeURIComponent(e.deviceId)}/ax`),a);return Array.isArray(n)?{elements:uo(n),errors:[]}:{elements:[],errors:[ja(n)]}}let t=await $a(e,Xe(e,"/api/accessibility",{device:e.deviceId}),a);if(!W(t)||!Array.isArray(t.nodes))return{elements:[],errors:[ja(t)]};let o=t.nodes.filter(n=>W(n)&&W(n.bounds)),l=o[0]?.bounds,d=Math.max(1,z(l?.right,1)),s=Math.max(1,z(l?.bottom,1));return{elements:o.slice(1).flatMap(n=>{let i=n.bounds,c=z(i.left,0),m=z(i.top,0),x=(z(i.right,c)-c)/d,L=(z(i.bottom,m)-m)/s,w=typeof n.text=="string"?n.text:"",v=typeof n.contentDescription=="string"?n.contentDescription:"",b=w||v;if(x>=.95&&L>=.9)return[];if(!b&&n.clickable!==!0)return[];let g=typeof n.className=="string"?n.className:"";return[{id:String(n.id??""),label:b,role:g.split(".").at(-1)??"",x:c/d,y:m/s,width:x,height:L}]}),errors:[]}}var Qa=(e,a,t)=>{let o=new AbortController,l=null,d=()=>{e.transport.fetch(a,{signal:o.signal}).then(s=>Xa(s,u=>{try{t(JSON.parse(u.data))}catch{}},o.signal)).catch(()=>{}).finally(()=>{o.signal.aborted||(l=setTimeout(d,lo))})};return d(),()=>{o.abort(),l!==null&&clearTimeout(l)}};function Ya(e,a){return e.platform!=="ios"?()=>{}:Qa(e,Xe(e,"/appstate",{device:e.deviceId}),t=>{if(W(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 Za=e=>!W(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 et(e,a){return e.platform!=="ios"?()=>{}:Qa(e,Xe(e,"/api/event-log/events",{device:e.deviceId,limit:"100"}),t=>{if(!W(t))return;if(Array.isArray(t.events)){a(t.events.flatMap(l=>Za(l)??[]),!0);return}let o=Za(t.event);o&&a([o],!1)})}function T(){return{t:O().i18n.usePluginTranslation()}}function je(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 at(e){let a=new Uint8Array(e);if(a.byteLength>16){let t=new DataView(e,0,16);if(t.getUint32(0,!1)===1397050709&&t.getUint8(4)===1){let o=t.getBigUint64(8,!1);return{data:a.subarray(16),isKey:(t.getUint8(5)&1)!==0,timestamp:o<=BigInt(Number.MAX_SAFE_INTEGER)?Number(o):null}}}return{data:a,isKey:null,timestamp:null}}var tt=e=>{try{return JSON.parse(e)?.type==="video-session"}catch{return!1}};function ot(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 no={1:"description",2:"keyframe",3:"delta",4:"seed"},$e=class{buffer=new Uint8Array(64*1024);length=0;push(a){if(this.length+a.length>this.buffer.length){let l=this.buffer.length;for(;l<this.length+a.length;)l*=2;let d=new Uint8Array(l);d.set(this.buffer.subarray(0,this.length)),this.buffer=d}this.buffer.set(a,this.length),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=no[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 io={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 rt(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:io[e]??null}var lt={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 ca(e){if(e.stopped)return;let a=o=>{e.configuring=!1,e.connecting(o),e.scheduleRetry("input",()=>ca(e))},t;try{t=e.transport.connect(`${e.vendor}/ws?device=${e.device}&frame-meta=1`)}catch(o){e.events.onInputConnected(!1,o.message),a(o.message);return}e.socket=t,t.onopen=()=>{e.stopped||e.socket!==t||(e.connecting(),e.events.onInputConnected(!0))},t.onmessage=o=>{if(e.stopped||e.socket!==t)return;if(typeof o.data=="string"){tt(o.data)&&(e.closeDecoder(),e.configuring=!1,e.connecting(),e.requestKeyframe());return}let l=at(o.data),d=!e.videoDecoder||e.videoDecoder.state!=="configured",u=l.isKey===null||l.isKey&&d?ot(l.data):null,n=l.isKey??u?.isKey??!1;if(u?.sps&&d){if(e.configuring)return;e.configuring=!0;let i=e.decoderEpoch,c=()=>!e.stopped&&e.socket===t;e.configureDecoder({codec:je(u.sps)},c).then(m=>{!c()||i!==e.decoderEpoch||(e.configuring=!1,e.awaitingKeyframe=!0,m&&e.requestKeyframe())});return}if(d){n||e.requestKeyframe();return}e.decode(n,l.data,l.timestamp)},t.onclose=o=>{e.socket===t&&(e.socket=null,e.closeDecoder(),!e.stopped&&(e.events.onInputConnected(!1,o.reason||`closed ${o.code}`),a(o.reason||void 0)))},t.onerror=()=>t.close()}function st(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=lt[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 dt(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 ut=new TextEncoder,nt=new TextDecoder;function ft(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 it(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 Ze=class{delimiter;buffer=new Uint8Array(64*1024);length=0;pos=0;state="boundary";contentLength=null;scanFrom=0;constructor(a){this.delimiter=a?ut.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>16777216)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){if(this.length+a.length>this.buffer.length){let t=this.buffer.length;for(;t<this.length+a.length;)t*=2;let o=new Uint8Array(t);o.set(this.buffer.subarray(0,this.length)),this.buffer=o}this.buffer.set(a,this.length),this.length+=a.length}lineEnd(a){return this.buffer.subarray(0,this.length).indexOf(10,a)}readBoundary(){let a=this.buffer;if(!this.delimiter)for(;;){let s=this.lineEnd(this.pos);if(s===-1)return!1;let u=nt.decode(a.subarray(this.pos,s)).trim();if(this.pos=s+1,u.startsWith("--"))return this.delimiter=ut.encode(u),this.state="headers",!0}let t=this.delimiter,o=it(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]===45&&a[l+1]===45)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=nt.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=it(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]!==10){t=o+1;continue}let l=o-1;l>this.pos&&this.buffer[l-1]===13&&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 Ze(ft(e.headers.get("content-type")));await Ke(e,l=>{for(let d of o.push(l))a(d)},t)}function Ie(e){e.stopped||e.mjpeg||(e.mjpeg=!0,e.controller?.abort(),e.controller=null,e.closeDecoder(),e.connecting(),e.events.onMjpegFallback?.(),ct(e))}var pa=e=>`${e.vendor}/helper/${e.device}/stream.mjpeg`;async function ct(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,u=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}},n;try{let i=await e.transport.fetch(pa(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||u())},o.signal),!l())return;n="Device stream ended."}catch(i){if(!l())return;n=i.message}l()&&(e.controller=null,o.abort(),e.connecting(n),e.scheduleRetry("video",()=>{ct(e)}))}var co=1e3,ma=15e3,po=16667,mo=8,go=e=>typeof e=="object"&&e!==null&&"present"in e;function mt(e){let{transport:a,platform:t,events:o}=e,l=go(e.output)?e.output:dt(e.output),d=u=>e.globals?.[u]??globalThis[u],s={platform:t,transport:a,events:o,preferMjpeg:e.preferMjpeg===!0,vendor:fe(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 u=d("VideoDecoder"),n=d("EncodedVideoChunk");return u&&n?{VideoDecoder:u,EncodedVideoChunk:n}:null},createBitmap(u){let n=d("createImageBitmap");return n?n(u):Promise.reject(new Error("createImageBitmap is unavailable."))},setStatus(u,n){s.stopped||o.onStatus(u,n)},fail(u){s.stopped||(s.stop(),o.onInputConnected(!1,u),o.onStatus("error",u))},connecting(u){s.firstFrame=!1,s.frameTimer===null&&(s.frameTimer=setTimeout(()=>s.fail("No video received from the device. Reconnect to try again."),ma)),s.setStatus("connecting",u)},paint(u,n,i){if(!s.stopped){if(t==="android"&&(s.screen?.width!==n||s.screen.height!==i)&&(s.screen={width:n,height:i,orientation:n>i?"landscape_left":"portrait"},o.onScreen(s.screen)),!l.present(u,n,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"?Ie(s):(s.closeDecoder(),s.connecting("Video decoder restarted."),s.requestKeyframe())},async configureDecoder(u,n=()=>!s.stopped){let i=s.webCodecs();if(!i)return!1;let c=s.decoderEpoch,m={...u,optimizeForLatency:!0},x=await i.VideoDecoder.isConfigSupported(m).catch(()=>({supported:!1}));if(!n()||c!==s.decoderEpoch)return!1;if(!x.supported)return t==="android"&&s.fail(`This browser cannot decode ${u.codec}.`),!1;try{return(!s.videoDecoder||s.videoDecoder.state==="closed")&&(s.videoDecoder=Lo(s,i)),s.videoDecoder.configure(m),!0}catch(L){return t==="android"&&s.fail(`Video decoder: ${L.message}`),!1}},decode(u,n,i){let c=s.videoDecoder,m=s.webCodecs();if(!(!c||c.state!=="configured"||!m)){if(s.awaitingKeyframe){if(!u)return;s.awaitingKeyframe=!1}if(c.decodeQueueSize>mo){s.recoverDecoder();return}try{c.decode(new m.EncodedVideoChunk({type:u?"key":"delta",timestamp:i??s.timestamp,data:n})),s.timestamp+=po}catch{s.recoverDecoder()}}},requestKeyframe(){t==="android"&&s.socket?.readyState===1&&s.socket.send(JSON.stringify({type:"reset-video",ack:!1}))},scheduleRetry(u,n){s.stopped||s.retryTimers.has(u)||s.retryTimers.set(u,setTimeout(()=>{s.retryTimers.delete(u),n()},co))},send(u){!s.stopped&&s.socket?.readyState===1&&s.socket.send(u)},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 n of s.retryTimers.values())clearTimeout(n);s.retryTimers.clear(),s.primeController?.abort(),s.primeController=null,s.controller?.abort(),s.controller=null;let u=s.socket;s.socket=null,u?.close(),s.closeDecoder()}};return s}function Lo(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 ho=3,xo=4,Io=6,gt=7,Co=13,So=130,yo=2e3,vo=new TextEncoder,wo=new TextDecoder,Je=["portrait","landscape_left","portrait_upside_down","landscape_right"],bo=new Set(Je);function ce(e,a){let t=vo.encode(JSON.stringify(a)),o=new Uint8Array(1+t.length);return o[0]=e,o.set(t,1),o}function ko(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"||!bo.has(o))return null;let d={width:a,height:t,orientation:o};return typeof l=="number"?{...d,screenId:l}:d}function Lt(e,a){xt(e),a?ht(e):Ie(e)}async function ht(e){let a=e.generation,t=++e.videoGeneration,o=new $e,l=new AbortController;e.controller=l;let d=()=>!e.stopped&&e.generation===a&&e.videoGeneration===t&&e.controller===l,s;try{let u=await e.transport.fetch(`${e.vendor}/helper/${e.device}/stream.avcc`,{signal:l.signal});if(!d()){await u.body?.cancel();return}if(!u.ok||!u.body)throw new Error(`stream ${u.status}`);let n=u.body.getReader();for(;;){let i=setTimeout(()=>{d()&&e.fail("Device stream stopped receiving video. Reconnect to try again.")},ma);e.videoReadTimer=i;let c;try{c=await n.read()}finally{clearTimeout(i),e.videoReadTimer===i&&(e.videoReadTimer=null)}let{done:m,value:x}=c;if(!d())return;if(m)break;for(let L of o.push(x))switch(L.type){case"seed":e.createBitmap(new Blob([L.payload],{type:"image/jpeg"})).then(w=>{try{d()&&e.paint(w,w.width,w.height)}finally{w.close()}}).catch(()=>{});break;case"description":{e.awaitingKeyframe=!0;let w=await e.configureDecoder({codec:je(L.payload),description:L.payload},d);if(!d())return;if(!w){if(await n.cancel().catch(()=>{}),!d())return;Ie(e);return}break}case"keyframe":case"delta":e.decode(L.type==="keyframe",L.payload);break}}}catch(u){if(!d())return;s=u.message}d()&&(e.controller=null,l.abort(),e.closeDecoder(),e.connecting(s),e.scheduleRetry("video",()=>{ht(e)}))}async function Do(e,a){let t=new AbortController;e.primeController=t;let o=setTimeout(()=>t.abort(),yo);try{let l=await e.transport.fetch(pa(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 xt(e){if(e.stopped)return;let a=e.generation;if(await Do(e,a),e.stopped||e.generation!==a)return;let t=()=>e.scheduleRetry("input",()=>{xt(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(ce(Co,{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]!==So))try{let s=ko(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 Po(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 It(e){return{sendTouch(a,t,o){e.send(ce(ho,{type:a,...Po(e,t,o)}))},sendKey(a,t){let o=rt(a.code);o!==null&&e.send(ce(Io,{type:t,usage:o}))},pressButton(a){let t=a==="home"?"home":a==="appSwitcher"?"app_switcher":a==="power"?"lock":null;t&&e.send(ce(xo,{button:t}))},rotate(){let a=e.screen?.orientation??"portrait",t=Je[(Je.indexOf(a)+1)%Je.length];e.send(ce(gt,{orientation:t}))},setOrientation(a){e.send(ce(gt,{orientation:a}))}}}function Ct(e){let a=mt(e),t=e.platform==="ios"?It(a):st(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"?Lt(a,l):l?ca(a):a.fail("This browser cannot decode the Android stream (WebCodecs unavailable).")},stop:a.stop,isMjpeg:()=>a.mjpeg,...t}}var Ao=56,To=2e3;function Bo(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 Mo(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 Ro(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 Fo=()=>typeof navigator<"u"&&/iPhone|iPad|iPod/.test(navigator.userAgent);function Qe(e){let{t:a}=T(),t=q(null),o=q(null),[l,d]=h("connecting"),[s,u]=h(),[n,i]=h(null),[c,m]=h({connected:!1}),{onHandle:x,onStreaming:L,onScreen:w,transport:v,platform:b,deviceId:g}=e;A(()=>w?.(n),[w,n]),A(()=>{let p=t.current;if(!p)return;let S=Ct({transport:v,platform:b,deviceId:g,output:p,preferMjpeg:Fo(),events:{onStatus:(I,E)=>{d(I),u(E),L(I==="streaming")},onScreen:i,onInputConnected:(I,E)=>{m({connected:I,...E?{detail:E}:{}}),x({pressButton:S.pressButton,rotate:S.rotate,inputConnected:I})}}});return o.current=S,m({connected:!1}),S.start(),x({pressButton:S.pressButton,rotate:S.rotate,inputConnected:!1}),()=>{S.stop(),o.current=null,x(null),L(!1),i(null)}},[g,x,L,b,v]);let D=q(null),[P,F]=h({width:0,height:0});A(()=>{let p=D.current;if(!p)return;let S=()=>{let E=p.getBoundingClientRect();F(Q=>Q.width===E.width&&Q.height===E.height?Q:{width:E.width,height:E.height})};S();let I=new ResizeObserver(S);return I.observe(p),()=>I.disconnect()},[]);let N=e.withControls?Ao:0,R=de(()=>Bo(Mo(b,n),P.width,P.height,N),[P,N,b,n]),U=Ro(b,n),$=U===90||U===-90?{width:R.height,height:R.width,left:(R.width-R.height)/2,top:(R.height-R.width)/2,transform:`rotate(${U}deg)`}:{width:R.width,height:R.height,...U?{transform:`rotate(${U}deg)`}:{}},[M,G]=h([]);A(()=>{if(!e.axOverlay)return;let p=null,S=null,I=!1,E=async()=>{p=new AbortController;try{let Q=await Ja({transport:v,platform:b,deviceId:g},p.signal);I||G(Q.elements)}catch{}I||(S=setTimeout(()=>{E()},To))};return E(),()=>{I=!0,p?.abort(),S&&clearTimeout(S),G([])}},[g,b,e.axOverlay,v]);let V=q(!1),B=p=>{let S=p.currentTarget.getBoundingClientRect(),I=(p.clientX-S.left)/S.width,E=(p.clientY-S.top)/S.height;return{x:Math.min(1,Math.max(0,I)),y:Math.min(1,Math.max(0,E))}},j=p=>{if(!V.current)return;V.current=!1;let{x:S,y:I}=B(p);o.current?.sendTouch("end",S,I)};return f("div",{ref:D,className:"relative flex size-full min-h-0 min-w-0 items-center justify-center overflow-hidden",style:N?{paddingRight:N}:void 0,tabIndex:0,role:"application","aria-label":a(b==="ios"?"stream.iosScreen":"stream.androidScreen"),onKeyDown:p=>{p.target===p.currentTarget&&(p.metaKey&&!["r","R"].includes(p.key)||(p.preventDefault(),o.current?.sendKey(p.nativeEvent,"down")))},onKeyUp:p=>{p.target===p.currentTarget&&o.current?.sendKey(p.nativeEvent,"up")},children:[f("div",{className:"relative touch-none select-none",style:{width:R.width,height:R.height},onPointerDown:p=>{p.currentTarget.setPointerCapture(p.pointerId),p.currentTarget.parentElement?.focus(),V.current=!0;let{x:S,y:I}=B(p);o.current?.sendTouch("begin",S,I)},onPointerMove:p=>{if(!V.current)return;let{x:S,y:I}=B(p);o.current?.sendTouch("move",S,I)},onPointerUp:j,onPointerCancel:j,children:[r("canvas",{ref:t,className:"absolute top-0 left-0",style:$}),M.length>0?r("div",{className:"pointer-events-none absolute inset-0","aria-hidden":!0,children:M.map(p=>r("div",{className:"absolute border border-info/80 bg-info/10",style:{left:`${p.x*100}%`,top:`${p.y*100}%`,width:`${p.width*100}%`,height:`${p.height*100}%`},children:p.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:p.label}):null},p.id))}):null]}),l==="streaming"&&!c.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:c.detail?a("stream.inputLostDetail",{detail:c.detail}):a("stream.inputLost")})}):null,l!=="streaming"?r("div",{className:"absolute inset-0 bg-background",children:r(J,{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(C,{size:"sm",variant:"outline",onClick:()=>{o.current?.stop(),o.current?.start()},children:a("stream.reconnect")}):null})}):null]})}var Uo={hosts:[],hostStatuses:{},devices:[],sessions:[],bootingDevices:[],revision:0};function pe(e){let t=O().commands.useSubscription("state",{},{environmentId:e});return{state:t.data??Uo,loaded:t.data!==null,error:t.error,unavailable:t.isUnavailable}}function ee(){let e=O();return se((a,t,o={})=>e.commands.invoke(a,o,{environmentId:t}),[e])}var me="local",Ye=class extends Error{code;constructor(a,t,o){super(t,o),this.name="DeviceError",this.code=a}};var St="hub";function ea(e){let a=O(),[t,o]=h({status:"connecting"});return A(()=>{let l=a.network;if(!ne(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:(u,n)=>s.fetch(St,u,{...n,instance:me}),connect:u=>s.connect(St,u,{instance:me})}})},s=>{d||o({status:"failed",message:s instanceof Error?s.message:String(s)})}),()=>{d=!0}},[a,e]),t}var yt=()=>{};function vt(e){let{environmentId:a,threadId:t,hostId:o,deviceId:l,platform:d}=e,s=e[Ba],u=O(),{t:n}=T(),{state:i,loaded:c}=pe(a),m=ea(a),x=de(()=>({environmentId:a,threadId:t}),[a,t]),L=i.devices.find(D=>D.hostId===o&&D.id===l),w=i.sessions.some(D=>D.threadId===t&&D.hostId===o&&D.deviceId===l);A(()=>{c&&!w&&u.floating?.close(x,s.key)},[u,s.key,c,w,x]),A(()=>(s.setOpenInPanel(()=>{Ee(a,t,s.key),u.floating?.openPanel(x,Ue),u.floating?.close(x,s.key)}),()=>s.setOpenInPanel(null)),[u,a,s,x,t]);let v=se(D=>s.reportSourceSize(D===null?null:Ma(D)),[s]),b=L?.name??l,g=L?.version??d;return m.status!=="ready"?r(J,{name:b,description:g,stage:m.status==="failed"?"error":"connecting",message:m.status==="failed"?m.message??n("workspace.needsNewerApp"):n("stream.connecting")}):r(Qe,{transport:m.transport,platform:d,deviceId:l,deviceName:b,deviceDescription:g,axOverlay:!1,withControls:!1,onHandle:yt,onStreaming:yt,onScreen:v})}var aa=(...e)=>e.filter((a,t,o)=>!!a&&a.trim()!==""&&o.indexOf(a)===t).join(" ").trim();var wt=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var bt=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,t,o)=>o?o.toUpperCase():t.toLowerCase());var ga=e=>{let a=bt(e);return a.charAt(0).toUpperCase()+a.slice(1)};var kt={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 Dt=e=>{for(let a in e)if(a.startsWith("aria-")||a==="role"||a==="title")return!0;return!1};var Pt=Re(({color:e="currentColor",size:a=24,strokeWidth:t=2,absoluteStrokeWidth:o,className:l="",children:d,iconNode:s,...u},n)=>le("svg",{ref:n,...kt,width:a,height:a,stroke:e,strokeWidth:o?Number(t)*24/Number(a):t,className:aa("lucide",l),...!d&&!Dt(u)&&{"aria-hidden":"true"},...u},[...s.map(([i,c])=>le(i,c)),...Array.isArray(d)?d:[d]]));var y=(e,a)=>{let t=Re(({className:o,...l},d)=>le(Pt,{ref:d,iconNode:a,className:aa(`lucide-${wt(ga(e))}`,`lucide-${e}`,o),...l}));return t.displayName=ga(e),t};var Oo=[["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"}]],Ce=y("camera",Oo);var Eo=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Se=y("chevron-down",Eo);var qo=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ye=y("chevron-left",qo);var Ho=[["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"}]],ae=y("ellipsis",Ho);var No=[["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"}]],te=y("house",No);var Go=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],ve=y("info",Go);var Vo=[["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"}]],we=y("moon",Vo);var zo=[["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"}]],be=y("picture-in-picture-2",zo);var _o=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],ke=y("power",_o);var Wo=[["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"}]],ge=y("rotate-ccw",Wo);var Ko=[["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"}]],De=y("rotate-cw",Ko);var Xo=[["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"}]],Pe=y("sliders-horizontal",Xo);var $o=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Le=y("smartphone",$o);var jo=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Ae=y("square",jo);var Zo=[["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"}]],Te=y("sun",Zo);var Jo=[["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"}]],Be=y("type",Jo);var Qo=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],K=y("x",Qo);function Yo(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 La(){let{t:e}=T();return a=>Yo(a,e)}function At(e){let{t:a}=T(),t=La(),[o,l]=h(!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(C,{size:"xs",variant:"outline",disabled:o,onClick:()=>{l(!0),e.onRetry().finally(()=>l(!1))},children:[o?r(H,{size:"xs"}):r(De,{}),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(H,{size:"xs"}),r("span",{className:"min-w-0 flex-1",children:t(d)})]})}var ha=["hub","agent"],xa=e=>e!==void 0&&!e.installedVersions.includes(e.requiredVersion);function Tt(e){let{t:a}=T(),t=ee(),[o,l]=h(null),[d,s]=h(null),u=e.host?.tools,n=e.busy||o!==null,i=m=>{l(m),s(null),(m==="check"?t("inspect",e.environmentId):t("updateTool",e.environmentId,{tool:m})).catch(()=>s(a(m==="check"?"versions.checkFailed":"versions.updateFailed"))).finally(()=>l(null))},c=m=>m??a("versions.none");return f(_a,{children:[f(Wa,{render:r(C,{size:"xs",variant:"ghost","aria-label":a("versions.title")}),children:[r(ve,{}),a("versions.title"),ha.some(m=>xa(u?.[m]))?r("span",{className:"size-1.5 rounded-full bg-warning","aria-hidden":!0}):null]}),r(Ka,{side:"bottom",align:"start",className:"w-80",children:f("div",{className:"space-y-3 text-xs",children:[ha.map(m=>{let x=u?.[m];return f("section",{className:"space-y-1",children:[r("h4",{className:"font-medium text-foreground",children:a(m==="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(x?.requiredVersion)}),r("dt",{children:a("versions.installed")}),r("dd",{className:"font-mono",children:x&&x.installedVersions.length>0?x.installedVersions.join(", "):a("versions.none")}),r("dt",{children:a("versions.running")}),r("dd",{className:"font-mono",children:c(x?.runningVersion)})]}),xa(x)?f(C,{size:"xs",variant:"outline",disabled:n,onClick:()=>i(m),children:[o===m?r(H,{size:"xs"}):null,a("versions.updateTo",{version:x?.requiredVersion??""})]}):null]},m)}),u===void 0?r("p",{className:"text-muted-foreground",children:a("versions.unknown")}):null,ha.some(m=>xa(u?.[m]))?r("p",{className:"text-muted-foreground",children:a("versions.pendingPolicy")}):null,d?r("p",{role:"alert",className:"text-destructive-foreground",children:d}):null,f("div",{className:"flex items-center justify-between gap-2 border-t pt-2",children:[r("p",{className:"text-muted-foreground",children:a("versions.checkHint")}),f(C,{size:"xs",variant:"ghost",disabled:n,onClick:()=>i("check"),children:[o==="check"?r(H,{size:"xs"}):null,a("versions.check")]})]})]})})]})}function Bt(e){let{t:a}=T(),t=ee(),l=O().commands.useSubscription("environmentProgress",{},{environmentId:e.environmentId}).data,[d,s]=h(!1),[u,n]=h("android"),[i,c]=h(""),[m,x]=h(""),[L,w]=h(null),[v,b]=h(!1),[g,D]=h(!1),[P,F]=h(!1),[N,R]=h(null),[U,X]=h(!1),[$,M]=h(!1),[G,V]=h(null),B=N!==null||l?.status==="working";A(()=>{l?.status==="done"&&l.plan?.platform===u&&l.id===G&&(w(l.plan),M(!0)),l?.status==="failed"&&l.id===G&&X(!0)},[u,l,G]);let j=()=>{w(null),b(!1),D(!1),F(!1),M(!1),V(null)},p=async(I,E={})=>{R(I),X(!1),M(!1);try{let Q=await t(I,e.environmentId,{platform:u,directory:i,version:m,...E});I==="cleanupEnvironment"?w(await t("environmentPlan",e.environmentId,{platform:u,directory:i,version:m})):I==="prepareEnvironment"?V(Q.id??null):w(Q),M(I==="cleanupEnvironment")}catch{X(!0)}finally{R(null)}},S=I=>I===null?a("environment.unknownSize"):`${(I/1024**3).toFixed(2)} GiB`;return f(Ve,{open:d,onOpenChange:s,className:"w-full text-left",children:[r(ze,{render:r(C,{variant:"outline",size:"sm",className:"w-full"}),children:a("environment.title")}),r(_e,{children:f("div",{className:"space-y-3 rounded-md border p-3 text-xs",children:[r("p",{children:a("environment.description")}),r("div",{className:"flex gap-2",children:["android","ios"].map(I=>r(C,{size:"sm",variant:u===I?"default":"outline",disabled:B,onClick:()=>{n(I),j()},children:a(I==="ios"?"panel.platformIos":"panel.platformAndroid")},I))}),f("label",{className:"block space-y-1",children:[r("span",{children:a("environment.directory")}),r(Y,{value:i,disabled:B,onChange:I=>{c(I.target.value),j()},placeholder:a("environment.defaultDirectory")})]}),r("p",{children:a("environment.directoryHint")}),u==="ios"?f("label",{className:"block space-y-1",children:[r("span",{children:a("environment.iosVersion")}),r(Y,{value:m,disabled:B,onChange:I=>{x(I.target.value),j()},placeholder:a("environment.iosVersionPlaceholder")})]}):null,r(C,{size:"sm",variant:"outline",disabled:B,onClick:()=>{p("environmentPlan")},children:a("environment.inspect")}),L?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.${L.source}`)}),r("dt",{children:a("environment.version")}),r("dd",{children:L.version||a("environment.versionRequired")}),r("dt",{children:a("environment.location")}),r("dd",{children:L.root}),L.existingSdkRoot?f(Z,{children:[r("dt",{children:a("environment.existingSdk")}),r("dd",{children:L.existingSdkRoot})]}):null,r("dt",{children:a("environment.download")}),r("dd",{children:S(L.downloadBytes)}),r("dt",{children:a("environment.free")}),r("dd",{children:S(L.freeBytes)}),r("dt",{children:a("environment.required")}),r("dd",{children:S(L.requiredFreeBytes)})]}),L.source==="external"?r("p",{children:a("environment.external")}):null,L.reasonCode?r("p",{role:"status",children:a(`environment.reasons.${L.reasonCode}`)}):null,r("a",{className:"underline",href:L.guidanceUrl,target:"_blank",rel:"noreferrer",children:a("environment.guide")}),u==="ios"?r("p",{children:a("environment.appleOwnership")}):r("p",{children:a("environment.privateOwnership")}),r("ul",{children:L.licenses.map(I=>r("li",{children:r("a",{className:"underline",href:I.url,target:"_blank",rel:"noreferrer",children:a(u==="ios"?"environment.appleLicense":"environment.androidLicense")})},I.url))}),f("label",{className:"flex items-center gap-2",children:[r(ie,{checked:v,disabled:B,onCheckedChange:b}),r("span",{children:a("environment.acceptLicense")})]}),u==="ios"?f("label",{className:"flex items-center gap-2",children:[r(ie,{checked:g,disabled:B,onCheckedChange:D}),r("span",{children:a("environment.confirmApple")})]}):null,r(C,{size:"sm",disabled:B||!L.supported||!v||u==="ios"&&(!g||!m)||L.freeBytes===null||L.freeBytes<L.requiredFreeBytes,onClick:()=>{p("prepareEnvironment",{acceptLicenses:v,confirmAppleInstall:g})},children:a("environment.prepare")}),f("div",{className:"space-y-2 border-t pt-2",children:[r("p",{children:a("environment.retention")}),r(C,{size:"sm",variant:"outline",disabled:B||L.cacheBytes===0,onClick:()=>{p("cleanupEnvironment",{category:"cache",confirm:!0})},children:a("environment.cleanCache",{size:S(L.cacheBytes)})}),u==="android"?f(Z,{children:[r("p",{children:a("environment.deviceData",{size:S(L.deviceDataBytes)})}),f("label",{className:"flex items-center gap-2",children:[r(ie,{checked:P,disabled:B,onCheckedChange:F}),r("span",{children:a("environment.confirmData")})]}),r(C,{size:"sm",variant:"destructive",disabled:B||!P||L.deviceDataBytes===0,onClick:()=>{p("cleanupEnvironment",{category:"devices",confirm:P})},children:a("environment.cleanDevices")})]}):null]})]}):null,B?f("p",{role:"status",className:"flex items-center gap-2",children:[r(H,{size:"xs"}),a(l?.status==="working"?"environment.preparing":"environment.working")]}):null,U?r("p",{role:"alert",className:"text-destructive-foreground",children:a("environment.failed")}):null,$?r("p",{role:"status",children:a("environment.done")}):null]})})]})}var Mt=["small","default","large","extra-large"],er=e=>Mt.includes(e);function Rt(e){let{t:a}=T(),{handle:t,controls:o}=e,l=o.detail?.settings,d=!t?.inputConnected,s=l?.appearance==="dark"?"light":"dark",u=n=>a(n==="small"?"rail.textSmall":n==="default"?"rail.textDefault":n==="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(oe,{label:a("rail.home"),disabled:d,onClick:()=>t?.pressButton("home"),children:r(te,{})}),e.platform==="android"?f(Z,{children:[r(oe,{label:a("rail.back"),disabled:d,onClick:()=>t?.pressButton("back"),children:r(ye,{})}),r(oe,{label:a("rail.recents"),disabled:d,onClick:()=>t?.pressButton("recents"),children:r(Ae,{})}),f(He,{children:[r(Ge,{render:r(C,{size:"icon-sm",variant:"ghost","aria-label":a("rail.rotate"),disabled:o.disabled}),children:r(ge,{})}),f(Ne,{side:"left",children:[r(xe,{onClick:()=>{o.act({type:"setOrientation",value:"portrait"})},children:a("rail.portrait")}),r(xe,{onClick:()=>{o.act({type:"setOrientation",value:"landscape_left"})},children:a("rail.landscape")})]})]})]}):r(oe,{label:a("rail.rotate"),disabled:d,onClick:()=>t?.rotate(),children:r(ge,{})}),r(ar,{}),r(oe,{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(Te,{}):r(we,{})}),f(He,{children:[r(Ge,{render:r(C,{size:"icon-sm",variant:"ghost","aria-label":a("rail.textSize"),title:a("rail.textSize"),disabled:o.disabled||!l?.textSize}),children:r(Be,{})}),r(Ne,{side:"left",className:"min-w-40",children:r(Ha,{value:l?.textSize??"",onValueChange:n=>{er(n)&&o.act({type:"setTextSize",value:n})},children:Mt.map(n=>r(Na,{value:n,children:u(n)},n))})})]}),r(oe,{label:a("rail.tools"),pressed:e.toolsOpen,onClick:e.onTools,children:r(Pe,{})}),r(oe,{label:e.screenshotPending?a("rail.capturing"):a("rail.screenshot"),disabled:!e.streaming||e.screenshotPending,onClick:e.onScreenshot,children:r(Ce,{})}),e.onFloat?r(oe,{label:a("rail.float"),onClick:e.onFloat,children:r(be,{})}):null,f(He,{children:[r(Ge,{render:r(C,{size:"icon-sm",variant:"ghost","aria-label":a("rail.more"),title:a("rail.more")}),children:r(ae,{})}),f(Ne,{side:"left",align:"end",children:[f(xe,{onClick:e.onClose,children:[r(K,{}),a("rail.closePanel")]}),r(qa,{}),f(xe,{variant:"destructive",onClick:e.onPowerOff,children:[r(ke,{}),a("rail.powerOff")]})]})]})]})})}function ar(){return r("div",{"aria-hidden":!0,className:"my-1 h-px w-5 shrink-0 bg-border/70"})}function oe(e){return f(Ua,{children:[r(Ea,{render:r(C,{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(Oa,{side:"left",children:e.label})]})}var Ia=(e,a)=>new Ye("invalid-input",`Invalid ${e}: ${a}.`);var Ft=4096,Ut=["light","dark"],Ot=["small","default","large","extra-large"];var Et=["clear","tinted"],qt=["none","grayscale","red-green","green-red","blue-yellow"],Ht=["portrait","landscape_left","portrait_upside_down","landscape_right"],Nt=["camera","microphone","photos","contacts","calendar","reminders","location","notifications","motion","media-library","faceid"];var tr=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);var Gt=e=>{let a=typeof e=="string"?{aps:{alert:e}}:e;if(!tr(a))throw Ia("push payload","expected a string or an object");let t;try{t=JSON.stringify(a)}catch{t=void 0}if(t===void 0)throw Ia("push payload","could not be encoded as JSON");if(new TextEncoder().encode(t).length>Ft)throw Ia("push payload",`larger than ${String(Ft)} bytes`);return t};var or=new Set(["setAppearance","setTextSize","setToggle","setLiquidGlass","setColorFilter","setLocation","clearLocation","setPermission","openUrl","launchApp","terminateApp","sendPush"]),rr=new Set(["setAppearance","setTextSize","setToggle","setOrientation","setLocation","clearLocation","setPermission","openUrl","launchApp","terminateApp"]),lr=new Set(["reduceMotion","increaseContrast","reduceTransparency","showBorders","voiceOver"]),sr=new Set(["reduceMotion","networkEnabled"]),Vt=(e,a)=>(e==="ios"?or:rr).has(a.type)?a.type==="setToggle"?(e==="ios"?lr:sr).has(a.setting):!0:!1;function ue(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 re(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 Ca(e){return r(re,{label:e.label,children:r(ie,{"aria-label":e.label,checked:e.checked??!1,disabled:e.disabled||e.checked===void 0,onCheckedChange:a=>{e.onChange(a)}})})}function Sa(e){return r(Va,{"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(za,{size:"xs",value:a.value,children:a.label},a.value))})}function Me(e){let a=e.options.find(t=>t.value===e.value);return f(da,{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(ua,{size:"xs",className:e.width??"w-40","aria-label":e.ariaLabel,children:r(na,{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(fa,{value:t.value,children:t.label},t.value))})]})}function ya(e){let[a,t]=h(""),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(Y,{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(C,{type:"submit",size:"xs",variant:"outline",disabled:e.disabled||!o,children:e.action})]})}var zt=[{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 Wt(e){let{t:a}=T(),[t,o]=h(""),[l,d]=h(""),s={latitude:Number(t),longitude:Number(l)},u=t.trim()!==""&&l.trim()!==""&&Math.abs(s.latitude)<=90&&Math.abs(s.longitude)<=180,n=(i,c)=>e.act({type:"setLocation",latitude:i,longitude:c});return f(ue,{title:a("tools.location.title"),children:[f("div",{className:"flex gap-1.5",children:[r(Y,{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(Y,{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(da,{value:null,disabled:e.disabled,onValueChange:i=>{let c=zt.find(m=>m.key===i);c&&(o(String(c.latitude)),d(String(c.longitude)),n(c.latitude,c.longitude))},children:[r(ua,{size:"xs",className:"w-32","aria-label":a("tools.location.preset"),children:r(na,{children:r("span",{className:"text-muted-foreground",children:a("tools.location.presetPlaceholder")})})}),r(ia,{align:"start",alignItemWithTrigger:!1,children:zt.map(i=>r(fa,{value:i.key,children:a(i.key)},i.key))})]}),r(C,{size:"xs",variant:"outline",disabled:e.disabled||!u,onClick:()=>{n(s.latitude,s.longitude)},children:a("tools.location.set")}),r(C,{size:"xs",variant:"ghost",disabled:e.disabled,onClick:()=>{o(""),d(""),e.act({type:"clearLocation"})},children:a("tools.location.clear")})]})]})}var dr={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"},ur=new Set(["camera","microphone","photos","contacts","calendar","location","notifications","motion"]);function Kt(e){let{t:a}=T(),t=e.platform==="ios",[o,l]=h(""),[d,s]=h("camera"),u=o.trim()||e.defaultAppId,n=Nt.filter(c=>t||ur.has(c)).map(c=>({value:c,label:a(!t&&c==="motion"?"tools.permissions.activity":dr[c])})),i=c=>{e.act({type:"setPermission",appId:u,permission:d,decision:c})};return f(ue,{title:a("tools.permissions.title"),children:[r(Y,{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(Me,{ariaLabel:a("tools.permissions.permission"),value:d,options:n,placeholder:a("tools.unknown"),disabled:e.disabled,onChange:c=>(s(c),Promise.resolve())}),r(C,{size:"xs",variant:"outline",disabled:e.disabled||!u,onClick:()=>i("grant"),children:a("tools.permissions.grant")}),r(C,{size:"xs",variant:"outline",disabled:e.disabled||!u,onClick:()=>i("revoke"),children:a("tools.permissions.revoke")}),t?r(C,{size:"xs",variant:"ghost",disabled:e.disabled||!u,onClick:()=>i("reset"),children:a("tools.permissions.reset")}):null]})]})}var nr=e=>{let a=e;try{let t=JSON.parse(e);typeof t=="object"&&t!==null&&!Array.isArray(t)&&(a=t)}catch{}try{return Gt(a),a}catch{return null}};function Xt(e){let{t:a}=T(),[t,o]=h(""),l=t.trim(),d=l?nr(l):null,s=e.appId;return f(ue,{title:a("tools.push.title"),children:[r(Ga,{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:u=>o(u.target.value)}),f("div",{className:"flex items-center gap-2",children:[r(C,{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 _t=100;function $t(e){let{t:a}=T(),[t,o]=h(!1),[l,d]=h([]),{transport:s,platform:u,deviceId:n}=e;return A(()=>{if(!t)return;let i=et({transport:s,platform:u,deviceId:n},(c,m)=>{d(x=>{let L=m?[...c]:[...x,...c];return L.length>_t?L.slice(-_t):L})});return()=>{i(),d([])}},[t,s,u,n]),f(Ve,{open:t,onOpenChange:o,children:[f(ze,{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(Se,{className:`ml-auto size-3.5 transition-transform ${t?"rotate-180":""}`})]}),r(_e,{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 ir=640,fr={light:"tools.settings.light",dark:"tools.settings.dark"},cr={small:"tools.settings.textSmall",default:"tools.settings.textDefault",large:"tools.settings.textLarge","extra-large":"tools.settings.textExtraLarge"},pr={clear:"tools.settings.glassClear",tinted:"tools.settings.glassTinted"},mr={none:"tools.settings.filterNone",grayscale:"tools.settings.filterGrayscale","red-green":"tools.settings.filterRedGreen","green-red":"tools.settings.filterGreenRed","blue-yellow":"tools.settings.filterBlueYellow"},gr={portrait:"tools.settings.orientationPortrait",landscape_left:"tools.settings.orientationLandscapeLeft",portrait_upside_down:"tools.settings.orientationUpsideDown",landscape_right:"tools.settings.orientationLandscapeRight"},Lr=[{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 jt(e){let{t:a}=T(),{device:t,controls:o}=e,{detail:l,pending:d,error:s,foregroundApp:u,disabled:n,act:i}=o,c=l?.settings,m=t.platform==="ios",x=q(null),[L,w]=h(!0);Da(()=>{let g=x.current?.parentElement;if(!g)return;let D=()=>w(g.clientWidth<ir);D();let P=new ResizeObserver(D);return P.observe(g),()=>P.disconnect()},[]);let v=Ot.map(g=>({value:g,label:a(cr[g])})),b=Lr.filter(g=>Vt(t.platform,{type:"setToggle",setting:g.setting,value:!0}));return f("aside",{ref:x,"aria-label":a("tools.title"),className:`flex min-h-0 flex-col border-l bg-background text-sm ${L?"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(H,{size:"sm"}):null,r(C,{size:"icon-xs",variant:"ghost-muted","aria-label":a("tools.close"),className:"ml-auto",onClick:e.onClose,children:r(K,{})})]}),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(H,{size:"sm"}),a("tools.reading")]}):null,f(ue,{title:a("tools.app.title"),children:[r(re,{label:a("tools.app.foreground"),children:r("span",{className:"truncate font-mono text-xs",children:u?.id??a("tools.app.none")})}),u?f("div",{className:"flex gap-1.5",children:[r(C,{size:"xs",variant:"outline",disabled:n,onClick:()=>{i({type:"terminateApp",appId:u.id})},children:a("tools.app.terminate")}),r(C,{size:"xs",variant:"outline",disabled:n,onClick:()=>{i({type:"launchApp",appId:u.id})},children:a("tools.app.relaunch")})]}):null,r(ya,{placeholder:a("tools.app.urlPlaceholder"),action:a("tools.app.open"),disabled:n,onSubmit:g=>i({type:"openUrl",url:g})}),r(ya,{placeholder:a(m?"tools.app.bundleIdPlaceholder":"tools.app.packagePlaceholder"),action:a("tools.app.launch"),disabled:n,fallback:u?.id,onSubmit:g=>i({type:"launchApp",appId:g})})]}),f(ue,{title:a(m?"tools.settings.titleIos":"tools.settings.titleAndroid"),children:[r(re,{label:a("tools.settings.appearance"),children:r(Sa,{label:a("tools.settings.appearance"),value:c?.appearance,options:Ut.map(g=>({value:g,label:a(fr[g])})),disabled:n,onChange:g=>i({type:"setAppearance",value:g})})}),r(re,{label:a("tools.settings.textSize"),children:r(Me,{ariaLabel:a("tools.settings.textSize"),value:c?.textSize??null,options:v,placeholder:a("tools.unknown"),disabled:n,onChange:g=>i({type:"setTextSize",value:g})})}),m?f(Z,{children:[r(re,{label:a("tools.settings.liquidGlass"),children:r(Sa,{label:a("tools.settings.liquidGlass"),value:c?.liquidGlass,options:Et.map(g=>({value:g,label:a(pr[g])})),disabled:n,onChange:g=>i({type:"setLiquidGlass",value:g})})}),r(re,{label:a("tools.settings.colorFilter"),children:r(Me,{ariaLabel:a("tools.settings.colorFilter"),value:c?.colorFilter??null,options:qt.map(g=>({value:g,label:a(mr[g])})),placeholder:a("tools.unknown"),disabled:n,onChange:g=>i({type:"setColorFilter",value:g})})})]}):r(re,{label:a("tools.settings.orientation"),children:r(Me,{ariaLabel:a("tools.settings.orientation"),value:null,options:Ht.map(g=>({value:g,label:a(gr[g])})),placeholder:a("tools.settings.rotateTo"),disabled:n,onChange:g=>i({type:"setOrientation",value:g})})}),b.map(g=>r(Ca,{label:a(g.labelKey),checked:c?.[g.setting],disabled:n,onChange:D=>i({type:"setToggle",setting:g.setting,value:D})},g.setting))]}),r(ue,{title:a("tools.accessibility.title"),children:r(Ca,{label:a("tools.accessibility.overlay"),checked:e.axOverlay,disabled:!1,onChange:g=>(e.onAxOverlayChange(g),Promise.resolve())})}),r(Wt,{disabled:n,act:i}),r(Kt,{platform:t.platform,defaultAppId:u?.id??"",disabled:n,act:i}),m?r(Xt,{appId:u?.id,disabled:n,act:i}):null,m?r($t,{transport:e.transport,platform:t.platform,deviceId:t.id}):null]})]})}var hr=2e4,va=class extends Error{status;constructor(a){super(`Screenshot capture failed (${a}). Try again.`),this.status=a}};async function Zt(e,a,t,o){let l=AbortSignal.timeout(hr),d=await e.fetch(`${fe(a)}/api/screenshot?device=${encodeURIComponent(t)}`,{method:"POST",signal:o?AbortSignal.any([o,l]):l});if(!d.ok)throw new va(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 Jt=e=>e instanceof Error?e.message:String(e);function Qt(e){let{environmentId:a,device:t}=e,o=ee(),[l,d]=h(null),[s,u]=h(!1),[n,i]=h(null),c=q(!1),m=q(0),x={hostId:t.hostId,deviceId:t.id},L=v=>o("detail",a,x).then(b=>{m.current===v&&(d(b),i(null))},b=>{m.current===v&&(d(null),i(Jt(b)))});return A(()=>{let v=++m.current;return L(v),()=>{m.current++}},[a,t.hostId,t.id]),{detail:l,pending:s,error:n,act:async v=>{if(c.current||l===null)return;c.current=!0;let b=++m.current;u(!0),i(null);try{let g=await o("action",a,{...x,...v});m.current===b?d(g):await L(++m.current)}catch(g){m.current===b&&i(Jt(g))}finally{c.current=!1,u(!1)}},disabled:s||l===null,foregroundApp:e.foreground===void 0?l?.foregroundApp??null:e.foreground}}var xr=()=>typeof window<"u"&&"ReactNativeWebView"in window;function Yt(e){let{t:a}=T(),t=ea(e.environmentId),[o,l]=h(null),[d,s]=h(!1),[u,n]=h(!1),[i,c]=h(!1),[m,x]=h(),[L,w]=h(!1),[v,b]=h(null),[g,D]=h(null),P=q(null),F=q(null),N=t.status==="ready"?t.transport:null,R=Qt({environmentId:e.environmentId,device:e.device,foreground:m}),U=se(M=>l(M),[]),X=se(M=>s(M),[]);A(()=>{if(!N)return;let M=Ya({transport:N,platform:e.device.platform,deviceId:e.device.id},x);return()=>{M(),x(void 0)}},[e.device.id,e.device.platform,N]),A(()=>()=>{P.current?.abort(),F.current&&URL.revokeObjectURL(F.current)},[]);let $=()=>{if(!N||P.current)return;let M=new AbortController;P.current=M,w(!0),b(null),Zt(N,e.device.platform,e.device.id,M.signal).then(G=>{if(M.signal.aborted)return;F.current&&URL.revokeObjectURL(F.current);let V=URL.createObjectURL(G);if(F.current=V,xr()){D(V);return}let B=document.createElement("a");B.href=V,B.download=`${e.device.name.replace(/[^a-z0-9-]/gi,"-")}-${Date.now()}.png`,document.body.append(B),B.click(),B.remove()}).catch(G=>{M.signal.aborted||b(G instanceof Error?G.message:a("workspace.screenshotFailed"))}).finally(()=>{P.current===M&&(P.current=null,w(!1))})};return t.status!=="ready"?r(J,{name:e.device.name,description:e.device.version,stage:t.status==="failed"?"error":"connecting",message:t.status==="failed"?t.message??a("workspace.needsNewerApp"):a("stream.connecting"),children:r(C,{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:[v||R.error&&!u?r("p",{role:"alert",className:"px-3 py-2 text-xs text-destructive-foreground",children:v??R.error}):null,f("div",{className:"relative min-h-0 flex-1",children:[r(Qe,{transport:t.transport,platform:e.device.platform,deviceId:e.device.id,deviceName:e.device.name,deviceDescription:e.device.version,axOverlay:i,withControls:!0,onHandle:U,onStreaming:X}),r(Rt,{platform:e.device.platform,handle:o,streaming:d,controls:R,screenshotPending:L,onScreenshot:$,toolsOpen:u,onTools:()=>n(!u),onClose:e.onClose,onPowerOff:e.onPowerOff,onFloat:e.onFloat})]})]}),u?r(jt,{device:e.device,controls:R,transport:t.transport,axOverlay:i,onAxOverlayChange:c,onClose:()=>n(!1)}):null,g?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:g,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(C,{size:"sm",variant:"outline",onClick:()=>D(null),children:[r(K,{}),a("workspace.closeBrowser")]})]}):null]})}var wa=e=>e instanceof Error?e.message:String(e);function eo(e){let{environmentId:a,threadId:t}=e,{t:o}=T(),{state:l,loaded:d,error:s,unavailable:u}=pe(a),n=ee(),[i,c]=h(null),[m,x]=h(null),L=Ra(a,t),w=p=>Ee(a,t,p),v=O(),b=ne(v,"floating"),g=()=>{c(null),n("refresh",a).catch(p=>c(wa(p)))};A(()=>{!d||u||n("refresh",a).catch(()=>{})},[a,d,n,u]);let D=de(()=>l.sessions.filter(p=>p.threadId===t),[l.sessions,t]),P=Cr(D,L),F=P?l.devices.find(p=>p.hostId===P.hostId&&p.id===P.deviceId):void 0,N=F&&P?he(F):null;A(()=>{v.floating?.present({environmentId:a,threadId:t},N)}),A(()=>()=>v.floating?.present({environmentId:a,threadId:t},null),[v,a,t]);let R=de(()=>Sr(l),[l]),U=l.hostStatuses[me],X=U?.status==="ready",$=U?.status==="installing"||U?.status==="starting",M=La(),G=l.bootingDevices.filter(p=>p.threadId===t),V=l.hosts.flatMap(p=>p.platforms.filter(S=>!S.available)),B=async p=>{c(null),x(p),sa(a,t,_(p));try{await n("open",a,{threadId:t,hostId:p.hostId,deviceId:p.id,platform:p.platform}),w(_(p))}catch(S){sa(a,t,_(p),!1),c(wa(S))}finally{x(null)}},j=p=>{P&&(c(null),n("close",a,{threadId:t,hostId:P.hostId,deviceId:P.deviceId,shutdown:p}).then(()=>w(null)).catch(S=>c(wa(S))))};return u?r(J,{name:o("panel.title"),stage:"error",message:o("panel.unavailable")}):f("div",{className:"flex size-full min-h-0 flex-col",children:[G.length>0?r("div",{role:"status",className:"border-b px-3 py-2 text-xs text-muted-foreground",children:o("panel.booting",{names:G.map(p=>p.name).join(", ")})}):null,$&&!F?null:r(At,{detail:U,onRetry:()=>n("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(C,{size:"icon-xs",variant:"ghost","aria-label":o("panel.dismissError"),onClick:()=>c(null),children:r(K,{className:"size-3"})}):null]}):null,r("div",{className:"relative flex min-h-0 flex-1",children:F&&P?r(Yt,{environmentId:a,device:F,onBack:()=>w(""),onFloat:b?()=>v.floating?.open({environmentId:a,threadId:t},{...he(F),reason:"user"}):void 0,onPowerOff:()=>j(!0),onClose:()=>j(!1)},`${a}\0${_(F)}`):m||$||!d?r(J,{name:m?.name??o("panel.title"),...m?{description:m.version}:{},stage:"opening",message:m?m.booted?o("panel.opening"):o("panel.starting"):$&&U?M(U):o("panel.finding")}):r(Ir,{environmentId:a,host:l.hosts.find(p=>p.id===me),grouped:R,hostReady:X,hostFailed:U?.status==="failed",unavailableReasons:V.map(p=>p.reason??""),showNoAvdHint:X&&!l.devices.some(p=>p.platform==="android")&&!V.some(p=>p.platform==="android"),pendingKey:m?_(m):null,onOpen:p=>{B(p)},onRefresh:g})})]})}function Ir(e){let{t:a}=T(),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?"my-auto items-center text-center":""}`,children:[r(Bt,{environmentId:e.environmentId},e.environmentId),t?f(Z,{children:[r(Le,{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(Le,{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(C,{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===_(l)?r(H,{size:"xs"}):r("span",{className:"text-xs",children:l.booted?a("panel.open"):a("panel.start")})]})},_(l)))})]},o.platform)):null,e.unavailableReasons.filter(o=>o.length>0).map(o=>r("p",{className:"max-w-sm text-xs",children:o},o)),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(C,{variant:t?"outline":"ghost",size:"sm",onClick:e.onRefresh,children:a("panel.refresh")}),r(Tt,{environmentId:e.environmentId,host:e.host,busy:!1})]})]})})}function Cr(e,a){if(a!==""){if(a!==null){let t=e.find(o=>_({hostId:o.hostId,id:o.deviceId})===a);if(t)return t}return e.toSorted((t,o)=>o.openedAt.localeCompare(t.openedAt))[0]}}function Sr(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 ao({environmentId:e,threadId:a}){let t=O(),{state:o,loaded:l}=pe(e),d=q(null);return A(()=>{if(!l||!ne(t,"floating"))return;let s=`${e}\0${a}`,u=d.current?.key===s?d.current.seen:null,{seen:n,opened:i}=Fa({environmentId:e,threadId:a,previous:u,sessions:o.sessions,devices:o.devices});d.current={key:s,seen:n};for(let c of i)t.floating?.open({environmentId:e,threadId:a},{...he(c),reason:"agent",panelId:Ue})},[t,e,l,o.devices,o.sessions,a]),null}function yr(e){return{panels:{device:function(t){return f(Fe,{value:e,children:[r("style",{children:ta}),r("div",{className:`${qe} flex h-full min-h-0 flex-1 flex-col`,children:r(eo,{environmentId:t.environmentId,threadId:t.threadId})})]})}},views:{deviceFloat:function(t){return f(Fe,{value:e,children:[r("style",{children:ta}),r("div",{className:`${qe} relative size-full`,children:r(vt,{...t})})]})},deviceSessions:function(t){return r(Fe,{value:e,children:r(ao,{environmentId:t.environmentId,threadId:t.threadId})})}}}}export{yr as default};
554
+ `),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 Ke(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:u}=await l.read();if(s||t?.aborted)return;a(u)}}catch(s){if(t?.aborted)return;throw s}finally{t?.removeEventListener("abort",d)}}async function $a(e,a,t){if(!e.ok)throw await e.body?.cancel().catch(()=>{}),new Error(`Event stream failed (${e.status}).`);let o=new We;await Ke(e,l=>{for(let d of o.push(l))a(d)},t)}var fe=e=>e==="ios"?"/vendor/serve-sim":"/vendor/serve-emu";var no=1e3,io=500,Xe=(e,a,t)=>`${fe(e.platform)}${a}${t?`?${new URLSearchParams(t).toString()}`:""}`,ja=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()},W=e=>typeof e=="object"&&e!==null,z=(e,a)=>typeof e=="number"&&Number.isFinite(e)?e:a,fo=e=>{let a=e[0],t=W(a)&&W(a.frame)?a.frame:null,o=Math.max(1,z(t?.width,1)),l=Math.max(1,z(t?.height,1)),d=[],s=(u,n)=>{if(d.length>=io||!W(u)||!W(u.frame))return;let i=u.frame,c=z(i.width,0),m=z(i.height,0);!(Math.abs(c-o)<.5&&Math.abs(m-l)<.5)&&c>0&&m>0&&d.push({id:typeof u.AXUniqueId=="string"?u.AXUniqueId:n,label:typeof u.AXLabel=="string"?u.AXLabel:"",role:typeof u.type=="string"?u.type:"",x:z(i.x,0)/o,y:z(i.y,0)/l,width:c/o,height:m/l}),(Array.isArray(u.children)?u.children:[]).forEach((w,y)=>s(w,`${n}.${y}`))};return e.forEach((u,n)=>s(u,String(n))),d},Za=e=>W(e)&&typeof e.error=="string"?e.error:"Unexpected accessibility payload.";async function Qa(e,a){if(e.platform==="ios"){let n=await ja(e,Xe(e,`/helper/${encodeURIComponent(e.deviceId)}/ax`),a);return Array.isArray(n)?{elements:fo(n),errors:[]}:{elements:[],errors:[Za(n)]}}let t=await ja(e,Xe(e,"/api/accessibility",{device:e.deviceId}),a);if(!W(t)||!Array.isArray(t.nodes))return{elements:[],errors:[Za(t)]};let o=t.nodes.filter(n=>W(n)&&W(n.bounds)),l=o[0]?.bounds,d=Math.max(1,z(l?.right,1)),s=Math.max(1,z(l?.bottom,1));return{elements:o.slice(1).flatMap(n=>{let i=n.bounds,c=z(i.left,0),m=z(i.top,0),x=(z(i.right,c)-c)/d,L=(z(i.bottom,m)-m)/s,w=typeof n.text=="string"?n.text:"",y=typeof n.contentDescription=="string"?n.contentDescription:"",b=w||y;if(x>=.95&&L>=.9)return[];if(!b&&n.clickable!==!0)return[];let g=typeof n.className=="string"?n.className:"";return[{id:String(n.id??""),label:b,role:g.split(".").at(-1)??"",x:c/d,y:m/s,width:x,height:L}]}),errors:[]}}var Ya=(e,a,t)=>{let o=new AbortController,l=null,d=()=>{e.transport.fetch(a,{signal:o.signal}).then(s=>$a(s,u=>{try{t(JSON.parse(u.data))}catch{}},o.signal)).catch(()=>{}).finally(()=>{o.signal.aborted||(l=setTimeout(d,no))})};return d(),()=>{o.abort(),l!==null&&clearTimeout(l)}};function et(e,a){return e.platform!=="ios"?()=>{}:Ya(e,Xe(e,"/appstate",{device:e.deviceId}),t=>{if(W(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 Ja=e=>!W(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 at(e,a){return e.platform!=="ios"?()=>{}:Ya(e,Xe(e,"/api/event-log/events",{device:e.deviceId,limit:"100"}),t=>{if(!W(t))return;if(Array.isArray(t.events)){a(t.events.flatMap(l=>Ja(l)??[]),!0);return}let o=Ja(t.event);o&&a([o],!1)})}function B(){return{t:E().i18n.usePluginTranslation()}}function je(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 tt(e){let a=new Uint8Array(e);if(a.byteLength>16){let t=new DataView(e,0,16);if(t.getUint32(0,!1)===1397050709&&t.getUint8(4)===1){let o=t.getBigUint64(8,!1);return{data:a.subarray(16),isKey:(t.getUint8(5)&1)!==0,timestamp:o<=BigInt(Number.MAX_SAFE_INTEGER)?Number(o):null}}}return{data:a,isKey:null,timestamp:null}}var ot=e=>{try{return JSON.parse(e)?.type==="video-session"}catch{return!1}};function rt(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 co={1:"description",2:"keyframe",3:"delta",4:"seed"},$e=class{buffer=new Uint8Array(64*1024);length=0;push(a){if(this.length+a.length>this.buffer.length){let l=this.buffer.length;for(;l<this.length+a.length;)l*=2;let d=new Uint8Array(l);d.set(this.buffer.subarray(0,this.length)),this.buffer=d}this.buffer.set(a,this.length),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=co[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 po={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:po[e]??null}var st={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 ca(e){if(e.stopped)return;let a=o=>{e.configuring=!1,e.connecting(o),e.scheduleRetry("input",()=>ca(e))},t;try{t=e.transport.connect(`${e.vendor}/ws?device=${e.device}&frame-meta=1`)}catch(o){e.events.onInputConnected(!1,o.message),a(o.message);return}e.socket=t,t.onopen=()=>{e.stopped||e.socket!==t||(e.connecting(),e.events.onInputConnected(!0))},t.onmessage=o=>{if(e.stopped||e.socket!==t)return;if(typeof o.data=="string"){ot(o.data)&&(e.closeDecoder(),e.configuring=!1,e.connecting(),e.requestKeyframe());return}let l=tt(o.data),d=!e.videoDecoder||e.videoDecoder.state!=="configured",u=l.isKey===null||l.isKey&&d?rt(l.data):null,n=l.isKey??u?.isKey??!1;if(u?.sps&&d){if(e.configuring)return;e.configuring=!0;let i=e.decoderEpoch,c=()=>!e.stopped&&e.socket===t;e.configureDecoder({codec:je(u.sps)},c).then(m=>{!c()||i!==e.decoderEpoch||(e.configuring=!1,e.awaitingKeyframe=!0,m&&e.requestKeyframe())});return}if(d){n||e.requestKeyframe();return}e.decode(n,l.data,l.timestamp)},t.onclose=o=>{e.socket===t&&(e.socket=null,e.closeDecoder(),!e.stopped&&(e.events.onInputConnected(!1,o.reason||`closed ${o.code}`),a(o.reason||void 0)))},t.onerror=()=>t.close()}function dt(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=st[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 ut(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 nt=new TextEncoder,it=new TextDecoder;function ct(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 ft(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 Ze=class{delimiter;buffer=new Uint8Array(64*1024);length=0;pos=0;state="boundary";contentLength=null;scanFrom=0;constructor(a){this.delimiter=a?nt.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>16777216)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){if(this.length+a.length>this.buffer.length){let t=this.buffer.length;for(;t<this.length+a.length;)t*=2;let o=new Uint8Array(t);o.set(this.buffer.subarray(0,this.length)),this.buffer=o}this.buffer.set(a,this.length),this.length+=a.length}lineEnd(a){return this.buffer.subarray(0,this.length).indexOf(10,a)}readBoundary(){let a=this.buffer;if(!this.delimiter)for(;;){let s=this.lineEnd(this.pos);if(s===-1)return!1;let u=it.decode(a.subarray(this.pos,s)).trim();if(this.pos=s+1,u.startsWith("--"))return this.delimiter=nt.encode(u),this.state="headers",!0}let t=this.delimiter,o=ft(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]===45&&a[l+1]===45)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=it.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=ft(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]!==10){t=o+1;continue}let l=o-1;l>this.pos&&this.buffer[l-1]===13&&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 Ze(ct(e.headers.get("content-type")));await Ke(e,l=>{for(let d of o.push(l))a(d)},t)}function Ie(e){e.stopped||e.mjpeg||(e.mjpeg=!0,e.controller?.abort(),e.controller=null,e.closeDecoder(),e.connecting(),e.events.onMjpegFallback?.(),pt(e))}var pa=e=>`${e.vendor}/helper/${e.device}/stream.mjpeg`;async function pt(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,u=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}},n;try{let i=await e.transport.fetch(pa(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||u())},o.signal),!l())return;n="Device stream ended."}catch(i){if(!l())return;n=i.message}l()&&(e.controller=null,o.abort(),e.connecting(n),e.scheduleRetry("video",()=>{pt(e)}))}var go=1e3,ma=15e3,Lo=16667,ho=8,xo=e=>typeof e=="object"&&e!==null&&"present"in e;function gt(e){let{transport:a,platform:t,events:o}=e,l=xo(e.output)?e.output:ut(e.output),d=u=>e.globals?.[u]??globalThis[u],s={platform:t,transport:a,events:o,preferMjpeg:e.preferMjpeg===!0,vendor:fe(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 u=d("VideoDecoder"),n=d("EncodedVideoChunk");return u&&n?{VideoDecoder:u,EncodedVideoChunk:n}:null},createBitmap(u){let n=d("createImageBitmap");return n?n(u):Promise.reject(new Error("createImageBitmap is unavailable."))},setStatus(u,n){s.stopped||o.onStatus(u,n)},fail(u){s.stopped||(s.stop(),o.onInputConnected(!1,u),o.onStatus("error",u))},connecting(u){s.firstFrame=!1,s.frameTimer===null&&(s.frameTimer=setTimeout(()=>s.fail("No video received from the device. Reconnect to try again."),ma)),s.setStatus("connecting",u)},paint(u,n,i){if(!s.stopped){if(t==="android"&&(s.screen?.width!==n||s.screen.height!==i)&&(s.screen={width:n,height:i,orientation:n>i?"landscape_left":"portrait"},o.onScreen(s.screen)),!l.present(u,n,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"?Ie(s):(s.closeDecoder(),s.connecting("Video decoder restarted."),s.requestKeyframe())},async configureDecoder(u,n=()=>!s.stopped){let i=s.webCodecs();if(!i)return!1;let c=s.decoderEpoch,m={...u,optimizeForLatency:!0},x=await i.VideoDecoder.isConfigSupported(m).catch(()=>({supported:!1}));if(!n()||c!==s.decoderEpoch)return!1;if(!x.supported)return t==="android"&&s.fail(`This browser cannot decode ${u.codec}.`),!1;try{return(!s.videoDecoder||s.videoDecoder.state==="closed")&&(s.videoDecoder=Io(s,i)),s.videoDecoder.configure(m),!0}catch(L){return t==="android"&&s.fail(`Video decoder: ${L.message}`),!1}},decode(u,n,i){let c=s.videoDecoder,m=s.webCodecs();if(!(!c||c.state!=="configured"||!m)){if(s.awaitingKeyframe){if(!u)return;s.awaitingKeyframe=!1}if(c.decodeQueueSize>ho){s.recoverDecoder();return}try{c.decode(new m.EncodedVideoChunk({type:u?"key":"delta",timestamp:i??s.timestamp,data:n})),s.timestamp+=Lo}catch{s.recoverDecoder()}}},requestKeyframe(){t==="android"&&s.socket?.readyState===1&&s.socket.send(JSON.stringify({type:"reset-video",ack:!1}))},scheduleRetry(u,n){s.stopped||s.retryTimers.has(u)||s.retryTimers.set(u,setTimeout(()=>{s.retryTimers.delete(u),n()},go))},send(u){!s.stopped&&s.socket?.readyState===1&&s.socket.send(u)},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 n of s.retryTimers.values())clearTimeout(n);s.retryTimers.clear(),s.primeController?.abort(),s.primeController=null,s.controller?.abort(),s.controller=null;let u=s.socket;s.socket=null,u?.close(),s.closeDecoder()}};return s}function Io(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 Co=3,So=4,vo=6,Lt=7,yo=13,wo=130,bo=2e3,ko=new TextEncoder,Do=new TextDecoder,Je=["portrait","landscape_left","portrait_upside_down","landscape_right"],Po=new Set(Je);function ce(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 Ao(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"||!Po.has(o))return null;let d={width:a,height:t,orientation:o};return typeof l=="number"?{...d,screenId:l}:d}function ht(e,a){It(e),a?xt(e):Ie(e)}async function xt(e){let a=e.generation,t=++e.videoGeneration,o=new $e,l=new AbortController;e.controller=l;let d=()=>!e.stopped&&e.generation===a&&e.videoGeneration===t&&e.controller===l,s;try{let u=await e.transport.fetch(`${e.vendor}/helper/${e.device}/stream.avcc`,{signal:l.signal});if(!d()){await u.body?.cancel();return}if(!u.ok||!u.body)throw new Error(`stream ${u.status}`);let n=u.body.getReader();for(;;){let i=setTimeout(()=>{d()&&e.fail("Device stream stopped receiving video. Reconnect to try again.")},ma);e.videoReadTimer=i;let c;try{c=await n.read()}finally{clearTimeout(i),e.videoReadTimer===i&&(e.videoReadTimer=null)}let{done:m,value:x}=c;if(!d())return;if(m)break;for(let L of o.push(x))switch(L.type){case"seed":e.createBitmap(new Blob([L.payload],{type:"image/jpeg"})).then(w=>{try{d()&&e.paint(w,w.width,w.height)}finally{w.close()}}).catch(()=>{});break;case"description":{e.awaitingKeyframe=!0;let w=await e.configureDecoder({codec:je(L.payload),description:L.payload},d);if(!d())return;if(!w){if(await n.cancel().catch(()=>{}),!d())return;Ie(e);return}break}case"keyframe":case"delta":e.decode(L.type==="keyframe",L.payload);break}}}catch(u){if(!d())return;s=u.message}d()&&(e.controller=null,l.abort(),e.closeDecoder(),e.connecting(s),e.scheduleRetry("video",()=>{xt(e)}))}async function To(e,a){let t=new AbortController;e.primeController=t;let o=setTimeout(()=>t.abort(),bo);try{let l=await e.transport.fetch(pa(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 It(e){if(e.stopped)return;let a=e.generation;if(await To(e,a),e.stopped||e.generation!==a)return;let t=()=>e.scheduleRetry("input",()=>{It(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(ce(yo,{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]!==wo))try{let s=Ao(JSON.parse(Do.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 Bo(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 Ct(e){return{sendTouch(a,t,o){e.send(ce(Co,{type:a,...Bo(e,t,o)}))},sendKey(a,t){let o=lt(a.code);o!==null&&e.send(ce(vo,{type:t,usage:o}))},pressButton(a){let t=a==="home"?"home":a==="appSwitcher"?"app_switcher":a==="power"?"lock":null;t&&e.send(ce(So,{button:t}))},rotate(){let a=e.screen?.orientation??"portrait",t=Je[(Je.indexOf(a)+1)%Je.length];e.send(ce(Lt,{orientation:t}))},setOrientation(a){e.send(ce(Lt,{orientation:a}))}}}function St(e){let a=gt(e),t=e.platform==="ios"?Ct(a):dt(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"?ht(a,l):l?ca(a):a.fail("This browser cannot decode the Android stream (WebCodecs unavailable).")},stop:a.stop,isMjpeg:()=>a.mjpeg,...t}}var Mo=56,Ro=2e3;function Fo(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 Uo(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 Oo(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 Eo=()=>typeof navigator<"u"&&/iPhone|iPad|iPod/.test(navigator.userAgent);function Qe(e){let{t:a}=B(),t=q(null),o=q(null),[l,d]=h("connecting"),[s,u]=h(),[n,i]=h(null),[c,m]=h({connected:!1}),{onHandle:x,onStreaming:L,onScreen:w,transport:y,platform:b,deviceId:g}=e;T(()=>w?.(n),[w,n]),T(()=>{let p=t.current;if(!p)return;let S=St({transport:y,platform:b,deviceId:g,output:p,preferMjpeg:Eo(),events:{onStatus:(D,C)=>{d(D),u(C),L(D==="streaming")},onScreen:i,onInputConnected:(D,C)=>{m({connected:D,...C?{detail:C}:{}}),x({pressButton:S.pressButton,rotate:S.rotate,inputConnected:D})}}});return o.current=S,m({connected:!1}),S.start(),x({pressButton:S.pressButton,rotate:S.rotate,inputConnected:!1}),()=>{S.stop(),o.current=null,x(null),L(!1),i(null)}},[g,x,L,b,y]);let P=q(null),[A,U]=h({width:0,height:0});T(()=>{let p=P.current;if(!p)return;let S=()=>{let C=p.getBoundingClientRect();U(re=>re.width===C.width&&re.height===C.height?re:{width:C.width,height:C.height})};S();let D=new ResizeObserver(S);return D.observe(p),()=>D.disconnect()},[]);let N=e.withControls?Mo:0,F=de(()=>Fo(Uo(b,n),A.width,A.height,N),[A,N,b,n]),O=Oo(b,n),$=O===90||O===-90?{width:F.height,height:F.width,left:(F.width-F.height)/2,top:(F.height-F.width)/2,transform:`rotate(${O}deg)`}:{width:F.width,height:F.height,...O?{transform:`rotate(${O}deg)`}:{}},[R,G]=h([]);T(()=>{if(!e.axOverlay)return;let p=null,S=null,D=!1,C=async()=>{p=new AbortController;try{let re=await Qa({transport:y,platform:b,deviceId:g},p.signal);D||G(re.elements)}catch{}D||(S=setTimeout(()=>{C()},Ro))};return C(),()=>{D=!0,p?.abort(),S&&clearTimeout(S),G([])}},[g,b,e.axOverlay,y]);let V=q(!1),M=p=>{let S=p.currentTarget.getBoundingClientRect(),D=(p.clientX-S.left)/S.width,C=(p.clientY-S.top)/S.height;return{x:Math.min(1,Math.max(0,D)),y:Math.min(1,Math.max(0,C))}},j=p=>{if(!V.current)return;V.current=!1;let{x:S,y:D}=M(p);o.current?.sendTouch("end",S,D)};return f("div",{ref:P,className:"relative flex size-full min-h-0 min-w-0 items-center justify-center overflow-hidden",style:N?{paddingRight:N}:void 0,tabIndex:0,role:"application","aria-label":a(b==="ios"?"stream.iosScreen":"stream.androidScreen"),onKeyDown:p=>{p.target===p.currentTarget&&(p.metaKey&&!["r","R"].includes(p.key)||(p.preventDefault(),o.current?.sendKey(p.nativeEvent,"down")))},onKeyUp:p=>{p.target===p.currentTarget&&o.current?.sendKey(p.nativeEvent,"up")},children:[f("div",{className:"relative touch-none select-none",style:{width:F.width,height:F.height},onPointerDown:p=>{p.currentTarget.setPointerCapture(p.pointerId),p.currentTarget.parentElement?.focus(),V.current=!0;let{x:S,y:D}=M(p);o.current?.sendTouch("begin",S,D)},onPointerMove:p=>{if(!V.current)return;let{x:S,y:D}=M(p);o.current?.sendTouch("move",S,D)},onPointerUp:j,onPointerCancel:j,children:[r("canvas",{ref:t,className:"absolute top-0 left-0",style:$}),R.length>0?r("div",{className:"pointer-events-none absolute inset-0","aria-hidden":!0,children:R.map(p=>r("div",{className:"absolute border border-info/80 bg-info/10",style:{left:`${p.x*100}%`,top:`${p.y*100}%`,width:`${p.width*100}%`,height:`${p.height*100}%`},children:p.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:p.label}):null},p.id))}):null]}),l==="streaming"&&!c.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:c.detail?a("stream.inputLostDetail",{detail:c.detail}):a("stream.inputLost")})}):null,l!=="streaming"?r("div",{className:"absolute inset-0 bg-background",children:r(J,{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(I,{size:"sm",variant:"outline",onClick:()=>{o.current?.stop(),o.current?.start()},children:a("stream.reconnect")}):null})}):null]})}var qo={hosts:[],hostStatuses:{},devices:[],sessions:[],bootingDevices:[],revision:0};function pe(e){let t=E().commands.useSubscription("state",{},{environmentId:e});return{state:t.data??qo,loaded:t.data!==null,error:t.error,unavailable:t.isUnavailable}}function Y(){let e=E();return se((a,t,o={})=>e.commands.invoke(a,o,{environmentId:t}),[e])}var me="local",Ye=class extends Error{code;constructor(a,t,o){super(t,o),this.name="DeviceError",this.code=a}};var vt="hub";function ea(e){let a=E(),[t,o]=h({status:"connecting"});return T(()=>{let l=a.network;if(!ne(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:(u,n)=>s.fetch(vt,u,{...n,instance:me}),connect:u=>s.connect(vt,u,{instance:me})}})},s=>{d||o({status:"failed",message:s instanceof Error?s.message:String(s)})}),()=>{d=!0}},[a,e]),t}var yt=()=>{};function wt(e){let{environmentId:a,threadId:t,hostId:o,deviceId:l,platform:d}=e,s=e[Ma],u=E(),{t:n}=B(),{state:i,loaded:c}=pe(a),m=ea(a),x=de(()=>({environmentId:a,threadId:t}),[a,t]),L=i.devices.find(P=>P.hostId===o&&P.id===l),w=i.sessions.some(P=>P.threadId===t&&P.hostId===o&&P.deviceId===l);T(()=>{c&&!w&&u.floating?.close(x,s.key)},[u,s.key,c,w,x]),T(()=>(s.setOpenInPanel(()=>{Ee(a,t,s.key),u.floating?.openPanel(x,Ue),u.floating?.close(x,s.key)}),()=>s.setOpenInPanel(null)),[u,a,s,x,t]);let y=se(P=>s.reportSourceSize(P===null?null:Ra(P)),[s]),b=L?.name??l,g=L?.version??d;return m.status!=="ready"?r(J,{name:b,description:g,stage:m.status==="failed"?"error":"connecting",message:m.status==="failed"?m.message??n("workspace.needsNewerApp"):n("stream.connecting")}):r(Qe,{transport:m.transport,platform:d,deviceId:l,deviceName:b,deviceDescription:g,axOverlay:!1,withControls:!1,onHandle:yt,onStreaming:yt,onScreen:y})}var aa=(...e)=>e.filter((a,t,o)=>!!a&&a.trim()!==""&&o.indexOf(a)===t).join(" ").trim();var bt=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var kt=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,t,o)=>o?o.toUpperCase():t.toLowerCase());var ga=e=>{let a=kt(e);return a.charAt(0).toUpperCase()+a.slice(1)};var Dt={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 Pt=e=>{for(let a in e)if(a.startsWith("aria-")||a==="role"||a==="title")return!0;return!1};var At=Re(({color:e="currentColor",size:a=24,strokeWidth:t=2,absoluteStrokeWidth:o,className:l="",children:d,iconNode:s,...u},n)=>le("svg",{ref:n,...Dt,width:a,height:a,stroke:e,strokeWidth:o?Number(t)*24/Number(a):t,className:aa("lucide",l),...!d&&!Pt(u)&&{"aria-hidden":"true"},...u},[...s.map(([i,c])=>le(i,c)),...Array.isArray(d)?d:[d]]));var v=(e,a)=>{let t=Re(({className:o,...l},d)=>le(At,{ref:d,iconNode:a,className:aa(`lucide-${bt(ga(e))}`,`lucide-${e}`,o),...l}));return t.displayName=ga(e),t};var Ho=[["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"}]],Ce=v("camera",Ho);var No=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Se=v("chevron-down",No);var Go=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ve=v("chevron-left",Go);var Vo=[["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"}]],ee=v("ellipsis",Vo);var zo=[["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"}]],ae=v("house",zo);var _o=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],ye=v("info",_o);var Wo=[["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"}]],we=v("moon",Wo);var Ko=[["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"}]],be=v("picture-in-picture-2",Ko);var Xo=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],ke=v("power",Xo);var $o=[["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"}]],ge=v("rotate-ccw",$o);var jo=[["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"}]],De=v("rotate-cw",jo);var Zo=[["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"}]],Pe=v("sliders-horizontal",Zo);var Jo=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Le=v("smartphone",Jo);var Qo=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Ae=v("square",Qo);var Yo=[["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"}]],Te=v("sun",Yo);var er=[["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"}]],Be=v("type",er);var ar=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],K=v("x",ar);function tr(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 La(){let{t:e}=B();return a=>tr(a,e)}function Tt(e){let{t:a}=B(),t=La(),[o,l]=h(!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(I,{size:"xs",variant:"outline",disabled:o,onClick:()=>{l(!0),e.onRetry().finally(()=>l(!1))},children:[o?r(H,{size:"xs"}):r(De,{}),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(H,{size:"xs"}),r("span",{className:"min-w-0 flex-1",children:t(d)})]})}var ha=["hub","agent"],xa=e=>e!==void 0&&!e.installedVersions.includes(e.requiredVersion);function Bt(e){let{t:a}=B(),t=Y(),[o,l]=h(null),[d,s]=h(null),u=e.host?.tools,n=e.busy||o!==null,i=m=>{l(m),s(null),(m==="check"?t("inspect",e.environmentId):t("updateTool",e.environmentId,{tool:m})).catch(()=>s(a(m==="check"?"versions.checkFailed":"versions.updateFailed"))).finally(()=>l(null))},c=m=>m??a("versions.none");return f(Wa,{children:[f(Ka,{render:r(I,{size:"xs",variant:"ghost","aria-label":a("versions.title")}),children:[r(ye,{}),a("versions.title"),ha.some(m=>xa(u?.[m]))?r("span",{className:"size-1.5 rounded-full bg-warning","aria-hidden":!0}):null]}),r(Xa,{side:"bottom",align:"start",className:"w-80",children:f("div",{className:"space-y-3 text-xs",children:[ha.map(m=>{let x=u?.[m];return f("section",{className:"space-y-1",children:[r("h4",{className:"font-medium text-foreground",children:a(m==="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(x?.requiredVersion)}),r("dt",{children:a("versions.installed")}),r("dd",{className:"font-mono",children:x&&x.installedVersions.length>0?x.installedVersions.join(", "):a("versions.none")}),r("dt",{children:a("versions.running")}),r("dd",{className:"font-mono",children:c(x?.runningVersion)})]}),xa(x)?f(I,{size:"xs",variant:"outline",disabled:n,onClick:()=>i(m),children:[o===m?r(H,{size:"xs"}):null,a("versions.updateTo",{version:x?.requiredVersion??""})]}):null]},m)}),u===void 0?r("p",{className:"text-muted-foreground",children:a("versions.unknown")}):null,ha.some(m=>xa(u?.[m]))?r("p",{className:"text-muted-foreground",children:a("versions.pendingPolicy")}):null,d?r("p",{role:"alert",className:"text-destructive-foreground",children:d}):null,f("div",{className:"flex items-center justify-between gap-2 border-t pt-2",children:[r("p",{className:"text-muted-foreground",children:a("versions.checkHint")}),f(I,{size:"xs",variant:"ghost",disabled:n,onClick:()=>i("check"),children:[o==="check"?r(H,{size:"xs"}):null,a("versions.check")]})]})]})})]})}function Mt(e){return e.supported?e.freeBytes!==null&&e.freeBytes<e.requiredFreeBytes?"environment.notEnoughSpace":null:e.reasonCode?`environment.reasons.${e.reasonCode}`:"environment.unsupported"}function Rt(e,a){return e.cacheBytes>0||a==="android"&&e.deviceDataBytes>0}function Ft(e){let{t:a}=B(),t=Y(),l=E().commands.useSubscription("environmentProgress",{},{environmentId:e.environmentId}).data,[d,s]=h(!1),[u,n]=h("android"),[i,c]=h(""),[m,x]=h(""),[L,w]=h(null),[y,b]=h(!1),[g,P]=h(!1),[A,U]=h(!1),[N,F]=h(null),[O,X]=h(!1),[$,R]=h(!1),[G,V]=h(null),M=N!==null||l?.status==="working";T(()=>{l?.status==="done"&&l.plan?.platform===u&&l.id===G&&(w(l.plan),R(!0)),l?.status==="failed"&&l.id===G&&X(!0)},[u,l,G]);let j=()=>{w(null),b(!1),P(!1),U(!1),R(!1),V(null)},p=async(C,re={})=>{F(C),X(!1),R(!1);try{let ba=await t(C,e.environmentId,{platform:u,directory:i,version:m,...re});C==="cleanupEnvironment"?w(await t("environmentPlan",e.environmentId,{platform:u,directory:i,version:m})):C==="prepareEnvironment"?V(ba.id??null):w(ba),R(C==="cleanupEnvironment")}catch{X(!0)}finally{F(null)}},S=L?Mt(L):null,D=C=>C===null?a("environment.unknownSize"):`${(C/1024**3).toFixed(2)} GiB`;return f(Ve,{open:d,onOpenChange:s,className:"w-full text-left",children:[r(ze,{render:r(I,{variant:"outline",size:"sm",className:"w-full"}),children:a("environment.title")}),r(_e,{children:f("div",{className:"space-y-3 rounded-md border p-3 text-xs",children:[r("p",{children:a("environment.description")}),r("div",{className:"flex gap-2",children:["android","ios"].map(C=>r(I,{size:"sm",variant:u===C?"default":"outline",disabled:M,onClick:()=>{n(C),j()},children:a(C==="ios"?"panel.platformIos":"panel.platformAndroid")},C))}),f("label",{className:"block space-y-1",children:[r("span",{children:a("environment.directory")}),r(Q,{value:i,disabled:M,onChange:C=>{c(C.target.value),j()},placeholder:a("environment.defaultDirectory")})]}),r("p",{children:a("environment.directoryHint")}),u==="ios"?f("label",{className:"block space-y-1",children:[r("span",{children:a("environment.iosVersion")}),r(Q,{value:m,disabled:M,onChange:C=>{x(C.target.value),j()},placeholder:a("environment.iosVersionPlaceholder")})]}):null,r(I,{size:"sm",variant:"outline",disabled:M,onClick:()=>{p("environmentPlan")},children:a("environment.inspect")}),L?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.${L.source}`)}),r("dt",{children:a("environment.version")}),r("dd",{children:L.version||a("environment.versionRequired")}),r("dt",{children:a("environment.location")}),r("dd",{children:L.root}),L.existingSdkRoot?f(Z,{children:[r("dt",{children:a("environment.existingSdk")}),r("dd",{children:L.existingSdkRoot})]}):null,r("dt",{children:a("environment.download")}),r("dd",{children:D(L.downloadBytes)}),r("dt",{children:a("environment.free")}),r("dd",{children:D(L.freeBytes)}),r("dt",{children:a("environment.required")}),r("dd",{children:D(L.requiredFreeBytes)})]}),L.source==="external"?r("p",{children:a("environment.external")}):null,L.reasonCode&&L.supported?r("p",{role:"status",children:a(`environment.reasons.${L.reasonCode}`)}):null,r("a",{className:"underline",href:L.guidanceUrl,target:"_blank",rel:"noreferrer",children:a("environment.guide")}),u==="ios"?r("p",{children:a("environment.appleOwnership")}):r("p",{children:a("environment.privateOwnership")}),r("ul",{children:L.licenses.map(C=>r("li",{children:r("a",{className:"underline",href:C.url,target:"_blank",rel:"noreferrer",children:a(u==="ios"?"environment.appleLicense":"environment.androidLicense")})},C.url))}),f("label",{className:"flex items-center gap-2",children:[r(ie,{checked:y,disabled:M,onCheckedChange:b}),r("span",{children:a("environment.acceptLicense")})]}),u==="ios"?f("label",{className:"flex items-center gap-2",children:[r(ie,{checked:g,disabled:M,onCheckedChange:P}),r("span",{children:a("environment.confirmApple")})]}):null,S?r("p",{role:"alert",className:"font-medium text-warning-foreground",children:a(S)}):null,r(I,{size:"sm",disabled:M||!L.supported||!y||u==="ios"&&(!g||!m)||L.freeBytes===null||L.freeBytes<L.requiredFreeBytes,onClick:()=>{p("prepareEnvironment",{acceptLicenses:y,confirmAppleInstall:g})},children:a("environment.prepare")}),Rt(L,u)?f("div",{className:"space-y-2 border-t pt-2",children:[r("p",{children:a("environment.retention")}),r(I,{size:"sm",variant:"outline",disabled:M||L.cacheBytes===0,onClick:()=>{p("cleanupEnvironment",{category:"cache",confirm:!0})},children:a("environment.cleanCache",{size:D(L.cacheBytes)})}),u==="android"?f(Z,{children:[r("p",{children:a("environment.deviceData",{size:D(L.deviceDataBytes)})}),f("label",{className:"flex items-center gap-2",children:[r(ie,{checked:A,disabled:M,onCheckedChange:U}),r("span",{children:a("environment.confirmData")})]}),r(I,{size:"sm",variant:"destructive",disabled:M||!A||L.deviceDataBytes===0,onClick:()=>{p("cleanupEnvironment",{category:"devices",confirm:A})},children:a("environment.cleanDevices")})]}):null]}):null]}):null,M?f("p",{role:"status",className:"flex items-center gap-2",children:[r(H,{size:"xs"}),a(l?.status==="working"?"environment.preparing":"environment.working")]}):null,O?r("p",{role:"alert",className:"text-destructive-foreground",children:a("environment.failed")}):null,$?r("p",{role:"status",children:a("environment.done")}):null]})})]})}var Ut=["small","default","large","extra-large"],or=e=>Ut.includes(e);function Ot(e){let{t:a}=B(),{handle:t,controls:o}=e,l=o.detail?.settings,d=!t?.inputConnected,s=l?.appearance==="dark"?"light":"dark",u=n=>a(n==="small"?"rail.textSmall":n==="default"?"rail.textDefault":n==="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(te,{label:a("rail.home"),disabled:d,onClick:()=>t?.pressButton("home"),children:r(ae,{})}),e.platform==="android"?f(Z,{children:[r(te,{label:a("rail.back"),disabled:d,onClick:()=>t?.pressButton("back"),children:r(ve,{})}),r(te,{label:a("rail.recents"),disabled:d,onClick:()=>t?.pressButton("recents"),children:r(Ae,{})}),f(He,{children:[r(Ge,{render:r(I,{size:"icon-sm",variant:"ghost","aria-label":a("rail.rotate"),disabled:o.disabled}),children:r(ge,{})}),f(Ne,{side:"left",children:[r(xe,{onClick:()=>{o.act({type:"setOrientation",value:"portrait"})},children:a("rail.portrait")}),r(xe,{onClick:()=>{o.act({type:"setOrientation",value:"landscape_left"})},children:a("rail.landscape")})]})]})]}):r(te,{label:a("rail.rotate"),disabled:d,onClick:()=>t?.rotate(),children:r(ge,{})}),r(rr,{}),r(te,{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(Te,{}):r(we,{})}),f(He,{children:[r(Ge,{render:r(I,{size:"icon-sm",variant:"ghost","aria-label":a("rail.textSize"),title:a("rail.textSize"),disabled:o.disabled||!l?.textSize}),children:r(Be,{})}),r(Ne,{side:"left",children:r(Na,{value:l?.textSize??"",onValueChange:n=>{or(n)&&o.act({type:"setTextSize",value:n})},children:Ut.map(n=>r(Ga,{value:n,children:u(n)},n))})})]}),r(te,{label:a("rail.tools"),pressed:e.toolsOpen,onClick:e.onTools,children:r(Pe,{})}),r(te,{label:e.screenshotPending?a("rail.capturing"):a("rail.screenshot"),disabled:!e.streaming||e.screenshotPending,onClick:e.onScreenshot,children:r(Ce,{})}),e.onFloat?r(te,{label:a("rail.float"),onClick:e.onFloat,children:r(be,{})}):null,f(He,{children:[r(Ge,{render:r(I,{size:"icon-sm",variant:"ghost","aria-label":a("rail.more"),title:a("rail.more")}),children:r(ee,{})}),f(Ne,{side:"left",align:"end",children:[f(xe,{onClick:e.onClose,children:[r(K,{}),a("rail.closePanel")]}),r(Ha,{}),f(xe,{variant:"destructive",onClick:e.onPowerOff,children:[r(ke,{}),a("rail.powerOff")]})]})]})]})})}function rr(){return r("div",{"aria-hidden":!0,className:"my-1 h-px w-5 shrink-0 bg-border/70"})}function te(e){return f(Oa,{children:[r(qa,{render:r(I,{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(Ea,{side:"left",children:e.label})]})}var Ia=(e,a)=>new Ye("invalid-input",`Invalid ${e}: ${a}.`);var Et=4096,qt=["light","dark"],Ht=["small","default","large","extra-large"];var Nt=["clear","tinted"],Gt=["none","grayscale","red-green","green-red","blue-yellow"],Vt=["portrait","landscape_left","portrait_upside_down","landscape_right"],zt=["camera","microphone","photos","contacts","calendar","reminders","location","notifications","motion","media-library","faceid"];var lr=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);var _t=e=>{let a=typeof e=="string"?{aps:{alert:e}}:e;if(!lr(a))throw Ia("push payload","expected a string or an object");let t;try{t=JSON.stringify(a)}catch{t=void 0}if(t===void 0)throw Ia("push payload","could not be encoded as JSON");if(new TextEncoder().encode(t).length>Et)throw Ia("push payload",`larger than ${String(Et)} bytes`);return t};var sr=new Set(["setAppearance","setTextSize","setToggle","setLiquidGlass","setColorFilter","setLocation","clearLocation","setPermission","openUrl","launchApp","terminateApp","sendPush"]),dr=new Set(["setAppearance","setTextSize","setToggle","setOrientation","setLocation","clearLocation","setPermission","openUrl","launchApp","terminateApp"]),ur=new Set(["reduceMotion","increaseContrast","reduceTransparency","showBorders","voiceOver"]),nr=new Set(["reduceMotion","networkEnabled"]),Wt=(e,a)=>(e==="ios"?sr:dr).has(a.type)?a.type==="setToggle"?(e==="ios"?ur:nr).has(a.setting):!0:!1;function ue(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 oe(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 Ca(e){return r(oe,{label:e.label,children:r(ie,{"aria-label":e.label,checked:e.checked??!1,disabled:e.disabled||e.checked===void 0,onCheckedChange:a=>{e.onChange(a)}})})}function Sa(e){return r(za,{"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(_a,{size:"xs",value:a.value,children:a.label},a.value))})}function Me(e){let a=e.options.find(t=>t.value===e.value);return f(da,{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(ua,{size:"xs",className:e.width??"w-40","aria-label":e.ariaLabel,children:r(na,{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(fa,{value:t.value,children:t.label},t.value))})]})}function va(e){let[a,t]=h(""),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(Q,{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(I,{type:"submit",size:"xs",variant:"outline",disabled:e.disabled||!o,children:e.action})]})}var Kt=[{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 $t(e){let{t:a}=B(),[t,o]=h(""),[l,d]=h(""),s={latitude:Number(t),longitude:Number(l)},u=t.trim()!==""&&l.trim()!==""&&Math.abs(s.latitude)<=90&&Math.abs(s.longitude)<=180,n=(i,c)=>e.act({type:"setLocation",latitude:i,longitude:c});return f(ue,{title:a("tools.location.title"),children:[f("div",{className:"flex gap-1.5",children:[r(Q,{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(Q,{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(da,{value:null,disabled:e.disabled,onValueChange:i=>{let c=Kt.find(m=>m.key===i);c&&(o(String(c.latitude)),d(String(c.longitude)),n(c.latitude,c.longitude))},children:[r(ua,{size:"xs",className:"w-32","aria-label":a("tools.location.preset"),children:r(na,{children:r("span",{className:"text-muted-foreground",children:a("tools.location.presetPlaceholder")})})}),r(ia,{align:"start",alignItemWithTrigger:!1,children:Kt.map(i=>r(fa,{value:i.key,children:a(i.key)},i.key))})]}),r(I,{size:"xs",variant:"outline",disabled:e.disabled||!u,onClick:()=>{n(s.latitude,s.longitude)},children:a("tools.location.set")}),r(I,{size:"xs",variant:"ghost",disabled:e.disabled,onClick:()=>{o(""),d(""),e.act({type:"clearLocation"})},children:a("tools.location.clear")})]})]})}var ir={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"},fr=new Set(["camera","microphone","photos","contacts","calendar","location","notifications","motion"]);function jt(e){let{t:a}=B(),t=e.platform==="ios",[o,l]=h(""),[d,s]=h("camera"),u=o.trim()||e.defaultAppId,n=zt.filter(c=>t||fr.has(c)).map(c=>({value:c,label:a(!t&&c==="motion"?"tools.permissions.activity":ir[c])})),i=c=>{e.act({type:"setPermission",appId:u,permission:d,decision:c})};return f(ue,{title:a("tools.permissions.title"),children:[r(Q,{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(Me,{ariaLabel:a("tools.permissions.permission"),value:d,options:n,placeholder:a("tools.unknown"),disabled:e.disabled,onChange:c=>(s(c),Promise.resolve())}),r(I,{size:"xs",variant:"outline",disabled:e.disabled||!u,onClick:()=>i("grant"),children:a("tools.permissions.grant")}),r(I,{size:"xs",variant:"outline",disabled:e.disabled||!u,onClick:()=>i("revoke"),children:a("tools.permissions.revoke")}),t?r(I,{size:"xs",variant:"ghost",disabled:e.disabled||!u,onClick:()=>i("reset"),children:a("tools.permissions.reset")}):null]})]})}var cr=e=>{let a=e;try{let t=JSON.parse(e);typeof t=="object"&&t!==null&&!Array.isArray(t)&&(a=t)}catch{}try{return _t(a),a}catch{return null}};function Zt(e){let{t:a}=B(),[t,o]=h(""),l=t.trim(),d=l?cr(l):null,s=e.appId;return f(ue,{title:a("tools.push.title"),children:[r(Va,{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:u=>o(u.target.value)}),f("div",{className:"flex items-center gap-2",children:[r(I,{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 Xt=100;function Jt(e){let{t:a}=B(),[t,o]=h(!1),[l,d]=h([]),{transport:s,platform:u,deviceId:n}=e;return T(()=>{if(!t)return;let i=at({transport:s,platform:u,deviceId:n},(c,m)=>{d(x=>{let L=m?[...c]:[...x,...c];return L.length>Xt?L.slice(-Xt):L})});return()=>{i(),d([])}},[t,s,u,n]),f(Ve,{open:t,onOpenChange:o,children:[f(ze,{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(Se,{className:`ml-auto size-3.5 transition-transform ${t?"rotate-180":""}`})]}),r(_e,{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 pr=640,mr={light:"tools.settings.light",dark:"tools.settings.dark"},gr={small:"tools.settings.textSmall",default:"tools.settings.textDefault",large:"tools.settings.textLarge","extra-large":"tools.settings.textExtraLarge"},Lr={clear:"tools.settings.glassClear",tinted:"tools.settings.glassTinted"},hr={none:"tools.settings.filterNone",grayscale:"tools.settings.filterGrayscale","red-green":"tools.settings.filterRedGreen","green-red":"tools.settings.filterGreenRed","blue-yellow":"tools.settings.filterBlueYellow"},xr={portrait:"tools.settings.orientationPortrait",landscape_left:"tools.settings.orientationLandscapeLeft",portrait_upside_down:"tools.settings.orientationUpsideDown",landscape_right:"tools.settings.orientationLandscapeRight"},Ir=[{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 Qt(e){let{t:a}=B(),{device:t,controls:o}=e,{detail:l,pending:d,error:s,foregroundApp:u,disabled:n,act:i}=o,c=l?.settings,m=t.platform==="ios",x=q(null),[L,w]=h(!0);Pa(()=>{let g=x.current?.parentElement;if(!g)return;let P=()=>w(g.clientWidth<pr);P();let A=new ResizeObserver(P);return A.observe(g),()=>A.disconnect()},[]);let y=Ht.map(g=>({value:g,label:a(gr[g])})),b=Ir.filter(g=>Wt(t.platform,{type:"setToggle",setting:g.setting,value:!0}));return f("aside",{ref:x,"aria-label":a("tools.title"),className:`flex min-h-0 flex-col border-l bg-background text-sm ${L?"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(H,{size:"sm"}):null,r(I,{size:"icon-xs",variant:"ghost-muted","aria-label":a("tools.close"),className:"ml-auto",onClick:e.onClose,children:r(K,{})})]}),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(H,{size:"sm"}),a("tools.reading")]}):null,f(ue,{title:a("tools.app.title"),children:[r(oe,{label:a("tools.app.foreground"),children:r("span",{className:"truncate font-mono text-xs",children:u?.id??a("tools.app.none")})}),u?f("div",{className:"flex gap-1.5",children:[r(I,{size:"xs",variant:"outline",disabled:n,onClick:()=>{i({type:"terminateApp",appId:u.id})},children:a("tools.app.terminate")}),r(I,{size:"xs",variant:"outline",disabled:n,onClick:()=>{i({type:"launchApp",appId:u.id})},children:a("tools.app.relaunch")})]}):null,r(va,{placeholder:a("tools.app.urlPlaceholder"),action:a("tools.app.open"),disabled:n,onSubmit:g=>i({type:"openUrl",url:g})}),r(va,{placeholder:a(m?"tools.app.bundleIdPlaceholder":"tools.app.packagePlaceholder"),action:a("tools.app.launch"),disabled:n,fallback:u?.id,onSubmit:g=>i({type:"launchApp",appId:g})})]}),f(ue,{title:a(m?"tools.settings.titleIos":"tools.settings.titleAndroid"),children:[r(oe,{label:a("tools.settings.appearance"),children:r(Sa,{label:a("tools.settings.appearance"),value:c?.appearance,options:qt.map(g=>({value:g,label:a(mr[g])})),disabled:n,onChange:g=>i({type:"setAppearance",value:g})})}),r(oe,{label:a("tools.settings.textSize"),children:r(Me,{ariaLabel:a("tools.settings.textSize"),value:c?.textSize??null,options:y,placeholder:a("tools.unknown"),disabled:n,onChange:g=>i({type:"setTextSize",value:g})})}),m?f(Z,{children:[r(oe,{label:a("tools.settings.liquidGlass"),children:r(Sa,{label:a("tools.settings.liquidGlass"),value:c?.liquidGlass,options:Nt.map(g=>({value:g,label:a(Lr[g])})),disabled:n,onChange:g=>i({type:"setLiquidGlass",value:g})})}),r(oe,{label:a("tools.settings.colorFilter"),children:r(Me,{ariaLabel:a("tools.settings.colorFilter"),value:c?.colorFilter??null,options:Gt.map(g=>({value:g,label:a(hr[g])})),placeholder:a("tools.unknown"),disabled:n,onChange:g=>i({type:"setColorFilter",value:g})})})]}):r(oe,{label:a("tools.settings.orientation"),children:r(Me,{ariaLabel:a("tools.settings.orientation"),value:null,options:Vt.map(g=>({value:g,label:a(xr[g])})),placeholder:a("tools.settings.rotateTo"),disabled:n,onChange:g=>i({type:"setOrientation",value:g})})}),b.map(g=>r(Ca,{label:a(g.labelKey),checked:c?.[g.setting],disabled:n,onChange:P=>i({type:"setToggle",setting:g.setting,value:P})},g.setting))]}),r(ue,{title:a("tools.accessibility.title"),children:r(Ca,{label:a("tools.accessibility.overlay"),checked:e.axOverlay,disabled:!1,onChange:g=>(e.onAxOverlayChange(g),Promise.resolve())})}),r($t,{disabled:n,act:i}),r(jt,{platform:t.platform,defaultAppId:u?.id??"",disabled:n,act:i}),m?r(Zt,{appId:u?.id,disabled:n,act:i}):null,m?r(Jt,{transport:e.transport,platform:t.platform,deviceId:t.id}):null]})]})}var Cr=2e4,ya=class extends Error{status;constructor(a){super(`Screenshot capture failed (${a}). Try again.`),this.status=a}};async function Yt(e,a,t,o){let l=AbortSignal.timeout(Cr),d=await e.fetch(`${fe(a)}/api/screenshot?device=${encodeURIComponent(t)}`,{method:"POST",signal:o?AbortSignal.any([o,l]):l});if(!d.ok)throw new ya(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 eo=e=>e instanceof Error?e.message:String(e);function ao(e){let{environmentId:a,device:t}=e,o=Y(),[l,d]=h(null),[s,u]=h(!1),[n,i]=h(null),c=q(!1),m=q(0),x={hostId:t.hostId,deviceId:t.id},L=y=>o("detail",a,x).then(b=>{m.current===y&&(d(b),i(null))},b=>{m.current===y&&(d(null),i(eo(b)))});return T(()=>{let y=++m.current;return L(y),()=>{m.current++}},[a,t.hostId,t.id]),{detail:l,pending:s,error:n,act:async y=>{if(c.current||l===null)return;c.current=!0;let b=++m.current;u(!0),i(null);try{let g=await o("action",a,{...x,...y});m.current===b?d(g):await L(++m.current)}catch(g){m.current===b&&i(eo(g))}finally{c.current=!1,u(!1)}},disabled:s||l===null,foregroundApp:e.foreground===void 0?l?.foregroundApp??null:e.foreground}}var Sr=()=>typeof window<"u"&&"ReactNativeWebView"in window;function to(e){let{t:a}=B(),t=ea(e.environmentId),[o,l]=h(null),[d,s]=h(!1),[u,n]=h(!1),[i,c]=h(!1),[m,x]=h(),[L,w]=h(!1),[y,b]=h(null),[g,P]=h(null),A=q(null),U=q(null),N=t.status==="ready"?t.transport:null,F=ao({environmentId:e.environmentId,device:e.device,foreground:m}),O=se(R=>l(R),[]),X=se(R=>s(R),[]);T(()=>{if(!N)return;let R=et({transport:N,platform:e.device.platform,deviceId:e.device.id},x);return()=>{R(),x(void 0)}},[e.device.id,e.device.platform,N]),T(()=>()=>{A.current?.abort(),U.current&&URL.revokeObjectURL(U.current)},[]);let $=()=>{if(!N||A.current)return;let R=new AbortController;A.current=R,w(!0),b(null),Yt(N,e.device.platform,e.device.id,R.signal).then(G=>{if(R.signal.aborted)return;U.current&&URL.revokeObjectURL(U.current);let V=URL.createObjectURL(G);if(U.current=V,Sr()){P(V);return}let M=document.createElement("a");M.href=V,M.download=`${e.device.name.replace(/[^a-z0-9-]/gi,"-")}-${Date.now()}.png`,document.body.append(M),M.click(),M.remove()}).catch(G=>{R.signal.aborted||b(G instanceof Error?G.message:a("workspace.screenshotFailed"))}).finally(()=>{A.current===R&&(A.current=null,w(!1))})};return t.status!=="ready"?r(J,{name:e.device.name,description:e.device.version,stage:t.status==="failed"?"error":"connecting",message:t.status==="failed"?t.message??a("workspace.needsNewerApp"):a("stream.connecting"),children:r(I,{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:[y||F.error&&!u?r("p",{role:"alert",className:"px-3 py-2 text-xs text-destructive-foreground",children:y??F.error}):null,f("div",{className:"relative min-h-0 flex-1",children:[r(Qe,{transport:t.transport,platform:e.device.platform,deviceId:e.device.id,deviceName:e.device.name,deviceDescription:e.device.version,axOverlay:i,withControls:!0,onHandle:O,onStreaming:X}),r(Ot,{platform:e.device.platform,handle:o,streaming:d,controls:F,screenshotPending:L,onScreenshot:$,toolsOpen:u,onTools:()=>n(!u),onClose:e.onClose,onPowerOff:e.onPowerOff,onFloat:e.onFloat})]})]}),u?r(Qt,{device:e.device,controls:F,transport:t.transport,axOverlay:i,onAxOverlayChange:c,onClose:()=>n(!1)}):null,g?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:g,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(I,{size:"sm",variant:"outline",onClick:()=>P(null),children:[r(K,{}),a("workspace.closeBrowser")]})]}):null]})}var wa=e=>e instanceof Error?e.message:String(e);function oo(e){let{environmentId:a,threadId:t}=e,{t:o}=B(),{state:l,loaded:d,error:s,unavailable:u}=pe(a),n=Y(),[i,c]=h(null),[m,x]=h(null),L=Fa(a,t),w=p=>Ee(a,t,p),y=E(),b=ne(y,"floating"),g=()=>{c(null),n("refresh",a).catch(p=>c(wa(p)))};T(()=>{!d||u||n("refresh",a).catch(()=>{})},[a,d,n,u]);let P=de(()=>l.sessions.filter(p=>p.threadId===t),[l.sessions,t]),A=yr(P,L),U=A?l.devices.find(p=>p.hostId===A.hostId&&p.id===A.deviceId):void 0,N=U&&A?he(U):null;T(()=>{y.floating?.present({environmentId:a,threadId:t},N)}),T(()=>()=>y.floating?.present({environmentId:a,threadId:t},null),[y,a,t]);let F=de(()=>wr(l),[l]),O=l.hostStatuses[me],X=O?.status==="ready",$=O?.status==="installing"||O?.status==="starting",R=La(),G=l.bootingDevices.filter(p=>p.threadId===t),V=l.hosts.flatMap(p=>p.platforms.filter(S=>!S.available)),M=async p=>{c(null),x(p),sa(a,t,_(p));try{await n("open",a,{threadId:t,hostId:p.hostId,deviceId:p.id,platform:p.platform}),w(_(p))}catch(S){sa(a,t,_(p),!1),c(wa(S))}finally{x(null)}},j=p=>{A&&(c(null),n("close",a,{threadId:t,hostId:A.hostId,deviceId:A.deviceId,shutdown:p}).then(()=>w(null)).catch(S=>c(wa(S))))};return u?r(J,{name:o("panel.title"),stage:"error",message:o("panel.unavailable")}):f("div",{className:"flex size-full min-h-0 flex-col",children:[G.length>0?r("div",{role:"status",className:"border-b px-3 py-2 text-xs text-muted-foreground",children:o("panel.booting",{names:G.map(p=>p.name).join(", ")})}):null,$&&!U?null:r(Tt,{detail:O,onRetry:()=>n("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(I,{size:"icon-xs",variant:"ghost","aria-label":o("panel.dismissError"),onClick:()=>c(null),children:r(K,{className:"size-3"})}):null]}):null,r("div",{className:"relative flex min-h-0 flex-1",children:U&&A?r(to,{environmentId:a,device:U,onBack:()=>w(""),onFloat:b?()=>y.floating?.open({environmentId:a,threadId:t},{...he(U),reason:"user"}):void 0,onPowerOff:()=>j(!0),onClose:()=>j(!1)},`${a}\0${_(U)}`):m||$||!d?r(J,{name:m?.name??o("panel.title"),...m?{description:m.version}:{},stage:"opening",message:m?m.booted?o("panel.opening"):o("panel.starting"):$&&O?R(O):o("panel.finding")}):r(vr,{environmentId:a,host:l.hosts.find(p=>p.id===me),grouped:F,hostReady:X,hostFailed:O?.status==="failed",unavailableReasons:V,showNoAvdHint:X&&!l.devices.some(p=>p.platform==="android")&&!V.some(p=>p.platform==="android"),pendingKey:m?_(m):null,onOpen:p=>{M(p)},onRefresh:g})})]})}function vr(e){let{t:a}=B(),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(Ft,{environmentId:e.environmentId},e.environmentId),t?f(Z,{children:[r(Le,{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(Le,{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(I,{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===_(l)?r(H,{size:"xs"}):r("span",{className:"text-xs",children:l.booted?a("panel.open"):a("panel.start")})]})},_(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(I,{variant:t?"outline":"ghost",size:"sm",onClick:e.onRefresh,children:a("panel.refresh")}),r(Bt,{environmentId:e.environmentId,host:e.host,busy:!1})]})]})})}function yr(e,a){if(a!==""){if(a!==null){let t=e.find(o=>_({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 ro({environmentId:e,threadId:a}){let t=E(),{state:o,loaded:l}=pe(e),d=q(null);return T(()=>{if(!l||!ne(t,"floating"))return;let s=`${e}\0${a}`,u=d.current?.key===s?d.current.seen:null,{seen:n,opened:i}=Ua({environmentId:e,threadId:a,previous:u,sessions:o.sessions,devices:o.devices});d.current={key:s,seen:n};for(let c of i)t.floating?.open({environmentId:e,threadId:a},{...he(c),reason:"agent",panelId:Ue})},[t,e,l,o.devices,o.sessions,a]),null}function br(e){return{panels:{device:function(t){return f(Fe,{value:e,children:[r("style",{children:ta}),r("div",{className:`${qe} flex h-full min-h-0 flex-1 flex-col`,children:r(oo,{environmentId:t.environmentId,threadId:t.threadId})})]})}},views:{deviceFloat:function(t){return f(Fe,{value:e,children:[r("style",{children:ta}),r("div",{className:`${qe} relative size-full`,children:r(wt,{...t})})]})},deviceSessions:function(t){return r(Fe,{value:e,children:r(ro,{environmentId:t.environmentId,threadId:t.threadId})})}}}}export{br as default};
package/dist/helper.mjs CHANGED
@@ -167,6 +167,13 @@ function exists(file) {
167
167
  function probeAndroidSdk(override) {
168
168
  const env = process.env;
169
169
  const home = env.HOME ?? env.USERPROFILE ?? "";
170
+ const source = override
171
+ ? "setting"
172
+ : env.ANDROID_HOME?.trim()
173
+ ? "ANDROID_HOME"
174
+ : env.ANDROID_SDK_ROOT?.trim()
175
+ ? "ANDROID_SDK_ROOT"
176
+ : null;
170
177
  const explicit = override || env.ANDROID_HOME?.trim() || env.ANDROID_SDK_ROOT?.trim() || null;
171
178
  const candidates = explicit
172
179
  ? [explicit]
@@ -179,6 +186,7 @@ function probeAndroidSdk(override) {
179
186
  "Sdk",
180
187
  ),
181
188
  ];
189
+ const defaults = candidates.length;
182
190
  if (!explicit) {
183
191
  for (const directory of (env.PATH ?? env.Path ?? "").split(NodePath.delimiter)) {
184
192
  if (!directory) continue;
@@ -191,7 +199,7 @@ function probeAndroidSdk(override) {
191
199
  }
192
200
  }
193
201
  const script = (name) => (isWindows ? `${name}.bat` : name);
194
- for (const root of candidates) {
202
+ for (const [index, root] of candidates.entries()) {
195
203
  const adb = exists(NodePath.join(root, "platform-tools", exe("adb")));
196
204
  const emulator = exists(NodePath.join(root, "emulator", exe("emulator")));
197
205
  if (explicit || adb || emulator) {
@@ -200,10 +208,19 @@ function probeAndroidSdk(override) {
200
208
  );
201
209
  const legacyAvdmanager =
202
210
  !avdmanager && exists(NodePath.join(root, "tools", "bin", script("avdmanager")));
203
- return { root, adb, emulator, avdmanager, legacyAvdmanager };
211
+ // 找到它的是哪条规则:设置里填的、两个环境变量、默认位置,还是 PATH 上的 adb。
212
+ const from = source ?? (index < defaults ? "default" : "path");
213
+ return { root, source: from, adb, emulator, avdmanager, legacyAvdmanager };
204
214
  }
205
215
  }
206
- return { root: null, adb: false, emulator: false, avdmanager: false, legacyAvdmanager: false };
216
+ return {
217
+ root: null,
218
+ source: null,
219
+ adb: false,
220
+ emulator: false,
221
+ avdmanager: false,
222
+ legacyAvdmanager: false,
223
+ };
207
224
  }
208
225
 
209
226
  /** 把 SDK 的两个目录排到 PATH 最前,并设好 ANDROID_HOME。 */
package/dist/index.js CHANGED
@@ -336,6 +336,7 @@ var versionParams = (prefix, version) => ({
336
336
  });
337
337
  var SETTINGS_CARD = {
338
338
  titleKey: "settings.card.title",
339
+ effectiveCommand: "effectiveSettings",
339
340
  actions: [
340
341
  {
341
342
  id: "check-tools",
@@ -459,6 +460,18 @@ var registerCommands = (ctx, service) => {
459
460
  return {};
460
461
  }
461
462
  });
463
+ ctx.command({
464
+ name: "effectiveSettings",
465
+ description: "Settings card: the Android SDK this machine would use if the location were empty.",
466
+ scope: "read",
467
+ payloadSchema: emptyPayload,
468
+ handle: async () => {
469
+ const sdk = await service.effectiveAndroidSdk();
470
+ return {
471
+ androidSdk: sdk.root === null ? { detailKey: "settings.androidSdk.notFound" } : sdk.source === null ? { value: sdk.root } : { value: sdk.root, detailKey: `settings.androidSdk.source.${sdk.source}` }
472
+ };
473
+ }
474
+ });
462
475
  ctx.command({
463
476
  name: "updateTool",
464
477
  description: "Verify this plugin's bundled version of one device tool without downloading or starting it.",
@@ -1388,6 +1401,13 @@ var registerEnvironmentCommands = (ctx, environments) => {
1388
1401
 
1389
1402
  // src/probe.ts
1390
1403
  var MIN_NODE_VERSION = [22, 12, 0];
1404
+ var ANDROID_SDK_SOURCES = /* @__PURE__ */ new Set([
1405
+ "setting",
1406
+ "ANDROID_HOME",
1407
+ "ANDROID_SDK_ROOT",
1408
+ "default",
1409
+ "path"
1410
+ ]);
1391
1411
  var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1392
1412
  var parseMachineProbe = (stdout) => {
1393
1413
  const line = stdout.trim().split(/\r?\n/).at(-1) ?? "";
@@ -1414,6 +1434,7 @@ var parseMachineProbe = (stdout) => {
1414
1434
  ...typeof value["iosToolsAvailable"] === "boolean" ? { iosToolsAvailable: value["iosToolsAvailable"] } : {},
1415
1435
  android: {
1416
1436
  root: typeof android["root"] === "string" ? android["root"] : null,
1437
+ source: typeof android["source"] === "string" && ANDROID_SDK_SOURCES.has(android["source"]) ? android["source"] : null,
1417
1438
  adb: android["adb"] === true,
1418
1439
  emulator: android["emulator"] === true,
1419
1440
  avdmanager: android["avdmanager"] === true,
@@ -1466,7 +1487,7 @@ var platformAvailability = (probe, platform2) => {
1466
1487
  return unavailable(
1467
1488
  "android",
1468
1489
  "android-sdk-missing",
1469
- "Android SDK was not found. Install it with Android Studio or set its location in the Devices settings."
1490
+ "Android SDK was not found. Prepare a private environment from the Devices panel, or set an existing SDK location in the Devices settings."
1470
1491
  );
1471
1492
  }
1472
1493
  if (!sdk.adb) {
@@ -2235,6 +2256,22 @@ var LocalDeviceHost = class {
2235
2256
  });
2236
2257
  return this.probeCache;
2237
2258
  }
2259
+ /**
2260
+ * 设置里的 SDK 位置留空时此刻会用哪个:准备过的私有环境优先,否则照助手的顺序现找一次。
2261
+ * 不看设置里填的值,也不动探测缓存。
2262
+ */
2263
+ async effectiveAndroidSdk() {
2264
+ const privateSdk = await selectedPrivateSdk(this.options.dataDir);
2265
+ if (privateSdk) return { root: privateSdk, source: "private" };
2266
+ const probe = await probeMachine({
2267
+ helperPath: this.options.helperPath,
2268
+ process: this.options.process,
2269
+ cwd: this.options.dataDir,
2270
+ sdkOverride: "",
2271
+ runtimeDir: bundledToolPaths(this.pluginDir, HUB_SPEC, this.options.runtimeDir).installDir
2272
+ });
2273
+ return { root: probe.android.root, source: probe.android.source };
2274
+ }
2238
2275
  async platformAvailability(platform2) {
2239
2276
  return platformAvailability(await this.machine(), platform2);
2240
2277
  }
@@ -3052,6 +3089,10 @@ var DeviceService = class {
3052
3089
  }
3053
3090
  }));
3054
3091
  }
3092
+ /** 设置卡的生效值:SDK 位置留空时此刻会用哪个。 */
3093
+ effectiveAndroidSdk() {
3094
+ return this.host.effectiveAndroidSdk();
3095
+ }
3055
3096
  /** 宿主现状,不装不起。 */
3056
3097
  async inspect(refreshProbe = false) {
3057
3098
  const summary = await this.host.summary(refreshProbe);
@@ -3522,7 +3563,7 @@ var deviceToolkit = (service) => ({
3522
3563
  var HUB_SERVICE = "hub";
3523
3564
  var index_default = definePlugin({
3524
3565
  id: "devices",
3525
- apiVersion: 53,
3566
+ apiVersion: 60,
3526
3567
  activate: async (ctx) => {
3527
3568
  const direct = (input, init) => ctx.proxies.fetch(PLUGIN_PROXY_DIRECT).then((fetchDirect) => fetchDirect(input, init));
3528
3569
  const host = new LocalDeviceHost({
package/locales/en.json CHANGED
@@ -1,4 +1,8 @@
1
1
  {
2
+ "presentation": {
3
+ "name": "Devices",
4
+ "description": "Lets agents drive iOS Simulators and Android Emulators on this machine."
5
+ },
2
6
  "environment": {
3
7
  "title": "Prepare simulator environment",
4
8
  "description": "Existing Android SDKs and Xcode are reused; preparation only starts when you choose it.",
@@ -49,11 +53,13 @@
49
53
  "ios-version-required": "Choose an exact iOS version supported by your Xcode. Apple determines the download size and final installation location.",
50
54
  "android-platform-unsupported": "Google does not provide this pinned emulator for the machine's operating system and architecture.",
51
55
  "virtualization-unavailable": "The emulator's system acceleration is unavailable or not accessible. Follow the official guidance for WHPX, KVM or Hypervisor.framework. Ycodium does not enable system features, elevate privileges or install drivers.",
52
- "windows-hypervisor-platform-disabled": "Windows Hypervisor Platform is not enabled. This does not mean hardware virtualization is disabled in BIOS/UEFI. Follow the official Windows setup guidance; Ycodium will not change system features.",
56
+ "windows-hypervisor-platform-disabled": "Android emulators need Windows Hypervisor Platform, which is turned off, so preparation can't start. Turn it on in Windows Features (Turn Windows features on or off → Windows Hypervisor Platform) as an administrator, restart the computer, then check again. Ycodium does not change system features.",
53
57
  "windows-hypervisor-not-running": "Windows Hypervisor Platform is enabled, but the Windows hypervisor is not currently running. Follow the official guidance to check restart and boot requirements. Ycodium will not change boot settings.",
54
58
  "virtualization-firmware-disabled": "Windows reports that virtualization is disabled in BIOS/UEFI. Check the firmware setting using the computer manufacturer's instructions.",
55
59
  "virtualization-probe-failed": "The emulator acceleration status could not be determined. This is not evidence that hardware virtualization is disabled. Retry the check or consult the official setup guidance."
56
- }
60
+ },
61
+ "unsupported": "This machine can't run the emulator yet, so preparation is unavailable. See the official setup guidance above.",
62
+ "notEnoughSpace": "Not enough free space on this disk. Choose a directory on another disk above, then check again."
57
63
  },
58
64
  "settings": {
59
65
  "card": {
@@ -61,8 +67,16 @@
61
67
  },
62
68
  "androidSdk": {
63
69
  "label": "Android SDK location",
64
- "description": "Leave empty to use ANDROID_HOME or Android Studio's default location.",
65
- "placeholder": "Detect automatically"
70
+ "description": "Leave empty to use the private emulator environment if you prepared one, otherwise ANDROID_HOME, ANDROID_SDK_ROOT or Android Studio's default location.",
71
+ "placeholder": "Detect automatically",
72
+ "notFound": "No Android SDK found on this machine",
73
+ "source": {
74
+ "private": "private emulator environment",
75
+ "ANDROID_HOME": "ANDROID_HOME",
76
+ "ANDROID_SDK_ROOT": "ANDROID_SDK_ROOT",
77
+ "default": "Android Studio's default location",
78
+ "path": "found through adb on PATH"
79
+ }
66
80
  },
67
81
  "checkTools": {
68
82
  "label": "Check tool versions",
@@ -86,7 +100,7 @@
86
100
  "platformAndroid": "Android Emulators",
87
101
  "empty": "No simulators or emulators were found on this machine.",
88
102
  "hubFailed": "The device hub failed to start.",
89
- "noAvd": "No Android virtual devices found. Prepare a private simulator below, or create one in Android Studio's Device Manager, then refresh.",
103
+ "noAvd": "No Android virtual devices found. Prepare a private simulator above, or create one in Android Studio's Device Manager, then refresh.",
90
104
  "refresh": "Refresh devices",
91
105
  "open": "Open",
92
106
  "start": "Start",
@@ -261,5 +275,17 @@
261
275
  "check": "Check versions",
262
276
  "checkFailed": "Could not read the tool versions. Try again.",
263
277
  "updateFailed": "Bundled components are missing or incomplete. Repair or update Ycodium on this machine."
278
+ },
279
+ "unavailable": {
280
+ "ios-needs-macos": "iOS Simulators need macOS with Xcode.",
281
+ "ios-tools-missing": "The bundled iOS Simulator helpers are missing or could not load. Repair or update Ycodium on this machine.",
282
+ "xcode-missing": "Xcode command line tools were not found.",
283
+ "ios-runtime-missing": "An iOS Simulator runtime is missing. Choose an exact version in Prepare simulator environment, or install one in Xcode Settings.",
284
+ "android-sdk-invalid": "The Android SDK tools could not run. Check the SDK installation, or prepare a private environment above.",
285
+ "android-sdk-missing": "No Android SDK was found on this machine. Prepare one with Prepare simulator environment above, or set an existing SDK location in the Devices settings.",
286
+ "android-platform-tools-missing": "Android SDK Platform-Tools are missing from {{root}}. Install them in Android Studio's SDK Manager, or prepare a private environment above.",
287
+ "android-emulator-missing": "Android Emulator is missing from {{root}}. Install it in Android Studio's SDK Manager, or prepare a private environment above.",
288
+ "android-cmdline-tools-missing": "Android SDK command-line tools are missing from {{root}}. Install them in Android Studio's SDK Manager, or prepare a private environment above.",
289
+ "android-cmdline-tools-legacy": "The Android SDK command-line tools in {{root}} are too old. Update them in Android Studio's SDK Manager, or prepare a private environment above."
264
290
  }
265
291
  }
@@ -1,4 +1,8 @@
1
1
  {
2
+ "presentation": {
3
+ "name": "设备",
4
+ "description": "让 agent 操作这台机器上的 iOS 模拟器与安卓模拟器。"
5
+ },
2
6
  "environment": {
3
7
  "title": "准备模拟器环境",
4
8
  "description": "优先复用已有 Android SDK 和 Xcode,只有主动点击准备才会下载。",
@@ -49,11 +53,13 @@
49
53
  "ios-version-required": "请选择当前 Xcode 支持的明确 iOS 版本。下载大小和最终安装位置由 Apple 决定。",
50
54
  "android-platform-unsupported": "Google 没有为这台机器的系统和架构提供此固定版本的模拟器。",
51
55
  "virtualization-unavailable": "模拟器需要的系统加速功能不可用或无法访问。请按官方指引检查 WHPX、KVM 或 Hypervisor.framework。Ycodium 不会启用系统功能、提权或安装驱动。",
52
- "windows-hypervisor-platform-disabled": "Windows Hypervisor Platform(Windows 虚拟机监控程序平台)尚未启用。这不代表 BIOS/UEFI 中的硬件虚拟化未开启。请按 Windows 官方指引检查;Ycodium 不会修改系统功能。",
56
+ "windows-hypervisor-platform-disabled": "安卓模拟器需要「Windows 虚拟机监控程序平台」,它目前没有开启,所以还不能准备。请用管理员身份在「启用或关闭 Windows 功能」里勾选「Windows 虚拟机监控程序平台」,重启电脑后再检查一次。Ycodium 不会修改系统功能。",
53
57
  "windows-hypervisor-not-running": "Windows Hypervisor Platform 已启用,但 Windows hypervisor 当前没有运行。请按官方指引检查是否需要重启及启动配置;Ycodium 不会修改启动设置。",
54
58
  "virtualization-firmware-disabled": "Windows 报告 BIOS/UEFI 中的虚拟化未开启。请按电脑厂商的说明检查固件设置。",
55
59
  "virtualization-probe-failed": "无法确定模拟器加速状态,不能据此认定硬件虚拟化未开启。请重试检查或参考官方设置指引。"
56
- }
60
+ },
61
+ "unsupported": "这台机器暂时跑不了模拟器,所以现在不能准备。请看上面的官方设置指引。",
62
+ "notEnoughSpace": "这块磁盘剩余空间不够。请在上面换一个其他磁盘上的目录,再检查一次。"
57
63
  },
58
64
  "settings": {
59
65
  "card": {
@@ -61,8 +67,16 @@
61
67
  },
62
68
  "androidSdk": {
63
69
  "label": "Android SDK 位置",
64
- "description": "留空则使用 ANDROID_HOME 或 Android Studio 的默认位置。",
65
- "placeholder": "自动检测"
70
+ "description": "留空时,准备过私有模拟器环境就用它,否则依次用 ANDROID_HOME、ANDROID_SDK_ROOT 或 Android Studio 的默认位置。",
71
+ "placeholder": "自动检测",
72
+ "notFound": "这台机器上没有找到 Android SDK",
73
+ "source": {
74
+ "private": "私有模拟器环境",
75
+ "ANDROID_HOME": "ANDROID_HOME",
76
+ "ANDROID_SDK_ROOT": "ANDROID_SDK_ROOT",
77
+ "default": "Android Studio 默认位置",
78
+ "path": "按 PATH 上的 adb 找到"
79
+ }
66
80
  },
67
81
  "checkTools": {
68
82
  "label": "检查工具版本",
@@ -86,7 +100,7 @@
86
100
  "platformAndroid": "安卓模拟器",
87
101
  "empty": "这台机器上没有找到模拟器。",
88
102
  "hubFailed": "设备 hub 没能启动。",
89
- "noAvd": "没有找到安卓虚拟设备。可在下方准备私有模拟器,或在 Android Studio 的 Device Manager 中创建后刷新。",
103
+ "noAvd": "没有找到安卓虚拟设备。可在上方准备私有模拟器,或在 Android Studio 的 Device Manager 中创建后刷新。",
90
104
  "refresh": "刷新设备",
91
105
  "open": "打开",
92
106
  "start": "启动",
@@ -261,5 +275,17 @@
261
275
  "check": "检查版本",
262
276
  "checkFailed": "读不到工具版本,请重试。",
263
277
  "updateFailed": "随包组件缺失或不完整,请修复或更新这台机器上的 Ycodium。"
278
+ },
279
+ "unavailable": {
280
+ "ios-needs-macos": "iOS 模拟器需要装有 Xcode 的 macOS。",
281
+ "ios-tools-missing": "随包的 iOS 模拟器助手缺失或无法加载。请在这台机器上修复或更新 Ycodium。",
282
+ "xcode-missing": "没有找到 Xcode 命令行工具。",
283
+ "ios-runtime-missing": "缺少 iOS 模拟器运行时。请在「准备模拟器环境」里选一个明确版本,或在 Xcode 设置中安装。",
284
+ "android-sdk-invalid": "Android SDK 工具无法运行。请检查 SDK 安装,或在上方准备私有环境。",
285
+ "android-sdk-missing": "这台机器上没有找到 Android SDK。可以用上方的「准备模拟器环境」准备一套,或在 Devices 设置中指定已有 SDK 的位置。",
286
+ "android-platform-tools-missing": "{{root}} 中缺少 Android SDK Platform-Tools。请在 Android Studio 的 SDK Manager 中安装,或在上方准备私有环境。",
287
+ "android-emulator-missing": "{{root}} 中缺少 Android Emulator。请在 Android Studio 的 SDK Manager 中安装,或在上方准备私有环境。",
288
+ "android-cmdline-tools-missing": "{{root}} 中缺少 Android SDK 命令行工具。请在 Android Studio 的 SDK Manager 中安装,或在上方准备私有环境。",
289
+ "android-cmdline-tools-legacy": "{{root}} 中的 Android SDK 命令行工具版本过旧。请在 Android Studio 的 SDK Manager 中更新,或在上方准备私有环境。"
264
290
  }
265
291
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/plugin-devices",
3
- "version": "0.2.3710",
3
+ "version": "0.2.3799",
4
4
  "description": "Lets agents drive iOS Simulators and Android Emulators on this machine.",
5
5
  "keywords": [
6
6
  "android",
@@ -33,14 +33,16 @@
33
33
  "tailwindcss": "^4.0.0",
34
34
  "typescript": "~6.0.3",
35
35
  "vite-plus": "0.2.2",
36
+ "@ycodium-ai/plugin-api": "0.2.3799",
36
37
  "ycodium-fetch-ports": "0.0.0",
37
- "@ycodium-ai/plugin-api": "0.2.3710",
38
38
  "ycodium-sse-stream": "0.0.0"
39
39
  },
40
40
  "ycodium": {
41
41
  "plugin": "./dist/index.js",
42
42
  "displayName": "Devices",
43
+ "displayNameKey": "presentation.name",
43
44
  "description": "Lets agents drive iOS Simulators and Android Emulators on this machine.",
45
+ "descriptionKey": "presentation.description",
44
46
  "icon": "./assets/icon.svg",
45
47
  "ui": {
46
48
  "assets": "./assets",