@iryu54/stack-monitor
Version:
Monitor processes as a stack
95 lines • 71.2 kB
JavaScript
import{R as Xe,x as et,s as G,u as se,S as _,n as x,y as tt,P as nt,M as Ve,T as pe,e as ot,a as it,c as we,g as Ce,z as st,A as rt}from"./router-BlYJbnFA.js";import le from"./system-DypTfGqd.js";import{_ as F}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{B as lt,T as at,$ as Y,I as fe,J as Ie,K as Z,L as Se,g as N,M as ut,c as g,o as v,b as f,i as j,v as he,d as S,w as V,h as z,q as me,p as Q,F as L,k as B,l as Oe,N as ct,n as U,e as H,j as R,t as $,a as O,s as _e,O as ge,f as ee,S as M,x as X,y as Fe,u as P,P as dt,m as ft}from"./index-Dyc6L6BZ.js";import{b as vt,v as De,a as Ne,T as pt}from"./vue.runtime.esm-bundler-CUmbNKcA.js";import{a as ae}from"./axios-BZk75tkI.js";import{P as Ke}from"./Section-CIoUqrrC.js";import{s as ht,a as Re}from"./Markdown-D5RrXO2v.js";import"./Editor-R-oT1rsL.js";var mt=({dt:t})=>`
.p-speeddial {
position: static;
display: flex;
gap: ${t("speeddial.gap")};
}
.p-speeddial-button {
z-index: 1;
}
.p-speeddial-button.p-speeddial-rotate {
transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, background ${t("speeddial.transition.duration")}, color ${t("speeddial.transition.duration")}, border-color ${t("speeddial.transition.duration")},
box-shadow ${t("speeddial.transition.duration")}, outline-color ${t("speeddial.transition.duration")};
will-change: transform;
}
.p-speeddial-list {
margin: 0;
padding: 0;
list-style: none;
display: flex;
align-items: center;
justify-content: center;
transition: inset-block-start 0s linear ${t("speeddial.transition.duration")};
pointer-events: none;
outline: 0 none;
z-index: 2;
gap: ${t("speeddial.gap")};
}
.p-speeddial-item {
transform: scale(0);
opacity: 0;
transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, opacity 0.8s;
will-change: transform;
}
.p-speeddial-circle .p-speeddial-item,
.p-speeddial-semi-circle .p-speeddial-item,
.p-speeddial-quarter-circle .p-speeddial-item {
position: absolute;
}
.p-speeddial-mask {
position: absolute;
inset-inline-start: 0;
inset-block-start: 0;
width: 100%;
height: 100%;
opacity: 0;
background: ${t("mask.background")};
border-radius: 6px;
transition: opacity 150ms;
}
.p-speeddial-mask-visible {
pointer-events: none;
opacity: 1;
transition: opacity 150ms;
}
.p-speeddial-open .p-speeddial-list {
pointer-events: auto;
}
.p-speeddial-open .p-speeddial-item {
transform: scale(1);
opacity: 1;
}
.p-speeddial-open .p-speeddial-rotate {
transform: rotate(45deg);
}
`;function ue(t){"@babel/helpers - typeof";return ue=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ue(t)}function Ee(t,e,n){return(e=gt(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gt(t){var e=yt(t,"string");return ue(e)=="symbol"?e:e+""}function yt(t,e){if(ue(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var o=n.call(t,e);if(ue(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var bt={root:function(e){var n=e.props;return{alignItems:(n.direction==="up"||n.direction==="down")&&"center",justifyContent:(n.direction==="left"||n.direction==="right")&&"center",flexDirection:n.direction==="up"?"column-reverse":n.direction==="down"?"column":n.direction==="left"?"row-reverse":n.direction==="right"?"row":null}},list:function(e){var n=e.props;return{flexDirection:n.direction==="up"?"column-reverse":n.direction==="down"?"column":n.direction==="left"?"row-reverse":n.direction==="right"?"row":null}}},kt={root:function(e){var n=e.instance,o=e.props;return["p-speeddial p-component p-speeddial-".concat(o.type),Ee(Ee(Ee({},"p-speeddial-direction-".concat(o.direction),o.type!=="circle"),"p-speeddial-open",n.d_visible),"p-disabled",o.disabled)]},pcButton:function(e){var n=e.props;return["p-speeddial-button",{"p-speeddial-rotate":n.rotateAnimation&&!n.hideIcon}]},list:"p-speeddial-list",item:"p-speeddial-item",action:"p-speeddial-action",actionIcon:"p-speeddial-action-icon",mask:function(e){var n=e.instance;return["p-speeddial-mask",{"p-speeddial-mask-visible":n.d_visible}]}},wt=lt.extend({name:"speeddial",style:mt,classes:kt,inlineStyles:bt}),Ct={name:"BaseSpeedDial",extends:ht,props:{model:null,visible:{type:Boolean,default:!1},direction:{type:String,default:"up"},transitionDelay:{type:Number,default:30},type:{type:String,default:"linear"},radius:{type:Number,default:0},mask:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},hideOnClickOutside:{type:Boolean,default:!0},buttonClass:null,maskStyle:null,maskClass:null,showIcon:{type:String,default:void 0},hideIcon:{type:String,default:void 0},rotateAnimation:{type:Boolean,default:!0},tooltipOptions:null,style:null,class:null,buttonProps:{type:Object,default:function(){return{rounded:!0}}},actionButtonProps:{type:Object,default:function(){return{severity:"secondary",rounded:!0,size:"small"}}},ariaLabelledby:{type:String,default:null},ariaLabel:{type:String,default:null}},style:wt,provide:function(){return{$pcSpeedDial:this,$parentInstance:this}}};function ce(t){"@babel/helpers - typeof";return ce=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ce(t)}function ze(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,o)}return n}function It(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ze(Object(n),!0).forEach(function(o){St(t,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ze(Object(n)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(n,o))})}return t}function St(t,e,n){return(e=Et(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Et(t){var e=xt(t,"string");return ce(e)=="symbol"?e:e+""}function xt(t,e){if(ce(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var o=n.call(t,e);if(ce(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ve(t){return Tt(t)||_t(t)||Ot(t)||Vt()}function Vt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ot(t,e){if(t){if(typeof t=="string")return Te(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Te(t,e):void 0}}function _t(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Tt(t){if(Array.isArray(t))return Te(t)}function Te(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,o=Array(e);n<e;n++)o[n]=t[n];return o}var xe=3.14159265358979,Ge={name:"SpeedDial",extends:Ct,inheritAttrs:!1,emits:["click","show","hide","focus","blur"],documentClickListener:null,container:null,list:null,data:function(){return{d_visible:this.visible,isItemClicked:!1,focused:!1,focusedOptionIndex:-1}},watch:{visible:function(e){this.d_visible=e}},mounted:function(){if(this.type!=="linear"){var e=Z(this.container,'[data-pc-name="pcbutton"]'),n=Z(this.list,'[data-pc-section="item"]');if(e&&n){var o=Math.abs(e.offsetWidth-n.offsetWidth),i=Math.abs(e.offsetHeight-n.offsetHeight);this.list.style.setProperty(Y("item.diff.x").name,"".concat(o/2,"px")),this.list.style.setProperty(Y("item.diff.y").name,"".concat(i/2,"px"))}}this.hideOnClickOutside&&this.bindDocumentClickListener()},beforeUnmount:function(){this.unbindDocumentClickListener()},methods:{getPTOptions:function(e,n){return this.ptm(n,{context:{active:this.isItemActive(e),hidden:!this.d_visible}})},onFocus:function(e){this.$emit("focus",e)},onBlur:function(e){this.focusedOptionIndex=-1,this.$emit("blur",e)},onItemClick:function(e,n){n.command&&n.command({originalEvent:e,item:n}),this.hide(),this.isItemClicked=!0,e.preventDefault()},onClick:function(e){this.d_visible?this.hide():this.show(),this.isItemClicked=!0,this.$emit("click",e)},show:function(){this.d_visible=!0,this.$emit("show")},hide:function(){this.d_visible=!1,this.$emit("hide")},calculateTransitionDelay:function(e){var n=this.model.length,o=this.d_visible;return(o?e:n-e-1)*this.transitionDelay},onTogglerKeydown:function(e){switch(e.code){case"ArrowDown":case"ArrowLeft":this.onTogglerArrowDown(e);break;case"ArrowUp":case"ArrowRight":this.onTogglerArrowUp(e);break;case"Escape":this.onEscapeKey();break}},onKeyDown:function(e){switch(e.code){case"ArrowDown":this.onArrowDown(e);break;case"ArrowUp":this.onArrowUp(e);break;case"ArrowLeft":this.onArrowLeft(e);break;case"ArrowRight":this.onArrowRight(e);break;case"Enter":case"NumpadEnter":case"Space":this.onEnterKey(e);break;case"Escape":this.onEscapeKey(e);break;case"Home":this.onHomeKey(e);break;case"End":this.onEndKey(e);break}},onTogglerArrowUp:function(e){this.show(),this.navigatePrevItem(e),e.preventDefault()},onTogglerArrowDown:function(e){this.show(),this.navigateNextItem(e),e.preventDefault()},onEnterKey:function(e){var n=this,o=fe(this.container,'[data-pc-section="item"]'),i=ve(o).findIndex(function(p){return p.id===n.focusedOptionIndex}),c=Z(this.container,"button");this.onItemClick(e,this.model[i]),this.onBlur(e),c&&Se(c)},onEscapeKey:function(){this.hide();var e=Z(this.container,"button");e&&Se(e)},onArrowUp:function(e){this.direction==="down"?this.navigatePrevItem(e):this.navigateNextItem(e)},onArrowDown:function(e){this.direction==="down"?this.navigateNextItem(e):this.navigatePrevItem(e)},onArrowLeft:function(e){var n=["left","up-right","down-left"],o=["right","up-left","down-right"];n.includes(this.direction)?this.navigateNextItem(e):o.includes(this.direction)?this.navigatePrevItem(e):this.navigatePrevItem(e)},onArrowRight:function(e){var n=["left","up-right","down-left"],o=["right","up-left","down-right"];n.includes(this.direction)?this.navigatePrevItem(e):o.includes(this.direction)?this.navigateNextItem(e):this.navigateNextItem(e)},onEndKey:function(e){e.preventDefault(),this.focusedOptionIndex=-1,this.navigatePrevItem(e)},onHomeKey:function(e){e.preventDefault(),this.focusedOptionIndex=-1,this.navigateNextItem(e)},navigateNextItem:function(e){var n=this.findNextOptionIndex(this.focusedOptionIndex);this.changeFocusedOptionIndex(n),e.preventDefault()},navigatePrevItem:function(e){var n=this.findPrevOptionIndex(this.focusedOptionIndex);this.changeFocusedOptionIndex(n),e.preventDefault()},changeFocusedOptionIndex:function(e){var n=fe(this.container,'[data-pc-section="item"]'),o=ve(n).filter(function(c){return!Ie(Z(c,"a"),"p-disabled")});if(o[e]){this.focusedOptionIndex=o[e].getAttribute("id");var i=Z(o[e],'[type="button"]');i&&Se(i)}},findPrevOptionIndex:function(e){var n=fe(this.container,'[data-pc-section="item"]'),o=ve(n).filter(function(p){return!Ie(Z(p,"a"),"p-disabled")}),i=e===-1?o[o.length-1].id:e,c=o.findIndex(function(p){return p.getAttribute("id")===i});return c=e===-1?o.length-1:c-1,c},findNextOptionIndex:function(e){var n=fe(this.container,'[data-pc-section="item"]'),o=ve(n).filter(function(p){return!Ie(Z(p,"a"),"p-disabled")}),i=e===-1?o[0].id:e,c=o.findIndex(function(p){return p.getAttribute("id")===i});return c=e===-1?0:c+1,c},calculatePointStyle:function(e){var n=this.type;if(n!=="linear"){var o=this.model.length,i=this.radius||o*20;if(n==="circle"){var c=2*xe/o;return{left:"calc(".concat(i*Math.cos(c*e),"px + ").concat(Y("item.diff.x").variable,")"),top:"calc(".concat(i*Math.sin(c*e),"px + ").concat(Y("item.diff.y").variable,")")}}else if(n==="semi-circle"){var p=this.direction,d=xe/(o-1),a="calc(".concat(i*Math.cos(d*e),"px + ").concat(Y("item.diff.x").variable,")"),u="calc(".concat(i*Math.sin(d*e),"px + ").concat(Y("item.diff.y").variable,")");if(p==="up")return{left:a,bottom:u};if(p==="down")return{left:a,top:u};if(p==="left")return{right:u,top:a};if(p==="right")return{left:u,top:a}}else if(n==="quarter-circle"){var y=this.direction,b=xe/(2*(o-1)),E="calc(".concat(i*Math.cos(b*e),"px + ").concat(Y("item.diff.x").variable,")"),A="calc(".concat(i*Math.sin(b*e),"px + ").concat(Y("item.diff.y").variable,")");if(y==="up-left")return{right:E,bottom:A};if(y==="up-right")return{left:E,bottom:A};if(y==="down-left")return{right:A,top:E};if(y==="down-right")return{left:A,top:E}}}return{}},getItemStyle:function(e){var n=this.calculateTransitionDelay(e),o=this.calculatePointStyle(e);return It({transitionDelay:"".concat(n,"ms")},o)},bindDocumentClickListener:function(){var e=this;this.documentClickListener||(this.documentClickListener=function(n){e.d_visible&&e.isOutsideClicked(n)&&e.hide(),e.isItemClicked=!1},document.addEventListener("click",this.documentClickListener))},unbindDocumentClickListener:function(){this.documentClickListener&&(document.removeEventListener("click",this.documentClickListener),this.documentClickListener=null)},isOutsideClicked:function(e){return this.container&&!(this.container.isSameNode(e.target)||this.container.contains(e.target)||this.isItemClicked)},isItemVisible:function(e){return typeof e.visible=="function"?e.visible():e.visible!==!1},isItemActive:function(e){return e===this.focusedOptionId},containerRef:function(e){this.container=e},listRef:function(e){this.list=e}},computed:{containerClass:function(){return[this.cx("root"),this.class]},focusedOptionId:function(){return this.focusedOptionIndex!==-1?this.focusedOptionIndex:null}},components:{Button:G,PlusIcon:et},directives:{ripple:Xe,tooltip:at}},jt=["id"],At=["id","data-p-active"];function $t(t,e,n,o,i,c){var p=N("Button"),d=ut("tooltip");return v(),g(L,null,[f("div",Q({ref:c.containerRef,class:c.containerClass,style:[t.style,t.sx("root")]},t.ptmi("root")),[he(t.$slots,"button",{visible:i.d_visible,toggleCallback:c.onClick},function(){return[S(p,Q({class:[t.cx("pcButton"),t.buttonClass],disabled:t.disabled,"aria-expanded":i.d_visible,"aria-haspopup":!0,"aria-controls":t.$id+"_list","aria-label":t.ariaLabel,"aria-labelledby":t.ariaLabelledby,unstyled:t.unstyled,onClick:e[0]||(e[0]=function(a){return c.onClick(a)}),onKeydown:c.onTogglerKeydown},t.buttonProps,{pt:t.ptm("pcButton")}),{icon:V(function(a){return[he(t.$slots,"icon",{visible:i.d_visible},function(){return[i.d_visible&&t.hideIcon?(v(),z(me(t.hideIcon?"span":"PlusIcon"),Q({key:0,class:[t.hideIcon,a.class]},t.ptm("pcButton").icon,{"data-pc-section":"icon"}),null,16,["class"])):(v(),z(me(t.showIcon?"span":"PlusIcon"),Q({key:1,class:[i.d_visible&&t.hideIcon?t.hideIcon:t.showIcon,a.class]},t.ptm("pcButton").icon,{"data-pc-section":"icon"}),null,16,["class"]))]})]}),_:3},16,["class","disabled","aria-expanded","aria-controls","aria-label","aria-labelledby","unstyled","onKeydown","pt"])]}),f("ul",Q({ref:c.listRef,id:t.$id+"_list",class:t.cx("list"),style:t.sx("list"),role:"menu",tabindex:"-1",onFocus:e[1]||(e[1]=function(){return c.onFocus&&c.onFocus.apply(c,arguments)}),onBlur:e[2]||(e[2]=function(){return c.onBlur&&c.onBlur.apply(c,arguments)}),onKeydown:e[3]||(e[3]=function(){return c.onKeyDown&&c.onKeyDown.apply(c,arguments)})},t.ptm("list")),[(v(!0),g(L,null,B(t.model,function(a,u){return v(),g(L,{key:u},[c.isItemVisible(a)?(v(),g("li",Q({key:0,id:"".concat(t.$id,"_").concat(u),class:t.cx("item",{id:"".concat(t.$id,"_").concat(u)}),style:c.getItemStyle(u),role:"none","data-p-active":c.isItemActive("".concat(t.$id,"_").concat(u)),ref_for:!0},c.getPTOptions("".concat(t.$id,"_").concat(u),"item")),[t.$slots.item?(v(),z(me(t.$slots.item),{key:1,item:a,onClick:function(b){return c.onItemClick(b,a)},toggleCallback:function(b){return c.onItemClick(b,a)}},null,8,["item","onClick","toggleCallback"])):Oe((v(),z(p,Q({key:0,tabindex:-1,role:"menuitem",class:t.cx("pcAction",{item:a}),"aria-label":a.label,disabled:t.disabled,unstyled:t.unstyled,onClick:function(b){return c.onItemClick(b,a)},ref_for:!0},t.actionButtonProps,{pt:c.getPTOptions("".concat(t.$id,"_").concat(u),"pcAction")}),ct({_:2},[a.icon?{name:"icon",fn:V(function(y){return[he(t.$slots,"itemicon",{item:a,class:U(y.class)},function(){return[f("span",Q({class:[a.icon,y.class],ref_for:!0},c.getPTOptions("".concat(t.$id,"_").concat(u),"actionIcon")),null,16)]})]}),key:"0"}:void 0]),1040,["class","aria-label","disabled","unstyled","onClick","pt"])),[[d,{value:a.label,disabled:!t.tooltipOptions},t.tooltipOptions]])],16,At)):j("",!0)],64)}),128))],16,jt)],16),t.mask?(v(),g("div",Q({key:0,class:[t.cx("mask"),t.maskClass],style:t.maskStyle},t.ptm("mask")),null,16)):j("",!0)],64)}Ge.render=$t;const Lt={key:0,class:"fas fa-exclamation"},Pt={key:1,class:"fas fa-heartbeat success"},Mt={key:2,class:"fas fa-times warning"},Dt={key:3,class:"fas fa-square"},Nt={__name:"sidebarItem",props:{service:{default:null}},setup(t){const e=se(),n=t,o=H(()=>{var d;const p=e.currentRoute.value.fullPath.split("?")[0].split("/").filter(a=>a).pop();return(d=n.service)!=null&&d.label?encodeURIComponent(n.service.label)===p:!1});function i(c){localStorage.setItem("last-service-visisted",c.label||""),e.push({name:"stack-single",params:{label:c.label}})}return(c,p)=>(v(),g("div",{onClick:p[0]||(p[0]=d=>i(t.service)),class:U(["sidebar-item",{active:o.value,disabled:!t.service.enabled,crashed:t.service.crashed}])},[f("span",null,[t.service.crashed?(v(),g("i",Lt)):t.service.enabled&&!t.service.exited?(v(),g("i",Pt)):t.service.exited?(v(),g("i",Mt)):(v(),g("i",Dt)),R(" "+$(t.service.label),1)]),p[1]||(p[1]=f("i",{class:"fas fa-chevron-right hover","aria-hidden":"true"},null,-1))],2))}},Rt=F(Nt,[["__scopeId","data-v-3374b244"]]),zt={class:"title"},Bt={__name:"sidebarGroup",props:{header:{default:""},open:{default:!1}},emits:["open","close"],setup(t,{emit:e}){const n=t,o=e,i=O(n.open),c=O();_e(()=>n.open,async()=>{i.value=n.open,await ge(),c.value&&(c.value.style.maxHeight=`${c.value.scrollHeight}px`)});function p(){i.value=!i.value,i.value?o("open"):o("close")}return(d,a)=>(v(),g("div",{class:U({open:i.value})},[f("div",{class:"header",onClick:p},[a[0]||(a[0]=f("i",{class:"fas fa-chevron-right"},null,-1)),f("h3",zt,$(t.header),1)]),S(vt,{name:"fade-sidebar"},{default:V(()=>[i.value?(v(),g("div",{key:0,class:"slot-container",ref_key:"slotRef",ref:c},[he(d.$slots,"default",{},void 0,!0)],512)):j("",!0)]),_:3})],2))}},Jt=F(Bt,[["__scopeId","data-v-e715e98d"]]),Ut={components:{sidebarItem:Rt,sidebarGroup:Jt},props:{currentService:{default:null}},setup(){const t=se(),e=O(""),n=O("All"),o=O(!1),i=O(!1);ee(async()=>{await _.loadServices(),M.on("service:crash",async({label:a,code:u,signal:y})=>{x.next("error",`${a} has crashed with code ${u}`),await _.loadServices()}),M.on("service:exit",async({label:a,code:u,signal:y})=>{await _.loadServices()}),M.on("service:healthcheck:down",async({label:a,code:u,signal:y})=>{const b=await _.getService(a);b!=null&&b.crashed||await _.loadServices()}),M.on("service:healthcheck:up",async({label:a,code:u,signal:y})=>{const b=await _.getService(a);b!=null&&b.crashed&&await _.loadServices()})});const c=H(()=>tt(_.services.value.filter(a=>(a.label||"").toUpperCase().includes(e.value.toUpperCase()))).desc(a=>a.enabled)),p=H(()=>{const a=c.value.reduce((u,y)=>{var b;return(b=y.groups)!=null&&b.length&&y.groups.forEach(E=>{u[E]||(u[E]=[]),u[E].push(y)}),u},{});return Object.keys(a).map(u=>({label:u,services:a[u]})).sort((u,y)=>u.label.localeCompare(y.label))}),d=O("");return{groups:p,minimized:o,mouseInAnchor:i,openGroup:n,search:e,sortedStack:c,System:le,serviceLabelToAdd:d,addServiceError:H(()=>_.services.value.find(a=>a.label===d.value)?"A service already exists with this label":""),addService:()=>{_.services.value.find(a=>a.label===d.value)||ae.post("/stack/services",{label:d.value}).then(()=>{const a=d.value;setTimeout(()=>{t.push({name:"stack-single",params:{label:a},query:{tab:"Configuration"}})},100),d.value=""})},launchService(a){const u=c.value[0];a.ctrlKey&&u&&(u==null||u.restart(),localStorage.setItem("last-service-visisted",u.label||""),t.push({name:"stack-single",params:{label:u.label}}))}}}},qt={class:"sidebar"},Ft={class:"header"},Kt={class:"add-container"},Gt={class:"add"},Wt={key:0},Ht={key:0,class:"fas fa-thumbtack"},Qt={key:1,class:"fas fa-chevron-right"};function Yt(t,e,n,o,i,c){const p=N("sidebar-item"),d=N("sidebar-group");return v(),g("div",{class:U(["sidebar-root",{minimized:o.minimized,mouseInAnchor:o.mouseInAnchor}]),onMouseenter:e[9]||(e[9]=a=>o.mouseInAnchor=!0),onMouseleave:e[10]||(e[10]=a=>o.mouseInAnchor=!1)},[f("div",null,[f("div",qt,[f("div",Ft,[Oe(f("input",{type:"text","onUpdate:modelValue":e[0]||(e[0]=a=>o.search=a),onInput:e[1]||(e[1]=a=>o.openGroup="All"),placeholder:"Search service...",onKeypress:e[2]||(e[2]=Ne((...a)=>o.launchService&&o.launchService(...a),["enter"]))},null,544),[[De,o.search]]),f("i",{class:"fas fa-chevron-left",onClick:e[3]||(e[3]=a=>o.minimized=!0)})]),f("div",Kt,[f("div",Gt,[e[11]||(e[11]=f("i",{class:"fas fa-plus"},null,-1)),Oe(f("input",{"onUpdate:modelValue":e[4]||(e[4]=a=>o.serviceLabelToAdd=a),placeholder:"Add new service...",onKeypress:e[5]||(e[5]=Ne((...a)=>o.addService&&o.addService(...a),["enter"]))},null,544),[[De,o.serviceLabelToAdd]])]),o.addServiceError?(v(),g("label",Wt,$(o.addServiceError),1)):j("",!0)]),S(d,{header:"All",open:o.openGroup==="All",onOpen:e[6]||(e[6]=a=>o.openGroup="All")},{default:V(()=>[(v(!0),g(L,null,B(o.sortedStack,a=>(v(),z(p,{key:a.label,service:a},null,8,["service"]))),128))]),_:1},8,["open"]),(v(!0),g(L,null,B(o.groups,a=>(v(),z(d,{header:a.label,open:o.openGroup===a.label,onOpen:u=>o.openGroup=a.label,onClose:e[7]||(e[7]=u=>o.openGroup="All")},{default:V(()=>[(v(!0),g(L,null,B(a.services,u=>(v(),z(p,{key:u.label,service:u},null,8,["service"]))),128))]),_:2},1032,["header","open","onOpen"]))),256))])]),f("div",{class:"minimized anchor",onClick:e[8]||(e[8]=a=>o.minimized=!1)},[o.mouseInAnchor?(v(),g("i",Ht)):(v(),g("i",Qt))])],34)}const Zt=F(Ut,[["render",Yt],["__scopeId","data-v-cf918d77"]]);function Xt(t={}){let e;if(t.repoUrl)e=t.repoUrl;else if(t.user&&t.repo)e=`https://github.com/${t.user}/${t.repo}`;else throw new Error("You need to specify either the `repoUrl` option or both the `user` and `repo` options");const n=new URL(`${e}/issues/new`),o=["body","title","labels","template","milestone","assignee","projects"];for(const i of o){let c=t[i];if(c!==void 0){if(i==="labels"||i==="projects"){if(!Array.isArray(c))throw new TypeError(`The \`${i}\` option should be an array`);c=c.join(",")}n.searchParams.set(i,c)}}return n.toString()}const en=Xt({user:"clabroche",repo:"stack-monitor",body:`
## Issue
### Plateform
\`\`\`<Windows10, Archlinux, MacOS...>\`\`\`
### Configuration file
\`\`\` javascript
<upload your configuration file but without sensitive infos>
\`\`\`
### Description
\\<Which part of this application bug...>
### Reproduction
\\<Step to bug...>
`}),tn={key:0},nn={key:1},on={class:"messages"},sn={key:0,class:"badge"},rn={key:2,class:"badge"},ln={__name:"Notification",props:{width:{default:"420px"},notif:{default:null},nolimit:{default:!1}},setup(t){return(e,n)=>{var o,i,c,p,d,a,u;return t.notif?(v(),g("div",{key:0,class:U([t.notif.type,"notif"]),style:X({maxWidth:t.width})},[t.notif.hover?t.notif.serviceLabel?(v(),g("h2",nn,n[0]||(n[0]=[f("i",{class:"fas fa-chevron-right"},null,-1)]))):j("",!0):(v(),g(L,{key:0},[t.notif.serviceLabel?(v(),g("h2",tn,$(t.notif.serviceLabel),1)):j("",!0)],64)),f("div",on,[(v(!0),g(L,null,B((o=t.notif)==null?void 0:o.msgs,y=>{var b,E;return v(),g("div",{class:U(["message",{glow:((E=(b=t.notif)==null?void 0:b.msgs)==null?void 0:E.length)>1,oneline:!t.nolimit}]),key:y.label},[R($(y.label)+" ",1),t.notif.msgs.length>1&&(y==null?void 0:y.nb)>1?(v(),g("div",sn,$(y==null?void 0:y.nb),1)):j("",!0)],2)}),128))]),((c=(i=t.notif)==null?void 0:i.msgs)==null?void 0:c.length)===1&&((d=(p=t.notif)==null?void 0:p.msgs[0])==null?void 0:d.nb)>1?(v(),g("div",rn,$((u=(a=t.notif)==null?void 0:a.msgs[0])==null?void 0:u.nb),1)):j("",!0)],6)):j("",!0)}}},We=F(ln,[["__scopeId","data-v-e8fbbfbc"]]),an={components:{Notification:We},setup(){const t=(e,n)=>x.remove(e,n);return{notifs:x.notifs,remove:t,trash(){nt.map(x.notifs.value||[],async e=>{await new Promise(n=>setTimeout(n,50)),x.notifs.value.map(n=>t(n,!1))})}}}},un={class:"notifications-container"};function cn(t,e,n,o,i,c){var d;const p=N("notification");return v(),g("div",un,[(d=o.notifs)!=null&&d.length?(v(),g("div",{key:0,class:"trash",onClick:e[0]||(e[0]=(...a)=>o.trash&&o.trash(...a))},e[1]||(e[1]=[f("i",{class:"fas fa-trash"},null,-1)]))):j("",!0),S(pt,{tag:"div",class:"root-notification",name:"slide"},{default:V(()=>[(v(!0),g(L,null,B(o.notifs,a=>(v(),z(p,{key:a.id,notif:a,onClick:u=>o.remove(a,!0),onMouseenter:u=>a.hover=!0,onMouseleave:u=>a.hover=!1},null,8,["notif","onClick","onMouseenter","onMouseleave"]))),128))]),_:1})])}const dn=F(an,[["render",cn],["__scopeId","data-v-5b545583"]]);M.on("alert",t=>{x.next(t.type||"error",t.message,t.label,null,t.commandId)});const fn={components:{Modal:Ve,Notification:We},setup(){const t=O(null);return ee(()=>{x.openHistory.subscribe(()=>{var n;(n=t.value)==null||n.open()})}),{notifs:O(x.notifsHistory.value),remove(n){x.removeHistory(n,!0)},modal:t}}},vn={class:"notif-history-root"},pn={class:"notifications"};function hn(t,e,n,o,i,c){const p=N("notification"),d=N("modal");return v(),g("div",vn,[S(d,{position:"right",ref:"modal",width:"600px",noActions:!0},{header:V(()=>e[0]||(e[0]=[R(" Notifications ")])),body:V(()=>[f("div",pn,[(v(!0),g(L,null,B(o.notifs,a=>(v(),z(p,{key:a.id,width:"100%",notif:a,onClick:u=>o.remove(a),nolimit:!0},null,8,["notif","onClick"]))),128))])]),_:1},512)])}const mn=F(fn,[["render",hn],["__scopeId","data-v-5c55cf64"]]),gn=["title"],yn=["alt","src"],bn={__name:"SidebarViewModeItem",props:{button:{default:null}},setup(t){const e=se(),n=t,o=H(()=>e.currentRoute.value.fullPath.includes(n.button.active));return(i,c)=>(v(),z(Ke,{appendTo:"parent",trigger:"mouseenter",placement:"right"},{trigger:V(()=>[f("button",{onClick:c[0]||(c[0]=p=>t.button.click()),class:U([{active:o.value},"sidebar-item"]),title:t.button.text},[t.button.icon?(v(),g("i",{key:0,class:U({[t.button.icon]:!0}),"aria-hidden":"true"},null,2)):t.button.img?(v(),g("img",{key:1,alt:`Icon for ${t.button.text}`,src:t.button.img},null,8,yn)):j("",!0)],10,gn)]),content:V(()=>[R($(t.button.text),1)]),_:1}))}},kn=F(bn,[["__scopeId","data-v-8c3bce38"]]),wn={name:"doughtnut-chart",props:{value:{default:0},rayon:{default:150},strokeWidth:{default:25},strokeWidthBg:{default:10},strokeColorBg:{default:"#b8d3ca"},strokeColor:{default:"#5e9985"},padding:{default:50},title:{default:""},adjustTop:{default:0},adjustLeft:{default:0},adjustTitleTop:{default:0},adjustTitleLeft:{default:0},adjustSubtitleTop:{default:0},adjustSubtitleLeft:{default:0},adjustContainer:{default:0},subtitle:{default:""},width:{default:"auto"},textAlign:{default:"left"},noSubtitle:{default:!1},fontSize:{default:30},titleSuffix:{default:""},color:{default:"#606060"},placeholder:{default:""}},data(){return{anim:1}},mounted(){this.animation()},methods:{animation(){this.anim=this.anim?1:2}}},Cn=["title"],In=["width","height"],Sn=["stroke","stroke-width","cx","cy","r"],En=["stroke","stroke-width","cx","cy","r","stroke-dasharray","stroke-dashoffset"],xn=["y","fill","font-size"],Vn=["x","y","fill","font-size"],On=["x","y","fill"];function _n(t,e,n,o,i,c){return n.value!==null?(v(),g("div",{key:0,style:X({width:n.width,textAlign:n.textAlign,marginLeft:n.adjustLeft,marginTop:n.adjustTop}),class:"root",title:n.placeholder},[f("section",null,[(v(),g("svg",{width:n.rayon*2+n.strokeWidth+n.padding+n.adjustContainer,height:n.rayon*2+n.strokeWidth+n.padding+n.adjustContainer,xmlns:"http://www.w3.org/2000/svg"},[f("circle",{stroke:n.strokeColorBg,"stroke-width":n.strokeWidthBg,fill:"none",cx:n.rayon+n.strokeWidth/2+n.padding/2+n.adjustContainer/2,cy:n.rayon+n.strokeWidth/2+n.padding/2+n.adjustContainer/2,r:n.rayon},null,8,Sn),f("circle",{class:"circle",stroke:n.strokeColor,"stroke-width":n.strokeWidth,fill:"none",cx:n.rayon+n.strokeWidth/2+n.padding/2+n.adjustContainer/2,cy:n.rayon+n.strokeWidth/2+n.padding/2+n.adjustContainer/2,r:n.rayon,"stroke-dasharray":2*3.14*n.rayon,"stroke-dashoffset":2*3.14*n.rayon*(1-n.value/100)},null,8,En),n.noSubtitle?j("",!0):(v(),g("g",{key:0,class:U("info info-anim-"+i.anim)},[f("text",{class:"text",x:"50%",y:n.rayon+13+n.padding/2+n.adjustSubtitleTop,width:"70",textAlign:"center","dominant-baseline":"central","alignment-baseline":"central","text-anchor":"middle",fill:n.strokeColorBg,"font-weight":"bold","font-size":n.fontSize},$(n.value.toFixed(0))+"% ",9,xn)],2)),f("text",{class:"additionnalText",x:n.rayon+n.padding-10+n.adjustTitleLeft+n.adjustContainer/2,y:n.rayon+n.padding-25+n.adjustTitleTop+n.adjustContainer/2,width:"60","dominant-baseline":"central","alignment-baseline":"central","text-anchor":"middle",fill:n.color,"font-size":n.fontSize},$(n.title)+" "+$(n.titleSuffix),9,Vn),f("text",{class:"additionnalSubText",x:n.rayon+n.padding-10+n.adjustTitleLeft,y:n.rayon+10+n.padding+n.adjustTitleTop,width:"60","dominant-baseline":"central","alignment-baseline":"central","text-anchor":"middle",fill:n.color,"font-size":"15"},$(n.subtitle),9,On)],8,In))])],12,Cn)):j("",!0)}const Tn=F(wn,[["render",_n],["__scopeId","data-v-6a6c8b71"]]),jn={components:{SidebarViewModeItem:kn,DoughtnutChart:Tn,Popover:Ke,SpeedDial:Ge,Button:G},setup(){const t=se(),e=O([]),n=O([]),o=O(0),i=O(0);ee(async()=>{await _.loadServices();const{data:d}=await ae.get("/plugins/sidebar"),{data:a}=await ae.get("/plugins/sidebar-top");e.value=(d==null?void 0:d.flat())||[],n.value=(a==null?void 0:a.flat())||[],M.on("infos:global",u=>{const{memPercentage:y,cpu:b}=u;o.value=b,i.value=y})});function c(d){return d.placements.map(a=>{if(typeof a!="string")return{text:a.label,icon:a.icon,img:le.proxyImg(a.img),click:a.goTo?()=>t.push(a.goTo||"/"):()=>{},active:a.active}})}function p(d){return d.map(c).flat().filter(a=>a)}return{speedDialVisible:O(!0),Theme:pe,groups:H(()=>{const d=Object.keys(pe.themes.value).reduce((u,y)=>{const b=pe.themes.value[y];if(b.id=y,!b.public||!b.preview)return u;const E=b.group||"Unknown";return u[E]||(u[E]={group:"unknown",themes:[]}),u[E].group=E,u[E].themes.push(b),u},{});return Object.keys(d).map(u=>({group:u,themes:d[u].themes})).sort((u,y)=>u.group.localeCompare(y.group))}),buttons:H(()=>[{text:"Overview",active:"overview",icon:"fas fa-home",click:()=>t.push({name:"overview"})},{text:"Single View",active:"single",icon:"fas fa-columns",click:()=>{var a;const d=_.services.value.find(u=>u.label===localStorage.getItem("last-service-visisted"));d?t.push({name:"stack-single",params:{label:d.label}}):_.services.value[0]?t.push({name:"stack-single",params:{label:(a=_.services.value[0])==null?void 0:a.label}}):t.push({name:"stack-single-no-view"})}},{text:"Multiple view",active:"multiple",icon:"fas fa-th",click:()=>t.push({name:"stack-multiple"})},...p(n.value)]),buttonsPlugins:H(()=>[...p(e.value)]),buttonsBottom:H(()=>[{text:"Settings",active:"settings",icon:"fas fa-cog",click:()=>t.push({name:"settings-no-view"})},{text:"Disconnect",icon:"fas fa-unlink",click:()=>le.disconnect()}]),cpu:o,mem:i,System:le}}},An={class:"sidebar"},$n={key:0},Ln={key:1},Pn={style:{position:"relative"}},Mn=["onClick","title"],Dn=["alt","src"],Nn={class:"groups"},Rn={class:"group"},zn={class:"themes"},Bn=["onClick"],Jn={class:"view"};function Un(t,e,n,o,i,c){const p=N("sidebar-view-mode-item"),d=N("Popover"),a=N("doughtnut-chart");return v(),g("div",An,[o.buttons.length?(v(),g("ul",$n,[(v(!0),g(L,null,B(o.buttons,u=>(v(),z(p,{key:u.label,button:u},null,8,["button"]))),128))])):j("",!0),o.buttonsBottom.length?(v(),g("ul",Ln,[f("div",Pn,[(v(!0),g(L,null,B(o.buttonsPlugins,u=>(v(),g("div",{key:u==null?void 0:u.text},[S(d,{appendTo:"parent",trigger:"mouseenter",placement:"right"},{trigger:V(()=>[f("button",{onClick:y=>u==null?void 0:u.click(),class:U([{active:t.$router.currentRoute.value.fullPath.includes((u==null?void 0:u.active)||""),"button-speed-dial":!0},"sidebar-item"]),title:u==null?void 0:u.text},[u!=null&&u.icon?(v(),g("i",{key:0,class:U({[u==null?void 0:u.icon]:!0}),"aria-hidden":"true"},null,2)):u!=null&&u.img?(v(),g("img",{key:1,alt:`Icon for ${u==null?void 0:u.text}`,src:u==null?void 0:u.img,height:"10px"},null,8,Dn)):j("",!0)],10,Mn)]),content:V(()=>[R($(u==null?void 0:u.text),1)]),_:2},1024)]))),128))]),S(d,{appendTo:"parent",trigger:"mouseenter",placement:"right"},{trigger:V(()=>[S(a,{placeholder:"CPU",width:"10px",rayon:17,fontSize:"11",value:o.cpu*100,strokeWidth:3,strokeWidthBg:5,adjustSubtitleLeft:-2,adjustTitleTop:-5,adjustSubtitleTop:-11,padding:14,strokeColor:"var(--system-accent-backgroundColor3-lightest)",strokeColorBg:"var(--system-accent-backgroundColor1)"},null,8,["value"])]),content:V(()=>e[0]||(e[0]=[R(" CPU ")])),_:1}),S(d,{appendTo:"parent",trigger:"mouseenter",placement:"right"},{trigger:V(()=>[S(a,{placeholder:"RAM",width:"10px",rayon:17,value:o.mem,fontSize:"11",strokeWidth:3,strokeWidthBg:5,adjustSubtitleTop:-11,adjustSubtitleLeft:-2,adjustTitleTop:-5,padding:14,strokeColor:"var(--system-accent-backgroundColor3-tertiary-lightest)",strokeColorBg:"var(--system-accent-backgroundColor1-tertiary)"},null,8,["value"])]),content:V(()=>e[1]||(e[1]=[R(" RAM ")])),_:1}),S(d,{appendTo:"parent",trigger:"mouseenter",placement:"left-start",showOnCreate:!1},{trigger:V(()=>[S(p,{key:"Themes",button:{text:"",icon:"fas fa-sun",click:()=>o.Theme.toggle()}},null,8,["button"])]),content:V(()=>[f("div",Nn,[(v(!0),g(L,null,B(o.groups,u=>(v(),g("div",Rn,[R($(u.group)+" ",1),f("div",zn,[(v(!0),g(L,null,B(u.themes,y=>(v(),g("div",{class:"theme",onClick:b=>o.Theme.apply(y.id)},[S(d,{appendTo:"parent",trigger:"mouseenter",placement:"top",showOnCreate:!1},{trigger:V(()=>[f("div",Jn,[f("div",{class:"viewwindows",style:X({...y.preview.background||{},border:`4px solid ${y.preview.background.backgroundColor}`})},[f("div",{class:"rad",style:X(y.preview.foreground4||y.preview.foreground1)},null,4),f("div",{class:"rad",style:X(y.preview.foreground3||y.preview.foreground1)},null,4),f("div",{class:"rad",style:X(y.preview.foreground2||y.preview.foreground1)},null,4),f("div",{class:"rad",style:X(y.preview.foreground1)},null,4)],4)])]),content:V(()=>[R($(y.name||y.label),1)]),_:2},1024)],8,Bn))),256))])]))),256))])]),_:1}),(v(!0),g(L,null,B(o.buttonsBottom,u=>(v(),z(p,{key:u.label,button:u},null,8,["button"]))),128))])):j("",!0)])}const qn=F(jn,[["render",Un],["__scopeId","data-v-c033101a"]]),Fn={class:"reload-modal"},Kn={__name:"EnvironmentsChooser",setup(t){const e=se(),n=O(null),o=O([]),i=O(!1),c=O(null),p=O(null),d=O({label:"",color:"",bgColor:""});ee(a);async function a(){n.value=await _.getEnvironment(),o.value=await _.getEnvironments()}ee(()=>{M.on("reloadEnvironments",a)}),Fe(()=>{M.off("reloadEnvironments",a)});async function u(){var C,w;await((C=p.value)==null?void 0:C.open().promise)&&(w=d.value)!=null&&w.label&&(await _.createEnvironment(d.value),d.value={label:"",color:"",bgColor:""})}function y(){var A;return(A=_.services.value)==null?void 0:A.filter(C=>C.enabled).reduce((C,w)=>{var J,W;const T=Object.keys(((J=w==null?void 0:w.spawnOptions)==null?void 0:J.overrideEnvs)||{});return Object.keys(((W=w==null?void 0:w.spawnOptions)==null?void 0:W.env)||{}).some(oe=>T.includes(oe))&&C.push(w),C},[])}async function b({value:A}){const C=y();C!=null&&C.length&&c.value&&!await c.value.open(C).promise||(i.value=!0,await _.changeEnvironment(A).then(()=>{window.location.reload()}).catch(w=>{console.error(w),x.next("error","Problem has occured")}).finally(()=>{i.value=!1}))}function E(){e.push({name:"settings",params:{setting:"environments"}})}return(A,C)=>(v(),g(L,null,[n.value?(v(),g("div",{key:0,class:"banner",style:X({backgroundColor:n.value.bgColor||"transparent",color:n.value.color||"transparent"})},[f("div",null,[C[3]||(C[3]=R(" Current environment ")),S(P(ot),{class:"select",size:"small",defaultValue:n.value.label,value:n.value.label,onChange:b,options:o.value.filter(w=>w),optionLabel:"label",optionValue:"label",placeholder:"Select an environment"},{footer:V(()=>[S(P(G),{label:"Add New",fluid:"",severity:"secondary",text:"",size:"small",icon:"fas fa-plus",onClick:u}),S(P(G),{label:"Edit",fluid:"",severity:"secondary",text:"",size:"small",icon:"fas fa-edit",onClick:E})]),_:1},8,["defaultValue","value","options"])])],4)):j("",!0),i.value?(v(),z(dt,{key:1,to:"body"},[f("div",Fn,[S(it),C[4]||(C[4]=R(" Change environments... "))])])):j("",!0),S(Ve,{ref_key:"overrideModalRef",ref:c,cancelString:"Cancel",validateString:"Ok"},{header:V(({data:w})=>C[5]||(C[5]=[R(" Change environment ")])),body:V(({data:w})=>[C[6]||(C[6]=R(" Because .env in services root folder is the main truth. Some environments may not be taken into account. ")),f("ul",null,[(v(!0),g(L,null,B(w,T=>(v(),g("li",{key:T.id},[R($(T.label)+" ",1),f("ul",null,[(v(!0),g(L,null,B(T.spawnOptions.overrideEnvs,(K,J)=>(v(),g("li",null,$(J)+": "+$(K),1))),256))])]))),128))])]),_:1},512),S(Ve,{ref_key:"createEnvironmentModalRef",ref:p,cancelString:"Cancel",validateString:"Ok"},{header:V(()=>C[7]||(C[7]=[R(" Create environment ")])),body:V(()=>[S(P(we),null,{default:V(()=>[S(P(Ce),{id:"environment-to-create-label",size:"small",modelValue:d.value.label,"onUpdate:modelValue":C[0]||(C[0]=w=>d.value.label=w),fluid:""},null,8,["modelValue"]),C[8]||(C[8]=f("label",{for:"environment-to-create-label"},"Label",-1))]),_:1}),S(P(we),null,{default:V(()=>[S(P(Ce),{id:"environment-to-create-bgColor",size:"small",modelValue:d.value.bgColor,"onUpdate:modelValue":C[1]||(C[1]=w=>d.value.bgColor=w),fluid:""},null,8,["modelValue"]),C[9]||(C[9]=f("label",{for:"environment-to-create-bgColor"},"Background color",-1))]),_:1}),S(P(we),null,{default:V(()=>[S(P(Ce),{id:"environment-to-create-color",size:"small",modelValue:d.value.color,"onUpdate:modelValue":C[2]||(C[2]=w=>d.value.color=w),fluid:""},null,8,["modelValue"]),C[10]||(C[10]=f("label",{for:"environment-to-create-color"},"Color",-1))]),_:1})]),_:1},512)],64))}},Gn=F(Kn,[["__scopeId","data-v-42a01f9f"]]);function te(){}te.prototype={diff:function(e,n){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=o.callback;typeof o=="function"&&(i=o,o={}),this.options=o;var c=this;function p(w){return i?(setTimeout(function(){i(void 0,w)},0),!0):w}e=this.castInput(e),n=this.castInput(n),e=this.removeEmpty(this.tokenize(e)),n=this.removeEmpty(this.tokenize(n));var d=n.length,a=e.length,u=1,y=d+a,b=[{newPos:-1,components:[]}],E=this.extractCommon(b[0],n,e,0);if(b[0].newPos+1>=d&&E+1>=a)return p([{value:this.join(n),count:n.length}]);function A(){for(var w=-1*u;w<=u;w+=2){var T=void 0,K=b[w-1],J=b[w+1],W=(J?J.newPos:0)-w;K&&(b[w-1]=void 0);var oe=K&&K.newPos+1<d,re=J&&0<=W&&W<a;if(!oe&&!re){b[w]=void 0;continue}if(!oe||re&&K.newPos<J.newPos?(T=Hn(J),c.pushComponent(T.components,void 0,!0)):(T=K,T.newPos++,c.pushComponent(T.components,!0,void 0)),W=c.extractCommon(T,n,e,w),T.newPos+1>=d&&W+1>=a)return p(Wn(c,T.components,n,e,c.useLongestToken));b[w]=T}u++}if(i)(function w(){setTimeout(function(){if(u>y)return i();A()||w()},0)})();else for(;u<=y;){var C=A();if(C)return C}},pushComponent:function(e,n,o){var i=e[e.length-1];i&&i.added===n&&i.removed===o?e[e.length-1]={count:i.count+1,added:n,removed:o}:e.push({count:1,added:n,removed:o})},extractCommon:function(e,n,o,i){for(var c=n.length,p=o.length,d=e.newPos,a=d-i,u=0;d+1<c&&a+1<p&&this.equals(n[d+1],o[a+1]);)d++,a++,u++;return u&&e.components.push({count:u}),e.newPos=d,a},equals:function(e,n){return this.options.comparator?this.options.comparator(e,n):e===n||this.options.ignoreCase&&e.toLowerCase()===n.toLowerCase()},removeEmpty:function(e){for(var n=[],o=0;o<e.length;o++)e[o]&&n.push(e[o]);return n},castInput:function(e){return e},tokenize:function(e){return e.split("")},join:function(e){return e.join("")}};function Wn(t,e,n,o,i){for(var c=0,p=e.length,d=0,a=0;c<p;c++){var u=e[c];if(u.removed){if(u.value=t.join(o.slice(a,a+u.count)),a+=u.count,c&&e[c-1].added){var b=e[c-1];e[c-1]=e[c],e[c]=b}}else{if(!u.added&&i){var y=n.slice(d,d+u.count);y=y.map(function(A,C){var w=o[a+C];return w.length>A.length?w:A}),u.value=t.join(y)}else u.value=t.join(n.slice(d,d+u.count));d+=u.count,u.added||(a+=u.count)}}var E=e[p-1];return p>1&&typeof E.value=="string"&&(E.added||E.removed)&&t.equals("",E.value)&&(e[p-2].value+=E.value,e.pop()),e}function Hn(t){return{newPos:t.newPos,components:t.components.slice(0)}}function Qn(t,e){if(typeof t=="function")e.callback=t;else if(t)for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}var Be=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,Je=/\S/,$e=new te;$e.equals=function(t,e){return this.options.ignoreCase&&(t=t.toLowerCase(),e=e.toLowerCase()),t===e||this.options.ignoreWhitespace&&!Je.test(t)&&!Je.test(e)};$e.tokenize=function(t){for(var e=t.split(/(\s+|[()[\]{}'"]|\b)/),n=0;n<e.length-1;n++)!e[n+1]&&e[n+2]&&Be.test(e[n])&&Be.test(e[n+2])&&(e[n]+=e[n+2],e.splice(n+1,2),n--);return e};function Ue(t,e,n){return n=Qn(n,{ignoreWhitespace:!0}),$e.diff(t,e,n)}var He=new te;He.tokenize=function(t){var e=[],n=t.split(/(\n|\r\n)/);n[n.length-1]||n.pop();for(var o=0;o<n.length;o++){var i=n[o];o%2&&!this.options.newlineIsToken?e[e.length-1]+=i:(this.options.ignoreWhitespace&&(i=i.trim()),e.push(i))}return e};var Yn=new te;Yn.tokenize=function(t){return t.split(/(\S.+?[.!?])(?=\s+|$)/)};var Zn=new te;Zn.tokenize=function(t){return t.split(/([{}:;,]|\s+)/)};function ye(t){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ye=function(e){return typeof e}:ye=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ye(t)}var Xn=Object.prototype.toString,de=new te;de.useLongestToken=!0;de.tokenize=He.tokenize;de.castInput=function(t){var e=this.options,n=e.undefinedReplacement,o=e.stringifyReplacer,i=o===void 0?function(c,p){return typeof p>"u"?n:p}:o;return typeof t=="string"?t:JSON.stringify(je(t,null,null,i),i," ")};de.equals=function(t,e){return te.prototype.equals.call(de,t.replace(/,([\r\n])/g,"$1"),e.replace(/,([\r\n])/g,"$1"))};function je(t,e,n,o,i){e=e||[],n=n||[],o&&(t=o(i,t));var c;for(c=0;c<e.length;c+=1)if(e[c]===t)return n[c];var p;if(Xn.call(t)==="[object Array]"){for(e.push(t),p=new Array(t.length),n.push(p),c=0;c<t.length;c+=1)p[c]=je(t[c],e,n,o,i);return e.pop(),n.pop(),p}if(t&&t.toJSON&&(t=t.toJSON()),ye(t)==="object"&&t!==null){e.push(t),p={},n.push(p);var d=[],a;for(a in t)t.hasOwnProperty(a)&&d.push(a);for(d.sort(),c=0;c<d.length;c+=1)a=d[c],p[a]=je(t[a],e,n,o,a);e.pop(),n.pop()}else p=t;return p}var Ae=new te;Ae.tokenize=function(t){return t.slice()};Ae.join=Ae.removeEmpty=function(t){return t};const eo={key:0,class:"conflict-container"},to={class:"conflict-header"},no={key:0,class:"file-info"},oo={class:"version-actions"},io={key:0,class:"json-conflicts"},so={class:"json-conflicts-list"},ro={class:"json-header"},lo={class:"json-path"},ao={class:"manual-edit-actions"},uo={class:"conflict-section"},co={class:"conflict-versions"},fo=["onClick","data-index"],vo={class:"json-content"},po=["onClick","data-index"],ho={class:"json-content"},mo={class:"manual-edit-container"},go={key:1,class:"conflicts-container"},yo={class:"conflict-columns"},bo={class:"conflict-column"},ko={class:"interactive-conflict"},wo=["innerHTML"],Co={class:"conflict-column"},Io={class:"manual-edit-container"},So={key:1,class:"no-conflict-message"},Eo={class:"flex justify-content-end"},xo={class:"flex gap-2"},Vo={__name:"GitConflictModal",emits:["conflict-resolved"],setup(t,{expose:e,emit:n}){const o=O(!1),i=O(null),c=O([]);function p(r,s){const l=Ue(r,s),m=[];let h="",k=0;return l.forEach(I=>{if(I.added||I.removed){const D=`chunk-${k++}`;I.added?(m.push({id:D,ourVersion:"",theirVersion:I.value,selectedVersion:"ours"}),h+=`<span class="diff-chunk their-version not-selected" data-chunk-id="${D}">${I.value}</span>`):I.removed&&(m.push({id:D,ourVersion:I.value,theirVersion:"",selectedVersion:"ours"}),h+=`<span class="diff-chunk our-version selected" data-chunk-id="${D}">${I.value}</span>`)}else h+=`<span class="common-text">${I.value}</span>`}),[m,h]}function d(){i.value&&(i.value.isJson&&i.value.jsonConflicts?(i.value.jsonConflicts.forEach(r=>{r.selectedVersion="ours"}),T()):i.value.chunks&&(i.value.chunks.forEach(r=>{r.selectedVersion="ours";const s=document.querySelector(`.diff-chunk[data-chunk-id="${r.id}"]`);s&&(s.classList.contains("our-version")?(s.classList.add("selected"),s.classList.remove("not-selected")):(s.classList.remove("selected"),s.classList.add("not-selected")))}),y()))}function a(){i.value&&(i.value.isJson&&i.value.jsonConflicts?(i.value.jsonConflicts.forEach(r=>{r.selectedVersion="theirs"}),T()):i.value.chunks&&(i.value.chunks.forEach(r=>{r.selectedVersion="theirs";const s=document.querySelector(`.diff-chunk[data-chunk-id="${r.id}"]`);s&&(s.classList.contains("their-version")?(s.classList.add("selected"),s.classList.remove("not-selected")):(s.classList.remove("selected"),s.classList.add("not-selected")))}),y()))}function u(r){if(!i.value||!i.value.chunks)return;const s=i.value.chunks.find(m=>m.id===r);if(!s)return;s.selectedVersion=s.selectedVersion==="ours"?"theirs":"ours";const l=document.querySelector(`.diff-chunk[data-chunk-id="${r}"]`);l&&(l.classList.toggle("selected"),l.classList.toggle("not-selected"),l.classList.contains("our-version")?s.selectedVersion==="ours"?(l.classList.add("selected"),l.classList.remove("not-selected")):(l.classList.remove("selected"),l.classList.add("not-selected")):s.selectedVersion==="theirs"?(l.classList.add("selected"),l.classList.remove("not-selected")):(l.classList.remove("selected"),l.classList.add("not-selected"))),y()}function y(){if(!i.value||!i.value.chunks){console.warn("updateResolution appelée alors que currentConflict ou ses chunks sont null");return}try{let r="";const s=Ue(i.value.ourVersion,i.value.theirVersion),l=i.value.chunks;s.forEach(m=>{try{if(m.added){const h=l.find(k=>k.theirVersion===m.value&&k.ourVersion==="");h&&h.selectedVersion==="theirs"&&(r+=m.value)}else if(m.removed){const h=l.find(k=>k.ourVersion===m.value&&k.theirVersion==="");(!h||h.selectedVersion==="ours")&&(r+=m.value)}else r+=m.value}catch(h){console.error("Erreur lors du traitement d'une partie:",h)}}),i.value&&(i.value.resolution=r)}catch(r){console.error("Erreur lors de la mise à jour de la résolution:",r)}}function b(){if(!i.value){console.warn("setupChunkListeners appelé alors que currentConflict.value est null"),setTimeout(()=>{i.value&&b()},50);return}console.log("Mise en place des écouteurs d'événements sur les chunks");try{const r=()=>{const s=document.querySelectorAll(".json-value");console.log(`Found ${s.length} JSON value elements`),s.forEach(l=>{if(l instanceof HTMLElement){const m=l.getAttribute("data-version"),h=l.getAttribute("data-index");if(m&&h&&(m==="ours"||m==="theirs"))try{const k=parseInt(h,10);l.addEventListener("click",I=>{I.stopPropagation(),console.log(`Clic sur JSON value: index=${k}, version=${m}`),(m==="ours"||m==="theirs")&&w(k,m)}),l.style.cursor="pointer"}catch(k){console.error("Error parsing index:",k)}}})};ge(()=>{setTimeout(()=>{if(!i.value){console.warn("setupChunkListeners: currentConflict.value est devenu null pendant le délai");return}const s=document.querySelectorAll(".diff-chunk");if(console.log(`${s.length} chunks trouvés pour le conflit`),s.length===0){console.warn("Aucun chunk trouvé, tentative avec un délai plus long"),setTimeout(b,200);return}s.forEach(l=>{try{const m=l.getAttribute("data-chunk-id");if(m){l.replaceWith(l.cloneNode(!0));const h=document.querySelector(`.diff-chunk[data-chunk-id="${m}"]`);h&&(h.addEventListener("click",k=>{k.stopPropagation();try{console.log(`Clic sur le chunk ${m}`),u(m)}catch(I){console.error(`Erreur sur le clic du chunk ${m}:`,I)}}),h instanceof HTMLElement&&(h.style.cursor="pointer",h.style.userSelect="none"))}}catch(m){console.error("Erreur lors de la configuration d'un chunk:",m)}}),r(),console.log("Écouteurs d'événements ajoutés avec succès")},150)})}catch(r){console.error("Erreur générale dans setupChunkListeners:",r)}}function E(r,s){try{const l=JSON.parse(r),m=JSON.parse(s);return A(l,m)}catch{return[]}}function A(r,s,l=""){const m=[];for(const h in r){const k=l?`${l}.${h}`:h;if(!(h in s)){const I={path:k,ourValue:r[h],theirValue:void 0,selectedVersion:"ours",manualEdit:JSON.stringify(r[h],null,2)};m.push(I);continue}if(typeof r[h]=="object"&&r[h]!==null&&typeof s[h]=="object"&&s[h]!==null&&!Array.isArray(r[h])&&!Array.isArray(s[h])){m.push(...A(r[h],s[h],k));continue}if(JSON.stringify(r[h])!==JSON.stringify(s[h])){const I={path:k,ourValue:r[h],theirValue:s[h],selectedVersion:"ours",manualEdit:JSON.stringify(r[h],null,2)};m.push(I)}}for(const h in s)if(!(h in r)){const I={path:l?`${l}.${h}`:h,ourValue:void 0,theirValue:s[h],selectedVersion:"ours",manualEdit:"undefined"};m.push(I)}return m}function C(r){if(r===void 0)return"undefined";try{return JSON.stringify(r,null,2)}catch{return String(r)}}function w(r,s){if(console.log(`Tentative de sélection JSON : index=${r}, version=${s}`),!i.value||!i.value.jsonConflicts){console.error("selectJsonVersion: currentConflict ou jsonConflicts est null");return}const l=i.value.jsonConflicts[r];if(l){console.log(`Avant changement: selectedVersion=${l.selectedVersion}`),l.selectedVersion=s;const m=s==="ours"?l.ourValue:l.theirValue;l.manualEdit=C(m),console.log(`Après changement: selectedVersion=${l.selectedVersion}, manualEdit mis à jour`),T()}else console.error(`Aucun conflit JSON trouvé à l'index ${r}`)}function T(){if(!i.value||!i.value.jsonConflicts){console.warn("updateJsonResolution appelée alors que currentConflict ou ses jsonConflicts sont null");return}try{console.log("Mise à jour de la résolution JSON à partir des éditions manuelles");const r=JSON.parse(i.value.ourVersion),s=JSON.parse(JSON.stringify(r));if(i.value.jsonConflicts.forEach((l,m)=>{try{if(!l||!l.path){console.warn(`Conflit JSON invalide ou sans chemin à l'index ${m}`);return}const h=l.path.split(".");let k=s;for(let D=0;D<h.length-1;D++){const q=h[D];q in k||(k[q]={}),k=k[q]}const I=h[h.length-1];if(l.manualEdit&&l.manualEdit.trim()!==""&&l.manualEdit!=="undefined")try{console.log(`Utilisation de l'édition manuelle pour ${l.path}:`,l.manualEdit);const D=JSON.parse(l.manualEdit);k[I]=D,console.log(`Édition manuelle appliquée avec succès pour ${l.path}`)}catch(D){console.warn(`Échec du parsing de l'édition manuelle pour ${l.path}:`,D),console.log("Contenu de l'édition manuelle:",l.manualEdit),l.selectedVersion==="ours"?l.ourValue!==void 0?(console.log(`Fallback à notre version pour ${l.path}`),k[I]=l.ourValue):(console.log(`Suppression de ${l.path} car notre version est undefined`),delete k[I]):l.theirValue!==void 0?(console.log(`Fallback à leur version pour ${l.path}`),k[I]=l.theirValue):(console.log(`Suppression de ${l.path} car leur version est undefined`),delete k[I])}else console.log(`Pas d'édition manuelle pour ${l.path}, utilisation de la version ${l.selectedVersion}`),l.selectedVersion==="ours"?l.ourValue!==void 0?(k[I]=l.ourValue,console.log(`Utilisé notre version pour ${l.path}`)):(delete k[I],console.log(`Supprimé ${l.path} car notre version est undefined`)):l.theirValue!==void 0?(k[I]=l.theirValue,console.log(`Utilisé leur version pour ${l.path}`)):(delete k[I],console.log(`Supprimé ${l.path} car leur version est undefined`))}catch(h){console.error(`Erreur lors du traitement du conflit JSON à l'index ${m}:`,h)}}),i.value){const l=JSON.stringify(s,null,2);i.value.resolution=l,console.log("Résolution JSON finale mise à jour:",l.substring(0,100)+"...")}}catch(r){console.error("Erreur lors de la mise à jour de la résolution JSON:",r)}}H(()=>{if(!i.value||!i.value.resolution)return{};try{return JSON.parse(i.value.resolution)}catch{return{}}});async function K(r){if(!r)return!1;try{if(console.log("Affichage du conflit:",{id:r.id,filename:r.filename,hasOriginal:!!r.original,originalLength:r.original?r.original.length:0,hasOurVersion:!!r.ourVersion,hasTheirVersion:!!r.theirVersion}),!r.original)return console.error(`Impossible d'afficher le conflit: champ "original" manquant`),x.next("error","Impossible d'afficher ce conflit: données originales manquantes"),!1;const s=E(r.ourVersion,r.theirVersion),l=s.length>0,[m,h]=p(r.ourVersion,r.theirVersion);return i.value={...r,chunks:m,mergedDisplay:h,resolution:r.resolution||r.ourVersion,jsonConflicts:l?s:void 0,isJson:l},o.value=!0,setTimeout(()=>{var k;b(),l&&((k=i.value)!=null&&k.jsonConflicts)&&console.log("Configuration de l'interface pour les conflits JSON")},300),!0}catch(s){return console.error("Erreur lors de l'affichage du conflit:",s),x.next("error",`Échec de l'affichage du conflit: ${be(s)}`),!1}}function J(){var r;try{const s=(r=i.value)==null?void 0:r.id;console.log(`Fermeture de la modal pour le conflit ${s||"inconnu"}`),o.value=!1,i.value=null}catch(s){console.error("Erreur lors de la fermeture de la modal:",s)}}async function W(){try{await ie(),x.next("success","Liste des conflits rafraîchie")}catch(r){console.error("Erreur lors du rafraîchissement des conflits:",r),x.next("error","Erreur lors du rafraîchissement des conflits")}}async function oe(){try{x.next("success","Redémarrage de l'application en cours...","Veuillez patienter"),await _.restartApplication()}catch(r){console.error("Erreur lors du redémarrage de l'application:",r);const s=r instanceof Error?r.message:String(r);x.next("error",`Erreur lors du redémarrage: ${s}`)}}async function re(){console.log("Début de la résolution du conflit");const r=document.querySelector('button[label="Resolve and save"]');r&&r.setAttribute("disabled","disabled");try{const s=i.value?{...i.value}:null;if(!s){console.error("Impossible de résoudre : conflit est null"),x.next("error","Impossible de résoudre ce conflit. Données manquantes.");return}if(!s.resolution){console.error("Impossible de résoudre : résolution manquante"),x.next("error","Impossible de résoudre ce conflit. Résolution manquante.");return}if(!s.original){console.error("Impossible de résoudre : données originales manquantes"),x.next("error","Impossible de résoudre ce conflit. Données originales manquantes.");return}const l=s.id;console.log(`Résolution du conflit ${l} avec une copie sécurisée`);const m={conflictId:l,resolution:s.resolution,original:s.original};if(s.isJson&&s.resolution)try{const h=JSON.parse(s.resolution);if(s.filename&&s.filename.includes("/service/")&&h&&!h.label){console.error("Service sans label détecté lors de la résolution:",h),x.next("error",`Le service doit avoir une propriété "label". Veuillez l'ajouter manuellement.`);return}m.resolution=JSON.stringify(h)}catch(h){console.error("Erreur de parsing JSON:",h),x.next("error","Le format JSON de la résolution est invalide");return}console.log("Envoi de la résolution au serveur:",m);try{const h=await ae.post("/crypto/resolve-conflict",m);console.log("Réponse du serveur après résolution:",h.data),x.next("success","Conflit résolu avec succès, redémarrage de l'application..."),i.value&&i.value.id===l&&(console.log(`Fermeture du conflit ${l} après résolution`),o.value=!1,i.value=null),await ie(),setTimeout(async()=>{try{await oe()}catch(k){console.error("Erreur lors du redémarrage:",k)}},1e3);try{let k=null;if(s.filename&&s.filename.includes("/service/")){const I=s.filename.split("/"),q=I[I.length-1].replace(".encrypted.json","");console.log(`Attempting to restart service: ${q}`);try{const Me=(await _.loadServices()).find(Ze=>Ze.label===q);Me?(console.log(`Service found for restart: ${q}`),await Me.restart(),x.next("success",`Service ${q} restarted successfully`)):console.log(`No service found with name: ${q}`)}catch(Pe){console.error(`Error while searching/restarting service ${q}:`,Pe)}}else console.log("The file is not associated with a specific service, no restart needed")}catch(k){console.error("Error while attempting to restart the service:",k)}console.log("Immediate processing of the next conflict after resolution"),ne()}catch(h){throw console.error("Error during server request:",h),h}}catch(s){console.error("Error during conflict resolution:",s);let l="Error during conflict resolution";typeof s=="object"&&s!==null&&"response"in s&&s.response&&typeof s.response=="object"&&"data"in s.response&&s.response.data&&typeof s.response.data=="object"&&"message"in s.response.data?l=String(s.response.data.message):s instanceof Error&&(l=`${s.name}: ${s.message}`),x.next("error",l)}finally{r&&r.removeAttribute("disabled")}}async function ne(){if(console.log("Processing next conflict. Queue size:",c.value.length,"isVisible:",o.value),o.value||c.value.length===0){console.log("No conflict to process: modal already visible or empty queue");return}try{if(c.value.length===0){console.log("The queue is empty, nothing to process");return}const r={...c.value[0]};if(!r.id||!r.original){console.error("Invalid conflict found in the queue, ignored"),c.value.shift(),setTimeout(ne,50);return}console.log("Preparing to display the next conflict:",r.id),await K(r)?(console.log("Conflict displayed successfully, removing from queue"),c.value.shift()):(console.error("Failed to display conflict, it remains in the queue"),c.value.shift(),setTimeout(ne,200))}catch(r){console.error("Erreur lors du traitement du prochain conflit:",r),x.next("error",`Erreur lors du traitement du conflit: ${be(r)}`),c.value.length>0&&(c.value.shift(),setTimeout(ne,300))}}ee(async()=>{console.log("GitConflictModal mounted"),setTimeout(()=>{const s=document.querySelector(".conflict-dialog .p-dialog-content");s&&(console.log("Adding click event listener to modal content for debugging"),s.addEventListener("click",l=>{console.log("Click detected in modal content",{target:l.target,currentTarget:l.currentTarget,classes:l.target instanceof HTMLElement?Array.from(l.target.classList):[],id:l.target instanceof HTMLElement?l.target.id:null,tagName:l.target instanceof HTMLElement?l.target.tagName:null})}))},1e3);const r=new MutationObserver(s=>{for(const l of s)if(l.type==="attributes"&&l.attributeName==="class"){const m=document.querySelector(".conflict-dialog");m&&m.classList.contains("p-dialog-visible")&&(console.log("Modal is now visible - setting up click debugging"),document.querySelectorAll(".json-value").forEach(k=>{if(k instanceof HTMLElement){k.addEventListener("click",D=>{console.log("Direct click on json-value:",{element:k,classes:Array.from(k.classList),version:k.getAttribute("data-version"),index:k.getAttribute("data-index")})}),k.style.position="relative";const I=document.createElement("div");I.innerText="👆 Clickable",I.style.position="absolute",I.style.top="0",I.style.right="0",I.style.background="rgba(255,0,0,0.2)",I.style.color="white",I.style.padding="2px 5px",I.style.fontSize="10px",I.style.borderRadius="3px",k.appendChild(I)}}),r.disconnect())}});r.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["class"]}),i.value=null,o.value=!1,c.value=[],await ie(),M.on("crypto:conflict-resolved",async s=>{var l;try{if(console.log("Event crypto:conflict-resolved received:",s),!s||!s.conflictId){console.warn("Resolution event received without conflict ID");return}const m=s.conflictId,h=(l=i.value)==null?void 0:l.id;o.value&&h===m?(console.log(`Closing conflict ${m} following external resolution`),o.value=!1,i.value=null):console.log(`The resolved conflict ${m} is not currently displayed (displayed: ${h})`);const I=c.value.filter(q=>q.id!==m),D=c.value.length-I.length;D>0&&(console.log(`${D} conflict(s) removed from the queue`),c.value=I),await ie(),!o.value&&c.value.length>0&&(console.log("Scheduling processing of the next conflict"),setTimeout(ne,200))}catch(m){console.error("Error while processing conflict-resolved event:",m)}}),M.on("crypto:conflict",async s=>{try{if(!s||!s.id){console.warn("New conflict event received without valid data");return}console.log("New conflict detected:",s.id),await ie(),s&&s.id&&s.original&&ke(s)}catch(l){console.error("Error while processing a new conflict:",l)}})}),ft(()=>{console.log("GitConflictModal unmounted"),M.off("crypto:conflict-resolved"),M.off("crypto:conflict")});async function ie(){try{const{data:r}=await ae.get("/crypto/pending-conflicts");if(console.log("Conflicts retrieved from server:",r?r.length:0),Array.isArray(r)&&r.length>0){console.log("Details of retrieved conflicts:",r.map(l=>({id:l.id,filename:l.filename,hasOriginal:!!l.original,hasOurVersion:!!l.ourVersion,hasTheirVersion:!!l.theirVersion})));const s=r.filter(l=>!l.id||!l.original?(console.warn("Invalid conflict ignored (id or original missing):",l.id),!1):((!l.ourVersion||!l.theirVersion)&&console.warn("Conflict with missing versions:",l.id),!0));s.forEach(l=>{ke(l)}),s.length>0&&x.next("error",`${s.length} Git conflict(s) pending resolution`,"Git Conflicts")}}catch(r){console.error("Error while retrieving pending conflicts:",r),x.next("error",`Error while retrieving conflicts: ${be(r)}`)}}function be(r){if(!r)return"Unknown error";if(typeof r=="object"&&r!==null){if("response"in r&&r.response&&typeof r.response=="object"&&"data"in r.response&&r.response.data&&typeof r.response.data=="object"&&"message"in r.response.data)return String(r.response.data.message);if("message"in r&&typeof r.message=="string")return r.message}try{return String(r)}catch{return"Unknown error"}}function ke(r){console.log("Adding a new conflict to the queue:",r.id),c.value.push(r),ne()}function Qe(){}function Ye(r){if(!i.value){console.error("updateManualEditForConflict: currentConflict.value is null");return}if(!i.value.jsonConflicts){console.error("updateManualEditForConflict: jsonConflicts is null");return}if(r<0||r>=i.value.jsonConflicts.length){console.error(`updateManualEditForConflict: invalid index ${r}, jsonConflicts length: ${i.value.jsonConflicts.length}`);return}const s=i.value.jsonConflicts[r];if(!s){console.error(`updateManualEditForConflict: conflict at index ${r} is null`);return}try{s.manualEdit!==void 0&&T()}catch(l){console.error(`Error while updating manual edit for index ${r}:`,l)}}function Le(r,s){if(!i.value){console.error("useVersionInManualEdit: currentConflict.value is null");return}if(!i.value.jsonConflicts){console.error("useVersionInManualEdit: jsonConflicts is null");return}if(r<0||r>=i.value.jsonConflicts.length){console.error(`useVersionInManualEdit: invalid index ${r}, jsonConflicts length: ${i.value.jsonConflicts.length}`);return}const l=i.value.jsonConflicts[r];if(!l){console.error(`useVersionInManualEdit: conflict at index ${r} is null`);return}try{console.log(`Using version ${s} for manual edit at index ${r}`);const m=s==="ours"?l.ourValue:l.theirValue;l.manualEdit=C(m),l.selectedVersion=s,console.log(`Manual edit updated with version ${s}:`,l.manualEdit),T()}catch(m){console.error(`Error while updating manual version for index ${r}:`,m)}}return e({addConflict:ke,showConflict:K,resolveConflict:re,closeModal:J,refreshConflicts:W,processNextConflict:ne,fetchPendingConflicts:ie}),_e(o,r=>{r&&i.value&&(console.log("Modal displayed, setting up event listeners"),ge(()=>{b()}))}),_e(()=>{var r;return(r=i.value)==null?void 0:r.id},(r,s)=>{r&&r!==s&&(console.log(`New conflict displayed (${r}), setting up event listeners`),ge(()=>{b()}))}),(r,s)=>(v(),z(P(st),{visible:o.value,"onUpdate:visible":s[1]||(s[1]=l=>o.value=l),modal:!0,closable:!0,style:{width:"95vw"},maximizable:!0,header:"Git Conflict Resolution",class:"conflict-dialog"},{footer:V(()=>[f("div",Eo,[f("div",xo,[S(P(G),{label:"Cancel",icon:"pi pi-times",onClick:J,class:"p-button-text"}),S(P(G),{label:"Refresh",icon:"pi pi-refresh",onClick:W,class:"p-button-outlined"}),S(P(G),{label:"Resolve and save",icon:"pi pi-check",onClick:re,disabled:!i.value||!i.value.resolution||!i.value.original},null,8,["disabled"])])])]),default:V(()=>[i.value&&i.value.id?(v(),g("div",eo,[f("div",to,[i.value.filename?(v(),g("div",no,[s[2]||(s[2]=f("i",{class:"pi pi-file"},null,-1)),f("span",null,$(i.value.filename),1)])):j("",!0),f("div",oo,[S(P(G),{label:"Keep all your versions",icon:"pi pi-user",class:"p-button-outlined p-button-success",onClick:d}),S(P(G),{label:"Keep all their versions",icon:"pi pi-users",class:"p-button-outlined p-button-info",onClick:a})])]),i.value.isJson&&i.value.jsonConflicts&&i.value.jsonConflicts.length>0?(v(),g("div",io,[s[9]||(s[9]=f("h3",null,"Conflicts detected in JSON",-1)),f("div",so,[(v(!0),g(L,null,B(i.value.jsonConflicts,(l,m)=>(v(),g("div",{key:l.path||m,class:"json-conflict-item"},[f("div",ro,[f("div",lo,[s[3]||(s[3]=f("i",{class:"pi pi-key"},null,-1)),f("span",null,$(l.path||"Unknown path"),1)]),f("div",ao,[S(P(G),{label:"Use your version",size:"small",class:"p-button-sm p-button-text",onClick:h=>Le(m,"ours")},null,8,["onClick"]),S(P(G),{label:"Use remote version",size:"small",class:"p-button-sm p-button-text",onClick:h=>Le(m,"theirs")},null,8,["onClick"])])]),f("div",uo,[f("div",co,[f("div",{class:U(["json-value our-value",{selected:l.selectedVersion==="ours"}]),onClick:h=>w(m,"ours"),"data-version":"ours","data-index":m},[s[4]||(s[4]=f("div",{class:"json-value-header"},[f("span",{class:"legend-color your-version"}),f("span",null,"Your version")],-1)),f("pre",vo,$(C(l.ourValue)),1),s[5]||(s[5]=f("div",{class:"select-overlay"},"Click to select your version",-1))],10,fo),f("div",{class:U(["json-value their-value",{selected:l.selectedVersion==="theirs"}]),onClick:h=>w(m,"theirs"),"data-version":"theirs","data-index":m},[s[6]||(s[6]=f("div",{class:"json-value-header"},[f("span",{class:"legend-color their-version"}),f("span",null,"Remote version")],-1)),f("pre",ho,$(C(l.theirValue)),1),s[7]||(s[7]=f("div",{class:"select-overlay"},"Click to select remote version",-1))],10,po)]),f("div",mo,[s[8]||(s[8]=f("div",{class:"manual-edit-header"},[f("h4",null,"Manual editing (final)"),f("span",{class:"manual-edit-info"},"This value will be used with priority for resolution")],-1)),S(P(Re),{modelValue:l.manualEdit,"onUpdate:modelValue":h=>l.manualEdit=h,class:"manual-edit-area",onInput:h=>Ye(m),autoResize:!0},null,8,["modelValue","onUpdate:modelValue","onInput"])])])]))),128))])])):(v(),g("div",go,[f("div",yo,[f("div",bo,[s[10]||(s[10]=f("div",{class:"column-header"},[f("h4",null,"Differences")],-1)),f("div",ko,[i.value.mergedDisplay?(v(),g("div",{key:0,class:"interactive-editor",innerHTML:i.value.mergedDisplay},null,8,wo)):j("",!0)])]),f("div",Co,[s[12]||(s[12]=f("div",{class:"column-header"},[f("h4",null,"Manual editing")],-1)),f("div",Io,[s[11]||(s[11]=f("div",{class:"manual-edit-header"},[f("h4",null,"Manual editing (final)"),f("span",{class:"manual-edit-info"},"This value will be used with priority for resolution")],-1)),S(P(Re),{modelValue:i.value.resolution,"onUpdate:modelValue":s[0]||(s[0]=l=>i.value.resolution=l),class:"manual-edit-area",onInput:Qe,autoResize:!0},null,8,["modelValue"])])])])]))])):o.value?(v(),g("div",So,s[13]||(s[13]=[f("p",null,"No conflict to display or incomplete data.",-1)]))):j("",!0)]),_:1},8,["visible"]))}},Oo=F(Vo,[["__scopeId","data-v-43eafe4e"]]),qe=rt.filter(t=>t.load).reduce((t,{cmp:e,name:n})=>(t[n]=e,t),{}),_o={components:{sidebar:Zt,Notifications:dn,NotifHistory:mn,SidebarViewMode:qn,EnvironmentsChooser:Gn,GitConflictModal:Oo,...qe},setup(){(async()=>{const d=await _.getAdditionalThemes().catch(a=>(console.error(a),{}));pe.load(d)})();const t=se(),e=O(!0),n=O(null),o=O([]),i=async()=>{e.value=M.socket.connected,e.value||(_.services.value=[]),(t.currentRoute.value.fullPath.startsWith("/stack-single")||t.currentRoute.value.fullPath.startsWith("/stack-multiple"))&&t.push({name:"stack-chooser"}),await _.shouldSetup()&&t.push({name:"settings",params:{setting:"crypto"},query:{wrongKey:"true"}})};ee(async()=>{M.on("connect",i),M.on("disconnect",i),M.on("forceReload",()=>{window.location.reload()}),M.on("system:wrongKey",()=>t.push({name:"settings",params:{setting:"crypto"},query:{wrongKey:"true"}})),M.on("crypto:conflict",c),await i(),setTimeout(()=>{n.value&&typeof n.value.fetchPendingConflicts=="function"?(n.value.fetchPendingConflicts(),o.value.length>0&&(console.log(`Traitement de ${o.value.length} conflits en attente...`),o.value.forEach(d=>{n.value&&typeof n.value.addConflict=="function"&&n.value.addConflict(d)}),o.value=[])):console.warn("GitConflictModal n'est pas correctement initialisé, impossible de récupérer les conflits en attente.")},500)}),Fe(()=>{M.off("crypto:conflict",c)});function c(d){if(n.value&&typeof n.value.addConflict=="function"){n.value.addConflict(d),x.next("error","Conflit Git détecté dans un fichier chiffré","Conflit Git");return}console.log("GitConflictModal n'est pas encore prêt, nouvelle tentative dans 500ms..."),setTimeout(()=>{n.value&&typeof n.value.addConflict=="function"?(n.value.addConflict(d),x.next("error","Conflit Git détecté dans un fichier chiffré","Conflit Git")):(console.error("Impossible d'ajouter le conflit Git: le composant GitConflictModal n'est pas correctement initialisé."),o.value.push(d),x.next("error","Conflit Git détecté mais l'interface n'est pas prête. Rechargez la page pour le résoudre.","Conflit Git"))},500)}let p=O({local:"",remote:"",hasUpdate:!1});return ee(async()=>{var d;p.value=await le.hasUpdate(),(d=p.value)!=null&&d.hasUpdate&&x.next("error",`Update available: ${p.value.local} => ${p.value.remote}`)}),{componentsToLoad:O(Object.keys(qe)),redirect:i,connected:e,githubIssue:en,versions:p,gitConflictModalRef:n}}},To={key:0,id:"app-container"},jo={id:"app"},Ao={class:"main"},$o={key:1,class:"not-connected"},Lo=["href"];function Po(t,e,n,o,i,c){var C,w;const p=N("sidebar-view-mode"),d=N("sidebar"),a=N("router-view"),u=N("EnvironmentsChooser"),y=N("Finder"),b=N("notif-history"),E=N("notifications"),A=N("GitConflictModal");return v(),g(L,null,[o.connected?(v(),g("div",To,[f("div",jo,[["stack-chooser","import-create"].includes(((C=t.$route.name)==null?void 0:C.toString())||"")?j("",!0):(v(),z(p,{key:0})),["stack-single","stack-single-no-view"].includes(((w=t.$route.name)==null?void 0:w.toString())||"")?(v(),z(d,{key:1})):j("",!0),f("div",Ao,[S(a)])]),S(u)])):(v(),g("div",$o,[e[0]||(e[0]=R(" Server is not connected or has crashed ")),e[1]||(e[1]=f("br",null,null,-1)),e[2]||(e[2]=R(" Try to restart it or fill an issue: ")),e[3]||(e[3]=f("br",null,null,-1)),e[4]||(e[4]=f("br",null,null,-1)),f("a",{href:o.githubIssue,target:"_blank"},"Click here",8,Lo)])),(v(!0),g(L,null,B(o.componentsToLoad,T=>(v(),z(me(T)))),256)),S(y),S(b),S(E),S(A,{ref:"gitConflictModalRef"},null,512)],64)}const Fo=F(_o,[["render",Po],["__scopeId","data-v-6305c0f7"]]);export{Fo as default};