vibora 5.2.0 → 5.3.0

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/bin/vibora.js CHANGED
@@ -32583,7 +32583,7 @@ function installUv() {
32583
32583
  var package_default = {
32584
32584
  name: "vibora",
32585
32585
  private: true,
32586
- version: "5.2.0",
32586
+ version: "5.3.0",
32587
32587
  description: "The Vibe Engineer's Cockpit",
32588
32588
  license: "PolyForm-Shield-1.0.0",
32589
32589
  type: "module",
@@ -28,7 +28,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
28
28
 
29
29
  `)+n.map(mOe).join(`
30
30
  `)}var vOe=0,yOe=(function(){function e(){Object.defineProperty(this,"cacheId",{enumerable:!0,configurable:!0,writable:!0,value:vOe++}),Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:fr.map()}),Object.defineProperty(this,"lastCacheModificationPerId",{enumerable:!0,configurable:!0,writable:!0,value:fr.map()})}return Object.defineProperty(e.prototype,"updateLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this.lastCacheModificationPerId.get(t);this.lastCacheModificationPerId.set(t,n===void 0?1:n+1)}}),Object.defineProperty(e.prototype,"getLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this.lastCacheModificationPerId.get(t)||0;return"".concat(this.cacheId,"-").concat(n)}}),Object.defineProperty(e.prototype,"addNodeToCache",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if(n===void 0&&(n=!0),t.identifierAttribute){var r=t.identifier;this.cache.has(r)||this.cache.set(r,fr.array([],yw));var i=this.cache.get(r);if(i.indexOf(t)!==-1)throw new St("Already registered");i.push(t),n&&this.updateLastCacheModificationPerId(r)}}}),Object.defineProperty(e.prototype,"mergeCache",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this;Rre(t.identifierCache.cache).forEach(function(r){return r.forEach(function(i){n.addNodeToCache(i)})})}}),Object.defineProperty(e.prototype,"notifyDied",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(t.identifierAttribute){var n=t.identifier,r=this.cache.get(n);r&&(r.remove(t),r.length||this.cache.delete(n),this.updateLastCacheModificationPerId(t.identifier))}}}),Object.defineProperty(e.prototype,"splitCache",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this,r=new e,i=t.path+"/";return Ike(this.cache).forEach(function(a){for(var s=Eu(a,2),o=s[0],l=s[1],u=!1,f=l.length-1;f>=0;f--){var d=l[f];(d===t||d.path.indexOf(i)===0)&&(r.addNodeToCache(d,!1),l.splice(f,1),l.length||n.cache.delete(o),u=!0)}u&&n.updateLastCacheModificationPerId(o)}),r}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var r=this.cache.get(n);return r?r.some(function(i){return t.isAssignableFrom(i.type)}):!1}}),Object.defineProperty(e.prototype,"resolve",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var r=this.cache.get(n);if(!r)return null;var i=r.filter(function(a){return t.isAssignableFrom(a.type)});switch(i.length){case 0:return null;case 1:return i[0];default:throw new St("Cannot resolve a reference to type '".concat(t.name,"' with id: '").concat(n,"' unambigously, there are multiple candidates: ").concat(i.map(function(a){return a.path}).join(", ")))}}}),e})();function JM(e,t,n,r,i){var a=Zre(i);if(a){if(a.parent)throw new St("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '".concat(t?t.path:"","/").concat(n,"', but it lives already at '").concat(a.path,"'"));return t&&a.setParent(t,n),a}return new Aa(e,t,n,r,i)}function cd(e,t,n,r,i){return new jv(e,t,n,r,i)}function _Oe(e){return e instanceof jv||e instanceof Aa}var Ti;(function(e){e[e.INITIALIZING=0]="INITIALIZING",e[e.CREATED=1]="CREATED",e[e.FINALIZED=2]="FINALIZED",e[e.DETACHING=3]="DETACHING",e[e.DEAD=4]="DEAD"})(Ti||(Ti={}));function Sr(e){return!!(e&&e.$treenode)}function On(e){if(!Sr(e))throw new St("Value ".concat(e," is no MST Node"));return e.$treenode}function Zre(e){return e&&e.$treenode||null}function EOe(){return On(this).snapshot}function SOe(e,t,n){n===void 0&&(n=!0);var r=e;try{for(var i=0;i<t.length;i++){var a=t[i];if(a===".."){if(r=r.parent,r)continue}else{if(a===".")continue;if(r){if(r instanceof jv){var s=r.value;Sr(s)&&(r=On(s))}if(r instanceof Aa){var o=r.getChildType(a);if(o&&(r=r.getChildNode(a),r))continue}}}throw new St("Could not resolve '".concat(a,"' in path '").concat(qz(t.slice(0,i))||"/","' while resolving '").concat(qz(t),"'"))}}catch(l){if(!n)return;throw l}return r}function Qre(e){if(!e)return Vp;var t=Object.keys(e);if(!t.length)return Vp;var n=new Array(t.length);return t.forEach(function(r,i){n[i]=e[r]}),n}var xOe=Object.toString(),Vp=Object.freeze([]),Gp=Object.freeze({}),yw=ike().useProxies?{deep:!1}:{deep:!1,proxy:!1};Object.freeze(yw);var St=(function(e){tr(t,e);function t(n){return n===void 0&&(n="Illegal state"),e.call(this,"[mobx-state-tree] ".concat(n))||this}return t})(Error);function wOe(e){return e}var TOe=Number.isInteger;function COe(e){return Number(e)===e&&e%1!==0}function AOe(e){return Number.isFinite(e)}function Jre(e){return Array.isArray(e)||vl(e)}function eie(e){return e?Jre(e)?e:[e]:Vp}function kOe(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r=0;r<t.length;r++){var i=t[r];for(var a in i)e[a]=i[a]}return e}function up(e){var t;if(e===null||typeof e!="object")return!1;var n=Object.getPrototypeOf(e);return n==null?!0:((t=n.constructor)===null||t===void 0?void 0:t.toString())===xOe}function tie(e){return e!==null&&typeof e=="object"&&!(e instanceof Date)&&!(e instanceof RegExp)}function Bv(e,t){return t===void 0&&(t=!0),e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"||t&&e instanceof Date}function nie(e){return typeof e!="function"}function OOe(e,t,n){Ao(e)?Ire(e,t,n):Object.defineProperty(e,t,n)}function _f(e,t,n){OOe(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}var ROe=(function(){function e(){Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:[]})}return Object.defineProperty(e.prototype,"hasSubscribers",{get:function(){return this.handlers.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var r=this;return n===void 0&&(n=!1),n?this.handlers.unshift(t):this.handlers.push(t),function(){r.unregister(t)}}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this.handlers.indexOf(t)>=0}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this.handlers.indexOf(t);n>=0&&this.handlers.splice(n,1)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.handlers.length=0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=this.handlers.slice();r.forEach(function(i){return i.apply(void 0,Su([],Eu(t),!1))})}}),e})(),rie=(function(){function e(){Object.defineProperty(this,"eventHandlers",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}return Object.defineProperty(e.prototype,"hasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this.eventHandlers&&this.eventHandlers[t];return!!n&&n.hasSubscribers}}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,r){r===void 0&&(r=!1),this.eventHandlers||(this.eventHandlers={});var i=this.eventHandlers[t];return i||(i=this.eventHandlers[t]=new ROe),i.register(n,r)}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var r=this.eventHandlers&&this.eventHandlers[t];return!!r&&r.has(n)}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var r=this.eventHandlers&&this.eventHandlers[t];r&&r.unregister(n)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.eventHandlers&&delete this.eventHandlers[t]}}),Object.defineProperty(e.prototype,"clearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.eventHandlers=void 0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(t){for(var n,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];var a=this.eventHandlers&&this.eventHandlers[t];a&&(n=a).emit.apply(n,Su([],Eu(r),!1))}}),e})();function iie(e){for(var t=new Array(e.length),n=0;n<e.length;n++)t[n]=e[n];return t}function wk(e,t){return e.indexOf(t)===0}function NOe(e){console.warn(new Error("[mobx-state-tree] ".concat(e)))}function IOe(){return typeof process<"u"&&Vz&&Vz.ENABLE_TYPE_CHECK==="true"}function Tk(e){typeof queueMicrotask=="function"?queueMicrotask(e):typeof setImmediate=="function"?setImmediate(e):setTimeout(e,1)}function Ck(e){return DOe(e.name,e)}function DOe(e,t){var n=function(){var i=Kre(),a=qre();if(!a)throw new St("a mst flow must always have a parent context");var s=Yre(a);if(!s)throw new St("a mst flow must always have a parent action context");var o={name:e,id:i,tree:a.tree,context:a.context,parentId:a.id,allParentIds:Su(Su([],Eu(a.allParentIds),!1),[a.id],!1),rootId:a.rootId,parentEvent:a,parentActionEvent:s},l=arguments;function u(f,d,p){return f.$mst_middleware=n.$mst_middleware,ED(Ea(Ea({},o),{type:d,args:[p]}),f)}return new Promise(function(f,d){var p,m=function(){p=t.apply(null,arguments),E(void 0)};m.$mst_middleware=n.$mst_middleware,ED(Ea(Ea({},o),{type:"flow_spawn",args:iie(l)}),m);function E(y){var v;try{var x=u(function(T){v=p.next(T)},"flow_resume",y);x instanceof Error&&(v=p.throw(x))}catch(T){Tk(function(){u(function(w){d(T)},"flow_throw",T)});return}g(v)}function S(y){var v;try{u(function(x){v=p.throw(x)},"flow_resume_error",y)}catch(x){Tk(function(){u(function(T){d(x)},"flow_throw",x)});return}g(v)}function g(y){if(y.done){Tk(function(){u(function(v){f(v)},"flow_return",y.value)});return}if(!y.value||typeof y.value.then!="function")throw new St("Only promises can be yielded to `async`, got: "+y);return y.value.then(E,S)}})};return n._isFlowAction=!0,n}function LOe(e){if(!("oldValue"in e))throw new St("Patches without `oldValue` field cannot be inversed");return[POe(e),MOe(e)]}function POe(e){switch(e.op){case"add":return{op:"add",path:e.path,value:e.value};case"remove":return{op:"remove",path:e.path};case"replace":return{op:"replace",path:e.path,value:e.value}}}function MOe(e){switch(e.op){case"add":return{op:"remove",path:e.path};case"remove":return{op:"add",path:e.path,value:e.oldValue};case"replace":return{op:"replace",path:e.path,value:e.oldValue}}}function jOe(e){return typeof e=="number"}function Ef(e){return jOe(e)===!0?""+e:e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function FOe(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function qz(e){if(e.length===0)return"";var t=function(n){return n.map(Ef).join("/")};return e[0]==="."||e[0]===".."?t(e):"/"+t(e)}function BOe(e){var t=e.split("/").map(FOe),n=e===""||e==="."||e===".."||wk(e,"/")||wk(e,"./")||wk(e,"../");if(!n)throw new St("a json path must be either rooted, empty or relative, but got '".concat(e,"'"));return t[0]===""&&t.shift(),t}var Ak=Symbol("$preProcessorFailed"),UOe=(function(e){tr(t,e);function t(n,r,i){var a=e.call(this,i||n.name)||this;return Object.defineProperty(a,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"_processors",{enumerable:!0,configurable:!0,writable:!0,value:r}),a}return Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|_n.SnapshotProcessor},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"snapshotProcessor(".concat(this._subtype.describe(),")")}}),Object.defineProperty(t.prototype,"preProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this._processors.preProcessor?this._processors.preProcessor.call(null,n):n}}),Object.defineProperty(t.prototype,"preProcessSnapshotSafe",{enumerable:!1,configurable:!0,writable:!0,value:function(n){try{return this.preProcessSnapshot(n)}catch{return Ak}}}),Object.defineProperty(t.prototype,"postProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return this._processors.postProcessor?this._processors.postProcessor.call(null,n,r.storedValue):n}}),Object.defineProperty(t.prototype,"_fixNode",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this;$Oe(n.type,this,"create"),n instanceof Aa&&(n.hasSnapshotPostProcessor=!!this._processors.postProcessor);var i=n.getSnapshot;n.getSnapshot=function(){return r.postProcessSnapshot(i.call(n),n)},oRe(this._subtype)||(n.getReconciliationType=function(){return r})}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=Sr(a)?a:this.preProcessSnapshot(a),o=this._subtype.instantiate(n,r,i,s);return this._fixNode(o),o}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=this._subtype.reconcile(n,Sr(r)?r:this.preProcessSnapshot(r),i,a);return s!==n&&this._fixNode(s),s}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){r===void 0&&(r=!0);var i=this._subtype.getSnapshot(n);return r?this.postProcessSnapshot(i,n):i}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this.preProcessSnapshotSafe(n);return i===Ak?Na(r,n,"Failed to preprocess value"):this._subtype.validate(i,r)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),Object.defineProperty(t.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=wu(n)?this._subtype:Sr(n)?n:this.preProcessSnapshotSafe(n);return r===Ak?!1:this._subtype.validate(r,[{path:"",type:this._subtype}]).length===0}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this._subtype.isAssignableFrom(n)}}),Object.defineProperty(t.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){if(!(this._subtype instanceof Wp))return!1;var i=this.preProcessSnapshot(r);return this._subtype.isMatchingSnapshotId(n,i)}}),t})(xu);function $Oe(e,t){for(var n,r,i=[],a=2;a<arguments.length;a++)i[a-2]=arguments[a];try{for(var s=qb(i),o=s.next();!o.done;o=s.next()){var l=o.value;e[l]=t[l].bind(t)}}catch(u){n={error:u}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}}function zOe(e,t,n){return new UOe(e,t,n)}var Kz="Map.put can only be used to store complex values that have an identifier type attribute";function aie(e,t){var n,r,i=e.getSubTypes();if(i===Gre)return!1;if(i){var a=eie(i);try{for(var s=qb(a),o=s.next();!o.done;o=s.next()){var l=o.value;if(!aie(l,t))return!1}}catch(u){n={error:u}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}}return e instanceof Uv&&t.push(e),!0}var xc;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.YES=1]="YES",e[e.NO=2]="NO"})(xc||(xc={}));var HOe=(function(e){tr(t,e);function t(n,r){return e.call(this,n,fr.ref.enhancer,r)||this}return Object.defineProperty(t.prototype,"get",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return e.prototype.get.call(this,""+n)}}),Object.defineProperty(t.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return e.prototype.has.call(this,""+n)}}),Object.defineProperty(t.prototype,"delete",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return e.prototype.delete.call(this,""+n)}}),Object.defineProperty(t.prototype,"set",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return e.prototype.set.call(this,""+n,r)}}),Object.defineProperty(t.prototype,"put",{enumerable:!1,configurable:!0,writable:!0,value:function(n){if(!n)throw new St("Map.put cannot be used to set empty values");if(Sr(n)){var r=On(n);if(r.identifier===null)throw new St(Kz);return this.set(r.identifier,n),n}else if(tie(n)){var i=On(this),a=i.type;if(a.identifierMode!==xc.YES)throw new St(Kz);var s=a.mapIdentifierAttribute,o=n[s];if(!e3(o)){var l=this.put(a.getChildType().create(n,i.environment));return this.put(rOe(l))}var u=f0(o);return this.set(u,n),this.get(u)}else throw new St("Map.put can only be used to store complex values")}}),t})(YM),uS=(function(e){tr(t,e);function t(n,r,i){i===void 0&&(i=[]);var a=e.call(this,n)||this;return Object.defineProperty(a,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"identifierMode",{enumerable:!0,configurable:!0,writable:!0,value:xc.UNKNOWN}),Object.defineProperty(a,"mapIdentifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"flags",{enumerable:!0,configurable:!0,writable:!0,value:_n.Map}),Object.defineProperty(a,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),a._determineIdentifierMode(),a.hookInitializers=i,a}return Object.defineProperty(t.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this.hookInitializers.length>0?this.hookInitializers.concat(n):[n];return new t(this.name,this._subType,r)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return this._determineIdentifierMode(),JM(this,n,r,i,a)}}),Object.defineProperty(t.prototype,"_determineIdentifierMode",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.identifierMode===xc.UNKNOWN){var n=[];if(aie(this._subType,n)){var r=n.reduce(function(i,a){if(!a.identifierAttribute)return i;if(i&&i!==a.identifierAttribute)throw new St("The objects in a map should all have the same identifier attribute, expected '".concat(i,"', but child of type '").concat(a.name,"' declared attribute '").concat(a.identifierAttribute,"' as identifier"));return a.identifierAttribute},void 0);r?(this.identifierMode=xc.YES,this.mapIdentifierAttribute=r):this.identifierMode=xc.NO}}}}),Object.defineProperty(t.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){r===void 0&&(r={});var i=n.type._subType,a={};return Object.keys(r).forEach(function(s){a[s]=i.instantiate(n,s,void 0,r[s])}),a}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return new HOe(n,this.name)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){kre(r,n.unbox);var i=n.type;i.hookInitializers.forEach(function(a){var s=a(r);Object.keys(s).forEach(function(o){var l=s[o],u=Fv(r,o,l);_f(r,o,u)})}),GM(r,this.willChange),qM(r,this.didChange)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return Rre(n.storedValue)}}),Object.defineProperty(t.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=n.storedValue.get(""+r);if(!i)throw new St("Not a child "+r);return i}}),Object.defineProperty(t.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=On(n.object),i=n.name;r.assertWritable({subpath:i});var a=r.type,s=a._subType;switch(n.type){case"update":{var o=n.newValue,l=n.object.get(i);if(o===l)return null;du(s,o),n.newValue=s.reconcile(r.getChildNode(i),n.newValue,r,i),a.processIdentifier(i,n.newValue)}break;case"add":du(s,n.newValue),n.newValue=s.instantiate(r,i,void 0,n.newValue),a.processIdentifier(i,n.newValue);break}return n}}),Object.defineProperty(t.prototype,"processIdentifier",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){if(this.identifierMode===xc.YES&&r instanceof Aa){var i=r.identifier;if(i!==n)throw new St("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '".concat(i,"', but expected: '").concat(n,"'"))}}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r={};return n.getChildren().forEach(function(i){r[i.subpath]=i.snapshot}),r}}),Object.defineProperty(t.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r={};return Object.keys(n).forEach(function(i){r[i]=n[i].getSnapshot()}),r}}),Object.defineProperty(t.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=On(n.object);switch(n.type){case"update":return void r.emitPatch({op:"replace",path:Ef(n.name),value:n.newValue.snapshot,oldValue:n.oldValue?n.oldValue.snapshot:void 0},r);case"add":return void r.emitPatch({op:"add",path:Ef(n.name),value:n.newValue.snapshot,oldValue:void 0},r);case"delete":var i=n.oldValue.snapshot;return n.oldValue.die(),void r.emitPatch({op:"remove",path:Ef(n.name),oldValue:i},r)}}}),Object.defineProperty(t.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i){var a=n.storedValue;switch(i.op){case"add":case"replace":a.set(r,i.value);break;case"remove":a.delete(r);break}}}),Object.defineProperty(t.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){du(this,r);var i=n.storedValue,a={};if(Array.from(i.keys()).forEach(function(o){a[o]=!1}),r)for(var s in r)i.set(s,r[s]),a[""+s]=!0;Object.keys(a).forEach(function(o){a[o]===!1&&i.delete(o)})}}),Object.defineProperty(t.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this;return up(n)?vw(Object.keys(n).map(function(a){return i._subType.validate(n[a],QM(r,a,i._subType))})):Na(r,n,"Value is not a plain object")}}),Object.defineProperty(t.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Gp}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){n.storedValue.delete(r)}}),t})(Wp);uS.prototype.applySnapshot=ti(uS.prototype.applySnapshot);function WOe(e){return new uS("Map<string, ".concat(e.name,">"),e)}var cS=(function(e){tr(t,e);function t(n,r,i){i===void 0&&(i=[]);var a=e.call(this,n)||this;return Object.defineProperty(a,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"flags",{enumerable:!0,configurable:!0,writable:!0,value:_n.Array}),Object.defineProperty(a,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),a.hookInitializers=i,a}return Object.defineProperty(t.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this.hookInitializers.length>0?this.hookInitializers.concat(n):[n];return new t(this.name,this._subType,r)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return JM(this,n,r,i,a)}}),Object.defineProperty(t.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){r===void 0&&(r=[]);var i=n.type._subType,a={};return r.forEach(function(s,o){var l=""+o;a[l]=i.instantiate(n,l,void 0,s)}),a}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=Ea(Ea({},yw),{name:this.name});return fr.array(Qre(n),r)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){dl(r).dehancer=n.unbox;var i=n.type;i.hookInitializers.forEach(function(a){var s=a(r);Object.keys(s).forEach(function(o){var l=s[o],u=Fv(r,o,l);_f(r,o,u)})}),GM(r,this.willChange),qM(r,this.didChange)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return n.storedValue.slice()}}),Object.defineProperty(t.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=Number(r);if(i<n.storedValue.length)return n.storedValue[i];throw new St("Not a child: "+r)}}),Object.defineProperty(t.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=On(n.object);r.assertWritable({subpath:""+n.index});var i=r.type._subType,a=r.getChildren();switch(n.type){case"update":{if(n.newValue===n.object[n.index])return null;var s=Yz(r,i,[a[n.index]],[n.newValue],[n.index]);if(!s)return null;n.newValue=s[0]}break;case"splice":{var o=n.index,l=n.removedCount,u=n.added,f=Yz(r,i,a.slice(o,o+l),u,u.map(function(p,m){return o+m}));if(!f)return null;n.added=f;for(var d=o+l;d<a.length;d++)a[d].setParent(r,""+(d+u.length-l))}break}return n}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return n.getChildren().map(function(r){return r.snapshot})}}),Object.defineProperty(t.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=[];return Object.keys(n).forEach(function(i){r.push(n[i].getSnapshot())}),r}}),Object.defineProperty(t.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=On(n.object);switch(n.type){case"update":return void r.emitPatch({op:"replace",path:""+n.index,value:n.newValue.snapshot,oldValue:n.oldValue?n.oldValue.snapshot:void 0},r);case"splice":if(n.removedCount&&n.addedCount===n.object.length)return void r.emitPatch({op:"replace",path:"",value:r.snapshot,oldValue:n.removed.map(function(a){return a.snapshot})},r);for(var i=n.removedCount-1;i>=0;i--)r.emitPatch({op:"remove",path:""+(n.index+i),oldValue:n.removed[i].snapshot},r);for(var i=0;i<n.addedCount;i++)r.emitPatch({op:"add",path:""+(n.index+i),value:n.added[i].snapshot,oldValue:void 0},r);return}}}),Object.defineProperty(t.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i){var a=n.storedValue,s=r==="-"?a.length:Number(r);switch(i.op){case"replace":a[s]=i.value;break;case"add":a.splice(s,0,i.value);break;case"remove":a.splice(s,1);break}}}),Object.defineProperty(t.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){du(this,r);var i=n.storedValue;i.replace(r)}}),Object.defineProperty(t.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this;return Jre(n)?vw(n.map(function(a,s){return i._subType.validate(a,QM(r,""+s,i._subType))})):Na(r,n,"Value is not an array")}}),Object.defineProperty(t.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Vp}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){n.storedValue.splice(Number(r),1)}}),t})(Wp);cS.prototype.applySnapshot=ti(cS.prototype.applySnapshot);function VOe(e){return new cS("".concat(e.name,"[]"),e)}function Yz(e,t,n,r,i){for(var a=!0,s=0;;s++){var o=s<=r.length-1,l=n[s],u=o?r[s]:void 0,f=""+i[s];if(_Oe(u)&&(u=u.storedValue),!l&&!o)break;if(!o)a=!1,n.splice(s,1),l instanceof Aa&&l.createObservableInstanceIfNeeded(),l.die(),s--;else if(l)if(Xz(l,u))n[s]=kk(t,e,f,u,l);else{for(var p=void 0,m=s;m<n.length;m++)if(Xz(n[m],u)){p=n.splice(m,1)[0];break}a=!1;var d=kk(t,e,f,u,p);n.splice(s,0,d)}else{if(Sr(u)&&On(u).parent===e)throw new St("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '".concat(e.path,"/").concat(f,"', but it lives already at '").concat(On(u).path,"'"));a=!1;var d=kk(t,e,f,u);n.splice(s,0,d)}}return a?null:n}function kk(e,t,n,r,i){du(e,r);function a(){if(Sr(r)){var o=On(r);if(o.assertAlive(Gp),o.parent!==null&&o.parent===t)return o.setParent(t,n),o}return i?e.reconcile(i,r,t,n):e.instantiate(t,n,void 0,r)}var s=a();return i&&i!==s&&(i instanceof Aa&&i.createObservableInstanceIfNeeded(),i.die()),s}function Xz(e,t){if(!e.isAlive)return!1;if(Sr(t)){var n=On(t);return n.isAlive&&n===e}if(e.snapshot===t)return!0;if(!(e instanceof Aa))return!1;var r=e.getReconciliationType();return e.identifier!==null&&e.identifierAttribute&&up(t)&&r.is(t)&&r.isMatchingSnapshotId(e,t)}var Zz="preProcessSnapshot",Qz="postProcessSnapshot";function GOe(){return On(this).toString()}var Jz={name:"AnonymousModel",properties:{},initializers:Vp};function qOe(e){var t=Object.keys(e),n=new Set;return t.forEach(function(r){if(n.has(r))throw new St("".concat(r," is declared twice in the model. Model should not contain the same keys"));n.add(r)}),t.reduce(function(r,i){if(i in ei)throw new St("Hook '".concat(i,"' was defined as property. Hooks should be defined as part of the actions"));var a=Object.getOwnPropertyDescriptor(e,i);if("get"in a)throw new St("Getters are not supported as properties. Please use views instead");var s=a.value;if(s==null)throw new St("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");if(Bv(s))r[i]=Sf(eRe(s),s);else if(s instanceof uS)r[i]=Sf(s,{});else if(s instanceof cS)r[i]=Sf(s,[]);else if(!wu(s))throw new St("Invalid type definition for property '".concat(i,"', cannot infer a type from a value like '").concat(s,"' (").concat(typeof s,")"));return r},Ea({},e))}var Uv=(function(e){tr(t,e);function t(n){var r=e.call(this,n.name||Jz.name)||this;return Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:_n.Object}),Object.defineProperty(r,"initializers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"properties",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"preProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"postProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"propertyNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"named",{enumerable:!0,configurable:!0,writable:!0,value:function(i){return r.cloneAndEnhance({name:i})}}),Object.defineProperty(r,"props",{enumerable:!0,configurable:!0,writable:!0,value:function(i){return r.cloneAndEnhance({properties:i})}}),Object.defineProperty(r,"preProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(i){var a=r.preProcessor;return a?r.cloneAndEnhance({preProcessor:function(s){return a(i(s))}}):r.cloneAndEnhance({preProcessor:i})}}),Object.defineProperty(r,"postProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(i){var a=r.postProcessor;return a?r.cloneAndEnhance({postProcessor:function(s){return i(a(s))}}):r.cloneAndEnhance({postProcessor:i})}}),Object.assign(r,Jz,n),r.properties=qOe(r.properties),r.properties,r.propertyNames=Object.keys(r.properties),r.identifierAttribute=r._getIdentifierAttribute(),r}return Object.defineProperty(t.prototype,"_getIdentifierAttribute",{enumerable:!1,configurable:!0,writable:!0,value:function(){var n=void 0;return this.forAllProps(function(r,i){if(i.flags&_n.Identifier){if(n)throw new St("Cannot define property '".concat(r,"' as object identifier, property '").concat(n,"' is already defined as identifier property"));n=r}}),n}}),Object.defineProperty(t.prototype,"cloneAndEnhance",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return new t({name:n.name||this.name,properties:Object.assign({},this.properties,n.properties),initializers:this.initializers.concat(n.initializers||[]),preProcessor:n.preProcessor||this.preProcessor,postProcessor:n.postProcessor||this.postProcessor})}}),Object.defineProperty(t.prototype,"actions",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this,i=function(a){return r.instantiateActions(a,n(a)),a};return this.cloneAndEnhance({initializers:[i]})}}),Object.defineProperty(t.prototype,"instantiateActions",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this;if(!up(r))throw new St("actions initializer should return a plain object containing actions");Object.getOwnPropertyNames(r).forEach(function(a){if(a in i.properties)throw new St("'".concat(a,"' is a property and cannot be declared as an action"));if(a===Zz)throw new St("Cannot define action '".concat(Zz,"', it should be defined using 'type.preProcessSnapshot(fn)' instead"));if(a===Qz)throw new St("Cannot define action '".concat(Qz,"', it should be defined using 'type.postProcessSnapshot(fn)' instead"));var s=r[a],o=n[a];if(a in ei&&o){var l=s;s=function(){o.apply(null,arguments),l.apply(null,arguments)}}var u=s.$mst_middleware,f=s.bind(r);f._isFlowAction=s._isFlowAction||!1,f.$mst_middleware=u;var d=Fv(n,a,f);r[a]=d,_f(n,a,d)})}}),Object.defineProperty(t.prototype,"volatile",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this;if(typeof n!="function")throw new St("You passed an ".concat(typeof n," to volatile state as an argument, when function is expected"));var i=function(a){return r.instantiateVolatileState(a,n(a)),a};return this.cloneAndEnhance({initializers:[i]})}}),Object.defineProperty(t.prototype,"instantiateVolatileState",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this;if(!up(r))throw new St("volatile state initializer should return a plain object containing state");Object.getOwnPropertyNames(r).forEach(function(a){if(a in i.properties)throw new St("'".concat(a,"' is a property and cannot be declared as volatile state"));Nre(n,a,r[a])})}}),Object.defineProperty(t.prototype,"extend",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this,i=function(a){var s=n(a),o=s.actions,l=s.views,u=s.state,f=tOe(s,["actions","views","state"]);for(var d in f)throw new St("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '".concat(d,"'"));return u&&r.instantiateVolatileState(a,u),l&&r.instantiateViews(a,l),o&&r.instantiateActions(a,o),a};return this.cloneAndEnhance({initializers:[i]})}}),Object.defineProperty(t.prototype,"views",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this,i=function(a){return r.instantiateViews(a,n(a)),a};return this.cloneAndEnhance({initializers:[i]})}}),Object.defineProperty(t.prototype,"instantiateViews",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this;if(!up(r))throw new St("views initializer should return a plain object containing views");Object.getOwnPropertyNames(r).forEach(function(a){var s;if(a in i.properties)throw new St("'".concat(a,"' is a property and cannot be declared as a view"));var o=Object.getOwnPropertyDescriptor(r,a);if("get"in o)Ire(n,a,o),Lre(n,(s={},s[a]=Bm,s));else if(typeof o.value=="function")_f(n,a,o.value);else throw new St("A view member should either be a function or getter based property")})}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=Sr(a)?a:this.applySnapshotPreProcessor(a);return JM(this,n,r,i,s)}}),Object.defineProperty(t.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){r===void 0&&(r={});var i=n.type,a={};return i.forAllProps(function(s,o){a[s]=o.instantiate(n,s,void 0,r[s])}),a}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=Ea(Ea({},yw),{name:this.name});return fr.object(n,Gp,r)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){_f(r,"toString",GOe),this.forAllProps(function(i){kre(r,i,n.unbox)}),this.initializers.reduce(function(i,a){return a(i)},r),GM(r,this.willChange),qM(r,this.didChange)}}),Object.defineProperty(t.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=n,i=On(r.object),a=r.name;i.assertWritable({subpath:a});var s=i.type.properties[a];return s&&(du(s,r.newValue),r.newValue=s.reconcile(i.getChildNode(a),r.newValue,i,a)),r}}),Object.defineProperty(t.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=n,i=On(r.object),a=i.type.properties[r.name];if(a){var s=r.oldValue?r.oldValue.snapshot:void 0;i.emitPatch({op:"replace",path:Ef(r.name),value:r.newValue.snapshot,oldValue:s},i)}}}),Object.defineProperty(t.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this,i=[];return this.forAllProps(function(a){i.push(r.getChildNode(n,a))}),i}}),Object.defineProperty(t.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i;if(!(r in this.properties))throw new St("Not a value property: "+r);var a=dl(n.storedValue,r),s=(i=a.raw)===null||i===void 0?void 0:i.call(a);if(!s)throw new St("Node not available for property "+r);return s}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this;r===void 0&&(r=!0);var a={};return this.forAllProps(function(s,o){var l=Hp(n.storedValue,s);l.reportObserved(),a[s]=i.getChildNode(n,s).snapshot}),r?this.applySnapshotPostProcessor(a):a}}),Object.defineProperty(t.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r={};return Object.keys(n).forEach(function(i){r[i]=n[i].getSnapshot()}),this.applySnapshotPostProcessor(r)}}),Object.defineProperty(t.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i){if(!(i.op==="replace"||i.op==="add"))throw new St("object does not support operation ".concat(i.op));n.storedValue[r]=i.value}}),Object.defineProperty(t.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){du(this,r);var i=this.applySnapshotPreProcessor(r);this.forAllProps(function(a){n.storedValue[a]=i[a]})}}),Object.defineProperty(t.prototype,"applySnapshotPreProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this.preProcessor;return r?r.call(null,n):n}}),Object.defineProperty(t.prototype,"applySnapshotPostProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this.postProcessor;return r?r.call(null,n):n}}),Object.defineProperty(t.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this.properties[n]}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this,a=this.applySnapshotPreProcessor(n);return up(a)?vw(this.propertyNames.map(function(s){return i.properties[s].validate(a[s],QM(r,s,i.properties[s]))})):Na(r,a,"Value is not a plain object")}}),Object.defineProperty(t.prototype,"forAllProps",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this;this.propertyNames.forEach(function(i){return n(i,r.properties[i])})}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var n=this;return"{ "+this.propertyNames.map(function(r){return r+": "+n.properties[r].describe()}).join("; ")+" }"}}),Object.defineProperty(t.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Gp}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){n.storedValue[r]=void 0}}),t})(Wp);Uv.prototype.applySnapshot=ti(Uv.prototype.applySnapshot);function KOe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=typeof e[0]=="string"?e.shift():"AnonymousModel",r=e.shift()||{};return new Uv({name:n,properties:r})}function YOe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=typeof e[0]=="string",r=n?e[0]:"AnonymousModel";return n&&e.shift(),e.reduce(function(i,a){return i.cloneAndEnhance({name:i.name+"_"+a.name,properties:a.properties,initializers:a.initializers,preProcessor:function(s){return a.applySnapshotPreProcessor(i.applySnapshotPreProcessor(s))},postProcessor:function(s){return a.applySnapshotPostProcessor(i.applySnapshotPostProcessor(s))}})}).named(r)}function XOe(e){return wu(e)&&(e.flags&_n.Object)>0}var Pu=(function(e){tr(t,e);function t(n,r,i,a){a===void 0&&(a=wOe);var s=e.call(this,n)||this;return Object.defineProperty(s,"flags",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(s,"checker",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(s,"initializer",{enumerable:!0,configurable:!0,writable:!0,value:a}),s.flags=r,s}return Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return cd(this,n,r,i,a)}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this.initializer(n)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){if(Bv(n)&&this.checker(n))return ka();var i=this.name==="Date"?"Date or a unix milliseconds timestamp":this.name;return Na(r,n,"Value is not a ".concat(i))}}),t})(Jf),sie=new Pu("string",_n.String,function(e){return typeof e=="string"}),oie=new Pu("number",_n.Number,function(e){return typeof e=="number"}),ZOe=new Pu("integer",_n.Integer,function(e){return TOe(e)}),QOe=new Pu("float",_n.Float,function(e){return COe(e)}),JOe=new Pu("finite",_n.Finite,function(e){return AOe(e)}),lie=new Pu("boolean",_n.Boolean,function(e){return typeof e=="boolean"}),uie=new Pu("null",_n.Null,function(e){return e===null}),cie=new Pu("undefined",_n.Undefined,function(e){return e===void 0}),die=new Pu("Date",_n.Date,function(e){return typeof e=="number"||e instanceof Date},function(e){return e instanceof Date?e:new Date(e)});die.getSnapshot=function(e){return e.storedValue.getTime()};var fie=die;function eRe(e){switch(typeof e){case"string":return sie;case"number":return oie;case"boolean":return lie;case"object":if(e instanceof Date)return fie}throw new St("Cannot determine primitive type from value "+e)}function tRe(e){return wu(e)&&(e.flags&(_n.String|_n.Number|_n.Integer|_n.Boolean|_n.Date))>0}var nRe=(function(e){tr(t,e);function t(n){var r=e.call(this,JSON.stringify(n))||this;return Object.defineProperty(r,"value",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:_n.Literal}),r.value=n,r}return Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return cd(this,n,r,i,a)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return JSON.stringify(this.value)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return Bv(n)&&n===this.value?ka():Na(r,n,"Value is not a literal ".concat(JSON.stringify(this.value)))}}),t})(Jf);function hie(e){return new nRe(e)}var rRe=(function(e){tr(t,e);function t(n,r,i,a){var s=e.call(this,n)||this;return Object.defineProperty(s,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(s,"_predicate",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(s,"_message",{enumerable:!0,configurable:!0,writable:!0,value:a}),s}return Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|_n.Refinement},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return this._subtype.instantiate(n,r,i,a)}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this._subtype.isAssignableFrom(n)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this._subtype.validate(n,r);if(i.length>0)return i;var a=Sr(n)?On(n).snapshot:n;return this._predicate(a)?ka():Na(r,n,this._message(n))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return this._subtype.reconcile(n,r,i,a)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),t})(xu);function iRe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=typeof e[0]=="string"?e.shift():wu(e[0])?e[0].name:null,r=e[0],i=e[1],a=e[2]?e[2]:function(s){return"Value does not respect the refinement predicate"};return new rRe(n,r,i,a)}function aRe(e,t){var n=typeof e=="string"?t:e,r=_w.apply(void 0,Su([],Eu(n.map(function(i){return hie(""+i)})),!1));return typeof e=="string"&&(r.name=e),r}var sRe=(function(e){tr(t,e);function t(n,r,i){var a=e.call(this,n)||this;return Object.defineProperty(a,"_types",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"_dispatcher",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"_eager",{enumerable:!0,configurable:!0,writable:!0,value:!0}),i=Ea({eager:!0,dispatcher:void 0},i),a._dispatcher=i.dispatcher,i.eager||(a._eager=!1),a}return Object.defineProperty(t.prototype,"flags",{get:function(){var n=_n.Union;return this._types.forEach(function(r){n|=r.flags}),n},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this._types.some(function(r){return r.isAssignableFrom(n)})}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"("+this._types.map(function(n){return n.describe()}).join(" | ")+")"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=this.determineType(a,void 0);if(!s)throw new St("No matching type for union "+this.describe());return s.instantiate(n,r,i,a)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=this.determineType(r,n.getReconciliationType());if(!s)throw new St("No matching type for union "+this.describe());return s.reconcile(n,r,i,a)}}),Object.defineProperty(t.prototype,"determineType",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return this._dispatcher?this._dispatcher(n):r?r.is(n)?r:this._types.filter(function(i){return i!==r}).find(function(i){return i.is(n)}):this._types.find(function(i){return i.is(n)})}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){if(this._dispatcher)return this._dispatcher(n).validate(n,r);for(var i=[],a=0,s=0;s<this._types.length;s++){var o=this._types[s],l=o.validate(n,r);if(l.length===0){if(this._eager)return ka();a++}else i.push(l)}return a===1?ka():Na(r,n,"No type is applicable for the union").concat(vw(i))}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._types}}),t})(xu);function _w(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=wu(e)?void 0:e,i=wu(e)?Su([e],Eu(t),!1):t,a="("+i.map(function(s){return s.name}).join(" | ")+")";return new sRe(a,i,r)}function oRe(e){return wu(e)&&(e.flags&_n.Union)>0}var lRe=(function(e){tr(t,e);function t(n,r,i){var a=e.call(this,n.name)||this;return Object.defineProperty(a,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"_defaultValue",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"optionalValues",{enumerable:!0,configurable:!0,writable:!0,value:i}),a}return Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|_n.Optional},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype.describe()+"?"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){if(this.optionalValues.indexOf(a)>=0){var s=this.getDefaultInstanceOrSnapshot();return this._subtype.instantiate(n,r,i,s)}return this._subtype.instantiate(n,r,i,a)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return this._subtype.reconcile(n,this.optionalValues.indexOf(r)<0&&this._subtype.is(r)?r:this.getDefaultInstanceOrSnapshot(),i,a)}}),Object.defineProperty(t.prototype,"getDefaultInstanceOrSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var n=typeof this._defaultValue=="function"?this._defaultValue():this._defaultValue;return typeof this._defaultValue=="function"&&du(this,n),n}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return this.optionalValues.indexOf(n)>=0?ka():this._subtype.validate(n,r)}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this._subtype.isAssignableFrom(n)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),t})(xu);function uRe(e,t){if(typeof t!="function"&&Sr(t))throw new St("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead")}function Sf(e,t,n){return uRe(e,t),new lRe(e,t,n||cRe)}var cRe=[void 0],dRe=Sf(cie,void 0),fRe=Sf(uie,null);function pie(e){return _w(e,dRe)}function hRe(e){return _w(e,fRe)}var pRe=(function(e){tr(t,e);function t(n,r){var i=e.call(this,n)||this;return Object.defineProperty(i,"_definition",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),i}return Object.defineProperty(t.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|_n.Late},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"getSubType",{enumerable:!1,configurable:!0,writable:!0,value:function(n){if(!this._subType){var r=void 0;try{r=this._definition()}catch(i){if(i instanceof ReferenceError)r=void 0;else throw i}if(n&&r===void 0)throw new St("Late type seems to be used too early, the definition (still) returns undefined");r&&(this._subType=r)}return this._subType}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return this.getSubType(!0).instantiate(n,r,i,a)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return this.getSubType(!0).reconcile(n,r,i,a)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var n=this.getSubType(!1);return n?n.name:"<uknown late type>"}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this.getSubType(!1);return i?i.validate(n,r):ka()}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this.getSubType(!1);return r?r.isAssignableFrom(n):!1}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){var n=this.getSubType(!1);return n||Gre}}),t})(xu);function mRe(e,t){var n=typeof e=="string"?e:"late(".concat(e.toString(),")"),r=typeof e=="string"?t:e;return new pRe(n,r)}function gRe(e,t){return new bRe(e,t)}var bRe=(function(e){tr(t,e);function t(n,r){var i=e.call(this,n)||this;return Object.defineProperty(i,"options",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:_n.Lazy}),Object.defineProperty(i,"loadedType",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(i,"pendingNodeList",{enumerable:!0,configurable:!0,writable:!0,value:fr.array()}),Lz(function(){return i.pendingNodeList.length>0&&i.pendingNodeList.some(function(a){return a.isAlive&&i.options.shouldLoadPredicate(a.parent?a.parent.value:null)})},function(){i.options.loadType().then(ti(function(a){i.loadedType=a,i.pendingNodeList.forEach(function(s){s.parent&&i.loadedType&&s.parent.applyPatches([{op:"replace",path:"/".concat(s.subpath),value:s.snapshot}])})}))}),i}return Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"<lazy ".concat(this.name,">")}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=this;if(this.loadedType)return this.loadedType.instantiate(n,r,i,a);var o=cd(this,n,r,i,a);return this.pendingNodeList.push(o),Lz(function(){return!o.isAlive},function(){return s.pendingNodeList.splice(s.pendingNodeList.indexOf(o),1)}),o}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return this.loadedType?this.loadedType.validate(n,r):nie(n)?ka():Na(r,n,"Value is not serializable and cannot be lazy")}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return this.loadedType?(n.die(),this.loadedType.instantiate(i,a,i.environment,r)):e.prototype.reconcile.call(this,n,r,i,a)}}),t})(Jf),mie=(function(e){tr(t,e);function t(n){var r=e.call(this,n?"frozen(".concat(n.name,")"):"frozen")||this;return Object.defineProperty(r,"subType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:_n.Frozen}),r}return Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"<any immutable value>"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return cd(this,n,r,i,a)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return nie(n)?this.subType?this.subType.validate(n,r):ka():Na(r,n,"Value is not serializable and cannot be frozen")}}),t})(Jf),eH=new mie;function vRe(e){return arguments.length===0?eH:wu(e)?new mie(e):Sf(eH,e)}function yRe(e){switch(e){case ei.beforeDestroy:return"destroy";case ei.beforeDetach:return"detach";default:return}}var _Re=(function(){function e(t,n){if(Object.defineProperty(this,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"node",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"resolvedReference",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e3(t))this.identifier=t;else if(Sr(t)){var r=On(t);if(!r.identifierAttribute)throw new St("Can only store references with a defined identifier attribute.");var i=r.unnormalizedIdentifier;if(i==null)throw new St("Can only store references to tree nodes with a defined identifier.");this.identifier=i}else throw new St("Can only store references to tree nodes or identifiers, got: '".concat(t,"'"))}return Object.defineProperty(e.prototype,"updateResolvedReference",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=f0(this.identifier),r=t.root,i=r.identifierCache.getLastCacheModificationPerId(n);if(!this.resolvedReference||this.resolvedReference.lastCacheModification!==i){var a=this.targetType,s=r.identifierCache.resolve(a,n);if(!s)throw new ERe("[mobx-state-tree] Failed to resolve reference '".concat(this.identifier,"' to type '").concat(this.targetType.name,"' (from node: ").concat(t.path,")"));this.resolvedReference={node:s,lastCacheModification:i}}}}),Object.defineProperty(e.prototype,"resolvedValue",{get:function(){return this.updateResolvedReference(this.node),this.resolvedReference.node.value},enumerable:!1,configurable:!0}),e})(),ERe=(function(e){tr(t,e);function t(n){var r=e.call(this,n)||this;return Object.setPrototypeOf(r,t.prototype),r}return t})(Error),gie=(function(e){tr(t,e);function t(n,r){var i=e.call(this,"reference(".concat(n.name,")"))||this;return Object.defineProperty(i,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(i,"onInvalidated",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:_n.Reference}),i}return Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this.targetType.isAssignableFrom(n)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return e3(n)?ka():Na(r,n,"Value is not a valid identifier, which is a string or a number")}}),Object.defineProperty(t.prototype,"fireInvalidated",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=r.parent;if(!(!s||!s.isAlive)){var o=s.storedValue;o&&this.onInvalidated({cause:n,parent:o,invalidTarget:a?a.storedValue:void 0,invalidId:i,replaceRef:function(l){Mv(r.root.storedValue,{op:"replace",value:l,path:r.path})},removeRef:function(){XOe(s.type)?this.replaceRef(void 0):Mv(r.root.storedValue,{op:"remove",path:r.path})}})}}}),Object.defineProperty(t.prototype,"addTargetNodeWatcher",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this,a=this.getValue(n);if(a){var s=On(a),o=function(f,d){var p=yRe(d);p&&i.fireInvalidated(p,n,r,s)},l=s.registerHook(ei.beforeDetach,o),u=s.registerHook(ei.beforeDestroy,o);return function(){l(),u()}}}}),Object.defineProperty(t.prototype,"watchTargetNodeForInvalidations",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i){var a=this;if(this.onInvalidated){var s;n.registerHook(ei.beforeDestroy,function(){s&&s()});var o=function(l){s&&s();var u=n.parent,f=u&&u.storedValue;if(u&&u.isAlive&&f){var d=void 0;i?d=!!i.get(r,f):d=n.root.identifierCache.has(a.targetType,f0(r)),d?s=a.addTargetNodeWatcher(n,r):l||a.fireInvalidated("invalidSnapshotReference",n,r,null)}};n.state===Ti.FINALIZED?o(!0):(n.isRoot||n.root.registerHook(ei.afterCreationFinalization,function(){n.parent&&n.parent.createObservableInstanceIfNeeded()}),n.registerHook(ei.afterAttach,function(){o(!1)}))}}}),t})(Jf),SRe=(function(e){tr(t,e);function t(n,r){return e.call(this,n,r)||this}return Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(n){if(n.isAlive){var r=n.storedValue;return r.resolvedValue}}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=n.storedValue;return r.identifier}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=Sr(a)?aOe(a):a,o=new _Re(a,this.targetType),l=cd(this,n,r,i,o);return o.node=l,this.watchTargetNodeForInvalidations(l,s,void 0),l}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){if(!n.isDetaching&&n.type===this){var s=Sr(r),o=n.storedValue;if(!s&&o.identifier===r||s&&o.resolvedValue===r)return n.setParent(i,a),n}var l=this.instantiate(i,a,void 0,r);return n.die(),l}}),t})(gie),xRe=(function(e){tr(t,e);function t(n,r,i){var a=e.call(this,n,i)||this;return Object.defineProperty(a,"options",{enumerable:!0,configurable:!0,writable:!0,value:r}),a}return Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(n){if(n.isAlive){var r=this.options.get(n.storedValue,n.parent?n.parent.storedValue:null);return r}}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return n.storedValue}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=Sr(a)?this.options.set(a,n?n.storedValue:null):a,o=cd(this,n,r,i,s);return this.watchTargetNodeForInvalidations(o,s,this.options),o}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=Sr(r)?this.options.set(r,n?n.storedValue:null):r;if(!n.isDetaching&&n.type===this&&n.storedValue===s)return n.setParent(i,a),n;var o=this.instantiate(i,a,void 0,s);return n.die(),o}}),t})(gie);function bie(e,t){var n=t||void 0,r=t?t.onInvalidated:void 0;return n&&(n.get||n.set)?new xRe(e,{get:n.get,set:n.set},r):new SRe(e,r)}function wRe(e,t){var n=bie(e,Ea(Ea({},t),{onInvalidated:function(r){t&&t.onInvalidated&&t.onInvalidated(r),r.removeRef()}}));return t&&t.acceptsUndefined===!1?n:pie(n)}var vie=(function(e){tr(t,e);function t(n,r){var i=e.call(this,n)||this;return Object.defineProperty(i,"validType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:_n.Identifier}),i}return Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){if(!n||!(n.type instanceof Uv))throw new St("Identifier types can only be instantiated as direct child of a model type");return cd(this,n,r,i,a)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){if(n.storedValue!==r)throw new St("Tried to change identifier from '".concat(n.storedValue,"' to '").concat(r,"'. Changing identifiers is not allowed."));return n.setParent(i,a),n}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return typeof n!==this.validType?Na(r,n,"Value is not a valid ".concat(this.describe(),", expected a ").concat(this.validType)):ka()}}),t})(Jf),TRe=(function(e){tr(t,e);function t(){var n=e.call(this,"identifier","string")||this;return Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:_n.Identifier}),n}return Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifier"}}),t})(vie),CRe=(function(e){tr(t,e);function t(){return e.call(this,"identifierNumber","number")||this}return Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return n.storedValue}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifierNumber"}}),t})(vie),ARe=new TRe,kRe=new CRe;function f0(e){return""+e}function e3(e){return typeof e=="string"||typeof e=="number"}function ORe(e){return new RRe(e)}var RRe=(function(e){tr(t,e);function t(n){var r=e.call(this,n.name)||this;return Object.defineProperty(r,"options",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:_n.Custom}),r}return Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){if(this.options.isTargetType(n))return ka();var i=this.options.getValidationMessage(n);return i?Na(r,n,"Invalid value for type '".concat(this.name,"': ").concat(i)):ka()}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this.options.toSnapshot(n.storedValue)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=this.options.isTargetType(a)?a:this.options.fromSnapshot(a,n&&n.root.environment);return cd(this,n,r,i,s)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){var s=!this.options.isTargetType(r);if(!n.isDetaching){var o=n.type===this&&(s?r===n.snapshot:r===n.storedValue);if(o)return n.setParent(i,a),n}var l=s?this.options.fromSnapshot(r,i.root.environment):r,u=this.instantiate(i,a,void 0,l);return n.die(),u}}),t})(Jf),Ot={enumeration:aRe,model:KOe,compose:YOe,custom:ORe,reference:bie,safeReference:wRe,union:_w,optional:Sf,literal:hie,maybe:pie,maybeNull:hRe,refinement:iRe,string:sie,boolean:lie,number:oie,integer:ZOe,float:QOe,finite:JOe,Date:fie,map:WOe,array:VOe,frozen:vRe,identifier:ARe,identifierNumber:kRe,late:mRe,lazy:gRe,undefined:cie,null:uie,snapshotProcessor:zOe};const NRe=Ot.enumeration("TerminalStatus",["running","exited","error"]),IRe=Ot.model("Terminal",{id:Ot.identifier,name:Ot.string,cwd:Ot.string,status:NRe,exitCode:Ot.maybe(Ot.number),cols:Ot.number,rows:Ot.number,createdAt:Ot.number,tabId:Ot.maybeNull(Ot.string),positionInTab:Ot.optional(Ot.number,0)}).volatile(()=>({xterm:null,attachCleanup:null,isPending:!1,pendingId:null,isStartingUp:!1})).views(e=>({get isAlive(){return e.status==="running"},get isTabTerminal(){return e.tabId!=null}})).actions(e=>({updateFromServer(t){t.name!==void 0&&(e.name=t.name),t.cwd!==void 0&&(e.cwd=t.cwd),t.status!==void 0&&(e.status=t.status),t.exitCode!==void 0&&(e.exitCode=t.exitCode),t.cols!==void 0&&(e.cols=t.cols),t.rows!==void 0&&(e.rows=t.rows),t.tabId!==void 0&&(e.tabId=t.tabId),t.positionInTab!==void 0&&(e.positionInTab=t.positionInTab)},setXterm(t){e.xterm=t},setAttachCleanup(t){e.attachCleanup=t},markExited(t){e.status="exited",e.exitCode=t},assignToTab(t,n){e.tabId=t,n!==void 0&&(e.positionInTab=n)},rename(t){e.name=t},resize(t,n){e.cols=t,e.rows=n},setPending(t,n){e.isPending=t,n!==void 0&&(e.pendingId=n)},setStartingUp(t){e.isStartingUp=t},cleanup(){e.attachCleanup&&(e.attachCleanup(),e.attachCleanup=null),e.xterm=null}})),DRe=Ot.model("Tab",{id:Ot.identifier,name:Ot.string,position:Ot.number,directory:Ot.maybeNull(Ot.string),createdAt:Ot.number}).volatile(()=>({isPending:!1})).views(e=>({get terminals(){const t=Hre(e);return t.terminals?.items?t.terminals.items.filter(n=>n.tabId===e.id).sort((n,r)=>n.positionInTab-r.positionInTab):[]},get terminalCount(){return this.terminals.length}})).actions(e=>({updateFromServer(t){t.name!==void 0&&(e.name=t.name),t.directory!==void 0&&(e.directory=t.directory),t.position!==void 0&&(e.position=t.position)},rename(t){e.name=t},setDirectory(t){e.directory=t},setPosition(t){e.position=t},setPending(t){e.isPending=t}})),LRe=Ot.map(Ot.string),PRe=Ot.model("ViewState",{focusedTerminals:Ot.optional(LRe,{}),currentView:Ot.maybeNull(Ot.string),currentTaskId:Ot.maybeNull(Ot.string),isTabVisible:Ot.maybeNull(Ot.boolean),viewUpdatedAt:Ot.maybeNull(Ot.string)}).volatile(()=>({pendingUpdates:{},debounceTimer:null})).views(e=>({getFocusedTerminal(t){return e.focusedTerminals.get(t)??null}})).actions(e=>({setFocusedTerminal(t,n){n===null?e.focusedTerminals.delete(t):e.focusedTerminals.set(t,n)},clearFocusedTerminalForTab(t){e.focusedTerminals.delete(t)},updateViewTracking(t,n){e.currentView=t,e.currentTaskId=n,e.viewUpdatedAt=new Date().toISOString()},setTabVisible(t){e.isTabVisible=t,e.viewUpdatedAt=new Date().toISOString()},hydrateFromServer(t){if(t.focusedTerminals){e.focusedTerminals.clear();for(const[n,r]of Object.entries(t.focusedTerminals))e.focusedTerminals.set(n,r)}t.currentView!==void 0&&(e.currentView=t.currentView),t.currentTaskId!==void 0&&(e.currentTaskId=t.currentTaskId),t.isTabVisible!==void 0&&(e.isTabVisible=t.isTabVisible),t.viewUpdatedAt!==void 0&&(e.viewUpdatedAt=t.viewUpdatedAt)}}));function SD(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}function tH(){return`temp-${SD()}`}const MRe=Ot.model("TerminalsStore",{items:Ot.array(IRe)}).views(e=>({get(t){return e.items.find(n=>n.id===t)},getByTab(t){return e.items.filter(n=>n.tabId===t).sort((n,r)=>n.positionInTab-r.positionInTab)},get taskTerminals(){return e.items.filter(t=>t.tabId==null)},has(t){return e.items.some(n=>n.id===t)}})).actions(e=>({add(t){if(e.items.some(n=>n.id===t.id)){At.ws.debug("Terminal already exists, skipping add",{id:t.id});return}e.items.push(t)},remove(t){const n=e.items.find(r=>r.id===t);n&&(n.cleanup(),lS(n))},replaceAll(t){for(const n of e.items)n.cleanup();e.items.clear();for(const n of t)e.items.push(n)},clear(){for(const t of e.items)t.cleanup();e.items.clear()}})),jRe=Ot.model("TabsStore",{items:Ot.array(DRe)}).views(e=>({get(t){return e.items.find(n=>n.id===t)},get sorted(){return[...e.items].sort((t,n)=>t.position-n.position)},has(t){return e.items.some(n=>n.id===t)},get first(){return this.sorted[0]}})).actions(e=>({add(t){if(e.items.some(n=>n.id===t.id)){At.ws.debug("Tab already exists, skipping add",{id:t.id});return}e.items.push(t)},remove(t){const n=e.items.find(r=>r.id===t);n&&lS(n)},replaceAll(t){e.items.clear();for(const n of t)e.items.push(n)},clear(){e.items.clear()}})),FRe=Ot.model("RootStore",{terminals:Ot.optional(MRe,{items:[]}),tabs:Ot.optional(jRe,{items:[]}),viewState:Ot.optional(PRe,{})}).volatile(()=>({connected:!1,initialized:!1,hasEverConnected:!1,reconnectAttempt:0,maxReconnectAttempts:10,newTerminalIds:new Set,pendingUpdates:new Map,onAttachedCallbacks:new Map,terminalsReadyForCallback:new Set,lastFocusedTerminalId:null,terminalsPendingStartup:new Map,pendingTabCreation:null,lastCreatedTabId:null,broadcastedTheme:null})).views(e=>({get isReady(){return e.connected&&e.initialized}})).actions(e=>{const t=()=>sOe(e);return{setConnected(n){const r=e.connected;if(e.connected=n,!n)e.initialized=!1;else if(!r&&n&&(e.hasEverConnected=!0,e.reconnectAttempt=0,e.pendingUpdates.size>0)){t().log.ws.info("Reconnected: clearing stale pending updates",{count:e.pendingUpdates.size});for(const i of e.pendingUpdates.values())if(i.entityType==="terminal"){const a=e.terminals.get(i.tempId);a&&(a.cleanup(),e.terminals.remove(i.tempId)),e.newTerminalIds.delete(i.tempId)}else i.entityType==="tab"&&e.tabs.remove(i.tempId);e.pendingUpdates.clear()}},setInitialized(n){e.initialized=n},setReconnectAttempt(n){e.reconnectAttempt=n},setMaxReconnectAttempts(n){e.maxReconnectAttempts=n},markNewTerminal(n){e.newTerminalIds.add(n)},clearNewTerminal(n){e.newTerminalIds.delete(n)},setLastFocusedTerminal(n){e.lastFocusedTerminalId=n},consumePendingStartup(n){const r=e.terminalsPendingStartup.get(n);return r&&(e.terminalsPendingStartup.delete(n),t().log.ws.info("consumed pending startup",{terminalId:n,taskName:r.taskName})),r},clearStartingUp(n){const r=e.terminals.get(n);r&&(r.setStartingUp(!1),t().log.ws.info("cleared isStartingUp",{terminalId:n}))},setPendingTabCreation(n){e.pendingTabCreation=n},clearLastCreatedTabId(){e.lastCreatedTabId=null},syncTheme(n){t().send({type:"theme:sync",payload:{theme:n}})},clearBroadcastedTheme(){e.broadcastedTheme=null},createTerminal(n){const r=SD(),i=tH(),a={id:i,name:n.name,cwd:n.cwd??"~",status:"running",cols:n.cols,rows:n.rows,createdAt:Date.now(),tabId:n.tabId??null,positionInTab:n.positionInTab??0},s=Gz(e.terminals);e.terminals.add(a),s.stop();const o=e.terminals.get(i);o?.setPending(!0,i),e.pendingUpdates.set(r,{entityType:"terminal",tempId:i,inversePatches:s.inversePatches,createdAt:Date.now()}),e.newTerminalIds.add(i),n.startup&&(e.terminalsPendingStartup.set(i,n.startup),o?.setStartingUp(!0),t().log.ws.info("createTerminal registered startup",{tempId:i,taskName:n.startup.taskName,isStartingUp:o?.isStartingUp}));const{startup:l,...u}=n;t().send({type:"terminal:create",payload:{...u,requestId:r,tempId:i}}),t().log.ws.debug("createTerminal optimistic",{requestId:r,tempId:i,name:n.name})},destroyTerminal(n,r){t().send({type:"terminal:destroy",payload:{terminalId:n,force:r?.force,reason:r?.reason}});const i=e.terminals.get(n);i&&i.cleanup(),e.terminals.remove(n)},writeToTerminal(n,r){t().send({type:"terminal:input",payload:{terminalId:n,data:r}})},sendInputToTerminal(n,r){t().send({type:"terminal:input",payload:{terminalId:n,data:r}}),setTimeout(()=>{t().send({type:"terminal:input",payload:{terminalId:n,data:"\r"}})},50)},resizeTerminal(n,r,i){t().send({type:"terminal:resize",payload:{terminalId:n,cols:r,rows:i}}),e.terminals.get(n)?.resize(r,i)},renameTerminal(n,r){t().send({type:"terminal:rename",payload:{terminalId:n,name:r}}),e.terminals.get(n)?.rename(r)},attachXterm(n,r,i){const a=e.terminals.get(n);if(!a)return t().log.ws.warn("attachXterm: terminal not found",{terminalId:n}),()=>{};if(a.xterm===r)return t().log.ws.debug("attachXterm: already attached, skipping",{terminalId:n}),i?.onAttached&&(e.terminalsReadyForCallback.has(n)?(e.terminalsReadyForCallback.delete(n),setTimeout(()=>i.onAttached?.(n),0)):e.onAttachedCallbacks.set(n,i.onAttached)),a.attachCleanup||(()=>{});a.attachCleanup&&a.attachCleanup(),a.setXterm(r),r.attachCustomKeyEventHandler(u=>u.type==="keydown"&&u.shiftKey&&u.key==="Enter"?(u.preventDefault(),u.stopPropagation(),t().send({type:"terminal:input",payload:{terminalId:n,data:`
31
- `}}),!1):!0);const s=r.onData(u=>{t().send({type:"terminal:input",payload:{terminalId:n,data:u}})}),o=()=>{this.setLastFocusedTerminal(n)};r.textarea?.addEventListener("focus",o),i?.onAttached&&(e.terminalsReadyForCallback.has(n)?(t().log.ws.debug("attachXterm: terminal already attached, calling callback immediately",{terminalId:n}),e.terminalsReadyForCallback.delete(n),setTimeout(()=>i.onAttached?.(n),0)):(t().log.ws.debug("attachXterm: registering onAttached callback",{terminalId:n,existingCallbacks:Array.from(e.onAttachedCallbacks.keys())}),e.onAttachedCallbacks.set(n,i.onAttached)));const l=()=>{s.dispose(),r.textarea?.removeEventListener("focus",o),e.terminals.get(n)?.setXterm(null)};return a.setAttachCleanup(l),t().send({type:"terminal:attach",payload:{terminalId:n}}),l},requestAttach(n){t().send({type:"terminal:attach",payload:{terminalId:n}})},clearTerminalBuffer(n){t().send({type:"terminal:clearBuffer",payload:{terminalId:n}})},assignTerminalToTab(n,r,i){t().send({type:"terminal:assignTab",payload:{terminalId:n,tabId:r,positionInTab:i}}),e.terminals.get(n)?.assignToTab(r,i)},createTab(n,r,i,a){const s=SD(),o=tH(),l=r??e.tabs.items.length,u={id:o,name:n,position:l,directory:i??null,createdAt:Date.now()},f=Gz(e.tabs);e.tabs.add(u),f.stop(),e.tabs.get(o)?.setPending(!0),e.pendingTabCreation=o,e.pendingUpdates.set(s,{entityType:"tab",tempId:o,inversePatches:f.inversePatches,createdAt:Date.now()}),t().send({type:"tab:create",payload:{name:n,position:r,directory:i,adoptTerminalId:a,requestId:s,tempId:o}}),t().log.ws.debug("createTab optimistic",{requestId:s,tempId:o,name:n,adoptTerminalId:a})},updateTab(n,r){t().send({type:"tab:update",payload:{tabId:n,...r}}),e.tabs.get(n)?.updateFromServer(r)},deleteTab(n){t().send({type:"tab:delete",payload:{tabId:n}}),e.tabs.remove(n),e.viewState.clearFocusedTerminalForTab(n)},reorderTab(n,r){const i=e.tabs.get(n);if(!i)return;const a=i.position;if(t().send({type:"tab:reorder",payload:{tabId:n,position:r}}),r>a)for(const s of e.tabs.items)s.position>a&&s.position<=r&&s.setPosition(s.position-1);else if(r<a)for(const s of e.tabs.items)s.position>=r&&s.position<a&&s.setPosition(s.position+1);i.setPosition(r)},handleMessage(n){const{type:r,payload:i}=n;switch(r){case"terminals:list":e.terminals.replaceAll(i.terminals);break;case"terminal:created":{const{terminal:a,isNew:s,requestId:o,tempId:l}=i;if(o&&l){const u=e.pendingUpdates.get(o);if(u&&u.tempId===l){e.pendingUpdates.delete(o);const f=e.terminals.get(l);if(f){const d=f.xterm,p=e.onAttachedCallbacks.get(l),m=f.attachCleanup;if(t().log.ws.info("terminal:created optimistic handling",{tempId:l,realId:a.id,hasXterm:!!d,hasCallback:!!p,isNew:s}),m&&m(),f.setXterm(null),f.setAttachCleanup(null),e.onAttachedCallbacks.delete(l),s){const E=f.isStartingUp,S=e.terminals.items.findIndex(v=>v.id===l);S>=0&&lS(e.terminals.items[S]),e.terminals.add(a);const g=e.terminals.get(a.id);E&&g&&(g.setStartingUp(!0),t().log.ws.info("terminal:created transferred isStartingUp",{tempId:l,realId:a.id,isStartingUp:g.isStartingUp})),t().log.ws.info("terminal:created re-attaching xterm",{realId:a.id,hasRealTerminal:!!g,hasXterm:!!d,willAttach:!!(g&&d)}),g&&d?this.attachXterm(a.id,d,{onAttached:p}):p&&(t().log.ws.info("terminal:created preserving callback for later",{realId:a.id}),e.onAttachedCallbacks.set(a.id,p)),e.newTerminalIds.delete(l),e.newTerminalIds.add(a.id);const y=e.terminalsPendingStartup.get(l);y&&(e.terminalsPendingStartup.delete(l),e.terminalsPendingStartup.set(a.id,y),t().log.ws.debug("transferred pending startup",{tempId:l,realId:a.id})),t().log.ws.debug("terminal:created confirmed",{requestId:o,tempId:l,realId:a.id,xtermReattached:!!d,hasPendingStartup:!!y})}else{const E=e.terminals.items.findIndex(g=>g.id===l);E>=0&&lS(e.terminals.items[E]),e.newTerminalIds.delete(l),e.terminalsPendingStartup.delete(l),e.terminals.has(a.id)||e.terminals.add(a),e.terminals.get(a.id)&&d&&this.attachXterm(a.id,d,{onAttached:p}),t().log.ws.debug("terminal:created deduplicated",{requestId:o,tempId:l,existingId:a.id,xtermReattached:!!d})}}break}}e.terminals.add(a),s&&e.newTerminalIds.add(a.id);break}case"terminal:destroyed":{const{terminalId:a}=i;e.terminals.remove(a),e.newTerminalIds.delete(a),e.terminalsReadyForCallback.delete(a),e.onAttachedCallbacks.delete(a);break}case"terminal:output":{const{terminalId:a,data:s}=i,o=e.terminals.get(a);o?.xterm?o.xterm.write(s):t().log.ws.warn("terminal:output but no xterm",{terminalId:a});break}case"terminal:attached":{const{terminalId:a,buffer:s}=i,o=e.terminals.get(a);t().log.ws.info("terminal:attached received",{terminalId:a,hasTerminal:!!o,hasXterm:!!o?.xterm,bufferLength:s?.length??0,hasCallback:e.onAttachedCallbacks.has(a),isReadyForCallback:e.terminalsReadyForCallback.has(a),registeredCallbacks:Array.from(e.onAttachedCallbacks.keys())}),o?.xterm&&(o.xterm.reset(),s&&o.xterm.write(s));const l=e.onAttachedCallbacks.get(a);l?(e.onAttachedCallbacks.delete(a),t().log.ws.debug("terminal:attached calling callback",{terminalId:a}),l(a)):(t().log.ws.debug("terminal:attached no callback yet, marking ready",{terminalId:a}),e.terminalsReadyForCallback.add(a));break}case"terminal:bufferCleared":{const{terminalId:a}=i,s=e.terminals.get(a);s?.xterm&&s.xterm.reset();break}case"terminal:exit":{const{terminalId:a,exitCode:s}=i;e.terminals.get(a)?.markExited(s);break}case"terminal:renamed":{const{terminalId:a,name:s}=i;e.terminals.get(a)?.rename(s);break}case"terminal:tabAssigned":{const{terminalId:a,tabId:s,positionInTab:o}=i;e.terminals.get(a)?.assignToTab(s,o);break}case"tabs:list":e.tabs.replaceAll(i.tabs),e.initialized=!0;break;case"tab:created":{const{tab:a,requestId:s,tempId:o,adoptTerminalId:l}=i;if(s&&o){const u=e.pendingUpdates.get(s);if(u&&u.tempId===o){e.pendingUpdates.delete(s),e.tabs.get(o)&&(e.tabs.remove(o),e.tabs.add(a),e.pendingTabCreation=null,l||(e.lastCreatedTabId=a.id),t().log.ws.debug("tab:created confirmed",{requestId:s,tempId:o,realId:a.id,adoptTerminalId:l}));break}}e.tabs.add(a);break}case"tab:updated":{const{tabId:a,name:s,directory:o}=i;e.tabs.get(a)?.updateFromServer({name:s,directory:o});break}case"tab:deleted":{const{tabId:a}=i;e.tabs.remove(a),e.viewState.clearFocusedTerminalForTab(a);break}case"terminal:error":{const{error:a,requestId:s,tempId:o}=i;if(s&&o){const l=e.pendingUpdates.get(s);if(l&&l.tempId===o){e.pendingUpdates.delete(s);for(let u=l.inversePatches.length-1;u>=0;u--)Mv(e.terminals,l.inversePatches[u]);e.newTerminalIds.delete(o),e.terminalsPendingStartup.delete(o),t().log.ws.warn("terminal:error rollback",{requestId:s,tempId:o,error:a});break}}At.ws.error("Terminal error from server",{error:a});break}case"sync:stale":{const{entityType:a,entityId:s,requestId:o,tempId:l,error:u}=i;if(t().log.ws.warn("sync:stale received",{entityType:a,entityId:s,error:u}),o&&l){const f=e.pendingUpdates.get(o);if(f&&f.tempId===l)if(e.pendingUpdates.delete(o),f.entityType==="terminal"){const d=e.terminals.get(l);d&&(d.cleanup(),e.terminals.remove(l)),e.newTerminalIds.delete(l),e.terminalsPendingStartup.delete(l)}else f.entityType==="tab"&&e.tabs.remove(l)}if(a==="terminal"){if(e.terminals.has(s)){const f=e.terminals.get(s);f&&(f.cleanup(),e.terminals.remove(s))}e.terminalsPendingStartup.delete(s)}else a==="tab"&&e.tabs.has(s)&&(e.tabs.remove(s),e.viewState.clearFocusedTerminalForTab(s));break}case"theme:synced":{const{theme:a}=i;e.broadcastedTheme=a,t().log.ws.debug("theme:synced received",{theme:a});break}}},reset(){e.terminals.clear(),e.tabs.clear(),e.connected=!1,e.initialized=!1,e.newTerminalIds.clear(),e.pendingUpdates.clear(),e.terminalsPendingStartup.clear()}}});function yie(){const e=$m();return k.useMemo(()=>{const t=(n,r)=>{const i=async a=>{const s=a.clipboardData?.items;if(s){for(const o of s)if(o.type.startsWith("image/")){a.preventDefault(),a.stopPropagation();const l=o.getAsFile();if(!l)return;try{const u=await Bte(l);e.writeToTerminal(r,u)}catch(u){At.ws.error("Failed to upload image",{error:String(u)})}return}}};return n.addEventListener("paste",i,!0),()=>{n.removeEventListener("paste",i,!0)}};return{get terminals(){return[...e.terminals.items]},get terminalsLoaded(){return e.initialized},get tabs(){return[...e.tabs.sorted]},get connected(){return e.connected},get newTerminalIds(){return e.newTerminalIds},get pendingTabCreation(){return e.pendingTabCreation},get lastCreatedTabId(){return e.lastCreatedTabId},createTerminal:e.createTerminal.bind(e),destroyTerminal:e.destroyTerminal.bind(e),writeToTerminal:e.writeToTerminal.bind(e),sendInputToTerminal:e.sendInputToTerminal.bind(e),resizeTerminal:e.resizeTerminal.bind(e),renameTerminal:e.renameTerminal.bind(e),clearTerminalBuffer:e.clearTerminalBuffer.bind(e),assignTerminalToTab:e.assignTerminalToTab.bind(e),createTab:e.createTab.bind(e),updateTab:e.updateTab.bind(e),deleteTab:e.deleteTab.bind(e),reorderTab:e.reorderTab.bind(e),attachXterm:e.attachXterm.bind(e),setupImagePaste:t,consumePendingStartup:e.consumePendingStartup.bind(e),clearStartingUp:e.clearStartingUp.bind(e),clearLastCreatedTabId:e.clearLastCreatedTabId.bind(e)}},[e])}const Ok="",BRe=Ot.model("File",{path:Ot.identifier,content:Ot.string,originalContent:Ot.string,mimeType:Ot.string,size:Ot.number,lineCount:Ot.number,truncated:Ot.boolean,isMarkdownView:Ot.optional(Ot.boolean,!1)}).views(e=>({get isDirty(){return e.content!==e.originalContent},get isMarkdown(){return e.path.toLowerCase().endsWith(".md")},get isImage(){return e.mimeType.startsWith("image/")},get isBinary(){return e.mimeType==="application/octet-stream"},get isEditable(){return!e.mimeType.startsWith("image/")&&e.mimeType!=="application/octet-stream"}})).actions(e=>({setContent(t){e.content=t},markSaved(){e.originalContent=e.content},toggleMarkdownView(){e.isMarkdownView=!e.isMarkdownView},setMarkdownView(t){e.isMarkdownView=t}})),URe=Ot.model("FilesStore",{selectedFile:Ot.maybeNull(Ot.string),expandedDirs:Ot.array(Ot.string),openFiles:Ot.map(BRe)}).volatile(()=>({worktreePath:null,readOnly:!1,isLoading:!1,isSaving:!1,loadError:null,saveError:null,fileTree:null,isLoadingTree:!1,treeError:null})).views(e=>({get currentFile(){if(e.selectedFile)return e.openFiles.get(e.selectedFile)},get isDirty(){return(e.selectedFile?e.openFiles.get(e.selectedFile):void 0)?.isDirty??!1},isFileMarkdownView(t){return e.openFiles.get(t)?.isMarkdownView??!1},isDirExpanded(t){return e.expandedDirs.includes(t)}})).actions(e=>({setWorktreePath(t){e.worktreePath!==t&&(e.worktreePath=t,e.selectedFile=null,e.expandedDirs.clear(),e.openFiles.clear(),e.fileTree=null)},setReadOnly(t){e.readOnly=t},selectFile(t){e.selectedFile=t},toggleDir(t){const n=e.expandedDirs.indexOf(t);n>=0?e.expandedDirs.splice(n,1):e.expandedDirs.push(t)},collapseAll(){e.expandedDirs.clear()},updateContent(t,n){const r=e.openFiles.get(t);r&&r.setContent(n)},toggleMarkdownView(t){const n=e.openFiles.get(t);n&&n.toggleMarkdownView()},_setLoading(t){e.isLoading=t},_setLoadError(t){e.loadError=t},_setSaving(t){e.isSaving=t},_setSaveError(t){e.saveError=t},_setFileTree(t){e.fileTree=t},_setLoadingTree(t){e.isLoadingTree=t},_setTreeError(t){e.treeError=t},_addFile(t){e.openFiles.set(t.path,{path:t.path,content:t.content,originalContent:t.content,mimeType:t.mimeType,size:t.size,lineCount:t.lineCount,truncated:t.truncated,isMarkdownView:!1})},_markFileSaved(t){const n=e.openFiles.get(t);n&&n.markSaved()}})).actions(e=>({loadFileTree:Ck(function*(){if(e.worktreePath){e._setLoadingTree(!0),e._setTreeError(null);try{const t=yield zt(`${Ok}/api/fs/tree?root=${encodeURIComponent(e.worktreePath)}`);e._setFileTree(t.entries)}catch(t){e._setTreeError(t instanceof Error?t.message:"Failed to load file tree")}finally{e._setLoadingTree(!1)}}}),loadFile:Ck(function*(t){if(e.worktreePath){if(e.openFiles.has(t)){e.selectedFile=t;return}e._setLoading(!0),e._setLoadError(null);try{const n=new URLSearchParams({path:t,root:e.worktreePath}),r=yield zt(`${Ok}/api/fs/read?${n}`);e._addFile({path:t,content:r.content,mimeType:r.mimeType,size:r.size,lineCount:r.lineCount,truncated:r.truncated}),e.selectedFile=t}catch(n){e._setLoadError(n instanceof Error?n.message:"Failed to load file")}finally{e._setLoading(!1)}}}),saveFile:Ck(function*(t){if(!e.worktreePath)return;const n=e.openFiles.get(t);if(!(!n||!n.isDirty)){e._setSaving(!0),e._setSaveError(null);try{(yield fetch(`${Ok}/api/fs/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t,root:e.worktreePath,content:n.content})}).then(i=>i.ok?i.json():i.json().then(a=>{throw new Error(a.error||"Failed to save file")}))).success&&e._markFileSaved(t)}catch(r){throw e._setSaveError(r instanceof Error?r.message:"Failed to save file"),r}finally{e._setSaving(!1)}}}),closeFile(t){e.openFiles.delete(t),e.selectedFile===t&&(e.selectedFile=null)}}));function $Re(){return URe.create({selectedFile:null,expandedDirs:[],openFiles:{}})}const _ie=k.createContext(null);function zRe(e,t=!1,n){const r=k.useMemo(()=>$Re(),[]),i=k.useRef(!1);return k.useEffect(()=>{r.setWorktreePath(e),r.setReadOnly(t),i.current=!1,e&&r.loadFileTree().then(()=>{n&&!i.current&&(i.current=!0,r.selectFile(n),r.loadFile(n))})},[r,e,t,n]),r}function HRe(){const e=k.useContext(_ie);if(!e)throw new Error("useFilesStore must be used within a FilesStoreProvider");return e}function Eie(){const e=HRe();return{worktreePath:e.worktreePath,readOnly:e.readOnly,selectedFile:e.selectedFile,currentFile:e.currentFile,expandedDirs:[...e.expandedDirs],fileTree:e.fileTree,isLoading:e.isLoading,isSaving:e.isSaving,isLoadingTree:e.isLoadingTree,loadError:e.loadError,saveError:e.saveError,treeError:e.treeError,isDirty:e.isDirty,selectFile:e.selectFile,loadFile:e.loadFile,saveFile:e.saveFile,closeFile:e.closeFile,updateContent:e.updateContent,toggleDir:e.toggleDir,collapseAll:e.collapseAll,toggleMarkdownView:e.toggleMarkdownView,isFileMarkdownView:e.isFileMarkdownView,isDirExpanded:e.isDirExpanded,refreshTree:e.loadFileTree}}const Sie=k.createContext(null);function $m(){const e=k.useContext(Sie);if(!e)throw new Error("useStore must be used within a StoreProvider");return e}function WRe(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/terminal`}function VRe({children:e,wsUrl:t=WRe(),reconnectInterval:n=2e3,maxReconnectAttempts:r=10}){const i=k.useRef(null),a=k.useRef(0),s=k.useRef(void 0),o=k.useRef(null),[,l]=k.useState({}),u=k.useCallback(d=>{i.current?.readyState===WebSocket.OPEN?(At.ws.debug("send",{type:d.type}),i.current.send(JSON.stringify(d))):At.ws.warn("send dropped (WebSocket not open)",{type:d.type,readyState:i.current?.readyState??"no socket"})},[]);if(!o.current){const d={send:u,log:At};o.current=FRe.create({},d)}const f=o.current;return k.useEffect(()=>{f.setMaxReconnectAttempts(r)},[f,r]),k.useEffect(()=>{let d=!0;const p=()=>{const m=i.current;if(m&&(m.readyState===WebSocket.CONNECTING||m.readyState===WebSocket.OPEN))return;const E=new WebSocket(t);i.current=E,E.onopen=()=>{d&&(At.ws.info("WebSocket connected"),f.setConnected(!0),a.current=0)},E.onmessage=S=>{if(d)try{const g=JSON.parse(S.data);f.handleMessage(g)}catch(g){At.ws.error("Failed to parse WebSocket message",{error:String(g)})}},E.onclose=()=>{if(d)if(At.ws.info("WebSocket disconnected"),f.setConnected(!1),i.current===E&&(i.current=null),a.current<r){a.current++,f.setReconnectAttempt(a.current);const S=n*Math.pow(1.5,a.current-1);At.ws.info("Scheduling reconnect",{attempt:a.current,delay:S}),s.current=setTimeout(p,S)}else At.ws.warn("Max reconnect attempts reached"),f.setReconnectAttempt(a.current)},E.onerror=S=>{At.ws.error("WebSocket error",{event:String(S)})}};return p(),()=>{d=!1,s.current&&clearTimeout(s.current);const m=i.current;m?.readyState===WebSocket.OPEN&&m.close(),i.current=null}},[t,n,r,f]),k.useEffect(()=>{l({})},[]),b.jsx(Sie.Provider,{value:f,children:e})}function xie(){const e=$m(),{setTheme:t,resolvedTheme:n,theme:r}=Qc(),{data:i}=rwe(),a=k.useRef(void 0),s=k.useRef(!1),o=k.useRef(!1);k.useEffect(()=>VM(()=>e.broadcastedTheme,f=>{f&&(o.current=!0,t(f),e.clearBroadcastedTheme(),setTimeout(()=>{o.current=!1},0))},{fireImmediately:!0}),[e,t]),k.useEffect(()=>{let u=document.querySelector('link[rel="icon"]');u||(u=document.createElement("link"),u.rel="icon",document.head.appendChild(u)),u.type="image/jpeg",u.href="/logo.jpg"},[]),k.useEffect(()=>{const u=s.current&&i&&a.current===!1;a.current=i,s.current=!0,n&&u&&zt("/api/config/sync-claude-theme",{method:"POST",body:JSON.stringify({resolvedTheme:n})}).catch(()=>{})},[i,n]);const l=k.useCallback(u=>{if(!o.current&&(t(u),e.syncTheme(u),i)){const f=u==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":u;zt("/api/config/sync-claude-theme",{method:"POST",body:JSON.stringify({resolvedTheme:f})}).catch(()=>{})}},[t,e,i]);return{theme:r??"system",resolvedTheme:n,syncClaudeCode:i,changeTheme:l,isUpdating:!1}}let Rk=!1;const nH={activeTabId:null,focusedTerminals:{},currentView:null,currentTaskId:null,isTabVisible:null,viewUpdatedAt:null};function wie(){const e=wr(),t=k.useRef(void 0),n=k.useRef({}),{data:r=nH,isLoading:i}=qn({queryKey:["terminal-view-state"],queryFn:async()=>{const p=await fetch("/api/terminal-view-state");if(!p.ok)throw new Error("Failed to fetch terminal view state");return p.json()},staleTime:2e3}),a=Fn({mutationFn:async p=>{const m=await fetch("/api/terminal-view-state",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)});if(!m.ok)throw new Error("Failed to update terminal view state");return m.json()},onSuccess:p=>{e.setQueryData(["terminal-view-state"],p)}}),s=k.useRef(a);s.current=a;const o=k.useCallback(p=>{const m=n.current;n.current={...m,...p,focusedTerminals:p.focusedTerminals||m.focusedTerminals?{...m.focusedTerminals,...p.focusedTerminals}:void 0};const E=n.current;e.setQueryData(["terminal-view-state"],S=>{const g=S??nH;return{activeTabId:E.activeTabId!==void 0?E.activeTabId:g.activeTabId,focusedTerminals:{...g.focusedTerminals,...E.focusedTerminals},currentView:E.currentView!==void 0?E.currentView:g.currentView,currentTaskId:E.currentTaskId!==void 0?E.currentTaskId:g.currentTaskId,isTabVisible:E.isTabVisible!==void 0?E.isTabVisible:g.isTabVisible,viewUpdatedAt:E.viewUpdatedAt!==void 0?E.viewUpdatedAt:g.viewUpdatedAt}}),t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{s.current.mutate(n.current),n.current={}},500)},[e]),l=k.useCallback((p,m)=>{if(m===null){const E=e.getQueryData(["terminal-view-state"]);if(E){const{[p]:S,...g}=E.focusedTerminals;o({focusedTerminals:g})}}else o({focusedTerminals:{[p]:m}})},[e,o]),u=k.useCallback(p=>r.focusedTerminals[p]??null,[r.focusedTerminals]),f=k.useRef(!1);k.useEffect(()=>{if(Rk){f.current=!1;return}Rk=!0,f.current=!0;const p=()=>{o({isTabVisible:document.visibilityState==="visible",viewUpdatedAt:new Date().toISOString()})};return document.addEventListener("visibilitychange",p),p(),()=>{document.removeEventListener("visibilitychange",p),f.current&&(Rk=!1)}},[o]);const d=k.useCallback((p,m,E)=>{o({currentView:p,currentTaskId:m,activeTabId:E,viewUpdatedAt:new Date().toISOString()})},[o]);return{viewState:r,isLoading:i,getFocusedTerminal:u,setFocusedTerminal:l,updateViewTracking:d}}function no(e,t){const n=e.toLowerCase(),r=t.toLowerCase();if(n===r)return 100;if(n.startsWith(r))return 80;if(n.includes(r))return 60;let i=0,a=0,s=0;for(;i<n.length&&a<r.length;)n[i]===r[a]&&(s+=1,a++),i++;return a===r.length?s:0}function GRe(e,t){return t.trim()?e.map(r=>{let i=no(r.label,t);if(r.keywords)for(const a of r.keywords){const s=no(a,t);s>i&&(i=s)}return{command:r,score:i}}).filter(({score:r})=>r>0).sort((r,i)=>i.score-r.score).map(({command:r})=>r):e}function qRe(e){const t=new Map;for(const n of e){const r=t.get(n.category)||[];r.push(n),t.set(n.category,r)}return t}function KRe({open:e,onOpenChange:t,onNewTask:n,onShowShortcuts:r,onOpenInEditor:i}){const{t:a}=nn("navigation"),[s,o]=k.useState(!1),l=e??s,u=t??o,[f,d]=k.useState(""),[p,m]=k.useState(0),E=k.useRef(null),S=k.useRef(null),g=Ni(),y=k.useMemo(()=>[{id:"goto-tasks",label:a("commandPalette.commands.goToTasks"),shortcut:"meta+1",keywords:["kanban","board","home"],category:"navigation",icon:b.jsx(fe,{icon:Fp,size:16,strokeWidth:2}),action:()=>{g({to:"/tasks"}),u(!1)}},{id:"goto-terminals",label:a("commandPalette.commands.goToTerminals"),shortcut:"meta+2",keywords:["shell","console","cli"],category:"navigation",icon:b.jsx(fe,{icon:N1e,size:16,strokeWidth:2}),action:()=>{g({to:"/terminals"}),u(!1)}},{id:"goto-task-terminals",label:a("commandPalette.commands.goToTaskTerminals"),shortcut:"meta+i",keywords:["tasks","shell","console","cli"],category:"navigation",icon:b.jsx(fe,{icon:Fp,size:16,strokeWidth:2}),action:()=>{g({to:"/terminals",search:{tab:"all-tasks"}}),u(!1)}},{id:"goto-repositories",label:a("commandPalette.commands.goToRepositories"),shortcut:"meta+3",keywords:["repos","git","projects"],category:"navigation",icon:b.jsx(fe,{icon:D1e,size:16,strokeWidth:2}),action:()=>{g({to:"/repositories"}),u(!1)}},{id:"goto-review",label:a("commandPalette.commands.goToReview"),shortcut:"meta+4",keywords:["pr","pull request","issues","github"],category:"navigation",icon:b.jsx(fe,{icon:lu,size:16,strokeWidth:2}),action:()=>{g({to:"/review"}),u(!1)}},{id:"goto-monitoring",label:a("commandPalette.commands.goToMonitoring"),shortcut:"meta+5",keywords:["system","cpu","memory","processes","usage"],category:"navigation",icon:b.jsx(fe,{icon:pte,size:16,strokeWidth:2}),action:()=>{g({to:"/monitoring"}),u(!1)}},{id:"goto-settings",label:a("commandPalette.commands.goToSettings"),shortcut:"meta+,",keywords:["preferences","config","configuration"],category:"navigation",icon:b.jsx(fe,{icon:wte,size:16,strokeWidth:2}),action:()=>{g({to:"/settings"}),u(!1)}},{id:"new-task",label:a("commandPalette.commands.newTask"),shortcut:"meta+j",keywords:["create","add"],category:"actions",icon:b.jsx(fe,{icon:Iv,size:16,strokeWidth:2}),action:()=>{u(!1),n?.()}},{id:"open-in-editor",label:a("commandPalette.commands.openInEditor"),shortcut:"meta+e",keywords:["editor","code","vscode","cursor","folder","path"],category:"actions",icon:b.jsx(fe,{icon:rD,size:16,strokeWidth:2}),action:()=>{u(!1),i?.()}},{id:"show-shortcuts",label:a("commandPalette.commands.keyboardShortcuts"),shortcut:"meta+/",keywords:["help","hotkeys","keys"],category:"actions",icon:b.jsx(fe,{icon:yte,size:16,strokeWidth:2}),action:()=>{u(!1),r?.()}}],[g,n,r,i,u,a]),v=k.useMemo(()=>GRe(y,f),[y,f]),x=k.useMemo(()=>qRe(v),[v]),T=k.useMemo(()=>{const R=[],O=["navigation","actions"];for(const N of O){const D=x.get(N);D&&R.push(...D)}return R},[x]);k.useEffect(()=>{m(0)},[f]),k.useEffect(()=>{if(!S.current)return;const R=S.current.querySelector('[data-selected="true"]');R&&R.scrollIntoView({block:"nearest"})},[p]),ba("meta+k",()=>u(!0),{allowInInput:!0,allowInTerminal:!0}),ba("meta+1",()=>g({to:"/tasks"}),{allowInInput:!0,allowInTerminal:!0}),ba("meta+2",()=>g({to:"/terminals"}),{allowInInput:!0,allowInTerminal:!0}),ba("meta+i",()=>{g({to:"/terminals",search:{tab:"all-tasks"}})},{allowInInput:!0,allowInTerminal:!0}),ba("meta+3",()=>g({to:"/repositories"}),{allowInInput:!0,allowInTerminal:!0}),ba("meta+4",()=>g({to:"/review"}),{allowInInput:!0,allowInTerminal:!0}),ba("meta+5",()=>g({to:"/monitoring"}),{allowInInput:!0,allowInTerminal:!0}),ba("meta+,",()=>g({to:"/settings"}),{allowInInput:!0,allowInTerminal:!0}),ba("meta+j",()=>{n?.()},{allowInInput:!1,deps:[n]}),ba("meta+/",()=>{r?.()},{allowInInput:!0,allowInTerminal:!0,deps:[r]}),ba("meta+e",()=>{i?.()},{allowInInput:!1,deps:[i]});const w=k.useCallback(R=>{switch(R.key){case"ArrowDown":R.preventDefault(),m(O=>Math.min(O+1,T.length-1));break;case"ArrowUp":R.preventDefault(),m(O=>Math.max(O-1,0));break;case"Enter":R.preventDefault(),T[p]&&T[p].action();break;case"Escape":R.preventDefault(),u(!1);break;case"1":R.preventDefault(),g({to:"/tasks"}),u(!1);break;case"2":R.preventDefault(),g({to:"/terminals"}),u(!1);break;case"3":R.preventDefault(),g({to:"/repositories"}),u(!1);break;case"4":R.preventDefault(),g({to:"/review"}),u(!1);break;case"5":R.preventDefault(),g({to:"/monitoring"}),u(!1);break}},[T,p,u,g]);k.useEffect(()=>{l&&(d(""),m(0),setTimeout(()=>E.current?.focus(),50))},[l]),k.useEffect(()=>{const R=O=>{if(O.data?.type==="vibora:action")switch(O.data.action){case"openCommandPalette":u(!0);break;case"openNewTask":n?.();break;case"showShortcuts":r?.();break}};return window.addEventListener("message",R),()=>window.removeEventListener("message",R)},[u,n,r]);let C=0;return b.jsx(Iu,{open:l,onOpenChange:u,children:b.jsxs(Du,{className:"sm:max-w-lg p-0 gap-0 overflow-hidden",showCloseButton:!1,onKeyDown:w,children:[b.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[b.jsx("span",{className:"text-muted-foreground mr-2",children:">"}),b.jsx(ln,{ref:E,value:f,onChange:R=>d(R.target.value),placeholder:a("commandPalette.placeholder"),className:"border-0 ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 px-0 h-12"}),b.jsx("kbd",{className:"pointer-events-none ml-2 inline-flex h-5 select-none items-center gap-1 rounded border border-border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",children:"Esc"})]}),b.jsx("div",{ref:S,className:"max-h-80 overflow-y-auto p-2",children:v.length===0?b.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:a("commandPalette.noResults")}):b.jsx(b.Fragment,{children:["navigation","actions"].map(R=>{const O=x.get(R);return!O||O.length===0?null:b.jsxs("div",{className:"mb-2 last:mb-0",children:[b.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:a(`commandPalette.categories.${R}`)}),O.map(N=>{const D=C++,L=D===p;return b.jsxs("button",{"data-selected":L,onClick:()=>N.action(),onMouseEnter:()=>m(D),className:Be("flex w-full items-center gap-3 rounded-md px-2 py-2 text-sm",L?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"),children:[N.icon&&b.jsx("span",{className:"text-muted-foreground",children:N.icon}),b.jsx("span",{className:"flex-1 text-left",children:N.label}),N.shortcut&&b.jsx("kbd",{className:"pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border border-border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",children:Ate(N.shortcut)})]},N.id)})]},R)})})})]})})}const rH={sm:"w-8 h-8",md:"w-9 h-9 md:w-12 md:h-12",lg:"w-12 h-12 md:w-16 md:h-16"};function YRe({className:e,rows:t=100,cols:n=10,tileClassName:r,tileSize:i="md"}){return b.jsx("div",{className:Be("relative z-0 flex w-full h-full justify-center",e),children:Array.from({length:t}).map((a,s)=>b.jsx("div",{className:Be(rH[i],"border-l dark:border-neutral-900 border-neutral-200 relative",r),children:Array.from({length:n}).map((o,l)=>b.jsx("div",{className:Be(rH[i],"border-r border-t dark:border-neutral-900 border-neutral-200 relative hover:bg-tile transition-colors",r)},`col-${l}`))},`row-${s}`))})}const XRe=["/","/tasks","/terminals","/worktrees","/repositories","/review","/monitoring","/settings"];function ZRe(){const e=ri({select:n=>n.location.pathname});return XRe.some(n=>e===n||e.startsWith(n+"/"))?b.jsx("div",{className:"absolute inset-0 overflow-hidden pointer-events-none -z-10",children:b.jsx(YRe,{rows:100,cols:50,tileSize:"sm"})}):null}if(!k.useState)throw new Error("mobx-react-lite requires React with Hooks support");if(!Lre)throw new Error("mobx-react-lite@3 requires mobx at least version 6 to be available");function QRe(e){e()}function JRe(e){e||(e=QRe),xke({reactionScheduler:e})}function e2e(e){return Tke(e)}var t2e=1e4,n2e=1e4,r2e=(function(){function e(t){var n=this;Object.defineProperty(this,"finalize",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"registrations",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"sweepTimeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sweep",{enumerable:!0,configurable:!0,writable:!0,value:function(r){r===void 0&&(r=t2e),clearTimeout(n.sweepTimeout),n.sweepTimeout=void 0;var i=Date.now();n.registrations.forEach(function(a,s){i-a.registeredAt>=r&&(n.finalize(a.value),n.registrations.delete(s))}),n.registrations.size>0&&n.scheduleSweep()}}),Object.defineProperty(this,"finalizeAllImmediately",{enumerable:!0,configurable:!0,writable:!0,value:function(){n.sweep(0)}})}return Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,r){this.registrations.set(r,{value:n,registeredAt:Date.now()}),this.scheduleSweep()}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.registrations.delete(t)}}),Object.defineProperty(e.prototype,"scheduleSweep",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.sweepTimeout===void 0&&(this.sweepTimeout=setTimeout(this.sweep,n2e))}}),e})(),i2e=typeof FinalizationRegistry<"u"?FinalizationRegistry:r2e,xD=new i2e(function(e){var t;(t=e.reaction)===null||t===void 0||t.dispose(),e.reaction=null});function iH(e){e.reaction=new cl("observer".concat(e.name),function(){var t;e.stateVersion=Symbol(),(t=e.onStoreChange)===null||t===void 0||t.call(e)})}function a2e(e,t){t===void 0&&(t="observed");var n=oe.useRef(null);if(!n.current){var r={reaction:null,onStoreChange:null,stateVersion:Symbol(),name:t,subscribe:function(o){return xD.unregister(r),r.onStoreChange=o,r.reaction||(iH(r),r.stateVersion=Symbol()),function(){var l;r.onStoreChange=null,(l=r.reaction)===null||l===void 0||l.dispose(),r.reaction=null}},getSnapshot:function(){return r.stateVersion}};n.current=r}var i=n.current;i.reaction||(iH(i),xD.register(n,i,i)),oe.useDebugValue(i.reaction,e2e),FP.useSyncExternalStore(i.subscribe,i.getSnapshot,i.getSnapshot);var a,s;if(i.reaction.track(function(){try{a=e()}catch(o){s=o}}),s)throw s;return a}var Nk,Ik,Tie=typeof Symbol=="function"&&Symbol.for,s2e=(Ik=(Nk=Object.getOwnPropertyDescriptor(function(){},"name"))===null||Nk===void 0?void 0:Nk.configurable)!==null&&Ik!==void 0?Ik:!1,aH=Tie?Symbol.for("react.forward_ref"):typeof k.forwardRef=="function"&&k.forwardRef(function(e){return null}).$$typeof,sH=Tie?Symbol.for("react.memo"):typeof k.memo=="function"&&k.memo(function(e){return null}).$$typeof;function h0(e,t){var n;if(sH&&e.$$typeof===sH)throw new Error("[mobx-react-lite] You are trying to use `observer` on a function component wrapped in either another `observer` or `React.memo`. The observer already applies 'React.memo' for you.");var r=(n=void 0)!==null&&n!==void 0?n:!1,i=e,a=e.displayName||e.name;if(aH&&e.$$typeof===aH&&(r=!0,i=e.render,typeof i!="function"))throw new Error("[mobx-react-lite] `render` property of ForwardRef was not a function");var s=function(o,l){return a2e(function(){return i(o,l)},a)};return s.displayName=e.displayName,s2e&&Object.defineProperty(s,"name",{value:e.name,writable:!0,configurable:!0}),e.contextTypes&&(s.contextTypes=e.contextTypes),r&&(s=k.forwardRef(s)),s=k.memo(s),l2e(e,s),s}var o2e={$$typeof:!0,render:!0,compare:!0,type:!0,displayName:!0};function l2e(e,t){Object.keys(e).forEach(function(n){o2e[n]||Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})}var Dk;JRe(xr.unstable_batchedUpdates);Dk=xD.finalizeAllImmediately;const u2e=h0(function(){const t=$m();if(t.connected||!t.hasEverConnected)return null;const n=t.reconnectAttempt>0&&t.reconnectAttempt<t.maxReconnectAttempts,r=t.reconnectAttempt>=t.maxReconnectAttempts;return b.jsx("div",{className:Be("flex items-center justify-center gap-2 px-4 py-2 text-sm font-medium","border-b",r?"bg-destructive/10 border-destructive/30 text-destructive":"bg-amber-500/10 border-amber-500/30 text-amber-600 dark:text-amber-400"),role:"alert","aria-live":"polite",children:r?b.jsxs(b.Fragment,{children:[b.jsx(fe,{icon:rs,size:16,strokeWidth:2}),b.jsx("span",{children:"Connection lost. Please check if the server is running."})]}):n?b.jsxs(b.Fragment,{children:[b.jsx(fe,{icon:tn,size:16,strokeWidth:2,className:"animate-spin"}),b.jsxs("span",{children:["Reconnecting... (attempt ",t.reconnectAttempt,"/",t.maxReconnectAttempts,")"]})]}):b.jsxs(b.Fragment,{children:[b.jsx(fe,{icon:rs,size:16,strokeWidth:2}),b.jsx("span",{children:"Disconnected from server"})]})})});function c2e(){return qn({queryKey:["system","dependencies"],queryFn:()=>zt("/api/system/dependencies"),staleTime:30*1e3,refetchOnWindowFocus:!0})}const oH="npm install -g @anthropic/claude-code",d2e="https://docs.anthropic.com/en/docs/claude-code/overview";function f2e(){const{data:e,isLoading:t}=c2e(),[n,r]=k.useState(!1),[i,a]=k.useState(!1),s=k.useCallback(async()=>{try{await navigator.clipboard.writeText(oH),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[]),o=k.useCallback(()=>{r(!0)},[]);return t||n||e?.claudeCode?.installed?null:b.jsxs("div",{className:Be("flex items-center justify-between gap-4 px-4 py-3","border-b bg-amber-500/10 border-amber-500/30"),role:"alert",children:[b.jsxs("div",{className:"flex items-center gap-3",children:[b.jsx(fe,{icon:rs,size:18,strokeWidth:2,className:"shrink-0 text-amber-600 dark:text-amber-400"}),b.jsxs("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-4",children:[b.jsx("span",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:"Claude Code CLI not found"}),b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx("code",{className:"rounded bg-amber-500/20 px-2 py-0.5 text-xs font-mono text-amber-700 dark:text-amber-300",children:oH}),b.jsx("button",{onClick:s,className:Be("p-1 rounded transition-colors","text-amber-600 hover:text-amber-700 hover:bg-amber-500/20","dark:text-amber-400 dark:hover:text-amber-300"),title:i?"Copied!":"Copy to clipboard",children:b.jsx(fe,{icon:i?ml:I1e,size:14,strokeWidth:2})})]})]})]}),b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx("a",{href:d2e,target:"_blank",rel:"noopener noreferrer",className:Be("text-xs font-medium px-2 py-1 rounded transition-colors","text-amber-600 hover:text-amber-700 hover:bg-amber-500/20","dark:text-amber-400 dark:hover:text-amber-300"),children:"View Docs"}),b.jsx("button",{onClick:o,className:Be("p-1 rounded transition-colors","text-amber-600 hover:text-amber-700 hover:bg-amber-500/20","dark:text-amber-400 dark:hover:text-amber-300"),title:"Dismiss",children:b.jsx(fe,{icon:fi,size:16,strokeWidth:2})})]})]})}const h2e=[{titleKey:"navigation",items:[{labelKey:"goToTasks",shortcut:"meta+1"},{labelKey:"goToTerminals",shortcut:"meta+2"},{labelKey:"goToTaskTerminals",shortcut:"meta+i"},{labelKey:"goToRepositories",shortcut:"meta+3"},{labelKey:"goToReview",shortcut:"meta+4"},{labelKey:"goToMonitoring",shortcut:"meta+5"},{labelKey:"goToSettings",shortcut:"meta+,"}]},{titleKey:"actions",items:[{labelKey:"commandPalette",shortcut:"meta+k"},{labelKey:"newTask",shortcut:"meta+j"},{labelKey:"openInEditor",shortcut:"meta+e"},{labelKey:"keyboardShortcuts",shortcut:"meta+/"}]},{titleKey:"terminals",items:[{labelKey:"newTerminal",shortcut:"meta+d"},{labelKey:"closeTerminal",shortcut:"meta+w"}]},{titleKey:"general",items:[{labelKey:"closeModal",shortcut:"escape"},{labelKey:"submitForm",shortcut:"meta+enter"}]}];function p2e({open:e,onOpenChange:t}){const{t:n}=nn("navigation");return b.jsx(Iu,{open:e,onOpenChange:t,children:b.jsxs(Du,{className:"sm:max-w-md",children:[b.jsx(id,{children:b.jsx(ad,{children:n("shortcuts.title")})}),b.jsx(Mm,{className:"max-h-[60vh]",children:b.jsx("div",{className:"space-y-4 mt-2 pr-4",children:h2e.map(r=>b.jsxs("div",{children:[b.jsx("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:n(`shortcuts.groups.${r.titleKey}`)}),b.jsx("div",{className:"space-y-1",children:r.items.map(i=>b.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[b.jsx("span",{className:"text-sm",children:n(`shortcuts.labels.${i.labelKey}`)}),b.jsx("kbd",{className:"pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border border-border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",children:Ate(i.shortcut)})]},i.shortcut))})]},r.titleKey))})})]})})}const m2e={vscode:"vscode",cursor:"cursor",windsurf:"windsurf",zed:"zed",antigravity:"antigravity"};function Ew(e,t,n,r){const i=m2e[t];if(!n)return`${i}://file${e}`;const a=r!==22?`${n}:${r}`:n;return`${i}://vscode-remote/ssh-remote+${a}${e}`}function t3(e){return{vscode:"VS Code",cursor:"Cursor",windsurf:"Windsurf",zed:"Zed",antigravity:"Antigravity"}[e]}function nl(e){window.parent!==window?window.parent.postMessage({type:"vibora:openUrl",url:e},"*"):window.open(e,"_blank")}function g2e({open:e,onOpenChange:t}){const{t:n}=nn("navigation"),[r,i]=k.useState(""),[a,s]=k.useState(!1),{data:o}=r0(),{data:l}=i0(),{data:u}=a0();k.useEffect(()=>{e&&i("")},[e]);const f=()=>{if(!r.trim())return;const m=Ew(r.trim(),o??"vscode",l??"",u??22);nl(m),t(!1)},d=m=>{i(m)},p=t3(o??"vscode");return b.jsxs(b.Fragment,{children:[b.jsx(Iu,{open:e,onOpenChange:t,children:b.jsxs(Du,{className:"sm:max-w-md",children:[b.jsxs(id,{children:[b.jsx(ad,{children:n("openInEditor.title")}),b.jsx(Qy,{children:n("openInEditor.description",{editor:p})})]}),b.jsx("div",{className:"space-y-4",children:b.jsxs("div",{className:"space-y-2",children:[b.jsx("label",{className:"text-sm font-medium",children:n("openInEditor.pathLabel")}),b.jsxs("div",{className:"flex gap-2",children:[b.jsx(ln,{value:r,onChange:m=>i(m.target.value),placeholder:n("openInEditor.pathPlaceholder"),onKeyDown:m=>m.key==="Enter"&&f(),className:"flex-1 font-mono text-sm"}),b.jsx(We,{variant:"outline",size:"icon",onClick:()=>s(!0),title:n("openInEditor.browse"),children:b.jsx(fe,{icon:Ri,size:16,strokeWidth:2})})]}),b.jsx("p",{className:"text-xs text-muted-foreground",children:n("openInEditor.pathHint")})]})}),b.jsxs(Gc,{children:[b.jsx(Mf,{render:b.jsx(We,{variant:"outline"}),children:n("openInEditor.cancel")}),b.jsx(We,{onClick:f,disabled:!r.trim(),children:n("openInEditor.open")})]})]})}),b.jsx($c,{open:a,onOpenChange:s,onSelect:d})]})}const b2e=({...e})=>{const{resolvedTheme:t}=Qc();return b.jsx(O_e,{theme:t,className:"toaster group",icons:{success:b.jsx(fe,{icon:mte,strokeWidth:2,className:"size-4"}),info:b.jsx(fe,{icon:U1e,strokeWidth:2,className:"size-4"}),warning:b.jsx(fe,{icon:rs,strokeWidth:2,className:"size-4"}),error:b.jsx(fe,{icon:W1e,strokeWidth:2,className:"size-4"}),loading:b.jsx(fe,{icon:tn,strokeWidth:2,className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},toastOptions:{classNames:{toast:"cn-toast"}},...e})},ko=rme({component:x2e});function v2e(){return Twe(),null}function y2e(){return Wne(),null}function _2e(){return xie(),null}function E2e(){const e=ri({select:n=>n.location}),{updateViewTracking:t}=wie();return k.useEffect(()=>{const n=e.pathname;let r="other",i=null,a=null;n.startsWith("/tasks/")?(r="task-detail",i=n.split("/")[2]||null):n==="/terminals"&&(r="terminals",a=new URLSearchParams(e.search).get("tab")),t(r,i,a)},[e.pathname,e.search,t]),null}function S2e(){const e=ri({select:t=>t.location});return k.useEffect(()=>{window.parent!==window&&window.parent.postMessage({type:"vibora:route",pathname:e.pathname,search:e.search},"*")},[e.pathname,e.search]),null}function x2e(){const[e,t]=k.useState(null),[n,r]=k.useState(!1),[i,a]=k.useState(!1),[s,o]=k.useState(!1),l=typeof window<"u"&&window.parent!==window,u=k.useCallback(E=>{t(()=>E)},[]),f=k.useCallback(()=>{e?.()},[e]),d=k.useCallback(()=>{r(!0)},[]),p=k.useCallback(()=>{a(!0)},[]),m=k.useCallback(()=>{o(!0)},[]);return b.jsx(D_e,{children:b.jsxs("div",{className:"flex h-screen flex-col overflow-x-hidden bg-background text-foreground",children:[b.jsx(v2e,{}),b.jsx(y2e,{}),b.jsx(_2e,{}),b.jsx(E2e,{}),b.jsx(S2e,{}),b.jsx(u2e,{}),b.jsx(f2e,{}),b.jsx(Ewe,{onNewTaskRef:u,onOpenCommandPalette:p}),b.jsxs("main",{className:"isolate flex-1 overflow-hidden relative",children:[b.jsx(ZRe,{}),b.jsx(hJ,{})]}),b.jsx(KRe,{open:i,onOpenChange:a,onNewTask:f,onShowShortcuts:d,onOpenInEditor:m}),b.jsx(p2e,{open:n,onOpenChange:r}),b.jsx(g2e,{open:s,onOpenChange:o}),b.jsx(b2e,{position:l?"bottom-center":"bottom-right"})]})})}const w2e=js("/")({beforeLoad:()=>{throw ZQ({to:"/tasks"})}}),wD="";function Cie(){const[e,t]=k.useState(new Map),[n,r]=k.useState(null),[i,a]=k.useState(!0),[s,o]=k.useState(!1),[l,u]=k.useState(null),f=k.useRef(null),d=k.useRef(0),p=k.useRef(!1),m=k.useCallback(async()=>{a(!0),u(null);try{const g=await fetch(`${wD}/api/worktrees/json`);if(!g.ok)throw new Error("Failed to fetch worktrees");const y=await g.json();t(new Map(y.worktrees.map(v=>[v.path,{...v,size:v.size||0,sizeFormatted:v.sizeFormatted||"0 B",branch:v.branch||"unknown"}]))),r(y.summary),a(!1),o(!1)}catch(g){u(g instanceof Error?g:new Error("Failed to load worktrees")),a(!1),o(!1)}},[]),E=k.useCallback(()=>{if(p.current){m();return}f.current?.close(),a(!0),o(!1),u(null),t(new Map),r(null);const g=new EventSource(`${wD}/api/worktrees`);f.current=g,g.addEventListener("worktree:basic",y=>{const v=JSON.parse(y.data);d.current=v.length,t(new Map(v.map(x=>[x.path,{...x,size:0,sizeFormatted:"...",branch:"..."}]))),a(!1),o(v.length>0)}),g.addEventListener("worktree:details",y=>{const v=JSON.parse(y.data);t(x=>{const T=new Map(x),w=T.get(v.path);return w&&T.set(v.path,{...w,size:v.size,sizeFormatted:v.sizeFormatted,branch:v.branch}),T}),d.current--,d.current<=0&&o(!1)}),g.addEventListener("worktree:complete",y=>{const v=JSON.parse(y.data);r(v),o(!1),g.close()}),g.addEventListener("worktree:error",y=>{const{path:v}=JSON.parse(y.data);At.viewer.error("Error loading worktree details",{path:v}),d.current--,d.current<=0&&o(!1)}),g.onerror=()=>{g.close(),At.viewer.info("SSE connection failed, trying JSON fallback"),p.current=!0,m()}},[m]);return k.useEffect(()=>(E(),()=>{f.current?.close()}),[E]),{worktrees:k.useMemo(()=>Array.from(e.values()).sort((y,v)=>y.isOrphaned!==v.isOrphaned?y.isOrphaned?-1:1:new Date(v.lastModified).getTime()-new Date(y.lastModified).getTime()),[e]),summary:n,isLoading:i,isLoadingDetails:s,error:l,refetch:E}}function Aie(){const e=wr();return Fn({mutationFn:({worktreePath:t,repoPath:n,deleteLinkedTask:r})=>zt(`${wD}/api/worktrees`,{method:"DELETE",body:JSON.stringify({worktreePath:t,repoPath:n,deleteLinkedTask:r})}),onSuccess:()=>{e.invalidateQueries({queryKey:["worktrees"]}),e.invalidateQueries({queryKey:["tasks"]})}})}const T2e=ed("h-5 gap-1 rounded-full border border-transparent px-2 py-0.5 text-[0.625rem] font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-2.5! inline-flex items-center justify-center w-fit whitespace-nowrap shrink-0 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-colors overflow-hidden group/badge",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 [a]:hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 text-destructive dark:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground bg-input/20 dark:bg-input/30",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function co({className:e,variant:t="default",render:n,...r}){return kxe({defaultTagName:"span",props:ll({className:Be(T2e({className:e,variant:t}))},r),render:n,state:{slot:"badge",variant:t}})}function Ta({className:e,size:t="default",...n}){return b.jsx("div",{"data-slot":"card","data-size":t,className:Be("ring-foreground/10 bg-card text-card-foreground gap-4 overflow-hidden rounded-lg py-4 text-xs/relaxed ring-1 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 *:[img:first-child]:rounded-t-lg *:[img:last-child]:rounded-b-lg group/card flex flex-col",e),...n})}function C2e({className:e,...t}){return b.jsx("div",{"data-slot":"card-header",className:Be("gap-1 rounded-t-lg px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]",e),...t})}function A2e({className:e,...t}){return b.jsx("div",{"data-slot":"card-title",className:Be("text-sm font-medium",e),...t})}function Bf({className:e,...t}){return b.jsx("div",{"data-slot":"card-content",className:Be("px-4 group-data-[size=sm]/card:px-3",e),...t})}function go({...e}){return b.jsx(HEe,{"data-slot":"alert-dialog",...e})}function Tu({...e}){return b.jsx(jte,{"data-slot":"alert-dialog-trigger",...e})}function k2e({...e}){return b.jsx(Dte,{"data-slot":"alert-dialog-portal",...e})}function O2e({className:e,...t}){return b.jsx(Ote,{"data-slot":"alert-dialog-overlay",className:Be("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/80 duration-100 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 isolate z-50",e),...t})}function bo({className:e,size:t="default",...n}){return b.jsxs(k2e,{children:[b.jsx(O2e,{}),b.jsx(Ite,{"data-slot":"alert-dialog-content","data-size":t,className:Be("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 bg-background ring-foreground/10 gap-3 rounded-xl p-4 ring-1 duration-100 data-[size=default]:max-w-xs data-[size=sm]:max-w-64 data-[size=default]:sm:max-w-sm group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 outline-none",e),...n})]})}function vo({className:e,...t}){return b.jsx("div",{"data-slot":"alert-dialog-header",className:Be("grid grid-rows-[auto_1fr] place-items-center gap-1 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...t})}function yo({className:e,...t}){return b.jsx("div",{"data-slot":"alert-dialog-footer",className:Be("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",e),...t})}function _o({className:e,...t}){return b.jsx(Mte,{"data-slot":"alert-dialog-title",className:Be("text-sm font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...t})}function Eo({className:e,...t}){return b.jsx(Rte,{"data-slot":"alert-dialog-description",className:Be("text-muted-foreground *:[a]:hover:text-foreground text-xs/relaxed text-balance md:text-pretty *:[a]:underline *:[a]:underline-offset-3",e),...t})}function qp({className:e,...t}){return b.jsx(We,{"data-slot":"alert-dialog-action",className:Be(e),...t})}function So({className:e,variant:t="outline",size:n="default",...r}){return b.jsx(Zx,{"data-slot":"alert-dialog-cancel",className:Be(e),render:b.jsx(We,{variant:t,size:n}),...r})}const hi=k.forwardRef(({className:e,...t},n)=>b.jsx(vSe,{ref:n,className:Be("peer size-4 shrink-0 rounded border border-input ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50","data-checked:bg-primary data-checked:border-primary data-checked:text-primary-foreground","flex items-center justify-center transition-colors",e),...t,children:b.jsx(ySe,{className:"flex items-center justify-center",children:b.jsx(fe,{icon:ml,size:12,strokeWidth:3})})}));hi.displayName="Checkbox";const TD={IN_PROGRESS:"bg-muted-foreground/20 text-muted-foreground",IN_REVIEW:"bg-primary/20 text-primary",DONE:"bg-accent/20 text-accent",CANCELED:"bg-destructive/20 text-destructive",ORPHANED:"bg-destructive/20 text-destructive"},R2e=js("/worktrees/")({component:L2e});function N2e(){const{t:e}=nn("common");return t=>{const n=new Date(t),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3),s=Math.floor(a/60),o=Math.floor(s/60),l=Math.floor(o/24);return l>0?l===1?e("time.dayAgo"):e("time.daysAgo",{count:l}):o>0?o===1?e("time.hourAgo"):e("time.hoursAgo",{count:o}):s>0?s===1?e("time.minuteAgo"):e("time.minutesAgo",{count:s}):e("time.justNow")}}function lH({className:e}){return b.jsx("span",{className:`inline-block animate-pulse rounded bg-muted ${e}`})}function I2e({worktree:e,onDelete:t}){const{t:n}=nn("common"),{t:r}=nn("worktrees"),i=N2e(),[a,s]=k.useState(!1),[o,l]=k.useState(!1),[u,f]=k.useState(!1),d=e.sizeFormatted==="..."||e.branch==="...",p=!e.isOrphaned&&e.taskId,m=async()=>{l(!0);try{await t(e,u),s(!1)}catch{}finally{l(!1)}},E=S=>{s(S),S||f(!1)};return b.jsx(Ta,{className:"transition-colors hover:border-border/80",children:b.jsxs(Bf,{className:"flex items-start justify-between gap-4 py-4",children:[b.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx("span",{className:"truncate font-medium",children:e.name}),e.isOrphaned?b.jsx(co,{className:Be("shrink-0",TD.ORPHANED),children:n("statuses.ORPHANED")}):e.taskStatus?b.jsx(co,{className:Be("shrink-0",TD[e.taskStatus]),children:n(`statuses.${e.taskStatus}`)}):null]}),b.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[b.jsxs("div",{className:"flex items-center gap-1.5",children:[b.jsx(fe,{icon:Ri,size:12,strokeWidth:2,className:"shrink-0"}),b.jsx("span",{className:"truncate font-mono",children:e.path})]}),b.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:[b.jsxs("div",{className:"flex items-center gap-1.5",children:[b.jsx(fe,{icon:Yx,size:12,strokeWidth:2,className:"shrink-0"}),e.branch==="..."?b.jsx(lH,{className:"h-3 w-16"}):b.jsx("span",{className:"font-mono",children:e.branch})]}),b.jsxs("div",{className:"flex items-center gap-1.5",children:[b.jsx(fe,{icon:vte,size:12,strokeWidth:2,className:"shrink-0"}),e.sizeFormatted==="..."?b.jsx(lH,{className:"h-3 w-12"}):b.jsx("span",{children:e.sizeFormatted})]}),b.jsxs("div",{className:"flex items-center gap-1.5",children:[b.jsx(fe,{icon:hte,size:12,strokeWidth:2,className:"shrink-0"}),b.jsx("span",{children:i(e.lastModified)})]})]}),e.taskId&&e.taskTitle&&b.jsx("div",{className:"flex items-center gap-1.5 pt-1",children:b.jsxs(Ai,{to:"/tasks/$taskId",params:{taskId:e.taskId},className:"inline-flex items-center gap-1 text-foreground hover:underline",children:[b.jsx("span",{className:"truncate",children:e.taskTitle}),b.jsx(fe,{icon:Zy,size:12,strokeWidth:2,className:"shrink-0"})]})})]})]}),b.jsxs(go,{open:a,onOpenChange:E,children:[b.jsx(Tu,{render:b.jsx(We,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-muted-foreground hover:text-destructive",disabled:d}),children:b.jsx(fe,{icon:vu,size:14,strokeWidth:2})}),b.jsxs(bo,{children:[b.jsxs(vo,{children:[b.jsx(_o,{children:r("delete.title")}),b.jsxs(Eo,{children:[r("delete.description")," ",b.jsx("span",{className:"font-mono",children:e.name}),".",u&&p&&b.jsxs(b.Fragment,{children:[" ",r("delete.linkedTaskWillBeDeleted",{title:e.taskTitle})]})," ",r("delete.cannotUndo")]}),p&&b.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[b.jsx(hi,{checked:u,onCheckedChange:S=>f(S===!0),disabled:o}),r("delete.alsoDeleteLinkedTask",{title:e.taskTitle})]})]}),b.jsxs(yo,{children:[b.jsx(So,{disabled:o,children:n("buttons.cancel")}),b.jsxs(We,{variant:"destructive",onClick:m,disabled:o,className:"gap-2",children:[o&&b.jsx(fe,{icon:tn,size:14,strokeWidth:2,className:"animate-spin"}),n(o?"status.deleting":"buttons.delete")]})]})]})]})]})})}const D2e=["IN_PROGRESS","IN_REVIEW","DONE","CANCELED","ORPHANED"];function L2e(){const{t:e}=nn("common"),{t}=nn("worktrees"),{worktrees:n,summary:r,isLoading:i,isLoadingDetails:a,error:s,refetch:o}=Cie(),l=Aie(),[u,f]=k.useState(new Set),[d,p]=k.useState(!1),[m,E]=k.useState(!1),[S,g]=k.useState(!1),y=O=>{f(N=>{const D=new Set(N);return D.has(O)?D.delete(O):D.add(O),D})},v=()=>{f(new Set)},x=k.useMemo(()=>u.size===0?n:n.filter(O=>!!(O.isOrphaned&&u.has("ORPHANED")||O.taskStatus&&u.has(O.taskStatus))),[n,u]),T=k.useMemo(()=>n.filter(O=>O.taskStatus==="DONE"||O.taskStatus==="CANCELED"),[n]),w=async()=>{if(T.length!==0){E(!0);try{for(const O of T)await l.mutateAsync({worktreePath:O.path,repoPath:O.repoPath,deleteLinkedTask:S});p(!1),o()}catch{}finally{E(!1)}}},C=O=>{p(O),O||g(!1)},R=async(O,N)=>{await l.mutateAsync({worktreePath:O.path,repoPath:O.repoPath,deleteLinkedTask:N}),o()};return b.jsxs("div",{className:"flex h-full flex-col",children:[b.jsxs("div",{className:"flex shrink-0 flex-col gap-2 border-b border-border bg-background px-4 py-2",children:[b.jsxs("div",{className:"flex items-center justify-between",children:[b.jsxs("div",{className:"flex items-center gap-4",children:[b.jsx("h1",{className:"text-sm font-medium",children:t("title")}),(r||n.length>0)&&b.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[b.jsx("span",{children:t("summary.total",{count:r?.total??n.length})}),(r?.orphaned??n.filter(O=>O.isOrphaned).length)>0&&b.jsx("span",{className:"text-destructive",children:t("summary.orphaned",{count:r?.orphaned??n.filter(O=>O.isOrphaned).length})}),a?b.jsx("span",{className:"animate-pulse",children:e("status.calculating")}):r?b.jsx("span",{children:r.totalSizeFormatted}):null]})]}),b.jsxs("div",{className:"flex items-center gap-2",children:[T.length>0&&b.jsxs(go,{open:d,onOpenChange:C,children:[b.jsxs(Tu,{render:b.jsx(We,{variant:"ghost",size:"sm",className:"gap-1.5 text-xs text-muted-foreground hover:text-destructive",disabled:a}),children:[b.jsx(fe,{icon:gte,size:12,strokeWidth:2}),t("cleanup.button",{count:T.length})]}),b.jsxs(bo,{children:[b.jsxs(vo,{children:[b.jsx(_o,{children:t("cleanup.title")}),b.jsxs(Eo,{children:[t("cleanup.description",{count:T.length}),S&&` ${t("cleanup.linkedTasksWillBeDeleted")}`]}),b.jsxs("div",{className:"space-y-3",children:[b.jsxs("p",{className:"text-sm text-muted-foreground",children:[T.filter(O=>O.taskStatus==="DONE").length>0&&b.jsxs("span",{className:"mr-3",children:[b.jsx("span",{className:"font-medium text-accent",children:T.filter(O=>O.taskStatus==="DONE").length})," ",t("cleanup.done")]}),T.filter(O=>O.taskStatus==="CANCELED").length>0&&b.jsxs("span",{children:[b.jsx("span",{className:"font-medium text-destructive",children:T.filter(O=>O.taskStatus==="CANCELED").length})," ",t("cleanup.canceled")]})]}),b.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[b.jsx(hi,{checked:S,onCheckedChange:O=>g(O===!0),disabled:m}),t("cleanup.alsoDeleteLinkedTasks")]}),b.jsx("p",{className:"font-medium text-destructive text-xs",children:t("cleanup.cannotUndo")})]})]}),b.jsxs(yo,{children:[b.jsx(So,{disabled:m,children:e("buttons.cancel")}),b.jsxs(We,{variant:"destructive",onClick:w,disabled:m,className:"gap-2",children:[m&&b.jsx(fe,{icon:tn,size:14,strokeWidth:2,className:"animate-spin"}),m?e("status.deleting"):t("delete.button",{count:T.length})]})]})]})]}),u.size>0&&b.jsxs(We,{variant:"ghost",size:"sm",onClick:v,className:"gap-1.5 text-xs",children:[b.jsx(fe,{icon:fi,size:12,strokeWidth:2}),e("buttons.clearFilters")]})]})]}),b.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:D2e.map(O=>{const N=u.has(O);return b.jsx("button",{onClick:()=>y(O),className:Be("rounded-full px-2.5 py-1 text-xs font-medium transition-colors",N?TD[O]:"bg-muted text-muted-foreground hover:bg-muted/80"),children:e(`statuses.${O}`)},O)})})]}),b.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[i&&b.jsx("div",{className:"flex items-center justify-center py-12",children:b.jsx(fe,{icon:tn,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}),s&&b.jsxs("div",{className:"flex items-center gap-3 py-6 text-destructive",children:[b.jsx(fe,{icon:rs,size:20,strokeWidth:2}),b.jsx("span",{className:"text-sm",children:t("error.failedToLoad",{message:s.message})})]}),!i&&!s&&x.length===0&&b.jsx("div",{className:"py-12 text-muted-foreground",children:b.jsx("p",{className:"text-sm",children:u.size>0?t("empty.noMatch"):t("empty.noWorktrees")})}),!i&&b.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:x.map(O=>b.jsx(I2e,{worktree:O,onDelete:R},O.path))})]})]})}function Wn(e,t="Assertion error"){if(!e)throw Error(t)}function Kp({group:e}){const{orientation:t,panels:n}=e;return n.reduce((r,i)=>(r+=t==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,r),0)}function CD(e,t){return t.sort(e==="horizontal"?P2e:M2e)}function P2e(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function M2e(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function kie(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function j2e({orientation:e,rects:t,targetRect:n}){const r={x:n.x+n.width/2,y:n.y+n.height/2};let i,a=Number.MAX_VALUE;for(const s of t){const{x:o,y:l}=kie(r,s),u=e==="horizontal"?o:l;u<a&&(a=u,i=s)}return Wn(i,"No rect found"),i}function Oie(e){const{element:t,orientation:n,panels:r,separators:i}=e,a=CD(n,Array.from(t.children).filter(f=>f instanceof HTMLElement).map(f=>({element:f}))).map(({element:f})=>f),s=[];let o=!1,l,u=[];for(const f of a)if(f.hasAttribute("data-panel")){const d=r.find(p=>p.element===f);if(d){if(l){const p=l.element.getBoundingClientRect(),m=f.getBoundingClientRect();let E;if(o){const S=n==="horizontal"?new DOMRect(p.right,p.top,0,p.height):new DOMRect(p.left,p.bottom,p.width,0),g=n==="horizontal"?new DOMRect(m.left,m.top,0,m.height):new DOMRect(m.left,m.top,m.width,0);switch(u.length){case 0:{E=[S,g];break}case 1:{const y=u[0],v=j2e({orientation:n,rects:[p,m],targetRect:y.element.getBoundingClientRect()});E=[y,v===p?g:S];break}default:{E=u;break}}}else u.length?E=u:E=[n==="horizontal"?new DOMRect(p.right,m.top,m.left-p.right,m.height):new DOMRect(m.left,p.bottom,m.width,m.top-p.bottom)];for(const S of E)s.push({group:e,groupSize:Kp({group:e}),panels:[l,d],separator:"width"in S?void 0:S,rect:"width"in S?S:S.element.getBoundingClientRect()})}o=!1,l=d,u=[]}}else if(f.hasAttribute("data-separator")){const d=i.find(p=>p.element===f);d?u.push(d):(l=void 0,u=[])}else o=!0;return s}function F2e(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function B2e(e,t){const n=getComputedStyle(e.ownerDocument.body),r=parseFloat(n.fontSize);return t*r}function U2e(e){return e/100*window.innerHeight}function $2e(e){return e/100*window.innerWidth}function z2e(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function I_({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,a]=z2e(n);switch(a){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=B2e(t,i);break}case"em":{r=F2e(t,i);break}case"vh":{r=U2e(i);break}case"vw":{r=$2e(i);break}}return r}function ao(e){return parseFloat(e.toFixed(3))}function uH(e){const{panels:t}=e,n=Kp({group:e});return n===0?t.map(r=>({collapsedSize:0,collapsible:r.panelConstraints.collapsible===!0,defaultSize:void 0,minSize:0,maxSize:100,panelId:r.id})):t.map(r=>{const{element:i,panelConstraints:a}=r;let s=0;if(a.collapsedSize){const f=I_({groupSize:n,panelElement:i,styleProp:a.collapsedSize});s=ao(f/n*100)}let o;if(a.defaultSize){const f=I_({groupSize:n,panelElement:i,styleProp:a.defaultSize});o=ao(f/n*100)}let l=0;if(a.minSize){const f=I_({groupSize:n,panelElement:i,styleProp:a.minSize});l=ao(f/n*100)}let u=100;if(a.maxSize){const f=I_({groupSize:n,panelElement:i,styleProp:a.maxSize});u=ao(f/n*100)}return{collapsedSize:s,collapsible:a.collapsible===!0,defaultSize:o,minSize:l,maxSize:u,panelId:r.id}})}class H2e{#e={};addListener(t,n){const r=this.#e[t];return r===void 0?this.#e[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=this.#e[t];if(r!==void 0)if(r.length===1)r[0].call(null,n);else{let i=!1,a=null;const s=Array.from(r);for(let o=0;o<s.length;o++){const l=s[o];try{l.call(null,n)}catch(u){a===null&&(i=!0,a=u)}}if(i)throw a}}removeAllListeners(){this.#e={}}removeListener(t,n){const r=this.#e[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}function Ji(e,t,n=0){return Math.abs(ao(e)-ao(t))<=n}let Es={cursorFlags:0,interactionState:{state:"inactive"},mountedGroups:new Map};const xf=new H2e;function yl(){return Es}function Ls(e){const t=typeof e=="function"?e(Es):e;if(Es===t)return Es;const n=Es;return Es={...Es,...t},t.cursorFlags!==void 0&&xf.emit("cursorFlagsChange",Es.cursorFlags),t.interactionState!==void 0&&xf.emit("interactionStateChange",Es.interactionState),t.mountedGroups!==void 0&&(Es.mountedGroups.forEach((r,i)=>{r.derivedPanelConstraints.forEach(a=>{if(a.collapsible){const{layout:s}=n.mountedGroups.get(i)??{};if(s){const o=Ji(a.collapsedSize,r.layout[a.panelId]),l=Ji(a.collapsedSize,s[a.panelId]);o&&!l&&(i.inMemoryLastExpandedPanelSizes[a.panelId]=s[a.panelId])}}})}),xf.emit("mountedGroupsChange",Es.mountedGroups)),Es}const W2e=e=>e,Lk=()=>{},Rie=1,Nie=2,Iie=4,Die=8,cH={coarse:10,precise:5};function V2e({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case"active":case"hover":t.forEach(a=>{if(!a.disableCursor)switch(a.orientation){case"horizontal":{r++;break}case"vertical":{i++;break}}})}if(r===0&&i===0)return null;switch(n){case"active":{const a=(e&Rie)!==0,s=(e&Nie)!==0,o=(e&Iie)!==0,l=(e&Die)!==0;if(e){if(a)return o?"se-resize":l?"ne-resize":"e-resize";if(s)return o?"sw-resize":l?"nw-resize":"w-resize";if(o)return"s-resize";if(l)return"n-resize"}break}}return r>0&&i>0?"move":r>0?"ew-resize":"ns-resize"}let Pk,jo;function n3(){jo===void 0&&(jo=new CSSStyleSheet,document.adoptedStyleSheets=[jo]);const{cursorFlags:e,interactionState:t}=yl();switch(t.state){case"active":case"hover":{const n=V2e({cursorFlags:e,groups:t.hitRegions.map(i=>i.group),state:t.state}),r=`*{cursor: ${n} !important; ${t.state==="active"?"touch-action: none;":""} }`;if(Pk===r)return;Pk=r,n?jo.cssRules.length===0?jo.insertRule(r):jo.replaceSync(r):jo.cssRules.length===1&&jo.deleteRule(0);break}case"inactive":{Pk=void 0,jo.cssRules.length===1&&jo.deleteRule(0);break}}}function G2e(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function $v(e,t){return Ji(e,t)?0:e>t?1:-1}function cp({panelConstraints:e,size:t}){const{collapsedSize:n=0,collapsible:r,maxSize:i=100,minSize:a=0}=e;if($v(t,a)<0)if(r){const s=(n+a)/2;$v(t,s)<0?t=n:t=a}else t=a;return t=Math.min(i,t),t=ao(t),t}function zv({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(Ji(e,0))return t;const s=Object.values(t),o=Object.values(i),l=[...s],[u,f]=r;Wn(u!=null,"Invalid first pivot index"),Wn(f!=null,"Invalid second pivot index");let d=0;if(a==="keyboard"){{const E=e<0?f:u,S=n[E];Wn(S,`Panel constraints not found for index ${E}`);const{collapsedSize:g=0,collapsible:y,minSize:v=0}=S;if(y){const x=s[E];if(Wn(x!=null,`Previous layout not found for panel index ${E}`),Ji(x,g)){const T=v-x;$v(T,Math.abs(e))>0&&(e=e<0?0-T:T)}}}{const E=e<0?u:f,S=n[E];Wn(S,`No panel constraints found for index ${E}`);const{collapsedSize:g=0,collapsible:y,minSize:v=0}=S;if(y){const x=s[E];if(Wn(x!=null,`Previous layout not found for panel index ${E}`),Ji(x,v)){const T=x-g;$v(T,Math.abs(e))>0&&(e=e<0?0-T:T)}}}}{const E=e<0?1:-1;let S=e<0?f:u,g=0;for(;;){const v=s[S];Wn(v!=null,`Previous layout not found for panel index ${S}`);const x=cp({panelConstraints:n[S],size:100})-v;if(g+=x,S+=E,S<0||S>=n.length)break}const y=Math.min(Math.abs(e),Math.abs(g));e=e<0?0-y:y}{let E=e<0?u:f;for(;E>=0&&E<n.length;){const S=Math.abs(e)-Math.abs(d),g=s[E];Wn(g!=null,`Previous layout not found for panel index ${E}`);const y=g-S,v=cp({panelConstraints:n[E],size:y});if(!Ji(g,v)&&(d+=g-v,l[E]=v,d.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?E--:E++}}if(G2e(o,l))return i;{const E=e<0?f:u,S=s[E];Wn(S!=null,`Previous layout not found for panel index ${E}`);const g=S+d,y=cp({panelConstraints:n[E],size:g});if(l[E]=y,!Ji(y,g)){let v=g-y,x=e<0?f:u;for(;x>=0&&x<n.length;){const T=l[x];Wn(T!=null,`Previous layout not found for panel index ${x}`);const w=T+v,C=cp({panelConstraints:n[x],size:w});if(Ji(T,C)||(v-=C-T,l[x]=C),Ji(v,0))break;e>0?x--:x++}}}const p=Object.values(l).reduce((E,S)=>S+E,0);if(!Ji(p,100,.1))return i;const m=Object.keys(i);return l.reduce((E,S,g)=>(E[m[g]]=S,E),{})}function zm(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||$v(e[n],t[n])!==0)return!1;return!0}function Lie({event:e,hitRegions:t,initialLayoutMap:n,mountedGroups:r,pointerDownAtPoint:i}){let a=0;const s=new Map(r);t.forEach(o=>{const{group:l,groupSize:u}=o,{disableCursor:f,orientation:d,panels:p}=l;let m=0;i?d==="horizontal"?m=(e.clientX-i.x)/u*100:m=(e.clientY-i.y)/u*100:d==="horizontal"?m=e.clientX<0?-100:100:m=e.clientY<0?-100:100;const E=n.get(l),{defaultLayoutDeferred:S,derivedPanelConstraints:g,layout:y,separatorToPanels:v}=r.get(l)??{defaultLayoutDeferred:!1};if(g&&E&&y&&v){const x=zv({delta:m,initialLayout:E,panelConstraints:g,pivotIndices:o.panels.map(T=>p.indexOf(T)),prevLayout:y,trigger:"mouse-or-touch"});if(zm(x,y)){if(m!==0&&!f)switch(d){case"horizontal":{a|=m<0?Rie:Nie;break}case"vertical":{a|=m<0?Iie:Die;break}}}else{s.set(o.group,{defaultLayoutDeferred:S,derivedPanelConstraints:g,layout:x,separatorToPanels:v});const T=o.group.panels.map(({id:w})=>w).join(",");o.group.inMemoryLayouts[T]=x}}}),Ls({cursorFlags:a,mountedGroups:s}),n3()}function dH(e){if(e.defaultPrevented||e.relatedTarget!==null||e.clientX===0&&e.clientY===0)return;const{interactionState:t,mountedGroups:n}=yl();t.state==="active"&&t.hitRegions.forEach(r=>{e.currentTarget===r.group.element&&Lie({event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n})})}function yE(e){const t=e.parentElement;Wn(t,"Parent group element not found");const{mountedGroups:n}=yl();for(const[r]of n)if(r.element===t)return r;throw Error("Could not find parent Group for separator element")}function Uf({layout:e,panelConstraints:t}){const n=[...Object.values(e)],r=n.reduce((s,o)=>s+o,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!Ji(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const o=n[s];Wn(o!=null,`No layout data found for index ${s}`);const l=100/r*o;n[s]=l}let i=0;for(let s=0;s<t.length;s++){const o=n[s];Wn(o!=null,`No layout data found for index ${s}`);const l=cp({panelConstraints:t[s],size:o});o!=l&&(i+=o-l,n[s]=l)}if(!Ji(i,0))for(let s=0;s<t.length;s++){const o=n[s];Wn(o!=null,`No layout data found for index ${s}`);const l=o+i,u=cp({panelConstraints:t[s],size:l});if(o!==u&&(i-=u-o,n[s]=u,Ji(i,0)))break}const a=Object.keys(e);return n.reduce((s,o,l)=>(s[a[l]]=o,s),{})}function Pie({groupId:e}){const t=()=>{const{mountedGroups:n}=yl();for(const[r,i]of n)if(r.id===e)return{group:r,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:r}=t();return n?{}:r},setLayout(n){const{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:a,layout:s,separatorToPanels:o}=t(),l=Uf({layout:n,panelConstraints:i});return r?s:(zm(s,l)||Ls(u=>({mountedGroups:new Map(u.mountedGroups).set(a,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:l,separatorToPanels:o})})),l)}}}function Mie(e){const{mountedGroups:t}=yl(),n=t.get(e);return Wn(n,`Mounted Group ${e.id} not found`),n}function Bd(e,t){const n=yE(e),r=Mie(n),i=n.separators.find(f=>f.element===e);Wn(i,"Matching separator not found");const a=r.separatorToPanels.get(i);Wn(a,"Matching panels not found");const s=a.map(f=>n.panels.indexOf(f)),o=Pie({groupId:n.id}).getLayout(),l=zv({delta:t,initialLayout:o,panelConstraints:r.derivedPanelConstraints,pivotIndices:s,prevLayout:o,trigger:"keyboard"}),u=Uf({layout:l,panelConstraints:r.derivedPanelConstraints});zm(o,u)||Ls(f=>({mountedGroups:new Map(f.mountedGroups).set(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,layout:u,separatorToPanels:r.separatorToPanels})}))}function fH(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=yE(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Bd(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Bd(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Bd(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Bd(t,-5);break}case"End":{e.preventDefault(),Bd(t,100);break}case"Enter":{e.preventDefault();const r=yE(t),{derivedPanelConstraints:i,layout:a,separatorToPanels:s}=Mie(r),o=r.separators.find(d=>d.element===t);Wn(o,"Matching separator not found");const l=s.get(o);Wn(l,"Matching panels not found");const u=l[0],f=i.find(d=>d.panelId===u.id);if(Wn(f,"Panel metadata not found"),f.collapsible){const d=a[u.id],p=f.collapsedSize===d?r.inMemoryLastExpandedPanelSizes[u.id]??f.minSize:f.collapsedSize;Bd(t,p-d)}break}case"F6":{e.preventDefault();const r=yE(t).separators.map(s=>s.element),i=Array.from(r).findIndex(s=>s===e.currentTarget);Wn(i!==null,"Index not found");const a=e.shiftKey?i>0?i-1:r.length-1:i+1<r.length?i+1:0;r[a].focus();break}case"Home":{e.preventDefault(),Bd(t,-100);break}}}function q2e(e,t,n){let r,i={x:1/0,y:1/0};for(const a of t){const s=kie(n,a.rect);switch(e){case"horizontal":{s.x<=i.x&&(r=a,i=s);break}case"vertical":{s.y<=i.y&&(r=a,i=s);break}}}return r?{distance:i,hitRegion:r}:void 0}let D_;function K2e(){return D_===void 0&&(typeof matchMedia=="function"?D_=!!matchMedia("(pointer:coarse)").matches:D_=!1),D_}function Y2e(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:mH(e),b:mH(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Wn(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:pH(hH(n.a)),b:pH(hH(n.b))};if(i.a===i.b){const a=r.childNodes,s={a:n.a.at(-1),b:n.b.at(-1)};let o=a.length;for(;o--;){const l=a[o];if(l===s.a)return 1;if(l===s.b)return-1}}return Math.sign(i.a-i.b)}const X2e=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Z2e(e){const t=getComputedStyle(jie(e)??e).display;return t==="flex"||t==="inline-flex"}function Q2e(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Z2e(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||X2e.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function hH(e){let t=e.length;for(;t--;){const n=e[t];if(Wn(n,"Missing node"),Q2e(n))return n}return null}function pH(e){return e&&Number(getComputedStyle(e).zIndex)||0}function mH(e){const t=[];for(;e;)t.push(e),e=jie(e);return t}function jie(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}function J2e(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function eNe({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!(n instanceof HTMLElement)||n.contains(e)||e.contains(n))return!0;if(Y2e(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(J2e(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Fie(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const a=K2e()?cH.coarse:cH.precise,s=Oie(i),o=q2e(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=a&&o.distance.y<=a&&eNe({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function gH(e){if(e.defaultPrevented)return;const{mountedGroups:t}=yl(),n=Fie(e,t),r=new Set,i=new Set,a=new Set,s=new Map;let o=!1;n.forEach(l=>{r.add(l.group),l.panels.forEach(f=>{i.add(f)}),l.separator&&(a.add(l.separator),o||(o=!0,l.separator.element.focus()));const u=t.get(l.group);u&&s.set(l.group,u.layout)}),Ls({interactionState:{hitRegions:n,initialLayoutMap:s,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}}),n.length&&e.preventDefault()}function bH(e){if(e.defaultPrevented)return;const{interactionState:t,mountedGroups:n}=yl();switch(t.state){case"active":{if(e.type!=="pointerleave"&&e.buttons===0){Ls(r=>r.interactionState.state==="inactive"?r:{cursorFlags:0,interactionState:{state:"inactive"}});return}Lie({event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint});break}default:{const r=Fie(e,n);r.length===0?t.state!=="inactive"&&Ls({interactionState:{state:"inactive"}}):Ls({interactionState:{hitRegions:r,state:"hover"}}),n3();break}}}function vH(e){if(e.defaultPrevented)return;e.preventDefault();const{interactionState:t}=yl();t.state==="active"&&(Ls({cursorFlags:0,interactionState:{state:"inactive"}}),n3())}function yH(e){let t=0,n=0;const r={};for(const a of e)if(a.defaultSize!==void 0){t++;const s=ao(a.defaultSize);n+=s,r[a.panelId]=s}else r[a.panelId]=void 0;const i=e.length-t;if(i!==0){const a=ao((100-n)/i);for(const s of e)s.defaultSize===void 0&&(r[s.panelId]=a)}return r}function tNe(e,t,n){const r=n[0];if(!r)return;const i=e.panels.find(s=>s.element===t);if(!i||!i.onResize)return;const a=Kp({group:e});i.onResize({asPercentage:ao(r.inlineSize/a*100),inPixels:r.inlineSize},i.id)}function nNe(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function rNe(e){let t=!0;const n=new Set,r=new Set,i=new ResizeObserver(m=>{for(const E of m){const{borderBoxSize:S,target:g}=E;if(g===e.element){if(t){if(Kp({group:e})===0)return;Ls(y=>{const v=y.mountedGroups.get(e);if(v){const x=uH(e),T=v.defaultLayoutDeferred?yH(x):v.layout,w=Uf({layout:T,panelConstraints:x});return!v.defaultLayoutDeferred&&zm(T,w)&&nNe(v.derivedPanelConstraints,x)?y:{mountedGroups:new Map(y.mountedGroups).set(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:x,layout:w,separatorToPanels:v.separatorToPanels})}}return y})}}else tNe(e,g,S)}});i.observe(e.element),e.panels.forEach(m=>{Wn(!n.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),n.add(m.id),m.onResize&&i.observe(m.element)});const a=Kp({group:e}),s=uH(e),o=e.panels.map(({id:m})=>m).join(",");let l=e.defaultLayout;l&&e.panels.length!==Object.keys(l).length&&(l=void 0);const u=e.inMemoryLayouts[o]??l??yH(s),f=Uf({layout:u,panelConstraints:s}),d=Oie(e),p=Ls(m=>{const E=new Map;return d.forEach(S=>{S.separator&&E.set(S.separator,S.panels)}),{mountedGroups:new Map(m.mountedGroups).set(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:s,layout:f,separatorToPanels:E})}});return e.element.addEventListener("pointerleave",dH),e.separators.forEach(m=>{Wn(!r.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),r.add(m.id),m.element.addEventListener("keydown",fH)}),p.mountedGroups.size===1&&(window.addEventListener("pointerdown",gH),window.addEventListener("pointermove",bH),window.addEventListener("pointerup",vH)),function(){t=!1;const m=Ls(E=>{const S=new Map(E.mountedGroups);return S.delete(e),{mountedGroups:S}});e.element.removeEventListener("pointerleave",dH),e.separators.forEach(E=>{E.element.removeEventListener("keydown",fH)}),m.mountedGroups.size===0&&(window.removeEventListener("pointerdown",gH),window.removeEventListener("pointermove",bH),window.removeEventListener("pointerup",vH)),i.disconnect()}}function r3(e){const t=k.useId();return`${e??t}`}const eh=typeof window<"u"?k.useLayoutEffect:k.useEffect;function i3(e){const t=k.useRef(e);return eh(()=>{t.current=e},[e]),k.useCallback(n=>t.current?.(n),[t])}function a3(...e){return i3(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function iNe(e){const t=k.useRef({...e});return eh(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const Bie="--react-resizable-panels--panel--pointer-events";function Uie(e,t){const n=e.replace(/[^a-zA-Z0-9\-_]/g,""),r=t.replace(/[^a-zA-Z0-9\-_]/g,"");return`--react-resizable-panels--${n}--${r}`}const $ie=k.createContext(null);function aNe(e,t){const n=k.useRef({getLayout:()=>({}),setLayout:W2e});k.useImperativeHandle(t,()=>n.current,[]),eh(()=>{Object.assign(n.current,Pie({groupId:e}))})}function sNe({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:s,id:o,onLayoutChange:l,orientation:u="horizontal",style:f,...d}){const p=k.useRef({}),m=i3(H=>{zm(p.current,H)||(p.current=H,l?.(H))}),E=r3(o),[S,g]=k.useState(!1),[y,v]=k.useState(null),[x,T]=k.useState(n??{}),[w,C]=k.useState([]),[R,O]=k.useState([]),N=k.useRef({lastExpandedPanelSizes:{},layouts:{}}),D=a3(v,a);aNe(E,s);const L=k.useMemo(()=>({id:E,orientation:u,registerPanel:H=>(C(B=>CD(u,[...B,H])),()=>{C(B=>B.filter(q=>q!==H))}),registerSeparator:H=>(O(B=>CD(u,[...B,H])),()=>{O(B=>B.filter(q=>q!==H))})}),[E,u]),z=iNe({defaultLayout:n,disableCursor:r}),M=k.useRef(null);eh(()=>{if(y===null)return;const H={defaultLayout:z.defaultLayout,disableCursor:!!z.disableCursor,disabled:!!i,element:y,id:E,inMemoryLastExpandedPanelSizes:N.current.lastExpandedPanelSizes,inMemoryLayouts:N.current.layouts,orientation:u,panels:w,separators:R};M.current=H;const B=rNe(H),q=yl().mountedGroups.get(H);if(q){const{defaultLayoutDeferred:j,derivedPanelConstraints:$,layout:Y}=q;!j&&$.length>0&&(T(Y),m?.(Y))}const K=xf.addListener("interactionStateChange",j=>{j.state==="active"?g(j.hitRegions.some($=>$.group===H)):g(!1)}),U=xf.addListener("mountedGroupsChange",j=>{const $=j.get(H);if($){const{defaultLayoutDeferred:Y,derivedPanelConstraints:W,layout:J}=$;if(Y||W.length===0)return;T(J),m?.(J)}});return()=>{M.current=null,B(),K(),U()}},[i,y,E,m,u,w,R,z]),k.useEffect(()=>{const H=M.current;H&&(H.defaultLayout=n,H.disableCursor=!!r)});const V={[Bie]:S?"none":void 0};for(const H in x){const B=Uie(E,H),q=x[H];V[B]=q}return b.jsx($ie.Provider,{value:L,children:b.jsx("div",{...d,"aria-orientation":u,className:t,"data-group":!0,"data-testid":E,id:E,ref:D,style:{...f,...V,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap"},children:e})})}function s3(){const e=k.useContext($ie);return Wn(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function oNe({groupId:e,panelId:t}){const n=()=>{const{mountedGroups:o}=yl();for(const[l,{defaultLayoutDeferred:u,derivedPanelConstraints:f,layout:d,separatorToPanels:p}]of o)if(l.id===e)return{defaultLayoutDeferred:u,derivedPanelConstraints:f,group:l,layout:d,separatorToPanels:p};throw Error(`Group ${e} not found`)},r=()=>{const o=n().derivedPanelConstraints.find(l=>l.panelId===t);if(o!==void 0)return o;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const o=n().group.panels.find(l=>l.id===t);if(o!==void 0)return o;throw Error(`Layout not found for Panel ${t}`)},a=()=>{const o=n().layout[t];if(o!==void 0)return o;throw Error(`Layout not found for Panel ${t}`)},s=o=>{const l=a();if(o===l)return;const{defaultLayoutDeferred:u,derivedPanelConstraints:f,group:d,layout:p,separatorToPanels:m}=n(),E=d.panels.findIndex(v=>v.id===t),S=E===d.panels.length-1,g=zv({delta:S?l-o:o-l,initialLayout:p,panelConstraints:f,pivotIndices:S?[E-1,E]:[E,E+1],prevLayout:p,trigger:"imperative-api"}),y=Uf({layout:g,panelConstraints:f});zm(p,y)||Ls(v=>({mountedGroups:new Map(v.mountedGroups).set(d,{defaultLayoutDeferred:u,derivedPanelConstraints:f,layout:y,separatorToPanels:m})}))};return{collapse:()=>{const{collapsible:o,collapsedSize:l}=r(),u=a();o&&u!==l&&s(l)},expand:()=>{const{collapsible:o,collapsedSize:l,minSize:u}=r(),f=a();o&&f===l&&s(u)},getSize:()=>{const{group:o}=n(),l=a(),{element:u}=i(),f=o.orientation==="horizontal"?u.offsetWidth:u.offsetHeight;return{asPercentage:l,inPixels:f}},isCollapsed:()=>{const{collapsible:o,collapsedSize:l}=r(),u=a();return o&&Ji(l,u)},resize:o=>{if(a()!==o){let l;switch(typeof o){case"number":{const{group:u}=n(),f=Kp({group:u});l=ao(o/f*100);break}case"string":{l=parseFloat(o);break}}s(l)}}}}function lNe(e,t){const{id:n}=s3(),r=k.useRef({collapse:Lk,expand:Lk,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Lk});k.useImperativeHandle(t,()=>r.current,[]),eh(()=>{Object.assign(r.current,oNe({groupId:n,panelId:e}))})}function uNe({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:i,elementRef:a,id:s,maxSize:o="100%",minSize:l="0%",onResize:u,panelRef:f,style:d,...p}){const m=!!s,E=r3(s),[S,g]=k.useState(null),y=a3(g,a),{id:v,registerPanel:x}=s3(),T=u!==null,w=i3(R=>{u?.(R,s)});eh(()=>{if(S!==null)return x({element:S,id:E,idIsStable:m,onResize:T?w:void 0,panelConstraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:o,minSize:l}})},[n,r,i,S,T,E,m,o,l,w,x]),lNe(E,f);const C=Uie(v,E);return b.jsx("div",{...p,"data-panel":!0,"data-testid":E,id:E,ref:y,style:{...cNe,flexBasis:0,flexGrow:`var(${C}, 1)`,flexShrink:1,overflow:"hidden",pointerEvents:`var(${Bie})`},children:b.jsx("div",{className:t,style:{width:"100%",height:"100%",...d},children:e})})}const cNe={minHeight:"unset",maxHeight:"unset",height:"unset",minWidth:"unset",maxWidth:"unset",width:"unset",flex:"unset",flexBasis:"unset",flexShrink:"unset",flexGrow:"unset",border:"unset",borderWidth:"unset",padding:"unset",margin:"unset"};function dNe({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a;const s=e[n],o=t.find(l=>l.panelId===n);if(o){const l=o.maxSize,u=a=o.collapsible?o.collapsedSize:o.minSize,f=[r,r+1];a=Uf({layout:zv({delta:u-s,initialLayout:e,panelConstraints:t,pivotIndices:f,prevLayout:e,trigger:"keyboard"}),panelConstraints:t})[n],i=Uf({layout:zv({delta:l-s,initialLayout:e,panelConstraints:t,pivotIndices:f,prevLayout:e,trigger:"keyboard"}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:s}}function fNe({children:e,className:t,elementRef:n,id:r,style:i,...a}){const s=r3(r),[o,l]=k.useState({}),[u,f]=k.useState("inactive"),[d,p]=k.useState(null),m=a3(p,n),{id:E,orientation:S,registerSeparator:g}=s3(),y=S==="horizontal"?"vertical":"horizontal";return eh(()=>{if(d!==null){const v={element:d,id:s},x=g(v),T=xf.addListener("interactionStateChange",C=>{f(C.state!=="inactive"&&C.hitRegions.some(R=>R.separator===v)?C.state:"inactive")}),w=xf.addListener("mountedGroupsChange",C=>{C.forEach(({derivedPanelConstraints:R,layout:O,separatorToPanels:N},D)=>{if(D.id===E){const L=N.get(v);if(L){const z=L[0],M=D.panels.indexOf(z);l(dNe({layout:O,panelConstraints:R,panelId:z.id,panelIndex:M}))}}})});return()=>{T(),w(),x()}}},[d,E,s,g]),b.jsx("div",{...a,"aria-controls":o.valueControls,"aria-orientation":y,"aria-valuemax":o.valueMax,"aria-valuemin":o.valueMin,"aria-valuenow":o.valueNow,children:e,className:t,"data-separator":u,"data-testid":s,id:s,ref:m,role:"separator",style:{flexBasis:"auto",...i,flexGrow:0,flexShrink:0},tabIndex:0})}function Yd({className:e,direction:t,...n}){return b.jsx(sNe,{"data-slot":"resizable-panel-group",orientation:t,className:Be("flex h-full w-full data-[orientation=vertical]:flex-col",e),...n})}function xs({...e}){return b.jsx(uNe,{"data-slot":"resizable-panel",...e})}function Xd({withHandle:e,className:t,...n}){return b.jsx(fNe,{"data-slot":"resizable-handle",className:Be("relative flex w-px items-center justify-center bg-border cursor-grab active:cursor-grabbing group touch-none","focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/60","focus-visible:ring-offset-1 focus-visible:ring-offset-background","data-[orientation=vertical]:h-px data-[orientation=vertical]:w-full data-[orientation=vertical]:cursor-row-resize","[&[data-orientation=vertical]>div]:rotate-90",t),...n,children:e&&b.jsxs("div",{className:"pointer-events-none absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 flex flex-col items-center gap-1 bg-muted/90 border border-border rounded-full px-1 py-3 opacity-70 group-hover:opacity-100 group-focus:opacity-100 transition-opacity shadow-sm",children:[b.jsx("span",{className:"w-0.5 h-0.5 rounded-full bg-muted-foreground"}),b.jsx("span",{className:"w-0.5 h-0.5 rounded-full bg-muted-foreground"}),b.jsx("span",{className:"w-0.5 h-0.5 rounded-full bg-muted-foreground"})]})})}var Mk={exports:{}},_H;function hNe(){return _H||(_H=1,(function(e,t){(function(n,r){e.exports=r()})(globalThis,(()=>(()=>{var n={4567:function(s,o,l){var u=this&&this.__decorate||function(v,x,T,w){var C,R=arguments.length,O=R<3?x:w===null?w=Object.getOwnPropertyDescriptor(x,T):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(v,x,T,w);else for(var N=v.length-1;N>=0;N--)(C=v[N])&&(O=(R<3?C(O):R>3?C(x,T,O):C(x,T))||O);return R>3&&O&&Object.defineProperty(x,T,O),O},f=this&&this.__param||function(v,x){return function(T,w){x(T,w,v)}};Object.defineProperty(o,"__esModule",{value:!0}),o.AccessibilityManager=void 0;const d=l(9042),p=l(9924),m=l(844),E=l(4725),S=l(2585),g=l(3656);let y=o.AccessibilityManager=class extends m.Disposable{constructor(v,x,T,w){super(),this._terminal=v,this._coreBrowserService=T,this._renderService=w,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let C=0;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);if(this._topBoundaryFocusListener=C=>this._handleBoundaryFocus(C,0),this._bottomBoundaryFocusListener=C=>this._handleBoundaryFocus(C,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new p.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((C=>this._handleResize(C.rows)))),this.register(this._terminal.onRender((C=>this._refreshRows(C.start,C.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((C=>this._handleChar(C)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
31
+ `}}),!1):!0);const s=r.onData(u=>{t().send({type:"terminal:input",payload:{terminalId:n,data:u}})}),o=()=>{this.setLastFocusedTerminal(n)};r.textarea?.addEventListener("focus",o),i?.onAttached&&(e.terminalsReadyForCallback.has(n)?(t().log.ws.debug("attachXterm: terminal already attached, calling callback immediately",{terminalId:n}),e.terminalsReadyForCallback.delete(n),setTimeout(()=>i.onAttached?.(n),0)):(t().log.ws.debug("attachXterm: registering onAttached callback",{terminalId:n,existingCallbacks:Array.from(e.onAttachedCallbacks.keys())}),e.onAttachedCallbacks.set(n,i.onAttached)));const l=()=>{s.dispose(),r.textarea?.removeEventListener("focus",o),e.terminals.get(n)?.setXterm(null)};return a.setAttachCleanup(l),t().send({type:"terminal:attach",payload:{terminalId:n}}),l},requestAttach(n){t().send({type:"terminal:attach",payload:{terminalId:n}})},clearTerminalBuffer(n){t().send({type:"terminal:clearBuffer",payload:{terminalId:n}})},assignTerminalToTab(n,r,i){t().send({type:"terminal:assignTab",payload:{terminalId:n,tabId:r,positionInTab:i}}),e.terminals.get(n)?.assignToTab(r,i)},createTab(n,r,i,a){const s=SD(),o=tH(),l=r??e.tabs.items.length,u={id:o,name:n,position:l,directory:i??null,createdAt:Date.now()},f=Gz(e.tabs);e.tabs.add(u),f.stop(),e.tabs.get(o)?.setPending(!0),e.pendingTabCreation=o,e.pendingUpdates.set(s,{entityType:"tab",tempId:o,inversePatches:f.inversePatches,createdAt:Date.now()}),t().send({type:"tab:create",payload:{name:n,position:r,directory:i,adoptTerminalId:a,requestId:s,tempId:o}}),t().log.ws.debug("createTab optimistic",{requestId:s,tempId:o,name:n,adoptTerminalId:a})},updateTab(n,r){t().send({type:"tab:update",payload:{tabId:n,...r}}),e.tabs.get(n)?.updateFromServer(r)},deleteTab(n){t().send({type:"tab:delete",payload:{tabId:n}}),e.tabs.remove(n),e.viewState.clearFocusedTerminalForTab(n)},reorderTab(n,r){const i=e.tabs.get(n);if(!i)return;const a=i.position;if(t().send({type:"tab:reorder",payload:{tabId:n,position:r}}),r>a)for(const s of e.tabs.items)s.position>a&&s.position<=r&&s.setPosition(s.position-1);else if(r<a)for(const s of e.tabs.items)s.position>=r&&s.position<a&&s.setPosition(s.position+1);i.setPosition(r)},handleMessage(n){const{type:r,payload:i}=n;switch(r){case"terminals:list":e.terminals.replaceAll(i.terminals);break;case"terminal:created":{const{terminal:a,isNew:s,requestId:o,tempId:l}=i;if(o&&l){const u=e.pendingUpdates.get(o);if(u&&u.tempId===l){e.pendingUpdates.delete(o);const f=e.terminals.get(l);if(f){const d=f.xterm,p=e.onAttachedCallbacks.get(l),m=f.attachCleanup;if(t().log.ws.info("terminal:created optimistic handling",{tempId:l,realId:a.id,hasXterm:!!d,hasCallback:!!p,isNew:s}),m&&m(),f.setXterm(null),f.setAttachCleanup(null),e.onAttachedCallbacks.delete(l),s){const E=f.isStartingUp,S=e.terminals.items.findIndex(v=>v.id===l);S>=0&&lS(e.terminals.items[S]),e.terminals.add(a);const g=e.terminals.get(a.id);E&&g&&(g.setStartingUp(!0),t().log.ws.info("terminal:created transferred isStartingUp",{tempId:l,realId:a.id,isStartingUp:g.isStartingUp})),t().log.ws.info("terminal:created re-attaching xterm",{realId:a.id,hasRealTerminal:!!g,hasXterm:!!d,willAttach:!!(g&&d)}),g&&d?this.attachXterm(a.id,d,{onAttached:p}):p&&(t().log.ws.info("terminal:created preserving callback for later",{realId:a.id}),e.onAttachedCallbacks.set(a.id,p)),e.newTerminalIds.delete(l),e.newTerminalIds.add(a.id);const y=e.terminalsPendingStartup.get(l);y&&(e.terminalsPendingStartup.delete(l),e.terminalsPendingStartup.set(a.id,y),t().log.ws.debug("transferred pending startup",{tempId:l,realId:a.id})),t().log.ws.debug("terminal:created confirmed",{requestId:o,tempId:l,realId:a.id,xtermReattached:!!d,hasPendingStartup:!!y})}else{const E=e.terminals.items.findIndex(g=>g.id===l);E>=0&&lS(e.terminals.items[E]),e.newTerminalIds.delete(l),e.terminalsPendingStartup.delete(l),e.terminals.has(a.id)||e.terminals.add(a),e.terminals.get(a.id)&&d&&this.attachXterm(a.id,d,{onAttached:p}),t().log.ws.debug("terminal:created deduplicated",{requestId:o,tempId:l,existingId:a.id,xtermReattached:!!d})}}break}}e.terminals.add(a),s&&e.newTerminalIds.add(a.id);break}case"terminal:destroyed":{const{terminalId:a}=i;e.terminals.remove(a),e.newTerminalIds.delete(a),e.terminalsReadyForCallback.delete(a),e.onAttachedCallbacks.delete(a);break}case"terminal:output":{const{terminalId:a,data:s}=i,o=e.terminals.get(a);o?.xterm?o.xterm.write(s):t().log.ws.warn("terminal:output but no xterm",{terminalId:a});break}case"terminal:attached":{const{terminalId:a,buffer:s}=i,o=e.terminals.get(a);t().log.ws.info("terminal:attached received",{terminalId:a,hasTerminal:!!o,hasXterm:!!o?.xterm,bufferLength:s?.length??0,hasCallback:e.onAttachedCallbacks.has(a),isReadyForCallback:e.terminalsReadyForCallback.has(a),registeredCallbacks:Array.from(e.onAttachedCallbacks.keys())});const l=()=>{const u=e.onAttachedCallbacks.get(a);u?(e.onAttachedCallbacks.delete(a),t().log.ws.debug("terminal:attached calling callback",{terminalId:a}),u(a)):(t().log.ws.debug("terminal:attached no callback yet, marking ready",{terminalId:a}),e.terminalsReadyForCallback.add(a))};o?.xterm?(o.xterm.reset(),s?o.xterm.write(s,l):l()):l();break}case"terminal:bufferCleared":{const{terminalId:a}=i,s=e.terminals.get(a);s?.xterm&&s.xterm.reset();break}case"terminal:exit":{const{terminalId:a,exitCode:s}=i;e.terminals.get(a)?.markExited(s);break}case"terminal:renamed":{const{terminalId:a,name:s}=i;e.terminals.get(a)?.rename(s);break}case"terminal:tabAssigned":{const{terminalId:a,tabId:s,positionInTab:o}=i;e.terminals.get(a)?.assignToTab(s,o);break}case"tabs:list":e.tabs.replaceAll(i.tabs),e.initialized=!0;break;case"tab:created":{const{tab:a,requestId:s,tempId:o,adoptTerminalId:l}=i;if(s&&o){const u=e.pendingUpdates.get(s);if(u&&u.tempId===o){e.pendingUpdates.delete(s),e.tabs.get(o)&&(e.tabs.remove(o),e.tabs.add(a),e.pendingTabCreation=null,l||(e.lastCreatedTabId=a.id),t().log.ws.debug("tab:created confirmed",{requestId:s,tempId:o,realId:a.id,adoptTerminalId:l}));break}}e.tabs.add(a);break}case"tab:updated":{const{tabId:a,name:s,directory:o}=i;e.tabs.get(a)?.updateFromServer({name:s,directory:o});break}case"tab:deleted":{const{tabId:a}=i;e.tabs.remove(a),e.viewState.clearFocusedTerminalForTab(a);break}case"terminal:error":{const{error:a,requestId:s,tempId:o}=i;if(s&&o){const l=e.pendingUpdates.get(s);if(l&&l.tempId===o){e.pendingUpdates.delete(s);for(let u=l.inversePatches.length-1;u>=0;u--)Mv(e.terminals,l.inversePatches[u]);e.newTerminalIds.delete(o),e.terminalsPendingStartup.delete(o),t().log.ws.warn("terminal:error rollback",{requestId:s,tempId:o,error:a});break}}At.ws.error("Terminal error from server",{error:a});break}case"sync:stale":{const{entityType:a,entityId:s,requestId:o,tempId:l,error:u}=i;if(t().log.ws.warn("sync:stale received",{entityType:a,entityId:s,error:u}),o&&l){const f=e.pendingUpdates.get(o);if(f&&f.tempId===l)if(e.pendingUpdates.delete(o),f.entityType==="terminal"){const d=e.terminals.get(l);d&&(d.cleanup(),e.terminals.remove(l)),e.newTerminalIds.delete(l),e.terminalsPendingStartup.delete(l)}else f.entityType==="tab"&&e.tabs.remove(l)}if(a==="terminal"){if(e.terminals.has(s)){const f=e.terminals.get(s);f&&(f.cleanup(),e.terminals.remove(s))}e.terminalsPendingStartup.delete(s)}else a==="tab"&&e.tabs.has(s)&&(e.tabs.remove(s),e.viewState.clearFocusedTerminalForTab(s));break}case"theme:synced":{const{theme:a}=i;e.broadcastedTheme=a,t().log.ws.debug("theme:synced received",{theme:a});break}}},reset(){e.terminals.clear(),e.tabs.clear(),e.connected=!1,e.initialized=!1,e.newTerminalIds.clear(),e.pendingUpdates.clear(),e.terminalsPendingStartup.clear()}}});function yie(){const e=$m();return k.useMemo(()=>{const t=(n,r)=>{const i=async a=>{const s=a.clipboardData?.items;if(s){for(const o of s)if(o.type.startsWith("image/")){a.preventDefault(),a.stopPropagation();const l=o.getAsFile();if(!l)return;try{const u=await Bte(l);e.writeToTerminal(r,u)}catch(u){At.ws.error("Failed to upload image",{error:String(u)})}return}}};return n.addEventListener("paste",i,!0),()=>{n.removeEventListener("paste",i,!0)}};return{get terminals(){return[...e.terminals.items]},get terminalsLoaded(){return e.initialized},get tabs(){return[...e.tabs.sorted]},get connected(){return e.connected},get newTerminalIds(){return e.newTerminalIds},get pendingTabCreation(){return e.pendingTabCreation},get lastCreatedTabId(){return e.lastCreatedTabId},createTerminal:e.createTerminal.bind(e),destroyTerminal:e.destroyTerminal.bind(e),writeToTerminal:e.writeToTerminal.bind(e),sendInputToTerminal:e.sendInputToTerminal.bind(e),resizeTerminal:e.resizeTerminal.bind(e),renameTerminal:e.renameTerminal.bind(e),clearTerminalBuffer:e.clearTerminalBuffer.bind(e),assignTerminalToTab:e.assignTerminalToTab.bind(e),createTab:e.createTab.bind(e),updateTab:e.updateTab.bind(e),deleteTab:e.deleteTab.bind(e),reorderTab:e.reorderTab.bind(e),attachXterm:e.attachXterm.bind(e),setupImagePaste:t,consumePendingStartup:e.consumePendingStartup.bind(e),clearStartingUp:e.clearStartingUp.bind(e),clearLastCreatedTabId:e.clearLastCreatedTabId.bind(e)}},[e])}const Ok="",BRe=Ot.model("File",{path:Ot.identifier,content:Ot.string,originalContent:Ot.string,mimeType:Ot.string,size:Ot.number,lineCount:Ot.number,truncated:Ot.boolean,isMarkdownView:Ot.optional(Ot.boolean,!1)}).views(e=>({get isDirty(){return e.content!==e.originalContent},get isMarkdown(){return e.path.toLowerCase().endsWith(".md")},get isImage(){return e.mimeType.startsWith("image/")},get isBinary(){return e.mimeType==="application/octet-stream"},get isEditable(){return!e.mimeType.startsWith("image/")&&e.mimeType!=="application/octet-stream"}})).actions(e=>({setContent(t){e.content=t},markSaved(){e.originalContent=e.content},toggleMarkdownView(){e.isMarkdownView=!e.isMarkdownView},setMarkdownView(t){e.isMarkdownView=t}})),URe=Ot.model("FilesStore",{selectedFile:Ot.maybeNull(Ot.string),expandedDirs:Ot.array(Ot.string),openFiles:Ot.map(BRe)}).volatile(()=>({worktreePath:null,readOnly:!1,isLoading:!1,isSaving:!1,loadError:null,saveError:null,fileTree:null,isLoadingTree:!1,treeError:null})).views(e=>({get currentFile(){if(e.selectedFile)return e.openFiles.get(e.selectedFile)},get isDirty(){return(e.selectedFile?e.openFiles.get(e.selectedFile):void 0)?.isDirty??!1},isFileMarkdownView(t){return e.openFiles.get(t)?.isMarkdownView??!1},isDirExpanded(t){return e.expandedDirs.includes(t)}})).actions(e=>({setWorktreePath(t){e.worktreePath!==t&&(e.worktreePath=t,e.selectedFile=null,e.expandedDirs.clear(),e.openFiles.clear(),e.fileTree=null)},setReadOnly(t){e.readOnly=t},selectFile(t){e.selectedFile=t},toggleDir(t){const n=e.expandedDirs.indexOf(t);n>=0?e.expandedDirs.splice(n,1):e.expandedDirs.push(t)},collapseAll(){e.expandedDirs.clear()},updateContent(t,n){const r=e.openFiles.get(t);r&&r.setContent(n)},toggleMarkdownView(t){const n=e.openFiles.get(t);n&&n.toggleMarkdownView()},_setLoading(t){e.isLoading=t},_setLoadError(t){e.loadError=t},_setSaving(t){e.isSaving=t},_setSaveError(t){e.saveError=t},_setFileTree(t){e.fileTree=t},_setLoadingTree(t){e.isLoadingTree=t},_setTreeError(t){e.treeError=t},_addFile(t){e.openFiles.set(t.path,{path:t.path,content:t.content,originalContent:t.content,mimeType:t.mimeType,size:t.size,lineCount:t.lineCount,truncated:t.truncated,isMarkdownView:!1})},_markFileSaved(t){const n=e.openFiles.get(t);n&&n.markSaved()}})).actions(e=>({loadFileTree:Ck(function*(){if(e.worktreePath){e._setLoadingTree(!0),e._setTreeError(null);try{const t=yield zt(`${Ok}/api/fs/tree?root=${encodeURIComponent(e.worktreePath)}`);e._setFileTree(t.entries)}catch(t){e._setTreeError(t instanceof Error?t.message:"Failed to load file tree")}finally{e._setLoadingTree(!1)}}}),loadFile:Ck(function*(t){if(e.worktreePath){if(e.openFiles.has(t)){e.selectedFile=t;return}e._setLoading(!0),e._setLoadError(null);try{const n=new URLSearchParams({path:t,root:e.worktreePath}),r=yield zt(`${Ok}/api/fs/read?${n}`);e._addFile({path:t,content:r.content,mimeType:r.mimeType,size:r.size,lineCount:r.lineCount,truncated:r.truncated}),e.selectedFile=t}catch(n){e._setLoadError(n instanceof Error?n.message:"Failed to load file")}finally{e._setLoading(!1)}}}),saveFile:Ck(function*(t){if(!e.worktreePath)return;const n=e.openFiles.get(t);if(!(!n||!n.isDirty)){e._setSaving(!0),e._setSaveError(null);try{(yield fetch(`${Ok}/api/fs/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t,root:e.worktreePath,content:n.content})}).then(i=>i.ok?i.json():i.json().then(a=>{throw new Error(a.error||"Failed to save file")}))).success&&e._markFileSaved(t)}catch(r){throw e._setSaveError(r instanceof Error?r.message:"Failed to save file"),r}finally{e._setSaving(!1)}}}),closeFile(t){e.openFiles.delete(t),e.selectedFile===t&&(e.selectedFile=null)}}));function $Re(){return URe.create({selectedFile:null,expandedDirs:[],openFiles:{}})}const _ie=k.createContext(null);function zRe(e,t=!1,n){const r=k.useMemo(()=>$Re(),[]),i=k.useRef(!1);return k.useEffect(()=>{r.setWorktreePath(e),r.setReadOnly(t),i.current=!1,e&&r.loadFileTree().then(()=>{n&&!i.current&&(i.current=!0,r.selectFile(n),r.loadFile(n))})},[r,e,t,n]),r}function HRe(){const e=k.useContext(_ie);if(!e)throw new Error("useFilesStore must be used within a FilesStoreProvider");return e}function Eie(){const e=HRe();return{worktreePath:e.worktreePath,readOnly:e.readOnly,selectedFile:e.selectedFile,currentFile:e.currentFile,expandedDirs:[...e.expandedDirs],fileTree:e.fileTree,isLoading:e.isLoading,isSaving:e.isSaving,isLoadingTree:e.isLoadingTree,loadError:e.loadError,saveError:e.saveError,treeError:e.treeError,isDirty:e.isDirty,selectFile:e.selectFile,loadFile:e.loadFile,saveFile:e.saveFile,closeFile:e.closeFile,updateContent:e.updateContent,toggleDir:e.toggleDir,collapseAll:e.collapseAll,toggleMarkdownView:e.toggleMarkdownView,isFileMarkdownView:e.isFileMarkdownView,isDirExpanded:e.isDirExpanded,refreshTree:e.loadFileTree}}const Sie=k.createContext(null);function $m(){const e=k.useContext(Sie);if(!e)throw new Error("useStore must be used within a StoreProvider");return e}function WRe(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/terminal`}function VRe({children:e,wsUrl:t=WRe(),reconnectInterval:n=2e3,maxReconnectAttempts:r=10}){const i=k.useRef(null),a=k.useRef(0),s=k.useRef(void 0),o=k.useRef(null),[,l]=k.useState({}),u=k.useCallback(d=>{i.current?.readyState===WebSocket.OPEN?(At.ws.debug("send",{type:d.type}),i.current.send(JSON.stringify(d))):At.ws.warn("send dropped (WebSocket not open)",{type:d.type,readyState:i.current?.readyState??"no socket"})},[]);if(!o.current){const d={send:u,log:At};o.current=FRe.create({},d)}const f=o.current;return k.useEffect(()=>{f.setMaxReconnectAttempts(r)},[f,r]),k.useEffect(()=>{let d=!0;const p=()=>{const m=i.current;if(m&&(m.readyState===WebSocket.CONNECTING||m.readyState===WebSocket.OPEN))return;const E=new WebSocket(t);i.current=E,E.onopen=()=>{d&&(At.ws.info("WebSocket connected"),f.setConnected(!0),a.current=0)},E.onmessage=S=>{if(d)try{const g=JSON.parse(S.data);f.handleMessage(g)}catch(g){At.ws.error("Failed to parse WebSocket message",{error:String(g)})}},E.onclose=()=>{if(d)if(At.ws.info("WebSocket disconnected"),f.setConnected(!1),i.current===E&&(i.current=null),a.current<r){a.current++,f.setReconnectAttempt(a.current);const S=n*Math.pow(1.5,a.current-1);At.ws.info("Scheduling reconnect",{attempt:a.current,delay:S}),s.current=setTimeout(p,S)}else At.ws.warn("Max reconnect attempts reached"),f.setReconnectAttempt(a.current)},E.onerror=S=>{At.ws.error("WebSocket error",{event:String(S)})}};return p(),()=>{d=!1,s.current&&clearTimeout(s.current);const m=i.current;m?.readyState===WebSocket.OPEN&&m.close(),i.current=null}},[t,n,r,f]),k.useEffect(()=>{l({})},[]),b.jsx(Sie.Provider,{value:f,children:e})}function xie(){const e=$m(),{setTheme:t,resolvedTheme:n,theme:r}=Qc(),{data:i}=rwe(),a=k.useRef(void 0),s=k.useRef(!1),o=k.useRef(!1);k.useEffect(()=>VM(()=>e.broadcastedTheme,f=>{f&&(o.current=!0,t(f),e.clearBroadcastedTheme(),setTimeout(()=>{o.current=!1},0))},{fireImmediately:!0}),[e,t]),k.useEffect(()=>{let u=document.querySelector('link[rel="icon"]');u||(u=document.createElement("link"),u.rel="icon",document.head.appendChild(u)),u.type="image/jpeg",u.href="/logo.jpg"},[]),k.useEffect(()=>{const u=s.current&&i&&a.current===!1;a.current=i,s.current=!0,n&&u&&zt("/api/config/sync-claude-theme",{method:"POST",body:JSON.stringify({resolvedTheme:n})}).catch(()=>{})},[i,n]);const l=k.useCallback(u=>{if(!o.current&&(t(u),e.syncTheme(u),i)){const f=u==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":u;zt("/api/config/sync-claude-theme",{method:"POST",body:JSON.stringify({resolvedTheme:f})}).catch(()=>{})}},[t,e,i]);return{theme:r??"system",resolvedTheme:n,syncClaudeCode:i,changeTheme:l,isUpdating:!1}}let Rk=!1;const nH={activeTabId:null,focusedTerminals:{},currentView:null,currentTaskId:null,isTabVisible:null,viewUpdatedAt:null};function wie(){const e=wr(),t=k.useRef(void 0),n=k.useRef({}),{data:r=nH,isLoading:i}=qn({queryKey:["terminal-view-state"],queryFn:async()=>{const p=await fetch("/api/terminal-view-state");if(!p.ok)throw new Error("Failed to fetch terminal view state");return p.json()},staleTime:2e3}),a=Fn({mutationFn:async p=>{const m=await fetch("/api/terminal-view-state",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)});if(!m.ok)throw new Error("Failed to update terminal view state");return m.json()},onSuccess:p=>{e.setQueryData(["terminal-view-state"],p)}}),s=k.useRef(a);s.current=a;const o=k.useCallback(p=>{const m=n.current;n.current={...m,...p,focusedTerminals:p.focusedTerminals||m.focusedTerminals?{...m.focusedTerminals,...p.focusedTerminals}:void 0};const E=n.current;e.setQueryData(["terminal-view-state"],S=>{const g=S??nH;return{activeTabId:E.activeTabId!==void 0?E.activeTabId:g.activeTabId,focusedTerminals:{...g.focusedTerminals,...E.focusedTerminals},currentView:E.currentView!==void 0?E.currentView:g.currentView,currentTaskId:E.currentTaskId!==void 0?E.currentTaskId:g.currentTaskId,isTabVisible:E.isTabVisible!==void 0?E.isTabVisible:g.isTabVisible,viewUpdatedAt:E.viewUpdatedAt!==void 0?E.viewUpdatedAt:g.viewUpdatedAt}}),t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{s.current.mutate(n.current),n.current={}},500)},[e]),l=k.useCallback((p,m)=>{if(m===null){const E=e.getQueryData(["terminal-view-state"]);if(E){const{[p]:S,...g}=E.focusedTerminals;o({focusedTerminals:g})}}else o({focusedTerminals:{[p]:m}})},[e,o]),u=k.useCallback(p=>r.focusedTerminals[p]??null,[r.focusedTerminals]),f=k.useRef(!1);k.useEffect(()=>{if(Rk){f.current=!1;return}Rk=!0,f.current=!0;const p=()=>{o({isTabVisible:document.visibilityState==="visible",viewUpdatedAt:new Date().toISOString()})};return document.addEventListener("visibilitychange",p),p(),()=>{document.removeEventListener("visibilitychange",p),f.current&&(Rk=!1)}},[o]);const d=k.useCallback((p,m,E)=>{o({currentView:p,currentTaskId:m,activeTabId:E,viewUpdatedAt:new Date().toISOString()})},[o]);return{viewState:r,isLoading:i,getFocusedTerminal:u,setFocusedTerminal:l,updateViewTracking:d}}function no(e,t){const n=e.toLowerCase(),r=t.toLowerCase();if(n===r)return 100;if(n.startsWith(r))return 80;if(n.includes(r))return 60;let i=0,a=0,s=0;for(;i<n.length&&a<r.length;)n[i]===r[a]&&(s+=1,a++),i++;return a===r.length?s:0}function GRe(e,t){return t.trim()?e.map(r=>{let i=no(r.label,t);if(r.keywords)for(const a of r.keywords){const s=no(a,t);s>i&&(i=s)}return{command:r,score:i}}).filter(({score:r})=>r>0).sort((r,i)=>i.score-r.score).map(({command:r})=>r):e}function qRe(e){const t=new Map;for(const n of e){const r=t.get(n.category)||[];r.push(n),t.set(n.category,r)}return t}function KRe({open:e,onOpenChange:t,onNewTask:n,onShowShortcuts:r,onOpenInEditor:i}){const{t:a}=nn("navigation"),[s,o]=k.useState(!1),l=e??s,u=t??o,[f,d]=k.useState(""),[p,m]=k.useState(0),E=k.useRef(null),S=k.useRef(null),g=Ni(),y=k.useMemo(()=>[{id:"goto-tasks",label:a("commandPalette.commands.goToTasks"),shortcut:"meta+1",keywords:["kanban","board","home"],category:"navigation",icon:b.jsx(fe,{icon:Fp,size:16,strokeWidth:2}),action:()=>{g({to:"/tasks"}),u(!1)}},{id:"goto-terminals",label:a("commandPalette.commands.goToTerminals"),shortcut:"meta+2",keywords:["shell","console","cli"],category:"navigation",icon:b.jsx(fe,{icon:N1e,size:16,strokeWidth:2}),action:()=>{g({to:"/terminals"}),u(!1)}},{id:"goto-task-terminals",label:a("commandPalette.commands.goToTaskTerminals"),shortcut:"meta+i",keywords:["tasks","shell","console","cli"],category:"navigation",icon:b.jsx(fe,{icon:Fp,size:16,strokeWidth:2}),action:()=>{g({to:"/terminals",search:{tab:"all-tasks"}}),u(!1)}},{id:"goto-repositories",label:a("commandPalette.commands.goToRepositories"),shortcut:"meta+3",keywords:["repos","git","projects"],category:"navigation",icon:b.jsx(fe,{icon:D1e,size:16,strokeWidth:2}),action:()=>{g({to:"/repositories"}),u(!1)}},{id:"goto-review",label:a("commandPalette.commands.goToReview"),shortcut:"meta+4",keywords:["pr","pull request","issues","github"],category:"navigation",icon:b.jsx(fe,{icon:lu,size:16,strokeWidth:2}),action:()=>{g({to:"/review"}),u(!1)}},{id:"goto-monitoring",label:a("commandPalette.commands.goToMonitoring"),shortcut:"meta+5",keywords:["system","cpu","memory","processes","usage"],category:"navigation",icon:b.jsx(fe,{icon:pte,size:16,strokeWidth:2}),action:()=>{g({to:"/monitoring"}),u(!1)}},{id:"goto-settings",label:a("commandPalette.commands.goToSettings"),shortcut:"meta+,",keywords:["preferences","config","configuration"],category:"navigation",icon:b.jsx(fe,{icon:wte,size:16,strokeWidth:2}),action:()=>{g({to:"/settings"}),u(!1)}},{id:"new-task",label:a("commandPalette.commands.newTask"),shortcut:"meta+j",keywords:["create","add"],category:"actions",icon:b.jsx(fe,{icon:Iv,size:16,strokeWidth:2}),action:()=>{u(!1),n?.()}},{id:"open-in-editor",label:a("commandPalette.commands.openInEditor"),shortcut:"meta+e",keywords:["editor","code","vscode","cursor","folder","path"],category:"actions",icon:b.jsx(fe,{icon:rD,size:16,strokeWidth:2}),action:()=>{u(!1),i?.()}},{id:"show-shortcuts",label:a("commandPalette.commands.keyboardShortcuts"),shortcut:"meta+/",keywords:["help","hotkeys","keys"],category:"actions",icon:b.jsx(fe,{icon:yte,size:16,strokeWidth:2}),action:()=>{u(!1),r?.()}}],[g,n,r,i,u,a]),v=k.useMemo(()=>GRe(y,f),[y,f]),x=k.useMemo(()=>qRe(v),[v]),T=k.useMemo(()=>{const R=[],O=["navigation","actions"];for(const N of O){const D=x.get(N);D&&R.push(...D)}return R},[x]);k.useEffect(()=>{m(0)},[f]),k.useEffect(()=>{if(!S.current)return;const R=S.current.querySelector('[data-selected="true"]');R&&R.scrollIntoView({block:"nearest"})},[p]),ba("meta+k",()=>u(!0),{allowInInput:!0,allowInTerminal:!0}),ba("meta+1",()=>g({to:"/tasks"}),{allowInInput:!0,allowInTerminal:!0}),ba("meta+2",()=>g({to:"/terminals"}),{allowInInput:!0,allowInTerminal:!0}),ba("meta+i",()=>{g({to:"/terminals",search:{tab:"all-tasks"}})},{allowInInput:!0,allowInTerminal:!0}),ba("meta+3",()=>g({to:"/repositories"}),{allowInInput:!0,allowInTerminal:!0}),ba("meta+4",()=>g({to:"/review"}),{allowInInput:!0,allowInTerminal:!0}),ba("meta+5",()=>g({to:"/monitoring"}),{allowInInput:!0,allowInTerminal:!0}),ba("meta+,",()=>g({to:"/settings"}),{allowInInput:!0,allowInTerminal:!0}),ba("meta+j",()=>{n?.()},{allowInInput:!1,deps:[n]}),ba("meta+/",()=>{r?.()},{allowInInput:!0,allowInTerminal:!0,deps:[r]}),ba("meta+e",()=>{i?.()},{allowInInput:!1,deps:[i]});const w=k.useCallback(R=>{switch(R.key){case"ArrowDown":R.preventDefault(),m(O=>Math.min(O+1,T.length-1));break;case"ArrowUp":R.preventDefault(),m(O=>Math.max(O-1,0));break;case"Enter":R.preventDefault(),T[p]&&T[p].action();break;case"Escape":R.preventDefault(),u(!1);break;case"1":R.preventDefault(),g({to:"/tasks"}),u(!1);break;case"2":R.preventDefault(),g({to:"/terminals"}),u(!1);break;case"3":R.preventDefault(),g({to:"/repositories"}),u(!1);break;case"4":R.preventDefault(),g({to:"/review"}),u(!1);break;case"5":R.preventDefault(),g({to:"/monitoring"}),u(!1);break}},[T,p,u,g]);k.useEffect(()=>{l&&(d(""),m(0),setTimeout(()=>E.current?.focus(),50))},[l]),k.useEffect(()=>{const R=O=>{if(O.data?.type==="vibora:action")switch(O.data.action){case"openCommandPalette":u(!0);break;case"openNewTask":n?.();break;case"showShortcuts":r?.();break}};return window.addEventListener("message",R),()=>window.removeEventListener("message",R)},[u,n,r]);let C=0;return b.jsx(Iu,{open:l,onOpenChange:u,children:b.jsxs(Du,{className:"sm:max-w-lg p-0 gap-0 overflow-hidden",showCloseButton:!1,onKeyDown:w,children:[b.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[b.jsx("span",{className:"text-muted-foreground mr-2",children:">"}),b.jsx(ln,{ref:E,value:f,onChange:R=>d(R.target.value),placeholder:a("commandPalette.placeholder"),className:"border-0 ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 px-0 h-12"}),b.jsx("kbd",{className:"pointer-events-none ml-2 inline-flex h-5 select-none items-center gap-1 rounded border border-border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",children:"Esc"})]}),b.jsx("div",{ref:S,className:"max-h-80 overflow-y-auto p-2",children:v.length===0?b.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:a("commandPalette.noResults")}):b.jsx(b.Fragment,{children:["navigation","actions"].map(R=>{const O=x.get(R);return!O||O.length===0?null:b.jsxs("div",{className:"mb-2 last:mb-0",children:[b.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:a(`commandPalette.categories.${R}`)}),O.map(N=>{const D=C++,L=D===p;return b.jsxs("button",{"data-selected":L,onClick:()=>N.action(),onMouseEnter:()=>m(D),className:Be("flex w-full items-center gap-3 rounded-md px-2 py-2 text-sm",L?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"),children:[N.icon&&b.jsx("span",{className:"text-muted-foreground",children:N.icon}),b.jsx("span",{className:"flex-1 text-left",children:N.label}),N.shortcut&&b.jsx("kbd",{className:"pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border border-border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",children:Ate(N.shortcut)})]},N.id)})]},R)})})})]})})}const rH={sm:"w-8 h-8",md:"w-9 h-9 md:w-12 md:h-12",lg:"w-12 h-12 md:w-16 md:h-16"};function YRe({className:e,rows:t=100,cols:n=10,tileClassName:r,tileSize:i="md"}){return b.jsx("div",{className:Be("relative z-0 flex w-full h-full justify-center",e),children:Array.from({length:t}).map((a,s)=>b.jsx("div",{className:Be(rH[i],"border-l dark:border-neutral-900 border-neutral-200 relative",r),children:Array.from({length:n}).map((o,l)=>b.jsx("div",{className:Be(rH[i],"border-r border-t dark:border-neutral-900 border-neutral-200 relative hover:bg-tile transition-colors",r)},`col-${l}`))},`row-${s}`))})}const XRe=["/","/tasks","/terminals","/worktrees","/repositories","/review","/monitoring","/settings"];function ZRe(){const e=ri({select:n=>n.location.pathname});return XRe.some(n=>e===n||e.startsWith(n+"/"))?b.jsx("div",{className:"absolute inset-0 overflow-hidden pointer-events-none -z-10",children:b.jsx(YRe,{rows:100,cols:50,tileSize:"sm"})}):null}if(!k.useState)throw new Error("mobx-react-lite requires React with Hooks support");if(!Lre)throw new Error("mobx-react-lite@3 requires mobx at least version 6 to be available");function QRe(e){e()}function JRe(e){e||(e=QRe),xke({reactionScheduler:e})}function e2e(e){return Tke(e)}var t2e=1e4,n2e=1e4,r2e=(function(){function e(t){var n=this;Object.defineProperty(this,"finalize",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"registrations",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"sweepTimeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sweep",{enumerable:!0,configurable:!0,writable:!0,value:function(r){r===void 0&&(r=t2e),clearTimeout(n.sweepTimeout),n.sweepTimeout=void 0;var i=Date.now();n.registrations.forEach(function(a,s){i-a.registeredAt>=r&&(n.finalize(a.value),n.registrations.delete(s))}),n.registrations.size>0&&n.scheduleSweep()}}),Object.defineProperty(this,"finalizeAllImmediately",{enumerable:!0,configurable:!0,writable:!0,value:function(){n.sweep(0)}})}return Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,r){this.registrations.set(r,{value:n,registeredAt:Date.now()}),this.scheduleSweep()}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.registrations.delete(t)}}),Object.defineProperty(e.prototype,"scheduleSweep",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.sweepTimeout===void 0&&(this.sweepTimeout=setTimeout(this.sweep,n2e))}}),e})(),i2e=typeof FinalizationRegistry<"u"?FinalizationRegistry:r2e,xD=new i2e(function(e){var t;(t=e.reaction)===null||t===void 0||t.dispose(),e.reaction=null});function iH(e){e.reaction=new cl("observer".concat(e.name),function(){var t;e.stateVersion=Symbol(),(t=e.onStoreChange)===null||t===void 0||t.call(e)})}function a2e(e,t){t===void 0&&(t="observed");var n=oe.useRef(null);if(!n.current){var r={reaction:null,onStoreChange:null,stateVersion:Symbol(),name:t,subscribe:function(o){return xD.unregister(r),r.onStoreChange=o,r.reaction||(iH(r),r.stateVersion=Symbol()),function(){var l;r.onStoreChange=null,(l=r.reaction)===null||l===void 0||l.dispose(),r.reaction=null}},getSnapshot:function(){return r.stateVersion}};n.current=r}var i=n.current;i.reaction||(iH(i),xD.register(n,i,i)),oe.useDebugValue(i.reaction,e2e),FP.useSyncExternalStore(i.subscribe,i.getSnapshot,i.getSnapshot);var a,s;if(i.reaction.track(function(){try{a=e()}catch(o){s=o}}),s)throw s;return a}var Nk,Ik,Tie=typeof Symbol=="function"&&Symbol.for,s2e=(Ik=(Nk=Object.getOwnPropertyDescriptor(function(){},"name"))===null||Nk===void 0?void 0:Nk.configurable)!==null&&Ik!==void 0?Ik:!1,aH=Tie?Symbol.for("react.forward_ref"):typeof k.forwardRef=="function"&&k.forwardRef(function(e){return null}).$$typeof,sH=Tie?Symbol.for("react.memo"):typeof k.memo=="function"&&k.memo(function(e){return null}).$$typeof;function h0(e,t){var n;if(sH&&e.$$typeof===sH)throw new Error("[mobx-react-lite] You are trying to use `observer` on a function component wrapped in either another `observer` or `React.memo`. The observer already applies 'React.memo' for you.");var r=(n=void 0)!==null&&n!==void 0?n:!1,i=e,a=e.displayName||e.name;if(aH&&e.$$typeof===aH&&(r=!0,i=e.render,typeof i!="function"))throw new Error("[mobx-react-lite] `render` property of ForwardRef was not a function");var s=function(o,l){return a2e(function(){return i(o,l)},a)};return s.displayName=e.displayName,s2e&&Object.defineProperty(s,"name",{value:e.name,writable:!0,configurable:!0}),e.contextTypes&&(s.contextTypes=e.contextTypes),r&&(s=k.forwardRef(s)),s=k.memo(s),l2e(e,s),s}var o2e={$$typeof:!0,render:!0,compare:!0,type:!0,displayName:!0};function l2e(e,t){Object.keys(e).forEach(function(n){o2e[n]||Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})}var Dk;JRe(xr.unstable_batchedUpdates);Dk=xD.finalizeAllImmediately;const u2e=h0(function(){const t=$m();if(t.connected||!t.hasEverConnected)return null;const n=t.reconnectAttempt>0&&t.reconnectAttempt<t.maxReconnectAttempts,r=t.reconnectAttempt>=t.maxReconnectAttempts;return b.jsx("div",{className:Be("flex items-center justify-center gap-2 px-4 py-2 text-sm font-medium","border-b",r?"bg-destructive/10 border-destructive/30 text-destructive":"bg-amber-500/10 border-amber-500/30 text-amber-600 dark:text-amber-400"),role:"alert","aria-live":"polite",children:r?b.jsxs(b.Fragment,{children:[b.jsx(fe,{icon:rs,size:16,strokeWidth:2}),b.jsx("span",{children:"Connection lost. Please check if the server is running."})]}):n?b.jsxs(b.Fragment,{children:[b.jsx(fe,{icon:tn,size:16,strokeWidth:2,className:"animate-spin"}),b.jsxs("span",{children:["Reconnecting... (attempt ",t.reconnectAttempt,"/",t.maxReconnectAttempts,")"]})]}):b.jsxs(b.Fragment,{children:[b.jsx(fe,{icon:rs,size:16,strokeWidth:2}),b.jsx("span",{children:"Disconnected from server"})]})})});function c2e(){return qn({queryKey:["system","dependencies"],queryFn:()=>zt("/api/system/dependencies"),staleTime:30*1e3,refetchOnWindowFocus:!0})}const oH="npm install -g @anthropic/claude-code",d2e="https://docs.anthropic.com/en/docs/claude-code/overview";function f2e(){const{data:e,isLoading:t}=c2e(),[n,r]=k.useState(!1),[i,a]=k.useState(!1),s=k.useCallback(async()=>{try{await navigator.clipboard.writeText(oH),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[]),o=k.useCallback(()=>{r(!0)},[]);return t||n||e?.claudeCode?.installed?null:b.jsxs("div",{className:Be("flex items-center justify-between gap-4 px-4 py-3","border-b bg-amber-500/10 border-amber-500/30"),role:"alert",children:[b.jsxs("div",{className:"flex items-center gap-3",children:[b.jsx(fe,{icon:rs,size:18,strokeWidth:2,className:"shrink-0 text-amber-600 dark:text-amber-400"}),b.jsxs("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-4",children:[b.jsx("span",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:"Claude Code CLI not found"}),b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx("code",{className:"rounded bg-amber-500/20 px-2 py-0.5 text-xs font-mono text-amber-700 dark:text-amber-300",children:oH}),b.jsx("button",{onClick:s,className:Be("p-1 rounded transition-colors","text-amber-600 hover:text-amber-700 hover:bg-amber-500/20","dark:text-amber-400 dark:hover:text-amber-300"),title:i?"Copied!":"Copy to clipboard",children:b.jsx(fe,{icon:i?ml:I1e,size:14,strokeWidth:2})})]})]})]}),b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx("a",{href:d2e,target:"_blank",rel:"noopener noreferrer",className:Be("text-xs font-medium px-2 py-1 rounded transition-colors","text-amber-600 hover:text-amber-700 hover:bg-amber-500/20","dark:text-amber-400 dark:hover:text-amber-300"),children:"View Docs"}),b.jsx("button",{onClick:o,className:Be("p-1 rounded transition-colors","text-amber-600 hover:text-amber-700 hover:bg-amber-500/20","dark:text-amber-400 dark:hover:text-amber-300"),title:"Dismiss",children:b.jsx(fe,{icon:fi,size:16,strokeWidth:2})})]})]})}const h2e=[{titleKey:"navigation",items:[{labelKey:"goToTasks",shortcut:"meta+1"},{labelKey:"goToTerminals",shortcut:"meta+2"},{labelKey:"goToTaskTerminals",shortcut:"meta+i"},{labelKey:"goToRepositories",shortcut:"meta+3"},{labelKey:"goToReview",shortcut:"meta+4"},{labelKey:"goToMonitoring",shortcut:"meta+5"},{labelKey:"goToSettings",shortcut:"meta+,"}]},{titleKey:"actions",items:[{labelKey:"commandPalette",shortcut:"meta+k"},{labelKey:"newTask",shortcut:"meta+j"},{labelKey:"openInEditor",shortcut:"meta+e"},{labelKey:"keyboardShortcuts",shortcut:"meta+/"}]},{titleKey:"terminals",items:[{labelKey:"newTerminal",shortcut:"meta+d"},{labelKey:"closeTerminal",shortcut:"meta+w"}]},{titleKey:"general",items:[{labelKey:"closeModal",shortcut:"escape"},{labelKey:"submitForm",shortcut:"meta+enter"}]}];function p2e({open:e,onOpenChange:t}){const{t:n}=nn("navigation");return b.jsx(Iu,{open:e,onOpenChange:t,children:b.jsxs(Du,{className:"sm:max-w-md",children:[b.jsx(id,{children:b.jsx(ad,{children:n("shortcuts.title")})}),b.jsx(Mm,{className:"max-h-[60vh]",children:b.jsx("div",{className:"space-y-4 mt-2 pr-4",children:h2e.map(r=>b.jsxs("div",{children:[b.jsx("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:n(`shortcuts.groups.${r.titleKey}`)}),b.jsx("div",{className:"space-y-1",children:r.items.map(i=>b.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[b.jsx("span",{className:"text-sm",children:n(`shortcuts.labels.${i.labelKey}`)}),b.jsx("kbd",{className:"pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border border-border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",children:Ate(i.shortcut)})]},i.shortcut))})]},r.titleKey))})})]})})}const m2e={vscode:"vscode",cursor:"cursor",windsurf:"windsurf",zed:"zed",antigravity:"antigravity"};function Ew(e,t,n,r){const i=m2e[t];if(!n)return`${i}://file${e}`;const a=r!==22?`${n}:${r}`:n;return`${i}://vscode-remote/ssh-remote+${a}${e}`}function t3(e){return{vscode:"VS Code",cursor:"Cursor",windsurf:"Windsurf",zed:"Zed",antigravity:"Antigravity"}[e]}function nl(e){window.parent!==window?window.parent.postMessage({type:"vibora:openUrl",url:e},"*"):window.open(e,"_blank")}function g2e({open:e,onOpenChange:t}){const{t:n}=nn("navigation"),[r,i]=k.useState(""),[a,s]=k.useState(!1),{data:o}=r0(),{data:l}=i0(),{data:u}=a0();k.useEffect(()=>{e&&i("")},[e]);const f=()=>{if(!r.trim())return;const m=Ew(r.trim(),o??"vscode",l??"",u??22);nl(m),t(!1)},d=m=>{i(m)},p=t3(o??"vscode");return b.jsxs(b.Fragment,{children:[b.jsx(Iu,{open:e,onOpenChange:t,children:b.jsxs(Du,{className:"sm:max-w-md",children:[b.jsxs(id,{children:[b.jsx(ad,{children:n("openInEditor.title")}),b.jsx(Qy,{children:n("openInEditor.description",{editor:p})})]}),b.jsx("div",{className:"space-y-4",children:b.jsxs("div",{className:"space-y-2",children:[b.jsx("label",{className:"text-sm font-medium",children:n("openInEditor.pathLabel")}),b.jsxs("div",{className:"flex gap-2",children:[b.jsx(ln,{value:r,onChange:m=>i(m.target.value),placeholder:n("openInEditor.pathPlaceholder"),onKeyDown:m=>m.key==="Enter"&&f(),className:"flex-1 font-mono text-sm"}),b.jsx(We,{variant:"outline",size:"icon",onClick:()=>s(!0),title:n("openInEditor.browse"),children:b.jsx(fe,{icon:Ri,size:16,strokeWidth:2})})]}),b.jsx("p",{className:"text-xs text-muted-foreground",children:n("openInEditor.pathHint")})]})}),b.jsxs(Gc,{children:[b.jsx(Mf,{render:b.jsx(We,{variant:"outline"}),children:n("openInEditor.cancel")}),b.jsx(We,{onClick:f,disabled:!r.trim(),children:n("openInEditor.open")})]})]})}),b.jsx($c,{open:a,onOpenChange:s,onSelect:d})]})}const b2e=({...e})=>{const{resolvedTheme:t}=Qc();return b.jsx(O_e,{theme:t,className:"toaster group",icons:{success:b.jsx(fe,{icon:mte,strokeWidth:2,className:"size-4"}),info:b.jsx(fe,{icon:U1e,strokeWidth:2,className:"size-4"}),warning:b.jsx(fe,{icon:rs,strokeWidth:2,className:"size-4"}),error:b.jsx(fe,{icon:W1e,strokeWidth:2,className:"size-4"}),loading:b.jsx(fe,{icon:tn,strokeWidth:2,className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},toastOptions:{classNames:{toast:"cn-toast"}},...e})},ko=rme({component:x2e});function v2e(){return Twe(),null}function y2e(){return Wne(),null}function _2e(){return xie(),null}function E2e(){const e=ri({select:n=>n.location}),{updateViewTracking:t}=wie();return k.useEffect(()=>{const n=e.pathname;let r="other",i=null,a=null;n.startsWith("/tasks/")?(r="task-detail",i=n.split("/")[2]||null):n==="/terminals"&&(r="terminals",a=new URLSearchParams(e.search).get("tab")),t(r,i,a)},[e.pathname,e.search,t]),null}function S2e(){const e=ri({select:t=>t.location});return k.useEffect(()=>{window.parent!==window&&window.parent.postMessage({type:"vibora:route",pathname:e.pathname,search:e.search},"*")},[e.pathname,e.search]),null}function x2e(){const[e,t]=k.useState(null),[n,r]=k.useState(!1),[i,a]=k.useState(!1),[s,o]=k.useState(!1),l=typeof window<"u"&&window.parent!==window,u=k.useCallback(E=>{t(()=>E)},[]),f=k.useCallback(()=>{e?.()},[e]),d=k.useCallback(()=>{r(!0)},[]),p=k.useCallback(()=>{a(!0)},[]),m=k.useCallback(()=>{o(!0)},[]);return b.jsx(D_e,{children:b.jsxs("div",{className:"flex h-screen flex-col overflow-x-hidden bg-background text-foreground",children:[b.jsx(v2e,{}),b.jsx(y2e,{}),b.jsx(_2e,{}),b.jsx(E2e,{}),b.jsx(S2e,{}),b.jsx(u2e,{}),b.jsx(f2e,{}),b.jsx(Ewe,{onNewTaskRef:u,onOpenCommandPalette:p}),b.jsxs("main",{className:"isolate flex-1 overflow-hidden relative",children:[b.jsx(ZRe,{}),b.jsx(hJ,{})]}),b.jsx(KRe,{open:i,onOpenChange:a,onNewTask:f,onShowShortcuts:d,onOpenInEditor:m}),b.jsx(p2e,{open:n,onOpenChange:r}),b.jsx(g2e,{open:s,onOpenChange:o}),b.jsx(b2e,{position:l?"bottom-center":"bottom-right"})]})})}const w2e=js("/")({beforeLoad:()=>{throw ZQ({to:"/tasks"})}}),wD="";function Cie(){const[e,t]=k.useState(new Map),[n,r]=k.useState(null),[i,a]=k.useState(!0),[s,o]=k.useState(!1),[l,u]=k.useState(null),f=k.useRef(null),d=k.useRef(0),p=k.useRef(!1),m=k.useCallback(async()=>{a(!0),u(null);try{const g=await fetch(`${wD}/api/worktrees/json`);if(!g.ok)throw new Error("Failed to fetch worktrees");const y=await g.json();t(new Map(y.worktrees.map(v=>[v.path,{...v,size:v.size||0,sizeFormatted:v.sizeFormatted||"0 B",branch:v.branch||"unknown"}]))),r(y.summary),a(!1),o(!1)}catch(g){u(g instanceof Error?g:new Error("Failed to load worktrees")),a(!1),o(!1)}},[]),E=k.useCallback(()=>{if(p.current){m();return}f.current?.close(),a(!0),o(!1),u(null),t(new Map),r(null);const g=new EventSource(`${wD}/api/worktrees`);f.current=g,g.addEventListener("worktree:basic",y=>{const v=JSON.parse(y.data);d.current=v.length,t(new Map(v.map(x=>[x.path,{...x,size:0,sizeFormatted:"...",branch:"..."}]))),a(!1),o(v.length>0)}),g.addEventListener("worktree:details",y=>{const v=JSON.parse(y.data);t(x=>{const T=new Map(x),w=T.get(v.path);return w&&T.set(v.path,{...w,size:v.size,sizeFormatted:v.sizeFormatted,branch:v.branch}),T}),d.current--,d.current<=0&&o(!1)}),g.addEventListener("worktree:complete",y=>{const v=JSON.parse(y.data);r(v),o(!1),g.close()}),g.addEventListener("worktree:error",y=>{const{path:v}=JSON.parse(y.data);At.viewer.error("Error loading worktree details",{path:v}),d.current--,d.current<=0&&o(!1)}),g.onerror=()=>{g.close(),At.viewer.info("SSE connection failed, trying JSON fallback"),p.current=!0,m()}},[m]);return k.useEffect(()=>(E(),()=>{f.current?.close()}),[E]),{worktrees:k.useMemo(()=>Array.from(e.values()).sort((y,v)=>y.isOrphaned!==v.isOrphaned?y.isOrphaned?-1:1:new Date(v.lastModified).getTime()-new Date(y.lastModified).getTime()),[e]),summary:n,isLoading:i,isLoadingDetails:s,error:l,refetch:E}}function Aie(){const e=wr();return Fn({mutationFn:({worktreePath:t,repoPath:n,deleteLinkedTask:r})=>zt(`${wD}/api/worktrees`,{method:"DELETE",body:JSON.stringify({worktreePath:t,repoPath:n,deleteLinkedTask:r})}),onSuccess:()=>{e.invalidateQueries({queryKey:["worktrees"]}),e.invalidateQueries({queryKey:["tasks"]})}})}const T2e=ed("h-5 gap-1 rounded-full border border-transparent px-2 py-0.5 text-[0.625rem] font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-2.5! inline-flex items-center justify-center w-fit whitespace-nowrap shrink-0 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-colors overflow-hidden group/badge",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 [a]:hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 text-destructive dark:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground bg-input/20 dark:bg-input/30",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function co({className:e,variant:t="default",render:n,...r}){return kxe({defaultTagName:"span",props:ll({className:Be(T2e({className:e,variant:t}))},r),render:n,state:{slot:"badge",variant:t}})}function Ta({className:e,size:t="default",...n}){return b.jsx("div",{"data-slot":"card","data-size":t,className:Be("ring-foreground/10 bg-card text-card-foreground gap-4 overflow-hidden rounded-lg py-4 text-xs/relaxed ring-1 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 *:[img:first-child]:rounded-t-lg *:[img:last-child]:rounded-b-lg group/card flex flex-col",e),...n})}function C2e({className:e,...t}){return b.jsx("div",{"data-slot":"card-header",className:Be("gap-1 rounded-t-lg px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]",e),...t})}function A2e({className:e,...t}){return b.jsx("div",{"data-slot":"card-title",className:Be("text-sm font-medium",e),...t})}function Bf({className:e,...t}){return b.jsx("div",{"data-slot":"card-content",className:Be("px-4 group-data-[size=sm]/card:px-3",e),...t})}function go({...e}){return b.jsx(HEe,{"data-slot":"alert-dialog",...e})}function Tu({...e}){return b.jsx(jte,{"data-slot":"alert-dialog-trigger",...e})}function k2e({...e}){return b.jsx(Dte,{"data-slot":"alert-dialog-portal",...e})}function O2e({className:e,...t}){return b.jsx(Ote,{"data-slot":"alert-dialog-overlay",className:Be("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/80 duration-100 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 isolate z-50",e),...t})}function bo({className:e,size:t="default",...n}){return b.jsxs(k2e,{children:[b.jsx(O2e,{}),b.jsx(Ite,{"data-slot":"alert-dialog-content","data-size":t,className:Be("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 bg-background ring-foreground/10 gap-3 rounded-xl p-4 ring-1 duration-100 data-[size=default]:max-w-xs data-[size=sm]:max-w-64 data-[size=default]:sm:max-w-sm group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 outline-none",e),...n})]})}function vo({className:e,...t}){return b.jsx("div",{"data-slot":"alert-dialog-header",className:Be("grid grid-rows-[auto_1fr] place-items-center gap-1 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...t})}function yo({className:e,...t}){return b.jsx("div",{"data-slot":"alert-dialog-footer",className:Be("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",e),...t})}function _o({className:e,...t}){return b.jsx(Mte,{"data-slot":"alert-dialog-title",className:Be("text-sm font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...t})}function Eo({className:e,...t}){return b.jsx(Rte,{"data-slot":"alert-dialog-description",className:Be("text-muted-foreground *:[a]:hover:text-foreground text-xs/relaxed text-balance md:text-pretty *:[a]:underline *:[a]:underline-offset-3",e),...t})}function qp({className:e,...t}){return b.jsx(We,{"data-slot":"alert-dialog-action",className:Be(e),...t})}function So({className:e,variant:t="outline",size:n="default",...r}){return b.jsx(Zx,{"data-slot":"alert-dialog-cancel",className:Be(e),render:b.jsx(We,{variant:t,size:n}),...r})}const hi=k.forwardRef(({className:e,...t},n)=>b.jsx(vSe,{ref:n,className:Be("peer size-4 shrink-0 rounded border border-input ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50","data-checked:bg-primary data-checked:border-primary data-checked:text-primary-foreground","flex items-center justify-center transition-colors",e),...t,children:b.jsx(ySe,{className:"flex items-center justify-center",children:b.jsx(fe,{icon:ml,size:12,strokeWidth:3})})}));hi.displayName="Checkbox";const TD={IN_PROGRESS:"bg-muted-foreground/20 text-muted-foreground",IN_REVIEW:"bg-primary/20 text-primary",DONE:"bg-accent/20 text-accent",CANCELED:"bg-destructive/20 text-destructive",ORPHANED:"bg-destructive/20 text-destructive"},R2e=js("/worktrees/")({component:L2e});function N2e(){const{t:e}=nn("common");return t=>{const n=new Date(t),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3),s=Math.floor(a/60),o=Math.floor(s/60),l=Math.floor(o/24);return l>0?l===1?e("time.dayAgo"):e("time.daysAgo",{count:l}):o>0?o===1?e("time.hourAgo"):e("time.hoursAgo",{count:o}):s>0?s===1?e("time.minuteAgo"):e("time.minutesAgo",{count:s}):e("time.justNow")}}function lH({className:e}){return b.jsx("span",{className:`inline-block animate-pulse rounded bg-muted ${e}`})}function I2e({worktree:e,onDelete:t}){const{t:n}=nn("common"),{t:r}=nn("worktrees"),i=N2e(),[a,s]=k.useState(!1),[o,l]=k.useState(!1),[u,f]=k.useState(!1),d=e.sizeFormatted==="..."||e.branch==="...",p=!e.isOrphaned&&e.taskId,m=async()=>{l(!0);try{await t(e,u),s(!1)}catch{}finally{l(!1)}},E=S=>{s(S),S||f(!1)};return b.jsx(Ta,{className:"transition-colors hover:border-border/80",children:b.jsxs(Bf,{className:"flex items-start justify-between gap-4 py-4",children:[b.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx("span",{className:"truncate font-medium",children:e.name}),e.isOrphaned?b.jsx(co,{className:Be("shrink-0",TD.ORPHANED),children:n("statuses.ORPHANED")}):e.taskStatus?b.jsx(co,{className:Be("shrink-0",TD[e.taskStatus]),children:n(`statuses.${e.taskStatus}`)}):null]}),b.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[b.jsxs("div",{className:"flex items-center gap-1.5",children:[b.jsx(fe,{icon:Ri,size:12,strokeWidth:2,className:"shrink-0"}),b.jsx("span",{className:"truncate font-mono",children:e.path})]}),b.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:[b.jsxs("div",{className:"flex items-center gap-1.5",children:[b.jsx(fe,{icon:Yx,size:12,strokeWidth:2,className:"shrink-0"}),e.branch==="..."?b.jsx(lH,{className:"h-3 w-16"}):b.jsx("span",{className:"font-mono",children:e.branch})]}),b.jsxs("div",{className:"flex items-center gap-1.5",children:[b.jsx(fe,{icon:vte,size:12,strokeWidth:2,className:"shrink-0"}),e.sizeFormatted==="..."?b.jsx(lH,{className:"h-3 w-12"}):b.jsx("span",{children:e.sizeFormatted})]}),b.jsxs("div",{className:"flex items-center gap-1.5",children:[b.jsx(fe,{icon:hte,size:12,strokeWidth:2,className:"shrink-0"}),b.jsx("span",{children:i(e.lastModified)})]})]}),e.taskId&&e.taskTitle&&b.jsx("div",{className:"flex items-center gap-1.5 pt-1",children:b.jsxs(Ai,{to:"/tasks/$taskId",params:{taskId:e.taskId},className:"inline-flex items-center gap-1 text-foreground hover:underline",children:[b.jsx("span",{className:"truncate",children:e.taskTitle}),b.jsx(fe,{icon:Zy,size:12,strokeWidth:2,className:"shrink-0"})]})})]})]}),b.jsxs(go,{open:a,onOpenChange:E,children:[b.jsx(Tu,{render:b.jsx(We,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-muted-foreground hover:text-destructive",disabled:d}),children:b.jsx(fe,{icon:vu,size:14,strokeWidth:2})}),b.jsxs(bo,{children:[b.jsxs(vo,{children:[b.jsx(_o,{children:r("delete.title")}),b.jsxs(Eo,{children:[r("delete.description")," ",b.jsx("span",{className:"font-mono",children:e.name}),".",u&&p&&b.jsxs(b.Fragment,{children:[" ",r("delete.linkedTaskWillBeDeleted",{title:e.taskTitle})]})," ",r("delete.cannotUndo")]}),p&&b.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[b.jsx(hi,{checked:u,onCheckedChange:S=>f(S===!0),disabled:o}),r("delete.alsoDeleteLinkedTask",{title:e.taskTitle})]})]}),b.jsxs(yo,{children:[b.jsx(So,{disabled:o,children:n("buttons.cancel")}),b.jsxs(We,{variant:"destructive",onClick:m,disabled:o,className:"gap-2",children:[o&&b.jsx(fe,{icon:tn,size:14,strokeWidth:2,className:"animate-spin"}),n(o?"status.deleting":"buttons.delete")]})]})]})]})]})})}const D2e=["IN_PROGRESS","IN_REVIEW","DONE","CANCELED","ORPHANED"];function L2e(){const{t:e}=nn("common"),{t}=nn("worktrees"),{worktrees:n,summary:r,isLoading:i,isLoadingDetails:a,error:s,refetch:o}=Cie(),l=Aie(),[u,f]=k.useState(new Set),[d,p]=k.useState(!1),[m,E]=k.useState(!1),[S,g]=k.useState(!1),y=O=>{f(N=>{const D=new Set(N);return D.has(O)?D.delete(O):D.add(O),D})},v=()=>{f(new Set)},x=k.useMemo(()=>u.size===0?n:n.filter(O=>!!(O.isOrphaned&&u.has("ORPHANED")||O.taskStatus&&u.has(O.taskStatus))),[n,u]),T=k.useMemo(()=>n.filter(O=>O.taskStatus==="DONE"||O.taskStatus==="CANCELED"),[n]),w=async()=>{if(T.length!==0){E(!0);try{for(const O of T)await l.mutateAsync({worktreePath:O.path,repoPath:O.repoPath,deleteLinkedTask:S});p(!1),o()}catch{}finally{E(!1)}}},C=O=>{p(O),O||g(!1)},R=async(O,N)=>{await l.mutateAsync({worktreePath:O.path,repoPath:O.repoPath,deleteLinkedTask:N}),o()};return b.jsxs("div",{className:"flex h-full flex-col",children:[b.jsxs("div",{className:"flex shrink-0 flex-col gap-2 border-b border-border bg-background px-4 py-2",children:[b.jsxs("div",{className:"flex items-center justify-between",children:[b.jsxs("div",{className:"flex items-center gap-4",children:[b.jsx("h1",{className:"text-sm font-medium",children:t("title")}),(r||n.length>0)&&b.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[b.jsx("span",{children:t("summary.total",{count:r?.total??n.length})}),(r?.orphaned??n.filter(O=>O.isOrphaned).length)>0&&b.jsx("span",{className:"text-destructive",children:t("summary.orphaned",{count:r?.orphaned??n.filter(O=>O.isOrphaned).length})}),a?b.jsx("span",{className:"animate-pulse",children:e("status.calculating")}):r?b.jsx("span",{children:r.totalSizeFormatted}):null]})]}),b.jsxs("div",{className:"flex items-center gap-2",children:[T.length>0&&b.jsxs(go,{open:d,onOpenChange:C,children:[b.jsxs(Tu,{render:b.jsx(We,{variant:"ghost",size:"sm",className:"gap-1.5 text-xs text-muted-foreground hover:text-destructive",disabled:a}),children:[b.jsx(fe,{icon:gte,size:12,strokeWidth:2}),t("cleanup.button",{count:T.length})]}),b.jsxs(bo,{children:[b.jsxs(vo,{children:[b.jsx(_o,{children:t("cleanup.title")}),b.jsxs(Eo,{children:[t("cleanup.description",{count:T.length}),S&&` ${t("cleanup.linkedTasksWillBeDeleted")}`]}),b.jsxs("div",{className:"space-y-3",children:[b.jsxs("p",{className:"text-sm text-muted-foreground",children:[T.filter(O=>O.taskStatus==="DONE").length>0&&b.jsxs("span",{className:"mr-3",children:[b.jsx("span",{className:"font-medium text-accent",children:T.filter(O=>O.taskStatus==="DONE").length})," ",t("cleanup.done")]}),T.filter(O=>O.taskStatus==="CANCELED").length>0&&b.jsxs("span",{children:[b.jsx("span",{className:"font-medium text-destructive",children:T.filter(O=>O.taskStatus==="CANCELED").length})," ",t("cleanup.canceled")]})]}),b.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[b.jsx(hi,{checked:S,onCheckedChange:O=>g(O===!0),disabled:m}),t("cleanup.alsoDeleteLinkedTasks")]}),b.jsx("p",{className:"font-medium text-destructive text-xs",children:t("cleanup.cannotUndo")})]})]}),b.jsxs(yo,{children:[b.jsx(So,{disabled:m,children:e("buttons.cancel")}),b.jsxs(We,{variant:"destructive",onClick:w,disabled:m,className:"gap-2",children:[m&&b.jsx(fe,{icon:tn,size:14,strokeWidth:2,className:"animate-spin"}),m?e("status.deleting"):t("delete.button",{count:T.length})]})]})]})]}),u.size>0&&b.jsxs(We,{variant:"ghost",size:"sm",onClick:v,className:"gap-1.5 text-xs",children:[b.jsx(fe,{icon:fi,size:12,strokeWidth:2}),e("buttons.clearFilters")]})]})]}),b.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:D2e.map(O=>{const N=u.has(O);return b.jsx("button",{onClick:()=>y(O),className:Be("rounded-full px-2.5 py-1 text-xs font-medium transition-colors",N?TD[O]:"bg-muted text-muted-foreground hover:bg-muted/80"),children:e(`statuses.${O}`)},O)})})]}),b.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[i&&b.jsx("div",{className:"flex items-center justify-center py-12",children:b.jsx(fe,{icon:tn,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}),s&&b.jsxs("div",{className:"flex items-center gap-3 py-6 text-destructive",children:[b.jsx(fe,{icon:rs,size:20,strokeWidth:2}),b.jsx("span",{className:"text-sm",children:t("error.failedToLoad",{message:s.message})})]}),!i&&!s&&x.length===0&&b.jsx("div",{className:"py-12 text-muted-foreground",children:b.jsx("p",{className:"text-sm",children:u.size>0?t("empty.noMatch"):t("empty.noWorktrees")})}),!i&&b.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:x.map(O=>b.jsx(I2e,{worktree:O,onDelete:R},O.path))})]})]})}function Wn(e,t="Assertion error"){if(!e)throw Error(t)}function Kp({group:e}){const{orientation:t,panels:n}=e;return n.reduce((r,i)=>(r+=t==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,r),0)}function CD(e,t){return t.sort(e==="horizontal"?P2e:M2e)}function P2e(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function M2e(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function kie(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function j2e({orientation:e,rects:t,targetRect:n}){const r={x:n.x+n.width/2,y:n.y+n.height/2};let i,a=Number.MAX_VALUE;for(const s of t){const{x:o,y:l}=kie(r,s),u=e==="horizontal"?o:l;u<a&&(a=u,i=s)}return Wn(i,"No rect found"),i}function Oie(e){const{element:t,orientation:n,panels:r,separators:i}=e,a=CD(n,Array.from(t.children).filter(f=>f instanceof HTMLElement).map(f=>({element:f}))).map(({element:f})=>f),s=[];let o=!1,l,u=[];for(const f of a)if(f.hasAttribute("data-panel")){const d=r.find(p=>p.element===f);if(d){if(l){const p=l.element.getBoundingClientRect(),m=f.getBoundingClientRect();let E;if(o){const S=n==="horizontal"?new DOMRect(p.right,p.top,0,p.height):new DOMRect(p.left,p.bottom,p.width,0),g=n==="horizontal"?new DOMRect(m.left,m.top,0,m.height):new DOMRect(m.left,m.top,m.width,0);switch(u.length){case 0:{E=[S,g];break}case 1:{const y=u[0],v=j2e({orientation:n,rects:[p,m],targetRect:y.element.getBoundingClientRect()});E=[y,v===p?g:S];break}default:{E=u;break}}}else u.length?E=u:E=[n==="horizontal"?new DOMRect(p.right,m.top,m.left-p.right,m.height):new DOMRect(m.left,p.bottom,m.width,m.top-p.bottom)];for(const S of E)s.push({group:e,groupSize:Kp({group:e}),panels:[l,d],separator:"width"in S?void 0:S,rect:"width"in S?S:S.element.getBoundingClientRect()})}o=!1,l=d,u=[]}}else if(f.hasAttribute("data-separator")){const d=i.find(p=>p.element===f);d?u.push(d):(l=void 0,u=[])}else o=!0;return s}function F2e(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function B2e(e,t){const n=getComputedStyle(e.ownerDocument.body),r=parseFloat(n.fontSize);return t*r}function U2e(e){return e/100*window.innerHeight}function $2e(e){return e/100*window.innerWidth}function z2e(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function I_({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,a]=z2e(n);switch(a){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=B2e(t,i);break}case"em":{r=F2e(t,i);break}case"vh":{r=U2e(i);break}case"vw":{r=$2e(i);break}}return r}function ao(e){return parseFloat(e.toFixed(3))}function uH(e){const{panels:t}=e,n=Kp({group:e});return n===0?t.map(r=>({collapsedSize:0,collapsible:r.panelConstraints.collapsible===!0,defaultSize:void 0,minSize:0,maxSize:100,panelId:r.id})):t.map(r=>{const{element:i,panelConstraints:a}=r;let s=0;if(a.collapsedSize){const f=I_({groupSize:n,panelElement:i,styleProp:a.collapsedSize});s=ao(f/n*100)}let o;if(a.defaultSize){const f=I_({groupSize:n,panelElement:i,styleProp:a.defaultSize});o=ao(f/n*100)}let l=0;if(a.minSize){const f=I_({groupSize:n,panelElement:i,styleProp:a.minSize});l=ao(f/n*100)}let u=100;if(a.maxSize){const f=I_({groupSize:n,panelElement:i,styleProp:a.maxSize});u=ao(f/n*100)}return{collapsedSize:s,collapsible:a.collapsible===!0,defaultSize:o,minSize:l,maxSize:u,panelId:r.id}})}class H2e{#e={};addListener(t,n){const r=this.#e[t];return r===void 0?this.#e[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=this.#e[t];if(r!==void 0)if(r.length===1)r[0].call(null,n);else{let i=!1,a=null;const s=Array.from(r);for(let o=0;o<s.length;o++){const l=s[o];try{l.call(null,n)}catch(u){a===null&&(i=!0,a=u)}}if(i)throw a}}removeAllListeners(){this.#e={}}removeListener(t,n){const r=this.#e[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}function Ji(e,t,n=0){return Math.abs(ao(e)-ao(t))<=n}let Es={cursorFlags:0,interactionState:{state:"inactive"},mountedGroups:new Map};const xf=new H2e;function yl(){return Es}function Ls(e){const t=typeof e=="function"?e(Es):e;if(Es===t)return Es;const n=Es;return Es={...Es,...t},t.cursorFlags!==void 0&&xf.emit("cursorFlagsChange",Es.cursorFlags),t.interactionState!==void 0&&xf.emit("interactionStateChange",Es.interactionState),t.mountedGroups!==void 0&&(Es.mountedGroups.forEach((r,i)=>{r.derivedPanelConstraints.forEach(a=>{if(a.collapsible){const{layout:s}=n.mountedGroups.get(i)??{};if(s){const o=Ji(a.collapsedSize,r.layout[a.panelId]),l=Ji(a.collapsedSize,s[a.panelId]);o&&!l&&(i.inMemoryLastExpandedPanelSizes[a.panelId]=s[a.panelId])}}})}),xf.emit("mountedGroupsChange",Es.mountedGroups)),Es}const W2e=e=>e,Lk=()=>{},Rie=1,Nie=2,Iie=4,Die=8,cH={coarse:10,precise:5};function V2e({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case"active":case"hover":t.forEach(a=>{if(!a.disableCursor)switch(a.orientation){case"horizontal":{r++;break}case"vertical":{i++;break}}})}if(r===0&&i===0)return null;switch(n){case"active":{const a=(e&Rie)!==0,s=(e&Nie)!==0,o=(e&Iie)!==0,l=(e&Die)!==0;if(e){if(a)return o?"se-resize":l?"ne-resize":"e-resize";if(s)return o?"sw-resize":l?"nw-resize":"w-resize";if(o)return"s-resize";if(l)return"n-resize"}break}}return r>0&&i>0?"move":r>0?"ew-resize":"ns-resize"}let Pk,jo;function n3(){jo===void 0&&(jo=new CSSStyleSheet,document.adoptedStyleSheets=[jo]);const{cursorFlags:e,interactionState:t}=yl();switch(t.state){case"active":case"hover":{const n=V2e({cursorFlags:e,groups:t.hitRegions.map(i=>i.group),state:t.state}),r=`*{cursor: ${n} !important; ${t.state==="active"?"touch-action: none;":""} }`;if(Pk===r)return;Pk=r,n?jo.cssRules.length===0?jo.insertRule(r):jo.replaceSync(r):jo.cssRules.length===1&&jo.deleteRule(0);break}case"inactive":{Pk=void 0,jo.cssRules.length===1&&jo.deleteRule(0);break}}}function G2e(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function $v(e,t){return Ji(e,t)?0:e>t?1:-1}function cp({panelConstraints:e,size:t}){const{collapsedSize:n=0,collapsible:r,maxSize:i=100,minSize:a=0}=e;if($v(t,a)<0)if(r){const s=(n+a)/2;$v(t,s)<0?t=n:t=a}else t=a;return t=Math.min(i,t),t=ao(t),t}function zv({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(Ji(e,0))return t;const s=Object.values(t),o=Object.values(i),l=[...s],[u,f]=r;Wn(u!=null,"Invalid first pivot index"),Wn(f!=null,"Invalid second pivot index");let d=0;if(a==="keyboard"){{const E=e<0?f:u,S=n[E];Wn(S,`Panel constraints not found for index ${E}`);const{collapsedSize:g=0,collapsible:y,minSize:v=0}=S;if(y){const x=s[E];if(Wn(x!=null,`Previous layout not found for panel index ${E}`),Ji(x,g)){const T=v-x;$v(T,Math.abs(e))>0&&(e=e<0?0-T:T)}}}{const E=e<0?u:f,S=n[E];Wn(S,`No panel constraints found for index ${E}`);const{collapsedSize:g=0,collapsible:y,minSize:v=0}=S;if(y){const x=s[E];if(Wn(x!=null,`Previous layout not found for panel index ${E}`),Ji(x,v)){const T=x-g;$v(T,Math.abs(e))>0&&(e=e<0?0-T:T)}}}}{const E=e<0?1:-1;let S=e<0?f:u,g=0;for(;;){const v=s[S];Wn(v!=null,`Previous layout not found for panel index ${S}`);const x=cp({panelConstraints:n[S],size:100})-v;if(g+=x,S+=E,S<0||S>=n.length)break}const y=Math.min(Math.abs(e),Math.abs(g));e=e<0?0-y:y}{let E=e<0?u:f;for(;E>=0&&E<n.length;){const S=Math.abs(e)-Math.abs(d),g=s[E];Wn(g!=null,`Previous layout not found for panel index ${E}`);const y=g-S,v=cp({panelConstraints:n[E],size:y});if(!Ji(g,v)&&(d+=g-v,l[E]=v,d.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?E--:E++}}if(G2e(o,l))return i;{const E=e<0?f:u,S=s[E];Wn(S!=null,`Previous layout not found for panel index ${E}`);const g=S+d,y=cp({panelConstraints:n[E],size:g});if(l[E]=y,!Ji(y,g)){let v=g-y,x=e<0?f:u;for(;x>=0&&x<n.length;){const T=l[x];Wn(T!=null,`Previous layout not found for panel index ${x}`);const w=T+v,C=cp({panelConstraints:n[x],size:w});if(Ji(T,C)||(v-=C-T,l[x]=C),Ji(v,0))break;e>0?x--:x++}}}const p=Object.values(l).reduce((E,S)=>S+E,0);if(!Ji(p,100,.1))return i;const m=Object.keys(i);return l.reduce((E,S,g)=>(E[m[g]]=S,E),{})}function zm(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||$v(e[n],t[n])!==0)return!1;return!0}function Lie({event:e,hitRegions:t,initialLayoutMap:n,mountedGroups:r,pointerDownAtPoint:i}){let a=0;const s=new Map(r);t.forEach(o=>{const{group:l,groupSize:u}=o,{disableCursor:f,orientation:d,panels:p}=l;let m=0;i?d==="horizontal"?m=(e.clientX-i.x)/u*100:m=(e.clientY-i.y)/u*100:d==="horizontal"?m=e.clientX<0?-100:100:m=e.clientY<0?-100:100;const E=n.get(l),{defaultLayoutDeferred:S,derivedPanelConstraints:g,layout:y,separatorToPanels:v}=r.get(l)??{defaultLayoutDeferred:!1};if(g&&E&&y&&v){const x=zv({delta:m,initialLayout:E,panelConstraints:g,pivotIndices:o.panels.map(T=>p.indexOf(T)),prevLayout:y,trigger:"mouse-or-touch"});if(zm(x,y)){if(m!==0&&!f)switch(d){case"horizontal":{a|=m<0?Rie:Nie;break}case"vertical":{a|=m<0?Iie:Die;break}}}else{s.set(o.group,{defaultLayoutDeferred:S,derivedPanelConstraints:g,layout:x,separatorToPanels:v});const T=o.group.panels.map(({id:w})=>w).join(",");o.group.inMemoryLayouts[T]=x}}}),Ls({cursorFlags:a,mountedGroups:s}),n3()}function dH(e){if(e.defaultPrevented||e.relatedTarget!==null||e.clientX===0&&e.clientY===0)return;const{interactionState:t,mountedGroups:n}=yl();t.state==="active"&&t.hitRegions.forEach(r=>{e.currentTarget===r.group.element&&Lie({event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n})})}function yE(e){const t=e.parentElement;Wn(t,"Parent group element not found");const{mountedGroups:n}=yl();for(const[r]of n)if(r.element===t)return r;throw Error("Could not find parent Group for separator element")}function Uf({layout:e,panelConstraints:t}){const n=[...Object.values(e)],r=n.reduce((s,o)=>s+o,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!Ji(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const o=n[s];Wn(o!=null,`No layout data found for index ${s}`);const l=100/r*o;n[s]=l}let i=0;for(let s=0;s<t.length;s++){const o=n[s];Wn(o!=null,`No layout data found for index ${s}`);const l=cp({panelConstraints:t[s],size:o});o!=l&&(i+=o-l,n[s]=l)}if(!Ji(i,0))for(let s=0;s<t.length;s++){const o=n[s];Wn(o!=null,`No layout data found for index ${s}`);const l=o+i,u=cp({panelConstraints:t[s],size:l});if(o!==u&&(i-=u-o,n[s]=u,Ji(i,0)))break}const a=Object.keys(e);return n.reduce((s,o,l)=>(s[a[l]]=o,s),{})}function Pie({groupId:e}){const t=()=>{const{mountedGroups:n}=yl();for(const[r,i]of n)if(r.id===e)return{group:r,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:r}=t();return n?{}:r},setLayout(n){const{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:a,layout:s,separatorToPanels:o}=t(),l=Uf({layout:n,panelConstraints:i});return r?s:(zm(s,l)||Ls(u=>({mountedGroups:new Map(u.mountedGroups).set(a,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:l,separatorToPanels:o})})),l)}}}function Mie(e){const{mountedGroups:t}=yl(),n=t.get(e);return Wn(n,`Mounted Group ${e.id} not found`),n}function Bd(e,t){const n=yE(e),r=Mie(n),i=n.separators.find(f=>f.element===e);Wn(i,"Matching separator not found");const a=r.separatorToPanels.get(i);Wn(a,"Matching panels not found");const s=a.map(f=>n.panels.indexOf(f)),o=Pie({groupId:n.id}).getLayout(),l=zv({delta:t,initialLayout:o,panelConstraints:r.derivedPanelConstraints,pivotIndices:s,prevLayout:o,trigger:"keyboard"}),u=Uf({layout:l,panelConstraints:r.derivedPanelConstraints});zm(o,u)||Ls(f=>({mountedGroups:new Map(f.mountedGroups).set(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,layout:u,separatorToPanels:r.separatorToPanels})}))}function fH(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=yE(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Bd(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Bd(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Bd(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Bd(t,-5);break}case"End":{e.preventDefault(),Bd(t,100);break}case"Enter":{e.preventDefault();const r=yE(t),{derivedPanelConstraints:i,layout:a,separatorToPanels:s}=Mie(r),o=r.separators.find(d=>d.element===t);Wn(o,"Matching separator not found");const l=s.get(o);Wn(l,"Matching panels not found");const u=l[0],f=i.find(d=>d.panelId===u.id);if(Wn(f,"Panel metadata not found"),f.collapsible){const d=a[u.id],p=f.collapsedSize===d?r.inMemoryLastExpandedPanelSizes[u.id]??f.minSize:f.collapsedSize;Bd(t,p-d)}break}case"F6":{e.preventDefault();const r=yE(t).separators.map(s=>s.element),i=Array.from(r).findIndex(s=>s===e.currentTarget);Wn(i!==null,"Index not found");const a=e.shiftKey?i>0?i-1:r.length-1:i+1<r.length?i+1:0;r[a].focus();break}case"Home":{e.preventDefault(),Bd(t,-100);break}}}function q2e(e,t,n){let r,i={x:1/0,y:1/0};for(const a of t){const s=kie(n,a.rect);switch(e){case"horizontal":{s.x<=i.x&&(r=a,i=s);break}case"vertical":{s.y<=i.y&&(r=a,i=s);break}}}return r?{distance:i,hitRegion:r}:void 0}let D_;function K2e(){return D_===void 0&&(typeof matchMedia=="function"?D_=!!matchMedia("(pointer:coarse)").matches:D_=!1),D_}function Y2e(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:mH(e),b:mH(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Wn(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:pH(hH(n.a)),b:pH(hH(n.b))};if(i.a===i.b){const a=r.childNodes,s={a:n.a.at(-1),b:n.b.at(-1)};let o=a.length;for(;o--;){const l=a[o];if(l===s.a)return 1;if(l===s.b)return-1}}return Math.sign(i.a-i.b)}const X2e=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Z2e(e){const t=getComputedStyle(jie(e)??e).display;return t==="flex"||t==="inline-flex"}function Q2e(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Z2e(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||X2e.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function hH(e){let t=e.length;for(;t--;){const n=e[t];if(Wn(n,"Missing node"),Q2e(n))return n}return null}function pH(e){return e&&Number(getComputedStyle(e).zIndex)||0}function mH(e){const t=[];for(;e;)t.push(e),e=jie(e);return t}function jie(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}function J2e(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function eNe({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!(n instanceof HTMLElement)||n.contains(e)||e.contains(n))return!0;if(Y2e(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(J2e(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Fie(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const a=K2e()?cH.coarse:cH.precise,s=Oie(i),o=q2e(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=a&&o.distance.y<=a&&eNe({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function gH(e){if(e.defaultPrevented)return;const{mountedGroups:t}=yl(),n=Fie(e,t),r=new Set,i=new Set,a=new Set,s=new Map;let o=!1;n.forEach(l=>{r.add(l.group),l.panels.forEach(f=>{i.add(f)}),l.separator&&(a.add(l.separator),o||(o=!0,l.separator.element.focus()));const u=t.get(l.group);u&&s.set(l.group,u.layout)}),Ls({interactionState:{hitRegions:n,initialLayoutMap:s,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}}),n.length&&e.preventDefault()}function bH(e){if(e.defaultPrevented)return;const{interactionState:t,mountedGroups:n}=yl();switch(t.state){case"active":{if(e.type!=="pointerleave"&&e.buttons===0){Ls(r=>r.interactionState.state==="inactive"?r:{cursorFlags:0,interactionState:{state:"inactive"}});return}Lie({event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint});break}default:{const r=Fie(e,n);r.length===0?t.state!=="inactive"&&Ls({interactionState:{state:"inactive"}}):Ls({interactionState:{hitRegions:r,state:"hover"}}),n3();break}}}function vH(e){if(e.defaultPrevented)return;e.preventDefault();const{interactionState:t}=yl();t.state==="active"&&(Ls({cursorFlags:0,interactionState:{state:"inactive"}}),n3())}function yH(e){let t=0,n=0;const r={};for(const a of e)if(a.defaultSize!==void 0){t++;const s=ao(a.defaultSize);n+=s,r[a.panelId]=s}else r[a.panelId]=void 0;const i=e.length-t;if(i!==0){const a=ao((100-n)/i);for(const s of e)s.defaultSize===void 0&&(r[s.panelId]=a)}return r}function tNe(e,t,n){const r=n[0];if(!r)return;const i=e.panels.find(s=>s.element===t);if(!i||!i.onResize)return;const a=Kp({group:e});i.onResize({asPercentage:ao(r.inlineSize/a*100),inPixels:r.inlineSize},i.id)}function nNe(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function rNe(e){let t=!0;const n=new Set,r=new Set,i=new ResizeObserver(m=>{for(const E of m){const{borderBoxSize:S,target:g}=E;if(g===e.element){if(t){if(Kp({group:e})===0)return;Ls(y=>{const v=y.mountedGroups.get(e);if(v){const x=uH(e),T=v.defaultLayoutDeferred?yH(x):v.layout,w=Uf({layout:T,panelConstraints:x});return!v.defaultLayoutDeferred&&zm(T,w)&&nNe(v.derivedPanelConstraints,x)?y:{mountedGroups:new Map(y.mountedGroups).set(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:x,layout:w,separatorToPanels:v.separatorToPanels})}}return y})}}else tNe(e,g,S)}});i.observe(e.element),e.panels.forEach(m=>{Wn(!n.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),n.add(m.id),m.onResize&&i.observe(m.element)});const a=Kp({group:e}),s=uH(e),o=e.panels.map(({id:m})=>m).join(",");let l=e.defaultLayout;l&&e.panels.length!==Object.keys(l).length&&(l=void 0);const u=e.inMemoryLayouts[o]??l??yH(s),f=Uf({layout:u,panelConstraints:s}),d=Oie(e),p=Ls(m=>{const E=new Map;return d.forEach(S=>{S.separator&&E.set(S.separator,S.panels)}),{mountedGroups:new Map(m.mountedGroups).set(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:s,layout:f,separatorToPanels:E})}});return e.element.addEventListener("pointerleave",dH),e.separators.forEach(m=>{Wn(!r.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),r.add(m.id),m.element.addEventListener("keydown",fH)}),p.mountedGroups.size===1&&(window.addEventListener("pointerdown",gH),window.addEventListener("pointermove",bH),window.addEventListener("pointerup",vH)),function(){t=!1;const m=Ls(E=>{const S=new Map(E.mountedGroups);return S.delete(e),{mountedGroups:S}});e.element.removeEventListener("pointerleave",dH),e.separators.forEach(E=>{E.element.removeEventListener("keydown",fH)}),m.mountedGroups.size===0&&(window.removeEventListener("pointerdown",gH),window.removeEventListener("pointermove",bH),window.removeEventListener("pointerup",vH)),i.disconnect()}}function r3(e){const t=k.useId();return`${e??t}`}const eh=typeof window<"u"?k.useLayoutEffect:k.useEffect;function i3(e){const t=k.useRef(e);return eh(()=>{t.current=e},[e]),k.useCallback(n=>t.current?.(n),[t])}function a3(...e){return i3(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function iNe(e){const t=k.useRef({...e});return eh(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const Bie="--react-resizable-panels--panel--pointer-events";function Uie(e,t){const n=e.replace(/[^a-zA-Z0-9\-_]/g,""),r=t.replace(/[^a-zA-Z0-9\-_]/g,"");return`--react-resizable-panels--${n}--${r}`}const $ie=k.createContext(null);function aNe(e,t){const n=k.useRef({getLayout:()=>({}),setLayout:W2e});k.useImperativeHandle(t,()=>n.current,[]),eh(()=>{Object.assign(n.current,Pie({groupId:e}))})}function sNe({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:s,id:o,onLayoutChange:l,orientation:u="horizontal",style:f,...d}){const p=k.useRef({}),m=i3(H=>{zm(p.current,H)||(p.current=H,l?.(H))}),E=r3(o),[S,g]=k.useState(!1),[y,v]=k.useState(null),[x,T]=k.useState(n??{}),[w,C]=k.useState([]),[R,O]=k.useState([]),N=k.useRef({lastExpandedPanelSizes:{},layouts:{}}),D=a3(v,a);aNe(E,s);const L=k.useMemo(()=>({id:E,orientation:u,registerPanel:H=>(C(B=>CD(u,[...B,H])),()=>{C(B=>B.filter(q=>q!==H))}),registerSeparator:H=>(O(B=>CD(u,[...B,H])),()=>{O(B=>B.filter(q=>q!==H))})}),[E,u]),z=iNe({defaultLayout:n,disableCursor:r}),M=k.useRef(null);eh(()=>{if(y===null)return;const H={defaultLayout:z.defaultLayout,disableCursor:!!z.disableCursor,disabled:!!i,element:y,id:E,inMemoryLastExpandedPanelSizes:N.current.lastExpandedPanelSizes,inMemoryLayouts:N.current.layouts,orientation:u,panels:w,separators:R};M.current=H;const B=rNe(H),q=yl().mountedGroups.get(H);if(q){const{defaultLayoutDeferred:j,derivedPanelConstraints:$,layout:Y}=q;!j&&$.length>0&&(T(Y),m?.(Y))}const K=xf.addListener("interactionStateChange",j=>{j.state==="active"?g(j.hitRegions.some($=>$.group===H)):g(!1)}),U=xf.addListener("mountedGroupsChange",j=>{const $=j.get(H);if($){const{defaultLayoutDeferred:Y,derivedPanelConstraints:W,layout:J}=$;if(Y||W.length===0)return;T(J),m?.(J)}});return()=>{M.current=null,B(),K(),U()}},[i,y,E,m,u,w,R,z]),k.useEffect(()=>{const H=M.current;H&&(H.defaultLayout=n,H.disableCursor=!!r)});const V={[Bie]:S?"none":void 0};for(const H in x){const B=Uie(E,H),q=x[H];V[B]=q}return b.jsx($ie.Provider,{value:L,children:b.jsx("div",{...d,"aria-orientation":u,className:t,"data-group":!0,"data-testid":E,id:E,ref:D,style:{...f,...V,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap"},children:e})})}function s3(){const e=k.useContext($ie);return Wn(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function oNe({groupId:e,panelId:t}){const n=()=>{const{mountedGroups:o}=yl();for(const[l,{defaultLayoutDeferred:u,derivedPanelConstraints:f,layout:d,separatorToPanels:p}]of o)if(l.id===e)return{defaultLayoutDeferred:u,derivedPanelConstraints:f,group:l,layout:d,separatorToPanels:p};throw Error(`Group ${e} not found`)},r=()=>{const o=n().derivedPanelConstraints.find(l=>l.panelId===t);if(o!==void 0)return o;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const o=n().group.panels.find(l=>l.id===t);if(o!==void 0)return o;throw Error(`Layout not found for Panel ${t}`)},a=()=>{const o=n().layout[t];if(o!==void 0)return o;throw Error(`Layout not found for Panel ${t}`)},s=o=>{const l=a();if(o===l)return;const{defaultLayoutDeferred:u,derivedPanelConstraints:f,group:d,layout:p,separatorToPanels:m}=n(),E=d.panels.findIndex(v=>v.id===t),S=E===d.panels.length-1,g=zv({delta:S?l-o:o-l,initialLayout:p,panelConstraints:f,pivotIndices:S?[E-1,E]:[E,E+1],prevLayout:p,trigger:"imperative-api"}),y=Uf({layout:g,panelConstraints:f});zm(p,y)||Ls(v=>({mountedGroups:new Map(v.mountedGroups).set(d,{defaultLayoutDeferred:u,derivedPanelConstraints:f,layout:y,separatorToPanels:m})}))};return{collapse:()=>{const{collapsible:o,collapsedSize:l}=r(),u=a();o&&u!==l&&s(l)},expand:()=>{const{collapsible:o,collapsedSize:l,minSize:u}=r(),f=a();o&&f===l&&s(u)},getSize:()=>{const{group:o}=n(),l=a(),{element:u}=i(),f=o.orientation==="horizontal"?u.offsetWidth:u.offsetHeight;return{asPercentage:l,inPixels:f}},isCollapsed:()=>{const{collapsible:o,collapsedSize:l}=r(),u=a();return o&&Ji(l,u)},resize:o=>{if(a()!==o){let l;switch(typeof o){case"number":{const{group:u}=n(),f=Kp({group:u});l=ao(o/f*100);break}case"string":{l=parseFloat(o);break}}s(l)}}}}function lNe(e,t){const{id:n}=s3(),r=k.useRef({collapse:Lk,expand:Lk,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Lk});k.useImperativeHandle(t,()=>r.current,[]),eh(()=>{Object.assign(r.current,oNe({groupId:n,panelId:e}))})}function uNe({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:i,elementRef:a,id:s,maxSize:o="100%",minSize:l="0%",onResize:u,panelRef:f,style:d,...p}){const m=!!s,E=r3(s),[S,g]=k.useState(null),y=a3(g,a),{id:v,registerPanel:x}=s3(),T=u!==null,w=i3(R=>{u?.(R,s)});eh(()=>{if(S!==null)return x({element:S,id:E,idIsStable:m,onResize:T?w:void 0,panelConstraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:o,minSize:l}})},[n,r,i,S,T,E,m,o,l,w,x]),lNe(E,f);const C=Uie(v,E);return b.jsx("div",{...p,"data-panel":!0,"data-testid":E,id:E,ref:y,style:{...cNe,flexBasis:0,flexGrow:`var(${C}, 1)`,flexShrink:1,overflow:"hidden",pointerEvents:`var(${Bie})`},children:b.jsx("div",{className:t,style:{width:"100%",height:"100%",...d},children:e})})}const cNe={minHeight:"unset",maxHeight:"unset",height:"unset",minWidth:"unset",maxWidth:"unset",width:"unset",flex:"unset",flexBasis:"unset",flexShrink:"unset",flexGrow:"unset",border:"unset",borderWidth:"unset",padding:"unset",margin:"unset"};function dNe({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a;const s=e[n],o=t.find(l=>l.panelId===n);if(o){const l=o.maxSize,u=a=o.collapsible?o.collapsedSize:o.minSize,f=[r,r+1];a=Uf({layout:zv({delta:u-s,initialLayout:e,panelConstraints:t,pivotIndices:f,prevLayout:e,trigger:"keyboard"}),panelConstraints:t})[n],i=Uf({layout:zv({delta:l-s,initialLayout:e,panelConstraints:t,pivotIndices:f,prevLayout:e,trigger:"keyboard"}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:s}}function fNe({children:e,className:t,elementRef:n,id:r,style:i,...a}){const s=r3(r),[o,l]=k.useState({}),[u,f]=k.useState("inactive"),[d,p]=k.useState(null),m=a3(p,n),{id:E,orientation:S,registerSeparator:g}=s3(),y=S==="horizontal"?"vertical":"horizontal";return eh(()=>{if(d!==null){const v={element:d,id:s},x=g(v),T=xf.addListener("interactionStateChange",C=>{f(C.state!=="inactive"&&C.hitRegions.some(R=>R.separator===v)?C.state:"inactive")}),w=xf.addListener("mountedGroupsChange",C=>{C.forEach(({derivedPanelConstraints:R,layout:O,separatorToPanels:N},D)=>{if(D.id===E){const L=N.get(v);if(L){const z=L[0],M=D.panels.indexOf(z);l(dNe({layout:O,panelConstraints:R,panelId:z.id,panelIndex:M}))}}})});return()=>{T(),w(),x()}}},[d,E,s,g]),b.jsx("div",{...a,"aria-controls":o.valueControls,"aria-orientation":y,"aria-valuemax":o.valueMax,"aria-valuemin":o.valueMin,"aria-valuenow":o.valueNow,children:e,className:t,"data-separator":u,"data-testid":s,id:s,ref:m,role:"separator",style:{flexBasis:"auto",...i,flexGrow:0,flexShrink:0},tabIndex:0})}function Yd({className:e,direction:t,...n}){return b.jsx(sNe,{"data-slot":"resizable-panel-group",orientation:t,className:Be("flex h-full w-full data-[orientation=vertical]:flex-col",e),...n})}function xs({...e}){return b.jsx(uNe,{"data-slot":"resizable-panel",...e})}function Xd({withHandle:e,className:t,...n}){return b.jsx(fNe,{"data-slot":"resizable-handle",className:Be("relative flex w-px items-center justify-center bg-border cursor-grab active:cursor-grabbing group touch-none","focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/60","focus-visible:ring-offset-1 focus-visible:ring-offset-background","data-[orientation=vertical]:h-px data-[orientation=vertical]:w-full data-[orientation=vertical]:cursor-row-resize","[&[data-orientation=vertical]>div]:rotate-90",t),...n,children:e&&b.jsxs("div",{className:"pointer-events-none absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 flex flex-col items-center gap-1 bg-muted/90 border border-border rounded-full px-1 py-3 opacity-70 group-hover:opacity-100 group-focus:opacity-100 transition-opacity shadow-sm",children:[b.jsx("span",{className:"w-0.5 h-0.5 rounded-full bg-muted-foreground"}),b.jsx("span",{className:"w-0.5 h-0.5 rounded-full bg-muted-foreground"}),b.jsx("span",{className:"w-0.5 h-0.5 rounded-full bg-muted-foreground"})]})})}var Mk={exports:{}},_H;function hNe(){return _H||(_H=1,(function(e,t){(function(n,r){e.exports=r()})(globalThis,(()=>(()=>{var n={4567:function(s,o,l){var u=this&&this.__decorate||function(v,x,T,w){var C,R=arguments.length,O=R<3?x:w===null?w=Object.getOwnPropertyDescriptor(x,T):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(v,x,T,w);else for(var N=v.length-1;N>=0;N--)(C=v[N])&&(O=(R<3?C(O):R>3?C(x,T,O):C(x,T))||O);return R>3&&O&&Object.defineProperty(x,T,O),O},f=this&&this.__param||function(v,x){return function(T,w){x(T,w,v)}};Object.defineProperty(o,"__esModule",{value:!0}),o.AccessibilityManager=void 0;const d=l(9042),p=l(9924),m=l(844),E=l(4725),S=l(2585),g=l(3656);let y=o.AccessibilityManager=class extends m.Disposable{constructor(v,x,T,w){super(),this._terminal=v,this._coreBrowserService=T,this._renderService=w,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let C=0;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);if(this._topBoundaryFocusListener=C=>this._handleBoundaryFocus(C,0),this._bottomBoundaryFocusListener=C=>this._handleBoundaryFocus(C,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new p.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((C=>this._handleResize(C.rows)))),this.register(this._terminal.onRender((C=>this._refreshRows(C.start,C.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((C=>this._handleChar(C)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
32
32
  `)))),this.register(this._terminal.onA11yTab((C=>this._handleTab(C)))),this.register(this._terminal.onKey((C=>this._handleKey(C.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,g.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,m.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(v){for(let x=0;x<v;x++)this._handleChar(" ")}_handleChar(v){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==v&&(this._charsToAnnounce+=v):this._charsToAnnounce+=v,v===`
33
33
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=d.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(v){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(v)||this._charsToConsume.push(v)}_refreshRows(v,x){this._liveRegionDebouncer.refresh(v,x,this._terminal.rows)}_renderRows(v,x){const T=this._terminal.buffer,w=T.lines.length.toString();for(let C=v;C<=x;C++){const R=T.lines.get(T.ydisp+C),O=[],N=R?.translateToString(!0,void 0,void 0,O)||"",D=(T.ydisp+C+1).toString(),L=this._rowElements[C];L&&(N.length===0?(L.innerText=" ",this._rowColumns.set(L,[0,1])):(L.textContent=N,this._rowColumns.set(L,O)),L.setAttribute("aria-posinset",D),L.setAttribute("aria-setsize",w))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(v,x){const T=v.target,w=this._rowElements[x===0?1:this._rowElements.length-2];if(T.getAttribute("aria-posinset")===(x===0?"1":`${this._terminal.buffer.lines.length}`)||v.relatedTarget!==w)return;let C,R;if(x===0?(C=T,R=this._rowElements.pop(),this._rowContainer.removeChild(R)):(C=this._rowElements.shift(),R=T,this._rowContainer.removeChild(C)),C.removeEventListener("focus",this._topBoundaryFocusListener),R.removeEventListener("focus",this._bottomBoundaryFocusListener),x===0){const O=this._createAccessibilityTreeNode();this._rowElements.unshift(O),this._rowContainer.insertAdjacentElement("afterbegin",O)}else{const O=this._createAccessibilityTreeNode();this._rowElements.push(O),this._rowContainer.appendChild(O)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(x===0?-1:1),this._rowElements[x===0?1:this._rowElements.length-2].focus(),v.preventDefault(),v.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;const v=document.getSelection();if(!v)return;if(v.isCollapsed)return void(this._rowContainer.contains(v.anchorNode)&&this._terminal.clearSelection());if(!v.anchorNode||!v.focusNode)return void console.error("anchorNode and/or focusNode are null");let x={node:v.anchorNode,offset:v.anchorOffset},T={node:v.focusNode,offset:v.focusOffset};if((x.node.compareDocumentPosition(T.node)&Node.DOCUMENT_POSITION_PRECEDING||x.node===T.node&&x.offset>T.offset)&&([x,T]=[T,x]),x.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(x={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(x.node))return;const w=this._rowElements.slice(-1)[0];if(T.node.compareDocumentPosition(w)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(T={node:w,offset:w.textContent?.length??0}),!this._rowContainer.contains(T.node))return;const C=({node:N,offset:D})=>{const L=N instanceof Text?N.parentNode:N;let z=parseInt(L?.getAttribute("aria-posinset"),10)-1;if(isNaN(z))return console.warn("row is invalid. Race condition?"),null;const M=this._rowColumns.get(L);if(!M)return console.warn("columns is null. Race condition?"),null;let V=D<M.length?M[D]:M.slice(-1)[0]+1;return V>=this._terminal.cols&&(++z,V=0),{row:z,column:V}},R=C(x),O=C(T);if(R&&O){if(R.row>O.row||R.row===O.row&&R.column>=O.column)throw new Error("invalid range");this._terminal.select(R.column,R.row,(O.row-R.row)*this._terminal.cols-R.column+O.column)}}_handleResize(v){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let x=this._rowContainer.children.length;x<this._terminal.rows;x++)this._rowElements[x]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[x]);for(;this._rowElements.length>v;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const v=this._coreBrowserService.mainDocument.createElement("div");return v.setAttribute("role","listitem"),v.tabIndex=-1,this._refreshRowDimensions(v),v}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let v=0;v<this._terminal.rows;v++)this._refreshRowDimensions(this._rowElements[v])}}_refreshRowDimensions(v){v.style.height=`${this._renderService.dimensions.css.cell.height}px`}};o.AccessibilityManager=y=u([f(1,S.IInstantiationService),f(2,E.ICoreBrowserService),f(3,E.IRenderService)],y)},3614:(s,o)=>{function l(p){return p.replace(/\r?\n/g,"\r")}function u(p,m){return m?"\x1B[200~"+p+"\x1B[201~":p}function f(p,m,E,S){p=u(p=l(p),E.decPrivateModes.bracketedPasteMode&&S.rawOptions.ignoreBracketedPasteMode!==!0),E.triggerDataEvent(p,!0),m.value=""}function d(p,m,E){const S=E.getBoundingClientRect(),g=p.clientX-S.left-10,y=p.clientY-S.top-10;m.style.width="20px",m.style.height="20px",m.style.left=`${g}px`,m.style.top=`${y}px`,m.style.zIndex="1000",m.focus()}Object.defineProperty(o,"__esModule",{value:!0}),o.rightClickHandler=o.moveTextAreaUnderMouseCursor=o.paste=o.handlePasteEvent=o.copyHandler=o.bracketTextForPaste=o.prepareTextForTerminal=void 0,o.prepareTextForTerminal=l,o.bracketTextForPaste=u,o.copyHandler=function(p,m){p.clipboardData&&p.clipboardData.setData("text/plain",m.selectionText),p.preventDefault()},o.handlePasteEvent=function(p,m,E,S){p.stopPropagation(),p.clipboardData&&f(p.clipboardData.getData("text/plain"),m,E,S)},o.paste=f,o.moveTextAreaUnderMouseCursor=d,o.rightClickHandler=function(p,m,E,S,g){d(p,m,E),g&&S.rightClickSelect(p),m.value=S.selectionText,m.select()}},7239:(s,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ColorContrastCache=void 0;const u=l(1505);o.ColorContrastCache=class{constructor(){this._color=new u.TwoKeyMap,this._css=new u.TwoKeyMap}setCss(f,d,p){this._css.set(f,d,p)}getCss(f,d){return this._css.get(f,d)}setColor(f,d,p){this._color.set(f,d,p)}getColor(f,d){return this._color.get(f,d)}clear(){this._color.clear(),this._css.clear()}}},3656:(s,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.addDisposableDomListener=void 0,o.addDisposableDomListener=function(l,u,f,d){l.addEventListener(u,f,d);let p=!1;return{dispose:()=>{p||(p=!0,l.removeEventListener(u,f,d))}}}},3551:function(s,o,l){var u=this&&this.__decorate||function(y,v,x,T){var w,C=arguments.length,R=C<3?v:T===null?T=Object.getOwnPropertyDescriptor(v,x):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(y,v,x,T);else for(var O=y.length-1;O>=0;O--)(w=y[O])&&(R=(C<3?w(R):C>3?w(v,x,R):w(v,x))||R);return C>3&&R&&Object.defineProperty(v,x,R),R},f=this&&this.__param||function(y,v){return function(x,T){v(x,T,y)}};Object.defineProperty(o,"__esModule",{value:!0}),o.Linkifier=void 0;const d=l(3656),p=l(8460),m=l(844),E=l(2585),S=l(4725);let g=o.Linkifier=class extends m.Disposable{get currentLink(){return this._currentLink}constructor(y,v,x,T,w){super(),this._element=y,this._mouseService=v,this._renderService=x,this._bufferService=T,this._linkProviderService=w,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new p.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new p.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,m.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,m.toDisposable)((()=>{this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,d.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,d.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,d.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,d.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(y){this._lastMouseEvent=y;const v=this._positionFromMouseEvent(y,this._element,this._mouseService);if(!v)return;this._isMouseOut=!1;const x=y.composedPath();for(let T=0;T<x.length;T++){const w=x[T];if(w.classList.contains("xterm"))break;if(w.classList.contains("xterm-hover"))return}this._lastBufferCell&&v.x===this._lastBufferCell.x&&v.y===this._lastBufferCell.y||(this._handleHover(v),this._lastBufferCell=v)}_handleHover(y){if(this._activeLine!==y.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(y,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,y)||(this._clearCurrentLink(),this._askForLink(y,!0))}_askForLink(y,v){this._activeProviderReplies&&v||(this._activeProviderReplies?.forEach((T=>{T?.forEach((w=>{w.link.dispose&&w.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=y.y);let x=!1;for(const[T,w]of this._linkProviderService.linkProviders.entries())v?this._activeProviderReplies?.get(T)&&(x=this._checkLinkProviderResult(T,y,x)):w.provideLinks(y.y,(C=>{if(this._isMouseOut)return;const R=C?.map((O=>({link:O})));this._activeProviderReplies?.set(T,R),x=this._checkLinkProviderResult(T,y,x),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(y.y,this._activeProviderReplies)}))}_removeIntersectingLinks(y,v){const x=new Set;for(let T=0;T<v.size;T++){const w=v.get(T);if(w)for(let C=0;C<w.length;C++){const R=w[C],O=R.link.range.start.y<y?0:R.link.range.start.x,N=R.link.range.end.y>y?this._bufferService.cols:R.link.range.end.x;for(let D=O;D<=N;D++){if(x.has(D)){w.splice(C--,1);break}x.add(D)}}}}_checkLinkProviderResult(y,v,x){if(!this._activeProviderReplies)return x;const T=this._activeProviderReplies.get(y);let w=!1;for(let C=0;C<y;C++)this._activeProviderReplies.has(C)&&!this._activeProviderReplies.get(C)||(w=!0);if(!w&&T){const C=T.find((R=>this._linkAtPosition(R.link,v)));C&&(x=!0,this._handleNewLink(C))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!x)for(let C=0;C<this._activeProviderReplies.size;C++){const R=this._activeProviderReplies.get(C)?.find((O=>this._linkAtPosition(O.link,v)));if(R){x=!0,this._handleNewLink(R);break}}return x}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(y){if(!this._currentLink)return;const v=this._positionFromMouseEvent(y,this._element,this._mouseService);v&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,v)&&this._currentLink.link.activate(y,this._currentLink.link.text)}_clearCurrentLink(y,v){this._currentLink&&this._lastMouseEvent&&(!y||!v||this._currentLink.link.range.start.y>=y&&this._currentLink.link.range.end.y<=v)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,m.disposeArray)(this._linkCacheDisposables))}_handleNewLink(y){if(!this._lastMouseEvent)return;const v=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);v&&this._linkAtPosition(y.link,v)&&(this._currentLink=y,this._currentLink.state={decorations:{underline:y.link.decorations===void 0||y.link.decorations.underline,pointerCursor:y.link.decorations===void 0||y.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,y.link,this._lastMouseEvent),y.link.decorations={},Object.defineProperties(y.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:x=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==x&&(this._currentLink.state.decorations.pointerCursor=x,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",x))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:x=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==x&&(this._currentLink.state.decorations.underline=x,this._currentLink.state.isHovered&&this._fireUnderlineEvent(y.link,x))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((x=>{if(!this._currentLink)return;const T=x.start===0?0:x.start+1+this._bufferService.buffer.ydisp,w=this._bufferService.buffer.ydisp+1+x.end;if(this._currentLink.link.range.start.y>=T&&this._currentLink.link.range.end.y<=w&&(this._clearCurrentLink(T,w),this._lastMouseEvent)){const C=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);C&&this._askForLink(C,!1)}}))))}_linkHover(y,v,x){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(v,!0),this._currentLink.state.decorations.pointerCursor&&y.classList.add("xterm-cursor-pointer")),v.hover&&v.hover(x,v.text)}_fireUnderlineEvent(y,v){const x=y.range,T=this._bufferService.buffer.ydisp,w=this._createLinkUnderlineEvent(x.start.x-1,x.start.y-T-1,x.end.x,x.end.y-T-1,void 0);(v?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(w)}_linkLeave(y,v,x){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(v,!1),this._currentLink.state.decorations.pointerCursor&&y.classList.remove("xterm-cursor-pointer")),v.leave&&v.leave(x,v.text)}_linkAtPosition(y,v){const x=y.range.start.y*this._bufferService.cols+y.range.start.x,T=y.range.end.y*this._bufferService.cols+y.range.end.x,w=v.y*this._bufferService.cols+v.x;return x<=w&&w<=T}_positionFromMouseEvent(y,v,x){const T=x.getCoords(y,v,this._bufferService.cols,this._bufferService.rows);if(T)return{x:T[0],y:T[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(y,v,x,T,w){return{x1:y,y1:v,x2:x,y2:T,cols:this._bufferService.cols,fg:w}}};o.Linkifier=g=u([f(1,S.IMouseService),f(2,S.IRenderService),f(3,E.IBufferService),f(4,S.ILinkProviderService)],g)},9042:(s,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.tooMuchOutput=o.promptLabel=void 0,o.promptLabel="Terminal input",o.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(s,o,l){var u=this&&this.__decorate||function(S,g,y,v){var x,T=arguments.length,w=T<3?g:v===null?v=Object.getOwnPropertyDescriptor(g,y):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(S,g,y,v);else for(var C=S.length-1;C>=0;C--)(x=S[C])&&(w=(T<3?x(w):T>3?x(g,y,w):x(g,y))||w);return T>3&&w&&Object.defineProperty(g,y,w),w},f=this&&this.__param||function(S,g){return function(y,v){g(y,v,S)}};Object.defineProperty(o,"__esModule",{value:!0}),o.OscLinkProvider=void 0;const d=l(511),p=l(2585);let m=o.OscLinkProvider=class{constructor(S,g,y){this._bufferService=S,this._optionsService=g,this._oscLinkService=y}provideLinks(S,g){const y=this._bufferService.buffer.lines.get(S-1);if(!y)return void g(void 0);const v=[],x=this._optionsService.rawOptions.linkHandler,T=new d.CellData,w=y.getTrimmedLength();let C=-1,R=-1,O=!1;for(let N=0;N<w;N++)if(R!==-1||y.hasContent(N)){if(y.loadCell(N,T),T.hasExtendedAttrs()&&T.extended.urlId){if(R===-1){R=N,C=T.extended.urlId;continue}O=T.extended.urlId!==C}else R!==-1&&(O=!0);if(O||R!==-1&&N===w-1){const D=this._oscLinkService.getLinkData(C)?.uri;if(D){const L={start:{x:R+1,y:S},end:{x:N+(O||N!==w-1?0:1),y:S}};let z=!1;if(!x?.allowNonHttpProtocols)try{const M=new URL(D);["http:","https:"].includes(M.protocol)||(z=!0)}catch{z=!0}z||v.push({text:D,range:L,activate:(M,V)=>x?x.activate(M,V,L):E(0,V),hover:(M,V)=>x?.hover?.(M,V,L),leave:(M,V)=>x?.leave?.(M,V,L)})}O=!1,T.hasExtendedAttrs()&&T.extended.urlId?(R=N,C=T.extended.urlId):(R=-1,C=-1)}}g(v)}};function E(S,g){if(confirm(`Do you want to navigate to ${g}?
34
34
 
package/dist/index.html CHANGED
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/jpeg" href="/logo.jpg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Vibora</title>
8
- <script type="module" crossorigin src="/assets/index-C6ColFzJ.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-6VLueHY2.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-_L2gAsP8.css">
10
10
  </head>
11
11
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibora",
3
- "version": "5.2.0",
3
+ "version": "5.3.0",
4
4
  "description": "The Vibe Engineer's Cockpit",
5
5
  "license": "PolyForm-Shield-1.0.0",
6
6
  "repository": {