@getsolaris/oh-my-worktree 0.7.5 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/omw.js +61 -62
- package/package.json +1 -1
package/dist/omw.js
CHANGED
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var Oa=Object.defineProperty;var Wa=(t)=>t;function Da(t,e){this[t]=Wa.bind(null,e)}var xt=(t,e)=>{for(var o in e)Oa(t,o,{get:e[o],enumerable:!0,configurable:!0,set:Da.bind(e,o)})};var N=(t,e)=>()=>(t&&(e=t(t=0)),e);var he=import.meta.require;function ki(t){if(t instanceof Error)return t;return Error(typeof t==="string"?t:"Unknown error",{cause:t})}function zi(t,e=Ct){let o=e&&e.context&&e.context[Pf],n=ki(t);if(!o)throw n;try{for(let r of o)r(n)}catch(r){zi(r,e&&e.owner||null)}}function yf(){let t={owner:Ct,context:Ct?Ct.context:null,owned:null,cleanups:null};if(Ct)if(!Ct.owned)Ct.owned=[t];else Ct.owned.push(t);return t}function v(t,e){return[()=>t,(o)=>{return t=typeof o==="function"?o(t):o}]}function de(t,e){}function re(t,e){Ct=yf();let o;try{o=t(e)}catch(n){zi(n)}finally{Ct=Ct.owner}return()=>o}function Ye(t,e,o={}){let n=Array.isArray(t),r=o.defer;return()=>{if(r)return;let i;if(n){i=[];for(let s=0;s<t.length;s++)i.push(t[s]())}else i=t();return e(i)}}function an(t){if(Ct)if(!Ct.cleanups)Ct.cleanups=[t];else Ct.cleanups.push(t);return t}function to(t){let e=Symbol("context");return{id:e,Provider:Rf(e),defaultValue:t}}function eo(t){return Ct&&Ct.context&&Ct.context[t.id]!==void 0?Ct.context[t.id]:t.defaultValue}function Ef(t){let e=re(()=>sr(t()));return e.toArray=()=>{let o=e();return Array.isArray(o)?o:o!=null?[o]:[]},e}function sr(t){if(typeof t==="function"&&!t.length)return sr(t());if(Array.isArray(t)){let e=[];for(let o=0;o<t.length;o++){let n=sr(t[o]);Array.isArray(n)?e.push.apply(e,n):e.push(n)}return e}return t}function Rf(t){return function(o){return re(()=>{return Ct.context={...Ct.context,[t]:o.value},Ef(()=>o.children)})}}function Ni(t){let e=String(t),o=e.length-1;return pe.context.id+(o?String.fromCharCode(96+o):"")+e}function Mf(t,e){let o=t.each||[],n=o.length,r=t.children;if(n){let i=Array(n);for(let s=0;s<n;s++)i[s]=e(r,o[s],s);return i}return t.fallback}function St(t){return Mf(t,(e,o,n)=>e(o,()=>n))}function O(t){let e;return t.when?typeof(e=t.children)==="function"?e(t.keyed?t.when:()=>t.when):e:t.fallback||""}function vi(t,e,o={}){if(typeof e!=="function")o=e||{},e=t,t=!0;let n=new Set,r=pe.getNextContextId(),i={},s=o.storage?o.storage(o.initialValue)[0]():o.initialValue,c,f;if(pe.context.async&&o.ssrLoadFrom!=="initial"){if(i=pe.context.resources[r]||(pe.context.resources[r]={}),i.ref){if(!i.data&&!i.ref[0]._loading&&!i.ref[0].error)i.ref[1].refetch();return i.ref}}let a=()=>{if(f)throw f;let x=o.ssrLoadFrom!=="initial"&&pe.context.async&&"data"in pe.context.resources[r];if(!x&&Ao)Ao.push(r);if(!x&&h._loading){let m=eo(Of);if(m)m.resources.set(r,h),n.add(m)}return x},h=()=>{return a()?pe.context.resources[r].data:s},u=()=>{return a(),h._loading};h._loading=!1,h.error=void 0,h.state="initialValue"in o?"ready":"unresolved",Object.defineProperties(h,{latest:{get(){return h()}},loading:{get(){return u()}}});function d(){let x=pe.context;if(!x.async)return h._loading=!!(typeof t==="function"?t():t);if(x.resources&&r in x.resources&&"data"in x.resources[r]){s=x.resources[r].data;return}let m;try{if(Ao=[],m=typeof t==="function"?t():t,Ao.length)return}finally{Ao=null}if(!c){if(m==null||m===!1)return;c=e(m,{value:s})}if(c!=null&&typeof c==="object"&&"then"in c){if(h._loading=!0,h.state="pending",c=c.then((b)=>{return h._loading=!1,h.state="ready",x.resources[r].data=b,c=null,Ji(n),b}).catch((b)=>{throw h._loading=!1,h.state="errored",h.error=f=ki(b),c=null,Ji(n),f}),x.serialize)x.serialize(r,c,o.deferStream);return c}if(x.resources[r].data=c,x.serialize)x.serialize(r,c);return c=null,x.resources[r].data}if(o.ssrLoadFrom!=="initial")d();let g=[h,{refetch:d,mutate:(x)=>s=x}];if(c)i.ref=g;return g}function Wf(t){for(let e of t.resources.values())if(e._loading)return!1;return!0}function Ji(t){for(let e of t){if(!Wf(e))continue;e.completed(),t.delete(e)}}var Mm,Om,Wm,Pf,Ct=null,pe,Of,Ao=null;var Rt=N(()=>{Mm=Symbol("solid-proxy"),Om=Symbol("solid-track"),Wm=Symbol("solid-dev-component"),Pf=Symbol("error");pe={context:void 0,getContextId(){if(!this.context)throw Error("getContextId cannot be used under non-hydrating context");return Ni(this.context.count)},getNextContextId(){if(!this.context)throw Error("getNextContextId cannot be used under non-hydrating context");return Ni(this.context.count++)}};Of=to()});function Ui(t){return typeof t==="object"&&t!==null&&"frames"in t&&"interval"in t&&Array.isArray(t.frames)}function Vi(t){return typeof t==="object"&&t!==null&&"label"in t&&"onClick"in t}function cr(t,e){switch(t){case"success":return e.success;case"error":return e.error;case"warning":return e.warning;case"info":return e.info;case"loading":return ar(e.loading);default:return""}}function ar(t){if(Ui(t))return t.frames[0]??"\u25CC";return t}function fr(t){return Ui(t)?t:null}var Df,Ki;var qi=N(()=>{Df={frames:["\u25DC","\u25E0","\u25DD","\u25DE","\u25E1","\u25DF"],interval:100},Ki={success:"\u2713",error:"\u2717",warning:"!",info:"\u2139",loading:Df,close:"\xD7"}});import{BoxRenderable as ln,TextAttributes as Ff,TextRenderable as Io,parseColor as Bf}from"@opentui/core";function _f(t){return t!==null&&typeof t==="object"&&"ok"in t&&typeof t.ok==="boolean"&&"status"in t&&typeof t.status==="number"}function Jf(t,e={}){let[o,n]=t.split("-"),r={position:"absolute"};if(o==="top")r.top=e.top??fn.top;else r.bottom=e.bottom??fn.bottom;if(n==="left")r.left=e.left??fn.left,r.alignItems="flex-start";else if(n==="center")r.left=0,r.width="100%",r.alignItems="center";else r.right=e.right??fn.right,r.alignItems="flex-end";return r}function kf(t){return t.includes("center")}function zf(t){return t.startsWith("top")}function vf(t,e={top:0,right:0,bottom:0,left:0}){if(!t)return{...e};let{padding:o,paddingX:n,paddingY:r}=t;return{top:t.paddingTop??r??o??e.top,right:t.paddingRight??n??o??e.right,bottom:t.paddingBottom??r??o??e.bottom,left:t.paddingLeft??n??o??e.left}}function Uf(...t){let e={};for(let o of t){if(!o)continue;Object.assign(e,o)}return e}function Xi(t,e,o){let n=lr.style,r=lr[t]?.style,i=e?.style,s=e?.[t]?.style,c=Uf(n,r,i,s,o);if(c.border===!1)delete c.borderStyle,delete c.borderColor;return c}function Zi(t,e,o){if(o!==void 0)return o;let n=e?.[t]?.duration;if(n!==void 0)return n;if(e?.duration!==void 0)return e.duration;return lr.duration}var Lf,Af=200,Qi=60,fn,If,lr,jf=1,Tf=class{subscribers=[];toasts=[];dismissedToasts=new Set;_activeToasts=[];_updateActiveToastsCache=()=>{let t=this.toasts.filter((e)=>!this.dismissedToasts.has(e.id));if(t.length!==this._activeToasts.length||t.some((e,o)=>e!==this._activeToasts[o]))this._activeToasts=t};subscribe=(t)=>{return this.subscribers.push(t),()=>{let e=this.subscribers.indexOf(t);if(e>-1)this.subscribers.splice(e,1)}};publish=(t)=>{for(let e of this.subscribers)e(t)};addToast=(t)=>{this.toasts=[...this.toasts,t],this._updateActiveToastsCache(),this.publish(t)};create=(t)=>{let{message:e,...o}=t,n=typeof t.id==="number"||t.id&&t.id.length>0?t.id:jf++,r=this.toasts.find((s)=>s.id===n),i=t.dismissible===void 0?!0:t.dismissible;if(this.dismissedToasts.has(n))this.dismissedToasts.delete(n);if(r)this.toasts=this.toasts.map((s)=>{if(s.id===n)return this.publish({...s,...t,id:n,title:e}),{...s,...t,id:n,dismissible:i,title:e};return s}),this._updateActiveToastsCache();else this.addToast({title:e,...o,dismissible:i,id:n,type:t.type??"default"});return n};dismiss=(t)=>{if(t!==void 0)this.dismissedToasts.add(t),this._updateActiveToastsCache(),setTimeout(()=>{for(let e of this.subscribers)e({id:t,dismiss:!0})},0);else{for(let e of this.toasts){this.dismissedToasts.add(e.id);for(let o of this.subscribers)o({id:e.id,dismiss:!0})}this._updateActiveToastsCache()}return t};message=(t,e)=>{return this.create({...e,message:t,type:"default"})};error=(t,e)=>{return this.create({...e,message:t,type:"error"})};success=(t,e)=>{return this.create({...e,message:t,type:"success"})};info=(t,e)=>{return this.create({...e,message:t,type:"info"})};warning=(t,e)=>{return this.create({...e,message:t,type:"warning"})};loading=(t,e)=>{return this.create({...e,message:t,type:"loading"})};promise=(t,e)=>{if(!e)return;let o;if(e.loading!==void 0)o=this.create({...e,type:"loading",message:e.loading,description:typeof e.description!=="function"?e.description:void 0});let n=t instanceof Function?t():t,r=o!==void 0,i,s=n.then(async(f)=>{if(i=["resolve",f],_f(f)&&!f.ok){r=!1;let a=typeof e.error==="function"?await e.error(`HTTP error! status: ${f.status}`):e.error,h=typeof e.description==="function"?await e.description(`HTTP error! status: ${f.status}`):e.description,u=typeof a==="object"&&a!==null?a:{message:a};this.create({id:o,type:"error",description:h,...u})}else if(f instanceof Error){r=!1;let a=typeof e.error==="function"?await e.error(f):e.error,h=typeof e.description==="function"?await e.description(f):e.description,u=typeof a==="object"&&a!==null?a:{message:a};this.create({id:o,type:"error",description:h,...u})}else if(e.success!==void 0){r=!1;let a=typeof e.success==="function"?await e.success(f):e.success,h=typeof e.description==="function"?await e.description(f):e.description,u=typeof a==="object"&&a!==null?a:{message:a};this.create({id:o,type:"success",description:h,...u})}}).catch(async(f)=>{if(i=["reject",f],e.error!==void 0){r=!1;let a=typeof e.error==="function"?await e.error(f):e.error,h=typeof e.description==="function"?await e.description(f):e.description,u=typeof a==="object"&&a!==null?a:{message:a};this.create({id:o,type:"error",description:h,...u})}}).finally(()=>{if(r)this.dismiss(o),o=void 0;e.finally?.()}),c=()=>new Promise((f,a)=>s.then(()=>i[0]==="reject"?a(i[1]):f(i[1])).catch(a));if(typeof o!=="string"&&typeof o!=="number")return{unwrap:c};return Object.assign(o,{unwrap:c})};getActiveToasts=()=>{return this._activeToasts}},At,Gf=(t,e)=>At.message(t,e),Hf=()=>At.toasts,Nf=()=>At.getActiveToasts(),oo,Vf,Yi;var ts=N(()=>{qi();Lf={SHORT:2000,DEFAULT:4000,LONG:6000,EXTENDED:1e4,PERSISTENT:1/0},fn={top:1,right:2,bottom:1,left:2},If={border:!0,borderStyle:"single",borderColor:"#333333",minHeight:3,backgroundColor:"#1a1a1a",foregroundColor:"#ffffff",mutedColor:"#6b7280"},lr={style:If,duration:Lf.DEFAULT,default:{style:{borderColor:"#333333"}},success:{style:{borderColor:"#22c55e"}},error:{style:{borderColor:"#ef4444"}},warning:{style:{borderColor:"#f59e0b"}},info:{style:{borderColor:"#3b82f6"}},loading:{style:{borderColor:"#6b7280"}}};At=new Tf,oo=Object.assign(Gf,{success:At.success,info:At.info,warning:At.warning,error:At.error,message:At.message,promise:At.promise,dismiss:At.dismiss,loading:At.loading},{getHistory:Hf,getToasts:Nf});Vf=class extends ln{_toast;_icons;_toastOptions;_computedStyle;_closeButton;_onRemove;_remainingTime;_closeTimerStartTime=0;_lastCloseTimerStartTime=0;_timerHandle=null;_paused=!1;_dismissed=!1;_spinnerHandle=null;_spinnerFrameIndex=0;_spinnerConfig=null;_iconText=null;_contentBox=null;_titleText=null;_descriptionText=null;_actionsBox=null;constructor(t,e){let o=Xi(e.toast.type,e.toastOptions,e.toast.style),n=Zi(e.toast.type,e.toastOptions,e.toast.duration),r=vf(o,{top:0,right:1,bottom:0,left:1});super(t,{id:`toast-${e.toast.id}`,flexDirection:"row",gap:1,border:o.border,borderStyle:o.borderStyle,borderColor:o.borderColor,customBorderChars:o.customBorderChars,backgroundColor:o.backgroundColor,minHeight:o.minHeight,maxWidth:o.maxWidth??Qi,minWidth:o.minWidth,paddingTop:r.top,paddingRight:r.right,paddingBottom:r.bottom,paddingLeft:r.left,onMouseOver:()=>this.pause(),onMouseOut:()=>this.resume()});if(this._toast=e.toast,this._icons=e.icons===!1?!1:{...Ki,...e.icons},this._toastOptions=e.toastOptions,this._computedStyle=o,this._closeButton=e.closeButton,this._onRemove=e.onRemove,this._remainingTime=n,this.setupContent(),this._remainingTime!==1/0&&this._toast.type!=="loading")this.startTimer();if(this._toast.type==="loading")this.startSpinner()}setupContent(){let t=this.ctx,e=this._toast,o=this._computedStyle,n=this._icons,r=o.iconColor??o.borderColor,i=e.type==="loading";if(i&&n!==!1)this._spinnerConfig=fr(n.loading);let s=e.icon??(n===!1?void 0:i?ar(n.loading):cr(e.type,n));if(s)this._iconText=new Io(t,{id:`${this.id}-icon`,content:s,fg:r,flexShrink:0,paddingTop:0,paddingBottom:0}),this.add(this._iconText);this._contentBox=new ln(t,{id:`${this.id}-content`,flexDirection:"column",flexGrow:1,flexShrink:1,gap:0});let c=typeof e.title==="function"?e.title():e.title;if(c)this._titleText=new Io(t,{id:`${this.id}-title`,content:c,fg:o.foregroundColor,attributes:Ff.BOLD,wrapMode:"word"}),this._contentBox.add(this._titleText);let f=typeof e.description==="function"?e.description():e.description;if(f)this._descriptionText=new Io(t,{id:`${this.id}-description`,content:f,fg:o.mutedColor,wrapMode:"word"}),this._contentBox.add(this._descriptionText);if(this.add(this._contentBox),e.action){if(this._actionsBox=new ln(t,{id:`${this.id}-actions`,flexDirection:"row",gap:1,flexShrink:0,alignItems:"center"}),e.action&&Vi(e.action)){let a=new Io(t,{id:`${this.id}-action`,content:`[${e.action.label}]`,fg:o.foregroundColor,onMouseUp:()=>e.action?.onClick?.()});this._actionsBox.add(a)}this.add(this._actionsBox)}if((e.closeButton??this._closeButton)&&e.dismissible!==!1){let a=n===!1?"\xD7":n.close,h=new Io(t,{id:`${this.id}-close`,content:a,fg:o.mutedColor,flexShrink:0,onMouseUp:()=>this.dismiss()});this.add(h)}}startTimer(){if(this._remainingTime===1/0)return;this._closeTimerStartTime=Date.now(),this._timerHandle=setTimeout(()=>{this._toast.onAutoClose?.(this._toast),this.dismiss()},this._remainingTime)}pause(){if(this._paused||this._remainingTime===1/0)return;if(this._paused=!0,this._timerHandle)clearTimeout(this._timerHandle),this._timerHandle=null;if(this._lastCloseTimerStartTime<this._closeTimerStartTime){let t=Date.now()-this._closeTimerStartTime;this._remainingTime=Math.max(0,this._remainingTime-t)}this._lastCloseTimerStartTime=Date.now()}resume(){if(!this._paused||this._remainingTime===1/0)return;this._paused=!1,this.startTimer()}startSpinner(){if(this._spinnerHandle||!this._spinnerConfig)return;let{frames:t,interval:e}=this._spinnerConfig;this._spinnerHandle=setInterval(()=>{this._spinnerFrameIndex=(this._spinnerFrameIndex+1)%t.length;let o=t[this._spinnerFrameIndex];if(this._iconText&&o)this._iconText.content=o,this.requestRender()},e)}stopSpinner(){if(this._spinnerHandle)clearInterval(this._spinnerHandle),this._spinnerHandle=null}dismiss(){if(this._dismissed)return;if(this._dismissed=!0,this._timerHandle)clearTimeout(this._timerHandle),this._timerHandle=null;this.stopSpinner(),this._toast.onDismiss?.(this._toast),At.dismiss(this._toast.id),setTimeout(()=>{this._onRemove?.(this._toast)},Af)}updateToast(t){this._toast=t;let e=Xi(t.type,this._toastOptions,t.style);if(this._computedStyle=e,e.borderColor)this.borderColor=e.borderColor;if(e.customBorderChars)this.customBorderChars=e.customBorderChars;let o=e.iconColor??e.borderColor;if(this._iconText){let i=t.icon??(this._icons===!1?void 0:cr(t.type,this._icons));if(i)this._iconText.content=i;if(o)this._iconText.fg=Bf(o)}if(this._titleText){let i=typeof t.title==="function"?t.title():t.title;if(i)this._titleText.content=i}if(this._descriptionText){let i=typeof t.description==="function"?t.description():t.description;if(i)this._descriptionText.content=i}let n=this._spinnerHandle!==null,r=t.type==="loading";if(n&&!r)this.stopSpinner(),this._spinnerConfig=null;else if(!n&&r){if(this._icons!==!1)this._spinnerConfig=fr(this._icons.loading);this.startSpinner()}if(t.type!=="loading"){if(this._timerHandle)clearTimeout(this._timerHandle);if(this._remainingTime=Zi(t.type,this._toastOptions,t.duration),this._remainingTime!==1/0)this.startTimer()}this.requestRender()}get toast(){return this._toast}get isDismissed(){return this._dismissed}destroy(){if(this._timerHandle)clearTimeout(this._timerHandle),this._timerHandle=null;this.stopSpinner(),super.destroy()}},Yi=class extends ln{_options={};_toastRenderables=new Map;_unsubscribe=null;constructor(t,e={}){super(t,{id:"toaster",flexDirection:"column",gap:1,zIndex:9999});this._options=e,this.applyLayoutOptions(),this.subscribe()}applyLayoutOptions(){let t=this._options.position??"bottom-right",e=Jf(t,this._options.offset??{}),o=kf(t);if(Object.assign(this,e),super.gap=this._options.gap??1,!o)super.maxWidth=this._options.maxWidth??Qi}isToastPosition(t){return t==="top-left"||t==="top-center"||t==="top-right"||t==="bottom-left"||t==="bottom-center"||t==="bottom-right"}set position(t){if(this.isToastPosition(t))this._options.position=t,this.applyLayoutOptions();else super.position=t}set offset(t){this._options.offset=t,this.applyLayoutOptions()}set gap(t){this._options.gap=t,super.gap=t}set visibleToasts(t){this._options.visibleToasts=t}set closeButton(t){this._options.closeButton=t}set icons(t){this._options.icons=t}set stackingMode(t){this._options.stackingMode=t}set maxWidth(t){this._options.maxWidth=t,super.maxWidth=t}set toastOptions(t){this._options.toastOptions=t}subscribe(){this._unsubscribe=At.subscribe((t)=>{if("dismiss"in t&&t.dismiss)this.removeToast(t.id);else this.addOrUpdateToast(t)})}addOrUpdateToast(t){let e=this._toastRenderables.get(t.id);if(e){e.updateToast(t);return}if((this._options.stackingMode??"single")==="single")for(let[n]of this._toastRenderables)this.removeToast(n);else{let n=this._options.visibleToasts??3,r=this._toastRenderables.size;if(r>=n){let i=r-n+1,s=Array.from(this._toastRenderables.keys());for(let c=0;c<i;c++){let f=s[c];if(f!==void 0)this.removeToast(f)}}}let o=new Vf(this.ctx,{toast:t,icons:this._options.icons,toastOptions:this._options.toastOptions,closeButton:this._options.closeButton,onRemove:(n)=>this.handleToastRemoved(n)});if(this._toastRenderables.set(t.id,o),zf(this._options.position??"bottom-right"))this.add(o);else this.add(o,0);this.requestRender()}removeToast(t){let e=this._toastRenderables.get(t);if(e)e.dismiss()}handleToastRemoved(t){let e=this._toastRenderables.get(t.id);if(e)this._toastRenderables.delete(t.id),this.remove(e.id),e.destroy(),this.requestRender()}get toastCount(){return this._toastRenderables.size}dismissAll(){for(let[t]of this._toastRenderables)this.removeToast(t)}destroy(){this._unsubscribe?.();for(let[,t]of this._toastRenderables)t.destroy();this._toastRenderables.clear(),super.destroy()}}});import{createElement as Hm,extend as Kf,spread as Nm}from"@opentui/solid";var hr=N(()=>{ts();Kf({toaster:Yi})});function os(t){let[e,o]=v("list"),[n,r]=v(0),[i,s]=v(null),[c,f]=v(!1),[a,h]=v(!1),[u,d]=v(!1),[g,x]=v(new Set),[m,b]=v(!1),S=(it)=>{let st=new Set(g());if(st.has(it))st.delete(it);else st.add(it);x(st)},E=(it)=>{x(new Set(it))},y=(it)=>{let st=new Set(it),G=g(),ot=new Set;for(let et of G)if(st.has(et))ot.add(et);if(ot.size!==G.size)x(ot)},R=()=>{x(new Set)};return React.createElement(es.Provider,{value:{activeTab:e,setActiveTab:o,selectedWorktreeIndex:n,setSelectedWorktreeIndex:r,selectedWorktreePath:i,setSelectedWorktreePath:s,showRemove:c,setShowRemove:f,showCommandPalette:a,setShowCommandPalette:h,showDetailView:u,setShowDetailView:d,repoPath:()=>t.repoPath,repoPaths:()=>t.repoPaths,selectedWorktrees:g,toggleWorktreeSelection:S,selectAllNonMain:E,pruneSelectedWorktrees:y,clearSelection:R,showBulkActions:m,setShowBulkActions:b}},t.children)}function Et(){let t=eo(es);if(!t)throw Error("useApp must be used within AppProvider");return t}var es;var ie=N(()=>{Rt();es=to()});var Gt,jo,ur,_o;var Zt=N(()=>{Gt=class Gt extends Error{exitCode;stderr;command;constructor(t,e,o,n){super(t);this.exitCode=e;this.stderr=o;this.command=n;this.name="GitError"}};jo=class jo extends Error{installed;required;constructor(t,e){super(`git version ${t} is below minimum required ${e}`);this.installed=t;this.required=e;this.name="GitVersionError"}};ur=class ur extends Error{branch;reason;constructor(t,e,o){super(t);this.branch=e;this.reason=o;this.name="ArchiveError"}};_o=class _o extends Error{path;reason;constructor(t,e,o){super(t);this.path=e;this.reason=o;this.name="ImportError"}}});async function Qt(t,e,o){let n=Array(t.length),r=0;async function i(){while(r<t.length){let c=r++;n[c]=await o(t[c])}}let s=Array.from({length:Math.min(e,t.length)},()=>i());return await Promise.all(s),n}import{resolve as ns,dirname as Xf}from"path";import{mkdirSync as Zf,existsSync as Qf}from"fs";function To(t){let e=hn.get(t);if(!e)return;if(Date.now()>e.expires){hn.delete(t);return}return e.data}function se(t,e,o=Yf){return hn.set(t,{data:e,expires:Date.now()+o}),e}function Mt(){hn.clear()}class M{static gitVersionChecked=!1;static async run(t,e){let o=Bun.spawn(["git",...t],{cwd:e??Bun.cwd,stdout:"pipe",stderr:"pipe",env:{...Bun.env,LC_ALL:"C",LANG:"C"}}),[n,r,i]=await Promise.all([new Response(o.stdout).text(),new Response(o.stderr).text(),o.exited]);if(i!==0)throw new Gt(`git ${t[0]} failed: ${r.trim()}`,i,r.trim(),`git ${t.join(" ")}`);return n.trim()}static async exec(t,e){return this.run(t,e)}static async checkVersion(){if(this.gitVersionChecked)return;let e=(await this.run(["--version"])).match(/git version (\d+)\.(\d+)\.?((\d+)?)/);if(!e)throw Error("Cannot parse git version");let[,o,n]=e.map(Number);if(o<2||o===2&&n<17)throw new jo(`${o}.${n}`,"2.17");this.gitVersionChecked=!0}static async list(t){await this.checkVersion();let e=t??Bun.cwd,o=await this.getMainRepoPath(e).catch(()=>e),n=`list:${o}`,r=To(n);if(r)return r;let i=o.split("/").pop()??"",s=await this.run(["worktree","list","--porcelain"],e),c=this.parsePorcelain(s,i,o),f=await Qt(c,10,async(a)=>({...a,isDirty:await this.isDirty(a.path).catch(()=>!1)}));return se(n,f)}static async listAll(t){await this.checkVersion();let e=new Set,o=[];for(let r of t){let i=ns(r);if(!e.has(i))e.add(i),o.push(i)}return(await Qt(o,5,async(r)=>{try{return await this.list(r)}catch{return[]}})).flat()}static parsePorcelain(t,e,o){let n=t.trim();if(!n)return[];return n.split(/\n\n+/).filter(Boolean).map((i,s)=>{let c=i.split(`
|
|
4
|
-
`),
|
|
5
|
-
`).filter(Boolean).length)}catch{return
|
|
6
|
-
`).some((r)=>r.trim().replace(/^[*+] /,"")===
|
|
7
|
-
`).filter(Boolean)){let[f
|
|
8
|
-
`).filter(Boolean)){let[f
|
|
9
|
-
`),{encoding:"utf-8",mode:384})}function
|
|
10
|
-
`).filter(Boolean).filter((n)=>n.startsWith(`${e}_`)||n.startsWith(`${e}:`)).map((n)=>{let[r,i,s,c]=n.split("|");return{name:r??"",windows:parseInt(i??"0",10),attached:s==="1",created:c??""}})}catch{return[]}}async function mn(t,e,o){let n=De(t,o?.prefix),r=o?.attach??!0;if(await we(n)){if(r)await dn(n);return n}if(await xl(n,e,o?.layout),ml(e,{name:n,branch:t,worktreePath:e,createdAt:new Date().toISOString(),layout:o?.layoutName}),r)await dn(n);return n}async function xn(t,e,o){let n=De(t,o),r=await we(n);if(r)await wr(n);return xr(e),r}var uo,fs="omw";var Fe=N(()=>{We();uo=class uo extends Error{reason;constructor(t,e){super(t);this.reason=e;this.name="SessionError"}}});import{useTerminalDimensions as gl}from"@opentui/solid";function ls(t){let e=Ot(),o=gl(),n=()=>o().width,r=()=>o().height,[i,s]=v(null),[c,f]=v(!0),[a,h]=v(""),u;an(()=>{if(u)clearTimeout(u)});let d=()=>{return(e.worktrees()??[]).find((it)=>it.isMain)?.branch??"main"};de(Ye(()=>t.worktree.path,(y)=>{if(u)clearTimeout(u);if(!y){s(null),h(""),f(!1);return}s(null),h(""),f(!0),u=setTimeout(async()=>{if(t.worktree.path!==y)return;try{let[R,it,st]=await Promise.all([bl(y),t.worktree.branch&&!t.worktree.isMain?M.diffBetween(d(),t.worktree.branch,{stat:!0},y).catch(()=>""):Promise.resolve(""),t.worktree.branch?M.getAheadBehind(t.worktree.branch,y):Promise.resolve({ahead:0,behind:0})]);if(t.worktree.path!==y)return;let G=null;try{G=Yt(y)}catch{}let ot=null,et=Vt(y);if(et){let le=await we(et.name).catch(()=>!1);ot={meta:et,active:le}}if(t.worktree.path!==y)return;s({commits:R,diffStat:it,aheadBehind:st,focus:G,session:ot}),h("")}catch(R){if(t.worktree.path!==y)return;s(null),h(R.message)}finally{if(t.worktree.path===y)f(!1)}},wl)}));let g=()=>{let y=t.worktree;if(y.isLocked)return"\uD83D\uDD12 locked";if(y.isDirty)return"\u25CF dirty";return"\u2713 clean"},x=()=>{let y=t.worktree;if(y.isLocked)return l.text.warning;if(y.isDirty)return l.text.error;return l.text.success},m=()=>{let y=i();if(!y)return"";let R=[];if(y.aheadBehind.ahead>0)R.push(`\u2191${y.aheadBehind.ahead}`);if(y.aheadBehind.behind>0)R.push(`\u2193${y.aheadBehind.behind}`);return R.length>0?R.join(" "):"\u2713 up to date"},b=()=>{let y=i();if(!y)return l.text.secondary;return y.aheadBehind.ahead||y.aheadBehind.behind?l.text.warning:l.text.success},S=()=>{let y=i();if(!y||!y.diffStat)return[];return y.diffStat.split(`
|
|
11
|
-
`).filter(Boolean)},E=()=>"\u2500".repeat(Math.max(n()-7,10));return React.createElement("box",{x:0,y:0,width:n(),height:r(),backgroundColor:l.bg.base},React.createElement("scrollbox",{x:2,y:1,width:n()-3,height:r()-3},React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.text.accent,bold:!0},"Worktree Detail"),React.createElement("text",{x:17,y:0,fg:l.text.secondary},"(Esc to close)")),React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.border.subtle},E())),React.createElement("box",{height:1}),React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:te,height:1},React.createElement("text",{x:0,y:0,fg:l.text.secondary},"Branch")),React.createElement("text",{fg:l.text.accent},t.worktree.branch??"(detached)")),React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:te,height:1},React.createElement("text",{x:0,y:0,fg:l.text.secondary},"Path")),React.createElement("text",{fg:l.text.primary},t.worktree.path)),React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:te,height:1},React.createElement("text",{x:0,y:0,fg:l.text.secondary},"Status")),React.createElement("text",{fg:x()},g())),React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:te,height:1},React.createElement("text",{x:0,y:0,fg:l.text.secondary},"HEAD")),React.createElement("text",{fg:l.text.secondary},t.worktree.head?.slice(0,8))),React.createElement(O,{when:c()},React.createElement("box",{height:1}),React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.text.secondary},"Loading details..."))),React.createElement(O,{when:!c()&&!!a()},React.createElement("box",{height:1}),React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.text.error},`Failed to load details: ${a()}`))),React.createElement(O,{when:!c()&&!a()&&!!i()},React.createElement("box",{height:1}),React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.text.accent,bold:!0},"Upstream")),React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.border.subtle},E())),React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:te,height:1},React.createElement("text",{x:0,y:0,fg:l.text.secondary},"Sync")),React.createElement("text",{fg:b()},m())),React.createElement(O,{when:i().aheadBehind.ahead>0},React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:te,height:1},React.createElement("text",{x:0,y:0,fg:l.text.secondary},"Ahead")),React.createElement("text",{fg:l.text.warning},`${i().aheadBehind.ahead} commit(s)`))),React.createElement(O,{when:i().aheadBehind.behind>0},React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:te,height:1},React.createElement("text",{x:0,y:0,fg:l.text.secondary},"Behind")),React.createElement("text",{fg:l.text.warning},`${i().aheadBehind.behind} commit(s)`))),React.createElement("box",{height:1}),React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.text.accent,bold:!0},"Recent Commits")),React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.border.subtle},E())),React.createElement(O,{when:i().commits.length>0,fallback:React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.text.secondary},"No commits found"))},React.createElement(St,{each:i().commits},(y)=>React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.text.primary},y)))),React.createElement(O,{when:!t.worktree.isMain&&S().length>0},React.createElement("box",{height:1}),React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.text.accent,bold:!0},`Diff vs ${d()}`)),React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.border.subtle},E())),React.createElement(St,{each:S()},(y)=>React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.text.primary},y)))),React.createElement(O,{when:i().focus&&i().focus.length>0},React.createElement("box",{height:1}),React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.text.accent,bold:!0},"Focus Paths")),React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.border.subtle},E())),React.createElement(St,{each:i().focus},(y)=>React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.text.primary},` \u2022 ${y}`)))),React.createElement(O,{when:i().session},React.createElement("box",{height:1}),React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.text.accent,bold:!0},"Session")),React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.border.subtle},E())),React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:te,height:1},React.createElement("text",{x:0,y:0,fg:l.text.secondary},"Name")),React.createElement("text",{fg:l.text.primary},i().session.meta.name)),React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:te,height:1},React.createElement("text",{x:0,y:0,fg:l.text.secondary},"Status")),React.createElement("text",{fg:i().session.active?l.text.success:l.text.error},i().session.active?"\u25CF active":"\u25CB inactive")),React.createElement(O,{when:i().session.meta.layout},React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:te,height:1},React.createElement("text",{x:0,y:0,fg:l.text.secondary},"Layout")),React.createElement("text",{fg:l.text.primary},i().session.meta.layout)))),React.createElement(O,{when:t.worktree.isMain},React.createElement("box",{height:1}),React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:te,height:1},React.createElement("text",{x:0,y:0,fg:l.text.secondary},"Type")),React.createElement("text",{fg:l.text.accent},"main worktree")))),React.createElement("box",{height:1}),React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.border.subtle},E())),React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.text.secondary},"Esc:back d:delete o:open r:refresh"))))}async function bl(t){try{let e=Bun.spawn(["git","log","--oneline","-10"],{cwd:t,stdout:"pipe",stderr:"pipe",env:{...process.env,LC_ALL:"C"}}),o=await new Response(e.stdout).text();if(await e.exited,e.exitCode!==0)return[];return o.trim().split(`
|
|
12
|
-
`).filter(Boolean)}catch{return[]}}var wl=150,te=16;var hs=N(()=>{Rt();me();Ht();xe();Fe();ct()});import{useKeyboard as Cl,useTerminalDimensions as $l}from"@opentui/solid";function us(){let t=Et(),e=Ot(),o=$l(),n=()=>{let b=e.worktrees()??[],S=t.selectedWorktreePath();if(S){let E=b.find((y)=>y.path===S);if(E)return E}return b[t.selectedWorktreeIndex()]},r=()=>o().width,i=()=>o().height,s=14,[c,f]=v(null),[a,h]=v(!1),[u,d]=v(""),g;an(()=>{if(g)clearTimeout(g)}),de(Ye(()=>n()?.path,(b)=>{if(g)clearTimeout(g);if(!b){f(null),h(!1),d("");return}f(null),h(!0),d(""),g=setTimeout(async()=>{let S=n();if(!S||S.path!==b)return;try{let[E,y,R]=await Promise.all([S.branch?M.getAheadBehind(S.branch,S.path):Promise.resolve({ahead:0,behind:0}),M.getLastCommit(S.path),M.getDirtyCount(S.path)]);if(n()?.path===b)f({aheadBehind:E,lastCommit:y,dirtyCount:R}),d("")}catch(E){if(n()?.path===b)f(null),d(E.message)}finally{if(n()?.path===b)h(!1)}},Sl)}));let x=()=>{if(a())return"Loading...";if(u())return"Unavailable";let b=c();if(!b)return"";let S=[];if(b.aheadBehind.ahead>0)S.push(`\u2191${b.aheadBehind.ahead}`);if(b.aheadBehind.behind>0)S.push(`\u2193${b.aheadBehind.behind}`);return S.length>0?S.join(" "):"\u2713 up to date"},m=()=>{let b=n();if(!b)return"";if(b.isLocked)return"\uD83D\uDD12 locked";let S=c();if(S&&S.dirtyCount>0)return`\u25CF ${S.dirtyCount} file(s) dirty`;if(b.isDirty)return"\u25CF dirty";return"\u2713 clean"};return Cl((b)=>{if(t.activeTab()!=="list")return;if(t.showCommandPalette())return;if(t.showRemove())return;if(t.showBulkActions())return;let S=b.name;if(S==="x"&&t.selectedWorktrees().size>0){t.setShowBulkActions(!0);return}if(S==="return"&&!t.showDetailView()&&n()){t.setShowDetailView(!0);return}if(S==="escape"&&t.showDetailView()){t.setShowDetailView(!1);return}}),React.createElement("box",{width:"100%",height:"100%",backgroundColor:l.bg.base},React.createElement(O,{when:t.showDetailView()&&!!n()},React.createElement(ls,{worktree:n()})),React.createElement(O,{when:!t.showDetailView()},React.createElement(O,{when:e.loading()},React.createElement("text",{x:2,y:2,fg:l.text.secondary},"Loading worktrees...")),React.createElement(O,{when:!e.loading()&&!!e.error()},React.createElement("text",{x:2,y:2,fg:l.text.error},"Error: ",e.error()?.message),React.createElement("text",{x:2,y:3,fg:l.text.secondary},"Not in a git repository?")),React.createElement(O,{when:!e.loading()&&!e.error()&&!!n()},React.createElement("box",{width:"100%",height:"100%",flexDirection:"column",backgroundColor:l.bg.surface,paddingX:2,paddingY:1},React.createElement("box",{height:1,flexDirection:"row"},React.createElement("text",{fg:l.text.accent},"Worktree Details")),React.createElement("box",{height:1},React.createElement("text",{fg:l.border.subtle},"\u2500".repeat(Math.max(r()-38,10)))),React.createElement(O,{when:e.isMultiRepo()},React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:14,height:1},React.createElement("text",{fg:l.text.secondary},"Repo")),React.createElement("text",{fg:l.text.warning},n()?.repoName))),React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:14,height:1},React.createElement("text",{fg:l.text.secondary},"Branch")),React.createElement("text",{fg:l.text.accent},n()?.branch??"(detached)")),React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:14,height:1},React.createElement("text",{fg:l.text.secondary},"Path")),React.createElement("text",{fg:l.text.primary},n()?.path)),React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:14,height:1},React.createElement("text",{fg:l.text.secondary},"Status")),React.createElement("text",{fg:n()?.isDirty?l.text.error:n()?.isLocked?l.text.warning:l.text.success},m())),React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:14,height:1},React.createElement("text",{fg:l.text.secondary},"Sync")),React.createElement("text",{fg:u()?l.text.error:a()?l.text.secondary:c()?.aheadBehind?.ahead||c()?.aheadBehind?.behind?l.text.warning:l.text.success},x())),React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:14,height:1},React.createElement("text",{fg:l.text.secondary},"HEAD")),React.createElement("text",{fg:l.text.secondary},n()?.head?.slice(0,8))),React.createElement(O,{when:c()?.lastCommit},React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:14,height:1},React.createElement("text",{fg:l.text.secondary},"Last Commit")),React.createElement("text",{fg:l.text.primary},c().lastCommit.relativeDate)),React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:14,height:1},React.createElement("text",{fg:l.text.secondary},"")),React.createElement("text",{fg:l.text.secondary},c().lastCommit.message.length>50?c().lastCommit.message.slice(0,47)+"...":c().lastCommit.message))),React.createElement(O,{when:(()=>{let b=Yt(n()?.path??"");return b&&b.length>0})()},React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:14,height:1},React.createElement("text",{fg:l.text.secondary},"Focus")),React.createElement("text",{fg:l.text.accent},Yt(n()?.path??"")?.join(", ")??""))),React.createElement(O,{when:(()=>{return!!Vt(n()?.path??"")})()},React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:14,height:1},React.createElement("text",{fg:l.text.secondary},"Session")),React.createElement("text",{fg:l.text.accent},(()=>{let b=Vt(n()?.path??"");if(!b)return"";return b.layout?`${b.name} [${b.layout}]`:b.name})()))),React.createElement(O,{when:n()?.isMain},React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:14,height:1},React.createElement("text",{fg:l.text.secondary},"Type")),React.createElement("text",{fg:l.text.accent},"main worktree"))),React.createElement("box",{height:1},React.createElement("text",{fg:l.border.subtle},"\u2500".repeat(Math.max(r()-38,10)))),React.createElement("box",{height:1,flexDirection:"row",gap:2},React.createElement("text",{fg:l.text.secondary},"Enter:detail"),React.createElement("text",{fg:l.text.secondary},"d:delete"),React.createElement("text",{fg:l.text.secondary},"a:add"),React.createElement("text",{fg:l.text.secondary},"o:open"),React.createElement("text",{fg:l.text.secondary},"r:refresh"),React.createElement("text",{fg:l.text.secondary},"^P:commands")))),React.createElement(O,{when:!e.loading()&&!e.error()&&!n()},React.createElement("box",{flexDirection:"column",gap:1},React.createElement("text",{fg:l.text.secondary},"No worktree selected."),React.createElement("text",{fg:l.text.accent},"Press 'a' to create one.")))))}var Sl=150;var ps=N(()=>{Rt();ie();me();Ht();xe();Fe();ct();hs()});import{join as Cr,resolve as gn}from"path";import*as Be from"fs";function ae(t,e,o){if(!Array.isArray(t)||t.some((n)=>typeof n!=="string"))o.push({field:e,message:"Must be an array of strings"})}function gs(){let e=Bun.env.XDG_CONFIG_HOME??Cr(Bun.env.HOME??"~",".config");return Cr(e,"oh-my-worktree")}function Nt(){return Cr(gs(),"config.json")}function No(t){let e=[];if(typeof t!=="object"||t===null)return e.push({field:"root",message:"Config must be a JSON object"}),e;let o=t;if(!("version"in o))e.push({field:"version",message:"Required field 'version' is missing"});else if(o.version!==1)e.push({field:"version",message:`Expected version 1, got ${JSON.stringify(o.version)}`});for(let n of Object.keys(o))if(!Pl.has(n))e.push({field:n,message:`Unknown field '${n}'`});if("defaults"in o&&o.defaults!==void 0)if(typeof o.defaults!=="object"||o.defaults===null)e.push({field:"defaults",message:"Must be an object"});else{let n=o.defaults;for(let r of Object.keys(n))if(!yl.has(r))e.push({field:`defaults.${r}`,message:`Unknown field '${r}'`});if("worktreeDir"in n&&typeof n.worktreeDir!=="string")e.push({field:"defaults.worktreeDir",message:"Must be a string"});if("autoUpstream"in n&&typeof n.autoUpstream!=="boolean")e.push({field:"defaults.autoUpstream",message:"Must be a boolean"});for(let r of["copyFiles","linkFiles","postCreate","postRemove"])if(r in n)ae(n[r],`defaults.${r}`,e);if("sharedDeps"in n&&n.sharedDeps!==void 0)if(typeof n.sharedDeps!=="object"||n.sharedDeps===null)e.push({field:"defaults.sharedDeps",message:"Must be an object"});else ds(n.sharedDeps,"defaults.sharedDeps",e)}if("repos"in o&&o.repos!==void 0)if(!Array.isArray(o.repos))e.push({field:"repos",message:"Must be an array"});else for(let n=0;n<o.repos.length;n++){let r=o.repos[n],i=`repos[${n}]`;if(typeof r!=="object"||r===null){e.push({field:i,message:"Must be an object"});continue}let s=r;for(let c of Object.keys(s))if(!El.has(c))e.push({field:`${i}.${c}`,message:`Unknown field '${c}'`});if(!("path"in s)||typeof s.path!=="string")e.push({field:`${i}.path`,message:"Required string field 'path' is missing"});if("worktreeDir"in s&&typeof s.worktreeDir!=="string")e.push({field:`${i}.worktreeDir`,message:"Must be a string"});if("autoUpstream"in s&&typeof s.autoUpstream!=="boolean")e.push({field:`${i}.autoUpstream`,message:"Must be a boolean"});for(let c of["copyFiles","linkFiles","postCreate","postRemove"])if(c in s)ae(s[c],`${i}.${c}`,e);if("sharedDeps"in s&&s.sharedDeps!==void 0)if(typeof s.sharedDeps!=="object"||s.sharedDeps===null)e.push({field:`${i}.sharedDeps`,message:"Must be an object"});else ds(s.sharedDeps,`${i}.sharedDeps`,e);if("monorepo"in s&&s.monorepo!==void 0)if(typeof s.monorepo!=="object"||s.monorepo===null)e.push({field:`${i}.monorepo`,message:"Must be an object"});else{let c=s.monorepo;for(let f of Object.keys(c))if(!Rl.has(f))e.push({field:`${i}.monorepo.${f}`,message:`Unknown field '${f}'`});if("autoDetect"in c&&typeof c.autoDetect!=="boolean")e.push({field:`${i}.monorepo.autoDetect`,message:"Must be a boolean"});if("extraPatterns"in c&&c.extraPatterns!==void 0)ae(c.extraPatterns,`${i}.monorepo.extraPatterns`,e);if("hooks"in c&&c.hooks!==void 0)if(!Array.isArray(c.hooks))e.push({field:`${i}.monorepo.hooks`,message:"Must be an array"});else for(let f=0;f<c.hooks.length;f++){let a=c.hooks[f];if(typeof a!=="object"||a===null){e.push({field:`${i}.monorepo.hooks[${f}]`,message:"Must be an object"});continue}if(!("glob"in a)||typeof a.glob!=="string")e.push({field:`${i}.monorepo.hooks[${f}].glob`,message:"Required string field"});if("copyFiles"in a&&a.copyFiles!==void 0)ae(a.copyFiles,`${i}.monorepo.hooks[${f}].copyFiles`,e);if("linkFiles"in a&&a.linkFiles!==void 0)ae(a.linkFiles,`${i}.monorepo.hooks[${f}].linkFiles`,e);if("postCreate"in a&&a.postCreate!==void 0)ae(a.postCreate,`${i}.monorepo.hooks[${f}].postCreate`,e);if("postRemove"in a&&a.postRemove!==void 0)ae(a.postRemove,`${i}.monorepo.hooks[${f}].postRemove`,e)}}}if("templates"in o&&o.templates!==void 0)if(typeof o.templates!=="object"||o.templates===null||Array.isArray(o.templates))e.push({field:"templates",message:"Must be an object (key-value map)"});else{let n=o.templates;for(let[r,i]of Object.entries(n)){let s=`templates.${r}`;if(typeof i!=="object"||i===null){e.push({field:s,message:"Must be an object"});continue}let c=i;for(let f of Object.keys(c))if(!Ml.has(f))e.push({field:`${s}.${f}`,message:`Unknown field '${f}'`});if("worktreeDir"in c&&typeof c.worktreeDir!=="string")e.push({field:`${s}.worktreeDir`,message:"Must be a string"});if("base"in c&&typeof c.base!=="string")e.push({field:`${s}.base`,message:"Must be a string"});if("autoUpstream"in c&&typeof c.autoUpstream!=="boolean")e.push({field:`${s}.autoUpstream`,message:"Must be a boolean"});for(let f of["copyFiles","linkFiles","postCreate","postRemove"])if(f in c)ae(c[f],`${s}.${f}`,e)}}if("lifecycle"in o&&o.lifecycle!==void 0)if(typeof o.lifecycle!=="object"||o.lifecycle===null)e.push({field:"lifecycle",message:"Must be an object"});else{let n=o.lifecycle;for(let r of Object.keys(n))if(!Ol.has(r))e.push({field:`lifecycle.${r}`,message:`Unknown field '${r}'`});if("autoCleanMerged"in n&&typeof n.autoCleanMerged!=="boolean")e.push({field:"lifecycle.autoCleanMerged",message:"Must be a boolean"});if("staleAfterDays"in n&&(typeof n.staleAfterDays!=="number"||n.staleAfterDays<1))e.push({field:"lifecycle.staleAfterDays",message:"Must be a positive number"});if("maxWorktrees"in n&&(typeof n.maxWorktrees!=="number"||n.maxWorktrees<1))e.push({field:"lifecycle.maxWorktrees",message:"Must be a positive number"})}if("sessions"in o&&o.sessions!==void 0)if(typeof o.sessions!=="object"||o.sessions===null)e.push({field:"sessions",message:"Must be an object"});else{let n=o.sessions;for(let r of Object.keys(n))if(!Wl.has(r))e.push({field:`sessions.${r}`,message:`Unknown field '${r}'`});for(let r of["enabled","autoCreate","autoKill"])if(r in n&&typeof n[r]!=="boolean")e.push({field:`sessions.${r}`,message:"Must be a boolean"});if("prefix"in n&&typeof n.prefix!=="string")e.push({field:"sessions.prefix",message:"Must be a string"});if("defaultLayout"in n&&typeof n.defaultLayout!=="string")e.push({field:"sessions.defaultLayout",message:"Must be a string"});if("layouts"in n&&n.layouts!==void 0)if(typeof n.layouts!=="object"||n.layouts===null||Array.isArray(n.layouts))e.push({field:"sessions.layouts",message:"Must be an object (key-value map)"});else{let r=n.layouts;for(let[i,s]of Object.entries(r)){let c=`sessions.layouts.${i}`;if(typeof s!=="object"||s===null){e.push({field:c,message:"Must be an object"});continue}let f=s;if(!("windows"in f)||!Array.isArray(f.windows))e.push({field:`${c}.windows`,message:"Required array field"});else for(let a=0;a<f.windows.length;a++){let h=f.windows[a];if(typeof h!=="object"||h===null){e.push({field:`${c}.windows[${a}]`,message:"Must be an object"});continue}if(!("name"in h)||typeof h.name!=="string")e.push({field:`${c}.windows[${a}].name`,message:"Required string field"});if("command"in h&&typeof h.command!=="string")e.push({field:`${c}.windows[${a}].command`,message:"Must be a string"})}}}if("defaultLayout"in n&&typeof n.defaultLayout==="string"&&"layouts"in n&&typeof n.layouts==="object"&&n.layouts!==null){let r=n.layouts;if(!(n.defaultLayout in r))e.push({field:"sessions.defaultLayout",message:`Layout '${n.defaultLayout}' does not exist in sessions.layouts`})}}if("profiles"in o&&o.profiles!==void 0)if(typeof o.profiles!=="object"||o.profiles===null||Array.isArray(o.profiles))e.push({field:"profiles",message:"Must be an object (key-value map)"});else{let n=o.profiles;for(let[r,i]of Object.entries(n)){let s=`profiles.${r}`;if(typeof i!=="object"||i===null){e.push({field:s,message:"Must be an object"});continue}let c=i;for(let f of Object.keys(c))if(!Dl.has(f))e.push({field:`${s}.${f}`,message:`Unknown field '${f}'`})}}if("activeProfile"in o&&o.activeProfile!==void 0){if(typeof o.activeProfile!=="string")e.push({field:"activeProfile",message:"Must be a string"});else if("profiles"in o&&o.profiles!==void 0&&typeof o.profiles==="object"&&o.profiles!==null&&!Array.isArray(o.profiles)){let n=o.profiles;if(!(o.activeProfile in n))e.push({field:"activeProfile",message:`Profile '${o.activeProfile}' does not exist in profiles`})}else if(!("profiles"in o)||o.profiles===void 0)e.push({field:"activeProfile",message:"Cannot set activeProfile without profiles"})}return e}function ds(t,e,o){let n=new Set(["strategy","paths","invalidateOn"]);for(let r of Object.keys(t))if(!n.has(r))o.push({field:`${e}.${r}`,message:`Unknown field '${r}'`});if("strategy"in t&&!["hardlink","symlink","copy"].includes(t.strategy))o.push({field:`${e}.strategy`,message:'Must be "hardlink", "symlink", or "copy"'});if("paths"in t)ae(t.paths,`${e}.paths`,o);if("invalidateOn"in t)ae(t.invalidateOn,`${e}.invalidateOn`,o)}function Ho(t){return typeof t==="object"&&t!==null&&!Array.isArray(t)}function no(t){if(Array.isArray(t))return t.map((e)=>no(e));if(Ho(t)){let e={};for(let[o,n]of Object.entries(t))e[o]=no(n);return e}return t}function ws(t,e){if(e===void 0)return no(t);if(Array.isArray(e))return e.map((r)=>no(r));if(!Ho(e))return no(e);let o=Ho(t)?t:{},n={};for(let[r,i]of Object.entries(o))n[r]=no(i);for(let[r,i]of Object.entries(e)){if(i===void 0)continue;let s=o[r];if(Ho(s)&&Ho(i)){n[r]=ws(s,i);continue}n[r]=no(i)}return n}function Fl(t){if(!t.activeProfile)return structuredClone(t);let e=t.profiles?.[t.activeProfile];if(!e||typeof e!=="object"||Array.isArray(e))throw Error(`Active profile '${t.activeProfile}' does not exist`);return ws(t,e)}function Y(t){let e=t??Nt();if(!Be.existsSync(e))return structuredClone(xs);let o;try{let s=wn.readFileSync(e,"utf-8");o=JSON.parse(s)}catch(s){let c=s.message;if(c.includes("JSON"))throw Error(`Invalid JSON in config file: ${c}`);if(s instanceof SyntaxError)throw Error(`Invalid JSON in config file: ${c}`);throw Error(`Failed to read config file: ${c}`)}let n=No(o);if(n.length>0){let s=n.map((c)=>`${c.field}: ${c.message}`).join("; ");throw Error(`Config validation failed: ${s}`)}let r=Fl(o),i=No(r);if(i.length>0){let s=i.map((c)=>`${c.field}: ${c.message}`).join("; ");throw Error(`Config validation failed after applying activeProfile: ${s}`)}return r}function Lt(t,e){let o=gn(e),n=t.repos?.find((r)=>gn(r.path)===o);return{worktreeDir:n?.worktreeDir??t.defaults?.worktreeDir??mo.worktreeDir,copyFiles:n?.copyFiles??t.defaults?.copyFiles??mo.copyFiles,linkFiles:n?.linkFiles??t.defaults?.linkFiles??mo.linkFiles,postCreate:n?.postCreate??t.defaults?.postCreate??mo.postCreate,postRemove:n?.postRemove??t.defaults?.postRemove??mo.postRemove,autoUpstream:n?.autoUpstream??t.defaults?.autoUpstream??mo.autoUpstream,monorepo:n?.monorepo,sharedDeps:n?.sharedDeps??t.defaults?.sharedDeps}}function Le(t){return(t.repos??[]).map((e)=>gn(e.path))}function bn(t,e){let o=Bun.env.HOME??"~";return t.replace(/^~(?=\/|$)/,o).replace(/\{repo\}/g,e.repo).replace(/\{branch\}/g,e.branch)}function fe(t){let e=t??Nt(),o=t?gn(e,".."):gs();if(!Be.existsSync(o))wn.mkdirSync(o,{recursive:!0,mode:448});if(Be.existsSync(e))return e;return Jo(e,`${JSON.stringify(xs,null,2)}
|
|
13
|
-
`)
|
|
14
|
-
`);if(S.length===1)d.push(S[0]);else{d.push(S[0]);let E=d.join("");if(d.length=0,E)r(E);for(let R=1;R<S.length-1;R++)if(S[R])r(S[R]);let y=S[S.length-1];if(y)d.push(y)}}let g=d.join("")+u.decode();if(g)r(g)}let a=await i.exited;if(s)throw new Co(t,o);if(a!==0){let h=(await f).trim();throw new bo(t,a,h)}}finally{clearTimeout(c)}}var bo,Co;var $e=N(()=>{bo=class bo extends Error{command;exitCode;stderr;constructor(t,e,o){super(`Hook command failed (exit ${e}): ${t}
|
|
15
|
-
${o}`);this.command=t;this.exitCode=e;this.stderr=o;this.name="HookError"}};Co=class Co extends Error{command;timeoutMs;constructor(t,e){super(`Hook command timed out after ${e}ms: ${t}`);this.command=t;this.timeoutMs=e;this.name="HookTimeoutError"}}});import{existsSync as Hl,readdirSync as Hx,readFileSync as Nx,statSync as Nl}from"fs";import{join as Jl,relative as kx}from"path";function yn(t,e){let o=[],n=[];for(let r of e){let i=r.trim();if(!i){n.push(i);continue}let s=Jl(t,i);try{if(Hl(s)&&Nl(s).isDirectory())o.push(i);else n.push(i)}catch{n.push(i)}}return{valid:o,invalid:n}}var $r=()=>{};function ro(t,e){return t.map((o)=>{let n=new Bun.Glob(o.glob),r=e.filter((i)=>n.match(i));return{glob:o.glob,matchedPaths:r,copyFiles:o.copyFiles??[],linkFiles:o.linkFiles??[],postCreate:o.postCreate??[],postRemove:o.postRemove??[]}}).filter((o)=>o.matchedPaths.length>0)}function kl(t,e){return t.replace(/\{packagePath\}/g,e.packagePath).replace(/\{repo\}/g,e.repo).replace(/\{branch\}/g,e.branch)}async function $o(t,e,o){for(let n of t){let r=n[e],i=e==="postCreate"&&n.copyFiles.length>0,s=e==="postCreate"&&n.linkFiles.length>0,c=r.length>0;if(!i&&!s&&!c)continue;for(let f of n.matchedPaths){let{join:a}=await import("path"),h=a(o.mainRepoPath,f),u=a(o.cwd,f);if(i){let d=go(h,u,n.copyFiles);for(let g of d.copied)o.onOutput?.(`Copied ${f}/${g}`);for(let g of d.warnings)o.onOutput?.(`\u26A0 ${g}`)}if(s){let d=wo(h,u,n.linkFiles);for(let g of d.linked)o.onOutput?.(`Linked ${f}/${g}`);for(let g of d.warnings)o.onOutput?.(`\u26A0 ${g}`)}if(c){let d=r.map((x)=>kl(x,{packagePath:f,repo:o.repo,branch:o.branch})),g={...o.env??{},OMW_FOCUS_PATHS:o.focusPaths.join(","),OMW_PACKAGE_PATH:f};await Wt(d,{cwd:o.cwd,timeout:o.timeout,env:g,onOutput:o.onOutput})}}}}var En=N(()=>{$e();Pn()});import{useTerminalDimensions as zl}from"@opentui/solid";function je(t){let e=zl(),o=()=>Math.max(0,Math.floor((e().width-t.width)/2)),n=()=>Math.max(0,Math.floor((e().height-t.height)/2)),r=()=>React.createElement("box",{x:o(),y:n(),width:t.width,height:t.height,border:!0,borderStyle:"rounded",borderColor:t.borderColor??l.border.active,backgroundColor:t.backgroundColor??l.bg.surface,flexDirection:"column",paddingX:1,paddingY:1,gap:t.gap??0,title:t.title,titleAlignment:"left",position:"absolute"},t.children,React.createElement(O,{when:t.footer},t.footer));return React.createElement(O,{when:t.backdrop,fallback:r()},React.createElement("box",{x:0,y:0,width:e().width,height:e().height,backgroundColor:t.backdropColor??l.bg.overlay,position:"absolute"},r()))}var zo=N(()=>{Rt();Ht()});import{useKeyboard as vl,useTerminalDimensions as Ul}from"@opentui/solid";import{basename as ys,resolve as Vl}from"path";function Es(){let t=Et(),e=Ot(),o=Ul(),[n,r]=v("input"),[i,s]=v(""),[c,f]=v(""),[a,h]=v("branch"),[u,d]=v(""),[g,x]=v([]),[m,b]=v(""),[S,E]=v([]),[y,R]=v(-1),[it,st]=v(!1),G=()=>{let k=i().toLowerCase();if(!k)return S().slice(0,10);return S().filter((T)=>T.name.toLowerCase().includes(k)).slice(0,10)};de(Ye(()=>et(),async()=>{try{let k=et(),T=await M.listBranches(k);E(T)}catch{E([])}})),de(Ye(i,()=>{R(-1),st(i().length>0&&G().length>0)}));let ot=(k,T)=>{x((Z)=>Z.map((dt,A)=>A===k?{...dt,...T}:dt))},et=()=>{let k=e.worktrees()??[],T=t.selectedWorktreePath();return(T?k.find((dt)=>dt.path===T)??k[t.selectedWorktreeIndex()]:k[t.selectedWorktreeIndex()])?.repoPath??t.repoPath()},le=()=>{let k=e.worktrees()??[],T=t.selectedWorktreePath();return(T?k.find((dt)=>dt.path===T)??k[t.selectedWorktreeIndex()]:k[t.selectedWorktreeIndex()])?.repoName??t.repoPath().split("/").pop()??""},_=()=>{let k=i();if(!k)return"";let T=et(),Z=Y(),dt=Lt(Z,T),A=k.replace(/\//g,"-"),ee=ys(T);return Vl(bn(dt.worktreeDir,{repo:ee,branch:A}))};vl(async(k)=>{if(t.activeTab()!=="add")return;if(t.showCommandPalette())return;let T=k.name;if(T==="escape"){if(n()==="preview"){r("input");return}t.setActiveTab("list"),s(""),f(""),h("branch"),r("input");return}if(n()==="input"){if(T==="tab"){if(it()&&a()==="branch")st(!1),R(-1);h((Z)=>Z==="branch"?"focus":"branch");return}if(a()==="branch"&&it()&&G().length>0){if(T==="down"||k.sequence==="\x1B[B"){R((Z)=>Math.min(Z+1,G().length-1));return}if(T==="up"||k.sequence==="\x1B[A"){R((Z)=>Math.max(Z-1,-1));return}}if(T==="return"||T==="enter"){if(a()==="branch"&&y()>=0){let Z=G()[y()];if(Z){s(Z.name),st(!1),R(-1);return}}if(!i())return;st(!1),d(_()),r("preview");return}if(T==="backspace"){if(a()==="branch")s((Z)=>Z.slice(0,-1));else f((Z)=>Z.slice(0,-1));return}if(k.sequence==="\x15"||k.ctrl&&T==="u"){if(a()==="branch")s("");else f("");return}if(k.sequence==="\x17"||k.ctrl&&T==="w"){if(a()==="branch")s((Z)=>Z.replace(/\S+\s*$/,""));else f((Z)=>Z.replace(/\S+\s*$/,""));return}if(k.sequence&&k.sequence.length===1&&k.sequence.charCodeAt(0)>=32)if(a()==="branch")s((Z)=>Z+k.sequence);else f((Z)=>Z+k.sequence)}if(n()==="preview"){if(T==="return"||T==="enter"){r("creating");let Z=i(),dt=u(),A=et(),ee=ys(A);try{let Se=Y(),F=Lt(Se,A),nt=[{label:"Creating worktree",status:"pending"}];if(F.autoUpstream)nt.push({label:"Setting upstream",status:"pending"});if(F.copyFiles.length>0)nt.push({label:"Copying files",status:"pending"});if(F.linkFiles.length>0)nt.push({label:"Creating symlinks",status:"pending"});if(F.postCreate.length>0)nt.push({label:"Running hooks",status:"pending"});let pt=c(),U=[];if(pt)U=pt.split(/[,\s]+/).map((rt)=>rt.trim()).filter(Boolean);if(U.length>0)nt.push({label:"Setting focus",status:"pending"});if(U.length>0&&F.monorepo?.hooks&&F.monorepo.hooks.length>0){if(ro(F.monorepo.hooks,U).length>0)nt.push({label:"Running monorepo hooks",status:"pending"})}x(nt);let Q=0;if(ot(Q,{status:"running"}),await M.add(Z,dt,{createBranch:!0},A),ot(Q,{status:"done"}),Q++,F.autoUpstream){ot(Q,{status:"running"});try{let rt=await M.getDefaultRemote(A);if(await M.remoteBranchExists(Z,rt,A))await M.setUpstream(Z,rt,A),ot(Q,{status:"done",message:`\u2192 ${rt}/${Z}`});else ot(Q,{status:"done",message:"no remote branch"})}catch(rt){ot(Q,{status:"error",message:rt.message})}Q++}if(F.copyFiles.length>0)ot(Q,{status:"running"}),go(A,dt,F.copyFiles),ot(Q,{status:"done"}),Q++;if(F.linkFiles.length>0)ot(Q,{status:"running"}),wo(A,dt,F.linkFiles),ot(Q,{status:"done"}),Q++;let ft={OMW_BRANCH:Z,OMW_WORKTREE_PATH:dt,OMW_REPO_PATH:A};if(F.postCreate.length>0)ot(Q,{status:"running"}),await Wt(F.postCreate,{cwd:dt,env:ft,onOutput:(rt)=>ot(Q,{message:rt})}),ot(Q,{status:"done"}),Q++;if(U.length>0){ot(Q,{status:"running"});let{valid:rt}=yn(dt,U);if(U=rt,rt.length>0)ho(dt,rt),ft.OMW_FOCUS_PATHS=rt.join(",");ot(Q,{status:"done"}),Q++}if(U.length>0&&F.monorepo?.hooks&&F.monorepo.hooks.length>0){ot(Q,{status:"running"});let rt=ro(F.monorepo.hooks,U);if(rt.length>0)await $o(rt,"postCreate",{cwd:dt,env:ft,repo:ee,branch:Z,focusPaths:U,mainRepoPath:A,onOutput:(io)=>ot(Q,{message:io})});ot(Q,{status:"done"}),Q++}b("Worktree created successfully!"),r("done"),oo.success(`Worktree created: ${Z}`),e.refetch(),setTimeout(()=>{t.setActiveTab("list"),s(""),f(""),h("branch"),r("input")},1500)}catch(Se){oo.error(Se.message);let nt=g().findIndex((pt)=>pt.status==="running");if(nt>=0)ot(nt,{status:"error",message:Se.message});b(`${Se.message}`),r("error")}return}}if(n()==="error"){if(T==="escape"||T==="return"||T==="enter")r("input"),b("")}});let D=()=>o().width,L=()=>o().height,V=()=>Math.max(50,Math.min(80,D()-4)),tt=4,mt=()=>{if(n()==="input"){let k=it()&&a()==="branch"?G().length*2:0,T=i().length>0?4:0;return Math.max(21+tt,Math.min(21+tt+k+T,L()-4))}if(n()==="preview")return Math.max(13+tt,Math.min((c().length>0?15:13)+tt,L()-4));if(n()==="creating")return Math.max(9+tt,Math.min(g().length*2+7+tt,L()-4));if(n()==="done")return Math.max(11+tt,Math.min((c().length>0?15:13)+tt,L()-4));return Math.max(11+tt,Math.min(11+tt,L()-4))},q=()=>Math.max(V()-4,10),ut=()=>Math.max(q(),20);return React.createElement(je,{width:V(),height:mt(),borderColor:n()==="done"?l.text.success:n()==="error"?l.text.error:l.border.active,backgroundColor:l.bg.surface,gap:1,title:" Create Worktree ",footer:React.createElement(dg,null,React.createElement("box",{height:1,width:q()},React.createElement("text",{fg:l.border.subtle},"\u2500".repeat(Math.max(q(),1)))),React.createElement(O,{when:n()==="input"},React.createElement("box",{flexDirection:"row",gap:2},React.createElement("text",{fg:l.text.secondary},"Tab:switch"),React.createElement("text",{fg:l.text.secondary},"\u2191\u2193:pick"),React.createElement("text",{fg:l.text.secondary},"Enter:confirm"),React.createElement("text",{fg:l.text.secondary},"Esc:cancel"))),React.createElement(O,{when:n()==="preview"},React.createElement("box",{flexDirection:"row",gap:2},React.createElement("text",{fg:l.text.secondary},"Enter:create"),React.createElement("text",{fg:l.text.secondary},"Esc:back"))),React.createElement(O,{when:n()==="creating"},React.createElement("text",{fg:l.text.secondary},"Creating worktree...")),React.createElement(O,{when:n()==="done"},React.createElement("text",{fg:l.text.secondary},"\u2713 Done \u2014 returning to list")),React.createElement(O,{when:n()==="error"},React.createElement("box",{flexDirection:"row",gap:2},React.createElement("text",{fg:l.text.secondary},"Enter:retry"),React.createElement("text",{fg:l.text.secondary},"Esc:back"))))},React.createElement(O,{when:n()==="input"},React.createElement("box",{height:1,width:q(),backgroundColor:l.bg.elevated},React.createElement("text",{x:1,y:0,fg:l.text.accent},">"),React.createElement("text",{x:3,y:0,fg:l.text.primary},"New Worktree"),React.createElement("text",{x:17,y:0,fg:l.text.secondary},le())),React.createElement("text",{fg:l.border.subtle},"\u2500".repeat(q())),React.createElement("text",{fg:a()==="branch"?l.text.accent:l.text.secondary},"Branch name"),React.createElement("box",{width:ut(),height:1,backgroundColor:l.bg.elevated},React.createElement("text",{x:1,y:0,fg:l.text.primary},i()),React.createElement(O,{when:a()==="branch"},React.createElement("text",{x:i().length+1,y:0,fg:l.text.accent},"\u2588"))),React.createElement(O,{when:it()&&a()==="branch"&&G().length>0},React.createElement(St,{each:G()},(k,T)=>React.createElement("box",{height:1,width:q(),backgroundColor:T()===y()?l.select.focusedBg:l.bg.surface},React.createElement("text",{x:1,y:0,fg:T()===y()?l.tab.active:l.text.primary},T()===y()?"\u25B8 ":" ",k.name),React.createElement("text",{x:Math.max(1+k.name.length+4,27),y:0,fg:l.text.secondary},k.isRemote?"(remote) ":"",k.lastCommitDate)))),React.createElement("text",{fg:l.text.secondary},"Tab to switch fields \xB7 \u2191\u2193 to select branch"),React.createElement("box",{width:"100%",height:1,flexDirection:"row"},React.createElement("text",{fg:a()==="focus"?l.text.accent:l.text.secondary},"Focus "),React.createElement("text",{fg:l.text.secondary},"(optional)")),React.createElement("box",{width:ut(),height:1,backgroundColor:l.bg.elevated},React.createElement("text",{x:1,y:0,fg:l.text.primary},c()),React.createElement(O,{when:a()==="focus"},React.createElement("text",{x:c().length+1,y:0,fg:l.text.accent},"\u2588"))),React.createElement("text",{fg:l.text.secondary},"comma-separated paths, e.g. apps/web,apps/api"),React.createElement(O,{when:i().length>0},React.createElement("text",{fg:l.text.secondary},"Target path"),React.createElement("text",{fg:l.text.primary},_())),React.createElement("text",{fg:l.text.primary},"Type a branch name, e.g. feature/my-feature")),React.createElement(O,{when:n()==="preview"},React.createElement("box",{height:1,width:q(),backgroundColor:l.bg.elevated},React.createElement("text",{x:1,y:0,fg:l.text.accent},">"),React.createElement("text",{x:3,y:0,fg:l.text.primary},"Confirm Worktree")),React.createElement("text",{fg:l.border.subtle},"\u2500".repeat(q())),React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:14,height:1},React.createElement("text",{fg:l.text.secondary},"Branch")),React.createElement("text",{fg:l.text.accent},i())),React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:14,height:1},React.createElement("text",{fg:l.text.secondary},"Path")),React.createElement("text",{fg:l.text.primary},u())),React.createElement(O,{when:c().length>0},React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:14,height:1},React.createElement("text",{fg:l.text.secondary},"Focus")),React.createElement("text",{fg:l.text.accent},c()))),React.createElement("text",{fg:l.text.success},"\u2713 Ready to create. Press Enter to confirm.")),React.createElement(O,{when:n()==="creating"},React.createElement("box",{height:1,width:q(),backgroundColor:l.bg.elevated},React.createElement("text",{x:1,y:0,fg:l.text.accent},">"),React.createElement("text",{x:3,y:0,fg:l.text.primary},"Creating Worktree")),React.createElement("text",{fg:l.border.subtle},"\u2500".repeat(q())),React.createElement(St,{each:g()},(k)=>React.createElement("box",{height:1},React.createElement("text",{fg:k.status==="done"?l.text.success:k.status==="running"?l.text.accent:k.status==="error"?l.text.error:l.text.secondary},k.status==="done"?"\u2713":k.status==="running"?"\u27F3":k.status==="error"?"\u2717":"\u25CB"," ",k.label),React.createElement(O,{when:k.message},React.createElement("text",{x:k.label.length+4,y:0,fg:l.text.secondary},k.message))))),React.createElement(O,{when:n()==="done"},React.createElement("box",{height:1,width:q(),backgroundColor:l.bg.elevated},React.createElement("text",{x:1,y:0,fg:l.text.success},">"),React.createElement("text",{x:3,y:0,fg:l.text.primary},"Worktree Created")),React.createElement("text",{fg:l.border.subtle},"\u2500".repeat(q())),React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:14,height:1},React.createElement("text",{fg:l.text.secondary},"Branch")),React.createElement("text",{fg:l.text.accent},i())),React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:14,height:1},React.createElement("text",{fg:l.text.secondary},"Path")),React.createElement("text",{fg:l.text.primary},u())),React.createElement(O,{when:c().length>0},React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:14,height:1},React.createElement("text",{fg:l.text.secondary},"Focus")),React.createElement("text",{fg:l.text.accent},c()))),React.createElement("text",{fg:l.text.success},"\u2713 ",m())),React.createElement(O,{when:n()==="error"},React.createElement("box",{height:1,width:q(),backgroundColor:l.bg.elevated},React.createElement("text",{x:1,y:0,fg:l.text.error},">"),React.createElement("text",{x:3,y:0,fg:l.text.primary},"Error")),React.createElement("text",{fg:l.border.subtle},"\u2500".repeat(q())),React.createElement("text",{fg:l.text.error},"\u2717 Failed"),React.createElement("box",{width:ut(),height:1,backgroundColor:l.bg.elevated},React.createElement("text",{x:1,y:0,fg:l.text.primary},m().slice(0,Math.max(ut()-3,10)))),React.createElement("text",{fg:l.text.secondary},"Press Enter or Escape to try again")))}var Rs=N(()=>{Rt();ie();me();ct();$t();Pn();$e();xe();$r();En();hr();Ht();zo()});import{useKeyboard as Kl,useTerminalDimensions as ql}from"@opentui/solid";function Ms(){let t=Et(),e=Ot(),o=ql(),[n,r]=v(!1),[i,s]=v(""),[c,f]=v(!1),a=()=>{let m=e.worktrees()??[],b=t.selectedWorktreePath();if(b){let S=m.find((E)=>E.path===b);if(S)return S}return m[t.selectedWorktreeIndex()]},h=()=>{t.setShowRemove(!1),r(!1),s(""),f(!1)},u=async(m)=>{let b=a();if(!b){h();return}r(!0),s("Removing...");try{let S=Y(),E=Lt(S,b.repoPath);if(E.postRemove.length>0)s("Running postRemove hooks..."),await Wt(E.postRemove,{cwd:b.path,env:{OMW_BRANCH:b.branch??"",OMW_WORKTREE_PATH:b.path,OMW_REPO_PATH:b.repoPath}}).catch(()=>{});await M.remove(b.path,{force:m},b.repoPath),s("Removed successfully!"),oo.success("Worktree removed");let y=e.worktrees()??[],R=t.selectedWorktreeIndex(),it=y[R-1]??y[R+1]??null;if(R>0)t.setSelectedWorktreeIndex(R-1);else t.setSelectedWorktreeIndex(0);t.setSelectedWorktreePath(it?.path??null),e.refetch(),setTimeout(h,1000)}catch(S){let E=S.message;if(!m&&E.includes("dirty"))s("Worktree has changes. Press Enter to force remove."),r(!1),f(!0);else s(`Failed: ${E}`),r(!1),oo.error(`Failed: ${E}`)}};Kl(async(m)=>{if(!t.showRemove())return;if(t.showCommandPalette())return;let b=m.name;if(b==="escape"){h();return}if(c()&&(b==="return"||b==="enter")){f(!1),await u(!0);return}if((b==="return"||b==="enter")&&!n())await u(!1)});let d=()=>a(),g=()=>Math.max(50,Math.min(80,o().width-4)),x=()=>10;return React.createElement(je,{width:g(),height:x(),borderColor:l.border.active,backgroundColor:l.bg.elevated,gap:1,title:" Remove Worktree ",backdrop:!0,footer:React.createElement("box",{flexDirection:"column"},React.createElement(O,{when:!n()&&!c()},React.createElement("box",{height:1,flexDirection:"row",gap:2},React.createElement("text",{fg:l.text.secondary},"[Enter] Confirm"),React.createElement("text",{fg:l.text.secondary},"[Esc] Cancel"))),React.createElement(O,{when:c()},React.createElement("box",{height:1,flexDirection:"row",gap:2},React.createElement("text",{fg:l.text.secondary},"[Enter] Force remove"),React.createElement("text",{fg:l.text.secondary},"[Esc] Cancel"))))},React.createElement(O,{when:!!d()},React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:10,height:1},React.createElement("text",{fg:l.text.secondary},"Branch")),React.createElement("text",{fg:l.text.accent},d()?.branch??"(detached)")),React.createElement("box",{height:1,flexDirection:"row"},React.createElement("box",{width:10,height:1},React.createElement("text",{fg:l.text.secondary},"Path")),React.createElement("text",{fg:l.text.primary},d()?.path)),React.createElement(O,{when:c()},React.createElement("text",{fg:l.text.warning},i())),React.createElement(O,{when:n()},React.createElement("text",{fg:i().startsWith("Failed")?l.text.error:l.text.success},i()))),React.createElement(O,{when:!d()},React.createElement("text",{fg:l.text.secondary},"No worktree selected.")))}var Os=N(()=>{Rt();ie();me();ct();$t();$e();hr();Ht();zo()});function Ds(t){let[e,o]=v([]),n=(i)=>{o((s)=>s.filter((c)=>c.id!==i))},r=(i)=>{let s=`${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`,c=i.duration??3000;o((f)=>[...f,{...i,id:s}].slice(-5)),setTimeout(()=>{n(s)},c)};return React.createElement(Ws.Provider,{value:{toasts:e,addToast:r,removeToast:n}},t.children)}function Rn(){let t=eo(Ws);if(!t)throw Error("useToast must be used within ToastProvider");return t}var Ws;var Mn=N(()=>{Rt();Ws=to()});import{useKeyboard as Xl}from"@opentui/solid";function Fs(t){let e=Et(),o=Ot(),n=Rn(),[r,i]=v("confirming"),[s,c]=v(""),[f,a]=v(0),h=()=>{let x=o.worktrees()??[],m=e.selectedWorktrees(),b=[];for(let S of m){let E=x.find((y)=>y.path===S);if(E&&!E.isMain)b.push({branch:E.branch??"(detached)",path:E.path,repoPath:E.repoPath})}return b},u=()=>{e.setShowBulkActions(!1),i("confirming"),c(""),a(0)},d=async()=>{let x=h();if(x.length===0){u();return}i("executing"),a(0);let m=[];for(let b=0;b<x.length;b++){let S=x[b];c(`Removing ${S.branch} (${b+1}/${x.length})...`),a(b);try{let E=Y(),y=Lt(E,S.repoPath);if(y.postRemove.length>0)await Wt(y.postRemove,{cwd:S.path,env:{OMW_BRANCH:S.branch,OMW_WORKTREE_PATH:S.path,OMW_REPO_PATH:S.repoPath}}).catch(()=>{});await M.remove(S.path,{force:!1},S.repoPath)}catch(E){m.push(`${S.branch}: ${E.message}`)}}if(Mt(),e.clearSelection(),e.setSelectedWorktreeIndex(0),e.setSelectedWorktreePath(null),o.refetch(),m.length>0)i("error"),c(`Failed: ${m.join("; ")}`),n.addToast({message:`Failed to remove ${m.length} worktree(s)`,type:"error"}),setTimeout(u,3000);else i("done"),c(`Removed ${x.length} worktree(s) successfully!`),n.addToast({message:`Removed ${x.length} worktrees`,type:"success"}),setTimeout(u,1500)};Xl(async(x)=>{if(!e.showBulkActions())return;if(e.showCommandPalette())return;let m=x.name;if(r()==="executing")return;if(m==="escape"){u();return}if((m==="return"||m==="enter")&&r()==="confirming")await d()});let g=()=>h().length;return React.createElement("box",{x:0,y:0,width:t.w,height:t.h,backgroundColor:l.bg.base},React.createElement("box",{x:2,y:1,width:t.w-3,height:t.h-2,flexDirection:"column",backgroundColor:l.bg.base},React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.text.error},"Bulk Delete Worktrees")),React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.border.subtle},"\u2500".repeat(Math.max(t.w-5,10)))),React.createElement("box",{height:1}),React.createElement(O,{when:r()==="confirming"},React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.text.warning},`Delete ${g()} worktree(s)?`)),React.createElement("box",{height:1}),React.createElement(St,{each:h().slice(0,Math.max(t.h-10,5))},(x)=>React.createElement("box",{height:1},React.createElement("text",{x:2,y:0,fg:l.text.accent},`\u2022 ${x.branch}`))),React.createElement(O,{when:g()>Math.max(t.h-10,5)},React.createElement("box",{height:1},React.createElement("text",{x:2,y:0,fg:l.text.secondary},`... and ${g()-Math.max(t.h-10,5)} more`))),React.createElement("box",{height:1}),React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.text.secondary},"Enter:delete all Esc:cancel"))),React.createElement(O,{when:r()==="executing"},React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.text.warning},s())),React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.text.secondary},`Progress: ${f()+1}/${g()}`))),React.createElement(O,{when:r()==="done"},React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.text.success},s()))),React.createElement(O,{when:r()==="error"},React.createElement("box",{height:1},React.createElement("text",{x:0,y:0,fg:l.text.error},s())))))}var Bs=N(()=>{Rt();ie();Mn();me();ct();$t();$e();Ht()});import{useKeyboard as Zl,useTerminalDimensions as Ql}from"@opentui/solid";import{spawnSync as Yl}from"child_process";function Ls(){let t=Et(),e=Ql(),o=Nt(),n=()=>{try{return Y()}catch{return null}},[r,i]=v(n()),[s,c]=v("");Zl((h)=>{if(t.activeTab()!=="config")return;if(t.showCommandPalette())return;let u=h.name;if(u==="e"){let d=process.env.EDITOR??process.env.VISUAL??"vi";fe(),Yl(d,[o],{stdio:"inherit"}),i(n()),c("Config reloaded"),setTimeout(()=>c(""),2000)}if(u==="r")i(n()),c("Reloaded"),setTimeout(()=>c(""),2000);if(u==="i")fe(),i(n()),c("Config initialized"),setTimeout(()=>c(""),2000)});let f=()=>e().width,a=()=>e().height;return React.createElement("box",{x:0,y:0,width:"100%",height:"100%",backgroundColor:l.bg.base,flexDirection:"column"},React.createElement("box",{width:"100%",height:"100%",backgroundColor:l.bg.surface,flexDirection:"column",paddingX:2,paddingY:1},React.createElement("box",{height:1},React.createElement("text",{fg:l.text.accent},React.createElement("b",null,"Configuration"))),React.createElement("box",{flexDirection:"row",gap:1},React.createElement("text",{fg:l.text.secondary},"Path:"),React.createElement("text",{fg:l.text.primary},o)),React.createElement(O,{when:!r()},React.createElement("box",{flexDirection:"column",gap:1},React.createElement("text",{fg:l.text.warning},"No config file found."),React.createElement("box",{flexDirection:"row",gap:1},React.createElement("text",{fg:l.text.secondary},"Press"),React.createElement("text",{fg:l.text.accent},"i"),React.createElement("text",{fg:l.text.secondary},"to initialize with defaults.")))),React.createElement(O,{when:!!r()},React.createElement("box",{flexDirection:"column",gap:1},React.createElement("text",{fg:l.text.accent},"Defaults"),React.createElement("box",{flexDirection:"row"},React.createElement("box",{width:14},React.createElement("text",{fg:l.text.secondary},"worktreeDir")),React.createElement("text",{fg:l.text.primary},r()?.defaults?.worktreeDir??"../{repo}-{branch}")),React.createElement("box",{flexDirection:"row"},React.createElement("box",{width:14},React.createElement("text",{fg:l.text.secondary},"copyFiles")),React.createElement("text",{fg:l.text.primary},"[",(r()?.defaults?.copyFiles??[]).join(", "),"]")),React.createElement("box",{flexDirection:"row"},React.createElement("box",{width:14},React.createElement("text",{fg:l.text.secondary},"linkFiles")),React.createElement("text",{fg:l.text.primary},"[",(r()?.defaults?.linkFiles??[]).join(", "),"]")),React.createElement("box",{flexDirection:"row"},React.createElement("box",{width:14},React.createElement("text",{fg:l.text.secondary},"postCreate")),React.createElement("text",{fg:l.text.primary},"[",(r()?.defaults?.postCreate??[]).join(", "),"]"))),React.createElement("box",null,React.createElement("text",{fg:l.border.subtle},"\u2500".repeat(Math.max(f()-34,10)))),React.createElement(O,{when:(r()?.repos?.length??0)>0},React.createElement("box",{flexDirection:"column",gap:1},React.createElement("text",{fg:l.text.accent},"Repos (",r()?.repos?.length,")"),React.createElement(St,{each:r()?.repos?.slice(0,4)},(h)=>React.createElement("box",{flexDirection:"column",gap:0},React.createElement("text",{fg:l.text.primary},h.path.split("/").pop()??h.path),React.createElement("box",{flexDirection:"row"},React.createElement("box",{width:11},React.createElement("text",{fg:l.text.secondary},"copyFiles")),React.createElement("text",{fg:l.text.primary},(h.copyFiles??[]).length>0?(h.copyFiles??[]).join(", "):"\u2014")),React.createElement("box",{flexDirection:"row"},React.createElement("box",{width:11},React.createElement("text",{fg:l.text.secondary},"postCreate")),React.createElement("text",{fg:l.text.primary},(h.postCreate??[]).length>0?(h.postCreate??[]).join(", "):"\u2014")))))),React.createElement(O,{when:(r()?.repos?.length??0)===0},React.createElement("text",{fg:l.text.secondary},"No per-repo configs defined."))),React.createElement(O,{when:!!s()},React.createElement("text",{fg:l.text.success},s()))),React.createElement("box",{width:"100%",height:1,backgroundColor:l.bg.base,flexDirection:"row",gap:2},React.createElement("box",{flexDirection:"row"},React.createElement("text",{fg:l.text.secondary},"e"),React.createElement("text",{fg:l.text.primary},":edit")),React.createElement("box",{flexDirection:"row"},React.createElement("text",{fg:l.text.secondary},"r"),React.createElement("text",{fg:l.text.primary},":reload")),React.createElement("box",{flexDirection:"row"},React.createElement("text",{fg:l.text.secondary},"i"),React.createElement("text",{fg:l.text.primary},":init"))))}var As=N(()=>{Rt();ie();$t();Ht()});import{existsSync as Po,readdirSync as th,rmSync as eh}from"fs";import{basename as Sr,dirname as Pr,join as oh,resolve as So}from"path";function nh(t){let e=Bun.env.HOME??"~";return t.replace(/^~(?=\/|$)/,e)}function Is(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _s(t){if(!Po(Nt()))return[];let e=t.find((c)=>c.isMain);if(!e)return[];let o=Y(),n=So(e.path),r=Sr(n);return[o.repos?.find((c)=>So(c.path)===n)?.worktreeDir??o.defaults?.worktreeDir].filter((c)=>typeof c==="string").map((c)=>nh(c)).filter((c)=>!Pr(c).includes("{")&&Sr(c).includes("{")).map((c)=>{let f=Sr(c),a=`^${Is(f).replace(/\\\{repo\\\}/g,Is(r)).replace(/\\\{branch\\\}/g,".+")}$`,h=new RegExp(a);return{path:So(Pr(c)),matches:(u)=>h.test(u)}})}function Ts(t){let e=new Set;for(let o of t)if(!o.isMain)e.add(So(Pr(o.path)));return[...e]}function js(t,e,o,n){if(!Po(t))return;let r=th(t,{withFileTypes:!0});for(let i of r){if(!i.isDirectory())continue;if(n&&!n(i.name))continue;let s=So(oh(t,i.name));if(!e.has(s))o.add(s)}}function Gs(t){let e=new Set(t.map((r)=>So(r.path))),o=new Set,n=new Set;for(let r of _s(t))n.add(r.path),js(r.path,e,o,r.matches);for(let r of Ts(t)){if(n.has(r))continue;js(r,e,o)}return[...o]}function rh(t){return _s(t).some((e)=>Po(e.path))||Ts(t).some((e)=>Po(e))}async function ih(){let t=Bun.spawn(["git","--version"],{stdout:"pipe",stderr:"pipe",env:{...Bun.env,LC_ALL:"C",LANG:"C"}}),[e,o]=await Promise.all([new Response(t.stdout).text(),t.exited]);if(o!==0)return null;return e.trim().match(/git version (\d+\.\d+(?:\.\d+)?)/)?.[1]??null}async function sh(){try{return await M.checkVersion(),{name:"Git version",status:"pass",message:`${await ih()??"unknown"} (>= 2.17 required)`}}catch(e){if(e instanceof jo)return{name:"Git version",status:"fail",message:e.message};return{name:"Git version",status:"fail",message:`Check failed: ${e.message}`}}}async function ch(){try{let o=(Y().repos??[]).map((n)=>n.path).filter((n)=>!Po(n));if(o.length>0)return{name:"Configuration",status:"warn",message:"missing repository paths",detail:o};return{name:"Configuration",status:"pass",message:"valid"}}catch(e){return{name:"Configuration",status:"fail",message:`Check failed: ${e.message}`}}}function ah(t){let o=t.map((n)=>n.path).filter((n)=>!Po(n));if(o.length>0)return{name:"Stale worktrees",status:"warn",message:"missing worktree paths",detail:o};return{name:"Stale worktrees",status:"pass",message:"none"}}function fh(t){try{let o=Gs(t);if(o.length===0)return{name:"Orphaned directories",status:"pass",message:rh(t)?"none":"no worktree directory"};return{name:"Orphaned directories",status:"warn",message:"orphaned worktree directories found",detail:o}}catch(o){return{name:"Orphaned directories",status:"fail",message:`Check failed: ${o.message}`}}}function lh(t){let o=t.filter((r)=>r.isLocked);if(o.length===0)return{name:"Worktree locks",status:"pass",message:"all clear"};return{name:"Worktree locks",status:"warn",message:"locked worktrees present",detail:o.map((r)=>{let i=r.branch??"detached";if(!r.lockReason)return`${i} - ${r.path} (potential stale lock: no reason)`;return`${i} - ${r.path} (reason: ${r.lockReason})`})}}function hh(t){let o=t.filter((n)=>n.isDirty&&!n.isMain);if(o.length===0)return{name:"Dirty worktrees",status:"pass",message:"none"};return{name:"Dirty worktrees",status:"warn",message:"dirty non-main worktrees found",detail:o.map((n)=>`${n.branch??"detached"} - ${n.path}`)}}async function yo(t){let e=await M.list(t).catch(()=>[]),o=[await sh(),await ch(),ah(e),fh(e),lh(e),hh(e)];return{checks:o,healthy:o.every((n)=>n.status==="pass")}}async function uh(t){try{return await M.prune(t),{action:"Prune stale worktrees",success:!0}}catch(e){return{action:"Prune stale worktrees",success:!1,detail:e.message}}}async function ph(t){let e=[];try{let o=Gs(await M.list(t).catch(()=>[]));for(let n of o)try{eh(n,{recursive:!0,force:!0}),e.push({action:"Remove orphaned directory",success:!0,detail:n})}catch(r){e.push({action:"Remove orphaned directory",success:!1,detail:`${n}: ${r.message}`})}}catch(o){e.push({action:"Remove orphaned directories",success:!1,detail:o.message})}return e}async function dh(t){let e=[];try{let n=(await M.list(t)).filter((r)=>r.isLocked&&!r.lockReason);for(let r of n)try{await M.unlock(r.path,t),e.push({action:"Unlock stale lock",success:!0,detail:`${r.branch??"detached"} - ${r.path}`})}catch(i){e.push({action:"Unlock stale lock",success:!1,detail:`${r.path}: ${i.message}`})}}catch(o){e.push({action:"Fix stale locks",success:!1,detail:o.message})}return e}async function On(t){let e=[];return e.push(await uh(t)),e.push(...await ph(t)),e.push(...await dh(t)),e}var yr=N(()=>{$t();ct();Zt()});import{useKeyboard as mh,useTerminalDimensions as xh}from"@opentui/solid";function Hs(){let t=Et(),e=xh(),[o,n]=v(null),[r,i]=v(!0),[s,c]=v(""),[f,a]=v(!1),[h,u]=v([]),d=async()=>{i(!0),c(""),u([]);try{let G=await yo();n(G)}catch(G){c(G.message)}i(!1)},g=async()=>{if(o()?.healthy)return;a(!0);try{let G=await On();u(G);let ot=await yo();n(ot)}catch(G){c(G.message)}a(!1)};d(),mh((G)=>{if(t.activeTab()!=="doctor")return;if(t.showCommandPalette())return;let ot=G.name;if(ot==="r")d();if(ot==="f"&&!r()&&!f()&&!o()?.healthy)g()});let x=()=>e().width,m=()=>e().height,b=()=>Math.max(50,Math.min(80,x()-4)),S=()=>{let G=it()+st()+8+(st()>0?2:0);return Math.max(12,Math.min(G,m()-4))},E=()=>Math.max(b()-4,10),y=(G)=>{if(G==="pass")return"\u2713";if(G==="warn")return"\u26A0";return"\u2717"},R=(G)=>{if(G==="pass")return l.text.success;if(G==="warn")return l.text.warning;return l.text.error},it=()=>o()?.checks.length??0,st=()=>h().length;return React.createElement(je,{width:b(),height:S(),borderColor:o()?.healthy?l.text.success:o()?l.text.warning:l.border.default,backgroundColor:l.bg.surface,title:" Doctor ",footer:React.createElement(rw,null,React.createElement("box",{height:1,width:E()},React.createElement("text",{fg:l.border.subtle},"\u2500".repeat(Math.max(E(),1)))),React.createElement("box",{flexDirection:"row",gap:2},React.createElement("text",{fg:l.text.secondary},"r:recheck"),React.createElement(O,{when:!o()?.healthy},React.createElement("text",{fg:l.text.secondary},"f:fix")),React.createElement("text",{fg:l.text.secondary},"Esc:back")))},React.createElement(O,{when:r()},React.createElement("text",{fg:l.text.secondary},"Running health checks...")),React.createElement(O,{when:f()},React.createElement("text",{fg:l.text.accent},"Running auto-fix...")),React.createElement(O,{when:!r()&&!f()&&!!s()},React.createElement("text",{fg:l.text.error},"Error: ",s())),React.createElement(O,{when:!r()&&!f()&&!s()&&!!o()},React.createElement("text",{fg:l.text.accent},"Health Checks"),React.createElement("text",{fg:l.border.subtle},"\u2500".repeat(E())),React.createElement(St,{each:o().checks},(G)=>{return React.createElement("box",{width:"100%",height:1,flexDirection:"row"},React.createElement("text",{fg:R(G.status)},y(G.status)),React.createElement("text",{x:2,y:0,fg:l.text.primary},G.name,":"),React.createElement("text",{x:G.name.length+4,y:0,fg:l.text.secondary},G.message))}),React.createElement("text",{fg:l.border.subtle},"\u2500".repeat(E())),React.createElement("text",{fg:o().healthy?l.text.success:l.text.warning},o().healthy?"\u2713 All checks passed":`${o().checks.filter((G)=>G.status==="fail").length} error(s), ${o().checks.filter((G)=>G.status==="warn").length} warning(s) found`),React.createElement(O,{when:st()>0},React.createElement("text",{fg:l.text.accent},"Fix Results"),React.createElement("text",{fg:l.border.subtle},"\u2500".repeat(E())),React.createElement(St,{each:h()},(G)=>{return React.createElement("box",{width:"100%",height:1,flexDirection:"row"},React.createElement("text",{fg:G.success?l.text.success:l.text.error},G.success?"\u2713":"\u2717"),React.createElement("text",{x:2,y:0,fg:l.text.primary},G.action),React.createElement(O,{when:!!G.detail},React.createElement("text",{x:G.action.length+3,y:0,fg:l.text.secondary},"(",G.detail,")")))}))))}var Ns=N(()=>{Rt();ie();yr();Ht();zo()});var zs={};xt(zs,{writePin:()=>Rr,removePin:()=>Mr,readPin:()=>Uo,listPinnedWorktrees:()=>Or,isPinned:()=>_e});import{readFileSync as Js,writeFileSync as gh,unlinkSync as wh,mkdirSync as bh,existsSync as Er}from"fs";import{join as Ch,dirname as ks}from"path";function vo(t){return ce(t,"omw-pin")}function $h(t){let e=vo(t),o=ks(e),n=Ch(o,"HEAD"),r=Js(n,"utf-8").trim(),i=r.match(/^ref:\s+refs\/heads\/(.+)$/);return i?i[1]:r}function Rr(t,e){let o=vo(t),n={branch:$h(t),pinnedAt:new Date().toISOString(),...e?{reason:e}:{}};bh(ks(o),{recursive:!0}),gh(o,JSON.stringify(n),{encoding:"utf-8",mode:384})}function Uo(t){let e=vo(t);if(!Er(e))return null;return JSON.parse(Js(e,"utf-8"))}function Mr(t){let e=vo(t);if(!Er(e))return;wh(e)}function _e(t){return Er(vo(t))}function Or(t){return t.filter((e)=>_e(e.path))}var Eo=N(()=>{We()});import{useKeyboard as Sh}from"@opentui/solid";function vs(){let t=Et(),e=Ot(),o=()=>e.worktrees()??[],n=()=>t.selectedWorktreeIndex(),r=(h)=>{let u=Math.max(0,Math.min(h,Math.max(o().length-1,0))),d=o()[u];t.setSelectedWorktreeIndex(u),t.setSelectedWorktreePath(d?.path??null)},i=re(()=>{let h=o(),u=[],d=new Map;for(let m of h){let b=d.get(m.repoName);if(b)b.push(m);else d.set(m.repoName,[m])}let g=0,x=!0;for(let[m,b]of d){if(!x)u.push({type:"separator"});x=!1,u.push({type:"header",repoName:m});for(let S of b)u.push({type:"worktree",wt:S,flatIdx:g}),g++}return u}),s=()=>t.selectedWorktrees().size;Sh((h)=>{if(t.activeTab()!=="list")return;if(t.showCommandPalette())return;if(t.showRemove())return;if(t.showBulkActions())return;let u=h.name,d=o();if(u==="j"||u==="down")r(Math.min(n()+1,d.length-1));if(u==="k"||u==="up")r(Math.max(n()-1,0));if(u==="space"){let g=n(),x=d[g];if(x&&!x.isMain)t.toggleWorktreeSelection(x.path)}if(h.ctrl&&u==="a")t.selectAllNonMain(d.filter((g)=>!g.isMain).map((g)=>g.path))});let c=(h)=>{if(h.isLocked)return"\uD83D\uDD12";if(h.isDirty)return"\u25CF";return"\u2713"},f=(h)=>{if(h.isLocked)return l.text.warning;if(h.isDirty)return l.text.error;return l.text.success},a=(h,u)=>{let d=h.branch??"(detached)",g=Math.max(8,Vo-(u?9:7));return d.length>g?d.slice(0,g-1)+"\u2026":d};return React.createElement("box",{x:0,y:0,width:"100%",height:"100%",backgroundColor:l.bg.surface,flexDirection:"column",paddingX:1,paddingY:1,gap:0},React.createElement(O,{when:e.loading()},React.createElement("text",{fg:l.text.secondary},"Loading...")),React.createElement(O,{when:!e.loading()},React.createElement(St,{each:i()},(h)=>{if(h.type==="header")return React.createElement("box",{width:"100%",height:1},React.createElement("text",{fg:l.text.accent},React.createElement("b",null,h.repoName)));if(h.type==="separator")return React.createElement("box",{width:"100%",height:1},React.createElement("text",{fg:l.border.subtle},"\u2500".repeat(Vo)));let u=h.wt,d=()=>h.flatIdx===n(),g=()=>t.selectedWorktrees().has(u.path);return React.createElement("box",{width:"100%",height:1,backgroundColor:d()?l.select.focusedBg:g()?l.bg.elevated:l.bg.surface,paddingX:1,onMouseDown:()=>r(h.flatIdx)},React.createElement("text",{x:0,y:0,fg:f(u)},c(u)),React.createElement("text",{x:2,y:0,fg:d()?l.tab.active:l.text.primary},a(u,!1)),React.createElement(O,{when:g()},React.createElement("text",{x:Vo-1,y:0,fg:l.text.accent},"\u2713")),React.createElement(O,{when:!!Vt(u.path)},React.createElement("text",{x:Vo-(g()?3:1),y:0,fg:l.text.accent},"S")),React.createElement(O,{when:_e(u.path)},React.createElement("text",{x:Vo-(g()?5:3)+(Vt(u.path)?0:2),y:0,fg:l.text.warning},"P")))}),React.createElement(O,{when:s()>0},React.createElement("box",{width:"100%",height:1},React.createElement("text",{fg:l.text.accent},`Selected: ${s()}`)))))}var Vo=24;var Us=N(()=>{Rt();ie();me();Ht();Eo();Fe()});import{useKeyboard as Ph,useTerminalDimensions as yh}from"@opentui/solid";function Vs(){let t=Et(),e=Ot(),o=yh(),[n,r]=v(""),[i,s]=v(0),c=()=>{let m=e.worktrees()??[],b=t.selectedWorktreePath();if(b){let S=m.find((E)=>E.path===b);if(S)return S}return m[t.selectedWorktreeIndex()]},f=()=>{let m=process.env.VISUAL||process.env.EDITOR;if(m)return m;let b=["code","cursor","vim","nvim","zed","subl","idea","webstorm"];for(let S of b)try{if(Bun.spawnSync(["which",S],{stdout:"pipe",stderr:"pipe"}).exitCode===0)return S}catch{}return null},a=re(()=>[{id:"add",label:"Add Worktree",description:"Create a new git worktree",action:()=>{t.setActiveTab("add"),t.setShowCommandPalette(!1)}},{id:"delete",label:"Delete Worktree",description:"Remove the selected worktree",action:()=>{let m=c();if(!m||m.isMain)return;t.setShowRemove(!0),t.setShowCommandPalette(!1)}},{id:"open-editor",label:"Open in Editor",description:"Open selected worktree in IDE",action:()=>{let m=c();if(!m)return;let b=f();if(!b)return;t.setShowCommandPalette(!1),Bun.spawn([b,m.path],{stdout:"inherit",stderr:"inherit"})}},{id:"refresh",label:"Refresh",description:"Reload worktree list",action:()=>{e.refetch(),t.setShowCommandPalette(!1)}},{id:"config",label:"Open Config",description:"View configuration",action:()=>{t.setActiveTab("config"),t.setShowCommandPalette(!1)}},{id:"doctor",label:"Run Doctor",description:"Check worktree health",action:()=>{t.setActiveTab("doctor"),t.setShowCommandPalette(!1)}},...un.map((m)=>({id:`theme:${m}`,label:`Theme: ${ss[m]}`,description:"Switch color theme",action:()=>{pn(m);try{let b=Nt(),S={...Y()};S.theme=m,Jo(b,JSON.stringify(S,null,2))}catch{}t.setShowCommandPalette(!1)}})),{id:"quit",label:"Quit",description:"Exit oh-my-worktree",action:()=>process.exit(0)}]),h=re(()=>{let m=n().toLowerCase();if(!m)return a();return a().filter((b)=>b.label.toLowerCase().includes(m)||b.description.toLowerCase().includes(m))});Ph((m)=>{if(!t.showCommandPalette())return;let b=m.name;if(b==="escape"){t.setShowCommandPalette(!1),r(""),s(0);return}if(b==="return"||b==="enter"){let S=h()[i()];if(S)S.action();r(""),s(0);return}if(b==="down"||b==="j"){s((S)=>Math.min(S+1,h().length-1));return}if(b==="up"||b==="k"){s((S)=>Math.max(S-1,0));return}if(b==="backspace"){r((S)=>S.slice(0,-1)),s(0);return}if(m.sequence&&m.sequence.length===1&&m.sequence.charCodeAt(0)>=32)r((S)=>S+m.sequence),s(0)});let u=()=>Math.max(50,Math.min(80,o().width-4)),d=()=>Math.max(10,Math.min(h().length+8,o().height-4)),g=()=>u()-4,x=()=>d()-8;return React.createElement(je,{width:u(),height:d(),borderColor:l.border.active,backgroundColor:l.bg.surface,title:" Command Palette ",footer:React.createElement(yw,null,React.createElement("box",{height:1,width:g()},React.createElement("text",{fg:l.border.subtle},"\u2500".repeat(Math.max(g(),1)))),React.createElement("box",{flexDirection:"row",gap:2},React.createElement("text",{fg:l.text.secondary},"\u2191\u2193:navigate"),React.createElement("text",{fg:l.text.secondary},"Enter:run"),React.createElement("text",{fg:l.text.secondary},"Esc:close")))},React.createElement("box",{height:1,width:g(),backgroundColor:l.bg.elevated},React.createElement("text",{x:1,y:0,fg:l.text.accent},">"),React.createElement("text",{x:3,y:0,fg:l.text.primary},n()),React.createElement("text",{x:3+n().length,y:0,fg:l.text.accent},"\u2588")),React.createElement("box",{height:1,width:g()},React.createElement("text",{fg:l.border.subtle},"\u2500".repeat(Math.max(g(),1)))),React.createElement("box",{width:g(),height:x(),backgroundColor:l.bg.surface,flexDirection:"column"},React.createElement(St,{each:h().slice(0,x())},(m,b)=>{let S=()=>b()===i();return React.createElement("box",{height:1,width:g(),backgroundColor:S()?l.select.focusedBg:l.bg.surface,onMouseDown:()=>{s(b()),m.action()}},React.createElement("text",{x:2,y:0,fg:S()?l.tab.active:l.text.primary},m.label),React.createElement("text",{x:Math.max(25,m.label.length+4),y:0,fg:l.text.secondary},m.description))}),React.createElement(O,{when:h().length===0},React.createElement("box",{height:1},React.createElement("text",{x:2,y:0,fg:l.text.secondary},"No commands found")))))}var Ks=N(()=>{Rt();ie();me();Ht();zo();$t()});import{useTerminalDimensions as Eh}from"@opentui/solid";function Rh(t){if(t==="success")return"\u2713";if(t==="warning")return"\u26A0";if(t==="error")return"\u2717";return"\u2139"}function Mh(t){if(t==="success")return l.text.success;if(t==="warning")return l.text.warning;if(t==="error")return l.text.error;return l.text.primary}function qs(){let t=Eh(),e=()=>Math.min(60,Math.max(24,t().width-4));return React.createElement("box",{x:(()=>Math.max(0,t().width-e()-1))(),y:1,width:e(),height:5,flexDirection:"column"},React.createElement(St,{each:Rn().toasts()},(n,r)=>React.createElement("box",{x:0,y:r(),width:e(),height:1,backgroundColor:l.bg.elevated},React.createElement("text",{x:1,y:0,fg:Mh(n.type)},`${Rh(n.type)} ${n.message}`))))}var Xs=N(()=>{Rt();Mn();Ht()});var Ys={};xt(Ys,{launchTUI:()=>Ah});import{render as Oh,useKeyboard as Wh,useTerminalDimensions as Dh,useRenderer as Fh}from"@opentui/solid";import{resolve as Zs}from"path";function Bh(){let t=["code","cursor","vim","nvim","zed","subl","idea","webstorm"];for(let e of t)try{if(Bun.spawnSync(["which",e],{stdout:"pipe",stderr:"pipe"}).exitCode===0)return e}catch{}return null}function Lh(t){let e=Et(),o=Ot(),n=Fh(),[r,i]=v(!1),s=Dh(),c=()=>{let m=o.worktrees()??[],b=e.selectedWorktreePath();if(b){let S=m.find((E)=>E.path===b);if(S)return S}return m[e.selectedWorktreeIndex()]};de(()=>{let m=o.worktrees()??[],b=m.map((R)=>R.path);if(e.pruneSelectedWorktrees(b),m.length===0){if(e.selectedWorktreeIndex()!==0)e.setSelectedWorktreeIndex(0);if(e.selectedWorktreePath()!==null)e.setSelectedWorktreePath(null);return}let S=e.selectedWorktreePath();if(S){let R=m.findIndex((it)=>it.path===S);if(R>=0){if(R!==e.selectedWorktreeIndex())e.setSelectedWorktreeIndex(R);return}}let E=Math.min(e.selectedWorktreeIndex(),m.length-1),y=m[E]?.path??null;if(E!==e.selectedWorktreeIndex())e.setSelectedWorktreeIndex(E);if(y!==e.selectedWorktreePath())e.setSelectedWorktreePath(y)}),Wh((m)=>{if(e.showCommandPalette())return;let b=m.name;if(m.ctrl&&b==="p"){e.setShowCommandPalette(!0);return}if(b==="escape"){if(e.showBulkActions()){e.setShowBulkActions(!1);return}if(e.showDetailView()){e.setShowDetailView(!1);return}if(e.showRemove()){e.setShowRemove(!1);return}if(r()){i(!1);return}if(e.activeTab()!=="list"){e.setActiveTab("list");return}}if(e.showBulkActions())return;if(e.showRemove())return;if(e.activeTab()==="add")return;if(e.activeTab()==="list"){if(e.showDetailView())return;if(b==="a"){e.setActiveTab("add");return}if(b==="r"){o.refetch();return}if(b==="d"){let S=c();if(S&&!S.isMain)e.setShowRemove(!0);return}if(b==="o"){let S=c();if(S){let E=process.env.VISUAL||process.env.EDITOR||Bh();if(E)Bun.spawn([E,S.path],{stdout:"inherit",stderr:"inherit"})}return}}if(b==="h"){e.setActiveTab("doctor");return}if(b==="q"||b==="Q")n.destroy();if(b==="?")i((S)=>!S)});let f=()=>s().width,a=()=>s().height,h=()=>t.repoPath.split("/").pop()??"",u=()=>{let m=o.repoNames();if(m.length<=1)return h();return`${m.length} repos`},d=()=>{let m=o.worktrees()??[];return`${h()} \xB7 ${m.length} worktrees`},g=()=>{return` Worktrees (${(o.worktrees()??[]).length}) `},x=()=>f()-Qs-1;return React.createElement("box",{width:f(),height:a(),backgroundColor:l.bg.base,flexDirection:"column"},React.createElement("box",{height:1,backgroundColor:l.bg.overlay},React.createElement("text",{x:1,y:0,fg:l.text.accent},"\uD83C\uDF33 oh-my-worktree"),React.createElement("text",{x:f()-u().length-2,y:0,fg:l.text.secondary},u())),React.createElement("box",{flexGrow:1,flexDirection:"row"},React.createElement("box",{width:Qs,flexShrink:0,backgroundColor:l.bg.surface,flexDirection:"column"},React.createElement("box",{height:1,paddingX:1},React.createElement("text",{fg:l.text.accent},React.createElement("b",null,g()))),React.createElement(vs,null)),React.createElement("box",{width:1}),React.createElement("box",{flexGrow:1,backgroundColor:l.bg.base},React.createElement(O,{when:e.activeTab()!=="config"&&!e.showRemove()&&!e.showBulkActions()},React.createElement(us,null)),React.createElement(O,{when:e.activeTab()==="list"&&e.showBulkActions()},React.createElement(Fs,{w:x(),h:a()-3})),React.createElement(O,{when:e.activeTab()==="config"},React.createElement(Ls,null)))),React.createElement(qs,null),React.createElement("toaster",{position:"bottom-right"}),React.createElement("box",{height:1,backgroundColor:l.bg.overlay},React.createElement("text",{x:0,y:0,fg:l.border.subtle},"\u2500".repeat(f()))),React.createElement("box",{height:1,backgroundColor:l.bg.overlay},React.createElement("text",{x:1,y:0,fg:l.text.secondary},"d:delete a:add o:open r:refresh ^P:cmd h:health q:quit")),React.createElement(O,{when:r()&&!e.showCommandPalette()},React.createElement("box",{x:Math.max(0,Math.floor((f()-Math.max(40,Math.min(60,f()-4)))/2)),y:Math.max(0,Math.floor((a()-14)/2)),width:Math.max(40,Math.min(60,f()-4)),height:14,border:!0,borderStyle:"rounded",borderColor:l.border.active,backgroundColor:l.bg.elevated,title:" Keyboard Shortcuts ",titleAlignment:"left",flexDirection:"column",paddingX:1,paddingY:1,position:"absolute"},React.createElement("box",{height:1},React.createElement("text",{x:1,fg:l.text.secondary},"q"),React.createElement("text",{x:8,fg:l.text.primary},"Quit")),React.createElement("box",{height:1},React.createElement("text",{x:1,fg:l.text.secondary},"j/k"),React.createElement("text",{x:8,fg:l.text.primary},"Navigate list")),React.createElement("box",{height:1},React.createElement("text",{x:1,fg:l.text.secondary},"a"),React.createElement("text",{x:8,fg:l.text.primary},"Add worktree")),React.createElement("box",{height:1},React.createElement("text",{x:1,fg:l.text.secondary},"d"),React.createElement("text",{x:8,fg:l.text.primary},"Delete worktree")),React.createElement("box",{height:1},React.createElement("text",{x:1,fg:l.text.secondary},"r"),React.createElement("text",{x:8,fg:l.text.primary},"Refresh list")),React.createElement("box",{height:1}),React.createElement("box",{height:1},React.createElement("text",{x:1,fg:l.text.secondary},"Ctrl+P"),React.createElement("text",{x:8,fg:l.text.primary},"Command palette")),React.createElement("box",{height:1},React.createElement("text",{x:1,fg:l.text.secondary},"?"),React.createElement("text",{x:8,fg:l.text.primary},"Toggle help")),React.createElement("box",{height:1}),React.createElement("box",{height:1},React.createElement("text",{x:1,fg:l.text.accent},"Press ? to close")))),React.createElement(O,{when:e.activeTab()==="add"},React.createElement(Es,null)),React.createElement(O,{when:e.activeTab()==="doctor"},React.createElement(Hs,null)),React.createElement(O,{when:e.showRemove()},React.createElement(Ms,null)),React.createElement(O,{when:e.showCommandPalette()},React.createElement(Vs,null)))}async function Ah(){if(process.stdout.isTTY)process.stdout.write("\x1B]0;Oh My Worktree\x07");let t=await M.getMainRepoPath().catch(()=>process.cwd()),e=[t];try{let o={...Y()},n=Le(o),r=new Set([Zs(t)]);for(let i of n){let s=Zs(i);if(!r.has(s))r.add(s),e.push(i)}if(o.theme&&un.includes(o.theme))pn(o.theme)}catch{}await Oh(()=>React.createElement(os,{repoPath:t,repoPaths:e},React.createElement(is,{repoPaths:e},React.createElement(Ds,null,React.createElement(Lh,{repoPath:t})))),{exitOnCtrlC:!0,useMouse:!0})}var Qs=28;var tc=N(()=>{Rt();ie();me();ct();ps();Rs();Os();Bs();As();Ns();Us();Ht();Ks();Mn();Xs();$t()});import*as ec from"readline";async function Te(t){let e=ec.createInterface({input:process.stdin,output:process.stdout});return new Promise((o)=>{e.question(t,(n)=>{e.close(),o(n.toLowerCase()==="y"||n.toLowerCase()==="yes")})})}async function at(){return M.getMainRepoPath().catch(()=>process.cwd())}function Kt(t,e){let o=t.find((n)=>n.branch===e||n.path===e||n.path.endsWith("/"+e));if(!o)console.error(`Error: no worktree found for '${e}'`),process.exit(1);return o}function wt(t){if(t instanceof Gt)console.error(`Git error: ${t.message}`);else console.error(`Error: ${t.message}`);process.exit(1)}var Dt=N(()=>{ct();Zt()});import{mkdirSync as Ih,writeFileSync as jh}from"fs";import{dirname as _h}from"path";function Th(t){return ce(t,"omw-pr")}function oc(t,e){let o=Th(t);Ih(_h(o),{recursive:!0}),jh(o,JSON.stringify(e),{encoding:"utf-8",mode:384})}var nc=N(()=>{We()});import{appendFileSync as Gh,existsSync as Hh,mkdirSync as Nh,readFileSync as rc,rmSync as Jh,statSync as kh,writeFileSync as zh}from"fs";import{dirname as vh}from"path";function Wr(t){return ce(t,"omw-activity.log")}function qt(t,e){let o=Wr(t);Nh(vh(o),{recursive:!0}),Gh(o,`${JSON.stringify(e)}
|
|
16
|
-
`,{encoding:"utf-8",mode:384});let n=kh(o,{throwIfNoEntry:!1});if(n&&n.size>Vh){let r=rc(o,"utf-8").split(/\r?\n/).filter(Boolean);if(r.length>ic){let i=r.slice(-Uh);zh(o,`${i.join(`
|
|
3
|
+
var lu=Object.defineProperty;var fu=(e)=>e;function uu(e,t){this[e]=fu.bind(null,t)}var Ye=(e,t)=>{for(var n in t)lu(e,n,{get:t[n],enumerable:!0,configurable:!0,set:uu.bind(t,n)})};var $e=(e,t)=>()=>(e&&(t=e(e=0)),t);var En=import.meta.require;function ta(e){let t=String(e),n=t.length-1;return dt.context.id+(n?String.fromCharCode(96+n):"")+t}function od(e){dt.context=e}function os(e,t){let n=Ge,o=Ae,r=e.length===0,i=t===void 0?o:t,s=r?la:{owned:null,cleanups:null,context:i?i.context:null,owner:i},c=r?e:()=>e(()=>xn(()=>Xn(s)));Ae=s,Ge=null;try{return Ht(c,!0)}finally{Ge=n,Ae=o}}function be(e,t){t=t?Object.assign({},_r,t):_r;let n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},o=(r)=>{if(typeof r==="function")if(oe&&oe.running&&oe.sources.has(n))r=r(n.tValue);else r=r(n.value);return da(n,r)};return[ua.bind(n),o]}function oa(e,t,n){let o=oi(e,t,!0,zt);if(jo&&oe&&oe.running)at.push(o);else Go(o)}function cd(e,t,n){let o=oi(e,t,!1,zt);if(jo&&oe&&oe.running)at.push(o);else Go(o)}function ln(e,t,n){aa=md;let o=oi(e,t,!1,zt),r=br&&Qn(br);if(r)o.suspense=r;if(!n||!n.render)o.user=!0;Ct?Ct.push(o):Go(o)}function Ot(e,t,n){n=n?Object.assign({},_r,n):_r;let o=oi(e,t,!0,0);if(o.observers=null,o.observerSlots=null,o.comparator=n.equals||void 0,jo&&oe&&oe.running)o.tState=zt,at.push(o);else Go(o);return ua.bind(o)}function ad(e){return e&&typeof e==="object"&&"then"in e}function fa(e,t,n){let o,r,i;if(typeof t==="function")o=e,r=t,i=n||{};else o=!0,r=e,i=t||{};let s=null,c=ns,u=null,f=!1,m=!1,l="initialValue"in i,p=typeof o==="function"&&Ot(o),R=new Set,[M,d]=(i.storage||be)(i.initialValue),[b,y]=be(void 0),[S,P]=be(void 0,{equals:!1}),[E,I]=be(l?"ready":"unresolved");if(dt.context){if(u=dt.getNextContextId(),i.ssrLoadFrom==="initial")c=i.initialValue;else if(dt.load&&dt.has(u))c=dt.load(u)}function V(G,F,N,K){if(s===G){if(s=null,K!==void 0&&(l=!0),(G===c||F===c)&&i.onHydrated)queueMicrotask(()=>i.onHydrated(K,{value:F}));if(c=ns,oe&&G&&f)oe.promises.delete(G),f=!1,Ht(()=>{oe.running=!0,T(F,N)},!1);else T(F,N)}return F}function T(G,F){Ht(()=>{if(F===void 0)d(()=>G);I(F!==void 0?"errored":l?"ready":"unresolved"),y(F);for(let N of R.keys())N.decrement();R.clear()},!1)}function H(){let G=br&&Qn(br),F=M(),N=b();if(N!==void 0&&!s)throw N;if(Ge&&!Ge.user&&G)oa(()=>{if(S(),s){if(G.resolved&&oe&&f)oe.promises.add(s);else if(!R.has(G))G.increment(),R.add(G)}});return F}function Q(G=!0){if(G!==!1&&m)return;m=!1;let F=p?p():o;if(f=oe&&oe.running,F==null||F===!1){V(s,xn(M));return}if(oe&&s)oe.promises.delete(s);let N,K=c!==ns?c:xn(()=>{try{return r(F,{value:M(),refetching:G})}catch(k){N=k}});if(N!==void 0){V(s,void 0,Yr(N),F);return}else if(!ad(K))return V(s,K,void 0,F),K;if(s=K,"v"in K){if(K.s===1)V(s,K.v,void 0,F);else V(s,void 0,Yr(K.v),F);return K}return m=!0,queueMicrotask(()=>m=!1),Ht(()=>{I(l?"refreshing":"pending"),P()},!1),K.then((k)=>V(K,k,void 0,F),(k)=>V(K,void 0,Yr(k),F))}Object.defineProperties(H,{state:{get:()=>E()},error:{get:()=>b()},loading:{get(){let G=E();return G==="pending"||G==="refreshing"}},latest:{get(){if(!l)return H();let G=b();if(G&&!s)throw G;return M()}}});let he=Ae;if(p)oa(()=>(he=Ae,Q(!1)));else Q(!1);return[H,{refetch:(G)=>ld(he,()=>Q(G)),mutate:d}]}function xn(e){if(!To&&Ge===null)return e();let t=Ge;Ge=null;try{if(To)return To.untrack(e);return e()}finally{Ge=t}}function Zn(e,t,n){let o=Array.isArray(e),r,i=n&&n.defer;return(s)=>{let c;if(o){c=Array(e.length);for(let f=0;f<e.length;f++)c[f]=e[f]()}else c=e();if(i)return i=!1,s;let u=xn(()=>t(c,r,s));return r=c,u}}function ni(e){ln(()=>xn(e))}function en(e){if(Ae===null);else if(Ae.cleanups===null)Ae.cleanups=[e];else Ae.cleanups.push(e);return e}function ld(e,t){let n=Ae,o=Ge;Ae=e,Ge=null;try{return Ht(t,!0)}catch(r){ri(r)}finally{Ae=n,Ge=o}}function fd(e){if(oe&&oe.running)return e(),oe.done;let t=Ge,n=Ae;return Promise.resolve().then(()=>{Ge=t,Ae=n;let o;if(jo||br)o=oe||(oe={sources:new Set,effects:[],promises:new Set,disposed:new Set,queue:new Set,running:!0}),o.done||(o.done=new Promise((r)=>o.resolve=r)),o.running=!0;return Ht(e,!1),Ge=Ae=null,o?o.done:void 0})}function No(e,t){let n=Symbol("context");return{id:n,Provider:pd(n),defaultValue:e}}function Qn(e){let t;return Ae&&Ae.context&&(t=Ae.context[e.id])!==void 0?t:e.defaultValue}function ud(e){let t=Ot(e),n=Ot(()=>rs(t()));return n.toArray=()=>{let o=n();return Array.isArray(o)?o:o!=null?[o]:[]},n}function ua(){let e=oe&&oe.running;if(this.sources&&(e?this.tState:this.state))if((e?this.tState:this.state)===zt)Go(this);else{let t=at;at=null,Ht(()=>ei(this),!1),at=t}if(Ge){let t=this.observers?this.observers.length:0;if(!Ge.sources)Ge.sources=[this],Ge.sourceSlots=[t];else Ge.sources.push(this),Ge.sourceSlots.push(t);if(!this.observers)this.observers=[Ge],this.observerSlots=[Ge.sources.length-1];else this.observers.push(Ge),this.observerSlots.push(Ge.sources.length-1)}if(e&&oe.sources.has(this))return this.tValue;return this.value}function da(e,t,n){let o=oe&&oe.running&&oe.sources.has(e)?e.tValue:e.value;if(!e.comparator||!e.comparator(o,t)){if(oe){let r=oe.running;if(r||!n&&oe.sources.has(e))oe.sources.add(e),e.tValue=t;if(!r)e.value=t}else e.value=t;if(e.observers&&e.observers.length)Ht(()=>{for(let r=0;r<e.observers.length;r+=1){let i=e.observers[r],s=oe&&oe.running;if(s&&oe.disposed.has(i))continue;if(s?!i.tState:!i.state){if(i.pure)at.push(i);else Ct.push(i);if(i.observers)ma(i)}if(!s)i.state=zt;else i.tState=zt}if(at.length>1e6)throw at=[],Error()},!1)}return t}function Go(e){if(!e.fn)return;Xn(e);let t=ti;if(ia(e,oe&&oe.running&&oe.sources.has(e)?e.tValue:e.value,t),oe&&!oe.running&&oe.sources.has(e))queueMicrotask(()=>{Ht(()=>{oe&&(oe.running=!0),Ge=Ae=e,ia(e,e.tValue,t),Ge=Ae=null},!1)})}function ia(e,t,n){let o,r=Ae,i=Ge;Ge=Ae=e;try{o=e.fn(t)}catch(s){if(e.pure)if(oe&&oe.running)e.tState=zt,e.tOwned&&e.tOwned.forEach(Xn),e.tOwned=void 0;else e.state=zt,e.owned&&e.owned.forEach(Xn),e.owned=null;return e.updatedAt=n+1,ri(s)}finally{Ge=i,Ae=r}if(!e.updatedAt||e.updatedAt<=n){if(e.updatedAt!=null&&"observers"in e)da(e,o,!0);else if(oe&&oe.running&&e.pure){if(!oe.sources.has(e))e.value=o;oe.sources.add(e),e.tValue=o}else e.value=o;e.updatedAt=n}}function oi(e,t,n,o=zt,r){let i={fn:e,state:o,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:Ae,context:Ae?Ae.context:null,pure:n};if(oe&&oe.running)i.state=0,i.tState=o;if(Ae===null);else if(Ae!==la)if(oe&&oe.running&&Ae.pure)if(!Ae.tOwned)Ae.tOwned=[i];else Ae.tOwned.push(i);else if(!Ae.owned)Ae.owned=[i];else Ae.owned.push(i);if(To&&i.fn){let s=i.fn,[c,u]=be(void 0,{equals:!1}),f=To.factory(s,u);en(()=>f.dispose());let m,l=()=>fd(u).then(()=>{if(m)m.dispose(),m=void 0});i.fn=(p)=>{if(c(),oe&&oe.running){if(!m)m=To.factory(s,l);return m.track(p)}return f.track(p)}}return i}function vr(e){let t=oe&&oe.running;if((t?e.tState:e.state)===0)return;if((t?e.tState:e.state)===xr)return ei(e);if(e.suspense&&xn(e.suspense.inFallback))return e.suspense.effects.push(e);let n=[e];while((e=e.owner)&&(!e.updatedAt||e.updatedAt<ti)){if(t&&oe.disposed.has(e))return;if(t?e.tState:e.state)n.push(e)}for(let o=n.length-1;o>=0;o--){if(e=n[o],t){let r=e,i=n[o+1];while((r=r.owner)&&r!==i)if(oe.disposed.has(r))return}if((t?e.tState:e.state)===zt)Go(e);else if((t?e.tState:e.state)===xr){let r=at;at=null,Ht(()=>ei(e,n[0]),!1),at=r}}}function Ht(e,t){if(at)return e();let n=!1;if(!t)at=[];if(Ct)n=!0;else Ct=[];ti++;try{let o=e();return dd(n),o}catch(o){if(!n)Ct=null;at=null,ri(o)}}function dd(e){if(at){if(jo&&oe&&oe.running)hd(at);else ha(at);at=null}if(e)return;let t;if(oe){if(!oe.promises.size&&!oe.queue.size){let{sources:o,disposed:r}=oe;Ct.push.apply(Ct,oe.effects),t=oe.resolve;for(let i of Ct)"tState"in i&&(i.state=i.tState),delete i.tState;oe=null,Ht(()=>{for(let i of r)Xn(i);for(let i of o){if(i.value=i.tValue,i.owned)for(let s=0,c=i.owned.length;s<c;s++)Xn(i.owned[s]);if(i.tOwned)i.owned=i.tOwned;delete i.tValue,delete i.tOwned,i.tState=0}ra(!1)},!1)}else if(oe.running){oe.running=!1,oe.effects.push.apply(oe.effects,Ct),Ct=null,ra(!0);return}}let n=Ct;if(Ct=null,n.length)Ht(()=>aa(n),!1);if(t)t()}function ha(e){for(let t=0;t<e.length;t++)vr(e[t])}function hd(e){for(let t=0;t<e.length;t++){let n=e[t],o=oe.queue;if(!o.has(n))o.add(n),jo(()=>{o.delete(n),Ht(()=>{oe.running=!0,vr(n)},!1),oe&&(oe.running=!1)})}}function md(e){let t,n=0;for(t=0;t<e.length;t++){let o=e[t];if(!o.user)vr(o);else e[n++]=o}if(dt.context){if(dt.count){dt.effects||(dt.effects=[]),dt.effects.push(...e.slice(0,n));return}od()}if(dt.effects&&(dt.done||!dt.count))e=[...dt.effects,...e],n+=dt.effects.length,delete dt.effects;for(t=0;t<n;t++)vr(e[t])}function ei(e,t){let n=oe&&oe.running;if(n)e.tState=0;else e.state=0;for(let o=0;o<e.sources.length;o+=1){let r=e.sources[o];if(r.sources){let i=n?r.tState:r.state;if(i===zt){if(r!==t&&(!r.updatedAt||r.updatedAt<ti))vr(r)}else if(i===xr)ei(r,t)}}}function ma(e){let t=oe&&oe.running;for(let n=0;n<e.observers.length;n+=1){let o=e.observers[n];if(t?!o.tState:!o.state){if(t)o.tState=xr;else o.state=xr;if(o.pure)at.push(o);else Ct.push(o);o.observers&&ma(o)}}}function Xn(e){let t;if(e.sources)while(e.sources.length){let n=e.sources.pop(),o=e.sourceSlots.pop(),r=n.observers;if(r&&r.length){let i=r.pop(),s=n.observerSlots.pop();if(o<r.length)i.sourceSlots[s]=o,r[o]=i,n.observerSlots[o]=s}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)Xn(e.tOwned[t]);delete e.tOwned}if(oe&&oe.running&&e.pure)pa(e,!0);else if(e.owned){for(t=e.owned.length-1;t>=0;t--)Xn(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}if(oe&&oe.running)e.tState=0;else e.state=0}function pa(e,t){if(!t)e.tState=0,oe.disposed.add(e);if(e.owned)for(let n=0;n<e.owned.length;n++)pa(e.owned[n])}function Yr(e){if(e instanceof Error)return e;return Error(typeof e==="string"?e:"Unknown error",{cause:e})}function sa(e,t,n){try{for(let o of t)o(e)}catch(o){ri(o,n&&n.owner||null)}}function ri(e,t=Ae){let n=na&&t&&t.context&&t.context[na],o=Yr(e);if(!n)throw o;if(Ct)Ct.push({fn(){sa(o,n,t)},state:zt});else sa(o,n,t)}function rs(e){if(typeof e==="function"&&!e.length)return rs(e());if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let o=rs(e[n]);Array.isArray(o)?t.push.apply(t,o):t.push(o)}return t}return e}function pd(e,t){return function(o){let r;return cd(()=>r=xn(()=>{return Ae.context={...Ae.context,[e]:o.value},ud(()=>o.children)}),void 0),r}}function ca(e){for(let t=0;t<e.length;t++)e[t]()}function wd(e,t,n={}){let o=[],r=[],i=[],s=0,c=t.length>1?[]:null;return en(()=>ca(i)),()=>{let u=e()||[],f=u.length,m,l;return u[sd],xn(()=>{let R,M,d,b,y,S,P,E,I;if(f===0){if(s!==0)ca(i),i=[],o=[],r=[],s=0,c&&(c=[]);if(n.fallback)o=[gd],r[0]=os((V)=>{return i[0]=V,n.fallback()}),s=1}else if(s===0){r=Array(f);for(l=0;l<f;l++)o[l]=u[l],r[l]=os(p);s=f}else{d=Array(f),b=Array(f),c&&(y=Array(f));for(S=0,P=Math.min(s,f);S<P&&o[S]===u[S];S++);for(P=s-1,E=f-1;P>=S&&E>=S&&o[P]===u[E];P--,E--)d[E]=r[P],b[E]=i[P],c&&(y[E]=c[P]);R=new Map,M=Array(E+1);for(l=E;l>=S;l--)I=u[l],m=R.get(I),M[l]=m===void 0?-1:m,R.set(I,l);for(m=S;m<=P;m++)if(I=o[m],l=R.get(I),l!==void 0&&l!==-1)d[l]=r[m],b[l]=i[m],c&&(y[l]=c[m]),l=M[l],R.set(I,l);else i[m]();for(l=S;l<f;l++)if(l in d){if(r[l]=d[l],i[l]=b[l],c)c[l]=y[l],c[l](l)}else r[l]=os(p);r=r.slice(0,s=f),o=u.slice(0)}return r});function p(R){if(i[l]=R,c){let[M,d]=be(l);return c[l]=d,t(u[l],M)}return t(u[l])}}}function ft(e){let t="fallback"in e&&{fallback:()=>e.fallback};return Ot(wd(()=>e.each,e.children,t||void 0))}function te(e){let t=e.keyed,n=Ot(()=>e.when,void 0,void 0),o=t?n:Ot(n,void 0,{equals:(r,i)=>!r===!i});return Ot(()=>{let r=o();if(r){let i=e.children;return typeof i==="function"&&i.length>0?xn(()=>i(t?r:()=>{if(!xn(o))throw xd("Show");return n()})):i}return e.fallback},void 0,void 0)}var dt,rd=!1,id=(e,t)=>e===t,Wx,sd,Dx,_r,na=null,aa,zt=1,xr=2,la,ns,Ae=null,oe=null,jo=null,To=null,Ge=null,at=null,Ct=null,ti=0,Fx,ra,br,gd,xd=(e)=>`Stale read from <${e}>.`;var ht=$e(()=>{dt={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return ta(this.context.count)},getNextContextId(){return ta(this.context.count++)}};Wx=Symbol("solid-proxy"),sd=Symbol("solid-track"),Dx=Symbol("solid-dev-component"),_r={equals:id},aa=ha,la={owned:null,cleanups:null,context:null,owner:null},ns={};[Fx,ra]=be(!1);gd=Symbol("fallback")});function ga(e){return typeof e==="object"&&e!==null&&"frames"in e&&"interval"in e&&Array.isArray(e.frames)}function wa(e){return typeof e==="object"&&e!==null&&"label"in e&&"onClick"in e}function is(e,t){switch(e){case"success":return t.success;case"error":return t.error;case"warning":return t.warning;case"info":return t.info;case"loading":return ss(t.loading);default:return""}}function ss(e){if(ga(e))return e.frames[0]??"\u25CC";return e}function cs(e){return ga(e)?e:null}var bd,xa;var ba=$e(()=>{bd={frames:["\u25DC","\u25E0","\u25DD","\u25DE","\u25E1","\u25DF"],interval:100},xa={success:"\u2713",error:"\u2717",warning:"!",info:"\u2139",loading:bd,close:"\xD7"}});import{BoxRenderable as si,TextAttributes as vd,TextRenderable as Cr,parseColor as Cd}from"@opentui/core";function Md(e){return e!==null&&typeof e==="object"&&"ok"in e&&typeof e.ok==="boolean"&&"status"in e&&typeof e.status==="number"}function Dd(e,t={}){let[n,o]=e.split("-"),r={position:"absolute"};if(n==="top")r.top=t.top??ii.top;else r.bottom=t.bottom??ii.bottom;if(o==="left")r.left=t.left??ii.left,r.alignItems="flex-start";else if(o==="center")r.left=0,r.width="100%",r.alignItems="center";else r.right=t.right??ii.right,r.alignItems="flex-end";return r}function Fd(e){return e.includes("center")}function Id(e){return e.startsWith("top")}function Bd(e,t={top:0,right:0,bottom:0,left:0}){if(!e)return{...t};let{padding:n,paddingX:o,paddingY:r}=e;return{top:e.paddingTop??r??n??t.top,right:e.paddingRight??o??n??t.right,bottom:e.paddingBottom??r??n??t.bottom,left:e.paddingLeft??o??n??t.left}}function Ld(...e){let t={};for(let n of e){if(!n)continue;Object.assign(t,n)}return t}function va(e,t,n){let o=as.style,r=as[e]?.style,i=t?.style,s=t?.[e]?.style,c=Ld(o,r,i,s,n);if(c.border===!1)delete c.borderStyle,delete c.borderColor;return c}function Ca(e,t,n){if(n!==void 0)return n;let o=t?.[e]?.duration;if(o!==void 0)return o;if(t?.duration!==void 0)return t.duration;return as.duration}var $d,Pd=200,$a=60,ii,Sd,as,Ed=1,yd=class{subscribers=[];toasts=[];dismissedToasts=new Set;_activeToasts=[];_updateActiveToastsCache=()=>{let e=this.toasts.filter((t)=>!this.dismissedToasts.has(t.id));if(e.length!==this._activeToasts.length||e.some((t,n)=>t!==this._activeToasts[n]))this._activeToasts=e};subscribe=(e)=>{return this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);if(t>-1)this.subscribers.splice(t,1)}};publish=(e)=>{for(let t of this.subscribers)t(e)};addToast=(e)=>{this.toasts=[...this.toasts,e],this._updateActiveToastsCache(),this.publish(e)};create=(e)=>{let{message:t,...n}=e,o=typeof e.id==="number"||e.id&&e.id.length>0?e.id:Ed++,r=this.toasts.find((s)=>s.id===o),i=e.dismissible===void 0?!0:e.dismissible;if(this.dismissedToasts.has(o))this.dismissedToasts.delete(o);if(r)this.toasts=this.toasts.map((s)=>{if(s.id===o)return this.publish({...s,...e,id:o,title:t}),{...s,...e,id:o,dismissible:i,title:t};return s}),this._updateActiveToastsCache();else this.addToast({title:t,...n,dismissible:i,id:o,type:e.type??"default"});return o};dismiss=(e)=>{if(e!==void 0)this.dismissedToasts.add(e),this._updateActiveToastsCache(),setTimeout(()=>{for(let t of this.subscribers)t({id:e,dismiss:!0})},0);else{for(let t of this.toasts){this.dismissedToasts.add(t.id);for(let n of this.subscribers)n({id:t.id,dismiss:!0})}this._updateActiveToastsCache()}return e};message=(e,t)=>{return this.create({...t,message:e,type:"default"})};error=(e,t)=>{return this.create({...t,message:e,type:"error"})};success=(e,t)=>{return this.create({...t,message:e,type:"success"})};info=(e,t)=>{return this.create({...t,message:e,type:"info"})};warning=(e,t)=>{return this.create({...t,message:e,type:"warning"})};loading=(e,t)=>{return this.create({...t,message:e,type:"loading"})};promise=(e,t)=>{if(!t)return;let n;if(t.loading!==void 0)n=this.create({...t,type:"loading",message:t.loading,description:typeof t.description!=="function"?t.description:void 0});let o=e instanceof Function?e():e,r=n!==void 0,i,s=o.then(async(u)=>{if(i=["resolve",u],Md(u)&&!u.ok){r=!1;let f=typeof t.error==="function"?await t.error(`HTTP error! status: ${u.status}`):t.error,m=typeof t.description==="function"?await t.description(`HTTP error! status: ${u.status}`):t.description,l=typeof f==="object"&&f!==null?f:{message:f};this.create({id:n,type:"error",description:m,...l})}else if(u instanceof Error){r=!1;let f=typeof t.error==="function"?await t.error(u):t.error,m=typeof t.description==="function"?await t.description(u):t.description,l=typeof f==="object"&&f!==null?f:{message:f};this.create({id:n,type:"error",description:m,...l})}else if(t.success!==void 0){r=!1;let f=typeof t.success==="function"?await t.success(u):t.success,m=typeof t.description==="function"?await t.description(u):t.description,l=typeof f==="object"&&f!==null?f:{message:f};this.create({id:n,type:"success",description:m,...l})}}).catch(async(u)=>{if(i=["reject",u],t.error!==void 0){r=!1;let f=typeof t.error==="function"?await t.error(u):t.error,m=typeof t.description==="function"?await t.description(u):t.description,l=typeof f==="object"&&f!==null?f:{message:f};this.create({id:n,type:"error",description:m,...l})}}).finally(()=>{if(r)this.dismiss(n),n=void 0;t.finally?.()}),c=()=>new Promise((u,f)=>s.then(()=>i[0]==="reject"?f(i[1]):u(i[1])).catch(f));if(typeof n!=="string"&&typeof n!=="number")return{unwrap:c};return Object.assign(n,{unwrap:c})};getActiveToasts=()=>{return this._activeToasts}},Bt,Rd=(e,t)=>Bt.message(e,t),Od=()=>Bt.toasts,Wd=()=>Bt.getActiveToasts(),So,Ad,Pa;var Sa=$e(()=>{ba();$d={SHORT:2000,DEFAULT:4000,LONG:6000,EXTENDED:1e4,PERSISTENT:1/0},ii={top:1,right:2,bottom:1,left:2},Sd={border:!0,borderStyle:"single",borderColor:"#333333",minHeight:3,backgroundColor:"#1a1a1a",foregroundColor:"#ffffff",mutedColor:"#6b7280"},as={style:Sd,duration:$d.DEFAULT,default:{style:{borderColor:"#333333"}},success:{style:{borderColor:"#22c55e"}},error:{style:{borderColor:"#ef4444"}},warning:{style:{borderColor:"#f59e0b"}},info:{style:{borderColor:"#3b82f6"}},loading:{style:{borderColor:"#6b7280"}}};Bt=new yd,So=Object.assign(Rd,{success:Bt.success,info:Bt.info,warning:Bt.warning,error:Bt.error,message:Bt.message,promise:Bt.promise,dismiss:Bt.dismiss,loading:Bt.loading},{getHistory:Od,getToasts:Wd});Ad=class extends si{_toast;_icons;_toastOptions;_computedStyle;_closeButton;_onRemove;_remainingTime;_closeTimerStartTime=0;_lastCloseTimerStartTime=0;_timerHandle=null;_paused=!1;_dismissed=!1;_spinnerHandle=null;_spinnerFrameIndex=0;_spinnerConfig=null;_iconText=null;_contentBox=null;_titleText=null;_descriptionText=null;_actionsBox=null;constructor(e,t){let n=va(t.toast.type,t.toastOptions,t.toast.style),o=Ca(t.toast.type,t.toastOptions,t.toast.duration),r=Bd(n,{top:0,right:1,bottom:0,left:1});super(e,{id:`toast-${t.toast.id}`,flexDirection:"row",gap:1,border:n.border,borderStyle:n.borderStyle,borderColor:n.borderColor,customBorderChars:n.customBorderChars,backgroundColor:n.backgroundColor,minHeight:n.minHeight,maxWidth:n.maxWidth??$a,minWidth:n.minWidth,paddingTop:r.top,paddingRight:r.right,paddingBottom:r.bottom,paddingLeft:r.left,onMouseOver:()=>this.pause(),onMouseOut:()=>this.resume()});if(this._toast=t.toast,this._icons=t.icons===!1?!1:{...xa,...t.icons},this._toastOptions=t.toastOptions,this._computedStyle=n,this._closeButton=t.closeButton,this._onRemove=t.onRemove,this._remainingTime=o,this.setupContent(),this._remainingTime!==1/0&&this._toast.type!=="loading")this.startTimer();if(this._toast.type==="loading")this.startSpinner()}setupContent(){let e=this.ctx,t=this._toast,n=this._computedStyle,o=this._icons,r=n.iconColor??n.borderColor,i=t.type==="loading";if(i&&o!==!1)this._spinnerConfig=cs(o.loading);let s=t.icon??(o===!1?void 0:i?ss(o.loading):is(t.type,o));if(s)this._iconText=new Cr(e,{id:`${this.id}-icon`,content:s,fg:r,flexShrink:0,paddingTop:0,paddingBottom:0}),this.add(this._iconText);this._contentBox=new si(e,{id:`${this.id}-content`,flexDirection:"column",flexGrow:1,flexShrink:1,gap:0});let c=typeof t.title==="function"?t.title():t.title;if(c)this._titleText=new Cr(e,{id:`${this.id}-title`,content:c,fg:n.foregroundColor,attributes:vd.BOLD,wrapMode:"word"}),this._contentBox.add(this._titleText);let u=typeof t.description==="function"?t.description():t.description;if(u)this._descriptionText=new Cr(e,{id:`${this.id}-description`,content:u,fg:n.mutedColor,wrapMode:"word"}),this._contentBox.add(this._descriptionText);if(this.add(this._contentBox),t.action){if(this._actionsBox=new si(e,{id:`${this.id}-actions`,flexDirection:"row",gap:1,flexShrink:0,alignItems:"center"}),t.action&&wa(t.action)){let f=new Cr(e,{id:`${this.id}-action`,content:`[${t.action.label}]`,fg:n.foregroundColor,onMouseUp:()=>t.action?.onClick?.()});this._actionsBox.add(f)}this.add(this._actionsBox)}if((t.closeButton??this._closeButton)&&t.dismissible!==!1){let f=o===!1?"\xD7":o.close,m=new Cr(e,{id:`${this.id}-close`,content:f,fg:n.mutedColor,flexShrink:0,onMouseUp:()=>this.dismiss()});this.add(m)}}startTimer(){if(this._remainingTime===1/0)return;this._closeTimerStartTime=Date.now(),this._timerHandle=setTimeout(()=>{this._toast.onAutoClose?.(this._toast),this.dismiss()},this._remainingTime)}pause(){if(this._paused||this._remainingTime===1/0)return;if(this._paused=!0,this._timerHandle)clearTimeout(this._timerHandle),this._timerHandle=null;if(this._lastCloseTimerStartTime<this._closeTimerStartTime){let e=Date.now()-this._closeTimerStartTime;this._remainingTime=Math.max(0,this._remainingTime-e)}this._lastCloseTimerStartTime=Date.now()}resume(){if(!this._paused||this._remainingTime===1/0)return;this._paused=!1,this.startTimer()}startSpinner(){if(this._spinnerHandle||!this._spinnerConfig)return;let{frames:e,interval:t}=this._spinnerConfig;this._spinnerHandle=setInterval(()=>{this._spinnerFrameIndex=(this._spinnerFrameIndex+1)%e.length;let n=e[this._spinnerFrameIndex];if(this._iconText&&n)this._iconText.content=n,this.requestRender()},t)}stopSpinner(){if(this._spinnerHandle)clearInterval(this._spinnerHandle),this._spinnerHandle=null}dismiss(){if(this._dismissed)return;if(this._dismissed=!0,this._timerHandle)clearTimeout(this._timerHandle),this._timerHandle=null;this.stopSpinner(),this._toast.onDismiss?.(this._toast),Bt.dismiss(this._toast.id),setTimeout(()=>{this._onRemove?.(this._toast)},Pd)}updateToast(e){this._toast=e;let t=va(e.type,this._toastOptions,e.style);if(this._computedStyle=t,t.borderColor)this.borderColor=t.borderColor;if(t.customBorderChars)this.customBorderChars=t.customBorderChars;let n=t.iconColor??t.borderColor;if(this._iconText){let i=e.icon??(this._icons===!1?void 0:is(e.type,this._icons));if(i)this._iconText.content=i;if(n)this._iconText.fg=Cd(n)}if(this._titleText){let i=typeof e.title==="function"?e.title():e.title;if(i)this._titleText.content=i}if(this._descriptionText){let i=typeof e.description==="function"?e.description():e.description;if(i)this._descriptionText.content=i}let o=this._spinnerHandle!==null,r=e.type==="loading";if(o&&!r)this.stopSpinner(),this._spinnerConfig=null;else if(!o&&r){if(this._icons!==!1)this._spinnerConfig=cs(this._icons.loading);this.startSpinner()}if(e.type!=="loading"){if(this._timerHandle)clearTimeout(this._timerHandle);if(this._remainingTime=Ca(e.type,this._toastOptions,e.duration),this._remainingTime!==1/0)this.startTimer()}this.requestRender()}get toast(){return this._toast}get isDismissed(){return this._dismissed}destroy(){if(this._timerHandle)clearTimeout(this._timerHandle),this._timerHandle=null;this.stopSpinner(),super.destroy()}},Pa=class extends si{_options={};_toastRenderables=new Map;_unsubscribe=null;constructor(e,t={}){super(e,{id:"toaster",flexDirection:"column",gap:1,zIndex:9999});this._options=t,this.applyLayoutOptions(),this.subscribe()}applyLayoutOptions(){let e=this._options.position??"bottom-right",t=Dd(e,this._options.offset??{}),n=Fd(e);if(Object.assign(this,t),super.gap=this._options.gap??1,!n)super.maxWidth=this._options.maxWidth??$a}isToastPosition(e){return e==="top-left"||e==="top-center"||e==="top-right"||e==="bottom-left"||e==="bottom-center"||e==="bottom-right"}set position(e){if(this.isToastPosition(e))this._options.position=e,this.applyLayoutOptions();else super.position=e}set offset(e){this._options.offset=e,this.applyLayoutOptions()}set gap(e){this._options.gap=e,super.gap=e}set visibleToasts(e){this._options.visibleToasts=e}set closeButton(e){this._options.closeButton=e}set icons(e){this._options.icons=e}set stackingMode(e){this._options.stackingMode=e}set maxWidth(e){this._options.maxWidth=e,super.maxWidth=e}set toastOptions(e){this._options.toastOptions=e}subscribe(){this._unsubscribe=Bt.subscribe((e)=>{if("dismiss"in e&&e.dismiss)this.removeToast(e.id);else this.addOrUpdateToast(e)})}addOrUpdateToast(e){let t=this._toastRenderables.get(e.id);if(t){t.updateToast(e);return}if((this._options.stackingMode??"single")==="single")for(let[o]of this._toastRenderables)this.removeToast(o);else{let o=this._options.visibleToasts??3,r=this._toastRenderables.size;if(r>=o){let i=r-o+1,s=Array.from(this._toastRenderables.keys());for(let c=0;c<i;c++){let u=s[c];if(u!==void 0)this.removeToast(u)}}}let n=new Ad(this.ctx,{toast:e,icons:this._options.icons,toastOptions:this._options.toastOptions,closeButton:this._options.closeButton,onRemove:(o)=>this.handleToastRemoved(o)});if(this._toastRenderables.set(e.id,n),Id(this._options.position??"bottom-right"))this.add(n);else this.add(n,0);this.requestRender()}removeToast(e){let t=this._toastRenderables.get(e);if(t)t.dismiss()}handleToastRemoved(e){let t=this._toastRenderables.get(e.id);if(t)this._toastRenderables.delete(e.id),this.remove(t.id),t.destroy(),this.requestRender()}get toastCount(){return this._toastRenderables.size}dismissAll(){for(let[e]of this._toastRenderables)this.removeToast(e)}destroy(){this._unsubscribe?.();for(let[,e]of this._toastRenderables)e.destroy();this._toastRenderables.clear(),super.destroy()}}});import{createElement as zx,extend as Td,spread as Ux}from"@opentui/solid";var ls=$e(()=>{Sa();Td({toaster:Pa})});import{createComponent as jd}from"@opentui/solid";function Ma(e){let[t,n]=be("list"),[o,r]=be(0),[i,s]=be(null),[c,u]=be(!1),[f,m]=be(!1),[l,p]=be(!1),[R,M]=be(!1),[d,b]=be(new Set),[y,S]=be(!1),P=(T)=>{let H=new Set(d());if(H.has(T))H.delete(T);else H.add(T);b(H)},E=(T)=>{b(new Set(T))},I=(T)=>{let H=new Set(T),Q=d(),he=new Set;for(let G of Q)if(H.has(G))he.add(G);if(he.size!==Q.size)b(he)},V=()=>{b(new Set)};return jd(Ea.Provider,{value:{activeTab:t,setActiveTab:n,selectedWorktreeIndex:o,setSelectedWorktreeIndex:r,selectedWorktreePath:i,setSelectedWorktreePath:s,showRemove:c,setShowRemove:u,showCommandPalette:f,setShowCommandPalette:m,showDetailView:l,setShowDetailView:p,inputFocused:R,setInputFocused:M,repoPath:()=>e.repoPath,repoPaths:()=>e.repoPaths,selectedWorktrees:d,toggleWorktreeSelection:P,selectAllNonMain:E,pruneSelectedWorktrees:I,clearSelection:V,showBulkActions:y,setShowBulkActions:S},get children(){return e.children}})}function mt(){let e=Qn(Ea);if(!e)throw Error("useApp must be used within AppProvider");return e}var Ea;var bn=$e(()=>{ht();Ea=No()});var Ut,$r,fs,Pr;var fn=$e(()=>{Ut=class Ut extends Error{exitCode;stderr;command;constructor(e,t,n,o){super(e);this.exitCode=t;this.stderr=n;this.command=o;this.name="GitError"}};$r=class $r extends Error{installed;required;constructor(e,t){super(`git version ${e} is below minimum required ${t}`);this.installed=e;this.required=t;this.name="GitVersionError"}};fs=class fs extends Error{branch;reason;constructor(e,t,n){super(e);this.branch=t;this.reason=n;this.name="ArchiveError"}};Pr=class Pr extends Error{path;reason;constructor(e,t,n){super(e);this.path=t;this.reason=n;this.name="ImportError"}}});async function un(e,t,n){let o=Array(e.length),r=0;async function i(){while(r<e.length){let c=r++;o[c]=await n(e[c])}}let s=Array.from({length:Math.min(t,e.length)},()=>i());return await Promise.all(s),o}import{resolve as ya,dirname as Gd}from"path";import{mkdirSync as kd,existsSync as Hd}from"fs";function Sr(e){let t=ci.get(e);if(!t)return;if(Date.now()>t.expires){ci.delete(e);return}return t.data}function vn(e,t,n=zd){return ci.set(e,{data:t,expires:Date.now()+n}),t}function $t(){ci.clear()}class ee{static gitVersionChecked=!1;static async run(e,t){let n=Bun.spawn(["git",...e],{cwd:t??Bun.cwd,stdout:"pipe",stderr:"pipe",env:{...Bun.env,LC_ALL:"C",LANG:"C"}}),[o,r,i]=await Promise.all([new Response(n.stdout).text(),new Response(n.stderr).text(),n.exited]);if(i!==0)throw new Ut(`git ${e[0]} failed: ${r.trim()}`,i,r.trim(),`git ${e.join(" ")}`);return o.trim()}static async exec(e,t){return this.run(e,t)}static async checkVersion(){if(this.gitVersionChecked)return;let t=(await this.run(["--version"])).match(/git version (\d+)\.(\d+)\.?((\d+)?)/);if(!t)throw Error("Cannot parse git version");let[,n,o]=t.map(Number);if(n<2||n===2&&o<17)throw new $r(`${n}.${o}`,"2.17");this.gitVersionChecked=!0}static async list(e){await this.checkVersion();let t=e??Bun.cwd,n=await this.getMainRepoPath(t).catch(()=>t),o=`list:${n}`,r=Sr(o);if(r)return r;let i=n.split("/").pop()??"",s=await this.run(["worktree","list","--porcelain"],t),c=this.parsePorcelain(s,i,n),u=await un(c,10,async(f)=>({...f,isDirty:await this.isDirty(f.path).catch(()=>!1)}));return vn(o,u)}static async listAll(e){await this.checkVersion();let t=new Set,n=[];for(let r of e){let i=ya(r);if(!t.has(i))t.add(i),n.push(i)}return(await un(n,5,async(r)=>{try{return await this.list(r)}catch{return[]}})).flat()}static parsePorcelain(e,t,n){let o=e.trim();if(!o)return[];return o.split(/\n\n+/).filter(Boolean).map((i,s)=>{let c=i.split(`
|
|
4
|
+
`),u=c.find((b)=>b.startsWith("worktree ")),f=c.find((b)=>b.startsWith("HEAD ")),m=c.find((b)=>b.startsWith("branch ")),l=c.find((b)=>b.startsWith("locked")),p=u?.slice(9)??"",R=f?.slice(5)??"",M=null;if(m)M=m.slice(7).replace(/^refs\/heads\//,"");let d=l&&l.startsWith("locked ")?l.slice(7):void 0;return{path:p,branch:M,head:R,isMain:s===0,isDirty:!1,isLocked:Boolean(l),lockReason:d,repoName:t,repoPath:n}})}static async add(e,t,n,o){await this.checkVersion();let r=Gd(t);if(!Hd(r))kd(r,{recursive:!0});let s=!await this.localBranchExists(e,o),c=["worktree","add",t,e];if(s)c=["worktree","add","-b",e,t,n?.base??"HEAD"];await this.run(c,o),$t()}static async localBranchExists(e,t){try{return await this.run(["rev-parse","--verify",`refs/heads/${e}`],t??Bun.cwd),!0}catch{return!1}}static async remove(e,t,n){await this.checkVersion();let o=["worktree","remove",e];if(t?.force)o.push("--force");await this.run(o,n),$t()}static async move(e,t,n){await this.checkVersion(),await this.run(["worktree","move",e,t],n),$t()}static async prune(e){await this.checkVersion(),await this.run(["worktree","prune"],e),$t()}static async isWorktree(e){let t=e??Bun.cwd;try{let n=await this.run(["rev-parse","--git-dir"],t),o=await this.run(["rev-parse","--git-common-dir"],t);return n!==o&&!n.endsWith("/.git")&&!n.endsWith("\\.git")}catch{return!1}}static async getMainRepoPath(e){let t=e??Bun.cwd,n=await this.run(["rev-parse","--git-common-dir"],t),o=ya(t,n);return o.endsWith("/.git")?o.slice(0,-5):o}static async getBranchForWorktree(e){try{let t=await this.run(["rev-parse","--abbrev-ref","HEAD"],e);return t==="HEAD"?null:t}catch{return null}}static async isDirty(e){try{return(await this.run(["status","--porcelain"],e??Bun.cwd)).length>0}catch{return!1}}static async getAheadBehind(e,t){let n=t??Bun.cwd,o=`ahead-behind:${n}:${e}`,r=Sr(o);if(r)return r;try{let i=await this.run(["rev-parse","--abbrev-ref",`${e}@{upstream}`],n),s=await this.run(["rev-list","--left-right","--count",`${i}...${e}`],n),[c,u]=s.split(/\s+/).map(Number);return vn(o,{ahead:u??0,behind:c??0})}catch{return vn(o,{ahead:0,behind:0})}}static async getLastCommit(e){let t=e??Bun.cwd,n=`last-commit:${t}`,o=Sr(n);if(o!==void 0)return o;try{let r=await this.run(["log","-1","--format=%h\x1F%s\x1F%cr"],t);if(!r)return vn(n,null);let[i,s,c]=r.split("\x1F");return vn(n,{hash:i??"",message:s??"",relativeDate:c??""})}catch{return vn(n,null)}}static async getDirtyCount(e){let t=e??Bun.cwd,n=`dirty-count:${t}`,o=Sr(n);if(o!==void 0)return o;try{let r=await this.run(["status","--porcelain"],t);if(!r)return vn(n,0);return vn(n,r.split(`
|
|
5
|
+
`).filter(Boolean).length)}catch{return vn(n,0)}}static async unlock(e,t){await this.checkVersion(),await this.run(["worktree","unlock",e],t),$t()}static async isMergedInto(e,t,n){try{return(await this.run(["branch","--merged",t],n??Bun.cwd)).split(`
|
|
6
|
+
`).some((r)=>r.trim().replace(/^[*+] /,"")===e)}catch{return!1}}static async getDefaultRemote(e){try{return await this.run(["config","checkout.defaultRemote"],e??Bun.cwd)||"origin"}catch{return"origin"}}static async remoteBranchExists(e,t,n){let o=t??await this.getDefaultRemote(n);try{return await this.run(["rev-parse","--verify",`refs/remotes/${o}/${e}`],n??Bun.cwd),!0}catch{return!1}}static async listBranches(e){let t=e??Bun.cwd,n=`branches:${t}`,o=Sr(n);if(o)return o;let[r,i]=await Promise.all([this.run(["for-each-ref","--sort=-committerdate","--format=%(refname:short)\x1F%(committerdate:relative)","refs/heads/"],t).catch(()=>""),this.run(["for-each-ref","--sort=-committerdate","--format=%(refname:short)\x1F%(committerdate:relative)","refs/remotes/"],t).catch(()=>"")]),s=[];for(let c of r.split(`
|
|
7
|
+
`).filter(Boolean)){let[u,f]=c.split("\x1F");s.push({name:u??"",isRemote:!1,lastCommitDate:f??""})}for(let c of i.split(`
|
|
8
|
+
`).filter(Boolean)){let[u,f]=c.split("\x1F");if(!u||u.endsWith("/HEAD"))continue;let m=u.replace(/^[^/]+\//,"");if(s.some((l)=>l.name===m))continue;s.push({name:m,isRemote:!0,lastCommitDate:f??""})}return vn(n,s)}static async diffBetween(e,t,n,o){let r=["diff"];if(n?.stat)r.push("--stat");if(n?.nameOnly)r.push("--name-only");return r.push(e,t),this.run(r,o)}static async getWorktreeLastActivity(e){try{let t=await this.run(["log","-1","--format=%ci"],e);return t?new Date(t):null}catch{return null}}static async setUpstream(e,t,n){let o=t??await this.getDefaultRemote(n),r=n??Bun.cwd;try{if(await this.run(["config",`branch.${e}.remote`],r))return}catch{}await this.run(["branch",`--set-upstream-to=${o}/${e}`,e],r)}}var zd=3000,ci;var ke=$e(()=>{fn();ci=new Map});import{createComponent as Ud}from"@opentui/solid";function Oa(e){let[t,{refetch:n}]=fa(async()=>{try{if(e.repoPaths.length<=1)return await ee.list(e.repoPaths[0]);return await ee.listAll(e.repoPaths)}catch(s){throw s}}),o=()=>{$t(),n()},r=Ot(()=>{let s=t()??[],c=new Set,u=[];for(let f of s)if(!c.has(f.repoName))c.add(f.repoName),u.push(f.repoName);return u}),i=Ot(()=>r().length>1);return Ud(Ra.Provider,{value:{worktrees:()=>t(),refetch:o,loading:()=>t.loading,error:()=>t.error,repoNames:r,isMultiRepo:i},get children(){return e.children}})}function Pt(){let e=Qn(Ra);if(!e)throw Error("useGit must be used within GitProvider");return e}var Ra;var yn=$e(()=>{ht();ke();Ra=No()});var Jd,ai,Wa,Vd,li,h;var Lt=$e(()=>{ht();Jd={opencode:{bg:{base:"#090909",surface:"#111111",elevated:"#1a1a1a",overlay:"#000000"},border:{default:"#2a2a2a",active:"#4fc3f7",subtle:"#1e1e1e"},text:{primary:"#e8e8e8",secondary:"#666666",accent:"#4fc3f7",success:"#4ade80",warning:"#fbbf24",error:"#f87171",selected:"#ffffff"},tab:{active:"#4fc3f7",activeBg:"#1a1a1a",inactive:"#555555",inactiveBg:"#000000"},select:{focusedBg:"#1a2a3a",focusedFg:"#4fc3f7",selectedBg:"#161616",selectedFg:"#e8e8e8",normalFg:"#e8e8e8",descFg:"#666666"}},"tokyo-night":{bg:{base:"#1a1b26",surface:"#1f2335",elevated:"#24283b",overlay:"#0d1117"},border:{default:"#3b4261",active:"#7aa2f7",subtle:"#292e42"},text:{primary:"#c0caf5",secondary:"#565f89",accent:"#7aa2f7",success:"#9ece6a",warning:"#e0af68",error:"#f7768e",selected:"#ffffff"},tab:{active:"#7aa2f7",activeBg:"#24283b",inactive:"#565f89",inactiveBg:"#1a1b26"},select:{focusedBg:"#283457",focusedFg:"#7aa2f7",selectedBg:"#2a2f44",selectedFg:"#c0caf5",normalFg:"#c0caf5",descFg:"#565f89"}},dracula:{bg:{base:"#282a36",surface:"#21222c",elevated:"#343746",overlay:"#191a21"},border:{default:"#6272a4",active:"#bd93f9",subtle:"#44475a"},text:{primary:"#f8f8f2",secondary:"#6272a4",accent:"#bd93f9",success:"#50fa7b",warning:"#ffb86c",error:"#ff5555",selected:"#ffffff"},tab:{active:"#bd93f9",activeBg:"#343746",inactive:"#6272a4",inactiveBg:"#282a36"},select:{focusedBg:"#44475a",focusedFg:"#bd93f9",selectedBg:"#383a4a",selectedFg:"#f8f8f2",normalFg:"#f8f8f2",descFg:"#6272a4"}},nord:{bg:{base:"#2e3440",surface:"#3b4252",elevated:"#434c5e",overlay:"#242933"},border:{default:"#4c566a",active:"#81a1c1",subtle:"#3b4252"},text:{primary:"#eceff4",secondary:"#4c566a",accent:"#81a1c1",success:"#a3be8c",warning:"#ebcb8b",error:"#bf616a",selected:"#ffffff"},tab:{active:"#88c0d0",activeBg:"#434c5e",inactive:"#4c566a",inactiveBg:"#2e3440"},select:{focusedBg:"#3b4252",focusedFg:"#88c0d0",selectedBg:"#3b4252",selectedFg:"#eceff4",normalFg:"#eceff4",descFg:"#4c566a"}},catppuccin:{bg:{base:"#1e1e2e",surface:"#181825",elevated:"#313244",overlay:"#11111b"},border:{default:"#45475a",active:"#cba6f7",subtle:"#313244"},text:{primary:"#cdd6f4",secondary:"#585b70",accent:"#cba6f7",success:"#a6e3a1",warning:"#fab387",error:"#f38ba8",selected:"#ffffff"},tab:{active:"#cba6f7",activeBg:"#313244",inactive:"#585b70",inactiveBg:"#1e1e2e"},select:{focusedBg:"#313244",focusedFg:"#cba6f7",selectedBg:"#313244",selectedFg:"#cdd6f4",normalFg:"#cdd6f4",descFg:"#585b70"}},"github-dark":{bg:{base:"#0d1117",surface:"#161b22",elevated:"#21262d",overlay:"#010409"},border:{default:"#30363d",active:"#58a6ff",subtle:"#21262d"},text:{primary:"#e6edf3",secondary:"#484f58",accent:"#58a6ff",success:"#3fb950",warning:"#d29922",error:"#f85149",selected:"#ffffff"},tab:{active:"#58a6ff",activeBg:"#21262d",inactive:"#484f58",inactiveBg:"#0d1117"},select:{focusedBg:"#1f2937",focusedFg:"#58a6ff",selectedBg:"#1f2937",selectedFg:"#e6edf3",normalFg:"#e6edf3",descFg:"#484f58"}},"one-dark":{bg:{base:"#282c34",surface:"#21252b",elevated:"#2c313a",overlay:"#1b1f27"},border:{default:"#3e4451",active:"#61afef",subtle:"#2c313a"},text:{primary:"#abb2bf",secondary:"#5c6370",accent:"#61afef",success:"#98c379",warning:"#e5c07b",error:"#e06c75",selected:"#ffffff"},tab:{active:"#61afef",activeBg:"#2c313a",inactive:"#5c6370",inactiveBg:"#282c34"},select:{focusedBg:"#2c313a",focusedFg:"#61afef",selectedBg:"#2c313a",selectedFg:"#abb2bf",normalFg:"#abb2bf",descFg:"#5c6370"}},monokai:{bg:{base:"#272822",surface:"#1e1f1c",elevated:"#3e3d32",overlay:"#1a1b18"},border:{default:"#49483e",active:"#a6e22e",subtle:"#3e3d32"},text:{primary:"#f8f8f2",secondary:"#75715e",accent:"#66d9ef",success:"#a6e22e",warning:"#e6db74",error:"#f92672",selected:"#ffffff"},tab:{active:"#a6e22e",activeBg:"#3e3d32",inactive:"#75715e",inactiveBg:"#272822"},select:{focusedBg:"#3e3d32",focusedFg:"#66d9ef",selectedBg:"#3e3d32",selectedFg:"#f8f8f2",normalFg:"#f8f8f2",descFg:"#75715e"}},"github-light":{bg:{base:"#ffffff",surface:"#f6f8fa",elevated:"#eaeef2",overlay:"#d0d7de"},border:{default:"#d0d7de",active:"#0969da",subtle:"#eaeef2"},text:{primary:"#1f2328",secondary:"#656d76",accent:"#0969da",success:"#1a7f37",warning:"#9a6700",error:"#cf222e",selected:"#000000"},tab:{active:"#0969da",activeBg:"#eaeef2",inactive:"#656d76",inactiveBg:"#ffffff"},select:{focusedBg:"#ddf4ff",focusedFg:"#0969da",selectedBg:"#eaeef2",selectedFg:"#1f2328",normalFg:"#1f2328",descFg:"#656d76"}}},ai=["opencode","tokyo-night","dracula","nord","catppuccin","github-dark","one-dark","monokai","github-light"],Wa={opencode:"OpenCode","tokyo-night":"Tokyo Night",dracula:"Dracula",nord:"Nord",catppuccin:"Catppuccin Mocha","github-dark":"GitHub Dark","one-dark":"One Dark",monokai:"Monokai","github-light":"GitHub Light"},[Vd,li]=be("opencode"),h=new Proxy({},{get(e,t){return new Proxy({},{get(n,o){return Jd[Vd()][t]?.[o]}})}})});import{readFileSync as Kd,statSync as qd}from"fs";import{join as Da,resolve as Xd}from"path";function Er(e){let t=Da(e,".git"),n=qd(t,{throwIfNoEntry:!1});if(!n||n.isDirectory())return t;let r=Kd(t,"utf-8").trim().replace(/^gitdir:\s*/,"").trim();return Xd(e,r)}function Cn(e,t){return Da(Er(e),t)}var Yn=()=>{};import{existsSync as Zd,mkdirSync as Qd,readFileSync as Yd,writeFileSync as _d}from"fs";import{dirname as eh}from"path";function Fa(e){return Cn(e,"omw-focus")}function ko(e,t){let n=Fa(e);Qd(eh(n),{recursive:!0}),_d(n,t.join(`
|
|
9
|
+
`),{encoding:"utf-8",mode:384})}function dn(e){let t=Fa(e);if(!Zd(t))return null;return Yd(t,"utf-8").split(/\r?\n/).filter(Boolean)}var Rn=$e(()=>{Yn()});import{existsSync as ds,mkdirSync as th,readFileSync as nh,writeFileSync as oh,unlinkSync as rh}from"fs";import{dirname as ih}from"path";function us(e){return e.replace(/\//g,"-").replace(/[^a-zA-Z0-9._-]/g,"_")}async function On(e){let t=Bun.spawn(["tmux",...e],{stdout:"pipe",stderr:"pipe",env:{...Bun.env,LC_ALL:"C"}}),[n,o,r]=await Promise.all([new Response(t.stdout).text(),new Response(t.stderr).text(),t.exited]);if(r!==0)throw new Ho(`tmux ${e[0]} failed: ${o.trim()}`,o.trim());return n.trim()}function _n(e,t){let n=us(t??Ia),o=us(e);return`${n}_${o}`}function hs(e){return Cn(e,"omw-session")}function sh(e,t){let n=hs(e);th(ih(n),{recursive:!0}),oh(n,JSON.stringify(t),{encoding:"utf-8",mode:384})}function tn(e){let t=hs(e);if(!ds(t))return null;try{return JSON.parse(nh(t,"utf-8"))}catch{return null}}function ms(e){let t=hs(e);if(ds(t))rh(t)}async function zo(){try{return await Bun.spawn(["tmux","-V"],{stdout:"pipe",stderr:"pipe"}).exited===0}catch{return!1}}function ps(){return Boolean(Bun.env.TMUX)}async function Wn(e){try{return await On(["has-session","-t",e]),!0}catch{return!1}}async function ch(e,t,n){if(await Wn(e))throw new Ho(`Session '${e}' already exists`,"session_exists");if(!ds(t))throw new Ho(`Worktree path does not exist: ${t}`,"path_not_found");let o=n?.windows??[],r=o[0],i=["new-session","-d","-s",e,"-c",t];if(r)i.push("-n",r.name);if(await On(i),r?.command)await On(["send-keys","-t",`${e}:${r.name}`,r.command,"Enter"]);for(let s=1;s<o.length;s++){let c=o[s];if(await On(["new-window","-t",e,"-n",c.name,"-c",t]),c.command)await On(["send-keys","-t",`${e}:${c.name}`,c.command,"Enter"])}if(o.length>0)await On(["select-window","-t",`${e}:${o[0].name}`])}async function gs(e){if(!await Wn(e))return;await On(["kill-session","-t",e])}async function fi(e){if(!await Wn(e))throw new Ho(`Session '${e}' does not exist`,"session_not_found");if(ps())await On(["switch-client","-t",e]);else if(await Bun.spawn(["tmux","attach-session","-t",e],{stdin:"inherit",stdout:"inherit",stderr:"inherit"}).exited!==0)throw new Ho(`Failed to attach to session '${e}'`,"attach_failed")}async function ws(e){let t=us(e??Ia);try{let n=await On(["list-sessions","-F","#{session_name}|#{session_windows}|#{session_attached}|#{session_created}"]);if(!n)return[];return n.split(`
|
|
10
|
+
`).filter(Boolean).filter((o)=>o.startsWith(`${t}_`)||o.startsWith(`${t}:`)).map((o)=>{let[r,i,s,c]=o.split("|");return{name:r??"",windows:parseInt(i??"0",10),attached:s==="1",created:c??""}})}catch{return[]}}async function ui(e,t,n){let o=_n(e,n?.prefix),r=n?.attach??!0;if(await Wn(o)){if(r)await fi(o);return o}if(await ch(o,t,n?.layout),sh(t,{name:o,branch:e,worktreePath:t,createdAt:new Date().toISOString(),layout:n?.layoutName}),r)await fi(o);return o}async function di(e,t,n){let o=_n(e,n),r=await Wn(o);if(r)await gs(o);return ms(t),r}var Ho,Ia="omw";var eo=$e(()=>{Yn();Ho=class Ho extends Error{reason;constructor(e,t){super(e);this.reason=t;this.name="SessionError"}}});import{createComponent as ah}from"@opentui/solid";function La(e){let[t,n]=be([]),o=(i)=>{n((s)=>s.filter((c)=>c.id!==i))},r=(i)=>{let s=`${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`,c=i.duration??3000;n((u)=>[...u,{...i,id:s}].slice(-5)),setTimeout(()=>{o(s)},c)};return ah(Ba.Provider,{value:{toasts:t,addToast:r,removeToast:o},get children(){return e.children}})}function Uo(){let e=Qn(Ba);if(!e)throw Error("useToast must be used within ToastProvider");return e}var Ba;var Mr=$e(()=>{ht();Ba=No()});import{effect as Aa}from"@opentui/solid";import{insertNode as lh}from"@opentui/solid";import{memo as fh}from"@opentui/solid";import{insert as xs}from"@opentui/solid";import{setProp as hi}from"@opentui/solid";import{createElement as bs}from"@opentui/solid";function Jo(e){let[t,n]=be(0),o=setInterval(()=>{n((r)=>(r+1)%Ta.length)},80);return en(()=>clearInterval(o)),(()=>{var r=bs("box"),i=bs("text");return lh(r,i),hi(r,"flexDirection","row"),hi(r,"gap",1),xs(i,()=>Ta[t()]),xs(r,(()=>{var s=fh(()=>!!e.label);return()=>s()&&(()=>{var c=bs("text");return xs(c,()=>e.label),Aa((u)=>hi(c,"fg",h.text.secondary,u)),c})()})(),null),Aa((s)=>hi(i,"fg",e.color??h.text.accent,s)),r})()}var Ta;var mi=$e(()=>{ht();Lt();Ta=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]});import{effect as qe}from"@opentui/solid";import{createComponent as St}from"@opentui/solid";import{memo as vs}from"@opentui/solid";import{insert as Xe}from"@opentui/solid";import{createTextNode as rt}from"@opentui/solid";import{insertNode as ie}from"@opentui/solid";import{setProp as $}from"@opentui/solid";import{createElement as Y}from"@opentui/solid";import{useTerminalDimensions as uh,useRenderer as dh,useSelectionHandler as hh}from"@opentui/solid";function ja(e){let t=Pt(),n=Uo(),o=dh(),r=uh(),i=()=>r().width,s=()=>r().height,[c,u]=be(null),[f,m]=be(!0),[l,p]=be("");hh((E)=>{let I=E.getSelectedText();if(!I)return;o.copyToClipboardOSC52(I),n.addToast({type:"info",message:"Copied to clipboard"})});let R;en(()=>{if(R)clearTimeout(R)});let M=()=>{return(t.worktrees()??[]).find((V)=>V.isMain)?.branch??"main"};ln(Zn(()=>e.worktree.path,(E)=>{if(R)clearTimeout(R);if(!E){u(null),p(""),m(!1);return}u(null),p(""),m(!0),R=setTimeout(async()=>{if(e.worktree.path!==E)return;try{let[I,[V,T],H]=await Promise.all([ph(E),e.worktree.branch&&!e.worktree.isMain?Promise.all([ee.diffBetween(M(),e.worktree.branch,{stat:!0},E).catch(()=>""),ee.diffBetween(M(),e.worktree.branch,void 0,E).catch(()=>"")]):Promise.resolve(["",""]),e.worktree.branch?ee.getAheadBehind(e.worktree.branch,E):Promise.resolve({ahead:0,behind:0})]);if(e.worktree.path!==E)return;let Q=null;try{Q=dn(E)}catch{}let he=null,G=tn(E);if(G){let F=await Wn(G.name).catch(()=>!1);he={meta:G,active:F}}if(e.worktree.path!==E)return;u({commits:I,diffStat:V,fullDiff:T,aheadBehind:H,focus:Q,session:he}),p("")}catch(I){if(e.worktree.path!==E)return;u(null),p(I.message)}finally{if(e.worktree.path===E)m(!1)}},mh)}));let d=()=>{let E=e.worktree;if(E.isLocked)return"\uD83D\uDD12 locked";if(E.isDirty)return"\u25CF dirty";return"\u2713 clean"},b=()=>{let E=e.worktree;if(E.isLocked)return h.text.warning;if(E.isDirty)return h.text.error;return h.text.success},y=()=>{let E=c();if(!E)return"";let I=[];if(E.aheadBehind.ahead>0)I.push(`\u2191${E.aheadBehind.ahead}`);if(E.aheadBehind.behind>0)I.push(`\u2193${E.aheadBehind.behind}`);return I.length>0?I.join(" "):"\u2713 up to date"},S=()=>{let E=c();if(!E)return h.text.secondary;return E.aheadBehind.ahead||E.aheadBehind.behind?h.text.warning:h.text.success},P=()=>"\u2500".repeat(Math.max(i()-7,10));return(()=>{var E=Y("box"),I=Y("scrollbox"),V=Y("box"),T=Y("text"),H=Y("text"),Q=Y("box"),he=Y("text"),G=Y("box"),F=Y("box"),N=Y("box"),K=Y("text"),k=Y("text"),ge=Y("box"),re=Y("box"),me=Y("text"),x=Y("text"),v=Y("box"),A=Y("box"),B=Y("text"),D=Y("text"),z=Y("box"),se=Y("box"),J=Y("text"),_=Y("text"),Me=Y("box"),fe=Y("box"),pe=Y("text"),De=Y("box"),Ce=Y("text");return ie(E,I),$(E,"x",0),$(E,"y",0),ie(I,V),ie(I,Q),ie(I,G),ie(I,F),ie(I,ge),ie(I,v),ie(I,z),ie(I,Me),ie(I,fe),ie(I,De),$(I,"x",2),$(I,"y",1),ie(V,T),ie(V,H),$(V,"height",1),ie(T,rt("Worktree Detail")),$(T,"x",0),$(T,"y",0),$(T,"bold",!0),$(T,"selectable",!0),ie(H,rt("(Esc to close)")),$(H,"x",17),$(H,"y",0),$(H,"selectable",!0),ie(Q,he),$(Q,"height",1),$(he,"x",0),$(he,"y",0),$(he,"selectable",!0),Xe(he,P),$(G,"height",1),ie(F,N),ie(F,k),$(F,"height",1),$(F,"flexDirection","row"),ie(N,K),$(N,"width",16),$(N,"height",1),ie(K,rt("Branch")),$(K,"x",0),$(K,"y",0),$(K,"selectable",!0),$(k,"selectable",!0),Xe(k,()=>e.worktree.branch??"(detached)"),ie(ge,re),ie(ge,x),$(ge,"height",1),$(ge,"flexDirection","row"),ie(re,me),$(re,"width",16),$(re,"height",1),ie(me,rt("Path")),$(me,"x",0),$(me,"y",0),$(me,"selectable",!0),$(x,"selectable",!0),Xe(x,()=>e.worktree.path),ie(v,A),ie(v,D),$(v,"height",1),$(v,"flexDirection","row"),ie(A,B),$(A,"width",16),$(A,"height",1),ie(B,rt("Status")),$(B,"x",0),$(B,"y",0),$(B,"selectable",!0),$(D,"selectable",!0),Xe(D,d),ie(z,se),ie(z,_),$(z,"height",1),$(z,"flexDirection","row"),ie(se,J),$(se,"width",16),$(se,"height",1),ie(J,rt("HEAD")),$(J,"x",0),$(J,"y",0),$(J,"selectable",!0),$(_,"selectable",!0),Xe(_,()=>e.worktree.head?.slice(0,8)),Xe(I,St(te,{get when(){return f()},get children(){return[(()=>{var O=Y("box");return $(O,"height",1),O})(),(()=>{var O=Y("box");return $(O,"height",1),Xe(O,St(Jo,{label:"Loading details..."})),O})()]}}),Me),Xe(I,St(te,{get when(){return vs(()=>!f())()&&!!l()},get children(){return[(()=>{var O=Y("box");return $(O,"height",1),O})(),(()=>{var O=Y("box"),a=Y("text");return ie(O,a),$(O,"height",1),$(a,"x",0),$(a,"y",0),$(a,"selectable",!0),Xe(a,()=>`Failed to load details: ${l()}`),qe((w)=>$(a,"fg",h.text.error,w)),O})()]}}),Me),Xe(I,St(te,{get when(){return vs(()=>!f()&&!l())()&&!!c()},get children(){return[(()=>{var O=Y("box");return $(O,"height",1),O})(),(()=>{var O=Y("box"),a=Y("text");return ie(O,a),$(O,"height",1),ie(a,rt("Upstream")),$(a,"x",0),$(a,"y",0),$(a,"bold",!0),$(a,"selectable",!0),qe((w)=>$(a,"fg",h.text.accent,w)),O})(),(()=>{var O=Y("box"),a=Y("text");return ie(O,a),$(O,"height",1),$(a,"x",0),$(a,"y",0),$(a,"selectable",!0),Xe(a,P),qe((w)=>$(a,"fg",h.border.subtle,w)),O})(),(()=>{var O=Y("box"),a=Y("box"),w=Y("text"),L=Y("text");return ie(O,a),ie(O,L),$(O,"height",1),$(O,"flexDirection","row"),ie(a,w),$(a,"width",16),$(a,"height",1),ie(w,rt("Sync")),$(w,"x",0),$(w,"y",0),$(w,"selectable",!0),$(L,"selectable",!0),Xe(L,y),qe((W)=>{var C=h.text.secondary,q=S();return C!==W.e&&(W.e=$(w,"fg",C,W.e)),q!==W.t&&(W.t=$(L,"fg",q,W.t)),W},{e:void 0,t:void 0}),O})(),St(te,{get when(){return c().aheadBehind.ahead>0},get children(){var O=Y("box"),a=Y("box"),w=Y("text"),L=Y("text");return ie(O,a),ie(O,L),$(O,"height",1),$(O,"flexDirection","row"),ie(a,w),$(a,"width",16),$(a,"height",1),ie(w,rt("Ahead")),$(w,"x",0),$(w,"y",0),$(w,"selectable",!0),$(L,"selectable",!0),Xe(L,()=>`${c().aheadBehind.ahead} commit(s)`),qe((W)=>{var C=h.text.secondary,q=h.text.warning;return C!==W.e&&(W.e=$(w,"fg",C,W.e)),q!==W.t&&(W.t=$(L,"fg",q,W.t)),W},{e:void 0,t:void 0}),O}}),St(te,{get when(){return c().aheadBehind.behind>0},get children(){var O=Y("box"),a=Y("box"),w=Y("text"),L=Y("text");return ie(O,a),ie(O,L),$(O,"height",1),$(O,"flexDirection","row"),ie(a,w),$(a,"width",16),$(a,"height",1),ie(w,rt("Behind")),$(w,"x",0),$(w,"y",0),$(w,"selectable",!0),$(L,"selectable",!0),Xe(L,()=>`${c().aheadBehind.behind} commit(s)`),qe((W)=>{var C=h.text.secondary,q=h.text.warning;return C!==W.e&&(W.e=$(w,"fg",C,W.e)),q!==W.t&&(W.t=$(L,"fg",q,W.t)),W},{e:void 0,t:void 0}),O}}),(()=>{var O=Y("box");return $(O,"height",1),O})(),(()=>{var O=Y("box"),a=Y("text");return ie(O,a),$(O,"height",1),ie(a,rt("Recent Commits")),$(a,"x",0),$(a,"y",0),$(a,"bold",!0),$(a,"selectable",!0),qe((w)=>$(a,"fg",h.text.accent,w)),O})(),(()=>{var O=Y("box"),a=Y("text");return ie(O,a),$(O,"height",1),$(a,"x",0),$(a,"y",0),$(a,"selectable",!0),Xe(a,P),qe((w)=>$(a,"fg",h.border.subtle,w)),O})(),St(te,{get when(){return c().commits.length>0},get fallback(){return(()=>{var O=Y("box"),a=Y("text");return ie(O,a),$(O,"height",1),ie(a,rt("No commits found")),$(a,"x",0),$(a,"y",0),$(a,"selectable",!0),qe((w)=>$(a,"fg",h.text.secondary,w)),O})()},get children(){return St(ft,{get each(){return c().commits},children:(O)=>(()=>{var a=Y("box"),w=Y("text");return ie(a,w),$(a,"height",1),$(w,"x",0),$(w,"y",0),$(w,"selectable",!0),Xe(w,O),qe((L)=>$(w,"fg",h.text.primary,L)),a})()})}}),St(te,{get when(){return!e.worktree.isMain},get children(){return[(()=>{var O=Y("box");return $(O,"height",1),O})(),(()=>{var O=Y("box"),a=Y("text");return ie(O,a),$(O,"height",1),$(a,"x",0),$(a,"y",0),$(a,"bold",!0),$(a,"selectable",!0),Xe(a,()=>`Diff vs ${M()}`),qe((w)=>$(a,"fg",h.text.accent,w)),O})(),(()=>{var O=Y("box"),a=Y("text");return ie(O,a),$(O,"height",1),$(a,"x",0),$(a,"y",0),$(a,"selectable",!0),Xe(a,P),qe((w)=>$(a,"fg",h.border.subtle,w)),O})(),St(te,{get when(){return c().diffStat.length>0},get children(){var O=Y("code");return $(O,"language","diff"),qe((a)=>$(O,"code",c().diffStat,a)),O}}),(()=>{var O=Y("box");return $(O,"height",1),O})(),St(te,{get when(){return c().fullDiff.length>0},get fallback(){return(()=>{var O=Y("box"),a=Y("text");return ie(O,a),$(O,"height",1),ie(a,rt("No changes")),$(a,"x",0),$(a,"y",0),$(a,"selectable",!0),qe((w)=>$(a,"fg",h.text.secondary,w)),O})()},get children(){var O=Y("scrollbox"),a=Y("diff");return ie(O,a),$(O,"height",15),$(a,"view","unified"),qe((w)=>{var L=i()-3,W=c().fullDiff;return L!==w.e&&(w.e=$(O,"width",L,w.e)),W!==w.t&&(w.t=$(a,"diff",W,w.t)),w},{e:void 0,t:void 0}),O}})]}}),St(te,{get when(){return vs(()=>!!c().focus)()&&c().focus.length>0},get children(){return[(()=>{var O=Y("box");return $(O,"height",1),O})(),(()=>{var O=Y("box"),a=Y("text");return ie(O,a),$(O,"height",1),ie(a,rt("Focus Paths")),$(a,"x",0),$(a,"y",0),$(a,"bold",!0),$(a,"selectable",!0),qe((w)=>$(a,"fg",h.text.accent,w)),O})(),(()=>{var O=Y("box"),a=Y("text");return ie(O,a),$(O,"height",1),$(a,"x",0),$(a,"y",0),$(a,"selectable",!0),Xe(a,P),qe((w)=>$(a,"fg",h.border.subtle,w)),O})(),St(ft,{get each(){return c().focus},children:(O)=>(()=>{var a=Y("box"),w=Y("text");return ie(a,w),$(a,"height",1),$(w,"x",0),$(w,"y",0),$(w,"selectable",!0),Xe(w,` \u2022 ${O}`),qe((L)=>$(w,"fg",h.text.primary,L)),a})()})]}}),St(te,{get when(){return c().session},get children(){return[(()=>{var O=Y("box");return $(O,"height",1),O})(),(()=>{var O=Y("box"),a=Y("text");return ie(O,a),$(O,"height",1),ie(a,rt("Session")),$(a,"x",0),$(a,"y",0),$(a,"bold",!0),$(a,"selectable",!0),qe((w)=>$(a,"fg",h.text.accent,w)),O})(),(()=>{var O=Y("box"),a=Y("text");return ie(O,a),$(O,"height",1),$(a,"x",0),$(a,"y",0),$(a,"selectable",!0),Xe(a,P),qe((w)=>$(a,"fg",h.border.subtle,w)),O})(),(()=>{var O=Y("box"),a=Y("box"),w=Y("text"),L=Y("text");return ie(O,a),ie(O,L),$(O,"height",1),$(O,"flexDirection","row"),ie(a,w),$(a,"width",16),$(a,"height",1),ie(w,rt("Name")),$(w,"x",0),$(w,"y",0),$(w,"selectable",!0),$(L,"selectable",!0),Xe(L,()=>c().session.meta.name),qe((W)=>{var C=h.text.secondary,q=h.text.primary;return C!==W.e&&(W.e=$(w,"fg",C,W.e)),q!==W.t&&(W.t=$(L,"fg",q,W.t)),W},{e:void 0,t:void 0}),O})(),(()=>{var O=Y("box"),a=Y("box"),w=Y("text"),L=Y("text");return ie(O,a),ie(O,L),$(O,"height",1),$(O,"flexDirection","row"),ie(a,w),$(a,"width",16),$(a,"height",1),ie(w,rt("Status")),$(w,"x",0),$(w,"y",0),$(w,"selectable",!0),$(L,"selectable",!0),Xe(L,()=>c().session.active?"\u25CF active":"\u25CB inactive"),qe((W)=>{var C=h.text.secondary,q=c().session.active?h.text.success:h.text.error;return C!==W.e&&(W.e=$(w,"fg",C,W.e)),q!==W.t&&(W.t=$(L,"fg",q,W.t)),W},{e:void 0,t:void 0}),O})(),St(te,{get when(){return c().session.meta.layout},get children(){var O=Y("box"),a=Y("box"),w=Y("text"),L=Y("text");return ie(O,a),ie(O,L),$(O,"height",1),$(O,"flexDirection","row"),ie(a,w),$(a,"width",16),$(a,"height",1),ie(w,rt("Layout")),$(w,"x",0),$(w,"y",0),$(w,"selectable",!0),$(L,"selectable",!0),Xe(L,()=>c().session.meta.layout),qe((W)=>{var C=h.text.secondary,q=h.text.primary;return C!==W.e&&(W.e=$(w,"fg",C,W.e)),q!==W.t&&(W.t=$(L,"fg",q,W.t)),W},{e:void 0,t:void 0}),O}})]}}),St(te,{get when(){return e.worktree.isMain},get children(){return[(()=>{var O=Y("box");return $(O,"height",1),O})(),(()=>{var O=Y("box"),a=Y("box"),w=Y("text"),L=Y("text");return ie(O,a),ie(O,L),$(O,"height",1),$(O,"flexDirection","row"),ie(a,w),$(a,"width",16),$(a,"height",1),ie(w,rt("Type")),$(w,"x",0),$(w,"y",0),$(w,"selectable",!0),ie(L,rt("main worktree")),$(L,"selectable",!0),qe((W)=>{var C=h.text.secondary,q=h.text.accent;return C!==W.e&&(W.e=$(w,"fg",C,W.e)),q!==W.t&&(W.t=$(L,"fg",q,W.t)),W},{e:void 0,t:void 0}),O})()]}})]}}),Me),$(Me,"height",1),ie(fe,pe),$(fe,"height",1),$(pe,"x",0),$(pe,"y",0),$(pe,"selectable",!0),Xe(pe,P),ie(De,Ce),$(De,"height",1),ie(Ce,rt("Esc:back d:delete o:open r:refresh")),$(Ce,"x",0),$(Ce,"y",0),$(Ce,"selectable",!0),qe((O)=>{var a=i(),w=s(),L=h.bg.base,W=i()-3,C=s()-3,q=h.text.accent,X=h.text.secondary,U=h.border.subtle,Ne=h.text.secondary,Ue=h.text.accent,sn=h.text.secondary,cn=h.text.primary,Tn=h.text.secondary,jn=b(),Nn=h.text.secondary,Gn=h.text.secondary,kn=h.border.subtle,Hn=h.text.secondary;return a!==O.e&&(O.e=$(E,"width",a,O.e)),w!==O.t&&(O.t=$(E,"height",w,O.t)),L!==O.a&&(O.a=$(E,"backgroundColor",L,O.a)),W!==O.o&&(O.o=$(I,"width",W,O.o)),C!==O.i&&(O.i=$(I,"height",C,O.i)),q!==O.n&&(O.n=$(T,"fg",q,O.n)),X!==O.s&&(O.s=$(H,"fg",X,O.s)),U!==O.h&&(O.h=$(he,"fg",U,O.h)),Ne!==O.r&&(O.r=$(K,"fg",Ne,O.r)),Ue!==O.d&&(O.d=$(k,"fg",Ue,O.d)),sn!==O.l&&(O.l=$(me,"fg",sn,O.l)),cn!==O.u&&(O.u=$(x,"fg",cn,O.u)),Tn!==O.c&&(O.c=$(B,"fg",Tn,O.c)),jn!==O.w&&(O.w=$(D,"fg",jn,O.w)),Nn!==O.m&&(O.m=$(J,"fg",Nn,O.m)),Gn!==O.f&&(O.f=$(_,"fg",Gn,O.f)),kn!==O.y&&(O.y=$(pe,"fg",kn,O.y)),Hn!==O.g&&(O.g=$(Ce,"fg",Hn,O.g)),O},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0,c:void 0,w:void 0,m:void 0,f:void 0,y:void 0,g:void 0}),E})()}async function ph(e){try{let t=Bun.spawn(["git","log","--oneline","-10"],{cwd:e,stdout:"pipe",stderr:"pipe",env:{...process.env,LC_ALL:"C"}}),n=await new Response(t.stdout).text();if(await t.exited,t.exitCode!==0)return[];return n.trim().split(`
|
|
11
|
+
`).filter(Boolean)}catch{return[]}}var mh=150;var Na=$e(()=>{ht();yn();Mr();Lt();Rn();eo();ke();mi()});import{effect as hn}from"@opentui/solid";import{insert as lt}from"@opentui/solid";import{createTextNode as et}from"@opentui/solid";import{insertNode as de}from"@opentui/solid";import{createComponent as Jt}from"@opentui/solid";import{memo as yr}from"@opentui/solid";import{setProp as Z}from"@opentui/solid";import{createElement as ve}from"@opentui/solid";import{useKeyboard as gh,useTerminalDimensions as wh}from"@opentui/solid";function Ga(){let e=mt(),t=Pt(),n=wh(),o=()=>{let d=t.worktrees()??[],b=e.selectedWorktreePath();if(b){let y=d.find((S)=>S.path===b);if(y)return y}return d[e.selectedWorktreeIndex()]},r=()=>n().width,i=14,[s,c]=be(null),[u,f]=be(!1),[m,l]=be(""),p;en(()=>{if(p)clearTimeout(p)}),ln(Zn(()=>o()?.path,(d)=>{if(p)clearTimeout(p);if(!d){c(null),f(!1),l("");return}c(null),f(!0),l(""),p=setTimeout(async()=>{let b=o();if(!b||b.path!==d)return;try{let[y,S,P]=await Promise.all([b.branch?ee.getAheadBehind(b.branch,b.path):Promise.resolve({ahead:0,behind:0}),ee.getLastCommit(b.path),ee.getDirtyCount(b.path)]);if(o()?.path===d)c({aheadBehind:y,lastCommit:S,dirtyCount:P}),l("")}catch(y){if(o()?.path===d)c(null),l(y.message)}finally{if(o()?.path===d)f(!1)}},xh)}));let R=()=>{if(u())return"Loading...";if(m())return"Unavailable";let d=s();if(!d)return"";let b=[];if(d.aheadBehind.ahead>0)b.push(`\u2191${d.aheadBehind.ahead}`);if(d.aheadBehind.behind>0)b.push(`\u2193${d.aheadBehind.behind}`);return b.length>0?b.join(" "):"\u2713 up to date"},M=()=>{let d=o();if(!d)return"";if(d.isLocked)return"\uD83D\uDD12 locked";let b=s();if(b&&b.dirtyCount>0)return`\u25CF ${b.dirtyCount} file(s) dirty`;if(d.isDirty)return"\u25CF dirty";return"\u2713 clean"};return gh((d)=>{if(e.activeTab()!=="list")return;if(e.showCommandPalette())return;if(e.showRemove())return;if(e.showBulkActions())return;let b=d.name;if(b==="x"&&e.selectedWorktrees().size>0){e.setShowBulkActions(!0);return}if(b==="return"&&!e.showDetailView()&&o()){e.setShowDetailView(!0);return}if(b==="escape"&&e.showDetailView()){e.setShowDetailView(!1);return}}),(()=>{var d=ve("box");return Z(d,"width","100%"),Z(d,"height","100%"),lt(d,Jt(te,{get when(){return yr(()=>!!e.showDetailView())()&&!!o()},get children(){return Jt(ja,{get worktree(){return o()}})}}),null),lt(d,Jt(te,{get when(){return!e.showDetailView()},get children(){return[Jt(te,{get when(){return t.loading()},get children(){return Jt(Jo,{label:"Loading worktrees..."})}}),Jt(te,{get when(){return yr(()=>!t.loading())()&&!!t.error()},get children(){return[(()=>{var b=ve("text"),y=et("Error: ");return de(b,y),Z(b,"x",2),Z(b,"y",2),lt(b,()=>t.error()?.message,null),hn((S)=>Z(b,"fg",h.text.error,S)),b})(),(()=>{var b=ve("text");return de(b,et("Not in a git repository?")),Z(b,"x",2),Z(b,"y",3),hn((y)=>Z(b,"fg",h.text.secondary,y)),b})()]}}),Jt(te,{get when(){return yr(()=>!t.loading()&&!t.error())()&&!!o()},get children(){var b=ve("box"),y=ve("box"),S=ve("text"),P=ve("box"),E=ve("text"),I=ve("box"),V=ve("box"),T=ve("text"),H=ve("text"),Q=ve("box"),he=ve("box"),G=ve("text"),F=ve("text"),N=ve("box"),K=ve("box"),k=ve("text"),ge=ve("text"),re=ve("box"),me=ve("box"),x=ve("text"),v=ve("text"),A=ve("box"),B=ve("box"),D=ve("text"),z=ve("text"),se=ve("box"),J=ve("text"),_=ve("box"),Me=ve("text"),fe=ve("text"),pe=ve("text"),De=ve("text"),Ce=ve("text"),O=ve("text");return de(b,y),de(b,P),de(b,I),de(b,Q),de(b,N),de(b,re),de(b,A),de(b,se),de(b,_),Z(b,"width","100%"),Z(b,"height","100%"),Z(b,"flexDirection","column"),Z(b,"paddingX",2),Z(b,"paddingY",1),de(y,S),Z(y,"height",1),Z(y,"flexDirection","row"),de(S,et("Worktree Details")),de(P,E),Z(P,"height",1),lt(E,()=>"\u2500".repeat(Math.max(r()-38,10))),lt(b,Jt(te,{get when(){return t.isMultiRepo()},get children(){var a=ve("box"),w=ve("box"),L=ve("text"),W=ve("text");return de(a,w),de(a,W),Z(a,"height",1),Z(a,"flexDirection","row"),de(w,L),Z(w,"width",14),Z(w,"height",1),de(L,et("Repo")),lt(W,()=>o()?.repoName),hn((C)=>{var q=h.text.secondary,X=h.text.warning;return q!==C.e&&(C.e=Z(L,"fg",q,C.e)),X!==C.t&&(C.t=Z(W,"fg",X,C.t)),C},{e:void 0,t:void 0}),a}}),I),de(I,V),de(I,H),Z(I,"height",1),Z(I,"flexDirection","row"),de(V,T),Z(V,"width",14),Z(V,"height",1),de(T,et("Branch")),lt(H,()=>o()?.branch??"(detached)"),de(Q,he),de(Q,F),Z(Q,"height",1),Z(Q,"flexDirection","row"),de(he,G),Z(he,"width",14),Z(he,"height",1),de(G,et("Path")),lt(F,()=>o()?.path),de(N,K),de(N,ge),Z(N,"height",1),Z(N,"flexDirection","row"),de(K,k),Z(K,"width",14),Z(K,"height",1),de(k,et("Status")),lt(ge,M),de(re,me),de(re,v),Z(re,"height",1),Z(re,"flexDirection","row"),de(me,x),Z(me,"width",14),Z(me,"height",1),de(x,et("Sync")),lt(v,R),de(A,B),de(A,z),Z(A,"height",1),Z(A,"flexDirection","row"),de(B,D),Z(B,"width",14),Z(B,"height",1),de(D,et("HEAD")),lt(z,()=>o()?.head?.slice(0,8)),lt(b,Jt(te,{get when(){return s()?.lastCommit},get children(){return[(()=>{var a=ve("box"),w=ve("box"),L=ve("text"),W=ve("text");return de(a,w),de(a,W),Z(a,"height",1),Z(a,"flexDirection","row"),de(w,L),Z(w,"width",14),Z(w,"height",1),de(L,et("Last Commit")),lt(W,()=>s().lastCommit.relativeDate),hn((C)=>{var q=h.text.secondary,X=h.text.primary;return q!==C.e&&(C.e=Z(L,"fg",q,C.e)),X!==C.t&&(C.t=Z(W,"fg",X,C.t)),C},{e:void 0,t:void 0}),a})(),(()=>{var a=ve("box"),w=ve("box"),L=ve("text"),W=ve("text");return de(a,w),de(a,W),Z(a,"height",1),Z(a,"flexDirection","row"),de(w,L),Z(w,"width",14),Z(w,"height",1),lt(W,(()=>{var C=yr(()=>s().lastCommit.message.length>50);return()=>C()?s().lastCommit.message.slice(0,47)+"...":s().lastCommit.message})()),hn((C)=>{var q=h.text.secondary,X=h.text.secondary;return q!==C.e&&(C.e=Z(L,"fg",q,C.e)),X!==C.t&&(C.t=Z(W,"fg",X,C.t)),C},{e:void 0,t:void 0}),a})()]}}),se),lt(b,Jt(te,{get when(){let a=dn(o()?.path??"");return a&&a.length>0},get children(){var a=ve("box"),w=ve("box"),L=ve("text"),W=ve("text");return de(a,w),de(a,W),Z(a,"height",1),Z(a,"flexDirection","row"),de(w,L),Z(w,"width",14),Z(w,"height",1),de(L,et("Focus")),lt(W,()=>dn(o()?.path??"")?.join(", ")??""),hn((C)=>{var q=h.text.secondary,X=h.text.accent;return q!==C.e&&(C.e=Z(L,"fg",q,C.e)),X!==C.t&&(C.t=Z(W,"fg",X,C.t)),C},{e:void 0,t:void 0}),a}}),se),lt(b,Jt(te,{get when(){return!!tn(o()?.path??"")},get children(){var a=ve("box"),w=ve("box"),L=ve("text"),W=ve("text");return de(a,w),de(a,W),Z(a,"height",1),Z(a,"flexDirection","row"),de(w,L),Z(w,"width",14),Z(w,"height",1),de(L,et("Session")),lt(W,()=>{let C=tn(o()?.path??"");if(!C)return"";return C.layout?`${C.name} [${C.layout}]`:C.name}),hn((C)=>{var q=h.text.secondary,X=h.text.accent;return q!==C.e&&(C.e=Z(L,"fg",q,C.e)),X!==C.t&&(C.t=Z(W,"fg",X,C.t)),C},{e:void 0,t:void 0}),a}}),se),lt(b,Jt(te,{get when(){return o()?.isMain},get children(){var a=ve("box"),w=ve("box"),L=ve("text"),W=ve("text");return de(a,w),de(a,W),Z(a,"height",1),Z(a,"flexDirection","row"),de(w,L),Z(w,"width",14),Z(w,"height",1),de(L,et("Type")),de(W,et("main worktree")),hn((C)=>{var q=h.text.secondary,X=h.text.accent;return q!==C.e&&(C.e=Z(L,"fg",q,C.e)),X!==C.t&&(C.t=Z(W,"fg",X,C.t)),C},{e:void 0,t:void 0}),a}}),se),de(se,J),Z(se,"height",1),lt(J,()=>"\u2500".repeat(Math.max(r()-38,10))),de(_,Me),de(_,fe),de(_,pe),de(_,De),de(_,Ce),de(_,O),Z(_,"height",1),Z(_,"flexDirection","row"),Z(_,"gap",2),de(Me,et("Enter:detail")),de(fe,et("d:delete")),de(pe,et("a:add")),de(De,et("o:open")),de(Ce,et("r:refresh")),de(O,et("^P:commands")),hn((a)=>{var w=h.bg.surface,L=h.text.accent,W=h.border.subtle,C=h.text.secondary,q=h.text.accent,X=h.text.secondary,U=h.text.primary,Ne=h.text.secondary,Ue=o()?.isDirty?h.text.error:o()?.isLocked?h.text.warning:h.text.success,sn=h.text.secondary,cn=m()?h.text.error:u()?h.text.secondary:s()?.aheadBehind?.ahead||s()?.aheadBehind?.behind?h.text.warning:h.text.success,Tn=h.text.secondary,jn=h.text.secondary,Nn=h.border.subtle,Gn=h.text.secondary,kn=h.text.secondary,Hn=h.text.secondary,lr=h.text.secondary,fr=h.text.secondary,ur=h.text.secondary;return w!==a.e&&(a.e=Z(b,"backgroundColor",w,a.e)),L!==a.t&&(a.t=Z(S,"fg",L,a.t)),W!==a.a&&(a.a=Z(E,"fg",W,a.a)),C!==a.o&&(a.o=Z(T,"fg",C,a.o)),q!==a.i&&(a.i=Z(H,"fg",q,a.i)),X!==a.n&&(a.n=Z(G,"fg",X,a.n)),U!==a.s&&(a.s=Z(F,"fg",U,a.s)),Ne!==a.h&&(a.h=Z(k,"fg",Ne,a.h)),Ue!==a.r&&(a.r=Z(ge,"fg",Ue,a.r)),sn!==a.d&&(a.d=Z(x,"fg",sn,a.d)),cn!==a.l&&(a.l=Z(v,"fg",cn,a.l)),Tn!==a.u&&(a.u=Z(D,"fg",Tn,a.u)),jn!==a.c&&(a.c=Z(z,"fg",jn,a.c)),Nn!==a.w&&(a.w=Z(J,"fg",Nn,a.w)),Gn!==a.m&&(a.m=Z(Me,"fg",Gn,a.m)),kn!==a.f&&(a.f=Z(fe,"fg",kn,a.f)),Hn!==a.y&&(a.y=Z(pe,"fg",Hn,a.y)),lr!==a.g&&(a.g=Z(De,"fg",lr,a.g)),fr!==a.p&&(a.p=Z(Ce,"fg",fr,a.p)),ur!==a.b&&(a.b=Z(O,"fg",ur,a.b)),a},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0,c:void 0,w:void 0,m:void 0,f:void 0,y:void 0,g:void 0,p:void 0,b:void 0}),b}}),Jt(te,{get when(){return yr(()=>!t.loading()&&!t.error())()&&!o()},get children(){var b=ve("box"),y=ve("text"),S=ve("text");return de(b,y),de(b,S),Z(b,"flexDirection","column"),Z(b,"gap",1),de(y,et("No worktree selected.")),de(S,et("Press 'a' to create one.")),hn((P)=>{var E=h.text.secondary,I=h.text.accent;return E!==P.e&&(P.e=Z(y,"fg",E,P.e)),I!==P.t&&(P.t=Z(S,"fg",I,P.t)),P},{e:void 0,t:void 0}),b}})]}}),null),hn((b)=>Z(d,"backgroundColor",h.bg.base,b)),d})()}var xh=150;var ka=$e(()=>{ht();bn();yn();Lt();Rn();eo();ke();Na();mi()});import{join as Cs,resolve as pi}from"path";import*as to from"fs";function $n(e,t,n){if(!Array.isArray(e)||e.some((o)=>typeof o!=="string"))n.push({field:t,message:"Must be an array of strings"})}function Ja(){let t=Bun.env.XDG_CONFIG_HOME??Cs(Bun.env.HOME??"~",".config");return Cs(t,"oh-my-worktree")}function Vt(){return Cs(Ja(),"config.json")}function Or(e){let t=[];if(typeof e!=="object"||e===null)return t.push({field:"root",message:"Config must be a JSON object"}),t;let n=e;if(!("version"in n))t.push({field:"version",message:"Required field 'version' is missing"});else if(n.version!==1)t.push({field:"version",message:`Expected version 1, got ${JSON.stringify(n.version)}`});for(let o of Object.keys(n))if(!bh.has(o))t.push({field:o,message:`Unknown field '${o}'`});if("defaults"in n&&n.defaults!==void 0)if(typeof n.defaults!=="object"||n.defaults===null)t.push({field:"defaults",message:"Must be an object"});else{let o=n.defaults;for(let r of Object.keys(o))if(!vh.has(r))t.push({field:`defaults.${r}`,message:`Unknown field '${r}'`});if("worktreeDir"in o&&typeof o.worktreeDir!=="string")t.push({field:"defaults.worktreeDir",message:"Must be a string"});if("autoUpstream"in o&&typeof o.autoUpstream!=="boolean")t.push({field:"defaults.autoUpstream",message:"Must be a boolean"});for(let r of["copyFiles","linkFiles","postCreate","postRemove"])if(r in o)$n(o[r],`defaults.${r}`,t);if("sharedDeps"in o&&o.sharedDeps!==void 0)if(typeof o.sharedDeps!=="object"||o.sharedDeps===null)t.push({field:"defaults.sharedDeps",message:"Must be an object"});else Ha(o.sharedDeps,"defaults.sharedDeps",t)}if("repos"in n&&n.repos!==void 0)if(!Array.isArray(n.repos))t.push({field:"repos",message:"Must be an array"});else for(let o=0;o<n.repos.length;o++){let r=n.repos[o],i=`repos[${o}]`;if(typeof r!=="object"||r===null){t.push({field:i,message:"Must be an object"});continue}let s=r;for(let c of Object.keys(s))if(!Ch.has(c))t.push({field:`${i}.${c}`,message:`Unknown field '${c}'`});if(!("path"in s)||typeof s.path!=="string")t.push({field:`${i}.path`,message:"Required string field 'path' is missing"});if("worktreeDir"in s&&typeof s.worktreeDir!=="string")t.push({field:`${i}.worktreeDir`,message:"Must be a string"});if("autoUpstream"in s&&typeof s.autoUpstream!=="boolean")t.push({field:`${i}.autoUpstream`,message:"Must be a boolean"});for(let c of["copyFiles","linkFiles","postCreate","postRemove"])if(c in s)$n(s[c],`${i}.${c}`,t);if("sharedDeps"in s&&s.sharedDeps!==void 0)if(typeof s.sharedDeps!=="object"||s.sharedDeps===null)t.push({field:`${i}.sharedDeps`,message:"Must be an object"});else Ha(s.sharedDeps,`${i}.sharedDeps`,t);if("monorepo"in s&&s.monorepo!==void 0)if(typeof s.monorepo!=="object"||s.monorepo===null)t.push({field:`${i}.monorepo`,message:"Must be an object"});else{let c=s.monorepo;for(let u of Object.keys(c))if(!$h.has(u))t.push({field:`${i}.monorepo.${u}`,message:`Unknown field '${u}'`});if("autoDetect"in c&&typeof c.autoDetect!=="boolean")t.push({field:`${i}.monorepo.autoDetect`,message:"Must be a boolean"});if("extraPatterns"in c&&c.extraPatterns!==void 0)$n(c.extraPatterns,`${i}.monorepo.extraPatterns`,t);if("hooks"in c&&c.hooks!==void 0)if(!Array.isArray(c.hooks))t.push({field:`${i}.monorepo.hooks`,message:"Must be an array"});else for(let u=0;u<c.hooks.length;u++){let f=c.hooks[u];if(typeof f!=="object"||f===null){t.push({field:`${i}.monorepo.hooks[${u}]`,message:"Must be an object"});continue}if(!("glob"in f)||typeof f.glob!=="string")t.push({field:`${i}.monorepo.hooks[${u}].glob`,message:"Required string field"});if("copyFiles"in f&&f.copyFiles!==void 0)$n(f.copyFiles,`${i}.monorepo.hooks[${u}].copyFiles`,t);if("linkFiles"in f&&f.linkFiles!==void 0)$n(f.linkFiles,`${i}.monorepo.hooks[${u}].linkFiles`,t);if("postCreate"in f&&f.postCreate!==void 0)$n(f.postCreate,`${i}.monorepo.hooks[${u}].postCreate`,t);if("postRemove"in f&&f.postRemove!==void 0)$n(f.postRemove,`${i}.monorepo.hooks[${u}].postRemove`,t)}}}if("templates"in n&&n.templates!==void 0)if(typeof n.templates!=="object"||n.templates===null||Array.isArray(n.templates))t.push({field:"templates",message:"Must be an object (key-value map)"});else{let o=n.templates;for(let[r,i]of Object.entries(o)){let s=`templates.${r}`;if(typeof i!=="object"||i===null){t.push({field:s,message:"Must be an object"});continue}let c=i;for(let u of Object.keys(c))if(!Ph.has(u))t.push({field:`${s}.${u}`,message:`Unknown field '${u}'`});if("worktreeDir"in c&&typeof c.worktreeDir!=="string")t.push({field:`${s}.worktreeDir`,message:"Must be a string"});if("base"in c&&typeof c.base!=="string")t.push({field:`${s}.base`,message:"Must be a string"});if("autoUpstream"in c&&typeof c.autoUpstream!=="boolean")t.push({field:`${s}.autoUpstream`,message:"Must be a boolean"});for(let u of["copyFiles","linkFiles","postCreate","postRemove"])if(u in c)$n(c[u],`${s}.${u}`,t)}}if("lifecycle"in n&&n.lifecycle!==void 0)if(typeof n.lifecycle!=="object"||n.lifecycle===null)t.push({field:"lifecycle",message:"Must be an object"});else{let o=n.lifecycle;for(let r of Object.keys(o))if(!Sh.has(r))t.push({field:`lifecycle.${r}`,message:`Unknown field '${r}'`});if("autoCleanMerged"in o&&typeof o.autoCleanMerged!=="boolean")t.push({field:"lifecycle.autoCleanMerged",message:"Must be a boolean"});if("staleAfterDays"in o&&(typeof o.staleAfterDays!=="number"||o.staleAfterDays<1))t.push({field:"lifecycle.staleAfterDays",message:"Must be a positive number"});if("maxWorktrees"in o&&(typeof o.maxWorktrees!=="number"||o.maxWorktrees<1))t.push({field:"lifecycle.maxWorktrees",message:"Must be a positive number"})}if("sessions"in n&&n.sessions!==void 0)if(typeof n.sessions!=="object"||n.sessions===null)t.push({field:"sessions",message:"Must be an object"});else{let o=n.sessions;for(let r of Object.keys(o))if(!Eh.has(r))t.push({field:`sessions.${r}`,message:`Unknown field '${r}'`});for(let r of["enabled","autoCreate","autoKill"])if(r in o&&typeof o[r]!=="boolean")t.push({field:`sessions.${r}`,message:"Must be a boolean"});if("prefix"in o&&typeof o.prefix!=="string")t.push({field:"sessions.prefix",message:"Must be a string"});if("defaultLayout"in o&&typeof o.defaultLayout!=="string")t.push({field:"sessions.defaultLayout",message:"Must be a string"});if("layouts"in o&&o.layouts!==void 0)if(typeof o.layouts!=="object"||o.layouts===null||Array.isArray(o.layouts))t.push({field:"sessions.layouts",message:"Must be an object (key-value map)"});else{let r=o.layouts;for(let[i,s]of Object.entries(r)){let c=`sessions.layouts.${i}`;if(typeof s!=="object"||s===null){t.push({field:c,message:"Must be an object"});continue}let u=s;if(!("windows"in u)||!Array.isArray(u.windows))t.push({field:`${c}.windows`,message:"Required array field"});else for(let f=0;f<u.windows.length;f++){let m=u.windows[f];if(typeof m!=="object"||m===null){t.push({field:`${c}.windows[${f}]`,message:"Must be an object"});continue}if(!("name"in m)||typeof m.name!=="string")t.push({field:`${c}.windows[${f}].name`,message:"Required string field"});if("command"in m&&typeof m.command!=="string")t.push({field:`${c}.windows[${f}].command`,message:"Must be a string"})}}}if("defaultLayout"in o&&typeof o.defaultLayout==="string"&&"layouts"in o&&typeof o.layouts==="object"&&o.layouts!==null){let r=o.layouts;if(!(o.defaultLayout in r))t.push({field:"sessions.defaultLayout",message:`Layout '${o.defaultLayout}' does not exist in sessions.layouts`})}}if("profiles"in n&&n.profiles!==void 0)if(typeof n.profiles!=="object"||n.profiles===null||Array.isArray(n.profiles))t.push({field:"profiles",message:"Must be an object (key-value map)"});else{let o=n.profiles;for(let[r,i]of Object.entries(o)){let s=`profiles.${r}`;if(typeof i!=="object"||i===null){t.push({field:s,message:"Must be an object"});continue}let c=i;for(let u of Object.keys(c))if(!Mh.has(u))t.push({field:`${s}.${u}`,message:`Unknown field '${u}'`})}}if("activeProfile"in n&&n.activeProfile!==void 0){if(typeof n.activeProfile!=="string")t.push({field:"activeProfile",message:"Must be a string"});else if("profiles"in n&&n.profiles!==void 0&&typeof n.profiles==="object"&&n.profiles!==null&&!Array.isArray(n.profiles)){let o=n.profiles;if(!(n.activeProfile in o))t.push({field:"activeProfile",message:`Profile '${n.activeProfile}' does not exist in profiles`})}else if(!("profiles"in n)||n.profiles===void 0)t.push({field:"activeProfile",message:"Cannot set activeProfile without profiles"})}return t}function Ha(e,t,n){let o=new Set(["strategy","paths","invalidateOn"]);for(let r of Object.keys(e))if(!o.has(r))n.push({field:`${t}.${r}`,message:`Unknown field '${r}'`});if("strategy"in e&&!["hardlink","symlink","copy"].includes(e.strategy))n.push({field:`${t}.strategy`,message:'Must be "hardlink", "symlink", or "copy"'});if("paths"in e)$n(e.paths,`${t}.paths`,n);if("invalidateOn"in e)$n(e.invalidateOn,`${t}.invalidateOn`,n)}function Rr(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Eo(e){if(Array.isArray(e))return e.map((t)=>Eo(t));if(Rr(e)){let t={};for(let[n,o]of Object.entries(e))t[n]=Eo(o);return t}return e}function Va(e,t){if(t===void 0)return Eo(e);if(Array.isArray(t))return t.map((r)=>Eo(r));if(!Rr(t))return Eo(t);let n=Rr(e)?e:{},o={};for(let[r,i]of Object.entries(n))o[r]=Eo(i);for(let[r,i]of Object.entries(t)){if(i===void 0)continue;let s=n[r];if(Rr(s)&&Rr(i)){o[r]=Va(s,i);continue}o[r]=Eo(i)}return o}function yh(e){if(!e.activeProfile)return structuredClone(e);let t=e.profiles?.[e.activeProfile];if(!t||typeof t!=="object"||Array.isArray(t))throw Error(`Active profile '${e.activeProfile}' does not exist`);return Va(e,t)}function Fe(e){let t=e??Vt();if(!to.existsSync(t))return structuredClone(Ua);let n;try{let s=gi.readFileSync(t,"utf-8");n=JSON.parse(s)}catch(s){let c=s.message;if(c.includes("JSON"))throw Error(`Invalid JSON in config file: ${c}`);if(s instanceof SyntaxError)throw Error(`Invalid JSON in config file: ${c}`);throw Error(`Failed to read config file: ${c}`)}let o=Or(n);if(o.length>0){let s=o.map((c)=>`${c.field}: ${c.message}`).join("; ");throw Error(`Config validation failed: ${s}`)}let r=yh(n),i=Or(r);if(i.length>0){let s=i.map((c)=>`${c.field}: ${c.message}`).join("; ");throw Error(`Config validation failed after applying activeProfile: ${s}`)}return r}function Wt(e,t){let n=pi(t),o=e.repos?.find((r)=>pi(r.path)===n);return{worktreeDir:o?.worktreeDir??e.defaults?.worktreeDir??Vo.worktreeDir,copyFiles:o?.copyFiles??e.defaults?.copyFiles??Vo.copyFiles,linkFiles:o?.linkFiles??e.defaults?.linkFiles??Vo.linkFiles,postCreate:o?.postCreate??e.defaults?.postCreate??Vo.postCreate,postRemove:o?.postRemove??e.defaults?.postRemove??Vo.postRemove,autoUpstream:o?.autoUpstream??e.defaults?.autoUpstream??Vo.autoUpstream,monorepo:o?.monorepo,sharedDeps:o?.sharedDeps??e.defaults?.sharedDeps}}function no(e){return(e.repos??[]).map((t)=>pi(t.path))}function wi(e,t){let n=Bun.env.HOME??"~";return e.replace(/^~(?=\/|$)/,n).replace(/\{repo\}/g,t.repo).replace(/\{branch\}/g,t.branch)}function Pn(e){let t=e??Vt(),n=e?pi(t,".."):Ja();if(!to.existsSync(n))gi.mkdirSync(n,{recursive:!0,mode:448});if(to.existsSync(t))return t;return Wr(t,`${JSON.stringify(Ua,null,2)}
|
|
12
|
+
`),t}function xi(e,t){return e.templates?.[t]}function bi(e,t){return{worktreeDir:t.worktreeDir??e.worktreeDir,copyFiles:t.copyFiles??e.copyFiles,linkFiles:t.linkFiles??e.linkFiles,postCreate:t.postCreate??e.postCreate,postRemove:t.postRemove??e.postRemove,autoUpstream:t.autoUpstream??e.autoUpstream,monorepo:e.monorepo,sharedDeps:e.sharedDeps}}function oo(e){return e.sessions??{}}function vi(e,t){let n=e.sessions;if(!n?.layouts)return;let o=t??n.defaultLayout;if(!o)return;return n.layouts[o]}function Wr(e,t){let n=`${e}.tmp.${Date.now()}`;try{to.writeFileSync(n,t,{encoding:"utf-8",mode:384});let o=JSON.parse(t),r=Or(o);if(r.length>0)throw Error(`Validation failed: ${r.map((i)=>i.message).join("; ")}`);gi.renameSync(n,e)}catch(o){if(to.existsSync(n))gi.unlinkSync(n);throw o}}var gi,za="~/.omw/worktrees/{repo}-{branch}",Ua,Vo,bh,vh,Ch,$h,Ph,Sh,Eh,Mh;var it=$e(()=>{gi=to,Ua={version:1,defaults:{worktreeDir:za,copyFiles:[],linkFiles:[],postCreate:[],postRemove:[],autoUpstream:!0},repos:[]},Vo={worktreeDir:za,copyFiles:[],linkFiles:[],postCreate:[],postRemove:[],autoUpstream:!0,sharedDeps:void 0};bh=new Set(["version","defaults","repos","$schema","theme","templates","lifecycle","sessions","profiles","activeProfile"]),vh=new Set(["worktreeDir","copyFiles","linkFiles","postCreate","postRemove","autoUpstream","sharedDeps"]),Ch=new Set(["path","worktreeDir","copyFiles","linkFiles","postCreate","postRemove","autoUpstream","monorepo","sharedDeps"]),$h=new Set(["autoDetect","extraPatterns","hooks"]),Ph=new Set(["worktreeDir","copyFiles","linkFiles","postCreate","postRemove","autoUpstream","base"]),Sh=new Set(["autoCleanMerged","staleAfterDays","maxWorktrees"]),Eh=new Set(["enabled","autoCreate","autoKill","prefix","defaultLayout","layouts"]),Mh=new Set(["defaults","repos","theme","templates","lifecycle","sessions"])});import*as Rh from"fs";import{join as ro,resolve as Dn,dirname as Dr}from"path";function qo(e,t,n){let o={copied:[],linked:[],skipped:[],warnings:[]};for(let r of n){let i=ro(Dn(e),r),s=ro(Dn(t),r);if(!Fn(i)){o.skipped.push(r),o.warnings.push(`Source not found, skipping copy: ${r}`);continue}if(Fn(s)){o.skipped.push(r),o.warnings.push(`Target already exists, skipping copy: ${r}`);continue}try{Ko(Dr(s),{recursive:!0}),qa(i,s),o.copied.push(r)}catch(c){o.skipped.push(r),o.warnings.push(`Failed to copy ${r}: ${c.message}`)}}return o}function Xo(e,t,n){let o={copied:[],linked:[],skipped:[],warnings:[]};for(let r of n){let i=Dn(ro(Dn(e),r)),s=ro(Dn(t),r);if(!Fn(i)){o.skipped.push(r),o.warnings.push(`Source not found, skipping symlink: ${r}`);continue}if(Fn(s)){o.skipped.push(r),o.warnings.push(`Target already exists, skipping symlink: ${r}`);continue}try{Ko(Dr(s),{recursive:!0}),Xa(i,s),o.linked.push(r)}catch(c){o.skipped.push(r),o.warnings.push(`Failed to symlink ${r}: ${c.message}`)}}return o}function Za(e,t,n=0){let o=0,r=[];if(n>Fh)return{linked:0,errors:[`Max directory depth exceeded at ${e}`]};let i=Dn(e),s=Dn(t);if(!Fn(i))return{linked:0,errors:[`Source not found: ${e}`]};let c=Dh(i,{throwIfNoEntry:!1});if(!c||!c.isDirectory())try{return Ko(Dr(s),{recursive:!0}),Ka(i,s),{linked:1,errors:[]}}catch(u){return{linked:0,errors:[`Failed to hardlink ${e}: ${u.message}`]}}if(!Fn(s))Ko(s,{recursive:!0});try{let u=Wh(i,{withFileTypes:!0});for(let f of u){let m=ro(i,f.name),l=ro(s,f.name);if(f.isDirectory()){let p=Za(m,l,n+1);if(o+=p.linked,p.errors.length>0)r.push(...p.errors)}else if(f.isFile()){if(Fn(l))continue;try{Ka(m,l),o++}catch(p){try{qa(m,l),o++}catch(R){r.push(`Failed to link/copy ${f.name}: ${R.message}`)}}}}}catch(u){r.push(`Failed to read directory ${e}: ${u.message}`)}return{linked:o,errors:r}}function Qa(e,t,n){let o={copied:[],linked:[],skipped:[],warnings:[]},r=n.paths??[],i=n.strategy??"symlink";for(let s of r){let c=ro(Dn(e),s),u=ro(Dn(t),s);if(!Fn(c)){o.skipped.push(s),o.warnings.push(`Source not found, skipping shared dep: ${s}`);continue}if(Fn(u)){o.skipped.push(s);continue}try{if(i==="symlink")Ko(Dr(u),{recursive:!0}),Xa(c,u),o.linked.push(s);else if(i==="hardlink"){let f=Za(c,u);if(f.linked>0)o.linked.push(s);for(let m of f.errors)o.warnings.push(m)}else Ko(Dr(u),{recursive:!0}),Oh(c,u,{recursive:!0}),o.copied.push(s)}catch(f){o.skipped.push(s),o.warnings.push(`Failed to share dep ${s}: ${f.message}`)}}return o}var qa,Oh,Fn,Xa,wb,Ka,Wh,Dh,Ko,Fh=30;var Ci=$e(()=>{({copyFileSync:qa,cpSync:Oh,existsSync:Fn,symlinkSync:Xa,unlinkSync:wb,linkSync:Ka,readdirSync:Wh,statSync:Dh,mkdirSync:Ko}=Rh)});import{existsSync as Ih,mkdirSync as Bh}from"fs";async function Et(e,t){let n=t.timeout??30000;for(let o of e)await Lh(o,t.cwd,n,t.env??{},t.onOutput)}async function Lh(e,t,n,o,r){if(!Ih(t))Bh(t,{recursive:!0});let i;try{i=Bun.spawn(["sh","-c",e],{cwd:t,env:{...process.env,...o},stdout:"pipe",stderr:"pipe"})}catch(f){if(f.code!=="ENOENT")throw f;i=Bun.spawn(["/bin/sh","-c",e],{cwd:t,env:{...process.env,...o},stdout:"pipe",stderr:"pipe"})}let s=!1,c=setTimeout(()=>{s=!0,i.kill()},n),u=i.stderr?new Response(i.stderr).text():Promise.resolve("");try{if(r&&i.stdout){let m=i.stdout.getReader(),l=new TextDecoder,p=[];while(!0){let{done:M,value:d}=await m.read();if(M)break;let y=l.decode(d,{stream:!0}).split(`
|
|
13
|
+
`);if(y.length===1)p.push(y[0]);else{p.push(y[0]);let S=p.join("");if(p.length=0,S)r(S);for(let E=1;E<y.length-1;E++)if(y[E])r(y[E]);let P=y[y.length-1];if(P)p.push(P)}}let R=p.join("")+l.decode();if(R)r(R)}let f=await i.exited;if(s)throw new Qo(e,n);if(f!==0){let m=(await u).trim();throw new Zo(e,f,m)}}finally{clearTimeout(c)}}var Zo,Qo;var In=$e(()=>{Zo=class Zo extends Error{command;exitCode;stderr;constructor(e,t,n){super(`Hook command failed (exit ${t}): ${e}
|
|
14
|
+
${n}`);this.command=e;this.exitCode=t;this.stderr=n;this.name="HookError"}};Qo=class Qo extends Error{command;timeoutMs;constructor(e,t){super(`Hook command timed out after ${t}ms: ${e}`);this.command=e;this.timeoutMs=t;this.name="HookTimeoutError"}}});import{existsSync as Ah,readdirSync as $b,readFileSync as Pb,statSync as Th}from"fs";import{join as jh,relative as Eb}from"path";function $i(e,t){let n=[],o=[];for(let r of t){let i=r.trim();if(!i){o.push(i);continue}let s=jh(e,i);try{if(Ah(s)&&Th(s).isDirectory())n.push(i);else o.push(i)}catch{o.push(i)}}return{valid:n,invalid:o}}var $s=()=>{};function Mo(e,t){return e.map((n)=>{let o=new Bun.Glob(n.glob),r=t.filter((i)=>o.match(i));return{glob:n.glob,matchedPaths:r,copyFiles:n.copyFiles??[],linkFiles:n.linkFiles??[],postCreate:n.postCreate??[],postRemove:n.postRemove??[]}}).filter((n)=>n.matchedPaths.length>0)}function Nh(e,t){return e.replace(/\{packagePath\}/g,t.packagePath).replace(/\{repo\}/g,t.repo).replace(/\{branch\}/g,t.branch)}async function Yo(e,t,n){for(let o of e){let r=o[t],i=t==="postCreate"&&o.copyFiles.length>0,s=t==="postCreate"&&o.linkFiles.length>0,c=r.length>0;if(!i&&!s&&!c)continue;for(let u of o.matchedPaths){let{join:f}=await import("path"),m=f(n.mainRepoPath,u),l=f(n.cwd,u);if(i){let p=qo(m,l,o.copyFiles);for(let R of p.copied)n.onOutput?.(`Copied ${u}/${R}`);for(let R of p.warnings)n.onOutput?.(`\u26A0 ${R}`)}if(s){let p=Xo(m,l,o.linkFiles);for(let R of p.linked)n.onOutput?.(`Linked ${u}/${R}`);for(let R of p.warnings)n.onOutput?.(`\u26A0 ${R}`)}if(c){let p=r.map((M)=>Nh(M,{packagePath:u,repo:n.repo,branch:n.branch})),R={...n.env??{},OMW_FOCUS_PATHS:n.focusPaths.join(","),OMW_PACKAGE_PATH:u};await Et(p,{cwd:n.cwd,timeout:n.timeout,env:R,onOutput:n.onOutput})}}}}var Pi=$e(()=>{In();Ci()});import{effect as Ya}from"@opentui/solid";import{insert as Ps}from"@opentui/solid";import{createComponent as _a}from"@opentui/solid";import{setProp as st}from"@opentui/solid";import{createElement as el}from"@opentui/solid";import{useTerminalDimensions as Gh}from"@opentui/solid";function io(e){let t=Gh(),n=()=>Math.max(0,Math.floor((t().width-e.width)/2)),o=()=>Math.max(0,Math.floor((t().height-e.height)/2)),r=()=>(()=>{var i=el("box");return st(i,"border",!0),st(i,"borderStyle","rounded"),st(i,"flexDirection","column"),st(i,"paddingX",1),st(i,"paddingY",1),st(i,"titleAlignment","left"),st(i,"position","absolute"),Ps(i,()=>e.children,null),Ps(i,_a(te,{get when(){return e.footer},get children(){return e.footer}}),null),Ya((s)=>{var c=n(),u=o(),f=e.width,m=e.height,l=e.borderColor??h.border.active,p=e.backgroundColor??h.bg.surface,R=e.gap??0,M=e.title;return c!==s.e&&(s.e=st(i,"x",c,s.e)),u!==s.t&&(s.t=st(i,"y",u,s.t)),f!==s.a&&(s.a=st(i,"width",f,s.a)),m!==s.o&&(s.o=st(i,"height",m,s.o)),l!==s.i&&(s.i=st(i,"borderColor",l,s.i)),p!==s.n&&(s.n=st(i,"backgroundColor",p,s.n)),R!==s.s&&(s.s=st(i,"gap",R,s.s)),M!==s.h&&(s.h=st(i,"title",M,s.h)),s},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),i})();return _a(te,{get when(){return e.backdrop},get fallback(){return r()},get children(){var i=el("box");return st(i,"x",0),st(i,"y",0),st(i,"position","absolute"),Ps(i,r),Ya((s)=>{var c=t().width,u=t().height,f=e.backdropColor??h.bg.overlay;return c!==s.e&&(s.e=st(i,"width",c,s.e)),u!==s.t&&(s.t=st(i,"height",u,s.t)),f!==s.a&&(s.a=st(i,"backgroundColor",f,s.a)),s},{e:void 0,t:void 0,a:void 0}),i}})}var Fr=$e(()=>{ht();Lt()});import{createComponent as pt}from"@opentui/solid";import{effect as Be}from"@opentui/solid";import{insert as Qe}from"@opentui/solid";import{createTextNode as Te}from"@opentui/solid";import{insertNode as ae}from"@opentui/solid";import{setProp as j}from"@opentui/solid";import{createElement as ce}from"@opentui/solid";import{memo as Ir}from"@opentui/solid";import{useKeyboard as kh,usePaste as Hh,useTerminalDimensions as zh}from"@opentui/solid";import{decodePasteBytes as Uh}from"@opentui/core";import{basename as tl,resolve as Jh}from"path";function nl(){let e=mt(),t=Pt(),n=zh(),[o,r]=be("input"),[i,s]=be(""),[c,u]=be(""),[f,m]=be("branch"),[l,p]=be(""),[R,M]=be([]),[d,b]=be(""),[y,S]=be([]),[P,E]=be(-1),[I,V]=be(!1),T=()=>{let x=i().toLowerCase();if(!x)return y().slice(0,10);return y().filter((v)=>v.name.toLowerCase().includes(x)).slice(0,10)};ln(Zn(()=>Q(),async()=>{try{let x=Q(),v=await ee.listBranches(x);S(v)}catch{S([])}})),ni(()=>{queueMicrotask(()=>{s(""),u("")})}),ln(Zn(i,()=>{E(-1),V(i().length>0&&T().length>0)})),ln(Zn(o,(x)=>{e.setInputFocused(x==="input")})),en(()=>{e.setInputFocused(!1)});let H=(x,v)=>{M((A)=>A.map((B,D)=>D===x?{...B,...v}:B))},Q=()=>{let x=t.worktrees()??[],v=e.selectedWorktreePath();return(v?x.find((B)=>B.path===v)??x[e.selectedWorktreeIndex()]:x[e.selectedWorktreeIndex()])?.repoPath??e.repoPath()},he=()=>{let x=t.worktrees()??[],v=e.selectedWorktreePath();return(v?x.find((B)=>B.path===v)??x[e.selectedWorktreeIndex()]:x[e.selectedWorktreeIndex()])?.repoName??e.repoPath().split("/").pop()??""},G=()=>{let x=i();if(!x)return"";let v=Q(),A=Fe(),B=Wt(A,v),D=x.replace(/\//g,"-"),z=tl(v);return Jh(wi(B.worktreeDir,{repo:z,branch:D}))};kh(async(x)=>{if(e.activeTab()!=="add")return;if(e.showCommandPalette())return;let v=x.name;if(v==="escape"){if(o()==="preview"){r("input");return}e.setActiveTab("list"),s(""),u(""),m("branch"),r("input");return}if(o()==="input"){if(v==="tab"){if(I()&&f()==="branch")V(!1),E(-1);m((A)=>A==="branch"?"focus":"branch");return}if(f()==="branch"&&I()&&T().length>0){if(v==="down"||x.sequence==="\x1B[B"){E((A)=>Math.min(A+1,T().length-1));return}if(v==="up"||x.sequence==="\x1B[A"){E((A)=>Math.max(A-1,-1));return}}if(v==="return"||v==="enter"){if(f()==="branch"&&P()>=0){let A=T()[P()];if(A){s(A.name),V(!1),E(-1);return}}if(!i())return;V(!1),p(G()),r("preview");return}}if(o()==="preview"){if(v==="return"||v==="enter"){r("creating");let A=i(),B=l(),D=Q(),z=tl(D);try{let se=Fe(),J=Wt(se,D),_=[{label:"Creating worktree",status:"pending"}];if(J.autoUpstream)_.push({label:"Setting upstream",status:"pending"});if(J.copyFiles.length>0)_.push({label:"Copying files",status:"pending"});if(J.linkFiles.length>0)_.push({label:"Creating symlinks",status:"pending"});if(J.postCreate.length>0)_.push({label:"Running hooks",status:"pending"});let Me=c(),fe=[];if(Me)fe=Me.split(/[,\s]+/).map((Ce)=>Ce.trim()).filter(Boolean);if(fe.length>0)_.push({label:"Setting focus",status:"pending"});if(fe.length>0&&J.monorepo?.hooks&&J.monorepo.hooks.length>0){if(Mo(J.monorepo.hooks,fe).length>0)_.push({label:"Running monorepo hooks",status:"pending"})}M(_);let pe=0;if(H(pe,{status:"running"}),await ee.add(A,B,{createBranch:!0},D),H(pe,{status:"done"}),pe++,J.autoUpstream){H(pe,{status:"running"});try{let Ce=await ee.getDefaultRemote(D);if(await ee.remoteBranchExists(A,Ce,D))await ee.setUpstream(A,Ce,D),H(pe,{status:"done",message:`\u2192 ${Ce}/${A}`});else H(pe,{status:"done",message:"no remote branch"})}catch(Ce){H(pe,{status:"error",message:Ce.message})}pe++}if(J.copyFiles.length>0)H(pe,{status:"running"}),qo(D,B,J.copyFiles),H(pe,{status:"done"}),pe++;if(J.linkFiles.length>0)H(pe,{status:"running"}),Xo(D,B,J.linkFiles),H(pe,{status:"done"}),pe++;let De={OMW_BRANCH:A,OMW_WORKTREE_PATH:B,OMW_REPO_PATH:D};if(J.postCreate.length>0)H(pe,{status:"running"}),await Et(J.postCreate,{cwd:B,env:De,onOutput:(Ce)=>H(pe,{message:Ce})}),H(pe,{status:"done"}),pe++;if(fe.length>0){H(pe,{status:"running"});let{valid:Ce}=$i(B,fe);if(fe=Ce,Ce.length>0)ko(B,Ce),De.OMW_FOCUS_PATHS=Ce.join(",");H(pe,{status:"done"}),pe++}if(fe.length>0&&J.monorepo?.hooks&&J.monorepo.hooks.length>0){H(pe,{status:"running"});let Ce=Mo(J.monorepo.hooks,fe);if(Ce.length>0)await Yo(Ce,"postCreate",{cwd:B,env:De,repo:z,branch:A,focusPaths:fe,mainRepoPath:D,onOutput:(O)=>H(pe,{message:O})});H(pe,{status:"done"}),pe++}b("Worktree created successfully!"),r("done"),So.success(`Worktree created: ${A}`),t.refetch(),setTimeout(()=>{e.setActiveTab("list"),s(""),u(""),m("branch"),r("input")},1500)}catch(se){So.error(se.message);let _=R().findIndex((Me)=>Me.status==="running");if(_>=0)H(_,{status:"error",message:se.message});b(`${se.message}`),r("error")}return}}if(o()==="error"){if(v==="escape"||v==="return"||v==="enter")r("input"),b("")}}),Hh((x)=>{if(!e.inputFocused())return;let v=Uh(x.bytes).replace(/\r?\n/g,"");if(!v)return;if(f()==="branch"){s((A)=>A+v);return}if(f()==="focus")u((A)=>A+v)});let F=()=>n().width,N=()=>n().height,K=()=>Math.max(50,Math.min(80,F()-4)),k=4,ge=()=>{if(o()==="input"){let x=I()&&f()==="branch"?T().length*2:0,v=i().length>0?4:0;return Math.max(21+k,Math.min(21+k+x+v,N()-4))}if(o()==="preview")return Math.max(13+k,Math.min((c().length>0?15:13)+k,N()-4));if(o()==="creating")return Math.max(9+k,Math.min(R().length*2+7+k,N()-4));if(o()==="done")return Math.max(11+k,Math.min((c().length>0?15:13)+k,N()-4));return Math.max(11+k,Math.min(11+k,N()-4))},re=()=>Math.max(K()-4,10),me=()=>Math.max(re(),20);return pt(io,{get width(){return K()},get height(){return ge()},get borderColor(){return Ir(()=>o()==="done")()?h.text.success:Ir(()=>o()==="error")()?h.text.error:h.border.active},get backgroundColor(){return h.bg.surface},gap:1,title:" Create Worktree ",get footer(){return[(()=>{var x=ce("box"),v=ce("text");return ae(x,v),j(x,"height",1),Qe(v,()=>"\u2500".repeat(Math.max(re(),1))),Be((A)=>{var B=re(),D=h.border.subtle;return B!==A.e&&(A.e=j(x,"width",B,A.e)),D!==A.t&&(A.t=j(v,"fg",D,A.t)),A},{e:void 0,t:void 0}),x})(),pt(te,{get when(){return o()==="input"},get children(){var x=ce("box"),v=ce("text"),A=ce("text"),B=ce("text"),D=ce("text");return ae(x,v),ae(x,A),ae(x,B),ae(x,D),j(x,"flexDirection","row"),j(x,"gap",2),ae(v,Te("Tab:switch")),ae(A,Te("\u2191\u2193:pick")),ae(B,Te("Enter:confirm")),ae(D,Te("Esc:cancel")),Be((z)=>{var se=h.text.secondary,J=h.text.secondary,_=h.text.secondary,Me=h.text.secondary;return se!==z.e&&(z.e=j(v,"fg",se,z.e)),J!==z.t&&(z.t=j(A,"fg",J,z.t)),_!==z.a&&(z.a=j(B,"fg",_,z.a)),Me!==z.o&&(z.o=j(D,"fg",Me,z.o)),z},{e:void 0,t:void 0,a:void 0,o:void 0}),x}}),pt(te,{get when(){return o()==="preview"},get children(){var x=ce("box"),v=ce("text"),A=ce("text");return ae(x,v),ae(x,A),j(x,"flexDirection","row"),j(x,"gap",2),ae(v,Te("Enter:create")),ae(A,Te("Esc:back")),Be((B)=>{var D=h.text.secondary,z=h.text.secondary;return D!==B.e&&(B.e=j(v,"fg",D,B.e)),z!==B.t&&(B.t=j(A,"fg",z,B.t)),B},{e:void 0,t:void 0}),x}}),pt(te,{get when(){return o()==="creating"},get children(){var x=ce("text");return ae(x,Te("Creating worktree...")),Be((v)=>j(x,"fg",h.text.secondary,v)),x}}),pt(te,{get when(){return o()==="done"},get children(){var x=ce("text");return ae(x,Te("\u2713 Done \u2014 returning to list")),Be((v)=>j(x,"fg",h.text.secondary,v)),x}}),pt(te,{get when(){return o()==="error"},get children(){var x=ce("box"),v=ce("text"),A=ce("text");return ae(x,v),ae(x,A),j(x,"flexDirection","row"),j(x,"gap",2),ae(v,Te("Enter:retry")),ae(A,Te("Esc:back")),Be((B)=>{var D=h.text.secondary,z=h.text.secondary;return D!==B.e&&(B.e=j(v,"fg",D,B.e)),z!==B.t&&(B.t=j(A,"fg",z,B.t)),B},{e:void 0,t:void 0}),x}})]},get children(){return[pt(te,{get when(){return o()==="input"},get children(){return[(()=>{var x=ce("box"),v=ce("text"),A=ce("text"),B=ce("text");return ae(x,v),ae(x,A),ae(x,B),j(x,"height",1),ae(v,Te(">")),j(v,"x",1),j(v,"y",0),ae(A,Te("New Worktree")),j(A,"x",3),j(A,"y",0),j(B,"x",17),j(B,"y",0),Qe(B,he),Be((D)=>{var z=re(),se=h.bg.elevated,J=h.text.accent,_=h.text.primary,Me=h.text.secondary;return z!==D.e&&(D.e=j(x,"width",z,D.e)),se!==D.t&&(D.t=j(x,"backgroundColor",se,D.t)),J!==D.a&&(D.a=j(v,"fg",J,D.a)),_!==D.o&&(D.o=j(A,"fg",_,D.o)),Me!==D.i&&(D.i=j(B,"fg",Me,D.i)),D},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),x})(),(()=>{var x=ce("text");return Qe(x,()=>"\u2500".repeat(re())),Be((v)=>j(x,"fg",h.border.subtle,v)),x})(),(()=>{var x=ce("text");return ae(x,Te("Branch name")),Be((v)=>j(x,"fg",f()==="branch"?h.text.accent:h.text.secondary,v)),x})(),(()=>{var x=ce("input");return j(x,"onInput",(v)=>s(v)),j(x,"placeholder","Branch name or search..."),Be((v)=>{var A=i(),B=f()==="branch",D=me(),z=h.bg.elevated,se=h.text.accent;return A!==v.e&&(v.e=j(x,"value",A,v.e)),B!==v.t&&(v.t=j(x,"focused",B,v.t)),D!==v.a&&(v.a=j(x,"width",D,v.a)),z!==v.o&&(v.o=j(x,"backgroundColor",z,v.o)),se!==v.i&&(v.i=j(x,"cursorColor",se,v.i)),v},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),x})(),pt(te,{get when(){return Ir(()=>!!(I()&&f()==="branch"))()&&T().length>0},get children(){return pt(ft,{get each(){return T()},children:(x,v)=>(()=>{var A=ce("box"),B=ce("text"),D=ce("text");return ae(A,B),ae(A,D),j(A,"height",1),j(B,"x",1),j(B,"y",0),Qe(B,()=>v()===P()?"\u25B8 ":" ",null),Qe(B,()=>x.name,null),j(D,"y",0),Qe(D,()=>x.isRemote?"(remote) ":"",null),Qe(D,()=>x.lastCommitDate,null),Be((z)=>{var se=re(),J=v()===P()?h.select.focusedBg:h.bg.surface,_=v()===P()?h.tab.active:h.text.primary,Me=Math.max(1+x.name.length+4,27),fe=h.text.secondary;return se!==z.e&&(z.e=j(A,"width",se,z.e)),J!==z.t&&(z.t=j(A,"backgroundColor",J,z.t)),_!==z.a&&(z.a=j(B,"fg",_,z.a)),Me!==z.o&&(z.o=j(D,"x",Me,z.o)),fe!==z.i&&(z.i=j(D,"fg",fe,z.i)),z},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),A})()})}}),(()=>{var x=ce("text");return ae(x,Te("Tab to switch fields \xB7 \u2191\u2193 to select branch")),Be((v)=>j(x,"fg",h.text.secondary,v)),x})(),(()=>{var x=ce("box"),v=ce("text"),A=ce("text");return ae(x,v),ae(x,A),j(x,"width","100%"),j(x,"height",1),j(x,"flexDirection","row"),ae(v,Te("Focus ")),ae(A,Te("(optional)")),Be((B)=>{var D=f()==="focus"?h.text.accent:h.text.secondary,z=h.text.secondary;return D!==B.e&&(B.e=j(v,"fg",D,B.e)),z!==B.t&&(B.t=j(A,"fg",z,B.t)),B},{e:void 0,t:void 0}),x})(),(()=>{var x=ce("input");return j(x,"onInput",(v)=>u(v)),j(x,"placeholder","apps/web,apps/api (optional)"),Be((v)=>{var A=c(),B=f()==="focus",D=me(),z=h.bg.elevated,se=h.text.accent;return A!==v.e&&(v.e=j(x,"value",A,v.e)),B!==v.t&&(v.t=j(x,"focused",B,v.t)),D!==v.a&&(v.a=j(x,"width",D,v.a)),z!==v.o&&(v.o=j(x,"backgroundColor",z,v.o)),se!==v.i&&(v.i=j(x,"cursorColor",se,v.i)),v},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),x})(),(()=>{var x=ce("text");return ae(x,Te("comma-separated paths, e.g. apps/web,apps/api")),Be((v)=>j(x,"fg",h.text.secondary,v)),x})(),pt(te,{get when(){return i().length>0},get children(){return[(()=>{var x=ce("text");return ae(x,Te("Target path")),Be((v)=>j(x,"fg",h.text.secondary,v)),x})(),(()=>{var x=ce("text");return Qe(x,G),Be((v)=>j(x,"fg",h.text.primary,v)),x})()]}}),(()=>{var x=ce("text");return ae(x,Te("Type a branch name, e.g. feature/my-feature")),Be((v)=>j(x,"fg",h.text.primary,v)),x})()]}}),pt(te,{get when(){return o()==="preview"},get children(){return[(()=>{var x=ce("box"),v=ce("text"),A=ce("text");return ae(x,v),ae(x,A),j(x,"height",1),ae(v,Te(">")),j(v,"x",1),j(v,"y",0),ae(A,Te("Confirm Worktree")),j(A,"x",3),j(A,"y",0),Be((B)=>{var D=re(),z=h.bg.elevated,se=h.text.accent,J=h.text.primary;return D!==B.e&&(B.e=j(x,"width",D,B.e)),z!==B.t&&(B.t=j(x,"backgroundColor",z,B.t)),se!==B.a&&(B.a=j(v,"fg",se,B.a)),J!==B.o&&(B.o=j(A,"fg",J,B.o)),B},{e:void 0,t:void 0,a:void 0,o:void 0}),x})(),(()=>{var x=ce("text");return Qe(x,()=>"\u2500".repeat(re())),Be((v)=>j(x,"fg",h.border.subtle,v)),x})(),(()=>{var x=ce("box"),v=ce("box"),A=ce("text"),B=ce("text");return ae(x,v),ae(x,B),j(x,"height",1),j(x,"flexDirection","row"),ae(v,A),j(v,"width",14),j(v,"height",1),ae(A,Te("Branch")),Qe(B,i),Be((D)=>{var z=h.text.secondary,se=h.text.accent;return z!==D.e&&(D.e=j(A,"fg",z,D.e)),se!==D.t&&(D.t=j(B,"fg",se,D.t)),D},{e:void 0,t:void 0}),x})(),(()=>{var x=ce("box"),v=ce("box"),A=ce("text"),B=ce("text");return ae(x,v),ae(x,B),j(x,"height",1),j(x,"flexDirection","row"),ae(v,A),j(v,"width",14),j(v,"height",1),ae(A,Te("Path")),Qe(B,l),Be((D)=>{var z=h.text.secondary,se=h.text.primary;return z!==D.e&&(D.e=j(A,"fg",z,D.e)),se!==D.t&&(D.t=j(B,"fg",se,D.t)),D},{e:void 0,t:void 0}),x})(),pt(te,{get when(){return c().length>0},get children(){var x=ce("box"),v=ce("box"),A=ce("text"),B=ce("text");return ae(x,v),ae(x,B),j(x,"height",1),j(x,"flexDirection","row"),ae(v,A),j(v,"width",14),j(v,"height",1),ae(A,Te("Focus")),Qe(B,c),Be((D)=>{var z=h.text.secondary,se=h.text.accent;return z!==D.e&&(D.e=j(A,"fg",z,D.e)),se!==D.t&&(D.t=j(B,"fg",se,D.t)),D},{e:void 0,t:void 0}),x}}),(()=>{var x=ce("text");return ae(x,Te("\u2713 Ready to create. Press Enter to confirm.")),Be((v)=>j(x,"fg",h.text.success,v)),x})()]}}),pt(te,{get when(){return o()==="creating"},get children(){return[(()=>{var x=ce("box"),v=ce("text"),A=ce("text");return ae(x,v),ae(x,A),j(x,"height",1),ae(v,Te(">")),j(v,"x",1),j(v,"y",0),ae(A,Te("Creating Worktree")),j(A,"x",3),j(A,"y",0),Be((B)=>{var D=re(),z=h.bg.elevated,se=h.text.accent,J=h.text.primary;return D!==B.e&&(B.e=j(x,"width",D,B.e)),z!==B.t&&(B.t=j(x,"backgroundColor",z,B.t)),se!==B.a&&(B.a=j(v,"fg",se,B.a)),J!==B.o&&(B.o=j(A,"fg",J,B.o)),B},{e:void 0,t:void 0,a:void 0,o:void 0}),x})(),(()=>{var x=ce("text");return Qe(x,()=>"\u2500".repeat(re())),Be((v)=>j(x,"fg",h.border.subtle,v)),x})(),pt(ft,{get each(){return R()},children:(x)=>(()=>{var v=ce("box"),A=ce("text"),B=Te(" ");return ae(v,A),j(v,"height",1),ae(A,B),Qe(A,(()=>{var D=Ir(()=>x.status==="done");return()=>D()?"\u2713":Ir(()=>x.status==="running")()?"\u27F3":x.status==="error"?"\u2717":"\u25CB"})(),B),Qe(A,()=>x.label,null),Qe(v,pt(te,{get when(){return x.message},get children(){var D=ce("text");return j(D,"y",0),Qe(D,()=>x.message),Be((z)=>{var se=x.label.length+4,J=h.text.secondary;return se!==z.e&&(z.e=j(D,"x",se,z.e)),J!==z.t&&(z.t=j(D,"fg",J,z.t)),z},{e:void 0,t:void 0}),D}}),null),Be((D)=>j(A,"fg",x.status==="done"?h.text.success:x.status==="running"?h.text.accent:x.status==="error"?h.text.error:h.text.secondary,D)),v})()})]}}),pt(te,{get when(){return o()==="done"},get children(){return[(()=>{var x=ce("box"),v=ce("text"),A=ce("text");return ae(x,v),ae(x,A),j(x,"height",1),ae(v,Te(">")),j(v,"x",1),j(v,"y",0),ae(A,Te("Worktree Created")),j(A,"x",3),j(A,"y",0),Be((B)=>{var D=re(),z=h.bg.elevated,se=h.text.success,J=h.text.primary;return D!==B.e&&(B.e=j(x,"width",D,B.e)),z!==B.t&&(B.t=j(x,"backgroundColor",z,B.t)),se!==B.a&&(B.a=j(v,"fg",se,B.a)),J!==B.o&&(B.o=j(A,"fg",J,B.o)),B},{e:void 0,t:void 0,a:void 0,o:void 0}),x})(),(()=>{var x=ce("text");return Qe(x,()=>"\u2500".repeat(re())),Be((v)=>j(x,"fg",h.border.subtle,v)),x})(),(()=>{var x=ce("box"),v=ce("box"),A=ce("text"),B=ce("text");return ae(x,v),ae(x,B),j(x,"height",1),j(x,"flexDirection","row"),ae(v,A),j(v,"width",14),j(v,"height",1),ae(A,Te("Branch")),Qe(B,i),Be((D)=>{var z=h.text.secondary,se=h.text.accent;return z!==D.e&&(D.e=j(A,"fg",z,D.e)),se!==D.t&&(D.t=j(B,"fg",se,D.t)),D},{e:void 0,t:void 0}),x})(),(()=>{var x=ce("box"),v=ce("box"),A=ce("text"),B=ce("text");return ae(x,v),ae(x,B),j(x,"height",1),j(x,"flexDirection","row"),ae(v,A),j(v,"width",14),j(v,"height",1),ae(A,Te("Path")),Qe(B,l),Be((D)=>{var z=h.text.secondary,se=h.text.primary;return z!==D.e&&(D.e=j(A,"fg",z,D.e)),se!==D.t&&(D.t=j(B,"fg",se,D.t)),D},{e:void 0,t:void 0}),x})(),pt(te,{get when(){return c().length>0},get children(){var x=ce("box"),v=ce("box"),A=ce("text"),B=ce("text");return ae(x,v),ae(x,B),j(x,"height",1),j(x,"flexDirection","row"),ae(v,A),j(v,"width",14),j(v,"height",1),ae(A,Te("Focus")),Qe(B,c),Be((D)=>{var z=h.text.secondary,se=h.text.accent;return z!==D.e&&(D.e=j(A,"fg",z,D.e)),se!==D.t&&(D.t=j(B,"fg",se,D.t)),D},{e:void 0,t:void 0}),x}}),(()=>{var x=ce("text"),v=Te("\u2713 ");return ae(x,v),Qe(x,d,null),Be((A)=>j(x,"fg",h.text.success,A)),x})()]}}),pt(te,{get when(){return o()==="error"},get children(){return[(()=>{var x=ce("box"),v=ce("text"),A=ce("text");return ae(x,v),ae(x,A),j(x,"height",1),ae(v,Te(">")),j(v,"x",1),j(v,"y",0),ae(A,Te("Error")),j(A,"x",3),j(A,"y",0),Be((B)=>{var D=re(),z=h.bg.elevated,se=h.text.error,J=h.text.primary;return D!==B.e&&(B.e=j(x,"width",D,B.e)),z!==B.t&&(B.t=j(x,"backgroundColor",z,B.t)),se!==B.a&&(B.a=j(v,"fg",se,B.a)),J!==B.o&&(B.o=j(A,"fg",J,B.o)),B},{e:void 0,t:void 0,a:void 0,o:void 0}),x})(),(()=>{var x=ce("text");return Qe(x,()=>"\u2500".repeat(re())),Be((v)=>j(x,"fg",h.border.subtle,v)),x})(),(()=>{var x=ce("text");return ae(x,Te("\u2717 Failed")),Be((v)=>j(x,"fg",h.text.error,v)),x})(),(()=>{var x=ce("box"),v=ce("text");return ae(x,v),j(x,"height",1),j(v,"x",1),j(v,"y",0),Qe(v,()=>d().slice(0,Math.max(me()-3,10))),Be((A)=>{var B=me(),D=h.bg.elevated,z=h.text.primary;return B!==A.e&&(A.e=j(x,"width",B,A.e)),D!==A.t&&(A.t=j(x,"backgroundColor",D,A.t)),z!==A.a&&(A.a=j(v,"fg",z,A.a)),A},{e:void 0,t:void 0,a:void 0}),x})(),(()=>{var x=ce("text");return ae(x,Te("Press Enter or Escape to try again")),Be((v)=>j(x,"fg",h.text.secondary,v)),x})()]}})]}})}var ol=$e(()=>{ht();bn();yn();ke();it();Ci();In();Rn();$s();Pi();ls();Lt();Fr()});import{createComponent as yo}from"@opentui/solid";import{effect as Ro}from"@opentui/solid";import{insert as _o}from"@opentui/solid";import{memo as Vh}from"@opentui/solid";import{createTextNode as Oo}from"@opentui/solid";import{insertNode as xt}from"@opentui/solid";import{setProp as Je}from"@opentui/solid";import{createElement as gt}from"@opentui/solid";import{useKeyboard as Kh,useTerminalDimensions as qh}from"@opentui/solid";function rl(){let e=mt(),t=Pt(),n=qh(),[o,r]=be(!1),[i,s]=be(""),[c,u]=be(!1),f=()=>{let d=t.worktrees()??[],b=e.selectedWorktreePath();if(b){let y=d.find((S)=>S.path===b);if(y)return y}return d[e.selectedWorktreeIndex()]},m=()=>{e.setShowRemove(!1),r(!1),s(""),u(!1)},l=async(d)=>{let b=f();if(!b){m();return}r(!0),s("Removing...");try{let y=Fe(),S=Wt(y,b.repoPath);if(S.postRemove.length>0)s("Running postRemove hooks..."),await Et(S.postRemove,{cwd:b.path,env:{OMW_BRANCH:b.branch??"",OMW_WORKTREE_PATH:b.path,OMW_REPO_PATH:b.repoPath}}).catch(()=>{});await ee.remove(b.path,{force:d},b.repoPath),s("Removed successfully!"),So.success("Worktree removed");let P=t.worktrees()??[],E=e.selectedWorktreeIndex(),I=P[E-1]??P[E+1]??null;if(E>0)e.setSelectedWorktreeIndex(E-1);else e.setSelectedWorktreeIndex(0);e.setSelectedWorktreePath(I?.path??null),t.refetch(),setTimeout(m,1000)}catch(y){let S=y.message;if(!d&&S.includes("dirty"))s("Worktree has changes. Press Enter to force remove."),r(!1),u(!0);else s(`Failed: ${S}`),r(!1),So.error(`Failed: ${S}`)}};Kh(async(d)=>{if(!e.showRemove())return;if(e.showCommandPalette())return;let b=d.name;if(b==="escape"){m();return}if(c()&&(b==="return"||b==="enter")){u(!1),await l(!0);return}if((b==="return"||b==="enter")&&!o())await l(!1)});let p=()=>f(),R=()=>Math.max(50,Math.min(80,n().width-4)),M=()=>10;return yo(io,{get width(){return R()},get height(){return M()},get borderColor(){return h.border.active},get backgroundColor(){return h.bg.elevated},gap:1,title:" Remove Worktree ",backdrop:!0,get footer(){return(()=>{var d=gt("box");return Je(d,"flexDirection","column"),_o(d,yo(te,{get when(){return Vh(()=>!o())()&&!c()},get children(){var b=gt("box"),y=gt("text"),S=gt("text");return xt(b,y),xt(b,S),Je(b,"height",1),Je(b,"flexDirection","row"),Je(b,"gap",2),xt(y,Oo("[Enter] Confirm")),xt(S,Oo("[Esc] Cancel")),Ro((P)=>{var E=h.text.secondary,I=h.text.secondary;return E!==P.e&&(P.e=Je(y,"fg",E,P.e)),I!==P.t&&(P.t=Je(S,"fg",I,P.t)),P},{e:void 0,t:void 0}),b}}),null),_o(d,yo(te,{get when(){return c()},get children(){var b=gt("box"),y=gt("text"),S=gt("text");return xt(b,y),xt(b,S),Je(b,"height",1),Je(b,"flexDirection","row"),Je(b,"gap",2),xt(y,Oo("[Enter] Force remove")),xt(S,Oo("[Esc] Cancel")),Ro((P)=>{var E=h.text.secondary,I=h.text.secondary;return E!==P.e&&(P.e=Je(y,"fg",E,P.e)),I!==P.t&&(P.t=Je(S,"fg",I,P.t)),P},{e:void 0,t:void 0}),b}}),null),d})()},get children(){return[yo(te,{get when(){return!!p()},get children(){return[(()=>{var d=gt("box"),b=gt("box"),y=gt("text"),S=gt("text");return xt(d,b),xt(d,S),Je(d,"height",1),Je(d,"flexDirection","row"),xt(b,y),Je(b,"width",10),Je(b,"height",1),xt(y,Oo("Branch")),_o(S,()=>p()?.branch??"(detached)"),Ro((P)=>{var E=h.text.secondary,I=h.text.accent;return E!==P.e&&(P.e=Je(y,"fg",E,P.e)),I!==P.t&&(P.t=Je(S,"fg",I,P.t)),P},{e:void 0,t:void 0}),d})(),(()=>{var d=gt("box"),b=gt("box"),y=gt("text"),S=gt("text");return xt(d,b),xt(d,S),Je(d,"height",1),Je(d,"flexDirection","row"),xt(b,y),Je(b,"width",10),Je(b,"height",1),xt(y,Oo("Path")),_o(S,()=>p()?.path),Ro((P)=>{var E=h.text.secondary,I=h.text.primary;return E!==P.e&&(P.e=Je(y,"fg",E,P.e)),I!==P.t&&(P.t=Je(S,"fg",I,P.t)),P},{e:void 0,t:void 0}),d})(),yo(te,{get when(){return c()},get children(){var d=gt("text");return _o(d,i),Ro((b)=>Je(d,"fg",h.text.warning,b)),d}}),yo(te,{get when(){return o()},get children(){var d=gt("text");return _o(d,i),Ro((b)=>Je(d,"fg",i().startsWith("Failed")?h.text.error:h.text.success,b)),d}})]}}),yo(te,{get when(){return!p()},get children(){var d=gt("text");return xt(d,Oo("No worktree selected.")),Ro((b)=>Je(d,"fg",h.text.secondary,b)),d}})]}})}var il=$e(()=>{ht();bn();yn();ke();it();In();ls();Lt();Fr()});import{createComponent as er}from"@opentui/solid";import{effect as Bn}from"@opentui/solid";import{insert as nn}from"@opentui/solid";import{createTextNode as sl}from"@opentui/solid";import{insertNode as Mt}from"@opentui/solid";import{setProp as ye}from"@opentui/solid";import{createElement as Ze}from"@opentui/solid";import{useKeyboard as Xh}from"@opentui/solid";function cl(e){let t=mt(),n=Pt(),o=Uo(),[r,i]=be("confirming"),[s,c]=be(""),[u,f]=be(0),m=()=>{let M=n.worktrees()??[],d=t.selectedWorktrees(),b=[];for(let y of d){let S=M.find((P)=>P.path===y);if(S&&!S.isMain)b.push({branch:S.branch??"(detached)",path:S.path,repoPath:S.repoPath})}return b},l=()=>{t.setShowBulkActions(!1),i("confirming"),c(""),f(0)},p=async()=>{let M=m();if(M.length===0){l();return}i("executing"),f(0);let d=[];for(let b=0;b<M.length;b++){let y=M[b];c(`Removing ${y.branch} (${b+1}/${M.length})...`),f(b);try{let S=Fe(),P=Wt(S,y.repoPath);if(P.postRemove.length>0)await Et(P.postRemove,{cwd:y.path,env:{OMW_BRANCH:y.branch,OMW_WORKTREE_PATH:y.path,OMW_REPO_PATH:y.repoPath}}).catch(()=>{});await ee.remove(y.path,{force:!1},y.repoPath)}catch(S){d.push(`${y.branch}: ${S.message}`)}}if($t(),t.clearSelection(),t.setSelectedWorktreeIndex(0),t.setSelectedWorktreePath(null),n.refetch(),d.length>0)i("error"),c(`Failed: ${d.join("; ")}`),o.addToast({message:`Failed to remove ${d.length} worktree(s)`,type:"error"}),setTimeout(l,3000);else i("done"),c(`Removed ${M.length} worktree(s) successfully!`),o.addToast({message:`Removed ${M.length} worktrees`,type:"success"}),setTimeout(l,1500)};Xh(async(M)=>{if(!t.showBulkActions())return;if(t.showCommandPalette())return;let d=M.name;if(r()==="executing")return;if(d==="escape"){l();return}if((d==="return"||d==="enter")&&r()==="confirming")await p()});let R=()=>m().length;return(()=>{var M=Ze("box"),d=Ze("box"),b=Ze("box"),y=Ze("text"),S=Ze("box"),P=Ze("text"),E=Ze("box");return Mt(M,d),ye(M,"x",0),ye(M,"y",0),Mt(d,b),Mt(d,S),Mt(d,E),ye(d,"x",2),ye(d,"y",1),ye(d,"flexDirection","column"),Mt(b,y),ye(b,"height",1),Mt(y,sl("Bulk Delete Worktrees")),ye(y,"x",0),ye(y,"y",0),Mt(S,P),ye(S,"height",1),ye(P,"x",0),ye(P,"y",0),nn(P,()=>"\u2500".repeat(Math.max(e.w-5,10))),ye(E,"height",1),nn(d,er(te,{get when(){return r()==="confirming"},get children(){return[(()=>{var I=Ze("box"),V=Ze("text");return Mt(I,V),ye(I,"height",1),ye(V,"x",0),ye(V,"y",0),nn(V,()=>`Delete ${R()} worktree(s)?`),Bn((T)=>ye(V,"fg",h.text.warning,T)),I})(),(()=>{var I=Ze("box");return ye(I,"height",1),I})(),er(ft,{get each(){return m().slice(0,Math.max(e.h-10,5))},children:(I)=>(()=>{var V=Ze("box"),T=Ze("text");return Mt(V,T),ye(V,"height",1),ye(T,"x",2),ye(T,"y",0),nn(T,()=>`\u2022 ${I.branch}`),Bn((H)=>ye(T,"fg",h.text.accent,H)),V})()}),er(te,{get when(){return R()>Math.max(e.h-10,5)},get children(){var I=Ze("box"),V=Ze("text");return Mt(I,V),ye(I,"height",1),ye(V,"x",2),ye(V,"y",0),nn(V,()=>`... and ${R()-Math.max(e.h-10,5)} more`),Bn((T)=>ye(V,"fg",h.text.secondary,T)),I}}),(()=>{var I=Ze("box");return ye(I,"height",1),I})(),(()=>{var I=Ze("box"),V=Ze("text");return Mt(I,V),ye(I,"height",1),Mt(V,sl("Enter:delete all Esc:cancel")),ye(V,"x",0),ye(V,"y",0),Bn((T)=>ye(V,"fg",h.text.secondary,T)),I})()]}}),null),nn(d,er(te,{get when(){return r()==="executing"},get children(){return[(()=>{var I=Ze("box"),V=Ze("text");return Mt(I,V),ye(I,"height",1),ye(V,"x",0),ye(V,"y",0),nn(V,s),Bn((T)=>ye(V,"fg",h.text.warning,T)),I})(),(()=>{var I=Ze("box"),V=Ze("text");return Mt(I,V),ye(I,"height",1),ye(V,"x",0),ye(V,"y",0),nn(V,()=>`Progress: ${u()+1}/${R()}`),Bn((T)=>ye(V,"fg",h.text.secondary,T)),I})()]}}),null),nn(d,er(te,{get when(){return r()==="done"},get children(){var I=Ze("box"),V=Ze("text");return Mt(I,V),ye(I,"height",1),ye(V,"x",0),ye(V,"y",0),nn(V,s),Bn((T)=>ye(V,"fg",h.text.success,T)),I}}),null),nn(d,er(te,{get when(){return r()==="error"},get children(){var I=Ze("box"),V=Ze("text");return Mt(I,V),ye(I,"height",1),ye(V,"x",0),ye(V,"y",0),nn(V,s),Bn((T)=>ye(V,"fg",h.text.error,T)),I}}),null),Bn((I)=>{var{w:V,h:T}=e,H=h.bg.base,Q=e.w-3,he=e.h-2,G=h.bg.base,F=h.text.error,N=h.border.subtle;return V!==I.e&&(I.e=ye(M,"width",V,I.e)),T!==I.t&&(I.t=ye(M,"height",T,I.t)),H!==I.a&&(I.a=ye(M,"backgroundColor",H,I.a)),Q!==I.o&&(I.o=ye(d,"width",Q,I.o)),he!==I.i&&(I.i=ye(d,"height",he,I.i)),G!==I.n&&(I.n=ye(d,"backgroundColor",G,I.n)),F!==I.s&&(I.s=ye(y,"fg",F,I.s)),N!==I.h&&(I.h=ye(P,"fg",N,I.h)),I},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),M})()}var al=$e(()=>{ht();bn();Mr();yn();ke();it();In();Lt()});import{memo as ll}from"@opentui/solid";import{createComponent as tr}from"@opentui/solid";import{effect as so}from"@opentui/solid";import{insert as Dt}from"@opentui/solid";import{createTextNode as He}from"@opentui/solid";import{insertNode as le}from"@opentui/solid";import{setProp as ue}from"@opentui/solid";import{createElement as Se}from"@opentui/solid";import{useKeyboard as Zh,useTerminalDimensions as Qh}from"@opentui/solid";import{spawnSync as Yh}from"child_process";function fl(){let e=mt(),t=Qh(),n=Vt(),o=()=>{try{return Fe()}catch{return null}},[r,i]=be(o()),[s,c]=be("");Zh((m)=>{if(e.activeTab()!=="config")return;if(e.showCommandPalette())return;let l=m.name;if(l==="e"){let p=process.env.EDITOR??process.env.VISUAL??"vi";Pn(),Yh(p,[n],{stdio:"inherit"}),i(o()),c("Config reloaded"),setTimeout(()=>c(""),2000)}if(l==="r")i(o()),c("Reloaded"),setTimeout(()=>c(""),2000);if(l==="i")Pn(),i(o()),c("Config initialized"),setTimeout(()=>c(""),2000)});let u=()=>t().width,f=()=>t().height;return(()=>{var m=Se("box"),l=Se("box"),p=Se("box"),R=Se("text"),M=Se("b"),d=Se("box"),b=Se("text"),y=Se("text"),S=Se("box"),P=Se("box"),E=Se("text"),I=Se("text"),V=Se("box"),T=Se("text"),H=Se("text"),Q=Se("box"),he=Se("text"),G=Se("text");return le(m,l),le(m,S),ue(m,"x",0),ue(m,"y",0),ue(m,"width","100%"),ue(m,"height","100%"),ue(m,"flexDirection","column"),le(l,p),le(l,d),ue(l,"width","100%"),ue(l,"height","100%"),ue(l,"flexDirection","column"),ue(l,"paddingX",2),ue(l,"paddingY",1),le(p,R),ue(p,"height",1),le(R,M),le(M,He("Configuration")),le(d,b),le(d,y),ue(d,"flexDirection","row"),ue(d,"gap",1),le(b,He("Path:")),Dt(y,n),Dt(l,tr(te,{get when(){return!r()},get children(){var F=Se("box"),N=Se("text"),K=Se("box"),k=Se("text"),ge=Se("text"),re=Se("text");return le(F,N),le(F,K),ue(F,"flexDirection","column"),ue(F,"gap",1),le(N,He("No config file found.")),le(K,k),le(K,ge),le(K,re),ue(K,"flexDirection","row"),ue(K,"gap",1),le(k,He("Press")),le(ge,He("i")),le(re,He("to initialize with defaults.")),so((me)=>{var x=h.text.warning,v=h.text.secondary,A=h.text.accent,B=h.text.secondary;return x!==me.e&&(me.e=ue(N,"fg",x,me.e)),v!==me.t&&(me.t=ue(k,"fg",v,me.t)),A!==me.a&&(me.a=ue(ge,"fg",A,me.a)),B!==me.o&&(me.o=ue(re,"fg",B,me.o)),me},{e:void 0,t:void 0,a:void 0,o:void 0}),F}}),null),Dt(l,tr(te,{get when(){return!!r()},get children(){return[(()=>{var F=Se("box"),N=Se("text"),K=Se("box"),k=Se("box"),ge=Se("text"),re=Se("text"),me=Se("box"),x=Se("box"),v=Se("text"),A=Se("text"),B=He("["),D=He("]"),z=Se("box"),se=Se("box"),J=Se("text"),_=Se("text"),Me=He("["),fe=He("]"),pe=Se("box"),De=Se("box"),Ce=Se("text"),O=Se("text"),a=He("["),w=He("]");return le(F,N),le(F,K),le(F,me),le(F,z),le(F,pe),ue(F,"flexDirection","column"),ue(F,"gap",1),le(N,He("Defaults")),le(K,k),le(K,re),ue(K,"flexDirection","row"),le(k,ge),ue(k,"width",14),le(ge,He("worktreeDir")),Dt(re,()=>r()?.defaults?.worktreeDir??"../{repo}-{branch}"),le(me,x),le(me,A),ue(me,"flexDirection","row"),le(x,v),ue(x,"width",14),le(v,He("copyFiles")),le(A,B),le(A,D),Dt(A,()=>(r()?.defaults?.copyFiles??[]).join(", "),D),le(z,se),le(z,_),ue(z,"flexDirection","row"),le(se,J),ue(se,"width",14),le(J,He("linkFiles")),le(_,Me),le(_,fe),Dt(_,()=>(r()?.defaults?.linkFiles??[]).join(", "),fe),le(pe,De),le(pe,O),ue(pe,"flexDirection","row"),le(De,Ce),ue(De,"width",14),le(Ce,He("postCreate")),le(O,a),le(O,w),Dt(O,()=>(r()?.defaults?.postCreate??[]).join(", "),w),so((L)=>{var W=h.text.accent,C=h.text.secondary,q=h.text.primary,X=h.text.secondary,U=h.text.primary,Ne=h.text.secondary,Ue=h.text.primary,sn=h.text.secondary,cn=h.text.primary;return W!==L.e&&(L.e=ue(N,"fg",W,L.e)),C!==L.t&&(L.t=ue(ge,"fg",C,L.t)),q!==L.a&&(L.a=ue(re,"fg",q,L.a)),X!==L.o&&(L.o=ue(v,"fg",X,L.o)),U!==L.i&&(L.i=ue(A,"fg",U,L.i)),Ne!==L.n&&(L.n=ue(J,"fg",Ne,L.n)),Ue!==L.s&&(L.s=ue(_,"fg",Ue,L.s)),sn!==L.h&&(L.h=ue(Ce,"fg",sn,L.h)),cn!==L.r&&(L.r=ue(O,"fg",cn,L.r)),L},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),F})(),(()=>{var F=Se("box"),N=Se("text");return le(F,N),Dt(N,()=>"\u2500".repeat(Math.max(u()-34,10))),so((K)=>ue(N,"fg",h.border.subtle,K)),F})(),tr(te,{get when(){return(r()?.repos?.length??0)>0},get children(){var F=Se("box"),N=Se("text"),K=He("Repos ("),k=He(")");return le(F,N),ue(F,"flexDirection","column"),ue(F,"gap",1),le(N,K),le(N,k),Dt(N,()=>r()?.repos?.length,k),Dt(F,tr(ft,{get each(){return r()?.repos?.slice(0,4)},children:(ge)=>(()=>{var re=Se("box"),me=Se("text"),x=Se("box"),v=Se("box"),A=Se("text"),B=Se("text"),D=Se("box"),z=Se("box"),se=Se("text"),J=Se("text");return le(re,me),le(re,x),le(re,D),ue(re,"flexDirection","column"),ue(re,"gap",0),Dt(me,()=>ge.path.split("/").pop()??ge.path),le(x,v),le(x,B),ue(x,"flexDirection","row"),le(v,A),ue(v,"width",11),le(A,He("copyFiles")),Dt(B,(()=>{var _=ll(()=>(ge.copyFiles??[]).length>0);return()=>_()?(ge.copyFiles??[]).join(", "):"\u2014"})()),le(D,z),le(D,J),ue(D,"flexDirection","row"),le(z,se),ue(z,"width",11),le(se,He("postCreate")),Dt(J,(()=>{var _=ll(()=>(ge.postCreate??[]).length>0);return()=>_()?(ge.postCreate??[]).join(", "):"\u2014"})()),so((_)=>{var Me=h.text.primary,fe=h.text.secondary,pe=h.text.primary,De=h.text.secondary,Ce=h.text.primary;return Me!==_.e&&(_.e=ue(me,"fg",Me,_.e)),fe!==_.t&&(_.t=ue(A,"fg",fe,_.t)),pe!==_.a&&(_.a=ue(B,"fg",pe,_.a)),De!==_.o&&(_.o=ue(se,"fg",De,_.o)),Ce!==_.i&&(_.i=ue(J,"fg",Ce,_.i)),_},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),re})()}),null),so((ge)=>ue(N,"fg",h.text.accent,ge)),F}}),tr(te,{get when(){return(r()?.repos?.length??0)===0},get children(){var F=Se("text");return le(F,He("No per-repo configs defined.")),so((N)=>ue(F,"fg",h.text.secondary,N)),F}})]}}),null),Dt(l,tr(te,{get when(){return!!s()},get children(){var F=Se("text");return Dt(F,s),so((N)=>ue(F,"fg",h.text.success,N)),F}}),null),le(S,P),le(S,V),le(S,Q),ue(S,"width","100%"),ue(S,"height",1),ue(S,"flexDirection","row"),ue(S,"gap",2),le(P,E),le(P,I),ue(P,"flexDirection","row"),le(E,He("e")),le(I,He(":edit")),le(V,T),le(V,H),ue(V,"flexDirection","row"),le(T,He("r")),le(H,He(":reload")),le(Q,he),le(Q,G),ue(Q,"flexDirection","row"),le(he,He("i")),le(G,He(":init")),so((F)=>{var N=h.bg.base,K=h.bg.surface,k=h.text.accent,ge=h.text.secondary,re=h.text.primary,me=h.bg.base,x=h.text.secondary,v=h.text.primary,A=h.text.secondary,B=h.text.primary,D=h.text.secondary,z=h.text.primary;return N!==F.e&&(F.e=ue(m,"backgroundColor",N,F.e)),K!==F.t&&(F.t=ue(l,"backgroundColor",K,F.t)),k!==F.a&&(F.a=ue(R,"fg",k,F.a)),ge!==F.o&&(F.o=ue(b,"fg",ge,F.o)),re!==F.i&&(F.i=ue(y,"fg",re,F.i)),me!==F.n&&(F.n=ue(S,"backgroundColor",me,F.n)),x!==F.s&&(F.s=ue(E,"fg",x,F.s)),v!==F.h&&(F.h=ue(I,"fg",v,F.h)),A!==F.r&&(F.r=ue(T,"fg",A,F.r)),B!==F.d&&(F.d=ue(H,"fg",B,F.d)),D!==F.l&&(F.l=ue(he,"fg",D,F.l)),z!==F.u&&(F.u=ue(G,"fg",z,F.u)),F},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0}),m})()}var ul=$e(()=>{ht();bn();it();Lt()});import{existsSync as or,readdirSync as _h,rmSync as em}from"fs";import{basename as Ss,dirname as Es,join as tm,resolve as nr}from"path";function nm(e){let t=Bun.env.HOME??"~";return e.replace(/^~(?=\/|$)/,t)}function dl(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ml(e){if(!or(Vt()))return[];let t=e.find((c)=>c.isMain);if(!t)return[];let n=Fe(),o=nr(t.path),r=Ss(o);return[n.repos?.find((c)=>nr(c.path)===o)?.worktreeDir??n.defaults?.worktreeDir].filter((c)=>typeof c==="string").map((c)=>nm(c)).filter((c)=>!Es(c).includes("{")&&Ss(c).includes("{")).map((c)=>{let u=Ss(c),f=`^${dl(u).replace(/\\\{repo\\\}/g,dl(r)).replace(/\\\{branch\\\}/g,".+")}$`,m=new RegExp(f);return{path:nr(Es(c)),matches:(l)=>m.test(l)}})}function pl(e){let t=new Set;for(let n of e)if(!n.isMain)t.add(nr(Es(n.path)));return[...t]}function hl(e,t,n,o){if(!or(e))return;let r=_h(e,{withFileTypes:!0});for(let i of r){if(!i.isDirectory())continue;if(o&&!o(i.name))continue;let s=nr(tm(e,i.name));if(!t.has(s))n.add(s)}}function gl(e){let t=new Set(e.map((r)=>nr(r.path))),n=new Set,o=new Set;for(let r of ml(e))o.add(r.path),hl(r.path,t,n,r.matches);for(let r of pl(e)){if(o.has(r))continue;hl(r,t,n)}return[...n]}function om(e){return ml(e).some((t)=>or(t.path))||pl(e).some((t)=>or(t))}async function rm(){let e=Bun.spawn(["git","--version"],{stdout:"pipe",stderr:"pipe",env:{...Bun.env,LC_ALL:"C",LANG:"C"}}),[t,n]=await Promise.all([new Response(e.stdout).text(),e.exited]);if(n!==0)return null;return t.trim().match(/git version (\d+\.\d+(?:\.\d+)?)/)?.[1]??null}async function im(){try{return await ee.checkVersion(),{name:"Git version",status:"pass",message:`${await rm()??"unknown"} (>= 2.17 required)`}}catch(t){if(t instanceof $r)return{name:"Git version",status:"fail",message:t.message};return{name:"Git version",status:"fail",message:`Check failed: ${t.message}`}}}async function sm(){try{let n=(Fe().repos??[]).map((o)=>o.path).filter((o)=>!or(o));if(n.length>0)return{name:"Configuration",status:"warn",message:"missing repository paths",detail:n};return{name:"Configuration",status:"pass",message:"valid"}}catch(t){return{name:"Configuration",status:"fail",message:`Check failed: ${t.message}`}}}function cm(e){let n=e.map((o)=>o.path).filter((o)=>!or(o));if(n.length>0)return{name:"Stale worktrees",status:"warn",message:"missing worktree paths",detail:n};return{name:"Stale worktrees",status:"pass",message:"none"}}function am(e){try{let n=gl(e);if(n.length===0)return{name:"Orphaned directories",status:"pass",message:om(e)?"none":"no worktree directory"};return{name:"Orphaned directories",status:"warn",message:"orphaned worktree directories found",detail:n}}catch(n){return{name:"Orphaned directories",status:"fail",message:`Check failed: ${n.message}`}}}function lm(e){let n=e.filter((r)=>r.isLocked);if(n.length===0)return{name:"Worktree locks",status:"pass",message:"all clear"};return{name:"Worktree locks",status:"warn",message:"locked worktrees present",detail:n.map((r)=>{let i=r.branch??"detached";if(!r.lockReason)return`${i} - ${r.path} (potential stale lock: no reason)`;return`${i} - ${r.path} (reason: ${r.lockReason})`})}}function fm(e){let n=e.filter((o)=>o.isDirty&&!o.isMain);if(n.length===0)return{name:"Dirty worktrees",status:"pass",message:"none"};return{name:"Dirty worktrees",status:"warn",message:"dirty non-main worktrees found",detail:n.map((o)=>`${o.branch??"detached"} - ${o.path}`)}}async function rr(e){let t=await ee.list(e).catch(()=>[]),n=[await im(),await sm(),cm(t),am(t),lm(t),fm(t)];return{checks:n,healthy:n.every((o)=>o.status==="pass")}}async function um(e){try{return await ee.prune(e),{action:"Prune stale worktrees",success:!0}}catch(t){return{action:"Prune stale worktrees",success:!1,detail:t.message}}}async function dm(e){let t=[];try{let n=gl(await ee.list(e).catch(()=>[]));for(let o of n)try{em(o,{recursive:!0,force:!0}),t.push({action:"Remove orphaned directory",success:!0,detail:o})}catch(r){t.push({action:"Remove orphaned directory",success:!1,detail:`${o}: ${r.message}`})}}catch(n){t.push({action:"Remove orphaned directories",success:!1,detail:n.message})}return t}async function hm(e){let t=[];try{let o=(await ee.list(e)).filter((r)=>r.isLocked&&!r.lockReason);for(let r of o)try{await ee.unlock(r.path,e),t.push({action:"Unlock stale lock",success:!0,detail:`${r.branch??"detached"} - ${r.path}`})}catch(i){t.push({action:"Unlock stale lock",success:!1,detail:`${r.path}: ${i.message}`})}}catch(n){t.push({action:"Fix stale locks",success:!1,detail:n.message})}return t}async function Si(e){let t=[];return t.push(await um(e)),t.push(...await dm(e)),t.push(...await hm(e)),t}var Ms=$e(()=>{it();ke();fn()});import{insert as At}from"@opentui/solid";import{setProp as je}from"@opentui/solid";import{effect as Tt}from"@opentui/solid";import{createTextNode as Sn}from"@opentui/solid";import{insertNode as wt}from"@opentui/solid";import{createElement as tt}from"@opentui/solid";import{createComponent as mn}from"@opentui/solid";import{memo as Br}from"@opentui/solid";import{useKeyboard as mm,useTerminalDimensions as pm}from"@opentui/solid";function wl(){let e=mt(),t=pm(),[n,o]=be(null),[r,i]=be(!0),[s,c]=be(""),[u,f]=be(!1),[m,l]=be([]),p=async()=>{i(!0),c(""),l([]);try{let T=await rr();o(T)}catch(T){c(T.message)}i(!1)},R=async()=>{if(n()?.healthy)return;f(!0);try{let T=await Si();l(T);let H=await rr();o(H)}catch(T){c(T.message)}f(!1)};p(),mm((T)=>{if(e.activeTab()!=="doctor")return;if(e.showCommandPalette())return;let H=T.name;if(H==="r")p();if(H==="f"&&!r()&&!u()&&!n()?.healthy)R()});let M=()=>t().width,d=()=>t().height,b=()=>Math.max(50,Math.min(80,M()-4)),y=()=>{let T=I()+V()+8+(V()>0?2:0);return Math.max(12,Math.min(T,d()-4))},S=()=>Math.max(b()-4,10),P=(T)=>{if(T==="pass")return"\u2713";if(T==="warn")return"\u26A0";return"\u2717"},E=(T)=>{if(T==="pass")return h.text.success;if(T==="warn")return h.text.warning;return h.text.error},I=()=>n()?.checks.length??0,V=()=>m().length;return mn(io,{get width(){return b()},get height(){return y()},get borderColor(){return Br(()=>!!n()?.healthy)()?h.text.success:Br(()=>!!n())()?h.text.warning:h.border.default},get backgroundColor(){return h.bg.surface},title:" Doctor ",get footer(){return[(()=>{var T=tt("box"),H=tt("text");return wt(T,H),je(T,"height",1),At(H,()=>"\u2500".repeat(Math.max(S(),1))),Tt((Q)=>{var he=S(),G=h.border.subtle;return he!==Q.e&&(Q.e=je(T,"width",he,Q.e)),G!==Q.t&&(Q.t=je(H,"fg",G,Q.t)),Q},{e:void 0,t:void 0}),T})(),(()=>{var T=tt("box"),H=tt("text"),Q=tt("text");return wt(T,H),wt(T,Q),je(T,"flexDirection","row"),je(T,"gap",2),wt(H,Sn("r:recheck")),At(T,mn(te,{get when(){return!n()?.healthy},get children(){var he=tt("text");return wt(he,Sn("f:fix")),Tt((G)=>je(he,"fg",h.text.secondary,G)),he}}),Q),wt(Q,Sn("Esc:back")),Tt((he)=>{var G=h.text.secondary,F=h.text.secondary;return G!==he.e&&(he.e=je(H,"fg",G,he.e)),F!==he.t&&(he.t=je(Q,"fg",F,he.t)),he},{e:void 0,t:void 0}),T})()]},get children(){return[mn(te,{get when(){return r()},get children(){return mn(Jo,{label:"Running checks..."})}}),mn(te,{get when(){return u()},get children(){var T=tt("text");return wt(T,Sn("Running auto-fix...")),Tt((H)=>je(T,"fg",h.text.accent,H)),T}}),mn(te,{get when(){return Br(()=>!r()&&!u())()&&!!s()},get children(){var T=tt("text"),H=Sn("Error: ");return wt(T,H),At(T,s,null),Tt((Q)=>je(T,"fg",h.text.error,Q)),T}}),mn(te,{get when(){return Br(()=>!r()&&!u()&&!s())()&&!!n()},get children(){return[(()=>{var T=tt("text");return wt(T,Sn("Health Checks")),Tt((H)=>je(T,"fg",h.text.accent,H)),T})(),(()=>{var T=tt("text");return At(T,()=>"\u2500".repeat(S())),Tt((H)=>je(T,"fg",h.border.subtle,H)),T})(),mn(ft,{get each(){return n().checks},children:(T)=>{return(()=>{var H=tt("box"),Q=tt("text"),he=tt("text"),G=Sn(":"),F=tt("text");return wt(H,Q),wt(H,he),wt(H,F),je(H,"width","100%"),je(H,"height",1),je(H,"flexDirection","row"),At(Q,()=>P(T.status)),wt(he,G),je(he,"x",2),je(he,"y",0),At(he,()=>T.name,G),je(F,"y",0),At(F,()=>T.message),Tt((N)=>{var K=E(T.status),k=h.text.primary,ge=T.name.length+4,re=h.text.secondary;return K!==N.e&&(N.e=je(Q,"fg",K,N.e)),k!==N.t&&(N.t=je(he,"fg",k,N.t)),ge!==N.a&&(N.a=je(F,"x",ge,N.a)),re!==N.o&&(N.o=je(F,"fg",re,N.o)),N},{e:void 0,t:void 0,a:void 0,o:void 0}),H})()}}),(()=>{var T=tt("text");return At(T,()=>"\u2500".repeat(S())),Tt((H)=>je(T,"fg",h.border.subtle,H)),T})(),(()=>{var T=tt("text");return At(T,(()=>{var H=Br(()=>!!n().healthy);return()=>H()?"\u2713 All checks passed":`${n().checks.filter((Q)=>Q.status==="fail").length} error(s), ${n().checks.filter((Q)=>Q.status==="warn").length} warning(s) found`})()),Tt((H)=>je(T,"fg",n().healthy?h.text.success:h.text.warning,H)),T})(),mn(te,{get when(){return V()>0},get children(){return[(()=>{var T=tt("text");return wt(T,Sn("Fix Results")),Tt((H)=>je(T,"fg",h.text.accent,H)),T})(),(()=>{var T=tt("text");return At(T,()=>"\u2500".repeat(S())),Tt((H)=>je(T,"fg",h.border.subtle,H)),T})(),mn(ft,{get each(){return m()},children:(T)=>{return(()=>{var H=tt("box"),Q=tt("text"),he=tt("text");return wt(H,Q),wt(H,he),je(H,"width","100%"),je(H,"height",1),je(H,"flexDirection","row"),At(Q,()=>T.success?"\u2713":"\u2717"),je(he,"x",2),je(he,"y",0),At(he,()=>T.action),At(H,mn(te,{get when(){return!!T.detail},get children(){var G=tt("text"),F=Sn("("),N=Sn(")");return wt(G,F),wt(G,N),je(G,"y",0),At(G,()=>T.detail,N),Tt((K)=>{var k=T.action.length+3,ge=h.text.secondary;return k!==K.e&&(K.e=je(G,"x",k,K.e)),ge!==K.t&&(K.t=je(G,"fg",ge,K.t)),K},{e:void 0,t:void 0}),G}}),null),Tt((G)=>{var F=T.success?h.text.success:h.text.error,N=h.text.primary;return F!==G.e&&(G.e=je(Q,"fg",F,G.e)),N!==G.t&&(G.t=je(he,"fg",N,G.t)),G},{e:void 0,t:void 0}),H})()}})]}})]}})]}})}var xl=$e(()=>{ht();bn();Ms();Lt();Fr();mi()});var Cl={};Ye(Cl,{writePin:()=>Rs,removePin:()=>Os,readPin:()=>Ar,listPinnedWorktrees:()=>Ws,isPinned:()=>co});import{readFileSync as bl,writeFileSync as gm,unlinkSync as wm,mkdirSync as xm,existsSync as ys}from"fs";import{join as bm,dirname as vl}from"path";function Lr(e){return Cn(e,"omw-pin")}function vm(e){let t=Lr(e),n=vl(t),o=bm(n,"HEAD"),r=bl(o,"utf-8").trim(),i=r.match(/^ref:\s+refs\/heads\/(.+)$/);return i?i[1]:r}function Rs(e,t){let n=Lr(e),o={branch:vm(e),pinnedAt:new Date().toISOString(),...t?{reason:t}:{}};xm(vl(n),{recursive:!0}),gm(n,JSON.stringify(o),{encoding:"utf-8",mode:384})}function Ar(e){let t=Lr(e);if(!ys(t))return null;return JSON.parse(bl(t,"utf-8"))}function Os(e){let t=Lr(e);if(!ys(t))return;wm(t)}function co(e){return ys(Lr(e))}function Ws(e){return e.filter((t)=>co(t.path))}var ir=$e(()=>{Yn()});import{insert as Ln}from"@opentui/solid";import{createComponent as Wo}from"@opentui/solid";import{effect as An}from"@opentui/solid";import{createTextNode as Tr}from"@opentui/solid";import{insertNode as pn}from"@opentui/solid";import{setProp as Le}from"@opentui/solid";import{createElement as Ft}from"@opentui/solid";import{useKeyboard as Cm}from"@opentui/solid";function $l(){let e=mt(),t=Pt(),n=()=>t.worktrees()??[],o=()=>e.selectedWorktreeIndex(),r=(m)=>{let l=Math.max(0,Math.min(m,Math.max(n().length-1,0))),p=n()[l];e.setSelectedWorktreeIndex(l),e.setSelectedWorktreePath(p?.path??null)},i=Ot(()=>{let m=n(),l=[],p=new Map;for(let d of m){let b=p.get(d.repoName);if(b)b.push(d);else p.set(d.repoName,[d])}let R=0,M=!0;for(let[d,b]of p){if(!M)l.push({type:"separator"});M=!1,l.push({type:"header",repoName:d});for(let y of b)l.push({type:"worktree",wt:y,flatIdx:R}),R++}return l}),s=()=>e.selectedWorktrees().size;Cm((m)=>{if(e.activeTab()!=="list")return;if(e.showCommandPalette())return;if(e.showRemove())return;if(e.showBulkActions())return;if(e.inputFocused())return;let l=m.name,p=n();if(l==="j"||l==="down")r(Math.min(o()+1,p.length-1));if(l==="k"||l==="up")r(Math.max(o()-1,0));if(l==="space"){let R=o(),M=p[R];if(M&&!M.isMain)e.toggleWorktreeSelection(M.path)}if(m.ctrl&&l==="a")e.selectAllNonMain(p.filter((R)=>!R.isMain).map((R)=>R.path))});let c=(m)=>{if(m.isLocked)return"\uD83D\uDD12";if(m.isDirty)return"\u25CF";return"\u2713"},u=(m)=>{if(m.isLocked)return h.text.warning;if(m.isDirty)return h.text.error;return h.text.success},f=(m,l)=>{let p=m.branch??"(detached)",R=Math.max(8,Ds-(l?9:7));return p.length>R?p.slice(0,R-1)+"\u2026":p};return(()=>{var m=Ft("box");return Le(m,"x",0),Le(m,"y",0),Le(m,"width","100%"),Le(m,"height","100%"),Le(m,"flexDirection","column"),Le(m,"paddingX",1),Le(m,"paddingY",1),Le(m,"gap",0),Ln(m,Wo(te,{get when(){return t.loading()},get children(){var l=Ft("text");return pn(l,Tr("Loading...")),An((p)=>Le(l,"fg",h.text.secondary,p)),l}}),null),Ln(m,Wo(te,{get when(){return!t.loading()},get children(){return[Wo(ft,{get each(){return i()},children:(l)=>{if(l.type==="header")return(()=>{var d=Ft("box"),b=Ft("text"),y=Ft("b");return pn(d,b),Le(d,"width","100%"),Le(d,"height",1),pn(b,y),Ln(y,()=>l.repoName),An((S)=>Le(b,"fg",h.text.accent,S)),d})();if(l.type==="separator")return(()=>{var d=Ft("box"),b=Ft("text");return pn(d,b),Le(d,"width","100%"),Le(d,"height",1),pn(b,Tr("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),An((y)=>Le(b,"fg",h.border.subtle,y)),d})();let p=l.wt,R=()=>l.flatIdx===o(),M=()=>e.selectedWorktrees().has(p.path);return(()=>{var d=Ft("box"),b=Ft("text"),y=Ft("text");return pn(d,b),pn(d,y),Le(d,"width","100%"),Le(d,"height",1),Le(d,"paddingX",1),Le(d,"onMouseDown",()=>r(l.flatIdx)),Le(b,"x",0),Le(b,"y",0),Ln(b,()=>c(p)),Le(y,"x",2),Le(y,"y",0),Ln(y,()=>f(p,!1)),Ln(d,Wo(te,{get when(){return M()},get children(){var S=Ft("text");return pn(S,Tr("\u2713")),Le(S,"x",23),Le(S,"y",0),An((P)=>Le(S,"fg",h.text.accent,P)),S}}),null),Ln(d,Wo(te,{get when(){return!!tn(p.path)},get children(){var S=Ft("text");return pn(S,Tr("S")),Le(S,"y",0),An((P)=>{var E=Ds-(M()?3:1),I=h.text.accent;return E!==P.e&&(P.e=Le(S,"x",E,P.e)),I!==P.t&&(P.t=Le(S,"fg",I,P.t)),P},{e:void 0,t:void 0}),S}}),null),Ln(d,Wo(te,{get when(){return co(p.path)},get children(){var S=Ft("text");return pn(S,Tr("P")),Le(S,"y",0),An((P)=>{var E=Ds-(M()?5:3)+(tn(p.path)?0:2),I=h.text.warning;return E!==P.e&&(P.e=Le(S,"x",E,P.e)),I!==P.t&&(P.t=Le(S,"fg",I,P.t)),P},{e:void 0,t:void 0}),S}}),null),An((S)=>{var P=R()?h.select.focusedBg:M()?h.bg.elevated:h.bg.surface,E=u(p),I=R()?h.tab.active:h.text.primary;return P!==S.e&&(S.e=Le(d,"backgroundColor",P,S.e)),E!==S.t&&(S.t=Le(b,"fg",E,S.t)),I!==S.a&&(S.a=Le(y,"fg",I,S.a)),S},{e:void 0,t:void 0,a:void 0}),d})()}}),Wo(te,{get when(){return s()>0},get children(){var l=Ft("box"),p=Ft("text");return pn(l,p),Le(l,"width","100%"),Le(l,"height",1),Ln(p,()=>`Selected: ${s()}`),An((R)=>Le(p,"fg",h.text.accent,R)),l}})]}}),null),An((l)=>Le(m,"backgroundColor",h.bg.surface,l)),m})()}var Ds=24;var Pl=$e(()=>{ht();bn();yn();Lt();ir();eo()});import{createComponent as Fs}from"@opentui/solid";import{insert as sr}from"@opentui/solid";import{effect as Do}from"@opentui/solid";import{createTextNode as jr}from"@opentui/solid";import{insertNode as It}from"@opentui/solid";import{setProp as We}from"@opentui/solid";import{createElement as bt}from"@opentui/solid";import{useKeyboard as $m,usePaste as Pm,useTerminalDimensions as Sm}from"@opentui/solid";import{decodePasteBytes as Em}from"@opentui/core";function Sl(){let e=mt(),t=Pt(),n=Sm(),[o,r]=be(""),[i,s]=be(0);ni(()=>{e.setInputFocused(!0)}),en(()=>{e.setInputFocused(!1)});let c=()=>{let y=t.worktrees()??[],S=e.selectedWorktreePath();if(S){let P=y.find((E)=>E.path===S);if(P)return P}return y[e.selectedWorktreeIndex()]},u=()=>{let y=process.env.VISUAL||process.env.EDITOR;if(y)return y;let S=["code","cursor","vim","nvim","zed","subl","idea","webstorm"];for(let P of S)try{if(Bun.spawnSync(["which",P],{stdout:"pipe",stderr:"pipe"}).exitCode===0)return P}catch{}return null},f=Ot(()=>[{id:"add",label:"Add Worktree",description:"Create a new git worktree",action:()=>{e.setActiveTab("add"),e.setShowCommandPalette(!1)}},{id:"delete",label:"Delete Worktree",description:"Remove the selected worktree",action:()=>{let y=c();if(!y||y.isMain)return;e.setShowRemove(!0),e.setShowCommandPalette(!1)}},{id:"open-editor",label:"Open in Editor",description:"Open selected worktree in IDE",action:()=>{let y=c();if(!y)return;let S=u();if(!S)return;e.setShowCommandPalette(!1),Bun.spawn([S,y.path],{stdout:"inherit",stderr:"inherit"})}},{id:"refresh",label:"Refresh",description:"Reload worktree list",action:()=>{t.refetch(),e.setShowCommandPalette(!1)}},{id:"config",label:"Open Config",description:"View configuration",action:()=>{e.setActiveTab("config"),e.setShowCommandPalette(!1)}},{id:"doctor",label:"Run Doctor",description:"Check worktree health",action:()=>{e.setActiveTab("doctor"),e.setShowCommandPalette(!1)}},...ai.map((y)=>({id:`theme:${y}`,label:`Theme: ${Wa[y]}`,description:"Switch color theme",action:()=>{li(y);try{let S=Vt(),P={...Fe()};P.theme=y,Wr(S,JSON.stringify(P,null,2))}catch{}e.setShowCommandPalette(!1)}})),{id:"quit",label:"Quit",description:"Exit oh-my-worktree",action:()=>process.exit(0)}]),m=Ot(()=>{let y=o().toLowerCase();if(!y)return f();return f().filter((S)=>S.label.toLowerCase().includes(y)||S.description.toLowerCase().includes(y))});$m((y)=>{if(!e.showCommandPalette())return;let S=y.name;if(S==="escape"){e.setInputFocused(!1),e.setShowCommandPalette(!1),r(""),s(0);return}if(S==="return"||S==="enter"){let P=m()[i()];if(P)P.action();r(""),s(0);return}if(S==="down"||S==="j"){s((P)=>Math.min(P+1,m().length-1));return}if(S==="up"||S==="k"){s((P)=>Math.max(P-1,0));return}}),Pm((y)=>{if(!e.inputFocused())return;let S=Em(y.bytes).replace(/\r?\n/g,"");if(!S)return;r((P)=>P+S),s(0)});let l=(y)=>{r(y),s(0)},p=()=>Math.max(50,Math.min(80,n().width-4)),R=()=>Math.max(10,Math.min(m().length+8,n().height-4)),M=()=>p()-4,d=()=>Math.max(M()-2,1),b=()=>R()-8;return Fs(io,{get width(){return p()},get height(){return R()},get borderColor(){return h.border.active},get backgroundColor(){return h.bg.surface},title:" Command Palette ",get footer(){return[(()=>{var y=bt("box"),S=bt("text");return It(y,S),We(y,"height",1),sr(S,()=>"\u2500".repeat(Math.max(M(),1))),Do((P)=>{var E=M(),I=h.border.subtle;return E!==P.e&&(P.e=We(y,"width",E,P.e)),I!==P.t&&(P.t=We(S,"fg",I,P.t)),P},{e:void 0,t:void 0}),y})(),(()=>{var y=bt("box"),S=bt("text"),P=bt("text"),E=bt("text");return It(y,S),It(y,P),It(y,E),We(y,"flexDirection","row"),We(y,"gap",2),It(S,jr("\u2191\u2193:navigate")),It(P,jr("Enter:run")),It(E,jr("Esc:close")),Do((I)=>{var V=h.text.secondary,T=h.text.secondary,H=h.text.secondary;return V!==I.e&&(I.e=We(S,"fg",V,I.e)),T!==I.t&&(I.t=We(P,"fg",T,I.t)),H!==I.a&&(I.a=We(E,"fg",H,I.a)),I},{e:void 0,t:void 0,a:void 0}),y})()]},get children(){return[(()=>{var y=bt("box"),S=bt("text"),P=bt("input");return It(y,S),It(y,P),We(y,"height",1),We(y,"flexDirection","row"),It(S,jr("> ")),We(P,"onInput",l),We(P,"placeholder","Search commands..."),We(P,"focused",!0),Do((E)=>{var I=M(),V=h.bg.elevated,T=h.text.accent,H=o(),Q=d(),he=h.bg.elevated,G=h.text.primary,F=h.text.secondary,N=h.text.accent,K=h.bg.elevated;return I!==E.e&&(E.e=We(y,"width",I,E.e)),V!==E.t&&(E.t=We(y,"backgroundColor",V,E.t)),T!==E.a&&(E.a=We(S,"fg",T,E.a)),H!==E.o&&(E.o=We(P,"value",H,E.o)),Q!==E.i&&(E.i=We(P,"width",Q,E.i)),he!==E.n&&(E.n=We(P,"backgroundColor",he,E.n)),G!==E.s&&(E.s=We(P,"textColor",G,E.s)),F!==E.h&&(E.h=We(P,"placeholderColor",F,E.h)),N!==E.r&&(E.r=We(P,"cursorColor",N,E.r)),K!==E.d&&(E.d=We(P,"focusedBackgroundColor",K,E.d)),E},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0}),y})(),(()=>{var y=bt("box"),S=bt("text");return It(y,S),We(y,"height",1),sr(S,()=>"\u2500".repeat(Math.max(M(),1))),Do((P)=>{var E=M(),I=h.border.subtle;return E!==P.e&&(P.e=We(y,"width",E,P.e)),I!==P.t&&(P.t=We(S,"fg",I,P.t)),P},{e:void 0,t:void 0}),y})(),(()=>{var y=bt("box");return We(y,"flexDirection","column"),sr(y,Fs(ft,{get each(){return m().slice(0,b())},children:(S,P)=>{let E=()=>P()===i();return(()=>{var I=bt("box"),V=bt("text"),T=bt("text");return It(I,V),It(I,T),We(I,"height",1),We(I,"onMouseDown",()=>{s(P()),S.action()}),We(V,"x",2),We(V,"y",0),sr(V,()=>S.label),We(T,"y",0),sr(T,()=>S.description),Do((H)=>{var Q=M(),he=E()?h.select.focusedBg:h.bg.surface,G=E()?h.tab.active:h.text.primary,F=Math.max(25,S.label.length+4),N=h.text.secondary;return Q!==H.e&&(H.e=We(I,"width",Q,H.e)),he!==H.t&&(H.t=We(I,"backgroundColor",he,H.t)),G!==H.a&&(H.a=We(V,"fg",G,H.a)),F!==H.o&&(H.o=We(T,"x",F,H.o)),N!==H.i&&(H.i=We(T,"fg",N,H.i)),H},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),I})()}}),null),sr(y,Fs(te,{get when(){return m().length===0},get children(){var S=bt("box"),P=bt("text");return It(S,P),We(S,"height",1),It(P,jr("No commands found")),We(P,"x",2),We(P,"y",0),Do((E)=>We(P,"fg",h.text.secondary,E)),S}}),null),Do((S)=>{var P=M(),E=b(),I=h.bg.surface;return P!==S.e&&(S.e=We(y,"width",P,S.e)),E!==S.t&&(S.t=We(y,"height",E,S.t)),I!==S.a&&(S.a=We(y,"backgroundColor",I,S.a)),S},{e:void 0,t:void 0,a:void 0}),y})()]}})}var El=$e(()=>{ht();bn();yn();Lt();Fr();it()});import{insertNode as Mm}from"@opentui/solid";import{effect as Ml}from"@opentui/solid";import{insert as yl}from"@opentui/solid";import{createComponent as ym}from"@opentui/solid";import{setProp as Kt}from"@opentui/solid";import{createElement as Is}from"@opentui/solid";import{useTerminalDimensions as Rm}from"@opentui/solid";function Om(e){if(e==="success")return"\u2713";if(e==="warning")return"\u26A0";if(e==="error")return"\u2717";return"\u2139"}function Wm(e){if(e==="success")return h.text.success;if(e==="warning")return h.text.warning;if(e==="error")return h.text.error;return h.text.primary}function Rl(){let e=Rm(),t=()=>Math.min(60,Math.max(24,e().width-4)),n=()=>Math.max(0,e().width-t()-1);return(()=>{var o=Is("box");return Kt(o,"y",1),Kt(o,"height",5),Kt(o,"flexDirection","column"),yl(o,ym(ft,{get each(){return Uo().toasts()},children:(r,i)=>(()=>{var s=Is("box"),c=Is("text");return Mm(s,c),Kt(s,"x",0),Kt(s,"height",1),Kt(c,"x",1),Kt(c,"y",0),yl(c,()=>`${Om(r.type)} ${r.message}`),Ml((u)=>{var f=i(),m=t(),l=h.bg.elevated,p=Wm(r.type);return f!==u.e&&(u.e=Kt(s,"y",f,u.e)),m!==u.t&&(u.t=Kt(s,"width",m,u.t)),l!==u.a&&(u.a=Kt(s,"backgroundColor",l,u.a)),p!==u.o&&(u.o=Kt(c,"fg",p,u.o)),u},{e:void 0,t:void 0,a:void 0,o:void 0}),s})()})),Ml((r)=>{var i=n(),s=t();return i!==r.e&&(r.e=Kt(o,"x",i,r.e)),s!==r.t&&(r.t=Kt(o,"width",s,r.t)),r},{e:void 0,t:void 0}),o})()}var Ol=$e(()=>{ht();Mr();Lt()});var Fl={};Ye(Fl,{launchTUI:()=>jm});import{effect as Wl}from"@opentui/solid";import{memo as Bs}from"@opentui/solid";import{createComponent as ct}from"@opentui/solid";import{insert as qt}from"@opentui/solid";import{createTextNode as vt}from"@opentui/solid";import{insertNode as Ee}from"@opentui/solid";import{setProp as ne}from"@opentui/solid";import{createElement as Ie}from"@opentui/solid";import{render as Dm,useKeyboard as Fm,useTerminalDimensions as Im,useRenderer as Bm}from"@opentui/solid";import{resolve as Dl}from"path";function Lm(){let e=["code","cursor","vim","nvim","zed","subl","idea","webstorm"];for(let t of e)try{if(Bun.spawnSync(["which",t],{stdout:"pipe",stderr:"pipe"}).exitCode===0)return t}catch{}return null}function Tm(e){let t=mt(),n=Pt(),o=Bm(),[r,i]=be(!1),s=Im(),c=()=>{let d=n.worktrees()??[],b=t.selectedWorktreePath();if(b){let y=d.find((S)=>S.path===b);if(y)return y}return d[t.selectedWorktreeIndex()]};ln(()=>{let d=n.worktrees()??[],b=d.map((E)=>E.path);if(t.pruneSelectedWorktrees(b),d.length===0){if(t.selectedWorktreeIndex()!==0)t.setSelectedWorktreeIndex(0);if(t.selectedWorktreePath()!==null)t.setSelectedWorktreePath(null);return}let y=t.selectedWorktreePath();if(y){let E=d.findIndex((I)=>I.path===y);if(E>=0){if(E!==t.selectedWorktreeIndex())t.setSelectedWorktreeIndex(E);return}}let S=Math.min(t.selectedWorktreeIndex(),d.length-1),P=d[S]?.path??null;if(S!==t.selectedWorktreeIndex())t.setSelectedWorktreeIndex(S);if(P!==t.selectedWorktreePath())t.setSelectedWorktreePath(P)}),Fm((d)=>{let b=d.name;if(b==="escape"){if(t.showBulkActions()){t.setShowBulkActions(!1);return}if(t.showDetailView()){t.setShowDetailView(!1);return}if(t.showRemove()){t.setShowRemove(!1);return}if(r()){i(!1);return}if(t.activeTab()!=="list"){t.setActiveTab("list");return}}if(d.ctrl&&b==="p"){t.setShowCommandPalette(!0);return}if(t.inputFocused())return;if(t.showCommandPalette())return;if(t.showBulkActions())return;if(t.showRemove())return;if(t.activeTab()==="add")return;if(t.activeTab()==="list"){if(t.showDetailView())return;if(b==="a"){t.setActiveTab("add");return}if(b==="r"){n.refetch();return}if(b==="d"){let y=c();if(y&&!y.isMain)t.setShowRemove(!0);return}if(b==="o"){let y=c();if(y){let S=process.env.VISUAL||process.env.EDITOR||Lm();if(S)Bun.spawn([S,y.path],{stdout:"inherit",stderr:"inherit"})}return}}if(b==="h"){t.setActiveTab("doctor");return}if(b==="q"||b==="Q")o.destroy();if(b==="?")i((y)=>!y)});let u=()=>s().width,f=()=>s().height,m=()=>e.repoPath.split("/").pop()??"",l=()=>{let d=n.repoNames();if(d.length<=1)return m();return`${d.length} repos`},p=()=>{let d=n.worktrees()??[];return`${m()} \xB7 ${d.length} worktrees`},R=()=>{return` Worktrees (${(n.worktrees()??[]).length}) `},M=()=>u()-Am-1;return(()=>{var d=Ie("box"),b=Ie("box"),y=Ie("text"),S=Ie("text"),P=Ie("box"),E=Ie("box"),I=Ie("box"),V=Ie("text"),T=Ie("b"),H=Ie("box"),Q=Ie("box"),he=Ie("toaster"),G=Ie("box"),F=Ie("text"),N=Ie("box"),K=Ie("text");return Ee(d,b),Ee(d,P),Ee(d,he),Ee(d,G),Ee(d,N),ne(d,"flexDirection","column"),Ee(b,y),Ee(b,S),ne(b,"height",1),Ee(y,vt("\uD83C\uDF33 oh-my-worktree")),ne(y,"x",1),ne(y,"y",0),ne(S,"y",0),qt(S,l),Ee(P,E),Ee(P,H),Ee(P,Q),ne(P,"flexGrow",1),ne(P,"flexDirection","row"),Ee(E,I),ne(E,"width",28),ne(E,"flexShrink",0),ne(E,"flexDirection","column"),Ee(I,V),ne(I,"height",1),ne(I,"paddingX",1),Ee(V,T),qt(T,R),qt(E,ct($l,{}),null),ne(H,"width",1),ne(Q,"flexGrow",1),qt(Q,ct(te,{get when(){return Bs(()=>t.activeTab()!=="config"&&!t.showRemove())()&&!t.showBulkActions()},get children(){return ct(Ga,{})}}),null),qt(Q,ct(te,{get when(){return Bs(()=>t.activeTab()==="list")()&&t.showBulkActions()},get children(){return ct(cl,{get w(){return M()},get h(){return f()-3}})}}),null),qt(Q,ct(te,{get when(){return t.activeTab()==="config"},get children(){return ct(fl,{})}}),null),qt(d,ct(Rl,{}),he),ne(he,"position","bottom-right"),Ee(G,F),ne(G,"height",1),ne(F,"x",0),ne(F,"y",0),qt(F,()=>"\u2500".repeat(u())),Ee(N,K),ne(N,"height",1),Ee(K,vt("d:delete a:add o:open r:refresh ^P:cmd h:health q:quit")),ne(K,"x",1),ne(K,"y",0),qt(d,ct(te,{get when(){return Bs(()=>!!r())()&&!t.showCommandPalette()},get children(){var k=Ie("box"),ge=Ie("box"),re=Ie("text"),me=Ie("text"),x=Ie("box"),v=Ie("text"),A=Ie("text"),B=Ie("box"),D=Ie("text"),z=Ie("text"),se=Ie("box"),J=Ie("text"),_=Ie("text"),Me=Ie("box"),fe=Ie("text"),pe=Ie("text"),De=Ie("box"),Ce=Ie("box"),O=Ie("text"),a=Ie("text"),w=Ie("box"),L=Ie("text"),W=Ie("text"),C=Ie("box"),q=Ie("box"),X=Ie("text");return Ee(k,ge),Ee(k,x),Ee(k,B),Ee(k,se),Ee(k,Me),Ee(k,De),Ee(k,Ce),Ee(k,w),Ee(k,C),Ee(k,q),ne(k,"height",14),ne(k,"border",!0),ne(k,"borderStyle","rounded"),ne(k,"title"," Keyboard Shortcuts "),ne(k,"titleAlignment","left"),ne(k,"flexDirection","column"),ne(k,"paddingX",1),ne(k,"paddingY",1),ne(k,"position","absolute"),Ee(ge,re),Ee(ge,me),ne(ge,"height",1),Ee(re,vt("q")),ne(re,"x",1),Ee(me,vt("Quit")),ne(me,"x",8),Ee(x,v),Ee(x,A),ne(x,"height",1),Ee(v,vt("j/k")),ne(v,"x",1),Ee(A,vt("Navigate list")),ne(A,"x",8),Ee(B,D),Ee(B,z),ne(B,"height",1),Ee(D,vt("a")),ne(D,"x",1),Ee(z,vt("Add worktree")),ne(z,"x",8),Ee(se,J),Ee(se,_),ne(se,"height",1),Ee(J,vt("d")),ne(J,"x",1),Ee(_,vt("Delete worktree")),ne(_,"x",8),Ee(Me,fe),Ee(Me,pe),ne(Me,"height",1),Ee(fe,vt("r")),ne(fe,"x",1),Ee(pe,vt("Refresh list")),ne(pe,"x",8),ne(De,"height",1),Ee(Ce,O),Ee(Ce,a),ne(Ce,"height",1),Ee(O,vt("Ctrl+P")),ne(O,"x",1),Ee(a,vt("Command palette")),ne(a,"x",8),Ee(w,L),Ee(w,W),ne(w,"height",1),Ee(L,vt("?")),ne(L,"x",1),Ee(W,vt("Toggle help")),ne(W,"x",8),ne(C,"height",1),Ee(q,X),ne(q,"height",1),Ee(X,vt("Press ? to close")),ne(X,"x",1),Wl((U)=>{var Ne=Math.max(0,Math.floor((u()-Math.max(40,Math.min(60,u()-4)))/2)),Ue=Math.max(0,Math.floor((f()-14)/2)),sn=Math.max(40,Math.min(60,u()-4)),cn=h.border.active,Tn=h.bg.elevated,jn=h.text.secondary,Nn=h.text.primary,Gn=h.text.secondary,kn=h.text.primary,Hn=h.text.secondary,lr=h.text.primary,fr=h.text.secondary,ur=h.text.primary,zs=h.text.secondary,Us=h.text.primary,Js=h.text.secondary,Vs=h.text.primary,Ks=h.text.secondary,qs=h.text.primary,Xs=h.text.accent;return Ne!==U.e&&(U.e=ne(k,"x",Ne,U.e)),Ue!==U.t&&(U.t=ne(k,"y",Ue,U.t)),sn!==U.a&&(U.a=ne(k,"width",sn,U.a)),cn!==U.o&&(U.o=ne(k,"borderColor",cn,U.o)),Tn!==U.i&&(U.i=ne(k,"backgroundColor",Tn,U.i)),jn!==U.n&&(U.n=ne(re,"fg",jn,U.n)),Nn!==U.s&&(U.s=ne(me,"fg",Nn,U.s)),Gn!==U.h&&(U.h=ne(v,"fg",Gn,U.h)),kn!==U.r&&(U.r=ne(A,"fg",kn,U.r)),Hn!==U.d&&(U.d=ne(D,"fg",Hn,U.d)),lr!==U.l&&(U.l=ne(z,"fg",lr,U.l)),fr!==U.u&&(U.u=ne(J,"fg",fr,U.u)),ur!==U.c&&(U.c=ne(_,"fg",ur,U.c)),zs!==U.w&&(U.w=ne(fe,"fg",zs,U.w)),Us!==U.m&&(U.m=ne(pe,"fg",Us,U.m)),Js!==U.f&&(U.f=ne(O,"fg",Js,U.f)),Vs!==U.y&&(U.y=ne(a,"fg",Vs,U.y)),Ks!==U.g&&(U.g=ne(L,"fg",Ks,U.g)),qs!==U.p&&(U.p=ne(W,"fg",qs,U.p)),Xs!==U.b&&(U.b=ne(X,"fg",Xs,U.b)),U},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0,c:void 0,w:void 0,m:void 0,f:void 0,y:void 0,g:void 0,p:void 0,b:void 0}),k}}),null),qt(d,ct(te,{get when(){return t.activeTab()==="add"},get children(){return ct(nl,{})}}),null),qt(d,ct(te,{get when(){return t.activeTab()==="doctor"},get children(){return ct(wl,{})}}),null),qt(d,ct(te,{get when(){return t.showRemove()},get children(){return ct(rl,{})}}),null),qt(d,ct(te,{get when(){return t.showCommandPalette()},get children(){return ct(Sl,{})}}),null),Wl((k)=>{var ge=u(),re=f(),me=h.bg.base,x=h.bg.overlay,v=h.text.accent,A=u()-l().length-2,B=h.text.secondary,D=h.bg.surface,z=h.text.accent,se=h.bg.base,J=h.bg.overlay,_=h.border.subtle,Me=h.bg.overlay,fe=h.text.secondary;return ge!==k.e&&(k.e=ne(d,"width",ge,k.e)),re!==k.t&&(k.t=ne(d,"height",re,k.t)),me!==k.a&&(k.a=ne(d,"backgroundColor",me,k.a)),x!==k.o&&(k.o=ne(b,"backgroundColor",x,k.o)),v!==k.i&&(k.i=ne(y,"fg",v,k.i)),A!==k.n&&(k.n=ne(S,"x",A,k.n)),B!==k.s&&(k.s=ne(S,"fg",B,k.s)),D!==k.h&&(k.h=ne(E,"backgroundColor",D,k.h)),z!==k.r&&(k.r=ne(V,"fg",z,k.r)),se!==k.d&&(k.d=ne(Q,"backgroundColor",se,k.d)),J!==k.l&&(k.l=ne(G,"backgroundColor",J,k.l)),_!==k.u&&(k.u=ne(F,"fg",_,k.u)),Me!==k.c&&(k.c=ne(N,"backgroundColor",Me,k.c)),fe!==k.w&&(k.w=ne(K,"fg",fe,k.w)),k},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0,c:void 0,w:void 0}),d})()}async function jm(){if(process.stdout.isTTY)process.stdout.write("\x1B]0;Oh My Worktree\x07");let e=await ee.getMainRepoPath().catch(()=>process.cwd()),t=[e];try{let n={...Fe()},o=no(n),r=new Set([Dl(e)]);for(let i of o){let s=Dl(i);if(!r.has(s))r.add(s),t.push(i)}if(n.theme&&ai.includes(n.theme))li(n.theme)}catch{}await Dm(()=>ct(Ma,{repoPath:e,repoPaths:t,get children(){return ct(Oa,{repoPaths:t,get children(){return ct(La,{get children(){return ct(Tm,{repoPath:e})}})}})}}),{exitOnCtrlC:!0,useMouse:!0})}var Am=28;var Il=$e(()=>{ht();bn();yn();ke();ka();ol();il();al();ul();xl();Pl();Lt();El();Mr();Ol();it()});import*as Bl from"readline";async function ao(e){let t=Bl.createInterface({input:process.stdin,output:process.stdout});return new Promise((n)=>{t.question(e,(o)=>{t.close(),n(o.toLowerCase()==="y"||o.toLowerCase()==="yes")})})}async function ze(){return ee.getMainRepoPath().catch(()=>process.cwd())}function on(e,t){let n=e.find((o)=>o.branch===t||o.path===t||o.path.endsWith("/"+t));if(!n)console.error(`Error: no worktree found for '${t}'`),process.exit(1);return n}function nt(e){if(e instanceof Ut)console.error(`Git error: ${e.message}`);else console.error(`Error: ${e.message}`);process.exit(1)}var yt=$e(()=>{ke();fn()});import{mkdirSync as Nm,writeFileSync as Gm}from"fs";import{dirname as km}from"path";function Hm(e){return Cn(e,"omw-pr")}function Ll(e,t){let n=Hm(e);Nm(km(n),{recursive:!0}),Gm(n,JSON.stringify(t),{encoding:"utf-8",mode:384})}var Al=$e(()=>{Yn()});import{appendFileSync as zm,existsSync as Um,mkdirSync as Jm,readFileSync as Tl,rmSync as Vm,statSync as Km,writeFileSync as qm}from"fs";import{dirname as Xm}from"path";function Ls(e){return Cn(e,"omw-activity.log")}function rn(e,t){let n=Ls(e);Jm(Xm(n),{recursive:!0}),zm(n,`${JSON.stringify(t)}
|
|
15
|
+
`,{encoding:"utf-8",mode:384});let o=Km(n,{throwIfNoEntry:!1});if(o&&o.size>Qm){let r=Tl(n,"utf-8").split(/\r?\n/).filter(Boolean);if(r.length>jl){let i=r.slice(-Zm);qm(n,`${i.join(`
|
|
17
16
|
`)}
|
|
18
|
-
`,{encoding:"utf-8",mode:384})}}}function
|
|
19
|
-
Worktree ready: ${
|
|
20
|
-
Setup failed, rolling back...`);try{await
|
|
21
|
-
`)}var
|
|
22
|
-
Remove ${
|
|
23
|
-
No lifecycle config found. Add 'lifecycle' to your config to enable stale detection.`)}process.exit(0)}catch(
|
|
24
|
-
`;try{
|
|
25
|
-
`);for(let i of
|
|
26
|
-
All checks passed.`);else{let i=[];if(r>0)i.push(`${r} error(s)`);if(
|
|
27
|
-
${i.join(", ")} found.`)}if(
|
|
17
|
+
`,{encoding:"utf-8",mode:384})}}}function Nl(e,t){let n=Ls(e),o=t?.limit??50;if(!Um(n))return[];let i=Tl(n,"utf-8").split(/\r?\n/).filter(Boolean),s=Math.max(0,i.length-o),c=[];for(let u=i.length-1;u>=s;u--)try{c.push(JSON.parse(i[u]))}catch{}return c}function Gl(e){Vm(Ls(e),{force:!0})}var jl=1000,Zm=500,Qm;var lo=$e(()=>{Yn();Qm=80*jl});var kl={};Ye(kl,{default:()=>np});import{basename as Ym,resolve as _m}from"path";import{existsSync as ep}from"fs";var tp,np;var Hl=$e(()=>{ke();fn();it();yt();In();Pi();Ci();Rn();Al();lo();$s();eo();tp={command:"add [branch] [path]",describe:"Create a new worktree for a branch",builder:(e)=>e.positional("branch",{type:"string",describe:"Branch name"}).positional("path",{type:"string",describe:"Worktree directory path"}).option("create",{type:"boolean",alias:"c",describe:"Optional compatibility flag; missing branches are created automatically"}).option("base",{type:"string",alias:"b",describe:"Base branch/commit for new branch"}).option("focus",{type:"array",alias:"f",describe:"Focus packages for monorepo (comma or space separated paths)",string:!0}).option("template",{type:"string",alias:"t",describe:"Use a named template from config"}).option("pr",{type:"number",describe:"Create worktree from a GitHub PR number (requires gh CLI)"}).option("session",{type:"boolean",alias:"s",describe:"Create a tmux session for this worktree"}).option("layout",{type:"string",describe:"Session layout name from config"}),handler:async(e)=>{let{branch:t,pr:n}=e,o=await ze(),r=Ym(o);if(!t&&!n)console.error("Error: specify a branch or use --pr <number>."),process.exit(1);if(n)try{let M=Bun.spawn(["gh","pr","view",String(n),"--json","headRefName","--jq",".headRefName"],{cwd:o,stdout:"pipe",stderr:"pipe"}),[d,b,y]=await Promise.all([new Response(M.stdout).text(),new Response(M.stderr).text(),M.exited]);if(y!==0)console.error(`Error: failed to resolve PR #${n}: ${b.trim()}`),console.error("Make sure 'gh' CLI is installed and authenticated."),process.exit(1);if(t=d.trim(),!t)console.error(`Error: PR #${n} has no branch name`),process.exit(1);console.log(`PR #${n} \u2192 branch '${t}'`)}catch{console.error("Error: 'gh' CLI not found. Install it from https://cli.github.com"),process.exit(1)}if(!t)console.error("Error: could not determine branch name."),process.exit(1);let i=t.replace(/\//g,"-"),s=Fe(),c=Wt(s,o),u=e.template;if(u){let M=xi(s,u);if(!M){let d=Object.keys(s.templates??{});if(console.error(`Error: template '${u}' not found.`),d.length>0)console.error(`Available templates: ${d.join(", ")}`);else console.error("No templates configured. Add templates to your config file.");process.exit(1)}if(c=bi(c,M),M.base&&!e.base)e.base=M.base;console.log(`Using template '${u}'`)}let f=e.path??c.worktreeDir,m=wi(f,{repo:r,branch:i}),l=_m(o,m);console.log(`Creating worktree for branch '${t}'...`),console.log(` Target: ${l}`);let R=(await ee.list(o)).find((M)=>M.branch===t);if(R)console.error(`Error: branch '${t}' is already checked out in ${R.path}`),process.exit(1);if(ep(l))console.error(`Error: directory already exists: ${l}`),process.exit(1);try{await ee.add(t,l,{createBranch:Boolean(e.create),base:e.base},o),console.log(" \u2713 Worktree created");try{rn(o,{timestamp:new Date().toISOString(),event:"create",branch:t,path:l})}catch{}if(n)Ll(l,{number:n,branch:t,createdAt:new Date().toISOString()}),console.log(` \u2713 PR #${n} metadata saved`)}catch(M){if(M instanceof Ut)console.error(`Error creating worktree: ${M.stderr||M.message}`);else console.error(`Error: ${M.message}`);process.exit(1)}if(c.autoUpstream)try{let M=await ee.getDefaultRemote(o);if(await ee.remoteBranchExists(t,M,o))await ee.setUpstream(t,M,o),console.log(` \u2713 Upstream tracking set \u2192 ${M}/${t}`);else console.log(" \u2139 No remote branch found \u2014 upstream tracking skipped")}catch(M){console.warn(` \u26A0 Could not set upstream tracking: ${M.message}`)}try{if(c.copyFiles.length>0){console.log(` Copying files: ${c.copyFiles.join(", ")}`);let P=qo(o,l,c.copyFiles);for(let E of P.warnings)console.log(` \u26A0 ${E}`);if(P.copied.length>0)console.log(` \u2713 Copied: ${P.copied.join(", ")}`)}if(c.linkFiles.length>0){console.log(` Linking files: ${c.linkFiles.join(", ")}`);let P=Xo(o,l,c.linkFiles);for(let E of P.warnings)console.log(` \u26A0 ${E}`);if(P.linked.length>0)console.log(` \u2713 Linked: ${P.linked.join(", ")}`)}if(c.sharedDeps&&c.sharedDeps.paths&&c.sharedDeps.paths.length>0){let P=c.sharedDeps.strategy??"symlink";console.log(` Sharing dependencies (${P}): ${c.sharedDeps.paths.join(", ")}`);let E=Qa(o,l,c.sharedDeps);for(let I of E.warnings)console.log(` \u26A0 ${I}`);if(E.linked.length>0)console.log(` \u2713 Shared (${P}): ${E.linked.join(", ")}`);if(E.copied.length>0)console.log(` \u2713 Copied: ${E.copied.join(", ")}`)}let M={OMW_BRANCH:t,OMW_WORKTREE_PATH:l,OMW_REPO_PATH:o},d=e.focus,b=[];if(d&&d.length>0)b=d.flatMap((P)=>P.split(/[,\s]+/)).map((P)=>P.trim()).filter(Boolean);if(b.length>0){let{valid:P,invalid:E}=$i(l,b);if(E.length>0)console.log(` \u26A0 Focus paths not found (will be skipped): ${E.join(", ")}`);if(P.length>0)ko(l,P),console.log(` \u2713 Focus set: ${P.join(", ")}`);M.OMW_FOCUS_PATHS=P.join(",")}if(c.postCreate.length>0)console.log(" Running postCreate hooks..."),await Et(c.postCreate,{cwd:l,env:M,onOutput:(P)=>console.log(` ${P}`)}),console.log(" \u2713 Hooks completed");if(b.length>0&&c.monorepo?.hooks&&c.monorepo.hooks.length>0){let P=Mo(c.monorepo.hooks,b);if(P.length>0)console.log(" Running monorepo hooks..."),await Yo(P,"postCreate",{cwd:l,env:M,repo:r,branch:t,focusPaths:b,mainRepoPath:o,onOutput:(E)=>console.log(` ${E}`)}),console.log(" \u2713 Monorepo hooks completed")}let y=oo(s);if(e.session||y.autoCreate)if(await zo()){let E=e.layout??y.defaultLayout,I=vi(s,E),V=await ui(t,l,{layout:I,prefix:y.prefix,attach:!1,layoutName:E});console.log(` \u2713 Session created: ${V}`)}else console.log(" \u26A0 tmux not found \u2014 session skipped");console.log(`
|
|
18
|
+
Worktree ready: ${l}`),process.exit(0)}catch(M){console.error(`
|
|
19
|
+
Setup failed, rolling back...`);try{await ee.remove(l,{force:!0},o),console.error("Rolled back worktree.")}catch(d){console.error(`Warning: rollback failed: ${d.message}`)}if(M instanceof Qo)console.error(`Error: hook timed out: ${M.command}`);else if(M instanceof Zo){if(console.error(`Error: hook failed (exit ${M.exitCode}): ${M.command}`),M.stderr)console.error(M.stderr)}else console.error(`Error: ${M.message}`);process.exit(1)}}},np=tp});var zl={};Ye(zl,{default:()=>ip});import{relative as op,resolve as As}from"path";var rp,ip;var Ul=$e(()=>{ke();fn();it();Rn();yt();rp={command:"list",aliases:["ls"],describe:"List all worktrees with their status",builder:(e)=>e.option("json",{type:"boolean",alias:"j",describe:"Output as JSON"}).option("porcelain",{type:"boolean",alias:"p",describe:"Machine-readable output"}).option("all",{type:"boolean",alias:"a",describe:"List worktrees from all configured repos"}),handler:async(e)=>{try{let t;if(e.all){let s=Fe(),c=await ze(),u=no(s),f=new Set([As(c)]),m=[c];for(let l of u){let p=As(l);if(!f.has(p))f.add(p),m.push(l)}t=await ee.listAll(m)}else t=await ee.list();let n=await Promise.all(t.map(async(s)=>({...s,focus:dn(s.path)})));if(e.json)console.log(JSON.stringify(n,null,2)),process.exit(0);if(e.porcelain){for(let s of n){if(e.all)console.log(`repo ${s.repoName}`);if(console.log(`path ${s.path}`),console.log(`branch ${s.branch??"(detached)"}`),console.log(`head ${s.head}`),console.log(`dirty ${s.isDirty}`),console.log(`locked ${s.isLocked}`),s.focus&&s.focus.length>0)console.log(`focus ${s.focus.join(",")}`);console.log("")}process.exit(0)}if(t.length===0)console.log("No worktrees found."),process.exit(0);let o=As(process.cwd()),r=e.all&&new Set(n.map((s)=>s.repoName)).size>1,i=n.map((s)=>({repo:s.repoName,branch:s.branch??"(detached)",path:s.path===o?s.path:op(o,s.path)||s.path,status:s.isLocked?"locked":s.isDirty?"dirty":"clean",focus:s.focus?s.focus.join(", ").slice(0,40)+(s.focus.join(", ").length>40?"...":""):"\u2014"}));if(r){let s=Math.max(4,...i.map((l)=>l.repo.length)),c=Math.max(6,...i.map((l)=>l.branch.length)),u=Math.max(4,...i.map((l)=>l.path.length)),f=Math.max(6,...i.map((l)=>l.status.length)),m=Math.max(5,...i.map((l)=>l.focus.length));console.log(`${"Repo".padEnd(s)} ${"Branch".padEnd(c)} ${"Path".padEnd(u)} ${"Status".padEnd(f)} ${"Focus".padEnd(m)}`),console.log(`${"-".repeat(s)} ${"-".repeat(c)} ${"-".repeat(u)} ${"-".repeat(f)} ${"-".repeat(m)}`);for(let l of i)console.log(`${l.repo.padEnd(s)} ${l.branch.padEnd(c)} ${l.path.padEnd(u)} ${l.status.padEnd(f)} ${l.focus.padEnd(m)}`)}else{let s=Math.max(6,...i.map((m)=>m.branch.length)),c=Math.max(4,...i.map((m)=>m.path.length)),u=Math.max(6,...i.map((m)=>m.status.length)),f=Math.max(5,...i.map((m)=>m.focus.length));console.log(`${"Branch".padEnd(s)} ${"Path".padEnd(c)} ${"Status".padEnd(u)} ${"Focus".padEnd(f)}`),console.log(`${"-".repeat(s)} ${"-".repeat(c)} ${"-".repeat(u)} ${"-".repeat(f)}`);for(let m of i)console.log(`${m.branch.padEnd(s)} ${m.path.padEnd(c)} ${m.status.padEnd(u)} ${m.focus.padEnd(f)}`)}process.exit(0)}catch(t){if(t instanceof Ut)if(t.stderr.includes("not a git repository"))console.error("Error: not a git repository (or any of the parent directories): .git"),console.error("Run omw from within a git repository.");else console.error(`Git error: ${t.message}`);else console.error(`Error: ${t.message}`);process.exit(1)}}},ip=rp});var Vl={};Ye(Vl,{default:()=>cp});import{basename as Jl}from"path";var sp,cp;var Kl=$e(()=>{ke();it();In();Rn();Pi();lo();eo();yt();sp={command:"remove <branch-or-path>",aliases:["rm"],describe:"Remove a worktree",builder:(e)=>e.positional("branch-or-path",{type:"string",demandOption:!0}).option("force",{type:"boolean",alias:"f",describe:"Force removal even with uncommitted changes"}).option("yes",{type:"boolean",alias:"y",describe:"Skip confirmation prompt"}),handler:async(e)=>{let t=e["branch-or-path"],n=!!e.force,o=!!e.yes;try{let r=await ze(),i=await ee.list(r),s=on(i,t);if(s.isMain)console.error("Error: cannot remove the main worktree"),process.exit(1);if(await ee.isDirty(s.path)&&!n)console.error(`Error: worktree has uncommitted changes: ${s.path}`),console.error("Use --force to remove anyway."),process.exit(1);if(s.isLocked){if(console.error(`Error: worktree is locked: ${s.path}`),s.lockReason)console.error(`Lock reason: ${s.lockReason}`);process.exit(1)}if(!o){if(!await ao(`Remove worktree '${s.branch??Jl(s.path)}' at ${s.path}? [y/N] `))console.log("Cancelled."),process.exit(0)}let u=Fe(),f=Wt(u,r);if(f.postRemove.length>0)console.log("Running postRemove hooks..."),await Et(f.postRemove,{cwd:s.path,env:{OMW_BRANCH:s.branch??"",OMW_WORKTREE_PATH:s.path,OMW_REPO_PATH:r},onOutput:(p)=>console.log(` ${p}`)}).catch((p)=>console.warn(`Warning: postRemove hook failed: ${p.message}`));let m=dn(s.path)??[];if(m.length>0&&f.monorepo?.hooks&&f.monorepo.hooks.length>0){let p=Mo(f.monorepo.hooks,m);if(p.length>0){let R=Jl(r),M=s.branch??"unknown";console.log(" Running monorepo postRemove hooks..."),await Yo(p,"postRemove",{cwd:s.path,env:{OMW_BRANCH:M,OMW_WORKTREE_PATH:s.path,OMW_REPO_PATH:r,OMW_FOCUS_PATHS:m.join(",")},repo:R,branch:M,focusPaths:m,mainRepoPath:r,onOutput:(d)=>console.log(` ${d}`)}),console.log(" \u2713 Monorepo hooks completed")}}let l=oo(u);if(l.autoKill){if(await zo()){let R=s.branch??t;if(await di(R,s.path,l.prefix))console.log(" \u2713 Session killed")}}await ee.remove(s.path,{force:n},r),console.log(`Removed worktree: ${s.path}`);try{rn(r,{timestamp:new Date().toISOString(),event:"delete",branch:s.branch??t,path:s.path})}catch{}process.exit(0)}catch(r){nt(r)}}},cp=sp});var ql={};Ye(ql,{default:()=>fp});import{basename as ap}from"path";var lp,fp;var Xl=$e(()=>{ke();lo();it();eo();yt();lp={command:"switch <branch-or-path>",aliases:["sw"],describe:"Switch to a worktree directory (outputs cd command for shell eval)",builder:(e)=>e.positional("branch-or-path",{type:"string",demandOption:!0}),handler:async(e)=>{let t=e["branch-or-path"];try{let n=await ze(),o=await ee.list(n),r=on(o,t);try{rn(n,{timestamp:new Date().toISOString(),event:"switch",branch:r.branch??t,path:r.path})}catch{}let i=Fe(),s=oo(i);if(s.enabled&&ps()){let c=r.branch??ap(r.path),u=_n(c,s.prefix);if(await Wn(u))try{await fi(u),process.exit(0)}catch{}}console.log(`cd ${JSON.stringify(r.path)}`),process.exit(0)}catch(n){nt(n)}}},fp=lp});async function Zl(e,t,n,o){let r=e.filter((m)=>!m.isMain),i=r.filter((m)=>co(m.path)),s=new Set(i.map((m)=>m.path)),c=[];if(t.autoCleanMerged){let m=r.filter((p)=>!s.has(p.path)&&p.branch);c=(await un(m,10,async(p)=>({wt:p,isMerged:await ee.isMergedInto(p.branch,n,o)}))).filter((p)=>p.isMerged&&!p.wt.isDirty).map((p)=>p.wt)}let u=[];if(t.staleAfterDays&&t.staleAfterDays>0){let m=new Date,l=r.filter((R)=>!s.has(R.path));u=(await un(l,10,async(R)=>{let M=await ee.getWorktreeLastActivity(R.path),d=M?Math.floor((m.getTime()-M.getTime())/86400000):1/0;return{wt:R,lastActivity:M,daysSince:d}})).filter((R)=>R.daysSince>=t.staleAfterDays).map((R)=>({worktree:R.wt,lastActivity:R.lastActivity,daysSinceActivity:R.daysSince===1/0?-1:R.daysSince}))}let f=t.maxWorktrees?r.length>t.maxWorktrees:!1;return{merged:c,stale:u,pinProtected:i,overLimit:f,totalCount:r.length,maxWorktrees:t.maxWorktrees??null}}function Ql(e){let t=[];if(e.pinProtected.length>0){t.push(`Pin-protected worktrees (${e.pinProtected.length}):`);for(let n of e.pinProtected)t.push(` ${n.branch??"(detached)"} \u2192 ${n.path}`)}if(e.merged.length>0){t.push(`Merged worktrees (${e.merged.length}):`);for(let n of e.merged)t.push(` ${n.branch??"(detached)"} \u2192 ${n.path}`)}if(e.stale.length>0){t.push(`Stale worktrees (${e.stale.length}):`);for(let n of e.stale){let o=n.daysSinceActivity<0?"unknown":`${n.daysSinceActivity} days`;t.push(` ${n.worktree.branch??"(detached)"} \u2014 inactive ${o}`)}}if(e.overLimit)t.push(`Worktree limit exceeded: ${e.totalCount}/${e.maxWorktrees}`);if(t.length===0)t.push("All worktrees are healthy.");return t.join(`
|
|
20
|
+
`)}var Yl=$e(()=>{ke();ir()});var _l={};Ye(_l,{default:()=>dp});var up,dp;var ef=$e(()=>{ke();it();Yl();ir();yt();up={command:"clean",describe:"Remove merged worktrees and prune stale entries",builder:(e)=>e.option("dry-run",{type:"boolean",alias:"n",describe:"Show what would be removed"}).option("yes",{type:"boolean",alias:"y",describe:"Skip confirmation"}).option("stale",{type:"boolean",describe:"Also show stale worktrees (based on lifecycle config)"}),handler:async(e)=>{let t=!!(e["dry-run"]||e.n),n=!!e.yes;try{let o=await ze(),r=await ee.list(o),s=(r.find((m)=>m.isMain)??r[0])?.branch??"main",c=r.filter((m)=>{if(m.isMain)return!1;if(co(m.path))return console.log(` Skipping (pinned): ${m.branch}`),!1;if(!m.branch)return!1;return!0}),u=await un(c,10,async(m)=>{let[l,p]=await Promise.all([ee.isMergedInto(m.branch,s,o),ee.isDirty(m.path)]);return{wt:m,merged:l,dirty:p}}),f=[];for(let{wt:m,merged:l,dirty:p}of u){if(!l)continue;if(p){console.log(` Skipping (dirty): ${m.branch}`);continue}f.push(m)}if(f.length===0)console.log("No merged worktrees to clean.");else{console.log(t?"Would remove:":"To remove:");for(let m of f)console.log(` ${m.branch} (${m.path})`)}if(!t&&f.length>0){if(!n){if(!await ao(`
|
|
21
|
+
Remove ${f.length} worktree(s)? [y/N] `))console.log("Cancelled."),process.exit(0)}for(let m of f)await ee.remove(m.path,{force:!1},o),console.log(` Removed: ${m.branch}`)}if(!t)await ee.prune(o),console.log("Pruned stale worktree entries.");if(e.stale){let m=Fe();if(m.lifecycle){let l=await Zl(r,m.lifecycle,s,o);console.log(),console.log(Ql(l))}else console.log(`
|
|
22
|
+
No lifecycle config found. Add 'lifecycle' to your config to enable stale detection.`)}process.exit(0)}catch(o){nt(o)}}},dp=up});import{existsSync as hp,mkdirSync as mp,readFileSync as pp,writeFileSync as gp}from"fs";import{dirname as wp}from"path";function tf(){let e=Vt();try{return Fe(e)}catch{if(!hp(e))throw Error("Failed to load config");let t=pp(e,"utf-8");return JSON.parse(t)}}function nf(e){let t=Vt(),n=wp(t);mp(n,{recursive:!0,mode:448});let o=`${JSON.stringify(e,null,2)}
|
|
23
|
+
`;try{Wr(t,o)}catch{gp(t,o,{encoding:"utf-8",mode:384})}}function Ts(e){return Object.keys(e.profiles??{})}function of(e){let t=tf();nf({...t,activeProfile:e})}function rf(e){return e.activeProfile??null}function sf(e){let t=tf(),n={...t.profiles??{}};delete n[e],nf({...t,profiles:n,activeProfile:t.activeProfile===e?void 0:t.activeProfile})}var cf=$e(()=>{it()});var af={};Ye(af,{default:()=>Cp});import{spawnSync as xp}from"child_process";import{readFileSync as bp}from"fs";var vp,Cp;var lf=$e(()=>{it();cf();vp={command:"config",describe:"Manage oh-my-worktree configuration",builder:(e)=>e.option("init",{type:"boolean",describe:"Create default config file"}).option("show",{type:"boolean",alias:"s",describe:"Print current config as JSON"}).option("edit",{type:"boolean",alias:"e",describe:"Open config in $EDITOR"}).option("path",{type:"boolean",describe:"Print config file path"}).option("validate",{type:"boolean",describe:"Validate config against schema"}).option("profiles",{type:"boolean",describe:"List config profiles"}).option("profile",{type:"string",describe:"Profile name for activation/deletion"}).option("activate",{type:"boolean",describe:"Activate the specified profile"}).option("delete",{type:"boolean",describe:"Delete the specified profile"}),handler:async(e)=>{let t=Vt();if(e.init){let n=Pn();console.log(`Config initialized: ${n}`),process.exit(0)}if(e.path)console.log(t),process.exit(0);if(e.show){try{let n=Fe();console.log(JSON.stringify(n,null,2))}catch(n){console.error(`Error loading config: ${n.message}`),process.exit(1)}process.exit(0)}if(e.edit){let n=process.env.EDITOR??process.env.VISUAL??"vi";Pn();let o=xp(n,[t],{stdio:"inherit"});process.exit(o.status??0)}if(e.validate)try{let n=bp(t,"utf-8"),o;try{o=JSON.parse(n)}catch{console.error(`Error: invalid JSON in config file: ${t}`),process.exit(1)}let r=Or(o);if(r.length===0)console.log(`\u2713 Config is valid: ${t}`),process.exit(0);else{console.error(`Config validation failed (${r.length} error(s)):`);for(let i of r)console.error(` ${i.field}: ${i.message}`);process.exit(1)}}catch(n){console.error(`Error reading config: ${n.message}`),process.exit(1)}if(e.profiles){try{let n=Fe(),o=Ts(n),r=rf(n);for(let i of o)console.log(`${i}${i===r?" \u2605":""}`)}catch(n){console.error(`Error loading config: ${n.message}`),process.exit(1)}process.exit(0)}if(e.profile&&e.activate){try{let n=Fe(),o=e.profile;if(!Ts(n).includes(o))console.error(`Error: profile '${o}' does not exist.`),process.exit(1);of(o)}catch(n){console.error(`Error loading config: ${n.message}`),process.exit(1)}process.exit(0)}if(e.profile&&e.delete)sf(e.profile),process.exit(0);console.log("Usage: omw config [options]"),console.log(""),console.log("Options:"),console.log(" --init Create default config file"),console.log(" --show, -s Print current config as JSON"),console.log(" --edit, -e Open config in $EDITOR"),console.log(" --path Print config file path"),console.log(" --validate Validate config against schema"),console.log(" --profiles List config profiles"),console.log(" --profile Profile name for activation/deletion"),console.log(" --activate Activate the specified profile"),console.log(" --delete Delete the specified profile"),console.log(""),console.log(`Config path: ${t}`),process.exit(0)}},Cp=vp});var ff={};Ye(ff,{default:()=>Pp});var $p,Pp;var uf=$e(()=>{Ms();$p={command:"doctor",describe:"Check worktree health and diagnose issues",builder:(e)=>e.option("json",{type:"boolean",alias:"j",describe:"Output as JSON"}).option("fix",{type:"boolean",describe:"Auto-fix issues (prune stale, remove orphans, unlock stale locks)"}),handler:async(e)=>{let t=process.cwd(),n=await rr(t);if(e.json&&!e.fix){let i={pass:n.checks.filter((s)=>s.status==="pass").length,warn:n.checks.filter((s)=>s.status==="warn").length,fail:n.checks.filter((s)=>s.status==="fail").length};console.log(JSON.stringify({healthy:n.healthy,checks:n.checks,summary:i},null,2)),process.exit(n.healthy?0:1)}console.log(`oh-my-worktree doctor
|
|
24
|
+
`);for(let i of n.checks){let s=i.status==="pass"?"\u2713":i.status==="warn"?"\u26A0":"\u2717";if(console.log(`${s} ${i.name}: ${i.message}`),i.detail)for(let c of i.detail)console.log(` \u2192 ${c}`)}let o=n.checks.filter((i)=>i.status==="warn").length,r=n.checks.filter((i)=>i.status==="fail").length;if(n.healthy)console.log(`
|
|
25
|
+
All checks passed.`);else{let i=[];if(r>0)i.push(`${r} error(s)`);if(o>0)i.push(`${o} warning(s)`);console.log(`
|
|
26
|
+
${i.join(", ")} found.`)}if(e.fix){if(n.healthy)console.log(`
|
|
28
27
|
Nothing to fix.`),process.exit(0);console.log(`
|
|
29
28
|
Running auto-fix...
|
|
30
|
-
`);let i=await
|
|
31
|
-
Fixed ${c} issue(s)${
|
|
29
|
+
`);let i=await Si(t);if(i.length===0)console.log("No auto-fixable issues found.");else{for(let f of i){let m=f.success?"\u2713":"\u2717",l=f.detail?` (${f.detail})`:"";console.log(`${m} ${f.action}${l}`)}let c=i.filter((f)=>f.success).length,u=i.filter((f)=>!f.success).length;console.log(`
|
|
30
|
+
Fixed ${c} issue(s)${u>0?`, ${u} failed`:""}.`)}let s=await rr(t);if(s.healthy)console.log("All checks now pass.");process.exit(s.healthy?0:1)}process.exit(n.healthy?0:1)}},Pp=$p});var mf={};Ye(mf,{default:()=>Wp});function Sp(e){if(e?.includes("fish"))return"fish";if(e?.includes("bash"))return"bash";return"zsh"}function df(){return`omw() {
|
|
32
31
|
if [ "$1" = "switch" ] || [ "$1" = "sw" ]; then
|
|
33
32
|
local output
|
|
34
33
|
output=$(command omw "$@" 2>/dev/null)
|
|
@@ -46,7 +45,7 @@ Fixed ${c} issue(s)${f>0?`, ${f} failed`:""}.`)}let s=await yo(e);if(s.healthy)c
|
|
|
46
45
|
else
|
|
47
46
|
command omw "$@"
|
|
48
47
|
fi
|
|
49
|
-
}`}function
|
|
48
|
+
}`}function hf(){return`function omw
|
|
50
49
|
if test "$argv[1]" = "switch"; or test "$argv[1]" = "sw"
|
|
51
50
|
set output (command omw $argv 2>/dev/null)
|
|
52
51
|
set status_code $status
|
|
@@ -63,7 +62,7 @@ Fixed ${c} issue(s)${f>0?`, ${f} failed`:""}.`)}let s=await yo(e);if(s.healthy)c
|
|
|
63
62
|
else
|
|
64
63
|
command omw $argv
|
|
65
64
|
end
|
|
66
|
-
end`}function
|
|
65
|
+
end`}function Ep(){return`_omw_completions() {
|
|
67
66
|
local cur="\${COMP_WORDS[COMP_CWORD]}"
|
|
68
67
|
local prev="\${COMP_WORDS[COMP_CWORD-1]}"
|
|
69
68
|
local commands="add list remove switch clean config doctor pin log archive rename clone import exec diff open status shell-init"
|
|
@@ -87,7 +86,7 @@ end`}function $u(){return`_omw_completions() {
|
|
|
87
86
|
;;
|
|
88
87
|
esac
|
|
89
88
|
}
|
|
90
|
-
complete -F _omw_completions omw`}function
|
|
89
|
+
complete -F _omw_completions omw`}function Mp(){return`_omw() {
|
|
91
90
|
local -a commands
|
|
92
91
|
commands=(
|
|
93
92
|
'add:Add a new worktree'
|
|
@@ -124,7 +123,7 @@ complete -F _omw_completions omw`}function Su(){return`_omw() {
|
|
|
124
123
|
esac
|
|
125
124
|
fi
|
|
126
125
|
}
|
|
127
|
-
compdef _omw omw`}function
|
|
126
|
+
compdef _omw omw`}function yp(){return`complete -c omw -f
|
|
128
127
|
complete -c omw -n '__fish_use_subcommand' -a 'add' -d 'Add a new worktree'
|
|
129
128
|
complete -c omw -n '__fish_use_subcommand' -a 'list' -d 'List worktrees'
|
|
130
129
|
complete -c omw -n '__fish_use_subcommand' -a 'remove' -d 'Remove a worktree'
|
|
@@ -142,29 +141,29 @@ complete -c omw -n '__fish_use_subcommand' -a 'exec' -d 'Run command'
|
|
|
142
141
|
complete -c omw -n '__fish_use_subcommand' -a 'diff' -d 'Show diff'
|
|
143
142
|
complete -c omw -n '__fish_use_subcommand' -a 'open' -d 'Open in editor'
|
|
144
143
|
complete -c omw -n '__fish_use_subcommand' -a 'status' -d 'Show status'
|
|
145
|
-
complete -c omw -n '__fish_seen_subcommand_from add switch rename pin archive' -a '(git branch --format="%(refname:short)" 2>/dev/null)'`}function
|
|
146
|
-
`+s),process.exit(0)}if(r==="fish")console.log(
|
|
147
|
-
`);let s=async(
|
|
148
|
-
`))console.log(` ${
|
|
149
|
-
`))console.log(` ${
|
|
150
|
-
`);
|
|
151
|
-
`);for(let
|
|
152
|
-
Cloned: ${
|
|
153
|
-
`);for(let i of
|
|
154
|
-
Killed ${r} session${r!==1?"s":""}.`)}var
|
|
155
|
-
`)}function
|
|
156
|
-
`)}function
|
|
157
|
-
`))}let
|
|
158
|
-
`)}function ya(t){let e=dp(t),o=Mo(Sa(e),"references"),n=wp(),r=bp(),i=Sa(e);if(!Ar(i))Ca(i,{recursive:!0});if(!Ar(o))Ca(o,{recursive:!0});let s=Ar(e);$a(e,n,"utf-8");for(let[c,f]of r.entries())$a(Mo(o,c),f,"utf-8");return{filePath:e,referenceDir:o,referenceCount:r.size,platform:t,action:s?"updated":"created"}}var Ir,mp="Git worktree manager. Use when working with git worktrees \u2014 creating, switching, removing, listing, or managing worktrees across repositories. Also use for monorepo focus, tmux sessions, and worktree health checks.",xp,Pa;var Ea=N(()=>{Ir=["claude-code","codex","opencode"];xp=[{command:"add",aliases:"-",description:"Create a new worktree from a branch, template, or PR."},{command:"remove",aliases:"rm",description:"Remove a worktree by branch or path."},{command:"list",aliases:"ls",description:"List worktrees with branch, path, status, and focus."},{command:"switch",aliases:"sw",description:"Print shell cd command for a target worktree."},{command:"status",aliases:"st",description:"Show status summary for worktrees."},{command:"clean",aliases:"-",description:"Clean merged worktrees and optionally report stale ones."},{command:"doctor",aliases:"-",description:"Run worktree health checks and optional auto-fixes."},{command:"exec",aliases:"-",description:"Run commands across non-main worktrees."},{command:"diff",aliases:"-",description:"Compare two refs or worktree branches."},{command:"pin",aliases:"unpin",description:"Pin or unpin worktrees and inspect pin metadata."},{command:"log",aliases:"logs",description:"Read or clear the activity log."},{command:"archive",aliases:"-",description:"Archive worktree changes as patch files."},{command:"rename",aliases:"-",description:"Rename a worktree branch and optionally move its path."},{command:"clone",aliases:"-",description:"Clone a repository and initialize omw setup."},{command:"import",aliases:"-",description:"Import an existing worktree into omw metadata."},{command:"session",aliases:"ss",description:"Manage tmux sessions for worktrees."},{command:"config",aliases:"-",description:"Initialize, inspect, validate, and manage config profiles."},{command:"open",aliases:"-",description:"Open a worktree path in your preferred editor."},{command:"shell-init",aliases:"-",description:"Generate shell integration and completions."},{command:"init",aliases:"-",description:"Initialize config or install/update omw AI agent skill files."}],Pa=[{command:"add",summary:"Create a new worktree from a branch, template, or GitHub PR.",synopsis:"omw add [branch] [path]",options:[{flag:"--create",type:"boolean",alias:"-c",description:"Optional compatibility flag; missing branches are created automatically"},{flag:"--base",type:"string",alias:"-b",description:"Base branch/commit for new branch"},{flag:"--focus",type:"array",alias:"-f",description:"Focus packages for monorepo"},{flag:"--template",type:"string",alias:"-t",description:"Use a named template from config"},{flag:"--pr",type:"number",alias:"-",description:"Create worktree from a GitHub PR number"},{flag:"--session",type:"boolean",alias:"-s",description:"Create a tmux session for this worktree"},{flag:"--layout",type:"string",alias:"-",description:"Session layout name from config"}],examples:[["Create a feature branch worktree","omw add feature/auth --base main"],["Create from PR with session layout","omw add feature/review --pr 123 --session --layout dev"]],notes:["Creates the branch automatically when it does not already exist.","Existing branches are reused as-is; --base only applies when a new branch is created.","Runs copyFiles, linkFiles, sharedDeps, postCreate hooks, monorepo hooks after creation.","Rolls back on hook failure.","Requires gh CLI for --pr.","Supports comma/space separated focus paths."],configKeys:["`defaults.worktreeDir` \u2014 Directory pattern for new worktrees","`defaults.copyFiles` \u2014 Files to copy from main worktree","`defaults.linkFiles` \u2014 Files to symlink from main worktree","`defaults.sharedDeps` \u2014 Shared dependency strategy and paths","`defaults.postCreate` \u2014 Hooks to run after worktree creation","`defaults.autoUpstream` \u2014 Auto-set upstream tracking branch","`templates.*` \u2014 Named template overrides","`sessions.autoCreate` \u2014 Auto-create tmux session on add","`sessions.layouts` \u2014 Tmux session layout definitions"]},{command:"remove",summary:"Remove a worktree by branch name or path.",synopsis:"omw remove <branch-or-path>",options:[{flag:"--force",type:"boolean",alias:"-f",description:"Force removal even with uncommitted changes"},{flag:"--yes",type:"boolean",alias:"-y",description:"Skip confirmation prompt"}],examples:[["Remove a branch worktree","omw remove feature/auth"],["Force remove without prompt","omw remove feature/auth --force --yes"]],notes:["Runs postRemove hooks and monorepo postRemove hooks before removal.","Cannot remove main worktree.","Cannot remove locked worktrees.","Auto-kills tmux session if sessions.autoKill is enabled."],configKeys:["`defaults.postRemove` \u2014 Hooks to run before worktree removal","`sessions.autoKill` \u2014 Auto-kill tmux session on remove"]},{command:"list",summary:"List worktrees with branch, path, status, and focus details.",synopsis:"omw list",options:[{flag:"--json",type:"boolean",alias:"-j",description:"Output as JSON"},{flag:"--porcelain",type:"boolean",alias:"-p",description:"Machine-readable output"},{flag:"--all",type:"boolean",alias:"-a",description:"List worktrees from all configured repos"}],examples:[["Show all worktrees","omw list"],["Get machine-readable output","omw list --porcelain"]],notes:["Shows branch, path, status (clean/dirty/locked), focus paths.","Focus column truncated to 40 chars."],configKeys:["`repos[].path` \u2014 Repository paths for --all flag"]},{command:"switch",summary:"Switch shell context to a worktree by branch or path.",synopsis:"omw switch <branch-or-path>",options:[],examples:[["Switch using branch name","omw switch feature/auth"],["Switch using path","omw switch ~/.omw/worktrees/repo-feature-auth"]],notes:["Outputs cd command for shell eval.","Requires shell integration (omw shell-init).","Auto-switches tmux session if sessions.enabled and inside tmux.","Logs switch activity."],configKeys:["`sessions.enabled` \u2014 Enable tmux session switching","`sessions.prefix` \u2014 Tmux session name prefix"]},{command:"status",summary:"Show branch health, sync state, commit info, and focus.",synopsis:"omw status",options:[{flag:"--json",type:"boolean",alias:"-j",description:"Output as JSON"},{flag:"--all",type:"boolean",alias:"-a",description:"Show worktrees from all configured repos"}],examples:[["Print status table","omw status"],["Parse status in scripts","omw status --json"]],notes:["Shows branch, dirty count, sync status (ahead/behind), last commit info, focus paths.","Marks current worktree with *."],configKeys:["`repos[].path` \u2014 Repository paths for --all flag"]},{command:"clean",summary:"Remove merged worktrees and optionally inspect stale candidates.",synopsis:"omw clean",options:[{flag:"--dry-run",type:"boolean",alias:"-n",description:"Show what would be removed"},{flag:"--yes",type:"boolean",alias:"-y",description:"Skip confirmation"},{flag:"--stale",type:"boolean",alias:"-",description:"Also show stale worktrees based on lifecycle config"}],examples:[["Preview merged cleanup","omw clean --dry-run"],["Run cleanup without prompts","omw clean --yes"]],notes:["Only removes merged worktrees.","Skips pinned and dirty worktrees.","Runs git worktree prune after cleanup.","--stale uses lifecycle config (staleAfterDays, maxWorktrees)."],configKeys:["`lifecycle.staleAfterDays` \u2014 Days until a worktree is considered stale","`lifecycle.maxWorktrees` \u2014 Maximum allowed worktrees","`lifecycle.autoCleanMerged` \u2014 Auto-clean merged worktrees"]},{command:"doctor",summary:"Run health checks for worktree state and configuration.",synopsis:"omw doctor",options:[{flag:"--json",type:"boolean",alias:"-j",description:"Output as JSON"},{flag:"--fix",type:"boolean",alias:"-",description:"Auto-fix issues"}],examples:[["Run health checks","omw doctor"],["Auto-fix detectable issues","omw doctor --fix"]],notes:["Checks: git version (>=2.17), config validity, stale worktrees, orphaned directories, lock status, dirty worktrees.","Auto-fix: prune stale, remove orphans, unlock stale locks.","Exit code 0 if healthy, 1 if warnings/errors."],configKeys:[]},{command:"exec",summary:"Run a shell command across filtered non-main worktrees.",synopsis:"omw exec <command>",options:[{flag:"--all",type:"boolean",alias:"-a",description:"Run across all configured repos"},{flag:"--dirty",type:"boolean",alias:"-",description:"Only run in dirty worktrees"},{flag:"--clean",type:"boolean",alias:"-",description:"Only run in clean worktrees"},{flag:"--behind",type:"boolean",alias:"-",description:"Only run in worktrees behind upstream"},{flag:"--parallel",type:"boolean",alias:"-p",description:"Run commands in parallel"},{flag:"--json",type:"boolean",alias:"-j",description:"Output results as JSON"}],examples:[["Run tests in parallel",'omw exec "bun test" --parallel'],["Pull only behind worktrees",'omw exec "git pull" --behind']],notes:["Runs in non-main worktrees only.","Sets env vars: OMW_BRANCH, OMW_WORKTREE_PATH, OMW_REPO_PATH.","Exit code 1 if any command fails."],configKeys:["`repos[].path` \u2014 Repository paths for --all flag"]},{command:"diff",summary:"Diff two refs or worktree branches.",synopsis:"omw diff <ref1> [ref2]",options:[{flag:"--stat",type:"boolean",alias:"-s",description:"Show diffstat summary only"},{flag:"--name-only",type:"boolean",alias:"-n",description:"Show only names of changed files"}],examples:[["Show diffstat only","omw diff feature/a feature/b --stat"],["List changed file names","omw diff feature/a --name-only"]],notes:["ref2 defaults to HEAD.","Resolves worktree branch names to refs automatically."],configKeys:[]},{command:"pin",summary:"Pin or unpin worktrees and inspect pin metadata.",synopsis:"omw pin [branch]",options:[{flag:"--reason",type:"string",alias:"-",description:"Reason for pinning"},{flag:"--list",type:"boolean",alias:"-",description:"List pinned worktrees"},{flag:"--json",type:"boolean",alias:"-j",description:"Output as JSON"},{flag:"--unpin",type:"boolean",alias:"-",description:"Unpin instead of pinning"}],examples:[["Pin with a reason",'omw pin feature/auth --reason "active sprint"'],["Unpin a branch","omw pin feature/auth --unpin"]],notes:["Pinned worktrees are excluded from omw clean.","Also invokable as omw unpin <branch>.","Pin metadata stored in git internals."],configKeys:[]},{command:"log",summary:"View or clear activity log events.",synopsis:"omw log",options:[{flag:"--limit",type:"number",alias:"-",description:"default 20, Show the last N entries"},{flag:"--json",type:"boolean",alias:"-j",description:"Output as JSON"},{flag:"--clear",type:"boolean",alias:"-",description:"Clear the activity log"}],examples:[["Show recent entries","omw log --limit 50"],["Clear the log","omw log --clear"]],notes:["Events: create (green), delete (red), switch (blue), rename (yellow), archive (magenta), import (cyan).","Color-coded in terminal."],configKeys:[]},{command:"archive",summary:"Archive worktree changes as patch files before optional removal.",synopsis:"omw archive [branch]",options:[{flag:"--yes",type:"boolean",alias:"-y",description:"Skip confirmation prompt"},{flag:"--keep",type:"boolean",alias:"-",description:"Archive without removing the worktree"},{flag:"--list",type:"boolean",alias:"-",description:"List all archives"},{flag:"--json",type:"boolean",alias:"-j",description:"Output as JSON with --list"}],examples:[["Archive and remove","omw archive feature/done --yes"],["List archive records","omw archive --list --json"]],notes:["Archives stored as patch files in ~/.omw/archives/.","Cannot archive main worktree.","Runs postRemove hooks before removal unless --keep."],configKeys:["`defaults.postRemove` \u2014 Hooks to run before worktree removal"]},{command:"rename",summary:"Rename a worktree branch and optionally move its directory path.",synopsis:"omw rename <old> <new>",options:[{flag:"--move-path",type:"boolean",alias:"-",description:"Also rename the worktree directory path"}],examples:[["Rename a worktree branch","omw rename feature/old feature/new"],["Rename branch and directory","omw rename feature/old feature/new --move-path"]],notes:["Cannot rename main worktree.","Checks for branch name conflicts.","Logs rename activity.","--move-path replaces old branch slug with new one in directory name."],configKeys:[]},{command:"clone",summary:"Clone a repository and optionally apply omw template setup.",synopsis:"omw clone <url> [path]",options:[{flag:"--template",type:"string",alias:"-t",description:"Apply a named template after cloning"},{flag:"--init-config",type:"boolean",alias:"-",description:"default true, Initialize omw config after cloning"}],examples:[["Clone and initialize","omw clone https://github.com/user/repo.git"],["Clone with template and no config init","omw clone https://github.com/user/repo.git --template review --no-init-config"]],notes:["Auto-detects target path from URL.","Runs template postCreate hooks if template specified.","Use --no-init-config to skip config initialization."],configKeys:["`templates.*` \u2014 Named template overrides"]},{command:"import",summary:"Import an existing git worktree into omw metadata.",synopsis:"omw import <path>",options:[{flag:"--focus",type:"array",alias:"-f",description:"Focus packages for monorepo"},{flag:"--pin",type:"boolean",alias:"-",description:"Pin the worktree"}],examples:[["Import a worktree path","omw import /path/to/worktree"],["Import with focus and pin","omw import /path/to/worktree --focus apps/web,apps/api --pin"]],notes:["Validates that path is a valid git worktree.","Logs import activity.","Supports comma/space separated focus paths."],configKeys:[]},{command:"session",summary:"Manage tmux sessions for worktrees.",synopsis:"omw session [branch-or-path]",options:[{flag:"--list",type:"boolean",alias:"-l",description:"List active omw tmux sessions"},{flag:"--kill",type:"boolean",alias:"-k",description:"Kill the session for the specified worktree"},{flag:"--kill-all",type:"boolean",alias:"-",description:"Kill all omw tmux sessions"},{flag:"--layout",type:"string",alias:"-",description:"Use a named layout from config"},{flag:"--json",type:"boolean",alias:"-j",description:"Output in JSON format"}],examples:[["Attach or create a session","omw session feature/auth"],["List sessions as JSON","omw session --list --json"]],notes:["Requires tmux.","Session naming: branch feat/auth-token \u2192 tmux session omw_feat-auth-token.","Supports layout templates with multiple windows."],configKeys:["`sessions.enabled` \u2014 Enable tmux session integration","`sessions.autoCreate` \u2014 Auto-create session on worktree add","`sessions.autoKill` \u2014 Auto-kill session on worktree remove","`sessions.prefix` \u2014 Tmux session name prefix","`sessions.defaultLayout` \u2014 Default layout name","`sessions.layouts` \u2014 Layout definitions with windows"]},{command:"config",summary:"Initialize, inspect, edit, validate, and manage profiles.",synopsis:"omw config",options:[{flag:"--init",type:"boolean",alias:"-",description:"Create default config file"},{flag:"--show",type:"boolean",alias:"-s",description:"Print current config as JSON"},{flag:"--edit",type:"boolean",alias:"-e",description:"Open config in $EDITOR"},{flag:"--path",type:"boolean",alias:"-",description:"Print config file path"},{flag:"--validate",type:"boolean",alias:"-",description:"Validate config against schema"},{flag:"--profiles",type:"boolean",alias:"-",description:"List config profiles"},{flag:"--profile",type:"string",alias:"-",description:"Profile name for activation/deletion"},{flag:"--activate",type:"boolean",alias:"-",description:"Activate the specified profile"},{flag:"--delete",type:"boolean",alias:"-",description:"Delete the specified profile"}],examples:[["Initialize config","omw config --init"],["Activate a profile","omw config --profile work --activate"]],notes:["Config path: ~/.config/oh-my-worktree/config.json.","XDG-compliant."],configKeys:[]},{command:"open",summary:"Open the target or current worktree in an editor.",synopsis:"omw open [branch-or-path]",options:[{flag:"--editor",type:"string",alias:"-e",description:"Editor command to use"},{flag:"--list-editors",type:"boolean",alias:"-",description:"List detected editors"}],examples:[["Open current worktree","omw open"],["Open with specific editor","omw open feature/auth --editor nvim"]],notes:["Auto-detects editors: code, cursor, vim, nvim, emacs, nano, subl, zed, idea, webstorm.","Uses $VISUAL or $EDITOR env vars.","Defaults to current worktree if no branch specified."],configKeys:[]},{command:"shell-init",summary:"Generate shell integration wrappers and completions.",synopsis:"omw shell-init [shell]",options:[{flag:"--completions",type:"string",alias:"-",description:"Generate shell completions: bash, zsh, fish"}],examples:[["Generate shell wrapper","omw shell-init zsh"],["Generate completion script","omw shell-init --completions fish"]],notes:["Shell arg is auto-detected if omitted.","Generates wrapper function for omw switch to work with shell cd.","Supports bash, zsh, fish."],configKeys:[]},{command:"init",summary:"Initialize omw config or install AI agent skill files.",synopsis:"omw init",options:[{flag:"--skill",type:"string",alias:"-s",description:"Install AI agent skill: claude-code, codex, opencode"}],examples:[["Initialize config","omw init"],["Install Claude Code skill","omw init --skill claude-code"],["Install Codex skill","omw init --skill codex"]],notes:["Without --skill, reuses config initialization and creates only config.json.","With --skill, installs or updates SKILL.md + references/ directory.","Idempotent \u2014 running again updates existing files without breaking existing setup."],configKeys:[]}]});var Ra={};xt(Ra,{default:()=>Pp});import{dirname as $p}from"path";var Sp,Pp;var Ma=N(()=>{$t();Ea();Sp={command:"init",describe:"Initialize config or install omw integrations",builder:(t)=>t.option("skill",{type:"string",alias:"s",describe:`Install AI agent skill (${Ir.join(", ")})`,choices:Ir}),handler:async(t)=>{let e=t.skill;try{if(!e){let r=fe();console.log(`\u2713 Initialized config \u2192 ${r}`),process.exit(0)}let o=ya(e),n=o.action==="created"?"Installed":"Updated";console.log(`\u2713 ${n} \u2192 ${$p(o.filePath)}/`),console.log(" SKILL.md"),console.log(` references/ (${o.referenceCount} commands)`),process.exit(0)}catch(o){console.error(`Error: ${o.message}`),process.exit(1)}}},Pp=Sp});import"@opentui/solid/preload";import{notStrictEqual as Qa,strictEqual as Ya}from"assert";var Fa={right:Aa,center:Ia};class _r{constructor(t){var e;this.width=t.width,this.wrap=(e=t.wrap)!==null&&e!==void 0?e:!0,this.rows=[]}span(...t){let e=this.div(...t);e.span=!0}resetOutput(){this.rows=[]}div(...t){if(t.length===0)this.div("");if(this.wrap&&this.shouldApplyLayoutDSL(...t)&&typeof t[0]==="string")return this.applyLayoutDSL(t[0]);let e=t.map((o)=>{if(typeof o==="string")return this.colFromString(o);return o});return this.rows.push(e),e}shouldApplyLayoutDSL(...t){return t.length===1&&typeof t[0]==="string"&&/[\t\n]/.test(t[0])}applyLayoutDSL(t){let e=t.split(`
|
|
159
|
-
`).map((
|
|
160
|
-
`)}rowToString(t
|
|
161
|
-
`);else
|
|
162
|
-
`);if(r.border)
|
|
163
|
-
`;r+=t.charAt(i)}if(o&&n)r=`${o}${r}${n}`;return r}function In(t){return Tr(t,{stringWidth:(e)=>{return[...e].length},stripAnsi:An,wrap:Hr})}import{dirname as Nr,resolve as Jr}from"path";import{readdirSync as ja,statSync as _a}from"fs";function jn(t,e){let o=Jr(".",t),n;if(!_a(o).isDirectory())o=Nr(o);while(!0){if(n=e(o,ja(o)),n)return Jr(o,n);if(o=Nr(n=o),n===o)break}}import{inspect as tf}from"util";import{readFileSync as ef}from"fs";import{fileURLToPath as of}from"url";import{format as Ha}from"util";import{normalize as Na,resolve as Ja}from"path";function He(t){if(!(t!==t.toLowerCase()&&t!==t.toUpperCase()))t=t.toLowerCase();if(t.indexOf("-")===-1&&t.indexOf("_")===-1)return t;else{let o="",n=!1,r=t.match(/^-+/);for(let i=r?r[0].length:0;i<t.length;i++){let s=t.charAt(i);if(n)n=!1,s=s.toUpperCase();if(i!==0&&(s==="-"||s==="_"))n=!0;else if(s!=="-"&&s!=="_")o+=s}return o}}function Ko(t,e){let o=t.toLowerCase();e=e||"-";let n="";for(let r=0;r<t.length;r++){let i=o.charAt(r),s=t.charAt(r);if(i!==s&&r>0)n+=`${e}${o.charAt(r)}`;else n+=s}return n}function qo(t){if(t===null||t===void 0)return!1;if(typeof t==="number")return!0;if(/^0x[0-9a-f]+$/i.test(t))return!0;if(/^0[^.]/.test(t))return!1;return/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(t)}function kr(t){if(Array.isArray(t))return t.map((s)=>typeof s!=="string"?s+"":s);t=t.trim();let e=0,o=null,n=null,r=null,i=[];for(let s=0;s<t.length;s++){if(o=n,n=t.charAt(s),n===" "&&!r){if(o!==" ")e++;continue}if(n===r)r=null;else if((n==="'"||n==='"')&&!r)r=n;if(!i[e])i[e]="";i[e]+=n}return i}var Jt;(function(t){t.BOOLEAN="boolean",t.STRING="string",t.NUMBER="number",t.ARRAY="array"})(Jt||(Jt={}));var ue;class Tn{constructor(t){ue=t}parse(t,e){let o=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},e),n=kr(t),r=typeof t==="string",i=Ta(Object.assign(Object.create(null),o.alias)),s=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},o.configuration),c=Object.assign(Object.create(null),o.default),f=o.configObjects||[],a=o.envPrefix,h=s["populate--"],u=h?"--":"_",d=Object.create(null),g=Object.create(null),x=o.__||ue.format,m={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},b=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,S=new RegExp("^--"+s["negation-prefix"]+"(.+)");if([].concat(o.array||[]).filter(Boolean).forEach(function(w){let $=typeof w==="object"?w.key:w,W=Object.keys(w).map(function(P){return{boolean:"bools",string:"strings",number:"numbers"}[P]}).filter(Boolean).pop();if(W)m[W][$]=!0;m.arrays[$]=!0,m.keys.push($)}),[].concat(o.boolean||[]).filter(Boolean).forEach(function(w){m.bools[w]=!0,m.keys.push(w)}),[].concat(o.string||[]).filter(Boolean).forEach(function(w){m.strings[w]=!0,m.keys.push(w)}),[].concat(o.number||[]).filter(Boolean).forEach(function(w){m.numbers[w]=!0,m.keys.push(w)}),[].concat(o.count||[]).filter(Boolean).forEach(function(w){m.counts[w]=!0,m.keys.push(w)}),[].concat(o.normalize||[]).filter(Boolean).forEach(function(w){m.normalize[w]=!0,m.keys.push(w)}),typeof o.narg==="object")Object.entries(o.narg).forEach(([w,$])=>{if(typeof $==="number")m.nargs[w]=$,m.keys.push(w)});if(typeof o.coerce==="object")Object.entries(o.coerce).forEach(([w,$])=>{if(typeof $==="function")m.coercions[w]=$,m.keys.push(w)});if(typeof o.config<"u"){if(Array.isArray(o.config)||typeof o.config==="string")[].concat(o.config).filter(Boolean).forEach(function(w){m.configs[w]=!0});else if(typeof o.config==="object")Object.entries(o.config).forEach(([w,$])=>{if(typeof $==="boolean"||typeof $==="function")m.configs[w]=$})}dt(o.key,i,o.default,m.arrays),Object.keys(c).forEach(function(w){(m.aliases[w]||[]).forEach(function($){c[$]=c[w]})});let E=null;io();let y=[],R=Object.assign(Object.create(null),{_:[]}),it={};for(let w=0;w<n.length;w++){let $=n[w],W=$.replace(/^-{3,}/,"---"),P,C,H,B,z,Pt;if($!=="--"&&/^-/.test($)&&nt($))st($);else if(W.match(/^---+(=|$)/)){st($);continue}else if($.match(/^--.+=/)||!s["short-option-groups"]&&$.match(/^-.+=/)){if(B=$.match(/^--?([^=]+)=([\s\S]*)$/),B!==null&&Array.isArray(B)&&B.length>=3)if(A(B[1],m.arrays))w=ot(w,B[1],n,B[2]);else if(A(B[1],m.nargs)!==!1)w=G(w,B[1],n,B[2]);else et(B[1],B[2],!0)}else if($.match(S)&&s["boolean-negation"]){if(B=$.match(S),B!==null&&Array.isArray(B)&&B.length>=2)C=B[1],et(C,A(C,m.arrays)?[!1]:!1)}else if($.match(/^--.+/)||!s["short-option-groups"]&&$.match(/^-[^-]+/)){if(B=$.match(/^--?(.+)/),B!==null&&Array.isArray(B)&&B.length>=2)if(C=B[1],A(C,m.arrays))w=ot(w,C,n);else if(A(C,m.nargs)!==!1)w=G(w,C,n);else if(z=n[w+1],z!==void 0&&(!z.match(/^-/)||z.match(b))&&!A(C,m.bools)&&!A(C,m.counts))et(C,z),w++;else if(/^(true|false)$/.test(z))et(C,z),w++;else et(C,U(C))}else if($.match(/^-.\..+=/)){if(B=$.match(/^-([^=]+)=([\s\S]*)$/),B!==null&&Array.isArray(B)&&B.length>=3)et(B[1],B[2])}else if($.match(/^-.\..+/)&&!$.match(b)){if(z=n[w+1],B=$.match(/^-(.\..+)/),B!==null&&Array.isArray(B)&&B.length>=2)if(C=B[1],z!==void 0&&!z.match(/^-/)&&!A(C,m.bools)&&!A(C,m.counts))et(C,z),w++;else et(C,U(C))}else if($.match(/^-[^-]+/)&&!$.match(b)){H=$.slice(1,-1).split(""),P=!1;for(let Ft=0;Ft<H.length;Ft++){if(z=$.slice(Ft+2),H[Ft+1]&&H[Ft+1]==="="){if(Pt=$.slice(Ft+3),C=H[Ft],A(C,m.arrays))w=ot(w,C,n,Pt);else if(A(C,m.nargs)!==!1)w=G(w,C,n,Pt);else et(C,Pt);P=!0;break}if(z==="-"){et(H[Ft],z);continue}if(/[A-Za-z]/.test(H[Ft])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(z)&&A(z,m.bools)===!1){et(H[Ft],z),P=!0;break}if(H[Ft+1]&&H[Ft+1].match(/\W/)){et(H[Ft],z),P=!0;break}else et(H[Ft],U(H[Ft]))}if(C=$.slice(-1)[0],!P&&C!=="-")if(A(C,m.arrays))w=ot(w,C,n);else if(A(C,m.nargs)!==!1)w=G(w,C,n);else if(z=n[w+1],z!==void 0&&(!/^(-|--)[^-]/.test(z)||z.match(b))&&!A(C,m.bools)&&!A(C,m.counts))et(C,z),w++;else if(/^(true|false)$/.test(z))et(C,z),w++;else et(C,U(C))}else if($.match(/^-[0-9]$/)&&$.match(b)&&A($.slice(1),m.bools))C=$.slice(1),et(C,U(C));else if($==="--"){y=n.slice(w+1);break}else if(s["halt-at-non-option"]){y=n.slice(w);break}else st($)}if(mt(R,!0),mt(R,!1),L(R),tt(),k(R,m.aliases,c,!0),q(R),s["set-placeholder-key"])ut(R);if(Object.keys(m.counts).forEach(function(w){if(!T(R,w.split(".")))et(w,0)}),h&&y.length)R[u]=[];if(y.forEach(function(w){R[u].push(w)}),s["camel-case-expansion"]&&s["strip-dashed"])Object.keys(R).filter((w)=>w!=="--"&&w.includes("-")).forEach((w)=>{delete R[w]});if(s["strip-aliased"])[].concat(...Object.keys(i).map((w)=>i[w])).forEach((w)=>{if(s["camel-case-expansion"]&&w.includes("-"))delete R[w.split(".").map(($)=>He($)).join(".")];delete R[w]});function st(w){let $=D("_",w);if(typeof $==="string"||typeof $==="number")R._.push($)}function G(w,$,W,P){let C,H=A($,m.nargs);if(H=typeof H!=="number"||isNaN(H)?1:H,H===0){if(!rt(P))E=Error(x("Argument unexpected for: %s",$));return et($,U($)),w}let B=rt(P)?0:1;if(s["nargs-eats-options"]){if(W.length-(w+1)+B<H)E=Error(x("Not enough arguments following: %s",$));B=H}else{for(C=w+1;C<W.length;C++)if(!W[C].match(/^-[^0-9]/)||W[C].match(b)||nt(W[C]))B++;else break;if(B<H)E=Error(x("Not enough arguments following: %s",$))}let z=Math.min(B,H);if(!rt(P)&&z>0)et($,P),z--;for(C=w+1;C<z+w+1;C++)et($,W[C]);return w+z}function ot(w,$,W,P){let C=[],H=P||W[w+1],B=A($,m.nargs);if(A($,m.bools)&&!/^(true|false)$/.test(H))C.push(!0);else if(rt(H)||rt(P)&&/^-/.test(H)&&!b.test(H)&&!nt(H)){if(c[$]!==void 0){let z=c[$];C=Array.isArray(z)?z:[z]}}else{if(!rt(P))C.push(_($,P,!0));for(let z=w+1;z<W.length;z++){if(!s["greedy-arrays"]&&C.length>0||B&&typeof B==="number"&&C.length>=B)break;if(H=W[z],/^-/.test(H)&&!b.test(H)&&!nt(H))break;w=z,C.push(_($,H,r))}}if(typeof B==="number"&&(B&&C.length<B||isNaN(B)&&C.length===0))E=Error(x("Not enough arguments following: %s",$));return et($,C),w}function et(w,$,W=r){if(/-/.test(w)&&s["camel-case-expansion"]){let H=w.split(".").map(function(B){return He(B)}).join(".");le(w,H)}let P=_(w,$,W),C=w.split(".");if(Z(R,C,P),m.aliases[w])m.aliases[w].forEach(function(H){let B=H.split(".");Z(R,B,P)});if(C.length>1&&s["dot-notation"])(m.aliases[C[0]]||[]).forEach(function(H){let B=H.split("."),z=[].concat(C);if(z.shift(),B=B.concat(z),!(m.aliases[w]||[]).includes(B.join(".")))Z(R,B,P)});if(A(w,m.normalize)&&!A(w,m.arrays))[w].concat(m.aliases[w]||[]).forEach(function(B){Object.defineProperty(it,B,{enumerable:!0,get(){return $},set(z){$=typeof z==="string"?ue.normalize(z):z}})})}function le(w,$){if(!(m.aliases[w]&&m.aliases[w].length))m.aliases[w]=[$],d[$]=!0;if(!(m.aliases[$]&&m.aliases[$].length))le($,w)}function _(w,$,W){if(W)$=Ga($);if(A(w,m.bools)||A(w,m.counts)){if(typeof $==="string")$=$==="true"}let P=Array.isArray($)?$.map(function(C){return D(w,C)}):D(w,$);if(A(w,m.counts)&&(rt(P)||typeof P==="boolean"))P=_n();if(A(w,m.normalize)&&A(w,m.arrays))if(Array.isArray($))P=$.map((C)=>{return ue.normalize(C)});else P=ue.normalize($);return P}function D(w,$){if(!s["parse-positional-numbers"]&&w==="_")return $;if(!A(w,m.strings)&&!A(w,m.bools)&&!Array.isArray($)){if(qo($)&&s["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${$}`)))||!rt($)&&A(w,m.numbers))$=Number($)}return $}function L(w){let $=Object.create(null);k($,m.aliases,c),Object.keys(m.configs).forEach(function(W){let P=w[W]||$[W];if(P)try{let C=null,H=ue.resolve(ue.cwd(),P),B=m.configs[W];if(typeof B==="function"){try{C=B(H)}catch(z){C=z}if(C instanceof Error){E=C;return}}else C=ue.require(H);V(C)}catch(C){if(C.name==="PermissionDenied")E=C;else if(w[W])E=Error(x("Invalid JSON config file: %s",P))}})}function V(w,$){Object.keys(w).forEach(function(W){let P=w[W],C=$?$+"."+W:W;if(typeof P==="object"&&P!==null&&!Array.isArray(P)&&s["dot-notation"])V(P,C);else if(!T(R,C.split("."))||A(C,m.arrays)&&s["combine-arrays"])et(C,P)})}function tt(){if(typeof f<"u")f.forEach(function(w){V(w)})}function mt(w,$){if(typeof a>"u")return;let W=typeof a==="string"?a:"",P=ue.env();Object.keys(P).forEach(function(C){if(W===""||C.lastIndexOf(W,0)===0){let H=C.split("__").map(function(B,z){if(z===0)B=B.substring(W.length);return He(B)});if(($&&m.configs[H.join(".")]||!$)&&!T(w,H))et(H.join("."),P[C])}})}function q(w){let $,W=new Set;Object.keys(w).forEach(function(P){if(!W.has(P)){if($=A(P,m.coercions),typeof $==="function")try{let C=D(P,$(w[P]));[].concat(m.aliases[P]||[],P).forEach((H)=>{W.add(H),w[H]=C})}catch(C){E=C}}})}function ut(w){return m.keys.forEach(($)=>{if(~$.indexOf("."))return;if(typeof w[$]>"u")w[$]=void 0}),w}function k(w,$,W,P=!1){Object.keys(W).forEach(function(C){if(!T(w,C.split("."))){if(Z(w,C.split("."),W[C]),P)g[C]=!0;($[C]||[]).forEach(function(H){if(T(w,H.split(".")))return;Z(w,H.split("."),W[C])})}})}function T(w,$){let W=w;if(!s["dot-notation"])$=[$.join(".")];$.slice(0,-1).forEach(function(C){W=W[C]||{}});let P=$[$.length-1];if(typeof W!=="object")return!1;else return P in W}function Z(w,$,W){let P=w;if(!s["dot-notation"])$=[$.join(".")];$.slice(0,-1).forEach(function(Pt){if(Pt=zr(Pt),typeof P==="object"&&P[Pt]===void 0)P[Pt]={};if(typeof P[Pt]!=="object"||Array.isArray(P[Pt])){if(Array.isArray(P[Pt]))P[Pt].push({});else P[Pt]=[P[Pt],{}];P=P[Pt][P[Pt].length-1]}else P=P[Pt]});let C=zr($[$.length-1]),H=A($.join("."),m.arrays),B=Array.isArray(W),z=s["duplicate-arguments-array"];if(!z&&A(C,m.nargs)){if(z=!0,!rt(P[C])&&m.nargs[C]===1||Array.isArray(P[C])&&P[C].length===m.nargs[C])P[C]=void 0}if(W===_n())P[C]=_n(P[C]);else if(Array.isArray(P[C]))if(z&&H&&B)P[C]=s["flatten-duplicate-arrays"]?P[C].concat(W):(Array.isArray(P[C][0])?P[C]:[P[C]]).concat([W]);else if(!z&&Boolean(H)===Boolean(B))P[C]=W;else P[C]=P[C].concat([W]);else if(P[C]===void 0&&H)P[C]=B?W:[W];else if(z&&!(P[C]===void 0||A(C,m.counts)||A(C,m.bools)))P[C]=[P[C],W];else P[C]=W}function dt(...w){w.forEach(function($){Object.keys($||{}).forEach(function(W){if(m.aliases[W])return;m.aliases[W]=[].concat(i[W]||[]),m.aliases[W].concat(W).forEach(function(P){if(/-/.test(P)&&s["camel-case-expansion"]){let C=He(P);if(C!==W&&m.aliases[W].indexOf(C)===-1)m.aliases[W].push(C),d[C]=!0}}),m.aliases[W].concat(W).forEach(function(P){if(P.length>1&&/[A-Z]/.test(P)&&s["camel-case-expansion"]){let C=Ko(P,"-");if(C!==W&&m.aliases[W].indexOf(C)===-1)m.aliases[W].push(C),d[C]=!0}}),m.aliases[W].forEach(function(P){m.aliases[P]=[W].concat(m.aliases[W].filter(function(C){return P!==C}))})})})}function A(w,$){let W=[].concat(m.aliases[w]||[],w),P=Object.keys($),C=W.find((H)=>P.includes(H));return C?$[C]:!1}function ee(w){let $=Object.keys(m);return[].concat($.map((P)=>m[P])).some(function(P){return Array.isArray(P)?P.includes(w):P[w]})}function Se(w,...$){return[].concat(...$).some(function(P){let C=w.match(P);return C&&ee(C[1])})}function F(w){if(w.match(b)||!w.match(/^-[^-]+/))return!1;let $=!0,W,P=w.slice(1).split("");for(let C=0;C<P.length;C++){if(W=w.slice(C+2),!ee(P[C])){$=!1;break}if(P[C+1]&&P[C+1]==="="||W==="-"||/[A-Za-z]/.test(P[C])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(W)||P[C+1]&&P[C+1].match(/\W/))break}return $}function nt(w){return s["unknown-options-as-args"]&&pt(w)}function pt(w){if(w=w.replace(/^-{3,}/,"--"),w.match(b))return!1;if(F(w))return!1;return!Se(w,/^-+([^=]+?)=[\s\S]*$/,S,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function U(w){if(!A(w,m.bools)&&!A(w,m.counts)&&`${w}`in c)return c[w];else return Q(ft(w))}function Q(w){return{[Jt.BOOLEAN]:!0,[Jt.STRING]:"",[Jt.NUMBER]:void 0,[Jt.ARRAY]:[]}[w]}function ft(w){let $=Jt.BOOLEAN;if(A(w,m.strings))$=Jt.STRING;else if(A(w,m.numbers))$=Jt.NUMBER;else if(A(w,m.bools))$=Jt.BOOLEAN;else if(A(w,m.arrays))$=Jt.ARRAY;return $}function rt(w){return w===void 0}function io(){Object.keys(m.counts).find((w)=>{if(A(w,m.arrays))return E=Error(x("Invalid configuration: %s, opts.count excludes opts.array.",w)),!0;else if(A(w,m.nargs))return E=Error(x("Invalid configuration: %s, opts.count excludes opts.narg.",w)),!0;return!1})}return{aliases:Object.assign({},m.aliases),argv:Object.assign(it,R),configuration:s,defaulted:Object.assign({},g),error:E,newAliases:Object.assign({},d)}}}function Ta(t){let e=[],o=Object.create(null),n=!0;Object.keys(t).forEach(function(r){e.push([].concat(t[r],r))});while(n){n=!1;for(let r=0;r<e.length;r++)for(let i=r+1;i<e.length;i++)if(e[r].filter(function(c){return e[i].indexOf(c)!==-1}).length){e[r]=e[r].concat(e[i]),e.splice(i,1),n=!0;break}}return e.forEach(function(r){r=r.filter(function(s,c,f){return f.indexOf(s)===c});let i=r.pop();if(i!==void 0&&typeof i==="string")o[i]=r}),o}function _n(t){return t!==void 0?t+1:1}function zr(t){if(t==="__proto__")return"___proto___";return t}function Ga(t){return typeof t==="string"&&(t[0]==="'"||t[0]==='"')&&t[t.length-1]===t[0]?t.substring(1,t.length-1):t}var Gn,Hn,Nn,vr=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,Ur=(Hn=(Gn=process===null||process===void 0?void 0:process.versions)===null||Gn===void 0?void 0:Gn.node)!==null&&Hn!==void 0?Hn:(Nn=process===null||process===void 0?void 0:process.version)===null||Nn===void 0?void 0:Nn.slice(1);if(Ur){if(Number(Ur.match(/^([^.]+)/)[1])<vr)throw Error(`yargs parser supports a minimum Node.js version of ${vr}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var ka=process?process.env:{},Vr=new Tn({cwd:process.cwd,env:()=>{return ka},format:Ha,normalize:Na,resolve:Ja,require:(t)=>{return he(t)}}),Oo=function(e,o){return Vr.parse(e.slice(),o).argv};Oo.detailed=function(t,e){return Vr.parse(t.slice(),e)};Oo.camelCase=He;Oo.decamelize=Ko;Oo.looksLikeNumber=qo;var Jn=Oo;import{basename as nf,dirname as rf,extname as sf,relative as cf,resolve as ti}from"path";function Kr(){if(za())return 0;return 1}function za(){return va()&&!process.defaultApp}function va(){return!!process.versions.electron}function kn(t){return t.slice(Kr()+1)}function qr(){return process.argv[Kr()]}class lt extends Error{constructor(t){super(t||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,lt)}}import{readFileSync as Ua,statSync as Va,writeFile as Ka}from"fs";import{format as qa}from"util";import{resolve as Xa}from"path";var Xr={fs:{readFileSync:Ua,writeFile:Ka},format:qa,resolve:Xa,exists:(t)=>{try{return Va(t).isFile()}catch(e){return!1}}};var Xt;class Zr{constructor(t){t=t||{},this.directory=t.directory||"./locales",this.updateFiles=typeof t.updateFiles==="boolean"?t.updateFiles:!0,this.locale=t.locale||"en",this.fallbackToLanguage=typeof t.fallbackToLanguage==="boolean"?t.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...t){if(typeof arguments[0]!=="string")return this._taggedLiteral(arguments[0],...arguments);let e=t.shift(),o=function(){};if(typeof t[t.length-1]==="function")o=t.pop();if(o=o||function(){},!this.cache[this.locale])this._readLocaleFile();if(!this.cache[this.locale][e]&&this.updateFiles)this.cache[this.locale][e]=e,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:o});else o();return Xt.format.apply(Xt.format,[this.cache[this.locale][e]||e].concat(t))}__n(){let t=Array.prototype.slice.call(arguments),e=t.shift(),o=t.shift(),n=t.shift(),r=function(){};if(typeof t[t.length-1]==="function")r=t.pop();if(!this.cache[this.locale])this._readLocaleFile();let i=n===1?e:o;if(this.cache[this.locale][e])i=this.cache[this.locale][e][n===1?"one":"other"];if(!this.cache[this.locale][e]&&this.updateFiles)this.cache[this.locale][e]={one:e,other:o},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:r});else r();let s=[i];if(~i.indexOf("%d"))s.push(n);return Xt.format.apply(Xt.format,s.concat(t))}setLocale(t){this.locale=t}getLocale(){return this.locale}updateLocale(t){if(!this.cache[this.locale])this._readLocaleFile();for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e))this.cache[this.locale][e]=t[e]}_taggedLiteral(t,...e){let o="";return t.forEach(function(n,r){let i=e[r+1];if(o+=n,typeof i<"u")o+="%s"}),this.__.apply(this,[o].concat([].slice.call(e,1)))}_enqueueWrite(t){if(this.writeQueue.push(t),this.writeQueue.length===1)this._processWriteQueue()}_processWriteQueue(){let t=this,e=this.writeQueue[0],o=e.directory,n=e.locale,r=e.cb,i=this._resolveLocaleFile(o,n),s=JSON.stringify(this.cache[n],null,2);Xt.fs.writeFile(i,s,"utf-8",function(c){if(t.writeQueue.shift(),t.writeQueue.length>0)t._processWriteQueue();r(c)})}_readLocaleFile(){let t={},e=this._resolveLocaleFile(this.directory,this.locale);try{if(Xt.fs.readFileSync)t=JSON.parse(Xt.fs.readFileSync(e,"utf-8"))}catch(o){if(o instanceof SyntaxError)o.message="syntax error in "+e;if(o.code==="ENOENT")t={};else throw o}this.cache[this.locale]=t}_resolveLocaleFile(t,e){let o=Xt.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(o)&&~e.lastIndexOf("_")){let n=Xt.resolve(t,"./",e.split("_")[0]+".json");if(this._fileExistsSync(n))o=n}return o}_fileExistsSync(t){return Xt.exists(t)}}function Qr(t,e){Xt=e;let o=new Zr(t);return{__:o.__.bind(o),__n:o.__n.bind(o),setLocale:o.setLocale.bind(o),getLocale:o.getLocale.bind(o),updateLocale:o.updateLocale.bind(o),locale:o.locale}}var Za=(t)=>{return Qr(t,Xr)},Yr=Za;var af="require is not supported by ESM",ei="loading a directory of commands is not supported yet for ESM",Wo;try{Wo=of(import.meta.url)}catch(t){Wo=process.cwd()}var ff=Wo.substring(0,Wo.lastIndexOf("node_modules")),zn={assert:{notStrictEqual:Qa,strictEqual:Ya},cliui:In,findUp:jn,getEnv:(t)=>{return process.env[t]},inspect:tf,getCallerFile:()=>{throw new lt(ei)},getProcessArgvBin:qr,mainFilename:ff||process.cwd(),Parser:Jn,path:{basename:nf,dirname:rf,extname:sf,relative:cf,resolve:ti},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(t,e)=>process.emitWarning(t,e),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:ef,require:()=>{throw new lt(af)},requireDirectory:()=>{throw new lt(ei)},stringWidth:(t)=>{return[...t].length},y18n:Yr({directory:ti(Wo,"../../../locales"),updateFiles:!1})};function Bt(t,e,o,n){o.assert.notStrictEqual(t,e,n)}function vn(t,e){e.assert.strictEqual(typeof t,"string")}function so(t){return Object.keys(t)}function ht(t){return!!t&&!!t.then&&typeof t.then==="function"}function Pe(t){let o=t.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,r=o.shift();if(!r)throw Error(`No command found in: ${t}`);let i={cmd:r.replace(n,""),demanded:[],optional:[]};return o.forEach((s,c)=>{let f=!1;if(s=s.replace(/\s/g,""),/\.+[\]>]/.test(s)&&c===o.length-1)f=!0;if(/^\[/.test(s))i.optional.push({cmd:s.replace(n,"").split("|"),variadic:f});else i.demanded.push({cmd:s.replace(n,"").split("|"),variadic:f})}),i}var lf=["first","second","third","fourth","fifth","sixth"];function I(t,e,o){function n(){return typeof t==="object"?[{demanded:[],optional:[]},t,e]:[Pe(`cmd ${t}`),e,o]}try{let r=0,[i,s,c]=n(),f=[].slice.call(s);while(f.length&&f[f.length-1]===void 0)f.pop();let a=c||f.length;if(a<i.demanded.length)throw new lt(`Not enough arguments provided. Expected ${i.demanded.length} but received ${f.length}.`);let h=i.demanded.length+i.optional.length;if(a>h)throw new lt(`Too many arguments provided. Expected max ${h} but received ${a}.`);i.demanded.forEach((u)=>{let d=f.shift(),g=oi(d);if(u.cmd.filter((m)=>m===g||m==="*").length===0)ni(g,u.cmd,r);r+=1}),i.optional.forEach((u)=>{if(f.length===0)return;let d=f.shift(),g=oi(d);if(u.cmd.filter((m)=>m===g||m==="*").length===0)ni(g,u.cmd,r);r+=1})}catch(r){console.warn(r.stack)}}function oi(t){if(Array.isArray(t))return"array";else if(t===null)return"null";return typeof t}function ni(t,e,o){throw new lt(`Invalid ${lf[o]||"manyith"} argument. Expected ${e.join(" or ")} but received ${t}.`)}class Un{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,o=!0,n=!1){if(I("<array|function> [boolean] [boolean] [boolean]",[t,e,o],arguments.length),Array.isArray(t)){for(let r=0;r<t.length;r++){if(typeof t[r]!=="function")throw Error("middleware must be a function");let i=t[r];i.applyBeforeValidation=e,i.global=o}Array.prototype.push.apply(this.globalMiddleware,t)}else if(typeof t==="function"){let r=t;r.applyBeforeValidation=e,r.global=o,r.mutates=n,this.globalMiddleware.push(t)}return this.yargs}addCoerceMiddleware(t,e){let o=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((n)=>{let r=[...o[e]||[],e];if(!n.option)return!0;else return!r.includes(n.option)}),t.option=e,this.addMiddleware(t,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let t=this.frozens.pop();if(t!==void 0)this.globalMiddleware=t}reset(){this.globalMiddleware=this.globalMiddleware.filter((t)=>t.global)}}function ri(t){if(!t)return[];return t.map((e)=>{return e.applyBeforeValidation=!1,e})}function Ne(t,e,o,n){return o.reduce((r,i)=>{if(i.applyBeforeValidation!==n)return r;if(i.mutates){if(i.applied)return r;i.applied=!0}if(ht(r))return r.then((s)=>Promise.all([s,i(s,e)])).then(([s,c])=>Object.assign(s,c));else{let s=i(r,e);return ht(s)?s.then((c)=>Object.assign(r,c)):Object.assign(r,s)}},t)}function Je(t,e,o=(n)=>{throw n}){try{let n=hf(t)?t():t;return ht(n)?n.then((r)=>e(r)):e(n)}catch(n){return o(n)}}function hf(t){return typeof t==="function"}function Vn(t){for(let e=0,o=Object.keys(he.cache),n;e<o.length;e++)if(n=he.cache[o[e]],n.exports===t)return n;return null}var co=/(^\*)|(^\$0)/;class si{constructor(t,e,o,n){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=n,this.usage=t,this.globalMiddleware=o,this.validation=e}addDirectory(t,e,o,n){if(n=n||{},typeof n.recurse!=="boolean")n.recurse=!1;if(!Array.isArray(n.extensions))n.extensions=["js"];let r=typeof n.visit==="function"?n.visit:(i)=>i;n.visit=(i,s,c)=>{let f=r(i,s,c);if(f){if(this.requireCache.has(s))return f;else this.requireCache.add(s);this.addHandler(f)}return f},this.shim.requireDirectory({require:e,filename:o},t,n)}addHandler(t,e,o,n,r,i){let s=[],c=ri(r);if(n=n||(()=>{}),Array.isArray(t))if(uf(t))[t,...s]=t;else for(let f of t)this.addHandler(f);else if(df(t)){let f=Array.isArray(t.command)||typeof t.command==="string"?t.command:this.moduleName(t);if(t.aliases)f=[].concat(f).concat(t.aliases);this.addHandler(f,this.extractDesc(t),t.builder,t.handler,t.middlewares,t.deprecated);return}else if(ii(o)){this.addHandler([t].concat(s),e,o.builder,o.handler,o.middlewares,o.deprecated);return}if(typeof t==="string"){let f=Pe(t);s=s.map((u)=>Pe(u).cmd);let a=!1,h=[f.cmd].concat(s).filter((u)=>{if(co.test(u))return a=!0,!1;return!0});if(h.length===0&&a)h.push("$0");if(a)f.cmd=h[0],s=h.slice(1),t=t.replace(co,f.cmd);if(s.forEach((u)=>{this.aliasMap[u]=f.cmd}),e!==!1)this.usage.command(t,e,a,s,i);if(this.handlers[f.cmd]={original:t,description:e,handler:n,builder:o||{},middlewares:c,deprecated:i,demanded:f.demanded,optional:f.optional},a)this.defaultCommand=this.handlers[f.cmd]}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(t,e,o,n,r,i){let s=this.handlers[t]||this.handlers[this.aliasMap[t]]||this.defaultCommand,c=e.getInternalMethods().getContext(),f=c.commands.slice(),a=!t;if(t)c.commands.push(t),c.fullCommands.push(s.original);let h=this.applyBuilderUpdateUsageAndParse(a,s,e,o.aliases,f,n,r,i);return ht(h)?h.then((u)=>this.applyMiddlewareAndGetResult(a,s,u.innerArgv,c,r,u.aliases,e)):this.applyMiddlewareAndGetResult(a,s,h.innerArgv,c,r,h.aliases,e)}applyBuilderUpdateUsageAndParse(t,e,o,n,r,i,s,c){let f=e.builder,a=o;if(Xo(f)){o.getInternalMethods().getUsageInstance().freeze();let h=f(o.getInternalMethods().reset(n),c);if(ht(h))return h.then((u)=>{return a=ai(u)?u:o,this.parseAndUpdateUsage(t,e,a,r,i,s)})}else if(pf(f))o.getInternalMethods().getUsageInstance().freeze(),a=o.getInternalMethods().reset(n),Object.keys(e.builder).forEach((h)=>{a.option(h,f[h])});return this.parseAndUpdateUsage(t,e,a,r,i,s)}parseAndUpdateUsage(t,e,o,n,r,i){if(t)o.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(o))o.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(n,e),e.description);let s=o.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,r,i);return ht(s)?s.then((c)=>({aliases:o.parsed.aliases,innerArgv:c})):{aliases:o.parsed.aliases,innerArgv:s}}shouldUpdateUsage(t){return!t.getInternalMethods().getUsageInstance().getUsageDisabled()&&t.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(t,e){let o=co.test(e.original)?e.original.replace(co,"").trim():e.original,n=t.filter((r)=>{return!co.test(r)});return n.push(o),`$0 ${n.join(" ")}`}handleValidationAndGetResult(t,e,o,n,r,i,s,c){if(!i.getInternalMethods().getHasOutput()){let f=i.getInternalMethods().runValidation(r,c,i.parsed.error,t);o=Je(o,(a)=>{return f(a),a})}if(e.handler&&!i.getInternalMethods().getHasOutput()){i.getInternalMethods().setHasOutput();let f=!!i.getOptions().configuration["populate--"];if(i.getInternalMethods().postProcess(o,f,!1,!1),o=Ne(o,i,s,!1),o=Je(o,(a)=>{let h=e.handler(a);return ht(h)?h.then(()=>a):a}),!t)i.getInternalMethods().getUsageInstance().cacheHelpMessage();if(ht(o)&&!i.getInternalMethods().hasParseCallback())o.catch((a)=>{try{i.getInternalMethods().getUsageInstance().fail(null,a)}catch(h){}})}if(!t)n.commands.pop(),n.fullCommands.pop();return o}applyMiddlewareAndGetResult(t,e,o,n,r,i,s){let c={};if(r)return o;if(!s.getInternalMethods().getHasOutput())c=this.populatePositionals(e,o,n,s);let f=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),a=Ne(o,s,f,!0);return ht(a)?a.then((h)=>this.handleValidationAndGetResult(t,e,h,n,i,s,f,c)):this.handleValidationAndGetResult(t,e,a,n,i,s,f,c)}populatePositionals(t,e,o,n){e._=e._.slice(o.commands.length);let r=t.demanded.slice(0),i=t.optional.slice(0),s={};this.validation.positionalCount(r.length,e._.length);while(r.length){let c=r.shift();this.populatePositional(c,e,s)}while(i.length){let c=i.shift();this.populatePositional(c,e,s)}return e._=o.commands.concat(e._.map((c)=>""+c)),this.postProcessPositionals(e,s,this.cmdToParseOptions(t.original),n),s}populatePositional(t,e,o){let n=t.cmd[0];if(t.variadic)o[n]=e._.splice(0).map(String);else if(e._.length)o[n]=[String(e._.shift())]}cmdToParseOptions(t){let e={array:[],default:{},alias:{},demand:{}},o=Pe(t);return o.demanded.forEach((n)=>{let[r,...i]=n.cmd;if(n.variadic)e.array.push(r),e.default[r]=[];e.alias[r]=i,e.demand[r]=!0}),o.optional.forEach((n)=>{let[r,...i]=n.cmd;if(n.variadic)e.array.push(r),e.default[r]=[];e.alias[r]=i}),e}postProcessPositionals(t,e,o,n){let r=Object.assign({},n.getOptions());r.default=Object.assign(o.default,r.default);for(let f of Object.keys(o.alias))r.alias[f]=(r.alias[f]||[]).concat(o.alias[f]);r.array=r.array.concat(o.array),r.config={};let i=[];if(Object.keys(e).forEach((f)=>{e[f].map((a)=>{if(r.configuration["unknown-options-as-args"])r.key[f]=!0;i.push(`--${f}`),i.push(a)})}),!i.length)return;let s=Object.assign({},r.configuration,{"populate--":!1}),c=this.shim.Parser.detailed(i,Object.assign({},r,{configuration:s}));if(c.error)n.getInternalMethods().getUsageInstance().fail(c.error.message,c.error);else{let f=Object.keys(e);Object.keys(e).forEach((a)=>{f.push(...c.aliases[a])}),Object.keys(c.argv).forEach((a)=>{if(f.includes(a)){if(!e[a])e[a]=c.argv[a];if(!this.isInConfigs(n,a)&&!this.isDefaulted(n,a)&&Object.prototype.hasOwnProperty.call(t,a)&&Object.prototype.hasOwnProperty.call(c.argv,a)&&(Array.isArray(t[a])||Array.isArray(c.argv[a])))t[a]=[].concat(t[a],c.argv[a]);else t[a]=c.argv[a]}})}}isDefaulted(t,e){let{default:o}=t.getOptions();return Object.prototype.hasOwnProperty.call(o,e)||Object.prototype.hasOwnProperty.call(o,this.shim.Parser.camelCase(e))}isInConfigs(t,e){let{configObjects:o}=t.getOptions();return o.some((n)=>Object.prototype.hasOwnProperty.call(n,e))||o.some((n)=>Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(e)))}runDefaultBuilderOn(t){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(t)){let o=co.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");t.getInternalMethods().getUsageInstance().usage(o,this.defaultCommand.description)}let e=this.defaultCommand.builder;if(Xo(e))return e(t,!0);else if(!ii(e))Object.keys(e).forEach((o)=>{t.option(o,e[o])});return}moduleName(t){let e=Vn(t);if(!e)throw Error(`No command name given for module: ${this.shim.inspect(t)}`);return this.commandFromFilename(e.filename)}commandFromFilename(t){return this.shim.path.basename(t,this.shim.path.extname(t))}extractDesc({describe:t,description:e,desc:o}){for(let n of[t,e,o]){if(typeof n==="string"||n===!1)return n;Bt(n,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let t=this.frozens.pop();Bt(t,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=t}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function ci(t,e,o,n){return new si(t,e,o,n)}function ii(t){return typeof t==="object"&&!!t.builder&&typeof t.handler==="function"}function uf(t){return t.every((e)=>typeof e==="string")}function Xo(t){return typeof t==="function"}function pf(t){return typeof t==="object"}function df(t){return typeof t==="object"&&!Array.isArray(t)}function ye(t={},e=()=>!0){let o={};return so(t).forEach((n)=>{if(e(n,t[n]))o[n]=t[n]}),o}function Ee(t){if(typeof process>"u")return;[process.stdout,process.stderr].forEach((e)=>{let o=e;if(o._handle&&o.isTTY&&typeof o._handle.setBlocking==="function")o._handle.setBlocking(t)})}function mf(t){return typeof t==="boolean"}function li(t,e){let o=e.y18n.__,n={},r=[];n.failFn=function(D){r.push(D)};let i=null,s=null,c=!0;n.showHelpOnFail=function(D=!0,L){let[V,tt]=typeof D==="string"?[!0,D]:[D,L];if(t.getInternalMethods().isGlobalContext())s=tt;return i=tt,c=V,n};let f=!1;n.fail=function(D,L){let V=t.getInternalMethods().getLoggerInstance();if(r.length)for(let tt=r.length-1;tt>=0;--tt){let mt=r[tt];if(mf(mt)){if(L)throw L;else if(D)throw Error(D)}else mt(D,L,n)}else{if(t.getExitProcess())Ee(!0);if(!f){if(f=!0,c)t.showHelp("error"),V.error();if(D||L)V.error(D||L);let tt=i||s;if(tt){if(D||L)V.error("");V.error(tt)}}if(L=L||new lt(D),t.getExitProcess())return t.exit(1);else if(t.getInternalMethods().hasParseCallback())return t.exit(1,L);else throw L}};let a=[],h=!1;n.usage=(_,D)=>{if(_===null)return h=!0,a=[],n;return h=!1,a.push([_,D||""]),n},n.getUsage=()=>{return a},n.getUsageDisabled=()=>{return h},n.getPositionalGroupName=()=>{return o("Positionals:")};let u=[];n.example=(_,D)=>{u.push([_,D||""])};let d=[];n.command=function(D,L,V,tt,mt=!1){if(V)d=d.map((q)=>{return q[2]=!1,q});d.push([D,L||"",V,tt,mt])},n.getCommands=()=>d;let g={};n.describe=function(D,L){if(Array.isArray(D))D.forEach((V)=>{n.describe(V,L)});else if(typeof D==="object")Object.keys(D).forEach((V)=>{n.describe(V,D[V])});else g[D]=L},n.getDescriptions=()=>g;let x=[];n.epilog=(_)=>{x.push(_)};let m=!1,b;n.wrap=(_)=>{m=!0,b=_},n.getWrap=()=>{if(e.getEnv("YARGS_DISABLE_WRAP"))return null;if(!m)b=ot(),m=!0;return b};let S="__yargsString__:";n.deferY18nLookup=(_)=>S+_,n.help=function(){if(R)return R;y();let D=t.customScriptName?t.$0:e.path.basename(t.$0),L=t.getDemandedOptions(),V=t.getDemandedCommands(),tt=t.getDeprecatedOptions(),mt=t.getGroups(),q=t.getOptions(),ut=[];ut=ut.concat(Object.keys(g)),ut=ut.concat(Object.keys(L)),ut=ut.concat(Object.keys(V)),ut=ut.concat(Object.keys(q.default)),ut=ut.filter(st),ut=Object.keys(ut.reduce((F,nt)=>{if(nt!=="_")F[nt]=!0;return F},{}));let k=n.getWrap(),T=e.cliui({width:k,wrap:!!k});if(!h){if(a.length)a.forEach((F)=>{if(T.div({text:`${F[0].replace(/\$0/g,D)}`}),F[1])T.div({text:`${F[1]}`,padding:[1,0,0,0]})}),T.div();else if(d.length){let F=null;if(V._)F=`${D} <${o("command")}>
|
|
164
|
-
`;else
|
|
165
|
-
`;
|
|
166
|
-
`);
|
|
167
|
-
`)}return
|
|
144
|
+
complete -c omw -n '__fish_seen_subcommand_from add switch rename pin archive' -a '(git branch --format="%(refname:short)" 2>/dev/null)'`}function Rp(e){switch(e){case"bash":return Ep();case"zsh":return Mp();case"fish":return yp()}}var Op,Wp;var pf=$e(()=>{Op={command:"shell-init [shell]",describe:"Print shell integration code for omw switch",builder:(e)=>e.positional("shell",{type:"string",choices:["bash","zsh","fish"],describe:"Shell to generate integration for (auto-detected if omitted)"}).option("completions",{type:"string",describe:"Generate shell completions (bash, zsh, fish)",coerce:(t)=>t===!0?void 0:t}),handler:async(e)=>{let t="completions"in e,n=e.shell,o=e.completions,r=n??o??Sp(process.env.SHELL);if(t){let i=r==="fish"?hf():df(),s=Rp(r);console.log(i+`
|
|
145
|
+
`+s),process.exit(0)}if(r==="fish")console.log(hf()),process.exit(0);console.log(df()),process.exit(0)}},Wp=Op});var wf={};Ye(wf,{default:()=>Fp});import{resolve as Ei}from"path";function gf(e,t){if(e.length<=t)return e;return e.slice(0,t-3)+"..."}var Dp,Fp;var xf=$e(()=>{ke();fn();it();Rn();yt();Dp={command:"status",aliases:["st"],describe:"Show status overview of all worktrees",builder:(e)=>e.option("json",{type:"boolean",alias:"j",describe:"Output as JSON"}).option("all",{type:"boolean",alias:"a",describe:"Show worktrees from all configured repos"}),handler:async(e)=>{try{let t;if(e.all){let c=Fe(),u=await ze(),f=no(c),m=new Set([Ei(u)]),l=[u];for(let p of f){let R=Ei(p);if(!m.has(R))m.add(R),l.push(p)}t=await ee.listAll(l)}else t=await ee.list();if(t.length===0)console.log("No worktrees found."),process.exit(0);let n=await Promise.all(t.map(async(c)=>{let[u,f,m,l]=await Promise.all([c.branch?ee.getAheadBehind(c.branch,c.path):Promise.resolve({ahead:0,behind:0}),ee.getLastCommit(c.path),ee.getDirtyCount(c.path),Promise.resolve(dn(c.path))]);return{...c,aheadBehind:u,lastCommit:f,dirtyCount:m,focus:l}}));if(e.json)console.log(JSON.stringify(n,null,2)),process.exit(0);let o=Ei(process.cwd()),r=e.all&&new Set(n.map((c)=>c.repoName)).size>1,i=n.map((c)=>{let f=(Ei(c.path)===o?"* ":" ")+(c.branch??"(detached)"),m;if(c.isLocked)m="locked";else if(c.dirtyCount>0)m=`${c.dirtyCount} dirty`;else m="clean";let l=[];if(c.aheadBehind.ahead>0)l.push(`+${c.aheadBehind.ahead}`);if(c.aheadBehind.behind>0)l.push(`-${c.aheadBehind.behind}`);let p=l.length>0?l.join(" "):"=",R=c.lastCommit?`${c.lastCommit.relativeDate} ${gf(c.lastCommit.message,30)}`:"\u2014",M=c.focus&&c.focus.length>0?gf(c.focus.join(", "),30):"\u2014";return{repo:c.repoName,branch:f,dirty:m,sync:p,lastCommit:R,focus:M}}),s={branch:Math.max(6,...i.map((c)=>c.branch.length)),dirty:Math.max(6,...i.map((c)=>c.dirty.length)),sync:Math.max(4,...i.map((c)=>c.sync.length)),lastCommit:Math.max(11,...i.map((c)=>c.lastCommit.length)),focus:Math.max(5,...i.map((c)=>c.focus.length)),repo:Math.max(4,...i.map((c)=>c.repo.length))};if(r){let c=`${"Repo".padEnd(s.repo)} ${"Branch".padEnd(s.branch)} ${"Status".padEnd(s.dirty)} ${"Sync".padEnd(s.sync)} ${"Last Commit".padEnd(s.lastCommit)} ${"Focus".padEnd(s.focus)}`,u=`${"-".repeat(s.repo)} ${"-".repeat(s.branch)} ${"-".repeat(s.dirty)} ${"-".repeat(s.sync)} ${"-".repeat(s.lastCommit)} ${"-".repeat(s.focus)}`;console.log(c),console.log(u);for(let f of i)console.log(`${f.repo.padEnd(s.repo)} ${f.branch.padEnd(s.branch)} ${f.dirty.padEnd(s.dirty)} ${f.sync.padEnd(s.sync)} ${f.lastCommit.padEnd(s.lastCommit)} ${f.focus.padEnd(s.focus)}`)}else{let c=`${"Branch".padEnd(s.branch)} ${"Status".padEnd(s.dirty)} ${"Sync".padEnd(s.sync)} ${"Last Commit".padEnd(s.lastCommit)} ${"Focus".padEnd(s.focus)}`,u=`${"-".repeat(s.branch)} ${"-".repeat(s.dirty)} ${"-".repeat(s.sync)} ${"-".repeat(s.lastCommit)} ${"-".repeat(s.focus)}`;console.log(c),console.log(u);for(let f of i)console.log(`${f.branch.padEnd(s.branch)} ${f.dirty.padEnd(s.dirty)} ${f.sync.padEnd(s.sync)} ${f.lastCommit.padEnd(s.lastCommit)} ${f.focus.padEnd(s.focus)}`)}process.exit(0)}catch(t){if(t instanceof Ut)if(t.stderr.includes("not a git repository"))console.error("Error: not a git repository (or any of the parent directories): .git"),console.error("Run omw from within a git repository.");else console.error(`Git error: ${t.message}`);else console.error(`Error: ${t.message}`);process.exit(1)}}};Fp=Dp});var vf={};Ye(vf,{default:()=>Ap});import{existsSync as Ip}from"fs";function Bp(e){if(e)return e;let t=process.env.VISUAL||process.env.EDITOR;if(t)return t;for(let n of bf)try{if(Bun.spawnSync(["which",n],{stdout:"pipe",stderr:"pipe"}).exitCode===0)return n}catch{continue}return null}var bf,Lp,Ap;var Cf=$e(()=>{ke();yt();bf=["code","cursor","vim","nvim","emacs","nano","subl","zed","idea","webstorm"];Lp={command:"open [branch-or-path]",describe:"Open a worktree in your editor/IDE",builder:(e)=>e.positional("branch-or-path",{type:"string",describe:"Branch name or worktree path (defaults to current worktree)"}).option("editor",{type:"string",alias:"e",describe:"Editor command to use (overrides $VISUAL/$EDITOR)"}).option("list-editors",{type:"boolean",describe:"List detected editors"}),handler:async(e)=>{if(e["list-editors"]){let t=process.env.VISUAL||process.env.EDITOR;if(t)console.log(`$VISUAL/$EDITOR: ${t}`);for(let n of bf)try{let o=Bun.spawnSync(["which",n],{stdout:"pipe",stderr:"pipe"});if(o.exitCode===0){let r=new TextDecoder().decode(o.stdout).trim();console.log(` ${n}: ${r}`)}}catch{}process.exit(0)}try{let t=e["branch-or-path"],n;if(!t)n=process.cwd();else{let i=await ze(),s=await ee.list(i);n=on(s,t).path}if(!Ip(n))console.error(`Error: worktree path does not exist: ${n}`),process.exit(1);let o=Bp(e.editor);if(!o)console.error("Error: no editor detected."),console.error("Set $VISUAL or $EDITOR, or use --editor <command>."),console.error("Detected editors can be listed with: omw open --list-editors"),process.exit(1);console.log(`Opening ${n} with ${o}...`),await Bun.spawn([o,n],{stdout:"inherit",stderr:"inherit",stdin:"inherit"}).exited,process.exit(0)}catch(t){nt(t)}}},Ap=Lp});var Pf={};Ye(Pf,{default:()=>jp});import{resolve as $f}from"path";var Tp,jp;var Sf=$e(()=>{ke();it();yt();Tp={command:"exec <command>",describe:"Run a command in each worktree",builder:(e)=>e.positional("command",{type:"string",describe:"Shell command to execute",demandOption:!0}).option("all",{type:"boolean",alias:"a",describe:"Run across all configured repos"}).option("dirty",{type:"boolean",describe:"Only run in dirty worktrees"}).option("clean",{type:"boolean",describe:"Only run in clean worktrees"}).option("behind",{type:"boolean",describe:"Only run in worktrees behind upstream"}).option("parallel",{type:"boolean",alias:"p",describe:"Run commands in parallel (default: sequential)"}).option("json",{type:"boolean",alias:"j",describe:"Output results as JSON"}),handler:async(e)=>{let t=e.command,n=!!e.parallel,o=!!e.json;try{let r;if(e.all){let f=Fe(),m=await ze(),l=no(f),p=new Set([$f(m)]),R=[m];for(let M of l){let d=$f(M);if(!p.has(d))p.add(d),R.push(M)}r=await ee.listAll(R)}else r=await ee.list();let i=r.filter((f)=>!f.isMain);if(e.dirty)i=i.filter((f)=>f.isDirty);if(e.clean)i=i.filter((f)=>!f.isDirty);if(e.behind)i=(await un(i,10,async(m)=>{if(!m.branch)return{wt:m,behind:!1};let l=await ee.getAheadBehind(m.branch,m.path);return{wt:m,behind:l.behind>0}})).filter((m)=>m.behind).map((m)=>m.wt);if(i.length===0)console.log("No matching worktrees found."),process.exit(0);if(!o)console.log(`Running '${t}' in ${i.length} worktree(s)...
|
|
146
|
+
`);let s=async(f)=>{let m=Bun.spawn(["sh","-c",t],{cwd:f.path,stdout:"pipe",stderr:"pipe",env:{...Bun.env,OMW_BRANCH:f.branch??"",OMW_WORKTREE_PATH:f.path,OMW_REPO_PATH:f.repoPath}}),[l,p,R]=await Promise.all([new Response(m.stdout).text(),new Response(m.stderr).text(),m.exited]);return{branch:f.branch??"(detached)",path:f.path,exitCode:R,stdout:l.trim(),stderr:p.trim()}},c;if(n)c=await un(i,10,s);else{c=[];for(let f of i)c.push(await s(f))}if(o)console.log(JSON.stringify(c,null,2));else{for(let l of c){let p=l.exitCode===0?"\u2713":"\u2717";if(console.log(`${p} ${l.branch} (exit ${l.exitCode})`),l.stdout)for(let R of l.stdout.split(`
|
|
147
|
+
`))console.log(` ${R}`);if(l.stderr)for(let R of l.stderr.split(`
|
|
148
|
+
`))console.log(` ${R}`);console.log()}let f=c.filter((l)=>l.exitCode===0).length,m=c.length-f;console.log(`Done: ${f} passed, ${m} failed`)}let u=c.some((f)=>f.exitCode!==0);process.exit(u?1:0)}catch(r){nt(r)}}},jp=Tp});var Ef={};Ye(Ef,{default:()=>Gp});var Np,Gp;var Mf=$e(()=>{ke();yt();Np={command:"diff <ref1> [ref2]",describe:"Show diff between two worktrees or branches",builder:(e)=>e.positional("ref1",{type:"string",describe:"First worktree branch or ref",demandOption:!0}).positional("ref2",{type:"string",describe:"Second worktree branch or ref (default: current HEAD)"}).option("stat",{type:"boolean",alias:"s",describe:"Show diffstat summary only"}).option("name-only",{type:"boolean",alias:"n",describe:"Show only names of changed files"}),handler:async(e)=>{let t=e.ref1,n=e.ref2??"HEAD",o=!!e.stat,r=!!e["name-only"];try{let i=await ze(),s=await ee.list(i),c=(l)=>{return s.find((R)=>R.branch===l)?.branch??l},u=c(t),f=c(n),m=await ee.diffBetween(u,f,{stat:o,nameOnly:r},i);if(!m)console.log(`No differences between ${t} and ${n==="HEAD"?"current HEAD":n}`);else console.log(m);process.exit(0)}catch(i){nt(i)}}},Gp=Np});var yf={};Ye(yf,{default:()=>Hp});var kp,Hp;var Rf=$e(()=>{ke();ir();yt();kp={command:"pin [branch]",aliases:["unpin"],describe:"Pin or unpin a worktree",builder:(e)=>e.positional("branch",{type:"string",describe:"Branch name"}).option("reason",{type:"string",describe:"Reason for pinning"}).option("list",{type:"boolean",describe:"List pinned worktrees"}).option("json",{type:"boolean",alias:"j",describe:"Output as JSON"}).option("unpin",{type:"boolean",describe:"Unpin instead of pinning"}),handler:async(e)=>{try{let t=e,n=await ee.list();if(e.list){let c=Ws(n).map((p)=>({...p,pin:Ar(p.path)}));if(e.json)console.log(JSON.stringify(c,null,2)),process.exit(0);if(c.length===0)console.log("No pinned worktrees found."),process.exit(0);let u=Math.max(6,...c.map((p)=>(p.branch??"(detached)").length)),f=Math.max(4,...c.map((p)=>p.path.length)),m=Math.max(6,...c.map((p)=>(p.pin?.reason??"\u2014").length)),l=Math.max(9,...c.map((p)=>(p.pin?.pinnedAt??"\u2014").length));console.log(`${"Branch".padEnd(u)} ${"Path".padEnd(f)} ${"Reason".padEnd(m)} ${"Pinned At".padEnd(l)}`),console.log(`${"-".repeat(u)} ${"-".repeat(f)} ${"-".repeat(m)} ${"-".repeat(l)}`);for(let p of c)console.log(`${(p.branch??"(detached)").padEnd(u)} ${p.path.padEnd(f)} ${(p.pin?.reason??"\u2014").padEnd(m)} ${(p.pin?.pinnedAt??"\u2014").padEnd(l)}`);process.exit(0)}let o=e._[0]==="unpin"||!!e.unpin,r=typeof t.branch==="string"?t.branch:typeof e._[1]==="string"?e._[1]:void 0;if(!r)console.error("Error: branch is required"),process.exit(1);let i=n.find((c)=>c.branch===r);if(!i)console.error(`Error: no worktree found for '${r}'`),process.exit(1);if(o){if(!Ar(i.path))console.warn(`Warning: worktree is not pinned: ${i.path}`),process.exit(0);Os(i.path),console.log(`Unpinned worktree: ${i.path}`),process.exit(0)}if(Ar(i.path))console.warn(`Warning: worktree is already pinned: ${i.path}`),process.exit(0);let s=typeof t.reason==="string"?t.reason:void 0;Rs(i.path,s),console.log(`Pinned worktree: ${i.path}`),process.exit(0)}catch(t){nt(t)}}},Hp=kp});var Of={};Ye(Of,{default:()=>Jp});function zp(e){let t={create:"\x1B[32m",delete:"\x1B[31m",switch:"\x1B[34m",rename:"\x1B[33m",archive:"\x1B[35m",import:"\x1B[36m",reset:"\x1B[0m"};return`${t[e]??t.reset}${e}${t.reset}`}var Up,Jp;var Wf=$e(()=>{lo();yt();Up={command:"log",aliases:["logs"],describe:"Show worktree activity log",builder:(e)=>e.option("limit",{type:"number",default:20,describe:"Show the last N entries"}).option("json",{type:"boolean",alias:"j",describe:"Output as JSON"}).option("clear",{type:"boolean",describe:"Clear the activity log"}),handler:async(e)=>{try{let t=await ze();if(e.clear){if(!await ao("Clear activity log? [y/N] "))console.log("Cancelled."),process.exit(0);Gl(t),console.log("Activity log cleared."),process.exit(0)}let n=typeof e.limit==="number"?e.limit:20,o=Nl(t,{limit:n});if(e.json)console.log(JSON.stringify(o,null,2)),process.exit(0);for(let r of o){let i=zp(r.event),s=r.branch??"(unknown)",c=r.details?Object.entries(r.details).map(([u,f])=>`${u}=${f}`).join(" "):"";console.log(`[${r.timestamp}] ${i} ${s}${c?` (${c})`:""}`)}process.exit(0)}catch(t){nt(t)}}},Jp=Up});import{existsSync as If,mkdirSync as Vp,readFileSync as Bf,writeFileSync as Df}from"fs";import{homedir as Kp}from"os";import{basename as qp,join as Mi}from"path";function Xp(e){let t=Er(e),n=Mi(t,"HEAD");if(!If(n))return null;let r=Bf(n,"utf-8").trim().match(/^ref:\s+(.+)$/);if(!r)return null;return r[1]?.replace(/^refs\/heads\//,"")??null}async function Ff(e,t){return ee.exec(e,t)}function Lf(){let e=Bun.env.HOME??Kp();return Mi(e,".omw","archives")}async function Af(e,t){let n=qp(t),o=await ee.getBranchForWorktree(e)??Xp(e)??"detached-head",r=o.replaceAll("/","-"),i=new Date().toISOString(),s=i.replaceAll(":","-"),c=Mi(Lf(),n);Vp(c,{recursive:!0});let u=Mi(c,`${r}-${s}`),f=`${u}.patch`,m=`${u}.json`;try{let[l,p,R]=await Promise.all([Ff(["diff"],e),Ff(["format-patch","-5","HEAD","--stdout"],e),ee.getLastCommit(e)]),M=["# OMW archive",`# repo: ${n}`,`# branch: ${o}`,`# archivedAt: ${i}`,"","# Uncommitted diff",l||"# (no uncommitted changes)","","# Recent commits (git format-patch -5 HEAD --stdout)",p||"# (no recent commits)"].join(`
|
|
149
|
+
`);Df(f,M,"utf-8");let d={branch:o,repo:n,archivedAt:i,patchPath:f,commitHash:R?.hash??"",message:R?.message??""};return Df(m,JSON.stringify(d,null,2),"utf-8"),d}catch(l){let p=l instanceof Error?l.message:"Unknown archive error";throw new fs(`Failed to archive worktree: ${p}`,o,"archive_failed")}}async function Tf(e){let t=Lf();if(!If(t))return[];let n=e?`${e}/*.json`:"**/*.json",o=new Bun.Glob(n),r=[];for await(let i of o.scan({cwd:t,absolute:!0}))try{let s=Bf(i,"utf-8");r.push(JSON.parse(s))}catch{}return r.sort((i,s)=>{let c=Date.parse(i.archivedAt);return Date.parse(s.archivedAt)-c})}var jf=$e(()=>{ke();fn();Yn()});var Nf={};Ye(Nf,{default:()=>Yp});import{basename as Zp}from"path";var Qp,Yp;var Gf=$e(()=>{ke();lo();jf();it();In();yt();Qp={command:"archive [branch]",describe:"Archive worktree changes and optionally remove",builder:(e)=>e.positional("branch",{type:"string",describe:"Branch name or worktree path"}).option("yes",{type:"boolean",alias:"y",describe:"Skip confirmation prompt"}).option("keep",{type:"boolean",describe:"Archive without removing the worktree"}).option("list",{type:"boolean",describe:"List all archives"}).option("json",{type:"boolean",alias:"j",describe:"Output as JSON (with --list)"}),handler:async(e)=>{let t=e.branch,n=!!e.yes,o=!!e.keep,r=!!e.list,i=!!e.json;try{if(r){let l=await Tf();if(i)console.log(JSON.stringify(l,null,2));else if(l.length===0)console.log("No archives found.");else{console.log(`Archives:
|
|
150
|
+
`);for(let p of l){let R=new Date(p.archivedAt).toLocaleString();console.log(` ${p.repo}/${p.branch}`),console.log(` Date: ${R}`),console.log(` Commit: ${p.commitHash.slice(0,8)} ${p.message}`),console.log(` Patch: ${p.patchPath}`),console.log()}}process.exit(0)}if(!t)console.error("Error: branch name is required (or use --list to view archives)"),process.exit(1);let s=await ze(),c=await ee.list(s),u=on(c,t);if(u.isMain)console.error("Error: cannot archive the main worktree"),process.exit(1);let f=o?"Archive":"Archive and remove";if(!n){if(!await ao(`${f} worktree '${u.branch??Zp(u.path)}'? [y/N] `))console.log("Cancelled."),process.exit(0)}let m=await Af(u.path,s);console.log(`Archived: ${m.patchPath}`);try{rn(s,{timestamp:new Date().toISOString(),event:"archive",branch:m.branch,path:m.patchPath})}catch{}if(!o){let l=Fe(),p=Wt(l,s);if(p.postRemove.length>0)console.log("Running postRemove hooks..."),await Et(p.postRemove,{cwd:u.path,env:{OMW_BRANCH:u.branch??"",OMW_WORKTREE_PATH:u.path,OMW_REPO_PATH:s},onOutput:(R)=>console.log(` ${R}`)}).catch((R)=>console.warn(`Warning: postRemove hook failed: ${R.message}`));await ee.remove(u.path,{force:!1},s),$t(),console.log(`Removed worktree: ${u.path}`)}process.exit(0)}catch(s){nt(s)}}},Yp=Qp});var kf={};Ye(kf,{default:()=>og});import{dirname as _p,basename as eg,join as tg}from"path";var ng,og;var Hf=$e(()=>{ke();lo();yt();ng={command:"rename <old> <new>",describe:"Rename worktree branch",builder:(e)=>e.positional("old",{type:"string",demandOption:!0,describe:"Current branch name"}).positional("new",{type:"string",demandOption:!0,describe:"New branch name"}).option("move-path",{type:"boolean",describe:"Also rename the worktree directory path"}),handler:async(e)=>{let{old:t,new:n}=e,o=!!e["move-path"];try{let r=await ze(),i=await ee.list(r),s=on(i,t);if(s.isMain)console.error("Error: cannot rename the main worktree branch"),process.exit(1);if(i.find((u)=>u.branch===n))console.error(`Error: branch '${n}' already exists`),process.exit(1);if(await ee.exec(["branch","-m",t,n],r),$t(),o){let u=n.replace(/\//g,"-"),f=_p(s.path),m=eg(s.path),l=t.replace(/\//g,"-"),p=m.replace(l,u),R=tg(f,p);if(R!==s.path)await ee.move(s.path,R,r),$t(),console.log(`Moved worktree: ${s.path} \u2192 ${R}`)}console.log(`Renamed branch: ${t} \u2192 ${n}`);try{rn(r,{timestamp:new Date().toISOString(),event:"rename",branch:n,details:{oldBranch:t}})}catch{}process.exit(0)}catch(r){nt(r)}}},og=ng});var zf={};Ye(zf,{default:()=>cg});import{basename as rg,resolve as ig}from"path";var sg,cg;var Uf=$e(()=>{ke();fn();it();In();sg={command:"clone <url> [path]",describe:"Clone a repository and initialize omw config",builder:(e)=>e.positional("url",{type:"string",describe:"Repository URL to clone",demandOption:!0}).positional("path",{type:"string",describe:"Target directory path"}).option("template",{type:"string",alias:"t",describe:"Apply a named template after cloning"}).option("init-config",{type:"boolean",describe:"Initialize omw config after cloning",default:!0}),handler:async(e)=>{let{url:t,template:n}=e,o=e["init-config"],r=e.path;if(!r)try{let i=new URL(t);r=rg(i.pathname).replace(/\.git$/,"")}catch{r=(t.split("/").pop()??t.split(":").pop()??t).replace(/\.git$/,"")}if(!r)console.error("Error: could not determine target directory from URL"),process.exit(1);console.log(`Cloning ${t}...`);try{await ee.exec(["clone",t,r])}catch(i){if(i instanceof Ut)console.error(`Error: ${i.stderr||i.message}`);else console.error(`Error: ${i.message}`);process.exit(1)}if(o)try{let i=Pn();console.log(` \u2713 Config initialized: ${i}`)}catch(i){console.warn(` \u26A0 Could not initialize config: ${i.message}`)}if(n)try{let i=Fe(),s=xi(i,n);if(!s){let m=Object.keys(i.templates??{});if(console.error(`Error: template '${n}' not found.`),m.length>0)console.error(`Available templates: ${m.join(", ")}`);else console.error("No templates configured. Add templates to your config file.");process.exit(1)}console.log(` Using template '${n}'`);let c=ig(r),u=Wt(i,c),f=bi(u,s);if(f.postCreate.length>0)console.log(" Running postCreate hooks..."),await Et(f.postCreate,{cwd:c,env:{OMW_REPO_PATH:c},onOutput:(m)=>console.log(` ${m}`)}),console.log(" \u2713 Hooks completed");console.log(` \u2713 Template '${n}' applied`)}catch(i){if(i instanceof Qo)console.error(`Error: hook timed out: ${i.command}`);else if(i instanceof Zo){if(console.error(`Error: hook failed (exit ${i.exitCode}): ${i.command}`),i.stderr)console.error(i.stderr)}else console.error(`Error applying template: ${i.message}`);process.exit(1)}console.log(`
|
|
151
|
+
Cloned: ${t} \u2192 ${r}`),process.exit(0)}},cg=sg});import{existsSync as Jf,readFileSync as Vf,statSync as yi}from"fs";import{basename as ag,join as Ri,resolve as cr}from"path";async function js(e,t){return ee.exec(e,t)}function lg(e){let t=Ri(e,"HEAD");if(!Jf(t))return null;let o=Vf(t,"utf-8").trim().match(/^ref:\s+refs\/heads\/(.+)$/);return o?o[1]:null}function Kf(e){let t=cr(e),n=Ri(t,".git");if(!yi(n,{throwIfNoEntry:!1}))throw Error(`Missing .git at ${n}`);return Er(t)}function Ns(e){let t=cr(e),n=yi(t,{throwIfNoEntry:!1});if(!n)return{valid:!1,reason:`Path does not exist: ${t}`};if(!n.isDirectory())return{valid:!1,reason:`Path is not a directory: ${t}`};let o=Ri(t,".git"),r=yi(o,{throwIfNoEntry:!1});if(!r)return{valid:!1,reason:`Target is missing .git: ${t}`};if(r.isDirectory())return{valid:!1,reason:`Target is not a linked git worktree (.git is a directory): ${t}`};if(!r.isFile())return{valid:!1,reason:`Target has invalid .git entry: ${t}`};let i="";try{i=Kf(t)}catch{return{valid:!1,reason:`Cannot resolve gitdir from .git file: ${t}`}}if(!yi(i,{throwIfNoEntry:!1})?.isDirectory())return{valid:!1,reason:`Resolved gitdir does not exist: ${i}`};let c=lg(i);if(!c)return{valid:!1,reason:`Cannot resolve branch name from HEAD: ${t}`};return{valid:!0,branch:c}}async function qf(e,t){let n=cr(e),o=Ns(n);if(!o.valid)throw new Pr(`Cannot import worktree: ${o.reason??"invalid target"}`,n,o.reason??"invalid target");let[r,i,s]=await Promise.all([js(["rev-parse","HEAD"],n),js(["status","--porcelain"],n),js(["rev-parse","--git-common-dir"],n)]),c=cr(n,s),u=c.endsWith("/.git")||c.endsWith("\\.git")?c.slice(0,-5):c,f=ag(u),m=cr(n)===cr(u),l=Kf(n),p=Ri(l,"locked"),R=Jf(p),M=R?Vf(p,"utf-8").trim()||void 0:void 0;if(t?.focus&&t.focus.length>0)ko(n,t.focus);if(t?.pin)try{(await Promise.resolve().then(() => (ir(),Cl))).writePin(n)}catch(d){console.warn(`Warning: failed to pin worktree: ${d.message}`)}return{path:n,branch:o.branch??null,head:r,isMain:m,isDirty:i.length>0,isLocked:R,lockReason:M,repoName:f,repoPath:u}}var Xf=$e(()=>{ke();Rn();fn();Yn()});var Zf={};Ye(Zf,{default:()=>dg});import{resolve as fg}from"path";var ug,dg;var Qf=$e(()=>{Xf();ke();lo();fn();yt();ug={command:"import <path>",describe:"Adopt a worktree with omw metadata",builder:(e)=>e.positional("path",{type:"string",describe:"Existing worktree directory path",demandOption:!0}).option("focus",{type:"array",alias:"f",describe:"Focus packages for monorepo (comma or space separated paths)",string:!0}).option("pin",{type:"boolean",describe:"Pin the worktree"}),handler:async(e)=>{let t=fg(e.path),n=Ns(t);if(!n.valid)console.error(`Error: ${n.reason??"invalid import target"}`),process.exit(1);let r=e.focus?.flatMap((s)=>s.split(/[,\s]+/)).map((s)=>s.trim()).filter(Boolean)??[],i=!!e.pin;try{let s=await qf(t,{focus:r,pin:i});$t();let c=s.branch??n.branch??"unknown",u=s.repoPath??await ze();console.log(`Imported worktree: ${c} at ${s.path}`);try{rn(u,{timestamp:new Date().toISOString(),event:"import",branch:s.branch??n.branch??"unknown",path:s.path})}catch{}if(r.length>0)console.log(` Focus: ${r.join(", ")}`);if(i)console.log(" Pinned");process.exit(0)}catch(s){if(s instanceof Pr)console.error(`Error: ${s.reason}`);else console.error(`Error: ${s.message}`);process.exit(1)}}},dg=ug});var Yf={};Ye(Yf,{default:()=>gg});import{basename as Oi}from"path";async function mg(e,t,n){let[o,r]=await Promise.all([ws(t),ee.list(e)]);if(n){let i=o.map((s)=>{let c=r.find((f)=>{let m=f.branch??Oi(f.path);return _n(m,t)===s.name}),u=c?tn(c.path):null;return{...s,branch:c?.branch??null,worktreePath:c?.path??null,layout:u?.layout??null}});console.log(JSON.stringify(i,null,2));return}if(o.length===0){console.log("No active omw sessions.");return}console.log(`Active sessions (${o.length}):
|
|
152
|
+
`);for(let i of o){let s=r.find((l)=>{let p=l.branch??Oi(l.path);return _n(p,t)===i.name}),c=s?tn(s.path):null,u=i.attached?" (attached)":"",f=c?.layout?` [${c.layout}]`:"",m=s?.branch?` ${s.branch}`:"";console.log(` ${i.name}${m} ${i.windows} windows${f}${u}`)}}async function pg(e,t){let[n,o]=await Promise.all([ws(t),ee.list(e)]);if(n.length===0){console.log("No active omw sessions.");return}let r=0;for(let i of n){let s=o.find((c)=>{let u=tn(c.path),f=c.branch??Oi(c.path);return u?.name===i.name||_n(f,t)===i.name});if(await gs(i.name),s)ms(s.path);r++,console.log(` \u2713 Killed ${i.name}`)}console.log(`
|
|
153
|
+
Killed ${r} session${r!==1?"s":""}.`)}var hg,gg;var _f=$e(()=>{ke();it();eo();yt();hg={command:"session [branch-or-path]",aliases:["ss"],describe:"Manage tmux sessions for worktrees",builder:(e)=>e.positional("branch-or-path",{type:"string",describe:"Branch name or worktree path to open session for"}).option("list",{type:"boolean",alias:"l",describe:"List active omw tmux sessions"}).option("kill",{type:"boolean",alias:"k",describe:"Kill the session for the specified worktree"}).option("kill-all",{type:"boolean",describe:"Kill all omw tmux sessions"}).option("layout",{type:"string",describe:"Use a named layout from config"}).option("json",{type:"boolean",alias:"j",describe:"Output in JSON format"}),handler:async(e)=>{let t=e["branch-or-path"],n=!!e.list,o=!!e.kill,r=!!e["kill-all"],i=e.layout,s=!!e.json;if(!await zo())console.error("Error: tmux is not installed or not in PATH."),console.error("Install tmux to use session management."),process.exit(1);try{let c=await ze(),u=Fe(),f=oo(u);if(n)await mg(c,f.prefix,s),process.exit(0);if(r)await pg(c,f.prefix),process.exit(0);if(!t)console.error("Error: specify a branch or worktree path, or use --list."),process.exit(1);let m=await ee.list(c),l=on(m,t),p=l.branch??Oi(l.path);if(o){if(await di(p,l.path,f.prefix))console.log(`Killed session for '${p}'`);else console.log(`No active session for '${p}'`);process.exit(0)}let R=vi(u,i),M=await ui(p,l.path,{layout:R,prefix:f.prefix,attach:!0,layoutName:i??f.defaultLayout});console.log(`Session: ${M}`),process.exit(0)}catch(c){nt(c)}}};gg=hg});import{existsSync as Gs,mkdirSync as eu,writeFileSync as tu}from"fs";import{dirname as nu,join as ar}from"path";function wg(e){let t=process.env.HOME||process.env.USERPROFILE||"~";switch(e){case"claude-code":return ar(t,".claude","skills","omw");case"codex":return ar(t,".agents","skills","omw");case"opencode":return ar(t,".config","opencode","skill","omw")}}function xg(e){return ar(wg(e),"SKILL.md")}function Cg(e){return["| Flag | Type | Alias | Description |","|------|------|-------|-------------|",...e.length>0?e.map((n)=>`| ${n.flag} | ${n.type} | ${n.alias} | ${n.description} |`):["| - | - | - | No options |"]].join(`
|
|
154
|
+
`)}function $g(){let e=vg.map((n)=>`| \`${n.command}\` | ${n.aliases} | ${n.description} |`),t=ou.map((n)=>`- [\`omw ${n.command}\`](references/${n.command}.md)`);return["---","name: omw",`description: ${bg}`,"metadata:"," author: getsolaris",' version: "1.0.0"',"---","","# oh-my-worktree (omw)","","## Quick Start","","### Create a feature worktree","","```bash","omw add feature/my-feature --base main","```","","### List and check status","","```bash","omw list","omw status","```","","### Clean up merged worktrees","","```bash","omw clean --dry-run","omw clean --yes","```","","### Run commands across worktrees","","```bash",'omw exec "bun test" --parallel',"```","","### Review a GitHub PR","","```bash","omw add pr-review --pr 42","omw open pr-review","```","","### Use templates","","```bash","# Create worktree with predefined template (hooks, base branch, settings)","omw add feature/new --template frontend","```","","### Tmux session management","","```bash","# Create worktree with tmux session","omw add feature/api --session --layout dev","","# List active sessions","omw session --list","","# Attach to existing session","omw session feature/api","```","","### Shell integration setup","","```bash","# Add to ~/.zshrc or ~/.bashrc",'eval "$(omw shell-init)"',"","# Then switch worktrees with cd","omw switch feature/auth","```","","## Command Overview","","| Command | Aliases | Description |","|---------|---------|-------------|",...e,"","## Monorepo Workflows","","Use focus paths to target packages and trigger matching monorepo hooks.","","```bash","omw add feature/web-auth --focus apps/web,apps/api","omw import /path/to/worktree --focus packages/core --pin","omw list --json","```","","Focus accepts comma-separated values, space-separated values, or repeated --focus flags.","","## Configuration","","- Config path: `~/.config/oh-my-worktree/config.json`","- Use `--json` output flags for scripting and automation","- Environment variables in `omw exec`: `OMW_BRANCH`, `OMW_WORKTREE_PATH`, `OMW_REPO_PATH`","","## Command Reference","","For detailed options and examples for each command:","",...t,"- [`Configuration Schema`](references/config-schema.md)",""].join(`
|
|
155
|
+
`)}function Pg(){let e=new Map;for(let n of ou){let o=[`# omw ${n.command}`,"",n.summary,"","## Synopsis","","```",n.synopsis,"```","","## Options","",Cg(n.options),"","## Examples","","```bash",`# ${n.examples[0][0]}`,n.examples[0][1],"",`# ${n.examples[1][0]}`,n.examples[1][1],"```","","## Notes","",...n.notes.map((r)=>`- ${r}`),"",...n.configKeys.length>0?["## Configuration","","Related config keys in `~/.config/oh-my-worktree/config.json`:","",...n.configKeys.map((r)=>`- ${r}`),""]:[]];e.set(`${n.command}.md`,o.join(`
|
|
156
|
+
`))}let t=Sg();return e.set("config-schema.md",t),e}function Sg(){return["# Configuration Schema","","Config file path: `~/.config/oh-my-worktree/config.json`","","## Minimal Example","","```json","{",' "version": 1,',' "defaults": {',' "worktreeDir": "~/.omw/worktrees/{repo}-{branch}",',' "copyFiles": [".env", ".env.local"],',' "linkFiles": ["node_modules"],',' "postCreate": ["bun install"],',' "postRemove": [],',' "autoUpstream": true'," }","}","```","","## Full Example","","```json","{",' "version": 1,',' "defaults": {',' "worktreeDir": "~/.omw/worktrees/{repo}-{branch}",',' "copyFiles": [".env"],',' "linkFiles": [],',' "postCreate": ["bun install"],',' "postRemove": [],',' "autoUpstream": true,',' "sharedDeps": {',' "strategy": "symlink",',' "paths": ["node_modules"]'," }"," },",' "repos": ['," {",' "path": "/path/to/repo",',' "copyFiles": [".env", ".env.local"],',' "monorepo": {',' "autoDetect": true,',' "hooks": ['," {",' "glob": "apps/*",',' "postCreate": ["bun install"]'," }"," ]"," }"," }"," ],",' "templates": {',' "frontend": {',' "base": "main",',' "copyFiles": [".env"],',' "postCreate": ["bun install", "bun run build"]'," },",' "review": {',' "base": "main",',' "postCreate": ["bun install"]'," }"," },",' "sessions": {',' "enabled": true,',' "autoCreate": false,',' "autoKill": true,',' "prefix": "omw",',' "defaultLayout": "dev",',' "layouts": {',' "dev": {',' "windows": [',' { "name": "editor", "command": "nvim ." },',' { "name": "server", "command": "bun run dev" },',' { "name": "shell" }'," ]"," }"," }"," },",' "lifecycle": {',' "autoCleanMerged": false,',' "staleAfterDays": 30,',' "maxWorktrees": 10'," },",' "theme": "default"',"}","```","","## Key Reference","","### defaults","","| Key | Type | Default | Description |","|-----|------|---------|-------------|","| `worktreeDir` | string | `~/.omw/worktrees/{repo}-{branch}` | Directory pattern. Supports `{repo}` and `{branch}` variables |","| `copyFiles` | string[] | `[]` | Files to copy from main worktree on creation |","| `linkFiles` | string[] | `[]` | Files to symlink from main worktree on creation |","| `postCreate` | string[] | `[]` | Shell commands to run after worktree creation |","| `postRemove` | string[] | `[]` | Shell commands to run before worktree removal |","| `autoUpstream` | boolean | `false` | Automatically set upstream tracking branch |","| `sharedDeps.strategy` | string | `symlink` | Strategy for sharing deps: `symlink`, `hardlink`, or `copy` |","| `sharedDeps.paths` | string[] | `[]` | Paths to share between worktrees |","","### repos[]","","Per-repository overrides. Same keys as `defaults` plus:","","| Key | Type | Description |","|-----|------|-------------|","| `path` | string | **Required.** Absolute path to the repository |","| `monorepo.autoDetect` | boolean | Auto-detect monorepo tools (pnpm, turbo, nx, lerna) |","| `monorepo.extraPatterns` | string[] | Additional glob patterns for package discovery |","| `monorepo.hooks[]` | object[] | Per-package hooks matched by glob pattern |","| `monorepo.hooks[].glob` | string | Glob to match against focus paths |","| `monorepo.hooks[].copyFiles` | string[] | Package-level files to copy |","| `monorepo.hooks[].linkFiles` | string[] | Package-level files to symlink |","| `monorepo.hooks[].postCreate` | string[] | Package-level post-create hooks |","| `monorepo.hooks[].postRemove` | string[] | Package-level post-remove hooks |","","### templates","","Named presets applied via `omw add --template <name>` or `omw clone --template <name>`.","","| Key | Type | Description |","|-----|------|-------------|","| `base` | string | Default base branch for new worktrees |","| `worktreeDir` | string | Override directory pattern |","| `copyFiles` | string[] | Override files to copy |","| `linkFiles` | string[] | Override files to symlink |","| `postCreate` | string[] | Override post-create hooks |","| `postRemove` | string[] | Override post-remove hooks |","| `autoUpstream` | boolean | Override upstream tracking |","","### sessions","","| Key | Type | Default | Description |","|-----|------|---------|-------------|","| `enabled` | boolean | `false` | Enable tmux session integration |","| `autoCreate` | boolean | `false` | Auto-create session on `omw add` |","| `autoKill` | boolean | `false` | Auto-kill session on `omw remove` |","| `prefix` | string | `omw` | Prefix for tmux session names |","| `defaultLayout` | string | - | Default layout name |","| `layouts.<name>.windows[]` | object[] | - | Window definitions |","| `layouts.<name>.windows[].name` | string | **Required.** | Window name |","| `layouts.<name>.windows[].command` | string | - | Command to run in window |","","### lifecycle","","| Key | Type | Default | Description |","|-----|------|---------|-------------|","| `autoCleanMerged` | boolean | `false` | Auto-clean merged worktrees |","| `staleAfterDays` | number | `30` | Days until a worktree is considered stale |","| `maxWorktrees` | number | `10` | Maximum number of worktrees |",""].join(`
|
|
157
|
+
`)}function ru(e){let t=xg(e),n=ar(nu(t),"references"),o=$g(),r=Pg(),i=nu(t);if(!Gs(i))eu(i,{recursive:!0});if(!Gs(n))eu(n,{recursive:!0});let s=Gs(t);tu(t,o,"utf-8");for(let[c,u]of r.entries())tu(ar(n,c),u,"utf-8");return{filePath:t,referenceDir:n,referenceCount:r.size,platform:e,action:s?"updated":"created"}}var ks,bg="Git worktree manager. Use when working with git worktrees \u2014 creating, switching, removing, listing, or managing worktrees across repositories. Also use for monorepo focus, tmux sessions, and worktree health checks.",vg,ou;var iu=$e(()=>{ks=["claude-code","codex","opencode"];vg=[{command:"add",aliases:"-",description:"Create a new worktree from a branch, template, or PR."},{command:"remove",aliases:"rm",description:"Remove a worktree by branch or path."},{command:"list",aliases:"ls",description:"List worktrees with branch, path, status, and focus."},{command:"switch",aliases:"sw",description:"Print shell cd command for a target worktree."},{command:"status",aliases:"st",description:"Show status summary for worktrees."},{command:"clean",aliases:"-",description:"Clean merged worktrees and optionally report stale ones."},{command:"doctor",aliases:"-",description:"Run worktree health checks and optional auto-fixes."},{command:"exec",aliases:"-",description:"Run commands across non-main worktrees."},{command:"diff",aliases:"-",description:"Compare two refs or worktree branches."},{command:"pin",aliases:"unpin",description:"Pin or unpin worktrees and inspect pin metadata."},{command:"log",aliases:"logs",description:"Read or clear the activity log."},{command:"archive",aliases:"-",description:"Archive worktree changes as patch files."},{command:"rename",aliases:"-",description:"Rename a worktree branch and optionally move its path."},{command:"clone",aliases:"-",description:"Clone a repository and initialize omw setup."},{command:"import",aliases:"-",description:"Import an existing worktree into omw metadata."},{command:"session",aliases:"ss",description:"Manage tmux sessions for worktrees."},{command:"config",aliases:"-",description:"Initialize, inspect, validate, and manage config profiles."},{command:"open",aliases:"-",description:"Open a worktree path in your preferred editor."},{command:"shell-init",aliases:"-",description:"Generate shell integration and completions."},{command:"init",aliases:"-",description:"Initialize config or install/update omw AI agent skill files."}],ou=[{command:"add",summary:"Create a new worktree from a branch, template, or GitHub PR.",synopsis:"omw add [branch] [path]",options:[{flag:"--create",type:"boolean",alias:"-c",description:"Optional compatibility flag; missing branches are created automatically"},{flag:"--base",type:"string",alias:"-b",description:"Base branch/commit for new branch"},{flag:"--focus",type:"array",alias:"-f",description:"Focus packages for monorepo"},{flag:"--template",type:"string",alias:"-t",description:"Use a named template from config"},{flag:"--pr",type:"number",alias:"-",description:"Create worktree from a GitHub PR number"},{flag:"--session",type:"boolean",alias:"-s",description:"Create a tmux session for this worktree"},{flag:"--layout",type:"string",alias:"-",description:"Session layout name from config"}],examples:[["Create a feature branch worktree","omw add feature/auth --base main"],["Create from PR with session layout","omw add feature/review --pr 123 --session --layout dev"]],notes:["Creates the branch automatically when it does not already exist.","Existing branches are reused as-is; --base only applies when a new branch is created.","Runs copyFiles, linkFiles, sharedDeps, postCreate hooks, monorepo hooks after creation.","Rolls back on hook failure.","Requires gh CLI for --pr.","Supports comma/space separated focus paths."],configKeys:["`defaults.worktreeDir` \u2014 Directory pattern for new worktrees","`defaults.copyFiles` \u2014 Files to copy from main worktree","`defaults.linkFiles` \u2014 Files to symlink from main worktree","`defaults.sharedDeps` \u2014 Shared dependency strategy and paths","`defaults.postCreate` \u2014 Hooks to run after worktree creation","`defaults.autoUpstream` \u2014 Auto-set upstream tracking branch","`templates.*` \u2014 Named template overrides","`sessions.autoCreate` \u2014 Auto-create tmux session on add","`sessions.layouts` \u2014 Tmux session layout definitions"]},{command:"remove",summary:"Remove a worktree by branch name or path.",synopsis:"omw remove <branch-or-path>",options:[{flag:"--force",type:"boolean",alias:"-f",description:"Force removal even with uncommitted changes"},{flag:"--yes",type:"boolean",alias:"-y",description:"Skip confirmation prompt"}],examples:[["Remove a branch worktree","omw remove feature/auth"],["Force remove without prompt","omw remove feature/auth --force --yes"]],notes:["Runs postRemove hooks and monorepo postRemove hooks before removal.","Cannot remove main worktree.","Cannot remove locked worktrees.","Auto-kills tmux session if sessions.autoKill is enabled."],configKeys:["`defaults.postRemove` \u2014 Hooks to run before worktree removal","`sessions.autoKill` \u2014 Auto-kill tmux session on remove"]},{command:"list",summary:"List worktrees with branch, path, status, and focus details.",synopsis:"omw list",options:[{flag:"--json",type:"boolean",alias:"-j",description:"Output as JSON"},{flag:"--porcelain",type:"boolean",alias:"-p",description:"Machine-readable output"},{flag:"--all",type:"boolean",alias:"-a",description:"List worktrees from all configured repos"}],examples:[["Show all worktrees","omw list"],["Get machine-readable output","omw list --porcelain"]],notes:["Shows branch, path, status (clean/dirty/locked), focus paths.","Focus column truncated to 40 chars."],configKeys:["`repos[].path` \u2014 Repository paths for --all flag"]},{command:"switch",summary:"Switch shell context to a worktree by branch or path.",synopsis:"omw switch <branch-or-path>",options:[],examples:[["Switch using branch name","omw switch feature/auth"],["Switch using path","omw switch ~/.omw/worktrees/repo-feature-auth"]],notes:["Outputs cd command for shell eval.","Requires shell integration (omw shell-init).","Auto-switches tmux session if sessions.enabled and inside tmux.","Logs switch activity."],configKeys:["`sessions.enabled` \u2014 Enable tmux session switching","`sessions.prefix` \u2014 Tmux session name prefix"]},{command:"status",summary:"Show branch health, sync state, commit info, and focus.",synopsis:"omw status",options:[{flag:"--json",type:"boolean",alias:"-j",description:"Output as JSON"},{flag:"--all",type:"boolean",alias:"-a",description:"Show worktrees from all configured repos"}],examples:[["Print status table","omw status"],["Parse status in scripts","omw status --json"]],notes:["Shows branch, dirty count, sync status (ahead/behind), last commit info, focus paths.","Marks current worktree with *."],configKeys:["`repos[].path` \u2014 Repository paths for --all flag"]},{command:"clean",summary:"Remove merged worktrees and optionally inspect stale candidates.",synopsis:"omw clean",options:[{flag:"--dry-run",type:"boolean",alias:"-n",description:"Show what would be removed"},{flag:"--yes",type:"boolean",alias:"-y",description:"Skip confirmation"},{flag:"--stale",type:"boolean",alias:"-",description:"Also show stale worktrees based on lifecycle config"}],examples:[["Preview merged cleanup","omw clean --dry-run"],["Run cleanup without prompts","omw clean --yes"]],notes:["Only removes merged worktrees.","Skips pinned and dirty worktrees.","Runs git worktree prune after cleanup.","--stale uses lifecycle config (staleAfterDays, maxWorktrees)."],configKeys:["`lifecycle.staleAfterDays` \u2014 Days until a worktree is considered stale","`lifecycle.maxWorktrees` \u2014 Maximum allowed worktrees","`lifecycle.autoCleanMerged` \u2014 Auto-clean merged worktrees"]},{command:"doctor",summary:"Run health checks for worktree state and configuration.",synopsis:"omw doctor",options:[{flag:"--json",type:"boolean",alias:"-j",description:"Output as JSON"},{flag:"--fix",type:"boolean",alias:"-",description:"Auto-fix issues"}],examples:[["Run health checks","omw doctor"],["Auto-fix detectable issues","omw doctor --fix"]],notes:["Checks: git version (>=2.17), config validity, stale worktrees, orphaned directories, lock status, dirty worktrees.","Auto-fix: prune stale, remove orphans, unlock stale locks.","Exit code 0 if healthy, 1 if warnings/errors."],configKeys:[]},{command:"exec",summary:"Run a shell command across filtered non-main worktrees.",synopsis:"omw exec <command>",options:[{flag:"--all",type:"boolean",alias:"-a",description:"Run across all configured repos"},{flag:"--dirty",type:"boolean",alias:"-",description:"Only run in dirty worktrees"},{flag:"--clean",type:"boolean",alias:"-",description:"Only run in clean worktrees"},{flag:"--behind",type:"boolean",alias:"-",description:"Only run in worktrees behind upstream"},{flag:"--parallel",type:"boolean",alias:"-p",description:"Run commands in parallel"},{flag:"--json",type:"boolean",alias:"-j",description:"Output results as JSON"}],examples:[["Run tests in parallel",'omw exec "bun test" --parallel'],["Pull only behind worktrees",'omw exec "git pull" --behind']],notes:["Runs in non-main worktrees only.","Sets env vars: OMW_BRANCH, OMW_WORKTREE_PATH, OMW_REPO_PATH.","Exit code 1 if any command fails."],configKeys:["`repos[].path` \u2014 Repository paths for --all flag"]},{command:"diff",summary:"Diff two refs or worktree branches.",synopsis:"omw diff <ref1> [ref2]",options:[{flag:"--stat",type:"boolean",alias:"-s",description:"Show diffstat summary only"},{flag:"--name-only",type:"boolean",alias:"-n",description:"Show only names of changed files"}],examples:[["Show diffstat only","omw diff feature/a feature/b --stat"],["List changed file names","omw diff feature/a --name-only"]],notes:["ref2 defaults to HEAD.","Resolves worktree branch names to refs automatically."],configKeys:[]},{command:"pin",summary:"Pin or unpin worktrees and inspect pin metadata.",synopsis:"omw pin [branch]",options:[{flag:"--reason",type:"string",alias:"-",description:"Reason for pinning"},{flag:"--list",type:"boolean",alias:"-",description:"List pinned worktrees"},{flag:"--json",type:"boolean",alias:"-j",description:"Output as JSON"},{flag:"--unpin",type:"boolean",alias:"-",description:"Unpin instead of pinning"}],examples:[["Pin with a reason",'omw pin feature/auth --reason "active sprint"'],["Unpin a branch","omw pin feature/auth --unpin"]],notes:["Pinned worktrees are excluded from omw clean.","Also invokable as omw unpin <branch>.","Pin metadata stored in git internals."],configKeys:[]},{command:"log",summary:"View or clear activity log events.",synopsis:"omw log",options:[{flag:"--limit",type:"number",alias:"-",description:"default 20, Show the last N entries"},{flag:"--json",type:"boolean",alias:"-j",description:"Output as JSON"},{flag:"--clear",type:"boolean",alias:"-",description:"Clear the activity log"}],examples:[["Show recent entries","omw log --limit 50"],["Clear the log","omw log --clear"]],notes:["Events: create (green), delete (red), switch (blue), rename (yellow), archive (magenta), import (cyan).","Color-coded in terminal."],configKeys:[]},{command:"archive",summary:"Archive worktree changes as patch files before optional removal.",synopsis:"omw archive [branch]",options:[{flag:"--yes",type:"boolean",alias:"-y",description:"Skip confirmation prompt"},{flag:"--keep",type:"boolean",alias:"-",description:"Archive without removing the worktree"},{flag:"--list",type:"boolean",alias:"-",description:"List all archives"},{flag:"--json",type:"boolean",alias:"-j",description:"Output as JSON with --list"}],examples:[["Archive and remove","omw archive feature/done --yes"],["List archive records","omw archive --list --json"]],notes:["Archives stored as patch files in ~/.omw/archives/.","Cannot archive main worktree.","Runs postRemove hooks before removal unless --keep."],configKeys:["`defaults.postRemove` \u2014 Hooks to run before worktree removal"]},{command:"rename",summary:"Rename a worktree branch and optionally move its directory path.",synopsis:"omw rename <old> <new>",options:[{flag:"--move-path",type:"boolean",alias:"-",description:"Also rename the worktree directory path"}],examples:[["Rename a worktree branch","omw rename feature/old feature/new"],["Rename branch and directory","omw rename feature/old feature/new --move-path"]],notes:["Cannot rename main worktree.","Checks for branch name conflicts.","Logs rename activity.","--move-path replaces old branch slug with new one in directory name."],configKeys:[]},{command:"clone",summary:"Clone a repository and optionally apply omw template setup.",synopsis:"omw clone <url> [path]",options:[{flag:"--template",type:"string",alias:"-t",description:"Apply a named template after cloning"},{flag:"--init-config",type:"boolean",alias:"-",description:"default true, Initialize omw config after cloning"}],examples:[["Clone and initialize","omw clone https://github.com/user/repo.git"],["Clone with template and no config init","omw clone https://github.com/user/repo.git --template review --no-init-config"]],notes:["Auto-detects target path from URL.","Runs template postCreate hooks if template specified.","Use --no-init-config to skip config initialization."],configKeys:["`templates.*` \u2014 Named template overrides"]},{command:"import",summary:"Import an existing git worktree into omw metadata.",synopsis:"omw import <path>",options:[{flag:"--focus",type:"array",alias:"-f",description:"Focus packages for monorepo"},{flag:"--pin",type:"boolean",alias:"-",description:"Pin the worktree"}],examples:[["Import a worktree path","omw import /path/to/worktree"],["Import with focus and pin","omw import /path/to/worktree --focus apps/web,apps/api --pin"]],notes:["Validates that path is a valid git worktree.","Logs import activity.","Supports comma/space separated focus paths."],configKeys:[]},{command:"session",summary:"Manage tmux sessions for worktrees.",synopsis:"omw session [branch-or-path]",options:[{flag:"--list",type:"boolean",alias:"-l",description:"List active omw tmux sessions"},{flag:"--kill",type:"boolean",alias:"-k",description:"Kill the session for the specified worktree"},{flag:"--kill-all",type:"boolean",alias:"-",description:"Kill all omw tmux sessions"},{flag:"--layout",type:"string",alias:"-",description:"Use a named layout from config"},{flag:"--json",type:"boolean",alias:"-j",description:"Output in JSON format"}],examples:[["Attach or create a session","omw session feature/auth"],["List sessions as JSON","omw session --list --json"]],notes:["Requires tmux.","Session naming: branch feat/auth-token \u2192 tmux session omw_feat-auth-token.","Supports layout templates with multiple windows."],configKeys:["`sessions.enabled` \u2014 Enable tmux session integration","`sessions.autoCreate` \u2014 Auto-create session on worktree add","`sessions.autoKill` \u2014 Auto-kill session on worktree remove","`sessions.prefix` \u2014 Tmux session name prefix","`sessions.defaultLayout` \u2014 Default layout name","`sessions.layouts` \u2014 Layout definitions with windows"]},{command:"config",summary:"Initialize, inspect, edit, validate, and manage profiles.",synopsis:"omw config",options:[{flag:"--init",type:"boolean",alias:"-",description:"Create default config file"},{flag:"--show",type:"boolean",alias:"-s",description:"Print current config as JSON"},{flag:"--edit",type:"boolean",alias:"-e",description:"Open config in $EDITOR"},{flag:"--path",type:"boolean",alias:"-",description:"Print config file path"},{flag:"--validate",type:"boolean",alias:"-",description:"Validate config against schema"},{flag:"--profiles",type:"boolean",alias:"-",description:"List config profiles"},{flag:"--profile",type:"string",alias:"-",description:"Profile name for activation/deletion"},{flag:"--activate",type:"boolean",alias:"-",description:"Activate the specified profile"},{flag:"--delete",type:"boolean",alias:"-",description:"Delete the specified profile"}],examples:[["Initialize config","omw config --init"],["Activate a profile","omw config --profile work --activate"]],notes:["Config path: ~/.config/oh-my-worktree/config.json.","XDG-compliant."],configKeys:[]},{command:"open",summary:"Open the target or current worktree in an editor.",synopsis:"omw open [branch-or-path]",options:[{flag:"--editor",type:"string",alias:"-e",description:"Editor command to use"},{flag:"--list-editors",type:"boolean",alias:"-",description:"List detected editors"}],examples:[["Open current worktree","omw open"],["Open with specific editor","omw open feature/auth --editor nvim"]],notes:["Auto-detects editors: code, cursor, vim, nvim, emacs, nano, subl, zed, idea, webstorm.","Uses $VISUAL or $EDITOR env vars.","Defaults to current worktree if no branch specified."],configKeys:[]},{command:"shell-init",summary:"Generate shell integration wrappers and completions.",synopsis:"omw shell-init [shell]",options:[{flag:"--completions",type:"string",alias:"-",description:"Generate shell completions: bash, zsh, fish"}],examples:[["Generate shell wrapper","omw shell-init zsh"],["Generate completion script","omw shell-init --completions fish"]],notes:["Shell arg is auto-detected if omitted.","Generates wrapper function for omw switch to work with shell cd.","Supports bash, zsh, fish."],configKeys:[]},{command:"init",summary:"Initialize omw config or install AI agent skill files.",synopsis:"omw init",options:[{flag:"--skill",type:"string",alias:"-s",description:"Install AI agent skill: claude-code, codex, opencode"}],examples:[["Initialize config","omw init"],["Install Claude Code skill","omw init --skill claude-code"],["Install Codex skill","omw init --skill codex"]],notes:["Without --skill, reuses config initialization and creates only config.json.","With --skill, installs or updates SKILL.md + references/ directory.","Idempotent \u2014 running again updates existing files without breaking existing setup."],configKeys:[]}]});var su={};Ye(su,{default:()=>yg});import{dirname as Eg}from"path";var Mg,yg;var cu=$e(()=>{it();iu();Mg={command:"init",describe:"Initialize config or install omw integrations",builder:(e)=>e.option("skill",{type:"string",alias:"s",describe:`Install AI agent skill (${ks.join(", ")})`,choices:ks}),handler:async(e)=>{let t=e.skill;try{if(!t){let r=Pn();console.log(`\u2713 Initialized config \u2192 ${r}`),process.exit(0)}let n=ru(t),o=n.action==="created"?"Installed":"Updated";console.log(`\u2713 ${o} \u2192 ${Eg(n.filePath)}/`),console.log(" SKILL.md"),console.log(` references/ (${n.referenceCount} commands)`),process.exit(0)}catch(n){console.error(`Error: ${n.message}`),process.exit(1)}}},yg=Mg});import"@opentui/solid/preload";import{notStrictEqual as Iu,strictEqual as Bu}from"assert";var du={right:pu,center:gu};class Qs{constructor(e){var t;this.width=e.width,this.wrap=(t=e.wrap)!==null&&t!==void 0?t:!0,this.rows=[]}span(...e){let t=this.div(...e);t.span=!0}resetOutput(){this.rows=[]}div(...e){if(e.length===0)this.div("");if(this.wrap&&this.shouldApplyLayoutDSL(...e)&&typeof e[0]==="string")return this.applyLayoutDSL(e[0]);let t=e.map((n)=>{if(typeof n==="string")return this.colFromString(n);return n});return this.rows.push(t),t}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]==="string"&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){let t=e.split(`
|
|
158
|
+
`).map((o)=>o.split("\t")),n=0;return t.forEach((o)=>{if(o.length>1&&jt.stringWidth(o[0])>n)n=Math.min(Math.floor(this.width*0.5),jt.stringWidth(o[0]))}),t.forEach((o)=>{this.div(...o.map((r,i)=>{return{text:r.trim(),padding:this.measurePadding(r),width:i===0&&o.length>1?n:void 0}}))}),this.rows[this.rows.length-1]}colFromString(e){return{text:e,padding:this.measurePadding(e)}}measurePadding(e){let t=jt.stripAnsi(e);return[0,t.match(/\s*$/)[0].length,0,t.match(/^\s*/)[0].length]}toString(){let e=[];return this.rows.forEach((t)=>{this.rowToString(t,e)}),e.filter((t)=>!t.hidden).map((t)=>t.text).join(`
|
|
159
|
+
`)}rowToString(e,t){return this.rasterize(e).forEach((n,o)=>{let r="";n.forEach((i,s)=>{let{width:c}=e[s],u=this.negatePadding(e[s]),f=i;if(u>jt.stringWidth(i))f+=" ".repeat(u-jt.stringWidth(i));if(e[s].align&&e[s].align!=="left"&&this.wrap){let l=du[e[s].align];if(f=l(f,u),jt.stringWidth(f)<u)f+=" ".repeat((c||0)-jt.stringWidth(f)-1)}let m=e[s].padding||[0,0,0,0];if(m[3])r+=" ".repeat(m[3]);if(r+=Zs(e[s],f,"| "),r+=f,r+=Zs(e[s],f," |"),m[1])r+=" ".repeat(m[1]);if(o===0&&t.length>0)r=this.renderInline(r,t[t.length-1])}),t.push({text:r.replace(/ +$/,""),span:e.span})}),t}renderInline(e,t){let n=e.match(/^ */),o=n?n[0].length:0,r=t.text,i=jt.stringWidth(r.trimRight());if(!t.span)return e;if(!this.wrap)return t.hidden=!0,r+e;if(o<i)return e;return t.hidden=!0,r.trimRight()+" ".repeat(o-i)+e.trimLeft()}rasterize(e){let t=[],n=this.columnWidths(e),o;return e.forEach((r,i)=>{if(r.width=n[i],this.wrap)o=jt.wrap(r.text,this.negatePadding(r),{hard:!0}).split(`
|
|
160
|
+
`);else o=r.text.split(`
|
|
161
|
+
`);if(r.border)o.unshift("."+"-".repeat(this.negatePadding(r)+2)+"."),o.push("'"+"-".repeat(this.negatePadding(r)+2)+"'");if(r.padding)o.unshift(...Array(r.padding[0]||0).fill("")),o.push(...Array(r.padding[2]||0).fill(""));o.forEach((s,c)=>{if(!t[c])t.push([]);let u=t[c];for(let f=0;f<i;f++)if(u[f]===void 0)u.push("");u.push(s)})}),t}negatePadding(e){let t=e.width||0;if(e.padding)t-=(e.padding[3]||0)+(e.padding[1]||0);if(e.border)t-=4;return t}columnWidths(e){if(!this.wrap)return e.map((i)=>{return i.width||jt.stringWidth(i.text)});let t=e.length,n=this.width,o=e.map((i)=>{if(i.width)return t--,n-=i.width,i.width;return}),r=t?Math.floor(n/t):0;return o.map((i,s)=>{if(i===void 0)return Math.max(r,hu(e[s]));return i})}}function Zs(e,t,n){if(e.border){if(/[.']-+[.']/.test(t))return"";if(t.trim().length!==0)return n;return" "}return""}function hu(e){let t=e.padding||[],n=1+(t[3]||0)+(t[1]||0);if(e.border)return n+4;return n}function mu(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function pu(e,t){e=e.trim();let n=jt.stringWidth(e);if(n<t)return" ".repeat(t-n)+e;return e}function gu(e,t){e=e.trim();let n=jt.stringWidth(e);if(n>=t)return e;return" ".repeat(t-n>>1)+e}var jt;function Ys(e,t){return jt=t,new Qs({width:(e===null||e===void 0?void 0:e.width)||mu(),wrap:e===null||e===void 0?void 0:e.wrap})}var _s=new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function Wi(e){return e.replace(_s,"")}function ec(e,t){let[n,o]=e.match(_s)||["",""];e=Wi(e);let r="";for(let i=0;i<e.length;i++){if(i!==0&&i%t===0)r+=`
|
|
162
|
+
`;r+=e.charAt(i)}if(n&&o)r=`${n}${r}${o}`;return r}function Di(e){return Ys(e,{stringWidth:(t)=>{return[...t].length},stripAnsi:Wi,wrap:ec})}import{dirname as tc,resolve as nc}from"path";import{readdirSync as wu,statSync as xu}from"fs";function Fi(e,t){let n=nc(".",e),o;if(!xu(n).isDirectory())n=tc(n);while(!0){if(o=t(n,wu(n)),o)return nc(n,o);if(n=tc(o=n),o===n)break}}import{inspect as Lu}from"util";import{readFileSync as Au}from"fs";import{fileURLToPath as Tu}from"url";import{format as Cu}from"util";import{normalize as $u,resolve as Pu}from"path";function fo(e){if(!(e!==e.toLowerCase()&&e!==e.toUpperCase()))e=e.toLowerCase();if(e.indexOf("-")===-1&&e.indexOf("_")===-1)return e;else{let n="",o=!1,r=e.match(/^-+/);for(let i=r?r[0].length:0;i<e.length;i++){let s=e.charAt(i);if(o)o=!1,s=s.toUpperCase();if(i!==0&&(s==="-"||s==="_"))o=!0;else if(s!=="-"&&s!=="_")n+=s}return n}}function Nr(e,t){let n=e.toLowerCase();t=t||"-";let o="";for(let r=0;r<e.length;r++){let i=n.charAt(r),s=e.charAt(r);if(i!==s&&r>0)o+=`${t}${n.charAt(r)}`;else o+=s}return o}function Gr(e){if(e===null||e===void 0)return!1;if(typeof e==="number")return!0;if(/^0x[0-9a-f]+$/i.test(e))return!0;if(/^0[^.]/.test(e))return!1;return/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function oc(e){if(Array.isArray(e))return e.map((s)=>typeof s!=="string"?s+"":s);e=e.trim();let t=0,n=null,o=null,r=null,i=[];for(let s=0;s<e.length;s++){if(n=o,o=e.charAt(s),o===" "&&!r){if(n!==" ")t++;continue}if(o===r)r=null;else if((o==="'"||o==='"')&&!r)r=o;if(!i[t])i[t]="";i[t]+=o}return i}var Xt;(function(e){e.BOOLEAN="boolean",e.STRING="string",e.NUMBER="number",e.ARRAY="array"})(Xt||(Xt={}));var Mn;class Bi{constructor(e){Mn=e}parse(e,t){let n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},t),o=oc(e),r=typeof e==="string",i=bu(Object.assign(Object.create(null),n.alias)),s=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),c=Object.assign(Object.create(null),n.default),u=n.configObjects||[],f=n.envPrefix,m=s["populate--"],l=m?"--":"_",p=Object.create(null),R=Object.create(null),M=n.__||Mn.format,d={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},b=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,y=new RegExp("^--"+s["negation-prefix"]+"(.+)");if([].concat(n.array||[]).filter(Boolean).forEach(function(a){let w=typeof a==="object"?a.key:a,L=Object.keys(a).map(function(W){return{boolean:"bools",string:"strings",number:"numbers"}[W]}).filter(Boolean).pop();if(L)d[L][w]=!0;d.arrays[w]=!0,d.keys.push(w)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(a){d.bools[a]=!0,d.keys.push(a)}),[].concat(n.string||[]).filter(Boolean).forEach(function(a){d.strings[a]=!0,d.keys.push(a)}),[].concat(n.number||[]).filter(Boolean).forEach(function(a){d.numbers[a]=!0,d.keys.push(a)}),[].concat(n.count||[]).filter(Boolean).forEach(function(a){d.counts[a]=!0,d.keys.push(a)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(a){d.normalize[a]=!0,d.keys.push(a)}),typeof n.narg==="object")Object.entries(n.narg).forEach(([a,w])=>{if(typeof w==="number")d.nargs[a]=w,d.keys.push(a)});if(typeof n.coerce==="object")Object.entries(n.coerce).forEach(([a,w])=>{if(typeof w==="function")d.coercions[a]=w,d.keys.push(a)});if(typeof n.config<"u"){if(Array.isArray(n.config)||typeof n.config==="string")[].concat(n.config).filter(Boolean).forEach(function(a){d.configs[a]=!0});else if(typeof n.config==="object")Object.entries(n.config).forEach(([a,w])=>{if(typeof w==="boolean"||typeof w==="function")d.configs[a]=w})}B(n.key,i,n.default,d.arrays),Object.keys(c).forEach(function(a){(d.aliases[a]||[]).forEach(function(w){c[w]=c[a]})});let S=null;O();let P=[],E=Object.assign(Object.create(null),{_:[]}),I={};for(let a=0;a<o.length;a++){let w=o[a],L=w.replace(/^-{3,}/,"---"),W,C,q,X,U,Ne;if(w!=="--"&&/^-/.test(w)&&_(w))V(w);else if(L.match(/^---+(=|$)/)){V(w);continue}else if(w.match(/^--.+=/)||!s["short-option-groups"]&&w.match(/^-.+=/)){if(X=w.match(/^--?([^=]+)=([\s\S]*)$/),X!==null&&Array.isArray(X)&&X.length>=3)if(D(X[1],d.arrays))a=H(a,X[1],o,X[2]);else if(D(X[1],d.nargs)!==!1)a=T(a,X[1],o,X[2]);else Q(X[1],X[2],!0)}else if(w.match(y)&&s["boolean-negation"]){if(X=w.match(y),X!==null&&Array.isArray(X)&&X.length>=2)C=X[1],Q(C,D(C,d.arrays)?[!1]:!1)}else if(w.match(/^--.+/)||!s["short-option-groups"]&&w.match(/^-[^-]+/)){if(X=w.match(/^--?(.+)/),X!==null&&Array.isArray(X)&&X.length>=2)if(C=X[1],D(C,d.arrays))a=H(a,C,o);else if(D(C,d.nargs)!==!1)a=T(a,C,o);else if(U=o[a+1],U!==void 0&&(!U.match(/^-/)||U.match(b))&&!D(C,d.bools)&&!D(C,d.counts))Q(C,U),a++;else if(/^(true|false)$/.test(U))Q(C,U),a++;else Q(C,fe(C))}else if(w.match(/^-.\..+=/)){if(X=w.match(/^-([^=]+)=([\s\S]*)$/),X!==null&&Array.isArray(X)&&X.length>=3)Q(X[1],X[2])}else if(w.match(/^-.\..+/)&&!w.match(b)){if(U=o[a+1],X=w.match(/^-(.\..+)/),X!==null&&Array.isArray(X)&&X.length>=2)if(C=X[1],U!==void 0&&!U.match(/^-/)&&!D(C,d.bools)&&!D(C,d.counts))Q(C,U),a++;else Q(C,fe(C))}else if(w.match(/^-[^-]+/)&&!w.match(b)){q=w.slice(1,-1).split(""),W=!1;for(let Ue=0;Ue<q.length;Ue++){if(U=w.slice(Ue+2),q[Ue+1]&&q[Ue+1]==="="){if(Ne=w.slice(Ue+3),C=q[Ue],D(C,d.arrays))a=H(a,C,o,Ne);else if(D(C,d.nargs)!==!1)a=T(a,C,o,Ne);else Q(C,Ne);W=!0;break}if(U==="-"){Q(q[Ue],U);continue}if(/[A-Za-z]/.test(q[Ue])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(U)&&D(U,d.bools)===!1){Q(q[Ue],U),W=!0;break}if(q[Ue+1]&&q[Ue+1].match(/\W/)){Q(q[Ue],U),W=!0;break}else Q(q[Ue],fe(q[Ue]))}if(C=w.slice(-1)[0],!W&&C!=="-")if(D(C,d.arrays))a=H(a,C,o);else if(D(C,d.nargs)!==!1)a=T(a,C,o);else if(U=o[a+1],U!==void 0&&(!/^(-|--)[^-]/.test(U)||U.match(b))&&!D(C,d.bools)&&!D(C,d.counts))Q(C,U),a++;else if(/^(true|false)$/.test(U))Q(C,U),a++;else Q(C,fe(C))}else if(w.match(/^-[0-9]$/)&&w.match(b)&&D(w.slice(1),d.bools))C=w.slice(1),Q(C,fe(C));else if(w==="--"){P=o.slice(a+1);break}else if(s["halt-at-non-option"]){P=o.slice(a);break}else V(w)}if(ge(E,!0),ge(E,!1),N(E),k(),x(E,d.aliases,c,!0),re(E),s["set-placeholder-key"])me(E);if(Object.keys(d.counts).forEach(function(a){if(!v(E,a.split(".")))Q(a,0)}),m&&P.length)E[l]=[];if(P.forEach(function(a){E[l].push(a)}),s["camel-case-expansion"]&&s["strip-dashed"])Object.keys(E).filter((a)=>a!=="--"&&a.includes("-")).forEach((a)=>{delete E[a]});if(s["strip-aliased"])[].concat(...Object.keys(i).map((a)=>i[a])).forEach((a)=>{if(s["camel-case-expansion"]&&a.includes("-"))delete E[a.split(".").map((w)=>fo(w)).join(".")];delete E[a]});function V(a){let w=F("_",a);if(typeof w==="string"||typeof w==="number")E._.push(w)}function T(a,w,L,W){let C,q=D(w,d.nargs);if(q=typeof q!=="number"||isNaN(q)?1:q,q===0){if(!Ce(W))S=Error(M("Argument unexpected for: %s",w));return Q(w,fe(w)),a}let X=Ce(W)?0:1;if(s["nargs-eats-options"]){if(L.length-(a+1)+X<q)S=Error(M("Not enough arguments following: %s",w));X=q}else{for(C=a+1;C<L.length;C++)if(!L[C].match(/^-[^0-9]/)||L[C].match(b)||_(L[C]))X++;else break;if(X<q)S=Error(M("Not enough arguments following: %s",w))}let U=Math.min(X,q);if(!Ce(W)&&U>0)Q(w,W),U--;for(C=a+1;C<U+a+1;C++)Q(w,L[C]);return a+U}function H(a,w,L,W){let C=[],q=W||L[a+1],X=D(w,d.nargs);if(D(w,d.bools)&&!/^(true|false)$/.test(q))C.push(!0);else if(Ce(q)||Ce(W)&&/^-/.test(q)&&!b.test(q)&&!_(q)){if(c[w]!==void 0){let U=c[w];C=Array.isArray(U)?U:[U]}}else{if(!Ce(W))C.push(G(w,W,!0));for(let U=a+1;U<L.length;U++){if(!s["greedy-arrays"]&&C.length>0||X&&typeof X==="number"&&C.length>=X)break;if(q=L[U],/^-/.test(q)&&!b.test(q)&&!_(q))break;a=U,C.push(G(w,q,r))}}if(typeof X==="number"&&(X&&C.length<X||isNaN(X)&&C.length===0))S=Error(M("Not enough arguments following: %s",w));return Q(w,C),a}function Q(a,w,L=r){if(/-/.test(a)&&s["camel-case-expansion"]){let q=a.split(".").map(function(X){return fo(X)}).join(".");he(a,q)}let W=G(a,w,L),C=a.split(".");if(A(E,C,W),d.aliases[a])d.aliases[a].forEach(function(q){let X=q.split(".");A(E,X,W)});if(C.length>1&&s["dot-notation"])(d.aliases[C[0]]||[]).forEach(function(q){let X=q.split("."),U=[].concat(C);if(U.shift(),X=X.concat(U),!(d.aliases[a]||[]).includes(X.join(".")))A(E,X,W)});if(D(a,d.normalize)&&!D(a,d.arrays))[a].concat(d.aliases[a]||[]).forEach(function(X){Object.defineProperty(I,X,{enumerable:!0,get(){return w},set(U){w=typeof U==="string"?Mn.normalize(U):U}})})}function he(a,w){if(!(d.aliases[a]&&d.aliases[a].length))d.aliases[a]=[w],p[w]=!0;if(!(d.aliases[w]&&d.aliases[w].length))he(w,a)}function G(a,w,L){if(L)w=vu(w);if(D(a,d.bools)||D(a,d.counts)){if(typeof w==="string")w=w==="true"}let W=Array.isArray(w)?w.map(function(C){return F(a,C)}):F(a,w);if(D(a,d.counts)&&(Ce(W)||typeof W==="boolean"))W=Ii();if(D(a,d.normalize)&&D(a,d.arrays))if(Array.isArray(w))W=w.map((C)=>{return Mn.normalize(C)});else W=Mn.normalize(w);return W}function F(a,w){if(!s["parse-positional-numbers"]&&a==="_")return w;if(!D(a,d.strings)&&!D(a,d.bools)&&!Array.isArray(w)){if(Gr(w)&&s["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${w}`)))||!Ce(w)&&D(a,d.numbers))w=Number(w)}return w}function N(a){let w=Object.create(null);x(w,d.aliases,c),Object.keys(d.configs).forEach(function(L){let W=a[L]||w[L];if(W)try{let C=null,q=Mn.resolve(Mn.cwd(),W),X=d.configs[L];if(typeof X==="function"){try{C=X(q)}catch(U){C=U}if(C instanceof Error){S=C;return}}else C=Mn.require(q);K(C)}catch(C){if(C.name==="PermissionDenied")S=C;else if(a[L])S=Error(M("Invalid JSON config file: %s",W))}})}function K(a,w){Object.keys(a).forEach(function(L){let W=a[L],C=w?w+"."+L:L;if(typeof W==="object"&&W!==null&&!Array.isArray(W)&&s["dot-notation"])K(W,C);else if(!v(E,C.split("."))||D(C,d.arrays)&&s["combine-arrays"])Q(C,W)})}function k(){if(typeof u<"u")u.forEach(function(a){K(a)})}function ge(a,w){if(typeof f>"u")return;let L=typeof f==="string"?f:"",W=Mn.env();Object.keys(W).forEach(function(C){if(L===""||C.lastIndexOf(L,0)===0){let q=C.split("__").map(function(X,U){if(U===0)X=X.substring(L.length);return fo(X)});if((w&&d.configs[q.join(".")]||!w)&&!v(a,q))Q(q.join("."),W[C])}})}function re(a){let w,L=new Set;Object.keys(a).forEach(function(W){if(!L.has(W)){if(w=D(W,d.coercions),typeof w==="function")try{let C=F(W,w(a[W]));[].concat(d.aliases[W]||[],W).forEach((q)=>{L.add(q),a[q]=C})}catch(C){S=C}}})}function me(a){return d.keys.forEach((w)=>{if(~w.indexOf("."))return;if(typeof a[w]>"u")a[w]=void 0}),a}function x(a,w,L,W=!1){Object.keys(L).forEach(function(C){if(!v(a,C.split("."))){if(A(a,C.split("."),L[C]),W)R[C]=!0;(w[C]||[]).forEach(function(q){if(v(a,q.split(".")))return;A(a,q.split("."),L[C])})}})}function v(a,w){let L=a;if(!s["dot-notation"])w=[w.join(".")];w.slice(0,-1).forEach(function(C){L=L[C]||{}});let W=w[w.length-1];if(typeof L!=="object")return!1;else return W in L}function A(a,w,L){let W=a;if(!s["dot-notation"])w=[w.join(".")];w.slice(0,-1).forEach(function(Ne){if(Ne=rc(Ne),typeof W==="object"&&W[Ne]===void 0)W[Ne]={};if(typeof W[Ne]!=="object"||Array.isArray(W[Ne])){if(Array.isArray(W[Ne]))W[Ne].push({});else W[Ne]=[W[Ne],{}];W=W[Ne][W[Ne].length-1]}else W=W[Ne]});let C=rc(w[w.length-1]),q=D(w.join("."),d.arrays),X=Array.isArray(L),U=s["duplicate-arguments-array"];if(!U&&D(C,d.nargs)){if(U=!0,!Ce(W[C])&&d.nargs[C]===1||Array.isArray(W[C])&&W[C].length===d.nargs[C])W[C]=void 0}if(L===Ii())W[C]=Ii(W[C]);else if(Array.isArray(W[C]))if(U&&q&&X)W[C]=s["flatten-duplicate-arrays"]?W[C].concat(L):(Array.isArray(W[C][0])?W[C]:[W[C]]).concat([L]);else if(!U&&Boolean(q)===Boolean(X))W[C]=L;else W[C]=W[C].concat([L]);else if(W[C]===void 0&&q)W[C]=X?L:[L];else if(U&&!(W[C]===void 0||D(C,d.counts)||D(C,d.bools)))W[C]=[W[C],L];else W[C]=L}function B(...a){a.forEach(function(w){Object.keys(w||{}).forEach(function(L){if(d.aliases[L])return;d.aliases[L]=[].concat(i[L]||[]),d.aliases[L].concat(L).forEach(function(W){if(/-/.test(W)&&s["camel-case-expansion"]){let C=fo(W);if(C!==L&&d.aliases[L].indexOf(C)===-1)d.aliases[L].push(C),p[C]=!0}}),d.aliases[L].concat(L).forEach(function(W){if(W.length>1&&/[A-Z]/.test(W)&&s["camel-case-expansion"]){let C=Nr(W,"-");if(C!==L&&d.aliases[L].indexOf(C)===-1)d.aliases[L].push(C),p[C]=!0}}),d.aliases[L].forEach(function(W){d.aliases[W]=[L].concat(d.aliases[L].filter(function(C){return W!==C}))})})})}function D(a,w){let L=[].concat(d.aliases[a]||[],a),W=Object.keys(w),C=L.find((q)=>W.includes(q));return C?w[C]:!1}function z(a){let w=Object.keys(d);return[].concat(w.map((W)=>d[W])).some(function(W){return Array.isArray(W)?W.includes(a):W[a]})}function se(a,...w){return[].concat(...w).some(function(W){let C=a.match(W);return C&&z(C[1])})}function J(a){if(a.match(b)||!a.match(/^-[^-]+/))return!1;let w=!0,L,W=a.slice(1).split("");for(let C=0;C<W.length;C++){if(L=a.slice(C+2),!z(W[C])){w=!1;break}if(W[C+1]&&W[C+1]==="="||L==="-"||/[A-Za-z]/.test(W[C])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(L)||W[C+1]&&W[C+1].match(/\W/))break}return w}function _(a){return s["unknown-options-as-args"]&&Me(a)}function Me(a){if(a=a.replace(/^-{3,}/,"--"),a.match(b))return!1;if(J(a))return!1;return!se(a,/^-+([^=]+?)=[\s\S]*$/,y,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function fe(a){if(!D(a,d.bools)&&!D(a,d.counts)&&`${a}`in c)return c[a];else return pe(De(a))}function pe(a){return{[Xt.BOOLEAN]:!0,[Xt.STRING]:"",[Xt.NUMBER]:void 0,[Xt.ARRAY]:[]}[a]}function De(a){let w=Xt.BOOLEAN;if(D(a,d.strings))w=Xt.STRING;else if(D(a,d.numbers))w=Xt.NUMBER;else if(D(a,d.bools))w=Xt.BOOLEAN;else if(D(a,d.arrays))w=Xt.ARRAY;return w}function Ce(a){return a===void 0}function O(){Object.keys(d.counts).find((a)=>{if(D(a,d.arrays))return S=Error(M("Invalid configuration: %s, opts.count excludes opts.array.",a)),!0;else if(D(a,d.nargs))return S=Error(M("Invalid configuration: %s, opts.count excludes opts.narg.",a)),!0;return!1})}return{aliases:Object.assign({},d.aliases),argv:Object.assign(I,E),configuration:s,defaulted:Object.assign({},R),error:S,newAliases:Object.assign({},p)}}}function bu(e){let t=[],n=Object.create(null),o=!0;Object.keys(e).forEach(function(r){t.push([].concat(e[r],r))});while(o){o=!1;for(let r=0;r<t.length;r++)for(let i=r+1;i<t.length;i++)if(t[r].filter(function(c){return t[i].indexOf(c)!==-1}).length){t[r]=t[r].concat(t[i]),t.splice(i,1),o=!0;break}}return t.forEach(function(r){r=r.filter(function(s,c,u){return u.indexOf(s)===c});let i=r.pop();if(i!==void 0&&typeof i==="string")n[i]=r}),n}function Ii(e){return e!==void 0?e+1:1}function rc(e){if(e==="__proto__")return"___proto___";return e}function vu(e){return typeof e==="string"&&(e[0]==="'"||e[0]==='"')&&e[e.length-1]===e[0]?e.substring(1,e.length-1):e}var Li,Ai,Ti,ic=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,sc=(Ai=(Li=process===null||process===void 0?void 0:process.versions)===null||Li===void 0?void 0:Li.node)!==null&&Ai!==void 0?Ai:(Ti=process===null||process===void 0?void 0:process.version)===null||Ti===void 0?void 0:Ti.slice(1);if(sc){if(Number(sc.match(/^([^.]+)/)[1])<ic)throw Error(`yargs parser supports a minimum Node.js version of ${ic}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var Su=process?process.env:{},cc=new Bi({cwd:process.cwd,env:()=>{return Su},format:Cu,normalize:$u,resolve:Pu,require:(e)=>{return En(e)}}),dr=function(t,n){return cc.parse(t.slice(),n).argv};dr.detailed=function(e,t){return cc.parse(e.slice(),t)};dr.camelCase=fo;dr.decamelize=Nr;dr.looksLikeNumber=Gr;var ji=dr;import{basename as ju,dirname as Nu,extname as Gu,relative as ku,resolve as mc}from"path";function ac(){if(Eu())return 0;return 1}function Eu(){return Mu()&&!process.defaultApp}function Mu(){return!!process.versions.electron}function Ni(e){return e.slice(ac()+1)}function lc(){return process.argv[ac()]}class Ve extends Error{constructor(e){super(e||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,Ve)}}import{readFileSync as yu,statSync as Ru,writeFile as Ou}from"fs";import{format as Wu}from"util";import{resolve as Du}from"path";var fc={fs:{readFileSync:yu,writeFile:Ou},format:Wu,resolve:Du,exists:(e)=>{try{return Ru(e).isFile()}catch(t){return!1}}};var an;class uc{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles=typeof e.updateFiles==="boolean"?e.updateFiles:!0,this.locale=e.locale||"en",this.fallbackToLanguage=typeof e.fallbackToLanguage==="boolean"?e.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if(typeof arguments[0]!=="string")return this._taggedLiteral(arguments[0],...arguments);let t=e.shift(),n=function(){};if(typeof e[e.length-1]==="function")n=e.pop();if(n=n||function(){},!this.cache[this.locale])this._readLocaleFile();if(!this.cache[this.locale][t]&&this.updateFiles)this.cache[this.locale][t]=t,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n});else n();return an.format.apply(an.format,[this.cache[this.locale][t]||t].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift(),o=e.shift(),r=function(){};if(typeof e[e.length-1]==="function")r=e.pop();if(!this.cache[this.locale])this._readLocaleFile();let i=o===1?t:n;if(this.cache[this.locale][t])i=this.cache[this.locale][t][o===1?"one":"other"];if(!this.cache[this.locale][t]&&this.updateFiles)this.cache[this.locale][t]={one:t,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:r});else r();let s=[i];if(~i.indexOf("%d"))s.push(o);return an.format.apply(an.format,s.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){if(!this.cache[this.locale])this._readLocaleFile();for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))this.cache[this.locale][t]=e[t]}_taggedLiteral(e,...t){let n="";return e.forEach(function(o,r){let i=t[r+1];if(n+=o,typeof i<"u")n+="%s"}),this.__.apply(this,[n].concat([].slice.call(t,1)))}_enqueueWrite(e){if(this.writeQueue.push(e),this.writeQueue.length===1)this._processWriteQueue()}_processWriteQueue(){let e=this,t=this.writeQueue[0],n=t.directory,o=t.locale,r=t.cb,i=this._resolveLocaleFile(n,o),s=JSON.stringify(this.cache[o],null,2);an.fs.writeFile(i,s,"utf-8",function(c){if(e.writeQueue.shift(),e.writeQueue.length>0)e._processWriteQueue();r(c)})}_readLocaleFile(){let e={},t=this._resolveLocaleFile(this.directory,this.locale);try{if(an.fs.readFileSync)e=JSON.parse(an.fs.readFileSync(t,"utf-8"))}catch(n){if(n instanceof SyntaxError)n.message="syntax error in "+t;if(n.code==="ENOENT")e={};else throw n}this.cache[this.locale]=e}_resolveLocaleFile(e,t){let n=an.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~t.lastIndexOf("_")){let o=an.resolve(e,"./",t.split("_")[0]+".json");if(this._fileExistsSync(o))n=o}return n}_fileExistsSync(e){return an.exists(e)}}function dc(e,t){an=t;let n=new uc(e);return{__:n.__.bind(n),__n:n.__n.bind(n),setLocale:n.setLocale.bind(n),getLocale:n.getLocale.bind(n),updateLocale:n.updateLocale.bind(n),locale:n.locale}}var Fu=(e)=>{return dc(e,fc)},hc=Fu;var Hu="require is not supported by ESM",pc="loading a directory of commands is not supported yet for ESM",hr;try{hr=Tu(import.meta.url)}catch(e){hr=process.cwd()}var zu=hr.substring(0,hr.lastIndexOf("node_modules")),Gi={assert:{notStrictEqual:Iu,strictEqual:Bu},cliui:Di,findUp:Fi,getEnv:(e)=>{return process.env[e]},inspect:Lu,getCallerFile:()=>{throw new Ve(pc)},getProcessArgvBin:lc,mainFilename:zu||process.cwd(),Parser:ji,path:{basename:ju,dirname:Nu,extname:Gu,relative:ku,resolve:mc},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(e,t)=>process.emitWarning(e,t),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:Au,require:()=>{throw new Ve(Hu)},requireDirectory:()=>{throw new Ve(pc)},stringWidth:(e)=>{return[...e].length},y18n:hc({directory:mc(hr,"../../../locales"),updateFiles:!1})};function Rt(e,t,n,o){n.assert.notStrictEqual(e,t,o)}function ki(e,t){t.assert.strictEqual(typeof e,"string")}function Fo(e){return Object.keys(e)}function Ke(e){return!!e&&!!e.then&&typeof e.then==="function"}function zn(e){let n=e.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),o=/\.*[\][<>]/g,r=n.shift();if(!r)throw Error(`No command found in: ${e}`);let i={cmd:r.replace(o,""),demanded:[],optional:[]};return n.forEach((s,c)=>{let u=!1;if(s=s.replace(/\s/g,""),/\.+[\]>]/.test(s)&&c===n.length-1)u=!0;if(/^\[/.test(s))i.optional.push({cmd:s.replace(o,"").split("|"),variadic:u});else i.demanded.push({cmd:s.replace(o,"").split("|"),variadic:u})}),i}var Uu=["first","second","third","fourth","fifth","sixth"];function we(e,t,n){function o(){return typeof e==="object"?[{demanded:[],optional:[]},e,t]:[zn(`cmd ${e}`),t,n]}try{let r=0,[i,s,c]=o(),u=[].slice.call(s);while(u.length&&u[u.length-1]===void 0)u.pop();let f=c||u.length;if(f<i.demanded.length)throw new Ve(`Not enough arguments provided. Expected ${i.demanded.length} but received ${u.length}.`);let m=i.demanded.length+i.optional.length;if(f>m)throw new Ve(`Too many arguments provided. Expected max ${m} but received ${f}.`);i.demanded.forEach((l)=>{let p=u.shift(),R=gc(p);if(l.cmd.filter((d)=>d===R||d==="*").length===0)wc(R,l.cmd,r);r+=1}),i.optional.forEach((l)=>{if(u.length===0)return;let p=u.shift(),R=gc(p);if(l.cmd.filter((d)=>d===R||d==="*").length===0)wc(R,l.cmd,r);r+=1})}catch(r){console.warn(r.stack)}}function gc(e){if(Array.isArray(e))return"array";else if(e===null)return"null";return typeof e}function wc(e,t,n){throw new Ve(`Invalid ${Uu[n]||"manyith"} argument. Expected ${t.join(" or ")} but received ${e}.`)}class Hi{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,t,n=!0,o=!1){if(we("<array|function> [boolean] [boolean] [boolean]",[e,t,n],arguments.length),Array.isArray(e)){for(let r=0;r<e.length;r++){if(typeof e[r]!=="function")throw Error("middleware must be a function");let i=e[r];i.applyBeforeValidation=t,i.global=n}Array.prototype.push.apply(this.globalMiddleware,e)}else if(typeof e==="function"){let r=e;r.applyBeforeValidation=t,r.global=n,r.mutates=o,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,t){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((o)=>{let r=[...n[t]||[],t];if(!o.option)return!0;else return!r.includes(o.option)}),e.option=t,this.addMiddleware(e,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let e=this.frozens.pop();if(e!==void 0)this.globalMiddleware=e}reset(){this.globalMiddleware=this.globalMiddleware.filter((e)=>e.global)}}function xc(e){if(!e)return[];return e.map((t)=>{return t.applyBeforeValidation=!1,t})}function uo(e,t,n,o){return n.reduce((r,i)=>{if(i.applyBeforeValidation!==o)return r;if(i.mutates){if(i.applied)return r;i.applied=!0}if(Ke(r))return r.then((s)=>Promise.all([s,i(s,t)])).then(([s,c])=>Object.assign(s,c));else{let s=i(r,t);return Ke(s)?s.then((c)=>Object.assign(r,c)):Object.assign(r,s)}},e)}function ho(e,t,n=(o)=>{throw o}){try{let o=Ju(e)?e():e;return Ke(o)?o.then((r)=>t(r)):t(o)}catch(o){return n(o)}}function Ju(e){return typeof e==="function"}function zi(e){for(let t=0,n=Object.keys(En.cache),o;t<n.length;t++)if(o=En.cache[n[t]],o.exports===e)return o;return null}var Io=/(^\*)|(^\$0)/;class vc{constructor(e,t,n,o){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=o,this.usage=e,this.globalMiddleware=n,this.validation=t}addDirectory(e,t,n,o){if(o=o||{},typeof o.recurse!=="boolean")o.recurse=!1;if(!Array.isArray(o.extensions))o.extensions=["js"];let r=typeof o.visit==="function"?o.visit:(i)=>i;o.visit=(i,s,c)=>{let u=r(i,s,c);if(u){if(this.requireCache.has(s))return u;else this.requireCache.add(s);this.addHandler(u)}return u},this.shim.requireDirectory({require:t,filename:n},e,o)}addHandler(e,t,n,o,r,i){let s=[],c=xc(r);if(o=o||(()=>{}),Array.isArray(e))if(Vu(e))[e,...s]=e;else for(let u of e)this.addHandler(u);else if(qu(e)){let u=Array.isArray(e.command)||typeof e.command==="string"?e.command:this.moduleName(e);if(e.aliases)u=[].concat(u).concat(e.aliases);this.addHandler(u,this.extractDesc(e),e.builder,e.handler,e.middlewares,e.deprecated);return}else if(bc(n)){this.addHandler([e].concat(s),t,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof e==="string"){let u=zn(e);s=s.map((l)=>zn(l).cmd);let f=!1,m=[u.cmd].concat(s).filter((l)=>{if(Io.test(l))return f=!0,!1;return!0});if(m.length===0&&f)m.push("$0");if(f)u.cmd=m[0],s=m.slice(1),e=e.replace(Io,u.cmd);if(s.forEach((l)=>{this.aliasMap[l]=u.cmd}),t!==!1)this.usage.command(e,t,f,s,i);if(this.handlers[u.cmd]={original:e,description:t,handler:o,builder:n||{},middlewares:c,deprecated:i,demanded:u.demanded,optional:u.optional},f)this.defaultCommand=this.handlers[u.cmd]}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(e,t,n,o,r,i){let s=this.handlers[e]||this.handlers[this.aliasMap[e]]||this.defaultCommand,c=t.getInternalMethods().getContext(),u=c.commands.slice(),f=!e;if(e)c.commands.push(e),c.fullCommands.push(s.original);let m=this.applyBuilderUpdateUsageAndParse(f,s,t,n.aliases,u,o,r,i);return Ke(m)?m.then((l)=>this.applyMiddlewareAndGetResult(f,s,l.innerArgv,c,r,l.aliases,t)):this.applyMiddlewareAndGetResult(f,s,m.innerArgv,c,r,m.aliases,t)}applyBuilderUpdateUsageAndParse(e,t,n,o,r,i,s,c){let u=t.builder,f=n;if(kr(u)){n.getInternalMethods().getUsageInstance().freeze();let m=u(n.getInternalMethods().reset(o),c);if(Ke(m))return m.then((l)=>{return f=$c(l)?l:n,this.parseAndUpdateUsage(e,t,f,r,i,s)})}else if(Ku(u))n.getInternalMethods().getUsageInstance().freeze(),f=n.getInternalMethods().reset(o),Object.keys(t.builder).forEach((m)=>{f.option(m,u[m])});return this.parseAndUpdateUsage(e,t,f,r,i,s)}parseAndUpdateUsage(e,t,n,o,r,i){if(e)n.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(n))n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(o,t),t.description);let s=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,r,i);return Ke(s)?s.then((c)=>({aliases:n.parsed.aliases,innerArgv:c})):{aliases:n.parsed.aliases,innerArgv:s}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&e.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(e,t){let n=Io.test(t.original)?t.original.replace(Io,"").trim():t.original,o=e.filter((r)=>{return!Io.test(r)});return o.push(n),`$0 ${o.join(" ")}`}handleValidationAndGetResult(e,t,n,o,r,i,s,c){if(!i.getInternalMethods().getHasOutput()){let u=i.getInternalMethods().runValidation(r,c,i.parsed.error,e);n=ho(n,(f)=>{return u(f),f})}if(t.handler&&!i.getInternalMethods().getHasOutput()){i.getInternalMethods().setHasOutput();let u=!!i.getOptions().configuration["populate--"];if(i.getInternalMethods().postProcess(n,u,!1,!1),n=uo(n,i,s,!1),n=ho(n,(f)=>{let m=t.handler(f);return Ke(m)?m.then(()=>f):f}),!e)i.getInternalMethods().getUsageInstance().cacheHelpMessage();if(Ke(n)&&!i.getInternalMethods().hasParseCallback())n.catch((f)=>{try{i.getInternalMethods().getUsageInstance().fail(null,f)}catch(m){}})}if(!e)o.commands.pop(),o.fullCommands.pop();return n}applyMiddlewareAndGetResult(e,t,n,o,r,i,s){let c={};if(r)return n;if(!s.getInternalMethods().getHasOutput())c=this.populatePositionals(t,n,o,s);let u=this.globalMiddleware.getMiddleware().slice(0).concat(t.middlewares),f=uo(n,s,u,!0);return Ke(f)?f.then((m)=>this.handleValidationAndGetResult(e,t,m,o,i,s,u,c)):this.handleValidationAndGetResult(e,t,f,o,i,s,u,c)}populatePositionals(e,t,n,o){t._=t._.slice(n.commands.length);let r=e.demanded.slice(0),i=e.optional.slice(0),s={};this.validation.positionalCount(r.length,t._.length);while(r.length){let c=r.shift();this.populatePositional(c,t,s)}while(i.length){let c=i.shift();this.populatePositional(c,t,s)}return t._=n.commands.concat(t._.map((c)=>""+c)),this.postProcessPositionals(t,s,this.cmdToParseOptions(e.original),o),s}populatePositional(e,t,n){let o=e.cmd[0];if(e.variadic)n[o]=t._.splice(0).map(String);else if(t._.length)n[o]=[String(t._.shift())]}cmdToParseOptions(e){let t={array:[],default:{},alias:{},demand:{}},n=zn(e);return n.demanded.forEach((o)=>{let[r,...i]=o.cmd;if(o.variadic)t.array.push(r),t.default[r]=[];t.alias[r]=i,t.demand[r]=!0}),n.optional.forEach((o)=>{let[r,...i]=o.cmd;if(o.variadic)t.array.push(r),t.default[r]=[];t.alias[r]=i}),t}postProcessPositionals(e,t,n,o){let r=Object.assign({},o.getOptions());r.default=Object.assign(n.default,r.default);for(let u of Object.keys(n.alias))r.alias[u]=(r.alias[u]||[]).concat(n.alias[u]);r.array=r.array.concat(n.array),r.config={};let i=[];if(Object.keys(t).forEach((u)=>{t[u].map((f)=>{if(r.configuration["unknown-options-as-args"])r.key[u]=!0;i.push(`--${u}`),i.push(f)})}),!i.length)return;let s=Object.assign({},r.configuration,{"populate--":!1}),c=this.shim.Parser.detailed(i,Object.assign({},r,{configuration:s}));if(c.error)o.getInternalMethods().getUsageInstance().fail(c.error.message,c.error);else{let u=Object.keys(t);Object.keys(t).forEach((f)=>{u.push(...c.aliases[f])}),Object.keys(c.argv).forEach((f)=>{if(u.includes(f)){if(!t[f])t[f]=c.argv[f];if(!this.isInConfigs(o,f)&&!this.isDefaulted(o,f)&&Object.prototype.hasOwnProperty.call(e,f)&&Object.prototype.hasOwnProperty.call(c.argv,f)&&(Array.isArray(e[f])||Array.isArray(c.argv[f])))e[f]=[].concat(e[f],c.argv[f]);else e[f]=c.argv[f]}})}}isDefaulted(e,t){let{default:n}=e.getOptions();return Object.prototype.hasOwnProperty.call(n,t)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(t))}isInConfigs(e,t){let{configObjects:n}=e.getOptions();return n.some((o)=>Object.prototype.hasOwnProperty.call(o,t))||n.some((o)=>Object.prototype.hasOwnProperty.call(o,this.shim.Parser.camelCase(t)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){let n=Io.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");e.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}let t=this.defaultCommand.builder;if(kr(t))return t(e,!0);else if(!bc(t))Object.keys(t).forEach((n)=>{e.option(n,t[n])});return}moduleName(e){let t=zi(e);if(!t)throw Error(`No command name given for module: ${this.shim.inspect(e)}`);return this.commandFromFilename(t.filename)}commandFromFilename(e){return this.shim.path.basename(e,this.shim.path.extname(e))}extractDesc({describe:e,description:t,desc:n}){for(let o of[e,t,n]){if(typeof o==="string"||o===!1)return o;Rt(o,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let e=this.frozens.pop();Rt(e,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=e}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function Cc(e,t,n,o){return new vc(e,t,n,o)}function bc(e){return typeof e==="object"&&!!e.builder&&typeof e.handler==="function"}function Vu(e){return e.every((t)=>typeof t==="string")}function kr(e){return typeof e==="function"}function Ku(e){return typeof e==="object"}function qu(e){return typeof e==="object"&&!Array.isArray(e)}function Un(e={},t=()=>!0){let n={};return Fo(e).forEach((o)=>{if(t(o,e[o]))n[o]=e[o]}),n}function Jn(e){if(typeof process>"u")return;[process.stdout,process.stderr].forEach((t)=>{let n=t;if(n._handle&&n.isTTY&&typeof n._handle.setBlocking==="function")n._handle.setBlocking(e)})}function Xu(e){return typeof e==="boolean"}function Sc(e,t){let n=t.y18n.__,o={},r=[];o.failFn=function(F){r.push(F)};let i=null,s=null,c=!0;o.showHelpOnFail=function(F=!0,N){let[K,k]=typeof F==="string"?[!0,F]:[F,N];if(e.getInternalMethods().isGlobalContext())s=k;return i=k,c=K,o};let u=!1;o.fail=function(F,N){let K=e.getInternalMethods().getLoggerInstance();if(r.length)for(let k=r.length-1;k>=0;--k){let ge=r[k];if(Xu(ge)){if(N)throw N;else if(F)throw Error(F)}else ge(F,N,o)}else{if(e.getExitProcess())Jn(!0);if(!u){if(u=!0,c)e.showHelp("error"),K.error();if(F||N)K.error(F||N);let k=i||s;if(k){if(F||N)K.error("");K.error(k)}}if(N=N||new Ve(F),e.getExitProcess())return e.exit(1);else if(e.getInternalMethods().hasParseCallback())return e.exit(1,N);else throw N}};let f=[],m=!1;o.usage=(G,F)=>{if(G===null)return m=!0,f=[],o;return m=!1,f.push([G,F||""]),o},o.getUsage=()=>{return f},o.getUsageDisabled=()=>{return m},o.getPositionalGroupName=()=>{return n("Positionals:")};let l=[];o.example=(G,F)=>{l.push([G,F||""])};let p=[];o.command=function(F,N,K,k,ge=!1){if(K)p=p.map((re)=>{return re[2]=!1,re});p.push([F,N||"",K,k,ge])},o.getCommands=()=>p;let R={};o.describe=function(F,N){if(Array.isArray(F))F.forEach((K)=>{o.describe(K,N)});else if(typeof F==="object")Object.keys(F).forEach((K)=>{o.describe(K,F[K])});else R[F]=N},o.getDescriptions=()=>R;let M=[];o.epilog=(G)=>{M.push(G)};let d=!1,b;o.wrap=(G)=>{d=!0,b=G},o.getWrap=()=>{if(t.getEnv("YARGS_DISABLE_WRAP"))return null;if(!d)b=H(),d=!0;return b};let y="__yargsString__:";o.deferY18nLookup=(G)=>y+G,o.help=function(){if(E)return E;P();let F=e.customScriptName?e.$0:t.path.basename(e.$0),N=e.getDemandedOptions(),K=e.getDemandedCommands(),k=e.getDeprecatedOptions(),ge=e.getGroups(),re=e.getOptions(),me=[];me=me.concat(Object.keys(R)),me=me.concat(Object.keys(N)),me=me.concat(Object.keys(K)),me=me.concat(Object.keys(re.default)),me=me.filter(V),me=Object.keys(me.reduce((J,_)=>{if(_!=="_")J[_]=!0;return J},{}));let x=o.getWrap(),v=t.cliui({width:x,wrap:!!x});if(!m){if(f.length)f.forEach((J)=>{if(v.div({text:`${J[0].replace(/\$0/g,F)}`}),J[1])v.div({text:`${J[1]}`,padding:[1,0,0,0]})}),v.div();else if(p.length){let J=null;if(K._)J=`${F} <${n("command")}>
|
|
163
|
+
`;else J=`${F} [${n("command")}]
|
|
164
|
+
`;v.div(`${J}`)}}if(p.length>1||p.length===1&&!p[0][2]){v.div(n("Commands:"));let J=e.getInternalMethods().getContext(),_=J.commands.length?`${J.commands.join(" ")} `:"";if(e.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)p=p.sort((fe,pe)=>fe[0].localeCompare(pe[0]));let Me=F?`${F} `:"";p.forEach((fe)=>{let pe=`${Me}${_}${fe[0].replace(/^\$0 ?/,"")}`;v.span({text:pe,padding:[0,2,0,2],width:S(p,x,`${F}${_}`)+4},{text:fe[1]});let De=[];if(fe[2])De.push(`[${n("default")}]`);if(fe[3]&&fe[3].length)De.push(`[${n("aliases:")} ${fe[3].join(", ")}]`);if(fe[4])if(typeof fe[4]==="string")De.push(`[${n("deprecated: %s",fe[4])}]`);else De.push(`[${n("deprecated")}]`);if(De.length)v.div({text:De.join(" "),padding:[0,0,0,2],align:"right"});else v.div()}),v.div()}let A=(Object.keys(re.alias)||[]).concat(Object.keys(e.parsed.newAliases)||[]);me=me.filter((J)=>!e.parsed.newAliases[J]&&A.every((_)=>(re.alias[_]||[]).indexOf(J)===-1));let B=n("Options:");if(!ge[B])ge[B]=[];I(me,re.alias,ge,B);let D=(J)=>/^--/.test(Hr(J)),z=Object.keys(ge).filter((J)=>ge[J].length>0).map((J)=>{let _=ge[J].filter(V).map((Me)=>{if(A.includes(Me))return Me;for(let fe=0,pe;(pe=A[fe])!==void 0;fe++)if((re.alias[pe]||[]).includes(Me))return pe;return Me});return{groupName:J,normalizedKeys:_}}).filter(({normalizedKeys:J})=>J.length>0).map(({groupName:J,normalizedKeys:_})=>{let Me=_.reduce((fe,pe)=>{return fe[pe]=[pe].concat(re.alias[pe]||[]).map((De)=>{if(J===o.getPositionalGroupName())return De;else return(/^[0-9]$/.test(De)?re.boolean.includes(pe)?"-":"--":De.length>1?"--":"-")+De}).sort((De,Ce)=>D(De)===D(Ce)?0:D(De)?1:-1).join(", "),fe},{});return{groupName:J,normalizedKeys:_,switches:Me}});if(z.filter(({groupName:J})=>J!==o.getPositionalGroupName()).some(({normalizedKeys:J,switches:_})=>!J.every((Me)=>D(_[Me]))))z.filter(({groupName:J})=>J!==o.getPositionalGroupName()).forEach(({normalizedKeys:J,switches:_})=>{J.forEach((Me)=>{if(D(_[Me]))_[Me]=Zu(_[Me],4)})});if(z.forEach(({groupName:J,normalizedKeys:_,switches:Me})=>{v.div(J),_.forEach((fe)=>{let pe=Me[fe],De=R[fe]||"",Ce=null;if(De.includes(y))De=n(De.substring(y.length));if(re.boolean.includes(fe))Ce=`[${n("boolean")}]`;if(re.count.includes(fe))Ce=`[${n("count")}]`;if(re.string.includes(fe))Ce=`[${n("string")}]`;if(re.normalize.includes(fe))Ce=`[${n("string")}]`;if(re.array.includes(fe))Ce=`[${n("array")}]`;if(re.number.includes(fe))Ce=`[${n("number")}]`;let O=(L)=>typeof L==="string"?`[${n("deprecated: %s",L)}]`:`[${n("deprecated")}]`,a=[fe in k?O(k[fe]):null,Ce,fe in N?`[${n("required")}]`:null,re.choices&&re.choices[fe]?`[${n("choices:")} ${o.stringifiedValues(re.choices[fe])}]`:null,T(re.default[fe],re.defaultDescription[fe])].filter(Boolean).join(" ");v.span({text:Hr(pe),padding:[0,2,0,2+Pc(pe)],width:S(Me,x)+4},De);let w=e.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;if(a&&!w)v.div({text:a,padding:[0,0,0,2],align:"right"});else v.div()}),v.div()}),l.length)v.div(n("Examples:")),l.forEach((J)=>{J[0]=J[0].replace(/\$0/g,F)}),l.forEach((J)=>{if(J[1]==="")v.div({text:J[0],padding:[0,2,0,2]});else v.div({text:J[0],padding:[0,2,0,2],width:S(l,x)+4},{text:J[1]})}),v.div();if(M.length>0){let J=M.map((_)=>_.replace(/\$0/g,F)).join(`
|
|
165
|
+
`);v.div(`${J}
|
|
166
|
+
`)}return v.toString().replace(/\s*$/,"")};function S(G,F,N){let K=0;if(!Array.isArray(G))G=Object.values(G).map((k)=>[k]);if(G.forEach((k)=>{K=Math.max(t.stringWidth(N?`${N} ${Hr(k[0])}`:Hr(k[0]))+Pc(k[0]),K)}),F)K=Math.min(K,parseInt((F*0.5).toString(),10));return K}function P(){let G=e.getDemandedOptions(),F=e.getOptions();(Object.keys(F.alias)||[]).forEach((N)=>{F.alias[N].forEach((K)=>{if(R[K])o.describe(N,R[K]);if(K in G)e.demandOption(N,G[K]);if(F.boolean.includes(K))e.boolean(N);if(F.count.includes(K))e.count(N);if(F.string.includes(K))e.string(N);if(F.normalize.includes(K))e.normalize(N);if(F.array.includes(K))e.array(N);if(F.number.includes(K))e.number(N)})})}let E;o.cacheHelpMessage=function(){E=this.help()},o.clearCachedHelpMessage=function(){E=void 0},o.hasCachedHelpMessage=function(){return!!E};function I(G,F,N,K){let k=[],ge=null;return Object.keys(N).forEach((re)=>{k=k.concat(N[re])}),G.forEach((re)=>{if(ge=[re].concat(F[re]),!ge.some((me)=>k.indexOf(me)!==-1))N[K].push(re)}),k}function V(G){return e.getOptions().hiddenOptions.indexOf(G)<0||e.parsed.argv[e.getOptions().showHiddenOpt]}o.showHelp=(G)=>{let F=e.getInternalMethods().getLoggerInstance();if(!G)G="error";(typeof G==="function"?G:F[G])(o.help())},o.functionDescription=(G)=>{return["(",G.name?t.Parser.decamelize(G.name,"-"):n("generated-value"),")"].join("")},o.stringifiedValues=function(F,N){let K="",k=N||", ",ge=[].concat(F);if(!F||!ge.length)return K;return ge.forEach((re)=>{if(K.length)K+=k;K+=JSON.stringify(re)}),K};function T(G,F){let N=`[${n("default:")} `;if(G===void 0&&!F)return null;if(F)N+=F;else switch(typeof G){case"string":N+=`"${G}"`;break;case"object":N+=JSON.stringify(G);break;default:N+=G}return`${N}]`}function H(){if(t.process.stdColumns)return Math.min(80,t.process.stdColumns);else return 80}let Q=null;o.version=(G)=>{Q=G},o.showVersion=(G)=>{let F=e.getInternalMethods().getLoggerInstance();if(!G)G="error";(typeof G==="function"?G:F[G])(Q)},o.reset=function(F){return i=null,u=!1,f=[],m=!1,M=[],l=[],p=[],R=Un(R,(N)=>!F[N]),o};let he=[];return o.freeze=function(){he.push({failMessage:i,failureOutput:u,usages:f,usageDisabled:m,epilogs:M,examples:l,commands:p,descriptions:R})},o.unfreeze=function(F=!1){let N=he.pop();if(!N)return;if(F)R={...N.descriptions,...R},p=[...N.commands,...p],f=[...N.usages,...f],l=[...N.examples,...l],M=[...N.epilogs,...M];else({failMessage:i,failureOutput:u,usages:f,usageDisabled:m,epilogs:M,examples:l,commands:p,descriptions:R}=N)},o}function Ui(e){return typeof e==="object"}function Zu(e,t){return Ui(e)?{text:e.text,indentation:e.indentation+t}:{text:e,indentation:t}}function Pc(e){return Ui(e)?e.indentation:0}function Hr(e){return Ui(e)?e.text:e}var Ec=`###-begin-{{app_name}}-completions-###
|
|
168
167
|
#
|
|
169
168
|
# yargs command completion script
|
|
170
169
|
#
|
|
@@ -192,7 +191,7 @@ _{{app_name}}_yargs_completions()
|
|
|
192
191
|
}
|
|
193
192
|
complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}
|
|
194
193
|
###-end-{{app_name}}-completions-###
|
|
195
|
-
`,
|
|
194
|
+
`,Mc=`#compdef {{app_name}}
|
|
196
195
|
###-begin-{{app_name}}-completions-###
|
|
197
196
|
#
|
|
198
197
|
# yargs command completion script
|
|
@@ -211,11 +210,11 @@ _{{app_name}}_yargs_completions()
|
|
|
211
210
|
}
|
|
212
211
|
compdef _{{app_name}}_yargs_completions {{app_name}}
|
|
213
212
|
###-end-{{app_name}}-completions-###
|
|
214
|
-
`;class
|
|
215
|
-
${
|
|
216
|
-
`)}`:"";
|
|
217
|
-
${
|
|
218
|
-
`;d.forEach((x)=>{g+=x}),e.fail(g)}};let f={};i.conflicts=function(u,d){if(I("<string|object> [array|string]",[u,d],arguments.length),typeof u==="object")Object.keys(u).forEach((g)=>{i.conflicts(g,u[g])});else{if(t.global(u),!f[u])f[u]=[];if(Array.isArray(d))d.forEach((g)=>i.conflicts(u,g));else f[u].push(d)}},i.getConflicting=()=>f,i.conflicting=function(u){if(Object.keys(u).forEach((d)=>{if(f[d])f[d].forEach((g)=>{if(g&&u[d]!==void 0&&u[g]!==void 0)e.fail(n("Arguments %s and %s are mutually exclusive",d,g))})}),t.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(f).forEach((d)=>{f[d].forEach((g)=>{if(g&&u[o.Parser.camelCase(d)]!==void 0&&u[o.Parser.camelCase(g)]!==void 0)e.fail(n("Arguments %s and %s are mutually exclusive",d,g))})})},i.recommendCommands=function(u,d){d=d.sort((b,S)=>S.length-b.length);let x=null,m=1/0;for(let b=0,S;(S=d[b])!==void 0;b++){let E=mi(u,S);if(E<=3&&E<m)m=E,x=S}if(x)e.fail(n("Did you mean %s?",x))},i.reset=function(u){return s=ye(s,(d)=>!u[d]),f=ye(f,(d)=>!u[d]),i};let a=[];return i.freeze=function(){a.push({implied:s,conflicting:f})},i.unfreeze=function(){let u=a.pop();Bt(u,void 0,o),{implied:s,conflicting:f}=u},i}var qn=[],Do;function Fo(t,e,o,n){Do=n;let r={};if(Object.prototype.hasOwnProperty.call(t,"extends")){if(typeof t.extends!=="string")return r;let i=/\.json|\..*rc$/.test(t.extends),s=null;if(!i)try{s=he.resolve(t.extends)}catch(c){return t}else s=$f(e,t.extends);Cf(s),qn.push(s),r=i?JSON.parse(Do.readFileSync(s,"utf8")):he(t.extends),delete t.extends,r=Fo(r,Do.path.dirname(s),o,Do)}return qn=[],o?wi(r,t):Object.assign({},r,t)}function Cf(t){if(qn.indexOf(t)>-1)throw new lt(`Circular extended configurations: '${t}'.`)}function $f(t,e){return Do.path.resolve(t,e)}function wi(t,e){let o={};function n(r){return r&&typeof r==="object"&&!Array.isArray(r)}Object.assign(o,t);for(let r of Object.keys(e))if(n(e[r])&&n(o[r]))o[r]=wi(t[r],e[r]);else o[r]=e[r];return o}var j=function(t,e,o,n,r){if(n==="m")throw TypeError("Private method is not writable");if(n==="a"&&!r)throw TypeError("Private accessor was defined without a setter");if(typeof e==="function"?t!==e||!r:!e.has(t))throw TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?r.call(t,o):r?r.value=o:e.set(t,o),o},p=function(t,e,o,n){if(o==="a"&&!n)throw TypeError("Private accessor was defined without a getter");if(typeof e==="function"?t!==e||!n:!e.has(t))throw TypeError("Cannot read private member from an object whose class did not declare it");return o==="m"?n:o==="a"?n.call(t):n?n.value:e.get(t)},bt,ke,Bo,kt,jt,Qo,Re,ze,Yo,zt,tn,vt,oe,_t,Ut,en,ao,yt,J,on,nn,Tt,ve,fo,Ue,Me,rn,K,Ve,Ke,qe,X,sn,ne,gt;function Ti(t){return(e=[],o=t.process.cwd(),n)=>{let r=new Gi(e,o,n,t);return Object.defineProperty(r,"argv",{get:()=>{return r.parse()},enumerable:!0}),r.help(),r.version(),r}}var bi=Symbol("copyDoubleDash"),Ci=Symbol("copyDoubleDash"),Xn=Symbol("deleteFromParserHintObject"),$i=Symbol("emitWarning"),Si=Symbol("freeze"),Pi=Symbol("getDollarZero"),Xe=Symbol("getParserConfiguration"),yi=Symbol("getUsageConfiguration"),Zn=Symbol("guessLocale"),Ei=Symbol("guessVersion"),Ri=Symbol("parsePositionalNumbers"),Qn=Symbol("pkgUp"),Oe=Symbol("populateParserHintArray"),lo=Symbol("populateParserHintSingleValueDictionary"),Yn=Symbol("populateParserHintArrayDictionary"),tr=Symbol("populateParserHintDictionary"),er=Symbol("sanitizeKey"),or=Symbol("setKey"),nr=Symbol("unfreeze"),Mi=Symbol("validateAsync"),Oi=Symbol("getCommandInstance"),Wi=Symbol("getContext"),Di=Symbol("getHasOutput"),Fi=Symbol("getLoggerInstance"),Bi=Symbol("getParseContext"),Li=Symbol("getUsageInstance"),Ai=Symbol("getValidationInstance"),cn=Symbol("hasParseCallback"),Ii=Symbol("isGlobalContext"),Ze=Symbol("postProcess"),ji=Symbol("rebase"),rr=Symbol("reset"),Lo=Symbol("runYargsParserAndExecuteCommands"),ir=Symbol("runValidation"),_i=Symbol("setHasOutput"),Qe=Symbol("kTrackManuallySetKeys");class Gi{constructor(t=[],e,o,n){this.customScriptName=!1,this.parsed=!1,bt.set(this,void 0),ke.set(this,void 0),Bo.set(this,{commands:[],fullCommands:[]}),kt.set(this,null),jt.set(this,null),Qo.set(this,"show-hidden"),Re.set(this,null),ze.set(this,!0),Yo.set(this,{}),zt.set(this,!0),tn.set(this,[]),vt.set(this,void 0),oe.set(this,{}),_t.set(this,!1),Ut.set(this,null),en.set(this,!0),ao.set(this,void 0),yt.set(this,""),J.set(this,void 0),on.set(this,void 0),nn.set(this,{}),Tt.set(this,null),ve.set(this,null),fo.set(this,{}),Ue.set(this,{}),Me.set(this,void 0),rn.set(this,!1),K.set(this,void 0),Ve.set(this,!1),Ke.set(this,!1),qe.set(this,!1),X.set(this,void 0),sn.set(this,{}),ne.set(this,null),gt.set(this,void 0),j(this,K,n,"f"),j(this,Me,t,"f"),j(this,ke,e,"f"),j(this,on,o,"f"),j(this,vt,new Un(this),"f"),this.$0=this[Pi](),this[rr](),j(this,bt,p(this,bt,"f"),"f"),j(this,X,p(this,X,"f"),"f"),j(this,gt,p(this,gt,"f"),"f"),j(this,J,p(this,J,"f"),"f"),p(this,J,"f").showHiddenOpt=p(this,Qo,"f"),j(this,ao,this[Ci](),"f")}addHelpOpt(t,e){if(I("[string|boolean] [string]",[t,e],arguments.length),p(this,Ut,"f"))this[Xn](p(this,Ut,"f")),j(this,Ut,null,"f");if(t===!1&&e===void 0)return this;return j(this,Ut,typeof t==="string"?t:"help","f"),this.boolean(p(this,Ut,"f")),this.describe(p(this,Ut,"f"),e||p(this,X,"f").deferY18nLookup("Show help")),this}help(t,e){return this.addHelpOpt(t,e)}addShowHiddenOpt(t,e){if(I("[string|boolean] [string]",[t,e],arguments.length),t===!1&&e===void 0)return this;let o=typeof t==="string"?t:p(this,Qo,"f");return this.boolean(o),this.describe(o,e||p(this,X,"f").deferY18nLookup("Show hidden options")),p(this,J,"f").showHiddenOpt=o,this}showHidden(t,e){return this.addShowHiddenOpt(t,e)}alias(t,e){return I("<object|string|array> [string|array]",[t,e],arguments.length),this[Yn](this.alias.bind(this),"alias",t,e),this}array(t){return I("<array|string>",[t],arguments.length),this[Oe]("array",t),this[Qe](t),this}boolean(t){return I("<array|string>",[t],arguments.length),this[Oe]("boolean",t),this[Qe](t),this}check(t,e){return I("<function> [boolean]",[t,e],arguments.length),this.middleware((o,n)=>{return Je(()=>{return t(o,n.getOptions())},(r)=>{if(!r)p(this,X,"f").fail(p(this,K,"f").y18n.__("Argument check failed: %s",t.toString()));else if(typeof r==="string"||r instanceof Error)p(this,X,"f").fail(r.toString(),r);return o},(r)=>{return p(this,X,"f").fail(r.message?r.message:r.toString(),r),o})},!1,e),this}choices(t,e){return I("<object|string|array> [string|array]",[t,e],arguments.length),this[Yn](this.choices.bind(this),"choices",t,e),this}coerce(t,e){if(I("<object|string|array> [function]",[t,e],arguments.length),Array.isArray(t)){if(!e)throw new lt("coerce callback must be provided");for(let o of t)this.coerce(o,e);return this}else if(typeof t==="object"){for(let o of Object.keys(t))this.coerce(o,t[o]);return this}if(!e)throw new lt("coerce callback must be provided");return p(this,J,"f").key[t]=!0,p(this,vt,"f").addCoerceMiddleware((o,n)=>{let r;if(!Object.prototype.hasOwnProperty.call(o,t))return o;return Je(()=>{return r=n.getAliases(),e(o[t])},(s)=>{o[t]=s;let c=n.getInternalMethods().getParserConfiguration()["strip-aliased"];if(r[t]&&c!==!0)for(let f of r[t])o[f]=s;return o},(s)=>{throw new lt(s.message)})},t),this}conflicts(t,e){return I("<string|object> [string|array]",[t,e],arguments.length),p(this,gt,"f").conflicts(t,e),this}config(t="config",e,o){if(I("[object|string] [string|function] [function]",[t,e,o],arguments.length),typeof t==="object"&&!Array.isArray(t))return t=Fo(t,p(this,ke,"f"),this[Xe]()["deep-merge-config"]||!1,p(this,K,"f")),p(this,J,"f").configObjects=(p(this,J,"f").configObjects||[]).concat(t),this;if(typeof e==="function")o=e,e=void 0;return this.describe(t,e||p(this,X,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(t)?t:[t]).forEach((n)=>{p(this,J,"f").config[n]=o||!0}),this}completion(t,e,o){if(I("[string] [string|boolean|function] [function]",[t,e,o],arguments.length),typeof e==="function")o=e,e=void 0;if(j(this,jt,t||p(this,jt,"f")||"completion","f"),!e&&e!==!1)e="generate completion script";if(this.command(p(this,jt,"f"),e),o)p(this,kt,"f").registerFunction(o);return this}command(t,e,o,n,r,i){return I("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[t,e,o,n,r,i],arguments.length),p(this,bt,"f").addHandler(t,e,o,n,r,i),this}commands(t,e,o,n,r,i){return this.command(t,e,o,n,r,i)}commandDir(t,e){I("<string> [object]",[t,e],arguments.length);let o=p(this,on,"f")||p(this,K,"f").require;return p(this,bt,"f").addDirectory(t,o,p(this,K,"f").getCallerFile(),e),this}count(t){return I("<array|string>",[t],arguments.length),this[Oe]("count",t),this[Qe](t),this}default(t,e,o){if(I("<object|string|array> [*] [string]",[t,e,o],arguments.length),o)vn(t,p(this,K,"f")),p(this,J,"f").defaultDescription[t]=o;if(typeof e==="function"){if(vn(t,p(this,K,"f")),!p(this,J,"f").defaultDescription[t])p(this,J,"f").defaultDescription[t]=p(this,X,"f").functionDescription(e);e=e.call()}return this[lo](this.default.bind(this),"default",t,e),this}defaults(t,e,o){return this.default(t,e,o)}demandCommand(t=1,e,o,n){if(I("[number] [number|string] [string|null|undefined] [string|null|undefined]",[t,e,o,n],arguments.length),typeof e!=="number")o=e,e=1/0;return this.global("_",!1),p(this,J,"f").demandedCommands._={min:t,max:e,minMsg:o,maxMsg:n},this}demand(t,e,o){if(Array.isArray(e))e.forEach((n)=>{Bt(o,!0,p(this,K,"f")),this.demandOption(n,o)}),e=1/0;else if(typeof e!=="number")o=e,e=1/0;if(typeof t==="number")Bt(o,!0,p(this,K,"f")),this.demandCommand(t,e,o,o);else if(Array.isArray(t))t.forEach((n)=>{Bt(o,!0,p(this,K,"f")),this.demandOption(n,o)});else if(typeof o==="string")this.demandOption(t,o);else if(o===!0||typeof o>"u")this.demandOption(t);return this}demandOption(t,e){return I("<object|string|array> [string]",[t,e],arguments.length),this[lo](this.demandOption.bind(this),"demandedOptions",t,e),this}deprecateOption(t,e){return I("<string> [string|boolean]",[t,e],arguments.length),p(this,J,"f").deprecatedOptions[t]=e,this}describe(t,e){return I("<object|string|array> [string]",[t,e],arguments.length),this[or](t,!0),p(this,X,"f").describe(t,e),this}detectLocale(t){return I("<boolean>",[t],arguments.length),j(this,ze,t,"f"),this}env(t){if(I("[string|boolean]",[t],arguments.length),t===!1)delete p(this,J,"f").envPrefix;else p(this,J,"f").envPrefix=t||"";return this}epilogue(t){return I("<string>",[t],arguments.length),p(this,X,"f").epilog(t),this}epilog(t){return this.epilogue(t)}example(t,e){if(I("<string|array> [string]",[t,e],arguments.length),Array.isArray(t))t.forEach((o)=>this.example(...o));else p(this,X,"f").example(t,e);return this}exit(t,e){if(j(this,_t,!0,"f"),j(this,Re,e,"f"),p(this,zt,"f"))p(this,K,"f").process.exit(t)}exitProcess(t=!0){return I("[boolean]",[t],arguments.length),j(this,zt,t,"f"),this}fail(t){if(I("<function|boolean>",[t],arguments.length),typeof t==="boolean"&&t!==!1)throw new lt("Invalid first argument. Expected function or boolean 'false'");return p(this,X,"f").failFn(t),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(t,e){if(I("<array> [function]",[t,e],arguments.length),!e)return new Promise((o,n)=>{p(this,kt,"f").getCompletion(t,(r,i)=>{if(r)n(r);else o(i)})});else return p(this,kt,"f").getCompletion(t,e)}getDemandedOptions(){return I([],0),p(this,J,"f").demandedOptions}getDemandedCommands(){return I([],0),p(this,J,"f").demandedCommands}getDeprecatedOptions(){return I([],0),p(this,J,"f").deprecatedOptions}getDetectLocale(){return p(this,ze,"f")}getExitProcess(){return p(this,zt,"f")}getGroups(){return Object.assign({},p(this,oe,"f"),p(this,Ue,"f"))}getHelp(){if(j(this,_t,!0,"f"),!p(this,X,"f").hasCachedHelpMessage()){if(!this.parsed){let e=this[Lo](p(this,Me,"f"),void 0,void 0,0,!0);if(ht(e))return e.then(()=>{return p(this,X,"f").help()})}let t=p(this,bt,"f").runDefaultBuilderOn(this);if(ht(t))return t.then(()=>{return p(this,X,"f").help()})}return Promise.resolve(p(this,X,"f").help())}getOptions(){return p(this,J,"f")}getStrict(){return p(this,Ve,"f")}getStrictCommands(){return p(this,Ke,"f")}getStrictOptions(){return p(this,qe,"f")}global(t,e){if(I("<string|array> [boolean]",[t,e],arguments.length),t=[].concat(t),e!==!1)p(this,J,"f").local=p(this,J,"f").local.filter((o)=>t.indexOf(o)===-1);else t.forEach((o)=>{if(!p(this,J,"f").local.includes(o))p(this,J,"f").local.push(o)});return this}group(t,e){I("<string|array> <string>",[t,e],arguments.length);let o=p(this,Ue,"f")[e]||p(this,oe,"f")[e];if(p(this,Ue,"f")[e])delete p(this,Ue,"f")[e];let n={};return p(this,oe,"f")[e]=(o||[]).concat(t).filter((r)=>{if(n[r])return!1;return n[r]=!0}),this}hide(t){return I("<string>",[t],arguments.length),p(this,J,"f").hiddenOptions.push(t),this}implies(t,e){return I("<string|object> [number|string|array]",[t,e],arguments.length),p(this,gt,"f").implies(t,e),this}locale(t){if(I("[string]",[t],arguments.length),t===void 0)return this[Zn](),p(this,K,"f").y18n.getLocale();return j(this,ze,!1,"f"),p(this,K,"f").y18n.setLocale(t),this}middleware(t,e,o){return p(this,vt,"f").addMiddleware(t,!!e,o)}nargs(t,e){return I("<string|object|array> [number]",[t,e],arguments.length),this[lo](this.nargs.bind(this),"narg",t,e),this}normalize(t){return I("<array|string>",[t],arguments.length),this[Oe]("normalize",t),this}number(t){return I("<array|string>",[t],arguments.length),this[Oe]("number",t),this[Qe](t),this}option(t,e){if(I("<string|object> [object]",[t,e],arguments.length),typeof t==="object")Object.keys(t).forEach((o)=>{this.options(o,t[o])});else{if(typeof e!=="object")e={};if(this[Qe](t),p(this,ne,"f")&&(t==="version"||(e===null||e===void 0?void 0:e.alias)==="version"))this[$i](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join(`
|
|
219
|
-
`),void 0,"versionWarning");if(
|
|
220
|
-
`,"f");
|
|
221
|
-
`,"f");j(this,yt,p(this,yt,"f")+t.join(" "),"f")}}}[Xn](t){so(p(this,J,"f")).forEach((e)=>{if(((n)=>n==="configObjects")(e))return;let o=p(this,J,"f")[e];if(Array.isArray(o)){if(o.includes(t))o.splice(o.indexOf(t),1)}else if(typeof o==="object")delete o[t]}),delete p(this,X,"f").getDescriptions()[t]}[$i](t,e,o){if(!p(this,Yo,"f")[o])p(this,K,"f").process.emitWarning(t,e),p(this,Yo,"f")[o]=!0}[Si](){p(this,tn,"f").push({options:p(this,J,"f"),configObjects:p(this,J,"f").configObjects.slice(0),exitProcess:p(this,zt,"f"),groups:p(this,oe,"f"),strict:p(this,Ve,"f"),strictCommands:p(this,Ke,"f"),strictOptions:p(this,qe,"f"),completionCommand:p(this,jt,"f"),output:p(this,yt,"f"),exitError:p(this,Re,"f"),hasOutput:p(this,_t,"f"),parsed:this.parsed,parseFn:p(this,Tt,"f"),parseContext:p(this,ve,"f")}),p(this,X,"f").freeze(),p(this,gt,"f").freeze(),p(this,bt,"f").freeze(),p(this,vt,"f").freeze()}[Pi](){let t="",e;if(/\b(node|iojs|electron)(\.exe)?$/.test(p(this,K,"f").process.argv()[0]))e=p(this,K,"f").process.argv().slice(1,2);else e=p(this,K,"f").process.argv().slice(0,1);if(t=e.map((o)=>{let n=this[ji](p(this,ke,"f"),o);return o.match(/^(\/|([a-zA-Z]:)?\\)/)&&n.length<o.length?n:o}).join(" ").trim(),p(this,K,"f").getEnv("_")&&p(this,K,"f").getProcessArgvBin()===p(this,K,"f").getEnv("_"))t=p(this,K,"f").getEnv("_").replace(`${p(this,K,"f").path.dirname(p(this,K,"f").process.execPath())}/`,"");return t}[Xe](){return p(this,nn,"f")}[yi](){return p(this,sn,"f")}[Zn](){if(!p(this,ze,"f"))return;let t=p(this,K,"f").getEnv("LC_ALL")||p(this,K,"f").getEnv("LC_MESSAGES")||p(this,K,"f").getEnv("LANG")||p(this,K,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[Ei](){return this[Qn]().version||"unknown"}[Ri](t){let e=t["--"]?t["--"]:t._;for(let o=0,n;(n=e[o])!==void 0;o++)if(p(this,K,"f").Parser.looksLikeNumber(n)&&Number.isSafeInteger(Math.floor(parseFloat(`${n}`))))e[o]=Number(n);return t}[Qn](t){let e=t||"*";if(p(this,fo,"f")[e])return p(this,fo,"f")[e];let o={};try{let n=t||p(this,K,"f").mainFilename;if(!t&&p(this,K,"f").path.extname(n))n=p(this,K,"f").path.dirname(n);let r=p(this,K,"f").findUp(n,(i,s)=>{if(s.includes("package.json"))return"package.json";else return});Bt(r,void 0,p(this,K,"f")),o=JSON.parse(p(this,K,"f").readFileSync(r,"utf8"))}catch(n){}return p(this,fo,"f")[e]=o||{},p(this,fo,"f")[e]}[Oe](t,e){e=[].concat(e),e.forEach((o)=>{o=this[er](o),p(this,J,"f")[t].push(o)})}[lo](t,e,o,n){this[tr](t,e,o,n,(r,i,s)=>{p(this,J,"f")[r][i]=s})}[Yn](t,e,o,n){this[tr](t,e,o,n,(r,i,s)=>{p(this,J,"f")[r][i]=(p(this,J,"f")[r][i]||[]).concat(s)})}[tr](t,e,o,n,r){if(Array.isArray(o))o.forEach((i)=>{t(i,n)});else if(((i)=>typeof i==="object")(o))for(let i of so(o))t(i,o[i]);else r(e,this[er](o),n)}[er](t){if(t==="__proto__")return"___proto___";return t}[or](t,e){return this[lo](this[or].bind(this),"key",t,e),this}[nr](){var t,e,o,n,r,i,s,c,f,a,h,u;let d=p(this,tn,"f").pop();Bt(d,void 0,p(this,K,"f"));let g;t=this,e=this,o=this,n=this,r=this,i=this,s=this,c=this,f=this,a=this,h=this,u=this,{options:{set value(x){j(t,J,x,"f")}}.value,configObjects:g,exitProcess:{set value(x){j(e,zt,x,"f")}}.value,groups:{set value(x){j(o,oe,x,"f")}}.value,output:{set value(x){j(n,yt,x,"f")}}.value,exitError:{set value(x){j(r,Re,x,"f")}}.value,hasOutput:{set value(x){j(i,_t,x,"f")}}.value,parsed:this.parsed,strict:{set value(x){j(s,Ve,x,"f")}}.value,strictCommands:{set value(x){j(c,Ke,x,"f")}}.value,strictOptions:{set value(x){j(f,qe,x,"f")}}.value,completionCommand:{set value(x){j(a,jt,x,"f")}}.value,parseFn:{set value(x){j(h,Tt,x,"f")}}.value,parseContext:{set value(x){j(u,ve,x,"f")}}.value}=d,p(this,J,"f").configObjects=g,p(this,X,"f").unfreeze(),p(this,gt,"f").unfreeze(),p(this,bt,"f").unfreeze(),p(this,vt,"f").unfreeze()}[Mi](t,e){return Je(e,(o)=>{return t(o),o})}getInternalMethods(){return{getCommandInstance:this[Oi].bind(this),getContext:this[Wi].bind(this),getHasOutput:this[Di].bind(this),getLoggerInstance:this[Fi].bind(this),getParseContext:this[Bi].bind(this),getParserConfiguration:this[Xe].bind(this),getUsageConfiguration:this[yi].bind(this),getUsageInstance:this[Li].bind(this),getValidationInstance:this[Ai].bind(this),hasParseCallback:this[cn].bind(this),isGlobalContext:this[Ii].bind(this),postProcess:this[Ze].bind(this),reset:this[rr].bind(this),runValidation:this[ir].bind(this),runYargsParserAndExecuteCommands:this[Lo].bind(this),setHasOutput:this[_i].bind(this)}}[Oi](){return p(this,bt,"f")}[Wi](){return p(this,Bo,"f")}[Di](){return p(this,_t,"f")}[Fi](){return p(this,ao,"f")}[Bi](){return p(this,ve,"f")||{}}[Li](){return p(this,X,"f")}[Ai](){return p(this,gt,"f")}[cn](){return!!p(this,Tt,"f")}[Ii](){return p(this,en,"f")}[Ze](t,e,o,n){if(o)return t;if(ht(t))return t;if(!e)t=this[bi](t);if(this[Xe]()["parse-positional-numbers"]||this[Xe]()["parse-positional-numbers"]===void 0)t=this[Ri](t);if(n)t=Ne(t,this,p(this,vt,"f").getMiddleware(),!1);return t}[rr](t={}){j(this,J,p(this,J,"f")||{},"f");let e={};e.local=p(this,J,"f").local||[],e.configObjects=p(this,J,"f").configObjects||[];let o={};e.local.forEach((i)=>{o[i]=!0,(t[i]||[]).forEach((s)=>{o[s]=!0})}),Object.assign(p(this,Ue,"f"),Object.keys(p(this,oe,"f")).reduce((i,s)=>{let c=p(this,oe,"f")[s].filter((f)=>!(f in o));if(c.length>0)i[s]=c;return i},{})),j(this,oe,{},"f");let n=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],r=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(n.forEach((i)=>{e[i]=(p(this,J,"f")[i]||[]).filter((s)=>!o[s])}),r.forEach((i)=>{e[i]=ye(p(this,J,"f")[i],(s)=>!o[s])}),e.envPrefix=p(this,J,"f").envPrefix,j(this,J,e,"f"),j(this,X,p(this,X,"f")?p(this,X,"f").reset(o):li(this,p(this,K,"f")),"f"),j(this,gt,p(this,gt,"f")?p(this,gt,"f").reset(o):gi(this,p(this,X,"f"),p(this,K,"f")),"f"),j(this,bt,p(this,bt,"f")?p(this,bt,"f").reset():ci(p(this,X,"f"),p(this,gt,"f"),p(this,vt,"f"),p(this,K,"f")),"f"),!p(this,kt,"f"))j(this,kt,di(this,p(this,X,"f"),p(this,bt,"f"),p(this,K,"f")),"f");return p(this,vt,"f").reset(),j(this,jt,null,"f"),j(this,yt,"","f"),j(this,Re,null,"f"),j(this,_t,!1,"f"),this.parsed=!1,this}[ji](t,e){return p(this,K,"f").path.relative(t,e)}[Lo](t,e,o,n=0,r=!1){let i=!!o||r;t=t||p(this,Me,"f"),p(this,J,"f").__=p(this,K,"f").y18n.__,p(this,J,"f").configuration=this[Xe]();let s=!!p(this,J,"f").configuration["populate--"],c=Object.assign({},p(this,J,"f").configuration,{"populate--":!0}),f=p(this,K,"f").Parser.detailed(t,Object.assign({},p(this,J,"f"),{configuration:{"parse-positional-numbers":!1,...c}})),a=Object.assign(f.argv,p(this,ve,"f")),h=void 0,u=f.aliases,d=!1,g=!1;if(Object.keys(a).forEach((x)=>{if(x===p(this,Ut,"f")&&a[x])d=!0;else if(x===p(this,ne,"f")&&a[x])g=!0}),a.$0=this.$0,this.parsed=f,n===0)p(this,X,"f").clearCachedHelpMessage();try{if(this[Zn](),e)return this[Ze](a,s,!!o,!1);if(p(this,Ut,"f")){if([p(this,Ut,"f")].concat(u[p(this,Ut,"f")]||[]).filter((E)=>E.length>1).includes(""+a._[a._.length-1]))a._.pop(),d=!0}j(this,en,!1,"f");let x=p(this,bt,"f").getCommands(),m=p(this,kt,"f").completionKey in a,b=d||m||r;if(a._.length){if(x.length){let S;for(let E=n||0,y;a._[E]!==void 0;E++)if(y=String(a._[E]),x.includes(y)&&y!==p(this,jt,"f")){let R=p(this,bt,"f").runCommand(y,this,f,E+1,r,d||g||r);return this[Ze](R,s,!!o,!1)}else if(!S&&y!==p(this,jt,"f")){S=y;break}if(!p(this,bt,"f").hasDefaultCommand()&&p(this,rn,"f")&&S&&!b)p(this,gt,"f").recommendCommands(S,x)}if(p(this,jt,"f")&&a._.includes(p(this,jt,"f"))&&!m){if(p(this,zt,"f"))Ee(!0);this.showCompletionScript(),this.exit(0)}}if(p(this,bt,"f").hasDefaultCommand()&&!b){let S=p(this,bt,"f").runCommand(null,this,f,0,r,d||g||r);return this[Ze](S,s,!!o,!1)}if(m){if(p(this,zt,"f"))Ee(!0);t=[].concat(t);let S=t.slice(t.indexOf(`--${p(this,kt,"f").completionKey}`)+1);return p(this,kt,"f").getCompletion(S,(E,y)=>{if(E)throw new lt(E.message);(y||[]).forEach((R)=>{p(this,ao,"f").log(R)}),this.exit(0)}),this[Ze](a,!s,!!o,!1)}if(!p(this,_t,"f")){if(d){if(p(this,zt,"f"))Ee(!0);i=!0,this.showHelp("log"),this.exit(0)}else if(g){if(p(this,zt,"f"))Ee(!0);i=!0,p(this,X,"f").showVersion("log"),this.exit(0)}}if(!i&&p(this,J,"f").skipValidation.length>0)i=Object.keys(a).some((S)=>p(this,J,"f").skipValidation.indexOf(S)>=0&&a[S]===!0);if(!i){if(f.error)throw new lt(f.error.message);if(!m){let S=this[ir](u,{},f.error);if(!o)h=Ne(a,this,p(this,vt,"f").getMiddleware(),!0);if(h=this[Mi](S,h!==null&&h!==void 0?h:a),ht(h)&&!o)h=h.then(()=>{return Ne(a,this,p(this,vt,"f").getMiddleware(),!1)})}}}catch(x){if(x instanceof lt)p(this,X,"f").fail(x.message,x);else throw x}return this[Ze](h!==null&&h!==void 0?h:a,s,!!o,!0)}[ir](t,e,o,n){let r={...this.getDemandedOptions()};return(i)=>{if(o)throw new lt(o.message);p(this,gt,"f").nonOptionCount(i),p(this,gt,"f").requiredArguments(i,r);let s=!1;if(p(this,Ke,"f"))s=p(this,gt,"f").unknownCommands(i);if(p(this,Ve,"f")&&!s)p(this,gt,"f").unknownArguments(i,t,e,!!n);else if(p(this,qe,"f"))p(this,gt,"f").unknownArguments(i,t,{},!1,!1);p(this,gt,"f").limitedChoices(i),p(this,gt,"f").implications(i),p(this,gt,"f").conflicting(i)}}[_i](){j(this,_t,!0,"f")}[Qe](t){if(typeof t==="string")p(this,J,"f").key[t]=!0;else for(let e of t)p(this,J,"f").key[e]=!0}}function ai(t){return!!t&&typeof t.getInternalMethods==="function"}var Sf=Ti(zn),Hi=Sf;import{readFileSync as yp}from"fs";import{join as Ep}from"path";var Rp=JSON.parse(yp(Ep(import.meta.dir,"../../package.json"),"utf-8"));if(process.argv.length===2){let{launchTUI:t}=await Promise.resolve().then(() => (tc(),Ys));await t()}else{let[t,e,o,n,r,i,s,c,f,a,h,u,d,g,x,m,b,S,E,y]=await Promise.all([Promise.resolve().then(() => (fc(),ac)),Promise.resolve().then(() => (hc(),lc)),Promise.resolve().then(() => (dc(),pc)),Promise.resolve().then(() => (xc(),mc)),Promise.resolve().then(() => ($c(),Cc)),Promise.resolve().then(() => (Wc(),Oc)),Promise.resolve().then(() => (Fc(),Dc)),Promise.resolve().then(() => (Ic(),Ac)),Promise.resolve().then(() => (Tc(),_c)),Promise.resolve().then(() => (Nc(),Hc)),Promise.resolve().then(() => (zc(),kc)),Promise.resolve().then(() => (Uc(),vc)),Promise.resolve().then(() => (Kc(),Vc)),Promise.resolve().then(() => (Xc(),qc)),Promise.resolve().then(() => (sa(),ia)),Promise.resolve().then(() => (aa(),ca)),Promise.resolve().then(() => (la(),fa)),Promise.resolve().then(() => (ga(),xa)),Promise.resolve().then(() => (ba(),wa)),Promise.resolve().then(() => (Ma(),Ra))]);Hi(kn(process.argv)).locale("en").scriptName("omw").version(`oh-my-worktree v${Rp.version}`).alias("version","v").help("help").alias("help","h").option("no-color",{type:"boolean",description:"Disable color output"}).command(t.default).command(e.default).command(o.default).command(n.default).command(r.default).command(i.default).command(s.default).command(c.default).command(f.default).command(a.default).command(h.default).command(u.default).command(d.default).command(g.default).command(x.default).command(m.default).command(b.default).command(S.default).command(E.default).command(y.default).completion("completion","Generate shell completion script").demandCommand(1,"Please specify a command. Run --help to see available commands.").strict().parse()}
|
|
213
|
+
`;class yc{constructor(e,t,n,o){var r,i,s;this.yargs=e,this.usage=t,this.command=n,this.shim=o,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=(s=((r=this.shim.getEnv("SHELL"))===null||r===void 0?void 0:r.includes("zsh"))||((i=this.shim.getEnv("ZSH_NAME"))===null||i===void 0?void 0:i.includes("zsh")))!==null&&s!==void 0?s:!1}defaultCompletion(e,t,n,o){let r=this.command.getCommandHandlers();for(let s=0,c=e.length;s<c;++s)if(r[e[s]]&&r[e[s]].builder){let u=r[e[s]].builder;if(kr(u)){this.indexAfterLastReset=s+1;let f=this.yargs.getInternalMethods().reset();return u(f,!0),f.argv}}let i=[];this.commandCompletions(i,e,n),this.optionCompletions(i,e,t,n),this.choicesFromOptionsCompletions(i,e,t,n),this.choicesFromPositionalsCompletions(i,e,t,n),o(null,i)}commandCompletions(e,t,n){let o=this.yargs.getInternalMethods().getContext().commands;if(!n.match(/^-/)&&o[o.length-1]!==n&&!this.previousArgHasChoices(t))this.usage.getCommands().forEach((r)=>{let i=zn(r[0]).cmd;if(t.indexOf(i)===-1)if(!this.zshShell)e.push(i);else{let s=r[1]||"";e.push(i.replace(/:/g,"\\:")+":"+s)}})}optionCompletions(e,t,n,o){if((o.match(/^-/)||o===""&&e.length===0)&&!this.previousArgHasChoices(t)){let r=this.yargs.getOptions(),i=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(r.key).forEach((s)=>{let c=!!r.configuration["boolean-negation"]&&r.boolean.includes(s);if(!i.includes(s)&&!r.hiddenOptions.includes(s)&&!this.argsContainKey(t,s,c))this.completeOptionKey(s,e,o,c&&!!r.default[s])})}}choicesFromOptionsCompletions(e,t,n,o){if(this.previousArgHasChoices(t)){let r=this.getPreviousArgChoices(t);if(r&&r.length>0)e.push(...r.map((i)=>i.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(e,t,n,o){if(o===""&&e.length>0&&this.previousArgHasChoices(t))return;let r=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],i=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),s=r[n._.length-i-1];if(!s)return;let c=this.yargs.getOptions().choices[s]||[];for(let u of c)if(u.startsWith(o))e.push(u.replace(/:/g,"\\:"))}getPreviousArgChoices(e){if(e.length<1)return;let t=e[e.length-1],n="";if(!t.startsWith("-")&&e.length>1)n=t,t=e[e.length-2];if(!t.startsWith("-"))return;let o=t.replace(/^-+/,""),r=this.yargs.getOptions(),i=[o,...this.yargs.getAliases()[o]||[]],s;for(let c of i)if(Object.prototype.hasOwnProperty.call(r.key,c)&&Array.isArray(r.choices[c])){s=r.choices[c];break}if(s)return s.filter((c)=>!n||c.startsWith(n))}previousArgHasChoices(e){let t=this.getPreviousArgChoices(e);return t!==void 0&&t.length>0}argsContainKey(e,t,n){let o=(r)=>e.indexOf((/^[^0-9]$/.test(r)?"-":"--")+r)!==-1;if(o(t))return!0;if(n&&o(`no-${t}`))return!0;if(this.aliases){for(let r of this.aliases[t])if(o(r))return!0}return!1}completeOptionKey(e,t,n,o){var r,i,s,c;let u=e;if(this.zshShell){let p=this.usage.getDescriptions(),R=(i=(r=this===null||this===void 0?void 0:this.aliases)===null||r===void 0?void 0:r[e])===null||i===void 0?void 0:i.find((b)=>{let y=p[b];return typeof y==="string"&&y.length>0}),M=R?p[R]:void 0,d=(c=(s=p[e])!==null&&s!==void 0?s:M)!==null&&c!==void 0?c:"";u=`${e.replace(/:/g,"\\:")}:${d.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let f=(p)=>/^--/.test(p),m=(p)=>/^[^0-9]$/.test(p),l=!f(n)&&m(e)?"-":"--";if(t.push(l+u),o)t.push(l+"no-"+u)}customCompletion(e,t,n,o){if(Rt(this.customCompletionFunction,null,this.shim),Yu(this.customCompletionFunction)){let r=this.customCompletionFunction(n,t);if(Ke(r))return r.then((i)=>{this.shim.process.nextTick(()=>{o(null,i)})}).catch((i)=>{this.shim.process.nextTick(()=>{o(i,void 0)})});return o(null,r)}else if(_u(this.customCompletionFunction))return this.customCompletionFunction(n,t,(r=o)=>this.defaultCompletion(e,t,n,r),(r)=>{o(null,r)});else return this.customCompletionFunction(n,t,(r)=>{o(null,r)})}getCompletion(e,t){let n=e.length?e[e.length-1]:"",o=this.yargs.parse(e,!0),r=this.customCompletionFunction?(i)=>this.customCompletion(e,i,n,t):(i)=>this.defaultCompletion(e,i,n,t);return Ke(o)?o.then(r):r(o)}generateCompletionScript(e,t){let n=this.zshShell?Mc:Ec,o=this.shim.path.basename(e);if(e.match(/\.js$/))e=`./${e}`;return n=n.replace(/{{app_name}}/g,o),n=n.replace(/{{completion_command}}/g,t),n.replace(/{{app_path}}/g,e)}registerFunction(e){this.customCompletionFunction=e}setParsed(e){this.aliases=e.aliases}}function Rc(e,t,n,o){return new yc(e,t,n,o)}function Yu(e){return e.length<3}function _u(e){return e.length>3}function Oc(e,t){if(e.length===0)return t.length;if(t.length===0)return e.length;let n=[],o;for(o=0;o<=t.length;o++)n[o]=[o];let r;for(r=0;r<=e.length;r++)n[0][r]=r;for(o=1;o<=t.length;o++)for(r=1;r<=e.length;r++)if(t.charAt(o-1)===e.charAt(r-1))n[o][r]=n[o-1][r-1];else if(o>1&&r>1&&t.charAt(o-2)===e.charAt(r-1)&&t.charAt(o-1)===e.charAt(r-2))n[o][r]=n[o-2][r-2]+1;else n[o][r]=Math.min(n[o-1][r-1]+1,Math.min(n[o][r-1]+1,n[o-1][r]+1));return n[t.length][e.length]}var Wc=["$0","--","_"];function Dc(e,t,n){let o=n.y18n.__,r=n.y18n.__n,i={};i.nonOptionCount=function(l){let p=e.getDemandedCommands(),M=l._.length+(l["--"]?l["--"].length:0)-e.getInternalMethods().getContext().commands.length;if(p._&&(M<p._.min||M>p._.max)){if(M<p._.min)if(p._.minMsg!==void 0)t.fail(p._.minMsg?p._.minMsg.replace(/\$0/g,M.toString()).replace(/\$1/,p._.min.toString()):null);else t.fail(r("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",M,M.toString(),p._.min.toString()));else if(M>p._.max)if(p._.maxMsg!==void 0)t.fail(p._.maxMsg?p._.maxMsg.replace(/\$0/g,M.toString()).replace(/\$1/,p._.max.toString()):null);else t.fail(r("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",M,M.toString(),p._.max.toString()))}},i.positionalCount=function(l,p){if(p<l)t.fail(r("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",p,p+"",l+""))},i.requiredArguments=function(l,p){let R=null;for(let M of Object.keys(p))if(!Object.prototype.hasOwnProperty.call(l,M)||typeof l[M]>"u")R=R||{},R[M]=p[M];if(R){let M=[];for(let b of Object.keys(R)){let y=R[b];if(y&&M.indexOf(y)<0)M.push(y)}let d=M.length?`
|
|
214
|
+
${M.join(`
|
|
215
|
+
`)}`:"";t.fail(r("Missing required argument: %s","Missing required arguments: %s",Object.keys(R).length,Object.keys(R).join(", ")+d))}},i.unknownArguments=function(l,p,R,M,d=!0){var b;let y=e.getInternalMethods().getCommandInstance().getCommands(),S=[],P=e.getInternalMethods().getContext();if(Object.keys(l).forEach((E)=>{if(!Wc.includes(E)&&!Object.prototype.hasOwnProperty.call(R,E)&&!Object.prototype.hasOwnProperty.call(e.getInternalMethods().getParseContext(),E)&&!i.isValidAndSomeAliasIsNotNew(E,p))S.push(E)}),d&&(P.commands.length>0||y.length>0||M))l._.slice(P.commands.length).forEach((E)=>{if(!y.includes(""+E))S.push(""+E)});if(d){let I=((b=e.getDemandedCommands()._)===null||b===void 0?void 0:b.max)||0,V=P.commands.length+I;if(V<l._.length)l._.slice(V).forEach((T)=>{if(T=String(T),!P.commands.includes(T)&&!S.includes(T))S.push(T)})}if(S.length)t.fail(r("Unknown argument: %s","Unknown arguments: %s",S.length,S.map((E)=>E.trim()?E:`"${E}"`).join(", ")))},i.unknownCommands=function(l){let p=e.getInternalMethods().getCommandInstance().getCommands(),R=[],M=e.getInternalMethods().getContext();if(M.commands.length>0||p.length>0)l._.slice(M.commands.length).forEach((d)=>{if(!p.includes(""+d))R.push(""+d)});if(R.length>0)return t.fail(r("Unknown command: %s","Unknown commands: %s",R.length,R.join(", "))),!0;else return!1},i.isValidAndSomeAliasIsNotNew=function(l,p){if(!Object.prototype.hasOwnProperty.call(p,l))return!1;let R=e.parsed.newAliases;return[l,...p[l]].some((M)=>!Object.prototype.hasOwnProperty.call(R,M)||!R[l])},i.limitedChoices=function(l){let p=e.getOptions(),R={};if(!Object.keys(p.choices).length)return;Object.keys(l).forEach((b)=>{if(Wc.indexOf(b)===-1&&Object.prototype.hasOwnProperty.call(p.choices,b))[].concat(l[b]).forEach((y)=>{if(p.choices[b].indexOf(y)===-1&&y!==void 0)R[b]=(R[b]||[]).concat(y)})});let M=Object.keys(R);if(!M.length)return;let d=o("Invalid values:");M.forEach((b)=>{d+=`
|
|
216
|
+
${o("Argument: %s, Given: %s, Choices: %s",b,t.stringifiedValues(R[b]),t.stringifiedValues(p.choices[b]))}`}),t.fail(d)};let s={};i.implies=function(l,p){if(we("<string|object> [array|number|string]",[l,p],arguments.length),typeof l==="object")Object.keys(l).forEach((R)=>{i.implies(R,l[R])});else{if(e.global(l),!s[l])s[l]=[];if(Array.isArray(p))p.forEach((R)=>i.implies(l,R));else Rt(p,void 0,n),s[l].push(p)}},i.getImplied=function(){return s};function c(m,l){let p=Number(l);if(l=isNaN(p)?l:p,typeof l==="number")l=m._.length>=l;else if(l.match(/^--no-.+/))l=l.match(/^--no-(.+)/)[1],l=!Object.prototype.hasOwnProperty.call(m,l);else l=Object.prototype.hasOwnProperty.call(m,l);return l}i.implications=function(l){let p=[];if(Object.keys(s).forEach((R)=>{let M=R;(s[R]||[]).forEach((d)=>{let b=M,y=d;if(b=c(l,b),d=c(l,d),b&&!d)p.push(` ${M} -> ${y}`)})}),p.length){let R=`${o("Implications failed:")}
|
|
217
|
+
`;p.forEach((M)=>{R+=M}),t.fail(R)}};let u={};i.conflicts=function(l,p){if(we("<string|object> [array|string]",[l,p],arguments.length),typeof l==="object")Object.keys(l).forEach((R)=>{i.conflicts(R,l[R])});else{if(e.global(l),!u[l])u[l]=[];if(Array.isArray(p))p.forEach((R)=>i.conflicts(l,R));else u[l].push(p)}},i.getConflicting=()=>u,i.conflicting=function(l){if(Object.keys(l).forEach((p)=>{if(u[p])u[p].forEach((R)=>{if(R&&l[p]!==void 0&&l[R]!==void 0)t.fail(o("Arguments %s and %s are mutually exclusive",p,R))})}),e.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(u).forEach((p)=>{u[p].forEach((R)=>{if(R&&l[n.Parser.camelCase(p)]!==void 0&&l[n.Parser.camelCase(R)]!==void 0)t.fail(o("Arguments %s and %s are mutually exclusive",p,R))})})},i.recommendCommands=function(l,p){p=p.sort((b,y)=>y.length-b.length);let M=null,d=1/0;for(let b=0,y;(y=p[b])!==void 0;b++){let S=Oc(l,y);if(S<=3&&S<d)d=S,M=y}if(M)t.fail(o("Did you mean %s?",M))},i.reset=function(l){return s=Un(s,(p)=>!l[p]),u=Un(u,(p)=>!l[p]),i};let f=[];return i.freeze=function(){f.push({implied:s,conflicting:u})},i.unfreeze=function(){let l=f.pop();Rt(l,void 0,n),{implied:s,conflicting:u}=l},i}var Ji=[],mr;function pr(e,t,n,o){mr=o;let r={};if(Object.prototype.hasOwnProperty.call(e,"extends")){if(typeof e.extends!=="string")return r;let i=/\.json|\..*rc$/.test(e.extends),s=null;if(!i)try{s=En.resolve(e.extends)}catch(c){return e}else s=td(t,e.extends);ed(s),Ji.push(s),r=i?JSON.parse(mr.readFileSync(s,"utf8")):En(e.extends),delete e.extends,r=pr(r,mr.path.dirname(s),n,mr)}return Ji=[],n?Fc(r,e):Object.assign({},r,e)}function ed(e){if(Ji.indexOf(e)>-1)throw new Ve(`Circular extended configurations: '${e}'.`)}function td(e,t){return mr.path.resolve(e,t)}function Fc(e,t){let n={};function o(r){return r&&typeof r==="object"&&!Array.isArray(r)}Object.assign(n,e);for(let r of Object.keys(t))if(o(t[r])&&o(n[r]))n[r]=Fc(e[r],t[r]);else n[r]=t[r];return n}var xe=function(e,t,n,o,r){if(o==="m")throw TypeError("Private method is not writable");if(o==="a"&&!r)throw TypeError("Private accessor was defined without a setter");if(typeof t==="function"?e!==t||!r:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return o==="a"?r.call(e,n):r?r.value=n:t.set(e,n),n},g=function(e,t,n,o){if(n==="a"&&!o)throw TypeError("Private accessor was defined without a getter");if(typeof t==="function"?e!==t||!o:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?o:n==="a"?o.call(e):o?o.value:t.get(e)},ot,mo,gr,Zt,Nt,zr,Vn,po,Ur,Qt,Jr,Yt,gn,Gt,_t,Vr,Bo,ut,Pe,Kr,qr,kt,go,Lo,wo,Kn,Xr,Re,xo,bo,vo,Oe,Zr,wn,_e;function Yc(e){return(t=[],n=e.process.cwd(),o)=>{let r=new _c(t,n,o,e);return Object.defineProperty(r,"argv",{get:()=>{return r.parse()},enumerable:!0}),r.help(),r.version(),r}}var Ic=Symbol("copyDoubleDash"),Bc=Symbol("copyDoubleDash"),Vi=Symbol("deleteFromParserHintObject"),Lc=Symbol("emitWarning"),Ac=Symbol("freeze"),Tc=Symbol("getDollarZero"),Co=Symbol("getParserConfiguration"),jc=Symbol("getUsageConfiguration"),Ki=Symbol("guessLocale"),Nc=Symbol("guessVersion"),Gc=Symbol("parsePositionalNumbers"),qi=Symbol("pkgUp"),qn=Symbol("populateParserHintArray"),Ao=Symbol("populateParserHintSingleValueDictionary"),Xi=Symbol("populateParserHintArrayDictionary"),Zi=Symbol("populateParserHintDictionary"),Qi=Symbol("sanitizeKey"),Yi=Symbol("setKey"),_i=Symbol("unfreeze"),kc=Symbol("validateAsync"),Hc=Symbol("getCommandInstance"),zc=Symbol("getContext"),Uc=Symbol("getHasOutput"),Jc=Symbol("getLoggerInstance"),Vc=Symbol("getParseContext"),Kc=Symbol("getUsageInstance"),qc=Symbol("getValidationInstance"),Qr=Symbol("hasParseCallback"),Xc=Symbol("isGlobalContext"),$o=Symbol("postProcess"),Zc=Symbol("rebase"),es=Symbol("reset"),wr=Symbol("runYargsParserAndExecuteCommands"),ts=Symbol("runValidation"),Qc=Symbol("setHasOutput"),Po=Symbol("kTrackManuallySetKeys");class _c{constructor(e=[],t,n,o){this.customScriptName=!1,this.parsed=!1,ot.set(this,void 0),mo.set(this,void 0),gr.set(this,{commands:[],fullCommands:[]}),Zt.set(this,null),Nt.set(this,null),zr.set(this,"show-hidden"),Vn.set(this,null),po.set(this,!0),Ur.set(this,{}),Qt.set(this,!0),Jr.set(this,[]),Yt.set(this,void 0),gn.set(this,{}),Gt.set(this,!1),_t.set(this,null),Vr.set(this,!0),Bo.set(this,void 0),ut.set(this,""),Pe.set(this,void 0),Kr.set(this,void 0),qr.set(this,{}),kt.set(this,null),go.set(this,null),Lo.set(this,{}),wo.set(this,{}),Kn.set(this,void 0),Xr.set(this,!1),Re.set(this,void 0),xo.set(this,!1),bo.set(this,!1),vo.set(this,!1),Oe.set(this,void 0),Zr.set(this,{}),wn.set(this,null),_e.set(this,void 0),xe(this,Re,o,"f"),xe(this,Kn,e,"f"),xe(this,mo,t,"f"),xe(this,Kr,n,"f"),xe(this,Yt,new Hi(this),"f"),this.$0=this[Tc](),this[es](),xe(this,ot,g(this,ot,"f"),"f"),xe(this,Oe,g(this,Oe,"f"),"f"),xe(this,_e,g(this,_e,"f"),"f"),xe(this,Pe,g(this,Pe,"f"),"f"),g(this,Pe,"f").showHiddenOpt=g(this,zr,"f"),xe(this,Bo,this[Bc](),"f")}addHelpOpt(e,t){if(we("[string|boolean] [string]",[e,t],arguments.length),g(this,_t,"f"))this[Vi](g(this,_t,"f")),xe(this,_t,null,"f");if(e===!1&&t===void 0)return this;return xe(this,_t,typeof e==="string"?e:"help","f"),this.boolean(g(this,_t,"f")),this.describe(g(this,_t,"f"),t||g(this,Oe,"f").deferY18nLookup("Show help")),this}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(we("[string|boolean] [string]",[e,t],arguments.length),e===!1&&t===void 0)return this;let n=typeof e==="string"?e:g(this,zr,"f");return this.boolean(n),this.describe(n,t||g(this,Oe,"f").deferY18nLookup("Show hidden options")),g(this,Pe,"f").showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return we("<object|string|array> [string|array]",[e,t],arguments.length),this[Xi](this.alias.bind(this),"alias",e,t),this}array(e){return we("<array|string>",[e],arguments.length),this[qn]("array",e),this[Po](e),this}boolean(e){return we("<array|string>",[e],arguments.length),this[qn]("boolean",e),this[Po](e),this}check(e,t){return we("<function> [boolean]",[e,t],arguments.length),this.middleware((n,o)=>{return ho(()=>{return e(n,o.getOptions())},(r)=>{if(!r)g(this,Oe,"f").fail(g(this,Re,"f").y18n.__("Argument check failed: %s",e.toString()));else if(typeof r==="string"||r instanceof Error)g(this,Oe,"f").fail(r.toString(),r);return n},(r)=>{return g(this,Oe,"f").fail(r.message?r.message:r.toString(),r),n})},!1,t),this}choices(e,t){return we("<object|string|array> [string|array]",[e,t],arguments.length),this[Xi](this.choices.bind(this),"choices",e,t),this}coerce(e,t){if(we("<object|string|array> [function]",[e,t],arguments.length),Array.isArray(e)){if(!t)throw new Ve("coerce callback must be provided");for(let n of e)this.coerce(n,t);return this}else if(typeof e==="object"){for(let n of Object.keys(e))this.coerce(n,e[n]);return this}if(!t)throw new Ve("coerce callback must be provided");return g(this,Pe,"f").key[e]=!0,g(this,Yt,"f").addCoerceMiddleware((n,o)=>{let r;if(!Object.prototype.hasOwnProperty.call(n,e))return n;return ho(()=>{return r=o.getAliases(),t(n[e])},(s)=>{n[e]=s;let c=o.getInternalMethods().getParserConfiguration()["strip-aliased"];if(r[e]&&c!==!0)for(let u of r[e])n[u]=s;return n},(s)=>{throw new Ve(s.message)})},e),this}conflicts(e,t){return we("<string|object> [string|array]",[e,t],arguments.length),g(this,_e,"f").conflicts(e,t),this}config(e="config",t,n){if(we("[object|string] [string|function] [function]",[e,t,n],arguments.length),typeof e==="object"&&!Array.isArray(e))return e=pr(e,g(this,mo,"f"),this[Co]()["deep-merge-config"]||!1,g(this,Re,"f")),g(this,Pe,"f").configObjects=(g(this,Pe,"f").configObjects||[]).concat(e),this;if(typeof t==="function")n=t,t=void 0;return this.describe(e,t||g(this,Oe,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(e)?e:[e]).forEach((o)=>{g(this,Pe,"f").config[o]=n||!0}),this}completion(e,t,n){if(we("[string] [string|boolean|function] [function]",[e,t,n],arguments.length),typeof t==="function")n=t,t=void 0;if(xe(this,Nt,e||g(this,Nt,"f")||"completion","f"),!t&&t!==!1)t="generate completion script";if(this.command(g(this,Nt,"f"),t),n)g(this,Zt,"f").registerFunction(n);return this}command(e,t,n,o,r,i){return we("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,t,n,o,r,i],arguments.length),g(this,ot,"f").addHandler(e,t,n,o,r,i),this}commands(e,t,n,o,r,i){return this.command(e,t,n,o,r,i)}commandDir(e,t){we("<string> [object]",[e,t],arguments.length);let n=g(this,Kr,"f")||g(this,Re,"f").require;return g(this,ot,"f").addDirectory(e,n,g(this,Re,"f").getCallerFile(),t),this}count(e){return we("<array|string>",[e],arguments.length),this[qn]("count",e),this[Po](e),this}default(e,t,n){if(we("<object|string|array> [*] [string]",[e,t,n],arguments.length),n)ki(e,g(this,Re,"f")),g(this,Pe,"f").defaultDescription[e]=n;if(typeof t==="function"){if(ki(e,g(this,Re,"f")),!g(this,Pe,"f").defaultDescription[e])g(this,Pe,"f").defaultDescription[e]=g(this,Oe,"f").functionDescription(t);t=t.call()}return this[Ao](this.default.bind(this),"default",e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,o){if(we("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,t,n,o],arguments.length),typeof t!=="number")n=t,t=1/0;return this.global("_",!1),g(this,Pe,"f").demandedCommands._={min:e,max:t,minMsg:n,maxMsg:o},this}demand(e,t,n){if(Array.isArray(t))t.forEach((o)=>{Rt(n,!0,g(this,Re,"f")),this.demandOption(o,n)}),t=1/0;else if(typeof t!=="number")n=t,t=1/0;if(typeof e==="number")Rt(n,!0,g(this,Re,"f")),this.demandCommand(e,t,n,n);else if(Array.isArray(e))e.forEach((o)=>{Rt(n,!0,g(this,Re,"f")),this.demandOption(o,n)});else if(typeof n==="string")this.demandOption(e,n);else if(n===!0||typeof n>"u")this.demandOption(e);return this}demandOption(e,t){return we("<object|string|array> [string]",[e,t],arguments.length),this[Ao](this.demandOption.bind(this),"demandedOptions",e,t),this}deprecateOption(e,t){return we("<string> [string|boolean]",[e,t],arguments.length),g(this,Pe,"f").deprecatedOptions[e]=t,this}describe(e,t){return we("<object|string|array> [string]",[e,t],arguments.length),this[Yi](e,!0),g(this,Oe,"f").describe(e,t),this}detectLocale(e){return we("<boolean>",[e],arguments.length),xe(this,po,e,"f"),this}env(e){if(we("[string|boolean]",[e],arguments.length),e===!1)delete g(this,Pe,"f").envPrefix;else g(this,Pe,"f").envPrefix=e||"";return this}epilogue(e){return we("<string>",[e],arguments.length),g(this,Oe,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){if(we("<string|array> [string]",[e,t],arguments.length),Array.isArray(e))e.forEach((n)=>this.example(...n));else g(this,Oe,"f").example(e,t);return this}exit(e,t){if(xe(this,Gt,!0,"f"),xe(this,Vn,t,"f"),g(this,Qt,"f"))g(this,Re,"f").process.exit(e)}exitProcess(e=!0){return we("[boolean]",[e],arguments.length),xe(this,Qt,e,"f"),this}fail(e){if(we("<function|boolean>",[e],arguments.length),typeof e==="boolean"&&e!==!1)throw new Ve("Invalid first argument. Expected function or boolean 'false'");return g(this,Oe,"f").failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,t){if(we("<array> [function]",[e,t],arguments.length),!t)return new Promise((n,o)=>{g(this,Zt,"f").getCompletion(e,(r,i)=>{if(r)o(r);else n(i)})});else return g(this,Zt,"f").getCompletion(e,t)}getDemandedOptions(){return we([],0),g(this,Pe,"f").demandedOptions}getDemandedCommands(){return we([],0),g(this,Pe,"f").demandedCommands}getDeprecatedOptions(){return we([],0),g(this,Pe,"f").deprecatedOptions}getDetectLocale(){return g(this,po,"f")}getExitProcess(){return g(this,Qt,"f")}getGroups(){return Object.assign({},g(this,gn,"f"),g(this,wo,"f"))}getHelp(){if(xe(this,Gt,!0,"f"),!g(this,Oe,"f").hasCachedHelpMessage()){if(!this.parsed){let t=this[wr](g(this,Kn,"f"),void 0,void 0,0,!0);if(Ke(t))return t.then(()=>{return g(this,Oe,"f").help()})}let e=g(this,ot,"f").runDefaultBuilderOn(this);if(Ke(e))return e.then(()=>{return g(this,Oe,"f").help()})}return Promise.resolve(g(this,Oe,"f").help())}getOptions(){return g(this,Pe,"f")}getStrict(){return g(this,xo,"f")}getStrictCommands(){return g(this,bo,"f")}getStrictOptions(){return g(this,vo,"f")}global(e,t){if(we("<string|array> [boolean]",[e,t],arguments.length),e=[].concat(e),t!==!1)g(this,Pe,"f").local=g(this,Pe,"f").local.filter((n)=>e.indexOf(n)===-1);else e.forEach((n)=>{if(!g(this,Pe,"f").local.includes(n))g(this,Pe,"f").local.push(n)});return this}group(e,t){we("<string|array> <string>",[e,t],arguments.length);let n=g(this,wo,"f")[t]||g(this,gn,"f")[t];if(g(this,wo,"f")[t])delete g(this,wo,"f")[t];let o={};return g(this,gn,"f")[t]=(n||[]).concat(e).filter((r)=>{if(o[r])return!1;return o[r]=!0}),this}hide(e){return we("<string>",[e],arguments.length),g(this,Pe,"f").hiddenOptions.push(e),this}implies(e,t){return we("<string|object> [number|string|array]",[e,t],arguments.length),g(this,_e,"f").implies(e,t),this}locale(e){if(we("[string]",[e],arguments.length),e===void 0)return this[Ki](),g(this,Re,"f").y18n.getLocale();return xe(this,po,!1,"f"),g(this,Re,"f").y18n.setLocale(e),this}middleware(e,t,n){return g(this,Yt,"f").addMiddleware(e,!!t,n)}nargs(e,t){return we("<string|object|array> [number]",[e,t],arguments.length),this[Ao](this.nargs.bind(this),"narg",e,t),this}normalize(e){return we("<array|string>",[e],arguments.length),this[qn]("normalize",e),this}number(e){return we("<array|string>",[e],arguments.length),this[qn]("number",e),this[Po](e),this}option(e,t){if(we("<string|object> [object]",[e,t],arguments.length),typeof e==="object")Object.keys(e).forEach((n)=>{this.options(n,e[n])});else{if(typeof t!=="object")t={};if(this[Po](e),g(this,wn,"f")&&(e==="version"||(t===null||t===void 0?void 0:t.alias)==="version"))this[Lc](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join(`
|
|
218
|
+
`),void 0,"versionWarning");if(g(this,Pe,"f").key[e]=!0,t.alias)this.alias(e,t.alias);let n=t.deprecate||t.deprecated;if(n)this.deprecateOption(e,n);let o=t.demand||t.required||t.require;if(o)this.demand(e,o);if(t.demandOption)this.demandOption(e,typeof t.demandOption==="string"?t.demandOption:void 0);if(t.conflicts)this.conflicts(e,t.conflicts);if("default"in t)this.default(e,t.default);if(t.implies!==void 0)this.implies(e,t.implies);if(t.nargs!==void 0)this.nargs(e,t.nargs);if(t.config)this.config(e,t.configParser);if(t.normalize)this.normalize(e);if(t.choices)this.choices(e,t.choices);if(t.coerce)this.coerce(e,t.coerce);if(t.group)this.group(e,t.group);if(t.boolean||t.type==="boolean"){if(this.boolean(e),t.alias)this.boolean(t.alias)}if(t.array||t.type==="array"){if(this.array(e),t.alias)this.array(t.alias)}if(t.number||t.type==="number"){if(this.number(e),t.alias)this.number(t.alias)}if(t.string||t.type==="string"){if(this.string(e),t.alias)this.string(t.alias)}if(t.count||t.type==="count")this.count(e);if(typeof t.global==="boolean")this.global(e,t.global);if(t.defaultDescription)g(this,Pe,"f").defaultDescription[e]=t.defaultDescription;if(t.skipValidation)this.skipValidation(e);let r=t.describe||t.description||t.desc,i=g(this,Oe,"f").getDescriptions();if(!Object.prototype.hasOwnProperty.call(i,e)||typeof r==="string")this.describe(e,r);if(t.hidden)this.hide(e);if(t.requiresArg)this.requiresArg(e)}return this}options(e,t){return this.option(e,t)}parse(e,t,n){if(we("[string|array] [function|boolean|object] [function]",[e,t,n],arguments.length),this[Ac](),typeof e>"u")e=g(this,Kn,"f");if(typeof t==="object")xe(this,go,t,"f"),t=n;if(typeof t==="function")xe(this,kt,t,"f"),t=!1;if(!t)xe(this,Kn,e,"f");if(g(this,kt,"f"))xe(this,Qt,!1,"f");let o=this[wr](e,!!t),r=this.parsed;if(g(this,Zt,"f").setParsed(this.parsed),Ke(o))return o.then((i)=>{if(g(this,kt,"f"))g(this,kt,"f").call(this,g(this,Vn,"f"),i,g(this,ut,"f"));return i}).catch((i)=>{if(g(this,kt,"f"))g(this,kt,"f")(i,this.parsed.argv,g(this,ut,"f"));throw i}).finally(()=>{this[_i](),this.parsed=r});else{if(g(this,kt,"f"))g(this,kt,"f").call(this,g(this,Vn,"f"),o,g(this,ut,"f"));this[_i](),this.parsed=r}return o}parseAsync(e,t,n){let o=this.parse(e,t,n);return!Ke(o)?Promise.resolve(o):o}parseSync(e,t,n){let o=this.parse(e,t,n);if(Ke(o))throw new Ve(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return o}parserConfiguration(e){return we("<object>",[e],arguments.length),xe(this,qr,e,"f"),this}pkgConf(e,t){we("<string> [string]",[e,t],arguments.length);let n=null,o=this[qi](t||g(this,mo,"f"));if(o[e]&&typeof o[e]==="object")n=pr(o[e],t||g(this,mo,"f"),this[Co]()["deep-merge-config"]||!1,g(this,Re,"f")),g(this,Pe,"f").configObjects=(g(this,Pe,"f").configObjects||[]).concat(n);return this}positional(e,t){we("<string> <object>",[e,t],arguments.length);let n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];t=Un(t,(i,s)=>{if(i==="type"&&!["string","number","boolean"].includes(s))return!1;return n.includes(i)});let o=g(this,gr,"f").fullCommands[g(this,gr,"f").fullCommands.length-1],r=o?g(this,ot,"f").cmdToParseOptions(o):{array:[],alias:{},default:{},demand:{}};return Fo(r).forEach((i)=>{let s=r[i];if(Array.isArray(s)){if(s.indexOf(e)!==-1)t[i]=!0}else if(s[e]&&!(i in t))t[i]=s[e]}),this.group(e,g(this,Oe,"f").getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return we("[boolean]",[e],arguments.length),xe(this,Xr,e,"f"),this}required(e,t,n){return this.demand(e,t,n)}require(e,t,n){return this.demand(e,t,n)}requiresArg(e){if(we("<array|string|object> [number]",[e],arguments.length),typeof e==="string"&&g(this,Pe,"f").narg[e])return this;else this[Ao](this.requiresArg.bind(this),"narg",e,NaN);return this}showCompletionScript(e,t){return we("[string] [string]",[e,t],arguments.length),e=e||this.$0,g(this,Bo,"f").log(g(this,Zt,"f").generateCompletionScript(e,t||g(this,Nt,"f")||"completion")),this}showHelp(e){if(we("[string|function]",[e],arguments.length),xe(this,Gt,!0,"f"),!g(this,Oe,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[wr](g(this,Kn,"f"),void 0,void 0,0,!0);if(Ke(n))return n.then(()=>{g(this,Oe,"f").showHelp(e)}),this}let t=g(this,ot,"f").runDefaultBuilderOn(this);if(Ke(t))return t.then(()=>{g(this,Oe,"f").showHelp(e)}),this}return g(this,Oe,"f").showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,t){return we("[boolean|string] [string]",[e,t],arguments.length),g(this,Oe,"f").showHelpOnFail(e,t),this}showVersion(e){return we("[string|function]",[e],arguments.length),g(this,Oe,"f").showVersion(e),this}skipValidation(e){return we("<array|string>",[e],arguments.length),this[qn]("skipValidation",e),this}strict(e){return we("[boolean]",[e],arguments.length),xe(this,xo,e!==!1,"f"),this}strictCommands(e){return we("[boolean]",[e],arguments.length),xe(this,bo,e!==!1,"f"),this}strictOptions(e){return we("[boolean]",[e],arguments.length),xe(this,vo,e!==!1,"f"),this}string(e){return we("<array|string>",[e],arguments.length),this[qn]("string",e),this[Po](e),this}terminalWidth(){return we([],0),g(this,Re,"f").process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return we("<object>",[e],arguments.length),xe(this,po,!1,"f"),g(this,Re,"f").y18n.updateLocale(e),this}usage(e,t,n,o){if(we("<string|null|undefined> [string|boolean] [function|object] [function]",[e,t,n,o],arguments.length),t!==void 0)if(Rt(e,null,g(this,Re,"f")),(e||"").match(/^\$0( |$)/))return this.command(e,t,n,o);else throw new Ve(".usage() description must start with $0 if being used as alias for .command()");else return g(this,Oe,"f").usage(e),this}usageConfiguration(e){return we("<object>",[e],arguments.length),xe(this,Zr,e,"f"),this}version(e,t,n){if(we("[boolean|string] [string] [string]",[e,t,n],arguments.length),g(this,wn,"f"))this[Vi](g(this,wn,"f")),g(this,Oe,"f").version(void 0),xe(this,wn,null,"f");if(arguments.length===0)n=this[Nc](),e="version";else if(arguments.length===1){if(e===!1)return this;n=e,e="version"}else if(arguments.length===2)n=t,t=void 0;return xe(this,wn,typeof e==="string"?e:"version","f"),t=t||g(this,Oe,"f").deferY18nLookup("Show version number"),g(this,Oe,"f").version(n||void 0),this.boolean(g(this,wn,"f")),this.describe(g(this,wn,"f"),t),this}wrap(e){return we("<number|null|undefined>",[e],arguments.length),g(this,Oe,"f").wrap(e),this}[(ot=new WeakMap,mo=new WeakMap,gr=new WeakMap,Zt=new WeakMap,Nt=new WeakMap,zr=new WeakMap,Vn=new WeakMap,po=new WeakMap,Ur=new WeakMap,Qt=new WeakMap,Jr=new WeakMap,Yt=new WeakMap,gn=new WeakMap,Gt=new WeakMap,_t=new WeakMap,Vr=new WeakMap,Bo=new WeakMap,ut=new WeakMap,Pe=new WeakMap,Kr=new WeakMap,qr=new WeakMap,kt=new WeakMap,go=new WeakMap,Lo=new WeakMap,wo=new WeakMap,Kn=new WeakMap,Xr=new WeakMap,Re=new WeakMap,xo=new WeakMap,bo=new WeakMap,vo=new WeakMap,Oe=new WeakMap,Zr=new WeakMap,wn=new WeakMap,_e=new WeakMap,Ic)](e){if(!e._||!e["--"])return e;e._.push.apply(e._,e["--"]);try{delete e["--"]}catch(t){}return e}[Bc](){return{log:(...e)=>{if(!this[Qr]())console.log(...e);if(xe(this,Gt,!0,"f"),g(this,ut,"f").length)xe(this,ut,g(this,ut,"f")+`
|
|
219
|
+
`,"f");xe(this,ut,g(this,ut,"f")+e.join(" "),"f")},error:(...e)=>{if(!this[Qr]())console.error(...e);if(xe(this,Gt,!0,"f"),g(this,ut,"f").length)xe(this,ut,g(this,ut,"f")+`
|
|
220
|
+
`,"f");xe(this,ut,g(this,ut,"f")+e.join(" "),"f")}}}[Vi](e){Fo(g(this,Pe,"f")).forEach((t)=>{if(((o)=>o==="configObjects")(t))return;let n=g(this,Pe,"f")[t];if(Array.isArray(n)){if(n.includes(e))n.splice(n.indexOf(e),1)}else if(typeof n==="object")delete n[e]}),delete g(this,Oe,"f").getDescriptions()[e]}[Lc](e,t,n){if(!g(this,Ur,"f")[n])g(this,Re,"f").process.emitWarning(e,t),g(this,Ur,"f")[n]=!0}[Ac](){g(this,Jr,"f").push({options:g(this,Pe,"f"),configObjects:g(this,Pe,"f").configObjects.slice(0),exitProcess:g(this,Qt,"f"),groups:g(this,gn,"f"),strict:g(this,xo,"f"),strictCommands:g(this,bo,"f"),strictOptions:g(this,vo,"f"),completionCommand:g(this,Nt,"f"),output:g(this,ut,"f"),exitError:g(this,Vn,"f"),hasOutput:g(this,Gt,"f"),parsed:this.parsed,parseFn:g(this,kt,"f"),parseContext:g(this,go,"f")}),g(this,Oe,"f").freeze(),g(this,_e,"f").freeze(),g(this,ot,"f").freeze(),g(this,Yt,"f").freeze()}[Tc](){let e="",t;if(/\b(node|iojs|electron)(\.exe)?$/.test(g(this,Re,"f").process.argv()[0]))t=g(this,Re,"f").process.argv().slice(1,2);else t=g(this,Re,"f").process.argv().slice(0,1);if(e=t.map((n)=>{let o=this[Zc](g(this,mo,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&o.length<n.length?o:n}).join(" ").trim(),g(this,Re,"f").getEnv("_")&&g(this,Re,"f").getProcessArgvBin()===g(this,Re,"f").getEnv("_"))e=g(this,Re,"f").getEnv("_").replace(`${g(this,Re,"f").path.dirname(g(this,Re,"f").process.execPath())}/`,"");return e}[Co](){return g(this,qr,"f")}[jc](){return g(this,Zr,"f")}[Ki](){if(!g(this,po,"f"))return;let e=g(this,Re,"f").getEnv("LC_ALL")||g(this,Re,"f").getEnv("LC_MESSAGES")||g(this,Re,"f").getEnv("LANG")||g(this,Re,"f").getEnv("LANGUAGE")||"en_US";this.locale(e.replace(/[.:].*/,""))}[Nc](){return this[qi]().version||"unknown"}[Gc](e){let t=e["--"]?e["--"]:e._;for(let n=0,o;(o=t[n])!==void 0;n++)if(g(this,Re,"f").Parser.looksLikeNumber(o)&&Number.isSafeInteger(Math.floor(parseFloat(`${o}`))))t[n]=Number(o);return e}[qi](e){let t=e||"*";if(g(this,Lo,"f")[t])return g(this,Lo,"f")[t];let n={};try{let o=e||g(this,Re,"f").mainFilename;if(!e&&g(this,Re,"f").path.extname(o))o=g(this,Re,"f").path.dirname(o);let r=g(this,Re,"f").findUp(o,(i,s)=>{if(s.includes("package.json"))return"package.json";else return});Rt(r,void 0,g(this,Re,"f")),n=JSON.parse(g(this,Re,"f").readFileSync(r,"utf8"))}catch(o){}return g(this,Lo,"f")[t]=n||{},g(this,Lo,"f")[t]}[qn](e,t){t=[].concat(t),t.forEach((n)=>{n=this[Qi](n),g(this,Pe,"f")[e].push(n)})}[Ao](e,t,n,o){this[Zi](e,t,n,o,(r,i,s)=>{g(this,Pe,"f")[r][i]=s})}[Xi](e,t,n,o){this[Zi](e,t,n,o,(r,i,s)=>{g(this,Pe,"f")[r][i]=(g(this,Pe,"f")[r][i]||[]).concat(s)})}[Zi](e,t,n,o,r){if(Array.isArray(n))n.forEach((i)=>{e(i,o)});else if(((i)=>typeof i==="object")(n))for(let i of Fo(n))e(i,n[i]);else r(t,this[Qi](n),o)}[Qi](e){if(e==="__proto__")return"___proto___";return e}[Yi](e,t){return this[Ao](this[Yi].bind(this),"key",e,t),this}[_i](){var e,t,n,o,r,i,s,c,u,f,m,l;let p=g(this,Jr,"f").pop();Rt(p,void 0,g(this,Re,"f"));let R;e=this,t=this,n=this,o=this,r=this,i=this,s=this,c=this,u=this,f=this,m=this,l=this,{options:{set value(M){xe(e,Pe,M,"f")}}.value,configObjects:R,exitProcess:{set value(M){xe(t,Qt,M,"f")}}.value,groups:{set value(M){xe(n,gn,M,"f")}}.value,output:{set value(M){xe(o,ut,M,"f")}}.value,exitError:{set value(M){xe(r,Vn,M,"f")}}.value,hasOutput:{set value(M){xe(i,Gt,M,"f")}}.value,parsed:this.parsed,strict:{set value(M){xe(s,xo,M,"f")}}.value,strictCommands:{set value(M){xe(c,bo,M,"f")}}.value,strictOptions:{set value(M){xe(u,vo,M,"f")}}.value,completionCommand:{set value(M){xe(f,Nt,M,"f")}}.value,parseFn:{set value(M){xe(m,kt,M,"f")}}.value,parseContext:{set value(M){xe(l,go,M,"f")}}.value}=p,g(this,Pe,"f").configObjects=R,g(this,Oe,"f").unfreeze(),g(this,_e,"f").unfreeze(),g(this,ot,"f").unfreeze(),g(this,Yt,"f").unfreeze()}[kc](e,t){return ho(t,(n)=>{return e(n),n})}getInternalMethods(){return{getCommandInstance:this[Hc].bind(this),getContext:this[zc].bind(this),getHasOutput:this[Uc].bind(this),getLoggerInstance:this[Jc].bind(this),getParseContext:this[Vc].bind(this),getParserConfiguration:this[Co].bind(this),getUsageConfiguration:this[jc].bind(this),getUsageInstance:this[Kc].bind(this),getValidationInstance:this[qc].bind(this),hasParseCallback:this[Qr].bind(this),isGlobalContext:this[Xc].bind(this),postProcess:this[$o].bind(this),reset:this[es].bind(this),runValidation:this[ts].bind(this),runYargsParserAndExecuteCommands:this[wr].bind(this),setHasOutput:this[Qc].bind(this)}}[Hc](){return g(this,ot,"f")}[zc](){return g(this,gr,"f")}[Uc](){return g(this,Gt,"f")}[Jc](){return g(this,Bo,"f")}[Vc](){return g(this,go,"f")||{}}[Kc](){return g(this,Oe,"f")}[qc](){return g(this,_e,"f")}[Qr](){return!!g(this,kt,"f")}[Xc](){return g(this,Vr,"f")}[$o](e,t,n,o){if(n)return e;if(Ke(e))return e;if(!t)e=this[Ic](e);if(this[Co]()["parse-positional-numbers"]||this[Co]()["parse-positional-numbers"]===void 0)e=this[Gc](e);if(o)e=uo(e,this,g(this,Yt,"f").getMiddleware(),!1);return e}[es](e={}){xe(this,Pe,g(this,Pe,"f")||{},"f");let t={};t.local=g(this,Pe,"f").local||[],t.configObjects=g(this,Pe,"f").configObjects||[];let n={};t.local.forEach((i)=>{n[i]=!0,(e[i]||[]).forEach((s)=>{n[s]=!0})}),Object.assign(g(this,wo,"f"),Object.keys(g(this,gn,"f")).reduce((i,s)=>{let c=g(this,gn,"f")[s].filter((u)=>!(u in n));if(c.length>0)i[s]=c;return i},{})),xe(this,gn,{},"f");let o=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],r=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(o.forEach((i)=>{t[i]=(g(this,Pe,"f")[i]||[]).filter((s)=>!n[s])}),r.forEach((i)=>{t[i]=Un(g(this,Pe,"f")[i],(s)=>!n[s])}),t.envPrefix=g(this,Pe,"f").envPrefix,xe(this,Pe,t,"f"),xe(this,Oe,g(this,Oe,"f")?g(this,Oe,"f").reset(n):Sc(this,g(this,Re,"f")),"f"),xe(this,_e,g(this,_e,"f")?g(this,_e,"f").reset(n):Dc(this,g(this,Oe,"f"),g(this,Re,"f")),"f"),xe(this,ot,g(this,ot,"f")?g(this,ot,"f").reset():Cc(g(this,Oe,"f"),g(this,_e,"f"),g(this,Yt,"f"),g(this,Re,"f")),"f"),!g(this,Zt,"f"))xe(this,Zt,Rc(this,g(this,Oe,"f"),g(this,ot,"f"),g(this,Re,"f")),"f");return g(this,Yt,"f").reset(),xe(this,Nt,null,"f"),xe(this,ut,"","f"),xe(this,Vn,null,"f"),xe(this,Gt,!1,"f"),this.parsed=!1,this}[Zc](e,t){return g(this,Re,"f").path.relative(e,t)}[wr](e,t,n,o=0,r=!1){let i=!!n||r;e=e||g(this,Kn,"f"),g(this,Pe,"f").__=g(this,Re,"f").y18n.__,g(this,Pe,"f").configuration=this[Co]();let s=!!g(this,Pe,"f").configuration["populate--"],c=Object.assign({},g(this,Pe,"f").configuration,{"populate--":!0}),u=g(this,Re,"f").Parser.detailed(e,Object.assign({},g(this,Pe,"f"),{configuration:{"parse-positional-numbers":!1,...c}})),f=Object.assign(u.argv,g(this,go,"f")),m=void 0,l=u.aliases,p=!1,R=!1;if(Object.keys(f).forEach((M)=>{if(M===g(this,_t,"f")&&f[M])p=!0;else if(M===g(this,wn,"f")&&f[M])R=!0}),f.$0=this.$0,this.parsed=u,o===0)g(this,Oe,"f").clearCachedHelpMessage();try{if(this[Ki](),t)return this[$o](f,s,!!n,!1);if(g(this,_t,"f")){if([g(this,_t,"f")].concat(l[g(this,_t,"f")]||[]).filter((S)=>S.length>1).includes(""+f._[f._.length-1]))f._.pop(),p=!0}xe(this,Vr,!1,"f");let M=g(this,ot,"f").getCommands(),d=g(this,Zt,"f").completionKey in f,b=p||d||r;if(f._.length){if(M.length){let y;for(let S=o||0,P;f._[S]!==void 0;S++)if(P=String(f._[S]),M.includes(P)&&P!==g(this,Nt,"f")){let E=g(this,ot,"f").runCommand(P,this,u,S+1,r,p||R||r);return this[$o](E,s,!!n,!1)}else if(!y&&P!==g(this,Nt,"f")){y=P;break}if(!g(this,ot,"f").hasDefaultCommand()&&g(this,Xr,"f")&&y&&!b)g(this,_e,"f").recommendCommands(y,M)}if(g(this,Nt,"f")&&f._.includes(g(this,Nt,"f"))&&!d){if(g(this,Qt,"f"))Jn(!0);this.showCompletionScript(),this.exit(0)}}if(g(this,ot,"f").hasDefaultCommand()&&!b){let y=g(this,ot,"f").runCommand(null,this,u,0,r,p||R||r);return this[$o](y,s,!!n,!1)}if(d){if(g(this,Qt,"f"))Jn(!0);e=[].concat(e);let y=e.slice(e.indexOf(`--${g(this,Zt,"f").completionKey}`)+1);return g(this,Zt,"f").getCompletion(y,(S,P)=>{if(S)throw new Ve(S.message);(P||[]).forEach((E)=>{g(this,Bo,"f").log(E)}),this.exit(0)}),this[$o](f,!s,!!n,!1)}if(!g(this,Gt,"f")){if(p){if(g(this,Qt,"f"))Jn(!0);i=!0,this.showHelp("log"),this.exit(0)}else if(R){if(g(this,Qt,"f"))Jn(!0);i=!0,g(this,Oe,"f").showVersion("log"),this.exit(0)}}if(!i&&g(this,Pe,"f").skipValidation.length>0)i=Object.keys(f).some((y)=>g(this,Pe,"f").skipValidation.indexOf(y)>=0&&f[y]===!0);if(!i){if(u.error)throw new Ve(u.error.message);if(!d){let y=this[ts](l,{},u.error);if(!n)m=uo(f,this,g(this,Yt,"f").getMiddleware(),!0);if(m=this[kc](y,m!==null&&m!==void 0?m:f),Ke(m)&&!n)m=m.then(()=>{return uo(f,this,g(this,Yt,"f").getMiddleware(),!1)})}}}catch(M){if(M instanceof Ve)g(this,Oe,"f").fail(M.message,M);else throw M}return this[$o](m!==null&&m!==void 0?m:f,s,!!n,!0)}[ts](e,t,n,o){let r={...this.getDemandedOptions()};return(i)=>{if(n)throw new Ve(n.message);g(this,_e,"f").nonOptionCount(i),g(this,_e,"f").requiredArguments(i,r);let s=!1;if(g(this,bo,"f"))s=g(this,_e,"f").unknownCommands(i);if(g(this,xo,"f")&&!s)g(this,_e,"f").unknownArguments(i,e,t,!!o);else if(g(this,vo,"f"))g(this,_e,"f").unknownArguments(i,e,{},!1,!1);g(this,_e,"f").limitedChoices(i),g(this,_e,"f").implications(i),g(this,_e,"f").conflicting(i)}}[Qc](){xe(this,Gt,!0,"f")}[Po](e){if(typeof e==="string")g(this,Pe,"f").key[e]=!0;else for(let t of e)g(this,Pe,"f").key[t]=!0}}function $c(e){return!!e&&typeof e.getInternalMethods==="function"}var nd=Yc(Gi),ea=nd;import{readFileSync as au}from"fs";import{join as Hs}from"path";function Rg(){let e=import.meta.dir;for(let t=0;t<5;t++){let n=Hs(e,"package.json");try{return au(n,"utf-8"),n}catch{}e=Hs(e,"..")}return Hs(import.meta.dir,"../../package.json")}var Og=JSON.parse(au(Rg(),"utf-8"));if(process.argv.length===2){let{launchTUI:e}=await Promise.resolve().then(() => (Il(),Fl));await e()}else{let[e,t,n,o,r,i,s,c,u,f,m,l,p,R,M,d,b,y,S,P]=await Promise.all([Promise.resolve().then(() => (Hl(),kl)),Promise.resolve().then(() => (Ul(),zl)),Promise.resolve().then(() => (Kl(),Vl)),Promise.resolve().then(() => (Xl(),ql)),Promise.resolve().then(() => (ef(),_l)),Promise.resolve().then(() => (lf(),af)),Promise.resolve().then(() => (uf(),ff)),Promise.resolve().then(() => (pf(),mf)),Promise.resolve().then(() => (xf(),wf)),Promise.resolve().then(() => (Cf(),vf)),Promise.resolve().then(() => (Sf(),Pf)),Promise.resolve().then(() => (Mf(),Ef)),Promise.resolve().then(() => (Rf(),yf)),Promise.resolve().then(() => (Wf(),Of)),Promise.resolve().then(() => (Gf(),Nf)),Promise.resolve().then(() => (Hf(),kf)),Promise.resolve().then(() => (Uf(),zf)),Promise.resolve().then(() => (Qf(),Zf)),Promise.resolve().then(() => (_f(),Yf)),Promise.resolve().then(() => (cu(),su))]);ea(Ni(process.argv)).locale("en").scriptName("omw").version(`oh-my-worktree v${Og.version}`).alias("version","v").help("help").alias("help","h").option("no-color",{type:"boolean",description:"Disable color output"}).command(e.default).command(t.default).command(n.default).command(o.default).command(r.default).command(i.default).command(s.default).command(c.default).command(u.default).command(f.default).command(m.default).command(l.default).command(p.default).command(R.default).command(M.default).command(d.default).command(b.default).command(y.default).command(S.default).command(P.default).completion("completion","Generate shell completion script").demandCommand(1,"Please specify a command. Run --help to see available commands.").strict().parse()}
|