ocx 2.0.8 → 2.0.9

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.
Files changed (2) hide show
  1. package/dist/index.js +66 -66
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,63 +1,63 @@
1
1
  #!/usr/bin/env -S bun --no-env-file
2
2
  // @bun
3
- var KW=Object.create;var{getPrototypeOf:WW,defineProperty:F7,getOwnPropertyNames:zW}=Object;var BW=Object.prototype.hasOwnProperty;var B5=(Q,$,Y)=>{Y=Q!=null?KW(WW(Q)):{};let q=$||!Q||!Q.__esModule?F7(Y,"default",{value:Q,enumerable:!0}):Y;for(let J of zW(Q))if(!BW.call(q,J))F7(q,J,{get:()=>Q[J],enumerable:!0});return q};var L8=(Q,$)=>()=>($||Q(($={exports:{}}).exports,$),$.exports);var F8=(Q,$)=>{for(var Y in $)F7(Q,Y,{get:$[Y],enumerable:!0,configurable:!0,set:(q)=>$[Y]=()=>q})};var A=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var z9=import.meta.require;function s9(Q,$=!1){let Y=Q.length,q=0,J="",X=0,H=16,G=0,K=0,W=0,z=0,B=0;function Z(N,x){let w=0,b=0;while(w<N||!x){let D=Q.charCodeAt(q);if(D>=48&&D<=57)b=b*16+D-48;else if(D>=65&&D<=70)b=b*16+D-65+10;else if(D>=97&&D<=102)b=b*16+D-97+10;else break;q++,w++}if(w<N)b=-1;return b}function M(N){q=N,J="",X=0,H=16,B=0}function V(){let N=q;if(Q.charCodeAt(q)===48)q++;else{q++;while(q<Q.length&&B9(Q.charCodeAt(q)))q++}if(q<Q.length&&Q.charCodeAt(q)===46)if(q++,q<Q.length&&B9(Q.charCodeAt(q))){q++;while(q<Q.length&&B9(Q.charCodeAt(q)))q++}else return B=3,Q.substring(N,q);let x=q;if(q<Q.length&&(Q.charCodeAt(q)===69||Q.charCodeAt(q)===101)){if(q++,q<Q.length&&Q.charCodeAt(q)===43||Q.charCodeAt(q)===45)q++;if(q<Q.length&&B9(Q.charCodeAt(q))){q++;while(q<Q.length&&B9(Q.charCodeAt(q)))q++;x=q}else B=3}return Q.substring(N,x)}function U(){let N="",x=q;while(!0){if(q>=Y){N+=Q.substring(x,q),B=2;break}let w=Q.charCodeAt(q);if(w===34){N+=Q.substring(x,q),q++;break}if(w===92){if(N+=Q.substring(x,q),q++,q>=Y){B=2;break}switch(Q.charCodeAt(q++)){case 34:N+='"';break;case 92:N+="\\";break;case 47:N+="/";break;case 98:N+="\b";break;case 102:N+="\f";break;case 110:N+=`
4
- `;break;case 114:N+="\r";break;case 116:N+="\t";break;case 117:let D=Z(4,!0);if(D>=0)N+=String.fromCharCode(D);else B=4;break;default:B=5}x=q;continue}if(w>=0&&w<=31)if(o9(w)){N+=Q.substring(x,q),B=2;break}else B=6;q++}return N}function R(){if(J="",B=0,X=q,K=G,z=W,q>=Y)return X=Y,H=17;let N=Q.charCodeAt(q);if(j7(N)){do q++,J+=String.fromCharCode(N),N=Q.charCodeAt(q);while(j7(N));return H=15}if(o9(N)){if(q++,J+=String.fromCharCode(N),N===13&&Q.charCodeAt(q)===10)q++,J+=`
5
- `;return G++,W=q,H=14}switch(N){case 123:return q++,H=1;case 125:return q++,H=2;case 91:return q++,H=3;case 93:return q++,H=4;case 58:return q++,H=6;case 44:return q++,H=5;case 34:return q++,J=U(),H=10;case 47:let x=q-1;if(Q.charCodeAt(q+1)===47){q+=2;while(q<Y){if(o9(Q.charCodeAt(q)))break;q++}return J=Q.substring(x,q),H=12}if(Q.charCodeAt(q+1)===42){q+=2;let w=Y-1,b=!1;while(q<w){let D=Q.charCodeAt(q);if(D===42&&Q.charCodeAt(q+1)===47){q+=2,b=!0;break}if(q++,o9(D)){if(D===13&&Q.charCodeAt(q)===10)q++;G++,W=q}}if(!b)q++,B=1;return J=Q.substring(x,q),H=13}return J+=String.fromCharCode(N),q++,H=16;case 45:if(J+=String.fromCharCode(N),q++,q===Y||!B9(Q.charCodeAt(q)))return H=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return J+=V(),H=11;default:while(q<Y&&I(N))q++,N=Q.charCodeAt(q);if(X!==q){switch(J=Q.substring(X,q),J){case"true":return H=8;case"false":return H=9;case"null":return H=7}return H=16}return J+=String.fromCharCode(N),q++,H=16}}function I(N){if(j7(N)||o9(N))return!1;switch(N){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function c(){let N;do N=R();while(N>=12&&N<=15);return N}return{setPosition:M,getPosition:()=>q,scan:$?c:R,getToken:()=>H,getTokenValue:()=>J,getTokenOffset:()=>X,getTokenLength:()=>q-X,getTokenStartLine:()=>K,getTokenStartCharacter:()=>X-z,getTokenError:()=>B}}function j7(Q){return Q===32||Q===9}function o9(Q){return Q===10||Q===13}function B9(Q){return Q>=48&&Q<=57}var _5;var u2=A(()=>{(function(Q){Q[Q.lineFeed=10]="lineFeed",Q[Q.carriageReturn=13]="carriageReturn",Q[Q.space=32]="space",Q[Q._0=48]="_0",Q[Q._1=49]="_1",Q[Q._2=50]="_2",Q[Q._3=51]="_3",Q[Q._4=52]="_4",Q[Q._5=53]="_5",Q[Q._6=54]="_6",Q[Q._7=55]="_7",Q[Q._8=56]="_8",Q[Q._9=57]="_9",Q[Q.a=97]="a",Q[Q.b=98]="b",Q[Q.c=99]="c",Q[Q.d=100]="d",Q[Q.e=101]="e",Q[Q.f=102]="f",Q[Q.g=103]="g",Q[Q.h=104]="h",Q[Q.i=105]="i",Q[Q.j=106]="j",Q[Q.k=107]="k",Q[Q.l=108]="l",Q[Q.m=109]="m",Q[Q.n=110]="n",Q[Q.o=111]="o",Q[Q.p=112]="p",Q[Q.q=113]="q",Q[Q.r=114]="r",Q[Q.s=115]="s",Q[Q.t=116]="t",Q[Q.u=117]="u",Q[Q.v=118]="v",Q[Q.w=119]="w",Q[Q.x=120]="x",Q[Q.y=121]="y",Q[Q.z=122]="z",Q[Q.A=65]="A",Q[Q.B=66]="B",Q[Q.C=67]="C",Q[Q.D=68]="D",Q[Q.E=69]="E",Q[Q.F=70]="F",Q[Q.G=71]="G",Q[Q.H=72]="H",Q[Q.I=73]="I",Q[Q.J=74]="J",Q[Q.K=75]="K",Q[Q.L=76]="L",Q[Q.M=77]="M",Q[Q.N=78]="N",Q[Q.O=79]="O",Q[Q.P=80]="P",Q[Q.Q=81]="Q",Q[Q.R=82]="R",Q[Q.S=83]="S",Q[Q.T=84]="T",Q[Q.U=85]="U",Q[Q.V=86]="V",Q[Q.W=87]="W",Q[Q.X=88]="X",Q[Q.Y=89]="Y",Q[Q.Z=90]="Z",Q[Q.asterisk=42]="asterisk",Q[Q.backslash=92]="backslash",Q[Q.closeBrace=125]="closeBrace",Q[Q.closeBracket=93]="closeBracket",Q[Q.colon=58]="colon",Q[Q.comma=44]="comma",Q[Q.dot=46]="dot",Q[Q.doubleQuote=34]="doubleQuote",Q[Q.minus=45]="minus",Q[Q.openBrace=123]="openBrace",Q[Q.openBracket=91]="openBracket",Q[Q.plus=43]="plus",Q[Q.slash=47]="slash",Q[Q.formFeed=12]="formFeed",Q[Q.tab=9]="tab"})(_5||(_5={}))});var Z0,w7,Z5;var M5=A(()=>{Z0=Array(20).fill(0).map((Q,$)=>{return" ".repeat($)}),w7={" ":{"\n":Array(200).fill(0).map((Q,$)=>{return`
3
+ var KW=Object.create;var{getPrototypeOf:WW,defineProperty:F7,getOwnPropertyNames:zW}=Object;var BW=Object.prototype.hasOwnProperty;var B5=(Q,$,Y)=>{Y=Q!=null?KW(WW(Q)):{};let q=$||!Q||!Q.__esModule?F7(Y,"default",{value:Q,enumerable:!0}):Y;for(let J of zW(Q))if(!BW.call(q,J))F7(q,J,{get:()=>Q[J],enumerable:!0});return q};var L8=(Q,$)=>()=>($||Q(($={exports:{}}).exports,$),$.exports);var F8=(Q,$)=>{for(var Y in $)F7(Q,Y,{get:$[Y],enumerable:!0,configurable:!0,set:(q)=>$[Y]=()=>q})};var A=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var z9=import.meta.require;function s9(Q,$=!1){let Y=Q.length,q=0,J="",X=0,H=16,G=0,K=0,W=0,z=0,B=0;function Z(T,x){let O=0,I=0;while(O<T||!x){let w=Q.charCodeAt(q);if(w>=48&&w<=57)I=I*16+w-48;else if(w>=65&&w<=70)I=I*16+w-65+10;else if(w>=97&&w<=102)I=I*16+w-97+10;else break;q++,O++}if(O<T)I=-1;return I}function M(T){q=T,J="",X=0,H=16,B=0}function V(){let T=q;if(Q.charCodeAt(q)===48)q++;else{q++;while(q<Q.length&&B9(Q.charCodeAt(q)))q++}if(q<Q.length&&Q.charCodeAt(q)===46)if(q++,q<Q.length&&B9(Q.charCodeAt(q))){q++;while(q<Q.length&&B9(Q.charCodeAt(q)))q++}else return B=3,Q.substring(T,q);let x=q;if(q<Q.length&&(Q.charCodeAt(q)===69||Q.charCodeAt(q)===101)){if(q++,q<Q.length&&Q.charCodeAt(q)===43||Q.charCodeAt(q)===45)q++;if(q<Q.length&&B9(Q.charCodeAt(q))){q++;while(q<Q.length&&B9(Q.charCodeAt(q)))q++;x=q}else B=3}return Q.substring(T,x)}function U(){let T="",x=q;while(!0){if(q>=Y){T+=Q.substring(x,q),B=2;break}let O=Q.charCodeAt(q);if(O===34){T+=Q.substring(x,q),q++;break}if(O===92){if(T+=Q.substring(x,q),q++,q>=Y){B=2;break}switch(Q.charCodeAt(q++)){case 34:T+='"';break;case 92:T+="\\";break;case 47:T+="/";break;case 98:T+="\b";break;case 102:T+="\f";break;case 110:T+=`
4
+ `;break;case 114:T+="\r";break;case 116:T+="\t";break;case 117:let w=Z(4,!0);if(w>=0)T+=String.fromCharCode(w);else B=4;break;default:B=5}x=q;continue}if(O>=0&&O<=31)if(o9(O)){T+=Q.substring(x,q),B=2;break}else B=6;q++}return T}function R(){if(J="",B=0,X=q,K=G,z=W,q>=Y)return X=Y,H=17;let T=Q.charCodeAt(q);if(j7(T)){do q++,J+=String.fromCharCode(T),T=Q.charCodeAt(q);while(j7(T));return H=15}if(o9(T)){if(q++,J+=String.fromCharCode(T),T===13&&Q.charCodeAt(q)===10)q++,J+=`
5
+ `;return G++,W=q,H=14}switch(T){case 123:return q++,H=1;case 125:return q++,H=2;case 91:return q++,H=3;case 93:return q++,H=4;case 58:return q++,H=6;case 44:return q++,H=5;case 34:return q++,J=U(),H=10;case 47:let x=q-1;if(Q.charCodeAt(q+1)===47){q+=2;while(q<Y){if(o9(Q.charCodeAt(q)))break;q++}return J=Q.substring(x,q),H=12}if(Q.charCodeAt(q+1)===42){q+=2;let O=Y-1,I=!1;while(q<O){let w=Q.charCodeAt(q);if(w===42&&Q.charCodeAt(q+1)===47){q+=2,I=!0;break}if(q++,o9(w)){if(w===13&&Q.charCodeAt(q)===10)q++;G++,W=q}}if(!I)q++,B=1;return J=Q.substring(x,q),H=13}return J+=String.fromCharCode(T),q++,H=16;case 45:if(J+=String.fromCharCode(T),q++,q===Y||!B9(Q.charCodeAt(q)))return H=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return J+=V(),H=11;default:while(q<Y&&N(T))q++,T=Q.charCodeAt(q);if(X!==q){switch(J=Q.substring(X,q),J){case"true":return H=8;case"false":return H=9;case"null":return H=7}return H=16}return J+=String.fromCharCode(T),q++,H=16}}function N(T){if(j7(T)||o9(T))return!1;switch(T){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function c(){let T;do T=R();while(T>=12&&T<=15);return T}return{setPosition:M,getPosition:()=>q,scan:$?c:R,getToken:()=>H,getTokenValue:()=>J,getTokenOffset:()=>X,getTokenLength:()=>q-X,getTokenStartLine:()=>K,getTokenStartCharacter:()=>X-z,getTokenError:()=>B}}function j7(Q){return Q===32||Q===9}function o9(Q){return Q===10||Q===13}function B9(Q){return Q>=48&&Q<=57}var _5;var u2=A(()=>{(function(Q){Q[Q.lineFeed=10]="lineFeed",Q[Q.carriageReturn=13]="carriageReturn",Q[Q.space=32]="space",Q[Q._0=48]="_0",Q[Q._1=49]="_1",Q[Q._2=50]="_2",Q[Q._3=51]="_3",Q[Q._4=52]="_4",Q[Q._5=53]="_5",Q[Q._6=54]="_6",Q[Q._7=55]="_7",Q[Q._8=56]="_8",Q[Q._9=57]="_9",Q[Q.a=97]="a",Q[Q.b=98]="b",Q[Q.c=99]="c",Q[Q.d=100]="d",Q[Q.e=101]="e",Q[Q.f=102]="f",Q[Q.g=103]="g",Q[Q.h=104]="h",Q[Q.i=105]="i",Q[Q.j=106]="j",Q[Q.k=107]="k",Q[Q.l=108]="l",Q[Q.m=109]="m",Q[Q.n=110]="n",Q[Q.o=111]="o",Q[Q.p=112]="p",Q[Q.q=113]="q",Q[Q.r=114]="r",Q[Q.s=115]="s",Q[Q.t=116]="t",Q[Q.u=117]="u",Q[Q.v=118]="v",Q[Q.w=119]="w",Q[Q.x=120]="x",Q[Q.y=121]="y",Q[Q.z=122]="z",Q[Q.A=65]="A",Q[Q.B=66]="B",Q[Q.C=67]="C",Q[Q.D=68]="D",Q[Q.E=69]="E",Q[Q.F=70]="F",Q[Q.G=71]="G",Q[Q.H=72]="H",Q[Q.I=73]="I",Q[Q.J=74]="J",Q[Q.K=75]="K",Q[Q.L=76]="L",Q[Q.M=77]="M",Q[Q.N=78]="N",Q[Q.O=79]="O",Q[Q.P=80]="P",Q[Q.Q=81]="Q",Q[Q.R=82]="R",Q[Q.S=83]="S",Q[Q.T=84]="T",Q[Q.U=85]="U",Q[Q.V=86]="V",Q[Q.W=87]="W",Q[Q.X=88]="X",Q[Q.Y=89]="Y",Q[Q.Z=90]="Z",Q[Q.asterisk=42]="asterisk",Q[Q.backslash=92]="backslash",Q[Q.closeBrace=125]="closeBrace",Q[Q.closeBracket=93]="closeBracket",Q[Q.colon=58]="colon",Q[Q.comma=44]="comma",Q[Q.dot=46]="dot",Q[Q.doubleQuote=34]="doubleQuote",Q[Q.minus=45]="minus",Q[Q.openBrace=123]="openBrace",Q[Q.openBracket=91]="openBracket",Q[Q.plus=43]="plus",Q[Q.slash=47]="slash",Q[Q.formFeed=12]="formFeed",Q[Q.tab=9]="tab"})(_5||(_5={}))});var M0,w7,Z5;var M5=A(()=>{M0=Array(20).fill(0).map((Q,$)=>{return" ".repeat($)}),w7={" ":{"\n":Array(200).fill(0).map((Q,$)=>{return`
6
6
  `+" ".repeat($)}),"\r":Array(200).fill(0).map((Q,$)=>{return"\r"+" ".repeat($)}),"\r\n":Array(200).fill(0).map((Q,$)=>{return`\r
7
7
  `+" ".repeat($)})},"\t":{"\n":Array(200).fill(0).map((Q,$)=>{return`
8
8
  `+"\t".repeat($)}),"\r":Array(200).fill(0).map((Q,$)=>{return"\r"+"\t".repeat($)}),"\r\n":Array(200).fill(0).map((Q,$)=>{return`\r
9
9
  `+"\t".repeat($)})}},Z5=[`
10
10
  `,"\r",`\r
11
- `]});function D7(Q,$,Y){let q,J,X,H,G;if($){H=$.offset,G=H+$.length,X=H;while(X>0&&!r9(Q,X-1))X--;let w=G;while(w<Q.length&&!r9(Q,w))w++;J=Q.substring(X,w),q=ZW(J,Y)}else J=Q,q=0,X=0,H=0,G=Q.length;let K=MW(Y,Q),W=Z5.includes(K),z=0,B=0,Z;if(Y.insertSpaces)Z=Z0[Y.tabSize||4]??_9(Z0[1],Y.tabSize||4);else Z="\t";let M=Z==="\t"?"\t":" ",V=s9(J,!1),U=!1;function R(){if(z>1)return _9(K,z)+_9(Z,q+B);let w=Z.length*(q+B);if(!W||w>w7[M][K].length)return K+_9(Z,q+B);if(w<=0)return K;return w7[M][K][w]}function I(){let w=V.scan();z=0;while(w===15||w===14){if(w===14&&Y.keepLines)z+=1;else if(w===14)z=1;w=V.scan()}return U=w===16||V.getTokenError()!==0,w}let c=[];function N(w,b,D){if(!U&&(!$||b<G&&D>H)&&Q.substring(b,D)!==w)c.push({offset:b,length:D-b,content:w})}let x=I();if(Y.keepLines&&z>0)N(_9(K,z),0,0);if(x!==17){let w=V.getTokenOffset()+X,b=Z.length*q<20&&Y.insertSpaces?Z0[Z.length*q]:_9(Z,q);N(b,X,w)}while(x!==17){let w=V.getTokenOffset()+V.getTokenLength()+X,b=I(),D="",l=!1;while(z===0&&(b===12||b===13)){let r=V.getTokenOffset()+X;N(Z0[1],w,r),w=V.getTokenOffset()+V.getTokenLength()+X,l=b===12,D=l?R():"",b=I()}if(b===2){if(x!==1)B--;if(Y.keepLines&&z>0||!Y.keepLines&&x!==1)D=R();else if(Y.keepLines)D=Z0[1]}else if(b===4){if(x!==3)B--;if(Y.keepLines&&z>0||!Y.keepLines&&x!==3)D=R();else if(Y.keepLines)D=Z0[1]}else{switch(x){case 3:case 1:if(B++,Y.keepLines&&z>0||!Y.keepLines)D=R();else D=Z0[1];break;case 5:if(Y.keepLines&&z>0||!Y.keepLines)D=R();else D=Z0[1];break;case 12:D=R();break;case 13:if(z>0)D=R();else if(!l)D=Z0[1];break;case 6:if(Y.keepLines&&z>0)D=R();else if(!l)D=Z0[1];break;case 10:if(Y.keepLines&&z>0)D=R();else if(b===6&&!l)D="";break;case 7:case 8:case 9:case 11:case 2:case 4:if(Y.keepLines&&z>0)D=R();else if((b===12||b===13)&&!l)D=Z0[1];else if(b!==5&&b!==17)U=!0;break;case 16:U=!0;break}if(z>0&&(b===12||b===13))D=R()}if(b===17)if(Y.keepLines&&z>0)D=R();else D=Y.insertFinalNewline?K:"";let i=V.getTokenOffset()+X;N(D,w,i),x=b}return c}function _9(Q,$){let Y="";for(let q=0;q<$;q++)Y+=Q;return Y}function ZW(Q,$){let Y=0,q=0,J=$.tabSize||4;while(Y<Q.length){let X=Q.charAt(Y);if(X===Z0[1])q++;else if(X==="\t")q+=J;else break;Y++}return Math.floor(q/J)}function MW(Q,$){for(let Y=0;Y<$.length;Y++){let q=$.charAt(Y);if(q==="\r"){if(Y+1<$.length&&$.charAt(Y+1)===`
11
+ `]});function D7(Q,$,Y){let q,J,X,H,G;if($){H=$.offset,G=H+$.length,X=H;while(X>0&&!r9(Q,X-1))X--;let O=G;while(O<Q.length&&!r9(Q,O))O++;J=Q.substring(X,O),q=ZW(J,Y)}else J=Q,q=0,X=0,H=0,G=Q.length;let K=MW(Y,Q),W=Z5.includes(K),z=0,B=0,Z;if(Y.insertSpaces)Z=M0[Y.tabSize||4]??_9(M0[1],Y.tabSize||4);else Z="\t";let M=Z==="\t"?"\t":" ",V=s9(J,!1),U=!1;function R(){if(z>1)return _9(K,z)+_9(Z,q+B);let O=Z.length*(q+B);if(!W||O>w7[M][K].length)return K+_9(Z,q+B);if(O<=0)return K;return w7[M][K][O]}function N(){let O=V.scan();z=0;while(O===15||O===14){if(O===14&&Y.keepLines)z+=1;else if(O===14)z=1;O=V.scan()}return U=O===16||V.getTokenError()!==0,O}let c=[];function T(O,I,w){if(!U&&(!$||I<G&&w>H)&&Q.substring(I,w)!==O)c.push({offset:I,length:w-I,content:O})}let x=N();if(Y.keepLines&&z>0)T(_9(K,z),0,0);if(x!==17){let O=V.getTokenOffset()+X,I=Z.length*q<20&&Y.insertSpaces?M0[Z.length*q]:_9(Z,q);T(I,X,O)}while(x!==17){let O=V.getTokenOffset()+V.getTokenLength()+X,I=N(),w="",i=!1;while(z===0&&(I===12||I===13)){let r=V.getTokenOffset()+X;T(M0[1],O,r),O=V.getTokenOffset()+V.getTokenLength()+X,i=I===12,w=i?R():"",I=N()}if(I===2){if(x!==1)B--;if(Y.keepLines&&z>0||!Y.keepLines&&x!==1)w=R();else if(Y.keepLines)w=M0[1]}else if(I===4){if(x!==3)B--;if(Y.keepLines&&z>0||!Y.keepLines&&x!==3)w=R();else if(Y.keepLines)w=M0[1]}else{switch(x){case 3:case 1:if(B++,Y.keepLines&&z>0||!Y.keepLines)w=R();else w=M0[1];break;case 5:if(Y.keepLines&&z>0||!Y.keepLines)w=R();else w=M0[1];break;case 12:w=R();break;case 13:if(z>0)w=R();else if(!i)w=M0[1];break;case 6:if(Y.keepLines&&z>0)w=R();else if(!i)w=M0[1];break;case 10:if(Y.keepLines&&z>0)w=R();else if(I===6&&!i)w="";break;case 7:case 8:case 9:case 11:case 2:case 4:if(Y.keepLines&&z>0)w=R();else if((I===12||I===13)&&!i)w=M0[1];else if(I!==5&&I!==17)U=!0;break;case 16:U=!0;break}if(z>0&&(I===12||I===13))w=R()}if(I===17)if(Y.keepLines&&z>0)w=R();else w=Y.insertFinalNewline?K:"";let l=V.getTokenOffset()+X;T(w,O,l),x=I}return c}function _9(Q,$){let Y="";for(let q=0;q<$;q++)Y+=Q;return Y}function ZW(Q,$){let Y=0,q=0,J=$.tabSize||4;while(Y<Q.length){let X=Q.charAt(Y);if(X===M0[1])q++;else if(X==="\t")q+=J;else break;Y++}return Math.floor(q/J)}function MW(Q,$){for(let Y=0;Y<$.length;Y++){let q=$.charAt(Y);if(q==="\r"){if(Y+1<$.length&&$.charAt(Y+1)===`
12
12
  `)return`\r
13
13
  `;return"\r"}else if(q===`
14
14
  `)return`
15
15
  `}return Q&&Q.eol||`
16
16
  `}function r9(Q,$){return`\r
17
- `.indexOf(Q.charAt($))!==-1}var O7=A(()=>{u2();M5()});function U5(Q,$=[],Y=a9.DEFAULT){let q=null,J=[],X=[];function H(K){if(Array.isArray(J))J.push(K);else if(q!==null)J[q]=K}return N7(Q,{onObjectBegin:()=>{let K={};H(K),X.push(J),J=K,q=null},onObjectProperty:(K)=>{q=K},onObjectEnd:()=>{J=X.pop()},onArrayBegin:()=>{let K=[];H(K),X.push(J),J=K,q=null},onArrayEnd:()=>{J=X.pop()},onLiteralValue:H,onError:(K,W,z)=>{$.push({error:K,offset:W,length:z})}},Y),J[0]}function I7(Q,$=[],Y=a9.DEFAULT){let q={type:"array",offset:-1,length:-1,children:[],parent:void 0};function J(K){if(q.type==="property")q.length=K-q.offset,q=q.parent}function X(K){return q.children.push(K),K}N7(Q,{onObjectBegin:(K)=>{q=X({type:"object",offset:K,length:-1,parent:q,children:[]})},onObjectProperty:(K,W,z)=>{q=X({type:"property",offset:W,length:-1,parent:q,children:[]}),q.children.push({type:"string",value:K,offset:W,length:z,parent:q})},onObjectEnd:(K,W)=>{J(K+W),q.length=K+W-q.offset,q=q.parent,J(K+W)},onArrayBegin:(K,W)=>{q=X({type:"array",offset:K,length:-1,parent:q,children:[]})},onArrayEnd:(K,W)=>{q.length=K+W-q.offset,q=q.parent,J(K+W)},onLiteralValue:(K,W,z)=>{X({type:VW(K),offset:W,length:z,parent:q,value:K}),J(W+z)},onSeparator:(K,W,z)=>{if(q.type==="property"){if(K===":")q.colonOffset=W;else if(K===",")J(W)}},onError:(K,W,z)=>{$.push({error:K,offset:W,length:z})}},Y);let G=q.children[0];if(G)delete G.parent;return G}function m2(Q,$){if(!Q)return;let Y=Q;for(let q of $)if(typeof q==="string"){if(Y.type!=="object"||!Array.isArray(Y.children))return;let J=!1;for(let X of Y.children)if(Array.isArray(X.children)&&X.children[0].value===q&&X.children.length===2){Y=X.children[1],J=!0;break}if(!J)return}else{let J=q;if(Y.type!=="array"||J<0||!Array.isArray(Y.children)||J>=Y.children.length)return;Y=Y.children[J]}return Y}function N7(Q,$,Y=a9.DEFAULT){let q=s9(Q,!1),J=[],X=0;function H(E){return E?()=>X===0&&E(q.getTokenOffset(),q.getTokenLength(),q.getTokenStartLine(),q.getTokenStartCharacter()):()=>!0}function G(E){return E?(C)=>X===0&&E(C,q.getTokenOffset(),q.getTokenLength(),q.getTokenStartLine(),q.getTokenStartCharacter()):()=>!0}function K(E){return E?(C)=>X===0&&E(C,q.getTokenOffset(),q.getTokenLength(),q.getTokenStartLine(),q.getTokenStartCharacter(),()=>J.slice()):()=>!0}function W(E){return E?()=>{if(X>0)X++;else if(E(q.getTokenOffset(),q.getTokenLength(),q.getTokenStartLine(),q.getTokenStartCharacter(),()=>J.slice())===!1)X=1}:()=>!0}function z(E){return E?()=>{if(X>0)X--;if(X===0)E(q.getTokenOffset(),q.getTokenLength(),q.getTokenStartLine(),q.getTokenStartCharacter())}:()=>!0}let B=W($.onObjectBegin),Z=K($.onObjectProperty),M=z($.onObjectEnd),V=W($.onArrayBegin),U=z($.onArrayEnd),R=K($.onLiteralValue),I=G($.onSeparator),c=H($.onComment),N=G($.onError),x=Y&&Y.disallowComments,w=Y&&Y.allowTrailingComma;function b(){while(!0){let E=q.scan();switch(q.getTokenError()){case 4:D(14);break;case 5:D(15);break;case 3:D(13);break;case 1:if(!x)D(11);break;case 2:D(12);break;case 6:D(16);break}switch(E){case 12:case 13:if(x)D(10);else c();break;case 16:D(1);break;case 15:case 14:break;default:return E}}}function D(E,C=[],e=[]){if(N(E),C.length+e.length>0){let o=q.getToken();while(o!==17){if(C.indexOf(o)!==-1){b();break}else if(e.indexOf(o)!==-1)break;o=b()}}}function l(E){let C=q.getTokenValue();if(E)R(C);else Z(C),J.push(C);return b(),!0}function i(){switch(q.getToken()){case 11:let E=q.getTokenValue(),C=Number(E);if(isNaN(C))D(2),C=0;R(C);break;case 7:R(null);break;case 8:R(!0);break;case 9:R(!1);break;default:return!1}return b(),!0}function r(){if(q.getToken()!==10)return D(3,[],[2,5]),!1;if(l(!1),q.getToken()===6){if(I(":"),b(),!u())D(4,[],[2,5])}else D(5,[],[2,5]);return J.pop(),!0}function J1(){B(),b();let E=!1;while(q.getToken()!==2&&q.getToken()!==17){if(q.getToken()===5){if(!E)D(4,[],[]);if(I(","),b(),q.getToken()===2&&w)break}else if(E)D(6,[],[]);if(!r())D(4,[],[2,5]);E=!0}if(M(),q.getToken()!==2)D(7,[2],[]);else b();return!0}function S(){V(),b();let E=!0,C=!1;while(q.getToken()!==4&&q.getToken()!==17){if(q.getToken()===5){if(!C)D(4,[],[]);if(I(","),b(),q.getToken()===4&&w)break}else if(C)D(6,[],[]);if(E)J.push(0),E=!1;else J[J.length-1]++;if(!u())D(4,[],[4,5]);C=!0}if(U(),!E)J.pop();if(q.getToken()!==4)D(8,[4],[]);else b();return!0}function u(){switch(q.getToken()){case 3:return S();case 1:return J1();case 10:return l(!0);default:return i()}}if(b(),q.getToken()===17){if(Y.allowEmptyContent)return!0;return D(4,[],[]),!1}if(!u())return D(4,[],[]),!1;if(q.getToken()!==17)D(9,[],[]);return!0}function VW(Q){switch(typeof Q){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(!Q)return"null";else if(Array.isArray(Q))return"array";return"object"}default:return"null"}}var a9;var T7=A(()=>{u2();(function(Q){Q.DEFAULT={allowTrailingComma:!1}})(a9||(a9={}))});function V5(Q,$,Y,q){let J=$.slice(),H=I7(Q,[]),G=void 0,K=void 0;while(J.length>0)if(K=J.pop(),G=m2(H,J),G===void 0&&Y!==void 0)if(typeof K==="string")Y={[K]:Y};else Y=[Y];else break;if(!G){if(Y===void 0)throw Error("Can not delete in empty document");return h8(Q,{offset:H?H.offset:0,length:H?H.length:0,content:JSON.stringify(Y)},q)}else if(G.type==="object"&&typeof K==="string"&&Array.isArray(G.children)){let W=m2(G,[K]);if(W!==void 0)if(Y===void 0){if(!W.parent)throw Error("Malformed AST");let z=G.children.indexOf(W.parent),B,Z=W.parent.offset+W.parent.length;if(z>0){let M=G.children[z-1];B=M.offset+M.length}else if(B=G.offset+1,G.children.length>1)Z=G.children[1].offset;return h8(Q,{offset:B,length:Z-B,content:""},q)}else return h8(Q,{offset:W.offset,length:W.length,content:JSON.stringify(Y)},q);else{if(Y===void 0)return[];let z=`${JSON.stringify(K)}: ${JSON.stringify(Y)}`,B=q.getInsertionIndex?q.getInsertionIndex(G.children.map((M)=>M.children[0].value)):G.children.length,Z;if(B>0){let M=G.children[B-1];Z={offset:M.offset+M.length,length:0,content:","+z}}else if(G.children.length===0)Z={offset:G.offset+1,length:0,content:z};else Z={offset:G.offset+1,length:0,content:z+","};return h8(Q,Z,q)}}else if(G.type==="array"&&typeof K==="number"&&Array.isArray(G.children)){let W=K;if(W===-1){let z=`${JSON.stringify(Y)}`,B;if(G.children.length===0)B={offset:G.offset+1,length:0,content:z};else{let Z=G.children[G.children.length-1];B={offset:Z.offset+Z.length,length:0,content:","+z}}return h8(Q,B,q)}else if(Y===void 0&&G.children.length>=0){let z=K,B=G.children[z],Z;if(G.children.length===1)Z={offset:G.offset+1,length:G.length-2,content:""};else if(G.children.length-1===z){let M=G.children[z-1],V=M.offset+M.length,U=G.offset+G.length;Z={offset:V,length:U-2-V,content:""}}else Z={offset:B.offset,length:G.children[z+1].offset-B.offset,content:""};return h8(Q,Z,q)}else if(Y!==void 0){let z,B=`${JSON.stringify(Y)}`;if(!q.isArrayInsertion&&G.children.length>K){let Z=G.children[K];z={offset:Z.offset,length:Z.length,content:B}}else if(G.children.length===0||K===0)z={offset:G.offset+1,length:0,content:G.children.length===0?B:B+","};else{let Z=K>G.children.length?G.children.length:K,M=G.children[Z-1];z={offset:M.offset+M.length,length:0,content:","+B}}return h8(Q,z,q)}else throw Error(`Can not ${Y===void 0?"remove":q.isArrayInsertion?"insert":"modify"} Array index ${W} as length is not sufficient`)}else throw Error(`Can not add ${typeof K!=="number"?"index":"property"} to parent of type ${G.type}`)}function h8(Q,$,Y){if(!Y.formattingOptions)return[$];let q=g2(Q,$),J=$.offset,X=$.offset+$.content.length;if($.length===0||$.content.length===0){while(J>0&&!r9(q,J-1))J--;while(X<q.length&&!r9(q,X))X++}let H=D7(q,{offset:J,length:X-J},{...Y.formattingOptions,keepLines:!1});for(let K=H.length-1;K>=0;K--){let W=H[K];q=g2(q,W),J=Math.min(J,W.offset),X=Math.max(X,W.offset+W.length),X+=W.content.length-W.length}let G=Q.length-(q.length-X)-J;return[{offset:J,length:G,content:q.substring(J,X)}]}function g2(Q,$){return Q.substring(0,$.offset)+$.content+Q.substring($.offset+$.length)}var A5=A(()=>{O7();T7()});function n0(Q){switch(Q){case 1:return"InvalidSymbol";case 2:return"InvalidNumberFormat";case 3:return"PropertyNameExpected";case 4:return"ValueExpected";case 5:return"ColonExpected";case 6:return"CommaExpected";case 7:return"CloseBraceExpected";case 8:return"CloseBracketExpected";case 9:return"EndOfFileExpected";case 10:return"InvalidCommentToken";case 11:return"UnexpectedEndOfComment";case 12:return"UnexpectedEndOfString";case 13:return"UnexpectedEndOfNumber";case 14:return"InvalidUnicode";case 15:return"InvalidEscapeCharacter";case 16:return"InvalidCharacter"}return"<unknown ParseErrorCode>"}function Z9(Q,$,Y,q){return V5(Q,$,Y,q)}function M9(Q,$){let Y=$.slice(0).sort((J,X)=>{let H=J.offset-X.offset;if(H===0)return J.length-X.length;return H}),q=Q.length;for(let J=Y.length-1;J>=0;J--){let X=Y[J];if(X.offset+X.length<=q)Q=g2(Q,X);else throw Error("Overlapping edit");q=X.offset}return Q}var L5,F5,O1,j5;var D0=A(()=>{O7();A5();u2();T7();(function(Q){Q[Q.None=0]="None",Q[Q.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",Q[Q.UnexpectedEndOfString=2]="UnexpectedEndOfString",Q[Q.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",Q[Q.InvalidUnicode=4]="InvalidUnicode",Q[Q.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",Q[Q.InvalidCharacter=6]="InvalidCharacter"})(L5||(L5={}));(function(Q){Q[Q.OpenBraceToken=1]="OpenBraceToken",Q[Q.CloseBraceToken=2]="CloseBraceToken",Q[Q.OpenBracketToken=3]="OpenBracketToken",Q[Q.CloseBracketToken=4]="CloseBracketToken",Q[Q.CommaToken=5]="CommaToken",Q[Q.ColonToken=6]="ColonToken",Q[Q.NullKeyword=7]="NullKeyword",Q[Q.TrueKeyword=8]="TrueKeyword",Q[Q.FalseKeyword=9]="FalseKeyword",Q[Q.StringLiteral=10]="StringLiteral",Q[Q.NumericLiteral=11]="NumericLiteral",Q[Q.LineCommentTrivia=12]="LineCommentTrivia",Q[Q.BlockCommentTrivia=13]="BlockCommentTrivia",Q[Q.LineBreakTrivia=14]="LineBreakTrivia",Q[Q.Trivia=15]="Trivia",Q[Q.Unknown=16]="Unknown",Q[Q.EOF=17]="EOF"})(F5||(F5={}));O1=U5;(function(Q){Q[Q.InvalidSymbol=1]="InvalidSymbol",Q[Q.InvalidNumberFormat=2]="InvalidNumberFormat",Q[Q.PropertyNameExpected=3]="PropertyNameExpected",Q[Q.ValueExpected=4]="ValueExpected",Q[Q.ColonExpected=5]="ColonExpected",Q[Q.CommaExpected=6]="CommaExpected",Q[Q.CloseBraceExpected=7]="CloseBraceExpected",Q[Q.CloseBracketExpected=8]="CloseBracketExpected",Q[Q.EndOfFileExpected=9]="EndOfFileExpected",Q[Q.InvalidCommentToken=10]="InvalidCommentToken",Q[Q.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",Q[Q.UnexpectedEndOfString=12]="UnexpectedEndOfString",Q[Q.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",Q[Q.InvalidUnicode=14]="InvalidUnicode",Q[Q.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",Q[Q.InvalidCharacter=16]="InvalidCharacter"})(j5||(j5={}))});function j(Q,$,Y){function q(G,K){if(!G._zod)Object.defineProperty(G,"_zod",{value:{def:K,constr:H,traits:new Set},enumerable:!1});if(G._zod.traits.has(Q))return;G._zod.traits.add(Q),$(G,K);let W=H.prototype,z=Object.keys(W);for(let B=0;B<z.length;B++){let Z=z[B];if(!(Z in G))G[Z]=W[Z].bind(G)}}let J=Y?.Parent??Object;class X extends J{}Object.defineProperty(X,"name",{value:Q});function H(G){var K;let W=Y?.Parent?new X:this;q(W,G),(K=W._zod).deferred??(K.deferred=[]);for(let z of W._zod.deferred)z();return W}return Object.defineProperty(H,"init",{value:q}),Object.defineProperty(H,Symbol.hasInstance,{value:(G)=>{if(Y?.Parent&&G instanceof Y.Parent)return!0;return G?._zod?.traits?.has(Q)}}),Object.defineProperty(H,"name",{value:Q}),H}function O0(Q){if(Q)Object.assign(c2,Q);return c2}var WF,zF,Y8,t9,c2;var U9=A(()=>{WF=Object.freeze({status:"aborted"});zF=Symbol("zod_brand");Y8=class Y8 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};t9=class t9 extends Error{constructor(Q){super(`Encountered unidirectional transform during encode: ${Q}`);this.name="ZodEncodeError"}};c2={}});var z1={};F8(z1,{unwrapMessage:()=>e9,uint8ArrayToHex:()=>dW,uint8ArrayToBase64url:()=>gW,uint8ArrayToBase64:()=>b5,stringifyPrimitive:()=>i2,slugify:()=>S7,shallowClone:()=>D5,safeExtend:()=>CW,required:()=>fW,randomString:()=>RW,propertyKeyTypes:()=>k7,promiseAllObject:()=>bW,primitiveTypes:()=>O5,prefixIssues:()=>X8,pick:()=>vW,partial:()=>hW,parsedType:()=>x7,optionalKeys:()=>v7,omit:()=>PW,objectClone:()=>IW,numKeys:()=>SW,nullish:()=>Y2,normalizeParams:()=>d,mergeDefs:()=>q8,merge:()=>yW,jsonStringifyReplacer:()=>A9,joinValues:()=>d2,issue:()=>L9,isPlainObject:()=>w8,isObject:()=>V9,hexToUint8Array:()=>cW,getSizableOrigin:()=>N5,getParsedType:()=>EW,getLengthableOrigin:()=>J2,getEnumValues:()=>Q2,getElementAtPath:()=>TW,floatSafeRemainder:()=>R7,finalizeIssue:()=>x0,extend:()=>xW,escapeRegex:()=>J8,esc:()=>p2,defineLazy:()=>U1,createTransparentProxy:()=>kW,cloneDef:()=>NW,clone:()=>P0,cleanRegex:()=>q2,cleanEnum:()=>uW,captureStackTrace:()=>l2,cached:()=>$2,base64urlToUint8Array:()=>mW,base64ToUint8Array:()=>T5,assignProp:()=>j8,assertNotEqual:()=>jW,assertNever:()=>DW,assertIs:()=>wW,assertEqual:()=>FW,assert:()=>OW,allowsEval:()=>E7,aborted:()=>D8,NUMBER_FORMAT_RANGES:()=>P7,Class:()=>R5,BIGINT_FORMAT_RANGES:()=>I5});function FW(Q){return Q}function jW(Q){return Q}function wW(Q){}function DW(Q){throw Error("Unexpected value in exhaustive check")}function OW(Q){}function Q2(Q){let $=Object.values(Q).filter((q)=>typeof q==="number");return Object.entries(Q).filter(([q,J])=>$.indexOf(+q)===-1).map(([q,J])=>J)}function d2(Q,$="|"){return Q.map((Y)=>i2(Y)).join($)}function A9(Q,$){if(typeof $==="bigint")return $.toString();return $}function $2(Q){return{get value(){{let Y=Q();return Object.defineProperty(this,"value",{value:Y}),Y}throw Error("cached value already set")}}}function Y2(Q){return Q===null||Q===void 0}function q2(Q){let $=Q.startsWith("^")?1:0,Y=Q.endsWith("$")?Q.length-1:Q.length;return Q.slice($,Y)}function R7(Q,$){let Y=(Q.toString().split(".")[1]||"").length,q=$.toString(),J=(q.split(".")[1]||"").length;if(J===0&&/\d?e-\d?/.test(q)){let K=q.match(/\d?e-(\d?)/);if(K?.[1])J=Number.parseInt(K[1])}let X=Y>J?Y:J,H=Number.parseInt(Q.toFixed(X).replace(".","")),G=Number.parseInt($.toFixed(X).replace(".",""));return H%G/10**X}function U1(Q,$,Y){let q=void 0;Object.defineProperty(Q,$,{get(){if(q===w5)return;if(q===void 0)q=w5,q=Y();return q},set(J){Object.defineProperty(Q,$,{value:J})},configurable:!0})}function IW(Q){return Object.create(Object.getPrototypeOf(Q),Object.getOwnPropertyDescriptors(Q))}function j8(Q,$,Y){Object.defineProperty(Q,$,{value:Y,writable:!0,enumerable:!0,configurable:!0})}function q8(...Q){let $={};for(let Y of Q){let q=Object.getOwnPropertyDescriptors(Y);Object.assign($,q)}return Object.defineProperties({},$)}function NW(Q){return q8(Q._zod.def)}function TW(Q,$){if(!$)return Q;return $.reduce((Y,q)=>Y?.[q],Q)}function bW(Q){let $=Object.keys(Q),Y=$.map((q)=>Q[q]);return Promise.all(Y).then((q)=>{let J={};for(let X=0;X<$.length;X++)J[$[X]]=q[X];return J})}function RW(Q=10){let Y="";for(let q=0;q<Q;q++)Y+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return Y}function p2(Q){return JSON.stringify(Q)}function S7(Q){return Q.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function V9(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}function w8(Q){if(V9(Q)===!1)return!1;let $=Q.constructor;if($===void 0)return!0;if(typeof $!=="function")return!0;let Y=$.prototype;if(V9(Y)===!1)return!1;if(Object.prototype.hasOwnProperty.call(Y,"isPrototypeOf")===!1)return!1;return!0}function D5(Q){if(w8(Q))return{...Q};if(Array.isArray(Q))return[...Q];return Q}function SW(Q){let $=0;for(let Y in Q)if(Object.prototype.hasOwnProperty.call(Q,Y))$++;return $}function J8(Q){return Q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function P0(Q,$,Y){let q=new Q._zod.constr($??Q._zod.def);if(!$||Y?.parent)q._zod.parent=Q;return q}function d(Q){let $=Q;if(!$)return{};if(typeof $==="string")return{error:()=>$};if($?.message!==void 0){if($?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");$.error=$.message}if(delete $.message,typeof $.error==="string")return{...$,error:()=>$.error};return $}function kW(Q){let $;return new Proxy({},{get(Y,q,J){return $??($=Q()),Reflect.get($,q,J)},set(Y,q,J,X){return $??($=Q()),Reflect.set($,q,J,X)},has(Y,q){return $??($=Q()),Reflect.has($,q)},deleteProperty(Y,q){return $??($=Q()),Reflect.deleteProperty($,q)},ownKeys(Y){return $??($=Q()),Reflect.ownKeys($)},getOwnPropertyDescriptor(Y,q){return $??($=Q()),Reflect.getOwnPropertyDescriptor($,q)},defineProperty(Y,q,J){return $??($=Q()),Reflect.defineProperty($,q,J)}})}function i2(Q){if(typeof Q==="bigint")return Q.toString()+"n";if(typeof Q==="string")return`"${Q}"`;return`${Q}`}function v7(Q){return Object.keys(Q).filter(($)=>{return Q[$]._zod.optin==="optional"&&Q[$]._zod.optout==="optional"})}function vW(Q,$){let Y=Q._zod.def,q=Y.checks;if(q&&q.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let X=q8(Q._zod.def,{get shape(){let H={};for(let G in $){if(!(G in Y.shape))throw Error(`Unrecognized key: "${G}"`);if(!$[G])continue;H[G]=Y.shape[G]}return j8(this,"shape",H),H},checks:[]});return P0(Q,X)}function PW(Q,$){let Y=Q._zod.def,q=Y.checks;if(q&&q.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let X=q8(Q._zod.def,{get shape(){let H={...Q._zod.def.shape};for(let G in $){if(!(G in Y.shape))throw Error(`Unrecognized key: "${G}"`);if(!$[G])continue;delete H[G]}return j8(this,"shape",H),H},checks:[]});return P0(Q,X)}function xW(Q,$){if(!w8($))throw Error("Invalid input to extend: expected a plain object");let Y=Q._zod.def.checks;if(Y&&Y.length>0){let X=Q._zod.def.shape;for(let H in $)if(Object.getOwnPropertyDescriptor(X,H)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let J=q8(Q._zod.def,{get shape(){let X={...Q._zod.def.shape,...$};return j8(this,"shape",X),X}});return P0(Q,J)}function CW(Q,$){if(!w8($))throw Error("Invalid input to safeExtend: expected a plain object");let Y=q8(Q._zod.def,{get shape(){let q={...Q._zod.def.shape,...$};return j8(this,"shape",q),q}});return P0(Q,Y)}function yW(Q,$){let Y=q8(Q._zod.def,{get shape(){let q={...Q._zod.def.shape,...$._zod.def.shape};return j8(this,"shape",q),q},get catchall(){return $._zod.def.catchall},checks:[]});return P0(Q,Y)}function hW(Q,$,Y){let J=$._zod.def.checks;if(J&&J.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let H=q8($._zod.def,{get shape(){let G=$._zod.def.shape,K={...G};if(Y)for(let W in Y){if(!(W in G))throw Error(`Unrecognized key: "${W}"`);if(!Y[W])continue;K[W]=Q?new Q({type:"optional",innerType:G[W]}):G[W]}else for(let W in G)K[W]=Q?new Q({type:"optional",innerType:G[W]}):G[W];return j8(this,"shape",K),K},checks:[]});return P0($,H)}function fW(Q,$,Y){let q=q8($._zod.def,{get shape(){let J=$._zod.def.shape,X={...J};if(Y)for(let H in Y){if(!(H in X))throw Error(`Unrecognized key: "${H}"`);if(!Y[H])continue;X[H]=new Q({type:"nonoptional",innerType:J[H]})}else for(let H in J)X[H]=new Q({type:"nonoptional",innerType:J[H]});return j8(this,"shape",X),X}});return P0($,q)}function D8(Q,$=0){if(Q.aborted===!0)return!0;for(let Y=$;Y<Q.issues.length;Y++)if(Q.issues[Y]?.continue!==!0)return!0;return!1}function X8(Q,$){return $.map((Y)=>{var q;return(q=Y).path??(q.path=[]),Y.path.unshift(Q),Y})}function e9(Q){return typeof Q==="string"?Q:Q?.message}function x0(Q,$,Y){let q={...Q,path:Q.path??[]};if(!Q.message){let J=e9(Q.inst?._zod.def?.error?.(Q))??e9($?.error?.(Q))??e9(Y.customError?.(Q))??e9(Y.localeError?.(Q))??"Invalid input";q.message=J}if(delete q.inst,delete q.continue,!$?.reportInput)delete q.input;return q}function N5(Q){if(Q instanceof Set)return"set";if(Q instanceof Map)return"map";if(Q instanceof File)return"file";return"unknown"}function J2(Q){if(Array.isArray(Q))return"array";if(typeof Q==="string")return"string";return"unknown"}function x7(Q){let $=typeof Q;switch($){case"number":return Number.isNaN(Q)?"nan":"number";case"object":{if(Q===null)return"null";if(Array.isArray(Q))return"array";let Y=Q;if(Y&&Object.getPrototypeOf(Y)!==Object.prototype&&"constructor"in Y&&Y.constructor)return Y.constructor.name}}return $}function L9(...Q){let[$,Y,q]=Q;if(typeof $==="string")return{message:$,code:"custom",input:Y,inst:q};return{...$}}function uW(Q){return Object.entries(Q).filter(([$,Y])=>{return Number.isNaN(Number.parseInt($,10))}).map(($)=>$[1])}function T5(Q){let $=atob(Q),Y=new Uint8Array($.length);for(let q=0;q<$.length;q++)Y[q]=$.charCodeAt(q);return Y}function b5(Q){let $="";for(let Y=0;Y<Q.length;Y++)$+=String.fromCharCode(Q[Y]);return btoa($)}function mW(Q){let $=Q.replace(/-/g,"+").replace(/_/g,"/"),Y="=".repeat((4-$.length%4)%4);return T5($+Y)}function gW(Q){return b5(Q).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function cW(Q){let $=Q.replace(/^0x/,"");if($.length%2!==0)throw Error("Invalid hex string length");let Y=new Uint8Array($.length/2);for(let q=0;q<$.length;q+=2)Y[q/2]=Number.parseInt($.slice(q,q+2),16);return Y}function dW(Q){return Array.from(Q).map(($)=>$.toString(16).padStart(2,"0")).join("")}class R5{constructor(...Q){}}var w5,l2,E7,EW=(Q)=>{let $=typeof Q;switch($){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(Q)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(Q))return"array";if(Q===null)return"null";if(Q.then&&typeof Q.then==="function"&&Q.catch&&typeof Q.catch==="function")return"promise";if(typeof Map<"u"&&Q instanceof Map)return"map";if(typeof Set<"u"&&Q instanceof Set)return"set";if(typeof Date<"u"&&Q instanceof Date)return"date";if(typeof File<"u"&&Q instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${$}`)}},k7,O5,P7,I5;var C0=A(()=>{w5=Symbol("evaluating");l2="captureStackTrace"in Error?Error.captureStackTrace:(...Q)=>{};E7=$2(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(Q){return!1}});k7=new Set(["string","number","symbol"]),O5=new Set(["string","number","bigint","boolean","symbol","undefined"]);P7={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},I5={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]}});function E5(Q,$=(Y)=>Y.message){let Y={},q=[];for(let J of Q.issues)if(J.path.length>0)Y[J.path[0]]=Y[J.path[0]]||[],Y[J.path[0]].push($(J));else q.push($(J));return{formErrors:q,fieldErrors:Y}}function k5(Q,$=(Y)=>Y.message){let Y={_errors:[]},q=(J)=>{for(let X of J.issues)if(X.code==="invalid_union"&&X.errors.length)X.errors.map((H)=>q({issues:H}));else if(X.code==="invalid_key")q({issues:X.issues});else if(X.code==="invalid_element")q({issues:X.issues});else if(X.path.length===0)Y._errors.push($(X));else{let H=Y,G=0;while(G<X.path.length){let K=X.path[G];if(G!==X.path.length-1)H[K]=H[K]||{_errors:[]};else H[K]=H[K]||{_errors:[]},H[K]._errors.push($(X));H=H[K],G++}}};return q(Q),Y}var S5=(Q,$)=>{Q.name="$ZodError",Object.defineProperty(Q,"_zod",{value:Q._zod,enumerable:!1}),Object.defineProperty(Q,"issues",{value:$,enumerable:!1}),Q.message=JSON.stringify($,A9,2),Object.defineProperty(Q,"toString",{value:()=>Q.message,enumerable:!1})},n2,C7;var y7=A(()=>{U9();C0();n2=j("$ZodError",S5),C7=j("$ZodError",S5,{Parent:Error})});var o2=(Q)=>($,Y,q,J)=>{let X=q?Object.assign(q,{async:!1}):{async:!1},H=$._zod.run({value:Y,issues:[]},X);if(H instanceof Promise)throw new Y8;if(H.issues.length){let G=new(J?.Err??Q)(H.issues.map((K)=>x0(K,X,O0())));throw l2(G,J?.callee),G}return H.value},s2=(Q)=>async($,Y,q,J)=>{let X=q?Object.assign(q,{async:!0}):{async:!0},H=$._zod.run({value:Y,issues:[]},X);if(H instanceof Promise)H=await H;if(H.issues.length){let G=new(J?.Err??Q)(H.issues.map((K)=>x0(K,X,O0())));throw l2(G,J?.callee),G}return H.value},X2=(Q)=>($,Y,q)=>{let J=q?{...q,async:!1}:{async:!1},X=$._zod.run({value:Y,issues:[]},J);if(X instanceof Promise)throw new Y8;return X.issues.length?{success:!1,error:new(Q??n2)(X.issues.map((H)=>x0(H,J,O0())))}:{success:!0,data:X.value}},v5,H2=(Q)=>async($,Y,q)=>{let J=q?Object.assign(q,{async:!0}):{async:!0},X=$._zod.run({value:Y,issues:[]},J);if(X instanceof Promise)X=await X;return X.issues.length?{success:!1,error:new Q(X.issues.map((H)=>x0(H,J,O0())))}:{success:!0,data:X.value}},P5,x5=(Q)=>($,Y,q)=>{let J=q?Object.assign(q,{direction:"backward"}):{direction:"backward"};return o2(Q)($,Y,J)},C5=(Q)=>($,Y,q)=>{return o2(Q)($,Y,q)},y5=(Q)=>async($,Y,q)=>{let J=q?Object.assign(q,{direction:"backward"}):{direction:"backward"};return s2(Q)($,Y,J)},h5=(Q)=>async($,Y,q)=>{return s2(Q)($,Y,q)},f5=(Q)=>($,Y,q)=>{let J=q?Object.assign(q,{direction:"backward"}):{direction:"backward"};return X2(Q)($,Y,J)},u5=(Q)=>($,Y,q)=>{return X2(Q)($,Y,q)},m5=(Q)=>async($,Y,q)=>{let J=q?Object.assign(q,{direction:"backward"}):{direction:"backward"};return H2(Q)($,Y,J)},g5=(Q)=>async($,Y,q)=>{return H2(Q)($,Y,q)};var h7=A(()=>{U9();y7();C0();v5=X2(C7),P5=H2(C7)});function a5(){return new RegExp(lW,"u")}function HQ(Q){return typeof Q.precision==="number"?Q.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":Q.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${Q.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function GQ(Q){return new RegExp(`^${HQ(Q)}$`)}function KQ(Q){let $=HQ({precision:Q.precision}),Y=["Z"];if(Q.local)Y.push("");if(Q.offset)Y.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let q=`${$}(?:${Y.join("|")})`;return new RegExp(`^${JQ}T(?:${q})$`)}var c5,d5,p5,l5,i5,n5,o5,s5,f7=(Q)=>{if(!Q)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${Q}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)},r5,lW="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",t5,e5,QQ,$Q,YQ,u7,qQ,JQ="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",XQ,WQ=(Q)=>{let $=Q?`[\\s\\S]{${Q?.minimum??0},${Q?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${$}$`)},zQ,r2,BQ,_Q,ZQ;var t2=A(()=>{c5=/^[cC][^\s-]{8,}$/,d5=/^[0-9a-z]+$/,p5=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,l5=/^[0-9a-vA-V]{20}$/,i5=/^[A-Za-z0-9]{27}$/,n5=/^[a-zA-Z0-9_-]{21}$/,o5=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,s5=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,r5=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;t5=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,e5=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,QQ=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,$Q=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,YQ=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,u7=/^[A-Za-z0-9_-]*$/,qQ=/^\+[1-9]\d{6,14}$/,XQ=new RegExp(`^${JQ}$`);zQ=/^-?\d+$/,r2=/^-?\d+(?:\.\d+)?$/,BQ=/^(?:true|false)$/i,_Q=/^[^A-Z]*$/,ZQ=/^[^a-z]*$/});var s1,MQ,m7,g7,UQ,VQ,AQ,LQ,FQ,G2,jQ,wQ,DQ,OQ,IQ,NQ,TQ;var e2=A(()=>{U9();t2();C0();s1=j("$ZodCheck",(Q,$)=>{var Y;Q._zod??(Q._zod={}),Q._zod.def=$,(Y=Q._zod).onattach??(Y.onattach=[])}),MQ={number:"number",bigint:"bigint",object:"date"},m7=j("$ZodCheckLessThan",(Q,$)=>{s1.init(Q,$);let Y=MQ[typeof $.value];Q._zod.onattach.push((q)=>{let J=q._zod.bag,X=($.inclusive?J.maximum:J.exclusiveMaximum)??Number.POSITIVE_INFINITY;if($.value<X)if($.inclusive)J.maximum=$.value;else J.exclusiveMaximum=$.value}),Q._zod.check=(q)=>{if($.inclusive?q.value<=$.value:q.value<$.value)return;q.issues.push({origin:Y,code:"too_big",maximum:typeof $.value==="object"?$.value.getTime():$.value,input:q.value,inclusive:$.inclusive,inst:Q,continue:!$.abort})}}),g7=j("$ZodCheckGreaterThan",(Q,$)=>{s1.init(Q,$);let Y=MQ[typeof $.value];Q._zod.onattach.push((q)=>{let J=q._zod.bag,X=($.inclusive?J.minimum:J.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if($.value>X)if($.inclusive)J.minimum=$.value;else J.exclusiveMinimum=$.value}),Q._zod.check=(q)=>{if($.inclusive?q.value>=$.value:q.value>$.value)return;q.issues.push({origin:Y,code:"too_small",minimum:typeof $.value==="object"?$.value.getTime():$.value,input:q.value,inclusive:$.inclusive,inst:Q,continue:!$.abort})}}),UQ=j("$ZodCheckMultipleOf",(Q,$)=>{s1.init(Q,$),Q._zod.onattach.push((Y)=>{var q;(q=Y._zod.bag).multipleOf??(q.multipleOf=$.value)}),Q._zod.check=(Y)=>{if(typeof Y.value!==typeof $.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof Y.value==="bigint"?Y.value%$.value===BigInt(0):R7(Y.value,$.value)===0)return;Y.issues.push({origin:typeof Y.value,code:"not_multiple_of",divisor:$.value,input:Y.value,inst:Q,continue:!$.abort})}}),VQ=j("$ZodCheckNumberFormat",(Q,$)=>{s1.init(Q,$),$.format=$.format||"float64";let Y=$.format?.includes("int"),q=Y?"int":"number",[J,X]=P7[$.format];Q._zod.onattach.push((H)=>{let G=H._zod.bag;if(G.format=$.format,G.minimum=J,G.maximum=X,Y)G.pattern=zQ}),Q._zod.check=(H)=>{let G=H.value;if(Y){if(!Number.isInteger(G)){H.issues.push({expected:q,format:$.format,code:"invalid_type",continue:!1,input:G,inst:Q});return}if(!Number.isSafeInteger(G)){if(G>0)H.issues.push({input:G,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:Q,origin:q,inclusive:!0,continue:!$.abort});else H.issues.push({input:G,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:Q,origin:q,inclusive:!0,continue:!$.abort});return}}if(G<J)H.issues.push({origin:"number",input:G,code:"too_small",minimum:J,inclusive:!0,inst:Q,continue:!$.abort});if(G>X)H.issues.push({origin:"number",input:G,code:"too_big",maximum:X,inclusive:!0,inst:Q,continue:!$.abort})}}),AQ=j("$ZodCheckMaxLength",(Q,$)=>{var Y;s1.init(Q,$),(Y=Q._zod.def).when??(Y.when=(q)=>{let J=q.value;return!Y2(J)&&J.length!==void 0}),Q._zod.onattach.push((q)=>{let J=q._zod.bag.maximum??Number.POSITIVE_INFINITY;if($.maximum<J)q._zod.bag.maximum=$.maximum}),Q._zod.check=(q)=>{let J=q.value;if(J.length<=$.maximum)return;let H=J2(J);q.issues.push({origin:H,code:"too_big",maximum:$.maximum,inclusive:!0,input:J,inst:Q,continue:!$.abort})}}),LQ=j("$ZodCheckMinLength",(Q,$)=>{var Y;s1.init(Q,$),(Y=Q._zod.def).when??(Y.when=(q)=>{let J=q.value;return!Y2(J)&&J.length!==void 0}),Q._zod.onattach.push((q)=>{let J=q._zod.bag.minimum??Number.NEGATIVE_INFINITY;if($.minimum>J)q._zod.bag.minimum=$.minimum}),Q._zod.check=(q)=>{let J=q.value;if(J.length>=$.minimum)return;let H=J2(J);q.issues.push({origin:H,code:"too_small",minimum:$.minimum,inclusive:!0,input:J,inst:Q,continue:!$.abort})}}),FQ=j("$ZodCheckLengthEquals",(Q,$)=>{var Y;s1.init(Q,$),(Y=Q._zod.def).when??(Y.when=(q)=>{let J=q.value;return!Y2(J)&&J.length!==void 0}),Q._zod.onattach.push((q)=>{let J=q._zod.bag;J.minimum=$.length,J.maximum=$.length,J.length=$.length}),Q._zod.check=(q)=>{let J=q.value,X=J.length;if(X===$.length)return;let H=J2(J),G=X>$.length;q.issues.push({origin:H,...G?{code:"too_big",maximum:$.length}:{code:"too_small",minimum:$.length},inclusive:!0,exact:!0,input:q.value,inst:Q,continue:!$.abort})}}),G2=j("$ZodCheckStringFormat",(Q,$)=>{var Y,q;if(s1.init(Q,$),Q._zod.onattach.push((J)=>{let X=J._zod.bag;if(X.format=$.format,$.pattern)X.patterns??(X.patterns=new Set),X.patterns.add($.pattern)}),$.pattern)(Y=Q._zod).check??(Y.check=(J)=>{if($.pattern.lastIndex=0,$.pattern.test(J.value))return;J.issues.push({origin:"string",code:"invalid_format",format:$.format,input:J.value,...$.pattern?{pattern:$.pattern.toString()}:{},inst:Q,continue:!$.abort})});else(q=Q._zod).check??(q.check=()=>{})}),jQ=j("$ZodCheckRegex",(Q,$)=>{G2.init(Q,$),Q._zod.check=(Y)=>{if($.pattern.lastIndex=0,$.pattern.test(Y.value))return;Y.issues.push({origin:"string",code:"invalid_format",format:"regex",input:Y.value,pattern:$.pattern.toString(),inst:Q,continue:!$.abort})}}),wQ=j("$ZodCheckLowerCase",(Q,$)=>{$.pattern??($.pattern=_Q),G2.init(Q,$)}),DQ=j("$ZodCheckUpperCase",(Q,$)=>{$.pattern??($.pattern=ZQ),G2.init(Q,$)}),OQ=j("$ZodCheckIncludes",(Q,$)=>{s1.init(Q,$);let Y=J8($.includes),q=new RegExp(typeof $.position==="number"?`^.{${$.position}}${Y}`:Y);$.pattern=q,Q._zod.onattach.push((J)=>{let X=J._zod.bag;X.patterns??(X.patterns=new Set),X.patterns.add(q)}),Q._zod.check=(J)=>{if(J.value.includes($.includes,$.position))return;J.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:$.includes,input:J.value,inst:Q,continue:!$.abort})}}),IQ=j("$ZodCheckStartsWith",(Q,$)=>{s1.init(Q,$);let Y=new RegExp(`^${J8($.prefix)}.*`);$.pattern??($.pattern=Y),Q._zod.onattach.push((q)=>{let J=q._zod.bag;J.patterns??(J.patterns=new Set),J.patterns.add(Y)}),Q._zod.check=(q)=>{if(q.value.startsWith($.prefix))return;q.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:$.prefix,input:q.value,inst:Q,continue:!$.abort})}}),NQ=j("$ZodCheckEndsWith",(Q,$)=>{s1.init(Q,$);let Y=new RegExp(`.*${J8($.suffix)}$`);$.pattern??($.pattern=Y),Q._zod.onattach.push((q)=>{let J=q._zod.bag;J.patterns??(J.patterns=new Set),J.patterns.add(Y)}),Q._zod.check=(q)=>{if(q.value.endsWith($.suffix))return;q.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:$.suffix,input:q.value,inst:Q,continue:!$.abort})}}),TQ=j("$ZodCheckOverwrite",(Q,$)=>{s1.init(Q,$),Q._zod.check=(Y)=>{Y.value=$.tx(Y.value)}})});class c7{constructor(Q=[]){if(this.content=[],this.indent=0,this)this.args=Q}indented(Q){this.indent+=1,Q(this),this.indent-=1}write(Q){if(typeof Q==="function"){Q(this,{execution:"sync"}),Q(this,{execution:"async"});return}let Y=Q.split(`
17
+ `.indexOf(Q.charAt($))!==-1}var O7=A(()=>{u2();M5()});function U5(Q,$=[],Y=a9.DEFAULT){let q=null,J=[],X=[];function H(K){if(Array.isArray(J))J.push(K);else if(q!==null)J[q]=K}return N7(Q,{onObjectBegin:()=>{let K={};H(K),X.push(J),J=K,q=null},onObjectProperty:(K)=>{q=K},onObjectEnd:()=>{J=X.pop()},onArrayBegin:()=>{let K=[];H(K),X.push(J),J=K,q=null},onArrayEnd:()=>{J=X.pop()},onLiteralValue:H,onError:(K,W,z)=>{$.push({error:K,offset:W,length:z})}},Y),J[0]}function I7(Q,$=[],Y=a9.DEFAULT){let q={type:"array",offset:-1,length:-1,children:[],parent:void 0};function J(K){if(q.type==="property")q.length=K-q.offset,q=q.parent}function X(K){return q.children.push(K),K}N7(Q,{onObjectBegin:(K)=>{q=X({type:"object",offset:K,length:-1,parent:q,children:[]})},onObjectProperty:(K,W,z)=>{q=X({type:"property",offset:W,length:-1,parent:q,children:[]}),q.children.push({type:"string",value:K,offset:W,length:z,parent:q})},onObjectEnd:(K,W)=>{J(K+W),q.length=K+W-q.offset,q=q.parent,J(K+W)},onArrayBegin:(K,W)=>{q=X({type:"array",offset:K,length:-1,parent:q,children:[]})},onArrayEnd:(K,W)=>{q.length=K+W-q.offset,q=q.parent,J(K+W)},onLiteralValue:(K,W,z)=>{X({type:VW(K),offset:W,length:z,parent:q,value:K}),J(W+z)},onSeparator:(K,W,z)=>{if(q.type==="property"){if(K===":")q.colonOffset=W;else if(K===",")J(W)}},onError:(K,W,z)=>{$.push({error:K,offset:W,length:z})}},Y);let G=q.children[0];if(G)delete G.parent;return G}function m2(Q,$){if(!Q)return;let Y=Q;for(let q of $)if(typeof q==="string"){if(Y.type!=="object"||!Array.isArray(Y.children))return;let J=!1;for(let X of Y.children)if(Array.isArray(X.children)&&X.children[0].value===q&&X.children.length===2){Y=X.children[1],J=!0;break}if(!J)return}else{let J=q;if(Y.type!=="array"||J<0||!Array.isArray(Y.children)||J>=Y.children.length)return;Y=Y.children[J]}return Y}function N7(Q,$,Y=a9.DEFAULT){let q=s9(Q,!1),J=[],X=0;function H(E){return E?()=>X===0&&E(q.getTokenOffset(),q.getTokenLength(),q.getTokenStartLine(),q.getTokenStartCharacter()):()=>!0}function G(E){return E?(C)=>X===0&&E(C,q.getTokenOffset(),q.getTokenLength(),q.getTokenStartLine(),q.getTokenStartCharacter()):()=>!0}function K(E){return E?(C)=>X===0&&E(C,q.getTokenOffset(),q.getTokenLength(),q.getTokenStartLine(),q.getTokenStartCharacter(),()=>J.slice()):()=>!0}function W(E){return E?()=>{if(X>0)X++;else if(E(q.getTokenOffset(),q.getTokenLength(),q.getTokenStartLine(),q.getTokenStartCharacter(),()=>J.slice())===!1)X=1}:()=>!0}function z(E){return E?()=>{if(X>0)X--;if(X===0)E(q.getTokenOffset(),q.getTokenLength(),q.getTokenStartLine(),q.getTokenStartCharacter())}:()=>!0}let B=W($.onObjectBegin),Z=K($.onObjectProperty),M=z($.onObjectEnd),V=W($.onArrayBegin),U=z($.onArrayEnd),R=K($.onLiteralValue),N=G($.onSeparator),c=H($.onComment),T=G($.onError),x=Y&&Y.disallowComments,O=Y&&Y.allowTrailingComma;function I(){while(!0){let E=q.scan();switch(q.getTokenError()){case 4:w(14);break;case 5:w(15);break;case 3:w(13);break;case 1:if(!x)w(11);break;case 2:w(12);break;case 6:w(16);break}switch(E){case 12:case 13:if(x)w(10);else c();break;case 16:w(1);break;case 15:case 14:break;default:return E}}}function w(E,C=[],e=[]){if(T(E),C.length+e.length>0){let o=q.getToken();while(o!==17){if(C.indexOf(o)!==-1){I();break}else if(e.indexOf(o)!==-1)break;o=I()}}}function i(E){let C=q.getTokenValue();if(E)R(C);else Z(C),J.push(C);return I(),!0}function l(){switch(q.getToken()){case 11:let E=q.getTokenValue(),C=Number(E);if(isNaN(C))w(2),C=0;R(C);break;case 7:R(null);break;case 8:R(!0);break;case 9:R(!1);break;default:return!1}return I(),!0}function r(){if(q.getToken()!==10)return w(3,[],[2,5]),!1;if(i(!1),q.getToken()===6){if(N(":"),I(),!g())w(4,[],[2,5])}else w(5,[],[2,5]);return J.pop(),!0}function J1(){B(),I();let E=!1;while(q.getToken()!==2&&q.getToken()!==17){if(q.getToken()===5){if(!E)w(4,[],[]);if(N(","),I(),q.getToken()===2&&O)break}else if(E)w(6,[],[]);if(!r())w(4,[],[2,5]);E=!0}if(M(),q.getToken()!==2)w(7,[2],[]);else I();return!0}function S(){V(),I();let E=!0,C=!1;while(q.getToken()!==4&&q.getToken()!==17){if(q.getToken()===5){if(!C)w(4,[],[]);if(N(","),I(),q.getToken()===4&&O)break}else if(C)w(6,[],[]);if(E)J.push(0),E=!1;else J[J.length-1]++;if(!g())w(4,[],[4,5]);C=!0}if(U(),!E)J.pop();if(q.getToken()!==4)w(8,[4],[]);else I();return!0}function g(){switch(q.getToken()){case 3:return S();case 1:return J1();case 10:return i(!0);default:return l()}}if(I(),q.getToken()===17){if(Y.allowEmptyContent)return!0;return w(4,[],[]),!1}if(!g())return w(4,[],[]),!1;if(q.getToken()!==17)w(9,[],[]);return!0}function VW(Q){switch(typeof Q){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(!Q)return"null";else if(Array.isArray(Q))return"array";return"object"}default:return"null"}}var a9;var T7=A(()=>{u2();(function(Q){Q.DEFAULT={allowTrailingComma:!1}})(a9||(a9={}))});function V5(Q,$,Y,q){let J=$.slice(),H=I7(Q,[]),G=void 0,K=void 0;while(J.length>0)if(K=J.pop(),G=m2(H,J),G===void 0&&Y!==void 0)if(typeof K==="string")Y={[K]:Y};else Y=[Y];else break;if(!G){if(Y===void 0)throw Error("Can not delete in empty document");return h8(Q,{offset:H?H.offset:0,length:H?H.length:0,content:JSON.stringify(Y)},q)}else if(G.type==="object"&&typeof K==="string"&&Array.isArray(G.children)){let W=m2(G,[K]);if(W!==void 0)if(Y===void 0){if(!W.parent)throw Error("Malformed AST");let z=G.children.indexOf(W.parent),B,Z=W.parent.offset+W.parent.length;if(z>0){let M=G.children[z-1];B=M.offset+M.length}else if(B=G.offset+1,G.children.length>1)Z=G.children[1].offset;return h8(Q,{offset:B,length:Z-B,content:""},q)}else return h8(Q,{offset:W.offset,length:W.length,content:JSON.stringify(Y)},q);else{if(Y===void 0)return[];let z=`${JSON.stringify(K)}: ${JSON.stringify(Y)}`,B=q.getInsertionIndex?q.getInsertionIndex(G.children.map((M)=>M.children[0].value)):G.children.length,Z;if(B>0){let M=G.children[B-1];Z={offset:M.offset+M.length,length:0,content:","+z}}else if(G.children.length===0)Z={offset:G.offset+1,length:0,content:z};else Z={offset:G.offset+1,length:0,content:z+","};return h8(Q,Z,q)}}else if(G.type==="array"&&typeof K==="number"&&Array.isArray(G.children)){let W=K;if(W===-1){let z=`${JSON.stringify(Y)}`,B;if(G.children.length===0)B={offset:G.offset+1,length:0,content:z};else{let Z=G.children[G.children.length-1];B={offset:Z.offset+Z.length,length:0,content:","+z}}return h8(Q,B,q)}else if(Y===void 0&&G.children.length>=0){let z=K,B=G.children[z],Z;if(G.children.length===1)Z={offset:G.offset+1,length:G.length-2,content:""};else if(G.children.length-1===z){let M=G.children[z-1],V=M.offset+M.length,U=G.offset+G.length;Z={offset:V,length:U-2-V,content:""}}else Z={offset:B.offset,length:G.children[z+1].offset-B.offset,content:""};return h8(Q,Z,q)}else if(Y!==void 0){let z,B=`${JSON.stringify(Y)}`;if(!q.isArrayInsertion&&G.children.length>K){let Z=G.children[K];z={offset:Z.offset,length:Z.length,content:B}}else if(G.children.length===0||K===0)z={offset:G.offset+1,length:0,content:G.children.length===0?B:B+","};else{let Z=K>G.children.length?G.children.length:K,M=G.children[Z-1];z={offset:M.offset+M.length,length:0,content:","+B}}return h8(Q,z,q)}else throw Error(`Can not ${Y===void 0?"remove":q.isArrayInsertion?"insert":"modify"} Array index ${W} as length is not sufficient`)}else throw Error(`Can not add ${typeof K!=="number"?"index":"property"} to parent of type ${G.type}`)}function h8(Q,$,Y){if(!Y.formattingOptions)return[$];let q=g2(Q,$),J=$.offset,X=$.offset+$.content.length;if($.length===0||$.content.length===0){while(J>0&&!r9(q,J-1))J--;while(X<q.length&&!r9(q,X))X++}let H=D7(q,{offset:J,length:X-J},{...Y.formattingOptions,keepLines:!1});for(let K=H.length-1;K>=0;K--){let W=H[K];q=g2(q,W),J=Math.min(J,W.offset),X=Math.max(X,W.offset+W.length),X+=W.content.length-W.length}let G=Q.length-(q.length-X)-J;return[{offset:J,length:G,content:q.substring(J,X)}]}function g2(Q,$){return Q.substring(0,$.offset)+$.content+Q.substring($.offset+$.length)}var A5=A(()=>{O7();T7()});function n0(Q){switch(Q){case 1:return"InvalidSymbol";case 2:return"InvalidNumberFormat";case 3:return"PropertyNameExpected";case 4:return"ValueExpected";case 5:return"ColonExpected";case 6:return"CommaExpected";case 7:return"CloseBraceExpected";case 8:return"CloseBracketExpected";case 9:return"EndOfFileExpected";case 10:return"InvalidCommentToken";case 11:return"UnexpectedEndOfComment";case 12:return"UnexpectedEndOfString";case 13:return"UnexpectedEndOfNumber";case 14:return"InvalidUnicode";case 15:return"InvalidEscapeCharacter";case 16:return"InvalidCharacter"}return"<unknown ParseErrorCode>"}function Z9(Q,$,Y,q){return V5(Q,$,Y,q)}function M9(Q,$){let Y=$.slice(0).sort((J,X)=>{let H=J.offset-X.offset;if(H===0)return J.length-X.length;return H}),q=Q.length;for(let J=Y.length-1;J>=0;J--){let X=Y[J];if(X.offset+X.length<=q)Q=g2(Q,X);else throw Error("Overlapping edit");q=X.offset}return Q}var L5,F5,O1,j5;var O0=A(()=>{O7();A5();u2();T7();(function(Q){Q[Q.None=0]="None",Q[Q.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",Q[Q.UnexpectedEndOfString=2]="UnexpectedEndOfString",Q[Q.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",Q[Q.InvalidUnicode=4]="InvalidUnicode",Q[Q.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",Q[Q.InvalidCharacter=6]="InvalidCharacter"})(L5||(L5={}));(function(Q){Q[Q.OpenBraceToken=1]="OpenBraceToken",Q[Q.CloseBraceToken=2]="CloseBraceToken",Q[Q.OpenBracketToken=3]="OpenBracketToken",Q[Q.CloseBracketToken=4]="CloseBracketToken",Q[Q.CommaToken=5]="CommaToken",Q[Q.ColonToken=6]="ColonToken",Q[Q.NullKeyword=7]="NullKeyword",Q[Q.TrueKeyword=8]="TrueKeyword",Q[Q.FalseKeyword=9]="FalseKeyword",Q[Q.StringLiteral=10]="StringLiteral",Q[Q.NumericLiteral=11]="NumericLiteral",Q[Q.LineCommentTrivia=12]="LineCommentTrivia",Q[Q.BlockCommentTrivia=13]="BlockCommentTrivia",Q[Q.LineBreakTrivia=14]="LineBreakTrivia",Q[Q.Trivia=15]="Trivia",Q[Q.Unknown=16]="Unknown",Q[Q.EOF=17]="EOF"})(F5||(F5={}));O1=U5;(function(Q){Q[Q.InvalidSymbol=1]="InvalidSymbol",Q[Q.InvalidNumberFormat=2]="InvalidNumberFormat",Q[Q.PropertyNameExpected=3]="PropertyNameExpected",Q[Q.ValueExpected=4]="ValueExpected",Q[Q.ColonExpected=5]="ColonExpected",Q[Q.CommaExpected=6]="CommaExpected",Q[Q.CloseBraceExpected=7]="CloseBraceExpected",Q[Q.CloseBracketExpected=8]="CloseBracketExpected",Q[Q.EndOfFileExpected=9]="EndOfFileExpected",Q[Q.InvalidCommentToken=10]="InvalidCommentToken",Q[Q.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",Q[Q.UnexpectedEndOfString=12]="UnexpectedEndOfString",Q[Q.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",Q[Q.InvalidUnicode=14]="InvalidUnicode",Q[Q.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",Q[Q.InvalidCharacter=16]="InvalidCharacter"})(j5||(j5={}))});function j(Q,$,Y){function q(G,K){if(!G._zod)Object.defineProperty(G,"_zod",{value:{def:K,constr:H,traits:new Set},enumerable:!1});if(G._zod.traits.has(Q))return;G._zod.traits.add(Q),$(G,K);let W=H.prototype,z=Object.keys(W);for(let B=0;B<z.length;B++){let Z=z[B];if(!(Z in G))G[Z]=W[Z].bind(G)}}let J=Y?.Parent??Object;class X extends J{}Object.defineProperty(X,"name",{value:Q});function H(G){var K;let W=Y?.Parent?new X:this;q(W,G),(K=W._zod).deferred??(K.deferred=[]);for(let z of W._zod.deferred)z();return W}return Object.defineProperty(H,"init",{value:q}),Object.defineProperty(H,Symbol.hasInstance,{value:(G)=>{if(Y?.Parent&&G instanceof Y.Parent)return!0;return G?._zod?.traits?.has(Q)}}),Object.defineProperty(H,"name",{value:Q}),H}function I0(Q){if(Q)Object.assign(c2,Q);return c2}var _F,ZF,Y8,t9,c2;var U9=A(()=>{_F=Object.freeze({status:"aborted"});ZF=Symbol("zod_brand");Y8=class Y8 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};t9=class t9 extends Error{constructor(Q){super(`Encountered unidirectional transform during encode: ${Q}`);this.name="ZodEncodeError"}};c2={}});var z1={};F8(z1,{unwrapMessage:()=>e9,uint8ArrayToHex:()=>dW,uint8ArrayToBase64url:()=>gW,uint8ArrayToBase64:()=>b5,stringifyPrimitive:()=>i2,slugify:()=>S7,shallowClone:()=>D5,safeExtend:()=>CW,required:()=>fW,randomString:()=>RW,propertyKeyTypes:()=>k7,promiseAllObject:()=>bW,primitiveTypes:()=>O5,prefixIssues:()=>X8,pick:()=>vW,partial:()=>hW,parsedType:()=>x7,optionalKeys:()=>v7,omit:()=>PW,objectClone:()=>IW,numKeys:()=>SW,nullish:()=>Y2,normalizeParams:()=>d,mergeDefs:()=>q8,merge:()=>yW,jsonStringifyReplacer:()=>A9,joinValues:()=>d2,issue:()=>L9,isPlainObject:()=>w8,isObject:()=>V9,hexToUint8Array:()=>cW,getSizableOrigin:()=>N5,getParsedType:()=>EW,getLengthableOrigin:()=>J2,getEnumValues:()=>Q2,getElementAtPath:()=>TW,floatSafeRemainder:()=>R7,finalizeIssue:()=>C0,extend:()=>xW,escapeRegex:()=>J8,esc:()=>p2,defineLazy:()=>U1,createTransparentProxy:()=>kW,cloneDef:()=>NW,clone:()=>x0,cleanRegex:()=>q2,cleanEnum:()=>uW,captureStackTrace:()=>l2,cached:()=>$2,base64urlToUint8Array:()=>mW,base64ToUint8Array:()=>T5,assignProp:()=>j8,assertNotEqual:()=>jW,assertNever:()=>DW,assertIs:()=>wW,assertEqual:()=>FW,assert:()=>OW,allowsEval:()=>E7,aborted:()=>D8,NUMBER_FORMAT_RANGES:()=>P7,Class:()=>R5,BIGINT_FORMAT_RANGES:()=>I5});function FW(Q){return Q}function jW(Q){return Q}function wW(Q){}function DW(Q){throw Error("Unexpected value in exhaustive check")}function OW(Q){}function Q2(Q){let $=Object.values(Q).filter((q)=>typeof q==="number");return Object.entries(Q).filter(([q,J])=>$.indexOf(+q)===-1).map(([q,J])=>J)}function d2(Q,$="|"){return Q.map((Y)=>i2(Y)).join($)}function A9(Q,$){if(typeof $==="bigint")return $.toString();return $}function $2(Q){return{get value(){{let Y=Q();return Object.defineProperty(this,"value",{value:Y}),Y}throw Error("cached value already set")}}}function Y2(Q){return Q===null||Q===void 0}function q2(Q){let $=Q.startsWith("^")?1:0,Y=Q.endsWith("$")?Q.length-1:Q.length;return Q.slice($,Y)}function R7(Q,$){let Y=(Q.toString().split(".")[1]||"").length,q=$.toString(),J=(q.split(".")[1]||"").length;if(J===0&&/\d?e-\d?/.test(q)){let K=q.match(/\d?e-(\d?)/);if(K?.[1])J=Number.parseInt(K[1])}let X=Y>J?Y:J,H=Number.parseInt(Q.toFixed(X).replace(".","")),G=Number.parseInt($.toFixed(X).replace(".",""));return H%G/10**X}function U1(Q,$,Y){let q=void 0;Object.defineProperty(Q,$,{get(){if(q===w5)return;if(q===void 0)q=w5,q=Y();return q},set(J){Object.defineProperty(Q,$,{value:J})},configurable:!0})}function IW(Q){return Object.create(Object.getPrototypeOf(Q),Object.getOwnPropertyDescriptors(Q))}function j8(Q,$,Y){Object.defineProperty(Q,$,{value:Y,writable:!0,enumerable:!0,configurable:!0})}function q8(...Q){let $={};for(let Y of Q){let q=Object.getOwnPropertyDescriptors(Y);Object.assign($,q)}return Object.defineProperties({},$)}function NW(Q){return q8(Q._zod.def)}function TW(Q,$){if(!$)return Q;return $.reduce((Y,q)=>Y?.[q],Q)}function bW(Q){let $=Object.keys(Q),Y=$.map((q)=>Q[q]);return Promise.all(Y).then((q)=>{let J={};for(let X=0;X<$.length;X++)J[$[X]]=q[X];return J})}function RW(Q=10){let Y="";for(let q=0;q<Q;q++)Y+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return Y}function p2(Q){return JSON.stringify(Q)}function S7(Q){return Q.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function V9(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}function w8(Q){if(V9(Q)===!1)return!1;let $=Q.constructor;if($===void 0)return!0;if(typeof $!=="function")return!0;let Y=$.prototype;if(V9(Y)===!1)return!1;if(Object.prototype.hasOwnProperty.call(Y,"isPrototypeOf")===!1)return!1;return!0}function D5(Q){if(w8(Q))return{...Q};if(Array.isArray(Q))return[...Q];return Q}function SW(Q){let $=0;for(let Y in Q)if(Object.prototype.hasOwnProperty.call(Q,Y))$++;return $}function J8(Q){return Q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function x0(Q,$,Y){let q=new Q._zod.constr($??Q._zod.def);if(!$||Y?.parent)q._zod.parent=Q;return q}function d(Q){let $=Q;if(!$)return{};if(typeof $==="string")return{error:()=>$};if($?.message!==void 0){if($?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");$.error=$.message}if(delete $.message,typeof $.error==="string")return{...$,error:()=>$.error};return $}function kW(Q){let $;return new Proxy({},{get(Y,q,J){return $??($=Q()),Reflect.get($,q,J)},set(Y,q,J,X){return $??($=Q()),Reflect.set($,q,J,X)},has(Y,q){return $??($=Q()),Reflect.has($,q)},deleteProperty(Y,q){return $??($=Q()),Reflect.deleteProperty($,q)},ownKeys(Y){return $??($=Q()),Reflect.ownKeys($)},getOwnPropertyDescriptor(Y,q){return $??($=Q()),Reflect.getOwnPropertyDescriptor($,q)},defineProperty(Y,q,J){return $??($=Q()),Reflect.defineProperty($,q,J)}})}function i2(Q){if(typeof Q==="bigint")return Q.toString()+"n";if(typeof Q==="string")return`"${Q}"`;return`${Q}`}function v7(Q){return Object.keys(Q).filter(($)=>{return Q[$]._zod.optin==="optional"&&Q[$]._zod.optout==="optional"})}function vW(Q,$){let Y=Q._zod.def,q=Y.checks;if(q&&q.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let X=q8(Q._zod.def,{get shape(){let H={};for(let G in $){if(!(G in Y.shape))throw Error(`Unrecognized key: "${G}"`);if(!$[G])continue;H[G]=Y.shape[G]}return j8(this,"shape",H),H},checks:[]});return x0(Q,X)}function PW(Q,$){let Y=Q._zod.def,q=Y.checks;if(q&&q.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let X=q8(Q._zod.def,{get shape(){let H={...Q._zod.def.shape};for(let G in $){if(!(G in Y.shape))throw Error(`Unrecognized key: "${G}"`);if(!$[G])continue;delete H[G]}return j8(this,"shape",H),H},checks:[]});return x0(Q,X)}function xW(Q,$){if(!w8($))throw Error("Invalid input to extend: expected a plain object");let Y=Q._zod.def.checks;if(Y&&Y.length>0){let X=Q._zod.def.shape;for(let H in $)if(Object.getOwnPropertyDescriptor(X,H)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let J=q8(Q._zod.def,{get shape(){let X={...Q._zod.def.shape,...$};return j8(this,"shape",X),X}});return x0(Q,J)}function CW(Q,$){if(!w8($))throw Error("Invalid input to safeExtend: expected a plain object");let Y=q8(Q._zod.def,{get shape(){let q={...Q._zod.def.shape,...$};return j8(this,"shape",q),q}});return x0(Q,Y)}function yW(Q,$){let Y=q8(Q._zod.def,{get shape(){let q={...Q._zod.def.shape,...$._zod.def.shape};return j8(this,"shape",q),q},get catchall(){return $._zod.def.catchall},checks:[]});return x0(Q,Y)}function hW(Q,$,Y){let J=$._zod.def.checks;if(J&&J.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let H=q8($._zod.def,{get shape(){let G=$._zod.def.shape,K={...G};if(Y)for(let W in Y){if(!(W in G))throw Error(`Unrecognized key: "${W}"`);if(!Y[W])continue;K[W]=Q?new Q({type:"optional",innerType:G[W]}):G[W]}else for(let W in G)K[W]=Q?new Q({type:"optional",innerType:G[W]}):G[W];return j8(this,"shape",K),K},checks:[]});return x0($,H)}function fW(Q,$,Y){let q=q8($._zod.def,{get shape(){let J=$._zod.def.shape,X={...J};if(Y)for(let H in Y){if(!(H in X))throw Error(`Unrecognized key: "${H}"`);if(!Y[H])continue;X[H]=new Q({type:"nonoptional",innerType:J[H]})}else for(let H in J)X[H]=new Q({type:"nonoptional",innerType:J[H]});return j8(this,"shape",X),X}});return x0($,q)}function D8(Q,$=0){if(Q.aborted===!0)return!0;for(let Y=$;Y<Q.issues.length;Y++)if(Q.issues[Y]?.continue!==!0)return!0;return!1}function X8(Q,$){return $.map((Y)=>{var q;return(q=Y).path??(q.path=[]),Y.path.unshift(Q),Y})}function e9(Q){return typeof Q==="string"?Q:Q?.message}function C0(Q,$,Y){let q={...Q,path:Q.path??[]};if(!Q.message){let J=e9(Q.inst?._zod.def?.error?.(Q))??e9($?.error?.(Q))??e9(Y.customError?.(Q))??e9(Y.localeError?.(Q))??"Invalid input";q.message=J}if(delete q.inst,delete q.continue,!$?.reportInput)delete q.input;return q}function N5(Q){if(Q instanceof Set)return"set";if(Q instanceof Map)return"map";if(Q instanceof File)return"file";return"unknown"}function J2(Q){if(Array.isArray(Q))return"array";if(typeof Q==="string")return"string";return"unknown"}function x7(Q){let $=typeof Q;switch($){case"number":return Number.isNaN(Q)?"nan":"number";case"object":{if(Q===null)return"null";if(Array.isArray(Q))return"array";let Y=Q;if(Y&&Object.getPrototypeOf(Y)!==Object.prototype&&"constructor"in Y&&Y.constructor)return Y.constructor.name}}return $}function L9(...Q){let[$,Y,q]=Q;if(typeof $==="string")return{message:$,code:"custom",input:Y,inst:q};return{...$}}function uW(Q){return Object.entries(Q).filter(([$,Y])=>{return Number.isNaN(Number.parseInt($,10))}).map(($)=>$[1])}function T5(Q){let $=atob(Q),Y=new Uint8Array($.length);for(let q=0;q<$.length;q++)Y[q]=$.charCodeAt(q);return Y}function b5(Q){let $="";for(let Y=0;Y<Q.length;Y++)$+=String.fromCharCode(Q[Y]);return btoa($)}function mW(Q){let $=Q.replace(/-/g,"+").replace(/_/g,"/"),Y="=".repeat((4-$.length%4)%4);return T5($+Y)}function gW(Q){return b5(Q).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function cW(Q){let $=Q.replace(/^0x/,"");if($.length%2!==0)throw Error("Invalid hex string length");let Y=new Uint8Array($.length/2);for(let q=0;q<$.length;q+=2)Y[q/2]=Number.parseInt($.slice(q,q+2),16);return Y}function dW(Q){return Array.from(Q).map(($)=>$.toString(16).padStart(2,"0")).join("")}class R5{constructor(...Q){}}var w5,l2,E7,EW=(Q)=>{let $=typeof Q;switch($){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(Q)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(Q))return"array";if(Q===null)return"null";if(Q.then&&typeof Q.then==="function"&&Q.catch&&typeof Q.catch==="function")return"promise";if(typeof Map<"u"&&Q instanceof Map)return"map";if(typeof Set<"u"&&Q instanceof Set)return"set";if(typeof Date<"u"&&Q instanceof Date)return"date";if(typeof File<"u"&&Q instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${$}`)}},k7,O5,P7,I5;var y0=A(()=>{w5=Symbol("evaluating");l2="captureStackTrace"in Error?Error.captureStackTrace:(...Q)=>{};E7=$2(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(Q){return!1}});k7=new Set(["string","number","symbol"]),O5=new Set(["string","number","bigint","boolean","symbol","undefined"]);P7={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},I5={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]}});function E5(Q,$=(Y)=>Y.message){let Y={},q=[];for(let J of Q.issues)if(J.path.length>0)Y[J.path[0]]=Y[J.path[0]]||[],Y[J.path[0]].push($(J));else q.push($(J));return{formErrors:q,fieldErrors:Y}}function k5(Q,$=(Y)=>Y.message){let Y={_errors:[]},q=(J)=>{for(let X of J.issues)if(X.code==="invalid_union"&&X.errors.length)X.errors.map((H)=>q({issues:H}));else if(X.code==="invalid_key")q({issues:X.issues});else if(X.code==="invalid_element")q({issues:X.issues});else if(X.path.length===0)Y._errors.push($(X));else{let H=Y,G=0;while(G<X.path.length){let K=X.path[G];if(G!==X.path.length-1)H[K]=H[K]||{_errors:[]};else H[K]=H[K]||{_errors:[]},H[K]._errors.push($(X));H=H[K],G++}}};return q(Q),Y}var S5=(Q,$)=>{Q.name="$ZodError",Object.defineProperty(Q,"_zod",{value:Q._zod,enumerable:!1}),Object.defineProperty(Q,"issues",{value:$,enumerable:!1}),Q.message=JSON.stringify($,A9,2),Object.defineProperty(Q,"toString",{value:()=>Q.message,enumerable:!1})},n2,C7;var y7=A(()=>{U9();y0();n2=j("$ZodError",S5),C7=j("$ZodError",S5,{Parent:Error})});var o2=(Q)=>($,Y,q,J)=>{let X=q?Object.assign(q,{async:!1}):{async:!1},H=$._zod.run({value:Y,issues:[]},X);if(H instanceof Promise)throw new Y8;if(H.issues.length){let G=new(J?.Err??Q)(H.issues.map((K)=>C0(K,X,I0())));throw l2(G,J?.callee),G}return H.value},s2=(Q)=>async($,Y,q,J)=>{let X=q?Object.assign(q,{async:!0}):{async:!0},H=$._zod.run({value:Y,issues:[]},X);if(H instanceof Promise)H=await H;if(H.issues.length){let G=new(J?.Err??Q)(H.issues.map((K)=>C0(K,X,I0())));throw l2(G,J?.callee),G}return H.value},X2=(Q)=>($,Y,q)=>{let J=q?{...q,async:!1}:{async:!1},X=$._zod.run({value:Y,issues:[]},J);if(X instanceof Promise)throw new Y8;return X.issues.length?{success:!1,error:new(Q??n2)(X.issues.map((H)=>C0(H,J,I0())))}:{success:!0,data:X.value}},v5,H2=(Q)=>async($,Y,q)=>{let J=q?Object.assign(q,{async:!0}):{async:!0},X=$._zod.run({value:Y,issues:[]},J);if(X instanceof Promise)X=await X;return X.issues.length?{success:!1,error:new Q(X.issues.map((H)=>C0(H,J,I0())))}:{success:!0,data:X.value}},P5,x5=(Q)=>($,Y,q)=>{let J=q?Object.assign(q,{direction:"backward"}):{direction:"backward"};return o2(Q)($,Y,J)},C5=(Q)=>($,Y,q)=>{return o2(Q)($,Y,q)},y5=(Q)=>async($,Y,q)=>{let J=q?Object.assign(q,{direction:"backward"}):{direction:"backward"};return s2(Q)($,Y,J)},h5=(Q)=>async($,Y,q)=>{return s2(Q)($,Y,q)},f5=(Q)=>($,Y,q)=>{let J=q?Object.assign(q,{direction:"backward"}):{direction:"backward"};return X2(Q)($,Y,J)},u5=(Q)=>($,Y,q)=>{return X2(Q)($,Y,q)},m5=(Q)=>async($,Y,q)=>{let J=q?Object.assign(q,{direction:"backward"}):{direction:"backward"};return H2(Q)($,Y,J)},g5=(Q)=>async($,Y,q)=>{return H2(Q)($,Y,q)};var h7=A(()=>{U9();y7();y0();v5=X2(C7),P5=H2(C7)});function a5(){return new RegExp(lW,"u")}function HQ(Q){return typeof Q.precision==="number"?Q.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":Q.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${Q.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function GQ(Q){return new RegExp(`^${HQ(Q)}$`)}function KQ(Q){let $=HQ({precision:Q.precision}),Y=["Z"];if(Q.local)Y.push("");if(Q.offset)Y.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let q=`${$}(?:${Y.join("|")})`;return new RegExp(`^${JQ}T(?:${q})$`)}var c5,d5,p5,l5,i5,n5,o5,s5,f7=(Q)=>{if(!Q)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${Q}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)},r5,lW="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",t5,e5,QQ,$Q,YQ,u7,qQ,JQ="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",XQ,WQ=(Q)=>{let $=Q?`[\\s\\S]{${Q?.minimum??0},${Q?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${$}$`)},zQ,r2,BQ,_Q,ZQ;var t2=A(()=>{c5=/^[cC][^\s-]{8,}$/,d5=/^[0-9a-z]+$/,p5=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,l5=/^[0-9a-vA-V]{20}$/,i5=/^[A-Za-z0-9]{27}$/,n5=/^[a-zA-Z0-9_-]{21}$/,o5=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,s5=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,r5=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;t5=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,e5=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,QQ=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,$Q=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,YQ=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,u7=/^[A-Za-z0-9_-]*$/,qQ=/^\+[1-9]\d{6,14}$/,XQ=new RegExp(`^${JQ}$`);zQ=/^-?\d+$/,r2=/^-?\d+(?:\.\d+)?$/,BQ=/^(?:true|false)$/i,_Q=/^[^A-Z]*$/,ZQ=/^[^a-z]*$/});var s1,MQ,m7,g7,UQ,VQ,AQ,LQ,FQ,G2,jQ,wQ,DQ,OQ,IQ,NQ,TQ;var e2=A(()=>{U9();t2();y0();s1=j("$ZodCheck",(Q,$)=>{var Y;Q._zod??(Q._zod={}),Q._zod.def=$,(Y=Q._zod).onattach??(Y.onattach=[])}),MQ={number:"number",bigint:"bigint",object:"date"},m7=j("$ZodCheckLessThan",(Q,$)=>{s1.init(Q,$);let Y=MQ[typeof $.value];Q._zod.onattach.push((q)=>{let J=q._zod.bag,X=($.inclusive?J.maximum:J.exclusiveMaximum)??Number.POSITIVE_INFINITY;if($.value<X)if($.inclusive)J.maximum=$.value;else J.exclusiveMaximum=$.value}),Q._zod.check=(q)=>{if($.inclusive?q.value<=$.value:q.value<$.value)return;q.issues.push({origin:Y,code:"too_big",maximum:typeof $.value==="object"?$.value.getTime():$.value,input:q.value,inclusive:$.inclusive,inst:Q,continue:!$.abort})}}),g7=j("$ZodCheckGreaterThan",(Q,$)=>{s1.init(Q,$);let Y=MQ[typeof $.value];Q._zod.onattach.push((q)=>{let J=q._zod.bag,X=($.inclusive?J.minimum:J.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if($.value>X)if($.inclusive)J.minimum=$.value;else J.exclusiveMinimum=$.value}),Q._zod.check=(q)=>{if($.inclusive?q.value>=$.value:q.value>$.value)return;q.issues.push({origin:Y,code:"too_small",minimum:typeof $.value==="object"?$.value.getTime():$.value,input:q.value,inclusive:$.inclusive,inst:Q,continue:!$.abort})}}),UQ=j("$ZodCheckMultipleOf",(Q,$)=>{s1.init(Q,$),Q._zod.onattach.push((Y)=>{var q;(q=Y._zod.bag).multipleOf??(q.multipleOf=$.value)}),Q._zod.check=(Y)=>{if(typeof Y.value!==typeof $.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof Y.value==="bigint"?Y.value%$.value===BigInt(0):R7(Y.value,$.value)===0)return;Y.issues.push({origin:typeof Y.value,code:"not_multiple_of",divisor:$.value,input:Y.value,inst:Q,continue:!$.abort})}}),VQ=j("$ZodCheckNumberFormat",(Q,$)=>{s1.init(Q,$),$.format=$.format||"float64";let Y=$.format?.includes("int"),q=Y?"int":"number",[J,X]=P7[$.format];Q._zod.onattach.push((H)=>{let G=H._zod.bag;if(G.format=$.format,G.minimum=J,G.maximum=X,Y)G.pattern=zQ}),Q._zod.check=(H)=>{let G=H.value;if(Y){if(!Number.isInteger(G)){H.issues.push({expected:q,format:$.format,code:"invalid_type",continue:!1,input:G,inst:Q});return}if(!Number.isSafeInteger(G)){if(G>0)H.issues.push({input:G,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:Q,origin:q,inclusive:!0,continue:!$.abort});else H.issues.push({input:G,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:Q,origin:q,inclusive:!0,continue:!$.abort});return}}if(G<J)H.issues.push({origin:"number",input:G,code:"too_small",minimum:J,inclusive:!0,inst:Q,continue:!$.abort});if(G>X)H.issues.push({origin:"number",input:G,code:"too_big",maximum:X,inclusive:!0,inst:Q,continue:!$.abort})}}),AQ=j("$ZodCheckMaxLength",(Q,$)=>{var Y;s1.init(Q,$),(Y=Q._zod.def).when??(Y.when=(q)=>{let J=q.value;return!Y2(J)&&J.length!==void 0}),Q._zod.onattach.push((q)=>{let J=q._zod.bag.maximum??Number.POSITIVE_INFINITY;if($.maximum<J)q._zod.bag.maximum=$.maximum}),Q._zod.check=(q)=>{let J=q.value;if(J.length<=$.maximum)return;let H=J2(J);q.issues.push({origin:H,code:"too_big",maximum:$.maximum,inclusive:!0,input:J,inst:Q,continue:!$.abort})}}),LQ=j("$ZodCheckMinLength",(Q,$)=>{var Y;s1.init(Q,$),(Y=Q._zod.def).when??(Y.when=(q)=>{let J=q.value;return!Y2(J)&&J.length!==void 0}),Q._zod.onattach.push((q)=>{let J=q._zod.bag.minimum??Number.NEGATIVE_INFINITY;if($.minimum>J)q._zod.bag.minimum=$.minimum}),Q._zod.check=(q)=>{let J=q.value;if(J.length>=$.minimum)return;let H=J2(J);q.issues.push({origin:H,code:"too_small",minimum:$.minimum,inclusive:!0,input:J,inst:Q,continue:!$.abort})}}),FQ=j("$ZodCheckLengthEquals",(Q,$)=>{var Y;s1.init(Q,$),(Y=Q._zod.def).when??(Y.when=(q)=>{let J=q.value;return!Y2(J)&&J.length!==void 0}),Q._zod.onattach.push((q)=>{let J=q._zod.bag;J.minimum=$.length,J.maximum=$.length,J.length=$.length}),Q._zod.check=(q)=>{let J=q.value,X=J.length;if(X===$.length)return;let H=J2(J),G=X>$.length;q.issues.push({origin:H,...G?{code:"too_big",maximum:$.length}:{code:"too_small",minimum:$.length},inclusive:!0,exact:!0,input:q.value,inst:Q,continue:!$.abort})}}),G2=j("$ZodCheckStringFormat",(Q,$)=>{var Y,q;if(s1.init(Q,$),Q._zod.onattach.push((J)=>{let X=J._zod.bag;if(X.format=$.format,$.pattern)X.patterns??(X.patterns=new Set),X.patterns.add($.pattern)}),$.pattern)(Y=Q._zod).check??(Y.check=(J)=>{if($.pattern.lastIndex=0,$.pattern.test(J.value))return;J.issues.push({origin:"string",code:"invalid_format",format:$.format,input:J.value,...$.pattern?{pattern:$.pattern.toString()}:{},inst:Q,continue:!$.abort})});else(q=Q._zod).check??(q.check=()=>{})}),jQ=j("$ZodCheckRegex",(Q,$)=>{G2.init(Q,$),Q._zod.check=(Y)=>{if($.pattern.lastIndex=0,$.pattern.test(Y.value))return;Y.issues.push({origin:"string",code:"invalid_format",format:"regex",input:Y.value,pattern:$.pattern.toString(),inst:Q,continue:!$.abort})}}),wQ=j("$ZodCheckLowerCase",(Q,$)=>{$.pattern??($.pattern=_Q),G2.init(Q,$)}),DQ=j("$ZodCheckUpperCase",(Q,$)=>{$.pattern??($.pattern=ZQ),G2.init(Q,$)}),OQ=j("$ZodCheckIncludes",(Q,$)=>{s1.init(Q,$);let Y=J8($.includes),q=new RegExp(typeof $.position==="number"?`^.{${$.position}}${Y}`:Y);$.pattern=q,Q._zod.onattach.push((J)=>{let X=J._zod.bag;X.patterns??(X.patterns=new Set),X.patterns.add(q)}),Q._zod.check=(J)=>{if(J.value.includes($.includes,$.position))return;J.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:$.includes,input:J.value,inst:Q,continue:!$.abort})}}),IQ=j("$ZodCheckStartsWith",(Q,$)=>{s1.init(Q,$);let Y=new RegExp(`^${J8($.prefix)}.*`);$.pattern??($.pattern=Y),Q._zod.onattach.push((q)=>{let J=q._zod.bag;J.patterns??(J.patterns=new Set),J.patterns.add(Y)}),Q._zod.check=(q)=>{if(q.value.startsWith($.prefix))return;q.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:$.prefix,input:q.value,inst:Q,continue:!$.abort})}}),NQ=j("$ZodCheckEndsWith",(Q,$)=>{s1.init(Q,$);let Y=new RegExp(`.*${J8($.suffix)}$`);$.pattern??($.pattern=Y),Q._zod.onattach.push((q)=>{let J=q._zod.bag;J.patterns??(J.patterns=new Set),J.patterns.add(Y)}),Q._zod.check=(q)=>{if(q.value.endsWith($.suffix))return;q.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:$.suffix,input:q.value,inst:Q,continue:!$.abort})}}),TQ=j("$ZodCheckOverwrite",(Q,$)=>{s1.init(Q,$),Q._zod.check=(Y)=>{Y.value=$.tx(Y.value)}})});class c7{constructor(Q=[]){if(this.content=[],this.indent=0,this)this.args=Q}indented(Q){this.indent+=1,Q(this),this.indent-=1}write(Q){if(typeof Q==="function"){Q(this,{execution:"sync"}),Q(this,{execution:"async"});return}let Y=Q.split(`
18
18
  `).filter((X)=>X),q=Math.min(...Y.map((X)=>X.length-X.trimStart().length)),J=Y.map((X)=>X.slice(q)).map((X)=>" ".repeat(this.indent*2)+X);for(let X of J)this.content.push(X)}compile(){let Q=Function,$=this?.args,q=[...(this?.content??[""]).map((J)=>` ${J}`)];return new Q(...$,q.join(`
19
- `))}}var RQ;var d7=A(()=>{RQ={major:4,minor:3,patch:6}});function Y$(Q){if(Q==="")return!0;if(Q.length%4!==0)return!1;try{return atob(Q),!0}catch{return!1}}function iW(Q){if(!u7.test(Q))return!1;let $=Q.replace(/[-_]/g,(q)=>q==="-"?"+":"/"),Y=$.padEnd(Math.ceil($.length/4)*4,"=");return Y$(Y)}function nW(Q,$=null){try{let Y=Q.split(".");if(Y.length!==3)return!1;let[q]=Y;if(!q)return!1;let J=JSON.parse(atob(q));if("typ"in J&&J?.typ!=="JWT")return!1;if(!J.alg)return!1;if($&&(!("alg"in J)||J.alg!==$))return!1;return!0}catch{return!1}}function SQ(Q,$,Y){if(Q.issues.length)$.issues.push(...X8(Y,Q.issues));$.value[Y]=Q.value}function $3(Q,$,Y,q,J){if(Q.issues.length){if(J&&!(Y in q))return;$.issues.push(...X8(Y,Q.issues))}if(Q.value===void 0){if(Y in q)$.value[Y]=void 0}else $.value[Y]=Q.value}function Z$(Q){let $=Object.keys(Q.shape);for(let q of $)if(!Q.shape?.[q]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${q}": expected a Zod schema`);let Y=v7(Q.shape);return{...Q,keys:$,keySet:new Set($),numKeys:$.length,optionalKeys:new Set(Y)}}function M$(Q,$,Y,q,J,X){let H=[],G=J.keySet,K=J.catchall._zod,W=K.def.type,z=K.optout==="optional";for(let B in $){if(G.has(B))continue;if(W==="never"){H.push(B);continue}let Z=K.run({value:$[B],issues:[]},q);if(Z instanceof Promise)Q.push(Z.then((M)=>$3(M,Y,B,$,z)));else $3(Z,Y,B,$,z)}if(H.length)Y.issues.push({code:"unrecognized_keys",keys:H,input:$,inst:X});if(!Q.length)return Y;return Promise.all(Q).then(()=>{return Y})}function EQ(Q,$,Y,q){for(let X of Q)if(X.issues.length===0)return $.value=X.value,$;let J=Q.filter((X)=>!D8(X));if(J.length===1)return $.value=J[0].value,J[0];return $.issues.push({code:"invalid_union",input:$.value,inst:Y,errors:Q.map((X)=>X.issues.map((H)=>x0(H,q,O0())))}),$}function p7(Q,$){if(Q===$)return{valid:!0,data:Q};if(Q instanceof Date&&$ instanceof Date&&+Q===+$)return{valid:!0,data:Q};if(w8(Q)&&w8($)){let Y=Object.keys($),q=Object.keys(Q).filter((X)=>Y.indexOf(X)!==-1),J={...Q,...$};for(let X of q){let H=p7(Q[X],$[X]);if(!H.valid)return{valid:!1,mergeErrorPath:[X,...H.mergeErrorPath]};J[X]=H.data}return{valid:!0,data:J}}if(Array.isArray(Q)&&Array.isArray($)){if(Q.length!==$.length)return{valid:!1,mergeErrorPath:[]};let Y=[];for(let q=0;q<Q.length;q++){let J=Q[q],X=$[q],H=p7(J,X);if(!H.valid)return{valid:!1,mergeErrorPath:[q,...H.mergeErrorPath]};Y.push(H.data)}return{valid:!0,data:Y}}return{valid:!1,mergeErrorPath:[]}}function kQ(Q,$,Y){let q=new Map,J;for(let G of $.issues)if(G.code==="unrecognized_keys"){J??(J=G);for(let K of G.keys){if(!q.has(K))q.set(K,{});q.get(K).l=!0}}else Q.issues.push(G);for(let G of Y.issues)if(G.code==="unrecognized_keys")for(let K of G.keys){if(!q.has(K))q.set(K,{});q.get(K).r=!0}else Q.issues.push(G);let X=[...q].filter(([,G])=>G.l&&G.r).map(([G])=>G);if(X.length&&J)Q.issues.push({...J,keys:X});if(D8(Q))return Q;let H=p7($.value,Y.value);if(!H.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(H.mergeErrorPath)}`);return Q.value=H.data,Q}function vQ(Q,$){if(Q.issues.length&&$===void 0)return{issues:[],value:void 0};return Q}function PQ(Q,$){if(Q.value===void 0)Q.value=$.defaultValue;return Q}function xQ(Q,$){if(!Q.issues.length&&Q.value===void 0)Q.issues.push({code:"invalid_type",expected:"nonoptional",input:Q.value,inst:$});return Q}function Q3(Q,$,Y){if(Q.issues.length)return Q.aborted=!0,Q;return $._zod.run({value:Q.value,issues:Q.issues},Y)}function CQ(Q){return Q.value=Object.freeze(Q.value),Q}function yQ(Q,$,Y,q){if(!Q){let J={code:"custom",input:Y,inst:q,path:[...q._zod.def.path??[]],continue:!q._zod.def.abort};if(q._zod.def.params)J.params=q._zod.def.params;$.issues.push(L9(J))}}var T1,Y3,b1,hQ,fQ,uQ,mQ,gQ,cQ,dQ,pQ,lQ,iQ,nQ,oQ,sQ,rQ,aQ,tQ,eQ,Q$,$$,q$,J$,X$,H$,l7,G$,K$,W$,z$,B$,_$,oW,U$,V$,A$,L$,F$,j$,w$,i7,D$,O$,I$,N$,T$,b$,R$,S$,E$;var k$=A(()=>{e2();U9();h7();t2();C0();d7();C0();T1=j("$ZodType",(Q,$)=>{var Y;Q??(Q={}),Q._zod.def=$,Q._zod.bag=Q._zod.bag||{},Q._zod.version=RQ;let q=[...Q._zod.def.checks??[]];if(Q._zod.traits.has("$ZodCheck"))q.unshift(Q);for(let J of q)for(let X of J._zod.onattach)X(Q);if(q.length===0)(Y=Q._zod).deferred??(Y.deferred=[]),Q._zod.deferred?.push(()=>{Q._zod.run=Q._zod.parse});else{let J=(H,G,K)=>{let W=D8(H),z;for(let B of G){if(B._zod.def.when){if(!B._zod.def.when(H))continue}else if(W)continue;let Z=H.issues.length,M=B._zod.check(H);if(M instanceof Promise&&K?.async===!1)throw new Y8;if(z||M instanceof Promise)z=(z??Promise.resolve()).then(async()=>{if(await M,H.issues.length===Z)return;if(!W)W=D8(H,Z)});else{if(H.issues.length===Z)continue;if(!W)W=D8(H,Z)}}if(z)return z.then(()=>{return H});return H},X=(H,G,K)=>{if(D8(H))return H.aborted=!0,H;let W=J(G,q,K);if(W instanceof Promise){if(K.async===!1)throw new Y8;return W.then((z)=>Q._zod.parse(z,K))}return Q._zod.parse(W,K)};Q._zod.run=(H,G)=>{if(G.skipChecks)return Q._zod.parse(H,G);if(G.direction==="backward"){let W=Q._zod.parse({value:H.value,issues:[]},{...G,skipChecks:!0});if(W instanceof Promise)return W.then((z)=>{return X(z,H,G)});return X(W,H,G)}let K=Q._zod.parse(H,G);if(K instanceof Promise){if(G.async===!1)throw new Y8;return K.then((W)=>J(W,q,G))}return J(K,q,G)}}U1(Q,"~standard",()=>({validate:(J)=>{try{let X=v5(Q,J);return X.success?{value:X.data}:{issues:X.error?.issues}}catch(X){return P5(Q,J).then((H)=>H.success?{value:H.data}:{issues:H.error?.issues})}},vendor:"zod",version:1}))}),Y3=j("$ZodString",(Q,$)=>{T1.init(Q,$),Q._zod.pattern=[...Q?._zod.bag?.patterns??[]].pop()??WQ(Q._zod.bag),Q._zod.parse=(Y,q)=>{if($.coerce)try{Y.value=String(Y.value)}catch(J){}if(typeof Y.value==="string")return Y;return Y.issues.push({expected:"string",code:"invalid_type",input:Y.value,inst:Q}),Y}}),b1=j("$ZodStringFormat",(Q,$)=>{G2.init(Q,$),Y3.init(Q,$)}),hQ=j("$ZodGUID",(Q,$)=>{$.pattern??($.pattern=s5),b1.init(Q,$)}),fQ=j("$ZodUUID",(Q,$)=>{if($.version){let q={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[$.version];if(q===void 0)throw Error(`Invalid UUID version: "${$.version}"`);$.pattern??($.pattern=f7(q))}else $.pattern??($.pattern=f7());b1.init(Q,$)}),uQ=j("$ZodEmail",(Q,$)=>{$.pattern??($.pattern=r5),b1.init(Q,$)}),mQ=j("$ZodURL",(Q,$)=>{b1.init(Q,$),Q._zod.check=(Y)=>{try{let q=Y.value.trim(),J=new URL(q);if($.hostname){if($.hostname.lastIndex=0,!$.hostname.test(J.hostname))Y.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:$.hostname.source,input:Y.value,inst:Q,continue:!$.abort})}if($.protocol){if($.protocol.lastIndex=0,!$.protocol.test(J.protocol.endsWith(":")?J.protocol.slice(0,-1):J.protocol))Y.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:$.protocol.source,input:Y.value,inst:Q,continue:!$.abort})}if($.normalize)Y.value=J.href;else Y.value=q;return}catch(q){Y.issues.push({code:"invalid_format",format:"url",input:Y.value,inst:Q,continue:!$.abort})}}}),gQ=j("$ZodEmoji",(Q,$)=>{$.pattern??($.pattern=a5()),b1.init(Q,$)}),cQ=j("$ZodNanoID",(Q,$)=>{$.pattern??($.pattern=n5),b1.init(Q,$)}),dQ=j("$ZodCUID",(Q,$)=>{$.pattern??($.pattern=c5),b1.init(Q,$)}),pQ=j("$ZodCUID2",(Q,$)=>{$.pattern??($.pattern=d5),b1.init(Q,$)}),lQ=j("$ZodULID",(Q,$)=>{$.pattern??($.pattern=p5),b1.init(Q,$)}),iQ=j("$ZodXID",(Q,$)=>{$.pattern??($.pattern=l5),b1.init(Q,$)}),nQ=j("$ZodKSUID",(Q,$)=>{$.pattern??($.pattern=i5),b1.init(Q,$)}),oQ=j("$ZodISODateTime",(Q,$)=>{$.pattern??($.pattern=KQ($)),b1.init(Q,$)}),sQ=j("$ZodISODate",(Q,$)=>{$.pattern??($.pattern=XQ),b1.init(Q,$)}),rQ=j("$ZodISOTime",(Q,$)=>{$.pattern??($.pattern=GQ($)),b1.init(Q,$)}),aQ=j("$ZodISODuration",(Q,$)=>{$.pattern??($.pattern=o5),b1.init(Q,$)}),tQ=j("$ZodIPv4",(Q,$)=>{$.pattern??($.pattern=t5),b1.init(Q,$),Q._zod.bag.format="ipv4"}),eQ=j("$ZodIPv6",(Q,$)=>{$.pattern??($.pattern=e5),b1.init(Q,$),Q._zod.bag.format="ipv6",Q._zod.check=(Y)=>{try{new URL(`http://[${Y.value}]`)}catch{Y.issues.push({code:"invalid_format",format:"ipv6",input:Y.value,inst:Q,continue:!$.abort})}}}),Q$=j("$ZodCIDRv4",(Q,$)=>{$.pattern??($.pattern=QQ),b1.init(Q,$)}),$$=j("$ZodCIDRv6",(Q,$)=>{$.pattern??($.pattern=$Q),b1.init(Q,$),Q._zod.check=(Y)=>{let q=Y.value.split("/");try{if(q.length!==2)throw Error();let[J,X]=q;if(!X)throw Error();let H=Number(X);if(`${H}`!==X)throw Error();if(H<0||H>128)throw Error();new URL(`http://[${J}]`)}catch{Y.issues.push({code:"invalid_format",format:"cidrv6",input:Y.value,inst:Q,continue:!$.abort})}}});q$=j("$ZodBase64",(Q,$)=>{$.pattern??($.pattern=YQ),b1.init(Q,$),Q._zod.bag.contentEncoding="base64",Q._zod.check=(Y)=>{if(Y$(Y.value))return;Y.issues.push({code:"invalid_format",format:"base64",input:Y.value,inst:Q,continue:!$.abort})}});J$=j("$ZodBase64URL",(Q,$)=>{$.pattern??($.pattern=u7),b1.init(Q,$),Q._zod.bag.contentEncoding="base64url",Q._zod.check=(Y)=>{if(iW(Y.value))return;Y.issues.push({code:"invalid_format",format:"base64url",input:Y.value,inst:Q,continue:!$.abort})}}),X$=j("$ZodE164",(Q,$)=>{$.pattern??($.pattern=qQ),b1.init(Q,$)});H$=j("$ZodJWT",(Q,$)=>{b1.init(Q,$),Q._zod.check=(Y)=>{if(nW(Y.value,$.alg))return;Y.issues.push({code:"invalid_format",format:"jwt",input:Y.value,inst:Q,continue:!$.abort})}}),l7=j("$ZodNumber",(Q,$)=>{T1.init(Q,$),Q._zod.pattern=Q._zod.bag.pattern??r2,Q._zod.parse=(Y,q)=>{if($.coerce)try{Y.value=Number(Y.value)}catch(H){}let J=Y.value;if(typeof J==="number"&&!Number.isNaN(J)&&Number.isFinite(J))return Y;let X=typeof J==="number"?Number.isNaN(J)?"NaN":!Number.isFinite(J)?"Infinity":void 0:void 0;return Y.issues.push({expected:"number",code:"invalid_type",input:J,inst:Q,...X?{received:X}:{}}),Y}}),G$=j("$ZodNumberFormat",(Q,$)=>{VQ.init(Q,$),l7.init(Q,$)}),K$=j("$ZodBoolean",(Q,$)=>{T1.init(Q,$),Q._zod.pattern=BQ,Q._zod.parse=(Y,q)=>{if($.coerce)try{Y.value=Boolean(Y.value)}catch(X){}let J=Y.value;if(typeof J==="boolean")return Y;return Y.issues.push({expected:"boolean",code:"invalid_type",input:J,inst:Q}),Y}}),W$=j("$ZodAny",(Q,$)=>{T1.init(Q,$),Q._zod.parse=(Y)=>Y}),z$=j("$ZodUnknown",(Q,$)=>{T1.init(Q,$),Q._zod.parse=(Y)=>Y}),B$=j("$ZodNever",(Q,$)=>{T1.init(Q,$),Q._zod.parse=(Y,q)=>{return Y.issues.push({expected:"never",code:"invalid_type",input:Y.value,inst:Q}),Y}});_$=j("$ZodArray",(Q,$)=>{T1.init(Q,$),Q._zod.parse=(Y,q)=>{let J=Y.value;if(!Array.isArray(J))return Y.issues.push({expected:"array",code:"invalid_type",input:J,inst:Q}),Y;Y.value=Array(J.length);let X=[];for(let H=0;H<J.length;H++){let G=J[H],K=$.element._zod.run({value:G,issues:[]},q);if(K instanceof Promise)X.push(K.then((W)=>SQ(W,Y,H)));else SQ(K,Y,H)}if(X.length)return Promise.all(X).then(()=>Y);return Y}});oW=j("$ZodObject",(Q,$)=>{if(T1.init(Q,$),!Object.getOwnPropertyDescriptor($,"shape")?.get){let G=$.shape;Object.defineProperty($,"shape",{get:()=>{let K={...G};return Object.defineProperty($,"shape",{value:K}),K}})}let q=$2(()=>Z$($));U1(Q._zod,"propValues",()=>{let G=$.shape,K={};for(let W in G){let z=G[W]._zod;if(z.values){K[W]??(K[W]=new Set);for(let B of z.values)K[W].add(B)}}return K});let J=V9,X=$.catchall,H;Q._zod.parse=(G,K)=>{H??(H=q.value);let W=G.value;if(!J(W))return G.issues.push({expected:"object",code:"invalid_type",input:W,inst:Q}),G;G.value={};let z=[],B=H.shape;for(let Z of H.keys){let M=B[Z],V=M._zod.optout==="optional",U=M._zod.run({value:W[Z],issues:[]},K);if(U instanceof Promise)z.push(U.then((R)=>$3(R,G,Z,W,V)));else $3(U,G,Z,W,V)}if(!X)return z.length?Promise.all(z).then(()=>G):G;return M$(z,W,G,K,q.value,Q)}}),U$=j("$ZodObjectJIT",(Q,$)=>{oW.init(Q,$);let Y=Q._zod.parse,q=$2(()=>Z$($)),J=(Z)=>{let M=new c7(["shape","payload","ctx"]),V=q.value,U=(N)=>{let x=p2(N);return`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`};M.write("const input = payload.value;");let R=Object.create(null),I=0;for(let N of V.keys)R[N]=`key_${I++}`;M.write("const newResult = {};");for(let N of V.keys){let x=R[N],w=p2(N),D=Z[N]?._zod?.optout==="optional";if(M.write(`const ${x} = ${U(N)};`),D)M.write(`
19
+ `))}}var RQ;var d7=A(()=>{RQ={major:4,minor:3,patch:6}});function Y$(Q){if(Q==="")return!0;if(Q.length%4!==0)return!1;try{return atob(Q),!0}catch{return!1}}function iW(Q){if(!u7.test(Q))return!1;let $=Q.replace(/[-_]/g,(q)=>q==="-"?"+":"/"),Y=$.padEnd(Math.ceil($.length/4)*4,"=");return Y$(Y)}function nW(Q,$=null){try{let Y=Q.split(".");if(Y.length!==3)return!1;let[q]=Y;if(!q)return!1;let J=JSON.parse(atob(q));if("typ"in J&&J?.typ!=="JWT")return!1;if(!J.alg)return!1;if($&&(!("alg"in J)||J.alg!==$))return!1;return!0}catch{return!1}}function SQ(Q,$,Y){if(Q.issues.length)$.issues.push(...X8(Y,Q.issues));$.value[Y]=Q.value}function $3(Q,$,Y,q,J){if(Q.issues.length){if(J&&!(Y in q))return;$.issues.push(...X8(Y,Q.issues))}if(Q.value===void 0){if(Y in q)$.value[Y]=void 0}else $.value[Y]=Q.value}function Z$(Q){let $=Object.keys(Q.shape);for(let q of $)if(!Q.shape?.[q]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${q}": expected a Zod schema`);let Y=v7(Q.shape);return{...Q,keys:$,keySet:new Set($),numKeys:$.length,optionalKeys:new Set(Y)}}function M$(Q,$,Y,q,J,X){let H=[],G=J.keySet,K=J.catchall._zod,W=K.def.type,z=K.optout==="optional";for(let B in $){if(G.has(B))continue;if(W==="never"){H.push(B);continue}let Z=K.run({value:$[B],issues:[]},q);if(Z instanceof Promise)Q.push(Z.then((M)=>$3(M,Y,B,$,z)));else $3(Z,Y,B,$,z)}if(H.length)Y.issues.push({code:"unrecognized_keys",keys:H,input:$,inst:X});if(!Q.length)return Y;return Promise.all(Q).then(()=>{return Y})}function EQ(Q,$,Y,q){for(let X of Q)if(X.issues.length===0)return $.value=X.value,$;let J=Q.filter((X)=>!D8(X));if(J.length===1)return $.value=J[0].value,J[0];return $.issues.push({code:"invalid_union",input:$.value,inst:Y,errors:Q.map((X)=>X.issues.map((H)=>C0(H,q,I0())))}),$}function p7(Q,$){if(Q===$)return{valid:!0,data:Q};if(Q instanceof Date&&$ instanceof Date&&+Q===+$)return{valid:!0,data:Q};if(w8(Q)&&w8($)){let Y=Object.keys($),q=Object.keys(Q).filter((X)=>Y.indexOf(X)!==-1),J={...Q,...$};for(let X of q){let H=p7(Q[X],$[X]);if(!H.valid)return{valid:!1,mergeErrorPath:[X,...H.mergeErrorPath]};J[X]=H.data}return{valid:!0,data:J}}if(Array.isArray(Q)&&Array.isArray($)){if(Q.length!==$.length)return{valid:!1,mergeErrorPath:[]};let Y=[];for(let q=0;q<Q.length;q++){let J=Q[q],X=$[q],H=p7(J,X);if(!H.valid)return{valid:!1,mergeErrorPath:[q,...H.mergeErrorPath]};Y.push(H.data)}return{valid:!0,data:Y}}return{valid:!1,mergeErrorPath:[]}}function kQ(Q,$,Y){let q=new Map,J;for(let G of $.issues)if(G.code==="unrecognized_keys"){J??(J=G);for(let K of G.keys){if(!q.has(K))q.set(K,{});q.get(K).l=!0}}else Q.issues.push(G);for(let G of Y.issues)if(G.code==="unrecognized_keys")for(let K of G.keys){if(!q.has(K))q.set(K,{});q.get(K).r=!0}else Q.issues.push(G);let X=[...q].filter(([,G])=>G.l&&G.r).map(([G])=>G);if(X.length&&J)Q.issues.push({...J,keys:X});if(D8(Q))return Q;let H=p7($.value,Y.value);if(!H.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(H.mergeErrorPath)}`);return Q.value=H.data,Q}function vQ(Q,$){if(Q.issues.length&&$===void 0)return{issues:[],value:void 0};return Q}function PQ(Q,$){if(Q.value===void 0)Q.value=$.defaultValue;return Q}function xQ(Q,$){if(!Q.issues.length&&Q.value===void 0)Q.issues.push({code:"invalid_type",expected:"nonoptional",input:Q.value,inst:$});return Q}function Q3(Q,$,Y){if(Q.issues.length)return Q.aborted=!0,Q;return $._zod.run({value:Q.value,issues:Q.issues},Y)}function CQ(Q){return Q.value=Object.freeze(Q.value),Q}function yQ(Q,$,Y,q){if(!Q){let J={code:"custom",input:Y,inst:q,path:[...q._zod.def.path??[]],continue:!q._zod.def.abort};if(q._zod.def.params)J.params=q._zod.def.params;$.issues.push(L9(J))}}var T1,Y3,b1,hQ,fQ,uQ,mQ,gQ,cQ,dQ,pQ,lQ,iQ,nQ,oQ,sQ,rQ,aQ,tQ,eQ,Q$,$$,q$,J$,X$,H$,l7,G$,K$,W$,z$,B$,_$,oW,U$,V$,A$,L$,F$,j$,w$,i7,D$,O$,I$,N$,T$,b$,R$,S$,E$;var k$=A(()=>{e2();U9();h7();t2();y0();d7();y0();T1=j("$ZodType",(Q,$)=>{var Y;Q??(Q={}),Q._zod.def=$,Q._zod.bag=Q._zod.bag||{},Q._zod.version=RQ;let q=[...Q._zod.def.checks??[]];if(Q._zod.traits.has("$ZodCheck"))q.unshift(Q);for(let J of q)for(let X of J._zod.onattach)X(Q);if(q.length===0)(Y=Q._zod).deferred??(Y.deferred=[]),Q._zod.deferred?.push(()=>{Q._zod.run=Q._zod.parse});else{let J=(H,G,K)=>{let W=D8(H),z;for(let B of G){if(B._zod.def.when){if(!B._zod.def.when(H))continue}else if(W)continue;let Z=H.issues.length,M=B._zod.check(H);if(M instanceof Promise&&K?.async===!1)throw new Y8;if(z||M instanceof Promise)z=(z??Promise.resolve()).then(async()=>{if(await M,H.issues.length===Z)return;if(!W)W=D8(H,Z)});else{if(H.issues.length===Z)continue;if(!W)W=D8(H,Z)}}if(z)return z.then(()=>{return H});return H},X=(H,G,K)=>{if(D8(H))return H.aborted=!0,H;let W=J(G,q,K);if(W instanceof Promise){if(K.async===!1)throw new Y8;return W.then((z)=>Q._zod.parse(z,K))}return Q._zod.parse(W,K)};Q._zod.run=(H,G)=>{if(G.skipChecks)return Q._zod.parse(H,G);if(G.direction==="backward"){let W=Q._zod.parse({value:H.value,issues:[]},{...G,skipChecks:!0});if(W instanceof Promise)return W.then((z)=>{return X(z,H,G)});return X(W,H,G)}let K=Q._zod.parse(H,G);if(K instanceof Promise){if(G.async===!1)throw new Y8;return K.then((W)=>J(W,q,G))}return J(K,q,G)}}U1(Q,"~standard",()=>({validate:(J)=>{try{let X=v5(Q,J);return X.success?{value:X.data}:{issues:X.error?.issues}}catch(X){return P5(Q,J).then((H)=>H.success?{value:H.data}:{issues:H.error?.issues})}},vendor:"zod",version:1}))}),Y3=j("$ZodString",(Q,$)=>{T1.init(Q,$),Q._zod.pattern=[...Q?._zod.bag?.patterns??[]].pop()??WQ(Q._zod.bag),Q._zod.parse=(Y,q)=>{if($.coerce)try{Y.value=String(Y.value)}catch(J){}if(typeof Y.value==="string")return Y;return Y.issues.push({expected:"string",code:"invalid_type",input:Y.value,inst:Q}),Y}}),b1=j("$ZodStringFormat",(Q,$)=>{G2.init(Q,$),Y3.init(Q,$)}),hQ=j("$ZodGUID",(Q,$)=>{$.pattern??($.pattern=s5),b1.init(Q,$)}),fQ=j("$ZodUUID",(Q,$)=>{if($.version){let q={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[$.version];if(q===void 0)throw Error(`Invalid UUID version: "${$.version}"`);$.pattern??($.pattern=f7(q))}else $.pattern??($.pattern=f7());b1.init(Q,$)}),uQ=j("$ZodEmail",(Q,$)=>{$.pattern??($.pattern=r5),b1.init(Q,$)}),mQ=j("$ZodURL",(Q,$)=>{b1.init(Q,$),Q._zod.check=(Y)=>{try{let q=Y.value.trim(),J=new URL(q);if($.hostname){if($.hostname.lastIndex=0,!$.hostname.test(J.hostname))Y.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:$.hostname.source,input:Y.value,inst:Q,continue:!$.abort})}if($.protocol){if($.protocol.lastIndex=0,!$.protocol.test(J.protocol.endsWith(":")?J.protocol.slice(0,-1):J.protocol))Y.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:$.protocol.source,input:Y.value,inst:Q,continue:!$.abort})}if($.normalize)Y.value=J.href;else Y.value=q;return}catch(q){Y.issues.push({code:"invalid_format",format:"url",input:Y.value,inst:Q,continue:!$.abort})}}}),gQ=j("$ZodEmoji",(Q,$)=>{$.pattern??($.pattern=a5()),b1.init(Q,$)}),cQ=j("$ZodNanoID",(Q,$)=>{$.pattern??($.pattern=n5),b1.init(Q,$)}),dQ=j("$ZodCUID",(Q,$)=>{$.pattern??($.pattern=c5),b1.init(Q,$)}),pQ=j("$ZodCUID2",(Q,$)=>{$.pattern??($.pattern=d5),b1.init(Q,$)}),lQ=j("$ZodULID",(Q,$)=>{$.pattern??($.pattern=p5),b1.init(Q,$)}),iQ=j("$ZodXID",(Q,$)=>{$.pattern??($.pattern=l5),b1.init(Q,$)}),nQ=j("$ZodKSUID",(Q,$)=>{$.pattern??($.pattern=i5),b1.init(Q,$)}),oQ=j("$ZodISODateTime",(Q,$)=>{$.pattern??($.pattern=KQ($)),b1.init(Q,$)}),sQ=j("$ZodISODate",(Q,$)=>{$.pattern??($.pattern=XQ),b1.init(Q,$)}),rQ=j("$ZodISOTime",(Q,$)=>{$.pattern??($.pattern=GQ($)),b1.init(Q,$)}),aQ=j("$ZodISODuration",(Q,$)=>{$.pattern??($.pattern=o5),b1.init(Q,$)}),tQ=j("$ZodIPv4",(Q,$)=>{$.pattern??($.pattern=t5),b1.init(Q,$),Q._zod.bag.format="ipv4"}),eQ=j("$ZodIPv6",(Q,$)=>{$.pattern??($.pattern=e5),b1.init(Q,$),Q._zod.bag.format="ipv6",Q._zod.check=(Y)=>{try{new URL(`http://[${Y.value}]`)}catch{Y.issues.push({code:"invalid_format",format:"ipv6",input:Y.value,inst:Q,continue:!$.abort})}}}),Q$=j("$ZodCIDRv4",(Q,$)=>{$.pattern??($.pattern=QQ),b1.init(Q,$)}),$$=j("$ZodCIDRv6",(Q,$)=>{$.pattern??($.pattern=$Q),b1.init(Q,$),Q._zod.check=(Y)=>{let q=Y.value.split("/");try{if(q.length!==2)throw Error();let[J,X]=q;if(!X)throw Error();let H=Number(X);if(`${H}`!==X)throw Error();if(H<0||H>128)throw Error();new URL(`http://[${J}]`)}catch{Y.issues.push({code:"invalid_format",format:"cidrv6",input:Y.value,inst:Q,continue:!$.abort})}}});q$=j("$ZodBase64",(Q,$)=>{$.pattern??($.pattern=YQ),b1.init(Q,$),Q._zod.bag.contentEncoding="base64",Q._zod.check=(Y)=>{if(Y$(Y.value))return;Y.issues.push({code:"invalid_format",format:"base64",input:Y.value,inst:Q,continue:!$.abort})}});J$=j("$ZodBase64URL",(Q,$)=>{$.pattern??($.pattern=u7),b1.init(Q,$),Q._zod.bag.contentEncoding="base64url",Q._zod.check=(Y)=>{if(iW(Y.value))return;Y.issues.push({code:"invalid_format",format:"base64url",input:Y.value,inst:Q,continue:!$.abort})}}),X$=j("$ZodE164",(Q,$)=>{$.pattern??($.pattern=qQ),b1.init(Q,$)});H$=j("$ZodJWT",(Q,$)=>{b1.init(Q,$),Q._zod.check=(Y)=>{if(nW(Y.value,$.alg))return;Y.issues.push({code:"invalid_format",format:"jwt",input:Y.value,inst:Q,continue:!$.abort})}}),l7=j("$ZodNumber",(Q,$)=>{T1.init(Q,$),Q._zod.pattern=Q._zod.bag.pattern??r2,Q._zod.parse=(Y,q)=>{if($.coerce)try{Y.value=Number(Y.value)}catch(H){}let J=Y.value;if(typeof J==="number"&&!Number.isNaN(J)&&Number.isFinite(J))return Y;let X=typeof J==="number"?Number.isNaN(J)?"NaN":!Number.isFinite(J)?"Infinity":void 0:void 0;return Y.issues.push({expected:"number",code:"invalid_type",input:J,inst:Q,...X?{received:X}:{}}),Y}}),G$=j("$ZodNumberFormat",(Q,$)=>{VQ.init(Q,$),l7.init(Q,$)}),K$=j("$ZodBoolean",(Q,$)=>{T1.init(Q,$),Q._zod.pattern=BQ,Q._zod.parse=(Y,q)=>{if($.coerce)try{Y.value=Boolean(Y.value)}catch(X){}let J=Y.value;if(typeof J==="boolean")return Y;return Y.issues.push({expected:"boolean",code:"invalid_type",input:J,inst:Q}),Y}}),W$=j("$ZodAny",(Q,$)=>{T1.init(Q,$),Q._zod.parse=(Y)=>Y}),z$=j("$ZodUnknown",(Q,$)=>{T1.init(Q,$),Q._zod.parse=(Y)=>Y}),B$=j("$ZodNever",(Q,$)=>{T1.init(Q,$),Q._zod.parse=(Y,q)=>{return Y.issues.push({expected:"never",code:"invalid_type",input:Y.value,inst:Q}),Y}});_$=j("$ZodArray",(Q,$)=>{T1.init(Q,$),Q._zod.parse=(Y,q)=>{let J=Y.value;if(!Array.isArray(J))return Y.issues.push({expected:"array",code:"invalid_type",input:J,inst:Q}),Y;Y.value=Array(J.length);let X=[];for(let H=0;H<J.length;H++){let G=J[H],K=$.element._zod.run({value:G,issues:[]},q);if(K instanceof Promise)X.push(K.then((W)=>SQ(W,Y,H)));else SQ(K,Y,H)}if(X.length)return Promise.all(X).then(()=>Y);return Y}});oW=j("$ZodObject",(Q,$)=>{if(T1.init(Q,$),!Object.getOwnPropertyDescriptor($,"shape")?.get){let G=$.shape;Object.defineProperty($,"shape",{get:()=>{let K={...G};return Object.defineProperty($,"shape",{value:K}),K}})}let q=$2(()=>Z$($));U1(Q._zod,"propValues",()=>{let G=$.shape,K={};for(let W in G){let z=G[W]._zod;if(z.values){K[W]??(K[W]=new Set);for(let B of z.values)K[W].add(B)}}return K});let J=V9,X=$.catchall,H;Q._zod.parse=(G,K)=>{H??(H=q.value);let W=G.value;if(!J(W))return G.issues.push({expected:"object",code:"invalid_type",input:W,inst:Q}),G;G.value={};let z=[],B=H.shape;for(let Z of H.keys){let M=B[Z],V=M._zod.optout==="optional",U=M._zod.run({value:W[Z],issues:[]},K);if(U instanceof Promise)z.push(U.then((R)=>$3(R,G,Z,W,V)));else $3(U,G,Z,W,V)}if(!X)return z.length?Promise.all(z).then(()=>G):G;return M$(z,W,G,K,q.value,Q)}}),U$=j("$ZodObjectJIT",(Q,$)=>{oW.init(Q,$);let Y=Q._zod.parse,q=$2(()=>Z$($)),J=(Z)=>{let M=new c7(["shape","payload","ctx"]),V=q.value,U=(T)=>{let x=p2(T);return`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`};M.write("const input = payload.value;");let R=Object.create(null),N=0;for(let T of V.keys)R[T]=`key_${N++}`;M.write("const newResult = {};");for(let T of V.keys){let x=R[T],O=p2(T),w=Z[T]?._zod?.optout==="optional";if(M.write(`const ${x} = ${U(T)};`),w)M.write(`
20
20
  if (${x}.issues.length) {
21
- if (${w} in input) {
21
+ if (${O} in input) {
22
22
  payload.issues = payload.issues.concat(${x}.issues.map(iss => ({
23
23
  ...iss,
24
- path: iss.path ? [${w}, ...iss.path] : [${w}]
24
+ path: iss.path ? [${O}, ...iss.path] : [${O}]
25
25
  })));
26
26
  }
27
27
  }
28
28
 
29
29
  if (${x}.value === undefined) {
30
- if (${w} in input) {
31
- newResult[${w}] = undefined;
30
+ if (${O} in input) {
31
+ newResult[${O}] = undefined;
32
32
  }
33
33
  } else {
34
- newResult[${w}] = ${x}.value;
34
+ newResult[${O}] = ${x}.value;
35
35
  }
36
36
 
37
37
  `);else M.write(`
38
38
  if (${x}.issues.length) {
39
39
  payload.issues = payload.issues.concat(${x}.issues.map(iss => ({
40
40
  ...iss,
41
- path: iss.path ? [${w}, ...iss.path] : [${w}]
41
+ path: iss.path ? [${O}, ...iss.path] : [${O}]
42
42
  })));
43
43
  }
44
44
 
45
45
  if (${x}.value === undefined) {
46
- if (${w} in input) {
47
- newResult[${w}] = undefined;
46
+ if (${O} in input) {
47
+ newResult[${O}] = undefined;
48
48
  }
49
49
  } else {
50
- newResult[${w}] = ${x}.value;
50
+ newResult[${O}] = ${x}.value;
51
51
  }
52
52
 
53
- `)}M.write("payload.value = newResult;"),M.write("return payload;");let c=M.compile();return(N,x)=>c(Z,N,x)},X,H=V9,G=!c2.jitless,W=G&&E7.value,z=$.catchall,B;Q._zod.parse=(Z,M)=>{B??(B=q.value);let V=Z.value;if(!H(V))return Z.issues.push({expected:"object",code:"invalid_type",input:V,inst:Q}),Z;if(G&&W&&M?.async===!1&&M.jitless!==!0){if(!X)X=J($.shape);if(Z=X(Z,M),!z)return Z;return M$([],V,Z,M,B,Q)}return Y(Z,M)}});V$=j("$ZodUnion",(Q,$)=>{T1.init(Q,$),U1(Q._zod,"optin",()=>$.options.some((J)=>J._zod.optin==="optional")?"optional":void 0),U1(Q._zod,"optout",()=>$.options.some((J)=>J._zod.optout==="optional")?"optional":void 0),U1(Q._zod,"values",()=>{if($.options.every((J)=>J._zod.values))return new Set($.options.flatMap((J)=>Array.from(J._zod.values)));return}),U1(Q._zod,"pattern",()=>{if($.options.every((J)=>J._zod.pattern)){let J=$.options.map((X)=>X._zod.pattern);return new RegExp(`^(${J.map((X)=>q2(X.source)).join("|")})$`)}return});let Y=$.options.length===1,q=$.options[0]._zod.run;Q._zod.parse=(J,X)=>{if(Y)return q(J,X);let H=!1,G=[];for(let K of $.options){let W=K._zod.run({value:J.value,issues:[]},X);if(W instanceof Promise)G.push(W),H=!0;else{if(W.issues.length===0)return W;G.push(W)}}if(!H)return EQ(G,J,Q,X);return Promise.all(G).then((K)=>{return EQ(K,J,Q,X)})}}),A$=j("$ZodIntersection",(Q,$)=>{T1.init(Q,$),Q._zod.parse=(Y,q)=>{let J=Y.value,X=$.left._zod.run({value:J,issues:[]},q),H=$.right._zod.run({value:J,issues:[]},q);if(X instanceof Promise||H instanceof Promise)return Promise.all([X,H]).then(([K,W])=>{return kQ(Y,K,W)});return kQ(Y,X,H)}});L$=j("$ZodRecord",(Q,$)=>{T1.init(Q,$),Q._zod.parse=(Y,q)=>{let J=Y.value;if(!w8(J))return Y.issues.push({expected:"record",code:"invalid_type",input:J,inst:Q}),Y;let X=[],H=$.keyType._zod.values;if(H){Y.value={};let G=new Set;for(let W of H)if(typeof W==="string"||typeof W==="number"||typeof W==="symbol"){G.add(typeof W==="number"?W.toString():W);let z=$.valueType._zod.run({value:J[W],issues:[]},q);if(z instanceof Promise)X.push(z.then((B)=>{if(B.issues.length)Y.issues.push(...X8(W,B.issues));Y.value[W]=B.value}));else{if(z.issues.length)Y.issues.push(...X8(W,z.issues));Y.value[W]=z.value}}let K;for(let W in J)if(!G.has(W))K=K??[],K.push(W);if(K&&K.length>0)Y.issues.push({code:"unrecognized_keys",input:J,inst:Q,keys:K})}else{Y.value={};for(let G of Reflect.ownKeys(J)){if(G==="__proto__")continue;let K=$.keyType._zod.run({value:G,issues:[]},q);if(K instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof G==="string"&&r2.test(G)&&K.issues.length){let B=$.keyType._zod.run({value:Number(G),issues:[]},q);if(B instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(B.issues.length===0)K=B}if(K.issues.length){if($.mode==="loose")Y.value[G]=J[G];else Y.issues.push({code:"invalid_key",origin:"record",issues:K.issues.map((B)=>x0(B,q,O0())),input:G,path:[G],inst:Q});continue}let z=$.valueType._zod.run({value:J[G],issues:[]},q);if(z instanceof Promise)X.push(z.then((B)=>{if(B.issues.length)Y.issues.push(...X8(G,B.issues));Y.value[K.value]=B.value}));else{if(z.issues.length)Y.issues.push(...X8(G,z.issues));Y.value[K.value]=z.value}}}if(X.length)return Promise.all(X).then(()=>Y);return Y}}),F$=j("$ZodEnum",(Q,$)=>{T1.init(Q,$);let Y=Q2($.entries),q=new Set(Y);Q._zod.values=q,Q._zod.pattern=new RegExp(`^(${Y.filter((J)=>k7.has(typeof J)).map((J)=>typeof J==="string"?J8(J):J.toString()).join("|")})$`),Q._zod.parse=(J,X)=>{let H=J.value;if(q.has(H))return J;return J.issues.push({code:"invalid_value",values:Y,input:H,inst:Q}),J}}),j$=j("$ZodLiteral",(Q,$)=>{if(T1.init(Q,$),$.values.length===0)throw Error("Cannot create literal schema with no valid values");let Y=new Set($.values);Q._zod.values=Y,Q._zod.pattern=new RegExp(`^(${$.values.map((q)=>typeof q==="string"?J8(q):q?J8(q.toString()):String(q)).join("|")})$`),Q._zod.parse=(q,J)=>{let X=q.value;if(Y.has(X))return q;return q.issues.push({code:"invalid_value",values:$.values,input:X,inst:Q}),q}}),w$=j("$ZodTransform",(Q,$)=>{T1.init(Q,$),Q._zod.parse=(Y,q)=>{if(q.direction==="backward")throw new t9(Q.constructor.name);let J=$.transform(Y.value,Y);if(q.async)return(J instanceof Promise?J:Promise.resolve(J)).then((H)=>{return Y.value=H,Y});if(J instanceof Promise)throw new Y8;return Y.value=J,Y}});i7=j("$ZodOptional",(Q,$)=>{T1.init(Q,$),Q._zod.optin="optional",Q._zod.optout="optional",U1(Q._zod,"values",()=>{return $.innerType._zod.values?new Set([...$.innerType._zod.values,void 0]):void 0}),U1(Q._zod,"pattern",()=>{let Y=$.innerType._zod.pattern;return Y?new RegExp(`^(${q2(Y.source)})?$`):void 0}),Q._zod.parse=(Y,q)=>{if($.innerType._zod.optin==="optional"){let J=$.innerType._zod.run(Y,q);if(J instanceof Promise)return J.then((X)=>vQ(X,Y.value));return vQ(J,Y.value)}if(Y.value===void 0)return Y;return $.innerType._zod.run(Y,q)}}),D$=j("$ZodExactOptional",(Q,$)=>{i7.init(Q,$),U1(Q._zod,"values",()=>$.innerType._zod.values),U1(Q._zod,"pattern",()=>$.innerType._zod.pattern),Q._zod.parse=(Y,q)=>{return $.innerType._zod.run(Y,q)}}),O$=j("$ZodNullable",(Q,$)=>{T1.init(Q,$),U1(Q._zod,"optin",()=>$.innerType._zod.optin),U1(Q._zod,"optout",()=>$.innerType._zod.optout),U1(Q._zod,"pattern",()=>{let Y=$.innerType._zod.pattern;return Y?new RegExp(`^(${q2(Y.source)}|null)$`):void 0}),U1(Q._zod,"values",()=>{return $.innerType._zod.values?new Set([...$.innerType._zod.values,null]):void 0}),Q._zod.parse=(Y,q)=>{if(Y.value===null)return Y;return $.innerType._zod.run(Y,q)}}),I$=j("$ZodDefault",(Q,$)=>{T1.init(Q,$),Q._zod.optin="optional",U1(Q._zod,"values",()=>$.innerType._zod.values),Q._zod.parse=(Y,q)=>{if(q.direction==="backward")return $.innerType._zod.run(Y,q);if(Y.value===void 0)return Y.value=$.defaultValue,Y;let J=$.innerType._zod.run(Y,q);if(J instanceof Promise)return J.then((X)=>PQ(X,$));return PQ(J,$)}});N$=j("$ZodPrefault",(Q,$)=>{T1.init(Q,$),Q._zod.optin="optional",U1(Q._zod,"values",()=>$.innerType._zod.values),Q._zod.parse=(Y,q)=>{if(q.direction==="backward")return $.innerType._zod.run(Y,q);if(Y.value===void 0)Y.value=$.defaultValue;return $.innerType._zod.run(Y,q)}}),T$=j("$ZodNonOptional",(Q,$)=>{T1.init(Q,$),U1(Q._zod,"values",()=>{let Y=$.innerType._zod.values;return Y?new Set([...Y].filter((q)=>q!==void 0)):void 0}),Q._zod.parse=(Y,q)=>{let J=$.innerType._zod.run(Y,q);if(J instanceof Promise)return J.then((X)=>xQ(X,Q));return xQ(J,Q)}});b$=j("$ZodCatch",(Q,$)=>{T1.init(Q,$),U1(Q._zod,"optin",()=>$.innerType._zod.optin),U1(Q._zod,"optout",()=>$.innerType._zod.optout),U1(Q._zod,"values",()=>$.innerType._zod.values),Q._zod.parse=(Y,q)=>{if(q.direction==="backward")return $.innerType._zod.run(Y,q);let J=$.innerType._zod.run(Y,q);if(J instanceof Promise)return J.then((X)=>{if(Y.value=X.value,X.issues.length)Y.value=$.catchValue({...Y,error:{issues:X.issues.map((H)=>x0(H,q,O0()))},input:Y.value}),Y.issues=[];return Y});if(Y.value=J.value,J.issues.length)Y.value=$.catchValue({...Y,error:{issues:J.issues.map((X)=>x0(X,q,O0()))},input:Y.value}),Y.issues=[];return Y}}),R$=j("$ZodPipe",(Q,$)=>{T1.init(Q,$),U1(Q._zod,"values",()=>$.in._zod.values),U1(Q._zod,"optin",()=>$.in._zod.optin),U1(Q._zod,"optout",()=>$.out._zod.optout),U1(Q._zod,"propValues",()=>$.in._zod.propValues),Q._zod.parse=(Y,q)=>{if(q.direction==="backward"){let X=$.out._zod.run(Y,q);if(X instanceof Promise)return X.then((H)=>Q3(H,$.in,q));return Q3(X,$.in,q)}let J=$.in._zod.run(Y,q);if(J instanceof Promise)return J.then((X)=>Q3(X,$.out,q));return Q3(J,$.out,q)}});S$=j("$ZodReadonly",(Q,$)=>{T1.init(Q,$),U1(Q._zod,"propValues",()=>$.innerType._zod.propValues),U1(Q._zod,"values",()=>$.innerType._zod.values),U1(Q._zod,"optin",()=>$.innerType?._zod?.optin),U1(Q._zod,"optout",()=>$.innerType?._zod?.optout),Q._zod.parse=(Y,q)=>{if(q.direction==="backward")return $.innerType._zod.run(Y,q);let J=$.innerType._zod.run(Y,q);if(J instanceof Promise)return J.then(CQ);return CQ(J)}});E$=j("$ZodCustom",(Q,$)=>{s1.init(Q,$),T1.init(Q,$),Q._zod.parse=(Y,q)=>{return Y},Q._zod.check=(Y)=>{let q=Y.value,J=$.fn(q);if(J instanceof Promise)return J.then((X)=>yQ(X,Y,q,Q));yQ(J,Y,q,Q);return}})});function n7(){return{localeError:sW()}}var sW=()=>{let Q={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function $(J){return Q[J]??null}let Y={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},q={nan:"NaN"};return(J)=>{switch(J.code){case"invalid_type":{let X=q[J.expected]??J.expected,H=x7(J.input),G=q[H]??H;return`Invalid input: expected ${X}, received ${G}`}case"invalid_value":if(J.values.length===1)return`Invalid input: expected ${i2(J.values[0])}`;return`Invalid option: expected one of ${d2(J.values,"|")}`;case"too_big":{let X=J.inclusive?"<=":"<",H=$(J.origin);if(H)return`Too big: expected ${J.origin??"value"} to have ${X}${J.maximum.toString()} ${H.unit??"elements"}`;return`Too big: expected ${J.origin??"value"} to be ${X}${J.maximum.toString()}`}case"too_small":{let X=J.inclusive?">=":">",H=$(J.origin);if(H)return`Too small: expected ${J.origin} to have ${X}${J.minimum.toString()} ${H.unit}`;return`Too small: expected ${J.origin} to be ${X}${J.minimum.toString()}`}case"invalid_format":{let X=J;if(X.format==="starts_with")return`Invalid string: must start with "${X.prefix}"`;if(X.format==="ends_with")return`Invalid string: must end with "${X.suffix}"`;if(X.format==="includes")return`Invalid string: must include "${X.includes}"`;if(X.format==="regex")return`Invalid string: must match pattern ${X.pattern}`;return`Invalid ${Y[X.format]??J.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${J.divisor}`;case"unrecognized_keys":return`Unrecognized key${J.keys.length>1?"s":""}: ${d2(J.keys,", ")}`;case"invalid_key":return`Invalid key in ${J.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${J.origin}`;default:return"Invalid input"}}};var v$=A(()=>{C0()});var o7=()=>{};class C${constructor(){this._map=new WeakMap,this._idmap=new Map}add(Q,...$){let Y=$[0];if(this._map.set(Q,Y),Y&&typeof Y==="object"&&"id"in Y)this._idmap.set(Y.id,Q);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(Q){let $=this._map.get(Q);if($&&typeof $==="object"&&"id"in $)this._idmap.delete($.id);return this._map.delete(Q),this}get(Q){let $=Q._zod.parent;if($){let Y={...this.get($)??{}};delete Y.id;let q={...Y,...this._map.get(Q)};return Object.keys(q).length?q:void 0}return this._map.get(Q)}has(Q){return this._map.has(Q)}}function rW(){return new C$}var x$,RF,SF,f8;var s7=A(()=>{RF=Symbol("ZodOutput"),SF=Symbol("ZodInput");(x$=globalThis).__zod_globalRegistry??(x$.__zod_globalRegistry=rW());f8=globalThis.__zod_globalRegistry});function y$(Q,$){return new Q({type:"string",...d($)})}function h$(Q,$){return new Q({type:"string",format:"email",check:"string_format",abort:!1,...d($)})}function r7(Q,$){return new Q({type:"string",format:"guid",check:"string_format",abort:!1,...d($)})}function f$(Q,$){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,...d($)})}function u$(Q,$){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...d($)})}function m$(Q,$){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...d($)})}function g$(Q,$){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...d($)})}function c$(Q,$){return new Q({type:"string",format:"url",check:"string_format",abort:!1,...d($)})}function d$(Q,$){return new Q({type:"string",format:"emoji",check:"string_format",abort:!1,...d($)})}function p$(Q,$){return new Q({type:"string",format:"nanoid",check:"string_format",abort:!1,...d($)})}function l$(Q,$){return new Q({type:"string",format:"cuid",check:"string_format",abort:!1,...d($)})}function i$(Q,$){return new Q({type:"string",format:"cuid2",check:"string_format",abort:!1,...d($)})}function n$(Q,$){return new Q({type:"string",format:"ulid",check:"string_format",abort:!1,...d($)})}function o$(Q,$){return new Q({type:"string",format:"xid",check:"string_format",abort:!1,...d($)})}function s$(Q,$){return new Q({type:"string",format:"ksuid",check:"string_format",abort:!1,...d($)})}function r$(Q,$){return new Q({type:"string",format:"ipv4",check:"string_format",abort:!1,...d($)})}function a$(Q,$){return new Q({type:"string",format:"ipv6",check:"string_format",abort:!1,...d($)})}function t$(Q,$){return new Q({type:"string",format:"cidrv4",check:"string_format",abort:!1,...d($)})}function e$(Q,$){return new Q({type:"string",format:"cidrv6",check:"string_format",abort:!1,...d($)})}function QY(Q,$){return new Q({type:"string",format:"base64",check:"string_format",abort:!1,...d($)})}function $Y(Q,$){return new Q({type:"string",format:"base64url",check:"string_format",abort:!1,...d($)})}function YY(Q,$){return new Q({type:"string",format:"e164",check:"string_format",abort:!1,...d($)})}function qY(Q,$){return new Q({type:"string",format:"jwt",check:"string_format",abort:!1,...d($)})}function JY(Q,$){return new Q({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...d($)})}function XY(Q,$){return new Q({type:"string",format:"date",check:"string_format",...d($)})}function HY(Q,$){return new Q({type:"string",format:"time",check:"string_format",precision:null,...d($)})}function GY(Q,$){return new Q({type:"string",format:"duration",check:"string_format",...d($)})}function KY(Q,$){return new Q({type:"number",checks:[],...d($)})}function WY(Q,$){return new Q({type:"number",check:"number_format",abort:!1,format:"safeint",...d($)})}function zY(Q,$){return new Q({type:"boolean",...d($)})}function BY(Q){return new Q({type:"any"})}function _Y(Q){return new Q({type:"unknown"})}function ZY(Q,$){return new Q({type:"never",...d($)})}function q3(Q,$){return new m7({check:"less_than",...d($),value:Q,inclusive:!1})}function K2(Q,$){return new m7({check:"less_than",...d($),value:Q,inclusive:!0})}function J3(Q,$){return new g7({check:"greater_than",...d($),value:Q,inclusive:!1})}function W2(Q,$){return new g7({check:"greater_than",...d($),value:Q,inclusive:!0})}function X3(Q,$){return new UQ({check:"multiple_of",...d($),value:Q})}function H3(Q,$){return new AQ({check:"max_length",...d($),maximum:Q})}function F9(Q,$){return new LQ({check:"min_length",...d($),minimum:Q})}function G3(Q,$){return new FQ({check:"length_equals",...d($),length:Q})}function a7(Q,$){return new jQ({check:"string_format",format:"regex",...d($),pattern:Q})}function t7(Q){return new wQ({check:"string_format",format:"lowercase",...d(Q)})}function e7(Q){return new DQ({check:"string_format",format:"uppercase",...d(Q)})}function Q4(Q,$){return new OQ({check:"string_format",format:"includes",...d($),includes:Q})}function $4(Q,$){return new IQ({check:"string_format",format:"starts_with",...d($),prefix:Q})}function Y4(Q,$){return new NQ({check:"string_format",format:"ends_with",...d($),suffix:Q})}function O8(Q){return new TQ({check:"overwrite",tx:Q})}function q4(Q){return O8(($)=>$.normalize(Q))}function J4(){return O8((Q)=>Q.trim())}function X4(){return O8((Q)=>Q.toLowerCase())}function H4(){return O8((Q)=>Q.toUpperCase())}function G4(){return O8((Q)=>S7(Q))}function MY(Q,$,Y){return new Q({type:"array",element:$,...d(Y)})}function UY(Q,$,Y){return new Q({type:"custom",check:"custom",fn:$,...d(Y)})}function VY(Q){let $=aW((Y)=>{return Y.addIssue=(q)=>{if(typeof q==="string")Y.issues.push(L9(q,Y.value,$._zod.def));else{let J=q;if(J.fatal)J.continue=!1;J.code??(J.code="custom"),J.input??(J.input=Y.value),J.inst??(J.inst=$),J.continue??(J.continue=!$._zod.def.abort),Y.issues.push(L9(J))}},Q(Y.value,Y)});return $}function aW(Q,$){let Y=new s1({check:"custom",...d($)});return Y._zod.check=Q,Y}var AY=A(()=>{e2();C0()});function K4(Q){let $=Q?.target??"draft-2020-12";if($==="draft-4")$="draft-04";if($==="draft-7")$="draft-07";return{processors:Q.processors??{},metadataRegistry:Q?.metadata??f8,target:$,unrepresentable:Q?.unrepresentable??"throw",override:Q?.override??(()=>{}),io:Q?.io??"output",counter:0,seen:new Map,cycles:Q?.cycles??"ref",reused:Q?.reused??"inline",external:Q?.external??void 0}}function m1(Q,$,Y={path:[],schemaPath:[]}){var q;let J=Q._zod.def,X=$.seen.get(Q);if(X){if(X.count++,Y.schemaPath.includes(Q))X.cycle=Y.path;return X.schema}let H={schema:{},count:1,cycle:void 0,path:Y.path};$.seen.set(Q,H);let G=Q._zod.toJSONSchema?.();if(G)H.schema=G;else{let z={...Y,schemaPath:[...Y.schemaPath,Q],path:Y.path};if(Q._zod.processJSONSchema)Q._zod.processJSONSchema($,H.schema,z);else{let Z=H.schema,M=$.processors[J.type];if(!M)throw Error(`[toJSONSchema]: Non-representable type encountered: ${J.type}`);M(Q,$,Z,z)}let B=Q._zod.parent;if(B){if(!H.ref)H.ref=B;m1(B,$,z),$.seen.get(B).isParent=!0}}let K=$.metadataRegistry.get(Q);if(K)Object.assign(H.schema,K);if($.io==="input"&&Y0(Q))delete H.schema.examples,delete H.schema.default;if($.io==="input"&&H.schema._prefault)(q=H.schema).default??(q.default=H.schema._prefault);return delete H.schema._prefault,$.seen.get(Q).schema}function W4(Q,$){let Y=Q.seen.get($);if(!Y)throw Error("Unprocessed schema. This is a bug in Zod.");let q=new Map;for(let H of Q.seen.entries()){let G=Q.metadataRegistry.get(H[0])?.id;if(G){let K=q.get(G);if(K&&K!==H[0])throw Error(`Duplicate schema id "${G}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);q.set(G,H[0])}}let J=(H)=>{let G=Q.target==="draft-2020-12"?"$defs":"definitions";if(Q.external){let B=Q.external.registry.get(H[0])?.id,Z=Q.external.uri??((V)=>V);if(B)return{ref:Z(B)};let M=H[1].defId??H[1].schema.id??`schema${Q.counter++}`;return H[1].defId=M,{defId:M,ref:`${Z("__shared")}#/${G}/${M}`}}if(H[1]===Y)return{ref:"#"};let W=`${"#"}/${G}/`,z=H[1].schema.id??`__schema${Q.counter++}`;return{defId:z,ref:W+z}},X=(H)=>{if(H[1].schema.$ref)return;let G=H[1],{ref:K,defId:W}=J(H);if(G.def={...G.schema},W)G.defId=W;let z=G.schema;for(let B in z)delete z[B];z.$ref=K};if(Q.cycles==="throw")for(let H of Q.seen.entries()){let G=H[1];if(G.cycle)throw Error(`Cycle detected: #/${G.cycle?.join("/")}/<root>
53
+ `)}M.write("payload.value = newResult;"),M.write("return payload;");let c=M.compile();return(T,x)=>c(Z,T,x)},X,H=V9,G=!c2.jitless,W=G&&E7.value,z=$.catchall,B;Q._zod.parse=(Z,M)=>{B??(B=q.value);let V=Z.value;if(!H(V))return Z.issues.push({expected:"object",code:"invalid_type",input:V,inst:Q}),Z;if(G&&W&&M?.async===!1&&M.jitless!==!0){if(!X)X=J($.shape);if(Z=X(Z,M),!z)return Z;return M$([],V,Z,M,B,Q)}return Y(Z,M)}});V$=j("$ZodUnion",(Q,$)=>{T1.init(Q,$),U1(Q._zod,"optin",()=>$.options.some((J)=>J._zod.optin==="optional")?"optional":void 0),U1(Q._zod,"optout",()=>$.options.some((J)=>J._zod.optout==="optional")?"optional":void 0),U1(Q._zod,"values",()=>{if($.options.every((J)=>J._zod.values))return new Set($.options.flatMap((J)=>Array.from(J._zod.values)));return}),U1(Q._zod,"pattern",()=>{if($.options.every((J)=>J._zod.pattern)){let J=$.options.map((X)=>X._zod.pattern);return new RegExp(`^(${J.map((X)=>q2(X.source)).join("|")})$`)}return});let Y=$.options.length===1,q=$.options[0]._zod.run;Q._zod.parse=(J,X)=>{if(Y)return q(J,X);let H=!1,G=[];for(let K of $.options){let W=K._zod.run({value:J.value,issues:[]},X);if(W instanceof Promise)G.push(W),H=!0;else{if(W.issues.length===0)return W;G.push(W)}}if(!H)return EQ(G,J,Q,X);return Promise.all(G).then((K)=>{return EQ(K,J,Q,X)})}}),A$=j("$ZodIntersection",(Q,$)=>{T1.init(Q,$),Q._zod.parse=(Y,q)=>{let J=Y.value,X=$.left._zod.run({value:J,issues:[]},q),H=$.right._zod.run({value:J,issues:[]},q);if(X instanceof Promise||H instanceof Promise)return Promise.all([X,H]).then(([K,W])=>{return kQ(Y,K,W)});return kQ(Y,X,H)}});L$=j("$ZodRecord",(Q,$)=>{T1.init(Q,$),Q._zod.parse=(Y,q)=>{let J=Y.value;if(!w8(J))return Y.issues.push({expected:"record",code:"invalid_type",input:J,inst:Q}),Y;let X=[],H=$.keyType._zod.values;if(H){Y.value={};let G=new Set;for(let W of H)if(typeof W==="string"||typeof W==="number"||typeof W==="symbol"){G.add(typeof W==="number"?W.toString():W);let z=$.valueType._zod.run({value:J[W],issues:[]},q);if(z instanceof Promise)X.push(z.then((B)=>{if(B.issues.length)Y.issues.push(...X8(W,B.issues));Y.value[W]=B.value}));else{if(z.issues.length)Y.issues.push(...X8(W,z.issues));Y.value[W]=z.value}}let K;for(let W in J)if(!G.has(W))K=K??[],K.push(W);if(K&&K.length>0)Y.issues.push({code:"unrecognized_keys",input:J,inst:Q,keys:K})}else{Y.value={};for(let G of Reflect.ownKeys(J)){if(G==="__proto__")continue;let K=$.keyType._zod.run({value:G,issues:[]},q);if(K instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof G==="string"&&r2.test(G)&&K.issues.length){let B=$.keyType._zod.run({value:Number(G),issues:[]},q);if(B instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(B.issues.length===0)K=B}if(K.issues.length){if($.mode==="loose")Y.value[G]=J[G];else Y.issues.push({code:"invalid_key",origin:"record",issues:K.issues.map((B)=>C0(B,q,I0())),input:G,path:[G],inst:Q});continue}let z=$.valueType._zod.run({value:J[G],issues:[]},q);if(z instanceof Promise)X.push(z.then((B)=>{if(B.issues.length)Y.issues.push(...X8(G,B.issues));Y.value[K.value]=B.value}));else{if(z.issues.length)Y.issues.push(...X8(G,z.issues));Y.value[K.value]=z.value}}}if(X.length)return Promise.all(X).then(()=>Y);return Y}}),F$=j("$ZodEnum",(Q,$)=>{T1.init(Q,$);let Y=Q2($.entries),q=new Set(Y);Q._zod.values=q,Q._zod.pattern=new RegExp(`^(${Y.filter((J)=>k7.has(typeof J)).map((J)=>typeof J==="string"?J8(J):J.toString()).join("|")})$`),Q._zod.parse=(J,X)=>{let H=J.value;if(q.has(H))return J;return J.issues.push({code:"invalid_value",values:Y,input:H,inst:Q}),J}}),j$=j("$ZodLiteral",(Q,$)=>{if(T1.init(Q,$),$.values.length===0)throw Error("Cannot create literal schema with no valid values");let Y=new Set($.values);Q._zod.values=Y,Q._zod.pattern=new RegExp(`^(${$.values.map((q)=>typeof q==="string"?J8(q):q?J8(q.toString()):String(q)).join("|")})$`),Q._zod.parse=(q,J)=>{let X=q.value;if(Y.has(X))return q;return q.issues.push({code:"invalid_value",values:$.values,input:X,inst:Q}),q}}),w$=j("$ZodTransform",(Q,$)=>{T1.init(Q,$),Q._zod.parse=(Y,q)=>{if(q.direction==="backward")throw new t9(Q.constructor.name);let J=$.transform(Y.value,Y);if(q.async)return(J instanceof Promise?J:Promise.resolve(J)).then((H)=>{return Y.value=H,Y});if(J instanceof Promise)throw new Y8;return Y.value=J,Y}});i7=j("$ZodOptional",(Q,$)=>{T1.init(Q,$),Q._zod.optin="optional",Q._zod.optout="optional",U1(Q._zod,"values",()=>{return $.innerType._zod.values?new Set([...$.innerType._zod.values,void 0]):void 0}),U1(Q._zod,"pattern",()=>{let Y=$.innerType._zod.pattern;return Y?new RegExp(`^(${q2(Y.source)})?$`):void 0}),Q._zod.parse=(Y,q)=>{if($.innerType._zod.optin==="optional"){let J=$.innerType._zod.run(Y,q);if(J instanceof Promise)return J.then((X)=>vQ(X,Y.value));return vQ(J,Y.value)}if(Y.value===void 0)return Y;return $.innerType._zod.run(Y,q)}}),D$=j("$ZodExactOptional",(Q,$)=>{i7.init(Q,$),U1(Q._zod,"values",()=>$.innerType._zod.values),U1(Q._zod,"pattern",()=>$.innerType._zod.pattern),Q._zod.parse=(Y,q)=>{return $.innerType._zod.run(Y,q)}}),O$=j("$ZodNullable",(Q,$)=>{T1.init(Q,$),U1(Q._zod,"optin",()=>$.innerType._zod.optin),U1(Q._zod,"optout",()=>$.innerType._zod.optout),U1(Q._zod,"pattern",()=>{let Y=$.innerType._zod.pattern;return Y?new RegExp(`^(${q2(Y.source)}|null)$`):void 0}),U1(Q._zod,"values",()=>{return $.innerType._zod.values?new Set([...$.innerType._zod.values,null]):void 0}),Q._zod.parse=(Y,q)=>{if(Y.value===null)return Y;return $.innerType._zod.run(Y,q)}}),I$=j("$ZodDefault",(Q,$)=>{T1.init(Q,$),Q._zod.optin="optional",U1(Q._zod,"values",()=>$.innerType._zod.values),Q._zod.parse=(Y,q)=>{if(q.direction==="backward")return $.innerType._zod.run(Y,q);if(Y.value===void 0)return Y.value=$.defaultValue,Y;let J=$.innerType._zod.run(Y,q);if(J instanceof Promise)return J.then((X)=>PQ(X,$));return PQ(J,$)}});N$=j("$ZodPrefault",(Q,$)=>{T1.init(Q,$),Q._zod.optin="optional",U1(Q._zod,"values",()=>$.innerType._zod.values),Q._zod.parse=(Y,q)=>{if(q.direction==="backward")return $.innerType._zod.run(Y,q);if(Y.value===void 0)Y.value=$.defaultValue;return $.innerType._zod.run(Y,q)}}),T$=j("$ZodNonOptional",(Q,$)=>{T1.init(Q,$),U1(Q._zod,"values",()=>{let Y=$.innerType._zod.values;return Y?new Set([...Y].filter((q)=>q!==void 0)):void 0}),Q._zod.parse=(Y,q)=>{let J=$.innerType._zod.run(Y,q);if(J instanceof Promise)return J.then((X)=>xQ(X,Q));return xQ(J,Q)}});b$=j("$ZodCatch",(Q,$)=>{T1.init(Q,$),U1(Q._zod,"optin",()=>$.innerType._zod.optin),U1(Q._zod,"optout",()=>$.innerType._zod.optout),U1(Q._zod,"values",()=>$.innerType._zod.values),Q._zod.parse=(Y,q)=>{if(q.direction==="backward")return $.innerType._zod.run(Y,q);let J=$.innerType._zod.run(Y,q);if(J instanceof Promise)return J.then((X)=>{if(Y.value=X.value,X.issues.length)Y.value=$.catchValue({...Y,error:{issues:X.issues.map((H)=>C0(H,q,I0()))},input:Y.value}),Y.issues=[];return Y});if(Y.value=J.value,J.issues.length)Y.value=$.catchValue({...Y,error:{issues:J.issues.map((X)=>C0(X,q,I0()))},input:Y.value}),Y.issues=[];return Y}}),R$=j("$ZodPipe",(Q,$)=>{T1.init(Q,$),U1(Q._zod,"values",()=>$.in._zod.values),U1(Q._zod,"optin",()=>$.in._zod.optin),U1(Q._zod,"optout",()=>$.out._zod.optout),U1(Q._zod,"propValues",()=>$.in._zod.propValues),Q._zod.parse=(Y,q)=>{if(q.direction==="backward"){let X=$.out._zod.run(Y,q);if(X instanceof Promise)return X.then((H)=>Q3(H,$.in,q));return Q3(X,$.in,q)}let J=$.in._zod.run(Y,q);if(J instanceof Promise)return J.then((X)=>Q3(X,$.out,q));return Q3(J,$.out,q)}});S$=j("$ZodReadonly",(Q,$)=>{T1.init(Q,$),U1(Q._zod,"propValues",()=>$.innerType._zod.propValues),U1(Q._zod,"values",()=>$.innerType._zod.values),U1(Q._zod,"optin",()=>$.innerType?._zod?.optin),U1(Q._zod,"optout",()=>$.innerType?._zod?.optout),Q._zod.parse=(Y,q)=>{if(q.direction==="backward")return $.innerType._zod.run(Y,q);let J=$.innerType._zod.run(Y,q);if(J instanceof Promise)return J.then(CQ);return CQ(J)}});E$=j("$ZodCustom",(Q,$)=>{s1.init(Q,$),T1.init(Q,$),Q._zod.parse=(Y,q)=>{return Y},Q._zod.check=(Y)=>{let q=Y.value,J=$.fn(q);if(J instanceof Promise)return J.then((X)=>yQ(X,Y,q,Q));yQ(J,Y,q,Q);return}})});function n7(){return{localeError:sW()}}var sW=()=>{let Q={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function $(J){return Q[J]??null}let Y={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},q={nan:"NaN"};return(J)=>{switch(J.code){case"invalid_type":{let X=q[J.expected]??J.expected,H=x7(J.input),G=q[H]??H;return`Invalid input: expected ${X}, received ${G}`}case"invalid_value":if(J.values.length===1)return`Invalid input: expected ${i2(J.values[0])}`;return`Invalid option: expected one of ${d2(J.values,"|")}`;case"too_big":{let X=J.inclusive?"<=":"<",H=$(J.origin);if(H)return`Too big: expected ${J.origin??"value"} to have ${X}${J.maximum.toString()} ${H.unit??"elements"}`;return`Too big: expected ${J.origin??"value"} to be ${X}${J.maximum.toString()}`}case"too_small":{let X=J.inclusive?">=":">",H=$(J.origin);if(H)return`Too small: expected ${J.origin} to have ${X}${J.minimum.toString()} ${H.unit}`;return`Too small: expected ${J.origin} to be ${X}${J.minimum.toString()}`}case"invalid_format":{let X=J;if(X.format==="starts_with")return`Invalid string: must start with "${X.prefix}"`;if(X.format==="ends_with")return`Invalid string: must end with "${X.suffix}"`;if(X.format==="includes")return`Invalid string: must include "${X.includes}"`;if(X.format==="regex")return`Invalid string: must match pattern ${X.pattern}`;return`Invalid ${Y[X.format]??J.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${J.divisor}`;case"unrecognized_keys":return`Unrecognized key${J.keys.length>1?"s":""}: ${d2(J.keys,", ")}`;case"invalid_key":return`Invalid key in ${J.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${J.origin}`;default:return"Invalid input"}}};var v$=A(()=>{y0()});var o7=()=>{};class C${constructor(){this._map=new WeakMap,this._idmap=new Map}add(Q,...$){let Y=$[0];if(this._map.set(Q,Y),Y&&typeof Y==="object"&&"id"in Y)this._idmap.set(Y.id,Q);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(Q){let $=this._map.get(Q);if($&&typeof $==="object"&&"id"in $)this._idmap.delete($.id);return this._map.delete(Q),this}get(Q){let $=Q._zod.parent;if($){let Y={...this.get($)??{}};delete Y.id;let q={...Y,...this._map.get(Q)};return Object.keys(q).length?q:void 0}return this._map.get(Q)}has(Q){return this._map.has(Q)}}function rW(){return new C$}var x$,kF,vF,f8;var s7=A(()=>{kF=Symbol("ZodOutput"),vF=Symbol("ZodInput");(x$=globalThis).__zod_globalRegistry??(x$.__zod_globalRegistry=rW());f8=globalThis.__zod_globalRegistry});function y$(Q,$){return new Q({type:"string",...d($)})}function h$(Q,$){return new Q({type:"string",format:"email",check:"string_format",abort:!1,...d($)})}function r7(Q,$){return new Q({type:"string",format:"guid",check:"string_format",abort:!1,...d($)})}function f$(Q,$){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,...d($)})}function u$(Q,$){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...d($)})}function m$(Q,$){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...d($)})}function g$(Q,$){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...d($)})}function c$(Q,$){return new Q({type:"string",format:"url",check:"string_format",abort:!1,...d($)})}function d$(Q,$){return new Q({type:"string",format:"emoji",check:"string_format",abort:!1,...d($)})}function p$(Q,$){return new Q({type:"string",format:"nanoid",check:"string_format",abort:!1,...d($)})}function l$(Q,$){return new Q({type:"string",format:"cuid",check:"string_format",abort:!1,...d($)})}function i$(Q,$){return new Q({type:"string",format:"cuid2",check:"string_format",abort:!1,...d($)})}function n$(Q,$){return new Q({type:"string",format:"ulid",check:"string_format",abort:!1,...d($)})}function o$(Q,$){return new Q({type:"string",format:"xid",check:"string_format",abort:!1,...d($)})}function s$(Q,$){return new Q({type:"string",format:"ksuid",check:"string_format",abort:!1,...d($)})}function r$(Q,$){return new Q({type:"string",format:"ipv4",check:"string_format",abort:!1,...d($)})}function a$(Q,$){return new Q({type:"string",format:"ipv6",check:"string_format",abort:!1,...d($)})}function t$(Q,$){return new Q({type:"string",format:"cidrv4",check:"string_format",abort:!1,...d($)})}function e$(Q,$){return new Q({type:"string",format:"cidrv6",check:"string_format",abort:!1,...d($)})}function QY(Q,$){return new Q({type:"string",format:"base64",check:"string_format",abort:!1,...d($)})}function $Y(Q,$){return new Q({type:"string",format:"base64url",check:"string_format",abort:!1,...d($)})}function YY(Q,$){return new Q({type:"string",format:"e164",check:"string_format",abort:!1,...d($)})}function qY(Q,$){return new Q({type:"string",format:"jwt",check:"string_format",abort:!1,...d($)})}function JY(Q,$){return new Q({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...d($)})}function XY(Q,$){return new Q({type:"string",format:"date",check:"string_format",...d($)})}function HY(Q,$){return new Q({type:"string",format:"time",check:"string_format",precision:null,...d($)})}function GY(Q,$){return new Q({type:"string",format:"duration",check:"string_format",...d($)})}function KY(Q,$){return new Q({type:"number",checks:[],...d($)})}function WY(Q,$){return new Q({type:"number",check:"number_format",abort:!1,format:"safeint",...d($)})}function zY(Q,$){return new Q({type:"boolean",...d($)})}function BY(Q){return new Q({type:"any"})}function _Y(Q){return new Q({type:"unknown"})}function ZY(Q,$){return new Q({type:"never",...d($)})}function q3(Q,$){return new m7({check:"less_than",...d($),value:Q,inclusive:!1})}function K2(Q,$){return new m7({check:"less_than",...d($),value:Q,inclusive:!0})}function J3(Q,$){return new g7({check:"greater_than",...d($),value:Q,inclusive:!1})}function W2(Q,$){return new g7({check:"greater_than",...d($),value:Q,inclusive:!0})}function X3(Q,$){return new UQ({check:"multiple_of",...d($),value:Q})}function H3(Q,$){return new AQ({check:"max_length",...d($),maximum:Q})}function F9(Q,$){return new LQ({check:"min_length",...d($),minimum:Q})}function G3(Q,$){return new FQ({check:"length_equals",...d($),length:Q})}function a7(Q,$){return new jQ({check:"string_format",format:"regex",...d($),pattern:Q})}function t7(Q){return new wQ({check:"string_format",format:"lowercase",...d(Q)})}function e7(Q){return new DQ({check:"string_format",format:"uppercase",...d(Q)})}function Q4(Q,$){return new OQ({check:"string_format",format:"includes",...d($),includes:Q})}function $4(Q,$){return new IQ({check:"string_format",format:"starts_with",...d($),prefix:Q})}function Y4(Q,$){return new NQ({check:"string_format",format:"ends_with",...d($),suffix:Q})}function O8(Q){return new TQ({check:"overwrite",tx:Q})}function q4(Q){return O8(($)=>$.normalize(Q))}function J4(){return O8((Q)=>Q.trim())}function X4(){return O8((Q)=>Q.toLowerCase())}function H4(){return O8((Q)=>Q.toUpperCase())}function G4(){return O8((Q)=>S7(Q))}function MY(Q,$,Y){return new Q({type:"array",element:$,...d(Y)})}function UY(Q,$,Y){return new Q({type:"custom",check:"custom",fn:$,...d(Y)})}function VY(Q){let $=aW((Y)=>{return Y.addIssue=(q)=>{if(typeof q==="string")Y.issues.push(L9(q,Y.value,$._zod.def));else{let J=q;if(J.fatal)J.continue=!1;J.code??(J.code="custom"),J.input??(J.input=Y.value),J.inst??(J.inst=$),J.continue??(J.continue=!$._zod.def.abort),Y.issues.push(L9(J))}},Q(Y.value,Y)});return $}function aW(Q,$){let Y=new s1({check:"custom",...d($)});return Y._zod.check=Q,Y}var AY=A(()=>{e2();y0()});function K4(Q){let $=Q?.target??"draft-2020-12";if($==="draft-4")$="draft-04";if($==="draft-7")$="draft-07";return{processors:Q.processors??{},metadataRegistry:Q?.metadata??f8,target:$,unrepresentable:Q?.unrepresentable??"throw",override:Q?.override??(()=>{}),io:Q?.io??"output",counter:0,seen:new Map,cycles:Q?.cycles??"ref",reused:Q?.reused??"inline",external:Q?.external??void 0}}function m1(Q,$,Y={path:[],schemaPath:[]}){var q;let J=Q._zod.def,X=$.seen.get(Q);if(X){if(X.count++,Y.schemaPath.includes(Q))X.cycle=Y.path;return X.schema}let H={schema:{},count:1,cycle:void 0,path:Y.path};$.seen.set(Q,H);let G=Q._zod.toJSONSchema?.();if(G)H.schema=G;else{let z={...Y,schemaPath:[...Y.schemaPath,Q],path:Y.path};if(Q._zod.processJSONSchema)Q._zod.processJSONSchema($,H.schema,z);else{let Z=H.schema,M=$.processors[J.type];if(!M)throw Error(`[toJSONSchema]: Non-representable type encountered: ${J.type}`);M(Q,$,Z,z)}let B=Q._zod.parent;if(B){if(!H.ref)H.ref=B;m1(B,$,z),$.seen.get(B).isParent=!0}}let K=$.metadataRegistry.get(Q);if(K)Object.assign(H.schema,K);if($.io==="input"&&Y0(Q))delete H.schema.examples,delete H.schema.default;if($.io==="input"&&H.schema._prefault)(q=H.schema).default??(q.default=H.schema._prefault);return delete H.schema._prefault,$.seen.get(Q).schema}function W4(Q,$){let Y=Q.seen.get($);if(!Y)throw Error("Unprocessed schema. This is a bug in Zod.");let q=new Map;for(let H of Q.seen.entries()){let G=Q.metadataRegistry.get(H[0])?.id;if(G){let K=q.get(G);if(K&&K!==H[0])throw Error(`Duplicate schema id "${G}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);q.set(G,H[0])}}let J=(H)=>{let G=Q.target==="draft-2020-12"?"$defs":"definitions";if(Q.external){let B=Q.external.registry.get(H[0])?.id,Z=Q.external.uri??((V)=>V);if(B)return{ref:Z(B)};let M=H[1].defId??H[1].schema.id??`schema${Q.counter++}`;return H[1].defId=M,{defId:M,ref:`${Z("__shared")}#/${G}/${M}`}}if(H[1]===Y)return{ref:"#"};let W=`${"#"}/${G}/`,z=H[1].schema.id??`__schema${Q.counter++}`;return{defId:z,ref:W+z}},X=(H)=>{if(H[1].schema.$ref)return;let G=H[1],{ref:K,defId:W}=J(H);if(G.def={...G.schema},W)G.defId=W;let z=G.schema;for(let B in z)delete z[B];z.$ref=K};if(Q.cycles==="throw")for(let H of Q.seen.entries()){let G=H[1];if(G.cycle)throw Error(`Cycle detected: #/${G.cycle?.join("/")}/<root>
54
54
 
55
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let H of Q.seen.entries()){let G=H[1];if($===H[0]){X(H);continue}if(Q.external){let W=Q.external.registry.get(H[0])?.id;if($!==H[0]&&W){X(H);continue}}if(Q.metadataRegistry.get(H[0])?.id){X(H);continue}if(G.cycle){X(H);continue}if(G.count>1){if(Q.reused==="ref"){X(H);continue}}}}function z4(Q,$){let Y=Q.seen.get($);if(!Y)throw Error("Unprocessed schema. This is a bug in Zod.");let q=(H)=>{let G=Q.seen.get(H);if(G.ref===null)return;let K=G.def??G.schema,W={...K},z=G.ref;if(G.ref=null,z){q(z);let Z=Q.seen.get(z),M=Z.schema;if(M.$ref&&(Q.target==="draft-07"||Q.target==="draft-04"||Q.target==="openapi-3.0"))K.allOf=K.allOf??[],K.allOf.push(M);else Object.assign(K,M);if(Object.assign(K,W),H._zod.parent===z)for(let U in K){if(U==="$ref"||U==="allOf")continue;if(!(U in W))delete K[U]}if(M.$ref&&Z.def)for(let U in K){if(U==="$ref"||U==="allOf")continue;if(U in Z.def&&JSON.stringify(K[U])===JSON.stringify(Z.def[U]))delete K[U]}}let B=H._zod.parent;if(B&&B!==z){q(B);let Z=Q.seen.get(B);if(Z?.schema.$ref){if(K.$ref=Z.schema.$ref,Z.def)for(let M in K){if(M==="$ref"||M==="allOf")continue;if(M in Z.def&&JSON.stringify(K[M])===JSON.stringify(Z.def[M]))delete K[M]}}}Q.override({zodSchema:H,jsonSchema:K,path:G.path??[]})};for(let H of[...Q.seen.entries()].reverse())q(H[0]);let J={};if(Q.target==="draft-2020-12")J.$schema="https://json-schema.org/draft/2020-12/schema";else if(Q.target==="draft-07")J.$schema="http://json-schema.org/draft-07/schema#";else if(Q.target==="draft-04")J.$schema="http://json-schema.org/draft-04/schema#";else if(Q.target==="openapi-3.0");if(Q.external?.uri){let H=Q.external.registry.get($)?.id;if(!H)throw Error("Schema is missing an `id` property");J.$id=Q.external.uri(H)}Object.assign(J,Y.def??Y.schema);let X=Q.external?.defs??{};for(let H of Q.seen.entries()){let G=H[1];if(G.def&&G.defId)X[G.defId]=G.def}if(Q.external);else if(Object.keys(X).length>0)if(Q.target==="draft-2020-12")J.$defs=X;else J.definitions=X;try{let H=JSON.parse(JSON.stringify(J));return Object.defineProperty(H,"~standard",{value:{...$["~standard"],jsonSchema:{input:z2($,"input",Q.processors),output:z2($,"output",Q.processors)}},enumerable:!1,writable:!1}),H}catch(H){throw Error("Error converting schema to JSON.")}}function Y0(Q,$){let Y=$??{seen:new Set};if(Y.seen.has(Q))return!1;Y.seen.add(Q);let q=Q._zod.def;if(q.type==="transform")return!0;if(q.type==="array")return Y0(q.element,Y);if(q.type==="set")return Y0(q.valueType,Y);if(q.type==="lazy")return Y0(q.getter(),Y);if(q.type==="promise"||q.type==="optional"||q.type==="nonoptional"||q.type==="nullable"||q.type==="readonly"||q.type==="default"||q.type==="prefault")return Y0(q.innerType,Y);if(q.type==="intersection")return Y0(q.left,Y)||Y0(q.right,Y);if(q.type==="record"||q.type==="map")return Y0(q.keyType,Y)||Y0(q.valueType,Y);if(q.type==="pipe")return Y0(q.in,Y)||Y0(q.out,Y);if(q.type==="object"){for(let J in q.shape)if(Y0(q.shape[J],Y))return!0;return!1}if(q.type==="union"){for(let J of q.options)if(Y0(J,Y))return!0;return!1}if(q.type==="tuple"){for(let J of q.items)if(Y0(J,Y))return!0;if(q.rest&&Y0(q.rest,Y))return!0;return!1}return!1}var LY=(Q,$={})=>(Y)=>{let q=K4({...Y,processors:$});return m1(Q,q),W4(q,Q),z4(q,Q)},z2=(Q,$,Y={})=>(q)=>{let{libraryOptions:J,target:X}=q??{},H=K4({...J??{},target:X,io:$,processors:Y});return m1(Q,H),W4(H,Q),z4(H,Q)};var K3=A(()=>{s7()});var tW,FY=(Q,$,Y,q)=>{let J=Y;J.type="string";let{minimum:X,maximum:H,format:G,patterns:K,contentEncoding:W}=Q._zod.bag;if(typeof X==="number")J.minLength=X;if(typeof H==="number")J.maxLength=H;if(G){if(J.format=tW[G]??G,J.format==="")delete J.format;if(G==="time")delete J.format}if(W)J.contentEncoding=W;if(K&&K.size>0){let z=[...K];if(z.length===1)J.pattern=z[0].source;else if(z.length>1)J.allOf=[...z.map((B)=>({...$.target==="draft-07"||$.target==="draft-04"||$.target==="openapi-3.0"?{type:"string"}:{},pattern:B.source}))]}},jY=(Q,$,Y,q)=>{let J=Y,{minimum:X,maximum:H,format:G,multipleOf:K,exclusiveMaximum:W,exclusiveMinimum:z}=Q._zod.bag;if(typeof G==="string"&&G.includes("int"))J.type="integer";else J.type="number";if(typeof z==="number")if($.target==="draft-04"||$.target==="openapi-3.0")J.minimum=z,J.exclusiveMinimum=!0;else J.exclusiveMinimum=z;if(typeof X==="number"){if(J.minimum=X,typeof z==="number"&&$.target!=="draft-04")if(z>=X)delete J.minimum;else delete J.exclusiveMinimum}if(typeof W==="number")if($.target==="draft-04"||$.target==="openapi-3.0")J.maximum=W,J.exclusiveMaximum=!0;else J.exclusiveMaximum=W;if(typeof H==="number"){if(J.maximum=H,typeof W==="number"&&$.target!=="draft-04")if(W<=H)delete J.maximum;else delete J.exclusiveMaximum}if(typeof K==="number")J.multipleOf=K},wY=(Q,$,Y,q)=>{Y.type="boolean"},DY=(Q,$,Y,q)=>{Y.not={}},OY=(Q,$,Y,q)=>{},IY=(Q,$,Y,q)=>{},NY=(Q,$,Y,q)=>{let J=Q._zod.def,X=Q2(J.entries);if(X.every((H)=>typeof H==="number"))Y.type="number";if(X.every((H)=>typeof H==="string"))Y.type="string";Y.enum=X},TY=(Q,$,Y,q)=>{let J=Q._zod.def,X=[];for(let H of J.values)if(H===void 0){if($.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof H==="bigint")if($.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else X.push(Number(H));else X.push(H);if(X.length===0);else if(X.length===1){let H=X[0];if(Y.type=H===null?"null":typeof H,$.target==="draft-04"||$.target==="openapi-3.0")Y.enum=[H];else Y.const=H}else{if(X.every((H)=>typeof H==="number"))Y.type="number";if(X.every((H)=>typeof H==="string"))Y.type="string";if(X.every((H)=>typeof H==="boolean"))Y.type="boolean";if(X.every((H)=>H===null))Y.type="null";Y.enum=X}},bY=(Q,$,Y,q)=>{if($.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},RY=(Q,$,Y,q)=>{if($.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},SY=(Q,$,Y,q)=>{let J=Y,X=Q._zod.def,{minimum:H,maximum:G}=Q._zod.bag;if(typeof H==="number")J.minItems=H;if(typeof G==="number")J.maxItems=G;J.type="array",J.items=m1(X.element,$,{...q,path:[...q.path,"items"]})},EY=(Q,$,Y,q)=>{let J=Y,X=Q._zod.def;J.type="object",J.properties={};let H=X.shape;for(let W in H)J.properties[W]=m1(H[W],$,{...q,path:[...q.path,"properties",W]});let G=new Set(Object.keys(H)),K=new Set([...G].filter((W)=>{let z=X.shape[W]._zod;if($.io==="input")return z.optin===void 0;else return z.optout===void 0}));if(K.size>0)J.required=Array.from(K);if(X.catchall?._zod.def.type==="never")J.additionalProperties=!1;else if(!X.catchall){if($.io==="output")J.additionalProperties=!1}else if(X.catchall)J.additionalProperties=m1(X.catchall,$,{...q,path:[...q.path,"additionalProperties"]})},kY=(Q,$,Y,q)=>{let J=Q._zod.def,X=J.inclusive===!1,H=J.options.map((G,K)=>m1(G,$,{...q,path:[...q.path,X?"oneOf":"anyOf",K]}));if(X)Y.oneOf=H;else Y.anyOf=H},vY=(Q,$,Y,q)=>{let J=Q._zod.def,X=m1(J.left,$,{...q,path:[...q.path,"allOf",0]}),H=m1(J.right,$,{...q,path:[...q.path,"allOf",1]}),G=(W)=>("allOf"in W)&&Object.keys(W).length===1,K=[...G(X)?X.allOf:[X],...G(H)?H.allOf:[H]];Y.allOf=K},PY=(Q,$,Y,q)=>{let J=Y,X=Q._zod.def;J.type="object";let H=X.keyType,K=H._zod.bag?.patterns;if(X.mode==="loose"&&K&&K.size>0){let z=m1(X.valueType,$,{...q,path:[...q.path,"patternProperties","*"]});J.patternProperties={};for(let B of K)J.patternProperties[B.source]=z}else{if($.target==="draft-07"||$.target==="draft-2020-12")J.propertyNames=m1(X.keyType,$,{...q,path:[...q.path,"propertyNames"]});J.additionalProperties=m1(X.valueType,$,{...q,path:[...q.path,"additionalProperties"]})}let W=H._zod.values;if(W){let z=[...W].filter((B)=>typeof B==="string"||typeof B==="number");if(z.length>0)J.required=z}},xY=(Q,$,Y,q)=>{let J=Q._zod.def,X=m1(J.innerType,$,q),H=$.seen.get(Q);if($.target==="openapi-3.0")H.ref=J.innerType,Y.nullable=!0;else Y.anyOf=[X,{type:"null"}]},CY=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);X.ref=J.innerType},yY=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);X.ref=J.innerType,Y.default=JSON.parse(JSON.stringify(J.defaultValue))},hY=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);if(X.ref=J.innerType,$.io==="input")Y._prefault=JSON.parse(JSON.stringify(J.defaultValue))},fY=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);X.ref=J.innerType;let H;try{H=J.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}Y.default=H},uY=(Q,$,Y,q)=>{let J=Q._zod.def,X=$.io==="input"?J.in._zod.def.type==="transform"?J.out:J.in:J.out;m1(X,$,q);let H=$.seen.get(Q);H.ref=X},mY=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);X.ref=J.innerType,Y.readOnly=!0},B4=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);X.ref=J.innerType};var gY=A(()=>{K3();C0();tW={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""}});var cY=()=>{};var o0=A(()=>{C0();t2();o7();cY();U9();h7();y7();k$();e2();d7();s7();AY();K3()});var _4=A(()=>{o0()});function dY(Q){return JY(Xz,Q)}function pY(Q){return XY(Hz,Q)}function lY(Q){return HY(Gz,Q)}function iY(Q){return GY(Kz,Q)}var Xz,Hz,Gz,Kz;var Z4=A(()=>{o0();M4();Xz=j("ZodISODateTime",(Q,$)=>{oQ.init(Q,$),S1.init(Q,$)});Hz=j("ZodISODate",(Q,$)=>{sQ.init(Q,$),S1.init(Q,$)});Gz=j("ZodISOTime",(Q,$)=>{rQ.init(Q,$),S1.init(Q,$)});Kz=j("ZodISODuration",(Q,$)=>{aQ.init(Q,$),S1.init(Q,$)})});var oY=(Q,$)=>{n2.init(Q,$),Q.name="ZodError",Object.defineProperties(Q,{format:{value:(Y)=>k5(Q,Y)},flatten:{value:(Y)=>E5(Q,Y)},addIssue:{value:(Y)=>{Q.issues.push(Y),Q.message=JSON.stringify(Q.issues,A9,2)}},addIssues:{value:(Y)=>{Q.issues.push(...Y),Q.message=JSON.stringify(Q.issues,A9,2)}},isEmpty:{get(){return Q.issues.length===0}}})},U4,M0;var V4=A(()=>{o0();o0();C0();U4=j("ZodError",oY),M0=j("ZodError",oY,{Parent:Error})});var sY,rY,aY,tY,eY,Qq,$q,Yq,qq,Jq,Xq,Hq;var A4=A(()=>{o0();V4();sY=o2(M0),rY=s2(M0),aY=X2(M0),tY=H2(M0),eY=x5(M0),Qq=C5(M0),$q=y5(M0),Yq=h5(M0),qq=f5(M0),Jq=u5(M0),Xq=m5(M0),Hq=g5(M0)});function F(Q){return y$(Bz,Q)}function j9(Q){return KY(Zq,Q)}function Kq(Q){return WY(Sz,Q)}function i1(Q){return zY(Ez,Q)}function Mq(){return BY(kz)}function I8(){return _Y(vz)}function xz(Q){return ZY(Pz,Q)}function R1(Q,$){return MY(Cz,Q,$)}function Q1(Q,$){let Y={type:"object",shape:Q??{},...z1.normalizeParams($)};return new yz(Y)}function U0(Q,$){return new hz({type:"union",options:Q,...z1.normalizeParams($)})}function uz(Q,$){return new fz({type:"intersection",left:Q,right:$})}function q1(Q,$,Y){return new mz({type:"record",keyType:Q,valueType:$,...z1.normalizeParams(Y)})}function t1(Q,$){let Y=Array.isArray(Q)?Object.fromEntries(Q.map((q)=>[q,q])):Q;return new L4({type:"enum",entries:Y,...z1.normalizeParams($)})}function F4(Q,$){return new gz({type:"literal",values:Array.isArray(Q)?Q:[Q],...z1.normalizeParams($)})}function dz(Q){return new cz({type:"transform",transform:Q})}function Wq(Q){return new Uq({type:"optional",innerType:Q})}function lz(Q){return new pz({type:"optional",innerType:Q})}function zq(Q){return new iz({type:"nullable",innerType:Q})}function oz(Q,$){return new nz({type:"default",innerType:Q,get defaultValue(){return typeof $==="function"?$():z1.shallowClone($)}})}function rz(Q,$){return new sz({type:"prefault",innerType:Q,get defaultValue(){return typeof $==="function"?$():z1.shallowClone($)}})}function az(Q,$){return new Vq({type:"nonoptional",innerType:Q,...z1.normalizeParams($)})}function ez(Q,$){return new tz({type:"catch",innerType:Q,catchValue:typeof $==="function"?$:()=>$})}function Bq(Q,$){return new QB({type:"pipe",in:Q,out:$})}function YB(Q){return new $B({type:"readonly",innerType:Q})}function JB(Q,$={}){return UY(qB,Q,$)}function XB(Q){return VY(Q)}var E1,_q,Bz,S1,_z,Gq,W3,Zz,Mz,Uz,Vz,Az,Lz,Fz,jz,wz,Dz,Oz,Iz,Nz,Tz,bz,Rz,Zq,Sz,Ez,kz,vz,Pz,Cz,yz,hz,fz,mz,L4,gz,cz,Uq,pz,iz,nz,sz,Vq,tz,QB,$B,qB;var M4=A(()=>{o0();o0();gY();K3();_4();Z4();A4();E1=j("ZodType",(Q,$)=>{return T1.init(Q,$),Object.assign(Q["~standard"],{jsonSchema:{input:z2(Q,"input"),output:z2(Q,"output")}}),Q.toJSONSchema=LY(Q,{}),Q.def=$,Q.type=$.type,Object.defineProperty(Q,"_def",{value:$}),Q.check=(...Y)=>{return Q.clone(z1.mergeDefs($,{checks:[...$.checks??[],...Y.map((q)=>typeof q==="function"?{_zod:{check:q,def:{check:"custom"},onattach:[]}}:q)]}),{parent:!0})},Q.with=Q.check,Q.clone=(Y,q)=>P0(Q,Y,q),Q.brand=()=>Q,Q.register=(Y,q)=>{return Y.add(Q,q),Q},Q.parse=(Y,q)=>sY(Q,Y,q,{callee:Q.parse}),Q.safeParse=(Y,q)=>aY(Q,Y,q),Q.parseAsync=async(Y,q)=>rY(Q,Y,q,{callee:Q.parseAsync}),Q.safeParseAsync=async(Y,q)=>tY(Q,Y,q),Q.spa=Q.safeParseAsync,Q.encode=(Y,q)=>eY(Q,Y,q),Q.decode=(Y,q)=>Qq(Q,Y,q),Q.encodeAsync=async(Y,q)=>$q(Q,Y,q),Q.decodeAsync=async(Y,q)=>Yq(Q,Y,q),Q.safeEncode=(Y,q)=>qq(Q,Y,q),Q.safeDecode=(Y,q)=>Jq(Q,Y,q),Q.safeEncodeAsync=async(Y,q)=>Xq(Q,Y,q),Q.safeDecodeAsync=async(Y,q)=>Hq(Q,Y,q),Q.refine=(Y,q)=>Q.check(JB(Y,q)),Q.superRefine=(Y)=>Q.check(XB(Y)),Q.overwrite=(Y)=>Q.check(O8(Y)),Q.optional=()=>Wq(Q),Q.exactOptional=()=>lz(Q),Q.nullable=()=>zq(Q),Q.nullish=()=>Wq(zq(Q)),Q.nonoptional=(Y)=>az(Q,Y),Q.array=()=>R1(Q),Q.or=(Y)=>U0([Q,Y]),Q.and=(Y)=>uz(Q,Y),Q.transform=(Y)=>Bq(Q,dz(Y)),Q.default=(Y)=>oz(Q,Y),Q.prefault=(Y)=>rz(Q,Y),Q.catch=(Y)=>ez(Q,Y),Q.pipe=(Y)=>Bq(Q,Y),Q.readonly=()=>YB(Q),Q.describe=(Y)=>{let q=Q.clone();return f8.add(q,{description:Y}),q},Object.defineProperty(Q,"description",{get(){return f8.get(Q)?.description},configurable:!0}),Q.meta=(...Y)=>{if(Y.length===0)return f8.get(Q);let q=Q.clone();return f8.add(q,Y[0]),q},Q.isOptional=()=>Q.safeParse(void 0).success,Q.isNullable=()=>Q.safeParse(null).success,Q.apply=(Y)=>Y(Q),Q}),_q=j("_ZodString",(Q,$)=>{Y3.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(q,J,X)=>FY(Q,q,J,X);let Y=Q._zod.bag;Q.format=Y.format??null,Q.minLength=Y.minimum??null,Q.maxLength=Y.maximum??null,Q.regex=(...q)=>Q.check(a7(...q)),Q.includes=(...q)=>Q.check(Q4(...q)),Q.startsWith=(...q)=>Q.check($4(...q)),Q.endsWith=(...q)=>Q.check(Y4(...q)),Q.min=(...q)=>Q.check(F9(...q)),Q.max=(...q)=>Q.check(H3(...q)),Q.length=(...q)=>Q.check(G3(...q)),Q.nonempty=(...q)=>Q.check(F9(1,...q)),Q.lowercase=(q)=>Q.check(t7(q)),Q.uppercase=(q)=>Q.check(e7(q)),Q.trim=()=>Q.check(J4()),Q.normalize=(...q)=>Q.check(q4(...q)),Q.toLowerCase=()=>Q.check(X4()),Q.toUpperCase=()=>Q.check(H4()),Q.slugify=()=>Q.check(G4())}),Bz=j("ZodString",(Q,$)=>{Y3.init(Q,$),_q.init(Q,$),Q.email=(Y)=>Q.check(h$(_z,Y)),Q.url=(Y)=>Q.check(c$(Zz,Y)),Q.jwt=(Y)=>Q.check(qY(Rz,Y)),Q.emoji=(Y)=>Q.check(d$(Mz,Y)),Q.guid=(Y)=>Q.check(r7(Gq,Y)),Q.uuid=(Y)=>Q.check(f$(W3,Y)),Q.uuidv4=(Y)=>Q.check(u$(W3,Y)),Q.uuidv6=(Y)=>Q.check(m$(W3,Y)),Q.uuidv7=(Y)=>Q.check(g$(W3,Y)),Q.nanoid=(Y)=>Q.check(p$(Uz,Y)),Q.guid=(Y)=>Q.check(r7(Gq,Y)),Q.cuid=(Y)=>Q.check(l$(Vz,Y)),Q.cuid2=(Y)=>Q.check(i$(Az,Y)),Q.ulid=(Y)=>Q.check(n$(Lz,Y)),Q.base64=(Y)=>Q.check(QY(Nz,Y)),Q.base64url=(Y)=>Q.check($Y(Tz,Y)),Q.xid=(Y)=>Q.check(o$(Fz,Y)),Q.ksuid=(Y)=>Q.check(s$(jz,Y)),Q.ipv4=(Y)=>Q.check(r$(wz,Y)),Q.ipv6=(Y)=>Q.check(a$(Dz,Y)),Q.cidrv4=(Y)=>Q.check(t$(Oz,Y)),Q.cidrv6=(Y)=>Q.check(e$(Iz,Y)),Q.e164=(Y)=>Q.check(YY(bz,Y)),Q.datetime=(Y)=>Q.check(dY(Y)),Q.date=(Y)=>Q.check(pY(Y)),Q.time=(Y)=>Q.check(lY(Y)),Q.duration=(Y)=>Q.check(iY(Y))});S1=j("ZodStringFormat",(Q,$)=>{b1.init(Q,$),_q.init(Q,$)}),_z=j("ZodEmail",(Q,$)=>{uQ.init(Q,$),S1.init(Q,$)}),Gq=j("ZodGUID",(Q,$)=>{hQ.init(Q,$),S1.init(Q,$)}),W3=j("ZodUUID",(Q,$)=>{fQ.init(Q,$),S1.init(Q,$)}),Zz=j("ZodURL",(Q,$)=>{mQ.init(Q,$),S1.init(Q,$)}),Mz=j("ZodEmoji",(Q,$)=>{gQ.init(Q,$),S1.init(Q,$)}),Uz=j("ZodNanoID",(Q,$)=>{cQ.init(Q,$),S1.init(Q,$)}),Vz=j("ZodCUID",(Q,$)=>{dQ.init(Q,$),S1.init(Q,$)}),Az=j("ZodCUID2",(Q,$)=>{pQ.init(Q,$),S1.init(Q,$)}),Lz=j("ZodULID",(Q,$)=>{lQ.init(Q,$),S1.init(Q,$)}),Fz=j("ZodXID",(Q,$)=>{iQ.init(Q,$),S1.init(Q,$)}),jz=j("ZodKSUID",(Q,$)=>{nQ.init(Q,$),S1.init(Q,$)}),wz=j("ZodIPv4",(Q,$)=>{tQ.init(Q,$),S1.init(Q,$)}),Dz=j("ZodIPv6",(Q,$)=>{eQ.init(Q,$),S1.init(Q,$)}),Oz=j("ZodCIDRv4",(Q,$)=>{Q$.init(Q,$),S1.init(Q,$)}),Iz=j("ZodCIDRv6",(Q,$)=>{$$.init(Q,$),S1.init(Q,$)}),Nz=j("ZodBase64",(Q,$)=>{q$.init(Q,$),S1.init(Q,$)}),Tz=j("ZodBase64URL",(Q,$)=>{J$.init(Q,$),S1.init(Q,$)}),bz=j("ZodE164",(Q,$)=>{X$.init(Q,$),S1.init(Q,$)}),Rz=j("ZodJWT",(Q,$)=>{H$.init(Q,$),S1.init(Q,$)}),Zq=j("ZodNumber",(Q,$)=>{l7.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(q,J,X)=>jY(Q,q,J,X),Q.gt=(q,J)=>Q.check(J3(q,J)),Q.gte=(q,J)=>Q.check(W2(q,J)),Q.min=(q,J)=>Q.check(W2(q,J)),Q.lt=(q,J)=>Q.check(q3(q,J)),Q.lte=(q,J)=>Q.check(K2(q,J)),Q.max=(q,J)=>Q.check(K2(q,J)),Q.int=(q)=>Q.check(Kq(q)),Q.safe=(q)=>Q.check(Kq(q)),Q.positive=(q)=>Q.check(J3(0,q)),Q.nonnegative=(q)=>Q.check(W2(0,q)),Q.negative=(q)=>Q.check(q3(0,q)),Q.nonpositive=(q)=>Q.check(K2(0,q)),Q.multipleOf=(q,J)=>Q.check(X3(q,J)),Q.step=(q,J)=>Q.check(X3(q,J)),Q.finite=()=>Q;let Y=Q._zod.bag;Q.minValue=Math.max(Y.minimum??Number.NEGATIVE_INFINITY,Y.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,Q.maxValue=Math.min(Y.maximum??Number.POSITIVE_INFINITY,Y.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,Q.isInt=(Y.format??"").includes("int")||Number.isSafeInteger(Y.multipleOf??0.5),Q.isFinite=!0,Q.format=Y.format??null});Sz=j("ZodNumberFormat",(Q,$)=>{G$.init(Q,$),Zq.init(Q,$)});Ez=j("ZodBoolean",(Q,$)=>{K$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>wY(Q,Y,q,J)});kz=j("ZodAny",(Q,$)=>{W$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>OY(Q,Y,q,J)});vz=j("ZodUnknown",(Q,$)=>{z$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>IY(Q,Y,q,J)});Pz=j("ZodNever",(Q,$)=>{B$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>DY(Q,Y,q,J)});Cz=j("ZodArray",(Q,$)=>{_$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>SY(Q,Y,q,J),Q.element=$.element,Q.min=(Y,q)=>Q.check(F9(Y,q)),Q.nonempty=(Y)=>Q.check(F9(1,Y)),Q.max=(Y,q)=>Q.check(H3(Y,q)),Q.length=(Y,q)=>Q.check(G3(Y,q)),Q.unwrap=()=>Q.element});yz=j("ZodObject",(Q,$)=>{U$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>EY(Q,Y,q,J),z1.defineLazy(Q,"shape",()=>{return $.shape}),Q.keyof=()=>t1(Object.keys(Q._zod.def.shape)),Q.catchall=(Y)=>Q.clone({...Q._zod.def,catchall:Y}),Q.passthrough=()=>Q.clone({...Q._zod.def,catchall:I8()}),Q.loose=()=>Q.clone({...Q._zod.def,catchall:I8()}),Q.strict=()=>Q.clone({...Q._zod.def,catchall:xz()}),Q.strip=()=>Q.clone({...Q._zod.def,catchall:void 0}),Q.extend=(Y)=>{return z1.extend(Q,Y)},Q.safeExtend=(Y)=>{return z1.safeExtend(Q,Y)},Q.merge=(Y)=>z1.merge(Q,Y),Q.pick=(Y)=>z1.pick(Q,Y),Q.omit=(Y)=>z1.omit(Q,Y),Q.partial=(...Y)=>z1.partial(Uq,Q,Y[0]),Q.required=(...Y)=>z1.required(Vq,Q,Y[0])});hz=j("ZodUnion",(Q,$)=>{V$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>kY(Q,Y,q,J),Q.options=$.options});fz=j("ZodIntersection",(Q,$)=>{A$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>vY(Q,Y,q,J)});mz=j("ZodRecord",(Q,$)=>{L$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>PY(Q,Y,q,J),Q.keyType=$.keyType,Q.valueType=$.valueType});L4=j("ZodEnum",(Q,$)=>{F$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(q,J,X)=>NY(Q,q,J,X),Q.enum=$.entries,Q.options=Object.values($.entries);let Y=new Set(Object.keys($.entries));Q.extract=(q,J)=>{let X={};for(let H of q)if(Y.has(H))X[H]=$.entries[H];else throw Error(`Key ${H} not found in enum`);return new L4({...$,checks:[],...z1.normalizeParams(J),entries:X})},Q.exclude=(q,J)=>{let X={...$.entries};for(let H of q)if(Y.has(H))delete X[H];else throw Error(`Key ${H} not found in enum`);return new L4({...$,checks:[],...z1.normalizeParams(J),entries:X})}});gz=j("ZodLiteral",(Q,$)=>{j$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>TY(Q,Y,q,J),Q.values=new Set($.values),Object.defineProperty(Q,"value",{get(){if($.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return $.values[0]}})});cz=j("ZodTransform",(Q,$)=>{w$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>RY(Q,Y,q,J),Q._zod.parse=(Y,q)=>{if(q.direction==="backward")throw new t9(Q.constructor.name);Y.addIssue=(X)=>{if(typeof X==="string")Y.issues.push(z1.issue(X,Y.value,$));else{let H=X;if(H.fatal)H.continue=!1;H.code??(H.code="custom"),H.input??(H.input=Y.value),H.inst??(H.inst=Q),Y.issues.push(z1.issue(H))}};let J=$.transform(Y.value,Y);if(J instanceof Promise)return J.then((X)=>{return Y.value=X,Y});return Y.value=J,Y}});Uq=j("ZodOptional",(Q,$)=>{i7.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>B4(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});pz=j("ZodExactOptional",(Q,$)=>{D$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>B4(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});iz=j("ZodNullable",(Q,$)=>{O$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>xY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});nz=j("ZodDefault",(Q,$)=>{I$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>yY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType,Q.removeDefault=Q.unwrap});sz=j("ZodPrefault",(Q,$)=>{N$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>hY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});Vq=j("ZodNonOptional",(Q,$)=>{T$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>CY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});tz=j("ZodCatch",(Q,$)=>{b$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>fY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType,Q.removeCatch=Q.unwrap});QB=j("ZodPipe",(Q,$)=>{R$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>uY(Q,Y,q,J),Q.in=$.in,Q.out=$.out});$B=j("ZodReadonly",(Q,$)=>{S$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>mY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});qB=j("ZodCustom",(Q,$)=>{E$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>bY(Q,Y,q,J)})});var Aq;var Lq=A(()=>{(function(Q){})(Aq||(Aq={}))});var Fq=()=>{};var jq=A(()=>{o0();o0();v$();o7();Z4();Fq();M4();_4();V4();A4();Lq();O0(n7())});var H8=A(()=>{jq()});var Dq;var wq=A(()=>{Dq={name:"ocx",version:"2.0.8",description:"OCX CLI - OpenCode extension manager with portable, isolated profiles. Your setup, anywhere.",author:"kdcokenny",license:"MIT",type:"module",main:"./dist/index.js",bin:{ocx:"./dist/index.js"},files:["dist/index.js"],publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/kdcokenny/ocx.git"},homepage:"https://github.com/kdcokenny/ocx#readme",bugs:{url:"https://github.com/kdcokenny/ocx/issues"},keywords:["opencode","cli","extensions","agents","plugins","mcp","shadcn","registry"],engines:{bun:">=1.2.0"},scripts:{build:"bun run scripts/build.ts","build:binary":"bun run scripts/build-binary.ts","build:binary:all":"bun run scripts/build-binary.ts --all","build:binary:windows":"bun run scripts/build-binary.ts --target=windows-x64 && bun run scripts/build-binary.ts --target=windows-x64-baseline","release:tag":"bun run scripts/release-tag.ts",check:"bun check:biome && bun check:types","check:biome":"biome check .","check:types":"tsc --noEmit",dev:"bun run src/index.ts",prepublishOnly:"bun run build",test:"bun test","test:binary-smoke":"OCX_DIST_TESTS=1 bun test tests/binary-smoke.test.ts"},dependencies:{commander:"^14.0.3",fuzzysort:"^3.1.0","jsonc-parser":"3.3.1",kleur:"^4.1.5",ora:"^9.3.0",remeda:"^2.33.7",zod:"^4.3.6"},devDependencies:{"@types/bun":"^1.3.11"}}});function KB(Q){return`https://${_2}/schemas/v${Q}/registry.json`}var _2="ocx.kdco.dev",Oq="kdcokenny/ocx",j4,w4,y0=2,h0,Iq;var z3=A(()=>{wq();j4=`https://${_2}/schemas/ocx.json`,w4=`https://${_2}/schemas/registry.json`;h0=KB(y0),Iq=Dq.version});var G1,B1,_1,I1,h,L,u8,n1,m8,x1,f0,C1,N8,w9,u0,D9,D4;var t=A(()=>{G1={SUCCESS:0,GENERAL:1,NOT_FOUND:66,NETWORK:69,CONFIG:78,INTEGRITY:65,CONFLICT:6};B1=class B1 extends Error{code;exitCode;constructor(Q,$,Y=G1.GENERAL){super(Q);this.code=$;this.exitCode=Y;this.name="OCXError"}};_1=class _1 extends B1{constructor(Q){super(Q,"NOT_FOUND",G1.NOT_FOUND);this.name="NotFoundError"}};I1=class I1 extends B1{url;status;statusText;phase;qualifiedName;registryContext;registryName;constructor(Q,$){super(Q,"NETWORK_ERROR",G1.NETWORK);this.name="NetworkError",this.url=$?.url,this.status=$?.status,this.statusText=$?.statusText,this.phase=$?.phase,this.qualifiedName=$?.qualifiedName,this.registryContext=$?.registryContext,this.registryName=$?.registryName}};h=class h extends B1{constructor(Q){super(Q,"CONFIG_ERROR",G1.CONFIG);this.name="ConfigError"}};L=class L extends B1{constructor(Q){super(Q,"VALIDATION_ERROR",G1.GENERAL);this.name="ValidationError"}};u8=class u8 extends B1{details;constructor(Q){super("Registry validation failed","VALIDATION_FAILED",G1.CONFIG);this.details=Q;this.name="ValidationFailedError"}};n1=class n1 extends B1{constructor(Q){super(Q,"CONFLICT",G1.CONFLICT);this.name="ConflictError"}};m8=class m8 extends B1{component;expected;found;constructor(Q,$,Y){let q=`Integrity verification failed for "${Q}"
55
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let H of Q.seen.entries()){let G=H[1];if($===H[0]){X(H);continue}if(Q.external){let W=Q.external.registry.get(H[0])?.id;if($!==H[0]&&W){X(H);continue}}if(Q.metadataRegistry.get(H[0])?.id){X(H);continue}if(G.cycle){X(H);continue}if(G.count>1){if(Q.reused==="ref"){X(H);continue}}}}function z4(Q,$){let Y=Q.seen.get($);if(!Y)throw Error("Unprocessed schema. This is a bug in Zod.");let q=(H)=>{let G=Q.seen.get(H);if(G.ref===null)return;let K=G.def??G.schema,W={...K},z=G.ref;if(G.ref=null,z){q(z);let Z=Q.seen.get(z),M=Z.schema;if(M.$ref&&(Q.target==="draft-07"||Q.target==="draft-04"||Q.target==="openapi-3.0"))K.allOf=K.allOf??[],K.allOf.push(M);else Object.assign(K,M);if(Object.assign(K,W),H._zod.parent===z)for(let U in K){if(U==="$ref"||U==="allOf")continue;if(!(U in W))delete K[U]}if(M.$ref&&Z.def)for(let U in K){if(U==="$ref"||U==="allOf")continue;if(U in Z.def&&JSON.stringify(K[U])===JSON.stringify(Z.def[U]))delete K[U]}}let B=H._zod.parent;if(B&&B!==z){q(B);let Z=Q.seen.get(B);if(Z?.schema.$ref){if(K.$ref=Z.schema.$ref,Z.def)for(let M in K){if(M==="$ref"||M==="allOf")continue;if(M in Z.def&&JSON.stringify(K[M])===JSON.stringify(Z.def[M]))delete K[M]}}}Q.override({zodSchema:H,jsonSchema:K,path:G.path??[]})};for(let H of[...Q.seen.entries()].reverse())q(H[0]);let J={};if(Q.target==="draft-2020-12")J.$schema="https://json-schema.org/draft/2020-12/schema";else if(Q.target==="draft-07")J.$schema="http://json-schema.org/draft-07/schema#";else if(Q.target==="draft-04")J.$schema="http://json-schema.org/draft-04/schema#";else if(Q.target==="openapi-3.0");if(Q.external?.uri){let H=Q.external.registry.get($)?.id;if(!H)throw Error("Schema is missing an `id` property");J.$id=Q.external.uri(H)}Object.assign(J,Y.def??Y.schema);let X=Q.external?.defs??{};for(let H of Q.seen.entries()){let G=H[1];if(G.def&&G.defId)X[G.defId]=G.def}if(Q.external);else if(Object.keys(X).length>0)if(Q.target==="draft-2020-12")J.$defs=X;else J.definitions=X;try{let H=JSON.parse(JSON.stringify(J));return Object.defineProperty(H,"~standard",{value:{...$["~standard"],jsonSchema:{input:z2($,"input",Q.processors),output:z2($,"output",Q.processors)}},enumerable:!1,writable:!1}),H}catch(H){throw Error("Error converting schema to JSON.")}}function Y0(Q,$){let Y=$??{seen:new Set};if(Y.seen.has(Q))return!1;Y.seen.add(Q);let q=Q._zod.def;if(q.type==="transform")return!0;if(q.type==="array")return Y0(q.element,Y);if(q.type==="set")return Y0(q.valueType,Y);if(q.type==="lazy")return Y0(q.getter(),Y);if(q.type==="promise"||q.type==="optional"||q.type==="nonoptional"||q.type==="nullable"||q.type==="readonly"||q.type==="default"||q.type==="prefault")return Y0(q.innerType,Y);if(q.type==="intersection")return Y0(q.left,Y)||Y0(q.right,Y);if(q.type==="record"||q.type==="map")return Y0(q.keyType,Y)||Y0(q.valueType,Y);if(q.type==="pipe")return Y0(q.in,Y)||Y0(q.out,Y);if(q.type==="object"){for(let J in q.shape)if(Y0(q.shape[J],Y))return!0;return!1}if(q.type==="union"){for(let J of q.options)if(Y0(J,Y))return!0;return!1}if(q.type==="tuple"){for(let J of q.items)if(Y0(J,Y))return!0;if(q.rest&&Y0(q.rest,Y))return!0;return!1}return!1}var LY=(Q,$={})=>(Y)=>{let q=K4({...Y,processors:$});return m1(Q,q),W4(q,Q),z4(q,Q)},z2=(Q,$,Y={})=>(q)=>{let{libraryOptions:J,target:X}=q??{},H=K4({...J??{},target:X,io:$,processors:Y});return m1(Q,H),W4(H,Q),z4(H,Q)};var K3=A(()=>{s7()});var tW,FY=(Q,$,Y,q)=>{let J=Y;J.type="string";let{minimum:X,maximum:H,format:G,patterns:K,contentEncoding:W}=Q._zod.bag;if(typeof X==="number")J.minLength=X;if(typeof H==="number")J.maxLength=H;if(G){if(J.format=tW[G]??G,J.format==="")delete J.format;if(G==="time")delete J.format}if(W)J.contentEncoding=W;if(K&&K.size>0){let z=[...K];if(z.length===1)J.pattern=z[0].source;else if(z.length>1)J.allOf=[...z.map((B)=>({...$.target==="draft-07"||$.target==="draft-04"||$.target==="openapi-3.0"?{type:"string"}:{},pattern:B.source}))]}},jY=(Q,$,Y,q)=>{let J=Y,{minimum:X,maximum:H,format:G,multipleOf:K,exclusiveMaximum:W,exclusiveMinimum:z}=Q._zod.bag;if(typeof G==="string"&&G.includes("int"))J.type="integer";else J.type="number";if(typeof z==="number")if($.target==="draft-04"||$.target==="openapi-3.0")J.minimum=z,J.exclusiveMinimum=!0;else J.exclusiveMinimum=z;if(typeof X==="number"){if(J.minimum=X,typeof z==="number"&&$.target!=="draft-04")if(z>=X)delete J.minimum;else delete J.exclusiveMinimum}if(typeof W==="number")if($.target==="draft-04"||$.target==="openapi-3.0")J.maximum=W,J.exclusiveMaximum=!0;else J.exclusiveMaximum=W;if(typeof H==="number"){if(J.maximum=H,typeof W==="number"&&$.target!=="draft-04")if(W<=H)delete J.maximum;else delete J.exclusiveMaximum}if(typeof K==="number")J.multipleOf=K},wY=(Q,$,Y,q)=>{Y.type="boolean"},DY=(Q,$,Y,q)=>{Y.not={}},OY=(Q,$,Y,q)=>{},IY=(Q,$,Y,q)=>{},NY=(Q,$,Y,q)=>{let J=Q._zod.def,X=Q2(J.entries);if(X.every((H)=>typeof H==="number"))Y.type="number";if(X.every((H)=>typeof H==="string"))Y.type="string";Y.enum=X},TY=(Q,$,Y,q)=>{let J=Q._zod.def,X=[];for(let H of J.values)if(H===void 0){if($.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof H==="bigint")if($.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else X.push(Number(H));else X.push(H);if(X.length===0);else if(X.length===1){let H=X[0];if(Y.type=H===null?"null":typeof H,$.target==="draft-04"||$.target==="openapi-3.0")Y.enum=[H];else Y.const=H}else{if(X.every((H)=>typeof H==="number"))Y.type="number";if(X.every((H)=>typeof H==="string"))Y.type="string";if(X.every((H)=>typeof H==="boolean"))Y.type="boolean";if(X.every((H)=>H===null))Y.type="null";Y.enum=X}},bY=(Q,$,Y,q)=>{if($.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},RY=(Q,$,Y,q)=>{if($.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},SY=(Q,$,Y,q)=>{let J=Y,X=Q._zod.def,{minimum:H,maximum:G}=Q._zod.bag;if(typeof H==="number")J.minItems=H;if(typeof G==="number")J.maxItems=G;J.type="array",J.items=m1(X.element,$,{...q,path:[...q.path,"items"]})},EY=(Q,$,Y,q)=>{let J=Y,X=Q._zod.def;J.type="object",J.properties={};let H=X.shape;for(let W in H)J.properties[W]=m1(H[W],$,{...q,path:[...q.path,"properties",W]});let G=new Set(Object.keys(H)),K=new Set([...G].filter((W)=>{let z=X.shape[W]._zod;if($.io==="input")return z.optin===void 0;else return z.optout===void 0}));if(K.size>0)J.required=Array.from(K);if(X.catchall?._zod.def.type==="never")J.additionalProperties=!1;else if(!X.catchall){if($.io==="output")J.additionalProperties=!1}else if(X.catchall)J.additionalProperties=m1(X.catchall,$,{...q,path:[...q.path,"additionalProperties"]})},kY=(Q,$,Y,q)=>{let J=Q._zod.def,X=J.inclusive===!1,H=J.options.map((G,K)=>m1(G,$,{...q,path:[...q.path,X?"oneOf":"anyOf",K]}));if(X)Y.oneOf=H;else Y.anyOf=H},vY=(Q,$,Y,q)=>{let J=Q._zod.def,X=m1(J.left,$,{...q,path:[...q.path,"allOf",0]}),H=m1(J.right,$,{...q,path:[...q.path,"allOf",1]}),G=(W)=>("allOf"in W)&&Object.keys(W).length===1,K=[...G(X)?X.allOf:[X],...G(H)?H.allOf:[H]];Y.allOf=K},PY=(Q,$,Y,q)=>{let J=Y,X=Q._zod.def;J.type="object";let H=X.keyType,K=H._zod.bag?.patterns;if(X.mode==="loose"&&K&&K.size>0){let z=m1(X.valueType,$,{...q,path:[...q.path,"patternProperties","*"]});J.patternProperties={};for(let B of K)J.patternProperties[B.source]=z}else{if($.target==="draft-07"||$.target==="draft-2020-12")J.propertyNames=m1(X.keyType,$,{...q,path:[...q.path,"propertyNames"]});J.additionalProperties=m1(X.valueType,$,{...q,path:[...q.path,"additionalProperties"]})}let W=H._zod.values;if(W){let z=[...W].filter((B)=>typeof B==="string"||typeof B==="number");if(z.length>0)J.required=z}},xY=(Q,$,Y,q)=>{let J=Q._zod.def,X=m1(J.innerType,$,q),H=$.seen.get(Q);if($.target==="openapi-3.0")H.ref=J.innerType,Y.nullable=!0;else Y.anyOf=[X,{type:"null"}]},CY=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);X.ref=J.innerType},yY=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);X.ref=J.innerType,Y.default=JSON.parse(JSON.stringify(J.defaultValue))},hY=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);if(X.ref=J.innerType,$.io==="input")Y._prefault=JSON.parse(JSON.stringify(J.defaultValue))},fY=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);X.ref=J.innerType;let H;try{H=J.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}Y.default=H},uY=(Q,$,Y,q)=>{let J=Q._zod.def,X=$.io==="input"?J.in._zod.def.type==="transform"?J.out:J.in:J.out;m1(X,$,q);let H=$.seen.get(Q);H.ref=X},mY=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);X.ref=J.innerType,Y.readOnly=!0},B4=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);X.ref=J.innerType};var gY=A(()=>{K3();y0();tW={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""}});var cY=()=>{};var o0=A(()=>{y0();t2();o7();cY();U9();h7();y7();k$();e2();d7();s7();AY();K3()});var _4=A(()=>{o0()});function dY(Q){return JY(Xz,Q)}function pY(Q){return XY(Hz,Q)}function lY(Q){return HY(Gz,Q)}function iY(Q){return GY(Kz,Q)}var Xz,Hz,Gz,Kz;var Z4=A(()=>{o0();M4();Xz=j("ZodISODateTime",(Q,$)=>{oQ.init(Q,$),S1.init(Q,$)});Hz=j("ZodISODate",(Q,$)=>{sQ.init(Q,$),S1.init(Q,$)});Gz=j("ZodISOTime",(Q,$)=>{rQ.init(Q,$),S1.init(Q,$)});Kz=j("ZodISODuration",(Q,$)=>{aQ.init(Q,$),S1.init(Q,$)})});var oY=(Q,$)=>{n2.init(Q,$),Q.name="ZodError",Object.defineProperties(Q,{format:{value:(Y)=>k5(Q,Y)},flatten:{value:(Y)=>E5(Q,Y)},addIssue:{value:(Y)=>{Q.issues.push(Y),Q.message=JSON.stringify(Q.issues,A9,2)}},addIssues:{value:(Y)=>{Q.issues.push(...Y),Q.message=JSON.stringify(Q.issues,A9,2)}},isEmpty:{get(){return Q.issues.length===0}}})},U4,U0;var V4=A(()=>{o0();o0();y0();U4=j("ZodError",oY),U0=j("ZodError",oY,{Parent:Error})});var sY,rY,aY,tY,eY,Qq,$q,Yq,qq,Jq,Xq,Hq;var A4=A(()=>{o0();V4();sY=o2(U0),rY=s2(U0),aY=X2(U0),tY=H2(U0),eY=x5(U0),Qq=C5(U0),$q=y5(U0),Yq=h5(U0),qq=f5(U0),Jq=u5(U0),Xq=m5(U0),Hq=g5(U0)});function F(Q){return y$(Bz,Q)}function j9(Q){return KY(Zq,Q)}function Kq(Q){return WY(Sz,Q)}function i1(Q){return zY(Ez,Q)}function Mq(){return BY(kz)}function I8(){return _Y(vz)}function xz(Q){return ZY(Pz,Q)}function R1(Q,$){return MY(Cz,Q,$)}function Q1(Q,$){let Y={type:"object",shape:Q??{},...z1.normalizeParams($)};return new yz(Y)}function V0(Q,$){return new hz({type:"union",options:Q,...z1.normalizeParams($)})}function uz(Q,$){return new fz({type:"intersection",left:Q,right:$})}function q1(Q,$,Y){return new mz({type:"record",keyType:Q,valueType:$,...z1.normalizeParams(Y)})}function t1(Q,$){let Y=Array.isArray(Q)?Object.fromEntries(Q.map((q)=>[q,q])):Q;return new L4({type:"enum",entries:Y,...z1.normalizeParams($)})}function F4(Q,$){return new gz({type:"literal",values:Array.isArray(Q)?Q:[Q],...z1.normalizeParams($)})}function dz(Q){return new cz({type:"transform",transform:Q})}function Wq(Q){return new Uq({type:"optional",innerType:Q})}function lz(Q){return new pz({type:"optional",innerType:Q})}function zq(Q){return new iz({type:"nullable",innerType:Q})}function oz(Q,$){return new nz({type:"default",innerType:Q,get defaultValue(){return typeof $==="function"?$():z1.shallowClone($)}})}function rz(Q,$){return new sz({type:"prefault",innerType:Q,get defaultValue(){return typeof $==="function"?$():z1.shallowClone($)}})}function az(Q,$){return new Vq({type:"nonoptional",innerType:Q,...z1.normalizeParams($)})}function ez(Q,$){return new tz({type:"catch",innerType:Q,catchValue:typeof $==="function"?$:()=>$})}function Bq(Q,$){return new QB({type:"pipe",in:Q,out:$})}function YB(Q){return new $B({type:"readonly",innerType:Q})}function JB(Q,$={}){return UY(qB,Q,$)}function XB(Q){return VY(Q)}var E1,_q,Bz,S1,_z,Gq,W3,Zz,Mz,Uz,Vz,Az,Lz,Fz,jz,wz,Dz,Oz,Iz,Nz,Tz,bz,Rz,Zq,Sz,Ez,kz,vz,Pz,Cz,yz,hz,fz,mz,L4,gz,cz,Uq,pz,iz,nz,sz,Vq,tz,QB,$B,qB;var M4=A(()=>{o0();o0();gY();K3();_4();Z4();A4();E1=j("ZodType",(Q,$)=>{return T1.init(Q,$),Object.assign(Q["~standard"],{jsonSchema:{input:z2(Q,"input"),output:z2(Q,"output")}}),Q.toJSONSchema=LY(Q,{}),Q.def=$,Q.type=$.type,Object.defineProperty(Q,"_def",{value:$}),Q.check=(...Y)=>{return Q.clone(z1.mergeDefs($,{checks:[...$.checks??[],...Y.map((q)=>typeof q==="function"?{_zod:{check:q,def:{check:"custom"},onattach:[]}}:q)]}),{parent:!0})},Q.with=Q.check,Q.clone=(Y,q)=>x0(Q,Y,q),Q.brand=()=>Q,Q.register=(Y,q)=>{return Y.add(Q,q),Q},Q.parse=(Y,q)=>sY(Q,Y,q,{callee:Q.parse}),Q.safeParse=(Y,q)=>aY(Q,Y,q),Q.parseAsync=async(Y,q)=>rY(Q,Y,q,{callee:Q.parseAsync}),Q.safeParseAsync=async(Y,q)=>tY(Q,Y,q),Q.spa=Q.safeParseAsync,Q.encode=(Y,q)=>eY(Q,Y,q),Q.decode=(Y,q)=>Qq(Q,Y,q),Q.encodeAsync=async(Y,q)=>$q(Q,Y,q),Q.decodeAsync=async(Y,q)=>Yq(Q,Y,q),Q.safeEncode=(Y,q)=>qq(Q,Y,q),Q.safeDecode=(Y,q)=>Jq(Q,Y,q),Q.safeEncodeAsync=async(Y,q)=>Xq(Q,Y,q),Q.safeDecodeAsync=async(Y,q)=>Hq(Q,Y,q),Q.refine=(Y,q)=>Q.check(JB(Y,q)),Q.superRefine=(Y)=>Q.check(XB(Y)),Q.overwrite=(Y)=>Q.check(O8(Y)),Q.optional=()=>Wq(Q),Q.exactOptional=()=>lz(Q),Q.nullable=()=>zq(Q),Q.nullish=()=>Wq(zq(Q)),Q.nonoptional=(Y)=>az(Q,Y),Q.array=()=>R1(Q),Q.or=(Y)=>V0([Q,Y]),Q.and=(Y)=>uz(Q,Y),Q.transform=(Y)=>Bq(Q,dz(Y)),Q.default=(Y)=>oz(Q,Y),Q.prefault=(Y)=>rz(Q,Y),Q.catch=(Y)=>ez(Q,Y),Q.pipe=(Y)=>Bq(Q,Y),Q.readonly=()=>YB(Q),Q.describe=(Y)=>{let q=Q.clone();return f8.add(q,{description:Y}),q},Object.defineProperty(Q,"description",{get(){return f8.get(Q)?.description},configurable:!0}),Q.meta=(...Y)=>{if(Y.length===0)return f8.get(Q);let q=Q.clone();return f8.add(q,Y[0]),q},Q.isOptional=()=>Q.safeParse(void 0).success,Q.isNullable=()=>Q.safeParse(null).success,Q.apply=(Y)=>Y(Q),Q}),_q=j("_ZodString",(Q,$)=>{Y3.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(q,J,X)=>FY(Q,q,J,X);let Y=Q._zod.bag;Q.format=Y.format??null,Q.minLength=Y.minimum??null,Q.maxLength=Y.maximum??null,Q.regex=(...q)=>Q.check(a7(...q)),Q.includes=(...q)=>Q.check(Q4(...q)),Q.startsWith=(...q)=>Q.check($4(...q)),Q.endsWith=(...q)=>Q.check(Y4(...q)),Q.min=(...q)=>Q.check(F9(...q)),Q.max=(...q)=>Q.check(H3(...q)),Q.length=(...q)=>Q.check(G3(...q)),Q.nonempty=(...q)=>Q.check(F9(1,...q)),Q.lowercase=(q)=>Q.check(t7(q)),Q.uppercase=(q)=>Q.check(e7(q)),Q.trim=()=>Q.check(J4()),Q.normalize=(...q)=>Q.check(q4(...q)),Q.toLowerCase=()=>Q.check(X4()),Q.toUpperCase=()=>Q.check(H4()),Q.slugify=()=>Q.check(G4())}),Bz=j("ZodString",(Q,$)=>{Y3.init(Q,$),_q.init(Q,$),Q.email=(Y)=>Q.check(h$(_z,Y)),Q.url=(Y)=>Q.check(c$(Zz,Y)),Q.jwt=(Y)=>Q.check(qY(Rz,Y)),Q.emoji=(Y)=>Q.check(d$(Mz,Y)),Q.guid=(Y)=>Q.check(r7(Gq,Y)),Q.uuid=(Y)=>Q.check(f$(W3,Y)),Q.uuidv4=(Y)=>Q.check(u$(W3,Y)),Q.uuidv6=(Y)=>Q.check(m$(W3,Y)),Q.uuidv7=(Y)=>Q.check(g$(W3,Y)),Q.nanoid=(Y)=>Q.check(p$(Uz,Y)),Q.guid=(Y)=>Q.check(r7(Gq,Y)),Q.cuid=(Y)=>Q.check(l$(Vz,Y)),Q.cuid2=(Y)=>Q.check(i$(Az,Y)),Q.ulid=(Y)=>Q.check(n$(Lz,Y)),Q.base64=(Y)=>Q.check(QY(Nz,Y)),Q.base64url=(Y)=>Q.check($Y(Tz,Y)),Q.xid=(Y)=>Q.check(o$(Fz,Y)),Q.ksuid=(Y)=>Q.check(s$(jz,Y)),Q.ipv4=(Y)=>Q.check(r$(wz,Y)),Q.ipv6=(Y)=>Q.check(a$(Dz,Y)),Q.cidrv4=(Y)=>Q.check(t$(Oz,Y)),Q.cidrv6=(Y)=>Q.check(e$(Iz,Y)),Q.e164=(Y)=>Q.check(YY(bz,Y)),Q.datetime=(Y)=>Q.check(dY(Y)),Q.date=(Y)=>Q.check(pY(Y)),Q.time=(Y)=>Q.check(lY(Y)),Q.duration=(Y)=>Q.check(iY(Y))});S1=j("ZodStringFormat",(Q,$)=>{b1.init(Q,$),_q.init(Q,$)}),_z=j("ZodEmail",(Q,$)=>{uQ.init(Q,$),S1.init(Q,$)}),Gq=j("ZodGUID",(Q,$)=>{hQ.init(Q,$),S1.init(Q,$)}),W3=j("ZodUUID",(Q,$)=>{fQ.init(Q,$),S1.init(Q,$)}),Zz=j("ZodURL",(Q,$)=>{mQ.init(Q,$),S1.init(Q,$)}),Mz=j("ZodEmoji",(Q,$)=>{gQ.init(Q,$),S1.init(Q,$)}),Uz=j("ZodNanoID",(Q,$)=>{cQ.init(Q,$),S1.init(Q,$)}),Vz=j("ZodCUID",(Q,$)=>{dQ.init(Q,$),S1.init(Q,$)}),Az=j("ZodCUID2",(Q,$)=>{pQ.init(Q,$),S1.init(Q,$)}),Lz=j("ZodULID",(Q,$)=>{lQ.init(Q,$),S1.init(Q,$)}),Fz=j("ZodXID",(Q,$)=>{iQ.init(Q,$),S1.init(Q,$)}),jz=j("ZodKSUID",(Q,$)=>{nQ.init(Q,$),S1.init(Q,$)}),wz=j("ZodIPv4",(Q,$)=>{tQ.init(Q,$),S1.init(Q,$)}),Dz=j("ZodIPv6",(Q,$)=>{eQ.init(Q,$),S1.init(Q,$)}),Oz=j("ZodCIDRv4",(Q,$)=>{Q$.init(Q,$),S1.init(Q,$)}),Iz=j("ZodCIDRv6",(Q,$)=>{$$.init(Q,$),S1.init(Q,$)}),Nz=j("ZodBase64",(Q,$)=>{q$.init(Q,$),S1.init(Q,$)}),Tz=j("ZodBase64URL",(Q,$)=>{J$.init(Q,$),S1.init(Q,$)}),bz=j("ZodE164",(Q,$)=>{X$.init(Q,$),S1.init(Q,$)}),Rz=j("ZodJWT",(Q,$)=>{H$.init(Q,$),S1.init(Q,$)}),Zq=j("ZodNumber",(Q,$)=>{l7.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(q,J,X)=>jY(Q,q,J,X),Q.gt=(q,J)=>Q.check(J3(q,J)),Q.gte=(q,J)=>Q.check(W2(q,J)),Q.min=(q,J)=>Q.check(W2(q,J)),Q.lt=(q,J)=>Q.check(q3(q,J)),Q.lte=(q,J)=>Q.check(K2(q,J)),Q.max=(q,J)=>Q.check(K2(q,J)),Q.int=(q)=>Q.check(Kq(q)),Q.safe=(q)=>Q.check(Kq(q)),Q.positive=(q)=>Q.check(J3(0,q)),Q.nonnegative=(q)=>Q.check(W2(0,q)),Q.negative=(q)=>Q.check(q3(0,q)),Q.nonpositive=(q)=>Q.check(K2(0,q)),Q.multipleOf=(q,J)=>Q.check(X3(q,J)),Q.step=(q,J)=>Q.check(X3(q,J)),Q.finite=()=>Q;let Y=Q._zod.bag;Q.minValue=Math.max(Y.minimum??Number.NEGATIVE_INFINITY,Y.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,Q.maxValue=Math.min(Y.maximum??Number.POSITIVE_INFINITY,Y.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,Q.isInt=(Y.format??"").includes("int")||Number.isSafeInteger(Y.multipleOf??0.5),Q.isFinite=!0,Q.format=Y.format??null});Sz=j("ZodNumberFormat",(Q,$)=>{G$.init(Q,$),Zq.init(Q,$)});Ez=j("ZodBoolean",(Q,$)=>{K$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>wY(Q,Y,q,J)});kz=j("ZodAny",(Q,$)=>{W$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>OY(Q,Y,q,J)});vz=j("ZodUnknown",(Q,$)=>{z$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>IY(Q,Y,q,J)});Pz=j("ZodNever",(Q,$)=>{B$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>DY(Q,Y,q,J)});Cz=j("ZodArray",(Q,$)=>{_$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>SY(Q,Y,q,J),Q.element=$.element,Q.min=(Y,q)=>Q.check(F9(Y,q)),Q.nonempty=(Y)=>Q.check(F9(1,Y)),Q.max=(Y,q)=>Q.check(H3(Y,q)),Q.length=(Y,q)=>Q.check(G3(Y,q)),Q.unwrap=()=>Q.element});yz=j("ZodObject",(Q,$)=>{U$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>EY(Q,Y,q,J),z1.defineLazy(Q,"shape",()=>{return $.shape}),Q.keyof=()=>t1(Object.keys(Q._zod.def.shape)),Q.catchall=(Y)=>Q.clone({...Q._zod.def,catchall:Y}),Q.passthrough=()=>Q.clone({...Q._zod.def,catchall:I8()}),Q.loose=()=>Q.clone({...Q._zod.def,catchall:I8()}),Q.strict=()=>Q.clone({...Q._zod.def,catchall:xz()}),Q.strip=()=>Q.clone({...Q._zod.def,catchall:void 0}),Q.extend=(Y)=>{return z1.extend(Q,Y)},Q.safeExtend=(Y)=>{return z1.safeExtend(Q,Y)},Q.merge=(Y)=>z1.merge(Q,Y),Q.pick=(Y)=>z1.pick(Q,Y),Q.omit=(Y)=>z1.omit(Q,Y),Q.partial=(...Y)=>z1.partial(Uq,Q,Y[0]),Q.required=(...Y)=>z1.required(Vq,Q,Y[0])});hz=j("ZodUnion",(Q,$)=>{V$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>kY(Q,Y,q,J),Q.options=$.options});fz=j("ZodIntersection",(Q,$)=>{A$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>vY(Q,Y,q,J)});mz=j("ZodRecord",(Q,$)=>{L$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>PY(Q,Y,q,J),Q.keyType=$.keyType,Q.valueType=$.valueType});L4=j("ZodEnum",(Q,$)=>{F$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(q,J,X)=>NY(Q,q,J,X),Q.enum=$.entries,Q.options=Object.values($.entries);let Y=new Set(Object.keys($.entries));Q.extract=(q,J)=>{let X={};for(let H of q)if(Y.has(H))X[H]=$.entries[H];else throw Error(`Key ${H} not found in enum`);return new L4({...$,checks:[],...z1.normalizeParams(J),entries:X})},Q.exclude=(q,J)=>{let X={...$.entries};for(let H of q)if(Y.has(H))delete X[H];else throw Error(`Key ${H} not found in enum`);return new L4({...$,checks:[],...z1.normalizeParams(J),entries:X})}});gz=j("ZodLiteral",(Q,$)=>{j$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>TY(Q,Y,q,J),Q.values=new Set($.values),Object.defineProperty(Q,"value",{get(){if($.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return $.values[0]}})});cz=j("ZodTransform",(Q,$)=>{w$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>RY(Q,Y,q,J),Q._zod.parse=(Y,q)=>{if(q.direction==="backward")throw new t9(Q.constructor.name);Y.addIssue=(X)=>{if(typeof X==="string")Y.issues.push(z1.issue(X,Y.value,$));else{let H=X;if(H.fatal)H.continue=!1;H.code??(H.code="custom"),H.input??(H.input=Y.value),H.inst??(H.inst=Q),Y.issues.push(z1.issue(H))}};let J=$.transform(Y.value,Y);if(J instanceof Promise)return J.then((X)=>{return Y.value=X,Y});return Y.value=J,Y}});Uq=j("ZodOptional",(Q,$)=>{i7.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>B4(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});pz=j("ZodExactOptional",(Q,$)=>{D$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>B4(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});iz=j("ZodNullable",(Q,$)=>{O$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>xY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});nz=j("ZodDefault",(Q,$)=>{I$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>yY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType,Q.removeDefault=Q.unwrap});sz=j("ZodPrefault",(Q,$)=>{N$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>hY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});Vq=j("ZodNonOptional",(Q,$)=>{T$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>CY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});tz=j("ZodCatch",(Q,$)=>{b$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>fY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType,Q.removeCatch=Q.unwrap});QB=j("ZodPipe",(Q,$)=>{R$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>uY(Q,Y,q,J),Q.in=$.in,Q.out=$.out});$B=j("ZodReadonly",(Q,$)=>{S$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>mY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});qB=j("ZodCustom",(Q,$)=>{E$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>bY(Q,Y,q,J)})});var Aq;var Lq=A(()=>{(function(Q){})(Aq||(Aq={}))});var Fq=()=>{};var jq=A(()=>{o0();o0();v$();o7();Z4();Fq();M4();_4();V4();A4();Lq();I0(n7())});var H8=A(()=>{jq()});var Dq;var wq=A(()=>{Dq={name:"ocx",version:"2.0.9",description:"OCX CLI - OpenCode extension manager with portable, isolated profiles. Your setup, anywhere.",author:"kdcokenny",license:"MIT",type:"module",main:"./dist/index.js",bin:{ocx:"./dist/index.js"},files:["dist/index.js"],publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/kdcokenny/ocx.git"},homepage:"https://github.com/kdcokenny/ocx#readme",bugs:{url:"https://github.com/kdcokenny/ocx/issues"},keywords:["opencode","cli","extensions","agents","plugins","mcp","shadcn","registry"],engines:{bun:">=1.2.0"},scripts:{build:"bun run scripts/build.ts","build:binary":"bun run scripts/build-binary.ts","build:binary:all":"bun run scripts/build-binary.ts --all","build:binary:windows":"bun run scripts/build-binary.ts --target=windows-x64 && bun run scripts/build-binary.ts --target=windows-x64-baseline","release:tag":"bun run scripts/release-tag.ts",check:"bun check:biome && bun check:types","check:biome":"biome check .","check:types":"tsc --noEmit",dev:"bun run src/index.ts",prepublishOnly:"bun run build",test:"bun test","test:binary-smoke":"OCX_DIST_TESTS=1 bun test tests/binary-smoke.test.ts"},dependencies:{commander:"^14.0.3",fuzzysort:"^3.1.0","jsonc-parser":"3.3.1",kleur:"^4.1.5",ora:"^9.3.0",remeda:"^2.33.7",zod:"^4.3.6"},devDependencies:{"@types/bun":"^1.3.11"}}});function KB(Q){return`https://${_2}/schemas/v${Q}/registry.json`}var _2="ocx.kdco.dev",Oq="kdcokenny/ocx",j4,w4,h0=2,f0,Iq;var z3=A(()=>{wq();j4=`https://${_2}/schemas/ocx.json`,w4=`https://${_2}/schemas/registry.json`;f0=KB(h0),Iq=Dq.version});var G1,B1,_1,I1,h,L,u8,n1,m8,x1,u0,C1,N8,w9,m0,D9,D4;var t=A(()=>{G1={SUCCESS:0,GENERAL:1,NOT_FOUND:66,NETWORK:69,CONFIG:78,INTEGRITY:65,CONFLICT:6};B1=class B1 extends Error{code;exitCode;constructor(Q,$,Y=G1.GENERAL){super(Q);this.code=$;this.exitCode=Y;this.name="OCXError"}};_1=class _1 extends B1{constructor(Q){super(Q,"NOT_FOUND",G1.NOT_FOUND);this.name="NotFoundError"}};I1=class I1 extends B1{url;status;statusText;phase;qualifiedName;registryContext;registryName;constructor(Q,$){super(Q,"NETWORK_ERROR",G1.NETWORK);this.name="NetworkError",this.url=$?.url,this.status=$?.status,this.statusText=$?.statusText,this.phase=$?.phase,this.qualifiedName=$?.qualifiedName,this.registryContext=$?.registryContext,this.registryName=$?.registryName}};h=class h extends B1{constructor(Q){super(Q,"CONFIG_ERROR",G1.CONFIG);this.name="ConfigError"}};L=class L extends B1{constructor(Q){super(Q,"VALIDATION_ERROR",G1.GENERAL);this.name="ValidationError"}};u8=class u8 extends B1{details;constructor(Q){super("Registry validation failed","VALIDATION_FAILED",G1.CONFIG);this.details=Q;this.name="ValidationFailedError"}};n1=class n1 extends B1{constructor(Q){super(Q,"CONFLICT",G1.CONFLICT);this.name="ConflictError"}};m8=class m8 extends B1{component;expected;found;constructor(Q,$,Y){let q=`Integrity verification failed for "${Q}"
56
56
  Expected: ${$}
57
57
  Found: ${Y}
58
58
 
59
59
  The registry content has changed since this component was locked.
60
- Use 'ocx update ${Q}' to intentionally update this component.`;super(q,"INTEGRITY_ERROR",G1.INTEGRITY);this.component=Q;this.expected=$;this.found=Y;this.name="IntegrityError"}};x1=class x1 extends B1{constructor(Q){super(Q,"UPDATE_ERROR",G1.GENERAL);this.name="SelfUpdateError"}};f0=class f0 extends B1{url;issue;remediation;schemaUrl;supportedMajor;detectedMajor;constructor(Q,$){super(Q,"REGISTRY_COMPAT_ERROR",G1.CONFIG);this.name="RegistryCompatibilityError",this.url=$.url,this.issue=$.issue,this.remediation=$.remediation,this.schemaUrl=$.schemaUrl,this.supportedMajor=$.supportedMajor,this.detectedMajor=$.detectedMajor}};C1=class C1 extends B1{profile;constructor(Q,$){let Y=$??`Profile "${Q}" not found`;super(Y,"NOT_FOUND",G1.NOT_FOUND);this.profile=Q;this.name="ProfileNotFoundError"}};N8=class N8 extends B1{profile;constructor(Q,$){let Y=$?`Profile "${Q}" already exists. ${$}`:`Profile "${Q}" already exists.`;super(Y,"CONFLICT",G1.CONFLICT);this.profile=Q;this.name="ProfileExistsError"}};w9=class w9 extends B1{registryName;existingUrl;newUrl;targetLabel;existingName;conflictType;constructor(Q,$,Y,q,J){let X=q?` in ${q}`:"",H=J!==void 0&&J!==Q,G=H?`Registry URL already registered under name "${J}"${X}.
60
+ Use 'ocx update ${Q}' to intentionally update this component.`;super(q,"INTEGRITY_ERROR",G1.INTEGRITY);this.component=Q;this.expected=$;this.found=Y;this.name="IntegrityError"}};x1=class x1 extends B1{constructor(Q){super(Q,"UPDATE_ERROR",G1.GENERAL);this.name="SelfUpdateError"}};u0=class u0 extends B1{url;issue;remediation;schemaUrl;supportedMajor;detectedMajor;constructor(Q,$){super(Q,"REGISTRY_COMPAT_ERROR",G1.CONFIG);this.name="RegistryCompatibilityError",this.url=$.url,this.issue=$.issue,this.remediation=$.remediation,this.schemaUrl=$.schemaUrl,this.supportedMajor=$.supportedMajor,this.detectedMajor=$.detectedMajor}};C1=class C1 extends B1{profile;constructor(Q,$){let Y=$??`Profile "${Q}" not found`;super(Y,"NOT_FOUND",G1.NOT_FOUND);this.profile=Q;this.name="ProfileNotFoundError"}};N8=class N8 extends B1{profile;constructor(Q,$){let Y=$?`Profile "${Q}" already exists. ${$}`:`Profile "${Q}" already exists.`;super(Y,"CONFLICT",G1.CONFLICT);this.profile=Q;this.name="ProfileExistsError"}};w9=class w9 extends B1{registryName;existingUrl;newUrl;targetLabel;existingName;conflictType;constructor(Q,$,Y,q,J){let X=q?` in ${q}`:"",H=J!==void 0&&J!==Q,G=H?`Registry URL already registered under name "${J}"${X}.
61
61
  URL: ${$}
62
62
  Existing name: ${J}
63
63
  Requested name: ${Q}
@@ -66,12 +66,12 @@ Run 'ocx registry remove ${J}' first, then re-add with the new name.`:`Registry
66
66
  Current: ${$}
67
67
  New: ${Y}
68
68
 
69
- Run 'ocx registry remove ${Q}' first, then re-add with the new URL.`;super(G,"CONFLICT",G1.CONFLICT);this.registryName=Q;this.existingUrl=$;this.newUrl=Y;this.targetLabel=q;this.existingName=J;this.name="RegistryExistsError",this.conflictType=H?"url":"name"}};u0=class u0 extends B1{profile;reason;constructor(Q,$){super(`Invalid profile name "${Q}": ${$}`,"VALIDATION_ERROR",G1.GENERAL);this.profile=Q;this.reason=$;this.name="InvalidProfileNameError"}};D9=class D9 extends B1{constructor(){super("Profiles not initialized. Run 'ocx init --global' first.","NOT_FOUND",G1.NOT_FOUND);this.name="ProfilesNotInitializedError"}};D4=class D4 extends B1{profile;localDir;constructor(Q,$){super(`Local profile directory unsupported: "${$}"
69
+ Run 'ocx registry remove ${Q}' first, then re-add with the new URL.`;super(G,"CONFLICT",G1.CONFLICT);this.registryName=Q;this.existingUrl=$;this.newUrl=Y;this.targetLabel=q;this.existingName=J;this.name="RegistryExistsError",this.conflictType=H?"url":"name"}};m0=class m0 extends B1{profile;reason;constructor(Q,$){super(`Invalid profile name "${Q}": ${$}`,"VALIDATION_ERROR",G1.GENERAL);this.profile=Q;this.reason=$;this.name="InvalidProfileNameError"}};D9=class D9 extends B1{constructor(){super("Profiles not initialized. Run 'ocx init --global' first.","NOT_FOUND",G1.NOT_FOUND);this.name="ProfilesNotInitializedError"}};D4=class D4 extends B1{profile;localDir;constructor(Q,$){super(`Local profile directory unsupported: "${$}"
70
70
 
71
71
  Local profiles are not supported. Profiles must be global only.
72
72
  Remove the local profile directory and use global profiles instead:
73
73
  rm -rf "${$}"
74
- ocx profile show ${Q} --global`,"CONFIG_ERROR",G1.CONFIG);this.profile=Q;this.localDir=$;this.name="LocalProfileUnsupportedError"}}});import*as I0 from"path";function V0(Q,$){if($.includes("\x00"))throw new e1("Path contains null bytes",$,"null_byte");if(I0.isAbsolute($)||I0.win32.isAbsolute($))throw new e1("Path must be relative",$,"absolute_path");if(/^[a-zA-Z]:/.test($)||$.startsWith("\\\\"))throw new e1("Path contains Windows absolute",$,"windows_absolute");let Y=I0.basename($).toUpperCase().split(".")[0]??"";if(WB.has(Y))throw new e1("Path uses Windows reserved name",$,"windows_reserved");let J=$.normalize("NFC").replace(/\\/g,"/"),X=I0.resolve(Q),H=I0.resolve(X,J),G=I0.relative(X,H);if(G.startsWith("../")||G.startsWith("..\\")||G===".."||I0.isAbsolute(G))throw new e1("Path escapes base directory",$,"path_traversal");return H}var e1,WB;var g8=A(()=>{e1=class e1 extends Error{attemptedPath;reason;constructor(Q,$,Y){super(Q);this.attemptedPath=$;this.reason=Y;this.name="PathValidationError"}};WB=new Set(["CON","PRN","AUX","NUL","COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"])});import{isAbsolute as zB,normalize as Tq}from"path";function m0(Q){if(!Q.includes("/"))throw Error(`Invalid component reference: "${Q}". Use format: alias/component`);let $=Q.split("/");if($.length>2)throw Error(`Invalid component reference: "${Q}". Too many "/" separators. Use format: alias/component`);let[Y,q]=$;if(!Y||!q)throw Error(`Invalid component reference: "${Q}". Both alias and component are required.`);return{namespace:Y,component:q}}function N4(Q,$){return`${Q}/${$}`}function O4(Q){if(zB(Q))throw new L(`Invalid path: "${Q}" - absolute paths not allowed`);if(Q.startsWith("~"))throw new L(`Invalid path: "${Q}" - home directory paths not allowed`);if(Tq(Q).startsWith(".."))throw new L(`Invalid path: "${Q}" - path traversal not allowed`)}function yq(Q){return Q}function Nq(Q,$){if(BB.has(Q))throw new L(`Target "${Q}" is reserved for installer use`);try{V0("/dummy/base",Q)}catch(q){if(q instanceof e1)throw new L(`Invalid target "${Q}": ${q.message}`);throw q}if($!=="profile"){let q=Tq(Q);if(Rq.some((X)=>q===X||q.startsWith(X)))throw new L(`Target path '${Q}' is protected and cannot be overwritten by registry components`)}}function T8(Q,$){if(typeof Q==="string"){O4(Q);let Y=yq(Q);return Nq(Y,$),{path:Q,target:Y}}return O4(Q.path),O4(Q.target),Nq(Q.target,$),Q}function hq(Q){if(typeof Q==="string")return{type:"remote",url:Q,enabled:!0};return Q}function d8(Q){let $;if(Q.opencode){let{mcp:Y,...q}=Q.opencode;$={...q,...Y&&{mcp:Object.fromEntries(Object.entries(Y).map(([J,X])=>[J,hq(X)]))}}}return{...Q,files:Q.files.map((Y)=>T8(Y,Q.type)),opencode:$}}function I9(Q){if(Q===null||Q===void 0||typeof Q!=="object")return null;let $=Q;if(!Object.hasOwn($,"$schema"))return{issue:"legacy-schema-v1",remediation:`This registry uses legacy schema v1 (missing $schema). Set "$schema" to "${h0}".`,supportedMajor:y0};let q=$.$schema;if(typeof q!=="string")return{issue:"invalid-schema-url",remediation:`Registry $schema must be a canonical URL like "${h0}".`,schemaUrl:String(q),supportedMajor:y0};if(!q)return{issue:"invalid-schema-url",remediation:`Registry $schema must be a canonical URL like "${h0}".`,schemaUrl:q,supportedMajor:y0};if(q===w4)return{issue:"legacy-schema-v1",remediation:`Schema URL "${w4}" is legacy v1. Use "${h0}" instead.`,schemaUrl:q,supportedMajor:y0};let J=q.match(DB);if(!J)return{issue:"invalid-schema-url",remediation:`Registry $schema must be a canonical URL like "${h0}".`,schemaUrl:q,supportedMajor:y0};let X=J[1];if(!X)return{issue:"invalid-schema-url",remediation:`Registry $schema must be a canonical URL like "${h0}".`,schemaUrl:q,supportedMajor:y0};let H=Number.parseInt(X,10);if(H!==y0)return{issue:"unsupported-schema-version",remediation:`Schema major v${H} is unsupported. Use "${h0}" (v${y0}).`,schemaUrl:q,supportedMajor:y0,detectedMajor:H};return null}var xw,B3,I4,bq,O9,BB,Rq,_B,ZB,Sq,Eq,kq,vq,MB,UB,VB,AB,LB,FB,jB,wB,Pq,xq,Cq,c8,DB,Z2,p8,M2,T4;var g0=A(()=>{H8();z3();t();g8();xw=F().refine((Q)=>Q.startsWith("npm:"),{message:'npm specifier must start with "npm:" prefix'}).refine((Q)=>{let $=Q.slice(4);if(!$)return!1;if($.includes("..")||$.includes("/./"))return!1;return!0},{message:"Invalid npm specifier format"}),B3=F().min(1,"Name cannot be empty").max(64,"Name cannot exceed 64 characters").regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,{message:"Must be lowercase alphanumeric with single hyphen separators (e.g., 'my-component', 'my-plugin'). Cannot start/end with hyphen or have consecutive hyphens."}),I4=F().regex(/^[a-z0-9]+(-[a-z0-9]+)*\/[a-z0-9]+(-[a-z0-9]+)*$/,{message:'Must be in format "alias/component" (e.g., "kdco/researcher"). Both parts must be lowercase alphanumeric with hyphens.'});bq=F().refine((Q)=>{let $=/^[a-z0-9]+(-[a-z0-9]+)*$/,Y=/^[a-z0-9]+(-[a-z0-9]+)*\/[a-z0-9]+(-[a-z0-9]+)*$/;return $.test(Q)||Y.test(Q)},{message:'Dependency must be either a bare name (e.g., "utils") or qualified (e.g., "acme/utils")'}),O9=t1(["agent","skill","plugin","command","tool","bundle","profile"]),BB=new Set([".ocx","ocx.lock"]),Rq=[".ocx/","ocx.jsonc","package.json",".git/",".env","node_modules/"],_B=F().min(1,"Target path cannot be empty").refine((Q)=>{if(Q.startsWith("/")||/^[a-zA-Z]:/.test(Q))return!1;if(Q.includes("\x00"))return!1;return!0},{message:"Target path must be relative and safe (no absolute paths or null bytes)"}).refine((Q)=>{return!Rq.some(($)=>Q===$||Q.startsWith($))},{message:"Target path is protected and cannot be overwritten by registry components"}),ZB=Q1({clientId:F().optional(),scopes:R1(F()).optional(),authUrl:F().optional(),tokenUrl:F().optional()}),Sq=Q1({type:t1(["remote","local"]),url:F().optional(),command:U0([F(),R1(F())]).optional(),environment:q1(F(),F()).optional(),headers:q1(F(),F()).optional(),oauth:U0([i1(),ZB]).optional(),enabled:i1().default(!0)}).refine((Q)=>{if(Q.type==="remote"&&!Q.url)return!1;if(Q.type==="local"&&!Q.command)return!1;return!0},{message:"Remote MCP servers require 'url', local servers require 'command'"}),Eq=U0([F(),Sq]),kq=Q1({path:F().min(1,"File path cannot be empty"),target:F().min(1,"Target path cannot be empty")}),vq=U0([F().min(1,"File path cannot be empty"),kq]),MB=Q1({api:F().optional(),headers:q1(F(),F()).optional(),env:q1(F(),F()).optional(),enabled:i1().optional()}).passthrough(),UB=Q1({command:U0([F(),R1(F())]).optional(),enabled:i1().optional()}).passthrough(),VB=Q1({command:U0([F(),R1(F())]).optional(),glob:F().optional()}).passthrough(),AB=Q1({description:F().optional(),run:F().optional()}).passthrough(),LB=Q1({disabled:i1().optional()}).passthrough(),FB=Q1({host:F().optional(),port:j9().optional()}).passthrough(),jB=q1(F(),F()),wB=Q1({include:R1(F()).optional(),exclude:R1(F()).optional()}).passthrough(),Pq=Q1({model:F().optional(),description:F().optional(),steps:j9().int().positive().optional(),maxSteps:j9().int().positive().optional(),mode:t1(["primary","subagent","all"]).optional(),tools:q1(F(),i1()).optional(),temperature:j9().optional(),top_p:j9().optional(),prompt:F().optional(),permission:q1(F(),U0([t1(["ask","allow","deny"]),q1(F(),t1(["ask","allow","deny"]))])).optional(),color:F().optional(),disable:i1().optional(),options:q1(F(),Mq()).optional()}),xq=Q1({bash:U0([t1(["ask","allow","deny"]),q1(F(),t1(["ask","allow","deny"]))]).optional(),edit:U0([t1(["ask","allow","deny"]),q1(F(),t1(["ask","allow","deny"]))]).optional(),mcp:q1(F(),t1(["ask","allow","deny"])).optional()}).catchall(U0([t1(["ask","allow","deny"]),q1(F(),t1(["ask","allow","deny"]))])),Cq=Q1({$schema:F().optional(),theme:F().optional(),logLevel:F().optional(),username:F().optional(),model:F().optional(),small_model:F().optional(),default_agent:F().optional(),mcp:q1(F(),Eq).optional(),plugin:R1(F()).optional(),tools:q1(F(),i1()).optional(),agent:q1(F(),Pq).optional(),instructions:R1(F()).optional(),permission:xq.optional(),provider:q1(F(),MB).optional(),lsp:q1(F(),UB).optional(),formatter:q1(F(),VB).optional(),command:q1(F(),AB).optional(),tui:LB.optional(),server:FB.optional(),keybind:jB.optional(),watcher:wB.optional(),auto_update:i1().optional(),auto_compact:i1().optional(),share:U0([i1(),F()]).optional()}),c8=Q1({name:B3,type:O9,description:F().min(1).max(1024),files:R1(vq).default([]),dependencies:R1(bq).default([]),npmDependencies:R1(F()).optional(),npmDevDependencies:R1(F()).optional(),opencode:Cq.optional()});DB=new RegExp(`^https://${_2.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}/schemas/v([1-9]\\d*)/registry\\.json$`);Z2=/^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?(\+[a-zA-Z0-9.-]+)?$/,p8=Q1({$schema:F().optional(),name:F().min(1,"Registry name cannot be empty"),version:F().regex(Z2,{message:"Version must be valid semver"}),author:F().min(1,"Author cannot be empty"),opencode:F().regex(Z2,{message:"OpenCode version must be valid semver"}).optional(),ocx:F().regex(Z2,{message:"OCX version must be valid semver"}).optional(),components:R1(c8)}).refine((Q)=>{let $=new Set(Q.components.map((Y)=>Y.name));for(let Y of Q.components)for(let q of Y.dependencies)if(!q.includes("/")&&!$.has(q))return!1;return!0},{message:"Bare dependencies must reference components that exist in the registry. Use qualified references (e.g., 'other-registry/component') for cross-registry dependencies."}),M2=Q1({name:B3,"dist-tags":Q1({latest:F()}),versions:q1(F(),c8)}),T4=Q1({$schema:F().optional(),author:F(),opencode:F().regex(Z2,{message:"OpenCode version must be valid semver"}).optional(),ocx:F().regex(Z2,{message:"OCX version must be valid semver"}).optional(),components:R1(Q1({name:B3,type:O9,description:F()}))})});import{mkdir as b4}from"fs/promises";import{dirname as OB,join as s0}from"path";async function U2(Q){let{source:$,out:Y}=Q,q=Bun.file(s0($,"registry.jsonc")),J=Bun.file(s0($,"registry.json")),X=await q.exists(),H=await J.exists();if(!X&&!H)throw new r0("No registry.jsonc or registry.json found in source directory");let K=await(X?q:J).text(),W=O1(K,[],{allowTrailingComma:!0}),z=I9(W);if(z)throw new r0(`Registry schema compatibility failed (${z.issue})`,[z.remediation,...z.schemaUrl!==void 0?[`Invalid $schema: ${z.schemaUrl}`]:[]]);let B=p8.safeParse(W);if(!B.success){let N=B.error.issues.map((x)=>`${x.path.join(".")}: ${x.message}`);throw new r0("Registry validation failed",N)}let Z=B.data,M=[];if(Q.dryRun){let N=[];for(let w of Z.components){N.push({action:"create",target:`file:components/${w.name}.json`,details:{type:"packument"}});for(let b of w.files){let D=T8(b,w.type),l=s0($,"files",D.path);if(!await Bun.file(l).exists()){M.push(`${w.name}: Source file not found at ${l}`);continue}N.push({action:"create",target:`file:components/${w.name}/${D.path}`,details:{source:l}})}}N.push({action:"create",target:"file:index.json",details:{type:"registry index"}}),N.push({action:"create",target:"file:.well-known/ocx.json",details:{type:"discovery file"}});let x=N.filter((w)=>w.action==="create").length;return{dryRun:!0,command:"build",wouldPerform:N,validation:{passed:M.length===0,errors:M.length>0?M:void 0},summary:`Would build ${Z.components.length} components, ${x} files to ${Y}`}}let V=s0(Y,"components");await b4(V,{recursive:!0});let U="1.0.0";for(let N of Z.components){let x={name:N.name,versions:{[U]:N},"dist-tags":{latest:U}},w=s0(V,`${N.name}.json`);await Bun.write(w,JSON.stringify(x,null,2));for(let b of N.files){let D=T8(b,N.type),l=s0($,"files",D.path),i=s0(V,N.name,D.path),r=OB(i);if(!await Bun.file(l).exists()){M.push(`${N.name}: Source file not found at ${l}`);continue}await b4(r,{recursive:!0});let J1=Bun.file(l);await Bun.write(i,J1)}}if(M.length>0)throw new r0(`Build failed with ${M.length} errors`,M);let R={$schema:Z.$schema,name:Z.name,version:Z.version,author:Z.author,...Z.opencode&&{opencode:Z.opencode},...Z.ocx&&{ocx:Z.ocx},components:Z.components.map((N)=>({name:N.name,type:N.type,description:N.description}))};await Bun.write(s0(Y,"index.json"),JSON.stringify(R,null,2));let I=s0(Y,".well-known");await b4(I,{recursive:!0});let c={registry:"/index.json"};return await Bun.write(s0(I,"ocx.json"),JSON.stringify(c,null,2)),{componentsCount:Z.components.length,outputPath:Y}}var r0;var _3=A(()=>{D0();g0();r0=class r0 extends Error{errors;constructor(Q,$=[]){super(Q);this.errors=$;this.name="BuildRegistryError"}}});import fq from"path";function uq(Q){return fq.posix.isAbsolute(Q)||fq.win32.isAbsolute(Q)}var mq=()=>{};var R4;var S4=A(()=>{H8();mq();R4=F().refine((Q)=>!Q.includes("\x00"),"Path cannot contain null bytes").refine((Q)=>!Q.split(/[/\\]/).some(($)=>$===".."),"Path cannot contain '..'").refine((Q)=>!uq(Q),"Path must be relative, not absolute")});function g1(Q){return Q.trim().replace(/\/+$/,"")}import{existsSync as N9}from"fs";import{mkdir as cq}from"fs/promises";import G8 from"path";function A2(Q,$,Y,q){return`${g1(Q)}::${$}/${Y}@${q}`}function R8(Q){if(!Q.includes("::"))throw Error(`Invalid canonical ID: "${Q}". Expected format: registryUrl::registryName/component@revision`);let[$,Y]=Q.split("::");if(!Y||!$)throw Error(`Invalid canonical ID: "${Q}". Expected format: registryUrl::registryName/component@revision`);if(!Y.includes("@"))throw Error(`Invalid canonical ID: "${Q}". Expected format: registryUrl::registryName/component@revision`);let q=Y.indexOf("@");if(q===-1)throw Error(`Invalid canonical ID: missing revision in ${Q}`);let J=Y.slice(0,q),X=Y.slice(q+1);if(!J||!X)throw Error(`Invalid canonical ID: "${Q}". Expected format: registryUrl::registryName/component@revision`);if(!J.includes("/"))throw Error(`Invalid canonical ID: "${Q}". Component must be qualified (registryName/component)`);let[H,G]=J.split("/");if(!H||!G)throw Error(`Invalid canonical ID: "${Q}". Both registry name and component name are required`);return{registryUrl:g1($),registryName:H,name:G,revision:X}}function S8(Q){let $=G8.join(Q,dq,pq);return{path:$,exists:N9($)}}async function A0(Q){let{path:$,exists:Y}=S8(Q);if(!Y)return null;let J=await Bun.file($).text(),X=O1(J,[],{allowTrailingComma:!0});return iq.parse(X)}async function N0(Q,$){let Y=G8.join(Q,dq,pq);await cq(G8.dirname(Y),{recursive:!0});let q=JSON.stringify($,null,2);await Bun.write(Y,q)}function E8(Q){let $=G8.join(Q,E4,V2),Y=G8.join(Q,V2),q=N9($),J=N9(Y);if(q&&J)throw Error(`Found ${V2} in both .opencode/ and project root. Please consolidate to one location (recommended: .opencode/${V2})`);if(q)return{path:$,exists:!0};if(J)return{path:Y,exists:!0};return{path:$,exists:!1}}function T9(Q,$){let Y=G8.join(Q,E4,gq),q=G8.join(Q,gq);if($?.isFlattened){if(N9(q))return{path:q,exists:!0};return{path:q,exists:!1}}if(N9(Y))return{path:Y,exists:!0};if(N9(q))return{path:q,exists:!0};return{path:Y,exists:!1}}async function T0(Q,$={}){let{path:Y,exists:q}=E8(Q);if(!q)return null;let X=await Bun.file(Y).text();try{let H=O1(X,[],{allowTrailingComma:!0});return b8.parse(H)}catch(H){if($.emitParseDiagnostics??!0)console.error(`Error parsing ${Y}:`,H);throw H}}async function U3(Q,$,Y){let q=Y??G8.join(Q,E4,V2);await cq(G8.dirname(q),{recursive:!0});let J=JSON.stringify($,null,2);await Bun.write(q,J)}async function L2(Q,$){let{path:Y,exists:q}=T9(Q,$);if(!q)return null;let X=await Bun.file(Y).text(),H=O1(X,[],{allowTrailingComma:!0});return M3.parse(H)}var Z3,b8,dq=".ocx",pq="receipt.jsonc",lq,iq,IB,NB,M3,V2="ocx.jsonc",gq="ocx.lock",E4=".opencode";var q0=A(()=>{D0();H8();g0();Z3=Q1({url:F().url("Registry URL must be a valid URL"),headers:q1(F(),F()).optional()}),b8=Q1({$schema:F().optional(),profile:F().optional(),registries:q1(F(),Z3).default({}),lockRegistries:i1().default(!1),skipCompatCheck:i1().default(!1)}),lq=Q1({registryUrl:F(),registryName:F(),name:F(),revision:F(),hash:F(),files:R1(Q1({path:F(),hash:F()})),installedAt:F(),updatedAt:F().optional(),owner:Q1({type:t1(["user","profile","system"]),id:F().optional()}).optional(),opencode:q1(F(),I8()).optional()}),iq=Q1({version:F4(1),root:F().optional(),installed:q1(F(),lq).default({})}),IB=Q1({registry:F(),version:F(),hash:F(),files:R1(F()),installedAt:F(),updatedAt:F().optional()}),NB=Q1({registry:F(),component:F(),version:F().optional(),hash:F(),installedAt:F()}),M3=Q1({lockVersion:F4(1),installedFrom:NB.optional(),installed:q1(I4,IB).default({})})});var{Glob:TB}=globalThis.Bun;var nq,K8;var b9=A(()=>{H8();S4();q0();nq=F().refine((Q)=>{try{return new TB(Q),!0}catch{return!1}},{message:"Invalid glob pattern"}),K8=Q1({$schema:F().optional(),bin:F().optional(),registries:q1(F(),Z3).default({}),componentPath:R4.optional(),renameWindow:i1().default(!0).describe("Set terminal/tmux window name when launching OpenCode"),exclude:R1(nq).default(["**/CLAUDE.md","**/CONTEXT.md","**/.opencode/**","**/opencode.jsonc","**/opencode.json"]).describe("Glob patterns for project files to exclude from OpenCode discovery"),include:R1(nq).default([]).describe("Glob patterns for project files to include (overrides exclude)")})});var k4=A(()=>{S4();q0();b9();g0()});function oq(Q,$){let Y=0,q,J="",X="";for(;Y<Q.length;Y++)if(q=Q[Y],J+=q.open,X+=q.close,~$.indexOf(q.close))$=$.replace(q.rgx,q.close+q.open);return J+$+X}function bB(Q,$){let Y={has:Q,keys:$};return Y.reset=L1.reset.bind(Y),Y.bold=L1.bold.bind(Y),Y.dim=L1.dim.bind(Y),Y.italic=L1.italic.bind(Y),Y.underline=L1.underline.bind(Y),Y.inverse=L1.inverse.bind(Y),Y.hidden=L1.hidden.bind(Y),Y.strikethrough=L1.strikethrough.bind(Y),Y.black=L1.black.bind(Y),Y.red=L1.red.bind(Y),Y.green=L1.green.bind(Y),Y.yellow=L1.yellow.bind(Y),Y.blue=L1.blue.bind(Y),Y.magenta=L1.magenta.bind(Y),Y.cyan=L1.cyan.bind(Y),Y.white=L1.white.bind(Y),Y.gray=L1.gray.bind(Y),Y.grey=L1.grey.bind(Y),Y.bgBlack=L1.bgBlack.bind(Y),Y.bgRed=L1.bgRed.bind(Y),Y.bgGreen=L1.bgGreen.bind(Y),Y.bgYellow=L1.bgYellow.bind(Y),Y.bgBlue=L1.bgBlue.bind(Y),Y.bgMagenta=L1.bgMagenta.bind(Y),Y.bgCyan=L1.bgCyan.bind(Y),Y.bgWhite=L1.bgWhite.bind(Y),Y}function N1(Q,$){let Y={open:`\x1B[${Q}m`,close:`\x1B[${$}m`,rgx:new RegExp(`\\x1b\\[${$}m`,"g")};return function(q){if(this!==void 0&&this.has!==void 0)return!!~this.has.indexOf(Q)||(this.has.push(Q),this.keys.push(Y)),q===void 0?this:L1.enabled?oq(this.keys,q+""):q+"";return q===void 0?bB([Q],[Y]):L1.enabled?oq([Y],q+""):q+""}}var v4,sq,rq,aq,tq=!0,L1,P;var W8=A(()=>{if(typeof process<"u")({FORCE_COLOR:v4,NODE_DISABLE_COLORS:sq,NO_COLOR:rq,TERM:aq}=process.env||{}),tq=process.stdout&&process.stdout.isTTY;L1={enabled:!sq&&rq==null&&aq!=="dumb"&&(v4!=null&&v4!=="0"||tq),reset:N1(0,0),bold:N1(1,22),dim:N1(2,22),italic:N1(3,23),underline:N1(4,24),inverse:N1(7,27),hidden:N1(8,28),strikethrough:N1(9,29),black:N1(30,39),red:N1(31,39),green:N1(32,39),yellow:N1(33,39),blue:N1(34,39),magenta:N1(35,39),cyan:N1(36,39),white:N1(37,39),gray:N1(90,39),grey:N1(90,39),bgBlack:N1(40,49),bgRed:N1(41,49),bgGreen:N1(42,49),bgYellow:N1(43,49),bgBlue:N1(44,49),bgMagenta:N1(45,49),bgCyan:N1(46,49),bgWhite:N1(47,49)};P=L1});function QJ(Q,$){if(Q==null||Q==="")return $;let Y=Q.trim().toLowerCase();if(Y==="true"||Y==="1"||Y==="yes"||Y==="on")return!0;if(Y==="false"||Y==="0"||Y==="no"||Y==="off")return!1;return $}var RB,l8,eq;var F2=A(()=>{RB=Boolean(process.env.CI||process.env.GITHUB_ACTIONS||process.env.GITLAB_CI||process.env.CIRCLECI||process.env.JENKINS_URL||process.env.BUILDKITE),l8=Boolean(process.stdout.isTTY&&!RB),eq=Boolean(l8&&process.env.FORCE_COLOR!=="0"&&process.env.NO_COLOR===void 0)});var R9,_,L0;var c1=A(()=>{W8();F2();if(!eq)P.enabled=!1;R9={},_={info(...Q){if(R9.quiet)return;console.log(P.blue("info"),...Q)},success(...Q){if(R9.quiet)return;console.log(P.green("\u2713"),...Q)},warn(...Q){if(R9.quiet)return;console.warn(P.yellow("warn"),...Q)},error(...Q){console.error(P.red("error"),...Q)},debug(...Q){if(!R9.verbose)return;console.log(P.gray("debug"),...Q)},log(...Q){if(R9.quiet)return;console.log(...Q)},break(){if(R9.quiet)return;console.log("")}},L0={component:(Q)=>P.cyan(Q),path:(Q)=>P.green(Q),command:(Q)=>P.yellow(Q),url:(Q)=>P.blue().underline(Q),error:(Q)=>P.red(Q),dim:(Q)=>P.gray(Q),bold:(Q)=>P.bold(Q)}});function s(Q,$={}){if($.json){let Y=SB(Q);console.log(JSON.stringify(Y,null,2)),process.exit(Y.exitCode)}if(Q instanceof B1)_.error(Q.message),process.exit(Q.exitCode);if(Q instanceof U4){_.error("Validation failed:");for(let Y of Q.issues){let q=Y.path.join(".");_.error(` ${q}: ${Y.message}`)}process.exit(G1.CONFIG)}if(Q instanceof Error){if(_.error(Q.message),process.env.DEBUG)console.error(Q.stack)}else _.error("An unknown error occurred");process.exit(G1.GENERAL)}function SB(Q){if(Q instanceof w9)return{success:!1,error:{code:Q.code,message:Q.message,details:{conflictType:Q.conflictType,registryName:Q.registryName,existingUrl:Q.existingUrl,newUrl:Q.newUrl,...Q.targetLabel&&{targetLabel:Q.targetLabel},...Q.existingName&&{existingName:Q.existingName}}},exitCode:Q.exitCode,meta:{timestamp:new Date().toISOString()}};if(Q instanceof m8)return{success:!1,error:{code:Q.code,message:Q.message,details:{component:Q.component,expected:Q.expected,found:Q.found}},exitCode:Q.exitCode,meta:{timestamp:new Date().toISOString()}};if(Q instanceof I1){let $={};if(Q.url)$.url=Q.url;if(Q.status!==void 0)$.status=Q.status;if(Q.statusText)$.statusText=Q.statusText;if(Q.phase)$.phase=Q.phase;if(Q.qualifiedName)$.qualifiedName=Q.qualifiedName;if(Q.registryContext)$.registryContext=Q.registryContext;if(Q.registryName)$.registryName=Q.registryName;return{success:!1,error:{code:Q.code,message:Q.message,...Object.keys($).length>0&&{details:$}},exitCode:Q.exitCode,meta:{timestamp:new Date().toISOString()}}}if(Q instanceof C1)return{success:!1,error:{code:Q.code,message:Q.message,details:{profile:Q.profile}},exitCode:Q.exitCode,meta:{timestamp:new Date().toISOString()}};if(Q instanceof N8)return{success:!1,error:{code:Q.code,message:Q.message,details:{profile:Q.profile}},exitCode:Q.exitCode,meta:{timestamp:new Date().toISOString()}};if(Q instanceof u0)return{success:!1,error:{code:Q.code,message:Q.message,details:{profile:Q.profile,reason:Q.reason}},exitCode:Q.exitCode,meta:{timestamp:new Date().toISOString()}};if(Q instanceof r0)return{success:!1,error:{code:"BUILD_ERROR",message:Q.message,details:{errors:Q.errors}},exitCode:G1.GENERAL,meta:{timestamp:new Date().toISOString()}};if(Q instanceof f0){let $={url:Q.url,issue:Q.issue,remediation:Q.remediation};if(Q.schemaUrl!==void 0)$.schemaUrl=Q.schemaUrl;if(Q.supportedMajor!==void 0)$.supportedMajor=Q.supportedMajor;if(Q.detectedMajor!==void 0)$.detectedMajor=Q.detectedMajor;return{success:!1,error:{code:Q.code,message:Q.message,details:$},exitCode:Q.exitCode,meta:{timestamp:new Date().toISOString()}}}if(Q instanceof u8)return{success:!1,error:{code:Q.code,message:Q.message,details:Q.details},exitCode:Q.exitCode,meta:{timestamp:new Date().toISOString()}};if(Q instanceof B1)return{success:!1,error:{code:Q.code,message:Q.message},exitCode:Q.exitCode,meta:{timestamp:new Date().toISOString()}};if(Q instanceof U4)return{success:!1,error:{code:"VALIDATION_ERROR",message:Q.issues.map(($)=>`${$.path.join(".")}: ${$.message}`).join("; "),details:{issues:Q.issues.map(($)=>({path:$.path.join("."),message:$.message,code:$.code}))}},exitCode:G1.CONFIG,meta:{timestamp:new Date().toISOString()}};return{success:!1,error:{code:"UNKNOWN_ERROR",message:Q instanceof Error?Q.message:"An unknown error occurred"},exitCode:G1.GENERAL,meta:{timestamp:new Date().toISOString()}}}var y1=A(()=>{H8();_3();t();c1()});var j2=L8((EB)=>{class P4 extends Error{constructor(Q,$,Y){super(Y);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=$,this.exitCode=Q,this.nestedError=void 0}}class $J extends P4{constructor(Q){super(1,"commander.invalidArgument",Q);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}EB.CommanderError=P4;EB.InvalidArgumentError=$J});var V3=L8((CB)=>{var{InvalidArgumentError:PB}=j2();class YJ{constructor(Q,$){switch(this.description=$||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,Q[0]){case"<":this.required=!0,this._name=Q.slice(1,-1);break;case"[":this.required=!1,this._name=Q.slice(1,-1);break;default:this.required=!0,this._name=Q;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue(Q,$){if($===this.defaultValue||!Array.isArray($))return[Q];return $.push(Q),$}default(Q,$){return this.defaultValue=Q,this.defaultValueDescription=$,this}argParser(Q){return this.parseArg=Q,this}choices(Q){return this.argChoices=Q.slice(),this.parseArg=($,Y)=>{if(!this.argChoices.includes($))throw new PB(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue($,Y);return $},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function xB(Q){let $=Q.name()+(Q.variadic===!0?"...":"");return Q.required?"<"+$+">":"["+$+"]"}CB.Argument=YJ;CB.humanReadableArgName=xB});var x4=L8((uB)=>{var{humanReadableArgName:fB}=V3();class qJ{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(Q){this.helpWidth=this.helpWidth??Q.helpWidth??80}visibleCommands(Q){let $=Q.commands.filter((q)=>!q._hidden),Y=Q._getHelpCommand();if(Y&&!Y._hidden)$.push(Y);if(this.sortSubcommands)$.sort((q,J)=>{return q.name().localeCompare(J.name())});return $}compareOptions(Q,$){let Y=(q)=>{return q.short?q.short.replace(/^-/,""):q.long.replace(/^--/,"")};return Y(Q).localeCompare(Y($))}visibleOptions(Q){let $=Q.options.filter((q)=>!q.hidden),Y=Q._getHelpOption();if(Y&&!Y.hidden){let q=Y.short&&Q._findOption(Y.short),J=Y.long&&Q._findOption(Y.long);if(!q&&!J)$.push(Y);else if(Y.long&&!J)$.push(Q.createOption(Y.long,Y.description));else if(Y.short&&!q)$.push(Q.createOption(Y.short,Y.description))}if(this.sortOptions)$.sort(this.compareOptions);return $}visibleGlobalOptions(Q){if(!this.showGlobalOptions)return[];let $=[];for(let Y=Q.parent;Y;Y=Y.parent){let q=Y.options.filter((J)=>!J.hidden);$.push(...q)}if(this.sortOptions)$.sort(this.compareOptions);return $}visibleArguments(Q){if(Q._argsDescription)Q.registeredArguments.forEach(($)=>{$.description=$.description||Q._argsDescription[$.name()]||""});if(Q.registeredArguments.find(($)=>$.description))return Q.registeredArguments;return[]}subcommandTerm(Q){let $=Q.registeredArguments.map((Y)=>fB(Y)).join(" ");return Q._name+(Q._aliases[0]?"|"+Q._aliases[0]:"")+(Q.options.length?" [options]":"")+($?" "+$:"")}optionTerm(Q){return Q.flags}argumentTerm(Q){return Q.name()}longestSubcommandTermLength(Q,$){return $.visibleCommands(Q).reduce((Y,q)=>{return Math.max(Y,this.displayWidth($.styleSubcommandTerm($.subcommandTerm(q))))},0)}longestOptionTermLength(Q,$){return $.visibleOptions(Q).reduce((Y,q)=>{return Math.max(Y,this.displayWidth($.styleOptionTerm($.optionTerm(q))))},0)}longestGlobalOptionTermLength(Q,$){return $.visibleGlobalOptions(Q).reduce((Y,q)=>{return Math.max(Y,this.displayWidth($.styleOptionTerm($.optionTerm(q))))},0)}longestArgumentTermLength(Q,$){return $.visibleArguments(Q).reduce((Y,q)=>{return Math.max(Y,this.displayWidth($.styleArgumentTerm($.argumentTerm(q))))},0)}commandUsage(Q){let $=Q._name;if(Q._aliases[0])$=$+"|"+Q._aliases[0];let Y="";for(let q=Q.parent;q;q=q.parent)Y=q.name()+" "+Y;return Y+$+" "+Q.usage()}commandDescription(Q){return Q.description()}subcommandDescription(Q){return Q.summary()||Q.description()}optionDescription(Q){let $=[];if(Q.argChoices)$.push(`choices: ${Q.argChoices.map((Y)=>JSON.stringify(Y)).join(", ")}`);if(Q.defaultValue!==void 0){if(Q.required||Q.optional||Q.isBoolean()&&typeof Q.defaultValue==="boolean")$.push(`default: ${Q.defaultValueDescription||JSON.stringify(Q.defaultValue)}`)}if(Q.presetArg!==void 0&&Q.optional)$.push(`preset: ${JSON.stringify(Q.presetArg)}`);if(Q.envVar!==void 0)$.push(`env: ${Q.envVar}`);if($.length>0){let Y=`(${$.join(", ")})`;if(Q.description)return`${Q.description} ${Y}`;return Y}return Q.description}argumentDescription(Q){let $=[];if(Q.argChoices)$.push(`choices: ${Q.argChoices.map((Y)=>JSON.stringify(Y)).join(", ")}`);if(Q.defaultValue!==void 0)$.push(`default: ${Q.defaultValueDescription||JSON.stringify(Q.defaultValue)}`);if($.length>0){let Y=`(${$.join(", ")})`;if(Q.description)return`${Q.description} ${Y}`;return Y}return Q.description}formatItemList(Q,$,Y){if($.length===0)return[];return[Y.styleTitle(Q),...$,""]}groupItems(Q,$,Y){let q=new Map;return Q.forEach((J)=>{let X=Y(J);if(!q.has(X))q.set(X,[])}),$.forEach((J)=>{let X=Y(J);if(!q.has(X))q.set(X,[]);q.get(X).push(J)}),q}formatHelp(Q,$){let Y=$.padWidth(Q,$),q=$.helpWidth??80;function J(z,B){return $.formatItem(z,Y,B,$)}let X=[`${$.styleTitle("Usage:")} ${$.styleUsage($.commandUsage(Q))}`,""],H=$.commandDescription(Q);if(H.length>0)X=X.concat([$.boxWrap($.styleCommandDescription(H),q),""]);let G=$.visibleArguments(Q).map((z)=>{return J($.styleArgumentTerm($.argumentTerm(z)),$.styleArgumentDescription($.argumentDescription(z)))});if(X=X.concat(this.formatItemList("Arguments:",G,$)),this.groupItems(Q.options,$.visibleOptions(Q),(z)=>z.helpGroupHeading??"Options:").forEach((z,B)=>{let Z=z.map((M)=>{return J($.styleOptionTerm($.optionTerm(M)),$.styleOptionDescription($.optionDescription(M)))});X=X.concat(this.formatItemList(B,Z,$))}),$.showGlobalOptions){let z=$.visibleGlobalOptions(Q).map((B)=>{return J($.styleOptionTerm($.optionTerm(B)),$.styleOptionDescription($.optionDescription(B)))});X=X.concat(this.formatItemList("Global Options:",z,$))}return this.groupItems(Q.commands,$.visibleCommands(Q),(z)=>z.helpGroup()||"Commands:").forEach((z,B)=>{let Z=z.map((M)=>{return J($.styleSubcommandTerm($.subcommandTerm(M)),$.styleSubcommandDescription($.subcommandDescription(M)))});X=X.concat(this.formatItemList(B,Z,$))}),X.join(`
74
+ ocx profile show ${Q} --global`,"CONFIG_ERROR",G1.CONFIG);this.profile=Q;this.localDir=$;this.name="LocalProfileUnsupportedError"}}});import*as N0 from"path";function A0(Q,$){if($.includes("\x00"))throw new e1("Path contains null bytes",$,"null_byte");if(N0.isAbsolute($)||N0.win32.isAbsolute($))throw new e1("Path must be relative",$,"absolute_path");if(/^[a-zA-Z]:/.test($)||$.startsWith("\\\\"))throw new e1("Path contains Windows absolute",$,"windows_absolute");let Y=N0.basename($).toUpperCase().split(".")[0]??"";if(WB.has(Y))throw new e1("Path uses Windows reserved name",$,"windows_reserved");let J=$.normalize("NFC").replace(/\\/g,"/"),X=N0.resolve(Q),H=N0.resolve(X,J),G=N0.relative(X,H);if(G.startsWith("../")||G.startsWith("..\\")||G===".."||N0.isAbsolute(G))throw new e1("Path escapes base directory",$,"path_traversal");return H}var e1,WB;var g8=A(()=>{e1=class e1 extends Error{attemptedPath;reason;constructor(Q,$,Y){super(Q);this.attemptedPath=$;this.reason=Y;this.name="PathValidationError"}};WB=new Set(["CON","PRN","AUX","NUL","COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"])});import{isAbsolute as zB,normalize as Tq}from"path";function g0(Q){if(!Q.includes("/"))throw Error(`Invalid component reference: "${Q}". Use format: alias/component`);let $=Q.split("/");if($.length>2)throw Error(`Invalid component reference: "${Q}". Too many "/" separators. Use format: alias/component`);let[Y,q]=$;if(!Y||!q)throw Error(`Invalid component reference: "${Q}". Both alias and component are required.`);return{namespace:Y,component:q}}function N4(Q,$){return`${Q}/${$}`}function O4(Q){if(zB(Q))throw new L(`Invalid path: "${Q}" - absolute paths not allowed`);if(Q.startsWith("~"))throw new L(`Invalid path: "${Q}" - home directory paths not allowed`);if(Tq(Q).startsWith(".."))throw new L(`Invalid path: "${Q}" - path traversal not allowed`)}function yq(Q){return Q}function Nq(Q,$){if(BB.has(Q))throw new L(`Target "${Q}" is reserved for installer use`);try{A0("/dummy/base",Q)}catch(q){if(q instanceof e1)throw new L(`Invalid target "${Q}": ${q.message}`);throw q}if($!=="profile"){let q=Tq(Q);if(Rq.some((X)=>q===X||q.startsWith(X)))throw new L(`Target path '${Q}' is protected and cannot be overwritten by registry components`)}}function T8(Q,$){if(typeof Q==="string"){O4(Q);let Y=yq(Q);return Nq(Y,$),{path:Q,target:Y}}return O4(Q.path),O4(Q.target),Nq(Q.target,$),Q}function hq(Q){if(typeof Q==="string")return{type:"remote",url:Q,enabled:!0};return Q}function d8(Q){let $;if(Q.opencode){let{mcp:Y,...q}=Q.opencode;$={...q,...Y&&{mcp:Object.fromEntries(Object.entries(Y).map(([J,X])=>[J,hq(X)]))}}}return{...Q,files:Q.files.map((Y)=>T8(Y,Q.type)),opencode:$}}function I9(Q){if(Q===null||Q===void 0||typeof Q!=="object")return null;let $=Q;if(!Object.hasOwn($,"$schema"))return{issue:"legacy-schema-v1",remediation:`This registry uses legacy schema v1 (missing $schema). Set "$schema" to "${f0}".`,supportedMajor:h0};let q=$.$schema;if(typeof q!=="string")return{issue:"invalid-schema-url",remediation:`Registry $schema must be a canonical URL like "${f0}".`,schemaUrl:String(q),supportedMajor:h0};if(!q)return{issue:"invalid-schema-url",remediation:`Registry $schema must be a canonical URL like "${f0}".`,schemaUrl:q,supportedMajor:h0};if(q===w4)return{issue:"legacy-schema-v1",remediation:`Schema URL "${w4}" is legacy v1. Use "${f0}" instead.`,schemaUrl:q,supportedMajor:h0};let J=q.match(DB);if(!J)return{issue:"invalid-schema-url",remediation:`Registry $schema must be a canonical URL like "${f0}".`,schemaUrl:q,supportedMajor:h0};let X=J[1];if(!X)return{issue:"invalid-schema-url",remediation:`Registry $schema must be a canonical URL like "${f0}".`,schemaUrl:q,supportedMajor:h0};let H=Number.parseInt(X,10);if(H!==h0)return{issue:"unsupported-schema-version",remediation:`Schema major v${H} is unsupported. Use "${f0}" (v${h0}).`,schemaUrl:q,supportedMajor:h0,detectedMajor:H};return null}var hw,B3,I4,bq,O9,BB,Rq,_B,ZB,Sq,Eq,kq,vq,MB,UB,VB,AB,LB,FB,jB,wB,Pq,xq,Cq,c8,DB,Z2,p8,M2,T4;var c0=A(()=>{H8();z3();t();g8();hw=F().refine((Q)=>Q.startsWith("npm:"),{message:'npm specifier must start with "npm:" prefix'}).refine((Q)=>{let $=Q.slice(4);if(!$)return!1;if($.includes("..")||$.includes("/./"))return!1;return!0},{message:"Invalid npm specifier format"}),B3=F().min(1,"Name cannot be empty").max(64,"Name cannot exceed 64 characters").regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,{message:"Must be lowercase alphanumeric with single hyphen separators (e.g., 'my-component', 'my-plugin'). Cannot start/end with hyphen or have consecutive hyphens."}),I4=F().regex(/^[a-z0-9]+(-[a-z0-9]+)*\/[a-z0-9]+(-[a-z0-9]+)*$/,{message:'Must be in format "alias/component" (e.g., "kdco/researcher"). Both parts must be lowercase alphanumeric with hyphens.'});bq=F().refine((Q)=>{let $=/^[a-z0-9]+(-[a-z0-9]+)*$/,Y=/^[a-z0-9]+(-[a-z0-9]+)*\/[a-z0-9]+(-[a-z0-9]+)*$/;return $.test(Q)||Y.test(Q)},{message:'Dependency must be either a bare name (e.g., "utils") or qualified (e.g., "acme/utils")'}),O9=t1(["agent","skill","plugin","command","tool","bundle","profile"]),BB=new Set([".ocx","ocx.lock"]),Rq=[".ocx/","ocx.jsonc","package.json",".git/",".env","node_modules/"],_B=F().min(1,"Target path cannot be empty").refine((Q)=>{if(Q.startsWith("/")||/^[a-zA-Z]:/.test(Q))return!1;if(Q.includes("\x00"))return!1;return!0},{message:"Target path must be relative and safe (no absolute paths or null bytes)"}).refine((Q)=>{return!Rq.some(($)=>Q===$||Q.startsWith($))},{message:"Target path is protected and cannot be overwritten by registry components"}),ZB=Q1({clientId:F().optional(),scopes:R1(F()).optional(),authUrl:F().optional(),tokenUrl:F().optional()}),Sq=Q1({type:t1(["remote","local"]),url:F().optional(),command:V0([F(),R1(F())]).optional(),environment:q1(F(),F()).optional(),headers:q1(F(),F()).optional(),oauth:V0([i1(),ZB]).optional(),enabled:i1().default(!0)}).refine((Q)=>{if(Q.type==="remote"&&!Q.url)return!1;if(Q.type==="local"&&!Q.command)return!1;return!0},{message:"Remote MCP servers require 'url', local servers require 'command'"}),Eq=V0([F(),Sq]),kq=Q1({path:F().min(1,"File path cannot be empty"),target:F().min(1,"Target path cannot be empty")}),vq=V0([F().min(1,"File path cannot be empty"),kq]),MB=Q1({api:F().optional(),headers:q1(F(),F()).optional(),env:q1(F(),F()).optional(),enabled:i1().optional()}).passthrough(),UB=Q1({command:V0([F(),R1(F())]).optional(),enabled:i1().optional()}).passthrough(),VB=Q1({command:V0([F(),R1(F())]).optional(),glob:F().optional()}).passthrough(),AB=Q1({description:F().optional(),run:F().optional()}).passthrough(),LB=Q1({disabled:i1().optional()}).passthrough(),FB=Q1({host:F().optional(),port:j9().optional()}).passthrough(),jB=q1(F(),F()),wB=Q1({include:R1(F()).optional(),exclude:R1(F()).optional()}).passthrough(),Pq=Q1({model:F().optional(),description:F().optional(),steps:j9().int().positive().optional(),maxSteps:j9().int().positive().optional(),mode:t1(["primary","subagent","all"]).optional(),tools:q1(F(),i1()).optional(),temperature:j9().optional(),top_p:j9().optional(),prompt:F().optional(),permission:q1(F(),V0([t1(["ask","allow","deny"]),q1(F(),t1(["ask","allow","deny"]))])).optional(),color:F().optional(),disable:i1().optional(),options:q1(F(),Mq()).optional()}),xq=Q1({bash:V0([t1(["ask","allow","deny"]),q1(F(),t1(["ask","allow","deny"]))]).optional(),edit:V0([t1(["ask","allow","deny"]),q1(F(),t1(["ask","allow","deny"]))]).optional(),mcp:q1(F(),t1(["ask","allow","deny"])).optional()}).catchall(V0([t1(["ask","allow","deny"]),q1(F(),t1(["ask","allow","deny"]))])),Cq=Q1({$schema:F().optional(),theme:F().optional(),logLevel:F().optional(),username:F().optional(),model:F().optional(),small_model:F().optional(),default_agent:F().optional(),mcp:q1(F(),Eq).optional(),plugin:R1(F()).optional(),tools:q1(F(),i1()).optional(),agent:q1(F(),Pq).optional(),instructions:R1(F()).optional(),permission:xq.optional(),provider:q1(F(),MB).optional(),lsp:q1(F(),UB).optional(),formatter:q1(F(),VB).optional(),command:q1(F(),AB).optional(),tui:LB.optional(),server:FB.optional(),keybind:jB.optional(),watcher:wB.optional(),auto_update:i1().optional(),auto_compact:i1().optional(),share:V0([i1(),F()]).optional()}),c8=Q1({name:B3,type:O9,description:F().min(1).max(1024),files:R1(vq).default([]),dependencies:R1(bq).default([]),npmDependencies:R1(F()).optional(),npmDevDependencies:R1(F()).optional(),opencode:Cq.optional()});DB=new RegExp(`^https://${_2.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}/schemas/v([1-9]\\d*)/registry\\.json$`);Z2=/^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?(\+[a-zA-Z0-9.-]+)?$/,p8=Q1({$schema:F().optional(),name:F().min(1,"Registry name cannot be empty"),version:F().regex(Z2,{message:"Version must be valid semver"}),author:F().min(1,"Author cannot be empty"),opencode:F().regex(Z2,{message:"OpenCode version must be valid semver"}).optional(),ocx:F().regex(Z2,{message:"OCX version must be valid semver"}).optional(),components:R1(c8)}).refine((Q)=>{let $=new Set(Q.components.map((Y)=>Y.name));for(let Y of Q.components)for(let q of Y.dependencies)if(!q.includes("/")&&!$.has(q))return!1;return!0},{message:"Bare dependencies must reference components that exist in the registry. Use qualified references (e.g., 'other-registry/component') for cross-registry dependencies."}),M2=Q1({name:B3,"dist-tags":Q1({latest:F()}),versions:q1(F(),c8)}),T4=Q1({$schema:F().optional(),author:F(),opencode:F().regex(Z2,{message:"OpenCode version must be valid semver"}).optional(),ocx:F().regex(Z2,{message:"OCX version must be valid semver"}).optional(),components:R1(Q1({name:B3,type:O9,description:F()}))})});import{mkdir as b4}from"fs/promises";import{dirname as OB,join as s0}from"path";async function U2(Q){let{source:$,out:Y}=Q,q=Bun.file(s0($,"registry.jsonc")),J=Bun.file(s0($,"registry.json")),X=await q.exists(),H=await J.exists();if(!X&&!H)throw new r0("No registry.jsonc or registry.json found in source directory");let K=await(X?q:J).text(),W=O1(K,[],{allowTrailingComma:!0}),z=I9(W);if(z)throw new r0(`Registry schema compatibility failed (${z.issue})`,[z.remediation,...z.schemaUrl!==void 0?[`Invalid $schema: ${z.schemaUrl}`]:[]]);let B=p8.safeParse(W);if(!B.success){let T=B.error.issues.map((x)=>`${x.path.join(".")}: ${x.message}`);throw new r0("Registry validation failed",T)}let Z=B.data,M=[];if(Q.dryRun){let T=[];for(let O of Z.components){T.push({action:"create",target:`file:components/${O.name}.json`,details:{type:"packument"}});for(let I of O.files){let w=T8(I,O.type),i=s0($,"files",w.path);if(!await Bun.file(i).exists()){M.push(`${O.name}: Source file not found at ${i}`);continue}T.push({action:"create",target:`file:components/${O.name}/${w.path}`,details:{source:i}})}}T.push({action:"create",target:"file:index.json",details:{type:"registry index"}}),T.push({action:"create",target:"file:.well-known/ocx.json",details:{type:"discovery file"}});let x=T.filter((O)=>O.action==="create").length;return{dryRun:!0,command:"build",wouldPerform:T,validation:{passed:M.length===0,errors:M.length>0?M:void 0},summary:`Would build ${Z.components.length} components, ${x} files to ${Y}`}}let V=s0(Y,"components");await b4(V,{recursive:!0});let U="1.0.0";for(let T of Z.components){let x={name:T.name,versions:{[U]:T},"dist-tags":{latest:U}},O=s0(V,`${T.name}.json`);await Bun.write(O,JSON.stringify(x,null,2));for(let I of T.files){let w=T8(I,T.type),i=s0($,"files",w.path),l=s0(V,T.name,w.path),r=OB(l);if(!await Bun.file(i).exists()){M.push(`${T.name}: Source file not found at ${i}`);continue}await b4(r,{recursive:!0});let J1=Bun.file(i);await Bun.write(l,J1)}}if(M.length>0)throw new r0(`Build failed with ${M.length} errors`,M);let R={$schema:Z.$schema,name:Z.name,version:Z.version,author:Z.author,...Z.opencode&&{opencode:Z.opencode},...Z.ocx&&{ocx:Z.ocx},components:Z.components.map((T)=>({name:T.name,type:T.type,description:T.description}))};await Bun.write(s0(Y,"index.json"),JSON.stringify(R,null,2));let N=s0(Y,".well-known");await b4(N,{recursive:!0});let c={registry:"/index.json"};return await Bun.write(s0(N,"ocx.json"),JSON.stringify(c,null,2)),{componentsCount:Z.components.length,outputPath:Y}}var r0;var _3=A(()=>{O0();c0();r0=class r0 extends Error{errors;constructor(Q,$=[]){super(Q);this.errors=$;this.name="BuildRegistryError"}}});import fq from"path";function uq(Q){return fq.posix.isAbsolute(Q)||fq.win32.isAbsolute(Q)}var mq=()=>{};var R4;var S4=A(()=>{H8();mq();R4=F().refine((Q)=>!Q.includes("\x00"),"Path cannot contain null bytes").refine((Q)=>!Q.split(/[/\\]/).some(($)=>$===".."),"Path cannot contain '..'").refine((Q)=>!uq(Q),"Path must be relative, not absolute")});function g1(Q){return Q.trim().replace(/\/+$/,"")}import{existsSync as N9}from"fs";import{mkdir as cq}from"fs/promises";import G8 from"path";function A2(Q,$,Y,q){return`${g1(Q)}::${$}/${Y}@${q}`}function R8(Q){if(!Q.includes("::"))throw Error(`Invalid canonical ID: "${Q}". Expected format: registryUrl::registryName/component@revision`);let[$,Y]=Q.split("::");if(!Y||!$)throw Error(`Invalid canonical ID: "${Q}". Expected format: registryUrl::registryName/component@revision`);if(!Y.includes("@"))throw Error(`Invalid canonical ID: "${Q}". Expected format: registryUrl::registryName/component@revision`);let q=Y.indexOf("@");if(q===-1)throw Error(`Invalid canonical ID: missing revision in ${Q}`);let J=Y.slice(0,q),X=Y.slice(q+1);if(!J||!X)throw Error(`Invalid canonical ID: "${Q}". Expected format: registryUrl::registryName/component@revision`);if(!J.includes("/"))throw Error(`Invalid canonical ID: "${Q}". Component must be qualified (registryName/component)`);let[H,G]=J.split("/");if(!H||!G)throw Error(`Invalid canonical ID: "${Q}". Both registry name and component name are required`);return{registryUrl:g1($),registryName:H,name:G,revision:X}}function S8(Q){let $=G8.join(Q,dq,pq);return{path:$,exists:N9($)}}async function L0(Q){let{path:$,exists:Y}=S8(Q);if(!Y)return null;let J=await Bun.file($).text(),X=O1(J,[],{allowTrailingComma:!0});return iq.parse(X)}async function T0(Q,$){let Y=G8.join(Q,dq,pq);await cq(G8.dirname(Y),{recursive:!0});let q=JSON.stringify($,null,2);await Bun.write(Y,q)}function E8(Q){let $=G8.join(Q,E4,V2),Y=G8.join(Q,V2),q=N9($),J=N9(Y);if(q&&J)throw Error(`Found ${V2} in both .opencode/ and project root. Please consolidate to one location (recommended: .opencode/${V2})`);if(q)return{path:$,exists:!0};if(J)return{path:Y,exists:!0};return{path:$,exists:!1}}function T9(Q,$){let Y=G8.join(Q,E4,gq),q=G8.join(Q,gq);if($?.isFlattened){if(N9(q))return{path:q,exists:!0};return{path:q,exists:!1}}if(N9(Y))return{path:Y,exists:!0};if(N9(q))return{path:q,exists:!0};return{path:Y,exists:!1}}async function b0(Q,$={}){let{path:Y,exists:q}=E8(Q);if(!q)return null;let X=await Bun.file(Y).text();try{let H=O1(X,[],{allowTrailingComma:!0});return b8.parse(H)}catch(H){if($.emitParseDiagnostics??!0)console.error(`Error parsing ${Y}:`,H);throw H}}async function U3(Q,$,Y){let q=Y??G8.join(Q,E4,V2);await cq(G8.dirname(q),{recursive:!0});let J=JSON.stringify($,null,2);await Bun.write(q,J)}async function L2(Q,$){let{path:Y,exists:q}=T9(Q,$);if(!q)return null;let X=await Bun.file(Y).text(),H=O1(X,[],{allowTrailingComma:!0});return M3.parse(H)}var Z3,b8,dq=".ocx",pq="receipt.jsonc",lq,iq,IB,NB,M3,V2="ocx.jsonc",gq="ocx.lock",E4=".opencode";var q0=A(()=>{O0();H8();c0();Z3=Q1({url:F().url("Registry URL must be a valid URL"),headers:q1(F(),F()).optional()}),b8=Q1({$schema:F().optional(),profile:F().optional(),registries:q1(F(),Z3).default({}),lockRegistries:i1().default(!1),skipCompatCheck:i1().default(!1)}),lq=Q1({registryUrl:F(),registryName:F(),name:F(),revision:F(),hash:F(),files:R1(Q1({path:F(),hash:F()})),installedAt:F(),updatedAt:F().optional(),owner:Q1({type:t1(["user","profile","system"]),id:F().optional()}).optional(),opencode:q1(F(),I8()).optional()}),iq=Q1({version:F4(1),root:F().optional(),installed:q1(F(),lq).default({})}),IB=Q1({registry:F(),version:F(),hash:F(),files:R1(F()),installedAt:F(),updatedAt:F().optional()}),NB=Q1({registry:F(),component:F(),version:F().optional(),hash:F(),installedAt:F()}),M3=Q1({lockVersion:F4(1),installedFrom:NB.optional(),installed:q1(I4,IB).default({})})});var{Glob:TB}=globalThis.Bun;var nq,K8;var b9=A(()=>{H8();S4();q0();nq=F().refine((Q)=>{try{return new TB(Q),!0}catch{return!1}},{message:"Invalid glob pattern"}),K8=Q1({$schema:F().optional(),bin:F().optional(),registries:q1(F(),Z3).default({}),componentPath:R4.optional(),renameWindow:i1().default(!0).describe("Set terminal/tmux window name when launching OpenCode"),exclude:R1(nq).default(["**/CLAUDE.md","**/CONTEXT.md","**/.opencode/**","**/opencode.jsonc","**/opencode.json"]).describe("Glob patterns for project files to exclude from OpenCode discovery"),include:R1(nq).default([]).describe("Glob patterns for project files to include (overrides exclude)")})});var k4=A(()=>{S4();q0();b9();c0()});function oq(Q,$){let Y=0,q,J="",X="";for(;Y<Q.length;Y++)if(q=Q[Y],J+=q.open,X+=q.close,~$.indexOf(q.close))$=$.replace(q.rgx,q.close+q.open);return J+$+X}function bB(Q,$){let Y={has:Q,keys:$};return Y.reset=L1.reset.bind(Y),Y.bold=L1.bold.bind(Y),Y.dim=L1.dim.bind(Y),Y.italic=L1.italic.bind(Y),Y.underline=L1.underline.bind(Y),Y.inverse=L1.inverse.bind(Y),Y.hidden=L1.hidden.bind(Y),Y.strikethrough=L1.strikethrough.bind(Y),Y.black=L1.black.bind(Y),Y.red=L1.red.bind(Y),Y.green=L1.green.bind(Y),Y.yellow=L1.yellow.bind(Y),Y.blue=L1.blue.bind(Y),Y.magenta=L1.magenta.bind(Y),Y.cyan=L1.cyan.bind(Y),Y.white=L1.white.bind(Y),Y.gray=L1.gray.bind(Y),Y.grey=L1.grey.bind(Y),Y.bgBlack=L1.bgBlack.bind(Y),Y.bgRed=L1.bgRed.bind(Y),Y.bgGreen=L1.bgGreen.bind(Y),Y.bgYellow=L1.bgYellow.bind(Y),Y.bgBlue=L1.bgBlue.bind(Y),Y.bgMagenta=L1.bgMagenta.bind(Y),Y.bgCyan=L1.bgCyan.bind(Y),Y.bgWhite=L1.bgWhite.bind(Y),Y}function N1(Q,$){let Y={open:`\x1B[${Q}m`,close:`\x1B[${$}m`,rgx:new RegExp(`\\x1b\\[${$}m`,"g")};return function(q){if(this!==void 0&&this.has!==void 0)return!!~this.has.indexOf(Q)||(this.has.push(Q),this.keys.push(Y)),q===void 0?this:L1.enabled?oq(this.keys,q+""):q+"";return q===void 0?bB([Q],[Y]):L1.enabled?oq([Y],q+""):q+""}}var v4,sq,rq,aq,tq=!0,L1,P;var W8=A(()=>{if(typeof process<"u")({FORCE_COLOR:v4,NODE_DISABLE_COLORS:sq,NO_COLOR:rq,TERM:aq}=process.env||{}),tq=process.stdout&&process.stdout.isTTY;L1={enabled:!sq&&rq==null&&aq!=="dumb"&&(v4!=null&&v4!=="0"||tq),reset:N1(0,0),bold:N1(1,22),dim:N1(2,22),italic:N1(3,23),underline:N1(4,24),inverse:N1(7,27),hidden:N1(8,28),strikethrough:N1(9,29),black:N1(30,39),red:N1(31,39),green:N1(32,39),yellow:N1(33,39),blue:N1(34,39),magenta:N1(35,39),cyan:N1(36,39),white:N1(37,39),gray:N1(90,39),grey:N1(90,39),bgBlack:N1(40,49),bgRed:N1(41,49),bgGreen:N1(42,49),bgYellow:N1(43,49),bgBlue:N1(44,49),bgMagenta:N1(45,49),bgCyan:N1(46,49),bgWhite:N1(47,49)};P=L1});function QJ(Q,$){if(Q==null||Q==="")return $;let Y=Q.trim().toLowerCase();if(Y==="true"||Y==="1"||Y==="yes"||Y==="on")return!0;if(Y==="false"||Y==="0"||Y==="no"||Y==="off")return!1;return $}var RB,l8,eq;var F2=A(()=>{RB=Boolean(process.env.CI||process.env.GITHUB_ACTIONS||process.env.GITLAB_CI||process.env.CIRCLECI||process.env.JENKINS_URL||process.env.BUILDKITE),l8=Boolean(process.stdout.isTTY&&!RB),eq=Boolean(l8&&process.env.FORCE_COLOR!=="0"&&process.env.NO_COLOR===void 0)});var R9,_,F0;var c1=A(()=>{W8();F2();if(!eq)P.enabled=!1;R9={},_={info(...Q){if(R9.quiet)return;console.log(P.blue("info"),...Q)},success(...Q){if(R9.quiet)return;console.log(P.green("\u2713"),...Q)},warn(...Q){if(R9.quiet)return;console.warn(P.yellow("warn"),...Q)},error(...Q){console.error(P.red("error"),...Q)},debug(...Q){if(!R9.verbose)return;console.log(P.gray("debug"),...Q)},log(...Q){if(R9.quiet)return;console.log(...Q)},break(){if(R9.quiet)return;console.log("")}},F0={component:(Q)=>P.cyan(Q),path:(Q)=>P.green(Q),command:(Q)=>P.yellow(Q),url:(Q)=>P.blue().underline(Q),error:(Q)=>P.red(Q),dim:(Q)=>P.gray(Q),bold:(Q)=>P.bold(Q)}});function s(Q,$={}){if($.json){let Y=SB(Q);console.log(JSON.stringify(Y,null,2)),process.exit(Y.exitCode)}if(Q instanceof B1)_.error(Q.message),process.exit(Q.exitCode);if(Q instanceof U4){_.error("Validation failed:");for(let Y of Q.issues){let q=Y.path.join(".");_.error(` ${q}: ${Y.message}`)}process.exit(G1.CONFIG)}if(Q instanceof Error){if(_.error(Q.message),process.env.DEBUG)console.error(Q.stack)}else _.error("An unknown error occurred");process.exit(G1.GENERAL)}function SB(Q){if(Q instanceof w9)return{success:!1,error:{code:Q.code,message:Q.message,details:{conflictType:Q.conflictType,registryName:Q.registryName,existingUrl:Q.existingUrl,newUrl:Q.newUrl,...Q.targetLabel&&{targetLabel:Q.targetLabel},...Q.existingName&&{existingName:Q.existingName}}},exitCode:Q.exitCode,meta:{timestamp:new Date().toISOString()}};if(Q instanceof m8)return{success:!1,error:{code:Q.code,message:Q.message,details:{component:Q.component,expected:Q.expected,found:Q.found}},exitCode:Q.exitCode,meta:{timestamp:new Date().toISOString()}};if(Q instanceof I1){let $={};if(Q.url)$.url=Q.url;if(Q.status!==void 0)$.status=Q.status;if(Q.statusText)$.statusText=Q.statusText;if(Q.phase)$.phase=Q.phase;if(Q.qualifiedName)$.qualifiedName=Q.qualifiedName;if(Q.registryContext)$.registryContext=Q.registryContext;if(Q.registryName)$.registryName=Q.registryName;return{success:!1,error:{code:Q.code,message:Q.message,...Object.keys($).length>0&&{details:$}},exitCode:Q.exitCode,meta:{timestamp:new Date().toISOString()}}}if(Q instanceof C1)return{success:!1,error:{code:Q.code,message:Q.message,details:{profile:Q.profile}},exitCode:Q.exitCode,meta:{timestamp:new Date().toISOString()}};if(Q instanceof N8)return{success:!1,error:{code:Q.code,message:Q.message,details:{profile:Q.profile}},exitCode:Q.exitCode,meta:{timestamp:new Date().toISOString()}};if(Q instanceof m0)return{success:!1,error:{code:Q.code,message:Q.message,details:{profile:Q.profile,reason:Q.reason}},exitCode:Q.exitCode,meta:{timestamp:new Date().toISOString()}};if(Q instanceof r0)return{success:!1,error:{code:"BUILD_ERROR",message:Q.message,details:{errors:Q.errors}},exitCode:G1.GENERAL,meta:{timestamp:new Date().toISOString()}};if(Q instanceof u0){let $={url:Q.url,issue:Q.issue,remediation:Q.remediation};if(Q.schemaUrl!==void 0)$.schemaUrl=Q.schemaUrl;if(Q.supportedMajor!==void 0)$.supportedMajor=Q.supportedMajor;if(Q.detectedMajor!==void 0)$.detectedMajor=Q.detectedMajor;return{success:!1,error:{code:Q.code,message:Q.message,details:$},exitCode:Q.exitCode,meta:{timestamp:new Date().toISOString()}}}if(Q instanceof u8)return{success:!1,error:{code:Q.code,message:Q.message,details:Q.details},exitCode:Q.exitCode,meta:{timestamp:new Date().toISOString()}};if(Q instanceof B1)return{success:!1,error:{code:Q.code,message:Q.message},exitCode:Q.exitCode,meta:{timestamp:new Date().toISOString()}};if(Q instanceof U4)return{success:!1,error:{code:"VALIDATION_ERROR",message:Q.issues.map(($)=>`${$.path.join(".")}: ${$.message}`).join("; "),details:{issues:Q.issues.map(($)=>({path:$.path.join("."),message:$.message,code:$.code}))}},exitCode:G1.CONFIG,meta:{timestamp:new Date().toISOString()}};return{success:!1,error:{code:"UNKNOWN_ERROR",message:Q instanceof Error?Q.message:"An unknown error occurred"},exitCode:G1.GENERAL,meta:{timestamp:new Date().toISOString()}}}var y1=A(()=>{H8();_3();t();c1()});var j2=L8((EB)=>{class P4 extends Error{constructor(Q,$,Y){super(Y);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=$,this.exitCode=Q,this.nestedError=void 0}}class $J extends P4{constructor(Q){super(1,"commander.invalidArgument",Q);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}EB.CommanderError=P4;EB.InvalidArgumentError=$J});var V3=L8((CB)=>{var{InvalidArgumentError:PB}=j2();class YJ{constructor(Q,$){switch(this.description=$||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,Q[0]){case"<":this.required=!0,this._name=Q.slice(1,-1);break;case"[":this.required=!1,this._name=Q.slice(1,-1);break;default:this.required=!0,this._name=Q;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue(Q,$){if($===this.defaultValue||!Array.isArray($))return[Q];return $.push(Q),$}default(Q,$){return this.defaultValue=Q,this.defaultValueDescription=$,this}argParser(Q){return this.parseArg=Q,this}choices(Q){return this.argChoices=Q.slice(),this.parseArg=($,Y)=>{if(!this.argChoices.includes($))throw new PB(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue($,Y);return $},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function xB(Q){let $=Q.name()+(Q.variadic===!0?"...":"");return Q.required?"<"+$+">":"["+$+"]"}CB.Argument=YJ;CB.humanReadableArgName=xB});var x4=L8((uB)=>{var{humanReadableArgName:fB}=V3();class qJ{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(Q){this.helpWidth=this.helpWidth??Q.helpWidth??80}visibleCommands(Q){let $=Q.commands.filter((q)=>!q._hidden),Y=Q._getHelpCommand();if(Y&&!Y._hidden)$.push(Y);if(this.sortSubcommands)$.sort((q,J)=>{return q.name().localeCompare(J.name())});return $}compareOptions(Q,$){let Y=(q)=>{return q.short?q.short.replace(/^-/,""):q.long.replace(/^--/,"")};return Y(Q).localeCompare(Y($))}visibleOptions(Q){let $=Q.options.filter((q)=>!q.hidden),Y=Q._getHelpOption();if(Y&&!Y.hidden){let q=Y.short&&Q._findOption(Y.short),J=Y.long&&Q._findOption(Y.long);if(!q&&!J)$.push(Y);else if(Y.long&&!J)$.push(Q.createOption(Y.long,Y.description));else if(Y.short&&!q)$.push(Q.createOption(Y.short,Y.description))}if(this.sortOptions)$.sort(this.compareOptions);return $}visibleGlobalOptions(Q){if(!this.showGlobalOptions)return[];let $=[];for(let Y=Q.parent;Y;Y=Y.parent){let q=Y.options.filter((J)=>!J.hidden);$.push(...q)}if(this.sortOptions)$.sort(this.compareOptions);return $}visibleArguments(Q){if(Q._argsDescription)Q.registeredArguments.forEach(($)=>{$.description=$.description||Q._argsDescription[$.name()]||""});if(Q.registeredArguments.find(($)=>$.description))return Q.registeredArguments;return[]}subcommandTerm(Q){let $=Q.registeredArguments.map((Y)=>fB(Y)).join(" ");return Q._name+(Q._aliases[0]?"|"+Q._aliases[0]:"")+(Q.options.length?" [options]":"")+($?" "+$:"")}optionTerm(Q){return Q.flags}argumentTerm(Q){return Q.name()}longestSubcommandTermLength(Q,$){return $.visibleCommands(Q).reduce((Y,q)=>{return Math.max(Y,this.displayWidth($.styleSubcommandTerm($.subcommandTerm(q))))},0)}longestOptionTermLength(Q,$){return $.visibleOptions(Q).reduce((Y,q)=>{return Math.max(Y,this.displayWidth($.styleOptionTerm($.optionTerm(q))))},0)}longestGlobalOptionTermLength(Q,$){return $.visibleGlobalOptions(Q).reduce((Y,q)=>{return Math.max(Y,this.displayWidth($.styleOptionTerm($.optionTerm(q))))},0)}longestArgumentTermLength(Q,$){return $.visibleArguments(Q).reduce((Y,q)=>{return Math.max(Y,this.displayWidth($.styleArgumentTerm($.argumentTerm(q))))},0)}commandUsage(Q){let $=Q._name;if(Q._aliases[0])$=$+"|"+Q._aliases[0];let Y="";for(let q=Q.parent;q;q=q.parent)Y=q.name()+" "+Y;return Y+$+" "+Q.usage()}commandDescription(Q){return Q.description()}subcommandDescription(Q){return Q.summary()||Q.description()}optionDescription(Q){let $=[];if(Q.argChoices)$.push(`choices: ${Q.argChoices.map((Y)=>JSON.stringify(Y)).join(", ")}`);if(Q.defaultValue!==void 0){if(Q.required||Q.optional||Q.isBoolean()&&typeof Q.defaultValue==="boolean")$.push(`default: ${Q.defaultValueDescription||JSON.stringify(Q.defaultValue)}`)}if(Q.presetArg!==void 0&&Q.optional)$.push(`preset: ${JSON.stringify(Q.presetArg)}`);if(Q.envVar!==void 0)$.push(`env: ${Q.envVar}`);if($.length>0){let Y=`(${$.join(", ")})`;if(Q.description)return`${Q.description} ${Y}`;return Y}return Q.description}argumentDescription(Q){let $=[];if(Q.argChoices)$.push(`choices: ${Q.argChoices.map((Y)=>JSON.stringify(Y)).join(", ")}`);if(Q.defaultValue!==void 0)$.push(`default: ${Q.defaultValueDescription||JSON.stringify(Q.defaultValue)}`);if($.length>0){let Y=`(${$.join(", ")})`;if(Q.description)return`${Q.description} ${Y}`;return Y}return Q.description}formatItemList(Q,$,Y){if($.length===0)return[];return[Y.styleTitle(Q),...$,""]}groupItems(Q,$,Y){let q=new Map;return Q.forEach((J)=>{let X=Y(J);if(!q.has(X))q.set(X,[])}),$.forEach((J)=>{let X=Y(J);if(!q.has(X))q.set(X,[]);q.get(X).push(J)}),q}formatHelp(Q,$){let Y=$.padWidth(Q,$),q=$.helpWidth??80;function J(z,B){return $.formatItem(z,Y,B,$)}let X=[`${$.styleTitle("Usage:")} ${$.styleUsage($.commandUsage(Q))}`,""],H=$.commandDescription(Q);if(H.length>0)X=X.concat([$.boxWrap($.styleCommandDescription(H),q),""]);let G=$.visibleArguments(Q).map((z)=>{return J($.styleArgumentTerm($.argumentTerm(z)),$.styleArgumentDescription($.argumentDescription(z)))});if(X=X.concat(this.formatItemList("Arguments:",G,$)),this.groupItems(Q.options,$.visibleOptions(Q),(z)=>z.helpGroupHeading??"Options:").forEach((z,B)=>{let Z=z.map((M)=>{return J($.styleOptionTerm($.optionTerm(M)),$.styleOptionDescription($.optionDescription(M)))});X=X.concat(this.formatItemList(B,Z,$))}),$.showGlobalOptions){let z=$.visibleGlobalOptions(Q).map((B)=>{return J($.styleOptionTerm($.optionTerm(B)),$.styleOptionDescription($.optionDescription(B)))});X=X.concat(this.formatItemList("Global Options:",z,$))}return this.groupItems(Q.commands,$.visibleCommands(Q),(z)=>z.helpGroup()||"Commands:").forEach((z,B)=>{let Z=z.map((M)=>{return J($.styleSubcommandTerm($.subcommandTerm(M)),$.styleSubcommandDescription($.subcommandDescription(M)))});X=X.concat(this.formatItemList(B,Z,$))}),X.join(`
75
75
  `)}displayWidth(Q){return JJ(Q).length}styleTitle(Q){return Q}styleUsage(Q){return Q.split(" ").map(($)=>{if($==="[options]")return this.styleOptionText($);if($==="[command]")return this.styleSubcommandText($);if($[0]==="["||$[0]==="<")return this.styleArgumentText($);return this.styleCommandText($)}).join(" ")}styleCommandDescription(Q){return this.styleDescriptionText(Q)}styleOptionDescription(Q){return this.styleDescriptionText(Q)}styleSubcommandDescription(Q){return this.styleDescriptionText(Q)}styleArgumentDescription(Q){return this.styleDescriptionText(Q)}styleDescriptionText(Q){return Q}styleOptionTerm(Q){return this.styleOptionText(Q)}styleSubcommandTerm(Q){return Q.split(" ").map(($)=>{if($==="[options]")return this.styleOptionText($);if($[0]==="["||$[0]==="<")return this.styleArgumentText($);return this.styleSubcommandText($)}).join(" ")}styleArgumentTerm(Q){return this.styleArgumentText(Q)}styleOptionText(Q){return Q}styleArgumentText(Q){return Q}styleSubcommandText(Q){return Q}styleCommandText(Q){return Q}padWidth(Q,$){return Math.max($.longestOptionTermLength(Q,$),$.longestGlobalOptionTermLength(Q,$),$.longestSubcommandTermLength(Q,$),$.longestArgumentTermLength(Q,$))}preformatted(Q){return/\n[^\S\r\n]/.test(Q)}formatItem(Q,$,Y,q){let X=" ".repeat(2);if(!Y)return X+Q;let H=Q.padEnd($+Q.length-q.displayWidth(Q)),G=2,W=(this.helpWidth??80)-$-G-2,z;if(W<this.minWidthToWrap||q.preformatted(Y))z=Y;else z=q.boxWrap(Y,W).replace(/\n/g,`
76
76
  `+" ".repeat($+G));return X+H+" ".repeat(G)+z.replace(/\n/g,`
77
77
  ${X}`)}boxWrap(Q,$){if($<this.minWidthToWrap)return Q;let Y=Q.split(/\r\n|\n/),q=/[\s]*[^\s]+/g,J=[];return Y.forEach((X)=>{let H=X.match(q);if(H===null){J.push("");return}let G=[H.shift()],K=this.displayWidth(G[0]);H.forEach((W)=>{let z=this.displayWidth(W);if(K+z<=$){G.push(W),K+=z;return}J.push(G.join(""));let B=W.trimStart();G=[B],K=this.displayWidth(B)}),J.push(G.join(""))}),J.join(`
@@ -96,11 +96,11 @@ Expecting one of '${Y.join("', '")}'`);if(this._lifeCycleHooks[Q])this._lifeCycl
96
96
  `),this.outputHelp({error:!0});let Y=$||{},q=Y.exitCode||1,J=Y.code||"commander.error";this._exit(q,J,Q)}_parseOptionsEnv(){this.options.forEach((Q)=>{if(Q.envVar&&Q.envVar in Z1.env){let $=Q.attributeName();if(this.getOptionValue($)===void 0||["default","config","env"].includes(this.getOptionValueSource($)))if(Q.required||Q.optional)this.emit(`optionEnv:${Q.name()}`,Z1.env[Q.envVar]);else this.emit(`optionEnv:${Q.name()}`)}})}_parseOptionsImplied(){let Q=new Y_(this.options),$=(Y)=>{return this.getOptionValue(Y)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(Y))};this.options.filter((Y)=>Y.implied!==void 0&&$(Y.attributeName())&&Q.valueFromOption(this.getOptionValue(Y.attributeName()),Y)).forEach((Y)=>{Object.keys(Y.implied).filter((q)=>!$(q)).forEach((q)=>{this.setOptionValueWithSource(q,Y.implied[q],"implied")})})}missingArgument(Q){let $=`error: missing required argument '${Q}'`;this.error($,{code:"commander.missingArgument"})}optionMissingArgument(Q){let $=`error: option '${Q.flags}' argument missing`;this.error($,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(Q){let $=`error: required option '${Q.flags}' not specified`;this.error($,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(Q,$){let Y=(X)=>{let H=X.attributeName(),G=this.getOptionValue(H),K=this.options.find((z)=>z.negate&&H===z.attributeName()),W=this.options.find((z)=>!z.negate&&H===z.attributeName());if(K&&(K.presetArg===void 0&&G===!1||K.presetArg!==void 0&&G===K.presetArg))return K;return W||X},q=(X)=>{let H=Y(X),G=H.attributeName();if(this.getOptionValueSource(G)==="env")return`environment variable '${H.envVar}'`;return`option '${H.flags}'`},J=`error: ${q(Q)} cannot be used with ${q($)}`;this.error(J,{code:"commander.conflictingOption"})}unknownOption(Q){if(this._allowUnknownOption)return;let $="";if(Q.startsWith("--")&&this._showSuggestionAfterError){let q=[],J=this;do{let X=J.createHelp().visibleOptions(J).filter((H)=>H.long).map((H)=>H.long);q=q.concat(X),J=J.parent}while(J&&!J._enablePositionalOptions);$=zJ(Q,q)}let Y=`error: unknown option '${Q}'${$}`;this.error(Y,{code:"commander.unknownOption"})}_excessArguments(Q){if(this._allowExcessArguments)return;let $=this.registeredArguments.length,Y=$===1?"":"s",J=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${$} argument${Y} but got ${Q.length}.`;this.error(J,{code:"commander.excessArguments"})}unknownCommand(){let Q=this.args[0],$="";if(this._showSuggestionAfterError){let q=[];this.createHelp().visibleCommands(this).forEach((J)=>{if(q.push(J.name()),J.alias())q.push(J.alias())}),$=zJ(Q,q)}let Y=`error: unknown command '${Q}'${$}`;this.error(Y,{code:"commander.unknownCommand"})}version(Q,$,Y){if(Q===void 0)return this._version;this._version=Q,$=$||"-V, --version",Y=Y||"output the version number";let q=this.createOption($,Y);return this._versionOptionName=q.attributeName(),this._registerOption(q),this.on("option:"+q.name(),()=>{this._outputConfiguration.writeOut(`${Q}
97
97
  `),this._exit(0,"commander.version",Q)}),this}description(Q,$){if(Q===void 0&&$===void 0)return this._description;if(this._description=Q,$)this._argsDescription=$;return this}summary(Q){if(Q===void 0)return this._summary;return this._summary=Q,this}alias(Q){if(Q===void 0)return this._aliases[0];let $=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)$=this.commands[this.commands.length-1];if(Q===$._name)throw Error("Command alias can't be the same as its name");let Y=this.parent?._findCommand(Q);if(Y){let q=[Y.name()].concat(Y.aliases()).join("|");throw Error(`cannot add alias '${Q}' to command '${this.name()}' as already have command '${q}'`)}return $._aliases.push(Q),this}aliases(Q){if(Q===void 0)return this._aliases;return Q.forEach(($)=>this.alias($)),this}usage(Q){if(Q===void 0){if(this._usage)return this._usage;let $=this.registeredArguments.map((Y)=>{return eB(Y)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?$:[]).join(" ")}return this._usage=Q,this}name(Q){if(Q===void 0)return this._name;return this._name=Q,this}helpGroup(Q){if(Q===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=Q,this}commandsGroup(Q){if(Q===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=Q,this}optionsGroup(Q){if(Q===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=Q,this}_initOptionGroup(Q){if(this._defaultOptionGroup&&!Q.helpGroupHeading)Q.helpGroup(this._defaultOptionGroup)}_initCommandGroup(Q){if(this._defaultCommandGroup&&!Q.helpGroup())Q.helpGroup(this._defaultCommandGroup)}nameFromFilename(Q){return this._name=z8.basename(Q,z8.extname(Q)),this}executableDir(Q){if(Q===void 0)return this._executableDir;return this._executableDir=Q,this}helpInformation(Q){let $=this.createHelp(),Y=this._getOutputContext(Q);$.prepareContext({error:Y.error,helpWidth:Y.helpWidth,outputHasColors:Y.hasColors});let q=$.formatHelp(this,$);if(Y.hasColors)return q;return this._outputConfiguration.stripColor(q)}_getOutputContext(Q){Q=Q||{};let $=!!Q.error,Y,q,J;if($)Y=(H)=>this._outputConfiguration.writeErr(H),q=this._outputConfiguration.getErrHasColors(),J=this._outputConfiguration.getErrHelpWidth();else Y=(H)=>this._outputConfiguration.writeOut(H),q=this._outputConfiguration.getOutHasColors(),J=this._outputConfiguration.getOutHelpWidth();return{error:$,write:(H)=>{if(!q)H=this._outputConfiguration.stripColor(H);return Y(H)},hasColors:q,helpWidth:J}}outputHelp(Q){let $;if(typeof Q==="function")$=Q,Q=void 0;let Y=this._getOutputContext(Q),q={error:Y.error,write:Y.write,command:this};this._getCommandAndAncestors().reverse().forEach((X)=>X.emit("beforeAllHelp",q)),this.emit("beforeHelp",q);let J=this.helpInformation({error:Y.error});if($){if(J=$(J),typeof J!=="string"&&!Buffer.isBuffer(J))throw Error("outputHelp callback must return a string or a Buffer")}if(Y.write(J),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",q),this._getCommandAndAncestors().forEach((X)=>X.emit("afterAllHelp",q))}helpOption(Q,$){if(typeof Q==="boolean"){if(Q){if(this._helpOption===null)this._helpOption=void 0;if(this._defaultOptionGroup)this._initOptionGroup(this._getHelpOption())}else this._helpOption=null;return this}if(this._helpOption=this.createOption(Q??"-h, --help",$??"display help for command"),Q||$)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(Q){return this._helpOption=Q,this._initOptionGroup(Q),this}help(Q){this.outputHelp(Q);let $=Number(Z1.exitCode??0);if($===0&&Q&&typeof Q!=="function"&&Q.error)$=1;this._exit($,"commander.help","(outputHelp)")}addHelpText(Q,$){let Y=["beforeAll","before","after","afterAll"];if(!Y.includes(Q))throw Error(`Unexpected value for position to addHelpText.
98
98
  Expecting one of '${Y.join("', '")}'`);let q=`${Q}Help`;return this.on(q,(J)=>{let X;if(typeof $==="function")X=$({error:J.error,command:J.command});else X=$;if(X)J.write(`${X}
99
- `)}),this}_outputHelpIfRequested(Q){let $=this._getHelpOption();if($&&Q.find((q)=>$.is(q)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function BJ(Q){return Q.map(($)=>{if(!$.startsWith("--inspect"))return $;let Y,q="127.0.0.1",J="9229",X;if((X=$.match(/^(--inspect(-brk)?)$/))!==null)Y=X[1];else if((X=$.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(Y=X[1],/^\d+$/.test(X[3]))J=X[3];else q=X[3];else if((X=$.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)Y=X[1],q=X[3],J=X[4];if(Y&&J!=="0")return`${Y}=${q}:${parseInt(J)+1}`;return $})}function f4(){if(Z1.env.NO_COLOR||Z1.env.FORCE_COLOR==="0"||Z1.env.FORCE_COLOR==="false")return!1;if(Z1.env.FORCE_COLOR||Z1.env.CLICOLOR_FORCE!==void 0)return!0;return}q_.Command=u4;q_.useColor=f4});var VJ=L8((K_)=>{var{Argument:ZJ}=V3(),{Command:m4}=_J(),{CommanderError:H_,InvalidArgumentError:MJ}=j2(),{Help:G_}=x4(),{Option:UJ}=C4();K_.program=new m4;K_.createCommand=(Q)=>new m4(Q);K_.createOption=(Q,$)=>new UJ(Q,$);K_.createArgument=(Q,$)=>new ZJ(Q,$);K_.Command=m4;K_.Option=UJ;K_.Argument=ZJ;K_.Help=G_;K_.CommanderError=H_;K_.InvalidArgumentError=MJ;K_.InvalidOptionArgumentError=MJ});var AJ,yD,hD,fD,uD,mD,LJ,gD,FJ,cD,B8,dD;var L3=A(()=>{AJ=B5(VJ(),1),{program:yD,createCommand:hD,createArgument:fD,createOption:uD,CommanderError:mD,InvalidArgumentError:LJ,InvalidOptionArgumentError:gD,Command:FJ,Argument:cD,Option:B8,Help:dD}=AJ.default});import{existsSync as wJ,statSync as j_}from"fs";import{join as DJ}from"path";function jJ(Q,$){let Y=DJ(Q,$);if(!wJ(Y))return"missing";if(!j_(Y).isDirectory())throw new L(`Component root "${$}" exists at "${Y}" but is not a directory.`);return"directory"}function O_(Q,$){let Y=jJ(Q,$.singular),q=jJ(Q,$.plural);if(Y==="directory"&&q==="directory")return $.plural;if(Y==="directory")return $.singular;if(q==="directory")return $.plural;return $.plural}function I_(Q,$,Y,q,J){if(!J)return;let H=`${Y===q.plural?q.singular:q.plural}/${J}`,G=DJ(Q,H);if(!wJ(G))return;throw new n1(`Cross-root logical collision for "${$}": selected root "${Y}" but "${H}" already exists.`)}function S9(Q,$){let[Y,...q]=Q.split("/");if(!Y)return Q;let J=D_.get(Y);if(!J)return Q;let X=O_($,J),H=q.join("/");if(I_($,Q,X,J,H),!H)return X;return`${X}/${H}`}var w_,D_;var g4=A(()=>{t();w_={agent:"agents",command:"commands",plugin:"plugins",skill:"skills",tool:"tools",bundle:"bundles",profile:"profiles"},D_=new Map(Object.entries(w_).flatMap(([Q,$])=>{let Y={singular:Q,plural:$};return[[Q,Y],[$,Y]]}))});import{stat as N_}from"fs/promises";import{homedir as T_}from"os";import{isAbsolute as b_,join as OJ,relative as R_,resolve as IJ}from"path";function S_(Q){let $=Q.replace(/\\/g,"/");if($===F3)return".";if($.startsWith(c4))return $.slice(c4.length);return Q}function F0(){let Q=process.env.XDG_CONFIG_HOME,$=Q&&b_(Q)?Q:OJ(T_(),".config");return OJ($,"opencode")}async function NJ(){try{return(await N_(F0())).isDirectory()}catch{return!1}}function i8(Q,$,Y){if($){if(!Y)return Q;return S9(Q,Y)}let q=S_(Q),J=Y?IJ(Y):process.cwd(),X=IJ(J,F3),H;try{H=V0(X,q)}catch(W){if(W instanceof e1)throw new L(`Invalid local target "${Q}": ${W.message}`);throw W}let G=R_(X,H).replace(/\\/g,"/");if(G==="."||G==="")return F3;let K=Y?S9(G,X):G;return`${c4}${K}`}var F3=".opencode",c4;var k8=A(()=>{g4();t();g8();c4=`${F3}/`});class b0{cwd;config;constructor(Q,$){this.cwd=Q,this.config=$}static async requireInitialized(Q){let $=await T0(Q);if(!$)throw new h("No ocx.jsonc found in .opencode/ or project root. Run 'ocx init' first.");return new b0(Q,$)}getRegistries(){return this.config.registries}getComponentPath(){return".opencode"}}class E9{cwd;config;constructor(Q,$){this.cwd=Q,this.config=$}static async requireInitialized(){let Q=F0();if(!await NJ())throw new h("Global config not found. Run 'ocx init --global' first.");let $=await T0(Q);if(!$)throw new h("Global config not found. Run 'ocx init --global' first.");return new E9(Q,$)}getRegistries(){return this.config?.registries??{}}getComponentPath(){return""}}var k9=A(()=>{q0();t();k8()});import{rename as TJ,symlink as GO,unlink as bJ}from"fs/promises";async function v9(Q,$){let Y=`${Q}.tmp.${process.pid}`;try{await Bun.write(Y,JSON.stringify($,null,"\t"),{mode:384}),await TJ(Y,Q)}catch(q){try{await bJ(Y)}catch{}throw q}}async function RJ(Q,$){let Y=`${$}.tmp.${process.pid}`;try{let J=await Bun.file(Q).arrayBuffer();await Bun.write(Y,J,{mode:384}),await TJ(Y,$)}catch(q){try{await bJ(Y)}catch{}throw q}}var j3=()=>{};import{existsSync as SJ,statSync as E_}from"fs";import{readFile as k_,stat as v_}from"fs/promises";import{homedir as P_}from"os";import h1 from"path";function x_(Q={}){let $=Q.xdgConfigHome??process.env.XDG_CONFIG_HOME;if($&&$.trim().length>0)return h1.resolve($);let Y=Q.homeDir??P_();return h1.resolve(Y,".config")}function EJ(Q,$){let Y=h1.resolve(Q),q=h1.resolve($),J=h1.relative(Y,q);if(J==="")return!0;if(J==="..")return!1;if(J.startsWith(`..${h1.sep}`))return!1;return!h1.isAbsolute(J)}function w3(Q={}){return h1.join(x_(Q),"opencode")}function d4(Q,$={}){let Y=w3($);if(!EJ(Y,Q))return"local-project";let q=h1.join(Y,"profiles");if(EJ(q,Q))return"global-profile-root";return"global-root"}function _8(Q={}){return h1.join(w3(Q),"profiles")}function C_(Q=process.cwd()){let $=M8(Q);if($)return h1.join($,"profiles");return h1.join(Q,n8,"profiles")}function f1(Q){return h1.join(_8(),Q)}function kJ(Q,$=process.cwd()){return h1.join(C_($),Q)}function K0(Q){return h1.join(f1(Q),"ocx.jsonc")}function Z8(Q){return h1.join(f1(Q),"opencode.jsonc")}function o8(Q){return h1.join(f1(Q),"AGENTS.md")}function M8(Q){let $=Q;while(!0){let Y=h1.join($,n8);if(SJ(Y)&&E_(Y).isDirectory())return Y;let q=h1.join($,".git");if(SJ(q))return null;let J=h1.dirname($);if(J===$)return null;$=J}}function P9(){return h1.join(w3(),c0)}async function vJ(Q={}){let $=h1.join(w3(Q),c0),Y;try{Y=await v_($)}catch(q){let J=q.code;if(J==="ENOENT"||J==="ENOTDIR")throw new v8("missing",$);throw new v8("read-failed",$,q instanceof Error?q.message:String(q))}if(!Y.isFile())throw new v8("not-file",$);try{let q=await k_($,"utf8");return{path:$,content:q}}catch(q){throw new v8("read-failed",$,q instanceof Error?q.message:String(q))}}var c0="ocx.jsonc",w2="opencode.jsonc",n8=".opencode",v8;var W0=A(()=>{v8=class v8 extends Error{reason;configPath;constructor(Q,$,Y){let q=Q==="missing"?`Required global config is missing at "${$}".`:Q==="not-file"?`Required global config target is not a file: "${$}".`:`Failed to read required global config at "${$}": ${Y??"Unknown read error"}`;super(q);this.reason=Q;this.configPath=$;this.name="RequiredGlobalConfigReadError"}}});var a0,VO;var D3=A(()=>{H8();b9();a0=F().min(1,"Profile name is required").max(32,"Profile name must be 32 characters or less").regex(/^[a-zA-Z][a-zA-Z0-9._-]*$/,"Profile name must start with a letter and contain only alphanumeric characters, dots, underscores, or hyphens"),VO=Q1({name:a0,ocx:K8,opencode:q1(F(),I8()).optional(),hasAgents:i1()})});import{mkdir as PJ,readdir as y_,rename as h_,rm as f_,stat as p4}from"fs/promises";function m_(Q){if(Q.length===0)return"Unknown parse error";let $=Q[0];if(!$)return"Unknown parse error";return`${n0($.error)} at offset ${$.offset}`}function xJ(Q,$){let Y=[],q=O1(Q,Y,{allowTrailingComma:!0});if(Y.length>0){let J=m_(Y);throw new h(`Invalid JSONC in ${$}: ${J}`)}return q}function g_(Q,$,Y){let q=K8.safeParse(Q);if(!q.success){let J=q.error.issues[0],X=J?.path.length?J.path.join("."):"root",H=J?.message??"Invalid profile OCX configuration";throw new h(`Invalid profile "${Y}" ocx.jsonc at ${$}: ${X} ${H}`)}return q.data}function c_(Q,$,Y){if(!Q||typeof Q!=="object"||Array.isArray(Q))throw new h(`Invalid profile "${Y}" opencode.jsonc at ${$}: root must be an object`);return Q}function CJ(Q,$){if(Q.trim().length===0)throw new h(`Invalid profile from ${$}: value cannot be empty or whitespace`);return Q}class u1{cwd;constructor(Q=process.cwd()){this.cwd=Q}get profilesDir(){return _8()}static create(Q){return new u1(Q??process.cwd())}static async requireInitialized(){let Q=u1.create();if(!await Q.isInitialized())throw new D9;return Q}async isInitialized(){try{return(await p4(this.profilesDir)).isDirectory()}catch{return!1}}async ensureInitialized(){if(!await this.isInitialized())throw new D9}async list(){return await this.ensureInitialized(),(await y_(this.profilesDir,{withFileTypes:!0,encoding:"utf8"})).filter(($)=>$.isDirectory()&&!$.name.startsWith(".")).map(($)=>$.name).sort()}async exists(Q){let $=f1(Q);try{return(await p4($)).isDirectory()}catch{return!1}}async get(Q){if(!await this.exists(Q))throw new C1(Q);let $=K0(Q),Y=Bun.file($);if(!await Y.exists())throw new h(`Profile "${Q}" is missing ocx.jsonc. Expected at: ${$}`);let q=await Y.text(),J=xJ(q,$),X=g_(J,$,Q),H=Z8(Q),G=Bun.file(H),K;if(await G.exists()){let Z=await G.text(),M=xJ(Z,H);K=c_(M,H,Q)}let W=o8(Q),B=await Bun.file(W).exists();return{name:Q,ocx:X,opencode:K,hasAgents:B}}async getLayered(Q,$){let Y=kJ(Q,$),q=!1;try{q=(await p4(Y)).isDirectory()}catch{q=!1}if(q)throw new D4(Q,Y);return this.get(Q)}async add(Q){let $=a0.safeParse(Q);if(!$.success)throw new u0(Q,$.error.issues[0]?.message??"Invalid name");if(await this.exists(Q))throw new N8(Q);let Y=f1(Q);await PJ(Y,{recursive:!0,mode:448});let q=K0(Q);if(!await Bun.file(q).exists())await Bun.write(q,u_,{mode:384});let X=Z8(Q);if(!await Bun.file(X).exists())await v9(X,{});let G=o8(Q);if(!await Bun.file(G).exists()){let W=`# Profile Instructions
99
+ `)}),this}_outputHelpIfRequested(Q){let $=this._getHelpOption();if($&&Q.find((q)=>$.is(q)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function BJ(Q){return Q.map(($)=>{if(!$.startsWith("--inspect"))return $;let Y,q="127.0.0.1",J="9229",X;if((X=$.match(/^(--inspect(-brk)?)$/))!==null)Y=X[1];else if((X=$.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(Y=X[1],/^\d+$/.test(X[3]))J=X[3];else q=X[3];else if((X=$.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)Y=X[1],q=X[3],J=X[4];if(Y&&J!=="0")return`${Y}=${q}:${parseInt(J)+1}`;return $})}function f4(){if(Z1.env.NO_COLOR||Z1.env.FORCE_COLOR==="0"||Z1.env.FORCE_COLOR==="false")return!1;if(Z1.env.FORCE_COLOR||Z1.env.CLICOLOR_FORCE!==void 0)return!0;return}q_.Command=u4;q_.useColor=f4});var VJ=L8((K_)=>{var{Argument:ZJ}=V3(),{Command:m4}=_J(),{CommanderError:H_,InvalidArgumentError:MJ}=j2(),{Help:G_}=x4(),{Option:UJ}=C4();K_.program=new m4;K_.createCommand=(Q)=>new m4(Q);K_.createOption=(Q,$)=>new UJ(Q,$);K_.createArgument=(Q,$)=>new ZJ(Q,$);K_.Command=m4;K_.Option=UJ;K_.Argument=ZJ;K_.Help=G_;K_.CommanderError=H_;K_.InvalidArgumentError=MJ;K_.InvalidOptionArgumentError=MJ});var AJ,uD,mD,gD,cD,dD,LJ,pD,FJ,lD,B8,iD;var L3=A(()=>{AJ=B5(VJ(),1),{program:uD,createCommand:mD,createArgument:gD,createOption:cD,CommanderError:dD,InvalidArgumentError:LJ,InvalidOptionArgumentError:pD,Command:FJ,Argument:lD,Option:B8,Help:iD}=AJ.default});import{existsSync as wJ,statSync as j_}from"fs";import{join as DJ}from"path";function jJ(Q,$){let Y=DJ(Q,$);if(!wJ(Y))return"missing";if(!j_(Y).isDirectory())throw new L(`Component root "${$}" exists at "${Y}" but is not a directory.`);return"directory"}function O_(Q,$){let Y=jJ(Q,$.singular),q=jJ(Q,$.plural);if(Y==="directory"&&q==="directory")return $.plural;if(Y==="directory")return $.singular;if(q==="directory")return $.plural;return $.plural}function I_(Q,$,Y,q,J){if(!J)return;let H=`${Y===q.plural?q.singular:q.plural}/${J}`,G=DJ(Q,H);if(!wJ(G))return;throw new n1(`Cross-root logical collision for "${$}": selected root "${Y}" but "${H}" already exists.`)}function S9(Q,$){let[Y,...q]=Q.split("/");if(!Y)return Q;let J=D_.get(Y);if(!J)return Q;let X=O_($,J),H=q.join("/");if(I_($,Q,X,J,H),!H)return X;return`${X}/${H}`}var w_,D_;var g4=A(()=>{t();w_={agent:"agents",command:"commands",plugin:"plugins",skill:"skills",tool:"tools",bundle:"bundles",profile:"profiles"},D_=new Map(Object.entries(w_).flatMap(([Q,$])=>{let Y={singular:Q,plural:$};return[[Q,Y],[$,Y]]}))});import{stat as N_}from"fs/promises";import{homedir as T_}from"os";import{isAbsolute as b_,join as OJ,relative as R_,resolve as IJ}from"path";function S_(Q){let $=Q.replace(/\\/g,"/");if($===F3)return".";if($.startsWith(c4))return $.slice(c4.length);return Q}function j0(){let Q=process.env.XDG_CONFIG_HOME,$=Q&&b_(Q)?Q:OJ(T_(),".config");return OJ($,"opencode")}async function NJ(){try{return(await N_(j0())).isDirectory()}catch{return!1}}function i8(Q,$,Y){if($){if(!Y)return Q;return S9(Q,Y)}let q=S_(Q),J=Y?IJ(Y):process.cwd(),X=IJ(J,F3),H;try{H=A0(X,q)}catch(W){if(W instanceof e1)throw new L(`Invalid local target "${Q}": ${W.message}`);throw W}let G=R_(X,H).replace(/\\/g,"/");if(G==="."||G==="")return F3;let K=Y?S9(G,X):G;return`${c4}${K}`}var F3=".opencode",c4;var k8=A(()=>{g4();t();g8();c4=`${F3}/`});class R0{cwd;config;constructor(Q,$){this.cwd=Q,this.config=$}static async requireInitialized(Q){let $=await b0(Q);if(!$)throw new h("No ocx.jsonc found in .opencode/ or project root. Run 'ocx init' first.");return new R0(Q,$)}getRegistries(){return this.config.registries}getComponentPath(){return".opencode"}}class E9{cwd;config;constructor(Q,$){this.cwd=Q,this.config=$}static async requireInitialized(){let Q=j0();if(!await NJ())throw new h("Global config not found. Run 'ocx init --global' first.");let $=await b0(Q);if(!$)throw new h("Global config not found. Run 'ocx init --global' first.");return new E9(Q,$)}getRegistries(){return this.config?.registries??{}}getComponentPath(){return""}}var k9=A(()=>{q0();t();k8()});import{rename as TJ,symlink as zO,unlink as bJ}from"fs/promises";async function v9(Q,$){let Y=`${Q}.tmp.${process.pid}`;try{await Bun.write(Y,JSON.stringify($,null,"\t"),{mode:384}),await TJ(Y,Q)}catch(q){try{await bJ(Y)}catch{}throw q}}async function RJ(Q,$){let Y=`${$}.tmp.${process.pid}`;try{let J=await Bun.file(Q).arrayBuffer();await Bun.write(Y,J,{mode:384}),await TJ(Y,$)}catch(q){try{await bJ(Y)}catch{}throw q}}var j3=()=>{};import{existsSync as SJ,statSync as E_}from"fs";import{readFile as k_,stat as v_}from"fs/promises";import{homedir as P_}from"os";import h1 from"path";function x_(Q={}){let $=Q.xdgConfigHome??process.env.XDG_CONFIG_HOME;if($&&$.trim().length>0)return h1.resolve($);let Y=Q.homeDir??P_();return h1.resolve(Y,".config")}function EJ(Q,$){let Y=h1.resolve(Q),q=h1.resolve($),J=h1.relative(Y,q);if(J==="")return!0;if(J==="..")return!1;if(J.startsWith(`..${h1.sep}`))return!1;return!h1.isAbsolute(J)}function w3(Q={}){return h1.join(x_(Q),"opencode")}function d4(Q,$={}){let Y=w3($);if(!EJ(Y,Q))return"local-project";let q=h1.join(Y,"profiles");if(EJ(q,Q))return"global-profile-root";return"global-root"}function _8(Q={}){return h1.join(w3(Q),"profiles")}function C_(Q=process.cwd()){let $=M8(Q);if($)return h1.join($,"profiles");return h1.join(Q,n8,"profiles")}function f1(Q){return h1.join(_8(),Q)}function kJ(Q,$=process.cwd()){return h1.join(C_($),Q)}function K0(Q){return h1.join(f1(Q),"ocx.jsonc")}function Z8(Q){return h1.join(f1(Q),"opencode.jsonc")}function o8(Q){return h1.join(f1(Q),"AGENTS.md")}function M8(Q){let $=Q;while(!0){let Y=h1.join($,n8);if(SJ(Y)&&E_(Y).isDirectory())return Y;let q=h1.join($,".git");if(SJ(q))return null;let J=h1.dirname($);if(J===$)return null;$=J}}function P9(){return h1.join(w3(),d0)}async function vJ(Q={}){let $=h1.join(w3(Q),d0),Y;try{Y=await v_($)}catch(q){let J=q.code;if(J==="ENOENT"||J==="ENOTDIR")throw new v8("missing",$);throw new v8("read-failed",$,q instanceof Error?q.message:String(q))}if(!Y.isFile())throw new v8("not-file",$);try{let q=await k_($,"utf8");return{path:$,content:q}}catch(q){throw new v8("read-failed",$,q instanceof Error?q.message:String(q))}}var d0="ocx.jsonc",w2="opencode.jsonc",n8=".opencode",v8;var W0=A(()=>{v8=class v8 extends Error{reason;configPath;constructor(Q,$,Y){let q=Q==="missing"?`Required global config is missing at "${$}".`:Q==="not-file"?`Required global config target is not a file: "${$}".`:`Failed to read required global config at "${$}": ${Y??"Unknown read error"}`;super(q);this.reason=Q;this.configPath=$;this.name="RequiredGlobalConfigReadError"}}});var a0,FO;var D3=A(()=>{H8();b9();a0=F().min(1,"Profile name is required").max(32,"Profile name must be 32 characters or less").regex(/^[a-zA-Z][a-zA-Z0-9._-]*$/,"Profile name must start with a letter and contain only alphanumeric characters, dots, underscores, or hyphens"),FO=Q1({name:a0,ocx:K8,opencode:q1(F(),I8()).optional(),hasAgents:i1()})});import{mkdir as PJ,readdir as y_,rename as h_,rm as f_,stat as p4}from"fs/promises";function m_(Q){if(Q.length===0)return"Unknown parse error";let $=Q[0];if(!$)return"Unknown parse error";return`${n0($.error)} at offset ${$.offset}`}function xJ(Q,$){let Y=[],q=O1(Q,Y,{allowTrailingComma:!0});if(Y.length>0){let J=m_(Y);throw new h(`Invalid JSONC in ${$}: ${J}`)}return q}function g_(Q,$,Y){let q=K8.safeParse(Q);if(!q.success){let J=q.error.issues[0],X=J?.path.length?J.path.join("."):"root",H=J?.message??"Invalid profile OCX configuration";throw new h(`Invalid profile "${Y}" ocx.jsonc at ${$}: ${X} ${H}`)}return q.data}function c_(Q,$,Y){if(!Q||typeof Q!=="object"||Array.isArray(Q))throw new h(`Invalid profile "${Y}" opencode.jsonc at ${$}: root must be an object`);return Q}function CJ(Q,$){if(Q.trim().length===0)throw new h(`Invalid profile from ${$}: value cannot be empty or whitespace`);return Q}class u1{cwd;constructor(Q=process.cwd()){this.cwd=Q}get profilesDir(){return _8()}static create(Q){return new u1(Q??process.cwd())}static async requireInitialized(){let Q=u1.create();if(!await Q.isInitialized())throw new D9;return Q}async isInitialized(){try{return(await p4(this.profilesDir)).isDirectory()}catch{return!1}}async ensureInitialized(){if(!await this.isInitialized())throw new D9}async list(){return await this.ensureInitialized(),(await y_(this.profilesDir,{withFileTypes:!0,encoding:"utf8"})).filter(($)=>$.isDirectory()&&!$.name.startsWith(".")).map(($)=>$.name).sort()}async exists(Q){let $=f1(Q);try{return(await p4($)).isDirectory()}catch{return!1}}async get(Q){if(!await this.exists(Q))throw new C1(Q);let $=K0(Q),Y=Bun.file($);if(!await Y.exists())throw new h(`Profile "${Q}" is missing ocx.jsonc. Expected at: ${$}`);let q=await Y.text(),J=xJ(q,$),X=g_(J,$,Q),H=Z8(Q),G=Bun.file(H),K;if(await G.exists()){let Z=await G.text(),M=xJ(Z,H);K=c_(M,H,Q)}let W=o8(Q),B=await Bun.file(W).exists();return{name:Q,ocx:X,opencode:K,hasAgents:B}}async getLayered(Q,$){let Y=kJ(Q,$),q=!1;try{q=(await p4(Y)).isDirectory()}catch{q=!1}if(q)throw new D4(Q,Y);return this.get(Q)}async add(Q){let $=a0.safeParse(Q);if(!$.success)throw new m0(Q,$.error.issues[0]?.message??"Invalid name");if(await this.exists(Q))throw new N8(Q);let Y=f1(Q);await PJ(Y,{recursive:!0,mode:448});let q=K0(Q);if(!await Bun.file(q).exists())await Bun.write(q,u_,{mode:384});let X=Z8(Q);if(!await Bun.file(X).exists())await v9(X,{});let G=o8(Q);if(!await Bun.file(G).exists()){let W=`# Profile Instructions
100
100
 
101
101
  <!-- Add your custom instructions for this profile here -->
102
102
  <!-- These will be included when running \`ocx opencode -p ${Q}\` -->
103
- `;await Bun.write(G,W,{mode:384})}}async remove(Q){if(!await this.exists(Q))throw new C1(Q);if((await this.list()).length<=1)throw Error("Cannot delete the last profile. At least one profile must exist.");let Y=f1(Q);await f_(Y,{recursive:!0})}async move(Q,$){let Y=a0.safeParse(Q);if(!Y.success)throw new u0(Q,Y.error.issues[0]?.message??"Invalid name");let q=a0.safeParse($);if(!q.success)throw new u0($,q.error.issues[0]?.message??"Invalid name");if(await this.ensureInitialized(),!await this.exists(Q))throw new C1(Q);if(Q===$)return{warnActiveProfile:!1};if(await this.exists($))throw new n1(`Cannot move: profile "${$}" already exists. Remove it first with 'ocx profile rm ${$} --global'.`);let J=process.env.OCX_PROFILE===Q,X=f1(Q),H=f1($);try{await h_(X,H)}catch(G){if(G instanceof Error&&"code"in G){let K=G.code;if(K==="EEXIST"||K==="ENOTEMPTY")throw new n1(`Cannot move: profile "${$}" already exists. Remove it first with 'ocx profile rm ${$} --global'.`);if(K==="ENOENT")throw new C1(Q)}throw G}return{warnActiveProfile:J}}async resolveProfile(Q){if(Q!==void 0){let q=CJ(Q,"CLI option --profile");if(!await this.exists(q))throw new C1(q);return q}let $=process.env.OCX_PROFILE;if($!==void 0){let q=CJ($,"environment variable OCX_PROFILE");if(!await this.exists(q))throw new C1(q);return q}let Y="default";if(!await this.exists(Y))throw new C1(Y);return Y}async initialize(){await PJ(this.profilesDir,{recursive:!0,mode:448}),await this.add("default")}}var yJ,u_=`{
103
+ `;await Bun.write(G,W,{mode:384})}}async remove(Q){if(!await this.exists(Q))throw new C1(Q);if((await this.list()).length<=1)throw Error("Cannot delete the last profile. At least one profile must exist.");let Y=f1(Q);await f_(Y,{recursive:!0})}async move(Q,$){let Y=a0.safeParse(Q);if(!Y.success)throw new m0(Q,Y.error.issues[0]?.message??"Invalid name");let q=a0.safeParse($);if(!q.success)throw new m0($,q.error.issues[0]?.message??"Invalid name");if(await this.ensureInitialized(),!await this.exists(Q))throw new C1(Q);if(Q===$)return{warnActiveProfile:!1};if(await this.exists($))throw new n1(`Cannot move: profile "${$}" already exists. Remove it first with 'ocx profile rm ${$} --global'.`);let J=process.env.OCX_PROFILE===Q,X=f1(Q),H=f1($);try{await h_(X,H)}catch(G){if(G instanceof Error&&"code"in G){let K=G.code;if(K==="EEXIST"||K==="ENOTEMPTY")throw new n1(`Cannot move: profile "${$}" already exists. Remove it first with 'ocx profile rm ${$} --global'.`);if(K==="ENOENT")throw new C1(Q)}throw G}return{warnActiveProfile:J}}async resolveProfile(Q){if(Q!==void 0){let q=CJ(Q,"CLI option --profile");if(!await this.exists(q))throw new C1(q);return q}let $=process.env.OCX_PROFILE;if($!==void 0){let q=CJ($,"environment variable OCX_PROFILE");if(!await this.exists(q))throw new C1(q);return q}let Y="default";if(!await this.exists(Y))throw new C1(Y);return Y}async initialize(){await PJ(this.profilesDir,{recursive:!0,mode:448}),await this.add("default")}}var yJ,u_=`{
104
104
  "$schema": "https://ocx.kdco.dev/schemas/profile.json",
105
105
  "registries": {},
106
106
  "renameWindow": true,
@@ -114,20 +114,20 @@ Expecting one of '${Y.join("', '")}'`);let q=`${Q}Help`;return this.on(q,(J)=>{l
114
114
  ],
115
115
  "include": []
116
116
  }
117
- `;var t0=A(()=>{D0();b9();t();j3();W0();D3();yJ={$schema:"https://ocx.kdco.dev/schemas/profile.json",registries:{},renameWindow:!0,exclude:["**/CLAUDE.md","**/CONTEXT.md","**/.opencode/**","**/opencode.jsonc","**/opencode.json"],include:[]}});function hJ(Q,$,Y){let q=(J)=>Q(J,...$);return Y===void 0?q:Object.assign(q,{lazy:Y,lazyArgs:$})}var fJ=()=>{};function uJ(Q,$,Y){let q=Q.length-$.length;if(q===0)return Q(...$);if(q===1)return hJ(Q,$,Y);throw Error("Wrong number of arguments")}var mJ=A(()=>{fJ()});function l4(Q){if(typeof Q!="object"||!Q)return!1;let $=Object.getPrototypeOf(Q);return $===null||$===Object.prototype}var gJ=()=>{};function i4(...Q){return uJ(cJ,Q)}function cJ(Q,$){let Y={...Q,...$};for(let q in $){if(!(q in Q))continue;let{[q]:J}=Q;if(!l4(J))continue;let{[q]:X}=$;l4(X)&&(Y[q]=cJ(J,X))}return Y}var dJ=A(()=>{mJ();gJ()});var pJ=A(()=>{dJ()});function D2(Q){let $=Q.startsWith("npm:"),Y=$?Q.slice(4):Q;if(!Y)return Q;if(Y.startsWith("@")){let X=Y.indexOf("/");if(X===-1)return Q;let G=Y.slice(X+1).indexOf("@");if(G===-1)return Q;let K=Y.slice(0,X+1+G);return $?`npm:${K}`:K}let q=Y.indexOf("@");if(q===-1)return Q;let J=Y.slice(0,q);return $?`npm:${J}`:J}function n4(Q){let $=new Map;for(let q=Q.length-1;q>=0;q--){let J=Q[q],X=D2(J);if(!$.has(X))$.set(X,q)}let Y=[];for(let[q,J]of Q.entries()){let X=D2(J);if($.get(X)===q)Y.push(J)}return Y}function O3(Q,$){let Y=i4(Q,$);if(Array.isArray(Q.plugin)&&Array.isArray($.plugin))Y.plugin=n4([...Q.plugin,...$.plugin]);else if(Array.isArray(Q.plugin))Y.plugin=Q.plugin;else if(Array.isArray($.plugin))Y.plugin=$.plugin;if(Array.isArray(Q.instructions)&&Array.isArray($.instructions))Y.instructions=Array.from(new Set([...Q.instructions,...$.instructions]));else if(Array.isArray(Q.instructions))Y.instructions=Q.instructions;else if(Array.isArray($.instructions))Y.instructions=$.instructions;return Y}var I3=A(()=>{pJ()});import{existsSync as d_,readFileSync as p_}from"fs";import{dirname as l_,isAbsolute as uO,resolve as o4}from"path";function i_(Q){let $=o4(Q);while(!0){let Y=o4($,".git");if(d_(Y))try{let J=z9("fs").statSync(Y);if(J.isDirectory())return $;if(J.isFile()){if(p_(Y,"utf8").match(/^gitdir:\s*(.+)$/m)?.[1])return $}}catch{}let q=l_($);if(q===$)return null;$=q}}function s4(Q){let $=o4(Q);return i_($)??$}var lJ=()=>{};import{existsSync as n_}from"fs";import*as s8 from"path";var{Glob:o_}=globalThis.Bun;function iJ(Q){return Q.startsWith("http://")||Q.startsWith("https://")}function s_(Q,$){if(iJ(Q))return;if(s8.isAbsolute(Q)||s8.win32.isAbsolute(Q))throw new L(`Absolute path not allowed in registry instructions: "${Q}" (from ${$})`);if(Q.startsWith("~"))throw new L(`Home directory path not allowed in registry instructions: "${Q}" (from ${$})`);if(Q.split(/[/\\]/).some((q)=>q===".."))throw new L(`Path traversal (..) not allowed in registry instructions: "${Q}" (from ${$})`)}function r_(Q,$,Y){if(iJ(Q))return[Q];if(s_(Q,Y),Q.includes("*")||Q.includes("?")||Q.includes("[")){let X=new o_(Q),H=[];for(let G of X.scanSync($)){let K=s8.join($,G);H.push(K)}return H}let J=s8.join($,Q);if(!n_(J))throw new L(`Registry instruction file not found: "${Q}" (from ${Y})
118
- Expected at: ${J}`);return[J]}function nJ(Q,$,Y){let q=[],J=new Set;for(let X of Q){let H=r_(X,$,Y);for(let G of H)if(!J.has(G))J.add(G),q.push(G)}return q}var oJ=A(()=>{t()});import{existsSync as r8,readFileSync as rJ,statSync as a_}from"fs";import{homedir as t_}from"os";import{join as R0,relative as aJ}from"path";var{Glob:N3}=globalThis.Bun;function e_(Q){return Q==="local-config"||Q==="cli"||Q==="env"}function r4(Q,$){if(Q.trim().length===0)throw new h(`Invalid profile from ${$}: value cannot be empty or whitespace`);return Q}function tJ(Q){if(Q.length===0)return"Unknown parse error";let $=Q[0];if(!$)return"Unknown parse error";return`${n0($.error)} at offset ${$.offset}`}function sJ(Q){let $;try{$=rJ(Q,"utf8")}catch(X){let H=X instanceof Error?X.message:"Unknown read error";throw new h(`Failed to read local config at ${Q}: ${H}`)}let Y=[],q=O1($,Y,{allowTrailingComma:!0});if(Y.length>0){let X=tJ(Y);throw new h(`Invalid JSONC in local config at ${Q}: ${X}`)}let J=b8.safeParse(q);if(!J.success){let X=J.error.issues[0],H=X?.path.length?X.path.join("."):"root",G=X?.message??"Invalid OCX config";throw new h(`Invalid local config at ${Q}: ${H} ${G}`)}return J.data}function QZ(Q){let $;try{$=rJ(Q,"utf8")}catch(J){let X=J instanceof Error?J.message:"Unknown read error";throw new h(`Failed to read local OpenCode config at ${Q}: ${X}`)}let Y=[],q=O1($,Y,{allowTrailingComma:!0});if(Y.length>0){let J=tJ(Y);throw new h(`Invalid JSONC in local OpenCode config at ${Q}: ${J}`)}if(!q||typeof q!=="object"||Array.isArray(q))throw new h(`Invalid local OpenCode config at ${Q}: root must be an object`);return q}function YZ(Q,$,Y){let q=[],J=$;while(!0){let X=R0(J,Q);if(r8(X)&&a_(X).isFile()){let G=aJ(Y,X);q.push(G)}if(J===Y)break;let H=R0(J,"..");if(H===J)break;J=H}return q}function qZ(Q,$){for(let Y of $Z){let q=YZ(Y,Q,$);if(q.length>0)return q}return[]}function T3(Q){return Q.startsWith("./")?Q.slice(2):Q}function JZ(Q,$,Y){return Q.filter((q)=>{for(let J of Y)if(new N3(T3(J)).match(q))return!0;for(let J of $)if(new N3(T3(J)).match(q))return!1;return!0})}async function XZ(Q){let $=await A0(Q);if(!$||Object.keys($.installed).length===0)return[];let Y=[];for(let[q,J]of Object.entries($.installed)){if(!J.opencode?.instructions)continue;let X=J.opencode.instructions;if(!Array.isArray(X))continue;let H=`${J.registryName}/${J.name} (${q})`,G=nJ(X,Q,H);Y.push(...G)}return Array.from(new Set(Y))}class e0{cwd;profileName;profile;localConfigDir;registryInstructions;cachedConfig=null;constructor(Q,$,Y,q,J){this.cwd=Q,this.profileName=$,this.profile=Y,this.localConfigDir=q,this.registryInstructions=J}static async create(Q,$){let Y=u1.create(Q),q=null,J="none",X=M8(Q);if(X){let z=R0(X,c0);if(r8(z)){let B=sJ(z);if(B.profile!==void 0)q=r4(B.profile,`local config at ${z}`),J="local-config"}}if(q===null){if($?.profile!==void 0)q=r4($.profile,"CLI option --profile"),J="cli";else if(process.env.OCX_PROFILE!==void 0)q=r4(process.env.OCX_PROFILE,"environment variable OCX_PROFILE"),J="env"}let H=await Y.isInitialized();if(e_(J)&&!H)throw new D9;let G=null;if(H)if(q!==null)G=await Y.getLayered(q,Q);else try{q=await Y.resolveProfile(),G=await Y.getLayered(q,Q),J="default"}catch(z){if(!(z instanceof C1)||z.profile!=="default")throw z;q=null,G=null,J="none"}let K;if(G)K=f1(q);else if(X)K=R0(X,"..");else K=F0();let W=await XZ(K);return new e0(Q,q,G,X,W)}resolve(){if(this.cachedConfig)return this.cachedConfig;let Q={},$=n8,Y={};if(this.profile){if(Q={...Q,...this.profile.ocx.registries},this.profile.ocx.componentPath)$=this.profile.ocx.componentPath;if(this.profile.opencode)Y=this.mergeOpencode(Y,this.profile.opencode)}let q=this.shouldLoadLocalConfig();if(!this.profile&&q&&this.localConfigDir){let X=this.loadLocalOcxConfig();if(X)Q=X.registries}if(this.localConfigDir){let X=this.loadLocalOpencodeConfig();if(X)Y=this.mergeOpencode(Y,X)}let J=this.discoverInstructions();return this.cachedConfig={registries:Q,componentPath:$,opencode:Y,instructions:J,profileName:this.profileName},this.cachedConfig}resolveWithOrigin(){let Q=new Map,$={},Y=n8,q={};if(Q.set("componentPath",{path:"",source:"default"}),this.profile){let H=`~/.config/opencode/profiles/${this.profileName}/ocx.jsonc`;for(let[G,K]of Object.entries(this.profile.ocx.registries))$[G]=K,Q.set(`registries.${G}`,{path:H,source:"global-profile"});if(this.profile.ocx.componentPath)Y=this.profile.ocx.componentPath,Q.set("componentPath",{path:H,source:"global-profile"});if(this.profile.opencode){q=this.mergeOpencode(q,this.profile.opencode);let G=`~/.config/opencode/profiles/${this.profileName}/opencode.jsonc`;for(let K of Object.keys(this.profile.opencode))Q.set(`opencode.${K}`,{path:G,source:"global-profile"})}}let J=this.shouldLoadLocalConfig();if(!this.profile&&J&&this.localConfigDir){let H=this.loadLocalOcxConfig();if(H){let G=R0(this.localConfigDir,c0);for(let[K,W]of Object.entries(H.registries))$[K]=W,Q.set(`registries.${K}`,{path:G,source:"local-config"})}}if(this.localConfigDir){let H=this.loadLocalOpencodeConfig();if(H){q=this.mergeOpencode(q,H);let G=R0(this.localConfigDir,w2);for(let K of Object.keys(H))Q.set(`opencode.${K}`,{path:G,source:"local-opencode"})}}let X=this.discoverInstructions();return{registries:$,componentPath:Y,opencode:q,instructions:X,profileName:this.profileName,origins:Q}}shouldLoadLocalConfig(){if(!this.profile?.ocx.exclude)return!0;if(!this.localConfigDir)return!0;let $=s4(this.cwd),Y=aJ($,this.localConfigDir),q=this.profile.ocx.exclude??[],J=this.profile.ocx.include??[];for(let X of J){let H=new N3(T3(X));if(H.match(`${Y}/`)||H.match(Y))return!0}for(let X of q){let H=new N3(T3(X));if(H.match(`${Y}/`)||H.match(`${Y}/**`))return!1}return!0}loadLocalOcxConfig(){if(!this.localConfigDir)return null;let Q=R0(this.localConfigDir,c0);if(!r8(Q))return null;return{registries:sJ(Q).registries}}loadLocalOpencodeConfig(){if(!this.localConfigDir)return null;let Q=R0(this.localConfigDir,w2);if(!r8(Q))return null;return QZ(Q)}discoverInstructions(){let Q=[],$=F0(),Y=R0($,"AGENTS.md");if(r8(Y))Q.push(Y);else if(!process.env.OPENCODE_DISABLE_CLAUDE_CODE_PROMPT){let z=R0(t_(),".claude","CLAUDE.md");if(r8(z))Q.push(z)}if(this.profile&&this.profileName){let z=R0(f1(this.profileName),"AGENTS.md");if(r8(z))Q.push(z)}let q=this.loadRegistryInstructions();Q.push(...q);let J=s4(this.cwd),X=qZ(this.cwd,J),H=this.profile?.ocx.exclude??[],G=this.profile?.ocx.include??[],W=JZ(X,H,G).map((z)=>R0(J,z));return Q.push(...W),Q}loadRegistryInstructions(){return this.registryInstructions}mergeOpencode(Q,$){return O3(Q,$)}getRegistries(){return this.resolve().registries}getComponentPath(){return this.resolve().componentPath}getProfileName(){return this.profileName}getCwd(){return this.cwd}getProfile(){return this.profile}}var $Z;var O2=A(()=>{D0();t0();W0();I3();q0();t();lJ();oJ();k8();$Z=["AGENTS.md","CLAUDE.md","CONTEXT.md"]});function J0(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)&&Object.getPrototypeOf(Q)===Object.prototype}var XX={};F8(XX,{fetchRegistryIndex:()=>P8,fetchFileContent:()=>a8,fetchComponentVersion:()=>E3,fetchComponent:()=>N2,classifyRegistryIndexIssue:()=>JX,_clearFetcherCacheForTests:()=>UZ});import{posix as HZ}from"path";function WZ(Q,$){return new f0(`Registry at ${Q} uses an incompatible format (${$.issue}). ${$.remediation}`,{url:Q,issue:$.issue,remediation:$.remediation,...$.schemaUrl!==void 0&&{schemaUrl:$.schemaUrl},...$.supportedMajor!==void 0&&{supportedMajor:$.supportedMajor},...$.detectedMajor!==void 0&&{detectedMajor:$.detectedMajor}})}function QX(Q,$){if(typeof Q!=="string")throw new L(`Invalid ${$}: expected string, got ${typeof Q}`);let Y=S3[Q]??Q,q=O9.safeParse(Y);if(!q.success)throw new L(`Unsupported component type "${Q}" in ${$}. Expected one of: ${O9.options.join(", ")}`);return q.data}function $X(Q){return typeof Q==="string"&&Object.hasOwn(S3,Q)}function R3(Q){return Q.startsWith(".opencode/")||Q.startsWith(".opencode\\")}function YX(Q){if(!J0(Q)||!Array.isArray(Q.files))return[];let $=[];for(let[Y,q]of Q.files.entries()){if(typeof q==="string"){if(!R3(q))continue;$.push({path:`files[${Y}]`,target:q});continue}if(!J0(q)||typeof q.target!=="string")continue;if(!R3(q.target))continue;$.push({path:`files[${Y}].target`,target:q.target})}return $}function zZ(Q){if(!J0(Q))return[];let $=Q.components;if(!Array.isArray($))return[];let Y=[];for(let[q,J]of $.entries()){if(!J0(J))continue;let X=J.type;if(!$X(X))continue;Y.push({path:`components[${q}].type`,type:X})}return Y}function BZ(Q){if(!J0(Q))return!1;if(typeof Q.type==="string"&&Q.type.startsWith("ocx:"))return!0;return YX(Q).length>0}async function _Z(Q){let $=g1(Q),Y=I2.get($);if(Y)return Y;try{await P8($)}catch(J){if(J instanceof I1||J instanceof _1)return null;throw J}if(!I2.has($))return null;let q=I2.get($);if(!q)throw Error(`Missing registry schema mode cache entry for ${$}`);return q}function eJ(Q,$){if(Q.includes("\x00"))throw new L(`Unsafe target "${Q}" in ${$}: null bytes are not allowed`);if(Q.includes("%"))throw new L(`Unsafe target "${Q}" in ${$}: encoded paths are not allowed`);if(Q.includes("\\"))throw new L(`Unsafe target "${Q}" in ${$}: Windows separators are not allowed`);if(Q.startsWith("/")||Q.startsWith("//")||/^[a-zA-Z]:/.test(Q))throw new L(`Unsafe target "${Q}" in ${$}: absolute paths are not allowed`);let Y=Q.startsWith(".opencode/")?Q.slice(10):Q;if(!Y)throw new L(`Unsafe target "${Q}" in ${$}: missing path after .opencode/`);let q=Y.split("/");if(q.some((W)=>W.length===0))throw new L(`Unsafe target "${Q}" in ${$}: empty path segments are not allowed`);if(q.some((W)=>W==="."||W===".."))throw new L(`Unsafe target "${Q}" in ${$}: traversal segments are not allowed`);let[J,...X]=q;if(!J)throw new L(`Unsafe target "${Q}" in ${$}: missing path root segment`);let G=[GZ[J]??J,...X].join("/"),K=HZ.normalize(G);if(K!==G)throw new L(`Unsafe target "${Q}" in ${$}: path normalization is ambiguous`);if(K==="."||K===".."||K.startsWith("../"))throw new L(`Unsafe target "${Q}" in ${$}: target escapes project root`);return K}function ZZ(Q,$){if(!J0(Q))return Q;let Y={...Q};if(Object.hasOwn(Y,"type"))Y.type=QX(Y.type,`${$}.type`);if(Array.isArray(Y.files))Y.files=Y.files.map((q,J)=>{if(typeof q==="string"){if(!R3(q))return q;return eJ(q,`${$}.files[${J}]`)}if(!J0(q))return q;let X=q.target;if(typeof X!=="string")return q;if(!R3(X))return q;return{...q,target:eJ(X,`${$}.files[${J}].target`)}});return Y}function MZ(Q,$){if(!J0(Q))throw new f0(`Registry at ${$} uses legacy schema v1 but does not expose an object index payload.`,{url:$,issue:"legacy-schema-v1",remediation:"Publish an object index with author/components fields, or upgrade to schema v2."});let Y=Q.components;if(!Array.isArray(Y))throw new f0(`Registry at ${$} uses legacy schema v1 but the components field is missing or invalid.`,{url:$,issue:"legacy-schema-v1",remediation:"Ensure the legacy index has a components array, or upgrade to schema v2."});let q=Y.map((J,X)=>{if(!J0(J))throw new L(`Invalid index component at components[${X}]: expected object, got ${typeof J}`);let{name:H,description:G}=J;if(typeof H!=="string")throw new L(`Invalid index component name at components[${X}].name`);if(typeof G!=="string")throw new L(`Invalid index component description at components[${X}].description`);return{name:H,type:QX(J.type,`components[${X}].type`),description:G}});return{...Q,components:q}}async function qX(Q,$,Y={}){let q=b3.get(Q);if(q)return q;let J=Y.requestUrl??Q,X=(async()=>{let H={url:J,phase:Y.phase},G;try{G=await fetch(J)}catch(W){throw new I1(`Network request failed for ${J}: ${W instanceof Error?W.message:String(W)}`,H)}if(!G.ok){if(G.status===404)throw new _1(`Not found: ${J}`);throw new I1(`Failed to fetch ${J}: ${G.status} ${G.statusText}`,{...H,status:G.status,statusText:G.statusText})}let K;try{K=await G.json()}catch(W){throw new I1(`Invalid JSON response from ${J}: ${W instanceof Error?W.message:String(W)}`,H)}return await $(K)})();return b3.set(Q,X),X.catch(()=>b3.delete(Q)),X}function JX(Q){let $=I9(Q);if(!$)return null;return{issue:$.issue,remediation:$.remediation,schemaUrl:$.schemaUrl,supportedMajor:$.supportedMajor,detectedMajor:$.detectedMajor}}async function P8(Q){let $=g1(Q),Y=`${$}/index.json`;return qX(Y,(q)=>{let J=JX(q);if(J&&J.issue!=="legacy-schema-v1")throw WZ(Y,J);let X=q,H="v2";if(J?.issue==="legacy-schema-v1"){H="legacy-v1";try{X=MZ(q,Y)}catch(K){if(K instanceof f0)throw K;let W=K instanceof Error?K.message:String(K);throw new f0(`Registry at ${Y} uses legacy schema v1 but cannot be adapted safely. ${W}`,{url:Y,issue:"invalid-format",remediation:"Fix the legacy payload shape (types/descriptions/components) or upgrade the registry to v2."})}}else{let K=zZ(X);if(K.length>0){let W=K[0];if(!W)throw Error("Unexpected missing legacy type issue");let z=S3[W.type];throw new f0(`Registry at ${Y} uses legacy component type "${W.type}" in ${W.path}. Use "${z}" for v2 registries.`,{url:Y,issue:"invalid-format",remediation:`Replace legacy type "${W.type}" with canonical "${z}" in v2 manifests.`})}}let G=T4.safeParse(X);if(!G.success)throw new f0(`Registry at ${Y} returned an unrecognized index format. Ensure it follows the OCX registry specification. Schema error: ${G.error.message}`,{url:Y,issue:"invalid-format",remediation:`Ensure the registry index follows the OCX registry specification. Schema error: ${G.error.message}`});return I2.set($,H),G.data},{phase:"registry-index-fetch"})}async function N2(Q,$){return(await E3(Q,$)).manifest}async function E3(Q,$,Y){let q=`${g1(Q)}/components/${$}.json`;return qX(`${q}#v=${Y??"latest"}`,async(J)=>{let X=KZ.safeParse(J);if(!X.success)throw new L(`Invalid packument format for "${$}": ${X.error.message}`);let H=X.data,G=Y??H["dist-tags"].latest,K=H.versions[G];if(!K){if(Y){let Z=Object.keys(H.versions).join(", ");throw new L(`Component "${$}" has no version "${Y}". Available: ${Z}`)}throw new L(`Component "${$}" has no manifest for latest version ${G}`)}let W=`component "${$}@${G}"`,z=K;if(BZ(K))if(await _Z(Q)!=="v2")z=ZZ(K,W);else{let V=YX(K)[0];if(V)throw new L(`Invalid component manifest for "${$}@${G}": target "${V.target}" at ${V.path} uses a legacy .opencode/ prefix. For v2 registries, use canonical root-relative targets like "plugins/...", "profiles/...", "agents/...", "skills/...", or "commands/..." (without .opencode/).`);if(J0(K)&&$X(K.type)){let U=S3[K.type];throw new L(`Invalid component manifest for "${$}@${G}": type "${K.type}" is a legacy v1 alias. Use "${U}" for v2 registries.`)}}let B=c8.safeParse(z);if(!B.success)throw new L(`Invalid component manifest for "${$}@${G}": ${B.error.message}`);return{manifest:B.data,version:G}},{phase:"packument-fetch",requestUrl:q})}async function a8(Q,$,Y){let q=`${g1(Q)}/components/${$}/${Y}`,J={url:q,phase:"file-content-fetch",qualifiedName:$},X;try{X=await fetch(q)}catch(H){throw new I1(`Network request failed for ${q}: ${H instanceof Error?H.message:String(H)}`,J)}if(!X.ok)throw new I1(`Failed to fetch file ${Y} for ${$} from ${q}: ${X.status} ${X.statusText}`,{...J,status:X.status,statusText:X.statusText});return X.text()}function UZ(){b3.clear(),I2.clear()}var b3,I2,S3,GZ,KZ;var t8=A(()=>{H8();g0();t();b3=new Map,I2=new Map,S3={"ocx:agent":"agent","ocx:skill":"skill","ocx:plugin":"plugin","ocx:command":"command","ocx:tool":"tool","ocx:bundle":"bundle","ocx:profile":"profile"},GZ={agent:"agents",skill:"skills",plugin:"plugins",command:"commands",tool:"tools",bundle:"bundles",profile:"profiles",philosophy:"tools"},KZ=M2.extend({versions:q1(F(),I8())})});function HX(Q,$){if(Q.includes("/"))return m0(Q);if($)return{namespace:$,component:Q};throw new L(`Component '${Q}' must include a registry alias (e.g., 'kdco/${Q}')`)}async function GX(Q,$){let Y=new Map,q=new Set,J=new Set,X=new Set,H={};async function G(z,B,Z=[]){let M=N4(z,B);if(Y.has(M))return;if(q.has(M)){let I=[...Z,M].join(" \u2192 ");throw new L(`Circular dependency detected: ${I}`)}q.add(M);let V=Q[z];if(!V)throw new _1(`Registry alias '${z}' not found. Add it with 'ocx registry add <url> --name ${z}'.`);let U;try{U=await N2(V.url,B)}catch(I){if(I instanceof I1)throw I;if(I instanceof _1)throw new _1(`Component '${B}' not found in registry '${z}'.`);if(I instanceof B1)throw I;throw new I1(`Failed to fetch component '${B}' from registry '${z}': ${I instanceof Error?I.message:String(I)}`,{url:V.url})}for(let I of U.dependencies){let c=HX(I,z);await G(c.namespace,c.component,[...Z,M])}let R=d8(U);if(Y.set(M,{...R,registryName:z,baseUrl:V.url,qualifiedName:M}),q.delete(M),U.npmDependencies)for(let I of U.npmDependencies)J.add(I);if(U.npmDevDependencies)for(let I of U.npmDevDependencies)X.add(I);if(R.opencode)H=O3(H,R.opencode)}for(let z of $){let B=HX(z);await G(B.namespace,B.component)}let K=Array.from(Y.values()),W=Array.from(Y.keys());return{components:K,installOrder:W,npmDependencies:Array.from(J),npmDevDependencies:Array.from(X),opencode:H}}var KX=A(()=>{g0();t();t8();I3()});import{statSync as VZ}from"fs";import{mkdir as WX}from"fs/promises";import z0 from"path";function x9(Q){try{return VZ(Q).isFile()}catch{return!1}}function k3(Q){let $=z0.resolve(Q);if(d4($)!=="local-project"){let K=z0.join($,"opencode.jsonc"),W=z0.join($,"opencode.json");if(x9(K))return{path:K,exists:!0};if(x9(W))return{path:W,exists:!0};return{path:K,exists:!1}}let J=z0.join($,t4,"opencode.jsonc"),X=z0.join($,t4,"opencode.json");if(x9(J))return{path:J,exists:!0};if(x9(X))return{path:X,exists:!0};let H=z0.join($,"opencode.jsonc"),G=z0.join($,"opencode.json");if(x9(H))return{path:H,exists:!0};if(x9(G))return{path:G,exists:!0};return{path:J,exists:!1}}async function zX(Q){let{path:$,exists:Y}=k3(Q);if(Y)return{path:$,created:!1};return await WX(z0.dirname($),{recursive:!0}),await Bun.write($,AZ),{path:$,created:!0}}async function e4(Q){let{path:$,exists:Y}=k3(Q);if(!Y)return null;let J=await Bun.file($).text();return{config:O1(J,[],{allowTrailingComma:!0}),content:J,path:$}}async function LZ(Q,$){await Bun.write(Q,$)}function FZ(Q,$){let q=O1(Q,[],{allowTrailingComma:!0});for(let J of $){if(q===null||q===void 0)return;if(typeof q!=="object")return;q=q[J]}return q}function BX(Q,$,Y){if(Y===null||Y===void 0)return Q;if(J0(Y)){let J=FZ(Q,$);if(J!==void 0&&(J===null||typeof J!=="object")){let H=Z9(Q,$,Y,a4);return M9(Q,H)}let X=Q;for(let[H,G]of Object.entries(Y))X=BX(X,[...$,H],G);return X}if(Array.isArray(Y)){let J=Z9(Q,$,Y,a4);return M9(Q,J)}let q=Z9(Q,$,Y,a4);return M9(Q,q)}async function Q6(Q,$){let Y=await e4(Q),q,J,X=!1;if(Y)q=Y.content,J=Y.path;else{q=JSON.stringify({$schema:"https://opencode.ai/config.json"},null,"\t");let W=z0.resolve(Q);J=d4(W)!=="local-project"?z0.join(W,"opencode.jsonc"):z0.join(W,t4,"opencode.jsonc"),await WX(z0.dirname(J),{recursive:!0}),X=!0}let H=q;q=BX(q,[],$);let G=q!==H;if(G)await LZ(J,q);return{path:J,created:X,changed:G}}var t4=".opencode",a4,AZ=`{
117
+ `;var t0=A(()=>{O0();b9();t();j3();W0();D3();yJ={$schema:"https://ocx.kdco.dev/schemas/profile.json",registries:{},renameWindow:!0,exclude:["**/CLAUDE.md","**/CONTEXT.md","**/.opencode/**","**/opencode.jsonc","**/opencode.json"],include:[]}});function hJ(Q,$,Y){let q=(J)=>Q(J,...$);return Y===void 0?q:Object.assign(q,{lazy:Y,lazyArgs:$})}var fJ=()=>{};function uJ(Q,$,Y){let q=Q.length-$.length;if(q===0)return Q(...$);if(q===1)return hJ(Q,$,Y);throw Error("Wrong number of arguments")}var mJ=A(()=>{fJ()});function l4(Q){if(typeof Q!="object"||!Q)return!1;let $=Object.getPrototypeOf(Q);return $===null||$===Object.prototype}var gJ=()=>{};function i4(...Q){return uJ(cJ,Q)}function cJ(Q,$){let Y={...Q,...$};for(let q in $){if(!(q in Q))continue;let{[q]:J}=Q;if(!l4(J))continue;let{[q]:X}=$;l4(X)&&(Y[q]=cJ(J,X))}return Y}var dJ=A(()=>{mJ();gJ()});var pJ=A(()=>{dJ()});function D2(Q){let $=Q.startsWith("npm:"),Y=$?Q.slice(4):Q;if(!Y)return Q;if(Y.startsWith("@")){let X=Y.indexOf("/");if(X===-1)return Q;let G=Y.slice(X+1).indexOf("@");if(G===-1)return Q;let K=Y.slice(0,X+1+G);return $?`npm:${K}`:K}let q=Y.indexOf("@");if(q===-1)return Q;let J=Y.slice(0,q);return $?`npm:${J}`:J}function n4(Q){let $=new Map;for(let q=Q.length-1;q>=0;q--){let J=Q[q],X=D2(J);if(!$.has(X))$.set(X,q)}let Y=[];for(let[q,J]of Q.entries()){let X=D2(J);if($.get(X)===q)Y.push(J)}return Y}function O3(Q,$){let Y=i4(Q,$);if(Array.isArray(Q.plugin)&&Array.isArray($.plugin))Y.plugin=n4([...Q.plugin,...$.plugin]);else if(Array.isArray(Q.plugin))Y.plugin=Q.plugin;else if(Array.isArray($.plugin))Y.plugin=$.plugin;if(Array.isArray(Q.instructions)&&Array.isArray($.instructions))Y.instructions=Array.from(new Set([...Q.instructions,...$.instructions]));else if(Array.isArray(Q.instructions))Y.instructions=Q.instructions;else if(Array.isArray($.instructions))Y.instructions=$.instructions;return Y}var I3=A(()=>{pJ()});import{existsSync as d_,readFileSync as p_}from"fs";import{dirname as l_,isAbsolute as cO,resolve as o4}from"path";function i_(Q){let $=o4(Q);while(!0){let Y=o4($,".git");if(d_(Y))try{let J=z9("fs").statSync(Y);if(J.isDirectory())return $;if(J.isFile()){if(p_(Y,"utf8").match(/^gitdir:\s*(.+)$/m)?.[1])return $}}catch{}let q=l_($);if(q===$)return null;$=q}}function s4(Q){let $=o4(Q);return i_($)??$}var lJ=()=>{};import{existsSync as n_}from"fs";import*as s8 from"path";var{Glob:o_}=globalThis.Bun;function iJ(Q){return Q.startsWith("http://")||Q.startsWith("https://")}function s_(Q,$){if(iJ(Q))return;if(s8.isAbsolute(Q)||s8.win32.isAbsolute(Q))throw new L(`Absolute path not allowed in registry instructions: "${Q}" (from ${$})`);if(Q.startsWith("~"))throw new L(`Home directory path not allowed in registry instructions: "${Q}" (from ${$})`);if(Q.split(/[/\\]/).some((q)=>q===".."))throw new L(`Path traversal (..) not allowed in registry instructions: "${Q}" (from ${$})`)}function r_(Q,$,Y){if(iJ(Q))return[Q];if(s_(Q,Y),Q.includes("*")||Q.includes("?")||Q.includes("[")){let X=new o_(Q),H=[];for(let G of X.scanSync($)){let K=s8.join($,G);H.push(K)}return H}let J=s8.join($,Q);if(!n_(J))throw new L(`Registry instruction file not found: "${Q}" (from ${Y})
118
+ Expected at: ${J}`);return[J]}function nJ(Q,$,Y){let q=[],J=new Set;for(let X of Q){let H=r_(X,$,Y);for(let G of H)if(!J.has(G))J.add(G),q.push(G)}return q}var oJ=A(()=>{t()});import{existsSync as r8,readFileSync as rJ,statSync as a_}from"fs";import{homedir as t_}from"os";import{join as S0,relative as aJ}from"path";var{Glob:N3}=globalThis.Bun;function e_(Q){return Q==="local-config"||Q==="cli"||Q==="env"}function r4(Q,$){if(Q.trim().length===0)throw new h(`Invalid profile from ${$}: value cannot be empty or whitespace`);return Q}function tJ(Q){if(Q.length===0)return"Unknown parse error";let $=Q[0];if(!$)return"Unknown parse error";return`${n0($.error)} at offset ${$.offset}`}function sJ(Q){let $;try{$=rJ(Q,"utf8")}catch(X){let H=X instanceof Error?X.message:"Unknown read error";throw new h(`Failed to read local config at ${Q}: ${H}`)}let Y=[],q=O1($,Y,{allowTrailingComma:!0});if(Y.length>0){let X=tJ(Y);throw new h(`Invalid JSONC in local config at ${Q}: ${X}`)}let J=b8.safeParse(q);if(!J.success){let X=J.error.issues[0],H=X?.path.length?X.path.join("."):"root",G=X?.message??"Invalid OCX config";throw new h(`Invalid local config at ${Q}: ${H} ${G}`)}return J.data}function QZ(Q){let $;try{$=rJ(Q,"utf8")}catch(J){let X=J instanceof Error?J.message:"Unknown read error";throw new h(`Failed to read local OpenCode config at ${Q}: ${X}`)}let Y=[],q=O1($,Y,{allowTrailingComma:!0});if(Y.length>0){let J=tJ(Y);throw new h(`Invalid JSONC in local OpenCode config at ${Q}: ${J}`)}if(!q||typeof q!=="object"||Array.isArray(q))throw new h(`Invalid local OpenCode config at ${Q}: root must be an object`);return q}function YZ(Q,$,Y){let q=[],J=$;while(!0){let X=S0(J,Q);if(r8(X)&&a_(X).isFile()){let G=aJ(Y,X);q.push(G)}if(J===Y)break;let H=S0(J,"..");if(H===J)break;J=H}return q}function qZ(Q,$){for(let Y of $Z){let q=YZ(Y,Q,$);if(q.length>0)return q}return[]}function T3(Q){return Q.startsWith("./")?Q.slice(2):Q}function JZ(Q,$,Y){return Q.filter((q)=>{for(let J of Y)if(new N3(T3(J)).match(q))return!0;for(let J of $)if(new N3(T3(J)).match(q))return!1;return!0})}async function XZ(Q){let $=await L0(Q);if(!$||Object.keys($.installed).length===0)return[];let Y=[];for(let[q,J]of Object.entries($.installed)){if(!J.opencode?.instructions)continue;let X=J.opencode.instructions;if(!Array.isArray(X))continue;let H=`${J.registryName}/${J.name} (${q})`,G=nJ(X,Q,H);Y.push(...G)}return Array.from(new Set(Y))}class e0{cwd;profileName;profile;localConfigDir;registryInstructions;cachedConfig=null;constructor(Q,$,Y,q,J){this.cwd=Q,this.profileName=$,this.profile=Y,this.localConfigDir=q,this.registryInstructions=J}static async create(Q,$){let Y=u1.create(Q),q=null,J="none",X=M8(Q);if(X){let z=S0(X,d0);if(r8(z)){let B=sJ(z);if(B.profile!==void 0)q=r4(B.profile,`local config at ${z}`),J="local-config"}}if(q===null){if($?.profile!==void 0)q=r4($.profile,"CLI option --profile"),J="cli";else if(process.env.OCX_PROFILE!==void 0)q=r4(process.env.OCX_PROFILE,"environment variable OCX_PROFILE"),J="env"}let H=await Y.isInitialized();if(e_(J)&&!H)throw new D9;let G=null;if(H)if(q!==null)G=await Y.getLayered(q,Q);else try{q=await Y.resolveProfile(),G=await Y.getLayered(q,Q),J="default"}catch(z){if(!(z instanceof C1)||z.profile!=="default")throw z;q=null,G=null,J="none"}let K;if(G)K=f1(q);else if(X)K=S0(X,"..");else K=j0();let W=await XZ(K);return new e0(Q,q,G,X,W)}resolve(){if(this.cachedConfig)return this.cachedConfig;let Q={},$=n8,Y={};if(this.profile){if(Q={...Q,...this.profile.ocx.registries},this.profile.ocx.componentPath)$=this.profile.ocx.componentPath;if(this.profile.opencode)Y=this.mergeOpencode(Y,this.profile.opencode)}let q=this.shouldLoadLocalConfig();if(!this.profile&&q&&this.localConfigDir){let X=this.loadLocalOcxConfig();if(X)Q=X.registries}if(this.localConfigDir){let X=this.loadLocalOpencodeConfig();if(X)Y=this.mergeOpencode(Y,X)}let J=this.discoverInstructions();return this.cachedConfig={registries:Q,componentPath:$,opencode:Y,instructions:J,profileName:this.profileName},this.cachedConfig}resolveWithOrigin(){let Q=new Map,$={},Y=n8,q={};if(Q.set("componentPath",{path:"",source:"default"}),this.profile){let H=`~/.config/opencode/profiles/${this.profileName}/ocx.jsonc`;for(let[G,K]of Object.entries(this.profile.ocx.registries))$[G]=K,Q.set(`registries.${G}`,{path:H,source:"global-profile"});if(this.profile.ocx.componentPath)Y=this.profile.ocx.componentPath,Q.set("componentPath",{path:H,source:"global-profile"});if(this.profile.opencode){q=this.mergeOpencode(q,this.profile.opencode);let G=`~/.config/opencode/profiles/${this.profileName}/opencode.jsonc`;for(let K of Object.keys(this.profile.opencode))Q.set(`opencode.${K}`,{path:G,source:"global-profile"})}}let J=this.shouldLoadLocalConfig();if(!this.profile&&J&&this.localConfigDir){let H=this.loadLocalOcxConfig();if(H){let G=S0(this.localConfigDir,d0);for(let[K,W]of Object.entries(H.registries))$[K]=W,Q.set(`registries.${K}`,{path:G,source:"local-config"})}}if(this.localConfigDir){let H=this.loadLocalOpencodeConfig();if(H){q=this.mergeOpencode(q,H);let G=S0(this.localConfigDir,w2);for(let K of Object.keys(H))Q.set(`opencode.${K}`,{path:G,source:"local-opencode"})}}let X=this.discoverInstructions();return{registries:$,componentPath:Y,opencode:q,instructions:X,profileName:this.profileName,origins:Q}}shouldLoadLocalConfig(){if(!this.profile?.ocx.exclude)return!0;if(!this.localConfigDir)return!0;let $=s4(this.cwd),Y=aJ($,this.localConfigDir),q=this.profile.ocx.exclude??[],J=this.profile.ocx.include??[];for(let X of J){let H=new N3(T3(X));if(H.match(`${Y}/`)||H.match(Y))return!0}for(let X of q){let H=new N3(T3(X));if(H.match(`${Y}/`)||H.match(`${Y}/**`))return!1}return!0}loadLocalOcxConfig(){if(!this.localConfigDir)return null;let Q=S0(this.localConfigDir,d0);if(!r8(Q))return null;return{registries:sJ(Q).registries}}loadLocalOpencodeConfig(){if(!this.localConfigDir)return null;let Q=S0(this.localConfigDir,w2);if(!r8(Q))return null;return QZ(Q)}discoverInstructions(){let Q=[],$=j0(),Y=S0($,"AGENTS.md");if(r8(Y))Q.push(Y);else if(!process.env.OPENCODE_DISABLE_CLAUDE_CODE_PROMPT){let z=S0(t_(),".claude","CLAUDE.md");if(r8(z))Q.push(z)}if(this.profile&&this.profileName){let z=S0(f1(this.profileName),"AGENTS.md");if(r8(z))Q.push(z)}let q=this.loadRegistryInstructions();Q.push(...q);let J=s4(this.cwd),X=qZ(this.cwd,J),H=this.profile?.ocx.exclude??[],G=this.profile?.ocx.include??[],W=JZ(X,H,G).map((z)=>S0(J,z));return Q.push(...W),Q}loadRegistryInstructions(){return this.registryInstructions}mergeOpencode(Q,$){return O3(Q,$)}getRegistries(){return this.resolve().registries}getComponentPath(){return this.resolve().componentPath}getProfileName(){return this.profileName}getCwd(){return this.cwd}getProfile(){return this.profile}}var $Z;var O2=A(()=>{O0();t0();W0();I3();q0();t();lJ();oJ();k8();$Z=["AGENTS.md","CLAUDE.md","CONTEXT.md"]});function J0(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)&&Object.getPrototypeOf(Q)===Object.prototype}var XX={};F8(XX,{fetchRegistryIndex:()=>P8,fetchFileContent:()=>a8,fetchComponentVersion:()=>E3,fetchComponent:()=>N2,classifyRegistryIndexIssue:()=>JX,_clearFetcherCacheForTests:()=>UZ});import{posix as HZ}from"path";function WZ(Q,$){return new u0(`Registry at ${Q} uses an incompatible format (${$.issue}). ${$.remediation}`,{url:Q,issue:$.issue,remediation:$.remediation,...$.schemaUrl!==void 0&&{schemaUrl:$.schemaUrl},...$.supportedMajor!==void 0&&{supportedMajor:$.supportedMajor},...$.detectedMajor!==void 0&&{detectedMajor:$.detectedMajor}})}function QX(Q,$){if(typeof Q!=="string")throw new L(`Invalid ${$}: expected string, got ${typeof Q}`);let Y=S3[Q]??Q,q=O9.safeParse(Y);if(!q.success)throw new L(`Unsupported component type "${Q}" in ${$}. Expected one of: ${O9.options.join(", ")}`);return q.data}function $X(Q){return typeof Q==="string"&&Object.hasOwn(S3,Q)}function R3(Q){return Q.startsWith(".opencode/")||Q.startsWith(".opencode\\")}function YX(Q){if(!J0(Q)||!Array.isArray(Q.files))return[];let $=[];for(let[Y,q]of Q.files.entries()){if(typeof q==="string"){if(!R3(q))continue;$.push({path:`files[${Y}]`,target:q});continue}if(!J0(q)||typeof q.target!=="string")continue;if(!R3(q.target))continue;$.push({path:`files[${Y}].target`,target:q.target})}return $}function zZ(Q){if(!J0(Q))return[];let $=Q.components;if(!Array.isArray($))return[];let Y=[];for(let[q,J]of $.entries()){if(!J0(J))continue;let X=J.type;if(!$X(X))continue;Y.push({path:`components[${q}].type`,type:X})}return Y}function BZ(Q){if(!J0(Q))return!1;if(typeof Q.type==="string"&&Q.type.startsWith("ocx:"))return!0;return YX(Q).length>0}async function _Z(Q){let $=g1(Q),Y=I2.get($);if(Y)return Y;try{await P8($)}catch(J){if(J instanceof I1||J instanceof _1)return null;throw J}if(!I2.has($))return null;let q=I2.get($);if(!q)throw Error(`Missing registry schema mode cache entry for ${$}`);return q}function eJ(Q,$){if(Q.includes("\x00"))throw new L(`Unsafe target "${Q}" in ${$}: null bytes are not allowed`);if(Q.includes("%"))throw new L(`Unsafe target "${Q}" in ${$}: encoded paths are not allowed`);if(Q.includes("\\"))throw new L(`Unsafe target "${Q}" in ${$}: Windows separators are not allowed`);if(Q.startsWith("/")||Q.startsWith("//")||/^[a-zA-Z]:/.test(Q))throw new L(`Unsafe target "${Q}" in ${$}: absolute paths are not allowed`);let Y=Q.startsWith(".opencode/")?Q.slice(10):Q;if(!Y)throw new L(`Unsafe target "${Q}" in ${$}: missing path after .opencode/`);let q=Y.split("/");if(q.some((W)=>W.length===0))throw new L(`Unsafe target "${Q}" in ${$}: empty path segments are not allowed`);if(q.some((W)=>W==="."||W===".."))throw new L(`Unsafe target "${Q}" in ${$}: traversal segments are not allowed`);let[J,...X]=q;if(!J)throw new L(`Unsafe target "${Q}" in ${$}: missing path root segment`);let G=[GZ[J]??J,...X].join("/"),K=HZ.normalize(G);if(K!==G)throw new L(`Unsafe target "${Q}" in ${$}: path normalization is ambiguous`);if(K==="."||K===".."||K.startsWith("../"))throw new L(`Unsafe target "${Q}" in ${$}: target escapes project root`);return K}function ZZ(Q,$){if(!J0(Q))return Q;let Y={...Q};if(Object.hasOwn(Y,"type"))Y.type=QX(Y.type,`${$}.type`);if(Array.isArray(Y.files))Y.files=Y.files.map((q,J)=>{if(typeof q==="string"){if(!R3(q))return q;return eJ(q,`${$}.files[${J}]`)}if(!J0(q))return q;let X=q.target;if(typeof X!=="string")return q;if(!R3(X))return q;return{...q,target:eJ(X,`${$}.files[${J}].target`)}});return Y}function MZ(Q,$){if(!J0(Q))throw new u0(`Registry at ${$} uses legacy schema v1 but does not expose an object index payload.`,{url:$,issue:"legacy-schema-v1",remediation:"Publish an object index with author/components fields, or upgrade to schema v2."});let Y=Q.components;if(!Array.isArray(Y))throw new u0(`Registry at ${$} uses legacy schema v1 but the components field is missing or invalid.`,{url:$,issue:"legacy-schema-v1",remediation:"Ensure the legacy index has a components array, or upgrade to schema v2."});let q=Y.map((J,X)=>{if(!J0(J))throw new L(`Invalid index component at components[${X}]: expected object, got ${typeof J}`);let{name:H,description:G}=J;if(typeof H!=="string")throw new L(`Invalid index component name at components[${X}].name`);if(typeof G!=="string")throw new L(`Invalid index component description at components[${X}].description`);return{name:H,type:QX(J.type,`components[${X}].type`),description:G}});return{...Q,components:q}}async function qX(Q,$,Y={}){let q=b3.get(Q);if(q)return q;let J=Y.requestUrl??Q,X=(async()=>{let H={url:J,phase:Y.phase},G;try{G=await fetch(J)}catch(W){throw new I1(`Network request failed for ${J}: ${W instanceof Error?W.message:String(W)}`,H)}if(!G.ok){if(G.status===404)throw new _1(`Not found: ${J}`);throw new I1(`Failed to fetch ${J}: ${G.status} ${G.statusText}`,{...H,status:G.status,statusText:G.statusText})}let K;try{K=await G.json()}catch(W){throw new I1(`Invalid JSON response from ${J}: ${W instanceof Error?W.message:String(W)}`,H)}return await $(K)})();return b3.set(Q,X),X.catch(()=>b3.delete(Q)),X}function JX(Q){let $=I9(Q);if(!$)return null;return{issue:$.issue,remediation:$.remediation,schemaUrl:$.schemaUrl,supportedMajor:$.supportedMajor,detectedMajor:$.detectedMajor}}async function P8(Q){let $=g1(Q),Y=`${$}/index.json`;return qX(Y,(q)=>{let J=JX(q);if(J&&J.issue!=="legacy-schema-v1")throw WZ(Y,J);let X=q,H="v2";if(J?.issue==="legacy-schema-v1"){H="legacy-v1";try{X=MZ(q,Y)}catch(K){if(K instanceof u0)throw K;let W=K instanceof Error?K.message:String(K);throw new u0(`Registry at ${Y} uses legacy schema v1 but cannot be adapted safely. ${W}`,{url:Y,issue:"invalid-format",remediation:"Fix the legacy payload shape (types/descriptions/components) or upgrade the registry to v2."})}}else{let K=zZ(X);if(K.length>0){let W=K[0];if(!W)throw Error("Unexpected missing legacy type issue");let z=S3[W.type];throw new u0(`Registry at ${Y} uses legacy component type "${W.type}" in ${W.path}. Use "${z}" for v2 registries.`,{url:Y,issue:"invalid-format",remediation:`Replace legacy type "${W.type}" with canonical "${z}" in v2 manifests.`})}}let G=T4.safeParse(X);if(!G.success)throw new u0(`Registry at ${Y} returned an unrecognized index format. Ensure it follows the OCX registry specification. Schema error: ${G.error.message}`,{url:Y,issue:"invalid-format",remediation:`Ensure the registry index follows the OCX registry specification. Schema error: ${G.error.message}`});return I2.set($,H),G.data},{phase:"registry-index-fetch"})}async function N2(Q,$){return(await E3(Q,$)).manifest}async function E3(Q,$,Y){let q=`${g1(Q)}/components/${$}.json`;return qX(`${q}#v=${Y??"latest"}`,async(J)=>{let X=KZ.safeParse(J);if(!X.success)throw new L(`Invalid packument format for "${$}": ${X.error.message}`);let H=X.data,G=Y??H["dist-tags"].latest,K=H.versions[G];if(!K){if(Y){let Z=Object.keys(H.versions).join(", ");throw new L(`Component "${$}" has no version "${Y}". Available: ${Z}`)}throw new L(`Component "${$}" has no manifest for latest version ${G}`)}let W=`component "${$}@${G}"`,z=K;if(BZ(K))if(await _Z(Q)!=="v2")z=ZZ(K,W);else{let V=YX(K)[0];if(V)throw new L(`Invalid component manifest for "${$}@${G}": target "${V.target}" at ${V.path} uses a legacy .opencode/ prefix. For v2 registries, use canonical root-relative targets like "plugins/...", "profiles/...", "agents/...", "skills/...", or "commands/..." (without .opencode/).`);if(J0(K)&&$X(K.type)){let U=S3[K.type];throw new L(`Invalid component manifest for "${$}@${G}": type "${K.type}" is a legacy v1 alias. Use "${U}" for v2 registries.`)}}let B=c8.safeParse(z);if(!B.success)throw new L(`Invalid component manifest for "${$}@${G}": ${B.error.message}`);return{manifest:B.data,version:G}},{phase:"packument-fetch",requestUrl:q})}async function a8(Q,$,Y){let q=`${g1(Q)}/components/${$}/${Y}`,J={url:q,phase:"file-content-fetch",qualifiedName:$},X;try{X=await fetch(q)}catch(H){throw new I1(`Network request failed for ${q}: ${H instanceof Error?H.message:String(H)}`,J)}if(!X.ok)throw new I1(`Failed to fetch file ${Y} for ${$} from ${q}: ${X.status} ${X.statusText}`,{...J,status:X.status,statusText:X.statusText});return X.text()}function UZ(){b3.clear(),I2.clear()}var b3,I2,S3,GZ,KZ;var t8=A(()=>{H8();c0();t();b3=new Map,I2=new Map,S3={"ocx:agent":"agent","ocx:skill":"skill","ocx:plugin":"plugin","ocx:command":"command","ocx:tool":"tool","ocx:bundle":"bundle","ocx:profile":"profile"},GZ={agent:"agents",skill:"skills",plugin:"plugins",command:"commands",tool:"tools",bundle:"bundles",profile:"profiles",philosophy:"tools"},KZ=M2.extend({versions:q1(F(),I8())})});function HX(Q,$){if(Q.includes("/"))return g0(Q);if($)return{namespace:$,component:Q};throw new L(`Component '${Q}' must include a registry alias (e.g., 'kdco/${Q}')`)}async function GX(Q,$){let Y=new Map,q=new Set,J=new Set,X=new Set,H={};async function G(z,B,Z=[]){let M=N4(z,B);if(Y.has(M))return;if(q.has(M)){let N=[...Z,M].join(" \u2192 ");throw new L(`Circular dependency detected: ${N}`)}q.add(M);let V=Q[z];if(!V)throw new _1(`Registry alias '${z}' not found. Add it with 'ocx registry add <url> --name ${z}'.`);let U;try{U=await N2(V.url,B)}catch(N){if(N instanceof I1)throw N;if(N instanceof _1)throw new _1(`Component '${B}' not found in registry '${z}'.`);if(N instanceof B1)throw N;throw new I1(`Failed to fetch component '${B}' from registry '${z}': ${N instanceof Error?N.message:String(N)}`,{url:V.url})}for(let N of U.dependencies){let c=HX(N,z);await G(c.namespace,c.component,[...Z,M])}let R=d8(U);if(Y.set(M,{...R,registryName:z,baseUrl:V.url,qualifiedName:M}),q.delete(M),U.npmDependencies)for(let N of U.npmDependencies)J.add(N);if(U.npmDevDependencies)for(let N of U.npmDevDependencies)X.add(N);if(R.opencode)H=O3(H,R.opencode)}for(let z of $){let B=HX(z);await G(B.namespace,B.component)}let K=Array.from(Y.values()),W=Array.from(Y.keys());return{components:K,installOrder:W,npmDependencies:Array.from(J),npmDevDependencies:Array.from(X),opencode:H}}var KX=A(()=>{c0();t();t8();I3()});import{statSync as VZ}from"fs";import{mkdir as WX}from"fs/promises";import z0 from"path";function x9(Q){try{return VZ(Q).isFile()}catch{return!1}}function k3(Q){let $=z0.resolve(Q);if(d4($)!=="local-project"){let K=z0.join($,"opencode.jsonc"),W=z0.join($,"opencode.json");if(x9(K))return{path:K,exists:!0};if(x9(W))return{path:W,exists:!0};return{path:K,exists:!1}}let J=z0.join($,t4,"opencode.jsonc"),X=z0.join($,t4,"opencode.json");if(x9(J))return{path:J,exists:!0};if(x9(X))return{path:X,exists:!0};let H=z0.join($,"opencode.jsonc"),G=z0.join($,"opencode.json");if(x9(H))return{path:H,exists:!0};if(x9(G))return{path:G,exists:!0};return{path:J,exists:!1}}async function zX(Q){let{path:$,exists:Y}=k3(Q);if(Y)return{path:$,created:!1};return await WX(z0.dirname($),{recursive:!0}),await Bun.write($,AZ),{path:$,created:!0}}async function e4(Q){let{path:$,exists:Y}=k3(Q);if(!Y)return null;let J=await Bun.file($).text();return{config:O1(J,[],{allowTrailingComma:!0}),content:J,path:$}}async function LZ(Q,$){await Bun.write(Q,$)}function FZ(Q,$){let q=O1(Q,[],{allowTrailingComma:!0});for(let J of $){if(q===null||q===void 0)return;if(typeof q!=="object")return;q=q[J]}return q}function BX(Q,$,Y){if(Y===null||Y===void 0)return Q;if(J0(Y)){let J=FZ(Q,$);if(J!==void 0&&(J===null||typeof J!=="object")){let H=Z9(Q,$,Y,a4);return M9(Q,H)}let X=Q;for(let[H,G]of Object.entries(Y))X=BX(X,[...$,H],G);return X}if(Array.isArray(Y)){let J=Z9(Q,$,Y,a4);return M9(Q,J)}let q=Z9(Q,$,Y,a4);return M9(Q,q)}async function Q6(Q,$){let Y=await e4(Q),q,J,X=!1;if(Y)q=Y.content,J=Y.path;else{q=JSON.stringify({$schema:"https://opencode.ai/config.json"},null,"\t");let W=z0.resolve(Q);J=d4(W)!=="local-project"?z0.join(W,"opencode.jsonc"):z0.join(W,t4,"opencode.jsonc"),await WX(z0.dirname(J),{recursive:!0}),X=!0}let H=q;q=BX(q,[],$);let G=q!==H;if(G)await LZ(J,q);return{path:J,created:X,changed:G}}var t4=".opencode",a4,AZ=`{
119
119
  "$schema": "https://opencode.ai/config.json"
120
120
  // Add MCP servers, tools, plugins here
121
121
  }
122
- `;var $6=A(()=>{D0();W0();a4={formattingOptions:{tabSize:2,insertSpaces:!1,eol:`
122
+ `;var $6=A(()=>{O0();W0();a4={formattingOptions:{tabSize:2,insertSpaces:!1,eol:`
123
123
  `}}});function _X(Q){return Q.replace(/\r\n/g,`
124
- `).trim()}function Y6(Q,$){return _X(Q)===_X($)}import{existsSync as jZ,lstatSync as wZ}from"fs";import{rm as DZ,unlink as OZ}from"fs/promises";import{join as UX}from"path";function VX(Q,$){let Y=[];for(let[q,J]of Object.entries($)){let X=Q[q]??null;if(X!==J)Y.push({name:q,from:X,to:J})}return{changed:Y.length>0,entries:Y}}function AX(Q,$){let Y=UX(Q,"node_modules"),q=$.map((J)=>J.name).join(", ");return{action:"delete",target:Y,details:{reason:`dependency declarations changed (${q}); invalidating to force reinstall`,path:Y}}}function MX(Q){if(Q&&typeof Q==="object"&&"code"in Q)return String(Q.code);return"UNKNOWN"}function q6(Q){if(Q instanceof Error)return Q.message;return String(Q)}function TZ(Q){return new Promise(($)=>setTimeout($,Q))}async function LX(Q,$){let Y=UX(Q,"node_modules"),q=$?.rmImpl??((J,X)=>DZ(J,X));if(!jZ(Y))return{success:!0,action:"none"};try{if(wZ(Y).isSymbolicLink())return await OZ(Y),{success:!0,action:"unlinked"}}catch(J){let X=MX(J);if(X==="ENOENT")return{success:!0,action:"none"};return{success:!1,action:"failed",error:{code:X,message:q6(J)}}}for(let J=0;J<=ZX;J++)try{return await q(Y,{recursive:!0,force:!0}),{success:!0,action:"removed"}}catch(X){let H=MX(X);if(H==="ENOENT")return{success:!0,action:"none"};if(!IZ.has(H))return{success:!1,action:"failed",error:{code:H,message:q6(X)}};if(J<ZX)await TZ(NZ*2**J);else return{success:!1,action:"failed",error:{code:H,message:q6(X)}}}return{success:!1,action:"failed",error:{code:"UNKNOWN",message:"exhausted retries"}}}var IZ,ZX=3,NZ=100;var FX=A(()=>{IZ=new Set(["EBUSY","ENOTEMPTY"])});function j0(Q,$={}){if($.json){console.log(JSON.stringify(Q,null,2));return}if($.quiet)return;if(_.info(L0.dim("\uD83D\uDD0D DRY RUN: No changes will be made")),_.break(),Q.wouldPerform.length===0)_.info("No actions would be performed.");else{let q=bZ(Q.wouldPerform);for(let[J,X]of Object.entries(q)){let H=RZ(J);_.info(`Would ${H} ${X.length} item(s):`);for(let G of X){let K=SZ(G.details);_.info(` \u2022 ${L0.component(G.target)}${K}`)}_.break()}}if(Q.summary)_.info(Q.summary),_.break();if(Q.validation.errors&&Q.validation.errors.length>0){_.error("Would fail with errors:");for(let q of Q.validation.errors)_.error(` \u2022 ${q}`);_.break()}if(Q.validation.warnings&&Q.validation.warnings.length>0){_.warn("Warnings:");for(let q of Q.validation.warnings)_.warn(` \u2022 ${q}`);_.break()}if($.hints&&$.hints.length>0){for(let q of $.hints)_.info(L0.dim(q));_.break()}_.info(L0.dim("Run without --dry-run to apply changes."))}function bZ(Q){let $={};for(let Y of Q){if(!$[Y.action])$[Y.action]=[];$[Y.action]?.push(Y)}return $}function RZ(Q){return{add:"add",remove:"remove",delete:"delete",update:"update",create:"create",modify:"modify"}[Q]??Q}function SZ(Q){if(!Q||Object.keys(Q).length===0)return"";let $=[];for(let[Y,q]of Object.entries(Q??{}))if(q!==void 0&&q!==null)$.push(`${Y}: ${L0.dim(String(q))}`);return $.length>0?` (${$.join(", ")})`:""}var e8=A(()=>{c1()});function F1(Q){console.log(JSON.stringify(Q,null,2))}function wX(Q){if(!Q)throw new L("npm package name cannot be empty");if(Q.length>jX)throw new L(`npm package name exceeds maximum length of ${jX} characters: \`${Q}\``);if(Q.includes("..")||Q.includes("/./")||Q.startsWith("./"))throw new L(`Invalid npm package name - path traversal detected: \`${Q}\``);if(!vZ.test(Q))throw new L(`Invalid npm package name: \`${Q}\`. Must be lowercase, start with alphanumeric, and contain only letters, numbers, hyphens, dots, or underscores.`)}function DX(Q){if(!Q?.trim())throw new L("npm specifier cannot be empty");let $=Q.trim();if(!$.startsWith("npm:"))throw new L(`Invalid npm specifier: \`${Q}\`. Must start with \`npm:\` prefix.`);let Y=$.slice(4);if(!Y)throw new L(`Invalid npm specifier: \`${Q}\`. Package name is required.`);let q=Y.lastIndexOf("@"),J,X;if(q>0){let H=Y.slice(0,q),G=Y.slice(q+1);if(H.includes("/")||!H.startsWith("@"))J=H,X=G||void 0;else throw new L(`Invalid npm specifier: \`${Q}\`. Scoped packages must have format @scope/pkg.`)}else J=Y;return wX(J),{type:"npm",name:J,version:X}}function OX(Q){return Q.trim().startsWith("npm:")}async function J6(Q,$){wX(Q);let Y=Q.startsWith("@")?`@${encodeURIComponent(Q.slice(1))}`:encodeURIComponent(Q),q=`${EZ}/${Y}`;try{let J=$??AbortSignal.timeout(kZ),X=await fetch(q,{signal:J,headers:{Accept:"application/json"}});if(X.status===404)throw new _1(`npm package \`${Q}\` not found on registry`);if(!X.ok)throw new I1(`Failed to fetch npm package \`${Q}\`: HTTP ${X.status} ${X.statusText}`);return await X.json()}catch(J){if(J instanceof _1||J instanceof I1)throw J;if(J instanceof Error&&(J.name==="AbortError"||J.name==="TimeoutError"))throw new I1(`Request to npm registry timed out for package \`${Q}\``);let X=J instanceof Error?J.message:String(J);throw new I1(`Failed to fetch npm package \`${Q}\`: ${X}`)}}function C9(Q,$){return $?`${Q}@${$}`:Q}function IX(Q){let $=[];if(Q.type!=="module")throw new L(`Package \`${Q.name}\` is not an ESM module (missing "type": "module" in package.json)`);let Y=Boolean(Q.main),q=Q.exports!==void 0;if(!Y&&!q)throw new L(`Package \`${Q.name}\` has no entry point (missing "main" or "exports")`);if(!Q.name.includes("opencode"))$.push(`Package name \`${Q.name}\` doesn't contain "opencode" - this may not be an OpenCode plugin`);return{valid:!0,warnings:$}}async function v3(Q,$,Y){let q=await J6(Q,Y),J=$??q["dist-tags"].latest,X=q.versions[J];if(!X)throw new _1(`Version \`${J}\` not found for npm package \`${Q}\``);return X}function NX(Q){let $=Q.trim(),Y=$.lastIndexOf("@");if(Y<=0)return $;let q=$.slice(0,Y);if(q.includes("/")||!q.startsWith("@"))return q;return $}var EZ="https://registry.npmjs.org",kZ=30000,vZ,jX=214;var X6=A(()=>{t();vZ=/^(?:@[a-z0-9][\w.-]*\/)?[a-z0-9][\w.-]*$/});function Q9(Q,$){let Y=Q.get($.absolutePath);if(!Y){Q.set($.absolutePath,$);return}let q=Y.content.equals($.content)?"identical content":"different content";throw new n1(`Intra-batch target collision at "${$.relativePath}". Both "${Y.source}" and "${$.source}" resolve to this path with ${q}. Rename one manifest target so each component writes to a unique path.`)}var P3=A(()=>{t()});import{createHash as PZ}from"crypto";import{existsSync as xZ}from"fs";import{join as CZ}from"path";function $9(Q){return PZ("sha256").update(Q).digest("hex")}async function x3(Q){let $=[...Q].sort((q,J)=>q.path.localeCompare(J.path)),Y=[];for(let q of $){let J=$9(q.content);Y.push(`${q.path}:${J}`)}return $9(Y.join(`
125
- `))}async function T2(Q,$){let Y=[],q=[],J=[];for(let X of $.files){let H=CZ(Q,X.path);if(!xZ(H)){q.push(X.path),J.push({path:X.path,status:"missing"});continue}let G=await Bun.file(H).text();if($9(G)!==X.hash)Y.push(X.path),J.push({path:X.path,status:"modified"});else J.push({path:X.path,status:"intact"})}return{intact:Y.length===0&&q.length===0,modified:Y,missing:q,details:J}}var y9=A(()=>{q0()});function Q0(Q){return Q.addOption(S0.cwd()).addOption(S0.quiet()).addOption(S0.json())}function E0(Q){return Q.addOption(S0.verbose())}function Q8(Q){return Q.addOption(S0.global)}function C3(Q){return Q.addOption(S0.profile())}function TX(Q){if(!Q||Q.length===0)throw new u0(Q,"cannot be empty");if(Q.length>32)throw new u0(Q,"must be 32 characters or less");if(!/^[a-zA-Z][a-zA-Z0-9._-]*$/.test(Q))throw new u0(Q,"must start with a letter and contain only alphanumeric characters, dots, underscores, or hyphens")}var S0;var d0=A(()=>{L3();t();S0={cwd:()=>new B8("--cwd <path>","Working directory").default(process.cwd()),quiet:()=>new B8("-q, --quiet","Suppress output"),json:()=>new B8("--json","Output as JSON"),profile:()=>new B8("-p, --profile <name>","Target a specific profile's config"),verbose:()=>new B8("-v, --verbose","Verbose output"),global:new B8("-g, --global","Install to global OpenCode config (~/.config/opencode)")}});function fZ(){let Q=new Map;for(let[$,Y]of Object.entries(k1)){for(let[q,J]of Object.entries(Y))k1[q]={open:`\x1B[${J[0]}m`,close:`\x1B[${J[1]}m`},Y[q]=k1[q],Q.set(J[0],J[1]);Object.defineProperty(k1,$,{value:Y,enumerable:!1})}return Object.defineProperty(k1,"codes",{value:Q,enumerable:!1}),k1.color.close="\x1B[39m",k1.bgColor.close="\x1B[49m",k1.color.ansi=bX(),k1.color.ansi256=RX(),k1.color.ansi16m=SX(),k1.bgColor.ansi=bX(10),k1.bgColor.ansi256=RX(10),k1.bgColor.ansi16m=SX(10),Object.defineProperties(k1,{rgbToAnsi256:{value($,Y,q){if($===Y&&Y===q){if($<8)return 16;if($>248)return 231;return Math.round(($-8)/247*24)+232}return 16+36*Math.round($/255*5)+6*Math.round(Y/255*5)+Math.round(q/255*5)},enumerable:!1},hexToRgb:{value($){let Y=/[a-f\d]{6}|[a-f\d]{3}/i.exec($.toString(16));if(!Y)return[0,0,0];let[q]=Y;if(q.length===3)q=[...q].map((X)=>X+X).join("");let J=Number.parseInt(q,16);return[J>>16&255,J>>8&255,J&255]},enumerable:!1},hexToAnsi256:{value:($)=>k1.rgbToAnsi256(...k1.hexToRgb($)),enumerable:!1},ansi256ToAnsi:{value($){if($<8)return 30+$;if($<16)return 90+($-8);let Y,q,J;if($>=232)Y=(($-232)*10+8)/255,q=Y,J=Y;else{$-=16;let G=$%36;Y=Math.floor($/36)/5,q=Math.floor(G/6)/5,J=G%6/5}let X=Math.max(Y,q,J)*2;if(X===0)return 30;let H=30+(Math.round(J)<<2|Math.round(q)<<1|Math.round(Y));if(X===2)H+=60;return H},enumerable:!1},rgbToAnsi:{value:($,Y,q)=>k1.ansi256ToAnsi(k1.rgbToAnsi256($,Y,q)),enumerable:!1},hexToAnsi:{value:($)=>k1.ansi256ToAnsi(k1.hexToAnsi256($)),enumerable:!1}}),k1}var bX=(Q=0)=>($)=>`\x1B[${$+Q}m`,RX=(Q=0)=>($)=>`\x1B[${38+Q};5;${$}m`,SX=(Q=0)=>($,Y,q)=>`\x1B[${38+Q};2;${$};${Y};${q}m`,k1,pI,yZ,hZ,lI,uZ,p0;var EX=A(()=>{k1={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},pI=Object.keys(k1.modifier),yZ=Object.keys(k1.color),hZ=Object.keys(k1.bgColor),lI=[...yZ,...hZ];uZ=fZ(),p0=uZ});import H6 from"process";import mZ from"os";import kX from"tty";function k0(Q,$=globalThis.Deno?globalThis.Deno.args:H6.argv){let Y=Q.startsWith("-")?"":Q.length===1?"-":"--",q=$.indexOf(Y+Q),J=$.indexOf("--");return q!==-1&&(J===-1||q<J)}function gZ(){if("FORCE_COLOR"in v1){if(v1.FORCE_COLOR==="true")return 1;if(v1.FORCE_COLOR==="false")return 0;return v1.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(v1.FORCE_COLOR,10),3)}}function cZ(Q){if(Q===0)return!1;return{level:Q,hasBasic:!0,has256:Q>=2,has16m:Q>=3}}function dZ(Q,{streamIsTTY:$,sniffFlags:Y=!0}={}){let q=gZ();if(q!==void 0)y3=q;let J=Y?y3:q;if(J===0)return 0;if(Y){if(k0("color=16m")||k0("color=full")||k0("color=truecolor"))return 3;if(k0("color=256"))return 2}if("TF_BUILD"in v1&&"AGENT_NAME"in v1)return 1;if(Q&&!$&&J===void 0)return 0;let X=J||0;if(v1.TERM==="dumb")return X;if(H6.platform==="win32"){let H=mZ.release().split(".");if(Number(H[0])>=10&&Number(H[2])>=10586)return Number(H[2])>=14931?3:2;return 1}if("CI"in v1){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((H)=>(H in v1)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((H)=>(H in v1))||v1.CI_NAME==="codeship")return 1;return X}if("TEAMCITY_VERSION"in v1)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(v1.TEAMCITY_VERSION)?1:0;if(v1.COLORTERM==="truecolor")return 3;if(v1.TERM==="xterm-kitty")return 3;if(v1.TERM==="xterm-ghostty")return 3;if(v1.TERM==="wezterm")return 3;if("TERM_PROGRAM"in v1){let H=Number.parseInt((v1.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(v1.TERM_PROGRAM){case"iTerm.app":return H>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(v1.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(v1.TERM))return 1;if("COLORTERM"in v1)return 1;return X}function vX(Q,$={}){let Y=dZ(Q,{streamIsTTY:Q&&Q.isTTY,...$});return cZ(Y)}var v1,y3,pZ,PX;var xX=A(()=>{({env:v1}=H6);if(k0("no-color")||k0("no-colors")||k0("color=false")||k0("color=never"))y3=0;else if(k0("color")||k0("colors")||k0("color=true")||k0("color=always"))y3=1;pZ={stdout:vX({isTTY:kX.isatty(1)}),stderr:vX({isTTY:kX.isatty(2)})},PX=pZ});function CX(Q,$,Y){let q=Q.indexOf($);if(q===-1)return Q;let J=$.length,X=0,H="";do H+=Q.slice(X,q)+$+Y,X=q+J,q=Q.indexOf($,X);while(q!==-1);return H+=Q.slice(X),H}function yX(Q,$,Y,q){let J=0,X="";do{let H=Q[q-1]==="\r";X+=Q.slice(J,H?q-1:q)+$+(H?`\r
124
+ `).trim()}function Y6(Q,$){return _X(Q)===_X($)}import{existsSync as jZ,lstatSync as wZ}from"fs";import{rm as DZ,unlink as OZ}from"fs/promises";import{join as UX}from"path";function VX(Q,$){let Y=[];for(let[q,J]of Object.entries($)){let X=Q[q]??null;if(X!==J)Y.push({name:q,from:X,to:J})}return{changed:Y.length>0,entries:Y}}function AX(Q,$){let Y=UX(Q,"node_modules"),q=$.map((J)=>J.name).join(", ");return{action:"delete",target:Y,details:{reason:`dependency declarations changed (${q}); invalidating to force reinstall`,path:Y}}}function MX(Q){if(Q&&typeof Q==="object"&&"code"in Q)return String(Q.code);return"UNKNOWN"}function q6(Q){if(Q instanceof Error)return Q.message;return String(Q)}function TZ(Q){return new Promise(($)=>setTimeout($,Q))}async function LX(Q,$){let Y=UX(Q,"node_modules"),q=$?.rmImpl??((J,X)=>DZ(J,X));if(!jZ(Y))return{success:!0,action:"none"};try{if(wZ(Y).isSymbolicLink())return await OZ(Y),{success:!0,action:"unlinked"}}catch(J){let X=MX(J);if(X==="ENOENT")return{success:!0,action:"none"};return{success:!1,action:"failed",error:{code:X,message:q6(J)}}}for(let J=0;J<=ZX;J++)try{return await q(Y,{recursive:!0,force:!0}),{success:!0,action:"removed"}}catch(X){let H=MX(X);if(H==="ENOENT")return{success:!0,action:"none"};if(!IZ.has(H))return{success:!1,action:"failed",error:{code:H,message:q6(X)}};if(J<ZX)await TZ(NZ*2**J);else return{success:!1,action:"failed",error:{code:H,message:q6(X)}}}return{success:!1,action:"failed",error:{code:"UNKNOWN",message:"exhausted retries"}}}var IZ,ZX=3,NZ=100;var FX=A(()=>{IZ=new Set(["EBUSY","ENOTEMPTY"])});function w0(Q,$={}){if($.json){console.log(JSON.stringify(Q,null,2));return}if($.quiet)return;if(_.info(F0.dim("\uD83D\uDD0D DRY RUN: No changes will be made")),_.break(),Q.wouldPerform.length===0)_.info("No actions would be performed.");else{let q=bZ(Q.wouldPerform);for(let[J,X]of Object.entries(q)){let H=RZ(J);_.info(`Would ${H} ${X.length} item(s):`);for(let G of X){let K=SZ(G.details);_.info(` \u2022 ${F0.component(G.target)}${K}`)}_.break()}}if(Q.summary)_.info(Q.summary),_.break();if(Q.validation.errors&&Q.validation.errors.length>0){_.error("Would fail with errors:");for(let q of Q.validation.errors)_.error(` \u2022 ${q}`);_.break()}if(Q.validation.warnings&&Q.validation.warnings.length>0){_.warn("Warnings:");for(let q of Q.validation.warnings)_.warn(` \u2022 ${q}`);_.break()}if($.hints&&$.hints.length>0){for(let q of $.hints)_.info(F0.dim(q));_.break()}_.info(F0.dim("Run without --dry-run to apply changes."))}function bZ(Q){let $={};for(let Y of Q){if(!$[Y.action])$[Y.action]=[];$[Y.action]?.push(Y)}return $}function RZ(Q){return{add:"add",remove:"remove",delete:"delete",update:"update",create:"create",modify:"modify"}[Q]??Q}function SZ(Q){if(!Q||Object.keys(Q).length===0)return"";let $=[];for(let[Y,q]of Object.entries(Q??{}))if(q!==void 0&&q!==null)$.push(`${Y}: ${F0.dim(String(q))}`);return $.length>0?` (${$.join(", ")})`:""}var e8=A(()=>{c1()});function F1(Q){console.log(JSON.stringify(Q,null,2))}function wX(Q){if(!Q)throw new L("npm package name cannot be empty");if(Q.length>jX)throw new L(`npm package name exceeds maximum length of ${jX} characters: \`${Q}\``);if(Q.includes("..")||Q.includes("/./")||Q.startsWith("./"))throw new L(`Invalid npm package name - path traversal detected: \`${Q}\``);if(!vZ.test(Q))throw new L(`Invalid npm package name: \`${Q}\`. Must be lowercase, start with alphanumeric, and contain only letters, numbers, hyphens, dots, or underscores.`)}function DX(Q){if(!Q?.trim())throw new L("npm specifier cannot be empty");let $=Q.trim();if(!$.startsWith("npm:"))throw new L(`Invalid npm specifier: \`${Q}\`. Must start with \`npm:\` prefix.`);let Y=$.slice(4);if(!Y)throw new L(`Invalid npm specifier: \`${Q}\`. Package name is required.`);let q=Y.lastIndexOf("@"),J,X;if(q>0){let H=Y.slice(0,q),G=Y.slice(q+1);if(H.includes("/")||!H.startsWith("@"))J=H,X=G||void 0;else throw new L(`Invalid npm specifier: \`${Q}\`. Scoped packages must have format @scope/pkg.`)}else J=Y;return wX(J),{type:"npm",name:J,version:X}}function OX(Q){return Q.trim().startsWith("npm:")}async function J6(Q,$){wX(Q);let Y=Q.startsWith("@")?`@${encodeURIComponent(Q.slice(1))}`:encodeURIComponent(Q),q=`${EZ}/${Y}`;try{let J=$??AbortSignal.timeout(kZ),X=await fetch(q,{signal:J,headers:{Accept:"application/json"}});if(X.status===404)throw new _1(`npm package \`${Q}\` not found on registry`);if(!X.ok)throw new I1(`Failed to fetch npm package \`${Q}\`: HTTP ${X.status} ${X.statusText}`);return await X.json()}catch(J){if(J instanceof _1||J instanceof I1)throw J;if(J instanceof Error&&(J.name==="AbortError"||J.name==="TimeoutError"))throw new I1(`Request to npm registry timed out for package \`${Q}\``);let X=J instanceof Error?J.message:String(J);throw new I1(`Failed to fetch npm package \`${Q}\`: ${X}`)}}function C9(Q,$){return $?`${Q}@${$}`:Q}function IX(Q){let $=[];if(Q.type!=="module")throw new L(`Package \`${Q.name}\` is not an ESM module (missing "type": "module" in package.json)`);let Y=Boolean(Q.main),q=Q.exports!==void 0;if(!Y&&!q)throw new L(`Package \`${Q.name}\` has no entry point (missing "main" or "exports")`);if(!Q.name.includes("opencode"))$.push(`Package name \`${Q.name}\` doesn't contain "opencode" - this may not be an OpenCode plugin`);return{valid:!0,warnings:$}}async function v3(Q,$,Y){let q=await J6(Q,Y),J=$??q["dist-tags"].latest,X=q.versions[J];if(!X)throw new _1(`Version \`${J}\` not found for npm package \`${Q}\``);return X}function NX(Q){let $=Q.trim(),Y=$.lastIndexOf("@");if(Y<=0)return $;let q=$.slice(0,Y);if(q.includes("/")||!q.startsWith("@"))return q;return $}var EZ="https://registry.npmjs.org",kZ=30000,vZ,jX=214;var X6=A(()=>{t();vZ=/^(?:@[a-z0-9][\w.-]*\/)?[a-z0-9][\w.-]*$/});function Q9(Q,$){let Y=Q.get($.absolutePath);if(!Y){Q.set($.absolutePath,$);return}let q=Y.content.equals($.content)?"identical content":"different content";throw new n1(`Intra-batch target collision at "${$.relativePath}". Both "${Y.source}" and "${$.source}" resolve to this path with ${q}. Rename one manifest target so each component writes to a unique path.`)}var P3=A(()=>{t()});import{createHash as PZ}from"crypto";import{existsSync as xZ}from"fs";import{join as CZ}from"path";function $9(Q){return PZ("sha256").update(Q).digest("hex")}async function x3(Q){let $=[...Q].sort((q,J)=>q.path.localeCompare(J.path)),Y=[];for(let q of $){let J=$9(q.content);Y.push(`${q.path}:${J}`)}return $9(Y.join(`
125
+ `))}async function T2(Q,$){let Y=[],q=[],J=[];for(let X of $.files){let H=CZ(Q,X.path);if(!xZ(H)){q.push(X.path),J.push({path:X.path,status:"missing"});continue}let G=await Bun.file(H).text();if($9(G)!==X.hash)Y.push(X.path),J.push({path:X.path,status:"modified"});else J.push({path:X.path,status:"intact"})}return{intact:Y.length===0&&q.length===0,modified:Y,missing:q,details:J}}var y9=A(()=>{q0()});function Q0(Q){return Q.addOption(E0.cwd()).addOption(E0.quiet()).addOption(E0.json())}function B0(Q){return Q.addOption(E0.verbose())}function Q8(Q){return Q.addOption(E0.global)}function C3(Q){return Q.addOption(E0.profile())}function TX(Q){if(!Q||Q.length===0)throw new m0(Q,"cannot be empty");if(Q.length>32)throw new m0(Q,"must be 32 characters or less");if(!/^[a-zA-Z][a-zA-Z0-9._-]*$/.test(Q))throw new m0(Q,"must start with a letter and contain only alphanumeric characters, dots, underscores, or hyphens")}var E0;var k0=A(()=>{L3();t();E0={cwd:()=>new B8("--cwd <path>","Working directory").default(process.cwd()),quiet:()=>new B8("-q, --quiet","Suppress output"),json:()=>new B8("--json","Output as JSON"),profile:()=>new B8("-p, --profile <name>","Target a specific profile's config"),verbose:()=>new B8("-v, --verbose","Verbose output"),global:new B8("-g, --global","Install to global OpenCode config (~/.config/opencode)")}});function fZ(){let Q=new Map;for(let[$,Y]of Object.entries(k1)){for(let[q,J]of Object.entries(Y))k1[q]={open:`\x1B[${J[0]}m`,close:`\x1B[${J[1]}m`},Y[q]=k1[q],Q.set(J[0],J[1]);Object.defineProperty(k1,$,{value:Y,enumerable:!1})}return Object.defineProperty(k1,"codes",{value:Q,enumerable:!1}),k1.color.close="\x1B[39m",k1.bgColor.close="\x1B[49m",k1.color.ansi=bX(),k1.color.ansi256=RX(),k1.color.ansi16m=SX(),k1.bgColor.ansi=bX(10),k1.bgColor.ansi256=RX(10),k1.bgColor.ansi16m=SX(10),Object.defineProperties(k1,{rgbToAnsi256:{value($,Y,q){if($===Y&&Y===q){if($<8)return 16;if($>248)return 231;return Math.round(($-8)/247*24)+232}return 16+36*Math.round($/255*5)+6*Math.round(Y/255*5)+Math.round(q/255*5)},enumerable:!1},hexToRgb:{value($){let Y=/[a-f\d]{6}|[a-f\d]{3}/i.exec($.toString(16));if(!Y)return[0,0,0];let[q]=Y;if(q.length===3)q=[...q].map((X)=>X+X).join("");let J=Number.parseInt(q,16);return[J>>16&255,J>>8&255,J&255]},enumerable:!1},hexToAnsi256:{value:($)=>k1.rgbToAnsi256(...k1.hexToRgb($)),enumerable:!1},ansi256ToAnsi:{value($){if($<8)return 30+$;if($<16)return 90+($-8);let Y,q,J;if($>=232)Y=(($-232)*10+8)/255,q=Y,J=Y;else{$-=16;let G=$%36;Y=Math.floor($/36)/5,q=Math.floor(G/6)/5,J=G%6/5}let X=Math.max(Y,q,J)*2;if(X===0)return 30;let H=30+(Math.round(J)<<2|Math.round(q)<<1|Math.round(Y));if(X===2)H+=60;return H},enumerable:!1},rgbToAnsi:{value:($,Y,q)=>k1.ansi256ToAnsi(k1.rgbToAnsi256($,Y,q)),enumerable:!1},hexToAnsi:{value:($)=>k1.ansi256ToAnsi(k1.hexToAnsi256($)),enumerable:!1}}),k1}var bX=(Q=0)=>($)=>`\x1B[${$+Q}m`,RX=(Q=0)=>($)=>`\x1B[${38+Q};5;${$}m`,SX=(Q=0)=>($,Y,q)=>`\x1B[${38+Q};2;${$};${Y};${q}m`,k1,nI,yZ,hZ,oI,uZ,p0;var EX=A(()=>{k1={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},nI=Object.keys(k1.modifier),yZ=Object.keys(k1.color),hZ=Object.keys(k1.bgColor),oI=[...yZ,...hZ];uZ=fZ(),p0=uZ});import H6 from"process";import mZ from"os";import kX from"tty";function v0(Q,$=globalThis.Deno?globalThis.Deno.args:H6.argv){let Y=Q.startsWith("-")?"":Q.length===1?"-":"--",q=$.indexOf(Y+Q),J=$.indexOf("--");return q!==-1&&(J===-1||q<J)}function gZ(){if("FORCE_COLOR"in v1){if(v1.FORCE_COLOR==="true")return 1;if(v1.FORCE_COLOR==="false")return 0;return v1.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(v1.FORCE_COLOR,10),3)}}function cZ(Q){if(Q===0)return!1;return{level:Q,hasBasic:!0,has256:Q>=2,has16m:Q>=3}}function dZ(Q,{streamIsTTY:$,sniffFlags:Y=!0}={}){let q=gZ();if(q!==void 0)y3=q;let J=Y?y3:q;if(J===0)return 0;if(Y){if(v0("color=16m")||v0("color=full")||v0("color=truecolor"))return 3;if(v0("color=256"))return 2}if("TF_BUILD"in v1&&"AGENT_NAME"in v1)return 1;if(Q&&!$&&J===void 0)return 0;let X=J||0;if(v1.TERM==="dumb")return X;if(H6.platform==="win32"){let H=mZ.release().split(".");if(Number(H[0])>=10&&Number(H[2])>=10586)return Number(H[2])>=14931?3:2;return 1}if("CI"in v1){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((H)=>(H in v1)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((H)=>(H in v1))||v1.CI_NAME==="codeship")return 1;return X}if("TEAMCITY_VERSION"in v1)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(v1.TEAMCITY_VERSION)?1:0;if(v1.COLORTERM==="truecolor")return 3;if(v1.TERM==="xterm-kitty")return 3;if(v1.TERM==="xterm-ghostty")return 3;if(v1.TERM==="wezterm")return 3;if("TERM_PROGRAM"in v1){let H=Number.parseInt((v1.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(v1.TERM_PROGRAM){case"iTerm.app":return H>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(v1.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(v1.TERM))return 1;if("COLORTERM"in v1)return 1;return X}function vX(Q,$={}){let Y=dZ(Q,{streamIsTTY:Q&&Q.isTTY,...$});return cZ(Y)}var v1,y3,pZ,PX;var xX=A(()=>{({env:v1}=H6);if(v0("no-color")||v0("no-colors")||v0("color=false")||v0("color=never"))y3=0;else if(v0("color")||v0("colors")||v0("color=true")||v0("color=always"))y3=1;pZ={stdout:vX({isTTY:kX.isatty(1)}),stderr:vX({isTTY:kX.isatty(2)})},PX=pZ});function CX(Q,$,Y){let q=Q.indexOf($);if(q===-1)return Q;let J=$.length,X=0,H="";do H+=Q.slice(X,q)+$+Y,X=q+J,q=Q.indexOf($,X);while(q!==-1);return H+=Q.slice(X),H}function yX(Q,$,Y,q){let J=0,X="";do{let H=Q[q-1]==="\r";X+=Q.slice(J,H?q-1:q)+$+(H?`\r
126
126
  `:`
127
127
  `)+Y,J=q+1,q=Q.indexOf(`
128
128
  `,J)}while(q!==-1);return X+=Q.slice(J),X}function R2(Q){return iZ(Q)}var hX,fX,G6,h9,b2,uX,f9,lZ=(Q,$={})=>{if($.level&&!(Number.isInteger($.level)&&$.level>=0&&$.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let Y=hX?hX.level:0;Q.level=$.level===void 0?Y:$.level},iZ=(Q)=>{let $=(...Y)=>Y.join(" ");return lZ($,Q),Object.setPrototypeOf($,R2.prototype),$},K6=(Q,$,Y,...q)=>{if(Q==="rgb"){if($==="ansi16m")return p0[Y].ansi16m(...q);if($==="ansi256")return p0[Y].ansi256(p0.rgbToAnsi256(...q));return p0[Y].ansi(p0.rgbToAnsi(...q))}if(Q==="hex")return K6("rgb",$,Y,...p0.hexToRgb(...q));return p0[Y][Q](...q)},nZ,oZ,W6=(Q,$,Y)=>{let q,J;if(Y===void 0)q=Q,J=$;else q=Y.openAll+Q,J=$+Y.closeAll;return{open:Q,close:$,openAll:q,closeAll:J,parent:Y}},h3=(Q,$,Y)=>{let q=(...J)=>sZ(q,J.length===1?""+J[0]:J.join(" "));return Object.setPrototypeOf(q,oZ),q[G6]=Q,q[h9]=$,q[b2]=Y,q},sZ=(Q,$)=>{if(Q.level<=0||!$)return Q[b2]?"":$;let Y=Q[h9];if(Y===void 0)return $;let{openAll:q,closeAll:J}=Y;if($.includes("\x1B"))while(Y!==void 0)$=CX($,Y.close,Y.open),Y=Y.parent;let X=$.indexOf(`
129
- `);if(X!==-1)$=yX($,J,q,X);return q+$+J},rZ,$N,mX;var gX=A(()=>{EX();xX();({stdout:hX,stderr:fX}=PX),G6=Symbol("GENERATOR"),h9=Symbol("STYLER"),b2=Symbol("IS_EMPTY"),uX=["ansi","ansi","ansi256","ansi16m"],f9=Object.create(null);Object.setPrototypeOf(R2.prototype,Function.prototype);for(let[Q,$]of Object.entries(p0))f9[Q]={get(){let Y=h3(this,W6($.open,$.close,this[h9]),this[b2]);return Object.defineProperty(this,Q,{value:Y}),Y}};f9.visible={get(){let Q=h3(this,this[h9],!0);return Object.defineProperty(this,"visible",{value:Q}),Q}};nZ=["rgb","hex","ansi256"];for(let Q of nZ){f9[Q]={get(){let{level:Y}=this;return function(...q){let J=W6(K6(Q,uX[Y],"color",...q),p0.color.close,this[h9]);return h3(this,J,this[b2])}}};let $="bg"+Q[0].toUpperCase()+Q.slice(1);f9[$]={get(){let{level:Y}=this;return function(...q){let J=W6(K6(Q,uX[Y],"bgColor",...q),p0.bgColor.close,this[h9]);return h3(this,J,this[b2])}}}}oZ=Object.defineProperties(()=>{},{...f9,level:{enumerable:!0,get(){return this[G6].level},set(Q){this[G6].level=Q}}});Object.defineProperties(R2.prototype,f9);rZ=R2(),$N=R2({level:fX?fX.level:0}),mX=rZ});function z6(Q,$,{ignoreNonConfigurable:Y=!1}={}){let{name:q}=Q;for(let J of Reflect.ownKeys($))aZ(Q,$,J,Y);return eZ(Q,$),qM(Q,$,q),Q}var aZ=(Q,$,Y,q)=>{if(Y==="length"||Y==="prototype")return;if(Y==="arguments"||Y==="caller")return;let J=Object.getOwnPropertyDescriptor(Q,Y),X=Object.getOwnPropertyDescriptor($,Y);if(!tZ(J,X)&&q)return;Object.defineProperty(Q,Y,X)},tZ=function(Q,$){return Q===void 0||Q.configurable||Q.writable===$.writable&&Q.enumerable===$.enumerable&&Q.configurable===$.configurable&&(Q.writable||Q.value===$.value)},eZ=(Q,$)=>{let Y=Object.getPrototypeOf($);if(Y===Object.getPrototypeOf(Q))return;Object.setPrototypeOf(Q,Y)},QM=(Q,$)=>`/* Wrapped ${Q}*/
130
- ${$}`,$M,YM,qM=(Q,$,Y)=>{let q=Y===""?"":`with ${Y.trim()}() `,J=QM.bind(null,q,$.toString());Object.defineProperty(J,"name",YM);let{writable:X,enumerable:H,configurable:G}=$M;Object.defineProperty(Q,"toString",{value:J,writable:X,enumerable:H,configurable:G})};var cX=A(()=>{$M=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),YM=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name")});var f3,dX=(Q,$={})=>{if(typeof Q!=="function")throw TypeError("Expected a function");let Y,q=0,J=Q.displayName||Q.name||"<anonymous>",X=function(...H){if(f3.set(X,++q),q===1)Y=Q.apply(this,H),Q=void 0;else if($.throw===!0)throw Error(`Function \`${J}\` can only be called once`);return Y};return z6(X,Q),f3.set(X,q),X},pX;var lX=A(()=>{cX();f3=new WeakMap;dX.callCount=(Q)=>{if(!f3.has(Q))throw Error(`The given function \`${Q.name}\` is not wrapped by the \`onetime\` package`);return f3.get(Q)};pX=dX});var Y9;var iX=A(()=>{Y9=[];Y9.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")Y9.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")Y9.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")});class nX{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(_6[B6])return _6[B6];JM(_6,B6,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(Q,$){this.listeners[Q].push($)}removeListener(Q,$){let Y=this.listeners[Q],q=Y.indexOf($);if(q===-1)return;if(q===0&&Y.length===1)Y.length=0;else Y.splice(q,1)}emit(Q,$,Y){if(this.emitted[Q])return!1;this.emitted[Q]=!0;let q=!1;for(let J of this.listeners[Q])q=J($,Y)===!0||q;if(Q==="exit")q=this.emit("afterExit",$,Y)||q;return q}}class M6{}var u3=(Q)=>!!Q&&typeof Q==="object"&&typeof Q.removeListener==="function"&&typeof Q.emit==="function"&&typeof Q.reallyExit==="function"&&typeof Q.listeners==="function"&&typeof Q.kill==="function"&&typeof Q.pid==="number"&&typeof Q.on==="function",B6,_6,JM,XM=(Q)=>{return{onExit($,Y){return Q.onExit($,Y)},load(){return Q.load()},unload(){return Q.unload()}}},oX,sX,Z6,rX,KN,WN;var aX=A(()=>{iX();B6=Symbol.for("signal-exit emitter"),_6=globalThis,JM=Object.defineProperty.bind(Object);oX=class oX extends M6{onExit(){return()=>{}}load(){}unload(){}};sX=class sX extends M6{#X=Z6.platform==="win32"?"SIGINT":"SIGHUP";#q=new nX;#Y;#Q;#J;#$={};#H=!1;constructor(Q){super();this.#Y=Q,this.#$={};for(let $ of Y9)this.#$[$]=()=>{let Y=this.#Y.listeners($),{count:q}=this.#q,J=Q;if(typeof J.__signal_exit_emitter__==="object"&&typeof J.__signal_exit_emitter__.count==="number")q+=J.__signal_exit_emitter__.count;if(Y.length===q){this.unload();let X=this.#q.emit("exit",null,$),H=$==="SIGHUP"?this.#X:$;if(!X)Q.kill(Q.pid,H)}};this.#J=Q.reallyExit,this.#Q=Q.emit}onExit(Q,$){if(!u3(this.#Y))return()=>{};if(this.#H===!1)this.load();let Y=$?.alwaysLast?"afterExit":"exit";return this.#q.on(Y,Q),()=>{if(this.#q.removeListener(Y,Q),this.#q.listeners.exit.length===0&&this.#q.listeners.afterExit.length===0)this.unload()}}load(){if(this.#H)return;this.#H=!0,this.#q.count+=1;for(let Q of Y9)try{let $=this.#$[Q];if($)this.#Y.on(Q,$)}catch($){}this.#Y.emit=(Q,...$)=>{return this.#B(Q,...$)},this.#Y.reallyExit=(Q)=>{return this.#K(Q)}}unload(){if(!this.#H)return;this.#H=!1,Y9.forEach((Q)=>{let $=this.#$[Q];if(!$)throw Error("Listener not defined for signal: "+Q);try{this.#Y.removeListener(Q,$)}catch(Y){}}),this.#Y.emit=this.#Q,this.#Y.reallyExit=this.#J,this.#q.count-=1}#K(Q){if(!u3(this.#Y))return 0;return this.#Y.exitCode=Q||0,this.#q.emit("exit",this.#Y.exitCode,null),this.#J.call(this.#Y,this.#Y.exitCode)}#B(Q,...$){let Y=this.#Q;if(Q==="exit"&&u3(this.#Y)){if(typeof $[0]==="number")this.#Y.exitCode=$[0];let q=Y.call(this.#Y,Q,...$);return this.#q.emit("exit",this.#Y.exitCode,null),q}else return Y.call(this.#Y,Q,...$)}};Z6=globalThis.process,{onExit:rX,load:KN,unload:WN}=XM(u3(Z6)?new sX(Z6):new oX)});import m3 from"process";var tX,HM,eX;var QH=A(()=>{lX();aX();tX=m3.stderr.isTTY?m3.stderr:m3.stdout.isTTY?m3.stdout:void 0,HM=tX?pX(()=>{rX(()=>{tX.write("\x1B[?25h")},{alwaysLast:!0})}):()=>{},eX=HM});import $H from"process";var g3=!1,u9,U6;var YH=A(()=>{QH();u9={};u9.show=(Q=$H.stderr)=>{if(!Q.isTTY)return;g3=!1,Q.write("\x1B[?25h")};u9.hide=(Q=$H.stderr)=>{if(!Q.isTTY)return;eX(),g3=!0,Q.write("\x1B[?25l")};u9.toggle=(Q,$)=>{if(Q!==void 0)g3=Q;if(g3)u9.show($);else u9.hide($)};U6=u9});var V6;var qH=A(()=>{V6={dots:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]},dots2:{interval:80,frames:["\u28FE","\u28FD","\u28FB","\u28BF","\u287F","\u28DF","\u28EF","\u28F7"]},dots3:{interval:80,frames:["\u280B","\u2819","\u281A","\u281E","\u2816","\u2826","\u2834","\u2832","\u2833","\u2813"]},dots4:{interval:80,frames:["\u2804","\u2806","\u2807","\u280B","\u2819","\u2838","\u2830","\u2820","\u2830","\u2838","\u2819","\u280B","\u2807","\u2806"]},dots5:{interval:80,frames:["\u280B","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B"]},dots6:{interval:80,frames:["\u2801","\u2809","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2824","\u2804","\u2804","\u2824","\u2834","\u2832","\u2812","\u2802","\u2802","\u2812","\u281A","\u2819","\u2809","\u2801"]},dots7:{interval:80,frames:["\u2808","\u2809","\u280B","\u2813","\u2812","\u2810","\u2810","\u2812","\u2816","\u2826","\u2824","\u2820","\u2820","\u2824","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B","\u2809","\u2808"]},dots8:{interval:80,frames:["\u2801","\u2801","\u2809","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2824","\u2804","\u2804","\u2824","\u2820","\u2820","\u2824","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B","\u2809","\u2808","\u2808"]},dots9:{interval:80,frames:["\u28B9","\u28BA","\u28BC","\u28F8","\u28C7","\u2867","\u2857","\u284F"]},dots10:{interval:80,frames:["\u2884","\u2882","\u2881","\u2841","\u2848","\u2850","\u2860"]},dots11:{interval:100,frames:["\u2801","\u2802","\u2804","\u2840","\u2880","\u2820","\u2810","\u2808"]},dots12:{interval:80,frames:["\u2880\u2800","\u2840\u2800","\u2804\u2800","\u2882\u2800","\u2842\u2800","\u2805\u2800","\u2883\u2800","\u2843\u2800","\u280D\u2800","\u288B\u2800","\u284B\u2800","\u280D\u2801","\u288B\u2801","\u284B\u2801","\u280D\u2809","\u280B\u2809","\u280B\u2809","\u2809\u2819","\u2809\u2819","\u2809\u2829","\u2808\u2899","\u2808\u2859","\u2888\u2829","\u2840\u2899","\u2804\u2859","\u2882\u2829","\u2842\u2898","\u2805\u2858","\u2883\u2828","\u2843\u2890","\u280D\u2850","\u288B\u2820","\u284B\u2880","\u280D\u2841","\u288B\u2801","\u284B\u2801","\u280D\u2809","\u280B\u2809","\u280B\u2809","\u2809\u2819","\u2809\u2819","\u2809\u2829","\u2808\u2899","\u2808\u2859","\u2808\u2829","\u2800\u2899","\u2800\u2859","\u2800\u2829","\u2800\u2898","\u2800\u2858","\u2800\u2828","\u2800\u2890","\u2800\u2850","\u2800\u2820","\u2800\u2880","\u2800\u2840"]},dots13:{interval:80,frames:["\u28FC","\u28F9","\u28BB","\u283F","\u285F","\u28CF","\u28E7","\u28F6"]},dots14:{interval:80,frames:["\u2809\u2809","\u2808\u2819","\u2800\u2839","\u2800\u28B8","\u2800\u28F0","\u2880\u28E0","\u28C0\u28C0","\u28C4\u2840","\u28C6\u2800","\u2847\u2800","\u280F\u2800","\u280B\u2801"]},dots8Bit:{interval:80,frames:["\u2800","\u2801","\u2802","\u2803","\u2804","\u2805","\u2806","\u2807","\u2840","\u2841","\u2842","\u2843","\u2844","\u2845","\u2846","\u2847","\u2808","\u2809","\u280A","\u280B","\u280C","\u280D","\u280E","\u280F","\u2848","\u2849","\u284A","\u284B","\u284C","\u284D","\u284E","\u284F","\u2810","\u2811","\u2812","\u2813","\u2814","\u2815","\u2816","\u2817","\u2850","\u2851","\u2852","\u2853","\u2854","\u2855","\u2856","\u2857","\u2818","\u2819","\u281A","\u281B","\u281C","\u281D","\u281E","\u281F","\u2858","\u2859","\u285A","\u285B","\u285C","\u285D","\u285E","\u285F","\u2820","\u2821","\u2822","\u2823","\u2824","\u2825","\u2826","\u2827","\u2860","\u2861","\u2862","\u2863","\u2864","\u2865","\u2866","\u2867","\u2828","\u2829","\u282A","\u282B","\u282C","\u282D","\u282E","\u282F","\u2868","\u2869","\u286A","\u286B","\u286C","\u286D","\u286E","\u286F","\u2830","\u2831","\u2832","\u2833","\u2834","\u2835","\u2836","\u2837","\u2870","\u2871","\u2872","\u2873","\u2874","\u2875","\u2876","\u2877","\u2838","\u2839","\u283A","\u283B","\u283C","\u283D","\u283E","\u283F","\u2878","\u2879","\u287A","\u287B","\u287C","\u287D","\u287E","\u287F","\u2880","\u2881","\u2882","\u2883","\u2884","\u2885","\u2886","\u2887","\u28C0","\u28C1","\u28C2","\u28C3","\u28C4","\u28C5","\u28C6","\u28C7","\u2888","\u2889","\u288A","\u288B","\u288C","\u288D","\u288E","\u288F","\u28C8","\u28C9","\u28CA","\u28CB","\u28CC","\u28CD","\u28CE","\u28CF","\u2890","\u2891","\u2892","\u2893","\u2894","\u2895","\u2896","\u2897","\u28D0","\u28D1","\u28D2","\u28D3","\u28D4","\u28D5","\u28D6","\u28D7","\u2898","\u2899","\u289A","\u289B","\u289C","\u289D","\u289E","\u289F","\u28D8","\u28D9","\u28DA","\u28DB","\u28DC","\u28DD","\u28DE","\u28DF","\u28A0","\u28A1","\u28A2","\u28A3","\u28A4","\u28A5","\u28A6","\u28A7","\u28E0","\u28E1","\u28E2","\u28E3","\u28E4","\u28E5","\u28E6","\u28E7","\u28A8","\u28A9","\u28AA","\u28AB","\u28AC","\u28AD","\u28AE","\u28AF","\u28E8","\u28E9","\u28EA","\u28EB","\u28EC","\u28ED","\u28EE","\u28EF","\u28B0","\u28B1","\u28B2","\u28B3","\u28B4","\u28B5","\u28B6","\u28B7","\u28F0","\u28F1","\u28F2","\u28F3","\u28F4","\u28F5","\u28F6","\u28F7","\u28B8","\u28B9","\u28BA","\u28BB","\u28BC","\u28BD","\u28BE","\u28BF","\u28F8","\u28F9","\u28FA","\u28FB","\u28FC","\u28FD","\u28FE","\u28FF"]},dotsCircle:{interval:80,frames:["\u288E ","\u280E\u2801","\u280A\u2811","\u2808\u2831"," \u2871","\u2880\u2870","\u2884\u2860","\u2886\u2840"]},sand:{interval:80,frames:["\u2801","\u2802","\u2804","\u2840","\u2848","\u2850","\u2860","\u28C0","\u28C1","\u28C2","\u28C4","\u28CC","\u28D4","\u28E4","\u28E5","\u28E6","\u28EE","\u28F6","\u28F7","\u28FF","\u287F","\u283F","\u289F","\u281F","\u285B","\u281B","\u282B","\u288B","\u280B","\u280D","\u2849","\u2809","\u2811","\u2821","\u2881"]},line:{interval:130,frames:["-","\\","|","/"]},line2:{interval:100,frames:["\u2802","-","\u2013","\u2014","\u2013","-"]},rollingLine:{interval:80,frames:["/ "," - "," \\ "," |"," |"," \\ "," - ","/ "]},pipe:{interval:100,frames:["\u2524","\u2518","\u2534","\u2514","\u251C","\u250C","\u252C","\u2510"]},simpleDots:{interval:400,frames:[". ",".. ","..."," "]},simpleDotsScrolling:{interval:200,frames:[". ",".. ","..."," .."," ."," "]},star:{interval:70,frames:["\u2736","\u2738","\u2739","\u273A","\u2739","\u2737"]},star2:{interval:80,frames:["+","x","*"]},flip:{interval:70,frames:["_","_","_","-","`","`","'","\xB4","-","_","_","_"]},hamburger:{interval:100,frames:["\u2631","\u2632","\u2634"]},growVertical:{interval:120,frames:["\u2581","\u2583","\u2584","\u2585","\u2586","\u2587","\u2586","\u2585","\u2584","\u2583"]},growHorizontal:{interval:120,frames:["\u258F","\u258E","\u258D","\u258C","\u258B","\u258A","\u2589","\u258A","\u258B","\u258C","\u258D","\u258E"]},balloon:{interval:140,frames:[" ",".","o","O","@","*"," "]},balloon2:{interval:120,frames:[".","o","O","\xB0","O","o","."]},noise:{interval:100,frames:["\u2593","\u2592","\u2591"]},bounce:{interval:120,frames:["\u2801","\u2802","\u2804","\u2802"]},boxBounce:{interval:120,frames:["\u2596","\u2598","\u259D","\u2597"]},boxBounce2:{interval:100,frames:["\u258C","\u2580","\u2590","\u2584"]},triangle:{interval:50,frames:["\u25E2","\u25E3","\u25E4","\u25E5"]},binary:{interval:80,frames:["010010","001100","100101","111010","111101","010111","101011","111000","110011","110101"]},arc:{interval:100,frames:["\u25DC","\u25E0","\u25DD","\u25DE","\u25E1","\u25DF"]},circle:{interval:120,frames:["\u25E1","\u2299","\u25E0"]},squareCorners:{interval:180,frames:["\u25F0","\u25F3","\u25F2","\u25F1"]},circleQuarters:{interval:120,frames:["\u25F4","\u25F7","\u25F6","\u25F5"]},circleHalves:{interval:50,frames:["\u25D0","\u25D3","\u25D1","\u25D2"]},squish:{interval:100,frames:["\u256B","\u256A"]},toggle:{interval:250,frames:["\u22B6","\u22B7"]},toggle2:{interval:80,frames:["\u25AB","\u25AA"]},toggle3:{interval:120,frames:["\u25A1","\u25A0"]},toggle4:{interval:100,frames:["\u25A0","\u25A1","\u25AA","\u25AB"]},toggle5:{interval:100,frames:["\u25AE","\u25AF"]},toggle6:{interval:300,frames:["\u101D","\u1040"]},toggle7:{interval:80,frames:["\u29BE","\u29BF"]},toggle8:{interval:100,frames:["\u25CD","\u25CC"]},toggle9:{interval:100,frames:["\u25C9","\u25CE"]},toggle10:{interval:100,frames:["\u3282","\u3280","\u3281"]},toggle11:{interval:50,frames:["\u29C7","\u29C6"]},toggle12:{interval:120,frames:["\u2617","\u2616"]},toggle13:{interval:80,frames:["=","*","-"]},arrow:{interval:100,frames:["\u2190","\u2196","\u2191","\u2197","\u2192","\u2198","\u2193","\u2199"]},arrow2:{interval:80,frames:["\u2B06\uFE0F ","\u2197\uFE0F ","\u27A1\uFE0F ","\u2198\uFE0F ","\u2B07\uFE0F ","\u2199\uFE0F ","\u2B05\uFE0F ","\u2196\uFE0F "]},arrow3:{interval:120,frames:["\u25B9\u25B9\u25B9\u25B9\u25B9","\u25B8\u25B9\u25B9\u25B9\u25B9","\u25B9\u25B8\u25B9\u25B9\u25B9","\u25B9\u25B9\u25B8\u25B9\u25B9","\u25B9\u25B9\u25B9\u25B8\u25B9","\u25B9\u25B9\u25B9\u25B9\u25B8"]},bouncingBar:{interval:80,frames:["[ ]","[= ]","[== ]","[=== ]","[====]","[ ===]","[ ==]","[ =]","[ ]","[ =]","[ ==]","[ ===]","[====]","[=== ]","[== ]","[= ]"]},bouncingBall:{interval:80,frames:["( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF)","( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF )","(\u25CF )"]},smiley:{interval:200,frames:["\uD83D\uDE04 ","\uD83D\uDE1D "]},monkey:{interval:300,frames:["\uD83D\uDE48 ","\uD83D\uDE48 ","\uD83D\uDE49 ","\uD83D\uDE4A "]},hearts:{interval:100,frames:["\uD83D\uDC9B ","\uD83D\uDC99 ","\uD83D\uDC9C ","\uD83D\uDC9A ","\uD83D\uDC97 "]},clock:{interval:100,frames:["\uD83D\uDD5B ","\uD83D\uDD50 ","\uD83D\uDD51 ","\uD83D\uDD52 ","\uD83D\uDD53 ","\uD83D\uDD54 ","\uD83D\uDD55 ","\uD83D\uDD56 ","\uD83D\uDD57 ","\uD83D\uDD58 ","\uD83D\uDD59 ","\uD83D\uDD5A "]},earth:{interval:180,frames:["\uD83C\uDF0D ","\uD83C\uDF0E ","\uD83C\uDF0F "]},material:{interval:17,frames:["\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581"]},moon:{interval:80,frames:["\uD83C\uDF11 ","\uD83C\uDF12 ","\uD83C\uDF13 ","\uD83C\uDF14 ","\uD83C\uDF15 ","\uD83C\uDF16 ","\uD83C\uDF17 ","\uD83C\uDF18 "]},runner:{interval:140,frames:["\uD83D\uDEB6 ","\uD83C\uDFC3 "]},pong:{interval:80,frames:["\u2590\u2802 \u258C","\u2590\u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802\u258C","\u2590 \u2820\u258C","\u2590 \u2840\u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590\u2820 \u258C"]},shark:{interval:120,frames:["\u2590|\\____________\u258C","\u2590_|\\___________\u258C","\u2590__|\\__________\u258C","\u2590___|\\_________\u258C","\u2590____|\\________\u258C","\u2590_____|\\_______\u258C","\u2590______|\\______\u258C","\u2590_______|\\_____\u258C","\u2590________|\\____\u258C","\u2590_________|\\___\u258C","\u2590__________|\\__\u258C","\u2590___________|\\_\u258C","\u2590____________|\\\u258C","\u2590____________/|\u258C","\u2590___________/|_\u258C","\u2590__________/|__\u258C","\u2590_________/|___\u258C","\u2590________/|____\u258C","\u2590_______/|_____\u258C","\u2590______/|______\u258C","\u2590_____/|_______\u258C","\u2590____/|________\u258C","\u2590___/|_________\u258C","\u2590__/|__________\u258C","\u2590_/|___________\u258C","\u2590/|____________\u258C"]},dqpb:{interval:100,frames:["d","q","p","b"]},weather:{interval:100,frames:["\u2600\uFE0F ","\u2600\uFE0F ","\u2600\uFE0F ","\uD83C\uDF24 ","\u26C5\uFE0F ","\uD83C\uDF25 ","\u2601\uFE0F ","\uD83C\uDF27 ","\uD83C\uDF28 ","\uD83C\uDF27 ","\uD83C\uDF28 ","\uD83C\uDF27 ","\uD83C\uDF28 ","\u26C8 ","\uD83C\uDF28 ","\uD83C\uDF27 ","\uD83C\uDF28 ","\u2601\uFE0F ","\uD83C\uDF25 ","\u26C5\uFE0F ","\uD83C\uDF24 ","\u2600\uFE0F ","\u2600\uFE0F "]},christmas:{interval:400,frames:["\uD83C\uDF32","\uD83C\uDF84"]},grenade:{interval:80,frames:["\u060C ","\u2032 "," \xB4 "," \u203E "," \u2E0C"," \u2E0A"," |"," \u204E"," \u2055"," \u0DF4 "," \u2053"," "," "," "]},point:{interval:125,frames:["\u2219\u2219\u2219","\u25CF\u2219\u2219","\u2219\u25CF\u2219","\u2219\u2219\u25CF","\u2219\u2219\u2219"]},layer:{interval:150,frames:["-","=","\u2261"]},betaWave:{interval:80,frames:["\u03C1\u03B2\u03B2\u03B2\u03B2\u03B2\u03B2","\u03B2\u03C1\u03B2\u03B2\u03B2\u03B2\u03B2","\u03B2\u03B2\u03C1\u03B2\u03B2\u03B2\u03B2","\u03B2\u03B2\u03B2\u03C1\u03B2\u03B2\u03B2","\u03B2\u03B2\u03B2\u03B2\u03C1\u03B2\u03B2","\u03B2\u03B2\u03B2\u03B2\u03B2\u03C1\u03B2","\u03B2\u03B2\u03B2\u03B2\u03B2\u03B2\u03C1"]},fingerDance:{interval:160,frames:["\uD83E\uDD18 ","\uD83E\uDD1F ","\uD83D\uDD96 ","\u270B ","\uD83E\uDD1A ","\uD83D\uDC46 "]},fistBump:{interval:80,frames:["\uD83E\uDD1C\u3000\u3000\u3000\u3000\uD83E\uDD1B ","\uD83E\uDD1C\u3000\u3000\u3000\u3000\uD83E\uDD1B ","\uD83E\uDD1C\u3000\u3000\u3000\u3000\uD83E\uDD1B ","\u3000\uD83E\uDD1C\u3000\u3000\uD83E\uDD1B\u3000 ","\u3000\u3000\uD83E\uDD1C\uD83E\uDD1B\u3000\u3000 ","\u3000\uD83E\uDD1C\u2728\uD83E\uDD1B\u3000\u3000 ","\uD83E\uDD1C\u3000\u2728\u3000\uD83E\uDD1B\u3000 "]},soccerHeader:{interval:80,frames:[" \uD83E\uDDD1\u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F\uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 "]},mindblown:{interval:160,frames:["\uD83D\uDE10 ","\uD83D\uDE10 ","\uD83D\uDE2E ","\uD83D\uDE2E ","\uD83D\uDE26 ","\uD83D\uDE26 ","\uD83D\uDE27 ","\uD83D\uDE27 ","\uD83E\uDD2F ","\uD83D\uDCA5 ","\u2728 ","\u3000 ","\u3000 ","\u3000 "]},speaker:{interval:160,frames:["\uD83D\uDD08 ","\uD83D\uDD09 ","\uD83D\uDD0A ","\uD83D\uDD09 "]},orangePulse:{interval:100,frames:["\uD83D\uDD38 ","\uD83D\uDD36 ","\uD83D\uDFE0 ","\uD83D\uDFE0 ","\uD83D\uDD36 "]},bluePulse:{interval:100,frames:["\uD83D\uDD39 ","\uD83D\uDD37 ","\uD83D\uDD35 ","\uD83D\uDD35 ","\uD83D\uDD37 "]},orangeBluePulse:{interval:100,frames:["\uD83D\uDD38 ","\uD83D\uDD36 ","\uD83D\uDFE0 ","\uD83D\uDFE0 ","\uD83D\uDD36 ","\uD83D\uDD39 ","\uD83D\uDD37 ","\uD83D\uDD35 ","\uD83D\uDD35 ","\uD83D\uDD37 "]},timeTravel:{interval:100,frames:["\uD83D\uDD5B ","\uD83D\uDD5A ","\uD83D\uDD59 ","\uD83D\uDD58 ","\uD83D\uDD57 ","\uD83D\uDD56 ","\uD83D\uDD55 ","\uD83D\uDD54 ","\uD83D\uDD53 ","\uD83D\uDD52 ","\uD83D\uDD51 ","\uD83D\uDD50 "]},aesthetic:{interval:80,frames:["\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0","\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1\u25B1"]},dwarfFortress:{interval:80,frames:[" \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A \u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\xA3\xA3\xA3 "," \u263A \u2588\xA3\xA3\xA3 "," \u263A\u2588\xA3\xA3\xA3 "," \u263A\u2588\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3\xA3 "," \u263A\u2592\xA3\xA3\xA3 "," \u263A\u2592\xA3\xA3\xA3 "," \u263A\u2591\xA3\xA3\xA3 "," \u263A\u2591\xA3\xA3\xA3 "," \u263A \xA3\xA3\xA3 "," \u263A\xA3\xA3\xA3 "," \u263A\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3 "," \u263A\u2593\xA3\xA3 "," \u263A\u2592\xA3\xA3 "," \u263A\u2592\xA3\xA3 "," \u263A\u2591\xA3\xA3 "," \u263A\u2591\xA3\xA3 "," \u263A \xA3\xA3 "," \u263A\xA3\xA3 "," \u263A\xA3\xA3 "," \u263A\u2593\xA3 "," \u263A\u2593\xA3 "," \u263A\u2592\xA3 "," \u263A\u2592\xA3 "," \u263A\u2591\xA3 "," \u263A\u2591\xA3 "," \u263A \xA3 "," \u263A\xA3 "," \u263A\xA3 "," \u263A\u2593 "," \u263A\u2593 "," \u263A\u2592 "," \u263A\u2592 "," \u263A\u2591 "," \u263A\u2591 "," \u263A "," \u263A &"," \u263A \u263C&"," \u263A \u263C &"," \u263A\u263C &"," \u263A\u263C & "," \u203C & "," \u263A & "," \u203C & "," \u263A & "," \u203C & "," \u263A & ","\u203C & "," & "," & "," & \u2591 "," & \u2592 "," & \u2593 "," & \xA3 "," & \u2591\xA3 "," & \u2592\xA3 "," & \u2593\xA3 "," & \xA3\xA3 "," & \u2591\xA3\xA3 "," & \u2592\xA3\xA3 ","& \u2593\xA3\xA3 ","& \xA3\xA3\xA3 "," \u2591\xA3\xA3\xA3 "," \u2592\xA3\xA3\xA3 "," \u2593\xA3\xA3\xA3 "," \u2588\xA3\xA3\xA3 "," \u2591\u2588\xA3\xA3\xA3 "," \u2592\u2588\xA3\xA3\xA3 "," \u2593\u2588\xA3\xA3\xA3 "," \u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "]},fish:{interval:80,frames:["~~~~~~~~~~~~~~~~~~~~","> ~~~~~~~~~~~~~~~~~~","\xBA> ~~~~~~~~~~~~~~~~~","(\xBA> ~~~~~~~~~~~~~~~~","((\xBA> ~~~~~~~~~~~~~~~","<((\xBA> ~~~~~~~~~~~~~~","><((\xBA> ~~~~~~~~~~~~~"," ><((\xBA> ~~~~~~~~~~~~","~ ><((\xBA> ~~~~~~~~~~~","~~ <>((\xBA> ~~~~~~~~~~","~~~ ><((\xBA> ~~~~~~~~~","~~~~ <>((\xBA> ~~~~~~~~","~~~~~ ><((\xBA> ~~~~~~~","~~~~~~ <>((\xBA> ~~~~~~","~~~~~~~ ><((\xBA> ~~~~~","~~~~~~~~ <>((\xBA> ~~~~","~~~~~~~~~ ><((\xBA> ~~~","~~~~~~~~~~ <>((\xBA> ~~","~~~~~~~~~~~ ><((\xBA> ~","~~~~~~~~~~~~ <>((\xBA> ","~~~~~~~~~~~~~ ><((\xBA>","~~~~~~~~~~~~~~ <>((\xBA","~~~~~~~~~~~~~~~ ><((","~~~~~~~~~~~~~~~~ <>(","~~~~~~~~~~~~~~~~~ ><","~~~~~~~~~~~~~~~~~~ <","~~~~~~~~~~~~~~~~~~~~"]}}});var S2,jN;var JH=A(()=>{qH();S2=V6,jN=Object.keys(V6)});import KM from"tty";var WM,a=(Q,$)=>{if(!WM)return(J)=>J;let Y=`\x1B[${Q}m`,q=`\x1B[${$}m`;return(J)=>{let X=J+"",H=X.indexOf(q);if(H===-1)return Y+X+q;let G=Y,K=0,z=($===22?q:"")+Y;while(H!==-1)G+=X.slice(K,H)+z,K=H+q.length,H=X.indexOf(q,K);return G+=X.slice(K)+q,G}},ON,IN,NN,TN,bN,RN,SN,EN,kN,vN,XH,HH,GH,KH,PN,xN,CN,yN,hN,fN,uN,mN,gN,cN,dN,pN,lN,iN,nN,oN,sN,rN,aN,tN,eN,QT,$T,YT,qT,JT,XT;var A6=A(()=>{WM=KM?.WriteStream?.prototype?.hasColors?.()??!1,ON=a(0,0),IN=a(1,22),NN=a(2,22),TN=a(3,23),bN=a(4,24),RN=a(53,55),SN=a(7,27),EN=a(8,28),kN=a(9,29),vN=a(30,39),XH=a(31,39),HH=a(32,39),GH=a(33,39),KH=a(34,39),PN=a(35,39),xN=a(36,39),CN=a(37,39),yN=a(90,39),hN=a(40,49),fN=a(41,49),uN=a(42,49),mN=a(43,49),gN=a(44,49),cN=a(45,49),dN=a(46,49),pN=a(47,49),lN=a(100,49),iN=a(91,39),nN=a(92,39),oN=a(93,39),sN=a(94,39),rN=a(95,39),aN=a(96,39),tN=a(97,39),eN=a(101,49),QT=a(102,49),$T=a(103,49),YT=a(104,49),qT=a(105,49),JT=a(106,49),XT=a(107,49)});var WH=A(()=>{A6();A6()});import zH from"process";function E2(){let{env:Q}=zH,{TERM:$,TERM_PROGRAM:Y}=Q;if(zH.platform!=="win32")return $!=="linux";return Boolean(Q.WT_SESSION)||Boolean(Q.TERMINUS_SUBLIME)||Q.ConEmuTask==="{cmd::Cmder}"||Y==="Terminus-Sublime"||Y==="vscode"||$==="xterm-256color"||$==="alacritty"||$==="rxvt-unicode"||$==="rxvt-unicode-256color"||Q.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var L6=()=>{};var q9={};F8(q9,{warning:()=>ZM,success:()=>_M,info:()=>BM,error:()=>MM});var c3,BM,_M,ZM,MM;var BH=A(()=>{WH();L6();c3=E2(),BM=KH(c3?"\u2139":"i"),_M=HH(c3?"\u2714":"\u221A"),ZM=GH(c3?"\u26A0":"\u203C"),MM=XH(c3?"\u2716":"\xD7")});var _H=A(()=>{BH()});function F6({onlyFirst:Q=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",Q?void 0:"g")}function j6(Q){if(typeof Q!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof Q}\``);return Q.replace(UM,"")}var UM;var ZH=A(()=>{UM=F6()});var d3,p3,w6,D6,k2;var MH=A(()=>{d3=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],p3=[12288,12288,65281,65376,65504,65510],w6=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],D6=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],k2=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141]});var l3=(Q,$)=>{let Y=0,q=Math.floor(Q.length/2)-1;while(Y<=q){let J=Math.floor((Y+q)/2),X=J*2;if($<Q[X])q=J-1;else if($>Q[X+1])Y=J+1;else return!0}return!1};function IM(Q){let $=Q[0],Y=Q[1];for(let q=0;q<Q.length;q+=2){let J=Q[q],X=Q[q+1];if(UH>=J&&UH<=X)return[J,X];if(X-J>Y-$)$=J,Y=X}return[$,Y]}var VM,AM,LM,FM,jT,wT,DT,OT,jM,wM,UH=19968,DM,OM,VH=(Q)=>{if(Q<VM||Q>AM)return!1;return l3(d3,Q)},AH=(Q)=>{if(Q<LM||Q>FM)return!1;return l3(p3,Q)},LH=(Q)=>{if(Q>=DM&&Q<=OM)return!0;if(Q<jM||Q>wM)return!1;return l3(k2,Q)};var FH=A(()=>{MH();VM=d3[0],AM=d3.at(-1),LM=p3[0],FM=p3.at(-1),jT=w6[0],wT=w6.at(-1),DT=D6[0],OT=D6.at(-1),jM=k2[0],wM=k2.at(-1),[DM,OM]=IM(k2)});function NM(Q){if(!Number.isSafeInteger(Q))throw TypeError(`Expected a code point, got \`${typeof Q}\`.`)}function O6(Q,{ambiguousAsWide:$=!1}={}){if(NM(Q),AH(Q)||LH(Q)||$&&VH(Q))return 2;return 1}var jH=A(()=>{FH()});function vM(Q){if(Q.length>50)return!1;if(EM.test(Q))return!0;if(Q.includes("\u200D")){let $=Q.match(kM);return $!==null&&$.length>=2}return!1}function PM(Q){return Q.replace(RM,"")}function xM(Q){return bM.test(Q)}function CM(Q,$){let Y=0;if(Q.length>1){for(let q of Q.slice(1))if(q>="\uFF00"&&q<="\uFFEF")Y+=O6(q.codePointAt(0),$)}return Y}function I6(Q,$={}){if(typeof Q!=="string"||Q.length===0)return 0;let{ambiguousIsNarrow:Y=!0,countAnsiEscapeCodes:q=!1}=$,J=Q;if(!q&&(J.includes("\x1B")||J.includes("\x9B")))J=j6(J);if(J.length===0)return 0;if(/^[\u0020-\u007E]*$/.test(J))return J.length;let X=0,H={ambiguousAsWide:!Y};for(let{segment:G}of TM.segment(J)){if(xM(G))continue;if(SM.test(G)||vM(G)){X+=2;continue}let K=PM(G).codePointAt(0);X+=O6(K,H),X+=CM(G,H)}return X}var TM,bM,RM,SM,EM,kM;var wH=A(()=>{ZH();jH();TM=new Intl.Segmenter,bM=/^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Mark}|\p{Surrogate})+$/v,RM=/^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Mark}\p{Surrogate}]+/v,SM=/^\p{RGI_Emoji}$/v,EM=/^[\d#*]\u20E3$/,kM=/\p{Extended_Pictographic}/gu});function N6({stream:Q=process.stdout}={}){return Boolean(Q&&Q.isTTY&&process.env.TERM!=="dumb"&&!("CI"in process.env))}import m9 from"process";class DH{#X=0;#q;#Y=!1;#Q=!1;#J=(Q)=>{if(!Q?.length)return;if((typeof Q==="string"?Q.codePointAt(0):Q[0])===yM)if(m9.listenerCount("SIGINT")>0)m9.emit("SIGINT");else m9.kill(m9.pid,"SIGINT")};start(){if(this.#X++,this.#X===1)this.#$()}stop(){if(this.#X===0)return;if(--this.#X===0)this.#H()}#$(){let{stdin:Q}=m9;if(m9.platform==="win32"||!Q?.isTTY||typeof Q.setRawMode!=="function"){this.#q=void 0;return}if(this.#q=Q,this.#Y=Q.isPaused(),this.#Q=Boolean(Q.isRaw),Q.setRawMode(!0),Q.prependListener("data",this.#J),this.#Y)Q.resume()}#H(){if(!this.#q)return;let Q=this.#q;if(Q.off("data",this.#J),Q.isTTY)Q.setRawMode?.(this.#Q);if(this.#Y)Q.pause();this.#q=void 0,this.#Y=!1,this.#Q=!1}}var yM=3,hM,T6;var OH=A(()=>{hM=new DH,T6=Object.freeze(hM)});import v2 from"process";import{stripVTControlCharacters as fM}from"util";class IH{#X=0;#q=-1;#Y=0;#Q;#J;#$;#H;#K=new Map;#B=!1;#W;#G;#_=!1;color;#z(Q){this.#B=!0;try{return Q()}finally{this.#B=!1}}#M(){if(this.isSpinning)this.render()}#j(Q,$){if(Q===void 0||Q===null)return"";if(typeof Q==="string")return Q;if(Buffer.isBuffer(Q)||ArrayBuffer.isView(Q)){let Y=typeof $==="string"&&$&&$!=="buffer"?$:"utf8";return Buffer.from(Q).toString(Y)}return String(Q)}#w(Q){if(!Q)return!1;let $=Q.at(-1);return $===`
129
+ `);if(X!==-1)$=yX($,J,q,X);return q+$+J},rZ,JN,mX;var gX=A(()=>{EX();xX();({stdout:hX,stderr:fX}=PX),G6=Symbol("GENERATOR"),h9=Symbol("STYLER"),b2=Symbol("IS_EMPTY"),uX=["ansi","ansi","ansi256","ansi16m"],f9=Object.create(null);Object.setPrototypeOf(R2.prototype,Function.prototype);for(let[Q,$]of Object.entries(p0))f9[Q]={get(){let Y=h3(this,W6($.open,$.close,this[h9]),this[b2]);return Object.defineProperty(this,Q,{value:Y}),Y}};f9.visible={get(){let Q=h3(this,this[h9],!0);return Object.defineProperty(this,"visible",{value:Q}),Q}};nZ=["rgb","hex","ansi256"];for(let Q of nZ){f9[Q]={get(){let{level:Y}=this;return function(...q){let J=W6(K6(Q,uX[Y],"color",...q),p0.color.close,this[h9]);return h3(this,J,this[b2])}}};let $="bg"+Q[0].toUpperCase()+Q.slice(1);f9[$]={get(){let{level:Y}=this;return function(...q){let J=W6(K6(Q,uX[Y],"bgColor",...q),p0.bgColor.close,this[h9]);return h3(this,J,this[b2])}}}}oZ=Object.defineProperties(()=>{},{...f9,level:{enumerable:!0,get(){return this[G6].level},set(Q){this[G6].level=Q}}});Object.defineProperties(R2.prototype,f9);rZ=R2(),JN=R2({level:fX?fX.level:0}),mX=rZ});function z6(Q,$,{ignoreNonConfigurable:Y=!1}={}){let{name:q}=Q;for(let J of Reflect.ownKeys($))aZ(Q,$,J,Y);return eZ(Q,$),qM(Q,$,q),Q}var aZ=(Q,$,Y,q)=>{if(Y==="length"||Y==="prototype")return;if(Y==="arguments"||Y==="caller")return;let J=Object.getOwnPropertyDescriptor(Q,Y),X=Object.getOwnPropertyDescriptor($,Y);if(!tZ(J,X)&&q)return;Object.defineProperty(Q,Y,X)},tZ=function(Q,$){return Q===void 0||Q.configurable||Q.writable===$.writable&&Q.enumerable===$.enumerable&&Q.configurable===$.configurable&&(Q.writable||Q.value===$.value)},eZ=(Q,$)=>{let Y=Object.getPrototypeOf($);if(Y===Object.getPrototypeOf(Q))return;Object.setPrototypeOf(Q,Y)},QM=(Q,$)=>`/* Wrapped ${Q}*/
130
+ ${$}`,$M,YM,qM=(Q,$,Y)=>{let q=Y===""?"":`with ${Y.trim()}() `,J=QM.bind(null,q,$.toString());Object.defineProperty(J,"name",YM);let{writable:X,enumerable:H,configurable:G}=$M;Object.defineProperty(Q,"toString",{value:J,writable:X,enumerable:H,configurable:G})};var cX=A(()=>{$M=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),YM=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name")});var f3,dX=(Q,$={})=>{if(typeof Q!=="function")throw TypeError("Expected a function");let Y,q=0,J=Q.displayName||Q.name||"<anonymous>",X=function(...H){if(f3.set(X,++q),q===1)Y=Q.apply(this,H),Q=void 0;else if($.throw===!0)throw Error(`Function \`${J}\` can only be called once`);return Y};return z6(X,Q),f3.set(X,q),X},pX;var lX=A(()=>{cX();f3=new WeakMap;dX.callCount=(Q)=>{if(!f3.has(Q))throw Error(`The given function \`${Q.name}\` is not wrapped by the \`onetime\` package`);return f3.get(Q)};pX=dX});var Y9;var iX=A(()=>{Y9=[];Y9.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")Y9.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")Y9.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")});class nX{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(_6[B6])return _6[B6];JM(_6,B6,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(Q,$){this.listeners[Q].push($)}removeListener(Q,$){let Y=this.listeners[Q],q=Y.indexOf($);if(q===-1)return;if(q===0&&Y.length===1)Y.length=0;else Y.splice(q,1)}emit(Q,$,Y){if(this.emitted[Q])return!1;this.emitted[Q]=!0;let q=!1;for(let J of this.listeners[Q])q=J($,Y)===!0||q;if(Q==="exit")q=this.emit("afterExit",$,Y)||q;return q}}class M6{}var u3=(Q)=>!!Q&&typeof Q==="object"&&typeof Q.removeListener==="function"&&typeof Q.emit==="function"&&typeof Q.reallyExit==="function"&&typeof Q.listeners==="function"&&typeof Q.kill==="function"&&typeof Q.pid==="number"&&typeof Q.on==="function",B6,_6,JM,XM=(Q)=>{return{onExit($,Y){return Q.onExit($,Y)},load(){return Q.load()},unload(){return Q.unload()}}},oX,sX,Z6,rX,BN,_N;var aX=A(()=>{iX();B6=Symbol.for("signal-exit emitter"),_6=globalThis,JM=Object.defineProperty.bind(Object);oX=class oX extends M6{onExit(){return()=>{}}load(){}unload(){}};sX=class sX extends M6{#X=Z6.platform==="win32"?"SIGINT":"SIGHUP";#q=new nX;#Y;#Q;#J;#$={};#H=!1;constructor(Q){super();this.#Y=Q,this.#$={};for(let $ of Y9)this.#$[$]=()=>{let Y=this.#Y.listeners($),{count:q}=this.#q,J=Q;if(typeof J.__signal_exit_emitter__==="object"&&typeof J.__signal_exit_emitter__.count==="number")q+=J.__signal_exit_emitter__.count;if(Y.length===q){this.unload();let X=this.#q.emit("exit",null,$),H=$==="SIGHUP"?this.#X:$;if(!X)Q.kill(Q.pid,H)}};this.#J=Q.reallyExit,this.#Q=Q.emit}onExit(Q,$){if(!u3(this.#Y))return()=>{};if(this.#H===!1)this.load();let Y=$?.alwaysLast?"afterExit":"exit";return this.#q.on(Y,Q),()=>{if(this.#q.removeListener(Y,Q),this.#q.listeners.exit.length===0&&this.#q.listeners.afterExit.length===0)this.unload()}}load(){if(this.#H)return;this.#H=!0,this.#q.count+=1;for(let Q of Y9)try{let $=this.#$[Q];if($)this.#Y.on(Q,$)}catch($){}this.#Y.emit=(Q,...$)=>{return this.#B(Q,...$)},this.#Y.reallyExit=(Q)=>{return this.#K(Q)}}unload(){if(!this.#H)return;this.#H=!1,Y9.forEach((Q)=>{let $=this.#$[Q];if(!$)throw Error("Listener not defined for signal: "+Q);try{this.#Y.removeListener(Q,$)}catch(Y){}}),this.#Y.emit=this.#Q,this.#Y.reallyExit=this.#J,this.#q.count-=1}#K(Q){if(!u3(this.#Y))return 0;return this.#Y.exitCode=Q||0,this.#q.emit("exit",this.#Y.exitCode,null),this.#J.call(this.#Y,this.#Y.exitCode)}#B(Q,...$){let Y=this.#Q;if(Q==="exit"&&u3(this.#Y)){if(typeof $[0]==="number")this.#Y.exitCode=$[0];let q=Y.call(this.#Y,Q,...$);return this.#q.emit("exit",this.#Y.exitCode,null),q}else return Y.call(this.#Y,Q,...$)}};Z6=globalThis.process,{onExit:rX,load:BN,unload:_N}=XM(u3(Z6)?new sX(Z6):new oX)});import m3 from"process";var tX,HM,eX;var QH=A(()=>{lX();aX();tX=m3.stderr.isTTY?m3.stderr:m3.stdout.isTTY?m3.stdout:void 0,HM=tX?pX(()=>{rX(()=>{tX.write("\x1B[?25h")},{alwaysLast:!0})}):()=>{},eX=HM});import $H from"process";var g3=!1,u9,U6;var YH=A(()=>{QH();u9={};u9.show=(Q=$H.stderr)=>{if(!Q.isTTY)return;g3=!1,Q.write("\x1B[?25h")};u9.hide=(Q=$H.stderr)=>{if(!Q.isTTY)return;eX(),g3=!0,Q.write("\x1B[?25l")};u9.toggle=(Q,$)=>{if(Q!==void 0)g3=Q;if(g3)u9.show($);else u9.hide($)};U6=u9});var V6;var qH=A(()=>{V6={dots:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]},dots2:{interval:80,frames:["\u28FE","\u28FD","\u28FB","\u28BF","\u287F","\u28DF","\u28EF","\u28F7"]},dots3:{interval:80,frames:["\u280B","\u2819","\u281A","\u281E","\u2816","\u2826","\u2834","\u2832","\u2833","\u2813"]},dots4:{interval:80,frames:["\u2804","\u2806","\u2807","\u280B","\u2819","\u2838","\u2830","\u2820","\u2830","\u2838","\u2819","\u280B","\u2807","\u2806"]},dots5:{interval:80,frames:["\u280B","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B"]},dots6:{interval:80,frames:["\u2801","\u2809","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2824","\u2804","\u2804","\u2824","\u2834","\u2832","\u2812","\u2802","\u2802","\u2812","\u281A","\u2819","\u2809","\u2801"]},dots7:{interval:80,frames:["\u2808","\u2809","\u280B","\u2813","\u2812","\u2810","\u2810","\u2812","\u2816","\u2826","\u2824","\u2820","\u2820","\u2824","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B","\u2809","\u2808"]},dots8:{interval:80,frames:["\u2801","\u2801","\u2809","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2824","\u2804","\u2804","\u2824","\u2820","\u2820","\u2824","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B","\u2809","\u2808","\u2808"]},dots9:{interval:80,frames:["\u28B9","\u28BA","\u28BC","\u28F8","\u28C7","\u2867","\u2857","\u284F"]},dots10:{interval:80,frames:["\u2884","\u2882","\u2881","\u2841","\u2848","\u2850","\u2860"]},dots11:{interval:100,frames:["\u2801","\u2802","\u2804","\u2840","\u2880","\u2820","\u2810","\u2808"]},dots12:{interval:80,frames:["\u2880\u2800","\u2840\u2800","\u2804\u2800","\u2882\u2800","\u2842\u2800","\u2805\u2800","\u2883\u2800","\u2843\u2800","\u280D\u2800","\u288B\u2800","\u284B\u2800","\u280D\u2801","\u288B\u2801","\u284B\u2801","\u280D\u2809","\u280B\u2809","\u280B\u2809","\u2809\u2819","\u2809\u2819","\u2809\u2829","\u2808\u2899","\u2808\u2859","\u2888\u2829","\u2840\u2899","\u2804\u2859","\u2882\u2829","\u2842\u2898","\u2805\u2858","\u2883\u2828","\u2843\u2890","\u280D\u2850","\u288B\u2820","\u284B\u2880","\u280D\u2841","\u288B\u2801","\u284B\u2801","\u280D\u2809","\u280B\u2809","\u280B\u2809","\u2809\u2819","\u2809\u2819","\u2809\u2829","\u2808\u2899","\u2808\u2859","\u2808\u2829","\u2800\u2899","\u2800\u2859","\u2800\u2829","\u2800\u2898","\u2800\u2858","\u2800\u2828","\u2800\u2890","\u2800\u2850","\u2800\u2820","\u2800\u2880","\u2800\u2840"]},dots13:{interval:80,frames:["\u28FC","\u28F9","\u28BB","\u283F","\u285F","\u28CF","\u28E7","\u28F6"]},dots14:{interval:80,frames:["\u2809\u2809","\u2808\u2819","\u2800\u2839","\u2800\u28B8","\u2800\u28F0","\u2880\u28E0","\u28C0\u28C0","\u28C4\u2840","\u28C6\u2800","\u2847\u2800","\u280F\u2800","\u280B\u2801"]},dots8Bit:{interval:80,frames:["\u2800","\u2801","\u2802","\u2803","\u2804","\u2805","\u2806","\u2807","\u2840","\u2841","\u2842","\u2843","\u2844","\u2845","\u2846","\u2847","\u2808","\u2809","\u280A","\u280B","\u280C","\u280D","\u280E","\u280F","\u2848","\u2849","\u284A","\u284B","\u284C","\u284D","\u284E","\u284F","\u2810","\u2811","\u2812","\u2813","\u2814","\u2815","\u2816","\u2817","\u2850","\u2851","\u2852","\u2853","\u2854","\u2855","\u2856","\u2857","\u2818","\u2819","\u281A","\u281B","\u281C","\u281D","\u281E","\u281F","\u2858","\u2859","\u285A","\u285B","\u285C","\u285D","\u285E","\u285F","\u2820","\u2821","\u2822","\u2823","\u2824","\u2825","\u2826","\u2827","\u2860","\u2861","\u2862","\u2863","\u2864","\u2865","\u2866","\u2867","\u2828","\u2829","\u282A","\u282B","\u282C","\u282D","\u282E","\u282F","\u2868","\u2869","\u286A","\u286B","\u286C","\u286D","\u286E","\u286F","\u2830","\u2831","\u2832","\u2833","\u2834","\u2835","\u2836","\u2837","\u2870","\u2871","\u2872","\u2873","\u2874","\u2875","\u2876","\u2877","\u2838","\u2839","\u283A","\u283B","\u283C","\u283D","\u283E","\u283F","\u2878","\u2879","\u287A","\u287B","\u287C","\u287D","\u287E","\u287F","\u2880","\u2881","\u2882","\u2883","\u2884","\u2885","\u2886","\u2887","\u28C0","\u28C1","\u28C2","\u28C3","\u28C4","\u28C5","\u28C6","\u28C7","\u2888","\u2889","\u288A","\u288B","\u288C","\u288D","\u288E","\u288F","\u28C8","\u28C9","\u28CA","\u28CB","\u28CC","\u28CD","\u28CE","\u28CF","\u2890","\u2891","\u2892","\u2893","\u2894","\u2895","\u2896","\u2897","\u28D0","\u28D1","\u28D2","\u28D3","\u28D4","\u28D5","\u28D6","\u28D7","\u2898","\u2899","\u289A","\u289B","\u289C","\u289D","\u289E","\u289F","\u28D8","\u28D9","\u28DA","\u28DB","\u28DC","\u28DD","\u28DE","\u28DF","\u28A0","\u28A1","\u28A2","\u28A3","\u28A4","\u28A5","\u28A6","\u28A7","\u28E0","\u28E1","\u28E2","\u28E3","\u28E4","\u28E5","\u28E6","\u28E7","\u28A8","\u28A9","\u28AA","\u28AB","\u28AC","\u28AD","\u28AE","\u28AF","\u28E8","\u28E9","\u28EA","\u28EB","\u28EC","\u28ED","\u28EE","\u28EF","\u28B0","\u28B1","\u28B2","\u28B3","\u28B4","\u28B5","\u28B6","\u28B7","\u28F0","\u28F1","\u28F2","\u28F3","\u28F4","\u28F5","\u28F6","\u28F7","\u28B8","\u28B9","\u28BA","\u28BB","\u28BC","\u28BD","\u28BE","\u28BF","\u28F8","\u28F9","\u28FA","\u28FB","\u28FC","\u28FD","\u28FE","\u28FF"]},dotsCircle:{interval:80,frames:["\u288E ","\u280E\u2801","\u280A\u2811","\u2808\u2831"," \u2871","\u2880\u2870","\u2884\u2860","\u2886\u2840"]},sand:{interval:80,frames:["\u2801","\u2802","\u2804","\u2840","\u2848","\u2850","\u2860","\u28C0","\u28C1","\u28C2","\u28C4","\u28CC","\u28D4","\u28E4","\u28E5","\u28E6","\u28EE","\u28F6","\u28F7","\u28FF","\u287F","\u283F","\u289F","\u281F","\u285B","\u281B","\u282B","\u288B","\u280B","\u280D","\u2849","\u2809","\u2811","\u2821","\u2881"]},line:{interval:130,frames:["-","\\","|","/"]},line2:{interval:100,frames:["\u2802","-","\u2013","\u2014","\u2013","-"]},rollingLine:{interval:80,frames:["/ "," - "," \\ "," |"," |"," \\ "," - ","/ "]},pipe:{interval:100,frames:["\u2524","\u2518","\u2534","\u2514","\u251C","\u250C","\u252C","\u2510"]},simpleDots:{interval:400,frames:[". ",".. ","..."," "]},simpleDotsScrolling:{interval:200,frames:[". ",".. ","..."," .."," ."," "]},star:{interval:70,frames:["\u2736","\u2738","\u2739","\u273A","\u2739","\u2737"]},star2:{interval:80,frames:["+","x","*"]},flip:{interval:70,frames:["_","_","_","-","`","`","'","\xB4","-","_","_","_"]},hamburger:{interval:100,frames:["\u2631","\u2632","\u2634"]},growVertical:{interval:120,frames:["\u2581","\u2583","\u2584","\u2585","\u2586","\u2587","\u2586","\u2585","\u2584","\u2583"]},growHorizontal:{interval:120,frames:["\u258F","\u258E","\u258D","\u258C","\u258B","\u258A","\u2589","\u258A","\u258B","\u258C","\u258D","\u258E"]},balloon:{interval:140,frames:[" ",".","o","O","@","*"," "]},balloon2:{interval:120,frames:[".","o","O","\xB0","O","o","."]},noise:{interval:100,frames:["\u2593","\u2592","\u2591"]},bounce:{interval:120,frames:["\u2801","\u2802","\u2804","\u2802"]},boxBounce:{interval:120,frames:["\u2596","\u2598","\u259D","\u2597"]},boxBounce2:{interval:100,frames:["\u258C","\u2580","\u2590","\u2584"]},triangle:{interval:50,frames:["\u25E2","\u25E3","\u25E4","\u25E5"]},binary:{interval:80,frames:["010010","001100","100101","111010","111101","010111","101011","111000","110011","110101"]},arc:{interval:100,frames:["\u25DC","\u25E0","\u25DD","\u25DE","\u25E1","\u25DF"]},circle:{interval:120,frames:["\u25E1","\u2299","\u25E0"]},squareCorners:{interval:180,frames:["\u25F0","\u25F3","\u25F2","\u25F1"]},circleQuarters:{interval:120,frames:["\u25F4","\u25F7","\u25F6","\u25F5"]},circleHalves:{interval:50,frames:["\u25D0","\u25D3","\u25D1","\u25D2"]},squish:{interval:100,frames:["\u256B","\u256A"]},toggle:{interval:250,frames:["\u22B6","\u22B7"]},toggle2:{interval:80,frames:["\u25AB","\u25AA"]},toggle3:{interval:120,frames:["\u25A1","\u25A0"]},toggle4:{interval:100,frames:["\u25A0","\u25A1","\u25AA","\u25AB"]},toggle5:{interval:100,frames:["\u25AE","\u25AF"]},toggle6:{interval:300,frames:["\u101D","\u1040"]},toggle7:{interval:80,frames:["\u29BE","\u29BF"]},toggle8:{interval:100,frames:["\u25CD","\u25CC"]},toggle9:{interval:100,frames:["\u25C9","\u25CE"]},toggle10:{interval:100,frames:["\u3282","\u3280","\u3281"]},toggle11:{interval:50,frames:["\u29C7","\u29C6"]},toggle12:{interval:120,frames:["\u2617","\u2616"]},toggle13:{interval:80,frames:["=","*","-"]},arrow:{interval:100,frames:["\u2190","\u2196","\u2191","\u2197","\u2192","\u2198","\u2193","\u2199"]},arrow2:{interval:80,frames:["\u2B06\uFE0F ","\u2197\uFE0F ","\u27A1\uFE0F ","\u2198\uFE0F ","\u2B07\uFE0F ","\u2199\uFE0F ","\u2B05\uFE0F ","\u2196\uFE0F "]},arrow3:{interval:120,frames:["\u25B9\u25B9\u25B9\u25B9\u25B9","\u25B8\u25B9\u25B9\u25B9\u25B9","\u25B9\u25B8\u25B9\u25B9\u25B9","\u25B9\u25B9\u25B8\u25B9\u25B9","\u25B9\u25B9\u25B9\u25B8\u25B9","\u25B9\u25B9\u25B9\u25B9\u25B8"]},bouncingBar:{interval:80,frames:["[ ]","[= ]","[== ]","[=== ]","[====]","[ ===]","[ ==]","[ =]","[ ]","[ =]","[ ==]","[ ===]","[====]","[=== ]","[== ]","[= ]"]},bouncingBall:{interval:80,frames:["( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF)","( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF )","(\u25CF )"]},smiley:{interval:200,frames:["\uD83D\uDE04 ","\uD83D\uDE1D "]},monkey:{interval:300,frames:["\uD83D\uDE48 ","\uD83D\uDE48 ","\uD83D\uDE49 ","\uD83D\uDE4A "]},hearts:{interval:100,frames:["\uD83D\uDC9B ","\uD83D\uDC99 ","\uD83D\uDC9C ","\uD83D\uDC9A ","\uD83D\uDC97 "]},clock:{interval:100,frames:["\uD83D\uDD5B ","\uD83D\uDD50 ","\uD83D\uDD51 ","\uD83D\uDD52 ","\uD83D\uDD53 ","\uD83D\uDD54 ","\uD83D\uDD55 ","\uD83D\uDD56 ","\uD83D\uDD57 ","\uD83D\uDD58 ","\uD83D\uDD59 ","\uD83D\uDD5A "]},earth:{interval:180,frames:["\uD83C\uDF0D ","\uD83C\uDF0E ","\uD83C\uDF0F "]},material:{interval:17,frames:["\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581"]},moon:{interval:80,frames:["\uD83C\uDF11 ","\uD83C\uDF12 ","\uD83C\uDF13 ","\uD83C\uDF14 ","\uD83C\uDF15 ","\uD83C\uDF16 ","\uD83C\uDF17 ","\uD83C\uDF18 "]},runner:{interval:140,frames:["\uD83D\uDEB6 ","\uD83C\uDFC3 "]},pong:{interval:80,frames:["\u2590\u2802 \u258C","\u2590\u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802\u258C","\u2590 \u2820\u258C","\u2590 \u2840\u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590\u2820 \u258C"]},shark:{interval:120,frames:["\u2590|\\____________\u258C","\u2590_|\\___________\u258C","\u2590__|\\__________\u258C","\u2590___|\\_________\u258C","\u2590____|\\________\u258C","\u2590_____|\\_______\u258C","\u2590______|\\______\u258C","\u2590_______|\\_____\u258C","\u2590________|\\____\u258C","\u2590_________|\\___\u258C","\u2590__________|\\__\u258C","\u2590___________|\\_\u258C","\u2590____________|\\\u258C","\u2590____________/|\u258C","\u2590___________/|_\u258C","\u2590__________/|__\u258C","\u2590_________/|___\u258C","\u2590________/|____\u258C","\u2590_______/|_____\u258C","\u2590______/|______\u258C","\u2590_____/|_______\u258C","\u2590____/|________\u258C","\u2590___/|_________\u258C","\u2590__/|__________\u258C","\u2590_/|___________\u258C","\u2590/|____________\u258C"]},dqpb:{interval:100,frames:["d","q","p","b"]},weather:{interval:100,frames:["\u2600\uFE0F ","\u2600\uFE0F ","\u2600\uFE0F ","\uD83C\uDF24 ","\u26C5\uFE0F ","\uD83C\uDF25 ","\u2601\uFE0F ","\uD83C\uDF27 ","\uD83C\uDF28 ","\uD83C\uDF27 ","\uD83C\uDF28 ","\uD83C\uDF27 ","\uD83C\uDF28 ","\u26C8 ","\uD83C\uDF28 ","\uD83C\uDF27 ","\uD83C\uDF28 ","\u2601\uFE0F ","\uD83C\uDF25 ","\u26C5\uFE0F ","\uD83C\uDF24 ","\u2600\uFE0F ","\u2600\uFE0F "]},christmas:{interval:400,frames:["\uD83C\uDF32","\uD83C\uDF84"]},grenade:{interval:80,frames:["\u060C ","\u2032 "," \xB4 "," \u203E "," \u2E0C"," \u2E0A"," |"," \u204E"," \u2055"," \u0DF4 "," \u2053"," "," "," "]},point:{interval:125,frames:["\u2219\u2219\u2219","\u25CF\u2219\u2219","\u2219\u25CF\u2219","\u2219\u2219\u25CF","\u2219\u2219\u2219"]},layer:{interval:150,frames:["-","=","\u2261"]},betaWave:{interval:80,frames:["\u03C1\u03B2\u03B2\u03B2\u03B2\u03B2\u03B2","\u03B2\u03C1\u03B2\u03B2\u03B2\u03B2\u03B2","\u03B2\u03B2\u03C1\u03B2\u03B2\u03B2\u03B2","\u03B2\u03B2\u03B2\u03C1\u03B2\u03B2\u03B2","\u03B2\u03B2\u03B2\u03B2\u03C1\u03B2\u03B2","\u03B2\u03B2\u03B2\u03B2\u03B2\u03C1\u03B2","\u03B2\u03B2\u03B2\u03B2\u03B2\u03B2\u03C1"]},fingerDance:{interval:160,frames:["\uD83E\uDD18 ","\uD83E\uDD1F ","\uD83D\uDD96 ","\u270B ","\uD83E\uDD1A ","\uD83D\uDC46 "]},fistBump:{interval:80,frames:["\uD83E\uDD1C\u3000\u3000\u3000\u3000\uD83E\uDD1B ","\uD83E\uDD1C\u3000\u3000\u3000\u3000\uD83E\uDD1B ","\uD83E\uDD1C\u3000\u3000\u3000\u3000\uD83E\uDD1B ","\u3000\uD83E\uDD1C\u3000\u3000\uD83E\uDD1B\u3000 ","\u3000\u3000\uD83E\uDD1C\uD83E\uDD1B\u3000\u3000 ","\u3000\uD83E\uDD1C\u2728\uD83E\uDD1B\u3000\u3000 ","\uD83E\uDD1C\u3000\u2728\u3000\uD83E\uDD1B\u3000 "]},soccerHeader:{interval:80,frames:[" \uD83E\uDDD1\u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F\uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 "]},mindblown:{interval:160,frames:["\uD83D\uDE10 ","\uD83D\uDE10 ","\uD83D\uDE2E ","\uD83D\uDE2E ","\uD83D\uDE26 ","\uD83D\uDE26 ","\uD83D\uDE27 ","\uD83D\uDE27 ","\uD83E\uDD2F ","\uD83D\uDCA5 ","\u2728 ","\u3000 ","\u3000 ","\u3000 "]},speaker:{interval:160,frames:["\uD83D\uDD08 ","\uD83D\uDD09 ","\uD83D\uDD0A ","\uD83D\uDD09 "]},orangePulse:{interval:100,frames:["\uD83D\uDD38 ","\uD83D\uDD36 ","\uD83D\uDFE0 ","\uD83D\uDFE0 ","\uD83D\uDD36 "]},bluePulse:{interval:100,frames:["\uD83D\uDD39 ","\uD83D\uDD37 ","\uD83D\uDD35 ","\uD83D\uDD35 ","\uD83D\uDD37 "]},orangeBluePulse:{interval:100,frames:["\uD83D\uDD38 ","\uD83D\uDD36 ","\uD83D\uDFE0 ","\uD83D\uDFE0 ","\uD83D\uDD36 ","\uD83D\uDD39 ","\uD83D\uDD37 ","\uD83D\uDD35 ","\uD83D\uDD35 ","\uD83D\uDD37 "]},timeTravel:{interval:100,frames:["\uD83D\uDD5B ","\uD83D\uDD5A ","\uD83D\uDD59 ","\uD83D\uDD58 ","\uD83D\uDD57 ","\uD83D\uDD56 ","\uD83D\uDD55 ","\uD83D\uDD54 ","\uD83D\uDD53 ","\uD83D\uDD52 ","\uD83D\uDD51 ","\uD83D\uDD50 "]},aesthetic:{interval:80,frames:["\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0","\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1\u25B1"]},dwarfFortress:{interval:80,frames:[" \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A \u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\xA3\xA3\xA3 "," \u263A \u2588\xA3\xA3\xA3 "," \u263A\u2588\xA3\xA3\xA3 "," \u263A\u2588\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3\xA3 "," \u263A\u2592\xA3\xA3\xA3 "," \u263A\u2592\xA3\xA3\xA3 "," \u263A\u2591\xA3\xA3\xA3 "," \u263A\u2591\xA3\xA3\xA3 "," \u263A \xA3\xA3\xA3 "," \u263A\xA3\xA3\xA3 "," \u263A\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3 "," \u263A\u2593\xA3\xA3 "," \u263A\u2592\xA3\xA3 "," \u263A\u2592\xA3\xA3 "," \u263A\u2591\xA3\xA3 "," \u263A\u2591\xA3\xA3 "," \u263A \xA3\xA3 "," \u263A\xA3\xA3 "," \u263A\xA3\xA3 "," \u263A\u2593\xA3 "," \u263A\u2593\xA3 "," \u263A\u2592\xA3 "," \u263A\u2592\xA3 "," \u263A\u2591\xA3 "," \u263A\u2591\xA3 "," \u263A \xA3 "," \u263A\xA3 "," \u263A\xA3 "," \u263A\u2593 "," \u263A\u2593 "," \u263A\u2592 "," \u263A\u2592 "," \u263A\u2591 "," \u263A\u2591 "," \u263A "," \u263A &"," \u263A \u263C&"," \u263A \u263C &"," \u263A\u263C &"," \u263A\u263C & "," \u203C & "," \u263A & "," \u203C & "," \u263A & "," \u203C & "," \u263A & ","\u203C & "," & "," & "," & \u2591 "," & \u2592 "," & \u2593 "," & \xA3 "," & \u2591\xA3 "," & \u2592\xA3 "," & \u2593\xA3 "," & \xA3\xA3 "," & \u2591\xA3\xA3 "," & \u2592\xA3\xA3 ","& \u2593\xA3\xA3 ","& \xA3\xA3\xA3 "," \u2591\xA3\xA3\xA3 "," \u2592\xA3\xA3\xA3 "," \u2593\xA3\xA3\xA3 "," \u2588\xA3\xA3\xA3 "," \u2591\u2588\xA3\xA3\xA3 "," \u2592\u2588\xA3\xA3\xA3 "," \u2593\u2588\xA3\xA3\xA3 "," \u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "]},fish:{interval:80,frames:["~~~~~~~~~~~~~~~~~~~~","> ~~~~~~~~~~~~~~~~~~","\xBA> ~~~~~~~~~~~~~~~~~","(\xBA> ~~~~~~~~~~~~~~~~","((\xBA> ~~~~~~~~~~~~~~~","<((\xBA> ~~~~~~~~~~~~~~","><((\xBA> ~~~~~~~~~~~~~"," ><((\xBA> ~~~~~~~~~~~~","~ ><((\xBA> ~~~~~~~~~~~","~~ <>((\xBA> ~~~~~~~~~~","~~~ ><((\xBA> ~~~~~~~~~","~~~~ <>((\xBA> ~~~~~~~~","~~~~~ ><((\xBA> ~~~~~~~","~~~~~~ <>((\xBA> ~~~~~~","~~~~~~~ ><((\xBA> ~~~~~","~~~~~~~~ <>((\xBA> ~~~~","~~~~~~~~~ ><((\xBA> ~~~","~~~~~~~~~~ <>((\xBA> ~~","~~~~~~~~~~~ ><((\xBA> ~","~~~~~~~~~~~~ <>((\xBA> ","~~~~~~~~~~~~~ ><((\xBA>","~~~~~~~~~~~~~~ <>((\xBA","~~~~~~~~~~~~~~~ ><((","~~~~~~~~~~~~~~~~ <>(","~~~~~~~~~~~~~~~~~ ><","~~~~~~~~~~~~~~~~~~ <","~~~~~~~~~~~~~~~~~~~~"]}}});var S2,ON;var JH=A(()=>{qH();S2=V6,ON=Object.keys(V6)});import KM from"tty";var WM,a=(Q,$)=>{if(!WM)return(J)=>J;let Y=`\x1B[${Q}m`,q=`\x1B[${$}m`;return(J)=>{let X=J+"",H=X.indexOf(q);if(H===-1)return Y+X+q;let G=Y,K=0,z=($===22?q:"")+Y;while(H!==-1)G+=X.slice(K,H)+z,K=H+q.length,H=X.indexOf(q,K);return G+=X.slice(K)+q,G}},TN,bN,RN,SN,EN,kN,vN,PN,xN,CN,XH,HH,GH,KH,yN,hN,fN,uN,mN,gN,cN,dN,pN,lN,iN,nN,oN,sN,rN,aN,tN,eN,QT,$T,YT,qT,JT,XT,HT,GT,KT;var A6=A(()=>{WM=KM?.WriteStream?.prototype?.hasColors?.()??!1,TN=a(0,0),bN=a(1,22),RN=a(2,22),SN=a(3,23),EN=a(4,24),kN=a(53,55),vN=a(7,27),PN=a(8,28),xN=a(9,29),CN=a(30,39),XH=a(31,39),HH=a(32,39),GH=a(33,39),KH=a(34,39),yN=a(35,39),hN=a(36,39),fN=a(37,39),uN=a(90,39),mN=a(40,49),gN=a(41,49),cN=a(42,49),dN=a(43,49),pN=a(44,49),lN=a(45,49),iN=a(46,49),nN=a(47,49),oN=a(100,49),sN=a(91,39),rN=a(92,39),aN=a(93,39),tN=a(94,39),eN=a(95,39),QT=a(96,39),$T=a(97,39),YT=a(101,49),qT=a(102,49),JT=a(103,49),XT=a(104,49),HT=a(105,49),GT=a(106,49),KT=a(107,49)});var WH=A(()=>{A6();A6()});import zH from"process";function E2(){let{env:Q}=zH,{TERM:$,TERM_PROGRAM:Y}=Q;if(zH.platform!=="win32")return $!=="linux";return Boolean(Q.WT_SESSION)||Boolean(Q.TERMINUS_SUBLIME)||Q.ConEmuTask==="{cmd::Cmder}"||Y==="Terminus-Sublime"||Y==="vscode"||$==="xterm-256color"||$==="alacritty"||$==="rxvt-unicode"||$==="rxvt-unicode-256color"||Q.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var L6=()=>{};var q9={};F8(q9,{warning:()=>ZM,success:()=>_M,info:()=>BM,error:()=>MM});var c3,BM,_M,ZM,MM;var BH=A(()=>{WH();L6();c3=E2(),BM=KH(c3?"\u2139":"i"),_M=HH(c3?"\u2714":"\u221A"),ZM=GH(c3?"\u26A0":"\u203C"),MM=XH(c3?"\u2716":"\xD7")});var _H=A(()=>{BH()});function F6({onlyFirst:Q=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",Q?void 0:"g")}function j6(Q){if(typeof Q!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof Q}\``);return Q.replace(UM,"")}var UM;var ZH=A(()=>{UM=F6()});var d3,p3,w6,D6,k2;var MH=A(()=>{d3=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],p3=[12288,12288,65281,65376,65504,65510],w6=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],D6=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],k2=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141]});var l3=(Q,$)=>{let Y=0,q=Math.floor(Q.length/2)-1;while(Y<=q){let J=Math.floor((Y+q)/2),X=J*2;if($<Q[X])q=J-1;else if($>Q[X+1])Y=J+1;else return!0}return!1};function IM(Q){let $=Q[0],Y=Q[1];for(let q=0;q<Q.length;q+=2){let J=Q[q],X=Q[q+1];if(UH>=J&&UH<=X)return[J,X];if(X-J>Y-$)$=J,Y=X}return[$,Y]}var VM,AM,LM,FM,OT,IT,NT,TT,jM,wM,UH=19968,DM,OM,VH=(Q)=>{if(Q<VM||Q>AM)return!1;return l3(d3,Q)},AH=(Q)=>{if(Q<LM||Q>FM)return!1;return l3(p3,Q)},LH=(Q)=>{if(Q>=DM&&Q<=OM)return!0;if(Q<jM||Q>wM)return!1;return l3(k2,Q)};var FH=A(()=>{MH();VM=d3[0],AM=d3.at(-1),LM=p3[0],FM=p3.at(-1),OT=w6[0],IT=w6.at(-1),NT=D6[0],TT=D6.at(-1),jM=k2[0],wM=k2.at(-1),[DM,OM]=IM(k2)});function NM(Q){if(!Number.isSafeInteger(Q))throw TypeError(`Expected a code point, got \`${typeof Q}\`.`)}function O6(Q,{ambiguousAsWide:$=!1}={}){if(NM(Q),AH(Q)||LH(Q)||$&&VH(Q))return 2;return 1}var jH=A(()=>{FH()});function vM(Q){if(Q.length>50)return!1;if(EM.test(Q))return!0;if(Q.includes("\u200D")){let $=Q.match(kM);return $!==null&&$.length>=2}return!1}function PM(Q){return Q.replace(RM,"")}function xM(Q){return bM.test(Q)}function CM(Q,$){let Y=0;if(Q.length>1){for(let q of Q.slice(1))if(q>="\uFF00"&&q<="\uFFEF")Y+=O6(q.codePointAt(0),$)}return Y}function I6(Q,$={}){if(typeof Q!=="string"||Q.length===0)return 0;let{ambiguousIsNarrow:Y=!0,countAnsiEscapeCodes:q=!1}=$,J=Q;if(!q&&(J.includes("\x1B")||J.includes("\x9B")))J=j6(J);if(J.length===0)return 0;if(/^[\u0020-\u007E]*$/.test(J))return J.length;let X=0,H={ambiguousAsWide:!Y};for(let{segment:G}of TM.segment(J)){if(xM(G))continue;if(SM.test(G)||vM(G)){X+=2;continue}let K=PM(G).codePointAt(0);X+=O6(K,H),X+=CM(G,H)}return X}var TM,bM,RM,SM,EM,kM;var wH=A(()=>{ZH();jH();TM=new Intl.Segmenter,bM=/^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Mark}|\p{Surrogate})+$/v,RM=/^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Mark}\p{Surrogate}]+/v,SM=/^\p{RGI_Emoji}$/v,EM=/^[\d#*]\u20E3$/,kM=/\p{Extended_Pictographic}/gu});function N6({stream:Q=process.stdout}={}){return Boolean(Q&&Q.isTTY&&process.env.TERM!=="dumb"&&!("CI"in process.env))}import m9 from"process";class DH{#X=0;#q;#Y=!1;#Q=!1;#J=(Q)=>{if(!Q?.length)return;if((typeof Q==="string"?Q.codePointAt(0):Q[0])===yM)if(m9.listenerCount("SIGINT")>0)m9.emit("SIGINT");else m9.kill(m9.pid,"SIGINT")};start(){if(this.#X++,this.#X===1)this.#$()}stop(){if(this.#X===0)return;if(--this.#X===0)this.#H()}#$(){let{stdin:Q}=m9;if(m9.platform==="win32"||!Q?.isTTY||typeof Q.setRawMode!=="function"){this.#q=void 0;return}if(this.#q=Q,this.#Y=Q.isPaused(),this.#Q=Boolean(Q.isRaw),Q.setRawMode(!0),Q.prependListener("data",this.#J),this.#Y)Q.resume()}#H(){if(!this.#q)return;let Q=this.#q;if(Q.off("data",this.#J),Q.isTTY)Q.setRawMode?.(this.#Q);if(this.#Y)Q.pause();this.#q=void 0,this.#Y=!1,this.#Q=!1}}var yM=3,hM,T6;var OH=A(()=>{hM=new DH,T6=Object.freeze(hM)});import v2 from"process";import{stripVTControlCharacters as fM}from"util";class IH{#X=0;#q=-1;#Y=0;#Q;#J;#$;#H;#K=new Map;#B=!1;#W;#G;#_=!1;color;#z(Q){this.#B=!0;try{return Q()}finally{this.#B=!1}}#M(){if(this.isSpinning)this.render()}#j(Q,$){if(Q===void 0||Q===null)return"";if(typeof Q==="string")return Q;if(Buffer.isBuffer(Q)||ArrayBuffer.isView(Q)){let Y=typeof $==="string"&&$&&$!=="buffer"?$:"utf8";return Buffer.from(Q).toString(Y)}return String(Q)}#w(Q){if(!Q)return!1;let $=Q.at(-1);return $===`
131
131
  `||$==="\r"}#D(){if(this.#G)return;if(this.#G=setTimeout(()=>{if(this.#G=void 0,this.isSpinning)this.#M()},uM),typeof this.#G?.unref==="function")this.#G.unref()}#U(){if(this.#G)clearTimeout(this.#G),this.#G=void 0}#V(Q,$,Y,q){let J=this.#L(Y," "),H=typeof $==="string"?(Q?" ":"")+$:"",G=this.#F(q," ");return J+Q+H+G}constructor(Q){if(typeof Q==="string")Q={text:Q};if(this.#Q={color:"cyan",stream:v2.stderr,discardStdin:!0,hideCursor:!0,...Q},this.color=this.#Q.color,this.#$=this.#Q.stream,typeof this.#Q.isEnabled!=="boolean")this.#Q.isEnabled=N6({stream:this.#$});if(typeof this.#Q.isSilent!=="boolean")this.#Q.isSilent=!1;let $=this.#Q.interval;if(this.spinner=this.#Q.spinner,this.#Q.interval=$,this.text=this.#Q.text,this.prefixText=this.#Q.prefixText,this.suffixText=this.#Q.suffixText,this.indent=this.#Q.indent,v2.env.NODE_ENV==="test")this._stream=this.#$,this._isEnabled=this.#Q.isEnabled,Object.defineProperty(this,"_linesToClear",{get(){return this.#X},set(Y){this.#X=Y}}),Object.defineProperty(this,"_frameIndex",{get(){return this.#q}}),Object.defineProperty(this,"_lineCount",{get(){let Y=this.#$.columns??80,q=typeof this.#Q.prefixText==="function"?"":this.#Q.prefixText,J=typeof this.#Q.suffixText==="function"?"":this.#Q.suffixText,X=typeof q==="string"&&q!==""?q+" ":"",H=typeof J==="string"&&J!==""?" "+J:"",G="-",K=" ".repeat(this.#Q.indent)+X+"-"+(typeof this.#Q.text==="string"?" "+this.#Q.text:"")+H;return this.#Z(K,Y)}})}get indent(){return this.#Q.indent}set indent(Q=0){if(!(Q>=0&&Number.isInteger(Q)))throw Error("The `indent` option must be an integer from 0 and up");this.#Q.indent=Q}get interval(){return this.#Q.interval??this.#J.interval??100}get spinner(){return this.#J}set spinner(Q){if(this.#q=-1,this.#Q.interval=void 0,typeof Q==="object"){if(!Array.isArray(Q.frames)||Q.frames.length===0||Q.frames.some(($)=>typeof $!=="string"))throw Error("The given spinner must have a non-empty `frames` array of strings");if(Q.interval!==void 0&&!(Number.isInteger(Q.interval)&&Q.interval>0))throw Error("`spinner.interval` must be a positive integer if provided");this.#J=Q}else if(!E2())this.#J=S2.line;else if(Q===void 0)this.#J=S2.dots;else if(Q!=="default"&&S2[Q])this.#J=S2[Q];else throw Error(`There is no built-in spinner named '${Q}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`)}get text(){return this.#Q.text}set text(Q=""){this.#Q.text=Q}get prefixText(){return this.#Q.prefixText}set prefixText(Q=""){this.#Q.prefixText=Q}get suffixText(){return this.#Q.suffixText}set suffixText(Q=""){this.#Q.suffixText=Q}get isSpinning(){return this.#H!==void 0}#A(Q,$,Y=!1){let q=typeof Q==="function"?Q():Q;if(typeof q==="string"&&q!=="")return Y?$+q:q+$;return""}#L(Q=this.#Q.prefixText,$=" "){return this.#A(Q,$,!1)}#F(Q=this.#Q.suffixText,$=" "){return this.#A(Q,$,!0)}#Z(Q,$){let Y=0;for(let q of fM(Q).split(`
132
132
  `))Y+=Math.max(1,Math.ceil(I6(q)/$));return Y}get isEnabled(){return this.#Q.isEnabled&&!this.#Q.isSilent}set isEnabled(Q){if(typeof Q!=="boolean")throw TypeError("The `isEnabled` option must be a boolean");this.#Q.isEnabled=Q}get isSilent(){return this.#Q.isSilent}set isSilent(Q){if(typeof Q!=="boolean")throw TypeError("The `isSilent` option must be a boolean");this.#Q.isSilent=Q}frame(){let Q=Date.now();if(this.#q===-1||Q-this.#Y>=this.interval)this.#q=(this.#q+1)%this.#J.frames.length,this.#Y=Q;let{frames:$}=this.#J,Y=$[this.#q];if(this.color)Y=mX[this.color](Y);let q=this.#L(this.#Q.prefixText," "),J=typeof this.text==="string"?" "+this.text:"",X=this.#F(this.#Q.suffixText," ");return q+Y+J+X}clear(){if(!this.isEnabled||!this.#$.isTTY)return this;return this.#z(()=>{this.#$.cursorTo(0);for(let Q=0;Q<this.#X;Q++){if(Q>0)this.#$.moveCursor(0,-1);this.#$.clearLine(1)}if(this.#Q.indent)this.#$.cursorTo(this.#Q.indent)}),this.#X=0,this}#O(Q){if(!Q||this.#K.has(Q)||!Q.isTTY||typeof Q.write!=="function")return;if(i3.has(Q))console.warn("[ora] Multiple concurrent spinners detected. This may cause visual corruption. Use one spinner at a time.");let $=Q.write;this.#K.set(Q,$),i3.set(Q,this),Q.write=(Y,q,J)=>this.#T(Q,$,Y,q,J)}#I(){if(!this.isEnabled||this.#K.size>0)return;let Q=new Set([this.#$,v2.stdout,v2.stderr]);for(let $ of Q)this.#O($)}#N(){for(let[Q,$]of this.#K)if(Q.write=$,i3.get(Q)===this)i3.delete(Q);this.#K.clear()}#T(Q,$,Y,q,J){if(typeof q==="function")J=q,q=void 0;if(this.#B)return $.call(Q,Y,q,J);this.clear();let X=this.#j(Y,q),H=this.#w(X),G=$.call(Q,Y,q,J);if(H)this.#U();else if(X.length>0)this.#D();if(this.isSpinning&&!this.#G)this.render();return G}render(){if(!this.isEnabled||this.#W||this.#G)return this;let Q=this.#$.isTTY,$=!1;try{if(Q)this.#z(()=>this.#$.write(mM)),$=!0;this.clear();let Y=this.frame(),q=this.#$.columns??80,J=this.#Z(Y,q),X=this.#$.rows;if(X&&X>1&&J>X){let G=Y.split(`
133
133
  `),K=X-1;Y=[...G.slice(0,K),"... (content truncated to fit terminal)"].join(`
@@ -143,40 +143,40 @@ ${P.yellow().bold("\u26A0 WARN")} ${P.yellow("Version compatibility notice")}
143
143
  consider updating: ${P.dim(q)}
144
144
 
145
145
  To silence: ${P.dim("--skip-compat-check")} or set ${P.dim('"skipCompatCheck": true')} in ocx.jsonc
146
- `}function RH(Q){let{registry:$,ocxVersion:Y,opencodeVersion:q}=Q,J=[],X=bH($.ocx,Y,"ocx");if(!X.compatible)J.push(X);if(q){let H=bH($.opencode,q,"opencode");if(!H.compatible)J.push(H)}return J}function SH(Q,$){for(let Y of $)_.log(dM(Q,Y))}var EH=A(()=>{W8();c1()});import{randomUUID as kH}from"crypto";import{existsSync as v0}from"fs";import{lstat as pM,mkdir as E6,rename as R6,rm as g9,stat as CH,writeFile as lM}from"fs/promises";import{dirname as n3,isAbsolute as iM,join as X0,relative as nM,resolve as vH}from"path";function oM(Q,$){if(!Q?.installed)return null;for(let[Y,q]of Object.entries(Q.installed))if(q.files?.some((J)=>J.path===$))return Y;return null}function PH(Q){let $=Q.split("::")[1];if(!$)return Q;return $.split("@")[0]||Q}function sM(Q){if(!Q?.trim())throw new L("Component name cannot be empty");let $=Q.trim();if(OX($)){let Y=DX($);return{type:"npm",name:Y.name,version:Y.version}}if($.includes("/")){let{namespace:Y,component:q}=m0($);return{type:"registry",namespace:Y,component:q}}return{type:"registry",namespace:"",component:$}}function yH(Q){let $=Q.command("add").description(`Add components or npm plugins to your project.
146
+ `}function RH(Q){let{registry:$,ocxVersion:Y,opencodeVersion:q}=Q,J=[],X=bH($.ocx,Y,"ocx");if(!X.compatible)J.push(X);if(q){let H=bH($.opencode,q,"opencode");if(!H.compatible)J.push(H)}return J}function SH(Q,$){for(let Y of $)_.log(dM(Q,Y))}var EH=A(()=>{W8();c1()});import{randomUUID as kH}from"crypto";import{existsSync as P0}from"fs";import{lstat as pM,mkdir as E6,rename as R6,rm as g9,stat as CH,writeFile as lM}from"fs/promises";import{dirname as n3,isAbsolute as iM,join as X0,relative as nM,resolve as vH}from"path";function oM(Q,$){if(!Q?.installed)return null;for(let[Y,q]of Object.entries(Q.installed))if(q.files?.some((J)=>J.path===$))return Y;return null}function PH(Q){let $=Q.split("::")[1];if(!$)return Q;return $.split("@")[0]||Q}function sM(Q){if(!Q?.trim())throw new L("Component name cannot be empty");let $=Q.trim();if(OX($)){let Y=DX($);return{type:"npm",name:Y.name,version:Y.version}}if($.includes("/")){let{namespace:Y,component:q}=g0($);return{type:"registry",namespace:Y,component:q}}return{type:"registry",namespace:"",component:$}}function yH(Q){let $=Q.command("add").description(`Add components or npm plugins to your project.
147
147
 
148
148
  Registry components: ocx add alias/component
149
- npm plugins: ocx add npm:package-name[@version]`).argument("<components...>","Components to install (alias/component or npm:package[@version])").option("--dry-run","Show what would be installed without making changes").option("--skip-compat-check","Skip version compatibility checks").option("--trust","Skip npm plugin validation (for packages that don't follow conventions)").option("-p, --profile <name>","Use specific profile").option("--from <url>","Use ephemeral registry (does not persist)");Q0($),E0($),Q8($),$.action(async(Y,q)=>{try{let J=q.json?{...q,quiet:!0,verbose:!1}:q,X;if(J.profile){let H=await e0.create(J.cwd??process.cwd(),{profile:J.profile});X={cwd:f1(J.profile),getRegistries:()=>H.getRegistries(),getComponentPath:()=>H.getComponentPath()}}else if(J.global)X=await E9.requireInitialized();else X=await b0.requireInitialized(J.cwd??process.cwd());await k6(Y,J,X)}catch(J){s(J,{json:q.json})}})}async function k6(Q,$,Y){let q=Y.cwd,J=Q.map(sM),X=J.filter((B)=>B.type==="npm"),H=J.filter((B)=>B.type==="registry"),G=Boolean($.json&&X.length>0&&H.length>0),K=G?{...$,json:!1,quiet:!0,verbose:!1}:$,W,z;if(X.length>0)W=await rM(X,K,q,!G);if(H.length>0){let B=H.map((Z)=>Z.namespace?`${Z.namespace}/${Z.component}`:Z.component);z=await aM(B,K,Y,!G)}if(G)F1({success:!0,plugins:W?.plugins??[],installed:z?.installed??[],opencode:z?.opencode??!1,dryRun:Boolean(W?.dryRun||z?.dryRun)})}async function rM(Q,$,Y,q=!0){let J=$.quiet?null:M1({text:"Validating npm packages..."});J?.start();try{let X=[];for(let M of Q)if(await J6(M.name),!$.trust)try{let V=await v3(M.name,M.version),U=IX(V);X.push(...U.warnings)}catch(V){if(V instanceof L)throw J?.fail("Plugin validation failed"),new L(`${V.message}
149
+ npm plugins: ocx add npm:package-name[@version]`).argument("<components...>","Components to install (alias/component or npm:package[@version])").option("--dry-run","Show what would be installed without making changes").option("--skip-compat-check","Skip version compatibility checks").option("--trust","Skip npm plugin validation (for packages that don't follow conventions)").option("-p, --profile <name>","Use specific profile").option("--from <url>","Use ephemeral registry (does not persist)");Q0($),B0($),Q8($),$.action(async(Y,q)=>{try{let J=q.json?{...q,quiet:!0,verbose:!1}:q,X;if(J.profile){let H=await e0.create(J.cwd??process.cwd(),{profile:J.profile});X={cwd:f1(J.profile),getRegistries:()=>H.getRegistries(),getComponentPath:()=>H.getComponentPath()}}else if(J.global)X=await E9.requireInitialized();else X=await R0.requireInitialized(J.cwd??process.cwd());await k6(Y,J,X)}catch(J){s(J,{json:q.json})}})}async function k6(Q,$,Y){let q=Y.cwd,J=Q.map(sM),X=J.filter((B)=>B.type==="npm"),H=J.filter((B)=>B.type==="registry"),G=Boolean($.json&&X.length>0&&H.length>0),K=G?{...$,json:!1,quiet:!0,verbose:!1}:$,W,z;if(X.length>0)W=await rM(X,K,q,!G);if(H.length>0){let B=H.map((Z)=>Z.namespace?`${Z.namespace}/${Z.component}`:Z.component);z=await aM(B,K,Y,!G)}if(G)F1({success:!0,plugins:W?.plugins??[],installed:z?.installed??[],opencode:z?.opencode??!1,dryRun:Boolean(W?.dryRun||z?.dryRun)})}async function rM(Q,$,Y,q=!0){let J=$.quiet?null:M1({text:"Validating npm packages..."});J?.start();try{let X=[];for(let M of Q)if(await J6(M.name),!$.trust)try{let V=await v3(M.name,M.version),U=IX(V);X.push(...U.warnings)}catch(V){if(V instanceof L)throw J?.fail("Plugin validation failed"),new L(`${V.message}
150
150
  hint OpenCode plugins must be ESM modules with an entry point
151
151
  hint Use \`--trust\` to add anyway`);throw V}if(J?.succeed(`Validated ${Q.length} npm package(s)`),X.length>0&&!$.quiet){_.info("");for(let M of X)_.warn(M)}let G=(await e4(Y))?.config.plugin??[],K=new Map;for(let M of G){let V=NX(M);K.set(V,M)}let W=[],z=[];for(let M of Q)if(K.get(M.name))z.push(M.name);else W.push(C9(M.name,M.version));if(z.length>0)throw new n1(`Plugin(s) already exist in opencode.json: ${z.join(", ")}.
152
- Remove the existing entry manually or use 'ocx update' if it's an installed component.`);let B=[...K.values(),...W];if($.dryRun){let V={dryRun:!0,command:"add",wouldPerform:Q.map((U)=>({action:"add",target:C9(U.name,U.version),details:{type:"npm plugin"}})),validation:{passed:!0},summary:`Would add ${Q.length} npm plugin(s)`};if(q||!$.json)j0(V,{json:$.json,quiet:$.quiet});return{plugins:Q.map((U)=>C9(U.name,U.version)),dryRun:!0}}if(await Q6(Y,{plugin:B}),!$.quiet){_.info(""),_.success(`Added ${Q.length} npm plugin(s) to opencode.json`);for(let M of Q)_.info(` \u2713 ${C9(M.name,M.version)}`)}let Z=Q.map((M)=>C9(M.name,M.version));if($.json&&q)F1({success:!0,plugins:Z});return{plugins:Z,dryRun:!1}}catch(X){throw J?.fail("Failed to add npm plugins"),X}}async function aM(Q,$,Y,q=!0){let J=Boolean($.quiet||$.json),X=Y.cwd,H=!!($.global||$.profile),G=Y.getRegistries(),K=G;if($.from){let V=$.from.trim();if(!V)throw new L("--from URL cannot be empty");try{new URL(V)}catch{throw new L(`Invalid --from URL: ${V}`)}let U=new Set;for(let I of Q){let{namespace:c}=m0(I);U.add(c)}if(U.size>1){let I=Array.from(U).join(", ");throw new L(`Mixed registry prefixes in --from call: ${I}.
153
- When using --from, all components must use the same prefix.`)}let R=Array.from(U)[0];if(!R)throw new L("No valid component references provided");await P8(V),K={...G,[R]:{url:V}}}let W={version:1,root:X,installed:{}},z=await A0(X);if(z)W=z;let B=J?null:M1({text:"Resolving dependencies..."});B?.start();let Z=null,M=null;try{let V=new Set;for(let S of Q){let{namespace:u}=m0(S);V.add(u)}for(let S of V){let u=K[S];if(u)await P8(u.url)}let U=await GX(K,Q);if($.verbose){_.info("Install order:");for(let S of U.installOrder)_.info(` - ${S}`)}let R=new Map,I=new Map;for(let S of U.components)if(!I.has(S.registryName))I.set(S.registryName,S.baseUrl);for(let[S,u]of I){let E=await P8(u);R.set(S,E)}if(B?.succeed(`Resolved ${U.components.length} components from ${R.size} registries`),!$.skipCompatCheck&&!J)for(let[S,u]of R){let E=RH({registry:{opencode:u.opencode,ocx:u.ocx},ocxVersion:Iq});SH(S,E)}if($.dryRun){let S=U.components.map((E)=>({action:"add",target:`${E.registryName}/${E.name}`,details:{type:E.type}}));if(U.npmDependencies.length>0||U.npmDevDependencies.length>0){let E=$.global||$.profile?X:X0(X,".opencode"),e=[...U.npmDependencies,...U.npmDevDependencies].map((o)=>{let D1=o.lastIndexOf("@"),$1=D1>0?o.slice(0,D1):o,H0=D1>0?o.slice(D1+1):"*";return{name:$1,from:null,to:H0}});S.push(AX(E,e))}let u={dryRun:!0,command:"add",wouldPerform:S,validation:{passed:!0},summary:`Would add ${U.components.length} component(s)`};if(q||!$.json)j0(u,{json:$.json,quiet:$.quiet});return{installed:U.installOrder,opencode:Boolean(U.opencode),dryRun:!0}}let N=J?null:M1({text:"Fetching components..."});N?.start();let x=[];for(let S of U.components){let u=[];for(let o of S.files){let D1=await a8(S.baseUrl,S.name,o.path);u.push({path:o.path,content:Buffer.from(D1)})}let E=await x3(u);for(let o of S.files){let D1=i8(o.target,H,X),$1=X0(X,D1);try{V0(X,D1)}catch(H0){if(H0 instanceof e1)throw new L(`Invalid path "${$1}": ${H0.message}`);throw H0}}let C=Object.entries(W.installed).filter(([o,D1])=>g1(D1.registryUrl)===g1(S.baseUrl)&&D1.registryName===S.registryName&&D1.name===S.name);if(C.length>0){let o=C[0];if(o){let[D1,$1]=o;if($1.hash!==E)throw N?.fail("Integrity check failed"),new m8(D1,$1.hash,E)}}let e=A2(S.baseUrl,S.registryName,S.name,`sha256:${E}`);x.push({component:S,files:u,computedHash:E,canonicalId:e})}N?.succeed(`Fetched ${U.components.length} components`);let w=new Map;for(let{component:S,files:u}of x)for(let E of u){let C=S.files.find((D1)=>D1.path===E.path);if(!C)continue;let e=i8(C.target,H,X),o=X0(X,e);Q9(w,{absolutePath:o,relativePath:e,content:E.content,source:`${S.registryName}/${S.name}:${C.path}`})}let b=[];for(let S of w.values()){if(!v0(S.absolutePath))continue;let u=await Bun.file(S.absolutePath).text(),E=S.content.toString("utf-8");if(!Y6(u,E)){let C=oM(W,S.relativePath);b.push({path:S.relativePath,owningComponent:C})}}if(b.length>0){let S=b.filter((C)=>C.owningComponent!==null),u=b.filter((C)=>C.owningComponent===null);if(!J){if(_.error(""),_.error("File conflicts detected:"),S.length>0){_.error(""),_.error("Files from installed components (use 'ocx update' or 'ocx remove'):");for(let C of S)if(C.owningComponent){let e=PH(C.owningComponent);_.error(` \u2717 ${C.path} (from ${e})`)}}if(u.length>0){_.error(""),_.error("Files not managed by OCX (resolve manually):");for(let C of u)_.error(` \u2717 ${C.path}`)}_.error("")}let E=`${b.length} file(s) have conflicts.
152
+ Remove the existing entry manually or use 'ocx update' if it's an installed component.`);let B=[...K.values(),...W];if($.dryRun){let V={dryRun:!0,command:"add",wouldPerform:Q.map((U)=>({action:"add",target:C9(U.name,U.version),details:{type:"npm plugin"}})),validation:{passed:!0},summary:`Would add ${Q.length} npm plugin(s)`};if(q||!$.json)w0(V,{json:$.json,quiet:$.quiet});return{plugins:Q.map((U)=>C9(U.name,U.version)),dryRun:!0}}if(await Q6(Y,{plugin:B}),!$.quiet){_.info(""),_.success(`Added ${Q.length} npm plugin(s) to opencode.json`);for(let M of Q)_.info(` \u2713 ${C9(M.name,M.version)}`)}let Z=Q.map((M)=>C9(M.name,M.version));if($.json&&q)F1({success:!0,plugins:Z});return{plugins:Z,dryRun:!1}}catch(X){throw J?.fail("Failed to add npm plugins"),X}}async function aM(Q,$,Y,q=!0){let J=Boolean($.quiet||$.json),X=Y.cwd,H=!!($.global||$.profile),G=Y.getRegistries(),K=G;if($.from){let V=$.from.trim();if(!V)throw new L("--from URL cannot be empty");try{new URL(V)}catch{throw new L(`Invalid --from URL: ${V}`)}let U=new Set;for(let N of Q){let{namespace:c}=g0(N);U.add(c)}if(U.size>1){let N=Array.from(U).join(", ");throw new L(`Mixed registry prefixes in --from call: ${N}.
153
+ When using --from, all components must use the same prefix.`)}let R=Array.from(U)[0];if(!R)throw new L("No valid component references provided");await P8(V),K={...G,[R]:{url:V}}}let W={version:1,root:X,installed:{}},z=await L0(X);if(z)W=z;let B=J?null:M1({text:"Resolving dependencies..."});B?.start();let Z=null,M=null;try{let V=new Set;for(let S of Q){let{namespace:g}=g0(S);V.add(g)}for(let S of V){let g=K[S];if(g)await P8(g.url)}let U=await GX(K,Q);if($.verbose){_.info("Install order:");for(let S of U.installOrder)_.info(` - ${S}`)}let R=new Map,N=new Map;for(let S of U.components)if(!N.has(S.registryName))N.set(S.registryName,S.baseUrl);for(let[S,g]of N){let E=await P8(g);R.set(S,E)}if(B?.succeed(`Resolved ${U.components.length} components from ${R.size} registries`),!$.skipCompatCheck&&!J)for(let[S,g]of R){let E=RH({registry:{opencode:g.opencode,ocx:g.ocx},ocxVersion:Iq});SH(S,E)}if($.dryRun){let S=U.components.map((E)=>({action:"add",target:`${E.registryName}/${E.name}`,details:{type:E.type}}));if(U.npmDependencies.length>0||U.npmDevDependencies.length>0){let E=$.global||$.profile?X:X0(X,".opencode"),e=[...U.npmDependencies,...U.npmDevDependencies].map((o)=>{let D1=o.lastIndexOf("@"),$1=D1>0?o.slice(0,D1):o,H0=D1>0?o.slice(D1+1):"*";return{name:$1,from:null,to:H0}});S.push(AX(E,e))}let g={dryRun:!0,command:"add",wouldPerform:S,validation:{passed:!0},summary:`Would add ${U.components.length} component(s)`};if(q||!$.json)w0(g,{json:$.json,quiet:$.quiet});return{installed:U.installOrder,opencode:Boolean(U.opencode),dryRun:!0}}let T=J?null:M1({text:"Fetching components..."});T?.start();let x=[];for(let S of U.components){let g=[];for(let o of S.files){let D1=await a8(S.baseUrl,S.name,o.path);g.push({path:o.path,content:Buffer.from(D1)})}let E=await x3(g);for(let o of S.files){let D1=i8(o.target,H,X),$1=X0(X,D1);try{A0(X,D1)}catch(H0){if(H0 instanceof e1)throw new L(`Invalid path "${$1}": ${H0.message}`);throw H0}}let C=Object.entries(W.installed).filter(([o,D1])=>g1(D1.registryUrl)===g1(S.baseUrl)&&D1.registryName===S.registryName&&D1.name===S.name);if(C.length>0){let o=C[0];if(o){let[D1,$1]=o;if($1.hash!==E)throw T?.fail("Integrity check failed"),new m8(D1,$1.hash,E)}}let e=A2(S.baseUrl,S.registryName,S.name,`sha256:${E}`);x.push({component:S,files:g,computedHash:E,canonicalId:e})}T?.succeed(`Fetched ${U.components.length} components`);let O=new Map;for(let{component:S,files:g}of x)for(let E of g){let C=S.files.find((D1)=>D1.path===E.path);if(!C)continue;let e=i8(C.target,H,X),o=X0(X,e);Q9(O,{absolutePath:o,relativePath:e,content:E.content,source:`${S.registryName}/${S.name}:${C.path}`})}let I=[];for(let S of O.values()){if(!P0(S.absolutePath))continue;let g=await Bun.file(S.absolutePath).text(),E=S.content.toString("utf-8");if(!Y6(g,E)){let C=oM(W,S.relativePath);I.push({path:S.relativePath,owningComponent:C})}}if(I.length>0){let S=I.filter((C)=>C.owningComponent!==null),g=I.filter((C)=>C.owningComponent===null);if(!J){if(_.error(""),_.error("File conflicts detected:"),S.length>0){_.error(""),_.error("Files from installed components (use 'ocx update' or 'ocx remove'):");for(let C of S)if(C.owningComponent){let e=PH(C.owningComponent);_.error(` \u2717 ${C.path} (from ${e})`)}}if(g.length>0){_.error(""),_.error("Files not managed by OCX (resolve manually):");for(let C of g)_.error(` \u2717 ${C.path}`)}_.error("")}let E=`${I.length} file(s) have conflicts.
154
154
  `;if(S.length>0){let C=new Set(S.filter((e)=>e.owningComponent!==null).map((e)=>PH(e.owningComponent)));E+=`For OCX-managed files, use 'ocx update ${Array.from(C).join(" ")}' or 'ocx remove ${Array.from(C).join(" ")}'.
155
- `}if(u.length>0)E+="For unmanaged files, resolve conflicts manually by renaming or removing them.";throw new n1(E.trim())}let D=J?null:M1({text:"Installing components..."});D?.start(),M=await YU({cwd:X,isFlattened:H,trackOpencodeConfig:Boolean(U.opencode&&Object.keys(U.opencode).length>0),trackNpmManifests:U.npmDependencies.length>0||U.npmDevDependencies.length>0,quiet:$.quiet});let l=qU({quiet:$.quiet});Z=l;for(let{component:S,files:u,computedHash:E,canonicalId:C}of x){let e=await JU(S,u,X,H,l,{verbose:$.verbose});if($.verbose){for(let $1 of e.skipped)_.info(` \u25CB Skipped ${$1} (unchanged)`);for(let $1 of e.overwritten)_.info(` \u2713 Overwrote ${$1}`);for(let $1 of e.written)_.info(` \u2713 Wrote ${$1}`)}if(!R.get(S.registryName))throw new L(`Registry index not found for "${S.registryName}". This is an internal error - please report it at https://github.com/${Oq}/issues`);let D1=[];for(let $1 of u){let H0=S.files.find((W9)=>W9.path===$1.path);if(!H0)throw Error(`File ${$1.path} not found in component manifest`);let A7=i8(H0.target,H,X);D1.push({path:A7,hash:$9($1.content)})}W.installed[C]={registryUrl:S.baseUrl,registryName:S.registryName,name:S.name,revision:`sha256:${E}`,hash:E,files:D1,installedAt:new Date().toISOString(),...S.opencode&&{opencode:S.opencode}}}if(D?.succeed(`Installed ${U.components.length} components`),U.opencode&&Object.keys(U.opencode).length>0){let S=await Q6(X,U.opencode);if(!$.quiet&&S.changed)if(S.created)_.info(`Created ${S.path}`);else _.info(`Updated ${S.path}`)}let i=U.npmDependencies.length>0,r=U.npmDevDependencies.length>0,J1=$.global||$.profile?X0(X,"package.json"):X0(X,".opencode/package.json");if(i||r){let S=J?null:M1({text:`Updating ${J1}...`});S?.start();try{let u=!!($.global||$.profile),E=await zU(X,U.npmDependencies,U.npmDevDependencies,{isFlattened:u}),C=U.npmDependencies.length+U.npmDevDependencies.length;if(S?.succeed(`Added ${C} dependencies to ${J1}`),E.changed){let e=await LX(E.packageDir);if(e.success&&e.action!=="none"){if(!J)_.info(`Invalidated ${X0(E.packageDir,"node_modules")} to force reinstall`)}else if(!e.success){let o=X0(E.packageDir,"node_modules");_.warn(`Could not invalidate ${o}: ${e.error?.message??"unknown error"}. Run \`rm -rf "${o}"\` manually to force reinstall.`)}}}catch(u){throw S?.fail(`Failed to update ${J1}`),u}}if(await N0(X,W),!Z)throw Error("Internal error: missing add write transaction after install phase.");if(await Z.commit(),Z=null,M?.commit(),M=null,$.json&&q)F1({success:!0,installed:U.installOrder,opencode:!!U.opencode});else if(!$.quiet)_.info(""),_.success(`Done! Installed ${U.components.length} components.`);return{installed:U.installOrder,opencode:!!U.opencode,dryRun:!1}}catch(V){if(Z)await Z.rollback(),Z=null;if(M)await M.rollback(),M=null;if(B&&!B.isSpinning);else B?.fail("Failed to add components");throw V}}function S6(Q,$,Y){let q=Y instanceof Error?Y.message:String(Y);return`${Q} "${$}" (${q})`}function tM(Q,$){let Y=nM($,Q);return Y!==""&&!Y.startsWith("..")&&!iM(Y)}async function eM(Q,$){let Y=vH(Q),q=vH($);while(tM(Y,q)){let J=!0;try{if(!(await pM(Y)).isDirectory())break}catch(H){if(H.code==="ENOENT")J=!1;else throw H}try{if(J)await g9(Y,{recursive:!1})}catch(H){let G=H.code;if(G==="ENOENT");else if(G==="ENOTEMPTY"||G==="EEXIST"||G==="EBUSY")break;else if(G==="ENOTDIR")break;else throw H}let X=n3(Y);if(X===Y)break;Y=X}}async function QU(Q){let $;try{$=await CH(Q)}catch(Y){let q=Y.code;if(q==="ENOENT"||q==="ENOTDIR")return{path:Q,state:"missing",content:""};throw Y}if(!$.isFile())return{path:Q,state:"non-file",content:""};return{path:Q,state:"file",content:await Bun.file(Q).text()}}async function $U(Q,$){if(Q.state==="file"){await E6(n3(Q.path),{recursive:!0}),await Bun.write(Q.path,Q.content);return}if(Q.state==="non-file")return;if(v0(Q.path))await g9(Q.path,{force:!0,recursive:!0});await eM(n3(Q.path),$)}async function YU(Q){let $=[],Y=new Set,q=!1,J=async(G)=>{if(Y.has(G))return;Y.add(G),$.push(await QU(G))};if(Q.trackOpencodeConfig){let G=k3(Q.cwd).path;await J(G)}if(Q.trackNpmManifests){let G=Q.isFlattened?Q.cwd:X0(Q.cwd,".opencode");if(await J(X0(G,"package.json")),!Q.isFlattened)await J(X0(G,".gitignore"))}return await J(S8(Q.cwd).path),{rollback:async()=>{if(q)return;q=!0;let G=[];for(let K of[...$].reverse())try{await $U(K,Q.cwd)}catch(W){G.push(S6("Add rollback cleanup warning: failed to restore",K.path,W))}if(!Q.quiet)for(let K of G)_.warn(K)},commit:()=>{q=!0}}}function qU(Q){let $=[],Y=new Set,q=!1;return{writeFileAtomically:async({targetPath:G,resolvedTarget:K,content:W})=>{let z=n3(G);if(!v0(z))await E6(z,{recursive:!0});if(v0(G)){if((await CH(G)).isDirectory())throw new L(`Cannot install "${K}": target path is a directory.`)}let B=`${G}.ocx-add-tmp-${kH()}`;await lM(B,W),Y.add(B);let Z=null;if(v0(G))Z=`${G}.ocx-add-backup-${kH()}`,await R6(G,Z),$.push({targetPath:G,backupPath:Z});if(await R6(B,G),Y.delete(B),!Z)$.push({targetPath:G,backupPath:null})},rollback:async()=>{if(q)return;q=!0;let G=[];for(let K of Y)try{await g9(K,{force:!0})}catch(W){G.push(S6("Add rollback cleanup warning: failed to remove temp file",K,W))}for(let K of[...$].reverse())try{if(K.backupPath){if(v0(K.targetPath))await g9(K.targetPath,{force:!0,recursive:!0});if(v0(K.backupPath))await R6(K.backupPath,K.targetPath)}else if(v0(K.targetPath))await g9(K.targetPath,{force:!0,recursive:!0})}catch(W){G.push(S6("Add rollback cleanup warning: failed to restore target",K.targetPath,W))}if(!Q.quiet)for(let K of G)_.warn(K)},commit:async()=>{if(q)return;q=!0;for(let G of $){if(!G.backupPath||!v0(G.backupPath))continue;try{await g9(G.backupPath,{force:!0})}catch(K){if(!Q.quiet){let W=K instanceof Error?K.message:String(K);_.warn(`Post-add cleanup warning: failed to remove backup "${G.backupPath}" (${W})`)}}}}}}async function JU(Q,$,Y,q,J,X){let H={written:[],skipped:[],overwritten:[]};for(let G of $){let K=Q.files.find((B)=>B.path===G.path);if(!K)continue;let W=i8(K.target,q,Y),z=X0(Y,W);if(v0(z)){let B=await Bun.file(z).text(),Z=G.content.toString("utf-8");if(Y6(B,Z)){H.skipped.push(W);continue}H.overwritten.push(W)}else H.written.push(W);await J.writeFileAtomically({targetPath:z,resolvedTarget:W,content:G.content})}return H}function xH(Q){if(!Q?.trim())throw new L(`Invalid npm dependency: expected non-empty string, got "${Q}"`);let $=Q.trim(),Y=$.lastIndexOf("@");if(Y>0){let q=$.slice(0,Y),J=$.slice(Y+1);if(!J)throw new L(`Invalid npm dependency: missing version after @ in "${Q}"`);return{name:q,version:J}}return{name:$,version:"*"}}function HU(Q,$){let Y={...Q.dependencies};for(let q of $)Y[q.name]=q.version;return{...Q,dependencies:Y}}function GU(Q,$){let Y={...Q.devDependencies};for(let q of $)Y[q.name]=q.version;return{...Q,devDependencies:Y}}async function KU(Q){let $=X0(Q,"package.json");if(!v0($))return{...XU};try{let Y=await Bun.file($).text();return JSON.parse(Y)}catch(Y){let q=Y instanceof Error?Y.message:String(Y);throw new h(`Invalid ${$}: ${q}`)}}async function WU(Q){let $=X0(Q,".gitignore"),Y=new Set(["package.json","bun.lock"]),q=["node_modules"],J=[];if(v0($))J=(await Bun.file($).text()).split(`
155
+ `}if(g.length>0)E+="For unmanaged files, resolve conflicts manually by renaming or removing them.";throw new n1(E.trim())}let w=J?null:M1({text:"Installing components..."});w?.start(),M=await YU({cwd:X,isFlattened:H,trackOpencodeConfig:Boolean(U.opencode&&Object.keys(U.opencode).length>0),trackNpmManifests:U.npmDependencies.length>0||U.npmDevDependencies.length>0,quiet:$.quiet});let i=qU({quiet:$.quiet});Z=i;for(let{component:S,files:g,computedHash:E,canonicalId:C}of x){let e=await JU(S,g,X,H,i,{verbose:$.verbose});if($.verbose){for(let $1 of e.skipped)_.info(` \u25CB Skipped ${$1} (unchanged)`);for(let $1 of e.overwritten)_.info(` \u2713 Overwrote ${$1}`);for(let $1 of e.written)_.info(` \u2713 Wrote ${$1}`)}if(!R.get(S.registryName))throw new L(`Registry index not found for "${S.registryName}". This is an internal error - please report it at https://github.com/${Oq}/issues`);let D1=[];for(let $1 of g){let H0=S.files.find((W9)=>W9.path===$1.path);if(!H0)throw Error(`File ${$1.path} not found in component manifest`);let A7=i8(H0.target,H,X);D1.push({path:A7,hash:$9($1.content)})}W.installed[C]={registryUrl:S.baseUrl,registryName:S.registryName,name:S.name,revision:`sha256:${E}`,hash:E,files:D1,installedAt:new Date().toISOString(),...S.opencode&&{opencode:S.opencode}}}if(w?.succeed(`Installed ${U.components.length} components`),U.opencode&&Object.keys(U.opencode).length>0){let S=await Q6(X,U.opencode);if(!$.quiet&&S.changed)if(S.created)_.info(`Created ${S.path}`);else _.info(`Updated ${S.path}`)}let l=U.npmDependencies.length>0,r=U.npmDevDependencies.length>0,J1=$.global||$.profile?X0(X,"package.json"):X0(X,".opencode/package.json");if(l||r){let S=J?null:M1({text:`Updating ${J1}...`});S?.start();try{let g=!!($.global||$.profile),E=await zU(X,U.npmDependencies,U.npmDevDependencies,{isFlattened:g}),C=U.npmDependencies.length+U.npmDevDependencies.length;if(S?.succeed(`Added ${C} dependencies to ${J1}`),E.changed){let e=await LX(E.packageDir);if(e.success&&e.action!=="none"){if(!J)_.info(`Invalidated ${X0(E.packageDir,"node_modules")} to force reinstall`)}else if(!e.success){let o=X0(E.packageDir,"node_modules");_.warn(`Could not invalidate ${o}: ${e.error?.message??"unknown error"}. Run \`rm -rf "${o}"\` manually to force reinstall.`)}}}catch(g){throw S?.fail(`Failed to update ${J1}`),g}}if(await T0(X,W),!Z)throw Error("Internal error: missing add write transaction after install phase.");if(await Z.commit(),Z=null,M?.commit(),M=null,$.json&&q)F1({success:!0,installed:U.installOrder,opencode:!!U.opencode});else if(!$.quiet)_.info(""),_.success(`Done! Installed ${U.components.length} components.`);return{installed:U.installOrder,opencode:!!U.opencode,dryRun:!1}}catch(V){if(Z)await Z.rollback(),Z=null;if(M)await M.rollback(),M=null;if(B&&!B.isSpinning);else B?.fail("Failed to add components");throw V}}function S6(Q,$,Y){let q=Y instanceof Error?Y.message:String(Y);return`${Q} "${$}" (${q})`}function tM(Q,$){let Y=nM($,Q);return Y!==""&&!Y.startsWith("..")&&!iM(Y)}async function eM(Q,$){let Y=vH(Q),q=vH($);while(tM(Y,q)){let J=!0;try{if(!(await pM(Y)).isDirectory())break}catch(H){if(H.code==="ENOENT")J=!1;else throw H}try{if(J)await g9(Y,{recursive:!1})}catch(H){let G=H.code;if(G==="ENOENT");else if(G==="ENOTEMPTY"||G==="EEXIST"||G==="EBUSY")break;else if(G==="ENOTDIR")break;else throw H}let X=n3(Y);if(X===Y)break;Y=X}}async function QU(Q){let $;try{$=await CH(Q)}catch(Y){let q=Y.code;if(q==="ENOENT"||q==="ENOTDIR")return{path:Q,state:"missing",content:""};throw Y}if(!$.isFile())return{path:Q,state:"non-file",content:""};return{path:Q,state:"file",content:await Bun.file(Q).text()}}async function $U(Q,$){if(Q.state==="file"){await E6(n3(Q.path),{recursive:!0}),await Bun.write(Q.path,Q.content);return}if(Q.state==="non-file")return;if(P0(Q.path))await g9(Q.path,{force:!0,recursive:!0});await eM(n3(Q.path),$)}async function YU(Q){let $=[],Y=new Set,q=!1,J=async(G)=>{if(Y.has(G))return;Y.add(G),$.push(await QU(G))};if(Q.trackOpencodeConfig){let G=k3(Q.cwd).path;await J(G)}if(Q.trackNpmManifests){let G=Q.isFlattened?Q.cwd:X0(Q.cwd,".opencode");if(await J(X0(G,"package.json")),!Q.isFlattened)await J(X0(G,".gitignore"))}return await J(S8(Q.cwd).path),{rollback:async()=>{if(q)return;q=!0;let G=[];for(let K of[...$].reverse())try{await $U(K,Q.cwd)}catch(W){G.push(S6("Add rollback cleanup warning: failed to restore",K.path,W))}if(!Q.quiet)for(let K of G)_.warn(K)},commit:()=>{q=!0}}}function qU(Q){let $=[],Y=new Set,q=!1;return{writeFileAtomically:async({targetPath:G,resolvedTarget:K,content:W})=>{let z=n3(G);if(!P0(z))await E6(z,{recursive:!0});if(P0(G)){if((await CH(G)).isDirectory())throw new L(`Cannot install "${K}": target path is a directory.`)}let B=`${G}.ocx-add-tmp-${kH()}`;await lM(B,W),Y.add(B);let Z=null;if(P0(G))Z=`${G}.ocx-add-backup-${kH()}`,await R6(G,Z),$.push({targetPath:G,backupPath:Z});if(await R6(B,G),Y.delete(B),!Z)$.push({targetPath:G,backupPath:null})},rollback:async()=>{if(q)return;q=!0;let G=[];for(let K of Y)try{await g9(K,{force:!0})}catch(W){G.push(S6("Add rollback cleanup warning: failed to remove temp file",K,W))}for(let K of[...$].reverse())try{if(K.backupPath){if(P0(K.targetPath))await g9(K.targetPath,{force:!0,recursive:!0});if(P0(K.backupPath))await R6(K.backupPath,K.targetPath)}else if(P0(K.targetPath))await g9(K.targetPath,{force:!0,recursive:!0})}catch(W){G.push(S6("Add rollback cleanup warning: failed to restore target",K.targetPath,W))}if(!Q.quiet)for(let K of G)_.warn(K)},commit:async()=>{if(q)return;q=!0;for(let G of $){if(!G.backupPath||!P0(G.backupPath))continue;try{await g9(G.backupPath,{force:!0})}catch(K){if(!Q.quiet){let W=K instanceof Error?K.message:String(K);_.warn(`Post-add cleanup warning: failed to remove backup "${G.backupPath}" (${W})`)}}}}}}async function JU(Q,$,Y,q,J,X){let H={written:[],skipped:[],overwritten:[]};for(let G of $){let K=Q.files.find((B)=>B.path===G.path);if(!K)continue;let W=i8(K.target,q,Y),z=X0(Y,W);if(P0(z)){let B=await Bun.file(z).text(),Z=G.content.toString("utf-8");if(Y6(B,Z)){H.skipped.push(W);continue}H.overwritten.push(W)}else H.written.push(W);await J.writeFileAtomically({targetPath:z,resolvedTarget:W,content:G.content})}return H}function xH(Q){if(!Q?.trim())throw new L(`Invalid npm dependency: expected non-empty string, got "${Q}"`);let $=Q.trim(),Y=$.lastIndexOf("@");if(Y>0){let q=$.slice(0,Y),J=$.slice(Y+1);if(!J)throw new L(`Invalid npm dependency: missing version after @ in "${Q}"`);return{name:q,version:J}}return{name:$,version:"*"}}function HU(Q,$){let Y={...Q.dependencies};for(let q of $)Y[q.name]=q.version;return{...Q,dependencies:Y}}function GU(Q,$){let Y={...Q.devDependencies};for(let q of $)Y[q.name]=q.version;return{...Q,devDependencies:Y}}async function KU(Q){let $=X0(Q,"package.json");if(!P0($))return{...XU};try{let Y=await Bun.file($).text();return JSON.parse(Y)}catch(Y){let q=Y instanceof Error?Y.message:String(Y);throw new h(`Invalid ${$}: ${q}`)}}async function WU(Q){let $=X0(Q,".gitignore"),Y=new Set(["package.json","bun.lock"]),q=["node_modules"],J=[];if(P0($))J=(await Bun.file($).text()).split(`
156
156
  `).map((H)=>H.trim()).filter(Boolean);J=J.filter((X)=>!Y.has(X));for(let X of q)if(!J.includes(X))J.push(X);await Bun.write($,`${J.join(`
157
157
  `)}
158
158
  `)}async function zU(Q,$,Y,q={}){let J=q.isFlattened?Q:X0(Q,".opencode");if($.length===0&&Y.length===0)return{changed:!1,packageDir:J,delta:[]};await E6(J,{recursive:!0});let X=$.map(xH),H=Y.map(xH),G=new Set(X.map((V)=>V.name)),K=H.filter((V)=>G.has(V.name));if(K.length>0)throw new n1(`Package(s) appear in both dependencies and devDependencies: ${K.map((V)=>V.name).join(", ")}.
159
159
  A package cannot be in both fields. Remove from one list manually before adding.`);let W=await KU(J),z={...W.dependencies,...W.devDependencies},B=W;B=HU(B,X),B=GU(B,H),await Bun.write(X0(J,"package.json"),`${JSON.stringify(B,null,2)}
160
- `);let Z={...B.dependencies,...B.devDependencies},M=VX(z,Z);if(!q.isFlattened)await WU(J);return{changed:M.changed,packageDir:J,delta:M.entries}}var XU;var v6=A(()=>{k9();O2();z3();W0();t8();KX();q0();g0();$6();FX();e8();t();y1();c1();X6();g8();k8();P3();y9();d0();l0();EH();XU={name:"opencode-plugins",private:!0,type:"module"}});import{join as BU,posix as _U}from"path";function ZU(Q){if(Q.length===0)return"Unknown parse error";let $=Q[0];if(!$)return"Unknown parse error";return`${n0($.error)} at offset ${$.offset}`}async function hH(Q){let $=Bun.file(`${Q}/registry.jsonc`),Y=Bun.file(`${Q}/registry.json`),q=await $.exists(),J=await Y.exists();if(!q&&!J)return{success:!1,error:"No registry.jsonc or registry.json found in source directory",errorKind:"not_found"};let X=q?$:Y,H=q?"registry.jsonc":"registry.json",G=await X.text(),K=[],W=O1(G,K,{allowTrailingComma:!0});if(K.length>0){let z=ZU(K);return{success:!1,error:`Invalid JSONC in ${H}: ${z}`,errorKind:"parse_error"}}return{success:!0,data:W}}function fH(Q,$){let Y=I9(Q);if(Y)return{valid:!1,errors:[`Schema compatibility issue: ${Y.issue} - ${Y.remediation}`]};return MU(Q,$)}function MU(Q,$){let Y=p8.safeParse(Q);if(!Y.success)return{valid:!1,errors:Y.error.issues.map((J)=>`${J.path.join(".")}: ${J.message}`)};return{valid:!0,errors:[],data:Y.data}}async function UU(Q,$){let Y=[];for(let q of Q.components)for(let J of q.files){let X=T8(J,q.type),H=BU($,"files",X.path);if(!await Bun.file(H).exists())Y.push(`${q.name}: Source file not found at ${X.path}`)}return{valid:Y.length===0,errors:Y}}function VU(Q){let $=[],Y=new Map(Q.components.map((X)=>[X.name,X]));function q(X,H,G,K){if(H.has(X))return[...K,X].join(" -> ");if(G.has(X))return null;let W=Y.get(X);if(!W)return null;H.add(X),K.push(X);for(let z of W.dependencies){if(z.includes("/"))continue;let B=q(z,H,G,K);if(B)return B}return H.delete(X),G.add(X),K.pop(),null}let J=new Set;for(let X of Q.components){if(J.has(X.name))continue;let H=q(X.name,new Set,J,[]);if(H){$.push(`Circular dependency detected: ${H}`);break}}return{valid:$.length===0,errors:$}}function AU(Q){let $=[],Y=new Map,q=(J)=>{let H=J.normalize("NFC").replace(/\\/g,"/");return _U.normalize(H).replace(/^\.\//,"")};for(let J of Q.components)for(let X of J.files){let H=T8(X,J.type),G=q(H.target),K=Y.get(G);if(K)$.push(`Duplicate target "${G}" in components "${K.componentName}" and "${J.name}"`);else Y.set(G,{componentName:J.name})}return{valid:$.length===0,errors:$}}async function*uH(Q,$,Y={}){let q=await UU(Q,$);for(let X of q.errors)yield X;let J=VU(Q);for(let X of J.errors)yield X;if(!Y.skipDuplicateTargets){let X=AU(Q);for(let H of X.errors)yield H}}var mH=A(()=>{D0();g0()});async function o3(Q,$={}){let Y=await hH(Q);if(!Y.success)return{success:!1,errors:[Y.error||"Failed to load registry"],failureType:"load",loadErrorKind:Y.errorKind};let q=fH(Y.data,Q);if(!q.valid)return{success:!1,errors:q.errors,failureType:"schema"};let J=q.data;if(!J)throw Error("Registry validation succeeded but returned no parsed data");let X=[];for await(let H of uH(J,Q,$))X.push(H);if(X.length>0)return{success:!1,errors:X,failureType:"rules"};return{success:!0,errors:[],registry:J}}var P6=A(()=>{mH()});function x6(Q){return{file:Q.filter(($)=>$.includes("Source file not found")),circular:Q.filter(($)=>$.includes("Circular dependency")),duplicate:Q.filter(($)=>$.includes("Duplicate target"))}}function P2(Q,$={}){let Y=x6(Q),q=$.schemaErrors??0,J=Q.length,X=Math.max(0,J-q-Y.file.length-Y.circular.length-Y.duplicate.length);return{valid:J===0,totalErrors:J,schemaErrors:q,sourceFileErrors:Y.file.length,circularDependencyErrors:Y.circular.length,duplicateTargetErrors:Y.duplicate.length,otherErrors:X}}import{relative as LU,resolve as gH}from"path";function FU(Q,$){if($==="not_found")return new _1(Q);if($==="parse_error")return new B1(Q,"CONFIG_ERROR",G1.CONFIG);return new B1(Q,"CONFIG_ERROR",G1.CONFIG)}function jU(Q,$){let Y=P2(Q,{schemaErrors:$==="schema"?Q.length:0}),q={valid:!1,errors:Q,summary:{valid:!1,totalErrors:Y.totalErrors,schemaErrors:Y.schemaErrors,sourceFileErrors:Y.sourceFileErrors,circularDependencyErrors:Y.circularDependencyErrors,duplicateTargetErrors:Y.duplicateTargetErrors,otherErrors:Y.otherErrors}};return new u8(q)}function wU(Q,$){if($==="schema"){_.error("\u2717 Registry schema");for(let q of Q)console.log(P.red(` ${q}`));return}let Y=x6(Q);if(Y.file.length>0){_.error("\u2717 Source files");for(let q of Y.file)console.log(P.red(` ${q}`))}if(Y.circular.length>0){_.error("\u2717 Circular dependencies");for(let q of Y.circular)console.log(P.red(` ${q}`))}if(Y.duplicate.length>0){_.error("\u2717 Duplicate targets");for(let q of Y.duplicate)console.log(P.red(` ${q}`))}}function cH(Q){Q.command("build").description("Build a registry from source (for registry authors)").argument("[path]","Registry source directory",".").option("--out <dir>","Output directory","./dist").option("--cwd <path>","Working directory",process.cwd()).option("--json","Output as JSON",!1).option("-q, --quiet","Suppress output",!1).option("--dry-run","Validate and show what would be built").option("--show-validation","Display validation results before building",!1).action(async($,Y)=>{try{let q=gH(Y.cwd,$),J=gH(Y.cwd,Y.out);if(Y.showValidation){let K=!Y.json&&!Y.quiet;if(K)_.info("Running validation checks...");let W=await o3(q,{skipDuplicateTargets:!1});if(!W.success){let[z="Registry validation failed"]=W.errors;if(W.failureType==="load")throw FU(z,W.loadErrorKind);let B=W.failureType==="schema"?"schema":"rules",Z=jU(W.errors,B);if(Y.json)throw Z;if(!Y.quiet)wU(W.errors,B);process.exit(Z.exitCode)}if(K)_.success("\u2713 Schema compatibility and structure"),_.success("\u2713 Source files"),_.success("\u2713 No circular dependencies"),_.success("\u2713 No duplicate targets"),console.log("")}let X=M1({text:"Building registry...",quiet:Y.quiet||Y.json});if(!Y.json)X.start();let H=await U2({source:q,out:J,dryRun:Y.dryRun});if("dryRun"in H&&H.dryRun){if(!Y.json)X.stop();j0(H,{json:Y.json,quiet:Y.quiet});return}let G=H;if(!Y.json){let K=`Built ${G.componentsCount} components to ${LU(Y.cwd,J)}`;if(X.succeed(K),!process.stdout.isTTY)_.success(`Built ${G.componentsCount} components`)}if(Y.json)F1({success:!0,data:{components:G.componentsCount,output:G.outputPath}})}catch(q){if(q instanceof r0){if(Y.json)s(q,{json:!0});if(!Y.quiet){_.error(q.message);for(let J of q.errors)console.log(P.red(` ${J}`))}process.exit(1)}s(q,{json:Y.json})}})}var dH=A(()=>{W8();_3();P6();e8();t();y1();c1();l0()});import{existsSync as pH}from"fs";import{mkdir as DU}from"fs/promises";import{join as C6}from"path";function lH(Q){Q.command("edit").description("Open configuration file in editor").option("-g, --global","Edit global ocx.jsonc").option("-p, --profile <name>","Edit specific profile's config").action(async($)=>{try{await OU($)}catch(Y){s(Y)}})}async function OU(Q){if(Q.global&&Q.profile)throw new L("Cannot use both --global and --profile flags");let $;if(Q.profile){let X=a0.safeParse(Q.profile);if(!X.success)throw new L(`Invalid profile name "${Q.profile}": ${X.error.issues[0]?.message??"Invalid name"}`);if(await u1.requireInitialized(),!await u1.create().exists(Q.profile))throw new C1(Q.profile);$=K0(Q.profile)}else if(Q.global){if($=P9(),!pH($))throw new h(`Global config not found at ${$}.
161
- Run 'ocx init --global' first.`)}else{let X=M8(process.cwd());if(X)$=C6(X,c0);else{let H=C6(process.cwd(),n8);if(await DU(H,{recursive:!0}),$=C6(H,c0),!pH($)){let G={$schema:"https://ocx.kdco.dev/schemas/ocx.json",registries:{}};await Bun.write($,JSON.stringify(G,null,2)),_.info(`Created ${$}`)}}}let Y=process.env.EDITOR||process.env.VISUAL||"vi",J=await Bun.spawn([Y,$],{stdin:"inherit",stdout:"inherit",stderr:"inherit"}).exited;if(J!==0)throw Error(`Editor exited with code ${J}`)}var iH=A(()=>{t0();W0();D3();t();y1();c1()});function nH(Q){Q.command("show").description("Display resolved configuration for current directory").addOption(S0.json()).option("--origin","Show where each setting came from").option("-p, --profile <name>","Use specific profile").action(async($)=>{try{await IU($)}catch(Y){s(Y,{json:$.json})}})}async function IU(Q){let $=await e0.create(process.cwd(),{profile:Q.profile});if(Q.origin){let q=$.resolveWithOrigin();if(Q.json){let X={};for(let[H,G]of q.origins)X[H]=G;console.log(JSON.stringify({...q,origins:X},null,2));return}if(console.log(P.bold("Resolved Configuration")),console.log(),q.profileName){let X=q.origins.get("profileName");if(console.log(`${P.cyan("Profile:")} ${q.profileName}`),X)console.log(` ${P.dim(`\u2190 ${X.source}`)}`)}console.log(),console.log(P.cyan("Component Path:"),q.componentPath);let J=q.origins.get("componentPath");if(J)console.log(` ${P.dim(`\u2190 ${J.source} (${J.path})`)}`);console.log(),console.log(P.cyan("Registries:"));for(let[X,H]of Object.entries(q.registries)){console.log(` ${P.green(X)}: ${H.url}`);let G=q.origins.get(`registries.${X}`);if(G)console.log(` ${P.dim(`\u2190 ${G.source} (${G.path})`)}`)}if(q.instructions.length>0){console.log(),console.log(P.cyan("Instructions:"));for(let X of q.instructions)console.log(` ${X}`)}if(Object.keys(q.opencode).length>0){console.log(),console.log(P.cyan("OpenCode Config:"));for(let X of Object.keys(q.opencode)){let H=q.origins.get(`opencode.${X}`);if(console.log(` ${X}:`,JSON.stringify(q.opencode[X])),H)console.log(` ${P.dim(`\u2190 ${H.source} (${H.path})`)}`)}}return}let Y=$.resolve();if(Q.json){console.log(JSON.stringify(Y,null,2));return}if(console.log(P.bold("Resolved Configuration")),console.log(),Y.profileName)console.log(`${P.cyan("Profile:")} ${Y.profileName}`);if(console.log(`${P.cyan("Component Path:")} ${Y.componentPath}`),console.log(),console.log(P.cyan("Registries:")),Object.keys(Y.registries).length===0)console.log(" (none)");else for(let[q,J]of Object.entries(Y.registries))console.log(` ${P.green(q)}: ${J.url}`);if(Y.instructions.length>0){console.log(),console.log(P.cyan("Instructions:"));for(let q of Y.instructions)console.log(` ${q}`)}}var oH=A(()=>{W8();O2();y1();d0()});function sH(Q){let $=Q.command("config").description("View and edit configuration");nH($),lH($)}var rH=A(()=>{iH();oH()});import{existsSync as J9}from"fs";import{cp as NU,mkdir as c9,readdir as aH,readFile as TU,rm as bU,writeFile as y6}from"fs/promises";import{dirname as tH,join as s3}from"path";function eH(Q){let $=Q.command("init").description("Initialize OCX configuration in your project");Q0($),E0($),Q8($),$.option("--registry <path>","Scaffold a new OCX registry project at path").option("--namespace <name>","Registry namespace (e.g., my-org)").option("--author <name>","Author name for the registry").option("--canary","Use canary (main branch) instead of latest release").option("--local <path>","Use local template directory instead of fetching").action(async(Y)=>{try{if(Y.registry)await vU(Y.registry,Y);else if(Y.global)await kU(Y);else await EU(Y)}catch(q){s(q,{json:Y.json})}})}async function EU(Q){let $=Q.cwd??process.cwd(),{path:Y,exists:q}=E8($);if(q)throw new n1(`ocx.jsonc already exists at ${Y}
160
+ `);let Z={...B.dependencies,...B.devDependencies},M=VX(z,Z);if(!q.isFlattened)await WU(J);return{changed:M.changed,packageDir:J,delta:M.entries}}var XU;var v6=A(()=>{k9();O2();z3();W0();t8();KX();q0();c0();$6();FX();e8();t();y1();c1();X6();g8();k8();P3();y9();k0();l0();EH();XU={name:"opencode-plugins",private:!0,type:"module"}});import{join as BU,posix as _U}from"path";function ZU(Q){if(Q.length===0)return"Unknown parse error";let $=Q[0];if(!$)return"Unknown parse error";return`${n0($.error)} at offset ${$.offset}`}async function hH(Q){let $=Bun.file(`${Q}/registry.jsonc`),Y=Bun.file(`${Q}/registry.json`),q=await $.exists(),J=await Y.exists();if(!q&&!J)return{success:!1,error:"No registry.jsonc or registry.json found in source directory",errorKind:"not_found"};let X=q?$:Y,H=q?"registry.jsonc":"registry.json",G=await X.text(),K=[],W=O1(G,K,{allowTrailingComma:!0});if(K.length>0){let z=ZU(K);return{success:!1,error:`Invalid JSONC in ${H}: ${z}`,errorKind:"parse_error"}}return{success:!0,data:W}}function fH(Q,$){let Y=I9(Q);if(Y)return{valid:!1,errors:[`Schema compatibility issue: ${Y.issue} - ${Y.remediation}`]};return MU(Q,$)}function MU(Q,$){let Y=p8.safeParse(Q);if(!Y.success)return{valid:!1,errors:Y.error.issues.map((J)=>`${J.path.join(".")}: ${J.message}`)};return{valid:!0,errors:[],data:Y.data}}async function UU(Q,$){let Y=[];for(let q of Q.components)for(let J of q.files){let X=T8(J,q.type),H=BU($,"files",X.path);if(!await Bun.file(H).exists())Y.push(`${q.name}: Source file not found at ${X.path}`)}return{valid:Y.length===0,errors:Y}}function VU(Q){let $=[],Y=new Map(Q.components.map((X)=>[X.name,X]));function q(X,H,G,K){if(H.has(X))return[...K,X].join(" -> ");if(G.has(X))return null;let W=Y.get(X);if(!W)return null;H.add(X),K.push(X);for(let z of W.dependencies){if(z.includes("/"))continue;let B=q(z,H,G,K);if(B)return B}return H.delete(X),G.add(X),K.pop(),null}let J=new Set;for(let X of Q.components){if(J.has(X.name))continue;let H=q(X.name,new Set,J,[]);if(H){$.push(`Circular dependency detected: ${H}`);break}}return{valid:$.length===0,errors:$}}function AU(Q){let $=[],Y=new Map,q=(J)=>{let H=J.normalize("NFC").replace(/\\/g,"/");return _U.normalize(H).replace(/^\.\//,"")};for(let J of Q.components)for(let X of J.files){let H=T8(X,J.type),G=q(H.target),K=Y.get(G);if(K)$.push(`Duplicate target "${G}" in components "${K.componentName}" and "${J.name}"`);else Y.set(G,{componentName:J.name})}return{valid:$.length===0,errors:$}}async function*uH(Q,$,Y={}){let q=await UU(Q,$);for(let X of q.errors)yield X;let J=VU(Q);for(let X of J.errors)yield X;if(!Y.skipDuplicateTargets){let X=AU(Q);for(let H of X.errors)yield H}}var mH=A(()=>{O0();c0()});async function o3(Q,$={}){let Y=await hH(Q);if(!Y.success)return{success:!1,errors:[Y.error||"Failed to load registry"],failureType:"load",loadErrorKind:Y.errorKind};let q=fH(Y.data,Q);if(!q.valid)return{success:!1,errors:q.errors,failureType:"schema"};let J=q.data;if(!J)throw Error("Registry validation succeeded but returned no parsed data");let X=[];for await(let H of uH(J,Q,$))X.push(H);if(X.length>0)return{success:!1,errors:X,failureType:"rules"};return{success:!0,errors:[],registry:J}}var P6=A(()=>{mH()});function x6(Q){return{file:Q.filter(($)=>$.includes("Source file not found")),circular:Q.filter(($)=>$.includes("Circular dependency")),duplicate:Q.filter(($)=>$.includes("Duplicate target"))}}function P2(Q,$={}){let Y=x6(Q),q=$.schemaErrors??0,J=Q.length,X=Math.max(0,J-q-Y.file.length-Y.circular.length-Y.duplicate.length);return{valid:J===0,totalErrors:J,schemaErrors:q,sourceFileErrors:Y.file.length,circularDependencyErrors:Y.circular.length,duplicateTargetErrors:Y.duplicate.length,otherErrors:X}}import{relative as LU,resolve as gH}from"path";function FU(Q,$){if($==="not_found")return new _1(Q);if($==="parse_error")return new B1(Q,"CONFIG_ERROR",G1.CONFIG);return new B1(Q,"CONFIG_ERROR",G1.CONFIG)}function jU(Q,$){let Y=P2(Q,{schemaErrors:$==="schema"?Q.length:0}),q={valid:!1,errors:Q,summary:{valid:!1,totalErrors:Y.totalErrors,schemaErrors:Y.schemaErrors,sourceFileErrors:Y.sourceFileErrors,circularDependencyErrors:Y.circularDependencyErrors,duplicateTargetErrors:Y.duplicateTargetErrors,otherErrors:Y.otherErrors}};return new u8(q)}function wU(Q,$){if($==="schema"){_.error("\u2717 Registry schema");for(let q of Q)console.log(P.red(` ${q}`));return}let Y=x6(Q);if(Y.file.length>0){_.error("\u2717 Source files");for(let q of Y.file)console.log(P.red(` ${q}`))}if(Y.circular.length>0){_.error("\u2717 Circular dependencies");for(let q of Y.circular)console.log(P.red(` ${q}`))}if(Y.duplicate.length>0){_.error("\u2717 Duplicate targets");for(let q of Y.duplicate)console.log(P.red(` ${q}`))}}function cH(Q){Q.command("build").description("Build a registry from source (for registry authors)").argument("[path]","Registry source directory",".").option("--out <dir>","Output directory","./dist").option("--cwd <path>","Working directory",process.cwd()).option("--json","Output as JSON",!1).option("-q, --quiet","Suppress output",!1).option("--dry-run","Validate and show what would be built").option("--show-validation","Display validation results before building",!1).action(async($,Y)=>{try{let q=gH(Y.cwd,$),J=gH(Y.cwd,Y.out);if(Y.showValidation){let K=!Y.json&&!Y.quiet;if(K)_.info("Running validation checks...");let W=await o3(q,{skipDuplicateTargets:!1});if(!W.success){let[z="Registry validation failed"]=W.errors;if(W.failureType==="load")throw FU(z,W.loadErrorKind);let B=W.failureType==="schema"?"schema":"rules",Z=jU(W.errors,B);if(Y.json)throw Z;if(!Y.quiet)wU(W.errors,B);process.exit(Z.exitCode)}if(K)_.success("\u2713 Schema compatibility and structure"),_.success("\u2713 Source files"),_.success("\u2713 No circular dependencies"),_.success("\u2713 No duplicate targets"),console.log("")}let X=M1({text:"Building registry...",quiet:Y.quiet||Y.json});if(!Y.json)X.start();let H=await U2({source:q,out:J,dryRun:Y.dryRun});if("dryRun"in H&&H.dryRun){if(!Y.json)X.stop();w0(H,{json:Y.json,quiet:Y.quiet});return}let G=H;if(!Y.json){let K=`Built ${G.componentsCount} components to ${LU(Y.cwd,J)}`;if(X.succeed(K),!process.stdout.isTTY)_.success(`Built ${G.componentsCount} components`)}if(Y.json)F1({success:!0,data:{components:G.componentsCount,output:G.outputPath}})}catch(q){if(q instanceof r0){if(Y.json)s(q,{json:!0});if(!Y.quiet){_.error(q.message);for(let J of q.errors)console.log(P.red(` ${J}`))}process.exit(1)}s(q,{json:Y.json})}})}var dH=A(()=>{W8();_3();P6();e8();t();y1();c1();l0()});import{existsSync as pH}from"fs";import{mkdir as DU}from"fs/promises";import{join as C6}from"path";function lH(Q){Q.command("edit").description("Open configuration file in editor").option("-g, --global","Edit global ocx.jsonc").option("-p, --profile <name>","Edit specific profile's config").action(async($)=>{try{await OU($)}catch(Y){s(Y)}})}async function OU(Q){if(Q.global&&Q.profile)throw new L("Cannot use both --global and --profile flags");let $;if(Q.profile){let X=a0.safeParse(Q.profile);if(!X.success)throw new L(`Invalid profile name "${Q.profile}": ${X.error.issues[0]?.message??"Invalid name"}`);if(await u1.requireInitialized(),!await u1.create().exists(Q.profile))throw new C1(Q.profile);$=K0(Q.profile)}else if(Q.global){if($=P9(),!pH($))throw new h(`Global config not found at ${$}.
161
+ Run 'ocx init --global' first.`)}else{let X=M8(process.cwd());if(X)$=C6(X,d0);else{let H=C6(process.cwd(),n8);if(await DU(H,{recursive:!0}),$=C6(H,d0),!pH($)){let G={$schema:"https://ocx.kdco.dev/schemas/ocx.json",registries:{}};await Bun.write($,JSON.stringify(G,null,2)),_.info(`Created ${$}`)}}}let Y=process.env.EDITOR||process.env.VISUAL||"vi",J=await Bun.spawn([Y,$],{stdin:"inherit",stdout:"inherit",stderr:"inherit"}).exited;if(J!==0)throw Error(`Editor exited with code ${J}`)}var iH=A(()=>{t0();W0();D3();t();y1();c1()});function nH(Q){Q.command("show").description("Display resolved configuration for current directory").addOption(E0.json()).option("--origin","Show where each setting came from").option("-p, --profile <name>","Use specific profile").action(async($)=>{try{await IU($)}catch(Y){s(Y,{json:$.json})}})}async function IU(Q){let $=await e0.create(process.cwd(),{profile:Q.profile});if(Q.origin){let q=$.resolveWithOrigin();if(Q.json){let X={};for(let[H,G]of q.origins)X[H]=G;console.log(JSON.stringify({...q,origins:X},null,2));return}if(console.log(P.bold("Resolved Configuration")),console.log(),q.profileName){let X=q.origins.get("profileName");if(console.log(`${P.cyan("Profile:")} ${q.profileName}`),X)console.log(` ${P.dim(`\u2190 ${X.source}`)}`)}console.log(),console.log(P.cyan("Component Path:"),q.componentPath);let J=q.origins.get("componentPath");if(J)console.log(` ${P.dim(`\u2190 ${J.source} (${J.path})`)}`);console.log(),console.log(P.cyan("Registries:"));for(let[X,H]of Object.entries(q.registries)){console.log(` ${P.green(X)}: ${H.url}`);let G=q.origins.get(`registries.${X}`);if(G)console.log(` ${P.dim(`\u2190 ${G.source} (${G.path})`)}`)}if(q.instructions.length>0){console.log(),console.log(P.cyan("Instructions:"));for(let X of q.instructions)console.log(` ${X}`)}if(Object.keys(q.opencode).length>0){console.log(),console.log(P.cyan("OpenCode Config:"));for(let X of Object.keys(q.opencode)){let H=q.origins.get(`opencode.${X}`);if(console.log(` ${X}:`,JSON.stringify(q.opencode[X])),H)console.log(` ${P.dim(`\u2190 ${H.source} (${H.path})`)}`)}}return}let Y=$.resolve();if(Q.json){console.log(JSON.stringify(Y,null,2));return}if(console.log(P.bold("Resolved Configuration")),console.log(),Y.profileName)console.log(`${P.cyan("Profile:")} ${Y.profileName}`);if(console.log(`${P.cyan("Component Path:")} ${Y.componentPath}`),console.log(),console.log(P.cyan("Registries:")),Object.keys(Y.registries).length===0)console.log(" (none)");else for(let[q,J]of Object.entries(Y.registries))console.log(` ${P.green(q)}: ${J.url}`);if(Y.instructions.length>0){console.log(),console.log(P.cyan("Instructions:"));for(let q of Y.instructions)console.log(` ${q}`)}}var oH=A(()=>{W8();O2();y1();k0()});function sH(Q){let $=Q.command("config").description("View and edit configuration");nH($),lH($)}var rH=A(()=>{iH();oH()});import{existsSync as J9}from"fs";import{cp as NU,mkdir as c9,readdir as aH,readFile as TU,rm as bU,writeFile as y6}from"fs/promises";import{dirname as tH,join as s3}from"path";function eH(Q){let $=Q.command("init").description("Initialize OCX configuration in your project");Q0($),B0($),Q8($),$.option("--registry <path>","Scaffold a new OCX registry project at path").option("--namespace <name>","Registry namespace (e.g., my-org)").option("--author <name>","Author name for the registry").option("--canary","Use canary (main branch) instead of latest release").option("--local <path>","Use local template directory instead of fetching").action(async(Y)=>{try{if(Y.registry)await vU(Y.registry,Y);else if(Y.global)await kU(Y);else await EU(Y)}catch(q){s(q,{json:Y.json})}})}async function EU(Q){let $=Q.cwd??process.cwd(),{path:Y,exists:q}=E8($);if(q)throw new n1(`ocx.jsonc already exists at ${Y}
162
162
 
163
163
  To reset, delete the config and run init again:
164
164
  rm ${Y} && ocx init`);let J=Q.quiet?null:M1({text:"Initializing OCX..."});J?.start();try{let X={$schema:j4,registries:{}},H=b8.parse(X);await c9(tH(Y),{recursive:!0});let G=JSON.stringify(H,null,2);await y6(Y,G,"utf-8");let K=await zX($);if(J?.succeed("Initialized OCX configuration"),Q.json)console.log(JSON.stringify({success:!0,path:Y,opencodePath:K.path,opencodeCreated:K.created}));else if(!Q.quiet){if(_.info(`Created ${Y}`),K.created)_.info(`Created ${K.path}`);_.info(""),_.info("Next steps:"),_.info(" 1. Add a registry: ocx registry add <url>"),_.info(" 2. Install components: ocx add <component>")}}catch(X){throw J?.fail("Failed to initialize"),X}}async function kU(Q){let $=Q.quiet?null:M1({text:"Initializing global profiles..."});$?.start();try{let Y=[],q=[],J=P9();if(J9(J))q.push("globalConfig");else await c9(tH(J),{recursive:!0,mode:448}),await v9(J,{$schema:j4,registries:{}}),Y.push("globalConfig");let X=_8();if(!J9(X))await c9(X,{recursive:!0,mode:448});let H=f1("default");if(!J9(H))await c9(H,{recursive:!0,mode:448});let G=K0("default");if(J9(G))q.push("profileOcx");else await v9(G,yJ),Y.push("profileOcx");let K=Z8("default");if(J9(K))q.push("profileOpencode");else await v9(K,{}),Y.push("profileOpencode");let W=o8("default");if(J9(W))q.push("profileAgents");else await Bun.write(W,`# Profile Instructions
165
165
 
166
166
  <!-- Add your custom instructions for this profile here -->
167
167
  <!-- These will be included when running \`ocx opencode -p default\` -->
168
- `,{mode:384}),Y.push("profileAgents");if($?.succeed("Initialized global profiles"),Q.json)console.log(JSON.stringify({success:!0,files:{globalConfig:J,profileOcx:G,profileOpencode:K,profileAgents:W},created:Y,existed:q}));else if(!Q.quiet)if(Y.length>0){for(let z of Y){if(z==="globalConfig")_.info(`Created global config: ${J}`);if(z==="profileOcx")_.info(`Created profile config: ${G}`);if(z==="profileOpencode")_.info(`Created profile opencode config: ${K}`);if(z==="profileAgents")_.info(`Created profile instructions: ${W}`)}_.info(""),_.info("Next steps:"),_.info(" 1. Edit your profile config: ocx config edit -p default"),_.info(" 2. Add registries: ocx registry add <url> --name <name> --global"),_.info(" 3. Launch OpenCode: ocx opencode"),_.info(" 4. Create more profiles: ocx profile add <name> --global")}else _.info("Global profiles already initialized (all files exist)")}catch(Y){throw $?.fail("Failed to initialize"),Y}}async function vU(Q,$){let Y=Q,q=$.namespace??"my-registry",J=$.author??"Your Name";if(!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(q))throw new L("Invalid namespace format: must start with letter/number, use hyphens only between segments (e.g., 'my-registry')");if((await aH(Y).catch(()=>[])).some((K)=>!K.startsWith(".")))throw new n1("Directory is not empty. Remove existing files or choose a different directory.");let G=$.quiet?null:M1({text:"Scaffolding registry..."});G?.start();try{if(G)G.text=$.local?"Copying template...":"Fetching template...";if($.local)await c9(Y,{recursive:!0}),await QG($.local,Y);else{let K=$.canary?"main":PU();await CU(Y,K,$.verbose)}if(G)G.text="Configuring project...";if(await hU(Y,{namespace:q,author:J}),G?.succeed(`Created registry: ${q}`),$.json)console.log(JSON.stringify({success:!0,namespace:q,path:Y}));else if(!$.quiet)_.info(""),_.info("Next steps:"),_.info(" 1. bun install"),_.info(" 2. Edit registry.jsonc with your components"),_.info(" 3. bun run build"),_.info(""),_.info("Deploy to:"),_.info(" Cloudflare: bunx wrangler deploy"),_.info(" Vercel: vercel"),_.info(" Netlify: netlify deploy")}catch(K){throw G?.fail("Failed to scaffold registry"),K}}async function QG(Q,$){await NU(Q,$,{recursive:!0})}function PU(){return"v2.0.8"}function xU(Q){let $=Q==="main"?"heads/main":`tags/${Q}`;return`https://github.com/${RU}/archive/refs/${$}.tar.gz`}async function CU(Q,$,Y){let q=xU($);if(Y)_.info(`Fetching ${q}`);let J=await fetch(q);if(!J.ok||!J.body)throw new I1(`Failed to fetch template from ${q}: ${J.statusText}`);let X=s3(Q,".ocx-temp");await c9(X,{recursive:!0});try{let H=s3(X,"template.tar.gz"),G=await J.arrayBuffer();await y6(H,Buffer.from(G));let K=Bun.spawn(["tar","-xzf",H,"-C",X],{stdout:"ignore",stderr:"pipe"});if(await K.exited!==0){let M=await new Response(K.stderr).text();throw Error(`Failed to extract template: ${M}`)}let B=(await aH(X)).find((M)=>M.startsWith("ocx-"));if(!B)throw Error("Failed to find extracted template directory");let Z=s3(X,B,SU);await QG(Z,Q)}finally{await bU(X,{recursive:!0,force:!0})}}function yU(Q){return Q.split(/[-_\s]+/).map(($)=>$.charAt(0).toUpperCase()+$.slice(1).toLowerCase()).join(" ")}async function hU(Q,$){let Y=["registry.jsonc","package.json","wrangler.jsonc","README.md","AGENTS.md"];for(let q of Y){let J=s3(Q,q);if(!J9(J))continue;let X=await TU(J).then((H)=>H.toString());if(X=X.replace(/my-registry/g,$.namespace),X=X.replace(/My Registry/g,yU($.namespace)),X=X.replace(/Your Name/g,$.author),q==="registry.jsonc")if(/"\$schema"\s*:/.test(X))X=X.replace(/("\$schema"\s*:\s*")[^"]*(")/,`$1${h0}$2`);else X=X.replace(/{/,`{
169
- "$schema": "${h0}",`);await y6(J,X)}}var RU="kdcokenny/ocx",SU="examples/registry-starter";var $G=A(()=>{z3();j3();t0();W0();q0();$6();t();y1();c1();d0();l0()});function fU(Q,$,Y){let q=Q.indexOf("/");if(q===-1)throw Error(`Invalid legacy key: "${Q}". Expected format: alias/component`);let J=Q.slice(0,q),X=Q.slice(q+1);if(!J||!X)throw Error(`Invalid legacy key: "${Q}". Both alias and component are required.`);let H=A2(Y,J,X,$.version),G={registryUrl:Y,registryName:J,name:X,revision:$.version,hash:$.hash,files:$.files.map((K)=>({path:K,hash:""})),installedAt:$.installedAt,...$.updatedAt&&{updatedAt:$.updatedAt},owner:{type:"user"}};return[H,G]}function r3(Q,$,Y){let q={},J=[],X=Object.keys(Q.installed).sort();for(let G of X){let K=Q.installed[G];if(!K)continue;let W=$.registries[K.registry];if(!W)throw new h(`Registry "${K.registry}" referenced in lock key "${G}" is not configured in ocx.jsonc. Add it before migrating.`);let[z,B]=fU(G,K,W.url);q[z]=B,J.push({legacyKey:G,canonicalId:z,name:B.name,registryName:B.registryName})}return{receipt:{version:1,...Y&&{root:Y},installed:q},components:J}}function YG(Q){let $=Q.registries;if(!$||typeof $!=="object"||Array.isArray($))return[];let Y=[],q=$;for(let J of Object.keys(q).sort()){let X=q[J];if(!X||typeof X!=="object"||Array.isArray(X))continue;let H=X;for(let G of uU)if(G in H)Y.push({registry:J,field:G,action:"remove_deprecated"})}return Y}var uU;var qG=A(()=>{q0();t();uU=["version"]});import{existsSync as h6,readdirSync as mU,readFileSync as GG,statSync as gU}from"fs";import{rename as a3,writeFile as cU}from"fs/promises";import{join as JG}from"path";function KG(Q){Q.command("migrate").description("Migrate legacy ocx.lock to receipt format (.ocx/receipt.jsonc)").option("--global","Migrate global config scope (includes profiles)").option("--apply","Apply migration (default is dry-run preview)").option("--json","Output as JSON").option("-q, --quiet","Suppress output").option("--cwd <path>","Working directory").action(async($)=>{try{await pU($)}catch(Y){s(Y,{json:$.json})}})}async function pU(Q){if(Q.global){await lU(Q);return}await qV(Q,"local",GV(Q),!1)}async function lU(Q){let $=Q.cwd??F0(),Y=iU($);if(!Q.apply){let H=[],G=new Set;for(let{label:z,path:B}of Y){let Z=S8(B),M=T9(B,{isFlattened:!0});if(Z.exists&&M.exists)G.add(z);try{let V=await nU(B,!0,{emitWarnings:!Q.json&&!Q.quiet});H.push({...V,target:z})}catch(V){let U=HG(z,V);if(H.push(U),!Q.json&&!Q.quiet)_.error(`[global:${z}] Preview failed: ${U.error}`)}}let K=XG(H,"global",!1),W=sU(K);if(Q.json){if(d9(K,!1),W)process.exit(1);return}if(!Q.quiet)JV(H,K,G);if(W)process.exit(1);return}let q=[],J=!1;for(let{label:H,path:G}of Y)try{let K=await oU(G,!0);q.push({...K,target:H})}catch(K){J=!0;let W=HG(H,K);if(q.push(W),!Q.json&&!Q.quiet)_.error(`[global:${H}] Migration failed: ${W.error}`)}let X=XG(q,"global",!0);if(Q.json){if(d9(X,!0),J)process.exit(1);return}if(!Q.quiet)XV(q,J);if(J)process.exit(1)}function iU(Q){let $=[];$.push({label:"root",path:Q});let Y=JG(Q,"profiles");if(h6(Y)&&gU(Y).isDirectory()){let J=mU(Y,{withFileTypes:!0}).filter((X)=>X.isDirectory()&&!X.name.startsWith(".")).map((X)=>X.name).sort();for(let X of J)$.push({label:`profile:${X}`,path:JG(Y,X)})}return $}async function nU(Q,$,Y){let q=Y?.emitWarnings??!0,J=f6(Q),X=S8(Q),H=T9(Q,{isFlattened:$}),G=X.exists&&H.exists;if(X.exists&&J.length===0&&!G)return{status:"already_v2",count:0,components:[],configActions:[]};if(!H.exists&&!X.exists&&J.length===0)return{status:"nothing_to_migrate",count:0,components:[],configActions:[]};let K=[];if(H.exists&&!X.exists)try{let W=await L2(Q,{isFlattened:$}),z=await T0(Q,{emitParseDiagnostics:q});if(W&&z)K=r3(W,z,Q).components}catch{if(q)_.warn(`[preview] Could not parse lock/config at "${Q}"; component count may be incomplete.`)}return{status:"preview",count:K.length,components:K,configActions:J}}async function oU(Q,$){let Y=f6(Q),q=S8(Q),J=T9(Q,{isFlattened:$}),X=q.exists&&J.exists;if(q.exists&&Y.length===0&&!X)return{status:"already_v2",count:0,components:[],configActions:[]};if(!J.exists&&!q.exists&&Y.length===0)return{status:"nothing_to_migrate",count:0,components:[],configActions:[]};let H=null;if(J.exists&&!q.exists){let z=await L2(Q,{isFlattened:$});if(!z)throw new L("Failed to parse ocx.lock. The lock file exists but could not be read or contains invalid data.");let B=await T0(Q);if(!B)throw new h("No ocx.jsonc found. The config is required to resolve registry URLs during migration.");let{receipt:Z,components:M}=r3(z,B,Q);H={newReceipt:Z,components:M}}let G=H?.components??[],K=G.length;if(H){await N0(Q,H.newReceipt);let z=t3(J.path);await a3(J.path,z)}if(X){let z=t3(J.path);await a3(J.path,z)}if(Y.length>0)await WG(Q,Y);return{status:H!==null||X||Y.length>0?"migrated":"already_v2",count:K,components:G,configActions:Y}}function XG(Q,$,Y){let q=Q.some((z)=>z.status==="error"),J=Q.some((z)=>z.status==="migrated"||z.status==="preview"),X=Q.every((z)=>z.status==="already_v2"||z.status==="nothing_to_migrate"),H=Q.reduce((z,B)=>z+B.count,0),G=Q.flatMap((z)=>z.components),K=Q.flatMap((z)=>z.configActions),W;if(q)W=Y?"partial_failure":"preview_with_errors";else if(X)W=Q.every((B)=>B.status==="nothing_to_migrate")?"nothing_to_migrate":"already_v2";else if(Y)W=J?"migrated":"already_v2";else W=J?"preview":"already_v2";return{success:!q,status:W,scope:$,count:H,components:G,configActions:K,targets:Q}}function sU(Q){return Q.status==="preview_with_errors"}function d9(Q,$){let Y=rU(Q,$);console.log(JSON.stringify(Y,null,2))}function rU(Q,$){let Y=aU(Q),q=Y.flatMap((J)=>J.blockers??[]);return{...Q,lifecycle_status:QV(Q.status,$),schema_version:dU,blockers:q,targets:Y}}function aU(Q){return(Q.targets&&Q.targets.length>0?Q.targets:[tU(Q)]).map((Y)=>eU(Y))}function tU(Q){return{target:Q.scope,status:Q.status,count:Q.count,components:Q.components,configActions:Q.configActions,blockers:Q.blockers??[]}}function eU(Q){let $=Q.blockers??(Q.status==="error"?[{code:"MIGRATE_BLOCKER",message:Q.error??"Migration blocked",path:Q.target}]:[]);return{...Q,scope:Q.scope??Q.target,result:Q.result??Q.status,blockers:$}}function QV(Q,$){if($)return Q==="partial_failure"?"apply_failed":"apply_ok";return Q==="preview_with_errors"?"preview_blocked":"preview_ok"}function HG(Q,$){let Y=$V($,Q);return{target:Q,status:"error",count:0,components:[],configActions:[],error:Y.message,blockers:[Y]}}function $V(Q,$){let Y=Q instanceof Error?Q.message:String(Q);return{code:YV(Q,Y),message:Y,path:$}}function YV(Q,$){if(typeof Q==="object"&&Q!==null&&"code"in Q){let q=Q.code;if(typeof q==="string"&&q.length>0)return q}let Y=$.toLowerCase();if(Y.includes("ocx.jsonc")||Y.includes("registry"))return"CONFIG_ERROR";if(Y.includes("parse")||Y.includes("invalid"))return"VALIDATION_ERROR";return"MIGRATE_BLOCKER"}async function qV(Q,$,Y,q){let J=f6(Y),X=S8(Y),H=T9(Y,{isFlattened:q}),G=X.exists&&H.exists;if(X.exists&&J.length===0&&!G){let M={success:!0,status:"already_v2",scope:$,count:0,components:[],configActions:[]};if(Q.json){d9(M,Boolean(Q.apply));return}if(!Q.quiet)_.success(`[${$}] Already migrated to receipt format (.ocx/receipt.jsonc).`);return}if(!H.exists&&!X.exists&&J.length===0){let M={success:!0,status:"nothing_to_migrate",scope:$,count:0,components:[],configActions:[]};if(Q.json){d9(M,Boolean(Q.apply));return}if(!Q.quiet)_.info(`[${$}] Nothing to migrate. No legacy ocx.lock found.`);return}let K=null;if(H.exists&&!X.exists){let M=await L2(Y,{isFlattened:q});if(!M)throw new L("Failed to parse ocx.lock. The lock file exists but could not be read or contains invalid data.");let V=await T0(Y);if(!V)throw new h("No ocx.jsonc found. The config is required to resolve registry URLs during migration.");let{receipt:U,components:R}=r3(M,V,Y);K={newReceipt:U,components:R}}let W=K?.components??[],z=W.length;if(!Q.apply){let M={success:!0,status:"preview",scope:$,count:z,components:W,configActions:J};if(Q.json){d9(M,!1);return}if(!Q.quiet){if(z>0){_.info(`[${$}] Migration preview: ${z} component(s) would be migrated.`),_.break();for(let V of W)_.info(` ${V.legacyKey} \u2192 ${V.canonicalId}`);_.break()}if(G)_.info(`[${$}] Legacy ocx.lock would be backed up and removed (receipt already exists).`),_.break();if(J.length>0){_.info(`[${$}] Config normalization: ${J.length} deprecated field(s) would be removed.`);for(let V of J)_.info(` registries.${V.registry}.${V.field} \u2192 remove`);_.break()}if(z===0&&J.length===0&&!G)_.info(`[${$}] Nothing to migrate.`);else _.info("No changes made. Run with --apply to perform migration.")}return}if(K){await N0(Y,K.newReceipt);let M=t3(H.path);if(await a3(H.path,M),!Q.json&&!Q.quiet){_.success(`[${$}] Migrated ${z} component(s) to receipt format (.ocx/receipt.jsonc).`),_.break();for(let V of W)_.success(` \u2713 ${V.legacyKey} \u2192 ${V.canonicalId}`);_.break(),_.info(`Legacy lock backed up to: ${M}`)}}if(G){let M=t3(H.path);if(await a3(H.path,M),!Q.json&&!Q.quiet)_.success(`[${$}] Removed stale legacy lock (receipt already exists).`),_.info(`Legacy lock backed up to: ${M}`)}if(J.length>0){if(await WG(Y,J),!Q.json&&!Q.quiet){if(K)_.break();_.success(`[${$}] Normalized ${J.length} deprecated config field(s).`);for(let M of J)_.success(` \u2713 registries.${M.registry}.${M.field} removed`)}}let Z={success:!0,status:K!==null||G||J.length>0?"migrated":"already_v2",scope:$,count:z,components:W,configActions:J};if(Q.json){d9(Z,!0);return}if(!K&&J.length>0&&!Q.quiet)_.break(),_.success(`[${$}] Config normalization complete.`)}function JV(Q,$,Y){if($.status==="nothing_to_migrate"){_.info("[global] Nothing to migrate across all targets.");return}if($.status==="already_v2"){_.success("[global] All targets already migrated.");return}_.info(`[global] Migration preview across ${Q.length} target(s):`),_.break();for(let q of Q){let J=Y.has(q.target),X=HV(q,J);_.info(` ${q.target}: ${X}`)}if(_.break(),$.status==="preview_with_errors")_.warn("[global] Preview completed with errors on some targets. See above for details."),_.info("No changes made. Run with --apply to perform migration.");else _.info("No changes made. Run with --apply to perform migration.")}function XV(Q,$){_.break();let Y=Q.filter((X)=>X.status==="migrated"),q=Q.filter((X)=>X.status==="already_v2"||X.status==="nothing_to_migrate"),J=Q.filter((X)=>X.status==="error");if(Y.length>0){_.success(`[global] Migrated ${Y.length} target(s):`);for(let X of Y)_.success(` \u2713 ${X.target}`)}if(q.length>0)_.info(`[global] ${q.length} target(s) already up to date.`);if(J.length>0){_.error(`[global] ${J.length} target(s) failed:`);for(let X of J)_.error(` \u2717 ${X.target}: ${X.error}`)}if($)_.break(),_.error("[global] Migration completed with errors. See above for details.")}function HV(Q,$){if(Q.status==="error")return"error";if(Q.status==="already_v2")return"already migrated";if(Q.status==="nothing_to_migrate")return"nothing to migrate";let Y=[];if(Q.count>0)Y.push(`${Q.count} component(s) to migrate`);if(Q.configActions.length>0)Y.push(`${Q.configActions.length} config field(s) to normalize`);if($)Y.push("legacy lock cleanup pending");if(Y.length===0)return"nothing to migrate";return Y.join(", ")}function GV(Q){if(Q.global)return Q.cwd??F0();return Q.cwd??process.cwd()}function t3(Q){let $=`${Q}.bak`;if(!h6($))return $;for(let Y=1;Y<=100;Y++){let q=`${$}.${Y}`;if(!h6(q))return q}return`${$}.${Date.now()}`}function f6(Q){let $=E8(Q);if(!$.exists)return[];try{let Y=GG($.path,"utf-8"),q=O1(Y,[],{allowTrailingComma:!0});if(!q||typeof q!=="object"||Array.isArray(q))return[];return YG(q)}catch{return[]}}async function WG(Q,$){if($.length===0)return;let Y=E8(Q);if(!Y.exists)return;let q=GG(Y.path,"utf-8");for(let J of $){let X=Z9(q,["registries",J.registry,J.field],void 0,KV);q=M9(q,X)}await cU(Y.path,q)}var dU=1,KV;var zG=A(()=>{D0();q0();t();y1();c1();k8();qG();KV={formattingOptions:{tabSize:2,insertSpaces:!0,eol:`
170
- `}}});import{basename as WV,resolve as mR}from"path";function e3(){let{GIT_DIR:Q,GIT_WORK_TREE:$,...Y}=process.env;return Y}async function zV(Q){let $=Bun.spawn(["git","symbolic-ref","--short","HEAD"],{cwd:Q,env:e3(),stdout:"pipe",stderr:"pipe"});if(await $.exited===0){let K=(await new Response($.stdout).text()).trim();if(K)return K}let q=Bun.spawn(["git","describe","--tags","--exact-match","HEAD"],{cwd:Q,env:e3(),stdout:"pipe",stderr:"pipe"});if(await q.exited===0){let K=(await new Response(q.stdout).text()).trim();if(K)return K}let X=Bun.spawn(["git","rev-parse","--short","HEAD"],{cwd:Q,env:e3(),stdout:"pipe",stderr:"pipe"});if(await X.exited===0){let K=(await new Response(X.stdout).text()).trim();if(K)return K}return null}async function BV(Q){let $=Bun.spawn(["git","rev-parse","--show-toplevel"],{cwd:Q,env:e3(),stdout:"pipe",stderr:"pipe"});if(await $.exited!==0)return null;let J=(await new Response($.stdout).text()).trim();if(!J)return null;return WV(J)}async function BG(Q){let[$,Y]=await Promise.all([BV(Q),zV(Q)]);return{repoName:$,branch:Y}}var _G=()=>{};import _V from"path";function ZV(Q){return Q<=31||Q>=127&&Q<=159}function MG(){return Boolean(process.env.TMUX)}function MV(Q){if(!MG())return;Bun.spawnSync(["tmux","rename-window",Q]),Bun.spawnSync(["tmux","set-window-option","automatic-rename","off"])}function UV(Q){if(!u6())return;let $=VV(Q);if(!$)return;process.stdout.write(`\x1B]0;${$}\x07`)}function VV(Q){let $="";for(let Y of Q){let q=Y.codePointAt(0);if(q===void 0)continue;$+=ZV(q)?" ":Y}return $.trim()}function u6(){return l8}function UG(Q){MV(Q),UV(Q)}function VG(){if(Q7||!l8)return;process.stdout.write("\x1B[22;2t"),Q7=!0}function m6(){if(!Q7)return;if(MG())Bun.spawnSync(["tmux","set-window-option","automatic-rename","on"]);if(l8)process.stdout.write("\x1B[23;2t");Q7=!1}function AG(Q,$,Y){let q=Y.repoName??_V.basename(Q);if(!Y.branch)return`ocx[${$}]:${q}`;let J=Y.branch.length>ZG?`${Y.branch.slice(0,ZG-3)}...`:Y.branch;return`ocx[${$}]:${q}/${J}`}var ZG=20,Q7=!1;var LG=A(()=>{F2()});import{randomUUID as AV}from"crypto";import{copyFile as LV,cp as FV,lstat as C8,mkdir as jV,mkdtemp as wV,readdir as wG,readFile as DV,realpath as l9,rename as OV,rm as IV,unlink as NV}from"fs/promises";import{tmpdir as TV}from"os";import{basename as bV,dirname as d6,isAbsolute as DG,join as U8,relative as p6}from"path";var{Glob:g6}=globalThis.Bun;function p(Q,$){return new h(`ocx oc ${Q} error: ${$}`)}function P1(Q){if(Q instanceof Error)return Q.message;return String(Q)}function kV(Q){if(Q.length===0)return"Unknown parse error";let $=Q[0];if(!$)return"Unknown parse error";return`${n0($.error)} at offset ${$.offset}`}function Y7(Q){return Q.replaceAll("\\","/")}function c6(Q){return Q.startsWith("./")?Q.slice(2):Q}function l6(Q,$){let Y=p6(Q,$);if(Y.length===0)return!0;return!Y.startsWith("..")&&!DG(Y)}function vV(Q){if(Q.isFile())return"file";if(Q.isDirectory())return"directory";if(Q.isSymbolicLink())return"symlink";return"other"}function x2(Q){return{entryType:vV(Q),device:String(Q.dev),inode:String(Q.ino),mode:String(Q.mode),size:String(Q.size),mtimeMs:String(Q.mtimeMs)}}function PV(Q,$){return Q.entryType===$.entryType&&Q.device===$.device&&Q.inode===$.inode&&Q.mode===$.mode}function xV(Q,$){return Q.size===$.size&&Q.mtimeMs===$.mtimeMs}async function p9(Q){let $;try{$=await C8(Q.absolutePath)}catch{throw p("validate",`Overlay path changed during ${Q.phase}: ${Q.overlayRelativePath}. ${x8}`)}if(Q.mustRemainDirectory&&!$.isDirectory())throw p("validate",`Overlay path changed during ${Q.phase}: ${Q.overlayRelativePath}. ${x8}`);if(Q.mustRemainFile&&!$.isFile())throw p("validate",`Overlay path changed during ${Q.phase}: ${Q.overlayRelativePath}. ${x8}`);let Y=x2($),q=PV(Q.expectedSnapshot,Y),X=!(Q.compareContent??!0)?!0:xV(Q.expectedSnapshot,Y);if(!q||!X)throw p("validate",`Overlay path changed during ${Q.phase}: ${Q.overlayRelativePath}. ${x8}`)}async function $7(Q,$,Y){let J=Y7(p6(Q,$)).split("/").filter((H)=>H.length>0),X=Q;for(let H of J){X=U8(X,H);let G;try{G=await C8(X)}catch(K){if(K.code==="ENOENT")return;throw p("validate",`Failed to inspect overlay destination path (${Y}): ${P1(K)}`)}if(G.isSymbolicLink())throw p("validate",`Overlay destination path contains existing symlink (${Y})`)}}function FG(Q,$,Y){for(let q of Y)try{new g6(c6(q))}catch{throw p("validate",`Invalid project overlay policy at ${Q}: ${$} contains invalid glob pattern "${q}"`)}}async function yV(Q){if(!Q)return{include:[],exclude:[]};let $=U8(Q,c0),Y=await hV(Q,$);if(!Y)return{include:[],exclude:[]};let q;try{q=await DV(Y,"utf8")}catch(W){throw p("read",`Failed to read project overlay policy at ${$}: ${P1(W)}`)}let J=[],X=O1(q,J,{allowTrailingComma:!0});if(J.length>0)throw p("parse",`Failed to parse project overlay policy at ${$}: ${kV(J)}`);if(!X||typeof X!=="object"||Array.isArray(X))throw p("validate",`Invalid project overlay policy at ${$}: root must be an object`);let H=CV.safeParse(X);if(!H.success){let W=H.error.issues[0],z=W?.path.length?W.path.join("."):"root",B=W?.message??"Invalid project overlay policy";throw p("validate",`Invalid project overlay policy at ${$}: ${z} ${B}`)}let G=H.data.include??[],K=H.data.exclude??[];return FG($,"include",G),FG($,"exclude",K),{include:G,exclude:K}}async function hV(Q,$){let Y;try{Y=await C8($)}catch(X){let H=X.code;if(H==="ENOENT"||H==="ENOTDIR")return null;throw p("read",`Failed to inspect project overlay policy at ${$}: ${P1(X)}`)}if(!Y.isSymbolicLink())return $;let q;try{q=await l9(Q)}catch(X){throw p("validate",`Unable to resolve project config directory ${Q}: ${P1(X)}`)}let J;try{J=await l9($)}catch(X){let H=X.code;if(H==="ENOENT"||H==="ENOTDIR")throw p("validate",`Broken symlink in project overlay policy: ${$}`);throw p("read",`Failed to inspect project overlay policy symlink at ${$}: ${P1(X)}`)}if(!l6(q,J))throw p("validate",`Symlink escapes project overlay policy scope: ${$}`);return J}function fV(Q,$){for(let Y of $.include)if(new g6(c6(Y)).match(Q))return!0;for(let Y of $.exclude)if(new g6(c6(Y)).match(Q))return!1;return!0}function uV(Q,$){return Q.filter((Y)=>fV(Y.overlayRelativePath,$)).map((Y)=>({sourcePath:Y.sourcePath,destinationRelativePath:Y.overlayRelativePath,sourceSnapshot:Y.sourceSnapshot}))}async function OG(Q,$,Y){let q;try{q=await l9($)}catch(J){let X=J.code;if(X==="ENOENT"||X==="ENOTDIR")throw p("validate",`Broken symlink in project overlay scope: ${Y}`);throw p("read",`Failed to inspect symlink at ${Y}: ${P1(J)}`)}if(!l6(Q,q))throw p("validate",`Symlink escapes project overlay scope: ${Y}`);throw p("validate",`Symlink entries are not supported in project overlay scope: ${Y}`)}async function IG(Q,$,Y,q,J){let X;try{X=await C8($)}catch(G){throw p("read",`Failed to inspect project overlay path ${Y}: ${P1(G)}`)}if(X.isSymbolicLink())await OG(Q,$,Y);let H=x2(X);if(X.isDirectory()){await J.beforeDirectoryRead?.({absolutePath:$,overlayRelativePath:Y});let G;try{G=await wG($)}catch(K){throw p("read",`Failed to read project overlay directory ${Y}: ${P1(K)}`)}G.sort((K,W)=>K.localeCompare(W));for(let K of G){let W=U8($,K),z=Y7(U8(Y,K));await IG(Q,W,z,q,J)}await p9({absolutePath:$,overlayRelativePath:Y,expectedSnapshot:H,phase:"overlay discovery",mustRemainDirectory:!0});return}if(!X.isFile())return;q.push({sourcePath:$,overlayRelativePath:Y7(Y),sourceSnapshot:H})}async function mV(Q,$={}){let Y;try{Y=await l9(Q)}catch(H){throw p("validate",`Unable to resolve project config directory ${Q}: ${P1(H)}`)}let q;try{q=await C8(Q)}catch(H){throw p("validate",`Unable to inspect project overlay root ${Q}: ${P1(H)}`)}if(!q.isDirectory())throw p("validate",`Project overlay root changed before discovery: ${Q}. ${x8}`);let J=x2(q),X=[];for(let H of RV){let G=U8(Q,H);await $.beforeScopeInspect?.({scope:H,scopeAbsolutePath:G,projectConfigDir:Q}),await p9({absolutePath:Q,overlayRelativePath:".opencode",expectedSnapshot:J,phase:"overlay discovery",mustRemainDirectory:!0});let K;try{K=await C8(G)}catch(W){let z=W.code;if(z==="ENOENT"||z==="ENOTDIR")continue;throw p("read",`Failed to inspect project overlay scope ${H}: ${P1(W)}`)}if(K.isSymbolicLink())await OG(Y,G,H);await IG(Y,G,H,X,$)}return X.sort((H,G)=>H.overlayRelativePath.localeCompare(G.overlayRelativePath)),X}function gV(Q){let $=d6(Q),Y=bV(Q),q=`${process.pid}-${AV()}`;return U8($,`.${Y}.ocx-tmp-${q}`)}async function cV(Q,$){let Y=gV($);try{await LV(Q,Y),await OV(Y,$)}catch(q){try{await NV(Y)}catch{}throw q}}async function dV(Q,$,Y={}){let q=Y.publishAtomically??cV,J;try{J=await C8($)}catch(H){throw p("validate",`Unable to inspect merged overlay root ${$}: ${P1(H)}`)}if(!J.isDirectory())throw p("validate",`Merged overlay root is not a directory: ${$}`);let X=x2(J);for(let H of Q){if(await Y.beforeSourceVerification?.(H),H.sourceSnapshot)await p9({absolutePath:H.sourcePath,overlayRelativePath:H.destinationRelativePath,expectedSnapshot:H.sourceSnapshot,phase:"overlay source verification",mustRemainFile:!0});await p9({absolutePath:$,overlayRelativePath:".merged",expectedSnapshot:X,phase:"overlay destination verification",mustRemainDirectory:!0,compareContent:!1});let G;try{G=V0($,H.destinationRelativePath)}catch(B){throw p("validate",`Overlay destination path is invalid (${H.destinationRelativePath}): ${P1(B)}`)}await $7($,G,H.destinationRelativePath);let K=d6(G);await Y.beforeDestinationParentCreate?.({operation:H,destinationPath:G,destinationParentPath:K}),await $7($,G,H.destinationRelativePath);try{await jV(K,{recursive:!0})}catch(B){throw p("copy",`Failed to copy overlay file ${H.destinationRelativePath}: ${P1(B)}`)}await $7($,G,H.destinationRelativePath);let W;try{W=await C8(K)}catch(B){throw p("validate",`Failed to inspect overlay destination parent (${H.destinationRelativePath}): ${P1(B)}`)}if(!W.isDirectory())throw p("validate",`Overlay destination parent changed before publish (${H.destinationRelativePath}). ${x8}`);let z=x2(W);await Y.beforeDestinationPublish?.({operation:H,destinationPath:G,destinationParentPath:K}),await p9({absolutePath:$,overlayRelativePath:".merged",expectedSnapshot:X,phase:"overlay destination publish",mustRemainDirectory:!0,compareContent:!1}),await p9({absolutePath:K,overlayRelativePath:H.destinationRelativePath,expectedSnapshot:z,phase:"overlay destination publish",mustRemainDirectory:!0,compareContent:!1}),await $7($,G,H.destinationRelativePath);try{await q(H.sourcePath,G)}catch(B){if(B instanceof h)throw B;throw p("copy",`Failed to copy overlay file ${H.destinationRelativePath}: ${P1(B)}`)}}}async function pV(Q,$){let Y;try{Y=await wG(Q)}catch(q){throw p("copy",`Failed to read profile directory ${Q}: ${P1(q)}`)}for(let q of Y){let J=U8(Q,q),X=U8($,q);try{await FV(J,X,{recursive:!0,force:!0,errorOnExist:!1})}catch(H){throw p("copy",`Failed to copy profile base file ${q}: ${P1(H)}`)}}}async function jG(Q){try{await IV(Q,{recursive:!0,force:!0})}catch($){throw p("cleanup",`Failed to remove temporary merged config directory ${Q}: ${P1($)}`)}}function lV(Q,$){let Y=Y7(p6(Q,$));if(!Y||Y===".")throw p("validate",`Overlay source path failed relative parsing: ${$}`);if(Y===".."||Y.startsWith("../")||DG(Y))throw p("validate",`Overlay source path escapes project overlay scope: ${$}`);return Y}function iV(Q,$){let Y=$.map((q)=>{if(!q.sourceSnapshot)throw p("validate",`Overlay source snapshot missing for ${q.destinationRelativePath}. ${x8}`);return{sourceRelativePath:lV(Q,q.sourcePath),destinationRelativePath:q.destinationRelativePath,sourceSnapshot:q.sourceSnapshot}});return{version:EV,projectConfigDir:Q,operations:Y}}function nV(){return null}async function oV(Q){let $=Q.manifest.operations.map((Y)=>({sourcePath:V0(Q.manifest.projectConfigDir,Y.sourceRelativePath),destinationRelativePath:Y.destinationRelativePath,sourceSnapshot:Y.sourceSnapshot}));await dV($,Q.mergedConfigDir,Q.copySeams)}async function sV(Q){if(Q.manifest.operations.length===0)return"best-effort-js";let $=Q.nativeHelper??nV();if($)return await $.applyManifest(Q.manifest,Q.mergedConfigDir),"native-fd";if(Q.hardeningMode==="native-fd-required")throw p("validate",`Native fd helper required for overlay merge, but none is available in this Bun/Node runtime. ${x8}`);return await oV({manifest:Q.manifest,mergedConfigDir:Q.mergedConfigDir,copySeams:Q.copySeams}),"best-effort-js"}async function rV(Q){let $=d6(Q),Y;try{Y=await l9($)}catch(J){throw p("validate",`Unable to resolve project directory ${$}: ${P1(J)}`)}let q;try{q=await l9(Q)}catch(J){throw p("validate",`Unable to resolve project config directory ${Q}: ${P1(J)}`)}if(!l6(Y,q))throw p("validate",`Project .opencode root resolves outside project directory: ${Q}`);return q}function aV(Q){if(Q instanceof h)return Q;return p("copy",`Failed to prepare temporary merged config directory: ${P1(Q)}`)}async function NG(Q){let $=M8(Q.projectDir),Y=Q.hardeningMode??"best-effort-js",q=null;try{q=await wV(U8(TV(),SV)),await pV(Q.profileDir,q);let J="best-effort-js";if($){let H=await rV($),G=await yV(H),K=await mV(H,Q.seams?.collection),W=uV(K,G),z=iV(H,W);J=await sV({manifest:z,mergedConfigDir:q,hardeningMode:Y,copySeams:Q.seams?.copy,nativeHelper:Q.seams?.nativeHelper})}let X=q;return{path:X,cleanup:()=>jG(X),hardeningLevel:J}}catch(J){let X=aV(J);if(q)try{await jG(q)}catch(H){X.message=`${X.message}
171
- Cleanup warning: ${P1(H)}`}throw X}}var RV,SV="ocx-oc-merged-",EV=1,x8="Full TOCTOU/symlink-swap hardening requires an fd-based native helper transaction.",CV;var TG=A(()=>{D0();H8();W0();t();g8();RV=["agent","agents","skill","skills"];CV=Q1({include:R1(F()).optional(),exclude:R1(F()).optional()}).passthrough()});import*as B0 from"path";function q7(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}function tV(Q){if(Q.length===0)return"Unknown parse error";let $=Q[0];if(!$)return"Unknown parse error";return`${n0($.error)} at offset ${$.offset}`}function J7(Q){if(Q.length===0)return"$";let $="";for(let Y of Q){if(typeof Y==="number"){$+=`[${Y}]`;continue}$=$.length===0?Y:`${$}.${Y}`}return $}function C2(Q,$,Y,q){if(Q===void 0)return;if(q7(Q)){for(let[J,X]of Object.entries(Q))C2(X,$,[...Y,J],q);return}if(Array.isArray(Q)){for(let[J,X]of Q.entries())C2(X,$,[...Y,J],q);return}q.set(J7(Y),$)}function eV(Q,$,Y,q){let J=Array.from(new Set([...Q,...$])),X=new Map;for(let H of Q)if(!X.has(H))X.set(H,"profile");for(let H of $)if(!X.has(H))X.set(H,"local");for(let[H,G]of J.entries())q.set(J7([...Y,H]),X.get(G)??"local")}function QA(Q,$,Y,q){let J=[...Q,...$],X=n4(J),H=new Map;for(let G=J.length-1;G>=0;G--){let K=J[G];if(!K)continue;let W=D2(K);if(!H.has(W))H.set(W,G<Q.length?"profile":"local")}for(let[G,K]of X.entries()){let W=D2(K);q.set(J7([...Y,G]),H.get(W)??"local")}}function bG(Q,$){return Q.length===1&&Q[0]===$}function RG(Q){let{profileValue:$,localValue:Y,pathSegments:q,origins:J}=Q;if(Y===void 0){C2($,"profile",q,J);return}if($===void 0){C2(Y,"local",q,J);return}if(q7($)&&q7(Y)){let X=new Set([...Object.keys($),...Object.keys(Y)]);for(let H of X)RG({profileValue:$[H],localValue:Y[H],pathSegments:[...q,H],origins:J});return}if(Array.isArray($)&&Array.isArray(Y)){if(bG(q,"instructions")){if($.every((X)=>typeof X==="string")&&Y.every((X)=>typeof X==="string")){eV($,Y,q,J);return}}if(bG(q,"plugin")){if($.every((X)=>typeof X==="string")&&Y.every((X)=>typeof X==="string")){QA($,Y,q,J);return}}}C2(Y,"local",q,J)}function $A(Q){let $=new Map;return RG({profileValue:Q.profileConfig,localValue:Q.localConfig,pathSegments:[],origins:$}),$}function YA(Q){if(!Q.startsWith("{file:"))return null;if(!Q.endsWith("}"))return null;let $=Q.slice(6,-1);return $.length>0?$:null}function qA(Q){return/^[A-Za-z]:[\\/]/.test(Q)}function JA(Q){if(Q.startsWith("~"))return!1;if(B0.isAbsolute(Q))return!1;if(qA(Q))return!1;return!0}function XA(Q){let $=YA(Q.value);if(!$)return Q.value;let Y=J7(Q.pathSegments);if(Q.origins.get(Y)!=="profile")return Q.value;if(!JA($))return Q.value;return`{file:${B0.resolve(Q.profileDir,$)}}`}function i6(Q){let{value:$,pathSegments:Y,origins:q,profileDir:J}=Q;if(typeof $==="string")return XA({value:$,pathSegments:Y,origins:q,profileDir:J});if(Array.isArray($))return $.map((X,H)=>i6({value:X,pathSegments:[...Y,H],origins:q,profileDir:J}));if(q7($)){let X={};for(let[H,G]of Object.entries($))X[H]=i6({value:G,pathSegments:[...Y,H],origins:q,profileDir:J});return X}return $}async function HA(Q){let $=M8(Q);if(!$)return{};let Y=B0.join($,w2),q=Bun.file(Y);if(!await q.exists())return{};let J;try{J=await q.text()}catch(G){let K=G instanceof Error?G.message:"Unknown read error";throw new h(`Failed to read local OpenCode config at ${Y}: ${K}`)}let X=[],H=O1(J,X,{allowTrailingComma:!0});if(X.length>0){let G=tV(X);throw new h(`Invalid JSONC in local OpenCode config at ${Y}: ${G}`)}if(!H||typeof H!=="object"||Array.isArray(H))throw new h(`Invalid local OpenCode config at ${Y}: root must be an object`);return H}async function GA(Q){let $=await HA(Q.projectDir),Y=$A({profileConfig:Q.profileConfig,localConfig:$});return i6({value:Q.mergedConfig,pathSegments:[],origins:Y,profileDir:Q.profileDir})}function KA(Q){let $=new Set,Y=[];for(let q=Q.length-1;q>=0;q--){let J=Q[q];if(!$.has(J))$.add(J),Y.unshift(J)}return Y}function WA(Q){return Q.configBin??Q.envBin??"opencode"}function SG(Q){return Q.includes("/")||Q.includes("\\")}function zA(Q){let{configuredBin:$,cwd:Y}=Q,q=Q.resolveExecutable??((X)=>Bun.which(X));if(!$.trim())throw Error("OpenCode launcher is empty and cannot be resolved to a stable path");if(SG($))return B0.isAbsolute($)?$:B0.resolve(Y,$);let J=q($);if(!J)throw Error(`OpenCode launcher "${$}" is not available in PATH and cannot be used as OPENCODE_BIN`);return B0.isAbsolute(J)?J:B0.resolve(Y,J)}function BA(Q){let $=Q.resolveExecutable??((W)=>Bun.which(W)),Y=Q.argv??process.argv,q=Q.execPath??process.execPath,J=Q.isCompiledBinary??(typeof Bun<"u"&&typeof Bun.main==="string"&&Bun.main.startsWith("/$bunfs/")),X=Q.inheritedOcxBin?.trim(),H=J?q:Y[1],G=X&&X.length>0?X:H;if(!G?.trim())throw Error("OCX executable path is empty and cannot be resolved from the current process");if(SG(G))return B0.isAbsolute(G)?G:B0.resolve(Q.cwd,G);let K=$(G);if(!K)throw Error(`OCX executable "${G}" is not available in PATH and cannot be persisted as OCX_BIN`);return B0.isAbsolute(K)?K:B0.resolve(Q.cwd,K)}function _A(Q){let $=Boolean(Q.profileName),{OPENCODE_DISABLE_PROJECT_CONFIG:Y,OPENCODE_BIN:q,OCX_CONTEXT:J,OCX_BIN:X,OCX_PROFILE:H,OCX_TITLE_CONTEXT:G,...K}=Q.baseEnv;return{...K,...Q.opencodeBin!==void 0&&{OPENCODE_BIN:Q.opencodeBin},...$&&{OPENCODE_DISABLE_PROJECT_CONFIG:"true"},OPENCODE_CONFIG_DIR:Q.configDir??($?f1(Q.profileName):F0()),...Q.configContent&&{OPENCODE_CONFIG_CONTENT:Q.configContent},...$&&{OCX_CONTEXT:"1"},...$&&Q.ocxBin&&{OCX_BIN:Q.ocxBin},...Q.profileName&&{OCX_PROFILE:Q.profileName},...Q.titleContext&&{OCX_TITLE_CONTEXT:JSON.stringify(Q.titleContext)}}}function EG(Q){Q.command("oc").alias("opencode").description("Launch OpenCode with resolved configuration").option("-p, --profile <name>","Use specific profile").option("--no-rename","Disable terminal/tmux window renaming").allowUnknownOption().allowExcessArguments(!0).action(async($,Y)=>{try{await ZA(Y.args,$)}catch(q){s(q)}})}async function ZA(Q,$){let Y=process.cwd(),q=await e0.create(Y,{profile:$.profile}),J=q.resolve(),X=q.getProfile();if(J.profileName)_.info(`Using profile: ${J.profileName}`);let H=X?.ocx,G=$.rename!==!1&&H?.renameWindow!==!1;if(J.profileName){let w=Z8(J.profileName);if(!await Bun.file(w).exists())_.warn(`No opencode.jsonc found at ${w}. Create one to customize OpenCode settings.`)}let K=J.opencode;if(J.profileName)K=await GA({mergedConfig:J.opencode,profileConfig:X?.opencode??{},projectDir:Y,profileDir:f1(J.profileName)});let W=Array.isArray(K.instructions)?K.instructions:[],z=[...J.instructions,...W],B=KA(z),Z=B.length>0||Object.keys(K).length>0?{...K,instructions:B.length>0?B:void 0}:void 0,M=null,V=null,U=null,R=null,I=null,c=()=>{if(M)M.kill("SIGINT");else I=130},N=()=>{if(M)M.kill("SIGTERM");else I=143},x=()=>{if(G)m6()};try{if(process.on("SIGINT",c),process.on("SIGTERM",N),process.on("exit",x),I!==null){R=I;return}if(J.profileName)V=await NG({projectDir:Y,profileDir:f1(J.profileName)});if(I!==null){R=I;return}let w=G?await BG(Y):{repoName:null,branch:null};if(I!==null){R=I;return}let b=AG(Y,J.profileName??"default",w),D={mayWriteOscTitle:G&&u6(),baseTitle:b};if(G)VG(),UG(b);if(I!==null){R=I;return}let l=WA({configBin:H?.bin,envBin:process.env.OPENCODE_BIN}),i=Boolean(J.profileName),r=i?zA({configuredBin:l,cwd:Y}):l,J1=i?BA({cwd:Y,inheritedOcxBin:process.env.OCX_BIN}):void 0,S=Z?JSON.stringify(Z):void 0;try{M=Bun.spawn({cmd:[r,...Q],cwd:Y,env:_A({baseEnv:process.env,profileName:J.profileName??void 0,ocxBin:J1,opencodeBin:r,configDir:V?.path,configContent:S,titleContext:D}),stdin:"inherit",stdout:"inherit",stderr:"inherit"})}catch(u){throw p("spawn",`Failed to launch OpenCode binary "${l}": ${u instanceof Error?u.message:String(u)}`)}R=await M.exited}catch(w){U=w instanceof Error?w:p("spawn",`OpenCode process failed: ${String(w)}`)}finally{if(process.off("SIGINT",c),process.off("SIGTERM",N),process.off("exit",x),G)m6();if(V)try{await V.cleanup()}catch(w){if(U!==null||I!==null||R!==null&&R!==0)_.warn(`Cleanup warning: ${w instanceof Error?w.message:String(w)}`);else U=w instanceof Error?w:p("cleanup",`Failed to remove temporary merged config directory: ${String(w)}`)}}if(U)throw U;if(R!==null)process.exit(R)}var kG=A(()=>{D0();O2();W0();I3();t();_G();y1();c1();k8();LG();TG()});import{existsSync as i9}from"fs";import{mkdir as n6,mkdtemp as MA,rename as UA,rm as vG,writeFile as VA}from"fs/promises";import{dirname as PG,join as X7,relative as AA}from"path";function xG(Q,$,Y){let q=Y instanceof Error?Y.message:String(Y);return`${Q} "${$}" (${q})`}function fG(Q,$){let[Y,q]=$.split("/");if(!Y||!q)return;return`${g1(Q)}/components/${q}.json`}function CG(Q){if(!Q)return null;let[$,Y,...q]=Q.split("/");if(!$||!Y||q.length>0)return null;return{registryName:$,componentName:Y}}function LA(Q,$){if(!Q)return{};let Y;try{let H=new URL(Q),G=H.pathname.match(/(?:^|\/)components\/([^/]+)\.json$/);if(G?.[1])Y=decodeURIComponent(G[1]);else{let K=H.pathname.match(/(?:^|\/)components\/([^/]+)\/.+$/);if(K?.[1])Y=decodeURIComponent(K[1])}}catch{}let q=g1(Q),J,X=-1;for(let[H,G]of Object.entries($)){let K=g1(G.url);if(!(q===K||q.startsWith(`${K}/`))||K.length<=X)continue;J=H,X=K.length}return{registryName:J,componentName:Y}}function FA(Q){let $=Q.depRefs[0]??`${Q.namespace}/${Q.component}`,Y={...Q.profileRegistries,...Q.profileRegistries[Q.namespace]?{}:{[Q.namespace]:{url:Q.registryUrl}}},q=Q.error.registryName,J=Q.error.qualifiedName,X=CG(J);if(!q&&X)q=X.registryName;let H=X?.componentName,G=J&&!X&&!J.includes("/")?J:void 0,K=LA(Q.error.url,Y);if(!q&&K.registryName)q=K.registryName;let W=H??G??K.componentName;if((!J||!X)&&q&&W)J=`${q}/${W}`;if(!J)J=$;if(!q)q=CG(J)?.registryName??Q.namespace;let z=Y[q]?.url||(q===Q.namespace?Q.registryUrl:void 0);return{registryName:q,qualifiedName:J,fallbackUrl:Q.error.url||(z?fG(z,J):void 0)}}function yG(Q,$){let Y=Q.phase??$.fallbackPhase,q=Q.url??$.fallbackUrl,J=[`phase: ${Y}`,`qualifiedName: ${$.qualifiedName}`,`registryContext: ${$.registryContext}`,`registryName: ${$.registryName}`,...q?[`url: ${q}`]:[]];return new I1(`${Q.message} (${J.join(", ")})`,{url:q,status:Q.status,statusText:Q.statusText,phase:Y,qualifiedName:$.qualifiedName,registryContext:$.registryContext,registryName:$.registryName})}function hG(Q,$){if(!Q.startsWith(".opencode/"))throw new L(`Invalid embedded target "${Q}": expected .opencode/ prefix for embedded profile files.`);let Y=Q.slice(10);if(!Y)throw new L(`Invalid embedded target "${Q}": missing path after .opencode/ prefix.`);let q;try{q=V0($,Y)}catch(X){if(X instanceof e1)throw new L(`Invalid embedded target "${Q}": ${X.message}`);throw X}let J=AA($,q).replace(/\\/g,"/");if(J==="."||J==="")throw new L(`Invalid embedded target "${Q}": target must resolve to a file path.`);return J}async function o6(Q){let{namespace:$,component:Y,profileName:q,registryUrl:J,quiet:X}=Q;if(!a0.safeParse(q).success)throw new L(`Invalid profile name: "${q}". Profile names must start with a letter and contain only alphanumeric characters, dots, underscores, or hyphens.`);let G;if($)G=$;else throw new L(`Registry name is required for URL-based profile installs.
168
+ `,{mode:384}),Y.push("profileAgents");if($?.succeed("Initialized global profiles"),Q.json)console.log(JSON.stringify({success:!0,files:{globalConfig:J,profileOcx:G,profileOpencode:K,profileAgents:W},created:Y,existed:q}));else if(!Q.quiet)if(Y.length>0){for(let z of Y){if(z==="globalConfig")_.info(`Created global config: ${J}`);if(z==="profileOcx")_.info(`Created profile config: ${G}`);if(z==="profileOpencode")_.info(`Created profile opencode config: ${K}`);if(z==="profileAgents")_.info(`Created profile instructions: ${W}`)}_.info(""),_.info("Next steps:"),_.info(" 1. Edit your profile config: ocx config edit -p default"),_.info(" 2. Add registries: ocx registry add <url> --name <name> --global"),_.info(" 3. Launch OpenCode: ocx opencode"),_.info(" 4. Create more profiles: ocx profile add <name> --global")}else _.info("Global profiles already initialized (all files exist)")}catch(Y){throw $?.fail("Failed to initialize"),Y}}async function vU(Q,$){let Y=Q,q=$.namespace??"my-registry",J=$.author??"Your Name";if(!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(q))throw new L("Invalid namespace format: must start with letter/number, use hyphens only between segments (e.g., 'my-registry')");if((await aH(Y).catch(()=>[])).some((K)=>!K.startsWith(".")))throw new n1("Directory is not empty. Remove existing files or choose a different directory.");let G=$.quiet?null:M1({text:"Scaffolding registry..."});G?.start();try{if(G)G.text=$.local?"Copying template...":"Fetching template...";if($.local)await c9(Y,{recursive:!0}),await QG($.local,Y);else{let K=$.canary?"main":PU();await CU(Y,K,$.verbose)}if(G)G.text="Configuring project...";if(await hU(Y,{namespace:q,author:J}),G?.succeed(`Created registry: ${q}`),$.json)console.log(JSON.stringify({success:!0,namespace:q,path:Y}));else if(!$.quiet)_.info(""),_.info("Next steps:"),_.info(" 1. bun install"),_.info(" 2. Edit registry.jsonc with your components"),_.info(" 3. bun run build"),_.info(""),_.info("Deploy to:"),_.info(" Cloudflare: bunx wrangler deploy"),_.info(" Vercel: vercel"),_.info(" Netlify: netlify deploy")}catch(K){throw G?.fail("Failed to scaffold registry"),K}}async function QG(Q,$){await NU(Q,$,{recursive:!0})}function PU(){return"v2.0.9"}function xU(Q){let $=Q==="main"?"heads/main":`tags/${Q}`;return`https://github.com/${RU}/archive/refs/${$}.tar.gz`}async function CU(Q,$,Y){let q=xU($);if(Y)_.info(`Fetching ${q}`);let J=await fetch(q);if(!J.ok||!J.body)throw new I1(`Failed to fetch template from ${q}: ${J.statusText}`);let X=s3(Q,".ocx-temp");await c9(X,{recursive:!0});try{let H=s3(X,"template.tar.gz"),G=await J.arrayBuffer();await y6(H,Buffer.from(G));let K=Bun.spawn(["tar","-xzf",H,"-C",X],{stdout:"ignore",stderr:"pipe"});if(await K.exited!==0){let M=await new Response(K.stderr).text();throw Error(`Failed to extract template: ${M}`)}let B=(await aH(X)).find((M)=>M.startsWith("ocx-"));if(!B)throw Error("Failed to find extracted template directory");let Z=s3(X,B,SU);await QG(Z,Q)}finally{await bU(X,{recursive:!0,force:!0})}}function yU(Q){return Q.split(/[-_\s]+/).map(($)=>$.charAt(0).toUpperCase()+$.slice(1).toLowerCase()).join(" ")}async function hU(Q,$){let Y=["registry.jsonc","package.json","wrangler.jsonc","README.md","AGENTS.md"];for(let q of Y){let J=s3(Q,q);if(!J9(J))continue;let X=await TU(J).then((H)=>H.toString());if(X=X.replace(/my-registry/g,$.namespace),X=X.replace(/My Registry/g,yU($.namespace)),X=X.replace(/Your Name/g,$.author),q==="registry.jsonc")if(/"\$schema"\s*:/.test(X))X=X.replace(/("\$schema"\s*:\s*")[^"]*(")/,`$1${f0}$2`);else X=X.replace(/{/,`{
169
+ "$schema": "${f0}",`);await y6(J,X)}}var RU="kdcokenny/ocx",SU="examples/registry-starter";var $G=A(()=>{z3();j3();t0();W0();q0();$6();t();y1();c1();k0();l0()});function fU(Q,$,Y){let q=Q.indexOf("/");if(q===-1)throw Error(`Invalid legacy key: "${Q}". Expected format: alias/component`);let J=Q.slice(0,q),X=Q.slice(q+1);if(!J||!X)throw Error(`Invalid legacy key: "${Q}". Both alias and component are required.`);let H=A2(Y,J,X,$.version),G={registryUrl:Y,registryName:J,name:X,revision:$.version,hash:$.hash,files:$.files.map((K)=>({path:K,hash:""})),installedAt:$.installedAt,...$.updatedAt&&{updatedAt:$.updatedAt},owner:{type:"user"}};return[H,G]}function r3(Q,$,Y){let q={},J=[],X=Object.keys(Q.installed).sort();for(let G of X){let K=Q.installed[G];if(!K)continue;let W=$.registries[K.registry];if(!W)throw new h(`Registry "${K.registry}" referenced in lock key "${G}" is not configured in ocx.jsonc. Add it before migrating.`);let[z,B]=fU(G,K,W.url);q[z]=B,J.push({legacyKey:G,canonicalId:z,name:B.name,registryName:B.registryName})}return{receipt:{version:1,...Y&&{root:Y},installed:q},components:J}}function YG(Q){let $=Q.registries;if(!$||typeof $!=="object"||Array.isArray($))return[];let Y=[],q=$;for(let J of Object.keys(q).sort()){let X=q[J];if(!X||typeof X!=="object"||Array.isArray(X))continue;let H=X;for(let G of uU)if(G in H)Y.push({registry:J,field:G,action:"remove_deprecated"})}return Y}var uU;var qG=A(()=>{q0();t();uU=["version"]});import{existsSync as h6,readdirSync as mU,readFileSync as GG,statSync as gU}from"fs";import{rename as a3,writeFile as cU}from"fs/promises";import{join as JG}from"path";function KG(Q){Q.command("migrate").description("Migrate legacy ocx.lock to receipt format (.ocx/receipt.jsonc)").option("--global","Migrate global config scope (includes profiles)").option("--apply","Apply migration (default is dry-run preview)").option("--json","Output as JSON").option("-q, --quiet","Suppress output").option("--cwd <path>","Working directory").action(async($)=>{try{await pU($)}catch(Y){s(Y,{json:$.json})}})}async function pU(Q){if(Q.global){await lU(Q);return}await qV(Q,"local",GV(Q),!1)}async function lU(Q){let $=Q.cwd??j0(),Y=iU($);if(!Q.apply){let H=[],G=new Set;for(let{label:z,path:B}of Y){let Z=S8(B),M=T9(B,{isFlattened:!0});if(Z.exists&&M.exists)G.add(z);try{let V=await nU(B,!0,{emitWarnings:!Q.json&&!Q.quiet});H.push({...V,target:z})}catch(V){let U=HG(z,V);if(H.push(U),!Q.json&&!Q.quiet)_.error(`[global:${z}] Preview failed: ${U.error}`)}}let K=XG(H,"global",!1),W=sU(K);if(Q.json){if(d9(K,!1),W)process.exit(1);return}if(!Q.quiet)JV(H,K,G);if(W)process.exit(1);return}let q=[],J=!1;for(let{label:H,path:G}of Y)try{let K=await oU(G,!0);q.push({...K,target:H})}catch(K){J=!0;let W=HG(H,K);if(q.push(W),!Q.json&&!Q.quiet)_.error(`[global:${H}] Migration failed: ${W.error}`)}let X=XG(q,"global",!0);if(Q.json){if(d9(X,!0),J)process.exit(1);return}if(!Q.quiet)XV(q,J);if(J)process.exit(1)}function iU(Q){let $=[];$.push({label:"root",path:Q});let Y=JG(Q,"profiles");if(h6(Y)&&gU(Y).isDirectory()){let J=mU(Y,{withFileTypes:!0}).filter((X)=>X.isDirectory()&&!X.name.startsWith(".")).map((X)=>X.name).sort();for(let X of J)$.push({label:`profile:${X}`,path:JG(Y,X)})}return $}async function nU(Q,$,Y){let q=Y?.emitWarnings??!0,J=f6(Q),X=S8(Q),H=T9(Q,{isFlattened:$}),G=X.exists&&H.exists;if(X.exists&&J.length===0&&!G)return{status:"already_v2",count:0,components:[],configActions:[]};if(!H.exists&&!X.exists&&J.length===0)return{status:"nothing_to_migrate",count:0,components:[],configActions:[]};let K=[];if(H.exists&&!X.exists)try{let W=await L2(Q,{isFlattened:$}),z=await b0(Q,{emitParseDiagnostics:q});if(W&&z)K=r3(W,z,Q).components}catch{if(q)_.warn(`[preview] Could not parse lock/config at "${Q}"; component count may be incomplete.`)}return{status:"preview",count:K.length,components:K,configActions:J}}async function oU(Q,$){let Y=f6(Q),q=S8(Q),J=T9(Q,{isFlattened:$}),X=q.exists&&J.exists;if(q.exists&&Y.length===0&&!X)return{status:"already_v2",count:0,components:[],configActions:[]};if(!J.exists&&!q.exists&&Y.length===0)return{status:"nothing_to_migrate",count:0,components:[],configActions:[]};let H=null;if(J.exists&&!q.exists){let z=await L2(Q,{isFlattened:$});if(!z)throw new L("Failed to parse ocx.lock. The lock file exists but could not be read or contains invalid data.");let B=await b0(Q);if(!B)throw new h("No ocx.jsonc found. The config is required to resolve registry URLs during migration.");let{receipt:Z,components:M}=r3(z,B,Q);H={newReceipt:Z,components:M}}let G=H?.components??[],K=G.length;if(H){await T0(Q,H.newReceipt);let z=t3(J.path);await a3(J.path,z)}if(X){let z=t3(J.path);await a3(J.path,z)}if(Y.length>0)await WG(Q,Y);return{status:H!==null||X||Y.length>0?"migrated":"already_v2",count:K,components:G,configActions:Y}}function XG(Q,$,Y){let q=Q.some((z)=>z.status==="error"),J=Q.some((z)=>z.status==="migrated"||z.status==="preview"),X=Q.every((z)=>z.status==="already_v2"||z.status==="nothing_to_migrate"),H=Q.reduce((z,B)=>z+B.count,0),G=Q.flatMap((z)=>z.components),K=Q.flatMap((z)=>z.configActions),W;if(q)W=Y?"partial_failure":"preview_with_errors";else if(X)W=Q.every((B)=>B.status==="nothing_to_migrate")?"nothing_to_migrate":"already_v2";else if(Y)W=J?"migrated":"already_v2";else W=J?"preview":"already_v2";return{success:!q,status:W,scope:$,count:H,components:G,configActions:K,targets:Q}}function sU(Q){return Q.status==="preview_with_errors"}function d9(Q,$){let Y=rU(Q,$);console.log(JSON.stringify(Y,null,2))}function rU(Q,$){let Y=aU(Q),q=Y.flatMap((J)=>J.blockers??[]);return{...Q,lifecycle_status:QV(Q.status,$),schema_version:dU,blockers:q,targets:Y}}function aU(Q){return(Q.targets&&Q.targets.length>0?Q.targets:[tU(Q)]).map((Y)=>eU(Y))}function tU(Q){return{target:Q.scope,status:Q.status,count:Q.count,components:Q.components,configActions:Q.configActions,blockers:Q.blockers??[]}}function eU(Q){let $=Q.blockers??(Q.status==="error"?[{code:"MIGRATE_BLOCKER",message:Q.error??"Migration blocked",path:Q.target}]:[]);return{...Q,scope:Q.scope??Q.target,result:Q.result??Q.status,blockers:$}}function QV(Q,$){if($)return Q==="partial_failure"?"apply_failed":"apply_ok";return Q==="preview_with_errors"?"preview_blocked":"preview_ok"}function HG(Q,$){let Y=$V($,Q);return{target:Q,status:"error",count:0,components:[],configActions:[],error:Y.message,blockers:[Y]}}function $V(Q,$){let Y=Q instanceof Error?Q.message:String(Q);return{code:YV(Q,Y),message:Y,path:$}}function YV(Q,$){if(typeof Q==="object"&&Q!==null&&"code"in Q){let q=Q.code;if(typeof q==="string"&&q.length>0)return q}let Y=$.toLowerCase();if(Y.includes("ocx.jsonc")||Y.includes("registry"))return"CONFIG_ERROR";if(Y.includes("parse")||Y.includes("invalid"))return"VALIDATION_ERROR";return"MIGRATE_BLOCKER"}async function qV(Q,$,Y,q){let J=f6(Y),X=S8(Y),H=T9(Y,{isFlattened:q}),G=X.exists&&H.exists;if(X.exists&&J.length===0&&!G){let M={success:!0,status:"already_v2",scope:$,count:0,components:[],configActions:[]};if(Q.json){d9(M,Boolean(Q.apply));return}if(!Q.quiet)_.success(`[${$}] Already migrated to receipt format (.ocx/receipt.jsonc).`);return}if(!H.exists&&!X.exists&&J.length===0){let M={success:!0,status:"nothing_to_migrate",scope:$,count:0,components:[],configActions:[]};if(Q.json){d9(M,Boolean(Q.apply));return}if(!Q.quiet)_.info(`[${$}] Nothing to migrate. No legacy ocx.lock found.`);return}let K=null;if(H.exists&&!X.exists){let M=await L2(Y,{isFlattened:q});if(!M)throw new L("Failed to parse ocx.lock. The lock file exists but could not be read or contains invalid data.");let V=await b0(Y);if(!V)throw new h("No ocx.jsonc found. The config is required to resolve registry URLs during migration.");let{receipt:U,components:R}=r3(M,V,Y);K={newReceipt:U,components:R}}let W=K?.components??[],z=W.length;if(!Q.apply){let M={success:!0,status:"preview",scope:$,count:z,components:W,configActions:J};if(Q.json){d9(M,!1);return}if(!Q.quiet){if(z>0){_.info(`[${$}] Migration preview: ${z} component(s) would be migrated.`),_.break();for(let V of W)_.info(` ${V.legacyKey} \u2192 ${V.canonicalId}`);_.break()}if(G)_.info(`[${$}] Legacy ocx.lock would be backed up and removed (receipt already exists).`),_.break();if(J.length>0){_.info(`[${$}] Config normalization: ${J.length} deprecated field(s) would be removed.`);for(let V of J)_.info(` registries.${V.registry}.${V.field} \u2192 remove`);_.break()}if(z===0&&J.length===0&&!G)_.info(`[${$}] Nothing to migrate.`);else _.info("No changes made. Run with --apply to perform migration.")}return}if(K){await T0(Y,K.newReceipt);let M=t3(H.path);if(await a3(H.path,M),!Q.json&&!Q.quiet){_.success(`[${$}] Migrated ${z} component(s) to receipt format (.ocx/receipt.jsonc).`),_.break();for(let V of W)_.success(` \u2713 ${V.legacyKey} \u2192 ${V.canonicalId}`);_.break(),_.info(`Legacy lock backed up to: ${M}`)}}if(G){let M=t3(H.path);if(await a3(H.path,M),!Q.json&&!Q.quiet)_.success(`[${$}] Removed stale legacy lock (receipt already exists).`),_.info(`Legacy lock backed up to: ${M}`)}if(J.length>0){if(await WG(Y,J),!Q.json&&!Q.quiet){if(K)_.break();_.success(`[${$}] Normalized ${J.length} deprecated config field(s).`);for(let M of J)_.success(` \u2713 registries.${M.registry}.${M.field} removed`)}}let Z={success:!0,status:K!==null||G||J.length>0?"migrated":"already_v2",scope:$,count:z,components:W,configActions:J};if(Q.json){d9(Z,!0);return}if(!K&&J.length>0&&!Q.quiet)_.break(),_.success(`[${$}] Config normalization complete.`)}function JV(Q,$,Y){if($.status==="nothing_to_migrate"){_.info("[global] Nothing to migrate across all targets.");return}if($.status==="already_v2"){_.success("[global] All targets already migrated.");return}_.info(`[global] Migration preview across ${Q.length} target(s):`),_.break();for(let q of Q){let J=Y.has(q.target),X=HV(q,J);_.info(` ${q.target}: ${X}`)}if(_.break(),$.status==="preview_with_errors")_.warn("[global] Preview completed with errors on some targets. See above for details."),_.info("No changes made. Run with --apply to perform migration.");else _.info("No changes made. Run with --apply to perform migration.")}function XV(Q,$){_.break();let Y=Q.filter((X)=>X.status==="migrated"),q=Q.filter((X)=>X.status==="already_v2"||X.status==="nothing_to_migrate"),J=Q.filter((X)=>X.status==="error");if(Y.length>0){_.success(`[global] Migrated ${Y.length} target(s):`);for(let X of Y)_.success(` \u2713 ${X.target}`)}if(q.length>0)_.info(`[global] ${q.length} target(s) already up to date.`);if(J.length>0){_.error(`[global] ${J.length} target(s) failed:`);for(let X of J)_.error(` \u2717 ${X.target}: ${X.error}`)}if($)_.break(),_.error("[global] Migration completed with errors. See above for details.")}function HV(Q,$){if(Q.status==="error")return"error";if(Q.status==="already_v2")return"already migrated";if(Q.status==="nothing_to_migrate")return"nothing to migrate";let Y=[];if(Q.count>0)Y.push(`${Q.count} component(s) to migrate`);if(Q.configActions.length>0)Y.push(`${Q.configActions.length} config field(s) to normalize`);if($)Y.push("legacy lock cleanup pending");if(Y.length===0)return"nothing to migrate";return Y.join(", ")}function GV(Q){if(Q.global)return Q.cwd??j0();return Q.cwd??process.cwd()}function t3(Q){let $=`${Q}.bak`;if(!h6($))return $;for(let Y=1;Y<=100;Y++){let q=`${$}.${Y}`;if(!h6(q))return q}return`${$}.${Date.now()}`}function f6(Q){let $=E8(Q);if(!$.exists)return[];try{let Y=GG($.path,"utf-8"),q=O1(Y,[],{allowTrailingComma:!0});if(!q||typeof q!=="object"||Array.isArray(q))return[];return YG(q)}catch{return[]}}async function WG(Q,$){if($.length===0)return;let Y=E8(Q);if(!Y.exists)return;let q=GG(Y.path,"utf-8");for(let J of $){let X=Z9(q,["registries",J.registry,J.field],void 0,KV);q=M9(q,X)}await cU(Y.path,q)}var dU=1,KV;var zG=A(()=>{O0();q0();t();y1();c1();k8();qG();KV={formattingOptions:{tabSize:2,insertSpaces:!0,eol:`
170
+ `}}});import{basename as WV,resolve as dR}from"path";function e3(){let{GIT_DIR:Q,GIT_WORK_TREE:$,...Y}=process.env;return Y}async function zV(Q){let $=Bun.spawn(["git","symbolic-ref","--short","HEAD"],{cwd:Q,env:e3(),stdout:"pipe",stderr:"pipe"});if(await $.exited===0){let K=(await new Response($.stdout).text()).trim();if(K)return K}let q=Bun.spawn(["git","describe","--tags","--exact-match","HEAD"],{cwd:Q,env:e3(),stdout:"pipe",stderr:"pipe"});if(await q.exited===0){let K=(await new Response(q.stdout).text()).trim();if(K)return K}let X=Bun.spawn(["git","rev-parse","--short","HEAD"],{cwd:Q,env:e3(),stdout:"pipe",stderr:"pipe"});if(await X.exited===0){let K=(await new Response(X.stdout).text()).trim();if(K)return K}return null}async function BV(Q){let $=Bun.spawn(["git","rev-parse","--show-toplevel"],{cwd:Q,env:e3(),stdout:"pipe",stderr:"pipe"});if(await $.exited!==0)return null;let J=(await new Response($.stdout).text()).trim();if(!J)return null;return WV(J)}async function BG(Q){let[$,Y]=await Promise.all([BV(Q),zV(Q)]);return{repoName:$,branch:Y}}var _G=()=>{};import _V from"path";function ZV(Q){return Q<=31||Q>=127&&Q<=159}function MG(){return Boolean(process.env.TMUX)}function MV(Q){if(!MG())return;Bun.spawnSync(["tmux","rename-window",Q]),Bun.spawnSync(["tmux","set-window-option","automatic-rename","off"])}function UV(Q){if(!u6())return;let $=VV(Q);if(!$)return;process.stdout.write(`\x1B]0;${$}\x07`)}function VV(Q){let $="";for(let Y of Q){let q=Y.codePointAt(0);if(q===void 0)continue;$+=ZV(q)?" ":Y}return $.trim()}function u6(){return l8}function UG(Q){MV(Q),UV(Q)}function VG(){if(Q7||!l8)return;process.stdout.write("\x1B[22;2t"),Q7=!0}function m6(){if(!Q7)return;if(MG())Bun.spawnSync(["tmux","set-window-option","automatic-rename","on"]);if(l8)process.stdout.write("\x1B[23;2t");Q7=!1}function AG(Q,$,Y){let q=Y.repoName??_V.basename(Q);if(!Y.branch)return`ocx[${$}]:${q}`;let J=Y.branch.length>ZG?`${Y.branch.slice(0,ZG-3)}...`:Y.branch;return`ocx[${$}]:${q}/${J}`}var ZG=20,Q7=!1;var LG=A(()=>{F2()});import{randomUUID as AV}from"crypto";import{copyFile as LV,cp as FV,lstat as C8,mkdir as jV,mkdtemp as wV,readdir as wG,readFile as DV,realpath as l9,rename as OV,rm as IV,unlink as NV}from"fs/promises";import{tmpdir as TV}from"os";import{basename as bV,dirname as d6,isAbsolute as DG,join as U8,relative as p6}from"path";var{Glob:g6}=globalThis.Bun;function p(Q,$){return new h(`ocx oc ${Q} error: ${$}`)}function P1(Q){if(Q instanceof Error)return Q.message;return String(Q)}function kV(Q){if(Q.length===0)return"Unknown parse error";let $=Q[0];if(!$)return"Unknown parse error";return`${n0($.error)} at offset ${$.offset}`}function Y7(Q){return Q.replaceAll("\\","/")}function c6(Q){return Q.startsWith("./")?Q.slice(2):Q}function l6(Q,$){let Y=p6(Q,$);if(Y.length===0)return!0;return!Y.startsWith("..")&&!DG(Y)}function vV(Q){if(Q.isFile())return"file";if(Q.isDirectory())return"directory";if(Q.isSymbolicLink())return"symlink";return"other"}function x2(Q){return{entryType:vV(Q),device:String(Q.dev),inode:String(Q.ino),mode:String(Q.mode),size:String(Q.size),mtimeMs:String(Q.mtimeMs)}}function PV(Q,$){return Q.entryType===$.entryType&&Q.device===$.device&&Q.inode===$.inode&&Q.mode===$.mode}function xV(Q,$){return Q.size===$.size&&Q.mtimeMs===$.mtimeMs}async function p9(Q){let $;try{$=await C8(Q.absolutePath)}catch{throw p("validate",`Overlay path changed during ${Q.phase}: ${Q.overlayRelativePath}. ${x8}`)}if(Q.mustRemainDirectory&&!$.isDirectory())throw p("validate",`Overlay path changed during ${Q.phase}: ${Q.overlayRelativePath}. ${x8}`);if(Q.mustRemainFile&&!$.isFile())throw p("validate",`Overlay path changed during ${Q.phase}: ${Q.overlayRelativePath}. ${x8}`);let Y=x2($),q=PV(Q.expectedSnapshot,Y),X=!(Q.compareContent??!0)?!0:xV(Q.expectedSnapshot,Y);if(!q||!X)throw p("validate",`Overlay path changed during ${Q.phase}: ${Q.overlayRelativePath}. ${x8}`)}async function $7(Q,$,Y){let J=Y7(p6(Q,$)).split("/").filter((H)=>H.length>0),X=Q;for(let H of J){X=U8(X,H);let G;try{G=await C8(X)}catch(K){if(K.code==="ENOENT")return;throw p("validate",`Failed to inspect overlay destination path (${Y}): ${P1(K)}`)}if(G.isSymbolicLink())throw p("validate",`Overlay destination path contains existing symlink (${Y})`)}}function FG(Q,$,Y){for(let q of Y)try{new g6(c6(q))}catch{throw p("validate",`Invalid project overlay policy at ${Q}: ${$} contains invalid glob pattern "${q}"`)}}async function yV(Q){if(!Q)return{include:[],exclude:[]};let $=U8(Q,d0),Y=await hV(Q,$);if(!Y)return{include:[],exclude:[]};let q;try{q=await DV(Y,"utf8")}catch(W){throw p("read",`Failed to read project overlay policy at ${$}: ${P1(W)}`)}let J=[],X=O1(q,J,{allowTrailingComma:!0});if(J.length>0)throw p("parse",`Failed to parse project overlay policy at ${$}: ${kV(J)}`);if(!X||typeof X!=="object"||Array.isArray(X))throw p("validate",`Invalid project overlay policy at ${$}: root must be an object`);let H=CV.safeParse(X);if(!H.success){let W=H.error.issues[0],z=W?.path.length?W.path.join("."):"root",B=W?.message??"Invalid project overlay policy";throw p("validate",`Invalid project overlay policy at ${$}: ${z} ${B}`)}let G=H.data.include??[],K=H.data.exclude??[];return FG($,"include",G),FG($,"exclude",K),{include:G,exclude:K}}async function hV(Q,$){let Y;try{Y=await C8($)}catch(X){let H=X.code;if(H==="ENOENT"||H==="ENOTDIR")return null;throw p("read",`Failed to inspect project overlay policy at ${$}: ${P1(X)}`)}if(!Y.isSymbolicLink())return $;let q;try{q=await l9(Q)}catch(X){throw p("validate",`Unable to resolve project config directory ${Q}: ${P1(X)}`)}let J;try{J=await l9($)}catch(X){let H=X.code;if(H==="ENOENT"||H==="ENOTDIR")throw p("validate",`Broken symlink in project overlay policy: ${$}`);throw p("read",`Failed to inspect project overlay policy symlink at ${$}: ${P1(X)}`)}if(!l6(q,J))throw p("validate",`Symlink escapes project overlay policy scope: ${$}`);return J}function fV(Q,$){for(let Y of $.include)if(new g6(c6(Y)).match(Q))return!0;for(let Y of $.exclude)if(new g6(c6(Y)).match(Q))return!1;return!0}function uV(Q,$){return Q.filter((Y)=>fV(Y.overlayRelativePath,$)).map((Y)=>({sourcePath:Y.sourcePath,destinationRelativePath:Y.overlayRelativePath,sourceSnapshot:Y.sourceSnapshot}))}async function OG(Q,$,Y){let q;try{q=await l9($)}catch(J){let X=J.code;if(X==="ENOENT"||X==="ENOTDIR")throw p("validate",`Broken symlink in project overlay scope: ${Y}`);throw p("read",`Failed to inspect symlink at ${Y}: ${P1(J)}`)}if(!l6(Q,q))throw p("validate",`Symlink escapes project overlay scope: ${Y}`);throw p("validate",`Symlink entries are not supported in project overlay scope: ${Y}`)}async function IG(Q,$,Y,q,J){let X;try{X=await C8($)}catch(G){throw p("read",`Failed to inspect project overlay path ${Y}: ${P1(G)}`)}if(X.isSymbolicLink())await OG(Q,$,Y);let H=x2(X);if(X.isDirectory()){await J.beforeDirectoryRead?.({absolutePath:$,overlayRelativePath:Y});let G;try{G=await wG($)}catch(K){throw p("read",`Failed to read project overlay directory ${Y}: ${P1(K)}`)}G.sort((K,W)=>K.localeCompare(W));for(let K of G){let W=U8($,K),z=Y7(U8(Y,K));await IG(Q,W,z,q,J)}await p9({absolutePath:$,overlayRelativePath:Y,expectedSnapshot:H,phase:"overlay discovery",mustRemainDirectory:!0});return}if(!X.isFile())return;q.push({sourcePath:$,overlayRelativePath:Y7(Y),sourceSnapshot:H})}async function mV(Q,$={}){let Y;try{Y=await l9(Q)}catch(H){throw p("validate",`Unable to resolve project config directory ${Q}: ${P1(H)}`)}let q;try{q=await C8(Q)}catch(H){throw p("validate",`Unable to inspect project overlay root ${Q}: ${P1(H)}`)}if(!q.isDirectory())throw p("validate",`Project overlay root changed before discovery: ${Q}. ${x8}`);let J=x2(q),X=[];for(let H of RV){let G=U8(Q,H);await $.beforeScopeInspect?.({scope:H,scopeAbsolutePath:G,projectConfigDir:Q}),await p9({absolutePath:Q,overlayRelativePath:".opencode",expectedSnapshot:J,phase:"overlay discovery",mustRemainDirectory:!0});let K;try{K=await C8(G)}catch(W){let z=W.code;if(z==="ENOENT"||z==="ENOTDIR")continue;throw p("read",`Failed to inspect project overlay scope ${H}: ${P1(W)}`)}if(K.isSymbolicLink())await OG(Y,G,H);await IG(Y,G,H,X,$)}return X.sort((H,G)=>H.overlayRelativePath.localeCompare(G.overlayRelativePath)),X}function gV(Q){let $=d6(Q),Y=bV(Q),q=`${process.pid}-${AV()}`;return U8($,`.${Y}.ocx-tmp-${q}`)}async function cV(Q,$){let Y=gV($);try{await LV(Q,Y),await OV(Y,$)}catch(q){try{await NV(Y)}catch{}throw q}}async function dV(Q,$,Y={}){let q=Y.publishAtomically??cV,J;try{J=await C8($)}catch(H){throw p("validate",`Unable to inspect merged overlay root ${$}: ${P1(H)}`)}if(!J.isDirectory())throw p("validate",`Merged overlay root is not a directory: ${$}`);let X=x2(J);for(let H of Q){if(await Y.beforeSourceVerification?.(H),H.sourceSnapshot)await p9({absolutePath:H.sourcePath,overlayRelativePath:H.destinationRelativePath,expectedSnapshot:H.sourceSnapshot,phase:"overlay source verification",mustRemainFile:!0});await p9({absolutePath:$,overlayRelativePath:".merged",expectedSnapshot:X,phase:"overlay destination verification",mustRemainDirectory:!0,compareContent:!1});let G;try{G=A0($,H.destinationRelativePath)}catch(B){throw p("validate",`Overlay destination path is invalid (${H.destinationRelativePath}): ${P1(B)}`)}await $7($,G,H.destinationRelativePath);let K=d6(G);await Y.beforeDestinationParentCreate?.({operation:H,destinationPath:G,destinationParentPath:K}),await $7($,G,H.destinationRelativePath);try{await jV(K,{recursive:!0})}catch(B){throw p("copy",`Failed to copy overlay file ${H.destinationRelativePath}: ${P1(B)}`)}await $7($,G,H.destinationRelativePath);let W;try{W=await C8(K)}catch(B){throw p("validate",`Failed to inspect overlay destination parent (${H.destinationRelativePath}): ${P1(B)}`)}if(!W.isDirectory())throw p("validate",`Overlay destination parent changed before publish (${H.destinationRelativePath}). ${x8}`);let z=x2(W);await Y.beforeDestinationPublish?.({operation:H,destinationPath:G,destinationParentPath:K}),await p9({absolutePath:$,overlayRelativePath:".merged",expectedSnapshot:X,phase:"overlay destination publish",mustRemainDirectory:!0,compareContent:!1}),await p9({absolutePath:K,overlayRelativePath:H.destinationRelativePath,expectedSnapshot:z,phase:"overlay destination publish",mustRemainDirectory:!0,compareContent:!1}),await $7($,G,H.destinationRelativePath);try{await q(H.sourcePath,G)}catch(B){if(B instanceof h)throw B;throw p("copy",`Failed to copy overlay file ${H.destinationRelativePath}: ${P1(B)}`)}}}async function pV(Q,$){let Y;try{Y=await wG(Q)}catch(q){throw p("copy",`Failed to read profile directory ${Q}: ${P1(q)}`)}for(let q of Y){let J=U8(Q,q),X=U8($,q);try{await FV(J,X,{recursive:!0,force:!0,errorOnExist:!1})}catch(H){throw p("copy",`Failed to copy profile base file ${q}: ${P1(H)}`)}}}async function jG(Q){try{await IV(Q,{recursive:!0,force:!0})}catch($){throw p("cleanup",`Failed to remove temporary merged config directory ${Q}: ${P1($)}`)}}function lV(Q,$){let Y=Y7(p6(Q,$));if(!Y||Y===".")throw p("validate",`Overlay source path failed relative parsing: ${$}`);if(Y===".."||Y.startsWith("../")||DG(Y))throw p("validate",`Overlay source path escapes project overlay scope: ${$}`);return Y}function iV(Q,$){let Y=$.map((q)=>{if(!q.sourceSnapshot)throw p("validate",`Overlay source snapshot missing for ${q.destinationRelativePath}. ${x8}`);return{sourceRelativePath:lV(Q,q.sourcePath),destinationRelativePath:q.destinationRelativePath,sourceSnapshot:q.sourceSnapshot}});return{version:EV,projectConfigDir:Q,operations:Y}}function nV(){return null}async function oV(Q){let $=Q.manifest.operations.map((Y)=>({sourcePath:A0(Q.manifest.projectConfigDir,Y.sourceRelativePath),destinationRelativePath:Y.destinationRelativePath,sourceSnapshot:Y.sourceSnapshot}));await dV($,Q.mergedConfigDir,Q.copySeams)}async function sV(Q){if(Q.manifest.operations.length===0)return"best-effort-js";let $=Q.nativeHelper??nV();if($)return await $.applyManifest(Q.manifest,Q.mergedConfigDir),"native-fd";if(Q.hardeningMode==="native-fd-required")throw p("validate",`Native fd helper required for overlay merge, but none is available in this Bun/Node runtime. ${x8}`);return await oV({manifest:Q.manifest,mergedConfigDir:Q.mergedConfigDir,copySeams:Q.copySeams}),"best-effort-js"}async function rV(Q){let $=d6(Q),Y;try{Y=await l9($)}catch(J){throw p("validate",`Unable to resolve project directory ${$}: ${P1(J)}`)}let q;try{q=await l9(Q)}catch(J){throw p("validate",`Unable to resolve project config directory ${Q}: ${P1(J)}`)}if(!l6(Y,q))throw p("validate",`Project .opencode root resolves outside project directory: ${Q}`);return q}function aV(Q){if(Q instanceof h)return Q;return p("copy",`Failed to prepare temporary merged config directory: ${P1(Q)}`)}async function NG(Q){let $=M8(Q.projectDir),Y=Q.hardeningMode??"best-effort-js",q=null;try{q=await wV(U8(TV(),SV)),await pV(Q.profileDir,q);let J="best-effort-js";if($){let H=await rV($),G=await yV(H),K=await mV(H,Q.seams?.collection),W=uV(K,G),z=iV(H,W);J=await sV({manifest:z,mergedConfigDir:q,hardeningMode:Y,copySeams:Q.seams?.copy,nativeHelper:Q.seams?.nativeHelper})}let X=q;return{path:X,cleanup:()=>jG(X),hardeningLevel:J}}catch(J){let X=aV(J);if(q)try{await jG(q)}catch(H){X.message=`${X.message}
171
+ Cleanup warning: ${P1(H)}`}throw X}}var RV,SV="ocx-oc-merged-",EV=1,x8="Full TOCTOU/symlink-swap hardening requires an fd-based native helper transaction.",CV;var TG=A(()=>{O0();H8();W0();t();g8();RV=["agent","agents","skill","skills"];CV=Q1({include:R1(F()).optional(),exclude:R1(F()).optional()}).passthrough()});import*as _0 from"path";function q7(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}function QA(Q){if(Q.length===0)return"Unknown parse error";let $=Q[0];if(!$)return"Unknown parse error";return`${n0($.error)} at offset ${$.offset}`}function J7(Q){if(Q.length===0)return"$";let $="";for(let Y of Q){if(typeof Y==="number"){$+=`[${Y}]`;continue}$=$.length===0?Y:`${$}.${Y}`}return $}function C2(Q,$,Y,q){if(Q===void 0)return;if(q7(Q)){for(let[J,X]of Object.entries(Q))C2(X,$,[...Y,J],q);return}if(Array.isArray(Q)){for(let[J,X]of Q.entries())C2(X,$,[...Y,J],q);return}q.set(J7(Y),$)}function $A(Q,$,Y,q){let J=Array.from(new Set([...Q,...$])),X=new Map;for(let H of Q)if(!X.has(H))X.set(H,"profile");for(let H of $)if(!X.has(H))X.set(H,"local");for(let[H,G]of J.entries())q.set(J7([...Y,H]),X.get(G)??"local")}function YA(Q,$,Y,q){let J=[...Q,...$],X=n4(J),H=new Map;for(let G=J.length-1;G>=0;G--){let K=J[G];if(!K)continue;let W=D2(K);if(!H.has(W))H.set(W,G<Q.length?"profile":"local")}for(let[G,K]of X.entries()){let W=D2(K);q.set(J7([...Y,G]),H.get(W)??"local")}}function bG(Q,$){return Q.length===1&&Q[0]===$}function RG(Q){let{profileValue:$,localValue:Y,pathSegments:q,origins:J}=Q;if(Y===void 0){C2($,"profile",q,J);return}if($===void 0){C2(Y,"local",q,J);return}if(q7($)&&q7(Y)){let X=new Set([...Object.keys($),...Object.keys(Y)]);for(let H of X)RG({profileValue:$[H],localValue:Y[H],pathSegments:[...q,H],origins:J});return}if(Array.isArray($)&&Array.isArray(Y)){if(bG(q,"instructions")){if($.every((X)=>typeof X==="string")&&Y.every((X)=>typeof X==="string")){$A($,Y,q,J);return}}if(bG(q,"plugin")){if($.every((X)=>typeof X==="string")&&Y.every((X)=>typeof X==="string")){YA($,Y,q,J);return}}}C2(Y,"local",q,J)}function qA(Q){let $=new Map;return RG({profileValue:Q.profileConfig,localValue:Q.localConfig,pathSegments:[],origins:$}),$}function JA(Q){if(!Q.startsWith("{file:"))return null;if(!Q.endsWith("}"))return null;let $=Q.slice(6,-1);return $.length>0?$:null}function XA(Q){return/^[A-Za-z]:[\\/]/.test(Q)}function HA(Q){if(Q.startsWith("~"))return!1;if(_0.isAbsolute(Q))return!1;if(XA(Q))return!1;return!0}function GA(Q){let $=JA(Q.value);if(!$)return Q.value;let Y=J7(Q.pathSegments);if(Q.origins.get(Y)!=="profile")return Q.value;if(!HA($))return Q.value;return`{file:${_0.resolve(Q.profileDir,$)}}`}function i6(Q){let{value:$,pathSegments:Y,origins:q,profileDir:J}=Q;if(typeof $==="string")return GA({value:$,pathSegments:Y,origins:q,profileDir:J});if(Array.isArray($))return $.map((X,H)=>i6({value:X,pathSegments:[...Y,H],origins:q,profileDir:J}));if(q7($)){let X={};for(let[H,G]of Object.entries($))X[H]=i6({value:G,pathSegments:[...Y,H],origins:q,profileDir:J});return X}return $}async function KA(Q){let $=M8(Q);if(!$)return{};let Y=_0.join($,w2),q=Bun.file(Y);if(!await q.exists())return{};let J;try{J=await q.text()}catch(G){let K=G instanceof Error?G.message:"Unknown read error";throw new h(`Failed to read local OpenCode config at ${Y}: ${K}`)}let X=[],H=O1(J,X,{allowTrailingComma:!0});if(X.length>0){let G=QA(X);throw new h(`Invalid JSONC in local OpenCode config at ${Y}: ${G}`)}if(!H||typeof H!=="object"||Array.isArray(H))throw new h(`Invalid local OpenCode config at ${Y}: root must be an object`);return H}async function WA(Q){let $=await KA(Q.projectDir),Y=qA({profileConfig:Q.profileConfig,localConfig:$});return i6({value:Q.mergedConfig,pathSegments:[],origins:Y,profileDir:Q.profileDir})}function zA(Q){let $=new Set,Y=[];for(let q=Q.length-1;q>=0;q--){let J=Q[q];if(!$.has(J))$.add(J),Y.unshift(J)}return Y}function BA(Q){return Q.configBin??Q.envBin??"opencode"}function SG(Q){return Q.includes("/")||Q.includes("\\")}function _A(Q){let{configuredBin:$,cwd:Y}=Q,q=Q.resolveExecutable??((X)=>Bun.which(X));if(!$.trim())throw Error("OpenCode launcher is empty and cannot be resolved to a stable path");if(SG($))return _0.isAbsolute($)?$:_0.resolve(Y,$);let J=q($);if(!J)throw Error(`OpenCode launcher "${$}" is not available in PATH and cannot be used as OPENCODE_BIN`);return _0.isAbsolute(J)?J:_0.resolve(Y,J)}function ZA(Q){let $=Q.resolveExecutable??((W)=>Bun.which(W)),Y=Q.argv??process.argv,q=Q.execPath??process.execPath,J=Q.isCompiledBinary??(typeof Bun<"u"&&typeof Bun.main==="string"&&Bun.main.startsWith("/$bunfs/")),X=Q.inheritedOcxBin?.trim(),H=J?q:Y[1],G=X&&X.length>0?X:H;if(!G?.trim())throw Error("OCX executable path is empty and cannot be resolved from the current process");if(SG(G))return _0.isAbsolute(G)?G:_0.resolve(Q.cwd,G);let K=$(G);if(!K)throw Error(`OCX executable "${G}" is not available in PATH and cannot be persisted as OCX_BIN`);return _0.isAbsolute(K)?K:_0.resolve(Q.cwd,K)}function MA(Q){let $=Boolean(Q.profileName),{OPENCODE_DISABLE_PROJECT_CONFIG:Y,OPENCODE_BIN:q,OCX_CONTEXT:J,OCX_BIN:X,OCX_PROFILE:H,OCX_TITLE_CONTEXT:G,...K}=Q.baseEnv;return{...K,...Q.opencodeBin!==void 0&&{OPENCODE_BIN:Q.opencodeBin},...$&&{OPENCODE_DISABLE_PROJECT_CONFIG:"true"},OPENCODE_CONFIG_DIR:Q.configDir??($?f1(Q.profileName):j0()),...Q.configContent&&{OPENCODE_CONFIG_CONTENT:Q.configContent},...$&&{OCX_CONTEXT:"1"},...$&&Q.ocxBin&&{OCX_BIN:Q.ocxBin},...Q.profileName&&{OCX_PROFILE:Q.profileName},...Q.titleContext&&{OCX_TITLE_CONTEXT:JSON.stringify(Q.titleContext)}}}function EG(Q){let $=Q.command("oc").alias("opencode").description("Launch OpenCode with resolved configuration").option("-p, --profile <name>","Use specific profile").option("--no-rename","Disable terminal/tmux window renaming").allowUnknownOption().allowExcessArguments(!0);B0($),$.action(async(Y,q)=>{try{await VA(q.args,Y)}catch(J){s(J)}})}function UA(){let Q=null,$=null,Y=null,q=!1,J=()=>{if(!$)return;clearTimeout($),$=null},X=()=>{if(!Q)return;if(q)return;q=!0,Q.kill("SIGKILL")},H=()=>{if($)return;$=setTimeout(()=>{X()},tV)},G=(K)=>{if(Y??=eV[K],!Q)return;if($||q){X();return}Q.kill(K),H()};return{attachChild(K){Q=K},clearGraceTimer:J,getRememberedSignalExitCode(){return Y},handleSigint(){G("SIGINT")},handleSigterm(){G("SIGTERM")}}}async function VA(Q,$){let Y=process.cwd(),q=await e0.create(Y,{profile:$.profile}),J=q.resolve(),X=q.getProfile();if(J.profileName)_.info(`Using profile: ${J.profileName}`);let H=X?.ocx,G=$.rename!==!1&&H?.renameWindow!==!1;if(J.profileName){let I=Z8(J.profileName);if(!await Bun.file(I).exists())_.warn(`No opencode.jsonc found at ${I}. Create one to customize OpenCode settings.`)}let K=J.opencode;if(J.profileName)K=await WA({mergedConfig:J.opencode,profileConfig:X?.opencode??{},projectDir:Y,profileDir:f1(J.profileName)});let W=Array.isArray(K.instructions)?K.instructions:[],z=[...J.instructions,...W],B=zA(z),Z=B.length>0||Object.keys(K).length>0?{...K,instructions:B.length>0?B:void 0}:void 0,M=null,V=null,U=null,R=null,N=UA(),c=()=>N.handleSigint(),T=()=>N.handleSigterm(),x=()=>{if(G)m6()};try{if(process.on("SIGINT",c),process.on("SIGTERM",T),process.on("exit",x),N.getRememberedSignalExitCode()!==null){R=N.getRememberedSignalExitCode();return}if(J.profileName)V=await NG({projectDir:Y,profileDir:f1(J.profileName)});if(N.getRememberedSignalExitCode()!==null){R=N.getRememberedSignalExitCode();return}let I=G?await BG(Y):{repoName:null,branch:null};if(N.getRememberedSignalExitCode()!==null){R=N.getRememberedSignalExitCode();return}let w=AG(Y,J.profileName??"default",I),i={mayWriteOscTitle:G&&u6(),baseTitle:w};if(G)VG(),UG(w);if(N.getRememberedSignalExitCode()!==null){R=N.getRememberedSignalExitCode();return}let l=BA({configBin:H?.bin,envBin:process.env.OPENCODE_BIN}),r=Boolean(J.profileName),J1=r?_A({configuredBin:l,cwd:Y}):l,S=r?ZA({cwd:Y,inheritedOcxBin:process.env.OCX_BIN}):void 0,g=Z?JSON.stringify(Z):void 0;try{M=Bun.spawn({cmd:[J1,...Q],cwd:Y,env:MA({baseEnv:process.env,profileName:J.profileName??void 0,ocxBin:S,opencodeBin:J1,configDir:V?.path,configContent:g,titleContext:i}),stdin:"inherit",stdout:"inherit",stderr:"inherit"})}catch(E){throw p("spawn",`Failed to launch OpenCode binary "${l}": ${E instanceof Error?E.message:String(E)}`)}N.attachChild(M),R=await M.exited}catch(I){U=I instanceof Error?I:p("spawn",`OpenCode process failed: ${String(I)}`)}finally{if(N.clearGraceTimer(),process.off("SIGINT",c),process.off("SIGTERM",T),process.off("exit",x),G)m6();if(V)try{await V.cleanup()}catch(I){if(U!==null||N.getRememberedSignalExitCode()!==null||R!==null&&R!==0)_.warn(`Cleanup warning: ${I instanceof Error?I.message:String(I)}`);else U=I instanceof Error?I:p("cleanup",`Failed to remove temporary merged config directory: ${String(I)}`)}}if(U)throw U;let O=N.getRememberedSignalExitCode();if(O!==null)process.exit(O);if(R!==null)process.exit(R)}var tV=2500,eV;var kG=A(()=>{O0();O2();W0();I3();t();_G();y1();c1();k8();k0();LG();TG();eV={SIGINT:130,SIGTERM:143}});import{existsSync as i9}from"fs";import{mkdir as n6,mkdtemp as AA,rename as LA,rm as vG,writeFile as FA}from"fs/promises";import{dirname as PG,join as X7,relative as jA}from"path";function xG(Q,$,Y){let q=Y instanceof Error?Y.message:String(Y);return`${Q} "${$}" (${q})`}function fG(Q,$){let[Y,q]=$.split("/");if(!Y||!q)return;return`${g1(Q)}/components/${q}.json`}function CG(Q){if(!Q)return null;let[$,Y,...q]=Q.split("/");if(!$||!Y||q.length>0)return null;return{registryName:$,componentName:Y}}function wA(Q,$){if(!Q)return{};let Y;try{let H=new URL(Q),G=H.pathname.match(/(?:^|\/)components\/([^/]+)\.json$/);if(G?.[1])Y=decodeURIComponent(G[1]);else{let K=H.pathname.match(/(?:^|\/)components\/([^/]+)\/.+$/);if(K?.[1])Y=decodeURIComponent(K[1])}}catch{}let q=g1(Q),J,X=-1;for(let[H,G]of Object.entries($)){let K=g1(G.url);if(!(q===K||q.startsWith(`${K}/`))||K.length<=X)continue;J=H,X=K.length}return{registryName:J,componentName:Y}}function DA(Q){let $=Q.depRefs[0]??`${Q.namespace}/${Q.component}`,Y={...Q.profileRegistries,...Q.profileRegistries[Q.namespace]?{}:{[Q.namespace]:{url:Q.registryUrl}}},q=Q.error.registryName,J=Q.error.qualifiedName,X=CG(J);if(!q&&X)q=X.registryName;let H=X?.componentName,G=J&&!X&&!J.includes("/")?J:void 0,K=wA(Q.error.url,Y);if(!q&&K.registryName)q=K.registryName;let W=H??G??K.componentName;if((!J||!X)&&q&&W)J=`${q}/${W}`;if(!J)J=$;if(!q)q=CG(J)?.registryName??Q.namespace;let z=Y[q]?.url||(q===Q.namespace?Q.registryUrl:void 0);return{registryName:q,qualifiedName:J,fallbackUrl:Q.error.url||(z?fG(z,J):void 0)}}function yG(Q,$){let Y=Q.phase??$.fallbackPhase,q=Q.url??$.fallbackUrl,J=[`phase: ${Y}`,`qualifiedName: ${$.qualifiedName}`,`registryContext: ${$.registryContext}`,`registryName: ${$.registryName}`,...q?[`url: ${q}`]:[]];return new I1(`${Q.message} (${J.join(", ")})`,{url:q,status:Q.status,statusText:Q.statusText,phase:Y,qualifiedName:$.qualifiedName,registryContext:$.registryContext,registryName:$.registryName})}function hG(Q,$){if(!Q.startsWith(".opencode/"))throw new L(`Invalid embedded target "${Q}": expected .opencode/ prefix for embedded profile files.`);let Y=Q.slice(10);if(!Y)throw new L(`Invalid embedded target "${Q}": missing path after .opencode/ prefix.`);let q;try{q=A0($,Y)}catch(X){if(X instanceof e1)throw new L(`Invalid embedded target "${Q}": ${X.message}`);throw X}let J=jA($,q).replace(/\\/g,"/");if(J==="."||J==="")throw new L(`Invalid embedded target "${Q}": target must resolve to a file path.`);return J}async function o6(Q){let{namespace:$,component:Y,profileName:q,registryUrl:J,quiet:X}=Q;if(!a0.safeParse(q).success)throw new L(`Invalid profile name: "${q}". Profile names must start with a letter and contain only alphanumeric characters, dots, underscores, or hyphens.`);let G;if($)G=$;else throw new L(`Registry name is required for URL-based profile installs.
172
172
 
173
- Use a qualified component reference (e.g., 'my-registry/${Y}') or specify --name to provide a registry alias.`);let K=f1(q),W=`${G}/${Y}`;if(i9(K))throw new n1(`Profile "${q}" already exists. Remove it first with 'ocx profile rm ${q} --global'.`);let B=X?null:M1({text:`Fetching ${W}...`});B?.start();let Z;try{Z=await N2(J,Y)}catch(w){if(B?.fail(`Failed to fetch ${W}`),w instanceof I1)throw yG(w,{registryContext:"source",registryName:G,qualifiedName:W,fallbackPhase:"packument-fetch",fallbackUrl:fG(J,W)});if(w instanceof _1)throw new _1(`Profile component "${W}" not found in registry.
173
+ Use a qualified component reference (e.g., 'my-registry/${Y}') or specify --name to provide a registry alias.`);let K=f1(q),W=`${G}/${Y}`;if(i9(K))throw new n1(`Profile "${q}" already exists. Remove it first with 'ocx profile rm ${q} --global'.`);let B=X?null:M1({text:`Fetching ${W}...`});B?.start();let Z;try{Z=await N2(J,Y)}catch(O){if(B?.fail(`Failed to fetch ${W}`),O instanceof I1)throw yG(O,{registryContext:"source",registryName:G,qualifiedName:W,fallbackPhase:"packument-fetch",fallbackUrl:fG(J,W)});if(O instanceof _1)throw new _1(`Profile component "${W}" not found in registry.
174
174
 
175
- Check the component name and ensure the registry is configured.`);throw w}if(Z.type!=="profile")throw B?.fail("Invalid component type"),new L(`Component "${W}" is type "${Z.type}", not "profile".
175
+ Check the component name and ensure the registry is configured.`);throw O}if(Z.type!=="profile")throw B?.fail("Invalid component type"),new L(`Component "${W}" is type "${Z.type}", not "profile".
176
176
 
177
- Only profile components can be installed with 'ocx profile add --source <ns/comp> --global'.`);let M=d8(Z);B?.succeed(`Fetched ${W}`);let V=X?null:M1({text:"Downloading profile files..."});V?.start();let U=[],R=[];for(let w of M.files){let b=await a8(J,Y,w.path),D={path:w.path,target:w.target,content:Buffer.from(b)};if(w.target.startsWith(".opencode/"))R.push(D);else U.push(D)}V?.succeed(`Downloaded ${M.files.length} files`);let I=_8();await n6(I,{recursive:!0,mode:448});let c=await MA(X7(I,".staging-")),N=!1,x=!1;try{let w=X?null:M1({text:"Writing profile files..."});w?.start();let b=new Map;for(let i of U){let r=S9(i.target,c),J1=X7(c,r);Q9(b,{absolutePath:J1,relativePath:r,content:i.content,source:`${Y}:${i.path}`})}for(let i of R){let r=hG(i.target,c),J1=S9(r,c),S=X7(c,J1);Q9(b,{absolutePath:S,relativePath:J1,content:i.content,source:`${Y}:${i.path}`})}for(let i of b.values()){let r=i.absolutePath,J1=PG(r);if(!i9(J1))await n6(J1,{recursive:!0});await VA(r,i.content)}w?.succeed(`Wrote ${b.size} profile files`),await N0(c,{version:1,root:K,installed:{}});let D=X?null:M1({text:"Moving to profile directory..."});D?.start();let l=PG(K);if(!i9(l))await n6(l,{recursive:!0,mode:448});if(await UA(c,K),N=!0,D?.succeed("Profile installed"),Z.dependencies.length>0){let i=X?null:M1({text:"Installing dependencies..."});i?.start();let r=Z.dependencies.map((S)=>S.includes("/")?S:`${G}/${S}`),J1={};try{let S=X7(K,"ocx.jsonc");if(i9(S)){let C=await Bun.file(S).text(),e=O1(C),o=K8.safeParse(e);if(o.success)J1=o.data.registries??{};else if(J0(e)&&"registries"in e)throw new h(`Invalid registries in profile "${q}": ${o.error.message}`)}await k6(r,{profile:q,quiet:X},{cwd:K,getRegistries:()=>J1,getComponentPath:()=>""}),i?.succeed(`Installed ${Z.dependencies.length} dependencies`)}catch(S){if(i?.fail("Failed to install dependencies"),S instanceof I1){let u=FA({error:S,depRefs:r,namespace:G,component:Y,registryUrl:J,profileRegistries:J1});throw yG(S,{registryContext:"dependency",registryName:u.registryName,qualifiedName:u.qualifiedName,fallbackPhase:"packument-fetch",fallbackUrl:u.fallbackUrl})}throw S}}if(x=!0,!X){_.info(""),_.success(`Installed profile "${q}" from ${W}`),_.info(""),_.info("Profile contents:");for(let i of U)_.info(` ${i.target}`);for(let i of R){let r=hG(i.target,K);_.info(` ${r}`)}}}catch(w){let b=[];try{if(i9(c))await vG(c,{recursive:!0})}catch(D){b.push(xG("Profile add rollback cleanup warning: failed to remove staging directory",c,D))}if(N&&!x)try{if(i9(K))await vG(K,{recursive:!0,force:!0})}catch(D){b.push(xG("Profile add rollback cleanup warning: failed to remove promoted profile",K,D))}if(!X)for(let D of b)_.warn(D);throw w}}var uG=A(()=>{D0();W0();D3();t8();q0();b9();g0();g4();t();c1();g8();P3();l0();v6()});function jA(Q){if(!Q?.trim())throw new L("--source value cannot be empty");let $=Q.trim();if(($.match(/\//g)||[]).length!==1)throw new L(`Invalid --source format: "${Q}". Expected: namespace/component`);let[q,J]=$.split("/").map((X)=>X.trim());if(!q||!J)throw new L(`Invalid --source format: "${Q}". Expected: namespace/component`);return{namespace:q,component:J}}async function wA(){let Q="global ocx config";try{let $=await vJ();Q=$.path;let Y=$.content,q=O1(Y,[],{allowTrailingComma:!0});return K8.parse(q)}catch($){if($ instanceof v8)throw $;if($ instanceof Error)throw new h(`Failed to parse global config at "${Q}": ${$.message}
177
+ Only profile components can be installed with 'ocx profile add --source <ns/comp> --global'.`);let M=d8(Z);B?.succeed(`Fetched ${W}`);let V=X?null:M1({text:"Downloading profile files..."});V?.start();let U=[],R=[];for(let O of M.files){let I=await a8(J,Y,O.path),w={path:O.path,target:O.target,content:Buffer.from(I)};if(O.target.startsWith(".opencode/"))R.push(w);else U.push(w)}V?.succeed(`Downloaded ${M.files.length} files`);let N=_8();await n6(N,{recursive:!0,mode:448});let c=await AA(X7(N,".staging-")),T=!1,x=!1;try{let O=X?null:M1({text:"Writing profile files..."});O?.start();let I=new Map;for(let l of U){let r=S9(l.target,c),J1=X7(c,r);Q9(I,{absolutePath:J1,relativePath:r,content:l.content,source:`${Y}:${l.path}`})}for(let l of R){let r=hG(l.target,c),J1=S9(r,c),S=X7(c,J1);Q9(I,{absolutePath:S,relativePath:J1,content:l.content,source:`${Y}:${l.path}`})}for(let l of I.values()){let r=l.absolutePath,J1=PG(r);if(!i9(J1))await n6(J1,{recursive:!0});await FA(r,l.content)}O?.succeed(`Wrote ${I.size} profile files`),await T0(c,{version:1,root:K,installed:{}});let w=X?null:M1({text:"Moving to profile directory..."});w?.start();let i=PG(K);if(!i9(i))await n6(i,{recursive:!0,mode:448});if(await LA(c,K),T=!0,w?.succeed("Profile installed"),Z.dependencies.length>0){let l=X?null:M1({text:"Installing dependencies..."});l?.start();let r=Z.dependencies.map((S)=>S.includes("/")?S:`${G}/${S}`),J1={};try{let S=X7(K,"ocx.jsonc");if(i9(S)){let C=await Bun.file(S).text(),e=O1(C),o=K8.safeParse(e);if(o.success)J1=o.data.registries??{};else if(J0(e)&&"registries"in e)throw new h(`Invalid registries in profile "${q}": ${o.error.message}`)}await k6(r,{profile:q,quiet:X},{cwd:K,getRegistries:()=>J1,getComponentPath:()=>""}),l?.succeed(`Installed ${Z.dependencies.length} dependencies`)}catch(S){if(l?.fail("Failed to install dependencies"),S instanceof I1){let g=DA({error:S,depRefs:r,namespace:G,component:Y,registryUrl:J,profileRegistries:J1});throw yG(S,{registryContext:"dependency",registryName:g.registryName,qualifiedName:g.qualifiedName,fallbackPhase:"packument-fetch",fallbackUrl:g.fallbackUrl})}throw S}}if(x=!0,!X){_.info(""),_.success(`Installed profile "${q}" from ${W}`),_.info(""),_.info("Profile contents:");for(let l of U)_.info(` ${l.target}`);for(let l of R){let r=hG(l.target,K);_.info(` ${r}`)}}}catch(O){let I=[];try{if(i9(c))await vG(c,{recursive:!0})}catch(w){I.push(xG("Profile add rollback cleanup warning: failed to remove staging directory",c,w))}if(T&&!x)try{if(i9(K))await vG(K,{recursive:!0,force:!0})}catch(w){I.push(xG("Profile add rollback cleanup warning: failed to remove promoted profile",K,w))}if(!X)for(let w of I)_.warn(w);throw O}}var uG=A(()=>{O0();W0();D3();t8();q0();b9();c0();g4();t();c1();g8();P3();l0();v6()});function OA(Q){if(!Q?.trim())throw new L("--source value cannot be empty");let $=Q.trim();if(($.match(/\//g)||[]).length!==1)throw new L(`Invalid --source format: "${Q}". Expected: namespace/component`);let[q,J]=$.split("/").map((X)=>X.trim());if(!q||!J)throw new L(`Invalid --source format: "${Q}". Expected: namespace/component`);return{namespace:q,component:J}}async function IA(){let Q="global ocx config";try{let $=await vJ();Q=$.path;let Y=$.content,q=O1(Y,[],{allowTrailingComma:!0});return K8.parse(q)}catch($){if($ instanceof v8)throw $;if($ instanceof Error)throw new h(`Failed to parse global config at "${Q}": ${$.message}
178
178
 
179
- Check the file for syntax errors or run: ocx config edit --global`);throw $}}async function DA(Q){let $;try{$=await wA()}catch(q){if(q instanceof v8)throw new h(`Registry "${Q}" is not configured globally.
179
+ Check the file for syntax errors or run: ocx config edit --global`);throw $}}async function NA(Q){let $;try{$=await IA()}catch(q){if(q instanceof v8)throw new h(`Registry "${Q}" is not configured globally.
180
180
 
181
181
  Profile installation requires global registry configuration.
182
182
  ${q.message}
@@ -189,7 +189,7 @@ Examples:
189
189
  $ ocx profile add work --clone dev --global # Clone from existing global profile
190
190
  $ ocx profile add work --source kdco/minimal --global # Install from configured registry
191
191
  $ ocx profile add work --source kdco/minimal --from http://r.com --global # Install from ephemeral registry
192
- `).action(async($,Y)=>{try{let q=await OA($,Y);if(Y.json)F1({success:!0,data:q})}catch(q){s(q,{json:Y.json})}})}async function OA(Q,$){let Y=$.json===!0;if($.clone&&($.source||$.from))throw new L(`--clone cannot be used with --source or --from.
192
+ `).action(async($,Y)=>{try{let q=await TA($,Y);if(Y.json)F1({success:!0,data:q})}catch(q){s(q,{json:Y.json})}})}async function TA(Q,$){let Y=$.json===!0;if($.clone&&($.source||$.from))throw new L(`--clone cannot be used with --source or --from.
193
193
 
194
194
  Use one of:
195
195
  ocx profile add <name> --clone <profile> --global # Clone existing profile
@@ -225,37 +225,37 @@ Example: --from https://registry.example.com`)}catch(H){if(H instanceof L)throw
225
225
  --from must be a valid registry URL (http:// or https://).
226
226
  Example: --from https://registry.example.com`)}}if(!$.global)throw new h(`Local profiles are unsupported. Use --global to create a global profile.
227
227
 
228
- ocx profile add ${Q} --global`);let q="global",J=await u1.requireInitialized();if($.clone)return await NA(J,Q,$.clone,Y),{name:Q,scope:q,mode:"clone",cloneFrom:$.clone};if($.source){let{namespace:X,component:H}=jA($.source),G;if($.from)G=g1($.from.trim()),await o6({namespace:X,component:H,profileName:Q,registryUrl:G,quiet:Y});else G=(await DA(X)).registryUrl,await o6({namespace:X,component:H,profileName:Q,registryUrl:G,quiet:Y});return{name:Q,scope:q,mode:"registry",registry:{namespace:X,component:H,url:G,ephemeral:Boolean($.from)}}}return await IA(J,Q,Y),{name:Q,scope:q,mode:"empty"}}async function IA(Q,$,Y){if(await Q.exists($))throw new N8($,`Remove it first with 'ocx profile rm ${$} --global'.`);if(await Q.add($),!Y)_.success(`Created global profile "${$}"`)}async function NA(Q,$,Y,q){if(await Q.exists($))throw new N8($,`Remove it first with 'ocx profile rm ${$} --global'.`);try{await Q.get(Y)}catch(G){if(G instanceof C1)throw new C1(Y,`Profile '${Y}' not found in global scope.`);if(G instanceof B1)throw G;throw new L(`Failed to load profile '${Y}': ${G instanceof Error?G.message:String(G)}`)}await Q.add($);let X=K0(Y),H=K0($);if(await RJ(X,H),!q)_.success(`Created global profile "${$}" (cloned from "${Y}")`)}var gG=A(()=>{D0();j3();t0();W0();b9();t();y1();c1();uG()});function cG(Q){Q.command("list").alias("ls").description("List profiles (use --global; local profiles are unsupported)").option("-g, --global","List global profiles (required \u2014 local profiles are unsupported)").addOption(S0.json()).action(async($)=>{try{await TA($)}catch(Y){s(Y,{json:$.json})}})}async function TA(Q){if(!Q.global)throw new h(`Local profiles are unsupported. Use --global to list global profiles.
228
+ ocx profile add ${Q} --global`);let q="global",J=await u1.requireInitialized();if($.clone)return await RA(J,Q,$.clone,Y),{name:Q,scope:q,mode:"clone",cloneFrom:$.clone};if($.source){let{namespace:X,component:H}=OA($.source),G;if($.from)G=g1($.from.trim()),await o6({namespace:X,component:H,profileName:Q,registryUrl:G,quiet:Y});else G=(await NA(X)).registryUrl,await o6({namespace:X,component:H,profileName:Q,registryUrl:G,quiet:Y});return{name:Q,scope:q,mode:"registry",registry:{namespace:X,component:H,url:G,ephemeral:Boolean($.from)}}}return await bA(J,Q,Y),{name:Q,scope:q,mode:"empty"}}async function bA(Q,$,Y){if(await Q.exists($))throw new N8($,`Remove it first with 'ocx profile rm ${$} --global'.`);if(await Q.add($),!Y)_.success(`Created global profile "${$}"`)}async function RA(Q,$,Y,q){if(await Q.exists($))throw new N8($,`Remove it first with 'ocx profile rm ${$} --global'.`);try{await Q.get(Y)}catch(G){if(G instanceof C1)throw new C1(Y,`Profile '${Y}' not found in global scope.`);if(G instanceof B1)throw G;throw new L(`Failed to load profile '${Y}': ${G instanceof Error?G.message:String(G)}`)}await Q.add($);let X=K0(Y),H=K0($);if(await RJ(X,H),!q)_.success(`Created global profile "${$}" (cloned from "${Y}")`)}var gG=A(()=>{O0();j3();t0();W0();b9();t();y1();c1();uG()});function cG(Q){Q.command("list").alias("ls").description("List profiles (use --global; local profiles are unsupported)").option("-g, --global","List global profiles (required \u2014 local profiles are unsupported)").addOption(E0.json()).action(async($)=>{try{await SA($)}catch(Y){s(Y,{json:$.json})}})}async function SA(Q){if(!Q.global)throw new h(`Local profiles are unsupported. Use --global to list global profiles.
229
229
 
230
- ocx profile list --global`);let Y=await(await u1.requireInitialized()).list();if(Q.json){console.log(JSON.stringify({profiles:Y,initialized:!0},null,2));return}let q="Global profiles:",J="No global profiles found. Run 'ocx profile add <name> --global' to create one.";if(Y.length===0){console.log(J);return}console.log(q);for(let X of Y)console.log(` ${X}`)}var dG=A(()=>{t0();t();y1();d0()});function pG(Q){Q.command("move <old-name> <new-name>").alias("mv").description("Move (rename) a profile (use --global; local profiles are unsupported)").option("-g, --global","Move global profile (required \u2014 local profiles are unsupported)").option("--json","Output as JSON").action(async($,Y,q)=>{try{let J=await bA($,Y,q);if(q.json)F1({success:!0,data:J})}catch(J){s(J,{json:q.json})}})}async function bA(Q,$,Y){if(!Y.global)throw new h(`Local profiles are unsupported. Use --global to move a global profile.
230
+ ocx profile list --global`);let Y=await(await u1.requireInitialized()).list();if(Q.json){console.log(JSON.stringify({profiles:Y,initialized:!0},null,2));return}let q="Global profiles:",J="No global profiles found. Run 'ocx profile add <name> --global' to create one.";if(Y.length===0){console.log(J);return}console.log(q);for(let X of Y)console.log(` ${X}`)}var dG=A(()=>{t0();t();y1();k0()});function pG(Q){Q.command("move <old-name> <new-name>").alias("mv").description("Move (rename) a profile (use --global; local profiles are unsupported)").option("-g, --global","Move global profile (required \u2014 local profiles are unsupported)").option("--json","Output as JSON").action(async($,Y,q)=>{try{let J=await EA($,Y,q);if(q.json)F1({success:!0,data:J})}catch(J){s(J,{json:q.json})}})}async function EA(Q,$,Y){if(!Y.global)throw new h(`Local profiles are unsupported. Use --global to move a global profile.
231
231
 
232
- ocx profile move ${Q} ${$} --global`);let q=await u1.requireInitialized(),{warnActiveProfile:J}=await q.move(Q,$);if(J&&!Y.json)_.warn(`Moving active profile. Update OCX_PROFILE env var to "${$}".`);if(!Y.json)_.success(`Moved global profile "${Q}" \u2192 "${$}"`);return{from:Q,to:$,scope:"global",warnActiveProfile:J}}var lG=A(()=>{t0();t();y1();c1()});function iG(Q){Q.command("remove <name>").alias("rm").description("Delete a profile (use --global; local profiles are unsupported)").option("-g, --global","Remove global profile (required \u2014 local profiles are unsupported)").option("--json","Output as JSON").action(async($,Y)=>{try{let q=await RA($,Y);if(Y.json)F1({success:!0,data:q})}catch(q){s(q,{json:Y.json})}})}async function RA(Q,$){if(!$.global)throw new h(`Local profiles are unsupported. Use --global to remove a global profile.
232
+ ocx profile move ${Q} ${$} --global`);let q=await u1.requireInitialized(),{warnActiveProfile:J}=await q.move(Q,$);if(J&&!Y.json)_.warn(`Moving active profile. Update OCX_PROFILE env var to "${$}".`);if(!Y.json)_.success(`Moved global profile "${Q}" \u2192 "${$}"`);return{from:Q,to:$,scope:"global",warnActiveProfile:J}}var lG=A(()=>{t0();t();y1();c1()});function iG(Q){Q.command("remove <name>").alias("rm").description("Delete a profile (use --global; local profiles are unsupported)").option("-g, --global","Remove global profile (required \u2014 local profiles are unsupported)").option("--json","Output as JSON").action(async($,Y)=>{try{let q=await kA($,Y);if(Y.json)F1({success:!0,data:q})}catch(q){s(q,{json:Y.json})}})}async function kA(Q,$){if(!$.global)throw new h(`Local profiles are unsupported. Use --global to remove a global profile.
233
233
 
234
- ocx profile remove <name> --global`);let Y=await u1.requireInitialized();if(!await Y.exists(Q))throw new C1(Q);if(await Y.remove(Q),!$.json)_.success(`Deleted global profile "${Q}"`);return{name:Q,scope:"global"}}var nG=A(()=>{t0();t();y1();c1()});function oG(Q){Q.command("show [name]").description("Display profile contents (use --global; local profiles are unsupported)").option("-g, --global","Show global profile (required \u2014 local profiles are unsupported)").addOption(S0.json()).action(async($,Y)=>{try{await SA($,Y)}catch(q){s(q,{json:Y.json})}})}async function SA(Q,$){if(!$.global)throw new h(`Local profiles are unsupported. Use --global to show a global profile.
234
+ ocx profile remove <name> --global`);let Y=await u1.requireInitialized();if(!await Y.exists(Q))throw new C1(Q);if(await Y.remove(Q),!$.json)_.success(`Deleted global profile "${Q}"`);return{name:Q,scope:"global"}}var nG=A(()=>{t0();t();y1();c1()});function oG(Q){Q.command("show [name]").description("Display profile contents (use --global; local profiles are unsupported)").option("-g, --global","Show global profile (required \u2014 local profiles are unsupported)").addOption(E0.json()).action(async($,Y)=>{try{await vA($,Y)}catch(q){s(q,{json:Y.json})}})}async function vA(Q,$){if(!$.global)throw new h(`Local profiles are unsupported. Use --global to show a global profile.
235
235
 
236
236
  ocx profile show [name] --global`);let Y=await u1.requireInitialized(),q=Q??await Y.resolveProfile(),J=await Y.get(q);if($.json){console.log(JSON.stringify(J,null,2));return}if(console.log(`Profile: ${J.name}`),console.log(`
237
237
  Files:`),console.log(` ocx.jsonc: ${K0(q)}`),J.opencode)console.log(` opencode.jsonc: ${Z8(q)}`);if(J.hasAgents)console.log(` AGENTS.md: ${o8(q)}`);console.log(`
238
- OCX Config:`),console.log(JSON.stringify(J.ocx,null,2))}var sG=A(()=>{t0();W0();t();y1();d0()});function rG(Q){let $=Q.command("profile").alias("p").description("Manage profiles (global only)");cG($),mG($),iG($),pG($),oG($)}var aG=A(()=>{gG();dG();lG();nG();sG()});import{existsSync as EA}from"fs";import{dirname as tG,join as eG}from"path";async function kA(Q,$,Y){if(Y.isLocked?.())throw Error("Registries are locked. Cannot add.");let q=Q.trim();if(!q)throw new L("Registry URL is required");try{let V=new URL(q);if(!["http:","https:"].includes(V.protocol))throw new L(`Invalid registry URL: ${q} (must use http or https)`)}catch(V){if(V instanceof L)throw V;throw new L(`Invalid registry URL: ${q}`)}let J=g1(q),X=$.name,H=Y.getRegistries(),G=H[X],K=vA(H,J),{fetchRegistryIndex:W}=await Promise.resolve().then(() => (t8(),XX));await W(J);let z=G!==void 0,B=K!==null,Z=z&&g1(G.url)===J,M=B&&K.name!==X;if($.dryRun){let V=[];if(z&&!Z)V.push(`Registry '${X}' already exists with a different URL (${G.url}). Run 'ocx registry remove ${X}' first, then re-add.`);else if(M)V.push(`URL '${J}' is already registered under name '${K.name}'. Run 'ocx registry remove ${K.name}' first, then re-add.`);let U=z&&!Z||M,R=z&&Z,I=Y.targetLabel||"config";return{dryRun:!0,command:"registry add",wouldPerform:R?[]:[{action:"add",target:`registry:${X}`,details:{url:J}}],validation:{passed:!U,warnings:V.length>0?V:void 0},summary:U?`Would fail: conflict detected for registry '${X}'`:R?`Registry '${X}' already configured with same URL (no-op)`:`Would add registry '${X}' to ${I}`}}if(z&&!Z)throw new w9(X,G.url,J,Y.targetLabel);if(M)throw new w9(X,J,J,Y.targetLabel,K.name);if(z&&Z)return{name:X,url:J,updated:!1,alreadyConfigured:!0};return await Y.setRegistry(X,{url:J}),{name:X,url:J,updated:!1,alreadyConfigured:!1}}function vA(Q,$){for(let[Y,q]of Object.entries(Q))if(g1(q.url)===$)return{name:Y,config:q};return null}async function PA(Q,$){if($.isLocked?.())throw Error("Registries are locked. Cannot remove.");let Y=$.getRegistries();if(!(Q in Y))throw Error(`Registry '${Q}' not found.`);return await $.removeRegistry(Q),{removed:Q}}function xA(Q){let $=Q.getRegistries(),Y=Q.isLocked?.()??!1;return{registries:Object.entries($).map(([J,X])=>({name:J,url:X.url})),locked:Y}}async function s6(Q,$,Y){let q=$.getOptionValueSource("cwd")==="cli";if(Q.global&&Q.profile)throw new L("Cannot use both --global and --profile flags");if(q&&Q.profile)throw new L("Cannot use both --cwd and --profile flags");if(Q.global&&q)throw new L("Cannot use both --global and --cwd flags");if(Q.profile){if(TX(Q.profile),!await(await u1.requireInitialized()).exists(Q.profile))throw new C1(Q.profile);let H=K0(Q.profile);if(!EA(H))throw new h(`Profile '${Q.profile}' has no ocx.jsonc. Run 'ocx profile config ${Q.profile}' to create it.`);return{scope:"profile",configPath:H,configDir:tG(H),targetLabel:`profile '${Q.profile}' config`}}if(Q.global){let X=F0();return{scope:"global",configPath:eG(X,"ocx.jsonc"),configDir:X,targetLabel:"global config"}}let J=E8(Y);return{scope:"local",configPath:J.path,configDir:J.exists?tG(J.path):eG(Y,".opencode"),targetLabel:"local config"}}function QK(Q){let $=Q.command("registry").description("Manage registries"),Y=$.command("add").description("Add a registry").argument("<url>","Registry URL").requiredOption("--name <name>","Registry alias (required, used as lookup key for alias/component refs)").option("--dry-run","Validate registry without adding to config");Q8(Y),C3(Y),Q0(Y),Y.action(async(X,H,G)=>{let K;try{let W=H.cwd??process.cwd();K=await s6(H,G,W);let{configDir:z,configPath:B}=K,Z=await T0(z);if(!Z){let U=K.scope==="global"?"Run 'ocx init --global' first.":K.scope==="profile"?`Run 'ocx profile config ${H.profile}' to create it.`:"Run 'ocx init' first.";_.error(`${K.targetLabel} not found. ${U}`),process.exit(1)}let M=await kA(X,H,{getRegistries:()=>Z.registries,isLocked:()=>Z.lockRegistries??!1,setRegistry:async(U,R)=>{Z.registries[U]=R,await U3(z,Z,B)},targetLabel:K.targetLabel});if("dryRun"in M&&M.dryRun){j0(M,{json:H.json,quiet:H.quiet});return}let V=M;if(H.json)F1({success:!0,data:V});else if(!H.quiet)if(V.alreadyConfigured)_.info(`Registry already configured (no changes): ${V.name}`);else if(V.updated)_.success(`Updated registry in ${K.targetLabel}: ${V.name} -> ${V.url}`);else _.success(`Added registry to ${K.targetLabel}: ${V.name} -> ${V.url}`)}catch(W){s(W,{json:H.json})}});let q=$.command("remove").description("Remove a registry").argument("<name>","Registry name");Q8(q),C3(q),Q0(q),q.action(async(X,H,G)=>{try{let K=H.cwd??process.cwd(),W=await s6(H,G,K),z=await T0(W.configDir);if(!z){let Z=W.scope==="global"?"Run 'ocx init --global' first.":W.scope==="profile"?`Run 'ocx profile config ${H.profile}' to create it.`:"Run 'ocx init' first.";_.error(`${W.targetLabel} not found. ${Z}`),process.exit(1)}let B=await PA(X,{getRegistries:()=>z.registries,isLocked:()=>z.lockRegistries??!1,removeRegistry:async(Z)=>{delete z.registries[Z],await U3(W.configDir,z,W.configPath)}});if(H.json)F1({success:!0,data:B});else if(!H.quiet)_.success(`Removed registry from ${W.targetLabel}: ${B.removed}`)}catch(K){s(K,{json:H.json})}});let J=$.command("list").description("List configured registries");Q8(J),C3(J),Q0(J),J.action(async(X,H)=>{try{let G=X.cwd??process.cwd(),K=await s6(X,H,G),W=await T0(K.configDir);if(!W){let B=K.scope==="global"?"Run 'ocx init --global' first.":K.scope==="profile"?`Run 'ocx profile config ${X.profile}' to create it.`:"Run 'ocx init' first.";_.warn(`${K.targetLabel} not found. ${B}`);return}let z=xA({getRegistries:()=>W.registries,isLocked:()=>W.lockRegistries??!1});if(X.json)F1({success:!0,data:z});else if(!X.quiet)if(z.registries.length===0)_.info("No registries configured.");else{let B=K.scope==="global"?" (global)":K.scope==="profile"?` (profile '${X.profile}')`:"";_.info(`Configured registries${B}${z.locked?P.yellow(" (locked)"):""}:`);for(let Z of z.registries)console.log(` ${P.cyan(Z.name)}: ${Z.url}`)}}catch(G){s(G,{json:X.json})}})}var $K=A(()=>{W8();t0();W0();q0();e8();t();y1();c1();k8();d0()});function CA(Q){return Q.includes("/")&&!Q.includes("::")}function yA(Q){try{let{namespace:$,component:Y}=m0(Q);return{registryName:$,componentName:Y}}catch($){throw new L($ instanceof Error?$.message:`Invalid component ref: '${Q}'`)}}function hA(Q,$){return`Ambiguous component reference '${Q}'. Found ${$.length} installed matches:
238
+ OCX Config:`),console.log(JSON.stringify(J.ocx,null,2))}var sG=A(()=>{t0();W0();t();y1();k0()});function rG(Q){let $=Q.command("profile").alias("p").description("Manage profiles (global only)");cG($),mG($),iG($),pG($),oG($)}var aG=A(()=>{gG();dG();lG();nG();sG()});import{existsSync as PA}from"fs";import{dirname as tG,join as eG}from"path";async function xA(Q,$,Y){if(Y.isLocked?.())throw Error("Registries are locked. Cannot add.");let q=Q.trim();if(!q)throw new L("Registry URL is required");try{let V=new URL(q);if(!["http:","https:"].includes(V.protocol))throw new L(`Invalid registry URL: ${q} (must use http or https)`)}catch(V){if(V instanceof L)throw V;throw new L(`Invalid registry URL: ${q}`)}let J=g1(q),X=$.name,H=Y.getRegistries(),G=H[X],K=CA(H,J),{fetchRegistryIndex:W}=await Promise.resolve().then(() => (t8(),XX));await W(J);let z=G!==void 0,B=K!==null,Z=z&&g1(G.url)===J,M=B&&K.name!==X;if($.dryRun){let V=[];if(z&&!Z)V.push(`Registry '${X}' already exists with a different URL (${G.url}). Run 'ocx registry remove ${X}' first, then re-add.`);else if(M)V.push(`URL '${J}' is already registered under name '${K.name}'. Run 'ocx registry remove ${K.name}' first, then re-add.`);let U=z&&!Z||M,R=z&&Z,N=Y.targetLabel||"config";return{dryRun:!0,command:"registry add",wouldPerform:R?[]:[{action:"add",target:`registry:${X}`,details:{url:J}}],validation:{passed:!U,warnings:V.length>0?V:void 0},summary:U?`Would fail: conflict detected for registry '${X}'`:R?`Registry '${X}' already configured with same URL (no-op)`:`Would add registry '${X}' to ${N}`}}if(z&&!Z)throw new w9(X,G.url,J,Y.targetLabel);if(M)throw new w9(X,J,J,Y.targetLabel,K.name);if(z&&Z)return{name:X,url:J,updated:!1,alreadyConfigured:!0};return await Y.setRegistry(X,{url:J}),{name:X,url:J,updated:!1,alreadyConfigured:!1}}function CA(Q,$){for(let[Y,q]of Object.entries(Q))if(g1(q.url)===$)return{name:Y,config:q};return null}async function yA(Q,$){if($.isLocked?.())throw Error("Registries are locked. Cannot remove.");let Y=$.getRegistries();if(!(Q in Y))throw Error(`Registry '${Q}' not found.`);return await $.removeRegistry(Q),{removed:Q}}function hA(Q){let $=Q.getRegistries(),Y=Q.isLocked?.()??!1;return{registries:Object.entries($).map(([J,X])=>({name:J,url:X.url})),locked:Y}}async function s6(Q,$,Y){let q=$.getOptionValueSource("cwd")==="cli";if(Q.global&&Q.profile)throw new L("Cannot use both --global and --profile flags");if(q&&Q.profile)throw new L("Cannot use both --cwd and --profile flags");if(Q.global&&q)throw new L("Cannot use both --global and --cwd flags");if(Q.profile){if(TX(Q.profile),!await(await u1.requireInitialized()).exists(Q.profile))throw new C1(Q.profile);let H=K0(Q.profile);if(!PA(H))throw new h(`Profile '${Q.profile}' has no ocx.jsonc. Run 'ocx profile config ${Q.profile}' to create it.`);return{scope:"profile",configPath:H,configDir:tG(H),targetLabel:`profile '${Q.profile}' config`}}if(Q.global){let X=j0();return{scope:"global",configPath:eG(X,"ocx.jsonc"),configDir:X,targetLabel:"global config"}}let J=E8(Y);return{scope:"local",configPath:J.path,configDir:J.exists?tG(J.path):eG(Y,".opencode"),targetLabel:"local config"}}function QK(Q){let $=Q.command("registry").description("Manage registries"),Y=$.command("add").description("Add a registry").argument("<url>","Registry URL").requiredOption("--name <name>","Registry alias (required, used as lookup key for alias/component refs)").option("--dry-run","Validate registry without adding to config");Q8(Y),C3(Y),Q0(Y),Y.action(async(X,H,G)=>{let K;try{let W=H.cwd??process.cwd();K=await s6(H,G,W);let{configDir:z,configPath:B}=K,Z=await b0(z);if(!Z){let U=K.scope==="global"?"Run 'ocx init --global' first.":K.scope==="profile"?`Run 'ocx profile config ${H.profile}' to create it.`:"Run 'ocx init' first.";_.error(`${K.targetLabel} not found. ${U}`),process.exit(1)}let M=await xA(X,H,{getRegistries:()=>Z.registries,isLocked:()=>Z.lockRegistries??!1,setRegistry:async(U,R)=>{Z.registries[U]=R,await U3(z,Z,B)},targetLabel:K.targetLabel});if("dryRun"in M&&M.dryRun){w0(M,{json:H.json,quiet:H.quiet});return}let V=M;if(H.json)F1({success:!0,data:V});else if(!H.quiet)if(V.alreadyConfigured)_.info(`Registry already configured (no changes): ${V.name}`);else if(V.updated)_.success(`Updated registry in ${K.targetLabel}: ${V.name} -> ${V.url}`);else _.success(`Added registry to ${K.targetLabel}: ${V.name} -> ${V.url}`)}catch(W){s(W,{json:H.json})}});let q=$.command("remove").description("Remove a registry").argument("<name>","Registry name");Q8(q),C3(q),Q0(q),q.action(async(X,H,G)=>{try{let K=H.cwd??process.cwd(),W=await s6(H,G,K),z=await b0(W.configDir);if(!z){let Z=W.scope==="global"?"Run 'ocx init --global' first.":W.scope==="profile"?`Run 'ocx profile config ${H.profile}' to create it.`:"Run 'ocx init' first.";_.error(`${W.targetLabel} not found. ${Z}`),process.exit(1)}let B=await yA(X,{getRegistries:()=>z.registries,isLocked:()=>z.lockRegistries??!1,removeRegistry:async(Z)=>{delete z.registries[Z],await U3(W.configDir,z,W.configPath)}});if(H.json)F1({success:!0,data:B});else if(!H.quiet)_.success(`Removed registry from ${W.targetLabel}: ${B.removed}`)}catch(K){s(K,{json:H.json})}});let J=$.command("list").description("List configured registries");Q8(J),C3(J),Q0(J),J.action(async(X,H)=>{try{let G=X.cwd??process.cwd(),K=await s6(X,H,G),W=await b0(K.configDir);if(!W){let B=K.scope==="global"?"Run 'ocx init --global' first.":K.scope==="profile"?`Run 'ocx profile config ${X.profile}' to create it.`:"Run 'ocx init' first.";_.warn(`${K.targetLabel} not found. ${B}`);return}let z=hA({getRegistries:()=>W.registries,isLocked:()=>W.lockRegistries??!1});if(X.json)F1({success:!0,data:z});else if(!X.quiet)if(z.registries.length===0)_.info("No registries configured.");else{let B=K.scope==="global"?" (global)":K.scope==="profile"?` (profile '${X.profile}')`:"";_.info(`Configured registries${B}${z.locked?P.yellow(" (locked)"):""}:`);for(let Z of z.registries)console.log(` ${P.cyan(Z.name)}: ${Z.url}`)}}catch(G){s(G,{json:X.json})}})}var $K=A(()=>{W8();t0();W0();q0();e8();t();y1();c1();k8();k0()});function fA(Q){return Q.includes("/")&&!Q.includes("::")}function uA(Q){try{let{namespace:$,component:Y}=g0(Q);return{registryName:$,componentName:Y}}catch($){throw new L($ instanceof Error?$.message:`Invalid component ref: '${Q}'`)}}function mA(Q,$){return`Ambiguous component reference '${Q}'. Found ${$.length} installed matches:
239
239
  `+$.map((Y)=>` - ${Y}`).join(`
240
240
  `)+`
241
241
 
242
- Use one of the canonical IDs above.`}function fA(Q){return`Component '${Q}' is not installed.
243
- Run 'ocx search --installed' to see installed components.`}function uA(Q,$){let Y=Object.keys($.installed);if($.installed[Q])return Q;if(CA(Q)){let{registryName:q,componentName:J}=yA(Q),X=Y.filter((H)=>{let G=R8(H);return G.registryName===q&&G.name===J}).sort();if(X.length===1){let[H]=X;if(!H)throw Error("Unexpected empty canonical ID result");return H}if(X.length>1)throw new L(hA(Q,X))}throw new _1(fA(Q))}function H7(Q,$){return Q.map((Y)=>uA(Y,$))}var r6=A(()=>{g0();t();y9()});import{realpathSync as YK}from"fs";import{rm as mA}from"fs/promises";import{sep as gA}from"path";function qK(Q,$,Y){let q=V0(Q,Y),J;try{J=YK(q)}catch(X){let H=X.code;if(H==="ENOENT"||H==="ENOTDIR")return{path:Y,targetReal:null};if(H==="ELOOP")throw new L(`Security violation: symlink loop detected at ${Y}`);if(H==="EACCES"||H==="EPERM")throw new L(`Security violation: cannot verify path ${Y}`);throw X}if(J===$)throw new L(`Security violation: cannot delete project root directory (${Y})`);if(!J.startsWith($+gA))throw new L("Security violation: path escapes project directory");return{path:Y,targetReal:J}}function cA(Q,$,Y){let q=qK(Q,$,Y.path);if(!Y.targetReal){if(q.targetReal)throw new L(`Security violation: missing target reappeared during removal (${Y.path})`);return null}if(!q.targetReal)return null;if(q.targetReal!==Y.targetReal)throw new L(`Security violation: target changed during removal (${Y.path})`);return q.targetReal}function dA(Q){let $=new Set,Y=[];for(let q of Q){if($.has(q))continue;$.add(q),Y.push(q)}return Y}function JK(Q){let $=Q.command("remove").description("Remove installed components").argument("<components...>","Component refs to remove (canonical ID or alias/component)");Q0($),$.option("-f, --force","Force removal even if files have been modified"),E0($),$.option("--dry-run","Show what would be removed without making changes").action(async(Y,q)=>{try{await pA(Y,q)}catch(J){s(J,{json:q.json})}})}async function pA(Q,$){let Y=$.cwd??process.cwd(),q=await b0.requireInitialized(Y);if(Q.length===0)throw new L("No components specified. Specify at least one component ID.");let J=await A0(q.cwd);if(!J||Object.keys(J.installed).length===0)throw new _1("No components installed.");let X=dA(H7(Q,J)),H=$.quiet?null:M1({text:"Removing components..."});H?.start();let G=[],K=[],W=[],z=[],B=!1,Z;try{Z=YK(q.cwd)}catch(M){throw new L("Cannot resolve project directory")}try{for(let M of X){let V=J.installed[M];if(!V)throw Error(`Resolved component '${M}' was not found in receipt.`);let U=[];for(let I of V.files){if(!I.path||I.path===".")throw new L(`Invalid file path in receipt for '${M}': path cannot be empty or "."`);try{U.push(qK(q.cwd,Z,I.path))}catch(c){if(c instanceof e1)throw new L(`Security violation in receipt for '${M}': ${c.message}`);throw c}}let R=await T2(q.cwd,V);if(!R.intact){B=!0;let I=R.modified.map((c)=>` - ${c}`).join(`
242
+ Use one of the canonical IDs above.`}function gA(Q){return`Component '${Q}' is not installed.
243
+ Run 'ocx search --installed' to see installed components.`}function cA(Q,$){let Y=Object.keys($.installed);if($.installed[Q])return Q;if(fA(Q)){let{registryName:q,componentName:J}=uA(Q),X=Y.filter((H)=>{let G=R8(H);return G.registryName===q&&G.name===J}).sort();if(X.length===1){let[H]=X;if(!H)throw Error("Unexpected empty canonical ID result");return H}if(X.length>1)throw new L(mA(Q,X))}throw new _1(gA(Q))}function H7(Q,$){return Q.map((Y)=>cA(Y,$))}var r6=A(()=>{c0();t();y9()});import{realpathSync as YK}from"fs";import{rm as dA}from"fs/promises";import{sep as pA}from"path";function qK(Q,$,Y){let q=A0(Q,Y),J;try{J=YK(q)}catch(X){let H=X.code;if(H==="ENOENT"||H==="ENOTDIR")return{path:Y,targetReal:null};if(H==="ELOOP")throw new L(`Security violation: symlink loop detected at ${Y}`);if(H==="EACCES"||H==="EPERM")throw new L(`Security violation: cannot verify path ${Y}`);throw X}if(J===$)throw new L(`Security violation: cannot delete project root directory (${Y})`);if(!J.startsWith($+pA))throw new L("Security violation: path escapes project directory");return{path:Y,targetReal:J}}function lA(Q,$,Y){let q=qK(Q,$,Y.path);if(!Y.targetReal){if(q.targetReal)throw new L(`Security violation: missing target reappeared during removal (${Y.path})`);return null}if(!q.targetReal)return null;if(q.targetReal!==Y.targetReal)throw new L(`Security violation: target changed during removal (${Y.path})`);return q.targetReal}function iA(Q){let $=new Set,Y=[];for(let q of Q){if($.has(q))continue;$.add(q),Y.push(q)}return Y}function JK(Q){let $=Q.command("remove").description("Remove installed components").argument("<components...>","Component refs to remove (canonical ID or alias/component)");Q0($),$.option("-f, --force","Force removal even if files have been modified"),B0($),$.option("--dry-run","Show what would be removed without making changes").action(async(Y,q)=>{try{await nA(Y,q)}catch(J){s(J,{json:q.json})}})}async function nA(Q,$){let Y=$.cwd??process.cwd(),q=await R0.requireInitialized(Y);if(Q.length===0)throw new L("No components specified. Specify at least one component ID.");let J=await L0(q.cwd);if(!J||Object.keys(J.installed).length===0)throw new _1("No components installed.");let X=iA(H7(Q,J)),H=$.quiet?null:M1({text:"Removing components..."});H?.start();let G=[],K=[],W=[],z=[],B=!1,Z;try{Z=YK(q.cwd)}catch(M){throw new L("Cannot resolve project directory")}try{for(let M of X){let V=J.installed[M];if(!V)throw Error(`Resolved component '${M}' was not found in receipt.`);let U=[];for(let N of V.files){if(!N.path||N.path===".")throw new L(`Invalid file path in receipt for '${M}': path cannot be empty or "."`);try{U.push(qK(q.cwd,Z,N.path))}catch(c){if(c instanceof e1)throw new L(`Security violation in receipt for '${M}': ${c.message}`);throw c}}let R=await T2(q.cwd,V);if(!R.intact){B=!0;let N=R.modified.map((c)=>` - ${c}`).join(`
244
244
  `);if($.force)z.push(`Component '${M}' has been modified but will be force-removed:
245
- ${I}`);else z.push(`Component '${M}' has been modified. Use --force to remove anyway:
246
- ${I}`)}W.push({canonicalId:M,files:U})}if($.dryRun){H?.stop();let M={dryRun:!0,command:"remove",wouldPerform:W.flatMap(({canonicalId:V,files:U})=>U.map((R)=>({action:"delete",target:R.path,details:{component:V}}))),validation:{passed:!B||Boolean($.force),warnings:z.length>0?z:void 0},summary:`${W.length} component(s), ${W.reduce((V,U)=>V+U.files.length,0)} file(s) would be removed`};j0(M,{json:$.json,quiet:$.quiet,hints:B&&!$.force?["Add --force to remove modified files"]:void 0});return}if(B&&!$.force){H?.fail("File integrity check failed");let M;for(let V of W){let U=J.installed[V.canonicalId];if(!U)continue;try{let R=await T2(q.cwd,U);if(!R.intact){M={canonicalId:V.canonicalId,integrity:R};break}}catch(R){throw new L(`Failed to check integrity for '${V.canonicalId}': ${R instanceof Error?R.message:String(R)}`)}}if(M){let V=M.integrity.modified.length>0?`Modified files:
247
- ${M.integrity.modified.map((I)=>` - ${I}`).join(`
245
+ ${N}`);else z.push(`Component '${M}' has been modified. Use --force to remove anyway:
246
+ ${N}`)}W.push({canonicalId:M,files:U})}if($.dryRun){H?.stop();let M={dryRun:!0,command:"remove",wouldPerform:W.flatMap(({canonicalId:V,files:U})=>U.map((R)=>({action:"delete",target:R.path,details:{component:V}}))),validation:{passed:!B||Boolean($.force),warnings:z.length>0?z:void 0},summary:`${W.length} component(s), ${W.reduce((V,U)=>V+U.files.length,0)} file(s) would be removed`};w0(M,{json:$.json,quiet:$.quiet,hints:B&&!$.force?["Add --force to remove modified files"]:void 0});return}if(B&&!$.force){H?.fail("File integrity check failed");let M;for(let V of W){let U=J.installed[V.canonicalId];if(!U)continue;try{let R=await T2(q.cwd,U);if(!R.intact){M={canonicalId:V.canonicalId,integrity:R};break}}catch(R){throw new L(`Failed to check integrity for '${V.canonicalId}': ${R instanceof Error?R.message:String(R)}`)}}if(M){let V=M.integrity.modified.length>0?`Modified files:
247
+ ${M.integrity.modified.map((N)=>` - ${N}`).join(`
248
248
  `)}`:"",U=M.integrity.missing.length>0?`Missing files:
249
- ${M.integrity.missing.map((I)=>` - ${I}`).join(`
249
+ ${M.integrity.missing.map((N)=>` - ${N}`).join(`
250
250
  `)}`:"",R=[V,U].filter(Boolean).join(`
251
251
  `);throw new L(`Component '${M.canonicalId}' has been modified. Use --force to remove anyway.
252
- ${R}`)}}for(let{canonicalId:M,files:V}of W){for(let U of V){let R=cA(q.cwd,Z,U);if(!R){if($.verbose)_.info(` \u2298 Skipped ${U.path} (not found)`);continue}if(await mA(R,{force:!0}),$.verbose)_.info(` \u2713 Removed ${U.path}`)}delete J.installed[M],G.push(M)}if(await N0(q.cwd,J),H?.succeed(`Removed ${G.length} component(s)`),$.json)console.log(JSON.stringify({success:!0,removed:G,notFound:K},null,2));else if(!$.quiet){_.info("");for(let M of G){let V=R8(M);_.success(`\u2713 Removed ${V.registryName}/${V.name}@${V.revision}`)}_.info(""),_.success(`Done! Removed ${G.length} component(s).`)}}catch(M){throw H?.fail("Failed to remove components"),M}}var XK=A(()=>{k9();q0();r6();e8();t();y1();c1();g8();y9();d0();l0()});var GK=L8((HK,G7)=>{((Q,$)=>{if(typeof define==="function"&&define.amd)define([],$);else if(typeof G7==="object"&&G7.exports)G7.exports=$();else Q.fuzzysort=$()})(HK,(Q)=>{var $=(T,O)=>{if(!T||!O)return $1;var v=M(T);if(!C(O))O=Z(O);var f=v.bitflags;if((f&O._bitflags)!==f)return $1;return U(v,O)},Y=(T,O,v)=>{if(!T)return v?.all?V(O,v):D1;var f=M(T),m=f.bitflags,y=f.containsSpace,k=z(v?.threshold||0),n=v?.limit||e,g=0,K1=0,X1=O.length;function G0(y8){if(g<n)W9.add(y8),++g;else if(++K1,y8._score>W9.peek()._score)W9.replaceTop(y8)}if(v?.key){var r1=v.key;for(var W1=0;W1<X1;++W1){var $0=O[W1],V1=E($0,r1);if(!V1)continue;if(!C(V1))V1=Z(V1);if((m&V1._bitflags)!==m)continue;var j1=U(f,V1);if(j1===$1)continue;if(j1._score<k)continue;j1.obj=$0,G0(j1)}}else if(v?.keys){var V8=v.keys,w0=V8.length;Q:for(var W1=0;W1<X1;++W1){var $0=O[W1];{var a1=0;for(var H1=0;H1<w0;++H1){var r1=V8[H1],V1=E($0,r1);if(!V1){S[H1]=H0;continue}if(!C(V1))V1=Z(V1);S[H1]=V1,a1|=V1._bitflags}if((m&a1)!==m)continue}if(y)for(let A1=0;A1<f.spaceSearches.length;A1++)r[A1]=o;for(var H1=0;H1<w0;++H1){if(V1=S[H1],V1===H0){u[H1]=H0;continue}if(u[H1]=U(f,V1,!1,y),u[H1]===$1){u[H1]=H0;continue}if(y)for(let w1=0;w1<f.spaceSearches.length;w1++){if(J1[w1]>-1000){if(r[w1]>o){var o1=(r[w1]+J1[w1])/4;if(o1>r[w1])r[w1]=o1}}if(J1[w1]>r[w1])r[w1]=J1[w1]}}if(y){for(let A1=0;A1<f.spaceSearches.length;A1++)if(r[A1]===o)continue Q}else{var Y1=!1;for(let A1=0;A1<w0;A1++)if(u[A1]._score!==o){Y1=!0;break}if(!Y1)continue}var _0=new G(w0);for(let A1=0;A1<w0;A1++)_0[A1]=u[A1];if(y){var p1=0;for(let A1=0;A1<f.spaceSearches.length;A1++)p1+=r[A1]}else{var p1=o;for(let w1=0;w1<w0;w1++){var j1=_0[w1];if(j1._score>-1000){if(p1>o){var o1=(p1+j1._score)/4;if(o1>p1)p1=o1}}if(j1._score>p1)p1=j1._score}}if(_0.obj=$0,_0._score=p1,v?.scoreFn){if(p1=v.scoreFn(_0),!p1)continue;p1=z(p1),_0._score=p1}if(p1<k)continue;G0(_0)}}else for(var W1=0;W1<X1;++W1){var V1=O[W1];if(!V1)continue;if(!C(V1))V1=Z(V1);if((m&V1._bitflags)!==m)continue;var j1=U(f,V1);if(j1===$1)continue;if(j1._score<k)continue;G0(j1)}if(g===0)return D1;var A8=Array(g);for(var W1=g-1;W1>=0;--W1)A8[W1]=W9.poll();return A8.total=g+K1,A8},q=(T,O="<b>",v="</b>")=>{var f=typeof O==="function"?O:void 0,m=T.target,y=m.length,k=T.indexes,n="",g=0,K1=0,X1=!1,G0=[];for(var r1=0;r1<y;++r1){var W1=m[r1];if(k[K1]===r1){if(++K1,!X1)if(X1=!0,f)G0.push(n),n="";else n+=O;if(K1===k.length){if(f)n+=W1,G0.push(f(n,g++)),n="",G0.push(m.substr(r1+1));else n+=W1+v+m.substr(r1+1);break}}else if(X1)if(X1=!1,f)G0.push(f(n,g++)),n="";else n+=v;n+=W1}return f?G0:n},J=(T)=>{if(typeof T==="number")T=""+T;else if(typeof T!=="string")T="";var O=c(T);return K(T,{_targetLower:O._lower,_targetLowerCodes:O.lowerCodes,_bitflags:O.bitflags})},X=()=>{w.clear(),b.clear()};class H{get["indexes"](){return this._indexes.slice(0,this._indexes.len).sort((T,O)=>T-O)}set["indexes"](T){return this._indexes=T}["highlight"](T,O){return q(this,T,O)}get["score"](){return W(this._score)}set["score"](T){this._score=z(T)}}class G extends Array{get["score"](){return W(this._score)}set["score"](T){this._score=z(T)}}var K=(T,O)=>{let v=new H;return v.target=T,v.obj=O.obj??$1,v._score=O._score??o,v._indexes=O._indexes??[],v._targetLower=O._targetLower??"",v._targetLowerCodes=O._targetLowerCodes??$1,v._nextBeginningIndexes=O._nextBeginningIndexes??$1,v._bitflags=O._bitflags??0,v},W=(T)=>{if(T===o)return 0;if(T>1)return T;return Math.E**(((-T+1)**0.04307-1)*-2)},z=(T)=>{if(T===0)return o;if(T>1)return T;return 1-Math.pow(Math.log(T)/-2+1,23.218017181332716)},B=(T)=>{if(typeof T==="number")T=""+T;else if(typeof T!=="string")T="";T=T.trim();var O=c(T),v=[];if(O.containsSpace){var f=T.split(/\s+/);f=[...new Set(f)];for(var m=0;m<f.length;m++){if(f[m]==="")continue;var y=c(f[m]);v.push({lowerCodes:y.lowerCodes,_lower:f[m].toLowerCase(),containsSpace:!1})}}return{lowerCodes:O.lowerCodes,_lower:O._lower,containsSpace:O.containsSpace,bitflags:O.bitflags,spaceSearches:v}},Z=(T)=>{if(T.length>999)return J(T);var O=w.get(T);if(O!==void 0)return O;return O=J(T),w.set(T,O),O},M=(T)=>{if(T.length>999)return B(T);var O=b.get(T);if(O!==void 0)return O;return O=B(T),b.set(T,O),O},V=(T,O)=>{var v=[];v.total=T.length;var f=O?.limit||e;if(O?.key)for(var m=0;m<T.length;m++){var y=T[m],k=E(y,O.key);if(k==$1)continue;if(!C(k))k=Z(k);var n=K(k.target,{_score:k._score,obj:y});if(v.push(n),v.length>=f)return v}else if(O?.keys)for(var m=0;m<T.length;m++){var y=T[m],g=new G(O.keys.length);for(var K1=O.keys.length-1;K1>=0;--K1){var k=E(y,O.keys[K1]);if(!k){g[K1]=H0;continue}if(!C(k))k=Z(k);k._score=o,k._indexes.len=0,g[K1]=k}if(g.obj=y,g._score=o,v.push(g),v.length>=f)return v}else for(var m=0;m<T.length;m++){var k=T[m];if(k==$1)continue;if(!C(k))k=Z(k);if(k._score=o,k._indexes.len=0,v.push(k),v.length>=f)return v}return v},U=(T,O,v=!1,f=!1)=>{if(v===!1&&T.containsSpace)return R(T,O,f);var{_lower:m,lowerCodes:y}=T,k=y[0],n=O._targetLowerCodes,g=y.length,K1=n.length,W1=0,X1=0,G0=0;for(;;){var r1=k===n[X1];if(r1){if(D[G0++]=X1,++W1,W1===g)break;k=y[W1]}if(++X1,X1>=K1)return $1}var W1=0,$0=!1,V1=0,j1=O._nextBeginningIndexes;if(j1===$1)j1=O._nextBeginningIndexes=x(O.target);X1=D[0]===0?0:j1[D[0]-1];var V8=0;if(X1!==K1)for(;;)if(X1>=K1){if(W1<=0)break;if(++V8,V8>200)break;--W1;var w0=l[--V1];X1=j1[w0]}else{var r1=y[W1]===n[X1];if(r1){if(l[V1++]=X1,++W1,W1===g){$0=!0;break}++X1}else X1=j1[X1]}var a1=g<=1?-1:O._targetLower.indexOf(m,D[0]),H1=!!~a1,o1=!H1?!1:a1===0||O._nextBeginningIndexes[a1-1]===a1;if(H1&&!o1)for(var Y1=0;Y1<j1.length;Y1=j1[Y1]){if(Y1<=a1)continue;for(var _0=0;_0<g;_0++)if(y[_0]!==O._targetLowerCodes[Y1+_0])break;if(_0===g){a1=Y1,o1=!0;break}}var p1=(A1)=>{var w1=0,z5=0;for(var $8=1;$8<g;++$8)if(A1[$8]-A1[$8-1]!==1)w1-=A1[$8],++z5;var GW=A1[g-1]-A1[0]-(g-1);if(w1-=(12+GW)*z5,A1[0]!==0)w1-=A1[0]*A1[0]*0.2;if(!$0)w1*=1000;else{var L7=1;for(var $8=j1[0];$8<K1;$8=j1[$8])++L7;if(L7>24)w1*=(L7-24)*10}if(w1-=(K1-g)/2,H1)w1/=1+g*g*1;if(o1)w1/=1+g*g*1;return w1-=(K1-g)/2,w1};if(!$0){if(H1)for(var Y1=0;Y1<g;++Y1)D[Y1]=a1+Y1;var A8=D,y8=p1(A8)}else if(o1){for(var Y1=0;Y1<g;++Y1)D[Y1]=a1+Y1;var A8=D,y8=p1(D)}else var A8=l,y8=p1(l);O._score=y8;for(var Y1=0;Y1<g;++Y1)O._indexes[Y1]=A8[Y1];O._indexes.len=g;let f2=new H;return f2.target=O.target,f2._score=O._score,f2._indexes=O._indexes,f2},R=(T,O,v)=>{var f=new Set,m=0,y=$1,k=0,n=T.spaceSearches,g=n.length,K1=0,X1=()=>{for(let o1=K1-1;o1>=0;o1--)O._nextBeginningIndexes[i[o1*2+0]]=i[o1*2+1]},G0=!1;for(var H1=0;H1<g;++H1){J1[H1]=o;var r1=n[H1];if(y=U(r1,O),v){if(y===$1)continue;G0=!0}else if(y===$1)return X1(),$1;var W1=H1===g-1;if(!W1){var $0=y._indexes,V1=!0;for(let Y1=0;Y1<$0.len-1;Y1++)if($0[Y1+1]-$0[Y1]!==1){V1=!1;break}if(V1){var j1=$0[$0.len-1]+1,V8=O._nextBeginningIndexes[j1-1];for(let Y1=j1-1;Y1>=0;Y1--){if(V8!==O._nextBeginningIndexes[Y1])break;O._nextBeginningIndexes[Y1]=j1,i[K1*2+0]=Y1,i[K1*2+1]=V8,K1++}}}if(m+=y._score/g,J1[H1]=y._score/g,y._indexes[0]<k)m-=(k-y._indexes[0])*2;k=y._indexes[0];for(var w0=0;w0<y._indexes.len;++w0)f.add(y._indexes[w0])}if(v&&!G0)return $1;X1();var a1=U(T,O,!0);if(a1!==$1&&a1._score>m){if(v)for(var H1=0;H1<g;++H1)J1[H1]=a1._score/g;return a1}if(v)y=O;y._score=m;var H1=0;for(let o1 of f)y._indexes[H1++]=o1;return y._indexes.len=H1,y},I=(T)=>T.replace(/\p{Script=Latin}+/gu,(O)=>O.normalize("NFD")).replace(/[\u0300-\u036f]/g,""),c=(T)=>{T=I(T);var O=T.length,v=T.toLowerCase(),f=[],m=0,y=!1;for(var k=0;k<O;++k){var n=f[k]=v.charCodeAt(k);if(n===32){y=!0;continue}var g=n>=97&&n<=122?n-97:n>=48&&n<=57?26:n<=127?30:31;m|=1<<g}return{lowerCodes:f,bitflags:m,containsSpace:y,_lower:v}},N=(T)=>{var O=T.length,v=[],f=0,m=!1,y=!1;for(var k=0;k<O;++k){var n=T.charCodeAt(k),g=n>=65&&n<=90,K1=g||n>=97&&n<=122||n>=48&&n<=57,X1=g&&!m||!y||!K1;if(m=g,y=K1,X1)v[f++]=k}return v},x=(T)=>{T=I(T);var O=T.length,v=N(T),f=[],m=v[0],y=0;for(var k=0;k<O;++k)if(m>k)f[k]=m;else m=v[++y],f[k]=m===void 0?O:m;return f},w=new Map,b=new Map,D=[],l=[],i=[],r=[],J1=[],S=[],u=[],E=(T,O)=>{var v=T[O];if(v!==void 0)return v;if(typeof O==="function")return O(T);var f=O;if(!Array.isArray(O))f=O.split(".");var m=f.length,y=-1;while(T&&++y<m)T=T[f[y]];return T},C=(T)=>{return typeof T==="object"&&typeof T._bitflags==="number"},e=1/0,o=-e,D1=[];D1.total=0;var $1=null,H0=J(""),A7=(T)=>{var O=[],v=0,f={},m=(y)=>{for(var k=0,n=O[k],g=1;g<v;){var K1=g+1;k=g,K1<v&&O[K1]._score<O[g]._score&&(k=K1),O[k-1>>1]=O[k],g=1+(k<<1)}for(var X1=k-1>>1;k>0&&n._score<O[X1]._score;X1=(k=X1)-1>>1)O[k]=O[X1];O[k]=n};return f.add=(y)=>{var k=v;O[v++]=y;for(var n=k-1>>1;k>0&&y._score<O[n]._score;n=(k=n)-1>>1)O[k]=O[n];O[k]=y},f.poll=(y)=>{if(v!==0){var k=O[0];return O[0]=O[--v],m(),k}},f.peek=(y)=>{if(v!==0)return O[0]},f.replaceTop=(y)=>{O[0]=y,m()},f},W9=A7();return{single:$,go:Y,prepare:J,cleanup:X}})});var WK={};F8(WK,{runSearchCore:()=>KK,runSearchCommandAction:()=>lA});async function lA(Q,$){if($.installed){let q=await A0($.cwd);if(!q||Object.keys(q.installed).length===0){if($.json)F1({success:!0,data:{components:[]}});else _.info("No components installed.");return}let J=Object.entries(q.installed).map(([X,H])=>({name:`${H.registryName}/${H.name}`,registry:H.registryUrl,version:H.revision,installedAt:void 0}));if($.json)F1({success:!0,data:{components:J}});else{_.info(`Installed components (${J.length}):`);for(let X of J)console.log(` ${P.cyan(X.name)} ${P.dim(`v${X.version}`)} from ${X.registry}`)}return}let Y;if($.profile){let q=await e0.create($.cwd,{profile:$.profile});Y={cwd:q.getCwd(),getRegistries:()=>q.getRegistries(),getComponentPath:()=>q.getComponentPath()}}else Y=await b0.requireInitialized($.cwd);await KK(Q,$,Y)}async function KK(Q,$,Y){let q=Y.getRegistries();if($.verbose)_.info(`Searching in ${Object.keys(q).length} registries...`);let J=[],X=M1({text:"Searching registries...",quiet:$.quiet||$.verbose});if(!$.json&&!$.verbose)X.start();for(let[G,K]of Object.entries(q))try{if($.verbose)_.info(`Fetching index from ${G} (${K.url})...`);let W=await P8(K.url);if($.verbose)_.info(`Found ${W.components.length} components in ${G}`);for(let z of W.components)J.push({name:`${G}/${z.name}`,description:z.description,type:z.type,registry:G})}catch(W){if($.verbose)_.warn(`Failed to fetch registry ${G}: ${W instanceof Error?W.message:String(W)}`)}if(!$.json&&!$.verbose)X.stop();let H=J;if(Q)H=a6.default.go(Q,J,{keys:["name","description"],limit:$.limit}).map((K)=>K.obj);else H=H.slice(0,$.limit);if($.json){F1({success:!0,data:{components:H}});return}if(H.length===0){_.info("No components found.");return}_.info(`Found ${H.length} components:`);for(let G of H)console.log(` ${P.cyan(G.name)} ${P.dim(`(${G.type})`)} - ${G.description}`)}var a6;var zK=A(()=>{W8();k9();O2();t8();k4();c1();l0();a6=B5(GK(),1)});function iA(Q){let $=parseInt(Q,10);if(Number.isNaN($)||$<=0)throw new LJ("Must be a positive integer");return $}function BK(Q){let $=Q.command("search").alias("list").description("Search for components across registries or list installed").argument("[query]","Search query").option("--installed","List installed components only",!1).option("-p, --profile <name>","Use specific profile").addOption(new B8("--limit <n>","Limit results").default(20).argParser(iA));Q0($),E0($),$.action(async(Y,q)=>{try{let{runSearchCommandAction:J}=await Promise.resolve().then(() => (zK(),WK));await J(Y,q)}catch(J){s(J,{json:q.json})}})}var _K=A(()=>{L3();y1();d0()});function ZK(Q){let $=["curl","npm","yarn","pnpm","bun"],Y=$.find((q)=>q===Q);if(!Y)throw new x1(`Invalid install method: "${Q}"
253
- Valid methods: ${$.join(", ")}`);return Y}function n9(){if(nA())return"curl";let Q=process.argv[1]??"";if(oA(Q))return"unknown";if(sA(Q))return"yarn";if(rA(Q))return"pnpm";if(aA(Q))return"bun";if(tA(Q))return"npm";let $=process.env.npm_config_user_agent??"";if($.includes("yarn"))return"yarn";if($.includes("pnpm"))return"pnpm";if($.includes("bun"))return"bun";if($.includes("npm"))return"npm";return"unknown"}function K7(){if(typeof Bun<"u"&&Bun.main.startsWith("/$bunfs/"))return process.execPath;return process.argv[1]??process.execPath}var nA=()=>Bun.main.startsWith("/$bunfs/"),oA=(Q)=>Q.includes("/_npx/")||Q.includes("/.cache/bunx/")||Q.includes("/.pnpm/_temp/"),sA=(Q)=>Q.includes("/.yarn/global")||Q.includes("/.config/yarn/global"),rA=(Q)=>Q.includes("/.pnpm/")||Q.includes("/pnpm/global"),aA=(Q)=>Q.includes("/.bun/bin")||Q.includes("/.bun/install/global"),tA=(Q)=>Q.includes("/.npm/")||Q.includes("/node_modules/");var W7=A(()=>{t()});import{existsSync as e6,lstatSync as VK,readdirSync as eA,realpathSync as MK,rmSync as QL,unlinkSync as AK}from"fs";import{homedir as LK}from"os";import i0 from"path";function t6(Q,$=0){F1({success:!0,data:Q}),process.exit($)}function X9(Q,$,Y,q){let J={success:!1,error:{code:Q,message:$,...q&&{details:q}},exitCode:Y,meta:{timestamp:new Date().toISOString()}};F1(J),process.exit(Y)}function Q5(Q){return Q instanceof Error&&"code"in Q}function y2(Q){let $=LK();if(!$)return Q;if(Q===$)return"~";if(Q.startsWith($+i0.sep))return`~${Q.slice($.length)}`;return Q}function B7(Q,$){let Y=i0.normalize(Q),q=i0.normalize($),J=i0.relative(Y,q);if(J.startsWith("..")||i0.isAbsolute(J))return null;return J}function $L(Q,$){return B7(Q,$)!==null}function YL(Q,$){if(!e6($))return{contained:!0};try{let Y=MK(Q),q=MK($);return{contained:B7(Y,q)!==null}}catch(Y){if(Q5(Y)&&(Y.code==="EACCES"||Y.code==="EPERM"))return{contained:!1,error:"permission"};return{contained:!1,error:"io"}}}function FK(Q){try{let $=VK(Q);if($.isSymbolicLink())return{valid:!1,reason:"symlink"};if(!$.isDirectory())return{valid:!1,reason:"not-directory"};return{valid:!0}}catch($){if(Q5($)){if($.code==="ENOENT")return{valid:!1,reason:"not-found"};if($.code==="EACCES"||$.code==="EPERM")return{valid:!1,reason:"permission"}}return{valid:!1,reason:"permission"}}}function h2(Q){if(!e6(Q))return"missing";try{let $=VK(Q);if($.isSymbolicLink())return"symlink";if($.isDirectory())return"directory";return"file"}catch{return"missing"}}function qL(Q){if(!e6(Q))return!0;try{return eA(Q).length===0}catch{return!1}}function UK(Q){if(Q.kind==="missing")return"safe";if(Q.kind==="symlink")return $L(Q.rootPath,Q.absolutePath)?"safe":"forbidden";let $=YL(Q.rootPath,Q.absolutePath);if($.error)return"error";return $.contained?"safe":"forbidden"}function H9(Q){return Q==="npm"||Q==="pnpm"||Q==="bun"||Q==="yarn"}function _7(Q){switch(Q){case"npm":return"npm uninstall -g ocx";case"pnpm":return"pnpm remove -g ocx";case"bun":return"bun remove -g ocx";case"yarn":return"yarn global remove ocx";default:return"npm uninstall -g ocx"}}function $5(){let Q=process.env.XDG_CONFIG_HOME||i0.join(LK(),".config");return i0.join(Q,"opencode")}function jK(){let Q=$5(),$=[],Y=_8(),q=B7(Q,Y);if(q){let G=h2(Y);$.push({rootPath:Q,relativePath:q,absolutePath:Y,displayPath:y2(Y),kind:G,deleteIfEmpty:!1,safetyStatus:UK({rootPath:Q,absolutePath:Y,kind:G})})}let J=P9(),X=B7(Q,J);if(X){let G=h2(J);$.push({rootPath:Q,relativePath:X,absolutePath:J,displayPath:y2(J),kind:G,deleteIfEmpty:!1,safetyStatus:UK({rootPath:Q,absolutePath:J,kind:G})})}let H=h2(Q);return $.push({rootPath:Q,relativePath:".",absolutePath:Q,displayPath:y2(Q),kind:H,deleteIfEmpty:!0,safetyStatus:H==="missing"?"safe":"safe"}),$}function wK(){let Q=n9();if(H9(Q))return null;if(Q==="curl"){let $=K7(),Y=h2($);return{rootPath:i0.dirname($),relativePath:i0.basename($),absolutePath:$,displayPath:y2($),kind:Y,deleteIfEmpty:!1,safetyStatus:Y==="missing"?"safe":"safe"}}return null}function JL(Q){if(Q.kind==="missing")return{target:Q,success:!0,skipped:!0,reason:"not found"};if(Q.safetyStatus==="forbidden")return{target:Q,success:!1,skipped:!0,reason:"containment violation",error:Error("Target escapes containment boundary")};if(Q.deleteIfEmpty&&Q.kind==="directory"){if(!qL(Q.absolutePath))return{target:Q,success:!0,skipped:!0,reason:"not empty"}}try{if(Q.kind==="directory")QL(Q.absolutePath,{recursive:!0,force:!0});else AK(Q.absolutePath);return{target:Q,success:!0,skipped:!1}}catch($){let Y=$ instanceof Error?$:Error(String($)),q=Q5($)&&($.code==="EACCES"||$.code==="EPERM")?"permission denied":void 0;return{target:Q,success:!1,skipped:!1,reason:q,error:Y}}}function DK(Q){return Q.map(JL)}function OK(Q,$={}){let Y={rootPath:i0.dirname(Q),relativePath:i0.basename(Q),absolutePath:Q,displayPath:y2(Q),kind:h2(Q),deleteIfEmpty:!1,safetyStatus:"safe"};if(Y.kind==="missing")return{target:Y,success:!0,skipped:!0,reason:"not found"};if(process.platform==="win32"){if(!$.suppressOutput)_.info(`To complete uninstall, manually delete: ${Y.displayPath}`);return{target:Y,success:!0,skipped:!0}}try{return AK(Q),{target:Y,success:!0,skipped:!1}}catch(q){let J=q instanceof Error?q:Error(String(q));return{target:Y,success:!1,skipped:!1,reason:"permission denied",error:J}}}function XL(Q,$,Y){let{dryRunResult:q,hints:J}=IK(Q,$,Y);j0(q,{hints:J})}function IK(Q,$,Y){let q=Q.filter((G)=>G.kind!=="missing"),J=[];for(let G of q)J.push({action:"delete",target:G.displayPath,details:{kind:G.kind,...G.deleteIfEmpty&&{deleteIfEmpty:!0}}});if($&&$.kind!=="missing")J.push({action:"delete",target:$.displayPath,details:{kind:"binary"}});let X=[];if(H9(Y))X.push(`Binary is managed by ${Y}. Run: ${_7(Y)}`);return{dryRunResult:{dryRun:!0,command:"self uninstall",wouldPerform:J,validation:{passed:!0},summary:J.length>0?`Would remove ${J.length} item(s)`:"Nothing to remove"},hints:X}}function HL(Q,$){if(Q.filter((q)=>q.kind!=="missing").length>0||$&&$.kind!=="missing")_.info("Removing OCX files...")}function GL(Q,$,Y){_.break();for(let q of Q){if(q.skipped){if(q.reason==="not found")continue;if(q.reason==="not empty"){_.info(`Kept ${L0.path(q.target.displayPath)} (not empty)`);continue}if(q.reason==="permission denied"){_.warn(`Skipped ${L0.path(q.target.displayPath)} (permission denied)`);continue}if(q.reason==="containment violation"){_.warn(`Skipped ${L0.path(q.target.displayPath)} (containment violation)`);continue}}if(q.success)_.success(`Removed ${L0.path(q.target.displayPath)}`);else _.error(`Failed to remove ${q.target.displayPath}: ${q.error?.message}`)}if($){if($.skipped&&$.reason==="not found");else if($.success&&!$.skipped)_.success(`Removed binary ${L0.path($.target.displayPath)}`);else if(!$.success)_.error(`Failed to remove binary ${$.target.displayPath}: ${$.error?.message}`)}if(H9(Y))_.break(),_.info(`Binary is managed by ${Y}. To complete uninstall, run:`),_.log(` ${L0.command(_7(Y))}`)}function KL(){_.info("Nothing to remove. OCX is not installed globally.")}function z7(Q){return{path:Q.target.displayPath,kind:Q.target.kind,success:Q.success,skipped:Q.skipped,...Q.reason&&{reason:Q.reason},...Q.error&&{error:Q.error.message}}}async function WL(Q){let $=$5(),Y=FK($);if(!Y.valid)switch(Y.reason){case"not-found":break;case"symlink":return X9("VALIDATION_ERROR","Safety error: Global config root is a symlink. Aborting.",d1.SAFETY_ERROR);case"not-directory":return X9("VALIDATION_ERROR","Safety error: Global config root is not a directory. Aborting.",d1.SAFETY_ERROR);case"permission":return X9("PERMISSION_ERROR","Error: Cannot access global config root (permission denied).",d1.ERROR)}let q=jK(),J=q.filter((I)=>I.safetyStatus==="forbidden");if(J.length>0)return X9("VALIDATION_ERROR","Safety error: Target escapes containment boundary.",d1.SAFETY_ERROR,{targets:J.map((I)=>I.displayPath)});let X=q.filter((I)=>I.safetyStatus==="error");if(X.length>0)return X9("PERMISSION_ERROR","Error: Cannot verify containment for targets (permission/IO error).",d1.ERROR,{targets:X.map((I)=>I.displayPath)});let H=n9(),G=wK(),K=q.filter((I)=>I.kind!=="missing"),W=Boolean(G&&G.kind!=="missing"),z=H9(H);if(K.length===0&&!W&&!z)return t6({message:"Nothing to remove. OCX is not installed globally.",removed:[],skipped:[]},d1.SUCCESS);if(Q.dryRun){let{dryRunResult:I,hints:c}=IK(q,G,H);return t6({...I,...c.length>0&&{hints:c}},d1.SUCCESS)}let B=DK(q),Z=null;if(G)Z=OK(G.absolutePath,{suppressOutput:!0});let M=B.some((I)=>!I.success&&!I.skipped),V=Boolean(Z&&!Z.success&&!Z.skipped);if(M||V)return X9("PERMISSION_ERROR","Failed to remove one or more uninstall targets.",d1.ERROR,{configResults:B.map(z7),...Z&&{binaryResult:z7(Z)}});if(H9(H))return X9("UPDATE_ERROR",`Binary is managed by ${H}. Run: ${_7(H)}`,d1.ERROR,{installMethod:H,command:_7(H),configResults:B.map(z7),...Z&&{binaryResult:z7(Z)}});let U=B.filter((I)=>I.success&&!I.skipped).map((I)=>I.target.displayPath),R=B.filter((I)=>I.skipped).map((I)=>({path:I.target.displayPath,reason:I.reason??"skipped"}));if(Z){if(Z.success&&!Z.skipped)U.push(Z.target.displayPath);else if(Z.skipped)R.push({path:Z.target.displayPath,reason:Z.reason??"skipped"})}return t6({removed:U,skipped:R,installMethod:H},d1.SUCCESS)}async function zL(Q){if(Q.json){await WL(Q);return}let $=$5(),Y=FK($);if(!Y.valid)switch(Y.reason){case"not-found":break;case"symlink":_.error("Safety error: Global config root is a symlink. Aborting."),process.exit(d1.SAFETY_ERROR);break;case"not-directory":_.error("Safety error: Global config root is not a directory. Aborting."),process.exit(d1.SAFETY_ERROR);break;case"permission":_.error("Error: Cannot access global config root (permission denied)."),process.exit(d1.ERROR);break}let q=jK(),J=q.filter((U)=>U.safetyStatus==="forbidden");if(J.length>0){_.error("Safety error: Target escapes containment boundary:");for(let U of J)_.error(` ${U.displayPath}`);process.exit(d1.SAFETY_ERROR)}let X=q.filter((U)=>U.safetyStatus==="error");if(X.length>0){_.error("Error: Cannot verify containment for targets (permission/IO error):");for(let U of X)_.error(` ${U.displayPath}`);process.exit(d1.ERROR)}let H=n9(),G=wK(),K=q.filter((U)=>U.kind!=="missing"),W=G&&G.kind!=="missing",z=H9(H);if(K.length===0&&!W&&!z)KL(),process.exit(d1.SUCCESS);if(Q.dryRun)XL(q,G,H),process.exit(d1.SUCCESS);HL(q,G);let B=DK(q),Z=null;if(G)Z=OK(G.absolutePath);GL(B,Z,H);let M=B.some((U)=>!U.success&&!U.skipped),V=Z&&!Z.success&&!Z.skipped;if(M||V)process.exit(d1.ERROR);if(H9(H))process.exit(d1.ERROR);process.exit(d1.SUCCESS)}function NK(Q){Q.command("uninstall").description("Remove OCX global configuration and binary").option("--dry-run","Preview what would be removed").option("--json","Output as JSON").action(async($)=>{try{await zL($)}catch(Y){s(Y,{json:$.json})}})}var d1;var TK=A(()=>{W0();W7();e8();y1();c1();d1={SUCCESS:0,ERROR:1,SAFETY_ERROR:2}});class bK{version="2.0.8"}var RK;var SK=A(()=>{RK=new bK});var kK={};F8(kK,{checkForUpdate:()=>q5,EXPLICIT_UPDATE_TIMEOUT_MS:()=>Y5});function EK(Q){let[$=""]=Q.split("-"),Y=$.split("."),q=parseInt(Y[0]??"",10),J=parseInt(Y[1]??"",10),X=parseInt(Y[2]??"",10);if(Number.isNaN(q)||Number.isNaN(J)||Number.isNaN(X))return null;return{major:q,minor:J,patch:X}}function ZL(Q,$){let Y=EK(Q),q=EK($);if(!Y||!q)return null;if(Y.major!==q.major)return Y.major-q.major;if(Y.minor!==q.minor)return Y.minor-q.minor;return Y.patch-q.patch}async function q5(Q,$=BL){let q=(Q??RK).version||"0.0.0-dev";if(q==="0.0.0-dev")return{ok:!1,reason:"dev-version"};try{let X=(await v3(_L,void 0,AbortSignal.timeout($))).version,H=ZL(X,q);if(H===null)return{ok:!1,reason:"invalid-response"};return{ok:!0,current:q,latest:X,updateAvailable:H>0}}catch(J){if(J instanceof Error){if(J.name==="AbortError"||J.name==="TimeoutError")return{ok:!1,reason:"timeout"};if(J instanceof I1||J.name==="NetworkError")return{ok:!1,reason:"network-error"}}return{ok:!1,reason:"invalid-response"}}}var BL=200,Y5=1e4,_L="ocx";var J5=A(()=>{t();X6();SK()});import{chmodSync as ML,existsSync as G9,renameSync as X5,unlinkSync as Z7}from"fs";function AL(){let Q=process.env.OCX_DOWNLOAD_URL;if(Q)return Q.replace(/\/+$/,"");return VL}function H5(Q){let $=`${process.arch}-${process.platform}`,Y=vK[$];if(!Y){let J=Object.keys(vK).join(", ");throw new x1(`Unsupported platform: ${$}
254
- Supported platforms: ${J}`)}return`${AL()}/v${Q}/${Y}`}async function LL(Q,$,Y={}){let q=Y.quiet?null:M1({text:"Downloading update..."});q?.start();let J;try{J=await fetch(Q,{redirect:"follow"})}catch(W){throw q?.fail("Download failed"),new x1(`Network error: ${W instanceof Error?W.message:String(W)}`)}if(!J.ok)throw q?.fail("Download failed"),new x1(`Failed to download: HTTP ${J.status} ${J.statusText}`);if(!J.body)throw q?.fail("Download failed"),new x1("Download failed: Empty response body");let X=J.body.getReader(),H=Bun.file($).writer(),G=Number(J.headers.get("content-length")||0),K=0;try{while(!0){let{done:W,value:z}=await X.read();if(W)break;if(await H.write(z),K+=z.length,G>0&&q){let B=Math.round(K/G*100);q.text=`Downloading... ${B}%`}}await H.end(),q?.succeed("Download complete")}catch(W){throw q?.fail("Download failed"),await H.end(),new x1(`Download interrupted: ${W instanceof Error?W.message:String(W)}`)}}async function PK(Q,$={}){let Y=K7(),q=`${Y}.new.${Date.now()}`,J=H5(Q);await LL(J,q,$);try{ML(q,493)}catch(X){if(G9(q))Z7(q);throw new x1(`Failed to set permissions: ${X instanceof Error?X.message:String(X)}`)}return{tempPath:q,execPath:Y}}function xK(Q,$){let Y=`${$}.backup`;try{if(G9($))X5($,Y);if(X5(Q,$),G9(Y))Z7(Y)}catch(q){if(G9(Y)&&!G9($))try{X5(Y,$)}catch{}if(G9(Q))try{Z7(Q)}catch{}throw new x1(`Update failed: ${q instanceof Error?q.message:String(q)}`)}}function CK(Q){if(G9(Q))try{Z7(Q)}catch{}}var UL="kdcokenny/ocx",VL,vK;var yK=A(()=>{t();l0();W7();VL=`https://github.com/${UL}/releases/download`,vK={"arm64-darwin":"ocx-darwin-arm64","x64-darwin":"ocx-darwin-x64","arm64-linux":"ocx-linux-arm64","x64-linux":"ocx-linux-x64","x64-win32":"ocx-windows-x64.exe"}});var hK={};F8(hK,{notifyUpdated:()=>M7,notifyUpdate:()=>FL,notifyUpToDate:()=>G5});function FL(Q,$){if(!process.stdout.isTTY)return;console.error(`${P.cyan("info")}: update available - ${P.green($)} (current: ${P.dim(Q)})`),console.error(` run ${P.cyan("`ocx self update`")} to upgrade`)}function G5(Q){console.error(`${P.cyan("info")}: ocx unchanged - ${P.dim(Q)}`)}function M7(Q,$){console.error(` ${P.green("ocx updated")} - ${$} (from ${Q})`)}var K5=A(()=>{W8()});import{createHash as jL}from"crypto";function DL(Q){let $=new Map;for(let Y of Q.split(`
255
- `)){let q=Y.match(/^([a-fA-F0-9]{64})\s+\*?(.+)$/);if(q?.[1]&&q[2])$.set(q[2].trim(),q[1].toLowerCase())}return $}function OL(Q){return jL("sha256").update(Q).digest("hex")}async function fK(Q){let $=`https://github.com/${wL}/releases/download/v${Q}/SHA256SUMS.txt`,Y=await fetch($);if(!Y.ok)throw new x1(`Failed to fetch checksums: ${Y.status}`);let q=await Y.text();return DL(q)}async function uK(Q,$,Y){let J=await Bun.file(Q).arrayBuffer(),X=OL(Buffer.from(J));if(X!==$)throw new m8(Y,$,X)}var wL="kdcokenny/ocx";var mK=A(()=>{t()});var gK={};F8(gK,{runSelfUpdateCommand:()=>TL});async function TL(Q){let $=Q.method?ZK(Q.method):n9(),Y=Q.json===!0,q=await q5(void 0,Y5);if(!q.ok)throw new x1(NL[q.reason]);let{current:J,latest:X,updateAvailable:H}=q;if(!H&&!Q.force){if(Y)F1({success:!0,data:{current:J,latest:X,method:$,updated:!1}});else G5(J);return}let G=X;switch($){case"curl":{await bL(J,G,Y);break}case"npm":case"pnpm":case"bun":case"yarn":case"unknown":{await RL($,J,G,Y);break}}if(Y)F1({success:!0,data:{current:J,latest:G,method:$,updated:!0}})}async function bL(Q,$,Y){let J=H5($).split("/").pop();if(!J)throw new x1("Failed to determine binary filename from download URL");let H=(await fK($)).get(J);if(!H)throw new x1(`Security error: No checksum found for ${J}. Update aborted.`);let{tempPath:G,execPath:K}=await PK($,{quiet:Y});try{await uK(G,H,J)}catch(W){throw CK(G),W}if(xK(G,K),!Y)M7(Q,$)}async function U7(Q){let $=Bun.spawn(Q,{stdout:"pipe",stderr:"pipe"});if(await $.exited!==0){let q=await new Response($.stderr).text();throw new x1(`Package manager command failed: ${q.trim()}`)}}async function RL(Q,$,Y,q){if(!IL.test(Y))throw new x1(`Invalid version format: ${Y}`);let J=q?null:M1({text:`Updating via ${Q}...`});J?.start();try{switch(Q){case"npm":{await U7(["npm","install","-g",`ocx@${Y}`]);break}case"yarn":{await U7(["yarn","global","add",`ocx@${Y}`]);break}case"pnpm":{await U7(["pnpm","install","-g",`ocx@${Y}`]);break}case"bun":{await U7(["bun","install","-g",`ocx@${Y}`]);break}case"unknown":throw new x1(`Could not detect install method. Update manually with one of:
252
+ ${R}`)}}for(let{canonicalId:M,files:V}of W){for(let U of V){let R=lA(q.cwd,Z,U);if(!R){if($.verbose)_.info(` \u2298 Skipped ${U.path} (not found)`);continue}if(await dA(R,{force:!0}),$.verbose)_.info(` \u2713 Removed ${U.path}`)}delete J.installed[M],G.push(M)}if(await T0(q.cwd,J),H?.succeed(`Removed ${G.length} component(s)`),$.json)console.log(JSON.stringify({success:!0,removed:G,notFound:K},null,2));else if(!$.quiet){_.info("");for(let M of G){let V=R8(M);_.success(`\u2713 Removed ${V.registryName}/${V.name}@${V.revision}`)}_.info(""),_.success(`Done! Removed ${G.length} component(s).`)}}catch(M){throw H?.fail("Failed to remove components"),M}}var XK=A(()=>{k9();q0();r6();e8();t();y1();c1();g8();y9();k0();l0()});var GK=L8((HK,G7)=>{((Q,$)=>{if(typeof define==="function"&&define.amd)define([],$);else if(typeof G7==="object"&&G7.exports)G7.exports=$();else Q.fuzzysort=$()})(HK,(Q)=>{var $=(b,D)=>{if(!b||!D)return $1;var v=M(b);if(!C(D))D=Z(D);var f=v.bitflags;if((f&D._bitflags)!==f)return $1;return U(v,D)},Y=(b,D,v)=>{if(!b)return v?.all?V(D,v):D1;var f=M(b),u=f.bitflags,y=f.containsSpace,k=z(v?.threshold||0),n=v?.limit||e,m=0,K1=0,X1=D.length;function G0(y8){if(m<n)W9.add(y8),++m;else if(++K1,y8._score>W9.peek()._score)W9.replaceTop(y8)}if(v?.key){var r1=v.key;for(var W1=0;W1<X1;++W1){var $0=D[W1],V1=E($0,r1);if(!V1)continue;if(!C(V1))V1=Z(V1);if((u&V1._bitflags)!==u)continue;var j1=U(f,V1);if(j1===$1)continue;if(j1._score<k)continue;j1.obj=$0,G0(j1)}}else if(v?.keys){var V8=v.keys,D0=V8.length;Q:for(var W1=0;W1<X1;++W1){var $0=D[W1];{var a1=0;for(var H1=0;H1<D0;++H1){var r1=V8[H1],V1=E($0,r1);if(!V1){S[H1]=H0;continue}if(!C(V1))V1=Z(V1);S[H1]=V1,a1|=V1._bitflags}if((u&a1)!==u)continue}if(y)for(let A1=0;A1<f.spaceSearches.length;A1++)r[A1]=o;for(var H1=0;H1<D0;++H1){if(V1=S[H1],V1===H0){g[H1]=H0;continue}if(g[H1]=U(f,V1,!1,y),g[H1]===$1){g[H1]=H0;continue}if(y)for(let w1=0;w1<f.spaceSearches.length;w1++){if(J1[w1]>-1000){if(r[w1]>o){var o1=(r[w1]+J1[w1])/4;if(o1>r[w1])r[w1]=o1}}if(J1[w1]>r[w1])r[w1]=J1[w1]}}if(y){for(let A1=0;A1<f.spaceSearches.length;A1++)if(r[A1]===o)continue Q}else{var Y1=!1;for(let A1=0;A1<D0;A1++)if(g[A1]._score!==o){Y1=!0;break}if(!Y1)continue}var Z0=new G(D0);for(let A1=0;A1<D0;A1++)Z0[A1]=g[A1];if(y){var p1=0;for(let A1=0;A1<f.spaceSearches.length;A1++)p1+=r[A1]}else{var p1=o;for(let w1=0;w1<D0;w1++){var j1=Z0[w1];if(j1._score>-1000){if(p1>o){var o1=(p1+j1._score)/4;if(o1>p1)p1=o1}}if(j1._score>p1)p1=j1._score}}if(Z0.obj=$0,Z0._score=p1,v?.scoreFn){if(p1=v.scoreFn(Z0),!p1)continue;p1=z(p1),Z0._score=p1}if(p1<k)continue;G0(Z0)}}else for(var W1=0;W1<X1;++W1){var V1=D[W1];if(!V1)continue;if(!C(V1))V1=Z(V1);if((u&V1._bitflags)!==u)continue;var j1=U(f,V1);if(j1===$1)continue;if(j1._score<k)continue;G0(j1)}if(m===0)return D1;var A8=Array(m);for(var W1=m-1;W1>=0;--W1)A8[W1]=W9.poll();return A8.total=m+K1,A8},q=(b,D="<b>",v="</b>")=>{var f=typeof D==="function"?D:void 0,u=b.target,y=u.length,k=b.indexes,n="",m=0,K1=0,X1=!1,G0=[];for(var r1=0;r1<y;++r1){var W1=u[r1];if(k[K1]===r1){if(++K1,!X1)if(X1=!0,f)G0.push(n),n="";else n+=D;if(K1===k.length){if(f)n+=W1,G0.push(f(n,m++)),n="",G0.push(u.substr(r1+1));else n+=W1+v+u.substr(r1+1);break}}else if(X1)if(X1=!1,f)G0.push(f(n,m++)),n="";else n+=v;n+=W1}return f?G0:n},J=(b)=>{if(typeof b==="number")b=""+b;else if(typeof b!=="string")b="";var D=c(b);return K(b,{_targetLower:D._lower,_targetLowerCodes:D.lowerCodes,_bitflags:D.bitflags})},X=()=>{O.clear(),I.clear()};class H{get["indexes"](){return this._indexes.slice(0,this._indexes.len).sort((b,D)=>b-D)}set["indexes"](b){return this._indexes=b}["highlight"](b,D){return q(this,b,D)}get["score"](){return W(this._score)}set["score"](b){this._score=z(b)}}class G extends Array{get["score"](){return W(this._score)}set["score"](b){this._score=z(b)}}var K=(b,D)=>{let v=new H;return v.target=b,v.obj=D.obj??$1,v._score=D._score??o,v._indexes=D._indexes??[],v._targetLower=D._targetLower??"",v._targetLowerCodes=D._targetLowerCodes??$1,v._nextBeginningIndexes=D._nextBeginningIndexes??$1,v._bitflags=D._bitflags??0,v},W=(b)=>{if(b===o)return 0;if(b>1)return b;return Math.E**(((-b+1)**0.04307-1)*-2)},z=(b)=>{if(b===0)return o;if(b>1)return b;return 1-Math.pow(Math.log(b)/-2+1,23.218017181332716)},B=(b)=>{if(typeof b==="number")b=""+b;else if(typeof b!=="string")b="";b=b.trim();var D=c(b),v=[];if(D.containsSpace){var f=b.split(/\s+/);f=[...new Set(f)];for(var u=0;u<f.length;u++){if(f[u]==="")continue;var y=c(f[u]);v.push({lowerCodes:y.lowerCodes,_lower:f[u].toLowerCase(),containsSpace:!1})}}return{lowerCodes:D.lowerCodes,_lower:D._lower,containsSpace:D.containsSpace,bitflags:D.bitflags,spaceSearches:v}},Z=(b)=>{if(b.length>999)return J(b);var D=O.get(b);if(D!==void 0)return D;return D=J(b),O.set(b,D),D},M=(b)=>{if(b.length>999)return B(b);var D=I.get(b);if(D!==void 0)return D;return D=B(b),I.set(b,D),D},V=(b,D)=>{var v=[];v.total=b.length;var f=D?.limit||e;if(D?.key)for(var u=0;u<b.length;u++){var y=b[u],k=E(y,D.key);if(k==$1)continue;if(!C(k))k=Z(k);var n=K(k.target,{_score:k._score,obj:y});if(v.push(n),v.length>=f)return v}else if(D?.keys)for(var u=0;u<b.length;u++){var y=b[u],m=new G(D.keys.length);for(var K1=D.keys.length-1;K1>=0;--K1){var k=E(y,D.keys[K1]);if(!k){m[K1]=H0;continue}if(!C(k))k=Z(k);k._score=o,k._indexes.len=0,m[K1]=k}if(m.obj=y,m._score=o,v.push(m),v.length>=f)return v}else for(var u=0;u<b.length;u++){var k=b[u];if(k==$1)continue;if(!C(k))k=Z(k);if(k._score=o,k._indexes.len=0,v.push(k),v.length>=f)return v}return v},U=(b,D,v=!1,f=!1)=>{if(v===!1&&b.containsSpace)return R(b,D,f);var{_lower:u,lowerCodes:y}=b,k=y[0],n=D._targetLowerCodes,m=y.length,K1=n.length,W1=0,X1=0,G0=0;for(;;){var r1=k===n[X1];if(r1){if(w[G0++]=X1,++W1,W1===m)break;k=y[W1]}if(++X1,X1>=K1)return $1}var W1=0,$0=!1,V1=0,j1=D._nextBeginningIndexes;if(j1===$1)j1=D._nextBeginningIndexes=x(D.target);X1=w[0]===0?0:j1[w[0]-1];var V8=0;if(X1!==K1)for(;;)if(X1>=K1){if(W1<=0)break;if(++V8,V8>200)break;--W1;var D0=i[--V1];X1=j1[D0]}else{var r1=y[W1]===n[X1];if(r1){if(i[V1++]=X1,++W1,W1===m){$0=!0;break}++X1}else X1=j1[X1]}var a1=m<=1?-1:D._targetLower.indexOf(u,w[0]),H1=!!~a1,o1=!H1?!1:a1===0||D._nextBeginningIndexes[a1-1]===a1;if(H1&&!o1)for(var Y1=0;Y1<j1.length;Y1=j1[Y1]){if(Y1<=a1)continue;for(var Z0=0;Z0<m;Z0++)if(y[Z0]!==D._targetLowerCodes[Y1+Z0])break;if(Z0===m){a1=Y1,o1=!0;break}}var p1=(A1)=>{var w1=0,z5=0;for(var $8=1;$8<m;++$8)if(A1[$8]-A1[$8-1]!==1)w1-=A1[$8],++z5;var GW=A1[m-1]-A1[0]-(m-1);if(w1-=(12+GW)*z5,A1[0]!==0)w1-=A1[0]*A1[0]*0.2;if(!$0)w1*=1000;else{var L7=1;for(var $8=j1[0];$8<K1;$8=j1[$8])++L7;if(L7>24)w1*=(L7-24)*10}if(w1-=(K1-m)/2,H1)w1/=1+m*m*1;if(o1)w1/=1+m*m*1;return w1-=(K1-m)/2,w1};if(!$0){if(H1)for(var Y1=0;Y1<m;++Y1)w[Y1]=a1+Y1;var A8=w,y8=p1(A8)}else if(o1){for(var Y1=0;Y1<m;++Y1)w[Y1]=a1+Y1;var A8=w,y8=p1(w)}else var A8=i,y8=p1(i);D._score=y8;for(var Y1=0;Y1<m;++Y1)D._indexes[Y1]=A8[Y1];D._indexes.len=m;let f2=new H;return f2.target=D.target,f2._score=D._score,f2._indexes=D._indexes,f2},R=(b,D,v)=>{var f=new Set,u=0,y=$1,k=0,n=b.spaceSearches,m=n.length,K1=0,X1=()=>{for(let o1=K1-1;o1>=0;o1--)D._nextBeginningIndexes[l[o1*2+0]]=l[o1*2+1]},G0=!1;for(var H1=0;H1<m;++H1){J1[H1]=o;var r1=n[H1];if(y=U(r1,D),v){if(y===$1)continue;G0=!0}else if(y===$1)return X1(),$1;var W1=H1===m-1;if(!W1){var $0=y._indexes,V1=!0;for(let Y1=0;Y1<$0.len-1;Y1++)if($0[Y1+1]-$0[Y1]!==1){V1=!1;break}if(V1){var j1=$0[$0.len-1]+1,V8=D._nextBeginningIndexes[j1-1];for(let Y1=j1-1;Y1>=0;Y1--){if(V8!==D._nextBeginningIndexes[Y1])break;D._nextBeginningIndexes[Y1]=j1,l[K1*2+0]=Y1,l[K1*2+1]=V8,K1++}}}if(u+=y._score/m,J1[H1]=y._score/m,y._indexes[0]<k)u-=(k-y._indexes[0])*2;k=y._indexes[0];for(var D0=0;D0<y._indexes.len;++D0)f.add(y._indexes[D0])}if(v&&!G0)return $1;X1();var a1=U(b,D,!0);if(a1!==$1&&a1._score>u){if(v)for(var H1=0;H1<m;++H1)J1[H1]=a1._score/m;return a1}if(v)y=D;y._score=u;var H1=0;for(let o1 of f)y._indexes[H1++]=o1;return y._indexes.len=H1,y},N=(b)=>b.replace(/\p{Script=Latin}+/gu,(D)=>D.normalize("NFD")).replace(/[\u0300-\u036f]/g,""),c=(b)=>{b=N(b);var D=b.length,v=b.toLowerCase(),f=[],u=0,y=!1;for(var k=0;k<D;++k){var n=f[k]=v.charCodeAt(k);if(n===32){y=!0;continue}var m=n>=97&&n<=122?n-97:n>=48&&n<=57?26:n<=127?30:31;u|=1<<m}return{lowerCodes:f,bitflags:u,containsSpace:y,_lower:v}},T=(b)=>{var D=b.length,v=[],f=0,u=!1,y=!1;for(var k=0;k<D;++k){var n=b.charCodeAt(k),m=n>=65&&n<=90,K1=m||n>=97&&n<=122||n>=48&&n<=57,X1=m&&!u||!y||!K1;if(u=m,y=K1,X1)v[f++]=k}return v},x=(b)=>{b=N(b);var D=b.length,v=T(b),f=[],u=v[0],y=0;for(var k=0;k<D;++k)if(u>k)f[k]=u;else u=v[++y],f[k]=u===void 0?D:u;return f},O=new Map,I=new Map,w=[],i=[],l=[],r=[],J1=[],S=[],g=[],E=(b,D)=>{var v=b[D];if(v!==void 0)return v;if(typeof D==="function")return D(b);var f=D;if(!Array.isArray(D))f=D.split(".");var u=f.length,y=-1;while(b&&++y<u)b=b[f[y]];return b},C=(b)=>{return typeof b==="object"&&typeof b._bitflags==="number"},e=1/0,o=-e,D1=[];D1.total=0;var $1=null,H0=J(""),A7=(b)=>{var D=[],v=0,f={},u=(y)=>{for(var k=0,n=D[k],m=1;m<v;){var K1=m+1;k=m,K1<v&&D[K1]._score<D[m]._score&&(k=K1),D[k-1>>1]=D[k],m=1+(k<<1)}for(var X1=k-1>>1;k>0&&n._score<D[X1]._score;X1=(k=X1)-1>>1)D[k]=D[X1];D[k]=n};return f.add=(y)=>{var k=v;D[v++]=y;for(var n=k-1>>1;k>0&&y._score<D[n]._score;n=(k=n)-1>>1)D[k]=D[n];D[k]=y},f.poll=(y)=>{if(v!==0){var k=D[0];return D[0]=D[--v],u(),k}},f.peek=(y)=>{if(v!==0)return D[0]},f.replaceTop=(y)=>{D[0]=y,u()},f},W9=A7();return{single:$,go:Y,prepare:J,cleanup:X}})});var WK={};F8(WK,{runSearchCore:()=>KK,runSearchCommandAction:()=>oA});async function oA(Q,$){if($.installed){let q=await L0($.cwd);if(!q||Object.keys(q.installed).length===0){if($.json)F1({success:!0,data:{components:[]}});else _.info("No components installed.");return}let J=Object.entries(q.installed).map(([X,H])=>({name:`${H.registryName}/${H.name}`,registry:H.registryUrl,version:H.revision,installedAt:void 0}));if($.json)F1({success:!0,data:{components:J}});else{_.info(`Installed components (${J.length}):`);for(let X of J)console.log(` ${P.cyan(X.name)} ${P.dim(`v${X.version}`)} from ${X.registry}`)}return}let Y;if($.profile){let q=await e0.create($.cwd,{profile:$.profile});Y={cwd:q.getCwd(),getRegistries:()=>q.getRegistries(),getComponentPath:()=>q.getComponentPath()}}else Y=await R0.requireInitialized($.cwd);await KK(Q,$,Y)}async function KK(Q,$,Y){let q=Y.getRegistries();if($.verbose)_.info(`Searching in ${Object.keys(q).length} registries...`);let J=[],X=M1({text:"Searching registries...",quiet:$.quiet||$.verbose});if(!$.json&&!$.verbose)X.start();for(let[G,K]of Object.entries(q))try{if($.verbose)_.info(`Fetching index from ${G} (${K.url})...`);let W=await P8(K.url);if($.verbose)_.info(`Found ${W.components.length} components in ${G}`);for(let z of W.components)J.push({name:`${G}/${z.name}`,description:z.description,type:z.type,registry:G})}catch(W){if($.verbose)_.warn(`Failed to fetch registry ${G}: ${W instanceof Error?W.message:String(W)}`)}if(!$.json&&!$.verbose)X.stop();let H=J;if(Q)H=a6.default.go(Q,J,{keys:["name","description"],limit:$.limit}).map((K)=>K.obj);else H=H.slice(0,$.limit);if($.json){F1({success:!0,data:{components:H}});return}if(H.length===0){_.info("No components found.");return}_.info(`Found ${H.length} components:`);for(let G of H)console.log(` ${P.cyan(G.name)} ${P.dim(`(${G.type})`)} - ${G.description}`)}var a6;var zK=A(()=>{W8();k9();O2();t8();k4();c1();l0();a6=B5(GK(),1)});function sA(Q){let $=parseInt(Q,10);if(Number.isNaN($)||$<=0)throw new LJ("Must be a positive integer");return $}function BK(Q){let $=Q.command("search").alias("list").description("Search for components across registries or list installed").argument("[query]","Search query").option("--installed","List installed components only",!1).option("-p, --profile <name>","Use specific profile").addOption(new B8("--limit <n>","Limit results").default(20).argParser(sA));Q0($),B0($),$.action(async(Y,q)=>{try{let{runSearchCommandAction:J}=await Promise.resolve().then(() => (zK(),WK));await J(Y,q)}catch(J){s(J,{json:q.json})}})}var _K=A(()=>{L3();y1();k0()});function ZK(Q){let $=["curl","npm","yarn","pnpm","bun"],Y=$.find((q)=>q===Q);if(!Y)throw new x1(`Invalid install method: "${Q}"
253
+ Valid methods: ${$.join(", ")}`);return Y}function n9(){if(rA())return"curl";let Q=process.argv[1]??"";if(aA(Q))return"unknown";if(tA(Q))return"yarn";if(eA(Q))return"pnpm";if(QL(Q))return"bun";if($L(Q))return"npm";let $=process.env.npm_config_user_agent??"";if($.includes("yarn"))return"yarn";if($.includes("pnpm"))return"pnpm";if($.includes("bun"))return"bun";if($.includes("npm"))return"npm";return"unknown"}function K7(){if(typeof Bun<"u"&&Bun.main.startsWith("/$bunfs/"))return process.execPath;return process.argv[1]??process.execPath}var rA=()=>Bun.main.startsWith("/$bunfs/"),aA=(Q)=>Q.includes("/_npx/")||Q.includes("/.cache/bunx/")||Q.includes("/.pnpm/_temp/"),tA=(Q)=>Q.includes("/.yarn/global")||Q.includes("/.config/yarn/global"),eA=(Q)=>Q.includes("/.pnpm/")||Q.includes("/pnpm/global"),QL=(Q)=>Q.includes("/.bun/bin")||Q.includes("/.bun/install/global"),$L=(Q)=>Q.includes("/.npm/")||Q.includes("/node_modules/");var W7=A(()=>{t()});import{existsSync as e6,lstatSync as VK,readdirSync as YL,realpathSync as MK,rmSync as qL,unlinkSync as AK}from"fs";import{homedir as LK}from"os";import i0 from"path";function t6(Q,$=0){F1({success:!0,data:Q}),process.exit($)}function X9(Q,$,Y,q){let J={success:!1,error:{code:Q,message:$,...q&&{details:q}},exitCode:Y,meta:{timestamp:new Date().toISOString()}};F1(J),process.exit(Y)}function Q5(Q){return Q instanceof Error&&"code"in Q}function y2(Q){let $=LK();if(!$)return Q;if(Q===$)return"~";if(Q.startsWith($+i0.sep))return`~${Q.slice($.length)}`;return Q}function B7(Q,$){let Y=i0.normalize(Q),q=i0.normalize($),J=i0.relative(Y,q);if(J.startsWith("..")||i0.isAbsolute(J))return null;return J}function JL(Q,$){return B7(Q,$)!==null}function XL(Q,$){if(!e6($))return{contained:!0};try{let Y=MK(Q),q=MK($);return{contained:B7(Y,q)!==null}}catch(Y){if(Q5(Y)&&(Y.code==="EACCES"||Y.code==="EPERM"))return{contained:!1,error:"permission"};return{contained:!1,error:"io"}}}function FK(Q){try{let $=VK(Q);if($.isSymbolicLink())return{valid:!1,reason:"symlink"};if(!$.isDirectory())return{valid:!1,reason:"not-directory"};return{valid:!0}}catch($){if(Q5($)){if($.code==="ENOENT")return{valid:!1,reason:"not-found"};if($.code==="EACCES"||$.code==="EPERM")return{valid:!1,reason:"permission"}}return{valid:!1,reason:"permission"}}}function h2(Q){if(!e6(Q))return"missing";try{let $=VK(Q);if($.isSymbolicLink())return"symlink";if($.isDirectory())return"directory";return"file"}catch{return"missing"}}function HL(Q){if(!e6(Q))return!0;try{return YL(Q).length===0}catch{return!1}}function UK(Q){if(Q.kind==="missing")return"safe";if(Q.kind==="symlink")return JL(Q.rootPath,Q.absolutePath)?"safe":"forbidden";let $=XL(Q.rootPath,Q.absolutePath);if($.error)return"error";return $.contained?"safe":"forbidden"}function H9(Q){return Q==="npm"||Q==="pnpm"||Q==="bun"||Q==="yarn"}function _7(Q){switch(Q){case"npm":return"npm uninstall -g ocx";case"pnpm":return"pnpm remove -g ocx";case"bun":return"bun remove -g ocx";case"yarn":return"yarn global remove ocx";default:return"npm uninstall -g ocx"}}function $5(){let Q=process.env.XDG_CONFIG_HOME||i0.join(LK(),".config");return i0.join(Q,"opencode")}function jK(){let Q=$5(),$=[],Y=_8(),q=B7(Q,Y);if(q){let G=h2(Y);$.push({rootPath:Q,relativePath:q,absolutePath:Y,displayPath:y2(Y),kind:G,deleteIfEmpty:!1,safetyStatus:UK({rootPath:Q,absolutePath:Y,kind:G})})}let J=P9(),X=B7(Q,J);if(X){let G=h2(J);$.push({rootPath:Q,relativePath:X,absolutePath:J,displayPath:y2(J),kind:G,deleteIfEmpty:!1,safetyStatus:UK({rootPath:Q,absolutePath:J,kind:G})})}let H=h2(Q);return $.push({rootPath:Q,relativePath:".",absolutePath:Q,displayPath:y2(Q),kind:H,deleteIfEmpty:!0,safetyStatus:H==="missing"?"safe":"safe"}),$}function wK(){let Q=n9();if(H9(Q))return null;if(Q==="curl"){let $=K7(),Y=h2($);return{rootPath:i0.dirname($),relativePath:i0.basename($),absolutePath:$,displayPath:y2($),kind:Y,deleteIfEmpty:!1,safetyStatus:Y==="missing"?"safe":"safe"}}return null}function GL(Q){if(Q.kind==="missing")return{target:Q,success:!0,skipped:!0,reason:"not found"};if(Q.safetyStatus==="forbidden")return{target:Q,success:!1,skipped:!0,reason:"containment violation",error:Error("Target escapes containment boundary")};if(Q.deleteIfEmpty&&Q.kind==="directory"){if(!HL(Q.absolutePath))return{target:Q,success:!0,skipped:!0,reason:"not empty"}}try{if(Q.kind==="directory")qL(Q.absolutePath,{recursive:!0,force:!0});else AK(Q.absolutePath);return{target:Q,success:!0,skipped:!1}}catch($){let Y=$ instanceof Error?$:Error(String($)),q=Q5($)&&($.code==="EACCES"||$.code==="EPERM")?"permission denied":void 0;return{target:Q,success:!1,skipped:!1,reason:q,error:Y}}}function DK(Q){return Q.map(GL)}function OK(Q,$={}){let Y={rootPath:i0.dirname(Q),relativePath:i0.basename(Q),absolutePath:Q,displayPath:y2(Q),kind:h2(Q),deleteIfEmpty:!1,safetyStatus:"safe"};if(Y.kind==="missing")return{target:Y,success:!0,skipped:!0,reason:"not found"};if(process.platform==="win32"){if(!$.suppressOutput)_.info(`To complete uninstall, manually delete: ${Y.displayPath}`);return{target:Y,success:!0,skipped:!0}}try{return AK(Q),{target:Y,success:!0,skipped:!1}}catch(q){let J=q instanceof Error?q:Error(String(q));return{target:Y,success:!1,skipped:!1,reason:"permission denied",error:J}}}function KL(Q,$,Y){let{dryRunResult:q,hints:J}=IK(Q,$,Y);w0(q,{hints:J})}function IK(Q,$,Y){let q=Q.filter((G)=>G.kind!=="missing"),J=[];for(let G of q)J.push({action:"delete",target:G.displayPath,details:{kind:G.kind,...G.deleteIfEmpty&&{deleteIfEmpty:!0}}});if($&&$.kind!=="missing")J.push({action:"delete",target:$.displayPath,details:{kind:"binary"}});let X=[];if(H9(Y))X.push(`Binary is managed by ${Y}. Run: ${_7(Y)}`);return{dryRunResult:{dryRun:!0,command:"self uninstall",wouldPerform:J,validation:{passed:!0},summary:J.length>0?`Would remove ${J.length} item(s)`:"Nothing to remove"},hints:X}}function WL(Q,$){if(Q.filter((q)=>q.kind!=="missing").length>0||$&&$.kind!=="missing")_.info("Removing OCX files...")}function zL(Q,$,Y){_.break();for(let q of Q){if(q.skipped){if(q.reason==="not found")continue;if(q.reason==="not empty"){_.info(`Kept ${F0.path(q.target.displayPath)} (not empty)`);continue}if(q.reason==="permission denied"){_.warn(`Skipped ${F0.path(q.target.displayPath)} (permission denied)`);continue}if(q.reason==="containment violation"){_.warn(`Skipped ${F0.path(q.target.displayPath)} (containment violation)`);continue}}if(q.success)_.success(`Removed ${F0.path(q.target.displayPath)}`);else _.error(`Failed to remove ${q.target.displayPath}: ${q.error?.message}`)}if($){if($.skipped&&$.reason==="not found");else if($.success&&!$.skipped)_.success(`Removed binary ${F0.path($.target.displayPath)}`);else if(!$.success)_.error(`Failed to remove binary ${$.target.displayPath}: ${$.error?.message}`)}if(H9(Y))_.break(),_.info(`Binary is managed by ${Y}. To complete uninstall, run:`),_.log(` ${F0.command(_7(Y))}`)}function BL(){_.info("Nothing to remove. OCX is not installed globally.")}function z7(Q){return{path:Q.target.displayPath,kind:Q.target.kind,success:Q.success,skipped:Q.skipped,...Q.reason&&{reason:Q.reason},...Q.error&&{error:Q.error.message}}}async function _L(Q){let $=$5(),Y=FK($);if(!Y.valid)switch(Y.reason){case"not-found":break;case"symlink":return X9("VALIDATION_ERROR","Safety error: Global config root is a symlink. Aborting.",d1.SAFETY_ERROR);case"not-directory":return X9("VALIDATION_ERROR","Safety error: Global config root is not a directory. Aborting.",d1.SAFETY_ERROR);case"permission":return X9("PERMISSION_ERROR","Error: Cannot access global config root (permission denied).",d1.ERROR)}let q=jK(),J=q.filter((N)=>N.safetyStatus==="forbidden");if(J.length>0)return X9("VALIDATION_ERROR","Safety error: Target escapes containment boundary.",d1.SAFETY_ERROR,{targets:J.map((N)=>N.displayPath)});let X=q.filter((N)=>N.safetyStatus==="error");if(X.length>0)return X9("PERMISSION_ERROR","Error: Cannot verify containment for targets (permission/IO error).",d1.ERROR,{targets:X.map((N)=>N.displayPath)});let H=n9(),G=wK(),K=q.filter((N)=>N.kind!=="missing"),W=Boolean(G&&G.kind!=="missing"),z=H9(H);if(K.length===0&&!W&&!z)return t6({message:"Nothing to remove. OCX is not installed globally.",removed:[],skipped:[]},d1.SUCCESS);if(Q.dryRun){let{dryRunResult:N,hints:c}=IK(q,G,H);return t6({...N,...c.length>0&&{hints:c}},d1.SUCCESS)}let B=DK(q),Z=null;if(G)Z=OK(G.absolutePath,{suppressOutput:!0});let M=B.some((N)=>!N.success&&!N.skipped),V=Boolean(Z&&!Z.success&&!Z.skipped);if(M||V)return X9("PERMISSION_ERROR","Failed to remove one or more uninstall targets.",d1.ERROR,{configResults:B.map(z7),...Z&&{binaryResult:z7(Z)}});if(H9(H))return X9("UPDATE_ERROR",`Binary is managed by ${H}. Run: ${_7(H)}`,d1.ERROR,{installMethod:H,command:_7(H),configResults:B.map(z7),...Z&&{binaryResult:z7(Z)}});let U=B.filter((N)=>N.success&&!N.skipped).map((N)=>N.target.displayPath),R=B.filter((N)=>N.skipped).map((N)=>({path:N.target.displayPath,reason:N.reason??"skipped"}));if(Z){if(Z.success&&!Z.skipped)U.push(Z.target.displayPath);else if(Z.skipped)R.push({path:Z.target.displayPath,reason:Z.reason??"skipped"})}return t6({removed:U,skipped:R,installMethod:H},d1.SUCCESS)}async function ZL(Q){if(Q.json){await _L(Q);return}let $=$5(),Y=FK($);if(!Y.valid)switch(Y.reason){case"not-found":break;case"symlink":_.error("Safety error: Global config root is a symlink. Aborting."),process.exit(d1.SAFETY_ERROR);break;case"not-directory":_.error("Safety error: Global config root is not a directory. Aborting."),process.exit(d1.SAFETY_ERROR);break;case"permission":_.error("Error: Cannot access global config root (permission denied)."),process.exit(d1.ERROR);break}let q=jK(),J=q.filter((U)=>U.safetyStatus==="forbidden");if(J.length>0){_.error("Safety error: Target escapes containment boundary:");for(let U of J)_.error(` ${U.displayPath}`);process.exit(d1.SAFETY_ERROR)}let X=q.filter((U)=>U.safetyStatus==="error");if(X.length>0){_.error("Error: Cannot verify containment for targets (permission/IO error):");for(let U of X)_.error(` ${U.displayPath}`);process.exit(d1.ERROR)}let H=n9(),G=wK(),K=q.filter((U)=>U.kind!=="missing"),W=G&&G.kind!=="missing",z=H9(H);if(K.length===0&&!W&&!z)BL(),process.exit(d1.SUCCESS);if(Q.dryRun)KL(q,G,H),process.exit(d1.SUCCESS);WL(q,G);let B=DK(q),Z=null;if(G)Z=OK(G.absolutePath);zL(B,Z,H);let M=B.some((U)=>!U.success&&!U.skipped),V=Z&&!Z.success&&!Z.skipped;if(M||V)process.exit(d1.ERROR);if(H9(H))process.exit(d1.ERROR);process.exit(d1.SUCCESS)}function NK(Q){Q.command("uninstall").description("Remove OCX global configuration and binary").option("--dry-run","Preview what would be removed").option("--json","Output as JSON").action(async($)=>{try{await ZL($)}catch(Y){s(Y,{json:$.json})}})}var d1;var TK=A(()=>{W0();W7();e8();y1();c1();d1={SUCCESS:0,ERROR:1,SAFETY_ERROR:2}});class bK{version="2.0.9"}var RK;var SK=A(()=>{RK=new bK});var kK={};F8(kK,{checkForUpdate:()=>q5,EXPLICIT_UPDATE_TIMEOUT_MS:()=>Y5});function EK(Q){let[$=""]=Q.split("-"),Y=$.split("."),q=parseInt(Y[0]??"",10),J=parseInt(Y[1]??"",10),X=parseInt(Y[2]??"",10);if(Number.isNaN(q)||Number.isNaN(J)||Number.isNaN(X))return null;return{major:q,minor:J,patch:X}}function VL(Q,$){let Y=EK(Q),q=EK($);if(!Y||!q)return null;if(Y.major!==q.major)return Y.major-q.major;if(Y.minor!==q.minor)return Y.minor-q.minor;return Y.patch-q.patch}async function q5(Q,$=ML){let q=(Q??RK).version||"0.0.0-dev";if(q==="0.0.0-dev")return{ok:!1,reason:"dev-version"};try{let X=(await v3(UL,void 0,AbortSignal.timeout($))).version,H=VL(X,q);if(H===null)return{ok:!1,reason:"invalid-response"};return{ok:!0,current:q,latest:X,updateAvailable:H>0}}catch(J){if(J instanceof Error){if(J.name==="AbortError"||J.name==="TimeoutError")return{ok:!1,reason:"timeout"};if(J instanceof I1||J.name==="NetworkError")return{ok:!1,reason:"network-error"}}return{ok:!1,reason:"invalid-response"}}}var ML=200,Y5=1e4,UL="ocx";var J5=A(()=>{t();X6();SK()});import{chmodSync as AL,existsSync as G9,renameSync as X5,unlinkSync as Z7}from"fs";function jL(){let Q=process.env.OCX_DOWNLOAD_URL;if(Q)return Q.replace(/\/+$/,"");return FL}function H5(Q){let $=`${process.arch}-${process.platform}`,Y=vK[$];if(!Y){let J=Object.keys(vK).join(", ");throw new x1(`Unsupported platform: ${$}
254
+ Supported platforms: ${J}`)}return`${jL()}/v${Q}/${Y}`}async function wL(Q,$,Y={}){let q=Y.quiet?null:M1({text:"Downloading update..."});q?.start();let J;try{J=await fetch(Q,{redirect:"follow"})}catch(W){throw q?.fail("Download failed"),new x1(`Network error: ${W instanceof Error?W.message:String(W)}`)}if(!J.ok)throw q?.fail("Download failed"),new x1(`Failed to download: HTTP ${J.status} ${J.statusText}`);if(!J.body)throw q?.fail("Download failed"),new x1("Download failed: Empty response body");let X=J.body.getReader(),H=Bun.file($).writer(),G=Number(J.headers.get("content-length")||0),K=0;try{while(!0){let{done:W,value:z}=await X.read();if(W)break;if(await H.write(z),K+=z.length,G>0&&q){let B=Math.round(K/G*100);q.text=`Downloading... ${B}%`}}await H.end(),q?.succeed("Download complete")}catch(W){throw q?.fail("Download failed"),await H.end(),new x1(`Download interrupted: ${W instanceof Error?W.message:String(W)}`)}}async function PK(Q,$={}){let Y=K7(),q=`${Y}.new.${Date.now()}`,J=H5(Q);await wL(J,q,$);try{AL(q,493)}catch(X){if(G9(q))Z7(q);throw new x1(`Failed to set permissions: ${X instanceof Error?X.message:String(X)}`)}return{tempPath:q,execPath:Y}}function xK(Q,$){let Y=`${$}.backup`;try{if(G9($))X5($,Y);if(X5(Q,$),G9(Y))Z7(Y)}catch(q){if(G9(Y)&&!G9($))try{X5(Y,$)}catch{}if(G9(Q))try{Z7(Q)}catch{}throw new x1(`Update failed: ${q instanceof Error?q.message:String(q)}`)}}function CK(Q){if(G9(Q))try{Z7(Q)}catch{}}var LL="kdcokenny/ocx",FL,vK;var yK=A(()=>{t();l0();W7();FL=`https://github.com/${LL}/releases/download`,vK={"arm64-darwin":"ocx-darwin-arm64","x64-darwin":"ocx-darwin-x64","arm64-linux":"ocx-linux-arm64","x64-linux":"ocx-linux-x64","x64-win32":"ocx-windows-x64.exe"}});var hK={};F8(hK,{notifyUpdated:()=>M7,notifyUpdate:()=>DL,notifyUpToDate:()=>G5});function DL(Q,$){if(!process.stdout.isTTY)return;console.error(`${P.cyan("info")}: update available - ${P.green($)} (current: ${P.dim(Q)})`),console.error(` run ${P.cyan("`ocx self update`")} to upgrade`)}function G5(Q){console.error(`${P.cyan("info")}: ocx unchanged - ${P.dim(Q)}`)}function M7(Q,$){console.error(` ${P.green("ocx updated")} - ${$} (from ${Q})`)}var K5=A(()=>{W8()});import{createHash as OL}from"crypto";function NL(Q){let $=new Map;for(let Y of Q.split(`
255
+ `)){let q=Y.match(/^([a-fA-F0-9]{64})\s+\*?(.+)$/);if(q?.[1]&&q[2])$.set(q[2].trim(),q[1].toLowerCase())}return $}function TL(Q){return OL("sha256").update(Q).digest("hex")}async function fK(Q){let $=`https://github.com/${IL}/releases/download/v${Q}/SHA256SUMS.txt`,Y=await fetch($);if(!Y.ok)throw new x1(`Failed to fetch checksums: ${Y.status}`);let q=await Y.text();return NL(q)}async function uK(Q,$,Y){let J=await Bun.file(Q).arrayBuffer(),X=TL(Buffer.from(J));if(X!==$)throw new m8(Y,$,X)}var IL="kdcokenny/ocx";var mK=A(()=>{t()});var gK={};F8(gK,{runSelfUpdateCommand:()=>SL});async function SL(Q){let $=Q.method?ZK(Q.method):n9(),Y=Q.json===!0,q=await q5(void 0,Y5);if(!q.ok)throw new x1(RL[q.reason]);let{current:J,latest:X,updateAvailable:H}=q;if(!H&&!Q.force){if(Y)F1({success:!0,data:{current:J,latest:X,method:$,updated:!1}});else G5(J);return}let G=X;switch($){case"curl":{await EL(J,G,Y);break}case"npm":case"pnpm":case"bun":case"yarn":case"unknown":{await kL($,J,G,Y);break}}if(Y)F1({success:!0,data:{current:J,latest:G,method:$,updated:!0}})}async function EL(Q,$,Y){let J=H5($).split("/").pop();if(!J)throw new x1("Failed to determine binary filename from download URL");let H=(await fK($)).get(J);if(!H)throw new x1(`Security error: No checksum found for ${J}. Update aborted.`);let{tempPath:G,execPath:K}=await PK($,{quiet:Y});try{await uK(G,H,J)}catch(W){throw CK(G),W}if(xK(G,K),!Y)M7(Q,$)}async function U7(Q){let $=Bun.spawn(Q,{stdout:"pipe",stderr:"pipe"});if(await $.exited!==0){let q=await new Response($.stderr).text();throw new x1(`Package manager command failed: ${q.trim()}`)}}async function kL(Q,$,Y,q){if(!bL.test(Y))throw new x1(`Invalid version format: ${Y}`);let J=q?null:M1({text:`Updating via ${Q}...`});J?.start();try{switch(Q){case"npm":{await U7(["npm","install","-g",`ocx@${Y}`]);break}case"yarn":{await U7(["yarn","global","add",`ocx@${Y}`]);break}case"pnpm":{await U7(["pnpm","install","-g",`ocx@${Y}`]);break}case"bun":{await U7(["bun","install","-g",`ocx@${Y}`]);break}case"unknown":throw new x1(`Could not detect install method. Update manually with one of:
256
256
  npm install -g ocx@latest
257
257
  pnpm install -g ocx@latest
258
- bun install -g ocx@latest`)}if(J?.succeed(`Updated via ${Q}`),!q)M7($,Y)}catch(X){if(X instanceof x1)throw J?.fail("Update failed"),X;throw J?.fail("Update failed"),new x1(`Failed to run ${Q}: ${X instanceof Error?X.message:String(X)}`)}}var IL,NL;var cK=A(()=>{J5();W7();yK();K5();mK();t();l0();IL=/^\d+\.\d+\.\d+(-[\w.]+)?$/,NL={"dev-version":"Cannot check for updates in development mode. Install via npm for update support.",timeout:"Update check timed out after 10s. Try again or check your network.","network-error":"Cannot reach npm registry. Verify your internet connection.","invalid-response":"Received invalid response from npm registry. Try again later."}});function dK(Q){Q.command("update").description("Update OCX to the latest version").option("-f, --force","Reinstall even if already up to date").option("--method <method>","Override install method detection (curl|npm|pnpm|bun)").option("--json","Output as JSON").action(async($)=>{try{let{runSelfUpdateCommand:Y}=await Promise.resolve().then(() => (cK(),gK));await Y($)}catch(Y){s(Y,{json:$.json})}})}var pK=A(()=>{y1()});function lK(Q){let $=Q.command("self").description("Manage the OCX CLI");NK($),dK($)}var iK=A(()=>{TK();pK()});import{randomUUID as nK}from"crypto";import{existsSync as K9}from"fs";import{mkdir as SL,rename as EL,rm as V7,stat as kL,writeFile as vL}from"fs/promises";import{dirname as PL,join as xL}from"path";function W5(Q,$){return`ocx add${$.global?" --global":""} ${Q}`}function oK(Q){return Q==="apply"?"Failed to update components":"Failed to check for updates"}function sK(Q){let $=Q.command("update [components...]").description("Update installed components");Q0($),E0($),Q8($),$.option("--all","Update all installed components").option("--registry <name>","Update all components from a specific registry").option("--dry-run","Preview changes without applying").action(async(Y,q)=>{try{await CL(Y,q)}catch(J){s(J,{json:q.json})}})}async function CL(Q,$){let Y=$.cwd??process.cwd(),q=$.global?await E9.requireInitialized():await b0.requireInitialized(Y);await yL(Q,$,q)}async function yL(Q,$,Y,q){let J=Y.getRegistries(),X=Y.getComponentPath(),H=X===""||X===".",G=Q.map(fL),K=await A0(Y.cwd);if(!K||Object.keys(K.installed).length===0){if(Q.length>0){let N=Q[0];if(!N)throw Error("Unexpected: component name missing despite non-empty componentNames");throw new _1(`Component '${N}' is not installed. Run '${W5(N,$)}' first.`)}throw new _1(`No components installed. Run '${W5("<component>",$)}' first.`)}let W=Q.length>0,z=$.all===!0,B=$.registry!==void 0;if(!W&&!z&&!B)throw new L(`Specify components, use --all, or use --registry <name>.
258
+ bun install -g ocx@latest`)}if(J?.succeed(`Updated via ${Q}`),!q)M7($,Y)}catch(X){if(X instanceof x1)throw J?.fail("Update failed"),X;throw J?.fail("Update failed"),new x1(`Failed to run ${Q}: ${X instanceof Error?X.message:String(X)}`)}}var bL,RL;var cK=A(()=>{J5();W7();yK();K5();mK();t();l0();bL=/^\d+\.\d+\.\d+(-[\w.]+)?$/,RL={"dev-version":"Cannot check for updates in development mode. Install via npm for update support.",timeout:"Update check timed out after 10s. Try again or check your network.","network-error":"Cannot reach npm registry. Verify your internet connection.","invalid-response":"Received invalid response from npm registry. Try again later."}});function dK(Q){Q.command("update").description("Update OCX to the latest version").option("-f, --force","Reinstall even if already up to date").option("--method <method>","Override install method detection (curl|npm|pnpm|bun)").option("--json","Output as JSON").action(async($)=>{try{let{runSelfUpdateCommand:Y}=await Promise.resolve().then(() => (cK(),gK));await Y($)}catch(Y){s(Y,{json:$.json})}})}var pK=A(()=>{y1()});function lK(Q){let $=Q.command("self").description("Manage the OCX CLI");NK($),dK($)}var iK=A(()=>{TK();pK()});import{randomUUID as nK}from"crypto";import{existsSync as K9}from"fs";import{mkdir as vL,rename as PL,rm as V7,stat as xL,writeFile as CL}from"fs/promises";import{dirname as yL,join as hL}from"path";function W5(Q,$){return`ocx add${$.global?" --global":""} ${Q}`}function oK(Q){return Q==="apply"?"Failed to update components":"Failed to check for updates"}function sK(Q){let $=Q.command("update [components...]").description("Update installed components");Q0($),B0($),Q8($),$.option("--all","Update all installed components").option("--registry <name>","Update all components from a specific registry").option("--dry-run","Preview changes without applying").action(async(Y,q)=>{try{await fL(Y,q)}catch(J){s(J,{json:q.json})}})}async function fL(Q,$){let Y=$.cwd??process.cwd(),q=$.global?await E9.requireInitialized():await R0.requireInitialized(Y);await uL(Q,$,q)}async function uL(Q,$,Y,q){let J=Y.getRegistries(),X=Y.getComponentPath(),H=X===""||X===".",G=Q.map(gL),K=await L0(Y.cwd);if(!K||Object.keys(K.installed).length===0){if(Q.length>0){let T=Q[0];if(!T)throw Error("Unexpected: component name missing despite non-empty componentNames");throw new _1(`Component '${T}' is not installed. Run '${W5(T,$)}' first.`)}throw new _1(`No components installed. Run '${W5("<component>",$)}' first.`)}let W=Q.length>0,z=$.all===!0,B=$.registry!==void 0;if(!W&&!z&&!B)throw new L(`Specify components, use --all, or use --registry <name>.
259
259
 
260
260
  Examples:
261
261
  ocx update alias/component # Update specific component
@@ -263,12 +263,12 @@ Examples:
263
263
  ocx update --registry my-alias # Update all from a registry`);if(z&&W)throw new L(`Cannot specify components with --all.
264
264
  Use either 'ocx update --all' or 'ocx update <components>'.`);if(B&&W)throw new L(`Cannot specify components with --registry.
265
265
  Use either 'ocx update --registry <name>' or 'ocx update <components>'.`);if(z&&B)throw new L(`Cannot use --all with --registry.
266
- Use either 'ocx update --all' or 'ocx update --registry <name>'.`);let Z=uL(K,G,$);if(Z.length===0){if(B)throw new _1(`No installed components from registry '${$.registry}'.`);throw new _1("No matching components found to update.")}let M=$.quiet?null:M1({text:"Checking for updates..."});M?.start();let V=null,U="check",R=null,I=[],c=[];try{for(let w of Z){let b=w.component,D=K.installed[b];if(!D)throw new _1(`Component '${b}' not found in receipt.`);let{registryName:l,name:i}=D,r=J[l];if(!r)throw new h(`Registry alias '${l}' not configured. Component '${b}' cannot be updated.`);let S=(await E3(r.url,i,void 0)).manifest,u=d8(S),E=[];for(let o of u.files){let D1=await a8(r.url,i,o.path);E.push({path:o.path,content:Buffer.from(D1)})}let C=await x3(E),e=`sha256:${C}`;if(C===D.hash)I.push({qualifiedName:b,oldVersion:D.revision,newVersion:e,status:"up-to-date"});else if($.dryRun)I.push({qualifiedName:b,oldVersion:D.revision,newVersion:e,status:"would-update"});else I.push({qualifiedName:b,oldVersion:D.revision,newVersion:e,status:"updated"}),c.push({canonicalId:b,component:u,files:E,newHash:C,newVersion:e,baseUrl:r.url,registryName:l,name:i})}if(M?.succeed(`Checked ${Z.length} component(s)`),$.dryRun){mL(I,$);return}if(c.length===0){if(!$.quiet&&!$.json)_.info(""),_.success("All components are up to date.");if($.json)console.log(JSON.stringify({success:!0,updated:[],upToDate:I},null,2));return}U="apply",V=$.quiet?null:M1({text:"Updating components..."}),V?.start();let N=new Map,x=[];for(let w of c){let b=[];for(let D of w.files){let l=w.component.files.find((J1)=>J1.path===D.path);if(!l)throw new L(`File "${D.path}" not found in component manifest for "${w.registryName}/${w.name}".`);let i=i8(l.target,H,Y.cwd),r=xL(Y.cwd,i);Q9(N,{absolutePath:r,relativePath:i,content:D.content,source:`${w.registryName}/${w.name}:${l.path}`}),b.push({resolvedTarget:i,targetPath:r,content:D.content})}x.push({update:w,preparedFiles:b})}R=await hL(x,{verbose:$.verbose,quiet:$.quiet,fileOps:q});for(let w of x){let{update:b,preparedFiles:D}=w,l=K.installed[b.canonicalId];if(!l)throw new _1(`Component '${b.canonicalId}' not found in receipt.`);let i=[];for(let r of D)i.push({path:r.resolvedTarget,hash:$9(r.content)});K.installed[b.canonicalId]={registryUrl:l.registryUrl,registryName:l.registryName,name:l.name,revision:b.newVersion,hash:b.newHash,files:i,installedAt:l.installedAt,updatedAt:new Date().toISOString(),...b.component.opencode&&{opencode:b.component.opencode}}}if(await N0(Y.cwd,K),!R)throw Error("Internal error: missing applied write transaction after update apply phase.");if(await R.commit(),R=null,V?.succeed(`Updated ${c.length} component(s)`),$.json)console.log(JSON.stringify({success:!0,updated:I.filter((w)=>w.status==="updated"),upToDate:I.filter((w)=>w.status==="up-to-date")},null,2));else if(!$.quiet){_.info("");for(let w of I)if(w.status==="updated")_.info(` \u2713 ${w.qualifiedName} (${w.oldVersion} \u2192 ${w.newVersion})`);else if(w.status==="up-to-date"&&$.verbose)_.info(` \u25CB ${w.qualifiedName} (already up to date)`);_.info(""),_.success(`Done! Updated ${c.length} component(s).`)}}catch(N){if(U==="apply"){if(R)await R.rollback(),R=null;V?.fail(oK("apply"))}else M?.fail(oK("check"));throw N}}async function hL(Q,$){let Y=[],q=new Set,J=!1,X=$.fileOps?.rename??EL,H=async()=>{if(J)return;J=!0;for(let K of q)try{await V7(K,{force:!0})}catch{}for(let K of[...Y].reverse())try{if(K.backupPath){if(K9(K.targetPath))await V7(K.targetPath,{force:!0,recursive:!0});if(K9(K.backupPath))await X(K.backupPath,K.targetPath)}else if(K9(K.targetPath))await V7(K.targetPath,{force:!0,recursive:!0})}catch{}},G=async()=>{if(J)return;J=!0;for(let K of Y){if(!K.backupPath)continue;if(K9(K.backupPath))try{await V7(K.backupPath,{force:!0})}catch(W){if(!$.quiet){let z=W instanceof Error?W.message:String(W);_.warn(`Post-update cleanup warning: failed to remove backup "${K.backupPath}" (${z})`)}}}};try{for(let K of Q)for(let W of K.preparedFiles){let z=PL(W.targetPath);if(!K9(z))await SL(z,{recursive:!0});if(K9(W.targetPath)){if((await kL(W.targetPath)).isDirectory())throw new L(`Cannot update "${W.resolvedTarget}": target path is a directory.`)}let B=`${W.targetPath}.ocx-update-tmp-${nK()}`;await vL(B,W.content),q.add(B);let Z=null;if(K9(W.targetPath))Z=`${W.targetPath}.ocx-update-backup-${nK()}`,await X(W.targetPath,Z),Y.push({targetPath:W.targetPath,backupPath:Z});if(await X(B,W.targetPath),q.delete(B),!Z)Y.push({targetPath:W.targetPath,backupPath:null});if($.verbose)_.info(` \u2713 Updated ${W.resolvedTarget}`)}return{commit:G,rollback:H}}catch(K){throw await H(),K}}function fL(Q){if(Q.endsWith("@"))throw new h(`Invalid version specifier '${Q}'. The trailing '@' has no version.
267
- Use '${Q.slice(0,-1)}' to update to the latest version.`);return{component:Q}}function uL(Q,$,Y){let q=Object.keys(Q.installed);if(Y.all)return q.map((X)=>({component:X}));if(Y.registry)return q.filter((X)=>{return Q.installed[X]?.registryName===Y.registry}).map((X)=>({component:X}));let J=[];for(let X of $){let H=X.component;if(!H.includes("/")){let B=q.map((Z)=>{let M=R8(Z);return`${M.registryName}/${M.name}`}).filter((Z)=>Z.endsWith(`/${H}`));if(B.length===1)throw new L(`Ambiguous component '${H}'. Did you mean '${B[0]}'?`);if(B.length>1)throw new L(`Ambiguous component '${H}'. Found in multiple registries:
266
+ Use either 'ocx update --all' or 'ocx update --registry <name>'.`);let Z=cL(K,G,$);if(Z.length===0){if(B)throw new _1(`No installed components from registry '${$.registry}'.`);throw new _1("No matching components found to update.")}let M=$.quiet?null:M1({text:"Checking for updates..."});M?.start();let V=null,U="check",R=null,N=[],c=[];try{for(let O of Z){let I=O.component,w=K.installed[I];if(!w)throw new _1(`Component '${I}' not found in receipt.`);let{registryName:i,name:l}=w,r=J[i];if(!r)throw new h(`Registry alias '${i}' not configured. Component '${I}' cannot be updated.`);let S=(await E3(r.url,l,void 0)).manifest,g=d8(S),E=[];for(let o of g.files){let D1=await a8(r.url,l,o.path);E.push({path:o.path,content:Buffer.from(D1)})}let C=await x3(E),e=`sha256:${C}`;if(C===w.hash)N.push({qualifiedName:I,oldVersion:w.revision,newVersion:e,status:"up-to-date"});else if($.dryRun)N.push({qualifiedName:I,oldVersion:w.revision,newVersion:e,status:"would-update"});else N.push({qualifiedName:I,oldVersion:w.revision,newVersion:e,status:"updated"}),c.push({canonicalId:I,component:g,files:E,newHash:C,newVersion:e,baseUrl:r.url,registryName:i,name:l})}if(M?.succeed(`Checked ${Z.length} component(s)`),$.dryRun){dL(N,$);return}if(c.length===0){if(!$.quiet&&!$.json)_.info(""),_.success("All components are up to date.");if($.json)console.log(JSON.stringify({success:!0,updated:[],upToDate:N},null,2));return}U="apply",V=$.quiet?null:M1({text:"Updating components..."}),V?.start();let T=new Map,x=[];for(let O of c){let I=[];for(let w of O.files){let i=O.component.files.find((J1)=>J1.path===w.path);if(!i)throw new L(`File "${w.path}" not found in component manifest for "${O.registryName}/${O.name}".`);let l=i8(i.target,H,Y.cwd),r=hL(Y.cwd,l);Q9(T,{absolutePath:r,relativePath:l,content:w.content,source:`${O.registryName}/${O.name}:${i.path}`}),I.push({resolvedTarget:l,targetPath:r,content:w.content})}x.push({update:O,preparedFiles:I})}R=await mL(x,{verbose:$.verbose,quiet:$.quiet,fileOps:q});for(let O of x){let{update:I,preparedFiles:w}=O,i=K.installed[I.canonicalId];if(!i)throw new _1(`Component '${I.canonicalId}' not found in receipt.`);let l=[];for(let r of w)l.push({path:r.resolvedTarget,hash:$9(r.content)});K.installed[I.canonicalId]={registryUrl:i.registryUrl,registryName:i.registryName,name:i.name,revision:I.newVersion,hash:I.newHash,files:l,installedAt:i.installedAt,updatedAt:new Date().toISOString(),...I.component.opencode&&{opencode:I.component.opencode}}}if(await T0(Y.cwd,K),!R)throw Error("Internal error: missing applied write transaction after update apply phase.");if(await R.commit(),R=null,V?.succeed(`Updated ${c.length} component(s)`),$.json)console.log(JSON.stringify({success:!0,updated:N.filter((O)=>O.status==="updated"),upToDate:N.filter((O)=>O.status==="up-to-date")},null,2));else if(!$.quiet){_.info("");for(let O of N)if(O.status==="updated")_.info(` \u2713 ${O.qualifiedName} (${O.oldVersion} \u2192 ${O.newVersion})`);else if(O.status==="up-to-date"&&$.verbose)_.info(` \u25CB ${O.qualifiedName} (already up to date)`);_.info(""),_.success(`Done! Updated ${c.length} component(s).`)}}catch(T){if(U==="apply"){if(R)await R.rollback(),R=null;V?.fail(oK("apply"))}else M?.fail(oK("check"));throw T}}async function mL(Q,$){let Y=[],q=new Set,J=!1,X=$.fileOps?.rename??PL,H=async()=>{if(J)return;J=!0;for(let K of q)try{await V7(K,{force:!0})}catch{}for(let K of[...Y].reverse())try{if(K.backupPath){if(K9(K.targetPath))await V7(K.targetPath,{force:!0,recursive:!0});if(K9(K.backupPath))await X(K.backupPath,K.targetPath)}else if(K9(K.targetPath))await V7(K.targetPath,{force:!0,recursive:!0})}catch{}},G=async()=>{if(J)return;J=!0;for(let K of Y){if(!K.backupPath)continue;if(K9(K.backupPath))try{await V7(K.backupPath,{force:!0})}catch(W){if(!$.quiet){let z=W instanceof Error?W.message:String(W);_.warn(`Post-update cleanup warning: failed to remove backup "${K.backupPath}" (${z})`)}}}};try{for(let K of Q)for(let W of K.preparedFiles){let z=yL(W.targetPath);if(!K9(z))await vL(z,{recursive:!0});if(K9(W.targetPath)){if((await xL(W.targetPath)).isDirectory())throw new L(`Cannot update "${W.resolvedTarget}": target path is a directory.`)}let B=`${W.targetPath}.ocx-update-tmp-${nK()}`;await CL(B,W.content),q.add(B);let Z=null;if(K9(W.targetPath))Z=`${W.targetPath}.ocx-update-backup-${nK()}`,await X(W.targetPath,Z),Y.push({targetPath:W.targetPath,backupPath:Z});if(await X(B,W.targetPath),q.delete(B),!Z)Y.push({targetPath:W.targetPath,backupPath:null});if($.verbose)_.info(` \u2713 Updated ${W.resolvedTarget}`)}return{commit:G,rollback:H}}catch(K){throw await H(),K}}function gL(Q){if(Q.endsWith("@"))throw new h(`Invalid version specifier '${Q}'. The trailing '@' has no version.
267
+ Use '${Q.slice(0,-1)}' to update to the latest version.`);return{component:Q}}function cL(Q,$,Y){let q=Object.keys(Q.installed);if(Y.all)return q.map((X)=>({component:X}));if(Y.registry)return q.filter((X)=>{return Q.installed[X]?.registryName===Y.registry}).map((X)=>({component:X}));let J=[];for(let X of $){let H=X.component;if(!H.includes("/")){let B=q.map((Z)=>{let M=R8(Z);return`${M.registryName}/${M.name}`}).filter((Z)=>Z.endsWith(`/${H}`));if(B.length===1)throw new L(`Ambiguous component '${H}'. Did you mean '${B[0]}'?`);if(B.length>1)throw new L(`Ambiguous component '${H}'. Found in multiple registries:
268
268
  `+B.map((Z)=>` - ${Z}`).join(`
269
269
  `)+`
270
270
 
271
- Please use a fully qualified name (alias/component).`);throw new L(`Component '${H}' must include a registry alias (e.g., 'kdco/${H}').`)}let{namespace:G,component:K}=m0(H),W=q.filter((B)=>{let Z=R8(B);return Z.registryName===G&&Z.name===K});if(W.length===0)throw new _1(`Component '${H}' is not installed.
272
- Run '${W5(H,Y)}' to install it first.`);let z=W[0];if(!z)throw Error("Unexpected: matchingIds has length but first element is undefined");J.push({component:z})}return J}function mL(Q,$){let Y=Q.filter((X)=>X.status==="would-update"),J={dryRun:!0,command:"update",wouldPerform:Y.map((X)=>({action:"update",target:X.qualifiedName,details:{from:X.oldVersion,to:X.newVersion}})),validation:{passed:!0},summary:Y.length>0?`Would update ${Y.length} component(s)`:"All components are up to date"};j0(J,{json:$.json,quiet:$.quiet})}var rK=A(()=>{k9();t8();q0();g0();e8();t();y1();c1();k8();P3();y9();d0();l0()});import{resolve as gL}from"path";function cL(Q,$){if($==="not_found")return new _1(Q);if($==="parse_error")return new B1(Q,"CONFIG_ERROR",G1.CONFIG);return new B1(Q,"CONFIG_ERROR",G1.CONFIG)}function dL(Q,$){let Y=P2(Q,{schemaErrors:$==="schema"?Q.length:0}),q={valid:!1,errors:Q,summary:{valid:!1,totalErrors:Y.totalErrors,schemaErrors:Y.schemaErrors,sourceFileErrors:Y.sourceFileErrors,circularDependencyErrors:Y.circularDependencyErrors,duplicateTargetErrors:Y.duplicateTargetErrors,otherErrors:Y.otherErrors}};return new u8(q)}function pL(Q){for(let $ of Q)console.log(P.red(` ${$}`))}function aK(Q){Q.command("validate").description("Validate a registry source (for registry authors)").argument("[path]","Registry source directory",".").option("--cwd <path>","Working directory",process.cwd()).option("--json","Output as JSON",!1).option("-q, --quiet","Suppress output",!1).option("--no-duplicate-targets","Skip duplicate target validation").action(async($,Y)=>{try{let q=gL(Y.cwd,$),J=await o3(q,{skipDuplicateTargets:Y.duplicateTargets===!1});if(!J.success){let[X="Registry validation failed"]=J.errors;if(J.failureType==="load"){let G=cL(X,J.loadErrorKind);if(!Y.json&&Y.quiet){let K=G instanceof B1?G.exitCode:G1.GENERAL;process.exit(K)}throw G}let H=dL(J.errors,J.failureType==="schema"?"schema":"rules");if(Y.json)throw H;if(!Y.quiet)_.error(H.message),pL(J.errors);process.exit(H.exitCode)}if(!Y.quiet&&!Y.json)_.success("\u2713 Registry source is valid");if(Y.json)F1({success:!0,data:{valid:!0,errors:[],summary:P2([])}})}catch(q){if(!Y.json&&Y.quiet){let J=q instanceof B1?q.exitCode:G1.GENERAL;process.exit(J)}s(q,{json:Y.json})}})}var tK=A(()=>{W8();P6();t();y1();c1()});function eK(Q){let $=Q.command("verify").description("Verify integrity of installed components").argument("[components...]","Components to verify (optional, verifies all if omitted)");Q0($),E0($),$.action(async(Y,q)=>{try{await lL(Y,q)}catch(J){s(J,{json:q.json})}})}async function lL(Q,$){let Y=$.cwd??process.cwd(),q=await b0.requireInitialized(Y),J=await A0(q.cwd);if(!J||Object.keys(J.installed).length===0){if($.json)console.log(JSON.stringify({success:!0,verified:[],errors:[]},null,2));else if(!$.quiet)_.info("No components installed.");return}let X;if(Q.length>0)X=H7(Q,J);else X=Object.keys(J.installed);let H=$.quiet||$.json?null:M1({text:"Verifying components..."});H?.start();let G=[],K=!1;for(let W of X){let z=J.installed[W];if(!z){if(Q.length>0)_.warn(`Component '${W}' not found in receipt.`);continue}let B=await T2(q.cwd,z);if(!B.intact)K=!0;G.push({canonicalId:W,intact:B.intact,modified:B.modified,missing:B.missing})}if(H?.succeed(`Verified ${G.length} component(s)`),$.json){if(console.log(JSON.stringify({success:!K,verified:G.filter((W)=>W.intact),errors:G.filter((W)=>!W.intact)},null,2)),K)process.exit(G1.CONFLICT);return}if(!$.quiet){_.info("");for(let W of G)if(W.intact){if($.verbose)_.success(`\u2713 ${W.canonicalId} - all files intact`)}else{_.error(`\u2717 ${W.canonicalId} - integrity check failed`);for(let z of W.modified)_.error(` Modified: ${z}`);for(let z of W.missing)_.error(` Missing: ${z}`)}}if(K){if(!$.quiet)_.info(""),_.warn("Some files have been modified or are missing. Review local changes with git, then run 'ocx update <alias/component>' or 'ocx update --all' to restore.");throw new n1("File integrity check failed for one or more components.")}if(!$.quiet)_.info(""),_.success("All components verified successfully.")}var QW=A(()=>{k9();q0();r6();t();y1();c1();y9();d0();l0()});function iL(){if(process.env.OCX_SELF_UPDATE==="off")return!1;if(QJ(process.env.OCX_NO_UPDATE_CHECK,!1))return!1;if(process.env.CI)return!1;if(!process.stdout.isTTY)return!1;return!0}function $W(Q){Q.hook("postAction",async($,Y)=>{if(Y.name()==="update"&&Y.parent?.name()==="self")return;let q=Y.opts();if(q.json||q.quiet)return;if(!iL())return;try{let[{checkForUpdate:J},{notifyUpdate:X}]=await Promise.all([Promise.resolve().then(() => (J5(),kK)),Promise.resolve().then(() => (K5(),hK))]),H=await J();if(H.ok&&H.updateAvailable)X(H.current,H.latest)}catch{}})}var YW=A(()=>{F2()});async function qW(Q=process.argv){let $=new FJ().name("ocx").description("OpenCode Extensions - Install agents, skills, plugins, and commands").version(nL);if(eH($),yH($),sK($),BK($),QK($),cH($),aK($),lK($),eK($),JK($),KG($),rG($),sH($),EG($),$W($),Q.length<=2){process.stdout.write($.helpInformation());return}await $.parseAsync(Q)}var nL="2.0.8";var JW=A(()=>{L3();v6();dH();rH();$G();zG();kG();aG();$K();XK();_K();iK();rK();tK();QW();YW()});var XW={};F8(XW,{runCliEntryPoint:()=>oL});async function oL(Q=process.argv){try{await qW(Q)}catch($){s($)}}var HW=A(()=>{y1();JW()});_3();k4();if(import.meta.main)sL();async function sL(){let{runCliEntryPoint:Q}=await Promise.resolve().then(() => (HW(),XW));await Q()}export{p8 as registrySchema,M2 as packumentSchema,M3 as ocxLockSchema,b8 as ocxConfigSchema,c8 as componentManifestSchema,U2 as buildRegistry};
271
+ Please use a fully qualified name (alias/component).`);throw new L(`Component '${H}' must include a registry alias (e.g., 'kdco/${H}').`)}let{namespace:G,component:K}=g0(H),W=q.filter((B)=>{let Z=R8(B);return Z.registryName===G&&Z.name===K});if(W.length===0)throw new _1(`Component '${H}' is not installed.
272
+ Run '${W5(H,Y)}' to install it first.`);let z=W[0];if(!z)throw Error("Unexpected: matchingIds has length but first element is undefined");J.push({component:z})}return J}function dL(Q,$){let Y=Q.filter((X)=>X.status==="would-update"),J={dryRun:!0,command:"update",wouldPerform:Y.map((X)=>({action:"update",target:X.qualifiedName,details:{from:X.oldVersion,to:X.newVersion}})),validation:{passed:!0},summary:Y.length>0?`Would update ${Y.length} component(s)`:"All components are up to date"};w0(J,{json:$.json,quiet:$.quiet})}var rK=A(()=>{k9();t8();q0();c0();e8();t();y1();c1();k8();P3();y9();k0();l0()});import{resolve as pL}from"path";function lL(Q,$){if($==="not_found")return new _1(Q);if($==="parse_error")return new B1(Q,"CONFIG_ERROR",G1.CONFIG);return new B1(Q,"CONFIG_ERROR",G1.CONFIG)}function iL(Q,$){let Y=P2(Q,{schemaErrors:$==="schema"?Q.length:0}),q={valid:!1,errors:Q,summary:{valid:!1,totalErrors:Y.totalErrors,schemaErrors:Y.schemaErrors,sourceFileErrors:Y.sourceFileErrors,circularDependencyErrors:Y.circularDependencyErrors,duplicateTargetErrors:Y.duplicateTargetErrors,otherErrors:Y.otherErrors}};return new u8(q)}function nL(Q){for(let $ of Q)console.log(P.red(` ${$}`))}function aK(Q){Q.command("validate").description("Validate a registry source (for registry authors)").argument("[path]","Registry source directory",".").option("--cwd <path>","Working directory",process.cwd()).option("--json","Output as JSON",!1).option("-q, --quiet","Suppress output",!1).option("--no-duplicate-targets","Skip duplicate target validation").action(async($,Y)=>{try{let q=pL(Y.cwd,$),J=await o3(q,{skipDuplicateTargets:Y.duplicateTargets===!1});if(!J.success){let[X="Registry validation failed"]=J.errors;if(J.failureType==="load"){let G=lL(X,J.loadErrorKind);if(!Y.json&&Y.quiet){let K=G instanceof B1?G.exitCode:G1.GENERAL;process.exit(K)}throw G}let H=iL(J.errors,J.failureType==="schema"?"schema":"rules");if(Y.json)throw H;if(!Y.quiet)_.error(H.message),nL(J.errors);process.exit(H.exitCode)}if(!Y.quiet&&!Y.json)_.success("\u2713 Registry source is valid");if(Y.json)F1({success:!0,data:{valid:!0,errors:[],summary:P2([])}})}catch(q){if(!Y.json&&Y.quiet){let J=q instanceof B1?q.exitCode:G1.GENERAL;process.exit(J)}s(q,{json:Y.json})}})}var tK=A(()=>{W8();P6();t();y1();c1()});function eK(Q){let $=Q.command("verify").description("Verify integrity of installed components").argument("[components...]","Components to verify (optional, verifies all if omitted)");Q0($),B0($),$.action(async(Y,q)=>{try{await oL(Y,q)}catch(J){s(J,{json:q.json})}})}async function oL(Q,$){let Y=$.cwd??process.cwd(),q=await R0.requireInitialized(Y),J=await L0(q.cwd);if(!J||Object.keys(J.installed).length===0){if($.json)console.log(JSON.stringify({success:!0,verified:[],errors:[]},null,2));else if(!$.quiet)_.info("No components installed.");return}let X;if(Q.length>0)X=H7(Q,J);else X=Object.keys(J.installed);let H=$.quiet||$.json?null:M1({text:"Verifying components..."});H?.start();let G=[],K=!1;for(let W of X){let z=J.installed[W];if(!z){if(Q.length>0)_.warn(`Component '${W}' not found in receipt.`);continue}let B=await T2(q.cwd,z);if(!B.intact)K=!0;G.push({canonicalId:W,intact:B.intact,modified:B.modified,missing:B.missing})}if(H?.succeed(`Verified ${G.length} component(s)`),$.json){if(console.log(JSON.stringify({success:!K,verified:G.filter((W)=>W.intact),errors:G.filter((W)=>!W.intact)},null,2)),K)process.exit(G1.CONFLICT);return}if(!$.quiet){_.info("");for(let W of G)if(W.intact){if($.verbose)_.success(`\u2713 ${W.canonicalId} - all files intact`)}else{_.error(`\u2717 ${W.canonicalId} - integrity check failed`);for(let z of W.modified)_.error(` Modified: ${z}`);for(let z of W.missing)_.error(` Missing: ${z}`)}}if(K){if(!$.quiet)_.info(""),_.warn("Some files have been modified or are missing. Review local changes with git, then run 'ocx update <alias/component>' or 'ocx update --all' to restore.");throw new n1("File integrity check failed for one or more components.")}if(!$.quiet)_.info(""),_.success("All components verified successfully.")}var QW=A(()=>{k9();q0();r6();t();y1();c1();y9();k0();l0()});function sL(){if(process.env.OCX_SELF_UPDATE==="off")return!1;if(QJ(process.env.OCX_NO_UPDATE_CHECK,!1))return!1;if(process.env.CI)return!1;if(!process.stdout.isTTY)return!1;return!0}function $W(Q){Q.hook("postAction",async($,Y)=>{if(Y.name()==="update"&&Y.parent?.name()==="self")return;let q=Y.opts();if(q.json||q.quiet)return;if(!sL())return;try{let[{checkForUpdate:J},{notifyUpdate:X}]=await Promise.all([Promise.resolve().then(() => (J5(),kK)),Promise.resolve().then(() => (K5(),hK))]),H=await J();if(H.ok&&H.updateAvailable)X(H.current,H.latest)}catch{}})}var YW=A(()=>{F2()});async function qW(Q=process.argv){let $=new FJ().name("ocx").description("OpenCode Extensions - Install agents, skills, plugins, and commands").version(rL);if(eH($),yH($),sK($),BK($),QK($),cH($),aK($),lK($),eK($),JK($),KG($),rG($),sH($),EG($),$W($),Q.length<=2){process.stdout.write($.helpInformation());return}await $.parseAsync(Q)}var rL="2.0.9";var JW=A(()=>{L3();v6();dH();rH();$G();zG();kG();aG();$K();XK();_K();iK();rK();tK();QW();YW()});var XW={};F8(XW,{runCliEntryPoint:()=>aL});async function aL(Q=process.argv){try{await qW(Q)}catch($){s($)}}var HW=A(()=>{y1();JW()});_3();k4();if(import.meta.main)tL();async function tL(){let{runCliEntryPoint:Q}=await Promise.resolve().then(() => (HW(),XW));await Q()}export{p8 as registrySchema,M2 as packumentSchema,M3 as ocxLockSchema,b8 as ocxConfigSchema,c8 as componentManifestSchema,U2 as buildRegistry};
273
273
 
274
- //# debugId=036B4B03B684F1B764756E2164756E21
274
+ //# debugId=E31E2A787F91DAF064756E2164756E21