@fugood/bricks-cli 2.25.0-beta.4 → 2.25.0-beta.6
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/README.md +13 -0
- package/lib/10.js +1 -0
- package/lib/117.js +2543 -0
- package/lib/166.js +1 -0
- package/lib/178.js +1 -0
- package/lib/3.js +1 -0
- package/lib/456.js +1 -0
- package/lib/511.js +1 -0
- package/lib/587.js +7 -0
- package/lib/602.js +3 -0
- package/lib/647.js +30 -0
- package/lib/940.js +1 -0
- package/lib/index.js +535 -305
- package/package.json +6 -5
- package/lib/300.js +0 -1
- package/lib/356.js +0 -1
- package/lib/425.js +0 -1
- package/lib/428.js +0 -7
- package/lib/465.js +0 -1
- package/lib/63.js +0 -1
- package/lib/737.js +0 -2452
- package/lib/779.js +0 -1
- package/lib/890.js +0 -1
- package/lib/999.js +0 -1
package/lib/940.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"ink";import*as l from"react";import{Fragment as r,jsx as t,jsxs as n}from"react/jsx-runtime";export const __rspack_esm_id=940;export const __rspack_esm_ids=[940];export const __webpack_modules__={8498(l){l.exports=e},51649(e){e.exports=l},92319(e,l,i){i.r(l),i.d(l,{AppList:()=>O,CONTROL_ACTIONS:()=>T,MainMenu:()=>I,Header:()=>y,ModuleDetail:()=>R,ONLINE_THRESHOLD_MS:()=>p,ShortEditEditor:()=>q,MediaFileList:()=>F,App:()=>es,DeviceDetail:()=>L,VIEWS:()=>m,runInteractiveMode:()=>ex,DeviceList:()=>C,MediaBoxList:()=>$,Loading:()=>D,DeviceControl:()=>k,ProjectInitView:()=>eu,GroupDetail:()=>G,ModuleList:()=>P,MediaBoxDetail:()=>V,GroupList:()=>N,Footer:()=>b,DeviceStatus:()=>E,AppDetail:()=>M,DeviceScreenshot:()=>w,MediaFileDetail:()=>j});var o,a,c=i(99436),d=i(51649),u=i(8498),s=i(68832),h=i(85382),x=i(23258),g=i(60450),m={MAIN:"main",DEVICES:"devices",DEVICE_DETAIL:"device_detail",DEVICE_CONTROL:"device_control",DEVICE_SCREENSHOT:"device_screenshot",APPS:"apps",APP_DETAIL:"app_detail",APP_SHORT_EDIT:"app_short_edit",APP_PROJECT_INIT:"app_project_init",MODULES:"modules",MODULE_DETAIL:"module_detail",MODULE_SHORT_EDIT:"module_short_edit",MODULE_PROJECT_INIT:"module_project_init",GROUPS:"groups",GROUP_DETAIL:"group_detail",MEDIA_BOXES:"media_boxes",MEDIA_BOX_DETAIL:"media_box_detail",MEDIA_FILES:"media_files",MEDIA_FILE_DETAIL:"media_file_detail",ACTIVITY_LOG:"activity_log"},T=[{label:"Refresh Application",value:"refresh"},{label:"Clear Cache",value:"clear-cache"},{label:"Take Screenshot",value:"take-screenshot"},{label:"Open System Menu",value:"system-menu-open"},{label:"Close System Menu",value:"system-menu-close"},{label:"Open Debug Panel",value:"debug-panel-open"},{label:"Close Debug Panel",value:"debug-panel-close"},{label:"Enable Logging",value:"logging-on"},{label:"Disable Logging",value:"logging-off"},{label:"← Back",value:"back"}],p=3e5,f=i(47882),v=(e,l=!0)=>{var r=Math.floor(60),t=s((0,d.useState)(r),2),n=t[0],i=t[1],o=s((0,d.useState)(null),2),a=o[0],c=o[1],u=(0,d.useRef)(e);(0,d.useEffect)(()=>{u.current=e},[e]);var h=(0,d.useCallback)(()=>{i(r),c(Date.now())},[r]);return(0,d.useEffect)(()=>{if(l){var e=setInterval(()=>{i(e=>e<=1?(u.current?.(),c(Date.now()),r):e-1)},1e3);return()=>clearInterval(e)}},[l,r]),(0,d.useEffect)(()=>{l&&(i(r),c(Date.now()))},[l,r]),{countdown:n,lastRefreshTime:a,resetCountdown:h}},_=({countdown:e,lastRefreshTime:l})=>t(u.Box,{children:n(u.Text,{color:"gray",children:["Next refresh in ",n(u.Text,{color:"cyan",children:[e,"s"]}),l&&n(u.Text,{color:"gray",children:[" (last: ",l?new Date(l).toLocaleTimeString():null,")"]})]})}),y=({workspace:e,view:l})=>n(u.Box,{flexDirection:"column",marginBottom:1,children:[n(u.Box,{children:[t(u.Text,{bold:!0,color:"cyan",children:"BRICKS CLI"}),t(u.Text,{color:"gray",children:" - Interactive Mode"})]}),n(u.Box,{children:[t(u.Text,{color:"gray",children:"Workspace: "}),t(u.Text,{color:"green",children:e?.name||"Not connected"}),t(u.Text,{color:"gray",children:" | View: "}),t(u.Text,{color:"yellow",children:l})]}),t(u.Text,{color:"gray",children:"─".repeat(60)})]}),b=()=>n(u.Box,{marginTop:1,flexDirection:"column",children:[t(u.Text,{color:"gray",children:"─".repeat(60)}),n(u.Text,{color:"gray",children:["Press ",t(u.Text,{color:"cyan",children:"q"})," to quit, ",t(u.Text,{color:"cyan",children:"Esc"})," to go back"]})]}),D=({text:e})=>n(u.Box,{children:[t(u.Text,{color:"green",children:t(f.A,{type:"dots"})}),n(u.Text,{children:[" ",e||"Loading..."]})]}),E=({lastAliveTime:e})=>{if(!e)return t(u.Text,{color:"gray",children:"○ Unknown"});var l=Date.now()-new Date(e).getTime();if(l<=p)return t(u.Text,{color:"green",children:"● Online"});var r=Math.floor(l/6e4);if(r<60)return n(u.Text,{color:"yellow",children:["○ Offline (",r,"m ago)"]});var i=Math.floor(r/60);if(i<24)return n(u.Text,{color:"red",children:["○ Offline (",i,"h ago)"]});var o=Math.floor(i/24);return n(u.Text,{color:"red",children:["○ Offline (",o,"d ago)"]})},S=i(48724),I=({onSelect:e,mediaEnabled:l,activityLogEnabled:r})=>{var i=[{label:"Devices",value:m.DEVICES},{label:"Applications",value:m.APPS},{label:"Modules",value:m.MODULES},{label:"Device Groups",value:m.GROUPS},...l?[{label:"Media Flow",value:m.MEDIA_BOXES}]:[],...r?[{label:"Activity Log",value:m.ACTIVITY_LOG}]:[],{label:"Exit",value:"exit"}];return n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,marginBottom:1,children:"Main Menu"}),t(S.Ay,{items:i,onSelect:e})]})},A="1"===process.env.BRICKS_CLI_DISTRIBUTION,B=e=>{var l=s((0,d.useState)(null),2),r=l[0],n=l[1];return((0,d.useEffect)(()=>{if(!A){var e=!0;return i.e(166).then(i.bind(i,29557)).then(l=>{e&&n(()=>l.default)}).catch(()=>{e&&n(!1)}),()=>{e=!1}}},[]),A||!1===r)?t(u.Text,{color:"gray",children:"Image preview is not available in this CLI build."}):r?t(r,{...e}):t(D,{text:"Preparing image preview..."})},C=({devices:e,loading:l,onSelect:r,countdown:i,lastRefreshTime:o})=>{if(l)return t(D,{text:"Loading devices..."});if(!e?.length)return n(u.Box,{flexDirection:"column",children:[t(u.Text,{color:"yellow",children:"No devices found"}),t(_,{countdown:i,lastRefreshTime:o})]});var a=[...e.map(e=>{var l=(e=>{if(!e)return"○ Unknown";var l=Date.now()-new Date(e).getTime();if(l<=p)return"● Online";var r=Math.floor(l/6e4);if(r<60)return`○ ${r}m ago`;var t=Math.floor(r/60);if(t<24)return`○ ${t}h ago`;var n=Math.floor(t/24);return`○ ${n}d ago`})(e.entry_detail?.watch_dog_timer?.last_alive_time);return{label:`${l} - ${e.name||e.device_name}`,value:e._id,device:e}}),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Box,{marginBottom:1,children:[n(u.Text,{bold:!0,children:["Devices (",e.length,")"]}),t(u.Text,{color:"gray",children:" - "}),t(_,{countdown:i,lastRefreshTime:o})]}),t(S.Ay,{items:a,onSelect:r})]})},L=({device:e,loading:l,error:r,onSelect:i,mediaEnabled:o,countdown:a,lastRefreshTime:c})=>{if(l)return t(D,{text:"Loading device..."});if(r)return n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",r]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(u.Text,{color:"red",children:"Device not found"});var d=[{label:"Control Device",value:"control"},...o?[{label:"View Screenshot",value:"screenshot"}]:[],{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],s=e.entry_detail,h=s?.screen,x=s?.update,g=s?.local_sync;return n(u.Box,{flexDirection:"column",children:[n(u.Box,{children:[t(u.Text,{bold:!0,color:"cyan",children:e.name||e.device_name}),t(u.Text,{color:"gray",children:" - "}),t(_,{countdown:a,lastRefreshTime:c})]}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Box,{children:[t(u.Text,{color:"gray",children:"Status: "}),t(E,{lastAliveTime:s?.watch_dog_timer?.last_alive_time})]}),n(u.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),s?.application&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Application"}),n(u.Text,{color:"gray",children:[" Name: ",s.application.name]}),n(u.Text,{color:"gray",children:[" Mode: ",s.operation_mode||"N/A"]})]}),h&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Screen"}),h.resolution&&n(u.Text,{color:"gray",children:[" ","Resolution: ",h.resolution.width,"x",h.resolution.height,h.resolution.scale&&` @${h.resolution.scale}x`]}),h.orientation&&n(u.Text,{color:"gray",children:[" Orientation: ",h.orientation]}),h.touch&&n(u.Text,{color:"gray",children:[" ","Touch:"," ",h.touch.available?`Yes (${h.touch.touch_point} points)`:"No"]})]}),(s?.memory_usage||s?.disk_usage)&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"System"}),s.memory_usage&&n(u.Text,{color:"gray",children:[" Memory: ",Math.round(100*s.memory_usage),"%"]}),s.disk_usage&&n(u.Text,{color:"gray",children:[" Disk: ",Math.round(100*s.disk_usage),"%"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Capabilities"}),n(u.Text,{color:"gray",children:[" ","Sound: ",s?.sound?.available?"✓":"✗"," | ","Camera: ",s?.camera?.available?"✓":"✗"," | ","Audio In: ",s?.audio_in?.available?"✓":"✗"]})]}),g&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Local Sync"}),n(u.Text,{color:"gray",children:[" ","Role: ",g.is_main?"Main":"Peer",g.peer_count>0&&` | Peers: ${g.peer_count}`,g.mean_latency&&` | Latency: ${g.mean_latency}ms`]})]}),x&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Update"}),n(u.Text,{color:x.need_update?"yellow":"gray",children:[" ","Status: ",x.need_update?"⚠ Update available":"✓ Up to date"]}),x.current_version&&n(u.Text,{color:"gray",children:[" Version: ",x.current_version]})]})]}),t(S.Ay,{items:d,onSelect:i})]})},k=({device:e,onSelect:l,controlling:r,controlResult:i})=>n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,color:"cyan",children:["Control: ",e?.name||e?.device_name]}),r&&t(D,{text:"Sending command..."}),i&&t(u.Text,{color:i.success?"green":"red",children:i.message}),t(u.Box,{marginTop:1,children:t(S.Ay,{items:T,onSelect:l})})]}),w=({device:e,screenshot:l,loading:r,error:i,onSelect:o})=>{var a=l?.file?.meta,c=a?.originalWidth!=null&&a?.originalHeight!=null,d=a?.originalFileSize!=null;return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,color:"cyan",children:["Screenshot: ",e?.name||e?.device_name||"Unknown"]}),r&&t(D,{text:"Loading screenshot..."}),i&&t(u.Box,{marginY:1,children:t(u.Text,{color:"red",children:String(i)})}),!r&&!i&&l&&n(u.Box,{flexDirection:"column",children:[t(u.Box,{height:30,children:t(B,{src:l.path,width:80,alt:"Device screenshot"})}),n(u.Box,{marginY:1,flexDirection:"column",children:[t(u.Text,{bold:!0,color:"white",children:"Screenshot Details"}),n(u.Box,{marginY:1,children:[t(u.Text,{color:"green",children:"Screenshot saved to: "}),t(u.Text,{color:"cyan",children:String(l.path||"")})]}),c&&n(u.Text,{color:"gray",children:["Size: ",String(a.originalWidth),"x",String(a.originalHeight)]}),d&&n(u.Text,{color:"gray",children:["File: ",(Number(a.originalFileSize)/1024).toFixed(1)," KB"]}),l.file?.updatedAt&&n(u.Text,{color:"gray",children:["Updated: ",new Date(l.file.updatedAt).toLocaleString()]})]})]}),!r&&!i&&!l&&t(u.Box,{marginY:1,children:t(u.Text,{color:"yellow",children:"No screenshot available. Try taking a new one."})}),t(u.Box,{marginTop:1,children:t(S.Ay,{items:[{label:"Take New Screenshot",value:"take"},{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:o})})]})},O=({apps:e,loading:l,onSelect:r})=>{if(l)return t(D,{text:"Loading applications..."});if(!e?.length)return t(u.Text,{color:"yellow",children:"No applications found"});var i=[...e.map(e=>({label:`${e.has_unreleased_changes?"●":"○"} ${e.name}`,value:e._id,app:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,marginBottom:1,children:["Applications (",e.length,")"]}),t(S.Ay,{items:i,onSelect:r})]})},M=({app:e,loading:l,error:r,onSelect:i})=>{if(l)return t(D,{text:"Loading application..."});if(r)return n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",r]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(u.Text,{color:"red",children:"Application not found"});var o=[{label:"⚡ Initialize Project",value:"project_init"},...e.short_edit?.enabled&&e.short_edit.ref_map?[{label:"Short Edit",value:"short_edit"}]:[],{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],a=e.devices?.length||0,c=e.devices?.filter(e=>"online"===e.status)?.length||0;return n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:e.name}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Version"}),n(u.Text,{color:"gray",children:[" ","Current: ",e.current_version?`v${e.current_version}`:"N/A"]}),n(u.Text,{color:e.has_unreleased_changes?"yellow":"gray",children:[" ","Changes:"," ",e.has_unreleased_changes?"● Unreleased changes":"○ No pending changes"]}),e.current_version_details&&n(u.Text,{color:"gray",children:[" ","Released: v",e.current_version_details.version||"N/A"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Devices"}),n(u.Text,{color:"gray",children:[" ","Total: ",a,a>0&&` (${c} online)`]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Features"}),n(u.Text,{color:"gray",children:[" ","Short Edit: ",e.short_edit?.enabled?"✓ Enabled":"✗ Disabled"]}),n(u.Text,{color:"gray",children:[" ","Canvas Control: ",e.canvas_control?.enabled?"✓ Enabled":"✗ Disabled"]}),n(u.Text,{color:"gray",children:[" ","Device Control: ",e.device_control?.enabled?"✓ Enabled":"✗ Disabled"]}),n(u.Text,{color:e.lock?.enabled?"yellow":"gray",children:[" ","Lock: ",e.lock?.enabled?"\uD83D\uDD12 Locked":"\uD83D\uDD13 Unlocked"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&n(u.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&n(u.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),t(S.Ay,{items:o,onSelect:i})]})},P=({modules:e,loading:l,onSelect:r})=>{if(l)return t(D,{text:"Loading modules..."});var i=[...(e||[]).map(e=>({label:`${e.current_version?"●":"○"} ${e.name}`,value:e._id,module:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,marginBottom:1,children:["Modules (",e?.length||0,")"]}),!e?.length&&t(u.Text,{color:"yellow",children:"No modules found"}),t(S.Ay,{items:i,onSelect:r})]})},R=({module:e,loading:l,error:r,onSelect:i})=>{if(l)return t(D,{text:"Loading module..."});if(r)return n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",r]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(u.Text,{color:"red",children:"Module not found"});var o=[{label:"⚡ Initialize Project",value:"project_init"},...e.short_edit?.enabled&&e.short_edit.ref_map?[{label:"Short Edit",value:"short_edit"}]:[],{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:e.name}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Version"}),n(u.Text,{color:"gray",children:[" ","Current: ",e.current_version?`v${e.current_version}`:"N/A"]}),n(u.Text,{color:e.has_unreleased_changes?"yellow":"gray",children:[" ","Changes:"," ",e.has_unreleased_changes?"● Unreleased changes":"○ No pending changes"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Usage"}),n(u.Text,{color:"gray",children:[" ","Used in: ",e.use_count?.total_count||0," application(s)"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Settings"}),n(u.Text,{color:"gray",children:[" ","Public: ",e.is_public?"✓ Yes":"✗ No"]}),n(u.Text,{color:"gray",children:[" ","Modifiable: ",e.is_allow_modify?"✓ Yes":"✗ No"]}),n(u.Text,{color:"gray",children:[" ","Short Edit: ",e.short_edit?.enabled?"✓ Enabled":"✗ Disabled"]})]}),e.expose_properties?.length>0&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Exposed Properties"}),n(u.Text,{color:"gray",children:[" ",e.expose_properties.length," properties exposed"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&n(u.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&n(u.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),t(S.Ay,{items:o,onSelect:i})]})},N=({groups:e,loading:l,onSelect:r,countdown:i,lastRefreshTime:o})=>{if(l)return t(D,{text:"Loading device groups..."});var a=[...(e||[]).map(e=>({label:`📁 ${e.name} (${e.devices?.length||0} devices)`,value:e._id,group:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Box,{marginBottom:1,children:[n(u.Text,{bold:!0,children:["Device Groups (",e?.length||0,")"]}),t(u.Text,{color:"gray",children:" - "}),t(_,{countdown:i,lastRefreshTime:o})]}),!e?.length&&t(u.Text,{color:"yellow",children:"No device groups found"}),t(S.Ay,{items:a,onSelect:r})]})},U=({loading:e,groupDevices:l})=>e?t(D,{text:"Loading devices..."}):l?.length?n(r,{children:[l.slice(0,10).map(e=>n(u.Box,{children:[t(u.Text,{color:"gray",children:" "}),t(E,{lastAliveTime:e.entry_detail?.watch_dog_timer?.last_alive_time}),n(u.Text,{color:"gray",children:[" ",e.name||e.device_name]}),e.device_target_name&&n(u.Text,{color:"gray",dimColor:!0,children:[" ","(",e.device_target_name,")"]})]},e._id)),l.length>10&&n(u.Text,{color:"gray",dimColor:!0,children:[" ","... and ",l.length-10," more"]})]}):t(u.Text,{color:"gray",children:" No devices in this group"}),G=({group:e,groupDevices:l,loading:r,error:i,onSelect:o,countdown:a,lastRefreshTime:c})=>r&&!e?t(D,{text:"Loading device group..."}):i?n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",i]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]}):e?n(u.Box,{flexDirection:"column",children:[n(u.Box,{children:[t(u.Text,{bold:!0,color:"cyan",children:e.name}),t(u.Text,{color:"gray",children:" - "}),t(_,{countdown:a,lastRefreshTime:c})]}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[n(u.Text,{bold:!0,color:"white",children:["Devices (",e.devices?.length||0,")"]}),t(U,{loading:r,groupDevices:l})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&n(u.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&n(u.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),t(S.Ay,{items:[{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:o})]}):t(u.Text,{color:"red",children:"Device group not found"}),$=({boxes:e,loading:l,onSelect:r})=>{if(l)return t(D,{text:"Loading media boxes..."});if(!e?.length)return t(u.Text,{color:"yellow",children:"No media boxes found"});var i=[...e.map(e=>({label:`📦 ${e.name||"Unnamed"}`,value:e.id,box:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,marginBottom:1,children:["Media Boxes (",e.length,")"]}),t(S.Ay,{items:i,onSelect:r})]})},V=({box:e,loading:l,error:r,onSelect:i})=>l&&!e?t(D,{text:"Loading media box..."}):r?n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",r]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]}):e?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:e.name||"Unnamed"}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{color:"gray",children:["ID: ",e.id]}),e.tags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),null!=e.size&&n(u.Text,{color:"gray",children:["Size: ",e.size]}),e.passcodes?.length>0&&n(u.Box,{flexDirection:"column",marginTop:1,children:[n(u.Text,{bold:!0,color:"white",children:["Passcodes (",e.passcodes.length,")"]}),e.passcodes.slice(0,5).map(e=>n(u.Text,{color:"gray",children:[" ",e.name||"Passcode",": ",e.code]},e.id)),e.passcodes.length>5&&n(u.Text,{color:"gray",dimColor:!0,children:[" ","... and ",e.passcodes.length-5," more"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Timestamps"}),e.createdAt&&n(u.Text,{color:"gray",children:[" Created: ",new Date(e.createdAt).toLocaleString()]}),e.updatedAt&&n(u.Text,{color:"gray",children:[" Modified: ",new Date(e.updatedAt).toLocaleString()]})]})]}),t(S.Ay,{items:[{label:"List Files",value:"files"},{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:i})]}):t(u.Text,{color:"red",children:"Media box not found"}),F=({files:e,loading:l,onSelect:r,box:i})=>{if(l)return t(D,{text:"Loading media files..."});if(!e?.length)return t(u.Text,{color:"yellow",children:"No media files found"});var o=[...e.map(e=>{var l;return{label:`${"Image"===(l=e.fileType)?"\uD83D\uDDBC":"Video"===l?"\uD83C\uDF9E":"Audio"===l?"\uD83C\uDFB5":"\uD83D\uDCC4"} ${e.name||"Unnamed"}`,value:e.id,file:e}}),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,marginBottom:1,children:["Media Files (",e.length,")",i?.name?` - ${i.name}`:""]}),t(S.Ay,{items:o,onSelect:r})]})},j=({file:e,loading:l,error:r,onSelect:i})=>{if(l&&!e)return t(D,{text:"Loading media file..."});if(r)return n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",r]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(u.Text,{color:"red",children:"Media file not found"});var o=e.meta,a=(0,g.Gu)(e),c=(0,g.Gu)(e,{preferThumbnail:!0}),d=!!(c&&c!==a);return n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:e.name||"Unnamed"}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{color:"gray",children:["ID: ",e.id]}),n(u.Text,{color:"gray",children:["Box ID: ",e.boxId]}),n(u.Text,{color:"gray",children:["Type: ",e.fileType]}),e.userTags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.userTags.join(", ")]}),o?.originalWidth!=null&&o?.originalHeight!=null&&n(u.Text,{color:"gray",children:["Size: ",o.originalWidth,"x",o.originalHeight]}),o?.originalFileSize!=null&&n(u.Text,{color:"gray",children:["File: ",(Number(o.originalFileSize)/1024).toFixed(1)," KB"]}),a&&n(u.Text,{color:"gray",children:["Original URL: ",a]}),d&&n(u.Text,{color:"gray",children:["Thumbnail URL: ",c]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Timestamps"}),e.createdAt&&n(u.Text,{color:"gray",children:[" Created: ",new Date(e.createdAt).toLocaleString()]}),e.updatedAt&&n(u.Text,{color:"gray",children:[" Modified: ",new Date(e.updatedAt).toLocaleString()]})]})]}),t(S.Ay,{items:[{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:i})]})},H=i(92642),Y=(e,l)=>{if(!e)return"";var r="string"==typeof e?e:JSON.stringify(e);return r.length>l?r.slice(0,l-1)+"…":r},z=({onBack:e})=>{var l=s((0,d.useState)([]),2),r=l[0],i=l[1],o=s((0,d.useState)(!0),2),a=o[0],h=o[1],g=s((0,d.useState)(null),2),m=g[0],T=g[1];return(0,d.useEffect)(()=>{var e,l=(0,x.getCurrentProfile)(),r=(0,x.getToken)(l),t=(0,x.getActivityLogBaseUrl)();if(!r){T("Not logged in. Run `bricks auth login` first."),h(!1);return}if(!t){T("Activity log URL not configured."),h(!1);return}var n=(0,H.W)(t,r),o=new Date(Date.now()-36e5).toISOString(),a=new Date().toISOString(),d=new AbortController;return(e=c(function*(){try{var e=yield n.collectEvents({start_time:o,end_time:a},{limit:50,signal:d.signal});i(e)}catch(e){"AbortError"!==e.name&&T(e.message)}h(!1)}),function(){return e.apply(this,arguments)})(),()=>d.abort()},[]),n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,marginBottom:1,children:"Activity Log (last 1h)"}),a&&t(D,{text:"Fetching events..."}),m&&n(u.Text,{color:"red",children:["Error: ",m]}),!a&&!m&&0===r.length&&t(u.Text,{color:"yellow",children:"No events found in the last hour"}),!a&&r.length>0&&n(u.Box,{flexDirection:"column",marginBottom:1,children:[n(u.Text,{color:"gray",children:["Timestamp".padEnd(22)," ","Type".padEnd(12)," ","Device".padEnd(14)," ","Event Name".padEnd(24)," Sender"]}),r.map((e,l)=>n(u.Text,{children:[new Date(e.timestamp).toISOString().replace("T"," ").replace(/\.\d+Z$/,"Z").padEnd(22)," ",Y(e.event_type||"",12).padEnd(12)," ",Y(e.device_id||"",14).padEnd(14)," ",Y(e.event_name||"",24).padEnd(24)," ",Y(e.sender||"",16)]},l)),r.length>=50&&n(u.Text,{color:"yellow",children:["Showing first ",50," events"]})]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:l=>"back"===l.value&&e()})]})},X=i(29253),J=i(44618),W=["B","C","G","D"],q=({instanceType:e,instance:l,client:r,onDone:i,onCancel:o})=>{var a,h=(0,u.useApp)().exit,x=s((0,d.useState)("select_ref"),2),g=x[0],m=x[1],T=s((0,d.useState)(""),2),p=T[0],f=T[1],v=s((0,d.useState)("search"),2),_=v[0],y=v[1],b=s((0,d.useState)(null),2),E=b[0],I=b[1],A=s((0,d.useState)(null),2),B=A[0],C=A[1],L=s((0,d.useState)(""),2),k=L[0],w=L[1],O=s((0,d.useState)(""),2),M=O[0],P=O[1],R=s((0,d.useState)(null),2),N=R[0],U=R[1],G=l?.short_edit?.ref_map||{},$=Object.entries(G).filter(([,e])=>e&&!e.hide),V=(0,J.V)(G,{keyword:p,types:W}),F=V.flatMap(e=>[{label:e.label,value:`__header_${e.prefix}__`,isHeader:!0},...e.refs.map(({shortId:e,ref:l})=>({label:`${l.title||e} (${e})`,value:e,ref:l}))]),j=[...p?[{label:"↻ Clear Search",value:"__clear_search__"}]:[],{label:"← Back",value:"__back__"}],H=F.length>0?[...F,...j]:j,Y=H.findIndex(e=>!e.isHeader&&!e.value?.startsWith("__"));(0,u.useInput)((e,l)=>{l.tab&&"select_ref"===g?y(e=>"search"===e?"list":"search"):(l.escape&&("select_ref"===g&&o(),"input_path"===g&&m("select_ref"),"input_content"===g&&m("input_path"),"confirm"===g&&m("input_content"),"done"===g&&o()),"q"===e&&"input_path"!==g&&"input_content"!==g&&("select_ref"!==g||"search"!==_)&&h())},{isActive:!0});var z=(a=c(function*(){if(r&&l?._id&&E){m("submitting"),U(null);try{var t={shortId:E,path:k.trim(),content:(e=>{var l=e.trim();if(""===l)return null;try{return JSON.parse(l)}catch{return l}})(M),forwardDataLink:!0};B?.inner_ref?.pid&&(t.innerRefParentShortId=B.inner_ref.pid),"application"===e?yield r.shortEditApplication({id:l._id,list:[t]}):yield r.shortEditModule({id:l._id,list:[t]}),yield i(),m("done")}catch(e){U(e.message),m("confirm")}}}),function(){return a.apply(this,arguments)});return l?.short_edit?.enabled?0===$.length?n(u.Box,{flexDirection:"column",children:[t(u.Text,{color:"yellow",children:"No Short Edit references found."}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]}):"select_ref"===g?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,children:"Short Edit References"}),t(u.Text,{color:"gray",dimColor:!0,children:"Showing: Brick, Canvas, Generator, Data"}),n(u.Box,{marginTop:1,flexDirection:"column",children:[t(u.Text,{color:"gray",children:"Search (title or shortId)"}),t(X.A,{value:p,placeholder:"type to filter, Enter to focus list",onChange:e=>f(e),onSubmit:()=>y("list"),focus:"search"===_}),t(u.Text,{color:"gray",dimColor:!0,children:"Press Tab to switch focus"})]}),n(u.Box,{marginTop:1,children:[0===V.length&&t(u.Text,{color:"yellow",children:"No references match your search."}),t(S.Ay,{items:H,isFocused:"list"===_,initialIndex:Y>-1?Y:0,indicatorComponent:()=>null,itemComponent:({label:e,isSelected:l,isHeader:r})=>r?t(u.Box,{marginTop:1,children:t(u.Text,{bold:!0,color:"white",children:e})}):n(u.Text,{color:l?"blue":void 0,children:[l?"❯":" "," ",e]}),onSelect:e=>{if("__back__"===e.value)return void o();if("__clear_search__"===e.value){f(""),y("search");return}e.isHeader||(I(e.value),C(e.ref),m("input_path"))}})]})]}):"input_path"===g?n(u.Box,{flexDirection:"column",children:[n(u.Text,{children:["Reference:"," ",n(u.Text,{color:"cyan",children:[B?.title||E," (",E,")"]})]}),t(u.Text,{marginTop:1,children:"Enter property path (e.g. title, property.backgroundColor)"}),N&&n(u.Text,{color:"red",children:["Error: ",N]}),t(X.A,{value:k,placeholder:"path",onChange:e=>{w(e),N&&U(null)},onSubmit:e=>{var l=e.trim();l?(w(l),m("input_content")):U("Path is required")},focus:!0})]}):"input_content"===g?n(u.Box,{flexDirection:"column",children:[n(u.Text,{children:["Path: ",t(u.Text,{color:"cyan",children:k})]}),t(u.Text,{marginTop:1,children:"Enter new content (JSON or plain text). Empty to clear."}),N&&n(u.Text,{color:"red",children:["Error: ",N]}),t(X.A,{value:M,placeholder:"content",onChange:e=>{P(e),N&&U(null)},onSubmit:()=>m("confirm"),focus:!0})]}):"submitting"===g?t(D,{text:"Applying short edit..."}):"done"===g?n(u.Box,{flexDirection:"column",children:[t(u.Text,{color:"green",children:"Short edit applied successfully."}),t(S.Ay,{items:[{label:"Edit another property",value:"again"},{label:"← Back",value:"back"}],onSelect:e=>{"again"===e.value?(m("select_ref"),I(null),C(null),w(""),P(""),U(null)):o()}})]}):n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,marginBottom:1,children:"Confirm Short Edit"}),n(u.Text,{children:["Reference:"," ",n(u.Text,{color:"cyan",children:[B?.title||E," (",E,")"]})]}),n(u.Text,{children:["Path: ",t(u.Text,{color:"cyan",children:k})]}),n(u.Text,{children:["Content: ",t(u.Text,{color:"cyan",children:M||"<empty>"})]}),N&&n(u.Text,{color:"red",children:["Error: ",N]}),t(S.Ay,{items:[{label:"Apply",value:"apply"},{label:"Edit Path",value:"edit_path"},{label:"Edit Content",value:"edit_content"},{label:"← Back",value:"back"}],onSelect:e=>{"apply"===e.value&&z(),"edit_path"===e.value&&m("input_path"),"edit_content"===e.value&&m("input_content"),"back"===e.value&&o()}})]}):n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"yellow",children:["Short Edit is not enabled for this ",e,"."]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]})},K=i(16928),Z=i(79896),Q=i(35317),ee=i(10750),el="options",er="output_dir",et="confirm",en="generating",ei="post_install",eo="done",ea=e=>{try{return(0,Q.execSync)(`which ${e}`,{stdio:"ignore"}),!0}catch{return!1}},ec=(e,l,r)=>new Promise((t,n)=>{var i=[e,...l].join(" "),o=(0,Q.spawn)(i,[],{cwd:r,stdio:"pipe",shell:!0});o.on("close",e=>{0===e?t():n(Error(`Command failed with code ${e}`))}),o.on("error",n)}),ed=(o=c(function*(e,l){try{var r=(yield i.e(456).then(i.bind(i,79491))).format;return(yield r(l,e,{trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100})).code}catch{}return e}),function(e,l){return o.apply(this,arguments)}),eu=({type:e,instance:l,client:r,onDone:i,onCancel:o})=>{var a,h=(0,u.useApp)().exit,x=s((0,d.useState)(el),2),g=x[0],m=x[1],T=s((0,d.useState)({setupGitHubActions:!0,setupAgents:!0,setupClaudeCode:!0,setupGeminiCLI:!1,runBunInstall:!0,initGit:!0}),2),p=T[0],v=T[1],_=s((0,d.useState)(process.cwd()),2),y=_[0],b=_[1],D=s((0,d.useState)(""),2),E=D[0],I=D[1],A=s((0,d.useState)(null),2),B=A[0],C=A[1],L=s((0,d.useState)(null),2),k=L[0],w=L[1],O=ee(l?.name||"bricks-ctor"),M=K.resolve(y,O),P=(0,d.useCallback)(e=>{"back"===e.value?o():"continue"===e.value?m(er):v(l=>({...l,[e.value]:!l[e.value]}))},[o]),R=(0,d.useCallback)(()=>{Z.existsSync(M)?C(`Directory already exists: ${M}`):(C(null),m(et))},[M]),N=(0,d.useCallback)((a=c(function*(t){if("back"===t.value)return void m(er);if("cancel"===t.value)return void o();if("confirm"===t.value){m(en);try{I("Fetching project from BRICKS...");var n,i="application"===e,a=i?r.queries.applicationProject:r.queries.moduleProject,d=(yield r.query(a,{id:l._id,buildApplicationOnly:!1,setupGitHubActions:p.setupGitHubActions,setupAgents:p.setupAgents,setupClaudeCode:p.setupClaudeCode,setupGeminiCLI:p.setupGeminiCLI}))[i?"UNSTABLE_applicationProject":"UNSTABLE_moduleProject"];if(!d?.files)throw Error("Failed to fetch project files");I("Creating project directory..."),Z.mkdirSync(M,{recursive:!0}),I(`Writing ${d.files.length} files...`),(yield Promise.all(d.files.map((n=c(function*(e){var l=K.join(M,e.name),r=e.input;return e.formatable&&(r=yield ed(r,l)),{...e,filePath:l,content:r}}),function(e){return n.apply(this,arguments)})))).forEach(e=>{var l=K.dirname(e.filePath);Z.existsSync(l)||Z.mkdirSync(l,{recursive:!0}),Z.writeFileSync(e.filePath,e.content)}),m(ei);var u={path:M,files:d.files.length,bunInstalled:!1,gitInitialized:!1};if(p.runBunInstall&&ea("bun")){I("Installing dependencies (bun install)...");try{yield ec("bun",["install"],M),u.bunInstalled=!0}catch{}}if(p.initGit&&ea("git")){I("Initializing git repository...");try{yield ec("git",["init"],M),yield ec("git",["add","."],M),yield ec("git",["-c 'user.name=BRICKS CLI'","-c 'user.email=cli@bricks.tools'","commit","-m 'chore: initialize commit'"],M),u.gitInitialized=!0}catch{}}w(u),m(eo)}catch(e){C(e.message),m(el)}}}),function(e){return a.apply(this,arguments)}),[r,l,e,p,M,o]),U=(0,d.useCallback)(e=>{"exit"===e.value?h():i()},[h,i]);if(g===el){var G=[{label:`${p.setupGitHubActions?"[x]":"[ ]"} GitHub Actions workflow`,value:"setupGitHubActions"},{label:`${p.setupAgents?"[x]":"[ ]"} AGENTS.md`,value:"setupAgents"},{label:`${p.setupClaudeCode?"[x]":"[ ]"} CLAUDE.md`,value:"setupClaudeCode"},{label:`${p.setupGeminiCLI?"[x]":"[ ]"} GEMINI.md`,value:"setupGeminiCLI"},{label:`${p.runBunInstall?"[x]":"[ ]"} Run bun install after generation`,value:"runBunInstall"},{label:`${p.initGit?"[x]":"[ ]"} Initialize git repository`,value:"initGit"},{label:"→ Continue",value:"continue"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,color:"cyan",children:["Initialize BRICKS Project: ",l?.name||"Untitled"]}),t(u.Text,{color:"gray",marginBottom:1,children:"Select options for project generation (press Enter to toggle)"}),B&&n(u.Text,{color:"red",marginBottom:1,children:["Error: ",B]}),t(S.Ay,{items:G,onSelect:P})]})}return g===er?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:"Output Directory"}),t(u.Text,{color:"gray",marginBottom:1,children:"Enter the parent directory for the project:"}),B&&t(u.Text,{color:"red",marginBottom:1,children:B}),n(u.Box,{children:[t(u.Text,{children:"Directory: "}),t(X.A,{value:y,onChange:b,onSubmit:R})]}),n(u.Text,{color:"gray",marginTop:1,children:["Project will be created at: ",M]})]}):g===et?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:"Confirm Project Generation"}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{children:["Name: ",t(u.Text,{color:"green",children:l?.name||"Untitled"})]}),n(u.Text,{children:["Type: ",t(u.Text,{color:"yellow",children:e})]}),n(u.Text,{children:["Path: ",t(u.Text,{color:"cyan",children:M})]}),t(u.Text,{color:"gray",marginTop:1,children:"Options:"}),n(u.Text,{color:"gray",children:[" - GitHub Actions: ",p.setupGitHubActions?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - AGENTS.md: ",p.setupAgents?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - CLAUDE.md: ",p.setupClaudeCode?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - GEMINI.md: ",p.setupGeminiCLI?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - Run bun install: ",p.runBunInstall?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - Initialize git: ",p.initGit?"Yes":"No"]})]}),t(S.Ay,{items:[{label:"Confirm & Generate",value:"confirm"},{label:"← Change Directory",value:"back"},{label:"Cancel",value:"cancel"}],onSelect:N})]}):g===en||g===ei?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:"Generating Project..."}),n(u.Box,{marginY:1,children:[t(u.Text,{color:"green",children:t(f.A,{type:"dots"})}),n(u.Text,{children:[" ",E]})]})]}):g===eo&&k?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"green",children:"Project initialized successfully!"}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{children:["Path: ",t(u.Text,{color:"cyan",children:k.path})]}),n(u.Text,{children:["Files: ",t(u.Text,{color:"green",children:k.files})]}),n(u.Text,{children:["Dependencies:"," ",t(u.Text,{color:k.bunInstalled?"green":"yellow",children:k.bunInstalled?"Installed":"Not installed (run bun install manually)"})]}),n(u.Text,{children:["Git:"," ",t(u.Text,{color:k.gitInitialized?"green":"yellow",children:k.gitInitialized?"Initialized":"Not initialized"})]})]}),t(u.Text,{bold:!0,marginY:1,children:"Next steps:"}),n(u.Text,{color:"gray",children:[" cd ",O]}),!k.bunInstalled&&t(u.Text,{color:"gray",children:" bun install"}),t(u.Text,{color:"gray",children:" bun preview"}),n(u.Text,{color:"gray",marginTop:1,children:["For more information, see ",O,"/README.md"]}),t(u.Box,{marginTop:1,children:t(S.Ay,{items:[{label:"← Back to Detail",value:"back"},{label:"Exit CLI",value:"exit"}],onSelect:U})})]}):null};let es=()=>{var e,l,r,i,o,a,T,p,f=(0,u.useApp)().exit,_=s((0,d.useState)(m.MAIN),2),E=_[0],S=_[1],A=s((0,d.useState)(null),2),B=A[0],U=A[1],H=s((0,d.useState)(null),2),Y=H[0],X=H[1],J=s((0,d.useState)(!0),2),W=J[0],K=J[1],Z=s((0,d.useState)(null),2),Q=Z[0],ee=Z[1],el=s((0,d.useState)([]),2),er=el[0],et=el[1],en=s((0,d.useState)(null),2),ei=en[0],eo=en[1],ea=s((0,d.useState)([]),2),ec=ea[0],ed=ea[1],es=s((0,d.useState)(null),2),eh=es[0],ex=es[1],eg=s((0,d.useState)([]),2),em=eg[0],eT=eg[1],ep=s((0,d.useState)(null),2),ef=ep[0],ev=ep[1],e_=s((0,d.useState)([]),2),ey=e_[0],eb=e_[1],eD=s((0,d.useState)(null),2),eE=eD[0],eS=eD[1],eI=s((0,d.useState)([]),2),eA=eI[0],eB=eI[1],eC=s((0,d.useState)(!1),2),eL=eC[0],ek=eC[1],ew=s((0,d.useState)(null),2),eO=ew[0],eM=ew[1],eP=s((0,d.useState)(null),2),eR=eP[0],eN=eP[1],eU=s((0,d.useState)(null),2),eG=eU[0],e$=eU[1],eV=s((0,d.useState)(null),2),eF=eV[0],ej=eV[1],eH=s((0,d.useState)([]),2),eY=eH[0],ez=eH[1],eX=s((0,d.useState)(null),2),eJ=eX[0],eW=eX[1],eq=s((0,d.useState)([]),2),eK=eq[0],eZ=eq[1],eQ=s((0,d.useState)(null),2),e0=eQ[0],e1=eQ[1],e2=E===m.DEVICES,e4=E===m.DEVICE_DETAIL,e6=E===m.GROUPS,e5=E===m.GROUP_DETAIL;(0,d.useEffect)(()=>{var e=(0,x.getCurrentProfile)(),l=(0,x.getToken)(e);if(!l){ee("Not logged in. Run `bricks auth login` first."),K(!1);return}var r=(0,h.createClient)((0,x.getBaseUrl)(),l);U(r),r.workspace().then(e=>{X(e),K(!1)}).catch(e=>{ee(e.message),K(!1)})},[]),(0,u.useInput)((e,l)=>{"q"===e&&f(),l.escape&&(E===m.DEVICE_CONTROL?(S(m.DEVICE_DETAIL),eM(null)):E===m.DEVICE_SCREENSHOT?(S(m.DEVICE_DETAIL),e$(null),ej(null)):E===m.DEVICE_DETAIL?(S(m.DEVICES),eo(null)):E===m.APP_DETAIL?(S(m.APPS),ex(null)):E===m.MODULE_DETAIL?(S(m.MODULES),ev(null)):E===m.GROUP_DETAIL?(S(m.GROUPS),eS(null),eB([])):E===m.MEDIA_FILE_DETAIL?(S(m.MEDIA_FILES),e1(null)):E===m.MEDIA_FILES?(S(m.MEDIA_BOX_DETAIL),e1(null)):E===m.MEDIA_BOX_DETAIL?(S(m.MEDIA_BOXES),eW(null),eZ([])):E===m.MEDIA_BOXES?S(m.MAIN):E!==m.MAIN&&S(m.MAIN))},{isActive:E!==m.APP_SHORT_EDIT&&E!==m.MODULE_SHORT_EDIT&&E!==m.APP_PROJECT_INIT&&E!==m.MODULE_PROJECT_INIT});var e9=(0,d.useCallback)(c(function*(){if(B){K(!0);try{var e=yield B.devices({});et(e||[])}catch(e){ee(e.message)}K(!1)}}),[B]),e8=(0,d.useCallback)((e=c(function*(e){if(B){K(!0),eN(null);try{var l=yield B.device({id:e});eo(l)}catch(e){eN(e.message)}K(!1)}}),function(l){return e.apply(this,arguments)}),[B]),e3=(0,d.useCallback)(c(function*(){if(B){K(!0);try{var e=yield B.applications({});ed(e||[])}catch(e){ee(e.message)}K(!1)}}),[B]),e7=(0,d.useCallback)((l=c(function*(e){if(B){K(!0),eN(null);try{var l=yield B.application({id:e});ex(l)}catch(e){eN(e.message)}K(!1)}}),function(e){return l.apply(this,arguments)}),[B]),le=(0,d.useCallback)(c(function*(){if(B){K(!0);try{var e=yield B.modules({});eT(e||[])}catch(e){ee(e.message)}K(!1)}}),[B]),ll=(0,d.useCallback)((r=c(function*(e){if(B){K(!0),eN(null);try{var l=yield B.module({id:e});ev(l)}catch(e){eN(e.message)}K(!1)}}),function(e){return r.apply(this,arguments)}),[B]),lr=(0,d.useCallback)(c(function*(){if(B){K(!0);try{var e=yield B.deviceGroups({});eb(e||[])}catch(e){ee(e.message)}K(!1)}}),[B]),lt=(0,d.useCallback)((i=c(function*(e){if(B){K(!0),eN(null);try{var l=yield Promise.all([B.deviceGroup({id:e}),B.devicesByGroup({id:e})]),r=s(l,2),t=r[0],n=r[1];eS(t),eB(n||[])}catch(e){eN(e.message)}K(!1)}}),function(e){return i.apply(this,arguments)}),[B]),ln=(0,d.useCallback)(c(function*(){if(B){K(!0);try{var e=yield B.mediaBoxes();ez(e||[])}catch(e){ee(e.message)}K(!1)}}),[B]),li=(0,d.useCallback)((o=c(function*(e){if(B){K(!0),eN(null);try{var l=yield B.mediaBox({id:e});eW(l)}catch(e){eN(e.message)}K(!1)}}),function(e){return o.apply(this,arguments)}),[B]),lo=(0,d.useCallback)((a=c(function*(e){if(B){K(!0);try{var l=yield B.mediaFiles({boxId:e});eZ(l||[])}catch(e){ee(e.message)}K(!1)}}),function(e){return a.apply(this,arguments)}),[B]),la=(0,d.useCallback)((T=c(function*(e){if(B){K(!0),eN(null);try{var l=yield B.mediaFile({id:e});e1(l)}catch(e){eN(e.message)}K(!1)}}),function(e){return T.apply(this,arguments)}),[B]),lc=(0,d.useCallback)((p=c(function*(e){if(B&&ei){ek(!0),eM(null);try{yield B.controlDevice({id:ei._id,type:e}),eM({success:!0,message:`Command sent: ${e}`})}catch(e){eM({success:!1,message:e.message})}ek(!1)}}),function(e){return p.apply(this,arguments)}),[B,ei]),ld=(0,d.useCallback)(c(function*(e=!1){if(B&&ei&&Y){K(!0),ej(null),e$(null);try{e&&(yield B.controlDevice({id:ei._id,type:"take-screenshot"}),yield new Promise(e=>setTimeout(e,3e3)));var l=yield(0,g.he)(B,Y,ei._id,null,{preferThumbnail:!0});l.error?ej(l.error):e$(l)}catch(e){ej(e.message)}K(!1)}}),[B,ei,Y]),lu=v((0,d.useCallback)(()=>{B&&e9()},[B,e9]),e2),ls=v((0,d.useCallback)(()=>{B&&ei&&e8(ei._id)},[B,ei,e8]),e4),lh=v((0,d.useCallback)(()=>{B&&lr()},[B,lr]),e6),lx=v((0,d.useCallback)(()=>{B&&eE&<(eE._id)},[B,eE,lt]),e5);return W&&!Y?n(u.Box,{flexDirection:"column",children:[t(y,{workspace:Y,view:E}),t(D,{text:"Connecting to workspace..."})]}):Q&&!Y?n(u.Box,{flexDirection:"column",children:[t(y,{workspace:Y,view:E}),n(u.Text,{color:"red",children:["Error: ",Q]}),t(b,{})]}):n(u.Box,{flexDirection:"column",children:[t(y,{workspace:Y,view:E}),E===m.MAIN&&t(I,{onSelect:e=>{"exit"===e.value?f():(S(e.value),e.value===m.DEVICES?e9():e.value===m.APPS?e3():e.value===m.MODULES?le():e.value===m.GROUPS?lr():e.value===m.MEDIA_BOXES&&ln())},mediaEnabled:(0,g.wR)(Y),activityLogEnabled:!!(0,x.getActivityLogBaseUrl)()}),E===m.DEVICES&&t(C,{devices:er,loading:W,onSelect:e=>{if("back"===e.value)return void S(m.MAIN);if("refresh"===e.value){e9(),lu.resetCountdown();return}eo(null),K(!0),S(m.DEVICE_DETAIL),e8(e.value)},countdown:lu.countdown,lastRefreshTime:lu.lastRefreshTime}),E===m.DEVICE_DETAIL&&t(L,{device:ei,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.DEVICES),eo(null);return}if("refresh"===e.value){e8(ei._id),ls.resetCountdown();return}"control"===e.value&&(S(m.DEVICE_CONTROL),eM(null)),"screenshot"===e.value&&(S(m.DEVICE_SCREENSHOT),e$(null),ej(null),ld(!1))},mediaEnabled:(0,g.wR)(Y),countdown:ls.countdown,lastRefreshTime:ls.lastRefreshTime}),E===m.DEVICE_CONTROL&&t(k,{device:ei,onSelect:e=>{if("back"===e.value){S(m.DEVICE_DETAIL),eM(null);return}lc(e.value)},controlling:eL,controlResult:eO}),E===m.DEVICE_SCREENSHOT&&t(w,{device:ei,screenshot:eG,loading:W,error:eF,onSelect:e=>{if("back"===e.value){S(m.DEVICE_DETAIL),e$(null),ej(null);return}"refresh"===e.value?ld(!1):"take"===e.value&&ld(!0)}}),E===m.APPS&&t(O,{apps:ec,loading:W,onSelect:e=>{"back"===e.value?S(m.MAIN):"refresh"===e.value?e3():(ex(null),K(!0),S(m.APP_DETAIL),e7(e.value))}}),E===m.APP_DETAIL&&t(M,{app:eh,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.APPS),ex(null);return}"refresh"===e.value?e7(eh._id):("short_edit"===e.value&&(S(m.APP_SHORT_EDIT),eN(null)),"project_init"===e.value&&(S(m.APP_PROJECT_INIT),eN(null)))}}),E===m.APP_SHORT_EDIT&&t(q,{instanceType:"application",instance:eh,client:B,onDone:c(function*(){return e7(eh._id)}),onCancel:()=>S(m.APP_DETAIL)}),E===m.APP_PROJECT_INIT&&t(eu,{type:"application",instance:eh,client:B,onDone:()=>S(m.APP_DETAIL),onCancel:()=>S(m.APP_DETAIL)}),E===m.MODULES&&t(P,{modules:em,loading:W,onSelect:e=>{"back"===e.value?S(m.MAIN):"refresh"===e.value?le():(ev(null),K(!0),S(m.MODULE_DETAIL),ll(e.value))}}),E===m.MODULE_DETAIL&&t(R,{module:ef,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.MODULES),ev(null);return}"refresh"===e.value?ll(ef._id):("short_edit"===e.value&&(S(m.MODULE_SHORT_EDIT),eN(null)),"project_init"===e.value&&(S(m.MODULE_PROJECT_INIT),eN(null)))}}),E===m.MODULE_SHORT_EDIT&&t(q,{instanceType:"module",instance:ef,client:B,onDone:c(function*(){return ll(ef._id)}),onCancel:()=>S(m.MODULE_DETAIL)}),E===m.MODULE_PROJECT_INIT&&t(eu,{type:"module",instance:ef,client:B,onDone:()=>S(m.MODULE_DETAIL),onCancel:()=>S(m.MODULE_DETAIL)}),E===m.GROUPS&&t(N,{groups:ey,loading:W,onSelect:e=>{if("back"===e.value)return void S(m.MAIN);if("refresh"===e.value){lr(),lh.resetCountdown();return}eS(null),eB([]),K(!0),S(m.GROUP_DETAIL),lt(e.value)},countdown:lh.countdown,lastRefreshTime:lh.lastRefreshTime}),E===m.GROUP_DETAIL&&t(G,{group:eE,groupDevices:eA,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.GROUPS),eS(null),eB([]);return}"refresh"===e.value&&(lt(eE._id),lx.resetCountdown())},countdown:lx.countdown,lastRefreshTime:lx.lastRefreshTime}),E===m.ACTIVITY_LOG&&t(z,{onBack:()=>S(m.MAIN)}),E===m.MEDIA_BOXES&&t($,{boxes:eY,loading:W,onSelect:e=>{"back"===e.value?S(m.MAIN):"refresh"===e.value?ln():(eW(null),eZ([]),K(!0),S(m.MEDIA_BOX_DETAIL),li(e.value))}}),E===m.MEDIA_BOX_DETAIL&&t(V,{box:eJ,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.MEDIA_BOXES),eW(null),eZ([]);return}"refresh"===e.value?li(eJ.id):"files"===e.value&&(eZ([]),e1(null),S(m.MEDIA_FILES),lo(eJ.id))}}),E===m.MEDIA_FILES&&t(F,{files:eK,box:eJ,loading:W,onSelect:e=>{if("back"===e.value){S(m.MEDIA_BOX_DETAIL),e1(null);return}"refresh"===e.value?lo(eJ.id):(e1(null),K(!0),S(m.MEDIA_FILE_DETAIL),la(e.value))}}),E===m.MEDIA_FILE_DETAIL&&t(j,{file:e0,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.MEDIA_FILES),e1(null);return}"refresh"===e.value&&la(e0.id)}}),t(b,{})]})};var eh="1"===process.env.BRICKS_CLI_DISTRIBUTION,ex=(a=c(function*(){if(eh)return void(0,u.render)(t(es,{}));var e=(yield i.e(166).then(i.bind(i,29557))).TerminalInfoProvider;(0,u.render)(t(e,{children:t(es,{})}))}),function(){return a.apply(this,arguments)})}};
|