@fugood/bricks-cli 2.25.0-beta.50 → 2.25.0-beta.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/117.js CHANGED
@@ -234,6 +234,7 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
234
234
  lock {
235
235
  enabled
236
236
  }
237
+ enable_web_lan_discovery
237
238
  env {
238
239
  variables
239
240
  virtual_dev_url_query {
@@ -1117,6 +1118,7 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
1117
1118
  $preload: PreloadInput
1118
1119
  $applicationUpdate: ApplicationUpdateInput
1119
1120
  $lock: DeviceLockInput
1121
+ $enableWebLanDiscovery: Boolean
1120
1122
  $env: DeviceEnvInput
1121
1123
  $accessControl: DeviceAccessControlInput
1122
1124
  $forceNotifyDevice: Boolean
@@ -1133,6 +1135,7 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
1133
1135
  preload: $preload
1134
1136
  applicationUpdate: $applicationUpdate
1135
1137
  lock: $lock
1138
+ enableWebLanDiscovery: $enableWebLanDiscovery
1136
1139
  env: $env
1137
1140
  accessControl: $accessControl
1138
1141
  forceNotifyDevice: $forceNotifyDevice
@@ -2469,7 +2472,7 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
2469
2472
  timestamp
2470
2473
  }
2471
2474
  }
