vibora 4.3.0 → 4.4.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.
|
@@ -28,7 +28,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
28
28
|
|
|
29
29
|
`)+n.map(uOe).join(`
|
|
30
30
|
`)}var fOe=0,hOe=(function(){function e(){Object.defineProperty(this,"cacheId",{enumerable:!0,configurable:!0,writable:!0,value:fOe++}),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([],fw));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;gre(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 Cke(this.cache).forEach(function(a){for(var s=vu(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 YM(e,t,n,r,i){var a=jre(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 Ta(e,t,n,r,i)}function sd(e,t,n,r,i){return new Cv(e,t,n,r,i)}function pOe(e){return e instanceof Cv||e instanceof Ta}var Si;(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"})(Si||(Si={}));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 jre(e){return e&&e.$treenode||null}function mOe(){return On(this).snapshot}function gOe(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 Cv){var s=r.value;Sr(s)&&(r=On(s))}if(r instanceof Ta){var o=r.getChildType(a);if(o&&(r=r.getChildNode(a),r))continue}}}throw new St("Could not resolve '".concat(a,"' in path '").concat(jz(t.slice(0,i))||"/","' while resolving '").concat(jz(t),"'"))}}catch(l){if(!n)return;throw l}return r}function Fre(e){if(!e)return Up;var t=Object.keys(e);if(!t.length)return Up;var n=new Array(t.length);return t.forEach(function(r,i){n[i]=e[r]}),n}var bOe=Object.toString(),Up=Object.freeze([]),$p=Object.freeze({}),fw=QAe().useProxies?{deep:!1}:{deep:!1,proxy:!1};Object.freeze(fw);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 vOe(e){return e}var yOe=Number.isInteger;function _Oe(e){return Number(e)===e&&e%1!==0}function EOe(e){return Number.isFinite(e)}function Bre(e){return Array.isArray(e)||gl(e)}function Ure(e){return e?Bre(e)?e:[e]:Up}function SOe(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 ap(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())===bOe}function $re(e){return e!==null&&typeof e=="object"&&!(e instanceof Date)&&!(e instanceof RegExp)}function kv(e,t){return t===void 0&&(t=!0),e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"||t&&e instanceof Date}function zre(e){return typeof e!="function"}function xOe(e,t,n){ko(e)?vre(e,t,n):Object.defineProperty(e,t,n)}function mf(e,t,n){xOe(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}var wOe=(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,yu([],vu(t),!1))})}}),e})(),Hre=(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 wOe),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,yu([],vu(r),!1))}}),e})();function Wre(e){for(var t=new Array(e.length),n=0;n<e.length;n++)t[n]=e[n];return t}function gk(e,t){return e.indexOf(t)===0}function TOe(e){console.warn(new Error("[mobx-state-tree] ".concat(e)))}function COe(){return typeof process<"u"&&Pz&&Pz.ENABLE_TYPE_CHECK==="true"}function bk(e){typeof queueMicrotask=="function"?queueMicrotask(e):typeof setImmediate=="function"?setImmediate(e):setTimeout(e,1)}function vk(e){return AOe(e.name,e)}function AOe(e,t){var n=function(){var i=Lre(),a=Dre();if(!a)throw new St("a mst flow must always have a parent context");var s=Pre(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:yu(yu([],vu(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,fD(ya(ya({},o),{type:d,args:[p]}),f)}return new Promise(function(f,d){var p,m=function(){p=t.apply(null,arguments),y(void 0)};m.$mst_middleware=n.$mst_middleware,fD(ya(ya({},o),{type:"flow_spawn",args:Wre(l)}),m);function y(_){var v;try{var x=u(function(T){v=p.next(T)},"flow_resume",_);x instanceof Error&&(v=p.throw(x))}catch(T){bk(function(){u(function(w){d(T)},"flow_throw",T)});return}g(v)}function S(_){var v;try{u(function(x){v=p.throw(x)},"flow_resume_error",_)}catch(x){bk(function(){u(function(T){d(x)},"flow_throw",x)});return}g(v)}function g(_){if(_.done){bk(function(){u(function(v){f(v)},"flow_return",_.value)});return}if(!_.value||typeof _.value.then!="function")throw new St("Only promises can be yielded to `async`, got: "+_);return _.value.then(y,S)}})};return n._isFlowAction=!0,n}function kOe(e){if(!("oldValue"in e))throw new St("Patches without `oldValue` field cannot be inversed");return[OOe(e),ROe(e)]}function OOe(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 ROe(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 NOe(e){return typeof e=="number"}function gf(e){return NOe(e)===!0?""+e:e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function IOe(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function jz(e){if(e.length===0)return"";var t=function(n){return n.map(gf).join("/")};return e[0]==="."||e[0]===".."?t(e):"/"+t(e)}function DOe(e){var t=e.split("/").map(IOe),n=e===""||e==="."||e===".."||gk(e,"/")||gk(e,"./")||gk(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 yk=Symbol("$preProcessorFailed"),LOe=(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 yk}}}),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;POe(n.type,this,"create"),n instanceof Ta&&(n.hasSnapshotPostProcessor=!!this._processors.postProcessor);var i=n.getSnapshot;n.getSnapshot=function(){return r.postProcessSnapshot(i.call(n),n)},t2e(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===yk?Oa(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=Eu(n)?this._subtype:Sr(n)?n:this.preProcessSnapshotSafe(n);return r===yk?!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 Bp))return!1;var i=this.preProcessSnapshot(r);return this._subtype.isMatchingSnapshotId(n,i)}}),t})(_u);function POe(e,t){for(var n,r,i=[],a=2;a<arguments.length;a++)i[a-2]=arguments[a];try{for(var s=Hb(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 MOe(e,t,n){return new LOe(e,t,n)}var Fz="Map.put can only be used to store complex values that have an identifier type attribute";function Vre(e,t){var n,r,i=e.getSubTypes();if(i===Ire)return!1;if(i){var a=Ure(i);try{for(var s=Hb(a),o=s.next();!o.done;o=s.next()){var l=o.value;if(!Vre(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 Ov&&t.push(e),!0}var yc;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.YES=1]="YES",e[e.NO=2]="NO"})(yc||(yc={}));var jOe=(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(Fz);return this.set(r.identifier,n),n}else if($re(n)){var i=On(this),a=i.type;if(a.identifierMode!==yc.YES)throw new St(Fz);var s=a.mapIdentifierAttribute,o=n[s];if(!XM(o)){var l=this.put(a.getChildType().create(n,i.environment));return this.put(Zke(l))}var u=t0(o);return this.set(u,n),this.get(u)}else throw new St("Map.put can only be used to store complex values")}}),t})(VM),sS=(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:yc.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(),YM(this,n,r,i,a)}}),Object.defineProperty(t.prototype,"_determineIdentifierMode",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.identifierMode===yc.UNKNOWN){var n=[];if(Vre(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=yc.YES,this.mapIdentifierAttribute=r):this.identifierMode=yc.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 jOe(n,this.name)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){pre(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=Av(r,o,l);mf(r,o,u)})}),zM(r,this.willChange),HM(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 gre(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;cu(s,o),n.newValue=s.reconcile(r.getChildNode(i),n.newValue,r,i),a.processIdentifier(i,n.newValue)}break;case"add":cu(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===yc.YES&&r instanceof Ta){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:gf(n.name),value:n.newValue.snapshot,oldValue:n.oldValue?n.oldValue.snapshot:void 0},r);case"add":return void r.emitPatch({op:"add",path:gf(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:gf(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){cu(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 ap(n)?dw(Object.keys(n).map(function(a){return i._subType.validate(n[a],KM(r,a,i._subType))})):Oa(r,n,"Value is not a plain object")}}),Object.defineProperty(t.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return $p}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){n.storedValue.delete(r)}}),t})(Bp);sS.prototype.applySnapshot=Jr(sS.prototype.applySnapshot);function FOe(e){return new sS("Map<string, ".concat(e.name,">"),e)}var oS=(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 YM(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=ya(ya({},fw),{name:this.name});return fr.array(Fre(n),r)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){ul(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=Av(r,o,l);mf(r,o,u)})}),zM(r,this.willChange),HM(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=Bz(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=Bz(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){cu(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 Bre(n)?dw(n.map(function(a,s){return i._subType.validate(a,KM(r,""+s,i._subType))})):Oa(r,n,"Value is not an array")}}),Object.defineProperty(t.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Up}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){n.storedValue.splice(Number(r),1)}}),t})(Bp);oS.prototype.applySnapshot=Jr(oS.prototype.applySnapshot);function BOe(e){return new oS("".concat(e.name,"[]"),e)}function Bz(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(pOe(u)&&(u=u.storedValue),!l&&!o)break;if(!o)a=!1,n.splice(s,1),l instanceof Ta&&l.createObservableInstanceIfNeeded(),l.die(),s--;else if(l)if(Uz(l,u))n[s]=_k(t,e,f,u,l);else{for(var p=void 0,m=s;m<n.length;m++)if(Uz(n[m],u)){p=n.splice(m,1)[0];break}a=!1;var d=_k(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=_k(t,e,f,u);n.splice(s,0,d)}}return a?null:n}function _k(e,t,n,r,i){cu(e,r);function a(){if(Sr(r)){var o=On(r);if(o.assertAlive($p),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 Ta&&i.createObservableInstanceIfNeeded(),i.die()),s}function Uz(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 Ta))return!1;var r=e.getReconciliationType();return e.identifier!==null&&e.identifierAttribute&&ap(t)&&r.is(t)&&r.isMatchingSnapshotId(e,t)}var $z="preProcessSnapshot",zz="postProcessSnapshot";function UOe(){return On(this).toString()}var Hz={name:"AnonymousModel",properties:{},initializers:Up};function $Oe(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 Qr)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(kv(s))r[i]=bf(KOe(s),s);else if(s instanceof sS)r[i]=bf(s,{});else if(s instanceof oS)r[i]=bf(s,[]);else if(!Eu(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},ya({},e))}var Ov=(function(e){tr(t,e);function t(n){var r=e.call(this,n.name||Hz.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,Hz,n),r.properties=$Oe(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(!ap(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===$z)throw new St("Cannot define action '".concat($z,"', it should be defined using 'type.preProcessSnapshot(fn)' instead"));if(a===zz)throw new St("Cannot define action '".concat(zz,"', it should be defined using 'type.postProcessSnapshot(fn)' instead"));var s=r[a],o=n[a];if(a in Qr&&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=Av(n,a,f);r[a]=d,mf(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(!ap(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"));bre(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=Yke(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(!ap(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)vre(n,a,o),_re(n,(s={},s[a]=Lm,s));else if(typeof o.value=="function")mf(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 YM(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=ya(ya({},fw),{name:this.name});return fr.object(n,$p,r)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){mf(r,"toString",UOe),this.forAllProps(function(i){pre(r,i,n.unbox)}),this.initializers.reduce(function(i,a){return a(i)},r),zM(r,this.willChange),HM(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&&(cu(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:gf(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=ul(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=Fp(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){cu(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 ap(a)?dw(this.propertyNames.map(function(s){return i.properties[s].validate(a[s],KM(r,s,i.properties[s]))})):Oa(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 $p}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){n.storedValue[r]=void 0}}),t})(Bp);Ov.prototype.applySnapshot=Jr(Ov.prototype.applySnapshot);function zOe(){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 Ov({name:n,properties:r})}function HOe(){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 WOe(e){return Eu(e)&&(e.flags&_n.Object)>0}var Nu=(function(e){tr(t,e);function t(n,r,i,a){a===void 0&&(a=vOe);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 sd(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(kv(n)&&this.checker(n))return Ca();var i=this.name==="Date"?"Date or a unix milliseconds timestamp":this.name;return Oa(r,n,"Value is not a ".concat(i))}}),t})(Kf),Gre=new Nu("string",_n.String,function(e){return typeof e=="string"}),qre=new Nu("number",_n.Number,function(e){return typeof e=="number"}),VOe=new Nu("integer",_n.Integer,function(e){return yOe(e)}),GOe=new Nu("float",_n.Float,function(e){return _Oe(e)}),qOe=new Nu("finite",_n.Finite,function(e){return EOe(e)}),Kre=new Nu("boolean",_n.Boolean,function(e){return typeof e=="boolean"}),Yre=new Nu("null",_n.Null,function(e){return e===null}),Xre=new Nu("undefined",_n.Undefined,function(e){return e===void 0}),Zre=new Nu("Date",_n.Date,function(e){return typeof e=="number"||e instanceof Date},function(e){return e instanceof Date?e:new Date(e)});Zre.getSnapshot=function(e){return e.storedValue.getTime()};var Qre=Zre;function KOe(e){switch(typeof e){case"string":return Gre;case"number":return qre;case"boolean":return Kre;case"object":if(e instanceof Date)return Qre}throw new St("Cannot determine primitive type from value "+e)}function YOe(e){return Eu(e)&&(e.flags&(_n.String|_n.Number|_n.Integer|_n.Boolean|_n.Date))>0}var XOe=(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 sd(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 kv(n)&&n===this.value?Ca():Oa(r,n,"Value is not a literal ".concat(JSON.stringify(this.value)))}}),t})(Kf);function Jre(e){return new XOe(e)}var ZOe=(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)?Ca():Oa(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})(_u);function QOe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=typeof e[0]=="string"?e.shift():Eu(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 ZOe(n,r,i,a)}function JOe(e,t){var n=typeof e=="string"?t:e,r=hw.apply(void 0,yu([],vu(n.map(function(i){return Jre(""+i)})),!1));return typeof e=="string"&&(r.name=e),r}var e2e=(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=ya({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 Ca();a++}else i.push(l)}return a===1?Ca():Oa(r,n,"No type is applicable for the union").concat(dw(i))}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._types}}),t})(_u);function hw(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=Eu(e)?void 0:e,i=Eu(e)?yu([e],vu(t),!1):t,a="("+i.map(function(s){return s.name}).join(" | ")+")";return new e2e(a,i,r)}function t2e(e){return Eu(e)&&(e.flags&_n.Union)>0}var n2e=(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"&&cu(this,n),n}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return this.optionalValues.indexOf(n)>=0?Ca():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})(_u);function r2e(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 bf(e,t,n){return r2e(e,t),new n2e(e,t,n||i2e)}var i2e=[void 0],a2e=bf(Xre,void 0),s2e=bf(Yre,null);function eie(e){return hw(e,a2e)}function o2e(e){return hw(e,s2e)}var l2e=(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):Ca()}}),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||Ire}}),t})(_u);function u2e(e,t){var n=typeof e=="string"?e:"late(".concat(e.toString(),")"),r=typeof e=="string"?t:e;return new l2e(n,r)}function c2e(e,t){return new d2e(e,t)}var d2e=(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()}),wz(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(Jr(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=sd(this,n,r,i,a);return this.pendingNodeList.push(o),wz(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):zre(n)?Ca():Oa(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})(Kf),tie=(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 sd(this,n,r,i,a)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return zre(n)?this.subType?this.subType.validate(n,r):Ca():Oa(r,n,"Value is not serializable and cannot be frozen")}}),t})(Kf),Wz=new tie;function f2e(e){return arguments.length===0?Wz:Eu(e)?new tie(e):bf(Wz,e)}function h2e(e){switch(e){case Qr.beforeDestroy:return"destroy";case Qr.beforeDetach:return"detach";default:return}}var p2e=(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}),XM(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=t0(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 m2e("[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})(),m2e=(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),nie=(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 XM(n)?Ca():Oa(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){Tv(r.root.storedValue,{op:"replace",value:l,path:r.path})},removeRef:function(){WOe(s.type)?this.replaceRef(void 0):Tv(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=h2e(d);p&&i.fireInvalidated(p,n,r,s)},l=s.registerHook(Qr.beforeDetach,o),u=s.registerHook(Qr.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(Qr.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,t0(r)),d?s=a.addTargetNodeWatcher(n,r):l||a.fireInvalidated("invalidSnapshotReference",n,r,null)}};n.state===Si.FINALIZED?o(!0):(n.isRoot||n.root.registerHook(Qr.afterCreationFinalization,function(){n.parent&&n.parent.createObservableInstanceIfNeeded()}),n.registerHook(Qr.afterAttach,function(){o(!1)}))}}}),t})(Kf),g2e=(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)?Jke(a):a,o=new p2e(a,this.targetType),l=sd(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})(nie),b2e=(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=sd(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})(nie);function rie(e,t){var n=t||void 0,r=t?t.onInvalidated:void 0;return n&&(n.get||n.set)?new b2e(e,{get:n.get,set:n.set},r):new g2e(e,r)}function v2e(e,t){var n=rie(e,ya(ya({},t),{onInvalidated:function(r){t&&t.onInvalidated&&t.onInvalidated(r),r.removeRef()}}));return t&&t.acceptsUndefined===!1?n:eie(n)}var iie=(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 Ov))throw new St("Identifier types can only be instantiated as direct child of a model type");return sd(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?Oa(r,n,"Value is not a valid ".concat(this.describe(),", expected a ").concat(this.validType)):Ca()}}),t})(Kf),y2e=(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})(iie),_2e=(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})(iie),E2e=new y2e,S2e=new _2e;function t0(e){return""+e}function XM(e){return typeof e=="string"||typeof e=="number"}function x2e(e){return new w2e(e)}var w2e=(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 Ca();var i=this.options.getValidationMessage(n);return i?Oa(r,n,"Invalid value for type '".concat(this.name,"': ").concat(i)):Ca()}}),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 sd(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})(Kf),At={enumeration:JOe,model:zOe,compose:HOe,custom:x2e,reference:rie,safeReference:v2e,union:hw,optional:bf,literal:Jre,maybe:eie,maybeNull:o2e,refinement:QOe,string:Gre,boolean:Kre,number:qre,integer:VOe,float:GOe,finite:qOe,Date:Qre,map:FOe,array:BOe,frozen:f2e,identifier:E2e,identifierNumber:S2e,late:u2e,lazy:c2e,undefined:Xre,null:Yre,snapshotProcessor:MOe};const T2e=At.enumeration("TerminalStatus",["running","exited","error"]),C2e=At.model("Terminal",{id:At.identifier,name:At.string,cwd:At.string,status:T2e,exitCode:At.maybe(At.number),cols:At.number,rows:At.number,createdAt:At.number,tabId:At.maybeNull(At.string),positionInTab:At.optional(At.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}})),A2e=At.model("Tab",{id:At.identifier,name:At.string,position:At.number,directory:At.maybeNull(At.string),createdAt:At.number}).volatile(()=>({isPending:!1})).views(e=>({get terminals(){const t=Ore(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}})),k2e=At.map(At.string),O2e=At.model("ViewState",{focusedTerminals:At.optional(k2e,{}),currentView:At.maybeNull(At.string),currentTaskId:At.maybeNull(At.string),isTabVisible:At.maybeNull(At.boolean),viewUpdatedAt:At.maybeNull(At.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 hD(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}function Vz(){return`temp-${hD()}`}const R2e=At.model("TerminalsStore",{items:At.array(C2e)}).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)){kt.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(),aS(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()}})),N2e=At.model("TabsStore",{items:At.array(A2e)}).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)){kt.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&&aS(n)},replaceAll(t){e.items.clear();for(const n of t)e.items.push(n)},clear(){e.items.clear()}})),I2e=At.model("RootStore",{terminals:At.optional(R2e,{items:[]}),tabs:At.optional(N2e,{items:[]}),viewState:At.optional(O2e,{})}).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=()=>eOe(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=hD(),i=Vz(),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=Mz(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){const a=hD(),s=Vz(),o=r??e.tabs.items.length,l={id:s,name:n,position:o,directory:i??null,createdAt:Date.now()},u=Mz(e.tabs);e.tabs.add(l),u.stop(),e.tabs.get(s)?.setPending(!0),e.pendingTabCreation=s,e.pendingUpdates.set(a,{entityType:"tab",tempId:s,inversePatches:u.inversePatches,createdAt:Date.now()}),t().send({type:"tab:create",payload:{name:n,position:r,directory:i,requestId:a,tempId:s}}),t().log.ws.debug("createTab optimistic",{requestId:a,tempId:s,name:n})},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 y=f.isStartingUp,S=e.terminals.items.findIndex(v=>v.id===l);S>=0&&aS(e.terminals.items[S]),e.terminals.add(a);const g=e.terminals.get(a.id);y&&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 _=e.terminalsPendingStartup.get(l);_&&(e.terminalsPendingStartup.delete(l),e.terminalsPendingStartup.set(a.id,_),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:!!_})}else{const y=e.terminals.items.findIndex(g=>g.id===l);y>=0&&aS(e.terminals.items[y]),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}=i;if(s&&o){const l=e.pendingUpdates.get(s);if(l&&l.tempId===o){e.pendingUpdates.delete(s),e.tabs.get(o)&&(e.tabs.remove(o),e.tabs.add(a),e.pendingTabCreation=null,e.lastCreatedTabId=a.id,t().log.ws.debug("tab:created confirmed",{requestId:s,tempId:o,realId:a.id}));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--)Tv(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}}kt.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 aie(){const e=Mm();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 Cte(l);e.writeToTerminal(r,u)}catch(u){kt.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 Ek="",D2e=At.model("File",{path:At.identifier,content:At.string,originalContent:At.string,mimeType:At.string,size:At.number,lineCount:At.number,truncated:At.boolean,isMarkdownView:At.optional(At.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}})),L2e=At.model("FilesStore",{selectedFile:At.maybeNull(At.string),expandedDirs:At.array(At.string),openFiles:At.map(D2e)}).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:vk(function*(){if(e.worktreePath){e._setLoadingTree(!0),e._setTreeError(null);try{const t=yield $t(`${Ek}/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:vk(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 $t(`${Ek}/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:vk(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(`${Ek}/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 P2e(){return L2e.create({selectedFile:null,expandedDirs:[],openFiles:{}})}const sie=k.createContext(null);function M2e(e,t=!1,n){const r=k.useMemo(()=>P2e(),[]),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 j2e(){const e=k.useContext(sie);if(!e)throw new Error("useFilesStore must be used within a FilesStoreProvider");return e}function oie(){const e=j2e();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 lie=k.createContext(null);function Mm(){const e=k.useContext(lie);if(!e)throw new Error("useStore must be used within a StoreProvider");return e}function F2e(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/terminal`}function B2e({children:e,wsUrl:t=F2e(),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?(kt.ws.debug("send",{type:d.type}),i.current.send(JSON.stringify(d))):kt.ws.warn("send dropped (WebSocket not open)",{type:d.type,readyState:i.current?.readyState??"no socket"})},[]);if(!o.current){const d={send:u,log:kt};o.current=I2e.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 y=new WebSocket(t);i.current=y,y.onopen=()=>{d&&(kt.ws.info("WebSocket connected"),f.setConnected(!0),a.current=0)},y.onmessage=S=>{if(d)try{const g=JSON.parse(S.data);f.handleMessage(g)}catch(g){kt.ws.error("Failed to parse WebSocket message",{error:String(g)})}},y.onclose=()=>{if(d)if(kt.ws.info("WebSocket disconnected"),f.setConnected(!1),i.current===y&&(i.current=null),a.current<r){a.current++,f.setReconnectAttempt(a.current);const S=n*Math.pow(1.5,a.current-1);kt.ws.info("Scheduling reconnect",{attempt:a.current,delay:S}),s.current=setTimeout(p,S)}else kt.ws.warn("Max reconnect attempts reached"),f.setReconnectAttempt(a.current)},y.onerror=S=>{kt.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(lie.Provider,{value:f,children:e})}function uie(){const e=Mm(),{setTheme:t,resolvedTheme:n,theme:r}=qc(),{data:i}=Jxe(),a=k.useRef(void 0),s=k.useRef(!1),o=k.useRef(!1);k.useEffect(()=>$M(()=>e.broadcastedTheme,f=>{f&&(o.current=!0,t(f),e.clearBroadcastedTheme(),setTimeout(()=>{o.current=!1},0))},{fireImmediately:!0}),[e,t]),k.useEffect(()=>{if(!n)return;const u=n==="dark"?"/logo-dark.jpg":"/logo-light.jpg";let f=document.querySelector('link[rel="icon"]');f||(f=document.createElement("link"),f.rel="icon",document.head.appendChild(f)),f.type="image/jpeg",f.href=u},[n]),k.useEffect(()=>{const u=s.current&&i&&a.current===!1;a.current=i,s.current=!0,n&&u&&$t("/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;$t("/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 Sk=!1;const Gz={activeTabId:null,focusedTerminals:{},currentView:null,currentTaskId:null,isTabVisible:null,viewUpdatedAt:null};function cie(){const e=wr(),t=k.useRef(void 0),n=k.useRef({}),{data:r=Gz,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=zn({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 y=n.current;e.setQueryData(["terminal-view-state"],S=>{const g=S??Gz;return{activeTabId:y.activeTabId!==void 0?y.activeTabId:g.activeTabId,focusedTerminals:{...g.focusedTerminals,...y.focusedTerminals},currentView:y.currentView!==void 0?y.currentView:g.currentView,currentTaskId:y.currentTaskId!==void 0?y.currentTaskId:g.currentTaskId,isTabVisible:y.isTabVisible!==void 0?y.isTabVisible:g.isTabVisible,viewUpdatedAt:y.viewUpdatedAt!==void 0?y.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 y=e.getQueryData(["terminal-view-state"]);if(y){const{[p]:S,...g}=y.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(Sk){f.current=!1;return}Sk=!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&&(Sk=!1)}},[o]);const d=k.useCallback((p,m,y)=>{o({currentView:p,currentTaskId:m,activeTabId:y,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 U2e(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 $2e(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 z2e({open:e,onOpenChange:t,onNewTask:n,onShowShortcuts:r}){const{t:i}=tn("navigation"),[a,s]=k.useState(!1),o=e??a,l=t??s,[u,f]=k.useState(""),[d,p]=k.useState(0),m=k.useRef(null),y=k.useRef(null),S=Wi(),g=k.useMemo(()=>[{id:"goto-tasks",label:i("commandPalette.commands.goToTasks"),shortcut:"meta+1",keywords:["kanban","board","home"],category:"navigation",icon:b.jsx(fe,{icon:Dp,size:16,strokeWidth:2}),action:()=>{S({to:"/tasks"}),l(!1)}},{id:"goto-terminals",label:i("commandPalette.commands.goToTerminals"),shortcut:"meta+2",keywords:["shell","console","cli"],category:"navigation",icon:b.jsx(fe,{icon:x1e,size:16,strokeWidth:2}),action:()=>{S({to:"/terminals"}),l(!1)}},{id:"goto-task-terminals",label:i("commandPalette.commands.goToTaskTerminals"),shortcut:"meta+i",keywords:["tasks","shell","console","cli"],category:"navigation",icon:b.jsx(fe,{icon:Dp,size:16,strokeWidth:2}),action:()=>{S({to:"/terminals",search:{tab:"all-tasks"}}),l(!1)}},{id:"goto-worktrees",label:i("commandPalette.commands.goToWorktrees"),shortcut:"meta+3",keywords:["git","branches"],category:"navigation",icon:b.jsx(fe,{icon:R1e,size:16,strokeWidth:2}),action:()=>{S({to:"/worktrees"}),l(!1)}},{id:"goto-repositories",label:i("commandPalette.commands.goToRepositories"),shortcut:"meta+4",keywords:["repos","git","projects"],category:"navigation",icon:b.jsx(fe,{icon:T1e,size:16,strokeWidth:2}),action:()=>{S({to:"/repositories"}),l(!1)}},{id:"goto-settings",label:i("commandPalette.commands.goToSettings"),shortcut:"meta+,",keywords:["preferences","config","configuration"],category:"navigation",icon:b.jsx(fe,{icon:cte,size:16,strokeWidth:2}),action:()=>{S({to:"/settings"}),l(!1)}},{id:"new-task",label:i("commandPalette.commands.newTask"),shortcut:"meta+j",keywords:["create","add"],category:"actions",icon:b.jsx(fe,{icon:Ev,size:16,strokeWidth:2}),action:()=>{l(!1),n?.()}},{id:"show-shortcuts",label:i("commandPalette.commands.keyboardShortcuts"),shortcut:"meta+/",keywords:["help","hotkeys","keys"],category:"actions",icon:b.jsx(fe,{icon:ste,size:16,strokeWidth:2}),action:()=>{l(!1),r?.()}}],[S,n,r,l,i]),_=k.useMemo(()=>U2e(g,u),[g,u]),v=k.useMemo(()=>$2e(_),[_]),x=k.useMemo(()=>{const C=[],R=["navigation","actions"];for(const O of R){const N=v.get(O);N&&C.push(...N)}return C},[v]);k.useEffect(()=>{p(0)},[u]),k.useEffect(()=>{if(!y.current)return;const C=y.current.querySelector('[data-selected="true"]');C&&C.scrollIntoView({block:"nearest"})},[d]),Es("meta+k",()=>l(!0),{allowInInput:!0,allowInTerminal:!0}),Es("meta+1",()=>S({to:"/tasks"}),{allowInInput:!0,allowInTerminal:!0}),Es("meta+2",()=>S({to:"/terminals"}),{allowInInput:!0,allowInTerminal:!0}),Es("meta+i",()=>{S({to:"/terminals",search:{tab:"all-tasks"}})},{allowInInput:!0,allowInTerminal:!0}),Es("meta+3",()=>S({to:"/worktrees"}),{allowInInput:!0,allowInTerminal:!0}),Es("meta+4",()=>S({to:"/repositories"}),{allowInInput:!0,allowInTerminal:!0}),Es("meta+,",()=>S({to:"/settings"}),{allowInInput:!0,allowInTerminal:!0}),Es("meta+j",()=>{n?.()},{allowInInput:!1,deps:[n]}),Es("meta+/",()=>{r?.()},{allowInInput:!0,allowInTerminal:!0,deps:[r]});const T=k.useCallback(C=>{switch(C.key){case"ArrowDown":C.preventDefault(),p(R=>Math.min(R+1,x.length-1));break;case"ArrowUp":C.preventDefault(),p(R=>Math.max(R-1,0));break;case"Enter":C.preventDefault(),x[d]&&x[d].action();break;case"Escape":C.preventDefault(),l(!1);break}},[x,d,l]);k.useEffect(()=>{o&&(f(""),p(0),setTimeout(()=>m.current?.focus(),50))},[o]);let w=0;return b.jsx(ku,{open:o,onOpenChange:l,children:b.jsxs(Ou,{className:"sm:max-w-lg p-0 gap-0 overflow-hidden",showCloseButton:!1,onKeyDown:T,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(vn,{ref:m,value:u,onChange:C=>f(C.target.value),placeholder:i("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:y,className:"max-h-80 overflow-y-auto p-2",children:_.length===0?b.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:i("commandPalette.noResults")}):b.jsx(b.Fragment,{children:["navigation","actions"].map(C=>{const R=v.get(C);return!R||R.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:i(`commandPalette.categories.${C}`)}),R.map(O=>{const N=w++,L=N===d;return b.jsxs("button",{"data-selected":L,onClick:()=>O.action(),onMouseEnter:()=>p(N),className:Ue("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:[O.icon&&b.jsx("span",{className:"text-muted-foreground",children:O.icon}),b.jsx("span",{className:"flex-1 text-left",children:O.label}),O.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:pte(O.shortcut)})]},O.id)})]},C)})})})]})})}const qz={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 H2e({className:e,rows:t=100,cols:n=10,tileClassName:r,tileSize:i="md"}){return b.jsx("div",{className:Ue("relative z-0 flex w-full h-full justify-center",e),children:Array.from({length:t}).map((a,s)=>b.jsx("div",{className:Ue(qz[i],"border-l dark:border-neutral-900 border-neutral-200 relative",r),children:Array.from({length:n}).map((o,l)=>b.jsx("div",{className:Ue(qz[i],"border-r border-t dark:border-neutral-900 border-neutral-200 relative hover:bg-tile transition-colors",r)},`col-${l}`))},`row-${s}`))})}const W2e=["/","/tasks","/terminals","/worktrees","/repositories","/review","/monitoring","/settings"];function V2e(){const e=ti({select:n=>n.location.pathname});return W2e.some(n=>e===n||e.startsWith(n+"/"))?b.jsx("div",{className:"absolute inset-0 overflow-hidden pointer-events-none -z-10",children:b.jsx(H2e,{rows:100,cols:50,tileSize:"sm"})}):null}if(!k.useState)throw new Error("mobx-react-lite requires React with Hooks support");if(!_re)throw new Error("mobx-react-lite@3 requires mobx at least version 6 to be available");function G2e(e){e()}function q2e(e){e||(e=G2e),bke({reactionScheduler:e})}function K2e(e){return yke(e)}var Y2e=1e4,X2e=1e4,Z2e=(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=Y2e),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,X2e))}}),e})(),Q2e=typeof FinalizationRegistry<"u"?FinalizationRegistry:Z2e,pD=new Q2e(function(e){var t;(t=e.reaction)===null||t===void 0||t.dispose(),e.reaction=null});function Kz(e){e.reaction=new ll("observer".concat(e.name),function(){var t;e.stateVersion=Symbol(),(t=e.onStoreChange)===null||t===void 0||t.call(e)})}function J2e(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 pD.unregister(r),r.onStoreChange=o,r.reaction||(Kz(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||(Kz(i),pD.register(n,i,i)),oe.useDebugValue(i.reaction,K2e),OP.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 xk,wk,die=typeof Symbol=="function"&&Symbol.for,eRe=(wk=(xk=Object.getOwnPropertyDescriptor(function(){},"name"))===null||xk===void 0?void 0:xk.configurable)!==null&&wk!==void 0?wk:!1,Yz=die?Symbol.for("react.forward_ref"):typeof k.forwardRef=="function"&&k.forwardRef(function(e){return null}).$$typeof,Xz=die?Symbol.for("react.memo"):typeof k.memo=="function"&&k.memo(function(e){return null}).$$typeof;function n0(e,t){var n;if(Xz&&e.$$typeof===Xz)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(Yz&&e.$$typeof===Yz&&(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 J2e(function(){return i(o,l)},a)};return s.displayName=e.displayName,eRe&&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),nRe(e,s),s}var tRe={$$typeof:!0,render:!0,compare:!0,type:!0,displayName:!0};function nRe(e,t){Object.keys(e).forEach(function(n){tRe[n]||Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})}var Tk;q2e(xr.unstable_batchedUpdates);Tk=pD.finalizeAllImmediately;const rRe=n0(function(){const t=Mm();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:Ue("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:ts,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:en,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:ts,size:16,strokeWidth:2}),b.jsx("span",{children:"Disconnected from server"})]})})});function iRe(){return qn({queryKey:["system","dependencies"],queryFn:()=>$t("/api/system/dependencies"),staleTime:30*1e3,refetchOnWindowFocus:!0})}const Zz="npm install -g @anthropic/claude-code",aRe="https://docs.anthropic.com/en/docs/claude-code/overview";function sRe(){const{data:e,isLoading:t}=iRe(),[n,r]=k.useState(!1),[i,a]=k.useState(!1),s=k.useCallback(async()=>{try{await navigator.clipboard.writeText(Zz),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[]),o=k.useCallback(()=>{r(!0)},[]);return t||n||e?.claudeCode?.installed?null:b.jsxs("div",{className:Ue("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:ts,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:Zz}),b.jsx("button",{onClick:s,className:Ue("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?hl:w1e,size:14,strokeWidth:2})})]})]})]}),b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx("a",{href:aRe,target:"_blank",rel:"noopener noreferrer",className:Ue("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:Ue("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:ci,size:16,strokeWidth:2})})]})]})}const oRe=[{titleKey:"navigation",items:[{labelKey:"goToTasks",shortcut:"meta+1"},{labelKey:"goToTerminals",shortcut:"meta+2"},{labelKey:"goToTaskTerminals",shortcut:"meta+i"},{labelKey:"goToWorktrees",shortcut:"meta+3"},{labelKey:"goToRepositories",shortcut:"meta+4"},{labelKey:"goToSettings",shortcut:"meta+,"}]},{titleKey:"actions",items:[{labelKey:"commandPalette",shortcut:"meta+k"},{labelKey:"newTask",shortcut:"meta+j"},{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 lRe({open:e,onOpenChange:t}){const{t:n}=tn("navigation");return b.jsx(ku,{open:e,onOpenChange:t,children:b.jsxs(Ou,{className:"sm:max-w-md",children:[b.jsx(Jc,{children:b.jsx(ed,{children:n("shortcuts.title")})}),b.jsx("div",{className:"space-y-4 mt-2",children:oRe.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:pte(i.shortcut)})]},i.shortcut))})]},r.titleKey))})]})})}const uRe=({...e})=>{const{resolvedTheme:t}=qc();return b.jsx(w_e,{theme:t,className:"toaster group",icons:{success:b.jsx(fe,{icon:nte,strokeWidth:2,className:"size-4"}),info:b.jsx(fe,{icon:L1e,strokeWidth:2,className:"size-4"}),warning:b.jsx(fe,{icon:ts,strokeWidth:2,className:"size-4"}),error:b.jsx(fe,{icon:B1e,strokeWidth:2,className:"size-4"}),loading:b.jsx(fe,{icon:en,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})},Oo=Kpe({component:mRe});function cRe(){return Ewe(),null}function dRe(){return Rne(),null}function fRe(){return uie(),null}function hRe(){const e=ti({select:n=>n.location}),{updateViewTracking:t}=cie();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 pRe(){const e=ti({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 mRe(){const[e,t]=k.useState(null),[n,r]=k.useState(!1),[i,a]=k.useState(!1),s=k.useCallback(f=>{t(()=>f)},[]),o=k.useCallback(()=>{e?.()},[e]),l=k.useCallback(()=>{r(!0)},[]),u=k.useCallback(()=>{a(!0)},[]);return b.jsx(k_e,{children:b.jsxs("div",{className:"flex h-screen flex-col overflow-x-hidden bg-background text-foreground",children:[b.jsx(cRe,{}),b.jsx(dRe,{}),b.jsx(fRe,{}),b.jsx(hRe,{}),b.jsx(pRe,{}),b.jsx(rRe,{}),b.jsx(sRe,{}),b.jsx(bwe,{onNewTaskRef:s,onOpenCommandPalette:u}),b.jsxs("main",{className:"isolate flex-1 overflow-hidden relative",children:[b.jsx(V2e,{}),b.jsx(tJ,{})]}),b.jsx(z2e,{open:i,onOpenChange:a,onNewTask:o,onShowShortcuts:l}),b.jsx(lRe,{open:n,onOpenChange:r}),b.jsx(uRe,{position:"bottom-right"})]})})}const gRe=Ms("/")({beforeLoad:()=>{throw BQ({to:"/tasks"})}}),mD="";function fie(){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(`${mD}/api/worktrees/json`);if(!g.ok)throw new Error("Failed to fetch worktrees");const _=await g.json();t(new Map(_.worktrees.map(v=>[v.path,{...v,size:v.size||0,sizeFormatted:v.sizeFormatted||"0 B",branch:v.branch||"unknown"}]))),r(_.summary),a(!1),o(!1)}catch(g){u(g instanceof Error?g:new Error("Failed to load worktrees")),a(!1),o(!1)}},[]),y=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(`${mD}/api/worktrees`);f.current=g,g.addEventListener("worktree:basic",_=>{const v=JSON.parse(_.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",_=>{const v=JSON.parse(_.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",_=>{const v=JSON.parse(_.data);r(v),o(!1),g.close()}),g.addEventListener("worktree:error",_=>{const{path:v}=JSON.parse(_.data);kt.viewer.error("Error loading worktree details",{path:v}),d.current--,d.current<=0&&o(!1)}),g.onerror=()=>{g.close(),kt.viewer.info("SSE connection failed, trying JSON fallback"),p.current=!0,m()}},[m]);return k.useEffect(()=>(y(),()=>{f.current?.close()}),[y]),{worktrees:k.useMemo(()=>Array.from(e.values()).sort((_,v)=>_.isOrphaned!==v.isOrphaned?_.isOrphaned?-1:1:new Date(v.lastModified).getTime()-new Date(_.lastModified).getTime()),[e]),summary:n,isLoading:i,isLoadingDetails:s,error:l,refetch:y}}function hie(){const e=wr();return zn({mutationFn:({worktreePath:t,repoPath:n,deleteLinkedTask:r})=>$t(`${mD}/api/worktrees`,{method:"DELETE",body:JSON.stringify({worktreePath:t,repoPath:n,deleteLinkedTask:r})}),onSuccess:()=>{e.invalidateQueries({queryKey:["worktrees"]}),e.invalidateQueries({queryKey:["tasks"]})}})}const bRe=Yc("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 wxe({defaultTagName:"span",props:sl({className:Ue(bRe({className:e,variant:t}))},r),render:n,state:{slot:"badge",variant:t}})}function xa({className:e,size:t="default",...n}){return b.jsx("div",{"data-slot":"card","data-size":t,className:Ue("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 vRe({className:e,...t}){return b.jsx("div",{"data-slot":"card-header",className:Ue("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 yRe({className:e,...t}){return b.jsx("div",{"data-slot":"card-title",className:Ue("text-sm font-medium",e),...t})}function Df({className:e,...t}){return b.jsx("div",{"data-slot":"card-content",className:Ue("px-4 group-data-[size=sm]/card:px-3",e),...t})}function go({...e}){return b.jsx(BEe,{"data-slot":"alert-dialog",...e})}function bo({...e}){return b.jsx(wte,{"data-slot":"alert-dialog-trigger",...e})}function _Re({...e}){return b.jsx(_te,{"data-slot":"alert-dialog-portal",...e})}function ERe({className:e,...t}){return b.jsx(gte,{"data-slot":"alert-dialog-overlay",className:Ue("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 vo({className:e,size:t="default",...n}){return b.jsxs(_Re,{children:[b.jsx(ERe,{}),b.jsx(yte,{"data-slot":"alert-dialog-content","data-size":t,className:Ue("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 yo({className:e,...t}){return b.jsx("div",{"data-slot":"alert-dialog-header",className:Ue("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 _o({className:e,...t}){return b.jsx("div",{"data-slot":"alert-dialog-footer",className:Ue("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 Eo({className:e,...t}){return b.jsx(xte,{"data-slot":"alert-dialog-title",className:Ue("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 So({className:e,...t}){return b.jsx(bte,{"data-slot":"alert-dialog-description",className:Ue("text-muted-foreground *:[a]:hover:text-foreground text-xs/relaxed text-balance md:text-pretty *:[a]:underline *:[a]:underline-offset-3",e),...t})}function Rv({className:e,...t}){return b.jsx(Ke,{"data-slot":"alert-dialog-action",className:Ue(e),...t})}function xo({className:e,variant:t="outline",size:n="default",...r}){return b.jsx(qx,{"data-slot":"alert-dialog-cancel",className:Ue(e),render:b.jsx(Ke,{variant:t,size:n}),...r})}const Ti=k.forwardRef(({className:e,...t},n)=>b.jsx(pSe,{ref:n,className:Ue("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(mSe,{className:"flex items-center justify-center",children:b.jsx(fe,{icon:hl,size:12,strokeWidth:3})})}));Ti.displayName="Checkbox";const gD={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"},SRe=Ms("/worktrees/")({component:CRe});function xRe(){const{t:e}=tn("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 Qz({className:e}){return b.jsx("span",{className:`inline-block animate-pulse rounded bg-muted ${e}`})}function wRe({worktree:e,onDelete:t}){const{t:n}=tn("common"),{t:r}=tn("worktrees"),i=xRe(),[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)}},y=S=>{s(S),S||f(!1)};return b.jsx(xa,{className:"transition-colors hover:border-border/80",children:b.jsxs(Df,{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:Ue("shrink-0",gD.ORPHANED),children:n("statuses.ORPHANED")}):e.taskStatus?b.jsx(co,{className:Ue("shrink-0",gD[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:Hi,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:Vx,size:12,strokeWidth:2,className:"shrink-0"}),e.branch==="..."?b.jsx(Qz,{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:ate,size:12,strokeWidth:2,className:"shrink-0"}),e.sizeFormatted==="..."?b.jsx(Qz,{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:tte,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(wi,{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:$y,size:12,strokeWidth:2,className:"shrink-0"})]})})]})]}),b.jsxs(go,{open:a,onOpenChange:y,children:[b.jsx(bo,{render:b.jsx(Ke,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-muted-foreground hover:text-destructive",disabled:d}),children:b.jsx(fe,{icon:$c,size:14,strokeWidth:2})}),b.jsxs(vo,{children:[b.jsxs(yo,{children:[b.jsx(Eo,{children:r("delete.title")}),b.jsxs(So,{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(Ti,{checked:u,onCheckedChange:S=>f(S===!0),disabled:o}),r("delete.alsoDeleteLinkedTask",{title:e.taskTitle})]})]}),b.jsxs(_o,{children:[b.jsx(xo,{disabled:o,children:n("buttons.cancel")}),b.jsxs(Ke,{variant:"destructive",onClick:m,disabled:o,className:"gap-2",children:[o&&b.jsx(fe,{icon:en,size:14,strokeWidth:2,className:"animate-spin"}),n(o?"status.deleting":"buttons.delete")]})]})]})]})]})})}const TRe=["IN_PROGRESS","IN_REVIEW","DONE","CANCELED","ORPHANED"];function CRe(){const{t:e}=tn("common"),{t}=tn("worktrees"),{worktrees:n,summary:r,isLoading:i,isLoadingDetails:a,error:s,refetch:o}=fie(),l=hie(),[u,f]=k.useState(new Set),[d,p]=k.useState(!1),[m,y]=k.useState(!1),[S,g]=k.useState(!1),_=O=>{f(N=>{const L=new Set(N);return L.has(O)?L.delete(O):L.add(O),L})},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){y(!0);try{for(const O of T)await l.mutateAsync({worktreePath:O.path,repoPath:O.repoPath,deleteLinkedTask:S});p(!1),o()}catch{}finally{y(!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(bo,{render:b.jsx(Ke,{variant:"ghost",size:"sm",className:"gap-1.5 text-xs text-muted-foreground hover:text-destructive",disabled:a}),children:[b.jsx(fe,{icon:rte,size:12,strokeWidth:2}),t("cleanup.button",{count:T.length})]}),b.jsxs(vo,{children:[b.jsxs(yo,{children:[b.jsx(Eo,{children:t("cleanup.title")}),b.jsxs(So,{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(Ti,{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(_o,{children:[b.jsx(xo,{disabled:m,children:e("buttons.cancel")}),b.jsxs(Ke,{variant:"destructive",onClick:w,disabled:m,className:"gap-2",children:[m&&b.jsx(fe,{icon:en,size:14,strokeWidth:2,className:"animate-spin"}),m?e("status.deleting"):t("delete.button",{count:T.length})]})]})]})]}),u.size>0&&b.jsxs(Ke,{variant:"ghost",size:"sm",onClick:v,className:"gap-1.5 text-xs",children:[b.jsx(fe,{icon:ci,size:12,strokeWidth:2}),e("buttons.clearFilters")]})]})]}),b.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:TRe.map(O=>{const N=u.has(O);return b.jsx("button",{onClick:()=>_(O),className:Ue("rounded-full px-2.5 py-1 text-xs font-medium transition-colors",N?gD[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:en,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:ts,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(wRe,{worktree:O,onDelete:R},O.path))})]})]})}function Wn(e,t="Assertion error"){if(!e)throw Error(t)}function zp({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 bD(e,t){return t.sort(e==="horizontal"?ARe:kRe)}function ARe(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function kRe(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function pie(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 ORe({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}=pie(r,s),u=e==="horizontal"?o:l;u<a&&(a=u,i=s)}return Wn(i,"No rect found"),i}function mie(e){const{element:t,orientation:n,panels:r,separators:i}=e,a=bD(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 y;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:{y=[S,g];break}case 1:{const _=u[0],v=ORe({orientation:n,rects:[p,m],targetRect:_.element.getBoundingClientRect()});y=[_,v===p?g:S];break}default:{y=u;break}}}else u.length?y=u:y=[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 y)s.push({group:e,groupSize:zp({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 RRe(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function NRe(e,t){const n=getComputedStyle(e.ownerDocument.body),r=parseFloat(n.fontSize);return t*r}function IRe(e){return e/100*window.innerHeight}function DRe(e){return e/100*window.innerWidth}function LRe(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 E_({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,a]=LRe(n);switch(a){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=NRe(t,i);break}case"em":{r=RRe(t,i);break}case"vh":{r=IRe(i);break}case"vw":{r=DRe(i);break}}return r}function ao(e){return parseFloat(e.toFixed(3))}function Jz(e){const{panels:t}=e,n=zp({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=E_({groupSize:n,panelElement:i,styleProp:a.collapsedSize});s=ao(f/n*100)}let o;if(a.defaultSize){const f=E_({groupSize:n,panelElement:i,styleProp:a.defaultSize});o=ao(f/n*100)}let l=0;if(a.minSize){const f=E_({groupSize:n,panelElement:i,styleProp:a.minSize});l=ao(f/n*100)}let u=100;if(a.maxSize){const f=E_({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 PRe{#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 Qi(e,t,n=0){return Math.abs(ao(e)-ao(t))<=n}let ys={cursorFlags:0,interactionState:{state:"inactive"},mountedGroups:new Map};const vf=new PRe;function bl(){return ys}function Ds(e){const t=typeof e=="function"?e(ys):e;if(ys===t)return ys;const n=ys;return ys={...ys,...t},t.cursorFlags!==void 0&&vf.emit("cursorFlagsChange",ys.cursorFlags),t.interactionState!==void 0&&vf.emit("interactionStateChange",ys.interactionState),t.mountedGroups!==void 0&&(ys.mountedGroups.forEach((r,i)=>{r.derivedPanelConstraints.forEach(a=>{if(a.collapsible){const{layout:s}=n.mountedGroups.get(i)??{};if(s){const o=Qi(a.collapsedSize,r.layout[a.panelId]),l=Qi(a.collapsedSize,s[a.panelId]);o&&!l&&(i.inMemoryLastExpandedPanelSizes[a.panelId]=s[a.panelId])}}})}),vf.emit("mountedGroupsChange",ys.mountedGroups)),ys}const MRe=e=>e,Ck=()=>{},gie=1,bie=2,vie=4,yie=8,eH={coarse:10,precise:5};function jRe({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&gie)!==0,s=(e&bie)!==0,o=(e&vie)!==0,l=(e&yie)!==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 Ak,Fo;function ZM(){Fo===void 0&&(Fo=new CSSStyleSheet,document.adoptedStyleSheets=[Fo]);const{cursorFlags:e,interactionState:t}=bl();switch(t.state){case"active":case"hover":{const n=jRe({cursorFlags:e,groups:t.hitRegions.map(i=>i.group),state:t.state}),r=`*{cursor: ${n} !important; ${t.state==="active"?"touch-action: none;":""} }`;if(Ak===r)return;Ak=r,n?Fo.cssRules.length===0?Fo.insertRule(r):Fo.replaceSync(r):Fo.cssRules.length===1&&Fo.deleteRule(0);break}case"inactive":{Ak=void 0,Fo.cssRules.length===1&&Fo.deleteRule(0);break}}}function FRe(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 Nv(e,t){return Qi(e,t)?0:e>t?1:-1}function sp({panelConstraints:e,size:t}){const{collapsedSize:n=0,collapsible:r,maxSize:i=100,minSize:a=0}=e;if(Nv(t,a)<0)if(r){const s=(n+a)/2;Nv(t,s)<0?t=n:t=a}else t=a;return t=Math.min(i,t),t=ao(t),t}function Iv({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(Qi(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 y=e<0?f:u,S=n[y];Wn(S,`Panel constraints not found for index ${y}`);const{collapsedSize:g=0,collapsible:_,minSize:v=0}=S;if(_){const x=s[y];if(Wn(x!=null,`Previous layout not found for panel index ${y}`),Qi(x,g)){const T=v-x;Nv(T,Math.abs(e))>0&&(e=e<0?0-T:T)}}}{const y=e<0?u:f,S=n[y];Wn(S,`No panel constraints found for index ${y}`);const{collapsedSize:g=0,collapsible:_,minSize:v=0}=S;if(_){const x=s[y];if(Wn(x!=null,`Previous layout not found for panel index ${y}`),Qi(x,v)){const T=x-g;Nv(T,Math.abs(e))>0&&(e=e<0?0-T:T)}}}}{const y=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=sp({panelConstraints:n[S],size:100})-v;if(g+=x,S+=y,S<0||S>=n.length)break}const _=Math.min(Math.abs(e),Math.abs(g));e=e<0?0-_:_}{let y=e<0?u:f;for(;y>=0&&y<n.length;){const S=Math.abs(e)-Math.abs(d),g=s[y];Wn(g!=null,`Previous layout not found for panel index ${y}`);const _=g-S,v=sp({panelConstraints:n[y],size:_});if(!Qi(g,v)&&(d+=g-v,l[y]=v,d.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?y--:y++}}if(FRe(o,l))return i;{const y=e<0?f:u,S=s[y];Wn(S!=null,`Previous layout not found for panel index ${y}`);const g=S+d,_=sp({panelConstraints:n[y],size:g});if(l[y]=_,!Qi(_,g)){let v=g-_,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=sp({panelConstraints:n[x],size:w});if(Qi(T,C)||(v-=C-T,l[x]=C),Qi(v,0))break;e>0?x--:x++}}}const p=Object.values(l).reduce((y,S)=>S+y,0);if(!Qi(p,100,.1))return i;const m=Object.keys(i);return l.reduce((y,S,g)=>(y[m[g]]=S,y),{})}function jm(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||Nv(e[n],t[n])!==0)return!1;return!0}function _ie({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 y=n.get(l),{defaultLayoutDeferred:S,derivedPanelConstraints:g,layout:_,separatorToPanels:v}=r.get(l)??{defaultLayoutDeferred:!1};if(g&&y&&_&&v){const x=Iv({delta:m,initialLayout:y,panelConstraints:g,pivotIndices:o.panels.map(T=>p.indexOf(T)),prevLayout:_,trigger:"mouse-or-touch"});if(jm(x,_)){if(m!==0&&!f)switch(d){case"horizontal":{a|=m<0?gie:bie;break}case"vertical":{a|=m<0?vie:yie;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}}}),Ds({cursorFlags:a,mountedGroups:s}),ZM()}function tH(e){if(e.defaultPrevented||e.relatedTarget!==null||e.clientX===0&&e.clientY===0)return;const{interactionState:t,mountedGroups:n}=bl();t.state==="active"&&t.hitRegions.forEach(r=>{e.currentTarget===r.group.element&&_ie({event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n})})}function lE(e){const t=e.parentElement;Wn(t,"Parent group element not found");const{mountedGroups:n}=bl();for(const[r]of n)if(r.element===t)return r;throw Error("Could not find parent Group for separator element")}function Lf({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(!Qi(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=sp({panelConstraints:t[s],size:o});o!=l&&(i+=o-l,n[s]=l)}if(!Qi(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=sp({panelConstraints:t[s],size:l});if(o!==u&&(i-=u-o,n[s]=u,Qi(i,0)))break}const a=Object.keys(e);return n.reduce((s,o,l)=>(s[a[l]]=o,s),{})}function Eie({groupId:e}){const t=()=>{const{mountedGroups:n}=bl();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=Lf({layout:n,panelConstraints:i});return r?s:(jm(s,l)||Ds(u=>({mountedGroups:new Map(u.mountedGroups).set(a,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:l,separatorToPanels:o})})),l)}}}function Sie(e){const{mountedGroups:t}=bl(),n=t.get(e);return Wn(n,`Mounted Group ${e.id} not found`),n}function Pd(e,t){const n=lE(e),r=Sie(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=Eie({groupId:n.id}).getLayout(),l=Iv({delta:t,initialLayout:o,panelConstraints:r.derivedPanelConstraints,pivotIndices:s,prevLayout:o,trigger:"keyboard"}),u=Lf({layout:l,panelConstraints:r.derivedPanelConstraints});jm(o,u)||Ds(f=>({mountedGroups:new Map(f.mountedGroups).set(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,layout:u,separatorToPanels:r.separatorToPanels})}))}function nH(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=lE(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Pd(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Pd(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Pd(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Pd(t,-5);break}case"End":{e.preventDefault(),Pd(t,100);break}case"Enter":{e.preventDefault();const r=lE(t),{derivedPanelConstraints:i,layout:a,separatorToPanels:s}=Sie(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;Pd(t,p-d)}break}case"F6":{e.preventDefault();const r=lE(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(),Pd(t,-100);break}}}function BRe(e,t,n){let r,i={x:1/0,y:1/0};for(const a of t){const s=pie(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 S_;function URe(){return S_===void 0&&(typeof matchMedia=="function"?S_=!!matchMedia("(pointer:coarse)").matches:S_=!1),S_}function $Re(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:aH(e),b:aH(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:iH(rH(n.a)),b:iH(rH(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 zRe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function HRe(e){const t=getComputedStyle(xie(e)??e).display;return t==="flex"||t==="inline-flex"}function WRe(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||HRe(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"||zRe.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function rH(e){let t=e.length;for(;t--;){const n=e[t];if(Wn(n,"Missing node"),WRe(n))return n}return null}function iH(e){return e&&Number(getComputedStyle(e).zIndex)||0}function aH(e){const t=[];for(;e;)t.push(e),e=xie(e);return t}function xie(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}function VRe(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 GRe({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!(n instanceof HTMLElement)||n.contains(e)||e.contains(n))return!0;if($Re(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(VRe(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function wie(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const a=URe()?eH.coarse:eH.precise,s=mie(i),o=BRe(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=a&&o.distance.y<=a&&GRe({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function sH(e){if(e.defaultPrevented)return;const{mountedGroups:t}=bl(),n=wie(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)}),Ds({interactionState:{hitRegions:n,initialLayoutMap:s,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}}),n.length&&e.preventDefault()}function oH(e){if(e.defaultPrevented)return;const{interactionState:t,mountedGroups:n}=bl();switch(t.state){case"active":{if(e.type!=="pointerleave"&&e.buttons===0){Ds(r=>r.interactionState.state==="inactive"?r:{cursorFlags:0,interactionState:{state:"inactive"}});return}_ie({event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint});break}default:{const r=wie(e,n);r.length===0?t.state!=="inactive"&&Ds({interactionState:{state:"inactive"}}):Ds({interactionState:{hitRegions:r,state:"hover"}}),ZM();break}}}function lH(e){if(e.defaultPrevented)return;e.preventDefault();const{interactionState:t}=bl();t.state==="active"&&(Ds({cursorFlags:0,interactionState:{state:"inactive"}}),ZM())}function uH(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 qRe(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=zp({group:e});i.onResize({asPercentage:ao(r.inlineSize/a*100),inPixels:r.inlineSize},i.id)}function KRe(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 YRe(e){let t=!0;const n=new Set,r=new Set,i=new ResizeObserver(m=>{for(const y of m){const{borderBoxSize:S,target:g}=y;if(g===e.element){if(t){if(zp({group:e})===0)return;Ds(_=>{const v=_.mountedGroups.get(e);if(v){const x=Jz(e),T=v.defaultLayoutDeferred?uH(x):v.layout,w=Lf({layout:T,panelConstraints:x});return!v.defaultLayoutDeferred&&jm(T,w)&&KRe(v.derivedPanelConstraints,x)?_:{mountedGroups:new Map(_.mountedGroups).set(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:x,layout:w,separatorToPanels:v.separatorToPanels})}}return _})}}else qRe(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=zp({group:e}),s=Jz(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??uH(s),f=Lf({layout:u,panelConstraints:s}),d=mie(e),p=Ds(m=>{const y=new Map;return d.forEach(S=>{S.separator&&y.set(S.separator,S.panels)}),{mountedGroups:new Map(m.mountedGroups).set(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:s,layout:f,separatorToPanels:y})}});return e.element.addEventListener("pointerleave",tH),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",nH)}),p.mountedGroups.size===1&&(window.addEventListener("pointerdown",sH),window.addEventListener("pointermove",oH),window.addEventListener("pointerup",lH)),function(){t=!1;const m=Ds(y=>{const S=new Map(y.mountedGroups);return S.delete(e),{mountedGroups:S}});e.element.removeEventListener("pointerleave",tH),e.separators.forEach(y=>{y.element.removeEventListener("keydown",nH)}),m.mountedGroups.size===0&&(window.removeEventListener("pointerdown",sH),window.removeEventListener("pointermove",oH),window.removeEventListener("pointerup",lH)),i.disconnect()}}function QM(e){const t=k.useId();return`${e??t}`}const Yf=typeof window<"u"?k.useLayoutEffect:k.useEffect;function JM(e){const t=k.useRef(e);return Yf(()=>{t.current=e},[e]),k.useCallback(n=>t.current?.(n),[t])}function e3(...e){return JM(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function XRe(e){const t=k.useRef({...e});return Yf(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const Tie="--react-resizable-panels--panel--pointer-events";function Cie(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 Aie=k.createContext(null);function ZRe(e,t){const n=k.useRef({getLayout:()=>({}),setLayout:MRe});k.useImperativeHandle(t,()=>n.current,[]),Yf(()=>{Object.assign(n.current,Eie({groupId:e}))})}function QRe({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=JM(W=>{jm(p.current,W)||(p.current=W,l?.(W))}),y=QM(o),[S,g]=k.useState(!1),[_,v]=k.useState(null),[x,T]=k.useState(n??{}),[w,C]=k.useState([]),[R,O]=k.useState([]),N=k.useRef({lastExpandedPanelSizes:{},layouts:{}}),L=e3(v,a);ZRe(y,s);const D=k.useMemo(()=>({id:y,orientation:u,registerPanel:W=>(C($=>bD(u,[...$,W])),()=>{C($=>$.filter(q=>q!==W))}),registerSeparator:W=>(O($=>bD(u,[...$,W])),()=>{O($=>$.filter(q=>q!==W))})}),[y,u]),z=XRe({defaultLayout:n,disableCursor:r}),M=k.useRef(null);Yf(()=>{if(_===null)return;const W={defaultLayout:z.defaultLayout,disableCursor:!!z.disableCursor,disabled:!!i,element:_,id:y,inMemoryLastExpandedPanelSizes:N.current.lastExpandedPanelSizes,inMemoryLayouts:N.current.layouts,orientation:u,panels:w,separators:R};M.current=W;const $=YRe(W),q=bl().mountedGroups.get(W);if(q){const{defaultLayoutDeferred:j,derivedPanelConstraints:U,layout:K}=q;!j&&U.length>0&&(T(K),m?.(K))}const Y=vf.addListener("interactionStateChange",j=>{j.state==="active"?g(j.hitRegions.some(U=>U.group===W)):g(!1)}),B=vf.addListener("mountedGroupsChange",j=>{const U=j.get(W);if(U){const{defaultLayoutDeferred:K,derivedPanelConstraints:H,layout:J}=U;if(K||H.length===0)return;T(J),m?.(J)}});return()=>{M.current=null,$(),Y(),B()}},[i,_,y,m,u,w,R,z]),k.useEffect(()=>{const W=M.current;W&&(W.defaultLayout=n,W.disableCursor=!!r)});const V={[Tie]:S?"none":void 0};for(const W in x){const $=Cie(y,W),q=x[W];V[$]=q}return b.jsx(Aie.Provider,{value:D,children:b.jsx("div",{...d,"aria-orientation":u,className:t,"data-group":!0,"data-testid":y,id:y,ref:L,style:{...f,...V,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap"},children:e})})}function t3(){const e=k.useContext(Aie);return Wn(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function JRe({groupId:e,panelId:t}){const n=()=>{const{mountedGroups:o}=bl();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(),y=d.panels.findIndex(v=>v.id===t),S=y===d.panels.length-1,g=Iv({delta:S?l-o:o-l,initialLayout:p,panelConstraints:f,pivotIndices:S?[y-1,y]:[y,y+1],prevLayout:p,trigger:"imperative-api"}),_=Lf({layout:g,panelConstraints:f});jm(p,_)||Ds(v=>({mountedGroups:new Map(v.mountedGroups).set(d,{defaultLayoutDeferred:u,derivedPanelConstraints:f,layout:_,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&&Qi(l,u)},resize:o=>{if(a()!==o){let l;switch(typeof o){case"number":{const{group:u}=n(),f=zp({group:u});l=ao(o/f*100);break}case"string":{l=parseFloat(o);break}}s(l)}}}}function eNe(e,t){const{id:n}=t3(),r=k.useRef({collapse:Ck,expand:Ck,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Ck});k.useImperativeHandle(t,()=>r.current,[]),Yf(()=>{Object.assign(r.current,JRe({groupId:n,panelId:e}))})}function tNe({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,y=QM(s),[S,g]=k.useState(null),_=e3(g,a),{id:v,registerPanel:x}=t3(),T=u!==null,w=JM(R=>{u?.(R,s)});Yf(()=>{if(S!==null)return x({element:S,id:y,idIsStable:m,onResize:T?w:void 0,panelConstraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:o,minSize:l}})},[n,r,i,S,T,y,m,o,l,w,x]),eNe(y,f);const C=Cie(v,y);return b.jsx("div",{...p,"data-panel":!0,"data-testid":y,id:y,ref:_,style:{...nNe,flexBasis:0,flexGrow:`var(${C}, 1)`,flexShrink:1,overflow:"hidden",pointerEvents:`var(${Tie})`},children:b.jsx("div",{className:t,style:{width:"100%",height:"100%",...d},children:e})})}const nNe={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 rNe({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=Lf({layout:Iv({delta:u-s,initialLayout:e,panelConstraints:t,pivotIndices:f,prevLayout:e,trigger:"keyboard"}),panelConstraints:t})[n],i=Lf({layout:Iv({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 iNe({children:e,className:t,elementRef:n,id:r,style:i,...a}){const s=QM(r),[o,l]=k.useState({}),[u,f]=k.useState("inactive"),[d,p]=k.useState(null),m=e3(p,n),{id:y,orientation:S,registerSeparator:g}=t3(),_=S==="horizontal"?"vertical":"horizontal";return Yf(()=>{if(d!==null){const v={element:d,id:s},x=g(v),T=vf.addListener("interactionStateChange",C=>{f(C.state!=="inactive"&&C.hitRegions.some(R=>R.separator===v)?C.state:"inactive")}),w=vf.addListener("mountedGroupsChange",C=>{C.forEach(({derivedPanelConstraints:R,layout:O,separatorToPanels:N},L)=>{if(L.id===y){const D=N.get(v);if(D){const z=D[0],M=L.panels.indexOf(z);l(rNe({layout:O,panelConstraints:R,panelId:z.id,panelIndex:M}))}}})});return()=>{T(),w(),x()}}},[d,y,s,g]),b.jsx("div",{...a,"aria-controls":o.valueControls,"aria-orientation":_,"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 Vd({className:e,direction:t,...n}){return b.jsx(QRe,{"data-slot":"resizable-panel-group",orientation:t,className:Ue("flex h-full w-full data-[orientation=vertical]:flex-col",e),...n})}function Ss({...e}){return b.jsx(tNe,{"data-slot":"resizable-panel",...e})}function Gd({withHandle:e,className:t,...n}){return b.jsx(iNe,{"data-slot":"resizable-handle",className:Ue("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 kk={exports:{}},cH;function aNe(){return cH||(cH=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),y=l(4725),S=l(2585),g=l(3656);let _=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){const a=hD(),s=Vz(),o=r??e.tabs.items.length,l={id:s,name:n,position:o,directory:i??null,createdAt:Date.now()},u=Mz(e.tabs);e.tabs.add(l),u.stop(),e.tabs.get(s)?.setPending(!0),e.pendingTabCreation=s,e.pendingUpdates.set(a,{entityType:"tab",tempId:s,inversePatches:u.inversePatches,createdAt:Date.now()}),t().send({type:"tab:create",payload:{name:n,position:r,directory:i,requestId:a,tempId:s}}),t().log.ws.debug("createTab optimistic",{requestId:a,tempId:s,name:n})},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 y=f.isStartingUp,S=e.terminals.items.findIndex(v=>v.id===l);S>=0&&aS(e.terminals.items[S]),e.terminals.add(a);const g=e.terminals.get(a.id);y&&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 _=e.terminalsPendingStartup.get(l);_&&(e.terminalsPendingStartup.delete(l),e.terminalsPendingStartup.set(a.id,_),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:!!_})}else{const y=e.terminals.items.findIndex(g=>g.id===l);y>=0&&aS(e.terminals.items[y]),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}=i;if(s&&o){const l=e.pendingUpdates.get(s);if(l&&l.tempId===o){e.pendingUpdates.delete(s),e.tabs.get(o)&&(e.tabs.remove(o),e.tabs.add(a),e.pendingTabCreation=null,e.lastCreatedTabId=a.id,t().log.ws.debug("tab:created confirmed",{requestId:s,tempId:o,realId:a.id}));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--)Tv(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}}kt.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 aie(){const e=Mm();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 Cte(l);e.writeToTerminal(r,u)}catch(u){kt.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 Ek="",D2e=At.model("File",{path:At.identifier,content:At.string,originalContent:At.string,mimeType:At.string,size:At.number,lineCount:At.number,truncated:At.boolean,isMarkdownView:At.optional(At.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}})),L2e=At.model("FilesStore",{selectedFile:At.maybeNull(At.string),expandedDirs:At.array(At.string),openFiles:At.map(D2e)}).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:vk(function*(){if(e.worktreePath){e._setLoadingTree(!0),e._setTreeError(null);try{const t=yield $t(`${Ek}/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:vk(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 $t(`${Ek}/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:vk(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(`${Ek}/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 P2e(){return L2e.create({selectedFile:null,expandedDirs:[],openFiles:{}})}const sie=k.createContext(null);function M2e(e,t=!1,n){const r=k.useMemo(()=>P2e(),[]),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 j2e(){const e=k.useContext(sie);if(!e)throw new Error("useFilesStore must be used within a FilesStoreProvider");return e}function oie(){const e=j2e();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 lie=k.createContext(null);function Mm(){const e=k.useContext(lie);if(!e)throw new Error("useStore must be used within a StoreProvider");return e}function F2e(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/terminal`}function B2e({children:e,wsUrl:t=F2e(),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?(kt.ws.debug("send",{type:d.type}),i.current.send(JSON.stringify(d))):kt.ws.warn("send dropped (WebSocket not open)",{type:d.type,readyState:i.current?.readyState??"no socket"})},[]);if(!o.current){const d={send:u,log:kt};o.current=I2e.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 y=new WebSocket(t);i.current=y,y.onopen=()=>{d&&(kt.ws.info("WebSocket connected"),f.setConnected(!0),a.current=0)},y.onmessage=S=>{if(d)try{const g=JSON.parse(S.data);f.handleMessage(g)}catch(g){kt.ws.error("Failed to parse WebSocket message",{error:String(g)})}},y.onclose=()=>{if(d)if(kt.ws.info("WebSocket disconnected"),f.setConnected(!1),i.current===y&&(i.current=null),a.current<r){a.current++,f.setReconnectAttempt(a.current);const S=n*Math.pow(1.5,a.current-1);kt.ws.info("Scheduling reconnect",{attempt:a.current,delay:S}),s.current=setTimeout(p,S)}else kt.ws.warn("Max reconnect attempts reached"),f.setReconnectAttempt(a.current)},y.onerror=S=>{kt.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(lie.Provider,{value:f,children:e})}function uie(){const e=Mm(),{setTheme:t,resolvedTheme:n,theme:r}=qc(),{data:i}=Jxe(),a=k.useRef(void 0),s=k.useRef(!1),o=k.useRef(!1);k.useEffect(()=>$M(()=>e.broadcastedTheme,f=>{f&&(o.current=!0,t(f),e.clearBroadcastedTheme(),setTimeout(()=>{o.current=!1},0))},{fireImmediately:!0}),[e,t]),k.useEffect(()=>{if(!n)return;const u=n==="dark"?"/logo-dark.jpg":"/logo-light.jpg";let f=document.querySelector('link[rel="icon"]');f||(f=document.createElement("link"),f.rel="icon",document.head.appendChild(f)),f.type="image/jpeg",f.href=u},[n]),k.useEffect(()=>{const u=s.current&&i&&a.current===!1;a.current=i,s.current=!0,n&&u&&$t("/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;$t("/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 Sk=!1;const Gz={activeTabId:null,focusedTerminals:{},currentView:null,currentTaskId:null,isTabVisible:null,viewUpdatedAt:null};function cie(){const e=wr(),t=k.useRef(void 0),n=k.useRef({}),{data:r=Gz,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=zn({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 y=n.current;e.setQueryData(["terminal-view-state"],S=>{const g=S??Gz;return{activeTabId:y.activeTabId!==void 0?y.activeTabId:g.activeTabId,focusedTerminals:{...g.focusedTerminals,...y.focusedTerminals},currentView:y.currentView!==void 0?y.currentView:g.currentView,currentTaskId:y.currentTaskId!==void 0?y.currentTaskId:g.currentTaskId,isTabVisible:y.isTabVisible!==void 0?y.isTabVisible:g.isTabVisible,viewUpdatedAt:y.viewUpdatedAt!==void 0?y.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 y=e.getQueryData(["terminal-view-state"]);if(y){const{[p]:S,...g}=y.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(Sk){f.current=!1;return}Sk=!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&&(Sk=!1)}},[o]);const d=k.useCallback((p,m,y)=>{o({currentView:p,currentTaskId:m,activeTabId:y,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 U2e(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 $2e(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 z2e({open:e,onOpenChange:t,onNewTask:n,onShowShortcuts:r}){const{t:i}=tn("navigation"),[a,s]=k.useState(!1),o=e??a,l=t??s,[u,f]=k.useState(""),[d,p]=k.useState(0),m=k.useRef(null),y=k.useRef(null),S=Wi(),g=k.useMemo(()=>[{id:"goto-tasks",label:i("commandPalette.commands.goToTasks"),shortcut:"meta+1",keywords:["kanban","board","home"],category:"navigation",icon:b.jsx(fe,{icon:Dp,size:16,strokeWidth:2}),action:()=>{S({to:"/tasks"}),l(!1)}},{id:"goto-terminals",label:i("commandPalette.commands.goToTerminals"),shortcut:"meta+2",keywords:["shell","console","cli"],category:"navigation",icon:b.jsx(fe,{icon:x1e,size:16,strokeWidth:2}),action:()=>{S({to:"/terminals"}),l(!1)}},{id:"goto-task-terminals",label:i("commandPalette.commands.goToTaskTerminals"),shortcut:"meta+i",keywords:["tasks","shell","console","cli"],category:"navigation",icon:b.jsx(fe,{icon:Dp,size:16,strokeWidth:2}),action:()=>{S({to:"/terminals",search:{tab:"all-tasks"}}),l(!1)}},{id:"goto-worktrees",label:i("commandPalette.commands.goToWorktrees"),shortcut:"meta+3",keywords:["git","branches"],category:"navigation",icon:b.jsx(fe,{icon:R1e,size:16,strokeWidth:2}),action:()=>{S({to:"/worktrees"}),l(!1)}},{id:"goto-repositories",label:i("commandPalette.commands.goToRepositories"),shortcut:"meta+4",keywords:["repos","git","projects"],category:"navigation",icon:b.jsx(fe,{icon:T1e,size:16,strokeWidth:2}),action:()=>{S({to:"/repositories"}),l(!1)}},{id:"goto-settings",label:i("commandPalette.commands.goToSettings"),shortcut:"meta+,",keywords:["preferences","config","configuration"],category:"navigation",icon:b.jsx(fe,{icon:cte,size:16,strokeWidth:2}),action:()=>{S({to:"/settings"}),l(!1)}},{id:"new-task",label:i("commandPalette.commands.newTask"),shortcut:"meta+j",keywords:["create","add"],category:"actions",icon:b.jsx(fe,{icon:Ev,size:16,strokeWidth:2}),action:()=>{l(!1),n?.()}},{id:"show-shortcuts",label:i("commandPalette.commands.keyboardShortcuts"),shortcut:"meta+/",keywords:["help","hotkeys","keys"],category:"actions",icon:b.jsx(fe,{icon:ste,size:16,strokeWidth:2}),action:()=>{l(!1),r?.()}}],[S,n,r,l,i]),_=k.useMemo(()=>U2e(g,u),[g,u]),v=k.useMemo(()=>$2e(_),[_]),x=k.useMemo(()=>{const C=[],R=["navigation","actions"];for(const O of R){const N=v.get(O);N&&C.push(...N)}return C},[v]);k.useEffect(()=>{p(0)},[u]),k.useEffect(()=>{if(!y.current)return;const C=y.current.querySelector('[data-selected="true"]');C&&C.scrollIntoView({block:"nearest"})},[d]),Es("meta+k",()=>l(!0),{allowInInput:!0,allowInTerminal:!0}),Es("meta+1",()=>S({to:"/tasks"}),{allowInInput:!0,allowInTerminal:!0}),Es("meta+2",()=>S({to:"/terminals"}),{allowInInput:!0,allowInTerminal:!0}),Es("meta+i",()=>{S({to:"/terminals",search:{tab:"all-tasks"}})},{allowInInput:!0,allowInTerminal:!0}),Es("meta+3",()=>S({to:"/worktrees"}),{allowInInput:!0,allowInTerminal:!0}),Es("meta+4",()=>S({to:"/repositories"}),{allowInInput:!0,allowInTerminal:!0}),Es("meta+,",()=>S({to:"/settings"}),{allowInInput:!0,allowInTerminal:!0}),Es("meta+j",()=>{n?.()},{allowInInput:!1,deps:[n]}),Es("meta+/",()=>{r?.()},{allowInInput:!0,allowInTerminal:!0,deps:[r]});const T=k.useCallback(C=>{switch(C.key){case"ArrowDown":C.preventDefault(),p(R=>Math.min(R+1,x.length-1));break;case"ArrowUp":C.preventDefault(),p(R=>Math.max(R-1,0));break;case"Enter":C.preventDefault(),x[d]&&x[d].action();break;case"Escape":C.preventDefault(),l(!1);break}},[x,d,l]);k.useEffect(()=>{o&&(f(""),p(0),setTimeout(()=>m.current?.focus(),50))},[o]);let w=0;return b.jsx(ku,{open:o,onOpenChange:l,children:b.jsxs(Ou,{className:"sm:max-w-lg p-0 gap-0 overflow-hidden",showCloseButton:!1,onKeyDown:T,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(vn,{ref:m,value:u,onChange:C=>f(C.target.value),placeholder:i("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:y,className:"max-h-80 overflow-y-auto p-2",children:_.length===0?b.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:i("commandPalette.noResults")}):b.jsx(b.Fragment,{children:["navigation","actions"].map(C=>{const R=v.get(C);return!R||R.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:i(`commandPalette.categories.${C}`)}),R.map(O=>{const N=w++,L=N===d;return b.jsxs("button",{"data-selected":L,onClick:()=>O.action(),onMouseEnter:()=>p(N),className:Ue("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:[O.icon&&b.jsx("span",{className:"text-muted-foreground",children:O.icon}),b.jsx("span",{className:"flex-1 text-left",children:O.label}),O.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:pte(O.shortcut)})]},O.id)})]},C)})})})]})})}const qz={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 H2e({className:e,rows:t=100,cols:n=10,tileClassName:r,tileSize:i="md"}){return b.jsx("div",{className:Ue("relative z-0 flex w-full h-full justify-center",e),children:Array.from({length:t}).map((a,s)=>b.jsx("div",{className:Ue(qz[i],"border-l dark:border-neutral-900 border-neutral-200 relative",r),children:Array.from({length:n}).map((o,l)=>b.jsx("div",{className:Ue(qz[i],"border-r border-t dark:border-neutral-900 border-neutral-200 relative hover:bg-tile transition-colors",r)},`col-${l}`))},`row-${s}`))})}const W2e=["/","/tasks","/terminals","/worktrees","/repositories","/review","/monitoring","/settings"];function V2e(){const e=ti({select:n=>n.location.pathname});return W2e.some(n=>e===n||e.startsWith(n+"/"))?b.jsx("div",{className:"absolute inset-0 overflow-hidden pointer-events-none -z-10",children:b.jsx(H2e,{rows:100,cols:50,tileSize:"sm"})}):null}if(!k.useState)throw new Error("mobx-react-lite requires React with Hooks support");if(!_re)throw new Error("mobx-react-lite@3 requires mobx at least version 6 to be available");function G2e(e){e()}function q2e(e){e||(e=G2e),bke({reactionScheduler:e})}function K2e(e){return yke(e)}var Y2e=1e4,X2e=1e4,Z2e=(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=Y2e),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,X2e))}}),e})(),Q2e=typeof FinalizationRegistry<"u"?FinalizationRegistry:Z2e,pD=new Q2e(function(e){var t;(t=e.reaction)===null||t===void 0||t.dispose(),e.reaction=null});function Kz(e){e.reaction=new ll("observer".concat(e.name),function(){var t;e.stateVersion=Symbol(),(t=e.onStoreChange)===null||t===void 0||t.call(e)})}function J2e(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 pD.unregister(r),r.onStoreChange=o,r.reaction||(Kz(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||(Kz(i),pD.register(n,i,i)),oe.useDebugValue(i.reaction,K2e),OP.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 xk,wk,die=typeof Symbol=="function"&&Symbol.for,eRe=(wk=(xk=Object.getOwnPropertyDescriptor(function(){},"name"))===null||xk===void 0?void 0:xk.configurable)!==null&&wk!==void 0?wk:!1,Yz=die?Symbol.for("react.forward_ref"):typeof k.forwardRef=="function"&&k.forwardRef(function(e){return null}).$$typeof,Xz=die?Symbol.for("react.memo"):typeof k.memo=="function"&&k.memo(function(e){return null}).$$typeof;function n0(e,t){var n;if(Xz&&e.$$typeof===Xz)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(Yz&&e.$$typeof===Yz&&(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 J2e(function(){return i(o,l)},a)};return s.displayName=e.displayName,eRe&&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),nRe(e,s),s}var tRe={$$typeof:!0,render:!0,compare:!0,type:!0,displayName:!0};function nRe(e,t){Object.keys(e).forEach(function(n){tRe[n]||Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})}var Tk;q2e(xr.unstable_batchedUpdates);Tk=pD.finalizeAllImmediately;const rRe=n0(function(){const t=Mm();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:Ue("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:ts,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:en,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:ts,size:16,strokeWidth:2}),b.jsx("span",{children:"Disconnected from server"})]})})});function iRe(){return qn({queryKey:["system","dependencies"],queryFn:()=>$t("/api/system/dependencies"),staleTime:30*1e3,refetchOnWindowFocus:!0})}const Zz="npm install -g @anthropic/claude-code",aRe="https://docs.anthropic.com/en/docs/claude-code/overview";function sRe(){const{data:e,isLoading:t}=iRe(),[n,r]=k.useState(!1),[i,a]=k.useState(!1),s=k.useCallback(async()=>{try{await navigator.clipboard.writeText(Zz),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[]),o=k.useCallback(()=>{r(!0)},[]);return t||n||e?.claudeCode?.installed?null:b.jsxs("div",{className:Ue("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:ts,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:Zz}),b.jsx("button",{onClick:s,className:Ue("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?hl:w1e,size:14,strokeWidth:2})})]})]})]}),b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx("a",{href:aRe,target:"_blank",rel:"noopener noreferrer",className:Ue("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:Ue("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:ci,size:16,strokeWidth:2})})]})]})}const oRe=[{titleKey:"navigation",items:[{labelKey:"goToTasks",shortcut:"meta+1"},{labelKey:"goToTerminals",shortcut:"meta+2"},{labelKey:"goToTaskTerminals",shortcut:"meta+i"},{labelKey:"goToWorktrees",shortcut:"meta+3"},{labelKey:"goToRepositories",shortcut:"meta+4"},{labelKey:"goToSettings",shortcut:"meta+,"}]},{titleKey:"actions",items:[{labelKey:"commandPalette",shortcut:"meta+k"},{labelKey:"newTask",shortcut:"meta+j"},{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 lRe({open:e,onOpenChange:t}){const{t:n}=tn("navigation");return b.jsx(ku,{open:e,onOpenChange:t,children:b.jsxs(Ou,{className:"sm:max-w-md",children:[b.jsx(Jc,{children:b.jsx(ed,{children:n("shortcuts.title")})}),b.jsx("div",{className:"space-y-4 mt-2",children:oRe.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:pte(i.shortcut)})]},i.shortcut))})]},r.titleKey))})]})})}const uRe=({...e})=>{const{resolvedTheme:t}=qc();return b.jsx(w_e,{theme:t,className:"toaster group",icons:{success:b.jsx(fe,{icon:nte,strokeWidth:2,className:"size-4"}),info:b.jsx(fe,{icon:L1e,strokeWidth:2,className:"size-4"}),warning:b.jsx(fe,{icon:ts,strokeWidth:2,className:"size-4"}),error:b.jsx(fe,{icon:B1e,strokeWidth:2,className:"size-4"}),loading:b.jsx(fe,{icon:en,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})},Oo=Kpe({component:mRe});function cRe(){return Ewe(),null}function dRe(){return Rne(),null}function fRe(){return uie(),null}function hRe(){const e=ti({select:n=>n.location}),{updateViewTracking:t}=cie();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 pRe(){const e=ti({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 mRe(){const[e,t]=k.useState(null),[n,r]=k.useState(!1),[i,a]=k.useState(!1),s=typeof window<"u"&&window.parent!==window,o=k.useCallback(d=>{t(()=>d)},[]),l=k.useCallback(()=>{e?.()},[e]),u=k.useCallback(()=>{r(!0)},[]),f=k.useCallback(()=>{a(!0)},[]);return b.jsx(k_e,{children:b.jsxs("div",{className:"flex h-screen flex-col overflow-x-hidden bg-background text-foreground",children:[b.jsx(cRe,{}),b.jsx(dRe,{}),b.jsx(fRe,{}),b.jsx(hRe,{}),b.jsx(pRe,{}),b.jsx(rRe,{}),b.jsx(sRe,{}),b.jsx(bwe,{onNewTaskRef:o,onOpenCommandPalette:f}),b.jsxs("main",{className:"isolate flex-1 overflow-hidden relative",children:[b.jsx(V2e,{}),b.jsx(tJ,{})]}),b.jsx(z2e,{open:i,onOpenChange:a,onNewTask:l,onShowShortcuts:u}),b.jsx(lRe,{open:n,onOpenChange:r}),b.jsx(uRe,{position:s?"bottom-center":"bottom-right"})]})})}const gRe=Ms("/")({beforeLoad:()=>{throw BQ({to:"/tasks"})}}),mD="";function fie(){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(`${mD}/api/worktrees/json`);if(!g.ok)throw new Error("Failed to fetch worktrees");const _=await g.json();t(new Map(_.worktrees.map(v=>[v.path,{...v,size:v.size||0,sizeFormatted:v.sizeFormatted||"0 B",branch:v.branch||"unknown"}]))),r(_.summary),a(!1),o(!1)}catch(g){u(g instanceof Error?g:new Error("Failed to load worktrees")),a(!1),o(!1)}},[]),y=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(`${mD}/api/worktrees`);f.current=g,g.addEventListener("worktree:basic",_=>{const v=JSON.parse(_.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",_=>{const v=JSON.parse(_.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",_=>{const v=JSON.parse(_.data);r(v),o(!1),g.close()}),g.addEventListener("worktree:error",_=>{const{path:v}=JSON.parse(_.data);kt.viewer.error("Error loading worktree details",{path:v}),d.current--,d.current<=0&&o(!1)}),g.onerror=()=>{g.close(),kt.viewer.info("SSE connection failed, trying JSON fallback"),p.current=!0,m()}},[m]);return k.useEffect(()=>(y(),()=>{f.current?.close()}),[y]),{worktrees:k.useMemo(()=>Array.from(e.values()).sort((_,v)=>_.isOrphaned!==v.isOrphaned?_.isOrphaned?-1:1:new Date(v.lastModified).getTime()-new Date(_.lastModified).getTime()),[e]),summary:n,isLoading:i,isLoadingDetails:s,error:l,refetch:y}}function hie(){const e=wr();return zn({mutationFn:({worktreePath:t,repoPath:n,deleteLinkedTask:r})=>$t(`${mD}/api/worktrees`,{method:"DELETE",body:JSON.stringify({worktreePath:t,repoPath:n,deleteLinkedTask:r})}),onSuccess:()=>{e.invalidateQueries({queryKey:["worktrees"]}),e.invalidateQueries({queryKey:["tasks"]})}})}const bRe=Yc("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 wxe({defaultTagName:"span",props:sl({className:Ue(bRe({className:e,variant:t}))},r),render:n,state:{slot:"badge",variant:t}})}function xa({className:e,size:t="default",...n}){return b.jsx("div",{"data-slot":"card","data-size":t,className:Ue("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 vRe({className:e,...t}){return b.jsx("div",{"data-slot":"card-header",className:Ue("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 yRe({className:e,...t}){return b.jsx("div",{"data-slot":"card-title",className:Ue("text-sm font-medium",e),...t})}function Df({className:e,...t}){return b.jsx("div",{"data-slot":"card-content",className:Ue("px-4 group-data-[size=sm]/card:px-3",e),...t})}function go({...e}){return b.jsx(BEe,{"data-slot":"alert-dialog",...e})}function bo({...e}){return b.jsx(wte,{"data-slot":"alert-dialog-trigger",...e})}function _Re({...e}){return b.jsx(_te,{"data-slot":"alert-dialog-portal",...e})}function ERe({className:e,...t}){return b.jsx(gte,{"data-slot":"alert-dialog-overlay",className:Ue("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 vo({className:e,size:t="default",...n}){return b.jsxs(_Re,{children:[b.jsx(ERe,{}),b.jsx(yte,{"data-slot":"alert-dialog-content","data-size":t,className:Ue("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 yo({className:e,...t}){return b.jsx("div",{"data-slot":"alert-dialog-header",className:Ue("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 _o({className:e,...t}){return b.jsx("div",{"data-slot":"alert-dialog-footer",className:Ue("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 Eo({className:e,...t}){return b.jsx(xte,{"data-slot":"alert-dialog-title",className:Ue("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 So({className:e,...t}){return b.jsx(bte,{"data-slot":"alert-dialog-description",className:Ue("text-muted-foreground *:[a]:hover:text-foreground text-xs/relaxed text-balance md:text-pretty *:[a]:underline *:[a]:underline-offset-3",e),...t})}function Rv({className:e,...t}){return b.jsx(Ke,{"data-slot":"alert-dialog-action",className:Ue(e),...t})}function xo({className:e,variant:t="outline",size:n="default",...r}){return b.jsx(qx,{"data-slot":"alert-dialog-cancel",className:Ue(e),render:b.jsx(Ke,{variant:t,size:n}),...r})}const Ti=k.forwardRef(({className:e,...t},n)=>b.jsx(pSe,{ref:n,className:Ue("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(mSe,{className:"flex items-center justify-center",children:b.jsx(fe,{icon:hl,size:12,strokeWidth:3})})}));Ti.displayName="Checkbox";const gD={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"},SRe=Ms("/worktrees/")({component:CRe});function xRe(){const{t:e}=tn("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 Qz({className:e}){return b.jsx("span",{className:`inline-block animate-pulse rounded bg-muted ${e}`})}function wRe({worktree:e,onDelete:t}){const{t:n}=tn("common"),{t:r}=tn("worktrees"),i=xRe(),[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)}},y=S=>{s(S),S||f(!1)};return b.jsx(xa,{className:"transition-colors hover:border-border/80",children:b.jsxs(Df,{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:Ue("shrink-0",gD.ORPHANED),children:n("statuses.ORPHANED")}):e.taskStatus?b.jsx(co,{className:Ue("shrink-0",gD[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:Hi,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:Vx,size:12,strokeWidth:2,className:"shrink-0"}),e.branch==="..."?b.jsx(Qz,{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:ate,size:12,strokeWidth:2,className:"shrink-0"}),e.sizeFormatted==="..."?b.jsx(Qz,{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:tte,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(wi,{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:$y,size:12,strokeWidth:2,className:"shrink-0"})]})})]})]}),b.jsxs(go,{open:a,onOpenChange:y,children:[b.jsx(bo,{render:b.jsx(Ke,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-muted-foreground hover:text-destructive",disabled:d}),children:b.jsx(fe,{icon:$c,size:14,strokeWidth:2})}),b.jsxs(vo,{children:[b.jsxs(yo,{children:[b.jsx(Eo,{children:r("delete.title")}),b.jsxs(So,{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(Ti,{checked:u,onCheckedChange:S=>f(S===!0),disabled:o}),r("delete.alsoDeleteLinkedTask",{title:e.taskTitle})]})]}),b.jsxs(_o,{children:[b.jsx(xo,{disabled:o,children:n("buttons.cancel")}),b.jsxs(Ke,{variant:"destructive",onClick:m,disabled:o,className:"gap-2",children:[o&&b.jsx(fe,{icon:en,size:14,strokeWidth:2,className:"animate-spin"}),n(o?"status.deleting":"buttons.delete")]})]})]})]})]})})}const TRe=["IN_PROGRESS","IN_REVIEW","DONE","CANCELED","ORPHANED"];function CRe(){const{t:e}=tn("common"),{t}=tn("worktrees"),{worktrees:n,summary:r,isLoading:i,isLoadingDetails:a,error:s,refetch:o}=fie(),l=hie(),[u,f]=k.useState(new Set),[d,p]=k.useState(!1),[m,y]=k.useState(!1),[S,g]=k.useState(!1),_=O=>{f(N=>{const L=new Set(N);return L.has(O)?L.delete(O):L.add(O),L})},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){y(!0);try{for(const O of T)await l.mutateAsync({worktreePath:O.path,repoPath:O.repoPath,deleteLinkedTask:S});p(!1),o()}catch{}finally{y(!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(bo,{render:b.jsx(Ke,{variant:"ghost",size:"sm",className:"gap-1.5 text-xs text-muted-foreground hover:text-destructive",disabled:a}),children:[b.jsx(fe,{icon:rte,size:12,strokeWidth:2}),t("cleanup.button",{count:T.length})]}),b.jsxs(vo,{children:[b.jsxs(yo,{children:[b.jsx(Eo,{children:t("cleanup.title")}),b.jsxs(So,{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(Ti,{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(_o,{children:[b.jsx(xo,{disabled:m,children:e("buttons.cancel")}),b.jsxs(Ke,{variant:"destructive",onClick:w,disabled:m,className:"gap-2",children:[m&&b.jsx(fe,{icon:en,size:14,strokeWidth:2,className:"animate-spin"}),m?e("status.deleting"):t("delete.button",{count:T.length})]})]})]})]}),u.size>0&&b.jsxs(Ke,{variant:"ghost",size:"sm",onClick:v,className:"gap-1.5 text-xs",children:[b.jsx(fe,{icon:ci,size:12,strokeWidth:2}),e("buttons.clearFilters")]})]})]}),b.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:TRe.map(O=>{const N=u.has(O);return b.jsx("button",{onClick:()=>_(O),className:Ue("rounded-full px-2.5 py-1 text-xs font-medium transition-colors",N?gD[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:en,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:ts,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(wRe,{worktree:O,onDelete:R},O.path))})]})]})}function Wn(e,t="Assertion error"){if(!e)throw Error(t)}function zp({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 bD(e,t){return t.sort(e==="horizontal"?ARe:kRe)}function ARe(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function kRe(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function pie(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 ORe({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}=pie(r,s),u=e==="horizontal"?o:l;u<a&&(a=u,i=s)}return Wn(i,"No rect found"),i}function mie(e){const{element:t,orientation:n,panels:r,separators:i}=e,a=bD(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 y;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:{y=[S,g];break}case 1:{const _=u[0],v=ORe({orientation:n,rects:[p,m],targetRect:_.element.getBoundingClientRect()});y=[_,v===p?g:S];break}default:{y=u;break}}}else u.length?y=u:y=[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 y)s.push({group:e,groupSize:zp({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 RRe(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function NRe(e,t){const n=getComputedStyle(e.ownerDocument.body),r=parseFloat(n.fontSize);return t*r}function IRe(e){return e/100*window.innerHeight}function DRe(e){return e/100*window.innerWidth}function LRe(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 E_({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,a]=LRe(n);switch(a){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=NRe(t,i);break}case"em":{r=RRe(t,i);break}case"vh":{r=IRe(i);break}case"vw":{r=DRe(i);break}}return r}function ao(e){return parseFloat(e.toFixed(3))}function Jz(e){const{panels:t}=e,n=zp({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=E_({groupSize:n,panelElement:i,styleProp:a.collapsedSize});s=ao(f/n*100)}let o;if(a.defaultSize){const f=E_({groupSize:n,panelElement:i,styleProp:a.defaultSize});o=ao(f/n*100)}let l=0;if(a.minSize){const f=E_({groupSize:n,panelElement:i,styleProp:a.minSize});l=ao(f/n*100)}let u=100;if(a.maxSize){const f=E_({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 PRe{#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 Qi(e,t,n=0){return Math.abs(ao(e)-ao(t))<=n}let ys={cursorFlags:0,interactionState:{state:"inactive"},mountedGroups:new Map};const vf=new PRe;function bl(){return ys}function Ds(e){const t=typeof e=="function"?e(ys):e;if(ys===t)return ys;const n=ys;return ys={...ys,...t},t.cursorFlags!==void 0&&vf.emit("cursorFlagsChange",ys.cursorFlags),t.interactionState!==void 0&&vf.emit("interactionStateChange",ys.interactionState),t.mountedGroups!==void 0&&(ys.mountedGroups.forEach((r,i)=>{r.derivedPanelConstraints.forEach(a=>{if(a.collapsible){const{layout:s}=n.mountedGroups.get(i)??{};if(s){const o=Qi(a.collapsedSize,r.layout[a.panelId]),l=Qi(a.collapsedSize,s[a.panelId]);o&&!l&&(i.inMemoryLastExpandedPanelSizes[a.panelId]=s[a.panelId])}}})}),vf.emit("mountedGroupsChange",ys.mountedGroups)),ys}const MRe=e=>e,Ck=()=>{},gie=1,bie=2,vie=4,yie=8,eH={coarse:10,precise:5};function jRe({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&gie)!==0,s=(e&bie)!==0,o=(e&vie)!==0,l=(e&yie)!==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 Ak,Fo;function ZM(){Fo===void 0&&(Fo=new CSSStyleSheet,document.adoptedStyleSheets=[Fo]);const{cursorFlags:e,interactionState:t}=bl();switch(t.state){case"active":case"hover":{const n=jRe({cursorFlags:e,groups:t.hitRegions.map(i=>i.group),state:t.state}),r=`*{cursor: ${n} !important; ${t.state==="active"?"touch-action: none;":""} }`;if(Ak===r)return;Ak=r,n?Fo.cssRules.length===0?Fo.insertRule(r):Fo.replaceSync(r):Fo.cssRules.length===1&&Fo.deleteRule(0);break}case"inactive":{Ak=void 0,Fo.cssRules.length===1&&Fo.deleteRule(0);break}}}function FRe(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 Nv(e,t){return Qi(e,t)?0:e>t?1:-1}function sp({panelConstraints:e,size:t}){const{collapsedSize:n=0,collapsible:r,maxSize:i=100,minSize:a=0}=e;if(Nv(t,a)<0)if(r){const s=(n+a)/2;Nv(t,s)<0?t=n:t=a}else t=a;return t=Math.min(i,t),t=ao(t),t}function Iv({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(Qi(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 y=e<0?f:u,S=n[y];Wn(S,`Panel constraints not found for index ${y}`);const{collapsedSize:g=0,collapsible:_,minSize:v=0}=S;if(_){const x=s[y];if(Wn(x!=null,`Previous layout not found for panel index ${y}`),Qi(x,g)){const T=v-x;Nv(T,Math.abs(e))>0&&(e=e<0?0-T:T)}}}{const y=e<0?u:f,S=n[y];Wn(S,`No panel constraints found for index ${y}`);const{collapsedSize:g=0,collapsible:_,minSize:v=0}=S;if(_){const x=s[y];if(Wn(x!=null,`Previous layout not found for panel index ${y}`),Qi(x,v)){const T=x-g;Nv(T,Math.abs(e))>0&&(e=e<0?0-T:T)}}}}{const y=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=sp({panelConstraints:n[S],size:100})-v;if(g+=x,S+=y,S<0||S>=n.length)break}const _=Math.min(Math.abs(e),Math.abs(g));e=e<0?0-_:_}{let y=e<0?u:f;for(;y>=0&&y<n.length;){const S=Math.abs(e)-Math.abs(d),g=s[y];Wn(g!=null,`Previous layout not found for panel index ${y}`);const _=g-S,v=sp({panelConstraints:n[y],size:_});if(!Qi(g,v)&&(d+=g-v,l[y]=v,d.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?y--:y++}}if(FRe(o,l))return i;{const y=e<0?f:u,S=s[y];Wn(S!=null,`Previous layout not found for panel index ${y}`);const g=S+d,_=sp({panelConstraints:n[y],size:g});if(l[y]=_,!Qi(_,g)){let v=g-_,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=sp({panelConstraints:n[x],size:w});if(Qi(T,C)||(v-=C-T,l[x]=C),Qi(v,0))break;e>0?x--:x++}}}const p=Object.values(l).reduce((y,S)=>S+y,0);if(!Qi(p,100,.1))return i;const m=Object.keys(i);return l.reduce((y,S,g)=>(y[m[g]]=S,y),{})}function jm(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||Nv(e[n],t[n])!==0)return!1;return!0}function _ie({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 y=n.get(l),{defaultLayoutDeferred:S,derivedPanelConstraints:g,layout:_,separatorToPanels:v}=r.get(l)??{defaultLayoutDeferred:!1};if(g&&y&&_&&v){const x=Iv({delta:m,initialLayout:y,panelConstraints:g,pivotIndices:o.panels.map(T=>p.indexOf(T)),prevLayout:_,trigger:"mouse-or-touch"});if(jm(x,_)){if(m!==0&&!f)switch(d){case"horizontal":{a|=m<0?gie:bie;break}case"vertical":{a|=m<0?vie:yie;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}}}),Ds({cursorFlags:a,mountedGroups:s}),ZM()}function tH(e){if(e.defaultPrevented||e.relatedTarget!==null||e.clientX===0&&e.clientY===0)return;const{interactionState:t,mountedGroups:n}=bl();t.state==="active"&&t.hitRegions.forEach(r=>{e.currentTarget===r.group.element&&_ie({event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n})})}function lE(e){const t=e.parentElement;Wn(t,"Parent group element not found");const{mountedGroups:n}=bl();for(const[r]of n)if(r.element===t)return r;throw Error("Could not find parent Group for separator element")}function Lf({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(!Qi(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=sp({panelConstraints:t[s],size:o});o!=l&&(i+=o-l,n[s]=l)}if(!Qi(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=sp({panelConstraints:t[s],size:l});if(o!==u&&(i-=u-o,n[s]=u,Qi(i,0)))break}const a=Object.keys(e);return n.reduce((s,o,l)=>(s[a[l]]=o,s),{})}function Eie({groupId:e}){const t=()=>{const{mountedGroups:n}=bl();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=Lf({layout:n,panelConstraints:i});return r?s:(jm(s,l)||Ds(u=>({mountedGroups:new Map(u.mountedGroups).set(a,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:l,separatorToPanels:o})})),l)}}}function Sie(e){const{mountedGroups:t}=bl(),n=t.get(e);return Wn(n,`Mounted Group ${e.id} not found`),n}function Pd(e,t){const n=lE(e),r=Sie(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=Eie({groupId:n.id}).getLayout(),l=Iv({delta:t,initialLayout:o,panelConstraints:r.derivedPanelConstraints,pivotIndices:s,prevLayout:o,trigger:"keyboard"}),u=Lf({layout:l,panelConstraints:r.derivedPanelConstraints});jm(o,u)||Ds(f=>({mountedGroups:new Map(f.mountedGroups).set(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,layout:u,separatorToPanels:r.separatorToPanels})}))}function nH(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=lE(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Pd(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Pd(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Pd(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Pd(t,-5);break}case"End":{e.preventDefault(),Pd(t,100);break}case"Enter":{e.preventDefault();const r=lE(t),{derivedPanelConstraints:i,layout:a,separatorToPanels:s}=Sie(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;Pd(t,p-d)}break}case"F6":{e.preventDefault();const r=lE(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(),Pd(t,-100);break}}}function BRe(e,t,n){let r,i={x:1/0,y:1/0};for(const a of t){const s=pie(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 S_;function URe(){return S_===void 0&&(typeof matchMedia=="function"?S_=!!matchMedia("(pointer:coarse)").matches:S_=!1),S_}function $Re(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:aH(e),b:aH(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:iH(rH(n.a)),b:iH(rH(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 zRe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function HRe(e){const t=getComputedStyle(xie(e)??e).display;return t==="flex"||t==="inline-flex"}function WRe(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||HRe(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"||zRe.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function rH(e){let t=e.length;for(;t--;){const n=e[t];if(Wn(n,"Missing node"),WRe(n))return n}return null}function iH(e){return e&&Number(getComputedStyle(e).zIndex)||0}function aH(e){const t=[];for(;e;)t.push(e),e=xie(e);return t}function xie(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}function VRe(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 GRe({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!(n instanceof HTMLElement)||n.contains(e)||e.contains(n))return!0;if($Re(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(VRe(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function wie(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const a=URe()?eH.coarse:eH.precise,s=mie(i),o=BRe(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=a&&o.distance.y<=a&&GRe({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function sH(e){if(e.defaultPrevented)return;const{mountedGroups:t}=bl(),n=wie(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)}),Ds({interactionState:{hitRegions:n,initialLayoutMap:s,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}}),n.length&&e.preventDefault()}function oH(e){if(e.defaultPrevented)return;const{interactionState:t,mountedGroups:n}=bl();switch(t.state){case"active":{if(e.type!=="pointerleave"&&e.buttons===0){Ds(r=>r.interactionState.state==="inactive"?r:{cursorFlags:0,interactionState:{state:"inactive"}});return}_ie({event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint});break}default:{const r=wie(e,n);r.length===0?t.state!=="inactive"&&Ds({interactionState:{state:"inactive"}}):Ds({interactionState:{hitRegions:r,state:"hover"}}),ZM();break}}}function lH(e){if(e.defaultPrevented)return;e.preventDefault();const{interactionState:t}=bl();t.state==="active"&&(Ds({cursorFlags:0,interactionState:{state:"inactive"}}),ZM())}function uH(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 qRe(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=zp({group:e});i.onResize({asPercentage:ao(r.inlineSize/a*100),inPixels:r.inlineSize},i.id)}function KRe(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 YRe(e){let t=!0;const n=new Set,r=new Set,i=new ResizeObserver(m=>{for(const y of m){const{borderBoxSize:S,target:g}=y;if(g===e.element){if(t){if(zp({group:e})===0)return;Ds(_=>{const v=_.mountedGroups.get(e);if(v){const x=Jz(e),T=v.defaultLayoutDeferred?uH(x):v.layout,w=Lf({layout:T,panelConstraints:x});return!v.defaultLayoutDeferred&&jm(T,w)&&KRe(v.derivedPanelConstraints,x)?_:{mountedGroups:new Map(_.mountedGroups).set(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:x,layout:w,separatorToPanels:v.separatorToPanels})}}return _})}}else qRe(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=zp({group:e}),s=Jz(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??uH(s),f=Lf({layout:u,panelConstraints:s}),d=mie(e),p=Ds(m=>{const y=new Map;return d.forEach(S=>{S.separator&&y.set(S.separator,S.panels)}),{mountedGroups:new Map(m.mountedGroups).set(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:s,layout:f,separatorToPanels:y})}});return e.element.addEventListener("pointerleave",tH),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",nH)}),p.mountedGroups.size===1&&(window.addEventListener("pointerdown",sH),window.addEventListener("pointermove",oH),window.addEventListener("pointerup",lH)),function(){t=!1;const m=Ds(y=>{const S=new Map(y.mountedGroups);return S.delete(e),{mountedGroups:S}});e.element.removeEventListener("pointerleave",tH),e.separators.forEach(y=>{y.element.removeEventListener("keydown",nH)}),m.mountedGroups.size===0&&(window.removeEventListener("pointerdown",sH),window.removeEventListener("pointermove",oH),window.removeEventListener("pointerup",lH)),i.disconnect()}}function QM(e){const t=k.useId();return`${e??t}`}const Yf=typeof window<"u"?k.useLayoutEffect:k.useEffect;function JM(e){const t=k.useRef(e);return Yf(()=>{t.current=e},[e]),k.useCallback(n=>t.current?.(n),[t])}function e3(...e){return JM(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function XRe(e){const t=k.useRef({...e});return Yf(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const Tie="--react-resizable-panels--panel--pointer-events";function Cie(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 Aie=k.createContext(null);function ZRe(e,t){const n=k.useRef({getLayout:()=>({}),setLayout:MRe});k.useImperativeHandle(t,()=>n.current,[]),Yf(()=>{Object.assign(n.current,Eie({groupId:e}))})}function QRe({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=JM(W=>{jm(p.current,W)||(p.current=W,l?.(W))}),y=QM(o),[S,g]=k.useState(!1),[_,v]=k.useState(null),[x,T]=k.useState(n??{}),[w,C]=k.useState([]),[R,O]=k.useState([]),N=k.useRef({lastExpandedPanelSizes:{},layouts:{}}),L=e3(v,a);ZRe(y,s);const D=k.useMemo(()=>({id:y,orientation:u,registerPanel:W=>(C($=>bD(u,[...$,W])),()=>{C($=>$.filter(q=>q!==W))}),registerSeparator:W=>(O($=>bD(u,[...$,W])),()=>{O($=>$.filter(q=>q!==W))})}),[y,u]),z=XRe({defaultLayout:n,disableCursor:r}),M=k.useRef(null);Yf(()=>{if(_===null)return;const W={defaultLayout:z.defaultLayout,disableCursor:!!z.disableCursor,disabled:!!i,element:_,id:y,inMemoryLastExpandedPanelSizes:N.current.lastExpandedPanelSizes,inMemoryLayouts:N.current.layouts,orientation:u,panels:w,separators:R};M.current=W;const $=YRe(W),q=bl().mountedGroups.get(W);if(q){const{defaultLayoutDeferred:j,derivedPanelConstraints:U,layout:K}=q;!j&&U.length>0&&(T(K),m?.(K))}const Y=vf.addListener("interactionStateChange",j=>{j.state==="active"?g(j.hitRegions.some(U=>U.group===W)):g(!1)}),B=vf.addListener("mountedGroupsChange",j=>{const U=j.get(W);if(U){const{defaultLayoutDeferred:K,derivedPanelConstraints:H,layout:J}=U;if(K||H.length===0)return;T(J),m?.(J)}});return()=>{M.current=null,$(),Y(),B()}},[i,_,y,m,u,w,R,z]),k.useEffect(()=>{const W=M.current;W&&(W.defaultLayout=n,W.disableCursor=!!r)});const V={[Tie]:S?"none":void 0};for(const W in x){const $=Cie(y,W),q=x[W];V[$]=q}return b.jsx(Aie.Provider,{value:D,children:b.jsx("div",{...d,"aria-orientation":u,className:t,"data-group":!0,"data-testid":y,id:y,ref:L,style:{...f,...V,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap"},children:e})})}function t3(){const e=k.useContext(Aie);return Wn(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function JRe({groupId:e,panelId:t}){const n=()=>{const{mountedGroups:o}=bl();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(),y=d.panels.findIndex(v=>v.id===t),S=y===d.panels.length-1,g=Iv({delta:S?l-o:o-l,initialLayout:p,panelConstraints:f,pivotIndices:S?[y-1,y]:[y,y+1],prevLayout:p,trigger:"imperative-api"}),_=Lf({layout:g,panelConstraints:f});jm(p,_)||Ds(v=>({mountedGroups:new Map(v.mountedGroups).set(d,{defaultLayoutDeferred:u,derivedPanelConstraints:f,layout:_,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&&Qi(l,u)},resize:o=>{if(a()!==o){let l;switch(typeof o){case"number":{const{group:u}=n(),f=zp({group:u});l=ao(o/f*100);break}case"string":{l=parseFloat(o);break}}s(l)}}}}function eNe(e,t){const{id:n}=t3(),r=k.useRef({collapse:Ck,expand:Ck,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Ck});k.useImperativeHandle(t,()=>r.current,[]),Yf(()=>{Object.assign(r.current,JRe({groupId:n,panelId:e}))})}function tNe({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,y=QM(s),[S,g]=k.useState(null),_=e3(g,a),{id:v,registerPanel:x}=t3(),T=u!==null,w=JM(R=>{u?.(R,s)});Yf(()=>{if(S!==null)return x({element:S,id:y,idIsStable:m,onResize:T?w:void 0,panelConstraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:o,minSize:l}})},[n,r,i,S,T,y,m,o,l,w,x]),eNe(y,f);const C=Cie(v,y);return b.jsx("div",{...p,"data-panel":!0,"data-testid":y,id:y,ref:_,style:{...nNe,flexBasis:0,flexGrow:`var(${C}, 1)`,flexShrink:1,overflow:"hidden",pointerEvents:`var(${Tie})`},children:b.jsx("div",{className:t,style:{width:"100%",height:"100%",...d},children:e})})}const nNe={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 rNe({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=Lf({layout:Iv({delta:u-s,initialLayout:e,panelConstraints:t,pivotIndices:f,prevLayout:e,trigger:"keyboard"}),panelConstraints:t})[n],i=Lf({layout:Iv({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 iNe({children:e,className:t,elementRef:n,id:r,style:i,...a}){const s=QM(r),[o,l]=k.useState({}),[u,f]=k.useState("inactive"),[d,p]=k.useState(null),m=e3(p,n),{id:y,orientation:S,registerSeparator:g}=t3(),_=S==="horizontal"?"vertical":"horizontal";return Yf(()=>{if(d!==null){const v={element:d,id:s},x=g(v),T=vf.addListener("interactionStateChange",C=>{f(C.state!=="inactive"&&C.hitRegions.some(R=>R.separator===v)?C.state:"inactive")}),w=vf.addListener("mountedGroupsChange",C=>{C.forEach(({derivedPanelConstraints:R,layout:O,separatorToPanels:N},L)=>{if(L.id===y){const D=N.get(v);if(D){const z=D[0],M=L.panels.indexOf(z);l(rNe({layout:O,panelConstraints:R,panelId:z.id,panelIndex:M}))}}})});return()=>{T(),w(),x()}}},[d,y,s,g]),b.jsx("div",{...a,"aria-controls":o.valueControls,"aria-orientation":_,"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 Vd({className:e,direction:t,...n}){return b.jsx(QRe,{"data-slot":"resizable-panel-group",orientation:t,className:Ue("flex h-full w-full data-[orientation=vertical]:flex-col",e),...n})}function Ss({...e}){return b.jsx(tNe,{"data-slot":"resizable-panel",...e})}function Gd({withHandle:e,className:t,...n}){return b.jsx(iNe,{"data-slot":"resizable-handle",className:Ue("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 kk={exports:{}},cH;function aNe(){return cH||(cH=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),y=l(4725),S=l(2585),g=l(3656);let _=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)||"",L=(T.ydisp+C+1).toString(),D=this._rowElements[C];D&&(N.length===0?(D.innerText=" ",this._rowColumns.set(D,[0,1])):(D.textContent=N,this._rowColumns.set(D,O)),D.setAttribute("aria-posinset",L),D.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:L})=>{const D=N instanceof Text?N.parentNode:N;let z=parseInt(D?.getAttribute("aria-posinset"),10)-1;if(isNaN(z))return console.warn("row is invalid. Race condition?"),null;const M=this._rowColumns.get(D);if(!M)return console.warn("columns is null. Race condition?"),null;let V=L<M.length?M[L]: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=_=u([f(1,S.IInstantiationService),f(2,y.ICoreBrowserService),f(3,y.IRenderService)],_)},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,y,S){p=u(p=l(p),y.decPrivateModes.bracketedPasteMode&&S.rawOptions.ignoreBracketedPasteMode!==!0),y.triggerDataEvent(p,!0),m.value=""}function d(p,m,y){const S=y.getBoundingClientRect(),g=p.clientX-S.left-10,_=p.clientY-S.top-10;m.style.width="20px",m.style.height="20px",m.style.left=`${g}px`,m.style.top=`${_}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,y,S){p.stopPropagation(),p.clipboardData&&f(p.clipboardData.getData("text/plain"),m,y,S)},o.paste=f,o.moveTextAreaUnderMouseCursor=d,o.rightClickHandler=function(p,m,y,S,g){d(p,m,y),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(_,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(_,v,x,T);else for(var O=_.length-1;O>=0;O--)(w=_[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(_,v){return function(x,T){v(x,T,_)}};Object.defineProperty(o,"__esModule",{value:!0}),o.Linkifier=void 0;const d=l(3656),p=l(8460),m=l(844),y=l(2585),S=l(4725);let g=o.Linkifier=class extends m.Disposable{get currentLink(){return this._currentLink}constructor(_,v,x,T,w){super(),this._element=_,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(_){this._lastMouseEvent=_;const v=this._positionFromMouseEvent(_,this._element,this._mouseService);if(!v)return;this._isMouseOut=!1;const x=_.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(_){if(this._activeLine!==_.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(_,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,_)||(this._clearCurrentLink(),this._askForLink(_,!0))}_askForLink(_,v){this._activeProviderReplies&&v||(this._activeProviderReplies?.forEach((T=>{T?.forEach((w=>{w.link.dispose&&w.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=_.y);let x=!1;for(const[T,w]of this._linkProviderService.linkProviders.entries())v?this._activeProviderReplies?.get(T)&&(x=this._checkLinkProviderResult(T,_,x)):w.provideLinks(_.y,(C=>{if(this._isMouseOut)return;const R=C?.map((O=>({link:O})));this._activeProviderReplies?.set(T,R),x=this._checkLinkProviderResult(T,_,x),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(_.y,this._activeProviderReplies)}))}_removeIntersectingLinks(_,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<_?0:R.link.range.start.x,N=R.link.range.end.y>_?this._bufferService.cols:R.link.range.end.x;for(let L=O;L<=N;L++){if(x.has(L)){w.splice(C--,1);break}x.add(L)}}}}_checkLinkProviderResult(_,v,x){if(!this._activeProviderReplies)return x;const T=this._activeProviderReplies.get(_);let w=!1;for(let C=0;C<_;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(_){if(!this._currentLink)return;const v=this._positionFromMouseEvent(_,this._element,this._mouseService);v&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,v)&&this._currentLink.link.activate(_,this._currentLink.link.text)}_clearCurrentLink(_,v){this._currentLink&&this._lastMouseEvent&&(!_||!v||this._currentLink.link.range.start.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(_){if(!this._lastMouseEvent)return;const v=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);v&&this._linkAtPosition(_.link,v)&&(this._currentLink=_,this._currentLink.state={decorations:{underline:_.link.decorations===void 0||_.link.decorations.underline,pointerCursor:_.link.decorations===void 0||_.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,_.link,this._lastMouseEvent),_.link.decorations={},Object.defineProperties(_.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(_.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(_,v,x){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(v,!0),this._currentLink.state.decorations.pointerCursor&&_.classList.add("xterm-cursor-pointer")),v.hover&&v.hover(x,v.text)}_fireUnderlineEvent(_,v){const x=_.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(_,v,x){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(v,!1),this._currentLink.state.decorations.pointerCursor&&_.classList.remove("xterm-cursor-pointer")),v.leave&&v.leave(x,v.text)}_linkAtPosition(_,v){const x=_.range.start.y*this._bufferService.cols+_.range.start.x,T=_.range.end.y*this._bufferService.cols+_.range.end.x,w=v.y*this._bufferService.cols+v.x;return x<=w&&w<=T}_positionFromMouseEvent(_,v,x){const T=x.getCoords(_,v,this._bufferService.cols,this._bufferService.rows);if(T)return{x:T[0],y:T[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(_,v,x,T,w){return{x1:_,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,y.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,_,v){var x,T=arguments.length,w=T<3?g:v===null?v=Object.getOwnPropertyDescriptor(g,_):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(S,g,_,v);else for(var C=S.length-1;C>=0;C--)(x=S[C])&&(w=(T<3?x(w):T>3?x(g,_,w):x(g,_))||w);return T>3&&w&&Object.defineProperty(g,_,w),w},f=this&&this.__param||function(S,g){return function(_,v){g(_,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,_){this._bufferService=S,this._optionsService=g,this._oscLinkService=_}provideLinks(S,g){const _=this._bufferService.buffer.lines.get(S-1);if(!_)return void g(void 0);const v=[],x=this._optionsService.rawOptions.linkHandler,T=new d.CellData,w=_.getTrimmedLength();let C=-1,R=-1,O=!1;for(let N=0;N<w;N++)if(R!==-1||_.hasContent(N)){if(_.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 L=this._oscLinkService.getLinkData(C)?.uri;if(L){const D={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(L);["http:","https:"].includes(M.protocol)||(z=!0)}catch{z=!0}z||v.push({text:L,range:D,activate:(M,V)=>x?x.activate(M,V,D):y(0,V),hover:(M,V)=>x?.hover?.(M,V,D),leave:(M,V)=>x?.leave?.(M,V,D)})}O=!1,T.hasExtendedAttrs()&&T.extended.urlId?(R=N,C=T.extended.urlId):(R=-1,C=-1)}}g(v)}};function y(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-dark.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-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-j9FKYr9a.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-DujV-tJ5.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|