vibora 9.7.1 → 9.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/vibora.js
CHANGED
|
@@ -45126,7 +45126,7 @@ function installUv() {
|
|
|
45126
45126
|
var package_default = {
|
|
45127
45127
|
name: "vibora",
|
|
45128
45128
|
private: true,
|
|
45129
|
-
version: "9.7.
|
|
45129
|
+
version: "9.7.2",
|
|
45130
45130
|
description: "Harness Attention. Orchestrate Agents. Ship.",
|
|
45131
45131
|
license: "PolyForm-Perimeter-1.0.0",
|
|
45132
45132
|
type: "module",
|
|
@@ -33,7 +33,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
33
33
|
|
|
34
34
|
`)+n.map(eLe).join(`
|
|
35
35
|
`)}var rLe=0,iLe=(function(){function e(){Object.defineProperty(this,"cacheId",{enumerable:!0,configurable:!0,writable:!0,value:rLe++}),Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:Tr.map()}),Object.defineProperty(this,"lastCacheModificationPerId",{enumerable:!0,configurable:!0,writable:!0,value:Tr.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,Tr.array([],YC));var i=this.cache.get(r);if(i.indexOf(t)!==-1)throw new Nt("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;Rse(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 vDe(this.cache).forEach(function(a){for(var s=ic(a,2),o=s[0],l=s[1],u=!1,d=l.length-1;d>=0;d--){var c=l[d];(c===t||c.path.indexOf(i)===0)&&(r.addNodeToCache(c,!1),l.splice(d,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 Nt("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 a5(e,t,n,r,i){var a=Zse(i);if(a){if(a.parent)throw new Nt("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 ls(e,t,n,r,i)}function Yd(e,t,n,r,i){return new $y(e,t,n,r,i)}function aLe(e){return e instanceof $y||e instanceof ls}var Ji;(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"})(Ji||(Ji={}));function Mr(e){return!!(e&&e.$treenode)}function Mn(e){if(!Mr(e))throw new Nt("Value ".concat(e," is no MST Node"));return e.$treenode}function Zse(e){return e&&e.$treenode||null}function sLe(){return Mn(this).snapshot}function oLe(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 $y){var s=r.value;Mr(s)&&(r=Mn(s))}if(r instanceof ls){var o=r.getChildType(a);if(o&&(r=r.getChildNode(a),r))continue}}}throw new Nt("Could not resolve '".concat(a,"' in path '").concat(pW(t.slice(0,i))||"/","' while resolving '").concat(pW(t),"'"))}}catch(l){if(!n)return;throw l}return r}function Qse(e){if(!e)return Gm;var t=Object.keys(e);if(!t.length)return Gm;var n=new Array(t.length);return t.forEach(function(r,i){n[i]=e[r]}),n}var lLe=Object.toString(),Gm=Object.freeze([]),qm=Object.freeze({}),YC=VIe().useProxies?{deep:!1}:{deep:!1,proxy:!1};Object.freeze(YC);var Nt=(function(e){mr(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 uLe(e){return e}var cLe=Number.isInteger;function dLe(e){return Number(e)===e&&e%1!==0}function fLe(e){return Number.isFinite(e)}function Jse(e){return Array.isArray(e)||su(e)}function eoe(e){return e?Jse(e)?e:[e]:Gm}function pLe(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 im(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())===lLe}function toe(e){return e!==null&&typeof e=="object"&&!(e instanceof Date)&&!(e instanceof RegExp)}function Hy(e,t){return t===void 0&&(t=!0),e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"||t&&e instanceof Date}function noe(e){return typeof e!="function"}function hLe(e,t,n){hl(e)?Ise(e,t,n):Object.defineProperty(e,t,n)}function ap(e,t,n){hLe(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}var mLe=(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,ac([],ic(t),!1))})}}),e})(),roe=(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 mLe),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,ac([],ic(r),!1))}}),e})();function ioe(e){for(var t=new Array(e.length),n=0;n<e.length;n++)t[n]=e[n];return t}function aO(e,t){return e.indexOf(t)===0}function gLe(e){console.warn(new Error("[mobx-state-tree] ".concat(e)))}function bLe(){return typeof process<"u"&&dW&&dW.ENABLE_TYPE_CHECK==="true"}function sO(e){typeof queueMicrotask=="function"?queueMicrotask(e):typeof setImmediate=="function"?setImmediate(e):setTimeout(e,1)}function Dx(e){return vLe(e.name,e)}function vLe(e,t){var n=function(){var i=Kse(),a=qse();if(!a)throw new Nt("a mst flow must always have a parent context");var s=Yse(a);if(!s)throw new Nt("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:ac(ac([],ic(a.allParentIds),!1),[a.id],!1),rootId:a.rootId,parentEvent:a,parentActionEvent:s},l=arguments;function u(d,c,m){return d.$mst_middleware=n.$mst_middleware,dP(is(is({},o),{type:c,args:[m]}),d)}return new Promise(function(d,c){var m,g=function(){m=t.apply(null,arguments),_(void 0)};g.$mst_middleware=n.$mst_middleware,dP(is(is({},o),{type:"flow_spawn",args:ioe(l)}),g);function _(v){var y;try{var E=u(function(T){y=m.next(T)},"flow_resume",v);E instanceof Error&&(y=m.throw(E))}catch(T){sO(function(){u(function(w){c(T)},"flow_throw",T)});return}b(y)}function x(v){var y;try{u(function(E){y=m.throw(E)},"flow_resume_error",v)}catch(E){sO(function(){u(function(T){c(E)},"flow_throw",E)});return}b(y)}function b(v){if(v.done){sO(function(){u(function(y){d(y)},"flow_return",v.value)});return}if(!v.value||typeof v.value.then!="function")throw new Nt("Only promises can be yielded to `async`, got: "+v);return v.value.then(_,x)}})};return n._isFlowAction=!0,n}function yLe(e){if(!("oldValue"in e))throw new Nt("Patches without `oldValue` field cannot be inversed");return[_Le(e),xLe(e)]}function _Le(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 xLe(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 ELe(e){return typeof e=="number"}function sp(e){return ELe(e)===!0?""+e:e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function SLe(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function pW(e){if(e.length===0)return"";var t=function(n){return n.map(sp).join("/")};return e[0]==="."||e[0]===".."?t(e):"/"+t(e)}function wLe(e){var t=e.split("/").map(SLe),n=e===""||e==="."||e===".."||aO(e,"/")||aO(e,"./")||aO(e,"../");if(!n)throw new Nt("a json path must be either rooted, empty or relative, but got '".concat(e,"'"));return t[0]===""&&t.shift(),t}var oO=Symbol("$preProcessorFailed"),CLe=(function(e){mr(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|On.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 oO}}}),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;TLe(n.type,this,"create"),n instanceof ls&&(n.hasSnapshotPostProcessor=!!this._processors.postProcessor);var i=n.getSnapshot;n.getSnapshot=function(){return r.postProcessSnapshot(i.call(n),n)},GLe(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=Mr(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,Mr(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===oO?ds(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=oc(n)?this._subtype:Mr(n)?n:this.preProcessSnapshotSafe(n);return r===oO?!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 Wm))return!1;var i=this.preProcessSnapshot(r);return this._subtype.isMatchingSnapshotId(n,i)}}),t})(sc);function TLe(e,t){for(var n,r,i=[],a=2;a<arguments.length;a++)i[a-2]=arguments[a];try{for(var s=Jv(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 ALe(e,t,n){return new CLe(e,t,n)}var hW="Map.put can only be used to store complex values that have an identifier type attribute";function aoe(e,t){var n,r,i=e.getSubTypes();if(i===Gse)return!1;if(i){var a=eoe(i);try{for(var s=Jv(a),o=s.next();!o.done;o=s.next()){var l=o.value;if(!aoe(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 Vy&&t.push(e),!0}var dd;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.YES=1]="YES",e[e.NO=2]="NO"})(dd||(dd={}));var kLe=(function(e){mr(t,e);function t(n,r){return e.call(this,n,Tr.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 Nt("Map.put cannot be used to set empty values");if(Mr(n)){var r=Mn(n);if(r.identifier===null)throw new Nt(hW);return this.set(r.identifier,n),n}else if(toe(n)){var i=Mn(this),a=i.type;if(a.identifierMode!==dd.YES)throw new Nt(hW);var s=a.mapIdentifierAttribute,o=n[s];if(!s5(o)){var l=this.put(a.getChildType().create(n,i.environment));return this.put(HDe(l))}var u=b1(o);return this.set(u,n),this.get(u)}else throw new Nt("Map.put can only be used to store complex values")}}),t})(t5),wS=(function(e){mr(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:dd.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:On.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(),a5(this,n,r,i,a)}}),Object.defineProperty(t.prototype,"_determineIdentifierMode",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.identifierMode===dd.UNKNOWN){var n=[];if(aoe(this._subType,n)){var r=n.reduce(function(i,a){if(!a.identifierAttribute)return i;if(i&&i!==a.identifierAttribute)throw new Nt("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=dd.YES,this.mapIdentifierAttribute=r):this.identifierMode=dd.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 kLe(n,this.name)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){kse(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=zy(r,o,l);ap(r,o,u)})}),Qj(r,this.willChange),Jj(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 Rse(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 Nt("Not a child "+r);return i}}),Object.defineProperty(t.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=Mn(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;Zu(s,o),n.newValue=s.reconcile(r.getChildNode(i),n.newValue,r,i),a.processIdentifier(i,n.newValue)}break;case"add":Zu(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===dd.YES&&r instanceof ls){var i=r.identifier;if(i!==n)throw new Nt("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=Mn(n.object);switch(n.type){case"update":return void r.emitPatch({op:"replace",path:sp(n.name),value:n.newValue.snapshot,oldValue:n.oldValue?n.oldValue.snapshot:void 0},r);case"add":return void r.emitPatch({op:"add",path:sp(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:sp(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){Zu(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 im(n)?KC(Object.keys(n).map(function(a){return i._subType.validate(n[a],i5(r,a,i._subType))})):ds(r,n,"Value is not a plain object")}}),Object.defineProperty(t.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return qm}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){n.storedValue.delete(r)}}),t})(Wm);wS.prototype.applySnapshot=_i(wS.prototype.applySnapshot);function OLe(e){return new wS("Map<string, ".concat(e.name,">"),e)}var CS=(function(e){mr(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:On.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 a5(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=is(is({},YC),{name:this.name});return Tr.array(Qse(n),r)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){nu(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=zy(r,o,l);ap(r,o,u)})}),Qj(r,this.willChange),Jj(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 Nt("Not a child: "+r)}}),Object.defineProperty(t.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=Mn(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=mW(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,d=mW(r,i,a.slice(o,o+l),u,u.map(function(m,g){return o+g}));if(!d)return null;n.added=d;for(var c=o+l;c<a.length;c++)a[c].setParent(r,""+(c+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=Mn(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){Zu(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 Jse(n)?KC(n.map(function(a,s){return i._subType.validate(a,i5(r,""+s,i._subType))})):ds(r,n,"Value is not an array")}}),Object.defineProperty(t.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Gm}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){n.storedValue.splice(Number(r),1)}}),t})(Wm);CS.prototype.applySnapshot=_i(CS.prototype.applySnapshot);function RLe(e){return new CS("".concat(e.name,"[]"),e)}function mW(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,d=""+i[s];if(aLe(u)&&(u=u.storedValue),!l&&!o)break;if(!o)a=!1,n.splice(s,1),l instanceof ls&&l.createObservableInstanceIfNeeded(),l.die(),s--;else if(l)if(gW(l,u))n[s]=lO(t,e,d,u,l);else{for(var m=void 0,g=s;g<n.length;g++)if(gW(n[g],u)){m=n.splice(g,1)[0];break}a=!1;var c=lO(t,e,d,u,m);n.splice(s,0,c)}else{if(Mr(u)&&Mn(u).parent===e)throw new Nt("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(d,"', but it lives already at '").concat(Mn(u).path,"'"));a=!1;var c=lO(t,e,d,u);n.splice(s,0,c)}}return a?null:n}function lO(e,t,n,r,i){Zu(e,r);function a(){if(Mr(r)){var o=Mn(r);if(o.assertAlive(qm),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 ls&&i.createObservableInstanceIfNeeded(),i.die()),s}function gW(e,t){if(!e.isAlive)return!1;if(Mr(t)){var n=Mn(t);return n.isAlive&&n===e}if(e.snapshot===t)return!0;if(!(e instanceof ls))return!1;var r=e.getReconciliationType();return e.identifier!==null&&e.identifierAttribute&&im(t)&&r.is(t)&&r.isMatchingSnapshotId(e,t)}var bW="preProcessSnapshot",vW="postProcessSnapshot";function NLe(){return Mn(this).toString()}var yW={name:"AnonymousModel",properties:{},initializers:Gm};function ILe(e){var t=Object.keys(e),n=new Set;return t.forEach(function(r){if(n.has(r))throw new Nt("".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 yi)throw new Nt("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 Nt("Getters are not supported as properties. Please use views instead");var s=a.value;if(s==null)throw new Nt("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");if(Hy(s))r[i]=op(BLe(s),s);else if(s instanceof wS)r[i]=op(s,{});else if(s instanceof CS)r[i]=op(s,[]);else if(!oc(s))throw new Nt("Invalid type definition for property '".concat(i,"', cannot infer a type from a value like '").concat(s,"' (").concat(typeof s,")"));return r},is({},e))}var Vy=(function(e){mr(t,e);function t(n){var r=e.call(this,n.name||yW.name)||this;return Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:On.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,yW,n),r.properties=ILe(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&On.Identifier){if(n)throw new Nt("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(!im(r))throw new Nt("actions initializer should return a plain object containing actions");Object.getOwnPropertyNames(r).forEach(function(a){if(a in i.properties)throw new Nt("'".concat(a,"' is a property and cannot be declared as an action"));if(a===bW)throw new Nt("Cannot define action '".concat(bW,"', it should be defined using 'type.preProcessSnapshot(fn)' instead"));if(a===vW)throw new Nt("Cannot define action '".concat(vW,"', it should be defined using 'type.postProcessSnapshot(fn)' instead"));var s=r[a],o=n[a];if(a in yi&&o){var l=s;s=function(){o.apply(null,arguments),l.apply(null,arguments)}}var u=s.$mst_middleware,d=s.bind(r);d._isFlowAction=s._isFlowAction||!1,d.$mst_middleware=u;var c=zy(n,a,d);r[a]=c,ap(n,a,c)})}}),Object.defineProperty(t.prototype,"volatile",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this;if(typeof n!="function")throw new Nt("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(!im(r))throw new Nt("volatile state initializer should return a plain object containing state");Object.getOwnPropertyNames(r).forEach(function(a){if(a in i.properties)throw new Nt("'".concat(a,"' is a property and cannot be declared as volatile state"));Nse(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,d=$De(s,["actions","views","state"]);for(var c in d)throw new Nt("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '".concat(c,"'"));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(!im(r))throw new Nt("views initializer should return a plain object containing views");Object.getOwnPropertyNames(r).forEach(function(a){var s;if(a in i.properties)throw new Nt("'".concat(a,"' is a property and cannot be declared as a view"));var o=Object.getOwnPropertyDescriptor(r,a);if("get"in o)Ise(n,a,o),Lse(n,(s={},s[a]=zg,s));else if(typeof o.value=="function")ap(n,a,o.value);else throw new Nt("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=Mr(a)?a:this.applySnapshotPreProcessor(a);return a5(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=is(is({},YC),{name:this.name});return Tr.object(n,qm,r)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){ap(r,"toString",NLe),this.forAllProps(function(i){kse(r,i,n.unbox)}),this.initializers.reduce(function(i,a){return a(i)},r),Qj(r,this.willChange),Jj(r,this.didChange)}}),Object.defineProperty(t.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=n,i=Mn(r.object),a=r.name;i.assertWritable({subpath:a});var s=i.type.properties[a];return s&&(Zu(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=Mn(r.object),a=i.type.properties[r.name];if(a){var s=r.oldValue?r.oldValue.snapshot:void 0;i.emitPatch({op:"replace",path:sp(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 Nt("Not a value property: "+r);var a=nu(n.storedValue,r),s=(i=a.raw)===null||i===void 0?void 0:i.call(a);if(!s)throw new Nt("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=Vm(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 Nt("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){Zu(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 im(a)?KC(this.propertyNames.map(function(s){return i.properties[s].validate(a[s],i5(r,s,i.properties[s]))})):ds(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 qm}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){n.storedValue[r]=void 0}}),t})(Wm);Vy.prototype.applySnapshot=_i(Vy.prototype.applySnapshot);function DLe(){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 Vy({name:n,properties:r})}function LLe(){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 PLe(e){return oc(e)&&(e.flags&On.Object)>0}var Sc=(function(e){mr(t,e);function t(n,r,i,a){a===void 0&&(a=uLe);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 Yd(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(Hy(n)&&this.checker(n))return us();var i=this.name==="Date"?"Date or a unix milliseconds timestamp":this.name;return ds(r,n,"Value is not a ".concat(i))}}),t})(Wp),soe=new Sc("string",On.String,function(e){return typeof e=="string"}),ooe=new Sc("number",On.Number,function(e){return typeof e=="number"}),MLe=new Sc("integer",On.Integer,function(e){return cLe(e)}),jLe=new Sc("float",On.Float,function(e){return dLe(e)}),FLe=new Sc("finite",On.Finite,function(e){return fLe(e)}),loe=new Sc("boolean",On.Boolean,function(e){return typeof e=="boolean"}),uoe=new Sc("null",On.Null,function(e){return e===null}),coe=new Sc("undefined",On.Undefined,function(e){return e===void 0}),doe=new Sc("Date",On.Date,function(e){return typeof e=="number"||e instanceof Date},function(e){return e instanceof Date?e:new Date(e)});doe.getSnapshot=function(e){return e.storedValue.getTime()};var foe=doe;function BLe(e){switch(typeof e){case"string":return soe;case"number":return ooe;case"boolean":return loe;case"object":if(e instanceof Date)return foe}throw new Nt("Cannot determine primitive type from value "+e)}function ULe(e){return oc(e)&&(e.flags&(On.String|On.Number|On.Integer|On.Boolean|On.Date))>0}var $Le=(function(e){mr(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:On.Literal}),r.value=n,r}return Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,a){return Yd(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 Hy(n)&&n===this.value?us():ds(r,n,"Value is not a literal ".concat(JSON.stringify(this.value)))}}),t})(Wp);function poe(e){return new $Le(e)}var zLe=(function(e){mr(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|On.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=Mr(n)?Mn(n).snapshot:n;return this._predicate(a)?us():ds(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})(sc);function HLe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=typeof e[0]=="string"?e.shift():oc(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 zLe(n,r,i,a)}function VLe(e,t){var n=typeof e=="string"?t:e,r=XC.apply(void 0,ac([],ic(n.map(function(i){return poe(""+i)})),!1));return typeof e=="string"&&(r.name=e),r}var WLe=(function(e){mr(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=is({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=On.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 Nt("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 Nt("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 us();a++}else i.push(l)}return a===1?us():ds(r,n,"No type is applicable for the union").concat(KC(i))}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._types}}),t})(sc);function XC(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=oc(e)?void 0:e,i=oc(e)?ac([e],ic(t),!1):t,a="("+i.map(function(s){return s.name}).join(" | ")+")";return new WLe(a,i,r)}function GLe(e){return oc(e)&&(e.flags&On.Union)>0}var qLe=(function(e){mr(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|On.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"&&Zu(this,n),n}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return this.optionalValues.indexOf(n)>=0?us():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})(sc);function KLe(e,t){if(typeof t!="function"&&Mr(t))throw new Nt("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead")}function op(e,t,n){return KLe(e,t),new qLe(e,t,n||YLe)}var YLe=[void 0],XLe=op(coe,void 0),ZLe=op(uoe,null);function hoe(e){return XC(e,XLe)}function QLe(e){return XC(e,ZLe)}var JLe=(function(e){mr(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)|On.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 Nt("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):us()}}),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||Gse}}),t})(sc);function ePe(e,t){var n=typeof e=="string"?e:"late(".concat(e.toString(),")"),r=typeof e=="string"?t:e;return new JLe(n,r)}function tPe(e,t){return new nPe(e,t)}var nPe=(function(e){mr(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:On.Lazy}),Object.defineProperty(i,"loadedType",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(i,"pendingNodeList",{enumerable:!0,configurable:!0,writable:!0,value:Tr.array()}),eW(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(_i(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=Yd(this,n,r,i,a);return this.pendingNodeList.push(o),eW(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):noe(n)?us():ds(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})(Wp),moe=(function(e){mr(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:On.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 Yd(this,n,r,i,a)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return noe(n)?this.subType?this.subType.validate(n,r):us():ds(r,n,"Value is not serializable and cannot be frozen")}}),t})(Wp),_W=new moe;function rPe(e){return arguments.length===0?_W:oc(e)?new moe(e):op(_W,e)}function iPe(e){switch(e){case yi.beforeDestroy:return"destroy";case yi.beforeDetach:return"detach";default:return}}var aPe=(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}),s5(t))this.identifier=t;else if(Mr(t)){var r=Mn(t);if(!r.identifierAttribute)throw new Nt("Can only store references with a defined identifier attribute.");var i=r.unnormalizedIdentifier;if(i==null)throw new Nt("Can only store references to tree nodes with a defined identifier.");this.identifier=i}else throw new Nt("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=b1(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 sPe("[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})(),sPe=(function(e){mr(t,e);function t(n){var r=e.call(this,n)||this;return Object.setPrototypeOf(r,t.prototype),r}return t})(Error),goe=(function(e){mr(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:On.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 s5(n)?us():ds(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){Uy(r.root.storedValue,{op:"replace",value:l,path:r.path})},removeRef:function(){PLe(s.type)?this.replaceRef(void 0):Uy(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=Mn(a),o=function(d,c){var m=iPe(c);m&&i.fireInvalidated(m,n,r,s)},l=s.registerHook(yi.beforeDetach,o),u=s.registerHook(yi.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(yi.beforeDestroy,function(){s&&s()});var o=function(l){s&&s();var u=n.parent,d=u&&u.storedValue;if(u&&u.isAlive&&d){var c=void 0;i?c=!!i.get(r,d):c=n.root.identifierCache.has(a.targetType,b1(r)),c?s=a.addTargetNodeWatcher(n,r):l||a.fireInvalidated("invalidSnapshotReference",n,r,null)}};n.state===Ji.FINALIZED?o(!0):(n.isRoot||n.root.registerHook(yi.afterCreationFinalization,function(){n.parent&&n.parent.createObservableInstanceIfNeeded()}),n.registerHook(yi.afterAttach,function(){o(!1)}))}}}),t})(Wp),oPe=(function(e){mr(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=Mr(a)?WDe(a):a,o=new aPe(a,this.targetType),l=Yd(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=Mr(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})(goe),lPe=(function(e){mr(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=Mr(a)?this.options.set(a,n?n.storedValue:null):a,o=Yd(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=Mr(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})(goe);function boe(e,t){var n=t||void 0,r=t?t.onInvalidated:void 0;return n&&(n.get||n.set)?new lPe(e,{get:n.get,set:n.set},r):new oPe(e,r)}function uPe(e,t){var n=boe(e,is(is({},t),{onInvalidated:function(r){t&&t.onInvalidated&&t.onInvalidated(r),r.removeRef()}}));return t&&t.acceptsUndefined===!1?n:hoe(n)}var voe=(function(e){mr(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:On.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 Vy))throw new Nt("Identifier types can only be instantiated as direct child of a model type");return Yd(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 Nt("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?ds(r,n,"Value is not a valid ".concat(this.describe(),", expected a ").concat(this.validType)):us()}}),t})(Wp),cPe=(function(e){mr(t,e);function t(){var n=e.call(this,"identifier","string")||this;return Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:On.Identifier}),n}return Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifier"}}),t})(voe),dPe=(function(e){mr(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})(voe),fPe=new cPe,pPe=new dPe;function b1(e){return""+e}function s5(e){return typeof e=="string"||typeof e=="number"}function hPe(e){return new mPe(e)}var mPe=(function(e){mr(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:On.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 us();var i=this.options.getValidationMessage(n);return i?ds(r,n,"Invalid value for type '".concat(this.name,"': ").concat(i)):us()}}),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 Yd(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})(Wp),_t={enumeration:VLe,model:DLe,compose:LLe,custom:hPe,reference:boe,safeReference:uPe,union:XC,optional:op,literal:poe,maybe:hoe,maybeNull:QLe,refinement:HLe,string:soe,boolean:loe,number:ooe,integer:MLe,float:jLe,finite:FLe,Date:foe,map:OLe,array:RLe,frozen:rPe,identifier:fPe,identifierNumber:pPe,late:ePe,lazy:tPe,undefined:coe,null:uoe,snapshotProcessor:ALe};const gPe=_t.enumeration("TerminalStatus",["running","exited","error"]),bPe=_t.model("Terminal",{id:_t.identifier,name:_t.string,cwd:_t.string,status:gPe,exitCode:_t.maybe(_t.number),cols:_t.number,rows:_t.number,createdAt:_t.number,tabId:_t.maybeNull(_t.string),positionInTab:_t.optional(_t.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}})),vPe=_t.model("Tab",{id:_t.identifier,name:_t.string,position:_t.number,directory:_t.maybeNull(_t.string),createdAt:_t.number}).volatile(()=>({isPending:!1})).views(e=>({get terminals(){const t=Hse(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}})),yPe=_t.map(_t.string),_Pe=_t.model("ViewState",{focusedTerminals:_t.optional(yPe,{}),currentView:_t.maybeNull(_t.string),currentTaskId:_t.maybeNull(_t.string),isTabVisible:_t.maybeNull(_t.boolean),viewUpdatedAt:_t.maybeNull(_t.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 fP(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}function xW(){return`temp-${fP()}`}const xPe=_t.model("TerminalsStore",{items:_t.array(bPe)}).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)){Lt.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(),SS(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()}})),EPe=_t.model("TabsStore",{items:_t.array(vPe)}).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)){Lt.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&&SS(n)},replaceAll(t){e.items.clear();for(const n of t)e.items.push(n)},clear(){e.items.clear()}})),SPe=_t.model("RootStore",{terminals:_t.optional(xPe,{items:[]}),tabs:_t.optional(EPe,{items:[]}),viewState:_t.optional(_Pe,{})}).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=()=>cP(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=fP(),i=xW(),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=fW(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:`
|
|
36
|
-
`}}),!1):(u.type==="keydown"&&u.key==="Escape"&&(u.preventDefault(),window.parent!==window&&u.stopPropagation()),!0));const s=r.onData(u=>{new RegExp("^\x1B\\[<35;\\d+;\\d+[Mm]$").test(u)||new RegExp("^\x1B\\]").test(u)||new RegExp("^\x1BP").test(u)||/\$y/.test(u)||new RegExp("^\x1B\\[\\d+;\\d+R$").test(u)||new RegExp("^\x1B\\[[?>\\d;]*c$").test(u)||t().send({type:"terminal:input",payload:{terminalId:n,data:u}})}),o=()=>{this.setLastFocusedTerminal(n)};r.textarea?.addEventListener("focus",o),i?.onAttached&&(e.terminalsReadyForCallback.has(n)?(t().log.ws.debug("attachXterm: terminal already attached, calling callback immediately",{terminalId:n}),e.terminalsReadyForCallback.delete(n),setTimeout(()=>i.onAttached?.(n),0)):(t().log.ws.debug("attachXterm: registering onAttached callback",{terminalId:n,existingCallbacks:Array.from(e.onAttachedCallbacks.keys())}),e.onAttachedCallbacks.set(n,i.onAttached)));const l=()=>{s.dispose(),r.textarea?.removeEventListener("focus",o),e.terminals.get(n)?.setXterm(null)};return a.setAttachCleanup(l),t().send({type:"terminal:attach",payload:{terminalId:n}}),l},requestAttach(n){t().send({type:"terminal:attach",payload:{terminalId:n}})},clearTerminalBuffer(n){t().send({type:"terminal:clearBuffer",payload:{terminalId:n}})},assignTerminalToTab(n,r,i){t().send({type:"terminal:assignTab",payload:{terminalId:n,tabId:r,positionInTab:i}}),e.terminals.get(n)?.assignToTab(r,i)},createTab(n,r,i,a){const s=fP(),o=xW(),l=r??e.tabs.items.length,u={id:o,name:n,position:l,directory:i??null,createdAt:Date.now()},d=fW(e.tabs);e.tabs.add(u),d.stop(),e.tabs.get(o)?.setPending(!0),e.pendingTabCreation=o,e.pendingUpdates.set(s,{entityType:"tab",tempId:o,inversePatches:d.inversePatches,createdAt:Date.now()}),t().send({type:"tab:create",payload:{name:n,position:r,directory:i,adoptTerminalId:a,requestId:s,tempId:o}}),t().log.ws.debug("createTab optimistic",{requestId:s,tempId:o,name:n,adoptTerminalId:a})},updateTab(n,r){t().send({type:"tab:update",payload:{tabId:n,...r}}),e.tabs.get(n)?.updateFromServer(r)},deleteTab(n){t().send({type:"tab:delete",payload:{tabId:n}}),e.tabs.remove(n),e.viewState.clearFocusedTerminalForTab(n)},reorderTab(n,r){const i=e.tabs.get(n);if(!i)return;const a=i.position;if(t().send({type:"tab:reorder",payload:{tabId:n,position:r}}),r>a)for(const s of e.tabs.items)s.position>a&&s.position<=r&&s.setPosition(s.position-1);else if(r<a)for(const s of e.tabs.items)s.position>=r&&s.position<a&&s.setPosition(s.position+1);i.setPosition(r)},handleMessage(n){const{type:r,payload:i}=n;switch(r){case"terminals:list":e.terminals.replaceAll(i.terminals);break;case"terminal:created":{const{terminal:a,isNew:s,requestId:o,tempId:l}=i;if(o&&l){const u=e.pendingUpdates.get(o);if(u&&u.tempId===l){e.pendingUpdates.delete(o);const d=e.terminals.get(l);if(d){const c=d.xterm,m=e.onAttachedCallbacks.get(l),g=d.attachCleanup;if(t().log.ws.info("terminal:created optimistic handling",{tempId:l,realId:a.id,hasXterm:!!c,hasCallback:!!m,isNew:s}),g&&g(),d.setXterm(null),d.setAttachCleanup(null),e.onAttachedCallbacks.delete(l),s){const _=d.isStartingUp,x=e.terminals.items.findIndex(y=>y.id===l);x>=0&&SS(e.terminals.items[x]),e.terminals.add(a);const b=e.terminals.get(a.id);_&&b&&(b.setStartingUp(!0),t().log.ws.info("terminal:created transferred isStartingUp",{tempId:l,realId:a.id,isStartingUp:b.isStartingUp})),t().log.ws.info("terminal:created re-attaching xterm",{realId:a.id,hasRealTerminal:!!b,hasXterm:!!c,willAttach:!!(b&&c)}),b&&c?this.attachXterm(a.id,c,{onAttached:m}):m&&(t().log.ws.info("terminal:created preserving callback for later",{realId:a.id}),e.onAttachedCallbacks.set(a.id,m)),e.newTerminalIds.delete(l),e.newTerminalIds.add(a.id);const v=e.terminalsPendingStartup.get(l);v&&(e.terminalsPendingStartup.delete(l),e.terminalsPendingStartup.set(a.id,v),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:!!c,hasPendingStartup:!!v})}else{const _=e.terminals.items.findIndex(b=>b.id===l);_>=0&&SS(e.terminals.items[_]),e.newTerminalIds.delete(l),e.terminalsPendingStartup.delete(l),e.terminals.has(a.id)||e.terminals.add(a),e.terminals.get(a.id)&&c&&this.attachXterm(a.id,c,{onAttached:m}),t().log.ws.debug("terminal:created deduplicated",{requestId:o,tempId:l,existingId:a.id,xtermReattached:!!c})}}break}}e.terminals.add(a),s&&e.newTerminalIds.add(a.id);break}case"terminal:destroyed":{const{terminalId:a}=i;e.terminals.remove(a),e.newTerminalIds.delete(a),e.terminalsReadyForCallback.delete(a),e.onAttachedCallbacks.delete(a);break}case"terminal:output":{const{terminalId:a,data:s}=i,o=e.terminals.get(a);o?.xterm?o.xterm.write(s):t().log.ws.warn("terminal:output but no xterm",{terminalId:a});break}case"terminal:attached":{const{terminalId:a,buffer:s}=i,o=e.terminals.get(a);t().log.ws.info("terminal:attached received",{terminalId:a,hasTerminal:!!o,hasXterm:!!o?.xterm,bufferLength:s?.length??0,hasCallback:e.onAttachedCallbacks.has(a),isReadyForCallback:e.terminalsReadyForCallback.has(a),registeredCallbacks:Array.from(e.onAttachedCallbacks.keys())});const l=()=>{const u=e.onAttachedCallbacks.get(a);u?(e.onAttachedCallbacks.delete(a),t().log.ws.debug("terminal:attached calling callback",{terminalId:a}),u(a)):(t().log.ws.debug("terminal:attached no callback yet, marking ready",{terminalId:a}),e.terminalsReadyForCallback.add(a))};o?.xterm?(o.xterm.reset(),s?o.xterm.write(s,l):l()):l();break}case"terminal:bufferCleared":{const{terminalId:a}=i,s=e.terminals.get(a);s?.xterm&&s.xterm.reset();break}case"terminal:exit":{const{terminalId:a,exitCode:s}=i;e.terminals.get(a)?.markExited(s);break}case"terminal:renamed":{const{terminalId:a,name:s}=i;e.terminals.get(a)?.rename(s);break}case"terminal:tabAssigned":{const{terminalId:a,tabId:s,positionInTab:o}=i;e.terminals.get(a)?.assignToTab(s,o);break}case"tabs:list":e.tabs.replaceAll(i.tabs),e.initialized=!0;break;case"tab:created":{const{tab:a,requestId:s,tempId:o,adoptTerminalId:l}=i;if(s&&o){const u=e.pendingUpdates.get(s);if(u&&u.tempId===o){e.pendingUpdates.delete(s),e.tabs.get(o)&&(e.tabs.remove(o),e.tabs.add(a),e.pendingTabCreation=null,l||(e.lastCreatedTabId=a.id),t().log.ws.debug("tab:created confirmed",{requestId:s,tempId:o,realId:a.id,adoptTerminalId:l}));break}}e.tabs.add(a);break}case"tab:updated":{const{tabId:a,name:s,directory:o}=i;e.tabs.get(a)?.updateFromServer({name:s,directory:o});break}case"tab:deleted":{const{tabId:a}=i;e.tabs.remove(a),e.viewState.clearFocusedTerminalForTab(a);break}case"terminal:error":{const{error:a,requestId:s,tempId:o}=i;if(s&&o){const l=e.pendingUpdates.get(s);if(l&&l.tempId===o){e.pendingUpdates.delete(s);for(let u=l.inversePatches.length-1;u>=0;u--)Uy(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}}Lt.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 d=e.pendingUpdates.get(o);if(d&&d.tempId===l)if(e.pendingUpdates.delete(o),d.entityType==="terminal"){const c=e.terminals.get(l);c&&(c.cleanup(),e.terminals.remove(l)),e.newTerminalIds.delete(l),e.terminalsPendingStartup.delete(l)}else d.entityType==="tab"&&e.tabs.remove(l)}if(a==="terminal"){if(e.terminals.has(s)){const d=e.terminals.get(s);d&&(d.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 yoe(){const e=Vg();return C.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 Iie(l);e.writeToTerminal(r,u)}catch(u){Lt.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 Lx="",wPe=_t.model("File",{path:_t.identifier,content:_t.string,originalContent:_t.string,mimeType:_t.string,size:_t.number,lineCount:_t.number,truncated:_t.boolean,isMarkdownView:_t.optional(_t.boolean,!1),mtime:_t.optional(_t.string,"")}).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},setMtime(t){e.mtime=t},reloadFromServer(t){e.content=t.content,e.originalContent=t.content,e.mtime=t.mtime,e.size=t.size,e.lineCount=t.lineCount,e.truncated=t.truncated}})),CPe=_t.model("FilesStore",{selectedFile:_t.maybeNull(_t.string),expandedDirs:_t.array(_t.string),openFiles:_t.map(wPe)}).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()},updateFileTree(t){e.fileTree=t},_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,mtime:t.mtime})},_markFileSaved(t){const n=e.openFiles.get(t);n&&n.markSaved()}})).actions(e=>({loadFileTree:Dx(function*(){if(e.worktreePath){e._setLoadingTree(!0),e._setTreeError(null);try{const t=yield pt(`${Lx}/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:Dx(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 pt(`${Lx}/api/fs/read?${n}`);e._addFile({path:t,content:r.content,mimeType:r.mimeType,size:r.size,lineCount:r.lineCount,truncated:r.truncated,mtime:r.mtime}),e.selectedFile=t}catch(n){e._setLoadError(n instanceof Error?n.message:"Failed to load file")}finally{e._setLoading(!1)}}}),reloadFile:Dx(function*(t){if(!e.worktreePath)return;const n=e.openFiles.get(t);if(n){e._setLoading(!0),e._setLoadError(null);try{const r=new URLSearchParams({path:t,root:e.worktreePath}),i=yield pt(`${Lx}/api/fs/read?${r}`);n.reloadFromServer({content:i.content,mtime:i.mtime,size:i.size,lineCount:i.lineCount,truncated:i.truncated})}catch(r){e._setLoadError(r instanceof Error?r.message:"Failed to reload file")}finally{e._setLoading(!1)}}}),saveFile:Dx(function*(t){if(!e.worktreePath)return;const n=e.openFiles.get(t);if(!(!n||!n.isDirty)){e._setSaving(!0),e._setSaveError(null);try{const r=yield fetch(`${Lx}/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")}));r.success&&(e._markFileSaved(t),r.mtime&&n.setMtime(r.mtime))}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 TPe(){return CPe.create({selectedFile:null,expandedDirs:[],openFiles:{}})}const _oe=C.createContext(null);function APe(e,t=!1,n){const r=C.useMemo(()=>TPe(),[]),i=C.useRef(!1);return C.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 kPe(){const e=C.useContext(_oe);if(!e)throw new Error("useFilesStore must be used within a FilesStoreProvider");return e}function xoe(){const e=kPe();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,reloadFile:e.reloadFile,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,updateFileTree:e.updateFileTree}}const aa="";function o5(){const e=pn();return rn({mutationFn:({id:t,updates:n})=>pt(`${aa}/api/apps/${t}`,{method:"PATCH",body:JSON.stringify(n)}),onSuccess:(t,{id:n})=>{e.invalidateQueries({queryKey:["apps"]}),e.invalidateQueries({queryKey:["apps",n]}),e.invalidateQueries({queryKey:["projects"]})}})}function OPe(){const e=pn();return rn({mutationFn:t=>pt(`${aa}/api/apps/${t}/deploy`,{method:"POST"}),onSettled:(t,n,r)=>{e.invalidateQueries({queryKey:["apps"]}),e.invalidateQueries({queryKey:["apps",r]}),e.invalidateQueries({queryKey:["apps",r,"deployments"]}),e.invalidateQueries({queryKey:["apps",r,"status"]}),e.invalidateQueries({queryKey:["projects"]})}})}function Eoe(){const e=pn();return rn({mutationFn:t=>pt(`${aa}/api/apps/${t}/stop`,{method:"POST"}),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["apps"]}),e.invalidateQueries({queryKey:["apps",n]}),e.invalidateQueries({queryKey:["apps",n,"status"]}),e.invalidateQueries({queryKey:["projects"]})}})}function Soe(){const e=pn();return rn({mutationFn:t=>pt(`${aa}/api/apps/${t}/cancel-deploy`,{method:"POST"}),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["apps"]}),e.invalidateQueries({queryKey:["apps",n]}),e.invalidateQueries({queryKey:["apps",n,"status"]}),e.invalidateQueries({queryKey:["projects"]})}})}function RPe(e,t,n=100){return ln({queryKey:["apps",e,"logs",t,n],queryFn:()=>{const r=new URLSearchParams;return t&&r.set("service",t),r.set("tail",String(n)),pt(`${aa}/api/apps/${e}/logs?${r}`)},enabled:!!e,refetchInterval:5e3})}function woe(e){return ln({queryKey:["apps",e,"status"],queryFn:()=>pt(`${aa}/api/apps/${e}/status`),enabled:!!e,refetchInterval:1e4})}function NPe(e){return ln({queryKey:["apps",e,"deployments"],queryFn:()=>pt(`${aa}/api/apps/${e}/deployments`),enabled:!!e,refetchInterval:5e3})}function IPe(e){return ln({queryKey:["compose","find",e],queryFn:()=>pt(`${aa}/api/compose/find?repoId=${e}`),enabled:!!e})}function DPe(e,t){return ln({queryKey:["compose","file",e,t],queryFn:()=>pt(`${aa}/api/fs/read?path=${encodeURIComponent(t)}&root=${encodeURIComponent(e)}`),enabled:!!e&&!!t})}function LPe(){const e=pn();return rn({mutationFn:({repoPath:t,composeFile:n,content:r})=>pt(`${aa}/api/fs/write`,{method:"POST",body:JSON.stringify({path:n,root:t,content:r})}),onSuccess:(t,{repoPath:n,composeFile:r})=>{e.invalidateQueries({queryKey:["compose","file",n,r]})}})}function PPe(){const e=pn();return rn({mutationFn:t=>pt(`${aa}/api/apps/${t}/sync-services`,{method:"POST"}),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["apps",n]}),e.invalidateQueries({queryKey:["apps"]})}})}function MPe(){return ln({queryKey:["deployment","prerequisites"],queryFn:()=>pt(`${aa}/api/deployment/prerequisites`),staleTime:1e4})}function Coe(){return ln({queryKey:["deployment","settings"],queryFn:()=>pt(`${aa}/api/deployment/settings`)})}function jPe(){const e=pn();return rn({mutationFn:t=>pt(`${aa}/api/deployment/settings`,{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{e.invalidateQueries({queryKey:["deployment","settings"]}),e.invalidateQueries({queryKey:["deployment","prerequisites"]})}})}function FPe(e){return ln({queryKey:["apps",e,"swarm-compose"],queryFn:()=>pt(`${aa}/api/apps/${e}/swarm-compose`),enabled:!1})}const BPe=_t.model("DeploymentStreamStore",{appId:_t.maybeNull(_t.string),isDeploying:_t.optional(_t.boolean,!1),logs:_t.array(_t.string),stage:_t.maybeNull(_t.string),error:_t.maybeNull(_t.string)}).volatile(()=>({eventSource:null,deployment:null})).views(e=>({get typedStage(){return e.stage},get hasLogs(){return e.logs.length>0},get logCount(){return e.logs.length},get logsSnapshot(){return e.logs.slice()},get isComplete(){return!e.isDeploying&&(e.stage==="done"||e.stage==="failed"||e.stage==="cancelled"||!!e.error)}})).actions(e=>{const t=()=>cP(e).log,n=()=>cP(e).invalidateQueries;return{_handleProgress(r){t().debug("Deployment progress",{appId:e.appId,stage:r.stage,message:r.message.slice(0,100)}),e.stage=r.stage,e.logs.push(r.message)},_handleComplete(r){const i=t(),a=e.appId;i.info("Deployment complete",{appId:a,success:r.success,deploymentId:r.deployment?.id}),e.deployment=r.deployment,e.isDeploying=!1,e.stage="done",e.eventSource&&(e.eventSource.close(),e.eventSource=null),a&&n()(a)},_handleError(r){const i=t(),a=e.appId;i.error("Deployment failed",{appId:a,error:r}),e.error=r,e.stage="failed",e.isDeploying=!1,e.eventSource&&(e.eventSource.close(),e.eventSource=null),a&&n()(a)},_handleConnectionLost(){const r=t();e.isDeploying&&(r.error("EventSource connection lost",{appId:e.appId}),e.error="Connection lost during deployment",e.isDeploying=!1,e.stage="failed"),e.eventSource&&(e.eventSource.close(),e.eventSource=null)},deploy(r){const i=t();e.eventSource&&(i.debug("Closing existing EventSource before new deploy",{appId:e.appId}),e.eventSource.close(),e.eventSource=null),i.info("Starting deployment",{appId:r}),e.appId=r,e.isDeploying=!0,e.logs.clear(),e.stage=null,e.error=null,e.deployment=null;const a=new EventSource(`${aa}/api/apps/${r}/deploy/stream`);e.eventSource=a;const s=e;a.addEventListener("progress",o=>{try{const l=JSON.parse(o.data);s._handleProgress(l)}catch(l){i.warn("Failed to parse progress event",{error:String(l)})}}),a.addEventListener("complete",o=>{try{const l=JSON.parse(o.data);s._handleComplete(l)}catch(l){i.warn("Failed to parse complete event",{error:String(l)})}}),a.addEventListener("error",o=>{if(o instanceof MessageEvent)try{const l=JSON.parse(o.data);s._handleError(l.error)}catch{s._handleError("Deployment failed")}else s._handleError("Connection lost during deployment")}),a.onerror=()=>{s._handleConnectionLost()}},watchDeployment(r){const i=t();e.eventSource&&(i.debug("Closing existing EventSource before watching",{appId:e.appId}),e.eventSource.close(),e.eventSource=null),i.info("Watching deployment",{appId:r}),e.appId=r,e.isDeploying=!0,e.logs.clear(),e.stage=null,e.error=null,e.deployment=null;const a=new EventSource(`${aa}/api/apps/${r}/deploy/watch`);e.eventSource=a;const s=e;a.addEventListener("progress",o=>{try{const l=JSON.parse(o.data);s._handleProgress(l)}catch(l){i.warn("Failed to parse progress event",{error:String(l)})}}),a.addEventListener("complete",o=>{try{const l=JSON.parse(o.data);s._handleComplete({success:!0,deployment:l.deployment||{id:"",appId:r,status:"success",startedAt:""}})}catch(l){i.warn("Failed to parse complete event",{error:String(l)})}}),a.addEventListener("error",o=>{if(o instanceof MessageEvent)try{const l=JSON.parse(o.data);s._handleError(l.error)}catch{s._handleError("Deployment failed")}else i.debug("Watch connection ended",{appId:r}),e.isDeploying=!1,e.eventSource&&(e.eventSource.close(),e.eventSource=null)}),a.onerror=()=>{e.isDeploying&&!e.stage&&i.warn("Watch connection failed - no deployment in progress?",{appId:r}),e.isDeploying=!1,e.eventSource&&(e.eventSource.close(),e.eventSource=null)}},reset(){t().debug("Resetting deployment store",{appId:e.appId,hadLogs:e.logs.length}),e.eventSource&&(e.eventSource.close(),e.eventSource=null),e.appId=null,e.isDeploying=!1,e.logs.clear(),e.stage=null,e.error=null,e.deployment=null},disconnect(){const r=t();e.eventSource&&(r.debug("Disconnecting EventSource",{appId:e.appId}),e.eventSource.close(),e.eventSource=null)}}}),Toe=C.createContext(null);function Aoe(){const e=C.useContext(Toe);if(!e)throw new Error("useDeploymentStore must be used within a DeploymentStoreProvider");return e}function UPe({children:e}){const t=pn(),n=C.useMemo(()=>BPe.create({appId:null,isDeploying:!1,logs:[],stage:null,error:null},{log:Lt.deployment,invalidateQueries:i=>{t.invalidateQueries({queryKey:["apps"]}),t.invalidateQueries({queryKey:["apps",i]}),t.invalidateQueries({queryKey:["apps",i,"deployments"]})}}),[t]),r=C.useRef(n);return r.current=n,C.useEffect(()=>()=>{r.current?.disconnect()},[]),p.jsx(Toe.Provider,{value:n,children:e})}const koe=C.createContext(null);function Vg(){const e=C.useContext(koe);if(!e)throw new Error("useStore must be used within a StoreProvider");return e}function $Pe(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/terminal`}function zPe({children:e,wsUrl:t=$Pe(),reconnectInterval:n=2e3,maxReconnectAttempts:r=10}){const i=C.useRef(null),a=C.useRef(0),s=C.useRef(void 0),o=C.useRef(null),[,l]=C.useState({}),u=C.useCallback(c=>{i.current?.readyState===WebSocket.OPEN?(Lt.ws.debug("send",{type:c.type}),i.current.send(JSON.stringify(c))):Lt.ws.warn("send dropped (WebSocket not open)",{type:c.type,readyState:i.current?.readyState??"no socket"})},[]);if(!o.current){const c={send:u,log:Lt};o.current=SPe.create({},c)}const d=o.current;return C.useEffect(()=>{d.setMaxReconnectAttempts(r)},[d,r]),C.useEffect(()=>{let c=!0;const m=()=>{const g=i.current;if(g&&(g.readyState===WebSocket.CONNECTING||g.readyState===WebSocket.OPEN))return;const _=new WebSocket(t);i.current=_,_.onopen=()=>{c&&(Lt.ws.info("WebSocket connected"),d.setConnected(!0),a.current=0)},_.onmessage=x=>{if(c)try{const b=JSON.parse(x.data);d.handleMessage(b)}catch(b){Lt.ws.error("Failed to parse WebSocket message",{error:String(b)})}},_.onclose=()=>{if(c)if(Lt.ws.info("WebSocket disconnected"),d.setConnected(!1),i.current===_&&(i.current=null),a.current<r){a.current++,d.setReconnectAttempt(a.current);const x=n*Math.pow(1.5,a.current-1);Lt.ws.info("Scheduling reconnect",{attempt:a.current,delay:x}),s.current=setTimeout(m,x)}else Lt.ws.warn("Max reconnect attempts reached"),d.setReconnectAttempt(a.current)},_.onerror=x=>{Lt.ws.error("WebSocket error",{event:String(x)})}};return m(),()=>{c=!1,s.current&&clearTimeout(s.current);const g=i.current;g?.readyState===WebSocket.OPEN&&g.close(),i.current=null}},[t,n,r,d]),C.useEffect(()=>{l({})},[]),p.jsx(koe.Provider,{value:d,children:e})}function Ooe(){const e=Vg(),{setTheme:t,resolvedTheme:n,theme:r}=Bd(),{data:i}=oke(),a=C.useRef(void 0),s=C.useRef(!1),o=C.useRef(!1);C.useEffect(()=>zm(()=>e.broadcastedTheme,d=>{d&&(o.current=!0,t(d),e.clearBroadcastedTheme(),setTimeout(()=>{o.current=!1},0))},{fireImmediately:!0}),[e,t]),C.useEffect(()=>{let u=document.querySelector('link[rel="icon"]');u||(u=document.createElement("link"),u.rel="icon",document.head.appendChild(u)),u.type="image/png",u.href="/logo.png"},[]),C.useEffect(()=>{const u=s.current&&i&&a.current===!1;a.current=i,s.current=!0,n&&u&&pt("/api/config/sync-claude-theme",{method:"POST",body:JSON.stringify({resolvedTheme:n})}).catch(()=>{})},[i,n]);const l=C.useCallback(u=>{if(!o.current&&(t(u),e.syncTheme(u),i)){const d=u==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":u;pt("/api/config/sync-claude-theme",{method:"POST",body:JSON.stringify({resolvedTheme:d})}).catch(()=>{})}},[t,e,i]);return{theme:r??"system",resolvedTheme:n,syncClaudeCode:i,changeTheme:l,isUpdating:!1}}let uO=!1;const EW={activeTabId:null,focusedTerminals:{},selectedProjectIds:[],currentView:null,currentTaskId:null,isTabVisible:null,viewUpdatedAt:null};function Roe(){const e=pn(),t=C.useRef(void 0),n=C.useRef({}),{data:r=EW,isLoading:i}=ln({queryKey:["terminal-view-state"],queryFn:async()=>{const g=await fetch("/api/terminal-view-state");if(!g.ok)throw new Error("Failed to fetch terminal view state");return g.json()},staleTime:2e3}),a=rn({mutationFn:async g=>{const _=await fetch("/api/terminal-view-state",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)});if(!_.ok)throw new Error("Failed to update terminal view state");return _.json()},onSuccess:g=>{e.setQueryData(["terminal-view-state"],g)}}),s=C.useRef(a);s.current=a;const o=C.useCallback(g=>{const _=n.current;n.current={..._,...g,focusedTerminals:g.focusedTerminals||_.focusedTerminals?{..._.focusedTerminals,...g.focusedTerminals}:void 0};const x=n.current;e.setQueryData(["terminal-view-state"],b=>{const v=b??EW;return{activeTabId:x.activeTabId!==void 0?x.activeTabId:v.activeTabId,focusedTerminals:{...v.focusedTerminals,...x.focusedTerminals},selectedProjectIds:x.selectedProjectIds!==void 0?x.selectedProjectIds:v.selectedProjectIds,currentView:x.currentView!==void 0?x.currentView:v.currentView,currentTaskId:x.currentTaskId!==void 0?x.currentTaskId:v.currentTaskId,isTabVisible:x.isTabVisible!==void 0?x.isTabVisible:v.isTabVisible,viewUpdatedAt:x.viewUpdatedAt!==void 0?x.viewUpdatedAt:v.viewUpdatedAt}}),t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{s.current.mutate(n.current),n.current={}},500)},[e]),l=C.useCallback((g,_)=>{if(_===null){const x=e.getQueryData(["terminal-view-state"]);if(x){const{[g]:b,...v}=x.focusedTerminals;o({focusedTerminals:v})}}else o({focusedTerminals:{[g]:_}})},[e,o]),u=C.useCallback(g=>r.focusedTerminals[g]??null,[r.focusedTerminals]),d=C.useRef(!1);C.useEffect(()=>{if(uO){d.current=!1;return}uO=!0,d.current=!0;const g=()=>{o({isTabVisible:document.visibilityState==="visible",viewUpdatedAt:new Date().toISOString()})};return document.addEventListener("visibilitychange",g),g(),()=>{document.removeEventListener("visibilitychange",g),d.current&&(uO=!1)}},[o]);const c=C.useCallback((g,_,x)=>{o({currentView:g,currentTaskId:_,activeTabId:x,viewUpdatedAt:new Date().toISOString()})},[o]),m=C.useCallback(g=>{o({selectedProjectIds:g})},[o]);return{viewState:r,isLoading:i,selectedProjectIds:r.selectedProjectIds,getFocusedTerminal:u,setFocusedTerminal:l,setSelectedProjects:m,updateViewTracking:c}}function ts(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 HPe(e,t){return t.trim()?e.map(r=>{let i=ts(r.label,t);if(r.keywords)for(const a of r.keywords){const s=ts(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 VPe(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 WPe({open:e,onOpenChange:t,onNewTask:n,onShowShortcuts:r,onOpenInEditor:i}){const{t:a}=Ct("navigation"),[s,o]=C.useState(!1),l=e??s,u=t??o,[d,c]=C.useState(""),[m,g]=C.useState(0),_=C.useRef(null),x=C.useRef(null),b=Sa(),v=C.useMemo(()=>[{id:"goto-tasks",label:a("commandPalette.commands.goToTasks"),shortcut:"meta+1",keywords:["kanban","board","home"],category:"navigation",icon:p.jsx(te,{icon:qL,size:16,strokeWidth:2}),action:()=>{b({to:"/tasks"}),u(!1)}},{id:"goto-terminals",label:a("commandPalette.commands.goToTerminals"),shortcut:"meta+2",keywords:["shell","console","cli"],category:"navigation",icon:p.jsx(te,{icon:ISe,size:16,strokeWidth:2}),action:()=>{b({to:"/terminals"}),u(!1)}},{id:"goto-projects",label:a("commandPalette.commands.goToProjects"),shortcut:"meta+3",keywords:["repos","repositories","apps","deploy","docker"],category:"navigation",icon:p.jsx(te,{icon:Ds,size:16,strokeWidth:2}),action:()=>{b({to:"/projects"}),u(!1)}},{id:"goto-review",label:a("commandPalette.commands.goToReview"),shortcut:"meta+4",keywords:["pr","pull request","issues","github"],category:"navigation",icon:p.jsx(te,{icon:Ku,size:16,strokeWidth:2}),action:()=>{b({to:"/review"}),u(!1)}},{id:"goto-monitoring",label:a("commandPalette.commands.goToMonitoring"),shortcut:"meta+5",keywords:["system","cpu","memory","processes","usage"],category:"navigation",icon:p.jsx(te,{icon:iie,size:16,strokeWidth:2}),action:()=>{b({to:"/monitoring"}),u(!1)}},{id:"goto-settings",label:a("commandPalette.commands.goToSettings"),shortcut:"meta+,",keywords:["preferences","config","configuration"],category:"navigation",icon:p.jsx(te,{icon:mie,size:16,strokeWidth:2}),action:()=>{b({to:"/settings"}),u(!1)}},{id:"new-task",label:a("commandPalette.commands.newTask"),shortcut:"meta+j",keywords:["create","add"],category:"actions",icon:p.jsx(te,{icon:jm,size:16,strokeWidth:2}),action:()=>{u(!1),n?.()}},{id:"open-in-editor",label:a("commandPalette.commands.openInEditor"),shortcut:"meta+e",keywords:["editor","code","vscode","cursor","folder","path"],category:"actions",icon:p.jsx(te,{icon:WL,size:16,strokeWidth:2}),action:()=>{u(!1),i?.()}},{id:"show-shortcuts",label:a("commandPalette.commands.keyboardShortcuts"),shortcut:"meta+/",keywords:["help","hotkeys","keys"],category:"actions",icon:p.jsx(te,{icon:lie,size:16,strokeWidth:2}),action:()=>{u(!1),r?.()}},{id:"goto-task-terminals",label:a("commandPalette.commands.goToTaskTerminals"),shortcut:"meta+u",keywords:["tasks","shell","console","cli"],category:"actions",icon:p.jsx(te,{icon:qL,size:16,strokeWidth:2}),action:()=>{b({to:"/terminals",search:{tab:"all-tasks"}}),u(!1)}},{id:"goto-project-terminals",label:a("commandPalette.commands.goToProjectTerminals"),shortcut:"meta+i",keywords:["projects","shell","console","cli","workspace"],category:"actions",icon:p.jsx(te,{icon:Ds,size:16,strokeWidth:2}),action:()=>{b({to:"/terminals",search:R=>({...R,tab:"all-projects"})}),u(!1)}}],[b,n,r,i,u,a]),y=C.useMemo(()=>HPe(v,d),[v,d]),E=C.useMemo(()=>VPe(y),[y]),T=C.useMemo(()=>{const O=[],R=["navigation","actions"];for(const N of R){const D=E.get(N);D&&O.push(...D)}return O},[E]);C.useEffect(()=>{g(0)},[d]),C.useEffect(()=>{if(!x.current)return;const O=x.current.querySelector('[data-selected="true"]');O&&O.scrollIntoView({block:"nearest"})},[m]),Ra("meta+k",()=>u(!0),{allowInInput:!0,allowInTerminal:!0}),Ra("meta+1",()=>b({to:"/tasks"}),{allowInInput:!0,allowInTerminal:!0}),Ra("meta+2",()=>b({to:"/terminals"}),{allowInInput:!0,allowInTerminal:!0}),Ra("meta+3",()=>b({to:"/projects"}),{allowInInput:!0,allowInTerminal:!0}),Ra("meta+u",()=>{b({to:"/terminals",search:{tab:"all-tasks"}})},{allowInInput:!0,allowInTerminal:!0}),Ra("meta+i",()=>{b({to:"/terminals",search:O=>({...O,tab:"all-projects"})})},{allowInInput:!0,allowInTerminal:!0}),Ra("meta+4",()=>b({to:"/review"}),{allowInInput:!0,allowInTerminal:!0}),Ra("meta+5",()=>b({to:"/monitoring"}),{allowInInput:!0,allowInTerminal:!0}),Ra("meta+,",()=>b({to:"/settings"}),{allowInInput:!0,allowInTerminal:!0}),Ra("meta+j",()=>{n?.()},{allowInInput:!1,deps:[n]}),Ra("meta+/",()=>{r?.()},{allowInInput:!0,allowInTerminal:!0,deps:[r]}),Ra("meta+e",()=>{i?.()},{allowInInput:!0,allowInTerminal:!0,deps:[i]});const w=C.useCallback(O=>{switch(O.key){case"ArrowDown":O.preventDefault(),g(R=>Math.min(R+1,T.length-1));break;case"ArrowUp":O.preventDefault(),g(R=>Math.max(R-1,0));break;case"Enter":O.preventDefault(),T[m]&&T[m].action();break;case"Escape":O.preventDefault(),u(!1);break;case"1":O.preventDefault(),b({to:"/tasks"}),u(!1);break;case"2":O.preventDefault(),b({to:"/terminals"}),u(!1);break;case"3":O.preventDefault(),b({to:"/projects"}),u(!1);break;case"4":O.preventDefault(),b({to:"/review"}),u(!1);break;case"5":O.preventDefault(),b({to:"/monitoring"}),u(!1);break}},[T,m,u,b]);C.useEffect(()=>{l&&(c(""),g(0),setTimeout(()=>_.current?.focus(),50))},[l]),C.useEffect(()=>{const O=R=>{if(R.data?.type==="vibora:action")switch(R.data.action){case"openCommandPalette":u(!0);break;case"openNewTask":n?.();break;case"showShortcuts":r?.();break}};return window.addEventListener("message",O),()=>window.removeEventListener("message",O)},[u,n,r]);let A=0;return p.jsx(So,{open:l,onOpenChange:u,children:p.jsxs(wo,{className:"sm:max-w-lg p-0 gap-0 overflow-hidden",showCloseButton:!1,onKeyDown:w,children:[p.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[p.jsx("span",{className:"text-muted-foreground mr-2",children:">"}),p.jsx(Ht,{ref:_,value:d,onChange:O=>c(O.target.value),placeholder:a("commandPalette.placeholder"),className:"border-0 ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 px-0 h-12"}),p.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"})]}),p.jsx("div",{ref:x,className:"max-h-80 overflow-y-auto p-2",children:y.length===0?p.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:a("commandPalette.noResults")}):p.jsx(p.Fragment,{children:["navigation","actions"].map(O=>{const R=E.get(O);return!R||R.length===0?null:p.jsxs("div",{className:"mb-2 last:mb-0",children:[p.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:a(`commandPalette.categories.${O}`)}),R.map(N=>{const D=A++,L=D===m;return p.jsxs("button",{"data-selected":L,onClick:()=>N.action(),onMouseEnter:()=>g(D),className:ze("flex w-full items-center gap-3 rounded-md px-2 py-2 text-sm",L?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"),children:[N.icon&&p.jsx("span",{className:"text-muted-foreground",children:N.icon}),p.jsx("span",{className:"flex-1 text-left",children:N.label}),N.shortcut&&p.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:xie(N.shortcut)})]},N.id)})]},O)})})})]})})}const SW={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 GPe({className:e,rows:t=100,cols:n=10,tileClassName:r,tileSize:i="md"}){return p.jsx("div",{className:ze("relative z-0 flex w-full h-full justify-center",e),children:Array.from({length:t}).map((a,s)=>p.jsx("div",{className:ze(SW[i],"border-l dark:border-neutral-900 border-neutral-200 relative",r),children:Array.from({length:n}).map((o,l)=>p.jsx("div",{className:ze(SW[i],"border-r border-t dark:border-neutral-900 border-neutral-200 relative hover:bg-tile transition-colors",r)},`col-${l}`))},`row-${s}`))})}const qPe=["/","/tasks","/terminals","/worktrees","/repositories","/review","/monitoring","/settings"];function KPe(){const e=Ei({select:n=>n.location.pathname});return qPe.some(n=>e===n||e.startsWith(n+"/"))?p.jsx("div",{className:"absolute inset-0 overflow-hidden pointer-events-none -z-10",children:p.jsx(GPe,{rows:100,cols:50,tileSize:"sm"})}):null}if(!C.useState)throw new Error("mobx-react-lite requires React with Hooks support");if(!Lse)throw new Error("mobx-react-lite@3 requires mobx at least version 6 to be available");function YPe(e){e()}function XPe(e){e||(e=YPe),uDe({reactionScheduler:e})}function ZPe(e){return dDe(e)}var QPe=1e4,JPe=1e4,eMe=(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=QPe),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,JPe))}}),e})(),tMe=typeof FinalizationRegistry<"u"?FinalizationRegistry:eMe,pP=new tMe(function(e){var t;(t=e.reaction)===null||t===void 0||t.dispose(),e.reaction=null});function wW(e){e.reaction=new tu("observer".concat(e.name),function(){var t;e.stateVersion=Symbol(),(t=e.onStoreChange)===null||t===void 0||t.call(e)})}function nMe(e,t){t===void 0&&(t="observed");var n=le.useRef(null);if(!n.current){var r={reaction:null,onStoreChange:null,stateVersion:Symbol(),name:t,subscribe:function(o){return pP.unregister(r),r.onStoreChange=o,r.reaction||(wW(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||(wW(i),pP.register(n,i,i)),le.useDebugValue(i.reaction,ZPe),U3.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 cO,dO,Noe=typeof Symbol=="function"&&Symbol.for,rMe=(dO=(cO=Object.getOwnPropertyDescriptor(function(){},"name"))===null||cO===void 0?void 0:cO.configurable)!==null&&dO!==void 0?dO:!1,CW=Noe?Symbol.for("react.forward_ref"):typeof C.forwardRef=="function"&&C.forwardRef(function(e){return null}).$$typeof,TW=Noe?Symbol.for("react.memo"):typeof C.memo=="function"&&C.memo(function(e){return null}).$$typeof;function Wg(e,t){var n;if(TW&&e.$$typeof===TW)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(CW&&e.$$typeof===CW&&(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 nMe(function(){return i(o,l)},a)};return s.displayName=e.displayName,rMe&&Object.defineProperty(s,"name",{value:e.name,writable:!0,configurable:!0}),e.contextTypes&&(s.contextTypes=e.contextTypes),r&&(s=C.forwardRef(s)),s=C.memo(s),aMe(e,s),s}var iMe={$$typeof:!0,render:!0,compare:!0,type:!0,displayName:!0};function aMe(e,t){Object.keys(e).forEach(function(n){iMe[n]||Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})}var fO;XPe(jr.unstable_batchedUpdates);fO=pP.finalizeAllImmediately;const sMe=Wg(function(){const t=Vg();if(t.connected||!t.hasEverConnected)return null;const n=t.reconnectAttempt>0&&t.reconnectAttempt<t.maxReconnectAttempts,r=t.reconnectAttempt>=t.maxReconnectAttempts;return p.jsx("div",{className:ze("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?p.jsxs(p.Fragment,{children:[p.jsx(te,{icon:ai,size:16,strokeWidth:2}),p.jsx("span",{children:"Connection lost. Please check if the server is running."})]}):n?p.jsxs(p.Fragment,{children:[p.jsx(te,{icon:Ft,size:16,strokeWidth:2,className:"animate-spin"}),p.jsxs("span",{children:["Reconnecting... (attempt ",t.reconnectAttempt,"/",t.maxReconnectAttempts,")"]})]}):p.jsxs(p.Fragment,{children:[p.jsx(te,{icon:ai,size:16,strokeWidth:2}),p.jsx("span",{children:"Disconnected from server"})]})})});function oMe(){return ln({queryKey:["system","dependencies"],queryFn:()=>pt("/api/system/dependencies"),staleTime:30*1e3,refetchOnWindowFocus:!0})}function lMe(){const{data:e,isLoading:t}=oMe(),{data:n,isLoading:r}=Vj(),[i,a]=C.useState(!1),[s,o]=C.useState(!1),l=n??"claude",u=il[l],d=$ae[l],c=zae[l],m=C.useCallback(async()=>{try{await navigator.clipboard.writeText(d),o(!0),setTimeout(()=>o(!1),2e3)}catch{}},[d]),g=C.useCallback(()=>{a(!0)},[]);return t||r||i||(l==="claude"?e?.claudeCode?.installed:e?.openCode?.installed)?null:p.jsxs("div",{className:ze("flex items-center justify-between gap-4 px-4 py-3","border-b bg-amber-500/10 border-amber-500/30"),role:"alert",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(te,{icon:ai,size:18,strokeWidth:2,className:"shrink-0 text-amber-600 dark:text-amber-400"}),p.jsxs("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-4",children:[p.jsxs("span",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:[u," CLI not found"]}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.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:d}),p.jsx("button",{onClick:m,className:ze("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:s?"Copied!":"Copy to clipboard",children:p.jsx(te,{icon:s?di:wC,size:14,strokeWidth:2})})]})]})]}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:ze("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"}),p.jsx("button",{onClick:g,className:ze("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:p.jsx(te,{icon:Yr,size:16,strokeWidth:2})})]})]})}const uMe=[{titleKey:"navigation",items:[{labelKey:"goToTasks",shortcut:"meta+1"},{labelKey:"goToTerminals",shortcut:"meta+2"},{labelKey:"goToTaskTerminals",shortcut:"meta+u"},{labelKey:"goToProjectTerminals",shortcut:"meta+i"},{labelKey:"goToProjects",shortcut:"meta+3"},{labelKey:"goToReview",shortcut:"meta+4"},{labelKey:"goToMonitoring",shortcut:"meta+5"},{labelKey:"goToSettings",shortcut:"meta+,"}]},{titleKey:"actions",items:[{labelKey:"commandPalette",shortcut:"meta+k"},{labelKey:"newTask",shortcut:"meta+j"},{labelKey:"openInEditor",shortcut:"meta+e"},{labelKey:"keyboardShortcuts",shortcut:"meta+/"}]},{titleKey:"terminals",items:[{labelKey:"newTerminal",shortcut:"meta+d"},{labelKey:"closeTerminal",shortcut:"meta+w"}]},{titleKey:"general",items:[{labelKey:"closeModal",shortcut:"escape"},{labelKey:"submitForm",shortcut:"meta+enter"}]}];function cMe({open:e,onOpenChange:t}){const{t:n}=Ct("navigation");return p.jsx(So,{open:e,onOpenChange:t,children:p.jsxs(wo,{className:"sm:max-w-md",children:[p.jsx(cl,{children:p.jsx(dl,{children:n("shortcuts.title")})}),p.jsx(Bg,{className:"max-h-[60vh]",children:p.jsx("div",{className:"space-y-4 mt-2 pr-4",children:uMe.map(r=>p.jsxs("div",{children:[p.jsx("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:n(`shortcuts.groups.${r.titleKey}`)}),p.jsx("div",{className:"space-y-1",children:r.items.map(i=>p.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[p.jsx("span",{className:"text-sm",children:n(`shortcuts.labels.${i.labelKey}`)}),p.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:xie(i.shortcut)})]},i.shortcut))})]},r.titleKey))})})]})})}function dMe(e,t){return e&&(e==="~"?t:e.startsWith("~/")?t+e.slice(1):e)}const fMe={vscode:"vscode",cursor:"cursor",windsurf:"windsurf",zed:"zed",antigravity:"antigravity"};function ZC(e,t,n,r){const i=fMe[t];if(!n)return`${i}://file${e}`;const a=r!==22?`${n}:${r}`:n;return`${i}://vscode-remote/ssh-remote+${a}${e}`}function Ioe(e){return{vscode:"VS Code",cursor:"Cursor",windsurf:"Windsurf",zed:"Zed",antigravity:"Antigravity"}[e]}function Wl(e){window.parent!==window?window.parent.postMessage({type:"vibora:openUrl",url:e},"*"):window.open(e,"_blank")}function pMe({open:e,onOpenChange:t}){const{t:n}=Ct("navigation"),[r,i]=C.useState(""),[a,s]=C.useState(!1),{data:o}=u1(),{data:l}=c1(),{data:u}=d1(),{data:d}=rke(),{data:c,isLoading:m}=eke(r.trim()||null);C.useEffect(()=>{e&&i("")},[e]);const g=c?.exists&&c?.isDirectory,_=r.trim()&&c&&!m?c.exists?c.isDirectory?null:n("openInEditor.pathNotDirectory"):n("openInEditor.pathNotFound"):null,x=()=>{if(!r.trim()||!g)return;const y=dMe(r.trim(),d),E=ZC(y,o??"vscode",l??"",u??22);Wl(E),t(!1)},b=y=>{i(y)},v=Ioe(o??"vscode");return p.jsxs(p.Fragment,{children:[p.jsx(So,{open:e,onOpenChange:t,children:p.jsxs(wo,{className:"sm:max-w-md",children:[p.jsxs(cl,{children:[p.jsx(dl,{children:n("openInEditor.title")}),p.jsx(Up,{children:n("openInEditor.description",{editor:v})})]}),p.jsx("div",{className:"space-y-4",children:p.jsxs("div",{className:"space-y-2",children:[p.jsx("label",{className:"text-sm font-medium",children:n("openInEditor.pathLabel")}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx(Ht,{value:r,onChange:y=>i(y.target.value),placeholder:n("openInEditor.pathPlaceholder"),onKeyDown:y=>y.key==="Enter"&&x(),className:`flex-1 font-mono text-sm ${_?"border-destructive":""}`}),p.jsx(Be,{variant:"outline",size:"icon",onClick:()=>s(!0),title:n("openInEditor.browse"),children:p.jsx(te,{icon:Ba,size:16,strokeWidth:2})})]}),_?p.jsx("p",{className:"text-xs text-destructive",children:_}):p.jsx("p",{className:"text-xs text-muted-foreground",children:n("openInEditor.pathHint")})]})}),p.jsxs(i1,{children:[p.jsx(RC,{render:p.jsx(Be,{variant:"outline"}),children:n("openInEditor.cancel")}),p.jsx(Be,{onClick:x,disabled:!r.trim()||!g||m,children:n("openInEditor.open")})]})]})}),p.jsx(bd,{open:a,onOpenChange:s,onSelect:b})]})}const hMe=({...e})=>{const{resolvedTheme:t}=Bd();return p.jsx(Owe,{theme:t,className:"toaster group",icons:{success:p.jsx(te,{icon:nl,strokeWidth:2,className:"size-4"}),info:p.jsx(te,{icon:USe,strokeWidth:2,className:"size-4"}),warning:p.jsx(te,{icon:ai,strokeWidth:2,className:"size-4"}),error:p.jsx(te,{icon:HSe,strokeWidth:2,className:"size-4"}),loading:p.jsx(te,{icon:Ft,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})},$i=tye({component:_Me});function mMe(){return kke(),null}function gMe(){return Vae(),null}function bMe(){return Ooe(),null}function vMe(){const e=Ei({select:n=>n.location}),{updateViewTracking:t}=Roe();return C.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 yMe(){const e=Ei({select:t=>t.location});return C.useEffect(()=>{window.parent!==window&&window.parent.postMessage({type:"vibora:route",pathname:e.pathname,search:e.search},"*")},[e.pathname,e.search]),null}function _Me(){const[e,t]=C.useState(null),[n,r]=C.useState(!1),[i,a]=C.useState(!1),[s,o]=C.useState(!1),l=typeof window<"u"&&window.parent!==window,u=C.useCallback(_=>{t(()=>_)},[]),d=C.useCallback(()=>{e?.()},[e]),c=C.useCallback(()=>{r(!0)},[]),m=C.useCallback(()=>{a(!0)},[]),g=C.useCallback(()=>{o(!0)},[]);return p.jsx(Dwe,{children:p.jsxs("div",{className:"flex h-screen flex-col overflow-x-hidden bg-background text-foreground",children:[p.jsx(mMe,{}),p.jsx(gMe,{}),p.jsx(bMe,{}),p.jsx(vMe,{}),p.jsx(yMe,{}),p.jsx(sMe,{}),p.jsx(lMe,{}),p.jsx(wke,{onNewTaskRef:u,onOpenCommandPalette:m}),p.jsxs("main",{className:"isolate flex-1 overflow-hidden relative",children:[p.jsx(KPe,{}),p.jsx(rne,{})]}),p.jsx(WPe,{open:i,onOpenChange:a,onNewTask:d,onShowShortcuts:c,onOpenInEditor:g}),p.jsx(cMe,{open:n,onOpenChange:r}),p.jsx(pMe,{open:s,onOpenChange:o}),p.jsx(hMe,{position:l?"bottom-center":"bottom-right"})]})})}const xMe=Si("/")({beforeLoad:()=>{throw Xl({to:"/tasks"})}});function tr(e,t="Assertion error"){if(!e)throw Error(t)}function Km({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 hP(e,t){return t.sort(e==="horizontal"?EMe:SMe)}function EMe(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function SMe(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function Doe(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 wMe({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}=Doe(r,s),u=e==="horizontal"?o:l;u<a&&(a=u,i=s)}return tr(i,"No rect found"),i}function Loe(e){const{element:t,orientation:n,panels:r,separators:i}=e,a=hP(n,Array.from(t.children).filter(d=>d instanceof HTMLElement).map(d=>({element:d}))).map(({element:d})=>d),s=[];let o=!1,l,u=[];for(const d of a)if(d.hasAttribute("data-panel")){const c=r.find(m=>m.element===d);if(c){if(l){const m=l.element.getBoundingClientRect(),g=d.getBoundingClientRect();let _;if(o){const x=n==="horizontal"?new DOMRect(m.right,m.top,0,m.height):new DOMRect(m.left,m.bottom,m.width,0),b=n==="horizontal"?new DOMRect(g.left,g.top,0,g.height):new DOMRect(g.left,g.top,g.width,0);switch(u.length){case 0:{_=[x,b];break}case 1:{const v=u[0],y=wMe({orientation:n,rects:[m,g],targetRect:v.element.getBoundingClientRect()});_=[v,y===m?b:x];break}default:{_=u;break}}}else u.length?_=u:_=[n==="horizontal"?new DOMRect(m.right,g.top,g.left-m.right,g.height):new DOMRect(g.left,m.bottom,g.width,g.top-m.bottom)];for(const x of _)s.push({group:e,groupSize:Km({group:e}),panels:[l,c],separator:"width"in x?void 0:x,rect:"width"in x?x:x.element.getBoundingClientRect()})}o=!1,l=c,u=[]}}else if(d.hasAttribute("data-separator")){const c=i.find(m=>m.element===d);c?u.push(c):(l=void 0,u=[])}else o=!0;return s}function CMe(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function TMe(e,t){const n=getComputedStyle(e.ownerDocument.body),r=parseFloat(n.fontSize);return t*r}function AMe(e){return e/100*window.innerHeight}function kMe(e){return e/100*window.innerWidth}function OMe(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 Px({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,a]=OMe(n);switch(a){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=TMe(t,i);break}case"em":{r=CMe(t,i);break}case"vh":{r=AMe(i);break}case"vw":{r=kMe(i);break}}return r}function Go(e){return parseFloat(e.toFixed(3))}function AW(e){const{panels:t}=e,n=Km({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 d=Px({groupSize:n,panelElement:i,styleProp:a.collapsedSize});s=Go(d/n*100)}let o;if(a.defaultSize){const d=Px({groupSize:n,panelElement:i,styleProp:a.defaultSize});o=Go(d/n*100)}let l=0;if(a.minSize){const d=Px({groupSize:n,panelElement:i,styleProp:a.minSize});l=Go(d/n*100)}let u=100;if(a.maxSize){const d=Px({groupSize:n,panelElement:i,styleProp:a.maxSize});u=Go(d/n*100)}return{collapsedSize:s,collapsible:a.collapsible===!0,defaultSize:o,minSize:l,maxSize:u,panelId:r.id}})}class RMe{#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 Ia(e,t,n=0){return Math.abs(Go(e)-Go(t))<=n}let no={cursorFlags:0,interactionState:{state:"inactive"},mountedGroups:new Map};const lp=new RMe;function ou(){return no}function yo(e){const t=typeof e=="function"?e(no):e;if(no===t)return no;const n=no;return no={...no,...t},t.cursorFlags!==void 0&&lp.emit("cursorFlagsChange",no.cursorFlags),t.interactionState!==void 0&&lp.emit("interactionStateChange",no.interactionState),t.mountedGroups!==void 0&&(no.mountedGroups.forEach((r,i)=>{r.derivedPanelConstraints.forEach(a=>{if(a.collapsible){const{layout:s}=n.mountedGroups.get(i)??{};if(s){const o=Ia(a.collapsedSize,r.layout[a.panelId]),l=Ia(a.collapsedSize,s[a.panelId]);o&&!l&&(i.inMemoryLastExpandedPanelSizes[a.panelId]=s[a.panelId])}}})}),lp.emit("mountedGroupsChange",no.mountedGroups)),no}const NMe=e=>e,pO=()=>{},Poe=1,Moe=2,joe=4,Foe=8,kW={coarse:10,precise:5};function IMe({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&Poe)!==0,s=(e&Moe)!==0,o=(e&joe)!==0,l=(e&Foe)!==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 hO,kl;function l5(){kl===void 0&&(kl=new CSSStyleSheet,document.adoptedStyleSheets=[kl]);const{cursorFlags:e,interactionState:t}=ou();switch(t.state){case"active":case"hover":{const n=IMe({cursorFlags:e,groups:t.hitRegions.map(i=>i.group),state:t.state}),r=`*{cursor: ${n} !important; ${t.state==="active"?"touch-action: none;":""} }`;if(hO===r)return;hO=r,n?kl.cssRules.length===0?kl.insertRule(r):kl.replaceSync(r):kl.cssRules.length===1&&kl.deleteRule(0);break}case"inactive":{hO=void 0,kl.cssRules.length===1&&kl.deleteRule(0);break}}}function DMe(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 Wy(e,t){return Ia(e,t)?0:e>t?1:-1}function am({panelConstraints:e,size:t}){const{collapsedSize:n=0,collapsible:r,maxSize:i=100,minSize:a=0}=e;if(Wy(t,a)<0)if(r){const s=(n+a)/2;Wy(t,s)<0?t=n:t=a}else t=a;return t=Math.min(i,t),t=Go(t),t}function Gy({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(Ia(e,0))return t;const s=Object.values(t),o=Object.values(i),l=[...s],[u,d]=r;tr(u!=null,"Invalid first pivot index"),tr(d!=null,"Invalid second pivot index");let c=0;if(a==="keyboard"){{const _=e<0?d:u,x=n[_];tr(x,`Panel constraints not found for index ${_}`);const{collapsedSize:b=0,collapsible:v,minSize:y=0}=x;if(v){const E=s[_];if(tr(E!=null,`Previous layout not found for panel index ${_}`),Ia(E,b)){const T=y-E;Wy(T,Math.abs(e))>0&&(e=e<0?0-T:T)}}}{const _=e<0?u:d,x=n[_];tr(x,`No panel constraints found for index ${_}`);const{collapsedSize:b=0,collapsible:v,minSize:y=0}=x;if(v){const E=s[_];if(tr(E!=null,`Previous layout not found for panel index ${_}`),Ia(E,y)){const T=E-b;Wy(T,Math.abs(e))>0&&(e=e<0?0-T:T)}}}}{const _=e<0?1:-1;let x=e<0?d:u,b=0;for(;;){const y=s[x];tr(y!=null,`Previous layout not found for panel index ${x}`);const E=am({panelConstraints:n[x],size:100})-y;if(b+=E,x+=_,x<0||x>=n.length)break}const v=Math.min(Math.abs(e),Math.abs(b));e=e<0?0-v:v}{let _=e<0?u:d;for(;_>=0&&_<n.length;){const x=Math.abs(e)-Math.abs(c),b=s[_];tr(b!=null,`Previous layout not found for panel index ${_}`);const v=b-x,y=am({panelConstraints:n[_],size:v});if(!Ia(b,y)&&(c+=b-y,l[_]=y,c.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?_--:_++}}if(DMe(o,l))return i;{const _=e<0?d:u,x=s[_];tr(x!=null,`Previous layout not found for panel index ${_}`);const b=x+c,v=am({panelConstraints:n[_],size:b});if(l[_]=v,!Ia(v,b)){let y=b-v,E=e<0?d:u;for(;E>=0&&E<n.length;){const T=l[E];tr(T!=null,`Previous layout not found for panel index ${E}`);const w=T+y,A=am({panelConstraints:n[E],size:w});if(Ia(T,A)||(y-=A-T,l[E]=A),Ia(y,0))break;e>0?E--:E++}}}const m=Object.values(l).reduce((_,x)=>x+_,0);if(!Ia(m,100,.1))return i;const g=Object.keys(i);return l.reduce((_,x,b)=>(_[g[b]]=x,_),{})}function Gg(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||Wy(e[n],t[n])!==0)return!1;return!0}function Boe({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:d,orientation:c,panels:m}=l;let g=0;i?c==="horizontal"?g=(e.clientX-i.x)/u*100:g=(e.clientY-i.y)/u*100:c==="horizontal"?g=e.clientX<0?-100:100:g=e.clientY<0?-100:100;const _=n.get(l),{defaultLayoutDeferred:x,derivedPanelConstraints:b,layout:v,separatorToPanels:y}=r.get(l)??{defaultLayoutDeferred:!1};if(b&&_&&v&&y){const E=Gy({delta:g,initialLayout:_,panelConstraints:b,pivotIndices:o.panels.map(T=>m.indexOf(T)),prevLayout:v,trigger:"mouse-or-touch"});if(Gg(E,v)){if(g!==0&&!d)switch(c){case"horizontal":{a|=g<0?Poe:Moe;break}case"vertical":{a|=g<0?joe:Foe;break}}}else{s.set(o.group,{defaultLayoutDeferred:x,derivedPanelConstraints:b,layout:E,separatorToPanels:y});const T=o.group.panels.map(({id:w})=>w).join(",");o.group.inMemoryLayouts[T]=E}}}),yo({cursorFlags:a,mountedGroups:s}),l5()}function OW(e){if(e.defaultPrevented||e.relatedTarget!==null||e.clientX===0&&e.clientY===0)return;const{interactionState:t,mountedGroups:n}=ou();t.state==="active"&&t.hitRegions.forEach(r=>{e.currentTarget===r.group.element&&Boe({event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n})})}function kE(e){const t=e.parentElement;tr(t,"Parent group element not found");const{mountedGroups:n}=ou();for(const[r]of n)if(r.element===t)return r;throw Error("Could not find parent Group for separator element")}function Op({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(!Ia(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const o=n[s];tr(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];tr(o!=null,`No layout data found for index ${s}`);const l=am({panelConstraints:t[s],size:o});o!=l&&(i+=o-l,n[s]=l)}if(!Ia(i,0))for(let s=0;s<t.length;s++){const o=n[s];tr(o!=null,`No layout data found for index ${s}`);const l=o+i,u=am({panelConstraints:t[s],size:l});if(o!==u&&(i-=u-o,n[s]=u,Ia(i,0)))break}const a=Object.keys(e);return n.reduce((s,o,l)=>(s[a[l]]=o,s),{})}function Uoe({groupId:e}){const t=()=>{const{mountedGroups:n}=ou();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=Op({layout:n,panelConstraints:i});return r?s:(Gg(s,l)||yo(u=>({mountedGroups:new Map(u.mountedGroups).set(a,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:l,separatorToPanels:o})})),l)}}}function $oe(e){const{mountedGroups:t}=ou(),n=t.get(e);return tr(n,`Mounted Group ${e.id} not found`),n}function Cf(e,t){const n=kE(e),r=$oe(n),i=n.separators.find(d=>d.element===e);tr(i,"Matching separator not found");const a=r.separatorToPanels.get(i);tr(a,"Matching panels not found");const s=a.map(d=>n.panels.indexOf(d)),o=Uoe({groupId:n.id}).getLayout(),l=Gy({delta:t,initialLayout:o,panelConstraints:r.derivedPanelConstraints,pivotIndices:s,prevLayout:o,trigger:"keyboard"}),u=Op({layout:l,panelConstraints:r.derivedPanelConstraints});Gg(o,u)||yo(d=>({mountedGroups:new Map(d.mountedGroups).set(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,layout:u,separatorToPanels:r.separatorToPanels})}))}function RW(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=kE(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Cf(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Cf(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Cf(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Cf(t,-5);break}case"End":{e.preventDefault(),Cf(t,100);break}case"Enter":{e.preventDefault();const r=kE(t),{derivedPanelConstraints:i,layout:a,separatorToPanels:s}=$oe(r),o=r.separators.find(c=>c.element===t);tr(o,"Matching separator not found");const l=s.get(o);tr(l,"Matching panels not found");const u=l[0],d=i.find(c=>c.panelId===u.id);if(tr(d,"Panel metadata not found"),d.collapsible){const c=a[u.id],m=d.collapsedSize===c?r.inMemoryLastExpandedPanelSizes[u.id]??d.minSize:d.collapsedSize;Cf(t,m-c)}break}case"F6":{e.preventDefault();const r=kE(t).separators.map(s=>s.element),i=Array.from(r).findIndex(s=>s===e.currentTarget);tr(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(),Cf(t,-100);break}}}function LMe(e,t,n){let r,i={x:1/0,y:1/0};for(const a of t){const s=Doe(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 Mx;function PMe(){return Mx===void 0&&(typeof matchMedia=="function"?Mx=!!matchMedia("(pointer:coarse)").matches:Mx=!1),Mx}function MMe(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:DW(e),b:DW(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;tr(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:IW(NW(n.a)),b:IW(NW(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 jMe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function FMe(e){const t=getComputedStyle(zoe(e)??e).display;return t==="flex"||t==="inline-flex"}function BMe(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||FMe(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"||jMe.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function NW(e){let t=e.length;for(;t--;){const n=e[t];if(tr(n,"Missing node"),BMe(n))return n}return null}function IW(e){return e&&Number(getComputedStyle(e).zIndex)||0}function DW(e){const t=[];for(;e;)t.push(e),e=zoe(e);return t}function zoe(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}function UMe(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 $Me({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!(n instanceof HTMLElement)||n.contains(e)||e.contains(n))return!0;if(MMe(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(UMe(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Hoe(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const a=PMe()?kW.coarse:kW.precise,s=Loe(i),o=LMe(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=a&&o.distance.y<=a&&$Me({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function LW(e){if(e.defaultPrevented)return;const{mountedGroups:t}=ou(),n=Hoe(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(d=>{i.add(d)}),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)}),yo({interactionState:{hitRegions:n,initialLayoutMap:s,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}}),n.length&&e.preventDefault()}function PW(e){if(e.defaultPrevented)return;const{interactionState:t,mountedGroups:n}=ou();switch(t.state){case"active":{if(e.type!=="pointerleave"&&e.buttons===0){yo(r=>r.interactionState.state==="inactive"?r:{cursorFlags:0,interactionState:{state:"inactive"}});return}Boe({event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint});break}default:{const r=Hoe(e,n);r.length===0?t.state!=="inactive"&&yo({interactionState:{state:"inactive"}}):yo({interactionState:{hitRegions:r,state:"hover"}}),l5();break}}}function MW(e){if(e.defaultPrevented)return;e.preventDefault();const{interactionState:t}=ou();t.state==="active"&&(yo({cursorFlags:0,interactionState:{state:"inactive"}}),l5())}function jW(e){let t=0,n=0;const r={};for(const a of e)if(a.defaultSize!==void 0){t++;const s=Go(a.defaultSize);n+=s,r[a.panelId]=s}else r[a.panelId]=void 0;const i=e.length-t;if(i!==0){const a=Go((100-n)/i);for(const s of e)s.defaultSize===void 0&&(r[s.panelId]=a)}return r}function zMe(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=Km({group:e});i.onResize({asPercentage:Go(r.inlineSize/a*100),inPixels:r.inlineSize},i.id)}function HMe(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 VMe(e){let t=!0;const n=new Set,r=new Set,i=new ResizeObserver(g=>{for(const _ of g){const{borderBoxSize:x,target:b}=_;if(b===e.element){if(t){if(Km({group:e})===0)return;yo(v=>{const y=v.mountedGroups.get(e);if(y){const E=AW(e),T=y.defaultLayoutDeferred?jW(E):y.layout,w=Op({layout:T,panelConstraints:E});return!y.defaultLayoutDeferred&&Gg(T,w)&&HMe(y.derivedPanelConstraints,E)?v:{mountedGroups:new Map(v.mountedGroups).set(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:E,layout:w,separatorToPanels:y.separatorToPanels})}}return v})}}else zMe(e,b,x)}});i.observe(e.element),e.panels.forEach(g=>{tr(!n.has(g.id),`Panel ids must be unique; id "${g.id}" was used more than once`),n.add(g.id),g.onResize&&i.observe(g.element)});const a=Km({group:e}),s=AW(e),o=e.panels.map(({id:g})=>g).join(",");let l=e.defaultLayout;l&&e.panels.length!==Object.keys(l).length&&(l=void 0);const u=e.inMemoryLayouts[o]??l??jW(s),d=Op({layout:u,panelConstraints:s}),c=Loe(e),m=yo(g=>{const _=new Map;return c.forEach(x=>{x.separator&&_.set(x.separator,x.panels)}),{mountedGroups:new Map(g.mountedGroups).set(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:s,layout:d,separatorToPanels:_})}});return e.element.addEventListener("pointerleave",OW),e.separators.forEach(g=>{tr(!r.has(g.id),`Separator ids must be unique; id "${g.id}" was used more than once`),r.add(g.id),g.element.addEventListener("keydown",RW)}),m.mountedGroups.size===1&&(window.addEventListener("pointerdown",LW),window.addEventListener("pointermove",PW),window.addEventListener("pointerup",MW)),function(){t=!1;const g=yo(_=>{const x=new Map(_.mountedGroups);return x.delete(e),{mountedGroups:x}});e.element.removeEventListener("pointerleave",OW),e.separators.forEach(_=>{_.element.removeEventListener("keydown",RW)}),g.mountedGroups.size===0&&(window.removeEventListener("pointerdown",LW),window.removeEventListener("pointermove",PW),window.removeEventListener("pointerup",MW)),i.disconnect()}}function u5(e){const t=C.useId();return`${e??t}`}const Gp=typeof window<"u"?C.useLayoutEffect:C.useEffect;function c5(e){const t=C.useRef(e);return Gp(()=>{t.current=e},[e]),C.useCallback(n=>t.current?.(n),[t])}function d5(...e){return c5(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function WMe(e){const t=C.useRef({...e});return Gp(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const Voe="--react-resizable-panels--panel--pointer-events";function Woe(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 Goe=C.createContext(null);function GMe(e,t){const n=C.useRef({getLayout:()=>({}),setLayout:NMe});C.useImperativeHandle(t,()=>n.current,[]),Gp(()=>{Object.assign(n.current,Uoe({groupId:e}))})}function qMe({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:s,id:o,onLayoutChange:l,orientation:u="horizontal",style:d,...c}){const m=C.useRef({}),g=c5(z=>{Gg(m.current,z)||(m.current=z,l?.(z))}),_=u5(o),[x,b]=C.useState(!1),[v,y]=C.useState(null),[E,T]=C.useState(n??{}),[w,A]=C.useState([]),[O,R]=C.useState([]),N=C.useRef({lastExpandedPanelSizes:{},layouts:{}}),D=d5(y,a);GMe(_,s);const L=C.useMemo(()=>({id:_,orientation:u,registerPanel:z=>(A(H=>hP(u,[...H,z])),()=>{A(H=>H.filter(q=>q!==z))}),registerSeparator:z=>(R(H=>hP(u,[...H,z])),()=>{R(H=>H.filter(q=>q!==z))})}),[_,u]),U=WMe({defaultLayout:n,disableCursor:r}),M=C.useRef(null);Gp(()=>{if(v===null)return;const z={defaultLayout:U.defaultLayout,disableCursor:!!U.disableCursor,disabled:!!i,element:v,id:_,inMemoryLastExpandedPanelSizes:N.current.lastExpandedPanelSizes,inMemoryLayouts:N.current.layouts,orientation:u,panels:w,separators:O};M.current=z;const H=VMe(z),q=ou().mountedGroups.get(z);if(q){const{defaultLayoutDeferred:j,derivedPanelConstraints:F,layout:G}=q;!j&&F.length>0&&(T(G),g?.(G))}const K=lp.addListener("interactionStateChange",j=>{j.state==="active"?b(j.hitRegions.some(F=>F.group===z)):b(!1)}),$=lp.addListener("mountedGroupsChange",j=>{const F=j.get(z);if(F){const{defaultLayoutDeferred:G,derivedPanelConstraints:V,layout:J}=F;if(G||V.length===0)return;T(J),g?.(J)}});return()=>{M.current=null,H(),K(),$()}},[i,v,_,g,u,w,O,U]),C.useEffect(()=>{const z=M.current;z&&(z.defaultLayout=n,z.disableCursor=!!r)});const W={[Voe]:x?"none":void 0};for(const z in E){const H=Woe(_,z),q=E[z];W[H]=q}return p.jsx(Goe.Provider,{value:L,children:p.jsx("div",{...c,"aria-orientation":u,className:t,"data-group":!0,"data-testid":_,id:_,ref:D,style:{...d,...W,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap"},children:e})})}function f5(){const e=C.useContext(Goe);return tr(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function KMe({groupId:e,panelId:t}){const n=()=>{const{mountedGroups:o}=ou();for(const[l,{defaultLayoutDeferred:u,derivedPanelConstraints:d,layout:c,separatorToPanels:m}]of o)if(l.id===e)return{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:l,layout:c,separatorToPanels:m};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:d,group:c,layout:m,separatorToPanels:g}=n(),_=c.panels.findIndex(y=>y.id===t),x=_===c.panels.length-1,b=Gy({delta:x?l-o:o-l,initialLayout:m,panelConstraints:d,pivotIndices:x?[_-1,_]:[_,_+1],prevLayout:m,trigger:"imperative-api"}),v=Op({layout:b,panelConstraints:d});Gg(m,v)||yo(y=>({mountedGroups:new Map(y.mountedGroups).set(c,{defaultLayoutDeferred:u,derivedPanelConstraints:d,layout:v,separatorToPanels:g})}))};return{collapse:()=>{const{collapsible:o,collapsedSize:l}=r(),u=a();o&&u!==l&&s(l)},expand:()=>{const{collapsible:o,collapsedSize:l,minSize:u}=r(),d=a();o&&d===l&&s(u)},getSize:()=>{const{group:o}=n(),l=a(),{element:u}=i(),d=o.orientation==="horizontal"?u.offsetWidth:u.offsetHeight;return{asPercentage:l,inPixels:d}},isCollapsed:()=>{const{collapsible:o,collapsedSize:l}=r(),u=a();return o&&Ia(l,u)},resize:o=>{if(a()!==o){let l;switch(typeof o){case"number":{const{group:u}=n(),d=Km({group:u});l=Go(o/d*100);break}case"string":{l=parseFloat(o);break}}s(l)}}}}function YMe(e,t){const{id:n}=f5(),r=C.useRef({collapse:pO,expand:pO,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:pO});C.useImperativeHandle(t,()=>r.current,[]),Gp(()=>{Object.assign(r.current,KMe({groupId:n,panelId:e}))})}function XMe({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:d,style:c,...m}){const g=!!s,_=u5(s),[x,b]=C.useState(null),v=d5(b,a),{id:y,registerPanel:E}=f5(),T=u!==null,w=c5(O=>{u?.(O,s)});Gp(()=>{if(x!==null)return E({element:x,id:_,idIsStable:g,onResize:T?w:void 0,panelConstraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:o,minSize:l}})},[n,r,i,x,T,_,g,o,l,w,E]),YMe(_,d);const A=Woe(y,_);return p.jsx("div",{...m,"data-panel":!0,"data-testid":_,id:_,ref:v,style:{...ZMe,flexBasis:0,flexGrow:`var(${A}, 1)`,flexShrink:1,overflow:"hidden",pointerEvents:`var(${Voe})`},children:p.jsx("div",{className:t,style:{width:"100%",height:"100%",...c},children:e})})}const ZMe={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 QMe({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,d=[r,r+1];a=Op({layout:Gy({delta:u-s,initialLayout:e,panelConstraints:t,pivotIndices:d,prevLayout:e,trigger:"keyboard"}),panelConstraints:t})[n],i=Op({layout:Gy({delta:l-s,initialLayout:e,panelConstraints:t,pivotIndices:d,prevLayout:e,trigger:"keyboard"}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:s}}function JMe({children:e,className:t,elementRef:n,id:r,style:i,...a}){const s=u5(r),[o,l]=C.useState({}),[u,d]=C.useState("inactive"),[c,m]=C.useState(null),g=d5(m,n),{id:_,orientation:x,registerSeparator:b}=f5(),v=x==="horizontal"?"vertical":"horizontal";return Gp(()=>{if(c!==null){const y={element:c,id:s},E=b(y),T=lp.addListener("interactionStateChange",A=>{d(A.state!=="inactive"&&A.hitRegions.some(O=>O.separator===y)?A.state:"inactive")}),w=lp.addListener("mountedGroupsChange",A=>{A.forEach(({derivedPanelConstraints:O,layout:R,separatorToPanels:N},D)=>{if(D.id===_){const L=N.get(y);if(L){const U=L[0],M=D.panels.indexOf(U);l(QMe({layout:R,panelConstraints:O,panelId:U.id,panelIndex:M}))}}})});return()=>{T(),w(),E()}}},[c,_,s,b]),p.jsx("div",{...a,"aria-controls":o.valueControls,"aria-orientation":v,"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:g,role:"separator",style:{flexBasis:"auto",...i,flexGrow:0,flexShrink:0},tabIndex:0})}function Mf({className:e,direction:t,...n}){return p.jsx(qMe,{"data-slot":"resizable-panel-group",orientation:t,className:ze("flex h-full w-full data-[orientation=vertical]:flex-col",e),...n})}function so({...e}){return p.jsx(XMe,{"data-slot":"resizable-panel",...e})}function jf({withHandle:e,className:t,...n}){return p.jsx(JMe,{"data-slot":"resizable-handle",className:ze("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&&p.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:[p.jsx("span",{className:"w-0.5 h-0.5 rounded-full bg-muted-foreground"}),p.jsx("span",{className:"w-0.5 h-0.5 rounded-full bg-muted-foreground"}),p.jsx("span",{className:"w-0.5 h-0.5 rounded-full bg-muted-foreground"})]})})}var mO={exports:{}},FW;function e3e(){return FW||(FW=1,(function(e,t){(function(n,r){e.exports=r()})(globalThis,(()=>(()=>{var n={4567:function(s,o,l){var u=this&&this.__decorate||function(y,E,T,w){var A,O=arguments.length,R=O<3?E:w===null?w=Object.getOwnPropertyDescriptor(E,T):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(y,E,T,w);else for(var N=y.length-1;N>=0;N--)(A=y[N])&&(R=(O<3?A(R):O>3?A(E,T,R):A(E,T))||R);return O>3&&R&&Object.defineProperty(E,T,R),R},d=this&&this.__param||function(y,E){return function(T,w){E(T,w,y)}};Object.defineProperty(o,"__esModule",{value:!0}),o.AccessibilityManager=void 0;const c=l(9042),m=l(9924),g=l(844),_=l(4725),x=l(2585),b=l(3656);let v=o.AccessibilityManager=class extends g.Disposable{constructor(y,E,T,w){super(),this._terminal=y,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 A=0;A<this._terminal.rows;A++)this._rowElements[A]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[A]);if(this._topBoundaryFocusListener=A=>this._handleBoundaryFocus(A,0),this._bottomBoundaryFocusListener=A=>this._handleBoundaryFocus(A,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 m.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((A=>this._handleResize(A.rows)))),this.register(this._terminal.onRender((A=>this._refreshRows(A.start,A.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((A=>this._handleChar(A)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
36
|
+
`}}),!1):u.type==="keydown"&&u.key==="Escape"?(u.preventDefault(),u.stopPropagation(),t().send({type:"terminal:input",payload:{terminalId:n,data:"\x1B"}}),!1):!0);const s=r.onData(u=>{new RegExp("^\x1B\\[<35;\\d+;\\d+[Mm]$").test(u)||new RegExp("^\x1B\\]").test(u)||new RegExp("^\x1BP").test(u)||/\$y/.test(u)||new RegExp("^\x1B\\[\\d+;\\d+R$").test(u)||new RegExp("^\x1B\\[[?>\\d;]*c$").test(u)||t().send({type:"terminal:input",payload:{terminalId:n,data:u}})}),o=()=>{this.setLastFocusedTerminal(n)};r.textarea?.addEventListener("focus",o),i?.onAttached&&(e.terminalsReadyForCallback.has(n)?(t().log.ws.debug("attachXterm: terminal already attached, calling callback immediately",{terminalId:n}),e.terminalsReadyForCallback.delete(n),setTimeout(()=>i.onAttached?.(n),0)):(t().log.ws.debug("attachXterm: registering onAttached callback",{terminalId:n,existingCallbacks:Array.from(e.onAttachedCallbacks.keys())}),e.onAttachedCallbacks.set(n,i.onAttached)));const l=()=>{s.dispose(),r.textarea?.removeEventListener("focus",o),e.terminals.get(n)?.setXterm(null)};return a.setAttachCleanup(l),t().send({type:"terminal:attach",payload:{terminalId:n}}),l},requestAttach(n){t().send({type:"terminal:attach",payload:{terminalId:n}})},clearTerminalBuffer(n){t().send({type:"terminal:clearBuffer",payload:{terminalId:n}})},assignTerminalToTab(n,r,i){t().send({type:"terminal:assignTab",payload:{terminalId:n,tabId:r,positionInTab:i}}),e.terminals.get(n)?.assignToTab(r,i)},createTab(n,r,i,a){const s=fP(),o=xW(),l=r??e.tabs.items.length,u={id:o,name:n,position:l,directory:i??null,createdAt:Date.now()},d=fW(e.tabs);e.tabs.add(u),d.stop(),e.tabs.get(o)?.setPending(!0),e.pendingTabCreation=o,e.pendingUpdates.set(s,{entityType:"tab",tempId:o,inversePatches:d.inversePatches,createdAt:Date.now()}),t().send({type:"tab:create",payload:{name:n,position:r,directory:i,adoptTerminalId:a,requestId:s,tempId:o}}),t().log.ws.debug("createTab optimistic",{requestId:s,tempId:o,name:n,adoptTerminalId:a})},updateTab(n,r){t().send({type:"tab:update",payload:{tabId:n,...r}}),e.tabs.get(n)?.updateFromServer(r)},deleteTab(n){t().send({type:"tab:delete",payload:{tabId:n}}),e.tabs.remove(n),e.viewState.clearFocusedTerminalForTab(n)},reorderTab(n,r){const i=e.tabs.get(n);if(!i)return;const a=i.position;if(t().send({type:"tab:reorder",payload:{tabId:n,position:r}}),r>a)for(const s of e.tabs.items)s.position>a&&s.position<=r&&s.setPosition(s.position-1);else if(r<a)for(const s of e.tabs.items)s.position>=r&&s.position<a&&s.setPosition(s.position+1);i.setPosition(r)},handleMessage(n){const{type:r,payload:i}=n;switch(r){case"terminals:list":e.terminals.replaceAll(i.terminals);break;case"terminal:created":{const{terminal:a,isNew:s,requestId:o,tempId:l}=i;if(o&&l){const u=e.pendingUpdates.get(o);if(u&&u.tempId===l){e.pendingUpdates.delete(o);const d=e.terminals.get(l);if(d){const c=d.xterm,m=e.onAttachedCallbacks.get(l),g=d.attachCleanup;if(t().log.ws.info("terminal:created optimistic handling",{tempId:l,realId:a.id,hasXterm:!!c,hasCallback:!!m,isNew:s}),g&&g(),d.setXterm(null),d.setAttachCleanup(null),e.onAttachedCallbacks.delete(l),s){const _=d.isStartingUp,x=e.terminals.items.findIndex(y=>y.id===l);x>=0&&SS(e.terminals.items[x]),e.terminals.add(a);const b=e.terminals.get(a.id);_&&b&&(b.setStartingUp(!0),t().log.ws.info("terminal:created transferred isStartingUp",{tempId:l,realId:a.id,isStartingUp:b.isStartingUp})),t().log.ws.info("terminal:created re-attaching xterm",{realId:a.id,hasRealTerminal:!!b,hasXterm:!!c,willAttach:!!(b&&c)}),b&&c?this.attachXterm(a.id,c,{onAttached:m}):m&&(t().log.ws.info("terminal:created preserving callback for later",{realId:a.id}),e.onAttachedCallbacks.set(a.id,m)),e.newTerminalIds.delete(l),e.newTerminalIds.add(a.id);const v=e.terminalsPendingStartup.get(l);v&&(e.terminalsPendingStartup.delete(l),e.terminalsPendingStartup.set(a.id,v),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:!!c,hasPendingStartup:!!v})}else{const _=e.terminals.items.findIndex(b=>b.id===l);_>=0&&SS(e.terminals.items[_]),e.newTerminalIds.delete(l),e.terminalsPendingStartup.delete(l),e.terminals.has(a.id)||e.terminals.add(a),e.terminals.get(a.id)&&c&&this.attachXterm(a.id,c,{onAttached:m}),t().log.ws.debug("terminal:created deduplicated",{requestId:o,tempId:l,existingId:a.id,xtermReattached:!!c})}}break}}e.terminals.add(a),s&&e.newTerminalIds.add(a.id);break}case"terminal:destroyed":{const{terminalId:a}=i;e.terminals.remove(a),e.newTerminalIds.delete(a),e.terminalsReadyForCallback.delete(a),e.onAttachedCallbacks.delete(a);break}case"terminal:output":{const{terminalId:a,data:s}=i,o=e.terminals.get(a);o?.xterm?o.xterm.write(s):t().log.ws.warn("terminal:output but no xterm",{terminalId:a});break}case"terminal:attached":{const{terminalId:a,buffer:s}=i,o=e.terminals.get(a);t().log.ws.info("terminal:attached received",{terminalId:a,hasTerminal:!!o,hasXterm:!!o?.xterm,bufferLength:s?.length??0,hasCallback:e.onAttachedCallbacks.has(a),isReadyForCallback:e.terminalsReadyForCallback.has(a),registeredCallbacks:Array.from(e.onAttachedCallbacks.keys())});const l=()=>{const u=e.onAttachedCallbacks.get(a);u?(e.onAttachedCallbacks.delete(a),t().log.ws.debug("terminal:attached calling callback",{terminalId:a}),u(a)):(t().log.ws.debug("terminal:attached no callback yet, marking ready",{terminalId:a}),e.terminalsReadyForCallback.add(a))};o?.xterm?(o.xterm.reset(),s?o.xterm.write(s,l):l()):l();break}case"terminal:bufferCleared":{const{terminalId:a}=i,s=e.terminals.get(a);s?.xterm&&s.xterm.reset();break}case"terminal:exit":{const{terminalId:a,exitCode:s}=i;e.terminals.get(a)?.markExited(s);break}case"terminal:renamed":{const{terminalId:a,name:s}=i;e.terminals.get(a)?.rename(s);break}case"terminal:tabAssigned":{const{terminalId:a,tabId:s,positionInTab:o}=i;e.terminals.get(a)?.assignToTab(s,o);break}case"tabs:list":e.tabs.replaceAll(i.tabs),e.initialized=!0;break;case"tab:created":{const{tab:a,requestId:s,tempId:o,adoptTerminalId:l}=i;if(s&&o){const u=e.pendingUpdates.get(s);if(u&&u.tempId===o){e.pendingUpdates.delete(s),e.tabs.get(o)&&(e.tabs.remove(o),e.tabs.add(a),e.pendingTabCreation=null,l||(e.lastCreatedTabId=a.id),t().log.ws.debug("tab:created confirmed",{requestId:s,tempId:o,realId:a.id,adoptTerminalId:l}));break}}e.tabs.add(a);break}case"tab:updated":{const{tabId:a,name:s,directory:o}=i;e.tabs.get(a)?.updateFromServer({name:s,directory:o});break}case"tab:deleted":{const{tabId:a}=i;e.tabs.remove(a),e.viewState.clearFocusedTerminalForTab(a);break}case"terminal:error":{const{error:a,requestId:s,tempId:o}=i;if(s&&o){const l=e.pendingUpdates.get(s);if(l&&l.tempId===o){e.pendingUpdates.delete(s);for(let u=l.inversePatches.length-1;u>=0;u--)Uy(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}}Lt.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 d=e.pendingUpdates.get(o);if(d&&d.tempId===l)if(e.pendingUpdates.delete(o),d.entityType==="terminal"){const c=e.terminals.get(l);c&&(c.cleanup(),e.terminals.remove(l)),e.newTerminalIds.delete(l),e.terminalsPendingStartup.delete(l)}else d.entityType==="tab"&&e.tabs.remove(l)}if(a==="terminal"){if(e.terminals.has(s)){const d=e.terminals.get(s);d&&(d.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 yoe(){const e=Vg();return C.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 Iie(l);e.writeToTerminal(r,u)}catch(u){Lt.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 Lx="",wPe=_t.model("File",{path:_t.identifier,content:_t.string,originalContent:_t.string,mimeType:_t.string,size:_t.number,lineCount:_t.number,truncated:_t.boolean,isMarkdownView:_t.optional(_t.boolean,!1),mtime:_t.optional(_t.string,"")}).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},setMtime(t){e.mtime=t},reloadFromServer(t){e.content=t.content,e.originalContent=t.content,e.mtime=t.mtime,e.size=t.size,e.lineCount=t.lineCount,e.truncated=t.truncated}})),CPe=_t.model("FilesStore",{selectedFile:_t.maybeNull(_t.string),expandedDirs:_t.array(_t.string),openFiles:_t.map(wPe)}).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()},updateFileTree(t){e.fileTree=t},_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,mtime:t.mtime})},_markFileSaved(t){const n=e.openFiles.get(t);n&&n.markSaved()}})).actions(e=>({loadFileTree:Dx(function*(){if(e.worktreePath){e._setLoadingTree(!0),e._setTreeError(null);try{const t=yield pt(`${Lx}/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:Dx(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 pt(`${Lx}/api/fs/read?${n}`);e._addFile({path:t,content:r.content,mimeType:r.mimeType,size:r.size,lineCount:r.lineCount,truncated:r.truncated,mtime:r.mtime}),e.selectedFile=t}catch(n){e._setLoadError(n instanceof Error?n.message:"Failed to load file")}finally{e._setLoading(!1)}}}),reloadFile:Dx(function*(t){if(!e.worktreePath)return;const n=e.openFiles.get(t);if(n){e._setLoading(!0),e._setLoadError(null);try{const r=new URLSearchParams({path:t,root:e.worktreePath}),i=yield pt(`${Lx}/api/fs/read?${r}`);n.reloadFromServer({content:i.content,mtime:i.mtime,size:i.size,lineCount:i.lineCount,truncated:i.truncated})}catch(r){e._setLoadError(r instanceof Error?r.message:"Failed to reload file")}finally{e._setLoading(!1)}}}),saveFile:Dx(function*(t){if(!e.worktreePath)return;const n=e.openFiles.get(t);if(!(!n||!n.isDirty)){e._setSaving(!0),e._setSaveError(null);try{const r=yield fetch(`${Lx}/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")}));r.success&&(e._markFileSaved(t),r.mtime&&n.setMtime(r.mtime))}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 TPe(){return CPe.create({selectedFile:null,expandedDirs:[],openFiles:{}})}const _oe=C.createContext(null);function APe(e,t=!1,n){const r=C.useMemo(()=>TPe(),[]),i=C.useRef(!1);return C.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 kPe(){const e=C.useContext(_oe);if(!e)throw new Error("useFilesStore must be used within a FilesStoreProvider");return e}function xoe(){const e=kPe();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,reloadFile:e.reloadFile,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,updateFileTree:e.updateFileTree}}const aa="";function o5(){const e=pn();return rn({mutationFn:({id:t,updates:n})=>pt(`${aa}/api/apps/${t}`,{method:"PATCH",body:JSON.stringify(n)}),onSuccess:(t,{id:n})=>{e.invalidateQueries({queryKey:["apps"]}),e.invalidateQueries({queryKey:["apps",n]}),e.invalidateQueries({queryKey:["projects"]})}})}function OPe(){const e=pn();return rn({mutationFn:t=>pt(`${aa}/api/apps/${t}/deploy`,{method:"POST"}),onSettled:(t,n,r)=>{e.invalidateQueries({queryKey:["apps"]}),e.invalidateQueries({queryKey:["apps",r]}),e.invalidateQueries({queryKey:["apps",r,"deployments"]}),e.invalidateQueries({queryKey:["apps",r,"status"]}),e.invalidateQueries({queryKey:["projects"]})}})}function Eoe(){const e=pn();return rn({mutationFn:t=>pt(`${aa}/api/apps/${t}/stop`,{method:"POST"}),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["apps"]}),e.invalidateQueries({queryKey:["apps",n]}),e.invalidateQueries({queryKey:["apps",n,"status"]}),e.invalidateQueries({queryKey:["projects"]})}})}function Soe(){const e=pn();return rn({mutationFn:t=>pt(`${aa}/api/apps/${t}/cancel-deploy`,{method:"POST"}),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["apps"]}),e.invalidateQueries({queryKey:["apps",n]}),e.invalidateQueries({queryKey:["apps",n,"status"]}),e.invalidateQueries({queryKey:["projects"]})}})}function RPe(e,t,n=100){return ln({queryKey:["apps",e,"logs",t,n],queryFn:()=>{const r=new URLSearchParams;return t&&r.set("service",t),r.set("tail",String(n)),pt(`${aa}/api/apps/${e}/logs?${r}`)},enabled:!!e,refetchInterval:5e3})}function woe(e){return ln({queryKey:["apps",e,"status"],queryFn:()=>pt(`${aa}/api/apps/${e}/status`),enabled:!!e,refetchInterval:1e4})}function NPe(e){return ln({queryKey:["apps",e,"deployments"],queryFn:()=>pt(`${aa}/api/apps/${e}/deployments`),enabled:!!e,refetchInterval:5e3})}function IPe(e){return ln({queryKey:["compose","find",e],queryFn:()=>pt(`${aa}/api/compose/find?repoId=${e}`),enabled:!!e})}function DPe(e,t){return ln({queryKey:["compose","file",e,t],queryFn:()=>pt(`${aa}/api/fs/read?path=${encodeURIComponent(t)}&root=${encodeURIComponent(e)}`),enabled:!!e&&!!t})}function LPe(){const e=pn();return rn({mutationFn:({repoPath:t,composeFile:n,content:r})=>pt(`${aa}/api/fs/write`,{method:"POST",body:JSON.stringify({path:n,root:t,content:r})}),onSuccess:(t,{repoPath:n,composeFile:r})=>{e.invalidateQueries({queryKey:["compose","file",n,r]})}})}function PPe(){const e=pn();return rn({mutationFn:t=>pt(`${aa}/api/apps/${t}/sync-services`,{method:"POST"}),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["apps",n]}),e.invalidateQueries({queryKey:["apps"]})}})}function MPe(){return ln({queryKey:["deployment","prerequisites"],queryFn:()=>pt(`${aa}/api/deployment/prerequisites`),staleTime:1e4})}function Coe(){return ln({queryKey:["deployment","settings"],queryFn:()=>pt(`${aa}/api/deployment/settings`)})}function jPe(){const e=pn();return rn({mutationFn:t=>pt(`${aa}/api/deployment/settings`,{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{e.invalidateQueries({queryKey:["deployment","settings"]}),e.invalidateQueries({queryKey:["deployment","prerequisites"]})}})}function FPe(e){return ln({queryKey:["apps",e,"swarm-compose"],queryFn:()=>pt(`${aa}/api/apps/${e}/swarm-compose`),enabled:!1})}const BPe=_t.model("DeploymentStreamStore",{appId:_t.maybeNull(_t.string),isDeploying:_t.optional(_t.boolean,!1),logs:_t.array(_t.string),stage:_t.maybeNull(_t.string),error:_t.maybeNull(_t.string)}).volatile(()=>({eventSource:null,deployment:null})).views(e=>({get typedStage(){return e.stage},get hasLogs(){return e.logs.length>0},get logCount(){return e.logs.length},get logsSnapshot(){return e.logs.slice()},get isComplete(){return!e.isDeploying&&(e.stage==="done"||e.stage==="failed"||e.stage==="cancelled"||!!e.error)}})).actions(e=>{const t=()=>cP(e).log,n=()=>cP(e).invalidateQueries;return{_handleProgress(r){t().debug("Deployment progress",{appId:e.appId,stage:r.stage,message:r.message.slice(0,100)}),e.stage=r.stage,e.logs.push(r.message)},_handleComplete(r){const i=t(),a=e.appId;i.info("Deployment complete",{appId:a,success:r.success,deploymentId:r.deployment?.id}),e.deployment=r.deployment,e.isDeploying=!1,e.stage="done",e.eventSource&&(e.eventSource.close(),e.eventSource=null),a&&n()(a)},_handleError(r){const i=t(),a=e.appId;i.error("Deployment failed",{appId:a,error:r}),e.error=r,e.stage="failed",e.isDeploying=!1,e.eventSource&&(e.eventSource.close(),e.eventSource=null),a&&n()(a)},_handleConnectionLost(){const r=t();e.isDeploying&&(r.error("EventSource connection lost",{appId:e.appId}),e.error="Connection lost during deployment",e.isDeploying=!1,e.stage="failed"),e.eventSource&&(e.eventSource.close(),e.eventSource=null)},deploy(r){const i=t();e.eventSource&&(i.debug("Closing existing EventSource before new deploy",{appId:e.appId}),e.eventSource.close(),e.eventSource=null),i.info("Starting deployment",{appId:r}),e.appId=r,e.isDeploying=!0,e.logs.clear(),e.stage=null,e.error=null,e.deployment=null;const a=new EventSource(`${aa}/api/apps/${r}/deploy/stream`);e.eventSource=a;const s=e;a.addEventListener("progress",o=>{try{const l=JSON.parse(o.data);s._handleProgress(l)}catch(l){i.warn("Failed to parse progress event",{error:String(l)})}}),a.addEventListener("complete",o=>{try{const l=JSON.parse(o.data);s._handleComplete(l)}catch(l){i.warn("Failed to parse complete event",{error:String(l)})}}),a.addEventListener("error",o=>{if(o instanceof MessageEvent)try{const l=JSON.parse(o.data);s._handleError(l.error)}catch{s._handleError("Deployment failed")}else s._handleError("Connection lost during deployment")}),a.onerror=()=>{s._handleConnectionLost()}},watchDeployment(r){const i=t();e.eventSource&&(i.debug("Closing existing EventSource before watching",{appId:e.appId}),e.eventSource.close(),e.eventSource=null),i.info("Watching deployment",{appId:r}),e.appId=r,e.isDeploying=!0,e.logs.clear(),e.stage=null,e.error=null,e.deployment=null;const a=new EventSource(`${aa}/api/apps/${r}/deploy/watch`);e.eventSource=a;const s=e;a.addEventListener("progress",o=>{try{const l=JSON.parse(o.data);s._handleProgress(l)}catch(l){i.warn("Failed to parse progress event",{error:String(l)})}}),a.addEventListener("complete",o=>{try{const l=JSON.parse(o.data);s._handleComplete({success:!0,deployment:l.deployment||{id:"",appId:r,status:"success",startedAt:""}})}catch(l){i.warn("Failed to parse complete event",{error:String(l)})}}),a.addEventListener("error",o=>{if(o instanceof MessageEvent)try{const l=JSON.parse(o.data);s._handleError(l.error)}catch{s._handleError("Deployment failed")}else i.debug("Watch connection ended",{appId:r}),e.isDeploying=!1,e.eventSource&&(e.eventSource.close(),e.eventSource=null)}),a.onerror=()=>{e.isDeploying&&!e.stage&&i.warn("Watch connection failed - no deployment in progress?",{appId:r}),e.isDeploying=!1,e.eventSource&&(e.eventSource.close(),e.eventSource=null)}},reset(){t().debug("Resetting deployment store",{appId:e.appId,hadLogs:e.logs.length}),e.eventSource&&(e.eventSource.close(),e.eventSource=null),e.appId=null,e.isDeploying=!1,e.logs.clear(),e.stage=null,e.error=null,e.deployment=null},disconnect(){const r=t();e.eventSource&&(r.debug("Disconnecting EventSource",{appId:e.appId}),e.eventSource.close(),e.eventSource=null)}}}),Toe=C.createContext(null);function Aoe(){const e=C.useContext(Toe);if(!e)throw new Error("useDeploymentStore must be used within a DeploymentStoreProvider");return e}function UPe({children:e}){const t=pn(),n=C.useMemo(()=>BPe.create({appId:null,isDeploying:!1,logs:[],stage:null,error:null},{log:Lt.deployment,invalidateQueries:i=>{t.invalidateQueries({queryKey:["apps"]}),t.invalidateQueries({queryKey:["apps",i]}),t.invalidateQueries({queryKey:["apps",i,"deployments"]})}}),[t]),r=C.useRef(n);return r.current=n,C.useEffect(()=>()=>{r.current?.disconnect()},[]),p.jsx(Toe.Provider,{value:n,children:e})}const koe=C.createContext(null);function Vg(){const e=C.useContext(koe);if(!e)throw new Error("useStore must be used within a StoreProvider");return e}function $Pe(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/terminal`}function zPe({children:e,wsUrl:t=$Pe(),reconnectInterval:n=2e3,maxReconnectAttempts:r=10}){const i=C.useRef(null),a=C.useRef(0),s=C.useRef(void 0),o=C.useRef(null),[,l]=C.useState({}),u=C.useCallback(c=>{i.current?.readyState===WebSocket.OPEN?(Lt.ws.debug("send",{type:c.type}),i.current.send(JSON.stringify(c))):Lt.ws.warn("send dropped (WebSocket not open)",{type:c.type,readyState:i.current?.readyState??"no socket"})},[]);if(!o.current){const c={send:u,log:Lt};o.current=SPe.create({},c)}const d=o.current;return C.useEffect(()=>{d.setMaxReconnectAttempts(r)},[d,r]),C.useEffect(()=>{let c=!0;const m=()=>{const g=i.current;if(g&&(g.readyState===WebSocket.CONNECTING||g.readyState===WebSocket.OPEN))return;const _=new WebSocket(t);i.current=_,_.onopen=()=>{c&&(Lt.ws.info("WebSocket connected"),d.setConnected(!0),a.current=0)},_.onmessage=x=>{if(c)try{const b=JSON.parse(x.data);d.handleMessage(b)}catch(b){Lt.ws.error("Failed to parse WebSocket message",{error:String(b)})}},_.onclose=()=>{if(c)if(Lt.ws.info("WebSocket disconnected"),d.setConnected(!1),i.current===_&&(i.current=null),a.current<r){a.current++,d.setReconnectAttempt(a.current);const x=n*Math.pow(1.5,a.current-1);Lt.ws.info("Scheduling reconnect",{attempt:a.current,delay:x}),s.current=setTimeout(m,x)}else Lt.ws.warn("Max reconnect attempts reached"),d.setReconnectAttempt(a.current)},_.onerror=x=>{Lt.ws.error("WebSocket error",{event:String(x)})}};return m(),()=>{c=!1,s.current&&clearTimeout(s.current);const g=i.current;g?.readyState===WebSocket.OPEN&&g.close(),i.current=null}},[t,n,r,d]),C.useEffect(()=>{l({})},[]),p.jsx(koe.Provider,{value:d,children:e})}function Ooe(){const e=Vg(),{setTheme:t,resolvedTheme:n,theme:r}=Bd(),{data:i}=oke(),a=C.useRef(void 0),s=C.useRef(!1),o=C.useRef(!1);C.useEffect(()=>zm(()=>e.broadcastedTheme,d=>{d&&(o.current=!0,t(d),e.clearBroadcastedTheme(),setTimeout(()=>{o.current=!1},0))},{fireImmediately:!0}),[e,t]),C.useEffect(()=>{let u=document.querySelector('link[rel="icon"]');u||(u=document.createElement("link"),u.rel="icon",document.head.appendChild(u)),u.type="image/png",u.href="/logo.png"},[]),C.useEffect(()=>{const u=s.current&&i&&a.current===!1;a.current=i,s.current=!0,n&&u&&pt("/api/config/sync-claude-theme",{method:"POST",body:JSON.stringify({resolvedTheme:n})}).catch(()=>{})},[i,n]);const l=C.useCallback(u=>{if(!o.current&&(t(u),e.syncTheme(u),i)){const d=u==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":u;pt("/api/config/sync-claude-theme",{method:"POST",body:JSON.stringify({resolvedTheme:d})}).catch(()=>{})}},[t,e,i]);return{theme:r??"system",resolvedTheme:n,syncClaudeCode:i,changeTheme:l,isUpdating:!1}}let uO=!1;const EW={activeTabId:null,focusedTerminals:{},selectedProjectIds:[],currentView:null,currentTaskId:null,isTabVisible:null,viewUpdatedAt:null};function Roe(){const e=pn(),t=C.useRef(void 0),n=C.useRef({}),{data:r=EW,isLoading:i}=ln({queryKey:["terminal-view-state"],queryFn:async()=>{const g=await fetch("/api/terminal-view-state");if(!g.ok)throw new Error("Failed to fetch terminal view state");return g.json()},staleTime:2e3}),a=rn({mutationFn:async g=>{const _=await fetch("/api/terminal-view-state",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)});if(!_.ok)throw new Error("Failed to update terminal view state");return _.json()},onSuccess:g=>{e.setQueryData(["terminal-view-state"],g)}}),s=C.useRef(a);s.current=a;const o=C.useCallback(g=>{const _=n.current;n.current={..._,...g,focusedTerminals:g.focusedTerminals||_.focusedTerminals?{..._.focusedTerminals,...g.focusedTerminals}:void 0};const x=n.current;e.setQueryData(["terminal-view-state"],b=>{const v=b??EW;return{activeTabId:x.activeTabId!==void 0?x.activeTabId:v.activeTabId,focusedTerminals:{...v.focusedTerminals,...x.focusedTerminals},selectedProjectIds:x.selectedProjectIds!==void 0?x.selectedProjectIds:v.selectedProjectIds,currentView:x.currentView!==void 0?x.currentView:v.currentView,currentTaskId:x.currentTaskId!==void 0?x.currentTaskId:v.currentTaskId,isTabVisible:x.isTabVisible!==void 0?x.isTabVisible:v.isTabVisible,viewUpdatedAt:x.viewUpdatedAt!==void 0?x.viewUpdatedAt:v.viewUpdatedAt}}),t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{s.current.mutate(n.current),n.current={}},500)},[e]),l=C.useCallback((g,_)=>{if(_===null){const x=e.getQueryData(["terminal-view-state"]);if(x){const{[g]:b,...v}=x.focusedTerminals;o({focusedTerminals:v})}}else o({focusedTerminals:{[g]:_}})},[e,o]),u=C.useCallback(g=>r.focusedTerminals[g]??null,[r.focusedTerminals]),d=C.useRef(!1);C.useEffect(()=>{if(uO){d.current=!1;return}uO=!0,d.current=!0;const g=()=>{o({isTabVisible:document.visibilityState==="visible",viewUpdatedAt:new Date().toISOString()})};return document.addEventListener("visibilitychange",g),g(),()=>{document.removeEventListener("visibilitychange",g),d.current&&(uO=!1)}},[o]);const c=C.useCallback((g,_,x)=>{o({currentView:g,currentTaskId:_,activeTabId:x,viewUpdatedAt:new Date().toISOString()})},[o]),m=C.useCallback(g=>{o({selectedProjectIds:g})},[o]);return{viewState:r,isLoading:i,selectedProjectIds:r.selectedProjectIds,getFocusedTerminal:u,setFocusedTerminal:l,setSelectedProjects:m,updateViewTracking:c}}function ts(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 HPe(e,t){return t.trim()?e.map(r=>{let i=ts(r.label,t);if(r.keywords)for(const a of r.keywords){const s=ts(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 VPe(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 WPe({open:e,onOpenChange:t,onNewTask:n,onShowShortcuts:r,onOpenInEditor:i}){const{t:a}=Ct("navigation"),[s,o]=C.useState(!1),l=e??s,u=t??o,[d,c]=C.useState(""),[m,g]=C.useState(0),_=C.useRef(null),x=C.useRef(null),b=Sa(),v=C.useMemo(()=>[{id:"goto-tasks",label:a("commandPalette.commands.goToTasks"),shortcut:"meta+1",keywords:["kanban","board","home"],category:"navigation",icon:p.jsx(te,{icon:qL,size:16,strokeWidth:2}),action:()=>{b({to:"/tasks"}),u(!1)}},{id:"goto-terminals",label:a("commandPalette.commands.goToTerminals"),shortcut:"meta+2",keywords:["shell","console","cli"],category:"navigation",icon:p.jsx(te,{icon:ISe,size:16,strokeWidth:2}),action:()=>{b({to:"/terminals"}),u(!1)}},{id:"goto-projects",label:a("commandPalette.commands.goToProjects"),shortcut:"meta+3",keywords:["repos","repositories","apps","deploy","docker"],category:"navigation",icon:p.jsx(te,{icon:Ds,size:16,strokeWidth:2}),action:()=>{b({to:"/projects"}),u(!1)}},{id:"goto-review",label:a("commandPalette.commands.goToReview"),shortcut:"meta+4",keywords:["pr","pull request","issues","github"],category:"navigation",icon:p.jsx(te,{icon:Ku,size:16,strokeWidth:2}),action:()=>{b({to:"/review"}),u(!1)}},{id:"goto-monitoring",label:a("commandPalette.commands.goToMonitoring"),shortcut:"meta+5",keywords:["system","cpu","memory","processes","usage"],category:"navigation",icon:p.jsx(te,{icon:iie,size:16,strokeWidth:2}),action:()=>{b({to:"/monitoring"}),u(!1)}},{id:"goto-settings",label:a("commandPalette.commands.goToSettings"),shortcut:"meta+,",keywords:["preferences","config","configuration"],category:"navigation",icon:p.jsx(te,{icon:mie,size:16,strokeWidth:2}),action:()=>{b({to:"/settings"}),u(!1)}},{id:"new-task",label:a("commandPalette.commands.newTask"),shortcut:"meta+j",keywords:["create","add"],category:"actions",icon:p.jsx(te,{icon:jm,size:16,strokeWidth:2}),action:()=>{u(!1),n?.()}},{id:"open-in-editor",label:a("commandPalette.commands.openInEditor"),shortcut:"meta+e",keywords:["editor","code","vscode","cursor","folder","path"],category:"actions",icon:p.jsx(te,{icon:WL,size:16,strokeWidth:2}),action:()=>{u(!1),i?.()}},{id:"show-shortcuts",label:a("commandPalette.commands.keyboardShortcuts"),shortcut:"meta+/",keywords:["help","hotkeys","keys"],category:"actions",icon:p.jsx(te,{icon:lie,size:16,strokeWidth:2}),action:()=>{u(!1),r?.()}},{id:"goto-task-terminals",label:a("commandPalette.commands.goToTaskTerminals"),shortcut:"meta+u",keywords:["tasks","shell","console","cli"],category:"actions",icon:p.jsx(te,{icon:qL,size:16,strokeWidth:2}),action:()=>{b({to:"/terminals",search:{tab:"all-tasks"}}),u(!1)}},{id:"goto-project-terminals",label:a("commandPalette.commands.goToProjectTerminals"),shortcut:"meta+i",keywords:["projects","shell","console","cli","workspace"],category:"actions",icon:p.jsx(te,{icon:Ds,size:16,strokeWidth:2}),action:()=>{b({to:"/terminals",search:R=>({...R,tab:"all-projects"})}),u(!1)}}],[b,n,r,i,u,a]),y=C.useMemo(()=>HPe(v,d),[v,d]),E=C.useMemo(()=>VPe(y),[y]),T=C.useMemo(()=>{const O=[],R=["navigation","actions"];for(const N of R){const D=E.get(N);D&&O.push(...D)}return O},[E]);C.useEffect(()=>{g(0)},[d]),C.useEffect(()=>{if(!x.current)return;const O=x.current.querySelector('[data-selected="true"]');O&&O.scrollIntoView({block:"nearest"})},[m]),Ra("meta+k",()=>u(!0),{allowInInput:!0,allowInTerminal:!0}),Ra("meta+1",()=>b({to:"/tasks"}),{allowInInput:!0,allowInTerminal:!0}),Ra("meta+2",()=>b({to:"/terminals"}),{allowInInput:!0,allowInTerminal:!0}),Ra("meta+3",()=>b({to:"/projects"}),{allowInInput:!0,allowInTerminal:!0}),Ra("meta+u",()=>{b({to:"/terminals",search:{tab:"all-tasks"}})},{allowInInput:!0,allowInTerminal:!0}),Ra("meta+i",()=>{b({to:"/terminals",search:O=>({...O,tab:"all-projects"})})},{allowInInput:!0,allowInTerminal:!0}),Ra("meta+4",()=>b({to:"/review"}),{allowInInput:!0,allowInTerminal:!0}),Ra("meta+5",()=>b({to:"/monitoring"}),{allowInInput:!0,allowInTerminal:!0}),Ra("meta+,",()=>b({to:"/settings"}),{allowInInput:!0,allowInTerminal:!0}),Ra("meta+j",()=>{n?.()},{allowInInput:!1,deps:[n]}),Ra("meta+/",()=>{r?.()},{allowInInput:!0,allowInTerminal:!0,deps:[r]}),Ra("meta+e",()=>{i?.()},{allowInInput:!0,allowInTerminal:!0,deps:[i]});const w=C.useCallback(O=>{switch(O.key){case"ArrowDown":O.preventDefault(),g(R=>Math.min(R+1,T.length-1));break;case"ArrowUp":O.preventDefault(),g(R=>Math.max(R-1,0));break;case"Enter":O.preventDefault(),T[m]&&T[m].action();break;case"Escape":O.preventDefault(),u(!1);break;case"1":O.preventDefault(),b({to:"/tasks"}),u(!1);break;case"2":O.preventDefault(),b({to:"/terminals"}),u(!1);break;case"3":O.preventDefault(),b({to:"/projects"}),u(!1);break;case"4":O.preventDefault(),b({to:"/review"}),u(!1);break;case"5":O.preventDefault(),b({to:"/monitoring"}),u(!1);break}},[T,m,u,b]);C.useEffect(()=>{l&&(c(""),g(0),setTimeout(()=>_.current?.focus(),50))},[l]),C.useEffect(()=>{const O=R=>{if(R.data?.type==="vibora:action")switch(R.data.action){case"openCommandPalette":u(!0);break;case"openNewTask":n?.();break;case"showShortcuts":r?.();break}};return window.addEventListener("message",O),()=>window.removeEventListener("message",O)},[u,n,r]);let A=0;return p.jsx(So,{open:l,onOpenChange:u,children:p.jsxs(wo,{className:"sm:max-w-lg p-0 gap-0 overflow-hidden",showCloseButton:!1,onKeyDown:w,children:[p.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[p.jsx("span",{className:"text-muted-foreground mr-2",children:">"}),p.jsx(Ht,{ref:_,value:d,onChange:O=>c(O.target.value),placeholder:a("commandPalette.placeholder"),className:"border-0 ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 px-0 h-12"}),p.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"})]}),p.jsx("div",{ref:x,className:"max-h-80 overflow-y-auto p-2",children:y.length===0?p.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:a("commandPalette.noResults")}):p.jsx(p.Fragment,{children:["navigation","actions"].map(O=>{const R=E.get(O);return!R||R.length===0?null:p.jsxs("div",{className:"mb-2 last:mb-0",children:[p.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:a(`commandPalette.categories.${O}`)}),R.map(N=>{const D=A++,L=D===m;return p.jsxs("button",{"data-selected":L,onClick:()=>N.action(),onMouseEnter:()=>g(D),className:ze("flex w-full items-center gap-3 rounded-md px-2 py-2 text-sm",L?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"),children:[N.icon&&p.jsx("span",{className:"text-muted-foreground",children:N.icon}),p.jsx("span",{className:"flex-1 text-left",children:N.label}),N.shortcut&&p.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:xie(N.shortcut)})]},N.id)})]},O)})})})]})})}const SW={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 GPe({className:e,rows:t=100,cols:n=10,tileClassName:r,tileSize:i="md"}){return p.jsx("div",{className:ze("relative z-0 flex w-full h-full justify-center",e),children:Array.from({length:t}).map((a,s)=>p.jsx("div",{className:ze(SW[i],"border-l dark:border-neutral-900 border-neutral-200 relative",r),children:Array.from({length:n}).map((o,l)=>p.jsx("div",{className:ze(SW[i],"border-r border-t dark:border-neutral-900 border-neutral-200 relative hover:bg-tile transition-colors",r)},`col-${l}`))},`row-${s}`))})}const qPe=["/","/tasks","/terminals","/worktrees","/repositories","/review","/monitoring","/settings"];function KPe(){const e=Ei({select:n=>n.location.pathname});return qPe.some(n=>e===n||e.startsWith(n+"/"))?p.jsx("div",{className:"absolute inset-0 overflow-hidden pointer-events-none -z-10",children:p.jsx(GPe,{rows:100,cols:50,tileSize:"sm"})}):null}if(!C.useState)throw new Error("mobx-react-lite requires React with Hooks support");if(!Lse)throw new Error("mobx-react-lite@3 requires mobx at least version 6 to be available");function YPe(e){e()}function XPe(e){e||(e=YPe),uDe({reactionScheduler:e})}function ZPe(e){return dDe(e)}var QPe=1e4,JPe=1e4,eMe=(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=QPe),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,JPe))}}),e})(),tMe=typeof FinalizationRegistry<"u"?FinalizationRegistry:eMe,pP=new tMe(function(e){var t;(t=e.reaction)===null||t===void 0||t.dispose(),e.reaction=null});function wW(e){e.reaction=new tu("observer".concat(e.name),function(){var t;e.stateVersion=Symbol(),(t=e.onStoreChange)===null||t===void 0||t.call(e)})}function nMe(e,t){t===void 0&&(t="observed");var n=le.useRef(null);if(!n.current){var r={reaction:null,onStoreChange:null,stateVersion:Symbol(),name:t,subscribe:function(o){return pP.unregister(r),r.onStoreChange=o,r.reaction||(wW(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||(wW(i),pP.register(n,i,i)),le.useDebugValue(i.reaction,ZPe),U3.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 cO,dO,Noe=typeof Symbol=="function"&&Symbol.for,rMe=(dO=(cO=Object.getOwnPropertyDescriptor(function(){},"name"))===null||cO===void 0?void 0:cO.configurable)!==null&&dO!==void 0?dO:!1,CW=Noe?Symbol.for("react.forward_ref"):typeof C.forwardRef=="function"&&C.forwardRef(function(e){return null}).$$typeof,TW=Noe?Symbol.for("react.memo"):typeof C.memo=="function"&&C.memo(function(e){return null}).$$typeof;function Wg(e,t){var n;if(TW&&e.$$typeof===TW)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(CW&&e.$$typeof===CW&&(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 nMe(function(){return i(o,l)},a)};return s.displayName=e.displayName,rMe&&Object.defineProperty(s,"name",{value:e.name,writable:!0,configurable:!0}),e.contextTypes&&(s.contextTypes=e.contextTypes),r&&(s=C.forwardRef(s)),s=C.memo(s),aMe(e,s),s}var iMe={$$typeof:!0,render:!0,compare:!0,type:!0,displayName:!0};function aMe(e,t){Object.keys(e).forEach(function(n){iMe[n]||Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})}var fO;XPe(jr.unstable_batchedUpdates);fO=pP.finalizeAllImmediately;const sMe=Wg(function(){const t=Vg();if(t.connected||!t.hasEverConnected)return null;const n=t.reconnectAttempt>0&&t.reconnectAttempt<t.maxReconnectAttempts,r=t.reconnectAttempt>=t.maxReconnectAttempts;return p.jsx("div",{className:ze("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?p.jsxs(p.Fragment,{children:[p.jsx(te,{icon:ai,size:16,strokeWidth:2}),p.jsx("span",{children:"Connection lost. Please check if the server is running."})]}):n?p.jsxs(p.Fragment,{children:[p.jsx(te,{icon:Ft,size:16,strokeWidth:2,className:"animate-spin"}),p.jsxs("span",{children:["Reconnecting... (attempt ",t.reconnectAttempt,"/",t.maxReconnectAttempts,")"]})]}):p.jsxs(p.Fragment,{children:[p.jsx(te,{icon:ai,size:16,strokeWidth:2}),p.jsx("span",{children:"Disconnected from server"})]})})});function oMe(){return ln({queryKey:["system","dependencies"],queryFn:()=>pt("/api/system/dependencies"),staleTime:30*1e3,refetchOnWindowFocus:!0})}function lMe(){const{data:e,isLoading:t}=oMe(),{data:n,isLoading:r}=Vj(),[i,a]=C.useState(!1),[s,o]=C.useState(!1),l=n??"claude",u=il[l],d=$ae[l],c=zae[l],m=C.useCallback(async()=>{try{await navigator.clipboard.writeText(d),o(!0),setTimeout(()=>o(!1),2e3)}catch{}},[d]),g=C.useCallback(()=>{a(!0)},[]);return t||r||i||(l==="claude"?e?.claudeCode?.installed:e?.openCode?.installed)?null:p.jsxs("div",{className:ze("flex items-center justify-between gap-4 px-4 py-3","border-b bg-amber-500/10 border-amber-500/30"),role:"alert",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(te,{icon:ai,size:18,strokeWidth:2,className:"shrink-0 text-amber-600 dark:text-amber-400"}),p.jsxs("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-4",children:[p.jsxs("span",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:[u," CLI not found"]}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.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:d}),p.jsx("button",{onClick:m,className:ze("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:s?"Copied!":"Copy to clipboard",children:p.jsx(te,{icon:s?di:wC,size:14,strokeWidth:2})})]})]})]}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:ze("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"}),p.jsx("button",{onClick:g,className:ze("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:p.jsx(te,{icon:Yr,size:16,strokeWidth:2})})]})]})}const uMe=[{titleKey:"navigation",items:[{labelKey:"goToTasks",shortcut:"meta+1"},{labelKey:"goToTerminals",shortcut:"meta+2"},{labelKey:"goToTaskTerminals",shortcut:"meta+u"},{labelKey:"goToProjectTerminals",shortcut:"meta+i"},{labelKey:"goToProjects",shortcut:"meta+3"},{labelKey:"goToReview",shortcut:"meta+4"},{labelKey:"goToMonitoring",shortcut:"meta+5"},{labelKey:"goToSettings",shortcut:"meta+,"}]},{titleKey:"actions",items:[{labelKey:"commandPalette",shortcut:"meta+k"},{labelKey:"newTask",shortcut:"meta+j"},{labelKey:"openInEditor",shortcut:"meta+e"},{labelKey:"keyboardShortcuts",shortcut:"meta+/"}]},{titleKey:"terminals",items:[{labelKey:"newTerminal",shortcut:"meta+d"},{labelKey:"closeTerminal",shortcut:"meta+w"}]},{titleKey:"general",items:[{labelKey:"closeModal",shortcut:"escape"},{labelKey:"submitForm",shortcut:"meta+enter"}]}];function cMe({open:e,onOpenChange:t}){const{t:n}=Ct("navigation");return p.jsx(So,{open:e,onOpenChange:t,children:p.jsxs(wo,{className:"sm:max-w-md",children:[p.jsx(cl,{children:p.jsx(dl,{children:n("shortcuts.title")})}),p.jsx(Bg,{className:"max-h-[60vh]",children:p.jsx("div",{className:"space-y-4 mt-2 pr-4",children:uMe.map(r=>p.jsxs("div",{children:[p.jsx("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:n(`shortcuts.groups.${r.titleKey}`)}),p.jsx("div",{className:"space-y-1",children:r.items.map(i=>p.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[p.jsx("span",{className:"text-sm",children:n(`shortcuts.labels.${i.labelKey}`)}),p.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:xie(i.shortcut)})]},i.shortcut))})]},r.titleKey))})})]})})}function dMe(e,t){return e&&(e==="~"?t:e.startsWith("~/")?t+e.slice(1):e)}const fMe={vscode:"vscode",cursor:"cursor",windsurf:"windsurf",zed:"zed",antigravity:"antigravity"};function ZC(e,t,n,r){const i=fMe[t];if(!n)return`${i}://file${e}`;const a=r!==22?`${n}:${r}`:n;return`${i}://vscode-remote/ssh-remote+${a}${e}`}function Ioe(e){return{vscode:"VS Code",cursor:"Cursor",windsurf:"Windsurf",zed:"Zed",antigravity:"Antigravity"}[e]}function Wl(e){window.parent!==window?window.parent.postMessage({type:"vibora:openUrl",url:e},"*"):window.open(e,"_blank")}function pMe({open:e,onOpenChange:t}){const{t:n}=Ct("navigation"),[r,i]=C.useState(""),[a,s]=C.useState(!1),{data:o}=u1(),{data:l}=c1(),{data:u}=d1(),{data:d}=rke(),{data:c,isLoading:m}=eke(r.trim()||null);C.useEffect(()=>{e&&i("")},[e]);const g=c?.exists&&c?.isDirectory,_=r.trim()&&c&&!m?c.exists?c.isDirectory?null:n("openInEditor.pathNotDirectory"):n("openInEditor.pathNotFound"):null,x=()=>{if(!r.trim()||!g)return;const y=dMe(r.trim(),d),E=ZC(y,o??"vscode",l??"",u??22);Wl(E),t(!1)},b=y=>{i(y)},v=Ioe(o??"vscode");return p.jsxs(p.Fragment,{children:[p.jsx(So,{open:e,onOpenChange:t,children:p.jsxs(wo,{className:"sm:max-w-md",children:[p.jsxs(cl,{children:[p.jsx(dl,{children:n("openInEditor.title")}),p.jsx(Up,{children:n("openInEditor.description",{editor:v})})]}),p.jsx("div",{className:"space-y-4",children:p.jsxs("div",{className:"space-y-2",children:[p.jsx("label",{className:"text-sm font-medium",children:n("openInEditor.pathLabel")}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx(Ht,{value:r,onChange:y=>i(y.target.value),placeholder:n("openInEditor.pathPlaceholder"),onKeyDown:y=>y.key==="Enter"&&x(),className:`flex-1 font-mono text-sm ${_?"border-destructive":""}`}),p.jsx(Be,{variant:"outline",size:"icon",onClick:()=>s(!0),title:n("openInEditor.browse"),children:p.jsx(te,{icon:Ba,size:16,strokeWidth:2})})]}),_?p.jsx("p",{className:"text-xs text-destructive",children:_}):p.jsx("p",{className:"text-xs text-muted-foreground",children:n("openInEditor.pathHint")})]})}),p.jsxs(i1,{children:[p.jsx(RC,{render:p.jsx(Be,{variant:"outline"}),children:n("openInEditor.cancel")}),p.jsx(Be,{onClick:x,disabled:!r.trim()||!g||m,children:n("openInEditor.open")})]})]})}),p.jsx(bd,{open:a,onOpenChange:s,onSelect:b})]})}const hMe=({...e})=>{const{resolvedTheme:t}=Bd();return p.jsx(Owe,{theme:t,className:"toaster group",icons:{success:p.jsx(te,{icon:nl,strokeWidth:2,className:"size-4"}),info:p.jsx(te,{icon:USe,strokeWidth:2,className:"size-4"}),warning:p.jsx(te,{icon:ai,strokeWidth:2,className:"size-4"}),error:p.jsx(te,{icon:HSe,strokeWidth:2,className:"size-4"}),loading:p.jsx(te,{icon:Ft,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})},$i=tye({component:_Me});function mMe(){return kke(),null}function gMe(){return Vae(),null}function bMe(){return Ooe(),null}function vMe(){const e=Ei({select:n=>n.location}),{updateViewTracking:t}=Roe();return C.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 yMe(){const e=Ei({select:t=>t.location});return C.useEffect(()=>{window.parent!==window&&window.parent.postMessage({type:"vibora:route",pathname:e.pathname,search:e.search},"*")},[e.pathname,e.search]),null}function _Me(){const[e,t]=C.useState(null),[n,r]=C.useState(!1),[i,a]=C.useState(!1),[s,o]=C.useState(!1),l=typeof window<"u"&&window.parent!==window,u=C.useCallback(_=>{t(()=>_)},[]),d=C.useCallback(()=>{e?.()},[e]),c=C.useCallback(()=>{r(!0)},[]),m=C.useCallback(()=>{a(!0)},[]),g=C.useCallback(()=>{o(!0)},[]);return p.jsx(Dwe,{children:p.jsxs("div",{className:"flex h-screen flex-col overflow-x-hidden bg-background text-foreground",children:[p.jsx(mMe,{}),p.jsx(gMe,{}),p.jsx(bMe,{}),p.jsx(vMe,{}),p.jsx(yMe,{}),p.jsx(sMe,{}),p.jsx(lMe,{}),p.jsx(wke,{onNewTaskRef:u,onOpenCommandPalette:m}),p.jsxs("main",{className:"isolate flex-1 overflow-hidden relative",children:[p.jsx(KPe,{}),p.jsx(rne,{})]}),p.jsx(WPe,{open:i,onOpenChange:a,onNewTask:d,onShowShortcuts:c,onOpenInEditor:g}),p.jsx(cMe,{open:n,onOpenChange:r}),p.jsx(pMe,{open:s,onOpenChange:o}),p.jsx(hMe,{position:l?"bottom-center":"bottom-right"})]})})}const xMe=Si("/")({beforeLoad:()=>{throw Xl({to:"/tasks"})}});function tr(e,t="Assertion error"){if(!e)throw Error(t)}function Km({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 hP(e,t){return t.sort(e==="horizontal"?EMe:SMe)}function EMe(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function SMe(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function Doe(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 wMe({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}=Doe(r,s),u=e==="horizontal"?o:l;u<a&&(a=u,i=s)}return tr(i,"No rect found"),i}function Loe(e){const{element:t,orientation:n,panels:r,separators:i}=e,a=hP(n,Array.from(t.children).filter(d=>d instanceof HTMLElement).map(d=>({element:d}))).map(({element:d})=>d),s=[];let o=!1,l,u=[];for(const d of a)if(d.hasAttribute("data-panel")){const c=r.find(m=>m.element===d);if(c){if(l){const m=l.element.getBoundingClientRect(),g=d.getBoundingClientRect();let _;if(o){const x=n==="horizontal"?new DOMRect(m.right,m.top,0,m.height):new DOMRect(m.left,m.bottom,m.width,0),b=n==="horizontal"?new DOMRect(g.left,g.top,0,g.height):new DOMRect(g.left,g.top,g.width,0);switch(u.length){case 0:{_=[x,b];break}case 1:{const v=u[0],y=wMe({orientation:n,rects:[m,g],targetRect:v.element.getBoundingClientRect()});_=[v,y===m?b:x];break}default:{_=u;break}}}else u.length?_=u:_=[n==="horizontal"?new DOMRect(m.right,g.top,g.left-m.right,g.height):new DOMRect(g.left,m.bottom,g.width,g.top-m.bottom)];for(const x of _)s.push({group:e,groupSize:Km({group:e}),panels:[l,c],separator:"width"in x?void 0:x,rect:"width"in x?x:x.element.getBoundingClientRect()})}o=!1,l=c,u=[]}}else if(d.hasAttribute("data-separator")){const c=i.find(m=>m.element===d);c?u.push(c):(l=void 0,u=[])}else o=!0;return s}function CMe(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function TMe(e,t){const n=getComputedStyle(e.ownerDocument.body),r=parseFloat(n.fontSize);return t*r}function AMe(e){return e/100*window.innerHeight}function kMe(e){return e/100*window.innerWidth}function OMe(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 Px({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,a]=OMe(n);switch(a){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=TMe(t,i);break}case"em":{r=CMe(t,i);break}case"vh":{r=AMe(i);break}case"vw":{r=kMe(i);break}}return r}function Go(e){return parseFloat(e.toFixed(3))}function AW(e){const{panels:t}=e,n=Km({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 d=Px({groupSize:n,panelElement:i,styleProp:a.collapsedSize});s=Go(d/n*100)}let o;if(a.defaultSize){const d=Px({groupSize:n,panelElement:i,styleProp:a.defaultSize});o=Go(d/n*100)}let l=0;if(a.minSize){const d=Px({groupSize:n,panelElement:i,styleProp:a.minSize});l=Go(d/n*100)}let u=100;if(a.maxSize){const d=Px({groupSize:n,panelElement:i,styleProp:a.maxSize});u=Go(d/n*100)}return{collapsedSize:s,collapsible:a.collapsible===!0,defaultSize:o,minSize:l,maxSize:u,panelId:r.id}})}class RMe{#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 Ia(e,t,n=0){return Math.abs(Go(e)-Go(t))<=n}let no={cursorFlags:0,interactionState:{state:"inactive"},mountedGroups:new Map};const lp=new RMe;function ou(){return no}function yo(e){const t=typeof e=="function"?e(no):e;if(no===t)return no;const n=no;return no={...no,...t},t.cursorFlags!==void 0&&lp.emit("cursorFlagsChange",no.cursorFlags),t.interactionState!==void 0&&lp.emit("interactionStateChange",no.interactionState),t.mountedGroups!==void 0&&(no.mountedGroups.forEach((r,i)=>{r.derivedPanelConstraints.forEach(a=>{if(a.collapsible){const{layout:s}=n.mountedGroups.get(i)??{};if(s){const o=Ia(a.collapsedSize,r.layout[a.panelId]),l=Ia(a.collapsedSize,s[a.panelId]);o&&!l&&(i.inMemoryLastExpandedPanelSizes[a.panelId]=s[a.panelId])}}})}),lp.emit("mountedGroupsChange",no.mountedGroups)),no}const NMe=e=>e,pO=()=>{},Poe=1,Moe=2,joe=4,Foe=8,kW={coarse:10,precise:5};function IMe({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&Poe)!==0,s=(e&Moe)!==0,o=(e&joe)!==0,l=(e&Foe)!==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 hO,kl;function l5(){kl===void 0&&(kl=new CSSStyleSheet,document.adoptedStyleSheets=[kl]);const{cursorFlags:e,interactionState:t}=ou();switch(t.state){case"active":case"hover":{const n=IMe({cursorFlags:e,groups:t.hitRegions.map(i=>i.group),state:t.state}),r=`*{cursor: ${n} !important; ${t.state==="active"?"touch-action: none;":""} }`;if(hO===r)return;hO=r,n?kl.cssRules.length===0?kl.insertRule(r):kl.replaceSync(r):kl.cssRules.length===1&&kl.deleteRule(0);break}case"inactive":{hO=void 0,kl.cssRules.length===1&&kl.deleteRule(0);break}}}function DMe(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 Wy(e,t){return Ia(e,t)?0:e>t?1:-1}function am({panelConstraints:e,size:t}){const{collapsedSize:n=0,collapsible:r,maxSize:i=100,minSize:a=0}=e;if(Wy(t,a)<0)if(r){const s=(n+a)/2;Wy(t,s)<0?t=n:t=a}else t=a;return t=Math.min(i,t),t=Go(t),t}function Gy({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(Ia(e,0))return t;const s=Object.values(t),o=Object.values(i),l=[...s],[u,d]=r;tr(u!=null,"Invalid first pivot index"),tr(d!=null,"Invalid second pivot index");let c=0;if(a==="keyboard"){{const _=e<0?d:u,x=n[_];tr(x,`Panel constraints not found for index ${_}`);const{collapsedSize:b=0,collapsible:v,minSize:y=0}=x;if(v){const E=s[_];if(tr(E!=null,`Previous layout not found for panel index ${_}`),Ia(E,b)){const T=y-E;Wy(T,Math.abs(e))>0&&(e=e<0?0-T:T)}}}{const _=e<0?u:d,x=n[_];tr(x,`No panel constraints found for index ${_}`);const{collapsedSize:b=0,collapsible:v,minSize:y=0}=x;if(v){const E=s[_];if(tr(E!=null,`Previous layout not found for panel index ${_}`),Ia(E,y)){const T=E-b;Wy(T,Math.abs(e))>0&&(e=e<0?0-T:T)}}}}{const _=e<0?1:-1;let x=e<0?d:u,b=0;for(;;){const y=s[x];tr(y!=null,`Previous layout not found for panel index ${x}`);const E=am({panelConstraints:n[x],size:100})-y;if(b+=E,x+=_,x<0||x>=n.length)break}const v=Math.min(Math.abs(e),Math.abs(b));e=e<0?0-v:v}{let _=e<0?u:d;for(;_>=0&&_<n.length;){const x=Math.abs(e)-Math.abs(c),b=s[_];tr(b!=null,`Previous layout not found for panel index ${_}`);const v=b-x,y=am({panelConstraints:n[_],size:v});if(!Ia(b,y)&&(c+=b-y,l[_]=y,c.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?_--:_++}}if(DMe(o,l))return i;{const _=e<0?d:u,x=s[_];tr(x!=null,`Previous layout not found for panel index ${_}`);const b=x+c,v=am({panelConstraints:n[_],size:b});if(l[_]=v,!Ia(v,b)){let y=b-v,E=e<0?d:u;for(;E>=0&&E<n.length;){const T=l[E];tr(T!=null,`Previous layout not found for panel index ${E}`);const w=T+y,A=am({panelConstraints:n[E],size:w});if(Ia(T,A)||(y-=A-T,l[E]=A),Ia(y,0))break;e>0?E--:E++}}}const m=Object.values(l).reduce((_,x)=>x+_,0);if(!Ia(m,100,.1))return i;const g=Object.keys(i);return l.reduce((_,x,b)=>(_[g[b]]=x,_),{})}function Gg(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||Wy(e[n],t[n])!==0)return!1;return!0}function Boe({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:d,orientation:c,panels:m}=l;let g=0;i?c==="horizontal"?g=(e.clientX-i.x)/u*100:g=(e.clientY-i.y)/u*100:c==="horizontal"?g=e.clientX<0?-100:100:g=e.clientY<0?-100:100;const _=n.get(l),{defaultLayoutDeferred:x,derivedPanelConstraints:b,layout:v,separatorToPanels:y}=r.get(l)??{defaultLayoutDeferred:!1};if(b&&_&&v&&y){const E=Gy({delta:g,initialLayout:_,panelConstraints:b,pivotIndices:o.panels.map(T=>m.indexOf(T)),prevLayout:v,trigger:"mouse-or-touch"});if(Gg(E,v)){if(g!==0&&!d)switch(c){case"horizontal":{a|=g<0?Poe:Moe;break}case"vertical":{a|=g<0?joe:Foe;break}}}else{s.set(o.group,{defaultLayoutDeferred:x,derivedPanelConstraints:b,layout:E,separatorToPanels:y});const T=o.group.panels.map(({id:w})=>w).join(",");o.group.inMemoryLayouts[T]=E}}}),yo({cursorFlags:a,mountedGroups:s}),l5()}function OW(e){if(e.defaultPrevented||e.relatedTarget!==null||e.clientX===0&&e.clientY===0)return;const{interactionState:t,mountedGroups:n}=ou();t.state==="active"&&t.hitRegions.forEach(r=>{e.currentTarget===r.group.element&&Boe({event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n})})}function kE(e){const t=e.parentElement;tr(t,"Parent group element not found");const{mountedGroups:n}=ou();for(const[r]of n)if(r.element===t)return r;throw Error("Could not find parent Group for separator element")}function Op({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(!Ia(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const o=n[s];tr(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];tr(o!=null,`No layout data found for index ${s}`);const l=am({panelConstraints:t[s],size:o});o!=l&&(i+=o-l,n[s]=l)}if(!Ia(i,0))for(let s=0;s<t.length;s++){const o=n[s];tr(o!=null,`No layout data found for index ${s}`);const l=o+i,u=am({panelConstraints:t[s],size:l});if(o!==u&&(i-=u-o,n[s]=u,Ia(i,0)))break}const a=Object.keys(e);return n.reduce((s,o,l)=>(s[a[l]]=o,s),{})}function Uoe({groupId:e}){const t=()=>{const{mountedGroups:n}=ou();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=Op({layout:n,panelConstraints:i});return r?s:(Gg(s,l)||yo(u=>({mountedGroups:new Map(u.mountedGroups).set(a,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:l,separatorToPanels:o})})),l)}}}function $oe(e){const{mountedGroups:t}=ou(),n=t.get(e);return tr(n,`Mounted Group ${e.id} not found`),n}function Cf(e,t){const n=kE(e),r=$oe(n),i=n.separators.find(d=>d.element===e);tr(i,"Matching separator not found");const a=r.separatorToPanels.get(i);tr(a,"Matching panels not found");const s=a.map(d=>n.panels.indexOf(d)),o=Uoe({groupId:n.id}).getLayout(),l=Gy({delta:t,initialLayout:o,panelConstraints:r.derivedPanelConstraints,pivotIndices:s,prevLayout:o,trigger:"keyboard"}),u=Op({layout:l,panelConstraints:r.derivedPanelConstraints});Gg(o,u)||yo(d=>({mountedGroups:new Map(d.mountedGroups).set(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,layout:u,separatorToPanels:r.separatorToPanels})}))}function RW(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=kE(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Cf(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Cf(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Cf(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Cf(t,-5);break}case"End":{e.preventDefault(),Cf(t,100);break}case"Enter":{e.preventDefault();const r=kE(t),{derivedPanelConstraints:i,layout:a,separatorToPanels:s}=$oe(r),o=r.separators.find(c=>c.element===t);tr(o,"Matching separator not found");const l=s.get(o);tr(l,"Matching panels not found");const u=l[0],d=i.find(c=>c.panelId===u.id);if(tr(d,"Panel metadata not found"),d.collapsible){const c=a[u.id],m=d.collapsedSize===c?r.inMemoryLastExpandedPanelSizes[u.id]??d.minSize:d.collapsedSize;Cf(t,m-c)}break}case"F6":{e.preventDefault();const r=kE(t).separators.map(s=>s.element),i=Array.from(r).findIndex(s=>s===e.currentTarget);tr(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(),Cf(t,-100);break}}}function LMe(e,t,n){let r,i={x:1/0,y:1/0};for(const a of t){const s=Doe(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 Mx;function PMe(){return Mx===void 0&&(typeof matchMedia=="function"?Mx=!!matchMedia("(pointer:coarse)").matches:Mx=!1),Mx}function MMe(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:DW(e),b:DW(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;tr(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:IW(NW(n.a)),b:IW(NW(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 jMe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function FMe(e){const t=getComputedStyle(zoe(e)??e).display;return t==="flex"||t==="inline-flex"}function BMe(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||FMe(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"||jMe.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function NW(e){let t=e.length;for(;t--;){const n=e[t];if(tr(n,"Missing node"),BMe(n))return n}return null}function IW(e){return e&&Number(getComputedStyle(e).zIndex)||0}function DW(e){const t=[];for(;e;)t.push(e),e=zoe(e);return t}function zoe(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}function UMe(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 $Me({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!(n instanceof HTMLElement)||n.contains(e)||e.contains(n))return!0;if(MMe(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(UMe(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Hoe(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const a=PMe()?kW.coarse:kW.precise,s=Loe(i),o=LMe(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=a&&o.distance.y<=a&&$Me({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function LW(e){if(e.defaultPrevented)return;const{mountedGroups:t}=ou(),n=Hoe(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(d=>{i.add(d)}),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)}),yo({interactionState:{hitRegions:n,initialLayoutMap:s,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}}),n.length&&e.preventDefault()}function PW(e){if(e.defaultPrevented)return;const{interactionState:t,mountedGroups:n}=ou();switch(t.state){case"active":{if(e.type!=="pointerleave"&&e.buttons===0){yo(r=>r.interactionState.state==="inactive"?r:{cursorFlags:0,interactionState:{state:"inactive"}});return}Boe({event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint});break}default:{const r=Hoe(e,n);r.length===0?t.state!=="inactive"&&yo({interactionState:{state:"inactive"}}):yo({interactionState:{hitRegions:r,state:"hover"}}),l5();break}}}function MW(e){if(e.defaultPrevented)return;e.preventDefault();const{interactionState:t}=ou();t.state==="active"&&(yo({cursorFlags:0,interactionState:{state:"inactive"}}),l5())}function jW(e){let t=0,n=0;const r={};for(const a of e)if(a.defaultSize!==void 0){t++;const s=Go(a.defaultSize);n+=s,r[a.panelId]=s}else r[a.panelId]=void 0;const i=e.length-t;if(i!==0){const a=Go((100-n)/i);for(const s of e)s.defaultSize===void 0&&(r[s.panelId]=a)}return r}function zMe(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=Km({group:e});i.onResize({asPercentage:Go(r.inlineSize/a*100),inPixels:r.inlineSize},i.id)}function HMe(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 VMe(e){let t=!0;const n=new Set,r=new Set,i=new ResizeObserver(g=>{for(const _ of g){const{borderBoxSize:x,target:b}=_;if(b===e.element){if(t){if(Km({group:e})===0)return;yo(v=>{const y=v.mountedGroups.get(e);if(y){const E=AW(e),T=y.defaultLayoutDeferred?jW(E):y.layout,w=Op({layout:T,panelConstraints:E});return!y.defaultLayoutDeferred&&Gg(T,w)&&HMe(y.derivedPanelConstraints,E)?v:{mountedGroups:new Map(v.mountedGroups).set(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:E,layout:w,separatorToPanels:y.separatorToPanels})}}return v})}}else zMe(e,b,x)}});i.observe(e.element),e.panels.forEach(g=>{tr(!n.has(g.id),`Panel ids must be unique; id "${g.id}" was used more than once`),n.add(g.id),g.onResize&&i.observe(g.element)});const a=Km({group:e}),s=AW(e),o=e.panels.map(({id:g})=>g).join(",");let l=e.defaultLayout;l&&e.panels.length!==Object.keys(l).length&&(l=void 0);const u=e.inMemoryLayouts[o]??l??jW(s),d=Op({layout:u,panelConstraints:s}),c=Loe(e),m=yo(g=>{const _=new Map;return c.forEach(x=>{x.separator&&_.set(x.separator,x.panels)}),{mountedGroups:new Map(g.mountedGroups).set(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:s,layout:d,separatorToPanels:_})}});return e.element.addEventListener("pointerleave",OW),e.separators.forEach(g=>{tr(!r.has(g.id),`Separator ids must be unique; id "${g.id}" was used more than once`),r.add(g.id),g.element.addEventListener("keydown",RW)}),m.mountedGroups.size===1&&(window.addEventListener("pointerdown",LW),window.addEventListener("pointermove",PW),window.addEventListener("pointerup",MW)),function(){t=!1;const g=yo(_=>{const x=new Map(_.mountedGroups);return x.delete(e),{mountedGroups:x}});e.element.removeEventListener("pointerleave",OW),e.separators.forEach(_=>{_.element.removeEventListener("keydown",RW)}),g.mountedGroups.size===0&&(window.removeEventListener("pointerdown",LW),window.removeEventListener("pointermove",PW),window.removeEventListener("pointerup",MW)),i.disconnect()}}function u5(e){const t=C.useId();return`${e??t}`}const Gp=typeof window<"u"?C.useLayoutEffect:C.useEffect;function c5(e){const t=C.useRef(e);return Gp(()=>{t.current=e},[e]),C.useCallback(n=>t.current?.(n),[t])}function d5(...e){return c5(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function WMe(e){const t=C.useRef({...e});return Gp(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const Voe="--react-resizable-panels--panel--pointer-events";function Woe(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 Goe=C.createContext(null);function GMe(e,t){const n=C.useRef({getLayout:()=>({}),setLayout:NMe});C.useImperativeHandle(t,()=>n.current,[]),Gp(()=>{Object.assign(n.current,Uoe({groupId:e}))})}function qMe({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:s,id:o,onLayoutChange:l,orientation:u="horizontal",style:d,...c}){const m=C.useRef({}),g=c5(z=>{Gg(m.current,z)||(m.current=z,l?.(z))}),_=u5(o),[x,b]=C.useState(!1),[v,y]=C.useState(null),[E,T]=C.useState(n??{}),[w,A]=C.useState([]),[O,R]=C.useState([]),N=C.useRef({lastExpandedPanelSizes:{},layouts:{}}),D=d5(y,a);GMe(_,s);const L=C.useMemo(()=>({id:_,orientation:u,registerPanel:z=>(A(H=>hP(u,[...H,z])),()=>{A(H=>H.filter(q=>q!==z))}),registerSeparator:z=>(R(H=>hP(u,[...H,z])),()=>{R(H=>H.filter(q=>q!==z))})}),[_,u]),U=WMe({defaultLayout:n,disableCursor:r}),M=C.useRef(null);Gp(()=>{if(v===null)return;const z={defaultLayout:U.defaultLayout,disableCursor:!!U.disableCursor,disabled:!!i,element:v,id:_,inMemoryLastExpandedPanelSizes:N.current.lastExpandedPanelSizes,inMemoryLayouts:N.current.layouts,orientation:u,panels:w,separators:O};M.current=z;const H=VMe(z),q=ou().mountedGroups.get(z);if(q){const{defaultLayoutDeferred:j,derivedPanelConstraints:F,layout:G}=q;!j&&F.length>0&&(T(G),g?.(G))}const K=lp.addListener("interactionStateChange",j=>{j.state==="active"?b(j.hitRegions.some(F=>F.group===z)):b(!1)}),$=lp.addListener("mountedGroupsChange",j=>{const F=j.get(z);if(F){const{defaultLayoutDeferred:G,derivedPanelConstraints:V,layout:J}=F;if(G||V.length===0)return;T(J),g?.(J)}});return()=>{M.current=null,H(),K(),$()}},[i,v,_,g,u,w,O,U]),C.useEffect(()=>{const z=M.current;z&&(z.defaultLayout=n,z.disableCursor=!!r)});const W={[Voe]:x?"none":void 0};for(const z in E){const H=Woe(_,z),q=E[z];W[H]=q}return p.jsx(Goe.Provider,{value:L,children:p.jsx("div",{...c,"aria-orientation":u,className:t,"data-group":!0,"data-testid":_,id:_,ref:D,style:{...d,...W,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap"},children:e})})}function f5(){const e=C.useContext(Goe);return tr(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function KMe({groupId:e,panelId:t}){const n=()=>{const{mountedGroups:o}=ou();for(const[l,{defaultLayoutDeferred:u,derivedPanelConstraints:d,layout:c,separatorToPanels:m}]of o)if(l.id===e)return{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:l,layout:c,separatorToPanels:m};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:d,group:c,layout:m,separatorToPanels:g}=n(),_=c.panels.findIndex(y=>y.id===t),x=_===c.panels.length-1,b=Gy({delta:x?l-o:o-l,initialLayout:m,panelConstraints:d,pivotIndices:x?[_-1,_]:[_,_+1],prevLayout:m,trigger:"imperative-api"}),v=Op({layout:b,panelConstraints:d});Gg(m,v)||yo(y=>({mountedGroups:new Map(y.mountedGroups).set(c,{defaultLayoutDeferred:u,derivedPanelConstraints:d,layout:v,separatorToPanels:g})}))};return{collapse:()=>{const{collapsible:o,collapsedSize:l}=r(),u=a();o&&u!==l&&s(l)},expand:()=>{const{collapsible:o,collapsedSize:l,minSize:u}=r(),d=a();o&&d===l&&s(u)},getSize:()=>{const{group:o}=n(),l=a(),{element:u}=i(),d=o.orientation==="horizontal"?u.offsetWidth:u.offsetHeight;return{asPercentage:l,inPixels:d}},isCollapsed:()=>{const{collapsible:o,collapsedSize:l}=r(),u=a();return o&&Ia(l,u)},resize:o=>{if(a()!==o){let l;switch(typeof o){case"number":{const{group:u}=n(),d=Km({group:u});l=Go(o/d*100);break}case"string":{l=parseFloat(o);break}}s(l)}}}}function YMe(e,t){const{id:n}=f5(),r=C.useRef({collapse:pO,expand:pO,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:pO});C.useImperativeHandle(t,()=>r.current,[]),Gp(()=>{Object.assign(r.current,KMe({groupId:n,panelId:e}))})}function XMe({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:d,style:c,...m}){const g=!!s,_=u5(s),[x,b]=C.useState(null),v=d5(b,a),{id:y,registerPanel:E}=f5(),T=u!==null,w=c5(O=>{u?.(O,s)});Gp(()=>{if(x!==null)return E({element:x,id:_,idIsStable:g,onResize:T?w:void 0,panelConstraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:o,minSize:l}})},[n,r,i,x,T,_,g,o,l,w,E]),YMe(_,d);const A=Woe(y,_);return p.jsx("div",{...m,"data-panel":!0,"data-testid":_,id:_,ref:v,style:{...ZMe,flexBasis:0,flexGrow:`var(${A}, 1)`,flexShrink:1,overflow:"hidden",pointerEvents:`var(${Voe})`},children:p.jsx("div",{className:t,style:{width:"100%",height:"100%",...c},children:e})})}const ZMe={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 QMe({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,d=[r,r+1];a=Op({layout:Gy({delta:u-s,initialLayout:e,panelConstraints:t,pivotIndices:d,prevLayout:e,trigger:"keyboard"}),panelConstraints:t})[n],i=Op({layout:Gy({delta:l-s,initialLayout:e,panelConstraints:t,pivotIndices:d,prevLayout:e,trigger:"keyboard"}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:s}}function JMe({children:e,className:t,elementRef:n,id:r,style:i,...a}){const s=u5(r),[o,l]=C.useState({}),[u,d]=C.useState("inactive"),[c,m]=C.useState(null),g=d5(m,n),{id:_,orientation:x,registerSeparator:b}=f5(),v=x==="horizontal"?"vertical":"horizontal";return Gp(()=>{if(c!==null){const y={element:c,id:s},E=b(y),T=lp.addListener("interactionStateChange",A=>{d(A.state!=="inactive"&&A.hitRegions.some(O=>O.separator===y)?A.state:"inactive")}),w=lp.addListener("mountedGroupsChange",A=>{A.forEach(({derivedPanelConstraints:O,layout:R,separatorToPanels:N},D)=>{if(D.id===_){const L=N.get(y);if(L){const U=L[0],M=D.panels.indexOf(U);l(QMe({layout:R,panelConstraints:O,panelId:U.id,panelIndex:M}))}}})});return()=>{T(),w(),E()}}},[c,_,s,b]),p.jsx("div",{...a,"aria-controls":o.valueControls,"aria-orientation":v,"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:g,role:"separator",style:{flexBasis:"auto",...i,flexGrow:0,flexShrink:0},tabIndex:0})}function Mf({className:e,direction:t,...n}){return p.jsx(qMe,{"data-slot":"resizable-panel-group",orientation:t,className:ze("flex h-full w-full data-[orientation=vertical]:flex-col",e),...n})}function so({...e}){return p.jsx(XMe,{"data-slot":"resizable-panel",...e})}function jf({withHandle:e,className:t,...n}){return p.jsx(JMe,{"data-slot":"resizable-handle",className:ze("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&&p.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:[p.jsx("span",{className:"w-0.5 h-0.5 rounded-full bg-muted-foreground"}),p.jsx("span",{className:"w-0.5 h-0.5 rounded-full bg-muted-foreground"}),p.jsx("span",{className:"w-0.5 h-0.5 rounded-full bg-muted-foreground"})]})})}var mO={exports:{}},FW;function e3e(){return FW||(FW=1,(function(e,t){(function(n,r){e.exports=r()})(globalThis,(()=>(()=>{var n={4567:function(s,o,l){var u=this&&this.__decorate||function(y,E,T,w){var A,O=arguments.length,R=O<3?E:w===null?w=Object.getOwnPropertyDescriptor(E,T):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(y,E,T,w);else for(var N=y.length-1;N>=0;N--)(A=y[N])&&(R=(O<3?A(R):O>3?A(E,T,R):A(E,T))||R);return O>3&&R&&Object.defineProperty(E,T,R),R},d=this&&this.__param||function(y,E){return function(T,w){E(T,w,y)}};Object.defineProperty(o,"__esModule",{value:!0}),o.AccessibilityManager=void 0;const c=l(9042),m=l(9924),g=l(844),_=l(4725),x=l(2585),b=l(3656);let v=o.AccessibilityManager=class extends g.Disposable{constructor(y,E,T,w){super(),this._terminal=y,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 A=0;A<this._terminal.rows;A++)this._rowElements[A]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[A]);if(this._topBoundaryFocusListener=A=>this._handleBoundaryFocus(A,0),this._bottomBoundaryFocusListener=A=>this._handleBoundaryFocus(A,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 m.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((A=>this._handleResize(A.rows)))),this.register(this._terminal.onRender((A=>this._refreshRows(A.start,A.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((A=>this._handleChar(A)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
37
37
|
`)))),this.register(this._terminal.onA11yTab((A=>this._handleTab(A)))),this.register(this._terminal.onKey((A=>this._handleKey(A.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,b.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,g.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(y){for(let E=0;E<y;E++)this._handleChar(" ")}_handleChar(y){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==y&&(this._charsToAnnounce+=y):this._charsToAnnounce+=y,y===`
|
|
38
38
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=c.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(y){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(y)||this._charsToConsume.push(y)}_refreshRows(y,E){this._liveRegionDebouncer.refresh(y,E,this._terminal.rows)}_renderRows(y,E){const T=this._terminal.buffer,w=T.lines.length.toString();for(let A=y;A<=E;A++){const O=T.lines.get(T.ydisp+A),R=[],N=O?.translateToString(!0,void 0,void 0,R)||"",D=(T.ydisp+A+1).toString(),L=this._rowElements[A];L&&(N.length===0?(L.innerText=" ",this._rowColumns.set(L,[0,1])):(L.textContent=N,this._rowColumns.set(L,R)),L.setAttribute("aria-posinset",D),L.setAttribute("aria-setsize",w))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(y,E){const T=y.target,w=this._rowElements[E===0?1:this._rowElements.length-2];if(T.getAttribute("aria-posinset")===(E===0?"1":`${this._terminal.buffer.lines.length}`)||y.relatedTarget!==w)return;let A,O;if(E===0?(A=T,O=this._rowElements.pop(),this._rowContainer.removeChild(O)):(A=this._rowElements.shift(),O=T,this._rowContainer.removeChild(A)),A.removeEventListener("focus",this._topBoundaryFocusListener),O.removeEventListener("focus",this._bottomBoundaryFocusListener),E===0){const R=this._createAccessibilityTreeNode();this._rowElements.unshift(R),this._rowContainer.insertAdjacentElement("afterbegin",R)}else{const R=this._createAccessibilityTreeNode();this._rowElements.push(R),this._rowContainer.appendChild(R)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(E===0?-1:1),this._rowElements[E===0?1:this._rowElements.length-2].focus(),y.preventDefault(),y.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;const y=document.getSelection();if(!y)return;if(y.isCollapsed)return void(this._rowContainer.contains(y.anchorNode)&&this._terminal.clearSelection());if(!y.anchorNode||!y.focusNode)return void console.error("anchorNode and/or focusNode are null");let E={node:y.anchorNode,offset:y.anchorOffset},T={node:y.focusNode,offset:y.focusOffset};if((E.node.compareDocumentPosition(T.node)&Node.DOCUMENT_POSITION_PRECEDING||E.node===T.node&&E.offset>T.offset)&&([E,T]=[T,E]),E.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(E={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(E.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 A=({node:N,offset:D})=>{const L=N instanceof Text?N.parentNode:N;let U=parseInt(L?.getAttribute("aria-posinset"),10)-1;if(isNaN(U))return console.warn("row is invalid. Race condition?"),null;const M=this._rowColumns.get(L);if(!M)return console.warn("columns is null. Race condition?"),null;let W=D<M.length?M[D]:M.slice(-1)[0]+1;return W>=this._terminal.cols&&(++U,W=0),{row:U,column:W}},O=A(E),R=A(T);if(O&&R){if(O.row>R.row||O.row===R.row&&O.column>=R.column)throw new Error("invalid range");this._terminal.select(O.column,O.row,(R.row-O.row)*this._terminal.cols-O.column+R.column)}}_handleResize(y){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let E=this._rowContainer.children.length;E<this._terminal.rows;E++)this._rowElements[E]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[E]);for(;this._rowElements.length>y;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const y=this._coreBrowserService.mainDocument.createElement("div");return y.setAttribute("role","listitem"),y.tabIndex=-1,this._refreshRowDimensions(y),y}_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 y=0;y<this._terminal.rows;y++)this._refreshRowDimensions(this._rowElements[y])}}_refreshRowDimensions(y){y.style.height=`${this._renderService.dimensions.css.cell.height}px`}};o.AccessibilityManager=v=u([d(1,x.IInstantiationService),d(2,_.ICoreBrowserService),d(3,_.IRenderService)],v)},3614:(s,o)=>{function l(m){return m.replace(/\r?\n/g,"\r")}function u(m,g){return g?"\x1B[200~"+m+"\x1B[201~":m}function d(m,g,_,x){m=u(m=l(m),_.decPrivateModes.bracketedPasteMode&&x.rawOptions.ignoreBracketedPasteMode!==!0),_.triggerDataEvent(m,!0),g.value=""}function c(m,g,_){const x=_.getBoundingClientRect(),b=m.clientX-x.left-10,v=m.clientY-x.top-10;g.style.width="20px",g.style.height="20px",g.style.left=`${b}px`,g.style.top=`${v}px`,g.style.zIndex="1000",g.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(m,g){m.clipboardData&&m.clipboardData.setData("text/plain",g.selectionText),m.preventDefault()},o.handlePasteEvent=function(m,g,_,x){m.stopPropagation(),m.clipboardData&&d(m.clipboardData.getData("text/plain"),g,_,x)},o.paste=d,o.moveTextAreaUnderMouseCursor=c,o.rightClickHandler=function(m,g,_,x,b){c(m,g,_),b&&x.rightClickSelect(m),g.value=x.selectionText,g.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(d,c,m){this._css.set(d,c,m)}getCss(d,c){return this._css.get(d,c)}setColor(d,c,m){this._color.set(d,c,m)}getColor(d,c){return this._color.get(d,c)}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,d,c){l.addEventListener(u,d,c);let m=!1;return{dispose:()=>{m||(m=!0,l.removeEventListener(u,d,c))}}}},3551:function(s,o,l){var u=this&&this.__decorate||function(v,y,E,T){var w,A=arguments.length,O=A<3?y:T===null?T=Object.getOwnPropertyDescriptor(y,E):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(v,y,E,T);else for(var R=v.length-1;R>=0;R--)(w=v[R])&&(O=(A<3?w(O):A>3?w(y,E,O):w(y,E))||O);return A>3&&O&&Object.defineProperty(y,E,O),O},d=this&&this.__param||function(v,y){return function(E,T){y(E,T,v)}};Object.defineProperty(o,"__esModule",{value:!0}),o.Linkifier=void 0;const c=l(3656),m=l(8460),g=l(844),_=l(2585),x=l(4725);let b=o.Linkifier=class extends g.Disposable{get currentLink(){return this._currentLink}constructor(v,y,E,T,w){super(),this._element=v,this._mouseService=y,this._renderService=E,this._bufferService=T,this._linkProviderService=w,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new m.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new m.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,g.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,g.toDisposable)((()=>{this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,c.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,c.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(v){this._lastMouseEvent=v;const y=this._positionFromMouseEvent(v,this._element,this._mouseService);if(!y)return;this._isMouseOut=!1;const E=v.composedPath();for(let T=0;T<E.length;T++){const w=E[T];if(w.classList.contains("xterm"))break;if(w.classList.contains("xterm-hover"))return}this._lastBufferCell&&y.x===this._lastBufferCell.x&&y.y===this._lastBufferCell.y||(this._handleHover(y),this._lastBufferCell=y)}_handleHover(v){if(this._activeLine!==v.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(v,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,v)||(this._clearCurrentLink(),this._askForLink(v,!0))}_askForLink(v,y){this._activeProviderReplies&&y||(this._activeProviderReplies?.forEach((T=>{T?.forEach((w=>{w.link.dispose&&w.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=v.y);let E=!1;for(const[T,w]of this._linkProviderService.linkProviders.entries())y?this._activeProviderReplies?.get(T)&&(E=this._checkLinkProviderResult(T,v,E)):w.provideLinks(v.y,(A=>{if(this._isMouseOut)return;const O=A?.map((R=>({link:R})));this._activeProviderReplies?.set(T,O),E=this._checkLinkProviderResult(T,v,E),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(v.y,this._activeProviderReplies)}))}_removeIntersectingLinks(v,y){const E=new Set;for(let T=0;T<y.size;T++){const w=y.get(T);if(w)for(let A=0;A<w.length;A++){const O=w[A],R=O.link.range.start.y<v?0:O.link.range.start.x,N=O.link.range.end.y>v?this._bufferService.cols:O.link.range.end.x;for(let D=R;D<=N;D++){if(E.has(D)){w.splice(A--,1);break}E.add(D)}}}}_checkLinkProviderResult(v,y,E){if(!this._activeProviderReplies)return E;const T=this._activeProviderReplies.get(v);let w=!1;for(let A=0;A<v;A++)this._activeProviderReplies.has(A)&&!this._activeProviderReplies.get(A)||(w=!0);if(!w&&T){const A=T.find((O=>this._linkAtPosition(O.link,y)));A&&(E=!0,this._handleNewLink(A))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!E)for(let A=0;A<this._activeProviderReplies.size;A++){const O=this._activeProviderReplies.get(A)?.find((R=>this._linkAtPosition(R.link,y)));if(O){E=!0,this._handleNewLink(O);break}}return E}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(v){if(!this._currentLink)return;const y=this._positionFromMouseEvent(v,this._element,this._mouseService);y&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,y)&&this._currentLink.link.activate(v,this._currentLink.link.text)}_clearCurrentLink(v,y){this._currentLink&&this._lastMouseEvent&&(!v||!y||this._currentLink.link.range.start.y>=v&&this._currentLink.link.range.end.y<=y)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,g.disposeArray)(this._linkCacheDisposables))}_handleNewLink(v){if(!this._lastMouseEvent)return;const y=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);y&&this._linkAtPosition(v.link,y)&&(this._currentLink=v,this._currentLink.state={decorations:{underline:v.link.decorations===void 0||v.link.decorations.underline,pointerCursor:v.link.decorations===void 0||v.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,v.link,this._lastMouseEvent),v.link.decorations={},Object.defineProperties(v.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:E=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==E&&(this._currentLink.state.decorations.pointerCursor=E,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",E))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:E=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==E&&(this._currentLink.state.decorations.underline=E,this._currentLink.state.isHovered&&this._fireUnderlineEvent(v.link,E))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((E=>{if(!this._currentLink)return;const T=E.start===0?0:E.start+1+this._bufferService.buffer.ydisp,w=this._bufferService.buffer.ydisp+1+E.end;if(this._currentLink.link.range.start.y>=T&&this._currentLink.link.range.end.y<=w&&(this._clearCurrentLink(T,w),this._lastMouseEvent)){const A=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);A&&this._askForLink(A,!1)}}))))}_linkHover(v,y,E){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(y,!0),this._currentLink.state.decorations.pointerCursor&&v.classList.add("xterm-cursor-pointer")),y.hover&&y.hover(E,y.text)}_fireUnderlineEvent(v,y){const E=v.range,T=this._bufferService.buffer.ydisp,w=this._createLinkUnderlineEvent(E.start.x-1,E.start.y-T-1,E.end.x,E.end.y-T-1,void 0);(y?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(w)}_linkLeave(v,y,E){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(y,!1),this._currentLink.state.decorations.pointerCursor&&v.classList.remove("xterm-cursor-pointer")),y.leave&&y.leave(E,y.text)}_linkAtPosition(v,y){const E=v.range.start.y*this._bufferService.cols+v.range.start.x,T=v.range.end.y*this._bufferService.cols+v.range.end.x,w=y.y*this._bufferService.cols+y.x;return E<=w&&w<=T}_positionFromMouseEvent(v,y,E){const T=E.getCoords(v,y,this._bufferService.cols,this._bufferService.rows);if(T)return{x:T[0],y:T[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(v,y,E,T,w){return{x1:v,y1:y,x2:E,y2:T,cols:this._bufferService.cols,fg:w}}};o.Linkifier=b=u([d(1,x.IMouseService),d(2,x.IRenderService),d(3,_.IBufferService),d(4,x.ILinkProviderService)],b)},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(x,b,v,y){var E,T=arguments.length,w=T<3?b:y===null?y=Object.getOwnPropertyDescriptor(b,v):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(x,b,v,y);else for(var A=x.length-1;A>=0;A--)(E=x[A])&&(w=(T<3?E(w):T>3?E(b,v,w):E(b,v))||w);return T>3&&w&&Object.defineProperty(b,v,w),w},d=this&&this.__param||function(x,b){return function(v,y){b(v,y,x)}};Object.defineProperty(o,"__esModule",{value:!0}),o.OscLinkProvider=void 0;const c=l(511),m=l(2585);let g=o.OscLinkProvider=class{constructor(x,b,v){this._bufferService=x,this._optionsService=b,this._oscLinkService=v}provideLinks(x,b){const v=this._bufferService.buffer.lines.get(x-1);if(!v)return void b(void 0);const y=[],E=this._optionsService.rawOptions.linkHandler,T=new c.CellData,w=v.getTrimmedLength();let A=-1,O=-1,R=!1;for(let N=0;N<w;N++)if(O!==-1||v.hasContent(N)){if(v.loadCell(N,T),T.hasExtendedAttrs()&&T.extended.urlId){if(O===-1){O=N,A=T.extended.urlId;continue}R=T.extended.urlId!==A}else O!==-1&&(R=!0);if(R||O!==-1&&N===w-1){const D=this._oscLinkService.getLinkData(A)?.uri;if(D){const L={start:{x:O+1,y:x},end:{x:N+(R||N!==w-1?0:1),y:x}};let U=!1;if(!E?.allowNonHttpProtocols)try{const M=new URL(D);["http:","https:"].includes(M.protocol)||(U=!0)}catch{U=!0}U||y.push({text:D,range:L,activate:(M,W)=>E?E.activate(M,W,L):_(0,W),hover:(M,W)=>E?.hover?.(M,W,L),leave:(M,W)=>E?.leave?.(M,W,L)})}R=!1,T.hasExtendedAttrs()&&T.extended.urlId?(O=N,A=T.extended.urlId):(O=-1,A=-1)}}b(y)}};function _(x,b){if(confirm(`Do you want to navigate to ${b}?
|
|
39
39
|
|
package/dist/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/png" href="/logo.png" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>Vibora - Harness Attention. Ship.</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-CtSyC4sN.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-BFg6RnDv.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|