2472
- `,tK=z(function e(i,t){H(this,e),this.baseUrl=i,this.token=t,this.graphqlUrl=`${i}/api/graphql`},[{key:"graphql",value:(o=$(function*(e,i){var t=yield(0,x.Ay)(this.graphqlUrl,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`,Accept:"application/json"},body:JSON.stringify({query:e,variables:i})});if(!t.ok){var n=yield t.text().catch(()=>"");throw Error(`Activity-log query failed (${t.status}): ${n}`)}var a=yield t.json();if(a.errors?.length)throw Error(a.errors.map(e=>e.message).join("\n"));return a.data}),function(e,i){return o.apply(this,arguments)})},{key:"events",value:(r=$(function*(e,{limit:i,offset:t}={}){var n={...e};return null!=i&&(n.limit=i),null!=t&&(n.offset=t),(yield this.graphql(tj,{filter:n})).events}),function(e){return r.apply(this,arguments)})},{key:"screenshots",value:(s=$(function*(e){return(yield this.graphql(tV,{filter:e})).screenshots}),function(e){return s.apply(this,arguments)})},{key:"downloadScreenshot",value:(d=$(function*(e,i,t){var n=`${this.baseUrl}/api/v1/${encodeURIComponent(e)}/${encodeURIComponent(i)}/screenshot?ts=${encodeURIComponent(t)}`,a=yield(0,x.Ay)(n,{headers:{Authorization:`Bearer ${this.token}`}});if(!a.ok){var o=yield a.text().catch(()=>"");throw Error(`Screenshot fetch failed (${a.status}): ${o}`)}return Buffer.from((yield a.arrayBuffer()))}),function(e,i,t){return d.apply(this,arguments)})}]);process.env.STAGE,process.env.URL_BASE;var tY="bricks-mcp",tG={bricks:process.env.BRICKS_API_SERVER||"https://display-beta.bricks.tools",media:process.env.MEDIA_API_SERVER||"https://media-beta.bricks.tools",activityLog:process.env.ACTIVITY_LOG_API_SERVER||"https://activity-log-beta.bricks.tools"};process.env.AUTH0_DOMAIN,process.env.CACHE_URL;var tL=t(1639);let tz=({type:e,title:i,template_key:t})=>{var n,a,o=(0,tL.M4)(e);switch(e){case"subspace":n={title:i,layout:{width:"number",height:"number"},root_canvas_id:"CANVAS_<UUID>",canvas_map:{},brick_map:{},animation_map:{},generator_map:{},property_bank_map:{},property_bank_calc_map:{}},a={"canvas_map.CANVAS_<UUID>.item_list":[{type:"subspace",subspace_id:"SUBSPACE_<UUID>",$note:"If not a root subspace, it can be linked to canvas in other subspace"}]};break;case"canvas":var r=j(W.Ji);n={title:i,item_list:[],property:{$definitions:Object.fromEntries(Object.entries(r.propTypes).map(([e,i])=>[e,{...i,description:r.brickPropDescriptions[e]}]))},event_map:{$definitions:Object.fromEntries(Object.entries(r.eventTypes).map(([e])=>[e,{description:r.brickEventDescriptions[e]}]))}},a={property_bank_map:{[(0,tL.M4)("property_bank")]:{title:`Canvas ID: ${i}`,type:"string",value:o,routing:"read-only",kind:"auto-generated-item-id",idType:"canvas"}}};break;case"brick":var s=j(W.dK.Basic),d=j(W.brickMapping[t]);if(!d)throw Error(`Brick ${t} not found`);var c={...d,propTypes:{...s.propTypes,...d.propTypes},brickPropDescriptions:{...s.brickPropDescriptions,...d.brickPropDescriptions},eventTypes:{...s.eventTypes,...d.eventTypes},brickEventDescriptions:{...s.brickEventDescriptions,...d.brickEventDescriptions}};n={title:i,template_key:t,property:{$definitions:Object.fromEntries(Object.entries(c.propTypes).map(([e,i])=>[e,{...i,description:c.brickPropDescriptions[e]}]))},event_map:{$definitions:Object.fromEntries(Object.entries(c.eventTypes).map(([e])=>[e,{description:c.brickEventDescriptions[e]}]))},outlet:{$definitions:Object.fromEntries(Object.entries(c.outletTypes).map(([e])=>[e,{description:c.brickOutletDescriptions[e]}]))},state_group:{"BRICK_STATE_GROUP_<UUID>":{}}},a={canvas_map:{"CANVAS_<UUID WHICH NEED DISPLAY THIS BRICK>":{item_list:[{type:"brick",brick_id:o,frame:{x:"number",y:"number",width:"number",height:"number",standby_mode:"custom|top|left|right|bottom",standby_delay:"number",standby_easing:{default:{method:"ease",duration:"number"}}}}]}}};break;case"state_group":n={title:i,description:"State Group Description",conds:[{type:"property_bank|inner_state",key:"PROPERTY_BANK#<Data Node ID>|[current_canvas|BRICK_<OUTLET NAME>]|",method:"==|!=|>|>=|<|<=",value:"value_to_compare"}],override:{property:!1,event:!1,outlet:!1},commented:!1,break:!1,property:{},outlet:{},animation:{}};break;case"generator":var l=j(W.generatorMapping[t]);if(!l)throw Error(`Generator ${t} not found`);n={title:i,template_key:t,property:{$definitions:Object.fromEntries(Object.entries(l.propTypes).map(([e,i])=>[e,{...i,description:l.brickPropDescriptions[e]}]))},event_map:{$definitions:Object.fromEntries(Object.entries(l.eventTypes).map(([e])=>[e,{description:l.brickEventDescriptions[e]}]))},outlet:{$definitions:Object.fromEntries(Object.entries(l.outletTypes).map(([e])=>[e,{description:l.brickOutletDescriptions[e]}]))}};break;case"animation":n={title:i,type:"timing|decay|spring",property:"opacity|transform.translateX|transform.scale|etc",config:{$note:"Config for the animation"},compose_type:"parallel|sequence",item_list:[{animation_id:"ANIMATION_<SUB ANIMATION UUID>"}]};break;case"property_bank":n={title:i,description:"Property Bank Description",linkedFrom:"SUBSPACE_<UUID WHICH IS CROSS SUBSPACE>",type:"string|number|bool|object|array|any",kind:"color|datetime|id|media-resource-*|lottie-file-uri",unit:"grid|px|ms",routing:"read-only|default",value:"fit-to-type",event_map:{$note:`Available events: ${Object.keys(W.qJ.eventTypes).join(", ")}`},local_sync:{update_mode:"all|main-only|minor-only|dont-sync"},$remote_update_additional:{$note:"Configure remote update behavior",enable_remote_update:!0,bank_type:"create|create-device-specific"}};break;case"property_bank_command":break;case"property_bank_calc":var p=(0,tL.M4)("property_bank_command"),u=(0,tL.M4)("property_bank_command"),m=(0,tL.M4)("property_bank_command"),_="const { arg_name } = inputs;\n\nreturn { arg_name };";n={title:i,map:{$note:"Required, actual implementation","PROPERTY_BANK_DATA_NODE_<UUID>":{type:"data-node",properties:{},in:{change:null},out:{value:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID>",port:"value"}]},$note:"Use this to input data to the sandbox"},"PROPERTY_BANK_COMMAND_NODE_<UUID FIRST>":{type:"command-node-object",title:"Command: OBJECT_SET",properties:{command:"OBJECT_SET",args:{path:"arg_name"}},in:{obj:null,path:null,value:[{id:"PROPERTY_BANK_DATA_NODE_<UUID>",port:"value"}]},out:{result:[{id:`PROPERTY_BANK_COMMAND_NODE_<UUID NEXT> | ${p}`,port:"obj | inputs"}]}},"PROPERTY_BANK_COMMAND_NODE_<UUID SECOND>":{type:"command-node-object",title:"Command: OBJECT_SET",properties:{command:"OBJECT_SET",args:{path:"arg_name"}},in:{obj:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID PREVIOUS>",port:"result"}],path:null,value:[{id:"PROPERTY_BANK_DATA_NODE_<UUID SECOND>",port:"value"}]},out:{result:[{id:`PROPERTY_BANK_COMMAND_NODE_<UUID NEXT> | ${p}`,port:"obj | inputs"}]}},[p]:{type:"command-node-sandbox",title:"Command: SANDBOX_RUN_JAVASCRIPT",properties:{command:"SANDBOX_RUN_JAVASCRIPT",args:{code:_,enable_async:!1}},in:{code:null,inputs:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID FINAL>",port:"result"}]},out:{result:[{id:m,port:"result"},{id:u,port:"result"}]}},[m]:{type:"command-node-sandbox",title:"Command: SANDBOX_GET_ERROR",properties:{command:"SANDBOX_GET_ERROR"},in:{result:[{id:p,port:"result"}]},out:{result:[{id:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE ERROR>",port:"change"}],$note:"Set `result` as null if there is no error"}},[u]:{type:"command-node-sandbox",title:"Command: SANDBOX_GET_RETURN_VALUE",properties:{command:"SANDBOX_GET_RETURN_VALUE"},in:{result:[{id:p,port:"result"}]},out:{result:[{id:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE RESULT> | PROPERTY_BANK_COMMAND_NODE_<UUID PARSE RESULT> | null",port:"change"}]}},"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE RESULT>":{type:"data-node",properties:{},in:{change:[{id:u,port:"result"}]},out:{value:null},$note:"Put full result into data node"},"PROPERTY_BANK_COMMAND_NODE_<UUID PARSE RESULT>":{type:"command-node-object",title:"Command: OBJECT_GET",properties:{command:"OBJECT_GET",args:{path:"obj_key"}},in:{obj:[{id:u,port:"obj"}]},out:{result:[{id:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE PARTIAL RESULT>",port:"change"}]},$note:"Parse result object into data node"},"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE PARTIAL RESULT>":{type:"data-node",properties:{},in:{change:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID PARSE RESULT>",port:"result"}]},out:{value:null},$note:"Put partial result into data node"}},editor_info:{},type:"script",script_config:{title:i,enable_async:!1,inputs:{"PROPERTY_BANK_DATA_NODE_<UUID>":"arg_name"},disabled_triggers:{},error:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE ERROR> | null",output:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE RESULT> | null",outputs:{obj_key:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE PARTIAL RESULT>"},code:_,$note:"Required, info for GUI editor"}}}return C({id:o,example:n,extraInfo:a})};var tH="2.25.0-beta.50";function tJ(){return tX.apply(this,arguments)}function tX(){return(tX=$(function*(e={}){var i,t=e.token||process.env.BRICKS_API_TOKEN;if(!t)throw console.error("Error: API token is required"),console.error("Please provide a token via options or set BRICKS_API_TOKEN environment variable"),Error("API token is required");var n=function(e){try{var i=e.queryStringParameters?.token;if(!i){var t=new Headers(e.headers);i=t.get("authorization")?.replace("Bearer ","")}if(!i)return{success:!1,message:"Authentication failed: No token provided"};var n=function(e){try{var i=e.split(".");if(i.length<3)return null;var t=JSON.parse(Buffer.from(i[0],"base64url").toString());if(!k.includes(t?.alg))return null;return JSON.parse(Buffer.from(i[1],"base64url").toString())}catch{return null}}(i);if(!n)return{success:!1,message:"Authentication failed: Invalid token"};var a=D.includes(n.iss)?"user":"workspace";if("workspace"===a){var o=Array.isArray(n.t)?n.t:[];n.permissions=o.reduce((e,i)=>{var t=I[i];return t&&e.push(t),e},[])}else n.permissions=Object.keys(b);return{success:!0,token:i,tokenInfo:n,tokenType:a}}catch(e){return{success:!1,message:`Authentication failed: ${e.message}`}}}({queryStringParameters:{token:t}});if(!n.success)throw console.error("Error: Invalid BRICKS_API_TOKEN"),console.error(n.message),Error("Invalid BRICKS_API_TOKEN");var a=new v._({name:tY,version:tH}),o={...n,client:function(e,i,t){switch(t){case"user":return new iB(e,i);case"workspace":return new i3(e,i);default:throw Error(`Invalid token type: ${t}.`)}}(tG.bricks,n.token,n.tokenType)};a.prompt("getting-started","Getting started with BRICKS",{},$(function*(){return{messages:[{role:"user",content:{type:"text",text:`Welcome to BRICKS — start here.
2475
+ `,tK=z(function e(i,t){H(this,e),this.baseUrl=i,this.token=t,this.graphqlUrl=`${i}/api/graphql`},[{key:"graphql",value:(o=$(function*(e,i){var t=yield(0,x.Ay)(this.graphqlUrl,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`,Accept:"application/json"},body:JSON.stringify({query:e,variables:i})});if(!t.ok){var n=yield t.text().catch(()=>"");throw Error(`Activity-log query failed (${t.status}): ${n}`)}var a=yield t.json();if(a.errors?.length)throw Error(a.errors.map(e=>e.message).join("\n"));return a.data}),function(e,i){return o.apply(this,arguments)})},{key:"events",value:(r=$(function*(e,{limit:i,offset:t}={}){var n={...e};return null!=i&&(n.limit=i),null!=t&&(n.offset=t),(yield this.graphql(tj,{filter:n})).events}),function(e){return r.apply(this,arguments)})},{key:"screenshots",value:(s=$(function*(e){return(yield this.graphql(tV,{filter:e})).screenshots}),function(e){return s.apply(this,arguments)})},{key:"downloadScreenshot",value:(d=$(function*(e,i,t){var n=`${this.baseUrl}/api/v1/${encodeURIComponent(e)}/${encodeURIComponent(i)}/screenshot?ts=${encodeURIComponent(t)}`,a=yield(0,x.Ay)(n,{headers:{Authorization:`Bearer ${this.token}`}});if(!a.ok){var o=yield a.text().catch(()=>"");throw Error(`Screenshot fetch failed (${a.status}): ${o}`)}return Buffer.from((yield a.arrayBuffer()))}),function(e,i,t){return d.apply(this,arguments)})}]);process.env.STAGE,process.env.URL_BASE;var tY="bricks-mcp",tG={bricks:process.env.BRICKS_API_SERVER||"https://display-beta.bricks.tools",media:process.env.MEDIA_API_SERVER||"https://media-beta.bricks.tools",activityLog:process.env.ACTIVITY_LOG_API_SERVER||"https://activity-log-beta.bricks.tools"};process.env.AUTH0_DOMAIN,process.env.CACHE_URL;var tL=t(1639);let tz=({type:e,title:i,template_key:t})=>{var n,a,o=(0,tL.M4)(e);switch(e){case"subspace":n={title:i,layout:{width:"number",height:"number"},root_canvas_id:"CANVAS_<UUID>",canvas_map:{},brick_map:{},animation_map:{},generator_map:{},property_bank_map:{},property_bank_calc_map:{}},a={"canvas_map.CANVAS_<UUID>.item_list":[{type:"subspace",subspace_id:"SUBSPACE_<UUID>",$note:"If not a root subspace, it can be linked to canvas in other subspace"}]};break;case"canvas":var r=j(W.Ji);n={title:i,item_list:[],property:{$definitions:Object.fromEntries(Object.entries(r.propTypes).map(([e,i])=>[e,{...i,description:r.brickPropDescriptions[e]}]))},event_map:{$definitions:Object.fromEntries(Object.entries(r.eventTypes).map(([e])=>[e,{description:r.brickEventDescriptions[e]}]))}},a={property_bank_map:{[(0,tL.M4)("property_bank")]:{title:`Canvas ID: ${i}`,type:"string",value:o,routing:"read-only",kind:"auto-generated-item-id",idType:"canvas"}}};break;case"brick":var s=j(W.dK.Basic),d=j(W.brickMapping[t]);if(!d)throw Error(`Brick ${t} not found`);var c={...d,propTypes:{...s.propTypes,...d.propTypes},brickPropDescriptions:{...s.brickPropDescriptions,...d.brickPropDescriptions},eventTypes:{...s.eventTypes,...d.eventTypes},brickEventDescriptions:{...s.brickEventDescriptions,...d.brickEventDescriptions}};n={title:i,template_key:t,property:{$definitions:Object.fromEntries(Object.entries(c.propTypes).map(([e,i])=>[e,{...i,description:c.brickPropDescriptions[e]}]))},event_map:{$definitions:Object.fromEntries(Object.entries(c.eventTypes).map(([e])=>[e,{description:c.brickEventDescriptions[e]}]))},outlet:{$definitions:Object.fromEntries(Object.entries(c.outletTypes).map(([e])=>[e,{description:c.brickOutletDescriptions[e]}]))},state_group:{"BRICK_STATE_GROUP_<UUID>":{}}},a={canvas_map:{"CANVAS_<UUID WHICH NEED DISPLAY THIS BRICK>":{item_list:[{type:"brick",brick_id:o,frame:{x:"number",y:"number",width:"number",height:"number",standby_mode:"custom|top|left|right|bottom",standby_delay:"number",standby_easing:{default:{method:"ease",duration:"number"}}}}]}}};break;case"state_group":n={title:i,description:"State Group Description",conds:[{type:"property_bank|inner_state",key:"PROPERTY_BANK#<Data Node ID>|[current_canvas|BRICK_<OUTLET NAME>]|",method:"==|!=|>|>=|<|<=",value:"value_to_compare"}],override:{property:!1,event:!1,outlet:!1},commented:!1,break:!1,property:{},outlet:{},animation:{}};break;case"generator":var l=j(W.generatorMapping[t]);if(!l)throw Error(`Generator ${t} not found`);n={title:i,template_key:t,property:{$definitions:Object.fromEntries(Object.entries(l.propTypes).map(([e,i])=>[e,{...i,description:l.brickPropDescriptions[e]}]))},event_map:{$definitions:Object.fromEntries(Object.entries(l.eventTypes).map(([e])=>[e,{description:l.brickEventDescriptions[e]}]))},outlet:{$definitions:Object.fromEntries(Object.entries(l.outletTypes).map(([e])=>[e,{description:l.brickOutletDescriptions[e]}]))}};break;case"animation":n={title:i,type:"timing|decay|spring",property:"opacity|transform.translateX|transform.scale|etc",config:{$note:"Config for the animation"},compose_type:"parallel|sequence",item_list:[{animation_id:"ANIMATION_<SUB ANIMATION UUID>"}]};break;case"property_bank":n={title:i,description:"Property Bank Description",linkedFrom:"SUBSPACE_<UUID WHICH IS CROSS SUBSPACE>",type:"string|number|bool|object|array|any",kind:"color|datetime|id|media-resource-*|lottie-file-uri",unit:"grid|px|ms",routing:"read-only|default",value:"fit-to-type",event_map:{$note:`Available events: ${Object.keys(W.qJ.eventTypes).join(", ")}`},local_sync:{update_mode:"all|main-only|minor-only|dont-sync"},$remote_update_additional:{$note:"Configure remote update behavior",enable_remote_update:!0,bank_type:"create|create-device-specific"}};break;case"property_bank_command":break;case"property_bank_calc":var p=(0,tL.M4)("property_bank_command"),u=(0,tL.M4)("property_bank_command"),m=(0,tL.M4)("property_bank_command"),_="const { arg_name } = inputs;\n\nreturn { arg_name };";n={title:i,map:{$note:"Required, actual implementation","PROPERTY_BANK_DATA_NODE_<UUID>":{type:"data-node",properties:{},in:{change:null},out:{value:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID>",port:"value"}]},$note:"Use this to input data to the sandbox"},"PROPERTY_BANK_COMMAND_NODE_<UUID FIRST>":{type:"command-node-object",title:"Command: OBJECT_SET",properties:{command:"OBJECT_SET",args:{path:"arg_name"}},in:{obj:null,path:null,value:[{id:"PROPERTY_BANK_DATA_NODE_<UUID>",port:"value"}]},out:{result:[{id:`PROPERTY_BANK_COMMAND_NODE_<UUID NEXT> | ${p}`,port:"obj | inputs"}]}},"PROPERTY_BANK_COMMAND_NODE_<UUID SECOND>":{type:"command-node-object",title:"Command: OBJECT_SET",properties:{command:"OBJECT_SET",args:{path:"arg_name"}},in:{obj:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID PREVIOUS>",port:"result"}],path:null,value:[{id:"PROPERTY_BANK_DATA_NODE_<UUID SECOND>",port:"value"}]},out:{result:[{id:`PROPERTY_BANK_COMMAND_NODE_<UUID NEXT> | ${p}`,port:"obj | inputs"}]}},[p]:{type:"command-node-sandbox",title:"Command: SANDBOX_RUN_JAVASCRIPT",properties:{command:"SANDBOX_RUN_JAVASCRIPT",args:{code:_,enable_async:!1}},in:{code:null,inputs:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID FINAL>",port:"result"}]},out:{result:[{id:m,port:"result"},{id:u,port:"result"}]}},[m]:{type:"command-node-sandbox",title:"Command: SANDBOX_GET_ERROR",properties:{command:"SANDBOX_GET_ERROR"},in:{result:[{id:p,port:"result"}]},out:{result:[{id:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE ERROR>",port:"change"}],$note:"Set `result` as null if there is no error"}},[u]:{type:"command-node-sandbox",title:"Command: SANDBOX_GET_RETURN_VALUE",properties:{command:"SANDBOX_GET_RETURN_VALUE"},in:{result:[{id:p,port:"result"}]},out:{result:[{id:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE RESULT> | PROPERTY_BANK_COMMAND_NODE_<UUID PARSE RESULT> | null",port:"change"}]}},"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE RESULT>":{type:"data-node",properties:{},in:{change:[{id:u,port:"result"}]},out:{value:null},$note:"Put full result into data node"},"PROPERTY_BANK_COMMAND_NODE_<UUID PARSE RESULT>":{type:"command-node-object",title:"Command: OBJECT_GET",properties:{command:"OBJECT_GET",args:{path:"obj_key"}},in:{obj:[{id:u,port:"obj"}]},out:{result:[{id:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE PARTIAL RESULT>",port:"change"}]},$note:"Parse result object into data node"},"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE PARTIAL RESULT>":{type:"data-node",properties:{},in:{change:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID PARSE RESULT>",port:"result"}]},out:{value:null},$note:"Put partial result into data node"}},editor_info:{},type:"script",script_config:{title:i,enable_async:!1,inputs:{"PROPERTY_BANK_DATA_NODE_<UUID>":"arg_name"},disabled_triggers:{},error:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE ERROR> | null",output:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE RESULT> | null",outputs:{obj_key:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE PARTIAL RESULT>"},code:_,$note:"Required, info for GUI editor"}}}return C({id:o,example:n,extraInfo:a})};var tH="2.25.0-beta.51";function tJ(){return tX.apply(this,arguments)}function tX(){return(tX=$(function*(e={}){var i,t=e.token||process.env.BRICKS_API_TOKEN;if(!t)throw console.error("Error: API token is required"),console.error("Please provide a token via options or set BRICKS_API_TOKEN environment variable"),Error("API token is required");var n=function(e){try{var i=e.queryStringParameters?.token;if(!i){var t=new Headers(e.headers);i=t.get("authorization")?.replace("Bearer ","")}if(!i)return{success:!1,message:"Authentication failed: No token provided"};var n=function(e){try{var i=e.split(".");if(i.length<3)return null;var t=JSON.parse(Buffer.from(i[0],"base64url").toString());if(!k.includes(t?.alg))return null;return JSON.parse(Buffer.from(i[1],"base64url").toString())}catch{return null}}(i);if(!n)return{success:!1,message:"Authentication failed: Invalid token"};var a=D.includes(n.iss)?"user":"workspace";if("workspace"===a){var o=Array.isArray(n.t)?n.t:[];n.permissions=o.reduce((e,i)=>{var t=I[i];return t&&e.push(t),e},[])}else n.permissions=Object.keys(b);return{success:!0,token:i,tokenInfo:n,tokenType:a}}catch(e){return{success:!1,message:`Authentication failed: ${e.message}`}}}({queryStringParameters:{token:t}});if(!n.success)throw console.error("Error: Invalid BRICKS_API_TOKEN"),console.error(n.message),Error("Invalid BRICKS_API_TOKEN");var a=new v._({name:tY,version:tH}),o={...n,client:function(e,i,t){switch(t){case"user":return new iB(e,i);case"workspace":return new i3(e,i);default:throw Error(`Invalid token type: ${t}.`)}}(tG.bricks,n.token,n.tokenType)};a.prompt("getting-started","Getting started with BRICKS",{},$(function*(){return{messages:[{role:"user",content:{type:"text",text:`Welcome to BRICKS — start here.
2473
2476
 
2474
2477
  Before doing any complex work (application design, deployments, etc.),
2475
2478
  always consult the official docs rather than guessing.
package/lib/456.js CHANGED
@@ -1 +1,3 @@
1
- export const __rspack_esm_id=456;export const __rspack_esm_ids=[456];export const __webpack_modules__={79491(_){_.exports=import("oxfmt").then(function(_){return _})}};
1
+ export const __rspack_esm_id=456;export const __rspack_esm_ids=[456];export const __webpack_modules__={65650(e,t,r){e.exports=r(78942).Symbol},65111(e){e.exports=function(e,t){for(var r=-1,i=null==e?0:e.length,o=Array(i);++r<i;)o[r]=t(e[r],r,e);return o}},44187(e){e.exports=function(e,t,r,i){var o=-1,n=null==e?0:e.length;for(i&&n&&(r=e[++o]);++o<n;)r=t(r,e[o],o,e);return r}},39546(e){var t=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;e.exports=function(e){return e.match(t)||[]}},87379(e,t,r){var i=r(65650),o=r(8870),n=r(29005),u=i?i.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":u&&u in Object(e)?o(e):n(e)}},51035(e){e.exports=function(e){return function(t){return null==e?void 0:e[t]}}},52291(e,t,r){var i=r(65650),o=r(65111),n=r(53142),u=r(51187),a=1/0,l=i?i.prototype:void 0,c=l?l.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(n(t))return o(t,e)+"";if(u(t))return c?c.call(t):"";var r=t+"";return"0"==r&&1/t==-a?"-0":r}},93640(e,t,r){var i=r(44187),o=r(45881),n=r(39850),u=RegExp("['’]","g");e.exports=function(e){return function(t){return i(n(o(t).replace(u,"")),e,"")}}},69968(e,t,r){e.exports=r(51035)({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"})},74967(e){e.exports="object"==typeof global&&global&&global.Object===Object&&global},8870(e,t,r){var i=r(65650),o=Object.prototype,n=o.hasOwnProperty,u=o.toString,a=i?i.toStringTag:void 0;e.exports=function(e){var t=n.call(e,a),r=e[a];try{e[a]=void 0;var i=!0}catch(e){}var o=u.call(e);return i&&(t?e[a]=r:delete e[a]),o}},15813(e){var t=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;e.exports=function(e){return t.test(e)}},29005(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},78942(e,t,r){var i=r(74967),o="object"==typeof self&&self&&self.Object===Object&&self;e.exports=i||o||Function("return this")()},10482(e){var t="\\ud800-\\udfff",r="\\u2700-\\u27bf",i="a-z\\xdf-\\xf6\\xf8-\\xff",o="A-Z\\xc0-\\xd6\\xd8-\\xde",n="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",u="['’]",a="["+n+"]",l="["+i+"]",c="[^"+t+n+"\\d+"+r+i+o+"]",s="(?:\\ud83c[\\udde6-\\uddff]){2}",d="[\\ud800-\\udbff][\\udc00-\\udfff]",f="["+o+"]",p="(?:"+l+"|"+c+")",g="(?:"+f+"|"+c+")",y="(?:"+u+"(?:d|ll|m|re|s|t|ve))?",x="(?:"+u+"(?:D|LL|M|RE|S|T|VE))?",h="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\\ud83c[\\udffb-\\udfff])?",m="[\\ufe0e\\ufe0f]?",v="(?:\\u200d(?:"+["[^"+t+"]",s,d].join("|")+")"+m+h+")*",b="(?:"+["["+r+"]",s,d].join("|")+")"+(m+h+v),A=RegExp([f+"?"+l+"+"+y+"(?="+[a,f,"$"].join("|")+")",g+"+"+x+"(?="+[a,f+p,"$"].join("|")+")",f+"?"+p+"+"+y,f+"+"+x,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])|\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])|\\d+",b].join("|"),"g");e.exports=function(e){return e.match(A)||[]}},45881(e,t,r){var i=r(69968),o=r(95243),n=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,u=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]","g");e.exports=function(e){return(e=o(e))&&e.replace(n,i).replace(u,"")}},53142(e){e.exports=Array.isArray},80547(e){e.exports=function(e){return null!=e&&"object"==typeof e}},51187(e,t,r){var i=r(87379),o=r(80547);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==i(e)}},10750(e,t,r){e.exports=r(93640)(function(e,t,r){return e+(r?"-":"")+t.toLowerCase()})},95243(e,t,r){var i=r(52291);e.exports=function(e){return null==e?"":i(e)}},39850(e,t,r){var i=r(39546),o=r(15813),n=r(95243),u=r(10482);e.exports=function(e,t,r){return(e=n(e),void 0===(t=r?void 0:t))?o(e)?u(e):i(e):e.match(t)||[]}},58891(e,t,r){r.r(t),r.d(t,{initProject:()=>p});var i,o,n=r(99436),u=r(16928),a=r(73284),l=r(30155),c=r(88958),s=r(56493),d=r(77768),f=(i=n(function*(e,t){console.log(a.Ay.bold.cyan(`
2
+ Initialize BRICKS Project: ${t}
3
+ `));var r=yield(0,c.kv)({message:"Select files to include:",choices:[{name:"GitHub Actions workflow (.github/workflows/ci.yml)",value:"githubActions",checked:!1!==e.githubActions},{name:"AGENTS.md",value:"agents",checked:!1!==e.agents},{name:"CLAUDE.md",value:"claude",checked:!1!==e.claude},{name:"GEMINI.md",value:"gemini",checked:!0===e.gemini}]}),i=yield(0,c.kv)({message:"Select post-generation steps:",choices:[{name:"Run bun install",value:"install",checked:!1!==e.install},{name:"Initialize git repository",value:"git",checked:!1!==e.git}]}),o=e.output?u.resolve(e.output):u.join(process.cwd(),t),n=yield(0,c.hF)({message:"Output directory:",default:o});return{githubActions:r.includes("githubActions"),agents:r.includes("agents"),claude:r.includes("claude"),gemini:r.includes("gemini"),install:i.includes("install"),git:i.includes("git"),output:n,outputAsTarget:!0}}),function(e,t){return i.apply(this,arguments)}),p=(o=n(function*(e,t,r){var i=(0,s.o)(),o=r.json,n=r.yes||o,c="application"===e,p=c?i.queries.applicationProject:i.queries.moduleProject,g=o?null:(0,l.default)(`Fetching ${e} info...`).start(),y="bricks-ctor";try{var x=(yield i.query(p,{id:t,buildApplicationOnly:!0}))[c?"applicationProject":"moduleProject"];x?.files&&(y=(0,d.kU)(x.files)),g&&g.stop()}catch{g&&g.stop()}var h={...r};if(!n)try{var m=yield f(r,y);h={...r,...m}}catch{console.log(a.Ay.yellow("\nCancelled")),process.exit(0)}g=o?null:(0,l.default)(`Fetching ${e} project...`).start();var v=!!h.output;try{var b=yield(0,d.BZ)(e,t,{client:i,output:v?h.output:process.cwd(),outputAsTarget:v||!0===h.outputAsTarget,install:h.install,git:h.git,githubActions:h.githubActions,agents:h.agents,claude:h.claude,gemini:h.gemini});g&&g.succeed(`Project created: ${a.Ay.green(b.path)} (${b.files} files)`),o?console.log(JSON.stringify(b)):(console.log(""),console.log(a.Ay.bold.green("Project initialized successfully!")),console.log(""),console.log(a.Ay.bold("Next steps:")),console.log(a.Ay.gray(` cd ${u.basename(b.path)}`)),b.bunInstalled||console.log(a.Ay.gray(" bun install")),console.log(a.Ay.gray(" bun invoke-simulator")),console.log(""),console.log(a.Ay.gray(`For more information, see ${u.basename(b.path)}/README.md`)))}catch(t){o?console.error(JSON.stringify({error:t.message})):g?g.fail(`Failed to initialize ${e} project: ${t.message}`):console.error(a.Ay.red(`Failed to initialize ${e} project: ${t.message}`)),process.exit(1)}}),function(e,t,r){return o.apply(this,arguments)})},77768(e,t,r){r.d(t,{BZ:()=>v,KN:()=>x,kU:()=>y,o0:()=>m,oz:()=>h});var i,o,n,u,a=r(99436),l=r(16928),c=r(79896),s=r(35317),d=r(10750),f=e=>{try{return(0,s.execSync)(`which ${e}`,{stdio:"ignore"}),!0}catch{return!1}},p=(e,t,r)=>new Promise((i,o)=>{var n=[e,...t].join(" "),u=(0,s.spawn)(n,[],{cwd:r,stdio:"pipe",shell:!0}),a=[];u.stderr.on("data",e=>a.push(e)),u.on("close",e=>{0===e?i():o(Error(Buffer.concat(a).toString().trim()||`Command failed with code ${e}`))}),u.on("error",o)}),g=(i=a(function*(e,t){try{var i=(yield r.e(75).then(r.bind(r,79491))).format;return(yield i(t,e,{trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100})).code}catch{}return e}),function(e,t){return i.apply(this,arguments)}),y=(e=[])=>{var t=e.find(e=>"application.json"===e.name);if(!t)return"bricks-ctor";try{var r=JSON.parse(t.input);return d(r.name||"bricks-ctor")}catch{return"bricks-ctor"}},x=(o=a(function*(e,t){var r;return Promise.all(e.map((r=a(function*(e){var r=l.join(t,e.name),i=e.input;return e.formatable&&(i=yield g(i,r)),{...e,filePath:r,content:i}}),function(e){return r.apply(this,arguments)})))}),function(e,t){return o.apply(this,arguments)}),h=e=>{e.forEach(e=>{c.mkdirSync(l.dirname(e.filePath),{recursive:!0}),c.writeFileSync(e.filePath,e.content)})},m=(n=a(function*(e,t={}){var r="function"==typeof t.onStatus?t.onStatus:()=>{},i=!1,o=!1;if(!1!==t.install&&f("bun")){r("Installing dependencies (bun install)...");try{yield p("bun",["install"],e),i=!0}catch{}}if(!1!==t.git&&f("git")){r("Initializing git repository...");try{yield p("git",["init"],e),yield p("git",["add","."],e),yield p("git",["-c 'user.name=BRICKS CLI'","-c 'user.email=cli@bricks.tools'","commit","-m 'chore: initialize commit'"],e),o=!0}catch{}}return{bunInstalled:i,gitInitialized:o}}),function(e){return n.apply(this,arguments)}),v=(u=a(function*(e,t,r){var i=r.client,o=r.output,n=r.outputAsTarget;if(!i)throw Error("client is required");if(!o)throw Error("output directory is required");var u=(e=>{for(var t=l.resolve(e);;){if(c.existsSync(l.join(t,"application.json"))||c.existsSync(l.join(t,"module.json")))return t;var r=l.dirname(t);if(r===t)return null;t=r}})(n?l.dirname(l.resolve(o)):o);if(u)throw Error(`Cannot initialize a new BRICKS project inside an existing project (${u}). Choose a directory outside the project.`);var a="application"===e,s=a?i.queries.applicationProject:i.queries.moduleProject,d=(yield i.query(s,{id:t,buildApplicationOnly:!1,setupGitHubActions:!1!==r.githubActions,setupAgents:!1!==r.agents,setupClaudeCode:!1!==r.claude,setupGeminiCLI:!0===r.gemini}))[a?"applicationProject":"moduleProject"];if(!d?.files)throw Error(`${e} project not found`);var f=y(d.files),p=n?l.resolve(o):l.resolve(o,f);if(c.existsSync(p))throw Error(`Directory already exists: ${p}`);c.mkdirSync(p,{recursive:!0}),h((yield x(d.files,p)));var g=yield m(p,r),v=g.bunInstalled,b=g.gitInitialized;return{success:!0,path:p,files:d.files.length,bunInstalled:v,gitInitialized:b}}),function(e,t,r){return u.apply(this,arguments)})}};
package/lib/75.js ADDED
@@ -0,0 +1 @@
1
+ export const __rspack_esm_id=75;export const __rspack_esm_ids=[75];export const __webpack_modules__={79491(_){_.exports=import("oxfmt").then(function(_){return _})}};
package/lib/940.js CHANGED
@@ -1 +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:()=>f,ShortEditEditor:()=>q,MediaFileList:()=>F,App:()=>es,DeviceDetail:()=>k,VIEWS:()=>m,runInteractiveMode:()=>ex,DeviceList:()=>C,MediaBoxList:()=>$,Loading:()=>D,DeviceControl:()=>L,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(47988),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"}],f=3e5,p=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(p.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<=f)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<=f)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})]})},k=({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})]})},L=({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),f=T[0],p=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],k=s((0,d.useState)(""),2),L=k[0],w=k[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:f,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=[...f?[{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:L.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:f,placeholder:"type to filter, Enter to focus list",onChange:e=>p(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){p(""),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:L,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:L})]}),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:L})]}),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),f=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],k=s((0,d.useState)(null),2),L=k[0],w=k[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:f.setupGitHubActions,setupAgents:f.setupAgents,setupClaudeCode:f.setupClaudeCode,setupGeminiCLI:f.setupGeminiCLI}))[i?"applicationProject":"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(f.runBunInstall&&ea("bun")){I("Installing dependencies (bun install)...");try{yield ec("bun",["install"],M),u.bunInstalled=!0}catch{}}if(f.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,f,M,o]),U=(0,d.useCallback)(e=>{"exit"===e.value?h():i()},[h,i]);if(g===el){var G=[{label:`${f.setupGitHubActions?"[x]":"[ ]"} GitHub Actions workflow`,value:"setupGitHubActions"},{label:`${f.setupAgents?"[x]":"[ ]"} AGENTS.md`,value:"setupAgents"},{label:`${f.setupClaudeCode?"[x]":"[ ]"} CLAUDE.md`,value:"setupClaudeCode"},{label:`${f.setupGeminiCLI?"[x]":"[ ]"} GEMINI.md`,value:"setupGeminiCLI"},{label:`${f.runBunInstall?"[x]":"[ ]"} Run bun install after generation`,value:"runBunInstall"},{label:`${f.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: ",f.setupGitHubActions?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - AGENTS.md: ",f.setupAgents?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - CLAUDE.md: ",f.setupClaudeCode?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - GEMINI.md: ",f.setupGeminiCLI?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - Run bun install: ",f.runBunInstall?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - Initialize git: ",f.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(p.A,{type:"dots"})}),n(u.Text,{children:[" ",E]})]})]}):g===eo&&L?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:L.path})]}),n(u.Text,{children:["Files: ",t(u.Text,{color:"green",children:L.files})]}),n(u.Text,{children:["Dependencies:"," ",t(u.Text,{color:L.bunInstalled?"green":"yellow",children:L.bunInstalled?"Installed":"Not installed (run bun install manually)"})]}),n(u.Text,{children:["Git:"," ",t(u.Text,{color:L.gitInitialized?"green":"yellow",children:L.gitInitialized?"Initialized":"Not initialized"})]})]}),t(u.Text,{bold:!0,marginY:1,children:"Next steps:"}),n(u.Text,{color:"gray",children:[" cd ",O]}),!L.bunInstalled&&t(u.Text,{color:"gray",children:" bun install"}),t(u.Text,{color:"gray",children:" bun invoke-simulator"}),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,f,p=(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],ef=s((0,d.useState)(null),2),ep=ef[0],ev=ef[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),ek=eC[0],eL=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&&p(),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)((f=c(function*(e){if(B&&ei){eL(!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})}eL(!1)}}),function(e){return f.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&&lt(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?p():(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(k,{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(L,{device:ei,onSelect:e=>{if("back"===e.value){S(m.DEVICE_DETAIL),eM(null);return}lc(e.value)},controlling:ek,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:ep,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.MODULES),ev(null);return}"refresh"===e.value?ll(ep._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:ep,client:B,onDone:c(function*(){return ll(ep._id)}),onCancel:()=>S(m.MODULE_DETAIL)}),E===m.MODULE_PROJECT_INIT&&t(eu,{type:"module",instance:ep,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)})}};
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:()=>w,CONTROL_ACTIONS:()=>x,MainMenu:()=>S,Header:()=>y,ModuleDetail:()=>M,ONLINE_THRESHOLD_MS:()=>p,ShortEditEditor:()=>J,MediaFileList:()=>$,App:()=>ea,DeviceDetail:()=>C,VIEWS:()=>m,runInteractiveMode:()=>ed,DeviceList:()=>B,MediaBoxList:()=>G,Loading:()=>b,DeviceControl:()=>k,ProjectInitView:()=>eo,GroupDetail:()=>U,ModuleList:()=>P,MediaBoxDetail:()=>j,GroupList:()=>R,Footer:()=>_,DeviceStatus:()=>D,AppDetail:()=>O,DeviceScreenshot:()=>L,MediaFileDetail:()=>V});var o,a=i(99436),c=i(51649),d=i(8498),u=i(68832),s=i(85382),h=i(47988),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"},x=[{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),T=(e,l=!0)=>{var r=Math.floor(60),t=u((0,c.useState)(r),2),n=t[0],i=t[1],o=u((0,c.useState)(null),2),a=o[0],d=o[1],s=(0,c.useRef)(e);(0,c.useEffect)(()=>{s.current=e},[e]);var h=(0,c.useCallback)(()=>{i(r),d(Date.now())},[r]);return(0,c.useEffect)(()=>{if(l){var e=setInterval(()=>{i(e=>e<=1?(s.current?.(),d(Date.now()),r):e-1)},1e3);return()=>clearInterval(e)}},[l,r]),(0,c.useEffect)(()=>{l&&(i(r),d(Date.now()))},[l,r]),{countdown:n,lastRefreshTime:a,resetCountdown:h}},v=({countdown:e,lastRefreshTime:l})=>t(d.Box,{children:n(d.Text,{color:"gray",children:["Next refresh in ",n(d.Text,{color:"cyan",children:[e,"s"]}),l&&n(d.Text,{color:"gray",children:[" (last: ",l?new Date(l).toLocaleTimeString():null,")"]})]})}),y=({workspace:e,view:l})=>n(d.Box,{flexDirection:"column",marginBottom:1,children:[n(d.Box,{children:[t(d.Text,{bold:!0,color:"cyan",children:"BRICKS CLI"}),t(d.Text,{color:"gray",children:" - Interactive Mode"})]}),n(d.Box,{children:[t(d.Text,{color:"gray",children:"Workspace: "}),t(d.Text,{color:"green",children:e?.name||"Not connected"}),t(d.Text,{color:"gray",children:" | View: "}),t(d.Text,{color:"yellow",children:l})]}),t(d.Text,{color:"gray",children:"─".repeat(60)})]}),_=()=>n(d.Box,{marginTop:1,flexDirection:"column",children:[t(d.Text,{color:"gray",children:"─".repeat(60)}),n(d.Text,{color:"gray",children:["Press ",t(d.Text,{color:"cyan",children:"q"})," to quit, ",t(d.Text,{color:"cyan",children:"Esc"})," to go back"]})]}),b=({text:e})=>n(d.Box,{children:[t(d.Text,{color:"green",children:t(f.A,{type:"dots"})}),n(d.Text,{children:[" ",e||"Loading..."]})]}),D=({lastAliveTime:e})=>{if(!e)return t(d.Text,{color:"gray",children:"○ Unknown"});var l=Date.now()-new Date(e).getTime();if(l<=p)return t(d.Text,{color:"green",children:"● Online"});var r=Math.floor(l/6e4);if(r<60)return n(d.Text,{color:"yellow",children:["○ Offline (",r,"m ago)"]});var i=Math.floor(r/60);if(i<24)return n(d.Text,{color:"red",children:["○ Offline (",i,"h ago)"]});var o=Math.floor(i/24);return n(d.Text,{color:"red",children:["○ Offline (",o,"d ago)"]})},E=i(48724),S=({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(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,marginBottom:1,children:"Main Menu"}),t(E.Ay,{items:i,onSelect:e})]})},I="1"===process.env.BRICKS_CLI_DISTRIBUTION,A=e=>{var l=u((0,c.useState)(null),2),r=l[0],n=l[1];return((0,c.useEffect)(()=>{if(!I){var e=!0;return i.e(166).then(i.bind(i,29557)).then(l=>{e&&n(()=>l.default)}).catch(()=>{e&&n(!1)}),()=>{e=!1}}},[]),I||!1===r)?t(d.Text,{color:"gray",children:"Image preview is not available in this CLI build."}):r?t(r,{...e}):t(b,{text:"Preparing image preview..."})},B=({devices:e,loading:l,onSelect:r,countdown:i,lastRefreshTime:o})=>{if(l)return t(b,{text:"Loading devices..."});if(!e?.length)return n(d.Box,{flexDirection:"column",children:[t(d.Text,{color:"yellow",children:"No devices found"}),t(v,{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(d.Box,{flexDirection:"column",children:[n(d.Box,{marginBottom:1,children:[n(d.Text,{bold:!0,children:["Devices (",e.length,")"]}),t(d.Text,{color:"gray",children:" - "}),t(v,{countdown:i,lastRefreshTime:o})]}),t(E.Ay,{items:a,onSelect:r})]})},C=({device:e,loading:l,error:r,onSelect:i,mediaEnabled:o,countdown:a,lastRefreshTime:c})=>{if(l)return t(b,{text:"Loading device..."});if(r)return n(d.Box,{flexDirection:"column",children:[n(d.Text,{color:"red",children:["Error: ",r]}),t(E.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(d.Text,{color:"red",children:"Device not found"});var u=[{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,g=s?.update,m=s?.local_sync;return n(d.Box,{flexDirection:"column",children:[n(d.Box,{children:[t(d.Text,{bold:!0,color:"cyan",children:e.name||e.device_name}),t(d.Text,{color:"gray",children:" - "}),t(v,{countdown:a,lastRefreshTime:c})]}),e.description&&t(d.Text,{color:"gray",children:e.description}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Box,{children:[t(d.Text,{color:"gray",children:"Status: "}),t(D,{lastAliveTime:s?.watch_dog_timer?.last_alive_time})]}),n(d.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(d.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),s?.application&&n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Application"}),n(d.Text,{color:"gray",children:[" Name: ",s.application.name]}),n(d.Text,{color:"gray",children:[" Mode: ",s.operation_mode||"N/A"]})]}),h&&n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Screen"}),h.resolution&&n(d.Text,{color:"gray",children:[" ","Resolution: ",h.resolution.width,"x",h.resolution.height,h.resolution.scale&&` @${h.resolution.scale}x`]}),h.orientation&&n(d.Text,{color:"gray",children:[" Orientation: ",h.orientation]}),h.touch&&n(d.Text,{color:"gray",children:[" ","Touch:"," ",h.touch.available?`Yes (${h.touch.touch_point} points)`:"No"]})]}),(s?.memory_usage||s?.disk_usage)&&n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"System"}),s.memory_usage&&n(d.Text,{color:"gray",children:[" Memory: ",Math.round(100*s.memory_usage),"%"]}),s.disk_usage&&n(d.Text,{color:"gray",children:[" Disk: ",Math.round(100*s.disk_usage),"%"]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Capabilities"}),n(d.Text,{color:"gray",children:[" ","Sound: ",s?.sound?.available?"✓":"✗"," | ","Camera: ",s?.camera?.available?"✓":"✗"," | ","Audio In: ",s?.audio_in?.available?"✓":"✗"]})]}),m&&n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Local Sync"}),n(d.Text,{color:"gray",children:[" ","Role: ",m.is_main?"Main":"Peer",m.peer_count>0&&` | Peers: ${m.peer_count}`,m.mean_latency&&` | Latency: ${m.mean_latency}ms`]})]}),g&&n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Update"}),n(d.Text,{color:g.need_update?"yellow":"gray",children:[" ","Status: ",g.need_update?"⚠ Update available":"✓ Up to date"]}),g.current_version&&n(d.Text,{color:"gray",children:[" Version: ",g.current_version]})]})]}),t(E.Ay,{items:u,onSelect:i})]})},k=({device:e,onSelect:l,controlling:r,controlResult:i})=>n(d.Box,{flexDirection:"column",children:[n(d.Text,{bold:!0,color:"cyan",children:["Control: ",e?.name||e?.device_name]}),r&&t(b,{text:"Sending command..."}),i&&t(d.Text,{color:i.success?"green":"red",children:i.message}),t(d.Box,{marginTop:1,children:t(E.Ay,{items:x,onSelect:l})})]}),L=({device:e,screenshot:l,loading:r,error:i,onSelect:o})=>{var a=l?.file?.meta,c=a?.originalWidth!=null&&a?.originalHeight!=null,u=a?.originalFileSize!=null;return n(d.Box,{flexDirection:"column",children:[n(d.Text,{bold:!0,color:"cyan",children:["Screenshot: ",e?.name||e?.device_name||"Unknown"]}),r&&t(b,{text:"Loading screenshot..."}),i&&t(d.Box,{marginY:1,children:t(d.Text,{color:"red",children:String(i)})}),!r&&!i&&l&&n(d.Box,{flexDirection:"column",children:[t(d.Box,{height:30,children:t(A,{src:l.path,width:80,alt:"Device screenshot"})}),n(d.Box,{marginY:1,flexDirection:"column",children:[t(d.Text,{bold:!0,color:"white",children:"Screenshot Details"}),n(d.Box,{marginY:1,children:[t(d.Text,{color:"green",children:"Screenshot saved to: "}),t(d.Text,{color:"cyan",children:String(l.path||"")})]}),c&&n(d.Text,{color:"gray",children:["Size: ",String(a.originalWidth),"x",String(a.originalHeight)]}),u&&n(d.Text,{color:"gray",children:["File: ",(Number(a.originalFileSize)/1024).toFixed(1)," KB"]}),l.file?.updatedAt&&n(d.Text,{color:"gray",children:["Updated: ",new Date(l.file.updatedAt).toLocaleString()]})]})]}),!r&&!i&&!l&&t(d.Box,{marginY:1,children:t(d.Text,{color:"yellow",children:"No screenshot available. Try taking a new one."})}),t(d.Box,{marginTop:1,children:t(E.Ay,{items:[{label:"Take New Screenshot",value:"take"},{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:o})})]})},w=({apps:e,loading:l,onSelect:r})=>{if(l)return t(b,{text:"Loading applications..."});if(!e?.length)return t(d.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(d.Box,{flexDirection:"column",children:[n(d.Text,{bold:!0,marginBottom:1,children:["Applications (",e.length,")"]}),t(E.Ay,{items:i,onSelect:r})]})},O=({app:e,loading:l,error:r,onSelect:i})=>{if(l)return t(b,{text:"Loading application..."});if(r)return n(d.Box,{flexDirection:"column",children:[n(d.Text,{color:"red",children:["Error: ",r]}),t(E.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(d.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(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,color:"cyan",children:e.name}),e.description&&t(d.Text,{color:"gray",children:e.description}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(d.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Version"}),n(d.Text,{color:"gray",children:[" ","Current: ",e.current_version?`v${e.current_version}`:"N/A"]}),n(d.Text,{color:e.has_unreleased_changes?"yellow":"gray",children:[" ","Changes:"," ",e.has_unreleased_changes?"● Unreleased changes":"○ No pending changes"]}),e.current_version_details&&n(d.Text,{color:"gray",children:[" ","Released: v",e.current_version_details.version||"N/A"]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Devices"}),n(d.Text,{color:"gray",children:[" ","Total: ",a,a>0&&` (${c} online)`]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Features"}),n(d.Text,{color:"gray",children:[" ","Short Edit: ",e.short_edit?.enabled?"✓ Enabled":"✗ Disabled"]}),n(d.Text,{color:"gray",children:[" ","Canvas Control: ",e.canvas_control?.enabled?"✓ Enabled":"✗ Disabled"]}),n(d.Text,{color:"gray",children:[" ","Device Control: ",e.device_control?.enabled?"✓ Enabled":"✗ Disabled"]}),n(d.Text,{color:e.lock?.enabled?"yellow":"gray",children:[" ","Lock: ",e.lock?.enabled?"\uD83D\uDD12 Locked":"\uD83D\uDD13 Unlocked"]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&n(d.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&n(d.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),t(E.Ay,{items:o,onSelect:i})]})},P=({modules:e,loading:l,onSelect:r})=>{if(l)return t(b,{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(d.Box,{flexDirection:"column",children:[n(d.Text,{bold:!0,marginBottom:1,children:["Modules (",e?.length||0,")"]}),!e?.length&&t(d.Text,{color:"yellow",children:"No modules found"}),t(E.Ay,{items:i,onSelect:r})]})},M=({module:e,loading:l,error:r,onSelect:i})=>{if(l)return t(b,{text:"Loading module..."});if(r)return n(d.Box,{flexDirection:"column",children:[n(d.Text,{color:"red",children:["Error: ",r]}),t(E.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(d.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(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,color:"cyan",children:e.name}),e.description&&t(d.Text,{color:"gray",children:e.description}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(d.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Version"}),n(d.Text,{color:"gray",children:[" ","Current: ",e.current_version?`v${e.current_version}`:"N/A"]}),n(d.Text,{color:e.has_unreleased_changes?"yellow":"gray",children:[" ","Changes:"," ",e.has_unreleased_changes?"● Unreleased changes":"○ No pending changes"]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Usage"}),n(d.Text,{color:"gray",children:[" ","Used in: ",e.use_count?.total_count||0," application(s)"]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Settings"}),n(d.Text,{color:"gray",children:[" ","Public: ",e.is_public?"✓ Yes":"✗ No"]}),n(d.Text,{color:"gray",children:[" ","Modifiable: ",e.is_allow_modify?"✓ Yes":"✗ No"]}),n(d.Text,{color:"gray",children:[" ","Short Edit: ",e.short_edit?.enabled?"✓ Enabled":"✗ Disabled"]})]}),e.expose_properties?.length>0&&n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Exposed Properties"}),n(d.Text,{color:"gray",children:[" ",e.expose_properties.length," properties exposed"]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&n(d.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&n(d.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),t(E.Ay,{items:o,onSelect:i})]})},R=({groups:e,loading:l,onSelect:r,countdown:i,lastRefreshTime:o})=>{if(l)return t(b,{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(d.Box,{flexDirection:"column",children:[n(d.Box,{marginBottom:1,children:[n(d.Text,{bold:!0,children:["Device Groups (",e?.length||0,")"]}),t(d.Text,{color:"gray",children:" - "}),t(v,{countdown:i,lastRefreshTime:o})]}),!e?.length&&t(d.Text,{color:"yellow",children:"No device groups found"}),t(E.Ay,{items:a,onSelect:r})]})},N=({loading:e,groupDevices:l})=>e?t(b,{text:"Loading devices..."}):l?.length?n(r,{children:[l.slice(0,10).map(e=>n(d.Box,{children:[t(d.Text,{color:"gray",children:" "}),t(D,{lastAliveTime:e.entry_detail?.watch_dog_timer?.last_alive_time}),n(d.Text,{color:"gray",children:[" ",e.name||e.device_name]}),e.device_target_name&&n(d.Text,{color:"gray",dimColor:!0,children:[" ","(",e.device_target_name,")"]})]},e._id)),l.length>10&&n(d.Text,{color:"gray",dimColor:!0,children:[" ","... and ",l.length-10," more"]})]}):t(d.Text,{color:"gray",children:" No devices in this group"}),U=({group:e,groupDevices:l,loading:r,error:i,onSelect:o,countdown:a,lastRefreshTime:c})=>r&&!e?t(b,{text:"Loading device group..."}):i?n(d.Box,{flexDirection:"column",children:[n(d.Text,{color:"red",children:["Error: ",i]}),t(E.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]}):e?n(d.Box,{flexDirection:"column",children:[n(d.Box,{children:[t(d.Text,{bold:!0,color:"cyan",children:e.name}),t(d.Text,{color:"gray",children:" - "}),t(v,{countdown:a,lastRefreshTime:c})]}),e.description&&t(d.Text,{color:"gray",children:e.description}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(d.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[n(d.Text,{bold:!0,color:"white",children:["Devices (",e.devices?.length||0,")"]}),t(N,{loading:r,groupDevices:l})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&n(d.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&n(d.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),t(E.Ay,{items:[{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:o})]}):t(d.Text,{color:"red",children:"Device group not found"}),G=({boxes:e,loading:l,onSelect:r})=>{if(l)return t(b,{text:"Loading media boxes..."});if(!e?.length)return t(d.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(d.Box,{flexDirection:"column",children:[n(d.Text,{bold:!0,marginBottom:1,children:["Media Boxes (",e.length,")"]}),t(E.Ay,{items:i,onSelect:r})]})},j=({box:e,loading:l,error:r,onSelect:i})=>l&&!e?t(b,{text:"Loading media box..."}):r?n(d.Box,{flexDirection:"column",children:[n(d.Text,{color:"red",children:["Error: ",r]}),t(E.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]}):e?n(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,color:"cyan",children:e.name||"Unnamed"}),e.description&&t(d.Text,{color:"gray",children:e.description}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Text,{color:"gray",children:["ID: ",e.id]}),e.tags?.length>0&&n(d.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),null!=e.size&&n(d.Text,{color:"gray",children:["Size: ",e.size]}),e.passcodes?.length>0&&n(d.Box,{flexDirection:"column",marginTop:1,children:[n(d.Text,{bold:!0,color:"white",children:["Passcodes (",e.passcodes.length,")"]}),e.passcodes.slice(0,5).map(e=>n(d.Text,{color:"gray",children:[" ",e.name||"Passcode",": ",e.code]},e.id)),e.passcodes.length>5&&n(d.Text,{color:"gray",dimColor:!0,children:[" ","... and ",e.passcodes.length-5," more"]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Timestamps"}),e.createdAt&&n(d.Text,{color:"gray",children:[" Created: ",new Date(e.createdAt).toLocaleString()]}),e.updatedAt&&n(d.Text,{color:"gray",children:[" Modified: ",new Date(e.updatedAt).toLocaleString()]})]})]}),t(E.Ay,{items:[{label:"List Files",value:"files"},{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:i})]}):t(d.Text,{color:"red",children:"Media box not found"}),$=({files:e,loading:l,onSelect:r,box:i})=>{if(l)return t(b,{text:"Loading media files..."});if(!e?.length)return t(d.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(d.Box,{flexDirection:"column",children:[n(d.Text,{bold:!0,marginBottom:1,children:["Media Files (",e.length,")",i?.name?` - ${i.name}`:""]}),t(E.Ay,{items:o,onSelect:r})]})},V=({file:e,loading:l,error:r,onSelect:i})=>{if(l&&!e)return t(b,{text:"Loading media file..."});if(r)return n(d.Box,{flexDirection:"column",children:[n(d.Text,{color:"red",children:["Error: ",r]}),t(E.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(d.Text,{color:"red",children:"Media file not found"});var o=e.meta,a=(0,g.Gu)(e),c=(0,g.Gu)(e,{preferThumbnail:!0}),u=!!(c&&c!==a);return n(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,color:"cyan",children:e.name||"Unnamed"}),e.description&&t(d.Text,{color:"gray",children:e.description}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Text,{color:"gray",children:["ID: ",e.id]}),n(d.Text,{color:"gray",children:["Box ID: ",e.boxId]}),n(d.Text,{color:"gray",children:["Type: ",e.fileType]}),e.userTags?.length>0&&n(d.Text,{color:"gray",children:["Tags: ",e.userTags.join(", ")]}),o?.originalWidth!=null&&o?.originalHeight!=null&&n(d.Text,{color:"gray",children:["Size: ",o.originalWidth,"x",o.originalHeight]}),o?.originalFileSize!=null&&n(d.Text,{color:"gray",children:["File: ",(Number(o.originalFileSize)/1024).toFixed(1)," KB"]}),a&&n(d.Text,{color:"gray",children:["Original URL: ",a]}),u&&n(d.Text,{color:"gray",children:["Thumbnail URL: ",c]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Timestamps"}),e.createdAt&&n(d.Text,{color:"gray",children:[" Created: ",new Date(e.createdAt).toLocaleString()]}),e.updatedAt&&n(d.Text,{color:"gray",children:[" Modified: ",new Date(e.updatedAt).toLocaleString()]})]})]}),t(E.Ay,{items:[{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:i})]})},F=i(92642),H=(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=u((0,c.useState)([]),2),r=l[0],i=l[1],o=u((0,c.useState)(!0),2),s=o[0],g=o[1],m=u((0,c.useState)(null),2),x=m[0],p=m[1];return(0,c.useEffect)(()=>{var e,l=(0,h.getCurrentProfile)(),r=(0,h.getToken)(l),t=(0,h.getActivityLogBaseUrl)();if(!r){p("Not logged in. Run `bricks auth login` first."),g(!1);return}if(!t){p("Activity log URL not configured."),g(!1);return}var n=(0,F.W)(t,r),o=new Date(Date.now()-36e5).toISOString(),c=new Date().toISOString(),d=new AbortController;return(e=a(function*(){try{var e=yield n.collectEvents({start_time:o,end_time:c},{limit:50,signal:d.signal});i(e)}catch(e){"AbortError"!==e.name&&p(e.message)}g(!1)}),function(){return e.apply(this,arguments)})(),()=>d.abort()},[]),n(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,marginBottom:1,children:"Activity Log (last 1h)"}),s&&t(b,{text:"Fetching events..."}),x&&n(d.Text,{color:"red",children:["Error: ",x]}),!s&&!x&&0===r.length&&t(d.Text,{color:"yellow",children:"No events found in the last hour"}),!s&&r.length>0&&n(d.Box,{flexDirection:"column",marginBottom:1,children:[n(d.Text,{color:"gray",children:["Timestamp".padEnd(22)," ","Type".padEnd(12)," ","Device".padEnd(14)," ","Event Name".padEnd(24)," Sender"]}),r.map((e,l)=>n(d.Text,{children:[new Date(e.timestamp).toISOString().replace("T"," ").replace(/\.\d+Z$/,"Z").padEnd(22)," ",H(e.event_type||"",12).padEnd(12)," ",H(e.device_id||"",14).padEnd(14)," ",H(e.event_name||"",24).padEnd(24)," ",H(e.sender||"",16)]},l)),r.length>=50&&n(d.Text,{color:"yellow",children:["Showing first ",50," events"]})]}),t(E.Ay,{items:[{label:"← Back",value:"back"}],onSelect:l=>"back"===l.value&&e()})]})},Y=i(29253),q=i(44618),X=["B","C","G","D"],J=({instanceType:e,instance:l,client:r,onDone:i,onCancel:o})=>{var s,h=(0,d.useApp)().exit,g=u((0,c.useState)("select_ref"),2),m=g[0],x=g[1],p=u((0,c.useState)(""),2),f=p[0],T=p[1],v=u((0,c.useState)("search"),2),y=v[0],_=v[1],D=u((0,c.useState)(null),2),S=D[0],I=D[1],A=u((0,c.useState)(null),2),B=A[0],C=A[1],k=u((0,c.useState)(""),2),L=k[0],w=k[1],O=u((0,c.useState)(""),2),P=O[0],M=O[1],R=u((0,c.useState)(null),2),N=R[0],U=R[1],G=l?.short_edit?.ref_map||{},j=Object.entries(G).filter(([,e])=>e&&!e.hide),$=(0,q.V)(G,{keyword:f,types:X}),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}))]),F=[...f?[{label:"↻ Clear Search",value:"__clear_search__"}]:[],{label:"← Back",value:"__back__"}],H=V.length>0?[...V,...F]:F,z=H.findIndex(e=>!e.isHeader&&!e.value?.startsWith("__"));(0,d.useInput)((e,l)=>{l.tab&&"select_ref"===m?_(e=>"search"===e?"list":"search"):(l.escape&&("select_ref"===m&&o(),"input_path"===m&&x("select_ref"),"input_content"===m&&x("input_path"),"confirm"===m&&x("input_content"),"done"===m&&o()),"q"===e&&"input_path"!==m&&"input_content"!==m&&("select_ref"!==m||"search"!==y)&&h())},{isActive:!0});var J=(s=a(function*(){if(r&&l?._id&&S){x("submitting"),U(null);try{var t={shortId:S,path:L.trim(),content:(e=>{var l=e.trim();if(""===l)return null;try{return JSON.parse(l)}catch{return l}})(P),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(),x("done")}catch(e){U(e.message),x("confirm")}}}),function(){return s.apply(this,arguments)});return l?.short_edit?.enabled?0===j.length?n(d.Box,{flexDirection:"column",children:[t(d.Text,{color:"yellow",children:"No Short Edit references found."}),t(E.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]}):"select_ref"===m?n(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,children:"Short Edit References"}),t(d.Text,{color:"gray",dimColor:!0,children:"Showing: Brick, Canvas, Generator, Data"}),n(d.Box,{marginTop:1,flexDirection:"column",children:[t(d.Text,{color:"gray",children:"Search (title or shortId)"}),t(Y.A,{value:f,placeholder:"type to filter, Enter to focus list",onChange:e=>T(e),onSubmit:()=>_("list"),focus:"search"===y}),t(d.Text,{color:"gray",dimColor:!0,children:"Press Tab to switch focus"})]}),n(d.Box,{marginTop:1,children:[0===$.length&&t(d.Text,{color:"yellow",children:"No references match your search."}),t(E.Ay,{items:H,isFocused:"list"===y,initialIndex:z>-1?z:0,indicatorComponent:()=>null,itemComponent:({label:e,isSelected:l,isHeader:r})=>r?t(d.Box,{marginTop:1,children:t(d.Text,{bold:!0,color:"white",children:e})}):n(d.Text,{color:l?"blue":void 0,children:[l?"❯":" "," ",e]}),onSelect:e=>{if("__back__"===e.value)return void o();if("__clear_search__"===e.value){T(""),_("search");return}e.isHeader||(I(e.value),C(e.ref),x("input_path"))}})]})]}):"input_path"===m?n(d.Box,{flexDirection:"column",children:[n(d.Text,{children:["Reference:"," ",n(d.Text,{color:"cyan",children:[B?.title||S," (",S,")"]})]}),t(d.Text,{marginTop:1,children:"Enter property path (e.g. title, property.backgroundColor)"}),N&&n(d.Text,{color:"red",children:["Error: ",N]}),t(Y.A,{value:L,placeholder:"path",onChange:e=>{w(e),N&&U(null)},onSubmit:e=>{var l=e.trim();l?(w(l),x("input_content")):U("Path is required")},focus:!0})]}):"input_content"===m?n(d.Box,{flexDirection:"column",children:[n(d.Text,{children:["Path: ",t(d.Text,{color:"cyan",children:L})]}),t(d.Text,{marginTop:1,children:"Enter new content (JSON or plain text). Empty to clear."}),N&&n(d.Text,{color:"red",children:["Error: ",N]}),t(Y.A,{value:P,placeholder:"content",onChange:e=>{M(e),N&&U(null)},onSubmit:()=>x("confirm"),focus:!0})]}):"submitting"===m?t(b,{text:"Applying short edit..."}):"done"===m?n(d.Box,{flexDirection:"column",children:[t(d.Text,{color:"green",children:"Short edit applied successfully."}),t(E.Ay,{items:[{label:"Edit another property",value:"again"},{label:"← Back",value:"back"}],onSelect:e=>{"again"===e.value?(x("select_ref"),I(null),C(null),w(""),M(""),U(null)):o()}})]}):n(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,marginBottom:1,children:"Confirm Short Edit"}),n(d.Text,{children:["Reference:"," ",n(d.Text,{color:"cyan",children:[B?.title||S," (",S,")"]})]}),n(d.Text,{children:["Path: ",t(d.Text,{color:"cyan",children:L})]}),n(d.Text,{children:["Content: ",t(d.Text,{color:"cyan",children:P||"<empty>"})]}),N&&n(d.Text,{color:"red",children:["Error: ",N]}),t(E.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&&J(),"edit_path"===e.value&&x("input_path"),"edit_content"===e.value&&x("input_content"),"back"===e.value&&o()}})]}):n(d.Box,{flexDirection:"column",children:[n(d.Text,{color:"yellow",children:["Short Edit is not enabled for this ",e,"."]}),t(E.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]})},K=i(16928),W=i(79896),Z=i(10750),Q=i(77768),ee="options",el="output_dir",er="confirm",et="generating",en="post_install",ei="done",eo=({type:e,instance:l,client:r,onDone:i,onCancel:o})=>{var s,h=(0,d.useApp)().exit,g=u((0,c.useState)(ee),2),m=g[0],x=g[1],p=u((0,c.useState)({setupGitHubActions:!0,setupAgents:!0,setupClaudeCode:!0,setupGeminiCLI:!1,runBunInstall:!0,initGit:!0}),2),T=p[0],v=p[1],y=u((0,c.useState)(process.cwd()),2),_=y[0],b=y[1],D=u((0,c.useState)(""),2),S=D[0],I=D[1],A=u((0,c.useState)(null),2),B=A[0],C=A[1],k=u((0,c.useState)(null),2),L=k[0],w=k[1],O=Z(l?.name||"bricks-ctor"),P=K.resolve(_,O),M=(0,c.useCallback)(e=>{"back"===e.value?o():"continue"===e.value?x(el):v(l=>({...l,[e.value]:!l[e.value]}))},[o]),R=(0,c.useCallback)(()=>{W.existsSync(P)?C(`Directory already exists: ${P}`):(C(null),x(er))},[P]),N=(0,c.useCallback)((s=a(function*(t){if("back"===t.value)return void x(el);if("cancel"===t.value)return void o();if("confirm"===t.value){x(et);try{I("Fetching project from BRICKS...");var n="application"===e,i=n?r.queries.applicationProject:r.queries.moduleProject,a=(yield r.query(i,{id:l._id,buildApplicationOnly:!1,setupGitHubActions:T.setupGitHubActions,setupAgents:T.setupAgents,setupClaudeCode:T.setupClaudeCode,setupGeminiCLI:T.setupGeminiCLI}))[n?"applicationProject":"moduleProject"];if(!a?.files)throw Error("Failed to fetch project files");I("Creating project directory..."),W.mkdirSync(P,{recursive:!0}),I(`Writing ${a.files.length} files...`);var c=yield(0,Q.KN)(a.files,P);(0,Q.oz)(c),x(en);var d={path:P,files:a.files.length,bunInstalled:!1,gitInitialized:!1};Object.assign(d,(yield(0,Q.o0)(P,{install:T.runBunInstall,git:T.initGit,onStatus:I}))),w(d),x(ei)}catch(e){C(e.message),x(ee)}}}),function(e){return s.apply(this,arguments)}),[r,l,e,T,P,o]),U=(0,c.useCallback)(e=>{"exit"===e.value?h():i()},[h,i]);if(m===ee){var G=[{label:`${T.setupGitHubActions?"[x]":"[ ]"} GitHub Actions workflow`,value:"setupGitHubActions"},{label:`${T.setupAgents?"[x]":"[ ]"} AGENTS.md`,value:"setupAgents"},{label:`${T.setupClaudeCode?"[x]":"[ ]"} CLAUDE.md`,value:"setupClaudeCode"},{label:`${T.setupGeminiCLI?"[x]":"[ ]"} GEMINI.md`,value:"setupGeminiCLI"},{label:`${T.runBunInstall?"[x]":"[ ]"} Run bun install after generation`,value:"runBunInstall"},{label:`${T.initGit?"[x]":"[ ]"} Initialize git repository`,value:"initGit"},{label:"→ Continue",value:"continue"},{label:"← Back",value:"back"}];return n(d.Box,{flexDirection:"column",children:[n(d.Text,{bold:!0,color:"cyan",children:["Initialize BRICKS Project: ",l?.name||"Untitled"]}),t(d.Text,{color:"gray",marginBottom:1,children:"Select options for project generation (press Enter to toggle)"}),B&&n(d.Text,{color:"red",marginBottom:1,children:["Error: ",B]}),t(E.Ay,{items:G,onSelect:M})]})}return m===el?n(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,color:"cyan",children:"Output Directory"}),t(d.Text,{color:"gray",marginBottom:1,children:"Enter the parent directory for the project:"}),B&&t(d.Text,{color:"red",marginBottom:1,children:B}),n(d.Box,{children:[t(d.Text,{children:"Directory: "}),t(Y.A,{value:_,onChange:b,onSubmit:R})]}),n(d.Text,{color:"gray",marginTop:1,children:["Project will be created at: ",P]})]}):m===er?n(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,color:"cyan",children:"Confirm Project Generation"}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Text,{children:["Name: ",t(d.Text,{color:"green",children:l?.name||"Untitled"})]}),n(d.Text,{children:["Type: ",t(d.Text,{color:"yellow",children:e})]}),n(d.Text,{children:["Path: ",t(d.Text,{color:"cyan",children:P})]}),t(d.Text,{color:"gray",marginTop:1,children:"Options:"}),n(d.Text,{color:"gray",children:[" - GitHub Actions: ",T.setupGitHubActions?"Yes":"No"]}),n(d.Text,{color:"gray",children:[" - AGENTS.md: ",T.setupAgents?"Yes":"No"]}),n(d.Text,{color:"gray",children:[" - CLAUDE.md: ",T.setupClaudeCode?"Yes":"No"]}),n(d.Text,{color:"gray",children:[" - GEMINI.md: ",T.setupGeminiCLI?"Yes":"No"]}),n(d.Text,{color:"gray",children:[" - Run bun install: ",T.runBunInstall?"Yes":"No"]}),n(d.Text,{color:"gray",children:[" - Initialize git: ",T.initGit?"Yes":"No"]})]}),t(E.Ay,{items:[{label:"Confirm & Generate",value:"confirm"},{label:"← Change Directory",value:"back"},{label:"Cancel",value:"cancel"}],onSelect:N})]}):m===et||m===en?n(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,color:"cyan",children:"Generating Project..."}),n(d.Box,{marginY:1,children:[t(d.Text,{color:"green",children:t(f.A,{type:"dots"})}),n(d.Text,{children:[" ",S]})]})]}):m===ei&&L?n(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,color:"green",children:"Project initialized successfully!"}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Text,{children:["Path: ",t(d.Text,{color:"cyan",children:L.path})]}),n(d.Text,{children:["Files: ",t(d.Text,{color:"green",children:L.files})]}),n(d.Text,{children:["Dependencies:"," ",t(d.Text,{color:L.bunInstalled?"green":"yellow",children:L.bunInstalled?"Installed":"Not installed (run bun install manually)"})]}),n(d.Text,{children:["Git:"," ",t(d.Text,{color:L.gitInitialized?"green":"yellow",children:L.gitInitialized?"Initialized":"Not initialized"})]})]}),t(d.Text,{bold:!0,marginY:1,children:"Next steps:"}),n(d.Text,{color:"gray",children:[" cd ",O]}),!L.bunInstalled&&t(d.Text,{color:"gray",children:" bun install"}),t(d.Text,{color:"gray",children:" bun invoke-simulator"}),n(d.Text,{color:"gray",marginTop:1,children:["For more information, see ",O,"/README.md"]}),t(d.Box,{marginTop:1,children:t(E.Ay,{items:[{label:"← Back to Detail",value:"back"},{label:"Exit CLI",value:"exit"}],onSelect:U})})]}):null};let ea=()=>{var e,l,r,i,o,x,p,f,v=(0,d.useApp)().exit,D=u((0,c.useState)(m.MAIN),2),E=D[0],I=D[1],A=u((0,c.useState)(null),2),N=A[0],F=A[1],H=u((0,c.useState)(null),2),Y=H[0],q=H[1],X=u((0,c.useState)(!0),2),K=X[0],W=X[1],Z=u((0,c.useState)(null),2),Q=Z[0],ee=Z[1],el=u((0,c.useState)([]),2),er=el[0],et=el[1],en=u((0,c.useState)(null),2),ei=en[0],ea=en[1],ec=u((0,c.useState)([]),2),ed=ec[0],eu=ec[1],es=u((0,c.useState)(null),2),eh=es[0],eg=es[1],em=u((0,c.useState)([]),2),ex=em[0],ep=em[1],ef=u((0,c.useState)(null),2),eT=ef[0],ev=ef[1],ey=u((0,c.useState)([]),2),e_=ey[0],eb=ey[1],eD=u((0,c.useState)(null),2),eE=eD[0],eS=eD[1],eI=u((0,c.useState)([]),2),eA=eI[0],eB=eI[1],eC=u((0,c.useState)(!1),2),ek=eC[0],eL=eC[1],ew=u((0,c.useState)(null),2),eO=ew[0],eP=ew[1],eM=u((0,c.useState)(null),2),eR=eM[0],eN=eM[1],eU=u((0,c.useState)(null),2),eG=eU[0],ej=eU[1],e$=u((0,c.useState)(null),2),eV=e$[0],eF=e$[1],eH=u((0,c.useState)([]),2),ez=eH[0],eY=eH[1],eq=u((0,c.useState)(null),2),eX=eq[0],eJ=eq[1],eK=u((0,c.useState)([]),2),eW=eK[0],eZ=eK[1],eQ=u((0,c.useState)(null),2),e0=eQ[0],e1=eQ[1],e2=E===m.DEVICES,e4=E===m.DEVICE_DETAIL,e6=E===m.GROUPS,e9=E===m.GROUP_DETAIL;(0,c.useEffect)(()=>{var e=(0,h.getCurrentProfile)(),l=(0,h.getToken)(e);if(!l){ee("Not logged in. Run `bricks auth login` first."),W(!1);return}var r=(0,s.createClient)((0,h.getBaseUrl)(),l);F(r),r.workspace().then(e=>{q(e),W(!1)}).catch(e=>{ee(e.message),W(!1)})},[]),(0,d.useInput)((e,l)=>{"q"===e&&v(),l.escape&&(E===m.DEVICE_CONTROL?(I(m.DEVICE_DETAIL),eP(null)):E===m.DEVICE_SCREENSHOT?(I(m.DEVICE_DETAIL),ej(null),eF(null)):E===m.DEVICE_DETAIL?(I(m.DEVICES),ea(null)):E===m.APP_DETAIL?(I(m.APPS),eg(null)):E===m.MODULE_DETAIL?(I(m.MODULES),ev(null)):E===m.GROUP_DETAIL?(I(m.GROUPS),eS(null),eB([])):E===m.MEDIA_FILE_DETAIL?(I(m.MEDIA_FILES),e1(null)):E===m.MEDIA_FILES?(I(m.MEDIA_BOX_DETAIL),e1(null)):E===m.MEDIA_BOX_DETAIL?(I(m.MEDIA_BOXES),eJ(null),eZ([])):E===m.MEDIA_BOXES?I(m.MAIN):E!==m.MAIN&&I(m.MAIN))},{isActive:E!==m.APP_SHORT_EDIT&&E!==m.MODULE_SHORT_EDIT&&E!==m.APP_PROJECT_INIT&&E!==m.MODULE_PROJECT_INIT});var e5=(0,c.useCallback)(a(function*(){if(N){W(!0);try{var e=yield N.devices({});et(e||[])}catch(e){ee(e.message)}W(!1)}}),[N]),e8=(0,c.useCallback)((e=a(function*(e){if(N){W(!0),eN(null);try{var l=yield N.device({id:e});ea(l)}catch(e){eN(e.message)}W(!1)}}),function(l){return e.apply(this,arguments)}),[N]),e7=(0,c.useCallback)(a(function*(){if(N){W(!0);try{var e=yield N.applications({});eu(e||[])}catch(e){ee(e.message)}W(!1)}}),[N]),e3=(0,c.useCallback)((l=a(function*(e){if(N){W(!0),eN(null);try{var l=yield N.application({id:e});eg(l)}catch(e){eN(e.message)}W(!1)}}),function(e){return l.apply(this,arguments)}),[N]),le=(0,c.useCallback)(a(function*(){if(N){W(!0);try{var e=yield N.modules({});ep(e||[])}catch(e){ee(e.message)}W(!1)}}),[N]),ll=(0,c.useCallback)((r=a(function*(e){if(N){W(!0),eN(null);try{var l=yield N.module({id:e});ev(l)}catch(e){eN(e.message)}W(!1)}}),function(e){return r.apply(this,arguments)}),[N]),lr=(0,c.useCallback)(a(function*(){if(N){W(!0);try{var e=yield N.deviceGroups({});eb(e||[])}catch(e){ee(e.message)}W(!1)}}),[N]),lt=(0,c.useCallback)((i=a(function*(e){if(N){W(!0),eN(null);try{var l=yield Promise.all([N.deviceGroup({id:e}),N.devicesByGroup({id:e})]),r=u(l,2),t=r[0],n=r[1];eS(t),eB(n||[])}catch(e){eN(e.message)}W(!1)}}),function(e){return i.apply(this,arguments)}),[N]),ln=(0,c.useCallback)(a(function*(){if(N){W(!0);try{var e=yield N.mediaBoxes();eY(e||[])}catch(e){ee(e.message)}W(!1)}}),[N]),li=(0,c.useCallback)((o=a(function*(e){if(N){W(!0),eN(null);try{var l=yield N.mediaBox({id:e});eJ(l)}catch(e){eN(e.message)}W(!1)}}),function(e){return o.apply(this,arguments)}),[N]),lo=(0,c.useCallback)((x=a(function*(e){if(N){W(!0);try{var l=yield N.mediaFiles({boxId:e});eZ(l||[])}catch(e){ee(e.message)}W(!1)}}),function(e){return x.apply(this,arguments)}),[N]),la=(0,c.useCallback)((p=a(function*(e){if(N){W(!0),eN(null);try{var l=yield N.mediaFile({id:e});e1(l)}catch(e){eN(e.message)}W(!1)}}),function(e){return p.apply(this,arguments)}),[N]),lc=(0,c.useCallback)((f=a(function*(e){if(N&&ei){eL(!0),eP(null);try{yield N.controlDevice({id:ei._id,type:e}),eP({success:!0,message:`Command sent: ${e}`})}catch(e){eP({success:!1,message:e.message})}eL(!1)}}),function(e){return f.apply(this,arguments)}),[N,ei]),ld=(0,c.useCallback)(a(function*(e=!1){if(N&&ei&&Y){W(!0),eF(null),ej(null);try{e&&(yield N.controlDevice({id:ei._id,type:"take-screenshot"}),yield new Promise(e=>setTimeout(e,3e3)));var l=yield(0,g.he)(N,Y,ei._id,null,{preferThumbnail:!0});l.error?eF(l.error):ej(l)}catch(e){eF(e.message)}W(!1)}}),[N,ei,Y]),lu=T((0,c.useCallback)(()=>{N&&e5()},[N,e5]),e2),ls=T((0,c.useCallback)(()=>{N&&ei&&e8(ei._id)},[N,ei,e8]),e4),lh=T((0,c.useCallback)(()=>{N&&lr()},[N,lr]),e6),lg=T((0,c.useCallback)(()=>{N&&eE&&lt(eE._id)},[N,eE,lt]),e9);return K&&!Y?n(d.Box,{flexDirection:"column",children:[t(y,{workspace:Y,view:E}),t(b,{text:"Connecting to workspace..."})]}):Q&&!Y?n(d.Box,{flexDirection:"column",children:[t(y,{workspace:Y,view:E}),n(d.Text,{color:"red",children:["Error: ",Q]}),t(_,{})]}):n(d.Box,{flexDirection:"column",children:[t(y,{workspace:Y,view:E}),E===m.MAIN&&t(S,{onSelect:e=>{"exit"===e.value?v():(I(e.value),e.value===m.DEVICES?e5():e.value===m.APPS?e7():e.value===m.MODULES?le():e.value===m.GROUPS?lr():e.value===m.MEDIA_BOXES&&ln())},mediaEnabled:(0,g.wR)(Y),activityLogEnabled:!!(0,h.getActivityLogBaseUrl)()}),E===m.DEVICES&&t(B,{devices:er,loading:K,onSelect:e=>{if("back"===e.value)return void I(m.MAIN);if("refresh"===e.value){e5(),lu.resetCountdown();return}ea(null),W(!0),I(m.DEVICE_DETAIL),e8(e.value)},countdown:lu.countdown,lastRefreshTime:lu.lastRefreshTime}),E===m.DEVICE_DETAIL&&t(C,{device:ei,loading:K,error:eR,onSelect:e=>{if("back"===e.value){I(m.DEVICES),ea(null);return}if("refresh"===e.value){e8(ei._id),ls.resetCountdown();return}"control"===e.value&&(I(m.DEVICE_CONTROL),eP(null)),"screenshot"===e.value&&(I(m.DEVICE_SCREENSHOT),ej(null),eF(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){I(m.DEVICE_DETAIL),eP(null);return}lc(e.value)},controlling:ek,controlResult:eO}),E===m.DEVICE_SCREENSHOT&&t(L,{device:ei,screenshot:eG,loading:K,error:eV,onSelect:e=>{if("back"===e.value){I(m.DEVICE_DETAIL),ej(null),eF(null);return}"refresh"===e.value?ld(!1):"take"===e.value&&ld(!0)}}),E===m.APPS&&t(w,{apps:ed,loading:K,onSelect:e=>{"back"===e.value?I(m.MAIN):"refresh"===e.value?e7():(eg(null),W(!0),I(m.APP_DETAIL),e3(e.value))}}),E===m.APP_DETAIL&&t(O,{app:eh,loading:K,error:eR,onSelect:e=>{if("back"===e.value){I(m.APPS),eg(null);return}"refresh"===e.value?e3(eh._id):("short_edit"===e.value&&(I(m.APP_SHORT_EDIT),eN(null)),"project_init"===e.value&&(I(m.APP_PROJECT_INIT),eN(null)))}}),E===m.APP_SHORT_EDIT&&t(J,{instanceType:"application",instance:eh,client:N,onDone:a(function*(){return e3(eh._id)}),onCancel:()=>I(m.APP_DETAIL)}),E===m.APP_PROJECT_INIT&&t(eo,{type:"application",instance:eh,client:N,onDone:()=>I(m.APP_DETAIL),onCancel:()=>I(m.APP_DETAIL)}),E===m.MODULES&&t(P,{modules:ex,loading:K,onSelect:e=>{"back"===e.value?I(m.MAIN):"refresh"===e.value?le():(ev(null),W(!0),I(m.MODULE_DETAIL),ll(e.value))}}),E===m.MODULE_DETAIL&&t(M,{module:eT,loading:K,error:eR,onSelect:e=>{if("back"===e.value){I(m.MODULES),ev(null);return}"refresh"===e.value?ll(eT._id):("short_edit"===e.value&&(I(m.MODULE_SHORT_EDIT),eN(null)),"project_init"===e.value&&(I(m.MODULE_PROJECT_INIT),eN(null)))}}),E===m.MODULE_SHORT_EDIT&&t(J,{instanceType:"module",instance:eT,client:N,onDone:a(function*(){return ll(eT._id)}),onCancel:()=>I(m.MODULE_DETAIL)}),E===m.MODULE_PROJECT_INIT&&t(eo,{type:"module",instance:eT,client:N,onDone:()=>I(m.MODULE_DETAIL),onCancel:()=>I(m.MODULE_DETAIL)}),E===m.GROUPS&&t(R,{groups:e_,loading:K,onSelect:e=>{if("back"===e.value)return void I(m.MAIN);if("refresh"===e.value){lr(),lh.resetCountdown();return}eS(null),eB([]),W(!0),I(m.GROUP_DETAIL),lt(e.value)},countdown:lh.countdown,lastRefreshTime:lh.lastRefreshTime}),E===m.GROUP_DETAIL&&t(U,{group:eE,groupDevices:eA,loading:K,error:eR,onSelect:e=>{if("back"===e.value){I(m.GROUPS),eS(null),eB([]);return}"refresh"===e.value&&(lt(eE._id),lg.resetCountdown())},countdown:lg.countdown,lastRefreshTime:lg.lastRefreshTime}),E===m.ACTIVITY_LOG&&t(z,{onBack:()=>I(m.MAIN)}),E===m.MEDIA_BOXES&&t(G,{boxes:ez,loading:K,onSelect:e=>{"back"===e.value?I(m.MAIN):"refresh"===e.value?ln():(eJ(null),eZ([]),W(!0),I(m.MEDIA_BOX_DETAIL),li(e.value))}}),E===m.MEDIA_BOX_DETAIL&&t(j,{box:eX,loading:K,error:eR,onSelect:e=>{if("back"===e.value){I(m.MEDIA_BOXES),eJ(null),eZ([]);return}"refresh"===e.value?li(eX.id):"files"===e.value&&(eZ([]),e1(null),I(m.MEDIA_FILES),lo(eX.id))}}),E===m.MEDIA_FILES&&t($,{files:eW,box:eX,loading:K,onSelect:e=>{if("back"===e.value){I(m.MEDIA_BOX_DETAIL),e1(null);return}"refresh"===e.value?lo(eX.id):(e1(null),W(!0),I(m.MEDIA_FILE_DETAIL),la(e.value))}}),E===m.MEDIA_FILE_DETAIL&&t(V,{file:e0,loading:K,error:eR,onSelect:e=>{if("back"===e.value){I(m.MEDIA_FILES),e1(null);return}"refresh"===e.value&&la(e0.id)}}),t(_,{})]})};var ec="1"===process.env.BRICKS_CLI_DISTRIBUTION,ed=(o=a(function*(){if(ec)return void(0,d.render)(t(ea,{}));var e=(yield i.e(166).then(i.bind(i,29557))).TerminalInfoProvider;(0,d.render)(t(e,{children:t(ea,{})}))}),function(){return o.apply(this,arguments)})},77768(e,l,r){r.d(l,{BZ:()=>v,KN:()=>p,kU:()=>x,o0:()=>T,oz:()=>f});var t,n,i,o,a=r(99436),c=r(16928),d=r(79896),u=r(35317),s=r(10750),h=e=>{try{return(0,u.execSync)(`which ${e}`,{stdio:"ignore"}),!0}catch{return!1}},g=(e,l,r)=>new Promise((t,n)=>{var i=[e,...l].join(" "),o=(0,u.spawn)(i,[],{cwd:r,stdio:"pipe",shell:!0}),a=[];o.stderr.on("data",e=>a.push(e)),o.on("close",e=>{0===e?t():n(Error(Buffer.concat(a).toString().trim()||`Command failed with code ${e}`))}),o.on("error",n)}),m=(t=a(function*(e,l){try{var t=(yield r.e(75).then(r.bind(r,79491))).format;return(yield t(l,e,{trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100})).code}catch{}return e}),function(e,l){return t.apply(this,arguments)}),x=(e=[])=>{var l=e.find(e=>"application.json"===e.name);if(!l)return"bricks-ctor";try{var r=JSON.parse(l.input);return s(r.name||"bricks-ctor")}catch{return"bricks-ctor"}},p=(n=a(function*(e,l){var r;return Promise.all(e.map((r=a(function*(e){var r=c.join(l,e.name),t=e.input;return e.formatable&&(t=yield m(t,r)),{...e,filePath:r,content:t}}),function(e){return r.apply(this,arguments)})))}),function(e,l){return n.apply(this,arguments)}),f=e=>{e.forEach(e=>{d.mkdirSync(c.dirname(e.filePath),{recursive:!0}),d.writeFileSync(e.filePath,e.content)})},T=(i=a(function*(e,l={}){var r="function"==typeof l.onStatus?l.onStatus:()=>{},t=!1,n=!1;if(!1!==l.install&&h("bun")){r("Installing dependencies (bun install)...");try{yield g("bun",["install"],e),t=!0}catch{}}if(!1!==l.git&&h("git")){r("Initializing git repository...");try{yield g("git",["init"],e),yield g("git",["add","."],e),yield g("git",["-c 'user.name=BRICKS CLI'","-c 'user.email=cli@bricks.tools'","commit","-m 'chore: initialize commit'"],e),n=!0}catch{}}return{bunInstalled:t,gitInitialized:n}}),function(e){return i.apply(this,arguments)}),v=(o=a(function*(e,l,r){var t=r.client,n=r.output,i=r.outputAsTarget;if(!t)throw Error("client is required");if(!n)throw Error("output directory is required");var o=(e=>{for(var l=c.resolve(e);;){if(d.existsSync(c.join(l,"application.json"))||d.existsSync(c.join(l,"module.json")))return l;var r=c.dirname(l);if(r===l)return null;l=r}})(i?c.dirname(c.resolve(n)):n);if(o)throw Error(`Cannot initialize a new BRICKS project inside an existing project (${o}). Choose a directory outside the project.`);var a="application"===e,u=a?t.queries.applicationProject:t.queries.moduleProject,s=(yield t.query(u,{id:l,buildApplicationOnly:!1,setupGitHubActions:!1!==r.githubActions,setupAgents:!1!==r.agents,setupClaudeCode:!1!==r.claude,setupGeminiCLI:!0===r.gemini}))[a?"applicationProject":"moduleProject"];if(!s?.files)throw Error(`${e} project not found`);var h=x(s.files),g=i?c.resolve(n):c.resolve(n,h);if(d.existsSync(g))throw Error(`Directory already exists: ${g}`);d.mkdirSync(g,{recursive:!0}),f((yield p(s.files,g)));var m=yield T(g,r),v=m.bunInstalled,y=m.gitInitialized;return{success:!0,path:g,files:s.files.length,bunInstalled:v,gitInitialized:y}}),function(e,l,r){return o.apply(this,arguments)})}};