@fugood/bricks-cli 2.24.1-beta.2 → 2.24.1-beta.3
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/425.js +1 -1
- package/lib/737.js +1 -1
- package/lib/index.js +1 -1
- package/package.json +4 -4
package/lib/index.js
CHANGED
|
@@ -749,4 +749,4 @@ import{createRequire as e}from"node:module";const t=e(import.meta.url);import*as
|
|
|
749
749
|
name
|
|
750
750
|
}
|
|
751
751
|
}
|
|
752
|
-
`},94370:(e,t,a)=>{a.r(t),a.d(t,{default:()=>w,disableExperimentalFragmentVariables:()=>h,disableFragmentWarnings:()=>f,enableExperimentalFragmentVariables:()=>v,gql:()=>u,resetCaches:()=>m});var n=a(85608),i=a(93367),o=new Map,r=new Map,s=!0,p=!1;function l(e){return e.replace(/[\s,]+/g," ").trim()}function d(e){var t=new Set,a=[];return e.definitions.forEach(function(e){if("FragmentDefinition"===e.kind){var n=e.name.value,i=l((p=e.loc).source.body.substring(p.start,p.end)),o=r.get(n);o&&!o.has(i)?s&&console.warn("Warning: fragment with name "+n+" already exists.\ngraphql-tag enforces all fragment names across your application to be unique; read more about\nthis in the docs: http://dev.apollodata.com/core/fragments.html#unique-names"):o||r.set(n,o=new Set),o.add(i),t.has(i)||(t.add(i),a.push(e))}else a.push(e);var p}),(0,n.__assign)((0,n.__assign)({},e),{definitions:a})}function c(e){var t=l(e);if(!o.has(t)){var a=(0,i.qg)(e,{experimentalFragmentVariables:p,allowLegacyFragmentVariables:p});if(!a||"Document"!==a.kind)throw new Error("Not a valid GraphQL document.");o.set(t,function(e){var t=new Set(e.definitions);t.forEach(function(e){e.loc&&delete e.loc,Object.keys(e).forEach(function(a){var n=e[a];n&&"object"==typeof n&&t.add(n)})});var a=e.loc;return a&&(delete a.startToken,delete a.endToken),e}(d(a)))}return o.get(t)}function u(e){for(var t=[],a=1;a<arguments.length;a++)t[a-1]=arguments[a];"string"==typeof e&&(e=[e]);var n=e[0];return t.forEach(function(t,a){t&&"Document"===t.kind?n+=t.loc.source.body:n+=t,n+=e[a+1]}),c(n)}function m(){o.clear(),r.clear()}function f(){s=!1}function v(){p=!0}function h(){p=!1}var g,y=u,b=m,D=f,x=v,_=h;(g=u||(u={})).gql=y,g.resetCaches=b,g.disableFragmentWarnings=D,g.enableExperimentalFragmentVariables=x,g.disableExperimentalFragmentVariables=_,u.default=u;const w=u},96525:e=>{e.exports=function(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var n,i,o,r,s=[],p=!0,l=!1;try{if(o=(a=a.call(e)).next,0===t){if(Object(a)!==a)return;p=!1}else for(;!(p=(n=o.call(a)).done)&&(s.push(n.value),s.length!==t);p=!0);}catch(e){l=!0,i=e}finally{try{if(!p&&null!=a.return&&(r=a.return(),Object(r)!==r))return}finally{if(l)throw i}}return s}},e.exports.__esModule=!0,e.exports.default=e.exports},98472:(e,t,a)=>{a.d(t,{Ey:()=>v,JG:()=>p,MQ:()=>A,Z_:()=>l,qA:()=>f});var n=a(59841),i=a(59762),o=a(67714),r=a(25881),s=a(12039);class p{constructor(e){const t=new i.ou(s.Y.SOF,0,0,0,0);this.source=e,this.lastToken=t,this.token=t,this.line=1,this.lineStart=0}get[Symbol.toStringTag](){return"Lexer"}advance(){this.lastToken=this.token;return this.token=this.lookahead()}lookahead(){let e=this.token;if(e.kind!==s.Y.EOF)do{if(e.next)e=e.next;else{const t=h(this,e.end);e.next=t,t.prev=e,e=t}}while(e.kind===s.Y.COMMENT);return e}}function l(e){return e===s.Y.BANG||e===s.Y.DOLLAR||e===s.Y.AMP||e===s.Y.PAREN_L||e===s.Y.PAREN_R||e===s.Y.DOT||e===s.Y.SPREAD||e===s.Y.COLON||e===s.Y.EQUALS||e===s.Y.AT||e===s.Y.BRACKET_L||e===s.Y.BRACKET_R||e===s.Y.BRACE_L||e===s.Y.PIPE||e===s.Y.BRACE_R}function d(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function c(e,t){return u(e.charCodeAt(t))&&m(e.charCodeAt(t+1))}function u(e){return e>=55296&&e<=56319}function m(e){return e>=56320&&e<=57343}function f(e,t){const a=e.source.body.codePointAt(t);if(void 0===a)return s.Y.EOF;if(a>=32&&a<=126){const e=String.fromCodePoint(a);return'"'===e?"'\"'":`"${e}"`}return"U+"+a.toString(16).toUpperCase().padStart(4,"0")}function v(e,t,a,n,o){const r=e.line,s=1+a-e.lineStart;return new i.ou(t,a,n,r,s,o)}function h(e,t){const a=e.source.body,i=a.length;let o=t;for(;o<i;){const t=a.charCodeAt(o);switch(t){case 65279:case 9:case 32:case 44:++o;continue;case 10:++o,++e.line,e.lineStart=o;continue;case 13:10===a.charCodeAt(o+1)?o+=2:++o,++e.line,e.lineStart=o;continue;case 35:return g(e,o);case 33:return v(e,s.Y.BANG,o,o+1);case 36:return v(e,s.Y.DOLLAR,o,o+1);case 38:return v(e,s.Y.AMP,o,o+1);case 40:return v(e,s.Y.PAREN_L,o,o+1);case 41:return v(e,s.Y.PAREN_R,o,o+1);case 46:if(46===a.charCodeAt(o+1)&&46===a.charCodeAt(o+2))return v(e,s.Y.SPREAD,o,o+3);break;case 58:return v(e,s.Y.COLON,o,o+1);case 61:return v(e,s.Y.EQUALS,o,o+1);case 64:return v(e,s.Y.AT,o,o+1);case 91:return v(e,s.Y.BRACKET_L,o,o+1);case 93:return v(e,s.Y.BRACKET_R,o,o+1);case 123:return v(e,s.Y.BRACE_L,o,o+1);case 124:return v(e,s.Y.PIPE,o,o+1);case 125:return v(e,s.Y.BRACE_R,o,o+1);case 34:return 34===a.charCodeAt(o+1)&&34===a.charCodeAt(o+2)?N(e,o):D(e,o)}if((0,r.yp)(t)||45===t)return y(e,o,t);if((0,r.un)(t))return A(e,o);throw(0,n.I)(e.source,o,39===t?"Unexpected single quote character ('), did you mean to use a double quote (\")?":d(t)||c(a,o)?`Unexpected character: ${f(e,o)}.`:`Invalid character: ${f(e,o)}.`)}return v(e,s.Y.EOF,i,i)}function g(e,t){const a=e.source.body,n=a.length;let i=t+1;for(;i<n;){const e=a.charCodeAt(i);if(10===e||13===e)break;if(d(e))++i;else{if(!c(a,i))break;i+=2}}return v(e,s.Y.COMMENT,t,i,a.slice(t+1,i))}function y(e,t,a){const i=e.source.body;let o=t,p=a,l=!1;if(45===p&&(p=i.charCodeAt(++o)),48===p){if(p=i.charCodeAt(++o),(0,r.yp)(p))throw(0,n.I)(e.source,o,`Invalid number, unexpected digit after 0: ${f(e,o)}.`)}else o=b(e,o,p),p=i.charCodeAt(o);if(46===p&&(l=!0,p=i.charCodeAt(++o),o=b(e,o,p),p=i.charCodeAt(o)),69!==p&&101!==p||(l=!0,p=i.charCodeAt(++o),43!==p&&45!==p||(p=i.charCodeAt(++o)),o=b(e,o,p),p=i.charCodeAt(o)),46===p||(0,r.un)(p))throw(0,n.I)(e.source,o,`Invalid number, expected digit but got: ${f(e,o)}.`);return v(e,l?s.Y.FLOAT:s.Y.INT,t,o,i.slice(t,o))}function b(e,t,a){if(!(0,r.yp)(a))throw(0,n.I)(e.source,t,`Invalid number, expected digit but got: ${f(e,t)}.`);const i=e.source.body;let o=t+1;for(;(0,r.yp)(i.charCodeAt(o));)++o;return o}function D(e,t){const a=e.source.body,i=a.length;let o=t+1,r=o,p="";for(;o<i;){const i=a.charCodeAt(o);if(34===i)return p+=a.slice(r,o),v(e,s.Y.STRING,t,o+1,p);if(92===i){p+=a.slice(r,o);const t=117===a.charCodeAt(o+1)?123===a.charCodeAt(o+2)?x(e,o):_(e,o):T(e,o);p+=t.value,o+=t.size,r=o;continue}if(10===i||13===i)break;if(d(i))++o;else{if(!c(a,o))throw(0,n.I)(e.source,o,`Invalid character within String: ${f(e,o)}.`);o+=2}}throw(0,n.I)(e.source,o,"Unterminated string.")}function x(e,t){const a=e.source.body;let i=0,o=3;for(;o<12;){const e=a.charCodeAt(t+o++);if(125===e){if(o<5||!d(i))break;return{value:String.fromCodePoint(i),size:o}}if(i=i<<4|E(e),i<0)break}throw(0,n.I)(e.source,t,`Invalid Unicode escape sequence: "${a.slice(t,t+o)}".`)}function _(e,t){const a=e.source.body,i=w(a,t+2);if(d(i))return{value:String.fromCodePoint(i),size:6};if(u(i)&&92===a.charCodeAt(t+6)&&117===a.charCodeAt(t+7)){const e=w(a,t+8);if(m(e))return{value:String.fromCodePoint(i,e),size:12}}throw(0,n.I)(e.source,t,`Invalid Unicode escape sequence: "${a.slice(t,t+6)}".`)}function w(e,t){return E(e.charCodeAt(t))<<12|E(e.charCodeAt(t+1))<<8|E(e.charCodeAt(t+2))<<4|E(e.charCodeAt(t+3))}function E(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function T(e,t){const a=e.source.body;switch(a.charCodeAt(t+1)){case 34:return{value:'"',size:2};case 92:return{value:"\\",size:2};case 47:return{value:"/",size:2};case 98:return{value:"\b",size:2};case 102:return{value:"\f",size:2};case 110:return{value:"\n",size:2};case 114:return{value:"\r",size:2};case 116:return{value:"\t",size:2}}throw(0,n.I)(e.source,t,`Invalid character escape sequence: "${a.slice(t,t+2)}".`)}function N(e,t){const a=e.source.body,i=a.length;let r=e.lineStart,p=t+3,l=p,u="";const m=[];for(;p<i;){const i=a.charCodeAt(p);if(34===i&&34===a.charCodeAt(p+1)&&34===a.charCodeAt(p+2)){u+=a.slice(l,p),m.push(u);const n=v(e,s.Y.BLOCK_STRING,t,p+3,(0,o.OC)(m).join("\n"));return e.line+=m.length-1,e.lineStart=r,n}if(92!==i||34!==a.charCodeAt(p+1)||34!==a.charCodeAt(p+2)||34!==a.charCodeAt(p+3))if(10!==i&&13!==i)if(d(i))++p;else{if(!c(a,p))throw(0,n.I)(e.source,p,`Invalid character within String: ${f(e,p)}.`);p+=2}else u+=a.slice(l,p),m.push(u),13===i&&10===a.charCodeAt(p+1)?p+=2:++p,u="",l=p,r=p;else u+=a.slice(l,p),l=p+1,p+=4}throw(0,n.I)(e.source,p,"Unterminated string.")}function A(e,t){const a=e.source.body,n=a.length;let i=t+1;for(;i<n;){const e=a.charCodeAt(i);if(!(0,r.xr)(e))break;++i}return v(e,s.Y.NAME,t,i,a.slice(t,i))}},98706:(e,t,a)=>{const n=a(78323);t.implementation=class{constructor(e){const t=e[0],a=e[1];let i=null;if(void 0!==a&&(i=n.basicURLParse(a),"failure"===i))throw new TypeError("Invalid base URL");const o=n.basicURLParse(t,{baseURL:i});if("failure"===o)throw new TypeError("Invalid URL");this._url=o}get href(){return n.serializeURL(this._url)}set href(e){const t=n.basicURLParse(e);if("failure"===t)throw new TypeError("Invalid URL");this._url=t}get origin(){return n.serializeURLOrigin(this._url)}get protocol(){return this._url.scheme+":"}set protocol(e){n.basicURLParse(e+":",{url:this._url,stateOverride:"scheme start"})}get username(){return this._url.username}set username(e){n.cannotHaveAUsernamePasswordPort(this._url)||n.setTheUsername(this._url,e)}get password(){return this._url.password}set password(e){n.cannotHaveAUsernamePasswordPort(this._url)||n.setThePassword(this._url,e)}get host(){const e=this._url;return null===e.host?"":null===e.port?n.serializeHost(e.host):n.serializeHost(e.host)+":"+n.serializeInteger(e.port)}set host(e){this._url.cannotBeABaseURL||n.basicURLParse(e,{url:this._url,stateOverride:"host"})}get hostname(){return null===this._url.host?"":n.serializeHost(this._url.host)}set hostname(e){this._url.cannotBeABaseURL||n.basicURLParse(e,{url:this._url,stateOverride:"hostname"})}get port(){return null===this._url.port?"":n.serializeInteger(this._url.port)}set port(e){n.cannotHaveAUsernamePasswordPort(this._url)||(""===e?this._url.port=null:n.basicURLParse(e,{url:this._url,stateOverride:"port"}))}get pathname(){return this._url.cannotBeABaseURL?this._url.path[0]:0===this._url.path.length?"":"/"+this._url.path.join("/")}set pathname(e){this._url.cannotBeABaseURL||(this._url.path=[],n.basicURLParse(e,{url:this._url,stateOverride:"path start"}))}get search(){return null===this._url.query||""===this._url.query?"":"?"+this._url.query}set search(e){const t=this._url;if(""===e)return void(t.query=null);const a="?"===e[0]?e.substring(1):e;t.query="",n.basicURLParse(a,{url:t,stateOverride:"query"})}get hash(){return null===this._url.fragment||""===this._url.fragment?"":"#"+this._url.fragment}set hash(e){if(""===e)return void(this._url.fragment=null);const t="#"===e[0]?e.substring(1):e;this._url.fragment="",n.basicURLParse(t,{url:this._url,stateOverride:"fragment"})}toJSON(){return this.href}}},99436:e=>{function t(e,t,a,n,i,o,r){try{var s=e[o](r),p=s.value}catch(e){return void a(e)}s.done?t(p):Promise.resolve(p).then(n,i)}e.exports=function(e){return function(){var a=this,n=arguments;return new Promise(function(i,o){var r=e.apply(a,n);function s(e){t(r,i,o,s,p,"next",e)}function p(e){t(r,i,o,s,p,"throw",e)}s(void 0)})}},e.exports.__esModule=!0,e.exports.default=e.exports},99690:(e,t,a)=>{const{humanReadableArgName:n}=a(41762);t.Help=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){const t=e.commands.filter(e=>!e._hidden),a=e._getHelpCommand();return a&&!a._hidden&&t.push(a),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){const a=e=>e.short?e.short.replace(/^-/,""):e.long.replace(/^--/,"");return a(e).localeCompare(a(t))}visibleOptions(e){const t=e.options.filter(e=>!e.hidden),a=e._getHelpOption();if(a&&!a.hidden){const n=a.short&&e._findOption(a.short),i=a.long&&e._findOption(a.long);n||i?a.long&&!i?t.push(e.createOption(a.long,a.description)):a.short&&!n&&t.push(e.createOption(a.short,a.description)):t.push(a)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];const t=[];for(let a=e.parent;a;a=a.parent){const e=a.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){const t=e.registeredArguments.map(e=>n(e)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,a)=>Math.max(e,t.subcommandTerm(a).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,a)=>Math.max(e,t.optionTerm(a).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,a)=>Math.max(e,t.optionTerm(a).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,a)=>Math.max(e,t.argumentTerm(a).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let a="";for(let t=e.parent;t;t=t.parent)a=t.name()+" "+a;return a+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){const t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),void 0!==e.defaultValue){(e.required||e.optional||e.isBoolean()&&"boolean"==typeof e.defaultValue)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`)}return void 0!==e.presetArg&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),void 0!==e.envVar&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){const t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),void 0!==e.defaultValue&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){const a=`(${t.join(", ")})`;return e.description?`${e.description} ${a}`:a}return e.description}formatHelp(e,t){const a=t.padWidth(e,t),n=t.helpWidth||80;function i(e,i){if(i){const o=`${e.padEnd(a+2)}${i}`;return t.wrap(o,n-2,a+2)}return e}function o(e){return e.join("\n").replace(/^/gm," ".repeat(2))}let r=[`Usage: ${t.commandUsage(e)}`,""];const s=t.commandDescription(e);s.length>0&&(r=r.concat([t.wrap(s,n,0),""]));const p=t.visibleArguments(e).map(e=>i(t.argumentTerm(e),t.argumentDescription(e)));p.length>0&&(r=r.concat(["Arguments:",o(p),""]));const l=t.visibleOptions(e).map(e=>i(t.optionTerm(e),t.optionDescription(e)));if(l.length>0&&(r=r.concat(["Options:",o(l),""])),this.showGlobalOptions){const a=t.visibleGlobalOptions(e).map(e=>i(t.optionTerm(e),t.optionDescription(e)));a.length>0&&(r=r.concat(["Global Options:",o(a),""]))}const d=t.visibleCommands(e).map(e=>i(t.subcommandTerm(e),t.subcommandDescription(e)));return d.length>0&&(r=r.concat(["Commands:",o(d),""])),r.join("\n")}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,a,n=40){const i=new RegExp("[\\n][ \\f\\t\\v - \ufeff]+");if(e.match(i))return e;const o=t-a;if(o<n)return e;const r=e.slice(0,a),s=e.slice(a).replace("\r\n","\n"),p=" ".repeat(a),l="\\s",d=new RegExp(`\n|.{1,${o-1}}([${l}]|$)|[^${l}]+?([${l}]|$)`,"g");return r+(s.match(d)||[]).map((e,t)=>"\n"===e?"":(t>0?p:"")+e.trimEnd()).join("\n")}}}},g={};function y(e){var t=g[e];if(void 0!==t)return t.exports;var a=g[e]={id:e,loaded:!1,exports:{}};return h[e].call(a.exports,a,a.exports,y),a.loaded=!0,a.exports}y.m=h,s="function"==typeof Symbol,p=s?Symbol("webpack queues"):"__webpack_queues__",l=s?Symbol("webpack exports"):"__webpack_exports__",d=s?Symbol("webpack error"):"__webpack_error__",c=e=>{e&&e.d<1&&(e.d=1,e.forEach(e=>e.r--),e.forEach(e=>e.r--?e.r++:e()))},y.a=(e,t,a)=>{var n;a&&((n=[]).d=-1);var i,o,r,s=new Set,u=e.exports,m=new Promise((e,t)=>{r=t,o=e});m[l]=u,m[p]=e=>(n&&e(n),s.forEach(e),m.catch(e=>{})),e.exports=m,t(e=>{var t;i=(e=>e.map(e=>{if(null!==e&&"object"==typeof e){if(e[p])return e;if(e.then){var t=[];t.d=0,e.then(e=>{a[l]=e,c(t)},e=>{a[d]=e,c(t)});var a={};return a[p]=e=>e(t),a}}var n={};return n[p]=e=>{},n[l]=e,n}))(e);var a=()=>i.map(e=>{if(e[d])throw e[d];return e[l]}),o=new Promise(e=>{(t=()=>e(a)).r=0;var o=e=>e!==n&&!s.has(e)&&(s.add(e),e&&!e.d&&(t.r++,e.push(t)));i.map(e=>e[p](o))});return t.r?o:a()},e=>(e?r(m[d]=e):o(u),c(n))),n&&n.d<0&&(n.d=0)},y.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return y.d(t,{a:t}),t},m=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,y.t=function(e,t){if(1&t&&(e=this(e)),8&t)return e;if("object"==typeof e&&e){if(4&t&&e.__esModule)return e;if(16&t&&"function"==typeof e.then)return e}var a=Object.create(null);y.r(a);var n={};u=u||[null,m({}),m([]),m(m)];for(var i=2&t&&e;("object"==typeof i||"function"==typeof i)&&!~u.indexOf(i);i=m(i))Object.getOwnPropertyNames(i).forEach(t=>n[t]=()=>e[t]);return n.default=()=>e,y.d(a,n),a},y.d=(e,t)=>{for(var a in t)y.o(t,a)&&!y.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},y.f={},y.e=e=>Promise.all(Object.keys(y.f).reduce((t,a)=>(y.f[a](e,t),t),[])),y.u=e=>e+".js",y.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),y.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},y.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),f={57:0},v=e=>{var t,a,{__webpack_esm_ids__:n,__webpack_esm_modules__:i,__webpack_esm_runtime__:o}=e,r=0;for(t in i)y.o(i,t)&&(y.m[t]=i[t]);for(o&&o(y);r<n.length;r++)a=n[r],y.o(f,a)&&f[a]&&f[a][0](),f[n[r]]=0},y.f.j=(e,t)=>{var a=y.o(f,e)?f[e]:void 0;if(0!==a)if(a)t.push(a[1]);else{var n=import("./"+y.u(e)).then(v,t=>{throw 0!==f[e]&&(f[e]=void 0),t});n=Promise.race([n,new Promise(t=>a=f[e]=[t])]),t.push(a[1]=n)}};var b=y(99436),D=y(65181);const{DM:x,gu:_,er:w,Ww:E,b7:T,Di:N,a2:A,uB:O,ef:F,c$:S,_V:C}=D;var k=y(88568),I=y(74752),$=()=>Boolean(process.stdin.isTTY&&process.stdout.isTTY&&"function"==typeof process.stdin.setRawMode),j=y(29790);const R=t("readline");var V,P,B,L,M,U=y(50700),q=e=>{console.log(JSON.stringify(e,null,2))},z=(e,t={})=>{console.error(JSON.stringify({ok:!1,error:{message:e,...t}},null,2))},G=(e,t=4)=>e?e.length<=2*t?"*".repeat(e.length):`${e.slice(0,t)}…${e.slice(-t)}`:null,Y=(V=b(function*(){var e=(0,I.getCurrentProfile)(),t=(0,I.getCurrentProfileSource)(),a=(0,I.getTokenInfo)(e),n=(0,I.getBaseUrl)();if(!a?.token)return{ok:!1,profile:e,profileSource:t,baseUrl:n,auth:{available:!1,source:"missing",workspaceId:null,workspaceName:null,createdAt:null,tokenPreview:null},workspace:null,error:null};try{var i=(0,U.createClient)(n,a.token),o=yield i.workspace();return{ok:!0,profile:e,profileSource:t,baseUrl:n,auth:{available:!0,source:"config",workspaceId:o?._id||a.workspaceId||null,workspaceName:o?.name||a.workspaceName||null,createdAt:a.createdAt||null,tokenPreview:G(a.token)},workspace:o?{_id:o._id,name:o.name,description:o.description||null}:null,error:null}}catch(i){return{ok:!1,profile:e,profileSource:t,baseUrl:n,auth:{available:!0,source:"config",workspaceId:a.workspaceId||null,workspaceName:a.workspaceName||null,createdAt:a.createdAt||null,tokenPreview:G(a.token)},workspace:null,error:{message:i.message}}}}),function(){return V.apply(this,arguments)}),Q=new O("auth").description("Authentication and token management");Q.command("login").description("Login with a one-time passcode from BRICKS Controller (recommended)").argument("[passcode]","One-time passcode from BRICKS Controller").option("-p, --profile <profile>","Profile name to save the token").option("-n, --name <name>","Profile display name").action((P=b(function*(e,t){var a,n,i=t.profile||(0,I.getCurrentProfile)(),o=t.name,r=e;r||(console.log(k.Ay.cyan("Generate a one-time passcode from BRICKS Controller:")),console.log(k.Ay.gray(" 1. Open the link below (or select your workspace first)")),console.log(` ${k.Ay.underline.blue("https://control.bricks.tools/#/?action=manage-tokens")}`),console.log(k.Ay.gray(' 2. Click "Generate OTP" to create a one-time passcode\n')),(r=yield(a="Enter passcode: ",n=R.createInterface({input:process.stdin,output:process.stdout}),new Promise(e=>{n.question(a,t=>{n.close(),e(t.trim())})})))||(console.log(k.Ay.red("Passcode is required")),process.exit(1)));var s=(0,j.default)("Validating passcode...").start();try{var p=(0,U.createPublicClient)((0,I.getBaseUrl)()),l=yield p.checkWorkspaceOTP(r);l.valid||(s.fail(`Invalid passcode: ${l.error||"Unknown error"}`),process.exit(1)),s.text=`Exchanging passcode for token (workspace: ${l.workspaceName})...`;var d=yield p.exchangeWorkspaceOTP(r);d.token||(s.fail("Failed to obtain token"),process.exit(1));var c=(0,U.createClient)((0,I.getBaseUrl)(),d.token),u=yield c.workspace();u||(s.fail("Token validation failed"),process.exit(1)),(0,I.setToken)(i,{token:d.token,name:o||u.name,workspaceId:u._id,workspaceName:u.name}),(0,I.setCurrentProfile)(i),s.succeed(`Logged in to workspace: ${k.Ay.green(u.name)} (profile: ${k.Ay.cyan(i)})`)}catch(e){s.fail(`Login failed: ${e.message}`),process.exit(1)}}),function(e,t){return P.apply(this,arguments)})),Q.command("login-token").description("Login with a workspace token directly").option("-t, --token <token>","Workspace token").option("-p, --profile <profile>","Profile name to save the token").option("-n, --name <name>","Profile display name").action((B=b(function*(e){var t=e.profile||(0,I.getCurrentProfile)(),a=e.token,n=e.name;a||(console.error(k.Ay.red("Error: Token is required. Use -t or --token to provide it.")),console.log(k.Ay.gray("\nYou can get a workspace token from BRICKS Controller:")+k.Ay.underline.blue("https://control.bricks.tools/#/?action=manage-tokens")),console.log(` ${k.Ay.underline.blue("https://control.bricks.tools/#/?action=manage-tokens")}`),console.log(k.Ay.gray("Select your workspace and create a new token.\n")),console.log(k.Ay.yellow("Tip: Use `bricks auth login` for a simpler OTP-based login.")),process.exit(1));var i=(0,j.default)("Validating token...").start();try{var o=(0,U.createClient)((0,I.getBaseUrl)(),a),r=yield o.workspace();r||(i.fail("Invalid token or unable to access workspace"),process.exit(1)),(0,I.setToken)(t,{token:a,name:n||r.name,workspaceId:r._id,workspaceName:r.name}),(0,I.setCurrentProfile)(t),i.succeed(`Logged in to workspace: ${k.Ay.green(r.name)} (profile: ${k.Ay.cyan(t)})`)}catch(e){i.fail(`Login failed: ${e.message}`),process.exit(1)}}),function(e){return B.apply(this,arguments)})),Q.command("logout").description("Remove saved token").option("-p, --profile <profile>","Profile to remove").option("-a, --all","Remove all profiles").action((L=b(function*(e){var t=e.profile;if(e.all)return(0,I.listProfiles)().forEach(e=>(0,I.removeToken)(e.name)),void console.log(k.Ay.green("All profiles removed"));var a=t||(0,I.getCurrentProfile)();(0,I.getTokenInfo)(a)?((0,I.removeToken)(a),console.log(k.Ay.green(`Logged out from profile: ${a}`))):console.log(k.Ay.yellow(`No token found for profile: ${a}`))}),function(e){return L.apply(this,arguments)})),Q.command("status").description("Show current authentication status").option("-j, --json","Output as JSON").action((M=b(function*(e){var t=(0,I.getCurrentProfile)(),a=(0,I.getTokenInfo)(t);if(!a)return e.json?void q(yield Y()):(console.log(k.Ay.yellow("Not logged in")),void console.log(k.Ay.gray("Use `bricks auth login` to login")));if(e.json)q(yield Y());else{var n=(0,j.default)("Checking connection...").start();try{var i=(0,U.createClient)((0,I.getBaseUrl)(),a.token),o=yield i.workspace();n.stop(),console.log(k.Ay.bold("\nAuthentication Status")),console.log("─".repeat(40)),console.log(`Profile: ${k.Ay.cyan(t)}`),console.log(`Workspace: ${k.Ay.green(o.name)}`),console.log(`Workspace ID: ${k.Ay.gray(o._id)}`);var r=(0,I.getBaseUrl)(),s=a.baseUrl;console.log(`Base URL: ${k.Ay.gray(r)}${s?"":k.Ay.gray(" (global)")}`),console.log(`Logged in: ${k.Ay.gray(a.createdAt)}`),console.log("─".repeat(40))}catch(e){n.fail(`Connection failed: ${e.message}`)}}}),function(e){return M.apply(this,arguments)})),Q.command("list").description("List all saved profiles").action(()=>{var e=(0,I.listProfiles)();if(0===e.length)return console.log(k.Ay.yellow("No saved profiles")),void console.log(k.Ay.gray("Use `bricks auth login` to login"));console.log(k.Ay.bold("\nSaved Profiles")),console.log("─".repeat(60)),e.forEach(e=>{var t=e.current?k.Ay.green("● "):" ",a=e.current?k.Ay.green(e.name):e.name,n=e.baseUrl?k.Ay.gray(` [${e.baseUrl}]`):"";console.log(`${t}${a.padEnd(15)} ${k.Ay.gray(e.workspaceName||"Unknown")}${n}`)}),console.log("─".repeat(60))}),Q.command("use <profile>").description("Switch to a different profile").action(e=>{var t=(0,I.getTokenInfo)(e);if(!t)return console.log(k.Ay.red(`Profile not found: ${e}`)),void console.log(k.Ay.gray("Use `bricks auth list` to see available profiles"));(0,I.setCurrentProfile)(e),console.log(k.Ay.green(`Switched to profile: ${e}`)),t.workspaceName&&console.log(k.Ay.gray(`Workspace: ${t.workspaceName}`))}),Q.command("set-url <url>").description("Set the base URL for the current profile").option("-g, --global","Set the global base URL instead of per-profile").action((e,t)=>{if(t.global)(0,I.setBaseUrl)(e),console.log(k.Ay.green(`Global base URL set to: ${e}`));else{var a=(0,I.getCurrentProfile)();(0,I.setBaseUrl)(e,a),console.log(k.Ay.green(`Base URL for profile ${k.Ay.cyan(a)} set to: ${e}`))}});var J=y(68832),H=y(47336),W=e=>String(e||"").trim().toLowerCase(),K=({resource:e,query:t,items:a,fields:n,selectedBy:i=null})=>{var o=W(t),r=a.filter(e=>n.some(t=>W(((e,t)=>t.split(".").reduce((e,t)=>e?.[t],e)??null)(e,t))===o)),s=null,p=i;return"id"===i?s=a[0]||null:1===r.length?(s=r[0],p="exact"):1===a.length&&(s=a[0],p="single"),{resource:e,query:t,exactMatchCount:r.length,matchCount:a.length,selectedBy:p,ambiguous:a.length>1&&!s,resolved:s,matches:a}},X=function(){var e=b(function*(e){try{return yield e()}catch(e){if(/not found/i.test(e.message))return null;throw e}});return function(t){return e.apply(this,arguments)}}(),Z=(e,t,a)=>({label:e,ok:t,detail:a}),ee=e=>null==e?k.Ay.gray("N/A"):"object"==typeof e?k.Ay.gray(JSON.stringify(e,null,2)):String(e),te=({action:e,target:t,request:a,checks:n=[],json:i=!1})=>{i?q({ok:!0,dryRun:!0,action:e,target:t||null,request:a||null,checks:n}):(console.log(k.Ay.bold(`\nDry Run: ${e}`)),console.log("─".repeat(60)),t&&(console.log(k.Ay.bold("Target")),Object.entries(t).forEach(([e,t])=>{console.log(`${e}: ${ee(t)}`)})),a&&(console.log(`\n${k.Ay.bold("Request")}`),Object.entries(a).forEach(([e,t])=>{console.log(`${e}: ${ee(t)}`)})),n.length>0&&(console.log(`\n${k.Ay.bold("Checks")}`),n.forEach(e=>{var t=e.ok?k.Ay.green("OK"):k.Ay.red("FAIL"),a=e.detail?` ${e.detail}`:"";console.log(`${t} ${e.label}${a}`)})),console.log("─".repeat(60)))},ae=({action:e,target:t,result:a=null,json:n=!1,message:i})=>{n?q({ok:!0,dryRun:!1,action:e,target:t||null,result:a}):i&&console.log(i)},ne=/^(\d+)(s|m|h|d|w)$/,ie={s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5};function oe(e){var t=e.match(ne);if(t){var a=parseInt(t[1],10),n=ie[t[2]];return new Date(Date.now()-a*n).toISOString()}var i=new Date(e);if(isNaN(i.getTime()))throw new Error(`Invalid time format: "${e}". Use ISO 8601 or relative (e.g. 1h, 30m, 2d)`);return i.toISOString()}var re,se,pe,le,de,ce,ue,me=()=>{var e=(0,I.getCurrentProfile)(),t=(0,I.getToken)(e);return t||(console.error(k.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,U.createClient)((0,I.getBaseUrl)(),t)},fe=e=>{if(!e)return k.Ay.gray("○ Unknown");var t=Date.now()-new Date(e).getTime();if(t<=3e5)return k.Ay.green("● Online");var a=Math.floor(t/6e4);if(a<60)return k.Ay.yellow(`○ Offline (${a}m ago)`);var n=Math.floor(a/60);if(n<24)return k.Ay.red(`○ Offline (${n}h ago)`);var i=Math.floor(n/24);return k.Ay.red(`○ Offline (${i}d ago)`)},ve=e=>e.name||e.device_name||"Unnamed",he=(e,t)=>({id:e?._id||t,name:ve(e),deviceName:e?.device_name||null}),ge=function(){var e=b(function*(e,t){var a=yield e.device({id:t});if(!a)throw new Error("Device not found");return a});return function(t,a){return e.apply(this,arguments)}}(),ye=function(){var e=b(function*({id:e,type:t,eventPayload:a,options:n,progressMessage:i,successMessage:o,failureMessage:r="Failed to control device"}){var s=me(),p=n.json?null:(0,j.default)(i).start();try{var l=yield ge(s,e),d=he(l,e);if(n.dryRun)return p&&p.stop(),void te({action:"device.control",target:d,request:{type:t,eventPayload:a||null},checks:[Z("device exists",!0,`${d.name} (${d.id})`)],json:n.json});yield s.controlDevice({id:e,type:t,eventPayload:a}),p?p.succeed(o):ae({action:"device.control",target:d,result:{type:t,eventPayload:a||null},json:!0})}catch(a){n.json?z(a.message,{action:"device.control",target:{id:e},type:t}):p.fail(`${r}: ${a.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}(),be=new O("device").description("Device management");be.command("list").description("List all devices").option("-k, --keyword <keyword>","Filter by keyword").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){var t=me(),a=(0,j.default)("Fetching devices...").start();try{var n=yield t.devices({keyword:e.keyword});if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(k.Ay.yellow("No devices found"));console.log(k.Ay.bold("\nDevices")),console.log("─".repeat(80)),n.forEach(e=>{var t=e.entry_detail?.watch_dog_timer?.last_alive_time,a=fe(t),n=e.entry_detail?.application?.name||k.Ay.gray("No app bound");console.log(`${a} ${k.Ay.cyan(e.name||e.device_name)}`),console.log(` ID: ${k.Ay.gray(e._id)}`),console.log(` App: ${n}`),console.log()})}catch(e){a.fail(`Failed to list devices: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),be.command("get <id>").description("Get device details").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=me(),n=(0,j.default)("Fetching device...").start();try{var i=yield a.device({id:e});if(n.stop(),i||(console.log(k.Ay.red("Device not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(i,null,2));var o=i.entry_detail?.watch_dog_timer?.last_alive_time,r=fe(o);if(console.log(k.Ay.bold(`\nDevice: ${i.name||i.device_name}`)),console.log("─".repeat(60)),console.log(`Status: ${r}`),console.log(`ID: ${k.Ay.gray(i._id)}`),console.log(`Device Name: ${i.device_name||k.Ay.gray("N/A")}`),console.log(`Description: ${i.description||k.Ay.gray("N/A")}`),console.log(`Tags: ${i.tags?.join(", ")||k.Ay.gray("None")}`),console.log(`Created: ${k.Ay.gray(i.create_datetime||"N/A")}`),console.log(`Modified: ${k.Ay.gray(i.last_modify_datetime||"N/A")}`),i.entry_detail){var s=i.entry_detail;if(console.log(`\n${k.Ay.bold("Entry Details")}`),console.log(`Type: ${s.type||k.Ay.gray("N/A")}`),console.log(`Unique ID: ${k.Ay.gray(s.unique_id||"N/A")}`),console.log(`Version: ${s.operation_version||k.Ay.gray("N/A")}`),console.log(`Mode: ${s.operation_mode||k.Ay.gray("N/A")}`),Array.isArray(s.screen)&&s.screen.length>0)console.log(`\n${k.Ay.bold("Screens")} (${s.screen.length})`),s.screen.forEach((e,t)=>{var a=e.resolution,n=a?`${a.width}x${a.height} @${a.scale}x`:"N/A",i=e.master?k.Ay.green(" (master)"):"",o=e.orientation?` [${e.orientation}]`:"",r=e.touch?.available?k.Ay.cyan(` touch:${e.touch.touch_point}pt`):"";console.log(` ${t+1}. ${e.title||"Screen"}${i}${o} - ${n}${r}`)});else if(s.screen?.resolution){var p=s.screen.resolution;console.log(`Resolution: ${p.width}x${p.height} @${p.scale}x`)}var l=null!=s.memory_usage,d=null!=s.disk_usage;if(l||d){if(console.log(`\n${k.Ay.bold("System Resources")}`),l){var c=Array.isArray(s.memory_usage)?s.memory_usage[0]:s.memory_usage,u=Math.round(100*c),m=k.Ay.green;u>80?m=k.Ay.red:u>60&&(m=k.Ay.yellow),console.log(`Memory: ${m(`${u}%`)}`)}if(d){var f=Array.isArray(s.disk_usage)?s.disk_usage[0]:s.disk_usage,v=Math.round(100*f),h=k.Ay.green;v>90?h=k.Ay.red:v>75&&(h=k.Ay.yellow),console.log(`Disk: ${h(`${v}%`)}`)}}var g=[];if(s.sound?.available&&g.push("Sound"),s.camera?.available&&g.push("Camera"),s.audio_in?.available&&g.push("Audio Input"),g.length>0&&(console.log(`\n${k.Ay.bold("Capabilities")}`),console.log(`Available: ${g.join(", ")}`),s.camera?.channel?.length>0&&s.camera.channel.forEach(e=>{var t=e.resolution?`${e.resolution.width}x${e.resolution.height}`:"";console.log(` Camera: ${e.title||"Camera"} ${t} [${e.orientation||"N/A"}]`)})),s.local_sync){var y=s.local_sync;console.log(`\n${k.Ay.bold("Local Sync")}`),console.log(`Role: ${y.is_main?k.Ay.cyan("Main"):"Secondary"}`),null!=y.peer_count&&console.log(`Peers: ${y.peer_count}`),null!=y.mean_latency&&console.log(`Latency: ${y.mean_latency.toFixed(2)}ms`)}if(s.update){var b=s.update;console.log(`\n${k.Ay.bold("Update Status")}`),console.log(`Needs Update: ${b.need_update?k.Ay.yellow("Yes"):k.Ay.green("No")}`),b.current_version&&console.log(`App Version: ${b.current_version}`),b.running_mode&&console.log(`Running Mode: ${b.running_mode}`),b.last_update_at&&console.log(`Last Update: ${k.Ay.gray(b.last_update_at)}`)}if(s.watch_dog_timer){var D=s.watch_dog_timer;console.log(`\n${k.Ay.bold("Watchdog")}`),console.log(`Alive: ${D.alive?k.Ay.green("Yes"):k.Ay.red("No")}`),D.last_launch_time&&console.log(`Last Launch: ${k.Ay.gray(D.last_launch_time)}`),D.last_alive_time&&console.log(`Last Alive: ${k.Ay.gray(D.last_alive_time)}`)}}i.bound_application&&(console.log(`\n${k.Ay.bold("Bound Application")}`),console.log(`Name: ${i.bound_application.name}`),console.log(`ID: ${k.Ay.gray(i.bound_application._id)}`)),i.env?.variables&&Object.keys(i.env.variables).length>0&&(console.log(`\n${k.Ay.bold("Environment Variables")}`),Object.entries(i.env.variables).forEach(([e,t])=>{console.log(` ${k.Ay.cyan(e)}: ${t}`)})),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get device: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),be.command("resolve <query>").description("Resolve a device name or ID to stable IDs").option("-l, --limit <limit>","Limit search results",e=>Number.parseInt(e,10),10).option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=me(),n=t.json?null:(0,j.default)("Resolving device...").start();try{var i=yield X(()=>a.device({id:e})),o=i||!e?i?[i]:[]:yield a.devices({keyword:e,paginate:{limit:t.limit}}),r=K({resource:"device",query:e,items:i?[i]:o||[],fields:["_id","name","device_name"],selectedBy:i?"id":null});if(n&&n.stop(),t.json)return void q(r);if(r.resolved){var s=r.resolved;return console.log(k.Ay.bold("\nResolved Device")),console.log("─".repeat(60)),console.log(`Name: ${k.Ay.cyan(s.name||s.device_name||"Unnamed")}`),console.log(`ID: ${k.Ay.gray(s._id)}`),console.log(`Selected By: ${r.selectedBy}`),void console.log("─".repeat(60))}if(0===r.matches.length)return void console.log(k.Ay.yellow(`No devices matched "${e}"`));console.log(k.Ay.bold(`\nMatching Devices (${r.matches.length})`)),console.log("─".repeat(80)),r.matches.forEach(e=>{console.log(`${k.Ay.cyan(e.name||e.device_name||"Unnamed")} ${k.Ay.gray(e._id)}`)}),console.log("─".repeat(80))}catch(t){n?n.fail(`Failed to resolve device: ${t.message}`):z(t.message,{resource:"device",query:e}),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),be.command("bind <passcode>").description("Bind a new device using passcode").option("-n, --name <name>","Device name").option("--dry-run","Validate inputs and show the device binding plan without creating a device").option("-j, --json","Output as JSON").action((re=b(function*(e,t){var a=me(),n=t.json?null:(0,j.default)("Checking passcode...").start();try{var i=yield a.checkBindDevicePasscode({passcode:e});i||(t.json?z("Invalid passcode or expired",{action:"device.bind"}):n.fail("Invalid passcode or expired"),process.exit(1));var o={name:t.name||i.payload?.deviceName||"CLI Device",deviceName:i.payload?.deviceName||null};if(t.dryRun)return n&&n.stop(),void te({action:"device.bind",target:o,request:{passcodePreview:G(e),requestedName:t.name||null,inferredName:i.payload?.deviceName||null},checks:[Z("passcode is valid",!0),Z("device name resolved",!0,o.name)],json:t.json});n&&(n.text="Binding device...");var r=yield a.createDevice({bindPasscode:e,name:o.name,deviceName:i.payload?.deviceName});t.json?ae({action:"device.bind",target:he(r,r._id),result:{inferredName:i.payload?.deviceName||null},json:!0}):(n.succeed(`Device bound successfully: ${k.Ay.green(r.name)}`),console.log(k.Ay.gray(`Device ID: ${r._id}`)))}catch(e){t.json?z(e.message,{action:"device.bind"}):n.fail(`Failed to bind device: ${e.message}`),process.exit(1)}}),function(e,t){return re.apply(this,arguments)})),be.command("control <id> <type>").description("Control a device").option("-p, --payload <json>","Event payload as JSON").option("--dry-run","Validate inputs and show the control request without sending it").option("-j, --json","Output as JSON").action((se=b(function*(e,t,a){try{var n;a.payload&&(n=JSON.parse(a.payload)),yield ye({id:e,type:t,eventPayload:n,options:a,progressMessage:`Sending ${t} to device...`,successMessage:`Control event sent: ${k.Ay.green(t)}`,failureMessage:"Failed to control device"})}catch(n){a.json?z(n.message,{action:"device.control",target:{id:e},type:t}):console.error(k.Ay.red(`Failed to control device: ${n.message}`)),process.exit(1)}}),function(e,t,a){return se.apply(this,arguments)})),be.command("refresh <id>").description("Refresh device application").option("--dry-run","Validate inputs and show the refresh request without sending it").option("-j, --json","Output as JSON").action((pe=b(function*(e,t){yield ye({id:e,type:"refresh",options:t,progressMessage:"Refreshing device...",successMessage:"Device refreshed",failureMessage:"Failed to refresh device"})}),function(e,t){return pe.apply(this,arguments)})),be.command("clear-cache <id>").description("Clear device cache").option("--dry-run","Validate inputs and show the cache-clear request without sending it").option("-j, --json","Output as JSON").action((le=b(function*(e,t){yield ye({id:e,type:"clear-cache",options:t,progressMessage:"Clearing cache...",successMessage:"Cache cleared",failureMessage:"Failed to clear cache"})}),function(e,t){return le.apply(this,arguments)})),be.command("screenshot <id>").description("Take device screenshot and save to file").option("-o, --output <path>","Output file path").option("--no-take","Only fetch existing screenshot without taking a new one").action((de=b(function*(e,t){var a=me(),n=(0,j.default)("Fetching workspace info...").start();try{var i=yield a.workspace();i?.media_resource?.enable_media_workspace||(n.fail("Media workspace is not enabled for this workspace"),process.exit(1)),i.media_resource.system_media_box_id||(n.fail("No media box configured for this workspace"),process.exit(1)),!1!==t.take&&(n.text="Sending screenshot request to device...",yield a.controlDevice({id:e,type:"take-screenshot"}),n.text="Waiting for device to capture screenshot...",yield new Promise(e=>setTimeout(e,3e3))),n.text="Fetching screenshot...";var o=yield(0,H.he)(a,i,e,t.output);if(o.error&&(n.fail(o.error),process.exit(1)),n.succeed("Screenshot saved"),console.log(),console.log(k.Ay.bold("Screenshot saved to:")),console.log(k.Ay.cyan(o.path)),console.log(),o.file?.meta){var r=o.file.meta,s=r.originalWidth,p=r.originalHeight,l=r.originalFileSize;if(s&&p&&console.log(`${k.Ay.gray("Size:")} ${s}x${p}`),l){var d=(l/1024).toFixed(1);console.log(`${k.Ay.gray("File:")} ${d} KB`)}}o.file?.updatedAt&&console.log(`${k.Ay.gray("Updated:")} ${new Date(o.file.updatedAt).toLocaleString()}`)}catch(e){n.fail(`Failed to get screenshot: ${e.message}`),process.exit(1)}}),function(e,t){return de.apply(this,arguments)})),be.command("metrics <id>").description("Show device metrics (uptime, memory, disk)").option("--start-date <date>","Start date/time (ISO 8601 or relative e.g. 1h, 2d, default: today)").option("--end-date <date>","End date/time (ISO 8601 or relative e.g. 1h, 2d, default: now)").option("-j, --json","Output as JSON").action((ce=b(function*(e,t){var a=me(),n=(0,j.default)("Fetching device metrics...").start();try{var i=new Date,o=new Date(i.getFullYear(),i.getMonth(),i.getDate()).toISOString(),r=t.startDate?oe(t.startDate):o,s=t.endDate?oe(t.endDate):i.toISOString(),p=yield a.deviceUsage({deviceId:e,startDate:r,endDate:s});if(n.stop(),!p||0===p.length)return void console.log(k.Ay.yellow("No metrics data found for this device"));if(t.json)return void console.log(JSON.stringify(p,null,2));for(var l of(console.log(k.Ay.bold(`\nDevice Metrics: ${e}`)),console.log("─".repeat(60)),console.log(k.Ay.gray(`${"Date".padEnd(12)} ${"Uptime Events".padEnd(15)} ${"Avg Memory".padEnd(12)} ${"Avg Disk".padEnd(10)}`)),console.log("─".repeat(60)),p)){var d=(l.date||"").padEnd(12),c=String(l.uptime?.length||0).padEnd(15),u="N/A";if(l.memory_usage?.length){var m=0,f=0;for(var v of l.memory_usage){var h=v.values||[],g=J(h,2),y=g[0],b=g[1];null!=y&&null!=b&&b>0&&(m+=y,f+=b)}f>0&&(u=`${(m/f*100).toFixed(1)}%`)}var D="N/A";if(l.disk_usage?.length){var x=0,_=0;for(var w of l.disk_usage){var E=w.values||[],T=J(E,2),N=T[0],A=T[1];null!=N&&null!=A&&A>0&&(x+=N,_+=A)}_>0&&(D=`${(x/_*100).toFixed(1)}%`)}console.log(`${d} ${c} ${u.padEnd(12)} ${D.padEnd(10)}`)}console.log("─".repeat(60))}catch(e){n.fail(`Failed to get device metrics: ${e.message}`),process.exit(1)}}),function(e,t){return ce.apply(this,arguments)})),be.command("monitor").description("Monitor device status (polls every 60s)").option("-g, --group <id>","Monitor devices in a group").option("-i, --interval <seconds>","Polling interval in seconds","60").action((ue=b(function*(e){var t=me(),a=1e3*parseInt(e.interval,10);console.log(k.Ay.bold("\nDevice Monitor")),console.log(k.Ay.gray(`Polling every ${e.interval}s. Press Ctrl+C to stop.\n`));var n,i=(n=b(function*(){try{var a;if(a=e.group?yield t.devicesByGroup({id:e.group}):yield t.devices({}),process.stdout.write("[2J[0f"),console.log(k.Ay.bold("Device Monitor")+k.Ay.gray(` - ${(new Date).toLocaleTimeString()}`)),console.log("─".repeat(80)),!a||0===a.length)return void console.log(k.Ay.yellow("No devices found"));a.forEach(e=>{var t=e.entry_detail?.watch_dog_timer?.last_alive_time,a=fe(t),n=e.name||e.device_name||e.device_target_name,i=e.entry_detail?.application?.name||k.Ay.gray("No app");console.log(`${a} ${k.Ay.cyan(n.padEnd(25))} ${i}`)}),console.log(`\n${k.Ay.gray("Press Ctrl+C to stop")}`)}catch(e){console.error(k.Ay.red(`Error: ${e.message}`))}}),function(){return n.apply(this,arguments)});yield i(),setInterval(i,a)}),function(e){return ue.apply(this,arguments)}));var De,xe,_e=y(79896),we=y(35704),Ee=y(16928),Te=e=>{if(e.endsWith(".json")||e.includes("/")){if(!_e.existsSync(e))throw new Error(`Config file not found: ${e}`);var t=_e.readFileSync(e,"utf-8");return{config:t,source:{type:"file",path:Ee.resolve(e)},sizeBytes:Buffer.byteLength(t)}}return{config:e,source:{type:"inline"},sizeBytes:Buffer.byteLength(e)}},Ne=()=>{var e=(0,I.getCurrentProfile)(),t=(0,I.getToken)(e);return t||(console.error(k.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,U.createClient)((0,I.getBaseUrl)(),t)},Ae=(e,t)=>({id:e?._id||t,name:e?.name||"Unnamed",currentVersion:e?.current_version||null,unreleasedChanges:Boolean(e?.has_unreleased_changes)}),Oe=new O("app").description("Application management");Oe.command("new").description("Create a new application").requiredOption("-n, --name <name>","Application name").option("-d, --description <description>","Application description").option("--layout-width <width>","Layout width",parseInt).option("--layout-height <height>","Layout height",parseInt).option("--example <key>","Create from example template").option("--init","Initialize a BRICKS Project after creation").option("-o, --output <dir>","Output directory for --init (default: current directory)").option("-y, --yes","Skip prompts for --init").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){var t=Ne(),a=e.json?null:(0,j.default)("Creating application...").start();try{var n={name:e.name};e.description&&(n.description=e.description),e.layoutWidth&&(n.layoutWidth=e.layoutWidth),e.layoutHeight&&(n.layoutHeight=e.layoutHeight),e.example&&(n.createExampleKey=e.example);var i=yield t.createApplication(n);if(e.json&&!e.init?console.log(JSON.stringify(i,null,2)):e.json||(a.succeed(`Application created: ${k.Ay.green(i.name)}`),console.log(` ID: ${k.Ay.gray(i._id)}`),i.description&&console.log(` ${k.Ay.gray(i.description)}`)),e.init){a&&a.stop();var o=(yield Promise.all([y.e(356),y.e(465)]).then(y.bind(y,16465))).initProject;yield o("application",i._id,{output:e.output,yes:e.yes,json:e.json})}}catch(t){e.json?console.error(JSON.stringify({error:t.message})):a.fail(`Failed to create application: ${t.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),Oe.command("list").description("List all applications").option("-k, --keyword <keyword>","Filter by keyword").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){var t=Ne(),a=(0,j.default)("Fetching applications...").start();try{var n=yield t.applications({keyword:e.keyword});if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(k.Ay.yellow("No applications found"));console.log(k.Ay.bold("\nApplications")),console.log("─".repeat(80)),n.forEach(e=>{var t=e.has_unreleased_changes?k.Ay.yellow("●"):k.Ay.green("●"),a=e.current_version?`v${e.current_version}`:k.Ay.gray("no version");console.log(`${t} ${k.Ay.cyan(e.name)} ${k.Ay.gray(a)}`),console.log(` ID: ${k.Ay.gray(e._id)}`),e.description&&console.log(` ${k.Ay.gray(e.description)}`),console.log()})}catch(e){a.fail(`Failed to list applications: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),Oe.command("get <id>").description("Get application details").option("-c, --composed","Get composed configuration").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Ne(),n=(0,j.default)("Fetching application...").start();try{var i=yield a.application({id:e,composed:t.composed});if(n.stop(),i||(console.log(k.Ay.red("Application not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(i,null,2));if(console.log(k.Ay.bold(`\nApplication: ${i.name}`)),console.log("─".repeat(60)),console.log(`ID: ${k.Ay.gray(i._id)}`),console.log(`Description: ${i.description||k.Ay.gray("N/A")}`),console.log(`Tags: ${i.tags?.join(", ")||k.Ay.gray("None")}`),console.log(`Created: ${k.Ay.gray(i.create_datetime)}`),console.log(`Modified: ${k.Ay.gray(i.last_modify_datetime)}`),console.log(`\n${k.Ay.bold("Version")}`),i.current_version){if(console.log(`Current: v${i.current_version}`),i.current_version_details){var o=i.current_version_details;o.name&&console.log(`Release Name: ${o.name}`),o.note&&console.log(`Release Note: ${k.Ay.gray(o.note)}`),o.create_datetime&&console.log(`Released At: ${k.Ay.gray(o.create_datetime)}`)}}else console.log(`Current: ${k.Ay.gray("No version")}`);if(console.log(`Unreleased: ${i.has_unreleased_changes?k.Ay.yellow("Yes"):k.Ay.green("No")}`),console.log(`\n${k.Ay.bold("Features")}`),console.log(`Short Edit: ${i.short_edit?.enabled?k.Ay.green("Enabled"):k.Ay.gray("Disabled")}`),i.short_edit?.enabled&&i.short_edit.ref_map){var r=Object.keys(i.short_edit.ref_map).length;console.log(` References: ${r} editable properties`)}console.log(`Automation: ${i.canvas_control?.enable_schedule?k.Ay.green("Scheduled"):k.Ay.gray("No schedule")}`),i.lock?.locked&&console.log(`Locked: ${k.Ay.yellow("Yes")} (at ${i.lock.locked_at||"N/A"})`),i.sync_key&&console.log(`Sync Key: ${k.Ay.gray(i.sync_key)}`),i.devices?.length>0?(console.log(`\n${k.Ay.bold("Bound Devices")} (${i.devices.length})`),i.devices.forEach(e=>{var t="active"===e.status?k.Ay.green("●"):k.Ay.gray("○"),a=e.frame?k.Ay.gray(` [${e.frame.x||0},${e.frame.y||0} ${e.frame.width}x${e.frame.height}]`):"";console.log(` ${t} ${e.device_id}${a}`)})):console.log(`\n${k.Ay.bold("Bound Devices")}: ${k.Ay.gray("None")}`),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get application: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Oe.command("resolve <query>").description("Resolve an application name or ID to stable IDs").option("-l, --limit <limit>","Limit search results",e=>Number.parseInt(e,10),10).option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Ne(),n=t.json?null:(0,j.default)("Resolving application...").start();try{var i=yield X(()=>a.application({id:e})),o=i?[i]:yield a.applications({keyword:e,paginate:{limit:t.limit}}),r=K({resource:"application",query:e,items:o||[],fields:["_id","name"],selectedBy:i?"id":null});if(n&&n.stop(),t.json)return void q(r);if(r.resolved){var s=r.resolved;return console.log(k.Ay.bold("\nResolved Application")),console.log("─".repeat(60)),console.log(`Name: ${k.Ay.cyan(s.name||"Unnamed")}`),console.log(`ID: ${k.Ay.gray(s._id)}`),console.log(`Selected By: ${r.selectedBy}`),void console.log("─".repeat(60))}if(0===r.matches.length)return void console.log(k.Ay.yellow(`No applications matched "${e}"`));console.log(k.Ay.bold(`\nMatching Applications (${r.matches.length})`)),console.log("─".repeat(80)),r.matches.forEach(e=>{console.log(`${k.Ay.cyan(e.name||"Unnamed")} ${k.Ay.gray(e._id)}`)}),console.log("─".repeat(80))}catch(t){n?n.fail(`Failed to resolve application: ${t.message}`):z(t.message,{resource:"application",query:e}),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Oe.command("update <id>").description("Update application").option("-n, --name <name>","Application name").option("-d, --description <description>","Application description").option("-c, --config <json>","Application config as JSON string").option("-f, --file <path>","Application config from file").option("--validate","Validate configuration").action(function(){var e=b(function*(e,t){var a=Ne(),n=(0,j.default)("Updating application...").start();try{var i={id:e};t.name&&(i.name=t.name),t.description&&(i.description=t.description),t.validate&&(i.validateConfig=!0),t.config?i.config=t.config:t.file&&(i.config=_e.readFileSync(t.file,"utf-8"));var o=yield a.updateApplication(i);n.succeed(`Application updated: ${k.Ay.green(o.name)}`),o.has_unreleased_changes&&console.log(k.Ay.yellow("Note: Application has unreleased changes"))}catch(e){n.fail(`Failed to update application: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Oe.command("short-edit <id>").description("Short edit application properties").requiredOption("-l, --list <json>","Short edit list as JSON array").action(function(){var e=b(function*(e,t){var a=Ne(),n=(0,j.default)("Applying short edit...").start();try{var i=JSON.parse(t.list);Array.isArray(i)||(n.fail("List must be a JSON array"),process.exit(1));var o=yield a.shortEditApplication({id:e,list:i});n.succeed(`Short edit applied to: ${k.Ay.green(o.name)}`)}catch(e){n.fail(`Failed to apply short edit: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Oe.command("short-refs <id>").description("List short edit references for an application").option("-k, --keyword <keyword>","Filter by shortId or title").option("-t, --types <types>","Comma-separated shortId prefixes to include (e.g. B,C,S)").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Ne(),n=(0,j.default)("Fetching short edit references...").start();try{var i=yield a.application({id:e});if(n.stop(),!i?.short_edit?.enabled)return void console.log(k.Ay.yellow("Short Edit is not enabled for this application"));var o=t.types?t.types.split(",").map(e=>e.trim()).filter(Boolean):[],r=(0,we.V)(i.short_edit.ref_map,{keyword:t.keyword,types:o});if(t.json)return void console.log(JSON.stringify(r,null,2));if(0===r.length)return void console.log(k.Ay.yellow("No short edit references found"));console.log(k.Ay.bold(`\nShort Edit References: ${i.name}`)),r.forEach(e=>{console.log(k.Ay.cyan(`\n${e.label} (${e.prefix}_)`)),e.refs.forEach(({shortId:e,ref:t})=>{var a=t?.title?k.Ay.gray(`- ${t.title}`):"";console.log(` ${k.Ay.green(e)} ${a}`)})}),console.log()}catch(e){n.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Oe.command("bind <id>").description("Bind devices to application").option("-b, --bind <devices>","Device IDs to bind (comma-separated)").option("-u, --unbind <devices>","Device IDs to unbind (comma-separated)").option("--dry-run","Validate inputs and show the binding plan without applying it").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Ne(),n=t.json?null:(0,j.default)("Updating device bindings...").start();try{var i=yield a.application({id:e});if(!i)throw new Error("Application not found");var o=t.bind?t.bind.split(",").map(e=>e.trim()):[],r=t.unbind?t.unbind.split(",").map(e=>e.trim()):[],s={id:e};if(o.length>0&&(s.bindDevices=o),r.length>0&&(s.unbindDevices=r),t.dryRun)return n&&n.stop(),void te({action:"application.bind",target:Ae(i,e),request:{bindDevices:o,unbindDevices:r},checks:[Z("application exists",!0,`${i.name} (${i._id})`),Z("device changes provided",o.length+r.length>0,`bind=${o.length}, unbind=${r.length}`)],json:t.json});yield a.bindApplication(s),t.json?ae({action:"application.bind",target:Ae(i,e),result:{bindDevices:o,unbindDevices:r},json:!0}):n.succeed("Device bindings updated")}catch(a){t.json?z(a.message,{action:"application.bind",target:{id:e}}):n.fail(`Failed to update bindings: ${a.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Oe.command("trigger <id> <testId>").description("Trigger automation test on application").option("--play","Play the test",!0).option("--stop","Stop the test").option("--setup-at-launch","Setup to run at app launch").option("-g, --match-group <group>","Match group").action(function(){var e=b(function*(e,t,a){var n=Ne(),i=(0,j.default)("Triggering automation...").start();try{yield n.triggerApplicationCanvasControl({id:e,testId:t,play:!a.stop&&a.play,setupAtLaunch:a.setupAtLaunch,matchGroup:a.matchGroup}),i.succeed(`Automation triggered: ${k.Ay.green(t)}`)}catch(e){i.fail(`Failed to trigger automation: ${e.message}`),process.exit(1)}});return function(t,a,n){return e.apply(this,arguments)}}()),Oe.command("release <id>").description("Release application to BRICKS platform").requiredOption("-c, --config <path|json>","Application config file path or JSON string").option("--version <version>","Version name").option("--changelogs <text>","Release changelogs").option("--dry-run","Validate inputs and show the release plan without publishing").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Ne(),n=t.json?null:(0,j.default)("Releasing application...").start();try{var i=Te(t.config),o=i.config,r=i.source,s=i.sizeBytes,p=yield a.application({id:e});if(!p)throw new Error("Application not found");if(p.lock?.enabled)throw new Error("Application is locked");var l=t.version||p.name||"Untitled",d=t.changelogs?`${t.changelogs}\n\nRelease by BRICKS CLI`:"Release by BRICKS CLI";if(t.dryRun)return n&&n.stop(),void te({action:"application.release",target:Ae(p,e),request:{version:l,changelogs:t.changelogs||null,configSource:r,configSizeBytes:s},checks:[Z("application exists",!0,`${p.name} (${p._id})`),Z("application is unlocked",!p.lock?.enabled),Z("release config loaded",!0,`${s} bytes`)],json:t.json});yield a.releaseApplication({id:e,config:o,releaseCurrentVersion:l,releaseCurrentVersionNote:d}),t.json?ae({action:"application.release",target:Ae(p,e),result:{version:l,configSource:r,configSizeBytes:s},json:!0}):n.succeed(`Application released: ${k.Ay.green(p.name)}`)}catch(a){t.json?z(a.message,{action:"application.release",target:{id:e}}):n.fail(`Failed to release application: ${a.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Oe.command("project-pull <id>").description("Pull application source files from BRICKS platform").option("-j, --json","Output as JSON (for programmatic use)").action(function(){var e=b(function*(e,t){var a=Ne(),n=t.json?null:(0,j.default)("Pulling application project...").start();try{var i=yield a.applicationProject({id:e,buildApplicationOnly:!0});i||(n?n.fail("Application project not found"):console.error(JSON.stringify({error:"Application project not found"})),process.exit(1)),t.json?console.log(JSON.stringify(i)):(n.succeed(`Application project fetched: ${k.Ay.green(i.files?.length||0)} files`),console.log(JSON.stringify(i,null,2)))}catch(e){t.json?console.error(JSON.stringify({error:e.message})):n.fail(`Failed to pull application project: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Oe.command("check-config <path>").description("Validate application config against BRICKS schema").option("-j, --json","Output as JSON").action((De=b(function*(e,t){_e.existsSync(e)||(console.error(k.Ay.red(`Config file not found: ${e}`)),process.exit(1));var a=(0,j.default)("Validating config...").start();try{var n=_e.readFileSync(e,"utf-8"),i=JSON.parse(n),o=yield Promise.all([y.e(428),y.e(425),y.e(890)]).then(y.t.bind(y,38890,19)),r=o.checkConfig,s=o.checkConfigDeprecatedFeatures,p=r(i),l=s(i);if(a.stop(),t.json)return console.log(JSON.stringify({...p,deprecations:l},null,2)),void(p.valid||process.exit(1));if(p.valid&&0===l.length)return void console.log(k.Ay.green("✓ Config is valid"));console.log(k.Ay.bold("\nConfig Validation Report")),console.log("─".repeat(60)),p.schema.length>0&&(console.log(k.Ay.red(`\n Schema Errors (${p.schema.length})\n`)),p.schema.forEach((e,t)=>{var a=e.instancePath||e.dataPath||"/";console.log(` ${k.Ay.red(`${t+1}.`)} ${k.Ay.bold(a)}`),console.log(` ${e.message}`),e.params?.pattern&&console.log(` ${k.Ay.gray(`pattern: ${e.params.pattern}`)}`)})),p.ref.length>0&&(console.log(k.Ay.red(`\n Reference Errors (${p.ref.length})\n`)),p.ref.forEach((e,t)=>{console.log(` ${k.Ay.red(`${t+1}.`)} ${k.Ay.bold(e.field)}`),console.log(` ${e.message}`)})),l.length>0&&(console.log(k.Ay.yellow(`\n Deprecation Warnings (${l.length})\n`)),l.forEach((e,t)=>{console.log(` ${k.Ay.yellow(`${t+1}.`)} ${k.Ay.bold(e.id)}`),console.log(` ${e.data}`)})),console.log("\n"+"─".repeat(60));var d=p.schema.length+p.ref.length;p.valid?console.log(k.Ay.yellow(`⚠ ${l.length} warning(s)`)):console.log(k.Ay.red(`✗ ${d} error(s)`)+(l.length>0?k.Ay.yellow(`, ${l.length} warning(s)`):"")),p.valid||process.exit(1)}catch(e){a.fail(`Failed to validate config: ${e.message}`),process.exit(1)}}),function(e,t){return De.apply(this,arguments)})),Oe.command("ctor-init <id>").alias("project-init").description("Initialize a BRICKS Project from an application").option("-o, --output <dir>","Output directory (default: current directory)").option("--github-actions","Include GitHub Actions workflow (default: true)").option("--no-github-actions","Skip GitHub Actions workflow setup").option("--agents","Include AGENTS.md (default: true)").option("--no-agents","Skip AGENTS.md setup").option("--claude","Include CLAUDE.md (default: true)").option("--no-claude","Skip CLAUDE.md setup").option("--gemini","Include GEMINI.md (default: false)").option("--no-gemini","Skip GEMINI.md setup").option("--install","Run bun install after generation (default: true)").option("--no-install","Skip bun install after generation").option("--git","Initialize git repository (default: true)").option("--no-git","Skip git initialization").option("-y, --yes","Skip prompts and use defaults/flags").option("-j, --json","Output as JSON (for programmatic use)").action((xe=b(function*(e,t){var a=(yield Promise.all([y.e(356),y.e(465)]).then(y.bind(y,16465))).initProject;yield a("application",e,t)}),function(e,t){return xe.apply(this,arguments)}));var Fe=()=>{var e=(0,I.getCurrentProfile)(),t=(0,I.getToken)(e);return t||(console.error(k.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,U.createClient)((0,I.getBaseUrl)(),t)},Se=(e,t)=>({id:e?._id||t,name:e?.name||"Unnamed",currentVersion:e?.current_version||null,public:Boolean(e?.is_public)}),Ce=new O("module").description("Module management");Ce.command("new").description("Create a new module").requiredOption("-n, --name <name>","Module name").option("-d, --description <description>","Module description").option("--layout-width <width>","Layout width",parseInt).option("--layout-height <height>","Layout height",parseInt).option("--public","Make module available to all users").option("--allow-modify","Allow users to modify imported module config").option("--init","Initialize a BRICKS Project after creation").option("-o, --output <dir>","Output directory for --init (default: current directory)").option("-y, --yes","Skip prompts for --init").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){var t=Fe(),a=e.json?null:(0,j.default)("Creating module...").start();try{var n={name:e.name};e.description&&(n.description=e.description),e.layoutWidth&&(n.layoutWidth=e.layoutWidth),e.layoutHeight&&(n.layoutHeight=e.layoutHeight),e.public&&(n.isPublic=!0),e.allowModify&&(n.isAllowModify=!0);var i=yield t.createModule(n);if(e.json&&!e.init?console.log(JSON.stringify(i,null,2)):e.json||(a.succeed(`Module created: ${k.Ay.green(i.name)}`),console.log(` ID: ${k.Ay.gray(i._id)}`),i.description&&console.log(` ${k.Ay.gray(i.description)}`),console.log(` Public: ${i.is_public?k.Ay.green("Yes"):k.Ay.gray("No")}`),console.log(` Allow Modify: ${i.is_allow_modify?k.Ay.green("Yes"):k.Ay.gray("No")}`)),e.init){a&&a.stop();var o=(yield Promise.all([y.e(356),y.e(465)]).then(y.bind(y,16465))).initProject;yield o("module",i._id,{output:e.output,yes:e.yes,json:e.json})}}catch(t){e.json?console.error(JSON.stringify({error:t.message})):a.fail(`Failed to create module: ${t.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),Ce.command("list").description("List all modules").option("-k, --keyword <keyword>","Filter by keyword").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){var t=Fe(),a=(0,j.default)("Fetching modules...").start();try{var n=yield t.modules({keyword:e.keyword});if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(k.Ay.yellow("No modules found"));console.log(k.Ay.bold("\nModules")),console.log("─".repeat(80)),n.forEach(e=>{var t=e.current_version?`v${e.current_version}`:k.Ay.gray("no version");console.log(`● ${k.Ay.cyan(e.name)} ${k.Ay.gray(t)}`),console.log(` ID: ${k.Ay.gray(e._id)}`),e.description&&console.log(` ${k.Ay.gray(e.description)}`),console.log()})}catch(e){a.fail(`Failed to list modules: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),Ce.command("list-public").description("Search public modules").requiredOption("-k, --keyword <keyword>","Search keyword (min 2 characters)").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){var t=(0,U.createClient)((0,I.getBaseUrl)()),a=(0,j.default)("Searching public modules...").start();try{var n=yield t.publicModules({keyword:e.keyword});if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(k.Ay.yellow("No public modules found"));console.log(k.Ay.bold("\nPublic Modules")),console.log("─".repeat(80)),n.forEach(e=>{var t=e.current_version?`v${e.current_version}`:k.Ay.gray("no version");console.log(`● ${k.Ay.cyan(e.name)} ${k.Ay.gray(t)}`),console.log(` ID: ${k.Ay.gray(e._id)}`),e.description&&console.log(` ${k.Ay.gray(e.description)}`),console.log()})}catch(e){a.fail(`Failed to search public modules: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),Ce.command("get <id>").description("Get module details").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Fe(),n=(0,j.default)("Fetching module...").start();try{var i=yield a.module({id:e});if(n.stop(),i||(console.log(k.Ay.red("Module not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(i,null,2));if(console.log(k.Ay.bold(`\nModule: ${i.name}`)),console.log("─".repeat(60)),console.log(`ID: ${k.Ay.gray(i._id)}`),console.log(`Description: ${i.description||k.Ay.gray("N/A")}`),console.log(`Tags: ${i.tags?.join(", ")||k.Ay.gray("None")}`),console.log(`Created: ${k.Ay.gray(i.create_datetime)}`),console.log(`Modified: ${k.Ay.gray(i.last_modify_datetime)}`),console.log(`\n${k.Ay.bold("Version")}`),console.log(`Current: ${i.current_version?`v${i.current_version}`:k.Ay.gray("No version")}`),console.log(`Unreleased: ${i.has_unreleased_changes?k.Ay.yellow("Yes"):k.Ay.green("No")}`),console.log(`\n${k.Ay.bold("Settings")}`),console.log(`Public: ${i.is_public?k.Ay.green("Yes"):k.Ay.gray("No")}`),console.log(`Allow Modify: ${i.is_allow_modify?k.Ay.green("Yes"):k.Ay.gray("No")}`),console.log(`Short Edit: ${i.short_edit?.enabled?k.Ay.green("Enabled"):k.Ay.gray("Disabled")}`),i.short_edit?.enabled&&i.short_edit.ref_map){var o=Object.keys(i.short_edit.ref_map).length;console.log(` References: ${o} editable properties`)}null!=i.use_count?.total_count&&(console.log(`\n${k.Ay.bold("Usage")}`),console.log(`Used In: ${i.use_count.total_count} application(s)`)),i.expose_properties?.length>0&&(console.log(`\n${k.Ay.bold("Exposed Properties")} (${i.expose_properties.length})`),i.expose_properties.forEach(e=>{console.log(` - ${k.Ay.cyan(e)}`)})),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get module: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ce.command("resolve <query>").description("Resolve a module name or ID to stable IDs").option("-l, --limit <limit>","Limit search results",e=>Number.parseInt(e,10),10).option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Fe(),n=t.json?null:(0,j.default)("Resolving module...").start();try{var i=yield X(()=>a.module({id:e})),o=i?[i]:yield a.modules({keyword:e,paginate:{limit:t.limit}}),r=K({resource:"module",query:e,items:o||[],fields:["_id","name"],selectedBy:i?"id":null});if(n&&n.stop(),t.json)return void q(r);if(r.resolved){var s=r.resolved;return console.log(k.Ay.bold("\nResolved Module")),console.log("─".repeat(60)),console.log(`Name: ${k.Ay.cyan(s.name||"Unnamed")}`),console.log(`ID: ${k.Ay.gray(s._id)}`),console.log(`Selected By: ${r.selectedBy}`),void console.log("─".repeat(60))}if(0===r.matches.length)return void console.log(k.Ay.yellow(`No modules matched "${e}"`));console.log(k.Ay.bold(`\nMatching Modules (${r.matches.length})`)),console.log("─".repeat(80)),r.matches.forEach(e=>{console.log(`${k.Ay.cyan(e.name||"Unnamed")} ${k.Ay.gray(e._id)}`)}),console.log("─".repeat(80))}catch(t){n?n.fail(`Failed to resolve module: ${t.message}`):z(t.message,{resource:"module",query:e}),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ce.command("update <id>").description("Update module").option("-n, --name <name>","Module name").option("-d, --description <description>","Module description").option("-c, --config <json>","Module config as JSON string").option("-f, --file <path>","Module config from file").option("--validate","Validate configuration").action(function(){var e=b(function*(e,t){var a=Fe(),n=(0,j.default)("Updating module...").start();try{var i={id:e};t.name&&(i.name=t.name),t.description&&(i.description=t.description),t.validate&&(i.validateConfig=!0),t.config?i.config=t.config:t.file&&(i.config=_e.readFileSync(t.file,"utf-8"));var o=yield a.updateModule(i);n.succeed(`Module updated: ${k.Ay.green(o.name)}`)}catch(e){n.fail(`Failed to update module: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ce.command("short-edit <id>").description("Short edit module properties").requiredOption("-l, --list <json>","Short edit list as JSON array").action(function(){var e=b(function*(e,t){var a=Fe(),n=(0,j.default)("Applying short edit...").start();try{var i=JSON.parse(t.list);Array.isArray(i)||(n.fail("List must be a JSON array"),process.exit(1));var o=yield a.shortEditModule({id:e,list:i});n.succeed(`Short edit applied to: ${k.Ay.green(o.name)}`)}catch(e){n.fail(`Failed to apply short edit: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ce.command("short-refs <id>").description("List short edit references for a module").option("-k, --keyword <keyword>","Filter by shortId or title").option("-t, --types <types>","Comma-separated shortId prefixes to include (e.g. B,C,S)").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Fe(),n=(0,j.default)("Fetching short edit references...").start();try{var i=yield a.module({id:e});if(n.stop(),!i?.short_edit?.enabled)return void console.log(k.Ay.yellow("Short Edit is not enabled for this module"));var o=t.types?t.types.split(",").map(e=>e.trim()).filter(Boolean):[],r=(0,we.V)(i.short_edit.ref_map,{keyword:t.keyword,types:o});if(t.json)return void console.log(JSON.stringify(r,null,2));if(0===r.length)return void console.log(k.Ay.yellow("No short edit references found"));console.log(k.Ay.bold(`\nShort Edit References: ${i.name}`)),r.forEach(e=>{console.log(k.Ay.cyan(`\n${e.label} (${e.prefix}_)`)),e.refs.forEach(({shortId:e,ref:t})=>{var a=t?.title?k.Ay.gray(`- ${t.title}`):"";console.log(` ${k.Ay.green(e)} ${a}`)})}),console.log()}catch(e){n.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ce.command("release <id>").description("Release module to BRICKS platform").requiredOption("-c, --config <path|json>","Module config file path or JSON string").option("--version <version>","Version name").option("--changelogs <text>","Release changelogs").option("--dry-run","Validate inputs and show the release plan without publishing").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Fe(),n=t.json?null:(0,j.default)("Releasing module...").start();try{var i=Te(t.config),o=i.config,r=i.source,s=i.sizeBytes,p=yield a.module({id:e});if(!p)throw new Error("Module not found");if(p.is_public)throw new Error("Public module deployment is temporarily not recommended");var l=t.version||p.name||"Untitled",d=t.changelogs?`${t.changelogs}\n\nRelease by BRICKS CLI`:"Release by BRICKS CLI";if(t.dryRun)return n&&n.stop(),void te({action:"module.release",target:Se(p,e),request:{version:l,changelogs:t.changelogs||null,configSource:r,configSizeBytes:s},checks:[Z("module exists",!0,`${p.name} (${p._id})`),Z("module is private",!p.is_public),Z("release config loaded",!0,`${s} bytes`)],json:t.json});yield a.releaseModule({id:e,config:o,releaseCurrentVersion:l,releaseCurrentVersionNote:d}),t.json?ae({action:"module.release",target:Se(p,e),result:{version:l,configSource:r,configSizeBytes:s},json:!0}):n.succeed(`Module released: ${k.Ay.green(p.name)}`)}catch(a){t.json?z(a.message,{action:"module.release",target:{id:e}}):n.fail(`Failed to release module: ${a.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ce.command("project-pull <id>").description("Pull module source files from BRICKS platform").option("-j, --json","Output as JSON (for programmatic use)").action(function(){var e=b(function*(e,t){var a=Fe(),n=t.json?null:(0,j.default)("Pulling module project...").start();try{var i=yield a.moduleProject({id:e,buildApplicationOnly:!0});i||(n?n.fail("Module project not found"):console.error(JSON.stringify({error:"Module project not found"})),process.exit(1)),t.json?console.log(JSON.stringify(i)):(n.succeed(`Module project fetched: ${k.Ay.green(i.files?.length||0)} files`),console.log(JSON.stringify(i,null,2)))}catch(e){t.json?console.error(JSON.stringify({error:e.message})):n.fail(`Failed to pull module project: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ce.command("ctor-init <id>").alias("project-init").description("Initialize a BRICKS Project from a module").option("-o, --output <dir>","Output directory (default: current directory)").option("--github-actions","Include GitHub Actions workflow (default: true)").option("--no-github-actions","Skip GitHub Actions workflow setup").option("--agents","Include AGENTS.md (default: true)").option("--no-agents","Skip AGENTS.md setup").option("--claude","Include CLAUDE.md (default: true)").option("--no-claude","Skip CLAUDE.md setup").option("--gemini","Include GEMINI.md (default: false)").option("--no-gemini","Skip GEMINI.md setup").option("--install","Run bun install after generation (default: true)").option("--no-install","Skip bun install after generation").option("--git","Initialize git repository (default: true)").option("--no-git","Skip git initialization").option("-y, --yes","Skip prompts and use defaults/flags").option("-j, --json","Output as JSON (for programmatic use)").action(function(){var e=b(function*(e,t){var a=(yield Promise.all([y.e(356),y.e(465)]).then(y.bind(y,16465))).initProject;yield a("module",e,t)});return function(t,a){return e.apply(this,arguments)}}());var ke=()=>{var e=(0,I.getCurrentProfile)(),t=(0,I.getToken)(e);return t||(console.error(k.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,U.createClient)((0,I.getBaseUrl)(),t)},Ie=3e5,$e=e=>{if(!e)return k.Ay.gray("○");var t=Date.now()-new Date(e).getTime();return t<=Ie?k.Ay.green("●"):Math.floor(t/6e4)<60?k.Ay.yellow("○"):k.Ay.red("○")},je=(e,t)=>({id:e?._id||t,name:e?.name||"Unnamed",deviceCount:e?.devices?.length||0}),Re=["refresh","clear-cache","system-menu-open","system-menu-close","system-info-open","system-info-close","local-sync-panel-open","local-sync-panel-close","debug-panel-open","debug-panel-close","logging-on","logging-off","test-panel-open","test-panel-close"],Ve=new O("group").description("Device Group management");Ve.command("list").description("List all device groups").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){var t=ke(),a=(0,j.default)("Fetching device groups...").start();try{var n=yield t.deviceGroups({});if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(k.Ay.yellow("No device groups found"));console.log(k.Ay.bold("\nDevice Groups")),console.log("─".repeat(80)),n.forEach(e=>{var t=e.devices?.length||0;console.log(`● ${k.Ay.cyan(e.name)} ${k.Ay.gray(`(${t} devices)`)}`),console.log(` ID: ${k.Ay.gray(e._id)}`),e.description&&console.log(` ${k.Ay.gray(e.description)}`),console.log()})}catch(e){a.fail(`Failed to list groups: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),Ve.command("get <id>").description("Get device group details").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=ke(),n=(0,j.default)("Fetching device group...").start();try{var i=yield a.deviceGroup({id:e});if(n.stop(),i||(console.log(k.Ay.red("Device group not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(i,null,2));console.log(k.Ay.bold(`\nDevice Group: ${i.name}`)),console.log("─".repeat(60)),console.log(`ID: ${k.Ay.gray(i._id)}`),console.log(`Description: ${i.description||k.Ay.gray("N/A")}`),console.log(`Tags: ${i.tags?.join(", ")||k.Ay.gray("None")}`),console.log(`Created: ${k.Ay.gray(i.create_datetime)}`),console.log(`Modified: ${k.Ay.gray(i.last_modify_datetime)}`),i.devices?.length>0&&(console.log(`\n${k.Ay.bold("Devices")} (${i.devices.length})`),i.devices.forEach(e=>{var t=e.device_target_name||e.device_id;console.log(` - ${t} ${k.Ay.gray(`(${e.device_id})`)}`)})),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get group: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ve.command("resolve <query>").description("Resolve a device group name or ID to stable IDs").option("-l, --limit <limit>","Limit search results",e=>Number.parseInt(e,10),10).option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=ke(),n=t.json?null:(0,j.default)("Resolving device group...").start();try{var i=yield X(()=>a.deviceGroup({id:e})),o=i?[i]:yield a.deviceGroups({paginate:{limit:t.limit}}),r=i?o:(o||[]).filter(t=>t.name?.toLowerCase().includes(e.trim().toLowerCase())),s=K({resource:"group",query:e,items:r||[],fields:["_id","name"],selectedBy:i?"id":null});if(n&&n.stop(),t.json)return void q(s);if(s.resolved){var p=s.resolved;return console.log(k.Ay.bold("\nResolved Device Group")),console.log("─".repeat(60)),console.log(`Name: ${k.Ay.cyan(p.name||"Unnamed")}`),console.log(`ID: ${k.Ay.gray(p._id)}`),console.log(`Selected By: ${s.selectedBy}`),void console.log("─".repeat(60))}if(0===s.matches.length)return void console.log(k.Ay.yellow(`No device groups matched "${e}"`));console.log(k.Ay.bold(`\nMatching Device Groups (${s.matches.length})`)),console.log("─".repeat(80)),s.matches.forEach(e=>{console.log(`${k.Ay.cyan(e.name||"Unnamed")} ${k.Ay.gray(e._id)}`)}),console.log("─".repeat(80))}catch(t){n?n.fail(`Failed to resolve device group: ${t.message}`):z(t.message,{resource:"group",query:e}),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ve.command("devices <id>").description("List devices in a group with status").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=ke(),n=(0,j.default)("Fetching devices...").start();try{var i=yield a.devicesByGroup({id:e});if(n.stop(),t.json)return void console.log(JSON.stringify(i,null,2));if(!i||0===i.length)return void console.log(k.Ay.yellow("No devices in this group"));console.log(k.Ay.bold("\nDevices in Group")),console.log("─".repeat(80)),i.forEach(e=>{var t=e.entry_detail?.watch_dog_timer?.last_alive_time,a=$e(t),n=e.name||e.device_name||e.device_target_name,i=e.entry_detail?.application?.name||k.Ay.gray("No app");console.log(`${a} ${k.Ay.cyan(n.padEnd(30))} ${i}`)}),console.log("─".repeat(80))}catch(e){n.fail(`Failed to get devices: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ve.command("dispatch <id> <action>").description("Dispatch action to all devices in group").option("--dry-run","Validate inputs and show the dispatch plan without sending it").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t,a){var n=ke(),i=a.json?null:(0,j.default)(`Dispatching ${t}...`).start();Re.includes(t)||(a.json?z(`Invalid action. Valid actions: ${Re.join(", ")}`,{action:"group.dispatch",target:{id:e}}):i.fail(`Invalid action. Valid actions: ${Re.join(", ")}`),process.exit(1));try{var o=yield n.deviceGroup({id:e});if(!o)throw new Error("Device group not found");if(a.dryRun)return i&&i.stop(),void te({action:"group.dispatch",target:je(o,e),request:{action:t},checks:[Z("group exists",!0,`${o.name} (${o._id})`),Z("action is valid",!0)],json:a.json});var r=yield n.dispatchDeviceGroupAction({id:e,action:t});a.json?ae({action:"group.dispatch",target:je(o,e),result:{action:t,success:r?.success||0,failed:r?.failed||0},json:!0}):(i.succeed(`Action dispatched: ${k.Ay.green(t)}`),r&&(console.log(`Success: ${k.Ay.green(r.success||0)}`),console.log(`Failed: ${k.Ay.red(r.failed||0)}`)))}catch(t){a.json?z(t.message,{action:"group.dispatch",target:{id:e}}):i.fail(`Failed to dispatch action: ${t.message}`),process.exit(1)}});return function(t,a,n){return e.apply(this,arguments)}}()),Ve.command("refresh <id>").description("Refresh all devices in group").option("--dry-run","Validate inputs and show the refresh plan without sending it").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=ke(),n=t.json?null:(0,j.default)("Refreshing devices...").start();try{var i=yield a.deviceGroup({id:e});if(!i)throw new Error("Device group not found");if(t.dryRun)return n&&n.stop(),void te({action:"group.refresh",target:je(i,e),request:{action:"refresh"},checks:[Z("group exists",!0,`${i.name} (${i._id})`)],json:t.json});var o=yield a.dispatchDeviceGroupAction({id:e,action:"refresh"});t.json?ae({action:"group.refresh",target:je(i,e),result:{success:o?.success||0,failed:o?.failed||0},json:!0}):(n.succeed("Devices refreshed"),o&&(console.log(`Success: ${k.Ay.green(o.success||0)}`),console.log(`Failed: ${k.Ay.red(o.failed||0)}`)))}catch(a){t.json?z(a.message,{action:"group.refresh",target:{id:e}}):n.fail(`Failed to refresh: ${a.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ve.command("monitor <id>").description("Monitor devices in group (polls every 60s)").option("-i, --interval <seconds>","Polling interval in seconds","60").action(function(){var e=b(function*(e,t){var a=ke(),n=1e3*parseInt(t.interval,10);console.log(k.Ay.bold("\nDevice Group Monitor")),console.log(k.Ay.gray(`Polling every ${t.interval}s. Press Ctrl+C to stop.\n`));var i=function(){var t=b(function*(){try{var t=yield Promise.all([a.deviceGroup({id:e}),a.devicesByGroup({id:e})]),n=J(t,2),i=n[0],o=n[1];if(process.stdout.write("[2J[0f"),console.log(k.Ay.bold(`Device Group: ${i.name}`)+k.Ay.gray(` - ${(new Date).toLocaleTimeString()}`)),console.log("─".repeat(80)),!o||0===o.length)return void console.log(k.Ay.yellow("No devices in this group"));var r=0,s=0;o.forEach(e=>{var t=e.entry_detail?.watch_dog_timer?.last_alive_time,a=$e(t),n=e.name||e.device_name||e.device_target_name,i=e.entry_detail?.application?.name||k.Ay.gray("No app");t&&Date.now()-new Date(t).getTime()<=Ie?r++:s++,console.log(`${a} ${k.Ay.cyan(n.padEnd(30))} ${i}`)}),console.log("─".repeat(80)),console.log(`Online: ${k.Ay.green(r)} Offline: ${k.Ay.red(s)}`),console.log(`\n${k.Ay.gray("Press Ctrl+C to stop")}`)}catch(e){console.error(k.Ay.red(`Error: ${e.message}`))}});return function(){return t.apply(this,arguments)}}();yield i(),setInterval(i,n)});return function(t,a){return e.apply(this,arguments)}}());const Pe=t("fs/promises");var Be=y(86090),Le=()=>{var e=(0,I.getCurrentProfile)(),t=(0,I.getToken)(e);return t||(console.error(k.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,U.createClient)((0,I.getBaseUrl)(),t)},Me=function(){var e=b(function*(e){var t=yield e.workspace();if(!(0,H.wR)(t))throw new Error("Media workspace not enabled for this workspace")});return function(t){return e.apply(this,arguments)}}(),Ue=e=>{var t=e.meta||{};if(!t.originalFileUploaded)return{ready:!1,label:"Uploading"};if("Video"===e.fileType){if(!t.videoThumbOriginalFileKey)return{ready:!1,label:"Processing"};if(!t.convertedFileUploaded)return{ready:!1,label:"Transcoding"}}return{ready:!0,label:"Ready"}},qe=e=>e.ready?k.Ay.green(e.label):k.Ay.yellow(e.label),ze=new O("media").description("Media Flow support");ze.command("boxes").description("List Media Flow boxes").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){var t=Le(),a=(0,j.default)("Fetching media boxes...").start();try{yield Me(t);var n=yield t.mediaBoxes();if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(k.Ay.yellow("No media boxes found"));console.log(k.Ay.bold("\nMedia Boxes")),console.log("─".repeat(80)),n.forEach(e=>{console.log(`${k.Ay.cyan(e.name||"Unnamed")} ${k.Ay.gray(e.id)}`),e.description&&console.log(` ${e.description}`),e.tags?.length&&console.log(` Tags: ${e.tags.join(", ")}`),null!=e.size&&console.log(` Size: ${e.size}`),console.log()})}catch(e){a.fail(`Failed to list media boxes: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),ze.command("box <id>").description("Get Media Flow box details").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Le(),n=(0,j.default)("Fetching media box...").start();try{yield Me(a);var i=yield a.mediaBox({id:e});if(n.stop(),i||(console.log(k.Ay.red("Media box not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(i,null,2));console.log(k.Ay.bold(`\nMedia Box: ${i.name||"Unnamed"}`)),console.log("─".repeat(60)),console.log(`ID: ${k.Ay.gray(i.id)}`),console.log(`Description: ${i.description||k.Ay.gray("N/A")}`),console.log(`Tags: ${i.tags?.join(", ")||k.Ay.gray("None")}`),null!=i.size&&console.log(`Size: ${i.size}`),i.passcodes?.length&&(console.log(`\n${k.Ay.bold("Passcodes")}`),i.passcodes.forEach(e=>{console.log(`- ${e.name||"Passcode"}: ${e.code}`)})),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get media box: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),ze.command("files <boxId>").description("List Media Flow files in a box").option("-t, --types <types>","Comma-separated file types to include").option("-u, --user-tag <tag>","Filter by user tag (repeatable)",(e,t)=>[...t,e],[]).option("-l, --limit <limit>","Limit results",e=>Number.parseInt(e,10)).option("-o, --offset <offset>","Offset results",e=>Number.parseInt(e,10)).option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Le(),n=(0,j.default)("Fetching media files...").start();try{yield Me(a);var i=t.types?t.types.split(",").map(e=>e.trim()).filter(Boolean):void 0,o=t.userTag?.length?t.userTag:void 0,r=yield a.mediaFiles({boxId:e,includeTypes:i,userTags:o,limit:t.limit,offset:t.offset});if(n.stop(),t.json)return void console.log(JSON.stringify(r,null,2));if(!r||0===r.length)return void console.log(k.Ay.yellow("No media files found"));console.log(k.Ay.bold(`\nMedia Files (${r.length})`)),console.log("─".repeat(100)),r.forEach(e=>{var t=Ue(e);console.log(`${k.Ay.cyan(e.name||"Unnamed")} ${k.Ay.gray(e.id)}`),console.log(` Type: ${e.fileType} Status: ${qe(t)}`),e.userTags?.length&&console.log(` Tags: ${e.userTags.join(", ")}`),e.updatedAt&&console.log(` Updated: ${new Date(e.updatedAt).toLocaleString()}`),console.log()})}catch(e){n.fail(`Failed to list media files: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),ze.command("file <id>").description("Get Media Flow file details").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Le(),n=(0,j.default)("Fetching media file...").start();try{yield Me(a);var i=yield a.mediaFile({id:e});if(n.stop(),i||(console.log(k.Ay.red("Media file not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(i,null,2));var o=Ue(i);console.log(k.Ay.bold(`\nMedia File: ${i.name||"Unnamed"}`)),console.log("─".repeat(60)),console.log(`ID: ${k.Ay.gray(i.id)}`),console.log(`Box ID: ${k.Ay.gray(i.boxId)}`),console.log(`Type: ${i.fileType}`),console.log(`Status: ${qe(o)}`),console.log(`Description: ${i.description||k.Ay.gray("N/A")}`),console.log(`Tags: ${i.userTags?.join(", ")||k.Ay.gray("None")}`),console.log(`Created: ${k.Ay.gray(i.createdAt||"N/A")}`),console.log(`Updated: ${k.Ay.gray(i.updatedAt||"N/A")}`);var r=(0,H.Gu)(i),s=(0,H.Gu)(i,{preferThumbnail:!0});i.meta?.originalFileKey&&console.log(`Original Key: ${k.Ay.gray(i.meta.originalFileKey)}`),r&&console.log(`Original URL: ${k.Ay.gray(r)}`),s&&s!==r&&console.log(`Thumbnail URL: ${k.Ay.gray(s)}`),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get media file: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}());var Ge=e=>{var t=e.match(/^(\d+)x(\d+)(?::(\w+))?$/);if(!t)throw new Error(`Invalid image version spec: "${e}". Expected format: WxH or WxH:STRATEGY`);return{width:parseInt(t[1],10),height:parseInt(t[2],10),strategy:(t[3]||"FILL").toUpperCase(),copypreview:!1}},Ye=function(){var e=b(function*(e,t,a,n,i){var o=new FormData;for(var r of Object.entries(t)){var s=J(r,2),p=s[0],l=s[1];o.append(p,l)}o.append("file",new Blob([a],{type:i}),n);var d=yield fetch(e,{method:"POST",body:o});if(!d.ok&&204!==d.status){var c=yield d.text().catch(()=>"");throw new Error(`S3 upload failed (${d.status}): ${c}`)}});return function(t,a,n,i,o){return e.apply(this,arguments)}}(),Qe=function(){var e=b(function*(e,t,a){var n=[],i=0,o=function(){var t=b(function*(){for(;i<e.length;){var t=i++;n[t]=yield a(e[t],t)}});return function(){return t.apply(this,arguments)}}(),r=Array.from({length:Math.min(t,e.length)},()=>o());return yield Promise.all(r),n});return function(t,a,n){return e.apply(this,arguments)}}();ze.command("upload <boxId> <files...>").description("Upload file(s) to a Media Flow box").option("-d, --description <text>","File description","").option("-t, --user-tag <tag>","User tag (repeatable, max 15)",(e,t)=>[...t,e],[]).option("--image-version <spec>","Image resize spec as WxH or WxH:STRATEGY (repeatable)",(e,t)=>[...t,e],[]).option("--image-version-type <type>","Image output format: jpg or png").option("--enable-ai-analysis","Enable AI analysis on uploaded files").option("--ai-instruction <text>","Custom AI analysis instruction").option("--concurrency <n>","Max concurrent uploads",e=>parseInt(e,10),3).option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t,a){var n=Le(),i=(0,j.default)("Preparing upload...").start();try{if(yield Me(n),a.userTag.length>15)throw new Error("Maximum 15 user tags allowed");var o=a.imageVersion.map(Ge),r=a.enableAiAnalysis||!!a.aiInstruction,s=yield Promise.all(t.map(function(){var e=b(function*(e){var t=(0,Ee.resolve)(e),a=yield(0,Pe.stat)(t).catch(()=>null);if(!a||!a.isFile())throw new Error(`Not a file: ${e}`);var n=(0,Ee.basename)(t);return{filePath:t,fileName:n,contentType:(0,Be.lookup)(n)||"application/octet-stream",size:a.size}});return function(t){return e.apply(this,arguments)}}()));i.stop();var p=s.length;console.log(k.Ay.bold(`\nUploading ${p} file${p>1?"s":""} to box ${k.Ay.gray(e)}...\n`));var l=[];yield Qe(s,a.concurrency,function(){var t=b(function*(t,i){var s,d,c=`[${i+1}/${p}] ${t.fileName}`,u=(0,j.default)(`${c} — requesting upload...`).start();try{var m=(d=t.contentType)?"image/svg+xml"===d?"FILE":d.startsWith("image/")?"IMAGE":d.startsWith("video/")?"VIDEO":d.startsWith("audio/")?"AUDIO":"FILE":"FILE",f={imageVersions:"IMAGE"===m?o:[],imageVersionType:"IMAGE"===m?a.imageVersionType:void 0,enableAiAnalysis:r,aiCustomInstruction:a.aiInstruction||void 0},v=yield n.createMediaFileUploadRequest({name:t.fileName,description:a.description,boxId:e,fileType:m,contentType:t.contentType,userTags:a.userTag.length?a.userTag:[],meta:f});u.text=`${c} — uploading to storage...`;var h=JSON.parse(v.meta.uploadInfo),g=yield(0,Pe.readFile)(t.filePath);yield Ye(h.url,{AWSAccessKeyId:h.AWSAccessKeyId,"Content-Type":h["Content-Type"],key:h.key,Signature:h.Signature,Policy:h.Policy,acl:h.acl},g,t.fileName,t.contentType),u.succeed(`${c} ${k.Ay.green("✓")} ${k.Ay.gray(`(${m}, ${s=t.size,s<1024?`${s} B`:s<1048576?`${(s/1024).toFixed(1)} KB`:s<1073741824?`${(s/1048576).toFixed(1)} MB`:`${(s/1073741824).toFixed(1)} GB`})`)}`),l.push({file:t.fileName,id:v.id,status:"success",fileType:m,size:t.size})}catch(e){u.fail(`${c} — ${e.message}`),l.push({file:t.fileName,id:null,status:"failed",error:e.message})}});return function(e,a){return t.apply(this,arguments)}}());var d=l.filter(e=>"success"===e.status).length,c=l.filter(e=>"failed"===e.status).length;a.json?console.log(JSON.stringify({boxId:e,results:l,summary:{total:p,success:d,failed:c}},null,2)):(console.log(),0===c?console.log(k.Ay.green(`Uploaded ${d}/${p} files`)):console.log(k.Ay.yellow(`Uploaded ${d}/${p} files (${c} failed)`))),c>0&&process.exit(1)}catch(e){i.fail(`Upload failed: ${e.message}`),process.exit(1)}});return function(t,a,n){return e.apply(this,arguments)}}());var Je={prod:"https://display.bricks.tools",beta:"https://display-beta.bricks.tools",dev:"http://localhost:3001"},He=e=>{var t=Object.entries(Je).find(([,t])=>e===t);return t?t[0]:null},We={prod:"https://activity-log.bricks.tools",beta:"https://activity-log-beta.bricks.tools",dev:"http://localhost:8088"},Ke=e=>{var t=Object.entries(We).find(([,t])=>e===t);return t?t[0]:null},Xe=new O("config").description("CLI configuration management");Xe.command("endpoint").argument("[environment]","Environment to use (prod, beta, dev)").description("Show or set endpoint environment").option("-p, --profile","Set for current profile instead of global").action((e,t)=>{if(!e){var a=(0,I.getBaseUrl)(),n=He(a),i=(0,I.getActivityLogBaseUrl)(),o=Ke(i);return console.log(k.Ay.bold("\nEndpoint Configuration")),console.log("─".repeat(50)),console.log(k.Ay.bold("BRICKS")),console.log(` URL: ${k.Ay.cyan(a)}`),console.log(` Environment: ${n?k.Ay.green(n):k.Ay.yellow("custom")}`),console.log(k.Ay.bold("Activity Log")),console.log(` URL: ${k.Ay.cyan(i)}`),console.log(` Environment: ${o?k.Ay.green(o):k.Ay.yellow("custom")}`),console.log("─".repeat(50)),void console.log(k.Ay.gray("\nUsage: bricks config endpoint <prod|beta|dev>"))}var r=Object.keys(Je);r.includes(e)||(console.error(k.Ay.red(`Invalid environment: ${e}`)),console.log(k.Ay.gray(`Valid options: ${r.join(", ")}`)),process.exit(1));var s=Je[e],p=We[e],l=t.profile?(0,I.getCurrentProfile)():null;(0,I.setBaseUrl)(s,l),(0,I.setActivityLogBaseUrl)(p,l);var d=t.profile?` (profile: ${(0,I.getCurrentProfile)()})`:"";console.log(k.Ay.green(`✓ Endpoint changed to ${e}${d}`)),console.log(k.Ay.gray(` BRICKS: ${s}`)),console.log(k.Ay.gray(` Activity Log: ${p}`)),console.log(k.Ay.yellow("\nNote: You may need to re-authenticate if your token is for a different environment.")),console.log(k.Ay.gray("Use `bricks auth status` to check your connection."))}),Xe.command("show").description("Show current configuration").option("-j, --json","Output as JSON").action(e=>{var t=(0,I.getBaseUrl)(),a=He(t);if(e.json)console.log(JSON.stringify({endpoint:t,environment:a||"custom"},null,2));else{console.log(k.Ay.bold("\nBRICKS CLI Configuration")),console.log("─".repeat(50)),console.log(`BRICKS: ${k.Ay.cyan(t)}`),a?console.log(`Environment: ${k.Ay.green(a)}`):console.log(`Environment: ${k.Ay.yellow("custom")}`);var n=(0,I.getActivityLogBaseUrl)(),i=Ke(n);console.log(`Activity Log: ${k.Ay.cyan(n)} ${i?k.Ay.green(`(${i})`):k.Ay.yellow("(custom)")}`),console.log("─".repeat(50))}});var Ze=new O("mcp").description("MCP server management");Ze.command("start").description("Start the BRICKS MCP server in STDIO mode").option("-t, --token <token>","API token (overrides saved token)").action(function(){var e=b(function*(e){var t=(0,I.getCurrentProfile)(),a=e.token||(0,I.getToken)(t);a||(console.error(k.Ay.red("Error: No API token found.")),console.error(k.Ay.gray("Please login first with: bricks auth login <passcode>")),console.error(k.Ay.gray("Or provide a token with: bricks mcp start --token <token>")),process.exit(1));try{var n=(yield Promise.all([y.e(428),y.e(300),y.e(425),y.e(737)]).then(y.bind(y,18737))).startStdioServer;yield n({token:a})}catch(e){console.error(k.Ay.red(`Failed to start MCP server: ${e.message}`)),process.exit(1)}});return function(t){return e.apply(this,arguments)}}());const et=t("node:fs/promises");var tt=y(76760),at=y(12044),nt=function(){var e=b(function*(e,t,a=3e3){try{var n=new AbortController,i=setTimeout(()=>n.abort(),a),o=yield fetch(`http://${e}:${t}/json/list`,{signal:n.signal});return clearTimeout(i),o.ok?yield o.json():null}catch{return null}});return function(t,a){return e.apply(this,arguments)}}(),it=e=>{if(!e)return null;var t=e.match(/\/ws\/(.+)$/);return t?decodeURIComponent(t[1]):null},ot=function(){var e=b(function*(e,t=1e3){for(var a=[],n=e,i=0;i<10;i++){var o=tt.join(n,".bricks","devtools.json");try{var r=yield et.readFile(o,"utf8"),s=JSON.parse(r),p=yield(0,at.verifyDevToolsServer)(s.address||"localhost",s.port,t);p&&a.push({name:s.name||"BRICKS Preview (CTOR Preview)",address:s.address||"localhost",port:s.port,protocols:["cdp"],hasPasscode:!1,source:"project",projectPath:n,...p})}catch{}var l=tt.dirname(n);if(l===n)break;n=l}return a});return function(t){return e.apply(this,arguments)}}(),rt=function(){var e=b(function*({timeout:e=3e3,verify:t=!1,udpOnly:a=!1,project:n=!0,port:i=19851,cwd:o=process.cwd(),onStatus:r}={}){var s=(0,at.discoverDevToolsServers)({timeout:e,idleTimeout:800}),p=a?Promise.resolve([]):(r?.("Scanning via UDP + HTTP probe..."),(0,at.httpProbeSubnet)({port:i,timeout:e})),l=n?ot(o,1e3):Promise.resolve([]),d=yield Promise.all([s,p,l]),c=J(d,3),u=(e=>{var t=new Map;for(var a of e){var n=a.deviceId||`${a.address}:${a.port}`,i=t.get(n);if(i){for(var o of(i.addresses.includes(a.address)||i.addresses.push(a.address),"127.0.0.1"===i.address&&"127.0.0.1"!==a.address&&(i.address=a.address),a.protocols||[]))i.protocols.includes(o)||i.protocols.push(o);for(var r of Object.entries(a)){var s=J(r,2),p=s[0],l=s[1];null!=l&&"address"!==p&&"addresses"!==p&&"protocols"!==p&&(void 0!==i[p]&&null!==i[p]||(i[p]=l))}}else t.set(n,{...a,addresses:[a.address],protocols:[...a.protocols||[]]})}return[...t.values()]})([...c[0],...c[1],...c[2]]);if(0===u.length)return[];if(t){r?.(`Verifying ${u.length} server(s)...`);var m=yield Promise.all(u.map(function(){var e=b(function*(e){var t=yield(0,at.verifyDevToolsServer)(e.address,e.port);return{...e,verified:!!t,version:t?.version||e.version}});return function(t){return e.apply(this,arguments)}}()));u.splice(0,u.length,...m)}return r?.("Checking chrome://inspect support..."),yield Promise.all(u.map(function(){var e=b(function*(e){var t=yield nt(e.address,e.port);if(t){e.chromeInspect=!0;var a=it(t[0]?.webSocketDebuggerUrl);a&&(e.passcode=a)}});return function(t){return e.apply(this,arguments)}}())),u});return function(){return e.apply(this,arguments)}}(),st="2.24",pt=e=>{if(!e)return!1;for(var t=e.replace(/^v/,"").split(".").map(Number),a=st.split(".").map(Number),n=0;n<a.length;n++){if((t[n]||0)>a[n])return!0;if((t[n]||0)<a[n])return!1}return!0},lt=e=>e.requiredOption("-a, --address <address>","DevTools server address").option("-p, --port <port>","Server port","19851").option("--passcode <passcode>","Device passcode").option("-j, --json","Output as JSON"),dt=function(){var e=b(function*(e,t){var a,n=(yield Promise.resolve().then(y.bind(y,29790))).default,i=(yield Promise.resolve().then(y.bind(y,12044))).verifyDevToolsServer,o=(yield y.e(999).then(y.bind(y,12999))).createCdpClient,r=parseInt(e.port,10),s=n("Connecting to DevTools...").start();try{var p=yield i(e.address,r);p||(s.fail(`Cannot reach DevTools server at ${e.address}:${r}`),process.exit(1)),p.version&&!pt(p.version)&&(s.fail(`CDP requires app version >= ${st} (device: ${p.version})`),process.exit(1)),a=o(e.address,r,e.passcode),yield a.connect(),s.stop(),yield t(a)}catch(e){s.isSpinning&&s.stop(),console.error(k.Ay.red(e.message)),process.exit(1)}finally{a?.close()}});return function(t,a){return e.apply(this,arguments)}}(),ct=e=>{if(!e)return{};for(var t={},a=0;a<e.length;a+=2)t[e[a]]=e[a+1];return t},ut=(e,t="",a=!0,n=!0)=>{var i=[],o=n?"":a?"└─ ":"├─ ",r=n?"":a?" ":"│ ",s=e.nodeName||"#unknown";if(9===e.nodeType)s="#document";else if(3===e.nodeType){var p=e.nodeValue||"";s=k.Ay.gray(`"${p}"`)}else if(1===e.nodeType){var l=ct(e.attributes),d=l.id||l["short-id"];d&&(s+=k.Ay.gray(`#${d}`)),l.title&&(s+=` ${k.Ay.green(`"${l.title}"`)}`),void 0!==l.w&&void 0!==l.h&&(s+=k.Ay.blue(` ${l.w}×${l.h}`),void 0!==l.x&&void 0!==l.y&&(s+=k.Ay.blue(` @${l.x},${l.y}`)));var c=[];void 0!==l.hide&&c.push(k.Ay.red("hidden")),void 0!==l.pressable&&c.push(k.Ay.yellow("pressable")),void 0!==l.editable&&c.push(k.Ay.yellow("editable")),c.length>0&&(s+=` [${c.join(", ")}]`)}i.push(`${t}${o}${s}`);var u=e.children||[];return u.forEach((e,a)=>{i.push(...ut(e,t+r,a===u.length-1,!1))}),i},mt=new O("devtools").description("DevTools server discovery, inspection, and CDP commands");mt.command("scan").description("Scan LAN for DevTools servers via UDP + HTTP").option("-t, --timeout <ms>","Scan timeout in milliseconds","3000").option("-j, --json","Output as JSON").option("--verify","Verify each discovered server via HTTP").option("--udp-only","Skip HTTP subnet probe (UDP only)").option("--no-project","Exclude local BRICKS project preview servers").option("-p, --port <port>","Port for HTTP probe","19851").action(function(){var e=b(function*(e){var t=(yield Promise.resolve().then(y.bind(y,29790))).default,a=yield Promise.resolve().then(y.bind(y,74752)),n=a.getCurrentProfile,i=a.getTokenInfo,o=parseInt(e.timeout,10),r=t(`Scanning for DevTools servers (${o}ms)...`).start();try{var s=yield rt({timeout:o,verify:!!e.verify,udpOnly:!!e.udpOnly,project:!!e.project,port:parseInt(e.port,10),onStatus:e=>{r.text=e}});if(0===s.length)return e.json?(r.stop(),console.log(JSON.stringify([],null,2))):r.info("No DevTools servers found on the network."),void process.exit(0);r.stop(),e.json&&(console.log(JSON.stringify(s,null,2)),process.exit(0));var p=i(n()),l=p?.workspaceId||null;console.log(k.Ay.bold(`\nFound ${s.length} DevTools server(s)`)),console.log("─".repeat(80));var d=function*(e){var t=!1===e.verified?k.Ay.red("unverified"):k.Ay.green("online"),a=e.hasPasscode?k.Ay.yellow("passcode"):k.Ay.gray("open"),n=(e.protocols||[]).map(e=>k.Ay.cyan(e)).join(", "),i=e.workspaceId&&l&&e.workspaceId===l,o=e.addresses||[e.address],r=o.filter(t=>t!==e.address),s=r.length>0?`${e.address}:${e.port} +${r.length} more`:`${e.address}:${e.port}`;if(console.log(` ${k.Ay.bold(e.name||"Unknown")} ${k.Ay.gray(`(${s})`)} [${t}]`),r.length>0&&console.log(` Addresses: ${o.map(e=>k.Ay.gray(e)).join(", ")}`),e.version&&console.log(` Version: ${k.Ay.green(e.version)}`),e.chromeInspect){var p=e.passcode?k.Ay.cyan(e.passcode):k.Ay.gray("no passcode");console.log(` Chrome Inspect: ${k.Ay.green("supported")} (passcode: ${p})`)}var d=` Protocols: ${n||k.Ay.gray("none")} Auth: ${a}`;if(e.deviceId&&(d+=` Device: ${k.Ay.gray(e.deviceId)}`),console.log(d),e.workspaceId){var c=i?k.Ay.green(`${e.workspaceId} (current profile)`):k.Ay.gray(e.workspaceId);console.log(` Workspace: ${c}`)}};for(var c of s)yield*d(c);console.log("─".repeat(80));var u=s[0],m=`${u.address}:${u.port||19851}`,f=u.passcode?`/ws/${encodeURIComponent(u.passcode)}`:"/ws/<passcode>";console.log(k.Ay.gray(`\nConnect via: devtools://devtools/bundled/inspector.html?ws=${m}${f}`)),process.exit(0)}catch(e){r.fail(`Scan failed: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),mt.command("open <address>").description("Show DevTools server information").option("-p, --port <port>","Server port","19851").option("--info","Show connection URLs").action(function(){var e=b(function*(e,t){var a=(yield Promise.resolve().then(y.bind(y,29790))).default,n=(yield Promise.resolve().then(y.bind(y,12044))).verifyDevToolsServer,i=parseInt(t.port,10),o=`${e}:${i}`,r=a(`Fetching server info from ${o}...`).start(),s=yield n(e,i);s||(r.fail(`Could not reach DevTools server at ${o}`),process.exit(1)),r.stop();var p=yield nt(e,i),l=p?it(p?.[0]?.webSocketDebuggerUrl):null,d=l?`/ws/${encodeURIComponent(l)}`:"/ws/<passcode>";if(t.info)return console.log(k.Ay.bold("Connection URLs")),console.log("─".repeat(60)),console.log(` Web UI: ${k.Ay.cyan(`http://${o}`)}`),console.log(` CDP: ${k.Ay.cyan(`devtools://devtools/bundled/inspector.html?ws=${o}${d}`)}`),console.log(` MCP: ${k.Ay.cyan(`http://${o}/mcp`)}`),console.log(` MCP SSE: ${k.Ay.cyan(`http://${o}/sse`)}`),console.log(` Info: ${k.Ay.cyan(`http://${o}/devtools/info`)}`),console.log("─".repeat(60)),console.log(),console.log(k.Ay.bold("Authorization")),l&&console.log(` Passcode: ${k.Ay.cyan(l)}`),console.log(" MCP and MCP SSE require a Bearer token header with the device passcode:"),void console.log(` ${k.Ay.gray(`Authorization: Bearer ${l||"<passcode>"}`)}`);if(console.log(k.Ay.bold("DevTools Server")),console.log("─".repeat(60)),console.log(` Name: ${k.Ay.cyan(s.name||"Unknown")}`),console.log(` Version: ${s.version?k.Ay.green(s.version):k.Ay.gray("N/A")}`),console.log(` Device ID: ${k.Ay.gray(s.deviceId||"N/A")}`),console.log(` Workspace: ${k.Ay.gray(s.workspaceId||"N/A")}`),console.log(` Protocols: ${(s.protocols||[]).map(e=>k.Ay.cyan(e)).join(", ")||k.Ay.gray("none")}`),console.log(` Auth: ${s.hasPasscode?k.Ay.yellow("passcode required"):k.Ay.gray("open")}`),console.log(` Port: ${s.port}`),p){var c=l?k.Ay.cyan(l):k.Ay.gray("no passcode");console.log(` Inspect: ${k.Ay.green("chrome://inspect supported")} (passcode: ${c})`)}else console.log(` Inspect: ${k.Ay.gray("chrome://inspect not available")}`);console.log("─".repeat(60)),s.version&&!pt(s.version)&&console.log(k.Ay.yellow(`\n CDP commands require version >= ${st}`)),console.log(k.Ay.gray("\n Use --info to see connection URLs"))});return function(t,a){return e.apply(this,arguments)}}()),lt(mt.command("screenshot").description("Capture device screenshot").option("-o, --output <path>","Output file path")).action(function(){var e=b(function*(e){yield dt(e,function(){var t=b(function*(t){var a=yield t.send("Page.captureScreenshot",{format:"png"});a.data||(console.error(k.Ay.red("No screenshot data received")),process.exit(1));var n=yield Promise.resolve().then(y.t.bind(y,73024,19)),i=yield Promise.resolve().then(y.t.bind(y,76760,19)),o=e.output||`screenshot-${Date.now()}.png`,r=i.resolve(o);n.writeFileSync(r,Buffer.from(a.data,"base64")),console.log(k.Ay.green(`Screenshot saved to ${r}`))});return function(e){return t.apply(this,arguments)}}())});return function(t){return e.apply(this,arguments)}}());var ft,vt,ht,gt,yt=mt.command("brick").description("Brick component inspection");lt(yt.command("tree").description("Print brick component tree").option("-d, --depth <depth>","Max depth (-1 for full)","3")).action(function(){var e=b(function*(e){yield dt(e,function(){var t=b(function*(t){yield t.send("DOM.enable");var a=parseInt(e.depth,10),n=(yield t.send("DOM.getDocument",{depth:a})).root;e.json?console.log(JSON.stringify(n,null,2)):console.log(ut(n).join("\n"))});return function(e){return t.apply(this,arguments)}}())});return function(t){return e.apply(this,arguments)}}()),lt(yt.command("query <selector>").description("Find brick by CSS selector")).action(function(){var e=b(function*(e,t){yield dt(t,function(){var a=b(function*(a){yield a.send("DOM.enable");var n=(yield a.send("DOM.getDocument",{depth:0})).root,i=(yield a.send("DOM.querySelector",{nodeId:n.nodeId,selector:e})).nodeId;if(0!==i){var o=yield a.send("DOM.describeNode",{nodeId:i}),r=(yield a.send("DOM.getAttributes",{nodeId:i})).attributes,s=ct(r);if(t.json)console.log(JSON.stringify({nodeId:i,...o.node,attributes:s},null,2));else if(console.log(k.Ay.bold(`Node ${i}: ${o.node?.nodeName||"unknown"}`)),Object.keys(s).length>0)for(var p of(console.log(k.Ay.bold("Attributes:")),Object.entries(s))){var l=J(p,2),d=l[0],c=l[1];console.log(` ${k.Ay.cyan(d)}: ${c}`)}}else console.log(k.Ay.yellow("No element found"))});return function(e){return a.apply(this,arguments)}}())});return function(t,a){return e.apply(this,arguments)}}()),lt(yt.command("query-all <selector>").description("Find all bricks matching CSS selector")).action(function(){var e=b(function*(e,t){yield dt(t,function(){var a=b(function*(a){yield a.send("DOM.enable");var n=(yield a.send("DOM.getDocument",{depth:0})).root,i=(yield a.send("DOM.querySelectorAll",{nodeId:n.nodeId,selector:e})).nodeIds;if(t.json)console.log(JSON.stringify({nodeIds:i,count:i.length},null,2));else for(var o of(console.log(k.Ay.bold(`Found ${i.length} element(s)`)),i)){var r=yield a.send("DOM.describeNode",{nodeId:o}),s=(yield a.send("DOM.getAttributes",{nodeId:o})).attributes,p=ct(s),l=p.id||p["short-id"]||"";console.log(` ${o}: ${r.node?.nodeName}${l?k.Ay.gray(`#${l}`):""}`)}});return function(e){return a.apply(this,arguments)}}())});return function(t,a){return e.apply(this,arguments)}}()),lt(yt.command("attributes <nodeId>").description("Get brick attributes")).action((ft=b(function*(e,t){var a;yield dt(t,(a=b(function*(a){yield a.send("DOM.enable");var n=parseInt(e,10),i=(yield a.send("DOM.getAttributes",{nodeId:n})).attributes,o=ct(i);if(t.json)console.log(JSON.stringify(o,null,2));else if(0!==Object.keys(o).length)for(var r of Object.entries(o)){var s=J(r,2),p=s[0],l=s[1];console.log(` ${k.Ay.cyan(p)}: ${l}`)}else console.log(k.Ay.gray("No attributes"))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return ft.apply(this,arguments)})),lt(yt.command("box-model <nodeId>").description("Get brick dimensions and position")).action((vt=b(function*(e,t){var a;yield dt(t,(a=b(function*(a){yield a.send("DOM.enable");var n=parseInt(e,10),i=(yield a.send("DOM.getBoxModel",{nodeId:n})).model;t.json?console.log(JSON.stringify(i,null,2)):(console.log(k.Ay.bold(`Box Model for node ${n}`)),console.log(` Width: ${i.width}`),console.log(` Height: ${i.height}`),i.content&&console.log(` Content: [${i.content.join(", ")}]`),i.padding&&console.log(` Padding: [${i.padding.join(", ")}]`),i.border&&console.log(` Border: [${i.border.join(", ")}]`),i.margin&&console.log(` Margin: [${i.margin.join(", ")}]`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return vt.apply(this,arguments)})),lt(yt.command("resolve <nodeId>").description("Resolve brick to JavaScript object with properties")).action((ht=b(function*(e,t){var a;yield dt(t,(a=b(function*(a){yield a.send("DOM.enable");var n=parseInt(e,10),i=(yield a.send("DOM.resolveNode",{nodeId:n})).object;if(t.json)console.log(JSON.stringify(i,null,2));else if(console.log(k.Ay.bold(`Resolved node ${n}`)),console.log(` Type: ${i.type}`),i.className&&console.log(` Class: ${i.className}`),i.description&&console.log(` Description: ${i.description}`),i.objectId&&console.log(` Object ID: ${k.Ay.gray(i.objectId)}`),i.preview?.properties)for(var o of(console.log(k.Ay.bold(" Properties:")),i.preview.properties))console.log(` ${k.Ay.cyan(o.name)}: ${o.value}`)}),function(e){return a.apply(this,arguments)}))}),function(e,t){return ht.apply(this,arguments)})),lt(yt.command("focus <nodeId>").description("Focus a brick element")).action((gt=b(function*(e,t){var a;yield dt(t,(a=b(function*(t){yield t.send("DOM.enable");var a=parseInt(e,10);yield t.send("DOM.focus",{nodeId:a}),console.log(k.Ay.green(`Focused node ${a}`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return gt.apply(this,arguments)}));var bt,Dt,xt,_t=mt.command("input").description("Input emulation");lt(_t.command("tap <x> <y>").description("Tap/click at coordinates")).action((bt=b(function*(e,t,a){var n;yield dt(a,(n=b(function*(a){var n=parseFloat(e),i=parseFloat(t);yield a.send("Input.dispatchMouseEvent",{type:"mousePressed",x:n,y:i,button:"left",clickCount:1}),yield a.send("Input.dispatchMouseEvent",{type:"mouseReleased",x:n,y:i,button:"left",clickCount:1}),console.log(k.Ay.green(`Tapped at (${n}, ${i})`))}),function(e){return n.apply(this,arguments)}))}),function(e,t,a){return bt.apply(this,arguments)})),lt(_t.command("type <text>").description("Insert text into focused element")).action((Dt=b(function*(e,t){var a;yield dt(t,(a=b(function*(t){yield t.send("Input.insertText",{text:e}),console.log(k.Ay.green(`Typed: ${e}`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return Dt.apply(this,arguments)})),lt(_t.command("key <key>").description("Dispatch key event (e.g., Enter, Escape, Tab)")).action((xt=b(function*(e,t){var a;yield dt(t,(a=b(function*(t){yield t.send("Input.dispatchKeyEvent",{type:"keyDown",key:e}),yield t.send("Input.dispatchKeyEvent",{type:"keyUp",key:e}),console.log(k.Ay.green(`Key: ${e}`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return xt.apply(this,arguments)}));var wt,Et,Tt=mt.command("network").description("Network inspection");lt(Tt.command("list").description("Capture snapshot of network activity").option("--duration <ms>","Capture duration in milliseconds","2000")).action((wt=b(function*(e){var t;yield dt(e,(t=b(function*(t){var a=new Map,n=parseInt(e.duration,10);t.on("Network.requestWillBeSent",e=>{a.set(e.requestId,{method:e.request.method,url:e.request.url,requestId:e.requestId,timestamp:e.timestamp})}),t.on("Network.responseReceived",e=>{var t=a.get(e.requestId);t&&(t.status=e.response.status,t.mimeType=e.response.mimeType)}),t.on("Network.loadingFailed",e=>{var t=a.get(e.requestId);t&&(t.error=e.errorText)}),yield t.send("Network.enable"),yield new Promise(e=>setTimeout(e,n)),yield t.send("Network.disable");var i=[...a.values()];if(e.json)console.log(JSON.stringify(i,null,2));else if(console.log(k.Ay.bold(`Network Activity (captured ${(n/1e3).toFixed(1)}s, ${i.length} requests)`)),0!==i.length)for(var o of i){var r=o.error?k.Ay.red("ERR"):o.status?o.status<300?k.Ay.green(o.status):o.status<400?k.Ay.yellow(o.status):k.Ay.red(o.status):k.Ay.gray("..."),s=o.url.length>60?o.url.substring(0,57)+"...":o.url;console.log(` ${r} ${k.Ay.bold(o.method.padEnd(6))} ${s} ${k.Ay.gray(`(${o.requestId})`)}`)}else console.log(k.Ay.gray(" No network activity captured"))}),function(e){return t.apply(this,arguments)}))}),function(e){return wt.apply(this,arguments)})),lt(Tt.command("get <requestId>").description("Get response body for a network request")).action((Et=b(function*(e,t){var a;yield dt(t,(a=b(function*(a){yield a.send("Network.enable");var n=yield a.send("Network.getResponseBody",{requestId:e}),i=n.body,o=n.base64Encoded;t.json?console.log(JSON.stringify({body:i,base64Encoded:o},null,2)):o?console.log(k.Ay.gray(`[base64 encoded, ${i.length} chars]`)):console.log(i)}),function(e){return a.apply(this,arguments)}))}),function(e,t){return Et.apply(this,arguments)}));var Nt,At,Ot=mt.command("storage").description("Storage inspection"),Ft=Ot.command("system").description("System key-value storage");lt(Ft.command("persist").description("Show persistent system storage entries")).action((Nt=b(function*(e){var t;yield dt(e,(t=b(function*(t){yield t.send("DOMStorage.enable");var a=(yield t.send("DOMStorage.getDOMStorageItems",{storageId:{securityOrigin:"bricks://app",isLocalStorage:!0}})).entries;if(e.json)console.log(JSON.stringify(a,null,2));else for(var n of(console.log(k.Ay.bold(`Persistent Storage (${a.length} items)`)),console.log("─".repeat(60)),a)){var i=J(n,2),o=i[0],r=i[1],s=r.length>80?r.substring(0,80)+"...":r;console.log(` ${k.Ay.cyan(o)}: ${s}`)}}),function(e){return t.apply(this,arguments)}))}),function(e){return Nt.apply(this,arguments)})),lt(Ft.command("memory").description("Show in-memory system storage entries")).action((At=b(function*(e){var t;yield dt(e,(t=b(function*(t){yield t.send("DOMStorage.enable");var a=(yield t.send("DOMStorage.getDOMStorageItems",{storageId:{securityOrigin:"bricks://app",isLocalStorage:!1}})).entries;if(e.json)console.log(JSON.stringify(a,null,2));else for(var n of(console.log(k.Ay.bold(`Memory Storage (${a.length} items)`)),console.log("─".repeat(60)),a)){var i=J(n,2),o=i[0],r=i[1],s=r.length>80?r.substring(0,80)+"...":r;console.log(` ${k.Ay.cyan(o)}: ${s}`)}}),function(e){return t.apply(this,arguments)}))}),function(e){return At.apply(this,arguments)}));var St,Ct,kt,It=Ot.command("data-bank").description("Property Bank data stores");lt(It.command("list").description("List Property Banks")).action((St=b(function*(e){var t;yield dt(e,(t=b(function*(t){yield t.send("IndexedDB.enable");var a=(yield t.send("IndexedDB.requestDatabaseNames",{securityOrigin:"bricks://app"})).databaseNames.filter(e=>e.startsWith("DATA-"));if(e.json)console.log(JSON.stringify(a,null,2));else for(var n of(console.log(k.Ay.bold(`Property Banks (${a.length})`)),a))console.log(` ${k.Ay.cyan(n)}`)}),function(e){return t.apply(this,arguments)}))}),function(e){return St.apply(this,arguments)})),lt(It.command("get <name> <store>").description("Query Property Bank data").option("-l, --limit <count>","Max items to fetch","25").option("-s, --skip <count>","Items to skip","0")).action((Ct=b(function*(e,t,a){var n;yield dt(a,(n=b(function*(n){yield n.send("IndexedDB.enable");var i=(yield n.send("IndexedDB.requestData",{securityOrigin:"bricks://app",databaseName:e,objectStoreName:t,indexName:"",skipCount:parseInt(a.skip,10),pageSize:parseInt(a.limit,10)})).objectStoreDataEntries;if(a.json)console.log(JSON.stringify(i,null,2));else for(var o of(console.log(k.Ay.bold(`${e} / ${t} (${i.length} entries)`)),console.log("─".repeat(60)),i)){var r=JSON.stringify(o.key?.value??o.key),s=JSON.stringify(o.value?.value??o.value),p=s.length>100?s.substring(0,100)+"...":s;console.log(` ${k.Ay.cyan(r)}: ${p}`)}}),function(e){return n.apply(this,arguments)}))}),function(e,t,a){return Ct.apply(this,arguments)})),lt(Ot.command("generator-cache").description("Show generator cache entries")).action((kt=b(function*(e){var t;yield dt(e,(t=b(function*(t){yield t.send("IndexedDB.enable");var a=(yield t.send("IndexedDB.requestData",{securityOrigin:"bricks://app",databaseName:"GENERATOR_CACHE",objectStoreName:"entries",indexName:"",skipCount:0,pageSize:100})).objectStoreDataEntries;if(e.json)console.log(JSON.stringify(a,null,2));else for(var n of(console.log(k.Ay.bold(`Generator Cache (${a.length} entries)`)),console.log("─".repeat(60)),a)){var i=JSON.stringify(n.key?.value??n.key),o=JSON.stringify(n.value?.value??n.value),r=o.length>100?o.substring(0,100)+"...":o;console.log(` ${k.Ay.cyan(i)}: ${r}`)}}),function(e){return t.apply(this,arguments)}))}),function(e){return kt.apply(this,arguments)}));var $t,jt,Rt=mt.command("runtime").description("Runtime and evaluation");lt(Rt.command("eval <expression>").description("Evaluate JavaScript expression").option("--await","Await promise result")).action(($t=b(function*(e,t){var a;yield dt(t,(a=b(function*(a){yield a.send("Runtime.enable");var n=yield a.send("Runtime.evaluate",{expression:e,objectGroup:"console",returnByValue:!0,awaitPromise:!!t.await,generatePreview:!0});if(t.json)console.log(JSON.stringify(n,null,2));else{n.exceptionDetails&&(console.error(k.Ay.red(`Error: ${n.exceptionDetails.text}`)),n.exceptionDetails.exception?.description&&console.error(k.Ay.red(n.exceptionDetails.exception.description)),process.exit(1));var i=n.result;if("undefined"===i.type)console.log(k.Ay.gray("undefined"));else if(void 0!==i.value){var o="object"==typeof i.value?JSON.stringify(i.value,null,2):String(i.value);console.log(o)}else i.description?console.log(i.description):console.log(k.Ay.gray(`[${i.type}${i.subtype?`:${i.subtype}`:""}]`))}}),function(e){return a.apply(this,arguments)}))}),function(e,t){return $t.apply(this,arguments)})),lt(Rt.command("properties <objectId>").description("Get properties of a remote object")).action((jt=b(function*(e,t){var a;yield dt(t,(a=b(function*(a){var n=(yield a.send("Runtime.getProperties",{objectId:e,ownProperties:!0})).result;if(t.json)console.log(JSON.stringify(n,null,2));else for(var i of(console.log(k.Ay.bold(`Properties of ${e}`)),n))if(i.enumerable){var o=i.value,r=o?.description||o?.value?.toString()||k.Ay.gray(`[${o?.type}]`);console.log(` ${k.Ay.cyan(i.name)}: ${r}`)}}),function(e){return a.apply(this,arguments)}))}),function(e,t){return jt.apply(this,arguments)}));var Vt=y(69278),Pt=y(70857),Bt=process.env.BRICKS_PROJECT_DESKTOP_DATA_DIR||Ee.join(Pt.homedir(),".bricks-project-desktop"),Lt=Ee.join(Bt,"acp.sock"),Mt=new O("desktop-acp-bridge").description("ACP bridge — connects acpx to the running CTOR desktop app").action(()=>{var e=Vt.connect(Lt);e.on("connect",()=>{process.stdin.pipe(e),e.pipe(process.stdout)}),e.on("error",e=>{"ENOENT"===e.code||"ECONNREFUSED"===e.code?process.stderr.write(`[acp] Cannot connect to CTOR.\n Make sure the desktop app is running and ACP is enabled in Settings.\n Socket: ${Lt}\n`):process.stderr.write(`[acp] Connection error: ${e.message}\n`),process.exit(1)}),e.on("close",()=>{process.exit(0)})}),Ut=y(77146);function qt(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:t}})}return qt=function(e){this.s=e,this.n=e.next},qt.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var a=this.s.return;return void 0===a?Promise.resolve({value:e,done:!0}):t(a.apply(this.s,arguments))},throw:function(e){var a=this.s.return;return void 0===a?Promise.reject(e):t(a.apply(this.s,arguments))}},new qt(e)}var zt=()=>{var e=(0,I.getCurrentProfile)(),t=(0,I.getToken)(e);return t||(console.error(k.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,Ut.W)((0,I.getActivityLogBaseUrl)(),t)},Gt=2592e6,Yt=e=>new Date(e).toISOString().replace("T"," ").replace(/\.\d+Z$/,"Z"),Qt=(e,t)=>{if(!e)return"";var a="string"==typeof e?e:JSON.stringify(e);return a.length>t?a.slice(0,t-1)+"…":a},Jt=new O("activity-log").alias("al").description("Activity log queries (read-only)");Jt.command("events").description("Query activity log events (all types)").requiredOption("--start-time <datetime>","Start time (ISO 8601 or relative: 1h, 30m, 2d)").option("--end-time <datetime>","End time (default: now)").option("--device <id>","Filter by device ID").option("--type <type>","Filter by event type: general, data, local_sync").option("--event-name <name>","Filter by event name").option("--subspace <id>","Filter by subspace ID").option("--sender <id>","Filter by sender").option("--limit <n>","Max events to display",parseInt).option("-j, --json","Output as JSON array").option("--jsonl","Output as JSONL (one JSON per line)").action(function(){var e=b(function*(e){var t=zt(),a=(e=>{var t=oe(e.startTime),a=e.endTime?oe(e.endTime):(new Date).toISOString();new Date(a)-new Date(t)>Gt&&(console.error(k.Ay.red("Time range must be 30 days or less")),process.exit(1));var n={start_time:t,end_time:a};return e.device&&(n.device_id=e.device),e.type&&(n.event_type=e.type),e.eventName&&(n.event_name=e.eventName),e.subspace&&(n.subspace_id=e.subspace),e.sender&&(n.sender=e.sender),n})(e);if(e.jsonl){var n=0;try{var i,o=!1,r=!1;try{for(var s,p=function(e){var t,a,n,i=2;for("undefined"!=typeof Symbol&&(a=Symbol.asyncIterator,n=Symbol.iterator);i--;){if(a&&null!=(t=e[a]))return t.call(e);if(n&&null!=(t=e[n]))return new qt(t.call(e));a="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}(t.events(a));o=!(s=yield p.next()).done;o=!1){var l=s.value;if(console.log(JSON.stringify(l)),n++,e.limit&&n>=e.limit)break}}catch(e){r=!0,i=e}finally{try{o&&null!=p.return&&(yield p.return())}finally{if(r)throw i}}}catch(e){console.error(k.Ay.red(`Failed to query events: ${e.message}`)),process.exit(1)}}else{var d=(0,j.default)("Querying events...").start();try{var c=yield t.collectEvents(a,{limit:e.limit});if(d.stop(),e.json)return void console.log(JSON.stringify(c,null,2));if(0===c.length)return void console.log(k.Ay.yellow("No events found"));for(var u of(console.log(k.Ay.bold(`\nActivity Log Events (${c.length})`)),console.log("─".repeat(100)),console.log(k.Ay.gray(`${"Timestamp".padEnd(24)} ${"Type".padEnd(12)} ${"Device".padEnd(14)} ${"Event Name".padEnd(28)} ${"Sender".padEnd(16)} Payload`)),console.log("─".repeat(100)),c)){var m=Yt(u.timestamp),f=(u.event_type||"").padEnd(12),v=Qt(u.device_id,14).padEnd(14),h=Qt(u.event_name,28).padEnd(28),g=Qt(u.sender,16).padEnd(16),y=Qt(u.payload,40);console.log(`${m} ${f} ${v} ${h} ${g} ${k.Ay.gray(y)}`)}console.log("─".repeat(100))}catch(e){d.fail(`Failed to query events: ${e.message}`),process.exit(1)}}});return function(t){return e.apply(this,arguments)}}()),Jt.command("screenshots").description("List screenshot timestamps for a device").requiredOption("--device <id>","Device ID (required)").requiredOption("--start-time <datetime>","Start time (ISO 8601 or relative: 1h, 30m, 2d)").option("--end-time <datetime>","End time (default: now)").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){var t=zt(),a=oe(e.startTime),n=e.endTime?oe(e.endTime):(new Date).toISOString();new Date(n)-new Date(a)>Gt&&(console.error(k.Ay.red("Time range must be 30 days or less")),process.exit(1));var i={device_id:e.device,start_time:a,end_time:n},o=(0,j.default)("Querying screenshots...").start();try{var r=yield t.collectScreenshots(i);if(o.stop(),e.json)return void console.log(JSON.stringify(r,null,2));if(0===r.length)return void console.log(k.Ay.yellow("No screenshots found"));console.log(k.Ay.bold(`\nScreenshots (${r.length})`)),console.log("─".repeat(40)),console.log(k.Ay.gray(`${"#".padStart(4)} Timestamp`)),console.log("─".repeat(40)),r.forEach((e,t)=>{console.log(`${String(t+1).padStart(4)} ${Yt(e.timestamp)}`)}),console.log("─".repeat(40))}catch(e){o.fail(`Failed to query screenshots: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),Jt.command("screenshot").description("Download a screenshot image").requiredOption("--device <id>","Device ID").requiredOption("--ts <timestamp>","Screenshot timestamp (ISO 8601 or epoch ms)").option("--space <id>","Workspace/space ID (auto-detected from profile)").option("-o, --output <path>","Output file path").option("--open","Open with OS default viewer after download").action(function(){var e=b(function*(e){var t,a,n=zt(),i=e.space||(t=(0,I.getCurrentProfile)(),a=(0,I.getTokenInfo)(t),a?.workspaceId);i||(console.error(k.Ay.red("Could not determine workspace ID. Use --space <id> or log in first.")),process.exit(1));var o=/^\d+$/.test(e.ts)?e.ts:new Date(e.ts).getTime(),r=(0,j.default)("Downloading screenshot...").start();try{var s=yield n.downloadScreenshot(i,e.device,o);r.stop();var p=e.output||`screenshot-${e.device}-${o}.jpg`,l=Ee.resolve(p);_e.writeFileSync(l,s);var d=(s.length/1024).toFixed(1);if(console.log(k.Ay.green(`✓ Screenshot saved: ${l} (${d} KB)`)),e.open)(0,(yield Promise.resolve().then(y.t.bind(y,35317,19))).exec)(`${"darwin"===process.platform?"open":"win32"===process.platform?"start":"xdg-open"} "${l}"`)}catch(e){r.fail(`Failed to download screenshot: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}());var Ht=function(){var e=b(function*(){try{return yield Promise.all([y.e(428),y.e(300),y.e(425),y.e(737)]).then(y.bind(y,18737)),{available:!0}}catch(e){return{available:!1,error:e.message}}});return function(){return e.apply(this,arguments)}}(),Wt=(e,t,a)=>({severity:e,code:t,message:a}),Kt=function(){var e=b(function*({version:e="2.24.1-beta.2",mcpCheck:t=Ht}={}){var a=(0,I.getCurrentProfile)(),n=(0,I.getCurrentProfileSource)(),i=(0,I.getTokenInfo)(a),o=(0,I.getBaseUrl)(),r=(0,I.getActivityLogBaseUrl)(),s=[],p={ok:!1,timestamp:(new Date).toISOString(),cli:{name:"bricks",version:e},profile:{name:a,source:n},config:{path:I.CONFIG_PATH,baseUrl:o,activityLogBaseUrl:r},auth:{available:Boolean(i?.token),source:i?.token?"config":"missing",workspaceId:i?.workspaceId||null,workspaceName:i?.workspaceName||null,createdAt:i?.createdAt||null,tokenPreview:G(i?.token)},connectivity:{workspace:{ok:!1,skipped:!i?.token,error:null}},capabilities:{zeroArgMode:$()?"interactive":"help",mcp:{available:!1,error:null}},issues:s};if(i?.token)try{var l=yield(0,U.createClient)(o,i.token).workspace();p.connectivity.workspace={ok:!0,skipped:!1,error:null,id:l?._id||i.workspaceId||null,name:l?.name||i.workspaceName||null},p.auth.workspaceId=l?._id||p.auth.workspaceId,p.auth.workspaceName=l?.name||p.auth.workspaceName}catch(e){p.connectivity.workspace={ok:!1,skipped:!1,error:e.message},s.push(Wt("error","workspace_unreachable",`Workspace query failed for ${o}: ${e.message}`))}else s.push(Wt("warning","auth_missing","No saved token for the current profile."));var d=yield t();return p.capabilities.mcp={available:d.available,error:d.error||null},d.available||s.push(Wt("warning","mcp_unavailable",`MCP stdio server is unavailable: ${d.error||"Unknown error"}`)),p.ok=0===s.length,p});return function(){return e.apply(this,arguments)}}(),Xt=(e,t,a)=>`${e.padEnd(14)} ${t}${a?` ${a}`:""}`,Zt=new O("doctor").description("Check CLI configuration, auth state, and workspace reachability").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){try{var t=yield Kt();if(e.json)return void q(t);console.log((e=>{var t=[];if(t.push("BRICKS CLI Doctor"),t.push("─".repeat(60)),t.push(Xt("CLI","OK",`bricks v${e.cli.version}`)),t.push(Xt("Profile","OK",`${e.profile.name} (${e.profile.source})`)),t.push(Xt("BRICKS API","OK",e.config.baseUrl)),t.push(Xt("Activity Log","OK",e.config.activityLogBaseUrl)),e.auth.available){var a=e.auth.workspaceName||e.auth.workspaceId||"Unknown workspace";t.push(Xt("Auth","OK",`${a} (${e.auth.source}, ${e.auth.tokenPreview})`))}else t.push(Xt("Auth","WARN","No saved token for the current profile"));if(e.connectivity.workspace.skipped)t.push(Xt("Workspace","WARN","Skipped because no token is available"));else if(e.connectivity.workspace.ok){var n=e.connectivity.workspace.name||e.connectivity.workspace.id||"Unknown workspace";t.push(Xt("Workspace","OK",n))}else t.push(Xt("Workspace","FAIL",e.connectivity.workspace.error));return e.capabilities.mcp.available?t.push(Xt("MCP","OK","STDIO server import is available")):t.push(Xt("MCP","WARN",e.capabilities.mcp.error)),t.push(Xt("Zero-arg mode",((e,t=!1)=>e?"OK":t?"WARN":"FAIL")("interactive"===e.capabilities.zeroArgMode,"help"===e.capabilities.zeroArgMode),"interactive"===e.capabilities.zeroArgMode?"Starts Ink interactive mode on TTY":"Shows help outside TTY contexts")),e.issues.length>0&&(t.push("─".repeat(60)),t.push("Issues"),e.issues.forEach(e=>{t.push(`- [${e.severity}] ${e.message}`)})),t.join("\n")})(t))}catch(t){e.json?z(t.message):console.error(`Doctor failed: ${t.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),ea=function(){var e=b(function*(){var e=process.argv.findIndex(e=>"--auth-profile"===e||"-ap"===e);-1!==e&&process.argv[e+1]&&((0,I.setProfileOverride)(process.argv[e+1]),process.argv.splice(e,2)),x.name("bricks").description("BRICKS CLI - Command-line interface for BRICKS Workspace API").version("2.24.1-beta.2").enablePositionalOptions(),x.addCommand(Q),x.addCommand(be),x.addCommand(Oe),x.addCommand(Ce),x.addCommand(Ve),x.addCommand(ze),x.addCommand(Xe),x.addCommand(Ze),x.addCommand(mt),x.addCommand(Mt),x.addCommand(Jt),x.addCommand(Zt),x.command("interactive").alias("i").description("Start interactive mode with Ink UI").action(b(function*(){try{var e=(yield Promise.all([y.e(63),y.e(779)]).then(y.bind(y,18779))).runInteractiveMode;yield e()}catch(e){console.error(k.Ay.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}})),x.command("workspace").alias("ws").description("Show current workspace information").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){var t=yield Promise.resolve().then(y.bind(y,74752)),a=t.getToken,n=t.getBaseUrl,i=t.getCurrentProfile,o=(yield Promise.resolve().then(y.bind(y,50700))).createClient,r=(yield Promise.resolve().then(y.bind(y,29790))).default,s=a(i());s||(console.error(k.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1));var p=r("Fetching workspace info...").start();try{var l=o(n(),s),d=yield l.workspace();if(p.stop(),e.json)return void console.log(JSON.stringify(d,null,2));console.log(k.Ay.bold("\nWorkspace Information")),console.log("─".repeat(60)),console.log(`Name: ${k.Ay.green(d.name)}`),console.log(`ID: ${k.Ay.gray(d._id)}`),console.log(`Description: ${d.description||k.Ay.gray("N/A")}`),console.log(`\n${k.Ay.bold("Data")}`),console.log(`Remote Update: ${d.bank?.enable_remote_update?k.Ay.green("Enabled"):k.Ay.gray("Disabled")}`),console.log(`Spacename: ${d.bank?.spacename||k.Ay.gray("N/A")}`),console.log("─".repeat(60))}catch(e){p.fail(`Failed to get workspace: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),x.on("--help",()=>{console.log(""),console.log(k.Ay.bold("Examples:")),console.log(""),console.log(k.Ay.gray(" # Login with a one-time passcode (recommended)")),console.log(" $ bricks auth login <passcode>"),console.log(""),console.log(k.Ay.gray(" # List all devices")),console.log(" $ bricks device list"),console.log(""),console.log(k.Ay.gray(" # Monitor devices in real-time")),console.log(" $ bricks device monitor"),console.log(""),console.log(k.Ay.gray(" # Control a device")),console.log(" $ bricks device refresh <device-id>"),console.log(" $ bricks device control <device-id> clear-cache"),console.log(""),console.log(k.Ay.gray(" # Bind a new device")),console.log(' $ bricks device bind <passcode> -n "My Device"'),console.log(""),console.log(k.Ay.gray(" # List applications")),console.log(" $ bricks app list"),console.log(""),console.log(k.Ay.gray(" # Start interactive mode")),console.log(" $ bricks interactive"),console.log(""),console.log(k.Ay.gray(" # Change API endpoint")),console.log(" $ bricks config endpoint beta"),console.log(""),console.log(k.Ay.gray("Get workspace token from BRICKS Controller:")),console.log(k.Ay.cyan(" https://control.bricks.tools")),console.log(k.Ay.gray(" Go to Workspace Settings > API Token"))});var t=process.argv.slice(2);if(0===t.length){if(((e=[])=>0===e.length&&$())(t))try{var a=(yield Promise.all([y.e(63),y.e(779)]).then(y.bind(y,18779))).runInteractiveMode;return void(yield a())}catch(e){console.error(k.Ay.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}return console.error(k.Ay.gray("No command provided. Interactive mode requires a TTY, so showing help instead.\n")),void x.outputHelp()}yield x.parseAsync(process.argv)});return function(){return e.apply(this,arguments)}}();const ta=ea;export{ta as default,ea as run};
|
|
752
|
+
`},94370:(e,t,a)=>{a.r(t),a.d(t,{default:()=>w,disableExperimentalFragmentVariables:()=>h,disableFragmentWarnings:()=>f,enableExperimentalFragmentVariables:()=>v,gql:()=>u,resetCaches:()=>m});var n=a(85608),i=a(93367),o=new Map,r=new Map,s=!0,p=!1;function l(e){return e.replace(/[\s,]+/g," ").trim()}function d(e){var t=new Set,a=[];return e.definitions.forEach(function(e){if("FragmentDefinition"===e.kind){var n=e.name.value,i=l((p=e.loc).source.body.substring(p.start,p.end)),o=r.get(n);o&&!o.has(i)?s&&console.warn("Warning: fragment with name "+n+" already exists.\ngraphql-tag enforces all fragment names across your application to be unique; read more about\nthis in the docs: http://dev.apollodata.com/core/fragments.html#unique-names"):o||r.set(n,o=new Set),o.add(i),t.has(i)||(t.add(i),a.push(e))}else a.push(e);var p}),(0,n.__assign)((0,n.__assign)({},e),{definitions:a})}function c(e){var t=l(e);if(!o.has(t)){var a=(0,i.qg)(e,{experimentalFragmentVariables:p,allowLegacyFragmentVariables:p});if(!a||"Document"!==a.kind)throw new Error("Not a valid GraphQL document.");o.set(t,function(e){var t=new Set(e.definitions);t.forEach(function(e){e.loc&&delete e.loc,Object.keys(e).forEach(function(a){var n=e[a];n&&"object"==typeof n&&t.add(n)})});var a=e.loc;return a&&(delete a.startToken,delete a.endToken),e}(d(a)))}return o.get(t)}function u(e){for(var t=[],a=1;a<arguments.length;a++)t[a-1]=arguments[a];"string"==typeof e&&(e=[e]);var n=e[0];return t.forEach(function(t,a){t&&"Document"===t.kind?n+=t.loc.source.body:n+=t,n+=e[a+1]}),c(n)}function m(){o.clear(),r.clear()}function f(){s=!1}function v(){p=!0}function h(){p=!1}var g,y=u,b=m,D=f,x=v,_=h;(g=u||(u={})).gql=y,g.resetCaches=b,g.disableFragmentWarnings=D,g.enableExperimentalFragmentVariables=x,g.disableExperimentalFragmentVariables=_,u.default=u;const w=u},96525:e=>{e.exports=function(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var n,i,o,r,s=[],p=!0,l=!1;try{if(o=(a=a.call(e)).next,0===t){if(Object(a)!==a)return;p=!1}else for(;!(p=(n=o.call(a)).done)&&(s.push(n.value),s.length!==t);p=!0);}catch(e){l=!0,i=e}finally{try{if(!p&&null!=a.return&&(r=a.return(),Object(r)!==r))return}finally{if(l)throw i}}return s}},e.exports.__esModule=!0,e.exports.default=e.exports},98472:(e,t,a)=>{a.d(t,{Ey:()=>v,JG:()=>p,MQ:()=>A,Z_:()=>l,qA:()=>f});var n=a(59841),i=a(59762),o=a(67714),r=a(25881),s=a(12039);class p{constructor(e){const t=new i.ou(s.Y.SOF,0,0,0,0);this.source=e,this.lastToken=t,this.token=t,this.line=1,this.lineStart=0}get[Symbol.toStringTag](){return"Lexer"}advance(){this.lastToken=this.token;return this.token=this.lookahead()}lookahead(){let e=this.token;if(e.kind!==s.Y.EOF)do{if(e.next)e=e.next;else{const t=h(this,e.end);e.next=t,t.prev=e,e=t}}while(e.kind===s.Y.COMMENT);return e}}function l(e){return e===s.Y.BANG||e===s.Y.DOLLAR||e===s.Y.AMP||e===s.Y.PAREN_L||e===s.Y.PAREN_R||e===s.Y.DOT||e===s.Y.SPREAD||e===s.Y.COLON||e===s.Y.EQUALS||e===s.Y.AT||e===s.Y.BRACKET_L||e===s.Y.BRACKET_R||e===s.Y.BRACE_L||e===s.Y.PIPE||e===s.Y.BRACE_R}function d(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function c(e,t){return u(e.charCodeAt(t))&&m(e.charCodeAt(t+1))}function u(e){return e>=55296&&e<=56319}function m(e){return e>=56320&&e<=57343}function f(e,t){const a=e.source.body.codePointAt(t);if(void 0===a)return s.Y.EOF;if(a>=32&&a<=126){const e=String.fromCodePoint(a);return'"'===e?"'\"'":`"${e}"`}return"U+"+a.toString(16).toUpperCase().padStart(4,"0")}function v(e,t,a,n,o){const r=e.line,s=1+a-e.lineStart;return new i.ou(t,a,n,r,s,o)}function h(e,t){const a=e.source.body,i=a.length;let o=t;for(;o<i;){const t=a.charCodeAt(o);switch(t){case 65279:case 9:case 32:case 44:++o;continue;case 10:++o,++e.line,e.lineStart=o;continue;case 13:10===a.charCodeAt(o+1)?o+=2:++o,++e.line,e.lineStart=o;continue;case 35:return g(e,o);case 33:return v(e,s.Y.BANG,o,o+1);case 36:return v(e,s.Y.DOLLAR,o,o+1);case 38:return v(e,s.Y.AMP,o,o+1);case 40:return v(e,s.Y.PAREN_L,o,o+1);case 41:return v(e,s.Y.PAREN_R,o,o+1);case 46:if(46===a.charCodeAt(o+1)&&46===a.charCodeAt(o+2))return v(e,s.Y.SPREAD,o,o+3);break;case 58:return v(e,s.Y.COLON,o,o+1);case 61:return v(e,s.Y.EQUALS,o,o+1);case 64:return v(e,s.Y.AT,o,o+1);case 91:return v(e,s.Y.BRACKET_L,o,o+1);case 93:return v(e,s.Y.BRACKET_R,o,o+1);case 123:return v(e,s.Y.BRACE_L,o,o+1);case 124:return v(e,s.Y.PIPE,o,o+1);case 125:return v(e,s.Y.BRACE_R,o,o+1);case 34:return 34===a.charCodeAt(o+1)&&34===a.charCodeAt(o+2)?N(e,o):D(e,o)}if((0,r.yp)(t)||45===t)return y(e,o,t);if((0,r.un)(t))return A(e,o);throw(0,n.I)(e.source,o,39===t?"Unexpected single quote character ('), did you mean to use a double quote (\")?":d(t)||c(a,o)?`Unexpected character: ${f(e,o)}.`:`Invalid character: ${f(e,o)}.`)}return v(e,s.Y.EOF,i,i)}function g(e,t){const a=e.source.body,n=a.length;let i=t+1;for(;i<n;){const e=a.charCodeAt(i);if(10===e||13===e)break;if(d(e))++i;else{if(!c(a,i))break;i+=2}}return v(e,s.Y.COMMENT,t,i,a.slice(t+1,i))}function y(e,t,a){const i=e.source.body;let o=t,p=a,l=!1;if(45===p&&(p=i.charCodeAt(++o)),48===p){if(p=i.charCodeAt(++o),(0,r.yp)(p))throw(0,n.I)(e.source,o,`Invalid number, unexpected digit after 0: ${f(e,o)}.`)}else o=b(e,o,p),p=i.charCodeAt(o);if(46===p&&(l=!0,p=i.charCodeAt(++o),o=b(e,o,p),p=i.charCodeAt(o)),69!==p&&101!==p||(l=!0,p=i.charCodeAt(++o),43!==p&&45!==p||(p=i.charCodeAt(++o)),o=b(e,o,p),p=i.charCodeAt(o)),46===p||(0,r.un)(p))throw(0,n.I)(e.source,o,`Invalid number, expected digit but got: ${f(e,o)}.`);return v(e,l?s.Y.FLOAT:s.Y.INT,t,o,i.slice(t,o))}function b(e,t,a){if(!(0,r.yp)(a))throw(0,n.I)(e.source,t,`Invalid number, expected digit but got: ${f(e,t)}.`);const i=e.source.body;let o=t+1;for(;(0,r.yp)(i.charCodeAt(o));)++o;return o}function D(e,t){const a=e.source.body,i=a.length;let o=t+1,r=o,p="";for(;o<i;){const i=a.charCodeAt(o);if(34===i)return p+=a.slice(r,o),v(e,s.Y.STRING,t,o+1,p);if(92===i){p+=a.slice(r,o);const t=117===a.charCodeAt(o+1)?123===a.charCodeAt(o+2)?x(e,o):_(e,o):T(e,o);p+=t.value,o+=t.size,r=o;continue}if(10===i||13===i)break;if(d(i))++o;else{if(!c(a,o))throw(0,n.I)(e.source,o,`Invalid character within String: ${f(e,o)}.`);o+=2}}throw(0,n.I)(e.source,o,"Unterminated string.")}function x(e,t){const a=e.source.body;let i=0,o=3;for(;o<12;){const e=a.charCodeAt(t+o++);if(125===e){if(o<5||!d(i))break;return{value:String.fromCodePoint(i),size:o}}if(i=i<<4|E(e),i<0)break}throw(0,n.I)(e.source,t,`Invalid Unicode escape sequence: "${a.slice(t,t+o)}".`)}function _(e,t){const a=e.source.body,i=w(a,t+2);if(d(i))return{value:String.fromCodePoint(i),size:6};if(u(i)&&92===a.charCodeAt(t+6)&&117===a.charCodeAt(t+7)){const e=w(a,t+8);if(m(e))return{value:String.fromCodePoint(i,e),size:12}}throw(0,n.I)(e.source,t,`Invalid Unicode escape sequence: "${a.slice(t,t+6)}".`)}function w(e,t){return E(e.charCodeAt(t))<<12|E(e.charCodeAt(t+1))<<8|E(e.charCodeAt(t+2))<<4|E(e.charCodeAt(t+3))}function E(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function T(e,t){const a=e.source.body;switch(a.charCodeAt(t+1)){case 34:return{value:'"',size:2};case 92:return{value:"\\",size:2};case 47:return{value:"/",size:2};case 98:return{value:"\b",size:2};case 102:return{value:"\f",size:2};case 110:return{value:"\n",size:2};case 114:return{value:"\r",size:2};case 116:return{value:"\t",size:2}}throw(0,n.I)(e.source,t,`Invalid character escape sequence: "${a.slice(t,t+2)}".`)}function N(e,t){const a=e.source.body,i=a.length;let r=e.lineStart,p=t+3,l=p,u="";const m=[];for(;p<i;){const i=a.charCodeAt(p);if(34===i&&34===a.charCodeAt(p+1)&&34===a.charCodeAt(p+2)){u+=a.slice(l,p),m.push(u);const n=v(e,s.Y.BLOCK_STRING,t,p+3,(0,o.OC)(m).join("\n"));return e.line+=m.length-1,e.lineStart=r,n}if(92!==i||34!==a.charCodeAt(p+1)||34!==a.charCodeAt(p+2)||34!==a.charCodeAt(p+3))if(10!==i&&13!==i)if(d(i))++p;else{if(!c(a,p))throw(0,n.I)(e.source,p,`Invalid character within String: ${f(e,p)}.`);p+=2}else u+=a.slice(l,p),m.push(u),13===i&&10===a.charCodeAt(p+1)?p+=2:++p,u="",l=p,r=p;else u+=a.slice(l,p),l=p+1,p+=4}throw(0,n.I)(e.source,p,"Unterminated string.")}function A(e,t){const a=e.source.body,n=a.length;let i=t+1;for(;i<n;){const e=a.charCodeAt(i);if(!(0,r.xr)(e))break;++i}return v(e,s.Y.NAME,t,i,a.slice(t,i))}},98706:(e,t,a)=>{const n=a(78323);t.implementation=class{constructor(e){const t=e[0],a=e[1];let i=null;if(void 0!==a&&(i=n.basicURLParse(a),"failure"===i))throw new TypeError("Invalid base URL");const o=n.basicURLParse(t,{baseURL:i});if("failure"===o)throw new TypeError("Invalid URL");this._url=o}get href(){return n.serializeURL(this._url)}set href(e){const t=n.basicURLParse(e);if("failure"===t)throw new TypeError("Invalid URL");this._url=t}get origin(){return n.serializeURLOrigin(this._url)}get protocol(){return this._url.scheme+":"}set protocol(e){n.basicURLParse(e+":",{url:this._url,stateOverride:"scheme start"})}get username(){return this._url.username}set username(e){n.cannotHaveAUsernamePasswordPort(this._url)||n.setTheUsername(this._url,e)}get password(){return this._url.password}set password(e){n.cannotHaveAUsernamePasswordPort(this._url)||n.setThePassword(this._url,e)}get host(){const e=this._url;return null===e.host?"":null===e.port?n.serializeHost(e.host):n.serializeHost(e.host)+":"+n.serializeInteger(e.port)}set host(e){this._url.cannotBeABaseURL||n.basicURLParse(e,{url:this._url,stateOverride:"host"})}get hostname(){return null===this._url.host?"":n.serializeHost(this._url.host)}set hostname(e){this._url.cannotBeABaseURL||n.basicURLParse(e,{url:this._url,stateOverride:"hostname"})}get port(){return null===this._url.port?"":n.serializeInteger(this._url.port)}set port(e){n.cannotHaveAUsernamePasswordPort(this._url)||(""===e?this._url.port=null:n.basicURLParse(e,{url:this._url,stateOverride:"port"}))}get pathname(){return this._url.cannotBeABaseURL?this._url.path[0]:0===this._url.path.length?"":"/"+this._url.path.join("/")}set pathname(e){this._url.cannotBeABaseURL||(this._url.path=[],n.basicURLParse(e,{url:this._url,stateOverride:"path start"}))}get search(){return null===this._url.query||""===this._url.query?"":"?"+this._url.query}set search(e){const t=this._url;if(""===e)return void(t.query=null);const a="?"===e[0]?e.substring(1):e;t.query="",n.basicURLParse(a,{url:t,stateOverride:"query"})}get hash(){return null===this._url.fragment||""===this._url.fragment?"":"#"+this._url.fragment}set hash(e){if(""===e)return void(this._url.fragment=null);const t="#"===e[0]?e.substring(1):e;this._url.fragment="",n.basicURLParse(t,{url:this._url,stateOverride:"fragment"})}toJSON(){return this.href}}},99436:e=>{function t(e,t,a,n,i,o,r){try{var s=e[o](r),p=s.value}catch(e){return void a(e)}s.done?t(p):Promise.resolve(p).then(n,i)}e.exports=function(e){return function(){var a=this,n=arguments;return new Promise(function(i,o){var r=e.apply(a,n);function s(e){t(r,i,o,s,p,"next",e)}function p(e){t(r,i,o,s,p,"throw",e)}s(void 0)})}},e.exports.__esModule=!0,e.exports.default=e.exports},99690:(e,t,a)=>{const{humanReadableArgName:n}=a(41762);t.Help=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){const t=e.commands.filter(e=>!e._hidden),a=e._getHelpCommand();return a&&!a._hidden&&t.push(a),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){const a=e=>e.short?e.short.replace(/^-/,""):e.long.replace(/^--/,"");return a(e).localeCompare(a(t))}visibleOptions(e){const t=e.options.filter(e=>!e.hidden),a=e._getHelpOption();if(a&&!a.hidden){const n=a.short&&e._findOption(a.short),i=a.long&&e._findOption(a.long);n||i?a.long&&!i?t.push(e.createOption(a.long,a.description)):a.short&&!n&&t.push(e.createOption(a.short,a.description)):t.push(a)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];const t=[];for(let a=e.parent;a;a=a.parent){const e=a.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){const t=e.registeredArguments.map(e=>n(e)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,a)=>Math.max(e,t.subcommandTerm(a).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,a)=>Math.max(e,t.optionTerm(a).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,a)=>Math.max(e,t.optionTerm(a).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,a)=>Math.max(e,t.argumentTerm(a).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let a="";for(let t=e.parent;t;t=t.parent)a=t.name()+" "+a;return a+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){const t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),void 0!==e.defaultValue){(e.required||e.optional||e.isBoolean()&&"boolean"==typeof e.defaultValue)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`)}return void 0!==e.presetArg&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),void 0!==e.envVar&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){const t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),void 0!==e.defaultValue&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){const a=`(${t.join(", ")})`;return e.description?`${e.description} ${a}`:a}return e.description}formatHelp(e,t){const a=t.padWidth(e,t),n=t.helpWidth||80;function i(e,i){if(i){const o=`${e.padEnd(a+2)}${i}`;return t.wrap(o,n-2,a+2)}return e}function o(e){return e.join("\n").replace(/^/gm," ".repeat(2))}let r=[`Usage: ${t.commandUsage(e)}`,""];const s=t.commandDescription(e);s.length>0&&(r=r.concat([t.wrap(s,n,0),""]));const p=t.visibleArguments(e).map(e=>i(t.argumentTerm(e),t.argumentDescription(e)));p.length>0&&(r=r.concat(["Arguments:",o(p),""]));const l=t.visibleOptions(e).map(e=>i(t.optionTerm(e),t.optionDescription(e)));if(l.length>0&&(r=r.concat(["Options:",o(l),""])),this.showGlobalOptions){const a=t.visibleGlobalOptions(e).map(e=>i(t.optionTerm(e),t.optionDescription(e)));a.length>0&&(r=r.concat(["Global Options:",o(a),""]))}const d=t.visibleCommands(e).map(e=>i(t.subcommandTerm(e),t.subcommandDescription(e)));return d.length>0&&(r=r.concat(["Commands:",o(d),""])),r.join("\n")}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,a,n=40){const i=new RegExp("[\\n][ \\f\\t\\v - \ufeff]+");if(e.match(i))return e;const o=t-a;if(o<n)return e;const r=e.slice(0,a),s=e.slice(a).replace("\r\n","\n"),p=" ".repeat(a),l="\\s",d=new RegExp(`\n|.{1,${o-1}}([${l}]|$)|[^${l}]+?([${l}]|$)`,"g");return r+(s.match(d)||[]).map((e,t)=>"\n"===e?"":(t>0?p:"")+e.trimEnd()).join("\n")}}}},g={};function y(e){var t=g[e];if(void 0!==t)return t.exports;var a=g[e]={id:e,loaded:!1,exports:{}};return h[e].call(a.exports,a,a.exports,y),a.loaded=!0,a.exports}y.m=h,s="function"==typeof Symbol,p=s?Symbol("webpack queues"):"__webpack_queues__",l=s?Symbol("webpack exports"):"__webpack_exports__",d=s?Symbol("webpack error"):"__webpack_error__",c=e=>{e&&e.d<1&&(e.d=1,e.forEach(e=>e.r--),e.forEach(e=>e.r--?e.r++:e()))},y.a=(e,t,a)=>{var n;a&&((n=[]).d=-1);var i,o,r,s=new Set,u=e.exports,m=new Promise((e,t)=>{r=t,o=e});m[l]=u,m[p]=e=>(n&&e(n),s.forEach(e),m.catch(e=>{})),e.exports=m,t(e=>{var t;i=(e=>e.map(e=>{if(null!==e&&"object"==typeof e){if(e[p])return e;if(e.then){var t=[];t.d=0,e.then(e=>{a[l]=e,c(t)},e=>{a[d]=e,c(t)});var a={};return a[p]=e=>e(t),a}}var n={};return n[p]=e=>{},n[l]=e,n}))(e);var a=()=>i.map(e=>{if(e[d])throw e[d];return e[l]}),o=new Promise(e=>{(t=()=>e(a)).r=0;var o=e=>e!==n&&!s.has(e)&&(s.add(e),e&&!e.d&&(t.r++,e.push(t)));i.map(e=>e[p](o))});return t.r?o:a()},e=>(e?r(m[d]=e):o(u),c(n))),n&&n.d<0&&(n.d=0)},y.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return y.d(t,{a:t}),t},m=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,y.t=function(e,t){if(1&t&&(e=this(e)),8&t)return e;if("object"==typeof e&&e){if(4&t&&e.__esModule)return e;if(16&t&&"function"==typeof e.then)return e}var a=Object.create(null);y.r(a);var n={};u=u||[null,m({}),m([]),m(m)];for(var i=2&t&&e;("object"==typeof i||"function"==typeof i)&&!~u.indexOf(i);i=m(i))Object.getOwnPropertyNames(i).forEach(t=>n[t]=()=>e[t]);return n.default=()=>e,y.d(a,n),a},y.d=(e,t)=>{for(var a in t)y.o(t,a)&&!y.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},y.f={},y.e=e=>Promise.all(Object.keys(y.f).reduce((t,a)=>(y.f[a](e,t),t),[])),y.u=e=>e+".js",y.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),y.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},y.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),f={57:0},v=e=>{var t,a,{__webpack_esm_ids__:n,__webpack_esm_modules__:i,__webpack_esm_runtime__:o}=e,r=0;for(t in i)y.o(i,t)&&(y.m[t]=i[t]);for(o&&o(y);r<n.length;r++)a=n[r],y.o(f,a)&&f[a]&&f[a][0](),f[n[r]]=0},y.f.j=(e,t)=>{var a=y.o(f,e)?f[e]:void 0;if(0!==a)if(a)t.push(a[1]);else{var n=import("./"+y.u(e)).then(v,t=>{throw 0!==f[e]&&(f[e]=void 0),t});n=Promise.race([n,new Promise(t=>a=f[e]=[t])]),t.push(a[1]=n)}};var b=y(99436),D=y(65181);const{DM:x,gu:_,er:w,Ww:E,b7:T,Di:N,a2:A,uB:O,ef:F,c$:S,_V:C}=D;var k=y(88568),I=y(74752),$=()=>Boolean(process.stdin.isTTY&&process.stdout.isTTY&&"function"==typeof process.stdin.setRawMode),j=y(29790);const R=t("readline");var V,P,B,L,M,U=y(50700),q=e=>{console.log(JSON.stringify(e,null,2))},z=(e,t={})=>{console.error(JSON.stringify({ok:!1,error:{message:e,...t}},null,2))},G=(e,t=4)=>e?e.length<=2*t?"*".repeat(e.length):`${e.slice(0,t)}…${e.slice(-t)}`:null,Y=(V=b(function*(){var e=(0,I.getCurrentProfile)(),t=(0,I.getCurrentProfileSource)(),a=(0,I.getTokenInfo)(e),n=(0,I.getBaseUrl)();if(!a?.token)return{ok:!1,profile:e,profileSource:t,baseUrl:n,auth:{available:!1,source:"missing",workspaceId:null,workspaceName:null,createdAt:null,tokenPreview:null},workspace:null,error:null};try{var i=(0,U.createClient)(n,a.token),o=yield i.workspace();return{ok:!0,profile:e,profileSource:t,baseUrl:n,auth:{available:!0,source:"config",workspaceId:o?._id||a.workspaceId||null,workspaceName:o?.name||a.workspaceName||null,createdAt:a.createdAt||null,tokenPreview:G(a.token)},workspace:o?{_id:o._id,name:o.name,description:o.description||null}:null,error:null}}catch(i){return{ok:!1,profile:e,profileSource:t,baseUrl:n,auth:{available:!0,source:"config",workspaceId:a.workspaceId||null,workspaceName:a.workspaceName||null,createdAt:a.createdAt||null,tokenPreview:G(a.token)},workspace:null,error:{message:i.message}}}}),function(){return V.apply(this,arguments)}),Q=new O("auth").description("Authentication and token management");Q.command("login").description("Login with a one-time passcode from BRICKS Controller (recommended)").argument("[passcode]","One-time passcode from BRICKS Controller").option("-p, --profile <profile>","Profile name to save the token").option("-n, --name <name>","Profile display name").action((P=b(function*(e,t){var a,n,i=t.profile||(0,I.getCurrentProfile)(),o=t.name,r=e;r||(console.log(k.Ay.cyan("Generate a one-time passcode from BRICKS Controller:")),console.log(k.Ay.gray(" 1. Open the link below (or select your workspace first)")),console.log(` ${k.Ay.underline.blue("https://control.bricks.tools/#/?action=manage-tokens")}`),console.log(k.Ay.gray(' 2. Click "Generate OTP" to create a one-time passcode\n')),(r=yield(a="Enter passcode: ",n=R.createInterface({input:process.stdin,output:process.stdout}),new Promise(e=>{n.question(a,t=>{n.close(),e(t.trim())})})))||(console.log(k.Ay.red("Passcode is required")),process.exit(1)));var s=(0,j.default)("Validating passcode...").start();try{var p=(0,U.createPublicClient)((0,I.getBaseUrl)()),l=yield p.checkWorkspaceOTP(r);l.valid||(s.fail(`Invalid passcode: ${l.error||"Unknown error"}`),process.exit(1)),s.text=`Exchanging passcode for token (workspace: ${l.workspaceName})...`;var d=yield p.exchangeWorkspaceOTP(r);d.token||(s.fail("Failed to obtain token"),process.exit(1));var c=(0,U.createClient)((0,I.getBaseUrl)(),d.token),u=yield c.workspace();u||(s.fail("Token validation failed"),process.exit(1)),(0,I.setToken)(i,{token:d.token,name:o||u.name,workspaceId:u._id,workspaceName:u.name}),(0,I.setCurrentProfile)(i),s.succeed(`Logged in to workspace: ${k.Ay.green(u.name)} (profile: ${k.Ay.cyan(i)})`)}catch(e){s.fail(`Login failed: ${e.message}`),process.exit(1)}}),function(e,t){return P.apply(this,arguments)})),Q.command("login-token").description("Login with a workspace token directly").option("-t, --token <token>","Workspace token").option("-p, --profile <profile>","Profile name to save the token").option("-n, --name <name>","Profile display name").action((B=b(function*(e){var t=e.profile||(0,I.getCurrentProfile)(),a=e.token,n=e.name;a||(console.error(k.Ay.red("Error: Token is required. Use -t or --token to provide it.")),console.log(k.Ay.gray("\nYou can get a workspace token from BRICKS Controller:")+k.Ay.underline.blue("https://control.bricks.tools/#/?action=manage-tokens")),console.log(` ${k.Ay.underline.blue("https://control.bricks.tools/#/?action=manage-tokens")}`),console.log(k.Ay.gray("Select your workspace and create a new token.\n")),console.log(k.Ay.yellow("Tip: Use `bricks auth login` for a simpler OTP-based login.")),process.exit(1));var i=(0,j.default)("Validating token...").start();try{var o=(0,U.createClient)((0,I.getBaseUrl)(),a),r=yield o.workspace();r||(i.fail("Invalid token or unable to access workspace"),process.exit(1)),(0,I.setToken)(t,{token:a,name:n||r.name,workspaceId:r._id,workspaceName:r.name}),(0,I.setCurrentProfile)(t),i.succeed(`Logged in to workspace: ${k.Ay.green(r.name)} (profile: ${k.Ay.cyan(t)})`)}catch(e){i.fail(`Login failed: ${e.message}`),process.exit(1)}}),function(e){return B.apply(this,arguments)})),Q.command("logout").description("Remove saved token").option("-p, --profile <profile>","Profile to remove").option("-a, --all","Remove all profiles").action((L=b(function*(e){var t=e.profile;if(e.all)return(0,I.listProfiles)().forEach(e=>(0,I.removeToken)(e.name)),void console.log(k.Ay.green("All profiles removed"));var a=t||(0,I.getCurrentProfile)();(0,I.getTokenInfo)(a)?((0,I.removeToken)(a),console.log(k.Ay.green(`Logged out from profile: ${a}`))):console.log(k.Ay.yellow(`No token found for profile: ${a}`))}),function(e){return L.apply(this,arguments)})),Q.command("status").description("Show current authentication status").option("-j, --json","Output as JSON").action((M=b(function*(e){var t=(0,I.getCurrentProfile)(),a=(0,I.getTokenInfo)(t);if(!a)return e.json?void q(yield Y()):(console.log(k.Ay.yellow("Not logged in")),void console.log(k.Ay.gray("Use `bricks auth login` to login")));if(e.json)q(yield Y());else{var n=(0,j.default)("Checking connection...").start();try{var i=(0,U.createClient)((0,I.getBaseUrl)(),a.token),o=yield i.workspace();n.stop(),console.log(k.Ay.bold("\nAuthentication Status")),console.log("─".repeat(40)),console.log(`Profile: ${k.Ay.cyan(t)}`),console.log(`Workspace: ${k.Ay.green(o.name)}`),console.log(`Workspace ID: ${k.Ay.gray(o._id)}`);var r=(0,I.getBaseUrl)(),s=a.baseUrl;console.log(`Base URL: ${k.Ay.gray(r)}${s?"":k.Ay.gray(" (global)")}`),console.log(`Logged in: ${k.Ay.gray(a.createdAt)}`),console.log("─".repeat(40))}catch(e){n.fail(`Connection failed: ${e.message}`)}}}),function(e){return M.apply(this,arguments)})),Q.command("list").description("List all saved profiles").action(()=>{var e=(0,I.listProfiles)();if(0===e.length)return console.log(k.Ay.yellow("No saved profiles")),void console.log(k.Ay.gray("Use `bricks auth login` to login"));console.log(k.Ay.bold("\nSaved Profiles")),console.log("─".repeat(60)),e.forEach(e=>{var t=e.current?k.Ay.green("● "):" ",a=e.current?k.Ay.green(e.name):e.name,n=e.baseUrl?k.Ay.gray(` [${e.baseUrl}]`):"";console.log(`${t}${a.padEnd(15)} ${k.Ay.gray(e.workspaceName||"Unknown")}${n}`)}),console.log("─".repeat(60))}),Q.command("use <profile>").description("Switch to a different profile").action(e=>{var t=(0,I.getTokenInfo)(e);if(!t)return console.log(k.Ay.red(`Profile not found: ${e}`)),void console.log(k.Ay.gray("Use `bricks auth list` to see available profiles"));(0,I.setCurrentProfile)(e),console.log(k.Ay.green(`Switched to profile: ${e}`)),t.workspaceName&&console.log(k.Ay.gray(`Workspace: ${t.workspaceName}`))}),Q.command("set-url <url>").description("Set the base URL for the current profile").option("-g, --global","Set the global base URL instead of per-profile").action((e,t)=>{if(t.global)(0,I.setBaseUrl)(e),console.log(k.Ay.green(`Global base URL set to: ${e}`));else{var a=(0,I.getCurrentProfile)();(0,I.setBaseUrl)(e,a),console.log(k.Ay.green(`Base URL for profile ${k.Ay.cyan(a)} set to: ${e}`))}});var J=y(68832),H=y(47336),W=e=>String(e||"").trim().toLowerCase(),K=({resource:e,query:t,items:a,fields:n,selectedBy:i=null})=>{var o=W(t),r=a.filter(e=>n.some(t=>W(((e,t)=>t.split(".").reduce((e,t)=>e?.[t],e)??null)(e,t))===o)),s=null,p=i;return"id"===i?s=a[0]||null:1===r.length?(s=r[0],p="exact"):1===a.length&&(s=a[0],p="single"),{resource:e,query:t,exactMatchCount:r.length,matchCount:a.length,selectedBy:p,ambiguous:a.length>1&&!s,resolved:s,matches:a}},X=function(){var e=b(function*(e){try{return yield e()}catch(e){if(/not found/i.test(e.message))return null;throw e}});return function(t){return e.apply(this,arguments)}}(),Z=(e,t,a)=>({label:e,ok:t,detail:a}),ee=e=>null==e?k.Ay.gray("N/A"):"object"==typeof e?k.Ay.gray(JSON.stringify(e,null,2)):String(e),te=({action:e,target:t,request:a,checks:n=[],json:i=!1})=>{i?q({ok:!0,dryRun:!0,action:e,target:t||null,request:a||null,checks:n}):(console.log(k.Ay.bold(`\nDry Run: ${e}`)),console.log("─".repeat(60)),t&&(console.log(k.Ay.bold("Target")),Object.entries(t).forEach(([e,t])=>{console.log(`${e}: ${ee(t)}`)})),a&&(console.log(`\n${k.Ay.bold("Request")}`),Object.entries(a).forEach(([e,t])=>{console.log(`${e}: ${ee(t)}`)})),n.length>0&&(console.log(`\n${k.Ay.bold("Checks")}`),n.forEach(e=>{var t=e.ok?k.Ay.green("OK"):k.Ay.red("FAIL"),a=e.detail?` ${e.detail}`:"";console.log(`${t} ${e.label}${a}`)})),console.log("─".repeat(60)))},ae=({action:e,target:t,result:a=null,json:n=!1,message:i})=>{n?q({ok:!0,dryRun:!1,action:e,target:t||null,result:a}):i&&console.log(i)},ne=/^(\d+)(s|m|h|d|w)$/,ie={s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5};function oe(e){var t=e.match(ne);if(t){var a=parseInt(t[1],10),n=ie[t[2]];return new Date(Date.now()-a*n).toISOString()}var i=new Date(e);if(isNaN(i.getTime()))throw new Error(`Invalid time format: "${e}". Use ISO 8601 or relative (e.g. 1h, 30m, 2d)`);return i.toISOString()}var re,se,pe,le,de,ce,ue,me=()=>{var e=(0,I.getCurrentProfile)(),t=(0,I.getToken)(e);return t||(console.error(k.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,U.createClient)((0,I.getBaseUrl)(),t)},fe=e=>{if(!e)return k.Ay.gray("○ Unknown");var t=Date.now()-new Date(e).getTime();if(t<=3e5)return k.Ay.green("● Online");var a=Math.floor(t/6e4);if(a<60)return k.Ay.yellow(`○ Offline (${a}m ago)`);var n=Math.floor(a/60);if(n<24)return k.Ay.red(`○ Offline (${n}h ago)`);var i=Math.floor(n/24);return k.Ay.red(`○ Offline (${i}d ago)`)},ve=e=>e.name||e.device_name||"Unnamed",he=(e,t)=>({id:e?._id||t,name:ve(e),deviceName:e?.device_name||null}),ge=function(){var e=b(function*(e,t){var a=yield e.device({id:t});if(!a)throw new Error("Device not found");return a});return function(t,a){return e.apply(this,arguments)}}(),ye=function(){var e=b(function*({id:e,type:t,eventPayload:a,options:n,progressMessage:i,successMessage:o,failureMessage:r="Failed to control device"}){var s=me(),p=n.json?null:(0,j.default)(i).start();try{var l=yield ge(s,e),d=he(l,e);if(n.dryRun)return p&&p.stop(),void te({action:"device.control",target:d,request:{type:t,eventPayload:a||null},checks:[Z("device exists",!0,`${d.name} (${d.id})`)],json:n.json});yield s.controlDevice({id:e,type:t,eventPayload:a}),p?p.succeed(o):ae({action:"device.control",target:d,result:{type:t,eventPayload:a||null},json:!0})}catch(a){n.json?z(a.message,{action:"device.control",target:{id:e},type:t}):p.fail(`${r}: ${a.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}(),be=new O("device").description("Device management");be.command("list").description("List all devices").option("-k, --keyword <keyword>","Filter by keyword").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){var t=me(),a=(0,j.default)("Fetching devices...").start();try{var n=yield t.devices({keyword:e.keyword});if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(k.Ay.yellow("No devices found"));console.log(k.Ay.bold("\nDevices")),console.log("─".repeat(80)),n.forEach(e=>{var t=e.entry_detail?.watch_dog_timer?.last_alive_time,a=fe(t),n=e.entry_detail?.application?.name||k.Ay.gray("No app bound");console.log(`${a} ${k.Ay.cyan(e.name||e.device_name)}`),console.log(` ID: ${k.Ay.gray(e._id)}`),console.log(` App: ${n}`),console.log()})}catch(e){a.fail(`Failed to list devices: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),be.command("get <id>").description("Get device details").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=me(),n=(0,j.default)("Fetching device...").start();try{var i=yield a.device({id:e});if(n.stop(),i||(console.log(k.Ay.red("Device not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(i,null,2));var o=i.entry_detail?.watch_dog_timer?.last_alive_time,r=fe(o);if(console.log(k.Ay.bold(`\nDevice: ${i.name||i.device_name}`)),console.log("─".repeat(60)),console.log(`Status: ${r}`),console.log(`ID: ${k.Ay.gray(i._id)}`),console.log(`Device Name: ${i.device_name||k.Ay.gray("N/A")}`),console.log(`Description: ${i.description||k.Ay.gray("N/A")}`),console.log(`Tags: ${i.tags?.join(", ")||k.Ay.gray("None")}`),console.log(`Created: ${k.Ay.gray(i.create_datetime||"N/A")}`),console.log(`Modified: ${k.Ay.gray(i.last_modify_datetime||"N/A")}`),i.entry_detail){var s=i.entry_detail;if(console.log(`\n${k.Ay.bold("Entry Details")}`),console.log(`Type: ${s.type||k.Ay.gray("N/A")}`),console.log(`Unique ID: ${k.Ay.gray(s.unique_id||"N/A")}`),console.log(`Version: ${s.operation_version||k.Ay.gray("N/A")}`),console.log(`Mode: ${s.operation_mode||k.Ay.gray("N/A")}`),Array.isArray(s.screen)&&s.screen.length>0)console.log(`\n${k.Ay.bold("Screens")} (${s.screen.length})`),s.screen.forEach((e,t)=>{var a=e.resolution,n=a?`${a.width}x${a.height} @${a.scale}x`:"N/A",i=e.master?k.Ay.green(" (master)"):"",o=e.orientation?` [${e.orientation}]`:"",r=e.touch?.available?k.Ay.cyan(` touch:${e.touch.touch_point}pt`):"";console.log(` ${t+1}. ${e.title||"Screen"}${i}${o} - ${n}${r}`)});else if(s.screen?.resolution){var p=s.screen.resolution;console.log(`Resolution: ${p.width}x${p.height} @${p.scale}x`)}var l=null!=s.memory_usage,d=null!=s.disk_usage;if(l||d){if(console.log(`\n${k.Ay.bold("System Resources")}`),l){var c=Array.isArray(s.memory_usage)?s.memory_usage[0]:s.memory_usage,u=Math.round(100*c),m=k.Ay.green;u>80?m=k.Ay.red:u>60&&(m=k.Ay.yellow),console.log(`Memory: ${m(`${u}%`)}`)}if(d){var f=Array.isArray(s.disk_usage)?s.disk_usage[0]:s.disk_usage,v=Math.round(100*f),h=k.Ay.green;v>90?h=k.Ay.red:v>75&&(h=k.Ay.yellow),console.log(`Disk: ${h(`${v}%`)}`)}}var g=[];if(s.sound?.available&&g.push("Sound"),s.camera?.available&&g.push("Camera"),s.audio_in?.available&&g.push("Audio Input"),g.length>0&&(console.log(`\n${k.Ay.bold("Capabilities")}`),console.log(`Available: ${g.join(", ")}`),s.camera?.channel?.length>0&&s.camera.channel.forEach(e=>{var t=e.resolution?`${e.resolution.width}x${e.resolution.height}`:"";console.log(` Camera: ${e.title||"Camera"} ${t} [${e.orientation||"N/A"}]`)})),s.local_sync){var y=s.local_sync;console.log(`\n${k.Ay.bold("Local Sync")}`),console.log(`Role: ${y.is_main?k.Ay.cyan("Main"):"Secondary"}`),null!=y.peer_count&&console.log(`Peers: ${y.peer_count}`),null!=y.mean_latency&&console.log(`Latency: ${y.mean_latency.toFixed(2)}ms`)}if(s.update){var b=s.update;console.log(`\n${k.Ay.bold("Update Status")}`),console.log(`Needs Update: ${b.need_update?k.Ay.yellow("Yes"):k.Ay.green("No")}`),b.current_version&&console.log(`App Version: ${b.current_version}`),b.running_mode&&console.log(`Running Mode: ${b.running_mode}`),b.last_update_at&&console.log(`Last Update: ${k.Ay.gray(b.last_update_at)}`)}if(s.watch_dog_timer){var D=s.watch_dog_timer;console.log(`\n${k.Ay.bold("Watchdog")}`),console.log(`Alive: ${D.alive?k.Ay.green("Yes"):k.Ay.red("No")}`),D.last_launch_time&&console.log(`Last Launch: ${k.Ay.gray(D.last_launch_time)}`),D.last_alive_time&&console.log(`Last Alive: ${k.Ay.gray(D.last_alive_time)}`)}}i.bound_application&&(console.log(`\n${k.Ay.bold("Bound Application")}`),console.log(`Name: ${i.bound_application.name}`),console.log(`ID: ${k.Ay.gray(i.bound_application._id)}`)),i.env?.variables&&Object.keys(i.env.variables).length>0&&(console.log(`\n${k.Ay.bold("Environment Variables")}`),Object.entries(i.env.variables).forEach(([e,t])=>{console.log(` ${k.Ay.cyan(e)}: ${t}`)})),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get device: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),be.command("resolve <query>").description("Resolve a device name or ID to stable IDs").option("-l, --limit <limit>","Limit search results",e=>Number.parseInt(e,10),10).option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=me(),n=t.json?null:(0,j.default)("Resolving device...").start();try{var i=yield X(()=>a.device({id:e})),o=i||!e?i?[i]:[]:yield a.devices({keyword:e,paginate:{limit:t.limit}}),r=K({resource:"device",query:e,items:i?[i]:o||[],fields:["_id","name","device_name"],selectedBy:i?"id":null});if(n&&n.stop(),t.json)return void q(r);if(r.resolved){var s=r.resolved;return console.log(k.Ay.bold("\nResolved Device")),console.log("─".repeat(60)),console.log(`Name: ${k.Ay.cyan(s.name||s.device_name||"Unnamed")}`),console.log(`ID: ${k.Ay.gray(s._id)}`),console.log(`Selected By: ${r.selectedBy}`),void console.log("─".repeat(60))}if(0===r.matches.length)return void console.log(k.Ay.yellow(`No devices matched "${e}"`));console.log(k.Ay.bold(`\nMatching Devices (${r.matches.length})`)),console.log("─".repeat(80)),r.matches.forEach(e=>{console.log(`${k.Ay.cyan(e.name||e.device_name||"Unnamed")} ${k.Ay.gray(e._id)}`)}),console.log("─".repeat(80))}catch(t){n?n.fail(`Failed to resolve device: ${t.message}`):z(t.message,{resource:"device",query:e}),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),be.command("bind <passcode>").description("Bind a new device using passcode").option("-n, --name <name>","Device name").option("--dry-run","Validate inputs and show the device binding plan without creating a device").option("-j, --json","Output as JSON").action((re=b(function*(e,t){var a=me(),n=t.json?null:(0,j.default)("Checking passcode...").start();try{var i=yield a.checkBindDevicePasscode({passcode:e});i||(t.json?z("Invalid passcode or expired",{action:"device.bind"}):n.fail("Invalid passcode or expired"),process.exit(1));var o={name:t.name||i.payload?.deviceName||"CLI Device",deviceName:i.payload?.deviceName||null};if(t.dryRun)return n&&n.stop(),void te({action:"device.bind",target:o,request:{passcodePreview:G(e),requestedName:t.name||null,inferredName:i.payload?.deviceName||null},checks:[Z("passcode is valid",!0),Z("device name resolved",!0,o.name)],json:t.json});n&&(n.text="Binding device...");var r=yield a.createDevice({bindPasscode:e,name:o.name,deviceName:i.payload?.deviceName});t.json?ae({action:"device.bind",target:he(r,r._id),result:{inferredName:i.payload?.deviceName||null},json:!0}):(n.succeed(`Device bound successfully: ${k.Ay.green(r.name)}`),console.log(k.Ay.gray(`Device ID: ${r._id}`)))}catch(e){t.json?z(e.message,{action:"device.bind"}):n.fail(`Failed to bind device: ${e.message}`),process.exit(1)}}),function(e,t){return re.apply(this,arguments)})),be.command("control <id> <type>").description("Control a device").option("-p, --payload <json>","Event payload as JSON").option("--dry-run","Validate inputs and show the control request without sending it").option("-j, --json","Output as JSON").action((se=b(function*(e,t,a){try{var n;a.payload&&(n=JSON.parse(a.payload)),yield ye({id:e,type:t,eventPayload:n,options:a,progressMessage:`Sending ${t} to device...`,successMessage:`Control event sent: ${k.Ay.green(t)}`,failureMessage:"Failed to control device"})}catch(n){a.json?z(n.message,{action:"device.control",target:{id:e},type:t}):console.error(k.Ay.red(`Failed to control device: ${n.message}`)),process.exit(1)}}),function(e,t,a){return se.apply(this,arguments)})),be.command("refresh <id>").description("Refresh device application").option("--dry-run","Validate inputs and show the refresh request without sending it").option("-j, --json","Output as JSON").action((pe=b(function*(e,t){yield ye({id:e,type:"refresh",options:t,progressMessage:"Refreshing device...",successMessage:"Device refreshed",failureMessage:"Failed to refresh device"})}),function(e,t){return pe.apply(this,arguments)})),be.command("clear-cache <id>").description("Clear device cache").option("--dry-run","Validate inputs and show the cache-clear request without sending it").option("-j, --json","Output as JSON").action((le=b(function*(e,t){yield ye({id:e,type:"clear-cache",options:t,progressMessage:"Clearing cache...",successMessage:"Cache cleared",failureMessage:"Failed to clear cache"})}),function(e,t){return le.apply(this,arguments)})),be.command("screenshot <id>").description("Take device screenshot and save to file").option("-o, --output <path>","Output file path").option("--no-take","Only fetch existing screenshot without taking a new one").action((de=b(function*(e,t){var a=me(),n=(0,j.default)("Fetching workspace info...").start();try{var i=yield a.workspace();i?.media_resource?.enable_media_workspace||(n.fail("Media workspace is not enabled for this workspace"),process.exit(1)),i.media_resource.system_media_box_id||(n.fail("No media box configured for this workspace"),process.exit(1)),!1!==t.take&&(n.text="Sending screenshot request to device...",yield a.controlDevice({id:e,type:"take-screenshot"}),n.text="Waiting for device to capture screenshot...",yield new Promise(e=>setTimeout(e,3e3))),n.text="Fetching screenshot...";var o=yield(0,H.he)(a,i,e,t.output);if(o.error&&(n.fail(o.error),process.exit(1)),n.succeed("Screenshot saved"),console.log(),console.log(k.Ay.bold("Screenshot saved to:")),console.log(k.Ay.cyan(o.path)),console.log(),o.file?.meta){var r=o.file.meta,s=r.originalWidth,p=r.originalHeight,l=r.originalFileSize;if(s&&p&&console.log(`${k.Ay.gray("Size:")} ${s}x${p}`),l){var d=(l/1024).toFixed(1);console.log(`${k.Ay.gray("File:")} ${d} KB`)}}o.file?.updatedAt&&console.log(`${k.Ay.gray("Updated:")} ${new Date(o.file.updatedAt).toLocaleString()}`)}catch(e){n.fail(`Failed to get screenshot: ${e.message}`),process.exit(1)}}),function(e,t){return de.apply(this,arguments)})),be.command("metrics <id>").description("Show device metrics (uptime, memory, disk)").option("--start-date <date>","Start date/time (ISO 8601 or relative e.g. 1h, 2d, default: today)").option("--end-date <date>","End date/time (ISO 8601 or relative e.g. 1h, 2d, default: now)").option("-j, --json","Output as JSON").action((ce=b(function*(e,t){var a=me(),n=(0,j.default)("Fetching device metrics...").start();try{var i=new Date,o=new Date(i.getFullYear(),i.getMonth(),i.getDate()).toISOString(),r=t.startDate?oe(t.startDate):o,s=t.endDate?oe(t.endDate):i.toISOString(),p=yield a.deviceUsage({deviceId:e,startDate:r,endDate:s});if(n.stop(),!p||0===p.length)return void console.log(k.Ay.yellow("No metrics data found for this device"));if(t.json)return void console.log(JSON.stringify(p,null,2));for(var l of(console.log(k.Ay.bold(`\nDevice Metrics: ${e}`)),console.log("─".repeat(60)),console.log(k.Ay.gray(`${"Date".padEnd(12)} ${"Uptime Events".padEnd(15)} ${"Avg Memory".padEnd(12)} ${"Avg Disk".padEnd(10)}`)),console.log("─".repeat(60)),p)){var d=(l.date||"").padEnd(12),c=String(l.uptime?.length||0).padEnd(15),u="N/A";if(l.memory_usage?.length){var m=0,f=0;for(var v of l.memory_usage){var h=v.values||[],g=J(h,2),y=g[0],b=g[1];null!=y&&null!=b&&b>0&&(m+=y,f+=b)}f>0&&(u=`${(m/f*100).toFixed(1)}%`)}var D="N/A";if(l.disk_usage?.length){var x=0,_=0;for(var w of l.disk_usage){var E=w.values||[],T=J(E,2),N=T[0],A=T[1];null!=N&&null!=A&&A>0&&(x+=N,_+=A)}_>0&&(D=`${(x/_*100).toFixed(1)}%`)}console.log(`${d} ${c} ${u.padEnd(12)} ${D.padEnd(10)}`)}console.log("─".repeat(60))}catch(e){n.fail(`Failed to get device metrics: ${e.message}`),process.exit(1)}}),function(e,t){return ce.apply(this,arguments)})),be.command("monitor").description("Monitor device status (polls every 60s)").option("-g, --group <id>","Monitor devices in a group").option("-i, --interval <seconds>","Polling interval in seconds","60").action((ue=b(function*(e){var t=me(),a=1e3*parseInt(e.interval,10);console.log(k.Ay.bold("\nDevice Monitor")),console.log(k.Ay.gray(`Polling every ${e.interval}s. Press Ctrl+C to stop.\n`));var n,i=(n=b(function*(){try{var a;if(a=e.group?yield t.devicesByGroup({id:e.group}):yield t.devices({}),process.stdout.write("[2J[0f"),console.log(k.Ay.bold("Device Monitor")+k.Ay.gray(` - ${(new Date).toLocaleTimeString()}`)),console.log("─".repeat(80)),!a||0===a.length)return void console.log(k.Ay.yellow("No devices found"));a.forEach(e=>{var t=e.entry_detail?.watch_dog_timer?.last_alive_time,a=fe(t),n=e.name||e.device_name||e.device_target_name,i=e.entry_detail?.application?.name||k.Ay.gray("No app");console.log(`${a} ${k.Ay.cyan(n.padEnd(25))} ${i}`)}),console.log(`\n${k.Ay.gray("Press Ctrl+C to stop")}`)}catch(e){console.error(k.Ay.red(`Error: ${e.message}`))}}),function(){return n.apply(this,arguments)});yield i(),setInterval(i,a)}),function(e){return ue.apply(this,arguments)}));var De,xe,_e=y(79896),we=y(35704),Ee=y(16928),Te=e=>{if(e.endsWith(".json")||e.includes("/")){if(!_e.existsSync(e))throw new Error(`Config file not found: ${e}`);var t=_e.readFileSync(e,"utf-8");return{config:t,source:{type:"file",path:Ee.resolve(e)},sizeBytes:Buffer.byteLength(t)}}return{config:e,source:{type:"inline"},sizeBytes:Buffer.byteLength(e)}},Ne=()=>{var e=(0,I.getCurrentProfile)(),t=(0,I.getToken)(e);return t||(console.error(k.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,U.createClient)((0,I.getBaseUrl)(),t)},Ae=(e,t)=>({id:e?._id||t,name:e?.name||"Unnamed",currentVersion:e?.current_version||null,unreleasedChanges:Boolean(e?.has_unreleased_changes)}),Oe=new O("app").description("Application management");Oe.command("new").description("Create a new application").requiredOption("-n, --name <name>","Application name").option("-d, --description <description>","Application description").option("--layout-width <width>","Layout width",parseInt).option("--layout-height <height>","Layout height",parseInt).option("--example <key>","Create from example template").option("--init","Initialize a BRICKS Project after creation").option("-o, --output <dir>","Output directory for --init (default: current directory)").option("-y, --yes","Skip prompts for --init").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){var t=Ne(),a=e.json?null:(0,j.default)("Creating application...").start();try{var n={name:e.name};e.description&&(n.description=e.description),e.layoutWidth&&(n.layoutWidth=e.layoutWidth),e.layoutHeight&&(n.layoutHeight=e.layoutHeight),e.example&&(n.createExampleKey=e.example);var i=yield t.createApplication(n);if(e.json&&!e.init?console.log(JSON.stringify(i,null,2)):e.json||(a.succeed(`Application created: ${k.Ay.green(i.name)}`),console.log(` ID: ${k.Ay.gray(i._id)}`),i.description&&console.log(` ${k.Ay.gray(i.description)}`)),e.init){a&&a.stop();var o=(yield Promise.all([y.e(356),y.e(465)]).then(y.bind(y,16465))).initProject;yield o("application",i._id,{output:e.output,yes:e.yes,json:e.json})}}catch(t){e.json?console.error(JSON.stringify({error:t.message})):a.fail(`Failed to create application: ${t.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),Oe.command("list").description("List all applications").option("-k, --keyword <keyword>","Filter by keyword").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){var t=Ne(),a=(0,j.default)("Fetching applications...").start();try{var n=yield t.applications({keyword:e.keyword});if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(k.Ay.yellow("No applications found"));console.log(k.Ay.bold("\nApplications")),console.log("─".repeat(80)),n.forEach(e=>{var t=e.has_unreleased_changes?k.Ay.yellow("●"):k.Ay.green("●"),a=e.current_version?`v${e.current_version}`:k.Ay.gray("no version");console.log(`${t} ${k.Ay.cyan(e.name)} ${k.Ay.gray(a)}`),console.log(` ID: ${k.Ay.gray(e._id)}`),e.description&&console.log(` ${k.Ay.gray(e.description)}`),console.log()})}catch(e){a.fail(`Failed to list applications: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),Oe.command("get <id>").description("Get application details").option("-c, --composed","Get composed configuration").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Ne(),n=(0,j.default)("Fetching application...").start();try{var i=yield a.application({id:e,composed:t.composed});if(n.stop(),i||(console.log(k.Ay.red("Application not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(i,null,2));if(console.log(k.Ay.bold(`\nApplication: ${i.name}`)),console.log("─".repeat(60)),console.log(`ID: ${k.Ay.gray(i._id)}`),console.log(`Description: ${i.description||k.Ay.gray("N/A")}`),console.log(`Tags: ${i.tags?.join(", ")||k.Ay.gray("None")}`),console.log(`Created: ${k.Ay.gray(i.create_datetime)}`),console.log(`Modified: ${k.Ay.gray(i.last_modify_datetime)}`),console.log(`\n${k.Ay.bold("Version")}`),i.current_version){if(console.log(`Current: v${i.current_version}`),i.current_version_details){var o=i.current_version_details;o.name&&console.log(`Release Name: ${o.name}`),o.note&&console.log(`Release Note: ${k.Ay.gray(o.note)}`),o.create_datetime&&console.log(`Released At: ${k.Ay.gray(o.create_datetime)}`)}}else console.log(`Current: ${k.Ay.gray("No version")}`);if(console.log(`Unreleased: ${i.has_unreleased_changes?k.Ay.yellow("Yes"):k.Ay.green("No")}`),console.log(`\n${k.Ay.bold("Features")}`),console.log(`Short Edit: ${i.short_edit?.enabled?k.Ay.green("Enabled"):k.Ay.gray("Disabled")}`),i.short_edit?.enabled&&i.short_edit.ref_map){var r=Object.keys(i.short_edit.ref_map).length;console.log(` References: ${r} editable properties`)}console.log(`Automation: ${i.canvas_control?.enable_schedule?k.Ay.green("Scheduled"):k.Ay.gray("No schedule")}`),i.lock?.locked&&console.log(`Locked: ${k.Ay.yellow("Yes")} (at ${i.lock.locked_at||"N/A"})`),i.sync_key&&console.log(`Sync Key: ${k.Ay.gray(i.sync_key)}`),i.devices?.length>0?(console.log(`\n${k.Ay.bold("Bound Devices")} (${i.devices.length})`),i.devices.forEach(e=>{var t="active"===e.status?k.Ay.green("●"):k.Ay.gray("○"),a=e.frame?k.Ay.gray(` [${e.frame.x||0},${e.frame.y||0} ${e.frame.width}x${e.frame.height}]`):"";console.log(` ${t} ${e.device_id}${a}`)})):console.log(`\n${k.Ay.bold("Bound Devices")}: ${k.Ay.gray("None")}`),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get application: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Oe.command("resolve <query>").description("Resolve an application name or ID to stable IDs").option("-l, --limit <limit>","Limit search results",e=>Number.parseInt(e,10),10).option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Ne(),n=t.json?null:(0,j.default)("Resolving application...").start();try{var i=yield X(()=>a.application({id:e})),o=i?[i]:yield a.applications({keyword:e,paginate:{limit:t.limit}}),r=K({resource:"application",query:e,items:o||[],fields:["_id","name"],selectedBy:i?"id":null});if(n&&n.stop(),t.json)return void q(r);if(r.resolved){var s=r.resolved;return console.log(k.Ay.bold("\nResolved Application")),console.log("─".repeat(60)),console.log(`Name: ${k.Ay.cyan(s.name||"Unnamed")}`),console.log(`ID: ${k.Ay.gray(s._id)}`),console.log(`Selected By: ${r.selectedBy}`),void console.log("─".repeat(60))}if(0===r.matches.length)return void console.log(k.Ay.yellow(`No applications matched "${e}"`));console.log(k.Ay.bold(`\nMatching Applications (${r.matches.length})`)),console.log("─".repeat(80)),r.matches.forEach(e=>{console.log(`${k.Ay.cyan(e.name||"Unnamed")} ${k.Ay.gray(e._id)}`)}),console.log("─".repeat(80))}catch(t){n?n.fail(`Failed to resolve application: ${t.message}`):z(t.message,{resource:"application",query:e}),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Oe.command("update <id>").description("Update application").option("-n, --name <name>","Application name").option("-d, --description <description>","Application description").option("-c, --config <json>","Application config as JSON string").option("-f, --file <path>","Application config from file").option("--validate","Validate configuration").action(function(){var e=b(function*(e,t){var a=Ne(),n=(0,j.default)("Updating application...").start();try{var i={id:e};t.name&&(i.name=t.name),t.description&&(i.description=t.description),t.validate&&(i.validateConfig=!0),t.config?i.config=t.config:t.file&&(i.config=_e.readFileSync(t.file,"utf-8"));var o=yield a.updateApplication(i);n.succeed(`Application updated: ${k.Ay.green(o.name)}`),o.has_unreleased_changes&&console.log(k.Ay.yellow("Note: Application has unreleased changes"))}catch(e){n.fail(`Failed to update application: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Oe.command("short-edit <id>").description("Short edit application properties").requiredOption("-l, --list <json>","Short edit list as JSON array").action(function(){var e=b(function*(e,t){var a=Ne(),n=(0,j.default)("Applying short edit...").start();try{var i=JSON.parse(t.list);Array.isArray(i)||(n.fail("List must be a JSON array"),process.exit(1));var o=yield a.shortEditApplication({id:e,list:i});n.succeed(`Short edit applied to: ${k.Ay.green(o.name)}`)}catch(e){n.fail(`Failed to apply short edit: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Oe.command("short-refs <id>").description("List short edit references for an application").option("-k, --keyword <keyword>","Filter by shortId or title").option("-t, --types <types>","Comma-separated shortId prefixes to include (e.g. B,C,S)").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Ne(),n=(0,j.default)("Fetching short edit references...").start();try{var i=yield a.application({id:e});if(n.stop(),!i?.short_edit?.enabled)return void console.log(k.Ay.yellow("Short Edit is not enabled for this application"));var o=t.types?t.types.split(",").map(e=>e.trim()).filter(Boolean):[],r=(0,we.V)(i.short_edit.ref_map,{keyword:t.keyword,types:o});if(t.json)return void console.log(JSON.stringify(r,null,2));if(0===r.length)return void console.log(k.Ay.yellow("No short edit references found"));console.log(k.Ay.bold(`\nShort Edit References: ${i.name}`)),r.forEach(e=>{console.log(k.Ay.cyan(`\n${e.label} (${e.prefix}_)`)),e.refs.forEach(({shortId:e,ref:t})=>{var a=t?.title?k.Ay.gray(`- ${t.title}`):"";console.log(` ${k.Ay.green(e)} ${a}`)})}),console.log()}catch(e){n.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Oe.command("bind <id>").description("Bind devices to application").option("-b, --bind <devices>","Device IDs to bind (comma-separated)").option("-u, --unbind <devices>","Device IDs to unbind (comma-separated)").option("--dry-run","Validate inputs and show the binding plan without applying it").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Ne(),n=t.json?null:(0,j.default)("Updating device bindings...").start();try{var i=yield a.application({id:e});if(!i)throw new Error("Application not found");var o=t.bind?t.bind.split(",").map(e=>e.trim()):[],r=t.unbind?t.unbind.split(",").map(e=>e.trim()):[],s={id:e};if(o.length>0&&(s.bindDevices=o),r.length>0&&(s.unbindDevices=r),t.dryRun)return n&&n.stop(),void te({action:"application.bind",target:Ae(i,e),request:{bindDevices:o,unbindDevices:r},checks:[Z("application exists",!0,`${i.name} (${i._id})`),Z("device changes provided",o.length+r.length>0,`bind=${o.length}, unbind=${r.length}`)],json:t.json});yield a.bindApplication(s),t.json?ae({action:"application.bind",target:Ae(i,e),result:{bindDevices:o,unbindDevices:r},json:!0}):n.succeed("Device bindings updated")}catch(a){t.json?z(a.message,{action:"application.bind",target:{id:e}}):n.fail(`Failed to update bindings: ${a.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Oe.command("trigger <id> <testId>").description("Trigger automation test on application").option("--play","Play the test",!0).option("--stop","Stop the test").option("--setup-at-launch","Setup to run at app launch").option("-g, --match-group <group>","Match group").action(function(){var e=b(function*(e,t,a){var n=Ne(),i=(0,j.default)("Triggering automation...").start();try{yield n.triggerApplicationCanvasControl({id:e,testId:t,play:!a.stop&&a.play,setupAtLaunch:a.setupAtLaunch,matchGroup:a.matchGroup}),i.succeed(`Automation triggered: ${k.Ay.green(t)}`)}catch(e){i.fail(`Failed to trigger automation: ${e.message}`),process.exit(1)}});return function(t,a,n){return e.apply(this,arguments)}}()),Oe.command("release <id>").description("Release application to BRICKS platform").requiredOption("-c, --config <path|json>","Application config file path or JSON string").option("--version <version>","Version name").option("--changelogs <text>","Release changelogs").option("--dry-run","Validate inputs and show the release plan without publishing").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Ne(),n=t.json?null:(0,j.default)("Releasing application...").start();try{var i=Te(t.config),o=i.config,r=i.source,s=i.sizeBytes,p=yield a.application({id:e});if(!p)throw new Error("Application not found");if(p.lock?.enabled)throw new Error("Application is locked");var l=t.version||p.name||"Untitled",d=t.changelogs?`${t.changelogs}\n\nRelease by BRICKS CLI`:"Release by BRICKS CLI";if(t.dryRun)return n&&n.stop(),void te({action:"application.release",target:Ae(p,e),request:{version:l,changelogs:t.changelogs||null,configSource:r,configSizeBytes:s},checks:[Z("application exists",!0,`${p.name} (${p._id})`),Z("application is unlocked",!p.lock?.enabled),Z("release config loaded",!0,`${s} bytes`)],json:t.json});yield a.releaseApplication({id:e,config:o,releaseCurrentVersion:l,releaseCurrentVersionNote:d}),t.json?ae({action:"application.release",target:Ae(p,e),result:{version:l,configSource:r,configSizeBytes:s},json:!0}):n.succeed(`Application released: ${k.Ay.green(p.name)}`)}catch(a){t.json?z(a.message,{action:"application.release",target:{id:e}}):n.fail(`Failed to release application: ${a.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Oe.command("project-pull <id>").description("Pull application source files from BRICKS platform").option("-j, --json","Output as JSON (for programmatic use)").action(function(){var e=b(function*(e,t){var a=Ne(),n=t.json?null:(0,j.default)("Pulling application project...").start();try{var i=yield a.applicationProject({id:e,buildApplicationOnly:!0});i||(n?n.fail("Application project not found"):console.error(JSON.stringify({error:"Application project not found"})),process.exit(1)),t.json?console.log(JSON.stringify(i)):(n.succeed(`Application project fetched: ${k.Ay.green(i.files?.length||0)} files`),console.log(JSON.stringify(i,null,2)))}catch(e){t.json?console.error(JSON.stringify({error:e.message})):n.fail(`Failed to pull application project: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Oe.command("check-config <path>").description("Validate application config against BRICKS schema").option("-j, --json","Output as JSON").action((De=b(function*(e,t){_e.existsSync(e)||(console.error(k.Ay.red(`Config file not found: ${e}`)),process.exit(1));var a=(0,j.default)("Validating config...").start();try{var n=_e.readFileSync(e,"utf-8"),i=JSON.parse(n),o=yield Promise.all([y.e(428),y.e(425),y.e(890)]).then(y.t.bind(y,38890,19)),r=o.checkConfig,s=o.checkConfigDeprecatedFeatures,p=r(i),l=s(i);if(a.stop(),t.json)return console.log(JSON.stringify({...p,deprecations:l},null,2)),void(p.valid||process.exit(1));if(p.valid&&0===l.length)return void console.log(k.Ay.green("✓ Config is valid"));console.log(k.Ay.bold("\nConfig Validation Report")),console.log("─".repeat(60)),p.schema.length>0&&(console.log(k.Ay.red(`\n Schema Errors (${p.schema.length})\n`)),p.schema.forEach((e,t)=>{var a=e.instancePath||e.dataPath||"/";console.log(` ${k.Ay.red(`${t+1}.`)} ${k.Ay.bold(a)}`),console.log(` ${e.message}`),e.params?.pattern&&console.log(` ${k.Ay.gray(`pattern: ${e.params.pattern}`)}`)})),p.ref.length>0&&(console.log(k.Ay.red(`\n Reference Errors (${p.ref.length})\n`)),p.ref.forEach((e,t)=>{console.log(` ${k.Ay.red(`${t+1}.`)} ${k.Ay.bold(e.field)}`),console.log(` ${e.message}`)})),l.length>0&&(console.log(k.Ay.yellow(`\n Deprecation Warnings (${l.length})\n`)),l.forEach((e,t)=>{console.log(` ${k.Ay.yellow(`${t+1}.`)} ${k.Ay.bold(e.id)}`),console.log(` ${e.data}`)})),console.log("\n"+"─".repeat(60));var d=p.schema.length+p.ref.length;p.valid?console.log(k.Ay.yellow(`⚠ ${l.length} warning(s)`)):console.log(k.Ay.red(`✗ ${d} error(s)`)+(l.length>0?k.Ay.yellow(`, ${l.length} warning(s)`):"")),p.valid||process.exit(1)}catch(e){a.fail(`Failed to validate config: ${e.message}`),process.exit(1)}}),function(e,t){return De.apply(this,arguments)})),Oe.command("ctor-init <id>").alias("project-init").description("Initialize a BRICKS Project from an application").option("-o, --output <dir>","Output directory (default: current directory)").option("--github-actions","Include GitHub Actions workflow (default: true)").option("--no-github-actions","Skip GitHub Actions workflow setup").option("--agents","Include AGENTS.md (default: true)").option("--no-agents","Skip AGENTS.md setup").option("--claude","Include CLAUDE.md (default: true)").option("--no-claude","Skip CLAUDE.md setup").option("--gemini","Include GEMINI.md (default: false)").option("--no-gemini","Skip GEMINI.md setup").option("--install","Run bun install after generation (default: true)").option("--no-install","Skip bun install after generation").option("--git","Initialize git repository (default: true)").option("--no-git","Skip git initialization").option("-y, --yes","Skip prompts and use defaults/flags").option("-j, --json","Output as JSON (for programmatic use)").action((xe=b(function*(e,t){var a=(yield Promise.all([y.e(356),y.e(465)]).then(y.bind(y,16465))).initProject;yield a("application",e,t)}),function(e,t){return xe.apply(this,arguments)}));var Fe=()=>{var e=(0,I.getCurrentProfile)(),t=(0,I.getToken)(e);return t||(console.error(k.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,U.createClient)((0,I.getBaseUrl)(),t)},Se=(e,t)=>({id:e?._id||t,name:e?.name||"Unnamed",currentVersion:e?.current_version||null,public:Boolean(e?.is_public)}),Ce=new O("module").description("Module management");Ce.command("new").description("Create a new module").requiredOption("-n, --name <name>","Module name").option("-d, --description <description>","Module description").option("--layout-width <width>","Layout width",parseInt).option("--layout-height <height>","Layout height",parseInt).option("--public","Make module available to all users").option("--allow-modify","Allow users to modify imported module config").option("--init","Initialize a BRICKS Project after creation").option("-o, --output <dir>","Output directory for --init (default: current directory)").option("-y, --yes","Skip prompts for --init").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){var t=Fe(),a=e.json?null:(0,j.default)("Creating module...").start();try{var n={name:e.name};e.description&&(n.description=e.description),e.layoutWidth&&(n.layoutWidth=e.layoutWidth),e.layoutHeight&&(n.layoutHeight=e.layoutHeight),e.public&&(n.isPublic=!0),e.allowModify&&(n.isAllowModify=!0);var i=yield t.createModule(n);if(e.json&&!e.init?console.log(JSON.stringify(i,null,2)):e.json||(a.succeed(`Module created: ${k.Ay.green(i.name)}`),console.log(` ID: ${k.Ay.gray(i._id)}`),i.description&&console.log(` ${k.Ay.gray(i.description)}`),console.log(` Public: ${i.is_public?k.Ay.green("Yes"):k.Ay.gray("No")}`),console.log(` Allow Modify: ${i.is_allow_modify?k.Ay.green("Yes"):k.Ay.gray("No")}`)),e.init){a&&a.stop();var o=(yield Promise.all([y.e(356),y.e(465)]).then(y.bind(y,16465))).initProject;yield o("module",i._id,{output:e.output,yes:e.yes,json:e.json})}}catch(t){e.json?console.error(JSON.stringify({error:t.message})):a.fail(`Failed to create module: ${t.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),Ce.command("list").description("List all modules").option("-k, --keyword <keyword>","Filter by keyword").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){var t=Fe(),a=(0,j.default)("Fetching modules...").start();try{var n=yield t.modules({keyword:e.keyword});if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(k.Ay.yellow("No modules found"));console.log(k.Ay.bold("\nModules")),console.log("─".repeat(80)),n.forEach(e=>{var t=e.current_version?`v${e.current_version}`:k.Ay.gray("no version");console.log(`● ${k.Ay.cyan(e.name)} ${k.Ay.gray(t)}`),console.log(` ID: ${k.Ay.gray(e._id)}`),e.description&&console.log(` ${k.Ay.gray(e.description)}`),console.log()})}catch(e){a.fail(`Failed to list modules: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),Ce.command("list-public").description("Search public modules").requiredOption("-k, --keyword <keyword>","Search keyword (min 2 characters)").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){var t=(0,U.createClient)((0,I.getBaseUrl)()),a=(0,j.default)("Searching public modules...").start();try{var n=yield t.publicModules({keyword:e.keyword});if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(k.Ay.yellow("No public modules found"));console.log(k.Ay.bold("\nPublic Modules")),console.log("─".repeat(80)),n.forEach(e=>{var t=e.current_version?`v${e.current_version}`:k.Ay.gray("no version");console.log(`● ${k.Ay.cyan(e.name)} ${k.Ay.gray(t)}`),console.log(` ID: ${k.Ay.gray(e._id)}`),e.description&&console.log(` ${k.Ay.gray(e.description)}`),console.log()})}catch(e){a.fail(`Failed to search public modules: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),Ce.command("get <id>").description("Get module details").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Fe(),n=(0,j.default)("Fetching module...").start();try{var i=yield a.module({id:e});if(n.stop(),i||(console.log(k.Ay.red("Module not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(i,null,2));if(console.log(k.Ay.bold(`\nModule: ${i.name}`)),console.log("─".repeat(60)),console.log(`ID: ${k.Ay.gray(i._id)}`),console.log(`Description: ${i.description||k.Ay.gray("N/A")}`),console.log(`Tags: ${i.tags?.join(", ")||k.Ay.gray("None")}`),console.log(`Created: ${k.Ay.gray(i.create_datetime)}`),console.log(`Modified: ${k.Ay.gray(i.last_modify_datetime)}`),console.log(`\n${k.Ay.bold("Version")}`),console.log(`Current: ${i.current_version?`v${i.current_version}`:k.Ay.gray("No version")}`),console.log(`Unreleased: ${i.has_unreleased_changes?k.Ay.yellow("Yes"):k.Ay.green("No")}`),console.log(`\n${k.Ay.bold("Settings")}`),console.log(`Public: ${i.is_public?k.Ay.green("Yes"):k.Ay.gray("No")}`),console.log(`Allow Modify: ${i.is_allow_modify?k.Ay.green("Yes"):k.Ay.gray("No")}`),console.log(`Short Edit: ${i.short_edit?.enabled?k.Ay.green("Enabled"):k.Ay.gray("Disabled")}`),i.short_edit?.enabled&&i.short_edit.ref_map){var o=Object.keys(i.short_edit.ref_map).length;console.log(` References: ${o} editable properties`)}null!=i.use_count?.total_count&&(console.log(`\n${k.Ay.bold("Usage")}`),console.log(`Used In: ${i.use_count.total_count} application(s)`)),i.expose_properties?.length>0&&(console.log(`\n${k.Ay.bold("Exposed Properties")} (${i.expose_properties.length})`),i.expose_properties.forEach(e=>{console.log(` - ${k.Ay.cyan(e)}`)})),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get module: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ce.command("resolve <query>").description("Resolve a module name or ID to stable IDs").option("-l, --limit <limit>","Limit search results",e=>Number.parseInt(e,10),10).option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Fe(),n=t.json?null:(0,j.default)("Resolving module...").start();try{var i=yield X(()=>a.module({id:e})),o=i?[i]:yield a.modules({keyword:e,paginate:{limit:t.limit}}),r=K({resource:"module",query:e,items:o||[],fields:["_id","name"],selectedBy:i?"id":null});if(n&&n.stop(),t.json)return void q(r);if(r.resolved){var s=r.resolved;return console.log(k.Ay.bold("\nResolved Module")),console.log("─".repeat(60)),console.log(`Name: ${k.Ay.cyan(s.name||"Unnamed")}`),console.log(`ID: ${k.Ay.gray(s._id)}`),console.log(`Selected By: ${r.selectedBy}`),void console.log("─".repeat(60))}if(0===r.matches.length)return void console.log(k.Ay.yellow(`No modules matched "${e}"`));console.log(k.Ay.bold(`\nMatching Modules (${r.matches.length})`)),console.log("─".repeat(80)),r.matches.forEach(e=>{console.log(`${k.Ay.cyan(e.name||"Unnamed")} ${k.Ay.gray(e._id)}`)}),console.log("─".repeat(80))}catch(t){n?n.fail(`Failed to resolve module: ${t.message}`):z(t.message,{resource:"module",query:e}),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ce.command("update <id>").description("Update module").option("-n, --name <name>","Module name").option("-d, --description <description>","Module description").option("-c, --config <json>","Module config as JSON string").option("-f, --file <path>","Module config from file").option("--validate","Validate configuration").action(function(){var e=b(function*(e,t){var a=Fe(),n=(0,j.default)("Updating module...").start();try{var i={id:e};t.name&&(i.name=t.name),t.description&&(i.description=t.description),t.validate&&(i.validateConfig=!0),t.config?i.config=t.config:t.file&&(i.config=_e.readFileSync(t.file,"utf-8"));var o=yield a.updateModule(i);n.succeed(`Module updated: ${k.Ay.green(o.name)}`)}catch(e){n.fail(`Failed to update module: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ce.command("short-edit <id>").description("Short edit module properties").requiredOption("-l, --list <json>","Short edit list as JSON array").action(function(){var e=b(function*(e,t){var a=Fe(),n=(0,j.default)("Applying short edit...").start();try{var i=JSON.parse(t.list);Array.isArray(i)||(n.fail("List must be a JSON array"),process.exit(1));var o=yield a.shortEditModule({id:e,list:i});n.succeed(`Short edit applied to: ${k.Ay.green(o.name)}`)}catch(e){n.fail(`Failed to apply short edit: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ce.command("short-refs <id>").description("List short edit references for a module").option("-k, --keyword <keyword>","Filter by shortId or title").option("-t, --types <types>","Comma-separated shortId prefixes to include (e.g. B,C,S)").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Fe(),n=(0,j.default)("Fetching short edit references...").start();try{var i=yield a.module({id:e});if(n.stop(),!i?.short_edit?.enabled)return void console.log(k.Ay.yellow("Short Edit is not enabled for this module"));var o=t.types?t.types.split(",").map(e=>e.trim()).filter(Boolean):[],r=(0,we.V)(i.short_edit.ref_map,{keyword:t.keyword,types:o});if(t.json)return void console.log(JSON.stringify(r,null,2));if(0===r.length)return void console.log(k.Ay.yellow("No short edit references found"));console.log(k.Ay.bold(`\nShort Edit References: ${i.name}`)),r.forEach(e=>{console.log(k.Ay.cyan(`\n${e.label} (${e.prefix}_)`)),e.refs.forEach(({shortId:e,ref:t})=>{var a=t?.title?k.Ay.gray(`- ${t.title}`):"";console.log(` ${k.Ay.green(e)} ${a}`)})}),console.log()}catch(e){n.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ce.command("release <id>").description("Release module to BRICKS platform").requiredOption("-c, --config <path|json>","Module config file path or JSON string").option("--version <version>","Version name").option("--changelogs <text>","Release changelogs").option("--dry-run","Validate inputs and show the release plan without publishing").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Fe(),n=t.json?null:(0,j.default)("Releasing module...").start();try{var i=Te(t.config),o=i.config,r=i.source,s=i.sizeBytes,p=yield a.module({id:e});if(!p)throw new Error("Module not found");if(p.is_public)throw new Error("Public module deployment is temporarily not recommended");var l=t.version||p.name||"Untitled",d=t.changelogs?`${t.changelogs}\n\nRelease by BRICKS CLI`:"Release by BRICKS CLI";if(t.dryRun)return n&&n.stop(),void te({action:"module.release",target:Se(p,e),request:{version:l,changelogs:t.changelogs||null,configSource:r,configSizeBytes:s},checks:[Z("module exists",!0,`${p.name} (${p._id})`),Z("module is private",!p.is_public),Z("release config loaded",!0,`${s} bytes`)],json:t.json});yield a.releaseModule({id:e,config:o,releaseCurrentVersion:l,releaseCurrentVersionNote:d}),t.json?ae({action:"module.release",target:Se(p,e),result:{version:l,configSource:r,configSizeBytes:s},json:!0}):n.succeed(`Module released: ${k.Ay.green(p.name)}`)}catch(a){t.json?z(a.message,{action:"module.release",target:{id:e}}):n.fail(`Failed to release module: ${a.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ce.command("project-pull <id>").description("Pull module source files from BRICKS platform").option("-j, --json","Output as JSON (for programmatic use)").action(function(){var e=b(function*(e,t){var a=Fe(),n=t.json?null:(0,j.default)("Pulling module project...").start();try{var i=yield a.moduleProject({id:e,buildApplicationOnly:!0});i||(n?n.fail("Module project not found"):console.error(JSON.stringify({error:"Module project not found"})),process.exit(1)),t.json?console.log(JSON.stringify(i)):(n.succeed(`Module project fetched: ${k.Ay.green(i.files?.length||0)} files`),console.log(JSON.stringify(i,null,2)))}catch(e){t.json?console.error(JSON.stringify({error:e.message})):n.fail(`Failed to pull module project: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ce.command("ctor-init <id>").alias("project-init").description("Initialize a BRICKS Project from a module").option("-o, --output <dir>","Output directory (default: current directory)").option("--github-actions","Include GitHub Actions workflow (default: true)").option("--no-github-actions","Skip GitHub Actions workflow setup").option("--agents","Include AGENTS.md (default: true)").option("--no-agents","Skip AGENTS.md setup").option("--claude","Include CLAUDE.md (default: true)").option("--no-claude","Skip CLAUDE.md setup").option("--gemini","Include GEMINI.md (default: false)").option("--no-gemini","Skip GEMINI.md setup").option("--install","Run bun install after generation (default: true)").option("--no-install","Skip bun install after generation").option("--git","Initialize git repository (default: true)").option("--no-git","Skip git initialization").option("-y, --yes","Skip prompts and use defaults/flags").option("-j, --json","Output as JSON (for programmatic use)").action(function(){var e=b(function*(e,t){var a=(yield Promise.all([y.e(356),y.e(465)]).then(y.bind(y,16465))).initProject;yield a("module",e,t)});return function(t,a){return e.apply(this,arguments)}}());var ke=()=>{var e=(0,I.getCurrentProfile)(),t=(0,I.getToken)(e);return t||(console.error(k.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,U.createClient)((0,I.getBaseUrl)(),t)},Ie=3e5,$e=e=>{if(!e)return k.Ay.gray("○");var t=Date.now()-new Date(e).getTime();return t<=Ie?k.Ay.green("●"):Math.floor(t/6e4)<60?k.Ay.yellow("○"):k.Ay.red("○")},je=(e,t)=>({id:e?._id||t,name:e?.name||"Unnamed",deviceCount:e?.devices?.length||0}),Re=["refresh","clear-cache","system-menu-open","system-menu-close","system-info-open","system-info-close","local-sync-panel-open","local-sync-panel-close","debug-panel-open","debug-panel-close","logging-on","logging-off","test-panel-open","test-panel-close"],Ve=new O("group").description("Device Group management");Ve.command("list").description("List all device groups").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){var t=ke(),a=(0,j.default)("Fetching device groups...").start();try{var n=yield t.deviceGroups({});if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(k.Ay.yellow("No device groups found"));console.log(k.Ay.bold("\nDevice Groups")),console.log("─".repeat(80)),n.forEach(e=>{var t=e.devices?.length||0;console.log(`● ${k.Ay.cyan(e.name)} ${k.Ay.gray(`(${t} devices)`)}`),console.log(` ID: ${k.Ay.gray(e._id)}`),e.description&&console.log(` ${k.Ay.gray(e.description)}`),console.log()})}catch(e){a.fail(`Failed to list groups: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),Ve.command("get <id>").description("Get device group details").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=ke(),n=(0,j.default)("Fetching device group...").start();try{var i=yield a.deviceGroup({id:e});if(n.stop(),i||(console.log(k.Ay.red("Device group not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(i,null,2));console.log(k.Ay.bold(`\nDevice Group: ${i.name}`)),console.log("─".repeat(60)),console.log(`ID: ${k.Ay.gray(i._id)}`),console.log(`Description: ${i.description||k.Ay.gray("N/A")}`),console.log(`Tags: ${i.tags?.join(", ")||k.Ay.gray("None")}`),console.log(`Created: ${k.Ay.gray(i.create_datetime)}`),console.log(`Modified: ${k.Ay.gray(i.last_modify_datetime)}`),i.devices?.length>0&&(console.log(`\n${k.Ay.bold("Devices")} (${i.devices.length})`),i.devices.forEach(e=>{var t=e.device_target_name||e.device_id;console.log(` - ${t} ${k.Ay.gray(`(${e.device_id})`)}`)})),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get group: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ve.command("resolve <query>").description("Resolve a device group name or ID to stable IDs").option("-l, --limit <limit>","Limit search results",e=>Number.parseInt(e,10),10).option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=ke(),n=t.json?null:(0,j.default)("Resolving device group...").start();try{var i=yield X(()=>a.deviceGroup({id:e})),o=i?[i]:yield a.deviceGroups({paginate:{limit:t.limit}}),r=i?o:(o||[]).filter(t=>t.name?.toLowerCase().includes(e.trim().toLowerCase())),s=K({resource:"group",query:e,items:r||[],fields:["_id","name"],selectedBy:i?"id":null});if(n&&n.stop(),t.json)return void q(s);if(s.resolved){var p=s.resolved;return console.log(k.Ay.bold("\nResolved Device Group")),console.log("─".repeat(60)),console.log(`Name: ${k.Ay.cyan(p.name||"Unnamed")}`),console.log(`ID: ${k.Ay.gray(p._id)}`),console.log(`Selected By: ${s.selectedBy}`),void console.log("─".repeat(60))}if(0===s.matches.length)return void console.log(k.Ay.yellow(`No device groups matched "${e}"`));console.log(k.Ay.bold(`\nMatching Device Groups (${s.matches.length})`)),console.log("─".repeat(80)),s.matches.forEach(e=>{console.log(`${k.Ay.cyan(e.name||"Unnamed")} ${k.Ay.gray(e._id)}`)}),console.log("─".repeat(80))}catch(t){n?n.fail(`Failed to resolve device group: ${t.message}`):z(t.message,{resource:"group",query:e}),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ve.command("devices <id>").description("List devices in a group with status").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=ke(),n=(0,j.default)("Fetching devices...").start();try{var i=yield a.devicesByGroup({id:e});if(n.stop(),t.json)return void console.log(JSON.stringify(i,null,2));if(!i||0===i.length)return void console.log(k.Ay.yellow("No devices in this group"));console.log(k.Ay.bold("\nDevices in Group")),console.log("─".repeat(80)),i.forEach(e=>{var t=e.entry_detail?.watch_dog_timer?.last_alive_time,a=$e(t),n=e.name||e.device_name||e.device_target_name,i=e.entry_detail?.application?.name||k.Ay.gray("No app");console.log(`${a} ${k.Ay.cyan(n.padEnd(30))} ${i}`)}),console.log("─".repeat(80))}catch(e){n.fail(`Failed to get devices: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ve.command("dispatch <id> <action>").description("Dispatch action to all devices in group").option("--dry-run","Validate inputs and show the dispatch plan without sending it").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t,a){var n=ke(),i=a.json?null:(0,j.default)(`Dispatching ${t}...`).start();Re.includes(t)||(a.json?z(`Invalid action. Valid actions: ${Re.join(", ")}`,{action:"group.dispatch",target:{id:e}}):i.fail(`Invalid action. Valid actions: ${Re.join(", ")}`),process.exit(1));try{var o=yield n.deviceGroup({id:e});if(!o)throw new Error("Device group not found");if(a.dryRun)return i&&i.stop(),void te({action:"group.dispatch",target:je(o,e),request:{action:t},checks:[Z("group exists",!0,`${o.name} (${o._id})`),Z("action is valid",!0)],json:a.json});var r=yield n.dispatchDeviceGroupAction({id:e,action:t});a.json?ae({action:"group.dispatch",target:je(o,e),result:{action:t,success:r?.success||0,failed:r?.failed||0},json:!0}):(i.succeed(`Action dispatched: ${k.Ay.green(t)}`),r&&(console.log(`Success: ${k.Ay.green(r.success||0)}`),console.log(`Failed: ${k.Ay.red(r.failed||0)}`)))}catch(t){a.json?z(t.message,{action:"group.dispatch",target:{id:e}}):i.fail(`Failed to dispatch action: ${t.message}`),process.exit(1)}});return function(t,a,n){return e.apply(this,arguments)}}()),Ve.command("refresh <id>").description("Refresh all devices in group").option("--dry-run","Validate inputs and show the refresh plan without sending it").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=ke(),n=t.json?null:(0,j.default)("Refreshing devices...").start();try{var i=yield a.deviceGroup({id:e});if(!i)throw new Error("Device group not found");if(t.dryRun)return n&&n.stop(),void te({action:"group.refresh",target:je(i,e),request:{action:"refresh"},checks:[Z("group exists",!0,`${i.name} (${i._id})`)],json:t.json});var o=yield a.dispatchDeviceGroupAction({id:e,action:"refresh"});t.json?ae({action:"group.refresh",target:je(i,e),result:{success:o?.success||0,failed:o?.failed||0},json:!0}):(n.succeed("Devices refreshed"),o&&(console.log(`Success: ${k.Ay.green(o.success||0)}`),console.log(`Failed: ${k.Ay.red(o.failed||0)}`)))}catch(a){t.json?z(a.message,{action:"group.refresh",target:{id:e}}):n.fail(`Failed to refresh: ${a.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ve.command("monitor <id>").description("Monitor devices in group (polls every 60s)").option("-i, --interval <seconds>","Polling interval in seconds","60").action(function(){var e=b(function*(e,t){var a=ke(),n=1e3*parseInt(t.interval,10);console.log(k.Ay.bold("\nDevice Group Monitor")),console.log(k.Ay.gray(`Polling every ${t.interval}s. Press Ctrl+C to stop.\n`));var i=function(){var t=b(function*(){try{var t=yield Promise.all([a.deviceGroup({id:e}),a.devicesByGroup({id:e})]),n=J(t,2),i=n[0],o=n[1];if(process.stdout.write("[2J[0f"),console.log(k.Ay.bold(`Device Group: ${i.name}`)+k.Ay.gray(` - ${(new Date).toLocaleTimeString()}`)),console.log("─".repeat(80)),!o||0===o.length)return void console.log(k.Ay.yellow("No devices in this group"));var r=0,s=0;o.forEach(e=>{var t=e.entry_detail?.watch_dog_timer?.last_alive_time,a=$e(t),n=e.name||e.device_name||e.device_target_name,i=e.entry_detail?.application?.name||k.Ay.gray("No app");t&&Date.now()-new Date(t).getTime()<=Ie?r++:s++,console.log(`${a} ${k.Ay.cyan(n.padEnd(30))} ${i}`)}),console.log("─".repeat(80)),console.log(`Online: ${k.Ay.green(r)} Offline: ${k.Ay.red(s)}`),console.log(`\n${k.Ay.gray("Press Ctrl+C to stop")}`)}catch(e){console.error(k.Ay.red(`Error: ${e.message}`))}});return function(){return t.apply(this,arguments)}}();yield i(),setInterval(i,n)});return function(t,a){return e.apply(this,arguments)}}());const Pe=t("fs/promises");var Be=y(86090),Le=()=>{var e=(0,I.getCurrentProfile)(),t=(0,I.getToken)(e);return t||(console.error(k.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,U.createClient)((0,I.getBaseUrl)(),t)},Me=function(){var e=b(function*(e){var t=yield e.workspace();if(!(0,H.wR)(t))throw new Error("Media workspace not enabled for this workspace")});return function(t){return e.apply(this,arguments)}}(),Ue=e=>{var t=e.meta||{};if(!t.originalFileUploaded)return{ready:!1,label:"Uploading"};if("Video"===e.fileType){if(!t.videoThumbOriginalFileKey)return{ready:!1,label:"Processing"};if(!t.convertedFileUploaded)return{ready:!1,label:"Transcoding"}}return{ready:!0,label:"Ready"}},qe=e=>e.ready?k.Ay.green(e.label):k.Ay.yellow(e.label),ze=new O("media").description("Media Flow support");ze.command("boxes").description("List Media Flow boxes").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){var t=Le(),a=(0,j.default)("Fetching media boxes...").start();try{yield Me(t);var n=yield t.mediaBoxes();if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(k.Ay.yellow("No media boxes found"));console.log(k.Ay.bold("\nMedia Boxes")),console.log("─".repeat(80)),n.forEach(e=>{console.log(`${k.Ay.cyan(e.name||"Unnamed")} ${k.Ay.gray(e.id)}`),e.description&&console.log(` ${e.description}`),e.tags?.length&&console.log(` Tags: ${e.tags.join(", ")}`),null!=e.size&&console.log(` Size: ${e.size}`),console.log()})}catch(e){a.fail(`Failed to list media boxes: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),ze.command("box <id>").description("Get Media Flow box details").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Le(),n=(0,j.default)("Fetching media box...").start();try{yield Me(a);var i=yield a.mediaBox({id:e});if(n.stop(),i||(console.log(k.Ay.red("Media box not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(i,null,2));console.log(k.Ay.bold(`\nMedia Box: ${i.name||"Unnamed"}`)),console.log("─".repeat(60)),console.log(`ID: ${k.Ay.gray(i.id)}`),console.log(`Description: ${i.description||k.Ay.gray("N/A")}`),console.log(`Tags: ${i.tags?.join(", ")||k.Ay.gray("None")}`),null!=i.size&&console.log(`Size: ${i.size}`),i.passcodes?.length&&(console.log(`\n${k.Ay.bold("Passcodes")}`),i.passcodes.forEach(e=>{console.log(`- ${e.name||"Passcode"}: ${e.code}`)})),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get media box: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),ze.command("files <boxId>").description("List Media Flow files in a box").option("-t, --types <types>","Comma-separated file types to include").option("-u, --user-tag <tag>","Filter by user tag (repeatable)",(e,t)=>[...t,e],[]).option("-l, --limit <limit>","Limit results",e=>Number.parseInt(e,10)).option("-o, --offset <offset>","Offset results",e=>Number.parseInt(e,10)).option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Le(),n=(0,j.default)("Fetching media files...").start();try{yield Me(a);var i=t.types?t.types.split(",").map(e=>e.trim()).filter(Boolean):void 0,o=t.userTag?.length?t.userTag:void 0,r=yield a.mediaFiles({boxId:e,includeTypes:i,userTags:o,limit:t.limit,offset:t.offset});if(n.stop(),t.json)return void console.log(JSON.stringify(r,null,2));if(!r||0===r.length)return void console.log(k.Ay.yellow("No media files found"));console.log(k.Ay.bold(`\nMedia Files (${r.length})`)),console.log("─".repeat(100)),r.forEach(e=>{var t=Ue(e);console.log(`${k.Ay.cyan(e.name||"Unnamed")} ${k.Ay.gray(e.id)}`),console.log(` Type: ${e.fileType} Status: ${qe(t)}`),e.userTags?.length&&console.log(` Tags: ${e.userTags.join(", ")}`),e.updatedAt&&console.log(` Updated: ${new Date(e.updatedAt).toLocaleString()}`),console.log()})}catch(e){n.fail(`Failed to list media files: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),ze.command("file <id>").description("Get Media Flow file details").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t){var a=Le(),n=(0,j.default)("Fetching media file...").start();try{yield Me(a);var i=yield a.mediaFile({id:e});if(n.stop(),i||(console.log(k.Ay.red("Media file not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(i,null,2));var o=Ue(i);console.log(k.Ay.bold(`\nMedia File: ${i.name||"Unnamed"}`)),console.log("─".repeat(60)),console.log(`ID: ${k.Ay.gray(i.id)}`),console.log(`Box ID: ${k.Ay.gray(i.boxId)}`),console.log(`Type: ${i.fileType}`),console.log(`Status: ${qe(o)}`),console.log(`Description: ${i.description||k.Ay.gray("N/A")}`),console.log(`Tags: ${i.userTags?.join(", ")||k.Ay.gray("None")}`),console.log(`Created: ${k.Ay.gray(i.createdAt||"N/A")}`),console.log(`Updated: ${k.Ay.gray(i.updatedAt||"N/A")}`);var r=(0,H.Gu)(i),s=(0,H.Gu)(i,{preferThumbnail:!0});i.meta?.originalFileKey&&console.log(`Original Key: ${k.Ay.gray(i.meta.originalFileKey)}`),r&&console.log(`Original URL: ${k.Ay.gray(r)}`),s&&s!==r&&console.log(`Thumbnail URL: ${k.Ay.gray(s)}`),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get media file: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}());var Ge=e=>{var t=e.match(/^(\d+)x(\d+)(?::(\w+))?$/);if(!t)throw new Error(`Invalid image version spec: "${e}". Expected format: WxH or WxH:STRATEGY`);return{width:parseInt(t[1],10),height:parseInt(t[2],10),strategy:(t[3]||"FILL").toUpperCase(),copypreview:!1}},Ye=function(){var e=b(function*(e,t,a,n,i){var o=new FormData;for(var r of Object.entries(t)){var s=J(r,2),p=s[0],l=s[1];o.append(p,l)}o.append("file",new Blob([a],{type:i}),n);var d=yield fetch(e,{method:"POST",body:o});if(!d.ok&&204!==d.status){var c=yield d.text().catch(()=>"");throw new Error(`S3 upload failed (${d.status}): ${c}`)}});return function(t,a,n,i,o){return e.apply(this,arguments)}}(),Qe=function(){var e=b(function*(e,t,a){var n=[],i=0,o=function(){var t=b(function*(){for(;i<e.length;){var t=i++;n[t]=yield a(e[t],t)}});return function(){return t.apply(this,arguments)}}(),r=Array.from({length:Math.min(t,e.length)},()=>o());return yield Promise.all(r),n});return function(t,a,n){return e.apply(this,arguments)}}();ze.command("upload <boxId> <files...>").description("Upload file(s) to a Media Flow box").option("-d, --description <text>","File description","").option("-t, --user-tag <tag>","User tag (repeatable, max 15)",(e,t)=>[...t,e],[]).option("--image-version <spec>","Image resize spec as WxH or WxH:STRATEGY (repeatable)",(e,t)=>[...t,e],[]).option("--image-version-type <type>","Image output format: jpg or png").option("--enable-ai-analysis","Enable AI analysis on uploaded files").option("--ai-instruction <text>","Custom AI analysis instruction").option("--concurrency <n>","Max concurrent uploads",e=>parseInt(e,10),3).option("-j, --json","Output as JSON").action(function(){var e=b(function*(e,t,a){var n=Le(),i=(0,j.default)("Preparing upload...").start();try{if(yield Me(n),a.userTag.length>15)throw new Error("Maximum 15 user tags allowed");var o=a.imageVersion.map(Ge),r=a.enableAiAnalysis||!!a.aiInstruction,s=yield Promise.all(t.map(function(){var e=b(function*(e){var t=(0,Ee.resolve)(e),a=yield(0,Pe.stat)(t).catch(()=>null);if(!a||!a.isFile())throw new Error(`Not a file: ${e}`);var n=(0,Ee.basename)(t);return{filePath:t,fileName:n,contentType:(0,Be.lookup)(n)||"application/octet-stream",size:a.size}});return function(t){return e.apply(this,arguments)}}()));i.stop();var p=s.length;console.log(k.Ay.bold(`\nUploading ${p} file${p>1?"s":""} to box ${k.Ay.gray(e)}...\n`));var l=[];yield Qe(s,a.concurrency,function(){var t=b(function*(t,i){var s,d,c=`[${i+1}/${p}] ${t.fileName}`,u=(0,j.default)(`${c} — requesting upload...`).start();try{var m=(d=t.contentType)?"image/svg+xml"===d?"FILE":d.startsWith("image/")?"IMAGE":d.startsWith("video/")?"VIDEO":d.startsWith("audio/")?"AUDIO":"FILE":"FILE",f={imageVersions:"IMAGE"===m?o:[],imageVersionType:"IMAGE"===m?a.imageVersionType:void 0,enableAiAnalysis:r,aiCustomInstruction:a.aiInstruction||void 0},v=yield n.createMediaFileUploadRequest({name:t.fileName,description:a.description,boxId:e,fileType:m,contentType:t.contentType,userTags:a.userTag.length?a.userTag:[],meta:f});u.text=`${c} — uploading to storage...`;var h=JSON.parse(v.meta.uploadInfo),g=yield(0,Pe.readFile)(t.filePath);yield Ye(h.url,{AWSAccessKeyId:h.AWSAccessKeyId,"Content-Type":h["Content-Type"],key:h.key,Signature:h.Signature,Policy:h.Policy,acl:h.acl},g,t.fileName,t.contentType),u.succeed(`${c} ${k.Ay.green("✓")} ${k.Ay.gray(`(${m}, ${s=t.size,s<1024?`${s} B`:s<1048576?`${(s/1024).toFixed(1)} KB`:s<1073741824?`${(s/1048576).toFixed(1)} MB`:`${(s/1073741824).toFixed(1)} GB`})`)}`),l.push({file:t.fileName,id:v.id,status:"success",fileType:m,size:t.size})}catch(e){u.fail(`${c} — ${e.message}`),l.push({file:t.fileName,id:null,status:"failed",error:e.message})}});return function(e,a){return t.apply(this,arguments)}}());var d=l.filter(e=>"success"===e.status).length,c=l.filter(e=>"failed"===e.status).length;a.json?console.log(JSON.stringify({boxId:e,results:l,summary:{total:p,success:d,failed:c}},null,2)):(console.log(),0===c?console.log(k.Ay.green(`Uploaded ${d}/${p} files`)):console.log(k.Ay.yellow(`Uploaded ${d}/${p} files (${c} failed)`))),c>0&&process.exit(1)}catch(e){i.fail(`Upload failed: ${e.message}`),process.exit(1)}});return function(t,a,n){return e.apply(this,arguments)}}());var Je={prod:"https://display.bricks.tools",beta:"https://display-beta.bricks.tools",dev:"http://localhost:3001"},He=e=>{var t=Object.entries(Je).find(([,t])=>e===t);return t?t[0]:null},We={prod:"https://activity-log.bricks.tools",beta:"https://activity-log-beta.bricks.tools",dev:"http://localhost:8088"},Ke=e=>{var t=Object.entries(We).find(([,t])=>e===t);return t?t[0]:null},Xe=new O("config").description("CLI configuration management");Xe.command("endpoint").argument("[environment]","Environment to use (prod, beta, dev)").description("Show or set endpoint environment").option("-p, --profile","Set for current profile instead of global").action((e,t)=>{if(!e){var a=(0,I.getBaseUrl)(),n=He(a),i=(0,I.getActivityLogBaseUrl)(),o=Ke(i);return console.log(k.Ay.bold("\nEndpoint Configuration")),console.log("─".repeat(50)),console.log(k.Ay.bold("BRICKS")),console.log(` URL: ${k.Ay.cyan(a)}`),console.log(` Environment: ${n?k.Ay.green(n):k.Ay.yellow("custom")}`),console.log(k.Ay.bold("Activity Log")),console.log(` URL: ${k.Ay.cyan(i)}`),console.log(` Environment: ${o?k.Ay.green(o):k.Ay.yellow("custom")}`),console.log("─".repeat(50)),void console.log(k.Ay.gray("\nUsage: bricks config endpoint <prod|beta|dev>"))}var r=Object.keys(Je);r.includes(e)||(console.error(k.Ay.red(`Invalid environment: ${e}`)),console.log(k.Ay.gray(`Valid options: ${r.join(", ")}`)),process.exit(1));var s=Je[e],p=We[e],l=t.profile?(0,I.getCurrentProfile)():null;(0,I.setBaseUrl)(s,l),(0,I.setActivityLogBaseUrl)(p,l);var d=t.profile?` (profile: ${(0,I.getCurrentProfile)()})`:"";console.log(k.Ay.green(`✓ Endpoint changed to ${e}${d}`)),console.log(k.Ay.gray(` BRICKS: ${s}`)),console.log(k.Ay.gray(` Activity Log: ${p}`)),console.log(k.Ay.yellow("\nNote: You may need to re-authenticate if your token is for a different environment.")),console.log(k.Ay.gray("Use `bricks auth status` to check your connection."))}),Xe.command("show").description("Show current configuration").option("-j, --json","Output as JSON").action(e=>{var t=(0,I.getBaseUrl)(),a=He(t);if(e.json)console.log(JSON.stringify({endpoint:t,environment:a||"custom"},null,2));else{console.log(k.Ay.bold("\nBRICKS CLI Configuration")),console.log("─".repeat(50)),console.log(`BRICKS: ${k.Ay.cyan(t)}`),a?console.log(`Environment: ${k.Ay.green(a)}`):console.log(`Environment: ${k.Ay.yellow("custom")}`);var n=(0,I.getActivityLogBaseUrl)(),i=Ke(n);console.log(`Activity Log: ${k.Ay.cyan(n)} ${i?k.Ay.green(`(${i})`):k.Ay.yellow("(custom)")}`),console.log("─".repeat(50))}});var Ze=new O("mcp").description("MCP server management");Ze.command("start").description("Start the BRICKS MCP server in STDIO mode").option("-t, --token <token>","API token (overrides saved token)").action(function(){var e=b(function*(e){var t=(0,I.getCurrentProfile)(),a=e.token||(0,I.getToken)(t);a||(console.error(k.Ay.red("Error: No API token found.")),console.error(k.Ay.gray("Please login first with: bricks auth login <passcode>")),console.error(k.Ay.gray("Or provide a token with: bricks mcp start --token <token>")),process.exit(1));try{var n=(yield Promise.all([y.e(428),y.e(300),y.e(425),y.e(737)]).then(y.bind(y,18737))).startStdioServer;yield n({token:a})}catch(e){console.error(k.Ay.red(`Failed to start MCP server: ${e.message}`)),process.exit(1)}});return function(t){return e.apply(this,arguments)}}());const et=t("node:fs/promises");var tt=y(76760),at=y(12044),nt=function(){var e=b(function*(e,t,a=3e3){var n;try{var i=new AbortController;n=setTimeout(()=>i.abort(),a);var o=yield fetch(`http://${e}:${t}/json/list`,{signal:i.signal});return o.ok?yield o.json():null}catch{return null}finally{void 0!==n&&clearTimeout(n)}});return function(t,a){return e.apply(this,arguments)}}(),it=e=>{if(!e)return null;var t=e.match(/\/ws\/(.+)$/);return t?decodeURIComponent(t[1]):null},ot=function(){var e=b(function*(e,t=1e3){for(var a=[],n=e,i=0;i<10;i++){var o=tt.join(n,".bricks","devtools.json");try{var r=yield et.readFile(o,"utf8"),s=JSON.parse(r),p=yield(0,at.verifyDevToolsServer)(s.address||"localhost",s.port,t);p&&a.push({name:s.name||"BRICKS Preview (CTOR Preview)",address:s.address||"localhost",port:s.port,protocols:["cdp"],hasPasscode:!1,source:"project",projectPath:n,...p})}catch{}var l=tt.dirname(n);if(l===n)break;n=l}return a});return function(t){return e.apply(this,arguments)}}(),rt=function(){var e=b(function*({timeout:e=3e3,verify:t=!1,udpOnly:a=!1,project:n=!0,port:i=19851,cwd:o=process.cwd(),onStatus:r}={}){var s=(0,at.discoverDevToolsServers)({timeout:e,idleTimeout:800}),p=a?Promise.resolve([]):(r?.("Scanning via UDP + HTTP probe..."),(0,at.httpProbeSubnet)({port:i,timeout:e})),l=n?ot(o,1e3):Promise.resolve([]),d=yield Promise.all([s,p,l]),c=J(d,3),u=(e=>{var t=new Map;for(var a of e){var n=a.deviceId||`${a.address}:${a.port}`,i=t.get(n);if(i){for(var o of(i.addresses.includes(a.address)||i.addresses.push(a.address),"127.0.0.1"===i.address&&"127.0.0.1"!==a.address&&(i.address=a.address),a.protocols||[]))i.protocols.includes(o)||i.protocols.push(o);for(var r of Object.entries(a)){var s=J(r,2),p=s[0],l=s[1];null!=l&&"address"!==p&&"addresses"!==p&&"protocols"!==p&&(void 0!==i[p]&&null!==i[p]||(i[p]=l))}}else t.set(n,{...a,addresses:[a.address],protocols:[...a.protocols||[]]})}return[...t.values()]})([...c[0],...c[1],...c[2]]);if(0===u.length)return[];if(t){r?.(`Verifying ${u.length} server(s)...`);var m=yield Promise.all(u.map(function(){var e=b(function*(e){var t=yield(0,at.verifyDevToolsServer)(e.address,e.port);return{...e,verified:!!t,version:t?.version||e.version}});return function(t){return e.apply(this,arguments)}}()));u.splice(0,u.length,...m)}return r?.("Checking chrome://inspect support..."),yield Promise.all(u.map(function(){var e=b(function*(e){var t=yield nt(e.address,e.port);if(t){e.chromeInspect=!0;var a=it(t[0]?.webSocketDebuggerUrl);a&&(e.passcode=a)}});return function(t){return e.apply(this,arguments)}}())),u});return function(){return e.apply(this,arguments)}}(),st="2.24",pt=e=>{if(!e)return!1;for(var t=e.replace(/^v/,"").split(".").map(Number),a=st.split(".").map(Number),n=0;n<a.length;n++){if((t[n]||0)>a[n])return!0;if((t[n]||0)<a[n])return!1}return!0},lt=e=>e.requiredOption("-a, --address <address>","DevTools server address").option("-p, --port <port>","Server port","19851").option("--passcode <passcode>","Device passcode").option("-j, --json","Output as JSON"),dt=function(){var e=b(function*(e,t){var a,n=(yield Promise.resolve().then(y.bind(y,29790))).default,i=(yield Promise.resolve().then(y.bind(y,12044))).verifyDevToolsServer,o=(yield y.e(999).then(y.bind(y,12999))).createCdpClient,r=parseInt(e.port,10),s=n("Connecting to DevTools...").start();try{var p=yield i(e.address,r);p||(s.fail(`Cannot reach DevTools server at ${e.address}:${r}`),process.exit(1)),p.version&&!pt(p.version)&&(s.fail(`CDP requires app version >= ${st} (device: ${p.version})`),process.exit(1)),a=o(e.address,r,e.passcode),yield a.connect(),s.stop(),yield t(a)}catch(e){s.isSpinning&&s.stop(),console.error(k.Ay.red(e.message)),process.exit(1)}finally{a?.close()}});return function(t,a){return e.apply(this,arguments)}}(),ct=e=>{if(!e)return{};for(var t={},a=0;a<e.length;a+=2)t[e[a]]=e[a+1];return t},ut=(e,t="",a=!0,n=!0)=>{var i=[],o=n?"":a?"└─ ":"├─ ",r=n?"":a?" ":"│ ",s=e.nodeName||"#unknown";if(9===e.nodeType)s="#document";else if(3===e.nodeType){var p=e.nodeValue||"";s=k.Ay.gray(`"${p}"`)}else if(1===e.nodeType){var l=ct(e.attributes),d=l.id||l["short-id"];d&&(s+=k.Ay.gray(`#${d}`)),l.title&&(s+=` ${k.Ay.green(`"${l.title}"`)}`),void 0!==l.w&&void 0!==l.h&&(s+=k.Ay.blue(` ${l.w}×${l.h}`),void 0!==l.x&&void 0!==l.y&&(s+=k.Ay.blue(` @${l.x},${l.y}`)));var c=[];void 0!==l.hide&&c.push(k.Ay.red("hidden")),void 0!==l.pressable&&c.push(k.Ay.yellow("pressable")),void 0!==l.editable&&c.push(k.Ay.yellow("editable")),c.length>0&&(s+=` [${c.join(", ")}]`)}i.push(`${t}${o}${s}`);var u=e.children||[];return u.forEach((e,a)=>{i.push(...ut(e,t+r,a===u.length-1,!1))}),i},mt=new O("devtools").description("DevTools server discovery, inspection, and CDP commands");mt.command("scan").description("Scan LAN for DevTools servers via UDP + HTTP").option("-t, --timeout <ms>","Scan timeout in milliseconds","3000").option("-j, --json","Output as JSON").option("--verify","Verify each discovered server via HTTP").option("--udp-only","Skip HTTP subnet probe (UDP only)").option("--no-project","Exclude local BRICKS project preview servers").option("-p, --port <port>","Port for HTTP probe","19851").action(function(){var e=b(function*(e){var t=(yield Promise.resolve().then(y.bind(y,29790))).default,a=yield Promise.resolve().then(y.bind(y,74752)),n=a.getCurrentProfile,i=a.getTokenInfo,o=parseInt(e.timeout,10),r=t(`Scanning for DevTools servers (${o}ms)...`).start();try{var s=yield rt({timeout:o,verify:!!e.verify,udpOnly:!!e.udpOnly,project:!!e.project,port:parseInt(e.port,10),onStatus:e=>{r.text=e}});if(0===s.length)return e.json?(r.stop(),console.log(JSON.stringify([],null,2))):r.info("No DevTools servers found on the network."),void process.exit(0);r.stop(),e.json&&(console.log(JSON.stringify(s,null,2)),process.exit(0));var p=i(n()),l=p?.workspaceId||null;console.log(k.Ay.bold(`\nFound ${s.length} DevTools server(s)`)),console.log("─".repeat(80));var d=function*(e){var t=!1===e.verified?k.Ay.red("unverified"):k.Ay.green("online"),a=e.hasPasscode?k.Ay.yellow("passcode"):k.Ay.gray("open"),n=(e.protocols||[]).map(e=>k.Ay.cyan(e)).join(", "),i=e.workspaceId&&l&&e.workspaceId===l,o=e.addresses||[e.address],r=o.filter(t=>t!==e.address),s=r.length>0?`${e.address}:${e.port} +${r.length} more`:`${e.address}:${e.port}`;if(console.log(` ${k.Ay.bold(e.name||"Unknown")} ${k.Ay.gray(`(${s})`)} [${t}]`),r.length>0&&console.log(` Addresses: ${o.map(e=>k.Ay.gray(e)).join(", ")}`),e.version&&console.log(` Version: ${k.Ay.green(e.version)}`),e.chromeInspect){var p=e.passcode?k.Ay.cyan(e.passcode):k.Ay.gray("no passcode");console.log(` Chrome Inspect: ${k.Ay.green("supported")} (passcode: ${p})`)}var d=` Protocols: ${n||k.Ay.gray("none")} Auth: ${a}`;if(e.deviceId&&(d+=` Device: ${k.Ay.gray(e.deviceId)}`),console.log(d),e.workspaceId){var c=i?k.Ay.green(`${e.workspaceId} (current profile)`):k.Ay.gray(e.workspaceId);console.log(` Workspace: ${c}`)}};for(var c of s)yield*d(c);console.log("─".repeat(80));var u=s[0],m=`${u.address}:${u.port||19851}`,f=u.passcode?`/ws/${encodeURIComponent(u.passcode)}`:"/ws/<passcode>";console.log(k.Ay.gray(`\nConnect via: devtools://devtools/bundled/inspector.html?ws=${m}${f}`)),process.exit(0)}catch(e){r.fail(`Scan failed: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),mt.command("open <address>").description("Show DevTools server information").option("-p, --port <port>","Server port","19851").option("--info","Show connection URLs").action(function(){var e=b(function*(e,t){var a=(yield Promise.resolve().then(y.bind(y,29790))).default,n=(yield Promise.resolve().then(y.bind(y,12044))).verifyDevToolsServer,i=parseInt(t.port,10),o=`${e}:${i}`,r=a(`Fetching server info from ${o}...`).start(),s=yield n(e,i);s||(r.fail(`Could not reach DevTools server at ${o}`),process.exit(1)),r.stop();var p=yield nt(e,i),l=p?it(p?.[0]?.webSocketDebuggerUrl):null,d=l?`/ws/${encodeURIComponent(l)}`:"/ws/<passcode>";if(t.info)return console.log(k.Ay.bold("Connection URLs")),console.log("─".repeat(60)),console.log(` Web UI: ${k.Ay.cyan(`http://${o}`)}`),console.log(` CDP: ${k.Ay.cyan(`devtools://devtools/bundled/inspector.html?ws=${o}${d}`)}`),console.log(` MCP: ${k.Ay.cyan(`http://${o}/mcp`)}`),console.log(` MCP SSE: ${k.Ay.cyan(`http://${o}/sse`)}`),console.log(` Info: ${k.Ay.cyan(`http://${o}/devtools/info`)}`),console.log("─".repeat(60)),console.log(),console.log(k.Ay.bold("Authorization")),l&&console.log(` Passcode: ${k.Ay.cyan(l)}`),console.log(" MCP and MCP SSE require a Bearer token header with the device passcode:"),void console.log(` ${k.Ay.gray(`Authorization: Bearer ${l||"<passcode>"}`)}`);if(console.log(k.Ay.bold("DevTools Server")),console.log("─".repeat(60)),console.log(` Name: ${k.Ay.cyan(s.name||"Unknown")}`),console.log(` Version: ${s.version?k.Ay.green(s.version):k.Ay.gray("N/A")}`),console.log(` Device ID: ${k.Ay.gray(s.deviceId||"N/A")}`),console.log(` Workspace: ${k.Ay.gray(s.workspaceId||"N/A")}`),console.log(` Protocols: ${(s.protocols||[]).map(e=>k.Ay.cyan(e)).join(", ")||k.Ay.gray("none")}`),console.log(` Auth: ${s.hasPasscode?k.Ay.yellow("passcode required"):k.Ay.gray("open")}`),console.log(` Port: ${s.port}`),p){var c=l?k.Ay.cyan(l):k.Ay.gray("no passcode");console.log(` Inspect: ${k.Ay.green("chrome://inspect supported")} (passcode: ${c})`)}else console.log(` Inspect: ${k.Ay.gray("chrome://inspect not available")}`);console.log("─".repeat(60)),s.version&&!pt(s.version)&&console.log(k.Ay.yellow(`\n CDP commands require version >= ${st}`)),console.log(k.Ay.gray("\n Use --info to see connection URLs"))});return function(t,a){return e.apply(this,arguments)}}()),lt(mt.command("screenshot").description("Capture device screenshot").option("-o, --output <path>","Output file path")).action(function(){var e=b(function*(e){yield dt(e,function(){var t=b(function*(t){var a=yield t.send("Page.captureScreenshot",{format:"png"});a.data||(console.error(k.Ay.red("No screenshot data received")),process.exit(1));var n=yield Promise.resolve().then(y.t.bind(y,73024,19)),i=yield Promise.resolve().then(y.t.bind(y,76760,19)),o=e.output||`screenshot-${Date.now()}.png`,r=i.resolve(o);n.writeFileSync(r,Buffer.from(a.data,"base64")),console.log(k.Ay.green(`Screenshot saved to ${r}`))});return function(e){return t.apply(this,arguments)}}())});return function(t){return e.apply(this,arguments)}}());var ft,vt,ht,gt,yt=mt.command("brick").description("Brick component inspection");lt(yt.command("tree").description("Print brick component tree").option("-d, --depth <depth>","Max depth (-1 for full)","3")).action(function(){var e=b(function*(e){yield dt(e,function(){var t=b(function*(t){yield t.send("DOM.enable");var a=parseInt(e.depth,10),n=(yield t.send("DOM.getDocument",{depth:a})).root;e.json?console.log(JSON.stringify(n,null,2)):console.log(ut(n).join("\n"))});return function(e){return t.apply(this,arguments)}}())});return function(t){return e.apply(this,arguments)}}()),lt(yt.command("query <selector>").description("Find brick by CSS selector")).action(function(){var e=b(function*(e,t){yield dt(t,function(){var a=b(function*(a){yield a.send("DOM.enable");var n=(yield a.send("DOM.getDocument",{depth:0})).root,i=(yield a.send("DOM.querySelector",{nodeId:n.nodeId,selector:e})).nodeId;if(0!==i){var o=yield a.send("DOM.describeNode",{nodeId:i}),r=(yield a.send("DOM.getAttributes",{nodeId:i})).attributes,s=ct(r);if(t.json)console.log(JSON.stringify({nodeId:i,...o.node,attributes:s},null,2));else if(console.log(k.Ay.bold(`Node ${i}: ${o.node?.nodeName||"unknown"}`)),Object.keys(s).length>0)for(var p of(console.log(k.Ay.bold("Attributes:")),Object.entries(s))){var l=J(p,2),d=l[0],c=l[1];console.log(` ${k.Ay.cyan(d)}: ${c}`)}}else console.log(k.Ay.yellow("No element found"))});return function(e){return a.apply(this,arguments)}}())});return function(t,a){return e.apply(this,arguments)}}()),lt(yt.command("query-all <selector>").description("Find all bricks matching CSS selector")).action(function(){var e=b(function*(e,t){yield dt(t,function(){var a=b(function*(a){yield a.send("DOM.enable");var n=(yield a.send("DOM.getDocument",{depth:0})).root,i=(yield a.send("DOM.querySelectorAll",{nodeId:n.nodeId,selector:e})).nodeIds;if(t.json)console.log(JSON.stringify({nodeIds:i,count:i.length},null,2));else for(var o of(console.log(k.Ay.bold(`Found ${i.length} element(s)`)),i)){var r=yield a.send("DOM.describeNode",{nodeId:o}),s=(yield a.send("DOM.getAttributes",{nodeId:o})).attributes,p=ct(s),l=p.id||p["short-id"]||"";console.log(` ${o}: ${r.node?.nodeName}${l?k.Ay.gray(`#${l}`):""}`)}});return function(e){return a.apply(this,arguments)}}())});return function(t,a){return e.apply(this,arguments)}}()),lt(yt.command("attributes <nodeId>").description("Get brick attributes")).action((ft=b(function*(e,t){var a;yield dt(t,(a=b(function*(a){yield a.send("DOM.enable");var n=parseInt(e,10),i=(yield a.send("DOM.getAttributes",{nodeId:n})).attributes,o=ct(i);if(t.json)console.log(JSON.stringify(o,null,2));else if(0!==Object.keys(o).length)for(var r of Object.entries(o)){var s=J(r,2),p=s[0],l=s[1];console.log(` ${k.Ay.cyan(p)}: ${l}`)}else console.log(k.Ay.gray("No attributes"))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return ft.apply(this,arguments)})),lt(yt.command("box-model <nodeId>").description("Get brick dimensions and position")).action((vt=b(function*(e,t){var a;yield dt(t,(a=b(function*(a){yield a.send("DOM.enable");var n=parseInt(e,10),i=(yield a.send("DOM.getBoxModel",{nodeId:n})).model;t.json?console.log(JSON.stringify(i,null,2)):(console.log(k.Ay.bold(`Box Model for node ${n}`)),console.log(` Width: ${i.width}`),console.log(` Height: ${i.height}`),i.content&&console.log(` Content: [${i.content.join(", ")}]`),i.padding&&console.log(` Padding: [${i.padding.join(", ")}]`),i.border&&console.log(` Border: [${i.border.join(", ")}]`),i.margin&&console.log(` Margin: [${i.margin.join(", ")}]`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return vt.apply(this,arguments)})),lt(yt.command("resolve <nodeId>").description("Resolve brick to JavaScript object with properties")).action((ht=b(function*(e,t){var a;yield dt(t,(a=b(function*(a){yield a.send("DOM.enable");var n=parseInt(e,10),i=(yield a.send("DOM.resolveNode",{nodeId:n})).object;if(t.json)console.log(JSON.stringify(i,null,2));else if(console.log(k.Ay.bold(`Resolved node ${n}`)),console.log(` Type: ${i.type}`),i.className&&console.log(` Class: ${i.className}`),i.description&&console.log(` Description: ${i.description}`),i.objectId&&console.log(` Object ID: ${k.Ay.gray(i.objectId)}`),i.preview?.properties)for(var o of(console.log(k.Ay.bold(" Properties:")),i.preview.properties))console.log(` ${k.Ay.cyan(o.name)}: ${o.value}`)}),function(e){return a.apply(this,arguments)}))}),function(e,t){return ht.apply(this,arguments)})),lt(yt.command("focus <nodeId>").description("Focus a brick element")).action((gt=b(function*(e,t){var a;yield dt(t,(a=b(function*(t){yield t.send("DOM.enable");var a=parseInt(e,10);yield t.send("DOM.focus",{nodeId:a}),console.log(k.Ay.green(`Focused node ${a}`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return gt.apply(this,arguments)}));var bt,Dt,xt,_t=mt.command("input").description("Input emulation");lt(_t.command("tap <x> <y>").description("Tap/click at coordinates")).action((bt=b(function*(e,t,a){var n;yield dt(a,(n=b(function*(a){var n=parseFloat(e),i=parseFloat(t);yield a.send("Input.dispatchMouseEvent",{type:"mousePressed",x:n,y:i,button:"left",clickCount:1}),yield a.send("Input.dispatchMouseEvent",{type:"mouseReleased",x:n,y:i,button:"left",clickCount:1}),console.log(k.Ay.green(`Tapped at (${n}, ${i})`))}),function(e){return n.apply(this,arguments)}))}),function(e,t,a){return bt.apply(this,arguments)})),lt(_t.command("type <text>").description("Insert text into focused element")).action((Dt=b(function*(e,t){var a;yield dt(t,(a=b(function*(t){yield t.send("Input.insertText",{text:e}),console.log(k.Ay.green(`Typed: ${e}`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return Dt.apply(this,arguments)})),lt(_t.command("key <key>").description("Dispatch key event (e.g., Enter, Escape, Tab)")).action((xt=b(function*(e,t){var a;yield dt(t,(a=b(function*(t){yield t.send("Input.dispatchKeyEvent",{type:"keyDown",key:e}),yield t.send("Input.dispatchKeyEvent",{type:"keyUp",key:e}),console.log(k.Ay.green(`Key: ${e}`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return xt.apply(this,arguments)}));var wt,Et,Tt=mt.command("network").description("Network inspection");lt(Tt.command("list").description("Capture snapshot of network activity").option("--duration <ms>","Capture duration in milliseconds","2000")).action((wt=b(function*(e){var t;yield dt(e,(t=b(function*(t){var a=new Map,n=parseInt(e.duration,10);t.on("Network.requestWillBeSent",e=>{a.set(e.requestId,{method:e.request.method,url:e.request.url,requestId:e.requestId,timestamp:e.timestamp})}),t.on("Network.responseReceived",e=>{var t=a.get(e.requestId);t&&(t.status=e.response.status,t.mimeType=e.response.mimeType)}),t.on("Network.loadingFailed",e=>{var t=a.get(e.requestId);t&&(t.error=e.errorText)}),yield t.send("Network.enable"),yield new Promise(e=>setTimeout(e,n)),yield t.send("Network.disable");var i=[...a.values()];if(e.json)console.log(JSON.stringify(i,null,2));else if(console.log(k.Ay.bold(`Network Activity (captured ${(n/1e3).toFixed(1)}s, ${i.length} requests)`)),0!==i.length)for(var o of i){var r=o.error?k.Ay.red("ERR"):o.status?o.status<300?k.Ay.green(o.status):o.status<400?k.Ay.yellow(o.status):k.Ay.red(o.status):k.Ay.gray("..."),s=o.url.length>60?o.url.substring(0,57)+"...":o.url;console.log(` ${r} ${k.Ay.bold(o.method.padEnd(6))} ${s} ${k.Ay.gray(`(${o.requestId})`)}`)}else console.log(k.Ay.gray(" No network activity captured"))}),function(e){return t.apply(this,arguments)}))}),function(e){return wt.apply(this,arguments)})),lt(Tt.command("get <requestId>").description("Get response body for a network request")).action((Et=b(function*(e,t){var a;yield dt(t,(a=b(function*(a){yield a.send("Network.enable");var n=yield a.send("Network.getResponseBody",{requestId:e}),i=n.body,o=n.base64Encoded;t.json?console.log(JSON.stringify({body:i,base64Encoded:o},null,2)):o?console.log(k.Ay.gray(`[base64 encoded, ${i.length} chars]`)):console.log(i)}),function(e){return a.apply(this,arguments)}))}),function(e,t){return Et.apply(this,arguments)}));var Nt,At,Ot=mt.command("storage").description("Storage inspection"),Ft=Ot.command("system").description("System key-value storage");lt(Ft.command("persist").description("Show persistent system storage entries")).action((Nt=b(function*(e){var t;yield dt(e,(t=b(function*(t){yield t.send("DOMStorage.enable");var a=(yield t.send("DOMStorage.getDOMStorageItems",{storageId:{securityOrigin:"bricks://app",isLocalStorage:!0}})).entries;if(e.json)console.log(JSON.stringify(a,null,2));else for(var n of(console.log(k.Ay.bold(`Persistent Storage (${a.length} items)`)),console.log("─".repeat(60)),a)){var i=J(n,2),o=i[0],r=i[1],s=r.length>80?r.substring(0,80)+"...":r;console.log(` ${k.Ay.cyan(o)}: ${s}`)}}),function(e){return t.apply(this,arguments)}))}),function(e){return Nt.apply(this,arguments)})),lt(Ft.command("memory").description("Show in-memory system storage entries")).action((At=b(function*(e){var t;yield dt(e,(t=b(function*(t){yield t.send("DOMStorage.enable");var a=(yield t.send("DOMStorage.getDOMStorageItems",{storageId:{securityOrigin:"bricks://app",isLocalStorage:!1}})).entries;if(e.json)console.log(JSON.stringify(a,null,2));else for(var n of(console.log(k.Ay.bold(`Memory Storage (${a.length} items)`)),console.log("─".repeat(60)),a)){var i=J(n,2),o=i[0],r=i[1],s=r.length>80?r.substring(0,80)+"...":r;console.log(` ${k.Ay.cyan(o)}: ${s}`)}}),function(e){return t.apply(this,arguments)}))}),function(e){return At.apply(this,arguments)}));var St,Ct,kt,It=Ot.command("data-bank").description("Property Bank data stores");lt(It.command("list").description("List Property Banks")).action((St=b(function*(e){var t;yield dt(e,(t=b(function*(t){yield t.send("IndexedDB.enable");var a=(yield t.send("IndexedDB.requestDatabaseNames",{securityOrigin:"bricks://app"})).databaseNames.filter(e=>e.startsWith("DATA-"));if(e.json)console.log(JSON.stringify(a,null,2));else for(var n of(console.log(k.Ay.bold(`Property Banks (${a.length})`)),a))console.log(` ${k.Ay.cyan(n)}`)}),function(e){return t.apply(this,arguments)}))}),function(e){return St.apply(this,arguments)})),lt(It.command("get <name> <store>").description("Query Property Bank data").option("-l, --limit <count>","Max items to fetch","25").option("-s, --skip <count>","Items to skip","0")).action((Ct=b(function*(e,t,a){var n;yield dt(a,(n=b(function*(n){yield n.send("IndexedDB.enable");var i=(yield n.send("IndexedDB.requestData",{securityOrigin:"bricks://app",databaseName:e,objectStoreName:t,indexName:"",skipCount:parseInt(a.skip,10),pageSize:parseInt(a.limit,10)})).objectStoreDataEntries;if(a.json)console.log(JSON.stringify(i,null,2));else for(var o of(console.log(k.Ay.bold(`${e} / ${t} (${i.length} entries)`)),console.log("─".repeat(60)),i)){var r=JSON.stringify(o.key?.value??o.key),s=JSON.stringify(o.value?.value??o.value),p=s.length>100?s.substring(0,100)+"...":s;console.log(` ${k.Ay.cyan(r)}: ${p}`)}}),function(e){return n.apply(this,arguments)}))}),function(e,t,a){return Ct.apply(this,arguments)})),lt(Ot.command("generator-cache").description("Show generator cache entries")).action((kt=b(function*(e){var t;yield dt(e,(t=b(function*(t){yield t.send("IndexedDB.enable");var a=(yield t.send("IndexedDB.requestData",{securityOrigin:"bricks://app",databaseName:"GENERATOR_CACHE",objectStoreName:"entries",indexName:"",skipCount:0,pageSize:100})).objectStoreDataEntries;if(e.json)console.log(JSON.stringify(a,null,2));else for(var n of(console.log(k.Ay.bold(`Generator Cache (${a.length} entries)`)),console.log("─".repeat(60)),a)){var i=JSON.stringify(n.key?.value??n.key),o=JSON.stringify(n.value?.value??n.value),r=o.length>100?o.substring(0,100)+"...":o;console.log(` ${k.Ay.cyan(i)}: ${r}`)}}),function(e){return t.apply(this,arguments)}))}),function(e){return kt.apply(this,arguments)}));var $t,jt,Rt=mt.command("runtime").description("Runtime and evaluation");lt(Rt.command("eval <expression>").description("Evaluate JavaScript expression").option("--await","Await promise result")).action(($t=b(function*(e,t){var a;yield dt(t,(a=b(function*(a){yield a.send("Runtime.enable");var n=yield a.send("Runtime.evaluate",{expression:e,objectGroup:"console",returnByValue:!0,awaitPromise:!!t.await,generatePreview:!0});if(t.json)console.log(JSON.stringify(n,null,2));else{n.exceptionDetails&&(console.error(k.Ay.red(`Error: ${n.exceptionDetails.text}`)),n.exceptionDetails.exception?.description&&console.error(k.Ay.red(n.exceptionDetails.exception.description)),process.exit(1));var i=n.result;if("undefined"===i.type)console.log(k.Ay.gray("undefined"));else if(void 0!==i.value){var o="object"==typeof i.value?JSON.stringify(i.value,null,2):String(i.value);console.log(o)}else i.description?console.log(i.description):console.log(k.Ay.gray(`[${i.type}${i.subtype?`:${i.subtype}`:""}]`))}}),function(e){return a.apply(this,arguments)}))}),function(e,t){return $t.apply(this,arguments)})),lt(Rt.command("properties <objectId>").description("Get properties of a remote object")).action((jt=b(function*(e,t){var a;yield dt(t,(a=b(function*(a){var n=(yield a.send("Runtime.getProperties",{objectId:e,ownProperties:!0})).result;if(t.json)console.log(JSON.stringify(n,null,2));else for(var i of(console.log(k.Ay.bold(`Properties of ${e}`)),n))if(i.enumerable){var o=i.value,r=o?.description||o?.value?.toString()||k.Ay.gray(`[${o?.type}]`);console.log(` ${k.Ay.cyan(i.name)}: ${r}`)}}),function(e){return a.apply(this,arguments)}))}),function(e,t){return jt.apply(this,arguments)}));var Vt=y(69278),Pt=y(70857),Bt=process.env.BRICKS_PROJECT_DESKTOP_DATA_DIR||Ee.join(Pt.homedir(),".bricks-project-desktop"),Lt=Ee.join(Bt,"acp.sock"),Mt=new O("desktop-acp-bridge").description("ACP bridge — connects acpx to the running CTOR desktop app").action(()=>{var e=Vt.connect(Lt);e.on("connect",()=>{process.stdin.pipe(e),e.pipe(process.stdout)}),e.on("error",e=>{"ENOENT"===e.code||"ECONNREFUSED"===e.code?process.stderr.write(`[acp] Cannot connect to CTOR.\n Make sure the desktop app is running and ACP is enabled in Settings.\n Socket: ${Lt}\n`):process.stderr.write(`[acp] Connection error: ${e.message}\n`),process.exit(1)}),e.on("close",()=>{process.exit(0)})}),Ut=y(77146);function qt(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:t}})}return qt=function(e){this.s=e,this.n=e.next},qt.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var a=this.s.return;return void 0===a?Promise.resolve({value:e,done:!0}):t(a.apply(this.s,arguments))},throw:function(e){var a=this.s.return;return void 0===a?Promise.reject(e):t(a.apply(this.s,arguments))}},new qt(e)}var zt=()=>{var e=(0,I.getCurrentProfile)(),t=(0,I.getToken)(e);return t||(console.error(k.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,Ut.W)((0,I.getActivityLogBaseUrl)(),t)},Gt=2592e6,Yt=e=>new Date(e).toISOString().replace("T"," ").replace(/\.\d+Z$/,"Z"),Qt=(e,t)=>{if(!e)return"";var a="string"==typeof e?e:JSON.stringify(e);return a.length>t?a.slice(0,t-1)+"…":a},Jt=new O("activity-log").alias("al").description("Activity log queries (read-only)");Jt.command("events").description("Query activity log events (all types)").requiredOption("--start-time <datetime>","Start time (ISO 8601 or relative: 1h, 30m, 2d)").option("--end-time <datetime>","End time (default: now)").option("--device <id>","Filter by device ID").option("--type <type>","Filter by event type: general, data, local_sync").option("--event-name <name>","Filter by event name").option("--subspace <id>","Filter by subspace ID").option("--sender <id>","Filter by sender").option("--limit <n>","Max events to display",parseInt).option("-j, --json","Output as JSON array").option("--jsonl","Output as JSONL (one JSON per line)").action(function(){var e=b(function*(e){var t=zt(),a=(e=>{var t=oe(e.startTime),a=e.endTime?oe(e.endTime):(new Date).toISOString();new Date(a)-new Date(t)>Gt&&(console.error(k.Ay.red("Time range must be 30 days or less")),process.exit(1));var n={start_time:t,end_time:a};return e.device&&(n.device_id=e.device),e.type&&(n.event_type=e.type),e.eventName&&(n.event_name=e.eventName),e.subspace&&(n.subspace_id=e.subspace),e.sender&&(n.sender=e.sender),n})(e);if(e.jsonl){var n=0;try{var i,o=!1,r=!1;try{for(var s,p=function(e){var t,a,n,i=2;for("undefined"!=typeof Symbol&&(a=Symbol.asyncIterator,n=Symbol.iterator);i--;){if(a&&null!=(t=e[a]))return t.call(e);if(n&&null!=(t=e[n]))return new qt(t.call(e));a="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}(t.events(a));o=!(s=yield p.next()).done;o=!1){var l=s.value;if(console.log(JSON.stringify(l)),n++,e.limit&&n>=e.limit)break}}catch(e){r=!0,i=e}finally{try{o&&null!=p.return&&(yield p.return())}finally{if(r)throw i}}}catch(e){console.error(k.Ay.red(`Failed to query events: ${e.message}`)),process.exit(1)}}else{var d=(0,j.default)("Querying events...").start();try{var c=yield t.collectEvents(a,{limit:e.limit});if(d.stop(),e.json)return void console.log(JSON.stringify(c,null,2));if(0===c.length)return void console.log(k.Ay.yellow("No events found"));for(var u of(console.log(k.Ay.bold(`\nActivity Log Events (${c.length})`)),console.log("─".repeat(100)),console.log(k.Ay.gray(`${"Timestamp".padEnd(24)} ${"Type".padEnd(12)} ${"Device".padEnd(14)} ${"Event Name".padEnd(28)} ${"Sender".padEnd(16)} Payload`)),console.log("─".repeat(100)),c)){var m=Yt(u.timestamp),f=(u.event_type||"").padEnd(12),v=Qt(u.device_id,14).padEnd(14),h=Qt(u.event_name,28).padEnd(28),g=Qt(u.sender,16).padEnd(16),y=Qt(u.payload,40);console.log(`${m} ${f} ${v} ${h} ${g} ${k.Ay.gray(y)}`)}console.log("─".repeat(100))}catch(e){d.fail(`Failed to query events: ${e.message}`),process.exit(1)}}});return function(t){return e.apply(this,arguments)}}()),Jt.command("screenshots").description("List screenshot timestamps for a device").requiredOption("--device <id>","Device ID (required)").requiredOption("--start-time <datetime>","Start time (ISO 8601 or relative: 1h, 30m, 2d)").option("--end-time <datetime>","End time (default: now)").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){var t=zt(),a=oe(e.startTime),n=e.endTime?oe(e.endTime):(new Date).toISOString();new Date(n)-new Date(a)>Gt&&(console.error(k.Ay.red("Time range must be 30 days or less")),process.exit(1));var i={device_id:e.device,start_time:a,end_time:n},o=(0,j.default)("Querying screenshots...").start();try{var r=yield t.collectScreenshots(i);if(o.stop(),e.json)return void console.log(JSON.stringify(r,null,2));if(0===r.length)return void console.log(k.Ay.yellow("No screenshots found"));console.log(k.Ay.bold(`\nScreenshots (${r.length})`)),console.log("─".repeat(40)),console.log(k.Ay.gray(`${"#".padStart(4)} Timestamp`)),console.log("─".repeat(40)),r.forEach((e,t)=>{console.log(`${String(t+1).padStart(4)} ${Yt(e.timestamp)}`)}),console.log("─".repeat(40))}catch(e){o.fail(`Failed to query screenshots: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),Jt.command("screenshot").description("Download a screenshot image").requiredOption("--device <id>","Device ID").requiredOption("--ts <timestamp>","Screenshot timestamp (ISO 8601 or epoch ms)").option("--space <id>","Workspace/space ID (auto-detected from profile)").option("-o, --output <path>","Output file path").option("--open","Open with OS default viewer after download").action(function(){var e=b(function*(e){var t,a,n=zt(),i=e.space||(t=(0,I.getCurrentProfile)(),a=(0,I.getTokenInfo)(t),a?.workspaceId);i||(console.error(k.Ay.red("Could not determine workspace ID. Use --space <id> or log in first.")),process.exit(1));var o=/^\d+$/.test(e.ts)?e.ts:new Date(e.ts).getTime(),r=(0,j.default)("Downloading screenshot...").start();try{var s=yield n.downloadScreenshot(i,e.device,o);r.stop();var p=e.output||`screenshot-${e.device}-${o}.jpg`,l=Ee.resolve(p);_e.writeFileSync(l,s);var d=(s.length/1024).toFixed(1);if(console.log(k.Ay.green(`✓ Screenshot saved: ${l} (${d} KB)`)),e.open)(0,(yield Promise.resolve().then(y.t.bind(y,35317,19))).exec)(`${"darwin"===process.platform?"open":"win32"===process.platform?"start":"xdg-open"} "${l}"`)}catch(e){r.fail(`Failed to download screenshot: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}());var Ht=function(){var e=b(function*(){try{return yield Promise.all([y.e(428),y.e(300),y.e(425),y.e(737)]).then(y.bind(y,18737)),{available:!0}}catch(e){return{available:!1,error:e.message}}});return function(){return e.apply(this,arguments)}}(),Wt=(e,t,a)=>({severity:e,code:t,message:a}),Kt=function(){var e=b(function*({version:e="2.24.1-beta.3",mcpCheck:t=Ht}={}){var a=(0,I.getCurrentProfile)(),n=(0,I.getCurrentProfileSource)(),i=(0,I.getTokenInfo)(a),o=(0,I.getBaseUrl)(),r=(0,I.getActivityLogBaseUrl)(),s=[],p={ok:!1,timestamp:(new Date).toISOString(),cli:{name:"bricks",version:e},profile:{name:a,source:n},config:{path:I.CONFIG_PATH,baseUrl:o,activityLogBaseUrl:r},auth:{available:Boolean(i?.token),source:i?.token?"config":"missing",workspaceId:i?.workspaceId||null,workspaceName:i?.workspaceName||null,createdAt:i?.createdAt||null,tokenPreview:G(i?.token)},connectivity:{workspace:{ok:!1,skipped:!i?.token,error:null}},capabilities:{zeroArgMode:$()?"interactive":"help",mcp:{available:!1,error:null}},issues:s};if(i?.token)try{var l=yield(0,U.createClient)(o,i.token).workspace();p.connectivity.workspace={ok:!0,skipped:!1,error:null,id:l?._id||i.workspaceId||null,name:l?.name||i.workspaceName||null},p.auth.workspaceId=l?._id||p.auth.workspaceId,p.auth.workspaceName=l?.name||p.auth.workspaceName}catch(e){p.connectivity.workspace={ok:!1,skipped:!1,error:e.message},s.push(Wt("error","workspace_unreachable",`Workspace query failed for ${o}: ${e.message}`))}else s.push(Wt("warning","auth_missing","No saved token for the current profile."));var d=yield t();return p.capabilities.mcp={available:d.available,error:d.error||null},d.available||s.push(Wt("warning","mcp_unavailable",`MCP stdio server is unavailable: ${d.error||"Unknown error"}`)),p.ok=0===s.length,p});return function(){return e.apply(this,arguments)}}(),Xt=(e,t,a)=>`${e.padEnd(14)} ${t}${a?` ${a}`:""}`,Zt=new O("doctor").description("Check CLI configuration, auth state, and workspace reachability").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){try{var t=yield Kt();if(e.json)return void q(t);console.log((e=>{var t=[];if(t.push("BRICKS CLI Doctor"),t.push("─".repeat(60)),t.push(Xt("CLI","OK",`bricks v${e.cli.version}`)),t.push(Xt("Profile","OK",`${e.profile.name} (${e.profile.source})`)),t.push(Xt("BRICKS API","OK",e.config.baseUrl)),t.push(Xt("Activity Log","OK",e.config.activityLogBaseUrl)),e.auth.available){var a=e.auth.workspaceName||e.auth.workspaceId||"Unknown workspace";t.push(Xt("Auth","OK",`${a} (${e.auth.source}, ${e.auth.tokenPreview})`))}else t.push(Xt("Auth","WARN","No saved token for the current profile"));if(e.connectivity.workspace.skipped)t.push(Xt("Workspace","WARN","Skipped because no token is available"));else if(e.connectivity.workspace.ok){var n=e.connectivity.workspace.name||e.connectivity.workspace.id||"Unknown workspace";t.push(Xt("Workspace","OK",n))}else t.push(Xt("Workspace","FAIL",e.connectivity.workspace.error));return e.capabilities.mcp.available?t.push(Xt("MCP","OK","STDIO server import is available")):t.push(Xt("MCP","WARN",e.capabilities.mcp.error)),t.push(Xt("Zero-arg mode",((e,t=!1)=>e?"OK":t?"WARN":"FAIL")("interactive"===e.capabilities.zeroArgMode,"help"===e.capabilities.zeroArgMode),"interactive"===e.capabilities.zeroArgMode?"Starts Ink interactive mode on TTY":"Shows help outside TTY contexts")),e.issues.length>0&&(t.push("─".repeat(60)),t.push("Issues"),e.issues.forEach(e=>{t.push(`- [${e.severity}] ${e.message}`)})),t.join("\n")})(t))}catch(t){e.json?z(t.message):console.error(`Doctor failed: ${t.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),ea=function(){var e=b(function*(){var e=process.argv.findIndex(e=>"--auth-profile"===e||"-ap"===e);-1!==e&&process.argv[e+1]&&((0,I.setProfileOverride)(process.argv[e+1]),process.argv.splice(e,2)),x.name("bricks").description("BRICKS CLI - Command-line interface for BRICKS Workspace API").version("2.24.1-beta.3").enablePositionalOptions(),x.addCommand(Q),x.addCommand(be),x.addCommand(Oe),x.addCommand(Ce),x.addCommand(Ve),x.addCommand(ze),x.addCommand(Xe),x.addCommand(Ze),x.addCommand(mt),x.addCommand(Mt),x.addCommand(Jt),x.addCommand(Zt),x.command("interactive").alias("i").description("Start interactive mode with Ink UI").action(b(function*(){try{var e=(yield Promise.all([y.e(63),y.e(779)]).then(y.bind(y,18779))).runInteractiveMode;yield e()}catch(e){console.error(k.Ay.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}})),x.command("workspace").alias("ws").description("Show current workspace information").option("-j, --json","Output as JSON").action(function(){var e=b(function*(e){var t=yield Promise.resolve().then(y.bind(y,74752)),a=t.getToken,n=t.getBaseUrl,i=t.getCurrentProfile,o=(yield Promise.resolve().then(y.bind(y,50700))).createClient,r=(yield Promise.resolve().then(y.bind(y,29790))).default,s=a(i());s||(console.error(k.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1));var p=r("Fetching workspace info...").start();try{var l=o(n(),s),d=yield l.workspace();if(p.stop(),e.json)return void console.log(JSON.stringify(d,null,2));console.log(k.Ay.bold("\nWorkspace Information")),console.log("─".repeat(60)),console.log(`Name: ${k.Ay.green(d.name)}`),console.log(`ID: ${k.Ay.gray(d._id)}`),console.log(`Description: ${d.description||k.Ay.gray("N/A")}`),console.log(`\n${k.Ay.bold("Data")}`),console.log(`Remote Update: ${d.bank?.enable_remote_update?k.Ay.green("Enabled"):k.Ay.gray("Disabled")}`),console.log(`Spacename: ${d.bank?.spacename||k.Ay.gray("N/A")}`),console.log("─".repeat(60))}catch(e){p.fail(`Failed to get workspace: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),x.on("--help",()=>{console.log(""),console.log(k.Ay.bold("Examples:")),console.log(""),console.log(k.Ay.gray(" # Login with a one-time passcode (recommended)")),console.log(" $ bricks auth login <passcode>"),console.log(""),console.log(k.Ay.gray(" # List all devices")),console.log(" $ bricks device list"),console.log(""),console.log(k.Ay.gray(" # Monitor devices in real-time")),console.log(" $ bricks device monitor"),console.log(""),console.log(k.Ay.gray(" # Control a device")),console.log(" $ bricks device refresh <device-id>"),console.log(" $ bricks device control <device-id> clear-cache"),console.log(""),console.log(k.Ay.gray(" # Bind a new device")),console.log(' $ bricks device bind <passcode> -n "My Device"'),console.log(""),console.log(k.Ay.gray(" # List applications")),console.log(" $ bricks app list"),console.log(""),console.log(k.Ay.gray(" # Start interactive mode")),console.log(" $ bricks interactive"),console.log(""),console.log(k.Ay.gray(" # Change API endpoint")),console.log(" $ bricks config endpoint beta"),console.log(""),console.log(k.Ay.gray("Get workspace token from BRICKS Controller:")),console.log(k.Ay.cyan(" https://control.bricks.tools")),console.log(k.Ay.gray(" Go to Workspace Settings > API Token"))});var t=process.argv.slice(2);if(0===t.length){if(((e=[])=>0===e.length&&$())(t))try{var a=(yield Promise.all([y.e(63),y.e(779)]).then(y.bind(y,18779))).runInteractiveMode;return void(yield a())}catch(e){console.error(k.Ay.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}return console.error(k.Ay.gray("No command provided. Interactive mode requires a TTY, so showing help instead.\n")),void x.outputHelp()}yield x.parseAsync(process.argv)});return function(){return e.apply(this,arguments)}}();const ta=ea;export{ta as default,ea as run};
|