@knowsuchagency/fulcrum 5.6.0 → 5.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,7 +24,7 @@ Error generating stack: `+O.message+`
24
24
  `)?`
25
25
  `:"",A=E+k+y+w+T;t(A)}else t(e+(e?`
26
26
  `:"")+y)}catch(y){rt.error(s("errors.imageUploadFailed")),Yt.kanban.error("Upload error",{error:String(y)})}finally{o(!1)}return}}};return c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"relative",children:[c.jsx(Oc,{ref:l,value:e,onChange:f=>t(f.target.value),onPaste:d,className:Ae(a&&"opacity-50",n),disabled:a||r,...i}),a&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/50 rounded-md",children:c.jsx("span",{className:"text-sm text-muted-foreground",children:s("status.uploading")})})]}),u.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:u.map((f,h)=>c.jsx("a",{href:bse(f),target:"_blank",rel:"noopener noreferrer",className:"block",children:c.jsx("img",{src:bse(f),alt:`Attachment ${h+1}`,className:"h-16 w-auto rounded border object-cover hover:opacity-80 transition-opacity"})},h))})]})}function Ur({className:e,...t}){return c.jsx("label",{"data-slot":"label",className:Ae("gap-2 text-xs/relaxed leading-none font-medium group-data-[disabled=true]:opacity-50 peer-disabled:opacity-50 flex items-center select-none group-data-[disabled=true]:pointer-events-none peer-disabled:cursor-not-allowed",e),...t})}const gW=x.forwardRef(function(t,n){const{className:r,render:i,orientation:s="horizontal",...a}=t,o=x.useMemo(()=>({orientation:s}),[s]);return an("div",t,{state:o,ref:n,props:[{role:"separator","aria-orientation":s},a]})});function LUe({className:e,orientation:t="horizontal",...n}){return c.jsx(gW,{"data-slot":"separator",orientation:t,className:Ae("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",e),...n})}function qh({className:e,...t}){return c.jsx("div",{"data-slot":"field-group",className:Ae("gap-4 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4 group/field-group @container/field-group flex w-full flex-col",e),...t})}const MUe=Ym("data-[invalid=true]:text-destructive gap-2 group/field flex w-full",{variants:{orientation:{vertical:"flex-col [&>*]:w-full [&>.sr-only]:w-auto",horizontal:"flex-row items-center [&>[data-slot=field-label]]:flex-auto has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",responsive:"flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto @md/field-group:[&>[data-slot=field-label]]:flex-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"}},defaultVariants:{orientation:"vertical"}});function $n({className:e,orientation:t="vertical",...n}){return c.jsx("div",{role:"group","data-slot":"field","data-orientation":t,className:Ae(MUe({orientation:t}),e),...n})}function zn({className:e,...t}){return c.jsx(Ur,{"data-slot":"field-label",className:Ae("has-data-checked:bg-primary/5 dark:has-data-checked:bg-primary/10 gap-2 group-data-[disabled=true]/field:opacity-50 has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-2 group/field-label peer/field-label flex w-fit leading-snug","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",e),...t})}function Pi({className:e,...t}){return c.jsx("p",{"data-slot":"field-description",className:Ae("text-muted-foreground text-left text-xs/relaxed [[data-variant=legend]+&]:-mt-1.5 leading-normal font-normal group-has-[[data-orientation=horizontal]]/field:text-balance","last:mt-0 nth-last-2:-mt-1","[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4",e),...t})}function bSe(e){const t=x.useRef(!0);t.current&&(t.current=!1,e())}const ySe=x.createContext(null),vSe=x.createContext(null);function If(){const e=x.useContext(ySe);if(e===null)throw new Error(Un(60));return e}function xSe(){const e=x.useContext(vSe);if(e===null)throw new Error(Un(61));return e}const _Se=(e,t)=>Object.is(e,t);function Gh(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function xb(e,t,n){return!e||e.length===0?!1:e.some(r=>r===void 0?!1:Gh(r,t,n))}function ax(e,t,n){return!e||e.length===0?-1:e.findIndex(r=>r===void 0?!1:Gh(r,t,n))}function SSe(e,t,n){return e.filter(r=>!Gh(r,t,n))}function _$(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function wSe(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function ua(e,t){if(t&&e!=null)return t(e)??"";if(e&&typeof e=="object"){if("label"in e&&e.label!=null)return String(e.label);if("value"in e)return String(e.value)}return _$(e)}function sd(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?_$(e.value):_$(e)}function FUe(e,t,n){if(n&&e!=null)return n(e);if(e&&typeof e=="object"&&"label"in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return t[e]??ua(e,n);if(Array.isArray(t)){const r=wSe(t)?t.flatMap(i=>i.items):t;if(e==null){const i=r.find(s=>s.value==null);return i&&i.label!=null?i.label:ua(e,n)}if(typeof e!="object"){const i=r.find(s=>s&&s.value===e);return i&&i.label!=null?i.label:ua(e,n)}if("value"in e){const i=r.find(s=>s&&s.value===e.value);if(i&&i.label!=null)return i.label}}return ua(e,n)}function BUe(e,t){return!Array.isArray(e)||e.length===0?"":e.map(n=>ua(n,t)).join(", ")}const Wn={id:ft(e=>e.id),modal:ft(e=>e.modal),multiple:ft(e=>e.multiple),items:ft(e=>e.items),itemToStringLabel:ft(e=>e.itemToStringLabel),itemToStringValue:ft(e=>e.itemToStringValue),isItemEqualToValue:ft(e=>e.isItemEqualToValue),value:ft(e=>e.value),open:ft(e=>e.open),mounted:ft(e=>e.mounted),forceMount:ft(e=>e.forceMount),transitionStatus:ft(e=>e.transitionStatus),openMethod:ft(e=>e.openMethod),activeIndex:ft(e=>e.activeIndex),selectedIndex:ft(e=>e.selectedIndex),isActive:ft((e,t)=>e.activeIndex===t),isSelected:ft((e,t,n)=>{const r=e.isItemEqualToValue,i=e.value;return e.multiple?Array.isArray(i)&&i.some(s=>Gh(s,n,r)):e.selectedIndex===t&&e.selectedIndex!==null?!0:Gh(i,n,r)}),isSelectedByFocus:ft((e,t)=>e.selectedIndex===t),popupProps:ft(e=>e.popupProps),triggerProps:ft(e=>e.triggerProps),triggerElement:ft(e=>e.triggerElement),positionerElement:ft(e=>e.positionerElement),listElement:ft(e=>e.listElement),scrollUpArrowVisible:ft(e=>e.scrollUpArrowVisible),scrollDownArrowVisible:ft(e=>e.scrollDownArrowVisible),hasScrollArrows:ft(e=>e.hasScrollArrows),serializedValue:ft(e=>{const{multiple:t,value:n,itemToStringValue:r}=e;return t&&Array.isArray(n)&&n.length===0?"":sd(n,r)})};function ym(e,t){const n=x.useRef(e),r=_t(t);Lt(()=>{n.current!==e&&r(n.current)},[e,r]),Lt(()=>{n.current=e},[e])}function $Ue(e){const{id:t,value:n,defaultValue:r=null,onValueChange:i,open:s,defaultOpen:a=!1,onOpenChange:o,name:l,disabled:u=!1,readOnly:d=!1,required:f=!1,modal:h=!0,actionsRef:m,inputRef:g,onOpenChangeComplete:y,items:v,multiple:_=!1,itemToStringLabel:S,itemToStringValue:E,isItemEqualToValue:T=_Se,highlightItemOnHover:k=!0,children:w}=e,{clearErrors:A}=E1(),{setDirty:R,shouldValidateOnChange:I,validityData:D,setFilled:j,name:F,disabled:z,validation:P}=Hl(),{controlId:L}=Rf(),M=EC({id:t}),$=z||u,W=F??l,[Y,q]=Ml({controlled:n,default:_?r??Zo:r,name:"Select",state:"value"}),[K,X]=Ml({controlled:s,default:a,name:"Select",state:"open"}),U=x.useRef([]),J=x.useRef([]),te=x.useRef(null),ee=x.useRef(null),oe=x.useRef(0),ae=x.useRef(null),se=x.useRef([]),ue=x.useRef(!1),de=x.useRef(!1),ce=x.useRef(null),Ee=x.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}),Ie=x.useRef(!1),{mounted:fe,setMounted:be,transitionStatus:ge}=Lu(K),{openMethod:Ce,triggerProps:Re,reset:xe}=_C(K),ye=_a(()=>new Fb({id:M,modal:h,multiple:_,itemToStringLabel:S,itemToStringValue:E,isItemEqualToValue:T,value:Y,open:K,mounted:fe,transitionStatus:ge,items:v,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:{},triggerProps:{},triggerElement:null,positionerElement:null,listElement:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1})).current,De=Tt(ye,Wn.activeIndex),ve=Tt(ye,Wn.selectedIndex),Oe=Tt(ye,Wn.triggerElement),Be=Tt(ye,Wn.positionerElement),Te=x.useMemo(()=>_&&Array.isArray(Y)&&Y.length===0?"":sd(Y,E),[_,Y,E]),je=x.useMemo(()=>_&&Array.isArray(Y)?Y.map(Vt=>sd(Vt,E)):sd(Y,E),[_,Y,E]),ie=Wi(ye.state.triggerElement);C1({id:M,commit:P.commit,value:Y,controlRef:ie,name:W,getValue:()=>je});const Ke=x.useRef(Y);Lt(()=>{Y!==Ke.current&&ye.set("forceMount",!0)},[ye,Y]),Lt(()=>{j(Y!==null)},[Y,j]),Lt(function(){if(K)return;const en=se.current;if(_){const Ue=Array.isArray(Y)?Y:[];if(Ue.length===0){ye.set("selectedIndex",null);return}const ut=Ue[Ue.length-1],Kt=ax(en,ut,T);ye.set("selectedIndex",Kt===-1?null:Kt);return}const Fe=ax(en,Y,T);ye.set("selectedIndex",Fe===-1?null:Fe)},[_,K,Y,se,T,ye]),ym(Y,()=>{A(W),R(Y!==D.initialValue),I()?P.commit(Y):P.commit(Y,!0)});const lt=_t((Vt,en)=>{if(o?.(Vt,en),!en.isCanceled&&(X(Vt),!Vt&&ye.state.activeIndex!==null)){const Fe=U.current[ye.state.activeIndex];queueMicrotask(()=>{Fe?.setAttribute("tabindex","-1")})}}),Rt=_t(()=>{be(!1),ye.set("activeIndex",null),xe(),y?.(!1)});Sa({enabled:!m,open:K,ref:te,onComplete(){K||Rt()}}),x.useImperativeHandle(m,()=>({unmount:Rt}),[Rt]);const Ye=_t((Vt,en)=>{i?.(Vt,en),!en.isCanceled&&q(Vt)}),ct=_t(()=>{const Vt=ye.state.listElement||te.current;if(!Vt)return;const en=Vt.scrollTop,Fe=Vt.scrollTop+Vt.clientHeight,Ue=en>1,ut=Fe<Vt.scrollHeight-1;ye.state.scrollUpArrowVisible!==Ue&&ye.set("scrollUpArrowVisible",Ue),ye.state.scrollDownArrowVisible!==ut&&ye.set("scrollDownArrowVisible",ut)}),Ve=q3({open:K,onOpenChange:lt,elements:{reference:Oe,floating:Be}}),Et=wy(Ve,{enabled:!d&&!$,event:"mousedown"}),$e=Ey(Ve,{bubbles:!1}),Qe=JV(Ve,{enabled:!d&&!$,listRef:U,activeIndex:De,selectedIndex:ve,disabledIndices:Zo,onNavigate(Vt){Vt===null&&!K||ye.set("activeIndex",Vt)},focusItemOnHover:!1}),pt=tW(Ve,{enabled:!d&&!$&&(K||!_),listRef:J,activeIndex:De,selectedIndex:ve,onMatch(Vt){K?ye.set("activeIndex",Vt):Ye(se.current[Vt],$t("none"))},onTypingChange(Vt){ue.current=Vt}}),{getReferenceProps:at,getFloatingProps:gt,getItemProps:We}=Nf([Et,$e,Qe,pt]),Xe=x.useMemo(()=>gd(at(),Re),[at,Re]);bSe(()=>{ye.update({popupProps:gt(),triggerProps:Xe})}),Lt(()=>{ye.update({id:M,modal:h,multiple:_,value:Y,open:K,mounted:fe,transitionStatus:ge,popupProps:gt(),triggerProps:Xe,items:v,itemToStringLabel:S,itemToStringValue:E,isItemEqualToValue:T,openMethod:Ce})},[ye,M,h,_,Y,K,fe,ge,gt,Xe,v,S,E,T,Ce]);const it=x.useMemo(()=>({store:ye,name:W,required:f,disabled:$,readOnly:d,multiple:_,itemToStringLabel:S,itemToStringValue:E,highlightItemOnHover:k,setValue:Ye,setOpen:lt,listRef:U,popupRef:te,scrollHandlerRef:ee,handleScrollArrowVisibility:ct,scrollArrowsMountedCountRef:oe,getItemProps:We,events:Ve.context.events,valueRef:ae,valuesRef:se,labelsRef:J,typingRef:ue,selectionRef:Ee,selectedItemTextRef:ce,validation:P,onOpenChangeComplete:y,keyboardActiveRef:de,alignItemWithTriggerActiveRef:Ie,initialValueRef:Ke}),[ye,W,f,$,d,_,S,E,k,Ye,lt,We,Ve.context.events,P,y,ct]),ot=zl(g,P.inputRef),St=_&&Array.isArray(Y)&&Y.length>0,Xt=x.useMemo(()=>!_||!Array.isArray(Y)||!W?null:Y.map(Vt=>{const en=sd(Vt,E);return c.jsx("input",{type:"hidden",name:W,value:en},en)}),[_,Y,W,E]);return c.jsx(ySe.Provider,{value:it,children:c.jsxs(vSe.Provider,{value:Ve,children:[w,c.jsx("input",{...P.getInputValidationProps({onFocus(){ye.state.triggerElement?.focus()},onChange(Vt){if(Vt.nativeEvent.defaultPrevented)return;const en=Vt.target.value,Fe=$t(Es,Vt.nativeEvent);function Ue(){if(_)return;const ut=se.current.find(Kt=>sd(Kt,E).toLowerCase()===en.toLowerCase());ut!=null&&(R(ut!==D.initialValue),Ye(ut,Fe),I()&&P.commit(ut))}ye.set("forceMount",!0),queueMicrotask(Ue)}}),id:t||L||void 0,name:_?void 0:W,value:Te,disabled:$,required:f&&!St,readOnly:d,ref:ot,style:Zm,tabIndex:-1,"aria-hidden":!0}),Xt]})})}function bW(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e,"::before"),r=window.getComputedStyle(e,"::after");if(!(n.content!=="none"||r.content!=="none"))return t;const s=parseFloat(n.width)||0,a=parseFloat(n.height)||0,o=parseFloat(r.width)||0,l=parseFloat(r.height)||0,u=Math.max(t.width,s,o),d=Math.max(t.height,a,l),f=u-t.width,h=d-t.height;return{left:t.left-f/2,right:t.right+f/2,top:t.top-h/2,bottom:t.bottom+h/2}}const xA=2,zUe={...ay,...dp,value:()=>null},UUe=x.forwardRef(function(t,n){const{render:r,className:i,disabled:s=!1,nativeButton:a=!0,...o}=t,{setTouched:l,setFocused:u,validationMode:d,state:f,disabled:h}=Hl(),{labelId:m}=Rf(),{store:g,setOpen:y,selectionRef:v,validation:_,readOnly:S,alignItemWithTriggerActiveRef:E,disabled:T,keyboardActiveRef:k}=If(),w=h||T||s,A=Tt(g,Wn.open),R=Tt(g,Wn.value),I=Tt(g,Wn.triggerProps),D=Tt(g,Wn.positionerElement),j=Tt(g,Wn.listElement),F=Tt(g,Wn.serializedValue),z=Wi(D),P=x.useRef(null),L=si(),M=si(),{getButtonProps:$,buttonRef:W}=go({disabled:w,native:a}),Y=_t(ee=>{g.set("triggerElement",ee)}),q=zl(n,P,W,Y),K=si(),X=si();x.useEffect(()=>{if(A)return X.start(200,()=>{v.current.allowUnselectedMouseUp=!0,K.start(200,()=>{v.current.allowSelectedMouseUp=!0})}),()=>{K.clear(),X.clear()};v.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1},M.clear()},[A,v,M,K,X]);const U=x.useMemo(()=>j?.id??fE(D)?.id,[j,D]),J=gd(I,{role:"combobox","aria-expanded":A?"true":"false","aria-haspopup":"listbox","aria-controls":A?U:void 0,"aria-labelledby":m,"aria-readonly":S||void 0,tabIndex:w?-1:0,ref:q,onFocus(ee){u(!0),A&&E.current&&y(!1,$t(Ul,ee.nativeEvent)),L.start(0,()=>{g.set("forceMount",!0)})},onBlur(){l(!0),u(!1),d==="onBlur"&&_.commit(R)},onPointerMove(){k.current=!1},onKeyDown(){k.current=!0},onMouseDown(ee){if(A)return;const oe=ho(ee.currentTarget);function ae(se){if(!P.current)return;const ue=se.target;if(xn(P.current,ue)||xn(z.current,ue)||ue===P.current)return;const de=bW(P.current);se.clientX>=de.left-xA&&se.clientX<=de.right+xA&&se.clientY>=de.top-xA&&se.clientY<=de.bottom+xA||y(!1,$t(Z1e,se))}M.start(0,()=>{oe.addEventListener("mouseup",ae,{once:!0})})}},_.getValidationProps,o,$);J.role="combobox";const te=x.useMemo(()=>({...f,open:A,disabled:w,value:R,readOnly:S,placeholder:!F}),[f,A,w,R,S,F]);return an("button",t,{ref:[n,P],state:te,stateAttributesMapping:zUe,props:J})}),HUe={value:()=>null},VUe=x.forwardRef(function(t,n){const{className:r,render:i,children:s,...a}=t,{store:o,valueRef:l}=If(),u=Tt(o,Wn.value),d=Tt(o,Wn.items),f=Tt(o,Wn.itemToStringLabel),h=Tt(o,Wn.serializedValue),m=x.useMemo(()=>({value:u,placeholder:!h}),[u,h]),g=typeof s=="function"?s(u):s??(Array.isArray(u)?BUe(u,f):FUe(u,d,f));return an("span",t,{state:m,ref:[n,l],props:[{children:g},a],stateAttributesMapping:HUe})}),WUe=x.forwardRef(function(t,n){const{className:r,render:i,...s}=t,{store:a}=If(),o=Tt(a,Wn.open),l=x.useMemo(()=>({open:o}),[o]);return an("span",t,{state:l,ref:n,props:[{"aria-hidden":!0,children:"▼"},s],stateAttributesMapping:mC})}),qUe=x.createContext(void 0),GUe=x.forwardRef(function(t,n){const{store:r}=If(),i=Tt(r,Wn.mounted),s=Tt(r,Wn.forceMount);return i||s?c.jsx(qUe.Provider,{value:!0,children:c.jsx(x1,{ref:n,...t})}):null}),ESe=x.createContext(void 0);function yW(){const e=x.useContext(ESe);if(!e)throw new Error(Un(59));return e}function WO(e,t){e&&Object.assign(e.style,t)}const CSe={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},KUe={position:"fixed"},YUe=x.forwardRef(function(t,n){const{anchor:r,positionMethod:i="absolute",className:s,render:a,side:o="bottom",align:l="center",sideOffset:u=0,alignOffset:d=0,collisionBoundary:f="clipping-ancestors",collisionPadding:h,arrowPadding:m=5,sticky:g=!1,disableAnchorTracking:y,alignItemWithTrigger:v=!0,collisionAvoidance:_=I3,...S}=t,{store:E,listRef:T,labelsRef:k,alignItemWithTriggerActiveRef:w,selectedItemTextRef:A,valuesRef:R,initialValueRef:I,popupRef:D,setValue:j}=If(),F=xSe(),z=Tt(E,Wn.open),P=Tt(E,Wn.mounted),L=Tt(E,Wn.modal),M=Tt(E,Wn.value),$=Tt(E,Wn.openMethod),W=Tt(E,Wn.positionerElement),Y=Tt(E,Wn.triggerElement),q=Tt(E,Wn.isItemEqualToValue),K=x.useRef(null),X=x.useRef(null),[U,J]=x.useState(v),te=P&&U&&$!=="touch";!P&&U!==v&&J(v),Lt(()=>{P||(Wn.scrollUpArrowVisible(E.state)&&E.set("scrollUpArrowVisible",!1),Wn.scrollDownArrowVisible(E.state)&&E.set("scrollDownArrowVisible",!1))},[E,P]),x.useImperativeHandle(w,()=>te),xC((te||L)&&z&&$!=="touch",Y);const ee=w1({anchor:r,floatingRootContext:F,positionMethod:i,mounted:P,side:o,sideOffset:u,align:l,alignOffset:d,arrowPadding:m,collisionBoundary:f,collisionPadding:h,sticky:g,disableAnchorTracking:y??te,collisionAvoidance:_,keepMounted:!0}),oe=te?"none":ee.side,ae=te?KUe:ee.positionerStyles,se=x.useMemo(()=>{const be={};return z||(be.pointerEvents="none"),{role:"presentation",hidden:!P,style:{...ae,...be}}},[z,P,ae]),ue=x.useMemo(()=>({open:z,side:oe,align:ee.align,anchorHidden:ee.anchorHidden}),[z,oe,ee.align,ee.anchorHidden]),de=_t(be=>{E.set("positionerElement",be)}),ce=an("div",t,{ref:[n,de],state:ue,stateAttributesMapping:Po,props:[se,S]}),Ee=x.useRef(0),Ie=_t(be=>{if(be.size===0&&Ee.current===0||R.current.length===0)return;const ge=Ee.current;if(Ee.current=be.size,be.size===ge)return;const Ce=$t(Es);if(ge!==0&&!E.state.multiple&&M!==null&&ax(R.current,M,q)===-1){const xe=I.current,De=xe!=null&&xb(R.current,xe,q)?xe:null;j(De,Ce),De===null&&(E.set("selectedIndex",null),A.current=null)}if(ge!==0&&E.state.multiple&&Array.isArray(M)){const Re=M.filter(xe=>xb(R.current,xe,q));(Re.length!==M.length||Re.some(xe=>!xb(M,xe,q)))&&(j(Re,Ce),Re.length===0&&(E.set("selectedIndex",null),A.current=null))}if(z&&te){E.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const Re={height:""};WO(W,Re),WO(D.current,Re)}}),fe=x.useMemo(()=>({...ee,side:oe,alignItemWithTriggerActive:te,setControlledAlignItemWithTrigger:J,scrollUpArrowRef:K,scrollDownArrowRef:X}),[ee,oe,te,J]);return c.jsx(dC,{elementsRef:T,labelsRef:k,onMapChange:Ie,children:c.jsxs(ESe.Provider,{value:fe,children:[P&&L&&c.jsx(vC,{inert:Cy(!z),cutout:Y}),ce]})})});function kSe(e){const t=e.currentTarget.getBoundingClientRect();return t.top+1<=e.clientY&&e.clientY<=t.bottom-1&&t.left+1<=e.clientX&&e.clientX<=t.right-1}const _A="base-ui-disable-scrollbar",CE={className:_A,element:c.jsx("style",{href:_A,precedence:"base-ui:low",children:`.${_A}{scrollbar-width:none}.${_A}::-webkit-scrollbar{display:none}`})},XUe=x.createContext(void 0);function aD(e){return x.useContext(XUe)}const QUe={...Po,...ll},ZUe=x.forwardRef(function(t,n){const{render:r,className:i,...s}=t,{store:a,popupRef:o,onOpenChangeComplete:l,setOpen:u,valueRef:d,selectedItemTextRef:f,keyboardActiveRef:h,multiple:m,handleScrollArrowVisibility:g,scrollHandlerRef:y}=If(),{side:v,align:_,alignItemWithTriggerActive:S,setControlledAlignItemWithTrigger:E,scrollDownArrowRef:T,scrollUpArrowRef:k}=yW(),w=aD()!=null,A=xSe(),R=si(),I=Tt(a,Wn.id),D=Tt(a,Wn.open),j=Tt(a,Wn.mounted),F=Tt(a,Wn.popupProps),z=Tt(a,Wn.transitionStatus),P=Tt(a,Wn.triggerElement),L=Tt(a,Wn.positionerElement),M=Tt(a,Wn.listElement),$=x.useRef(0),W=x.useRef(!1),Y=x.useRef(0),q=x.useRef(!1),K=x.useRef({}),X=Oh(),U=_t(oe=>{if(!L||!o.current||!q.current)return;if(W.current||!S){g();return}const ae=L.style.top==="0px",se=L.style.bottom==="0px",ue=L.getBoundingClientRect().height,de=ho(L),ce=getComputedStyle(L),Ee=parseFloat(ce.marginTop),Ie=parseFloat(ce.marginBottom),fe=de.documentElement.clientHeight-Ee-Ie,be=oe.scrollTop,ge=oe.scrollHeight,Ce=oe.clientHeight,Re=ge-Ce;let xe=null,ye=null,De=!1;if(ae){const ve=Re-be,Oe=ue+ve,Be=Math.min(Oe,fe);xe=Be,Be!==fe?ye=Re:De=!0}else if(se){const ve=be-0,Oe=ue+ve,Be=Math.min(Oe,fe),Te=Oe-fe;xe=Be,Be!==fe?ye=0:(De=!0,be<Re&&(ye=be-(ve-Te)))}xe!=null&&(L.style.height=`${xe}px`),ye!=null&&(oe.scrollTop=ye),De&&(W.current=!0),g()});x.useImperativeHandle(y,()=>U,[U]),Sa({open:D,ref:o,onComplete(){D&&l?.(!0)}});const J=x.useMemo(()=>({open:D,transitionStatus:z,side:v,align:_}),[D,z,v,_]);Lt(()=>{!L||!o.current||Object.keys(K.current).length||(K.current={top:L.style.top||"0",left:L.style.left||"0",right:L.style.right,height:L.style.height,bottom:L.style.bottom,minHeight:L.style.minHeight,maxHeight:L.style.maxHeight,marginTop:L.style.marginTop,marginBottom:L.style.marginBottom})},[o,L]),Lt(()=>{j||S||(q.current=!1,W.current=!1,$.current=0,Y.current=0,WO(L,K.current))},[j,S,L,o]),Lt(()=>{const oe=o.current;if(!(!j||!P||!L||!oe)){if(!S){q.current=!0,X.request(g);return}queueMicrotask(()=>{const ae=getComputedStyle(L),se=getComputedStyle(oe),ue=ho(P),de=cs(L),ce=P.getBoundingClientRect(),Ee=L.getBoundingClientRect(),Ie=ce.left,fe=ce.height,be=M||oe,ge=be.scrollHeight,Ce=parseFloat(se.borderBottomWidth),Re=parseFloat(ae.marginTop)||10,xe=parseFloat(ae.marginBottom)||10,ye=parseFloat(ae.minHeight)||100,De=5,ve=5,Oe=20,Be=ue.documentElement.clientHeight-Re-xe,Te=ue.documentElement.clientWidth,je=Be-ce.bottom+fe,ie=f.current,Ke=d.current;let lt=0,Rt=0;if(ie&&Ke){const it=Ke.getBoundingClientRect(),ot=ie.getBoundingClientRect(),St=it.left-Ie,Xt=ot.left-Ee.left,Vt=it.top-ce.top+it.height/2,en=ot.top-Ee.top+ot.height/2;lt=St-Xt,Rt=en-Vt}const Ye=je+Rt+xe+Ce;let ct=Math.min(Be,Ye);const Ve=Be-Re-xe,Et=Ye-ct,$e=Math.max(De,Ie+lt),Qe=Te-ve,pt=Math.max(0,$e+Ee.width-Qe);L.style.left=`${$e-pt}px`,L.style.height=`${ct}px`,L.style.maxHeight="auto",L.style.marginTop=`${Re}px`,L.style.marginBottom=`${xe}px`,oe.style.height="100%";const at=be.scrollHeight-be.clientHeight,gt=Et>=at;gt&&(ct=Math.min(Be,Ee.height)-(Et-at));const We=ce.top<Oe||ce.bottom>Be-Oe||ct<Math.min(ge,ye),Xe=(de.visualViewport?.scale??1)!==1&&MV;if(We||Xe){q.current=!0,WO(L,K.current),_i.flushSync(()=>E(!1));return}if(gt){const it=Math.max(0,Be-Ye);L.style.top=Ee.height>=Ve?"0":`${it}px`,L.style.height=`${ct}px`,be.scrollTop=be.scrollHeight-be.clientHeight,$.current=Math.max(ye,ct)}else L.style.bottom="0",$.current=Math.max(ye,ct),be.scrollTop=Et;$.current===Be&&(W.current=!0),g(),setTimeout(()=>{q.current=!0})})}},[a,j,L,P,d,f,o,g,S,E,X,T,k,M]),x.useEffect(()=>{if(!S||!L||!j)return;const oe=cs(L);function ae(se){u(!1,$t(fFe,se))}return oe.addEventListener("resize",ae),()=>{oe.removeEventListener("resize",ae)}},[u,S,L,j]);const te={...M?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":m||void 0,id:`${I}-list`},onKeyDown(oe){h.current=!0,w&&Q3.has(oe.key)&&oe.stopPropagation()},onMouseMove(){h.current=!1},onPointerLeave(oe){if(kSe(oe)||oe.pointerType==="touch")return;const ae=oe.currentTarget;R.start(0,()=>{a.set("activeIndex",null),ae.focus({preventScroll:!0})})},onScroll(oe){M||y.current?.(oe.currentTarget)},...S&&{style:M?{height:"100%"}:CSe}},ee=an("div",t,{ref:[n,o],state:J,stateAttributesMapping:QUe,props:[F,te,Jm(z),{className:!M&&S?CE.className:void 0},s]});return c.jsxs(x.Fragment,{children:[CE.element,c.jsx(cC,{context:A,modal:!1,disabled:!j,restoreFocus:!0,children:ee})]})}),JUe=x.forwardRef(function(t,n){const{className:r,render:i,...s}=t,{store:a,scrollHandlerRef:o}=If(),{alignItemWithTriggerActive:l}=yW(),u=Tt(a,Wn.hasScrollArrows),d=Tt(a,Wn.openMethod),f=Tt(a,Wn.multiple),m={id:`${Tt(a,Wn.id)}-list`,role:"listbox","aria-multiselectable":f||void 0,onScroll(y){o.current?.(y.currentTarget)},...l&&{style:CSe},className:u&&d!=="touch"?CE.className:void 0},g=_t(y=>{a.set("listElement",y)});return an("div",t,{ref:[n,g],props:[m,s]})}),TSe=x.createContext(void 0);function vW(){const e=x.useContext(TSe);if(!e)throw new Error(Un(57));return e}const eHe=x.memo(x.forwardRef(function(t,n){const{render:r,className:i,value:s=null,label:a,disabled:o=!1,nativeButton:l=!1,...u}=t,d=x.useRef(null),f=S1({label:a,textRef:d,indexGuessBehavior:rW.GuessFromOrder}),{store:h,getItemProps:m,setOpen:g,setValue:y,selectionRef:v,typingRef:_,valuesRef:S,keyboardActiveRef:E,multiple:T,highlightItemOnHover:k}=If(),w=si(),A=Tt(h,Wn.isActive,f.index),R=Tt(h,Wn.isSelected,f.index,s),I=Tt(h,Wn.isSelectedByFocus,f.index),D=Tt(h,Wn.isItemEqualToValue),j=f.index,F=j!==-1,z=x.useRef(null),P=Wi(j);Lt(()=>{if(!F)return;const ee=S.current;return ee[j]=s,()=>{delete ee[j]}},[F,j,s,S]),Lt(()=>{if(!F)return;const ee=h.state.value;let oe=ee;T&&Array.isArray(ee)&&ee.length>0&&(oe=ee[ee.length-1]),oe!==void 0&&Gh(oe,s,D)&&h.set("selectedIndex",j)},[F,j,T,D,h,s]);const L=x.useMemo(()=>({disabled:o,selected:R,highlighted:A}),[o,R,A]),M=m({active:A,selected:R});M.onFocus=void 0,M.id=void 0;const $=x.useRef(null),W=x.useRef("mouse"),Y=x.useRef(!1),{getButtonProps:q,buttonRef:K}=go({disabled:o,focusableWhenDisabled:!0,native:l});function X(ee){const oe=h.state.value;if(T){const ae=Array.isArray(oe)?oe:[],se=R?SSe(ae,s,D):[...ae,s];y(se,$t(Lb,ee))}else y(s,$t(Lb,ee)),g(!1,$t(Lb,ee))}const U={role:"option","aria-selected":R,"aria-disabled":o||void 0,tabIndex:A?0:-1,onFocus(){h.set("activeIndex",j)},onMouseEnter(){!E.current&&h.state.selectedIndex===null&&h.set("activeIndex",j)},onMouseMove(){k&&h.set("activeIndex",j)},onMouseLeave(ee){!k||E.current||kSe(ee)||w.start(0,()=>{h.state.activeIndex===j&&h.set("activeIndex",null)})},onTouchStart(){v.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(ee){$.current=ee.key,h.set("activeIndex",j)},onClick(ee){Y.current=!1,!(ee.type==="keydown"&&$.current===null)&&(o||$.current===" "&&_.current||W.current!=="touch"&&!A||($.current=null,X(ee.nativeEvent)))},onPointerEnter(ee){W.current=ee.pointerType},onPointerDown(ee){W.current=ee.pointerType,Y.current=!0},onMouseUp(ee){if(o)return;if(Y.current){Y.current=!1;return}const oe=!v.current.allowSelectedMouseUp&&R,ae=!v.current.allowUnselectedMouseUp&&!R;oe||ae||W.current!=="touch"&&!A||X(ee.nativeEvent)}},J=an("div",t,{ref:[K,n,f.ref,z],state:L,props:[M,U,u,q]}),te=x.useMemo(()=>({selected:R,indexRef:P,textRef:d,selectedByFocus:I,hasRegistered:F}),[R,P,d,I,F]);return c.jsx(TSe.Provider,{value:te,children:J})})),tHe=x.forwardRef(function(t,n){const r=t.keepMounted??!1,{selected:i}=vW();return r||i?c.jsx(nHe,{...t,ref:n}):null}),nHe=x.memo(x.forwardRef((e,t)=>{const{render:n,className:r,keepMounted:i,...s}=e,{selected:a}=vW(),o=x.useRef(null),{transitionStatus:l,setMounted:u}=Lu(a),d=x.useMemo(()=>({selected:a,transitionStatus:l}),[a,l]),f=an("span",e,{ref:[t,o],state:d,props:[{"aria-hidden":!0,children:"✔️"},s],stateAttributesMapping:ll});return Sa({open:a,ref:o,onComplete(){a||u(!1)}}),f})),rHe=x.memo(x.forwardRef(function(t,n){const{indexRef:r,textRef:i,selectedByFocus:s,hasRegistered:a}=vW(),{selectedItemTextRef:o}=If(),{className:l,render:u,...d}=t,f=x.useCallback(m=>{if(!m||!a)return;const g=o.current===null||!o.current.isConnected;(s||g&&r.current===0)&&(o.current=m)},[o,r,s,a]);return an("div",t,{ref:[f,n,i],props:d})})),ASe=x.forwardRef(function(t,n){const{render:r,className:i,direction:s,keepMounted:a=!1,...o}=t,{store:l,popupRef:u,listRef:d,handleScrollArrowVisibility:f,scrollArrowsMountedCountRef:h}=If(),{side:m,scrollDownArrowRef:g,scrollUpArrowRef:y}=yW(),v=s==="up"?Wn.scrollUpArrowVisible:Wn.scrollDownArrowVisible,_=Tt(l,v),S=Tt(l,Wn.openMethod),E=_&&S!=="touch",T=si(),k=s==="up"?y:g,{transitionStatus:w,setMounted:A}=Lu(E);Lt(()=>(h.current+=1,l.state.hasScrollArrows||l.set("hasScrollArrows",!0),()=>{h.current=Math.max(0,h.current-1),h.current===0&&l.state.hasScrollArrows&&l.set("hasScrollArrows",!1)}),[l,h]),Sa({open:E,ref:k,onComplete(){E||A(!1)}});const R=x.useMemo(()=>({direction:s,visible:E,side:m,transitionStatus:w}),[s,E,m,w]),D=an("div",t,{ref:[n,k],state:R,props:[{"aria-hidden":!0,children:s==="up"?"▲":"▼",style:{position:"absolute"},onMouseMove(F){if(F.movementX===0&&F.movementY===0||T.isStarted())return;l.set("activeIndex",null);function z(){const P=l.state.listElement??u.current;if(!P)return;l.set("activeIndex",null),f();const L=P.scrollTop===0,M=Math.round(P.scrollTop+P.clientHeight)>=P.scrollHeight;if(d.current.length===0&&(s==="up"?l.set("scrollUpArrowVisible",!L):l.set("scrollDownArrowVisible",!M)),s==="up"&&L||s==="down"&&M){T.clear();return}if((l.state.listElement||u.current)&&d.current&&d.current.length>0){const W=d.current,Y=k.current?.offsetHeight||0;if(s==="up"){let q=0;const K=P.scrollTop+Y;for(let U=0;U<W.length;U+=1){const J=W[U];if(J&&J.offsetTop>=K){q=U;break}}const X=Math.max(0,q-1);if(X<q){const U=W[X];U&&(P.scrollTop=Math.max(0,U.offsetTop-Y))}else P.scrollTop=0}else{let q=W.length-1;const K=P.scrollTop+P.clientHeight-Y;for(let U=0;U<W.length;U+=1){const J=W[U];if(J&&J.offsetTop+J.offsetHeight>K){q=Math.max(0,U-1);break}}const X=Math.min(W.length-1,q+1);if(X>q){const U=W[X];U&&(P.scrollTop=U.offsetTop+U.offsetHeight-P.clientHeight+Y)}else P.scrollTop=P.scrollHeight-P.clientHeight}}T.start(40,z)}T.start(40,z)},onMouseLeave(){T.clear()}},o]});return E||a?D:null}),iHe=x.forwardRef(function(t,n){return c.jsx(ASe,{...t,ref:n,direction:"down"})}),sHe=x.forwardRef(function(t,n){return c.jsx(ASe,{...t,ref:n,direction:"up"})}),NSe=x.createContext(void 0);function aHe(){const e=x.useContext(NSe);if(e===void 0)throw new Error(Un(56));return e}const oHe=x.forwardRef(function(t,n){const{className:r,render:i,...s}=t,[a,o]=x.useState(),l=x.useMemo(()=>({labelId:a,setLabelId:o}),[a,o]),u=an("div",t,{ref:n,props:[{role:"group","aria-labelledby":a},s]});return c.jsx(NSe.Provider,{value:l,children:u})}),lHe=x.forwardRef(function(t,n){const{className:r,render:i,id:s,...a}=t,{setLabelId:o}=aHe(),l=ds(s);return Lt(()=>{o(l)},[l,o]),an("div",t,{ref:n,props:[{id:l},a]})}),Qr=$Ue;function yse({className:e,...t}){return c.jsx(oHe,{"data-slot":"select-group",className:Ae("scroll-my-1 p-1",e),...t})}function Zr({className:e,...t}){return c.jsx(VUe,{"data-slot":"select-value",className:Ae("flex flex-1 text-left",e),...t})}function Jr({className:e,size:t="default",children:n,...r}){return c.jsxs(UUe,{"data-slot":"select-trigger","data-size":t,className:Ae("border-border data-[placeholder]:text-muted-foreground bg-input dark:bg-input/80 dark:hover:bg-input focus-visible:border-ring focus-visible:ring-ring/30 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 gap-1.5 rounded-md border px-2 py-1.5 text-xs/relaxed transition-colors focus-visible:ring-[2px] aria-invalid:ring-[2px] data-[size=default]:h-7 data-[size=sm]:h-6 *:data-[slot=select-value]:flex *:data-[slot=select-value]:gap-1.5 [&_svg:not([class*='size-'])]:size-3.5 flex w-fit items-center justify-between whitespace-nowrap outline-none disabled:cursor-not-allowed disabled:opacity-50 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center [&_svg]:pointer-events-none [&_svg]:shrink-0",e),...r,children:[n,c.jsx(WUe,{render:c.jsx(Z,{icon:Z_e,strokeWidth:2,className:"text-muted-foreground size-3.5 pointer-events-none"})})]})}function ei({className:e,children:t,side:n="bottom",sideOffset:r=4,align:i="center",alignOffset:s=0,alignItemWithTrigger:a=!0,...o}){return c.jsx(GUe,{children:c.jsx(YUe,{side:n,sideOffset:r,align:i,alignOffset:s,alignItemWithTrigger:a,className:"isolate z-50",children:c.jsxs(ZUe,{"data-slot":"select-content",className:Ae("bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 min-w-32 rounded-lg shadow-md ring-1 duration-100 relative isolate z-50 max-h-(--available-height) w-(--anchor-width) origin-(--transform-origin) overflow-x-hidden overflow-y-auto",e),...o,children:[c.jsx(cHe,{}),c.jsx(JUe,{children:t}),c.jsx(uHe,{})]})})})}function vse({className:e,...t}){return c.jsx(lHe,{"data-slot":"select-label",className:Ae("text-muted-foreground px-2 py-1.5 text-xs",e),...t})}function jt({className:e,children:t,...n}){return c.jsxs(eHe,{"data-slot":"select-item",className:Ae("focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground min-h-7 gap-2 rounded-md px-2 py-1 text-xs/relaxed [&_svg:not([class*='size-'])]:size-3.5 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2 relative flex w-full cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",e),...n,children:[c.jsx(rHe,{className:"flex flex-1 gap-2 shrink-0 whitespace-nowrap",children:t}),c.jsx(tHe,{render:c.jsx("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center"}),children:c.jsx(Z,{icon:hr,strokeWidth:2,className:"pointer-events-none"})})]})}function cHe({className:e,...t}){return c.jsx(sHe,{"data-slot":"select-scroll-up-button",className:Ae("bg-popover z-10 flex cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-3.5 top-0 w-full",e),...t,children:c.jsx(Z,{icon:wd,strokeWidth:2})})}function uHe({className:e,...t}){return c.jsx(iHe,{"data-slot":"select-scroll-down-button",className:Ae("bg-popover z-10 flex cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-3.5 bottom-0 w-full",e),...t,children:c.jsx(Z,{icon:Ts,strokeWidth:2})})}const OSe=x.createContext(void 0);function xW(){const e=x.useContext(OSe);if(e===void 0)throw new Error(Un(64));return e}let dHe=(function(e){return e.activationDirection="data-activation-direction",e.orientation="data-orientation",e})({});const _W={tabActivationDirection:e=>({[dHe.activationDirection]:e})},fHe=x.forwardRef(function(t,n){const{className:r,defaultValue:i=0,onValueChange:s,orientation:a="horizontal",render:o,value:l,...u}=t,d=Of(),f=Object.hasOwn(t,"defaultValue"),h=x.useRef([]),[m,g]=x.useState(()=>new Map),[y,v]=Ml({controlled:l,default:i,name:"Tabs",state:"value"}),_=l!==void 0,[S,E]=x.useState(()=>new Map),[T,k]=x.useState("none"),w=_t(($,W)=>{s?.($,W),!W.isCanceled&&(v($),k(W.activationDirection))}),A=_t(($,W)=>{g(Y=>{if(Y.get($)===W)return Y;const q=new Map(Y);return q.set($,W),q})}),R=_t(($,W)=>{g(Y=>{if(!Y.has($)||Y.get($)!==W)return Y;const q=new Map(Y);return q.delete($),q})}),I=x.useCallback($=>m.get($),[m]),D=x.useCallback($=>{for(const W of S.values())if($===W?.value)return W?.id},[S]),j=x.useCallback($=>{if($===void 0)return null;for(const[W,Y]of S.entries())if(Y!=null&&$===(Y.value??Y.index))return W;return null},[S]),F=x.useMemo(()=>({direction:d,getTabElementBySelectedValue:j,getTabIdByPanelValue:D,getTabPanelIdByValue:I,onValueChange:w,orientation:a,registerMountedTabPanel:A,setTabMap:E,unregisterMountedTabPanel:R,tabActivationDirection:T,value:y}),[d,j,D,I,w,a,A,E,R,T,y]),z=x.useMemo(()=>{for(const $ of S.values())if($!=null&&$.value===y)return $},[S,y]),P=x.useMemo(()=>{for(const $ of S.values())if($!=null&&!$.disabled)return $.value},[S]);Lt(()=>{if(_||S.size===0)return;const $=z?.disabled,W=z==null&&y!==null;if(f&&$&&y===i||!$&&!W)return;const q=P??null;y!==q&&(v(q),k("none"))},[i,P,f,_,z,k,v,S,y]);const M=an("div",t,{state:{orientation:a,tabActivationDirection:T},ref:n,props:u,stateAttributesMapping:_W});return c.jsx(OSe.Provider,{value:F,children:c.jsx(dC,{elementsRef:h,children:M})})}),RSe=x.createContext(void 0);function hHe(){const e=x.useContext(RSe);if(e===void 0)throw new Error(Un(65));return e}const pHe=x.forwardRef(function(t,n){const{className:r,disabled:i=!1,render:s,value:a,id:o,nativeButton:l=!0,...u}=t,{value:d,getTabPanelIdByValue:f,orientation:h}=xW(),{activateOnFocus:m,highlightedTabIndex:g,onTabActivation:y,setHighlightedTabIndex:v,tabsListElement:_}=hHe(),S=ds(o),E=x.useMemo(()=>({disabled:i,id:S,value:a}),[i,S,a]),{compositeProps:T,compositeRef:k,index:w}=T_e({metadata:E}),A=a===d,R=x.useRef(!1);Lt(()=>{if(R.current){R.current=!1;return}if(!(A&&w>-1&&g!==w))return;const Y=_;if(Y!=null){const q=mu(ho(Y));if(q&&xn(Y,q))return}i||v(w)},[A,w,g,v,i,_]);const{getButtonProps:I,buttonRef:D}=go({disabled:i,native:l,focusableWhenDisabled:!0}),j=f(a),F=x.useRef(!1),z=x.useRef(!1);function P(Y){A||i||y(a,$t(Es,Y.nativeEvent,void 0,{activationDirection:"none"}))}function L(Y){A||(w>-1&&!i&&v(w),!i&&m&&(!F.current||F.current&&z.current)&&y(a,$t(Es,Y.nativeEvent,void 0,{activationDirection:"none"})))}function M(Y){if(A||i)return;F.current=!0;function q(){F.current=!1,z.current=!1}(!Y.button||Y.button===0)&&(z.current=!0,ho(Y.currentTarget).addEventListener("pointerup",q,{once:!0}))}const $=x.useMemo(()=>({disabled:i,active:A,orientation:h}),[i,A,h]);return an("button",t,{state:$,ref:[n,D,k],props:[T,{role:"tab","aria-controls":j,"aria-selected":A,id:S,onClick:P,onFocus:L,onPointerDown:M,[nW]:A?"":void 0,onKeyDownCapture(){R.current=!0}},u,I]})});let mHe=(function(e){return e.index="data-index",e.activationDirection="data-activation-direction",e.orientation="data-orientation",e.hidden="data-hidden",e})({});const gHe=x.forwardRef(function(t,n){const{className:r,value:i,render:s,keepMounted:a=!1,...o}=t,{value:l,getTabIdByPanelValue:u,orientation:d,tabActivationDirection:f,registerMountedTabPanel:h,unregisterMountedTabPanel:m}=xW(),g=ds(),y=x.useMemo(()=>({id:g,value:i}),[g,i]),{ref:v,index:_}=S1({metadata:y}),S=i!==l,E=u(i),T=x.useMemo(()=>({hidden:S,orientation:d,tabActivationDirection:f}),[S,d,f]),k=an("div",t,{state:T,ref:[n,v],props:[{"aria-labelledby":E,hidden:S,id:g??void 0,role:"tabpanel",tabIndex:S?-1:0,[mHe.index]:_},o],stateAttributesMapping:_W});return Lt(()=>{if(!(S&&!a)&&g!=null)return h(i,g),()=>{m(i,g)}},[S,a,i,g,h,m]),!S||a?k:null}),bHe=x.forwardRef(function(t,n){const{activateOnFocus:r=!1,className:i,loopFocus:s=!0,render:a,...o}=t,{getTabElementBySelectedValue:l,onValueChange:u,orientation:d,value:f,setTabMap:h,tabActivationDirection:m}=xW(),[g,y]=x.useState(0),[v,_]=x.useState(null),S=yHe(f,d,v,l),E=_t((A,R)=>{if(A!==f){const I=S(A);R.activationDirection=I,u(A,R)}}),T=x.useMemo(()=>({orientation:d,tabActivationDirection:m}),[d,m]),k={"aria-orientation":d==="vertical"?"vertical":void 0,role:"tablist"},w=x.useMemo(()=>({activateOnFocus:r,highlightedTabIndex:g,onTabActivation:E,setHighlightedTabIndex:y,tabsListElement:v,value:f}),[r,g,E,y,v,f]);return c.jsx(RSe.Provider,{value:w,children:c.jsx(pC,{render:a,className:i,state:T,refs:[n,_],props:[k,o],stateAttributesMapping:_W,highlightedIndex:g,enableHomeAndEndKeys:!0,loopFocus:s,orientation:d,onHighlightedIndexChange:y,onMapChange:h,disabledIndices:Zo})})});function xse(e,t){const{left:n,top:r}=e.getBoundingClientRect(),{left:i,top:s}=t.getBoundingClientRect(),a=n-i,o=r-s;return{left:a,top:o}}function yHe(e,t,n,r){const[i,s]=x.useState(null);return Lt(()=>{if(e==null||n==null){s(null);return}const a=r(e);if(a==null){s(null);return}const{left:o,top:l}=xse(a,n);s(t==="horizontal"?o:l)},[t,r,n,e]),x.useCallback(a=>{if(a===e)return"none";if(a==null)return s(null),"none";if(a!=null&&n!=null){const o=r(a);if(o!=null){const{left:l,top:u}=xse(o,n);if(i==null)return s(t==="horizontal"?l:u),"none";if(t==="horizontal"){if(l<i)return s(l),"left";if(l>i)return s(l),"right"}else{if(u<i)return s(u),"up";if(u>i)return s(u),"down"}}}return"none"},[r,t,i,n,e])}function nl({className:e,orientation:t="horizontal",...n}){return c.jsx(fHe,{"data-slot":"tabs","data-orientation":t,className:Ae("gap-2 group/tabs flex data-[orientation=horizontal]:flex-col",e),...n})}const vHe=Ym("rounded-lg p-[3px] group-data-horizontal/tabs:h-8 data-[variant=line]:rounded-none group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function rl({className:e,variant:t="default",...n}){return c.jsx(bHe,{"data-slot":"tabs-list","data-variant":t,className:Ae(vHe({variant:t}),e),...n})}function In({className:e,...t}){return c.jsx(pHe,{"data-slot":"tabs-trigger",className:Ae("gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-xs font-medium group-data-vertical/tabs:py-[calc(--spacing(1.25))] [&_svg:not([class*='size-'])]:size-3.5 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent","data-active:bg-background dark:data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 data-active:text-foreground","after:bg-foreground after:absolute after:origin-center after:transition-transform after:duration-200 group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=horizontal]/tabs:after:scale-x-0 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[orientation=vertical]/tabs:after:scale-y-0 group-data-[variant=line]/tabs-list:data-active:group-data-[orientation=horizontal]/tabs:after:scale-x-100 group-data-[variant=line]/tabs-list:data-active:group-data-[orientation=vertical]/tabs:after:scale-y-100",e),...t})}function jn({className:e,...t}){return c.jsx(gHe,{"data-slot":"tabs-content",className:Ae("text-xs/relaxed flex-1 min-h-0 outline-none",e),...t})}function xHe(e){const{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:s,actionsRef:a,handle:o,triggerId:l,defaultTriggerId:u=null}=e,d=up(),f=!!d,h=_a(()=>o?.store??new dSe({open:n??r,activeTriggerId:l!==void 0?l:u,modal:!0,disablePointerDismissal:!0,nested:f,role:"alertdialog"})).current;h.useControlledProp("open",n,r),h.useControlledProp("activeTriggerId",l,u),h.useSyncedValue("nested",f),h.useContextCallback("onOpenChange",i),h.useContextCallback("onOpenChangeComplete",s);const m=h.useState("payload");uSe({store:h,actionsRef:a,parentContext:d?.store.context});const g=x.useMemo(()=>({store:h}),[h]);return c.jsx(pW.Provider,{value:g,children:typeof t=="function"?t({payload:m}):t})}const ISe=x.createContext(void 0),DSe=x.createContext(void 0),jSe=x.createContext(void 0),PSe=x.createContext("");function fp(){const e=x.useContext(ISe);if(!e)throw new Error(Un(22));return e}function oD(){const e=x.useContext(DSe);if(!e)throw new Error(Un(23));return e}function Ny(){const e=x.useContext(jSe);if(!e)throw new Error(Un(24));return e}function SW(){return x.useContext(PSe)}const cn={id:ft(e=>e.id),query:ft(e=>e.query),items:ft(e=>e.items),selectedValue:ft(e=>e.selectedValue),open:ft(e=>e.open),mounted:ft(e=>e.mounted),forceMounted:ft(e=>e.forceMounted),inline:ft(e=>e.inline),activeIndex:ft(e=>e.activeIndex),selectedIndex:ft(e=>e.selectedIndex),isActive:ft((e,t)=>e.activeIndex===t),isSelected:ft((e,t)=>{const n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(i=>Gh(i,t,n)):Gh(r,t,n)}),transitionStatus:ft(e=>e.transitionStatus),popupProps:ft(e=>e.popupProps),inputProps:ft(e=>e.inputProps),triggerProps:ft(e=>e.triggerProps),getItemProps:ft(e=>e.getItemProps),positionerElement:ft(e=>e.positionerElement),listElement:ft(e=>e.listElement),triggerElement:ft(e=>e.triggerElement),inputElement:ft(e=>e.inputElement),popupSide:ft(e=>e.popupSide),openMethod:ft(e=>e.openMethod),inputInsidePopup:ft(e=>e.inputInsidePopup),selectionMode:ft(e=>e.selectionMode),listRef:ft(e=>e.listRef),labelsRef:ft(e=>e.labelsRef),popupRef:ft(e=>e.popupRef),emptyRef:ft(e=>e.emptyRef),inputRef:ft(e=>e.inputRef),keyboardActiveRef:ft(e=>e.keyboardActiveRef),chipsContainerRef:ft(e=>e.chipsContainerRef),clearRef:ft(e=>e.clearRef),valuesRef:ft(e=>e.valuesRef),allValuesRef:ft(e=>e.allValuesRef),name:ft(e=>e.name),disabled:ft(e=>e.disabled),readOnly:ft(e=>e.readOnly),required:ft(e=>e.required),grid:ft(e=>e.grid),isGrouped:ft(e=>e.isGrouped),virtualized:ft(e=>e.virtualized),onOpenChangeComplete:ft(e=>e.onOpenChangeComplete),openOnInputClick:ft(e=>e.openOnInputClick),itemToStringLabel:ft(e=>e.itemToStringLabel),isItemEqualToValue:ft(e=>e.isItemEqualToValue),modal:ft(e=>e.modal),autoHighlight:ft(e=>e.autoHighlight),submitOnItemClick:ft(e=>e.submitOnItemClick)};function _He(e,t){return(n,r)=>{if(n==null)return!1;const i=ua(n,t);return e.contains(i,r)}}function SHe(e,t,n){return(r,i)=>{if(r==null)return!1;if(!i)return!0;const s=ua(r,t),a=n!=null?ua(n,t):"";return a&&e.contains(a,i)&&a.length===i.length?!0:e.contains(s,i)}}const _se=new Map;function LSe(e){return Array.isArray(e)?e.map(t=>LSe(t)).join(","):e==null?"":String(e)}function wHe(e={}){const t={usage:"search",sensitivity:"base",ignorePunctuation:!0,...e},n=`${LSe(e.locale)}|${JSON.stringify(t)}`,r=_se.get(n);if(r)return r;const i=new Intl.Collator(e.locale,t),s={contains(a,o,l){if(!o)return!0;const u=ua(a,l);for(let d=0;d<=u.length-o.length;d+=1)if(i.compare(u.slice(d,d+o.length),o)===0)return!0;return!1},startsWith(a,o,l){if(!o)return!0;const u=ua(a,l);return i.compare(u.slice(0,o.length),o)===0},endsWith(a,o,l){if(!o)return!0;const u=ua(a,l),d=o.length;return u.length>=d&&i.compare(u.slice(u.length-d),o)===0}};return _se.set(n,s),s}const EHe=wHe,MSe=Symbol("none"),Wg={value:MSe,index:-1};function CHe(e){const{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:i,onSelectedValueChange:s,defaultInputValue:a,inputValue:o,selectionMode:l="none",onItemHighlighted:u,name:d,disabled:f=!1,readOnly:h=!1,required:m=!1,inputRef:g,grid:y=!1,items:v,filteredItems:_,filter:S,openOnInputClick:E=!0,autoHighlight:T=!1,keepHighlight:k=!1,highlightItemOnHover:w=!0,itemToStringLabel:A,itemToStringValue:R,isItemEqualToValue:I=_Se,virtualized:D=!1,inline:j=!1,fillInputOnItemPress:F=!0,modal:z=!1,limit:P=-1,autoComplete:L="list",locale:M,submitOnItemClick:$=!1}=e,{clearErrors:W}=E1(),{setDirty:Y,validityData:q,shouldValidateOnChange:K,setFilled:X,name:U,disabled:J,validation:te}=Hl(),ee=EC({id:t}),oe=EHe({locale:M}),[ae,se]=x.useState(!1),[ue,de]=x.useState(null),ce=x.useRef([]),Ee=x.useRef([]),Ie=x.useRef(null),fe=x.useRef(null),be=x.useRef(null),ge=x.useRef(!0),Ce=x.useRef(!1),Re=x.useRef(null),xe=x.useRef(null),ye=x.useRef(null),De=x.useRef(Wg),ve=x.useRef(null),Oe=x.useRef([]),Be=x.useRef([]),Te=J||f,je=U??d,ie=l==="multiple",Ke=l==="single",lt=o!==void 0||a!==void 0,Rt=v!==void 0,Ye=_!==void 0;let ct;T==="always"?ct="always":ct=T?"input-change":!1;const[Ve,Et]=Ml({controlled:i,default:ie?r??Zo:r,name:"Combobox",state:"selectedValue"}),$e=x.useMemo(()=>S===null?()=>!0:S!==void 0?S:Ke&&!ae?SHe(oe,A,Ve):_He(oe,A),[S,Ke,Ve,ae,oe,A]),Qe=_a(()=>lt?a??"":Ke?ua(Ve,A):"").current,[pt,at]=Ml({controlled:o,default:Qe,name:"Combobox",state:"inputValue"}),[gt,We]=Ml({controlled:e.open,default:e.defaultOpen,name:"Combobox",state:"open"}),Xe=wSe(v),it=ue??(pt===""?"":String(pt).trim()),ot=Ke?ua(Ve,A):"",St=Ke&&!ae&&it!==""&&ot!==""&&ot.length===it.length&&oe.contains(ot,it),Xt=St?"":it,Vt=Rt&&Ye&&St,en=x.useMemo(()=>v?Xe?v.flatMap(qt=>qt.items):v:Zo,[v,Xe]),Fe=x.useMemo(()=>{if(_&&!Vt)return _;if(!v)return Zo;if(Xe){const Le=v,vt=[];let pn=0;for(const En of Le){if(P>-1&&pn>=P)break;const on=Xt===""?En.items:En.items.filter(ra=>$e(ra,Xt,A));if(on.length===0)continue;const _o=P>-1?P-pn:1/0,ms=on.slice(0,_o);if(ms.length>0){const ra={...En,items:ms};vt.push(ra),pn+=ms.length}}return vt}if(Xt==="")return P>-1?en.slice(0,P):en;const qt=[];for(const Le of en){if(P>-1&&qt.length>=P)break;$e(Le,Xt,A)&&qt.push(Le)}return qt},[_,Vt,v,Xe,Xt,P,$e,A,en]),Ue=x.useMemo(()=>Xe?Fe.flatMap(Le=>Le.items):Fe,[Fe,Xe]),ut=_a(()=>new Fb({id:ee,selectedValue:Ve,open:gt,filter:$e,query:it,items:v,selectionMode:l,listRef:ce,labelsRef:Ee,popupRef:Ie,emptyRef:be,inputRef:fe,keyboardActiveRef:ge,chipsContainerRef:Re,clearRef:xe,valuesRef:Oe,allValuesRef:Be,selectionEventRef:ye,name:je,disabled:Te,readOnly:h,required:m,grid:y,isGrouped:Xe,virtualized:D,openOnInputClick:E,itemToStringLabel:A,isItemEqualToValue:I,modal:z,autoHighlight:ct,submitOnItemClick:$,hasInputValue:lt,mounted:!1,forceMounted:!1,transitionStatus:"idle",inline:j,activeIndex:null,selectedIndex:null,popupProps:{},inputProps:{},triggerProps:{},positionerElement:null,listElement:null,triggerElement:null,inputElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,onOpenChangeComplete:n||di,setOpen:di,setInputValue:di,setSelectedValue:di,setIndices:di,onItemHighlighted:di,handleSelection:di,getItemProps:()=>Ti,forceMount:di,requestSubmit:di})).current,Kt=l==="none"?pt:Ve,wn=x.useMemo(()=>l==="none"?Kt:Array.isArray(Ve)?Ve.map(qt=>sd(qt,R)):sd(Ve,R),[Kt,R,l,Ve]),pr=_t(u),Mr=_t(n),qi=Tt(ut,cn.activeIndex),na=Tt(ut,cn.selectedIndex),ai=Tt(ut,cn.positionerElement),Ar=Tt(ut,cn.listElement),mr=Tt(ut,cn.triggerElement),Ji=Tt(ut,cn.inputElement),hi=Tt(ut,cn.inline),Bs=Tt(ut,cn.inputInsidePopup),es=Wi(mr),{mounted:ts,setMounted:nt,transitionStatus:Fn}=Lu(gt),{openMethod:rn,triggerProps:Yn,reset:Nr}=_C(gt);C1({id:ee,name:je,commit:te.commit,value:Kt,controlRef:Bs?es:fe,getValue:()=>wn});const oi=_t(()=>{v?Ee.current=Ue.map(qt=>ua(qt,A)):ut.set("forceMounted",!0)}),Jn=x.useRef(Ve);Lt(()=>{Ve!==Jn.current&&oi()},[oi,Ve]);const Fr=_t(qt=>{ut.update(qt);const Le=qt.type||"none";if(qt.activeIndex!==void 0)if(qt.activeIndex===null)De.current!==Wg&&(De.current=Wg,pr(void 0,_S(Le,void 0,{index:-1})));else{const vt=Oe.current[qt.activeIndex];De.current={value:vt,index:qt.activeIndex},pr(vt,_S(Le,void 0,{index:qt.activeIndex}))}}),sr=_t((qt,Le)=>{if(Ce.current=Le.reason===om,e.onInputValueChange?.(qt,Le),!Le.isCanceled){if(Le.reason===gb){const vt=qt.trim()!=="";vt&&se(!0),ve.current={hasQuery:vt},vt&&ct&&ut.state.activeIndex==null&&ut.set("activeIndex",0)}at(qt)}}),Br=_t((qt,Le)=>{gt!==qt&&(Le.reason==="escape-key"&&Rt&&Ue.length===0&&!ut.state.emptyRef.current&&Le.allowPropagation(),e.onOpenChange?.(qt,Le),!Le.isCanceled&&(!qt&&ae&&(Ke?(de(it),it===""&&se(!1)):ie&&(hi||Bs?Fr({activeIndex:null}):de(it),sr("",$t(om,Le.event)))),We(qt)))}),Si=_t((qt,Le)=>{if(s?.(qt,Le),Le.isCanceled)return;Et(qt),(l==="none"&&Ie.current&&F||Ke&&!ut.state.inputInsidePopup)&&sr(ua(qt,A),$t(Le.reason,Le.event)),Ke&&qt!=null&&Le.reason!==gb&&ae&&de(it)}),ml=_t((qt,Le)=>{let vt=Le;if(vt===void 0){if(qi===null)return;vt=Oe.current[qi]}const pn=os(qt),En=ye.current??qt;ye.current=null;const on=$t(Lb,En),_o=pn?.closest("a")?.getAttribute("href");if(_o){_o.startsWith("#")&&Br(!1,on);return}if(ie){const ms=Array.isArray(Ve)?Ve:[],gs=xb(ms,vt,ut.state.isItemEqualToValue)?SSe(ms,vt,ut.state.isItemEqualToValue):[...ms,vt];if(Si(gs,on),!(fe.current?fe.current.value.trim()!=="":!1))return;ut.state.inputInsidePopup?sr("",$t(om,on.event)):Br(!1,on)}else Si(vt,on),Br(!1,on)}),tn=_t(()=>{if(!ut.state.submitOnItemClick)return;const qt=ut.state.inputElement?.form;qt&&typeof qt.requestSubmit=="function"&&qt.requestSubmit()}),Na=_t(()=>{if(nt(!1),Mr?.(!1),se(!1),Nr(),de(null),Fr(l==="none"?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),ie&&fe.current&&fe.current.value!==""&&!Ce.current&&sr("",$t(om)),Ke)if(ut.state.inputInsidePopup)fe.current&&fe.current.value!==""&&sr("",$t(om));else{const qt=ua(Ve,A);fe.current&&fe.current.value!==qt&&sr(qt,$t(qt===""?om:Es))}}),ns=x.useMemo(()=>hi&&ai?{current:ai.closest('[role="dialog"]')}:Ie,[hi,ai]);Sa({enabled:!e.actionsRef,open:gt,ref:ns,onComplete(){gt||Na()}}),x.useImperativeHandle(e.actionsRef,()=>({unmount:Na}),[Na]),Lt(function(){if(gt||l==="none")return;const Le=v?en:Be.current;if(ie){const vt=Array.isArray(Ve)?Ve:[],pn=vt[vt.length-1],En=ax(Le,pn,I);Fr({selectedIndex:En===-1?null:En})}else{const vt=ax(Le,Ve,I);Fr({selectedIndex:vt===-1?null:vt})}},[gt,Ve,v,l,en,ie,I,Fr]),Lt(()=>{v&&(Oe.current=Ue,ce.current.length=Ue.length)},[v,Ue]),Lt(()=>{const qt=ve.current;if(qt&&(qt.hasQuery?ct&&ut.set("activeIndex",0):ct==="always"&&ut.set("activeIndex",0),ve.current=null),!gt&&!hi)return;const vt=Rt||Ye?Ue:Oe.current,pn=ut.state.activeIndex;if(pn==null){if(ct==="always"&&vt.length>0){ut.set("activeIndex",0);return}De.current!==Wg&&(De.current=Wg,ut.state.onItemHighlighted(void 0,_S(Es,void 0,{index:-1})));return}if(pn>=vt.length){De.current!==Wg&&(De.current=Wg,ut.state.onItemHighlighted(void 0,_S(Es,void 0,{index:-1}))),ut.set("activeIndex",null);return}const En=vt[pn],on=De.current.value,_o=on!==MSe&&ut.state.isItemEqualToValue(En,on);(De.current.index!==pn||!_o)&&(De.current={value:En,index:pn},ut.state.onItemHighlighted(En,_S(Es,void 0,{index:pn})))},[qi,ct,Ye,Rt,Ue,hi,gt,ut]),Lt(()=>{if(!v||l==="none")return;const qt=en;if(ie){const pn=Array.isArray(Ve)?Ve:Zo,En=pn.filter(on=>xb(qt,on,ut.state.isItemEqualToValue));En.length!==pn.length&&Et(En);return}if(Ve==null?!0:xb(qt,Ve,ut.state.isItemEqualToValue))return;let vt=null;if(r!=null&&xb(qt,r,ut.state.isItemEqualToValue)&&(vt=r),Et(vt),!ut.state.inputInsidePopup){const pn=ua(vt,A);fe.current&&fe.current.value!==pn&&sr(pn,$t(Es))}},[v,en,ie,l,Ve,r,Et,A,ut,sr]),Lt(()=>{if(l==="none"){X(String(pt)!=="");return}X(ie?Array.isArray(Ve)&&Ve.length>0:Ve!=null)},[X,l,pt,Ve,ie]),x.useEffect(()=>{Rt&&ct&&Ue.length===0&&Fr({activeIndex:null})},[Rt,ct,Ue.length,Fr]),ym(it,()=>{!gt||it===""||it===String(Qe)||se(!0)}),ym(Ve,()=>{if(l!=="none"&&(W(je),Y(Ve!==q.initialValue),K()?te.commit(Ve):te.commit(Ve,!0),ie&&ut.state.selectedIndex!==null&&(!Array.isArray(Ve)||Ve.length===0)&&Fr({activeIndex:null,selectedIndex:null}),Ke&&!lt&&!Bs)){const qt=ua(Ve,A);pt!==qt&&sr(qt,$t(Es))}}),ym(pt,()=>{l==="none"&&(W(je),Y(pt!==q.initialValue),K()?te.commit(pt):te.commit(pt,!0))}),ym(v,()=>{if(!Ke||lt||Bs||ae)return;const qt=ua(Ve,A);pt!==qt&&sr(qt,$t(Es))});const Oa=q3({open:hi?!0:gt,onOpenChange:Br,elements:{reference:Bs?mr:Ji,floating:ai}});let nr,Ns;hi||(nr=y?"grid":"listbox",Ns=gt?"true":"false");const hs=x.useMemo(()=>{const qt=Ji?.tagName==="INPUT",Le=qt||gt,vt=qt?{autoComplete:"off",spellCheck:"false",autoCorrect:"off",autoCapitalize:"none"}:{};return Le&&(vt.role="combobox",vt["aria-expanded"]=Ns,vt["aria-haspopup"]=nr,vt["aria-controls"]=gt?Ar?.id:void 0,vt["aria-autocomplete"]=L),{reference:vt,floating:{role:"presentation"}}},[Ji,gt,Ns,nr,Ar?.id,L]),Uu=wy(Oa,{enabled:!h&&!Te&&E,event:"mousedown-only",toggle:!1,touchOpenDelay:Bs?0:50}),$o=Ey(Oa,{enabled:!h&&!Te&&!hi,outsidePressEvent:{mouse:"sloppy",touch:"intentional"},bubbles:hi?!0:void 0,outsidePress(qt){const Le=os(qt);return!xn(mr,Le)&&!xn(xe.current,Le)&&!xn(Re.current,Le)}}),Bc=JV(Oa,{enabled:!h&&!Te,id:ee,listRef:ce,activeIndex:qi,selectedIndex:na,virtual:!0,loopFocus:!0,allowEscape:!ct,focusItemOnOpen:ae||l==="none"&&!ct?!1:"auto",focusItemOnHover:w,resetOnPointerLeave:!k,cols:y?2:1,orientation:y?"horizontal":void 0,disabledIndices:Zo,onNavigate(qt,Le){!Le&&!gt||Fn==="ending"||Fr(Le?{activeIndex:qt,type:ge.current?"keyboard":"pointer"}:{activeIndex:qt})}}),{getReferenceProps:Ra,getFloatingProps:rs,getItemProps:wi}=Nf([hs,Uu,$o,Bc]);bSe(()=>{ut.update({inline:j,popupProps:rs(),inputProps:Ra(),triggerProps:Yn,getItemProps:wi,setOpen:Br,setInputValue:sr,setSelectedValue:Si,setIndices:Fr,onItemHighlighted:pr,handleSelection:ml,forceMount:oi,requestSubmit:tn})}),Lt(()=>{ut.update({id:ee,selectedValue:Ve,open:gt,mounted:ts,transitionStatus:Fn,items:v,inline:j,popupProps:rs(),inputProps:Ra(),triggerProps:Yn,openMethod:rn,getItemProps:wi,selectionMode:l,name:je,disabled:Te,readOnly:h,required:m,grid:y,isGrouped:Xe,virtualized:D,onOpenChangeComplete:Mr,openOnInputClick:E,itemToStringLabel:A,modal:z,autoHighlight:ct,isItemEqualToValue:I,submitOnItemClick:$,hasInputValue:lt,requestSubmit:tn})},[ut,ee,Ve,gt,ts,Fn,v,rs,Ra,wi,rn,Yn,l,je,Te,h,m,te,y,Xe,D,Mr,E,A,z,I,$,lt,j,tn,ct]);const ps=zl(g,te.inputRef),zo=x.useMemo(()=>({query:it,filteredItems:Fe,flatFilteredItems:Ue}),[it,Fe,Ue]),$c=x.useMemo(()=>Array.isArray(Kt)?"":sd(Kt,R),[Kt,R]),Ia=ie&&Array.isArray(Ve)&&Ve.length>0,to=x.useMemo(()=>!ie||!Array.isArray(Ve)||!je?null:Ve.map(qt=>{const Le=sd(qt,R);return c.jsx("input",{type:"hidden",name:je,value:Le},Le)}),[ie,Ve,je,R]),gl=c.jsxs(x.Fragment,{children:[e.children,c.jsx("input",{...te.getInputValidationProps({onFocus(){if(Bs){mr?.focus();return}(fe.current||mr)?.focus()},onChange(qt){if(qt.nativeEvent.defaultPrevented)return;const Le=qt.target.value,vt=$t(gb,qt.nativeEvent);function pn(){if(ie)return;if(l==="none"){Y(Le!==q.initialValue),sr(Le,vt),K()&&te.commit(Le);return}const En=Oe.current.find(on=>sd(on,R).toLowerCase()===Le.toLowerCase());En!=null&&(Y(En!==q.initialValue),Si?.(En,vt),K()&&te.commit(En))}v?pn():(oi(),queueMicrotask(pn))}}),id:ee,name:ie||l==="none"?void 0:je,disabled:Te,required:m&&!Ia,readOnly:h,value:$c,ref:ps,style:Zm,tabIndex:-1,"aria-hidden":!0}),to]});return c.jsx(ISe.Provider,{value:ut,children:c.jsx(DSe.Provider,{value:Oa,children:c.jsx(jSe.Provider,{value:zo,children:c.jsx(PSe.Provider,{value:pt,children:gl})})})})}const SA=2,kHe={...ay,...dp},THe=x.forwardRef(function(t,n){const{render:r,className:i,nativeButton:s=!0,disabled:a=!1,...o}=t,{state:l,disabled:u,setTouched:d,setFocused:f,validationMode:h,validation:m}=Hl(),{labelId:g}=Rf(),y=fp(),v=Tt(y,cn.selectionMode),_=Tt(y,cn.disabled),S=Tt(y,cn.readOnly),E=Tt(y,cn.listElement),T=Tt(y,cn.triggerProps),k=Tt(y,cn.triggerElement),w=Tt(y,cn.inputInsidePopup),A=Tt(y,cn.open),R=Tt(y,cn.selectedValue),I=Tt(y,cn.activeIndex),D=Tt(y,cn.selectedIndex),j=oD(),F=SW(),z=si(),P=u||_||a,L=x.useRef("");function M(te){L.current=te.pointerType}const $=j.select("domReferenceElement");x.useEffect(()=>{w&&k&&k!==$&&j.set("domReferenceElement",k)},[k,$,j,w]);const{reference:W}=tW(j,{enabled:!A&&!S&&!_&&v==="single",listRef:y.state.labelsRef,activeIndex:I,selectedIndex:D,onMatch(te){const ee=y.state.valuesRef.current[te];ee!==void 0&&y.state.setSelectedValue(ee,$t("none"))}}),{reference:Y}=wy(j,{enabled:!S&&!_,event:"mousedown"}),{buttonRef:q,getButtonProps:K}=go({native:s,disabled:P}),X=x.useMemo(()=>({...l,open:A,disabled:P}),[l,A,P]),U=_t(te=>{y.set("triggerElement",te)});return an("button",t,{ref:[n,q,U],state:X,props:[T,Y,W,{tabIndex:w?0:-1,disabled:P,role:w?"combobox":void 0,"aria-expanded":A?"true":"false","aria-haspopup":w?"dialog":"listbox","aria-controls":A?E?.id:void 0,"aria-readonly":S||void 0,"aria-labelledby":g,onPointerDown:M,onPointerEnter:M,onFocus(){f(!0),!(P||S)&&z.start(0,y.state.forceMount)},onBlur(){if(d(!0),f(!1),h==="onBlur"){const te=v==="none"?F:R;m.commit(te)}},onMouseDown(te){if(P||S||(w||j.set("domReferenceElement",te.currentTarget),y.state.forceMount(),L.current!=="touch"&&(y.state.inputRef.current?.focus(),w||te.preventDefault()),A))return;const ee=ho(te.currentTarget);function oe(ae){if(!k)return;const se=os(ae),ue=y.state.positionerElement,de=y.state.listElement;if(xn(k,se)||xn(ue,se)||xn(de,se)||se===k)return;const ce=bW(k),Ee=ae.clientX>=ce.left-SA&&ae.clientX<=ce.right+SA,Ie=ae.clientY>=ce.top-SA&&ae.clientY<=ce.bottom+SA;Ee&&Ie||y.state.setOpen(!1,$t("cancel-open",ae))}w&&ee.addEventListener("mouseup",oe,{once:!0})},onKeyDown(te){P||S||(te.key==="ArrowDown"||te.key==="ArrowUp")&&(ws(te),y.state.setOpen(!0,$t(j0,te.nativeEvent)),y.state.inputRef.current?.focus())}},m?m.getValidationProps(o):o,K],stateAttributesMapping:kHe})}),AHe=x.createContext(void 0);function NHe(){return x.useContext(AHe)}const FSe=x.createContext(void 0);function wW(e){const t=x.useContext(FSe);if(t===void 0&&!e)throw new Error(Un(21));return t}const OHe={...ay,...dp,popupSide:e=>e?{"data-popup-side":e}:null,listEmpty:e=>e?{"data-list-empty":""}:null},RHe=x.forwardRef(function(t,n){const{render:r,className:i,disabled:s=!1,id:a,...o}=t,{state:l,disabled:u,setTouched:d,setFocused:f,validationMode:h,validation:m}=Hl(),{labelId:g}=Rf(),y=NHe(),_=!!wW(!0),S=fp(),{filteredItems:E}=Ny(),T=SW(),k=ds(a),w=Of(),A=Tt(S,cn.disabled),R=Tt(S,cn.readOnly),I=Tt(S,cn.name),D=Tt(S,cn.selectionMode),j=Tt(S,cn.autoHighlight),F=Tt(S,cn.inputProps),z=Tt(S,cn.triggerProps),P=Tt(S,cn.open),L=Tt(S,cn.mounted),M=Tt(S,cn.selectedValue),$=Tt(S,cn.popupSide),W=Tt(S,cn.positionerElement),Y=!!j,q=L&&W?$:null,K=u||A||s,X=E.length===0,[U,J]=x.useState(null),te=x.useRef(!1),ee=_t(ue=>{const de=_||S.state.inline;de&&!S.state.hasInputValue&&S.state.setInputValue("",$t(Es)),S.update({inputElement:ue,inputInsidePopup:de})}),oe=x.useMemo(()=>({...l,open:P,disabled:K,readOnly:R,popupSide:q,listEmpty:X}),[l,P,K,R,q,X]);function ae(ue){if(!y)return;let de;const{highlightedChipIndex:ce}=y;if(ce!==void 0){if(ue.key==="ArrowLeft")ue.preventDefault(),ce>0?de=ce-1:de=void 0;else if(ue.key==="ArrowRight")ue.preventDefault(),ce<M.length-1?de=ce+1:de=void 0;else if(ue.key==="Backspace"||ue.key==="Delete"){ue.preventDefault();const Ee=ce>=M.length-1?M.length-2:ce;de=Ee>=0?Ee:void 0,S.state.setIndices({activeIndex:null,selectedIndex:null,type:"keyboard"})}return de}return ue.key==="ArrowLeft"&&(ue.currentTarget.selectionStart??0)===0&&M.length>0?(ue.preventDefault(),de=Math.max(M.length-1,0)):ue.key==="Backspace"&&ue.currentTarget.value===""&&M.length>0&&(S.state.setIndices({activeIndex:null,selectedIndex:null,type:"keyboard"}),ue.preventDefault()),de}return an("input",t,{state:oe,ref:[n,S.state.inputRef,ee],props:[F,z,{type:"text",value:t.value??U??T,"aria-readonly":R||void 0,"aria-labelledby":g,disabled:K,readOnly:R,...D==="none"&&I&&{name:I},id:k,onFocus(){f(!0)},onBlur(){if(d(!0),f(!1),h==="onBlur"){const ue=D==="none"?T:M;m.commit(ue)}},onCompositionStart(ue){IO||(te.current=!0,J(ue.currentTarget.value))},onCompositionEnd(ue){te.current=!1;const de=ue.currentTarget.value;J(null),S.state.setInputValue(de,$t(gb,ue.nativeEvent))},onChange(ue){if(te.current){const Ie=ue.currentTarget.value;J(Ie),Ie===""&&!S.state.openOnInputClick&&!S.state.inputInsidePopup&&S.state.setOpen(!1,$t(om,ue.nativeEvent));const fe=Ie.trim(),be=Y&&fe!=="";!R&&!K&&fe!==""&&(S.state.setOpen(!0,$t(gb,ue.nativeEvent)),Y||S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"})),P&&S.state.activeIndex!==null&&!be&&S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"});return}S.state.setInputValue(ue.currentTarget.value,$t(gb,ue.nativeEvent));const de=ue.currentTarget.value==="",ce=$t(om,ue.nativeEvent);de&&!S.state.inputInsidePopup&&(D==="single"&&S.state.setSelectedValue(null,ce),S.state.openOnInputClick||S.state.setOpen(!1,ce));const Ee=ue.currentTarget.value.trim();!R&&!K&&Ee!==""&&(S.state.setOpen(!0,$t(gb,ue.nativeEvent)),Y||S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"})),P&&S.state.activeIndex!==null&&!Y&&S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"})},onKeyDown(ue){if(K||R||ue.ctrlKey||ue.shiftKey||ue.altKey||ue.metaKey)return;S.state.keyboardActiveRef.current=!0;const de=ue.currentTarget,ce=de.scrollWidth-de.clientWidth,Ee=w==="rtl";if(ue.key==="Home"){ws(ue);const fe=Aie&&Ee?de.value.length:0;de.setSelectionRange(fe,fe),de.scrollLeft=0;return}if(ue.key==="End"){ws(ue);const fe=Aie&&Ee?0:de.value.length;de.setSelectionRange(fe,fe),de.scrollLeft=Ee?-ce:ce;return}if(!L&&ue.key==="Escape"){const fe=D==="multiple"&&Array.isArray(M)?M.length===0:M===null,be=$t(v1,ue.nativeEvent),ge=D==="multiple"?[]:null;S.state.setInputValue("",be),S.state.setSelectedValue(ge,be),!fe&&!S.state.inline&&!be.isPropagationAllowed&&ue.stopPropagation();return}if(y&&ue.key==="Backspace"&&de.value===""&&y.highlightedChipIndex===void 0&&Array.isArray(M)&&M.length>0){const fe=M.slice(0,-1);S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"}),S.state.setSelectedValue(fe,$t(Es,ue.nativeEvent));return}const Ie=ae(ue);if(y?.setHighlightedChipIndex(Ie),Ie!==void 0?y?.chipsRef.current[Ie]?.focus():S.state.inputRef.current?.focus(),ue.which!==229&&ue.key==="Enter"&&P){const fe=S.state.activeIndex,be=ue.nativeEvent;if(fe===null){S.state.setOpen(!1,$t(Es,be));return}ws(ue);const ge=S.state.listRef.current[fe];ge&&(S.state.selectionEventRef.current=be,ge.click(),S.state.selectionEventRef.current=null)}},onPointerMove(){S.state.keyboardActiveRef.current=!1},onPointerDown(){S.state.keyboardActiveRef.current=!1}},m?m.getValidationProps(o):o],stateAttributesMapping:OHe})}),IHe={...ll,...mC},DHe=x.forwardRef(function(t,n){const{render:r,className:i,disabled:s=!1,nativeButton:a=!0,keepMounted:o=!1,...l}=t,{disabled:u}=Hl(),d=fp(),f=Tt(d,cn.selectionMode),h=Tt(d,cn.disabled),m=Tt(d,cn.readOnly),g=Tt(d,cn.open),y=Tt(d,cn.selectedValue),v=SW();let _=!1;f==="none"?_=v!=="":f==="single"?_=y!=null:_=Array.isArray(y)&&y.length>0;const S=u||h||s,{buttonRef:E,getButtonProps:T}=go({native:a,disabled:S}),{mounted:k,transitionStatus:w,setMounted:A}=Lu(_),R=x.useMemo(()=>({disabled:S,open:g,transitionStatus:w}),[S,g,w]);Sa({open:_,ref:d.state.clearRef,onComplete(){_||A(!1)}});const I=an("button",t,{state:R,ref:[n,E,d.state.clearRef],props:[{tabIndex:-1,children:"x",disabled:S,"aria-readonly":m||void 0,onMouseDown(j){j.preventDefault()},onClick(j){if(S||m)return;const F=d.state.keyboardActiveRef;d.state.setInputValue("",$t(Pie,j.nativeEvent)),f!=="none"?(d.state.setSelectedValue(Array.isArray(y)?[]:null,$t(Pie,j.nativeEvent)),d.state.setIndices({activeIndex:null,selectedIndex:null,type:F.current?"keyboard":"pointer"})):d.state.setIndices({activeIndex:null,type:F.current?"keyboard":"pointer"}),d.state.inputRef.current?.focus()}},l,T],stateAttributesMapping:IHe});return o||k?I:null}),BSe=x.createContext(null);function jHe(){return x.useContext(BSe)}function PHe(e){const{children:t,items:n}=e,r=x.useMemo(()=>({items:n}),[n]);return c.jsx(BSe.Provider,{value:r,children:t})}function LHe(e){const{children:t}=e,{filteredItems:n}=Ny(),r=jHe(),i=r?r.items:n;return i?c.jsx(x.Fragment,{children:i.map(t)}):null}const MHe=x.forwardRef(function(t,n){var r;const{render:i,className:s,children:a,...o}=t,l=fp(),u=oD(),d=!!wW(!0),{filteredItems:f}=Ny(),h=Tt(l,cn.items),m=Tt(l,cn.labelsRef),g=Tt(l,cn.listRef),y=Tt(l,cn.selectionMode),v=Tt(l,cn.grid),_=Tt(l,cn.popupProps),S=Tt(l,cn.disabled),E=Tt(l,cn.readOnly),T=Tt(l,cn.virtualized),k=y==="multiple",w=f.length===0,A=_t(z=>{l.set("positionerElement",z)}),R=_t(z=>{l.set("listElement",z)}),I=x.useMemo(()=>typeof a=="function"?r||(r=c.jsx(LHe,{children:a})):a,[a]),D=x.useMemo(()=>({empty:w}),[w]),j=u.useState("floatingId"),F=an("div",t,{state:D,ref:[n,R,d?null:A],props:[_,{children:I,tabIndex:-1,id:j,role:v?"grid":"listbox","aria-multiselectable":k?"true":void 0,onKeyDown(z){if(!(S||E)&&z.key==="Enter"){const P=l.state.activeIndex;if(P==null)return;ws(z);const L=z.nativeEvent,M=l.state.listRef.current[P];M&&(l.state.selectionEventRef.current=L,M.click(),l.state.selectionEventRef.current=null)}},onKeyDownCapture(){l.state.keyboardActiveRef.current=!0},onPointerMoveCapture(){l.state.keyboardActiveRef.current=!1}},o]});return T?F:c.jsx(dC,{elementsRef:g,labelsRef:h?void 0:m,children:F})}),$Se=x.createContext(void 0);function FHe(){const e=x.useContext($Se);if(e===void 0)throw new Error(Un(20));return e}const BHe=x.forwardRef(function(t,n){const{keepMounted:r=!1,...i}=t,s=fp(),a=Tt(s,cn.mounted),o=Tt(s,cn.forceMounted);return a||r||o?c.jsx($Se.Provider,{value:r,children:c.jsx(x1,{ref:n,...i})}):null}),$He=x.forwardRef(function(t,n){const{render:r,className:i,anchor:s,positionMethod:a="absolute",side:o="bottom",align:l="center",sideOffset:u=0,alignOffset:d=0,collisionBoundary:f="clipping-ancestors",collisionPadding:h=5,arrowPadding:m=5,sticky:g=!1,disableAnchorTracking:y=!1,collisionAvoidance:v=I3,..._}=t,S=fp(),{filteredItems:E}=Ny(),T=oD(),k=FHe(),w=Tt(S,cn.modal),A=Tt(S,cn.open),R=Tt(S,cn.mounted),I=Tt(S,cn.openMethod),D=Tt(S,cn.triggerElement),j=Tt(S,cn.inputElement),F=Tt(S,cn.inputInsidePopup),z=E.length===0,L=w1({anchor:s??(F?D:j),floatingRootContext:T,positionMethod:a,mounted:R,side:o,sideOffset:u,align:l,alignOffset:d,arrowPadding:m,collisionBoundary:f,collisionPadding:h,sticky:g,disableAnchorTracking:y,keepMounted:k,collisionAvoidance:v,lazyFlip:!0});xC(A&&w&&I!=="touch",D);const M=x.useMemo(()=>{const K={...L.positionerStyles};return A||(K.pointerEvents="none"),{role:"presentation",hidden:!R,style:K}},[A,R,L.positionerStyles]),$=x.useMemo(()=>({open:A,side:L.side,align:L.align,anchorHidden:L.anchorHidden,empty:z}),[A,L.side,L.align,L.anchorHidden,z]);Lt(()=>{S.set("popupSide",L.side)},[S,L.side]);const W=x.useMemo(()=>({side:L.side,align:L.align,arrowRef:L.arrowRef,arrowUncentered:L.arrowUncentered,arrowStyles:L.arrowStyles,anchorHidden:L.anchorHidden,isPositioned:L.isPositioned}),[L.side,L.align,L.arrowRef,L.arrowUncentered,L.arrowStyles,L.anchorHidden,L.isPositioned]),Y=_t(K=>{S.set("positionerElement",K)}),q=an("div",t,{state:$,ref:[n,Y],props:[M,_],stateAttributesMapping:Po});return c.jsxs(FSe.Provider,{value:W,children:[R&&w&&c.jsx(vC,{inert:Cy(!A),cutout:j??D}),q]})}),zHe={...Po,...ll},UHe=x.forwardRef(function(t,n){const{render:r,className:i,initialFocus:s,finalFocus:a,...o}=t,l=fp(),u=wW(),d=oD(),{filteredItems:f}=Ny(),h=Tt(l,cn.mounted),m=Tt(l,cn.open),g=Tt(l,cn.openMethod),y=Tt(l,cn.transitionStatus),v=Tt(l,cn.inputInsidePopup),_=Tt(l,cn.inputElement),S=f.length===0;Sa({open:m,ref:l.state.popupRef,onComplete(){m&&l.state.onOpenChangeComplete(!0)}});const E=x.useMemo(()=>({open:m,side:u.side,align:u.align,anchorHidden:u.anchorHidden,transitionStatus:y,empty:S}),[m,u.side,u.align,u.anchorHidden,y,S]),T=an("div",t,{state:E,ref:[n,l.state.popupRef],props:[{role:v?"dialog":"presentation",tabIndex:-1,onFocus(R){const I=os(R.nativeEvent);g!=="touch"&&(xn(l.state.listElement,I)||I===R.currentTarget)&&l.state.inputRef.current?.focus()}},Jm(y),o],stateAttributesMapping:zHe}),w=s===void 0?v?R=>R==="touch"?l.state.popupRef.current:_:!1:s;let A;return a!=null?A=a:A=v?void 0:!1,c.jsx(cC,{context:d,disabled:!h,modal:!v,openInteractionType:g,initialFocus:w,returnFocus:A,children:T})}),zSe=x.createContext(void 0);function HHe(){const e=x.useContext(zSe);if(e===void 0)throw new Error(Un(18));return e}const VHe=x.forwardRef(function(t,n){const{render:r,className:i,items:s,...a}=t,[o,l]=x.useState(),u=x.useMemo(()=>({labelId:o,setLabelId:l,items:s}),[o,l,s]),d=an("div",t,{ref:n,props:[{role:"group","aria-labelledby":o},a]}),f=c.jsx(zSe.Provider,{value:u,children:d});return s?c.jsx(PHe,{items:s,children:f}):f}),WHe=x.forwardRef(function(t,n){const{render:r,className:i,id:s,...a}=t,{setLabelId:o}=HHe(),l=ds(s);return Lt(()=>(o(l),()=>{o(void 0)}),[l,o]),an("div",t,{ref:n,props:[{id:l},a]})}),USe=x.createContext(void 0);function HSe(){const e=x.useContext(USe);if(!e)throw new Error(Un(19));return e}const qHe=x.createContext(!1);function GHe(){return x.useContext(qHe)}const KHe=x.memo(x.forwardRef(function(t,n){const{render:r,className:i,value:s=null,index:a,disabled:o=!1,nativeButton:l=!1,...u}=t,d=x.useRef(!1),f=x.useRef(null),h=S1({index:a,textRef:f,indexGuessBehavior:rW.GuessFromOrder}),m=fp(),g=GHe(),{flatFilteredItems:y}=Ny(),v=Tt(m,cn.open),_=Tt(m,cn.selectionMode),S=Tt(m,cn.readOnly),E=Tt(m,cn.virtualized),T=Tt(m,cn.isItemEqualToValue),k=_!=="none",w=a??(E?ax(y,s,T):h.index),A=h.index!==-1,R=Tt(m,cn.id),I=Tt(m,cn.isActive,w),D=Tt(m,cn.isSelected,s),j=Tt(m,cn.items),F=Tt(m,cn.getItemProps),z=x.useRef(null),P=R!=null&&A?`${R}-${w}`:void 0,L=D&&k;Lt(()=>{if(!(A&&(E||a!=null)))return;const te=m.state.listRef.current;return te[w]=z.current,()=>{delete te[w]}},[A,E,w,a,m]),Lt(()=>{if(!A||j)return;const J=m.state.valuesRef.current;return J[w]=s,_!=="none"&&m.state.allValuesRef.current.push(s),()=>{delete J[w]}},[A,j,w,s,m,_]),Lt(()=>{if(!v){d.current=!1;return}if(!A||j)return;const J=m.state.selectedValue,te=Array.isArray(J)?J[J.length-1]:J;Gh(te,s,T)&&m.set("selectedIndex",w)},[A,j,v,m,w,s,T]);const M=x.useMemo(()=>({disabled:o,selected:L,highlighted:I}),[o,L,I]),$=F({active:I,selected:L});$.id=void 0,$.onFocus=void 0;const{getButtonProps:W,buttonRef:Y}=go({disabled:o,focusableWhenDisabled:!0,native:l});function q(J){function te(){m.state.handleSelection(J,s)}m.state.submitOnItemClick?(_i.flushSync(te),m.state.requestSubmit()):te()}const K={id:P,role:g?"gridcell":"option","aria-disabled":o||void 0,"aria-selected":k?L:void 0,tabIndex:void 0,onPointerDownCapture(J){d.current=!0,J.preventDefault()},onClick(J){o||S||q(J.nativeEvent)},onMouseUp(J){const te=d.current;d.current=!1,!(o||S||J.button!==0||te||!I)&&q(J.nativeEvent)}},X=an("div",t,{ref:[Y,n,h.ref,z],state:M,props:[$,K,u,W]}),U=x.useMemo(()=>({selected:L,textRef:f}),[L,f]);return c.jsx(USe.Provider,{value:U,children:X})})),YHe=x.forwardRef(function(t,n){const{render:r,className:i,children:s,...a}=t,{filteredItems:o}=Ny(),l=fp(),u=o.length===0?s:null;return an("div",t,{ref:[n,l.state.emptyRef],props:[{children:u,role:"status","aria-live":"polite","aria-atomic":!0},a]})});let Sse=(function(e){return e.checked="data-checked",e.unchecked="data-unchecked",e.disabled="data-disabled",e.readonly="data-readonly",e.required="data-required",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});function VSe(e){return x.useMemo(()=>({checked(t){return e.indeterminate?{}:t?{[Sse.checked]:""}:{[Sse.unchecked]:""}},...dp}),[e.indeterminate])}const WSe=x.createContext(void 0);function XHe(){const e=x.useContext(WSe);if(e===void 0)throw new Error(Un(14));return e}const QHe="data-parent",ZHe=x.forwardRef(function(t,n){const{checked:r,className:i,defaultChecked:s=!1,disabled:a=!1,id:o,indeterminate:l=!1,inputRef:u,name:d,onCheckedChange:f,parent:h=!1,readOnly:m=!1,render:g,required:y=!1,uncheckedValue:v,value:_,nativeButton:S=!1,...E}=t,{clearErrors:T}=E1(),{disabled:k,name:w,setDirty:A,setFilled:R,setFocused:I,setTouched:D,state:j,validationMode:F,validityData:z,shouldValidateOnChange:P,validation:L}=Hl(),M=pSe(),{labelId:$,controlId:W,setControlId:Y,getDescriptionProps:q}=Rf(),K=DUe(),X=K?.parent,U=X&&K.allValues,J=k||M.disabled||K?.disabled||a,te=w??d,ee=_??te,oe=ds(),ae=ds();let se=W;U?se=h?ae:`${X.id}-${ee}`:o&&(se=o);let ue={};U&&(h?ue=K.parent.getParentProps():ee&&(ue=K.parent.getChildProps(ee)));const de=_t(f),{checked:ce=r,indeterminate:Ee=l,onCheckedChange:Ie,...fe}=ue,be=K?.value,ge=K?.setValue,Ce=K?.defaultValue,Re=x.useRef(null),{getButtonProps:xe,buttonRef:ye}=go({disabled:J,native:S}),De=K?.validation??L,[ve,Oe]=Ml({controlled:ee&&be&&!h?be.includes(ee):ce,default:ee&&Ce&&!h?Ce.includes(ee):s,name:"Checkbox",state:"checked"});Lt(()=>{if(Y!==di)return Y(se),()=>{Y(void 0)}},[se,K,Y,h]),C1({enabled:!K,id:oe,commit:De.commit,value:ve,controlRef:Re,name:te,getValue:()=>ve});const Be=x.useRef(null),Te=zl(u,Be,De.inputRef);Lt(()=>{Be.current&&(Be.current.indeterminate=Ee,ve&&R(!0))},[ve,Ee,R]),ym(ve,()=>{K&&!h||(T(te),R(ve),A(ve!==z.initialValue),P()?De.commit(ve):De.commit(ve,!0))});const je=gd({checked:ve,disabled:J,name:h?void 0:te,id:se??void 0,required:y,ref:Te,style:Zm,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(ct){if(ct.nativeEvent.defaultPrevented)return;const Ve=ct.target.checked,Et=$t(Es,ct.nativeEvent);if(Ie?.(Ve,Et),de(Ve,Et),!Et.isCanceled&&(Oe(Ve),ee&&be&&ge&&!h)){const $e=Ve?[...be,ee]:be.filter(Qe=>Qe!==ee);ge($e,Et)}},onFocus(){Re.current?.focus()}},_!==void 0?{value:(K?ve&&_:_)||""}:Ti,q,K?De.getValidationProps:De.getInputValidationProps),ie=U?!!ce:ve,Ke=U&&Ee||l;x.useEffect(()=>{X&&ee&&X.disabledStatesRef.current.set(ee,J)},[X,J,ee]);const lt=x.useMemo(()=>({...j,checked:ie,disabled:J,readOnly:m,required:y,indeterminate:Ke}),[j,ie,J,m,y,Ke]),Rt=VSe(lt),Ye=an("span",t,{state:lt,ref:[ye,Re,n,K?.registerControlRef],props:[{id:oe,role:"checkbox","aria-checked":Ee?"mixed":ve,"aria-readonly":m||void 0,"aria-required":y||void 0,"aria-labelledby":$,[QHe]:h?"":void 0,onFocus(){I(!0)},onBlur(){const ct=Be.current;ct&&(D(!0),I(!1),F==="onBlur"&&De.commit(K?be:ct.checked))},onClick(ct){m||J||(ct.preventDefault(),Be.current?.click())}},q,De.getValidationProps,E,fe,xe],stateAttributesMapping:Rt});return c.jsxs(WSe.Provider,{value:lt,children:[Ye,!ve&&!K&&te&&!h&&v!==void 0&&c.jsx("input",{type:"hidden",name:te,value:v}),c.jsx("input",{...je})]})}),JHe=x.forwardRef(function(t,n){const{render:r,className:i,keepMounted:s=!1,...a}=t,o=XHe(),l=o.checked||o.indeterminate,{transitionStatus:u,setMounted:d}=Lu(l),f=x.useRef(null),h=x.useMemo(()=>({...o,transitionStatus:u}),[o,u]);Sa({open:l,ref:f,onComplete(){l||d(!1)}});const m=VSe(o),g=x.useMemo(()=>({...m,...ll,...dp}),[m]),y=s||l,v=an("span",t,{enabled:y,ref:[n,f],state:h,stateAttributesMapping:g,props:a});return y?v:null});function eVe(e){const{multiple:t=!1,defaultValue:n,value:r,onValueChange:i,...s}=e;return c.jsx(CHe,{...s,selectionMode:t?"multiple":"single",selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:i})}const tVe=x.forwardRef(function(t,n){const r=t.keepMounted??!1,{selected:i}=HSe();return r||i?c.jsx(nVe,{...t,ref:n}):null}),nVe=x.memo(x.forwardRef((e,t)=>{const{render:n,className:r,keepMounted:i,...s}=e,{selected:a}=HSe(),o=x.useRef(null),{transitionStatus:l,setMounted:u}=Lu(a),d=x.useMemo(()=>({selected:a,transitionStatus:l}),[a,l]),f=an("span",e,{ref:[t,o],state:d,props:[{"aria-hidden":!0,children:"✔️"},s],stateAttributesMapping:ll});return Sa({open:a,ref:o,onComplete(){a||u(!1)}}),f})),rVe=x.createContext(void 0);function lD(e=!0){const t=x.useContext(rVe);if(t===void 0&&!e)throw new Error(Un(25));return t}const qSe=x.createContext(void 0);function EW(e){const t=x.useContext(qSe);if(t===void 0&&!e)throw new Error(Un(33));return t}const GSe=x.createContext(void 0);function tg(e){const t=x.useContext(GSe);if(t===void 0&&!e)throw new Error(Un(36));return t}const KSe={type:"regular-item"};function YSe(e){const{closeOnClick:t,disabled:n=!1,highlighted:r,id:i,store:s,nativeButton:a,itemMetadata:o,nodeId:l}=e,u=x.useRef(null),d=lD(!0),f=d!==void 0,{events:h}=s.useState("floatingTreeRoot"),{getButtonProps:m,buttonRef:g}=go({disabled:n,focusableWhenDisabled:!0,native:a}),y=x.useCallback(_=>gd({id:i,role:"menuitem",tabIndex:r?0:-1,onMouseMove(S){l&&h.emit("itemhover",{nodeId:l,target:S.currentTarget})},onMouseEnter(){o.type==="submenu-trigger"&&o.setActive()},onKeyUp(S){S.key===" "&&s.context.typingRef.current&&S.preventBaseUIHandler()},onClick(S){t&&h.emit("close",{domEvent:S,reason:Lb})},onMouseUp(S){if(d){const E=d.initialCursorPointRef.current;if(d.initialCursorPointRef.current=null,f&&E&&Math.abs(S.clientX-E.x)<=1&&Math.abs(S.clientY-E.y)<=1)return}u.current&&s.context.allowMouseUpTriggerRef.current&&(!f||S.button===2)&&o.type==="regular-item"&&u.current.click()}},_,m),[i,r,m,t,h,s,f,d,o,l]),v=zl(u,g);return x.useMemo(()=>({getItemProps:y,itemRef:v}),[y,v])}let wse=(function(e){return e.checked="data-checked",e.unchecked="data-unchecked",e.disabled="data-disabled",e.highlighted="data-highlighted",e})({});const XSe={checked(e){return e?{[wse.checked]:""}:{[wse.unchecked]:""}},...ll},iVe=x.forwardRef(function(t,n){const{render:r,className:i,id:s,label:a,nativeButton:o=!1,disabled:l=!1,closeOnClick:u=!0,...d}=t,f=S1({label:a}),h=EW(!0),m=ds(s),{store:g}=tg(),y=g.useState("isActive",f.index),v=g.useState("itemProps"),{getItemProps:_,itemRef:S}=YSe({closeOnClick:u,disabled:l,highlighted:y,id:m,store:g,nativeButton:o,nodeId:h?.nodeId,itemMetadata:KSe}),E=x.useMemo(()=>({disabled:l,highlighted:y}),[l,y]);return an("div",t,{state:E,props:[v,d,_],ref:[S,n,f.ref]})}),sVe={...Po,...ll},aVe=x.forwardRef(function(t,n){const{render:r,className:i,finalFocus:s,...a}=t,{store:o}=tg(),{side:l,align:u}=EW(),d=aD()!=null,f=o.useState("open"),h=o.useState("transitionStatus"),m=o.useState("popupProps"),g=o.useState("mounted"),y=o.useState("instantType"),v=o.useState("activeTriggerElement"),_=o.useState("parent"),S=o.useState("lastOpenChangeReason"),E=o.useState("rootId"),T=o.useState("floatingRootContext"),k=o.useState("floatingTreeRoot"),w=o.useState("closeDelay"),A=o.useState("activeTriggerElement");Sa({open:f,ref:o.context.popupRef,onComplete(){f&&o.context.onOpenChangeComplete?.(!0)}}),x.useEffect(()=>{function z(P){o.setOpen(!1,$t(P.reason,P.domEvent))}return k.events.on("close",z),()=>{k.events.off("close",z)}},[k.events,o]);const R=o.useState("hoverEnabled"),I=o.useState("disabled");QV(T,{enabled:R&&!I&&_.type!=="context-menu"&&_.type!=="menubar",closeDelay:w});const D=x.useMemo(()=>({transitionStatus:h,side:l,align:u,open:f,nested:_.type==="menu",instant:y}),[h,l,u,f,_.type,y]),j=an("div",t,{state:D,ref:[n,o.context.popupRef],stateAttributesMapping:sVe,props:[m,{onKeyDown(z){d&&Q3.has(z.key)&&z.stopPropagation()}},Jm(h),a,{"data-rootownerid":E}]});let F=_.type===void 0||_.type==="context-menu";return(v||_.type==="menubar"&&S!==L3)&&(F=!0),c.jsx(cC,{context:T,modal:!1,disabled:!g,returnFocus:s===void 0?F:s,initialFocus:_.type!=="menu",restoreFocus:!0,externalTree:_.type!=="menubar"?k:void 0,previousFocusableElement:A,nextFocusableElement:_.type===void 0?o.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:_.type===void 0?o.context.beforeContentFocusGuardRef:void 0,children:j})}),QSe=x.createContext(void 0);function oVe(){const e=x.useContext(QSe);if(e===void 0)throw new Error(Un(32));return e}const lVe=x.forwardRef(function(t,n){const{keepMounted:r=!1,...i}=t,{store:s}=tg();return s.useState("mounted")||r?c.jsx(QSe.Provider,{value:r,children:c.jsx(x1,{ref:n,...i})}):null}),cVe=x.forwardRef(function(t,n){const{anchor:r,positionMethod:i="absolute",className:s,render:a,side:o,align:l,sideOffset:u=0,alignOffset:d=0,collisionBoundary:f="clipping-ancestors",collisionPadding:h=5,arrowPadding:m=5,sticky:g=!1,disableAnchorTracking:y=!1,collisionAvoidance:v=I3,..._}=t,{store:S}=tg(),E=oVe(),T=lD(!0),k=S.useState("parent"),w=S.useState("floatingRootContext"),A=S.useState("floatingTreeRoot"),R=S.useState("mounted"),I=S.useState("open"),D=S.useState("modal"),j=S.useState("activeTriggerElement"),F=S.useState("lastOpenChangeReason"),z=S.useState("floatingNodeId"),P=S.useState("floatingParentNodeId");let L=r,M=u,$=d,W=l,Y=v;k.type==="context-menu"&&(L=r??k.context?.anchor,W=W??"start",!o&&W!=="center"&&($=t.alignOffset??2,M=t.sideOffset??-5));let q=o,K=W;k.type==="menu"?(q=q??"inline-end",K=K??"start",Y=t.collisionAvoidance??D3):k.type==="menubar"&&(q=q??"bottom",K=K??"start");const X=k.type==="context-menu",U=w1({anchor:L,floatingRootContext:w,positionMethod:T?"fixed":i,mounted:R,side:q,sideOffset:M,align:K,alignOffset:$,arrowPadding:X?0:m,collisionBoundary:f,collisionPadding:h,sticky:g,nodeId:z,keepMounted:E,disableAnchorTracking:y,collisionAvoidance:Y,shiftCrossAxis:X,externalTree:A}),J=x.useMemo(()=>{const ue={};return I||(ue.pointerEvents="none"),{role:"presentation",hidden:!R,style:{...U.positionerStyles,...ue}}},[I,R,U.positionerStyles]);x.useEffect(()=>{function ue(de){de.open?(de.parentNodeId===z&&S.set("hoverEnabled",!1),de.nodeId!==z&&de.parentNodeId===S.select("floatingParentNodeId")&&S.setOpen(!1,$t(cw))):de.parentNodeId===z&&de.reason!==cw&&S.set("hoverEnabled",!0)}return A.events.on("menuopenchange",ue),()=>{A.events.off("menuopenchange",ue)}},[S,A.events,z]),x.useEffect(()=>{if(S.select("floatingParentNodeId")==null)return;function ue(de){if(de.open||de.nodeId!==S.select("floatingParentNodeId"))return;const ce=de.reason??cw;S.setOpen(!1,$t(ce))}return A.events.on("menuopenchange",ue),()=>{A.events.off("menuopenchange",ue)}},[A.events,S]),x.useEffect(()=>{function ue(de){!I||de.nodeId!==S.select("floatingParentNodeId")||de.target&&j&&j!==de.target&&S.setOpen(!1,$t(cw))}return A.events.on("itemhover",ue),()=>{A.events.off("itemhover",ue)}},[A.events,I,j,S]),x.useEffect(()=>{const ue={open:I,nodeId:z,parentNodeId:P,reason:S.select("lastOpenChangeReason")};A.events.emit("menuopenchange",ue)},[A.events,I,S,z,P]);const te=x.useMemo(()=>({open:I,side:U.side,align:U.align,anchorHidden:U.anchorHidden,nested:k.type==="menu"}),[I,U.side,U.align,U.anchorHidden,k.type]),ee=x.useMemo(()=>({side:U.side,align:U.align,arrowRef:U.arrowRef,arrowUncentered:U.arrowUncentered,arrowStyles:U.arrowStyles,nodeId:U.context.nodeId}),[U.side,U.align,U.arrowRef,U.arrowUncentered,U.arrowStyles,U.context.nodeId]),oe=an("div",t,{state:te,stateAttributesMapping:Po,ref:[n,S.useStateSetter("positionerElement")],props:[J,_]}),ae=R&&k.type!=="menu"&&(k.type!=="menubar"&&D&&F!==vi||k.type==="menubar"&&k.context.modal);let se=null;return k.type==="menubar"?se=k.context.contentElement:k.type===void 0&&(se=j),c.jsxs(qSe.Provider,{value:ee,children:[ae&&c.jsx(vC,{ref:k.type==="context-menu"||k.type==="nested-context-menu"?k.context.internalBackdropRef:null,inert:Cy(!I),cutout:se}),c.jsx(qV,{id:z,children:c.jsx(dC,{elementsRef:S.context.itemDomElements,labelsRef:S.context.itemLabels,children:oe})})]})}),ZSe=x.createContext(void 0);function uVe(){const e=x.useContext(ZSe);if(e===void 0)throw new Error(Un(34));return e}const dVe=x.memo(x.forwardRef(function(t,n){const{render:r,className:i,value:s,defaultValue:a,onValueChange:o,disabled:l=!1,...u}=t,[d,f]=Ml({controlled:s,default:a,name:"MenuRadioGroup"}),h=_t(o),m=_t((_,S)=>{h?.(_,S),!S.isCanceled&&f(_)}),g=x.useMemo(()=>({disabled:l}),[l]),y=an("div",t,{state:g,ref:n,props:{role:"group","aria-disabled":l||void 0,...u}}),v=x.useMemo(()=>({value:d,setValue:m,disabled:l}),[d,m,l]);return c.jsx(ZSe.Provider,{value:v,children:y})})),JSe=x.createContext(void 0);function fVe(){const e=x.useContext(JSe);if(e===void 0)throw new Error(Un(35));return e}const hVe=x.forwardRef(function(t,n){const{render:r,className:i,id:s,label:a,nativeButton:o=!1,disabled:l=!1,closeOnClick:u=!1,value:d,...f}=t,h=S1({label:a}),m=EW(!0),g=ds(s),{store:y}=tg(),v=y.useState("isActive",h.index),_=y.useState("itemProps"),{value:S,setValue:E,disabled:T}=uVe(),k=T||l,w=S===d,{getItemProps:A,itemRef:R}=YSe({closeOnClick:u,disabled:k,highlighted:v,id:g,store:y,nativeButton:o,nodeId:m?.nodeId,itemMetadata:KSe}),I=x.useMemo(()=>({disabled:k,highlighted:v,checked:w}),[k,v,w]),D=_t(F=>{const z={...$t(Lb,F.nativeEvent),preventUnmountOnClose:()=>{}};E(d,z)}),j=an("div",t,{state:I,stateAttributesMapping:XSe,props:[_,{role:"menuitemradio","aria-checked":w,onClick:D},f,A],ref:[R,n,h.ref]});return c.jsx(JSe.Provider,{value:I,children:j})}),pVe=x.forwardRef(function(t,n){const{render:r,className:i,keepMounted:s=!1,...a}=t,o=fVe(),l=x.useRef(null),{transitionStatus:u,setMounted:d}=Lu(o.checked);Sa({open:o.checked,ref:l,onComplete(){o.checked||d(!1)}});const f=x.useMemo(()=>({checked:o.checked,disabled:o.disabled,highlighted:o.highlighted,transitionStatus:u}),[o.checked,o.disabled,o.highlighted,u]);return an("span",t,{state:f,stateAttributesMapping:XSe,ref:[n,l],props:{"aria-hidden":!0,...a},enabled:s||o.checked})}),mVe=x.createContext(null);function ewe(e){return x.useContext(mVe)}const gVe={...W3,disabled:ft(e=>e.parent.type==="menubar"&&e.parent.context.disabled||e.disabled),modal:ft(e=>(e.parent.type===void 0||e.parent.type==="context-menu")&&(e.modal??!0)),allowMouseEnter:ft(e=>e.parent.type==="menu"?e.parent.store.select("allowMouseEnter"):e.allowMouseEnter),stickIfOpen:ft(e=>e.stickIfOpen),parent:ft(e=>e.parent),rootId:ft(e=>e.parent.type==="menu"?e.parent.store.select("rootId"):e.parent.type!==void 0?e.parent.context.rootId:e.rootId),activeIndex:ft(e=>e.activeIndex),isActive:ft((e,t)=>e.activeIndex===t),hoverEnabled:ft(e=>e.hoverEnabled),instantType:ft(e=>e.instantType),lastOpenChangeReason:ft(e=>e.openChangeReason),floatingTreeRoot:ft(e=>e.parent.type==="menu"?e.parent.store.select("floatingTreeRoot"):e.floatingTreeRoot),floatingNodeId:ft(e=>e.floatingNodeId),floatingParentNodeId:ft(e=>e.floatingParentNodeId),itemProps:ft(e=>e.itemProps),closeDelay:ft(e=>e.closeDelay),keyboardEventRelay:ft(e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type==="menu")return e.parent.store.select("keyboardEventRelay")})};class CW extends uC{constructor(t){super({...bVe(),...t},{positionerRef:x.createRef(),popupRef:x.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:x.createRef(),beforeContentFocusGuardRef:x.createRef(),onOpenChangeComplete:void 0,triggerElements:new _1},gVe),this.observe(ft(n=>n.allowMouseEnter),(n,r)=>{this.state.parent.type==="menu"&&n!==r&&this.state.parent.store.set("allowMouseEnter",n)}),this.unsubscribeParentListener=this.observe("parent",n=>{if(this.unsubscribeParentListener?.(),n.type==="menu"){this.unsubscribeParentListener=n.store.subscribe(()=>{this.notifyAll()}),this.context.allowMouseUpTriggerRef=n.store.context.allowMouseUpTriggerRef;return}n.type!==void 0&&(this.context.allowMouseUpTriggerRef=n.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(t,n){this.state.floatingRootContext.context.events.emit("setOpen",{open:t,eventDetails:n})}static useStore(t,n){return _a(()=>t??new CW(n)).current}unsubscribeParentListener=null}function bVe(){return{...V3(),disabled:!1,modal:!0,allowMouseEnter:!0,stickIfOpen:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new WV,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Ti,keyboardEventRelay:void 0,closeDelay:0}}const yVe=x.createContext(void 0);function vVe(){return x.useContext(yVe)}function xVe(e){const{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,defaultOpen:s=!1,disabled:a=!1,modal:o,loopFocus:l=!0,orientation:u="vertical",actionsRef:d,closeParentOnEsc:f=!1,handle:h,triggerId:m,defaultTriggerId:g=null,highlightItemOnHover:y=!0}=e,v=lD(!0),_=tg(!0),S=ewe(),E=vVe(),T=x.useMemo(()=>E&&_?{type:"menu",store:_.store}:S?{type:"menubar",context:S}:v&&!_?{type:"context-menu",context:v}:{type:void 0},[v,_,S,E]),k=CW.useStore(h?.store,{parent:T}),w=k.useState("floatingTreeRoot"),A=P3(w),R=Pu();Lt(()=>{v&&!_?k.update({parent:{type:"context-menu",context:v},floatingNodeId:A,floatingParentNodeId:R}):_&&k.update({floatingNodeId:A,floatingParentNodeId:R})},[v,_,A,R,k]),k.useControlledProp("open",n,s),k.useControlledProp("activeTriggerId",m,g),k.useContextCallback("onOpenChangeComplete",i);const I=k.useState("open"),D=k.useState("activeTriggerElement"),j=k.useState("positionerElement"),F=k.useState("hoverEnabled"),z=k.useState("modal"),P=k.useState("disabled"),L=k.useState("lastOpenChangeReason"),M=k.useState("parent"),$=k.useState("activeIndex"),W=k.useState("payload"),Y=k.useState("floatingParentNodeId"),q=x.useRef(null),K=Y!=null;let X;k.useSyncedValues({disabled:a,modal:M.type===void 0?o:void 0,rootId:Qm()});const{openMethod:U,triggerProps:J,reset:te}=_C(I);z3(k);const{forceUnmount:ee}=U3(I,k,()=>{k.update({allowMouseEnter:!1,stickIfOpen:!0}),te()}),oe=x.useRef(M.type!=="context-menu"),ae=si();x.useEffect(()=>{if(I||(q.current=null),M.type==="context-menu"){if(!I){ae.clear(),oe.current=!1;return}ae.start(500,()=>{oe.current=!0})}},[ae,I,M.type]),xC(I&&z&&L!==vi&&U!=="touch",j),Lt(()=>{!I&&!F&&k.set("hoverEnabled",!0)},[I,F,k]);const se=x.useRef(!0),ue=si(),de=_t((Ve,Et)=>{const $e=Et.reason;if(I===Ve&&Et.trigger===D||(Et.preventUnmountOnClose=()=>{k.set("preventUnmountingOnClose",!0)},!Ve&&Et.trigger==null&&(Et.trigger=D??void 0),r?.(Ve,Et),Et.isCanceled))return;const Qe={open:Ve,nativeEvent:Et.event,reason:Et.reason,nested:K};X?.emit("openchange",Qe);const pt=Et.event;if(Ve===!1&&pt?.type==="click"&&pt.pointerType==="touch"&&!se.current)return;if(!Ve&&$!==null){const Xe=k.context.itemDomElements.current[$];queueMicrotask(()=>{Xe?.setAttribute("tabindex","-1")})}Ve&&$e===pE?(se.current=!1,ue.start(300,()=>{se.current=!0})):(se.current=!0,ue.clear());const at=($e===Au||$e===Lb)&&pt.detail===0&&pt?.isTrusted,gt=!Ve&&($e===v1||$e==null);function We(){const Xe={open:Ve,openChangeReason:$e};q.current=Et.event??null;const it=Et.trigger?.id??null;(it||Ve)&&(Xe.activeTriggerId=it,Xe.activeTriggerElement=Et.trigger??null),k.update(Xe)}$e===vi?_i.flushSync(We):We(),M.type==="menubar"&&($e===pE||$e===Ul||$e===vi||$e===j0||$e===cw)?k.set("instantType","group"):at||gt?k.set("instantType",at?"click":"dismiss"):k.set("instantType",void 0)}),ce=x.useCallback(Ve=>{const Et=$t(Ve);return Et.preventUnmountOnClose=()=>{k.set("preventUnmountingOnClose",!0)},Et},[k]),Ee=x.useCallback(()=>{k.setOpen(!1,ce(M3))},[k,ce]);x.useImperativeHandle(d,()=>({unmount:ee,close:Ee}),[ee,Ee]);let Ie;M.type==="context-menu"&&(Ie=M.context),x.useImperativeHandle(Ie?.positionerRef,()=>j,[j]),x.useImperativeHandle(Ie?.actionsRef,()=>({setOpen:de}),[de]);const fe=G3({popupStore:k,onOpenChange:de});X=fe.context.events,x.useEffect(()=>{const Ve=({open:Et,eventDetails:$e})=>de(Et,$e);return X.on("setOpen",Ve),()=>{X?.off("setOpen",Ve)}},[X,de]);const be=Ey(fe,{enabled:!P,bubbles:f&&M.type==="menu",outsidePress(){return M.type!=="context-menu"||q.current?.type==="contextmenu"?!0:oe.current},externalTree:K?w:void 0}),ge=eW(fe,{role:"menu"}),Ce=Of(),Re=x.useCallback(Ve=>{k.select("activeIndex")!==Ve&&k.set("activeIndex",Ve)},[k]),xe=JV(fe,{enabled:!P,listRef:k.context.itemDomElements,activeIndex:$,nested:M.type!==void 0,loopFocus:l,orientation:u,parentOrientation:M.type==="menubar"?M.context.orientation:void 0,rtl:Ce==="rtl",disabledIndices:Zo,onNavigate:Re,openOnArrowKeyDown:M.type!=="context-menu",externalTree:K?w:void 0,focusItemOnHover:y}),ye=x.useCallback(Ve=>{k.context.typingRef.current=Ve},[k]),De=tW(fe,{listRef:k.context.itemLabels,activeIndex:$,resetMs:R9e,onMatch:Ve=>{I&&Ve!==$&&k.set("activeIndex",Ve)},onTypingChange:ye}),{getReferenceProps:ve,getFloatingProps:Oe,getItemProps:Be,getTriggerProps:Te}=Nf([be,ge,xe,De]),je=x.useMemo(()=>{const Ve=gd(ve(),{onMouseEnter(){k.set("hoverEnabled",!0)},onMouseMove(){k.set("allowMouseEnter",!0)}},J);return delete Ve.role,Ve},[ve,k,J]),ie=x.useMemo(()=>{const Ve=Te();if(!Ve)return Ve;const Et=gd(Ve,J);return delete Et.role,delete Et["aria-controls"],Et},[Te,J]),Ke=Oh(),lt=x.useMemo(()=>Oe({onMouseEnter(){M.type==="menu"&&Ke.request(()=>k.set("hoverEnabled",!1))},onMouseMove(){k.set("allowMouseEnter",!0)},onClick(){k.select("hoverEnabled")&&k.set("hoverEnabled",!1)},onKeyDown(Ve){const Et=k.select("keyboardEventRelay");Et&&!Ve.isPropagationStopped()&&Et(Ve)}}),[Oe,M.type,Ke,k]),Rt=x.useMemo(()=>Be(),[Be]);k.useSyncedValues({floatingRootContext:fe,activeTriggerProps:je,inactiveTriggerProps:ie,popupProps:lt,itemProps:Rt});const Ye=x.useMemo(()=>({store:k,parent:T}),[k,T]),ct=c.jsx(GSe.Provider,{value:Ye,children:typeof t=="function"?t({payload:W}):t});return M.type===void 0||M.type==="context-menu"?c.jsx(GV,{externalTree:w,children:ct}):ct}function twe(e){if(ki(e)&&e.hasAttribute("data-rootownerid"))return e.getAttribute("data-rootownerid")??void 0;if(!uf(e))return twe(vf(e))}function _Ve(e){const{enabled:t=!0,mouseDownAction:n,open:r}=e,i=x.useRef(!1);return x.useMemo(()=>t?{onMouseDown:s=>{(n==="open"&&!r||n==="close"&&r)&&(i.current=!0,ho(s.currentTarget).addEventListener("click",()=>{i.current=!1},{once:!0}))},onClick:s=>{i.current&&(i.current=!1,s.preventBaseUIHandler())}}:Ti,[t,n,r])}const wA=2,SVe=x.forwardRef(function(t,n){const{render:r,className:i,disabled:s=!1,nativeButton:a=!0,id:o,openOnHover:l,delay:u=100,closeDelay:d=0,handle:f,payload:h,...m}=t,g=tg(!0),y=f?.store??g?.store;if(!y)throw new Error(Un(85));const v=ds(o),_=y.useState("isTriggerActive",v),S=y.useState("floatingRootContext"),E=y.useState("isOpenedByTrigger",v),T=x.useRef(null),k=EVe(),w=OV(!0),A=Sd(),R=x.useMemo(()=>A??new WV,[A]),I=P3(R),D=Pu(),{registerTrigger:j,isMountedByThisTrigger:F}=$3(v,T,y,{payload:h,closeDelay:d,parent:k,floatingTreeRoot:R,floatingNodeId:I,floatingParentNodeId:D,keyboardEventRelay:w?.relayKeyboardEvent}),z=y.useState("disabled"),P=s||z||k.type==="menubar"&&k.context.disabled,{getButtonProps:L,buttonRef:M}=go({disabled:P,native:a});x.useEffect(()=>{!E&&k.type===void 0&&(y.context.allowMouseUpTriggerRef.current=!1)},[y,E,k.type]);const $=x.useRef(null),W=si(),Y=_t(ge=>{if(!$.current)return;W.clear(),y.context.allowMouseUpTriggerRef.current=!1;const Ce=ge.target;if(xn($.current,Ce)||xn(y.select("positionerElement"),Ce)||Ce===$.current||Ce!=null&&twe(Ce)===y.select("rootId"))return;const Re=bW($.current);ge.clientX>=Re.left-wA&&ge.clientX<=Re.right+wA&&ge.clientY>=Re.top-wA&&ge.clientY<=Re.bottom+wA||R.events.emit("close",{domEvent:ge,reason:Z1e})});x.useEffect(()=>{E&&y.select("lastOpenChangeReason")===vi&&ho($.current).addEventListener("mouseup",Y,{once:!0})},[E,Y,y]);const q=k.type==="menubar"&&k.context.hasSubmenuOpen,X=ZV(S,{enabled:(l??q??!1)&&!P&&k.type!=="context-menu"&&(k.type!=="menubar"||q&&!F),handleClose:Y3({blockPointerEvents:k.type!=="menubar"}),mouseOnly:!0,move:!1,restMs:k.type===void 0?u:void 0,delay:{close:d},triggerElementRef:T,externalTree:R,isActiveTrigger:_}),U=wVe(E,y.select("lastOpenChangeReason")),J=wy(S,{enabled:!P&&k.type!=="context-menu",event:E&&k.type==="menubar"?"click":"mousedown",toggle:!0,ignoreMouse:!1,stickIfOpen:k.type===void 0?U:!1}),te=p_e(S,{enabled:!P&&(k.type!=="menubar"&&E||q)}),ee=_Ve({open:E,enabled:k.type==="menubar",mouseDownAction:"open"}),oe=Nf([J,te]),ae=k.type==="menubar",se=x.useMemo(()=>({disabled:P,open:E}),[P,E]),ue=y.useState("triggerProps",F),de=[$,n,M,j,T],ce=[oe.getReferenceProps(),X??Ti,ue,{"aria-haspopup":"menu",id:v,onMouseDown:ge=>{if(y.select("open"))return;W.start(200,()=>{y.context.allowMouseUpTriggerRef.current=!0}),ho(ge.currentTarget).addEventListener("mouseup",Y,{once:!0})}},ae?{role:"menuitem"}:{},ee,m,L],Ee=x.useRef(null),Ie=_t(ge=>{_i.flushSync(()=>{y.setOpen(!1,$t(Ul,ge.nativeEvent,ge.currentTarget))}),G1e(Ee.current)?.focus()}),fe=_t(ge=>{const Ce=y.select("positionerElement");if(Ce&&Tu(ge,Ce))y.context.beforeContentFocusGuardRef.current?.focus();else{_i.flushSync(()=>{y.setOpen(!1,$t(Ul,ge.nativeEvent,ge.currentTarget))});let Re=q1e(T.current);for(;Re!==null&&xn(Ce,Re)||Re?.hasAttribute("aria-hidden");){const xe=Re;if(Re=y1(Re),Re===xe)break}Re?.focus()}}),be=an("button",t,{enabled:!ae,stateAttributesMapping:ay,state:se,ref:de,props:ce});return ae?c.jsx(gC,{tag:"button",render:r,className:i,state:se,refs:de,props:ce,stateAttributesMapping:ay}):E?c.jsxs(x.Fragment,{children:[c.jsx(Du,{ref:Ee,onFocus:Ie},`${v}-pre-focus-guard`),c.jsx(x.Fragment,{children:be},v),c.jsx(Du,{ref:y.context.triggerFocusTargetRef,onFocus:fe},`${v}-post-focus-guard`)]}):c.jsx(x.Fragment,{children:be},v)});function wVe(e,t){const n=si(),[r,i]=x.useState(!1);return Lt(()=>{e&&t==="trigger-hover"?(i(!0),n.start(IV,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function EVe(){const e=lD(!0),t=tg(!0),n=ewe();return x.useMemo(()=>n?{type:"menubar",context:n}:e&&!t?{type:"context-menu",context:e}:{type:void 0},[e,t,n])}function oh(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}const nwe=x.createContext(void 0);function CC(e){const t=x.useContext(nwe);if(t===void 0&&!e)throw new Error(Un(47));return t}function CVe(){return{...V3(),disabled:!1,modal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,nested:!1,openOnHover:!1,closeDelay:0}}const kVe={...W3,disabled:ft(e=>e.disabled),instantType:ft(e=>e.instantType),openMethod:ft(e=>e.openMethod),openChangeReason:ft(e=>e.openChangeReason),modal:ft(e=>e.modal),stickIfOpen:ft(e=>e.stickIfOpen),titleElementId:ft(e=>e.titleElementId),descriptionElementId:ft(e=>e.descriptionElementId),openOnHover:ft(e=>e.openOnHover),closeDelay:ft(e=>e.closeDelay)};class kW extends uC{constructor(t){const n={...CVe(),...t};n.open&&t?.mounted===void 0&&(n.mounted=!0),super(n,{popupRef:x.createRef(),backdropRef:x.createRef(),internalBackdropRef:x.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:x.createRef(),beforeContentFocusGuardRef:x.createRef(),stickIfOpenTimeout:new Hh,triggerElements:new _1},kVe)}setOpen=(t,n)=>{const r=n.reason===vi,i=n.reason===Au&&n.event.detail===0,s=!t&&(n.reason===v1||n.reason==null);if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},this.context.onOpenChange?.(t,n),n.isCanceled)return;const a={open:t,nativeEvent:n.event,reason:n.reason,nested:this.state.nested,triggerElement:n.trigger};this.state.floatingRootContext.context.events?.emit("openchange",a);const l=()=>{const u={open:t,openChangeReason:n.reason},d=n.trigger?.id??null;(d||t)&&(u.activeTriggerId=d,u.activeTriggerElement=n.trigger??null),this.update(u)};r?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start(IV,()=>{this.set("stickIfOpen",!1)}),_i.flushSync(l)):l(),i||s?this.set("instantType",i?"click":"dismiss"):n.reason===Ul?this.set("instantType","focus"):this.set("instantType",void 0)};static useStore(t,n){const r=_a(()=>t??new kW(n)).current;return PV(r.disposeEffect),r}disposeEffect=()=>this.context.stickIfOpenTimeout.disposeEffect()}function Ese({props:e}){const{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:s,modal:a=!1,handle:o,triggerId:l,defaultTriggerId:u=null}=e,d=kW.useStore(o?.store,{open:n??r,modal:a,activeTriggerId:l!==void 0?l:u});d.useControlledProp("open",n,r),d.useControlledProp("activeTriggerId",l,u);const f=d.useState("open"),h=d.useState("positionerElement"),m=d.useState("payload"),g=d.useState("openChangeReason");d.useContextCallback("onOpenChange",i),d.useContextCallback("onOpenChangeComplete",s);const{openMethod:y,triggerProps:v,reset:_}=_C(f);z3(d);const{forceUnmount:S}=U3(f,d,()=>{d.update({stickIfOpen:!0,openChangeReason:null}),_()});xC(f&&a===!0&&g!==vi&&y!=="touch",h),x.useEffect(()=>{f||d.context.stickIfOpenTimeout.clear()},[d,f]);const E=x.useCallback(L=>{const M=$t(L);return M.preventUnmountOnClose=()=>{d.set("preventUnmountingOnClose",!0)},M},[d]),T=x.useCallback(()=>{d.setOpen(!1,E(M3))},[d,E]);x.useImperativeHandle(e.actionsRef,()=>({unmount:S,close:T}),[S,T]);const k=G3({popupStore:d,onOpenChange:d.setOpen}),w=Ey(k,{outsidePressEvent:{mouse:a==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),A=eW(k),{getReferenceProps:R,getFloatingProps:I,getTriggerProps:D}=Nf([w,A]),j=x.useMemo(()=>R(v),[R,v]),F=x.useMemo(()=>D(v),[D,v]),z=x.useMemo(()=>I(),[I]);d.useSyncedValues({modal:a,openMethod:y,activeTriggerProps:j,inactiveTriggerProps:F,popupProps:z,floatingRootContext:k,nested:Pu()!=null});const P=x.useMemo(()=>({store:d}),[d]);return c.jsx(nwe.Provider,{value:P,children:typeof t=="function"?t({payload:m}):t})}function TVe(e){return CC(!0)?c.jsx(Ese,{props:e}):c.jsx(GV,{children:c.jsx(Ese,{props:e})})}const AVe=300,NVe=x.forwardRef(function(t,n){const{render:r,className:i,disabled:s=!1,nativeButton:a=!0,handle:o,payload:l,openOnHover:u=!1,delay:d=AVe,closeDelay:f=0,id:h,...m}=t,g=CC(!0),y=o?.store??g?.store;if(!y)throw new Error(Un(74));const v=ds(h),_=y.useState("isTriggerActive",v),S=y.useState("floatingRootContext"),E=y.useState("isOpenedByTrigger",v),T=x.useRef(null),{registerTrigger:k,isMountedByThisTrigger:w}=$3(v,T,y,{payload:l,disabled:s,openOnHover:u,closeDelay:f}),A=y.useState("openChangeReason"),R=y.useState("stickIfOpen"),I=y.useState("openMethod"),D=ZV(S,{enabled:S!=null&&u&&(I!=="touch"||A!==Au),mouseOnly:!0,move:!1,handleClose:Y3(),restMs:d,delay:{close:f},triggerElementRef:T,isActiveTrigger:_}),j=wy(S,{enabled:S!=null,stickIfOpen:R}),F=Nf([j]),z=y.useState("triggerProps",w),P=x.useMemo(()=>({disabled:s,open:E}),[s,E]),{getButtonProps:L,buttonRef:M}=go({disabled:s,native:a}),$=x.useMemo(()=>({open(X){return X&&A===Au?ay.open(X):mC.open(X)}}),[A]),W=an("button",t,{state:P,ref:[M,n,k,T],props:[F.getReferenceProps(),D,z,{[DV]:"",id:v},m,L],stateAttributesMapping:$}),Y=x.useRef(null),q=_t(X=>{_i.flushSync(()=>{y.setOpen(!1,$t(Ul,X.nativeEvent,X.currentTarget))}),G1e(Y.current)?.focus()}),K=_t(X=>{const U=y.select("positionerElement");if(U&&Tu(X,U))y.context.beforeContentFocusGuardRef.current?.focus();else{_i.flushSync(()=>{y.setOpen(!1,$t(Ul,X.nativeEvent,X.currentTarget))});let J=q1e(T.current);for(;J!==null&&xn(U,J)||J?.hasAttribute("aria-hidden");){const te=J;if(J=y1(J),J===te)break}J?.focus()}});return _?c.jsxs(x.Fragment,{children:[c.jsx(Du,{ref:Y,onFocus:q}),c.jsx(x.Fragment,{children:W},v),c.jsx(Du,{ref:y.context.triggerFocusTargetRef,onFocus:K})]}):c.jsx(x.Fragment,{children:W},v)}),rwe=x.createContext(void 0);function OVe(){const e=x.useContext(rwe);if(e===void 0)throw new Error(Un(45));return e}const RVe=x.forwardRef(function(t,n){const{keepMounted:r=!1,...i}=t,{store:s}=CC();return s.useState("mounted")||r?c.jsx(rwe.Provider,{value:r,children:c.jsx(x1,{ref:n,...i,renderGuards:!1})}):null}),iwe=x.createContext(void 0);function IVe(){const e=x.useContext(iwe);if(!e)throw new Error(Un(46));return e}const DVe=x.forwardRef(function(t,n){const{render:r,className:i,anchor:s,positionMethod:a="absolute",side:o="bottom",align:l="center",sideOffset:u=0,alignOffset:d=0,collisionBoundary:f="clipping-ancestors",collisionPadding:h=5,arrowPadding:m=5,sticky:g=!1,disableAnchorTracking:y=!1,collisionAvoidance:v=D3,..._}=t,{store:S}=CC(),E=OVe(),T=P3(),k=S.useState("floatingRootContext"),w=S.useState("mounted"),A=S.useState("open"),R=S.useState("openChangeReason"),I=S.useState("activeTriggerElement"),D=S.useState("modal"),j=S.useState("positionerElement"),F=S.useState("instantType"),z=S.useState("transitionStatus"),P=x.useRef(null),L=B3(j,!1,!1),M=w1({anchor:s,floatingRootContext:k,positionMethod:a,mounted:w,side:o,sideOffset:u,align:l,alignOffset:d,arrowPadding:m,collisionBoundary:f,collisionPadding:h,sticky:g,disableAnchorTracking:y,keepMounted:E,nodeId:T,collisionAvoidance:v,adaptiveOrigin:iW}),$=x.useMemo(()=>{const U={};return A||(U.pointerEvents="none"),{role:"presentation",hidden:!w,style:{...M.positionerStyles,...U}}},[A,w,M.positionerStyles]),W=x.useMemo(()=>({props:$,...M}),[$,M]),Y=k?.select("domReferenceElement");Lt(()=>{const U=Y,J=P.current;if(U&&(P.current=U),J&&U&&U!==J){S.set("instantType",void 0);const te=new AbortController;return L(()=>{S.set("instantType","trigger-change")},te.signal),()=>{te.abort()}}},[Y,L,S]);const q=x.useMemo(()=>({open:A,side:W.side,align:W.align,anchorHidden:W.anchorHidden,instant:F}),[A,W.side,W.align,W.anchorHidden,F]),K=x.useCallback(U=>{S.set("positionerElement",U)},[S]),X=an("div",t,{state:q,props:[W.props,Jm(z),_],ref:[n,K],stateAttributesMapping:Po});return c.jsxs(iwe.Provider,{value:W,children:[w&&D===!0&&R!==vi&&c.jsx(vC,{ref:S.context.internalBackdropRef,inert:Cy(!A),cutout:I}),c.jsx(qV,{id:T,children:X})]})}),jVe=typeof ResizeObserver<"u",PVe=()=>!0;function swe(e){const{popupElement:t,positionerElement:n,content:r,mounted:i,enabled:s=PVe,onMeasureLayout:a,onMeasureLayoutComplete:o,side:l,direction:u}=e,d=x.useRef(!0),f=B3(t,!0,!1),h=Oh(),m=x.useRef(null),g=_t(a),y=_t(o),v=x.useMemo(()=>{let _=l==="top",S=l==="left";return u==="rtl"?(_=_||l==="inline-end",S=S||l==="inline-end"):(_=_||l==="inline-start",S=S||l==="inline-start"),_?{position:"absolute",[l==="top"?"bottom":"top"]:"0",[S?"right":"left"]:"0"}:Ti},[l,u]);Lt(()=>{if(!i||!s()||!jVe){d.current=!0,m.current=null;return}if(!t||!n)return;Object.entries(v).forEach(([I,D])=>{t.style.setProperty(I,D)});const _=new ResizeObserver(I=>{const D=I[0];D&&(m.current===null?m.current={width:Math.ceil(D.borderBoxSize[0].inlineSize),height:Math.ceil(D.borderBoxSize[0].blockSize)}:(m.current.width=Math.ceil(D.borderBoxSize[0].inlineSize),m.current.height=Math.ceil(D.borderBoxSize[0].blockSize)))});_.observe(t),t.style.setProperty("--popup-width","auto"),t.style.setProperty("--popup-height","auto");const S=SS(t,"position","static"),E=SS(t,"transform","none"),T=SS(t,"scale","1"),k=SS(n,"--available-width","max-content"),w=SS(n,"--available-height","max-content");if(g?.(),d.current||m.current===null){n.style.setProperty("--positioner-width","max-content"),n.style.setProperty("--positioner-height","max-content");const I=gE(t);return n.style.setProperty("--positioner-width",`${I.width}px`),n.style.setProperty("--positioner-height",`${I.height}px`),S(),E(),T(),k(),w(),y?.(null,I),d.current=!1,()=>{_.disconnect()}}t.style.setProperty("--popup-width","auto"),t.style.setProperty("--popup-height","auto"),n.style.setProperty("--positioner-width","max-content"),n.style.setProperty("--positioner-height","max-content");const A=gE(t);t.style.setProperty("--popup-width",`${m.current.width}px`),t.style.setProperty("--popup-height",`${m.current.height}px`),S(),E(),k(),w(),y?.(m.current,A),n.style.setProperty("--positioner-width",`${A.width}px`),n.style.setProperty("--positioner-height",`${A.height}px`);const R=new AbortController;return h.request(()=>{t.style.setProperty("--popup-width",`${A.width}px`),t.style.setProperty("--popup-height",`${A.height}px`),f(()=>{t.style.setProperty("--popup-width","auto"),t.style.setProperty("--popup-height","auto")},R.signal)}),()=>{_.disconnect(),R.abort(),h.cancel()}},[r,t,n,f,h,s,i,g,y,v])}function SS(e,t,n){const r=e.style.getPropertyValue(t);return e.style.setProperty(t,n),()=>{e.style.setProperty(t,r)}}const LVe={...Po,...ll},MVe=x.forwardRef(function(t,n){const{className:r,render:i,initialFocus:s,finalFocus:a,...o}=t,{store:l}=CC(),u=IVe(),d=aD()!=null,f=Of(),h=l.useState("open"),m=l.useState("openMethod"),g=l.useState("instantType"),y=l.useState("transitionStatus"),v=l.useState("popupProps"),_=l.useState("titleElementId"),S=l.useState("descriptionElementId"),E=l.useState("modal"),T=l.useState("mounted"),k=l.useState("openChangeReason"),w=l.useState("popupElement"),A=l.useState("payload"),R=l.useState("positionerElement"),I=l.useState("activeTriggerElement"),D=l.useState("floatingRootContext");Sa({open:h,ref:l.context.popupRef,onComplete(){h&&l.context.onOpenChangeComplete?.(!0)}});const j=l.useState("disabled"),F=l.useState("openOnHover"),z=l.useState("closeDelay");QV(D,{enabled:F&&!j,closeDelay:z});function P(X){return X==="touch"?l.context.popupRef.current:!0}const L=s===void 0?P:s,M=x.useMemo(()=>({open:h,side:u.side,align:u.align,instant:g,transitionStatus:y}),[h,u.side,u.align,g,y]),$=x.useCallback(X=>{l.set("popupElement",X)},[l]);function W(){D.context.events.emit("measure-layout")}function Y(X,U){D.context.events.emit("measure-layout-complete",{previousDimensions:X,nextDimensions:U})}const q=x.useCallback(()=>l.context.triggerElements.size>1,[l]);swe({popupElement:w,positionerElement:R,mounted:T,content:A,enabled:q,onMeasureLayout:W,onMeasureLayoutComplete:Y,side:u.side,direction:f});const K=an("div",t,{state:M,ref:[n,l.context.popupRef,$],props:[v,{"aria-labelledby":_,"aria-describedby":S,onKeyDown(X){d&&Q3.has(X.key)&&X.stopPropagation()}},Jm(y),o],stateAttributesMapping:LVe});return c.jsx(cC,{context:D,openInteractionType:m,modal:E==="trap-focus",disabled:!T||k===vi,initialFocus:L,returnFocus:a,restoreFocus:"popup",previousFocusableElement:ki(I)?I:void 0,nextFocusableElement:l.context.triggerFocusTargetRef,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:K})}),FVe=x.forwardRef(function(t,n){const{children:r,container:i,className:s,render:a,...o}=t,{portalNode:l,portalSubtree:u}=r_e({container:i,ref:n,componentProps:t,elementProps:o});return!u&&!l?null:c.jsxs(x.Fragment,{children:[u,l&&_i.createPortal(r,l)]})});let Cse=(function(e){return e.checked="data-checked",e.unchecked="data-unchecked",e.disabled="data-disabled",e.readonly="data-readonly",e.required="data-required",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const S$={checked(e){return e?{[Cse.checked]:""}:{[Cse.unchecked]:""}},...ll,...dp},awe=x.createContext({disabled:void 0,readOnly:void 0,required:void 0,name:void 0,checkedValue:"",setCheckedValue:di,onValueChange:di,touched:!1,setTouched:di,registerControlRef:di});function BVe(){return x.useContext(awe)}const owe=x.createContext(void 0);function $Ve(){const e=x.useContext(owe);if(e===void 0)throw new Error(Un(52));return e}const zVe=x.forwardRef(function(t,n){const{render:r,className:i,disabled:s=!1,readOnly:a=!1,required:o=!1,value:l,inputRef:u,nativeButton:d=!1,id:f,...h}=t,{disabled:m,readOnly:g,required:y,checkedValue:v,setCheckedValue:_,touched:S,setTouched:E,validation:T,registerControlRef:k}=BVe(),{setDirty:w,validityData:A,setTouched:R,setFilled:I,state:D,disabled:j}=Hl(),F=pSe(),{labelId:z,getDescriptionProps:P}=Rf(),L=j||F.disabled||m||s,M=g||a,$=y||o,W=v===l,Y=x.useRef(null),q=x.useRef(null),K=zl(u,q);Lt(()=>{q.current?.checked&&I(!0)},[I]);const X=ds(),U=EC({id:f,implicit:!1,controlRef:Y}),J={role:"radio","aria-checked":W,"aria-required":$||void 0,"aria-disabled":L||void 0,"aria-readonly":M||void 0,"aria-labelledby":z,[nW]:W?"":void 0,id:X,disabled:L,onKeyDown(Ie){Ie.key==="Enter"&&Ie.preventDefault()},onClick(Ie){Ie.defaultPrevented||L||M||(Ie.preventDefault(),q.current?.click())},onFocus(Ie){Ie.defaultPrevented||L||M||!S||(q.current?.click(),E(!1))}},{getButtonProps:te,buttonRef:ee}=go({disabled:L,native:d}),oe=x.useMemo(()=>({type:"radio",ref:K,id:U,tabIndex:-1,style:Zm,"aria-hidden":!0,disabled:L,checked:W,required:$,readOnly:M,onChange(Ie){if(Ie.nativeEvent.defaultPrevented||L||M||l===void 0)return;const fe=$t(Es,Ie.nativeEvent);fe.isCanceled||(R(!0),w(l!==A.initialValue),I(!0),_(l,fe))},onFocus(){Y.current?.focus()}}),[W,L,U,K,M,$,_,w,R,I,A.initialValue,l]),ae=x.useMemo(()=>({...D,required:$,disabled:L,readOnly:M,checked:W}),[D,L,M,W,$]),se=x.useMemo(()=>ae,[ae]),ue=_!==di,de=[n,k,Y,ee],ce=[J,P,T?.getValidationProps??Ti,h,te],Ee=an("span",t,{enabled:!ue,state:ae,ref:de,props:ce,stateAttributesMapping:S$});return c.jsxs(owe.Provider,{value:se,children:[ue?c.jsx(gC,{tag:"span",render:r,className:i,state:ae,refs:de,props:ce,stateAttributesMapping:S$}):Ee,c.jsx("input",{...oe})]})}),UVe=x.forwardRef(function(t,n){const{render:r,className:i,keepMounted:s=!1,...a}=t,o=$Ve(),l=o.checked,{transitionStatus:u,setMounted:d}=Lu(l),f=x.useMemo(()=>({...o,transitionStatus:u}),[o,u]),h=x.useRef(null),m=s||l,g=an("span",t,{enabled:m,ref:[n,h],state:f,props:a,stateAttributesMapping:S$});return Sa({open:l,ref:h,onComplete(){l||d(!1)}}),m?g:null}),HVe=[S_e],VVe=x.forwardRef(function(t,n){const{render:r,className:i,disabled:s,readOnly:a,required:o,onValueChange:l,value:u,defaultValue:d,name:f,inputRef:h,id:m,...g}=t,{setTouched:y,setFocused:v,shouldValidateOnChange:_,validationMode:S,name:E,disabled:T,state:k,validation:w,setDirty:A,setFilled:R,validityData:I}=Hl(),{labelId:D}=Rf(),{clearErrors:j}=E1(),F=kUe(!0),z=T||s,P=E??f,L=ds(m),[M,$]=Ml({controlled:u,default:d,name:"RadioGroup",state:"value"}),W=_t(l),Y=_t((ce,Ee)=>{W(ce,Ee),!Ee.isCanceled&&$(ce)}),q=x.useRef(null),K=_t(ce=>{q.current==null&&ce!=null&&(q.current=ce)});C1({id:L,commit:w.commit,value:M,controlRef:q,name:P,getValue:()=>M??null}),ym(M,()=>{j(P),A(M!==I.initialValue),R(M!=null),_()?w.commit(M):w.commit(M,!0)});const[X,U]=x.useState(!1),J=_t(ce=>{xn(ce.currentTarget,ce.relatedTarget)||(y(!0),v(!1),S==="onBlur"&&w.commit(M))}),te=_t(ce=>{ce.key.startsWith("Arrow")&&(y(!0),U(!0),v(!0))}),ee=x.useMemo(()=>M==null?"":typeof M=="string"?M:JSON.stringify(M),[M]),oe=zl(w.inputRef,h),ae=gd({value:ee,ref:oe,id:L,name:ee?P:void 0,disabled:z,readOnly:a,required:o,"aria-labelledby":g["aria-labelledby"]??F?.legendId,"aria-hidden":!0,tabIndex:-1,style:Zm,onChange:di,onFocus(){q.current?.focus()}},w.getInputValidationProps),se=x.useMemo(()=>({...k,disabled:z??!1,required:o??!1,readOnly:a??!1}),[k,z,a,o]),ue=x.useMemo(()=>({...k,checkedValue:M,disabled:z,validation:w,name:P,onValueChange:W,readOnly:a,registerControlRef:K,required:o,setCheckedValue:Y,setTouched:U,touched:X}),[M,z,w,k,P,W,a,K,o,Y,U,X]),de={role:"radiogroup","aria-required":o||void 0,"aria-disabled":z||void 0,"aria-readonly":a||void 0,"aria-labelledby":D,onFocus(){v(!0)},onBlur:J,onKeyDownCapture:te};return c.jsxs(awe.Provider,{value:ue,children:[c.jsx(pC,{render:r,className:i,state:se,props:[de,w.getValidationProps,g],refs:[n],stateAttributesMapping:dp,enableHomeAndEndKeys:!1,modifierKeys:HVe}),c.jsx("input",{...ae})]})}),lwe=x.createContext(void 0);function cD(){const e=x.useContext(lwe);if(e===void 0)throw new Error(Un(53));return e}let qO=(function(e){return e.scrollAreaCornerHeight="--scroll-area-corner-height",e.scrollAreaCornerWidth="--scroll-area-corner-width",e})({});const EA=500,kse=16;function Su(e,t,n){if(!e)return 0;const r=getComputedStyle(e),i=n==="x"?"Inline":"Block";return n==="x"&&t==="margin"?parseFloat(r[`${t}InlineStart`])*2:parseFloat(r[`${t}${i}Start`])+parseFloat(r[`${t}${i}End`])}let WVe=(function(e){return e.orientation="data-orientation",e.hovering="data-hovering",e.scrolling="data-scrolling",e.hasOverflowX="data-has-overflow-x",e.hasOverflowY="data-has-overflow-y",e.overflowXStart="data-overflow-x-start",e.overflowXEnd="data-overflow-x-end",e.overflowYStart="data-overflow-y-start",e.overflowYEnd="data-overflow-y-end",e})({}),Uv=(function(e){return e.hasOverflowX="data-has-overflow-x",e.hasOverflowY="data-has-overflow-y",e.overflowXStart="data-overflow-x-start",e.overflowXEnd="data-overflow-x-end",e.overflowYStart="data-overflow-y-start",e.overflowYEnd="data-overflow-y-end",e})({});const TW={hasOverflowX:e=>e?{[Uv.hasOverflowX]:""}:null,hasOverflowY:e=>e?{[Uv.hasOverflowY]:""}:null,overflowXStart:e=>e?{[Uv.overflowXStart]:""}:null,overflowXEnd:e=>e?{[Uv.overflowXEnd]:""}:null,overflowYStart:e=>e?{[Uv.overflowYStart]:""}:null,overflowYEnd:e=>e?{[Uv.overflowYEnd]:""}:null,cornerHidden:()=>null},Tse={width:0,height:0},qVe={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},GVe=x.forwardRef(function(t,n){const{render:r,className:i,overflowEdgeThreshold:s,...a}=t,[o,l]=x.useState(!1),[u,d]=x.useState(!1),[f,h]=x.useState(!1),[m,g]=x.useState(Tse),[y,v]=x.useState(Tse),[_,S]=x.useState(!1),[E,T]=x.useState(qVe),k=ds(),w=x.useRef(null),A=x.useRef(null),R=x.useRef(null),I=x.useRef(null),D=x.useRef(null),j=x.useRef(null),F=x.useRef(null),z=x.useRef(!1),P=x.useRef(0),L=x.useRef(0),M=x.useRef(0),$=x.useRef(0),W=x.useRef("vertical"),Y=si(),q=si(),K=x.useRef({x:0,y:0}),[X,U]=x.useState({scrollbarYHidden:!1,scrollbarXHidden:!1,cornerHidden:!1}),J=KVe(s),te=_t(Ie=>{const fe=Ie.x-K.current.x,be=Ie.y-K.current.y;K.current=Ie,be!==0&&(h(!0),Y.start(EA,()=>{h(!1)})),fe!==0&&(d(!0),q.start(EA,()=>{d(!1)}))}),ee=_t(Ie=>{Ie.button===0&&(z.current=!0,P.current=Ie.clientY,L.current=Ie.clientX,W.current=Ie.currentTarget.getAttribute(WVe.orientation),A.current&&(M.current=A.current.scrollTop,$.current=A.current.scrollLeft),D.current&&W.current==="vertical"&&D.current.setPointerCapture(Ie.pointerId),j.current&&W.current==="horizontal"&&j.current.setPointerCapture(Ie.pointerId))}),oe=_t(Ie=>{if(!z.current)return;const fe=Ie.clientY-P.current,be=Ie.clientX-L.current;if(A.current){const ge=A.current.scrollHeight,Ce=A.current.clientHeight,Re=A.current.scrollWidth,xe=A.current.clientWidth;if(D.current&&R.current&&W.current==="vertical"){const ye=Su(R.current,"padding","y"),De=Su(D.current,"margin","y"),ve=D.current.offsetHeight,Oe=R.current.offsetHeight-ve-ye-De,Be=fe/Oe;A.current.scrollTop=M.current+Be*(ge-Ce),Ie.preventDefault(),h(!0),Y.start(EA,()=>{h(!1)})}if(j.current&&I.current&&W.current==="horizontal"){const ye=Su(I.current,"padding","x"),De=Su(j.current,"margin","x"),ve=j.current.offsetWidth,Oe=I.current.offsetWidth-ve-ye-De,Be=be/Oe;A.current.scrollLeft=$.current+Be*(Re-xe),Ie.preventDefault(),d(!0),q.start(EA,()=>{d(!1)})}}}),ae=_t(Ie=>{z.current=!1,D.current&&W.current==="vertical"&&D.current.releasePointerCapture(Ie.pointerId),j.current&&W.current==="horizontal"&&j.current.releasePointerCapture(Ie.pointerId)});function se(Ie){const fe=Ie.pointerType==="touch";if(S(fe),!fe){const be=xn(w.current,Ie.target);l(be)}}const ue=x.useMemo(()=>({hasOverflowX:!X.scrollbarXHidden,hasOverflowY:!X.scrollbarYHidden,overflowXStart:E.xStart,overflowXEnd:E.xEnd,overflowYStart:E.yStart,overflowYEnd:E.yEnd,cornerHidden:X.cornerHidden}),[X.scrollbarXHidden,X.scrollbarYHidden,X.cornerHidden,E]),de={role:"presentation",onPointerEnter:se,onPointerMove:se,onPointerDown({pointerType:Ie}){S(Ie==="touch")},onPointerLeave(){l(!1)},style:{position:"relative",[qO.scrollAreaCornerHeight]:`${m.height}px`,[qO.scrollAreaCornerWidth]:`${m.width}px`}},ce=an("div",t,{state:ue,ref:[n,w],props:[de,a],stateAttributesMapping:TW}),Ee=x.useMemo(()=>({handlePointerDown:ee,handlePointerMove:oe,handlePointerUp:ae,handleScroll:te,cornerSize:m,setCornerSize:g,thumbSize:y,setThumbSize:v,touchModality:_,cornerRef:F,scrollingX:u,setScrollingX:d,scrollingY:f,setScrollingY:h,hovering:o,setHovering:l,viewportRef:A,rootRef:w,scrollbarYRef:R,scrollbarXRef:I,thumbYRef:D,thumbXRef:j,rootId:k,hiddenState:X,setHiddenState:U,overflowEdges:E,setOverflowEdges:T,viewportState:ue,overflowEdgeThreshold:J}),[ee,oe,ae,te,m,y,_,F,u,d,f,h,o,l,A,w,R,I,D,j,k,X,E,ue,J]);return c.jsxs(lwe.Provider,{value:Ee,children:[CE.element,ce]})});function KVe(e){if(typeof e=="number"){const t=Math.max(0,e);return{xStart:t,xEnd:t,yStart:t,yEnd:t}}return{xStart:Math.max(0,e?.xStart||0),xEnd:Math.max(0,e?.xEnd||0),yStart:Math.max(0,e?.yStart||0),yEnd:Math.max(0,e?.yEnd||0)}}const YVe=x.createContext(void 0);function XVe(e,t){if(typeof IntersectionObserver>"u")return()=>{};const n=new IntersectionObserver(r=>{r.forEach(i=>{i.intersectionRatio>0&&(t(),n.disconnect())})});return n.observe(e),()=>{n.disconnect()}}let vm=(function(e){return e.scrollAreaOverflowXStart="--scroll-area-overflow-x-start",e.scrollAreaOverflowXEnd="--scroll-area-overflow-x-end",e.scrollAreaOverflowYStart="--scroll-area-overflow-y-start",e.scrollAreaOverflowYEnd="--scroll-area-overflow-y-end",e})({}),Ase=!1;function QVe(){Ase||MV||(typeof CSS<"u"&&"registerProperty"in CSS&&[vm.scrollAreaOverflowXStart,vm.scrollAreaOverflowXEnd,vm.scrollAreaOverflowYStart,vm.scrollAreaOverflowYEnd].forEach(e=>{try{CSS.registerProperty({name:e,syntax:"<length>",inherits:!1,initialValue:"0px"})}catch{}}),Ase=!0)}const ZVe=x.forwardRef(function(t,n){const{render:r,className:i,...s}=t,{viewportRef:a,scrollbarYRef:o,scrollbarXRef:l,thumbYRef:u,thumbXRef:d,cornerRef:f,setCornerSize:h,setThumbSize:m,rootId:g,setHiddenState:y,hiddenState:v,handleScroll:_,setHovering:S,setOverflowEdges:E,overflowEdges:T,overflowEdgeThreshold:k}=cD(),w=Of(),A=x.useRef(!0),R=si(),I=si();function D(){const $=a.current,W=o.current,Y=l.current,q=u.current,K=d.current,X=f.current;if(!$)return;const U=$.scrollHeight,J=$.scrollWidth,te=$.clientHeight,ee=$.clientWidth,oe=$.scrollTop,ae=$.scrollLeft;if(U===0||J===0)return;const se=te>=U,ue=ee>=J,de=ee/J,ce=te/U,Ee=Math.max(0,J-ee),Ie=Math.max(0,U-te);let fe=0,be=0;ue||(w==="rtl"?fe=oh(-ae,0,Ee):fe=oh(ae,0,Ee),be=Ee-fe);const ge=se?0:oh(oe,0,Ie),Ce=se?0:Ie-ge,Re=ue?0:ee,xe=se?0:te,ye=Su(Y,"padding","x"),De=Su(W,"padding","y"),ve=Su(K,"margin","x"),Oe=Su(q,"margin","y"),Be=Re-ye-ve,Te=xe-De-Oe,je=Y?Math.min(Y.offsetWidth,Be):Be,ie=W?Math.min(W.offsetHeight,Te):Te,Ke=Math.max(kse,je*de),lt=Math.max(kse,ie*ce);if(m(Qe=>Qe.height===lt&&Qe.width===Ke?Qe:{width:Ke,height:lt}),W&&q){const Qe=W.offsetHeight-lt-De-Oe,pt=U-te,at=pt===0?0:oe/pt,gt=Math.min(Qe,Math.max(0,at*Qe));q.style.transform=`translate3d(0,${gt}px,0)`}if(Y&&K){const Qe=Y.offsetWidth-Ke-ye-ve,pt=J-ee,at=pt===0?0:ae/pt,gt=w==="rtl"?oh(at*Qe,-Qe,0):oh(at*Qe,0,Qe);K.style.transform=`translate3d(${gt}px,0,0)`}const Rt=oh(fe,0,Ee),Ye=oh(be,0,Ee),ct=oh(ge,0,Ie),Ve=oh(Ce,0,Ie),Et=[[vm.scrollAreaOverflowXStart,Rt],[vm.scrollAreaOverflowXEnd,Ye],[vm.scrollAreaOverflowYStart,ct],[vm.scrollAreaOverflowYEnd,Ve]];for(const[Qe,pt]of Et)$.style.setProperty(Qe,`${pt}px`);if(X){if(ue||se)h({width:0,height:0});else if(!ue&&!se){const Qe=W?.offsetWidth||0,pt=Y?.offsetHeight||0;h({width:Qe,height:pt})}}y(Qe=>{const pt=se||ue;return Qe.scrollbarYHidden===se&&Qe.scrollbarXHidden===ue&&Qe.cornerHidden===pt?Qe:{scrollbarYHidden:se,scrollbarXHidden:ue,cornerHidden:pt}});const $e={xStart:!ue&&Rt>k.xStart,xEnd:!ue&&Ye>k.xEnd,yStart:!se&&ct>k.yStart,yEnd:!se&&Ve>k.yEnd};E(Qe=>Qe.xStart===$e.xStart&&Qe.xEnd===$e.xEnd&&Qe.yStart===$e.yStart&&Qe.yEnd===$e.yEnd?Qe:$e)}const j=_t(()=>{_i.flushSync(D)});Lt(()=>a.current?(QVe(),XVe(a.current,j)):void 0,[j,a]),Lt(()=>{queueMicrotask(j)},[j,v,w]),Lt(()=>{a.current?.matches(":hover")&&S(!0)},[a,S]),x.useEffect(()=>{const $=a.current;if(typeof ResizeObserver>"u"||!$)return;const W=new ResizeObserver(j);return W.observe($),I.start(0,()=>{Promise.all($.getAnimations({subtree:!0}).map(Y=>Y.finished)).then(j).catch(()=>{})}),()=>{W.disconnect(),I.clear()}},[j,a,I]);function F(){A.current=!1}const z={role:"presentation",...g&&{"data-id":`${g}-viewport`},...(!v.scrollbarXHidden||!v.scrollbarYHidden)&&{tabIndex:0},className:CE.className,style:{overflow:"scroll"},onScroll(){a.current&&(j(),A.current||_({x:a.current.scrollLeft,y:a.current.scrollTop}),R.start(100,()=>{A.current=!0}))},onWheel:F,onTouchMove:F,onPointerMove:F,onPointerEnter:F,onKeyDown:F},P=x.useMemo(()=>({hasOverflowX:!v.scrollbarXHidden,hasOverflowY:!v.scrollbarYHidden,overflowXStart:T.xStart,overflowXEnd:T.xEnd,overflowYStart:T.yStart,overflowYEnd:T.yEnd,cornerHidden:v.cornerHidden}),[v.scrollbarXHidden,v.scrollbarYHidden,v.cornerHidden,T]),L=an("div",t,{ref:[n,a],state:P,props:[z,s],stateAttributesMapping:TW}),M=x.useMemo(()=>({computeThumbPosition:j}),[j]);return c.jsx(YVe.Provider,{value:M,children:L})}),cwe=x.createContext(void 0);function JVe(){const e=x.useContext(cwe);if(e===void 0)throw new Error(Un(54));return e}let GO=(function(e){return e.scrollAreaThumbHeight="--scroll-area-thumb-height",e.scrollAreaThumbWidth="--scroll-area-thumb-width",e})({});const eWe=x.forwardRef(function(t,n){const{render:r,className:i,orientation:s="vertical",keepMounted:a=!1,...o}=t,{hovering:l,scrollingX:u,scrollingY:d,hiddenState:f,overflowEdges:h,scrollbarYRef:m,scrollbarXRef:g,viewportRef:y,thumbYRef:v,thumbXRef:_,handlePointerDown:S,handlePointerUp:E,rootId:T,thumbSize:k}=cD(),w=x.useMemo(()=>({hovering:l,scrolling:{horizontal:u,vertical:d}[s],orientation:s,hasOverflowX:!f.scrollbarXHidden,hasOverflowY:!f.scrollbarYHidden,overflowXStart:h.xStart,overflowXEnd:h.xEnd,overflowYStart:h.yStart,overflowYEnd:h.yEnd,cornerHidden:f.cornerHidden}),[l,u,d,s,f,h]),A=Of();x.useEffect(()=>{const z=y.current,P=s==="vertical"?m.current:g.current;if(!P)return;function L(M){if(!(!z||!P||M.ctrlKey)){if(M.preventDefault(),s==="vertical"){if(z.scrollTop===0&&M.deltaY<0)return}else if(z.scrollLeft===0&&M.deltaX<0)return;if(s==="vertical"){if(z.scrollTop===z.scrollHeight-z.clientHeight&&M.deltaY>0)return}else if(z.scrollLeft===z.scrollWidth-z.clientWidth&&M.deltaX>0)return;s==="vertical"?z.scrollTop+=M.deltaY:z.scrollLeft+=M.deltaX}}return P.addEventListener("wheel",L,{passive:!1}),()=>{P.removeEventListener("wheel",L)}},[s,g,m,y]);const R={...T&&{"data-id":`${T}-scrollbar`},onPointerDown(z){if(z.button===0&&z.currentTarget===z.target&&y.current){if(v.current&&m.current&&s==="vertical"){const P=Su(v.current,"margin","y"),L=Su(m.current,"padding","y"),M=v.current.offsetHeight,$=m.current.getBoundingClientRect(),W=z.clientY-$.top-M/2-L+P/2,Y=y.current.scrollHeight,q=y.current.clientHeight,K=m.current.offsetHeight-M-L-P,U=W/K*(Y-q);y.current.scrollTop=U}if(_.current&&g.current&&s==="horizontal"){const P=Su(_.current,"margin","x"),L=Su(g.current,"padding","x"),M=_.current.offsetWidth,$=g.current.getBoundingClientRect(),W=z.clientX-$.left-M/2-L+P/2,Y=y.current.scrollWidth,q=y.current.clientWidth,K=g.current.offsetWidth-M-L-P,X=W/K;let U;A==="rtl"?(U=(1-X)*(Y-q),y.current.scrollLeft<=0&&(U=-U)):U=X*(Y-q),y.current.scrollLeft=U}S(z)}},onPointerUp:E,style:{position:"absolute",touchAction:"none",WebkitUserSelect:"none",userSelect:"none",...s==="vertical"&&{top:0,bottom:`var(${qO.scrollAreaCornerHeight})`,insetInlineEnd:0,[GO.scrollAreaThumbHeight]:`${k.height}px`},...s==="horizontal"&&{insetInlineStart:0,insetInlineEnd:`var(${qO.scrollAreaCornerWidth})`,bottom:0,[GO.scrollAreaThumbWidth]:`${k.width}px`}}},I=an("div",t,{ref:[n,s==="vertical"?m:g],state:w,props:[R,o],stateAttributesMapping:TW}),D=x.useMemo(()=>({orientation:s}),[s]),j=s==="vertical"?f.scrollbarYHidden:f.scrollbarXHidden;return a||!j?c.jsx(cwe.Provider,{value:D,children:I}):null}),tWe=x.forwardRef(function(t,n){const{render:r,className:i,...s}=t,{thumbYRef:a,thumbXRef:o,handlePointerDown:l,handlePointerMove:u,handlePointerUp:d,setScrollingX:f,setScrollingY:h}=cD(),{orientation:m}=JVe(),g=x.useMemo(()=>({orientation:m}),[m]);return an("div",t,{ref:[n,m==="vertical"?a:o],state:g,props:[{onPointerDown:l,onPointerMove:u,onPointerUp(v){m==="vertical"&&h(!1),m==="horizontal"&&f(!1),d(v)},style:{...m==="vertical"&&{height:`var(${GO.scrollAreaThumbHeight})`},...m==="horizontal"&&{width:`var(${GO.scrollAreaThumbWidth})`}}},s]})}),nWe=x.forwardRef(function(t,n){const{render:r,className:i,...s}=t,{cornerRef:a,cornerSize:o,hiddenState:l}=cD(),u=an("div",t,{ref:[n,a],props:[{style:{position:"absolute",bottom:0,insetInlineEnd:0,width:o.width,height:o.height}},s]});return l.cornerHidden?null:u}),uwe=x.createContext(void 0);function rWe(){const e=x.useContext(uwe);if(e===void 0)throw new Error(Un(63));return e}let Nse=(function(e){return e.checked="data-checked",e.unchecked="data-unchecked",e.disabled="data-disabled",e.readonly="data-readonly",e.required="data-required",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const dwe={...dp,checked(e){return e?{[Nse.checked]:""}:{[Nse.unchecked]:""}}},iWe=x.forwardRef(function(t,n){const{checked:r,className:i,defaultChecked:s,id:a,inputRef:o,name:l,nativeButton:u=!1,onCheckedChange:d,readOnly:f=!1,required:h=!1,disabled:m=!1,render:g,uncheckedValue:y,...v}=t,{clearErrors:_}=E1(),{state:S,setTouched:E,setDirty:T,validityData:k,setFilled:w,setFocused:A,shouldValidateOnChange:R,validationMode:I,disabled:D,name:j,validation:F}=Hl(),{labelId:z}=Rf(),P=D||m,L=j??l,M=_t(d),$=x.useRef(null),W=zl($,o,F.inputRef),Y=x.useRef(null),q=ds(),K=EC({id:a,implicit:!1,controlRef:Y}),[X,U]=Ml({controlled:r,default:!!s,name:"Switch",state:"checked"});C1({id:q,commit:F.commit,value:X,controlRef:Y,name:L,getValue:()=>X}),Lt(()=>{$.current&&w($.current.checked)},[$,w]),ym(X,()=>{_(L),T(X!==k.initialValue),w(X),R()?F.commit(X):F.commit(X,!0)});const{getButtonProps:J,buttonRef:te}=go({disabled:P,native:u}),ee={id:q,role:"switch","aria-checked":X,"aria-readonly":f||void 0,"aria-labelledby":z,onFocus(){P||A(!0)},onBlur(){const ue=$.current;!ue||P||(E(!0),A(!1),I==="onBlur"&&F.commit(ue.checked))},onClick(ue){f||P||(ue.preventDefault(),$?.current?.click())}},oe=x.useMemo(()=>gd({checked:X,disabled:P,id:K,name:L,required:h,style:Zm,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:W,onChange(ue){if(ue.nativeEvent.defaultPrevented)return;const de=ue.target.checked,ce=$t(Es,ue.nativeEvent);M?.(de,ce),!ce.isCanceled&&U(de)},onFocus(){Y.current?.focus()}},F.getInputValidationProps),[X,P,W,K,L,M,h,U,F]),ae=x.useMemo(()=>({...S,checked:X,disabled:P,readOnly:f,required:h}),[S,X,P,f,h]),se=an("span",t,{state:ae,ref:[n,Y,te],props:[ee,F.getValidationProps,v,J],stateAttributesMapping:dwe});return c.jsxs(uwe.Provider,{value:ae,children:[se,!X&&L&&y!==void 0&&c.jsx("input",{type:"hidden",name:L,value:y}),c.jsx("input",{...oe})]})}),sWe=x.forwardRef(function(t,n){const{render:r,className:i,...s}=t,{state:a}=Hl(),o=rWe(),l={...a,...o};return an("span",t,{state:l,ref:n,stateAttributesMapping:dwe,props:s})}),fwe=x.createContext(void 0);function aWe(e=!0){const t=x.useContext(fwe);if(t===void 0&&!e)throw new Error(Un(7));return t}const hwe=x.forwardRef(function(t,n){const{className:r,defaultPressed:i=!1,disabled:s=!1,form:a,onPressedChange:o,pressed:l,render:u,type:d,value:f,nativeButton:h=!0,...m}=t,g=ds(f||void 0),y=aWe(),v=y?.value??[],_=y?void 0:i,S=(s||y?.disabled)??!1,[E,T]=Ml({controlled:y?v?.indexOf(g)>-1:l,default:_,name:"Toggle",state:"pressed"}),k=_t((F,z)=>{g&&y?.setGroupValue?.(g,F,z),o?.(F,z)}),{getButtonProps:w,buttonRef:A}=go({disabled:S,native:h}),R=x.useMemo(()=>({disabled:S,pressed:E}),[S,E]),I=[A,n],D=[{"aria-pressed":E,onClick(F){const z=!E,P=$t(Es,F.nativeEvent);k(z,P),!P.isCanceled&&T(z)}},m,w],j=an("button",t,{enabled:!y,state:R,ref:I,props:D});return y?c.jsx(gC,{tag:"button",render:u,className:r,state:R,refs:I,props:D}):j});let oWe=(function(e){return e.disabled="data-disabled",e.orientation="data-orientation",e.multiple="data-multiple",e})({});const Ose={multiple(e){return e?{[oWe.multiple]:""}:null}},lWe=x.forwardRef(function(t,n){const{defaultValue:r,disabled:i=!1,loopFocus:s=!0,onValueChange:a,orientation:o="horizontal",multiple:l=!1,value:u,className:d,render:f,...h}=t,m=aD(),g=x.useMemo(()=>{if(u===void 0)return r??[]},[u,r]),y=(m?.disabled??!1)||i,[v,_]=Ml({controlled:u,default:g,name:"ToggleGroup",state:"value"}),S=_t((A,R,I)=>{let D;if(l?(D=v.slice(),R?D.push(A):D.splice(v.indexOf(A),1)):D=R?[A]:[],Array.isArray(D)){if(a?.(D,I),I.isCanceled)return;_(D)}}),E=x.useMemo(()=>({disabled:y,multiple:l,orientation:o}),[y,o,l]),T=x.useMemo(()=>({disabled:y,orientation:o,setGroupValue:S,value:v}),[y,o,S,v]),k={role:"group"},w=an("div",t,{enabled:!!m,state:E,ref:n,props:[k,h],stateAttributesMapping:Ose});return c.jsx(fwe.Provider,{value:T,children:m?w:c.jsx(pC,{render:f,className:d,state:E,refs:[n],props:[k,h],stateAttributesMapping:Ose,loopFocus:s})})}),pwe=x.createContext(void 0);function kC(e){const t=x.useContext(pwe);if(t===void 0&&!e)throw new Error(Un(72));return t}const cWe={...W3,disabled:ft(e=>e.disabled),instantType:ft(e=>e.instantType),isInstantPhase:ft(e=>e.isInstantPhase),trackCursorAxis:ft(e=>e.trackCursorAxis),disableHoverablePopup:ft(e=>e.disableHoverablePopup),lastOpenChangeReason:ft(e=>e.openChangeReason),closeDelay:ft(e=>e.closeDelay)};class AW extends uC{constructor(t){super({...uWe(),...t},{popupRef:x.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:new _1},cWe)}setOpen=(t,n)=>{const r=n.reason,i=r===vi,s=t&&r===pE,a=!t&&(r===Au||r===v1);if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},this.context.onOpenChange?.(t,n),n.isCanceled)return;const o=()=>{const l={open:t,openChangeReason:r};s?l.instantType="focus":a?l.instantType="dismiss":r===vi&&(l.instantType=void 0);const u=n.trigger?.id??null;(u||t)&&(l.activeTriggerId=u,l.activeTriggerElement=n.trigger??null),this.update(l)};i?_i.flushSync(o):o()};static useStore(t,n){const r=_a(()=>t??new AW(n)).current,i=G3({popupStore:r,onOpenChange:r.setOpen});return r.state.floatingRootContext=i,r}}function uWe(){return{...V3(),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:"none",disableHoverablePopup:!1,openChangeReason:null,closeDelay:0}}function dWe(e){const{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:s="none",actionsRef:a,onOpenChange:o,onOpenChangeComplete:l,handle:u,triggerId:d,defaultTriggerId:f=null,children:h}=e,m=AW.useStore(u?.store,{open:r??n,activeTriggerId:d!==void 0?d:f});m.useControlledProp("open",r,n),m.useControlledProp("activeTriggerId",d,f),m.useContextCallback("onOpenChange",o),m.useContextCallback("onOpenChangeComplete",l);const g=m.useState("open"),y=m.useState("activeTriggerId"),v=m.useState("payload");m.useSyncedValues({trackCursorAxis:s,disableHoverablePopup:i});const _=!t&&g;Lt(()=>{g&&t&&m.setOpen(!1,$t(dFe))},[g,t,m]),m.useSyncedValue("disabled",t),z3(m);const{forceUnmount:S,transitionStatus:E}=U3(_,m),T=m.useState("isInstantPhase"),k=m.useState("instantType"),w=m.useState("lastOpenChangeReason"),A=x.useRef(null);Lt(()=>{E==="ending"&&w===Es||E!=="ending"&&T?(k!=="delay"&&(A.current=k),m.set("instantType","delay")):A.current!==null&&(m.set("instantType",A.current),A.current=null)},[E,T,w,k,m]),Lt(()=>{_&&y==null&&m.set("payload",void 0)},[m,y,_]);const R=x.useCallback(()=>{m.setOpen(!1,fWe(m,M3))},[m]);x.useImperativeHandle(a,()=>({unmount:S,close:R}),[S,R]);const I=m.useState("floatingRootContext"),D=p_e(I,{enabled:!t}),j=Ey(I,{enabled:!t,referencePress:!0}),F=AFe(I,{enabled:!t&&s!=="none",axis:s==="none"?void 0:s}),{getReferenceProps:z,getFloatingProps:P,getTriggerProps:L}=Nf([D,j,F]),M=x.useMemo(()=>z(),[z]),$=x.useMemo(()=>L(),[L]),W=x.useMemo(()=>P(),[P]);return m.useSyncedValues({floatingRootContext:I,activeTriggerProps:M,inactiveTriggerProps:$,popupProps:W}),c.jsx(pwe.Provider,{value:m,children:typeof h=="function"?h({payload:v}):h})}function fWe(e,t){const n=$t(t);return n.preventUnmountOnClose=()=>{e.set("preventUnmountingOnClose",!0)},n}const mwe=x.createContext(void 0);function hWe(){return x.useContext(mwe)}const pWe=600,mWe=x.forwardRef(function(t,n){const{className:r,render:i,handle:s,payload:a,disabled:o,delay:l,closeDelay:u,id:d,...f}=t,h=kC(!0),m=s?.store??h;if(!m)throw new Error(Un(82));const g=ds(d),y=m.useState("isTriggerActive",g),v=m.useState("floatingRootContext"),_=m.useState("isOpenedByTrigger",g),S=x.useRef(null),E=l??pWe,T=u??0,{registerTrigger:k,isMountedByThisTrigger:w}=$3(g,S,m,{payload:a,closeDelay:T}),A=hWe(),{delayRef:R,isInstantPhase:I,hasProvider:D}=bFe(v,{open:_});m.useSyncedValue("isInstantPhase",I);const j=m.useState("disabled"),F=o??j,z=m.useState("trackCursorAxis"),P=m.useState("disableHoverablePopup"),L=ZV(v,{enabled:!F,mouseOnly:!0,move:!1,handleClose:!P&&z!=="both"?Y3():null,restMs(){const Y=A?.delay,q=typeof R.current=="object"?R.current.open:void 0;let K=E;return D&&(q!==0?K=l??Y??E:K=0),K},delay(){const Y=typeof R.current=="object"?R.current.close:void 0;let q=T;return u==null&&D&&(q=Y),{close:q}},triggerElementRef:S,isActiveTrigger:y}),M=x.useMemo(()=>({open:_}),[_]),$=m.useState("triggerProps",w);return an("button",t,{state:M,ref:[n,k,S],props:[L,$,{id:g},f],stateAttributesMapping:mC})}),gwe=x.createContext(void 0);function gWe(){const e=x.useContext(gwe);if(e===void 0)throw new Error(Un(70));return e}const bWe=x.forwardRef(function(t,n){const{keepMounted:r=!1,...i}=t;return kC().useState("mounted")||r?c.jsx(gwe.Provider,{value:r,children:c.jsx(FVe,{ref:n,...i})}):null}),bwe=x.createContext(void 0);function ywe(){const e=x.useContext(bwe);if(e===void 0)throw new Error(Un(71));return e}const yWe=x.forwardRef(function(t,n){const{render:r,className:i,anchor:s,positionMethod:a="absolute",side:o="top",align:l="center",sideOffset:u=0,alignOffset:d=0,collisionBoundary:f="clipping-ancestors",collisionPadding:h=5,arrowPadding:m=5,sticky:g=!1,disableAnchorTracking:y=!1,collisionAvoidance:v=D3,..._}=t,S=kC(),E=gWe(),T=S.useState("open"),k=S.useState("mounted"),w=S.useState("trackCursorAxis"),A=S.useState("disableHoverablePopup"),R=S.useState("floatingRootContext"),I=S.useState("instantType"),D=S.useState("transitionStatus"),j=w1({anchor:s,positionMethod:a,floatingRootContext:R,mounted:k,side:o,sideOffset:u,align:l,alignOffset:d,collisionBoundary:f,collisionPadding:h,sticky:g,arrowPadding:m,disableAnchorTracking:y,keepMounted:E,collisionAvoidance:v,adaptiveOrigin:iW}),F=x.useMemo(()=>{const M={};return(!T||w==="both"||A)&&(M.pointerEvents="none"),{role:"presentation",hidden:!k,style:{...j.positionerStyles,...M}}},[T,w,A,k,j.positionerStyles]),z=x.useMemo(()=>({open:T,side:j.side,align:j.align,anchorHidden:j.anchorHidden,instant:w!=="none"?"tracking-cursor":I}),[T,j.side,j.align,j.anchorHidden,w,I]),P=x.useMemo(()=>({...z,arrowRef:j.arrowRef,arrowStyles:j.arrowStyles,arrowUncentered:j.arrowUncentered}),[z,j.arrowRef,j.arrowStyles,j.arrowUncentered]),L=an("div",t,{state:z,props:[F,Jm(D),_],ref:[n,S.useStateSetter("positionerElement")],stateAttributesMapping:Po});return c.jsx(bwe.Provider,{value:P,children:L})}),vWe={...Po,...ll},xWe=x.forwardRef(function(t,n){const{className:r,render:i,...s}=t,a=kC(),{side:o,align:l}=ywe(),u=a.useState("open"),d=a.useState("mounted"),f=a.useState("instantType"),h=a.useState("transitionStatus"),m=a.useState("popupProps"),g=a.useState("payload"),y=a.useState("popupElement"),v=a.useState("positionerElement"),_=a.useState("floatingRootContext"),S=Of();Sa({open:u,ref:a.context.popupRef,onComplete(){u&&a.context.onOpenChangeComplete?.(!0)}});function E(){_.context.events.emit("measure-layout")}function T(D,j){_.context.events.emit("measure-layout-complete",{previousDimensions:D,nextDimensions:j})}const k=x.useCallback(()=>a.context.triggerElements.size>1,[a]);swe({popupElement:y,positionerElement:v,mounted:d,content:g,enabled:k,onMeasureLayout:E,onMeasureLayoutComplete:T,side:o,direction:S});const w=a.useState("disabled"),A=a.useState("closeDelay");QV(_,{enabled:!w,closeDelay:A});const R=x.useMemo(()=>({open:u,side:o,align:l,instant:f,transitionStatus:h}),[u,o,l,f,h]);return an("div",t,{state:R,ref:[n,a.context.popupRef,a.useStateSetter("popupElement")],props:[m,Jm(h),s],stateAttributesMapping:vWe})}),_We=x.forwardRef(function(t,n){const{className:r,render:i,...s}=t,o=kC().useState("instantType"),{open:l,arrowRef:u,side:d,align:f,arrowUncentered:h,arrowStyles:m}=ywe(),g=x.useMemo(()=>({open:l,side:d,align:f,uncentered:h,instant:o}),[l,d,f,h,o]);return an("div",t,{state:g,ref:[n,u],props:[{style:m,"aria-hidden":!0},s],stateAttributesMapping:Po})}),SWe=function(t){const{delay:n,closeDelay:r,timeout:i=400}=t,s=x.useMemo(()=>({delay:n,closeDelay:r}),[n,r]),a=x.useMemo(()=>({open:n,close:r}),[n,r]);return c.jsx(mwe.Provider,{value:s,children:c.jsx(gFe,{delay:a,timeoutMs:i,children:t.children})})};function wWe(e){return an(e.defaultTagName??"div",e,e)}function EWe({className:e,...t}){return c.jsx("div",{"data-slot":"input-group",role:"group",className:Ae("border-input bg-input/20 dark:bg-input/30 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/30 has-[[data-slot=input-group-control]:focus-visible]:ring-inset has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[[data-slot][aria-invalid=true]]:ring-inset h-7 rounded-md border transition-colors has-data-[align=block-end]:rounded-md has-data-[align=block-start]:rounded-md has-[[data-slot=input-group-control]:focus-visible]:ring-[2px] has-[[data-slot][aria-invalid=true]]:ring-[2px] has-[textarea]:rounded-md has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5 [[data-slot=combobox-content]_&]:focus-within:border-inherit [[data-slot=combobox-content]_&]:focus-within:ring-0 group/input-group relative flex w-full min-w-0 items-center outline-none has-[>textarea]:h-auto",e),...t})}const CWe=Ym("text-muted-foreground **:data-[slot=kbd]:bg-muted-foreground/10 h-auto gap-1 py-2 text-xs/relaxed font-medium group-data-[disabled=true]/input-group:opacity-50 **:data-[slot=kbd]:rounded-[calc(var(--radius-sm)-2px)] **:data-[slot=kbd]:px-1 **:data-[slot=kbd]:text-[0.625rem] [&>svg:not([class*='size-'])]:size-3.5 flex cursor-text items-center justify-center select-none",{variants:{align:{"inline-start":"pl-2 has-[>button]:ml-[-0.275rem] has-[>kbd]:ml-[-0.275rem] order-first","inline-end":"pr-2 has-[>button]:mr-[-0.275rem] has-[>kbd]:mr-[-0.275rem] order-last","block-start":"px-2 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2 order-first w-full justify-start","block-end":"px-2 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2 order-last w-full justify-start"}},defaultVariants:{align:"inline-start"}});function kWe({className:e,align:t="inline-start",...n}){return c.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":t,className:Ae(CWe({align:t}),e),onClick:r=>{r.target.closest("button")||r.currentTarget.parentElement?.querySelector("input")?.focus()},...n})}const TWe=Ym("gap-2 rounded-md text-xs/relaxed shadow-none flex items-center",{variants:{size:{xs:"h-5 gap-1 rounded-[calc(var(--radius-sm)-2px)] px-1 [&>svg:not([class*='size-'])]:size-3",sm:"","icon-xs":"size-6 p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function vwe({className:e,type:t="button",variant:n="ghost",size:r="xs",...i}){return c.jsx(_e,{type:t,"data-size":r,variant:n,className:Ae(TWe({size:r}),e),...i})}function AWe({className:e,...t}){return c.jsx(At,{"data-slot":"input-group-control",className:Ae("rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent flex-1",e),...t})}const ox=eVe;function NWe({className:e,children:t,...n}){return c.jsxs(THe,{"data-slot":"combobox-trigger",className:Ae("[&_svg:not([class*='size-'])]:size-3.5",e),...n,children:[t,c.jsx(Z,{icon:Ts,strokeWidth:2,className:"text-muted-foreground size-3.5 pointer-events-none"})]})}function OWe({className:e,...t}){return c.jsx(DHe,{"data-slot":"combobox-clear",render:c.jsx(vwe,{variant:"ghost",size:"icon-xs"}),className:Ae(e),...t,children:c.jsx(Z,{icon:Tn,strokeWidth:2,className:"pointer-events-none"})})}function lx({className:e,children:t,disabled:n=!1,showTrigger:r=!0,showClear:i=!1,...s}){return c.jsxs(EWe,{className:Ae("w-auto",e),children:[c.jsx(RHe,{render:c.jsx(AWe,{disabled:n}),...s}),c.jsxs(kWe,{align:"inline-end",children:[r&&c.jsx(vwe,{size:"icon-xs",variant:"ghost",render:c.jsx(NWe,{}),"data-slot":"input-group-button",className:"group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent",disabled:n}),i&&c.jsx(OWe,{disabled:n})]}),t]})}function cx({className:e,side:t="bottom",sideOffset:n=6,align:r="start",alignOffset:i=0,anchor:s,...a}){return c.jsx(BHe,{children:c.jsx($He,{side:t,sideOffset:n,align:r,alignOffset:i,anchor:s,className:"isolate z-50",children:c.jsx(UHe,{"data-slot":"combobox-content","data-chips":!!s,className:Ae("bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 *:data-[slot=input-group]:bg-input/20 dark:bg-popover max-h-72 min-w-32 overflow-hidden rounded-lg shadow-md ring-1 duration-100 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-7 *:data-[slot=input-group]:border-none *:data-[slot=input-group]:shadow-none group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) data-[chips=true]:min-w-(--anchor-width)",e),...a})})})}function ux({className:e,...t}){return c.jsx(MHe,{"data-slot":"combobox-list",className:Ae("no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto p-1 data-empty:p-0 overflow-y-auto overscroll-contain",e),...t})}function Rh({className:e,children:t,...n}){return c.jsxs(KHe,{"data-slot":"combobox-item",className:Ae("data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground min-h-7 gap-2 rounded-md px-2 py-1 text-xs/relaxed [&_svg:not([class*='size-'])]:size-3.5 relative flex w-full cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",e),...n,children:[t,c.jsx(tVe,{render:c.jsx("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center"}),children:c.jsx(Z,{icon:hr,strokeWidth:2,className:"pointer-events-none"})})]})}function kE({className:e,...t}){return c.jsx(VHe,{"data-slot":"combobox-group",className:Ae(e),...t})}function TE({className:e,...t}){return c.jsx(WHe,{"data-slot":"combobox-label",className:Ae("text-muted-foreground px-2 py-1.5 text-xs",e),...t})}function dx({className:e,...t}){return c.jsx(YHe,{"data-slot":"combobox-empty",className:Ae("text-muted-foreground hidden w-full justify-center py-2 text-center text-xs/relaxed group-data-empty/combobox-content:flex",e),...t})}function Rse({className:e,...t}){return c.jsx(gW,{"data-slot":"combobox-separator",className:Ae("bg-border/50 -mx-1 my-1 h-px",e),...t})}const xwe=Ym("hover:text-foreground hover:bg-accent/20 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive aria-pressed:bg-accent aria-pressed:text-accent-foreground aria-pressed:hover:bg-accent data-[state=on]:bg-accent data-[state=on]:text-accent-foreground data-[state=on]:hover:bg-accent gap-1 rounded-md text-xs font-medium transition-all [&_svg:not([class*='size-'])]:size-3.5 group/toggle inline-flex items-center justify-center whitespace-nowrap outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",{variants:{variant:{default:"bg-transparent",outline:"border-input hover:bg-accent/20 border bg-transparent"},size:{default:"h-7 min-w-7 px-2",sm:"h-6 min-w-6 rounded-[min(var(--radius-md),8px)] px-1.5 text-[0.625rem] [&_svg:not([class*='size-'])]:size-3",lg:"h-8 min-w-8 px-2"}},defaultVariants:{variant:"default",size:"default"}});function RWe({className:e,variant:t="default",size:n="default",...r}){return c.jsx(hwe,{"data-slot":"toggle",className:Ae(xwe({variant:t,size:n,className:e})),...r})}const _we=x.createContext({size:"default",variant:"default",spacing:0,orientation:"horizontal"});function AE({className:e,variant:t,size:n,spacing:r=0,orientation:i="horizontal",children:s,...a}){return c.jsx(lWe,{"data-slot":"toggle-group","data-variant":t,"data-size":n,"data-spacing":r,"data-orientation":i,style:{"--gap":r},className:Ae("rounded-md data-[size=sm]:rounded-[min(var(--radius-md),8px)] group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch",e),...a,children:c.jsx(_we.Provider,{value:{variant:t,size:n,spacing:r,orientation:i},children:s})})}function Ih({className:e,children:t,variant:n="default",size:r="default",...i}){const s=x.useContext(_we);return c.jsx(hwe,{"data-slot":"toggle-group-item","data-variant":s.variant||n,"data-size":s.size||r,"data-spacing":s.spacing,className:Ae("group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-md group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-md group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-md group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-md shrink-0 focus:z-10 focus-visible:z-10 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",xwe({variant:s.variant||n,size:s.size||r}),e),...i,children:t})}const Io={claude:"Claude Code",opencode:"OpenCode"},Swe={claude:"npm install -g @anthropic-ai/claude-code",opencode:"npm install -g opencode-ai@latest"},wwe={claude:"https://docs.anthropic.com/en/docs/claude-code/overview",opencode:"https://opencode.ai/docs/"};function TC(e){return e?e.type==="scratch"?"scratch":e.type==="worktree"||e.worktreePath||e.repoPath||e.repositoryId?"worktree":"manual":"manual"}function Ewe(e){return`var(--type-${TC(e)})`}function Xr({className:e,size:t="default",...n}){return c.jsx(iWe,{"data-slot":"switch","data-size":t,className:Ae("data-checked:bg-primary data-unchecked:bg-input focus-visible:border-ring focus-visible:ring-ring/30 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 dark:data-unchecked:bg-input/80 shrink-0 rounded-full border border-transparent focus-visible:ring-[2px] aria-invalid:ring-[2px] data-[size=default]:h-[16.6px] data-[size=default]:w-[28px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] peer group/switch relative inline-flex items-center transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 data-disabled:cursor-not-allowed data-disabled:opacity-50",e),...n,children:c.jsx(sWe,{"data-slot":"switch-thumb",className:"bg-background dark:data-unchecked:bg-foreground dark:data-checked:bg-primary-foreground rounded-full group-data-[size=default]/switch:size-3.5 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 pointer-events-none block ring-0 transition-transform"})})}async function ht(e,t){const n=await fetch(e,{...t,headers:{"Content-Type":"application/json",...t?.headers}});if(!n.ok){const r=await n.json().catch(()=>({error:"Request failed"}));throw new Error(r.error||"Request failed")}return n.json()}const jo="";function cl(){return Jt({queryKey:["tasks"],queryFn:()=>ht(`${jo}/api/tasks`)})}function Cwe(e){return Jt({queryKey:["tasks",e],queryFn:()=>ht(`${jo}/api/tasks/${e}`),enabled:!!e})}function IWe(){const e=It();return wt({mutationFn:t=>ht(`${jo}/api/tasks`,{method:"POST",body:JSON.stringify({...t,status:t.status??"IN_PROGRESS"})}),onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),e.invalidateQueries({queryKey:["task-dependencies"]}),e.invalidateQueries({queryKey:["repositories"]})}})}function kwe(){const e=It();return wt({mutationFn:({taskId:t,status:n,position:r})=>ht(`${jo}/api/tasks/${t}/status`,{method:"PATCH",body:JSON.stringify({status:n,position:r})}),onMutate:async({taskId:t,status:n,position:r})=>{await e.cancelQueries({queryKey:["tasks"]});const i=e.getQueryData(["tasks"]);return e.setQueryData(["tasks"],s=>s?.map(a=>a.id===t?{...a,status:n,position:r}:a)),{previous:i}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(["tasks"],r.previous)},onSettled:()=>{e.invalidateQueries({queryKey:["tasks"]}),e.invalidateQueries({queryKey:["task-dependencies"]})}})}function AC(){const e=It();return wt({mutationFn:({taskId:t,updates:n})=>ht(`${jo}/api/tasks/${t}`,{method:"PATCH",body:JSON.stringify(n)}),onSuccess:(t,{taskId:n})=>{e.invalidateQueries({queryKey:["tasks"]}),e.invalidateQueries({queryKey:["tasks",n]}),e.invalidateQueries({queryKey:["task-dependencies"]}),e.invalidateQueries({queryKey:["projects"]})}})}function DWe(){const e=It();return wt({mutationFn:({taskId:t,deleteLinkedWorktree:n})=>{const r=n?`${jo}/api/tasks/${t}?deleteLinkedWorktree=true`:`${jo}/api/tasks/${t}`;return ht(r,{method:"DELETE"})},onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),e.invalidateQueries({queryKey:["worktrees"]})}})}function jWe(){const e=It();return wt({mutationFn:({ids:t,deleteLinkedWorktrees:n})=>ht(`${jo}/api/tasks/bulk`,{method:"DELETE",body:JSON.stringify({ids:t,deleteLinkedWorktrees:n})}),onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),e.invalidateQueries({queryKey:["worktrees"]})}})}function PWe(){const e=It();return wt({mutationFn:({taskId:t,pinned:n})=>ht(`${jo}/api/tasks/${t}`,{method:"PATCH",body:JSON.stringify({pinned:n})}),onSuccess:(t,{taskId:n})=>{e.invalidateQueries({queryKey:["tasks"]}),e.invalidateQueries({queryKey:["tasks",n]}),e.invalidateQueries({queryKey:["worktrees"]})}})}function LWe(){const e=It();return wt({mutationFn:({taskId:t,agent:n,aiMode:r})=>ht(`${jo}/api/tasks/${t}/initialize-scratch`,{method:"POST",body:JSON.stringify({agent:n,aiMode:r})}),onSuccess:(t,{taskId:n})=>{e.invalidateQueries({queryKey:["tasks"]}),e.invalidateQueries({queryKey:["tasks",n]})}})}function Twe(){const e=It();return wt({mutationFn:({taskId:t,url:n,label:r})=>ht(`${jo}/api/tasks/${t}/links`,{method:"POST",body:JSON.stringify({url:n,label:r})}),onSuccess:(t,{taskId:n})=>{e.invalidateQueries({queryKey:["tasks"]}),e.invalidateQueries({queryKey:["tasks",n]})}})}function MWe(){const e=It();return wt({mutationFn:({taskId:t,linkId:n})=>ht(`${jo}/api/tasks/${t}/links/${n}`,{method:"DELETE"}),onSuccess:(t,{taskId:n})=>{e.invalidateQueries({queryKey:["tasks"]}),e.invalidateQueries({queryKey:["tasks",n]})}})}function Awe(){return Jt({queryKey:["task-dependencies","graph"],queryFn:()=>ht(`${jo}/api/task-dependencies/graph`)})}function FWe(e){return Jt({queryKey:["task-dependencies",e],queryFn:()=>ht(`${jo}/api/task-dependencies/${e}`),enabled:!!e})}function BWe(){const e=It();return wt({mutationFn:({taskId:t,dependsOnTaskId:n})=>ht(`${jo}/api/task-dependencies/${t}`,{method:"POST",body:JSON.stringify({dependsOnTaskId:n})}),onSuccess:(t,{taskId:n})=>{e.invalidateQueries({queryKey:["task-dependencies"]}),e.invalidateQueries({queryKey:["tasks",n]})}})}function $We(){const e=It();return wt({mutationFn:({taskId:t,dependencyId:n})=>ht(`${jo}/api/task-dependencies/${t}/${n}`,{method:"DELETE"}),onSuccess:(t,{taskId:n})=>{e.invalidateQueries({queryKey:["task-dependencies"]}),e.invalidateQueries({queryKey:["tasks",n]})}})}const k1="";function zWe(){return Jt({queryKey:["tags"],queryFn:()=>ht(`${k1}/api/tags`)})}function NW(e){return Jt({queryKey:["tags","search",e],queryFn:()=>ht(`${k1}/api/tags/search?q=${encodeURIComponent(e)}&limit=10`),enabled:!0})}function UWe(){const e=It();return wt({mutationFn:({projectId:t,tagId:n,name:r,color:i})=>ht(`${k1}/api/projects/${t}/tags`,{method:"POST",body:JSON.stringify({tagId:n,name:r,color:i})}),onSuccess:(t,{projectId:n})=>{e.invalidateQueries({queryKey:["projects"]}),e.invalidateQueries({queryKey:["project",n]}),e.invalidateQueries({queryKey:["tags"]})}})}function HWe(){const e=It();return wt({mutationFn:({projectId:t,tagId:n})=>ht(`${k1}/api/projects/${t}/tags/${n}`,{method:"DELETE"}),onSuccess:(t,{projectId:n})=>{e.invalidateQueries({queryKey:["projects"]}),e.invalidateQueries({queryKey:["project",n]}),e.invalidateQueries({queryKey:["tags"]})}})}function Nwe(){const e=It();return wt({mutationFn:({taskId:t,tag:n})=>ht(`${k1}/api/tasks/${t}/tags`,{method:"POST",body:JSON.stringify({tag:n})}),onSuccess:(t,{taskId:n})=>{e.invalidateQueries({queryKey:["tasks"]}),e.invalidateQueries({queryKey:["tasks",n]}),e.invalidateQueries({queryKey:["tags"]})}})}function Owe(){const e=It();return wt({mutationFn:({taskId:t,tag:n})=>ht(`${k1}/api/tasks/${t}/tags/${encodeURIComponent(n)}`,{method:"DELETE"}),onSuccess:(t,{taskId:n})=>{e.invalidateQueries({queryKey:["tasks"]}),e.invalidateQueries({queryKey:["tasks",n]}),e.invalidateQueries({queryKey:["tags"]})}})}const T1="";function VWe(e){return Jt({queryKey:["fs","list",e],queryFn:()=>{const t=e?`?path=${encodeURIComponent(e)}`:"";return ht(`${T1}/api/fs/list${t}`)},enabled:e!==null})}function OW(e){return Jt({queryKey:["git","branches",e],queryFn:()=>ht(`${T1}/api/git/branches?repo=${encodeURIComponent(e)}`),enabled:!!e})}function WWe(e,t={}){const{staged:n=!1,ignoreWhitespace:r=!1,includeUntracked:i=!1,baseBranch:s}=t;return Jt({queryKey:["git","diff",e,n,r,i,s],queryFn:()=>{const a=new URLSearchParams({path:e,...n&&{staged:"true"},...r&&{ignoreWhitespace:"true"},...i&&{includeUntracked:"true"},...s&&{baseBranch:s}});return ht(`${T1}/api/git/diff?${a}`)},enabled:!!e,refetchInterval:5e3,refetchIntervalInBackground:!1})}function qWe(e){return Jt({queryKey:["git","status",e],queryFn:()=>ht(`${T1}/api/git/status?path=${encodeURIComponent(e)}`),enabled:!!e,refetchInterval:5e3,refetchIntervalInBackground:!1})}async function Rwe(e){return ht(`${T1}/api/fs/is-git-repo?path=${encodeURIComponent(e)}`)}function GWe(e){return Jt({queryKey:["fs","stat",e],queryFn:()=>ht(`${T1}/api/fs/stat?path=${encodeURIComponent(e)}`),enabled:!!e&&e.trim().length>0})}const Qt={PORT:"server.port",TAILSCALE_HOSTNAME:"server.tailscaleHostname",WORKTREE_BASE_PATH:"worktree_base_path",SCRATCH_BASE_PATH:"scratch_base_path",HOME_DIR:"home_dir",DEFAULT_GIT_REPOS_DIR:"paths.defaultGitReposDir",EDITOR_APP:"editor.app",EDITOR_HOST:"editor.host",EDITOR_SSH_PORT:"editor.sshPort",GITHUB_PAT:"integrations.githubPat",GOOGLE_CLIENT_ID:"integrations.googleClientId",GOOGLE_CLIENT_SECRET:"integrations.googleClientSecret",DEFAULT_AGENT:"agent.defaultAgent",OPENCODE_MODEL:"agent.opencodeModel",OPENCODE_DEFAULT_AGENT:"agent.opencodeDefaultAgent",OPENCODE_PLAN_AGENT:"agent.opencodePlanAgent",AGENT_AUTO_SCROLL_TO_BOTTOM:"agent.autoScrollToBottom",CLAUDE_CODE_PATH:"agent.claudeCodePath",LANGUAGE:"appearance.language",TIMEZONE:"appearance.timezone",DEFAULT_TASK_TYPE:"tasks.defaultTaskType",START_WORKTREE_TASKS_IMMEDIATELY:"tasks.startWorktreeTasksImmediately",SCRATCH_STARTUP_SCRIPT:"tasks.scratchStartupScript",ASSISTANT_PROVIDER:"assistant.provider",ASSISTANT_MODEL:"assistant.model",ASSISTANT_OBSERVER_MODEL:"assistant.observerModel",ASSISTANT_OBSERVER_PROVIDER:"assistant.observerProvider",ASSISTANT_OBSERVER_OPENCODE_MODEL:"assistant.observerOpencodeModel",ASSISTANT_DOCUMENTS_DIR:"assistant.documentsDir",ASSISTANT_RITUALS_ENABLED:"assistant.ritualsEnabled",ASSISTANT_MORNING_RITUAL_TIME:"assistant.morningRitual.time",ASSISTANT_MORNING_RITUAL_PROMPT:"assistant.morningRitual.prompt",ASSISTANT_EVENING_RITUAL_TIME:"assistant.eveningRitual.time",ASSISTANT_EVENING_RITUAL_PROMPT:"assistant.eveningRitual.prompt",EMAIL_POLL_INTERVAL:"channels.email.pollIntervalSeconds"},tc="",KWe=7777;function Tr(e){return Jt({queryKey:["config",e],queryFn:()=>ht(`${tc}/api/config/${e}`)})}function RW(){const e=Tr(Qt.PORT);return{...e,data:e.data?.value??KWe,isDefault:e.data?.isDefault??!0}}function YWe(){const e=Tr(Qt.TAILSCALE_HOSTNAME);return{...e,data:e.data?.value??null,isDefault:e.data?.isDefault??!0}}function Iwe(){const e=Tr(Qt.WORKTREE_BASE_PATH);return{...e,data:e.data?.value??""}}function XWe(){const e=Tr(Qt.SCRATCH_BASE_PATH);return{...e,data:e.data?.value??""}}function Dwe(){const e=Tr(Qt.HOME_DIR);return{...e,data:e.data?.value??""}}function uD(){const e=Tr(Qt.DEFAULT_GIT_REPOS_DIR);return{...e,data:e.data?.value??"",isDefault:e.data?.isDefault??!0}}function dD(){const e=Tr(Qt.EDITOR_APP);return{...e,data:e.data?.value??"vscode",isDefault:e.data?.isDefault??!0}}function fD(){const e=Tr(Qt.EDITOR_HOST);return{...e,data:e.data?.value??"",isDefault:e.data?.isDefault??!0}}function hD(){const e=Tr(Qt.EDITOR_SSH_PORT);return{...e,data:e.data?.value??22,isDefault:e.data?.isDefault??!0}}function QWe(){const e=Tr(Qt.GITHUB_PAT);return{...e,data:e.data?.value??"",isDefault:e.data?.isDefault??!0}}function ZWe(){const e=Tr(Qt.GOOGLE_CLIENT_ID);return{...e,data:e.data?.value??"",isDefault:e.data?.isDefault??!0}}function JWe(){const e=Tr(Qt.GOOGLE_CLIENT_SECRET);return{...e,data:e.data?.value??"",isDefault:e.data?.isDefault??!0}}function NC(){const e=Tr(Qt.DEFAULT_AGENT);return{...e,data:e.data?.value??"claude",isDefault:e.data?.isDefault??!0}}function A1(){const e=Tr(Qt.OPENCODE_MODEL);return{...e,data:e.data?.value??null,isDefault:e.data?.isDefault??!0}}function jwe(){const e=Tr(Qt.OPENCODE_DEFAULT_AGENT);return{...e,data:e.data?.value??"build",isDefault:e.data?.isDefault??!0}}function Pwe(){const e=Tr(Qt.OPENCODE_PLAN_AGENT);return{...e,data:e.data?.value??"plan",isDefault:e.data?.isDefault??!0}}function Lwe(){const e=Tr(Qt.AGENT_AUTO_SCROLL_TO_BOTTOM);return{...e,data:e.data?.value===void 0?!0:!!e.data.value,isDefault:e.data?.isDefault??!0}}function eqe(){const e=Tr(Qt.CLAUDE_CODE_PATH);return{...e,data:e.data?.value??null,isDefault:e.data?.isDefault??!0}}function tqe(){const e=Tr(Qt.LANGUAGE);return{...e,data:e.data?.value??null,isDefault:e.data?.isDefault??!0}}function pD(){const e=Tr(Qt.TIMEZONE);return{...e,data:e.data?.value??null,isDefault:e.data?.isDefault??!0}}const nqe=new Set(["worktree","manual","scratch"]);function Mwe(){const e=Tr(Qt.DEFAULT_TASK_TYPE),t=e.data?.value,n=t&&nqe.has(t)?t:void 0;return{...e,data:n??"worktree",isDefault:e.data?.isDefault??!0}}function Fwe(){const e=Tr(Qt.START_WORKTREE_TASKS_IMMEDIATELY);return{...e,data:e.data?.value===void 0?!0:!!e.data.value,isDefault:e.data?.isDefault??!0}}function Bwe(){const e=Tr(Qt.SCRATCH_STARTUP_SCRIPT);return{...e,data:e.data?.value??null,isDefault:e.data?.isDefault??!0}}const Ise=["opus","sonnet","haiku"];function $we(){const e=Tr(Qt.ASSISTANT_PROVIDER);return{...e,data:e.data?.value??"claude",isDefault:e.data?.isDefault??!0}}function IW(){const e=Tr(Qt.ASSISTANT_MODEL);return{...e,data:e.data?e.data.value??"sonnet":void 0,isDefault:e.data?.isDefault??!0}}function rqe(){const e=Tr(Qt.ASSISTANT_OBSERVER_MODEL);return{...e,data:e.data?.value??"haiku",isDefault:e.data?.isDefault??!0}}function iqe(){const e=Tr(Qt.ASSISTANT_OBSERVER_PROVIDER);return{...e,data:e.data?.value??null,isDefault:e.data?.isDefault??!0}}function sqe(){const e=Tr(Qt.ASSISTANT_OBSERVER_OPENCODE_MODEL);return{...e,data:e.data?.value??null,isDefault:e.data?.isDefault??!0}}function aqe(){const e=Tr(Qt.ASSISTANT_DOCUMENTS_DIR);return{...e,data:e.data?.value??"~/.fulcrum/documents",isDefault:e.data?.isDefault??!0}}function oqe(){const e=Tr(Qt.ASSISTANT_RITUALS_ENABLED);return{...e,data:!!e.data?.value,isDefault:e.data?.isDefault??!0}}function lqe(){const e=Tr(Qt.ASSISTANT_MORNING_RITUAL_TIME);return{...e,data:e.data?.value??"09:00",isDefault:e.data?.isDefault??!0}}function cqe(){const e=Tr(Qt.ASSISTANT_MORNING_RITUAL_PROMPT);return{...e,data:e.data?.value??"",isDefault:e.data?.isDefault??!0}}function uqe(){const e=Tr(Qt.ASSISTANT_EVENING_RITUAL_TIME);return{...e,data:e.data?.value??"18:00",isDefault:e.data?.isDefault??!0}}function dqe(){const e=Tr(Qt.ASSISTANT_EVENING_RITUAL_PROMPT);return{...e,data:e.data?.value??"",isDefault:e.data?.isDefault??!0}}function DW(){const e=It();return wt({mutationFn:({key:t,value:n})=>ht(`${tc}/api/config/${t}`,{method:"PUT",body:JSON.stringify({value:n})}),onSuccess:(t,{key:n})=>{e.invalidateQueries({queryKey:["config",n]}),n===Qt.GITHUB_PAT&&(e.invalidateQueries({queryKey:["github-user"]}),e.invalidateQueries({queryKey:["github-prs"]}),e.invalidateQueries({queryKey:["github-issues"]}),e.invalidateQueries({queryKey:["github-orgs"]}))}})}function fqe(){const e=It();return wt({mutationFn:t=>ht(`${tc}/api/config/${t}`,{method:"DELETE"}),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["config",n]})}})}class zwe extends Error{current;constructor(t,n){super(t),this.name="NotificationSettingsConflictError",this.current=n}}function hqe(){return Jt({queryKey:["config","notifications"],queryFn:()=>ht(`${tc}/api/config/notifications`)})}function pqe(){const e=It();return wt({mutationFn:async t=>{const n=await fetch(`${tc}/api/config/notifications`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await n.json();if(n.status===409)throw new zwe(r.error||"Settings changed by another client",r.current);if(!n.ok)throw new Error(r.error||"Failed to update notification settings");return r},onSuccess:()=>{e.invalidateQueries({queryKey:["config","notifications"]})}})}function mqe(){return wt({mutationFn:e=>ht(`${tc}/api/config/notifications/test/${e}`,{method:"POST"})})}function gqe(){return Jt({queryKey:["config","z-ai"],queryFn:()=>ht(`${tc}/api/config/z-ai`)})}function bqe(){const e=It();return wt({mutationFn:t=>ht(`${tc}/api/config/z-ai`,{method:"PUT",body:JSON.stringify(t)}),onSuccess:()=>{e.invalidateQueries({queryKey:["config","z-ai"]}),e.invalidateQueries({queryKey:["monitoring","claude-usage"]})}})}function yqe(){return Jt({queryKey:["config","developer-mode"],queryFn:()=>ht(`${tc}/api/config/developer-mode`),staleTime:1/0})}function vqe(){return wt({mutationFn:()=>ht(`${tc}/api/config/restart`,{method:"POST"})})}function xqe(){const e=Jt({queryKey:["health"],queryFn:()=>ht(`${tc}/health`),staleTime:1/0});return{...e,version:e.data?.version??null,uptime:e.data?.uptime??null}}const _qe=7200*1e3;function Sqe(){return Jt({queryKey:["version-check"],queryFn:()=>ht(`${tc}/api/version/check`),staleTime:_qe,refetchOnWindowFocus:!1})}function wqe(){const e=It();return wt({mutationFn:()=>ht(`${tc}/api/version/check?force=1`),onSuccess:t=>{e.setQueryData(["version-check"],t)}})}function Eqe(){return wt({mutationFn:()=>ht(`${tc}/api/version/update`,{method:"POST"})})}const mD="";function Oy(){return Jt({queryKey:["repositories"],queryFn:()=>ht(`${mD}/api/repositories`)})}function Cqe(e){return Jt({queryKey:["repositories",e],queryFn:()=>ht(`${mD}/api/repositories/${e}`),enabled:!!e})}function kqe(){const e=It();return wt({mutationFn:({id:t,updates:n})=>ht(`${mD}/api/repositories/${t}`,{method:"PATCH",body:JSON.stringify(n)}),onSuccess:(t,{id:n})=>{e.invalidateQueries({queryKey:["repositories"]}),e.invalidateQueries({queryKey:["repositories",n]}),e.invalidateQueries({queryKey:["projects"]})}})}function Tqe(){const e=It();return wt({mutationFn:({id:t,deleteDirectory:n=!1,deleteApp:r=!1})=>{const i=new URLSearchParams;n&&i.set("deleteDirectory","true"),r&&i.set("deleteApp","true");const s=i.toString();return ht(`${mD}/api/repositories/${t}${s?`?${s}`:""}`,{method:"DELETE"})},onSuccess:()=>{e.invalidateQueries({queryKey:["repositories"]}),e.invalidateQueries({queryKey:["apps"]})}})}const Mu="";function Mc(){return Jt({queryKey:["projects"],queryFn:()=>ht(`${Mu}/api/projects`)})}function Aqe(e){return Jt({queryKey:["projects",e],queryFn:()=>ht(`${Mu}/api/projects/${e}`),enabled:!!e})}function Uwe(){const e=It();return wt({mutationFn:t=>ht(`${Mu}/api/projects`,{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),e.invalidateQueries({queryKey:["repositories"]})}})}function Hwe(){const e=It();return wt({mutationFn:async({projectId:t,...n})=>{const r=await fetch(`${Mu}/api/projects/${t}/repositories`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),i=await r.json();if(!r.ok){if(r.status===409){const s=new Error(i.error);throw s.conflict=i,s}throw new Error(i.error||"Failed to add repository")}return i},onSuccess:(t,{projectId:n})=>{e.invalidateQueries({queryKey:["projects"]}),e.invalidateQueries({queryKey:["projects",n]}),e.invalidateQueries({queryKey:["repositories"]})}})}function Nqe(){const e=It();return wt({mutationFn:async({projectId:t,repositoryId:n,deleteRecord:r=!1})=>ht(`${Mu}/api/projects/${t}/repositories/${n}${r?"?deleteRecord=true":""}`,{method:"DELETE"}),onSuccess:(t,{projectId:n})=>{e.invalidateQueries({queryKey:["projects"]}),e.invalidateQueries({queryKey:["projects",n]}),e.invalidateQueries({queryKey:["repositories"]})}})}function Vwe(){const e=It();return wt({mutationFn:({id:t,updates:n})=>ht(`${Mu}/api/projects/${t}`,{method:"PATCH",body:JSON.stringify(n)}),onSuccess:(t,{id:n})=>{e.invalidateQueries({queryKey:["projects"]}),e.invalidateQueries({queryKey:["projects",n]})}})}function Wwe(){const e=It();return wt({mutationFn:({id:t,deleteDirectory:n=!1,deleteApp:r=!1})=>{const i=new URLSearchParams;n&&i.set("deleteDirectory","true"),r&&i.set("deleteApp","true");const s=`${Mu}/api/projects/${t}${i.toString()?`?${i}`:""}`;return ht(s,{method:"DELETE"})},onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:["projects"]}),e.invalidateQueries({queryKey:["repositories"]}),e.invalidateQueries({queryKey:["apps"]})])}})}function Oqe(){const e=It();return wt({mutationFn:t=>ht(`${Mu}/api/projects/${t}/access`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]})}})}function Rqe(){return wt({mutationFn:e=>ht(`${Mu}/api/projects/scan`,{method:"POST",body:JSON.stringify(e?{directory:e}:{})})})}function Iqe(){const e=It();return wt({mutationFn:t=>ht(`${Mu}/api/projects/bulk`,{method:"POST",body:JSON.stringify({repositories:t})}),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),e.invalidateQueries({queryKey:["repositories"]})}})}function Dqe(){const e=It();return wt({mutationFn:({projectId:t,url:n,label:r})=>ht(`${Mu}/api/projects/${t}/links`,{method:"POST",body:JSON.stringify({url:n,label:r})}),onSuccess:(t,{projectId:n})=>{e.invalidateQueries({queryKey:["projects"]}),e.invalidateQueries({queryKey:["projects",n]})}})}function jqe(){const e=It();return wt({mutationFn:({projectId:t,linkId:n})=>ht(`${Mu}/api/projects/${t}/links/${n}`,{method:"DELETE"}),onSuccess:(t,{projectId:n})=>{e.invalidateQueries({queryKey:["projects"]}),e.invalidateQueries({queryKey:["projects",n]})}})}function hp({className:e,children:t,...n}){return c.jsxs(GVe,{"data-slot":"scroll-area",className:Ae("relative",e),...n,children:[c.jsx(ZVe,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),c.jsx(Pqe,{}),c.jsx(nWe,{})]})}function Pqe({className:e,orientation:t="vertical",...n}){return c.jsx(eWe,{"data-slot":"scroll-area-scrollbar","data-orientation":t,orientation:t,className:Ae("data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent flex touch-none p-px transition-colors select-none",e),...n,children:c.jsx(tWe,{"data-slot":"scroll-area-thumb",className:"rounded-full bg-border relative flex-1"})})}function yh({open:e,onOpenChange:t,onSelect:n,initialPath:r}){const[i,s]=x.useState(r||null),[a,o]=x.useState(""),[l,u]=x.useState("");x.useEffect(()=>{e&&(s(r||null),o(""),u(""))},[e,r]);const{data:d,isLoading:f,error:h}=VWe(e?i??"":null),m=E=>{d&&(s(d.path+"/"+E),u(""))},g=()=>{d?.parent&&d.parent!==d.path&&(s(d.parent),u(""))},y=()=>{s(null),u("")},v=()=>{a.trim()&&(s(a.trim()),u(""))},_=E=>{n(E),t(!1)},S=d?.entries.filter(E=>E.name.toLowerCase().includes(l.toLowerCase()));return c.jsx(Ya,{open:e,onOpenChange:t,children:c.jsxs(Xa,{className:"sm:max-w-lg overflow-x-hidden max-w-[calc(100vw-2rem)]",children:[c.jsxs(Lo,{children:[c.jsx(Mo,{children:"Select Git Repository"}),c.jsx(eg,{children:"Choose an existing git repository"})]}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Click folder names to navigate • Use action buttons to select"}),c.jsx(LUe,{}),c.jsxs("div",{className:"space-y-1 min-w-0",children:[c.jsx("label",{className:"text-xs font-medium",children:"Enter path manually:"}),c.jsxs("div",{className:"flex gap-2 min-w-0",children:[c.jsx(At,{value:a,onChange:E=>o(E.target.value),placeholder:"/path/to/your/project",onKeyDown:E=>E.key==="Enter"&&v(),className:"flex-1 min-w-0"}),c.jsx(_e,{variant:"outline",size:"sm",onClick:v,className:"shrink-0",children:"Go"})]})]}),c.jsxs("div",{className:"space-y-1 min-w-0",children:[c.jsx("label",{className:"text-xs font-medium",children:"Search current directory:"}),c.jsxs("div",{className:"relative",children:[c.jsx(Z,{icon:cp,size:14,strokeWidth:2,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),c.jsx(At,{value:l,onChange:E=>u(E.target.value),placeholder:"Filter folders and files...",className:"pl-8"})]})]}),c.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c.jsx(_e,{variant:"outline",size:"icon-sm",onClick:y,title:"Home",className:"shrink-0",children:c.jsx(Z,{icon:nze,size:14,strokeWidth:2})}),c.jsx(_e,{variant:"outline",size:"icon-sm",onClick:g,disabled:!d||d.parent===d.path,title:"Parent directory",className:"shrink-0",children:c.jsx(Z,{icon:wd,size:14,strokeWidth:2})}),c.jsx("code",{className:"min-w-0 flex-1 text-xs bg-muted/50 px-2 py-1 rounded truncate overflow-hidden",children:d?.path||"~"}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>d&&_(d.path),disabled:!d,className:"shrink-0 max-sm:px-2",title:"Select current directory",children:[c.jsx(Z,{icon:y$,size:14,strokeWidth:2,className:"sm:hidden"}),c.jsx("span",{className:"max-sm:hidden",children:"Select Current"})]})]}),c.jsx(hp,{className:"h-64 border rounded-md min-w-0",children:c.jsxs("div",{className:"p-1 min-w-0",children:[f&&c.jsx("div",{className:"text-muted-foreground text-xs p-3",children:"Loading..."}),h&&c.jsx("div",{className:"text-destructive text-xs p-3",children:h.message}),d&&S&&c.jsxs(c.Fragment,{children:[S.length===0&&c.jsx("div",{className:"text-muted-foreground text-xs p-3",children:l?"No matches found":"Empty directory"}),S.map(E=>c.jsx("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded hover:bg-muted group min-w-0",children:E.type==="directory"?c.jsxs(c.Fragment,{children:[c.jsx(Z,{icon:E.isGitRepo?y$:Zs,size:16,strokeWidth:2,className:"text-accent shrink-0"}),c.jsx("button",{onClick:()=>m(E.name),className:"flex-1 text-left text-xs truncate hover:underline min-w-0",children:E.name}),E.isGitRepo&&c.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded border border-accent/50 text-accent font-medium shrink-0",children:[c.jsx("span",{className:"max-sm:hidden",children:"git repo"}),c.jsx("span",{className:"sm:hidden",children:"git"})]})]}):c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"w-4 shrink-0"}),c.jsx("span",{className:"flex-1 text-xs text-muted-foreground truncate min-w-0",children:E.name})]})},E.name))]})]})}),c.jsxs(wC,{children:[c.jsx(SC,{render:c.jsx(_e,{variant:"outline"}),children:"Cancel"}),c.jsx(_e,{onClick:()=>d&&_(d.path),disabled:!d,children:"Select Path"})]})]})})}function Lqe(e,t,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(" ")}const Mqe={},uw={};function _b(e,t){try{const r=(Mqe[e]||=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).format)(t).split("GMT")[1];return r in uw?uw[r]:Dse(r,r.split(":"))}catch{if(e in uw)return uw[e];const n=e?.match(Fqe);return n?Dse(e,n.slice(1)):NaN}}const Fqe=/([+-]\d\d):?(\d\d)?/;function Dse(e,t){const n=+(t[0]||0),r=+(t[1]||0),i=+(t[2]||0)/60;return uw[e]=n*60+r>0?n*60+r+i:n*60-r-i}class tf extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(_b(this.timeZone,this))?this.setTime(NaN):t.length?typeof t[0]=="number"&&(t.length===1||t.length===2&&typeof t[1]!="number")?this.setTime(t[0]):typeof t[0]=="string"?this.setTime(+new Date(t[0])):t[0]instanceof Date?this.setTime(+t[0]):(this.setTime(+new Date(...t)),qwe(this),w$(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new tf(...n,t):new tf(Date.now(),t)}withTimeZone(t){return new tf(+this,t)}getTimezoneOffset(){const t=-_b(this.timeZone,this);return t>0?Math.floor(t):Math.ceil(t)}setTime(t){return Date.prototype.setTime.apply(this,arguments),w$(this),+this}[Symbol.for("constructDateFrom")](t){return new tf(+new Date(t),this.timeZone)}}const jse=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!jse.test(e))return;const t=e.replace(jse,"$1UTC");tf.prototype[t]&&(e.startsWith("get")?tf.prototype[e]=function(){return this.internal[t]()}:(tf.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),Bqe(this),+this},tf.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),w$(this),+this}))});function w$(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-_b(e.timeZone,e)*60))}function Bqe(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),qwe(e)}function qwe(e){const t=_b(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),r=new Date(+e);r.setUTCHours(r.getUTCHours()-1);const i=-new Date(+e).getTimezoneOffset(),s=-new Date(+r).getTimezoneOffset(),a=i-s,o=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();a&&o&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+a);const l=i-n;l&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+l);const u=new Date(+e);u.setUTCSeconds(0);const d=i>0?u.getSeconds():(u.getSeconds()-60)%60,f=Math.round(-(_b(e.timeZone,e)*60))%60;(f||d)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+f),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+f+d));const h=_b(e.timeZone,e),m=h>0?Math.floor(h):Math.ceil(h),y=-new Date(+e).getTimezoneOffset()-m,v=m!==n,_=y-l;if(v&&_){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+_);const S=_b(e.timeZone,e),E=S>0?Math.floor(S):Math.ceil(S),T=m-E;T&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+T),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+T))}}class ko extends tf{static tz(t,...n){return n.length?new ko(...n,t):new ko(Date.now(),t)}toISOString(){const[t,n,r]=this.tzComponents(),i=`${t}${n}:${r}`;return this.internal.toISOString().slice(0,-1)+i}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[t,n,r,i]=this.internal.toUTCString().split(" ");return`${t?.slice(0,-1)} ${r} ${n} ${i}`}toTimeString(){const t=this.internal.toUTCString().split(" ")[4],[n,r,i]=this.tzComponents();return`${t} GMT${n}${r}${i} (${Lqe(this.timeZone,this)})`}toLocaleString(t,n){return Date.prototype.toLocaleString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleDateString(t,n){return Date.prototype.toLocaleDateString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleTimeString(t,n){return Date.prototype.toLocaleTimeString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}tzComponents(){const t=this.getTimezoneOffset(),n=t>0?"-":"+",r=String(Math.floor(Math.abs(t)/60)).padStart(2,"0"),i=String(Math.abs(t)%60).padStart(2,"0");return[n,r,i]}withTimeZone(t){return new ko(+this,t)}[Symbol.for("constructDateFrom")](t){return new ko(+new Date(t),this.timeZone)}}const Gwe=6048e5,$qe=864e5,CA=43200,Pse=1440,Lse=Symbol.for("constructDateFrom");function Fs(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&Lse in e?e[Lse](t):e instanceof Date?new e.constructor(t):new Date(t)}function Dr(e,t){return Fs(t||e,e)}function Kwe(e,t,n){const r=Dr(e,n?.in);return isNaN(t)?Fs(e,NaN):(t&&r.setDate(r.getDate()+t),r)}function Ywe(e,t,n){const r=Dr(e,n?.in);if(isNaN(t))return Fs(e,NaN);if(!t)return r;const i=r.getDate(),s=Fs(e,r.getTime());s.setMonth(r.getMonth()+t+1,0);const a=s.getDate();return i>=a?s:(r.setFullYear(s.getFullYear(),s.getMonth(),i),r)}let zqe={};function N1(){return zqe}function fx(e,t){const n=N1(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=Dr(e,t?.in),s=i.getDay(),a=(s<r?7:0)+s-r;return i.setDate(i.getDate()-a),i.setHours(0,0,0,0),i}function NE(e,t){return fx(e,{...t,weekStartsOn:1})}function Xwe(e,t){const n=Dr(e,t?.in),r=n.getFullYear(),i=Fs(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);const s=NE(i),a=Fs(n,0);a.setFullYear(r,0,4),a.setHours(0,0,0,0);const o=NE(a);return n.getTime()>=s.getTime()?r+1:n.getTime()>=o.getTime()?r:r-1}function KO(e){const t=Dr(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function ng(e,...t){const n=Fs.bind(null,e||t.find(r=>typeof r=="object"));return t.map(n)}function OE(e,t){const n=Dr(e,t?.in);return n.setHours(0,0,0,0),n}function jW(e,t,n){const[r,i]=ng(n?.in,e,t),s=OE(r),a=OE(i),o=+s-KO(s),l=+a-KO(a);return Math.round((o-l)/$qe)}function Uqe(e,t){const n=Xwe(e,t),r=Fs(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),NE(r)}function Hqe(e,t,n){return Kwe(e,t*7,n)}function Vqe(e,t,n){return Ywe(e,t*12,n)}function Wqe(e,t){let n,r=t?.in;return e.forEach(i=>{!r&&typeof i=="object"&&(r=Fs.bind(null,i));const s=Dr(i,r);(!n||n<s||isNaN(+s))&&(n=s)}),Fs(r,n||NaN)}function qqe(e,t){let n,r=t?.in;return e.forEach(i=>{!r&&typeof i=="object"&&(r=Fs.bind(null,i));const s=Dr(i,r);(!n||n>s||isNaN(+s))&&(n=s)}),Fs(r,n||NaN)}function UN(e,t){const n=+Dr(e)-+Dr(t);return n<0?-1:n>0?1:n}function Gqe(e){return Fs(e,Date.now())}function Kqe(e,t,n){const[r,i]=ng(n?.in,e,t);return+OE(r)==+OE(i)}function Qwe(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Yqe(e){return!(!Qwe(e)&&typeof e!="number"||isNaN(+Dr(e)))}function PW(e,t,n){const[r,i]=ng(n?.in,e,t),s=r.getFullYear()-i.getFullYear(),a=r.getMonth()-i.getMonth();return s*12+a}function Xqe(e){return t=>{const r=(e?Math[e]:Math.trunc)(t);return r===0?0:r}}function Qqe(e,t){return+Dr(e)-+Dr(t)}function Zqe(e,t){const n=Dr(e,t?.in);return n.setHours(23,59,59,999),n}function Zwe(e,t){const n=Dr(e,t?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function Jqe(e,t){const n=Dr(e,t?.in);return+Zqe(n,t)==+Zwe(n,t)}function eGe(e,t,n){const[r,i,s]=ng(n?.in,e,e,t),a=UN(i,s),o=Math.abs(PW(i,s));if(o<1)return 0;i.getMonth()===1&&i.getDate()>27&&i.setDate(30),i.setMonth(i.getMonth()-a*o);let l=UN(i,s)===-a;Jqe(r)&&o===1&&UN(r,s)===1&&(l=!1);const u=a*(o-+l);return u===0?0:u}function tGe(e,t,n){const r=Qqe(e,t)/1e3;return Xqe(n?.roundingMethod)(r)}function Jwe(e,t){const[n,r]=ng(e,t.start,t.end);return{start:n,end:r}}function nGe(e,t){const{start:n,end:r}=Jwe(t?.in,e);let i=+n>+r;const s=i?+n:+r,a=i?r:n;a.setHours(0,0,0,0),a.setDate(1);let o=1;const l=[];for(;+a<=s;)l.push(Fs(n,a)),a.setMonth(a.getMonth()+o);return i?l.reverse():l}function rGe(e,t){const n=Dr(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function iGe(e,t){const n=Dr(e,t?.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function eEe(e,t){const n=Dr(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function sGe(e,t){const{start:n,end:r}=Jwe(t?.in,e);let i=+n>+r;const s=i?+n:+r,a=i?r:n;a.setHours(0,0,0,0),a.setMonth(0,1);let o=1;const l=[];for(;+a<=s;)l.push(Fs(n,a)),a.setFullYear(a.getFullYear()+o);return i?l.reverse():l}function tEe(e,t){const n=N1(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=Dr(e,t?.in),s=i.getDay(),a=(s<r?-7:0)+6-(s-r);return i.setDate(i.getDate()+a),i.setHours(23,59,59,999),i}function aGe(e,t){return tEe(e,{...t,weekStartsOn:1})}const oGe={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},lGe=(e,t,n)=>{let r;const i=oGe[e];return typeof i=="string"?r=i:t===1?r=i.one:r=i.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function n4(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const cGe={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},uGe={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},dGe={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},fGe={date:n4({formats:cGe,defaultWidth:"full"}),time:n4({formats:uGe,defaultWidth:"full"}),dateTime:n4({formats:dGe,defaultWidth:"full"})},hGe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},pGe=(e,t,n,r)=>hGe[e];function wS(e){return(t,n)=>{const r=n?.context?String(n.context):"standalone";let i;if(r==="formatting"&&e.formattingValues){const a=e.defaultFormattingWidth||e.defaultWidth,o=n?.width?String(n.width):a;i=e.formattingValues[o]||e.formattingValues[a]}else{const a=e.defaultWidth,o=n?.width?String(n.width):e.defaultWidth;i=e.values[o]||e.values[a]}const s=e.argumentCallback?e.argumentCallback(t):t;return i[s]}}const mGe={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},gGe={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},bGe={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},yGe={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},vGe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},xGe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},_Ge=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},SGe={ordinalNumber:_Ge,era:wS({values:mGe,defaultWidth:"wide"}),quarter:wS({values:gGe,defaultWidth:"wide",argumentCallback:e=>e-1}),month:wS({values:bGe,defaultWidth:"wide"}),day:wS({values:yGe,defaultWidth:"wide"}),dayPeriod:wS({values:vGe,defaultWidth:"wide",formattingValues:xGe,defaultFormattingWidth:"wide"})};function ES(e){return(t,n={})=>{const r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],s=t.match(i);if(!s)return null;const a=s[0],o=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(o)?EGe(o,f=>f.test(a)):wGe(o,f=>f.test(a));let u;u=e.valueCallback?e.valueCallback(l):l,u=n.valueCallback?n.valueCallback(u):u;const d=t.slice(a.length);return{value:u,rest:d}}}function wGe(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function EGe(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function CGe(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const i=r[0],s=t.match(e.parsePattern);if(!s)return null;let a=e.valueCallback?e.valueCallback(s[0]):s[0];a=n.valueCallback?n.valueCallback(a):a;const o=t.slice(i.length);return{value:a,rest:o}}}const kGe=/^(\d+)(th|st|nd|rd)?/i,TGe=/\d+/i,AGe={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},NGe={any:[/^b/i,/^(a|c)/i]},OGe={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},RGe={any:[/1/i,/2/i,/3/i,/4/i]},IGe={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},DGe={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},jGe={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},PGe={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},LGe={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},MGe={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},FGe={ordinalNumber:CGe({matchPattern:kGe,parsePattern:TGe,valueCallback:e=>parseInt(e,10)}),era:ES({matchPatterns:AGe,defaultMatchWidth:"wide",parsePatterns:NGe,defaultParseWidth:"any"}),quarter:ES({matchPatterns:OGe,defaultMatchWidth:"wide",parsePatterns:RGe,defaultParseWidth:"any",valueCallback:e=>e+1}),month:ES({matchPatterns:IGe,defaultMatchWidth:"wide",parsePatterns:DGe,defaultParseWidth:"any"}),day:ES({matchPatterns:jGe,defaultMatchWidth:"wide",parsePatterns:PGe,defaultParseWidth:"any"}),dayPeriod:ES({matchPatterns:LGe,defaultMatchWidth:"any",parsePatterns:MGe,defaultParseWidth:"any"})},cb={code:"en-US",formatDistance:lGe,formatLong:fGe,formatRelative:pGe,localize:SGe,match:FGe,options:{weekStartsOn:0,firstWeekContainsDate:1}};function BGe(e,t){const n=Dr(e,t?.in);return jW(n,eEe(n))+1}function LW(e,t){const n=Dr(e,t?.in),r=+NE(n)-+Uqe(n);return Math.round(r/Gwe)+1}function nEe(e,t){const n=Dr(e,t?.in),r=n.getFullYear(),i=N1(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,a=Fs(t?.in||e,0);a.setFullYear(r+1,0,s),a.setHours(0,0,0,0);const o=fx(a,t),l=Fs(t?.in||e,0);l.setFullYear(r,0,s),l.setHours(0,0,0,0);const u=fx(l,t);return+n>=+o?r+1:+n>=+u?r:r-1}function $Ge(e,t){const n=N1(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=nEe(e,t),s=Fs(t?.in||e,0);return s.setFullYear(i,0,r),s.setHours(0,0,0,0),fx(s,t)}function MW(e,t){const n=Dr(e,t?.in),r=+fx(n,t)-+$Ge(n,t);return Math.round(r/Gwe)+1}function ui(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const Xp={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return ui(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):ui(n+1,2)},d(e,t){return ui(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return n==="am"?"a.m.":"p.m."}},h(e,t){return ui(e.getHours()%12||12,t.length)},H(e,t){return ui(e.getHours(),t.length)},m(e,t){return ui(e.getMinutes(),t.length)},s(e,t){return ui(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),i=Math.trunc(r*Math.pow(10,n-3));return ui(i,t.length)}},Hv={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Mse={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),i=r>0?r:1-r;return n.ordinalNumber(i,{unit:"year"})}return Xp.y(e,t)},Y:function(e,t,n,r){const i=nEe(e,r),s=i>0?i:1-i;if(t==="YY"){const a=s%100;return ui(a,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):ui(s,t.length)},R:function(e,t){const n=Xwe(e);return ui(n,t.length)},u:function(e,t){const n=e.getFullYear();return ui(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return ui(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return ui(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return Xp.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return ui(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const i=MW(e,r);return t==="wo"?n.ordinalNumber(i,{unit:"week"}):ui(i,t.length)},I:function(e,t,n){const r=LW(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):ui(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):Xp.d(e,t)},D:function(e,t,n){const r=BGe(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):ui(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const i=e.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return ui(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const i=e.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return ui(s,t.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),i=r===0?7:r;switch(t){case"i":return String(i);case"ii":return ui(i,t.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const i=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let i;switch(r===12?i=Hv.noon:r===0?i=Hv.midnight:i=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let i;switch(r>=17?i=Hv.evening:r>=12?i=Hv.afternoon:r>=4?i=Hv.morning:i=Hv.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return Xp.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):Xp.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):ui(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):ui(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):Xp.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):Xp.s(e,t)},S:function(e,t){return Xp.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return Bse(r);case"XXXX":case"XX":return tb(r);default:return tb(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return Bse(r);case"xxxx":case"xx":return tb(r);default:return tb(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+Fse(r,":");default:return"GMT"+tb(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+Fse(r,":");default:return"GMT"+tb(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return ui(r,t.length)},T:function(e,t,n){return ui(+e,t.length)}};function Fse(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),i=Math.trunc(r/60),s=r%60;return s===0?n+String(i):n+String(i)+t+ui(s,2)}function Bse(e,t){return e%60===0?(e>0?"-":"+")+ui(Math.abs(e)/60,2):tb(e,t)}function tb(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),i=ui(Math.trunc(r/60),2),s=ui(r%60,2);return n+i+t+s}const $se=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},rEe=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},zGe=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return $se(e,t);let s;switch(r){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",$se(r,t)).replace("{{time}}",rEe(i,t))},UGe={p:rEe,P:zGe},HGe=/^D+$/,VGe=/^Y+$/,WGe=["D","DD","YY","YYYY"];function qGe(e){return HGe.test(e)}function GGe(e){return VGe.test(e)}function KGe(e,t,n){const r=YGe(e,t,n);if(console.warn(r),WGe.includes(e))throw new RangeError(r)}function YGe(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const XGe=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,QGe=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,ZGe=/^'([^]*?)'?$/,JGe=/''/g,eKe=/[a-zA-Z]/;function g0(e,t,n){const r=N1(),i=n?.locale??r.locale??cb,s=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,o=Dr(e,n?.in);if(!Yqe(o))throw new RangeError("Invalid time value");let l=t.match(QGe).map(d=>{const f=d[0];if(f==="p"||f==="P"){const h=UGe[f];return h(d,i.formatLong)}return d}).join("").match(XGe).map(d=>{if(d==="''")return{isToken:!1,value:"'"};const f=d[0];if(f==="'")return{isToken:!1,value:tKe(d)};if(Mse[f])return{isToken:!0,value:d};if(f.match(eKe))throw new RangeError("Format string contains an unescaped latin alphabet character `"+f+"`");return{isToken:!1,value:d}});i.localize.preprocessor&&(l=i.localize.preprocessor(o,l));const u={firstWeekContainsDate:s,weekStartsOn:a,locale:i};return l.map(d=>{if(!d.isToken)return d.value;const f=d.value;(!n?.useAdditionalWeekYearTokens&&GGe(f)||!n?.useAdditionalDayOfYearTokens&&qGe(f))&&KGe(f,t,String(e));const h=Mse[f[0]];return h(o,f,i.localize,u)}).join("")}function tKe(e){const t=e.match(ZGe);return t?t[1].replace(JGe,"'"):e}function nKe(e,t,n){const r=N1(),i=n?.locale??r.locale??cb,s=2520,a=UN(e,t);if(isNaN(a))throw new RangeError("Invalid time value");const o=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:a}),[l,u]=ng(n?.in,...a>0?[t,e]:[e,t]),d=tGe(u,l),f=(KO(u)-KO(l))/1e3,h=Math.round((d-f)/60);let m;if(h<2)return n?.includeSeconds?d<5?i.formatDistance("lessThanXSeconds",5,o):d<10?i.formatDistance("lessThanXSeconds",10,o):d<20?i.formatDistance("lessThanXSeconds",20,o):d<40?i.formatDistance("halfAMinute",0,o):d<60?i.formatDistance("lessThanXMinutes",1,o):i.formatDistance("xMinutes",1,o):h===0?i.formatDistance("lessThanXMinutes",1,o):i.formatDistance("xMinutes",h,o);if(h<45)return i.formatDistance("xMinutes",h,o);if(h<90)return i.formatDistance("aboutXHours",1,o);if(h<Pse){const g=Math.round(h/60);return i.formatDistance("aboutXHours",g,o)}else{if(h<s)return i.formatDistance("xDays",1,o);if(h<CA){const g=Math.round(h/Pse);return i.formatDistance("xDays",g,o)}else if(h<CA*2)return m=Math.round(h/CA),i.formatDistance("aboutXMonths",m,o)}if(m=eGe(u,l),m<12){const g=Math.round(h/CA);return i.formatDistance("xMonths",g,o)}else{const g=m%12,y=Math.trunc(m/12);return g<3?i.formatDistance("aboutXYears",y,o):g<9?i.formatDistance("overXYears",y,o):i.formatDistance("almostXYears",y+1,o)}}function FW(e,t){return nKe(e,Gqe(e),t)}function rKe(e,t){const n=Dr(e,t?.in),r=n.getFullYear(),i=n.getMonth(),s=Fs(n,0);return s.setFullYear(r,i+1,0),s.setHours(0,0,0,0),s.getDate()}function iKe(e,t){return Dr(e,t?.in).getMonth()}function sKe(e,t){return Dr(e,t?.in).getFullYear()}function aKe(e,t){return+Dr(e)>+Dr(t)}function oKe(e,t){return+Dr(e)<+Dr(t)}function lKe(e,t,n){const[r,i]=ng(n?.in,e,t);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()}function cKe(e,t,n){const[r,i]=ng(n?.in,e,t);return r.getFullYear()===i.getFullYear()}function uKe(e,t,n){const r=Dr(e,n?.in),i=r.getFullYear(),s=r.getDate(),a=Fs(e,0);a.setFullYear(i,t,15),a.setHours(0,0,0,0);const o=rKe(a);return r.setMonth(t,Math.min(s,o)),r}function dKe(e,t,n){const r=Dr(e,n?.in);return isNaN(+r)?Fs(e,NaN):(r.setFullYear(t),r)}const zse=5,fKe=4;function hKe(e,t){const n=t.startOfMonth(e),r=n.getDay()>0?n.getDay():7,i=t.addDays(e,-r+1),s=t.addDays(i,zse*7-1);return t.getMonth(e)===t.getMonth(s)?zse:fKe}function iEe(e,t){const n=t.startOfMonth(e),r=n.getDay();return r===1?n:r===0?t.addDays(n,-6):t.addDays(n,-1*(r-1))}function pKe(e,t){const n=iEe(e,t),r=hKe(e,t);return t.addDays(n,r*7-1)}const sEe={...cb,labels:{labelDayButton:(e,t,n,r)=>{let i;r&&typeof r.format=="function"?i=r.format.bind(r):i=(a,o)=>g0(a,o,{locale:cb,...n});let s=i(e,"PPPP");return t.today&&(s=`Today, ${s}`),t.selected&&(s=`${s}, selected`),s},labelMonthDropdown:"Choose the Month",labelNext:"Go to the Next Month",labelPrevious:"Go to the Previous Month",labelWeekNumber:e=>`Week ${e}`,labelYearDropdown:"Choose the Year",labelGrid:(e,t,n)=>{let r;return n&&typeof n.format=="function"?r=n.format.bind(n):r=(i,s)=>g0(i,s,{locale:cb,...t}),r(e,"LLLL yyyy")},labelGridcell:(e,t,n,r)=>{let i;r&&typeof r.format=="function"?i=r.format.bind(r):i=(a,o)=>g0(a,o,{locale:cb,...n});let s=i(e,"PPPP");return t?.today&&(s=`Today, ${s}`),s},labelNav:"Navigation bar",labelWeekNumberHeader:"Week Number",labelWeekday:(e,t,n)=>{let r;return n&&typeof n.format=="function"?r=n.format.bind(n):r=(i,s)=>g0(i,s,{locale:cb,...t}),r(e,"cccc")}}};class Dc{constructor(t,n){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?ko.tz(this.options.timeZone):new this.Date,this.newDate=(r,i,s)=>this.overrides?.newDate?this.overrides.newDate(r,i,s):this.options.timeZone?new ko(r,i,s,this.options.timeZone):new Date(r,i,s),this.addDays=(r,i)=>this.overrides?.addDays?this.overrides.addDays(r,i):Kwe(r,i),this.addMonths=(r,i)=>this.overrides?.addMonths?this.overrides.addMonths(r,i):Ywe(r,i),this.addWeeks=(r,i)=>this.overrides?.addWeeks?this.overrides.addWeeks(r,i):Hqe(r,i),this.addYears=(r,i)=>this.overrides?.addYears?this.overrides.addYears(r,i):Vqe(r,i),this.differenceInCalendarDays=(r,i)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(r,i):jW(r,i),this.differenceInCalendarMonths=(r,i)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(r,i):PW(r,i),this.eachMonthOfInterval=r=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(r):nGe(r),this.eachYearOfInterval=r=>{const i=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(r):sGe(r),s=new Set(i.map(o=>this.getYear(o)));if(s.size===i.length)return i;const a=[];return s.forEach(o=>{a.push(new Date(o,0,1))}),a},this.endOfBroadcastWeek=r=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(r):pKe(r,this),this.endOfISOWeek=r=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(r):aGe(r),this.endOfMonth=r=>this.overrides?.endOfMonth?this.overrides.endOfMonth(r):Zwe(r),this.endOfWeek=(r,i)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(r,i):tEe(r,this.options),this.endOfYear=r=>this.overrides?.endOfYear?this.overrides.endOfYear(r):iGe(r),this.format=(r,i,s)=>{const a=this.overrides?.format?this.overrides.format(r,i,this.options):g0(r,i,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(a):a},this.getISOWeek=r=>this.overrides?.getISOWeek?this.overrides.getISOWeek(r):LW(r),this.getMonth=(r,i)=>this.overrides?.getMonth?this.overrides.getMonth(r,this.options):iKe(r,this.options),this.getYear=(r,i)=>this.overrides?.getYear?this.overrides.getYear(r,this.options):sKe(r,this.options),this.getWeek=(r,i)=>this.overrides?.getWeek?this.overrides.getWeek(r,this.options):MW(r,this.options),this.isAfter=(r,i)=>this.overrides?.isAfter?this.overrides.isAfter(r,i):aKe(r,i),this.isBefore=(r,i)=>this.overrides?.isBefore?this.overrides.isBefore(r,i):oKe(r,i),this.isDate=r=>this.overrides?.isDate?this.overrides.isDate(r):Qwe(r),this.isSameDay=(r,i)=>this.overrides?.isSameDay?this.overrides.isSameDay(r,i):Kqe(r,i),this.isSameMonth=(r,i)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(r,i):lKe(r,i),this.isSameYear=(r,i)=>this.overrides?.isSameYear?this.overrides.isSameYear(r,i):cKe(r,i),this.max=r=>this.overrides?.max?this.overrides.max(r):Wqe(r),this.min=r=>this.overrides?.min?this.overrides.min(r):qqe(r),this.setMonth=(r,i)=>this.overrides?.setMonth?this.overrides.setMonth(r,i):uKe(r,i),this.setYear=(r,i)=>this.overrides?.setYear?this.overrides.setYear(r,i):dKe(r,i),this.startOfBroadcastWeek=(r,i)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(r,this):iEe(r,this),this.startOfDay=r=>this.overrides?.startOfDay?this.overrides.startOfDay(r):OE(r),this.startOfISOWeek=r=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(r):NE(r),this.startOfMonth=r=>this.overrides?.startOfMonth?this.overrides.startOfMonth(r):rGe(r),this.startOfWeek=(r,i)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(r,this.options):fx(r,this.options),this.startOfYear=r=>this.overrides?.startOfYear?this.overrides.startOfYear(r):eEe(r),this.options={locale:sEe,...t},this.overrides=n}getDigitMap(){const{numerals:t="latn"}=this.options,n=new Intl.NumberFormat("en-US",{numberingSystem:t}),r={};for(let i=0;i<10;i++)r[i.toString()]=n.format(i);return r}replaceDigits(t){const n=this.getDigitMap();return t.replace(/\d/g,r=>n[r]||r)}formatNumber(t){return this.replaceDigits(t.toString())}getMonthYearOrder(){const t=this.options.locale?.code;return t&&Dc.yearFirstLocales.has(t)?"year-first":"month-first"}formatMonthYear(t){const{locale:n,timeZone:r,numerals:i}=this.options,s=n?.code;if(s&&Dc.yearFirstLocales.has(s))try{return new Intl.DateTimeFormat(s,{month:"long",year:"numeric",timeZone:r,numberingSystem:i}).format(t)}catch{}const a=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(t,a)}}Dc.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const Df=new Dc;class aEe{constructor(t,n,r=Df){this.date=t,this.displayMonth=n,this.outside=!!(n&&!r.isSameMonth(t,n)),this.dateLib=r,this.isoDate=r.format(t,"yyyy-MM-dd"),this.displayMonthId=r.format(n,"yyyy-MM"),this.dateMonthId=r.format(t,"yyyy-MM")}isEqualTo(t){return this.dateLib.isSameDay(t.date,this.date)&&this.dateLib.isSameMonth(t.displayMonth,this.displayMonth)}}class mKe{constructor(t,n){this.date=t,this.weeks=n}}class gKe{constructor(t,n){this.days=n,this.weekNumber=t}}function bKe(e){return Q.createElement("button",{...e})}function yKe(e){return Q.createElement("span",{...e})}function vKe(e){const{size:t=24,orientation:n="left",className:r}=e;return Q.createElement("svg",{className:r,width:t,height:t,viewBox:"0 0 24 24"},n==="up"&&Q.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),n==="down"&&Q.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),n==="left"&&Q.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),n==="right"&&Q.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function xKe(e){const{day:t,modifiers:n,...r}=e;return Q.createElement("td",{...r})}function _Ke(e){const{day:t,modifiers:n,...r}=e,i=Q.useRef(null);return Q.useEffect(()=>{n.focused&&i.current?.focus()},[n.focused]),Q.createElement("button",{ref:i,...r})}var An;(function(e){e.Root="root",e.Chevron="chevron",e.Day="day",e.DayButton="day_button",e.CaptionLabel="caption_label",e.Dropdowns="dropdowns",e.Dropdown="dropdown",e.DropdownRoot="dropdown_root",e.Footer="footer",e.MonthGrid="month_grid",e.MonthCaption="month_caption",e.MonthsDropdown="months_dropdown",e.Month="month",e.Months="months",e.Nav="nav",e.NextMonthButton="button_next",e.PreviousMonthButton="button_previous",e.Week="week",e.Weeks="weeks",e.Weekday="weekday",e.Weekdays="weekdays",e.WeekNumber="week_number",e.WeekNumberHeader="week_number_header",e.YearsDropdown="years_dropdown"})(An||(An={}));var as;(function(e){e.disabled="disabled",e.hidden="hidden",e.outside="outside",e.focused="focused",e.today="today"})(as||(as={}));var ld;(function(e){e.range_end="range_end",e.range_middle="range_middle",e.range_start="range_start",e.selected="selected"})(ld||(ld={}));var wc;(function(e){e.weeks_before_enter="weeks_before_enter",e.weeks_before_exit="weeks_before_exit",e.weeks_after_enter="weeks_after_enter",e.weeks_after_exit="weeks_after_exit",e.caption_after_enter="caption_after_enter",e.caption_after_exit="caption_after_exit",e.caption_before_enter="caption_before_enter",e.caption_before_exit="caption_before_exit"})(wc||(wc={}));function SKe(e){const{options:t,className:n,components:r,classNames:i,...s}=e,a=[i[An.Dropdown],n].join(" "),o=t?.find(({value:l})=>l===s.value);return Q.createElement("span",{"data-disabled":s.disabled,className:i[An.DropdownRoot]},Q.createElement(r.Select,{className:a,...s},t?.map(({value:l,label:u,disabled:d})=>Q.createElement(r.Option,{key:l,value:l,disabled:d},u))),Q.createElement("span",{className:i[An.CaptionLabel],"aria-hidden":!0},o?.label,Q.createElement(r.Chevron,{orientation:"down",size:18,className:i[An.Chevron]})))}function wKe(e){return Q.createElement("div",{...e})}function EKe(e){return Q.createElement("div",{...e})}function CKe(e){const{calendarMonth:t,displayIndex:n,...r}=e;return Q.createElement("div",{...r},e.children)}function kKe(e){const{calendarMonth:t,displayIndex:n,...r}=e;return Q.createElement("div",{...r})}function TKe(e){return Q.createElement("table",{...e})}function AKe(e){return Q.createElement("div",{...e})}const oEe=x.createContext(void 0);function OC(){const e=x.useContext(oEe);if(e===void 0)throw new Error("useDayPicker() must be used within a custom component.");return e}function NKe(e){const{components:t}=OC();return Q.createElement(t.Dropdown,{...e})}function OKe(e){const{onPreviousClick:t,onNextClick:n,previousMonth:r,nextMonth:i,...s}=e,{components:a,classNames:o,labels:{labelPrevious:l,labelNext:u}}=OC(),d=x.useCallback(h=>{i&&n?.(h)},[i,n]),f=x.useCallback(h=>{r&&t?.(h)},[r,t]);return Q.createElement("nav",{...s},Q.createElement(a.PreviousMonthButton,{type:"button",className:o[An.PreviousMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":l(r),onClick:f},Q.createElement(a.Chevron,{disabled:r?void 0:!0,className:o[An.Chevron],orientation:"left"})),Q.createElement(a.NextMonthButton,{type:"button",className:o[An.NextMonthButton],tabIndex:i?void 0:-1,"aria-disabled":i?void 0:!0,"aria-label":u(i),onClick:d},Q.createElement(a.Chevron,{disabled:i?void 0:!0,orientation:"right",className:o[An.Chevron]})))}function RKe(e){const{components:t}=OC();return Q.createElement(t.Button,{...e})}function IKe(e){return Q.createElement("option",{...e})}function DKe(e){const{components:t}=OC();return Q.createElement(t.Button,{...e})}function jKe(e){const{rootRef:t,...n}=e;return Q.createElement("div",{...n,ref:t})}function PKe(e){return Q.createElement("select",{...e})}function LKe(e){const{week:t,...n}=e;return Q.createElement("tr",{...n})}function MKe(e){return Q.createElement("th",{...e})}function FKe(e){return Q.createElement("thead",{"aria-hidden":!0},Q.createElement("tr",{...e}))}function BKe(e){const{week:t,...n}=e;return Q.createElement("th",{...n})}function $Ke(e){return Q.createElement("th",{...e})}function zKe(e){return Q.createElement("tbody",{...e})}function UKe(e){const{components:t}=OC();return Q.createElement(t.Dropdown,{...e})}const HKe=Object.freeze(Object.defineProperty({__proto__:null,Button:bKe,CaptionLabel:yKe,Chevron:vKe,Day:xKe,DayButton:_Ke,Dropdown:SKe,DropdownNav:wKe,Footer:EKe,Month:CKe,MonthCaption:kKe,MonthGrid:TKe,Months:AKe,MonthsDropdown:NKe,Nav:OKe,NextMonthButton:RKe,Option:IKe,PreviousMonthButton:DKe,Root:jKe,Select:PKe,Week:LKe,WeekNumber:BKe,WeekNumberHeader:$Ke,Weekday:MKe,Weekdays:FKe,Weeks:zKe,YearsDropdown:UKe},Symbol.toStringTag,{value:"Module"}));function vh(e,t,n=!1,r=Df){let{from:i,to:s}=e;const{differenceInCalendarDays:a,isSameDay:o}=r;return i&&s?(a(s,i)<0&&([i,s]=[s,i]),a(t,i)>=(n?1:0)&&a(s,t)>=(n?1:0)):!n&&s?o(s,t):!n&&i?o(i,t):!1}function BW(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function gD(e){return!!(e&&typeof e=="object"&&"from"in e)}function $W(e){return!!(e&&typeof e=="object"&&"after"in e)}function zW(e){return!!(e&&typeof e=="object"&&"before"in e)}function lEe(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function cEe(e,t){return Array.isArray(e)&&e.every(t.isDate)}function xh(e,t,n=Df){const r=Array.isArray(t)?t:[t],{isSameDay:i,differenceInCalendarDays:s,isAfter:a}=n;return r.some(o=>{if(typeof o=="boolean")return o;if(n.isDate(o))return i(e,o);if(cEe(o,n))return o.some(l=>i(e,l));if(gD(o))return vh(o,e,!1,n);if(lEe(o))return Array.isArray(o.dayOfWeek)?o.dayOfWeek.includes(e.getDay()):o.dayOfWeek===e.getDay();if(BW(o)){const l=s(o.before,e),u=s(o.after,e),d=l>0,f=u<0;return a(o.before,o.after)?f&&d:d||f}return $W(o)?s(e,o.after)>0:zW(o)?s(o.before,e)>0:typeof o=="function"?o(e):!1})}function VKe(e,t,n,r,i){const{disabled:s,hidden:a,modifiers:o,showOutsideDays:l,broadcastCalendar:u,today:d=i.today()}=t,{isSameDay:f,isSameMonth:h,startOfMonth:m,isBefore:g,endOfMonth:y,isAfter:v}=i,_=n&&m(n),S=r&&y(r),E={[as.focused]:[],[as.outside]:[],[as.disabled]:[],[as.hidden]:[],[as.today]:[]},T={};for(const k of e){const{date:w,displayMonth:A}=k,R=!!(A&&!h(w,A)),I=!!(_&&g(w,_)),D=!!(S&&v(w,S)),j=!!(s&&xh(w,s,i)),F=!!(a&&xh(w,a,i))||I||D||!u&&!l&&R||u&&l===!1&&R,z=f(w,d);R&&E.outside.push(k),j&&E.disabled.push(k),F&&E.hidden.push(k),z&&E.today.push(k),o&&Object.keys(o).forEach(P=>{const L=o?.[P];L&&xh(w,L,i)&&(T[P]?T[P].push(k):T[P]=[k])})}return k=>{const w={[as.focused]:!1,[as.disabled]:!1,[as.hidden]:!1,[as.outside]:!1,[as.today]:!1},A={};for(const R in E){const I=E[R];w[R]=I.some(D=>D===k)}for(const R in T)A[R]=T[R].some(I=>I===k);return{...w,...A}}}function WKe(e,t,n={}){return Object.entries(e).filter(([,i])=>i===!0).reduce((i,[s])=>(n[s]?i.push(n[s]):t[as[s]]?i.push(t[as[s]]):t[ld[s]]&&i.push(t[ld[s]]),i),[t[An.Day]])}function qKe(e){return{...HKe,...e}}function GKe(e){const t={"data-mode":e.mode??void 0,"data-required":"required"in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([n,r])=>{n.startsWith("data-")&&(t[n]=r)}),t}function UW(){const e={};for(const t in An)e[An[t]]=`rdp-${An[t]}`;for(const t in as)e[as[t]]=`rdp-${as[t]}`;for(const t in ld)e[ld[t]]=`rdp-${ld[t]}`;for(const t in wc)e[wc[t]]=`rdp-${wc[t]}`;return e}function uEe(e,t,n){return(n??new Dc(t)).formatMonthYear(e)}const KKe=uEe;function YKe(e,t,n){return(n??new Dc(t)).format(e,"d")}function XKe(e,t=Df){return t.format(e,"LLLL")}function QKe(e,t,n){return(n??new Dc(t)).format(e,"cccccc")}function ZKe(e,t=Df){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function JKe(){return""}function dEe(e,t=Df){return t.format(e,"yyyy")}const eYe=dEe,tYe=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:uEe,formatDay:YKe,formatMonthCaption:KKe,formatMonthDropdown:XKe,formatWeekNumber:ZKe,formatWeekNumberHeader:JKe,formatWeekdayName:QKe,formatYearCaption:eYe,formatYearDropdown:dEe},Symbol.toStringTag,{value:"Module"}));function nYe(e){return e?.formatMonthCaption&&!e.formatCaption&&(e.formatCaption=e.formatMonthCaption),e?.formatYearCaption&&!e.formatYearDropdown&&(e.formatYearDropdown=e.formatYearCaption),{...tYe,...e}}function HW(e,t,n,r){let i=(r??new Dc(n)).format(e,"PPPP");return t.today&&(i=`Today, ${i}`),t.selected&&(i=`${i}, selected`),i}const rYe=HW;function VW(e,t,n){return(n??new Dc(t)).formatMonthYear(e)}const iYe=VW;function fEe(e,t,n,r){let i=(r??new Dc(n)).format(e,"PPPP");return t?.today&&(i=`Today, ${i}`),i}function hEe(e){return"Choose the Month"}function pEe(){return""}const sYe="Go to the Next Month";function mEe(e,t){return sYe}function gEe(e){return"Go to the Previous Month"}function bEe(e,t,n){return(n??new Dc(t)).format(e,"cccc")}function yEe(e,t){return`Week ${e}`}function vEe(e){return"Week Number"}function xEe(e){return"Choose the Year"}const aYe=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:iYe,labelDay:rYe,labelDayButton:HW,labelGrid:VW,labelGridcell:fEe,labelMonthDropdown:hEe,labelNav:pEe,labelNext:mEe,labelPrevious:gEe,labelWeekNumber:yEe,labelWeekNumberHeader:vEe,labelWeekday:bEe,labelYearDropdown:xEe},Symbol.toStringTag,{value:"Module"})),Yu=(e,t,n)=>t||(n?typeof n=="function"?n:(...r)=>n:e);function oYe(e,t){const n=t.locale?.labels??{};return{...aYe,...e??{},labelDayButton:Yu(HW,e?.labelDayButton,n.labelDayButton),labelMonthDropdown:Yu(hEe,e?.labelMonthDropdown,n.labelMonthDropdown),labelNext:Yu(mEe,e?.labelNext,n.labelNext),labelPrevious:Yu(gEe,e?.labelPrevious,n.labelPrevious),labelWeekNumber:Yu(yEe,e?.labelWeekNumber,n.labelWeekNumber),labelYearDropdown:Yu(xEe,e?.labelYearDropdown,n.labelYearDropdown),labelGrid:Yu(VW,e?.labelGrid,n.labelGrid),labelGridcell:Yu(fEe,e?.labelGridcell,n.labelGridcell),labelNav:Yu(pEe,e?.labelNav,n.labelNav),labelWeekNumberHeader:Yu(vEe,e?.labelWeekNumberHeader,n.labelWeekNumberHeader),labelWeekday:Yu(bEe,e?.labelWeekday,n.labelWeekday)}}function lYe(e,t,n,r,i){const{startOfMonth:s,startOfYear:a,endOfYear:o,eachMonthOfInterval:l,getMonth:u}=i;return l({start:a(e),end:o(e)}).map(h=>{const m=r.formatMonthDropdown(h,i),g=u(h),y=t&&h<s(t)||n&&h>s(n)||!1;return{value:g,label:m,disabled:y}})}function cYe(e,t={},n={}){let r={...t?.[An.Day]};return Object.entries(e).filter(([,i])=>i===!0).forEach(([i])=>{r={...r,...n?.[i]}}),r}function uYe(e,t,n,r){const i=r??e.today(),s=n?e.startOfBroadcastWeek(i,e):t?e.startOfISOWeek(i):e.startOfWeek(i),a=[];for(let o=0;o<7;o++){const l=e.addDays(s,o);a.push(l)}return a}function dYe(e,t,n,r,i=!1){if(!e||!t)return;const{startOfYear:s,endOfYear:a,eachYearOfInterval:o,getYear:l}=r,u=s(e),d=a(t),f=o({start:u,end:d});return i&&f.reverse(),f.map(h=>{const m=n.formatYearDropdown(h,r);return{value:l(h),label:m,disabled:!1}})}function fYe(e,t={}){const{weekStartsOn:n,locale:r}=t,i=n??r?.options?.weekStartsOn??0,s=o=>{const l=typeof o=="number"||typeof o=="string"?new Date(o):o;return new ko(l.getFullYear(),l.getMonth(),l.getDate(),12,0,0,e)},a=o=>{const l=s(o);return new Date(l.getFullYear(),l.getMonth(),l.getDate(),0,0,0,0)};return{today:()=>s(ko.tz(e)),newDate:(o,l,u)=>new ko(o,l,u,12,0,0,e),startOfDay:o=>s(o),startOfWeek:(o,l)=>{const u=s(o),d=l?.weekStartsOn??i,f=(u.getDay()-d+7)%7;return u.setDate(u.getDate()-f),u},startOfISOWeek:o=>{const l=s(o),u=(l.getDay()-1+7)%7;return l.setDate(l.getDate()-u),l},startOfMonth:o=>{const l=s(o);return l.setDate(1),l},startOfYear:o=>{const l=s(o);return l.setMonth(0,1),l},endOfWeek:(o,l)=>{const u=s(o),h=(((l?.weekStartsOn??i)+6)%7-u.getDay()+7)%7;return u.setDate(u.getDate()+h),u},endOfISOWeek:o=>{const l=s(o),u=(7-l.getDay())%7;return l.setDate(l.getDate()+u),l},endOfMonth:o=>{const l=s(o);return l.setMonth(l.getMonth()+1,0),l},endOfYear:o=>{const l=s(o);return l.setMonth(11,31),l},eachMonthOfInterval:o=>{const l=s(o.start),u=s(o.end),d=[],f=new ko(l.getFullYear(),l.getMonth(),1,12,0,0,e),h=u.getFullYear()*12+u.getMonth();for(;f.getFullYear()*12+f.getMonth()<=h;)d.push(new ko(f,e)),f.setMonth(f.getMonth()+1,1);return d},addDays:(o,l)=>{const u=s(o);return u.setDate(u.getDate()+l),u},addWeeks:(o,l)=>{const u=s(o);return u.setDate(u.getDate()+l*7),u},addMonths:(o,l)=>{const u=s(o);return u.setMonth(u.getMonth()+l),u},addYears:(o,l)=>{const u=s(o);return u.setFullYear(u.getFullYear()+l),u},eachYearOfInterval:o=>{const l=s(o.start),u=s(o.end),d=[],f=new ko(l.getFullYear(),0,1,12,0,0,e);for(;f.getFullYear()<=u.getFullYear();)d.push(new ko(f,e)),f.setFullYear(f.getFullYear()+1,0,1);return d},getWeek:(o,l)=>{const u=a(o);return MW(u,{weekStartsOn:l?.weekStartsOn??i,firstWeekContainsDate:l?.firstWeekContainsDate??r?.options?.firstWeekContainsDate??1})},getISOWeek:o=>{const l=a(o);return LW(l)},differenceInCalendarDays:(o,l)=>{const u=a(o),d=a(l);return jW(u,d)},differenceInCalendarMonths:(o,l)=>{const u=a(o),d=a(l);return PW(u,d)}}}const RC=e=>e instanceof HTMLElement?e:null,r4=e=>[...e.querySelectorAll("[data-animated-month]")??[]],hYe=e=>RC(e.querySelector("[data-animated-month]")),i4=e=>RC(e.querySelector("[data-animated-caption]")),s4=e=>RC(e.querySelector("[data-animated-weeks]")),pYe=e=>RC(e.querySelector("[data-animated-nav]")),mYe=e=>RC(e.querySelector("[data-animated-weekdays]"));function gYe(e,t,{classNames:n,months:r,focused:i,dateLib:s}){const a=x.useRef(null),o=x.useRef(r),l=x.useRef(!1);x.useLayoutEffect(()=>{const u=o.current;if(o.current=r,!t||!e.current||!(e.current instanceof HTMLElement)||r.length===0||u.length===0||r.length!==u.length)return;const d=s.isSameMonth(r[0].date,u[0].date),f=s.isAfter(r[0].date,u[0].date),h=f?n[wc.caption_after_enter]:n[wc.caption_before_enter],m=f?n[wc.weeks_after_enter]:n[wc.weeks_before_enter],g=a.current,y=e.current.cloneNode(!0);if(y instanceof HTMLElement?(r4(y).forEach(E=>{if(!(E instanceof HTMLElement))return;const T=hYe(E);T&&E.contains(T)&&E.removeChild(T);const k=i4(E);k&&k.classList.remove(h);const w=s4(E);w&&w.classList.remove(m)}),a.current=y):a.current=null,l.current||d||i)return;const v=g instanceof HTMLElement?r4(g):[],_=r4(e.current);if(_?.every(S=>S instanceof HTMLElement)&&v&&v.every(S=>S instanceof HTMLElement)){l.current=!0,e.current.style.isolation="isolate";const S=pYe(e.current);S&&(S.style.zIndex="1"),_.forEach((E,T)=>{const k=v[T];if(!k)return;E.style.position="relative",E.style.overflow="hidden";const w=i4(E);w&&w.classList.add(h);const A=s4(E);A&&A.classList.add(m);const R=()=>{l.current=!1,e.current&&(e.current.style.isolation=""),S&&(S.style.zIndex=""),w&&w.classList.remove(h),A&&A.classList.remove(m),E.style.position="",E.style.overflow="",E.contains(k)&&E.removeChild(k)};k.style.pointerEvents="none",k.style.position="absolute",k.style.overflow="hidden",k.setAttribute("aria-hidden","true");const I=mYe(k);I&&(I.style.opacity="0");const D=i4(k);D&&(D.classList.add(f?n[wc.caption_before_exit]:n[wc.caption_after_exit]),D.addEventListener("animationend",R));const j=s4(k);j&&j.classList.add(f?n[wc.weeks_before_exit]:n[wc.weeks_after_exit]),E.insertBefore(k,E.firstChild)})}})}function bYe(e,t,n,r){const i=e[0],s=e[e.length-1],{ISOWeek:a,fixedWeeks:o,broadcastCalendar:l}=n??{},{addDays:u,differenceInCalendarDays:d,differenceInCalendarMonths:f,endOfBroadcastWeek:h,endOfISOWeek:m,endOfMonth:g,endOfWeek:y,isAfter:v,startOfBroadcastWeek:_,startOfISOWeek:S,startOfWeek:E}=r,T=l?_(i,r):a?S(i):E(i),k=l?h(s):a?m(g(s)):y(g(s)),w=t&&(l?h(t):a?m(t):y(t)),A=w&&v(k,w)?w:k,R=d(A,T),I=f(s,i)+1,D=[];for(let z=0;z<=R;z++){const P=u(T,z);D.push(P)}const F=(l?35:42)*I;if(o&&D.length<F){const z=F-D.length;for(let P=0;P<z;P++){const L=u(D[D.length-1],1);D.push(L)}}return D}function yYe(e){const t=[];return e.reduce((n,r)=>{const i=r.weeks.reduce((s,a)=>s.concat(a.days.slice()),t.slice());return n.concat(i.slice())},t.slice())}function vYe(e,t,n,r){const{numberOfMonths:i=1}=n,s=[];for(let a=0;a<i;a++){const o=r.addMonths(e,a);if(t&&o>t)break;s.push(o)}return s}function Use(e,t,n,r){const{month:i,defaultMonth:s,today:a=r.today(),numberOfMonths:o=1}=e;let l=i||s||a;const{differenceInCalendarMonths:u,addMonths:d,startOfMonth:f}=r;if(n&&u(n,l)<o-1){const h=-1*(o-1);l=d(n,h)}return t&&u(l,t)<0&&(l=t),f(l)}function xYe(e,t,n,r){const{addDays:i,endOfBroadcastWeek:s,endOfISOWeek:a,endOfMonth:o,endOfWeek:l,getISOWeek:u,getWeek:d,startOfBroadcastWeek:f,startOfISOWeek:h,startOfWeek:m}=r,g=e.reduce((y,v)=>{const _=n.broadcastCalendar?f(v,r):n.ISOWeek?h(v):m(v),S=n.broadcastCalendar?s(v):n.ISOWeek?a(o(v)):l(o(v)),E=t.filter(A=>A>=_&&A<=S),T=n.broadcastCalendar?35:42;if(n.fixedWeeks&&E.length<T){const A=t.filter(R=>{const I=T-E.length;return R>S&&R<=i(S,I)});E.push(...A)}const k=E.reduce((A,R)=>{const I=n.ISOWeek?u(R):d(R),D=A.find(F=>F.weekNumber===I),j=new aEe(R,v,r);return D?D.days.push(j):A.push(new gKe(I,[j])),A},[]),w=new mKe(v,k);return y.push(w),y},[]);return n.reverseMonths?g.reverse():g}function _Ye(e,t){let{startMonth:n,endMonth:r}=e;const{startOfYear:i,startOfDay:s,startOfMonth:a,endOfMonth:o,addYears:l,endOfYear:u,newDate:d,today:f}=t,{fromYear:h,toYear:m,fromMonth:g,toMonth:y}=e;!n&&g&&(n=g),!n&&h&&(n=t.newDate(h,0,1)),!r&&y&&(r=y),!r&&m&&(r=d(m,11,31));const v=e.captionLayout==="dropdown"||e.captionLayout==="dropdown-years";return n?n=a(n):h?n=d(h,0,1):!n&&v&&(n=i(l(e.today??f(),-100))),r?r=o(r):m?r=d(m,11,31):!r&&v&&(r=u(e.today??f())),[n&&s(n),r&&s(r)]}function SYe(e,t,n,r){if(n.disableNavigation)return;const{pagedNavigation:i,numberOfMonths:s=1}=n,{startOfMonth:a,addMonths:o,differenceInCalendarMonths:l}=r,u=i?s:1,d=a(e);if(!t)return o(d,u);if(!(l(t,e)<s))return o(d,u)}function wYe(e,t,n,r){if(n.disableNavigation)return;const{pagedNavigation:i,numberOfMonths:s}=n,{startOfMonth:a,addMonths:o,differenceInCalendarMonths:l}=r,u=i?s??1:1,d=a(e);if(!t)return o(d,-u);if(!(l(d,t)<=0))return o(d,-u)}function EYe(e){const t=[];return e.reduce((n,r)=>n.concat(r.weeks.slice()),t.slice())}function bD(e,t){const[n,r]=x.useState(e);return[t===void 0?n:t,r]}function CYe(e,t){const[n,r]=_Ye(e,t),{startOfMonth:i,endOfMonth:s}=t,a=Use(e,n,r,t),[o,l]=bD(a,e.month?a:void 0);x.useEffect(()=>{const T=Use(e,n,r,t);l(T)},[e.timeZone]);const{months:u,weeks:d,days:f,previousMonth:h,nextMonth:m}=x.useMemo(()=>{const T=vYe(o,r,{numberOfMonths:e.numberOfMonths},t),k=bYe(T,e.endMonth?s(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),w=xYe(T,k,{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t),A=EYe(w),R=yYe(w),I=wYe(o,n,e,t),D=SYe(o,r,e,t);return{months:w,weeks:A,days:R,previousMonth:I,nextMonth:D}},[t,o.getTime(),r?.getTime(),n?.getTime(),e.disableNavigation,e.broadcastCalendar,e.endMonth?.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:g,onMonthChange:y}=e,v=T=>d.some(k=>k.days.some(w=>w.isEqualTo(T))),_=T=>{if(g)return;let k=i(T);n&&k<i(n)&&(k=i(n)),r&&k>i(r)&&(k=i(r)),l(k),y?.(k)};return{months:u,weeks:d,days:f,navStart:n,navEnd:r,previousMonth:h,nextMonth:m,goToMonth:_,goToDay:T=>{v(T)||_(T.date)}}}var Yd;(function(e){e[e.Today=0]="Today",e[e.Selected=1]="Selected",e[e.LastFocused=2]="LastFocused",e[e.FocusedModifier=3]="FocusedModifier"})(Yd||(Yd={}));function Hse(e){return!e[as.disabled]&&!e[as.hidden]&&!e[as.outside]}function kYe(e,t,n,r){let i,s=-1;for(const a of e){const o=t(a);Hse(o)&&(o[as.focused]&&s<Yd.FocusedModifier?(i=a,s=Yd.FocusedModifier):r?.isEqualTo(a)&&s<Yd.LastFocused?(i=a,s=Yd.LastFocused):n(a.date)&&s<Yd.Selected?(i=a,s=Yd.Selected):o[as.today]&&s<Yd.Today&&(i=a,s=Yd.Today))}return i||(i=e.find(a=>Hse(t(a)))),i}function TYe(e,t,n,r,i,s,a){const{ISOWeek:o,broadcastCalendar:l}=s,{addDays:u,addMonths:d,addWeeks:f,addYears:h,endOfBroadcastWeek:m,endOfISOWeek:g,endOfWeek:y,max:v,min:_,startOfBroadcastWeek:S,startOfISOWeek:E,startOfWeek:T}=a;let w={day:u,week:f,month:d,year:h,startOfWeek:A=>l?S(A,a):o?E(A):T(A),endOfWeek:A=>l?m(A):o?g(A):y(A)}[e](n,t==="after"?1:-1);return t==="before"&&r?w=v([r,w]):t==="after"&&i&&(w=_([i,w])),w}function _Ee(e,t,n,r,i,s,a,o=0){if(o>365)return;const l=TYe(e,t,n.date,r,i,s,a),u=!!(s.disabled&&xh(l,s.disabled,a)),d=!!(s.hidden&&xh(l,s.hidden,a)),f=l,h=new aEe(l,f,a);return!u&&!d?h:_Ee(e,t,h,r,i,s,a,o+1)}function AYe(e,t,n,r,i){const{autoFocus:s}=e,[a,o]=x.useState(),l=kYe(t.days,n,r||(()=>!1),a),[u,d]=x.useState(s?l:void 0);return{isFocusTarget:y=>!!l?.isEqualTo(y),setFocused:d,focused:u,blur:()=>{o(u),d(void 0)},moveFocus:(y,v)=>{if(!u)return;const _=_Ee(y,v,u,t.navStart,t.navEnd,e,i);_&&(e.disableNavigation&&!t.days.some(E=>E.isEqualTo(_))||(t.goToDay(_),d(_)))}}}function NYe(e,t){const{selected:n,required:r,onSelect:i}=e,[s,a]=bD(n,i?n:void 0),o=i?n:s,{isSameDay:l}=t,u=m=>o?.some(g=>l(g,m))??!1,{min:d,max:f}=e;return{selected:o,select:(m,g,y)=>{let v=[...o??[]];if(u(m)){if(o?.length===d||r&&o?.length===1)return;v=o?.filter(_=>!l(_,m))}else o?.length===f?v=[m]:v=[...v,m];return i||a(v),i?.(v,m,g,y),v},isSelected:u}}function OYe(e,t,n=0,r=0,i=!1,s=Df){const{from:a,to:o}=t||{},{isSameDay:l,isAfter:u,isBefore:d}=s;let f;if(!a&&!o)f={from:e,to:n>0?void 0:e};else if(a&&!o)l(a,e)?n===0?f={from:a,to:e}:i?f={from:a,to:void 0}:f=void 0:d(e,a)?f={from:e,to:a}:f={from:a,to:e};else if(a&&o)if(l(a,e)&&l(o,e))i?f={from:a,to:o}:f=void 0;else if(l(a,e))f={from:a,to:n>0?void 0:e};else if(l(o,e))f={from:e,to:n>0?void 0:e};else if(d(e,a))f={from:e,to:o};else if(u(e,a))f={from:a,to:e};else if(u(e,o))f={from:a,to:e};else throw new Error("Invalid range");if(f?.from&&f?.to){const h=s.differenceInCalendarDays(f.to,f.from);r>0&&h>r?f={from:e,to:void 0}:n>1&&h<n&&(f={from:e,to:void 0})}return f}function RYe(e,t,n=Df){const r=Array.isArray(t)?t:[t];let i=e.from;const s=n.differenceInCalendarDays(e.to,e.from),a=Math.min(s,6);for(let o=0;o<=a;o++){if(r.includes(i.getDay()))return!0;i=n.addDays(i,1)}return!1}function Vse(e,t,n=Df){return vh(e,t.from,!1,n)||vh(e,t.to,!1,n)||vh(t,e.from,!1,n)||vh(t,e.to,!1,n)}function IYe(e,t,n=Df){const r=Array.isArray(t)?t:[t];if(r.filter(o=>typeof o!="function").some(o=>typeof o=="boolean"?o:n.isDate(o)?vh(e,o,!1,n):cEe(o,n)?o.some(l=>vh(e,l,!1,n)):gD(o)?o.from&&o.to?Vse(e,{from:o.from,to:o.to},n):!1:lEe(o)?RYe(e,o.dayOfWeek,n):BW(o)?n.isAfter(o.before,o.after)?Vse(e,{from:n.addDays(o.after,1),to:n.addDays(o.before,-1)},n):xh(e.from,o,n)||xh(e.to,o,n):$W(o)||zW(o)?xh(e.from,o,n)||xh(e.to,o,n):!1))return!0;const a=r.filter(o=>typeof o=="function");if(a.length){let o=e.from;const l=n.differenceInCalendarDays(e.to,e.from);for(let u=0;u<=l;u++){if(a.some(d=>d(o)))return!0;o=n.addDays(o,1)}}return!1}function DYe(e,t){const{disabled:n,excludeDisabled:r,selected:i,required:s,onSelect:a}=e,[o,l]=bD(i,a?i:void 0),u=a?i:o;return{selected:u,select:(h,m,g)=>{const{min:y,max:v}=e,_=h?OYe(h,u,y,v,s,t):void 0;return r&&n&&_?.from&&_.to&&IYe({from:_.from,to:_.to},n,t)&&(_.from=h,_.to=void 0),a||l(_),a?.(_,h,m,g),_},isSelected:h=>u&&vh(u,h,!1,t)}}function jYe(e,t){const{selected:n,required:r,onSelect:i}=e,[s,a]=bD(n,i?n:void 0),o=i?n:s,{isSameDay:l}=t;return{selected:o,select:(f,h,m)=>{let g=f;return!r&&o&&o&&l(f,o)&&(g=void 0),i||a(g),i?.(g,f,h,m),g},isSelected:f=>o?l(o,f):!1}}function PYe(e,t){const n=jYe(e,t),r=NYe(e,t),i=DYe(e,t);switch(e.mode){case"single":return n;case"multiple":return r;case"range":return i;default:return}}function lu(e,t){return e instanceof ko&&e.timeZone===t?e:new ko(e,t)}function Vv(e,t,n){return lu(e,t)}function Wse(e,t,n){return typeof e=="boolean"||typeof e=="function"?e:e instanceof Date?Vv(e,t):Array.isArray(e)?e.map(r=>r instanceof Date?Vv(r,t):r):gD(e)?{...e,from:e.from?lu(e.from,t):e.from,to:e.to?lu(e.to,t):e.to}:BW(e)?{before:Vv(e.before,t),after:Vv(e.after,t)}:$W(e)?{after:Vv(e.after,t)}:zW(e)?{before:Vv(e.before,t)}:e}function a4(e,t,n){return e&&(Array.isArray(e)?e.map(r=>Wse(r,t)):Wse(e,t))}function LYe(e){let t=e;const n=t.timeZone;if(n&&(t={...e,timeZone:n},t.today&&(t.today=lu(t.today,n)),t.month&&(t.month=lu(t.month,n)),t.defaultMonth&&(t.defaultMonth=lu(t.defaultMonth,n)),t.startMonth&&(t.startMonth=lu(t.startMonth,n)),t.endMonth&&(t.endMonth=lu(t.endMonth,n)),t.mode==="single"&&t.selected?t.selected=lu(t.selected,n):t.mode==="multiple"&&t.selected?t.selected=t.selected?.map(at=>lu(at,n)):t.mode==="range"&&t.selected&&(t.selected={from:t.selected.from?lu(t.selected.from,n):t.selected.from,to:t.selected.to?lu(t.selected.to,n):t.selected.to}),t.disabled!==void 0&&(t.disabled=a4(t.disabled,n)),t.hidden!==void 0&&(t.hidden=a4(t.hidden,n)),t.modifiers)){const at={};Object.keys(t.modifiers).forEach(gt=>{at[gt]=a4(t.modifiers?.[gt],n)}),t.modifiers=at}const{components:r,formatters:i,labels:s,dateLib:a,locale:o,classNames:l}=x.useMemo(()=>{const at={...sEe,...t.locale},gt=t.broadcastCalendar?1:t.weekStartsOn,We=t.noonSafe&&t.timeZone?fYe(t.timeZone,{weekStartsOn:gt,locale:at}):void 0,Xe=t.dateLib&&We?{...We,...t.dateLib}:t.dateLib??We,it=new Dc({locale:at,weekStartsOn:gt,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},Xe);return{dateLib:it,components:qKe(t.components),formatters:nYe(t.formatters),labels:oYe(t.labels,it.options),locale:at,classNames:{...UW(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.noonSafe,t.components,t.formatters,t.labels,t.classNames]);t.today||(t={...t,today:a.today()});const{captionLayout:u,mode:d,navLayout:f,numberOfMonths:h=1,onDayBlur:m,onDayClick:g,onDayFocus:y,onDayKeyDown:v,onDayMouseEnter:_,onDayMouseLeave:S,onNextClick:E,onPrevClick:T,showWeekNumber:k,styles:w}=t,{formatCaption:A,formatDay:R,formatMonthDropdown:I,formatWeekNumber:D,formatWeekNumberHeader:j,formatWeekdayName:F,formatYearDropdown:z}=i,P=CYe(t,a),{days:L,months:M,navStart:$,navEnd:W,previousMonth:Y,nextMonth:q,goToMonth:K}=P,X=VKe(L,t,$,W,a),{isSelected:U,select:J,selected:te}=PYe(t,a)??{},{blur:ee,focused:oe,isFocusTarget:ae,moveFocus:se,setFocused:ue}=AYe(t,P,X,U??(()=>!1),a),{labelDayButton:de,labelGridcell:ce,labelGrid:Ee,labelMonthDropdown:Ie,labelNav:fe,labelPrevious:be,labelNext:ge,labelWeekday:Ce,labelWeekNumber:Re,labelWeekNumberHeader:xe,labelYearDropdown:ye}=s,De=x.useMemo(()=>uYe(a,t.ISOWeek,t.broadcastCalendar,t.today),[a,t.ISOWeek,t.broadcastCalendar,t.today]),ve=d!==void 0||g!==void 0,Oe=x.useCallback(()=>{Y&&(K(Y),T?.(Y))},[Y,K,T]),Be=x.useCallback(()=>{q&&(K(q),E?.(q))},[K,q,E]),Te=x.useCallback((at,gt)=>We=>{We.preventDefault(),We.stopPropagation(),ue(at),!gt.disabled&&(J?.(at.date,gt,We),g?.(at.date,gt,We))},[J,g,ue]),je=x.useCallback((at,gt)=>We=>{ue(at),y?.(at.date,gt,We)},[y,ue]),ie=x.useCallback((at,gt)=>We=>{ee(),m?.(at.date,gt,We)},[ee,m]),Ke=x.useCallback((at,gt)=>We=>{const Xe={ArrowLeft:[We.shiftKey?"month":"day",t.dir==="rtl"?"after":"before"],ArrowRight:[We.shiftKey?"month":"day",t.dir==="rtl"?"before":"after"],ArrowDown:[We.shiftKey?"year":"week","after"],ArrowUp:[We.shiftKey?"year":"week","before"],PageUp:[We.shiftKey?"year":"month","before"],PageDown:[We.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(Xe[We.key]){We.preventDefault(),We.stopPropagation();const[it,ot]=Xe[We.key];se(it,ot)}v?.(at.date,gt,We)},[se,v,t.dir]),lt=x.useCallback((at,gt)=>We=>{_?.(at.date,gt,We)},[_]),Rt=x.useCallback((at,gt)=>We=>{S?.(at.date,gt,We)},[S]),Ye=x.useCallback(at=>gt=>{const We=Number(gt.target.value),Xe=a.setMonth(a.startOfMonth(at),We);K(Xe)},[a,K]),ct=x.useCallback(at=>gt=>{const We=Number(gt.target.value),Xe=a.setYear(a.startOfMonth(at),We);K(Xe)},[a,K]),{className:Ve,style:Et}=x.useMemo(()=>({className:[l[An.Root],t.className].filter(Boolean).join(" "),style:{...w?.[An.Root],...t.style}}),[l,t.className,t.style,w]),$e=GKe(t),Qe=x.useRef(null);gYe(Qe,!!t.animate,{classNames:l,months:M,focused:oe,dateLib:a});const pt={dayPickerProps:t,selected:te,select:J,isSelected:U,months:M,nextMonth:q,previousMonth:Y,goToMonth:K,getModifiers:X,components:r,classNames:l,styles:w,labels:s,formatters:i};return Q.createElement(oEe.Provider,{value:pt},Q.createElement(r.Root,{rootRef:t.animate?Qe:void 0,className:Ve,style:Et,dir:t.dir,id:t.id,lang:t.lang,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t["aria-label"],"aria-labelledby":t["aria-labelledby"],...$e},Q.createElement(r.Months,{className:l[An.Months],style:w?.[An.Months]},!t.hideNavigation&&!f&&Q.createElement(r.Nav,{"data-animated-nav":t.animate?"true":void 0,className:l[An.Nav],style:w?.[An.Nav],"aria-label":fe(),onPreviousClick:Oe,onNextClick:Be,previousMonth:Y,nextMonth:q}),M.map((at,gt)=>Q.createElement(r.Month,{"data-animated-month":t.animate?"true":void 0,className:l[An.Month],style:w?.[An.Month],key:gt,displayIndex:gt,calendarMonth:at},f==="around"&&!t.hideNavigation&&gt===0&&Q.createElement(r.PreviousMonthButton,{type:"button",className:l[An.PreviousMonthButton],tabIndex:Y?void 0:-1,"aria-disabled":Y?void 0:!0,"aria-label":be(Y),onClick:Oe,"data-animated-button":t.animate?"true":void 0},Q.createElement(r.Chevron,{disabled:Y?void 0:!0,className:l[An.Chevron],orientation:t.dir==="rtl"?"right":"left"})),Q.createElement(r.MonthCaption,{"data-animated-caption":t.animate?"true":void 0,className:l[An.MonthCaption],style:w?.[An.MonthCaption],calendarMonth:at,displayIndex:gt},u?.startsWith("dropdown")?Q.createElement(r.DropdownNav,{className:l[An.Dropdowns],style:w?.[An.Dropdowns]},(()=>{const We=u==="dropdown"||u==="dropdown-months"?Q.createElement(r.MonthsDropdown,{key:"month",className:l[An.MonthsDropdown],"aria-label":Ie(),classNames:l,components:r,disabled:!!t.disableNavigation,onChange:Ye(at.date),options:lYe(at.date,$,W,i,a),style:w?.[An.Dropdown],value:a.getMonth(at.date)}):Q.createElement("span",{key:"month"},I(at.date,a)),Xe=u==="dropdown"||u==="dropdown-years"?Q.createElement(r.YearsDropdown,{key:"year",className:l[An.YearsDropdown],"aria-label":ye(a.options),classNames:l,components:r,disabled:!!t.disableNavigation,onChange:ct(at.date),options:dYe($,W,i,a,!!t.reverseYears),style:w?.[An.Dropdown],value:a.getYear(at.date)}):Q.createElement("span",{key:"year"},z(at.date,a));return a.getMonthYearOrder()==="year-first"?[Xe,We]:[We,Xe]})(),Q.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},A(at.date,a.options,a))):Q.createElement(r.CaptionLabel,{className:l[An.CaptionLabel],role:"status","aria-live":"polite"},A(at.date,a.options,a))),f==="around"&&!t.hideNavigation&&gt===h-1&&Q.createElement(r.NextMonthButton,{type:"button",className:l[An.NextMonthButton],tabIndex:q?void 0:-1,"aria-disabled":q?void 0:!0,"aria-label":ge(q),onClick:Be,"data-animated-button":t.animate?"true":void 0},Q.createElement(r.Chevron,{disabled:q?void 0:!0,className:l[An.Chevron],orientation:t.dir==="rtl"?"left":"right"})),gt===h-1&&f==="after"&&!t.hideNavigation&&Q.createElement(r.Nav,{"data-animated-nav":t.animate?"true":void 0,className:l[An.Nav],style:w?.[An.Nav],"aria-label":fe(),onPreviousClick:Oe,onNextClick:Be,previousMonth:Y,nextMonth:q}),Q.createElement(r.MonthGrid,{role:"grid","aria-multiselectable":d==="multiple"||d==="range","aria-label":Ee(at.date,a.options,a)||void 0,className:l[An.MonthGrid],style:w?.[An.MonthGrid]},!t.hideWeekdays&&Q.createElement(r.Weekdays,{"data-animated-weekdays":t.animate?"true":void 0,className:l[An.Weekdays],style:w?.[An.Weekdays]},k&&Q.createElement(r.WeekNumberHeader,{"aria-label":xe(a.options),className:l[An.WeekNumberHeader],style:w?.[An.WeekNumberHeader],scope:"col"},j()),De.map(We=>Q.createElement(r.Weekday,{"aria-label":Ce(We,a.options,a),className:l[An.Weekday],key:String(We),style:w?.[An.Weekday],scope:"col"},F(We,a.options,a)))),Q.createElement(r.Weeks,{"data-animated-weeks":t.animate?"true":void 0,className:l[An.Weeks],style:w?.[An.Weeks]},at.weeks.map(We=>Q.createElement(r.Week,{className:l[An.Week],key:We.weekNumber,style:w?.[An.Week],week:We},k&&Q.createElement(r.WeekNumber,{week:We,style:w?.[An.WeekNumber],"aria-label":Re(We.weekNumber,{locale:o}),className:l[An.WeekNumber],scope:"row",role:"rowheader"},D(We.weekNumber,a)),We.days.map(Xe=>{const{date:it}=Xe,ot=X(Xe);if(ot[as.focused]=!ot.hidden&&!!oe?.isEqualTo(Xe),ot[ld.selected]=U?.(it)||ot.selected,gD(te)){const{from:en,to:Fe}=te;ot[ld.range_start]=!!(en&&Fe&&a.isSameDay(it,en)),ot[ld.range_end]=!!(en&&Fe&&a.isSameDay(it,Fe)),ot[ld.range_middle]=vh(te,it,!0,a)}const St=cYe(ot,w,t.modifiersStyles),Xt=WKe(ot,l,t.modifiersClassNames),Vt=!ve&&!ot.hidden?ce(it,ot,a.options,a):void 0;return Q.createElement(r.Day,{key:`${Xe.isoDate}_${Xe.displayMonthId}`,day:Xe,modifiers:ot,className:Xt.join(" "),style:St,role:"gridcell","aria-selected":ot.selected||void 0,"aria-label":Vt,"data-day":Xe.isoDate,"data-month":Xe.outside?Xe.dateMonthId:void 0,"data-selected":ot.selected||void 0,"data-disabled":ot.disabled||void 0,"data-hidden":ot.hidden||void 0,"data-outside":Xe.outside||void 0,"data-focused":ot.focused||void 0,"data-today":ot.today||void 0},!ot.hidden&&ve?Q.createElement(r.DayButton,{className:l[An.DayButton],style:w?.[An.DayButton],type:"button",day:Xe,modifiers:ot,disabled:!ot.focused&&ot.disabled||void 0,"aria-disabled":ot.focused&&ot.disabled||void 0,tabIndex:ae(Xe)?0:-1,"aria-label":de(it,ot,a.options,a),onClick:Te(Xe,ot),onBlur:ie(Xe,ot),onFocus:je(Xe,ot),onKeyDown:Ke(Xe,ot),onMouseEnter:lt(Xe,ot),onMouseLeave:Rt(Xe,ot)},R(it,a.options,a)):!ot.hidden&&R(Xe.date,a.options,a))})))))))),t.footer&&Q.createElement(r.Footer,{className:l[An.Footer],style:w?.[An.Footer],role:"status","aria-live":"polite"},t.footer)))}function MYe({className:e,classNames:t,showOutsideDays:n=!0,captionLayout:r="label",buttonVariant:i="ghost",formatters:s,components:a,...o}){const l=UW();return c.jsx(LYe,{showOutsideDays:n,className:Ae("p-3 [--cell-radius:var(--radius-md)] [--cell-size:--spacing(6)] bg-background group/calendar [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:r,formatters:{formatMonthDropdown:u=>u.toLocaleString("default",{month:"short"}),...s},classNames:{root:Ae("w-fit",l.root),months:Ae("flex gap-4 flex-col md:flex-row relative",l.months),month:Ae("flex flex-col w-full gap-4",l.month),nav:Ae("flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between",l.nav),button_previous:Ae(n$({variant:i}),"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",l.button_previous),button_next:Ae(n$({variant:i}),"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",l.button_next),month_caption:Ae("flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)",l.month_caption),dropdowns:Ae("w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5",l.dropdowns),dropdown_root:Ae("relative cn-calendar-dropdown-root rounded-(--cell-radius)",l.dropdown_root),dropdown:Ae("absolute bg-popover inset-0 opacity-0",l.dropdown),caption_label:Ae("select-none font-medium",r==="label"?"text-sm":"cn-calendar-caption-label rounded-(--cell-radius) flex items-center gap-1 text-sm [&>svg]:text-muted-foreground [&>svg]:size-3.5",l.caption_label),table:"w-full border-collapse",weekdays:Ae("flex",l.weekdays),weekday:Ae("text-muted-foreground rounded-(--cell-radius) flex-1 font-normal text-[0.8rem] select-none",l.weekday),week:Ae("flex w-full mt-2",l.week),week_number_header:Ae("select-none w-(--cell-size)",l.week_number_header),week_number:Ae("text-[0.8rem] select-none text-muted-foreground",l.week_number),day:Ae("relative w-full rounded-(--cell-radius) h-full p-0 text-center [&:last-child[data-selected=true]_button]:rounded-r-(--cell-radius) group/day aspect-square select-none",o.showWeekNumber?"[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)":"[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)",l.day),range_start:Ae("rounded-l-(--cell-radius) bg-muted relative after:bg-muted after:absolute after:inset-y-0 after:w-4 after:right-0 -z-0 isolate",l.range_start),range_middle:Ae("rounded-none",l.range_middle),range_end:Ae("rounded-r-(--cell-radius) bg-muted relative after:bg-muted after:absolute after:inset-y-0 after:w-4 after:left-0 -z-0 isolate",l.range_end),today:Ae("bg-muted text-foreground rounded-(--cell-radius) data-[selected=true]:rounded-none",l.today),outside:Ae("text-muted-foreground aria-selected:text-muted-foreground",l.outside),disabled:Ae("text-muted-foreground opacity-50",l.disabled),hidden:Ae("invisible",l.hidden),...t},components:{Root:({className:u,rootRef:d,...f})=>c.jsx("div",{"data-slot":"calendar",ref:d,className:Ae(u),...f}),Chevron:({className:u,orientation:d,...f})=>d==="left"?c.jsx(Z,{icon:xf,strokeWidth:2,className:Ae("size-4",u),...f}):d==="right"?c.jsx(Z,{icon:Bl,strokeWidth:2,className:Ae("size-4",u),...f}):c.jsx(Z,{icon:Ts,strokeWidth:2,className:Ae("size-4",u),...f}),DayButton:FYe,WeekNumber:({children:u,...d})=>c.jsx("td",{...d,children:c.jsx("div",{className:"flex size-(--cell-size) items-center justify-center text-center",children:u})}),...a},...o})}function FYe({className:e,day:t,modifiers:n,...r}){const i=UW(),s=x.useRef(null);return x.useEffect(()=>{n.focused&&s.current?.focus()},[n.focused]),c.jsx(_e,{variant:"ghost",size:"icon","data-day":t.date.toLocaleDateString(),"data-selected-single":n.selected&&!n.range_start&&!n.range_end&&!n.range_middle,"data-range-start":n.range_start,"data-range-end":n.range_end,"data-range-middle":n.range_middle,className:Ae("data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-muted data-[range-middle=true]:text-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-foreground relative isolate z-10 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 border-0 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-(--cell-radius) data-[range-end=true]:rounded-r-(--cell-radius) data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-(--cell-radius) data-[range-start=true]:rounded-l-(--cell-radius) [&>span]:text-xs [&>span]:opacity-70",i.day,e),...r})}function O1({...e}){return c.jsx(TVe,{"data-slot":"popover",...e})}function R1({...e}){return c.jsx(NVe,{"data-slot":"popover-trigger",...e})}function I1({className:e,align:t="center",alignOffset:n=0,side:r="bottom",sideOffset:i=4,...s}){return c.jsx(RVe,{children:c.jsx(DVe,{align:t,alignOffset:n,side:r,sideOffset:i,className:"isolate z-50",children:c.jsx(MVe,{"data-slot":"popover-content",className:Ae("film-grain text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 flex flex-col gap-4 rounded-lg p-2.5 text-xs shadow-md ring-1 duration-100 z-50 w-72 origin-(--transform-origin) outline-hidden",e),style:{background:"var(--gradient-card)"},...s})})})}function ma(e){const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${r}`}function Js(e){const[t,n,r]=e.split("-").map(Number);return new Date(t,n-1,r)}function WW(e,t={month:"short",day:"numeric"},n="en-US"){return Js(e).toLocaleDateString(n,t)}function qW(e){const t=new Date;if(!e){const r=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return`${r}-${i}-${s}`}return new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit"}).format(t)}function BYe(e,t,n){if(!e||n==="DONE"||n==="CANCELED")return!1;const r=qW(t);return e<r}function $Ye(e,t,n){if(!e||n==="DONE"||n==="CANCELED")return!1;const r=qW(t);return e===r}function GW({value:e,onChange:t,placeholder:n="Set due date",className:r,showClear:i=!0,isOverdue:s=!1}){const[a,o]=x.useState(!1),l=e?Js(e):void 0,u=h=>{if(h){const m=ma(h);t(m)}o(!1)},d=h=>{h.stopPropagation(),t(null),o(!1)},f=h=>Js(h).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return c.jsxs(O1,{open:a,onOpenChange:o,children:[c.jsxs(R1,{className:Ae("flex items-center gap-2 text-sm cursor-pointer rounded-md px-2 py-1 hover:bg-muted transition-colors",s&&"text-destructive",r),children:[c.jsx(Z,{icon:op,size:14}),e?c.jsxs("span",{className:s?"font-medium":"",children:[f(e),s&&" (Overdue)"]}):c.jsx("span",{className:"text-muted-foreground",children:n})]}),c.jsxs(I1,{className:"w-auto p-0",align:"start",children:[c.jsx(MYe,{mode:"single",selected:l,onSelect:u,defaultMonth:l}),i&&e&&c.jsx("div",{className:"border-t p-2",children:c.jsx(_e,{variant:"ghost",size:"sm",className:"w-full text-muted-foreground",onClick:d,children:"Clear date"})})]})]})}function yD(){const e=Jt({queryKey:["opencode","models"],queryFn:()=>ht("/api/opencode/models"),staleTime:3e5,gcTime:6e5});return{...e,installed:e.data?.installed??!1,providers:e.data?.providers??{},models:e.data?.models??[]}}function Bb({value:e,onChange:t,placeholder:n,showUseDefault:r=!0,className:i}){const{t:s}=Ot("common"),{providers:a,installed:o,isLoading:l,isError:u}=yD(),d=x.useMemo(()=>Object.entries(a).sort(([h],[m])=>h.localeCompare(m)),[a]),f=h=>h||"";return l?c.jsx("div",{className:`text-muted-foreground text-sm ${i}`,children:s("status.loading")}):u||!o?c.jsx("div",{className:`text-muted-foreground text-sm ${i}`,children:s("opencode.notInstalled","OpenCode not installed")}):c.jsx("div",{className:i,children:c.jsxs(ox,{value:e||"",onValueChange:h=>t(h===""?null:h),itemToStringLabel:f,children:[c.jsx(lx,{placeholder:n||s("opencode.selectModel","Select model"),className:"w-full"}),c.jsx(cx,{children:c.jsxs(ux,{children:[c.jsx(dx,{children:s("opencode.noModelsFound","No models found")}),r&&c.jsxs(c.Fragment,{children:[c.jsx(Rh,{value:"",children:c.jsx("span",{className:"text-muted-foreground",children:s("opencode.useDefault","Use default")})}),d.length>0&&c.jsx(Rse,{})]}),d.map(([h,m],g)=>c.jsxs(kE,{children:[c.jsx(TE,{children:h}),m.map(y=>c.jsx(Rh,{value:`${h}/${y}`,children:c.jsx("span",{className:"pl-2",children:y})},`${h}/${y}`)),g<d.length-1&&c.jsx(Rse,{})]},h))]})})]})})}const vD="";function zYe(e){return Jt({queryKey:["task-attachments",e],queryFn:async()=>{const t=await fetch(`${vD}/api/tasks/${e}/attachments`);if(!t.ok)throw new Error("Failed to fetch attachments");return t.json()},enabled:!!e})}function SEe(){const e=It();return wt({mutationFn:async({taskId:t,file:n})=>{const r=new FormData;r.append("file",n);const i=await fetch(`${vD}/api/tasks/${t}/attachments`,{method:"POST",body:r});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.error||"Failed to upload attachment")}return i.json()},onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["task-attachments",n.taskId]}),e.invalidateQueries({queryKey:["tasks"]})}})}function UYe(){const e=It();return wt({mutationFn:async({taskId:t,attachmentId:n})=>{const r=await fetch(`${vD}/api/tasks/${t}/attachments/${n}`,{method:"DELETE"});if(!r.ok)throw new Error("Failed to delete attachment");return r.json()},onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["task-attachments",n.taskId]}),e.invalidateQueries({queryKey:["tasks"]})}})}function o4(e,t){return`${vD}/api/tasks/${e}/attachments/${t}`}const qse={TO_DO:"bg-status-todo/20 text-status-todo",IN_PROGRESS:"bg-status-in-progress/20 text-status-in-progress",IN_REVIEW:"bg-status-in-review/20 text-status-in-review",DONE:"bg-status-done/20 text-status-done",CANCELED:"bg-status-canceled/20 text-status-canceled"};function HYe({selectedIds:e,onSelectionChange:t,className:n}){const{t:r}=Ot("tasks"),{data:i=[]}=cl(),[s,a]=x.useState(""),[o,l]=x.useState(!1),u=x.useRef(null);x.useEffect(()=>{o&&u.current&&u.current.focus()},[o]);const d=x.useMemo(()=>i.filter(g=>e.includes(g.id)),[i,e]),f=x.useMemo(()=>{const g=s.toLowerCase().trim(),y=new Set(["DONE","CANCELED"]);return i.filter(v=>!e.includes(v.id)).filter(v=>g?v.title.toLowerCase().includes(g)||v.description?.toLowerCase().includes(g):!0).sort((v,_)=>{const S=y.has(v.status),E=y.has(_.status);return S!==E?S?1:-1:new Date(_.updatedAt).getTime()-new Date(v.updatedAt).getTime()}).slice(0,10)},[i,e,s]),h=g=>{t([...e,g]),a(""),l(!1)},m=g=>{t(e.filter(y=>y!==g))};return c.jsxs("div",{className:Ae("space-y-2",n),children:[d.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1",children:d.map(g=>c.jsxs("div",{className:"inline-flex items-center gap-1.5 rounded border border-border bg-card px-2 py-1 text-xs",children:[c.jsx("span",{className:Ae("shrink-0 rounded px-1 py-0.5 text-[10px] font-medium",qse[g.status]),children:g.status.replace("_"," ")}),c.jsx("span",{className:"truncate max-w-[150px]",children:g.title}),c.jsx("button",{type:"button",onClick:()=>m(g.id),className:"shrink-0 text-muted-foreground hover:text-foreground",children:c.jsx(Z,{icon:Tn,size:12})})]},g.id))}),c.jsxs("div",{className:"relative",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(Z,{icon:wd,size:14,className:"text-muted-foreground shrink-0"}),c.jsx(At,{ref:u,value:s,onChange:g=>{a(g.target.value),l(!0)},onFocus:()=>l(!0),onBlur:()=>{setTimeout(()=>l(!1),150)},placeholder:r("createModal.blockedByPlaceholder","Search tasks to block this..."),className:"h-8 text-sm",onKeyDown:g=>{g.key==="Escape"&&(a(""),l(!1),u.current?.blur())}})]}),o&&(s||f.length>0)&&c.jsx("div",{className:"absolute z-10 top-full left-0 right-0 mt-1 max-h-40 overflow-y-auto rounded-md border bg-popover shadow-md",children:f.length>0?f.map(g=>c.jsxs("button",{type:"button",className:"w-full px-2 py-1.5 text-left text-xs hover:bg-muted flex items-center gap-2",onMouseDown:y=>{y.preventDefault(),h(g.id)},children:[c.jsx("span",{className:Ae("shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",qse[g.status]),children:g.status.replace("_"," ")}),c.jsx("span",{className:"truncate",children:g.title})]},g.id)):s&&c.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:r("createModal.noTasksFound","No tasks found")})})]})]})}const Gse=[1,2,3,5,8];function KW({value:e,onChange:t,className:n}){const[r,i]=x.useState(!1),[s,a]=x.useState(""),o=e!=null&&Gse.includes(e),l=f=>{e===f?t(null):(t(f),i(!1))},u=()=>{const f=parseInt(s,10);f>=1&&(t(f),i(!1),a(""))},d=f=>{f.key==="Enter"?(f.preventDefault(),u()):f.key==="Escape"&&(i(!1),a(""))};return c.jsxs("div",{className:Ae("flex items-center gap-1",n),children:[Gse.map(f=>c.jsxs("button",{type:"button",onClick:()=>l(f),className:Ae("rounded-md px-2 py-1 text-xs font-medium transition-colors",e===f?"bg-primary text-primary-foreground":"bg-muted/50 text-muted-foreground hover:bg-muted hover:text-foreground"),children:[f,"h"]},f)),r?c.jsx(At,{type:"number",min:1,value:s,onChange:f=>a(f.target.value),onKeyDown:d,onBlur:()=>{s?u():i(!1)},placeholder:"h",className:"w-14 h-7 px-1.5 text-xs text-center",autoFocus:!0}):c.jsx("button",{type:"button",onClick:()=>i(!0),className:Ae("rounded-md px-1.5 py-1 text-xs font-medium transition-colors",e!=null&&!o?"bg-primary text-primary-foreground":"bg-muted/50 text-muted-foreground hover:bg-muted hover:text-foreground"),title:"Custom value",children:e!=null&&!o?`${e}h`:c.jsx(Z,{icon:cze,size:14})}),e!=null&&c.jsx("button",{type:"button",onClick:()=>{t(null),i(!1)},className:"text-muted-foreground hover:text-foreground ml-0.5",title:"Clear estimate",children:c.jsx(Z,{icon:Tn,size:12})})]})}function YW({value:e,onChange:t,className:n}){const{t:r}=Ot("tasks"),i=[{key:"low",label:r("priority.low")},{key:"medium",label:r("priority.medium")},{key:"high",label:r("priority.high")}];return c.jsx("div",{className:Ae("flex items-center gap-1",n),children:i.map(({key:s,label:a})=>c.jsx("button",{type:"button",onClick:()=>t(e===s?null:s),className:Ae("rounded-md px-2 py-1 text-xs font-medium transition-colors",e===s?s==="high"?"bg-destructive text-destructive-foreground":s==="low"?"bg-muted text-foreground ring-1 ring-ring":"bg-primary text-primary-foreground":"bg-muted/50 text-muted-foreground hover:bg-muted hover:text-foreground"),children:a},s))})}function wEe(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function VYe(e){const t=e.trim().split(/\s+/).slice(0,4).join(" "),n=wEe(t);if(!n)return"";const r=Math.random().toString(36).substring(2,6);return`${n}-${r}`}function XW({open:e,onOpenChange:t,defaultRepository:n,showTrigger:r=!0}={}){const{t:i}=Ot("tasks"),{t:s}=Ot("common"),[a,o]=x.useState(!1),l=e??a,u=t??o,[d,f]=x.useState(!1),[h,m]=x.useState(""),[g,y]=x.useState(""),[v,_]=x.useState("worktree"),[S,E]=x.useState(!0),[T,k]=x.useState([]),[w,A]=x.useState(""),[R,I]=x.useState(""),[D,j]=x.useState(null),[F,z]=x.useState("medium"),[P,L]=x.useState(""),[M,$]=x.useState(""),[W,Y]=x.useState(""),[q,K]=x.useState(""),[X,U]=x.useState(""),[J,te]=x.useState(""),[ee,oe]=x.useState(""),[ae,se]=x.useState(""),[ue,de]=x.useState("default"),[ce,Ee]=x.useState(!1),[Ie,fe]=x.useState("claude"),[be,ge]=x.useState(null),[Ce,Re]=x.useState("browse"),[xe,ye]=x.useState(""),[De,ve]=x.useState(null),[Oe,Be]=x.useState(!1),[Te,je]=x.useState(null),[ie,Ke]=x.useState([]),[lt,Rt]=x.useState([]),[Ye,ct]=x.useState(""),[Ve,Et]=x.useState(""),[$e,Qe]=x.useState(""),[pt,at]=x.useState(null),[gt,We]=x.useState([]),[Xe,it]=x.useState(!1),[ot,St]=x.useState(""),[Xt,Vt]=x.useState(!1),[en,Fe]=x.useState(!1),[Ue,ut]=x.useState(!1),Kt=x.useRef(null),wn=x.useRef(null),pr=Ni(),Mr=IWe(),qi=SEe(),na=Twe(),ai=x.useRef(null),Ar=x.useRef(null),mr=x.useRef(!1),{data:Ji}=Iwe(),{data:hi}=XWe(),{data:Bs}=uD(),{data:es}=NC(),{data:ts}=A1(),{data:nt}=Mwe(),{data:Fn}=Fwe(),{data:rn}=Oy(),{data:Yn}=Mc(),{data:Nr,isLoading:oi}=OW(W||null),Jn=be?rn?.find(Le=>Le.id===be):null,Fr=x.useMemo(()=>!be||!Yn?null:Yn.find(Le=>Le.repositories.some(vt=>vt.id===be))??null,[be,Yn]),{data:sr=[]}=NW(w),Br=sr.filter(Le=>!T.includes(Le.name)),Si=sr.find(Le=>Le.name.toLowerCase()===w.toLowerCase()),ml=w.trim()&&!Si&&!T.includes(w.trim()),tn=x.useMemo(()=>{if(!Yn)return[];if(!ot.trim())return Yn;const Le=ot.toLowerCase();return Yn.filter(vt=>vt.name.toLowerCase().includes(Le))},[Yn,ot]),Na=x.useMemo(()=>{if(!rn)return[];if(Jn&&xe===Jn.displayName||!xe.trim())return rn;const Le=xe.toLowerCase();return rn.filter(vt=>vt.displayName.toLowerCase().includes(Le)||vt.path.toLowerCase().includes(Le))},[rn,xe,Jn]),{filteredLocalBranches:ns,filteredRemoteBranches:Oa}=x.useMemo(()=>{const Le=Nr?.branches??[],vt=Nr?.remoteBranches??[];if(!X.trim()||X===q)return{filteredLocalBranches:Le,filteredRemoteBranches:vt};const pn=X.toLowerCase();return{filteredLocalBranches:Le.filter(En=>En.toLowerCase().includes(pn)),filteredRemoteBranches:vt.filter(En=>En.toLowerCase().includes(pn))}},[Nr?.branches,Nr?.remoteBranches,X,q]);x.useEffect(()=>{rn&&rn.length>0?Re("saved"):Re("browse")},[rn]),x.useEffect(()=>{if(!l){mr.current=!1;return}if(mr.current||!rn)return;mr.current=!0,nt&&_(nt),Fn!==void 0&&E(Fn);const Le=n??(rn.length>0?rn[0]:null),vt=Le&&Yn?Yn.find(pn=>pn.repositories.some(En=>En.id===Le.id)):null;if(Le?.defaultAgent?fe(Le.defaultAgent):vt?.defaultAgent?fe(vt.defaultAgent):es&&fe(es),Le?.opencodeModel?je(Le.opencodeModel):vt?.opencodeModel?je(vt.opencodeModel):je(ts||null),n)ge(n.id),Y(n.path),ye(n.displayName),Re("saved");else if(rn.length>0){const pn=rn[0];ge(pn.id),Y(pn.path),ye(pn.displayName),Re("saved")}},[l,n,rn,Yn,es,ts,nt,Fn]),x.useEffect(()=>{if(Nr){const vt=rn?.find(on=>on.id===be)?.lastBaseBranch,pn=[...Nr.branches,...Nr.remoteBranches??[]],En=vt&&pn.includes(vt)?vt:Nr.defaultBranch||Nr.branches[0]||"main";K(En),U(En)}else K(""),U("")},[Nr,W,rn,be]),x.useEffect(()=>{const Le=vt=>{Kt.current&&!Kt.current.contains(vt.target)&&it(!1),wn.current&&!wn.current.contains(vt.target)&&Vt(!1)};return document.addEventListener("mousedown",Le),()=>document.removeEventListener("mousedown",Le)},[]);const nr=Le=>{m(Le),oe(VYe(Le))},Ns=async Le=>{ve(null),Be(!0);try{if(!(await Rwe(Le)).isGitRepo){ve(i("createModal.errors.notGitRepo")),Be(!1);return}Y(Le);const pn=rn?.find(En=>En.path===Le);ge(pn?pn.id:null)}catch(vt){ve(vt instanceof Error?vt.message:i("createModal.errors.validationFailed"))}finally{Be(!1)}},hs=Le=>{if(Le.preventDefault(),!h.trim()||v==="worktree"&&!W)return;const vt=v==="worktree",pn=v==="scratch",En=vt&&S,on=pn&&S,_o=En?W.split("/").pop()||"repo":null,ms=En?J.trim()||ee:null,ra=En&&ms?ae.trim()?`${ae.trim().replace(/\/+$/,"")}/${ms}`:ms:null,gs=En&&ra?`${Ji}/${ra}`:null,zc=wEe(h.trim().split(/\s+/).slice(0,4).join(" ")),bl=Math.random().toString(36).substring(2,6),sc=zc?`${zc}-${bl}`:bl,N=on?`${hi}/${sc}`:null,H=Ie==="claude"?Jn?.claudeOptions??Fr?.claudeOptions:Jn?.opencodeOptions??Fr?.opencodeOptions;Mr.mutate({title:h.trim(),description:g.trim()||void 0,status:En||on?"IN_PROGRESS":"TO_DO",agent:Ie,aiMode:vt||pn?ue:void 0,repoPath:En?W:null,repoName:En?_o:null,baseBranch:vt?q||"main":null,branch:En?ra:null,prefix:vt&&ae.trim()?ae.trim():void 0,worktreePath:En?gs:on?N:null,type:pn?"scratch":vt?"worktree":void 0,repositoryId:vt&&!S?be:void 0,copyFiles:vt&&Jn?.copyFiles||void 0,startupScript:vt&&[Fr?.startupScript,Jn?.startupScript].filter(Boolean).join(`
27
- `)||void 0,agentOptions:(vt||pn)&&H||void 0,opencodeModel:(vt||pn)&&Ie==="opencode"?Te:void 0,tags:T.length>0?T:void 0,dueDate:R||null,timeEstimate:D,priority:F,recurrenceRule:P||null,notes:M.trim()||null,projectId:vt?Fr?.id:pt,prUrl:$e.trim()||null,blockedByTaskIds:gt.length>0?gt:void 0,pinned:en||void 0},{onSuccess:async ne=>{if(ie.length>0)for(const le of ie)try{await qi.mutateAsync({taskId:ne.id,file:le})}catch{}if(lt.length>0)for(const le of lt)try{await na.mutateAsync({taskId:ne.id,url:le.url,label:le.label})}catch{}if(u(!1),Uu(),En||on){const le=g.trim()?{aiMode:ue,description:g.trim(),focusTerminal:!0}:{aiMode:ue,focusTerminal:!0};pr({to:"/tasks/$taskId",params:{taskId:ne.id},state:le})}},onError:ne=>{rt.error(i("createModal.errors.createFailed"),{description:ne instanceof Error?ne.message:String(ne)})}})},Uu=()=>{m(""),y(""),_("worktree"),E(!0),k([]),A(""),I(""),j(null),z("medium"),L(""),$(""),Ke([]),Rt([]),ct(""),Et(""),Qe(""),Y(""),K(""),te(""),oe(""),se(""),de("default"),Ee(!1),fe(es||"claude"),je(null),ge(null),ye(""),ve(null),at(null),We([]),Fe(!1),ut(!1),it(!1),St(""),Vt(!1),Re(rn&&rn.length>0?"saved":"browse")},$o=Le=>{const vt=(Le??w).trim();vt&&!T.includes(vt)&&k([...T,vt]),A(""),it(!1)},Bc=Le=>{k(T.filter(vt=>vt!==Le))},Ra=Le=>{Le.key==="Enter"&&w.trim()?(Le.preventDefault(),Si&&!T.includes(Si.name)?$o(Si.name):ml&&$o(w.trim())):Le.key==="Escape"?(it(!1),A("")):Le.key==="Backspace"&&!w&&T.length>0&&k(T.slice(0,-1))},rs=Le=>{const vt=Le.target.files;vt&&(Ke(pn=>[...pn,...Array.from(vt)]),Le.target.value="")},wi=Le=>{Ke(vt=>vt.filter((pn,En)=>En!==Le))},ps=()=>{const Le=Ye.trim();if(Le){try{new URL(Le)}catch{rt.error(i("createModal.errors.invalidUrl"),{description:i("createModal.errors.invalidUrlDescription")});return}Rt(vt=>[...vt,{url:Le,label:Ve.trim()||void 0}]),ct(""),Et("")}},zo=Le=>{Rt(vt=>vt.filter((pn,En)=>En!==Le))},$c=Le=>{Le.key==="Enter"&&(Le.preventDefault(),ps())},Ia=!Mr.isPending&&!!h.trim()&&(v==="manual"||v==="scratch"||!!W);Ma("meta+enter",()=>{ai.current&&ai.current.requestSubmit()},{enabled:l&&Ia,allowInInput:!0,ignoreContext:!0,deps:[l,Ia]});const to=J.trim()||ee,gl=ae.trim()&&to?`${ae.trim().replace(/\/+$/,"")}/${to}`:to,qt=gl?`${Ji}/${gl}`:"";return c.jsxs(c.Fragment,{children:[c.jsxs(Ya,{open:l,onOpenChange:u,children:[r&&c.jsxs(xUe,{render:c.jsx(_e,{size:"sm"}),children:[c.jsx(Z,{icon:rD,size:16,strokeWidth:2,"data-slot":"icon",className:"-translate-y-px"}),i("newTask")]}),c.jsx(Xa,{className:"sm:max-w-md max-h-[80dvh] flex flex-col overflow-hidden",children:c.jsxs("form",{ref:ai,onSubmit:hs,className:"flex flex-col min-h-0 flex-1",children:[c.jsxs(Lo,{className:"shrink-0 px-3",children:[c.jsx(Mo,{className:"sr-only",children:i("createModal.title")}),c.jsx(AE,{value:[v],onValueChange:Le=>{const vt=Array.isArray(Le)?Le[0]:Le;vt&&(_(vt),vt!=="manual"&&L(""))},className:"h-7 mx-auto",variant:"outline",children:["worktree","scratch","manual"].map(Le=>c.jsx(Ih,{value:Le,className:"h-7 rounded-full px-3 text-xs font-medium",style:v===Le?{backgroundColor:Ewe({type:Le}),color:"white"}:void 0,children:i(`createModal.taskTypes.${Le}`)},Le))}),c.jsx(eg,{className:"mt-2 text-center",children:i(v==="worktree"?"createModal.taskDescriptions.worktree":v==="scratch"?"createModal.taskDescriptions.scratch":"createModal.taskDescriptions.manual")})]}),c.jsxs(qh,{className:"mt-2 py-4 px-3 overflow-y-auto min-h-0 flex-1",children:[c.jsxs($n,{children:[c.jsx(zn,{htmlFor:"title",children:i("createModal.fields.title")}),c.jsxs("div",{className:"flex gap-1.5 items-center",children:[c.jsx(At,{id:"title",value:h,onChange:Le=>nr(Le.target.value),placeholder:i("createModal.fields.titlePlaceholder"),required:!0,autoFocus:!0,className:"flex-1"}),c.jsx(_e,{type:"button",variant:"ghost",size:"icon-sm",className:Ae("shrink-0 cursor-pointer",en?"text-primary":"text-muted-foreground hover:text-foreground"),onClick:()=>Fe(!en),title:i(en?"createModal.unpinTask":"createModal.pinTask"),children:c.jsx(Z,{icon:en?nD:wE,size:16,strokeWidth:2})})]})]}),c.jsxs($n,{children:[c.jsx(zn,{htmlFor:"description",children:i("createModal.fields.description")}),c.jsx(mW,{id:"description",value:g,onValueChange:Le=>{y(Le),!ce&&(v==="worktree"||v==="scratch")&&de(Le.trim()?"plan":"default")},placeholder:i("createModal.fields.descriptionPlaceholder"),rows:2})]}),(v==="worktree"||v==="scratch")&&c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.aiMode")}),c.jsxs(AE,{value:[ue],onValueChange:Le=>{const vt=Array.isArray(Le)?Le[0]:Le;vt&&(de(vt),Ee(!0))},className:"w-full",variant:"outline",children:[c.jsx(Ih,{value:"plan",className:"flex-1",children:i("createModal.aiModes.plan")}),c.jsx(Ih,{value:"default",className:"flex-1",children:i("createModal.aiModes.default")})]})]}),(v==="manual"||v==="scratch")&&c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.project")}),c.jsxs("div",{className:"relative",ref:wn,children:[c.jsx(At,{value:pt?Yn?.find(Le=>Le.id===pt)?.name||"":ot,onChange:Le=>{St(Le.target.value),at(null),Vt(!0)},onFocus:()=>Vt(!0),onKeyDown:Le=>{Le.key==="Escape"&&Vt(!1)},placeholder:i("createModal.noProject"),className:"w-full"}),Xt&&c.jsxs("div",{className:"absolute top-full left-0 right-0 mt-1 bg-popover border rounded-md shadow-lg z-50 max-h-48 overflow-y-auto",children:[c.jsxs("button",{type:"button",className:Ae("group w-full px-3 py-2 text-left text-sm hover:bg-accent hover:text-accent-foreground flex items-center justify-between",pt===null&&"bg-accent text-accent-foreground"),onClick:()=>{at(null),St(""),Vt(!1)},children:[c.jsx("span",{className:Ae("text-muted-foreground group-hover:text-accent-foreground",pt===null&&"text-accent-foreground"),children:i("createModal.noProject")}),pt===null&&c.jsx(Z,{icon:Q_e,size:14,className:"text-primary"})]}),tn.map(Le=>c.jsxs("button",{type:"button",className:Ae("group w-full px-3 py-2 text-left text-sm hover:bg-accent hover:text-accent-foreground flex items-center justify-between",pt===Le.id&&"bg-accent text-accent-foreground"),onClick:()=>{at(Le.id),St(""),Vt(!1)},children:[c.jsx("span",{children:Le.name}),c.jsxs("span",{className:Ae("text-xs text-muted-foreground group-hover:text-accent-foreground",pt===Le.id&&"text-accent-foreground"),children:[Le.taskCount??0," tasks"]})]},Le.id)),tn.length===0&&ot&&c.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"No projects found"})]})]}),c.jsx(Pi,{children:i("createModal.projectHint")})]}),v==="worktree"&&c.jsxs(c.Fragment,{children:[c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.repository")}),c.jsxs(nl,{value:Ce,onValueChange:Le=>{Re(Le),ve(null)},children:[c.jsxs(rl,{children:[c.jsx(In,{value:"saved",disabled:!rn?.length,children:i("createModal.tabs.saved")}),c.jsx(In,{value:"browse",children:i("createModal.tabs.browse")})]}),c.jsx(jn,{value:"saved",className:"mt-2",children:c.jsxs(ox,{value:be||"",onValueChange:Le=>{const vt=rn?.find(pn=>pn.id===Le);if(vt){ge(Le),Y(vt.path),ye(vt.displayName),ve(null);const pn=Yn?.find(En=>En.repositories.some(on=>on.id===Le));vt.defaultAgent?fe(vt.defaultAgent):pn?.defaultAgent&&fe(pn.defaultAgent),je(vt.opencodeModel??pn?.opencodeModel??ts??null)}},inputValue:xe,onInputValueChange:Le=>{ye(Le)},itemToStringLabel:Le=>rn?.find(vt=>vt.id===Le)?.displayName||"",children:[c.jsx(lx,{placeholder:i("createModal.searchRepositories"),className:"w-full"}),c.jsx(cx,{children:c.jsxs(ux,{children:[c.jsx(dx,{children:i("createModal.noRepositoriesFound")}),Na.map(Le=>c.jsx(Rh,{value:Le.id,children:Le.displayName},Le.id))]})})]})}),c.jsx(jn,{value:"browse",className:"mt-2",children:c.jsxs(_e,{type:"button",variant:"outline",className:"w-full justify-start font-normal",onClick:()=>f(!0),disabled:Oe,children:[c.jsx(Z,{icon:Zs,size:14,strokeWidth:2,className:"mr-2"}),Oe?c.jsx("span",{className:"text-muted-foreground",children:s("status.validating")}):W&&!be?c.jsx("span",{className:"truncate",children:W}):c.jsx("span",{className:"text-muted-foreground group-hover/button:text-accent-foreground",children:i("createModal.selectFolder")})]})})]}),De&&c.jsx("p",{className:"text-sm text-destructive",children:De}),W&&!De&&c.jsx(Pi,{className:"font-mono text-xs truncate",children:W})]}),c.jsxs($n,{children:[c.jsx(zn,{htmlFor:"baseBranch",children:i("createModal.fields.baseBranch")}),c.jsxs(ox,{value:q,onValueChange:Le=>{K(Le??""),U(Le??"")},inputValue:X,onInputValueChange:U,itemToStringLabel:Le=>Le,children:[c.jsx(lx,{disabled:!W||oi,placeholder:i(W?oi?"createModal.loadingBranches":"createModal.selectBranch":"createModal.selectRepositoryFirst"),className:"w-full"}),c.jsx(cx,{children:c.jsxs(ux,{children:[c.jsx(dx,{children:i("createModal.noBranchesFound")}),ns.length>0&&c.jsxs(kE,{children:[Oa.length>0&&c.jsx(TE,{children:"Local"}),ns.map(Le=>c.jsxs(Rh,{value:Le,children:[Le,Le===Nr?.current&&c.jsx("span",{className:"text-muted-foreground ml-2",children:i("createModal.current")})]},Le))]}),Oa.length>0&&c.jsxs(kE,{children:[c.jsx(TE,{children:"Remote"}),Oa.map(Le=>c.jsx(Rh,{value:Le,children:Le},Le))]})]})})]})]})]}),c.jsxs("button",{type:"button",className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors -mx-0.5",onClick:()=>ut(!Ue),children:[c.jsx(Z,{icon:Ts,size:14,strokeWidth:2,className:Ae("transition-transform",Ue&&"rotate-180")}),i("createModal.advanced")]}),Ue&&c.jsxs(c.Fragment,{children:[v==="worktree"&&c.jsxs(c.Fragment,{children:[c.jsxs($n,{children:[c.jsx(zn,{htmlFor:"prefix",children:i("createModal.fields.prefix")}),c.jsx(At,{id:"prefix",value:ae,onChange:Le=>se(Le.target.value),placeholder:i("createModal.fields.prefixPlaceholder")}),c.jsx(Pi,{children:i("createModal.prefixHint")})]}),c.jsxs($n,{children:[c.jsx(zn,{htmlFor:"branch",children:i("createModal.fields.branchName")}),c.jsx(At,{id:"branch",value:J,onChange:Le=>te(Le.target.value),placeholder:ee||i("createModal.fields.branchPlaceholder")}),qt&&c.jsxs(Pi,{children:[i("createModal.worktreePrefix")," ",qt]}),!J.trim()&&ee&&c.jsx(Pi,{children:i("createModal.branchAutoGenerated",{branch:ee})})]})]}),(v==="worktree"||v==="scratch")&&c.jsxs(c.Fragment,{children:[c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.agent")}),c.jsxs(Qr,{value:Ie,onValueChange:Le=>fe(Le),children:[c.jsx(Jr,{className:"w-full",children:c.jsx(Zr,{})}),c.jsx(ei,{children:Object.keys(Io).map(Le=>c.jsx(jt,{value:Le,children:Io[Le]},Le))})]})]}),Ie==="opencode"&&c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.opencodeModel")}),c.jsx(Bb,{value:Te,onChange:je,placeholder:i("createModal.fields.opencodeModelPlaceholder")})]})]}),c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.estimate")}),c.jsx(KW,{value:D,onChange:j})]}),c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.priority")}),c.jsx(YW,{value:F,onChange:Le=>z(Le??"medium")})]}),c.jsxs("div",{className:"flex gap-3",children:[c.jsxs($n,{className:"flex-1",children:[c.jsx(zn,{htmlFor:"tags",children:i("createModal.fields.tags")}),c.jsxs("div",{className:"relative",ref:Kt,children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-1 rounded-md border border-input bg-background px-2 py-1.5 min-h-[36px]",children:[T.map(Le=>c.jsxs("span",{className:"inline-flex items-center gap-0.5 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium",children:[Le,c.jsx("button",{type:"button",onClick:()=>Bc(Le),className:"text-muted-foreground hover:text-foreground",children:c.jsx(Z,{icon:Tn,size:10})})]},Le)),c.jsx("input",{id:"tags",type:"text",value:w,onChange:Le=>{A(Le.target.value),it(!0)},onFocus:()=>it(!0),onKeyDown:Ra,placeholder:T.length===0?i("createModal.fields.tagsPlaceholder"):"",className:"flex-1 min-w-[60px] bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),Xe&&(w||Br.length>0)&&c.jsxs("div",{className:"absolute top-full left-0 right-0 mt-1 bg-popover border rounded-md shadow-lg z-50 max-h-48 overflow-y-auto",children:[Br.map(Le=>c.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm hover:bg-accent flex items-center justify-between",onClick:()=>$o(Le.name),children:[c.jsx("span",{children:Le.name}),c.jsxs("span",{className:"text-xs text-muted-foreground",children:[Le.taskCount+Le.projectCount," uses"]})]},Le.id)),ml&&c.jsxs("button",{type:"button",className:Ae("w-full px-3 py-2 text-left text-sm hover:bg-accent flex items-center gap-2",Br.length>0&&"border-t"),onClick:()=>$o(w.trim()),children:[c.jsx(Z,{icon:Ic,size:14}),c.jsxs("span",{children:['Create "',w.trim(),'"']})]}),!ml&&Br.length===0&&w&&c.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"No matching tags"})]})]})]}),c.jsxs($n,{className:"w-40",children:[c.jsx(zn,{children:i("createModal.fields.dueDate")}),c.jsx(GW,{value:R||null,onChange:Le=>I(Le||""),placeholder:i("createModal.fields.dueDatePlaceholder"),showClear:!0,className:"border border-input rounded-md px-3 py-2 w-full justify-start"})]}),v==="manual"&&c.jsxs($n,{className:"w-32",children:[c.jsx(zn,{children:i("createModal.fields.repeat")}),c.jsxs(Qr,{value:P||"none",onValueChange:Le=>L(Le==="none"?"":Le),children:[c.jsx(Jr,{className:"w-full !h-auto py-2",children:c.jsx(Zr,{})}),c.jsxs(ei,{children:[c.jsx(jt,{value:"none",children:i("createModal.recurrence.none")}),c.jsx(jt,{value:"daily",children:i("createModal.recurrence.daily")}),c.jsx(jt,{value:"weekly",children:i("createModal.recurrence.weekly")}),c.jsx(jt,{value:"biweekly",children:i("createModal.recurrence.biweekly")}),c.jsx(jt,{value:"monthly",children:i("createModal.recurrence.monthly")}),c.jsx(jt,{value:"quarterly",children:i("createModal.recurrence.quarterly")}),c.jsx(jt,{value:"yearly",children:i("createModal.recurrence.yearly")})]})]})]})]}),c.jsxs($n,{children:[c.jsx(zn,{htmlFor:"notes",children:i("createModal.fields.notes")}),c.jsx("textarea",{id:"notes",value:M,onChange:Le=>$(Le.target.value),placeholder:i("createModal.fields.notesPlaceholder"),rows:2,className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none"})]}),c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.blockedBy")}),c.jsx(HYe,{selectedIds:gt,onSelectionChange:We}),c.jsx(Pi,{children:i("createModal.blockedByHint")})]}),c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.links")}),c.jsxs("div",{className:"space-y-2",children:[lt.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1",children:lt.map((Le,vt)=>c.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-border bg-card px-1.5 py-0.5 text-xs",children:[c.jsx(Z,{icon:Ay,size:10,className:"shrink-0"}),c.jsx("span",{className:"truncate max-w-[150px]",children:Le.label||Le.url}),c.jsx("button",{type:"button",onClick:()=>zo(vt),className:"text-muted-foreground hover:text-foreground",children:c.jsx(Z,{icon:Tn,size:10})})]},`${Le.url}-${vt}`))}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(At,{type:"url",value:Ye,onChange:Le=>ct(Le.target.value),onKeyDown:$c,placeholder:i("createModal.fields.urlPlaceholder"),className:"flex-1 h-8 text-sm"}),c.jsx(At,{type:"text",value:Ve,onChange:Le=>Et(Le.target.value),onKeyDown:$c,placeholder:i("createModal.fields.linkLabelPlaceholder"),className:"w-28 h-8 text-sm"}),c.jsx(_e,{type:"button",variant:"outline",size:"sm",className:"h-8 px-2",onClick:ps,disabled:!Ye.trim(),children:c.jsx(Z,{icon:Ic,size:14})})]})]})]}),c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.prUrl")}),c.jsx(At,{type:"url",value:$e,onChange:Le=>Qe(Le.target.value),placeholder:i("createModal.fields.prUrlPlaceholder"),className:"h-8 text-sm"})]}),c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.attachments")}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("input",{ref:Ar,type:"file",multiple:!0,className:"hidden",onChange:rs,accept:".pdf,.png,.jpg,.jpeg,.gif,.webp,.svg,.txt,.md,.doc,.docx,.xls,.xlsx,.csv"}),c.jsxs(_e,{type:"button",variant:"outline",size:"sm",className:"w-full justify-start text-muted-foreground",onClick:()=>Ar.current?.click(),children:[c.jsx(Z,{icon:W$e,size:14,className:"mr-2"}),ie.length===0?i("createModal.fields.addAttachments"):i("createModal.fields.addMoreFiles")]}),ie.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1",children:ie.map((Le,vt)=>c.jsxs("span",{className:"inline-flex items-center gap-0.5 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium",children:[Le.name,c.jsx("button",{type:"button",onClick:()=>wi(vt),className:"text-muted-foreground hover:text-foreground",children:c.jsx(Z,{icon:Tn,size:10})})]},`${Le.name}-${vt}`))})]})]})]})]}),c.jsxs(wC,{className:"mt-4 shrink-0 px-3",children:[(v==="worktree"||v==="scratch")&&c.jsxs("label",{className:"flex items-center gap-2 mr-auto cursor-pointer",children:[c.jsx(Xr,{checked:S,onCheckedChange:E,size:"sm"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:i("createModal.startImmediately")})]}),c.jsx(SC,{render:c.jsx(_e,{variant:"outline",type:"button",className:"border-destructive text-destructive hover:bg-destructive hover:text-white"}),children:s("buttons.cancel")}),c.jsx(_e,{type:"submit",disabled:!Ia,children:Mr.isPending?s("status.creating"):i("createModal.createTask")})]})]})})]}),c.jsx(yh,{open:d,onOpenChange:f,onSelect:Ns,initialPath:Bs||void 0})]})}function lr(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];throw new Error(typeof e=="number"?"[MobX] minified error nr: "+e+(n.length?" "+n.map(String).join(","):"")+". Find the full error at: https://github.com/mobxjs/mobx/blob/main/packages/mobx/src/errors.ts":"[MobX] "+e)}var WYe={};function xD(){return typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:WYe}var EEe=Object.assign,YO=Object.getOwnPropertyDescriptor,ff=Object.defineProperty,_D=Object.prototype,E$=[];Object.freeze(E$);var QW={};Object.freeze(QW);var qYe=typeof Proxy<"u",GYe=Object.toString();function CEe(){qYe||lr("Proxy not available")}function kEe(e){var t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}var b0=function(){};function jc(e){return typeof e=="function"}function oy(e){var t=typeof e;switch(t){case"string":case"symbol":case"number":return!0}return!1}function SD(e){return e!==null&&typeof e=="object"}function Hm(e){if(!SD(e))return!1;var t=Object.getPrototypeOf(e);if(t==null)return!0;var n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n.toString()===GYe}function TEe(e){var t=e?.constructor;return t?t.name==="GeneratorFunction"||t.displayName==="GeneratorFunction":!1}function wD(e,t,n){ff(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function AEe(e,t,n){ff(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}function rg(e,t){var n="isMobX"+e;return t.prototype[n]=!0,function(r){return SD(r)&&r[n]===!0}}function D1(e){return e!=null&&Object.prototype.toString.call(e)==="[object Map]"}function KYe(e){var t=Object.getPrototypeOf(e),n=Object.getPrototypeOf(t),r=Object.getPrototypeOf(n);return r===null}function hh(e){return e!=null&&Object.prototype.toString.call(e)==="[object Set]"}var NEe=typeof Object.getOwnPropertySymbols<"u";function YYe(e){var t=Object.keys(e);if(!NEe)return t;var n=Object.getOwnPropertySymbols(e);return n.length?[].concat(t,n.filter(function(r){return _D.propertyIsEnumerable.call(e,r)})):t}var ED=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:NEe?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames;function OEe(e){return e===null?null:typeof e=="object"?""+e:e}function Dh(e,t){return _D.hasOwnProperty.call(e,t)}var XYe=Object.getOwnPropertyDescriptors||function(t){var n={};return ED(t).forEach(function(r){n[r]=YO(t,r)}),n};function Tc(e,t){return!!(e&t)}function Ac(e,t,n){return n?e|=t:e&=~t,e}function Kse(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function QYe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,JYe(r.key),r)}}function j1(e,t,n){return t&&QYe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function y0(e,t){var n=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=eXe(e))||t){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
27
+ `)||void 0,agentOptions:(vt||pn)&&H||void 0,opencodeModel:(vt||pn)&&Ie==="opencode"?Te:void 0,tags:T.length>0?T:void 0,dueDate:R||null,timeEstimate:D,priority:F,recurrenceRule:P||null,notes:M.trim()||null,projectId:vt?Fr?.id:pt,prUrl:$e.trim()||null,blockedByTaskIds:gt.length>0?gt:void 0,pinned:en||void 0},{onSuccess:async ne=>{if(ie.length>0)for(const le of ie)try{await qi.mutateAsync({taskId:ne.id,file:le})}catch{}if(lt.length>0)for(const le of lt)try{await na.mutateAsync({taskId:ne.id,url:le.url,label:le.label})}catch{}if(u(!1),Uu(),En||on){const le=g.trim()?{aiMode:ue,description:g.trim(),focusTerminal:!0}:{aiMode:ue,focusTerminal:!0};pr({to:"/tasks/$taskId",params:{taskId:ne.id},state:le})}},onError:ne=>{rt.error(i("createModal.errors.createFailed"),{description:ne instanceof Error?ne.message:String(ne)})}})},Uu=()=>{m(""),y(""),_("worktree"),E(!0),k([]),A(""),I(""),j(null),z("medium"),L(""),$(""),Ke([]),Rt([]),ct(""),Et(""),Qe(""),Y(""),K(""),te(""),oe(""),se(""),de("default"),Ee(!1),fe(es||"claude"),je(null),ge(null),ye(""),ve(null),at(null),We([]),Fe(!1),ut(!1),it(!1),St(""),Vt(!1),Re(rn&&rn.length>0?"saved":"browse")},$o=Le=>{const vt=(Le??w).trim();vt&&!T.includes(vt)&&k([...T,vt]),A(""),it(!1)},Bc=Le=>{k(T.filter(vt=>vt!==Le))},Ra=Le=>{Le.key==="Enter"&&w.trim()?(Le.preventDefault(),Si&&!T.includes(Si.name)?$o(Si.name):ml&&$o(w.trim())):Le.key==="Escape"?(it(!1),A("")):Le.key==="Backspace"&&!w&&T.length>0&&k(T.slice(0,-1))},rs=Le=>{const vt=Le.target.files;vt&&(Ke(pn=>[...pn,...Array.from(vt)]),Le.target.value="")},wi=Le=>{Ke(vt=>vt.filter((pn,En)=>En!==Le))},ps=()=>{const Le=Ye.trim();if(Le){try{new URL(Le)}catch{rt.error(i("createModal.errors.invalidUrl"),{description:i("createModal.errors.invalidUrlDescription")});return}Rt(vt=>[...vt,{url:Le,label:Ve.trim()||void 0}]),ct(""),Et("")}},zo=Le=>{Rt(vt=>vt.filter((pn,En)=>En!==Le))},$c=Le=>{Le.key==="Enter"&&(Le.preventDefault(),ps())},Ia=!Mr.isPending&&!!h.trim()&&(v==="manual"||v==="scratch"||!!W);Ma("meta+enter",()=>{ai.current&&ai.current.requestSubmit()},{enabled:l&&Ia,allowInInput:!0,ignoreContext:!0,deps:[l,Ia]});const to=J.trim()||ee,gl=ae.trim()&&to?`${ae.trim().replace(/\/+$/,"")}/${to}`:to,qt=gl?`${Ji}/${gl}`:"";return c.jsxs(c.Fragment,{children:[c.jsxs(Ya,{open:l,onOpenChange:u,children:[r&&c.jsxs(xUe,{render:c.jsx(_e,{size:"sm"}),children:[c.jsx(Z,{icon:rD,size:16,strokeWidth:2,"data-slot":"icon",className:"-translate-y-px"}),i("newTask")]}),c.jsx(Xa,{className:"sm:max-w-md max-h-[80dvh] flex flex-col overflow-hidden",children:c.jsxs("form",{ref:ai,onSubmit:hs,className:"flex flex-col min-h-0 flex-1",children:[c.jsxs(Lo,{className:"shrink-0 px-3",children:[c.jsx(Mo,{className:"sr-only",children:i("createModal.title")}),c.jsx(AE,{value:[v],onValueChange:Le=>{const vt=Array.isArray(Le)?Le[0]:Le;vt&&(_(vt),vt!=="manual"&&L(""))},className:"h-7 mx-auto",variant:"outline",children:["worktree","scratch","manual"].map(Le=>c.jsx(Ih,{value:Le,className:"h-7 rounded-full px-3 text-xs font-medium",style:v===Le?{backgroundColor:Ewe({type:Le}),color:"white"}:void 0,children:i(`createModal.taskTypes.${Le}`)},Le))}),c.jsx(eg,{className:"mt-2 text-center",children:i(v==="worktree"?"createModal.taskDescriptions.worktree":v==="scratch"?"createModal.taskDescriptions.scratch":"createModal.taskDescriptions.manual")})]}),c.jsxs(qh,{className:"mt-2 py-4 px-3 overflow-y-auto min-h-0 flex-1",children:[c.jsxs($n,{children:[c.jsx(zn,{htmlFor:"title",children:i("createModal.fields.title")}),c.jsxs("div",{className:"flex gap-1.5 items-center",children:[c.jsx(At,{id:"title",value:h,onChange:Le=>nr(Le.target.value),placeholder:i("createModal.fields.titlePlaceholder"),required:!0,autoFocus:!0,className:"flex-1"}),c.jsx(_e,{type:"button",variant:"ghost",size:"icon-sm",className:Ae("shrink-0 cursor-pointer",en?"text-primary":"text-muted-foreground hover:text-foreground"),onClick:()=>Fe(!en),title:i(en?"createModal.unpinTask":"createModal.pinTask"),children:c.jsx(Z,{icon:en?nD:wE,size:16,strokeWidth:2})})]})]}),c.jsxs($n,{children:[c.jsx(zn,{htmlFor:"description",children:i("createModal.fields.description")}),c.jsx(mW,{id:"description",value:g,onValueChange:Le=>{y(Le),!ce&&(v==="worktree"||v==="scratch")&&de(Le.trim()?"plan":"default")},placeholder:i("createModal.fields.descriptionPlaceholder"),rows:2})]}),(v==="worktree"||v==="scratch")&&c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.aiMode")}),c.jsxs(AE,{value:[ue],onValueChange:Le=>{const vt=Array.isArray(Le)?Le[0]:Le;vt&&(de(vt),Ee(!0))},className:"w-full",variant:"outline",children:[c.jsx(Ih,{value:"plan",className:"flex-1",children:i("createModal.aiModes.plan")}),c.jsx(Ih,{value:"default",className:"flex-1",children:i("createModal.aiModes.default")})]})]}),(v==="manual"||v==="scratch")&&c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.project")}),c.jsxs("div",{className:"relative",ref:wn,children:[c.jsx(At,{value:pt?Yn?.find(Le=>Le.id===pt)?.name||"":ot,onChange:Le=>{St(Le.target.value),at(null),Vt(!0)},onFocus:()=>Vt(!0),onKeyDown:Le=>{Le.key==="Escape"&&Vt(!1)},placeholder:i("createModal.noProject"),className:"w-full"}),Xt&&c.jsxs("div",{className:"absolute top-full left-0 right-0 mt-1 bg-popover border rounded-md shadow-lg z-50 max-h-48 overflow-y-auto",children:[c.jsxs("button",{type:"button",className:Ae("group w-full px-3 py-2 text-left text-sm hover:bg-accent hover:text-accent-foreground flex items-center justify-between",pt===null&&"bg-accent text-accent-foreground"),onClick:()=>{at(null),St(""),Vt(!1)},children:[c.jsx("span",{className:Ae("text-muted-foreground group-hover:text-accent-foreground",pt===null&&"text-accent-foreground"),children:i("createModal.noProject")}),pt===null&&c.jsx(Z,{icon:Q_e,size:14,className:"text-primary"})]}),tn.map(Le=>c.jsxs("button",{type:"button",className:Ae("group w-full px-3 py-2 text-left text-sm hover:bg-accent hover:text-accent-foreground flex items-center justify-between",pt===Le.id&&"bg-accent text-accent-foreground"),onClick:()=>{at(Le.id),St(""),Vt(!1)},children:[c.jsx("span",{children:Le.name}),c.jsxs("span",{className:Ae("text-xs text-muted-foreground group-hover:text-accent-foreground",pt===Le.id&&"text-accent-foreground"),children:[Le.taskCount??0," tasks"]})]},Le.id)),tn.length===0&&ot&&c.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"No projects found"})]})]}),c.jsx(Pi,{children:i("createModal.projectHint")})]}),v==="worktree"&&c.jsxs(c.Fragment,{children:[c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.repository")}),c.jsxs(nl,{value:Ce,onValueChange:Le=>{Re(Le),ve(null)},children:[c.jsxs(rl,{children:[c.jsx(In,{value:"saved",disabled:!rn?.length,children:i("createModal.tabs.saved")}),c.jsx(In,{value:"browse",children:i("createModal.tabs.browse")})]}),c.jsx(jn,{value:"saved",className:"mt-2",children:c.jsxs(ox,{value:be||"",onValueChange:Le=>{const vt=rn?.find(pn=>pn.id===Le);if(vt){ge(Le),Y(vt.path),ye(vt.displayName),ve(null);const pn=Yn?.find(En=>En.repositories.some(on=>on.id===Le));vt.defaultAgent?fe(vt.defaultAgent):pn?.defaultAgent&&fe(pn.defaultAgent),je(vt.opencodeModel??pn?.opencodeModel??ts??null)}},inputValue:xe,onInputValueChange:Le=>{ye(Le)},itemToStringLabel:Le=>rn?.find(vt=>vt.id===Le)?.displayName||"",children:[c.jsx(lx,{placeholder:i("createModal.searchRepositories"),className:"w-full"}),c.jsx(cx,{children:c.jsxs(ux,{children:[c.jsx(dx,{children:i("createModal.noRepositoriesFound")}),Na.map(Le=>c.jsx(Rh,{value:Le.id,children:Le.displayName},Le.id))]})})]})}),c.jsx(jn,{value:"browse",className:"mt-2",children:c.jsxs(_e,{type:"button",variant:"outline",className:"w-full justify-start font-normal",onClick:()=>f(!0),disabled:Oe,children:[c.jsx(Z,{icon:Zs,size:14,strokeWidth:2,className:"mr-2"}),Oe?c.jsx("span",{className:"text-muted-foreground",children:s("status.validating")}):W&&!be?c.jsx("span",{className:"truncate",children:W}):c.jsx("span",{className:"text-muted-foreground group-hover/button:text-accent-foreground",children:i("createModal.selectFolder")})]})})]}),De&&c.jsx("p",{className:"text-sm text-destructive",children:De}),W&&!De&&c.jsx(Pi,{className:"font-mono text-xs truncate",children:W})]}),c.jsxs($n,{children:[c.jsx(zn,{htmlFor:"baseBranch",children:i("createModal.fields.baseBranch")}),c.jsxs(ox,{value:q,onValueChange:Le=>{K(Le??""),U(Le??"")},inputValue:X,onInputValueChange:U,itemToStringLabel:Le=>Le,children:[c.jsx(lx,{disabled:!W||oi,placeholder:i(W?oi?"createModal.loadingBranches":"createModal.selectBranch":"createModal.selectRepositoryFirst"),className:"w-full"}),c.jsx(cx,{children:c.jsxs(ux,{children:[c.jsx(dx,{children:i("createModal.noBranchesFound")}),ns.length>0&&c.jsxs(kE,{children:[Oa.length>0&&c.jsx(TE,{children:"Local"}),ns.map(Le=>c.jsxs(Rh,{value:Le,children:[Le,Le===Nr?.current&&c.jsx("span",{className:"text-muted-foreground ml-2",children:i("createModal.current")})]},Le))]}),Oa.length>0&&c.jsxs(kE,{children:[c.jsx(TE,{children:"Remote"}),Oa.map(Le=>c.jsx(Rh,{value:Le,children:Le},Le))]})]})})]})]})]}),c.jsxs("button",{type:"button",className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors -mx-0.5",onClick:()=>ut(!Ue),children:[c.jsx(Z,{icon:Ts,size:14,strokeWidth:2,className:Ae("transition-transform",Ue&&"rotate-180")}),i("createModal.advanced")]}),Ue&&c.jsxs(c.Fragment,{children:[v==="worktree"&&c.jsxs(c.Fragment,{children:[c.jsxs($n,{children:[c.jsx(zn,{htmlFor:"prefix",children:i("createModal.fields.prefix")}),c.jsx(At,{id:"prefix",value:ae,onChange:Le=>se(Le.target.value),placeholder:i("createModal.fields.prefixPlaceholder")}),c.jsx(Pi,{children:i("createModal.prefixHint")})]}),c.jsxs($n,{children:[c.jsx(zn,{htmlFor:"branch",children:i("createModal.fields.branchName")}),c.jsx(At,{id:"branch",value:J,onChange:Le=>te(Le.target.value),placeholder:ee||i("createModal.fields.branchPlaceholder")}),qt&&c.jsxs(Pi,{children:[i("createModal.worktreePrefix")," ",qt]}),!J.trim()&&ee&&c.jsx(Pi,{children:i("createModal.branchAutoGenerated",{branch:ee})})]})]}),(v==="worktree"||v==="scratch")&&c.jsxs(c.Fragment,{children:[c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.agent")}),c.jsxs(Qr,{value:Ie,onValueChange:Le=>fe(Le),children:[c.jsx(Jr,{className:"w-full",children:c.jsx(Zr,{})}),c.jsx(ei,{children:Object.keys(Io).map(Le=>c.jsx(jt,{value:Le,children:Io[Le]},Le))})]})]}),Ie==="opencode"&&c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.opencodeModel")}),c.jsx(Bb,{value:Te,onChange:je,placeholder:i("createModal.fields.opencodeModelPlaceholder")})]})]}),c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.estimate")}),c.jsx(KW,{value:D,onChange:j})]}),c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.priority")}),c.jsx(YW,{value:F,onChange:Le=>z(Le??"medium")})]}),c.jsxs("div",{className:"flex gap-3",children:[c.jsxs($n,{className:"flex-1",children:[c.jsx(zn,{htmlFor:"tags",children:i("createModal.fields.tags")}),c.jsxs("div",{className:"relative",ref:Kt,children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-1 rounded-md border border-input bg-background px-2 py-1.5 min-h-[36px]",children:[T.map(Le=>c.jsxs("span",{className:"inline-flex items-center gap-0.5 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium",children:[Le,c.jsx("button",{type:"button",onClick:()=>Bc(Le),className:"text-muted-foreground hover:text-foreground",children:c.jsx(Z,{icon:Tn,size:10})})]},Le)),c.jsx("input",{id:"tags",type:"text",value:w,onChange:Le=>{A(Le.target.value),it(!0)},onFocus:()=>it(!0),onKeyDown:Ra,placeholder:T.length===0?i("createModal.fields.tagsPlaceholder"):"",className:"flex-1 min-w-[60px] bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),Xe&&(w||Br.length>0)&&c.jsxs("div",{className:"absolute top-full left-0 right-0 mt-1 bg-popover border rounded-md shadow-lg z-50 max-h-48 overflow-y-auto",children:[Br.map(Le=>c.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm hover:bg-accent flex items-center justify-between",onClick:()=>$o(Le.name),children:[c.jsx("span",{children:Le.name}),c.jsxs("span",{className:"text-xs text-muted-foreground",children:[Le.taskCount+Le.projectCount," uses"]})]},Le.id)),ml&&c.jsxs("button",{type:"button",className:Ae("w-full px-3 py-2 text-left text-sm hover:bg-accent flex items-center gap-2",Br.length>0&&"border-t"),onClick:()=>$o(w.trim()),children:[c.jsx(Z,{icon:Ic,size:14}),c.jsxs("span",{children:['Create "',w.trim(),'"']})]}),!ml&&Br.length===0&&w&&c.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"No matching tags"})]})]})]}),c.jsxs($n,{className:"w-40",children:[c.jsx(zn,{children:i("createModal.fields.dueDate")}),c.jsx(GW,{value:R||null,onChange:Le=>I(Le||""),placeholder:i("createModal.fields.dueDatePlaceholder"),showClear:!0,className:"border border-input rounded-md px-3 py-2 w-full justify-start"})]}),v==="manual"&&c.jsxs($n,{className:"w-32",children:[c.jsx(zn,{children:i("createModal.fields.repeat")}),c.jsxs(Qr,{value:P||"none",onValueChange:Le=>L(Le==="none"?"":Le),children:[c.jsx(Jr,{className:"w-full !h-auto py-2",children:c.jsx(Zr,{})}),c.jsxs(ei,{children:[c.jsx(jt,{value:"none",children:i("createModal.recurrence.none")}),c.jsx(jt,{value:"daily",children:i("createModal.recurrence.daily")}),c.jsx(jt,{value:"weekly",children:i("createModal.recurrence.weekly")}),c.jsx(jt,{value:"biweekly",children:i("createModal.recurrence.biweekly")}),c.jsx(jt,{value:"monthly",children:i("createModal.recurrence.monthly")}),c.jsx(jt,{value:"quarterly",children:i("createModal.recurrence.quarterly")}),c.jsx(jt,{value:"yearly",children:i("createModal.recurrence.yearly")})]})]})]})]}),c.jsxs($n,{children:[c.jsx(zn,{htmlFor:"notes",children:i("createModal.fields.notes")}),c.jsx("textarea",{id:"notes",value:M,onChange:Le=>$(Le.target.value),placeholder:i("createModal.fields.notesPlaceholder"),rows:2,className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none"})]}),c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.blockedBy")}),c.jsx(HYe,{selectedIds:gt,onSelectionChange:We}),c.jsx(Pi,{children:i("createModal.blockedByHint")})]}),c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.links")}),c.jsxs("div",{className:"space-y-2",children:[lt.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1",children:lt.map((Le,vt)=>c.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-border bg-card px-1.5 py-0.5 text-xs",children:[c.jsx(Z,{icon:Ay,size:10,className:"shrink-0"}),c.jsx("span",{className:"truncate max-w-[150px]",children:Le.label||Le.url}),c.jsx("button",{type:"button",onClick:()=>zo(vt),className:"text-muted-foreground hover:text-foreground",children:c.jsx(Z,{icon:Tn,size:10})})]},`${Le.url}-${vt}`))}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(At,{type:"url",value:Ye,onChange:Le=>ct(Le.target.value),onKeyDown:$c,placeholder:i("createModal.fields.urlPlaceholder"),className:"flex-1 h-8 text-sm"}),c.jsx(At,{type:"text",value:Ve,onChange:Le=>Et(Le.target.value),onKeyDown:$c,placeholder:i("createModal.fields.linkLabelPlaceholder"),className:"w-28 h-8 text-sm"}),c.jsx(_e,{type:"button",variant:"outline",size:"sm",className:"h-8 px-2",onClick:ps,disabled:!Ye.trim(),children:c.jsx(Z,{icon:Ic,size:14})})]})]})]}),c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.prUrl")}),c.jsx(At,{type:"url",value:$e,onChange:Le=>Qe(Le.target.value),placeholder:i("createModal.fields.prUrlPlaceholder"),className:"h-8 text-sm"})]}),c.jsxs($n,{children:[c.jsx(zn,{children:i("createModal.fields.attachments")}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("input",{ref:Ar,type:"file",multiple:!0,className:"hidden",onChange:rs}),c.jsxs(_e,{type:"button",variant:"outline",size:"sm",className:"w-full justify-start text-muted-foreground",onClick:()=>Ar.current?.click(),children:[c.jsx(Z,{icon:W$e,size:14,className:"mr-2"}),ie.length===0?i("createModal.fields.addAttachments"):i("createModal.fields.addMoreFiles")]}),ie.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1",children:ie.map((Le,vt)=>c.jsxs("span",{className:"inline-flex items-center gap-0.5 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium",children:[Le.name,c.jsx("button",{type:"button",onClick:()=>wi(vt),className:"text-muted-foreground hover:text-foreground",children:c.jsx(Z,{icon:Tn,size:10})})]},`${Le.name}-${vt}`))})]})]})]})]}),c.jsxs(wC,{className:"mt-4 shrink-0 px-3",children:[(v==="worktree"||v==="scratch")&&c.jsxs("label",{className:"flex items-center gap-2 mr-auto cursor-pointer",children:[c.jsx(Xr,{checked:S,onCheckedChange:E,size:"sm"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:i("createModal.startImmediately")})]}),c.jsx(SC,{render:c.jsx(_e,{variant:"outline",type:"button",className:"border-destructive text-destructive hover:bg-destructive hover:text-white"}),children:s("buttons.cancel")}),c.jsx(_e,{type:"submit",disabled:!Ia,children:Mr.isPending?s("status.creating"):i("createModal.createTask")})]})]})})]}),c.jsx(yh,{open:d,onOpenChange:f,onSelect:Ns,initialPath:Bs||void 0})]})}function lr(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];throw new Error(typeof e=="number"?"[MobX] minified error nr: "+e+(n.length?" "+n.map(String).join(","):"")+". Find the full error at: https://github.com/mobxjs/mobx/blob/main/packages/mobx/src/errors.ts":"[MobX] "+e)}var WYe={};function xD(){return typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:WYe}var EEe=Object.assign,YO=Object.getOwnPropertyDescriptor,ff=Object.defineProperty,_D=Object.prototype,E$=[];Object.freeze(E$);var QW={};Object.freeze(QW);var qYe=typeof Proxy<"u",GYe=Object.toString();function CEe(){qYe||lr("Proxy not available")}function kEe(e){var t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}var b0=function(){};function jc(e){return typeof e=="function"}function oy(e){var t=typeof e;switch(t){case"string":case"symbol":case"number":return!0}return!1}function SD(e){return e!==null&&typeof e=="object"}function Hm(e){if(!SD(e))return!1;var t=Object.getPrototypeOf(e);if(t==null)return!0;var n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n.toString()===GYe}function TEe(e){var t=e?.constructor;return t?t.name==="GeneratorFunction"||t.displayName==="GeneratorFunction":!1}function wD(e,t,n){ff(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function AEe(e,t,n){ff(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}function rg(e,t){var n="isMobX"+e;return t.prototype[n]=!0,function(r){return SD(r)&&r[n]===!0}}function D1(e){return e!=null&&Object.prototype.toString.call(e)==="[object Map]"}function KYe(e){var t=Object.getPrototypeOf(e),n=Object.getPrototypeOf(t),r=Object.getPrototypeOf(n);return r===null}function hh(e){return e!=null&&Object.prototype.toString.call(e)==="[object Set]"}var NEe=typeof Object.getOwnPropertySymbols<"u";function YYe(e){var t=Object.keys(e);if(!NEe)return t;var n=Object.getOwnPropertySymbols(e);return n.length?[].concat(t,n.filter(function(r){return _D.propertyIsEnumerable.call(e,r)})):t}var ED=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:NEe?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames;function OEe(e){return e===null?null:typeof e=="object"?""+e:e}function Dh(e,t){return _D.hasOwnProperty.call(e,t)}var XYe=Object.getOwnPropertyDescriptors||function(t){var n={};return ED(t).forEach(function(r){n[r]=YO(t,r)}),n};function Tc(e,t){return!!(e&t)}function Ac(e,t,n){return n?e|=t:e&=~t,e}function Kse(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function QYe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,JYe(r.key),r)}}function j1(e,t,n){return t&&QYe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function y0(e,t){var n=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=eXe(e))||t){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
28
28
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Vm(){return Vm=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Vm.apply(null,arguments)}function REe(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,C$(e,t)}function C$(e,t){return C$=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},C$(e,t)}function ZYe(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function JYe(e){var t=ZYe(e,"string");return typeof t=="symbol"?t:t+""}function eXe(e,t){if(e){if(typeof e=="string")return Kse(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Kse(e,t):void 0}}var nf=Symbol("mobx-stored-annotations");function hf(e){function t(n,r){if(DC(r))return e.decorate_20223_(n,r);IC(n,r,e)}return Object.assign(t,e)}function IC(e,t,n){Dh(e,nf)||wD(e,nf,Vm({},e[nf])),oXe(n)||(e[nf][t]=n)}function tXe(e){return Dh(e,nf)||wD(e,nf,Vm({},e[nf])),e[nf]}function DC(e){return typeof e=="object"&&typeof e.kind=="string"}var Mn=Symbol("mobx administration"),ig=(function(){function e(n){n===void 0&&(n="Atom"),this.name_=void 0,this.flags_=0,this.observers_=new Set,this.lastAccessedBy_=0,this.lowestObserverState_=Vr.NOT_TRACKING_,this.onBOL=void 0,this.onBUOL=void 0,this.name_=n}var t=e.prototype;return t.onBO=function(){this.onBOL&&this.onBOL.forEach(function(r){return r()})},t.onBUO=function(){this.onBUOL&&this.onBUOL.forEach(function(r){return r()})},t.reportObserved=function(){return KEe(this)},t.reportChanged=function(){Rl(),YEe(this),Il()},t.toString=function(){return this.name_},j1(e,[{key:"isBeingObserved",get:function(){return Tc(this.flags_,e.isBeingObservedMask_)},set:function(r){this.flags_=Ac(this.flags_,e.isBeingObservedMask_,r)}},{key:"isPendingUnobservation",get:function(){return Tc(this.flags_,e.isPendingUnobservationMask_)},set:function(r){this.flags_=Ac(this.flags_,e.isPendingUnobservationMask_,r)}},{key:"diffValue",get:function(){return Tc(this.flags_,e.diffValueMask_)?1:0},set:function(r){this.flags_=Ac(this.flags_,e.diffValueMask_,r===1)}}])})();ig.isBeingObservedMask_=1;ig.isPendingUnobservationMask_=2;ig.diffValueMask_=4;var ZW=rg("Atom",ig);function XO(e,t,n){t===void 0&&(t=b0),n===void 0&&(n=b0);var r=new ig(e);return t!==b0&&uQe(r,t),n!==b0&&r2e(r,n),r}function nXe(e,t){return x2e(e,t)}function rXe(e,t){return Object.is?Object.is(e,t):e===t?e!==0||1/e===1/t:e!==e&&t!==t}var hx={structural:nXe,default:rXe};function ly(e,t,n){return l2e(e)?e:Array.isArray(e)?Yi.array(e,{name:n}):Hm(e)?Yi.object(e,void 0,{name:n}):D1(e)?Yi.map(e,{name:n}):hh(e)?Yi.set(e,{name:n}):typeof e=="function"&&!px(e)&&!IE(e)?TEe(e)?gx(e):RE(n,e):e}function iXe(e,t,n){if(e==null||Cd(e)||jf(e)||Fu(e)||Jo(e))return e;if(Array.isArray(e))return Yi.array(e,{name:n,deep:!1});if(Hm(e))return Yi.object(e,void 0,{name:n,deep:!1});if(D1(e))return Yi.map(e,{name:n,deep:!1});if(hh(e))return Yi.set(e,{name:n,deep:!1})}function CD(e){return e}function sXe(e,t){return x2e(e,t)?t:e}var aXe="override";function oXe(e){return e.annotationType_===aXe}function jC(e,t){return{annotationType_:e,options_:t,make_:lXe,extend_:cXe,decorate_20223_:uXe}}function lXe(e,t,n,r){var i;if((i=this.options_)!=null&&i.bound)return this.extend_(e,t,n,!1)===null?0:1;if(r===e.target_)return this.extend_(e,t,n,!1)===null?0:2;if(px(n.value))return 1;var s=IEe(e,this,t,n,!1);return ff(r,t,s),2}function cXe(e,t,n,r){var i=IEe(e,this,t,n);return e.defineProperty_(t,i,r)}function uXe(e,t){var n=t.kind,r=t.name,i=t.addInitializer,s=this,a=function(u){var d,f,h,m;return Wm((d=(f=s.options_)==null?void 0:f.name)!=null?d:r.toString(),u,(h=(m=s.options_)==null?void 0:m.autoAction)!=null?h:!1)};if(n=="field")return function(l){var u,d=l;return px(d)||(d=a(d)),(u=s.options_)!=null&&u.bound&&(d=d.bind(this),d.isMobxAction=!0),d};if(n=="method"){var o;return px(e)||(e=a(e)),(o=this.options_)!=null&&o.bound&&i(function(){var l=this,u=l[r].bind(l);u.isMobxAction=!0,l[r]=u}),e}lr("Cannot apply '"+s.annotationType_+"' to '"+String(r)+"' (kind: "+n+"):"+(`
29
29
  '`+s.annotationType_+"' can only be used on properties with a function value."))}function dXe(e,t,n,r){t.annotationType_,r.value}function IEe(e,t,n,r,i){var s,a,o,l,u,d,f;i===void 0&&(i=Zt.safeDescriptors),dXe(e,t,n,r);var h=r.value;if((s=t.options_)!=null&&s.bound){var m;h=h.bind((m=e.proxy_)!=null?m:e.target_)}return{value:Wm((a=(o=t.options_)==null?void 0:o.name)!=null?a:n.toString(),h,(l=(u=t.options_)==null?void 0:u.autoAction)!=null?l:!1,(d=t.options_)!=null&&d.bound?(f=e.proxy_)!=null?f:e.target_:void 0),configurable:i?e.isPlainObject_:!0,enumerable:!1,writable:!i}}function DEe(e,t){return{annotationType_:e,options_:t,make_:fXe,extend_:hXe,decorate_20223_:pXe}}function fXe(e,t,n,r){var i;if(r===e.target_)return this.extend_(e,t,n,!1)===null?0:2;if((i=this.options_)!=null&&i.bound&&(!Dh(e.target_,t)||!IE(e.target_[t]))&&this.extend_(e,t,n,!1)===null)return 0;if(IE(n.value))return 1;var s=jEe(e,this,t,n,!1,!1);return ff(r,t,s),2}function hXe(e,t,n,r){var i,s=jEe(e,this,t,n,(i=this.options_)==null?void 0:i.bound);return e.defineProperty_(t,s,r)}function pXe(e,t){var n,r=t.name,i=t.addInitializer;return IE(e)||(e=gx(e)),(n=this.options_)!=null&&n.bound&&i(function(){var s=this,a=s[r].bind(s);a.isMobXFlow=!0,s[r]=a}),e}function mXe(e,t,n,r){t.annotationType_,r.value}function jEe(e,t,n,r,i,s){s===void 0&&(s=Zt.safeDescriptors),mXe(e,t,n,r);var a=r.value;if(IE(a)||(a=gx(a)),i){var o;a=a.bind((o=e.proxy_)!=null?o:e.target_),a.isMobXFlow=!0}return{value:a,configurable:s?e.isPlainObject_:!0,enumerable:!1,writable:!s}}function JW(e,t){return{annotationType_:e,options_:t,make_:gXe,extend_:bXe,decorate_20223_:yXe}}function gXe(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function bXe(e,t,n,r){return vXe(e,this,t,n),e.defineComputedProperty_(t,Vm({},this.options_,{get:n.get,set:n.set}),r)}function yXe(e,t){var n=this,r=t.name,i=t.addInitializer;return i(function(){var s=L1(this)[Mn],a=Vm({},n.options_,{get:e,context:this});a.name||(a.name="ObservableObject."+r.toString()),s.values_.set(r,new yd(a))}),function(){return this[Mn].getObservablePropValue_(r)}}function vXe(e,t,n,r){t.annotationType_,r.get}function kD(e,t){return{annotationType_:e,options_:t,make_:xXe,extend_:_Xe,decorate_20223_:SXe}}function xXe(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function _Xe(e,t,n,r){var i,s;return wXe(e,this),e.defineObservableProperty_(t,n.value,(i=(s=this.options_)==null?void 0:s.enhancer)!=null?i:ly,r)}function SXe(e,t){var n=this,r=t.kind,i=t.name,s=new WeakSet;function a(o,l){var u,d,f=L1(o)[Mn],h=new Pm(l,(u=(d=n.options_)==null?void 0:d.enhancer)!=null?u:ly,"ObservableObject."+i.toString(),!1);f.values_.set(i,h),s.add(o)}if(r=="accessor")return{get:function(){return s.has(this)||a(this,e.get.call(this)),this[Mn].getObservablePropValue_(i)},set:function(l){return s.has(this)||a(this,l),this[Mn].setObservablePropValue_(i,l)},init:function(l){return s.has(this)||a(this,l),l}}}function wXe(e,t,n,r){t.annotationType_}var EXe="true",CXe=PEe();function PEe(e){return{annotationType_:EXe,options_:e,make_:kXe,extend_:TXe,decorate_20223_:AXe}}function kXe(e,t,n,r){var i,s;if(n.get)return P1.make_(e,t,n,r);if(n.set){var a=px(n.set)?n.set:Wm(t.toString(),n.set);return r===e.target_?e.defineProperty_(t,{configurable:Zt.safeDescriptors?e.isPlainObject_:!0,set:a})===null?0:2:(ff(r,t,{configurable:!0,set:a}),2)}if(r!==e.target_&&typeof n.value=="function"){var o;if(TEe(n.value)){var l,u=(l=this.options_)!=null&&l.autoBind?gx.bound:gx;return u.make_(e,t,n,r)}var d=(o=this.options_)!=null&&o.autoBind?RE.bound:RE;return d.make_(e,t,n,r)}var f=((i=this.options_)==null?void 0:i.deep)===!1?Yi.ref:Yi;if(typeof n.value=="function"&&(s=this.options_)!=null&&s.autoBind){var h;n.value=n.value.bind((h=e.proxy_)!=null?h:e.target_)}return f.make_(e,t,n,r)}function TXe(e,t,n,r){var i,s;if(n.get)return P1.extend_(e,t,n,r);if(n.set)return e.defineProperty_(t,{configurable:Zt.safeDescriptors?e.isPlainObject_:!0,set:Wm(t.toString(),n.set)},r);if(typeof n.value=="function"&&(i=this.options_)!=null&&i.autoBind){var a;n.value=n.value.bind((a=e.proxy_)!=null?a:e.target_)}var o=((s=this.options_)==null?void 0:s.deep)===!1?Yi.ref:Yi;return o.extend_(e,t,n,r)}function AXe(e,t){lr("'"+this.annotationType_+"' cannot be used as a decorator")}var NXe="observable",OXe="observable.ref",RXe="observable.shallow",IXe="observable.struct",LEe={deep:!0,name:void 0,defaultDecorator:void 0,proxy:!0};Object.freeze(LEe);function kA(e){return e||LEe}var k$=kD(NXe),DXe=kD(OXe,{enhancer:CD}),jXe=kD(RXe,{enhancer:iXe}),PXe=kD(IXe,{enhancer:sXe}),MEe=hf(k$);function TA(e){return e.deep===!0?ly:e.deep===!1?CD:MXe(e.defaultDecorator)}function LXe(e){var t;return e?(t=e.defaultDecorator)!=null?t:PEe(e):void 0}function MXe(e){var t,n;return e&&(t=(n=e.options_)==null?void 0:n.enhancer)!=null?t:ly}function FEe(e,t,n){if(DC(t))return k$.decorate_20223_(e,t);if(oy(t)){IC(e,t,k$);return}return l2e(e)?e:Hm(e)?Yi.object(e,t,n):Array.isArray(e)?Yi.array(e,t):D1(e)?Yi.map(e,t):hh(e)?Yi.set(e,t):typeof e=="object"&&e!==null?e:Yi.box(e,t)}EEe(FEe,MEe);var FXe={box:function(t,n){var r=kA(n);return new Pm(t,TA(r),r.name,!0,r.equals)},array:function(t,n){var r=kA(n);return(Zt.useProxies===!1||r.proxy===!1?$Qe:OQe)(t,TA(r),r.name)},map:function(t,n){var r=kA(n);return new iq(t,TA(r),r.name)},set:function(t,n){var r=kA(n);return new m2e(t,TA(r),r.name)},object:function(t,n,r){return Iy(function(){return pQe(Zt.useProxies===!1||r?.proxy===!1?L1({},r):TQe({},r),t,n)})},ref:hf(DXe),shallow:hf(jXe),deep:MEe,struct:hf(PXe)},Yi=EEe(FEe,FXe),BEe="computed",BXe="computed.struct",T$=JW(BEe),$Xe=JW(BXe,{equals:hx.structural}),P1=function(t,n){if(DC(n))return T$.decorate_20223_(t,n);if(oy(n))return IC(t,n,T$);if(Hm(t))return hf(JW(BEe,t));var r=Hm(n)?n:{};return r.get=t,r.name||(r.name=t.name||""),new yd(r)};Object.assign(P1,T$);P1.struct=hf($Xe);var Yse,Xse,QO=0,zXe=1,UXe=(Yse=(Xse=YO(function(){},"name"))==null?void 0:Xse.configurable)!=null?Yse:!1,Qse={value:"action",configurable:!0,writable:!1,enumerable:!1};function Wm(e,t,n,r){n===void 0&&(n=!1);function i(){return $Ee(e,n,t,r||this,arguments)}return i.isMobxAction=!0,i.toString=function(){return t.toString()},UXe&&(Qse.value=e,ff(i,"name",Qse)),i}function $Ee(e,t,n,r,i){var s=HXe(e,t);try{return n.apply(r,i)}catch(a){throw s.error_=a,a}finally{VXe(s)}}function HXe(e,t,n,r){var i=!1,s=0,a=Zt.trackingDerivation,o=!t||!a;Rl();var l=Zt.allowStateChanges;o&&(Ry(),l=TD(!0));var u=eq(!0),d={runAsAction_:o,prevDerivation_:a,prevAllowStateChanges_:l,prevAllowStateReads_:u,notifySpy_:i,startTime_:s,actionId_:zXe++,parentActionId_:QO};return QO=d.actionId_,d}function VXe(e){QO!==e.actionId_&&lr(30),QO=e.parentActionId_,e.error_!==void 0&&(Zt.suppressReactionErrors=!0),AD(e.prevAllowStateChanges_),jw(e.prevAllowStateReads_),Il(),e.runAsAction_&&jh(e.prevDerivation_),Zt.suppressReactionErrors=!1}function zEe(e,t){var n=TD(e);try{return t()}finally{AD(n)}}function TD(e){var t=Zt.allowStateChanges;return Zt.allowStateChanges=e,t}function AD(e){Zt.allowStateChanges=e}var Pm=(function(e){function t(r,i,s,a,o){var l;return s===void 0&&(s="ObservableValue"),o===void 0&&(o=hx.default),l=e.call(this,s)||this,l.enhancer=void 0,l.name_=void 0,l.equals=void 0,l.hasUnreportedChange_=!1,l.interceptors_=void 0,l.changeListeners_=void 0,l.value_=void 0,l.dehancer=void 0,l.enhancer=i,l.name_=s,l.equals=o,l.value_=i(r,void 0,s),l}REe(t,e);var n=t.prototype;return n.dehanceValue=function(i){return this.dehancer!==void 0?this.dehancer(i):i},n.set=function(i){this.value_,i=this.prepareNewValue_(i),i!==Zt.UNCHANGED&&this.setNewValue_(i)},n.prepareNewValue_=function(i){if(gu(this)){var s=bu(this,{object:this,type:pf,newValue:i});if(!s)return Zt.UNCHANGED;i=s.newValue}return i=this.enhancer(i,this.value_,this.name_),this.equals(this.value_,i)?Zt.UNCHANGED:i},n.setNewValue_=function(i){var s=this.value_;this.value_=i,this.reportChanged(),dd(this)&&fd(this,{type:pf,object:this,newValue:i,oldValue:s})},n.get=function(){return this.reportObserved(),this.dehanceValue(this.value_)},n.intercept_=function(i){return PC(this,i)},n.observe_=function(i,s){return s&&i({observableKind:"value",debugObjectName:this.name_,object:this,type:pf,newValue:this.value_,oldValue:void 0}),LC(this,i)},n.raw=function(){return this.value_},n.toJSON=function(){return this.get()},n.toString=function(){return this.name_+"["+this.value_+"]"},n.valueOf=function(){return OEe(this.get())},n[Symbol.toPrimitive]=function(){return this.valueOf()},t})(ig),WXe=rg("ObservableValue",Pm),yd=(function(){function e(n){this.dependenciesState_=Vr.NOT_TRACKING_,this.observing_=[],this.newObserving_=null,this.observers_=new Set,this.runId_=0,this.lastAccessedBy_=0,this.lowestObserverState_=Vr.UP_TO_DATE_,this.unboundDepsCount_=0,this.value_=new JO(null),this.name_=void 0,this.triggeredBy_=void 0,this.flags_=0,this.derivation=void 0,this.setter_=void 0,this.isTracing_=ZO.NONE,this.scope_=void 0,this.equals_=void 0,this.requiresReaction_=void 0,this.keepAlive_=void 0,this.onBOL=void 0,this.onBUOL=void 0,n.get||lr(31),this.derivation=n.get,this.name_=n.name||"ComputedValue",n.set&&(this.setter_=Wm("ComputedValue-setter",n.set)),this.equals_=n.equals||(n.compareStructural||n.struct?hx.structural:hx.default),this.scope_=n.context,this.requiresReaction_=n.requiresReaction,this.keepAlive_=!!n.keepAlive}var t=e.prototype;return t.onBecomeStale_=function(){QXe(this)},t.onBO=function(){this.onBOL&&this.onBOL.forEach(function(r){return r()})},t.onBUO=function(){this.onBUOL&&this.onBUOL.forEach(function(r){return r()})},t.get=function(){if(this.isComputing&&lr(32,this.name_,this.derivation),Zt.inBatch===0&&this.observers_.size===0&&!this.keepAlive_)A$(this)&&(this.warnAboutUntrackedRead_(),Rl(),this.value_=this.computeValue_(!1),Il());else if(KEe(this),A$(this)){var r=Zt.trackingContext;this.keepAlive_&&!r&&(Zt.trackingContext=this),this.trackAndCompute()&&XXe(this),Zt.trackingContext=r}var i=this.value_;if(HN(i))throw i.cause;return i},t.set=function(r){if(this.setter_){this.isRunningSetter&&lr(33,this.name_),this.isRunningSetter=!0;try{this.setter_.call(this.scope_,r)}finally{this.isRunningSetter=!1}}else lr(34,this.name_)},t.trackAndCompute=function(){var r=this.value_,i=this.dependenciesState_===Vr.NOT_TRACKING_,s=this.computeValue_(!0),a=i||HN(r)||HN(s)||!this.equals_(r,s);return a&&(this.value_=s),a},t.computeValue_=function(r){this.isComputing=!0;var i=TD(!1),s;if(r)s=UEe(this,this.derivation,this.scope_);else if(Zt.disableErrorBoundaries===!0)s=this.derivation.call(this.scope_);else try{s=this.derivation.call(this.scope_)}catch(a){s=new JO(a)}return AD(i),this.isComputing=!1,s},t.suspend_=function(){this.keepAlive_||(N$(this),this.value_=void 0)},t.observe_=function(r,i){var s=this,a=!0,o=void 0;return t2e(function(){var l=s.get();if(!a||i){var u=Ry();r({observableKind:"computed",debugObjectName:s.name_,type:pf,object:s,newValue:l,oldValue:o}),jh(u)}a=!1,o=l})},t.warnAboutUntrackedRead_=function(){},t.toString=function(){return this.name_+"["+this.derivation.toString()+"]"},t.valueOf=function(){return OEe(this.get())},t[Symbol.toPrimitive]=function(){return this.valueOf()},j1(e,[{key:"isComputing",get:function(){return Tc(this.flags_,e.isComputingMask_)},set:function(r){this.flags_=Ac(this.flags_,e.isComputingMask_,r)}},{key:"isRunningSetter",get:function(){return Tc(this.flags_,e.isRunningSetterMask_)},set:function(r){this.flags_=Ac(this.flags_,e.isRunningSetterMask_,r)}},{key:"isBeingObserved",get:function(){return Tc(this.flags_,e.isBeingObservedMask_)},set:function(r){this.flags_=Ac(this.flags_,e.isBeingObservedMask_,r)}},{key:"isPendingUnobservation",get:function(){return Tc(this.flags_,e.isPendingUnobservationMask_)},set:function(r){this.flags_=Ac(this.flags_,e.isPendingUnobservationMask_,r)}},{key:"diffValue",get:function(){return Tc(this.flags_,e.diffValueMask_)?1:0},set:function(r){this.flags_=Ac(this.flags_,e.diffValueMask_,r===1)}}])})();yd.isComputingMask_=1;yd.isRunningSetterMask_=2;yd.isBeingObservedMask_=4;yd.isPendingUnobservationMask_=8;yd.diffValueMask_=16;var ND=rg("ComputedValue",yd),Vr;(function(e){e[e.NOT_TRACKING_=-1]="NOT_TRACKING_",e[e.UP_TO_DATE_=0]="UP_TO_DATE_",e[e.POSSIBLY_STALE_=1]="POSSIBLY_STALE_",e[e.STALE_=2]="STALE_"})(Vr||(Vr={}));var ZO;(function(e){e[e.NONE=0]="NONE",e[e.LOG=1]="LOG",e[e.BREAK=2]="BREAK"})(ZO||(ZO={}));var JO=function(t){this.cause=void 0,this.cause=t};function HN(e){return e instanceof JO}function A$(e){switch(e.dependenciesState_){case Vr.UP_TO_DATE_:return!1;case Vr.NOT_TRACKING_:case Vr.STALE_:return!0;case Vr.POSSIBLY_STALE_:{for(var t=eq(!0),n=Ry(),r=e.observing_,i=r.length,s=0;s<i;s++){var a=r[s];if(ND(a)){if(Zt.disableErrorBoundaries)a.get();else try{a.get()}catch{return jh(n),jw(t),!0}if(e.dependenciesState_===Vr.STALE_)return jh(n),jw(t),!0}}return VEe(e),jh(n),jw(t),!1}}}function UEe(e,t,n){var r=eq(!0);VEe(e),e.newObserving_=new Array(e.runId_===0?100:e.observing_.length),e.unboundDepsCount_=0,e.runId_=++Zt.runId;var i=Zt.trackingDerivation;Zt.trackingDerivation=e,Zt.inBatch++;var s;if(Zt.disableErrorBoundaries===!0)s=t.call(n);else try{s=t.call(n)}catch(a){s=new JO(a)}return Zt.inBatch--,Zt.trackingDerivation=i,qXe(e),jw(r),s}function qXe(e){for(var t=e.observing_,n=e.observing_=e.newObserving_,r=Vr.UP_TO_DATE_,i=0,s=e.unboundDepsCount_,a=0;a<s;a++){var o=n[a];o.diffValue===0&&(o.diffValue=1,i!==a&&(n[i]=o),i++),o.dependenciesState_>r&&(r=o.dependenciesState_)}for(n.length=i,e.newObserving_=null,s=t.length;s--;){var l=t[s];l.diffValue===0&&qEe(l,e),l.diffValue=0}for(;i--;){var u=n[i];u.diffValue===1&&(u.diffValue=0,YXe(u,e))}r!==Vr.UP_TO_DATE_&&(e.dependenciesState_=r,e.onBecomeStale_())}function N$(e){var t=e.observing_;e.observing_=[];for(var n=t.length;n--;)qEe(t[n],e);e.dependenciesState_=Vr.NOT_TRACKING_}function HEe(e){var t=Ry();try{return e()}finally{jh(t)}}function Ry(){var e=Zt.trackingDerivation;return Zt.trackingDerivation=null,e}function jh(e){Zt.trackingDerivation=e}function eq(e){var t=Zt.allowStateReads;return Zt.allowStateReads=e,t}function jw(e){Zt.allowStateReads=e}function VEe(e){if(e.dependenciesState_!==Vr.UP_TO_DATE_){e.dependenciesState_=Vr.UP_TO_DATE_;for(var t=e.observing_,n=t.length;n--;)t[n].lowestObserverState_=Vr.UP_TO_DATE_}}var VN=function(){this.version=6,this.UNCHANGED={},this.trackingDerivation=null,this.trackingContext=null,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.allowStateChanges=!1,this.allowStateReads=!0,this.enforceActions=!0,this.spyListeners=[],this.globalReactionErrorHandlers=[],this.computedRequiresReaction=!1,this.reactionRequiresObservable=!1,this.observableRequiresReaction=!1,this.disableErrorBoundaries=!1,this.suppressReactionErrors=!1,this.useProxies=!0,this.verifyProxies=!1,this.safeDescriptors=!0},WN=!0,WEe=!1,Zt=(function(){var e=xD();return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(WN=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==new VN().version&&(WN=!1),WN?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new VN):(setTimeout(function(){WEe||lr(35)},1),new VN)})();function GXe(){if((Zt.pendingReactions.length||Zt.inBatch||Zt.isRunningReactions)&&lr(36),WEe=!0,WN){var e=xD();--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),Zt=new VN}}function KXe(){return Zt}function YXe(e,t){e.observers_.add(t),e.lowestObserverState_>t.dependenciesState_&&(e.lowestObserverState_=t.dependenciesState_)}function qEe(e,t){e.observers_.delete(t),e.observers_.size===0&&GEe(e)}function GEe(e){e.isPendingUnobservation===!1&&(e.isPendingUnobservation=!0,Zt.pendingUnobservations.push(e))}function Rl(){Zt.inBatch++}function Il(){if(--Zt.inBatch===0){XEe();for(var e=Zt.pendingUnobservations,t=0;t<e.length;t++){var n=e[t];n.isPendingUnobservation=!1,n.observers_.size===0&&(n.isBeingObserved&&(n.isBeingObserved=!1,n.onBUO()),n instanceof yd&&n.suspend_())}Zt.pendingUnobservations=[]}}function KEe(e){var t=Zt.trackingDerivation;return t!==null?(t.runId_!==e.lastAccessedBy_&&(e.lastAccessedBy_=t.runId_,t.newObserving_[t.unboundDepsCount_++]=e,!e.isBeingObserved&&Zt.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved):(e.observers_.size===0&&Zt.inBatch>0&&GEe(e),!1)}function YEe(e){e.lowestObserverState_!==Vr.STALE_&&(e.lowestObserverState_=Vr.STALE_,e.observers_.forEach(function(t){t.dependenciesState_===Vr.UP_TO_DATE_&&t.onBecomeStale_(),t.dependenciesState_=Vr.STALE_}))}function XXe(e){e.lowestObserverState_!==Vr.STALE_&&(e.lowestObserverState_=Vr.STALE_,e.observers_.forEach(function(t){t.dependenciesState_===Vr.POSSIBLY_STALE_?t.dependenciesState_=Vr.STALE_:t.dependenciesState_===Vr.UP_TO_DATE_&&(e.lowestObserverState_=Vr.UP_TO_DATE_)}))}function QXe(e){e.lowestObserverState_===Vr.UP_TO_DATE_&&(e.lowestObserverState_=Vr.POSSIBLY_STALE_,e.observers_.forEach(function(t){t.dependenciesState_===Vr.UP_TO_DATE_&&(t.dependenciesState_=Vr.POSSIBLY_STALE_,t.onBecomeStale_())}))}var _f=(function(){function e(n,r,i,s){n===void 0&&(n="Reaction"),this.name_=void 0,this.onInvalidate_=void 0,this.errorHandler_=void 0,this.requiresObservable_=void 0,this.observing_=[],this.newObserving_=[],this.dependenciesState_=Vr.NOT_TRACKING_,this.runId_=0,this.unboundDepsCount_=0,this.flags_=0,this.isTracing_=ZO.NONE,this.name_=n,this.onInvalidate_=r,this.errorHandler_=i,this.requiresObservable_=s}var t=e.prototype;return t.onBecomeStale_=function(){this.schedule_()},t.schedule_=function(){this.isScheduled||(this.isScheduled=!0,Zt.pendingReactions.push(this),XEe())},t.runReaction_=function(){if(!this.isDisposed){Rl(),this.isScheduled=!1;var r=Zt.trackingContext;if(Zt.trackingContext=this,A$(this)){this.isTrackPending=!0;try{this.onInvalidate_()}catch(i){this.reportExceptionInDerivation_(i)}}Zt.trackingContext=r,Il()}},t.track=function(r){if(!this.isDisposed){Rl(),this.isRunning=!0;var i=Zt.trackingContext;Zt.trackingContext=this;var s=UEe(this,r,void 0);Zt.trackingContext=i,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&N$(this),HN(s)&&this.reportExceptionInDerivation_(s.cause),Il()}},t.reportExceptionInDerivation_=function(r){var i=this;if(this.errorHandler_){this.errorHandler_(r,this);return}if(Zt.disableErrorBoundaries)throw r;var s="[mobx] uncaught error in '"+this+"'";Zt.suppressReactionErrors||console.error(s,r),Zt.globalReactionErrorHandlers.forEach(function(a){return a(r,i)})},t.dispose=function(){this.isDisposed||(this.isDisposed=!0,this.isRunning||(Rl(),N$(this),Il()))},t.getDisposer_=function(r){var i=this,s=function a(){i.dispose(),r==null||r.removeEventListener==null||r.removeEventListener("abort",a)};return r==null||r.addEventListener==null||r.addEventListener("abort",s),s[Mn]=this,"dispose"in Symbol&&typeof Symbol.dispose=="symbol"&&(s[Symbol.dispose]=s),s},t.toString=function(){return"Reaction["+this.name_+"]"},t.trace=function(r){},j1(e,[{key:"isDisposed",get:function(){return Tc(this.flags_,e.isDisposedMask_)},set:function(r){this.flags_=Ac(this.flags_,e.isDisposedMask_,r)}},{key:"isScheduled",get:function(){return Tc(this.flags_,e.isScheduledMask_)},set:function(r){this.flags_=Ac(this.flags_,e.isScheduledMask_,r)}},{key:"isTrackPending",get:function(){return Tc(this.flags_,e.isTrackPendingMask_)},set:function(r){this.flags_=Ac(this.flags_,e.isTrackPendingMask_,r)}},{key:"isRunning",get:function(){return Tc(this.flags_,e.isRunningMask_)},set:function(r){this.flags_=Ac(this.flags_,e.isRunningMask_,r)}},{key:"diffValue",get:function(){return Tc(this.flags_,e.diffValueMask_)?1:0},set:function(r){this.flags_=Ac(this.flags_,e.diffValueMask_,r===1)}}])})();_f.isDisposedMask_=1;_f.isScheduledMask_=2;_f.isTrackPendingMask_=4;_f.isRunningMask_=8;_f.diffValueMask_=16;var ZXe=100,O$=function(t){return t()};function XEe(){Zt.inBatch>0||Zt.isRunningReactions||O$(JXe)}function JXe(){Zt.isRunningReactions=!0;for(var e=Zt.pendingReactions,t=0;e.length>0;){++t===ZXe&&(console.error("[mobx] cycle in reaction: "+e[0]),e.splice(0));for(var n=e.splice(0),r=0,i=n.length;r<i;r++)n[r].runReaction_()}Zt.isRunningReactions=!1}var eR=rg("Reaction",_f);function eQe(e){var t=O$;O$=function(r){return e(function(){return t(r)})}}function Pw(){return!1}function tQe(e){return console.warn("[mobx.spy] Is a no-op in production builds"),function(){}}var QEe="action",nQe="action.bound",ZEe="autoAction",rQe="autoAction.bound",JEe="<unnamed action>",R$=jC(QEe),iQe=jC(nQe,{bound:!0}),I$=jC(ZEe,{autoAction:!0}),sQe=jC(rQe,{autoAction:!0,bound:!0});function e2e(e){var t=function(r,i){if(jc(r))return Wm(r.name||JEe,r,e);if(jc(i))return Wm(r,i,e);if(DC(i))return(e?I$:R$).decorate_20223_(r,i);if(oy(i))return IC(r,i,e?I$:R$);if(oy(r))return hf(jC(e?ZEe:QEe,{name:r,autoAction:e}))};return t}var ya=e2e(!1);Object.assign(ya,R$);var RE=e2e(!0);Object.assign(RE,I$);ya.bound=hf(iQe);RE.bound=hf(sQe);function Zse(e){return $Ee(e.name||JEe,!1,e,this,void 0)}function px(e){return jc(e)&&e.isMobxAction===!0}function t2e(e,t){var n,r,i,s;t===void 0&&(t=QW);var a=(n=(r=t)==null?void 0:r.name)!=null?n:"Autorun",o=!t.scheduler&&!t.delay,l;if(o)l=new _f(a,function(){this.track(f)},t.onError,t.requiresObservable);else{var u=n2e(t),d=!1;l=new _f(a,function(){d||(d=!0,u(function(){d=!1,l.isDisposed||l.track(f)}))},t.onError,t.requiresObservable)}function f(){e(l)}return(i=t)!=null&&(i=i.signal)!=null&&i.aborted||l.schedule_(),l.getDisposer_((s=t)==null?void 0:s.signal)}var aQe=function(t){return t()};function n2e(e){return e.scheduler?e.scheduler:e.delay?function(t){return setTimeout(t,e.delay)}:aQe}function mx(e,t,n){var r,i,s;n===void 0&&(n=QW);var a=(r=n.name)!=null?r:"Reaction",o=ya(a,n.onError?oQe(n.onError,t):t),l=!n.scheduler&&!n.delay,u=n2e(n),d=!0,f=!1,h,m=n.compareStructural?hx.structural:n.equals||hx.default,g=new _f(a,function(){d||l?y():f||(f=!0,u(y))},n.onError,n.requiresObservable);function y(){if(f=!1,!g.isDisposed){var v=!1,_=h;g.track(function(){var S=zEe(!1,function(){return e(g)});v=d||!m(h,S),h=S}),(d&&n.fireImmediately||!d&&v)&&o(h,_,g),d=!1}}return(i=n)!=null&&(i=i.signal)!=null&&i.aborted||g.schedule_(),g.getDisposer_((s=n)==null?void 0:s.signal)}function oQe(e,t){return function(){try{return t.apply(this,arguments)}catch(n){e.call(this,n)}}}var lQe="onBO",cQe="onBUO";function uQe(e,t,n){return i2e(lQe,e,t,n)}function r2e(e,t,n){return i2e(cQe,e,t,n)}function i2e(e,t,n,r){var i=bx(t),s=jc(r)?r:n,a=e+"L";return i[a]?i[a].add(s):i[a]=new Set([s]),function(){var o=i[a];o&&(o.delete(s),o.size===0&&delete i[a])}}var dQe="never",AA="always",fQe="observed";function hQe(e){e.isolateGlobalState===!0&&GXe();var t=e.useProxies,n=e.enforceActions;if(t!==void 0&&(Zt.useProxies=t===AA?!0:t===dQe?!1:typeof Proxy<"u"),t==="ifavailable"&&(Zt.verifyProxies=!0),n!==void 0){var r=n===AA?AA:n===fQe;Zt.enforceActions=r,Zt.allowStateChanges=!(r===!0||r===AA)}["computedRequiresReaction","reactionRequiresObservable","observableRequiresReaction","disableErrorBoundaries","safeDescriptors"].forEach(function(i){i in e&&(Zt[i]=!!e[i])}),Zt.allowStateReads=!Zt.observableRequiresReaction,e.reactionScheduler&&eQe(e.reactionScheduler)}function pQe(e,t,n,r){var i=XYe(t);return Iy(function(){var s=L1(e,r)[Mn];ED(i).forEach(function(a){s.extend_(a,i[a],n&&a in n?n[a]:!0)})}),e}function mQe(e,t){return s2e(bx(e,t))}function s2e(e){var t={name:e.name_};return e.observing_&&e.observing_.length>0&&(t.dependencies=gQe(e.observing_).map(s2e)),t}function gQe(e){return Array.from(new Set(e))}var bQe=0;function a2e(){this.message="FLOW_CANCELLED"}a2e.prototype=Object.create(Error.prototype);var l4=DEe("flow"),yQe=DEe("flow.bound",{bound:!0}),gx=Object.assign(function(t,n){if(DC(n))return l4.decorate_20223_(t,n);if(oy(n))return IC(t,n,l4);var r=t,i=r.name||"<unnamed flow>",s=function(){var o=this,l=arguments,u=++bQe,d=ya(i+" - runid: "+u+" - init",r).apply(o,l),f,h=void 0,m=new Promise(function(g,y){var v=0;f=y;function _(T){h=void 0;var k;try{k=ya(i+" - runid: "+u+" - yield "+v++,d.next).call(d,T)}catch(w){return y(w)}E(k)}function S(T){h=void 0;var k;try{k=ya(i+" - runid: "+u+" - yield "+v++,d.throw).call(d,T)}catch(w){return y(w)}E(k)}function E(T){if(jc(T?.then)){T.then(E,y);return}return T.done?g(T.value):(h=Promise.resolve(T.value),h.then(_,S))}_(void 0)});return m.cancel=ya(i+" - runid: "+u+" - cancel",function(){try{h&&Jse(h);var g=d.return(void 0),y=Promise.resolve(g.value);y.then(b0,b0),Jse(y),f(new a2e)}catch(v){f(v)}}),m};return s.isMobXFlow=!0,s},l4);gx.bound=hf(yQe);function Jse(e){jc(e.cancel)&&e.cancel()}function IE(e){return e?.isMobXFlow===!0}function o2e(e,t,n){var r;return Fu(e)||jf(e)||WXe(e)?r=Sf(e):Cd(e)&&(r=Sf(e,t)),r.dehancer=typeof t=="function"?t:n,function(){r.dehancer=void 0}}function tq(e,t,n){return jc(n)?xQe(e,t,n):vQe(e,t)}function vQe(e,t){return Sf(e).intercept_(t)}function xQe(e,t,n){return Sf(e,t).intercept_(n)}function _Qe(e,t){return e?Cd(e)||!!e[Mn]||ZW(e)||eR(e)||ND(e):!1}function l2e(e){return _Qe(e)}function tR(e){if(Cd(e))return e[Mn].keys_();if(Fu(e)||Jo(e))return Array.from(e.keys());if(jf(e))return e.map(function(t,n){return n});lr(5)}function c2e(e){if(Cd(e))return tR(e).map(function(t){return e[t]});if(Fu(e))return tR(e).map(function(t){return e.get(t)});if(Jo(e))return Array.from(e.values());if(jf(e))return e.slice();lr(6)}function SQe(e){if(Cd(e))return tR(e).map(function(t){return[t,e[t]]});if(Fu(e))return tR(e).map(function(t){return[t,e.get(t)]});if(Jo(e))return Array.from(e.entries());if(jf(e))return e.map(function(t,n){return[n,t]});lr(7)}function u2e(e,t,n){if(arguments.length===2&&!Jo(e)){Rl();var r=t;try{for(var i in r)u2e(e,i,r[i])}finally{Il()}return}Cd(e)?e[Mn].set_(t,n):Fu(e)?e.set(t,n):Jo(e)?e.add(t):jf(e)?(typeof t!="number"&&(t=parseInt(t,10)),t<0&&lr("Invalid index: '"+t+"'"),Rl(),t>=e.length&&(e.length=t+1),e[t]=n,Il()):lr(8)}function d2e(e,t,n){if(Cd(e))return e[Mn].defineProperty_(t,n);lr(39)}function nq(e,t,n,r){return jc(n)?EQe(e,t,n,r):wQe(e,t,n)}function wQe(e,t,n){return Sf(e).observe_(t,n)}function EQe(e,t,n,r){return Sf(e,t).observe_(n,r)}function ph(e,t){t===void 0&&(t=void 0),Rl();try{return e.apply(t)}finally{Il()}}function eae(e,t,n){return arguments.length===1||t&&typeof t=="object"?CQe(e,t):f2e(e,t,{})}function f2e(e,t,n){var r;if(typeof n.timeout=="number"){var i=new Error("WHEN_TIMEOUT");r=setTimeout(function(){if(!a[Mn].isDisposed)if(a(),n.onError)n.onError(i);else throw i},n.timeout)}n.name="When";var s=Wm("When-effect",t),a=t2e(function(o){var l=zEe(!1,e);l&&(o.dispose(),r&&clearTimeout(r),s())},n);return a}function CQe(e,t){var n;if(t!=null&&(n=t.signal)!=null&&n.aborted)return Object.assign(Promise.reject(new Error("WHEN_ABORTED")),{cancel:function(){return null}});var r,i,s=new Promise(function(a,o){var l,u=f2e(e,a,Vm({},t,{onError:o}));r=function(){u(),o(new Error("WHEN_CANCELLED"))},i=function(){u(),o(new Error("WHEN_ABORTED"))},t==null||(l=t.signal)==null||l.addEventListener==null||l.addEventListener("abort",i)}).finally(function(){var a;return t==null||(a=t.signal)==null||a.removeEventListener==null?void 0:a.removeEventListener("abort",i)});return s.cancel=r,s}function Wv(e){return e[Mn]}var kQe={has:function(t,n){return Wv(t).has_(n)},get:function(t,n){return Wv(t).get_(n)},set:function(t,n,r){var i;return oy(n)?(i=Wv(t).set_(n,r,!0))!=null?i:!0:!1},deleteProperty:function(t,n){var r;return oy(n)?(r=Wv(t).delete_(n,!0))!=null?r:!0:!1},defineProperty:function(t,n,r){var i;return(i=Wv(t).defineProperty_(n,r))!=null?i:!0},ownKeys:function(t){return Wv(t).ownKeys_()},preventExtensions:function(t){lr(13)}};function TQe(e,t){var n,r;return CEe(),e=L1(e,t),(r=(n=e[Mn]).proxy_)!=null?r:n.proxy_=new Proxy(e,kQe)}function gu(e){return e.interceptors_!==void 0&&e.interceptors_.length>0}function PC(e,t){var n=e.interceptors_||(e.interceptors_=[]);return n.push(t),kEe(function(){var r=n.indexOf(t);r!==-1&&n.splice(r,1)})}function bu(e,t){var n=Ry();try{for(var r=[].concat(e.interceptors_||[]),i=0,s=r.length;i<s&&(t=r[i](t),t&&!t.type&&lr(14),!!t);i++);return t}finally{jh(n)}}function dd(e){return e.changeListeners_!==void 0&&e.changeListeners_.length>0}function LC(e,t){var n=e.changeListeners_||(e.changeListeners_=[]);return n.push(t),kEe(function(){var r=n.indexOf(t);r!==-1&&n.splice(r,1)})}function fd(e,t){var n=Ry(),r=e.changeListeners_;if(r){r=r.slice();for(var i=0,s=r.length;i<s;i++)r[i](t);jh(n)}}function h2e(e,t,n){return Iy(function(){var r,i=L1(e,n)[Mn];(r=t)!=null||(t=tXe(e)),ED(t).forEach(function(s){return i.make_(s,t[s])})}),e}var tae="splice",pf="update",AQe=1e4,NQe={get:function(t,n){var r=t[Mn];return n===Mn?r:n==="length"?r.getArrayLength_():typeof n=="string"&&!isNaN(n)?r.get_(parseInt(n)):Dh(nR,n)?nR[n]:t[n]},set:function(t,n,r){var i=t[Mn];return n==="length"&&i.setArrayLength_(r),typeof n=="symbol"||isNaN(n)?t[n]=r:i.set_(parseInt(n),r),!0},preventExtensions:function(){lr(15)}},rq=(function(){function e(n,r,i,s){n===void 0&&(n="ObservableArray"),this.owned_=void 0,this.legacyMode_=void 0,this.atom_=void 0,this.values_=[],this.interceptors_=void 0,this.changeListeners_=void 0,this.enhancer_=void 0,this.dehancer=void 0,this.proxy_=void 0,this.lastKnownLength_=0,this.owned_=i,this.legacyMode_=s,this.atom_=new ig(n),this.enhancer_=function(a,o){return r(a,o,"ObservableArray[..]")}}var t=e.prototype;return t.dehanceValue_=function(r){return this.dehancer!==void 0?this.dehancer(r):r},t.dehanceValues_=function(r){return this.dehancer!==void 0&&r.length>0?r.map(this.dehancer):r},t.intercept_=function(r){return PC(this,r)},t.observe_=function(r,i){return i===void 0&&(i=!1),i&&r({observableKind:"array",object:this.proxy_,debugObjectName:this.atom_.name_,type:"splice",index:0,added:this.values_.slice(),addedCount:this.values_.length,removed:[],removedCount:0}),LC(this,r)},t.getArrayLength_=function(){return this.atom_.reportObserved(),this.values_.length},t.setArrayLength_=function(r){(typeof r!="number"||isNaN(r)||r<0)&&lr("Out of range: "+r);var i=this.values_.length;if(r!==i)if(r>i){for(var s=new Array(r-i),a=0;a<r-i;a++)s[a]=void 0;this.spliceWithArray_(i,0,s)}else this.spliceWithArray_(r,i-r)},t.updateArrayLength_=function(r,i){r!==this.lastKnownLength_&&lr(16),this.lastKnownLength_+=i,this.legacyMode_&&i>0&&v2e(r+i+1)},t.spliceWithArray_=function(r,i,s){var a=this;this.atom_;var o=this.values_.length;if(r===void 0?r=0:r>o?r=o:r<0&&(r=Math.max(0,o+r)),arguments.length===1?i=o-r:i==null?i=0:i=Math.max(0,Math.min(i,o-r)),s===void 0&&(s=E$),gu(this)){var l=bu(this,{object:this.proxy_,type:tae,index:r,removedCount:i,added:s});if(!l)return E$;i=l.removedCount,s=l.added}if(s=s.length===0?s:s.map(function(f){return a.enhancer_(f,void 0)}),this.legacyMode_){var u=s.length-i;this.updateArrayLength_(o,u)}var d=this.spliceItemsIntoValues_(r,i,s);return(i!==0||s.length!==0)&&this.notifyArraySplice_(r,s,d),this.dehanceValues_(d)},t.spliceItemsIntoValues_=function(r,i,s){if(s.length<AQe){var a;return(a=this.values_).splice.apply(a,[r,i].concat(s))}else{var o=this.values_.slice(r,r+i),l=this.values_.slice(r+i);this.values_.length+=s.length-i;for(var u=0;u<s.length;u++)this.values_[r+u]=s[u];for(var d=0;d<l.length;d++)this.values_[r+s.length+d]=l[d];return o}},t.notifyArrayChildUpdate_=function(r,i,s){var a=!this.owned_&&Pw(),o=dd(this),l=o||a?{observableKind:"array",object:this.proxy_,type:pf,debugObjectName:this.atom_.name_,index:r,newValue:i,oldValue:s}:null;this.atom_.reportChanged(),o&&fd(this,l)},t.notifyArraySplice_=function(r,i,s){var a=!this.owned_&&Pw(),o=dd(this),l=o||a?{observableKind:"array",object:this.proxy_,debugObjectName:this.atom_.name_,type:tae,index:r,removed:s,added:i,removedCount:s.length,addedCount:i.length}:null;this.atom_.reportChanged(),o&&fd(this,l)},t.get_=function(r){if(this.legacyMode_&&r>=this.values_.length){console.warn("[mobx] Out of bounds read: "+r);return}return this.atom_.reportObserved(),this.dehanceValue_(this.values_[r])},t.set_=function(r,i){var s=this.values_;if(this.legacyMode_&&r>s.length&&lr(17,r,s.length),r<s.length){this.atom_;var a=s[r];if(gu(this)){var o=bu(this,{type:pf,object:this.proxy_,index:r,newValue:i});if(!o)return;i=o.newValue}i=this.enhancer_(i,a);var l=i!==a;l&&(s[r]=i,this.notifyArrayChildUpdate_(r,i,a))}else{for(var u=new Array(r+1-s.length),d=0;d<u.length-1;d++)u[d]=void 0;u[u.length-1]=i,this.spliceWithArray_(s.length,0,u)}},e})();function OQe(e,t,n,r){return n===void 0&&(n="ObservableArray"),r===void 0&&(r=!1),CEe(),Iy(function(){var i=new rq(n,t,r,!1);AEe(i.values_,Mn,i);var s=new Proxy(i.values_,NQe);return i.proxy_=s,e&&e.length&&i.spliceWithArray_(0,0,e),s})}var nR={clear:function(){return this.splice(0)},replace:function(t){var n=this[Mn];return n.spliceWithArray_(0,n.values_.length,t)},toJSON:function(){return this.slice()},splice:function(t,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];var a=this[Mn];switch(arguments.length){case 0:return[];case 1:return a.spliceWithArray_(t);case 2:return a.spliceWithArray_(t,n)}return a.spliceWithArray_(t,n,i)},spliceWithArray:function(t,n,r){return this[Mn].spliceWithArray_(t,n,r)},push:function(){for(var t=this[Mn],n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return t.spliceWithArray_(t.values_.length,0,r),t.values_.length},pop:function(){return this.splice(Math.max(this[Mn].values_.length-1,0),1)[0]},shift:function(){return this.splice(0,1)[0]},unshift:function(){for(var t=this[Mn],n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return t.spliceWithArray_(0,0,r),t.values_.length},reverse:function(){return Zt.trackingDerivation&&lr(37,"reverse"),this.replace(this.slice().reverse()),this},sort:function(){Zt.trackingDerivation&&lr(37,"sort");var t=this.slice();return t.sort.apply(t,arguments),this.replace(t),this},remove:function(t){var n=this[Mn],r=n.dehanceValues_(n.values_).indexOf(t);return r>-1?(this.splice(r,1),!0):!1}};Mi("at",Fc);Mi("concat",Fc);Mi("flat",Fc);Mi("includes",Fc);Mi("indexOf",Fc);Mi("join",Fc);Mi("lastIndexOf",Fc);Mi("slice",Fc);Mi("toString",Fc);Mi("toLocaleString",Fc);Mi("toSorted",Fc);Mi("toSpliced",Fc);Mi("with",Fc);Mi("every",Ed);Mi("filter",Ed);Mi("find",Ed);Mi("findIndex",Ed);Mi("findLast",Ed);Mi("findLastIndex",Ed);Mi("flatMap",Ed);Mi("forEach",Ed);Mi("map",Ed);Mi("some",Ed);Mi("toReversed",Ed);Mi("reduce",p2e);Mi("reduceRight",p2e);function Mi(e,t){typeof Array.prototype[e]=="function"&&(nR[e]=t(e))}function Fc(e){return function(){var t=this[Mn];t.atom_.reportObserved();var n=t.dehanceValues_(t.values_);return n[e].apply(n,arguments)}}function Ed(e){return function(t,n){var r=this,i=this[Mn];i.atom_.reportObserved();var s=i.dehanceValues_(i.values_);return s[e](function(a,o){return t.call(n,a,o,r)})}}function p2e(e){return function(){var t=this,n=this[Mn];n.atom_.reportObserved();var r=n.dehanceValues_(n.values_),i=arguments[0];return arguments[0]=function(s,a,o){return i(s,a,o,t)},r[e].apply(r,arguments)}}var RQe=rg("ObservableArrayAdministration",rq);function jf(e){return SD(e)&&RQe(e[Mn])}var IQe={},xm="add",rR="delete",iq=(function(){function e(n,r,i){var s=this;r===void 0&&(r=ly),i===void 0&&(i="ObservableMap"),this.enhancer_=void 0,this.name_=void 0,this[Mn]=IQe,this.data_=void 0,this.hasMap_=void 0,this.keysAtom_=void 0,this.interceptors_=void 0,this.changeListeners_=void 0,this.dehancer=void 0,this.enhancer_=r,this.name_=i,jc(Map)||lr(18),Iy(function(){s.keysAtom_=XO("ObservableMap.keys()"),s.data_=new Map,s.hasMap_=new Map,n&&s.merge(n)})}var t=e.prototype;return t.has_=function(r){return this.data_.has(r)},t.has=function(r){var i=this;if(!Zt.trackingDerivation)return this.has_(r);var s=this.hasMap_.get(r);if(!s){var a=s=new Pm(this.has_(r),CD,"ObservableMap.key?",!1);this.hasMap_.set(r,a),r2e(a,function(){return i.hasMap_.delete(r)})}return s.get()},t.set=function(r,i){var s=this.has_(r);if(gu(this)){var a=bu(this,{type:s?pf:xm,object:this,newValue:i,name:r});if(!a)return this;i=a.newValue}return s?this.updateValue_(r,i):this.addValue_(r,i),this},t.delete=function(r){var i=this;if(this.keysAtom_,gu(this)){var s=bu(this,{type:rR,object:this,name:r});if(!s)return!1}if(this.has_(r)){var a=Pw(),o=dd(this),l=o||a?{observableKind:"map",debugObjectName:this.name_,type:rR,object:this,oldValue:this.data_.get(r).value_,name:r}:null;return ph(function(){var u;i.keysAtom_.reportChanged(),(u=i.hasMap_.get(r))==null||u.setNewValue_(!1);var d=i.data_.get(r);d.setNewValue_(void 0),i.data_.delete(r)}),o&&fd(this,l),!0}return!1},t.updateValue_=function(r,i){var s=this.data_.get(r);if(i=s.prepareNewValue_(i),i!==Zt.UNCHANGED){var a=Pw(),o=dd(this),l=o||a?{observableKind:"map",debugObjectName:this.name_,type:pf,object:this,oldValue:s.value_,name:r,newValue:i}:null;s.setNewValue_(i),o&&fd(this,l)}},t.addValue_=function(r,i){var s=this;this.keysAtom_,ph(function(){var u,d=new Pm(i,s.enhancer_,"ObservableMap.key",!1);s.data_.set(r,d),i=d.value_,(u=s.hasMap_.get(r))==null||u.setNewValue_(!0),s.keysAtom_.reportChanged()});var a=Pw(),o=dd(this),l=o||a?{observableKind:"map",debugObjectName:this.name_,type:xm,object:this,name:r,newValue:i}:null;o&&fd(this,l)},t.get=function(r){return this.has(r)?this.dehanceValue_(this.data_.get(r).get()):this.dehanceValue_(void 0)},t.dehanceValue_=function(r){return this.dehancer!==void 0?this.dehancer(r):r},t.keys=function(){return this.keysAtom_.reportObserved(),this.data_.keys()},t.values=function(){var r=this,i=this.keys();return nae({next:function(){var a=i.next(),o=a.done,l=a.value;return{done:o,value:o?void 0:r.get(l)}}})},t.entries=function(){var r=this,i=this.keys();return nae({next:function(){var a=i.next(),o=a.done,l=a.value;return{done:o,value:o?void 0:[l,r.get(l)]}}})},t[Symbol.iterator]=function(){return this.entries()},t.forEach=function(r,i){for(var s=y0(this),a;!(a=s()).done;){var o=a.value,l=o[0],u=o[1];r.call(i,u,l,this)}},t.merge=function(r){var i=this;return Fu(r)&&(r=new Map(r)),ph(function(){Hm(r)?YYe(r).forEach(function(s){return i.set(s,r[s])}):Array.isArray(r)?r.forEach(function(s){var a=s[0],o=s[1];return i.set(a,o)}):D1(r)?(KYe(r)||lr(19,r),r.forEach(function(s,a){return i.set(a,s)})):r!=null&&lr(20,r)}),this},t.clear=function(){var r=this;ph(function(){HEe(function(){for(var i=y0(r.keys()),s;!(s=i()).done;){var a=s.value;r.delete(a)}})})},t.replace=function(r){var i=this;return ph(function(){for(var s=DQe(r),a=new Map,o=!1,l=y0(i.data_.keys()),u;!(u=l()).done;){var d=u.value;if(!s.has(d)){var f=i.delete(d);if(f)o=!0;else{var h=i.data_.get(d);a.set(d,h)}}}for(var m=y0(s.entries()),g;!(g=m()).done;){var y=g.value,v=y[0],_=y[1],S=i.data_.has(v);if(i.set(v,_),i.data_.has(v)){var E=i.data_.get(v);a.set(v,E),S||(o=!0)}}if(!o)if(i.data_.size!==a.size)i.keysAtom_.reportChanged();else for(var T=i.data_.keys(),k=a.keys(),w=T.next(),A=k.next();!w.done;){if(w.value!==A.value){i.keysAtom_.reportChanged();break}w=T.next(),A=k.next()}i.data_=a}),this},t.toString=function(){return"[object ObservableMap]"},t.toJSON=function(){return Array.from(this)},t.observe_=function(r,i){return LC(this,r)},t.intercept_=function(r){return PC(this,r)},j1(e,[{key:"size",get:function(){return this.keysAtom_.reportObserved(),this.data_.size}},{key:Symbol.toStringTag,get:function(){return"Map"}}])})(),Fu=rg("ObservableMap",iq);function nae(e){return e[Symbol.toStringTag]="MapIterator",aq(e)}function DQe(e){if(D1(e)||Fu(e))return e;if(Array.isArray(e))return new Map(e);if(Hm(e)){var t=new Map;for(var n in e)t.set(n,e[n]);return t}else return lr(21,e)}var jQe={},m2e=(function(){function e(n,r,i){var s=this;r===void 0&&(r=ly),i===void 0&&(i="ObservableSet"),this.name_=void 0,this[Mn]=jQe,this.data_=new Set,this.atom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.dehancer=void 0,this.enhancer_=void 0,this.name_=i,jc(Set)||lr(22),this.enhancer_=function(a,o){return r(a,o,i)},Iy(function(){s.atom_=XO(s.name_),n&&s.replace(n)})}var t=e.prototype;return t.dehanceValue_=function(r){return this.dehancer!==void 0?this.dehancer(r):r},t.clear=function(){var r=this;ph(function(){HEe(function(){for(var i=y0(r.data_.values()),s;!(s=i()).done;){var a=s.value;r.delete(a)}})})},t.forEach=function(r,i){for(var s=y0(this),a;!(a=s()).done;){var o=a.value;r.call(i,o,o,this)}},t.add=function(r){var i=this;if(this.atom_,gu(this)){var s=bu(this,{type:xm,object:this,newValue:r});if(!s)return this;r=s.newValue}if(!this.has(r)){ph(function(){i.data_.add(i.enhancer_(r,void 0)),i.atom_.reportChanged()});var a=!1,o=dd(this),l=o||a?{observableKind:"set",debugObjectName:this.name_,type:xm,object:this,newValue:r}:null;o&&fd(this,l)}return this},t.delete=function(r){var i=this;if(gu(this)){var s=bu(this,{type:rR,object:this,oldValue:r});if(!s)return!1}if(this.has(r)){var a=!1,o=dd(this),l=o||a?{observableKind:"set",debugObjectName:this.name_,type:rR,object:this,oldValue:r}:null;return ph(function(){i.atom_.reportChanged(),i.data_.delete(r)}),o&&fd(this,l),!0}return!1},t.has=function(r){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(r))},t.entries=function(){var r=this.values();return rae({next:function(){var s=r.next(),a=s.value,o=s.done;return o?{value:void 0,done:o}:{value:[a,a],done:o}}})},t.keys=function(){return this.values()},t.values=function(){this.atom_.reportObserved();var r=this,i=this.data_.values();return rae({next:function(){var a=i.next(),o=a.value,l=a.done;return l?{value:void 0,done:l}:{value:r.dehanceValue_(o),done:l}}})},t.intersection=function(r){if(hh(r)&&!Jo(r))return r.intersection(this);var i=new Set(this);return i.intersection(r)},t.union=function(r){if(hh(r)&&!Jo(r))return r.union(this);var i=new Set(this);return i.union(r)},t.difference=function(r){return new Set(this).difference(r)},t.symmetricDifference=function(r){if(hh(r)&&!Jo(r))return r.symmetricDifference(this);var i=new Set(this);return i.symmetricDifference(r)},t.isSubsetOf=function(r){return new Set(this).isSubsetOf(r)},t.isSupersetOf=function(r){return new Set(this).isSupersetOf(r)},t.isDisjointFrom=function(r){if(hh(r)&&!Jo(r))return r.isDisjointFrom(this);var i=new Set(this);return i.isDisjointFrom(r)},t.replace=function(r){var i=this;return Jo(r)&&(r=new Set(r)),ph(function(){Array.isArray(r)?(i.clear(),r.forEach(function(s){return i.add(s)})):hh(r)?(i.clear(),r.forEach(function(s){return i.add(s)})):r!=null&&lr("Cannot initialize set from "+r)}),this},t.observe_=function(r,i){return LC(this,r)},t.intercept_=function(r){return PC(this,r)},t.toJSON=function(){return Array.from(this)},t.toString=function(){return"[object ObservableSet]"},t[Symbol.iterator]=function(){return this.values()},j1(e,[{key:"size",get:function(){return this.atom_.reportObserved(),this.data_.size}},{key:Symbol.toStringTag,get:function(){return"Set"}}])})(),Jo=rg("ObservableSet",m2e);function rae(e){return e[Symbol.toStringTag]="SetIterator",aq(e)}var iae=Object.create(null),sae="remove",g2e=(function(){function e(n,r,i,s){r===void 0&&(r=new Map),s===void 0&&(s=CXe),this.target_=void 0,this.values_=void 0,this.name_=void 0,this.defaultAnnotation_=void 0,this.keysAtom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.proxy_=void 0,this.isPlainObject_=void 0,this.appliedAnnotations_=void 0,this.pendingKeys_=void 0,this.target_=n,this.values_=r,this.name_=i,this.defaultAnnotation_=s,this.keysAtom_=new ig("ObservableObject.keys"),this.isPlainObject_=Hm(this.target_)}var t=e.prototype;return t.getObservablePropValue_=function(r){return this.values_.get(r).get()},t.setObservablePropValue_=function(r,i){var s=this.values_.get(r);if(s instanceof yd)return s.set(i),!0;if(gu(this)){var a=bu(this,{type:pf,object:this.proxy_||this.target_,name:r,newValue:i});if(!a)return null;i=a.newValue}if(i=s.prepareNewValue_(i),i!==Zt.UNCHANGED){var o=dd(this),l=!1,u=o||l?{type:pf,observableKind:"object",debugObjectName:this.name_,object:this.proxy_||this.target_,oldValue:s.value_,name:r,newValue:i}:null;s.setNewValue_(i),o&&fd(this,u)}return!0},t.get_=function(r){return Zt.trackingDerivation&&!Dh(this.target_,r)&&this.has_(r),this.target_[r]},t.set_=function(r,i,s){return s===void 0&&(s=!1),Dh(this.target_,r)?this.values_.has(r)?this.setObservablePropValue_(r,i):s?Reflect.set(this.target_,r,i):(this.target_[r]=i,!0):this.extend_(r,{value:i,enumerable:!0,writable:!0,configurable:!0},this.defaultAnnotation_,s)},t.has_=function(r){if(!Zt.trackingDerivation)return r in this.target_;this.pendingKeys_||(this.pendingKeys_=new Map);var i=this.pendingKeys_.get(r);return i||(i=new Pm(r in this.target_,CD,"ObservableObject.key?",!1),this.pendingKeys_.set(r,i)),i.get()},t.make_=function(r,i){if(i===!0&&(i=this.defaultAnnotation_),i!==!1){if(!(r in this.target_)){var s;if((s=this.target_[nf])!=null&&s[r])return;lr(1,i.annotationType_,this.name_+"."+r.toString())}for(var a=this.target_;a&&a!==_D;){var o=YO(a,r);if(o){var l=i.make_(this,r,o,a);if(l===0)return;if(l===1)break}a=Object.getPrototypeOf(a)}oae(this,i,r)}},t.extend_=function(r,i,s,a){if(a===void 0&&(a=!1),s===!0&&(s=this.defaultAnnotation_),s===!1)return this.defineProperty_(r,i,a);var o=s.extend_(this,r,i,a);return o&&oae(this,s,r),o},t.defineProperty_=function(r,i,s){s===void 0&&(s=!1),this.keysAtom_;try{Rl();var a=this.delete_(r);if(!a)return a;if(gu(this)){var o=bu(this,{object:this.proxy_||this.target_,name:r,type:xm,newValue:i.value});if(!o)return null;var l=o.newValue;i.value!==l&&(i=Vm({},i,{value:l}))}if(s){if(!Reflect.defineProperty(this.target_,r,i))return!1}else ff(this.target_,r,i);this.notifyPropertyAddition_(r,i.value)}finally{Il()}return!0},t.defineObservableProperty_=function(r,i,s,a){a===void 0&&(a=!1),this.keysAtom_;try{Rl();var o=this.delete_(r);if(!o)return o;if(gu(this)){var l=bu(this,{object:this.proxy_||this.target_,name:r,type:xm,newValue:i});if(!l)return null;i=l.newValue}var u=aae(r),d={configurable:Zt.safeDescriptors?this.isPlainObject_:!0,enumerable:!0,get:u.get,set:u.set};if(a){if(!Reflect.defineProperty(this.target_,r,d))return!1}else ff(this.target_,r,d);var f=new Pm(i,s,"ObservableObject.key",!1);this.values_.set(r,f),this.notifyPropertyAddition_(r,f.value_)}finally{Il()}return!0},t.defineComputedProperty_=function(r,i,s){s===void 0&&(s=!1),this.keysAtom_;try{Rl();var a=this.delete_(r);if(!a)return a;if(gu(this)){var o=bu(this,{object:this.proxy_||this.target_,name:r,type:xm,newValue:void 0});if(!o)return null}i.name||(i.name="ObservableObject.key"),i.context=this.proxy_||this.target_;var l=aae(r),u={configurable:Zt.safeDescriptors?this.isPlainObject_:!0,enumerable:!1,get:l.get,set:l.set};if(s){if(!Reflect.defineProperty(this.target_,r,u))return!1}else ff(this.target_,r,u);this.values_.set(r,new yd(i)),this.notifyPropertyAddition_(r,void 0)}finally{Il()}return!0},t.delete_=function(r,i){if(i===void 0&&(i=!1),this.keysAtom_,!Dh(this.target_,r))return!0;if(gu(this)){var s=bu(this,{object:this.proxy_||this.target_,name:r,type:sae});if(!s)return null}try{var a;Rl();var o=dd(this),l=!1,u=this.values_.get(r),d=void 0;if(!u&&(o||l)){var f;d=(f=YO(this.target_,r))==null?void 0:f.value}if(i){if(!Reflect.deleteProperty(this.target_,r))return!1}else delete this.target_[r];if(u&&(this.values_.delete(r),u instanceof Pm&&(d=u.value_),YEe(u)),this.keysAtom_.reportChanged(),(a=this.pendingKeys_)==null||(a=a.get(r))==null||a.set(r in this.target_),o||l){var h={type:sae,observableKind:"object",object:this.proxy_||this.target_,debugObjectName:this.name_,oldValue:d,name:r};o&&fd(this,h)}}finally{Il()}return!0},t.observe_=function(r,i){return LC(this,r)},t.intercept_=function(r){return PC(this,r)},t.notifyPropertyAddition_=function(r,i){var s,a=dd(this),o=!1;if(a||o){var l=a||o?{type:xm,observableKind:"object",debugObjectName:this.name_,object:this.proxy_||this.target_,name:r,newValue:i}:null;a&&fd(this,l)}(s=this.pendingKeys_)==null||(s=s.get(r))==null||s.set(!0),this.keysAtom_.reportChanged()},t.ownKeys_=function(){return this.keysAtom_.reportObserved(),ED(this.target_)},t.keys_=function(){return this.keysAtom_.reportObserved(),Object.keys(this.target_)},e})();function L1(e,t){var n;if(Dh(e,Mn))return e;var r=(n=t?.name)!=null?n:"ObservableObject",i=new g2e(e,new Map,String(r),LXe(t));return wD(e,Mn,i),e}var PQe=rg("ObservableObjectAdministration",g2e);function aae(e){return iae[e]||(iae[e]={get:function(){return this[Mn].getObservablePropValue_(e)},set:function(n){return this[Mn].setObservablePropValue_(e,n)}})}function Cd(e){return SD(e)?PQe(e[Mn]):!1}function oae(e,t,n){var r;(r=e.target_[nf])==null||delete r[n]}var LQe=y2e(0),MQe=(function(){var e=!1,t={};return Object.defineProperty(t,"0",{set:function(){e=!0}}),Object.create(t)[0]=1,e===!1})(),c4=0,b2e=function(){};function FQe(e,t){Object.setPrototypeOf?Object.setPrototypeOf(e.prototype,t):e.prototype.__proto__!==void 0?e.prototype.__proto__=t:e.prototype=t}FQe(b2e,Array.prototype);var sq=(function(e){function t(r,i,s,a){var o;return s===void 0&&(s="ObservableArray"),a===void 0&&(a=!1),o=e.call(this)||this,Iy(function(){var l=new rq(s,i,a,!0);l.proxy_=o,AEe(o,Mn,l),r&&r.length&&o.spliceWithArray(0,0,r),MQe&&Object.defineProperty(o,"0",LQe)}),o}REe(t,e);var n=t.prototype;return n.concat=function(){this[Mn].atom_.reportObserved();for(var i=arguments.length,s=new Array(i),a=0;a<i;a++)s[a]=arguments[a];return Array.prototype.concat.apply(this.slice(),s.map(function(o){return jf(o)?o.slice():o}))},n[Symbol.iterator]=function(){var r=this,i=0;return aq({next:function(){return i<r.length?{value:r[i++],done:!1}:{done:!0,value:void 0}}})},j1(t,[{key:"length",get:function(){return this[Mn].getArrayLength_()},set:function(i){this[Mn].setArrayLength_(i)}},{key:Symbol.toStringTag,get:function(){return"Array"}}])})(b2e);Object.entries(nR).forEach(function(e){var t=e[0],n=e[1];t!=="concat"&&wD(sq.prototype,t,n)});function y2e(e){return{enumerable:!1,configurable:!0,get:function(){return this[Mn].get_(e)},set:function(n){this[Mn].set_(e,n)}}}function BQe(e){ff(sq.prototype,""+e,y2e(e))}function v2e(e){if(e>c4){for(var t=c4;t<e+100;t++)BQe(t);c4=e}}v2e(1e3);function $Qe(e,t,n){return new sq(e,t,n)}function bx(e,t){if(typeof e=="object"&&e!==null){if(jf(e))return t!==void 0&&lr(23),e[Mn].atom_;if(Jo(e))return e.atom_;if(Fu(e)){if(t===void 0)return e.keysAtom_;var n=e.data_.get(t)||e.hasMap_.get(t);return n||lr(25,t,D$(e)),n}if(Cd(e)){if(!t)return lr(26);var r=e[Mn].values_.get(t);return r||lr(27,t,D$(e)),r}if(ZW(e)||ND(e)||eR(e))return e}else if(jc(e)&&eR(e[Mn]))return e[Mn];lr(28)}function Sf(e,t){if(e||lr(29),t!==void 0)return Sf(bx(e,t));if(ZW(e)||ND(e)||eR(e)||Fu(e)||Jo(e))return e;if(e[Mn])return e[Mn];lr(24,e)}function D$(e,t){var n;if(t!==void 0)n=bx(e,t);else{if(px(e))return e.name;Cd(e)||Fu(e)||Jo(e)?n=Sf(e):n=bx(e)}return n.name_}function Iy(e){var t=Ry(),n=TD(!0);Rl();try{return e()}finally{Il(),AD(n),jh(t)}}var lae=_D.toString;function x2e(e,t,n){return n===void 0&&(n=-1),j$(e,t,n)}function j$(e,t,n,r,i){if(e===t)return e!==0||1/e===1/t;if(e==null||t==null)return!1;if(e!==e)return t!==t;var s=typeof e;if(s!=="function"&&s!=="object"&&typeof t!="object")return!1;var a=lae.call(e);if(a!==lae.call(t))return!1;switch(a){case"[object RegExp]":case"[object String]":return""+e==""+t;case"[object Number]":return+e!=+e?+t!=+t:+e==0?1/+e===1/t:+e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object Symbol]":return typeof Symbol<"u"&&Symbol.valueOf.call(e)===Symbol.valueOf.call(t);case"[object Map]":case"[object Set]":n>=0&&n++;break}e=cae(e),t=cae(t);var o=a==="[object Array]";if(!o){if(typeof e!="object"||typeof t!="object")return!1;var l=e.constructor,u=t.constructor;if(l!==u&&!(jc(l)&&l instanceof l&&jc(u)&&u instanceof u)&&"constructor"in e&&"constructor"in t)return!1}if(n===0)return!1;n<0&&(n=-1),r=r||[],i=i||[];for(var d=r.length;d--;)if(r[d]===e)return i[d]===t;if(r.push(e),i.push(t),o){if(d=e.length,d!==t.length)return!1;for(;d--;)if(!j$(e[d],t[d],n-1,r,i))return!1}else{var f=Object.keys(e),h=f.length;if(Object.keys(t).length!==h)return!1;for(var m=0;m<h;m++){var g=f[m];if(!(Dh(t,g)&&j$(e[g],t[g],n-1,r,i)))return!1}}return r.pop(),i.pop(),!0}function cae(e){return jf(e)?e.slice():D1(e)||Fu(e)||hh(e)||Jo(e)?Array.from(e.entries()):e}var uae,zQe=((uae=xD().Iterator)==null?void 0:uae.prototype)||{};function aq(e){return e[Symbol.iterator]=UQe,Object.assign(Object.create(zQe),e)}function UQe(){return this}["Symbol","Map","Set"].forEach(function(e){var t=xD();typeof t[e]>"u"&&lr("MobX requires global '"+e+"' to be available or polyfilled")});typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__=="object"&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:tQe,extras:{getDebugName:D$},$mobx:Mn});var dae={},HQe="warn";function VQe(){return HQe}var ba;(function(e){e.afterCreate="afterCreate",e.afterAttach="afterAttach",e.afterCreationFinalization="afterCreationFinalization",e.beforeDetach="beforeDetach",e.beforeDestroy="beforeDestroy"})(ba||(ba={}));var P$=function(e,t){return P$=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])},P$(e,t)};function Fi(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");P$(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Dl=function(){return Dl=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Dl.apply(this,arguments)};function WQe(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Lw(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Kh(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,s=[],a;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(o){a={error:o}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(a)throw a.error}}return s}function Yh(e,t,n){if(arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}function _2e(e){return qr(e).type}function qQe(e,t){return qr(e).onPatch(t)}function DE(e,t){qr(e).applyPatches(D2e(t))}function fae(e,t){var n={patches:[],inversePatches:[]},r={},i,s={get recording(){return!!i},get patches(){return r.patches||(r.patches=n.patches.slice()),r.patches},get reversedInversePatches(){return r.reversedInversePatches||(r.reversedInversePatches=n.inversePatches.slice().reverse()),r.reversedInversePatches},get inversePatches(){return r.inversePatches||(r.inversePatches=n.inversePatches.slice()),r.inversePatches},stop:function(){i&&(i(),i=void 0)},resume:function(){i||(i=qQe(e,function(a,o){n.patches.push(a),n.inversePatches.push(o),r.patches=void 0,r.inversePatches=void 0,r.reversedInversePatches=void 0}))},replay:function(a){DE(a||e,n.patches)},undo:function(a){DE(a||e,n.inversePatches.slice().reverse())}};return s.resume(),s}function GQe(e,t){t===void 0&&(t=!0);var n=qr(e);return t?n.snapshot:n.type.getSnapshot(n,!1)}function S2e(e){return qr(e).root.storedValue}function KQe(e){return qr(e).path}function YQe(e){return qr(e).identifier}function iR(e){var t=qr(e);t.isRoot?t.die():t.parent.removeChild(t.subpath)}function sR(e){var t=qr(e),n=t.root.environment;if(!n)throw new yn("Failed to find the environment of ".concat(t," ").concat(t.path));return n}var w2e=(function(){function e(t,n,r,i){Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"environment",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_escapedSubpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storedValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"aliveAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_state",{enumerable:!0,configurable:!0,writable:!0,value:lo.INITIALIZING}),Object.defineProperty(this,"_hookSubscribers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pathAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.environment=i,this.baseSetParent(n,r)}return Object.defineProperty(e.prototype,"subpath",{get:function(){return this._subpath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subpathUponDeath",{get:function(){return this._subpathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pathUponDeath",{get:function(){return this._pathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},set:function(t){var n=this.isAlive;this._state=t;var r=this.isAlive;this.aliveAtom&&n!==r&&this.aliveAtom.reportChanged()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fireInternalHook",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this._hookSubscribers&&this._hookSubscribers.emit(t,this,t)}}),Object.defineProperty(e.prototype,"registerHook",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return this._hookSubscribers||(this._hookSubscribers=new L2e),this._hookSubscribers.register(t,n)}}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getReconciliationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type}}),Object.defineProperty(e.prototype,"baseSetParent",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){this._parent=t,this._subpath=n,this._escapedSubpath=void 0,this.pathAtom&&this.pathAtom.reportChanged()}}),Object.defineProperty(e.prototype,"path",{get:function(){return this.getEscapedPath(!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getEscapedPath",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return t&&(this.pathAtom||(this.pathAtom=XO("path")),this.pathAtom.reportObserved()),this.parent?(this._escapedSubpath===void 0&&(this._escapedSubpath=this._subpath?zb(this._subpath):""),this.parent.getEscapedPath(t)+"/"+this._escapedSubpath):""}}),Object.defineProperty(e.prototype,"isRoot",{get:function(){return this.parent===null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isAlive",{get:function(){return this.state!==lo.DEAD},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDetaching",{get:function(){return this.state===lo.DETACHING},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"observableIsAlive",{get:function(){return this.aliveAtom||(this.aliveAtom=XO("alive")),this.aliveAtom.reportObserved(),this.isAlive},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseFinalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(this.state===lo.CREATED){if(this.parent){if(this.parent.state!==lo.FINALIZED)return;this.fireHook(ba.afterAttach)}this.state=lo.FINALIZED,t&&t()}}}),Object.defineProperty(e.prototype,"baseFinalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._hookSubscribers&&this._hookSubscribers.clearAll(),this._subpathUponDeath=this._subpath,this._pathUponDeath=this.getEscapedPath(!1),this.baseSetParent(null,""),this.state=lo.DEAD}}),Object.defineProperty(e.prototype,"baseAboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.fireHook(ba.beforeDestroy)}}),e})(),jE=(function(e){Fi(t,e);function t(n,r,i,s,a){var o=e.call(this,n,r,i,s)||this;try{o.storedValue=n.createNewInstance(a)}catch(l){throw o.state=lo.DEAD,l}return o.state=lo.CREATED,o.finalizeCreation(),o}return Object.defineProperty(t.prototype,"root",{get:function(){if(!this.parent)throw new yn("This scalar node is not part of a tree");return this.parent.root},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this.parent!==n,s=this.subpath!==r;!i&&!s||(this.environment=void 0,this.baseSetParent(this.parent,r))}}),Object.defineProperty(t.prototype,"snapshot",{get:function(){return this.getSnapshot()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(t.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){var n=(this.isAlive?this.path:this.pathUponDeath)||"<root>";return"".concat(this.type.name,"@").concat(n).concat(this.isAlive?"":" [dead]")}}),Object.defineProperty(t.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){!this.isAlive||this.state===lo.DETACHING||(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(t.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeCreation()}}),Object.defineProperty(t.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseAboutToDie()}}),Object.defineProperty(t.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeDeath()}}),Object.defineProperty(t.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(n){this.fireInternalHook(n)}}),t})(w2e);jE.prototype.die=ya(jE.prototype.die);var XQe=1,Ju;(function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.CREATING=1]="CREATING",e[e.CREATED=2]="CREATED"})(Ju||(Ju={}));var xc;(function(e){e.Dispose="dispose",e.Patch="patch",e.Snapshot="snapshot"})(xc||(xc={}));var QQe={onError:function(e){throw e}},Vl=(function(e){Fi(t,e);function t(n,r,i,s,a){var o=e.call(this,n,r,i,s)||this;if(Object.defineProperty(o,"nodeId",{enumerable:!0,configurable:!0,writable:!0,value:++XQe}),Object.defineProperty(o,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"unnormalizedIdentifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"identifierCache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"isProtectionEnabled",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(o,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"hasSnapshotPostProcessor",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(o,"_applyPatches",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"_applySnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"_autoUnbox",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(o,"_isRunningAction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(o,"_hasSnapshotReaction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(o,"_observableInstanceState",{enumerable:!0,configurable:!0,writable:!0,value:Ju.UNINITIALIZED}),Object.defineProperty(o,"_childNodes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"_initialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"_cachedInitialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"_cachedInitialSnapshotCreated",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(o,"_snapshotComputed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"_snapshotUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"_internalEvents",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),o._snapshotComputed=P1(function(){return o.getSnapshot()}),o.unbox=o.unbox.bind(o),o._initialSnapshot=a,o.identifierAttribute=n.identifierAttribute,r||(o.identifierCache=new lZe),o._childNodes=n.initializeChildNodes(o,o._initialSnapshot),o.identifier=null,o.unnormalizedIdentifier=null,o.identifierAttribute&&o._initialSnapshot){var l=o._initialSnapshot[o.identifierAttribute];if(l===void 0){var u=o._childNodes[o.identifierAttribute];u&&(l=u.value)}if(typeof l!="string"&&typeof l!="number")throw new yn("Instance identifier '".concat(o.identifierAttribute,"' for type '").concat(o.type.name,"' must be a string or a number"));o.identifier=MC(l),o.unnormalizedIdentifier=l}return r?r.root.identifierCache.addNodeToCache(o):o.identifierCache.addNodeToCache(o),o}return Object.defineProperty(t.prototype,"applyPatches",{enumerable:!1,configurable:!0,writable:!0,value:function(n){this.createObservableInstanceIfNeeded(),this._applyPatches(n)}}),Object.defineProperty(t.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){this.createObservableInstanceIfNeeded(),this._applySnapshot(n)}}),Object.defineProperty(t.prototype,"createObservableInstanceIfNeeded",{enumerable:!1,configurable:!0,writable:!0,value:function(n){n===void 0&&(n=!0),this._observableInstanceState===Ju.UNINITIALIZED&&this.createObservableInstance(n)}}),Object.defineProperty(t.prototype,"createObservableInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r,i,s,a;n===void 0&&(n=!0),this._observableInstanceState=Ju.CREATING;for(var o=[],l=this.parent;l&&l._observableInstanceState===Ju.UNINITIALIZED;)o.unshift(l),l=l.parent;try{for(var u=Lw(o),d=u.next();!d.done;d=u.next()){var f=d.value;f.createObservableInstanceIfNeeded(!1)}}catch(y){r={error:y}}finally{try{d&&!d.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}var h=this.type;try{this.storedValue=h.createNewInstance(this._childNodes),this.preboot(),this._isRunningAction=!0,h.finalizeNewInstance(this,this.storedValue)}catch(y){throw this.state=lo.DEAD,y}finally{this._isRunningAction=!1}if(this._observableInstanceState=Ju.CREATED,this._snapshotComputed.trackAndCompute(),this.isRoot&&this._addSnapshotReaction(),this._childNodes=xx,this.state=lo.CREATED,n){this.fireHook(ba.afterCreate),this.finalizeCreation();try{for(var m=Lw(o.reverse()),g=m.next();!g.done;g=m.next()){var f=g.value;f.fireHook(ba.afterCreate),f.finalizeCreation()}}catch(y){s={error:y}}finally{try{g&&!g.done&&(a=m.return)&&a.call(m)}finally{if(s)throw s.error}}}}}),Object.defineProperty(t.prototype,"root",{get:function(){var n=this.parent;return n?n.root:this},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clearParent",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.parent){this.fireHook(ba.beforeDetach);var n=this.state;this.state=lo.DETACHING;var r=this.root,i=r.environment,s=r.identifierCache.splitCache(this);try{this.parent.removeChild(this.subpath),this.baseSetParent(null,""),this.environment=i,this.identifierCache=s}finally{this.state=n}}}}),Object.defineProperty(t.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=n!==this.parent,s=r!==this.subpath;!i&&!s||(i?(this.environment=void 0,n.root.identifierCache.mergeCache(this),this.baseSetParent(n,r),this.fireHook(ba.afterAttach)):s&&this.baseSetParent(this.parent,r))}}),Object.defineProperty(t.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this;this.fireInternalHook(n);var i=this.storedValue&&typeof this.storedValue=="object"&&this.storedValue[n];typeof i=="function"&&(Zse?Zse(function(){i.apply(r.storedValue)}):i.apply(this.storedValue))}}),Object.defineProperty(t.prototype,"snapshot",{get:function(){return this.hasSnapshotPostProcessor&&this.createObservableInstanceIfNeeded(),this._snapshotComputed.get()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.isAlive?this._observableInstanceState===Ju.CREATED?this._getActualSnapshot():this._getCachedInitialSnapshot():this._snapshotUponDeath}}),Object.defineProperty(t.prototype,"_getActualSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(t.prototype,"_getCachedInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this._cachedInitialSnapshotCreated){var n=this.type,r=this._childNodes,i=this._initialSnapshot;this._cachedInitialSnapshot=n.processInitialSnapshot(r,i),this._cachedInitialSnapshotCreated=!0}return this._cachedInitialSnapshot}}),Object.defineProperty(t.prototype,"isRunningAction",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isRunningAction?!0:this.isRoot?!1:this.parent.isRunningAction()}}),Object.defineProperty(t.prototype,"assertAlive",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=VQe();if(!this.isAlive&&r!=="ignore"){var i=this._getAssertAliveError(n);switch(r){case"error":throw new yn(i);case"warn":xZe(i)}}}}),Object.defineProperty(t.prototype,"_getAssertAliveError",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this.getEscapedPath(!1)||this.pathUponDeath||"",i=n.subpath&&zb(n.subpath)||"",s=n.actionContext||k2e();s&&s.type!=="action"&&s.parentActionEvent&&(s=s.parentActionEvent);var a="";if(s&&s.name!=null){var o=s&&s.context&&KQe(s.context)||r;a="".concat(o,".").concat(s.name,"()")}return"You are trying to read or write to an object that is no longer part of a state tree. (Object type: '".concat(this.type.name,"', Path upon death: '").concat(r,"', Subpath: '").concat(i,"', Action: '").concat(a,"'). Either detach nodes first, or don't use objects after removing / replacing them in the tree.")}}),Object.defineProperty(t.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(n){this.assertAlive({subpath:n}),this._autoUnbox=!1;try{return this._observableInstanceState===Ju.CREATED?this.type.getChildNode(this,n):this._childNodes[n]}finally{this._autoUnbox=!0}}}),Object.defineProperty(t.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.assertAlive(xx),this._autoUnbox=!1;try{return this._observableInstanceState===Ju.CREATED?this.type.getChildren(this):R2e(this._childNodes)}finally{this._autoUnbox=!0}}}),Object.defineProperty(t.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this.type.getChildType(n)}}),Object.defineProperty(t.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"assertWritable",{enumerable:!1,configurable:!0,writable:!0,value:function(n){if(this.assertAlive(n),!this.isRunningAction()&&this.isProtected)throw new yn("Cannot modify '".concat(this,"', the object is protected and can only be modified by using an action."))}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(n){this.type.removeChild(this,n)}}),Object.defineProperty(t.prototype,"unbox",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return n&&(this.assertAlive({subpath:n.subpath||n.subpathUponDeath}),this._autoUnbox?n.value:n)}}),Object.defineProperty(t.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){var n=(this.isAlive?this.path:this.pathUponDeath)||"<root>",r=this.identifier?"(id: ".concat(this.identifier,")"):"";return"".concat(this.type.name,"@").concat(n).concat(r).concat(this.isAlive?"":" [dead]")}}),Object.defineProperty(t.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){var n=this;this.baseFinalizeCreation(function(){var r,i;try{for(var s=Lw(n.getChildren()),a=s.next();!a.done;a=s.next()){var o=a.value;o.finalizeCreation()}}catch(l){r={error:l}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}n.fireInternalHook(ba.afterCreationFinalization)})}}),Object.defineProperty(t.prototype,"detach",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this.isAlive)throw new yn("Error while detaching, node is not alive.");this.clearParent()}}),Object.defineProperty(t.prototype,"preboot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var n=this;this._applyPatches=PE(this.storedValue,"@APPLY_PATCHES",function(r){r.forEach(function(i){if(!i.path){n.type.applySnapshot(n,i.value);return}var s=AZe(i.path),a=dZe(n,s.slice(0,-1));a.applyPatchLocally(s[s.length-1],i)})}),this._applySnapshot=PE(this.storedValue,"@APPLY_SNAPSHOT",function(r){if(r!==n.snapshot)return n.type.applySnapshot(n,r)}),$b(this.storedValue,"$treenode",this),$b(this.storedValue,"toJSON",uZe)}}),Object.defineProperty(t.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){!this.isAlive||this.state===lo.DETACHING||(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(t.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._observableInstanceState!==Ju.UNINITIALIZED&&(this.getChildren().forEach(function(n){n.aboutToDie()}),this.baseAboutToDie(),this._internalEventsEmit(xc.Dispose),this._internalEventsClear(xc.Dispose))}}),Object.defineProperty(t.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.getChildren().forEach(function(r){r.finalizeDeath()}),this.root.identifierCache.notifyDied(this);var n=this.snapshot;this._snapshotUponDeath=n,this._internalEventsClearAll(),this.baseFinalizeDeath()}}),Object.defineProperty(t.prototype,"onSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this._addSnapshotReaction(),this._internalEventsRegister(xc.Snapshot,n)}}),Object.defineProperty(t.prototype,"emitSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){this._internalEventsEmit(xc.Snapshot,n)}}),Object.defineProperty(t.prototype,"onPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this._internalEventsRegister(xc.Patch,n)}}),Object.defineProperty(t.prototype,"emitPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){if(this._internalEventsHasSubscribers(xc.Patch)){var i=r.path.substr(this.path.length)+(n.path?"/"+n.path:""),s=bZe({},n,{path:i}),a=Kh(wZe(s),2),o=a[0],l=a[1];this._internalEventsEmit(xc.Patch,o,l)}this.parent&&this.parent.emitPatch(n,r)}}),Object.defineProperty(t.prototype,"hasDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return this._internalEventsHas(xc.Dispose,n)}}),Object.defineProperty(t.prototype,"addDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(n){if(!this.hasDisposer(n)){this._internalEventsRegister(xc.Dispose,n,!0);return}throw new yn("cannot add a disposer when it is already registered for execution")}}),Object.defineProperty(t.prototype,"removeDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(n){if(!this._internalEventsHas(xc.Dispose,n))throw new yn("cannot remove a disposer which was never registered for execution");this._internalEventsUnregister(xc.Dispose,n)}}),Object.defineProperty(t.prototype,"removeMiddleware",{enumerable:!1,configurable:!0,writable:!0,value:function(n){if(this.middlewares){var r=this.middlewares.indexOf(n);r>=0&&this.middlewares.splice(r,1)}}}),Object.defineProperty(t.prototype,"addMiddleWare",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this;r===void 0&&(r=!0);var s={handler:n,includeHooks:r};return this.middlewares?this.middlewares.push(s):this.middlewares=[s],function(){i.removeMiddleware(s)}}}),Object.defineProperty(t.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){this.assertWritable({subpath:n}),this.createObservableInstanceIfNeeded(),this.type.applyPatchLocally(this,n,r)}}),Object.defineProperty(t.prototype,"_addSnapshotReaction",{enumerable:!1,configurable:!0,writable:!0,value:function(){var n=this;if(!this._hasSnapshotReaction){var r=mx(function(){return n.snapshot},function(i){return n.emitSnapshot(i)},QQe);this.addDisposer(r),this._hasSnapshotReaction=!0}}}),Object.defineProperty(t.prototype,"_internalEventsHasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return!!this._internalEvents&&this._internalEvents.hasSubscribers(n)}}),Object.defineProperty(t.prototype,"_internalEventsRegister",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i){return i===void 0&&(i=!1),this._internalEvents||(this._internalEvents=new L2e),this._internalEvents.register(n,r,i)}}),Object.defineProperty(t.prototype,"_internalEventsHas",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return!!this._internalEvents&&this._internalEvents.has(n,r)}}),Object.defineProperty(t.prototype,"_internalEventsUnregister",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){this._internalEvents&&this._internalEvents.unregister(n,r)}}),Object.defineProperty(t.prototype,"_internalEventsEmit",{enumerable:!1,configurable:!0,writable:!0,value:function(n){for(var r,i=[],s=1;s<arguments.length;s++)i[s-1]=arguments[s];this._internalEvents&&(r=this._internalEvents).emit.apply(r,Yh([n],Kh(i),!1))}}),Object.defineProperty(t.prototype,"_internalEventsClear",{enumerable:!1,configurable:!0,writable:!0,value:function(n){this._internalEvents&&this._internalEvents.clear(n)}}),Object.defineProperty(t.prototype,"_internalEventsClearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._internalEvents&&this._internalEvents.clearAll()}}),t})(w2e);Vl.prototype.createObservableInstance=ya(Vl.prototype.createObservableInstance);Vl.prototype.detach=ya(Vl.prototype.detach);Vl.prototype.die=ya(Vl.prototype.die);var E2e,Ir;(function(e){e[e.String=1]="String",e[e.Number=2]="Number",e[e.Boolean=4]="Boolean",e[e.Date=8]="Date",e[e.Literal=16]="Literal",e[e.Array=32]="Array",e[e.Map=64]="Map",e[e.Object=128]="Object",e[e.Frozen=256]="Frozen",e[e.Optional=512]="Optional",e[e.Reference=1024]="Reference",e[e.Identifier=2048]="Identifier",e[e.Late=4096]="Late",e[e.Refinement=8192]="Refinement",e[e.Union=16384]="Union",e[e.Null=32768]="Null",e[e.Undefined=65536]="Undefined",e[e.Integer=131072]="Integer",e[e.Custom=262144]="Custom",e[e.SnapshotProcessor=524288]="SnapshotProcessor",e[e.Lazy=1048576]="Lazy",e[e.Finite=2097152]="Finite",e[e.Float=4194304]="Float"})(Ir||(Ir={}));var C2e="cannotDetermine",ZQe=Symbol("$type"),Xh=(function(){function e(t){Object.defineProperty(this,E2e,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"C",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"S",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"T",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"N",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isType",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=t}return Object.defineProperty(e.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return Ph(this,t),this.instantiate(null,"",n,t).value}}),Object.defineProperty(e.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){throw new yn("unimplemented method")}}),Object.defineProperty(e.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return t===this}}),Object.defineProperty(e.prototype,"validate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var r=O2e(t);if(r){var i=_2e(t);return this.isAssignableFrom(i)?Wl():nc(n,t)}return this.isValidSnapshot(t,n)}}),Object.defineProperty(e.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this.validate(t,[{path:"",type:this}]).length===0}}),Object.defineProperty(e.prototype,"Type",{get:function(){throw new yn("Factory.Type should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.Type`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"TypeWithoutSTN",{get:function(){throw new yn("Factory.TypeWithoutSTN should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.TypeWithoutSTN`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"SnapshotType",{get:function(){throw new yn("Factory.SnapshotType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.SnapshotType`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"CreationType",{get:function(){throw new yn("Factory.CreationType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.CreationType`")},enumerable:!1,configurable:!0}),e})();E2e=ZQe;Xh.prototype.create=ya(Xh.prototype.create);var yx=(function(e){Fi(t,e);function t(n){var r=e.call(this,n)||this;return Object.defineProperty(r,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),r}return Object.defineProperty(t.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return n===void 0&&(n=this.getDefaultSnapshot()),e.prototype.create.call(this,n,r)}}),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return n.createObservableInstanceIfNeeded(),n.storedValue}}),Object.defineProperty(t.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return!n.identifierAttribute||n.identifier===MC(r[n.identifierAttribute])}}),Object.defineProperty(t.prototype,"tryToReconcileNode",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return n.isDetaching?!1:n.snapshot===r||us(r)&&qr(r)===n?!0:n.type===this&&j2e(r)&&!us(r)&&this.isMatchingSnapshotId(n,r)?(n.applySnapshot(r),!0):!1}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,s){var a=this.tryToReconcileNode(n,r);if(a)return n.setParent(i,s),n;if(n.die(),us(r)&&this.isAssignableFrom(_2e(r))){var o=qr(r);return o.setParent(i,s),o}return this.instantiate(i,s,void 0,r)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),t})(Xh);yx.prototype.create=ya(yx.prototype.create);var Dy=(function(e){Fi(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return n}}),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return n.storedValue}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return n.storedValue}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,s){if(!n.isDetaching&&n.type===this&&n.storedValue===r)return n;var a=this.instantiate(i,s,void 0,r);return n.die(),a}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),t})(Xh);function Qh(e){return typeof e=="object"&&e&&e.isType===!0}var JQe=1,Mw;function k2e(){return Mw}function T2e(){return JQe++}function L$(e,t){var n=qr(e.context);e.type==="action"&&n.assertAlive({actionContext:e});var r=n._isRunningAction;n._isRunningAction=!0;var i=Mw;Mw=e;try{return tZe(n,e,t)}finally{Mw=i,n._isRunningAction=r}}function A2e(e){if(e)return e.type==="action"?e:e.parentActionEvent}function PE(e,t,n){var r=function(){var i=T2e(),s=Mw,a=A2e(s);return L$({type:"action",name:t,id:i,args:M2e(arguments),context:e,tree:S2e(e),rootId:s?s.rootId:i,parentId:s?s.id:0,allParentIds:s?Yh(Yh([],Kh(s.allParentIds),!1),[s.id],!1):[],parentEvent:s,parentActionEvent:a},n)};return r._isMSTAction=!0,r._isFlowAction=n._isFlowAction,r}var eZe=(function(){function e(t,n){Object.defineProperty(this,"arrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"inArrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:[]}),n.$mst_middleware&&this.middlewares.push(n.$mst_middleware);for(var r=t;r;)r.middlewares&&this.middlewares.push(r.middlewares),r=r.parent}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return this.middlewares.length<=0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getNextMiddleware",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this.middlewares[this.arrayIndex];if(t){var n=t[this.inArrayIndex++];return n||(this.arrayIndex++,this.inArrayIndex=0,this.getNextMiddleware())}}}),e})();function tZe(e,t,n){var r=new eZe(e,n);if(r.isEmpty)return ya(n).apply(null,t.args);var i=null;function s(a){var o=r.getNextMiddleware(),l=o&&o.handler;if(!l)return ya(n).apply(null,a.args);if(!o.includeHooks&&ba[a.name])return s(a);function u(f,h){i=s(f),h&&(i=h(i))}function d(f){i=f}return l(a,u,d),i}return s(t)}function nZe(e){try{return JSON.stringify(e)}catch(t){return"<Unserializable: ".concat(t,">")}}function N2e(e){return typeof e=="function"?"<function".concat(e.name?" "+e.name:"",">"):us(e)?"<".concat(e,">"):"`".concat(nZe(e),"`")}function rZe(e){return e.length<280?e:"".concat(e.substring(0,272),"......").concat(e.substring(e.length-8))}function iZe(e){var t=e.value,n=e.context[e.context.length-1].type,r=e.context.map(function(o){var l=o.path;return l}).filter(function(o){return o.length>0}).join("/"),i=r.length>0?'at path "/'.concat(r,'" '):"",s=us(t)?"value of type ".concat(qr(t).type.name,":"):LE(t)?"value":"snapshot",a=n&&us(t)&&n.is(qr(t).snapshot);return"".concat(i).concat(s," ").concat(N2e(t)," is not assignable ").concat(n?"to type: `".concat(n.name,"`"):"")+(e.message?" (".concat(e.message,")"):"")+(n?VZe(n)||LE(t)?".":", expected an instance of `".concat(n.name,"` or a snapshot like `").concat(n.describe(),"` instead.")+(a?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function oq(e,t,n){return e.concat([{path:t,type:n}])}function Wl(){return vx}function nc(e,t,n){return[{context:e,value:t,message:n}]}function OD(e){return e.reduce(function(t,n){return t.concat(n)},[])}function Ph(e,t){_Ze()&&sZe(e,t)}function sZe(e,t){var n=e.validate(t,[{path:"",type:e}]);if(n.length>0)throw new yn(aZe(e,t,n))}function aZe(e,t,n){if(n.length!==0)return"Error while converting ".concat(rZe(N2e(t))," to `").concat(e.name,`\`:
30
30
 
@@ -32,7 +32,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
32
32
  `)}var oZe=0,lZe=(function(){function e(){Object.defineProperty(this,"cacheId",{enumerable:!0,configurable:!0,writable:!0,value:oZe++}),Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:Yi.map()}),Object.defineProperty(this,"lastCacheModificationPerId",{enumerable:!0,configurable:!0,writable:!0,value:Yi.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,Yi.array([],RD));var i=this.cache.get(r);if(i.indexOf(t)!==-1)throw new yn("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;c2e(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 SQe(this.cache).forEach(function(s){for(var a=Kh(s,2),o=a[0],l=a[1],u=!1,d=l.length-1;d>=0;d--){var f=l[d];(f===t||f.path.indexOf(i)===0)&&(r.addNodeToCache(f,!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(s){return t.isAssignableFrom(s.type)});switch(i.length){case 0:return null;case 1:return i[0];default:throw new yn("Cannot resolve a reference to type '".concat(t.name,"' with id: '").concat(n,"' unambigously, there are multiple candidates: ").concat(i.map(function(s){return s.path}).join(", ")))}}}),e})();function lq(e,t,n,r,i){var s=O2e(i);if(s){if(s.parent)throw new yn("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(s.path,"'"));return t&&s.setParent(t,n),s}return new Vl(e,t,n,r,i)}function sg(e,t,n,r,i){return new jE(e,t,n,r,i)}function cZe(e){return e instanceof jE||e instanceof Vl}var lo;(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"})(lo||(lo={}));function us(e){return!!(e&&e.$treenode)}function qr(e){if(!us(e))throw new yn("Value ".concat(e," is no MST Node"));return e.$treenode}function O2e(e){return e&&e.$treenode||null}function uZe(){return qr(this).snapshot}function dZe(e,t,n){n===void 0&&(n=!0);var r=e;try{for(var i=0;i<t.length;i++){var s=t[i];if(s===".."){if(r=r.parent,r)continue}else{if(s===".")continue;if(r){if(r instanceof jE){var a=r.value;us(a)&&(r=qr(a))}if(r instanceof Vl){var o=r.getChildType(s);if(o&&(r=r.getChildNode(s),r))continue}}}throw new yn("Could not resolve '".concat(s,"' in path '").concat(hae(t.slice(0,i))||"/","' while resolving '").concat(hae(t),"'"))}}catch(l){if(!n)return;throw l}return r}function R2e(e){if(!e)return vx;var t=Object.keys(e);if(!t.length)return vx;var n=new Array(t.length);return t.forEach(function(r,i){n[i]=e[r]}),n}var fZe=Object.toString(),vx=Object.freeze([]),xx=Object.freeze({}),RD=KXe().useProxies?{deep:!1}:{deep:!1,proxy:!1};Object.freeze(RD);var yn=(function(e){Fi(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 hZe(e){return e}var pZe=Number.isInteger;function mZe(e){return Number(e)===e&&e%1!==0}function gZe(e){return Number.isFinite(e)}function I2e(e){return Array.isArray(e)||jf(e)}function D2e(e){return e?I2e(e)?e:[e]:vx}function bZe(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 s in i)e[s]=i[s]}return e}function v0(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())===fZe}function j2e(e){return e!==null&&typeof e=="object"&&!(e instanceof Date)&&!(e instanceof RegExp)}function LE(e,t){return t===void 0&&(t=!0),e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"||t&&e instanceof Date}function P2e(e){return typeof e!="function"}function yZe(e,t,n){Cd(e)?d2e(e,t,n):Object.defineProperty(e,t,n)}function $b(e,t,n){yZe(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}var vZe=(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,Yh([],Kh(t),!1))})}}),e})(),L2e=(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 vZe),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 s=this.eventHandlers&&this.eventHandlers[t];s&&(n=s).emit.apply(n,Yh([],Kh(r),!1))}}),e})();function M2e(e){for(var t=new Array(e.length),n=0;n<e.length;n++)t[n]=e[n];return t}function u4(e,t){return e.indexOf(t)===0}function xZe(e){console.warn(new Error("[mobx-state-tree] ".concat(e)))}function _Ze(){return typeof process<"u"&&dae&&dae.ENABLE_TYPE_CHECK==="true"}function d4(e){typeof queueMicrotask=="function"?queueMicrotask(e):typeof setImmediate=="function"?setImmediate(e):setTimeout(e,1)}function Sb(e){return SZe(e.name,e)}function SZe(e,t){var n=function(){var i=T2e(),s=k2e();if(!s)throw new yn("a mst flow must always have a parent context");var a=A2e(s);if(!a)throw new yn("a mst flow must always have a parent action context");var o={name:e,id:i,tree:s.tree,context:s.context,parentId:s.id,allParentIds:Yh(Yh([],Kh(s.allParentIds),!1),[s.id],!1),rootId:s.rootId,parentEvent:s,parentActionEvent:a},l=arguments;function u(d,f,h){return d.$mst_middleware=n.$mst_middleware,L$(Dl(Dl({},o),{type:f,args:[h]}),d)}return new Promise(function(d,f){var h,m=function(){h=t.apply(null,arguments),g(void 0)};m.$mst_middleware=n.$mst_middleware,L$(Dl(Dl({},o),{type:"flow_spawn",args:M2e(l)}),m);function g(_){var S;try{var E=u(function(T){S=h.next(T)},"flow_resume",_);E instanceof Error&&(S=h.throw(E))}catch(T){d4(function(){u(function(k){f(T)},"flow_throw",T)});return}v(S)}function y(_){var S;try{u(function(E){S=h.throw(E)},"flow_resume_error",_)}catch(E){d4(function(){u(function(T){f(E)},"flow_throw",E)});return}v(S)}function v(_){if(_.done){d4(function(){u(function(S){d(S)},"flow_return",_.value)});return}if(!_.value||typeof _.value.then!="function")throw new yn("Only promises can be yielded to `async`, got: "+_);return _.value.then(g,y)}})};return n._isFlowAction=!0,n}function wZe(e){if(!("oldValue"in e))throw new yn("Patches without `oldValue` field cannot be inversed");return[EZe(e),CZe(e)]}function EZe(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 CZe(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 kZe(e){return typeof e=="number"}function zb(e){return kZe(e)===!0?""+e:e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function TZe(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function hae(e){if(e.length===0)return"";var t=function(n){return n.map(zb).join("/")};return e[0]==="."||e[0]===".."?t(e):"/"+t(e)}function AZe(e){var t=e.split("/").map(TZe),n=e===""||e==="."||e===".."||u4(e,"/")||u4(e,"./")||u4(e,"../");if(!n)throw new yn("a json path must be either rooted, empty or relative, but got '".concat(e,"'"));return t[0]===""&&t.shift(),t}var f4=Symbol("$preProcessorFailed"),NZe=(function(e){Fi(t,e);function t(n,r,i){var s=e.call(this,i||n.name)||this;return Object.defineProperty(s,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(s,"_processors",{enumerable:!0,configurable:!0,writable:!0,value:r}),s}return Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|Ir.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 f4}}}),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;OZe(n.type,this,"create"),n instanceof Vl&&(n.hasSnapshotPostProcessor=!!this._processors.postProcessor);var i=n.getSnapshot;n.getSnapshot=function(){return r.postProcessSnapshot(i.call(n),n)},XZe(this._subtype)||(n.getReconciliationType=function(){return r})}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,s){var a=us(s)?s:this.preProcessSnapshot(s),o=this._subtype.instantiate(n,r,i,a);return this._fixNode(o),o}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,s){var a=this._subtype.reconcile(n,us(r)?r:this.preProcessSnapshot(r),i,s);return a!==n&&this._fixNode(a),a}}),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===f4?nc(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=Qh(n)?this._subtype:us(n)?n:this.preProcessSnapshotSafe(n);return r===f4?!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 yx))return!1;var i=this.preProcessSnapshot(r);return this._subtype.isMatchingSnapshotId(n,i)}}),t})(Xh);function OZe(e,t){for(var n,r,i=[],s=2;s<arguments.length;s++)i[s-2]=arguments[s];try{for(var a=Lw(i),o=a.next();!o.done;o=a.next()){var l=o.value;e[l]=t[l].bind(t)}}catch(u){n={error:u}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}function RZe(e,t,n){return new NZe(e,t,n)}var pae="Map.put can only be used to store complex values that have an identifier type attribute";function F2e(e,t){var n,r,i=e.getSubTypes();if(i===C2e)return!1;if(i){var s=D2e(i);try{for(var a=Lw(s),o=a.next();!o.done;o=a.next()){var l=o.value;if(!F2e(l,t))return!1}}catch(u){n={error:u}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}return e instanceof ME&&t.push(e),!0}var fm;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.YES=1]="YES",e[e.NO=2]="NO"})(fm||(fm={}));var IZe=(function(e){Fi(t,e);function t(n,r){return e.call(this,n,Yi.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 yn("Map.put cannot be used to set empty values");if(us(n)){var r=qr(n);if(r.identifier===null)throw new yn(pae);return this.set(r.identifier,n),n}else if(j2e(n)){var i=qr(this),s=i.type;if(s.identifierMode!==fm.YES)throw new yn(pae);var a=s.mapIdentifierAttribute,o=n[a];if(!cq(o)){var l=this.put(s.getChildType().create(n,i.environment));return this.put(GQe(l))}var u=MC(o);return this.set(u,n),this.get(u)}else throw new yn("Map.put can only be used to store complex values")}}),t})(iq),aR=(function(e){Fi(t,e);function t(n,r,i){i===void 0&&(i=[]);var s=e.call(this,n)||this;return Object.defineProperty(s,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(s,"identifierMode",{enumerable:!0,configurable:!0,writable:!0,value:fm.UNKNOWN}),Object.defineProperty(s,"mapIdentifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(s,"flags",{enumerable:!0,configurable:!0,writable:!0,value:Ir.Map}),Object.defineProperty(s,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),s._determineIdentifierMode(),s.hookInitializers=i,s}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,s){return this._determineIdentifierMode(),lq(this,n,r,i,s)}}),Object.defineProperty(t.prototype,"_determineIdentifierMode",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.identifierMode===fm.UNKNOWN){var n=[];if(F2e(this._subType,n)){var r=n.reduce(function(i,s){if(!s.identifierAttribute)return i;if(i&&i!==s.identifierAttribute)throw new yn("The objects in a map should all have the same identifier attribute, expected '".concat(i,"', but child of type '").concat(s.name,"' declared attribute '").concat(s.identifierAttribute,"' as identifier"));return s.identifierAttribute},void 0);r?(this.identifierMode=fm.YES,this.mapIdentifierAttribute=r):this.identifierMode=fm.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,s={};return Object.keys(r).forEach(function(a){s[a]=i.instantiate(n,a,void 0,r[a])}),s}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n){return new IZe(n,this.name)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){o2e(r,n.unbox);var i=n.type;i.hookInitializers.forEach(function(s){var a=s(r);Object.keys(a).forEach(function(o){var l=a[o],u=PE(r,o,l);$b(r,o,u)})}),tq(r,this.willChange),nq(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 c2e(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 yn("Not a child "+r);return i}}),Object.defineProperty(t.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=qr(n.object),i=n.name;r.assertWritable({subpath:i});var s=r.type,a=s._subType;switch(n.type){case"update":{var o=n.newValue,l=n.object.get(i);if(o===l)return null;Ph(a,o),n.newValue=a.reconcile(r.getChildNode(i),n.newValue,r,i),s.processIdentifier(i,n.newValue)}break;case"add":Ph(a,n.newValue),n.newValue=a.instantiate(r,i,void 0,n.newValue),s.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===fm.YES&&r instanceof Vl){var i=r.identifier;if(i!==n)throw new yn("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=qr(n.object);switch(n.type){case"update":return void r.emitPatch({op:"replace",path:zb(n.name),value:n.newValue.snapshot,oldValue:n.oldValue?n.oldValue.snapshot:void 0},r);case"add":return void r.emitPatch({op:"add",path:zb(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:zb(n.name),oldValue:i},r)}}}),Object.defineProperty(t.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i){var s=n.storedValue;switch(i.op){case"add":case"replace":s.set(r,i.value);break;case"remove":s.delete(r);break}}}),Object.defineProperty(t.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){Ph(this,r);var i=n.storedValue,s={};if(Array.from(i.keys()).forEach(function(o){s[o]=!1}),r)for(var a in r)i.set(a,r[a]),s[""+a]=!0;Object.keys(s).forEach(function(o){s[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 v0(n)?OD(Object.keys(n).map(function(s){return i._subType.validate(n[s],oq(r,s,i._subType))})):nc(r,n,"Value is not a plain object")}}),Object.defineProperty(t.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return xx}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){n.storedValue.delete(r)}}),t})(yx);aR.prototype.applySnapshot=ya(aR.prototype.applySnapshot);function DZe(e){return new aR("Map<string, ".concat(e.name,">"),e)}var oR=(function(e){Fi(t,e);function t(n,r,i){i===void 0&&(i=[]);var s=e.call(this,n)||this;return Object.defineProperty(s,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(s,"flags",{enumerable:!0,configurable:!0,writable:!0,value:Ir.Array}),Object.defineProperty(s,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),s.hookInitializers=i,s}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,s){return lq(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._subType,s={};return r.forEach(function(a,o){var l=""+o;s[l]=i.instantiate(n,l,void 0,a)}),s}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=Dl(Dl({},RD),{name:this.name});return Yi.array(R2e(n),r)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){Sf(r).dehancer=n.unbox;var i=n.type;i.hookInitializers.forEach(function(s){var a=s(r);Object.keys(a).forEach(function(o){var l=a[o],u=PE(r,o,l);$b(r,o,u)})}),tq(r,this.willChange),nq(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 yn("Not a child: "+r)}}),Object.defineProperty(t.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=qr(n.object);r.assertWritable({subpath:""+n.index});var i=r.type._subType,s=r.getChildren();switch(n.type){case"update":{if(n.newValue===n.object[n.index])return null;var a=mae(r,i,[s[n.index]],[n.newValue],[n.index]);if(!a)return null;n.newValue=a[0]}break;case"splice":{var o=n.index,l=n.removedCount,u=n.added,d=mae(r,i,s.slice(o,o+l),u,u.map(function(h,m){return o+m}));if(!d)return null;n.added=d;for(var f=o+l;f<s.length;f++)s[f].setParent(r,""+(f+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=qr(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(s){return s.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 s=n.storedValue,a=r==="-"?s.length:Number(r);switch(i.op){case"replace":s[a]=i.value;break;case"add":s.splice(a,0,i.value);break;case"remove":s.splice(a,1);break}}}),Object.defineProperty(t.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){Ph(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 I2e(n)?OD(n.map(function(s,a){return i._subType.validate(s,oq(r,""+a,i._subType))})):nc(r,n,"Value is not an array")}}),Object.defineProperty(t.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return vx}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){n.storedValue.splice(Number(r),1)}}),t})(yx);oR.prototype.applySnapshot=ya(oR.prototype.applySnapshot);function jZe(e){return new oR("".concat(e.name,"[]"),e)}function mae(e,t,n,r,i){for(var s=!0,a=0;;a++){var o=a<=r.length-1,l=n[a],u=o?r[a]:void 0,d=""+i[a];if(cZe(u)&&(u=u.storedValue),!l&&!o)break;if(!o)s=!1,n.splice(a,1),l instanceof Vl&&l.createObservableInstanceIfNeeded(),l.die(),a--;else if(l)if(gae(l,u))n[a]=h4(t,e,d,u,l);else{for(var h=void 0,m=a;m<n.length;m++)if(gae(n[m],u)){h=n.splice(m,1)[0];break}s=!1;var f=h4(t,e,d,u,h);n.splice(a,0,f)}else{if(us(u)&&qr(u).parent===e)throw new yn("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(qr(u).path,"'"));s=!1;var f=h4(t,e,d,u);n.splice(a,0,f)}}return s?null:n}function h4(e,t,n,r,i){Ph(e,r);function s(){if(us(r)){var o=qr(r);if(o.assertAlive(xx),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 a=s();return i&&i!==a&&(i instanceof Vl&&i.createObservableInstanceIfNeeded(),i.die()),a}function gae(e,t){if(!e.isAlive)return!1;if(us(t)){var n=qr(t);return n.isAlive&&n===e}if(e.snapshot===t)return!0;if(!(e instanceof Vl))return!1;var r=e.getReconciliationType();return e.identifier!==null&&e.identifierAttribute&&v0(t)&&r.is(t)&&r.isMatchingSnapshotId(e,t)}var bae="preProcessSnapshot",yae="postProcessSnapshot";function PZe(){return qr(this).toString()}var vae={name:"AnonymousModel",properties:{},initializers:vx};function LZe(e){var t=Object.keys(e),n=new Set;return t.forEach(function(r){if(n.has(r))throw new yn("".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 ba)throw new yn("Hook '".concat(i,"' was defined as property. Hooks should be defined as part of the actions"));var s=Object.getOwnPropertyDescriptor(e,i);if("get"in s)throw new yn("Getters are not supported as properties. Please use views instead");var a=s.value;if(a==null)throw new yn("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");if(LE(a))r[i]=Ub(HZe(a),a);else if(a instanceof aR)r[i]=Ub(a,{});else if(a instanceof oR)r[i]=Ub(a,[]);else if(!Qh(a))throw new yn("Invalid type definition for property '".concat(i,"', cannot infer a type from a value like '").concat(a,"' (").concat(typeof a,")"));return r},Dl({},e))}var ME=(function(e){Fi(t,e);function t(n){var r=e.call(this,n.name||vae.name)||this;return Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:Ir.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 s=r.preProcessor;return s?r.cloneAndEnhance({preProcessor:function(a){return s(i(a))}}):r.cloneAndEnhance({preProcessor:i})}}),Object.defineProperty(r,"postProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(i){var s=r.postProcessor;return s?r.cloneAndEnhance({postProcessor:function(a){return i(s(a))}}):r.cloneAndEnhance({postProcessor:i})}}),Object.assign(r,vae,n),r.properties=LZe(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&Ir.Identifier){if(n)throw new yn("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(s){return r.instantiateActions(s,n(s)),s};return this.cloneAndEnhance({initializers:[i]})}}),Object.defineProperty(t.prototype,"instantiateActions",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this;if(!v0(r))throw new yn("actions initializer should return a plain object containing actions");Object.getOwnPropertyNames(r).forEach(function(s){if(s in i.properties)throw new yn("'".concat(s,"' is a property and cannot be declared as an action"));if(s===bae)throw new yn("Cannot define action '".concat(bae,"', it should be defined using 'type.preProcessSnapshot(fn)' instead"));if(s===yae)throw new yn("Cannot define action '".concat(yae,"', it should be defined using 'type.postProcessSnapshot(fn)' instead"));var a=r[s],o=n[s];if(s in ba&&o){var l=a;a=function(){o.apply(null,arguments),l.apply(null,arguments)}}var u=a.$mst_middleware,d=a.bind(r);d._isFlowAction=a._isFlowAction||!1,d.$mst_middleware=u;var f=PE(n,s,d);r[s]=f,$b(n,s,f)})}}),Object.defineProperty(t.prototype,"volatile",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this;if(typeof n!="function")throw new yn("You passed an ".concat(typeof n," to volatile state as an argument, when function is expected"));var i=function(s){return r.instantiateVolatileState(s,n(s)),s};return this.cloneAndEnhance({initializers:[i]})}}),Object.defineProperty(t.prototype,"instantiateVolatileState",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this;if(!v0(r))throw new yn("volatile state initializer should return a plain object containing state");Object.getOwnPropertyNames(r).forEach(function(s){if(s in i.properties)throw new yn("'".concat(s,"' is a property and cannot be declared as volatile state"));u2e(n,s,r[s])})}}),Object.defineProperty(t.prototype,"extend",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this,i=function(s){var a=n(s),o=a.actions,l=a.views,u=a.state,d=WQe(a,["actions","views","state"]);for(var f in d)throw new yn("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '".concat(f,"'"));return u&&r.instantiateVolatileState(s,u),l&&r.instantiateViews(s,l),o&&r.instantiateActions(s,o),s};return this.cloneAndEnhance({initializers:[i]})}}),Object.defineProperty(t.prototype,"views",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this,i=function(s){return r.instantiateViews(s,n(s)),s};return this.cloneAndEnhance({initializers:[i]})}}),Object.defineProperty(t.prototype,"instantiateViews",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this;if(!v0(r))throw new yn("views initializer should return a plain object containing views");Object.getOwnPropertyNames(r).forEach(function(s){var a;if(s in i.properties)throw new yn("'".concat(s,"' is a property and cannot be declared as a view"));var o=Object.getOwnPropertyDescriptor(r,s);if("get"in o)d2e(n,s,o),h2e(n,(a={},a[s]=P1,a));else if(typeof o.value=="function")$b(n,s,o.value);else throw new yn("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,s){var a=us(s)?s:this.applySnapshotPreProcessor(s);return lq(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,s={};return i.forAllProps(function(a,o){s[a]=o.instantiate(n,a,void 0,r[a])}),s}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=Dl(Dl({},RD),{name:this.name});return Yi.object(n,xx,r)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){$b(r,"toString",PZe),this.forAllProps(function(i){o2e(r,i,n.unbox)}),this.initializers.reduce(function(i,s){return s(i)},r),tq(r,this.willChange),nq(r,this.didChange)}}),Object.defineProperty(t.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=n,i=qr(r.object),s=r.name;i.assertWritable({subpath:s});var a=i.type.properties[s];return a&&(Ph(a,r.newValue),r.newValue=a.reconcile(i.getChildNode(s),r.newValue,i,s)),r}}),Object.defineProperty(t.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=n,i=qr(r.object),s=i.type.properties[r.name];if(s){var a=r.oldValue?r.oldValue.snapshot:void 0;i.emitPatch({op:"replace",path:zb(r.name),value:r.newValue.snapshot,oldValue:a},i)}}}),Object.defineProperty(t.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(n){var r=this,i=[];return this.forAllProps(function(s){i.push(r.getChildNode(n,s))}),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 yn("Not a value property: "+r);var s=Sf(n.storedValue,r),a=(i=s.raw)===null||i===void 0?void 0:i.call(s);if(!a)throw new yn("Node not available for property "+r);return a}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){var i=this;r===void 0&&(r=!0);var s={};return this.forAllProps(function(a,o){var l=bx(n.storedValue,a);l.reportObserved(),s[a]=i.getChildNode(n,a).snapshot}),r?this.applySnapshotPostProcessor(s):s}}),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 yn("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){Ph(this,r);var i=this.applySnapshotPreProcessor(r);this.forAllProps(function(s){n.storedValue[s]=i[s]})}}),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,s=this.applySnapshotPreProcessor(n);return v0(s)?OD(this.propertyNames.map(function(a){return i.properties[a].validate(s[a],oq(r,a,i.properties[a]))})):nc(r,s,"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 xx}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){n.storedValue[r]=void 0}}),t})(yx);ME.prototype.applySnapshot=ya(ME.prototype.applySnapshot);function MZe(){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 ME({name:n,properties:r})}function FZe(){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,s){return i.cloneAndEnhance({name:i.name+"_"+s.name,properties:s.properties,initializers:s.initializers,preProcessor:function(a){return s.applySnapshotPreProcessor(i.applySnapshotPreProcessor(a))},postProcessor:function(a){return s.applySnapshotPostProcessor(i.applySnapshotPostProcessor(a))}})}).named(r)}function BZe(e){return Qh(e)&&(e.flags&Ir.Object)>0}var pp=(function(e){Fi(t,e);function t(n,r,i,s){s===void 0&&(s=hZe);var a=e.call(this,n)||this;return Object.defineProperty(a,"flags",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"checker",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(a,"initializer",{enumerable:!0,configurable:!0,writable:!0,value:s}),a.flags=r,a}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,s){return sg(this,n,r,i,s)}}),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(LE(n)&&this.checker(n))return Wl();var i=this.name==="Date"?"Date or a unix milliseconds timestamp":this.name;return nc(r,n,"Value is not a ".concat(i))}}),t})(Dy),B2e=new pp("string",Ir.String,function(e){return typeof e=="string"}),$2e=new pp("number",Ir.Number,function(e){return typeof e=="number"}),$Ze=new pp("integer",Ir.Integer,function(e){return pZe(e)}),zZe=new pp("float",Ir.Float,function(e){return mZe(e)}),UZe=new pp("finite",Ir.Finite,function(e){return gZe(e)}),z2e=new pp("boolean",Ir.Boolean,function(e){return typeof e=="boolean"}),U2e=new pp("null",Ir.Null,function(e){return e===null}),H2e=new pp("undefined",Ir.Undefined,function(e){return e===void 0}),V2e=new pp("Date",Ir.Date,function(e){return typeof e=="number"||e instanceof Date},function(e){return e instanceof Date?e:new Date(e)});V2e.getSnapshot=function(e){return e.storedValue.getTime()};var W2e=V2e;function HZe(e){switch(typeof e){case"string":return B2e;case"number":return $2e;case"boolean":return z2e;case"object":if(e instanceof Date)return W2e}throw new yn("Cannot determine primitive type from value "+e)}function VZe(e){return Qh(e)&&(e.flags&(Ir.String|Ir.Number|Ir.Integer|Ir.Boolean|Ir.Date))>0}var WZe=(function(e){Fi(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:Ir.Literal}),r.value=n,r}return Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,s){return sg(this,n,r,i,s)}}),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 LE(n)&&n===this.value?Wl():nc(r,n,"Value is not a literal ".concat(JSON.stringify(this.value)))}}),t})(Dy);function q2e(e){return new WZe(e)}var qZe=(function(e){Fi(t,e);function t(n,r,i,s){var a=e.call(this,n)||this;return Object.defineProperty(a,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"_predicate",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(a,"_message",{enumerable:!0,configurable:!0,writable:!0,value:s}),a}return Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|Ir.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,s){return this._subtype.instantiate(n,r,i,s)}}),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 s=us(n)?qr(n).snapshot:n;return this._predicate(s)?Wl():nc(r,n,this._message(n))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,s){return this._subtype.reconcile(n,r,i,s)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),t})(Xh);function GZe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=typeof e[0]=="string"?e.shift():Qh(e[0])?e[0].name:null,r=e[0],i=e[1],s=e[2]?e[2]:function(a){return"Value does not respect the refinement predicate"};return new qZe(n,r,i,s)}function KZe(e,t){var n=typeof e=="string"?t:e,r=ID.apply(void 0,Yh([],Kh(n.map(function(i){return q2e(""+i)})),!1));return typeof e=="string"&&(r.name=e),r}var YZe=(function(e){Fi(t,e);function t(n,r,i){var s=e.call(this,n)||this;return Object.defineProperty(s,"_types",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(s,"_dispatcher",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(s,"_eager",{enumerable:!0,configurable:!0,writable:!0,value:!0}),i=Dl({eager:!0,dispatcher:void 0},i),s._dispatcher=i.dispatcher,i.eager||(s._eager=!1),s}return Object.defineProperty(t.prototype,"flags",{get:function(){var n=Ir.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,s){var a=this.determineType(s,void 0);if(!a)throw new yn("No matching type for union "+this.describe());return a.instantiate(n,r,i,s)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,s){var a=this.determineType(r,n.getReconciliationType());if(!a)throw new yn("No matching type for union "+this.describe());return a.reconcile(n,r,i,s)}}),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=[],s=0,a=0;a<this._types.length;a++){var o=this._types[a],l=o.validate(n,r);if(l.length===0){if(this._eager)return Wl();s++}else i.push(l)}return s===1?Wl():nc(r,n,"No type is applicable for the union").concat(OD(i))}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._types}}),t})(Xh);function ID(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=Qh(e)?void 0:e,i=Qh(e)?Yh([e],Kh(t),!1):t,s="("+i.map(function(a){return a.name}).join(" | ")+")";return new YZe(s,i,r)}function XZe(e){return Qh(e)&&(e.flags&Ir.Union)>0}var QZe=(function(e){Fi(t,e);function t(n,r,i){var s=e.call(this,n.name)||this;return Object.defineProperty(s,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(s,"_defaultValue",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(s,"optionalValues",{enumerable:!0,configurable:!0,writable:!0,value:i}),s}return Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|Ir.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,s){if(this.optionalValues.indexOf(s)>=0){var a=this.getDefaultInstanceOrSnapshot();return this._subtype.instantiate(n,r,i,a)}return this._subtype.instantiate(n,r,i,s)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,s){return this._subtype.reconcile(n,this.optionalValues.indexOf(r)<0&&this._subtype.is(r)?r:this.getDefaultInstanceOrSnapshot(),i,s)}}),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"&&Ph(this,n),n}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return this.optionalValues.indexOf(n)>=0?Wl():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})(Xh);function ZZe(e,t){if(typeof t!="function"&&us(t))throw new yn("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead")}function Ub(e,t,n){return ZZe(e,t),new QZe(e,t,n||JZe)}var JZe=[void 0],eJe=Ub(H2e,void 0),tJe=Ub(U2e,null);function G2e(e){return ID(e,eJe)}function nJe(e){return ID(e,tJe)}var rJe=(function(e){Fi(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)|Ir.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 yn("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,s){return this.getSubType(!0).instantiate(n,r,i,s)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,s){return this.getSubType(!0).reconcile(n,r,i,s)}}),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):Wl()}}),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||C2e}}),t})(Xh);function iJe(e,t){var n=typeof e=="string"?e:"late(".concat(e.toString(),")"),r=typeof e=="string"?t:e;return new rJe(n,r)}function sJe(e,t){return new aJe(e,t)}var aJe=(function(e){Fi(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:Ir.Lazy}),Object.defineProperty(i,"loadedType",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(i,"pendingNodeList",{enumerable:!0,configurable:!0,writable:!0,value:Yi.array()}),eae(function(){return i.pendingNodeList.length>0&&i.pendingNodeList.some(function(s){return s.isAlive&&i.options.shouldLoadPredicate(s.parent?s.parent.value:null)})},function(){i.options.loadType().then(ya(function(s){i.loadedType=s,i.pendingNodeList.forEach(function(a){a.parent&&i.loadedType&&a.parent.applyPatches([{op:"replace",path:"/".concat(a.subpath),value:a.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,s){var a=this;if(this.loadedType)return this.loadedType.instantiate(n,r,i,s);var o=sg(this,n,r,i,s);return this.pendingNodeList.push(o),eae(function(){return!o.isAlive},function(){return a.pendingNodeList.splice(a.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):P2e(n)?Wl():nc(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,s){return this.loadedType?(n.die(),this.loadedType.instantiate(i,s,i.environment,r)):e.prototype.reconcile.call(this,n,r,i,s)}}),t})(Dy),K2e=(function(e){Fi(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:Ir.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,s){return sg(this,n,r,i,s)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return P2e(n)?this.subType?this.subType.validate(n,r):Wl():nc(r,n,"Value is not serializable and cannot be frozen")}}),t})(Dy),xae=new K2e;function oJe(e){return arguments.length===0?xae:Qh(e)?new K2e(e):Ub(xae,e)}function lJe(e){switch(e){case ba.beforeDestroy:return"destroy";case ba.beforeDetach:return"detach";default:return}}var cJe=(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}),cq(t))this.identifier=t;else if(us(t)){var r=qr(t);if(!r.identifierAttribute)throw new yn("Can only store references with a defined identifier attribute.");var i=r.unnormalizedIdentifier;if(i==null)throw new yn("Can only store references to tree nodes with a defined identifier.");this.identifier=i}else throw new yn("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=MC(this.identifier),r=t.root,i=r.identifierCache.getLastCacheModificationPerId(n);if(!this.resolvedReference||this.resolvedReference.lastCacheModification!==i){var s=this.targetType,a=r.identifierCache.resolve(s,n);if(!a)throw new uJe("[mobx-state-tree] Failed to resolve reference '".concat(this.identifier,"' to type '").concat(this.targetType.name,"' (from node: ").concat(t.path,")"));this.resolvedReference={node:a,lastCacheModification:i}}}}),Object.defineProperty(e.prototype,"resolvedValue",{get:function(){return this.updateResolvedReference(this.node),this.resolvedReference.node.value},enumerable:!1,configurable:!0}),e})(),uJe=(function(e){Fi(t,e);function t(n){var r=e.call(this,n)||this;return Object.setPrototypeOf(r,t.prototype),r}return t})(Error),Y2e=(function(e){Fi(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:Ir.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 cq(n)?Wl():nc(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,s){var a=r.parent;if(!(!a||!a.isAlive)){var o=a.storedValue;o&&this.onInvalidated({cause:n,parent:o,invalidTarget:s?s.storedValue:void 0,invalidId:i,replaceRef:function(l){DE(r.root.storedValue,{op:"replace",value:l,path:r.path})},removeRef:function(){BZe(a.type)?this.replaceRef(void 0):DE(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,s=this.getValue(n);if(s){var a=qr(s),o=function(d,f){var h=lJe(f);h&&i.fireInvalidated(h,n,r,a)},l=a.registerHook(ba.beforeDetach,o),u=a.registerHook(ba.beforeDestroy,o);return function(){l(),u()}}}}),Object.defineProperty(t.prototype,"watchTargetNodeForInvalidations",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i){var s=this;if(this.onInvalidated){var a;n.registerHook(ba.beforeDestroy,function(){a&&a()});var o=function(l){a&&a();var u=n.parent,d=u&&u.storedValue;if(u&&u.isAlive&&d){var f=void 0;i?f=!!i.get(r,d):f=n.root.identifierCache.has(s.targetType,MC(r)),f?a=s.addTargetNodeWatcher(n,r):l||s.fireInvalidated("invalidSnapshotReference",n,r,null)}};n.state===lo.FINALIZED?o(!0):(n.isRoot||n.root.registerHook(ba.afterCreationFinalization,function(){n.parent&&n.parent.createObservableInstanceIfNeeded()}),n.registerHook(ba.afterAttach,function(){o(!1)}))}}}),t})(Dy),dJe=(function(e){Fi(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,s){var a=us(s)?YQe(s):s,o=new cJe(s,this.targetType),l=sg(this,n,r,i,o);return o.node=l,this.watchTargetNodeForInvalidations(l,a,void 0),l}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,s){if(!n.isDetaching&&n.type===this){var a=us(r),o=n.storedValue;if(!a&&o.identifier===r||a&&o.resolvedValue===r)return n.setParent(i,s),n}var l=this.instantiate(i,s,void 0,r);return n.die(),l}}),t})(Y2e),fJe=(function(e){Fi(t,e);function t(n,r,i){var s=e.call(this,n,i)||this;return Object.defineProperty(s,"options",{enumerable:!0,configurable:!0,writable:!0,value:r}),s}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,s){var a=us(s)?this.options.set(s,n?n.storedValue:null):s,o=sg(this,n,r,i,a);return this.watchTargetNodeForInvalidations(o,a,this.options),o}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,s){var a=us(r)?this.options.set(r,n?n.storedValue:null):r;if(!n.isDetaching&&n.type===this&&n.storedValue===a)return n.setParent(i,s),n;var o=this.instantiate(i,s,void 0,a);return n.die(),o}}),t})(Y2e);function X2e(e,t){var n=t||void 0,r=t?t.onInvalidated:void 0;return n&&(n.get||n.set)?new fJe(e,{get:n.get,set:n.set},r):new dJe(e,r)}function hJe(e,t){var n=X2e(e,Dl(Dl({},t),{onInvalidated:function(r){t&&t.onInvalidated&&t.onInvalidated(r),r.removeRef()}}));return t&&t.acceptsUndefined===!1?n:G2e(n)}var Q2e=(function(e){Fi(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:Ir.Identifier}),i}return Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,s){if(!n||!(n.type instanceof ME))throw new yn("Identifier types can only be instantiated as direct child of a model type");return sg(this,n,r,i,s)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,s){if(n.storedValue!==r)throw new yn("Tried to change identifier from '".concat(n.storedValue,"' to '").concat(r,"'. Changing identifiers is not allowed."));return n.setParent(i,s),n}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r){return typeof n!==this.validType?nc(r,n,"Value is not a valid ".concat(this.describe(),", expected a ").concat(this.validType)):Wl()}}),t})(Dy),pJe=(function(e){Fi(t,e);function t(){var n=e.call(this,"identifier","string")||this;return Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:Ir.Identifier}),n}return Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifier"}}),t})(Q2e),mJe=(function(e){Fi(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})(Q2e),gJe=new pJe,bJe=new mJe;function MC(e){return""+e}function cq(e){return typeof e=="string"||typeof e=="number"}function yJe(e){return new vJe(e)}var vJe=(function(e){Fi(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:Ir.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 Wl();var i=this.options.getValidationMessage(n);return i?nc(r,n,"Invalid value for type '".concat(this.name,"': ").concat(i)):Wl()}}),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,s){var a=this.options.isTargetType(s)?s:this.options.fromSnapshot(s,n&&n.root.environment);return sg(this,n,r,i,a)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(n,r,i,s){var a=!this.options.isTargetType(r);if(!n.isDetaching){var o=n.type===this&&(a?r===n.snapshot:r===n.storedValue);if(o)return n.setParent(i,s),n}var l=a?this.options.fromSnapshot(r,i.root.environment):r,u=this.instantiate(i,s,void 0,l);return n.die(),u}}),t})(Dy),Bt={enumeration:KZe,model:MZe,compose:FZe,custom:yJe,reference:X2e,safeReference:hJe,union:ID,optional:Ub,literal:q2e,maybe:G2e,maybeNull:nJe,refinement:GZe,string:B2e,boolean:z2e,number:$2e,integer:$Ze,float:zZe,finite:UZe,Date:W2e,map:DZe,array:jZe,frozen:oJe,identifier:gJe,identifierNumber:bJe,late:iJe,lazy:sJe,undefined:H2e,null:U2e,snapshotProcessor:RZe};const ls="";function Z2e(){return Jt({queryKey:["apps"],queryFn:()=>ht(`${ls}/api/apps`)})}function xJe(){const e=It();return wt({mutationFn:({repositoryId:t,name:n,branch:r,composeFile:i,autoDeployEnabled:s})=>ht(`${ls}/api/apps`,{method:"POST",body:JSON.stringify({repositoryId:t,name:n??t,branch:r,composeFile:i,autoDeployEnabled:s,services:[]})}),onSuccess:(t,{repositoryId:n})=>{e.invalidateQueries({queryKey:["apps"]}),e.invalidateQueries({queryKey:["apps","repository",n]}),e.invalidateQueries({queryKey:["repositories"]})}})}function uq(){const e=It();return wt({mutationFn:({id:t,updates:n})=>ht(`${ls}/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 _Je(){const e=It();return wt({mutationFn:t=>ht(`${ls}/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 J2e(){const e=It();return wt({mutationFn:t=>ht(`${ls}/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 SJe(e,t,n=100){return Jt({queryKey:["apps",e,"logs",t,n],queryFn:()=>{const r=new URLSearchParams;return t&&r.set("service",t),r.set("tail",String(n)),ht(`${ls}/api/apps/${e}/logs?${r}`)},enabled:!!e,refetchInterval:5e3})}function eCe(e){return Jt({queryKey:["apps",e,"status"],queryFn:()=>ht(`${ls}/api/apps/${e}/status`),enabled:!!e,refetchInterval:1e4})}function wJe(e){return Jt({queryKey:["apps",e,"deployments"],queryFn:()=>ht(`${ls}/api/apps/${e}/deployments`),enabled:!!e,refetchInterval:5e3})}function EJe(e){return Jt({queryKey:["compose","find",e],queryFn:()=>ht(`${ls}/api/compose/find?repoId=${e}`),enabled:!!e})}function CJe(e,t){return Jt({queryKey:["compose","file",e,t],queryFn:()=>ht(`${ls}/api/fs/read?path=${encodeURIComponent(t)}&root=${encodeURIComponent(e)}`),enabled:!!e&&!!t})}function kJe(){const e=It();return wt({mutationFn:({repoPath:t,composeFile:n,content:r})=>ht(`${ls}/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 tCe(){const e=It();return wt({mutationFn:t=>ht(`${ls}/api/apps/${t}/sync-services`,{method:"POST"}),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["apps",n]}),e.invalidateQueries({queryKey:["apps"]})}})}function TJe(e){const{data:t}=Z2e();return t?.find(n=>n.repository?.id===e)??null}function nCe(){return Jt({queryKey:["deployment","prerequisites"],queryFn:()=>ht(`${ls}/api/deployment/prerequisites`),staleTime:1e4})}function AJe(){const e=It();return wt({mutationFn:()=>ht(`${ls}/api/deployment/traefik/start`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["deployment","prerequisites"]})}})}function rCe(){return Jt({queryKey:["deployment","settings"],queryFn:()=>ht(`${ls}/api/deployment/settings`)})}function NJe(){const e=It();return wt({mutationFn:t=>ht(`${ls}/api/deployment/settings`,{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{e.invalidateQueries({queryKey:["deployment","settings"]}),e.invalidateQueries({queryKey:["deployment","prerequisites"]})}})}function OJe(e){return Jt({queryKey:["apps",e,"swarm-compose"],queryFn:()=>ht(`${ls}/api/apps/${e}/swarm-compose`),enabled:!1})}const qg="fulcrum-chat-session",_ae=[{id:"opus",label:"Opus",description:"Most powerful"},{id:"sonnet",label:"Sonnet",description:"Fast & capable"},{id:"haiku",label:"Haiku",description:"Fastest"}],NA=Bt.model("ChatMessage",{id:Bt.identifier,role:Bt.enumeration(["user","assistant"]),content:Bt.string,timestamp:Bt.Date,isStreaming:Bt.optional(Bt.boolean,!1),attachments:Bt.optional(Bt.frozen(),[])}),RJe=Bt.model("ChatStore",{sessionId:Bt.maybeNull(Bt.string),messages:Bt.array(NA),isStreaming:Bt.optional(Bt.boolean,!1),isOpen:Bt.optional(Bt.boolean,!1),error:Bt.maybeNull(Bt.string),provider:Bt.optional(Bt.enumeration(["claude","opencode"]),"claude"),model:Bt.optional(Bt.enumeration(["opus","sonnet","haiku"]),"opus"),opencodeModel:Bt.maybeNull(Bt.string)}).volatile(()=>({eventSource:null,abortController:null,streamReader:null,streamGeneration:0})).views(e=>({get hasMessages(){return e.messages.length>0},get lastMessage(){return e.messages[e.messages.length-1]}})).actions(e=>{const t=()=>sR(e).log;return{setOpen(n){e.isOpen=n,n&&!e.sessionId&&this.createSession()},toggle(){this.setOpen(!e.isOpen)},setModel(n){e.model=n},setProvider(n){e.provider!==n&&(e.sessionId=null,e.provider=n)},setOpencodeModel(n){e.opencodeModel=n},createSession:Sb(function*(){const n=t();try{const r=new Date().toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),i=yield fetch(`${ls}/api/assistant/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e.provider,title:r})});if(!i.ok)throw new Error("Failed to create chat session");const s=yield i.json();if(!s.id)throw new Error("Invalid session response");e.sessionId=s.id,localStorage.setItem(qg,JSON.stringify({sessionId:s.id,provider:e.provider})),n.info("Created chat session",{sessionId:s.id,provider:e.provider})}catch(r){const i=r instanceof Error?r.message:String(r);n.error("Failed to create chat session",{error:i}),e.error=i}}),loadSession:Sb(function*(){const n=t(),r=localStorage.getItem(qg);if(!r)return;let i,s="claude";try{const a=JSON.parse(r);i=a.sessionId,s=a.provider||"claude"}catch{i=r}try{const a=yield fetch(`${ls}/api/assistant/sessions/${i}`);if(a.ok){const o=yield a.json();if(e.sessionId=i,e.provider=o.provider||s,o.messages&&o.messages.length>0){e.messages.clear();for(const l of o.messages)e.messages.push(NA.create({id:crypto.randomUUID(),role:l.role,content:l.content,timestamp:new Date(l.createdAt),isStreaming:!1}))}n.info("Restored session",{sessionId:i,provider:e.provider,messageCount:o.messages?.length??0})}else localStorage.removeItem(qg),n.debug("Removed stale session from storage",{sessionId:i})}catch{localStorage.removeItem(qg)}}),sendMessage:Sb(function*(r,i,s){const a=t();if(!e.sessionId)try{const y=new Date().toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),v=yield fetch(`${ls}/api/assistant/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e.provider,title:y})});if(!v.ok)throw new Error("Failed to create chat session");const _=yield v.json();if(!_.id)throw new Error("Invalid session response");e.sessionId=_.id,localStorage.setItem(qg,JSON.stringify({sessionId:_.id,provider:e.provider})),a.info("Created chat session",{sessionId:_.id,provider:e.provider})}catch(y){const v=y instanceof Error?y.message:String(y);a.error("Failed to create chat session",{error:v}),e.error=v;return}const o=e.streamGeneration;e.abortController=new AbortController;let l=r;if(s&&s.length>0){const y=s.filter(v=>v.type!=="image").map(v=>`[${v.filename}]`);if(y.length>0){const v=y.join(" ");l=r?`${v} ${r}`:v}}const u=s?s.map(y=>({type:y.type,dataUrl:y.type==="image"?y.dataUrl:void 0,filename:y.filename})):[],d=NA.create({id:crypto.randomUUID(),role:"user",content:l,timestamp:new Date,attachments:u});e.messages.push(d);const f=NA.create({id:crypto.randomUUID(),role:"assistant",content:"",timestamp:new Date,isStreaming:!0});e.messages.push(f),e.isStreaming=!0,e.error=null;const h=y=>{if(e.streamGeneration!==o)return;const v=e.messages[e.messages.length-1];v&&v.role==="assistant"&&(v.content=y)},m=()=>{if(e.streamGeneration!==o)return;const y=e.messages[e.messages.length-1];y&&y.role==="assistant"&&(y.isStreaming=!1),e.isStreaming=!1,e.abortController=null,e.streamReader=null},g=y=>{if(e.streamGeneration!==o)return;a.error("Chat error",{error:y}),e.error=y,e.isStreaming=!1;const v=e.messages[e.messages.length-1];v&&v.role==="assistant"&&!v.content?e.messages.pop():v&&v.role==="assistant"&&(v.isStreaming=!1)};try{e.eventSource&&(e.eventSource.close(),e.eventSource=null);const y=e.provider==="opencode"?e.opencodeModel:e.model,v=s?.map(w=>({mediaType:w.mediaType,data:w.type==="text"?w.dataUrl:w.dataUrl.split(",")[1],filename:w.filename,type:w.type})),_=yield fetch(`${ls}/api/assistant/sessions/${e.sessionId}/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:r,model:y,context:i,provider:e.provider,attachments:v,...e.provider==="claude"&&{uiMode:"compact"}}),signal:e.abortController?.signal});if(!_.ok)throw new Error("Failed to send message");const S=_.body?.getReader();if(!S)throw new Error("No response body");e.streamReader=S;const E=new TextDecoder;let T="",k="";for(;;){const{done:w,value:A}=yield S.read();if(w)break;T+=E.decode(A,{stream:!0});const R=T.split(`
33
33
  `);T=R.pop()||"";for(const I of R)if(!I.startsWith("event: ")){if(I.startsWith("data: ")){const D=I.slice(6);try{const j=JSON.parse(D);"text"in j?(k+=j.text,h(k)):"content"in j?h(j.content):"message"in j&&g(j.message)}catch{}}}}m()}catch(y){if(y instanceof Error&&y.name==="AbortError"){a.debug("Chat stream aborted by user"),m();return}const v=y instanceof Error?y.message:String(y);a.error("Failed to send message",{error:v}),g(v)}}),cancelStream(){const n=t();e.streamReader&&(e.streamReader.cancel().catch(()=>{}),e.streamReader=null),e.abortController&&(e.abortController.abort(),e.abortController=null);const r=e.messages[e.messages.length-1];r&&r.role==="assistant"&&(r.isStreaming=!1),e.isStreaming=!1,n.info("Cancelled streaming response")},clearMessages(){const n=t();e.isStreaming&&(e.streamGeneration+=1,e.isStreaming=!1,e.streamReader=null,e.abortController=null),e.messages.clear(),e.sessionId=null,e.error=null,localStorage.removeItem(qg),n.info("Cleared chat messages, ready for new session")},endSession(){const n=t();e.eventSource&&(e.eventSource.close(),e.eventSource=null),n.info("Cleared chat state",{sessionId:e.sessionId,provider:e.provider}),e.sessionId=null,e.messages.clear(),e.isStreaming=!1,e.error=null,localStorage.removeItem(qg)},reset(){this.endSession(),e.isOpen=!1}}});let p4=null,Sae=!1;function IJe(){return p4||(p4=RJe.create({sessionId:null,messages:[],isStreaming:!1,isOpen:!1,error:null,provider:"claude",model:"opus",opencodeModel:null},{log:vc()})),p4}function iCe(){const e=x.useMemo(()=>IJe(),[]),t=x.useRef(!1);x.useEffect(()=>{!t.current&&!Sae&&(t.current=!0,Sae=!0,e.loadSession())},[e]);const n=x.useCallback(()=>e.toggle(),[e]),r=x.useCallback(()=>e.setOpen(!0),[e]),i=x.useCallback(()=>e.setOpen(!1),[e]),s=x.useCallback((h,m,g)=>e.sendMessage(h,m,g),[e]),a=x.useCallback(()=>e.clearMessages(),[e]),o=x.useCallback(h=>e.setProvider(h),[e]),l=x.useCallback(h=>e.setModel(h),[e]),u=x.useCallback(h=>e.setOpencodeModel(h),[e]),d=x.useCallback(()=>e.reset(),[e]),f=x.useCallback(()=>e.cancelStream(),[e]);return{isOpen:e.isOpen,isStreaming:e.isStreaming,messages:e.messages,hasMessages:e.hasMessages,error:e.error,sessionId:e.sessionId,provider:e.provider,model:e.model,opencodeModel:e.opencodeModel,toggle:n,open:r,close:i,sendMessage:s,clearMessages:a,setProvider:o,setModel:l,setOpencodeModel:u,reset:d,cancelStream:f}}const wae=[{to:"/tasks",icon:iD,labelKey:"header.tasks",matchPrefix:!0},{to:"/calendar",icon:op,labelKey:"header.calendar",matchPrefix:!0},{to:"/terminals",icon:M_e,labelKey:"header.terminals",matchPrefix:!1},{to:"/assistant",icon:null,lucideIcon:Um,labelKey:"header.assistant",matchPrefix:!0},{to:"/projects",icon:SE,labelKey:"header.projects",matchPrefix:!0},{to:"/jobs",icon:Dw,labelKey:"header.jobs",matchPrefix:!0},{to:"/apps",icon:vb,labelKey:"header.apps",matchPrefix:!0},{to:"/monitoring",icon:j_e,labelKey:"header.monitoring",matchPrefix:!0}];function DJe({onNewTaskRef:e,onOpenCommandPalette:t}){const{t:n}=Ot("navigation"),{location:r}=Ls(),{resolvedTheme:i}=ol(),s=i==="dark",a=r.pathname,[o,l]=x.useState(!1),[u,d]=x.useState(""),{toggle:f,isOpen:h}=iCe(),m=(g,y)=>y?a.startsWith(g):a===g;return x.useEffect(()=>{e?.(()=>l(!0))},[e]),c.jsxs("header",{className:"sticky top-0 z-10 flex h-10 shrink-0 items-center justify-between border-b border-border px-4 max-sm:px-2",style:{background:"var(--gradient-header)"},children:[c.jsxs("div",{className:"flex min-w-0 items-center gap-4 max-sm:gap-2",children:[c.jsx(_ze,{className:"sm:hidden",value:u,onValueChange:d,children:c.jsx(Sze,{children:c.jsxs(wze,{children:[c.jsxs(Cze,{className:"bg-transparent hover:bg-muted/50 data-open:bg-muted/50 gap-1 px-2",children:[c.jsx(Z,{icon:zN,size:16,strokeWidth:2}),c.jsx("span",{className:"sr-only",children:"Menu"})]}),c.jsx(kze,{className:"min-w-48",children:wae.map(g=>c.jsxs(Aze,{href:g.to,active:m(g.to,g.matchPrefix),render:c.jsx(Pr,{to:g.to}),onClick:()=>d(""),children:[g.icon?c.jsx(Z,{icon:g.icon,size:16,strokeWidth:2}):g.lucideIcon?c.jsx(g.lucideIcon,{className:"size-4"}):null,n(g.labelKey)]},g.to))})]})})}),c.jsx("nav",{className:"hidden items-center gap-0.5 sm:flex lg:gap-1",children:wae.map(g=>{const y=m(g.to,g.matchPrefix);return c.jsxs(Pr,{to:g.to,title:n(g.labelKey),className:Ae("relative flex items-center gap-0 rounded-md px-2 py-1 text-sm font-medium transition-colors lg:gap-1.5",y?"bg-background text-foreground":"text-foreground/60 hover:text-foreground","after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:bg-foreground","after:origin-center after:transition-transform after:duration-200",y?"after:scale-x-100":"after:scale-x-0 hover:after:scale-x-100"),children:[g.icon?c.jsx(Z,{icon:g.icon,size:16,strokeWidth:2,"data-slot":"icon"}):g.lucideIcon?c.jsx(g.lucideIcon,{className:"size-4","data-slot":"icon"}):null,c.jsx("span",{className:"hidden lg:inline",children:n(g.labelKey)})]},g.to)})})]}),c.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[c.jsx(XW,{open:o,onOpenChange:l}),c.jsxs("button",{onClick:f,className:"sm:hidden relative w-7 h-7 rounded-full flex items-center justify-center transition-all duration-300 hover:scale-110",style:{background:s?"linear-gradient(135deg, var(--destructive) 0%, color-mix(in oklch, var(--destructive) 80%, black) 100%)":"linear-gradient(135deg, var(--accent) 0%, color-mix(in oklch, var(--accent) 80%, black) 100%)",boxShadow:s?"0 0 8px color-mix(in oklch, var(--destructive) 40%, transparent)":"0 0 8px color-mix(in oklch, var(--accent) 40%, transparent)"},title:"AI Assistant",children:[c.jsx(Um,{className:`w-4 h-4 text-white transition-transform ${h?"rotate-12":""}`}),!h&&c.jsx("div",{className:`absolute inset-0 rounded-full animate-pulse opacity-30 ${s?"bg-destructive":"bg-accent"}`})]}),c.jsx(_e,{variant:"ghost",size:"icon-sm",onClick:t,title:n("header.commandPalette",{shortcut:"⌘K"}),className:"hidden cursor-pointer sm:inline-flex",children:c.jsx(Z,{icon:UO,size:16,strokeWidth:2})}),c.jsx(Pr,{to:"/settings",className:Ae("relative flex items-center justify-center rounded-md p-1.5 transition-colors",a==="/settings"?"bg-background text-foreground":"text-foreground/60 hover:text-foreground","after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:bg-foreground","after:origin-center after:transition-transform after:duration-200",a==="/settings"?"after:scale-x-100":"after:scale-x-0 hover:after:scale-x-100"),children:c.jsx(Z,{icon:X_e,size:16,strokeWidth:2})})]})]})}function jJe(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/terminal`}const PJe=10,LJe=2e3;function MJe(){const e=It(),t=Ni(),n=x.useRef(null),r=x.useRef(void 0),i=x.useRef(0),s=x.useRef(void 0),a=x.useCallback(l=>{try{const u=JSON.parse(l.data);if(u.type==="task:updated")e.invalidateQueries({queryKey:["tasks"]});else if(u.type==="notification"&&"payload"in u){let d=function(){const D=S&&!E?"/goat.jpeg":"/logo.png";if(v!==!1){const F={description:m,icon:c.jsx("img",{src:D,alt:"",className:"size-8 shrink-0 aspect-square rounded-sm object-cover"}),...y&&{action:{label:"View",onClick:()=>t({to:"/tasks/$taskId",params:{taskId:y}})}}};switch(g){case"success":rt.success(h,F);break;case"error":rt.error(h,F);break;case"warning":rt.warning(h,F);break;default:rt.info(h,F);break}}if(_!==!1&&"Notification"in window&&window.parent===window&&Notification.permission==="granted"&&new Notification(h,{body:m,icon:D,tag:f}),S){const z="fulcrum:lastSoundPlayed",P=Date.now(),L=localStorage.getItem(z);if(L){const $=parseInt(L.split(":")[0]);if(P-$<1e3)return}const M=`${P}:${Math.random().toString(36).slice(2)}`;localStorage.setItem(z,M),setTimeout(()=>{if(localStorage.getItem(z)!==M)return;let $=!1;const W=()=>{if($)return;$=!0,new Audio("/sounds/goat-bleat.mp3").play().catch(()=>{})},Y=new Audio("/api/uploads/sound");Y.onerror=W,Y.play().catch(W)},50)}window.parent!==window&&window.parent.postMessage({type:"fulcrum:notification",title:h,message:m,notificationType:g},"*")};const{id:f,title:h,message:m,notificationType:g,taskId:y,showToast:v,showDesktop:_,playSound:S,isCustomSound:E}=u.payload,T=`fulcrum:notification:${f}`,k=50,w=1e4;if(localStorage.getItem(T))return;const R=`${Date.now()}:${Math.random().toString(36).slice(2)}`;localStorage.setItem(T,R),setTimeout(()=>{localStorage.getItem(T)===R&&(setTimeout(()=>localStorage.removeItem(T),w),d())},k)}}catch{}},[e,t]),o=x.useCallback(()=>{const l=n.current;if(l&&(l.readyState===WebSocket.CONNECTING||l.readyState===WebSocket.OPEN))return;const u=jJe(),d=new WebSocket(u);n.current=d,d.onopen=()=>{i.current=0},d.onmessage=a,d.onclose=()=>{n.current===d&&(n.current=null),i.current<PJe&&(i.current++,r.current=setTimeout(()=>{s.current?.()},LJe))},d.onerror=()=>{}},[a]);s.current=o,x.useEffect(()=>{"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()},[]),x.useEffect(()=>(o(),()=>{r.current&&clearTimeout(r.current);const l=n.current;l&&(l.readyState===WebSocket.OPEN&&l.close(),n.current=null)}),[o])}const FJe={save:"Save Changes",cancel:"Cancel",delete:"Delete",create:"Create",reset:"Reset to default",browse:"Browse",clearFilters:"Clear filters"},BJe={loading:"Loading...",saving:"Saving...",saved:"Saved",error:"Error",calculating:"calculating...",validating:"Validating...",creating:"Creating...",deleting:"Deleting...",loggingIn:"Logging in...",uploading:"Uploading..."},$Je={justNow:"just now",minuteAgo:"1 minute ago",minutesAgo:"{{count}} minutes ago",hourAgo:"1 hour ago",hoursAgo:"{{count}} hours ago",dayAgo:"1 day ago",daysAgo:"{{count}} days ago"},zJe={one:"{{count}} result",other:"{{count}} results"},UJe={TO_DO:"To Do",IN_PROGRESS:"In Progress",IN_REVIEW:"In Review",DONE:"Done",CANCELED:"Canceled",ORPHANED:"Orphaned"},HJe={loginTitle:"Login to Fulcrum",username:"Username",password:"Password",login:"Login",loginFailed:"Login failed"},VJe={sentToClaude:"Sent to Claude Code",noTerminal:"No terminal available",syncedFromMain:"Synced from main",mergedToMain:"Merged to main",pushedToOrigin:"Pushed to origin",parentSynced:"Parent synced with origin",prCreated:"PR created",prExists:"PR already exists"},WJe={imageUploadFailed:"Failed to upload image",terminalNotConnected:"Terminal not connected",terminalNotConnectedDesc:"Please wait for the connection to establish"},qJe={notInstalled:"OpenCode not installed",selectModel:"Select model",useDefault:"Use default",noModelsFound:"No models found"},GJe={manualDnsRequired:"Manual DNS required",manualDnsRequiredDesc:"Cloudflare API token not configured. You must create DNS records manually for your domains.",deployToApply:"Deploy to apply changes",deployToApplyDesc:"Domain configuration saved. Deploy the app for changes to take effect.",unknownRepo:"Unknown repo",service:"service",services:"services",exposed:"exposed",lastDeployed:"Last deployed",stop:"Stop",deploy:"Deploy",deploying:"Deploying...",building:"Building...",cancelDeploy:"Cancel",cancelling:"Cancelling...",delete:"Delete",deleting:"Deleting...",searchApps:"Search apps...",allRepos:"All repos",newApp:"New App",createApp:"Create App",noAppsYet:"No apps yet. Create your first app to get started!",noAppsMatch:"No apps match your search.",failedToLoadApps:"Failed to load apps",deleteApp:"Delete App",deleteAppConfirm:'Are you sure you want to delete "{{name}}"? This will stop all containers and remove the app configuration. This action cannot be undone.',cancel:"Cancel",appNotFound:"App not found",backToApps:"Back to Apps",tabs:{general:"General",deployments:"Deployments",logs:"Logs",environment:"Environment",domains:"Domains",monitoring:"Monitoring",workspace:"Workspace"},general:{deploy:"Deploy",deployOptions:"Deploy Options",autodeploy:"Autodeploy",noCache:"No-cache",notifications:"Notifications",services:"Services",noServicesConfigured:"No services configured"},workspace:{noRepository:"No repository linked to this app"},compose:{title:"Compose File",repoNotFound:"Repository path not found",unsavedChanges:"unsaved changes",save:"Save",edit:"Edit",done:"Done",preview:"Preview",previewDescription:"Preview the compose file that will be deployed",generatedTitle:"Generated Compose File Preview",generatedDescription:"This shows what will be deployed with the current configuration, including environment variable expansion and Docker Swarm transformations."},logs:{title:"Logs",description:"Watch the logs of the application in real time",allContainers:"All containers",lines:"lines",copy:"Copy",copied:"Copied",download:"Download",refresh:"Refresh",noLogs:"No logs available"},deployments:{title:"Deployments",description:"See the last 10 deployments for this compose",noDeployments:"No deployments yet",view:"View",statusDone:"Done",statusError:"Error",statusBuilding:"Building",deployment:"Deployment",seeDetails:"See all the details of this deployment",noBuildLogs:"No build logs available"},environment:{title:"Environment Variables",description:"Set environment variables for Docker Compose builds. These will be available during the build and in your containers.",placeholder:`DATABASE_URL=postgres://...
34
34
  API_KEY=your-api-key
35
- # Comments are supported`,save:"Save Environment",showValues:"Show values",hideValues:"Hide values",unsavedChanges:"You have unsaved changes"},domains:{title:"Domain Configuration",description:"Configure which services are exposed and their domain mappings",expose:"Expose",exposeRequiresPort:"No port configured. Add a port mapping to your compose file.",domain:"Domain",noDomain:"No domain configured",portRequired:"Port required",editDomain:"Edit domain",noServices:"No services configured. Deploy the app first to see available services.",save:"Save"},streaming:{pulling:"Pulling code...",building:"Building containers...",starting:"Starting services...",configuring:"Configuring routing...",done:"Deployment complete!",failed:"Deployment failed",cancelled:"Deployment cancelled",preparing:"Preparing...",waitingForLogs:"Waiting for logs..."},dnsConfigRequired:"DNS configuration required",settings:"Settings",status:{running:"Running",building:"Building",failed:"Failed",stopped:"Stopped"},monitoring:{title:"Resource Usage",description:"Real-time CPU and memory usage for each service",cpu:"CPU",memory:"Memory",noContainers:"No running containers found",dockerUnavailable:"Docker stats not available",serviceTotal:"Service Total"}},KJe={weekly:"Weekly",monthly:"Monthly"},YJe={buttons:FJe,status:BJe,time:$Je,results:zJe,statuses:UJe,auth:HJe,git:VJe,errors:WJe,opencode:qJe,apps:GJe,calendar:KJe},XJe={tasks:"Tasks",projects:"Projects",terminals:"Terminals",worktrees:"Worktrees",repositories:"Repositories",apps:"Apps",jobs:"Jobs",assistant:"Assistant",review:"Review",calendar:"Calendar",monitoring:"Monitoring",settings:"Settings",commandPalette:"Command Palette ({{shortcut}})",help:"Documentation"},QJe={placeholder:"Type a command or search...",noResults:"No commands found.",categories:{navigation:"Navigation",actions:"Actions"},commands:{goToTasks:"Go to Tasks",goToProjects:"Go to Projects",goToTerminals:"Go to Terminals",goToAssistant:"Go to Assistant",goToTaskTerminals:"Go to Task Terminals",goToProjectTerminals:"Go to Project Terminals",goToRepositories:"Go to Repositories",goToApps:"Go to Apps",goToJobs:"Go to Jobs",goToReview:"Go to Review",goToCalendar:"Go to Calendar",goToMonitoring:"Go to Monitoring",goToSettings:"Go to Settings",newTask:"New Task",newProject:"New Project",openInEditor:"Open in Editor",keyboardShortcuts:"Keyboard Shortcuts"}},ZJe={title:"Keyboard Shortcuts",groups:{navigation:"Navigation",actions:"Actions",terminals:"Terminals (Desktop)",general:"General"},labels:{goToTasks:"Go to Tasks",goToProjects:"Go to Projects",goToTerminals:"Go to Terminals",goToAssistant:"Go to Assistant",goToTaskTerminals:"Go to Task Terminals",goToProjectTerminals:"Go to Project Terminals",goToRepositories:"Go to Repositories",goToApps:"Go to Apps",goToJobs:"Go to Jobs",goToReview:"Go to Review",goToCalendar:"Go to Calendar",goToMonitoring:"Go to Monitoring",goToSettings:"Go to Settings",commandPalette:"Command Palette",newTask:"New Task",newProject:"New Project",openInEditor:"Open in Editor",openAiAssistant:"Open AI Assistant",keyboardShortcuts:"Keyboard Shortcuts",closeModal:"Close Modal",newTerminal:"New Terminal",closeTerminal:"Close Terminal",submitForm:"Submit Form"}},JJe={title:"Open in Editor",description:"Open a folder in {{editor}}",pathLabel:"Directory Path",pathPlaceholder:"~/projects/my-project",pathHint:"Enter a directory path. Supports ~ for home directory.",pathNotFound:"Path does not exist",pathNotDirectory:"Path must be a directory, not a file",browse:"Browse",cancel:"Cancel",open:"Open"},eet={header:XJe,commandPalette:QJe,shortcuts:ZJe,openInEditor:JJe},tet="Tasks",net="Search",ret="All Projects",iet="Tags",set="Search tags...",aet="No tags found",oet="Clear all tags",cet="Search projects...",uet="No projects found",det={label:"Type",types:{worktree:"Git",scratch:"Scratch",manual:"Manual"},clear:"Clear filter",showLabels:"Show task type labels"},fet={label:"Priority",priorities:{high:"High",medium:"Medium",low:"Low"},clear:"Clear filter"},het="New Task",pet={high:"High",medium:"Medium",low:"Low"},met={title:"Create New Task",description:"Create a new task with a git worktree for isolated development.",taskTypes:{worktree:"Git",manual:"Manual",scratch:"Scratch"},taskDescriptions:{worktree:"Creates a git worktree and opens an AI coding agent.",manual:"A general task without a git worktree or AI agent.",scratch:"Creates an isolated directory with an AI coding agent, without a git repository."},fields:{title:"Title",titlePlaceholder:"Add user authentication",description:"Description",descriptionPlaceholder:"Implement OAuth2 login flow...",aiMode:"AI Mode",agent:"AI Agent",opencodeModel:"OpenCode Model",opencodeModelPlaceholder:"Select model",repository:"Repository",baseBranch:"Base Branch",prefix:"Branch Prefix",prefixPlaceholder:"e.g., ENG-123",branchName:"Branch Name",branchPlaceholder:"auto-generated-from-title",project:"Project (optional)",tags:"Tags",tagsPlaceholder:"Add tag...",dueDate:"Due Date",dueDatePlaceholder:"Set date",estimate:"Estimate",priority:"Priority",repeat:"Repeat",notes:"Notes",notesPlaceholder:"Add notes...",links:"Links",urlPlaceholder:"https://...",linkLabelPlaceholder:"Label (optional)",prUrl:"GitHub PR",prUrlPlaceholder:"https://github.com/owner/repo/pull/123",attachments:"Attachments",addAttachments:"Add attachments...",addMoreFiles:"Add more files...",blockedBy:"Blocked By",recurrenceEndDate:"Repeat Until"},recurrence:{none:"None",daily:"Daily",weekly:"Weekly",biweekly:"Biweekly",monthly:"Monthly",quarterly:"Quarterly",yearly:"Yearly",recurringSeriesNote:"Part of a recurring series"},aiModes:{plan:"Plan",default:"Default"},tabs:{saved:"Repos",browse:"Browse"},worktreePrefix:"Worktree:",prefixHint:"Prepended to the branch name for ticket linkage.",branchAutoGenerated:'Will use "{{branch}}" if left empty.',selectFolder:"Select folder...",searchRepositories:"Search repositories...",noRepositoriesFound:"No repositories found",selectRepositoryFirst:"Select repository first",loadingBranches:"Loading branches...",selectBranch:"Select branch",noBranchesFound:"No branches found",current:"(current)",createTask:"Create Task",noProject:"No project (Inbox)",projectHint:"Tasks without a project appear in the Inbox.",blockedByHint:"Tasks that must be completed before this one can start.",blockedByPlaceholder:"Search tasks to block this...",noTasksFound:"No tasks found",startImmediately:"Start work immediately",advanced:"Advanced",pinTask:"Pin task to top",unpinTask:"Unpin task",errors:{notGitRepo:"Selected folder is not a git repository",validationFailed:"Failed to validate repository",createFailed:"Failed to create task",invalidUrl:"Invalid URL",invalidUrlDescription:"Please enter a valid URL including the scheme (e.g., https://)"}},get={title:tet,searchPlaceholder:net,allProjects:ret,allTags:iet,searchTags:set,noTagsFound:aet,clearTags:oet,searchProjects:cet,noProjectsFound:uet,typeFilter:det,priorityFilter:fet,newTask:het,priority:pet,createModal:met},bet="Settings",yet={general:"General",ai:"AI & Dev",messaging:"Email & Messaging",calendar:"Calendar"},vet={server:"Server",serverDefaults:"Server & Defaults",paths:"Paths",editor:"Editor",integrations:"Integrations",zai:"z.ai",agent:"Worktree Agents",assistant:"AI Assistant",tasks:"Task Defaults",notifications:"Notifications",messaging:"Messaging",appearance:"Appearance",developer:"Developer",caldav:"Calendar Integration"},xet={upToDate:"Up to date",updateAvailable:"Update available: v{{version}}",checkingForUpdates:"Checking...",updateButton:"Update",update:"Update",updating:"Updating...",updateStarted:"Update started. The server will restart momentarily.",updateFailed:"Update failed. Please try again or update manually.",updateCommand:"Run to update:",viewRelease:"View release",refresh:"Check for updates"},_et={port:{label:"Port",description:"Requires restart"},startupCommand:{label:"Startup Command",description:"Command for new task terminals"},gitReposDir:{label:"Git Repos Directory",description:"Starting directory for repo picker"},editor:{app:{label:"Editor",description:"Code editor for opening worktrees",options:{vscode:"VS Code",cursor:"Cursor",windsurf:"Windsurf",zed:"Zed",antigravity:"Antigravity"}},host:{label:"Remote Host",description:"For SSH URLs when code is on a remote machine",placeholder:"e.g., my-server.tailnet.ts.net"},sshPort:{label:"SSH Port",description:"Remote SSH port (default 22)"}},linear:{label:"Linear",description:"API key for ticket sync"},github:{label:"GitHub",description:"PAT for Issues & PRs"},google:{clientId:"Google ID",clientIdDescription:"OAuth Client ID from Google Cloud Console",clientSecret:"Google Secret",clientSecretDescription:"OAuth Client Secret for Google Calendar & Gmail"},cloudflare:{label:"Cloudflare",placeholder:"Enter API token...",description:"API token for automatic DNS records"},zai:{enable:"Enable",apiKey:"API Key",description:"Configures Claude Code to use z.ai proxy",modelMappings:"Model Mappings",haiku:"Haiku",sonnet:"Sonnet",opus:"Opus"},agent:{default:{label:"Default Agent",description:"The AI coding agent to use for new tasks"},opencodeModel:{label:"OpenCode Model",placeholder:"Select model",description:"Default model used when launching OpenCode tasks"},advancedAgentNames:{label:"Advanced Agent Names",description:"Configure specific agent names for OpenCode modes",warning:"Only change these if you know what you're doing. These settings are for users with custom OpenCode agents (e.g., oh-my-opencode plugin with Sisyphus/Planner-Sisyphus agents)."},opencodeDefaultAgent:{label:"Default Mode",description:"Agent name for full-permission mode. Use 'Sisyphus' for oh-my-opencode, or 'build' for vanilla OpenCode."},opencodePlanAgent:{label:"Plan Mode",description:"Agent name for restricted/planning mode. Use 'Planner-Sisyphus' for oh-my-opencode, or 'plan' for vanilla OpenCode. Note: Planner-Sisyphus inherits its model from OpenCode's plan agent config, so the model override above may not apply. Configure the model in ~/.config/opencode/oh-my-opencode.json instead."},autoScrollToBottom:{label:"Auto-scroll to Bottom",description:"Automatically scroll terminals to the bottom when new output arrives"},claudeCodePath:{label:"Claude Code Path",placeholder:"Auto-detect (leave empty)",description:"Override the auto-detected Claude Code executable path. Leave empty for automatic detection from PATH or common installation locations."}},assistant:{provider:{label:"Default Provider",description:"The AI provider to use for assistant conversations"},model:{label:"Claude Model",description:"The Claude model to use for AI assistant conversations",options:{opus:"Opus (Most capable)",sonnet:"Sonnet (Balanced)",haiku:"Haiku (Fastest)"}},observerProvider:{label:"Observer Provider",description:"AI provider for observe-only message processing. Observe-only messages (non-self WhatsApp, unauthorized emails) use restricted tool access for security.",options:{default:"Same as main provider"}},observerModel:{label:"Observer Model",description:"Claude model for observe-only message processing. Use a cheaper model to reduce costs.",options:{opus:"Opus (Most capable)",sonnet:"Sonnet (Balanced)",haiku:"Haiku (Fastest)"}},observerOpencodeModel:{label:"Observer OpenCode Model",description:"OpenCode model for observe-only message processing. Falls back to the main OpenCode model if not set.",placeholder:"Same as main OpenCode model"},opencodeModel:{label:"OpenCode Model",description:"The model to use when OpenCode is selected as the provider",placeholder:"Select model"},customInstructions:{label:"Memory File",openMemoryFile:"Open Memory File",memoryDescription:"Persistent instructions and knowledge for the assistant. Stored in ~/.fulcrum/MEMORY.md and included in every conversation."},documentsDir:{label:"Documents Directory",description:"Directory where AI-generated documents are saved as markdown files."}},tasks:{defaultType:{label:"Default Type",description:"Type to select by default when creating new tasks",options:{worktree:"Git",manual:"Manual",scratch:"Scratch"}},startImmediately:{label:"Start Immediately",description:"When enabled, worktree tasks start work immediately and create a git worktree. When disabled, tasks go to To Do."},scratchStartupScript:{label:"Scratch Startup Script",description:"Commands to run before agent invocation for scratch tasks (e.g., export ENV_VAR=value)"}},language:{label:"Language",description:"Interface language",options:{auto:"Auto-detect",en:"English",zh:"Chinese (Simplified)"}},theme:{label:"Theme",description:"Color theme for the interface",options:{system:"System",light:"Light",dark:"Dark"}},timezone:{label:"Timezone",description:"Timezone for due date calculations. Auto uses your system timezone.",options:{auto:"Auto (System)"}}},wet={enable:"Enable Notifications",toast:"In-app Toast",toastDescription:"Show toast notifications in the Fulcrum interface",desktop:"Desktop Notifications",desktopDescription:"Show native desktop or browser notifications",sound:"Sound",slack:"Slack",discord:"Discord",pushover:"Pushover",appToken:"App Token",userKey:"User Key",useMessagingChannel:"Use messaging channel",whatsapp:"WhatsApp",telegram:"Telegram",messagingChannelRequired:"Requires connected messaging channel",messagingChannelNote:"Sends via connected messaging channel",gmail:"Gmail",gmailDescription:"Sends notification emails to your own Gmail address",gmailAutoResolve:"Auto-resolve",gmailNoAccounts:"No Gmail-enabled Google accounts configured",testSuccess:"{{channel}} test successful",testFailed:"{{channel}} test failed: {{error}}",uploadSound:"Upload custom sound",deleteSound:"Remove custom sound",testSound:"Test sound",soundUploaded:"Custom sound uploaded",soundUploadFailed:"Failed to upload sound: {{error}}",soundDeleted:"Custom sound removed",soundDeleteFailed:"Failed to remove custom sound",customSoundActive:"Custom sound active"},Eet={rituals:"Daily Rituals",ritualsDescription:"Schedule morning and evening briefings. The assistant will execute your prompts at the specified times.",morningRitual:"Morning Ritual",morningRitualDescription:"Morning briefing with today's priorities.",morningRitualPromptPlaceholder:"Review messages since yesterday evening, summarize what needs attention today, and send a prioritized action plan.",eveningRitual:"Evening Ritual",eveningRitualDescription:"Evening summary with accomplishments and pending items.",eveningRitualPromptPlaceholder:"Summarize what was accomplished today, note pending items, and suggest focus areas for tomorrow."},Cet={restartButton:"Restart Fulcrum",restarting:"Restarting...",restartDescription:"Rebuild and restart the Fulcrum server. If the build fails, the server will continue running.",restartFailed:"Restart failed",checkLogs:"Build may have failed. Check journalctl --user -u fulcrum for details."},ket={label:"CalDAV",statusConnecting:"Connecting...",statusConnected:"Connected ({{count}} calendars)",statusSyncing:"Syncing...",statusError:"Connection error",statusDisconnected:"Disconnected",serverUrl:"Server URL",serverUrlPlaceholder:"https://cloud.example.com/remote.php/dav",username:"Username",usernamePlaceholder:"Enter your username",password:"Password",passwordPlaceholder:"Enter your password or app-specific password",syncInterval:"Sync interval (minutes)",testButton:"Test Connection",connectButton:"Connect",cancelButton:"Cancel",syncButton:"Sync Now",disconnectButton:"Disconnect",testSuccess:"Connection successful! Found {{count}} calendars.",testFailed:"Connection failed",configured:"CalDAV configured and connected",configureFailed:"Failed to configure CalDAV",toggleFailed:"Failed to toggle CalDAV",syncComplete:"Calendars synced",syncFailed:"Sync failed",disconnected:"CalDAV disconnected",disconnectFailed:"Failed to disconnect",fillRequired:"Server URL, username, and password are required",tabBasic:"CalDAV Server",tabGoogle:"Google Calendar",googleClientId:"Client ID",googleClientIdPlaceholder:"your-app.apps.googleusercontent.com",googleClientSecret:"Client Secret",googleClientSecretPlaceholder:"Enter your Google OAuth client secret",connectGoogleButton:"Connect Google Calendar",googleAuthStarted:"Google authorization opened in browser. Complete the sign-in to connect.",googleSetupHelp:"To set up Google Calendar integration:",googleStep1:"1. Go to the Google Cloud Console and create a project (or select an existing one).",googleStep2:'2. Enable the CalDAV API: navigate to APIs & Services > Library, search for "CalDAV API", and enable it.',googleStep3:'3. Configure the OAuth consent screen: go to APIs & Services > OAuth consent screen, set user type to "External", and fill in the required fields.',googleStep4:`4. Add your Google email as a test user under the consent screen's "Test users" section (required while the app is in testing mode).`,googleStep5:'5. Create OAuth credentials: go to APIs & Services > Credentials > Create Credentials > OAuth client ID. Select "Web application" and add your Fulcrum callback URL as an authorized redirect URI.',googleCallbackNote:"Your callback URL: {{callbackUrl}}",googleStep6:"6. Copy the Client ID and Client Secret into the fields above and click Connect.",googleFillRequired:"Client ID and Client Secret are required",setupInstructions:"Setup instructions",helpIntro:"Enter your CalDAV server URL and credentials. Common server URLs:",helpNote:"For Google Calendar, use the Google Calendar tab with OAuth2 authentication.",addAccount:"Add Account",accountName:"Account Name",accountNamePlaceholder:"My CalDAV Server",googleAccountNamePlaceholder:"Google Calendar",disabled:"Disabled",deleteAccount:"Delete",copyRules:"Copy Rules",addRule:"Add Rule",copyRulesSource:"Source Calendar",copyRulesDest:"Destination Calendar",copyRulesSelectCalendar:"Select a calendar...",copyRulesSelectBoth:"Please select both source and destination calendars",copyRulesSameCalendar:"Source and destination must be different calendars",copyRuleCreated:"Copy rule created",copyRuleCreateFailed:"Failed to create copy rule",copyRuleUpdateFailed:"Failed to update copy rule",copyRuleDeleted:"Copy rule deleted",copyRuleDeleteFailed:"Failed to delete copy rule",copyRuleExecuted:"Copied {{created}} new, updated {{updated}} events",copyRuleExecuteFailed:"Failed to execute copy rule",copyRulesLastRun:"Last run: {{date}}",copyRulesRunNow:"Run Now",copyRulesDelete:"Delete",copyRulesEmpty:"No copy rules configured. Add a rule to sync events between calendars."},Tet={label:"IMAP Feed",description:"Monitor an IMAP mailbox as a read-only feed. Incoming emails appear in the messaging timeline but no replies are sent.",disableButton:"Disable Email",emailBackend:"Email Backend"},Aet={title:"Google Accounts",addAccount:"Add Google Account",accountName:"Account Name",nameRequired:"Account name is required",connect:"Connect with Google",connecting:"Connecting...",accountAdded:"Google account connected",accountDeleted:"Google account deleted",calendarSync:"Calendar Sync",lastSync:"Last sync",gmail:"Gmail",sync:"Sync",syncComplete:"Calendar sync complete",delete:"Delete",calendarEnabled:"Calendar sync enabled",calendarDisabled:"Calendar sync disabled",gmailEnabled:"Gmail enabled",gmailDisabled:"Gmail disabled",noAccounts:"No Google accounts configured.",noAccountsGmail:"No Google accounts connected.",addInGeneral:"Add one in General settings",oauthNote:"You will be redirected to Google to authorize access to Calendar and Gmail.",monitorInbox:"Monitor inbox",sendAs:"Send as",sendAsPlaceholder:"you@gmail.com",sendAsUpdated:"Send-as address updated",draftsOnly:"(drafts only)",gmailDescription:"Gmail API uses OAuth2 — no app passwords needed. Drafts are created for human review before sending.",setupGuideTitle:"How to set up Google OAuth credentials",setupGuideStep1:"Go to <link>Google Cloud Console</link>",setupGuideStep2:"Create a new project (or select an existing one)",setupGuideStep3:"Enable the <strong>Google Calendar API</strong> and <strong>Gmail API</strong>",setupGuideStep4:"Go to <strong>APIs & Services → Credentials</strong>",setupGuideStep5:"Create an <strong>OAuth 2.0 Client ID</strong> (type: Web application)",setupGuideStep6:"Add authorized redirect URI: <code>{{redirectUri}}</code>",setupGuideStep7:"Copy the Client ID and Client Secret into the fields below",drafts:"Gmail Drafts",newDraft:"New Draft",to:"To",cc:"CC",subject:"Subject",body:"Body",saveDraft:"Save Draft",updateDraft:"Update Draft",draftCreated:"Draft created",draftUpdated:"Draft updated",draftDeleted:"Draft deleted",draftSent:"Draft sent",noDrafts:"No drafts.",noSubject:"(No Subject)",noRecipients:"No recipients",edit:"Edit",send:"Send"},Net={title:"Unsaved Changes",description:"You have unsaved changes that will be lost if you leave this page.",stay:"Stay",leave:"Leave"},Oet={title:bet,tabs:yet,sections:vet,version:xet,fields:_et,notifications:wet,concierge:Eet,developer:Cet,caldav:ket,imap:Tet,google:Aet,unsavedChanges:Net},Ret="Review",Iet={pullRequests:"Pull Requests",issues:"Issues"},Det={pr:{created:"Created by me",assigned:"Assigned to me",reviewRequested:"Review requests",mentioned:"Mentioned"},issue:{assigned:"Assigned to me",created:"Created by me",mentioned:"Mentioned"},allOrgs:"All Orgs",allOrganizations:"All Organizations",fulcrumReposOnly:"Fulcrum repos only"},jet={tokenRequired:"GitHub Token Required",tokenDescription:"To view your issues and pull requests, add a GitHub Personal Access Token in Settings.",requiredScopes:"Required scopes:",scopes:{repo:"(for private repositories)",readUser:"(for user info)",readOrg:"(for organization list)"},generateToken:"Generate Token",goToSettings:"Go to Settings"},Pet={loading:"Loading...",failedToLoad:"Failed to load pull requests",empty:{all:"No open pull requests",created:"No pull requests created by you",assigned:"No pull requests assigned to you",reviewRequested:"No pull requests awaiting your review",mentioned:"No pull requests mentioning you"},draft:"Draft"},Let={loading:"Loading...",failedToLoad:"Failed to load issues",empty:{assigned:"No issues assigned to you",created:"No issues created by you",mentioned:"No issues mentioning you"}},Met={title:Ret,tabs:Iet,filters:Det,github:jet,prs:Pet,issues:Let},Fet="Worktrees",Bet={total:"{{count}} total",orphaned:"{{count}} orphaned"},$et={button:"Clean up ({{count}})",title:"Delete Completed Worktrees",description:"This will permanently delete {{count}} worktree(s).",linkedTasksWillBeDeleted:"Their linked tasks will also be deleted.",alsoDeleteLinkedTasks:"Also delete linked tasks",done:"Done",canceled:"Canceled",cannotUndo:"This action cannot be undone.",pinnedSkipped:"{{count}} pinned worktree(s) will be skipped"},zet={pin:"Pin worktree",unpin:"Unpin worktree"},Uet={noMatch:"No worktrees match the selected filters.",noWorktrees:"No worktrees found. Worktrees are created when you create tasks."},Het={failedToLoad:"Failed to load worktrees: {{message}}"},Vet={title:Fet,summary:Bet,cleanup:$et,delete:{title:"Delete Worktree",description:"This will permanently delete the worktree directory at",linkedTaskWillBeDeleted:'The linked task "{{title}}" will also be deleted.',alsoDeleteLinkedTask:'Also delete linked task "{{title}}"',cannotUndo:"This action cannot be undone.",button:"Delete {{count}}",unpinFirst:"Unpin worktree before deleting"},pin:zet,empty:Uet,error:Het},Wet="Monitoring",qet={claude:"AI Agents",system:"System Metrics",processes:"Processes",fulcrum:"Fulcrum Servers",worktrees:"Worktrees",scratch:"Scratch",jobs:"Jobs",usage:"Usage Limits",assistant:"Assistant",messages:"Messages",memory:"Memory",review:"Review",observer:"Observer"},Get={showAllInstances:"Show all instances",instanceCount:"{{count}} instance(s) running",totalRam:"{{ram}} MB total",headers:{agent:"Agent",terminal:"Terminal",task:"Task",ram:"RAM",actions:"Actions",pid:"PID",workingDirectory:"Working Dir",source:"Source"},noTask:"(no task)",kill:"Kill",killing:"Killing...",killSelected:"Kill {{count}} selected",source:{fulcrum:"Fulcrum: {{name}}",external:"External"},empty:"No AI agent instances running",emptyFulcrum:" in Fulcrum terminals",error:"Failed to load AI agent instances: {{message}}"},Ket={cpuUsage:"CPU Usage",memoryUsage:"Memory Usage",memoryLabels:{used:"Used",cache:"Cache / Buffers"},diskUsage:"Disk Usage ({{path}})",error:"Failed to load system metrics: {{message}}",timeWindows:{"1m":"1 min","10m":"10 min","1h":"1 hour","3h":"3 hours","6h":"6 hours","12h":"12 hours","24h":"24 hours"}},Yet={topProcesses:"Top Processes",sortBy:{memory:"By Memory",cpu:"By CPU"},headers:{pid:"PID",name:"Name",command:"Command",memory:"Memory"},empty:"No processes found",error:"Failed to load processes: {{message}}",containers:"Containers",containersEmpty:"No containers running",containersUnavailable:"Docker/Podman not available"},Xet={description:"Running Fulcrum dev servers",instanceCount:"{{count}} instance(s) running",headers:{port:"Port",mode:"Mode",directory:"Directory",ram:"RAM",actions:"Actions"},mode:{dev:"Dev",prod:"Prod"},vite:"Vite",kill:"Kill",killing:"Killing...",empty:"No Fulcrum instances running",error:"Failed to load Fulcrum instances: {{message}}"},Qet={fiveHourBlock:"5-Hour Block",sevenDayRolling:"7-Day Rolling",opusWeekly:"Opus Weekly",sonnetWeekly:"Sonnet Weekly",resetsIn:"Resets in {{time}}",resetsAt:"Resets {{time}}",weekProgress:"{{percent}}% through week",unavailable:"Claude Code usage data not available. Make sure you're logged in to Claude Code.",error:"Failed to load usage data: {{message}}"},Zet={sweeps:{title:"Recent Sweeps",empty:"No sweeps recorded",hourly:"Hourly",morningRitual:"Morning Ritual",eveningRitual:"Evening Ritual",eventsProcessed:"{{count}} events",tasksUpdated:"{{count}} tasks",messagesSent:"{{count}} messages",stale:"stale"}},Jet={title:"Agent Memories",search:"Search memories...",empty:"No memories stored yet",noResults:"No memories match your search",total:"{{count}} memories",deleteConfirm:"Delete this memory?",deleted:"Memory deleted",tagsPlaceholder:"Tags (comma-separated)"},ett={title:"Channel Messages",search:"Search...",empty:"No messages found",channels:{all:"All Channels",total:"Total",email:"Email",whatsapp:"WhatsApp",discord:"Discord",telegram:"Telegram",slack:"Slack"},direction:{all:"All",incoming:"Incoming",outgoing:"Outgoing"},labels:{from:"From:",to:"To:"}},ttt={status:{healthy:"Observer Healthy",circuitOpen:"Circuit Breaker Open",failures:"failures"},stats:{total:"Total Processed",successRate:"Success Rate",avgDuration:"Avg Duration",tasksCreated:"Tasks Created",memoriesStored:"Memories Stored",last24h:"Last 24h"},filters:{allChannels:"All Channels",allStatuses:"All Statuses",allProviders:"All Providers",completed:"Completed",failed:"Failed",timeout:"Timeout",circuitOpen:"Circuit Open"},invocations:{title:"Recent Invocations",empty:"No observer invocations recorded"},actions:{createTask:"Task Created",storeMemory:"Memory Stored"},details:{error:"Error",actions:"Actions"}},ntt={title:Wet,tabs:qet,claude:Get,system:Ket,processes:Yet,fulcrum:Xet,usage:Qet,assistant:Zet,memory:Jet,messages:ett,observer:ttt},rtt="Tasks",itt="Repos",stt="New Terminal",att="All Projects",ott="Select repos",ltt="{{count}} selected",ctt="Select up to 6 repos",utt="Search repositories...",dtt="No repositories found",ftt="Clear selection",htt="Select a repository to open its workspace terminal",ptt="No active tasks",mtt={title:"Edit Tab",name:"Name",namePlaceholder:"Tab name",directory:"Directory",directoryPlaceholder:"Select a directory...",clearDirectory:"Clear directory",cancel:"Cancel",save:"Save"},gtt={title:"New Tab",create:"Create"},btt={taskTerminals:rtt,repoTerminals:itt,newTerminal:stt,allProjects:att,selectRepos:ott,reposSelected:ltt,filterByRepo:ctt,searchRepos:utt,noReposFound:dtt,clearFilter:ftt,emptyRepos:htt,emptyTasks:ptt,editTab:mtt,newTab:gtt},ytt="Repositories",vtt="{{count}} total",xtt="Search repositories...",_tt="New Task",Stt="Tasks",wtt="Terminal",Ett="Editor",Ctt="Application",ktt="Applications",Ttt="Create App",Att={title:"Docker Compose Required",description:"To create an app for deployment, this repository needs a Docker Compose file.",instructions:"Create a docker-compose.yml file in your repository.",close:"Got it"},Ntt="Settings",Ott="Add Repository",Rtt="Scan Directory",Itt="Open in Terminal",Dtt="Open in {{editor}}",jtt={openInVSCode:"Open in VS Code"},Ptt={title:"Add Repository",description:"Add a git repository from a URL or local path, or scan a directory.",tabs:{add:"Add",scan:"Scan",template:"From Template"},inputLabel:"Repository URL or path",inputPlaceholder:"https://github.com/user/repo or /local/path",browse:"Browse...",cloneOptions:"Clone Options",targetDirectory:"Clone to directory",folderName:"Folder name",willCloneTo:"Will clone to",cloning:"Cloning repository...",adding:"Adding...",cloneFailed:"Failed to clone repository",createFailed:"Failed to add repository",cancel:"Cancel",add:"Add",retry:"Retry",fields:{path:"Repository Path",pathPlaceholder:"Select repository...",displayName:"Display Name",startupScript:"Startup Script",startupScriptPlaceholder:"npm install && npm run dev",startupScriptDescription:"Command to run in the terminal when creating a worktree.",copyFiles:"Copy Files",copyFilesPlaceholder:".env, config.local.json",copyFilesDescription:"Comma-separated glob patterns for files to copy into new worktrees.",isCopierTemplate:"Use as Copier Template",isCopierTemplateDescription:"Mark as a template for creating new projects."}},Ltt={button:"New Project",title:"Create New Project",back:"Back",next:"Next",create:"Create Project",steps:{template:{description:"Select a template to create your project from.",sectionTitle:"Copier Template",sectionDescription:"Select a saved template or enter a URL/path.",learnMore:"Learn more",savedTemplates:"Saved Templates",selectTemplate:"Select a template...",or:"or",customUrl:"Custom Template URL/Path"},questions:{title:"Template Questions",description:"Configure your project.",noQuestions:"This template has no configuration questions."},output:{title:"Output Location",description:"Choose where to create your project.",projectName:"Project Name",outputDirectory:"Output Directory",selectDirectory:"Select directory...",willCreate:"Will create",trust:"Trust template"},creating:{description:"Creating your project...",inProgress:"Running Copier..."}}},Mtt={title:"Scan Directory for Repositories",description:"Find and add multiple git repositories from a directory.",directoryLabel:"Directory to scan",directoryPlaceholder:"Enter directory path",browse:"Browse...",scan:"Scan",foundRepos:"Found {{count}} repositories",selectAll:"Select all",selectNone:"Select none",noReposFound:"No git repositories found in this directory.",alreadyAdded:"Already added",adding:"Adding repositories...",scanFailed:"Failed to scan directory",addFailed:"Failed to add repositories",cancel:"Cancel",addSelected:"Add {{count}} selected"},Ftt={noRepositories:"No repositories added yet. Add a repository for quick access when creating tasks.",noMatches:"No repositories match your search."},Btt={failedToLoad:"Failed to load repositories: {{message}}"},$tt={breadcrumb:"Repositories",notFound:"Repository not found",save:"Save",saving:"Saving...",saved:"Repository saved",failedToSave:"Failed to save repository",tabs:{settings:"Task Settings",workspace:"Workspace"},mobileWorkspace:{terminal:"Terminal",files:"Files"},fileTree:{title:"Files",searchPlaceholder:"Search files...",noFiles:"No files",collapseAll:"Collapse all folders"},settings:{generalTitle:"General",agentTitle:"Agent Options",displayName:"Display Name",defaultAgent:"Default Agent",defaultAgentInherit:"Use global default",defaultAgentDescription:"Override the global default agent for tasks created from this repository.",startupScript:"Startup Script",startupScriptPlaceholder:"npm install && npm run dev",startupScriptDescription:"Command to run in the terminal when creating a worktree.",claudeOptions:"Claude Code Options",claudeOptionsDescription:"CLI flags passed to Claude Code when starting a task.",opencodeOptions:"OpenCode Options",opencodeOptionsDescription:"CLI flags passed to OpenCode when starting a task.",opencodeModel:"OpenCode Model",opencodeModelPlaceholder:"Select model",opencodeModelDescription:"Default OpenCode model for tasks created from this repository.",agentOptionsFlag:"Flag",agentOptionsValue:"Value",addAgentOption:"Add option",copyFiles:"Copy Files",copyFilesPlaceholder:".env, config.local.json",copyFilesDescription:"Comma-separated glob patterns for files to copy into new worktrees.",isCopierTemplate:"Use as Copier Template",isCopierTemplateDescription:"Mark as a template for creating new projects with Copier."},workspace:{connectingToTerminal:"Connecting to terminal server...",initializingTerminal:"Initializing terminal...",terminalConnectionFailed:"Terminal connection failed",recreateTerminal:"Recreate Terminal"}},ztt={title:ytt,total:vtt,searchPlaceholder:xtt,newTask:_tt,viewTasks:Stt,terminal:wtt,editor:Ett,application:Ctt,applications:ktt,createApp:Ttt,createAppDialog:Att,settings:Ntt,addRepository:Ott,scanDirectory:Rtt,openInTerminal:Itt,openInEditor:Dtt,card:jtt,delete:{title:"Delete Repository",description:'This will remove "{{name}}" from Fulcrum. The actual repository files will not be affected.',button:"Delete",deleting:"Deleting...",alsoDeleteDirectory:"Also delete the directory from disk",deleteDirectoryWarning:"This will permanently delete all files in the repository. This action cannot be undone."},addModal:Ptt,newProject:Ltt,bulkAdd:Mtt,empty:Ftt,error:Btt,detailView:$tt},Utt="Jobs",Htt="View scheduled tasks (systemd timers on Linux, launchd jobs on macOS)",Vtt="Search jobs...",Wtt="No scheduled jobs found",qtt="No jobs match your search",Gtt="Create Job",Ktt={all:"All",user:"User",system:"System"},Ytt={active:"Active",inactive:"Inactive",failed:"Failed",waiting:"Waiting",disabled:"Disabled"},Xtt="Next",Qtt="Last",Ztt="System timers are read-only",Jtt="Jobs on macOS are read-only",ent={enable:"Enable",disable:"Disable",start:"Start",stop:"Stop",runNow:"Run Now",edit:"Edit",delete:"Delete",viewLogs:"View Logs"},tnt={tabs:{general:"General",logs:"Logs",edit:"Edit"},schedule:"Schedule",nextRun:"Next Run",lastRun:"Last Run",lastResult:"Last Result",description:"Description",command:"Command",workingDir:"Working Directory",systemTimer:"System timer (read-only)",timerFile:"Timer File",serviceFile:"Service File",executionStats:"Last Execution",duration:"Duration",cpuTime:"CPU Time",noStats:"No execution data available"},nnt={title:"Create Scheduled Job",name:"Job Name",namePlaceholder:"backup-daily",nameHelp:"Alphanumeric, hyphens, and underscores only",description:"Description",descriptionPlaceholder:"Daily backup of important files",schedule:"Schedule",scheduleHelp:"OnCalendar expression (e.g., *-*-* 02:00:00, daily, weekly)",command:"Command",commandPlaceholder:"/home/user/scripts/backup.sh",workingDir:"Working Directory",workingDirPlaceholder:"/home/user",persistent:"Persistent",persistentHelp:"Run missed executions when system starts",cancel:"Cancel",create:"Create Job"},rnt={title:"Job Logs",noLogs:"No logs available",lines:"lines",refresh:"Refresh"},int={loadFailed:"Failed to load jobs",createFailed:"Failed to create job",updateFailed:"Failed to update job",deleteFailed:"Failed to delete job"},Eae={title:Utt,description:Htt,searchPlaceholder:Vtt,noJobs:Wtt,noJobsMatch:qtt,createJob:Gtt,scope:Ktt,status:Ytt,nextRun:Xtt,lastRun:Qtt,systemTimerReadonly:Ztt,macosReadonly:Jtt,actions:ent,detail:tnt,create:nnt,delete:{title:"Delete Job",confirm:'Are you sure you want to delete "{{name}}"? This will remove both the timer and service files.',cancel:"Cancel",delete:"Delete"},logs:rnt,errors:int},snt="Projects",ant="{{count}} total",ont="Search projects...",lnt="New Task",cnt="Add Repo",unt="Link Repo",dnt="Back to Projects",fnt="New Task",hnt="Project not found",pnt="Terminal",mnt="Editor",gnt="Deploy",bnt="Stop",ynt="New Project",vnt={noProjects:"No projects yet. Create a project to get started.",noMatches:"No projects match your search."},xnt={failedToLoad:"Failed to load projects: {{message}}"},_nt={noApp:"No app",running:"Running",building:"Building",stopped:"Stopped",failed:"Failed"},Snt={breadcrumb:"Projects",notFound:"Project not found",save:"Save",saving:"Saving...",tabs:{settings:"Task Settings",workspace:"Workspace",deploy:"Deploy",deployGeneral:"General",deployments:"Deployments",logs:"Logs",monitoring:"Monitoring"},general:{repositoryTitle:"Repository",agentTitle:"Agent Options",path:"Path",displayName:"Display Name",startupScript:"Startup Script",copyFiles:"Copy Files",defaultAgent:"Default Agent",claudeOptions:"Claude Code Options",opencodeOptions:"OpenCode Options",opencodeModel:"OpenCode Model",noRepository:"No repository linked to this project."},app:{title:"App Configuration",noApp:"No app configured for this project.",configureDeployment:"Configure Deployment",configureDeploymentDescription:"Set up Docker Compose deployment for this project",configuring:"Configuring...",deployOptions:"Deploy Options",autoDeployEnabled:"Auto-deploy on commit",autoPortAllocation:"Auto-allocate ports",noCacheBuild:"No-cache builds",notificationsEnabled:"Deployment notifications",services:"Services",environment:"Environment Variables",composeFile:"Compose File"}},wnt={step:"Step {{current}} of {{total}}",selectRepository:"Select Repository",existingRepo:"Existing",addNewRepo:"Add New",searchRepos:"Search repositories...",noReposFound:"No repositories found",repoPathOrUrl:"Repository Path or URL",repoInputPlaceholder:"~/code/my-repo or https://github.com/user/repo",browse:"Browse",cloneOptions:"Clone Options",targetDirectory:"Target Directory",folderName:"Folder Name",willCloneTo:"Will clone to",cloning:"Cloning repository...",adding:"Adding repository...",cloneAndSelect:"Clone & Select",addAndSelect:"Add & Select",addRepoFailed:"Failed to add repository",checkingCompose:"Checking for compose file...",composeFound:"Found {{file}}",noCompose:"No compose file found",cancel:"Cancel",next:"Next",back:"Back",configureProject:"Configure Project",projectName:"Project Name",projectNamePlaceholder:"my-project",description:"Description",descriptionPlaceholder:"Optional project description",composeDetected:"Docker Compose detected: {{file}}",setupAppNow:"Set up app deployment after creation",createProject:"Create Project",creating:"Creating...",create:"Create"},Ent={all:"All",hasApp:"With App",noApp:"Without App",running:"Running",archived:"Archived"},Cnt={summaryDefault:"Default",inherit:"Inherit",summaryClaudeOptions_one:"Claude: {{count}} option",summaryClaudeOptions_other:"Claude: {{count}} options",summaryOpencodeOptions_one:"OpenCode: {{count}} option",summaryOpencodeOptions_other:"OpenCode: {{count}} options",summaryModel:"Model",description:"Configure default agent settings for this project. Repositories can override these settings.",useGlobalDefault:"Use global default",startupScript:"Startup Script",startupScriptDescription:"Commands to run before agent invocation. Runs before the repository's startup script."},knt={activeCount_one:"{{count}} active",activeCount_other:"{{count}} active",doneCount_one:"{{count}} done",doneCount_other:"{{count}} done"},Tnt={clickToEdit:"Click to edit",actions:{task:"Task",repo:"Repo",link:"Link"},sections:{repositories:"Repositories",links:"Links",attachments:"Attachments",tags:"Tags",notes:"Notes",activeTasks:"Active Tasks"},addDescription:"Add a description...",save:"Save",edit:"Edit",done:"Done",add:"Add",cancel:"Cancel",noRepositories:"No repositories linked to this project.",linkExisting:"Link Existing",urlPlaceholder:"https://...",linkLabelPlaceholder:"Label (optional)",labelPlaceholder:"Label",removeLink:"Remove link",addLink:"Add link",addTag:"Add tag...",loadingAttachments:"Loading attachments...",uploading:"Uploading...",dropOrClick:"Drop files here or click to upload",dropOrClickShort:"Drop or click",attachmentTypes:"PDF, images, documents, archives (max 10MB)",noAttachments:"No attachments",noTags:"No tags",searchOrCreateTag:"Search or create tag...",createTag:'Create "{{tag}}"',noMatchingTags:"No matching tags",addNotes:"Add notes about this project...",noNotes:"No notes",noActiveTasks:"No active tasks",loading:"Loading..."},Ant={title:snt,total:ant,searchPlaceholder:ont,newTask:lnt,addRepo:cnt,linkRepo:unt,backToProjects:dnt,createTask:fnt,notFound:hnt,terminal:pnt,editor:mnt,deploy:gnt,stop:bnt,newProjectButton:ynt,empty:vnt,error:xnt,card:_nt,delete:{title:"Delete Project",description:'This will remove the project "{{name}}".',confirmText:'Are you sure you want to delete "{{name}}"? This action cannot be undone.',button:"Delete",confirm:"Delete",cancel:"Cancel",success:"Project deleted",error:"Failed to delete project",deleting:"Deleting...",reposWarning_one:"This project has {{count}} linked repository. Deleting will unlink it.",reposWarning_other:"This project has {{count}} linked repositories. Deleting will unlink them.",alsoDeleteDirectory:"Also delete the directory",alsoDeleteApp:"Also delete the app and stop containers"},detailView:Snt,newProject:wnt,filter:Ent,agentSettings:Cnt,repoCard:knt,detail:Tnt},Nnt="AI Assistant",Ont={clearConversation:"Clear conversation",connected:"Connected",aiAssistantResponse:"AI Assistant Response"},Rnt={claude:"Claude",opencode:"OpenCode"},Int={selectModel:"Select model",filterModels:"Filter models...",noModelsMatch:'No models match "{{filter}}"',opus:"Opus",opusDescription:"Most capable",sonnet:"Sonnet",sonnetDescription:"Balanced",haiku:"Haiku",haikuDescription:"Fastest"},Dnt={placeholder:"Manage tasks, projects, run commands, deploy apps... Ask anything!",askAnything:"Ask anything...",shiftEnterHint:"Press <kbd>Shift + Enter</kbd> for new line"},jnt={selectChat:"Select a chat",messages:"messages",msgs:"msgs",rename:"Rename",delete:"Delete",noChatsYet:"No chats yet",newChat:"New Chat",selectOrCreate:"Select or create a chat to get started",startConversation:"Start a conversation by sending a message",thinking:"Thinking"},Pnt={tabs:{canvas:"Canvas",editor:"Editor",documents:"Documents",memory:"Memory"},empty:{title:"Select a chat to view the canvas",description:"Charts and visualizations will appear here"},viewer:{empty:{title:"Canvas is empty",description:"Ask the assistant to show a chart, table, or visualization"}},editor:{title:"Document Editor - Write markdown with AI assistance",placeholder:"Start writing your document..."},documents:{empty:{title:"No documents yet",description:"Documents created by AI will appear here"}},memory:{title:"Master Memory File",path:"~/.fulcrum/MEMORY.md",placeholder:`# Memory
35
+ # Comments are supported`,save:"Save Environment",showValues:"Show values",hideValues:"Hide values",unsavedChanges:"You have unsaved changes"},domains:{title:"Domain Configuration",description:"Configure which services are exposed and their domain mappings",expose:"Expose",exposeRequiresPort:"No port configured. Add a port mapping to your compose file.",domain:"Domain",noDomain:"No domain configured",portRequired:"Port required",editDomain:"Edit domain",noServices:"No services configured. Deploy the app first to see available services.",save:"Save"},streaming:{pulling:"Pulling code...",building:"Building containers...",starting:"Starting services...",configuring:"Configuring routing...",done:"Deployment complete!",failed:"Deployment failed",cancelled:"Deployment cancelled",preparing:"Preparing...",waitingForLogs:"Waiting for logs..."},dnsConfigRequired:"DNS configuration required",settings:"Settings",status:{running:"Running",building:"Building",failed:"Failed",stopped:"Stopped"},monitoring:{title:"Resource Usage",description:"Real-time CPU and memory usage for each service",cpu:"CPU",memory:"Memory",noContainers:"No running containers found",dockerUnavailable:"Docker stats not available",serviceTotal:"Service Total"}},KJe={weekly:"Weekly",monthly:"Monthly"},YJe={buttons:FJe,status:BJe,time:$Je,results:zJe,statuses:UJe,auth:HJe,git:VJe,errors:WJe,opencode:qJe,apps:GJe,calendar:KJe},XJe={tasks:"Tasks",projects:"Projects",terminals:"Terminals",worktrees:"Worktrees",repositories:"Repositories",apps:"Apps",jobs:"Jobs",assistant:"Assistant",review:"Review",calendar:"Calendar",monitoring:"Monitoring",settings:"Settings",commandPalette:"Command Palette ({{shortcut}})",help:"Documentation"},QJe={placeholder:"Type a command or search...",noResults:"No commands found.",categories:{navigation:"Navigation",actions:"Actions"},commands:{goToTasks:"Go to Tasks",goToProjects:"Go to Projects",goToTerminals:"Go to Terminals",goToAssistant:"Go to Assistant",goToTaskTerminals:"Go to Task Terminals",goToProjectTerminals:"Go to Project Terminals",goToRepositories:"Go to Repositories",goToApps:"Go to Apps",goToJobs:"Go to Jobs",goToReview:"Go to Review",goToCalendar:"Go to Calendar",goToMonitoring:"Go to Monitoring",goToSettings:"Go to Settings",newTask:"New Task",newProject:"New Project",openInEditor:"Open in Editor",keyboardShortcuts:"Keyboard Shortcuts"}},ZJe={title:"Keyboard Shortcuts",groups:{navigation:"Navigation",actions:"Actions",terminals:"Terminals (Desktop)",general:"General"},labels:{goToTasks:"Go to Tasks",goToProjects:"Go to Projects",goToTerminals:"Go to Terminals",goToAssistant:"Go to Assistant",goToTaskTerminals:"Go to Task Terminals",goToProjectTerminals:"Go to Project Terminals",goToRepositories:"Go to Repositories",goToApps:"Go to Apps",goToJobs:"Go to Jobs",goToReview:"Go to Review",goToCalendar:"Go to Calendar",goToMonitoring:"Go to Monitoring",goToSettings:"Go to Settings",commandPalette:"Command Palette",newTask:"New Task",newProject:"New Project",openInEditor:"Open in Editor",openAiAssistant:"Open AI Assistant",keyboardShortcuts:"Keyboard Shortcuts",closeModal:"Close Modal",newTerminal:"New Terminal",closeTerminal:"Close Terminal",submitForm:"Submit Form"}},JJe={title:"Open in Editor",description:"Open a folder in {{editor}}",pathLabel:"Directory Path",pathPlaceholder:"~/projects/my-project",pathHint:"Enter a directory path. Supports ~ for home directory.",pathNotFound:"Path does not exist",pathNotDirectory:"Path must be a directory, not a file",browse:"Browse",cancel:"Cancel",open:"Open"},eet={header:XJe,commandPalette:QJe,shortcuts:ZJe,openInEditor:JJe},tet="Tasks",net="Search",ret="All Projects",iet="Tags",set="Search tags...",aet="No tags found",oet="Clear all tags",cet="Search projects...",uet="No projects found",det={label:"Type",types:{worktree:"Git",scratch:"Scratch",manual:"Manual"},clear:"Clear filter",showLabels:"Show task type labels"},fet={label:"Priority",priorities:{high:"High",medium:"Medium",low:"Low"},clear:"Clear filter"},het="New Task",pet={high:"High",medium:"Medium",low:"Low"},met={title:"Create New Task",description:"Create a new task with a git worktree for isolated development.",taskTypes:{worktree:"Git",manual:"Manual",scratch:"Scratch"},taskDescriptions:{worktree:"Creates a git worktree and opens an AI coding agent.",manual:"A general task without a git worktree or AI agent.",scratch:"Creates an isolated directory with an AI coding agent, without a git repository."},fields:{title:"Title",titlePlaceholder:"Add user authentication",description:"Description",descriptionPlaceholder:"Implement OAuth2 login flow...",aiMode:"AI Mode",agent:"AI Agent",opencodeModel:"OpenCode Model",opencodeModelPlaceholder:"Select model",repository:"Repository",baseBranch:"Base Branch",prefix:"Branch Prefix",prefixPlaceholder:"e.g., ENG-123",branchName:"Branch Name",branchPlaceholder:"auto-generated-from-title",project:"Project (optional)",tags:"Tags",tagsPlaceholder:"Add tag...",dueDate:"Due Date",dueDatePlaceholder:"Set date",estimate:"Estimate",priority:"Priority",repeat:"Repeat",notes:"Notes",notesPlaceholder:"Add notes...",links:"Links",urlPlaceholder:"https://...",linkLabelPlaceholder:"Label (optional)",prUrl:"GitHub PR",prUrlPlaceholder:"https://github.com/owner/repo/pull/123",attachments:"Attachments",addAttachments:"Add attachments...",addMoreFiles:"Add more files...",blockedBy:"Blocked By",recurrenceEndDate:"Repeat Until"},recurrence:{none:"None",daily:"Daily",weekly:"Weekly",biweekly:"Biweekly",monthly:"Monthly",quarterly:"Quarterly",yearly:"Yearly",recurringSeriesNote:"Part of a recurring series"},aiModes:{plan:"Plan",default:"Default"},tabs:{saved:"Repos",browse:"Browse"},worktreePrefix:"Worktree:",prefixHint:"Prepended to the branch name for ticket linkage.",branchAutoGenerated:'Will use "{{branch}}" if left empty.',selectFolder:"Select folder...",searchRepositories:"Search repositories...",noRepositoriesFound:"No repositories found",selectRepositoryFirst:"Select repository first",loadingBranches:"Loading branches...",selectBranch:"Select branch",noBranchesFound:"No branches found",current:"(current)",createTask:"Create Task",noProject:"No project (Inbox)",projectHint:"Tasks without a project appear in the Inbox.",blockedByHint:"Tasks that must be completed before this one can start.",blockedByPlaceholder:"Search tasks to block this...",noTasksFound:"No tasks found",startImmediately:"Start work immediately",advanced:"Advanced",pinTask:"Pin task to top",unpinTask:"Unpin task",errors:{notGitRepo:"Selected folder is not a git repository",validationFailed:"Failed to validate repository",createFailed:"Failed to create task",invalidUrl:"Invalid URL",invalidUrlDescription:"Please enter a valid URL including the scheme (e.g., https://)"}},get={title:tet,searchPlaceholder:net,allProjects:ret,allTags:iet,searchTags:set,noTagsFound:aet,clearTags:oet,searchProjects:cet,noProjectsFound:uet,typeFilter:det,priorityFilter:fet,newTask:het,priority:pet,createModal:met},bet="Settings",yet={general:"General",ai:"AI & Dev",messaging:"Email & Messaging",calendar:"Calendar"},vet={server:"Server",serverDefaults:"Server & Defaults",paths:"Paths",editor:"Editor",integrations:"Integrations",zai:"z.ai",agent:"Worktree Agents",assistant:"AI Assistant",tasks:"Task Defaults",notifications:"Notifications",messaging:"Messaging",appearance:"Appearance",developer:"Developer",caldav:"Calendar Integration"},xet={upToDate:"Up to date",updateAvailable:"Update available: v{{version}}",checkingForUpdates:"Checking...",updateButton:"Update",update:"Update",updating:"Updating...",updateStarted:"Update started. The server will restart momentarily.",updateFailed:"Update failed. Please try again or update manually.",updateCommand:"Run to update:",viewRelease:"View release",refresh:"Check for updates"},_et={port:{label:"Port",description:"Requires restart"},startupCommand:{label:"Startup Command",description:"Command for new task terminals"},gitReposDir:{label:"Git Repos Directory",description:"Starting directory for repo picker"},editor:{app:{label:"Editor",description:"Code editor for opening worktrees",options:{vscode:"VS Code",cursor:"Cursor",windsurf:"Windsurf",zed:"Zed",antigravity:"Antigravity"}},host:{label:"Remote Host",description:"For SSH URLs when code is on a remote machine",placeholder:"e.g., my-server.tailnet.ts.net"},sshPort:{label:"SSH Port",description:"Remote SSH port (default 22)"}},linear:{label:"Linear",description:"API key for ticket sync"},github:{label:"GitHub",description:"PAT for Issues & PRs"},google:{clientId:"Google ID",clientIdDescription:"OAuth Client ID from Google Cloud Console",clientSecret:"Google Secret",clientSecretDescription:"OAuth Client Secret for Google Calendar & Gmail"},cloudflare:{label:"Cloudflare",placeholder:"Enter API token...",description:"API token for automatic DNS records"},zai:{enable:"Enable",apiKey:"API Key",description:"Configures Claude Code to use z.ai proxy",modelMappings:"Model Mappings",haiku:"Haiku",sonnet:"Sonnet",opus:"Opus"},agent:{default:{label:"Default Agent",description:"The AI coding agent to use for new tasks"},opencodeModel:{label:"OpenCode Model",placeholder:"Select model",description:"Default model used when launching OpenCode tasks"},advancedAgentNames:{label:"Advanced Agent Names",description:"Configure specific agent names for OpenCode modes",warning:"Only change these if you know what you're doing. These settings are for users with custom OpenCode agents (e.g., oh-my-opencode plugin with Sisyphus/Planner-Sisyphus agents)."},opencodeDefaultAgent:{label:"Default Mode",description:"Agent name for full-permission mode. Use 'Sisyphus' for oh-my-opencode, or 'build' for vanilla OpenCode."},opencodePlanAgent:{label:"Plan Mode",description:"Agent name for restricted/planning mode. Use 'Planner-Sisyphus' for oh-my-opencode, or 'plan' for vanilla OpenCode. Note: Planner-Sisyphus inherits its model from OpenCode's plan agent config, so the model override above may not apply. Configure the model in ~/.config/opencode/oh-my-opencode.json instead."},autoScrollToBottom:{label:"Auto-scroll to Bottom",description:"Automatically scroll terminals to the bottom when new output arrives"},claudeCodePath:{label:"Claude Code Path",placeholder:"Auto-detect (leave empty)",description:"Override the auto-detected Claude Code executable path. Leave empty for automatic detection from PATH or common installation locations."}},assistant:{provider:{label:"Default Provider",description:"The AI provider to use for assistant conversations"},model:{label:"Claude Model",description:"The Claude model to use for AI assistant conversations",options:{opus:"Opus (Most capable)",sonnet:"Sonnet (Balanced)",haiku:"Haiku (Fastest)"}},observerProvider:{label:"Observer Provider",description:"AI provider for observe-only message processing. Observe-only messages (non-self WhatsApp, unauthorized emails) use restricted tool access for security.",options:{default:"Same as main provider"}},observerModel:{label:"Observer Model",description:"Claude model for observe-only message processing. Use a cheaper model to reduce costs.",options:{opus:"Opus (Most capable)",sonnet:"Sonnet (Balanced)",haiku:"Haiku (Fastest)"}},observerOpencodeModel:{label:"Observer OpenCode Model",description:"OpenCode model for observe-only message processing. Falls back to the main OpenCode model if not set.",placeholder:"Same as main OpenCode model"},opencodeModel:{label:"OpenCode Model",description:"The model to use when OpenCode is selected as the provider",placeholder:"Select model"},customInstructions:{label:"Memory File",openMemoryFile:"Open Memory File",memoryDescription:"Persistent instructions and knowledge for the assistant. Stored in ~/.fulcrum/MEMORY.md and included in every conversation."},documentsDir:{label:"Documents Directory",description:"Directory where AI-generated documents are saved as markdown files."}},tasks:{defaultType:{label:"Default Type",description:"Type to select by default when creating new tasks",options:{worktree:"Git",manual:"Manual",scratch:"Scratch"}},startImmediately:{label:"Start Immediately",description:"When enabled, worktree tasks start work immediately and create a git worktree. When disabled, tasks go to To Do."},scratchStartupScript:{label:"Scratch Startup Script",description:"Commands to run before agent invocation for scratch tasks (e.g., export ENV_VAR=value)"}},language:{label:"Language",description:"Interface language",options:{auto:"Auto-detect",en:"English",zh:"Chinese (Simplified)"}},theme:{label:"Theme",description:"Color theme for the interface",options:{system:"System",light:"Light",dark:"Dark"}},timezone:{label:"Timezone",description:"Timezone for due date calculations. Auto uses your system timezone.",options:{auto:"Auto (System)"}}},wet={enable:"Enable Notifications",toast:"In-app Toast",toastDescription:"Show toast notifications in the Fulcrum interface",desktop:"Desktop Notifications",desktopDescription:"Show native desktop or browser notifications",sound:"Sound",slack:"Slack",discord:"Discord",pushover:"Pushover",appToken:"App Token",userKey:"User Key",useMessagingChannel:"Use messaging channel",whatsapp:"WhatsApp",telegram:"Telegram",messagingChannelRequired:"Requires connected messaging channel",messagingChannelNote:"Sends via connected messaging channel",gmail:"Gmail",gmailDescription:"Sends notification emails to your own Gmail address",gmailAutoResolve:"Auto-resolve",gmailNoAccounts:"No Gmail-enabled Google accounts configured",testSuccess:"{{channel}} test successful",testFailed:"{{channel}} test failed: {{error}}",uploadSound:"Upload custom sound",deleteSound:"Remove custom sound",testSound:"Test sound",soundUploaded:"Custom sound uploaded",soundUploadFailed:"Failed to upload sound: {{error}}",soundDeleted:"Custom sound removed",soundDeleteFailed:"Failed to remove custom sound",customSoundActive:"Custom sound active"},Eet={rituals:"Daily Rituals",ritualsDescription:"Schedule morning and evening briefings. The assistant will execute your prompts at the specified times.",morningRitual:"Morning Ritual",morningRitualDescription:"Morning briefing with today's priorities.",morningRitualPromptPlaceholder:"Review messages since yesterday evening, summarize what needs attention today, and send a prioritized action plan.",eveningRitual:"Evening Ritual",eveningRitualDescription:"Evening summary with accomplishments and pending items.",eveningRitualPromptPlaceholder:"Summarize what was accomplished today, note pending items, and suggest focus areas for tomorrow."},Cet={restartButton:"Restart Fulcrum",restarting:"Restarting...",restartDescription:"Rebuild and restart the Fulcrum server. If the build fails, the server will continue running.",restartFailed:"Restart failed",checkLogs:"Build may have failed. Check journalctl --user -u fulcrum for details."},ket={label:"CalDAV",statusConnecting:"Connecting...",statusConnected:"Connected ({{count}} calendars)",statusSyncing:"Syncing...",statusError:"Connection error",statusDisconnected:"Disconnected",serverUrl:"Server URL",serverUrlPlaceholder:"https://cloud.example.com/remote.php/dav",username:"Username",usernamePlaceholder:"Enter your username",password:"Password",passwordPlaceholder:"Enter your password or app-specific password",syncInterval:"Sync interval (minutes)",testButton:"Test Connection",connectButton:"Connect",cancelButton:"Cancel",syncButton:"Sync Now",disconnectButton:"Disconnect",testSuccess:"Connection successful! Found {{count}} calendars.",testFailed:"Connection failed",configured:"CalDAV configured and connected",configureFailed:"Failed to configure CalDAV",toggleFailed:"Failed to toggle CalDAV",syncComplete:"Calendars synced",syncFailed:"Sync failed",disconnected:"CalDAV disconnected",disconnectFailed:"Failed to disconnect",fillRequired:"Server URL, username, and password are required",tabBasic:"CalDAV Server",tabGoogle:"Google Calendar",googleClientId:"Client ID",googleClientIdPlaceholder:"your-app.apps.googleusercontent.com",googleClientSecret:"Client Secret",googleClientSecretPlaceholder:"Enter your Google OAuth client secret",connectGoogleButton:"Connect Google Calendar",googleAuthStarted:"Google authorization opened in browser. Complete the sign-in to connect.",googleSetupHelp:"To set up Google Calendar integration:",googleStep1:"1. Go to the Google Cloud Console and create a project (or select an existing one).",googleStep2:'2. Enable the CalDAV API: navigate to APIs & Services > Library, search for "CalDAV API", and enable it.',googleStep3:'3. Configure the OAuth consent screen: go to APIs & Services > OAuth consent screen, set user type to "External", and fill in the required fields.',googleStep4:`4. Add your Google email as a test user under the consent screen's "Test users" section (required while the app is in testing mode).`,googleStep5:'5. Create OAuth credentials: go to APIs & Services > Credentials > Create Credentials > OAuth client ID. Select "Web application" and add your Fulcrum callback URL as an authorized redirect URI.',googleCallbackNote:"Your callback URL: {{callbackUrl}}",googleStep6:"6. Copy the Client ID and Client Secret into the fields above and click Connect.",googleFillRequired:"Client ID and Client Secret are required",setupInstructions:"Setup instructions",helpIntro:"Enter your CalDAV server URL and credentials. Common server URLs:",helpNote:"For Google Calendar, use the Google Calendar tab with OAuth2 authentication.",addAccount:"Add Account",accountName:"Account Name",accountNamePlaceholder:"My CalDAV Server",googleAccountNamePlaceholder:"Google Calendar",disabled:"Disabled",deleteAccount:"Delete",copyRules:"Copy Rules",addRule:"Add Rule",copyRulesSource:"Source Calendar",copyRulesDest:"Destination Calendar",copyRulesSelectCalendar:"Select a calendar...",copyRulesSelectBoth:"Please select both source and destination calendars",copyRulesSameCalendar:"Source and destination must be different calendars",copyRuleCreated:"Copy rule created",copyRuleCreateFailed:"Failed to create copy rule",copyRuleUpdateFailed:"Failed to update copy rule",copyRuleDeleted:"Copy rule deleted",copyRuleDeleteFailed:"Failed to delete copy rule",copyRuleExecuted:"Copied {{created}} new, updated {{updated}} events",copyRuleExecuteFailed:"Failed to execute copy rule",copyRulesLastRun:"Last run: {{date}}",copyRulesRunNow:"Run Now",copyRulesDelete:"Delete",copyRulesEmpty:"No copy rules configured. Add a rule to sync events between calendars."},Tet={label:"IMAP Feed",description:"Monitor an IMAP mailbox as a read-only feed. Incoming emails appear in the messaging timeline but no replies are sent.",disableButton:"Disable Email",emailBackend:"Email Backend"},Aet={title:"Google Accounts",addAccount:"Add Google Account",accountName:"Account Name",nameRequired:"Account name is required",connect:"Connect with Google",connecting:"Connecting...",accountAdded:"Google account connected",accountDeleted:"Google account deleted",calendarSync:"Calendar Sync",lastSync:"Last sync",gmail:"Gmail",sync:"Sync",syncComplete:"Calendar sync complete",delete:"Delete",calendarEnabled:"Calendar sync enabled",calendarDisabled:"Calendar sync disabled",gmailEnabled:"Gmail enabled",gmailDisabled:"Gmail disabled",noAccounts:"No Google accounts configured.",noAccountsGmail:"No Google accounts connected.",addInGeneral:"Add one in General settings",oauthNote:"You will be redirected to Google to authorize access to Calendar and Gmail.",monitorInbox:"Monitor inbox",sendAs:"Send as",sendAsPlaceholder:"you@gmail.com",sendAsUpdated:"Send-as address updated",draftsOnly:"(drafts only)",gmailDescription:"Gmail API uses OAuth2 — no app passwords needed. Drafts are created for human review before sending.",setupGuideTitle:"How to set up Google OAuth credentials",setupGuideStep1:"Go to <link>Google Cloud Console</link>",setupGuideStep2:"Create a new project (or select an existing one)",setupGuideStep3:"Enable the <strong>Google Calendar API</strong> and <strong>Gmail API</strong>",setupGuideStep4:"Go to <strong>APIs & Services → Credentials</strong>",setupGuideStep5:"Create an <strong>OAuth 2.0 Client ID</strong> (type: Web application)",setupGuideStep6:"Add authorized redirect URI: <code>{{redirectUri}}</code>",setupGuideStep7:"Copy the Client ID and Client Secret into the fields below",drafts:"Gmail Drafts",newDraft:"New Draft",to:"To",cc:"CC",subject:"Subject",body:"Body",saveDraft:"Save Draft",updateDraft:"Update Draft",draftCreated:"Draft created",draftUpdated:"Draft updated",draftDeleted:"Draft deleted",draftSent:"Draft sent",noDrafts:"No drafts.",noSubject:"(No Subject)",noRecipients:"No recipients",edit:"Edit",send:"Send"},Net={title:"Unsaved Changes",description:"You have unsaved changes that will be lost if you leave this page.",stay:"Stay",leave:"Leave"},Oet={title:bet,tabs:yet,sections:vet,version:xet,fields:_et,notifications:wet,concierge:Eet,developer:Cet,caldav:ket,imap:Tet,google:Aet,unsavedChanges:Net},Ret="Review",Iet={pullRequests:"Pull Requests",issues:"Issues"},Det={pr:{created:"Created by me",assigned:"Assigned to me",reviewRequested:"Review requests",mentioned:"Mentioned"},issue:{assigned:"Assigned to me",created:"Created by me",mentioned:"Mentioned"},allOrgs:"All Orgs",allOrganizations:"All Organizations",fulcrumReposOnly:"Fulcrum repos only"},jet={tokenRequired:"GitHub Token Required",tokenDescription:"To view your issues and pull requests, add a GitHub Personal Access Token in Settings.",requiredScopes:"Required scopes:",scopes:{repo:"(for private repositories)",readUser:"(for user info)",readOrg:"(for organization list)"},generateToken:"Generate Token",goToSettings:"Go to Settings"},Pet={loading:"Loading...",failedToLoad:"Failed to load pull requests",empty:{all:"No open pull requests",created:"No pull requests created by you",assigned:"No pull requests assigned to you",reviewRequested:"No pull requests awaiting your review",mentioned:"No pull requests mentioning you"},draft:"Draft"},Let={loading:"Loading...",failedToLoad:"Failed to load issues",empty:{assigned:"No issues assigned to you",created:"No issues created by you",mentioned:"No issues mentioning you"}},Met={title:Ret,tabs:Iet,filters:Det,github:jet,prs:Pet,issues:Let},Fet="Worktrees",Bet={total:"{{count}} total",orphaned:"{{count}} orphaned"},$et={button:"Clean up ({{count}})",title:"Delete Completed Worktrees",description:"This will permanently delete {{count}} worktree(s).",linkedTasksWillBeDeleted:"Their linked tasks will also be deleted.",alsoDeleteLinkedTasks:"Also delete linked tasks",done:"Done",canceled:"Canceled",cannotUndo:"This action cannot be undone.",pinnedSkipped:"{{count}} pinned worktree(s) will be skipped"},zet={pin:"Pin worktree",unpin:"Unpin worktree"},Uet={noMatch:"No worktrees match the selected filters.",noWorktrees:"No worktrees found. Worktrees are created when you create tasks."},Het={failedToLoad:"Failed to load worktrees: {{message}}"},Vet={title:Fet,summary:Bet,cleanup:$et,delete:{title:"Delete Worktree",description:"This will permanently delete the worktree directory at",linkedTaskWillBeDeleted:'The linked task "{{title}}" will also be deleted.',alsoDeleteLinkedTask:'Also delete linked task "{{title}}"',cannotUndo:"This action cannot be undone.",button:"Delete {{count}}",unpinFirst:"Unpin worktree before deleting"},pin:zet,empty:Uet,error:Het},Wet="Monitoring",qet={claude:"AI Agents",system:"System Metrics",processes:"Processes",fulcrum:"Fulcrum Servers",worktrees:"Worktrees",scratch:"Scratch",jobs:"Jobs",usage:"Usage Limits",assistant:"Assistant",messages:"Messages",memory:"Memory",review:"Review",observer:"Observer"},Get={showAllInstances:"Show all instances",instanceCount:"{{count}} instance(s) running",totalRam:"{{ram}} MB total",headers:{agent:"Agent",terminal:"Terminal",task:"Task",ram:"RAM",actions:"Actions",pid:"PID",workingDirectory:"Working Dir",source:"Source"},noTask:"(no task)",kill:"Kill",killing:"Killing...",killSelected:"Kill {{count}} selected",source:{fulcrum:"Fulcrum: {{name}}",external:"External"},empty:"No AI agent instances running",emptyFulcrum:" in Fulcrum terminals",error:"Failed to load AI agent instances: {{message}}"},Ket={cpuUsage:"CPU Usage",memoryUsage:"Memory Usage",memoryLabels:{used:"Used",cache:"Cache / Buffers"},diskUsage:"Disk Usage ({{path}})",error:"Failed to load system metrics: {{message}}",timeWindows:{"1m":"1 min","10m":"10 min","1h":"1 hour","3h":"3 hours","6h":"6 hours","12h":"12 hours","24h":"24 hours"}},Yet={topProcesses:"Top Processes",sortBy:{memory:"By Memory",cpu:"By CPU"},headers:{pid:"PID",name:"Name",command:"Command",memory:"Memory"},empty:"No processes found",error:"Failed to load processes: {{message}}",containers:"Containers",containersEmpty:"No containers running",containersUnavailable:"Docker/Podman not available"},Xet={description:"Running Fulcrum dev servers",instanceCount:"{{count}} instance(s) running",headers:{port:"Port",mode:"Mode",directory:"Directory",ram:"RAM",actions:"Actions"},mode:{dev:"Dev",prod:"Prod"},vite:"Vite",kill:"Kill",killing:"Killing...",empty:"No Fulcrum instances running",error:"Failed to load Fulcrum instances: {{message}}"},Qet={fiveHourBlock:"5-Hour Block",sevenDayRolling:"7-Day Rolling",opusWeekly:"Opus Weekly",sonnetWeekly:"Sonnet Weekly",resetsIn:"Resets in {{time}}",resetsAt:"Resets {{time}}",weekProgress:"{{percent}}% through week",unavailable:"Claude Code usage data not available. Make sure you're logged in to Claude Code.",error:"Failed to load usage data: {{message}}"},Zet={sweeps:{title:"Recent Sweeps",empty:"No sweeps recorded",hourly:"Hourly",morningRitual:"Morning Ritual",eveningRitual:"Evening Ritual",eventsProcessed:"{{count}} events",tasksUpdated:"{{count}} tasks",messagesSent:"{{count}} messages",stale:"stale"}},Jet={title:"Agent Memories",search:"Search memories...",empty:"No memories stored yet",noResults:"No memories match your search",total:"{{count}} memories",deleteConfirm:"Delete this memory?",deleted:"Memory deleted",tagsPlaceholder:"Tags (comma-separated)"},ett={title:"Channel Messages",search:"Search...",empty:"No messages found",channels:{all:"All Channels",total:"Total",email:"Email",whatsapp:"WhatsApp",discord:"Discord",telegram:"Telegram",slack:"Slack"},direction:{all:"All",incoming:"Incoming",outgoing:"Outgoing"},labels:{from:"From:",to:"To:"}},ttt={status:{healthy:"Observer Healthy",circuitOpen:"Circuit Breaker Open",failures:"failures"},stats:{total:"Total Processed",successRate:"Success Rate",avgDuration:"Avg Duration",tasksCreated:"Tasks Created",memoriesStored:"Memories Stored",last24h:"Last 24h"},filters:{allChannels:"All Channels",allStatuses:"All Statuses",allProviders:"All Providers",completed:"Completed",failed:"Failed",timeout:"Timeout",circuitOpen:"Circuit Open"},invocations:{title:"Recent Invocations",empty:"No observer invocations recorded"},actions:{createTask:"Task Created",storeMemory:"Memory Stored"},details:{error:"Error",actions:"Actions"}},ntt={title:Wet,tabs:qet,claude:Get,system:Ket,processes:Yet,fulcrum:Xet,usage:Qet,assistant:Zet,memory:Jet,messages:ett,observer:ttt},rtt="Tasks",itt="Repos",stt="New Terminal",att="All Projects",ott="Select repos",ltt="{{count}} selected",ctt="Select up to 6 repos",utt="Search repositories...",dtt="No repositories found",ftt="Clear selection",htt="Select a repository to open its workspace terminal",ptt="No active tasks",mtt={title:"Edit Tab",name:"Name",namePlaceholder:"Tab name",directory:"Directory",directoryPlaceholder:"Select a directory...",clearDirectory:"Clear directory",cancel:"Cancel",save:"Save"},gtt={title:"New Tab",create:"Create"},btt={taskTerminals:rtt,repoTerminals:itt,newTerminal:stt,allProjects:att,selectRepos:ott,reposSelected:ltt,filterByRepo:ctt,searchRepos:utt,noReposFound:dtt,clearFilter:ftt,emptyRepos:htt,emptyTasks:ptt,editTab:mtt,newTab:gtt},ytt="Repositories",vtt="{{count}} total",xtt="Search repositories...",_tt="New Task",Stt="Tasks",wtt="Terminal",Ett="Editor",Ctt="Application",ktt="Applications",Ttt="Create App",Att={title:"Docker Compose Required",description:"To create an app for deployment, this repository needs a Docker Compose file.",instructions:"Create a docker-compose.yml file in your repository.",close:"Got it"},Ntt="Settings",Ott="Add Repository",Rtt="Scan Directory",Itt="Open in Terminal",Dtt="Open in {{editor}}",jtt={openInVSCode:"Open in VS Code"},Ptt={title:"Add Repository",description:"Add a git repository from a URL or local path, or scan a directory.",tabs:{add:"Add",scan:"Scan",template:"From Template"},inputLabel:"Repository URL or path",inputPlaceholder:"https://github.com/user/repo or /local/path",browse:"Browse...",cloneOptions:"Clone Options",targetDirectory:"Clone to directory",folderName:"Folder name",willCloneTo:"Will clone to",cloning:"Cloning repository...",adding:"Adding...",cloneFailed:"Failed to clone repository",createFailed:"Failed to add repository",cancel:"Cancel",add:"Add",retry:"Retry",fields:{path:"Repository Path",pathPlaceholder:"Select repository...",displayName:"Display Name",startupScript:"Startup Script",startupScriptPlaceholder:"npm install && npm run dev",startupScriptDescription:"Command to run in the terminal when creating a worktree.",copyFiles:"Copy Files",copyFilesPlaceholder:".env, config.local.json",copyFilesDescription:"Comma-separated glob patterns for files to copy into new worktrees.",isCopierTemplate:"Use as Copier Template",isCopierTemplateDescription:"Mark as a template for creating new projects."}},Ltt={button:"New Project",title:"Create New Project",back:"Back",next:"Next",create:"Create Project",steps:{template:{description:"Select a template to create your project from.",sectionTitle:"Copier Template",sectionDescription:"Select a saved template or enter a URL/path.",learnMore:"Learn more",savedTemplates:"Saved Templates",selectTemplate:"Select a template...",or:"or",customUrl:"Custom Template URL/Path"},questions:{title:"Template Questions",description:"Configure your project.",noQuestions:"This template has no configuration questions."},output:{title:"Output Location",description:"Choose where to create your project.",projectName:"Project Name",outputDirectory:"Output Directory",selectDirectory:"Select directory...",willCreate:"Will create",trust:"Trust template"},creating:{description:"Creating your project...",inProgress:"Running Copier..."}}},Mtt={title:"Scan Directory for Repositories",description:"Find and add multiple git repositories from a directory.",directoryLabel:"Directory to scan",directoryPlaceholder:"Enter directory path",browse:"Browse...",scan:"Scan",foundRepos:"Found {{count}} repositories",selectAll:"Select all",selectNone:"Select none",noReposFound:"No git repositories found in this directory.",alreadyAdded:"Already added",adding:"Adding repositories...",scanFailed:"Failed to scan directory",addFailed:"Failed to add repositories",cancel:"Cancel",addSelected:"Add {{count}} selected"},Ftt={noRepositories:"No repositories added yet. Add a repository for quick access when creating tasks.",noMatches:"No repositories match your search."},Btt={failedToLoad:"Failed to load repositories: {{message}}"},$tt={breadcrumb:"Repositories",notFound:"Repository not found",save:"Save",saving:"Saving...",saved:"Repository saved",failedToSave:"Failed to save repository",tabs:{settings:"Task Settings",workspace:"Workspace"},mobileWorkspace:{terminal:"Terminal",files:"Files"},fileTree:{title:"Files",searchPlaceholder:"Search files...",noFiles:"No files",collapseAll:"Collapse all folders"},settings:{generalTitle:"General",agentTitle:"Agent Options",displayName:"Display Name",defaultAgent:"Default Agent",defaultAgentInherit:"Use global default",defaultAgentDescription:"Override the global default agent for tasks created from this repository.",startupScript:"Startup Script",startupScriptPlaceholder:"npm install && npm run dev",startupScriptDescription:"Command to run in the terminal when creating a worktree.",claudeOptions:"Claude Code Options",claudeOptionsDescription:"CLI flags passed to Claude Code when starting a task.",opencodeOptions:"OpenCode Options",opencodeOptionsDescription:"CLI flags passed to OpenCode when starting a task.",opencodeModel:"OpenCode Model",opencodeModelPlaceholder:"Select model",opencodeModelDescription:"Default OpenCode model for tasks created from this repository.",agentOptionsFlag:"Flag",agentOptionsValue:"Value",addAgentOption:"Add option",copyFiles:"Copy Files",copyFilesPlaceholder:".env, config.local.json",copyFilesDescription:"Comma-separated glob patterns for files to copy into new worktrees.",isCopierTemplate:"Use as Copier Template",isCopierTemplateDescription:"Mark as a template for creating new projects with Copier."},workspace:{connectingToTerminal:"Connecting to terminal server...",initializingTerminal:"Initializing terminal...",terminalConnectionFailed:"Terminal connection failed",recreateTerminal:"Recreate Terminal"}},ztt={title:ytt,total:vtt,searchPlaceholder:xtt,newTask:_tt,viewTasks:Stt,terminal:wtt,editor:Ett,application:Ctt,applications:ktt,createApp:Ttt,createAppDialog:Att,settings:Ntt,addRepository:Ott,scanDirectory:Rtt,openInTerminal:Itt,openInEditor:Dtt,card:jtt,delete:{title:"Delete Repository",description:'This will remove "{{name}}" from Fulcrum. The actual repository files will not be affected.',button:"Delete",deleting:"Deleting...",alsoDeleteDirectory:"Also delete the directory from disk",deleteDirectoryWarning:"This will permanently delete all files in the repository. This action cannot be undone."},addModal:Ptt,newProject:Ltt,bulkAdd:Mtt,empty:Ftt,error:Btt,detailView:$tt},Utt="Jobs",Htt="View scheduled tasks (systemd timers on Linux, launchd jobs on macOS)",Vtt="Search jobs...",Wtt="No scheduled jobs found",qtt="No jobs match your search",Gtt="Create Job",Ktt={all:"All",user:"User",system:"System"},Ytt={active:"Active",inactive:"Inactive",failed:"Failed",waiting:"Waiting",disabled:"Disabled"},Xtt="Next",Qtt="Last",Ztt="System timers are read-only",Jtt="Jobs on macOS are read-only",ent={enable:"Enable",disable:"Disable",start:"Start",stop:"Stop",runNow:"Run Now",edit:"Edit",delete:"Delete",viewLogs:"View Logs"},tnt={tabs:{general:"General",logs:"Logs",edit:"Edit"},schedule:"Schedule",nextRun:"Next Run",lastRun:"Last Run",lastResult:"Last Result",description:"Description",command:"Command",workingDir:"Working Directory",systemTimer:"System timer (read-only)",timerFile:"Timer File",serviceFile:"Service File",executionStats:"Last Execution",duration:"Duration",cpuTime:"CPU Time",noStats:"No execution data available"},nnt={title:"Create Scheduled Job",name:"Job Name",namePlaceholder:"backup-daily",nameHelp:"Alphanumeric, hyphens, and underscores only",description:"Description",descriptionPlaceholder:"Daily backup of important files",schedule:"Schedule",scheduleHelp:"OnCalendar expression (e.g., *-*-* 02:00:00, daily, weekly)",command:"Command",commandPlaceholder:"/home/user/scripts/backup.sh",workingDir:"Working Directory",workingDirPlaceholder:"/home/user",persistent:"Persistent",persistentHelp:"Run missed executions when system starts",cancel:"Cancel",create:"Create Job"},rnt={title:"Job Logs",noLogs:"No logs available",lines:"lines",refresh:"Refresh"},int={loadFailed:"Failed to load jobs",createFailed:"Failed to create job",updateFailed:"Failed to update job",deleteFailed:"Failed to delete job"},Eae={title:Utt,description:Htt,searchPlaceholder:Vtt,noJobs:Wtt,noJobsMatch:qtt,createJob:Gtt,scope:Ktt,status:Ytt,nextRun:Xtt,lastRun:Qtt,systemTimerReadonly:Ztt,macosReadonly:Jtt,actions:ent,detail:tnt,create:nnt,delete:{title:"Delete Job",confirm:'Are you sure you want to delete "{{name}}"? This will remove both the timer and service files.',cancel:"Cancel",delete:"Delete"},logs:rnt,errors:int},snt="Projects",ant="{{count}} total",ont="Search projects...",lnt="New Task",cnt="Add Repo",unt="Link Repo",dnt="Back to Projects",fnt="New Task",hnt="Project not found",pnt="Terminal",mnt="Editor",gnt="Deploy",bnt="Stop",ynt="New Project",vnt={noProjects:"No projects yet. Create a project to get started.",noMatches:"No projects match your search."},xnt={failedToLoad:"Failed to load projects: {{message}}"},_nt={noApp:"No app",running:"Running",building:"Building",stopped:"Stopped",failed:"Failed"},Snt={breadcrumb:"Projects",notFound:"Project not found",save:"Save",saving:"Saving...",tabs:{settings:"Task Settings",workspace:"Workspace",deploy:"Deploy",deployGeneral:"General",deployments:"Deployments",logs:"Logs",monitoring:"Monitoring"},general:{repositoryTitle:"Repository",agentTitle:"Agent Options",path:"Path",displayName:"Display Name",startupScript:"Startup Script",copyFiles:"Copy Files",defaultAgent:"Default Agent",claudeOptions:"Claude Code Options",opencodeOptions:"OpenCode Options",opencodeModel:"OpenCode Model",noRepository:"No repository linked to this project."},app:{title:"App Configuration",noApp:"No app configured for this project.",configureDeployment:"Configure Deployment",configureDeploymentDescription:"Set up Docker Compose deployment for this project",configuring:"Configuring...",deployOptions:"Deploy Options",autoDeployEnabled:"Auto-deploy on commit",autoPortAllocation:"Auto-allocate ports",noCacheBuild:"No-cache builds",notificationsEnabled:"Deployment notifications",services:"Services",environment:"Environment Variables",composeFile:"Compose File"}},wnt={step:"Step {{current}} of {{total}}",selectRepository:"Select Repository",existingRepo:"Existing",addNewRepo:"Add New",searchRepos:"Search repositories...",noReposFound:"No repositories found",repoPathOrUrl:"Repository Path or URL",repoInputPlaceholder:"~/code/my-repo or https://github.com/user/repo",browse:"Browse",cloneOptions:"Clone Options",targetDirectory:"Target Directory",folderName:"Folder Name",willCloneTo:"Will clone to",cloning:"Cloning repository...",adding:"Adding repository...",cloneAndSelect:"Clone & Select",addAndSelect:"Add & Select",addRepoFailed:"Failed to add repository",checkingCompose:"Checking for compose file...",composeFound:"Found {{file}}",noCompose:"No compose file found",cancel:"Cancel",next:"Next",back:"Back",configureProject:"Configure Project",projectName:"Project Name",projectNamePlaceholder:"my-project",description:"Description",descriptionPlaceholder:"Optional project description",composeDetected:"Docker Compose detected: {{file}}",setupAppNow:"Set up app deployment after creation",createProject:"Create Project",creating:"Creating...",create:"Create"},Ent={all:"All",hasApp:"With App",noApp:"Without App",running:"Running",archived:"Archived"},Cnt={summaryDefault:"Default",inherit:"Inherit",summaryClaudeOptions_one:"Claude: {{count}} option",summaryClaudeOptions_other:"Claude: {{count}} options",summaryOpencodeOptions_one:"OpenCode: {{count}} option",summaryOpencodeOptions_other:"OpenCode: {{count}} options",summaryModel:"Model",description:"Configure default agent settings for this project. Repositories can override these settings.",useGlobalDefault:"Use global default",startupScript:"Startup Script",startupScriptDescription:"Commands to run before agent invocation. Runs before the repository's startup script."},knt={activeCount_one:"{{count}} active",activeCount_other:"{{count}} active",doneCount_one:"{{count}} done",doneCount_other:"{{count}} done"},Tnt={clickToEdit:"Click to edit",actions:{task:"Task",repo:"Repo",link:"Link"},sections:{repositories:"Repositories",links:"Links",attachments:"Attachments",tags:"Tags",notes:"Notes",activeTasks:"Active Tasks"},addDescription:"Add a description...",save:"Save",edit:"Edit",done:"Done",add:"Add",cancel:"Cancel",noRepositories:"No repositories linked to this project.",linkExisting:"Link Existing",urlPlaceholder:"https://...",linkLabelPlaceholder:"Label (optional)",labelPlaceholder:"Label",removeLink:"Remove link",addLink:"Add link",addTag:"Add tag...",loadingAttachments:"Loading attachments...",uploading:"Uploading...",dropOrClick:"Drop files here or click to upload",dropOrClickShort:"Drop or click",attachmentTypes:"Any file (max 10MB)",noAttachments:"No attachments",noTags:"No tags",searchOrCreateTag:"Search or create tag...",createTag:'Create "{{tag}}"',noMatchingTags:"No matching tags",addNotes:"Add notes about this project...",noNotes:"No notes",noActiveTasks:"No active tasks",loading:"Loading..."},Ant={title:snt,total:ant,searchPlaceholder:ont,newTask:lnt,addRepo:cnt,linkRepo:unt,backToProjects:dnt,createTask:fnt,notFound:hnt,terminal:pnt,editor:mnt,deploy:gnt,stop:bnt,newProjectButton:ynt,empty:vnt,error:xnt,card:_nt,delete:{title:"Delete Project",description:'This will remove the project "{{name}}".',confirmText:'Are you sure you want to delete "{{name}}"? This action cannot be undone.',button:"Delete",confirm:"Delete",cancel:"Cancel",success:"Project deleted",error:"Failed to delete project",deleting:"Deleting...",reposWarning_one:"This project has {{count}} linked repository. Deleting will unlink it.",reposWarning_other:"This project has {{count}} linked repositories. Deleting will unlink them.",alsoDeleteDirectory:"Also delete the directory",alsoDeleteApp:"Also delete the app and stop containers"},detailView:Snt,newProject:wnt,filter:Ent,agentSettings:Cnt,repoCard:knt,detail:Tnt},Nnt="AI Assistant",Ont={clearConversation:"Clear conversation",connected:"Connected",aiAssistantResponse:"AI Assistant Response"},Rnt={claude:"Claude",opencode:"OpenCode"},Int={selectModel:"Select model",filterModels:"Filter models...",noModelsMatch:'No models match "{{filter}}"',opus:"Opus",opusDescription:"Most capable",sonnet:"Sonnet",sonnetDescription:"Balanced",haiku:"Haiku",haikuDescription:"Fastest"},Dnt={placeholder:"Manage tasks, projects, run commands, deploy apps... Ask anything!",askAnything:"Ask anything...",shiftEnterHint:"Press <kbd>Shift + Enter</kbd> for new line"},jnt={selectChat:"Select a chat",messages:"messages",msgs:"msgs",rename:"Rename",delete:"Delete",noChatsYet:"No chats yet",newChat:"New Chat",selectOrCreate:"Select or create a chat to get started",startConversation:"Start a conversation by sending a message",thinking:"Thinking"},Pnt={tabs:{canvas:"Canvas",editor:"Editor",documents:"Documents",memory:"Memory"},empty:{title:"Select a chat to view the canvas",description:"Charts and visualizations will appear here"},viewer:{empty:{title:"Canvas is empty",description:"Ask the assistant to show a chart, table, or visualization"}},editor:{title:"Document Editor - Write markdown with AI assistance",placeholder:"Start writing your document..."},documents:{empty:{title:"No documents yet",description:"Documents created by AI will appear here"}},memory:{title:"Master Memory File",path:"~/.fulcrum/MEMORY.md",placeholder:`# Memory
36
36
 
37
37
  The assistant will store persistent knowledge here as it learns about you.
38
38
  You can also edit this file directly.
@@ -41,7 +41,7 @@ You can also edit this file directly.
41
41
 
42
42
  Add any standing instructions for the assistant here...`,empty:{title:"Memory file is empty",description:"The assistant will populate this as it learns about you, or you can add content directly"}}},Lnt={chartInCanvas:"Chart rendered in canvas",contentInCanvas:"Content displayed in canvas",documentInEditor:"Document updated in editor"},Mnt={title:Nnt,header:Ont,providers:Rnt,models:Int,input:Dnt,chat:jnt,canvas:Pnt,placeholders:Lnt},Fnt="Scratch Directories",Bnt={total:"{{count}} total",orphaned:"{{count}} orphaned"},$nt={button:"Clean up ({{count}})",title:"Delete Completed Scratch Directories",description:"This will permanently delete {{count}} scratch directory/directories.",linkedTasksWillBeDeleted:"Their linked tasks will also be deleted.",alsoDeleteLinkedTasks:"Also delete linked tasks",cannotUndo:"This action cannot be undone.",pinnedSkipped:"{{count}} pinned directory/directories will be skipped"},znt={pin:"Pin directory",unpin:"Unpin directory"},Unt={noMatch:"No scratch directories match the selected filters.",noDirs:"No scratch directories found. Scratch directories are created when you create scratch tasks."},Hnt={failedToLoad:"Failed to load scratch directories: {{message}}"},Vnt={title:Fnt,summary:Bnt,cleanup:$nt,delete:{title:"Delete Scratch Directory",description:"This will permanently delete the scratch directory at",linkedTaskWillBeDeleted:'The linked task "{{title}}" will also be deleted.',alsoDeleteLinkedTask:'Also delete linked task "{{title}}"',cannotUndo:"This action cannot be undone.",button:"Delete {{count}}",unpinFirst:"Unpin directory before deleting"},pin:znt,empty:Unt,error:Hnt},Wnt={save:"保存更改",cancel:"取消",delete:"删除",create:"创建",reset:"重置为默认值",browse:"浏览",clearFilters:"清除筛选"},qnt={loading:"加载中...",saving:"保存中...",saved:"已保存",error:"错误",calculating:"计算中...",validating:"验证中...",creating:"创建中...",deleting:"删除中...",loggingIn:"登录中...",uploading:"上传中..."},Gnt={justNow:"刚刚",minuteAgo:"1 分钟前",minutesAgo:"{{count}} 分钟前",hourAgo:"1 小时前",hoursAgo:"{{count}} 小时前",dayAgo:"1 天前",daysAgo:"{{count}} 天前"},Knt={one:"{{count}} 个结果",other:"{{count}} 个结果"},Ynt={TO_DO:"待办",IN_PROGRESS:"进行中",IN_REVIEW:"审核中",DONE:"已完成",CANCELED:"已取消",ORPHANED:"孤立"},Xnt={loginTitle:"登录 Fulcrum",username:"用户名",password:"密码",login:"登录",loginFailed:"登录失败"},Qnt={sentToClaude:"已发送到 Claude Code",noTerminal:"没有可用的终端",syncedFromMain:"已从 main 同步",mergedToMain:"已合并到 main",pushedToOrigin:"已推送到 origin",parentSynced:"父仓库已与 origin 同步",prCreated:"PR 已创建",prExists:"PR 已存在"},Znt={imageUploadFailed:"图片上传失败",terminalNotConnected:"终端未连接",terminalNotConnectedDesc:"请等待连接建立"},Jnt={notInstalled:"OpenCode 未安装",selectModel:"选择模型",useDefault:"使用默认",noModelsFound:"未找到模型"},ert={manualDnsRequired:"需要手动配置 DNS",manualDnsRequiredDesc:"未配置 Cloudflare API 令牌。您需要手动为域名创建 DNS 记录。",deployToApply:"部署以应用更改",deployToApplyDesc:"域名配置已保存。部署应用程序以使更改生效。",unknownRepo:"未知仓库",service:"服务",services:"服务",exposed:"已暴露",lastDeployed:"上次部署",stop:"停止",deploy:"部署",deploying:"部署中...",building:"构建中...",cancelDeploy:"取消",cancelling:"取消中...",delete:"删除",deleting:"删除中...",searchApps:"搜索应用...",allRepos:"所有仓库",newApp:"新建应用",createApp:"创建应用",noAppsYet:"暂无应用。创建您的第一个应用开始使用!",noAppsMatch:"没有匹配的应用。",failedToLoadApps:"加载应用失败",deleteApp:"删除应用",deleteAppConfirm:'确定要删除 "{{name}}" 吗?这将停止所有容器并删除应用配置。此操作无法撤销。',cancel:"取消",appNotFound:"应用未找到",backToApps:"返回应用列表",tabs:{general:"概览",deployments:"部署记录",logs:"日志",environment:"环境变量",domains:"域名",monitoring:"监控",workspace:"工作区"},general:{deploy:"部署",deployOptions:"部署选项",autodeploy:"自动部署",noCache:"无缓存",notifications:"通知",services:"服务",noServicesConfigured:"未配置服务"},workspace:{noRepository:"此应用未关联仓库"},compose:{title:"Compose 文件",repoNotFound:"未找到仓库路径",unsavedChanges:"未保存的更改",save:"保存",edit:"编辑",done:"完成",preview:"预览",previewDescription:"预览将要部署的 compose 文件",generatedTitle:"生成的 Compose 文件预览",generatedDescription:"显示当前配置将要部署的内容,包括环境变量展开和 Docker Swarm 转换。"},logs:{title:"日志",description:"实时查看应用程序日志",allContainers:"所有容器",lines:"行",copy:"复制",copied:"已复制",download:"下载",refresh:"刷新",noLogs:"暂无日志"},deployments:{title:"部署记录",description:"查看此 Compose 的最近 10 次部署",noDeployments:"暂无部署记录",view:"查看",statusDone:"完成",statusError:"错误",statusBuilding:"构建中",deployment:"部署",seeDetails:"查看此部署的详细信息",noBuildLogs:"暂无构建日志"},environment:{title:"环境变量",description:"设置 Docker Compose 构建的环境变量。这些变量在构建期间和容器中都可用。",placeholder:`DATABASE_URL=postgres://...
43
43
  API_KEY=your-api-key
44
- # 支持注释`,save:"保存环境变量",showValues:"显示值",hideValues:"隐藏值",unsavedChanges:"您有未保存的更改"},domains:{title:"域名配置",description:"配置要暴露的服务及其域名映射",expose:"暴露",exposeRequiresPort:"未配置端口。请在 compose 文件中添加端口映射。",domain:"域名",noDomain:"未配置域名",portRequired:"需要端口",editDomain:"编辑域名",noServices:"未配置服务。请先部署应用以查看可用服务。",save:"保存"},streaming:{pulling:"拉取代码...",building:"构建容器...",starting:"启动服务...",configuring:"配置路由...",done:"部署完成!",failed:"部署失败",cancelled:"部署已取消",preparing:"准备中...",waitingForLogs:"等待日志..."},dnsConfigRequired:"需要配置 DNS",settings:"设置",status:{running:"运行中",building:"构建中",failed:"失败",stopped:"已停止"},monitoring:{title:"资源使用",description:"每个服务的实时 CPU 和内存使用情况",cpu:"CPU",memory:"内存",noContainers:"未找到运行中的容器",dockerUnavailable:"Docker 统计不可用",serviceTotal:"服务总计"}},trt={weekly:"周视图",monthly:"月视图"},nrt={buttons:Wnt,status:qnt,time:Gnt,results:Knt,statuses:Ynt,auth:Xnt,git:Qnt,errors:Znt,opencode:Jnt,apps:ert,calendar:trt},rrt={tasks:"任务",projects:"项目",terminals:"终端",worktrees:"工作树",repositories:"仓库",apps:"应用",jobs:"作业",assistant:"助手",review:"审核",calendar:"日历",monitoring:"监控",settings:"设置",commandPalette:"命令面板 ({{shortcut}})",help:"文档"},irt={placeholder:"输入命令或搜索...",noResults:"未找到命令",categories:{navigation:"导航",actions:"操作"},commands:{goToTasks:"前往任务",goToProjects:"前往项目",goToTerminals:"前往终端",goToAssistant:"前往助手",goToTaskTerminals:"前往任务终端",goToProjectTerminals:"前往项目终端",goToRepositories:"前往仓库",goToApps:"前往应用",goToJobs:"前往作业",goToReview:"前往审核",goToCalendar:"前往日历",goToMonitoring:"前往监控",goToSettings:"前往设置",newTask:"新建任务",newProject:"新建项目",openInEditor:"在编辑器中打开",keyboardShortcuts:"键盘快捷键"}},srt={title:"键盘快捷键",groups:{navigation:"导航",actions:"操作",terminals:"终端(桌面端)",general:"通用"},labels:{goToTasks:"前往任务",goToProjects:"前往项目",goToTerminals:"前往终端",goToAssistant:"前往助手",goToTaskTerminals:"前往任务终端",goToProjectTerminals:"前往项目终端",goToRepositories:"前往仓库",goToApps:"前往应用",goToJobs:"前往作业",goToReview:"前往审核",goToCalendar:"前往日历",goToMonitoring:"前往监控",goToSettings:"前往设置",commandPalette:"命令面板",newTask:"新建任务",newProject:"新建项目",openInEditor:"在编辑器中打开",openAiAssistant:"打开AI助手",keyboardShortcuts:"键盘快捷键",closeModal:"关闭弹窗",newTerminal:"新建终端",closeTerminal:"关闭终端",submitForm:"提交表单"}},art={title:"在编辑器中打开",description:"在 {{editor}} 中打开文件夹",pathLabel:"目录路径",pathPlaceholder:"~/projects/my-project",pathHint:"请输入目录路径。支持 ~ 表示主目录。",pathNotFound:"路径不存在",pathNotDirectory:"路径必须是目录,不能是文件",browse:"浏览",cancel:"取消",open:"打开"},ort={header:rrt,commandPalette:irt,shortcuts:srt,openInEditor:art},lrt="任务",crt="搜索",urt="全部项目",drt="标签",frt="搜索标签...",hrt="未找到标签",prt="清除所有标签",mrt="搜索项目...",grt="未找到项目",brt={label:"类型",types:{worktree:"Git",scratch:"临时",manual:"手动"},clear:"清除筛选",showLabels:"显示任务类型标签"},yrt={label:"优先级",priorities:{high:"高",medium:"中",low:"低"},clear:"清除筛选"},vrt="新建任务",xrt={high:"高",medium:"中",low:"低"},_rt={title:"创建新任务",description:"创建一个带有 Git 工作树的新任务,用于隔离开发。",taskTypes:{worktree:"Git",manual:"手动",scratch:"临时"},taskDescriptions:{worktree:"创建 Git 工作树并打开 AI 编程代理。",manual:"无需 Git 工作树或 AI 代理的通用任务。",scratch:"创建一个带有 AI 编程代理的独立目录,无需 Git 仓库。"},fields:{title:"标题",titlePlaceholder:"添加用户认证",description:"描述",descriptionPlaceholder:"实现 OAuth2 登录流程...",aiMode:"AI 模式",agent:"AI 代理",opencodeModel:"OpenCode 模型",opencodeModelPlaceholder:"选择模型",repository:"仓库",baseBranch:"基础分支",prefix:"分支前缀",prefixPlaceholder:"例如 ENG-123",branchName:"分支名称",branchPlaceholder:"自动生成分支名",project:"项目(可选)",tags:"标签",tagsPlaceholder:"添加标签...",dueDate:"截止日期",dueDatePlaceholder:"设置日期",estimate:"预估时间",priority:"优先级",notes:"备注",notesPlaceholder:"添加备注...",links:"链接",urlPlaceholder:"https://...",linkLabelPlaceholder:"标签(可选)",prUrl:"GitHub PR",prUrlPlaceholder:"https://github.com/owner/repo/pull/123",attachments:"附件",addAttachments:"添加附件...",addMoreFiles:"添加更多文件...",blockedBy:"阻塞任务",repeat:"重复",recurrenceEndDate:"重复截止"},recurrence:{none:"无",daily:"每天",weekly:"每周",biweekly:"每两周",monthly:"每月",quarterly:"每季度",yearly:"每年",recurringSeriesNote:"属于重复系列任务"},aiModes:{plan:"计划",default:"默认"},tabs:{saved:"仓库",browse:"浏览"},worktreePrefix:"工作树:",prefixHint:"添加到分支名称前,用于关联工单。",branchAutoGenerated:'留空将使用 "{{branch}}"。',selectFolder:"选择文件夹...",searchRepositories:"搜索仓库...",noRepositoriesFound:"未找到仓库",selectRepositoryFirst:"请先选择仓库",loadingBranches:"加载分支中...",selectBranch:"选择分支",noBranchesFound:"未找到分支",current:"(当前)",createTask:"创建任务",noProject:"无项目(收件箱)",projectHint:"无项目的任务将显示在收件箱中。",blockedByHint:"必须完成才能开始此任务的前置任务。",blockedByPlaceholder:"搜索阻塞任务...",noTasksFound:"未找到任务",startImmediately:"立即开始工作",advanced:"高级",pinTask:"置顶任务",unpinTask:"取消置顶",errors:{notGitRepo:"所选文件夹不是 Git 仓库",validationFailed:"验证仓库失败",createFailed:"创建任务失败",invalidUrl:"无效的 URL",invalidUrlDescription:"请输入包含协议的有效 URL(例如:https://)"}},Srt={title:lrt,searchPlaceholder:crt,allProjects:urt,allTags:drt,searchTags:frt,noTagsFound:hrt,clearTags:prt,searchProjects:mrt,noProjectsFound:grt,typeFilter:brt,priorityFilter:yrt,newTask:vrt,priority:xrt,createModal:_rt},wrt="设置",Ert={general:"常规",ai:"AI 与开发",messaging:"邮件与消息",calendar:"日历"},Crt={server:"服务器",serverDefaults:"服务器与默认设置",paths:"路径",editor:"编辑器",integrations:"集成",zai:"z.ai",agent:"工作树代理",assistant:"AI 助手",tasks:"任务默认值",notifications:"通知",messaging:"消息",appearance:"外观",developer:"开发者",caldav:"日历集成"},krt={upToDate:"已是最新版本",updateAvailable:"有新版本: v{{version}}",checkingForUpdates:"检查中...",updateButton:"更新",update:"更新",updating:"更新中...",updateStarted:"更新已启动。服务器即将重启。",updateFailed:"更新失败。请重试或手动更新。",updateCommand:"运行以更新:",viewRelease:"查看版本",refresh:"检查更新"},Trt={port:{label:"端口",description:"需要重启"},startupCommand:{label:"启动命令",description:"新任务终端的命令"},gitReposDir:{label:"Git 仓库目录",description:"仓库选择器的起始目录"},editor:{app:{label:"编辑器",description:"用于打开工作树的代码编辑器",options:{vscode:"VS Code",cursor:"Cursor",windsurf:"Windsurf",zed:"Zed",antigravity:"Antigravity"}},host:{label:"远程主机",description:"代码在远程机器上时使用的 SSH 地址",placeholder:"例如:my-server.tailnet.ts.net"},sshPort:{label:"SSH 端口",description:"远程 SSH 端口(默认 22)"}},linear:{label:"Linear",description:"用于工单同步的 API 密钥"},github:{label:"GitHub",description:"用于 Issues 和 PR 的个人访问令牌"},cloudflare:{label:"Cloudflare",placeholder:"输入 API 令牌...",description:"用于自动 DNS 记录的 API 令牌"},zai:{enable:"启用",apiKey:"API 密钥",description:"配置 Claude Code 使用 z.ai 代理",modelMappings:"模型映射",haiku:"Haiku",sonnet:"Sonnet",opus:"Opus"},agent:{default:{label:"默认代理",description:"新任务使用的 AI 编码代理"},opencodeModel:{label:"OpenCode 模型",placeholder:"选择模型",description:"启动 OpenCode 任务时使用的默认模型"},advancedAgentNames:{label:"高级代理名称",description:"配置 OpenCode 模式的特定代理名称",warning:"仅在您知道自己在做什么的情况下更改这些设置。这些设置适用于拥有自定义 OpenCode 代理(例如,带有 Sisyphus/Planner-Sisyphus 代理的 oh-my-opencode 插件)的用户。"},opencodeDefaultAgent:{label:"默认模式",description:"全权限模式的代理名称。oh-my-opencode 使用 'Sisyphus',原版 OpenCode 使用 'build'。"},opencodePlanAgent:{label:"计划模式",description:"受限/计划模式的代理名称。oh-my-opencode 使用 'Planner-Sisyphus',原版 OpenCode 使用 'plan'。注意:Planner-Sisyphus 从 OpenCode 的 plan 代理配置继承模型,因此上述模型覆盖可能不适用。请在 ~/.config/opencode/oh-my-opencode.json 中配置模型。"},autoScrollToBottom:{label:"自动滚动到底部",description:"当有新输出时自动将终端滚动到底部"},claudeCodePath:{label:"Claude Code 路径",placeholder:"自动检测(留空)",description:"覆盖自动检测的 Claude Code 可执行文件路径。留空则从 PATH 或常见安装位置自动检测。"}},assistant:{provider:{label:"默认提供商",description:"助手对话使用的 AI 提供商"},model:{label:"Claude 模型",description:"AI 助手对话使用的 Claude 模型",options:{opus:"Opus(最强大)",sonnet:"Sonnet(平衡)",haiku:"Haiku(最快)"}},observerProvider:{label:"观察者提供商",description:"用于仅观察消息处理的 AI 提供商。仅观察消息(非自聊 WhatsApp、未授权邮件)使用受限工具访问以确保安全。",options:{default:"与主提供商相同"}},observerModel:{label:"观察者模型",description:"用于仅观察消息处理的 Claude 模型。使用更便宜的模型可降低成本。",options:{opus:"Opus(最强大)",sonnet:"Sonnet(平衡)",haiku:"Haiku(最快)"}},observerOpencodeModel:{label:"观察者 OpenCode 模型",description:"用于仅观察消息处理的 OpenCode 模型。未设置时回退到主 OpenCode 模型。",placeholder:"与主 OpenCode 模型相同"},opencodeModel:{label:"OpenCode 模型",description:"选择 OpenCode 作为提供商时使用的模型",placeholder:"选择模型"},customInstructions:{label:"记忆文件",openMemoryFile:"打开记忆文件",memoryDescription:"助手的持久指令和知识。存储在 ~/.fulcrum/MEMORY.md 中,包含在每次对话中。"},documentsDir:{label:"文档目录",description:"AI 生成的文档保存为 Markdown 文件的目录。"}},tasks:{defaultType:{label:"默认类型",description:"创建新任务时默认选择的类型",options:{worktree:"Git",manual:"手动",scratch:"临时"}},startImmediately:{label:"立即开始",description:"启用后,工作树任务会立即开始工作并创建 git 工作树。禁用后,任务会进入待办事项。"}},language:{label:"语言",description:"界面语言",options:{auto:"自动检测",en:"English",zh:"简体中文"}},theme:{label:"主题",description:"界面颜色主题",options:{system:"跟随系统",light:"浅色",dark:"深色"}},timezone:{label:"时区",description:"用于截止日期计算的时区。自动使用系统时区。",options:{auto:"自动(系统)"}}},Art={enable:"启用通知",toast:"应用内提示",toastDescription:"在 Fulcrum 界面中显示提示通知",desktop:"桌面通知",desktopDescription:"显示原生桌面或浏览器通知",sound:"声音",slack:"Slack",discord:"Discord",pushover:"Pushover",appToken:"应用令牌",userKey:"用户密钥",useMessagingChannel:"使用消息通道",whatsapp:"WhatsApp",telegram:"Telegram",messagingChannelRequired:"需要已连接的消息通道",messagingChannelNote:"通过已连接的消息通道发送",gmail:"Gmail",gmailDescription:"向您自己的 Gmail 地址发送通知邮件",gmailAutoResolve:"自动选择",gmailNoAccounts:"未配置启用 Gmail 的 Google 账号",testSuccess:"{{channel}} 测试成功",testFailed:"{{channel}} 测试失败:{{error}}",uploadSound:"上传自定义声音",deleteSound:"删除自定义声音",testSound:"测试声音",soundUploaded:"自定义声音已上传",soundUploadFailed:"上传声音失败:{{error}}",soundDeleted:"自定义声音已删除",soundDeleteFailed:"删除自定义声音失败",customSoundActive:"使用自定义声音"},Nrt={rituals:"每日仪式",ritualsDescription:"设置晨间和晚间简报的时间。助手将在指定时间执行您的提示词。",morningRitual:"晨间仪式",morningRitualDescription:"包含今日优先事项的晨间简报。",morningRitualPromptPlaceholder:"回顾昨晚以来的消息,总结今天需要关注的事项,并发送优先行动计划。",eveningRitual:"晚间仪式",eveningRitualDescription:"包含成就和待办事项的晚间总结。",eveningRitualPromptPlaceholder:"总结今天完成的工作,记录待办事项,并建议明天的重点领域。"},Ort={restartButton:"重启 Fulcrum",restarting:"重启中...",restartDescription:"重新构建并重启 Fulcrum 服务器。如果构建失败,服务器将继续运行。",restartFailed:"重启失败",checkLogs:"构建可能失败。运行 journalctl --user -u fulcrum 查看详情。"},Rrt={label:"CalDAV",statusConnecting:"连接中...",statusConnected:"已连接({{count}} 个日历)",statusSyncing:"同步中...",statusError:"连接错误",statusDisconnected:"未连接",serverUrl:"服务器 URL",serverUrlPlaceholder:"https://cloud.example.com/remote.php/dav",username:"用户名",usernamePlaceholder:"输入用户名",password:"密码",passwordPlaceholder:"输入密码或应用专用密码",syncInterval:"同步间隔(分钟)",testButton:"测试连接",connectButton:"连接",cancelButton:"取消",syncButton:"立即同步",disconnectButton:"断开连接",testSuccess:"连接成功!找到 {{count}} 个日历。",testFailed:"连接失败",configured:"CalDAV 已配置并连接",configureFailed:"配置 CalDAV 失败",toggleFailed:"切换 CalDAV 失败",syncComplete:"日历已同步",syncFailed:"同步失败",disconnected:"CalDAV 已断开",disconnectFailed:"断开连接失败",fillRequired:"服务器 URL、用户名和密码为必填项",tabBasic:"CalDAV 服务器",tabGoogle:"Google 日历",googleClientId:"客户端 ID",googleClientIdPlaceholder:"your-app.apps.googleusercontent.com",googleClientSecret:"客户端密钥",googleClientSecretPlaceholder:"输入您的 Google OAuth 客户端密钥",connectGoogleButton:"连接 Google 日历",googleAuthStarted:"已在浏览器中打开 Google 授权。完成登录以连接。",googleSetupHelp:"设置 Google 日历集成:",googleStep1:"1. 前往 Google Cloud Console 创建项目(或选择现有项目)。",googleStep2:"2. 启用 CalDAV API:导航至 API 和服务 > 库,搜索 CalDAV API 并启用。",googleStep3:"3. 配置 OAuth 同意屏幕:前往 API 和服务 > OAuth 同意屏幕,将用户类型设为「外部」,填写必填字段。",googleStep4:"4. 在同意屏幕的「测试用户」部分添加您的 Google 邮箱(应用处于测试模式时必须添加)。",googleStep5:"5. 创建 OAuth 凭据:前往 API 和服务 > 凭据 > 创建凭据 > OAuth 客户端 ID。选择「Web 应用」,将 Fulcrum 回调 URL 添加为授权重定向 URI。",googleCallbackNote:"您的回调 URL:{{callbackUrl}}",googleStep6:"6. 将客户端 ID 和客户端密钥复制到上方字段,然后点击连接。",googleFillRequired:"客户端 ID 和客户端密钥为必填项",setupInstructions:"设置说明",helpIntro:"输入您的 CalDAV 服务器 URL 和凭据。常见服务器 URL:",helpNote:"如需使用 Google 日历,请使用 Google 日历选项卡进行 OAuth2 认证。",addAccount:"添加账户",accountName:"账户名称",accountNamePlaceholder:"我的 CalDAV 服务器",googleAccountNamePlaceholder:"Google 日历",disabled:"已禁用",deleteAccount:"删除",copyRules:"复制规则",addRule:"添加规则",copyRulesSource:"源日历",copyRulesDest:"目标日历",copyRulesSelectCalendar:"选择日历...",copyRulesSelectBoth:"请选择源日历和目标日历",copyRulesSameCalendar:"源日历和目标日历不能相同",copyRuleCreated:"复制规则已创建",copyRuleCreateFailed:"创建复制规则失败",copyRuleUpdateFailed:"更新复制规则失败",copyRuleDeleted:"复制规则已删除",copyRuleDeleteFailed:"删除复制规则失败",copyRuleExecuted:"已复制 {{created}} 个新事件,更新 {{updated}} 个事件",copyRuleExecuteFailed:"执行复制规则失败",copyRulesLastRun:"上次运行:{{date}}",copyRulesRunNow:"立即运行",copyRulesDelete:"删除",copyRulesEmpty:"未配置复制规则。添加规则以在日历之间同步事件。"},Irt={label:"IMAP 订阅",description:"将 IMAP 邮箱作为只读订阅源进行监控。收到的邮件会显示在消息时间线中,但不会发送回复。",disableButton:"停用邮箱",emailBackend:"邮箱后端"},Drt={title:"Google 账号",addAccount:"添加 Google 账号",accountName:"账号名称",nameRequired:"请输入账号名称",connect:"通过 Google 连接",connecting:"连接中...",accountAdded:"Google 账号已连接",accountDeleted:"Google 账号已删除",calendarSync:"日历同步",lastSync:"上次同步",gmail:"Gmail",sync:"同步",syncComplete:"日历同步完成",delete:"删除",calendarEnabled:"日历同步已启用",calendarDisabled:"日历同步已停用",gmailEnabled:"Gmail 已启用",gmailDisabled:"Gmail 已停用",noAccounts:"未配置 Google 账号。",noAccountsGmail:"未连接 Google 账号。",addInGeneral:"在常规设置中添加",oauthNote:"您将被重定向到 Google 以授权访问日历和 Gmail。",monitorInbox:"监控收件箱",sendAs:"发件人",sendAsPlaceholder:"you@gmail.com",sendAsUpdated:"发件人地址已更新",draftsOnly:"(仅草稿)",gmailDescription:"Gmail API 使用 OAuth2 — 无需应用密码。草稿创建后需人工审核后发送。",setupGuideTitle:"如何设置 Google OAuth 凭据",setupGuideStep1:"前往 <link>Google Cloud Console</link>",setupGuideStep2:"创建新项目(或选择已有项目)",setupGuideStep3:"启用 <strong>Google Calendar API</strong> 和 <strong>Gmail API</strong>",setupGuideStep4:"转到 <strong>API 和服务 → 凭据</strong>",setupGuideStep5:"创建 <strong>OAuth 2.0 客户端 ID</strong>(类型:Web 应用)",setupGuideStep6:"添加授权重定向 URI:<code>{{redirectUri}}</code>",setupGuideStep7:"将客户端 ID 和客户端密钥复制到下方字段中"},jrt={title:"未保存的更改",description:"您有未保存的更改,离开此页面将丢失这些更改。",stay:"留下",leave:"离开"},Prt={title:wrt,tabs:Ert,sections:Crt,version:krt,fields:Trt,notifications:Art,concierge:Nrt,developer:Ort,caldav:Rrt,imap:Irt,google:Drt,unsavedChanges:jrt},Lrt="审核",Mrt={pullRequests:"拉取请求",issues:"问题"},Frt={pr:{created:"我创建的",assigned:"分配给我的",reviewRequested:"待我审核",mentioned:"提及我的"},issue:{assigned:"分配给我的",created:"我创建的",mentioned:"提及我的"},allOrgs:"所有组织",allOrganizations:"所有组织",fulcrumReposOnly:"仅 Fulcrum 仓库"},Brt={tokenRequired:"需要 GitHub 令牌",tokenDescription:"要查看您的问题和拉取请求,请在设置中添加 GitHub 个人访问令牌。",requiredScopes:"所需权限:",scopes:{repo:"(用于私有仓库)",readUser:"(用于用户信息)",readOrg:"(用于组织列表)"},generateToken:"生成令牌",goToSettings:"前往设置"},$rt={loading:"加载中...",failedToLoad:"加载拉取请求失败",empty:{all:"没有打开的拉取请求",created:"没有您创建的拉取请求",assigned:"没有分配给您的拉取请求",reviewRequested:"没有等待您审核的拉取请求",mentioned:"没有提及您的拉取请求"},draft:"草稿"},zrt={loading:"加载中...",failedToLoad:"加载问题失败",empty:{assigned:"没有分配给您的问题",created:"没有您创建的问题",mentioned:"没有提及您的问题"}},Urt={title:Lrt,tabs:Mrt,filters:Frt,github:Brt,prs:$rt,issues:zrt},Hrt="工作树",Vrt={total:"共 {{count}} 个",orphaned:"{{count}} 个孤立"},Wrt={button:"清理 ({{count}})",title:"删除已完成的工作树",description:"这将永久删除 {{count}} 个工作树。",linkedTasksWillBeDeleted:"关联的任务也将被删除。",alsoDeleteLinkedTasks:"同时删除关联的任务",done:"已完成",canceled:"已取消",cannotUndo:"此操作无法撤销。",pinnedSkipped:"将跳过 {{count}} 个已固定的工作树"},qrt={pin:"固定工作树",unpin:"取消固定工作树"},Grt={noMatch:"没有匹配所选筛选条件的工作树。",noWorktrees:"未找到工作树。工作树在创建任务时自动生成。"},Krt={failedToLoad:"加载工作树失败:{{message}}"},Yrt={title:Hrt,summary:Vrt,cleanup:Wrt,delete:{title:"删除工作树",description:"这将永久删除位于以下位置的工作树目录",linkedTaskWillBeDeleted:'关联的任务 "{{title}}" 也将被删除。',alsoDeleteLinkedTask:'同时删除关联的任务 "{{title}}"',cannotUndo:"此操作无法撤销。",button:"删除 {{count}} 个",unpinFirst:"请先取消固定工作树再删除"},pin:qrt,empty:Grt,error:Krt},Xrt="监控",Qrt={claude:"AI 代理",system:"系统指标",processes:"进程",fulcrum:"Fulcrum 服务器",worktrees:"工作树",scratch:"临时目录",jobs:"作业",usage:"使用限额",assistant:"助手",messages:"消息",memory:"记忆",review:"审核",observer:"观察者"},Zrt={showAllInstances:"显示所有实例",instanceCount:"{{count}} 个实例运行中",totalRam:"总计 {{ram}} MB",headers:{agent:"代理",terminal:"终端",task:"任务",ram:"内存",actions:"操作",pid:"PID",workingDirectory:"工作目录",source:"来源"},noTask:"(无任务)",kill:"终止",killing:"终止中...",killSelected:"终止 {{count}} 个已选",source:{fulcrum:"Fulcrum: {{name}}",external:"外部"},empty:"没有 AI 代理实例运行中",emptyFulcrum:" (在 Fulcrum 终端中)",error:"加载 AI 代理实例失败:{{message}}"},Jrt={cpuUsage:"CPU 使用率",memoryUsage:"内存使用率",memoryLabels:{used:"已使用",cache:"缓存/缓冲区"},diskUsage:"磁盘使用率 ({{path}})",error:"加载系统指标失败:{{message}}",timeWindows:{"1m":"1 分钟","10m":"10 分钟","1h":"1 小时","3h":"3 小时","6h":"6 小时","12h":"12 小时","24h":"24 小时"}},eit={topProcesses:"热门进程",sortBy:{memory:"按内存",cpu:"按 CPU"},headers:{pid:"PID",name:"名称",command:"命令",memory:"内存"},empty:"未找到进程",error:"加载进程失败:{{message}}",containers:"容器",containersEmpty:"没有容器运行中",containersUnavailable:"Docker/Podman 不可用"},tit={description:"运行中的 Fulcrum 开发服务器",instanceCount:"{{count}} 个实例运行中",headers:{port:"端口",mode:"模式",directory:"目录",ram:"内存",actions:"操作"},mode:{dev:"开发",prod:"生产"},vite:"Vite",kill:"终止",killing:"终止中...",empty:"没有 Fulcrum 实例运行中",error:"加载 Fulcrum 实例失败:{{message}}"},nit={fiveHourBlock:"5小时配额",sevenDayRolling:"7天滚动配额",opusWeekly:"Opus 周配额",sonnetWeekly:"Sonnet 周配额",resetsIn:"{{time}}后重置",resetsAt:"{{time}}重置",weekProgress:"本周已过 {{percent}}%",unavailable:"Claude Code 使用数据不可用。请确保已登录 Claude Code。",error:"加载使用数据失败:{{message}}"},rit={sweeps:{title:"最近扫描",empty:"暂无扫描记录",hourly:"每小时",morningRitual:"早间例行",eveningRitual:"晚间例行",eventsProcessed:"{{count}} 个事件",tasksUpdated:"{{count}} 个任务",messagesSent:"{{count}} 条消息",stale:"过期"}},iit={title:"频道消息",search:"搜索...",empty:"未找到消息",channels:{all:"所有频道",total:"总计",email:"邮件",whatsapp:"WhatsApp",discord:"Discord",telegram:"Telegram",slack:"Slack"},direction:{all:"全部",incoming:"收到",outgoing:"发出"},labels:{from:"发件人:",to:"收件人:"}},sit={status:{healthy:"观察者正常",circuitOpen:"熔断器已打开",failures:"次失败"},stats:{total:"总处理数",successRate:"成功率",avgDuration:"平均耗时",tasksCreated:"已创建任务",memoriesStored:"已存储记忆",last24h:"最近24小时"},filters:{allChannels:"所有频道",allStatuses:"所有状态",allProviders:"所有提供者",completed:"已完成",failed:"失败",timeout:"超时",circuitOpen:"熔断器打开"},invocations:{title:"最近调用",empty:"暂无观察者调用记录"},actions:{createTask:"已创建任务",storeMemory:"已存储记忆"},details:{error:"错误",actions:"操作"}},ait={title:Xrt,tabs:Qrt,claude:Zrt,system:Jrt,processes:eit,fulcrum:tit,usage:nit,assistant:rit,messages:iit,observer:sit},oit="任务",lit="仓库",cit="新建终端",uit="全部项目",dit="选择仓库",fit="已选择 {{count}} 个",hit="最多选择6个仓库",pit="搜索仓库...",mit="未找到仓库",git="清除选择",bit="选择仓库以打开其工作区终端",yit="没有进行中的任务",vit={title:"编辑标签页",name:"名称",namePlaceholder:"标签页名称",directory:"目录",directoryPlaceholder:"选择目录...",clearDirectory:"清除目录",cancel:"取消",save:"保存"},xit={title:"新建标签页",create:"创建"},_it={taskTerminals:oit,repoTerminals:lit,newTerminal:cit,allProjects:uit,selectRepos:dit,reposSelected:fit,filterByRepo:hit,searchRepos:pit,noReposFound:mit,clearFilter:git,emptyRepos:bit,emptyTasks:yit,editTab:vit,newTab:xit},Sit="仓库",wit="共 {{count}} 个",Eit="搜索仓库...",Cit="新建任务",kit="任务",Tit="终端",Ait="编辑器",Nit="应用",Oit="应用",Rit="创建应用",Iit={title:"需要 Docker Compose",description:"要为部署创建应用,此仓库需要 Docker Compose 文件。",instructions:"请在仓库中创建 docker-compose.yml 文件。",close:"知道了"},Dit="设置",jit="添加仓库",Pit="扫描目录",Lit="在终端中打开",Mit="在 {{editor}} 中打开",Fit={openInVSCode:"在 VS Code 中打开"},Bit={title:"添加仓库",description:"从 URL 或本地路径添加 Git 仓库,或扫描目录。",tabs:{add:"添加",scan:"扫描",template:"从模板创建"},inputLabel:"仓库 URL 或路径",inputPlaceholder:"https://github.com/user/repo 或 /local/path",browse:"浏览...",cloneOptions:"克隆选项",targetDirectory:"克隆到目录",folderName:"文件夹名称",willCloneTo:"将克隆到",cloning:"正在克隆仓库...",adding:"添加中...",cloneFailed:"克隆仓库失败",createFailed:"添加仓库失败",cancel:"取消",add:"添加",retry:"重试",fields:{path:"仓库路径",pathPlaceholder:"选择仓库...",displayName:"显示名称",startupScript:"启动脚本",startupScriptPlaceholder:"npm install && npm run dev",startupScriptDescription:"创建工作树时在终端中运行的命令。",copyFiles:"复制文件",copyFilesPlaceholder:".env, config.local.json",copyFilesDescription:"用逗号分隔的 glob 模式,用于复制文件到新的工作树。"}},$it={title:"扫描目录中的仓库",description:"从目录中查找并添加多个 Git 仓库。",directoryLabel:"要扫描的目录",directoryPlaceholder:"输入目录路径",browse:"浏览...",scan:"扫描",foundRepos:"找到 {{count}} 个仓库",selectAll:"全选",selectNone:"取消全选",noReposFound:"此目录中未找到 Git 仓库。",alreadyAdded:"已添加",adding:"正在添加仓库...",scanFailed:"扫描目录失败",addFailed:"添加仓库失败",cancel:"取消",addSelected:"添加 {{count}} 个选中项"},zit={button:"新建项目",title:"创建新项目",back:"返回",next:"下一步",create:"创建项目",steps:{template:{description:"选择一个模板来创建您的项目。",sectionTitle:"Copier 模板",sectionDescription:"选择已保存的模板或输入 URL/路径。",learnMore:"了解更多",savedTemplates:"已保存的模板",selectTemplate:"选择模板...",or:"或",customUrl:"自定义模板 URL/路径"},questions:{title:"模板问题",description:"配置您的项目。",noQuestions:"此模板没有配置问题。"},output:{title:"输出位置",description:"选择项目创建位置。",projectName:"项目名称",outputDirectory:"输出目录",selectDirectory:"选择目录...",willCreate:"将创建",trust:"信任模板"},creating:{description:"正在创建您的项目...",inProgress:"正在运行 Copier..."}}},Uit={noRepositories:"尚未添加任何仓库。添加一个仓库以便在创建任务时快速访问。",noMatches:"没有匹配的仓库。"},Hit={failedToLoad:"加载仓库失败:{{message}}"},Vit={breadcrumb:"仓库",notFound:"仓库未找到",save:"保存",saving:"保存中...",saved:"仓库已保存",failedToSave:"保存仓库失败",tabs:{settings:"任务设置",workspace:"工作区"},mobileWorkspace:{terminal:"终端",files:"文件"},fileTree:{title:"文件",searchPlaceholder:"搜索文件...",noFiles:"无文件",collapseAll:"折叠所有文件夹"},settings:{generalTitle:"常规",agentTitle:"代理选项",displayName:"显示名称",defaultAgent:"默认代理",defaultAgentInherit:"使用全局默认",defaultAgentDescription:"覆盖从此仓库创建任务时使用的全局默认代理。",startupScript:"启动脚本",startupScriptPlaceholder:"npm install && npm run dev",startupScriptDescription:"创建工作树时在终端中运行的命令。",claudeOptions:"Claude Code 选项",claudeOptionsDescription:"启动任务时传递给 Claude Code 的命令行参数。",opencodeOptions:"OpenCode 选项",opencodeOptionsDescription:"启动任务时传递给 OpenCode 的命令行参数。",opencodeModel:"OpenCode 模型",opencodeModelPlaceholder:"选择模型",opencodeModelDescription:"从此仓库创建任务时使用的默认 OpenCode 模型。",agentOptionsFlag:"参数",agentOptionsValue:"值",addAgentOption:"添加选项",copyFiles:"复制文件",copyFilesPlaceholder:".env, config.local.json",copyFilesDescription:"用逗号分隔的 glob 模式,用于复制文件到新的工作树。",isCopierTemplate:"用作 Copier 模板",isCopierTemplateDescription:"标记为使用 Copier 创建新项目的模板。"},workspace:{connectingToTerminal:"正在连接终端服务器...",initializingTerminal:"正在初始化终端...",terminalConnectionFailed:"终端连接失败",recreateTerminal:"重新创建终端"}},Wit={title:Sit,total:wit,searchPlaceholder:Eit,newTask:Cit,viewTasks:kit,terminal:Tit,editor:Ait,application:Nit,applications:Oit,createApp:Rit,createAppDialog:Iit,settings:Dit,addRepository:jit,scanDirectory:Pit,openInTerminal:Lit,openInEditor:Mit,card:Fit,delete:{title:"删除仓库",description:'这将从 Fulcrum 中移除 "{{name}}"。实际的仓库文件不会受到影响。',button:"删除",deleting:"删除中...",alsoDeleteDirectory:"同时从磁盘删除目录",deleteDirectoryWarning:"这将永久删除仓库中的所有文件。此操作无法撤销。"},addModal:Bit,bulkAdd:$it,newProject:zit,empty:Uit,error:Hit,detailView:Vit},qit="项目",Git="共 {{count}} 个",Kit="搜索项目...",Yit="新建任务",Xit="添加仓库",Qit="关联仓库",Zit="返回项目列表",Jit="新建任务",est="项目未找到",tst="终端",nst="编辑器",rst="部署",ist="停止",sst="新建项目",ast={noProjects:"暂无项目。创建一个项目开始使用。",noMatches:"没有匹配的项目。"},ost={failedToLoad:"加载项目失败:{{message}}"},lst={noApp:"无应用",running:"运行中",building:"构建中",stopped:"已停止",failed:"失败"},cst={breadcrumb:"项目",notFound:"项目未找到",save:"保存",saving:"保存中...",tabs:{settings:"任务设置",workspace:"工作区",deploy:"部署",deployGeneral:"通用",deployments:"部署记录",logs:"日志",monitoring:"监控"},general:{repositoryTitle:"仓库",agentTitle:"代理选项",path:"路径",displayName:"显示名称",startupScript:"启动脚本",copyFiles:"复制文件",defaultAgent:"默认代理",claudeOptions:"Claude Code 选项",opencodeOptions:"OpenCode 选项",opencodeModel:"OpenCode 模型",noRepository:"该项目未关联仓库。"},app:{title:"应用配置",noApp:"该项目未配置应用。",configureDeployment:"配置部署",configureDeploymentDescription:"为此项目设置 Docker Compose 部署",configuring:"配置中...",deployOptions:"部署选项",autoDeployEnabled:"提交时自动部署",autoPortAllocation:"自动分配端口",noCacheBuild:"无缓存构建",notificationsEnabled:"部署通知",services:"服务",environment:"环境变量",composeFile:"Compose 文件"}},ust={step:"第 {{current}} 步,共 {{total}} 步",selectRepository:"选择仓库",existingRepo:"现有仓库",addNewRepo:"添加新仓库",searchRepos:"搜索仓库...",noReposFound:"未找到仓库",repoPathOrUrl:"仓库路径或 URL",repoInputPlaceholder:"~/code/my-repo 或 https://github.com/user/repo",browse:"浏览",cloneOptions:"克隆选项",targetDirectory:"目标目录",folderName:"文件夹名称",willCloneTo:"将克隆到",cloning:"正在克隆仓库...",adding:"正在添加仓库...",cloneAndSelect:"克隆并选择",addAndSelect:"添加并选择",addRepoFailed:"添加仓库失败",checkingCompose:"正在检查 compose 文件...",composeFound:"找到 {{file}}",noCompose:"未找到 compose 文件",cancel:"取消",next:"下一步",back:"上一步",configureProject:"配置项目",projectName:"项目名称",projectNamePlaceholder:"my-project",description:"描述",descriptionPlaceholder:"可选的项目描述",composeDetected:"检测到 Docker Compose:{{file}}",setupAppNow:"创建后设置应用部署",createProject:"创建项目",creating:"创建中...",create:"创建"},dst={all:"全部",hasApp:"有应用",noApp:"无应用",running:"运行中",archived:"已归档"},fst={summaryDefault:"默认",inherit:"继承",summaryClaudeOptions_one:"Claude: {{count}} 个选项",summaryClaudeOptions_other:"Claude: {{count}} 个选项",summaryOpencodeOptions_one:"OpenCode: {{count}} 个选项",summaryOpencodeOptions_other:"OpenCode: {{count}} 个选项",summaryModel:"模型",description:"配置此项目的默认代理设置。仓库可以覆盖这些设置。",useGlobalDefault:"使用全局默认"},hst={activeCount_one:"{{count}} 个进行中",activeCount_other:"{{count}} 个进行中",doneCount_one:"{{count}} 个已完成",doneCount_other:"{{count}} 个已完成"},pst={clickToEdit:"点击编辑",actions:{task:"任务",repo:"仓库",link:"链接"},sections:{repositories:"仓库",links:"链接",attachments:"附件",tags:"标签",notes:"备注",activeTasks:"进行中的任务"},addDescription:"添加描述...",save:"保存",edit:"编辑",done:"完成",add:"添加",cancel:"取消",noRepositories:"该项目未关联任何仓库。",linkExisting:"关联现有仓库",urlPlaceholder:"https://...",linkLabelPlaceholder:"标签(可选)",labelPlaceholder:"标签",removeLink:"移除链接",addLink:"添加链接",addTag:"添加标签...",loadingAttachments:"加载附件中...",uploading:"上传中...",dropOrClick:"拖放文件到此处或点击上传",dropOrClickShort:"拖放或点击",attachmentTypes:"PDF、图片、文档、压缩包(最大 10MB)",noAttachments:"暂无附件",noTags:"暂无标签",searchOrCreateTag:"搜索或创建标签...",createTag:'创建 "{{tag}}"',noMatchingTags:"无匹配的标签",addNotes:"添加项目备注...",noNotes:"暂无备注",noActiveTasks:"暂无进行中的任务",loading:"加载中..."},mst={title:qit,total:Git,searchPlaceholder:Kit,newTask:Yit,addRepo:Xit,linkRepo:Qit,backToProjects:Zit,createTask:Jit,notFound:est,terminal:tst,editor:nst,deploy:rst,stop:ist,newProjectButton:sst,empty:ast,error:ost,card:lst,delete:{title:"删除项目",description:"这将删除项目「{{name}}」。",confirmText:"确定要删除「{{name}}」吗?此操作无法撤销。",button:"删除",confirm:"删除",cancel:"取消",success:"项目已删除",error:"删除项目失败",deleting:"删除中...",reposWarning:"此项目有 {{count}} 个关联的仓库。删除项目将取消关联。",alsoDeleteDirectory:"同时删除目录",alsoDeleteApp:"同时删除应用并停止容器"},detailView:cst,newProject:ust,filter:dst,agentSettings:fst,repoCard:hst,detail:pst},gst="AI 助手",bst={clearConversation:"清除对话",connected:"已连接",aiAssistantResponse:"AI 助手回复"},yst={claude:"Claude",opencode:"OpenCode"},vst={selectModel:"选择模型",filterModels:"筛选模型...",noModelsMatch:'没有匹配 "{{filter}}" 的模型',opus:"Opus",opusDescription:"最强大",sonnet:"Sonnet",sonnetDescription:"均衡",haiku:"Haiku",haikuDescription:"最快"},xst={placeholder:"管理任务、项目、运行命令、部署应用... 问我任何问题!",askAnything:"问我任何问题...",shiftEnterHint:"按 <kbd>Shift + Enter</kbd> 换行"},_st={selectChat:"选择聊天",messages:"条消息",msgs:"条",rename:"重命名",delete:"删除",noChatsYet:"暂无聊天",newChat:"新建聊天",selectOrCreate:"选择或创建聊天开始对话",startConversation:"发送消息开始对话",thinking:"思考中"},Sst={tabs:{canvas:"画布",editor:"编辑器",documents:"文档",memory:"记忆"},empty:{title:"选择聊天以查看画布",description:"图表和可视化内容将显示在这里"},viewer:{empty:{title:"画布为空",description:"让助手显示图表、表格或可视化内容"}},editor:{title:"文档编辑器 - 使用 AI 辅助编写 Markdown",placeholder:"开始编写文档..."},documents:{empty:{title:"暂无文档",description:"AI 创建的文档将显示在这里"}},memory:{title:"主记忆文件",path:"~/.fulcrum/MEMORY.md",placeholder:`# 记忆
44
+ # 支持注释`,save:"保存环境变量",showValues:"显示值",hideValues:"隐藏值",unsavedChanges:"您有未保存的更改"},domains:{title:"域名配置",description:"配置要暴露的服务及其域名映射",expose:"暴露",exposeRequiresPort:"未配置端口。请在 compose 文件中添加端口映射。",domain:"域名",noDomain:"未配置域名",portRequired:"需要端口",editDomain:"编辑域名",noServices:"未配置服务。请先部署应用以查看可用服务。",save:"保存"},streaming:{pulling:"拉取代码...",building:"构建容器...",starting:"启动服务...",configuring:"配置路由...",done:"部署完成!",failed:"部署失败",cancelled:"部署已取消",preparing:"准备中...",waitingForLogs:"等待日志..."},dnsConfigRequired:"需要配置 DNS",settings:"设置",status:{running:"运行中",building:"构建中",failed:"失败",stopped:"已停止"},monitoring:{title:"资源使用",description:"每个服务的实时 CPU 和内存使用情况",cpu:"CPU",memory:"内存",noContainers:"未找到运行中的容器",dockerUnavailable:"Docker 统计不可用",serviceTotal:"服务总计"}},trt={weekly:"周视图",monthly:"月视图"},nrt={buttons:Wnt,status:qnt,time:Gnt,results:Knt,statuses:Ynt,auth:Xnt,git:Qnt,errors:Znt,opencode:Jnt,apps:ert,calendar:trt},rrt={tasks:"任务",projects:"项目",terminals:"终端",worktrees:"工作树",repositories:"仓库",apps:"应用",jobs:"作业",assistant:"助手",review:"审核",calendar:"日历",monitoring:"监控",settings:"设置",commandPalette:"命令面板 ({{shortcut}})",help:"文档"},irt={placeholder:"输入命令或搜索...",noResults:"未找到命令",categories:{navigation:"导航",actions:"操作"},commands:{goToTasks:"前往任务",goToProjects:"前往项目",goToTerminals:"前往终端",goToAssistant:"前往助手",goToTaskTerminals:"前往任务终端",goToProjectTerminals:"前往项目终端",goToRepositories:"前往仓库",goToApps:"前往应用",goToJobs:"前往作业",goToReview:"前往审核",goToCalendar:"前往日历",goToMonitoring:"前往监控",goToSettings:"前往设置",newTask:"新建任务",newProject:"新建项目",openInEditor:"在编辑器中打开",keyboardShortcuts:"键盘快捷键"}},srt={title:"键盘快捷键",groups:{navigation:"导航",actions:"操作",terminals:"终端(桌面端)",general:"通用"},labels:{goToTasks:"前往任务",goToProjects:"前往项目",goToTerminals:"前往终端",goToAssistant:"前往助手",goToTaskTerminals:"前往任务终端",goToProjectTerminals:"前往项目终端",goToRepositories:"前往仓库",goToApps:"前往应用",goToJobs:"前往作业",goToReview:"前往审核",goToCalendar:"前往日历",goToMonitoring:"前往监控",goToSettings:"前往设置",commandPalette:"命令面板",newTask:"新建任务",newProject:"新建项目",openInEditor:"在编辑器中打开",openAiAssistant:"打开AI助手",keyboardShortcuts:"键盘快捷键",closeModal:"关闭弹窗",newTerminal:"新建终端",closeTerminal:"关闭终端",submitForm:"提交表单"}},art={title:"在编辑器中打开",description:"在 {{editor}} 中打开文件夹",pathLabel:"目录路径",pathPlaceholder:"~/projects/my-project",pathHint:"请输入目录路径。支持 ~ 表示主目录。",pathNotFound:"路径不存在",pathNotDirectory:"路径必须是目录,不能是文件",browse:"浏览",cancel:"取消",open:"打开"},ort={header:rrt,commandPalette:irt,shortcuts:srt,openInEditor:art},lrt="任务",crt="搜索",urt="全部项目",drt="标签",frt="搜索标签...",hrt="未找到标签",prt="清除所有标签",mrt="搜索项目...",grt="未找到项目",brt={label:"类型",types:{worktree:"Git",scratch:"临时",manual:"手动"},clear:"清除筛选",showLabels:"显示任务类型标签"},yrt={label:"优先级",priorities:{high:"高",medium:"中",low:"低"},clear:"清除筛选"},vrt="新建任务",xrt={high:"高",medium:"中",low:"低"},_rt={title:"创建新任务",description:"创建一个带有 Git 工作树的新任务,用于隔离开发。",taskTypes:{worktree:"Git",manual:"手动",scratch:"临时"},taskDescriptions:{worktree:"创建 Git 工作树并打开 AI 编程代理。",manual:"无需 Git 工作树或 AI 代理的通用任务。",scratch:"创建一个带有 AI 编程代理的独立目录,无需 Git 仓库。"},fields:{title:"标题",titlePlaceholder:"添加用户认证",description:"描述",descriptionPlaceholder:"实现 OAuth2 登录流程...",aiMode:"AI 模式",agent:"AI 代理",opencodeModel:"OpenCode 模型",opencodeModelPlaceholder:"选择模型",repository:"仓库",baseBranch:"基础分支",prefix:"分支前缀",prefixPlaceholder:"例如 ENG-123",branchName:"分支名称",branchPlaceholder:"自动生成分支名",project:"项目(可选)",tags:"标签",tagsPlaceholder:"添加标签...",dueDate:"截止日期",dueDatePlaceholder:"设置日期",estimate:"预估时间",priority:"优先级",notes:"备注",notesPlaceholder:"添加备注...",links:"链接",urlPlaceholder:"https://...",linkLabelPlaceholder:"标签(可选)",prUrl:"GitHub PR",prUrlPlaceholder:"https://github.com/owner/repo/pull/123",attachments:"附件",addAttachments:"添加附件...",addMoreFiles:"添加更多文件...",blockedBy:"阻塞任务",repeat:"重复",recurrenceEndDate:"重复截止"},recurrence:{none:"无",daily:"每天",weekly:"每周",biweekly:"每两周",monthly:"每月",quarterly:"每季度",yearly:"每年",recurringSeriesNote:"属于重复系列任务"},aiModes:{plan:"计划",default:"默认"},tabs:{saved:"仓库",browse:"浏览"},worktreePrefix:"工作树:",prefixHint:"添加到分支名称前,用于关联工单。",branchAutoGenerated:'留空将使用 "{{branch}}"。',selectFolder:"选择文件夹...",searchRepositories:"搜索仓库...",noRepositoriesFound:"未找到仓库",selectRepositoryFirst:"请先选择仓库",loadingBranches:"加载分支中...",selectBranch:"选择分支",noBranchesFound:"未找到分支",current:"(当前)",createTask:"创建任务",noProject:"无项目(收件箱)",projectHint:"无项目的任务将显示在收件箱中。",blockedByHint:"必须完成才能开始此任务的前置任务。",blockedByPlaceholder:"搜索阻塞任务...",noTasksFound:"未找到任务",startImmediately:"立即开始工作",advanced:"高级",pinTask:"置顶任务",unpinTask:"取消置顶",errors:{notGitRepo:"所选文件夹不是 Git 仓库",validationFailed:"验证仓库失败",createFailed:"创建任务失败",invalidUrl:"无效的 URL",invalidUrlDescription:"请输入包含协议的有效 URL(例如:https://)"}},Srt={title:lrt,searchPlaceholder:crt,allProjects:urt,allTags:drt,searchTags:frt,noTagsFound:hrt,clearTags:prt,searchProjects:mrt,noProjectsFound:grt,typeFilter:brt,priorityFilter:yrt,newTask:vrt,priority:xrt,createModal:_rt},wrt="设置",Ert={general:"常规",ai:"AI 与开发",messaging:"邮件与消息",calendar:"日历"},Crt={server:"服务器",serverDefaults:"服务器与默认设置",paths:"路径",editor:"编辑器",integrations:"集成",zai:"z.ai",agent:"工作树代理",assistant:"AI 助手",tasks:"任务默认值",notifications:"通知",messaging:"消息",appearance:"外观",developer:"开发者",caldav:"日历集成"},krt={upToDate:"已是最新版本",updateAvailable:"有新版本: v{{version}}",checkingForUpdates:"检查中...",updateButton:"更新",update:"更新",updating:"更新中...",updateStarted:"更新已启动。服务器即将重启。",updateFailed:"更新失败。请重试或手动更新。",updateCommand:"运行以更新:",viewRelease:"查看版本",refresh:"检查更新"},Trt={port:{label:"端口",description:"需要重启"},startupCommand:{label:"启动命令",description:"新任务终端的命令"},gitReposDir:{label:"Git 仓库目录",description:"仓库选择器的起始目录"},editor:{app:{label:"编辑器",description:"用于打开工作树的代码编辑器",options:{vscode:"VS Code",cursor:"Cursor",windsurf:"Windsurf",zed:"Zed",antigravity:"Antigravity"}},host:{label:"远程主机",description:"代码在远程机器上时使用的 SSH 地址",placeholder:"例如:my-server.tailnet.ts.net"},sshPort:{label:"SSH 端口",description:"远程 SSH 端口(默认 22)"}},linear:{label:"Linear",description:"用于工单同步的 API 密钥"},github:{label:"GitHub",description:"用于 Issues 和 PR 的个人访问令牌"},cloudflare:{label:"Cloudflare",placeholder:"输入 API 令牌...",description:"用于自动 DNS 记录的 API 令牌"},zai:{enable:"启用",apiKey:"API 密钥",description:"配置 Claude Code 使用 z.ai 代理",modelMappings:"模型映射",haiku:"Haiku",sonnet:"Sonnet",opus:"Opus"},agent:{default:{label:"默认代理",description:"新任务使用的 AI 编码代理"},opencodeModel:{label:"OpenCode 模型",placeholder:"选择模型",description:"启动 OpenCode 任务时使用的默认模型"},advancedAgentNames:{label:"高级代理名称",description:"配置 OpenCode 模式的特定代理名称",warning:"仅在您知道自己在做什么的情况下更改这些设置。这些设置适用于拥有自定义 OpenCode 代理(例如,带有 Sisyphus/Planner-Sisyphus 代理的 oh-my-opencode 插件)的用户。"},opencodeDefaultAgent:{label:"默认模式",description:"全权限模式的代理名称。oh-my-opencode 使用 'Sisyphus',原版 OpenCode 使用 'build'。"},opencodePlanAgent:{label:"计划模式",description:"受限/计划模式的代理名称。oh-my-opencode 使用 'Planner-Sisyphus',原版 OpenCode 使用 'plan'。注意:Planner-Sisyphus 从 OpenCode 的 plan 代理配置继承模型,因此上述模型覆盖可能不适用。请在 ~/.config/opencode/oh-my-opencode.json 中配置模型。"},autoScrollToBottom:{label:"自动滚动到底部",description:"当有新输出时自动将终端滚动到底部"},claudeCodePath:{label:"Claude Code 路径",placeholder:"自动检测(留空)",description:"覆盖自动检测的 Claude Code 可执行文件路径。留空则从 PATH 或常见安装位置自动检测。"}},assistant:{provider:{label:"默认提供商",description:"助手对话使用的 AI 提供商"},model:{label:"Claude 模型",description:"AI 助手对话使用的 Claude 模型",options:{opus:"Opus(最强大)",sonnet:"Sonnet(平衡)",haiku:"Haiku(最快)"}},observerProvider:{label:"观察者提供商",description:"用于仅观察消息处理的 AI 提供商。仅观察消息(非自聊 WhatsApp、未授权邮件)使用受限工具访问以确保安全。",options:{default:"与主提供商相同"}},observerModel:{label:"观察者模型",description:"用于仅观察消息处理的 Claude 模型。使用更便宜的模型可降低成本。",options:{opus:"Opus(最强大)",sonnet:"Sonnet(平衡)",haiku:"Haiku(最快)"}},observerOpencodeModel:{label:"观察者 OpenCode 模型",description:"用于仅观察消息处理的 OpenCode 模型。未设置时回退到主 OpenCode 模型。",placeholder:"与主 OpenCode 模型相同"},opencodeModel:{label:"OpenCode 模型",description:"选择 OpenCode 作为提供商时使用的模型",placeholder:"选择模型"},customInstructions:{label:"记忆文件",openMemoryFile:"打开记忆文件",memoryDescription:"助手的持久指令和知识。存储在 ~/.fulcrum/MEMORY.md 中,包含在每次对话中。"},documentsDir:{label:"文档目录",description:"AI 生成的文档保存为 Markdown 文件的目录。"}},tasks:{defaultType:{label:"默认类型",description:"创建新任务时默认选择的类型",options:{worktree:"Git",manual:"手动",scratch:"临时"}},startImmediately:{label:"立即开始",description:"启用后,工作树任务会立即开始工作并创建 git 工作树。禁用后,任务会进入待办事项。"}},language:{label:"语言",description:"界面语言",options:{auto:"自动检测",en:"English",zh:"简体中文"}},theme:{label:"主题",description:"界面颜色主题",options:{system:"跟随系统",light:"浅色",dark:"深色"}},timezone:{label:"时区",description:"用于截止日期计算的时区。自动使用系统时区。",options:{auto:"自动(系统)"}}},Art={enable:"启用通知",toast:"应用内提示",toastDescription:"在 Fulcrum 界面中显示提示通知",desktop:"桌面通知",desktopDescription:"显示原生桌面或浏览器通知",sound:"声音",slack:"Slack",discord:"Discord",pushover:"Pushover",appToken:"应用令牌",userKey:"用户密钥",useMessagingChannel:"使用消息通道",whatsapp:"WhatsApp",telegram:"Telegram",messagingChannelRequired:"需要已连接的消息通道",messagingChannelNote:"通过已连接的消息通道发送",gmail:"Gmail",gmailDescription:"向您自己的 Gmail 地址发送通知邮件",gmailAutoResolve:"自动选择",gmailNoAccounts:"未配置启用 Gmail 的 Google 账号",testSuccess:"{{channel}} 测试成功",testFailed:"{{channel}} 测试失败:{{error}}",uploadSound:"上传自定义声音",deleteSound:"删除自定义声音",testSound:"测试声音",soundUploaded:"自定义声音已上传",soundUploadFailed:"上传声音失败:{{error}}",soundDeleted:"自定义声音已删除",soundDeleteFailed:"删除自定义声音失败",customSoundActive:"使用自定义声音"},Nrt={rituals:"每日仪式",ritualsDescription:"设置晨间和晚间简报的时间。助手将在指定时间执行您的提示词。",morningRitual:"晨间仪式",morningRitualDescription:"包含今日优先事项的晨间简报。",morningRitualPromptPlaceholder:"回顾昨晚以来的消息,总结今天需要关注的事项,并发送优先行动计划。",eveningRitual:"晚间仪式",eveningRitualDescription:"包含成就和待办事项的晚间总结。",eveningRitualPromptPlaceholder:"总结今天完成的工作,记录待办事项,并建议明天的重点领域。"},Ort={restartButton:"重启 Fulcrum",restarting:"重启中...",restartDescription:"重新构建并重启 Fulcrum 服务器。如果构建失败,服务器将继续运行。",restartFailed:"重启失败",checkLogs:"构建可能失败。运行 journalctl --user -u fulcrum 查看详情。"},Rrt={label:"CalDAV",statusConnecting:"连接中...",statusConnected:"已连接({{count}} 个日历)",statusSyncing:"同步中...",statusError:"连接错误",statusDisconnected:"未连接",serverUrl:"服务器 URL",serverUrlPlaceholder:"https://cloud.example.com/remote.php/dav",username:"用户名",usernamePlaceholder:"输入用户名",password:"密码",passwordPlaceholder:"输入密码或应用专用密码",syncInterval:"同步间隔(分钟)",testButton:"测试连接",connectButton:"连接",cancelButton:"取消",syncButton:"立即同步",disconnectButton:"断开连接",testSuccess:"连接成功!找到 {{count}} 个日历。",testFailed:"连接失败",configured:"CalDAV 已配置并连接",configureFailed:"配置 CalDAV 失败",toggleFailed:"切换 CalDAV 失败",syncComplete:"日历已同步",syncFailed:"同步失败",disconnected:"CalDAV 已断开",disconnectFailed:"断开连接失败",fillRequired:"服务器 URL、用户名和密码为必填项",tabBasic:"CalDAV 服务器",tabGoogle:"Google 日历",googleClientId:"客户端 ID",googleClientIdPlaceholder:"your-app.apps.googleusercontent.com",googleClientSecret:"客户端密钥",googleClientSecretPlaceholder:"输入您的 Google OAuth 客户端密钥",connectGoogleButton:"连接 Google 日历",googleAuthStarted:"已在浏览器中打开 Google 授权。完成登录以连接。",googleSetupHelp:"设置 Google 日历集成:",googleStep1:"1. 前往 Google Cloud Console 创建项目(或选择现有项目)。",googleStep2:"2. 启用 CalDAV API:导航至 API 和服务 > 库,搜索 CalDAV API 并启用。",googleStep3:"3. 配置 OAuth 同意屏幕:前往 API 和服务 > OAuth 同意屏幕,将用户类型设为「外部」,填写必填字段。",googleStep4:"4. 在同意屏幕的「测试用户」部分添加您的 Google 邮箱(应用处于测试模式时必须添加)。",googleStep5:"5. 创建 OAuth 凭据:前往 API 和服务 > 凭据 > 创建凭据 > OAuth 客户端 ID。选择「Web 应用」,将 Fulcrum 回调 URL 添加为授权重定向 URI。",googleCallbackNote:"您的回调 URL:{{callbackUrl}}",googleStep6:"6. 将客户端 ID 和客户端密钥复制到上方字段,然后点击连接。",googleFillRequired:"客户端 ID 和客户端密钥为必填项",setupInstructions:"设置说明",helpIntro:"输入您的 CalDAV 服务器 URL 和凭据。常见服务器 URL:",helpNote:"如需使用 Google 日历,请使用 Google 日历选项卡进行 OAuth2 认证。",addAccount:"添加账户",accountName:"账户名称",accountNamePlaceholder:"我的 CalDAV 服务器",googleAccountNamePlaceholder:"Google 日历",disabled:"已禁用",deleteAccount:"删除",copyRules:"复制规则",addRule:"添加规则",copyRulesSource:"源日历",copyRulesDest:"目标日历",copyRulesSelectCalendar:"选择日历...",copyRulesSelectBoth:"请选择源日历和目标日历",copyRulesSameCalendar:"源日历和目标日历不能相同",copyRuleCreated:"复制规则已创建",copyRuleCreateFailed:"创建复制规则失败",copyRuleUpdateFailed:"更新复制规则失败",copyRuleDeleted:"复制规则已删除",copyRuleDeleteFailed:"删除复制规则失败",copyRuleExecuted:"已复制 {{created}} 个新事件,更新 {{updated}} 个事件",copyRuleExecuteFailed:"执行复制规则失败",copyRulesLastRun:"上次运行:{{date}}",copyRulesRunNow:"立即运行",copyRulesDelete:"删除",copyRulesEmpty:"未配置复制规则。添加规则以在日历之间同步事件。"},Irt={label:"IMAP 订阅",description:"将 IMAP 邮箱作为只读订阅源进行监控。收到的邮件会显示在消息时间线中,但不会发送回复。",disableButton:"停用邮箱",emailBackend:"邮箱后端"},Drt={title:"Google 账号",addAccount:"添加 Google 账号",accountName:"账号名称",nameRequired:"请输入账号名称",connect:"通过 Google 连接",connecting:"连接中...",accountAdded:"Google 账号已连接",accountDeleted:"Google 账号已删除",calendarSync:"日历同步",lastSync:"上次同步",gmail:"Gmail",sync:"同步",syncComplete:"日历同步完成",delete:"删除",calendarEnabled:"日历同步已启用",calendarDisabled:"日历同步已停用",gmailEnabled:"Gmail 已启用",gmailDisabled:"Gmail 已停用",noAccounts:"未配置 Google 账号。",noAccountsGmail:"未连接 Google 账号。",addInGeneral:"在常规设置中添加",oauthNote:"您将被重定向到 Google 以授权访问日历和 Gmail。",monitorInbox:"监控收件箱",sendAs:"发件人",sendAsPlaceholder:"you@gmail.com",sendAsUpdated:"发件人地址已更新",draftsOnly:"(仅草稿)",gmailDescription:"Gmail API 使用 OAuth2 — 无需应用密码。草稿创建后需人工审核后发送。",setupGuideTitle:"如何设置 Google OAuth 凭据",setupGuideStep1:"前往 <link>Google Cloud Console</link>",setupGuideStep2:"创建新项目(或选择已有项目)",setupGuideStep3:"启用 <strong>Google Calendar API</strong> 和 <strong>Gmail API</strong>",setupGuideStep4:"转到 <strong>API 和服务 → 凭据</strong>",setupGuideStep5:"创建 <strong>OAuth 2.0 客户端 ID</strong>(类型:Web 应用)",setupGuideStep6:"添加授权重定向 URI:<code>{{redirectUri}}</code>",setupGuideStep7:"将客户端 ID 和客户端密钥复制到下方字段中"},jrt={title:"未保存的更改",description:"您有未保存的更改,离开此页面将丢失这些更改。",stay:"留下",leave:"离开"},Prt={title:wrt,tabs:Ert,sections:Crt,version:krt,fields:Trt,notifications:Art,concierge:Nrt,developer:Ort,caldav:Rrt,imap:Irt,google:Drt,unsavedChanges:jrt},Lrt="审核",Mrt={pullRequests:"拉取请求",issues:"问题"},Frt={pr:{created:"我创建的",assigned:"分配给我的",reviewRequested:"待我审核",mentioned:"提及我的"},issue:{assigned:"分配给我的",created:"我创建的",mentioned:"提及我的"},allOrgs:"所有组织",allOrganizations:"所有组织",fulcrumReposOnly:"仅 Fulcrum 仓库"},Brt={tokenRequired:"需要 GitHub 令牌",tokenDescription:"要查看您的问题和拉取请求,请在设置中添加 GitHub 个人访问令牌。",requiredScopes:"所需权限:",scopes:{repo:"(用于私有仓库)",readUser:"(用于用户信息)",readOrg:"(用于组织列表)"},generateToken:"生成令牌",goToSettings:"前往设置"},$rt={loading:"加载中...",failedToLoad:"加载拉取请求失败",empty:{all:"没有打开的拉取请求",created:"没有您创建的拉取请求",assigned:"没有分配给您的拉取请求",reviewRequested:"没有等待您审核的拉取请求",mentioned:"没有提及您的拉取请求"},draft:"草稿"},zrt={loading:"加载中...",failedToLoad:"加载问题失败",empty:{assigned:"没有分配给您的问题",created:"没有您创建的问题",mentioned:"没有提及您的问题"}},Urt={title:Lrt,tabs:Mrt,filters:Frt,github:Brt,prs:$rt,issues:zrt},Hrt="工作树",Vrt={total:"共 {{count}} 个",orphaned:"{{count}} 个孤立"},Wrt={button:"清理 ({{count}})",title:"删除已完成的工作树",description:"这将永久删除 {{count}} 个工作树。",linkedTasksWillBeDeleted:"关联的任务也将被删除。",alsoDeleteLinkedTasks:"同时删除关联的任务",done:"已完成",canceled:"已取消",cannotUndo:"此操作无法撤销。",pinnedSkipped:"将跳过 {{count}} 个已固定的工作树"},qrt={pin:"固定工作树",unpin:"取消固定工作树"},Grt={noMatch:"没有匹配所选筛选条件的工作树。",noWorktrees:"未找到工作树。工作树在创建任务时自动生成。"},Krt={failedToLoad:"加载工作树失败:{{message}}"},Yrt={title:Hrt,summary:Vrt,cleanup:Wrt,delete:{title:"删除工作树",description:"这将永久删除位于以下位置的工作树目录",linkedTaskWillBeDeleted:'关联的任务 "{{title}}" 也将被删除。',alsoDeleteLinkedTask:'同时删除关联的任务 "{{title}}"',cannotUndo:"此操作无法撤销。",button:"删除 {{count}} 个",unpinFirst:"请先取消固定工作树再删除"},pin:qrt,empty:Grt,error:Krt},Xrt="监控",Qrt={claude:"AI 代理",system:"系统指标",processes:"进程",fulcrum:"Fulcrum 服务器",worktrees:"工作树",scratch:"临时目录",jobs:"作业",usage:"使用限额",assistant:"助手",messages:"消息",memory:"记忆",review:"审核",observer:"观察者"},Zrt={showAllInstances:"显示所有实例",instanceCount:"{{count}} 个实例运行中",totalRam:"总计 {{ram}} MB",headers:{agent:"代理",terminal:"终端",task:"任务",ram:"内存",actions:"操作",pid:"PID",workingDirectory:"工作目录",source:"来源"},noTask:"(无任务)",kill:"终止",killing:"终止中...",killSelected:"终止 {{count}} 个已选",source:{fulcrum:"Fulcrum: {{name}}",external:"外部"},empty:"没有 AI 代理实例运行中",emptyFulcrum:" (在 Fulcrum 终端中)",error:"加载 AI 代理实例失败:{{message}}"},Jrt={cpuUsage:"CPU 使用率",memoryUsage:"内存使用率",memoryLabels:{used:"已使用",cache:"缓存/缓冲区"},diskUsage:"磁盘使用率 ({{path}})",error:"加载系统指标失败:{{message}}",timeWindows:{"1m":"1 分钟","10m":"10 分钟","1h":"1 小时","3h":"3 小时","6h":"6 小时","12h":"12 小时","24h":"24 小时"}},eit={topProcesses:"热门进程",sortBy:{memory:"按内存",cpu:"按 CPU"},headers:{pid:"PID",name:"名称",command:"命令",memory:"内存"},empty:"未找到进程",error:"加载进程失败:{{message}}",containers:"容器",containersEmpty:"没有容器运行中",containersUnavailable:"Docker/Podman 不可用"},tit={description:"运行中的 Fulcrum 开发服务器",instanceCount:"{{count}} 个实例运行中",headers:{port:"端口",mode:"模式",directory:"目录",ram:"内存",actions:"操作"},mode:{dev:"开发",prod:"生产"},vite:"Vite",kill:"终止",killing:"终止中...",empty:"没有 Fulcrum 实例运行中",error:"加载 Fulcrum 实例失败:{{message}}"},nit={fiveHourBlock:"5小时配额",sevenDayRolling:"7天滚动配额",opusWeekly:"Opus 周配额",sonnetWeekly:"Sonnet 周配额",resetsIn:"{{time}}后重置",resetsAt:"{{time}}重置",weekProgress:"本周已过 {{percent}}%",unavailable:"Claude Code 使用数据不可用。请确保已登录 Claude Code。",error:"加载使用数据失败:{{message}}"},rit={sweeps:{title:"最近扫描",empty:"暂无扫描记录",hourly:"每小时",morningRitual:"早间例行",eveningRitual:"晚间例行",eventsProcessed:"{{count}} 个事件",tasksUpdated:"{{count}} 个任务",messagesSent:"{{count}} 条消息",stale:"过期"}},iit={title:"频道消息",search:"搜索...",empty:"未找到消息",channels:{all:"所有频道",total:"总计",email:"邮件",whatsapp:"WhatsApp",discord:"Discord",telegram:"Telegram",slack:"Slack"},direction:{all:"全部",incoming:"收到",outgoing:"发出"},labels:{from:"发件人:",to:"收件人:"}},sit={status:{healthy:"观察者正常",circuitOpen:"熔断器已打开",failures:"次失败"},stats:{total:"总处理数",successRate:"成功率",avgDuration:"平均耗时",tasksCreated:"已创建任务",memoriesStored:"已存储记忆",last24h:"最近24小时"},filters:{allChannels:"所有频道",allStatuses:"所有状态",allProviders:"所有提供者",completed:"已完成",failed:"失败",timeout:"超时",circuitOpen:"熔断器打开"},invocations:{title:"最近调用",empty:"暂无观察者调用记录"},actions:{createTask:"已创建任务",storeMemory:"已存储记忆"},details:{error:"错误",actions:"操作"}},ait={title:Xrt,tabs:Qrt,claude:Zrt,system:Jrt,processes:eit,fulcrum:tit,usage:nit,assistant:rit,messages:iit,observer:sit},oit="任务",lit="仓库",cit="新建终端",uit="全部项目",dit="选择仓库",fit="已选择 {{count}} 个",hit="最多选择6个仓库",pit="搜索仓库...",mit="未找到仓库",git="清除选择",bit="选择仓库以打开其工作区终端",yit="没有进行中的任务",vit={title:"编辑标签页",name:"名称",namePlaceholder:"标签页名称",directory:"目录",directoryPlaceholder:"选择目录...",clearDirectory:"清除目录",cancel:"取消",save:"保存"},xit={title:"新建标签页",create:"创建"},_it={taskTerminals:oit,repoTerminals:lit,newTerminal:cit,allProjects:uit,selectRepos:dit,reposSelected:fit,filterByRepo:hit,searchRepos:pit,noReposFound:mit,clearFilter:git,emptyRepos:bit,emptyTasks:yit,editTab:vit,newTab:xit},Sit="仓库",wit="共 {{count}} 个",Eit="搜索仓库...",Cit="新建任务",kit="任务",Tit="终端",Ait="编辑器",Nit="应用",Oit="应用",Rit="创建应用",Iit={title:"需要 Docker Compose",description:"要为部署创建应用,此仓库需要 Docker Compose 文件。",instructions:"请在仓库中创建 docker-compose.yml 文件。",close:"知道了"},Dit="设置",jit="添加仓库",Pit="扫描目录",Lit="在终端中打开",Mit="在 {{editor}} 中打开",Fit={openInVSCode:"在 VS Code 中打开"},Bit={title:"添加仓库",description:"从 URL 或本地路径添加 Git 仓库,或扫描目录。",tabs:{add:"添加",scan:"扫描",template:"从模板创建"},inputLabel:"仓库 URL 或路径",inputPlaceholder:"https://github.com/user/repo 或 /local/path",browse:"浏览...",cloneOptions:"克隆选项",targetDirectory:"克隆到目录",folderName:"文件夹名称",willCloneTo:"将克隆到",cloning:"正在克隆仓库...",adding:"添加中...",cloneFailed:"克隆仓库失败",createFailed:"添加仓库失败",cancel:"取消",add:"添加",retry:"重试",fields:{path:"仓库路径",pathPlaceholder:"选择仓库...",displayName:"显示名称",startupScript:"启动脚本",startupScriptPlaceholder:"npm install && npm run dev",startupScriptDescription:"创建工作树时在终端中运行的命令。",copyFiles:"复制文件",copyFilesPlaceholder:".env, config.local.json",copyFilesDescription:"用逗号分隔的 glob 模式,用于复制文件到新的工作树。"}},$it={title:"扫描目录中的仓库",description:"从目录中查找并添加多个 Git 仓库。",directoryLabel:"要扫描的目录",directoryPlaceholder:"输入目录路径",browse:"浏览...",scan:"扫描",foundRepos:"找到 {{count}} 个仓库",selectAll:"全选",selectNone:"取消全选",noReposFound:"此目录中未找到 Git 仓库。",alreadyAdded:"已添加",adding:"正在添加仓库...",scanFailed:"扫描目录失败",addFailed:"添加仓库失败",cancel:"取消",addSelected:"添加 {{count}} 个选中项"},zit={button:"新建项目",title:"创建新项目",back:"返回",next:"下一步",create:"创建项目",steps:{template:{description:"选择一个模板来创建您的项目。",sectionTitle:"Copier 模板",sectionDescription:"选择已保存的模板或输入 URL/路径。",learnMore:"了解更多",savedTemplates:"已保存的模板",selectTemplate:"选择模板...",or:"或",customUrl:"自定义模板 URL/路径"},questions:{title:"模板问题",description:"配置您的项目。",noQuestions:"此模板没有配置问题。"},output:{title:"输出位置",description:"选择项目创建位置。",projectName:"项目名称",outputDirectory:"输出目录",selectDirectory:"选择目录...",willCreate:"将创建",trust:"信任模板"},creating:{description:"正在创建您的项目...",inProgress:"正在运行 Copier..."}}},Uit={noRepositories:"尚未添加任何仓库。添加一个仓库以便在创建任务时快速访问。",noMatches:"没有匹配的仓库。"},Hit={failedToLoad:"加载仓库失败:{{message}}"},Vit={breadcrumb:"仓库",notFound:"仓库未找到",save:"保存",saving:"保存中...",saved:"仓库已保存",failedToSave:"保存仓库失败",tabs:{settings:"任务设置",workspace:"工作区"},mobileWorkspace:{terminal:"终端",files:"文件"},fileTree:{title:"文件",searchPlaceholder:"搜索文件...",noFiles:"无文件",collapseAll:"折叠所有文件夹"},settings:{generalTitle:"常规",agentTitle:"代理选项",displayName:"显示名称",defaultAgent:"默认代理",defaultAgentInherit:"使用全局默认",defaultAgentDescription:"覆盖从此仓库创建任务时使用的全局默认代理。",startupScript:"启动脚本",startupScriptPlaceholder:"npm install && npm run dev",startupScriptDescription:"创建工作树时在终端中运行的命令。",claudeOptions:"Claude Code 选项",claudeOptionsDescription:"启动任务时传递给 Claude Code 的命令行参数。",opencodeOptions:"OpenCode 选项",opencodeOptionsDescription:"启动任务时传递给 OpenCode 的命令行参数。",opencodeModel:"OpenCode 模型",opencodeModelPlaceholder:"选择模型",opencodeModelDescription:"从此仓库创建任务时使用的默认 OpenCode 模型。",agentOptionsFlag:"参数",agentOptionsValue:"值",addAgentOption:"添加选项",copyFiles:"复制文件",copyFilesPlaceholder:".env, config.local.json",copyFilesDescription:"用逗号分隔的 glob 模式,用于复制文件到新的工作树。",isCopierTemplate:"用作 Copier 模板",isCopierTemplateDescription:"标记为使用 Copier 创建新项目的模板。"},workspace:{connectingToTerminal:"正在连接终端服务器...",initializingTerminal:"正在初始化终端...",terminalConnectionFailed:"终端连接失败",recreateTerminal:"重新创建终端"}},Wit={title:Sit,total:wit,searchPlaceholder:Eit,newTask:Cit,viewTasks:kit,terminal:Tit,editor:Ait,application:Nit,applications:Oit,createApp:Rit,createAppDialog:Iit,settings:Dit,addRepository:jit,scanDirectory:Pit,openInTerminal:Lit,openInEditor:Mit,card:Fit,delete:{title:"删除仓库",description:'这将从 Fulcrum 中移除 "{{name}}"。实际的仓库文件不会受到影响。',button:"删除",deleting:"删除中...",alsoDeleteDirectory:"同时从磁盘删除目录",deleteDirectoryWarning:"这将永久删除仓库中的所有文件。此操作无法撤销。"},addModal:Bit,bulkAdd:$it,newProject:zit,empty:Uit,error:Hit,detailView:Vit},qit="项目",Git="共 {{count}} 个",Kit="搜索项目...",Yit="新建任务",Xit="添加仓库",Qit="关联仓库",Zit="返回项目列表",Jit="新建任务",est="项目未找到",tst="终端",nst="编辑器",rst="部署",ist="停止",sst="新建项目",ast={noProjects:"暂无项目。创建一个项目开始使用。",noMatches:"没有匹配的项目。"},ost={failedToLoad:"加载项目失败:{{message}}"},lst={noApp:"无应用",running:"运行中",building:"构建中",stopped:"已停止",failed:"失败"},cst={breadcrumb:"项目",notFound:"项目未找到",save:"保存",saving:"保存中...",tabs:{settings:"任务设置",workspace:"工作区",deploy:"部署",deployGeneral:"通用",deployments:"部署记录",logs:"日志",monitoring:"监控"},general:{repositoryTitle:"仓库",agentTitle:"代理选项",path:"路径",displayName:"显示名称",startupScript:"启动脚本",copyFiles:"复制文件",defaultAgent:"默认代理",claudeOptions:"Claude Code 选项",opencodeOptions:"OpenCode 选项",opencodeModel:"OpenCode 模型",noRepository:"该项目未关联仓库。"},app:{title:"应用配置",noApp:"该项目未配置应用。",configureDeployment:"配置部署",configureDeploymentDescription:"为此项目设置 Docker Compose 部署",configuring:"配置中...",deployOptions:"部署选项",autoDeployEnabled:"提交时自动部署",autoPortAllocation:"自动分配端口",noCacheBuild:"无缓存构建",notificationsEnabled:"部署通知",services:"服务",environment:"环境变量",composeFile:"Compose 文件"}},ust={step:"第 {{current}} 步,共 {{total}} 步",selectRepository:"选择仓库",existingRepo:"现有仓库",addNewRepo:"添加新仓库",searchRepos:"搜索仓库...",noReposFound:"未找到仓库",repoPathOrUrl:"仓库路径或 URL",repoInputPlaceholder:"~/code/my-repo 或 https://github.com/user/repo",browse:"浏览",cloneOptions:"克隆选项",targetDirectory:"目标目录",folderName:"文件夹名称",willCloneTo:"将克隆到",cloning:"正在克隆仓库...",adding:"正在添加仓库...",cloneAndSelect:"克隆并选择",addAndSelect:"添加并选择",addRepoFailed:"添加仓库失败",checkingCompose:"正在检查 compose 文件...",composeFound:"找到 {{file}}",noCompose:"未找到 compose 文件",cancel:"取消",next:"下一步",back:"上一步",configureProject:"配置项目",projectName:"项目名称",projectNamePlaceholder:"my-project",description:"描述",descriptionPlaceholder:"可选的项目描述",composeDetected:"检测到 Docker Compose:{{file}}",setupAppNow:"创建后设置应用部署",createProject:"创建项目",creating:"创建中...",create:"创建"},dst={all:"全部",hasApp:"有应用",noApp:"无应用",running:"运行中",archived:"已归档"},fst={summaryDefault:"默认",inherit:"继承",summaryClaudeOptions_one:"Claude: {{count}} 个选项",summaryClaudeOptions_other:"Claude: {{count}} 个选项",summaryOpencodeOptions_one:"OpenCode: {{count}} 个选项",summaryOpencodeOptions_other:"OpenCode: {{count}} 个选项",summaryModel:"模型",description:"配置此项目的默认代理设置。仓库可以覆盖这些设置。",useGlobalDefault:"使用全局默认"},hst={activeCount_one:"{{count}} 个进行中",activeCount_other:"{{count}} 个进行中",doneCount_one:"{{count}} 个已完成",doneCount_other:"{{count}} 个已完成"},pst={clickToEdit:"点击编辑",actions:{task:"任务",repo:"仓库",link:"链接"},sections:{repositories:"仓库",links:"链接",attachments:"附件",tags:"标签",notes:"备注",activeTasks:"进行中的任务"},addDescription:"添加描述...",save:"保存",edit:"编辑",done:"完成",add:"添加",cancel:"取消",noRepositories:"该项目未关联任何仓库。",linkExisting:"关联现有仓库",urlPlaceholder:"https://...",linkLabelPlaceholder:"标签(可选)",labelPlaceholder:"标签",removeLink:"移除链接",addLink:"添加链接",addTag:"添加标签...",loadingAttachments:"加载附件中...",uploading:"上传中...",dropOrClick:"拖放文件到此处或点击上传",dropOrClickShort:"拖放或点击",attachmentTypes:"任何文件(最大 10MB)",noAttachments:"暂无附件",noTags:"暂无标签",searchOrCreateTag:"搜索或创建标签...",createTag:'创建 "{{tag}}"',noMatchingTags:"无匹配的标签",addNotes:"添加项目备注...",noNotes:"暂无备注",noActiveTasks:"暂无进行中的任务",loading:"加载中..."},mst={title:qit,total:Git,searchPlaceholder:Kit,newTask:Yit,addRepo:Xit,linkRepo:Qit,backToProjects:Zit,createTask:Jit,notFound:est,terminal:tst,editor:nst,deploy:rst,stop:ist,newProjectButton:sst,empty:ast,error:ost,card:lst,delete:{title:"删除项目",description:"这将删除项目「{{name}}」。",confirmText:"确定要删除「{{name}}」吗?此操作无法撤销。",button:"删除",confirm:"删除",cancel:"取消",success:"项目已删除",error:"删除项目失败",deleting:"删除中...",reposWarning:"此项目有 {{count}} 个关联的仓库。删除项目将取消关联。",alsoDeleteDirectory:"同时删除目录",alsoDeleteApp:"同时删除应用并停止容器"},detailView:cst,newProject:ust,filter:dst,agentSettings:fst,repoCard:hst,detail:pst},gst="AI 助手",bst={clearConversation:"清除对话",connected:"已连接",aiAssistantResponse:"AI 助手回复"},yst={claude:"Claude",opencode:"OpenCode"},vst={selectModel:"选择模型",filterModels:"筛选模型...",noModelsMatch:'没有匹配 "{{filter}}" 的模型',opus:"Opus",opusDescription:"最强大",sonnet:"Sonnet",sonnetDescription:"均衡",haiku:"Haiku",haikuDescription:"最快"},xst={placeholder:"管理任务、项目、运行命令、部署应用... 问我任何问题!",askAnything:"问我任何问题...",shiftEnterHint:"按 <kbd>Shift + Enter</kbd> 换行"},_st={selectChat:"选择聊天",messages:"条消息",msgs:"条",rename:"重命名",delete:"删除",noChatsYet:"暂无聊天",newChat:"新建聊天",selectOrCreate:"选择或创建聊天开始对话",startConversation:"发送消息开始对话",thinking:"思考中"},Sst={tabs:{canvas:"画布",editor:"编辑器",documents:"文档",memory:"记忆"},empty:{title:"选择聊天以查看画布",description:"图表和可视化内容将显示在这里"},viewer:{empty:{title:"画布为空",description:"让助手显示图表、表格或可视化内容"}},editor:{title:"文档编辑器 - 使用 AI 辅助编写 Markdown",placeholder:"开始编写文档..."},documents:{empty:{title:"暂无文档",description:"AI 创建的文档将显示在这里"}},memory:{title:"主记忆文件",path:"~/.fulcrum/MEMORY.md",placeholder:`# 记忆
45
45
 
46
46
  助手会在了解你的过程中将持久知识存储在这里。
47
47
  你也可以直接编辑此文件。
@@ -134,7 +134,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
134
134
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function rNe(e){return __t(e)||S_t(e)||XAe(e)||w_t()}function Gy(e){var t=null;return function(){if(!t){for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];var a=e.apply(this,i);t={result:a}}return t.result}}var E_t=Gy(function(){return navigator.userAgent.includes("Firefox")}),ok=Gy(function(){var t=navigator,n=t.userAgent;return n.includes("AppleWebKit")&&!n.includes("Chrome")}),Gz={isLeavingWindow:Symbol("leaving"),isEnteringWindow:Symbol("entering")};function C_t(e){var t=e.dragLeave;return ok()?t.hasOwnProperty(Gz.isLeavingWindow):!1}(function(){if(typeof window>"u"||!ok())return;function t(){return{enterCount:0,isOverWindow:!1}}var n=t();function r(){n=t()}Tx.bindAll(window,[{type:"dragstart",listener:function(){n.enterCount=0,n.isOverWindow=!0}},{type:"drop",listener:r},{type:"dragend",listener:r},{type:"dragenter",listener:function(s){!n.isOverWindow&&n.enterCount===0&&(s[Gz.isEnteringWindow]=!0),n.isOverWindow=!0,n.enterCount++}},{type:"dragleave",listener:function(s){n.enterCount--,n.isOverWindow&&n.enterCount===0&&(s[Gz.isLeavingWindow]=!0,n.isOverWindow=!1)}}],{capture:!0})})();function k_t(e){return"nodeName"in e}function T_t(e){return k_t(e)&&e.ownerDocument!==document}function A_t(e){var t=e.dragLeave,n=t.type,r=t.relatedTarget;return n!=="dragleave"?!1:ok()?C_t({dragLeave:t}):r==null?!0:E_t()?T_t(r):r instanceof HTMLIFrameElement}function N_t(e){var t=e.onDragEnd;return[{type:"pointermove",listener:(function(){var n=0;return function(){if(n<20){n++;return}t()}})()},{type:"pointerdown",listener:t}]}function Kw(e){return{altKey:e.altKey,button:e.button,buttons:e.buttons,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY}}var O_t=function(t){var n=[],r=null,i=function(){for(var a=arguments.length,o=new Array(a),l=0;l<a;l++)o[l]=arguments[l];n=o,!r&&(r=requestAnimationFrame(function(){r=null,t.apply(void 0,n)}))};return i.cancel=function(){r&&(cancelAnimationFrame(r),r=null)},i},l6=O_t(function(e){return e()}),YA=(function(){var e=null;function t(r){var i=requestAnimationFrame(function(){e=null,r()});e={frameId:i,fn:r}}function n(){e&&(cancelAnimationFrame(e.frameId),e.fn(),e=null)}return{schedule:t,flush:n}})();function R_t(e){var t=e.source,n=e.initial,r=e.dispatchEvent,i={dropTargets:[]};function s(o){r(o),i={dropTargets:o.payload.location.current.dropTargets}}var a={start:function(l){var u=l.nativeSetDragImage,d={current:n,previous:i,initial:n};s({eventName:"onGenerateDragPreview",payload:{source:t,location:d,nativeSetDragImage:u}}),YA.schedule(function(){s({eventName:"onDragStart",payload:{source:t,location:d}})})},dragUpdate:function(l){var u=l.current;YA.flush(),l6.cancel(),s({eventName:"onDropTargetChange",payload:{source:t,location:{initial:n,previous:i,current:u}}})},drag:function(l){var u=l.current;l6(function(){YA.flush();var d={initial:n,previous:i,current:u};s({eventName:"onDrag",payload:{source:t,location:d}})})},drop:function(l){var u=l.current,d=l.updatedSourcePayload;YA.flush(),l6.cancel(),s({eventName:"onDrop",payload:{source:d??t,location:{current:u,previous:i,initial:n}}})}};return a}var Kz={isActive:!1};function iNe(){return!Kz.isActive}function I_t(e){return e.dataTransfer?e.dataTransfer.setDragImage.bind(e.dataTransfer):null}function D_t(e){var t=e.current,n=e.next;if(t.length!==n.length)return!0;for(var r=0;r<t.length;r++)if(t[r].element!==n[r].element)return!0;return!1}function j_t(e){var t=e.event,n=e.dragType,r=e.getDropTargetsOver,i=e.dispatchEvent;if(!iNe())return;var s=P_t({event:t,dragType:n,getDropTargetsOver:r});Kz.isActive=!0;var a={current:s};c6({event:t,current:s.dropTargets});var o=R_t({source:n.payload,dispatchEvent:i,initial:s});function l(m){var g=D_t({current:a.current.dropTargets,next:m.dropTargets});a.current=m,g&&o.dragUpdate({current:a.current})}function u(m){var g=Kw(m),y=eNe(m.target)?tNe({x:g.clientX,y:g.clientY}):m.target,v=r({target:y,input:g,source:n.payload,current:a.current.dropTargets});v.length&&(m.preventDefault(),c6({event:m,current:v})),l({dropTargets:v,input:g})}function d(){a.current.dropTargets.length&&l({dropTargets:[],input:a.current.input}),o.drop({current:a.current,updatedSourcePayload:null}),f()}function f(){Kz.isActive=!1,h()}var h=Tx.bindAll(window,[{type:"dragover",listener:function(g){u(g),o.drag({current:a.current})}},{type:"dragenter",listener:u},{type:"dragleave",listener:function(g){A_t({dragLeave:g})&&(l({input:a.current.input,dropTargets:[]}),n.startedFrom==="external"&&d())}},{type:"drop",listener:function(g){if(a.current={dropTargets:a.current.dropTargets,input:Kw(g)},!a.current.dropTargets.length){d();return}g.preventDefault(),c6({event:g,current:a.current.dropTargets}),o.drop({current:a.current,updatedSourcePayload:n.type==="external"?n.getDropPayload(g):null}),f()}},{type:"dragend",listener:function(g){a.current={dropTargets:a.current.dropTargets,input:Kw(g)},d()}}].concat(rNe(N_t({onDragEnd:d}))),{capture:!0});o.start({nativeSetDragImage:I_t(t)})}function c6(e){var t,n=e.event,r=e.current,i=(t=r[0])===null||t===void 0?void 0:t.dropEffect;i!=null&&n.dataTransfer&&(n.dataTransfer.dropEffect=i)}function P_t(e){var t=e.event,n=e.dragType,r=e.getDropTargetsOver,i=Kw(t);if(n.startedFrom==="external")return{input:i,dropTargets:[]};var s=r({input:i,source:n.payload,target:t.target,current:[]});return{input:i,dropTargets:s}}var wce={canStart:iNe,start:j_t},Yz=new Map;function L_t(e){var t=e.typeKey,n=e.mount,r=Yz.get(t);if(r)return r.usageCount++,r;var i={typeKey:t,unmount:n(),usageCount:1};return Yz.set(t,i),i}function M_t(e){var t=L_t(e);return function(){t.usageCount--,!(t.usageCount>0)&&(t.unmount(),Yz.delete(e.typeKey))}}function lk(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(){t.forEach(function(i){return i()})}}function sNe(e,t){var n=t.attribute,r=t.value;return e.setAttribute(n,r),function(){return e.removeAttribute(n)}}function Ece(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function tm(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ece(Object(n),!0).forEach(function(r){ak(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ece(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function u6(e,t){var n=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=F_t(e))||t){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
135
135
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s,a=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var u=n.next();return a=u.done,u},e:function(u){o=!0,s=u},f:function(){try{a||n.return==null||n.return()}finally{if(o)throw s}}}}function F_t(e,t){if(e){if(typeof e=="string")return Cce(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Cce(e,t):void 0}}function Cce(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function d6(e){return e.slice(0).reverse()}function B_t(e){var t=e.typeKey,n=e.defaultDropEffect,r=new WeakMap,i="data-drop-target-for-".concat(t),s="[".concat(i,"]");function a(m){return r.set(m.element,m),function(){return r.delete(m.element)}}function o(m){var g=lk(sNe(m.element,{attribute:i,value:"true"}),a(m));return Gy(g)}function l(m){var g,y,v,_,S=m.source,E=m.target,T=m.input,k=m.result,w=k===void 0?[]:k;if(E==null)return w;if(!(E instanceof Element))return E instanceof Node?l({source:S,target:E.parentElement,input:T,result:w}):w;var A=E.closest(s);if(A==null)return w;var R=r.get(A);if(R==null)return w;var I={input:T,source:S,element:R.element};if(R.canDrop&&!R.canDrop(I))return l({source:S,target:R.element.parentElement,input:T,result:w});var D=(g=(y=R.getData)===null||y===void 0?void 0:y.call(R,I))!==null&&g!==void 0?g:{},j=(v=(_=R.getDropEffect)===null||_===void 0?void 0:_.call(R,I))!==null&&v!==void 0?v:n,F={data:D,element:R.element,dropEffect:j,isActiveDueToStickiness:!1};return l({source:S,target:R.element.parentElement,input:T,result:[].concat(rNe(w),[F])})}function u(m){var g=m.eventName,y=m.payload,v=u6(y.location.current.dropTargets),_;try{for(v.s();!(_=v.n()).done;){var S,E=_.value,T=r.get(E.element),k=tm(tm({},y),{},{self:E});T==null||(S=T[g])===null||S===void 0||S.call(T,k)}}catch(w){v.e(w)}finally{v.f()}}var d={onGenerateDragPreview:u,onDrag:u,onDragStart:u,onDrop:u,onDropTargetChange:function(g){var y=g.payload,v=new Set(y.location.current.dropTargets.map(function($){return $.element})),_=new Set,S=u6(y.location.previous.dropTargets),E;try{for(S.s();!(E=S.n()).done;){var T,k=E.value;_.add(k.element);var w=r.get(k.element),A=v.has(k.element),R=tm(tm({},y),{},{self:k});if(w==null||(T=w.onDropTargetChange)===null||T===void 0||T.call(w,R),!A){var I;w==null||(I=w.onDragLeave)===null||I===void 0||I.call(w,R)}}}catch($){S.e($)}finally{S.f()}var D=u6(y.location.current.dropTargets),j;try{for(D.s();!(j=D.n()).done;){var F,z,P=j.value;if(!_.has(P.element)){var L=tm(tm({},y),{},{self:P}),M=r.get(P.element);M==null||(F=M.onDropTargetChange)===null||F===void 0||F.call(M,L),M==null||(z=M.onDragEnter)===null||z===void 0||z.call(M,L)}}}catch($){D.e($)}finally{D.f()}}};function f(m){d[m.eventName](m)}function h(m){var g=m.source,y=m.target,v=m.input,_=m.current,S=l({source:g,target:y,input:v});if(S.length>=_.length)return S;for(var E=d6(_),T=d6(S),k=[],w=0;w<E.length;w++){var A,R=E[w],I=T[w];if(I!=null){k.push(I);continue}var D=k[w-1],j=E[w-1];if(D?.element!==j?.element)break;var F=r.get(R.element);if(!F)break;var z={input:v,source:g,element:F.element};if(F.canDrop&&!F.canDrop(z)||!((A=F.getIsSticky)!==null&&A!==void 0&&A.call(F,z)))break;k.push(tm(tm({},R),{},{isActiveDueToStickiness:!0}))}return d6(k)}return{dropTargetForConsumers:o,getIsOver:h,dispatchEvent:f}}function $_t(e,t){var n=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=z_t(e))||t){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
136
136
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s,a=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var u=n.next();return a=u.done,u},e:function(u){o=!0,s=u},f:function(){try{a||n.return==null||n.return()}finally{if(o)throw s}}}}function z_t(e,t){if(e){if(typeof e=="string")return kce(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?kce(e,t):void 0}}function kce(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Tce(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function U_t(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Tce(Object(n),!0).forEach(function(r){ak(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Tce(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function H_t(){var e=new Set,t=null;function n(s){t&&(!s.canMonitor||s.canMonitor(t.canMonitorArgs))&&t.active.add(s)}function r(s){var a=U_t({},s);e.add(a),n(a);function o(){e.delete(a),t&&t.active.delete(a)}return Gy(o)}function i(s){var a=s.eventName,o=s.payload;if(a==="onGenerateDragPreview"){t={canMonitorArgs:{initial:o.location.initial,source:o.source},active:new Set};var l=$_t(e),u;try{for(l.s();!(u=l.n()).done;){var d=u.value;n(d)}}catch(v){l.e(v)}finally{l.f()}}if(t){for(var f=Array.from(t.active),h=0,m=f;h<m.length;h++){var g=m[h];if(t.active.has(g)){var y;(y=g[a])===null||y===void 0||y.call(g,o)}}a==="onDrop"&&(t.active.clear(),t=null)}}return{dispatchEvent:i,monitorForConsumers:r}}function V_t(e){var t=e.typeKey,n=e.mount,r=e.dispatchEventToSource,i=e.onPostDispatch,s=e.defaultDropEffect,a=H_t(),o=B_t({typeKey:t,defaultDropEffect:s});function l(f){r?.(f),o.dispatchEvent(f),a.dispatchEvent(f),i?.(f)}function u(f){var h=f.event,m=f.dragType;wce.start({event:h,dragType:m,getDropTargetsOver:o.getIsOver,dispatchEvent:l})}function d(){function f(){var h={canStart:wce.canStart,start:u};return n(h)}return M_t({typeKey:t,mount:f})}return{registerUsage:d,dropTarget:o.dropTargetForConsumers,monitor:a.monitorForConsumers}}var aNe=Gy(function(){return navigator.userAgent.toLocaleLowerCase().includes("android")}),W_t="pdnd:android-fallback",Ace="text/plain",q_t="text/uri-list",G_t="application/vnd.pdnd",AR=new WeakMap;function K_t(e){return AR.set(e.element,e),function(){AR.delete(e.element)}}var Nce=x_t(),WQ=V_t({typeKey:"element",defaultDropEffect:"move",mount:function(t){return lk(Nce.bindEvents(),Tx.bind(document,{type:"dragstart",listener:function(r){var i,s,a,o,l,u;if(t.canStart(r)&&!r.defaultPrevented&&r.dataTransfer){var d=r.target;if(d instanceof HTMLElement){var f=AR.get(d);if(f){var h=Kw(r),m={element:f.element,dragHandle:(i=f.dragHandle)!==null&&i!==void 0?i:null,input:h};if(f.canDrag&&!f.canDrag(m)){r.preventDefault();return}if(f.dragHandle){var g=tNe({x:h.clientX,y:h.clientY});if(!f.dragHandle.contains(g)){r.preventDefault();return}}var y=(s=(a=f.getInitialDataForExternal)===null||a===void 0?void 0:a.call(f,m))!==null&&s!==void 0?s:null;if(y)for(var v=0,_=Object.entries(y);v<_.length;v++){var S=QAe(_[v],2),E=S[0],T=S[1];r.dataTransfer.setData(E,T??"")}aNe()&&!r.dataTransfer.types.includes(Ace)&&!r.dataTransfer.types.includes(q_t)&&r.dataTransfer.setData(Ace,W_t),r.dataTransfer.setData(G_t,"");var k={element:f.element,dragHandle:(o=f.dragHandle)!==null&&o!==void 0?o:null,data:(l=(u=f.getInitialData)===null||u===void 0?void 0:u.call(f,m))!==null&&l!==void 0?l:{}},w={type:"element",payload:k,startedFrom:"internal"};t.start({event:r,dragType:w})}}}}}))},dispatchEventToSource:function(t){var n,r,i=t.eventName,s=t.payload;(n=AR.get(s.source.element))===null||n===void 0||(r=n[i])===null||r===void 0||r.call(n,s)},onPostDispatch:Nce.getOnPostDispatch()}),h5=WQ.dropTarget,oNe=WQ.monitor;function lNe(e){var t=lk(WQ.registerUsage(),K_t(e),sNe(e.element,{attribute:"draggable",value:"true"}));return Gy(t)}function Oce(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Rce(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Oce(Object(n),!0).forEach(function(r){ak(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Oce(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var Y_t={top:function(t,n){return Math.abs(n.y-t.top)},right:function(t,n){return Math.abs(t.right-n.x)},bottom:function(t,n){return Math.abs(t.bottom-n.y)},left:function(t,n){return Math.abs(n.x-t.left)}},cNe=Symbol("closestEdge");function uNe(e,t){var n,r,i=t.element,s=t.input,a=t.allowedEdges,o={x:s.clientX,y:s.clientY},l=i.getBoundingClientRect(),u=a.map(function(f){return{edge:f,value:Y_t[f](l,o)}}),d=(n=(r=u.sort(function(f,h){return f.value-h.value})[0])===null||r===void 0?void 0:r.edge)!==null&&n!==void 0?n:null;return Rce(Rce({},e),{},ak({},cNe,d))}function z0(e){var t;return(t=e[cNe])!==null&&t!==void 0?t:null}function X_t({tab:e,isActive:t,canClose:n,onSelect:r,onClose:i,onEdit:s,onReorder:a}){const o=x.useRef(null),[l,u]=x.useState(!1),[d,f]=x.useState(null),h=x.useRef(!1);x.useEffect(()=>{const y=o.current;if(!(!y||!a))return lk(lNe({element:y,getInitialData:()=>({type:"terminal-tab",tabId:e.id,position:e.position}),onDragStart:()=>{u(!0),h.current=!0},onDrop:()=>{u(!1)}}),h5({element:y,getData:({input:v,element:_})=>{const S={type:"terminal-tab",tabId:e.id,position:e.position};return uNe(S,{input:v,element:_,allowedEdges:["left","right"]})},canDrop:({source:v})=>v.data.type==="terminal-tab"&&v.data.tabId!==e.id,onDragEnter:({self:v})=>{f(z0(v.data))},onDrag:({self:v})=>{f(z0(v.data))},onDragLeave:()=>{f(null)},onDrop:({source:v,self:_})=>{f(null);const S=z0(_.data),E=v.data.tabId,T=e.position;let k;S==="left"?k=T:k=T+1,a(E,k)}}))},[e.id,e.position,a]);const m=()=>{h.current=!1},g=()=>{h.current||r(),h.current=!1};return c.jsxs("button",{ref:o,onPointerDown:m,onClick:g,onDoubleClick:s,onContextMenu:y=>{y.preventDefault(),s()},className:Ae("group relative flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs transition-colors max-sm:px-2 max-sm:py-1",t?"bg-background text-foreground":"text-muted-foreground hover:text-foreground","after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:bg-foreground after:transition-opacity",t?"after:opacity-100":"after:opacity-0",l&&"opacity-50",a&&"cursor-grab active:cursor-grabbing"),title:e.directory?`${e.name}
137
- ${e.directory}`:e.name,children:[d&&c.jsx("div",{className:Ae("absolute top-0 bottom-0 w-0.5 bg-primary z-10",d==="left"&&"-left-1",d==="right"&&"-right-1")}),e.directory&&c.jsx(Z,{icon:Zs,size:12,strokeWidth:2,className:"shrink-0 opacity-60"}),e.name,n&&c.jsx("button",{onClick:y=>{y.stopPropagation(),i()},onPointerDown:y=>y.stopPropagation(),className:"ml-1 rounded opacity-0 hover:bg-muted group-hover:opacity-100",children:c.jsx(Z,{icon:Tn,size:12,strokeWidth:2})})]})}function Q_t({tabs:e,activeTabId:t,onTabSelect:n,onTabClose:r,onTabCreate:i,onTabEdit:s,onTabReorder:a}){const o=x.useRef(null),l=x.useRef(null),[u,d]=x.useState(!1),[f,h]=x.useState(!1),[m,g]=x.useState(!0),y=x.useCallback(()=>{const S=o.current;if(!S)return;const{scrollLeft:E,scrollWidth:T,clientWidth:k}=S;d(E>0),h(E+k<T-1)},[]);x.useEffect(()=>{const S=l.current,E=o.current;if(!S||!E)return;const T=new IntersectionObserver(([k])=>{g(k.isIntersecting)},{root:E,threshold:.9});return T.observe(S),()=>T.disconnect()},[]),x.useEffect(()=>{const S=o.current;if(!S)return;y(),S.addEventListener("scroll",y);const E=new ResizeObserver(y);return E.observe(S),()=>{S.removeEventListener("scroll",y),E.disconnect()}},[y]),x.useEffect(()=>{y()},[e,y]);const v=x.useCallback(()=>{o.current?.scrollTo({left:0,behavior:"smooth"})},[]),_=x.useCallback(()=>{const S=o.current;S&&S.scrollTo({left:S.scrollWidth,behavior:"smooth"})},[]);return c.jsxs("div",{className:"flex items-center",children:[u&&c.jsx(_e,{variant:"ghost",size:"icon-xs",onClick:v,className:"shrink-0",children:c.jsx(Z,{icon:xf,size:14,strokeWidth:2})}),c.jsxs("div",{ref:o,className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto scrollbar-none",children:[e.map(S=>c.jsx(X_t,{tab:S,isActive:S.id===t,canClose:e.length>1,onSelect:()=>n(S.id),onClose:()=>r(S.id),onEdit:()=>s(S),onReorder:a},S.id)),c.jsx("span",{ref:l,children:c.jsx(_e,{variant:"ghost",size:"icon-xs",onClick:i,className:"shrink-0",children:c.jsx(Z,{icon:sx,size:14,strokeWidth:2})})})]}),f&&c.jsx(_e,{variant:"ghost",size:"icon-xs",onClick:_,className:"shrink-0",children:c.jsx(Z,{icon:Bl,size:14,strokeWidth:2})}),!m&&c.jsx(_e,{variant:"ghost",size:"icon-xs",onClick:i,className:"shrink-0",children:c.jsx(Z,{icon:sx,size:14,strokeWidth:2})})]})}function Z_t({tab:e,open:t,onOpenChange:n,onSave:r,onCreate:i,defaultName:s=""}){const{t:a}=Ot("terminals"),[o,l]=x.useState(""),[u,d]=x.useState(null),[f,h]=x.useState(!1),m=!e&&i;x.useEffect(()=>{t&&(e?(l(e.name),d(e.directory??null)):(l(s),d(null)))},[t,e,s]);const g=()=>{if(m){i(o.trim(),u??void 0),n(!1);return}if(!e)return;const E={};o.trim()&&o.trim()!==e.name&&(E.name=o.trim()),u!==(e.directory??null)&&(E.directory=u),Object.keys(E).length>0&&r(e.id,E),n(!1)},y=E=>{E.key==="Enter"&&(E.preventDefault(),g())},v=()=>{d(null)},_=E=>{d(E)},S=u?u.split("/").pop():null;return c.jsxs(c.Fragment,{children:[c.jsx(Ya,{open:t,onOpenChange:n,children:c.jsxs(Xa,{className:"sm:max-w-md",children:[c.jsx(Lo,{children:c.jsx(Mo,{children:a(m?"newTab.title":"editTab.title")})}),c.jsxs(qh,{className:"mt-4",children:[c.jsxs($n,{children:[c.jsx(zn,{htmlFor:"tabName",children:a("editTab.name")}),c.jsx(At,{id:"tabName",value:o,onChange:E=>l(E.target.value),onKeyDown:y,placeholder:a("editTab.namePlaceholder"),autoFocus:!0})]}),c.jsxs($n,{children:[c.jsx(zn,{children:a("editTab.directory")}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(_e,{type:"button",variant:"outline",className:"flex-1 justify-start font-normal",onClick:()=>h(!0),children:[c.jsx(Z,{icon:Zs,size:14,strokeWidth:2,className:"mr-2 shrink-0"}),S?c.jsx("span",{className:"truncate font-mono text-xs",children:u}):c.jsx("span",{className:"text-muted-foreground",children:a("editTab.directoryPlaceholder")})]}),u&&c.jsx(_e,{type:"button",variant:"ghost",size:"icon",onClick:v,title:a("editTab.clearDirectory"),children:c.jsx(Z,{icon:Tn,size:14,strokeWidth:2})})]})]})]}),c.jsxs(wC,{className:"mt-4",children:[c.jsx(SC,{render:c.jsx(_e,{variant:"outline",type:"button"}),children:a("editTab.cancel")}),c.jsx(_e,{onClick:g,disabled:!o.trim(),children:a(m?"newTab.create":"editTab.save")})]})]})}),c.jsx(yh,{open:f,onOpenChange:h,onSelect:_,initialPath:u??void 0})]})}const J_t=Ym("h-5 gap-1 rounded-full border border-transparent px-2 py-0.5 text-[0.625rem] font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-2.5! inline-flex items-center justify-center w-fit whitespace-nowrap shrink-0 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-colors overflow-hidden group/badge",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 [a]:hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 text-destructive dark:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground bg-input/20 dark:bg-input/30",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function ir({className:e,variant:t="default",render:n,...r}){return wWe({defaultTagName:"span",props:gd({className:Ae(J_t({className:e,variant:t}))},r),render:n,state:{slot:"badge",variant:t}})}function qQ({value:e,onChange:t,options:n,allLabel:r,showInbox:i=!0}){const{t:s}=Ot("tasks"),[a,o]=x.useState(!1),[l,u]=x.useState(""),d=x.useRef(null),{data:f=[]}=Mc(),{data:h=[]}=cl(),m=n??f.map(w=>({id:w.id,name:w.name,count:w.taskCount})),g=!!n,y=x.useMemo(()=>{if(g)return 0;const w=new Set,A=new Set;for(const R of f)for(const I of R.repositories)w.add(I.id),A.add(I.path);return h.filter(R=>!R.projectId&&(!R.repositoryId||!w.has(R.repositoryId))&&(!R.repoPath||!A.has(R.repoPath))).length},[h,f,g]),v=m.filter(w=>w.name.toLowerCase().includes(l.toLowerCase()));x.useEffect(()=>{a&&setTimeout(()=>d.current?.focus(),0)},[a]);const _=w=>{t(w),o(!1)},S=w=>{w.stopPropagation(),t(null)},E=e?m.find(w=>w.id===e):null,T=e==="inbox"?"Inbox":E?.name??null,k=r??s("allProjects");return c.jsxs(O1,{open:a,onOpenChange:o,children:[c.jsxs(R1,{render:c.jsx(_e,{variant:"outline",size:"sm",className:Ae("shrink-0 gap-1.5 h-7 px-2",e&&"pr-1")}),children:[c.jsx(Z,{icon:Ty,size:12,strokeWidth:2,className:"text-muted-foreground"}),e?c.jsxs(c.Fragment,{children:[c.jsxs(ir,{variant:"secondary",className:"h-5 px-1.5 text-[10px] gap-0.5",children:[T,e==="inbox"?` (${y})`:E?.count!==void 0?` (${E.count})`:""]}),c.jsx("button",{onClick:S,className:"ml-0.5 p-0.5 hover:text-destructive transition-colors",children:c.jsx(Z,{icon:Tn,size:12})})]}):c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-xs",children:k}),c.jsx(Z,{icon:Ts,size:12,strokeWidth:2,className:"text-muted-foreground"})]})]}),c.jsxs(I1,{align:"start",className:"w-56 p-0",children:[c.jsx("div",{className:"p-2 border-b",children:c.jsx(At,{ref:d,value:l,onChange:w=>u(w.target.value),placeholder:s("searchProjects"),className:"h-7 text-xs"})}),c.jsxs("div",{className:"max-h-48 overflow-y-auto py-1",children:[c.jsxs("button",{className:Ae("w-full px-3 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground flex items-center gap-2",!e&&"bg-accent text-accent-foreground"),onClick:()=>_(null),children:[c.jsx("span",{className:"w-3.5 shrink-0",children:!e&&c.jsx(Z,{icon:hr,size:14,className:"text-primary"})}),c.jsx("span",{className:"flex-1 truncate",children:k})]}),v.map(w=>{const A=e===w.id;return c.jsxs("button",{className:Ae("group w-full px-3 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground flex items-center gap-2",A&&"bg-accent text-accent-foreground"),onClick:()=>_(w.id),children:[c.jsx("span",{className:"w-3.5 shrink-0",children:A&&c.jsx(Z,{icon:hr,size:14,className:"text-primary"})}),c.jsx("span",{className:"flex-1 truncate",children:w.name}),w.count!==void 0&&c.jsx("span",{className:Ae("text-muted-foreground group-hover:text-accent-foreground text-[10px]",A&&"text-accent-foreground"),children:w.count})]},w.id)}),!g&&i&&"inbox".includes(l.toLowerCase())&&c.jsxs("button",{className:Ae("group w-full px-3 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground flex items-center gap-2",e==="inbox"&&"bg-accent text-accent-foreground"),onClick:()=>_("inbox"),children:[c.jsx("span",{className:"w-3.5 shrink-0",children:e==="inbox"&&c.jsx(Z,{icon:hr,size:14,className:"text-primary"})}),c.jsx("span",{className:"flex-1 truncate",children:"Inbox"}),c.jsx("span",{className:Ae("text-muted-foreground group-hover:text-accent-foreground text-[10px]",e==="inbox"&&"text-accent-foreground"),children:y})]}),v.length===0&&(g||!"inbox".includes(l.toLowerCase()))&&c.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground text-center",children:s("noProjectsFound")})]})]})]})}function eSt(e){return{id:e.id,name:e.name,cwd:e.cwd,status:e.status,exitCode:e.exitCode,cols:e.cols,rows:e.rows,createdAt:e.createdAt,tabId:e.tabId??void 0,positionInTab:e.positionInTab}}function tSt(e){return{id:e.id,name:e.name,position:e.position,directory:e.directory??void 0,createdAt:e.createdAt}}function p5(e={}){const t=dq();return{get terminals(){return t.terminals.map(eSt)},get terminalsLoaded(){return t.terminalsLoaded},get tabs(){return t.tabs.map(tSt)},get connected(){return t.connected},get newTerminalIds(){return t.newTerminalIds},createTerminal:t.createTerminal,destroyTerminal:t.destroyTerminal,recreateTerminal:t.recreateTerminal,writeToTerminal:t.writeToTerminal,sendInputToTerminal:t.sendInputToTerminal,resizeTerminal:t.resizeTerminal,renameTerminal:t.renameTerminal,clearTerminalBuffer:t.clearTerminalBuffer,assignTerminalToTab:t.assignTerminalToTab,createTab:t.createTab,updateTab:t.updateTab,deleteTab:t.deleteTab,reorderTab:t.reorderTab,attachXterm:t.attachXterm,setupImagePaste:t.setupImagePaste,consumePendingStartup:t.consumePendingStartup,clearStartingUp:t.clearStartingUp}}const dNe="task-shell:";function Ice({taskId:e,taskName:t,cwd:n,className:r}){const i=`${dNe}${e}`,[s,a]=x.useState(null),[o,l]=x.useState(!1),u=x.useRef(null),d=x.useRef(null),f=x.useRef(!1),h=x.useRef(!1),{resolvedTheme:m}=ol(),g=m==="dark",{terminals:y,terminalsLoaded:v,connected:_,createTerminal:S,attachXterm:E,resizeTerminal:T,setupImagePaste:k,writeToTerminal:w,recreateTerminal:A}=p5(),R=x.useRef(E),I=x.useRef(k);x.useEffect(()=>{R.current=E},[E]),x.useEffect(()=>{I.current=k},[k]);const D=s?y.find($=>$.id===s):null,j=D?.status;x.useEffect(()=>{f.current=!1,h.current=!1,a(null),l(!1)},[n]),x.useEffect(()=>{if(!_||!n||!v)return;const $=y.find(W=>W.tabId===i);if($){Yt.taskTerminal.debug("Found existing shell terminal",{id:$.id,shellTabId:i}),a($.id),l(!1);return}if(!f.current&&u.current){Yt.taskTerminal.info("Creating shell terminal",{cwd:n,shellTabId:i}),f.current=!0,l(!0);const{cols:W,rows:Y}=u.current;S({name:`${t} (shell)`,cols:W,rows:Y,cwd:n,tabId:i,taskId:e})}},[_,n,v,y,i,t,e,S]),x.useEffect(()=>{if(!n)return;const $=y.find(Y=>Y.tabId===i);if(!$)return;const W=s&&y.some(Y=>Y.id===s);(!s||!W)&&(a($.id),l(!1),s&&!W&&(h.current=!1))},[y,n,s,i]),x.useEffect(()=>{if(!s||!u.current||!d.current||h.current)return;const $=()=>{requestAnimationFrame(()=>{})},W=R.current(s,u.current,{onAttached:$}),Y=I.current(d.current,s);return h.current=!0,()=>{W(),Y(),h.current=!1}},[s]);const F=x.useCallback($=>{u.current=$},[]),z=x.useCallback(($,W)=>{s&&T(s,$,W)},[s,T]),P=x.useCallback($=>{d.current=$},[]),L=x.useCallback($=>{s&&w(s,$)},[s,w]),M=x.useCallback(()=>{s&&(h.current=!1,f.current=!1,a(null),A(s))},[s,A]);return n?c.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[!_&&c.jsx("div",{className:"shrink-0 px-2 py-1 bg-muted-foreground/20 text-muted-foreground text-xs",children:"Connecting to terminal server..."}),j==="error"&&c.jsx("div",{className:"shrink-0 px-2 py-1 bg-destructive/20 text-destructive text-xs",children:"Terminal failed to start. The worktree directory may not exist."}),j==="exited"&&c.jsxs("div",{className:"shrink-0 px-2 py-1 bg-muted text-muted-foreground text-xs",children:["Terminal exited (code: ",D?.exitCode,")"]}),c.jsxs("div",{className:"relative min-h-0 min-w-0 flex-1",children:[c.jsx(ER,{className:Ae("h-full w-full overflow-hidden p-2 bg-terminal-background",r),onReady:F,onResize:z,onContainerReady:P,terminalId:s??void 0,setupImagePaste:k,onSend:L,onReset:s?M:void 0}),o&&!s&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-terminal-background",children:c.jsxs("div",{className:"flex flex-col items-center gap-3",children:[c.jsx(Z,{icon:Nt,size:24,strokeWidth:2,className:Ae("animate-spin",g?"text-white/50":"text-black/50")}),c.jsx("span",{className:Ae("font-mono text-sm",g?"text-white/50":"text-black/50"),children:"Initializing terminal..."})]})})]}),c.jsx("div",{className:"h-2 shrink-0 bg-terminal-background"}),c.jsx(JE,{onSend:L})]}):c.jsx("div",{className:Ae("flex h-full items-center justify-center text-muted-foreground text-sm bg-terminal-background",r),children:"No worktree path configured for this task"})}function f6(e){return{id:e.id,name:e.name,cwd:e.cwd,status:e.status,exitCode:e.exitCode??void 0,cols:e.cols,rows:e.rows,createdAt:e.createdAt,tabId:e.tabId??void 0,positionInTab:e.positionInTab}}function nSt(e,t){return{id:e.id,name:e.name,layout:"single",position:t,directory:e.directory??void 0}}const Wo="all-tasks",ja="all-repos",Dce=["IN_PROGRESS","IN_REVIEW"],jce="fulcrum:lastTerminalTab",rSt=Py(function(){const{t}=Ot("terminals"),n=Ni(),{tab:r,project:i,repoIds:s}=aC({from:"/terminals/"}),{terminals:a,tabs:o,connected:l,createTerminal:u,destroyTerminal:d,renameTerminal:f,assignTerminalToTab:h,createTab:m,updateTab:g,deleteTab:y,reorderTab:v,attachXterm:_,resizeTerminal:S,setupImagePaste:E,writeToTerminal:T,sendInputToTerminal:k,newTerminalIds:w,pendingTabCreation:A,lastCreatedTabId:R}=dq(),[I,D]=x.useState(null),{getFocusedTerminal:j,selectedRepositoryIds:F,setSelectedRepositories:z,isLoading:P}=fCe(),L=x.useMemo(()=>o.map(Fe=>Fe.id),[o]),M=r&&(L.includes(r)||r===Wo||r===ja),$=M?r:o[0]?.id??null,W=x.useCallback(Fe=>{n({to:"/terminals",search:{tab:Fe,project:Fe===Wo?i:void 0,repoIds:Fe===ja?s:void 0},replace:!0})},[n,i,s]),Y=x.useCallback(Fe=>{n({to:"/terminals",search:Ue=>({...Ue,project:Fe}),replace:!0})},[n]),q=jy();x.useEffect(()=>mx(()=>({lastCreatedTabId:q.lastCreatedTabId,pendingTabCreation:q.pendingTabCreation}),({lastCreatedTabId:Ue})=>{Ue&&(Yt.terminal.info("MobX reaction: lastCreatedTabId changed",{tabId:Ue}),W(Ue),setTimeout(()=>{q.clearLastCreatedTabId(),Ye.current++;const ut=`Terminal ${Ye.current}`;Yt.terminal.debug("Creating terminal in new tab",{tabId:Ue,name:ut}),u({name:ut,cols:80,rows:24,tabId:Ue,positionInTab:0})},150))},{fireImmediately:!0}),[q,W,u]),x.useEffect(()=>{if(Yt.terminal.debug("Redirect effect running",{tabsLength:o.length,isValidTab:M,pendingTabCreation:A,lastCreatedTabId:R}),o.length!==0&&!(A||R)&&!M){const Fe=localStorage.getItem(jce),Ue=Fe&&(o.some(ut=>ut.id===Fe)||Fe===Wo||Fe===ja)?Fe:o[0].id;Yt.terminal.debug("Redirecting to tab",{targetTab:Ue}),n({to:"/terminals",search:{tab:Ue},replace:!0})}},[o,M,R,A,n]),x.useEffect(()=>{$&&localStorage.setItem(jce,$)},[$]);const{data:K=[],status:X}=cl(),{data:U=[]}=Oy(),{data:J=[]}=Mc(),te=x.useMemo(()=>{const Fe=new Map;for(const Ue of U)Fe.set(Ue.path,Ue.id);return Fe},[U]),ee=x.useMemo(()=>new Set(K.filter(Fe=>Dce.includes(Fe.status)&&Fe.worktreePath).map(Fe=>Fe.worktreePath)),[K]),oe=x.useMemo(()=>new Set(K.filter(Fe=>Fe.worktreePath).map(Fe=>Fe.worktreePath)),[K]),ae=x.useMemo(()=>{const Fe=new Map;for(const Ue of K)Ue.worktreePath&&Ue.repoPath&&Ue.repoName&&Ue.baseBranch?Fe.set(Ue.worktreePath,{taskId:Ue.id,repoId:te.get(Ue.repoPath),repoName:Ue.repoName,title:Ue.title,repoPath:Ue.repoPath,worktreePath:Ue.worktreePath,baseBranch:Ue.baseBranch,branch:Ue.branch,prUrl:Ue.prUrl,pinned:Ue.pinned}):Ue.worktreePath&&Ue.type==="scratch"&&Fe.set(Ue.worktreePath,{taskId:Ue.id,repoId:void 0,repoName:"",title:Ue.title,repoPath:"",worktreePath:Ue.worktreePath,baseBranch:"",branch:null,prUrl:Ue.prUrl,pinned:Ue.pinned});return Fe},[K,te]),se=x.useMemo(()=>{const Fe=new Map;for(const Ue of J)Fe.set(Ue.id,Ue.name);return Fe},[J]),ue=x.useMemo(()=>{const Fe=new Map;for(const Ue of J)if(Ue.repositories)for(const ut of Ue.repositories)Fe.set(ut.id,Ue.id);return Fe},[J]),de=x.useMemo(()=>{const Fe=new Map;for(const Ue of J)if(Ue.repositories)for(const ut of Ue.repositories)Fe.set(ut.path,Ue.id);return Fe},[J]),ce=x.useCallback(Fe=>Fe.projectId?Fe.projectId:Fe.repositoryId?ue.get(Fe.repositoryId)??null:Fe.repoPath?de.get(Fe.repoPath)??null:null,[ue,de]),Ee=x.useMemo(()=>{const Fe=new Set;for(const ut of K)if(Dce.includes(ut.status)){const Kt=ce(ut);Kt&&Fe.add(Kt)}const Ue=[];for(const ut of Fe){const Kt=se.get(ut)??ut;Ue.push({id:ut,name:Kt})}return Ue.sort((ut,Kt)=>ut.name.localeCompare(Kt.name)),Ue},[K,se,ce]),Ie=i,fe=x.useMemo(()=>{const Fe=new Map;for(const Ue of U)Fe.set(Ue.path,Ue.id);return Fe},[U]),be=x.useMemo(()=>{const Fe=new Map;for(const Ue of U)Fe.set(Ue.path,{repoId:Ue.id,repoName:Ue.displayName,repoPath:Ue.path});return Fe},[U]),ge=x.useMemo(()=>s?.split(",").filter(Boolean)??[],[s]),Ce=x.useMemo(()=>{const Fe=new Set(U.map(Ue=>Ue.id));return ge.filter(Ue=>Fe.has(Ue))},[ge,U]),[Re,xe]=x.useState(!1),[ye,De]=x.useState(""),ve=x.useRef(null),Oe=x.useMemo(()=>{if(!ye)return U;const Fe=ye.toLowerCase();return U.filter(Ue=>Ue.displayName.toLowerCase().includes(Fe))},[U,ye]);x.useEffect(()=>{Re?setTimeout(()=>ve.current?.focus(),0):De("")},[Re]);const[Be,Te]=x.useState(null),je=x.useRef(0),ie=400,Ke=x.useCallback((Fe,Ue)=>{Yt.projectTerminals.info("toggleRepoFilter called",{repoId:Fe,checked:Ue});const ut=s?.split(",").filter(Boolean)??[];if(Ue&&ut.length>=6)return;Ue&&(Yt.projectTerminals.info("Setting loadingRepoId",{repoId:Fe}),je.current=Date.now(),Te(Fe));const Kt=Ue?[...ut,Fe]:ut.filter(wn=>wn!==Fe);n({to:"/terminals",search:wn=>({...wn,repoIds:Kt.length>0?Kt.join(","):void 0}),replace:!0})},[n,s]),lt=x.useRef(!1);x.useEffect(()=>{if($!==ja){lt.current=!1;return}if(P||lt.current||s||F.length===0)return;const Fe=new Set(U.map(ut=>ut.id)),Ue=F.filter(ut=>Fe.has(ut));Ue.length!==0&&(lt.current=!0,n({to:"/terminals",search:ut=>({...ut,repoIds:Ue.join(",")}),replace:!0}))},[$,s,F,U,n,P]),x.useEffect(()=>{if($!==ja||P||!s&&!lt.current&&F.length>0)return;const Fe=ge.join(","),Ue=F.join(",");Fe!==Ue&&z(ge)},[$,ge,F,z,P,s]),x.useEffect(()=>{if($===ja&&l){Yt.projectTerminals.debug("Auto-create effect running",{selectedRepoIds:ge,terminalCount:a.length,terminalCwds:a.map(Fe=>Fe.cwd)});for(const Fe of ge){const Ue=U.find(wn=>wn.id===Fe);if(!Ue?.path)continue;const ut=Ue.path;if(a.find(wn=>wn.cwd===ut&&!wn.tabId)){Yt.projectTerminals.debug("Terminal already exists for repo",{repoId:Fe,repoPath:ut});continue}Yt.projectTerminals.info("Creating terminal for repo",{repoId:Fe,repoPath:ut}),u({name:Ue.displayName,cwd:ut,cols:80,rows:24})}}},[$,ge,U,a,l,u]);const Rt=x.useRef(new Map),Ye=x.useRef(0),ct=x.useRef(!1),Ve=x.useRef(!1),Et=x.useMemo(()=>{if($===Wo){const Fe=new Set;return a.filter(Ue=>Ue.cwd&&ee.has(Ue.cwd)&&!Ue.tabId).sort((Ue,ut)=>{const Kt=Ue.name.endsWith("(shell)")?1:0,wn=ut.name.endsWith("(shell)")?1:0;return Kt-wn}).filter(Ue=>Fe.has(Ue.cwd)?!1:(Fe.add(Ue.cwd),!0)).filter(Ue=>{if(!Ie)return!0;const ut=K.find(wn=>wn.worktreePath===Ue.cwd);return ut?ce(ut)===Ie:!1}).sort((Ue,ut)=>{const Kt=K.find(pr=>pr.worktreePath===Ue.cwd),wn=K.find(pr=>pr.worktreePath===ut.cwd);return!Kt||!wn?0:new Date(wn.createdAt).getTime()-new Date(Kt.createdAt).getTime()}).map(f6)}return $===ja?ge.length===0?[]:a.filter(Fe=>Fe.cwd&&!Fe.tabId&&fe.has(Fe.cwd)).filter(Fe=>{const Ue=fe.get(Fe.cwd);return Ue&&ge.includes(Ue)}).map(f6):a.filter(Fe=>Fe.tabId===$).sort((Fe,Ue)=>Fe.positionInTab-Ue.positionInTab).map(f6)},[$,a,ee,Ie,K,fe,ge,ce]);x.useEffect(()=>{if(!Be)return;const Fe=U.find(Kt=>Kt.id===Be);if(!Fe?.path)return;const Ue=Fe.path,ut=Et.some(Kt=>Kt.cwd===Ue);if(Yt.projectTerminals.debug("Clear loading effect",{loadingRepoId:Be,repoPath:Ue,hasTerminal:ut,visibleTerminalCwds:Et.map(Kt=>Kt.cwd)}),ut){const Kt=Date.now()-je.current,wn=ie-Kt;if(wn>0){const pr=setTimeout(()=>{Yt.projectTerminals.info("Clearing loadingRepoId after delay",{loadingRepoId:Be}),Te(null)},wn);return()=>clearTimeout(pr)}Yt.projectTerminals.info("Clearing loadingRepoId",{loadingRepoId:Be}),Te(null)}},[Be,U,Et]);const $e=x.useCallback(()=>{if(Yt.terminal.info("handleTerminalAdd called",{activeTabId:$,connected:l,pendingTerminalCreate:ct.current,terminalCount:a.length}),ct.current){Yt.terminal.debug("Skipping terminal creation, already pending");return}ct.current=!0,Ye.current++;const Fe=`Terminal ${Ye.current}`,Ue=a.filter(Kt=>Kt.tabId===$),ut=Ue.length;Yt.terminal.info("Creating terminal",{name:Fe,tabId:$,positionInTab:ut,terminalsInTabCount:Ue.length}),u({name:Fe,cols:80,rows:24,tabId:$??void 0,positionInTab:ut}),setTimeout(()=>{ct.current=!1},500)},[u,$,a,l]);x.useEffect(()=>{if(X!=="success"){Yt.terminalsView.debug("Tab assignment effect skipped",{tasksStatus:X});return}for(const Fe of a)Fe.cwd&&oe.has(Fe.cwd)&&Fe.tabId&&!Fe.tabId.startsWith(dNe)&&(Yt.terminalsView.debug("Removing task terminal from regular tab",{terminalId:Fe.id,name:Fe.name,cwd:Fe.cwd,tabId:Fe.tabId}),h(Fe.id,null))},[a,oe,h,X]);const Qe=x.useCallback(Fe=>{const Ue=Rt.current.get(Fe);Ue&&(Ue(),Rt.current.delete(Fe)),d(Fe,{force:!0,reason:"user_closed"})},[d]),pt=x.useCallback((Fe,Ue)=>{const ut=_(Fe,Ue);Rt.current.set(Fe,ut),w.has(Fe)&&setTimeout(()=>{Ue.focus()},50)},[_,w]),at=x.useCallback((Fe,Ue,ut)=>{S(Fe,Ue,ut)},[S]),gt=x.useCallback((Fe,Ue)=>{f(Fe,Ue)},[f]),We=x.useCallback(()=>{if(Ve.current){Yt.terminal.debug("Skipping tab creation, already pending");return}Ve.current=!0;const Fe=`Tab ${o.length+1}`;Yt.terminal.debug("Quick creating tab",{name:Fe}),m(Fe,void 0,void 0),setTimeout(()=>{Ve.current=!1},500)},[m,o.length]),Xe=x.useCallback((Fe,Ue)=>{Yt.terminal.debug("Reordering tab",{tabId:Fe,newPosition:Ue}),v(Fe,Ue)},[v]),it=x.useCallback((Fe,Ue)=>{if(Ve.current){Yt.terminal.debug("Skipping tab creation, already pending");return}Ve.current=!0,Yt.terminal.debug("Creating tab",{name:Fe,directory:Ue}),m(Fe,void 0,Ue),setTimeout(()=>{Ve.current=!1},500)},[m]),ot=x.useCallback(Fe=>{const Ue=a.filter(ut=>ut.tabId===Fe);for(const ut of Ue){const Kt=Rt.current.get(ut.id);Kt&&(Kt(),Rt.current.delete(ut.id))}y(Fe)},[a,y]),St=o.map(nSt),Xt=x.useCallback(Fe=>{D(Fe)},[]),Vt=x.useCallback((Fe,Ue)=>{g(Fe,Ue)},[g]),en=$===Wo||$===ja;return Ma("meta+d",$e,{enabled:!en&&l,allowInTerminal:!0,deps:[$e,en,l]}),Ma("meta+w",()=>{if($&&!en){const Fe=j($);Fe&&Qe(Fe)}},{enabled:!en,allowInTerminal:!0,deps:[$,en,j,Qe]}),c.jsxs("div",{className:"flex h-full max-w-full flex-col overflow-hidden",children:[c.jsxs("div",{className:"film-grain relative sticky top-0 z-10 flex shrink-0 items-center justify-between border-b border-border px-2 py-1",style:{background:"var(--gradient-header)"},children:[c.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[c.jsxs("button",{onClick:()=>W(Wo),className:Ae("relative flex shrink-0 items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors max-sm:px-2",$===Wo?"bg-primary/10 text-primary":"text-muted-foreground hover:text-primary hover:bg-primary/5","after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:bg-primary after:transition-opacity",$===Wo?"after:opacity-100":"after:opacity-0"),children:[c.jsx(Z,{icon:iD,size:12,strokeWidth:2}),c.jsx("span",{className:"max-sm:hidden",children:t("taskTerminals")})]}),c.jsxs("button",{onClick:()=>W(ja),className:Ae("relative flex shrink-0 items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors max-sm:px-2",$===ja?"bg-primary/10 text-primary":"text-muted-foreground hover:text-primary hover:bg-primary/5","after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:bg-primary after:transition-opacity",$===ja?"after:opacity-100":"after:opacity-0"),children:[c.jsx(Z,{icon:ef,size:12,strokeWidth:2}),c.jsx("span",{className:"max-sm:hidden",children:t("repoTerminals")})]}),c.jsx("div",{className:"mx-2 h-4 w-px shrink-0 bg-border"}),c.jsx("div",{className:"min-w-0 flex-1",children:c.jsx(Q_t,{tabs:St,activeTabId:$??"",onTabSelect:W,onTabClose:ot,onTabCreate:We,onTabEdit:Xt,onTabReorder:Xe})})]}),c.jsxs("div",{className:"flex shrink-0 items-center gap-3 max-sm:gap-1",children:[$===Wo&&Ee.length>1&&c.jsx(qQ,{value:Ie??null,onChange:Fe=>Y(Fe??void 0),options:Ee,allLabel:t("allProjects")}),$===ja&&U.length>0&&c.jsxs(O1,{open:Re,onOpenChange:xe,children:[c.jsxs(R1,{render:c.jsx(_e,{variant:"outline",size:"sm",className:"max-sm:w-auto"}),children:[Be?c.jsx(Z,{icon:Nt,size:12,strokeWidth:2,className:"animate-spin text-muted-foreground"}):c.jsx(Z,{icon:Ty,size:12,strokeWidth:2,className:"text-muted-foreground"}),c.jsx("span",{children:Ce.length===0?t("selectRepos"):t("reposSelected",{count:Ce.length})})]}),c.jsxs(I1,{className:"w-64 p-0",align:"end",children:[c.jsx("div",{className:"border-b px-2 py-1.5",children:c.jsx(At,{ref:ve,value:ye,onChange:Fe=>De(Fe.target.value),placeholder:t("searchRepos"),className:"h-7 text-xs border-0 shadow-none focus-visible:ring-0"})}),c.jsxs("div",{className:"p-2 space-y-2",children:[c.jsx("div",{className:"text-sm font-medium mb-2",children:t("filterByRepo")}),c.jsx("div",{className:"max-h-48 overflow-y-auto space-y-2",children:Oe.length===0?c.jsx("div",{className:"text-xs text-muted-foreground py-1",children:t("noReposFound")}):Oe.map(Fe=>{const Ue=ge.includes(Fe.id),ut=Be===Fe.id,Kt=Be!==null||!Ue&&ge.length>=6;return c.jsxs("div",{className:"flex items-center gap-2",children:[ut?c.jsx(Z,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin text-muted-foreground"}):c.jsx(ni,{id:`repo-filter-${Fe.id}`,checked:Ue,disabled:Kt,onCheckedChange:wn=>Ke(Fe.id,wn===!0)}),c.jsx(Ur,{htmlFor:`repo-filter-${Fe.id}`,className:`text-sm ${Kt?"text-muted-foreground cursor-not-allowed":"cursor-pointer"}`,children:Fe.displayName})]},Fe.id)})}),Ce.length>0&&!Be&&c.jsx(_e,{variant:"ghost",size:"sm",className:"w-full mt-2",onClick:()=>n({to:"/terminals",search:Fe=>({...Fe,repoIds:void 0}),replace:!0}),children:t("clearFilter")})]})]})]}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:$e,disabled:!l||$===Wo||$===ja,className:"max-sm:px-2 border-transparent text-primary",children:[c.jsx(Z,{icon:M_e,size:14,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"max-sm:hidden",children:t("newTerminal")})]})]})]}),c.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:c.jsx(a_t,{terminals:Et,onTerminalClose:$===Wo||$===ja?void 0:Qe,onTerminalAdd:l&&$!==Wo&&$!==ja?$e:void 0,onTerminalReady:pt,onTerminalResize:at,onTerminalRename:$===Wo||$===ja?void 0:gt,setupImagePaste:E,writeToTerminal:T,sendInputToTerminal:k,taskInfoByCwd:$===Wo?ae:void 0,repoInfoByCwd:$===ja?be:void 0,emptyMessage:$===ja?t("emptyRepos"):$===Wo?t("emptyTasks"):void 0})}),c.jsx(Z_t,{tab:I,open:I!==null,onOpenChange:Fe=>{Fe||D(null)},onSave:Vt,onCreate:it,defaultName:`Tab ${o.length+1}`})]})}),iSt=xa("/terminals/")({component:rSt,validateSearch:e=>({tab:typeof e.tab=="string"?e.tab:void 0,project:typeof e.project=="string"?e.project:void 0,repoIds:typeof e.repoIds=="string"?e.repoIds:void 0})});function sSt(){return{x:0,y:0}}function aSt(e){var t=e.render,n=e.nativeSetDragImage,r=e.getOffset,i=r===void 0?sSt:r,s=document.createElement("div");Object.assign(s.style,{position:"fixed",top:0,left:0,zIndex:nNe,pointerEvents:"none"}),document.body.append(s);var a=t({container:s});queueMicrotask(function(){var u=i({container:s});if(ok()){var d=s.getBoundingClientRect();if(d.width===0)return;s.style.left="-".concat(d.width-1e-4,"px")}n?.(s,u.x,u.y)});function o(){l(),a?.(),document.body.removeChild(s)}var l=oNe({onDragStart:o,onDrop:o})}var oSt=Gy(function(){return ok()&&"ontouchend"in document}),lSt=function(t){var n=t.container,r=n.getBoundingClientRect();return{x:r.width/2,y:r.height/2}};function cSt(e){return function(n){var r=n.container;if(oSt()||aNe())return lSt({container:r});Object.assign(r.style,{borderInlineStart:"".concat(e.x," solid transparent"),borderTop:"".concat(e.y," solid transparent")});var i=window.getComputedStyle(r);if(i.direction==="rtl"){var s=r.getBoundingClientRect();return{x:s.width,y:0}}return{x:0,y:0}}}function xi({className:e,size:t="default",...n}){return c.jsx("div",{"data-slot":"card","data-size":t,className:Ae("film-grain relative ring-foreground/10 text-card-foreground gap-4 overflow-hidden rounded-lg py-4 text-xs/relaxed ring-1 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 *:[img:first-child]:rounded-t-lg *:[img:last-child]:rounded-b-lg group/card flex flex-col",e),style:{background:"var(--gradient-card)"},...n})}function J1({className:e,...t}){return c.jsx("div",{"data-slot":"card-header",className:Ae("gap-1 rounded-t-lg px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]",e),...t})}function e_({className:e,...t}){return c.jsx("div",{"data-slot":"card-title",className:Ae("text-sm font-medium",e),...t})}function uSt({className:e,...t}){return c.jsx("div",{"data-slot":"card-description",className:Ae("text-muted-foreground text-xs/relaxed",e),...t})}function Ms({className:e,...t}){return c.jsx("div",{"data-slot":"card-content",className:Ae("px-4 group-data-[size=sm]/card:px-3",e),...t})}const fNe=x.createContext(null);function dSt({children:e}){const[t,n]=x.useState(null);return c.jsx(fNe.Provider,{value:{activeTask:t,setActiveTask:n},children:e})}function hNe(){const e=x.useContext(fNe);if(!e)throw new Error("useDrag must be used within DragProvider");return e}const pNe=x.createContext(null);function fSt({children:e}){const[t,n]=x.useState(new Set),[r,i]=x.useState(null),s=x.useCallback(u=>{n(d=>{const f=new Set(d);return f.has(u)?f.delete(u):f.add(u),f}),i(u)},[]),a=x.useCallback((u,d)=>{if(!r){n(new Set([u])),i(u);return}const f=d.indexOf(r),h=d.indexOf(u);if(f===-1||h===-1){n(new Set([u])),i(u);return}const[m,g]=f<h?[f,h]:[h,f],y=d.slice(m,g+1);n(v=>{const _=new Set(v);for(const S of y)_.add(S);return _})},[r]),o=x.useCallback(()=>{n(new Set),i(null)},[]),l=x.useCallback(u=>t.has(u),[t]);return c.jsx(pNe.Provider,{value:{selectedIds:t,lastSelectedId:r,toggleSelection:s,selectRange:a,clearSelection:o,isSelected:l},children:e})}function GQ(){const e=x.useContext(pNe);if(!e)throw new Error("useSelection must be used within a SelectionProvider");return e}function m5(){const{data:e}=pD();return x.useMemo(()=>qW(e),[e])}function g5(e,t){const{data:n}=pD();return x.useMemo(()=>BYe(e,n,t),[e,n,t])}function mNe(e,t){const{data:n}=pD();return x.useMemo(()=>$Ye(e,n,t),[e,n,t])}function gNe({task:e,isDragPreview:t,isBlocked:n,isBlocking:r,showTypeLabel:i}){const{t:s}=Ot("tasks"),{setActiveTask:a}=hNe(),{isSelected:o,toggleSelection:l}=GQ(),u=Ni(),d=PWe(),{data:f}=Oy(),h=o(e.id),m=x.useRef(null),[g,y]=x.useState(!1),[v,_]=x.useState(null),[S,E]=x.useState(null),T=!!(e.worktreePath||e.repositoryId||e.type==="scratch"),k=!!e.worktreePath,w=!e.worktreePath&&!!e.repositoryId,A=w?f?.find(P=>P.id===e.repositoryId):null,R=g5(e.dueDate,e.status),I=mNe(e.dueDate,e.status),D=x.useRef(!1);x.useEffect(()=>{const P=m.current;if(!(!P||t))return lk(lNe({element:P,getInitialData:()=>({type:"task",taskId:e.id,status:e.status}),onGenerateDragPreview:({nativeSetDragImage:L})=>{aSt({nativeSetDragImage:L,getOffset:cSt({x:"16px",y:"8px"}),render:({container:M})=>{E(M)}})},onDragStart:()=>{y(!0),a(e),D.current=!0},onDrop:()=>{y(!1),a(null),E(null)}}),h5({element:P,getData:({input:L,element:M})=>{const $={type:"task",taskId:e.id,status:e.status};return uNe($,{input:L,element:M,allowedEdges:["top","bottom"]})},canDrop:({source:L})=>L.data.taskId!==e.id,onDragEnter:({self:L})=>{_(z0(L.data))},onDrag:({self:L})=>{_(z0(L.data))},onDragLeave:()=>{_(null)},onDrop:()=>{_(null)}}))},[e,t,a]);const j=()=>{D.current=!1},F=()=>{if(D.current){D.current=!1;return}u(k?{to:"/tasks/$taskId",params:{taskId:e.id}}:{to:"/tasks",search:P=>({...P,task:e.id}),replace:!0}),D.current=!1},z=c.jsxs("div",{className:"group/card relative",children:[!t&&c.jsx("div",{className:Ae("absolute left-2 top-2 z-20 transition-opacity duration-150",h?"opacity-100":"opacity-0 group-hover/card:opacity-100"),onPointerDown:P=>P.stopPropagation(),children:c.jsx(ni,{checked:h,onCheckedChange:()=>l(e.id)})}),!t&&c.jsx("button",{type:"button",className:Ae("absolute right-2 top-2 z-20 p-0.5 rounded transition-opacity duration-150 hover:bg-muted cursor-pointer",e.pinned?"opacity-100":"opacity-0 group-hover/card:opacity-100"),onPointerDown:P=>P.stopPropagation(),onClick:P=>{P.stopPropagation(),d.mutate({taskId:e.id,pinned:!e.pinned})},title:e.pinned?"Unpin task":"Pin task to top",children:c.jsx(Z,{icon:e.pinned?nD:wE,size:14,strokeWidth:2,className:e.pinned?"text-primary":"text-muted-foreground"})}),c.jsxs(xi,{ref:t?void 0:m,onPointerDown:j,onClick:F,className:Ae("relative cursor-grab active:cursor-grabbing","transition-all duration-200 ease-out","hover:shadow-md hover:scale-[1.02] hover:-translate-y-0.5",g&&"opacity-50",h&&"ring-2 ring-primary bg-primary/5"),children:[v&&c.jsx("div",{className:Ae("absolute left-0 right-0 h-0.5 bg-primary z-10",v==="top"&&"-top-1",v==="bottom"&&"-bottom-1")}),c.jsx(J1,{className:Ae("p-3 pb-1 flex flex-row items-start justify-between gap-2",!t&&"pl-8"),children:c.jsx(e_,{className:"text-sm font-medium leading-tight flex-1",children:e.title})}),c.jsxs(Ms,{className:Ae("p-3 pt-1",!t&&"pl-8"),children:[e.description&&c.jsx("p",{className:"line-clamp-2 text-xs text-muted-foreground",children:e.description}),e.tags.length>0&&c.jsxs("div",{className:"mt-2 flex items-center gap-1 flex-wrap",children:[e.tags.slice(0,3).map(P=>c.jsx("span",{className:"rounded-full border border-border bg-card px-1.5 py-0.5 text-[10px] font-medium",children:P},P)),e.tags.length>3&&c.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",e.tags.length-3]})]}),c.jsxs("div",{className:Ae("flex items-center gap-1 text-xs text-muted-foreground/70 flex-wrap",e.tags.length>0?"mt-1.5":"mt-2"),children:[n&&c.jsxs(c.Fragment,{children:[c.jsxs("span",{className:"inline-flex items-center gap-0.5 whitespace-nowrap text-destructive font-medium",children:[c.jsx(Z,{icon:U$e,size:12,strokeWidth:2}),c.jsx("span",{children:"Blocked"})]}),c.jsx("span",{className:"text-muted-foreground/30",children:"•"})]}),r&&c.jsxs(c.Fragment,{children:[c.jsxs("span",{className:"inline-flex items-center gap-0.5 whitespace-nowrap text-accent font-medium",children:[c.jsx(Z,{icon:wr,size:12,strokeWidth:2}),c.jsx("span",{children:"Blocking"})]}),c.jsx("span",{className:"text-muted-foreground/30",children:"•"})]}),k&&c.jsxs("span",{className:"inline-flex items-center gap-1 whitespace-nowrap",children:[c.jsx(Z,{icon:ef,size:12,strokeWidth:2}),c.jsx("span",{className:"truncate max-w-24",children:e.repoName}),e.prUrl&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-muted-foreground/30",children:"•"}),c.jsx(Z,{icon:ud,size:12,strokeWidth:2,className:"text-foreground"})]})]}),w&&A&&c.jsxs("span",{className:"inline-flex items-center gap-1 whitespace-nowrap",children:[c.jsx(Z,{icon:ef,size:12,strokeWidth:2}),c.jsx("span",{className:"truncate max-w-24",children:A.displayName})]}),e.dueDate&&c.jsxs(c.Fragment,{children:[T&&c.jsx("span",{className:"text-muted-foreground/30",children:"•"}),c.jsxs("span",{className:Ae("inline-flex items-center gap-1 whitespace-nowrap",R?"text-destructive":I?"text-amber-600 dark:text-amber-500":""),children:[c.jsx(Z,{icon:op,size:12,strokeWidth:2}),c.jsx("span",{children:WW(e.dueDate)})]})]}),e.timeEstimate!=null&&c.jsxs(c.Fragment,{children:[(T||e.dueDate)&&c.jsx("span",{className:"text-muted-foreground/30",children:"•"}),c.jsxs("span",{className:"inline-flex items-center gap-0.5 whitespace-nowrap",children:[c.jsx(Z,{icon:ky,size:12,strokeWidth:2}),c.jsxs("span",{children:[e.timeEstimate,"h"]})]})]}),e.priority&&e.priority!=="medium"&&c.jsxs(c.Fragment,{children:[(T||e.dueDate||e.timeEstimate!=null)&&c.jsx("span",{className:"text-muted-foreground/30",children:"•"}),c.jsx("span",{className:Ae("inline-flex items-center gap-0.5 whitespace-nowrap",e.priority==="high"?"text-destructive":"text-muted-foreground/50"),children:c.jsx(Z,{icon:e.priority==="high"?wd:Ts,size:12,strokeWidth:2})})]}),e.recurrenceRule&&c.jsxs(c.Fragment,{children:[(T||e.dueDate||e.timeEstimate!=null)&&c.jsx("span",{className:"text-muted-foreground/30",children:"•"}),c.jsx("span",{className:"inline-flex items-center gap-0.5 whitespace-nowrap",children:c.jsx(Z,{icon:pze,size:12,strokeWidth:2})})]}),!T&&!n&&!r&&e.tags.length===0&&!e.dueDate&&e.timeEstimate==null&&(!e.priority||e.priority==="medium")&&!e.recurrenceRule&&c.jsx("span",{className:"italic",children:"Non-code task"})]}),c.jsx("span",{className:Ae("absolute bottom-1.5 right-2 text-[10px] font-medium transition-opacity duration-200",i?"opacity-100":"opacity-0 group-hover/card:opacity-100"),style:{color:Ewe(e)},children:s(`typeFilter.types.${TC(e)}`)})]})]})]});return c.jsxs(c.Fragment,{children:[z,S&&_i.createPortal(c.jsx("div",{className:"w-72 max-w-[90vw]",children:c.jsx(gNe,{task:e,isDragPreview:!0})}),S)]})}const hSt={TO_DO:"border-t-status-todo",IN_PROGRESS:"border-t-status-in-progress",IN_REVIEW:"border-t-status-in-review",DONE:"border-t-status-done",CANCELED:"border-t-status-canceled"};function Pce({status:e,tasks:t,isMobile:n,blockedTaskIds:r,blockingTaskIds:i,showTypeLabels:s}){const{t:a}=Ot("common"),o=x.useRef(null),[l,u]=x.useState(!1),d=[...t].sort((f,h)=>{const m=f.pinned?1:0,g=h.pinned?1:0;return m!==g?g-m:new Date(h.updatedAt).getTime()-new Date(f.updatedAt).getTime()});return x.useEffect(()=>{const f=o.current;if(f)return h5({element:f,getData:()=>({type:"column",status:e}),canDrop:({source:h})=>h.data.type==="task",onDragEnter:()=>u(!0),onDragLeave:()=>u(!1),onDrop:()=>u(!1)})},[e]),c.jsxs("div",{ref:o,className:Ae("flex flex-col rounded-lg border border-t-4 bg-card",n?"h-full w-full":"h-full w-72 min-w-52 flex-shrink",hSt[e],l&&"ring-2 ring-primary ring-offset-2 ring-offset-background"),children:[!n&&c.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[c.jsx("h3",{className:"text-sm font-medium",children:a(`statuses.${e}`)}),c.jsx("span",{className:"flex h-5 min-w-5 items-center justify-center rounded-full bg-muted px-1.5 text-xs font-medium",children:t.length})]}),c.jsx(hp,{className:"min-h-0 flex-1",children:c.jsx("div",{className:"flex flex-col gap-2 p-2",children:d.map(f=>c.jsx(gNe,{task:f,isBlocked:r?.has(f.id),isBlocking:i?.has(f.id),showTypeLabel:s},f.id))})})]})}function pSt(){const{selectedIds:e,clearSelection:t}=GQ(),n=jWe(),{data:r=[]}=cl(),[i,s]=x.useState(!0),a=e.size,l=x.useMemo(()=>r.filter(f=>e.has(f.id)).some(f=>f.worktreePath),[r,e]),u=()=>{n.mutate({ids:Array.from(e),deleteLinkedWorktrees:i},{onSuccess:()=>{t()}})};return a===0?null:c.jsx("div",{className:Ae("fixed bottom-4 left-1/2 z-40 -translate-x-1/2 rounded-lg border bg-background/95 shadow-lg backdrop-blur-sm","animate-in slide-in-from-bottom-2 duration-200"),children:c.jsxs("div",{className:"flex items-center gap-4 px-4 py-2.5",children:[c.jsxs("span",{className:"text-sm text-muted-foreground",children:[a," task",a!==1?"s":""," selected"]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(_e,{variant:"ghost",size:"sm",onClick:t,children:"Clear"}),c.jsxs(ql,{children:[c.jsx(VQ,{render:c.jsx(_e,{variant:"destructive",size:"sm",disabled:n.isPending}),children:n.isPending?"Deleting...":"Delete"}),c.jsxs(Gl,{children:[c.jsxs(Kl,{children:[c.jsxs(Xl,{children:["Delete ",a," Task",a!==1?"s":""]}),c.jsxs(Ql,{children:["This will permanently delete ",a," task",a!==1?"s":"",". This action cannot be undone."]})]}),l&&c.jsxs("div",{className:"flex items-center gap-2 py-2",children:[c.jsx(ni,{id:"bulk-delete-worktrees",checked:i,onCheckedChange:d=>s(d===!0)}),c.jsx("label",{htmlFor:"bulk-delete-worktrees",className:"cursor-pointer text-sm",children:"Also delete linked worktrees"})]}),c.jsxs(Yl,{children:[c.jsx(Zl,{children:"Cancel"}),c.jsx(cg,{onClick:u,variant:"destructive",disabled:n.isPending,children:n.isPending?"Deleting...":"Delete"})]})]})]})]})]})})}function bNe({taskId:e,links:t}){const[n,r]=x.useState(!1),[i,s]=x.useState(""),[a,o]=x.useState(""),l=Twe(),u=MWe(),d=()=>{const m=i.trim();if(m){try{new URL(m)}catch{rt.error("Invalid URL",{description:"Please enter a valid URL including the scheme (e.g., https://)"});return}l.mutate({taskId:e,url:m,label:a.trim()||void 0},{onSuccess:()=>{s(""),o(""),r(!1)}})}},f=m=>{u.mutate({taskId:e,linkId:m})},h=m=>{m.key==="Enter"?(m.preventDefault(),d()):m.key==="Escape"&&(r(!1),s(""),o(""))};return c.jsxs("div",{className:"space-y-2",children:[t.length>0&&c.jsx("div",{className:"space-y-1.5",children:t.map(m=>c.jsxs("div",{className:"flex items-center gap-2 group",children:[c.jsxs("button",{type:"button",onClick:()=>jl(m.url),className:"flex items-center gap-2 text-sm text-primary hover:underline flex-1 min-w-0",children:[c.jsx(Z,{icon:Ay,size:14,className:"shrink-0"}),c.jsx("span",{className:"truncate",children:m.label||m.url})]}),c.jsx("button",{type:"button",onClick:()=>f(m.id),className:"opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-opacity",title:"Remove link",children:c.jsx(Z,{icon:ks,size:14})})]},m.id))}),n?c.jsxs("div",{className:"space-y-2 pt-1",children:[c.jsx(At,{type:"url",value:i,onChange:m=>s(m.target.value),onKeyDown:h,placeholder:"https://...",className:"h-8 text-sm",autoFocus:!0}),c.jsx(At,{type:"text",value:a,onChange:m=>o(m.target.value),onKeyDown:h,placeholder:"Label (optional)",className:"h-8 text-sm"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(_e,{size:"sm",className:"h-7",onClick:d,disabled:!i.trim()||l.isPending,children:"Add"}),c.jsx(_e,{variant:"outline",size:"sm",className:"h-7",onClick:()=>{r(!1),s(""),o("")},children:"Cancel"})]})]}):c.jsxs("button",{type:"button",onClick:()=>r(!0),className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[c.jsx(Z,{icon:Ic,size:14}),c.jsx("span",{children:"Add link"})]})]})}const Lce={TO_DO:"bg-status-todo/20 text-status-todo",IN_PROGRESS:"bg-status-in-progress/20 text-status-in-progress",IN_REVIEW:"bg-status-in-review/20 text-status-in-review",DONE:"bg-status-done/20 text-status-done",CANCELED:"bg-status-canceled/20 text-status-canceled"};function Mce({title:e,icon:t,count:n,items:r,isAdding:i,onStartAdding:s,onCancelAdding:a,onAdd:o,onRemove:l,filteredTasks:u,searchQuery:d,onSearchChange:f,inputRef:h,addButtonLabel:m,emptyLabel:g}){return c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground mb-2",children:[c.jsx(Z,{icon:t,size:12}),c.jsx("span",{children:e}),n>0&&c.jsxs("span",{className:"text-warning",children:["(",n,")"]})]}),c.jsx("div",{className:"rounded-md border bg-muted/30 min-h-[60px]",children:c.jsxs("div",{className:"p-1.5 space-y-1",children:[r.length>0?r.map(y=>c.jsxs("div",{className:"flex items-center gap-2 rounded bg-background px-2 py-1.5 group",children:[c.jsx("span",{className:Ae("shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",Lce[y.status]),children:y.status.replace("_"," ")}),c.jsx("span",{className:"flex-1 truncate text-xs",children:y.title}),c.jsx("button",{type:"button",onClick:()=>l(y),className:"shrink-0 text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity",children:c.jsx(Z,{icon:Tn,size:12})})]},y.id)):!i&&c.jsx("div",{className:"text-xs text-muted-foreground italic px-2 py-1.5",children:g}),i&&c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(At,{ref:h,value:d,onChange:y=>f(y.target.value),placeholder:"Search tasks...",className:"h-7 text-xs",onKeyDown:y=>{y.key==="Escape"&&a()}}),c.jsx(_e,{variant:"ghost",size:"icon-xs",onClick:a,children:c.jsx(Z,{icon:Tn,size:12})})]}),u.length>0&&c.jsx("div",{className:"max-h-32 overflow-y-auto rounded border bg-background",children:u.map(y=>c.jsxs("button",{type:"button",className:"w-full px-2 py-1.5 text-left text-xs hover:bg-muted flex items-center gap-2",onClick:()=>o(y.id),children:[c.jsx("span",{className:Ae("shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",Lce[y.status]),children:y.status.replace("_"," ")}),c.jsx("span",{className:"truncate",children:y.title})]},y.id))}),d&&u.length===0&&c.jsx("div",{className:"text-xs text-muted-foreground px-2 py-1",children:"No tasks found"})]})]})}),!i&&c.jsxs(_e,{variant:"ghost",size:"sm",className:"mt-1.5 h-7 text-xs text-muted-foreground hover:text-foreground w-full justify-start",onClick:s,children:[c.jsx(Z,{icon:Ic,size:12,className:"mr-1.5"}),m]})]})}function yNe({taskId:e}){const{data:t=[]}=cl(),{data:n,isLoading:r}=FWe(e),i=BWe(),s=$We(),[a,o]=x.useState(""),[l,u]=x.useState(!1),[d,f]=x.useState(!1),h=x.useRef(null),m=x.useRef(null);x.useEffect(()=>{l&&h.current&&h.current.focus()},[l]),x.useEffect(()=>{d&&m.current&&m.current.focus()},[d]);const g=x.useMemo(()=>{const k=new Set([e]);if(n){for(const w of n.blockedBy)k.add(w.id);for(const w of n.blocking)k.add(w.id)}return k},[e,n]),y=x.useMemo(()=>{const k=a.toLowerCase().trim(),w=new Set(["DONE","CANCELED"]);return t.filter(A=>!g.has(A.id)).filter(A=>k?A.title.toLowerCase().includes(k)||A.description?.toLowerCase().includes(k):!0).sort((A,R)=>{const I=w.has(A.status),D=w.has(R.status);return I!==D?I?1:-1:new Date(R.updatedAt).getTime()-new Date(A.updatedAt).getTime()}).slice(0,10)},[t,g,a]),v=k=>{i.mutate({taskId:e,dependsOnTaskId:k},{onSuccess:()=>{o(""),u(!1)}})},_=k=>{i.mutate({taskId:k,dependsOnTaskId:e},{onSuccess:()=>{o(""),f(!1)}})},S=k=>{s.mutate({taskId:e,dependencyId:k.dependencyId})};if(r)return c.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading dependencies..."});const E=n?.blockedBy??[],T=n?.blocking??[];return c.jsxs("div",{className:"grid gap-4 grid-cols-1 sm:grid-cols-2",children:[c.jsx(Mce,{title:"Blocked by",icon:wd,count:E.length,items:E,isAdding:l,onStartAdding:()=>{f(!1),o(""),u(!0)},onCancelAdding:()=>{o(""),u(!1)},onAdd:v,onRemove:S,filteredTasks:y,searchQuery:a,onSearchChange:o,inputRef:h,addButtonLabel:"Add blocker",emptyLabel:"No blockers"}),c.jsx(Mce,{title:"Blocking",icon:Ts,count:T.length,items:T,isAdding:d,onStartAdding:()=>{u(!1),o(""),f(!0)},onCancelAdding:()=>{o(""),f(!1)},onAdd:_,onRemove:S,filteredTasks:y,searchQuery:a,onSearchChange:o,inputRef:m,addButtonLabel:"Add blocked task",emptyLabel:"Not blocking any"})]})}function mSt(e){return e==="application/pdf"?Y_e:e.startsWith("image/")?U_e:$_e}function Fce(e){return e==="application/pdf"||e.startsWith("image/")}function gSt(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function vNe({taskId:e}){const{data:t=[],isLoading:n}=zYe(e),r=SEe(),i=UYe(),s=x.useRef(null),[a,o]=x.useState(!1),[l,u]=x.useState(null),[d,f]=x.useState(null),h=x.useCallback(async E=>{if(!(!E||E.length===0)){u(null);for(const T of Array.from(E))try{await r.mutateAsync({taskId:e,file:T})}catch(k){u(k instanceof Error?k.message:"Upload failed")}}},[e,r]),m=x.useCallback(E=>{E.preventDefault(),E.stopPropagation(),o(!0)},[]),g=x.useCallback(E=>{E.preventDefault(),E.stopPropagation(),o(!1)},[]),y=x.useCallback(E=>{E.preventDefault(),E.stopPropagation(),o(!1),h(E.dataTransfer.files)},[h]),v=async E=>{d?.id===E.id&&f(null);try{await i.mutateAsync({taskId:e,attachmentId:E.id})}catch{}},_=E=>{const T=o4(e,E.id);window.open(T,"_blank")},S=E=>{Fce(E.mimeType)?f(T=>T?.id===E.id?null:E):_(E)};return n?c.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading attachments..."}):c.jsxs("div",{className:"space-y-3",children:[d&&c.jsxs("div",{className:"rounded border bg-card overflow-hidden",children:[c.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 border-b border-border text-xs",children:[c.jsx("span",{className:"text-muted-foreground truncate",children:d.filename}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(_e,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",onClick:()=>_(d),title:"Download",children:c.jsx(Z,{icon:cse,size:12})}),c.jsx(_e,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",onClick:()=>f(null),title:"Close preview",children:c.jsx(Z,{icon:Tn,size:12})})]})]}),c.jsx("div",{className:"bg-muted",children:d.mimeType==="application/pdf"?c.jsx("iframe",{src:`${o4(e,d.id)}?inline=1`,className:"w-full border-0",style:{height:"500px"},title:d.filename}):d.mimeType.startsWith("image/")?c.jsx("div",{className:"p-4 flex items-center justify-center",children:c.jsx("img",{src:o4(e,d.id),alt:d.filename,className:"max-w-full max-h-[400px] object-contain"})}):null})]}),c.jsxs("div",{className:Ae("border-2 border-dashed rounded-lg p-4 text-center transition-colors cursor-pointer",a?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-muted-foreground/50"),onDragOver:m,onDragLeave:g,onDrop:y,onClick:()=>s.current?.click(),children:[c.jsx("input",{ref:s,type:"file",multiple:!0,className:"hidden",onChange:E=>h(E.target.files),accept:".pdf,.png,.jpg,.jpeg,.gif,.webp,.svg,.txt,.md,.doc,.docx,.xls,.xlsx,.csv"}),c.jsx(Z,{icon:J_e,size:20,className:"mx-auto text-muted-foreground mb-1"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:r.isPending?"Uploading...":"Drop files here or click to upload"}),c.jsx("p",{className:"text-[10px] text-muted-foreground/70 mt-0.5",children:"PDF, images, documents, spreadsheets (max 50MB)"})]}),l&&c.jsx("p",{className:"text-xs text-destructive",children:l}),t.length>0&&c.jsx("div",{className:"space-y-1.5",children:t.map(E=>{const T=mSt(E.mimeType),k=d?.id===E.id;return c.jsxs("div",{className:Ae("flex items-center gap-2 p-2 rounded border transition-colors group",Fce(E.mimeType)?"cursor-pointer":"cursor-default",k?"bg-primary/10 border-primary/30":"bg-card hover:bg-accent/50"),onClick:()=>S(E),children:[c.jsx(Z,{icon:T,size:16,className:"text-muted-foreground shrink-0"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("p",{className:"text-xs font-medium truncate",children:E.filename}),c.jsx("p",{className:"text-[10px] text-muted-foreground",children:gSt(E.size)})]}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[c.jsx(_e,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:w=>{w.stopPropagation(),_(E)},title:"Download",children:c.jsx(Z,{icon:cse,size:14})}),c.jsx(_e,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-destructive hover:text-destructive",onClick:w=>{w.stopPropagation(),v(E)},disabled:i.isPending,title:"Delete",children:c.jsx(Z,{icon:ks,size:14})})]})]},E.id)})}),t.length===0&&!n&&c.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No attachments"})]})}function bSt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function ySt(e){const t=e.trim().split(/\s+/).slice(0,4).join(" "),n=bSt(t);if(!n)return"";const r=Math.random().toString(36).substring(2,6);return`${n}-${r}`}function vSt({task:e,open:t,onOpenChange:n}){const r=Ni(),i=It(),[s,a]=x.useState(!1),[o,l]=x.useState(!1),[u,d]=x.useState(""),[f,h]=x.useState(""),[m,g]=x.useState(""),[y,v]=x.useState(""),[_,S]=x.useState(""),[E,T]=x.useState(""),[k,w]=x.useState("default"),[A,R]=x.useState("claude"),[I,D]=x.useState(null),[j,F]=x.useState("browse"),[z,P]=x.useState(""),[L,M]=x.useState(null),[$,W]=x.useState(!1),[Y,q]=x.useState(null),{data:K}=Iwe(),{data:X}=uD(),{data:U}=NC(),{data:J}=A1(),{data:te}=Oy(),{data:ee}=Mc(),{data:oe,isLoading:ae}=OW(u||null),se=I?te?.find(xe=>xe.id===I):null,ue=x.useMemo(()=>!I||!ee?null:ee.find(xe=>xe.repositories.some(ye=>ye.id===I))??null,[I,ee]),de=x.useMemo(()=>{if(!te)return[];if(se&&z===se.displayName||!z.trim())return te;const xe=z.toLowerCase();return te.filter(ye=>ye.displayName.toLowerCase().includes(xe)||ye.path.toLowerCase().includes(xe))},[te,z,se]),{filteredLocalBranches:ce,filteredRemoteBranches:Ee}=x.useMemo(()=>{const xe=oe?.branches??[],ye=oe?.remoteBranches??[];if(!m.trim()||m===f)return{filteredLocalBranches:xe,filteredRemoteBranches:ye};const De=m.toLowerCase();return{filteredLocalBranches:xe.filter(ve=>ve.toLowerCase().includes(De)),filteredRemoteBranches:ye.filter(ve=>ve.toLowerCase().includes(De))}},[oe?.branches,oe?.remoteBranches,m,f]);x.useEffect(()=>{t&&(S(ySt(e.title)),T(e.prefix||""))},[t,e.title,e.prefix]),x.useEffect(()=>{te&&te.length>0?F("saved"):F("browse")},[te]),x.useEffect(()=>{if(t){const xe=te&&te.length>0?e.repositoryId?te.find(De=>De.id===e.repositoryId)??te[0]:te[0]:null,ye=xe&&ee?ee.find(De=>De.repositories.some(ve=>ve.id===xe.id)):null;if(xe?.defaultAgent?R(xe.defaultAgent):ye?.defaultAgent?R(ye.defaultAgent):U&&R(U),xe?.opencodeModel?q(xe.opencodeModel):ye?.opencodeModel?q(ye.opencodeModel):q(J||null),te&&te.length>0){const De=e.repositoryId?te.find(ve=>ve.id===e.repositoryId)??te[0]:te[0];D(De.id),d(De.path),P(De.displayName),F("saved")}e.description?.trim()?w("plan"):w("default")}},[t,te,ee,U,J,e.description,e.repositoryId]),x.useEffect(()=>{if(oe){const ye=te?.find(Oe=>Oe.id===I)?.lastBaseBranch,De=[...oe.branches,...oe.remoteBranches??[]],ve=ye&&De.includes(ye)?ye:oe.defaultBranch||oe.branches[0]||"main";h(ve),g(ve)}else h(""),g("")},[oe,u,te,I]);const Ie=async xe=>{M(null),W(!0);try{if(!(await Rwe(xe)).isGitRepo){M("Selected folder is not a git repository"),W(!1);return}d(xe);const De=te?.find(ve=>ve.path===xe);D(De?De.id:null)}catch(ye){M(ye instanceof Error?ye.message:"Validation failed")}finally{W(!1)}},fe=async xe=>{if(xe.preventDefault(),!!u){l(!0);try{const ye=u.split("/").pop()||"repo",De=y.trim()||_,ve=E.trim()?`${E.trim().replace(/\/+$/,"")}/${De}`:De,Oe=`${K}/${ve}`,Be=A==="claude"?se?.claudeOptions??ue?.claudeOptions:se?.opencodeOptions??ue?.opencodeOptions;await ht(`/api/tasks/${e.id}/initialize-worktree`,{method:"POST",body:JSON.stringify({agent:A,aiMode:k,repoPath:u,repoName:ye,baseBranch:f||"main",branch:ve,prefix:E.trim()||void 0,worktreePath:Oe,copyFiles:se?.copyFiles||void 0,startupScript:[ue?.startupScript,se?.startupScript].filter(Boolean).join(`
137
+ ${e.directory}`:e.name,children:[d&&c.jsx("div",{className:Ae("absolute top-0 bottom-0 w-0.5 bg-primary z-10",d==="left"&&"-left-1",d==="right"&&"-right-1")}),e.directory&&c.jsx(Z,{icon:Zs,size:12,strokeWidth:2,className:"shrink-0 opacity-60"}),e.name,n&&c.jsx("button",{onClick:y=>{y.stopPropagation(),i()},onPointerDown:y=>y.stopPropagation(),className:"ml-1 rounded opacity-0 hover:bg-muted group-hover:opacity-100",children:c.jsx(Z,{icon:Tn,size:12,strokeWidth:2})})]})}function Q_t({tabs:e,activeTabId:t,onTabSelect:n,onTabClose:r,onTabCreate:i,onTabEdit:s,onTabReorder:a}){const o=x.useRef(null),l=x.useRef(null),[u,d]=x.useState(!1),[f,h]=x.useState(!1),[m,g]=x.useState(!0),y=x.useCallback(()=>{const S=o.current;if(!S)return;const{scrollLeft:E,scrollWidth:T,clientWidth:k}=S;d(E>0),h(E+k<T-1)},[]);x.useEffect(()=>{const S=l.current,E=o.current;if(!S||!E)return;const T=new IntersectionObserver(([k])=>{g(k.isIntersecting)},{root:E,threshold:.9});return T.observe(S),()=>T.disconnect()},[]),x.useEffect(()=>{const S=o.current;if(!S)return;y(),S.addEventListener("scroll",y);const E=new ResizeObserver(y);return E.observe(S),()=>{S.removeEventListener("scroll",y),E.disconnect()}},[y]),x.useEffect(()=>{y()},[e,y]);const v=x.useCallback(()=>{o.current?.scrollTo({left:0,behavior:"smooth"})},[]),_=x.useCallback(()=>{const S=o.current;S&&S.scrollTo({left:S.scrollWidth,behavior:"smooth"})},[]);return c.jsxs("div",{className:"flex items-center",children:[u&&c.jsx(_e,{variant:"ghost",size:"icon-xs",onClick:v,className:"shrink-0",children:c.jsx(Z,{icon:xf,size:14,strokeWidth:2})}),c.jsxs("div",{ref:o,className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto scrollbar-none",children:[e.map(S=>c.jsx(X_t,{tab:S,isActive:S.id===t,canClose:e.length>1,onSelect:()=>n(S.id),onClose:()=>r(S.id),onEdit:()=>s(S),onReorder:a},S.id)),c.jsx("span",{ref:l,children:c.jsx(_e,{variant:"ghost",size:"icon-xs",onClick:i,className:"shrink-0",children:c.jsx(Z,{icon:sx,size:14,strokeWidth:2})})})]}),f&&c.jsx(_e,{variant:"ghost",size:"icon-xs",onClick:_,className:"shrink-0",children:c.jsx(Z,{icon:Bl,size:14,strokeWidth:2})}),!m&&c.jsx(_e,{variant:"ghost",size:"icon-xs",onClick:i,className:"shrink-0",children:c.jsx(Z,{icon:sx,size:14,strokeWidth:2})})]})}function Z_t({tab:e,open:t,onOpenChange:n,onSave:r,onCreate:i,defaultName:s=""}){const{t:a}=Ot("terminals"),[o,l]=x.useState(""),[u,d]=x.useState(null),[f,h]=x.useState(!1),m=!e&&i;x.useEffect(()=>{t&&(e?(l(e.name),d(e.directory??null)):(l(s),d(null)))},[t,e,s]);const g=()=>{if(m){i(o.trim(),u??void 0),n(!1);return}if(!e)return;const E={};o.trim()&&o.trim()!==e.name&&(E.name=o.trim()),u!==(e.directory??null)&&(E.directory=u),Object.keys(E).length>0&&r(e.id,E),n(!1)},y=E=>{E.key==="Enter"&&(E.preventDefault(),g())},v=()=>{d(null)},_=E=>{d(E)},S=u?u.split("/").pop():null;return c.jsxs(c.Fragment,{children:[c.jsx(Ya,{open:t,onOpenChange:n,children:c.jsxs(Xa,{className:"sm:max-w-md",children:[c.jsx(Lo,{children:c.jsx(Mo,{children:a(m?"newTab.title":"editTab.title")})}),c.jsxs(qh,{className:"mt-4",children:[c.jsxs($n,{children:[c.jsx(zn,{htmlFor:"tabName",children:a("editTab.name")}),c.jsx(At,{id:"tabName",value:o,onChange:E=>l(E.target.value),onKeyDown:y,placeholder:a("editTab.namePlaceholder"),autoFocus:!0})]}),c.jsxs($n,{children:[c.jsx(zn,{children:a("editTab.directory")}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(_e,{type:"button",variant:"outline",className:"flex-1 justify-start font-normal",onClick:()=>h(!0),children:[c.jsx(Z,{icon:Zs,size:14,strokeWidth:2,className:"mr-2 shrink-0"}),S?c.jsx("span",{className:"truncate font-mono text-xs",children:u}):c.jsx("span",{className:"text-muted-foreground",children:a("editTab.directoryPlaceholder")})]}),u&&c.jsx(_e,{type:"button",variant:"ghost",size:"icon",onClick:v,title:a("editTab.clearDirectory"),children:c.jsx(Z,{icon:Tn,size:14,strokeWidth:2})})]})]})]}),c.jsxs(wC,{className:"mt-4",children:[c.jsx(SC,{render:c.jsx(_e,{variant:"outline",type:"button"}),children:a("editTab.cancel")}),c.jsx(_e,{onClick:g,disabled:!o.trim(),children:a(m?"newTab.create":"editTab.save")})]})]})}),c.jsx(yh,{open:f,onOpenChange:h,onSelect:_,initialPath:u??void 0})]})}const J_t=Ym("h-5 gap-1 rounded-full border border-transparent px-2 py-0.5 text-[0.625rem] font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-2.5! inline-flex items-center justify-center w-fit whitespace-nowrap shrink-0 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-colors overflow-hidden group/badge",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 [a]:hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 text-destructive dark:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground bg-input/20 dark:bg-input/30",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function ir({className:e,variant:t="default",render:n,...r}){return wWe({defaultTagName:"span",props:gd({className:Ae(J_t({className:e,variant:t}))},r),render:n,state:{slot:"badge",variant:t}})}function qQ({value:e,onChange:t,options:n,allLabel:r,showInbox:i=!0}){const{t:s}=Ot("tasks"),[a,o]=x.useState(!1),[l,u]=x.useState(""),d=x.useRef(null),{data:f=[]}=Mc(),{data:h=[]}=cl(),m=n??f.map(w=>({id:w.id,name:w.name,count:w.taskCount})),g=!!n,y=x.useMemo(()=>{if(g)return 0;const w=new Set,A=new Set;for(const R of f)for(const I of R.repositories)w.add(I.id),A.add(I.path);return h.filter(R=>!R.projectId&&(!R.repositoryId||!w.has(R.repositoryId))&&(!R.repoPath||!A.has(R.repoPath))).length},[h,f,g]),v=m.filter(w=>w.name.toLowerCase().includes(l.toLowerCase()));x.useEffect(()=>{a&&setTimeout(()=>d.current?.focus(),0)},[a]);const _=w=>{t(w),o(!1)},S=w=>{w.stopPropagation(),t(null)},E=e?m.find(w=>w.id===e):null,T=e==="inbox"?"Inbox":E?.name??null,k=r??s("allProjects");return c.jsxs(O1,{open:a,onOpenChange:o,children:[c.jsxs(R1,{render:c.jsx(_e,{variant:"outline",size:"sm",className:Ae("shrink-0 gap-1.5 h-7 px-2",e&&"pr-1")}),children:[c.jsx(Z,{icon:Ty,size:12,strokeWidth:2,className:"text-muted-foreground"}),e?c.jsxs(c.Fragment,{children:[c.jsxs(ir,{variant:"secondary",className:"h-5 px-1.5 text-[10px] gap-0.5",children:[T,e==="inbox"?` (${y})`:E?.count!==void 0?` (${E.count})`:""]}),c.jsx("button",{onClick:S,className:"ml-0.5 p-0.5 hover:text-destructive transition-colors",children:c.jsx(Z,{icon:Tn,size:12})})]}):c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-xs",children:k}),c.jsx(Z,{icon:Ts,size:12,strokeWidth:2,className:"text-muted-foreground"})]})]}),c.jsxs(I1,{align:"start",className:"w-56 p-0",children:[c.jsx("div",{className:"p-2 border-b",children:c.jsx(At,{ref:d,value:l,onChange:w=>u(w.target.value),placeholder:s("searchProjects"),className:"h-7 text-xs"})}),c.jsxs("div",{className:"max-h-48 overflow-y-auto py-1",children:[c.jsxs("button",{className:Ae("w-full px-3 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground flex items-center gap-2",!e&&"bg-accent text-accent-foreground"),onClick:()=>_(null),children:[c.jsx("span",{className:"w-3.5 shrink-0",children:!e&&c.jsx(Z,{icon:hr,size:14,className:"text-primary"})}),c.jsx("span",{className:"flex-1 truncate",children:k})]}),v.map(w=>{const A=e===w.id;return c.jsxs("button",{className:Ae("group w-full px-3 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground flex items-center gap-2",A&&"bg-accent text-accent-foreground"),onClick:()=>_(w.id),children:[c.jsx("span",{className:"w-3.5 shrink-0",children:A&&c.jsx(Z,{icon:hr,size:14,className:"text-primary"})}),c.jsx("span",{className:"flex-1 truncate",children:w.name}),w.count!==void 0&&c.jsx("span",{className:Ae("text-muted-foreground group-hover:text-accent-foreground text-[10px]",A&&"text-accent-foreground"),children:w.count})]},w.id)}),!g&&i&&"inbox".includes(l.toLowerCase())&&c.jsxs("button",{className:Ae("group w-full px-3 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground flex items-center gap-2",e==="inbox"&&"bg-accent text-accent-foreground"),onClick:()=>_("inbox"),children:[c.jsx("span",{className:"w-3.5 shrink-0",children:e==="inbox"&&c.jsx(Z,{icon:hr,size:14,className:"text-primary"})}),c.jsx("span",{className:"flex-1 truncate",children:"Inbox"}),c.jsx("span",{className:Ae("text-muted-foreground group-hover:text-accent-foreground text-[10px]",e==="inbox"&&"text-accent-foreground"),children:y})]}),v.length===0&&(g||!"inbox".includes(l.toLowerCase()))&&c.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground text-center",children:s("noProjectsFound")})]})]})]})}function eSt(e){return{id:e.id,name:e.name,cwd:e.cwd,status:e.status,exitCode:e.exitCode,cols:e.cols,rows:e.rows,createdAt:e.createdAt,tabId:e.tabId??void 0,positionInTab:e.positionInTab}}function tSt(e){return{id:e.id,name:e.name,position:e.position,directory:e.directory??void 0,createdAt:e.createdAt}}function p5(e={}){const t=dq();return{get terminals(){return t.terminals.map(eSt)},get terminalsLoaded(){return t.terminalsLoaded},get tabs(){return t.tabs.map(tSt)},get connected(){return t.connected},get newTerminalIds(){return t.newTerminalIds},createTerminal:t.createTerminal,destroyTerminal:t.destroyTerminal,recreateTerminal:t.recreateTerminal,writeToTerminal:t.writeToTerminal,sendInputToTerminal:t.sendInputToTerminal,resizeTerminal:t.resizeTerminal,renameTerminal:t.renameTerminal,clearTerminalBuffer:t.clearTerminalBuffer,assignTerminalToTab:t.assignTerminalToTab,createTab:t.createTab,updateTab:t.updateTab,deleteTab:t.deleteTab,reorderTab:t.reorderTab,attachXterm:t.attachXterm,setupImagePaste:t.setupImagePaste,consumePendingStartup:t.consumePendingStartup,clearStartingUp:t.clearStartingUp}}const dNe="task-shell:";function Ice({taskId:e,taskName:t,cwd:n,className:r}){const i=`${dNe}${e}`,[s,a]=x.useState(null),[o,l]=x.useState(!1),u=x.useRef(null),d=x.useRef(null),f=x.useRef(!1),h=x.useRef(!1),{resolvedTheme:m}=ol(),g=m==="dark",{terminals:y,terminalsLoaded:v,connected:_,createTerminal:S,attachXterm:E,resizeTerminal:T,setupImagePaste:k,writeToTerminal:w,recreateTerminal:A}=p5(),R=x.useRef(E),I=x.useRef(k);x.useEffect(()=>{R.current=E},[E]),x.useEffect(()=>{I.current=k},[k]);const D=s?y.find($=>$.id===s):null,j=D?.status;x.useEffect(()=>{f.current=!1,h.current=!1,a(null),l(!1)},[n]),x.useEffect(()=>{if(!_||!n||!v)return;const $=y.find(W=>W.tabId===i);if($){Yt.taskTerminal.debug("Found existing shell terminal",{id:$.id,shellTabId:i}),a($.id),l(!1);return}if(!f.current&&u.current){Yt.taskTerminal.info("Creating shell terminal",{cwd:n,shellTabId:i}),f.current=!0,l(!0);const{cols:W,rows:Y}=u.current;S({name:`${t} (shell)`,cols:W,rows:Y,cwd:n,tabId:i,taskId:e})}},[_,n,v,y,i,t,e,S]),x.useEffect(()=>{if(!n)return;const $=y.find(Y=>Y.tabId===i);if(!$)return;const W=s&&y.some(Y=>Y.id===s);(!s||!W)&&(a($.id),l(!1),s&&!W&&(h.current=!1))},[y,n,s,i]),x.useEffect(()=>{if(!s||!u.current||!d.current||h.current)return;const $=()=>{requestAnimationFrame(()=>{})},W=R.current(s,u.current,{onAttached:$}),Y=I.current(d.current,s);return h.current=!0,()=>{W(),Y(),h.current=!1}},[s]);const F=x.useCallback($=>{u.current=$},[]),z=x.useCallback(($,W)=>{s&&T(s,$,W)},[s,T]),P=x.useCallback($=>{d.current=$},[]),L=x.useCallback($=>{s&&w(s,$)},[s,w]),M=x.useCallback(()=>{s&&(h.current=!1,f.current=!1,a(null),A(s))},[s,A]);return n?c.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[!_&&c.jsx("div",{className:"shrink-0 px-2 py-1 bg-muted-foreground/20 text-muted-foreground text-xs",children:"Connecting to terminal server..."}),j==="error"&&c.jsx("div",{className:"shrink-0 px-2 py-1 bg-destructive/20 text-destructive text-xs",children:"Terminal failed to start. The worktree directory may not exist."}),j==="exited"&&c.jsxs("div",{className:"shrink-0 px-2 py-1 bg-muted text-muted-foreground text-xs",children:["Terminal exited (code: ",D?.exitCode,")"]}),c.jsxs("div",{className:"relative min-h-0 min-w-0 flex-1",children:[c.jsx(ER,{className:Ae("h-full w-full overflow-hidden p-2 bg-terminal-background",r),onReady:F,onResize:z,onContainerReady:P,terminalId:s??void 0,setupImagePaste:k,onSend:L,onReset:s?M:void 0}),o&&!s&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-terminal-background",children:c.jsxs("div",{className:"flex flex-col items-center gap-3",children:[c.jsx(Z,{icon:Nt,size:24,strokeWidth:2,className:Ae("animate-spin",g?"text-white/50":"text-black/50")}),c.jsx("span",{className:Ae("font-mono text-sm",g?"text-white/50":"text-black/50"),children:"Initializing terminal..."})]})})]}),c.jsx("div",{className:"h-2 shrink-0 bg-terminal-background"}),c.jsx(JE,{onSend:L})]}):c.jsx("div",{className:Ae("flex h-full items-center justify-center text-muted-foreground text-sm bg-terminal-background",r),children:"No worktree path configured for this task"})}function f6(e){return{id:e.id,name:e.name,cwd:e.cwd,status:e.status,exitCode:e.exitCode??void 0,cols:e.cols,rows:e.rows,createdAt:e.createdAt,tabId:e.tabId??void 0,positionInTab:e.positionInTab}}function nSt(e,t){return{id:e.id,name:e.name,layout:"single",position:t,directory:e.directory??void 0}}const Wo="all-tasks",ja="all-repos",Dce=["IN_PROGRESS","IN_REVIEW"],jce="fulcrum:lastTerminalTab",rSt=Py(function(){const{t}=Ot("terminals"),n=Ni(),{tab:r,project:i,repoIds:s}=aC({from:"/terminals/"}),{terminals:a,tabs:o,connected:l,createTerminal:u,destroyTerminal:d,renameTerminal:f,assignTerminalToTab:h,createTab:m,updateTab:g,deleteTab:y,reorderTab:v,attachXterm:_,resizeTerminal:S,setupImagePaste:E,writeToTerminal:T,sendInputToTerminal:k,newTerminalIds:w,pendingTabCreation:A,lastCreatedTabId:R}=dq(),[I,D]=x.useState(null),{getFocusedTerminal:j,selectedRepositoryIds:F,setSelectedRepositories:z,isLoading:P}=fCe(),L=x.useMemo(()=>o.map(Fe=>Fe.id),[o]),M=r&&(L.includes(r)||r===Wo||r===ja),$=M?r:o[0]?.id??null,W=x.useCallback(Fe=>{n({to:"/terminals",search:{tab:Fe,project:Fe===Wo?i:void 0,repoIds:Fe===ja?s:void 0},replace:!0})},[n,i,s]),Y=x.useCallback(Fe=>{n({to:"/terminals",search:Ue=>({...Ue,project:Fe}),replace:!0})},[n]),q=jy();x.useEffect(()=>mx(()=>({lastCreatedTabId:q.lastCreatedTabId,pendingTabCreation:q.pendingTabCreation}),({lastCreatedTabId:Ue})=>{Ue&&(Yt.terminal.info("MobX reaction: lastCreatedTabId changed",{tabId:Ue}),W(Ue),setTimeout(()=>{q.clearLastCreatedTabId(),Ye.current++;const ut=`Terminal ${Ye.current}`;Yt.terminal.debug("Creating terminal in new tab",{tabId:Ue,name:ut}),u({name:ut,cols:80,rows:24,tabId:Ue,positionInTab:0})},150))},{fireImmediately:!0}),[q,W,u]),x.useEffect(()=>{if(Yt.terminal.debug("Redirect effect running",{tabsLength:o.length,isValidTab:M,pendingTabCreation:A,lastCreatedTabId:R}),o.length!==0&&!(A||R)&&!M){const Fe=localStorage.getItem(jce),Ue=Fe&&(o.some(ut=>ut.id===Fe)||Fe===Wo||Fe===ja)?Fe:o[0].id;Yt.terminal.debug("Redirecting to tab",{targetTab:Ue}),n({to:"/terminals",search:{tab:Ue},replace:!0})}},[o,M,R,A,n]),x.useEffect(()=>{$&&localStorage.setItem(jce,$)},[$]);const{data:K=[],status:X}=cl(),{data:U=[]}=Oy(),{data:J=[]}=Mc(),te=x.useMemo(()=>{const Fe=new Map;for(const Ue of U)Fe.set(Ue.path,Ue.id);return Fe},[U]),ee=x.useMemo(()=>new Set(K.filter(Fe=>Dce.includes(Fe.status)&&Fe.worktreePath).map(Fe=>Fe.worktreePath)),[K]),oe=x.useMemo(()=>new Set(K.filter(Fe=>Fe.worktreePath).map(Fe=>Fe.worktreePath)),[K]),ae=x.useMemo(()=>{const Fe=new Map;for(const Ue of K)Ue.worktreePath&&Ue.repoPath&&Ue.repoName&&Ue.baseBranch?Fe.set(Ue.worktreePath,{taskId:Ue.id,repoId:te.get(Ue.repoPath),repoName:Ue.repoName,title:Ue.title,repoPath:Ue.repoPath,worktreePath:Ue.worktreePath,baseBranch:Ue.baseBranch,branch:Ue.branch,prUrl:Ue.prUrl,pinned:Ue.pinned}):Ue.worktreePath&&Ue.type==="scratch"&&Fe.set(Ue.worktreePath,{taskId:Ue.id,repoId:void 0,repoName:"",title:Ue.title,repoPath:"",worktreePath:Ue.worktreePath,baseBranch:"",branch:null,prUrl:Ue.prUrl,pinned:Ue.pinned});return Fe},[K,te]),se=x.useMemo(()=>{const Fe=new Map;for(const Ue of J)Fe.set(Ue.id,Ue.name);return Fe},[J]),ue=x.useMemo(()=>{const Fe=new Map;for(const Ue of J)if(Ue.repositories)for(const ut of Ue.repositories)Fe.set(ut.id,Ue.id);return Fe},[J]),de=x.useMemo(()=>{const Fe=new Map;for(const Ue of J)if(Ue.repositories)for(const ut of Ue.repositories)Fe.set(ut.path,Ue.id);return Fe},[J]),ce=x.useCallback(Fe=>Fe.projectId?Fe.projectId:Fe.repositoryId?ue.get(Fe.repositoryId)??null:Fe.repoPath?de.get(Fe.repoPath)??null:null,[ue,de]),Ee=x.useMemo(()=>{const Fe=new Set;for(const ut of K)if(Dce.includes(ut.status)){const Kt=ce(ut);Kt&&Fe.add(Kt)}const Ue=[];for(const ut of Fe){const Kt=se.get(ut)??ut;Ue.push({id:ut,name:Kt})}return Ue.sort((ut,Kt)=>ut.name.localeCompare(Kt.name)),Ue},[K,se,ce]),Ie=i,fe=x.useMemo(()=>{const Fe=new Map;for(const Ue of U)Fe.set(Ue.path,Ue.id);return Fe},[U]),be=x.useMemo(()=>{const Fe=new Map;for(const Ue of U)Fe.set(Ue.path,{repoId:Ue.id,repoName:Ue.displayName,repoPath:Ue.path});return Fe},[U]),ge=x.useMemo(()=>s?.split(",").filter(Boolean)??[],[s]),Ce=x.useMemo(()=>{const Fe=new Set(U.map(Ue=>Ue.id));return ge.filter(Ue=>Fe.has(Ue))},[ge,U]),[Re,xe]=x.useState(!1),[ye,De]=x.useState(""),ve=x.useRef(null),Oe=x.useMemo(()=>{if(!ye)return U;const Fe=ye.toLowerCase();return U.filter(Ue=>Ue.displayName.toLowerCase().includes(Fe))},[U,ye]);x.useEffect(()=>{Re?setTimeout(()=>ve.current?.focus(),0):De("")},[Re]);const[Be,Te]=x.useState(null),je=x.useRef(0),ie=400,Ke=x.useCallback((Fe,Ue)=>{Yt.projectTerminals.info("toggleRepoFilter called",{repoId:Fe,checked:Ue});const ut=s?.split(",").filter(Boolean)??[];if(Ue&&ut.length>=6)return;Ue&&(Yt.projectTerminals.info("Setting loadingRepoId",{repoId:Fe}),je.current=Date.now(),Te(Fe));const Kt=Ue?[...ut,Fe]:ut.filter(wn=>wn!==Fe);n({to:"/terminals",search:wn=>({...wn,repoIds:Kt.length>0?Kt.join(","):void 0}),replace:!0})},[n,s]),lt=x.useRef(!1);x.useEffect(()=>{if($!==ja){lt.current=!1;return}if(P||lt.current||s||F.length===0)return;const Fe=new Set(U.map(ut=>ut.id)),Ue=F.filter(ut=>Fe.has(ut));Ue.length!==0&&(lt.current=!0,n({to:"/terminals",search:ut=>({...ut,repoIds:Ue.join(",")}),replace:!0}))},[$,s,F,U,n,P]),x.useEffect(()=>{if($!==ja||P||!s&&!lt.current&&F.length>0)return;const Fe=ge.join(","),Ue=F.join(",");Fe!==Ue&&z(ge)},[$,ge,F,z,P,s]),x.useEffect(()=>{if($===ja&&l){Yt.projectTerminals.debug("Auto-create effect running",{selectedRepoIds:ge,terminalCount:a.length,terminalCwds:a.map(Fe=>Fe.cwd)});for(const Fe of ge){const Ue=U.find(wn=>wn.id===Fe);if(!Ue?.path)continue;const ut=Ue.path;if(a.find(wn=>wn.cwd===ut&&!wn.tabId)){Yt.projectTerminals.debug("Terminal already exists for repo",{repoId:Fe,repoPath:ut});continue}Yt.projectTerminals.info("Creating terminal for repo",{repoId:Fe,repoPath:ut}),u({name:Ue.displayName,cwd:ut,cols:80,rows:24})}}},[$,ge,U,a,l,u]);const Rt=x.useRef(new Map),Ye=x.useRef(0),ct=x.useRef(!1),Ve=x.useRef(!1),Et=x.useMemo(()=>{if($===Wo){const Fe=new Set;return a.filter(Ue=>Ue.cwd&&ee.has(Ue.cwd)&&!Ue.tabId).sort((Ue,ut)=>{const Kt=Ue.name.endsWith("(shell)")?1:0,wn=ut.name.endsWith("(shell)")?1:0;return Kt-wn}).filter(Ue=>Fe.has(Ue.cwd)?!1:(Fe.add(Ue.cwd),!0)).filter(Ue=>{if(!Ie)return!0;const ut=K.find(wn=>wn.worktreePath===Ue.cwd);return ut?ce(ut)===Ie:!1}).sort((Ue,ut)=>{const Kt=K.find(pr=>pr.worktreePath===Ue.cwd),wn=K.find(pr=>pr.worktreePath===ut.cwd);return!Kt||!wn?0:new Date(wn.createdAt).getTime()-new Date(Kt.createdAt).getTime()}).map(f6)}return $===ja?ge.length===0?[]:a.filter(Fe=>Fe.cwd&&!Fe.tabId&&fe.has(Fe.cwd)).filter(Fe=>{const Ue=fe.get(Fe.cwd);return Ue&&ge.includes(Ue)}).map(f6):a.filter(Fe=>Fe.tabId===$).sort((Fe,Ue)=>Fe.positionInTab-Ue.positionInTab).map(f6)},[$,a,ee,Ie,K,fe,ge,ce]);x.useEffect(()=>{if(!Be)return;const Fe=U.find(Kt=>Kt.id===Be);if(!Fe?.path)return;const Ue=Fe.path,ut=Et.some(Kt=>Kt.cwd===Ue);if(Yt.projectTerminals.debug("Clear loading effect",{loadingRepoId:Be,repoPath:Ue,hasTerminal:ut,visibleTerminalCwds:Et.map(Kt=>Kt.cwd)}),ut){const Kt=Date.now()-je.current,wn=ie-Kt;if(wn>0){const pr=setTimeout(()=>{Yt.projectTerminals.info("Clearing loadingRepoId after delay",{loadingRepoId:Be}),Te(null)},wn);return()=>clearTimeout(pr)}Yt.projectTerminals.info("Clearing loadingRepoId",{loadingRepoId:Be}),Te(null)}},[Be,U,Et]);const $e=x.useCallback(()=>{if(Yt.terminal.info("handleTerminalAdd called",{activeTabId:$,connected:l,pendingTerminalCreate:ct.current,terminalCount:a.length}),ct.current){Yt.terminal.debug("Skipping terminal creation, already pending");return}ct.current=!0,Ye.current++;const Fe=`Terminal ${Ye.current}`,Ue=a.filter(Kt=>Kt.tabId===$),ut=Ue.length;Yt.terminal.info("Creating terminal",{name:Fe,tabId:$,positionInTab:ut,terminalsInTabCount:Ue.length}),u({name:Fe,cols:80,rows:24,tabId:$??void 0,positionInTab:ut}),setTimeout(()=>{ct.current=!1},500)},[u,$,a,l]);x.useEffect(()=>{if(X!=="success"){Yt.terminalsView.debug("Tab assignment effect skipped",{tasksStatus:X});return}for(const Fe of a)Fe.cwd&&oe.has(Fe.cwd)&&Fe.tabId&&!Fe.tabId.startsWith(dNe)&&(Yt.terminalsView.debug("Removing task terminal from regular tab",{terminalId:Fe.id,name:Fe.name,cwd:Fe.cwd,tabId:Fe.tabId}),h(Fe.id,null))},[a,oe,h,X]);const Qe=x.useCallback(Fe=>{const Ue=Rt.current.get(Fe);Ue&&(Ue(),Rt.current.delete(Fe)),d(Fe,{force:!0,reason:"user_closed"})},[d]),pt=x.useCallback((Fe,Ue)=>{const ut=_(Fe,Ue);Rt.current.set(Fe,ut),w.has(Fe)&&setTimeout(()=>{Ue.focus()},50)},[_,w]),at=x.useCallback((Fe,Ue,ut)=>{S(Fe,Ue,ut)},[S]),gt=x.useCallback((Fe,Ue)=>{f(Fe,Ue)},[f]),We=x.useCallback(()=>{if(Ve.current){Yt.terminal.debug("Skipping tab creation, already pending");return}Ve.current=!0;const Fe=`Tab ${o.length+1}`;Yt.terminal.debug("Quick creating tab",{name:Fe}),m(Fe,void 0,void 0),setTimeout(()=>{Ve.current=!1},500)},[m,o.length]),Xe=x.useCallback((Fe,Ue)=>{Yt.terminal.debug("Reordering tab",{tabId:Fe,newPosition:Ue}),v(Fe,Ue)},[v]),it=x.useCallback((Fe,Ue)=>{if(Ve.current){Yt.terminal.debug("Skipping tab creation, already pending");return}Ve.current=!0,Yt.terminal.debug("Creating tab",{name:Fe,directory:Ue}),m(Fe,void 0,Ue),setTimeout(()=>{Ve.current=!1},500)},[m]),ot=x.useCallback(Fe=>{const Ue=a.filter(ut=>ut.tabId===Fe);for(const ut of Ue){const Kt=Rt.current.get(ut.id);Kt&&(Kt(),Rt.current.delete(ut.id))}y(Fe)},[a,y]),St=o.map(nSt),Xt=x.useCallback(Fe=>{D(Fe)},[]),Vt=x.useCallback((Fe,Ue)=>{g(Fe,Ue)},[g]),en=$===Wo||$===ja;return Ma("meta+d",$e,{enabled:!en&&l,allowInTerminal:!0,deps:[$e,en,l]}),Ma("meta+w",()=>{if($&&!en){const Fe=j($);Fe&&Qe(Fe)}},{enabled:!en,allowInTerminal:!0,deps:[$,en,j,Qe]}),c.jsxs("div",{className:"flex h-full max-w-full flex-col overflow-hidden",children:[c.jsxs("div",{className:"film-grain relative sticky top-0 z-10 flex shrink-0 items-center justify-between border-b border-border px-2 py-1",style:{background:"var(--gradient-header)"},children:[c.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[c.jsxs("button",{onClick:()=>W(Wo),className:Ae("relative flex shrink-0 items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors max-sm:px-2",$===Wo?"bg-primary/10 text-primary":"text-muted-foreground hover:text-primary hover:bg-primary/5","after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:bg-primary after:transition-opacity",$===Wo?"after:opacity-100":"after:opacity-0"),children:[c.jsx(Z,{icon:iD,size:12,strokeWidth:2}),c.jsx("span",{className:"max-sm:hidden",children:t("taskTerminals")})]}),c.jsxs("button",{onClick:()=>W(ja),className:Ae("relative flex shrink-0 items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors max-sm:px-2",$===ja?"bg-primary/10 text-primary":"text-muted-foreground hover:text-primary hover:bg-primary/5","after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:bg-primary after:transition-opacity",$===ja?"after:opacity-100":"after:opacity-0"),children:[c.jsx(Z,{icon:ef,size:12,strokeWidth:2}),c.jsx("span",{className:"max-sm:hidden",children:t("repoTerminals")})]}),c.jsx("div",{className:"mx-2 h-4 w-px shrink-0 bg-border"}),c.jsx("div",{className:"min-w-0 flex-1",children:c.jsx(Q_t,{tabs:St,activeTabId:$??"",onTabSelect:W,onTabClose:ot,onTabCreate:We,onTabEdit:Xt,onTabReorder:Xe})})]}),c.jsxs("div",{className:"flex shrink-0 items-center gap-3 max-sm:gap-1",children:[$===Wo&&Ee.length>1&&c.jsx(qQ,{value:Ie??null,onChange:Fe=>Y(Fe??void 0),options:Ee,allLabel:t("allProjects")}),$===ja&&U.length>0&&c.jsxs(O1,{open:Re,onOpenChange:xe,children:[c.jsxs(R1,{render:c.jsx(_e,{variant:"outline",size:"sm",className:"max-sm:w-auto"}),children:[Be?c.jsx(Z,{icon:Nt,size:12,strokeWidth:2,className:"animate-spin text-muted-foreground"}):c.jsx(Z,{icon:Ty,size:12,strokeWidth:2,className:"text-muted-foreground"}),c.jsx("span",{children:Ce.length===0?t("selectRepos"):t("reposSelected",{count:Ce.length})})]}),c.jsxs(I1,{className:"w-64 p-0",align:"end",children:[c.jsx("div",{className:"border-b px-2 py-1.5",children:c.jsx(At,{ref:ve,value:ye,onChange:Fe=>De(Fe.target.value),placeholder:t("searchRepos"),className:"h-7 text-xs border-0 shadow-none focus-visible:ring-0"})}),c.jsxs("div",{className:"p-2 space-y-2",children:[c.jsx("div",{className:"text-sm font-medium mb-2",children:t("filterByRepo")}),c.jsx("div",{className:"max-h-48 overflow-y-auto space-y-2",children:Oe.length===0?c.jsx("div",{className:"text-xs text-muted-foreground py-1",children:t("noReposFound")}):Oe.map(Fe=>{const Ue=ge.includes(Fe.id),ut=Be===Fe.id,Kt=Be!==null||!Ue&&ge.length>=6;return c.jsxs("div",{className:"flex items-center gap-2",children:[ut?c.jsx(Z,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin text-muted-foreground"}):c.jsx(ni,{id:`repo-filter-${Fe.id}`,checked:Ue,disabled:Kt,onCheckedChange:wn=>Ke(Fe.id,wn===!0)}),c.jsx(Ur,{htmlFor:`repo-filter-${Fe.id}`,className:`text-sm ${Kt?"text-muted-foreground cursor-not-allowed":"cursor-pointer"}`,children:Fe.displayName})]},Fe.id)})}),Ce.length>0&&!Be&&c.jsx(_e,{variant:"ghost",size:"sm",className:"w-full mt-2",onClick:()=>n({to:"/terminals",search:Fe=>({...Fe,repoIds:void 0}),replace:!0}),children:t("clearFilter")})]})]})]}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:$e,disabled:!l||$===Wo||$===ja,className:"max-sm:px-2 border-transparent text-primary",children:[c.jsx(Z,{icon:M_e,size:14,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"max-sm:hidden",children:t("newTerminal")})]})]})]}),c.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:c.jsx(a_t,{terminals:Et,onTerminalClose:$===Wo||$===ja?void 0:Qe,onTerminalAdd:l&&$!==Wo&&$!==ja?$e:void 0,onTerminalReady:pt,onTerminalResize:at,onTerminalRename:$===Wo||$===ja?void 0:gt,setupImagePaste:E,writeToTerminal:T,sendInputToTerminal:k,taskInfoByCwd:$===Wo?ae:void 0,repoInfoByCwd:$===ja?be:void 0,emptyMessage:$===ja?t("emptyRepos"):$===Wo?t("emptyTasks"):void 0})}),c.jsx(Z_t,{tab:I,open:I!==null,onOpenChange:Fe=>{Fe||D(null)},onSave:Vt,onCreate:it,defaultName:`Tab ${o.length+1}`})]})}),iSt=xa("/terminals/")({component:rSt,validateSearch:e=>({tab:typeof e.tab=="string"?e.tab:void 0,project:typeof e.project=="string"?e.project:void 0,repoIds:typeof e.repoIds=="string"?e.repoIds:void 0})});function sSt(){return{x:0,y:0}}function aSt(e){var t=e.render,n=e.nativeSetDragImage,r=e.getOffset,i=r===void 0?sSt:r,s=document.createElement("div");Object.assign(s.style,{position:"fixed",top:0,left:0,zIndex:nNe,pointerEvents:"none"}),document.body.append(s);var a=t({container:s});queueMicrotask(function(){var u=i({container:s});if(ok()){var d=s.getBoundingClientRect();if(d.width===0)return;s.style.left="-".concat(d.width-1e-4,"px")}n?.(s,u.x,u.y)});function o(){l(),a?.(),document.body.removeChild(s)}var l=oNe({onDragStart:o,onDrop:o})}var oSt=Gy(function(){return ok()&&"ontouchend"in document}),lSt=function(t){var n=t.container,r=n.getBoundingClientRect();return{x:r.width/2,y:r.height/2}};function cSt(e){return function(n){var r=n.container;if(oSt()||aNe())return lSt({container:r});Object.assign(r.style,{borderInlineStart:"".concat(e.x," solid transparent"),borderTop:"".concat(e.y," solid transparent")});var i=window.getComputedStyle(r);if(i.direction==="rtl"){var s=r.getBoundingClientRect();return{x:s.width,y:0}}return{x:0,y:0}}}function xi({className:e,size:t="default",...n}){return c.jsx("div",{"data-slot":"card","data-size":t,className:Ae("film-grain relative ring-foreground/10 text-card-foreground gap-4 overflow-hidden rounded-lg py-4 text-xs/relaxed ring-1 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 *:[img:first-child]:rounded-t-lg *:[img:last-child]:rounded-b-lg group/card flex flex-col",e),style:{background:"var(--gradient-card)"},...n})}function J1({className:e,...t}){return c.jsx("div",{"data-slot":"card-header",className:Ae("gap-1 rounded-t-lg px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]",e),...t})}function e_({className:e,...t}){return c.jsx("div",{"data-slot":"card-title",className:Ae("text-sm font-medium",e),...t})}function uSt({className:e,...t}){return c.jsx("div",{"data-slot":"card-description",className:Ae("text-muted-foreground text-xs/relaxed",e),...t})}function Ms({className:e,...t}){return c.jsx("div",{"data-slot":"card-content",className:Ae("px-4 group-data-[size=sm]/card:px-3",e),...t})}const fNe=x.createContext(null);function dSt({children:e}){const[t,n]=x.useState(null);return c.jsx(fNe.Provider,{value:{activeTask:t,setActiveTask:n},children:e})}function hNe(){const e=x.useContext(fNe);if(!e)throw new Error("useDrag must be used within DragProvider");return e}const pNe=x.createContext(null);function fSt({children:e}){const[t,n]=x.useState(new Set),[r,i]=x.useState(null),s=x.useCallback(u=>{n(d=>{const f=new Set(d);return f.has(u)?f.delete(u):f.add(u),f}),i(u)},[]),a=x.useCallback((u,d)=>{if(!r){n(new Set([u])),i(u);return}const f=d.indexOf(r),h=d.indexOf(u);if(f===-1||h===-1){n(new Set([u])),i(u);return}const[m,g]=f<h?[f,h]:[h,f],y=d.slice(m,g+1);n(v=>{const _=new Set(v);for(const S of y)_.add(S);return _})},[r]),o=x.useCallback(()=>{n(new Set),i(null)},[]),l=x.useCallback(u=>t.has(u),[t]);return c.jsx(pNe.Provider,{value:{selectedIds:t,lastSelectedId:r,toggleSelection:s,selectRange:a,clearSelection:o,isSelected:l},children:e})}function GQ(){const e=x.useContext(pNe);if(!e)throw new Error("useSelection must be used within a SelectionProvider");return e}function m5(){const{data:e}=pD();return x.useMemo(()=>qW(e),[e])}function g5(e,t){const{data:n}=pD();return x.useMemo(()=>BYe(e,n,t),[e,n,t])}function mNe(e,t){const{data:n}=pD();return x.useMemo(()=>$Ye(e,n,t),[e,n,t])}function gNe({task:e,isDragPreview:t,isBlocked:n,isBlocking:r,showTypeLabel:i}){const{t:s}=Ot("tasks"),{setActiveTask:a}=hNe(),{isSelected:o,toggleSelection:l}=GQ(),u=Ni(),d=PWe(),{data:f}=Oy(),h=o(e.id),m=x.useRef(null),[g,y]=x.useState(!1),[v,_]=x.useState(null),[S,E]=x.useState(null),T=!!(e.worktreePath||e.repositoryId||e.type==="scratch"),k=!!e.worktreePath,w=!e.worktreePath&&!!e.repositoryId,A=w?f?.find(P=>P.id===e.repositoryId):null,R=g5(e.dueDate,e.status),I=mNe(e.dueDate,e.status),D=x.useRef(!1);x.useEffect(()=>{const P=m.current;if(!(!P||t))return lk(lNe({element:P,getInitialData:()=>({type:"task",taskId:e.id,status:e.status}),onGenerateDragPreview:({nativeSetDragImage:L})=>{aSt({nativeSetDragImage:L,getOffset:cSt({x:"16px",y:"8px"}),render:({container:M})=>{E(M)}})},onDragStart:()=>{y(!0),a(e),D.current=!0},onDrop:()=>{y(!1),a(null),E(null)}}),h5({element:P,getData:({input:L,element:M})=>{const $={type:"task",taskId:e.id,status:e.status};return uNe($,{input:L,element:M,allowedEdges:["top","bottom"]})},canDrop:({source:L})=>L.data.taskId!==e.id,onDragEnter:({self:L})=>{_(z0(L.data))},onDrag:({self:L})=>{_(z0(L.data))},onDragLeave:()=>{_(null)},onDrop:()=>{_(null)}}))},[e,t,a]);const j=()=>{D.current=!1},F=()=>{if(D.current){D.current=!1;return}u(k?{to:"/tasks/$taskId",params:{taskId:e.id}}:{to:"/tasks",search:P=>({...P,task:e.id}),replace:!0}),D.current=!1},z=c.jsxs("div",{className:"group/card relative",children:[!t&&c.jsx("div",{className:Ae("absolute left-2 top-2 z-20 transition-opacity duration-150",h?"opacity-100":"opacity-0 group-hover/card:opacity-100"),onPointerDown:P=>P.stopPropagation(),children:c.jsx(ni,{checked:h,onCheckedChange:()=>l(e.id)})}),!t&&c.jsx("button",{type:"button",className:Ae("absolute right-2 top-2 z-20 p-0.5 rounded transition-opacity duration-150 hover:bg-muted cursor-pointer",e.pinned?"opacity-100":"opacity-0 group-hover/card:opacity-100"),onPointerDown:P=>P.stopPropagation(),onClick:P=>{P.stopPropagation(),d.mutate({taskId:e.id,pinned:!e.pinned})},title:e.pinned?"Unpin task":"Pin task to top",children:c.jsx(Z,{icon:e.pinned?nD:wE,size:14,strokeWidth:2,className:e.pinned?"text-primary":"text-muted-foreground"})}),c.jsxs(xi,{ref:t?void 0:m,onPointerDown:j,onClick:F,className:Ae("relative cursor-grab active:cursor-grabbing","transition-all duration-200 ease-out","hover:shadow-md hover:scale-[1.02] hover:-translate-y-0.5",g&&"opacity-50",h&&"ring-2 ring-primary bg-primary/5"),children:[v&&c.jsx("div",{className:Ae("absolute left-0 right-0 h-0.5 bg-primary z-10",v==="top"&&"-top-1",v==="bottom"&&"-bottom-1")}),c.jsx(J1,{className:Ae("p-3 pb-1 flex flex-row items-start justify-between gap-2",!t&&"pl-8"),children:c.jsx(e_,{className:"text-sm font-medium leading-tight flex-1",children:e.title})}),c.jsxs(Ms,{className:Ae("p-3 pt-1",!t&&"pl-8"),children:[e.description&&c.jsx("p",{className:"line-clamp-2 text-xs text-muted-foreground",children:e.description}),e.tags.length>0&&c.jsxs("div",{className:"mt-2 flex items-center gap-1 flex-wrap",children:[e.tags.slice(0,3).map(P=>c.jsx("span",{className:"rounded-full border border-border bg-card px-1.5 py-0.5 text-[10px] font-medium",children:P},P)),e.tags.length>3&&c.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",e.tags.length-3]})]}),c.jsxs("div",{className:Ae("flex items-center gap-1 text-xs text-muted-foreground/70 flex-wrap",e.tags.length>0?"mt-1.5":"mt-2"),children:[n&&c.jsxs(c.Fragment,{children:[c.jsxs("span",{className:"inline-flex items-center gap-0.5 whitespace-nowrap text-destructive font-medium",children:[c.jsx(Z,{icon:U$e,size:12,strokeWidth:2}),c.jsx("span",{children:"Blocked"})]}),c.jsx("span",{className:"text-muted-foreground/30",children:"•"})]}),r&&c.jsxs(c.Fragment,{children:[c.jsxs("span",{className:"inline-flex items-center gap-0.5 whitespace-nowrap text-accent font-medium",children:[c.jsx(Z,{icon:wr,size:12,strokeWidth:2}),c.jsx("span",{children:"Blocking"})]}),c.jsx("span",{className:"text-muted-foreground/30",children:"•"})]}),k&&c.jsxs("span",{className:"inline-flex items-center gap-1 whitespace-nowrap",children:[c.jsx(Z,{icon:ef,size:12,strokeWidth:2}),c.jsx("span",{className:"truncate max-w-24",children:e.repoName}),e.prUrl&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-muted-foreground/30",children:"•"}),c.jsx(Z,{icon:ud,size:12,strokeWidth:2,className:"text-foreground"})]})]}),w&&A&&c.jsxs("span",{className:"inline-flex items-center gap-1 whitespace-nowrap",children:[c.jsx(Z,{icon:ef,size:12,strokeWidth:2}),c.jsx("span",{className:"truncate max-w-24",children:A.displayName})]}),e.dueDate&&c.jsxs(c.Fragment,{children:[T&&c.jsx("span",{className:"text-muted-foreground/30",children:"•"}),c.jsxs("span",{className:Ae("inline-flex items-center gap-1 whitespace-nowrap",R?"text-destructive":I?"text-amber-600 dark:text-amber-500":""),children:[c.jsx(Z,{icon:op,size:12,strokeWidth:2}),c.jsx("span",{children:WW(e.dueDate)})]})]}),e.timeEstimate!=null&&c.jsxs(c.Fragment,{children:[(T||e.dueDate)&&c.jsx("span",{className:"text-muted-foreground/30",children:"•"}),c.jsxs("span",{className:"inline-flex items-center gap-0.5 whitespace-nowrap",children:[c.jsx(Z,{icon:ky,size:12,strokeWidth:2}),c.jsxs("span",{children:[e.timeEstimate,"h"]})]})]}),e.priority&&e.priority!=="medium"&&c.jsxs(c.Fragment,{children:[(T||e.dueDate||e.timeEstimate!=null)&&c.jsx("span",{className:"text-muted-foreground/30",children:"•"}),c.jsx("span",{className:Ae("inline-flex items-center gap-0.5 whitespace-nowrap",e.priority==="high"?"text-destructive":"text-muted-foreground/50"),children:c.jsx(Z,{icon:e.priority==="high"?wd:Ts,size:12,strokeWidth:2})})]}),e.recurrenceRule&&c.jsxs(c.Fragment,{children:[(T||e.dueDate||e.timeEstimate!=null)&&c.jsx("span",{className:"text-muted-foreground/30",children:"•"}),c.jsx("span",{className:"inline-flex items-center gap-0.5 whitespace-nowrap",children:c.jsx(Z,{icon:pze,size:12,strokeWidth:2})})]}),!T&&!n&&!r&&e.tags.length===0&&!e.dueDate&&e.timeEstimate==null&&(!e.priority||e.priority==="medium")&&!e.recurrenceRule&&c.jsx("span",{className:"italic",children:"Non-code task"})]}),c.jsx("span",{className:Ae("absolute bottom-1.5 right-2 text-[10px] font-medium transition-opacity duration-200",i?"opacity-100":"opacity-0 group-hover/card:opacity-100"),style:{color:Ewe(e)},children:s(`typeFilter.types.${TC(e)}`)})]})]})]});return c.jsxs(c.Fragment,{children:[z,S&&_i.createPortal(c.jsx("div",{className:"w-72 max-w-[90vw]",children:c.jsx(gNe,{task:e,isDragPreview:!0})}),S)]})}const hSt={TO_DO:"border-t-status-todo",IN_PROGRESS:"border-t-status-in-progress",IN_REVIEW:"border-t-status-in-review",DONE:"border-t-status-done",CANCELED:"border-t-status-canceled"};function Pce({status:e,tasks:t,isMobile:n,blockedTaskIds:r,blockingTaskIds:i,showTypeLabels:s}){const{t:a}=Ot("common"),o=x.useRef(null),[l,u]=x.useState(!1),d=[...t].sort((f,h)=>{const m=f.pinned?1:0,g=h.pinned?1:0;return m!==g?g-m:new Date(h.updatedAt).getTime()-new Date(f.updatedAt).getTime()});return x.useEffect(()=>{const f=o.current;if(f)return h5({element:f,getData:()=>({type:"column",status:e}),canDrop:({source:h})=>h.data.type==="task",onDragEnter:()=>u(!0),onDragLeave:()=>u(!1),onDrop:()=>u(!1)})},[e]),c.jsxs("div",{ref:o,className:Ae("flex flex-col rounded-lg border border-t-4 bg-card",n?"h-full w-full":"h-full w-72 min-w-52 flex-shrink",hSt[e],l&&"ring-2 ring-primary ring-offset-2 ring-offset-background"),children:[!n&&c.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[c.jsx("h3",{className:"text-sm font-medium",children:a(`statuses.${e}`)}),c.jsx("span",{className:"flex h-5 min-w-5 items-center justify-center rounded-full bg-muted px-1.5 text-xs font-medium",children:t.length})]}),c.jsx(hp,{className:"min-h-0 flex-1",children:c.jsx("div",{className:"flex flex-col gap-2 p-2",children:d.map(f=>c.jsx(gNe,{task:f,isBlocked:r?.has(f.id),isBlocking:i?.has(f.id),showTypeLabel:s},f.id))})})]})}function pSt(){const{selectedIds:e,clearSelection:t}=GQ(),n=jWe(),{data:r=[]}=cl(),[i,s]=x.useState(!0),a=e.size,l=x.useMemo(()=>r.filter(f=>e.has(f.id)).some(f=>f.worktreePath),[r,e]),u=()=>{n.mutate({ids:Array.from(e),deleteLinkedWorktrees:i},{onSuccess:()=>{t()}})};return a===0?null:c.jsx("div",{className:Ae("fixed bottom-4 left-1/2 z-40 -translate-x-1/2 rounded-lg border bg-background/95 shadow-lg backdrop-blur-sm","animate-in slide-in-from-bottom-2 duration-200"),children:c.jsxs("div",{className:"flex items-center gap-4 px-4 py-2.5",children:[c.jsxs("span",{className:"text-sm text-muted-foreground",children:[a," task",a!==1?"s":""," selected"]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(_e,{variant:"ghost",size:"sm",onClick:t,children:"Clear"}),c.jsxs(ql,{children:[c.jsx(VQ,{render:c.jsx(_e,{variant:"destructive",size:"sm",disabled:n.isPending}),children:n.isPending?"Deleting...":"Delete"}),c.jsxs(Gl,{children:[c.jsxs(Kl,{children:[c.jsxs(Xl,{children:["Delete ",a," Task",a!==1?"s":""]}),c.jsxs(Ql,{children:["This will permanently delete ",a," task",a!==1?"s":"",". This action cannot be undone."]})]}),l&&c.jsxs("div",{className:"flex items-center gap-2 py-2",children:[c.jsx(ni,{id:"bulk-delete-worktrees",checked:i,onCheckedChange:d=>s(d===!0)}),c.jsx("label",{htmlFor:"bulk-delete-worktrees",className:"cursor-pointer text-sm",children:"Also delete linked worktrees"})]}),c.jsxs(Yl,{children:[c.jsx(Zl,{children:"Cancel"}),c.jsx(cg,{onClick:u,variant:"destructive",disabled:n.isPending,children:n.isPending?"Deleting...":"Delete"})]})]})]})]})]})})}function bNe({taskId:e,links:t}){const[n,r]=x.useState(!1),[i,s]=x.useState(""),[a,o]=x.useState(""),l=Twe(),u=MWe(),d=()=>{const m=i.trim();if(m){try{new URL(m)}catch{rt.error("Invalid URL",{description:"Please enter a valid URL including the scheme (e.g., https://)"});return}l.mutate({taskId:e,url:m,label:a.trim()||void 0},{onSuccess:()=>{s(""),o(""),r(!1)}})}},f=m=>{u.mutate({taskId:e,linkId:m})},h=m=>{m.key==="Enter"?(m.preventDefault(),d()):m.key==="Escape"&&(r(!1),s(""),o(""))};return c.jsxs("div",{className:"space-y-2",children:[t.length>0&&c.jsx("div",{className:"space-y-1.5",children:t.map(m=>c.jsxs("div",{className:"flex items-center gap-2 group",children:[c.jsxs("button",{type:"button",onClick:()=>jl(m.url),className:"flex items-center gap-2 text-sm text-primary hover:underline flex-1 min-w-0",children:[c.jsx(Z,{icon:Ay,size:14,className:"shrink-0"}),c.jsx("span",{className:"truncate",children:m.label||m.url})]}),c.jsx("button",{type:"button",onClick:()=>f(m.id),className:"opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-opacity",title:"Remove link",children:c.jsx(Z,{icon:ks,size:14})})]},m.id))}),n?c.jsxs("div",{className:"space-y-2 pt-1",children:[c.jsx(At,{type:"url",value:i,onChange:m=>s(m.target.value),onKeyDown:h,placeholder:"https://...",className:"h-8 text-sm",autoFocus:!0}),c.jsx(At,{type:"text",value:a,onChange:m=>o(m.target.value),onKeyDown:h,placeholder:"Label (optional)",className:"h-8 text-sm"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(_e,{size:"sm",className:"h-7",onClick:d,disabled:!i.trim()||l.isPending,children:"Add"}),c.jsx(_e,{variant:"outline",size:"sm",className:"h-7",onClick:()=>{r(!1),s(""),o("")},children:"Cancel"})]})]}):c.jsxs("button",{type:"button",onClick:()=>r(!0),className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[c.jsx(Z,{icon:Ic,size:14}),c.jsx("span",{children:"Add link"})]})]})}const Lce={TO_DO:"bg-status-todo/20 text-status-todo",IN_PROGRESS:"bg-status-in-progress/20 text-status-in-progress",IN_REVIEW:"bg-status-in-review/20 text-status-in-review",DONE:"bg-status-done/20 text-status-done",CANCELED:"bg-status-canceled/20 text-status-canceled"};function Mce({title:e,icon:t,count:n,items:r,isAdding:i,onStartAdding:s,onCancelAdding:a,onAdd:o,onRemove:l,filteredTasks:u,searchQuery:d,onSearchChange:f,inputRef:h,addButtonLabel:m,emptyLabel:g}){return c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground mb-2",children:[c.jsx(Z,{icon:t,size:12}),c.jsx("span",{children:e}),n>0&&c.jsxs("span",{className:"text-warning",children:["(",n,")"]})]}),c.jsx("div",{className:"rounded-md border bg-muted/30 min-h-[60px]",children:c.jsxs("div",{className:"p-1.5 space-y-1",children:[r.length>0?r.map(y=>c.jsxs("div",{className:"flex items-center gap-2 rounded bg-background px-2 py-1.5 group",children:[c.jsx("span",{className:Ae("shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",Lce[y.status]),children:y.status.replace("_"," ")}),c.jsx("span",{className:"flex-1 truncate text-xs",children:y.title}),c.jsx("button",{type:"button",onClick:()=>l(y),className:"shrink-0 text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity",children:c.jsx(Z,{icon:Tn,size:12})})]},y.id)):!i&&c.jsx("div",{className:"text-xs text-muted-foreground italic px-2 py-1.5",children:g}),i&&c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(At,{ref:h,value:d,onChange:y=>f(y.target.value),placeholder:"Search tasks...",className:"h-7 text-xs",onKeyDown:y=>{y.key==="Escape"&&a()}}),c.jsx(_e,{variant:"ghost",size:"icon-xs",onClick:a,children:c.jsx(Z,{icon:Tn,size:12})})]}),u.length>0&&c.jsx("div",{className:"max-h-32 overflow-y-auto rounded border bg-background",children:u.map(y=>c.jsxs("button",{type:"button",className:"w-full px-2 py-1.5 text-left text-xs hover:bg-muted flex items-center gap-2",onClick:()=>o(y.id),children:[c.jsx("span",{className:Ae("shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",Lce[y.status]),children:y.status.replace("_"," ")}),c.jsx("span",{className:"truncate",children:y.title})]},y.id))}),d&&u.length===0&&c.jsx("div",{className:"text-xs text-muted-foreground px-2 py-1",children:"No tasks found"})]})]})}),!i&&c.jsxs(_e,{variant:"ghost",size:"sm",className:"mt-1.5 h-7 text-xs text-muted-foreground hover:text-foreground w-full justify-start",onClick:s,children:[c.jsx(Z,{icon:Ic,size:12,className:"mr-1.5"}),m]})]})}function yNe({taskId:e}){const{data:t=[]}=cl(),{data:n,isLoading:r}=FWe(e),i=BWe(),s=$We(),[a,o]=x.useState(""),[l,u]=x.useState(!1),[d,f]=x.useState(!1),h=x.useRef(null),m=x.useRef(null);x.useEffect(()=>{l&&h.current&&h.current.focus()},[l]),x.useEffect(()=>{d&&m.current&&m.current.focus()},[d]);const g=x.useMemo(()=>{const k=new Set([e]);if(n){for(const w of n.blockedBy)k.add(w.id);for(const w of n.blocking)k.add(w.id)}return k},[e,n]),y=x.useMemo(()=>{const k=a.toLowerCase().trim(),w=new Set(["DONE","CANCELED"]);return t.filter(A=>!g.has(A.id)).filter(A=>k?A.title.toLowerCase().includes(k)||A.description?.toLowerCase().includes(k):!0).sort((A,R)=>{const I=w.has(A.status),D=w.has(R.status);return I!==D?I?1:-1:new Date(R.updatedAt).getTime()-new Date(A.updatedAt).getTime()}).slice(0,10)},[t,g,a]),v=k=>{i.mutate({taskId:e,dependsOnTaskId:k},{onSuccess:()=>{o(""),u(!1)}})},_=k=>{i.mutate({taskId:k,dependsOnTaskId:e},{onSuccess:()=>{o(""),f(!1)}})},S=k=>{s.mutate({taskId:e,dependencyId:k.dependencyId})};if(r)return c.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading dependencies..."});const E=n?.blockedBy??[],T=n?.blocking??[];return c.jsxs("div",{className:"grid gap-4 grid-cols-1 sm:grid-cols-2",children:[c.jsx(Mce,{title:"Blocked by",icon:wd,count:E.length,items:E,isAdding:l,onStartAdding:()=>{f(!1),o(""),u(!0)},onCancelAdding:()=>{o(""),u(!1)},onAdd:v,onRemove:S,filteredTasks:y,searchQuery:a,onSearchChange:o,inputRef:h,addButtonLabel:"Add blocker",emptyLabel:"No blockers"}),c.jsx(Mce,{title:"Blocking",icon:Ts,count:T.length,items:T,isAdding:d,onStartAdding:()=>{u(!1),o(""),f(!0)},onCancelAdding:()=>{o(""),f(!1)},onAdd:_,onRemove:S,filteredTasks:y,searchQuery:a,onSearchChange:o,inputRef:m,addButtonLabel:"Add blocked task",emptyLabel:"Not blocking any"})]})}function mSt(e){return e==="application/pdf"?Y_e:e.startsWith("image/")?U_e:$_e}function Fce(e){return e==="application/pdf"||e.startsWith("image/")}function gSt(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function vNe({taskId:e}){const{data:t=[],isLoading:n}=zYe(e),r=SEe(),i=UYe(),s=x.useRef(null),[a,o]=x.useState(!1),[l,u]=x.useState(null),[d,f]=x.useState(null),h=x.useCallback(async E=>{if(!(!E||E.length===0)){u(null);for(const T of Array.from(E))try{await r.mutateAsync({taskId:e,file:T})}catch(k){u(k instanceof Error?k.message:"Upload failed")}}},[e,r]),m=x.useCallback(E=>{E.preventDefault(),E.stopPropagation(),o(!0)},[]),g=x.useCallback(E=>{E.preventDefault(),E.stopPropagation(),o(!1)},[]),y=x.useCallback(E=>{E.preventDefault(),E.stopPropagation(),o(!1),h(E.dataTransfer.files)},[h]),v=async E=>{d?.id===E.id&&f(null);try{await i.mutateAsync({taskId:e,attachmentId:E.id})}catch{}},_=E=>{const T=o4(e,E.id);window.open(T,"_blank")},S=E=>{Fce(E.mimeType)?f(T=>T?.id===E.id?null:E):_(E)};return n?c.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading attachments..."}):c.jsxs("div",{className:"space-y-3",children:[d&&c.jsxs("div",{className:"rounded border bg-card overflow-hidden",children:[c.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 border-b border-border text-xs",children:[c.jsx("span",{className:"text-muted-foreground truncate",children:d.filename}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(_e,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",onClick:()=>_(d),title:"Download",children:c.jsx(Z,{icon:cse,size:12})}),c.jsx(_e,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",onClick:()=>f(null),title:"Close preview",children:c.jsx(Z,{icon:Tn,size:12})})]})]}),c.jsx("div",{className:"bg-muted",children:d.mimeType==="application/pdf"?c.jsx("iframe",{src:`${o4(e,d.id)}?inline=1`,className:"w-full border-0",style:{height:"500px"},title:d.filename}):d.mimeType.startsWith("image/")?c.jsx("div",{className:"p-4 flex items-center justify-center",children:c.jsx("img",{src:o4(e,d.id),alt:d.filename,className:"max-w-full max-h-[400px] object-contain"})}):null})]}),c.jsxs("div",{className:Ae("border-2 border-dashed rounded-lg p-4 text-center transition-colors cursor-pointer",a?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-muted-foreground/50"),onDragOver:m,onDragLeave:g,onDrop:y,onClick:()=>s.current?.click(),children:[c.jsx("input",{ref:s,type:"file",multiple:!0,className:"hidden",onChange:E=>h(E.target.files)}),c.jsx(Z,{icon:J_e,size:20,className:"mx-auto text-muted-foreground mb-1"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:r.isPending?"Uploading...":"Drop files here or click to upload"}),c.jsx("p",{className:"text-[10px] text-muted-foreground/70 mt-0.5",children:"Any file (max 50MB)"})]}),l&&c.jsx("p",{className:"text-xs text-destructive",children:l}),t.length>0&&c.jsx("div",{className:"space-y-1.5",children:t.map(E=>{const T=mSt(E.mimeType),k=d?.id===E.id;return c.jsxs("div",{className:Ae("flex items-center gap-2 p-2 rounded border transition-colors group",Fce(E.mimeType)?"cursor-pointer":"cursor-default",k?"bg-primary/10 border-primary/30":"bg-card hover:bg-accent/50"),onClick:()=>S(E),children:[c.jsx(Z,{icon:T,size:16,className:"text-muted-foreground shrink-0"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("p",{className:"text-xs font-medium truncate",children:E.filename}),c.jsx("p",{className:"text-[10px] text-muted-foreground",children:gSt(E.size)})]}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[c.jsx(_e,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:w=>{w.stopPropagation(),_(E)},title:"Download",children:c.jsx(Z,{icon:cse,size:14})}),c.jsx(_e,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-destructive hover:text-destructive",onClick:w=>{w.stopPropagation(),v(E)},disabled:i.isPending,title:"Delete",children:c.jsx(Z,{icon:ks,size:14})})]})]},E.id)})}),t.length===0&&!n&&c.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No attachments"})]})}function bSt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function ySt(e){const t=e.trim().split(/\s+/).slice(0,4).join(" "),n=bSt(t);if(!n)return"";const r=Math.random().toString(36).substring(2,6);return`${n}-${r}`}function vSt({task:e,open:t,onOpenChange:n}){const r=Ni(),i=It(),[s,a]=x.useState(!1),[o,l]=x.useState(!1),[u,d]=x.useState(""),[f,h]=x.useState(""),[m,g]=x.useState(""),[y,v]=x.useState(""),[_,S]=x.useState(""),[E,T]=x.useState(""),[k,w]=x.useState("default"),[A,R]=x.useState("claude"),[I,D]=x.useState(null),[j,F]=x.useState("browse"),[z,P]=x.useState(""),[L,M]=x.useState(null),[$,W]=x.useState(!1),[Y,q]=x.useState(null),{data:K}=Iwe(),{data:X}=uD(),{data:U}=NC(),{data:J}=A1(),{data:te}=Oy(),{data:ee}=Mc(),{data:oe,isLoading:ae}=OW(u||null),se=I?te?.find(xe=>xe.id===I):null,ue=x.useMemo(()=>!I||!ee?null:ee.find(xe=>xe.repositories.some(ye=>ye.id===I))??null,[I,ee]),de=x.useMemo(()=>{if(!te)return[];if(se&&z===se.displayName||!z.trim())return te;const xe=z.toLowerCase();return te.filter(ye=>ye.displayName.toLowerCase().includes(xe)||ye.path.toLowerCase().includes(xe))},[te,z,se]),{filteredLocalBranches:ce,filteredRemoteBranches:Ee}=x.useMemo(()=>{const xe=oe?.branches??[],ye=oe?.remoteBranches??[];if(!m.trim()||m===f)return{filteredLocalBranches:xe,filteredRemoteBranches:ye};const De=m.toLowerCase();return{filteredLocalBranches:xe.filter(ve=>ve.toLowerCase().includes(De)),filteredRemoteBranches:ye.filter(ve=>ve.toLowerCase().includes(De))}},[oe?.branches,oe?.remoteBranches,m,f]);x.useEffect(()=>{t&&(S(ySt(e.title)),T(e.prefix||""))},[t,e.title,e.prefix]),x.useEffect(()=>{te&&te.length>0?F("saved"):F("browse")},[te]),x.useEffect(()=>{if(t){const xe=te&&te.length>0?e.repositoryId?te.find(De=>De.id===e.repositoryId)??te[0]:te[0]:null,ye=xe&&ee?ee.find(De=>De.repositories.some(ve=>ve.id===xe.id)):null;if(xe?.defaultAgent?R(xe.defaultAgent):ye?.defaultAgent?R(ye.defaultAgent):U&&R(U),xe?.opencodeModel?q(xe.opencodeModel):ye?.opencodeModel?q(ye.opencodeModel):q(J||null),te&&te.length>0){const De=e.repositoryId?te.find(ve=>ve.id===e.repositoryId)??te[0]:te[0];D(De.id),d(De.path),P(De.displayName),F("saved")}e.description?.trim()?w("plan"):w("default")}},[t,te,ee,U,J,e.description,e.repositoryId]),x.useEffect(()=>{if(oe){const ye=te?.find(Oe=>Oe.id===I)?.lastBaseBranch,De=[...oe.branches,...oe.remoteBranches??[]],ve=ye&&De.includes(ye)?ye:oe.defaultBranch||oe.branches[0]||"main";h(ve),g(ve)}else h(""),g("")},[oe,u,te,I]);const Ie=async xe=>{M(null),W(!0);try{if(!(await Rwe(xe)).isGitRepo){M("Selected folder is not a git repository"),W(!1);return}d(xe);const De=te?.find(ve=>ve.path===xe);D(De?De.id:null)}catch(ye){M(ye instanceof Error?ye.message:"Validation failed")}finally{W(!1)}},fe=async xe=>{if(xe.preventDefault(),!!u){l(!0);try{const ye=u.split("/").pop()||"repo",De=y.trim()||_,ve=E.trim()?`${E.trim().replace(/\/+$/,"")}/${De}`:De,Oe=`${K}/${ve}`,Be=A==="claude"?se?.claudeOptions??ue?.claudeOptions:se?.opencodeOptions??ue?.opencodeOptions;await ht(`/api/tasks/${e.id}/initialize-worktree`,{method:"POST",body:JSON.stringify({agent:A,aiMode:k,repoPath:u,repoName:ye,baseBranch:f||"main",branch:ve,prefix:E.trim()||void 0,worktreePath:Oe,copyFiles:se?.copyFiles||void 0,startupScript:[ue?.startupScript,se?.startupScript].filter(Boolean).join(`
138
138
  `)||void 0,agentOptions:Be||void 0,opencodeModel:A==="opencode"?Y:void 0})}),i.invalidateQueries({queryKey:["tasks"]}),i.invalidateQueries({queryKey:["tasks",e.id]}),n(!1);const Te=e.description?.trim()?{aiMode:k,description:e.description.trim(),focusTerminal:!0}:{aiMode:k,focusTerminal:!0};r({to:"/tasks/$taskId",params:{taskId:e.id},state:Te,replace:!0})}catch(ye){rt.error("Failed to initialize worktree task",{description:ye instanceof Error?ye.message:String(ye)})}finally{l(!1)}}},be=y.trim()||_,ge=E.trim()&&be?`${E.trim().replace(/\/+$/,"")}/${be}`:be,Ce=ge?`${K}/${ge}`:"",Re=!o&&!!u;return c.jsxs(c.Fragment,{children:[c.jsx(Ya,{open:t,onOpenChange:n,children:c.jsx(Xa,{className:"sm:max-w-md max-h-[80dvh] flex flex-col overflow-hidden",children:c.jsxs("form",{onSubmit:fe,className:"flex flex-col min-h-0 flex-1",children:[c.jsxs(Lo,{className:"shrink-0",children:[c.jsx(Mo,{children:"Initialize as Worktree Task"}),c.jsxs(eg,{children:['Create a git worktree and start a coding session for "',e.title,'"']})]}),c.jsxs(qh,{className:"mt-4 pb-4 overflow-y-auto min-h-0 flex-1",children:[c.jsxs($n,{children:[c.jsx(zn,{children:"AI Mode"}),c.jsxs(AE,{value:[k],onValueChange:xe=>{const ye=Array.isArray(xe)?xe[0]:xe;ye&&w(ye)},className:"w-full",variant:"outline",children:[c.jsx(Ih,{value:"plan",className:"flex-1",children:"Plan"}),c.jsx(Ih,{value:"default",className:"flex-1",children:"Execute"})]})]}),c.jsxs($n,{children:[c.jsx(zn,{children:"Agent"}),c.jsxs(Qr,{value:A,onValueChange:xe=>R(xe),children:[c.jsx(Jr,{className:"w-full",children:c.jsx(Zr,{})}),c.jsx(ei,{children:Object.keys(Io).map(xe=>c.jsx(jt,{value:xe,children:Io[xe]},xe))})]})]}),A==="opencode"&&c.jsxs($n,{children:[c.jsx(zn,{children:"OpenCode Model"}),c.jsx(Bb,{value:Y,onChange:q,placeholder:"Select model..."})]}),c.jsxs($n,{children:[c.jsx(zn,{children:"Repository"}),c.jsxs(nl,{value:j,onValueChange:xe=>{F(xe),M(null)},children:[c.jsxs(rl,{children:[c.jsx(In,{value:"saved",disabled:!te?.length,children:"Saved"}),c.jsx(In,{value:"browse",children:"Browse"})]}),c.jsx(jn,{value:"saved",className:"mt-2",children:c.jsxs(ox,{value:I||"",onValueChange:xe=>{const ye=te?.find(De=>De.id===xe);ye&&(D(xe),d(ye.path),P(ye.displayName),M(null),ye.defaultAgent&&R(ye.defaultAgent),q(ye.opencodeModel??J??null))},inputValue:z,onInputValueChange:P,itemToStringLabel:xe=>te?.find(ye=>ye.id===xe)?.displayName||"",children:[c.jsx(lx,{placeholder:"Search repositories...",className:"w-full"}),c.jsx(cx,{children:c.jsxs(ux,{children:[c.jsx(dx,{children:"No repositories found"}),de.map(xe=>c.jsx(Rh,{value:xe.id,children:xe.displayName},xe.id))]})})]})}),c.jsx(jn,{value:"browse",className:"mt-2",children:c.jsxs(_e,{type:"button",variant:"outline",className:"w-full justify-start font-normal",onClick:()=>a(!0),disabled:$,children:[c.jsx(Z,{icon:Zs,size:14,strokeWidth:2,className:"mr-2"}),$?c.jsx("span",{className:"text-muted-foreground",children:"Validating..."}):u&&!I?c.jsx("span",{className:"truncate",children:u}):c.jsx("span",{className:"text-muted-foreground",children:"Select folder..."})]})})]}),L&&c.jsx("p",{className:"text-sm text-destructive",children:L}),u&&!L&&c.jsx(Pi,{className:"font-mono text-xs truncate",children:u})]}),c.jsxs($n,{children:[c.jsx(zn,{htmlFor:"baseBranch",children:"Base Branch"}),c.jsxs(ox,{value:f,onValueChange:xe=>{h(xe??""),g(xe??"")},inputValue:m,onInputValueChange:g,itemToStringLabel:xe=>xe,children:[c.jsx(lx,{disabled:!u||ae,placeholder:u?ae?"Loading branches...":"Select branch":"Select repository first",className:"w-full"}),c.jsx(cx,{children:c.jsxs(ux,{children:[c.jsx(dx,{children:"No branches found"}),ce.length>0&&c.jsxs(kE,{children:[Ee.length>0&&c.jsx(TE,{children:"Local"}),ce.map(xe=>c.jsxs(Rh,{value:xe,children:[xe,xe===oe?.current&&c.jsx("span",{className:"text-muted-foreground ml-2",children:"(current)"})]},xe))]}),Ee.length>0&&c.jsxs(kE,{children:[c.jsx(TE,{children:"Remote"}),Ee.map(xe=>c.jsx(Rh,{value:xe,children:xe},xe))]})]})})]})]}),c.jsxs($n,{children:[c.jsx(zn,{children:"Branch Name"}),c.jsx(At,{value:y,onChange:xe=>v(xe.target.value),placeholder:_||"Enter branch name"}),Ce&&c.jsxs(Pi,{children:["Worktree: ",Ce]}),!y.trim()&&_&&c.jsxs(Pi,{children:["Auto-generated: ",_]})]})]}),c.jsxs(wC,{className:"mt-4 shrink-0",children:[c.jsx(SC,{render:c.jsx(_e,{variant:"outline",type:"button"}),children:"Cancel"}),c.jsx(_e,{type:"submit",disabled:!Re,children:o?"Initializing...":"Initialize & Open"})]})]})})}),c.jsx(yh,{open:s,onOpenChange:a,onSelect:Ie,initialPath:X||void 0})]})}function xSt({task:e,compact:t}){const n=Ni(),{data:r}=NC(),i=LWe(),[s,a]=x.useState(!1),o=()=>{i.mutate({taskId:e.id,agent:r||"claude"},{onSuccess:f=>{f&&n({to:"/tasks/$taskId",params:{taskId:e.id}})}})},l=t?"p-3":"p-4",u=t?"mb-2":"mb-3",d=t?"text-xs":"text-sm";return e.type==="scratch"?c.jsxs("div",{className:`rounded-lg border bg-card ${l}`,children:[c.jsx("h2",{className:`${d} font-medium text-muted-foreground ${u}`,children:"Scratch Task"}),c.jsx(_e,{variant:"outline",onClick:o,disabled:i.isPending,className:"w-full",size:t?"sm":"default",children:i.isPending?"Creating...":"Initialize Scratch Task"}),c.jsx("p",{className:`text-muted-foreground italic mt-2 ${t?"text-xs":"text-sm"}`,children:"Creates an isolated directory without git for quick experiments."})]}):c.jsxs("div",{className:`rounded-lg border bg-card ${l}`,children:[c.jsx("h2",{className:`${d} font-medium text-muted-foreground ${u}`,children:"Initialize Task"}),c.jsx(_e,{onClick:()=>a(!0),className:"w-full",size:t?"sm":"default",children:"Initialize as Worktree Task"}),e.type!=="scratch"&&e.type!=="worktree"&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"my-3 flex items-center gap-2",children:[c.jsx("div",{className:"h-px flex-1 bg-border"}),c.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),c.jsx("div",{className:"h-px flex-1 bg-border"})]}),c.jsx(_e,{variant:"outline",onClick:o,disabled:i.isPending,className:"w-full",size:t?"sm":"default",children:i.isPending?"Creating...":"Initialize as Scratch Task"}),c.jsx("p",{className:`text-muted-foreground italic mt-2 ${t?"text-xs":"text-sm"}`,children:"Creates an isolated directory without git for quick experiments."})]}),c.jsx(vSt,{task:e,open:s,onOpenChange:a})]})}const Bce={TO_DO:"To Do",IN_PROGRESS:"In Progress",IN_REVIEW:"In Review",DONE:"Done",CANCELED:"Canceled"},_St={TO_DO:"bg-status-todo/20 text-status-todo",IN_PROGRESS:"bg-status-in-progress/20 text-status-in-progress",IN_REVIEW:"bg-status-in-review/20 text-status-in-review",DONE:"bg-status-done/20 text-status-done",CANCELED:"bg-status-canceled/20 text-status-canceled"};function xNe({task:e,onDeleted:t,compact:n}){const r=AC(),i=Nwe(),s=Owe(),{data:a}=Mc(),[o,l]=x.useState(!1),[u,d]=x.useState(!1),[f,h]=x.useState(e.title),[m,g]=x.useState(!1),[y,v]=x.useState(e.description||""),[_,S]=x.useState(!1),[E,T]=x.useState(e.notes||""),[k,w]=x.useState(""),[A,R]=x.useState(new Set),[I,D]=x.useState(e.prUrl||""),[j,F]=x.useState(!1),[z,P]=x.useState(""),[L,M]=x.useState(!1),$=x.useRef(null),W=x.useMemo(()=>{if(!a)return[];if(!z.trim())return a;const xe=z.toLowerCase();return a.filter(ye=>ye.name.toLowerCase().includes(xe))},[a,z]);x.useEffect(()=>{const xe=ye=>{$.current&&!$.current.contains(ye.target)&&(M(!1),P(""))};return document.addEventListener("mousedown",xe),()=>document.removeEventListener("mousedown",xe)},[]);const Y=xe=>{r.mutate({taskId:e.id,updates:{status:xe}})},q=()=>{f.trim()&&f!==e.title&&r.mutate({taskId:e.id,updates:{title:f.trim()}}),d(!1)},K=()=>{y!==(e.description||"")&&r.mutate({taskId:e.id,updates:{description:y||null}}),g(!1)},X=()=>{E!==(e.notes||"")&&r.mutate({taskId:e.id,updates:{notes:E||null}}),S(!1)},U=xe=>{r.mutate({taskId:e.id,updates:{dueDate:xe}})},J=xe=>{r.mutate({taskId:e.id,updates:{timeEstimate:xe}})},te=xe=>{r.mutate({taskId:e.id,updates:{priority:xe}})},ee=xe=>{r.mutate({taskId:e.id,updates:{recurrenceRule:!xe||xe==="none"?null:xe}})},oe=()=>{const xe=k.trim();xe&&!e.tags.includes(xe)&&(i.mutate({taskId:e.id,tag:xe}),w(""))},ae=xe=>{R(ye=>new Set(ye).add(xe)),s.mutate({taskId:e.id,tag:xe})},se=xe=>{xe.key==="Enter"&&(xe.preventDefault(),oe())},ue=()=>{const xe=I.trim();xe!==(e.prUrl||"")&&r.mutate({taskId:e.id,updates:{prUrl:xe||null}}),F(!1)},de=xe=>{xe.key==="Enter"?(xe.preventDefault(),ue()):xe.key==="Escape"&&(D(e.prUrl||""),F(!1))},ce=xe=>{r.mutate({taskId:e.id,updates:{projectId:xe}}),M(!1),P("")},Ee=a?.find(xe=>xe.id===e.projectId),Ie=g5(e.dueDate,e.status),fe=n?"p-3":"p-4",be=n?"mb-2":"mb-3",ge=n?"text-xs":"text-sm",Ce=n?"gap-3":"gap-4",Re=n?"space-y-4":"space-y-6";return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"shrink-0 border-b border-border bg-background px-4 py-3",children:c.jsxs("div",{className:"flex items-center justify-between gap-4",children:[c.jsx("div",{className:"flex-1 min-w-0",children:u?c.jsx(At,{value:f,onChange:xe=>h(xe.target.value),onBlur:q,onKeyDown:xe=>{xe.key==="Enter"&&q(),xe.key==="Escape"&&(h(e.title),d(!1))},className:n?"text-base font-semibold":"text-lg font-semibold",autoFocus:!0}):c.jsx("h1",{className:`${n?"text-base":"text-lg"} font-semibold cursor-pointer hover:text-primary`,onClick:()=>d(!0),children:e.title})}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(sf,{children:[c.jsx(af,{render:c.jsx("button",{type:"button",className:`rounded-full ${n?"px-2.5 py-0.5 text-xs":"px-3 py-1 text-sm"} font-medium ${_St[e.status]}`}),children:c.jsxs("span",{className:"flex items-center gap-1",children:[r.isPending&&r.variables?.updates?.status&&c.jsx(Z,{icon:Nt,size:12,className:"animate-spin"}),Bce[e.status]]})}),c.jsx(of,{align:"end",children:c.jsx(CR,{value:e.status,onValueChange:Y,children:Object.entries(Bce).map(([xe,ye])=>c.jsx(kR,{value:xe,children:ye},xe))})})]}),c.jsx(_e,{variant:"ghost",size:"icon-sm",className:`cursor-pointer ${e.pinned?"text-primary":"text-muted-foreground hover:text-foreground"}`,onClick:()=>r.mutate({taskId:e.id,updates:{pinned:!e.pinned}}),title:e.pinned?"Unpin task":"Pin task to top",children:c.jsx(Z,{icon:e.pinned?nD:wE,size:n?14:16,strokeWidth:2})}),c.jsx(_e,{variant:"ghost",size:"icon-sm",className:"cursor-pointer text-muted-foreground hover:text-destructive",onClick:()=>l(!0),children:c.jsx(Z,{icon:ks,size:n?14:16,strokeWidth:2})})]})]})}),c.jsx("div",{className:`flex-1 overflow-auto ${n?"p-4":"p-6"}`,children:c.jsxs("div",{className:`${n?"":"mx-auto max-w-3xl"} ${Re}`,children:[c.jsxs("div",{className:`rounded-lg border bg-card ${fe}`,children:[c.jsxs("div",{className:`flex items-center justify-between ${be}`,children:[c.jsx("h2",{className:`${ge} font-medium text-muted-foreground`,children:"Description"}),!m&&c.jsx(_e,{variant:"ghost",size:"sm",onClick:()=>g(!0),className:n?"text-xs h-6":"text-xs",children:"Edit"})]}),m?c.jsxs("div",{className:"space-y-2",children:[c.jsx(mW,{value:y,onValueChange:v,placeholder:"Add a description...",rows:n?4:6}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(_e,{variant:"outline",size:"sm",onClick:()=>{v(e.description||""),g(!1)},children:"Cancel"}),c.jsx(_e,{size:"sm",onClick:K,children:"Save"})]})]}):c.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:e.description?c.jsx("p",{className:`whitespace-pre-wrap ${n?"text-sm":""}`,children:e.description}):c.jsx("p",{className:`text-muted-foreground italic ${n?"text-sm":""}`,children:"No description"})})]}),c.jsxs("div",{className:`grid ${Ce} sm:grid-cols-2`,children:[c.jsxs("div",{className:`rounded-lg border bg-card ${fe}`,children:[c.jsx("h2",{className:`${ge} font-medium text-muted-foreground ${be}`,children:"Tags"}),c.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.tags.map(xe=>{const ye=A.has(xe);return c.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full border border-border bg-card ${n?"px-2 py-0.5":"px-2.5 py-1"} text-xs font-medium`,children:[xe,c.jsx("button",{type:"button",onClick:()=>ae(xe),disabled:ye,className:"text-muted-foreground hover:text-foreground disabled:opacity-50",children:c.jsx(Z,{icon:ye?Nt:Tn,size:10,className:ye?"animate-spin":""})})]},xe)}),c.jsx("input",{type:"text",value:k,onChange:xe=>w(xe.target.value),onKeyDown:se,onBlur:oe,placeholder:e.tags.length===0?"Add tag...":"+",className:"w-16 bg-transparent text-xs outline-none placeholder:text-muted-foreground"})]})]}),c.jsxs("div",{className:`rounded-lg border bg-card ${fe}`,children:[c.jsx("h2",{className:`${ge} font-medium text-muted-foreground ${be}`,children:"Due Date"}),c.jsx(GW,{value:e.dueDate,onChange:U,isOverdue:!!Ie})]}),c.jsxs("div",{className:`rounded-lg border bg-card ${fe}`,children:[c.jsx("h2",{className:`${ge} font-medium text-muted-foreground ${be}`,children:"Estimate"}),c.jsx(KW,{value:e.timeEstimate,onChange:J})]}),c.jsxs("div",{className:`rounded-lg border bg-card ${fe}`,children:[c.jsx("h2",{className:`${ge} font-medium text-muted-foreground ${be}`,children:"Priority"}),c.jsx(YW,{value:e.priority,onChange:te})]}),!e.type&&c.jsxs("div",{className:`rounded-lg border bg-card ${fe}`,children:[c.jsx("h2",{className:`${ge} font-medium text-muted-foreground ${be}`,children:"Repeat"}),c.jsxs(Qr,{value:e.recurrenceRule||"none",onValueChange:ee,children:[c.jsx(Jr,{className:"w-full",children:c.jsx(Zr,{})}),c.jsxs(ei,{children:[c.jsx(jt,{value:"none",children:"None"}),c.jsx(jt,{value:"daily",children:"Daily"}),c.jsx(jt,{value:"weekly",children:"Weekly"}),c.jsx(jt,{value:"biweekly",children:"Biweekly"}),c.jsx(jt,{value:"monthly",children:"Monthly"}),c.jsx(jt,{value:"quarterly",children:"Quarterly"}),c.jsx(jt,{value:"yearly",children:"Yearly"})]})]}),e.recurrenceSourceTaskId&&c.jsx("p",{className:`text-muted-foreground italic mt-2 ${n?"text-xs":"text-sm"}`,children:"Part of a recurring series"})]}),c.jsxs("div",{className:`rounded-lg border bg-card ${fe} sm:col-span-2`,children:[c.jsx("h2",{className:`${ge} font-medium text-muted-foreground ${be}`,children:"Project"}),c.jsxs("div",{className:"relative",ref:$,children:[L?c.jsx("input",{type:"text",value:z,onChange:xe=>P(xe.target.value),onKeyDown:xe=>{xe.key==="Escape"&&(M(!1),P(""))},placeholder:"Search projects...",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",autoFocus:!0}):c.jsxs("button",{type:"button",onClick:()=>M(!0),className:"flex items-center gap-2 text-sm hover:text-primary",children:[c.jsx(Z,{icon:Zs,size:14,strokeWidth:2,className:"text-muted-foreground"}),c.jsx("span",{className:Ee?"":"text-muted-foreground italic",children:Ee?.name??"No project"})]}),L&&c.jsxs("div",{className:"absolute top-full left-0 right-0 mt-1 bg-popover border rounded-md shadow-lg z-50 max-h-48 overflow-y-auto",children:[c.jsxs("button",{type:"button",className:Ae("w-full px-3 py-2 text-left text-sm hover:bg-accent flex items-center justify-between",!e.projectId&&"bg-accent"),onClick:()=>ce(null),children:[c.jsx("span",{className:"text-muted-foreground",children:"No project"}),!e.projectId&&c.jsx(Z,{icon:Q_e,size:14,className:"text-primary"})]}),W.map(xe=>c.jsxs("button",{type:"button",className:Ae("w-full px-3 py-2 text-left text-sm hover:bg-accent flex items-center justify-between",e.projectId===xe.id&&"bg-accent"),onClick:()=>ce(xe.id),children:[c.jsx("span",{children:xe.name}),c.jsxs("span",{className:"text-xs text-muted-foreground",children:[xe.taskCount??0," tasks"]})]},xe.id)),W.length===0&&z&&c.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"No projects found"})]})]})]})]}),c.jsxs("div",{className:`rounded-lg border bg-card ${fe}`,children:[c.jsxs("div",{className:`flex items-center justify-between ${be}`,children:[c.jsx("h2",{className:`${ge} font-medium text-muted-foreground`,children:"Pull Request"}),!j&&e.prUrl&&c.jsx(_e,{variant:"ghost",size:"sm",onClick:()=>F(!0),className:n?"text-xs h-6":"text-xs",children:"Edit"})]}),j?c.jsxs("div",{className:"flex gap-2",children:[c.jsx(At,{value:I,onChange:xe=>D(xe.target.value),onKeyDown:de,placeholder:"https://github.com/owner/repo/pull/123",className:"flex-1",autoFocus:!0}),c.jsx(_e,{size:"sm",onClick:ue,children:"Save"})]}):e.prUrl?c.jsxs("button",{onClick:()=>jl(e.prUrl),className:"flex items-center gap-2 text-sm text-primary hover:underline",children:[c.jsx(Z,{icon:ud,size:14,strokeWidth:2}),c.jsxs("span",{children:["#",e.prUrl.match(/\/pull\/(\d+)/)?.[1]??"PR"]}),c.jsx(Z,{icon:V_e,size:12,strokeWidth:2,className:"text-muted-foreground"})]}):c.jsx(_e,{variant:"outline",size:"sm",onClick:()=>F(!0),className:n?"text-xs h-6":"text-xs",children:"Link PR"})]}),c.jsxs("div",{className:`rounded-lg border bg-card ${fe}`,children:[c.jsx("h2",{className:`${ge} font-medium text-muted-foreground ${be}`,children:"Dependencies"}),c.jsx(yNe,{taskId:e.id})]}),c.jsxs("div",{className:`rounded-lg border bg-card ${fe}`,children:[c.jsx("h2",{className:`${ge} font-medium text-muted-foreground ${be}`,children:"Links"}),c.jsx(bNe,{taskId:e.id,links:e.links||[]})]}),c.jsxs("div",{className:`rounded-lg border bg-card ${fe}`,children:[c.jsxs("div",{className:`flex items-center justify-between ${be}`,children:[c.jsx("h2",{className:`${ge} font-medium text-muted-foreground`,children:"Notes"}),!_&&c.jsx(_e,{variant:"ghost",size:"sm",onClick:()=>S(!0),className:n?"text-xs h-6":"text-xs",children:"Edit"})]}),_?c.jsxs("div",{className:"space-y-2",children:[c.jsx("textarea",{value:E,onChange:xe=>T(xe.target.value),placeholder:"Add notes...",rows:n?3:4,className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none",autoFocus:!0}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(_e,{variant:"outline",size:"sm",onClick:()=>{T(e.notes||""),S(!1)},children:"Cancel"}),c.jsx(_e,{size:"sm",onClick:X,children:"Save"})]})]}):c.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:e.notes?c.jsx("p",{className:`whitespace-pre-wrap ${n?"text-sm":""}`,children:e.notes}):c.jsx("p",{className:`text-muted-foreground italic ${n?"text-sm":""}`,children:"No notes"})})]}),c.jsxs("div",{className:`rounded-lg border bg-card ${fe}`,children:[c.jsx("h2",{className:`${ge} font-medium text-muted-foreground ${be}`,children:"Attachments"}),c.jsx(vNe,{taskId:e.id})]}),!e.worktreePath&&c.jsx(xSt,{task:e,compact:n})]})}),c.jsx(e2,{task:e,open:o,onOpenChange:l,onDeleted:t})]})}function b5({task:e,open:t,onOpenChange:n}){const r=()=>{n(!1)};return c.jsx(Ya,{open:t,onOpenChange:n,children:c.jsx(Xa,{className:"sm:max-w-2xl max-h-[85vh] overflow-y-auto p-0",showCloseButton:!1,children:c.jsx(xNe,{task:e,onDeleted:r,compact:!0})})})}const h6=["TO_DO","IN_PROGRESS","IN_REVIEW","DONE","CANCELED"];function SSt({status:e}){const{t}=Ot("common"),n=x.useRef(null),[r,i]=x.useState(!1);return x.useEffect(()=>{const s=n.current;if(s)return h5({element:s,getData:()=>({type:"column",status:e}),canDrop:({source:a})=>a.data.type==="task",onDragEnter:()=>i(!0),onDragLeave:()=>i(!1),onDrop:()=>i(!1)})},[e]),c.jsx("div",{ref:n,className:Ae("flex-1 rounded-lg border-2 border-dashed px-3 py-2 text-center text-xs font-medium transition-colors",r?"border-primary bg-primary/10 text-primary":"border-muted-foreground/30 text-muted-foreground"),children:t(`statuses.${e}`)})}function wSt({projectFilter:e,searchQuery:t,tagsFilter:n,taskTypesFilter:r,prioritiesFilter:i,showTypeLabels:s,selectedTaskId:a}){const{t:o}=Ot("common"),l=Ni(),{data:u=[],isLoading:d}=cl(),{data:f=[]}=Mc(),{data:h}=Awe(),m=kwe(),{activeTask:g}=hNe(),{clearSelection:y,selectedIds:v}=GQ(),[_,S]=x.useState("IN_PROGRESS"),E=x.useMemo(()=>a?u.find(P=>P.id===a)??null:null,[a,u]),T=E&&!E.worktreePath,k=x.useCallback(P=>{P||l({to:"/tasks",search:L=>({...L,task:void 0}),replace:!0})},[l]),{blockedTaskIds:w,blockingTaskIds:A}=x.useMemo(()=>{if(!h)return{blockedTaskIds:new Set,blockingTaskIds:new Set};const P=new Set,L=new Set,M=new Map(h.nodes.map($=>[$.id,$.status]));for(const $ of h.edges){const W=M.get($.source);W&&W!=="DONE"&&W!=="CANCELED"&&(P.add($.target),L.add($.source))}return{blockedTaskIds:P,blockingTaskIds:L}},[h]);x.useEffect(()=>{const P=L=>{L.key==="Escape"&&v.size>0&&y()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[y,v.size]);const{projectRepoIds:R,projectRepoPaths:I}=x.useMemo(()=>{const P=new Set,L=new Set;for(const M of f)for(const $ of M.repositories)P.add($.id),L.add($.path);return{projectRepoIds:P,projectRepoPaths:L}},[f]),{selectedProjectRepoIds:D,selectedProjectRepoPaths:j}=x.useMemo(()=>{if(!e||e==="inbox")return{selectedProjectRepoIds:new Set,selectedProjectRepoPaths:new Set};const P=f.find(L=>L.id===e);return P?{selectedProjectRepoIds:new Set(P.repositories.map(L=>L.id)),selectedProjectRepoPaths:new Set(P.repositories.map(L=>L.path))}:{selectedProjectRepoIds:new Set,selectedProjectRepoPaths:new Set}},[e,f]),F=x.useMemo(()=>{let P=u;return e==="inbox"?P=P.filter(L=>!L.projectId&&(!L.repositoryId||!R.has(L.repositoryId))&&(!L.repoPath||!I.has(L.repoPath))):e&&(P=P.filter(L=>L.projectId===e||L.repositoryId&&D.has(L.repositoryId)||L.repoPath&&j.has(L.repoPath))),n&&n.length>0&&(P=P.filter(L=>L.tags.some(M=>n.includes(M)))),r&&r.length>0&&(P=P.filter(L=>r.includes(TC(L)))),i&&i.length>0&&(P=P.filter(L=>i.includes(L.priority??"medium"))),t?.trim()?P=P.map(L=>({task:L,score:Math.max(Ol(L.title,t),Ol(L.description||"",t),Ol(L.branch||"",t),Ol(L.prUrl||"",t),Ol(L.tags.join(" "),t))})).filter(({score:L})=>L>0).sort((L,M)=>M.score-L.score).map(({task:L})=>L):P=[...P].sort((L,M)=>new Date(M.updatedAt).getTime()-new Date(L.updatedAt).getTime()),P},[u,e,t,n,r,i,R,I,D,j]),z=x.useMemo(()=>{const P={TO_DO:0,IN_PROGRESS:0,IN_REVIEW:0,DONE:0,CANCELED:0};for(const L of F)P[L.status]++;return P},[F]);return x.useEffect(()=>oNe({canMonitor:({source:P})=>P.data.type==="task",onDrop:({source:P,location:L})=>{const M=L.current.dropTargets;if(M.length===0)return;const $=P.data.taskId,W=F.find(U=>U.id===$);if(!W)return;const Y=M[0],q=Y.data,K=U=>{const J=!!(W.repositoryId||W.repoPath);return W.status==="TO_DO"&&U==="IN_PROGRESS"&&J},X=U=>{if(K(U))return()=>{l({to:"/tasks/$taskId",params:{taskId:$},state:{focusTerminal:!0}})}};if(q.type==="column"){const U=q.status;if(U!==W.status){const J=F.filter(te=>te.status===U);m.mutate({taskId:$,status:U,position:J.length},{onSuccess:X(U)})}}else if(q.type==="task"){const U=z0(Y.data),J=q.status,te=F.filter(ae=>ae.status===J).sort((ae,se)=>ae.position-se.position),ee=te.findIndex(ae=>ae.id===q.taskId);let oe=ee;U==="bottom"&&(oe=ee+1),W.status===J&&te.findIndex(se=>se.id===$)<ee&&(oe=Math.max(0,oe-1)),(W.status!==J||oe!==W.position)&&m.mutate({taskId:$,status:J,position:oe},{onSuccess:X(J)})}}}),[F,m,l]),d?c.jsx("div",{className:"flex h-full items-center justify-center",children:c.jsx("p",{className:"text-muted-foreground",children:"Loading tasks..."})}):c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsx("div",{className:"border-b bg-background lg:hidden",children:c.jsx(nl,{value:_,onValueChange:P=>S(P),children:c.jsx(rl,{variant:"line",className:"w-full justify-start px-4",children:h6.map(P=>c.jsxs(In,{value:P,className:"gap-1.5",children:[c.jsx("span",{className:"truncate",children:o(`statuses.${P}`)}),c.jsx("span",{className:"text-muted-foreground",children:z[P]})]},P))})})}),c.jsx("div",{className:"hidden h-full justify-center gap-4 overflow-x-auto p-4 lg:flex",children:h6.map(P=>c.jsx(Pce,{status:P,tasks:F.filter(L=>L.status===P),blockedTaskIds:w,blockingTaskIds:A,showTypeLabels:s},P))}),c.jsx("div",{className:"flex-1 overflow-y-auto p-4 lg:hidden",children:c.jsx(Pce,{status:_,tasks:F.filter(P=>P.status===_),isMobile:!0,blockedTaskIds:w,blockingTaskIds:A,showTypeLabels:s})}),g&&c.jsx("div",{className:"fixed inset-x-0 bottom-0 flex gap-2 border-t bg-background/95 p-4 backdrop-blur-sm lg:hidden",children:h6.filter(P=>P!==_).map(P=>c.jsx(SSt,{status:P},P))}),c.jsx(pSt,{}),T&&E&&c.jsx(b5,{task:E,open:!0,onOpenChange:k})]})}function ESt(e){return c.jsx(fSt,{children:c.jsx(dSt,{children:c.jsx(wSt,{...e})})})}function vo(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=vo(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}const CSt={},$ce=e=>{let t;const n=new Set,r=(d,f)=>{const h=typeof d=="function"?d(t):d;if(!Object.is(h,t)){const m=t;t=f??(typeof h!="object"||h===null)?h:Object.assign({},t,h),n.forEach(g=>g(t,m))}},i=()=>t,l={setState:r,getState:i,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(CSt?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=t=e(r,i,l);return l},kSt=e=>e?$ce(e):$ce,{useDebugValue:TSt}=Q,{useSyncExternalStoreWithSelector:ASt}=o6e,NSt=e=>e;function _Ne(e,t=NSt,n){const r=ASt(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return TSt(r),r}const zce=(e,t)=>{const n=kSt(e),r=(i,s=t)=>_Ne(n,i,s);return Object.assign(r,n),r},OSt=(e,t)=>e?zce(e,t):zce;function Ka(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,i]of e)if(!Object.is(i,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var RSt={value:()=>{}};function y5(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new aO(n)}function aO(e){this._=e}function ISt(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}aO.prototype=y5.prototype={constructor:aO,on:function(e,t){var n=this._,r=ISt(e+"",n),i,s=-1,a=r.length;if(arguments.length<2){for(;++s<a;)if((i=(e=r[s]).type)&&(i=DSt(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<a;)if(i=(e=r[s]).type)n[i]=Uce(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Uce(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new aO(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,s;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],r=0,i=s.length;r<i;++r)s[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,s=r.length;i<s;++i)r[i].value.apply(t,n)}};function DSt(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Uce(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=RSt,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Xz="http://www.w3.org/1999/xhtml";const Hce={svg:"http://www.w3.org/2000/svg",xhtml:Xz,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function v5(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Hce.hasOwnProperty(t)?{space:Hce[t],local:e}:e}function jSt(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Xz&&t.documentElement.namespaceURI===Xz?t.createElement(e):t.createElementNS(n,e)}}function PSt(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function SNe(e){var t=v5(e);return(t.local?PSt:jSt)(t)}function LSt(){}function KQ(e){return e==null?LSt:function(){return this.querySelector(e)}}function MSt(e){typeof e!="function"&&(e=KQ(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=new Array(a),l,u,d=0;d<a;++d)(l=s[d])&&(u=e.call(l,l.__data__,d,s))&&("__data__"in l&&(u.__data__=l.__data__),o[d]=u);return new Pc(r,this._parents)}function FSt(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function BSt(){return[]}function wNe(e){return e==null?BSt:function(){return this.querySelectorAll(e)}}function $St(e){return function(){return FSt(e.apply(this,arguments))}}function zSt(e){typeof e=="function"?e=$St(e):e=wNe(e);for(var t=this._groups,n=t.length,r=[],i=[],s=0;s<n;++s)for(var a=t[s],o=a.length,l,u=0;u<o;++u)(l=a[u])&&(r.push(e.call(l,l.__data__,u,a)),i.push(l));return new Pc(r,i)}function ENe(e){return function(){return this.matches(e)}}function CNe(e){return function(t){return t.matches(e)}}var USt=Array.prototype.find;function HSt(e){return function(){return USt.call(this.children,e)}}function VSt(){return this.firstElementChild}function WSt(e){return this.select(e==null?VSt:HSt(typeof e=="function"?e:CNe(e)))}var qSt=Array.prototype.filter;function GSt(){return Array.from(this.children)}function KSt(e){return function(){return qSt.call(this.children,e)}}function YSt(e){return this.selectAll(e==null?GSt:KSt(typeof e=="function"?e:CNe(e)))}function XSt(e){typeof e!="function"&&(e=ENe(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=[],l,u=0;u<a;++u)(l=s[u])&&e.call(l,l.__data__,u,s)&&o.push(l);return new Pc(r,this._parents)}function kNe(e){return new Array(e.length)}function QSt(){return new Pc(this._enter||this._groups.map(kNe),this._parents)}function NR(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}NR.prototype={constructor:NR,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function ZSt(e){return function(){return e}}function JSt(e,t,n,r,i,s){for(var a=0,o,l=t.length,u=s.length;a<u;++a)(o=t[a])?(o.__data__=s[a],r[a]=o):n[a]=new NR(e,s[a]);for(;a<l;++a)(o=t[a])&&(i[a]=o)}function ewt(e,t,n,r,i,s,a){var o,l,u=new Map,d=t.length,f=s.length,h=new Array(d),m;for(o=0;o<d;++o)(l=t[o])&&(h[o]=m=a.call(l,l.__data__,o,t)+"",u.has(m)?i[o]=l:u.set(m,l));for(o=0;o<f;++o)m=a.call(e,s[o],o,s)+"",(l=u.get(m))?(r[o]=l,l.__data__=s[o],u.delete(m)):n[o]=new NR(e,s[o]);for(o=0;o<d;++o)(l=t[o])&&u.get(h[o])===l&&(i[o]=l)}function twt(e){return e.__data__}function nwt(e,t){if(!arguments.length)return Array.from(this,twt);var n=t?ewt:JSt,r=this._parents,i=this._groups;typeof e!="function"&&(e=ZSt(e));for(var s=i.length,a=new Array(s),o=new Array(s),l=new Array(s),u=0;u<s;++u){var d=r[u],f=i[u],h=f.length,m=rwt(e.call(d,d&&d.__data__,u,r)),g=m.length,y=o[u]=new Array(g),v=a[u]=new Array(g),_=l[u]=new Array(h);n(d,f,y,v,_,m,t);for(var S=0,E=0,T,k;S<g;++S)if(T=y[S]){for(S>=E&&(E=S+1);!(k=v[E])&&++E<g;);T._next=k||null}}return a=new Pc(a,r),a._enter=o,a._exit=l,a}function rwt(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function iwt(){return new Pc(this._exit||this._groups.map(kNe),this._parents)}function swt(e,t,n){var r=this.enter(),i=this,s=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),n==null?s.remove():n(s),r&&i?r.merge(i).order():i}function awt(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,s=r.length,a=Math.min(i,s),o=new Array(i),l=0;l<a;++l)for(var u=n[l],d=r[l],f=u.length,h=o[l]=new Array(f),m,g=0;g<f;++g)(m=u[g]||d[g])&&(h[g]=m);for(;l<i;++l)o[l]=n[l];return new Pc(o,this._parents)}function owt(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,s=r[i],a;--i>=0;)(a=r[i])&&(s&&a.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(a,s),s=a);return this}function lwt(e){e||(e=cwt);function t(f,h){return f&&h?e(f.__data__,h.__data__):!f-!h}for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s){for(var a=n[s],o=a.length,l=i[s]=new Array(o),u,d=0;d<o;++d)(u=a[d])&&(l[d]=u);l.sort(t)}return new Pc(i,this._parents).order()}function cwt(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function uwt(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function dwt(){return Array.from(this)}function fwt(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,s=r.length;i<s;++i){var a=r[i];if(a)return a}return null}function hwt(){let e=0;for(const t of this)++e;return e}function pwt(){return!this.node()}function mwt(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],s=0,a=i.length,o;s<a;++s)(o=i[s])&&e.call(o,o.__data__,s,i);return this}function gwt(e){return function(){this.removeAttribute(e)}}function bwt(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ywt(e,t){return function(){this.setAttribute(e,t)}}function vwt(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function xwt(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function _wt(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Swt(e,t){var n=v5(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?bwt:gwt:typeof t=="function"?n.local?_wt:xwt:n.local?vwt:ywt)(n,t))}function TNe(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function wwt(e){return function(){this.style.removeProperty(e)}}function Ewt(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Cwt(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function kwt(e,t,n){return arguments.length>1?this.each((t==null?wwt:typeof t=="function"?Cwt:Ewt)(e,t,n??"")):Ax(this.node(),e)}function Ax(e,t){return e.style.getPropertyValue(t)||TNe(e).getComputedStyle(e,null).getPropertyValue(t)}function Twt(e){return function(){delete this[e]}}function Awt(e,t){return function(){this[e]=t}}function Nwt(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Owt(e,t){return arguments.length>1?this.each((t==null?Twt:typeof t=="function"?Nwt:Awt)(e,t)):this.node()[e]}function ANe(e){return e.trim().split(/^|\s+/)}function YQ(e){return e.classList||new NNe(e)}function NNe(e){this._node=e,this._names=ANe(e.getAttribute("class")||"")}NNe.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function ONe(e,t){for(var n=YQ(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function RNe(e,t){for(var n=YQ(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function Rwt(e){return function(){ONe(this,e)}}function Iwt(e){return function(){RNe(this,e)}}function Dwt(e,t){return function(){(t.apply(this,arguments)?ONe:RNe)(this,e)}}function jwt(e,t){var n=ANe(e+"");if(arguments.length<2){for(var r=YQ(this.node()),i=-1,s=n.length;++i<s;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?Dwt:t?Rwt:Iwt)(n,t))}function Pwt(){this.textContent=""}function Lwt(e){return function(){this.textContent=e}}function Mwt(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Fwt(e){return arguments.length?this.each(e==null?Pwt:(typeof e=="function"?Mwt:Lwt)(e)):this.node().textContent}function Bwt(){this.innerHTML=""}function $wt(e){return function(){this.innerHTML=e}}function zwt(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Uwt(e){return arguments.length?this.each(e==null?Bwt:(typeof e=="function"?zwt:$wt)(e)):this.node().innerHTML}function Hwt(){this.nextSibling&&this.parentNode.appendChild(this)}function Vwt(){return this.each(Hwt)}function Wwt(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function qwt(){return this.each(Wwt)}function Gwt(e){var t=typeof e=="function"?e:SNe(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Kwt(){return null}function Ywt(e,t){var n=typeof e=="function"?e:SNe(e),r=t==null?Kwt:typeof t=="function"?t:KQ(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Xwt(){var e=this.parentNode;e&&e.removeChild(this)}function Qwt(){return this.each(Xwt)}function Zwt(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Jwt(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function eEt(e){return this.select(e?Jwt:Zwt)}function tEt(e){return arguments.length?this.property("__data__",e):this.node().__data__}function nEt(e){return function(t){e.call(this,t,this.__data__)}}function rEt(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function iEt(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,s;n<i;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++r]=s;++r?t.length=r:delete this.__on}}}function sEt(e,t,n){return function(){var r=this.__on,i,s=nEt(t);if(r){for(var a=0,o=r.length;a<o;++a)if((i=r[a]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=s,i.options=n),i.value=t;return}}this.addEventListener(e.type,s,n),i={type:e.type,name:e.name,value:t,listener:s,options:n},r?r.push(i):this.__on=[i]}}function aEt(e,t,n){var r=rEt(e+""),i,s=r.length,a;if(arguments.length<2){var o=this.node().__on;if(o){for(var l=0,u=o.length,d;l<u;++l)for(i=0,d=o[l];i<s;++i)if((a=r[i]).type===d.type&&a.name===d.name)return d.value}return}for(o=t?sEt:iEt,i=0;i<s;++i)this.each(o(r[i],t,n));return this}function INe(e,t,n){var r=TNe(e),i=r.CustomEvent;typeof i=="function"?i=new i(t,n):(i=r.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function oEt(e,t){return function(){return INe(this,e,t)}}function lEt(e,t){return function(){return INe(this,e,t.apply(this,arguments))}}function cEt(e,t){return this.each((typeof t=="function"?lEt:oEt)(e,t))}function*uEt(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,s=r.length,a;i<s;++i)(a=r[i])&&(yield a)}var DNe=[null];function Pc(e,t){this._groups=e,this._parents=t}function ck(){return new Pc([[document.documentElement]],DNe)}function dEt(){return this}Pc.prototype=ck.prototype={constructor:Pc,select:MSt,selectAll:zSt,selectChild:WSt,selectChildren:YSt,filter:XSt,data:nwt,enter:QSt,exit:iwt,join:swt,merge:awt,selection:dEt,order:owt,sort:lwt,call:uwt,nodes:dwt,node:fwt,size:hwt,empty:pwt,each:mwt,attr:Swt,style:kwt,property:Owt,classed:jwt,text:Fwt,html:Uwt,raise:Vwt,lower:qwt,append:Gwt,insert:Ywt,remove:Qwt,clone:eEt,datum:tEt,on:aEt,dispatch:cEt,[Symbol.iterator]:uEt};function yu(e){return typeof e=="string"?new Pc([[document.querySelector(e)]],[document.documentElement]):new Pc([[e]],DNe)}function fEt(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ed(e,t){if(e=fEt(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const hEt={passive:!1},r2={capture:!0,passive:!1};function p6(e){e.stopImmediatePropagation()}function U0(e){e.preventDefault(),e.stopImmediatePropagation()}function jNe(e){var t=e.document.documentElement,n=yu(e).on("dragstart.drag",U0,r2);"onselectstart"in t?n.on("selectstart.drag",U0,r2):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function PNe(e,t){var n=e.document.documentElement,r=yu(e).on("dragstart.drag",null);t&&(r.on("click.drag",U0,r2),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const XA=e=>()=>e;function Qz(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:s,x:a,y:o,dx:l,dy:u,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:o,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}Qz.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function pEt(e){return!e.ctrlKey&&!e.button}function mEt(){return this.parentNode}function gEt(e,t){return t??{x:e.x,y:e.y}}function bEt(){return navigator.maxTouchPoints||"ontouchstart"in this}function yEt(){var e=pEt,t=mEt,n=gEt,r=bEt,i={},s=y5("start","drag","end"),a=0,o,l,u,d,f=0;function h(T){T.on("mousedown.drag",m).filter(r).on("touchstart.drag",v).on("touchmove.drag",_,hEt).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(T,k){if(!(d||!e.call(this,T,k))){var w=E(this,t.call(this,T,k),T,k,"mouse");w&&(yu(T.view).on("mousemove.drag",g,r2).on("mouseup.drag",y,r2),jNe(T.view),p6(T),u=!1,o=T.clientX,l=T.clientY,w("start",T))}}function g(T){if(U0(T),!u){var k=T.clientX-o,w=T.clientY-l;u=k*k+w*w>f}i.mouse("drag",T)}function y(T){yu(T.view).on("mousemove.drag mouseup.drag",null),PNe(T.view,u),U0(T),i.mouse("end",T)}function v(T,k){if(e.call(this,T,k)){var w=T.changedTouches,A=t.call(this,T,k),R=w.length,I,D;for(I=0;I<R;++I)(D=E(this,A,T,k,w[I].identifier,w[I]))&&(p6(T),D("start",T,w[I]))}}function _(T){var k=T.changedTouches,w=k.length,A,R;for(A=0;A<w;++A)(R=i[k[A].identifier])&&(U0(T),R("drag",T,k[A]))}function S(T){var k=T.changedTouches,w=k.length,A,R;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),A=0;A<w;++A)(R=i[k[A].identifier])&&(p6(T),R("end",T,k[A]))}function E(T,k,w,A,R,I){var D=s.copy(),j=ed(I||w,k),F,z,P;if((P=n.call(T,new Qz("beforestart",{sourceEvent:w,target:h,identifier:R,active:a,x:j[0],y:j[1],dx:0,dy:0,dispatch:D}),A))!=null)return F=P.x-j[0]||0,z=P.y-j[1]||0,function L(M,$,W){var Y=j,q;switch(M){case"start":i[R]=L,q=a++;break;case"end":delete i[R],--a;case"drag":j=ed(W||$,k),q=a;break}D.call(M,T,new Qz(M,{sourceEvent:$,subject:P,target:h,identifier:R,active:q,x:j[0]+F,y:j[1]+z,dx:j[0]-Y[0],dy:j[1]-Y[1],dispatch:D}),A)}}return h.filter=function(T){return arguments.length?(e=typeof T=="function"?T:XA(!!T),h):e},h.container=function(T){return arguments.length?(t=typeof T=="function"?T:XA(T),h):t},h.subject=function(T){return arguments.length?(n=typeof T=="function"?T:XA(T),h):n},h.touchable=function(T){return arguments.length?(r=typeof T=="function"?T:XA(!!T),h):r},h.on=function(){var T=s.on.apply(s,arguments);return T===s?h:T},h.clickDistance=function(T){return arguments.length?(f=(T=+T)*T,h):Math.sqrt(f)},h}function XQ(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function LNe(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function uk(){}var i2=.7,OR=1/i2,H0="\\s*([+-]?\\d+)\\s*",s2="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",gf="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",vEt=/^#([0-9a-f]{3,8})$/,xEt=new RegExp(`^rgb\\(${H0},${H0},${H0}\\)$`),_Et=new RegExp(`^rgb\\(${gf},${gf},${gf}\\)$`),SEt=new RegExp(`^rgba\\(${H0},${H0},${H0},${s2}\\)$`),wEt=new RegExp(`^rgba\\(${gf},${gf},${gf},${s2}\\)$`),EEt=new RegExp(`^hsl\\(${s2},${gf},${gf}\\)$`),CEt=new RegExp(`^hsla\\(${s2},${gf},${gf},${s2}\\)$`),Vce={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};XQ(uk,py,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Wce,formatHex:Wce,formatHex8:kEt,formatHsl:TEt,formatRgb:qce,toString:qce});function Wce(){return this.rgb().formatHex()}function kEt(){return this.rgb().formatHex8()}function TEt(){return MNe(this).formatHsl()}function qce(){return this.rgb().formatRgb()}function py(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=vEt.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Gce(t):n===3?new Pl(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?QA(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?QA(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=xEt.exec(e))?new Pl(t[1],t[2],t[3],1):(t=_Et.exec(e))?new Pl(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=SEt.exec(e))?QA(t[1],t[2],t[3],t[4]):(t=wEt.exec(e))?QA(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=EEt.exec(e))?Xce(t[1],t[2]/100,t[3]/100,1):(t=CEt.exec(e))?Xce(t[1],t[2]/100,t[3]/100,t[4]):Vce.hasOwnProperty(e)?Gce(Vce[e]):e==="transparent"?new Pl(NaN,NaN,NaN,0):null}function Gce(e){return new Pl(e>>16&255,e>>8&255,e&255,1)}function QA(e,t,n,r){return r<=0&&(e=t=n=NaN),new Pl(e,t,n,r)}function AEt(e){return e instanceof uk||(e=py(e)),e?(e=e.rgb(),new Pl(e.r,e.g,e.b,e.opacity)):new Pl}function Zz(e,t,n,r){return arguments.length===1?AEt(e):new Pl(e,t,n,r??1)}function Pl(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}XQ(Pl,Zz,LNe(uk,{brighter(e){return e=e==null?OR:Math.pow(OR,e),new Pl(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?i2:Math.pow(i2,e),new Pl(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Pl(Gb(this.r),Gb(this.g),Gb(this.b),RR(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Kce,formatHex:Kce,formatHex8:NEt,formatRgb:Yce,toString:Yce}));function Kce(){return`#${Cb(this.r)}${Cb(this.g)}${Cb(this.b)}`}function NEt(){return`#${Cb(this.r)}${Cb(this.g)}${Cb(this.b)}${Cb((isNaN(this.opacity)?1:this.opacity)*255)}`}function Yce(){const e=RR(this.opacity);return`${e===1?"rgb(":"rgba("}${Gb(this.r)}, ${Gb(this.g)}, ${Gb(this.b)}${e===1?")":`, ${e})`}`}function RR(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Gb(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Cb(e){return e=Gb(e),(e<16?"0":"")+e.toString(16)}function Xce(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ad(e,t,n,r)}function MNe(e){if(e instanceof ad)return new ad(e.h,e.s,e.l,e.opacity);if(e instanceof uk||(e=py(e)),!e)return new ad;if(e instanceof ad)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),s=Math.max(t,n,r),a=NaN,o=s-i,l=(s+i)/2;return o?(t===s?a=(n-r)/o+(n<r)*6:n===s?a=(r-t)/o+2:a=(t-n)/o+4,o/=l<.5?s+i:2-s-i,a*=60):o=l>0&&l<1?0:a,new ad(a,o,l,e.opacity)}function OEt(e,t,n,r){return arguments.length===1?MNe(e):new ad(e,t,n,r??1)}function ad(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}XQ(ad,OEt,LNe(uk,{brighter(e){return e=e==null?OR:Math.pow(OR,e),new ad(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?i2:Math.pow(i2,e),new ad(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new Pl(m6(e>=240?e-240:e+120,i,r),m6(e,i,r),m6(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new ad(Qce(this.h),ZA(this.s),ZA(this.l),RR(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=RR(this.opacity);return`${e===1?"hsl(":"hsla("}${Qce(this.h)}, ${ZA(this.s)*100}%, ${ZA(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Qce(e){return e=(e||0)%360,e<0?e+360:e}function ZA(e){return Math.max(0,Math.min(1,e||0))}function m6(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const QQ=e=>()=>e;function REt(e,t){return function(n){return e+n*t}}function IEt(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function DEt(e){return(e=+e)==1?FNe:function(t,n){return n-t?IEt(t,n,e):QQ(isNaN(t)?n:t)}}function FNe(e,t){var n=t-e;return n?REt(e,n):QQ(isNaN(e)?t:e)}const IR=(function e(t){var n=DEt(t);function r(i,s){var a=n((i=Zz(i)).r,(s=Zz(s)).r),o=n(i.g,s.g),l=n(i.b,s.b),u=FNe(i.opacity,s.opacity);return function(d){return i.r=a(d),i.g=o(d),i.b=l(d),i.opacity=u(d),i+""}}return r.gamma=e,r})(1);function jEt(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(s){for(i=0;i<n;++i)r[i]=e[i]*(1-s)+t[i]*s;return r}}function PEt(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function LEt(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=new Array(r),s=new Array(n),a;for(a=0;a<r;++a)i[a]=t_(e[a],t[a]);for(;a<n;++a)s[a]=t[a];return function(o){for(a=0;a<r;++a)s[a]=i[a](o);return s}}function MEt(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function rd(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function FEt(e,t){var n={},r={},i;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(i in t)i in e?n[i]=t_(e[i],t[i]):r[i]=t[i];return function(s){for(i in n)r[i]=n[i](s);return r}}var Jz=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,g6=new RegExp(Jz.source,"g");function BEt(e){return function(){return e}}function $Et(e){return function(t){return e(t)+""}}function BNe(e,t){var n=Jz.lastIndex=g6.lastIndex=0,r,i,s,a=-1,o=[],l=[];for(e=e+"",t=t+"";(r=Jz.exec(e))&&(i=g6.exec(t));)(s=i.index)>n&&(s=t.slice(n,s),o[a]?o[a]+=s:o[++a]=s),(r=r[0])===(i=i[0])?o[a]?o[a]+=i:o[++a]=i:(o[++a]=null,l.push({i:a,x:rd(r,i)})),n=g6.lastIndex;return n<t.length&&(s=t.slice(n),o[a]?o[a]+=s:o[++a]=s),o.length<2?l[0]?$Et(l[0].x):BEt(t):(t=l.length,function(u){for(var d=0,f;d<t;++d)o[(f=l[d]).i]=f.x(u);return o.join("")})}function t_(e,t){var n=typeof t,r;return t==null||n==="boolean"?QQ(t):(n==="number"?rd:n==="string"?(r=py(t))?(t=r,IR):BNe:t instanceof py?IR:t instanceof Date?MEt:PEt(t)?jEt:Array.isArray(t)?LEt:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?FEt:rd)(e,t)}function ZQ(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var Zce=180/Math.PI,eU={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function $Ne(e,t,n,r,i,s){var a,o,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*n+t*r)&&(n-=e*l,r-=t*l),(o=Math.sqrt(n*n+r*r))&&(n/=o,r/=o,l/=o),e*r<t*n&&(e=-e,t=-t,l=-l,a=-a),{translateX:i,translateY:s,rotate:Math.atan2(t,e)*Zce,skewX:Math.atan(l)*Zce,scaleX:a,scaleY:o}}var JA;function zEt(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?eU:$Ne(t.a,t.b,t.c,t.d,t.e,t.f)}function UEt(e){return e==null||(JA||(JA=document.createElementNS("http://www.w3.org/2000/svg","g")),JA.setAttribute("transform",e),!(e=JA.transform.baseVal.consolidate()))?eU:(e=e.matrix,$Ne(e.a,e.b,e.c,e.d,e.e,e.f))}function zNe(e,t,n,r){function i(u){return u.length?u.pop()+" ":""}function s(u,d,f,h,m,g){if(u!==f||d!==h){var y=m.push("translate(",null,t,null,n);g.push({i:y-4,x:rd(u,f)},{i:y-2,x:rd(d,h)})}else(f||h)&&m.push("translate("+f+t+h+n)}function a(u,d,f,h){u!==d?(u-d>180?d+=360:d-u>180&&(u+=360),h.push({i:f.push(i(f)+"rotate(",null,r)-2,x:rd(u,d)})):d&&f.push(i(f)+"rotate("+d+r)}function o(u,d,f,h){u!==d?h.push({i:f.push(i(f)+"skewX(",null,r)-2,x:rd(u,d)}):d&&f.push(i(f)+"skewX("+d+r)}function l(u,d,f,h,m,g){if(u!==f||d!==h){var y=m.push(i(m)+"scale(",null,",",null,")");g.push({i:y-4,x:rd(u,f)},{i:y-2,x:rd(d,h)})}else(f!==1||h!==1)&&m.push(i(m)+"scale("+f+","+h+")")}return function(u,d){var f=[],h=[];return u=e(u),d=e(d),s(u.translateX,u.translateY,d.translateX,d.translateY,f,h),a(u.rotate,d.rotate,f,h),o(u.skewX,d.skewX,f,h),l(u.scaleX,u.scaleY,d.scaleX,d.scaleY,f,h),u=d=null,function(m){for(var g=-1,y=h.length,v;++g<y;)f[(v=h[g]).i]=v.x(m);return f.join("")}}}var HEt=zNe(zEt,"px, ","px)","deg)"),VEt=zNe(UEt,", ",")",")"),WEt=1e-12;function Jce(e){return((e=Math.exp(e))+1/e)/2}function qEt(e){return((e=Math.exp(e))-1/e)/2}function GEt(e){return((e=Math.exp(2*e))-1)/(e+1)}const KEt=(function e(t,n,r){function i(s,a){var o=s[0],l=s[1],u=s[2],d=a[0],f=a[1],h=a[2],m=d-o,g=f-l,y=m*m+g*g,v,_;if(y<WEt)_=Math.log(h/u)/t,v=function(A){return[o+A*m,l+A*g,u*Math.exp(t*A*_)]};else{var S=Math.sqrt(y),E=(h*h-u*u+r*y)/(2*u*n*S),T=(h*h-u*u-r*y)/(2*h*n*S),k=Math.log(Math.sqrt(E*E+1)-E),w=Math.log(Math.sqrt(T*T+1)-T);_=(w-k)/t,v=function(A){var R=A*_,I=Jce(k),D=u/(n*S)*(I*GEt(t*R+k)-qEt(k));return[o+D*m,l+D*g,u*I/Jce(t*R+k)]}}return v.duration=_*1e3*t/Math.SQRT2,v}return i.rho=function(s){var a=Math.max(.001,+s),o=a*a,l=o*o;return e(a,o,l)},i})(Math.SQRT2,2,4);function YEt(e,t){t===void 0&&(t=e,e=t_);for(var n=0,r=t.length-1,i=t[0],s=new Array(r<0?0:r);n<r;)s[n]=e(i,i=t[++n]);return function(a){var o=Math.max(0,Math.min(r-1,Math.floor(a*=r)));return s[o](a-o)}}var Nx=0,bw=0,HS=0,UNe=1e3,DR,yw,jR=0,my=0,x5=0,a2=typeof performance=="object"&&performance.now?performance:Date,HNe=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function JQ(){return my||(HNe(XEt),my=a2.now()+x5)}function XEt(){my=0}function PR(){this._call=this._time=this._next=null}PR.prototype=VNe.prototype={constructor:PR,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?JQ():+n)+(t==null?0:+t),!this._next&&yw!==this&&(yw?yw._next=this:DR=this,yw=this),this._call=e,this._time=n,tU()},stop:function(){this._call&&(this._call=null,this._time=1/0,tU())}};function VNe(e,t,n){var r=new PR;return r.restart(e,t,n),r}function QEt(){JQ(),++Nx;for(var e=DR,t;e;)(t=my-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Nx}function eue(){my=(jR=a2.now())+x5,Nx=bw=0;try{QEt()}finally{Nx=0,JEt(),my=0}}function ZEt(){var e=a2.now(),t=e-jR;t>UNe&&(x5-=t,jR=e)}function JEt(){for(var e,t=DR,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:DR=n);yw=e,tU(r)}function tU(e){if(!Nx){bw&&(bw=clearTimeout(bw));var t=e-my;t>24?(e<1/0&&(bw=setTimeout(eue,e-a2.now()-x5)),HS&&(HS=clearInterval(HS))):(HS||(jR=a2.now(),HS=setInterval(ZEt,UNe)),Nx=1,HNe(eue))}}function tue(e,t,n){var r=new PR;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var e2t=y5("start","end","cancel","interrupt"),t2t=[],WNe=0,nue=1,nU=2,oO=3,rue=4,rU=5,lO=6;function _5(e,t,n,r,i,s){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;n2t(e,n,{name:t,index:r,group:i,on:e2t,tween:t2t,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:WNe})}function eZ(e,t){var n=Ad(e,t);if(n.state>WNe)throw new Error("too late; already scheduled");return n}function Bf(e,t){var n=Ad(e,t);if(n.state>oO)throw new Error("too late; already running");return n}function Ad(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function n2t(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=VNe(s,0,n.time);function s(u){n.state=nue,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var d,f,h,m;if(n.state!==nue)return l();for(d in r)if(m=r[d],m.name===n.name){if(m.state===oO)return tue(a);m.state===rue?(m.state=lO,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete r[d]):+d<t&&(m.state=lO,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete r[d])}if(tue(function(){n.state===oO&&(n.state=rue,n.timer.restart(o,n.delay,n.time),o(u))}),n.state=nU,n.on.call("start",e,e.__data__,n.index,n.group),n.state===nU){for(n.state=oO,i=new Array(h=n.tween.length),d=0,f=-1;d<h;++d)(m=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(i[++f]=m);i.length=f+1}}function o(u){for(var d=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(l),n.state=rU,1),f=-1,h=i.length;++f<h;)i[f].call(e,d);n.state===rU&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=lO,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function cO(e,t){var n=e.__transition,r,i,s=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((r=n[a]).name!==t){s=!1;continue}i=r.state>nU&&r.state<rU,r.state=lO,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}s&&delete e.__transition}}function r2t(e){return this.each(function(){cO(this,e)})}function i2t(e,t){var n,r;return function(){var i=Bf(this,e),s=i.tween;if(s!==n){r=n=s;for(var a=0,o=r.length;a<o;++a)if(r[a].name===t){r=r.slice(),r.splice(a,1);break}}i.tween=r}}function s2t(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var s=Bf(this,e),a=s.tween;if(a!==r){i=(r=a).slice();for(var o={name:t,value:n},l=0,u=i.length;l<u;++l)if(i[l].name===t){i[l]=o;break}l===u&&i.push(o)}s.tween=i}}function a2t(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Ad(this.node(),n).tween,i=0,s=r.length,a;i<s;++i)if((a=r[i]).name===e)return a.value;return null}return this.each((t==null?i2t:s2t)(n,e,t))}function tZ(e,t,n){var r=e._id;return e.each(function(){var i=Bf(this,r);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return Ad(i,r).value[t]}}function qNe(e,t){var n;return(typeof t=="number"?rd:t instanceof py?IR:(n=py(t))?(t=n,IR):BNe)(e,t)}function o2t(e){return function(){this.removeAttribute(e)}}function l2t(e){return function(){this.removeAttributeNS(e.space,e.local)}}function c2t(e,t,n){var r,i=n+"",s;return function(){var a=this.getAttribute(e);return a===i?null:a===r?s:s=t(r=a,n)}}function u2t(e,t,n){var r,i=n+"",s;return function(){var a=this.getAttributeNS(e.space,e.local);return a===i?null:a===r?s:s=t(r=a,n)}}function d2t(e,t,n){var r,i,s;return function(){var a,o=n(this),l;return o==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=o+"",a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o)))}}function f2t(e,t,n){var r,i,s;return function(){var a,o=n(this),l;return o==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=o+"",a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o)))}}function h2t(e,t){var n=v5(e),r=n==="transform"?VEt:qNe;return this.attrTween(e,typeof t=="function"?(n.local?f2t:d2t)(n,r,tZ(this,"attr."+e,t)):t==null?(n.local?l2t:o2t)(n):(n.local?u2t:c2t)(n,r,t))}function p2t(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function m2t(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function g2t(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&m2t(e,s)),n}return i._value=t,i}function b2t(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&p2t(e,s)),n}return i._value=t,i}function y2t(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=v5(e);return this.tween(n,(r.local?g2t:b2t)(r,t))}function v2t(e,t){return function(){eZ(this,e).delay=+t.apply(this,arguments)}}function x2t(e,t){return t=+t,function(){eZ(this,e).delay=t}}function _2t(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?v2t:x2t)(t,e)):Ad(this.node(),t).delay}function S2t(e,t){return function(){Bf(this,e).duration=+t.apply(this,arguments)}}function w2t(e,t){return t=+t,function(){Bf(this,e).duration=t}}function E2t(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?S2t:w2t)(t,e)):Ad(this.node(),t).duration}function C2t(e,t){if(typeof t!="function")throw new Error;return function(){Bf(this,e).ease=t}}function k2t(e){var t=this._id;return arguments.length?this.each(C2t(t,e)):Ad(this.node(),t).ease}function T2t(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Bf(this,e).ease=n}}function A2t(e){if(typeof e!="function")throw new Error;return this.each(T2t(this._id,e))}function N2t(e){typeof e!="function"&&(e=ENe(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=[],l,u=0;u<a;++u)(l=s[u])&&e.call(l,l.__data__,u,s)&&o.push(l);return new Zh(r,this._parents,this._name,this._id)}function O2t(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,i=n.length,s=Math.min(r,i),a=new Array(r),o=0;o<s;++o)for(var l=t[o],u=n[o],d=l.length,f=a[o]=new Array(d),h,m=0;m<d;++m)(h=l[m]||u[m])&&(f[m]=h);for(;o<r;++o)a[o]=t[o];return new Zh(a,this._parents,this._name,this._id)}function R2t(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function I2t(e,t,n){var r,i,s=R2t(t)?eZ:Bf;return function(){var a=s(this,e),o=a.on;o!==r&&(i=(r=o).copy()).on(t,n),a.on=i}}function D2t(e,t){var n=this._id;return arguments.length<2?Ad(this.node(),n).on.on(e):this.each(I2t(n,e,t))}function j2t(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function P2t(){return this.on("end.remove",j2t(this._id))}function L2t(e){var t=this._name,n=this._id;typeof e!="function"&&(e=KQ(e));for(var r=this._groups,i=r.length,s=new Array(i),a=0;a<i;++a)for(var o=r[a],l=o.length,u=s[a]=new Array(l),d,f,h=0;h<l;++h)(d=o[h])&&(f=e.call(d,d.__data__,h,o))&&("__data__"in d&&(f.__data__=d.__data__),u[h]=f,_5(u[h],t,n,h,u,Ad(d,n)));return new Zh(s,this._parents,t,n)}function M2t(e){var t=this._name,n=this._id;typeof e!="function"&&(e=wNe(e));for(var r=this._groups,i=r.length,s=[],a=[],o=0;o<i;++o)for(var l=r[o],u=l.length,d,f=0;f<u;++f)if(d=l[f]){for(var h=e.call(d,d.__data__,f,l),m,g=Ad(d,n),y=0,v=h.length;y<v;++y)(m=h[y])&&_5(m,t,n,y,h,g);s.push(h),a.push(d)}return new Zh(s,a,t,n)}var F2t=ck.prototype.constructor;function B2t(){return new F2t(this._groups,this._parents)}function $2t(e,t){var n,r,i;return function(){var s=Ax(this,e),a=(this.style.removeProperty(e),Ax(this,e));return s===a?null:s===n&&a===r?i:i=t(n=s,r=a)}}function GNe(e){return function(){this.style.removeProperty(e)}}function z2t(e,t,n){var r,i=n+"",s;return function(){var a=Ax(this,e);return a===i?null:a===r?s:s=t(r=a,n)}}function U2t(e,t,n){var r,i,s;return function(){var a=Ax(this,e),o=n(this),l=o+"";return o==null&&(l=o=(this.style.removeProperty(e),Ax(this,e))),a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o))}}function H2t(e,t){var n,r,i,s="style."+t,a="end."+s,o;return function(){var l=Bf(this,e),u=l.on,d=l.value[s]==null?o||(o=GNe(t)):void 0;(u!==n||i!==d)&&(r=(n=u).copy()).on(a,i=d),l.on=r}}function V2t(e,t,n){var r=(e+="")=="transform"?HEt:qNe;return t==null?this.styleTween(e,$2t(e,r)).on("end.style."+e,GNe(e)):typeof t=="function"?this.styleTween(e,U2t(e,r,tZ(this,"style."+e,t))).each(H2t(this._id,e)):this.styleTween(e,z2t(e,r,t),n).on("end.style."+e,null)}function W2t(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function q2t(e,t,n){var r,i;function s(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&W2t(e,a,n)),r}return s._value=t,s}function G2t(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,q2t(e,t,n??""))}function K2t(e){return function(){this.textContent=e}}function Y2t(e){return function(){var t=e(this);this.textContent=t??""}}function X2t(e){return this.tween("text",typeof e=="function"?Y2t(tZ(this,"text",e)):K2t(e==null?"":e+""))}function Q2t(e){return function(t){this.textContent=e.call(this,t)}}function Z2t(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&Q2t(i)),t}return r._value=e,r}function J2t(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Z2t(e))}function eCt(){for(var e=this._name,t=this._id,n=KNe(),r=this._groups,i=r.length,s=0;s<i;++s)for(var a=r[s],o=a.length,l,u=0;u<o;++u)if(l=a[u]){var d=Ad(l,t);_5(l,e,n,u,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Zh(r,this._parents,e,n)}function tCt(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(s,a){var o={value:a},l={value:function(){--i===0&&s()}};n.each(function(){var u=Bf(this,r),d=u.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(o),t._.interrupt.push(o),t._.end.push(l)),u.on=t}),i===0&&s()})}var nCt=0;function Zh(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function KNe(){return++nCt}var ch=ck.prototype;Zh.prototype={constructor:Zh,select:L2t,selectAll:M2t,selectChild:ch.selectChild,selectChildren:ch.selectChildren,filter:N2t,merge:O2t,selection:B2t,transition:eCt,call:ch.call,nodes:ch.nodes,node:ch.node,size:ch.size,empty:ch.empty,each:ch.each,on:D2t,attr:h2t,attrTween:y2t,style:V2t,styleTween:G2t,text:X2t,textTween:J2t,remove:P2t,tween:a2t,delay:_2t,duration:E2t,ease:k2t,easeVarying:A2t,end:tCt,[Symbol.iterator]:ch[Symbol.iterator]};function rCt(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var iCt={time:null,delay:0,duration:250,ease:rCt};function sCt(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function aCt(e){var t,n;e instanceof Zh?(t=e._id,e=e._name):(t=KNe(),(n=iCt).time=JQ(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,s=0;s<i;++s)for(var a=r[s],o=a.length,l,u=0;u<o;++u)(l=a[u])&&_5(l,e,t,u,a,n||sCt(l,t));return new Zh(r,this._parents,e,t)}ck.prototype.interrupt=r2t;ck.prototype.transition=aCt;const eN=e=>()=>e;function oCt(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function Sh(e,t,n){this.k=e,this.x=t,this.y=n}Sh.prototype={constructor:Sh,scale:function(e){return e===1?this:new Sh(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Sh(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Mh=new Sh(1,0,0);Sh.prototype;function b6(e){e.stopImmediatePropagation()}function VS(e){e.preventDefault(),e.stopImmediatePropagation()}function lCt(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function cCt(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function iue(){return this.__zoom||Mh}function uCt(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function dCt(){return navigator.maxTouchPoints||"ontouchstart"in this}function fCt(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a))}function YNe(){var e=lCt,t=cCt,n=fCt,r=uCt,i=dCt,s=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],o=250,l=KEt,u=y5("start","zoom","end"),d,f,h,m=500,g=150,y=0,v=10;function _(P){P.property("__zoom",iue).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",D).filter(i).on("touchstart.zoom",j).on("touchmove.zoom",F).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(P,L,M,$){var W=P.selection?P.selection():P;W.property("__zoom",iue),P!==W?k(P,L,M,$):W.interrupt().each(function(){w(this,arguments).event($).start().zoom(null,typeof L=="function"?L.apply(this,arguments):L).end()})},_.scaleBy=function(P,L,M,$){_.scaleTo(P,function(){var W=this.__zoom.k,Y=typeof L=="function"?L.apply(this,arguments):L;return W*Y},M,$)},_.scaleTo=function(P,L,M,$){_.transform(P,function(){var W=t.apply(this,arguments),Y=this.__zoom,q=M==null?T(W):typeof M=="function"?M.apply(this,arguments):M,K=Y.invert(q),X=typeof L=="function"?L.apply(this,arguments):L;return n(E(S(Y,X),q,K),W,a)},M,$)},_.translateBy=function(P,L,M,$){_.transform(P,function(){return n(this.__zoom.translate(typeof L=="function"?L.apply(this,arguments):L,typeof M=="function"?M.apply(this,arguments):M),t.apply(this,arguments),a)},null,$)},_.translateTo=function(P,L,M,$,W){_.transform(P,function(){var Y=t.apply(this,arguments),q=this.__zoom,K=$==null?T(Y):typeof $=="function"?$.apply(this,arguments):$;return n(Mh.translate(K[0],K[1]).scale(q.k).translate(typeof L=="function"?-L.apply(this,arguments):-L,typeof M=="function"?-M.apply(this,arguments):-M),Y,a)},$,W)};function S(P,L){return L=Math.max(s[0],Math.min(s[1],L)),L===P.k?P:new Sh(L,P.x,P.y)}function E(P,L,M){var $=L[0]-M[0]*P.k,W=L[1]-M[1]*P.k;return $===P.x&&W===P.y?P:new Sh(P.k,$,W)}function T(P){return[(+P[0][0]+ +P[1][0])/2,(+P[0][1]+ +P[1][1])/2]}function k(P,L,M,$){P.on("start.zoom",function(){w(this,arguments).event($).start()}).on("interrupt.zoom end.zoom",function(){w(this,arguments).event($).end()}).tween("zoom",function(){var W=this,Y=arguments,q=w(W,Y).event($),K=t.apply(W,Y),X=M==null?T(K):typeof M=="function"?M.apply(W,Y):M,U=Math.max(K[1][0]-K[0][0],K[1][1]-K[0][1]),J=W.__zoom,te=typeof L=="function"?L.apply(W,Y):L,ee=l(J.invert(X).concat(U/J.k),te.invert(X).concat(U/te.k));return function(oe){if(oe===1)oe=te;else{var ae=ee(oe),se=U/ae[2];oe=new Sh(se,X[0]-ae[0]*se,X[1]-ae[1]*se)}q.zoom(null,oe)}})}function w(P,L,M){return!M&&P.__zooming||new A(P,L)}function A(P,L){this.that=P,this.args=L,this.active=0,this.sourceEvent=null,this.extent=t.apply(P,L),this.taps=0}A.prototype={event:function(P){return P&&(this.sourceEvent=P),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(P,L){return this.mouse&&P!=="mouse"&&(this.mouse[1]=L.invert(this.mouse[0])),this.touch0&&P!=="touch"&&(this.touch0[1]=L.invert(this.touch0[0])),this.touch1&&P!=="touch"&&(this.touch1[1]=L.invert(this.touch1[0])),this.that.__zoom=L,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(P){var L=yu(this.that).datum();u.call(P,this.that,new oCt(P,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:u}),L)}};function R(P,...L){if(!e.apply(this,arguments))return;var M=w(this,L).event(P),$=this.__zoom,W=Math.max(s[0],Math.min(s[1],$.k*Math.pow(2,r.apply(this,arguments)))),Y=ed(P);if(M.wheel)(M.mouse[0][0]!==Y[0]||M.mouse[0][1]!==Y[1])&&(M.mouse[1]=$.invert(M.mouse[0]=Y)),clearTimeout(M.wheel);else{if($.k===W)return;M.mouse=[Y,$.invert(Y)],cO(this),M.start()}VS(P),M.wheel=setTimeout(q,g),M.zoom("mouse",n(E(S($,W),M.mouse[0],M.mouse[1]),M.extent,a));function q(){M.wheel=null,M.end()}}function I(P,...L){if(h||!e.apply(this,arguments))return;var M=P.currentTarget,$=w(this,L,!0).event(P),W=yu(P.view).on("mousemove.zoom",X,!0).on("mouseup.zoom",U,!0),Y=ed(P,M),q=P.clientX,K=P.clientY;jNe(P.view),b6(P),$.mouse=[Y,this.__zoom.invert(Y)],cO(this),$.start();function X(J){if(VS(J),!$.moved){var te=J.clientX-q,ee=J.clientY-K;$.moved=te*te+ee*ee>y}$.event(J).zoom("mouse",n(E($.that.__zoom,$.mouse[0]=ed(J,M),$.mouse[1]),$.extent,a))}function U(J){W.on("mousemove.zoom mouseup.zoom",null),PNe(J.view,$.moved),VS(J),$.event(J).end()}}function D(P,...L){if(e.apply(this,arguments)){var M=this.__zoom,$=ed(P.changedTouches?P.changedTouches[0]:P,this),W=M.invert($),Y=M.k*(P.shiftKey?.5:2),q=n(E(S(M,Y),$,W),t.apply(this,L),a);VS(P),o>0?yu(this).transition().duration(o).call(k,q,$,P):yu(this).call(_.transform,q,$,P)}}function j(P,...L){if(e.apply(this,arguments)){var M=P.touches,$=M.length,W=w(this,L,P.changedTouches.length===$).event(P),Y,q,K,X;for(b6(P),q=0;q<$;++q)K=M[q],X=ed(K,this),X=[X,this.__zoom.invert(X),K.identifier],W.touch0?!W.touch1&&W.touch0[2]!==X[2]&&(W.touch1=X,W.taps=0):(W.touch0=X,Y=!0,W.taps=1+!!d);d&&(d=clearTimeout(d)),Y&&(W.taps<2&&(f=X[0],d=setTimeout(function(){d=null},m)),cO(this),W.start())}}function F(P,...L){if(this.__zooming){var M=w(this,L).event(P),$=P.changedTouches,W=$.length,Y,q,K,X;for(VS(P),Y=0;Y<W;++Y)q=$[Y],K=ed(q,this),M.touch0&&M.touch0[2]===q.identifier?M.touch0[0]=K:M.touch1&&M.touch1[2]===q.identifier&&(M.touch1[0]=K);if(q=M.that.__zoom,M.touch1){var U=M.touch0[0],J=M.touch0[1],te=M.touch1[0],ee=M.touch1[1],oe=(oe=te[0]-U[0])*oe+(oe=te[1]-U[1])*oe,ae=(ae=ee[0]-J[0])*ae+(ae=ee[1]-J[1])*ae;q=S(q,Math.sqrt(oe/ae)),K=[(U[0]+te[0])/2,(U[1]+te[1])/2],X=[(J[0]+ee[0])/2,(J[1]+ee[1])/2]}else if(M.touch0)K=M.touch0[0],X=M.touch0[1];else return;M.zoom("touch",n(E(q,K,X),M.extent,a))}}function z(P,...L){if(this.__zooming){var M=w(this,L).event(P),$=P.changedTouches,W=$.length,Y,q;for(b6(P),h&&clearTimeout(h),h=setTimeout(function(){h=null},m),Y=0;Y<W;++Y)q=$[Y],M.touch0&&M.touch0[2]===q.identifier?delete M.touch0:M.touch1&&M.touch1[2]===q.identifier&&delete M.touch1;if(M.touch1&&!M.touch0&&(M.touch0=M.touch1,delete M.touch1),M.touch0)M.touch0[1]=this.__zoom.invert(M.touch0[0]);else if(M.end(),M.taps===2&&(q=ed(q,this),Math.hypot(f[0]-q[0],f[1]-q[1])<v)){var K=yu(this).on("dblclick.zoom");K&&K.apply(this,arguments)}}}return _.wheelDelta=function(P){return arguments.length?(r=typeof P=="function"?P:eN(+P),_):r},_.filter=function(P){return arguments.length?(e=typeof P=="function"?P:eN(!!P),_):e},_.touchable=function(P){return arguments.length?(i=typeof P=="function"?P:eN(!!P),_):i},_.extent=function(P){return arguments.length?(t=typeof P=="function"?P:eN([[+P[0][0],+P[0][1]],[+P[1][0],+P[1][1]]]),_):t},_.scaleExtent=function(P){return arguments.length?(s[0]=+P[0],s[1]=+P[1],_):[s[0],s[1]]},_.translateExtent=function(P){return arguments.length?(a[0][0]=+P[0][0],a[1][0]=+P[1][0],a[0][1]=+P[0][1],a[1][1]=+P[1][1],_):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},_.constrain=function(P){return arguments.length?(n=P,_):n},_.duration=function(P){return arguments.length?(o=+P,_):o},_.interpolate=function(P){return arguments.length?(l=P,_):l},_.on=function(){var P=u.on.apply(u,arguments);return P===u?_:P},_.clickDistance=function(P){return arguments.length?(y=(P=+P)*P,_):Math.sqrt(y)},_.tapDistance=function(P){return arguments.length?(v=+P,_):v},_}const S5=x.createContext(null),hCt=S5.Provider,Jh={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},XNe=Jh.error001();function Li(e,t){const n=x.useContext(S5);if(n===null)throw new Error(XNe);return _Ne(n,e,t)}const Ca=()=>{const e=x.useContext(S5);if(e===null)throw new Error(XNe);return x.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},pCt=e=>e.userSelectionActive?"none":"all";function nZ({position:e,children:t,className:n,style:r,...i}){const s=Li(pCt),a=`${e}`.split("-");return Q.createElement("div",{className:vo(["react-flow__panel",n,...a]),style:{...r,pointerEvents:s},...i},t)}function mCt({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:Q.createElement(nZ,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},Q.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const gCt=({x:e,y:t,label:n,labelStyle:r={},labelShowBg:i=!0,labelBgStyle:s={},labelBgPadding:a=[2,4],labelBgBorderRadius:o=2,children:l,className:u,...d})=>{const f=x.useRef(null),[h,m]=x.useState({x:0,y:0,width:0,height:0}),g=vo(["react-flow__edge-textwrapper",u]);return x.useEffect(()=>{if(f.current){const y=f.current.getBBox();m({x:y.x,y:y.y,width:y.width,height:y.height})}},[n]),typeof n>"u"||!n?null:Q.createElement("g",{transform:`translate(${e-h.width/2} ${t-h.height/2})`,className:g,visibility:h.width?"visible":"hidden",...d},i&&Q.createElement("rect",{width:h.width+2*a[0],x:-a[0],y:-a[1],height:h.height+2*a[1],className:"react-flow__edge-textbg",style:s,rx:o,ry:o}),Q.createElement("text",{className:"react-flow__edge-text",y:h.height/2,dy:"0.3em",ref:f,style:r},n),l)};var bCt=x.memo(gCt);const rZ=e=>({width:e.offsetWidth,height:e.offsetHeight}),Ox=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),iZ=(e={x:0,y:0},t)=>({x:Ox(e.x,t[0][0],t[1][0]),y:Ox(e.y,t[0][1],t[1][1])}),sue=(e,t,n)=>e<t?Ox(Math.abs(e-t),1,50)/50:e>n?-Ox(Math.abs(e-n),1,50)/50:0,QNe=(e,t)=>{const n=sue(e.x,35,t.width-35)*20,r=sue(e.y,35,t.height-35)*20;return[n,r]},ZNe=e=>e.getRootNode?.()||window?.document,JNe=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),o2=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),eOe=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),aue=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),yCt=(e,t)=>eOe(JNe(o2(e),o2(t))),iU=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},vCt=e=>Eu(e.width)&&Eu(e.height)&&Eu(e.x)&&Eu(e.y),Eu=e=>!isNaN(e)&&isFinite(e),Cs=Symbol.for("internals"),tOe=["Enter"," ","Escape"],xCt=(e,t)=>{},_Ct=e=>"nativeEvent"in e;function sU(e){const n=(_Ct(e)?e.nativeEvent:e).composedPath?.()?.[0]||e.target;return["INPUT","SELECT","TEXTAREA"].includes(n?.nodeName)||n?.hasAttribute("contenteditable")||!!n?.closest(".nokey")}const nOe=e=>"clientX"in e,Mm=(e,t)=>{const n=nOe(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},LR=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0,dk=({id:e,path:t,labelX:n,labelY:r,label:i,labelStyle:s,labelShowBg:a,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:u,style:d,markerEnd:f,markerStart:h,interactionWidth:m=20})=>Q.createElement(Q.Fragment,null,Q.createElement("path",{id:e,style:d,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:f,markerStart:h}),m&&Q.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:m,className:"react-flow__edge-interaction"}),i&&Eu(n)&&Eu(r)?Q.createElement(bCt,{x:n,y:r,label:i,labelStyle:s,labelShowBg:a,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:u}):null);dk.displayName="BaseEdge";function WS(e,t,n){return n===void 0?n:r=>{const i=t().edges.find(s=>s.id===e);i&&n(r,{...i})}}function rOe({sourceX:e,sourceY:t,targetX:n,targetY:r}){const i=Math.abs(n-e)/2,s=n<e?n+i:n-i,a=Math.abs(r-t)/2,o=r<t?r+a:r-a;return[s,o,i,a]}function iOe({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:s,targetControlX:a,targetControlY:o}){const l=e*.125+i*.375+a*.375+n*.125,u=t*.125+s*.375+o*.375+r*.125,d=Math.abs(l-e),f=Math.abs(u-t);return[l,u,d,f]}var gy;(function(e){e.Strict="strict",e.Loose="loose"})(gy||(gy={}));var kb;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(kb||(kb={}));var l2;(function(e){e.Partial="partial",e.Full="full"})(l2||(l2={}));var hm;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(hm||(hm={}));var c2;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(c2||(c2={}));var kn;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(kn||(kn={}));function oue({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===kn.Left||e===kn.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function sOe({sourceX:e,sourceY:t,sourcePosition:n=kn.Bottom,targetX:r,targetY:i,targetPosition:s=kn.Top}){const[a,o]=oue({pos:n,x1:e,y1:t,x2:r,y2:i}),[l,u]=oue({pos:s,x1:r,y1:i,x2:e,y2:t}),[d,f,h,m]=iOe({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:a,sourceControlY:o,targetControlX:l,targetControlY:u});return[`M${e},${t} C${a},${o} ${l},${u} ${r},${i}`,d,f,h,m]}const sZ=x.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i=kn.Bottom,targetPosition:s=kn.Top,label:a,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:m,markerStart:g,interactionWidth:y})=>{const[v,_,S]=sOe({sourceX:e,sourceY:t,sourcePosition:i,targetX:n,targetY:r,targetPosition:s});return Q.createElement(dk,{path:v,labelX:_,labelY:S,label:a,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:m,markerStart:g,interactionWidth:y})});sZ.displayName="SimpleBezierEdge";const lue={[kn.Left]:{x:-1,y:0},[kn.Right]:{x:1,y:0},[kn.Top]:{x:0,y:-1},[kn.Bottom]:{x:0,y:1}},SCt=({source:e,sourcePosition:t=kn.Bottom,target:n})=>t===kn.Left||t===kn.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},cue=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function wCt({source:e,sourcePosition:t=kn.Bottom,target:n,targetPosition:r=kn.Top,center:i,offset:s}){const a=lue[t],o=lue[r],l={x:e.x+a.x*s,y:e.y+a.y*s},u={x:n.x+o.x*s,y:n.y+o.y*s},d=SCt({source:l,sourcePosition:t,target:u}),f=d.x!==0?"x":"y",h=d[f];let m=[],g,y;const v={x:0,y:0},_={x:0,y:0},[S,E,T,k]=rOe({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[f]*o[f]===-1){g=i.x??S,y=i.y??E;const A=[{x:g,y:l.y},{x:g,y:u.y}],R=[{x:l.x,y},{x:u.x,y}];a[f]===h?m=f==="x"?A:R:m=f==="x"?R:A}else{const A=[{x:l.x,y:u.y}],R=[{x:u.x,y:l.y}];if(f==="x"?m=a.x===h?R:A:m=a.y===h?A:R,t===r){const z=Math.abs(e[f]-n[f]);if(z<=s){const P=Math.min(s-1,s-z);a[f]===h?v[f]=(l[f]>e[f]?-1:1)*P:_[f]=(u[f]>n[f]?-1:1)*P}}if(t!==r){const z=f==="x"?"y":"x",P=a[f]===o[z],L=l[z]>u[z],M=l[z]<u[z];(a[f]===1&&(!P&&L||P&&M)||a[f]!==1&&(!P&&M||P&&L))&&(m=f==="x"?A:R)}const I={x:l.x+v.x,y:l.y+v.y},D={x:u.x+_.x,y:u.y+_.y},j=Math.max(Math.abs(I.x-m[0].x),Math.abs(D.x-m[0].x)),F=Math.max(Math.abs(I.y-m[0].y),Math.abs(D.y-m[0].y));j>=F?(g=(I.x+D.x)/2,y=m[0].y):(g=m[0].x,y=(I.y+D.y)/2)}return[[e,{x:l.x+v.x,y:l.y+v.y},...m,{x:u.x+_.x,y:u.y+_.y},n],g,y,T,k]}function ECt(e,t,n,r){const i=Math.min(cue(e,t)/2,cue(t,n)/2,r),{x:s,y:a}=t;if(e.x===s&&s===n.x||e.y===a&&a===n.y)return`L${s} ${a}`;if(e.y===a){const u=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${s+i*u},${a}Q ${s},${a} ${s},${a+i*d}`}const o=e.x<n.x?1:-1,l=e.y<n.y?-1:1;return`L ${s},${a+i*l}Q ${s},${a} ${s+i*o},${a}`}function aU({sourceX:e,sourceY:t,sourcePosition:n=kn.Bottom,targetX:r,targetY:i,targetPosition:s=kn.Top,borderRadius:a=5,centerX:o,centerY:l,offset:u=20}){const[d,f,h,m,g]=wCt({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:s,center:{x:o,y:l},offset:u});return[d.reduce((v,_,S)=>{let E="";return S>0&&S<d.length-1?E=ECt(d[S-1],_,d[S+1],a):E=`${S===0?"M":"L"}${_.x} ${_.y}`,v+=E,v},""),f,h,m,g]}const w5=x.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:i,labelStyle:s,labelShowBg:a,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:u,style:d,sourcePosition:f=kn.Bottom,targetPosition:h=kn.Top,markerEnd:m,markerStart:g,pathOptions:y,interactionWidth:v})=>{const[_,S,E]=aU({sourceX:e,sourceY:t,sourcePosition:f,targetX:n,targetY:r,targetPosition:h,borderRadius:y?.borderRadius,offset:y?.offset});return Q.createElement(dk,{path:_,labelX:S,labelY:E,label:i,labelStyle:s,labelShowBg:a,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:u,style:d,markerEnd:m,markerStart:g,interactionWidth:v})});w5.displayName="SmoothStepEdge";const aZ=x.memo(e=>Q.createElement(w5,{...e,pathOptions:x.useMemo(()=>({borderRadius:0,offset:e.pathOptions?.offset}),[e.pathOptions?.offset])}));aZ.displayName="StepEdge";function CCt({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[i,s,a,o]=rOe({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,s,a,o]}const oZ=x.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:i,labelStyle:s,labelShowBg:a,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:u,style:d,markerEnd:f,markerStart:h,interactionWidth:m})=>{const[g,y,v]=CCt({sourceX:e,sourceY:t,targetX:n,targetY:r});return Q.createElement(dk,{path:g,labelX:y,labelY:v,label:i,labelStyle:s,labelShowBg:a,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:u,style:d,markerEnd:f,markerStart:h,interactionWidth:m})});oZ.displayName="StraightEdge";function tN(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function uue({pos:e,x1:t,y1:n,x2:r,y2:i,c:s}){switch(e){case kn.Left:return[t-tN(t-r,s),n];case kn.Right:return[t+tN(r-t,s),n];case kn.Top:return[t,n-tN(n-i,s)];case kn.Bottom:return[t,n+tN(i-n,s)]}}function aOe({sourceX:e,sourceY:t,sourcePosition:n=kn.Bottom,targetX:r,targetY:i,targetPosition:s=kn.Top,curvature:a=.25}){const[o,l]=uue({pos:n,x1:e,y1:t,x2:r,y2:i,c:a}),[u,d]=uue({pos:s,x1:r,y1:i,x2:e,y2:t,c:a}),[f,h,m,g]=iOe({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:l,targetControlX:u,targetControlY:d});return[`M${e},${t} C${o},${l} ${u},${d} ${r},${i}`,f,h,m,g]}const MR=x.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i=kn.Bottom,targetPosition:s=kn.Top,label:a,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:m,markerStart:g,pathOptions:y,interactionWidth:v})=>{const[_,S,E]=aOe({sourceX:e,sourceY:t,sourcePosition:i,targetX:n,targetY:r,targetPosition:s,curvature:y?.curvature});return Q.createElement(dk,{path:_,labelX:S,labelY:E,label:a,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:h,markerEnd:m,markerStart:g,interactionWidth:v})});MR.displayName="BezierEdge";const lZ=x.createContext(null),kCt=lZ.Provider;lZ.Consumer;const TCt=()=>x.useContext(lZ),ACt=e=>"id"in e&&"source"in e&&"target"in e,NCt=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,oU=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`,OCt=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),RCt=(e,t)=>{if(!e.source||!e.target)return t;let n;return ACt(e)?n={...e}:n={...e,id:NCt(e)},OCt(n,t)?t:t.concat(n)},lU=({x:e,y:t},[n,r,i],s,[a,o])=>{const l={x:(e-n)/i,y:(t-r)/i};return s?{x:a*Math.round(l.x/a),y:o*Math.round(l.y/o)}:l},oOe=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r}),Kb=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],r=(e.height??0)*t[1],i={x:e.position.x-n,y:e.position.y-r};return{...i,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:i}},E5=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,i)=>{const{x:s,y:a}=Kb(i,t).positionAbsolute;return JNe(r,o2({x:s,y:a,width:i.width||0,height:i.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return eOe(n)},lOe=(e,t,[n,r,i]=[0,0,1],s=!1,a=!1,o=[0,0])=>{const l={x:(t.x-n)/i,y:(t.y-r)/i,width:t.width/i,height:t.height/i},u=[];return e.forEach(d=>{const{width:f,height:h,selectable:m=!0,hidden:g=!1}=d;if(a&&!m||g)return!1;const{positionAbsolute:y}=Kb(d,o),v={x:y.x,y:y.y,width:f||0,height:h||0},_=iU(l,v),S=typeof f>"u"||typeof h>"u"||f===null||h===null,E=s&&_>0,T=(f||0)*(h||0);(S||E||_>=T||d.dragging)&&u.push(d)}),u},cOe=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},uOe=(e,t,n,r,i,s=.1)=>{const a=t/(e.width*(1+s)),o=n/(e.height*(1+s)),l=Math.min(a,o),u=Ox(l,r,i),d=e.x+e.width/2,f=e.y+e.height/2,h=t/2-d*u,m=n/2-f*u;return{x:h,y:m,zoom:u}},ib=(e,t=0)=>e.transition().duration(t);function due(e,t,n,r){return(t[n]||[]).reduce((i,s)=>(`${e.id}-${s.id}-${n}`!==r&&i.push({id:s.id||null,type:n,nodeId:e.id,x:(e.positionAbsolute?.x??0)+s.x+s.width/2,y:(e.positionAbsolute?.y??0)+s.y+s.height/2}),i),[])}function ICt(e,t,n,r,i,s){const{x:a,y:o}=Mm(e),u=t.elementsFromPoint(a,o).find(g=>g.classList.contains("react-flow__handle"));if(u){const g=u.getAttribute("data-nodeid");if(g){const y=cZ(void 0,u),v=u.getAttribute("data-handleid"),_=s({nodeId:g,id:v,type:y});if(_){const S=i.find(E=>E.nodeId===g&&E.type===y&&E.id===v);return{handle:{id:v,type:y,nodeId:g,x:S?.x||n.x,y:S?.y||n.y},validHandleResult:_}}}}let d=[],f=1/0;if(i.forEach(g=>{const y=Math.sqrt((g.x-n.x)**2+(g.y-n.y)**2);if(y<=r){const v=s(g);y<=f&&(y<f?d=[{handle:g,validHandleResult:v}]:y===f&&d.push({handle:g,validHandleResult:v}),f=y)}}),!d.length)return{handle:null,validHandleResult:dOe()};if(d.length===1)return d[0];const h=d.some(({validHandleResult:g})=>g.isValid),m=d.some(({handle:g})=>g.type==="target");return d.find(({handle:g,validHandleResult:y})=>m?g.type==="target":h?y.isValid:!0)||d[0]}const DCt={source:null,target:null,sourceHandle:null,targetHandle:null},dOe=()=>({handleDomNode:null,isValid:!1,connection:DCt,endHandle:null});function fOe(e,t,n,r,i,s,a){const o=i==="target",l=a.querySelector(`.react-flow__handle[data-id="${e?.nodeId}-${e?.id}-${e?.type}"]`),u={...dOe(),handleDomNode:l};if(l){const d=cZ(void 0,l),f=l.getAttribute("data-nodeid"),h=l.getAttribute("data-handleid"),m=l.classList.contains("connectable"),g=l.classList.contains("connectableend"),y={source:o?f:n,sourceHandle:o?h:r,target:o?n:f,targetHandle:o?r:h};u.connection=y,m&&g&&(t===gy.Strict?o&&d==="source"||!o&&d==="target":f!==n||h!==r)&&(u.endHandle={nodeId:f,handleId:h,type:d},u.isValid=s(y))}return u}function jCt({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((i,s)=>{if(s[Cs]){const{handleBounds:a}=s[Cs];let o=[],l=[];a&&(o=due(s,a,"source",`${t}-${n}-${r}`),l=due(s,a,"target",`${t}-${n}-${r}`)),i.push(...o,...l)}return i},[])}function cZ(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function y6(e){e?.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function PCt(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function hOe({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:i,getState:s,setState:a,isValidConnection:o,edgeUpdaterType:l,onReconnectEnd:u}){const d=ZNe(e.target),{connectionMode:f,domNode:h,autoPanOnConnect:m,connectionRadius:g,onConnectStart:y,panBy:v,getNodes:_,cancelConnection:S}=s();let E=0,T;const{x:k,y:w}=Mm(e),A=d?.elementFromPoint(k,w),R=cZ(l,A),I=h?.getBoundingClientRect();if(!I||!R)return;let D,j=Mm(e,I),F=!1,z=null,P=!1,L=null;const M=jCt({nodes:_(),nodeId:n,handleId:t,handleType:R}),$=()=>{if(!m)return;const[q,K]=QNe(j,I);v({x:q,y:K}),E=requestAnimationFrame($)};a({connectionPosition:j,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:R,connectionStartHandle:{nodeId:n,handleId:t,type:R},connectionEndHandle:null}),y?.(e,{nodeId:n,handleId:t,handleType:R});function W(q){const{transform:K}=s();j=Mm(q,I);const{handle:X,validHandleResult:U}=ICt(q,d,lU(j,K,!1,[1,1]),g,M,J=>fOe(J,f,n,t,i?"target":"source",o,d));if(T=X,F||($(),F=!0),L=U.handleDomNode,z=U.connection,P=U.isValid,a({connectionPosition:T&&P?oOe({x:T.x,y:T.y},K):j,connectionStatus:PCt(!!T,P),connectionEndHandle:U.endHandle}),!T&&!P&&!L)return y6(D);z.source!==z.target&&L&&(y6(D),D=L,L.classList.add("connecting","react-flow__handle-connecting"),L.classList.toggle("valid",P),L.classList.toggle("react-flow__handle-valid",P))}function Y(q){(T||L)&&z&&P&&r?.(z),s().onConnectEnd?.(q),l&&u?.(q),y6(D),S(),cancelAnimationFrame(E),F=!1,P=!1,z=null,L=null,d.removeEventListener("mousemove",W),d.removeEventListener("mouseup",Y),d.removeEventListener("touchmove",W),d.removeEventListener("touchend",Y)}d.addEventListener("mousemove",W),d.addEventListener("mouseup",Y),d.addEventListener("touchmove",W),d.addEventListener("touchend",Y)}const fue=()=>!0,LCt=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),MCt=(e,t,n)=>r=>{const{connectionStartHandle:i,connectionEndHandle:s,connectionClickStartHandle:a}=r;return{connecting:i?.nodeId===e&&i?.handleId===t&&i?.type===n||s?.nodeId===e&&s?.handleId===t&&s?.type===n,clickConnecting:a?.nodeId===e&&a?.handleId===t&&a?.type===n}},pOe=x.forwardRef(({type:e="source",position:t=kn.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:s=!0,id:a,onConnect:o,children:l,className:u,onMouseDown:d,onTouchStart:f,...h},m)=>{const g=a||null,y=e==="target",v=Ca(),_=TCt(),{connectOnClick:S,noPanClassName:E}=Li(LCt,Ka),{connecting:T,clickConnecting:k}=Li(MCt(_,g,e),Ka);_||v.getState().onError?.("010",Jh.error010());const w=I=>{const{defaultEdgeOptions:D,onConnect:j,hasDefaultEdges:F}=v.getState(),z={...D,...I};if(F){const{edges:P,setEdges:L}=v.getState();L(RCt(z,P))}j?.(z),o?.(z)},A=I=>{if(!_)return;const D=nOe(I);i&&(D&&I.button===0||!D)&&hOe({event:I,handleId:g,nodeId:_,onConnect:w,isTarget:y,getState:v.getState,setState:v.setState,isValidConnection:n||v.getState().isValidConnection||fue}),D?d?.(I):f?.(I)},R=I=>{const{onClickConnectStart:D,onClickConnectEnd:j,connectionClickStartHandle:F,connectionMode:z,isValidConnection:P}=v.getState();if(!_||!F&&!i)return;if(!F){D?.(I,{nodeId:_,handleId:g,handleType:e}),v.setState({connectionClickStartHandle:{nodeId:_,type:e,handleId:g}});return}const L=ZNe(I.target),M=n||P||fue,{connection:$,isValid:W}=fOe({nodeId:_,id:g,type:e},z,F.nodeId,F.handleId||null,F.type,M,L);W&&w($),j?.(I),v.setState({connectionClickStartHandle:null})};return Q.createElement("div",{"data-handleid":g,"data-nodeid":_,"data-handlepos":t,"data-id":`${_}-${g}-${e}`,className:vo(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",E,u,{source:!y,target:y,connectable:r,connectablestart:i,connectableend:s,connecting:k,connectionindicator:r&&(i&&!T||s&&T)}]),onMouseDown:A,onTouchStart:A,onClick:S?R:void 0,ref:m,...h},l)});pOe.displayName="Handle";var Rx=x.memo(pOe);const mOe=({data:e,isConnectable:t,targetPosition:n=kn.Top,sourcePosition:r=kn.Bottom})=>Q.createElement(Q.Fragment,null,Q.createElement(Rx,{type:"target",position:n,isConnectable:t}),e?.label,Q.createElement(Rx,{type:"source",position:r,isConnectable:t}));mOe.displayName="DefaultNode";var cU=x.memo(mOe);const gOe=({data:e,isConnectable:t,sourcePosition:n=kn.Bottom})=>Q.createElement(Q.Fragment,null,e?.label,Q.createElement(Rx,{type:"source",position:n,isConnectable:t}));gOe.displayName="InputNode";var bOe=x.memo(gOe);const yOe=({data:e,isConnectable:t,targetPosition:n=kn.Top})=>Q.createElement(Q.Fragment,null,Q.createElement(Rx,{type:"target",position:n,isConnectable:t}),e?.label);yOe.displayName="OutputNode";var vOe=x.memo(yOe);const uZ=()=>null;uZ.displayName="GroupNode";const FCt=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),nN=e=>e.id;function BCt(e,t){return Ka(e.selectedNodes.map(nN),t.selectedNodes.map(nN))&&Ka(e.selectedEdges.map(nN),t.selectedEdges.map(nN))}const xOe=x.memo(({onSelectionChange:e})=>{const t=Ca(),{selectedNodes:n,selectedEdges:r}=Li(FCt,BCt);return x.useEffect(()=>{const i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChange.forEach(s=>s(i))},[n,r,e]),null});xOe.displayName="SelectionListener";const $Ct=e=>!!e.onSelectionChange;function zCt({onSelectionChange:e}){const t=Li($Ct);return e||t?Q.createElement(xOe,{onSelectionChange:e}):null}const UCt=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function Qv(e,t){x.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function dr(e,t,n){x.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const HCt=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:i,onConnectStart:s,onConnectEnd:a,onClickConnectStart:o,onClickConnectEnd:l,nodesDraggable:u,nodesConnectable:d,nodesFocusable:f,edgesFocusable:h,edgesUpdatable:m,elevateNodesOnSelect:g,minZoom:y,maxZoom:v,nodeExtent:_,onNodesChange:S,onEdgesChange:E,elementsSelectable:T,connectionMode:k,snapGrid:w,snapToGrid:A,translateExtent:R,connectOnClick:I,defaultEdgeOptions:D,fitView:j,fitViewOptions:F,onNodesDelete:z,onEdgesDelete:P,onNodeDrag:L,onNodeDragStart:M,onNodeDragStop:$,onSelectionDrag:W,onSelectionDragStart:Y,onSelectionDragStop:q,noPanClassName:K,nodeOrigin:X,rfId:U,autoPanOnConnect:J,autoPanOnNodeDrag:te,onError:ee,connectionRadius:oe,isValidConnection:ae,nodeDragThreshold:se})=>{const{setNodes:ue,setEdges:de,setDefaultNodesAndEdges:ce,setMinZoom:Ee,setMaxZoom:Ie,setTranslateExtent:fe,setNodeExtent:be,reset:ge}=Li(UCt,Ka),Ce=Ca();return x.useEffect(()=>{const Re=r?.map(xe=>({...xe,...D}));return ce(n,Re),()=>{ge()}},[]),dr("defaultEdgeOptions",D,Ce.setState),dr("connectionMode",k,Ce.setState),dr("onConnect",i,Ce.setState),dr("onConnectStart",s,Ce.setState),dr("onConnectEnd",a,Ce.setState),dr("onClickConnectStart",o,Ce.setState),dr("onClickConnectEnd",l,Ce.setState),dr("nodesDraggable",u,Ce.setState),dr("nodesConnectable",d,Ce.setState),dr("nodesFocusable",f,Ce.setState),dr("edgesFocusable",h,Ce.setState),dr("edgesUpdatable",m,Ce.setState),dr("elementsSelectable",T,Ce.setState),dr("elevateNodesOnSelect",g,Ce.setState),dr("snapToGrid",A,Ce.setState),dr("snapGrid",w,Ce.setState),dr("onNodesChange",S,Ce.setState),dr("onEdgesChange",E,Ce.setState),dr("connectOnClick",I,Ce.setState),dr("fitViewOnInit",j,Ce.setState),dr("fitViewOnInitOptions",F,Ce.setState),dr("onNodesDelete",z,Ce.setState),dr("onEdgesDelete",P,Ce.setState),dr("onNodeDrag",L,Ce.setState),dr("onNodeDragStart",M,Ce.setState),dr("onNodeDragStop",$,Ce.setState),dr("onSelectionDrag",W,Ce.setState),dr("onSelectionDragStart",Y,Ce.setState),dr("onSelectionDragStop",q,Ce.setState),dr("noPanClassName",K,Ce.setState),dr("nodeOrigin",X,Ce.setState),dr("rfId",U,Ce.setState),dr("autoPanOnConnect",J,Ce.setState),dr("autoPanOnNodeDrag",te,Ce.setState),dr("onError",ee,Ce.setState),dr("connectionRadius",oe,Ce.setState),dr("isValidConnection",ae,Ce.setState),dr("nodeDragThreshold",se,Ce.setState),Qv(e,ue),Qv(t,de),Qv(y,Ee),Qv(v,Ie),Qv(R,fe),Qv(_,be),null},hue={display:"none"},VCt={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},_Oe="react-flow__node-desc",SOe="react-flow__edge-desc",WCt="react-flow__aria-live",qCt=e=>e.ariaLiveMessage;function GCt({rfId:e}){const t=Li(qCt);return Q.createElement("div",{id:`${WCt}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:VCt},t)}function KCt({rfId:e,disableKeyboardA11y:t}){return Q.createElement(Q.Fragment,null,Q.createElement("div",{id:`${_Oe}-${e}`,style:hue},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),Q.createElement("div",{id:`${SOe}-${e}`,style:hue},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&Q.createElement(GCt,{rfId:e}))}var u2=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,r]=x.useState(!1),i=x.useRef(!1),s=x.useRef(new Set([])),[a,o]=x.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.split("+")),d=u.reduce((f,h)=>f.concat(...h),[]);return[u,d]}return[[],[]]},[e]);return x.useEffect(()=>{const l=typeof document<"u"?document:null,u=t?.target||l;if(e!==null){const d=m=>{if(i.current=m.ctrlKey||m.metaKey||m.shiftKey,(!i.current||i.current&&!t.actInsideInputWithModifier)&&sU(m))return!1;const y=mue(m.code,o);s.current.add(m[y]),pue(a,s.current,!1)&&(m.preventDefault(),r(!0))},f=m=>{if((!i.current||i.current&&!t.actInsideInputWithModifier)&&sU(m))return!1;const y=mue(m.code,o);pue(a,s.current,!0)?(r(!1),s.current.clear()):s.current.delete(m[y]),m.key==="Meta"&&s.current.clear(),i.current=!1},h=()=>{s.current.clear(),r(!1)};return u?.addEventListener("keydown",d),u?.addEventListener("keyup",f),window.addEventListener("blur",h),()=>{u?.removeEventListener("keydown",d),u?.removeEventListener("keyup",f),window.removeEventListener("blur",h)}}},[e,r]),n};function pue(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(i=>t.has(i)))}function mue(e,t){return t.includes(e)?"code":"key"}function wOe(e,t,n,r){const i=e.parentNode||e.parentId;if(!i)return n;const s=t.get(i),a=Kb(s,r);return wOe(s,t,{x:(n.x??0)+a.x,y:(n.y??0)+a.y,z:(s[Cs]?.z??0)>(n.z??0)?s[Cs]?.z??0:n.z??0},r)}function EOe(e,t,n){e.forEach(r=>{const i=r.parentNode||r.parentId;if(i&&!e.has(i))throw new Error(`Parent node ${i} not found`);if(i||n?.[r.id]){const{x:s,y:a,z:o}=wOe(r,e,{...r.position,z:r[Cs]?.z??0},t);r.positionAbsolute={x:s,y:a},r[Cs].z=o,n?.[r.id]&&(r[Cs].isParent=!0)}})}function v6(e,t,n,r){const i=new Map,s={},a=r?1e3:0;return e.forEach(o=>{const l=(Eu(o.zIndex)?o.zIndex:0)+(o.selected?a:0),u=t.get(o.id),d={...o,positionAbsolute:{x:o.position.x,y:o.position.y}},f=o.parentNode||o.parentId;f&&(s[f]=!0);const h=u?.type&&u?.type!==o.type;Object.defineProperty(d,Cs,{enumerable:!1,value:{handleBounds:h?void 0:u?.[Cs]?.handleBounds,z:l}}),i.set(o.id,d)}),EOe(i,n,s),i}function COe(e,t={}){const{getNodes:n,width:r,height:i,minZoom:s,maxZoom:a,d3Zoom:o,d3Selection:l,fitViewOnInitDone:u,fitViewOnInit:d,nodeOrigin:f}=e(),h=t.initial&&!u&&d;if(o&&l&&(h||!t.initial)){const g=n().filter(v=>{const _=t.includeHiddenNodes?v.width&&v.height:!v.hidden;return t.nodes?.length?_&&t.nodes.some(S=>S.id===v.id):_}),y=g.every(v=>v.width&&v.height);if(g.length>0&&y){const v=E5(g,f),{x:_,y:S,zoom:E}=uOe(v,r,i,t.minZoom??s,t.maxZoom??a,t.padding??.1),T=Mh.translate(_,S).scale(E);return typeof t.duration=="number"&&t.duration>0?o.transform(ib(l,t.duration),T):o.transform(l,T),!0}}return!1}function YCt(e,t){return e.forEach(n=>{const r=t.get(n.id);r&&t.set(r.id,{...r,[Cs]:r[Cs],selected:n.selected})}),new Map(t)}function XCt(e,t){return t.map(n=>{const r=e.find(i=>i.id===n.id);return r&&(n.selected=r.selected),n})}function rN({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:i,edges:s,onNodesChange:a,onEdgesChange:o,hasDefaultNodes:l,hasDefaultEdges:u}=n();e?.length&&(l&&r({nodeInternals:YCt(e,i)}),a?.(e)),t?.length&&(u&&r({edges:XCt(t,s)}),o?.(t))}const Zv=()=>{},QCt={zoomIn:Zv,zoomOut:Zv,zoomTo:Zv,getZoom:()=>1,setViewport:Zv,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Zv,fitBounds:Zv,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},ZCt=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),JCt=()=>{const e=Ca(),{d3Zoom:t,d3Selection:n}=Li(ZCt,Ka);return x.useMemo(()=>n&&t?{zoomIn:i=>t.scaleBy(ib(n,i?.duration),1.2),zoomOut:i=>t.scaleBy(ib(n,i?.duration),1/1.2),zoomTo:(i,s)=>t.scaleTo(ib(n,s?.duration),i),getZoom:()=>e.getState().transform[2],setViewport:(i,s)=>{const[a,o,l]=e.getState().transform,u=Mh.translate(i.x??a,i.y??o).scale(i.zoom??l);t.transform(ib(n,s?.duration),u)},getViewport:()=>{const[i,s,a]=e.getState().transform;return{x:i,y:s,zoom:a}},fitView:i=>COe(e.getState,i),setCenter:(i,s,a)=>{const{width:o,height:l,maxZoom:u}=e.getState(),d=typeof a?.zoom<"u"?a.zoom:u,f=o/2-i*d,h=l/2-s*d,m=Mh.translate(f,h).scale(d);t.transform(ib(n,a?.duration),m)},fitBounds:(i,s)=>{const{width:a,height:o,minZoom:l,maxZoom:u}=e.getState(),{x:d,y:f,zoom:h}=uOe(i,a,o,l,u,s?.padding??.1),m=Mh.translate(d,f).scale(h);t.transform(ib(n,s?.duration),m)},project:i=>{const{transform:s,snapToGrid:a,snapGrid:o}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),lU(i,s,a,o)},screenToFlowPosition:i=>{const{transform:s,snapToGrid:a,snapGrid:o,domNode:l}=e.getState();if(!l)return i;const{x:u,y:d}=l.getBoundingClientRect(),f={x:i.x-u,y:i.y-d};return lU(f,s,a,o)},flowToScreenPosition:i=>{const{transform:s,domNode:a}=e.getState();if(!a)return i;const{x:o,y:l}=a.getBoundingClientRect(),u=oOe(i,s);return{x:u.x+o,y:u.y+l}},viewportInitialized:!0}:QCt,[t,n])};function dZ(){const e=JCt(),t=Ca(),n=x.useCallback(()=>t.getState().getNodes().map(y=>({...y})),[]),r=x.useCallback(y=>t.getState().nodeInternals.get(y),[]),i=x.useCallback(()=>{const{edges:y=[]}=t.getState();return y.map(v=>({...v}))},[]),s=x.useCallback(y=>{const{edges:v=[]}=t.getState();return v.find(_=>_.id===y)},[]),a=x.useCallback(y=>{const{getNodes:v,setNodes:_,hasDefaultNodes:S,onNodesChange:E}=t.getState(),T=v(),k=typeof y=="function"?y(T):y;if(S)_(k);else if(E){const w=k.length===0?T.map(A=>({type:"remove",id:A.id})):k.map(A=>({item:A,type:"reset"}));E(w)}},[]),o=x.useCallback(y=>{const{edges:v=[],setEdges:_,hasDefaultEdges:S,onEdgesChange:E}=t.getState(),T=typeof y=="function"?y(v):y;if(S)_(T);else if(E){const k=T.length===0?v.map(w=>({type:"remove",id:w.id})):T.map(w=>({item:w,type:"reset"}));E(k)}},[]),l=x.useCallback(y=>{const v=Array.isArray(y)?y:[y],{getNodes:_,setNodes:S,hasDefaultNodes:E,onNodesChange:T}=t.getState();if(E){const w=[..._(),...v];S(w)}else if(T){const k=v.map(w=>({item:w,type:"add"}));T(k)}},[]),u=x.useCallback(y=>{const v=Array.isArray(y)?y:[y],{edges:_=[],setEdges:S,hasDefaultEdges:E,onEdgesChange:T}=t.getState();if(E)S([..._,...v]);else if(T){const k=v.map(w=>({item:w,type:"add"}));T(k)}},[]),d=x.useCallback(()=>{const{getNodes:y,edges:v=[],transform:_}=t.getState(),[S,E,T]=_;return{nodes:y().map(k=>({...k})),edges:v.map(k=>({...k})),viewport:{x:S,y:E,zoom:T}}},[]),f=x.useCallback(({nodes:y,edges:v})=>{const{nodeInternals:_,getNodes:S,edges:E,hasDefaultNodes:T,hasDefaultEdges:k,onNodesDelete:w,onEdgesDelete:A,onNodesChange:R,onEdgesChange:I}=t.getState(),D=(y||[]).map(L=>L.id),j=(v||[]).map(L=>L.id),F=S().reduce((L,M)=>{const $=M.parentNode||M.parentId,W=!D.includes(M.id)&&$&&L.find(q=>q.id===$);return(typeof M.deletable!="boolean"||M.deletable)&&(D.includes(M.id)||W)&&L.push(M),L},[]),z=E.filter(L=>typeof L.deletable=="boolean"?L.deletable:!0),P=z.filter(L=>j.includes(L.id));if(F||P){const L=cOe(F,z),M=[...P,...L],$=M.reduce((W,Y)=>(W.includes(Y.id)||W.push(Y.id),W),[]);if((k||T)&&(k&&t.setState({edges:E.filter(W=>!$.includes(W.id))}),T&&(F.forEach(W=>{_.delete(W.id)}),t.setState({nodeInternals:new Map(_)}))),$.length>0&&(A?.(M),I&&I($.map(W=>({id:W,type:"remove"})))),F.length>0&&(w?.(F),R)){const W=F.map(Y=>({id:Y.id,type:"remove"}));R(W)}}},[]),h=x.useCallback(y=>{const v=vCt(y),_=v?null:t.getState().nodeInternals.get(y.id);return!v&&!_?[null,null,v]:[v?y:aue(_),_,v]},[]),m=x.useCallback((y,v=!0,_)=>{const[S,E,T]=h(y);return S?(_||t.getState().getNodes()).filter(k=>{if(!T&&(k.id===E.id||!k.positionAbsolute))return!1;const w=aue(k),A=iU(w,S);return v&&A>0||A>=S.width*S.height}):[]},[]),g=x.useCallback((y,v,_=!0)=>{const[S]=h(y);if(!S)return!1;const E=iU(S,v);return _&&E>0||E>=S.width*S.height},[]);return x.useMemo(()=>({...e,getNodes:n,getNode:r,getEdges:i,getEdge:s,setNodes:a,setEdges:o,addNodes:l,addEdges:u,toObject:d,deleteElements:f,getIntersectingNodes:m,isNodeIntersecting:g}),[e,n,r,i,s,a,o,l,u,d,f,m,g])}const ekt={actInsideInputWithModifier:!1};var tkt=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=Ca(),{deleteElements:r}=dZ(),i=u2(e,ekt),s=u2(t);x.useEffect(()=>{if(i){const{edges:a,getNodes:o}=n.getState(),l=o().filter(d=>d.selected),u=a.filter(d=>d.selected);r({nodes:l,edges:u}),n.setState({nodesSelectionActive:!1})}},[i]),x.useEffect(()=>{n.setState({multiSelectionActive:s})},[s])};function nkt(e){const t=Ca();x.useEffect(()=>{let n;const r=()=>{if(!e.current)return;const i=rZ(e.current);(i.height===0||i.width===0)&&t.getState().onError?.("004",Jh.error004()),t.setState({width:i.width||500,height:i.height||500})};return r(),window.addEventListener("resize",r),e.current&&(n=new ResizeObserver(()=>r()),n.observe(e.current)),()=>{window.removeEventListener("resize",r),n&&e.current&&n.unobserve(e.current)}},[])}const fZ={position:"absolute",width:"100%",height:"100%",top:0,left:0},rkt=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,iN=e=>({x:e.x,y:e.y,zoom:e.k}),Jv=(e,t)=>e.target.closest(`.${t}`),gue=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),bue=e=>{const t=e.ctrlKey&&LR()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},ikt=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),skt=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:i=!0,zoomOnPinch:s=!0,panOnScroll:a=!1,panOnScrollSpeed:o=.5,panOnScrollMode:l=kb.Free,zoomOnDoubleClick:u=!0,elementsSelectable:d,panOnDrag:f=!0,defaultViewport:h,translateExtent:m,minZoom:g,maxZoom:y,zoomActivationKeyCode:v,preventScrolling:_=!0,children:S,noWheelClassName:E,noPanClassName:T})=>{const k=x.useRef(),w=Ca(),A=x.useRef(!1),R=x.useRef(!1),I=x.useRef(null),D=x.useRef({x:0,y:0,zoom:0}),{d3Zoom:j,d3Selection:F,d3ZoomHandler:z,userSelectionActive:P}=Li(ikt,Ka),L=u2(v),M=x.useRef(0),$=x.useRef(!1),W=x.useRef();return nkt(I),x.useEffect(()=>{if(I.current){const Y=I.current.getBoundingClientRect(),q=YNe().scaleExtent([g,y]).translateExtent(m),K=yu(I.current).call(q),X=Mh.translate(h.x,h.y).scale(Ox(h.zoom,g,y)),U=[[0,0],[Y.width,Y.height]],J=q.constrain()(X,U,m);q.transform(K,J),q.wheelDelta(bue),w.setState({d3Zoom:q,d3Selection:K,d3ZoomHandler:K.on("wheel.zoom"),transform:[J.x,J.y,J.k],domNode:I.current.closest(".react-flow")})}},[]),x.useEffect(()=>{F&&j&&(a&&!L&&!P?F.on("wheel.zoom",Y=>{if(Jv(Y,E))return!1;Y.preventDefault(),Y.stopImmediatePropagation();const q=F.property("__zoom").k||1;if(Y.ctrlKey&&s){const ae=ed(Y),se=bue(Y),ue=q*Math.pow(2,se);j.scaleTo(F,ue,ae,Y);return}const K=Y.deltaMode===1?20:1;let X=l===kb.Vertical?0:Y.deltaX*K,U=l===kb.Horizontal?0:Y.deltaY*K;!LR()&&Y.shiftKey&&l!==kb.Vertical&&(X=Y.deltaY*K,U=0),j.translateBy(F,-(X/q)*o,-(U/q)*o,{internal:!0});const J=iN(F.property("__zoom")),{onViewportChangeStart:te,onViewportChange:ee,onViewportChangeEnd:oe}=w.getState();clearTimeout(W.current),$.current||($.current=!0,t?.(Y,J),te?.(J)),$.current&&(e?.(Y,J),ee?.(J),W.current=setTimeout(()=>{n?.(Y,J),oe?.(J),$.current=!1},150))},{passive:!1}):typeof z<"u"&&F.on("wheel.zoom",function(Y,q){if(!_&&Y.type==="wheel"&&!Y.ctrlKey||Jv(Y,E))return null;Y.preventDefault(),z.call(this,Y,q)},{passive:!1}))},[P,a,l,F,j,z,L,s,_,E,t,e,n]),x.useEffect(()=>{j&&j.on("start",Y=>{if(!Y.sourceEvent||Y.sourceEvent.internal)return null;M.current=Y.sourceEvent?.button;const{onViewportChangeStart:q}=w.getState(),K=iN(Y.transform);A.current=!0,D.current=K,Y.sourceEvent?.type==="mousedown"&&w.setState({paneDragging:!0}),q?.(K),t?.(Y.sourceEvent,K)})},[j,t]),x.useEffect(()=>{j&&(P&&!A.current?j.on("zoom",null):P||j.on("zoom",Y=>{const{onViewportChange:q}=w.getState();if(w.setState({transform:[Y.transform.x,Y.transform.y,Y.transform.k]}),R.current=!!(r&&gue(f,M.current??0)),(e||q)&&!Y.sourceEvent?.internal){const K=iN(Y.transform);q?.(K),e?.(Y.sourceEvent,K)}}))},[P,j,e,f,r]),x.useEffect(()=>{j&&j.on("end",Y=>{if(!Y.sourceEvent||Y.sourceEvent.internal)return null;const{onViewportChangeEnd:q}=w.getState();if(A.current=!1,w.setState({paneDragging:!1}),r&&gue(f,M.current??0)&&!R.current&&r(Y.sourceEvent),R.current=!1,(n||q)&&rkt(D.current,Y.transform)){const K=iN(Y.transform);D.current=K,clearTimeout(k.current),k.current=setTimeout(()=>{q?.(K),n?.(Y.sourceEvent,K)},a?150:0)}})},[j,a,f,n,r]),x.useEffect(()=>{j&&j.filter(Y=>{const q=L||i,K=s&&Y.ctrlKey;if((f===!0||Array.isArray(f)&&f.includes(1))&&Y.button===1&&Y.type==="mousedown"&&(Jv(Y,"react-flow__node")||Jv(Y,"react-flow__edge")))return!0;if(!f&&!q&&!a&&!u&&!s||P||!u&&Y.type==="dblclick"||Jv(Y,E)&&Y.type==="wheel"||Jv(Y,T)&&(Y.type!=="wheel"||a&&Y.type==="wheel"&&!L)||!s&&Y.ctrlKey&&Y.type==="wheel"||!q&&!a&&!K&&Y.type==="wheel"||!f&&(Y.type==="mousedown"||Y.type==="touchstart")||Array.isArray(f)&&!f.includes(Y.button)&&Y.type==="mousedown")return!1;const X=Array.isArray(f)&&f.includes(Y.button)||!Y.button||Y.button<=1;return(!Y.ctrlKey||Y.type==="wheel")&&X})},[P,j,i,s,a,u,f,d,L]),Q.createElement("div",{className:"react-flow__renderer",ref:I,style:fZ},S)},akt=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function okt(){const{userSelectionActive:e,userSelectionRect:t}=Li(akt,Ka);return e&&t?Q.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function yue(e,t){const n=t.parentNode||t.parentId,r=e.find(i=>i.id===n);if(r){const i=t.position.x+t.width-r.width,s=t.position.y+t.height-r.height;if(i>0||s>0||t.position.x<0||t.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,i>0&&(r.style.width+=i),s>0&&(r.style.height+=s),t.position.x<0){const a=Math.abs(t.position.x);r.position.x=r.position.x-a,r.style.width+=a,t.position.x=0}if(t.position.y<0){const a=Math.abs(t.position.y);r.position.y=r.position.y-a,r.style.height+=a,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function kOe(e,t){if(e.some(r=>r.type==="reset"))return e.filter(r=>r.type==="reset").map(r=>r.item);const n=e.filter(r=>r.type==="add").map(r=>r.item);return t.reduce((r,i)=>{const s=e.filter(o=>o.id===i.id);if(s.length===0)return r.push(i),r;const a={...i};for(const o of s)if(o)switch(o.type){case"select":{a.selected=o.selected;break}case"position":{typeof o.position<"u"&&(a.position=o.position),typeof o.positionAbsolute<"u"&&(a.positionAbsolute=o.positionAbsolute),typeof o.dragging<"u"&&(a.dragging=o.dragging),a.expandParent&&yue(r,a);break}case"dimensions":{typeof o.dimensions<"u"&&(a.width=o.dimensions.width,a.height=o.dimensions.height),typeof o.updateStyle<"u"&&(a.style={...a.style||{},...o.dimensions}),typeof o.resizing=="boolean"&&(a.resizing=o.resizing),a.expandParent&&yue(r,a);break}case"remove":return r}return r.push(a),r},n)}function TOe(e,t){return kOe(e,t)}function lkt(e,t){return kOe(e,t)}const cm=(e,t)=>({id:e,type:"select",selected:t});function E0(e,t){return e.reduce((n,r)=>{const i=t.includes(r.id);return!r.selected&&i?(r.selected=!0,n.push(cm(r.id,!0))):r.selected&&!i&&(r.selected=!1,n.push(cm(r.id,!1))),n},[])}const x6=(e,t)=>n=>{n.target===t.current&&e?.(n)},ckt=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),AOe=x.memo(({isSelecting:e,selectionMode:t=l2.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:i,onPaneClick:s,onPaneContextMenu:a,onPaneScroll:o,onPaneMouseEnter:l,onPaneMouseMove:u,onPaneMouseLeave:d,children:f})=>{const h=x.useRef(null),m=Ca(),g=x.useRef(0),y=x.useRef(0),v=x.useRef(),{userSelectionActive:_,elementsSelectable:S,dragging:E}=Li(ckt,Ka),T=()=>{m.setState({userSelectionActive:!1,userSelectionRect:null}),g.current=0,y.current=0},k=z=>{s?.(z),m.getState().resetSelectedElements(),m.setState({nodesSelectionActive:!1})},w=z=>{if(Array.isArray(n)&&n?.includes(2)){z.preventDefault();return}a?.(z)},A=o?z=>o(z):void 0,R=z=>{const{resetSelectedElements:P,domNode:L}=m.getState();if(v.current=L?.getBoundingClientRect(),!S||!e||z.button!==0||z.target!==h.current||!v.current)return;const{x:M,y:$}=Mm(z,v.current);P(),m.setState({userSelectionRect:{width:0,height:0,startX:M,startY:$,x:M,y:$}}),r?.(z)},I=z=>{const{userSelectionRect:P,nodeInternals:L,edges:M,transform:$,onNodesChange:W,onEdgesChange:Y,nodeOrigin:q,getNodes:K}=m.getState();if(!e||!v.current||!P)return;m.setState({userSelectionActive:!0,nodesSelectionActive:!1});const X=Mm(z,v.current),U=P.startX??0,J=P.startY??0,te={...P,x:X.x<U?X.x:U,y:X.y<J?X.y:J,width:Math.abs(X.x-U),height:Math.abs(X.y-J)},ee=K(),oe=lOe(L,te,$,t===l2.Partial,!0,q),ae=cOe(oe,M).map(ue=>ue.id),se=oe.map(ue=>ue.id);if(g.current!==se.length){g.current=se.length;const ue=E0(ee,se);ue.length&&W?.(ue)}if(y.current!==ae.length){y.current=ae.length;const ue=E0(M,ae);ue.length&&Y?.(ue)}m.setState({userSelectionRect:te})},D=z=>{if(z.button!==0)return;const{userSelectionRect:P}=m.getState();!_&&P&&z.target===h.current&&k?.(z),m.setState({nodesSelectionActive:g.current>0}),T(),i?.(z)},j=z=>{_&&(m.setState({nodesSelectionActive:g.current>0}),i?.(z)),T()},F=S&&(e||_);return Q.createElement("div",{className:vo(["react-flow__pane",{dragging:E,selection:e}]),onClick:F?void 0:x6(k,h),onContextMenu:x6(w,h),onWheel:x6(A,h),onMouseEnter:F?void 0:l,onMouseDown:F?R:void 0,onMouseMove:F?I:u,onMouseUp:F?D:void 0,onMouseLeave:F?j:d,ref:h,style:fZ},f,Q.createElement(okt,null))});AOe.displayName="Pane";function NOe(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return r?r.selected?!0:NOe(r,t):!1}function vue(e,t,n){let r=e;do{if(r?.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function ukt(e,t,n,r){return Array.from(e.values()).filter(i=>(i.selected||i.id===r)&&(!i.parentNode||i.parentId||!NOe(i,e))&&(i.draggable||t&&typeof i.draggable>"u")).map(i=>({id:i.id,position:i.position||{x:0,y:0},positionAbsolute:i.positionAbsolute||{x:0,y:0},distance:{x:n.x-(i.positionAbsolute?.x??0),y:n.y-(i.positionAbsolute?.y??0)},delta:{x:0,y:0},extent:i.extent,parentNode:i.parentNode||i.parentId,parentId:i.parentNode||i.parentId,width:i.width,height:i.height,expandParent:i.expandParent}))}function dkt(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function OOe(e,t,n,r,i=[0,0],s){const a=dkt(e,e.extent||r);let o=a;const l=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(l&&e.width&&e.height){const f=n.get(l),{x:h,y:m}=Kb(f,i).positionAbsolute;o=f&&Eu(h)&&Eu(m)&&Eu(f.width)&&Eu(f.height)?[[h+e.width*i[0],m+e.height*i[1]],[h+f.width-e.width+e.width*i[0],m+f.height-e.height+e.height*i[1]]]:o}else s?.("005",Jh.error005()),o=a;else if(e.extent&&l&&e.extent!=="parent"){const f=n.get(l),{x:h,y:m}=Kb(f,i).positionAbsolute;o=[[e.extent[0][0]+h,e.extent[0][1]+m],[e.extent[1][0]+h,e.extent[1][1]+m]]}let u={x:0,y:0};if(l){const f=n.get(l);u=Kb(f,i).positionAbsolute}const d=o&&o!=="parent"?iZ(t,o):t;return{position:{x:d.x-u.x,y:d.y-u.y},positionAbsolute:d}}function _6({nodeId:e,dragItems:t,nodeInternals:n}){const r=t.map(i=>({...n.get(i.id),position:i.position,positionAbsolute:i.positionAbsolute}));return[e?r.find(i=>i.id===e):r[0],r]}const xue=(e,t,n,r)=>{const i=t.querySelectorAll(e);if(!i||!i.length)return null;const s=Array.from(i),a=t.getBoundingClientRect(),o={x:a.width*r[0],y:a.height*r[1]};return s.map(l=>{const u=l.getBoundingClientRect();return{id:l.getAttribute("data-handleid"),position:l.getAttribute("data-handlepos"),x:(u.left-a.left-o.x)/n,y:(u.top-a.top-o.y)/n,...rZ(l)}})};function qS(e,t,n){return n===void 0?n:r=>{const i=t().nodeInternals.get(e);i&&n(r,{...i})}}function uU({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:i,unselectNodesAndEdges:s,multiSelectionActive:a,nodeInternals:o,onError:l}=t.getState(),u=o.get(e);if(!u){l?.("012",Jh.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&a)&&(s({nodes:[u],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function fkt(){const e=Ca();return x.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:i,snapToGrid:s}=e.getState(),a=n.touches?n.touches[0].clientX:n.clientX,o=n.touches?n.touches[0].clientY:n.clientY,l={x:(a-r[0])/r[2],y:(o-r[1])/r[2]};return{xSnapped:s?i[0]*Math.round(l.x/i[0]):l.x,ySnapped:s?i[1]*Math.round(l.y/i[1]):l.y,...l}},[])}function S6(e){return(t,n,r)=>e?.(t,r)}function ROe({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:s,selectNodesOnDrag:a}){const o=Ca(),[l,u]=x.useState(!1),d=x.useRef([]),f=x.useRef({x:null,y:null}),h=x.useRef(0),m=x.useRef(null),g=x.useRef({x:0,y:0}),y=x.useRef(null),v=x.useRef(!1),_=x.useRef(!1),S=x.useRef(!1),E=fkt();return x.useEffect(()=>{if(e?.current){const T=yu(e.current),k=({x:R,y:I})=>{const{nodeInternals:D,onNodeDrag:j,onSelectionDrag:F,updateNodePositions:z,nodeExtent:P,snapGrid:L,snapToGrid:M,nodeOrigin:$,onError:W}=o.getState();f.current={x:R,y:I};let Y=!1,q={x:0,y:0,x2:0,y2:0};if(d.current.length>1&&P){const X=E5(d.current,$);q=o2(X)}if(d.current=d.current.map(X=>{const U={x:R-X.distance.x,y:I-X.distance.y};M&&(U.x=L[0]*Math.round(U.x/L[0]),U.y=L[1]*Math.round(U.y/L[1]));const J=[[P[0][0],P[0][1]],[P[1][0],P[1][1]]];d.current.length>1&&P&&!X.extent&&(J[0][0]=X.positionAbsolute.x-q.x+P[0][0],J[1][0]=X.positionAbsolute.x+(X.width??0)-q.x2+P[1][0],J[0][1]=X.positionAbsolute.y-q.y+P[0][1],J[1][1]=X.positionAbsolute.y+(X.height??0)-q.y2+P[1][1]);const te=OOe(X,U,D,J,$,W);return Y=Y||X.position.x!==te.position.x||X.position.y!==te.position.y,X.position=te.position,X.positionAbsolute=te.positionAbsolute,X}),!Y)return;z(d.current,!0,!0),u(!0);const K=i?j:S6(F);if(K&&y.current){const[X,U]=_6({nodeId:i,dragItems:d.current,nodeInternals:D});K(y.current,X,U)}},w=()=>{if(!m.current)return;const[R,I]=QNe(g.current,m.current);if(R!==0||I!==0){const{transform:D,panBy:j}=o.getState();f.current.x=(f.current.x??0)-R/D[2],f.current.y=(f.current.y??0)-I/D[2],j({x:R,y:I})&&k(f.current)}h.current=requestAnimationFrame(w)},A=R=>{const{nodeInternals:I,multiSelectionActive:D,nodesDraggable:j,unselectNodesAndEdges:F,onNodeDragStart:z,onSelectionDragStart:P}=o.getState();_.current=!0;const L=i?z:S6(P);(!a||!s)&&!D&&i&&(I.get(i)?.selected||F()),i&&s&&a&&uU({id:i,store:o,nodeRef:e});const M=E(R);if(f.current=M,d.current=ukt(I,j,M,i),L&&d.current){const[$,W]=_6({nodeId:i,dragItems:d.current,nodeInternals:I});L(R.sourceEvent,$,W)}};if(t)T.on(".drag",null);else{const R=yEt().on("start",I=>{const{domNode:D,nodeDragThreshold:j}=o.getState();j===0&&A(I),S.current=!1;const F=E(I);f.current=F,m.current=D?.getBoundingClientRect()||null,g.current=Mm(I.sourceEvent,m.current)}).on("drag",I=>{const D=E(I),{autoPanOnNodeDrag:j,nodeDragThreshold:F}=o.getState();if(I.sourceEvent.type==="touchmove"&&I.sourceEvent.touches.length>1&&(S.current=!0),!S.current){if(!v.current&&_.current&&j&&(v.current=!0,w()),!_.current){const z=D.xSnapped-(f?.current?.x??0),P=D.ySnapped-(f?.current?.y??0);Math.sqrt(z*z+P*P)>F&&A(I)}(f.current.x!==D.xSnapped||f.current.y!==D.ySnapped)&&d.current&&_.current&&(y.current=I.sourceEvent,g.current=Mm(I.sourceEvent,m.current),k(D))}}).on("end",I=>{if(!(!_.current||S.current)&&(u(!1),v.current=!1,_.current=!1,cancelAnimationFrame(h.current),d.current)){const{updateNodePositions:D,nodeInternals:j,onNodeDragStop:F,onSelectionDragStop:z}=o.getState(),P=i?F:S6(z);if(D(d.current,!1,!1),P){const[L,M]=_6({nodeId:i,dragItems:d.current,nodeInternals:j});P(I.sourceEvent,L,M)}}}).filter(I=>{const D=I.target;return!I.button&&(!n||!vue(D,`.${n}`,e))&&(!r||vue(D,r,e))});return T.call(R),()=>{T.on(".drag",null)}}}},[e,t,n,r,s,o,i,a,E]),l}function IOe(){const e=Ca();return x.useCallback(n=>{const{nodeInternals:r,nodeExtent:i,updateNodePositions:s,getNodes:a,snapToGrid:o,snapGrid:l,onError:u,nodesDraggable:d}=e.getState(),f=a().filter(S=>S.selected&&(S.draggable||d&&typeof S.draggable>"u")),h=o?l[0]:5,m=o?l[1]:5,g=n.isShiftPressed?4:1,y=n.x*h*g,v=n.y*m*g,_=f.map(S=>{if(S.positionAbsolute){const E={x:S.positionAbsolute.x+y,y:S.positionAbsolute.y+v};o&&(E.x=l[0]*Math.round(E.x/l[0]),E.y=l[1]*Math.round(E.y/l[1]));const{positionAbsolute:T,position:k}=OOe(S,E,r,i,void 0,u);S.position=k,S.positionAbsolute=T}return S});s(_,!0,!1)},[])}const V0={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var GS=e=>{const t=({id:n,type:r,data:i,xPos:s,yPos:a,xPosOrigin:o,yPosOrigin:l,selected:u,onClick:d,onMouseEnter:f,onMouseMove:h,onMouseLeave:m,onContextMenu:g,onDoubleClick:y,style:v,className:_,isDraggable:S,isSelectable:E,isConnectable:T,isFocusable:k,selectNodesOnDrag:w,sourcePosition:A,targetPosition:R,hidden:I,resizeObserver:D,dragHandle:j,zIndex:F,isParent:z,noDragClassName:P,noPanClassName:L,initialized:M,disableKeyboardA11y:$,ariaLabel:W,rfId:Y,hasHandleBounds:q})=>{const K=Ca(),X=x.useRef(null),U=x.useRef(null),J=x.useRef(A),te=x.useRef(R),ee=x.useRef(r),oe=E||S||d||f||h||m,ae=IOe(),se=qS(n,K.getState,f),ue=qS(n,K.getState,h),de=qS(n,K.getState,m),ce=qS(n,K.getState,g),Ee=qS(n,K.getState,y),Ie=ge=>{const{nodeDragThreshold:Ce}=K.getState();if(E&&(!w||!S||Ce>0)&&uU({id:n,store:K,nodeRef:X}),d){const Re=K.getState().nodeInternals.get(n);Re&&d(ge,{...Re})}},fe=ge=>{if(!sU(ge)&&!$)if(tOe.includes(ge.key)&&E){const Ce=ge.key==="Escape";uU({id:n,store:K,unselect:Ce,nodeRef:X})}else S&&u&&Object.prototype.hasOwnProperty.call(V0,ge.key)&&(K.setState({ariaLiveMessage:`Moved selected node ${ge.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~s}, y: ${~~a}`}),ae({x:V0[ge.key].x,y:V0[ge.key].y,isShiftPressed:ge.shiftKey}))};x.useEffect(()=>()=>{U.current&&(D?.unobserve(U.current),U.current=null)},[]),x.useEffect(()=>{if(X.current&&!I){const ge=X.current;(!M||!q||U.current!==ge)&&(U.current&&D?.unobserve(U.current),D?.observe(ge),U.current=ge)}},[I,M,q]),x.useEffect(()=>{const ge=ee.current!==r,Ce=J.current!==A,Re=te.current!==R;X.current&&(ge||Ce||Re)&&(ge&&(ee.current=r),Ce&&(J.current=A),Re&&(te.current=R),K.getState().updateNodeDimensions([{id:n,nodeElement:X.current,forceUpdate:!0}]))},[n,r,A,R]);const be=ROe({nodeRef:X,disabled:I||!S,noDragClassName:P,handleSelector:j,nodeId:n,isSelectable:E,selectNodesOnDrag:w});return I?null:Q.createElement("div",{className:vo(["react-flow__node",`react-flow__node-${r}`,{[L]:S},_,{selected:u,selectable:E,parent:z,dragging:be}]),ref:X,style:{zIndex:F,transform:`translate(${o}px,${l}px)`,pointerEvents:oe?"all":"none",visibility:M?"visible":"hidden",...v},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:se,onMouseMove:ue,onMouseLeave:de,onContextMenu:ce,onClick:Ie,onDoubleClick:Ee,onKeyDown:k?fe:void 0,tabIndex:k?0:void 0,role:k?"button":void 0,"aria-describedby":$?void 0:`${_Oe}-${Y}`,"aria-label":W},Q.createElement(kCt,{value:n},Q.createElement(e,{id:n,data:i,type:r,xPos:s,yPos:a,selected:u,isConnectable:T,sourcePosition:A,targetPosition:R,dragging:be,dragHandle:j,zIndex:F})))};return t.displayName="NodeWrapper",x.memo(t)};const hkt=e=>{const t=e.getNodes().filter(n=>n.selected);return{...E5(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function pkt({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Ca(),{width:i,height:s,x:a,y:o,transformString:l,userSelectionActive:u}=Li(hkt,Ka),d=IOe(),f=x.useRef(null);if(x.useEffect(()=>{n||f.current?.focus({preventScroll:!0})},[n]),ROe({nodeRef:f}),u||!i||!s)return null;const h=e?g=>{const y=r.getState().getNodes().filter(v=>v.selected);e(g,y)}:void 0,m=g=>{Object.prototype.hasOwnProperty.call(V0,g.key)&&d({x:V0[g.key].x,y:V0[g.key].y,isShiftPressed:g.shiftKey})};return Q.createElement("div",{className:vo(["react-flow__nodesselection","react-flow__container",t]),style:{transform:l}},Q.createElement("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:h,tabIndex:n?void 0:-1,onKeyDown:n?void 0:m,style:{width:i,height:s,top:o,left:a}}))}var mkt=x.memo(pkt);const gkt=e=>e.nodesSelectionActive,DOe=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:s,onPaneScroll:a,deleteKeyCode:o,onMove:l,onMoveStart:u,onMoveEnd:d,selectionKeyCode:f,selectionOnDrag:h,selectionMode:m,onSelectionStart:g,onSelectionEnd:y,multiSelectionKeyCode:v,panActivationKeyCode:_,zoomActivationKeyCode:S,elementsSelectable:E,zoomOnScroll:T,zoomOnPinch:k,panOnScroll:w,panOnScrollSpeed:A,panOnScrollMode:R,zoomOnDoubleClick:I,panOnDrag:D,defaultViewport:j,translateExtent:F,minZoom:z,maxZoom:P,preventScrolling:L,onSelectionContextMenu:M,noWheelClassName:$,noPanClassName:W,disableKeyboardA11y:Y})=>{const q=Li(gkt),K=u2(f),X=u2(_),U=X||D,J=X||w,te=K||h&&U!==!0;return tkt({deleteKeyCode:o,multiSelectionKeyCode:v}),Q.createElement(skt,{onMove:l,onMoveStart:u,onMoveEnd:d,onPaneContextMenu:s,elementsSelectable:E,zoomOnScroll:T,zoomOnPinch:k,panOnScroll:J,panOnScrollSpeed:A,panOnScrollMode:R,zoomOnDoubleClick:I,panOnDrag:!K&&U,defaultViewport:j,translateExtent:F,minZoom:z,maxZoom:P,zoomActivationKeyCode:S,preventScrolling:L,noWheelClassName:$,noPanClassName:W},Q.createElement(AOe,{onSelectionStart:g,onSelectionEnd:y,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:s,onPaneScroll:a,panOnDrag:U,isSelecting:!!te,selectionMode:m},e,q&&Q.createElement(mkt,{onSelectionContextMenu:M,noPanClassName:W,disableKeyboardA11y:Y})))};DOe.displayName="FlowRenderer";var bkt=x.memo(DOe);function ykt(e){return Li(x.useCallback(n=>e?lOe(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function vkt(e){const t={input:GS(e.input||bOe),default:GS(e.default||cU),output:GS(e.output||vOe),group:GS(e.group||uZ)},n={},r=Object.keys(e).filter(i=>!["input","default","output","group"].includes(i)).reduce((i,s)=>(i[s]=GS(e[s]||cU),i),n);return{...t,...r}}const xkt=({x:e,y:t,width:n,height:r,origin:i})=>!n||!r?{x:e,y:t}:i[0]<0||i[1]<0||i[0]>1||i[1]>1?{x:e,y:t}:{x:e-n*i[0],y:t-r*i[1]},_kt=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),jOe=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,updateNodeDimensions:s,onError:a}=Li(_kt,Ka),o=ykt(e.onlyRenderVisibleElements),l=x.useRef(),u=x.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const d=new ResizeObserver(f=>{const h=f.map(m=>({id:m.target.getAttribute("data-id"),nodeElement:m.target,forceUpdate:!0}));s(h)});return l.current=d,d},[]);return x.useEffect(()=>()=>{l?.current?.disconnect()},[]),Q.createElement("div",{className:"react-flow__nodes",style:fZ},o.map(d=>{let f=d.type||"default";e.nodeTypes[f]||(a?.("003",Jh.error003(f)),f="default");const h=e.nodeTypes[f]||e.nodeTypes.default,m=!!(d.draggable||t&&typeof d.draggable>"u"),g=!!(d.selectable||i&&typeof d.selectable>"u"),y=!!(d.connectable||n&&typeof d.connectable>"u"),v=!!(d.focusable||r&&typeof d.focusable>"u"),_=e.nodeExtent?iZ(d.positionAbsolute,e.nodeExtent):d.positionAbsolute,S=_?.x??0,E=_?.y??0,T=xkt({x:S,y:E,width:d.width??0,height:d.height??0,origin:e.nodeOrigin});return Q.createElement(h,{key:d.id,id:d.id,className:d.className,style:d.style,type:f,data:d.data,sourcePosition:d.sourcePosition||kn.Bottom,targetPosition:d.targetPosition||kn.Top,hidden:d.hidden,xPos:S,yPos:E,xPosOrigin:T.x,yPosOrigin:T.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!d.selected,isDraggable:m,isSelectable:g,isConnectable:y,isFocusable:v,resizeObserver:u,dragHandle:d.dragHandle,zIndex:d[Cs]?.z??0,isParent:!!d[Cs]?.isParent,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!d.width&&!!d.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:d.ariaLabel,hasHandleBounds:!!d[Cs]?.handleBounds})}))};jOe.displayName="NodeRenderer";var Skt=x.memo(jOe);const wkt=(e,t,n)=>n===kn.Left?e-t:n===kn.Right?e+t:e,Ekt=(e,t,n)=>n===kn.Top?e-t:n===kn.Bottom?e+t:e,_ue="react-flow__edgeupdater",Sue=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:s,onMouseOut:a,type:o})=>Q.createElement("circle",{onMouseDown:i,onMouseEnter:s,onMouseOut:a,className:vo([_ue,`${_ue}-${o}`]),cx:wkt(t,r,e),cy:Ekt(n,r,e),r,stroke:"transparent",fill:"transparent"}),Ckt=()=>!0;var e0=e=>{const t=({id:n,className:r,type:i,data:s,onClick:a,onEdgeDoubleClick:o,selected:l,animated:u,label:d,labelStyle:f,labelShowBg:h,labelBgStyle:m,labelBgPadding:g,labelBgBorderRadius:y,style:v,source:_,target:S,sourceX:E,sourceY:T,targetX:k,targetY:w,sourcePosition:A,targetPosition:R,elementsSelectable:I,hidden:D,sourceHandleId:j,targetHandleId:F,onContextMenu:z,onMouseEnter:P,onMouseMove:L,onMouseLeave:M,reconnectRadius:$,onReconnect:W,onReconnectStart:Y,onReconnectEnd:q,markerEnd:K,markerStart:X,rfId:U,ariaLabel:J,isFocusable:te,isReconnectable:ee,pathOptions:oe,interactionWidth:ae,disableKeyboardA11y:se})=>{const ue=x.useRef(null),[de,ce]=x.useState(!1),[Ee,Ie]=x.useState(!1),fe=Ca(),be=x.useMemo(()=>`url('#${oU(X,U)}')`,[X,U]),ge=x.useMemo(()=>`url('#${oU(K,U)}')`,[K,U]);if(D)return null;const Ce=Rt=>{const{edges:Ye,addSelectedEdges:ct,unselectNodesAndEdges:Ve,multiSelectionActive:Et}=fe.getState(),$e=Ye.find(Qe=>Qe.id===n);$e&&(I&&(fe.setState({nodesSelectionActive:!1}),$e.selected&&Et?(Ve({nodes:[],edges:[$e]}),ue.current?.blur()):ct([n])),a&&a(Rt,$e))},Re=WS(n,fe.getState,o),xe=WS(n,fe.getState,z),ye=WS(n,fe.getState,P),De=WS(n,fe.getState,L),ve=WS(n,fe.getState,M),Oe=(Rt,Ye)=>{if(Rt.button!==0)return;const{edges:ct,isValidConnection:Ve}=fe.getState(),Et=Ye?S:_,$e=(Ye?F:j)||null,Qe=Ye?"target":"source",pt=Ve||Ckt,at=Ye,gt=ct.find(it=>it.id===n);Ie(!0),Y?.(Rt,gt,Qe);const We=it=>{Ie(!1),q?.(it,gt,Qe)};hOe({event:Rt,handleId:$e,nodeId:Et,onConnect:it=>W?.(gt,it),isTarget:at,getState:fe.getState,setState:fe.setState,isValidConnection:pt,edgeUpdaterType:Qe,onReconnectEnd:We})},Be=Rt=>Oe(Rt,!0),Te=Rt=>Oe(Rt,!1),je=()=>ce(!0),ie=()=>ce(!1),Ke=!I&&!a,lt=Rt=>{if(!se&&tOe.includes(Rt.key)&&I){const{unselectNodesAndEdges:Ye,addSelectedEdges:ct,edges:Ve}=fe.getState();Rt.key==="Escape"?(ue.current?.blur(),Ye({edges:[Ve.find($e=>$e.id===n)]})):ct([n])}};return Q.createElement("g",{className:vo(["react-flow__edge",`react-flow__edge-${i}`,r,{selected:l,animated:u,inactive:Ke,updating:de}]),onClick:Ce,onDoubleClick:Re,onContextMenu:xe,onMouseEnter:ye,onMouseMove:De,onMouseLeave:ve,onKeyDown:te?lt:void 0,tabIndex:te?0:void 0,role:te?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":J===null?void 0:J||`Edge from ${_} to ${S}`,"aria-describedby":te?`${SOe}-${U}`:void 0,ref:ue},!Ee&&Q.createElement(e,{id:n,source:_,target:S,selected:l,animated:u,label:d,labelStyle:f,labelShowBg:h,labelBgStyle:m,labelBgPadding:g,labelBgBorderRadius:y,data:s,style:v,sourceX:E,sourceY:T,targetX:k,targetY:w,sourcePosition:A,targetPosition:R,sourceHandleId:j,targetHandleId:F,markerStart:be,markerEnd:ge,pathOptions:oe,interactionWidth:ae}),ee&&Q.createElement(Q.Fragment,null,(ee==="source"||ee===!0)&&Q.createElement(Sue,{position:A,centerX:E,centerY:T,radius:$,onMouseDown:Be,onMouseEnter:je,onMouseOut:ie,type:"source"}),(ee==="target"||ee===!0)&&Q.createElement(Sue,{position:R,centerX:k,centerY:w,radius:$,onMouseDown:Te,onMouseEnter:je,onMouseOut:ie,type:"target"})))};return t.displayName="EdgeWrapper",x.memo(t)};function kkt(e){const t={default:e0(e.default||MR),straight:e0(e.bezier||oZ),step:e0(e.step||aZ),smoothstep:e0(e.step||w5),simplebezier:e0(e.simplebezier||sZ)},n={},r=Object.keys(e).filter(i=>!["default","bezier"].includes(i)).reduce((i,s)=>(i[s]=e0(e[s]||MR),i),n);return{...t,...r}}function wue(e,t,n=null){const r=(n?.x||0)+t.x,i=(n?.y||0)+t.y,s=n?.width||t.width,a=n?.height||t.height;switch(e){case kn.Top:return{x:r+s/2,y:i};case kn.Right:return{x:r+s,y:i+a/2};case kn.Bottom:return{x:r+s/2,y:i+a};case kn.Left:return{x:r,y:i+a/2}}}function Eue(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const Tkt=(e,t,n,r,i,s)=>{const a=wue(n,e,t),o=wue(s,r,i);return{sourceX:a.x,sourceY:a.y,targetX:o.x,targetY:o.y}};function Akt({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:i,targetHeight:s,width:a,height:o,transform:l}){const u={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+i),y2:Math.max(e.y+r,t.y+s)};u.x===u.x2&&(u.x2+=1),u.y===u.y2&&(u.y2+=1);const d=o2({x:(0-l[0])/l[2],y:(0-l[1])/l[2],width:a/l[2],height:o/l[2]}),f=Math.max(0,Math.min(d.x2,u.x2)-Math.max(d.x,u.x)),h=Math.max(0,Math.min(d.y2,u.y2)-Math.max(d.y,u.y));return Math.ceil(f*h)>0}function Cue(e){const t=e?.[Cs]?.handleBounds||null,n=t&&e?.width&&e?.height&&typeof e?.positionAbsolute?.x<"u"&&typeof e?.positionAbsolute?.y<"u";return[{x:e?.positionAbsolute?.x||0,y:e?.positionAbsolute?.y||0,width:e?.width||0,height:e?.height||0},t,!!n]}const Nkt=[{level:0,isMaxLevel:!0,edges:[]}];function Okt(e,t,n=!1){let r=-1;const i=e.reduce((a,o)=>{const l=Eu(o.zIndex);let u=l?o.zIndex:0;if(n){const d=t.get(o.target),f=t.get(o.source),h=o.selected||d?.selected||f?.selected,m=Math.max(f?.[Cs]?.z||0,d?.[Cs]?.z||0,1e3);u=(l?o.zIndex:0)+(h?m:0)}return a[u]?a[u].push(o):a[u]=[o],r=u>r?u:r,a},{}),s=Object.entries(i).map(([a,o])=>{const l=+a;return{edges:o,level:l,isMaxLevel:l===r}});return s.length===0?Nkt:s}function Rkt(e,t,n){const r=Li(x.useCallback(i=>e?i.edges.filter(s=>{const a=t.get(s.source),o=t.get(s.target);return a?.width&&a?.height&&o?.width&&o?.height&&Akt({sourcePos:a.positionAbsolute||{x:0,y:0},targetPos:o.positionAbsolute||{x:0,y:0},sourceWidth:a.width,sourceHeight:a.height,targetWidth:o.width,targetHeight:o.height,width:i.width,height:i.height,transform:i.transform})}):i.edges,[e,t]));return Okt(r,t,n)}const Ikt=({color:e="none",strokeWidth:t=1})=>Q.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),Dkt=({color:e="none",strokeWidth:t=1})=>Q.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),kue={[c2.Arrow]:Ikt,[c2.ArrowClosed]:Dkt};function jkt(e){const t=Ca();return x.useMemo(()=>Object.prototype.hasOwnProperty.call(kue,e)?kue[e]:(t.getState().onError?.("009",Jh.error009(e)),null),[e])}const Pkt=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:s="strokeWidth",strokeWidth:a,orient:o="auto-start-reverse"})=>{const l=jkt(t);return l?Q.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:o,refX:"0",refY:"0"},Q.createElement(l,{color:n,strokeWidth:a})):null},Lkt=({defaultColor:e,rfId:t})=>n=>{const r=[];return n.edges.reduce((i,s)=>([s.markerStart,s.markerEnd].forEach(a=>{if(a&&typeof a=="object"){const o=oU(a,t);r.includes(o)||(i.push({id:o,color:a.color||e,...a}),r.push(o))}}),i),[]).sort((i,s)=>i.id.localeCompare(s.id))},POe=({defaultColor:e,rfId:t})=>{const n=Li(x.useCallback(Lkt({defaultColor:e,rfId:t}),[e,t]),(r,i)=>!(r.length!==i.length||r.some((s,a)=>s.id!==i[a].id)));return Q.createElement("defs",null,n.map(r=>Q.createElement(Pkt,{id:r.id,key:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient})))};POe.displayName="MarkerDefinitions";var Mkt=x.memo(POe);const Fkt=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),LOe=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:i,noPanClassName:s,onEdgeContextMenu:a,onEdgeMouseEnter:o,onEdgeMouseMove:l,onEdgeMouseLeave:u,onEdgeClick:d,onEdgeDoubleClick:f,onReconnect:h,onReconnectStart:m,onReconnectEnd:g,reconnectRadius:y,children:v,disableKeyboardA11y:_})=>{const{edgesFocusable:S,edgesUpdatable:E,elementsSelectable:T,width:k,height:w,connectionMode:A,nodeInternals:R,onError:I}=Li(Fkt,Ka),D=Rkt(t,R,n);return k?Q.createElement(Q.Fragment,null,D.map(({level:j,edges:F,isMaxLevel:z})=>Q.createElement("svg",{key:j,style:{zIndex:j},width:k,height:w,className:"react-flow__edges react-flow__container"},z&&Q.createElement(Mkt,{defaultColor:e,rfId:r}),Q.createElement("g",null,F.map(P=>{const[L,M,$]=Cue(R.get(P.source)),[W,Y,q]=Cue(R.get(P.target));if(!$||!q)return null;let K=P.type||"default";i[K]||(I?.("011",Jh.error011(K)),K="default");const X=i[K]||i.default,U=A===gy.Strict?Y.target:(Y.target??[]).concat(Y.source??[]),J=Eue(M.source,P.sourceHandle),te=Eue(U,P.targetHandle),ee=J?.position||kn.Bottom,oe=te?.position||kn.Top,ae=!!(P.focusable||S&&typeof P.focusable>"u"),se=P.reconnectable||P.updatable,ue=typeof h<"u"&&(se||E&&typeof se>"u");if(!J||!te)return I?.("008",Jh.error008(J,P)),null;const{sourceX:de,sourceY:ce,targetX:Ee,targetY:Ie}=Tkt(L,J,ee,W,te,oe);return Q.createElement(X,{key:P.id,id:P.id,className:vo([P.className,s]),type:K,data:P.data,selected:!!P.selected,animated:!!P.animated,hidden:!!P.hidden,label:P.label,labelStyle:P.labelStyle,labelShowBg:P.labelShowBg,labelBgStyle:P.labelBgStyle,labelBgPadding:P.labelBgPadding,labelBgBorderRadius:P.labelBgBorderRadius,style:P.style,source:P.source,target:P.target,sourceHandleId:P.sourceHandle,targetHandleId:P.targetHandle,markerEnd:P.markerEnd,markerStart:P.markerStart,sourceX:de,sourceY:ce,targetX:Ee,targetY:Ie,sourcePosition:ee,targetPosition:oe,elementsSelectable:T,onContextMenu:a,onMouseEnter:o,onMouseMove:l,onMouseLeave:u,onClick:d,onEdgeDoubleClick:f,onReconnect:h,onReconnectStart:m,onReconnectEnd:g,reconnectRadius:y,rfId:r,ariaLabel:P.ariaLabel,isFocusable:ae,isReconnectable:ue,pathOptions:"pathOptions"in P?P.pathOptions:void 0,interactionWidth:P.interactionWidth,disableKeyboardA11y:_})})))),v):null};LOe.displayName="EdgeRenderer";var Bkt=x.memo(LOe);const $kt=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function zkt({children:e}){const t=Li($kt);return Q.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function Ukt(e){const t=dZ(),n=x.useRef(!1);x.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Hkt={[kn.Left]:kn.Right,[kn.Right]:kn.Left,[kn.Top]:kn.Bottom,[kn.Bottom]:kn.Top},MOe=({nodeId:e,handleType:t,style:n,type:r=hm.Bezier,CustomComponent:i,connectionStatus:s})=>{const{fromNode:a,handleId:o,toX:l,toY:u,connectionMode:d}=Li(x.useCallback(w=>({fromNode:w.nodeInternals.get(e),handleId:w.connectionHandleId,toX:(w.connectionPosition.x-w.transform[0])/w.transform[2],toY:(w.connectionPosition.y-w.transform[1])/w.transform[2],connectionMode:w.connectionMode}),[e]),Ka),f=a?.[Cs]?.handleBounds;let h=f?.[t];if(d===gy.Loose&&(h=h||f?.[t==="source"?"target":"source"]),!a||!h)return null;const m=o?h.find(w=>w.id===o):h[0],g=m?m.x+m.width/2:(a.width??0)/2,y=m?m.y+m.height/2:a.height??0,v=(a.positionAbsolute?.x??0)+g,_=(a.positionAbsolute?.y??0)+y,S=m?.position,E=S?Hkt[S]:null;if(!S||!E)return null;if(i)return Q.createElement(i,{connectionLineType:r,connectionLineStyle:n,fromNode:a,fromHandle:m,fromX:v,fromY:_,toX:l,toY:u,fromPosition:S,toPosition:E,connectionStatus:s});let T="";const k={sourceX:v,sourceY:_,sourcePosition:S,targetX:l,targetY:u,targetPosition:E};return r===hm.Bezier?[T]=aOe(k):r===hm.Step?[T]=aU({...k,borderRadius:0}):r===hm.SmoothStep?[T]=aU(k):r===hm.SimpleBezier?[T]=sOe(k):T=`M${v},${_} ${l},${u}`,Q.createElement("path",{d:T,fill:"none",className:"react-flow__connection-path",style:n})};MOe.displayName="ConnectionLine";const Vkt=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function Wkt({containerStyle:e,style:t,type:n,component:r}){const{nodeId:i,handleType:s,nodesConnectable:a,width:o,height:l,connectionStatus:u}=Li(Vkt,Ka);return!(i&&s&&o&&a)?null:Q.createElement("svg",{style:e,width:o,height:l,className:"react-flow__edges react-flow__connectionline react-flow__container"},Q.createElement("g",{className:vo(["react-flow__connection",u])},Q.createElement(MOe,{nodeId:i,handleType:s,style:t,type:n,CustomComponent:r,connectionStatus:u})))}function Tue(e,t){return x.useRef(null),Ca(),x.useMemo(()=>t(e),[e])}const FOe=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:i,onInit:s,onNodeClick:a,onEdgeClick:o,onNodeDoubleClick:l,onEdgeDoubleClick:u,onNodeMouseEnter:d,onNodeMouseMove:f,onNodeMouseLeave:h,onNodeContextMenu:m,onSelectionContextMenu:g,onSelectionStart:y,onSelectionEnd:v,connectionLineType:_,connectionLineStyle:S,connectionLineComponent:E,connectionLineContainerStyle:T,selectionKeyCode:k,selectionOnDrag:w,selectionMode:A,multiSelectionKeyCode:R,panActivationKeyCode:I,zoomActivationKeyCode:D,deleteKeyCode:j,onlyRenderVisibleElements:F,elementsSelectable:z,selectNodesOnDrag:P,defaultViewport:L,translateExtent:M,minZoom:$,maxZoom:W,preventScrolling:Y,defaultMarkerColor:q,zoomOnScroll:K,zoomOnPinch:X,panOnScroll:U,panOnScrollSpeed:J,panOnScrollMode:te,zoomOnDoubleClick:ee,panOnDrag:oe,onPaneClick:ae,onPaneMouseEnter:se,onPaneMouseMove:ue,onPaneMouseLeave:de,onPaneScroll:ce,onPaneContextMenu:Ee,onEdgeContextMenu:Ie,onEdgeMouseEnter:fe,onEdgeMouseMove:be,onEdgeMouseLeave:ge,onReconnect:Ce,onReconnectStart:Re,onReconnectEnd:xe,reconnectRadius:ye,noDragClassName:De,noWheelClassName:ve,noPanClassName:Oe,elevateEdgesOnSelect:Be,disableKeyboardA11y:Te,nodeOrigin:je,nodeExtent:ie,rfId:Ke})=>{const lt=Tue(e,vkt),Rt=Tue(t,kkt);return Ukt(s),Q.createElement(bkt,{onPaneClick:ae,onPaneMouseEnter:se,onPaneMouseMove:ue,onPaneMouseLeave:de,onPaneContextMenu:Ee,onPaneScroll:ce,deleteKeyCode:j,selectionKeyCode:k,selectionOnDrag:w,selectionMode:A,onSelectionStart:y,onSelectionEnd:v,multiSelectionKeyCode:R,panActivationKeyCode:I,zoomActivationKeyCode:D,elementsSelectable:z,onMove:n,onMoveStart:r,onMoveEnd:i,zoomOnScroll:K,zoomOnPinch:X,zoomOnDoubleClick:ee,panOnScroll:U,panOnScrollSpeed:J,panOnScrollMode:te,panOnDrag:oe,defaultViewport:L,translateExtent:M,minZoom:$,maxZoom:W,onSelectionContextMenu:g,preventScrolling:Y,noDragClassName:De,noWheelClassName:ve,noPanClassName:Oe,disableKeyboardA11y:Te},Q.createElement(zkt,null,Q.createElement(Bkt,{edgeTypes:Rt,onEdgeClick:o,onEdgeDoubleClick:u,onlyRenderVisibleElements:F,onEdgeContextMenu:Ie,onEdgeMouseEnter:fe,onEdgeMouseMove:be,onEdgeMouseLeave:ge,onReconnect:Ce,onReconnectStart:Re,onReconnectEnd:xe,reconnectRadius:ye,defaultMarkerColor:q,noPanClassName:Oe,elevateEdgesOnSelect:!!Be,disableKeyboardA11y:Te,rfId:Ke},Q.createElement(Wkt,{style:S,type:_,component:E,containerStyle:T})),Q.createElement("div",{className:"react-flow__edgelabel-renderer"}),Q.createElement(Skt,{nodeTypes:lt,onNodeClick:a,onNodeDoubleClick:l,onNodeMouseEnter:d,onNodeMouseMove:f,onNodeMouseLeave:h,onNodeContextMenu:m,selectNodesOnDrag:P,onlyRenderVisibleElements:F,noPanClassName:Oe,noDragClassName:De,disableKeyboardA11y:Te,nodeOrigin:je,nodeExtent:ie,rfId:Ke})))};FOe.displayName="GraphView";var qkt=x.memo(FOe);const dU=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],nm={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:dU,nodeExtent:dU,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:gy.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:xCt,isValidConnection:void 0},Gkt=()=>OSt((e,t)=>({...nm,setNodes:n=>{const{nodeInternals:r,nodeOrigin:i,elevateNodesOnSelect:s}=t();e({nodeInternals:v6(n,r,i,s)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=t();e({edges:n.map(i=>({...r,...i}))})},setDefaultNodesAndEdges:(n,r)=>{const i=typeof n<"u",s=typeof r<"u",a=i?v6(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:a,edges:s?r:[],hasDefaultNodes:i,hasDefaultEdges:s})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:i,fitViewOnInit:s,fitViewOnInitDone:a,fitViewOnInitOptions:o,domNode:l,nodeOrigin:u}=t(),d=l?.querySelector(".react-flow__viewport");if(!d)return;const f=window.getComputedStyle(d),{m22:h}=new window.DOMMatrixReadOnly(f.transform),m=n.reduce((y,v)=>{const _=i.get(v.id);if(_?.hidden)i.set(_.id,{..._,[Cs]:{..._[Cs],handleBounds:void 0}});else if(_){const S=rZ(v.nodeElement);S.width&&S.height&&(_.width!==S.width||_.height!==S.height||v.forceUpdate)&&(i.set(_.id,{..._,[Cs]:{..._[Cs],handleBounds:{source:xue(".source",v.nodeElement,h,u),target:xue(".target",v.nodeElement,h,u)}},...S}),y.push({id:_.id,type:"dimensions",dimensions:S}))}return y},[]);EOe(i,u);const g=a||s&&!a&&COe(t,{initial:!0,...o});e({nodeInternals:new Map(i),fitViewOnInitDone:g}),m?.length>0&&r?.(m)},updateNodePositions:(n,r=!0,i=!1)=>{const{triggerNodeChanges:s}=t(),a=n.map(o=>{const l={id:o.id,type:"position",dragging:i};return r&&(l.positionAbsolute=o.positionAbsolute,l.position=o.position),l});s(a)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:i,hasDefaultNodes:s,nodeOrigin:a,getNodes:o,elevateNodesOnSelect:l}=t();if(n?.length){if(s){const u=TOe(n,o()),d=v6(u,i,a,l);e({nodeInternals:d})}r?.(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:i,getNodes:s}=t();let a,o=null;r?a=n.map(l=>cm(l,!0)):(a=E0(s(),n),o=E0(i,[])),rN({changedNodes:a,changedEdges:o,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:i,getNodes:s}=t();let a,o=null;r?a=n.map(l=>cm(l,!0)):(a=E0(i,n),o=E0(s(),[])),rN({changedNodes:o,changedEdges:a,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:i,getNodes:s}=t(),a=n||s(),o=r||i,l=a.map(d=>(d.selected=!1,cm(d.id,!1))),u=o.map(d=>cm(d.id,!1));rN({changedNodes:l,changedEdges:u,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:i}=t();r?.scaleExtent([n,i]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:i}=t();r?.scaleExtent([i,n]),e({maxZoom:n})},setTranslateExtent:n=>{t().d3Zoom?.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=t(),s=r().filter(o=>o.selected).map(o=>cm(o.id,!1)),a=n.filter(o=>o.selected).map(o=>cm(o.id,!1));rN({changedNodes:s,changedEdges:a,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach(i=>{i.positionAbsolute=iZ(i.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:i,height:s,d3Zoom:a,d3Selection:o,translateExtent:l}=t();if(!a||!o||!n.x&&!n.y)return!1;const u=Mh.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),d=[[0,0],[i,s]],f=a?.constrain()(u,d,l);return a.transform(o,f),r[0]!==f.x||r[1]!==f.y||r[2]!==f.k},cancelConnection:()=>e({connectionNodeId:nm.connectionNodeId,connectionHandleId:nm.connectionHandleId,connectionHandleType:nm.connectionHandleType,connectionStatus:nm.connectionStatus,connectionStartHandle:nm.connectionStartHandle,connectionEndHandle:nm.connectionEndHandle}),reset:()=>e({...nm})}),Object.is),BOe=({children:e})=>{const t=x.useRef(null);return t.current||(t.current=Gkt()),Q.createElement(hCt,{value:t.current},e)};BOe.displayName="ReactFlowProvider";const $Oe=({children:e})=>x.useContext(S5)?Q.createElement(Q.Fragment,null,e):Q.createElement(BOe,null,e);$Oe.displayName="ReactFlowWrapper";const Kkt={input:bOe,default:cU,output:vOe,group:uZ},Ykt={default:MR,straight:oZ,step:aZ,smoothstep:w5,simplebezier:sZ},Xkt=[0,0],Qkt=[15,15],Zkt={x:0,y:0,zoom:1},Jkt={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},zOe=x.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:s=Kkt,edgeTypes:a=Ykt,onNodeClick:o,onEdgeClick:l,onInit:u,onMove:d,onMoveStart:f,onMoveEnd:h,onConnect:m,onConnectStart:g,onConnectEnd:y,onClickConnectStart:v,onClickConnectEnd:_,onNodeMouseEnter:S,onNodeMouseMove:E,onNodeMouseLeave:T,onNodeContextMenu:k,onNodeDoubleClick:w,onNodeDragStart:A,onNodeDrag:R,onNodeDragStop:I,onNodesDelete:D,onEdgesDelete:j,onSelectionChange:F,onSelectionDragStart:z,onSelectionDrag:P,onSelectionDragStop:L,onSelectionContextMenu:M,onSelectionStart:$,onSelectionEnd:W,connectionMode:Y=gy.Strict,connectionLineType:q=hm.Bezier,connectionLineStyle:K,connectionLineComponent:X,connectionLineContainerStyle:U,deleteKeyCode:J="Backspace",selectionKeyCode:te="Shift",selectionOnDrag:ee=!1,selectionMode:oe=l2.Full,panActivationKeyCode:ae="Space",multiSelectionKeyCode:se=LR()?"Meta":"Control",zoomActivationKeyCode:ue=LR()?"Meta":"Control",snapToGrid:de=!1,snapGrid:ce=Qkt,onlyRenderVisibleElements:Ee=!1,selectNodesOnDrag:Ie=!0,nodesDraggable:fe,nodesConnectable:be,nodesFocusable:ge,nodeOrigin:Ce=Xkt,edgesFocusable:Re,edgesUpdatable:xe,elementsSelectable:ye,defaultViewport:De=Zkt,minZoom:ve=.5,maxZoom:Oe=2,translateExtent:Be=dU,preventScrolling:Te=!0,nodeExtent:je,defaultMarkerColor:ie="#b1b1b7",zoomOnScroll:Ke=!0,zoomOnPinch:lt=!0,panOnScroll:Rt=!1,panOnScrollSpeed:Ye=.5,panOnScrollMode:ct=kb.Free,zoomOnDoubleClick:Ve=!0,panOnDrag:Et=!0,onPaneClick:$e,onPaneMouseEnter:Qe,onPaneMouseMove:pt,onPaneMouseLeave:at,onPaneScroll:gt,onPaneContextMenu:We,children:Xe,onEdgeContextMenu:it,onEdgeDoubleClick:ot,onEdgeMouseEnter:St,onEdgeMouseMove:Xt,onEdgeMouseLeave:Vt,onEdgeUpdate:en,onEdgeUpdateStart:Fe,onEdgeUpdateEnd:Ue,onReconnect:ut,onReconnectStart:Kt,onReconnectEnd:wn,reconnectRadius:pr=10,edgeUpdaterRadius:Mr=10,onNodesChange:qi,onEdgesChange:na,noDragClassName:ai="nodrag",noWheelClassName:Ar="nowheel",noPanClassName:mr="nopan",fitView:Ji=!1,fitViewOptions:hi,connectOnClick:Bs=!0,attributionPosition:es,proOptions:ts,defaultEdgeOptions:nt,elevateNodesOnSelect:Fn=!0,elevateEdgesOnSelect:rn=!1,disableKeyboardA11y:Yn=!1,autoPanOnConnect:Nr=!0,autoPanOnNodeDrag:oi=!0,connectionRadius:Jn=20,isValidConnection:Fr,onError:sr,style:Br,id:Si,nodeDragThreshold:ml,...tn},Na)=>{const ns=Si||"1";return Q.createElement("div",{...tn,style:{...Br,...Jkt},ref:Na,className:vo(["react-flow",i]),"data-testid":"rf__wrapper",id:Si},Q.createElement($Oe,null,Q.createElement(qkt,{onInit:u,onMove:d,onMoveStart:f,onMoveEnd:h,onNodeClick:o,onEdgeClick:l,onNodeMouseEnter:S,onNodeMouseMove:E,onNodeMouseLeave:T,onNodeContextMenu:k,onNodeDoubleClick:w,nodeTypes:s,edgeTypes:a,connectionLineType:q,connectionLineStyle:K,connectionLineComponent:X,connectionLineContainerStyle:U,selectionKeyCode:te,selectionOnDrag:ee,selectionMode:oe,deleteKeyCode:J,multiSelectionKeyCode:se,panActivationKeyCode:ae,zoomActivationKeyCode:ue,onlyRenderVisibleElements:Ee,selectNodesOnDrag:Ie,defaultViewport:De,translateExtent:Be,minZoom:ve,maxZoom:Oe,preventScrolling:Te,zoomOnScroll:Ke,zoomOnPinch:lt,zoomOnDoubleClick:Ve,panOnScroll:Rt,panOnScrollSpeed:Ye,panOnScrollMode:ct,panOnDrag:Et,onPaneClick:$e,onPaneMouseEnter:Qe,onPaneMouseMove:pt,onPaneMouseLeave:at,onPaneScroll:gt,onPaneContextMenu:We,onSelectionContextMenu:M,onSelectionStart:$,onSelectionEnd:W,onEdgeContextMenu:it,onEdgeDoubleClick:ot,onEdgeMouseEnter:St,onEdgeMouseMove:Xt,onEdgeMouseLeave:Vt,onReconnect:ut??en,onReconnectStart:Kt??Fe,onReconnectEnd:wn??Ue,reconnectRadius:pr??Mr,defaultMarkerColor:ie,noDragClassName:ai,noWheelClassName:Ar,noPanClassName:mr,elevateEdgesOnSelect:rn,rfId:ns,disableKeyboardA11y:Yn,nodeOrigin:Ce,nodeExtent:je}),Q.createElement(HCt,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:m,onConnectStart:g,onConnectEnd:y,onClickConnectStart:v,onClickConnectEnd:_,nodesDraggable:fe,nodesConnectable:be,nodesFocusable:ge,edgesFocusable:Re,edgesUpdatable:xe,elementsSelectable:ye,elevateNodesOnSelect:Fn,minZoom:ve,maxZoom:Oe,nodeExtent:je,onNodesChange:qi,onEdgesChange:na,snapToGrid:de,snapGrid:ce,connectionMode:Y,translateExtent:Be,connectOnClick:Bs,defaultEdgeOptions:nt,fitView:Ji,fitViewOptions:hi,onNodesDelete:D,onEdgesDelete:j,onNodeDragStart:A,onNodeDrag:R,onNodeDragStop:I,onSelectionDrag:P,onSelectionDragStart:z,onSelectionDragStop:L,noPanClassName:mr,nodeOrigin:Ce,rfId:ns,autoPanOnConnect:Nr,autoPanOnNodeDrag:oi,onError:sr,connectionRadius:Jn,isValidConnection:Fr,nodeDragThreshold:ml}),Q.createElement(zCt,{onSelectionChange:F}),Xe,Q.createElement(mCt,{proOptions:ts,position:es}),Q.createElement(KCt,{rfId:ns,disableKeyboardA11y:Yn})))});zOe.displayName="ReactFlow";function UOe(e){return t=>{const[n,r]=x.useState(t),i=x.useCallback(s=>r(a=>e(s,a)),[]);return[n,r,i]}}const eTt=UOe(TOe),tTt=UOe(lkt),HOe=({id:e,x:t,y:n,width:r,height:i,style:s,color:a,strokeColor:o,strokeWidth:l,className:u,borderRadius:d,shapeRendering:f,onClick:h,selected:m})=>{const{background:g,backgroundColor:y}=s||{},v=a||g||y;return Q.createElement("rect",{className:vo(["react-flow__minimap-node",{selected:m},u]),x:t,y:n,rx:d,ry:d,width:r,height:i,fill:v,stroke:o,strokeWidth:l,shapeRendering:f,onClick:h?_=>h(_,e):void 0})};HOe.displayName="MiniMapNode";var nTt=x.memo(HOe);const rTt=e=>e.nodeOrigin,iTt=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),w6=e=>e instanceof Function?e:()=>e;function sTt({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:i=2,nodeComponent:s=nTt,onClick:a}){const o=Li(iTt,Ka),l=Li(rTt),u=w6(t),d=w6(e),f=w6(n),h=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return Q.createElement(Q.Fragment,null,o.map(m=>{const{x:g,y}=Kb(m,l).positionAbsolute;return Q.createElement(s,{key:m.id,x:g,y,width:m.width,height:m.height,style:m.style,selected:m.selected,className:f(m),color:u(m),borderRadius:r,strokeColor:d(m),strokeWidth:i,shapeRendering:h,onClick:a,id:m.id})}))}var aTt=x.memo(sTt);const oTt=200,lTt=150,cTt=e=>{const t=e.getNodes(),n={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:n,boundingRect:t.length>0?yCt(E5(t,e.nodeOrigin),n):n,rfId:e.rfId}},uTt="react-flow__minimap-desc";function VOe({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:r="#e2e2e2",nodeClassName:i="",nodeBorderRadius:s=5,nodeStrokeWidth:a=2,nodeComponent:o,maskColor:l="rgb(240, 240, 240, 0.6)",maskStrokeColor:u="none",maskStrokeWidth:d=1,position:f="bottom-right",onClick:h,onNodeClick:m,pannable:g=!1,zoomable:y=!1,ariaLabel:v="React Flow mini map",inversePan:_=!1,zoomStep:S=10,offsetScale:E=5}){const T=Ca(),k=x.useRef(null),{boundingRect:w,viewBB:A,rfId:R}=Li(cTt,Ka),I=e?.width??oTt,D=e?.height??lTt,j=w.width/I,F=w.height/D,z=Math.max(j,F),P=z*I,L=z*D,M=E*z,$=w.x-(P-w.width)/2-M,W=w.y-(L-w.height)/2-M,Y=P+M*2,q=L+M*2,K=`${uTt}-${R}`,X=x.useRef(0);X.current=z,x.useEffect(()=>{if(k.current){const te=yu(k.current),ee=se=>{const{transform:ue,d3Selection:de,d3Zoom:ce}=T.getState();if(se.sourceEvent.type!=="wheel"||!de||!ce)return;const Ee=-se.sourceEvent.deltaY*(se.sourceEvent.deltaMode===1?.05:se.sourceEvent.deltaMode?1:.002)*S,Ie=ue[2]*Math.pow(2,Ee);ce.scaleTo(de,Ie)},oe=se=>{const{transform:ue,d3Selection:de,d3Zoom:ce,translateExtent:Ee,width:Ie,height:fe}=T.getState();if(se.sourceEvent.type!=="mousemove"||!de||!ce)return;const be=X.current*Math.max(1,ue[2])*(_?-1:1),ge={x:ue[0]-se.sourceEvent.movementX*be,y:ue[1]-se.sourceEvent.movementY*be},Ce=[[0,0],[Ie,fe]],Re=Mh.translate(ge.x,ge.y).scale(ue[2]),xe=ce.constrain()(Re,Ce,Ee);ce.transform(de,xe)},ae=YNe().on("zoom",g?oe:null).on("zoom.wheel",y?ee:null);return te.call(ae),()=>{te.on("zoom",null)}}},[g,y,_,S]);const U=h?te=>{const ee=ed(te);h(te,{x:ee[0],y:ee[1]})}:void 0,J=m?(te,ee)=>{const oe=T.getState().nodeInternals.get(ee);m(te,oe)}:void 0;return Q.createElement(nZ,{position:f,style:e,className:vo(["react-flow__minimap",t]),"data-testid":"rf__minimap"},Q.createElement("svg",{width:I,height:D,viewBox:`${$} ${W} ${Y} ${q}`,role:"img","aria-labelledby":K,ref:k,onClick:U},v&&Q.createElement("title",{id:K},v),Q.createElement(aTt,{onClick:J,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:s,nodeClassName:i,nodeStrokeWidth:a,nodeComponent:o}),Q.createElement("path",{className:"react-flow__minimap-mask",d:`M${$-M},${W-M}h${Y+M*2}v${q+M*2}h${-Y-M*2}z
139
139
  M${A.x},${A.y}h${A.width}v${A.height}h${-A.width}z`,fill:l,fillRule:"evenodd",stroke:u,strokeWidth:d,pointerEvents:"none"})))}VOe.displayName="MiniMap";var dTt=x.memo(VOe);function fTt(){return Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},Q.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function hTt(){return Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},Q.createElement("path",{d:"M0 0h32v4.2H0z"}))}function pTt(){return Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},Q.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function mTt(){return Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},Q.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function gTt(){return Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},Q.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const vw=({children:e,className:t,...n})=>Q.createElement("button",{type:"button",className:vo(["react-flow__controls-button",t]),...n},e);vw.displayName="ControlButton";const bTt=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),WOe=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:s,onZoomOut:a,onFitView:o,onInteractiveChange:l,className:u,children:d,position:f="bottom-left"})=>{const h=Ca(),[m,g]=x.useState(!1),{isInteractive:y,minZoomReached:v,maxZoomReached:_}=Li(bTt,Ka),{zoomIn:S,zoomOut:E,fitView:T}=dZ();if(x.useEffect(()=>{g(!0)},[]),!m)return null;const k=()=>{S(),s?.()},w=()=>{E(),a?.()},A=()=>{T(i),o?.()},R=()=>{h.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),l?.(!y)};return Q.createElement(nZ,{className:vo(["react-flow__controls",u]),position:f,style:e,"data-testid":"rf__controls"},t&&Q.createElement(Q.Fragment,null,Q.createElement(vw,{onClick:k,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:_},Q.createElement(fTt,null)),Q.createElement(vw,{onClick:w,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:v},Q.createElement(hTt,null))),n&&Q.createElement(vw,{className:"react-flow__controls-fitview",onClick:A,title:"fit view","aria-label":"fit view"},Q.createElement(pTt,null)),r&&Q.createElement(vw,{className:"react-flow__controls-interactive",onClick:R,title:"toggle interactivity","aria-label":"toggle interactivity"},y?Q.createElement(gTt,null):Q.createElement(mTt,null)),d)};WOe.displayName="Controls";var yTt=x.memo(WOe),pd;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(pd||(pd={}));function vTt({color:e,dimensions:t,lineWidth:n}){return Q.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function xTt({color:e,radius:t}){return Q.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const _Tt={[pd.Dots]:"#91919a",[pd.Lines]:"#eee",[pd.Cross]:"#e2e2e2"},STt={[pd.Dots]:1,[pd.Lines]:1,[pd.Cross]:6},wTt=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function qOe({id:e,variant:t=pd.Dots,gap:n=20,size:r,lineWidth:i=1,offset:s=2,color:a,style:o,className:l}){const u=x.useRef(null),{transform:d,patternId:f}=Li(wTt,Ka),h=a||_Tt[t],m=r||STt[t],g=t===pd.Dots,y=t===pd.Cross,v=Array.isArray(n)?n:[n,n],_=[v[0]*d[2]||1,v[1]*d[2]||1],S=m*d[2],E=y?[S,S]:_,T=g?[S/s,S/s]:[E[0]/s,E[1]/s];return Q.createElement("svg",{className:vo(["react-flow__background",l]),style:{...o,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:u,"data-testid":"rf__background"},Q.createElement("pattern",{id:f+e,x:d[0]%_[0],y:d[1]%_[1],width:_[0],height:_[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`},g?Q.createElement(xTt,{color:h,radius:S/s}):Q.createElement(vTt,{dimensions:E,color:h,lineWidth:i})),Q.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${f+e})`}))}qOe.displayName="Background";var ETt=x.memo(qOe),E6,Aue;function hZ(){if(Aue)return E6;Aue=1;var e="\0",t="\0",n="";class r{_isDirected=!0;_isMultigraph=!1;_isCompound=!1;_label;_defaultNodeLabelFn=()=>{};_defaultEdgeLabelFn=()=>{};_nodes={};_in={};_preds={};_out={};_sucs={};_edgeObjs={};_edgeLabels={};_nodeCount=0;_edgeCount=0;_parent;_children;constructor(d){d&&(this._isDirected=Object.hasOwn(d,"directed")?d.directed:!0,this._isMultigraph=Object.hasOwn(d,"multigraph")?d.multigraph:!1,this._isCompound=Object.hasOwn(d,"compound")?d.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[t]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(d){return this._label=d,this}graph(){return this._label}setDefaultNodeLabel(d){return this._defaultNodeLabelFn=d,typeof d!="function"&&(this._defaultNodeLabelFn=()=>d),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var d=this;return this.nodes().filter(f=>Object.keys(d._in[f]).length===0)}sinks(){var d=this;return this.nodes().filter(f=>Object.keys(d._out[f]).length===0)}setNodes(d,f){var h=arguments,m=this;return d.forEach(function(g){h.length>1?m.setNode(g,f):m.setNode(g)}),this}setNode(d,f){return Object.hasOwn(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=f),this):(this._nodes[d]=arguments.length>1?f:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=t,this._children[d]={},this._children[t][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)}node(d){return this._nodes[d]}hasNode(d){return Object.hasOwn(this._nodes,d)}removeNode(d){var f=this;if(Object.hasOwn(this._nodes,d)){var h=m=>f.removeEdge(f._edgeObjs[m]);delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],this.children(d).forEach(function(m){f.setParent(m)}),delete this._children[d]),Object.keys(this._in[d]).forEach(h),delete this._in[d],delete this._preds[d],Object.keys(this._out[d]).forEach(h),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this}setParent(d,f){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(f===void 0)f=t;else{f+="";for(var h=f;h!==void 0;h=this.parent(h))if(h===d)throw new Error("Setting "+f+" as parent of "+d+" would create a cycle");this.setNode(f)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=f,this._children[f][d]=!0,this}_removeFromParentsChildList(d){delete this._children[this._parent[d]][d]}parent(d){if(this._isCompound){var f=this._parent[d];if(f!==t)return f}}children(d=t){if(this._isCompound){var f=this._children[d];if(f)return Object.keys(f)}else{if(d===t)return this.nodes();if(this.hasNode(d))return[]}}predecessors(d){var f=this._preds[d];if(f)return Object.keys(f)}successors(d){var f=this._sucs[d];if(f)return Object.keys(f)}neighbors(d){var f=this.predecessors(d);if(f){const m=new Set(f);for(var h of this.successors(d))m.add(h);return Array.from(m.values())}}isLeaf(d){var f;return this.isDirected()?f=this.successors(d):f=this.neighbors(d),f.length===0}filterNodes(d){var f=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});f.setGraph(this.graph());var h=this;Object.entries(this._nodes).forEach(function([y,v]){d(y)&&f.setNode(y,v)}),Object.values(this._edgeObjs).forEach(function(y){f.hasNode(y.v)&&f.hasNode(y.w)&&f.setEdge(y,h.edge(y))});var m={};function g(y){var v=h.parent(y);return v===void 0||f.hasNode(v)?(m[y]=v,v):v in m?m[v]:g(v)}return this._isCompound&&f.nodes().forEach(y=>f.setParent(y,g(y))),f}setDefaultEdgeLabel(d){return this._defaultEdgeLabelFn=d,typeof d!="function"&&(this._defaultEdgeLabelFn=()=>d),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(d,f){var h=this,m=arguments;return d.reduce(function(g,y){return m.length>1?h.setEdge(g,y,f):h.setEdge(g,y),y}),this}setEdge(){var d,f,h,m,g=!1,y=arguments[0];typeof y=="object"&&y!==null&&"v"in y?(d=y.v,f=y.w,h=y.name,arguments.length===2&&(m=arguments[1],g=!0)):(d=y,f=arguments[1],h=arguments[3],arguments.length>2&&(m=arguments[2],g=!0)),d=""+d,f=""+f,h!==void 0&&(h=""+h);var v=a(this._isDirected,d,f,h);if(Object.hasOwn(this._edgeLabels,v))return g&&(this._edgeLabels[v]=m),this;if(h!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(f),this._edgeLabels[v]=g?m:this._defaultEdgeLabelFn(d,f,h);var _=o(this._isDirected,d,f,h);return d=_.v,f=_.w,Object.freeze(_),this._edgeObjs[v]=_,i(this._preds[f],d),i(this._sucs[d],f),this._in[f][v]=_,this._out[d][v]=_,this._edgeCount++,this}edge(d,f,h){var m=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,f,h);return this._edgeLabels[m]}edgeAsObj(){const d=this.edge(...arguments);return typeof d!="object"?{label:d}:d}hasEdge(d,f,h){var m=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,f,h);return Object.hasOwn(this._edgeLabels,m)}removeEdge(d,f,h){var m=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,f,h),g=this._edgeObjs[m];return g&&(d=g.v,f=g.w,delete this._edgeLabels[m],delete this._edgeObjs[m],s(this._preds[f],d),s(this._sucs[d],f),delete this._in[f][m],delete this._out[d][m],this._edgeCount--),this}inEdges(d,f){var h=this._in[d];if(h){var m=Object.values(h);return f?m.filter(g=>g.v===f):m}}outEdges(d,f){var h=this._out[d];if(h){var m=Object.values(h);return f?m.filter(g=>g.w===f):m}}nodeEdges(d,f){var h=this.inEdges(d,f);if(h)return h.concat(this.outEdges(d,f))}}function i(u,d){u[d]?u[d]++:u[d]=1}function s(u,d){--u[d]||delete u[d]}function a(u,d,f,h){var m=""+d,g=""+f;if(!u&&m>g){var y=m;m=g,g=y}return m+n+g+n+(h===void 0?e:h)}function o(u,d,f,h){var m=""+d,g=""+f;if(!u&&m>g){var y=m;m=g,g=y}var v={v:m,w:g};return h&&(v.name=h),v}function l(u,d){return a(u,d.v,d.w,d.name)}return E6=r,E6}var C6,Nue;function CTt(){return Nue||(Nue=1,C6="2.2.4"),C6}var k6,Oue;function kTt(){return Oue||(Oue=1,k6={Graph:hZ(),version:CTt()}),k6}var T6,Rue;function TTt(){if(Rue)return T6;Rue=1;var e=hZ();T6={write:t,read:i};function t(s){var a={options:{directed:s.isDirected(),multigraph:s.isMultigraph(),compound:s.isCompound()},nodes:n(s),edges:r(s)};return s.graph()!==void 0&&(a.value=structuredClone(s.graph())),a}function n(s){return s.nodes().map(function(a){var o=s.node(a),l=s.parent(a),u={v:a};return o!==void 0&&(u.value=o),l!==void 0&&(u.parent=l),u})}function r(s){return s.edges().map(function(a){var o=s.edge(a),l={v:a.v,w:a.w};return a.name!==void 0&&(l.name=a.name),o!==void 0&&(l.value=o),l})}function i(s){var a=new e(s.options).setGraph(s.value);return s.nodes.forEach(function(o){a.setNode(o.v,o.value),o.parent&&a.setParent(o.v,o.parent)}),s.edges.forEach(function(o){a.setEdge({v:o.v,w:o.w,name:o.name},o.value)}),a}return T6}var A6,Iue;function ATt(){if(Iue)return A6;Iue=1,A6=e;function e(t){var n={},r=[],i;function s(a){Object.hasOwn(n,a)||(n[a]=!0,i.push(a),t.successors(a).forEach(s),t.predecessors(a).forEach(s))}return t.nodes().forEach(function(a){i=[],s(a),i.length&&r.push(i)}),r}return A6}var N6,Due;function GOe(){if(Due)return N6;Due=1;class e{_arr=[];_keyIndices={};size(){return this._arr.length}keys(){return this._arr.map(function(n){return n.key})}has(n){return Object.hasOwn(this._keyIndices,n)}priority(n){var r=this._keyIndices[n];if(r!==void 0)return this._arr[r].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(n,r){var i=this._keyIndices;if(n=String(n),!Object.hasOwn(i,n)){var s=this._arr,a=s.length;return i[n]=a,s.push({key:n,priority:r}),this._decrease(a),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key}decrease(n,r){var i=this._keyIndices[n];if(r>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[i].priority+" New: "+r);this._arr[i].priority=r,this._decrease(i)}_heapify(n){var r=this._arr,i=2*n,s=i+1,a=n;i<r.length&&(a=r[i].priority<r[a].priority?i:a,s<r.length&&(a=r[s].priority<r[a].priority?s:a),a!==n&&(this._swap(n,a),this._heapify(a)))}_decrease(n){for(var r=this._arr,i=r[n].priority,s;n!==0&&(s=n>>1,!(r[s].priority<i));)this._swap(n,s),n=s}_swap(n,r){var i=this._arr,s=this._keyIndices,a=i[n],o=i[r];i[n]=o,i[r]=a,s[o.key]=n,s[a.key]=r}}return N6=e,N6}var O6,jue;function KOe(){if(jue)return O6;jue=1;var e=GOe();O6=n;var t=()=>1;function n(i,s,a,o){return r(i,String(s),a||t,o||function(l){return i.outEdges(l)})}function r(i,s,a,o){var l={},u=new e,d,f,h=function(m){var g=m.v!==d?m.v:m.w,y=l[g],v=a(m),_=f.distance+v;if(v<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+m+" Weight: "+v);_<y.distance&&(y.distance=_,y.predecessor=d,u.decrease(g,_))};for(i.nodes().forEach(function(m){var g=m===s?0:Number.POSITIVE_INFINITY;l[m]={distance:g},u.add(m,g)});u.size()>0&&(d=u.removeMin(),f=l[d],f.distance!==Number.POSITIVE_INFINITY);)o(d).forEach(h);return l}return O6}var R6,Pue;function NTt(){if(Pue)return R6;Pue=1;var e=KOe();R6=t;function t(n,r,i){return n.nodes().reduce(function(s,a){return s[a]=e(n,a,r,i),s},{})}return R6}var I6,Lue;function YOe(){if(Lue)return I6;Lue=1,I6=e;function e(t){var n=0,r=[],i={},s=[];function a(o){var l=i[o]={onStack:!0,lowlink:n,index:n++};if(r.push(o),t.successors(o).forEach(function(f){Object.hasOwn(i,f)?i[f].onStack&&(l.lowlink=Math.min(l.lowlink,i[f].index)):(a(f),l.lowlink=Math.min(l.lowlink,i[f].lowlink))}),l.lowlink===l.index){var u=[],d;do d=r.pop(),i[d].onStack=!1,u.push(d);while(o!==d);s.push(u)}}return t.nodes().forEach(function(o){Object.hasOwn(i,o)||a(o)}),s}return I6}var D6,Mue;function OTt(){if(Mue)return D6;Mue=1;var e=YOe();D6=t;function t(n){return e(n).filter(function(r){return r.length>1||r.length===1&&n.hasEdge(r[0],r[0])})}return D6}var j6,Fue;function RTt(){if(Fue)return j6;Fue=1,j6=t;var e=()=>1;function t(r,i,s){return n(r,i||e,s||function(a){return r.outEdges(a)})}function n(r,i,s){var a={},o=r.nodes();return o.forEach(function(l){a[l]={},a[l][l]={distance:0},o.forEach(function(u){l!==u&&(a[l][u]={distance:Number.POSITIVE_INFINITY})}),s(l).forEach(function(u){var d=u.v===l?u.w:u.v,f=i(u);a[l][d]={distance:f,predecessor:l}})}),o.forEach(function(l){var u=a[l];o.forEach(function(d){var f=a[d];o.forEach(function(h){var m=f[l],g=u[h],y=f[h],v=m.distance+g.distance;v<y.distance&&(y.distance=v,y.predecessor=g.predecessor)})})}),a}return j6}var P6,Bue;function XOe(){if(Bue)return P6;Bue=1;function e(n){var r={},i={},s=[];function a(o){if(Object.hasOwn(i,o))throw new t;Object.hasOwn(r,o)||(i[o]=!0,r[o]=!0,n.predecessors(o).forEach(a),delete i[o],s.push(o))}if(n.sinks().forEach(a),Object.keys(r).length!==n.nodeCount())throw new t;return s}class t extends Error{constructor(){super(...arguments)}}return P6=e,e.CycleException=t,P6}var L6,$ue;function ITt(){if($ue)return L6;$ue=1;var e=XOe();L6=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return L6}var M6,zue;function QOe(){if(zue)return M6;zue=1,M6=e;function e(i,s,a){Array.isArray(s)||(s=[s]);var o=i.isDirected()?f=>i.successors(f):f=>i.neighbors(f),l=a==="post"?t:n,u=[],d={};return s.forEach(f=>{if(!i.hasNode(f))throw new Error("Graph does not have node: "+f);l(f,o,d,u)}),u}function t(i,s,a,o){for(var l=[[i,!1]];l.length>0;){var u=l.pop();u[1]?o.push(u[0]):Object.hasOwn(a,u[0])||(a[u[0]]=!0,l.push([u[0],!0]),r(s(u[0]),d=>l.push([d,!1])))}}function n(i,s,a,o){for(var l=[i];l.length>0;){var u=l.pop();Object.hasOwn(a,u)||(a[u]=!0,o.push(u),r(s(u),d=>l.push(d)))}}function r(i,s){for(var a=i.length;a--;)s(i[a],a,i);return i}return M6}var F6,Uue;function DTt(){if(Uue)return F6;Uue=1;var e=QOe();F6=t;function t(n,r){return e(n,r,"post")}return F6}var B6,Hue;function jTt(){if(Hue)return B6;Hue=1;var e=QOe();B6=t;function t(n,r){return e(n,r,"pre")}return B6}var $6,Vue;function PTt(){if(Vue)return $6;Vue=1;var e=hZ(),t=GOe();$6=n;function n(r,i){var s=new e,a={},o=new t,l;function u(f){var h=f.v===l?f.w:f.v,m=o.priority(h);if(m!==void 0){var g=i(f);g<m&&(a[h]=l,o.decrease(h,g))}}if(r.nodeCount()===0)return s;r.nodes().forEach(function(f){o.add(f,Number.POSITIVE_INFINITY),s.setNode(f)}),o.decrease(r.nodes()[0],0);for(var d=!1;o.size()>0;){if(l=o.removeMin(),Object.hasOwn(a,l))s.setEdge(l,a[l]);else{if(d)throw new Error("Input graph is not connected: "+r);d=!0}r.nodeEdges(l).forEach(u)}return s}return $6}var z6,Wue;function LTt(){return Wue||(Wue=1,z6={components:ATt(),dijkstra:KOe(),dijkstraAll:NTt(),findCycles:OTt(),floydWarshall:RTt(),isAcyclic:ITt(),postorder:DTt(),preorder:jTt(),prim:PTt(),tarjan:YOe(),topsort:XOe()}),z6}var U6,que;function vd(){if(que)return U6;que=1;var e=kTt();return U6={Graph:e.Graph,json:TTt(),alg:LTt(),version:e.version},U6}var H6,Gue;function MTt(){if(Gue)return H6;Gue=1;class e{constructor(){let i={};i._next=i._prev=i,this._sentinel=i}dequeue(){let i=this._sentinel,s=i._prev;if(s!==i)return t(s),s}enqueue(i){let s=this._sentinel;i._prev&&i._next&&t(i),i._next=s._next,s._next._prev=i,s._next=i,i._prev=s}toString(){let i=[],s=this._sentinel,a=s._prev;for(;a!==s;)i.push(JSON.stringify(a,n)),a=a._prev;return"["+i.join(", ")+"]"}}function t(r){r._prev._next=r._next,r._next._prev=r._prev,delete r._next,delete r._prev}function n(r,i){if(r!=="_next"&&r!=="_prev")return i}return H6=e,H6}var V6,Kue;function FTt(){if(Kue)return V6;Kue=1;let e=vd().Graph,t=MTt();V6=r;let n=()=>1;function r(u,d){if(u.nodeCount()<=1)return[];let f=a(u,d||n);return i(f.graph,f.buckets,f.zeroIdx).flatMap(m=>u.outEdges(m.v,m.w))}function i(u,d,f){let h=[],m=d[d.length-1],g=d[0],y;for(;u.nodeCount();){for(;y=g.dequeue();)s(u,d,f,y);for(;y=m.dequeue();)s(u,d,f,y);if(u.nodeCount()){for(let v=d.length-2;v>0;--v)if(y=d[v].dequeue(),y){h=h.concat(s(u,d,f,y,!0));break}}}return h}function s(u,d,f,h,m){let g=m?[]:void 0;return u.inEdges(h.v).forEach(y=>{let v=u.edge(y),_=u.node(y.v);m&&g.push({v:y.v,w:y.w}),_.out-=v,o(d,f,_)}),u.outEdges(h.v).forEach(y=>{let v=u.edge(y),_=y.w,S=u.node(_);S.in-=v,o(d,f,S)}),u.removeNode(h.v),g}function a(u,d){let f=new e,h=0,m=0;u.nodes().forEach(v=>{f.setNode(v,{v,in:0,out:0})}),u.edges().forEach(v=>{let _=f.edge(v.v,v.w)||0,S=d(v),E=_+S;f.setEdge(v.v,v.w,E),m=Math.max(m,f.node(v.v).out+=S),h=Math.max(h,f.node(v.w).in+=S)});let g=l(m+h+3).map(()=>new t),y=h+1;return f.nodes().forEach(v=>{o(g,y,f.node(v))}),{graph:f,buckets:g,zeroIdx:y}}function o(u,d,f){f.out?f.in?u[f.out-f.in+d].enqueue(f):u[u.length-1].enqueue(f):u[0].enqueue(f)}function l(u){const d=[];for(let f=0;f<u;f++)d.push(f);return d}return V6}var W6,Yue;function ea(){if(Yue)return W6;Yue=1;let e=vd().Graph;W6={addBorderNode:d,addDummyNode:t,applyWithChunking:m,asNonCompoundGraph:r,buildLayerMatrix:o,intersectRect:a,mapValues:w,maxRank:g,normalizeRanks:l,notime:_,partition:y,pick:k,predecessorWeights:s,range:T,removeEmptyRanks:u,simplify:n,successorWeights:i,time:v,uniqueId:E,zipObject:A};function t(R,I,D,j){for(var F=j;R.hasNode(F);)F=E(j);return D.dummy=I,R.setNode(F,D),F}function n(R){let I=new e().setGraph(R.graph());return R.nodes().forEach(D=>I.setNode(D,R.node(D))),R.edges().forEach(D=>{let j=I.edge(D.v,D.w)||{weight:0,minlen:1},F=R.edge(D);I.setEdge(D.v,D.w,{weight:j.weight+F.weight,minlen:Math.max(j.minlen,F.minlen)})}),I}function r(R){let I=new e({multigraph:R.isMultigraph()}).setGraph(R.graph());return R.nodes().forEach(D=>{R.children(D).length||I.setNode(D,R.node(D))}),R.edges().forEach(D=>{I.setEdge(D,R.edge(D))}),I}function i(R){let I=R.nodes().map(D=>{let j={};return R.outEdges(D).forEach(F=>{j[F.w]=(j[F.w]||0)+R.edge(F).weight}),j});return A(R.nodes(),I)}function s(R){let I=R.nodes().map(D=>{let j={};return R.inEdges(D).forEach(F=>{j[F.v]=(j[F.v]||0)+R.edge(F).weight}),j});return A(R.nodes(),I)}function a(R,I){let D=R.x,j=R.y,F=I.x-D,z=I.y-j,P=R.width/2,L=R.height/2;if(!F&&!z)throw new Error("Not possible to find intersection inside of the rectangle");let M,$;return Math.abs(z)*P>Math.abs(F)*L?(z<0&&(L=-L),M=L*F/z,$=L):(F<0&&(P=-P),M=P,$=P*z/F),{x:D+M,y:j+$}}function o(R){let I=T(g(R)+1).map(()=>[]);return R.nodes().forEach(D=>{let j=R.node(D),F=j.rank;F!==void 0&&(I[F][j.order]=D)}),I}function l(R){let I=R.nodes().map(j=>{let F=R.node(j).rank;return F===void 0?Number.MAX_VALUE:F}),D=m(Math.min,I);R.nodes().forEach(j=>{let F=R.node(j);Object.hasOwn(F,"rank")&&(F.rank-=D)})}function u(R){let I=R.nodes().map(P=>R.node(P).rank),D=m(Math.min,I),j=[];R.nodes().forEach(P=>{let L=R.node(P).rank-D;j[L]||(j[L]=[]),j[L].push(P)});let F=0,z=R.graph().nodeRankFactor;Array.from(j).forEach((P,L)=>{P===void 0&&L%z!==0?--F:P!==void 0&&F&&P.forEach(M=>R.node(M).rank+=F)})}function d(R,I,D,j){let F={width:0,height:0};return arguments.length>=4&&(F.rank=D,F.order=j),t(R,"border",F,I)}function f(R,I=h){const D=[];for(let j=0;j<R.length;j+=I){const F=R.slice(j,j+I);D.push(F)}return D}const h=65535;function m(R,I){if(I.length>h){const D=f(I);return R.apply(null,D.map(j=>R.apply(null,j)))}else return R.apply(null,I)}function g(R){const D=R.nodes().map(j=>{let F=R.node(j).rank;return F===void 0?Number.MIN_VALUE:F});return m(Math.max,D)}function y(R,I){let D={lhs:[],rhs:[]};return R.forEach(j=>{I(j)?D.lhs.push(j):D.rhs.push(j)}),D}function v(R,I){let D=Date.now();try{return I()}finally{console.log(R+" time: "+(Date.now()-D)+"ms")}}function _(R,I){return I()}let S=0;function E(R){var I=++S;return R+(""+I)}function T(R,I,D=1){I==null&&(I=R,R=0);let j=z=>z<I;D<0&&(j=z=>I<z);const F=[];for(let z=R;j(z);z+=D)F.push(z);return F}function k(R,I){const D={};for(const j of I)R[j]!==void 0&&(D[j]=R[j]);return D}function w(R,I){let D=I;return typeof I=="string"&&(D=j=>j[I]),Object.entries(R).reduce((j,[F,z])=>(j[F]=D(z,F),j),{})}function A(R,I){return R.reduce((D,j,F)=>(D[j]=I[F],D),{})}return W6}var q6,Xue;function BTt(){if(Xue)return q6;Xue=1;let e=FTt(),t=ea().uniqueId;q6={run:n,undo:i};function n(s){(s.graph().acyclicer==="greedy"?e(s,o(s)):r(s)).forEach(l=>{let u=s.edge(l);s.removeEdge(l),u.forwardName=l.name,u.reversed=!0,s.setEdge(l.w,l.v,u,t("rev"))});function o(l){return u=>l.edge(u).weight}}function r(s){let a=[],o={},l={};function u(d){Object.hasOwn(l,d)||(l[d]=!0,o[d]=!0,s.outEdges(d).forEach(f=>{Object.hasOwn(o,f.w)?a.push(f):u(f.w)}),delete o[d])}return s.nodes().forEach(u),a}function i(s){s.edges().forEach(a=>{let o=s.edge(a);if(o.reversed){s.removeEdge(a);let l=o.forwardName;delete o.reversed,delete o.forwardName,s.setEdge(a.w,a.v,o,l)}})}return q6}var G6,Que;function $Tt(){if(Que)return G6;Que=1;let e=ea();G6={run:t,undo:r};function t(i){i.graph().dummyChains=[],i.edges().forEach(s=>n(i,s))}function n(i,s){let a=s.v,o=i.node(a).rank,l=s.w,u=i.node(l).rank,d=s.name,f=i.edge(s),h=f.labelRank;if(u===o+1)return;i.removeEdge(s);let m,g,y;for(y=0,++o;o<u;++y,++o)f.points=[],g={width:0,height:0,edgeLabel:f,edgeObj:s,rank:o},m=e.addDummyNode(i,"edge",g,"_d"),o===h&&(g.width=f.width,g.height=f.height,g.dummy="edge-label",g.labelpos=f.labelpos),i.setEdge(a,m,{weight:f.weight},d),y===0&&i.graph().dummyChains.push(m),a=m;i.setEdge(a,l,{weight:f.weight},d)}function r(i){i.graph().dummyChains.forEach(s=>{let a=i.node(s),o=a.edgeLabel,l;for(i.setEdge(a.edgeObj,o);a.dummy;)l=i.successors(s)[0],i.removeNode(s),o.points.push({x:a.x,y:a.y}),a.dummy==="edge-label"&&(o.x=a.x,o.y=a.y,o.width=a.width,o.height=a.height),s=l,a=i.node(s)})}return G6}var K6,Zue;function FR(){if(Zue)return K6;Zue=1;const{applyWithChunking:e}=ea();K6={longestPath:t,slack:n};function t(r){var i={};function s(a){var o=r.node(a);if(Object.hasOwn(i,a))return o.rank;i[a]=!0;let l=r.outEdges(a).map(d=>d==null?Number.POSITIVE_INFINITY:s(d.w)-r.edge(d).minlen);var u=e(Math.min,l);return u===Number.POSITIVE_INFINITY&&(u=0),o.rank=u}r.sources().forEach(s)}function n(r,i){return r.node(i.w).rank-r.node(i.v).rank-r.edge(i).minlen}return K6}var Y6,Jue;function ZOe(){if(Jue)return Y6;Jue=1;var e=vd().Graph,t=FR().slack;Y6=n;function n(a){var o=new e({directed:!1}),l=a.nodes()[0],u=a.nodeCount();o.setNode(l,{});for(var d,f;r(o,a)<u;)d=i(o,a),f=o.hasNode(d.v)?t(a,d):-t(a,d),s(o,a,f);return o}function r(a,o){function l(u){o.nodeEdges(u).forEach(d=>{var f=d.v,h=u===f?d.w:f;!a.hasNode(h)&&!t(o,d)&&(a.setNode(h,{}),a.setEdge(u,h,{}),l(h))})}return a.nodes().forEach(l),a.nodeCount()}function i(a,o){return o.edges().reduce((u,d)=>{let f=Number.POSITIVE_INFINITY;return a.hasNode(d.v)!==a.hasNode(d.w)&&(f=t(o,d)),f<u[0]?[f,d]:u},[Number.POSITIVE_INFINITY,null])[1]}function s(a,o,l){a.nodes().forEach(u=>o.node(u).rank+=l)}return Y6}var X6,ede;function zTt(){if(ede)return X6;ede=1;var e=ZOe(),t=FR().slack,n=FR().longestPath,r=vd().alg.preorder,i=vd().alg.postorder,s=ea().simplify;X6=a,a.initLowLimValues=d,a.initCutValues=o,a.calcCutValue=u,a.leaveEdge=h,a.enterEdge=m,a.exchangeEdges=g;function a(S){S=s(S),n(S);var E=e(S);d(E),o(E,S);for(var T,k;T=h(E);)k=m(E,S,T),g(E,S,T,k)}function o(S,E){var T=i(S,S.nodes());T=T.slice(0,T.length-1),T.forEach(k=>l(S,E,k))}function l(S,E,T){var k=S.node(T),w=k.parent;S.edge(T,w).cutvalue=u(S,E,T)}function u(S,E,T){var k=S.node(T),w=k.parent,A=!0,R=E.edge(T,w),I=0;return R||(A=!1,R=E.edge(w,T)),I=R.weight,E.nodeEdges(T).forEach(D=>{var j=D.v===T,F=j?D.w:D.v;if(F!==w){var z=j===A,P=E.edge(D).weight;if(I+=z?P:-P,v(S,T,F)){var L=S.edge(T,F).cutvalue;I+=z?-L:L}}}),I}function d(S,E){arguments.length<2&&(E=S.nodes()[0]),f(S,{},1,E)}function f(S,E,T,k,w){var A=T,R=S.node(k);return E[k]=!0,S.neighbors(k).forEach(I=>{Object.hasOwn(E,I)||(T=f(S,E,T,I,k))}),R.low=A,R.lim=T++,w?R.parent=w:delete R.parent,T}function h(S){return S.edges().find(E=>S.edge(E).cutvalue<0)}function m(S,E,T){var k=T.v,w=T.w;E.hasEdge(k,w)||(k=T.w,w=T.v);var A=S.node(k),R=S.node(w),I=A,D=!1;A.lim>R.lim&&(I=R,D=!0);var j=E.edges().filter(F=>D===_(S,S.node(F.v),I)&&D!==_(S,S.node(F.w),I));return j.reduce((F,z)=>t(E,z)<t(E,F)?z:F)}function g(S,E,T,k){var w=T.v,A=T.w;S.removeEdge(w,A),S.setEdge(k.v,k.w,{}),d(S),o(S,E),y(S,E)}function y(S,E){var T=S.nodes().find(w=>!E.node(w).parent),k=r(S,T);k=k.slice(1),k.forEach(w=>{var A=S.node(w).parent,R=E.edge(w,A),I=!1;R||(R=E.edge(A,w),I=!0),E.node(w).rank=E.node(A).rank+(I?R.minlen:-R.minlen)})}function v(S,E,T){return S.hasEdge(E,T)}function _(S,E,T){return T.low<=E.lim&&E.lim<=T.lim}return X6}var Q6,tde;function UTt(){if(tde)return Q6;tde=1;var e=FR(),t=e.longestPath,n=ZOe(),r=zTt();Q6=i;function i(l){var u=l.graph().ranker;if(u instanceof Function)return u(l);switch(l.graph().ranker){case"network-simplex":o(l);break;case"tight-tree":a(l);break;case"longest-path":s(l);break;case"none":break;default:o(l)}}var s=t;function a(l){t(l),n(l)}function o(l){r(l)}return Q6}var Z6,nde;function HTt(){if(nde)return Z6;nde=1,Z6=e;function e(r){let i=n(r);r.graph().dummyChains.forEach(s=>{let a=r.node(s),o=a.edgeObj,l=t(r,i,o.v,o.w),u=l.path,d=l.lca,f=0,h=u[f],m=!0;for(;s!==o.w;){if(a=r.node(s),m){for(;(h=u[f])!==d&&r.node(h).maxRank<a.rank;)f++;h===d&&(m=!1)}if(!m){for(;f<u.length-1&&r.node(h=u[f+1]).minRank<=a.rank;)f++;h=u[f]}r.setParent(s,h),s=r.successors(s)[0]}})}function t(r,i,s,a){let o=[],l=[],u=Math.min(i[s].low,i[a].low),d=Math.max(i[s].lim,i[a].lim),f,h;f=s;do f=r.parent(f),o.push(f);while(f&&(i[f].low>u||d>i[f].lim));for(h=f,f=a;(f=r.parent(f))!==h;)l.push(f);return{path:o.concat(l.reverse()),lca:h}}function n(r){let i={},s=0;function a(o){let l=s;r.children(o).forEach(a),i[o]={low:l,lim:s++}}return r.children().forEach(a),i}return Z6}var J6,rde;function VTt(){if(rde)return J6;rde=1;let e=ea();J6={run:t,cleanup:s};function t(a){let o=e.addDummyNode(a,"root",{},"_root"),l=r(a),u=Object.values(l),d=e.applyWithChunking(Math.max,u)-1,f=2*d+1;a.graph().nestingRoot=o,a.edges().forEach(m=>a.edge(m).minlen*=f);let h=i(a)+1;a.children().forEach(m=>n(a,o,f,h,d,l,m)),a.graph().nodeRankFactor=f}function n(a,o,l,u,d,f,h){let m=a.children(h);if(!m.length){h!==o&&a.setEdge(o,h,{weight:0,minlen:l});return}let g=e.addBorderNode(a,"_bt"),y=e.addBorderNode(a,"_bb"),v=a.node(h);a.setParent(g,h),v.borderTop=g,a.setParent(y,h),v.borderBottom=y,m.forEach(_=>{n(a,o,l,u,d,f,_);let S=a.node(_),E=S.borderTop?S.borderTop:_,T=S.borderBottom?S.borderBottom:_,k=S.borderTop?u:2*u,w=E!==T?1:d-f[h]+1;a.setEdge(g,E,{weight:k,minlen:w,nestingEdge:!0}),a.setEdge(T,y,{weight:k,minlen:w,nestingEdge:!0})}),a.parent(h)||a.setEdge(o,g,{weight:0,minlen:d+f[h]})}function r(a){var o={};function l(u,d){var f=a.children(u);f&&f.length&&f.forEach(h=>l(h,d+1)),o[u]=d}return a.children().forEach(u=>l(u,1)),o}function i(a){return a.edges().reduce((o,l)=>o+a.edge(l).weight,0)}function s(a){var o=a.graph();a.removeNode(o.nestingRoot),delete o.nestingRoot,a.edges().forEach(l=>{var u=a.edge(l);u.nestingEdge&&a.removeEdge(l)})}return J6}var eM,ide;function WTt(){if(ide)return eM;ide=1;let e=ea();eM=t;function t(r){function i(s){let a=r.children(s),o=r.node(s);if(a.length&&a.forEach(i),Object.hasOwn(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(let l=o.minRank,u=o.maxRank+1;l<u;++l)n(r,"borderLeft","_bl",s,o,l),n(r,"borderRight","_br",s,o,l)}}r.children().forEach(i)}function n(r,i,s,a,o,l){let u={width:0,height:0,rank:l,borderType:i},d=o[i][l-1],f=e.addDummyNode(r,"border",u,s);o[i][l]=f,r.setParent(f,a),d&&r.setEdge(d,f,{weight:1})}return eM}var tM,sde;function qTt(){if(sde)return tM;sde=1,tM={adjust:e,undo:t};function e(l){let u=l.graph().rankdir.toLowerCase();(u==="lr"||u==="rl")&&n(l)}function t(l){let u=l.graph().rankdir.toLowerCase();(u==="bt"||u==="rl")&&i(l),(u==="lr"||u==="rl")&&(a(l),n(l))}function n(l){l.nodes().forEach(u=>r(l.node(u))),l.edges().forEach(u=>r(l.edge(u)))}function r(l){let u=l.width;l.width=l.height,l.height=u}function i(l){l.nodes().forEach(u=>s(l.node(u))),l.edges().forEach(u=>{let d=l.edge(u);d.points.forEach(s),Object.hasOwn(d,"y")&&s(d)})}function s(l){l.y=-l.y}function a(l){l.nodes().forEach(u=>o(l.node(u))),l.edges().forEach(u=>{let d=l.edge(u);d.points.forEach(o),Object.hasOwn(d,"x")&&o(d)})}function o(l){let u=l.x;l.x=l.y,l.y=u}return tM}var nM,ade;function GTt(){if(ade)return nM;ade=1;let e=ea();nM=t;function t(n){let r={},i=n.nodes().filter(d=>!n.children(d).length),s=i.map(d=>n.node(d).rank),a=e.applyWithChunking(Math.max,s),o=e.range(a+1).map(()=>[]);function l(d){if(r[d])return;r[d]=!0;let f=n.node(d);o[f.rank].push(d),n.successors(d).forEach(l)}return i.sort((d,f)=>n.node(d).rank-n.node(f).rank).forEach(l),o}return nM}var rM,ode;function KTt(){if(ode)return rM;ode=1;let e=ea().zipObject;rM=t;function t(r,i){let s=0;for(let a=1;a<i.length;++a)s+=n(r,i[a-1],i[a]);return s}function n(r,i,s){let a=e(s,s.map((h,m)=>m)),o=i.flatMap(h=>r.outEdges(h).map(m=>({pos:a[m.w],weight:r.edge(m).weight})).sort((m,g)=>m.pos-g.pos)),l=1;for(;l<s.length;)l<<=1;let u=2*l-1;l-=1;let d=new Array(u).fill(0),f=0;return o.forEach(h=>{let m=h.pos+l;d[m]+=h.weight;let g=0;for(;m>0;)m%2&&(g+=d[m+1]),m=m-1>>1,d[m]+=h.weight;f+=h.weight*g}),f}return rM}var iM,lde;function YTt(){if(lde)return iM;lde=1,iM=e;function e(t,n=[]){return n.map(r=>{let i=t.inEdges(r);if(i.length){let s=i.reduce((a,o)=>{let l=t.edge(o),u=t.node(o.v);return{sum:a.sum+l.weight*u.order,weight:a.weight+l.weight}},{sum:0,weight:0});return{v:r,barycenter:s.sum/s.weight,weight:s.weight}}else return{v:r}})}return iM}var sM,cde;function XTt(){if(cde)return sM;cde=1;let e=ea();sM=t;function t(i,s){let a={};i.forEach((l,u)=>{let d=a[l.v]={indegree:0,in:[],out:[],vs:[l.v],i:u};l.barycenter!==void 0&&(d.barycenter=l.barycenter,d.weight=l.weight)}),s.edges().forEach(l=>{let u=a[l.v],d=a[l.w];u!==void 0&&d!==void 0&&(d.indegree++,u.out.push(a[l.w]))});let o=Object.values(a).filter(l=>!l.indegree);return n(o)}function n(i){let s=[];function a(l){return u=>{u.merged||(u.barycenter===void 0||l.barycenter===void 0||u.barycenter>=l.barycenter)&&r(l,u)}}function o(l){return u=>{u.in.push(l),--u.indegree===0&&i.push(u)}}for(;i.length;){let l=i.pop();s.push(l),l.in.reverse().forEach(a(l)),l.out.forEach(o(l))}return s.filter(l=>!l.merged).map(l=>e.pick(l,["vs","i","barycenter","weight"]))}function r(i,s){let a=0,o=0;i.weight&&(a+=i.barycenter*i.weight,o+=i.weight),s.weight&&(a+=s.barycenter*s.weight,o+=s.weight),i.vs=s.vs.concat(i.vs),i.barycenter=a/o,i.weight=o,i.i=Math.min(s.i,i.i),s.merged=!0}return sM}var aM,ude;function QTt(){if(ude)return aM;ude=1;let e=ea();aM=t;function t(i,s){let a=e.partition(i,g=>Object.hasOwn(g,"barycenter")),o=a.lhs,l=a.rhs.sort((g,y)=>y.i-g.i),u=[],d=0,f=0,h=0;o.sort(r(!!s)),h=n(u,l,h),o.forEach(g=>{h+=g.vs.length,u.push(g.vs),d+=g.barycenter*g.weight,f+=g.weight,h=n(u,l,h)});let m={vs:u.flat(!0)};return f&&(m.barycenter=d/f,m.weight=f),m}function n(i,s,a){let o;for(;s.length&&(o=s[s.length-1]).i<=a;)s.pop(),i.push(o.vs),a++;return a}function r(i){return(s,a)=>s.barycenter<a.barycenter?-1:s.barycenter>a.barycenter?1:i?a.i-s.i:s.i-a.i}return aM}var oM,dde;function ZTt(){if(dde)return oM;dde=1;let e=YTt(),t=XTt(),n=QTt();oM=r;function r(a,o,l,u){let d=a.children(o),f=a.node(o),h=f?f.borderLeft:void 0,m=f?f.borderRight:void 0,g={};h&&(d=d.filter(S=>S!==h&&S!==m));let y=e(a,d);y.forEach(S=>{if(a.children(S.v).length){let E=r(a,S.v,l,u);g[S.v]=E,Object.hasOwn(E,"barycenter")&&s(S,E)}});let v=t(y,l);i(v,g);let _=n(v,u);if(h&&(_.vs=[h,_.vs,m].flat(!0),a.predecessors(h).length)){let S=a.node(a.predecessors(h)[0]),E=a.node(a.predecessors(m)[0]);Object.hasOwn(_,"barycenter")||(_.barycenter=0,_.weight=0),_.barycenter=(_.barycenter*_.weight+S.order+E.order)/(_.weight+2),_.weight+=2}return _}function i(a,o){a.forEach(l=>{l.vs=l.vs.flatMap(u=>o[u]?o[u].vs:u)})}function s(a,o){a.barycenter!==void 0?(a.barycenter=(a.barycenter*a.weight+o.barycenter*o.weight)/(a.weight+o.weight),a.weight+=o.weight):(a.barycenter=o.barycenter,a.weight=o.weight)}return oM}var lM,fde;function JTt(){if(fde)return lM;fde=1;let e=vd().Graph,t=ea();lM=n;function n(i,s,a,o){o||(o=i.nodes());let l=r(i),u=new e({compound:!0}).setGraph({root:l}).setDefaultNodeLabel(d=>i.node(d));return o.forEach(d=>{let f=i.node(d),h=i.parent(d);(f.rank===s||f.minRank<=s&&s<=f.maxRank)&&(u.setNode(d),u.setParent(d,h||l),i[a](d).forEach(m=>{let g=m.v===d?m.w:m.v,y=u.edge(g,d),v=y!==void 0?y.weight:0;u.setEdge(g,d,{weight:i.edge(m).weight+v})}),Object.hasOwn(f,"minRank")&&u.setNode(d,{borderLeft:f.borderLeft[s],borderRight:f.borderRight[s]}))}),u}function r(i){for(var s;i.hasNode(s=t.uniqueId("_root")););return s}return lM}var cM,hde;function eAt(){if(hde)return cM;hde=1,cM=e;function e(t,n,r){let i={},s;r.forEach(a=>{let o=t.parent(a),l,u;for(;o;){if(l=t.parent(o),l?(u=i[l],i[l]=o):(u=s,s=o),u&&u!==o){n.setEdge(u,o);return}o=l}})}return cM}var uM,pde;function tAt(){if(pde)return uM;pde=1;let e=GTt(),t=KTt(),n=ZTt(),r=JTt(),i=eAt(),s=vd().Graph,a=ea();uM=o;function o(f,h){if(h&&typeof h.customOrder=="function"){h.customOrder(f,o);return}let m=a.maxRank(f),g=l(f,a.range(1,m+1),"inEdges"),y=l(f,a.range(m-1,-1,-1),"outEdges"),v=e(f);if(d(f,v),h&&h.disableOptimalOrderHeuristic)return;let _=Number.POSITIVE_INFINITY,S;for(let E=0,T=0;T<4;++E,++T){u(E%2?g:y,E%4>=2),v=a.buildLayerMatrix(f);let k=t(f,v);k<_&&(T=0,S=Object.assign({},v),_=k)}d(f,S)}function l(f,h,m){const g=new Map,y=(v,_)=>{g.has(v)||g.set(v,[]),g.get(v).push(_)};for(const v of f.nodes()){const _=f.node(v);if(typeof _.rank=="number"&&y(_.rank,v),typeof _.minRank=="number"&&typeof _.maxRank=="number")for(let S=_.minRank;S<=_.maxRank;S++)S!==_.rank&&y(S,v)}return h.map(function(v){return r(f,v,m,g.get(v)||[])})}function u(f,h){let m=new s;f.forEach(function(g){let y=g.graph().root,v=n(g,y,m,h);v.vs.forEach((_,S)=>g.node(_).order=S),i(g,m,v.vs)})}function d(f,h){Object.values(h).forEach(m=>m.forEach((g,y)=>f.node(g).order=y))}return uM}var dM,mde;function nAt(){if(mde)return dM;mde=1;let e=vd().Graph,t=ea();dM={positionX:m,findType1Conflicts:n,findType2Conflicts:r,addConflict:s,hasConflict:a,verticalAlignment:o,horizontalCompaction:l,alignCoordinates:f,findSmallestWidthAlignment:d,balance:h};function n(v,_){let S={};function E(T,k){let w=0,A=0,R=T.length,I=k[k.length-1];return k.forEach((D,j)=>{let F=i(v,D),z=F?v.node(F).order:R;(F||D===I)&&(k.slice(A,j+1).forEach(P=>{v.predecessors(P).forEach(L=>{let M=v.node(L),$=M.order;($<w||z<$)&&!(M.dummy&&v.node(P).dummy)&&s(S,L,P)})}),A=j+1,w=z)}),k}return _.length&&_.reduce(E),S}function r(v,_){let S={};function E(k,w,A,R,I){let D;t.range(w,A).forEach(j=>{D=k[j],v.node(D).dummy&&v.predecessors(D).forEach(F=>{let z=v.node(F);z.dummy&&(z.order<R||z.order>I)&&s(S,F,D)})})}function T(k,w){let A=-1,R,I=0;return w.forEach((D,j)=>{if(v.node(D).dummy==="border"){let F=v.predecessors(D);F.length&&(R=v.node(F[0]).order,E(w,I,j,A,R),I=j,A=R)}E(w,I,w.length,R,k.length)}),w}return _.length&&_.reduce(T),S}function i(v,_){if(v.node(_).dummy)return v.predecessors(_).find(S=>v.node(S).dummy)}function s(v,_,S){if(_>S){let T=_;_=S,S=T}let E=v[_];E||(v[_]=E={}),E[S]=!0}function a(v,_,S){if(_>S){let E=_;_=S,S=E}return!!v[_]&&Object.hasOwn(v[_],S)}function o(v,_,S,E){let T={},k={},w={};return _.forEach(A=>{A.forEach((R,I)=>{T[R]=R,k[R]=R,w[R]=I})}),_.forEach(A=>{let R=-1;A.forEach(I=>{let D=E(I);if(D.length){D=D.sort((F,z)=>w[F]-w[z]);let j=(D.length-1)/2;for(let F=Math.floor(j),z=Math.ceil(j);F<=z;++F){let P=D[F];k[I]===I&&R<w[P]&&!a(S,I,P)&&(k[P]=I,k[I]=T[I]=T[P],R=w[P])}}})}),{root:T,align:k}}function l(v,_,S,E,T){let k={},w=u(v,_,S,T),A=T?"borderLeft":"borderRight";function R(j,F){let z=w.nodes(),P=z.pop(),L={};for(;P;)L[P]?j(P):(L[P]=!0,z.push(P),z=z.concat(F(P))),P=z.pop()}function I(j){k[j]=w.inEdges(j).reduce((F,z)=>Math.max(F,k[z.v]+w.edge(z)),0)}function D(j){let F=w.outEdges(j).reduce((P,L)=>Math.min(P,k[L.w]-w.edge(L)),Number.POSITIVE_INFINITY),z=v.node(j);F!==Number.POSITIVE_INFINITY&&z.borderType!==A&&(k[j]=Math.max(k[j],F))}return R(I,w.predecessors.bind(w)),R(D,w.successors.bind(w)),Object.keys(E).forEach(j=>k[j]=k[S[j]]),k}function u(v,_,S,E){let T=new e,k=v.graph(),w=g(k.nodesep,k.edgesep,E);return _.forEach(A=>{let R;A.forEach(I=>{let D=S[I];if(T.setNode(D),R){var j=S[R],F=T.edge(j,D);T.setEdge(j,D,Math.max(w(v,I,R),F||0))}R=I})}),T}function d(v,_){return Object.values(_).reduce((S,E)=>{let T=Number.NEGATIVE_INFINITY,k=Number.POSITIVE_INFINITY;Object.entries(E).forEach(([A,R])=>{let I=y(v,A)/2;T=Math.max(R+I,T),k=Math.min(R-I,k)});const w=T-k;return w<S[0]&&(S=[w,E]),S},[Number.POSITIVE_INFINITY,null])[1]}function f(v,_){let S=Object.values(_),E=t.applyWithChunking(Math.min,S),T=t.applyWithChunking(Math.max,S);["u","d"].forEach(k=>{["l","r"].forEach(w=>{let A=k+w,R=v[A];if(R===_)return;let I=Object.values(R),D=E-t.applyWithChunking(Math.min,I);w!=="l"&&(D=T-t.applyWithChunking(Math.max,I)),D&&(v[A]=t.mapValues(R,j=>j+D))})})}function h(v,_){return t.mapValues(v.ul,(S,E)=>{if(_)return v[_.toLowerCase()][E];{let T=Object.values(v).map(k=>k[E]).sort((k,w)=>k-w);return(T[1]+T[2])/2}})}function m(v){let _=t.buildLayerMatrix(v),S=Object.assign(n(v,_),r(v,_)),E={},T;["u","d"].forEach(w=>{T=w==="u"?_:Object.values(_).reverse(),["l","r"].forEach(A=>{A==="r"&&(T=T.map(j=>Object.values(j).reverse()));let R=(w==="u"?v.predecessors:v.successors).bind(v),I=o(v,T,S,R),D=l(v,T,I.root,I.align,A==="r");A==="r"&&(D=t.mapValues(D,j=>-j)),E[w+A]=D})});let k=d(v,E);return f(E,k),h(E,v.graph().align)}function g(v,_,S){return(E,T,k)=>{let w=E.node(T),A=E.node(k),R=0,I;if(R+=w.width/2,Object.hasOwn(w,"labelpos"))switch(w.labelpos.toLowerCase()){case"l":I=-w.width/2;break;case"r":I=w.width/2;break}if(I&&(R+=S?I:-I),I=0,R+=(w.dummy?_:v)/2,R+=(A.dummy?_:v)/2,R+=A.width/2,Object.hasOwn(A,"labelpos"))switch(A.labelpos.toLowerCase()){case"l":I=A.width/2;break;case"r":I=-A.width/2;break}return I&&(R+=S?I:-I),I=0,R}}function y(v,_){return v.node(_).width}return dM}var fM,gde;function rAt(){if(gde)return fM;gde=1;let e=ea(),t=nAt().positionX;fM=n;function n(i){i=e.asNonCompoundGraph(i),r(i),Object.entries(t(i)).forEach(([s,a])=>i.node(s).x=a)}function r(i){let s=e.buildLayerMatrix(i),a=i.graph().ranksep,o=0;s.forEach(l=>{const u=l.reduce((d,f)=>{const h=i.node(f).height;return d>h?d:h},0);l.forEach(d=>i.node(d).y=o+u/2),o+=u+a})}return fM}var hM,bde;function iAt(){if(bde)return hM;bde=1;let e=BTt(),t=$Tt(),n=UTt(),r=ea().normalizeRanks,i=HTt(),s=ea().removeEmptyRanks,a=VTt(),o=WTt(),l=qTt(),u=tAt(),d=rAt(),f=ea(),h=vd().Graph;hM=m;function m(U,J){let te=J&&J.debugTiming?f.time:f.notime;te("layout",()=>{let ee=te(" buildLayoutGraph",()=>R(U));te(" runLayout",()=>g(ee,te,J)),te(" updateInputGraph",()=>y(U,ee))})}function g(U,J,te){J(" makeSpaceForEdgeLabels",()=>I(U)),J(" removeSelfEdges",()=>W(U)),J(" acyclic",()=>e.run(U)),J(" nestingGraph.run",()=>a.run(U)),J(" rank",()=>n(f.asNonCompoundGraph(U))),J(" injectEdgeLabelProxies",()=>D(U)),J(" removeEmptyRanks",()=>s(U)),J(" nestingGraph.cleanup",()=>a.cleanup(U)),J(" normalizeRanks",()=>r(U)),J(" assignRankMinMax",()=>j(U)),J(" removeEdgeLabelProxies",()=>F(U)),J(" normalize.run",()=>t.run(U)),J(" parentDummyChains",()=>i(U)),J(" addBorderSegments",()=>o(U)),J(" order",()=>u(U,te)),J(" insertSelfEdges",()=>Y(U)),J(" adjustCoordinateSystem",()=>l.adjust(U)),J(" position",()=>d(U)),J(" positionSelfEdges",()=>q(U)),J(" removeBorderNodes",()=>$(U)),J(" normalize.undo",()=>t.undo(U)),J(" fixupEdgeLabelCoords",()=>L(U)),J(" undoCoordinateSystem",()=>l.undo(U)),J(" translateGraph",()=>z(U)),J(" assignNodeIntersects",()=>P(U)),J(" reversePoints",()=>M(U)),J(" acyclic.undo",()=>e.undo(U))}function y(U,J){U.nodes().forEach(te=>{let ee=U.node(te),oe=J.node(te);ee&&(ee.x=oe.x,ee.y=oe.y,ee.rank=oe.rank,J.children(te).length&&(ee.width=oe.width,ee.height=oe.height))}),U.edges().forEach(te=>{let ee=U.edge(te),oe=J.edge(te);ee.points=oe.points,Object.hasOwn(oe,"x")&&(ee.x=oe.x,ee.y=oe.y)}),U.graph().width=J.graph().width,U.graph().height=J.graph().height}let v=["nodesep","edgesep","ranksep","marginx","marginy"],_={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},S=["acyclicer","ranker","rankdir","align"],E=["width","height","rank"],T={width:0,height:0},k=["minlen","weight","width","height","labeloffset"],w={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},A=["labelpos"];function R(U){let J=new h({multigraph:!0,compound:!0}),te=X(U.graph());return J.setGraph(Object.assign({},_,K(te,v),f.pick(te,S))),U.nodes().forEach(ee=>{let oe=X(U.node(ee));const ae=K(oe,E);Object.keys(T).forEach(se=>{ae[se]===void 0&&(ae[se]=T[se])}),J.setNode(ee,ae),J.setParent(ee,U.parent(ee))}),U.edges().forEach(ee=>{let oe=X(U.edge(ee));J.setEdge(ee,Object.assign({},w,K(oe,k),f.pick(oe,A)))}),J}function I(U){let J=U.graph();J.ranksep/=2,U.edges().forEach(te=>{let ee=U.edge(te);ee.minlen*=2,ee.labelpos.toLowerCase()!=="c"&&(J.rankdir==="TB"||J.rankdir==="BT"?ee.width+=ee.labeloffset:ee.height+=ee.labeloffset)})}function D(U){U.edges().forEach(J=>{let te=U.edge(J);if(te.width&&te.height){let ee=U.node(J.v),ae={rank:(U.node(J.w).rank-ee.rank)/2+ee.rank,e:J};f.addDummyNode(U,"edge-proxy",ae,"_ep")}})}function j(U){let J=0;U.nodes().forEach(te=>{let ee=U.node(te);ee.borderTop&&(ee.minRank=U.node(ee.borderTop).rank,ee.maxRank=U.node(ee.borderBottom).rank,J=Math.max(J,ee.maxRank))}),U.graph().maxRank=J}function F(U){U.nodes().forEach(J=>{let te=U.node(J);te.dummy==="edge-proxy"&&(U.edge(te.e).labelRank=te.rank,U.removeNode(J))})}function z(U){let J=Number.POSITIVE_INFINITY,te=0,ee=Number.POSITIVE_INFINITY,oe=0,ae=U.graph(),se=ae.marginx||0,ue=ae.marginy||0;function de(ce){let Ee=ce.x,Ie=ce.y,fe=ce.width,be=ce.height;J=Math.min(J,Ee-fe/2),te=Math.max(te,Ee+fe/2),ee=Math.min(ee,Ie-be/2),oe=Math.max(oe,Ie+be/2)}U.nodes().forEach(ce=>de(U.node(ce))),U.edges().forEach(ce=>{let Ee=U.edge(ce);Object.hasOwn(Ee,"x")&&de(Ee)}),J-=se,ee-=ue,U.nodes().forEach(ce=>{let Ee=U.node(ce);Ee.x-=J,Ee.y-=ee}),U.edges().forEach(ce=>{let Ee=U.edge(ce);Ee.points.forEach(Ie=>{Ie.x-=J,Ie.y-=ee}),Object.hasOwn(Ee,"x")&&(Ee.x-=J),Object.hasOwn(Ee,"y")&&(Ee.y-=ee)}),ae.width=te-J+se,ae.height=oe-ee+ue}function P(U){U.edges().forEach(J=>{let te=U.edge(J),ee=U.node(J.v),oe=U.node(J.w),ae,se;te.points?(ae=te.points[0],se=te.points[te.points.length-1]):(te.points=[],ae=oe,se=ee),te.points.unshift(f.intersectRect(ee,ae)),te.points.push(f.intersectRect(oe,se))})}function L(U){U.edges().forEach(J=>{let te=U.edge(J);if(Object.hasOwn(te,"x"))switch((te.labelpos==="l"||te.labelpos==="r")&&(te.width-=te.labeloffset),te.labelpos){case"l":te.x-=te.width/2+te.labeloffset;break;case"r":te.x+=te.width/2+te.labeloffset;break}})}function M(U){U.edges().forEach(J=>{let te=U.edge(J);te.reversed&&te.points.reverse()})}function $(U){U.nodes().forEach(J=>{if(U.children(J).length){let te=U.node(J),ee=U.node(te.borderTop),oe=U.node(te.borderBottom),ae=U.node(te.borderLeft[te.borderLeft.length-1]),se=U.node(te.borderRight[te.borderRight.length-1]);te.width=Math.abs(se.x-ae.x),te.height=Math.abs(oe.y-ee.y),te.x=ae.x+te.width/2,te.y=ee.y+te.height/2}}),U.nodes().forEach(J=>{U.node(J).dummy==="border"&&U.removeNode(J)})}function W(U){U.edges().forEach(J=>{if(J.v===J.w){var te=U.node(J.v);te.selfEdges||(te.selfEdges=[]),te.selfEdges.push({e:J,label:U.edge(J)}),U.removeEdge(J)}})}function Y(U){var J=f.buildLayerMatrix(U);J.forEach(te=>{var ee=0;te.forEach((oe,ae)=>{var se=U.node(oe);se.order=ae+ee,(se.selfEdges||[]).forEach(ue=>{f.addDummyNode(U,"selfedge",{width:ue.label.width,height:ue.label.height,rank:se.rank,order:ae+ ++ee,e:ue.e,label:ue.label},"_se")}),delete se.selfEdges})})}function q(U){U.nodes().forEach(J=>{var te=U.node(J);if(te.dummy==="selfedge"){var ee=U.node(te.e.v),oe=ee.x+ee.width/2,ae=ee.y,se=te.x-oe,ue=ee.height/2;U.setEdge(te.e,te.label),U.removeNode(J),te.label.points=[{x:oe+2*se/3,y:ae-ue},{x:oe+5*se/6,y:ae-ue},{x:oe+se,y:ae},{x:oe+5*se/6,y:ae+ue},{x:oe+2*se/3,y:ae+ue}],te.label.x=te.x,te.label.y=te.y}})}function K(U,J){return f.mapValues(f.pick(U,J),Number)}function X(U){var J={};return U&&Object.entries(U).forEach(([te,ee])=>{typeof te=="string"&&(te=te.toLowerCase()),J[te]=ee}),J}return hM}var pM,yde;function sAt(){if(yde)return pM;yde=1;let e=ea(),t=vd().Graph;pM={debugOrdering:n};function n(r){let i=e.buildLayerMatrix(r),s=new t({compound:!0,multigraph:!0}).setGraph({});return r.nodes().forEach(a=>{s.setNode(a,{label:a}),s.setParent(a,"layer"+r.node(a).rank)}),r.edges().forEach(a=>s.setEdge(a.v,a.w,{},a.name)),i.forEach((a,o)=>{let l="layer"+o;s.setNode(l,{rank:"same"}),a.reduce((u,d)=>(s.setEdge(u,d,{style:"invis"}),d))}),s}return pM}var mM,vde;function aAt(){return vde||(vde=1,mM="1.1.8"),mM}var gM,xde;function oAt(){return xde||(xde=1,gM={graphlib:vd(),layout:iAt(),debug:sAt(),util:{time:ea().time,notime:ea().notime},version:aAt()}),gM}var lAt=oAt();const _de=Kn(lAt),JOe={TO_DO:{bg:"#f3f4f6",border:"#6b7280",text:"#374151"},IN_PROGRESS:{bg:"#e5e7eb",border:"#8d909b",text:"#374151"},IN_REVIEW:{bg:"#fef3c7",border:"#e08d3c",text:"#92400e"},DONE:{bg:"#d1fae5",border:"#0d5c63",text:"#065f46"},CANCELED:{bg:"#fee2e2",border:"#dd403a",text:"#991b1b"}};function cAt({data:e}){const{task:t,projectName:n,isBlocked:r,direction:i}=e,s=JOe[t.status],a=g5(t.dueDate,t.status),o=mNe(t.dueDate,t.status),l=i==="LR"?kn.Left:kn.Top,u=i==="LR"?kn.Right:kn.Bottom;return c.jsxs("div",{className:"rounded-lg shadow-md px-3 py-2 min-w-[180px] max-w-[240px] cursor-pointer transition-shadow hover:shadow-lg",style:{backgroundColor:s.bg,borderWidth:2,borderStyle:"solid",borderColor:a?"#dd403a":s.border,opacity:r?.7:1},children:[c.jsx(Rx,{type:"target",position:l,className:"!bg-gray-400 !w-2 !h-2"}),c.jsxs("div",{className:"flex flex-col gap-1",children:[n&&c.jsx("div",{className:"text-[10px] text-gray-500 font-medium truncate",children:n}),c.jsx("div",{className:"font-medium text-sm leading-tight line-clamp-2",style:{color:s.text},children:t.title}),c.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{backgroundColor:s.border+"20",color:s.border},children:t.status.replace("_"," ")}),r&&c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium bg-red-100 text-red-700",children:"BLOCKED"}),a&&c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium bg-red-100 text-red-700",children:"OVERDUE"})]}),t.tags.length>0&&c.jsxs("div",{className:"flex gap-1 flex-wrap mt-0.5",children:[t.tags.slice(0,3).map(d=>c.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-gray-200 text-gray-600",children:d},d)),t.tags.length>3&&c.jsxs("span",{className:"text-[9px] px-1 py-0.5 rounded bg-gray-200 text-gray-600",children:["+",t.tags.length-3]})]}),t.dueDate&&c.jsxs("div",{className:"text-[10px] mt-0.5",style:{color:a?"#dd403a":o?"#d97706":"#6b7280"},children:["Due: ",Js(t.dueDate).toLocaleDateString()]})]}),c.jsx(Rx,{type:"source",position:u,className:"!bg-gray-400 !w-2 !h-2"})]})}const uAt={task:cAt};function dAt(e,t,n="TB"){const r=new _de.graphlib.Graph;r.setDefaultEdgeLabel(()=>({}));const i=200,s=80;return r.setGraph({rankdir:n,nodesep:50,ranksep:80,marginx:20,marginy:20}),e.forEach(o=>{r.setNode(o.id,{width:i,height:s})}),t.forEach(o=>{r.setEdge(o.source,o.target)}),_de.layout(r),{nodes:e.map(o=>{const l=r.node(o.id);return{...o,position:{x:l.x-i/2,y:l.y-s/2}}}),edges:t}}const Sde=768;function fAt({className:e,projectFilter:t,tagsFilter:n,taskTypesFilter:r,prioritiesFilter:i}){const s=Ni(),{data:a,isLoading:o}=Awe(),{data:l=[]}=cl(),{data:u=[]}=Mc(),[d,f]=x.useState(null),[h,m]=x.useState(!1),g=x.useMemo(()=>d?l.find(q=>q.id===d)??null:null,[d,l]),y=x.useMemo(()=>new Map(l.map(q=>[q.id,q])),[l]),{projectRepoIds:v,projectRepoPaths:_}=x.useMemo(()=>{const q=new Set,K=new Set;for(const X of u)for(const U of X.repositories)q.add(U.id),K.add(U.path);return{projectRepoIds:q,projectRepoPaths:K}},[u]),{selectedProjectRepoIds:S,selectedProjectRepoPaths:E}=x.useMemo(()=>{if(!t||t==="inbox")return{selectedProjectRepoIds:new Set,selectedProjectRepoPaths:new Set};const q=u.find(K=>K.id===t);return q?{selectedProjectRepoIds:new Set(q.repositories.map(K=>K.id)),selectedProjectRepoPaths:new Set(q.repositories.map(K=>K.path))}:{selectedProjectRepoIds:new Set,selectedProjectRepoPaths:new Set}},[t,u]),[T,k]=x.useState(()=>typeof window<"u"?window.innerWidth<Sde:!1);x.useEffect(()=>{const q=()=>{k(window.innerWidth<Sde)};return window.addEventListener("resize",q),()=>window.removeEventListener("resize",q)},[]);const w=T?"TB":"LR",A=x.useMemo(()=>{if(!a)return new Set;const q=new Set,K=new Set(["DONE","CANCELED"]);for(const X of a.edges){const U=a.nodes.find(J=>J.id===X.source);U&&!K.has(U.status)&&q.add(X.target)}return q},[a]),R=x.useMemo(()=>{if(!a)return new Set;const q=new Set,K=new Set(["DONE","CANCELED"]);for(const X of a.edges){const U=a.nodes.find(J=>J.id===X.source);U&&!K.has(U.status)&&q.add(X.source)}return q},[a]),I=x.useCallback(q=>{const K=y.get(q.id);return K?t==="inbox"?!K.projectId&&(!K.repositoryId||!v.has(K.repositoryId))&&(!K.repoPath||!_.has(K.repoPath)):t?K.projectId===t||!!K.repositoryId&&S.has(K.repositoryId)||!!K.repoPath&&E.has(K.repoPath):!0:!0},[t,v,_,S,E,y]),D=x.useCallback(q=>!n||n.length===0?!0:q.tags.some(K=>n.includes(K)),[n]),{initialNodes:j,initialEdges:F}=x.useMemo(()=>{if(!a)return{initialNodes:[],initialEdges:[]};const q=de=>{if(!r||r.length===0)return!0;const ce=y.get(de.id);return ce?r.includes(TC(ce)):!0},K=de=>{if(!i||i.length===0)return!0;const ce=y.get(de.id);return ce?i.includes(ce.priority??"medium"):!0},X=new Set;for(const de of a.nodes)I(de)&&D(de)&&q(de)&&K(de)&&X.add(de.id);const U=new Set;for(const de of a.edges){const ce=X.has(de.source),Ee=X.has(de.target);(ce||Ee)&&(U.add(de.source),U.add(de.target))}if(!(t||n&&n.length>0||r&&r.length>0||i&&i.length>0))for(const de of a.edges)U.add(de.source),U.add(de.target);const te=a.nodes.filter(de=>U.has(de.id)),ee=a.edges.filter(de=>U.has(de.source)&&U.has(de.target)),oe=new Map(u.map(de=>[de.id,de.name])),ae=te.map(de=>({id:de.id,type:"task",position:{x:0,y:0},data:{task:de,projectName:de.projectId?oe.get(de.projectId)??null:null,isBlocked:A.has(de.id),isBlocking:R.has(de.id),direction:w}})),se=ee.map(de=>({id:de.id,source:de.source,target:de.target,type:"smoothstep",animated:!0,markerEnd:{type:c2.ArrowClosed,width:15,height:15,color:"#6b7280"},style:{stroke:"#6b7280",strokeWidth:2}})),ue=dAt(ae,se,w);return{initialNodes:ue.nodes,initialEdges:ue.edges}},[a,A,R,w,I,D,t,n,r,i,y,u]),[z,P,L]=eTt(j),[M,$,W]=tTt(F);x.useEffect(()=>{(j.length>0||F.length>0)&&(P(j),$(F))},[j,F,P,$]);const Y=x.useCallback((q,K)=>{const X=y.get(K.id);X&&(X.worktreePath?s({to:"/tasks/$taskId",params:{taskId:K.id}}):(f(X.id),m(!0)))},[s,y]);return o?c.jsx("div",{className:`flex items-center justify-center h-full ${e}`,children:c.jsx("span",{className:"text-muted-foreground",children:"Loading dependency graph..."})}):!a||a.nodes.length===0?c.jsx("div",{className:`flex items-center justify-center h-full ${e}`,children:c.jsx("span",{className:"text-muted-foreground",children:"No tasks found"})}):a.edges.length===0?c.jsxs("div",{className:`flex flex-col items-center justify-center h-full gap-2 ${e}`,children:[c.jsx("span",{className:"text-muted-foreground",children:"No dependencies defined"}),c.jsx("span",{className:"text-sm text-muted-foreground/70",children:"Add dependencies between tasks to see the graph"})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:`h-full relative ${e}`,children:c.jsxs(zOe,{nodes:z,edges:M,onNodesChange:L,onEdgesChange:W,onNodeClick:Y,nodeTypes:uAt,fitView:!0,fitViewOptions:{padding:.2},minZoom:.1,maxZoom:2,defaultEdgeOptions:{type:"smoothstep"},proOptions:{hideAttribution:!0},children:[c.jsx(ETt,{color:"#e5e7eb",gap:20,size:1}),c.jsx(yTt,{showInteractive:!1}),c.jsx(dTt,{nodeColor:q=>{const K=q.data;return JOe[K.task.status].border},maskColor:"rgba(0, 0, 0, 0.1)",className:"!bg-background/80"})]})}),g&&!g.worktreePath&&c.jsx(b5,{task:g,open:h,onOpenChange:q=>{m(q),q||f(null)}})]})}function eRe({delay:e=0,...t}){return c.jsx(SWe,{"data-slot":"tooltip-provider",delay:e,...t})}function wh({...e}){return c.jsx(eRe,{children:c.jsx(dWe,{"data-slot":"tooltip",...e})})}function Eh({...e}){return c.jsx(mWe,{"data-slot":"tooltip-trigger",...e})}function Ch({className:e,side:t="top",sideOffset:n=4,align:r="center",alignOffset:i=0,children:s,...a}){return c.jsx(bWe,{children:c.jsx(yWe,{align:r,alignOffset:i,side:t,sideOffset:n,className:"isolate z-50",children:c.jsxs(xWe,{"data-slot":"tooltip-content",className:Ae("data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 rounded-md px-3 py-1.5 text-xs **:data-[slot=kbd]:rounded-md bg-foreground text-background z-50 w-fit max-w-xs origin-(--transform-origin)",e),...a,children:[s,c.jsx(_We,{className:"size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground z-50 data-[side=bottom]:top-1 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5"})]})})})}function tRe({value:e,onChange:t}){const{t:n}=Ot("tasks"),[r,i]=x.useState(!1),[s,a]=x.useState(""),o=x.useRef(null),{data:l=[]}=zWe(),u=l.filter(m=>m.name.toLowerCase().includes(s.toLowerCase()));x.useEffect(()=>{r&&setTimeout(()=>o.current?.focus(),0)},[r]);const d=m=>{e.includes(m)?t(e.filter(g=>g!==m)):t([...e,m])},f=(m,g)=>{g.stopPropagation(),t(e.filter(y=>y!==m))},h=m=>{m.stopPropagation(),t([])};return c.jsxs(O1,{open:r,onOpenChange:i,children:[c.jsxs(R1,{render:c.jsx(_e,{variant:"outline",size:"sm",className:Ae("shrink-0 gap-1.5 h-7 px-2",e.length>0&&"pr-1")}),children:[c.jsx(Z,{icon:yze,size:12,strokeWidth:2,className:"text-muted-foreground"}),e.length===0?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-xs",children:n("allTags")}),c.jsx(Z,{icon:Ts,size:12,strokeWidth:2,className:"text-muted-foreground"})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[e.slice(0,2).map(m=>c.jsxs(ir,{variant:"secondary",className:"h-5 px-1.5 text-[10px] gap-0.5",children:[m,c.jsx("button",{onClick:g=>f(m,g),className:"hover:text-destructive transition-colors",children:c.jsx(Z,{icon:Tn,size:10})})]},m)),e.length>2&&c.jsxs(ir,{variant:"secondary",className:"h-5 px-1.5 text-[10px]",children:["+",e.length-2]})]}),c.jsx("button",{onClick:h,className:"ml-0.5 p-0.5 hover:text-destructive transition-colors",children:c.jsx(Z,{icon:Tn,size:12})})]})]}),c.jsxs(I1,{align:"start",className:"w-56 p-0",children:[c.jsx("div",{className:"p-2 border-b",children:c.jsx(At,{ref:o,value:s,onChange:m=>a(m.target.value),placeholder:n("searchTags"),className:"h-7 text-xs"})}),c.jsx("div",{className:"max-h-48 overflow-y-auto py-1",children:u.length===0?c.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground text-center",children:n("noTagsFound")}):u.map(m=>{const g=e.includes(m.name);return c.jsxs("button",{className:Ae("w-full px-3 py-1.5 text-left text-xs hover:bg-accent flex items-center gap-2",g&&"bg-accent/50"),onClick:()=>d(m.name),children:[c.jsx(ni,{checked:g,className:"pointer-events-none"}),c.jsx("span",{className:"flex-1 truncate",children:m.name}),c.jsx("span",{className:"text-muted-foreground text-[10px]",children:m.taskCount})]},m.id)})}),e.length>0&&c.jsx("div",{className:"p-2 border-t",children:c.jsx(_e,{variant:"ghost",size:"sm",className:"w-full h-7 text-xs",onClick:()=>{t([]),i(!1)},children:n("clearTags")})})]})]})}const hAt=["worktree","scratch","manual"];function pAt({value:e,onChange:t}){const{t:n}=Ot("tasks"),[r,i]=x.useState(!1),{data:s=[]}=cl(),a={worktree:0,scratch:0,manual:0};for(const d of s)a[TC(d)]++;const o=d=>{e.includes(d)?t(e.filter(f=>f!==d)):t([...e,d])},l=(d,f)=>{f.stopPropagation(),t(e.filter(h=>h!==d))},u=d=>{d.stopPropagation(),t([])};return c.jsxs(O1,{open:r,onOpenChange:i,children:[c.jsxs(R1,{render:c.jsx(_e,{variant:"outline",size:"sm",className:Ae("shrink-0 gap-1.5 h-7 px-2",e.length>0&&"pr-1")}),children:[c.jsx(Z,{icon:H_e,size:12,strokeWidth:2,className:"text-muted-foreground"}),e.length===0?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-xs",children:n("typeFilter.label")}),c.jsx(Z,{icon:Ts,size:12,strokeWidth:2,className:"text-muted-foreground"})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex items-center gap-1",children:e.map(d=>c.jsxs(ir,{variant:"secondary",className:"h-5 px-1.5 text-[10px] gap-0.5",children:[c.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full",style:{backgroundColor:`var(--type-${d})`}}),n(`typeFilter.types.${d}`),c.jsx("button",{onClick:f=>l(d,f),className:"hover:text-destructive transition-colors",children:c.jsx(Z,{icon:Tn,size:10})})]},d))}),c.jsx("button",{onClick:u,className:"ml-0.5 p-0.5 hover:text-destructive transition-colors",children:c.jsx(Z,{icon:Tn,size:12})})]})]}),c.jsxs(I1,{align:"start",className:"w-44 p-0",children:[c.jsx("div",{className:"py-1",children:hAt.map(d=>{const f=e.includes(d);return c.jsxs("button",{className:Ae("w-full px-3 py-1.5 text-left text-xs hover:bg-accent flex items-center gap-2",f&&"bg-accent/50"),onClick:()=>o(d),children:[c.jsx(ni,{checked:f,className:"pointer-events-none"}),c.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:`var(--type-${d})`}}),c.jsx("span",{className:"flex-1",children:n(`typeFilter.types.${d}`)}),c.jsx("span",{className:"text-muted-foreground text-[10px]",children:a[d]})]},d)})}),e.length>0&&c.jsx("div",{className:"p-2 border-t",children:c.jsx(_e,{variant:"ghost",size:"sm",className:"w-full h-7 text-xs",onClick:()=>{t([]),i(!1)},children:n("typeFilter.clear")})})]})]})}const mAt=["high","medium","low"],bM={high:{icon:wd,className:"text-destructive"},medium:{icon:Ty,className:"text-primary"},low:{icon:Ts,className:"text-muted-foreground"}};function gAt({value:e,onChange:t}){const{t:n}=Ot("tasks"),[r,i]=x.useState(!1),{data:s=[]}=cl(),a={high:0,medium:0,low:0};for(const d of s)a[d.priority??"medium"]++;const o=d=>{e.includes(d)?t(e.filter(f=>f!==d)):t([...e,d])},l=(d,f)=>{f.stopPropagation(),t(e.filter(h=>h!==d))},u=d=>{d.stopPropagation(),t([])};return c.jsxs(O1,{open:r,onOpenChange:i,children:[c.jsxs(R1,{render:c.jsx(_e,{variant:"outline",size:"sm",className:Ae("shrink-0 gap-1.5 h-7 px-2",e.length>0&&"pr-1")}),children:[c.jsx(Z,{icon:Ty,size:12,strokeWidth:2,className:"text-muted-foreground"}),e.length===0?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-xs",children:n("priorityFilter.label")}),c.jsx(Z,{icon:Ts,size:12,strokeWidth:2,className:"text-muted-foreground"})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex items-center gap-1",children:e.map(d=>c.jsxs(ir,{variant:"secondary",className:"h-5 px-1.5 text-[10px] gap-0.5",children:[c.jsx(Z,{icon:bM[d].icon,size:10,strokeWidth:2,className:bM[d].className}),n(`priorityFilter.priorities.${d}`),c.jsx("button",{onClick:f=>l(d,f),className:"hover:text-destructive transition-colors",children:c.jsx(Z,{icon:Tn,size:10})})]},d))}),c.jsx("button",{onClick:u,className:"ml-0.5 p-0.5 hover:text-destructive transition-colors",children:c.jsx(Z,{icon:Tn,size:12})})]})]}),c.jsxs(I1,{align:"start",className:"w-44 p-0",children:[c.jsx("div",{className:"py-1",children:mAt.map(d=>{const f=e.includes(d),h=bM[d];return c.jsxs("button",{className:Ae("w-full px-3 py-1.5 text-left text-xs hover:bg-accent flex items-center gap-2",f&&"bg-accent/50"),onClick:()=>o(d),children:[c.jsx(ni,{checked:f,className:"pointer-events-none"}),c.jsx(Z,{icon:h.icon,size:14,strokeWidth:2,className:h.className}),c.jsx("span",{className:"flex-1",children:n(`priorityFilter.priorities.${d}`)}),c.jsx("span",{className:"text-muted-foreground text-[10px]",children:a[d]})]},d)})}),e.length>0&&c.jsx("div",{className:"p-2 border-t",children:c.jsx(_e,{variant:"ghost",size:"sm",className:"w-full h-7 text-xs",onClick:()=>{t([]),i(!1)},children:n("priorityFilter.clear")})})]})]})}const nRe=xa("/tasks/")({component:bAt,validateSearch:e=>({project:typeof e.project=="string"?e.project:void 0,tags:typeof e.tags=="string"?e.tags:void 0,types:typeof e.types=="string"?e.types:void 0,priorities:typeof e.priorities=="string"?e.priorities:void 0,view:e.view==="graph"?"graph":void 0,task:typeof e.task=="string"?e.task:void 0})});function bAt(){const{t:e}=Ot("tasks"),{project:t,tags:n,types:r,priorities:i,view:s="kanban",task:a}=nRe.useSearch(),o=Ni(),[l,u]=x.useState(""),[d,f]=x.useState(!1),h=x.useMemo(()=>n?n.split(",").filter(Boolean):[],[n]),m=x.useMemo(()=>r?r.split(",").filter(Boolean):[],[r]),g=x.useMemo(()=>i?i.split(",").filter(Boolean):[],[i]),y=x.useCallback(T=>{o({to:"/tasks",search:k=>({...k,project:T||void 0}),replace:!0})},[o]),v=x.useCallback(T=>{o({to:"/tasks",search:k=>({...k,tags:T.length>0?T.join(","):void 0}),replace:!0})},[o]),_=x.useCallback(T=>{o({to:"/tasks",search:k=>({...k,types:T.length>0?T.join(","):void 0}),replace:!0})},[o]),S=x.useCallback(T=>{o({to:"/tasks",search:k=>({...k,priorities:T.length>0?T.join(","):void 0}),replace:!0})},[o]),E=x.useCallback(T=>{o({to:"/tasks",search:k=>({...k,view:T==="kanban"?void 0:T}),replace:!0})},[o]);return c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsxs("div",{className:"film-grain relative flex shrink-0 items-center gap-2 border-b border-border px-4 py-2",style:{background:"var(--gradient-header)"},children:[s==="kanban"&&c.jsxs("div",{className:"relative shrink-0",children:[c.jsx(Z,{icon:cp,size:12,strokeWidth:2,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground"}),c.jsx(At,{value:l,onChange:T=>u(T.target.value),placeholder:e("searchPlaceholder"),className:"h-7 w-48 pl-7 text-xs"})]}),c.jsxs("div",{className:"hidden sm:contents",children:[c.jsx(qQ,{value:t??null,onChange:y}),c.jsx(tRe,{value:h,onChange:v}),c.jsx(pAt,{value:m,onChange:_}),c.jsx(gAt,{value:g,onChange:S}),c.jsxs(wh,{children:[c.jsx(Eh,{children:c.jsx(RWe,{size:"sm",variant:"outline",pressed:d,onPressedChange:f,className:"h-7 w-7 p-0 shrink-0","aria-label":e("typeFilter.showLabels"),children:c.jsx(Z,{icon:H_e,size:14,strokeWidth:2})})}),c.jsx(Ch,{children:e("typeFilter.showLabels")})]})]}),c.jsx("div",{className:"flex-1"}),c.jsxs(AE,{value:[s],onValueChange:T=>{const k=Array.isArray(T)?T[0]:T;k&&E(k)},size:"sm",variant:"outline",children:[c.jsx(Ih,{value:"kanban","aria-label":"Kanban view",children:c.jsx(Z,{icon:Dw,size:14,strokeWidth:2})}),c.jsx(Ih,{value:"graph","aria-label":"Dependency graph",children:c.jsx(Z,{icon:tze,size:14,strokeWidth:2})})]})]}),c.jsxs("div",{className:"flex-1 overflow-hidden",children:[s==="kanban"&&c.jsx(ESt,{projectFilter:t??null,searchQuery:l,tagsFilter:h,taskTypesFilter:m,prioritiesFilter:g,showTypeLabels:d,selectedTaskId:a}),s==="graph"&&c.jsx(fAt,{projectFilter:t??null,tagsFilter:h,taskTypesFilter:m,prioritiesFilter:g})]})]})}function yAt(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e?.(i),n===!1||!i.defaultPrevented)return t?.(i)}}function vAt(e,t=[]){let n=[];function r(s,a){const o=x.createContext(a),l=n.length;n=[...n,a];const u=f=>{const{scope:h,children:m,...g}=f,y=h?.[e]?.[l]||o,v=x.useMemo(()=>g,Object.values(g));return c.jsx(y.Provider,{value:v,children:m})};u.displayName=s+"Provider";function d(f,h){const m=h?.[e]?.[l]||o,g=x.useContext(m);if(g)return g;if(a!==void 0)return a;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const i=()=>{const s=n.map(a=>x.createContext(a));return function(o){const l=o?.[e]||s;return x.useMemo(()=>({[`__scope${e}`]:{...o,[e]:l}}),[o,l])}};return i.scopeName=e,[r,xAt(i,...t)]}function xAt(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const a=r.reduce((o,{useScope:l,scopeName:u})=>{const f=l(s)[`__scope${u}`];return{...o,...f}},{});return x.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}var d2=globalThis?.document?x.useLayoutEffect:()=>{},_At=v3[" useInsertionEffect ".trim().toString()]||d2;function SAt({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[i,s,a]=wAt({defaultProp:t,onChange:n}),o=e!==void 0,l=o?e:i;{const d=x.useRef(e!==void 0);x.useEffect(()=>{const f=d.current;f!==o&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${o?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=o},[o,r])}const u=x.useCallback(d=>{if(o){const f=EAt(d)?d(e):d;f!==e&&a.current?.(f)}else s(d)},[o,e,s,a]);return[l,u]}function wAt({defaultProp:e,onChange:t}){const[n,r]=x.useState(e),i=x.useRef(n),s=x.useRef(t);return _At(()=>{s.current=t},[t]),x.useEffect(()=>{i.current!==n&&(s.current?.(n),i.current=n)},[n,i]),[n,r,s]}function EAt(e){return typeof e=="function"}function wde(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function rRe(...e){return t=>{let n=!1;const r=e.map(i=>{const s=wde(i,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let i=0;i<r.length;i++){const s=r[i];typeof s=="function"?s():wde(e[i],null)}}}}function iRe(...e){return x.useCallback(rRe(...e),e)}function CAt(e){const t=kAt(e),n=x.forwardRef((r,i)=>{const{children:s,...a}=r,o=x.Children.toArray(s),l=o.find(AAt);if(l){const u=l.props.children,d=o.map(f=>f===l?x.Children.count(u)>1?x.Children.only(null):x.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...a,ref:i,children:x.isValidElement(u)?x.cloneElement(u,void 0,d):null})}return c.jsx(t,{...a,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}function kAt(e){const t=x.forwardRef((n,r)=>{const{children:i,...s}=n;if(x.isValidElement(i)){const a=OAt(i),o=NAt(s,i.props);return i.type!==x.Fragment&&(o.ref=r?rRe(r,a):a),x.cloneElement(i,o)}return x.Children.count(i)>1?x.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var TAt=Symbol("radix.slottable");function AAt(e){return x.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===TAt}function NAt(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...o)=>{const l=s(...o);return i(...o),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function OAt(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var RAt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],pZ=RAt.reduce((e,t)=>{const n=CAt(`Primitive.${t}`),r=x.forwardRef((i,s)=>{const{asChild:a,...o}=i,l=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...o,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function IAt(e,t){return x.useReducer((n,r)=>t[n][r]??n,e)}var sRe=e=>{const{present:t,children:n}=e,r=DAt(t),i=typeof n=="function"?n({present:r.isPresent}):x.Children.only(n),s=iRe(r.ref,jAt(i));return typeof n=="function"||r.isPresent?x.cloneElement(i,{ref:s}):null};sRe.displayName="Presence";function DAt(e){const[t,n]=x.useState(),r=x.useRef(null),i=x.useRef(e),s=x.useRef("none"),a=e?"mounted":"unmounted",[o,l]=IAt(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return x.useEffect(()=>{const u=sN(r.current);s.current=o==="mounted"?u:"none"},[o]),d2(()=>{const u=r.current,d=i.current;if(d!==e){const h=s.current,m=sN(u);e?l("MOUNT"):m==="none"||u?.display==="none"?l("UNMOUNT"):l(d&&h!==m?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,l]),d2(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=m=>{const y=sN(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&y&&(l("ANIMATION_END"),!i.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},h=m=>{m.target===t&&(s.current=sN(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(o),ref:x.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function sN(e){return e?.animationName||"none"}function jAt(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var PAt=v3[" useId ".trim().toString()]||(()=>{}),LAt=0;function MAt(e){const[t,n]=x.useState(PAt());return d2(()=>{n(r=>r??String(LAt++))},[e]),e||(t?`radix-${t}`:"")}var C5="Collapsible",[FAt]=vAt(C5),[BAt,mZ]=FAt(C5),aRe=x.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:s,onOpenChange:a,...o}=e,[l,u]=SAt({prop:r,defaultProp:i??!1,onChange:a,caller:C5});return c.jsx(BAt,{scope:n,disabled:s,contentId:MAt(),open:l,onOpenToggle:x.useCallback(()=>u(d=>!d),[u]),children:c.jsx(pZ.div,{"data-state":bZ(l),"data-disabled":s?"":void 0,...o,ref:t})})});aRe.displayName=C5;var oRe="CollapsibleTrigger",lRe=x.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=mZ(oRe,n);return c.jsx(pZ.button,{type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":bZ(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled,...r,ref:t,onClick:yAt(e.onClick,i.onOpenToggle)})});lRe.displayName=oRe;var gZ="CollapsibleContent",cRe=x.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=mZ(gZ,e.__scopeCollapsible);return c.jsx(sRe,{present:n||i.open,children:({present:s})=>c.jsx($At,{...r,ref:t,present:s})})});cRe.displayName=gZ;var $At=x.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...s}=e,a=mZ(gZ,n),[o,l]=x.useState(r),u=x.useRef(null),d=iRe(t,u),f=x.useRef(0),h=f.current,m=x.useRef(0),g=m.current,y=a.open||o,v=x.useRef(y),_=x.useRef(void 0);return x.useEffect(()=>{const S=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(S)},[]),d2(()=>{const S=u.current;if(S){_.current=_.current||{transitionDuration:S.style.transitionDuration,animationName:S.style.animationName},S.style.transitionDuration="0s",S.style.animationName="none";const E=S.getBoundingClientRect();f.current=E.height,m.current=E.width,v.current||(S.style.transitionDuration=_.current.transitionDuration,S.style.animationName=_.current.animationName),l(r)}},[a.open,r]),c.jsx(pZ.div,{"data-state":bZ(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!y,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:y&&i})});function bZ(e){return e?"open":"closed"}var zAt=aRe;const ug=zAt,dg=lRe;function fg({className:e,...t}){return c.jsx(cRe,{className:Ae("overflow-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down",e),...t})}const fi="/api/messaging";function UAt(){return Jt({queryKey:["messaging","whatsapp"],queryFn:async()=>{const e=await fetch(`${fi}/whatsapp`);if(!e.ok)throw new Error("Failed to fetch WhatsApp status");return await e.json()},refetchInterval:5e3})}function HAt(){const e=It();return wt({mutationFn:async()=>{const t=await fetch(`${fi}/whatsapp/enable`,{method:"POST"});if(!t.ok)throw new Error("Failed to enable WhatsApp");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function VAt(){const e=It();return wt({mutationFn:async()=>{const t=await fetch(`${fi}/whatsapp/disable`,{method:"POST"});if(!t.ok)throw new Error("Failed to disable WhatsApp");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function WAt(){const e=It();return wt({mutationFn:async()=>{const t=await fetch(`${fi}/whatsapp/auth`,{method:"POST"});if(!t.ok)throw new Error("Failed to request WhatsApp auth");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging","whatsapp"]})}})}function qAt(){const e=It();return wt({mutationFn:async()=>{const t=await fetch(`${fi}/whatsapp/disconnect`,{method:"POST"});if(!t.ok)throw new Error("Failed to disconnect WhatsApp");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function GAt(){return Jt({queryKey:["messaging","whatsapp","sessions"],queryFn:async()=>{const e=await fetch(`${fi}/whatsapp/sessions`);if(!e.ok)throw new Error("Failed to fetch WhatsApp sessions");return(await e.json()).sessions}})}function KAt(){return Jt({queryKey:["messaging","discord"],queryFn:async()=>{const e=await fetch(`${fi}/discord`);if(!e.ok)throw new Error("Failed to fetch Discord status");return await e.json()},refetchInterval:5e3})}function YAt(){const e=It();return wt({mutationFn:async t=>{const n=await fetch(`${fi}/discord/configure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({botToken:t})});if(!n.ok){const r=await n.json();throw new Error(r.error||"Failed to configure Discord")}return await n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function XAt(){const e=It();return wt({mutationFn:async()=>{const t=await fetch(`${fi}/discord/enable`,{method:"POST"});if(!t.ok){const n=await t.json();throw new Error(n.error||"Failed to enable Discord")}return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function QAt(){const e=It();return wt({mutationFn:async()=>{const t=await fetch(`${fi}/discord/disable`,{method:"POST"});if(!t.ok)throw new Error("Failed to disable Discord");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function ZAt(){const e=It();return wt({mutationFn:async()=>{const t=await fetch(`${fi}/discord/disconnect`,{method:"POST"});if(!t.ok)throw new Error("Failed to disconnect Discord");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function JAt(){return Jt({queryKey:["messaging","discord","sessions"],queryFn:async()=>{const e=await fetch(`${fi}/discord/sessions`);if(!e.ok)throw new Error("Failed to fetch Discord sessions");return(await e.json()).sessions}})}function eNt(){return Jt({queryKey:["messaging","telegram"],queryFn:async()=>{const e=await fetch(`${fi}/telegram`);if(!e.ok)throw new Error("Failed to fetch Telegram status");return await e.json()},refetchInterval:5e3})}function tNt(){const e=It();return wt({mutationFn:async t=>{const n=await fetch(`${fi}/telegram/configure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({botToken:t})});if(!n.ok){const r=await n.json();throw new Error(r.error||"Failed to configure Telegram")}return await n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function nNt(){const e=It();return wt({mutationFn:async()=>{const t=await fetch(`${fi}/telegram/enable`,{method:"POST"});if(!t.ok){const n=await t.json();throw new Error(n.error||"Failed to enable Telegram")}return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function rNt(){const e=It();return wt({mutationFn:async()=>{const t=await fetch(`${fi}/telegram/disable`,{method:"POST"});if(!t.ok)throw new Error("Failed to disable Telegram");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function iNt(){const e=It();return wt({mutationFn:async()=>{const t=await fetch(`${fi}/telegram/disconnect`,{method:"POST"});if(!t.ok)throw new Error("Failed to disconnect Telegram");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function sNt(){return Jt({queryKey:["messaging","telegram","sessions"],queryFn:async()=>{const e=await fetch(`${fi}/telegram/sessions`);if(!e.ok)throw new Error("Failed to fetch Telegram sessions");return(await e.json()).sessions}})}function aNt(){return Jt({queryKey:["messaging","slack"],queryFn:async()=>{const e=await fetch(`${fi}/slack`);if(!e.ok)throw new Error("Failed to fetch Slack status");return await e.json()},refetchInterval:5e3})}function oNt(){const e=It();return wt({mutationFn:async t=>{const n=await fetch(`${fi}/slack/configure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.json();throw new Error(r.error||"Failed to configure Slack")}return await n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function lNt(){const e=It();return wt({mutationFn:async()=>{const t=await fetch(`${fi}/slack/enable`,{method:"POST"});if(!t.ok){const n=await t.json();throw new Error(n.error||"Failed to enable Slack")}return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function cNt(){const e=It();return wt({mutationFn:async()=>{const t=await fetch(`${fi}/slack/disable`,{method:"POST"});if(!t.ok)throw new Error("Failed to disable Slack");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function uNt(){const e=It();return wt({mutationFn:async()=>{const t=await fetch(`${fi}/slack/disconnect`,{method:"POST"});if(!t.ok)throw new Error("Failed to disconnect Slack");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function dNt(){return Jt({queryKey:["messaging","slack","sessions"],queryFn:async()=>{const e=await fetch(`${fi}/slack/sessions`);if(!e.ok)throw new Error("Failed to fetch Slack sessions");return(await e.json()).sessions}})}function fNt(){return Jt({queryKey:["messaging","email"],queryFn:async()=>{const e=await fetch(`${fi}/email`);if(!e.ok)throw new Error("Failed to fetch email status");return await e.json()},refetchInterval:5e3})}function hNt(){const e=It();return wt({mutationFn:async t=>{const n=await fetch(`${fi}/email/configure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.json();throw new Error(r.error||"Failed to configure email")}return await n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function pNt(){return wt({mutationFn:async e=>{const t=await fetch(`${fi}/email/test`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const n=await t.json();throw new Error(n.error||"Failed to test email credentials")}return await t.json()}})}function mNt(){const e=It();return wt({mutationFn:async()=>{const t=await fetch(`${fi}/email/enable`,{method:"POST"});if(!t.ok){const n=await t.json();throw new Error(n.error||"Failed to enable email")}return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function gNt(){const e=It();return wt({mutationFn:async()=>{const t=await fetch(`${fi}/email/disable`,{method:"POST"});if(!t.ok)throw new Error("Failed to disable email");return await t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["messaging"]})}})}function bNt({isLoading:e=!1}){const{data:t,refetch:n}=UAt(),{data:r}=GAt(),i=HAt(),s=VAt(),a=WAt(),o=qAt(),[l,u]=x.useState(null),d=t?.status==="connected",f=t?.status==="connecting",h=t?.status==="qr_pending",m=t?.enabled??!1,g=async T=>{try{if(T){await i.mutateAsync();const k=await a.mutateAsync();u(k.qrDataUrl)}else await s.mutateAsync(),u(null);n()}catch{rt.error(T?"Failed to enable WhatsApp":"Failed to disable WhatsApp")}},y=async()=>{try{const T=await a.mutateAsync();u(T.qrDataUrl)}catch{rt.error("Failed to generate QR code")}},v=async()=>{try{await o.mutateAsync(),u(null),rt.success("WhatsApp disconnected")}catch{rt.error("Failed to disconnect WhatsApp")}},_=()=>d?c.jsx(Z,{icon:hr,size:14,strokeWidth:2,className:"text-green-500"}):f||h?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin text-yellow-500"}):c.jsx(Z,{icon:Tn,size:14,strokeWidth:2,className:"text-muted-foreground"}),S=()=>d?t?.displayName?`Connected as ${t.displayName}`:"Connected":f?"Connecting...":h?"Scan QR code":"Disconnected",E=i.isPending||s.isPending||a.isPending||o.isPending;return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:"WhatsApp"}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Xr,{checked:m,onCheckedChange:g,disabled:e||E}),c.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[_(),c.jsx("span",{className:"text-muted-foreground",children:S()})]})]})]}),m&&(l||h)&&!d&&c.jsxs("div",{className:"ml-4 sm:ml-44",children:[c.jsx("div",{className:"rounded-lg border border-border bg-white p-4 inline-block",children:l?c.jsx("img",{src:l,alt:"WhatsApp QR Code",className:"w-48 h-48"}):c.jsx("div",{className:"w-48 h-48 flex items-center justify-center",children:c.jsx(Z,{icon:Nt,size:32,strokeWidth:2,className:"animate-spin text-muted-foreground"})})}),c.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Scan this QR code with WhatsApp on your phone"}),c.jsxs(_e,{variant:"ghost",size:"sm",onClick:y,disabled:E,className:"mt-2",children:[c.jsx(Z,{icon:lp,size:14,strokeWidth:2,className:"mr-2"}),"Refresh QR"]})]}),m&&d&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-3",children:[c.jsxs(_e,{variant:"outline",size:"sm",onClick:v,disabled:E,children:[c.jsx(Z,{icon:tD,size:14,strokeWidth:2,className:"mr-2"}),"Disconnect"]}),r&&r.length>0&&c.jsxs("div",{className:"mt-4",children:[c.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Active Conversations"}),c.jsx("div",{className:"space-y-1",children:r.map(T=>c.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[c.jsx("span",{className:"font-mono",children:T.channelUserId}),T.channelUserName&&c.jsxs("span",{children:["(",T.channelUserName,")"]}),c.jsxs("span",{className:"text-muted-foreground/60",children:["Last: ",new Date(T.lastMessageAt).toLocaleString()]})]},T.id))})]})]}),c.jsx("p",{className:"ml-4 sm:ml-44 text-xs text-muted-foreground",children:"Connect WhatsApp to chat with the AI assistant via your phone. Send any message to start a conversation, or use /reset to start fresh."})]})}function yNt({isLoading:e=!1}){const{data:t,refetch:n}=KAt(),{data:r}=JAt(),i=YAt(),s=XAt(),a=QAt(),o=ZAt(),l=!!t?.config?.botToken,[u,d]=x.useState(""),[f,h]=x.useState(!1),m=t?.status==="connected",g=t?.status==="connecting",y=async k=>{try{k?l?(await s.mutateAsync(),n()):h(!0):(await a.mutateAsync(),h(!1),d(""),n())}catch{rt.error("Failed to toggle Discord")}},v=async()=>{if(!u.trim()){rt.error("Please enter a bot token");return}try{await i.mutateAsync(u.trim()),h(!1),d(""),rt.success("Discord configuration saved"),n()}catch(k){rt.error(k instanceof Error?k.message:"Failed to connect Discord")}},_=async()=>{try{await o.mutateAsync(),rt.success("Discord disconnected")}catch{rt.error("Failed to disconnect Discord")}},S=()=>m?c.jsx(Z,{icon:hr,size:14,strokeWidth:2,className:"text-green-500"}):g?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin text-yellow-500"}):c.jsx(Z,{icon:Tn,size:14,strokeWidth:2,className:"text-muted-foreground"}),E=()=>m?t?.displayName?`Connected as ${t.displayName}`:"Connected":g?"Connecting...":"Disconnected",T=i.isPending||s.isPending||a.isPending||o.isPending;return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:"Discord"}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Xr,{checked:m||g||f,onCheckedChange:y,disabled:e||T}),c.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[S(),c.jsx("span",{className:"text-muted-foreground",children:E()})]})]})]}),f&&!m&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-3",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:"Bot Token"}),c.jsx(At,{type:"password",placeholder:"Enter your Discord bot token",value:u,onChange:k=>d(k.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(_e,{size:"sm",onClick:v,disabled:T||!u.trim(),children:[i.isPending?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"mr-2 animate-spin"}):null,"Connect"]}),c.jsx(_e,{variant:"ghost",size:"sm",onClick:()=>{h(!1),d("")},disabled:T,children:"Cancel"})]})]}),m&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-3",children:[c.jsxs(_e,{variant:"outline",size:"sm",onClick:_,disabled:T,children:[c.jsx(Z,{icon:tD,size:14,strokeWidth:2,className:"mr-2"}),"Disconnect"]}),r&&r.length>0&&c.jsxs("div",{className:"mt-4",children:[c.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Active Conversations"}),c.jsx("div",{className:"space-y-1",children:r.map(k=>c.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[c.jsx("span",{className:"font-mono",children:k.channelUserId}),k.channelUserName&&c.jsxs("span",{children:["(",k.channelUserName,")"]}),c.jsxs("span",{className:"text-muted-foreground/60",children:["Last: ",new Date(k.lastMessageAt).toLocaleString()]})]},k.id))})]})]}),c.jsxs("details",{className:"ml-4 sm:ml-44 text-sm text-muted-foreground",children:[c.jsx("summary",{className:"cursor-pointer hover:text-foreground",children:"Setup instructions"}),c.jsxs("ol",{className:"mt-2 ml-4 space-y-1 list-decimal",children:[c.jsxs("li",{children:["Go to the"," ",c.jsx("a",{href:"https://discord.com/developers/applications",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Discord Developer Portal"})]}),c.jsxs("li",{children:["Create a new application and click ",c.jsx("strong",{children:"Bot"})," in the sidebar"]}),c.jsxs("li",{children:["Click ",c.jsx("strong",{children:"Reset Token"})," to generate a bot token, then copy it"]}),c.jsxs("li",{children:["Enable ",c.jsx("strong",{children:"Message Content Intent"})," under Privileged Gateway Intents"]}),c.jsxs("li",{children:["Go to ",c.jsx("strong",{children:"OAuth2 → URL Generator"})," in the sidebar"]}),c.jsxs("li",{children:["Select both ",c.jsx("strong",{children:"bot"})," and ",c.jsx("strong",{children:"applications.commands"})," scopes"]}),c.jsx("li",{children:"Copy the generated URL and open it to add the bot (slash commands need re-auth)"}),c.jsx("li",{children:"Paste the bot token above and click Connect"}),c.jsx("li",{children:"DM the bot in Discord to chat with the AI assistant"})]})]})]})}function vNt({isLoading:e=!1}){const{data:t,refetch:n}=eNt(),{data:r}=sNt(),i=tNt(),s=nNt(),a=rNt(),o=iNt(),l=!!t?.config?.botToken,[u,d]=x.useState(""),[f,h]=x.useState(!1),m=t?.status==="connected",g=t?.status==="connecting",y=async k=>{try{k?l?(await s.mutateAsync(),n()):h(!0):(await a.mutateAsync(),h(!1),d(""),n())}catch{rt.error("Failed to toggle Telegram")}},v=async()=>{if(!u.trim()){rt.error("Please enter a bot token");return}try{await i.mutateAsync(u.trim()),h(!1),d(""),rt.success("Telegram configuration saved"),n()}catch(k){rt.error(k instanceof Error?k.message:"Failed to connect Telegram")}},_=async()=>{try{await o.mutateAsync(),rt.success("Telegram disconnected")}catch{rt.error("Failed to disconnect Telegram")}},S=()=>m?c.jsx(Z,{icon:hr,size:14,strokeWidth:2,className:"text-green-500"}):g?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin text-yellow-500"}):c.jsx(Z,{icon:Tn,size:14,strokeWidth:2,className:"text-muted-foreground"}),E=()=>m?t?.displayName?`Connected as ${t.displayName}`:"Connected":g?"Connecting...":"Disconnected",T=i.isPending||s.isPending||a.isPending||o.isPending;return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:"Telegram"}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Xr,{checked:m||g||f,onCheckedChange:y,disabled:e||T}),c.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[S(),c.jsx("span",{className:"text-muted-foreground",children:E()})]})]})]}),f&&!m&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-3",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:"Bot Token"}),c.jsx(At,{type:"password",placeholder:"Enter your Telegram bot token",value:u,onChange:k=>d(k.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(_e,{size:"sm",onClick:v,disabled:T||!u.trim(),children:[i.isPending?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"mr-2 animate-spin"}):null,"Connect"]}),c.jsx(_e,{variant:"ghost",size:"sm",onClick:()=>{h(!1),d("")},disabled:T,children:"Cancel"})]})]}),m&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-3",children:[c.jsxs(_e,{variant:"outline",size:"sm",onClick:_,disabled:T,children:[c.jsx(Z,{icon:tD,size:14,strokeWidth:2,className:"mr-2"}),"Disconnect"]}),r&&r.length>0&&c.jsxs("div",{className:"mt-4",children:[c.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Active Conversations"}),c.jsx("div",{className:"space-y-1",children:r.map(k=>c.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[c.jsx("span",{className:"font-mono",children:k.channelUserId}),k.channelUserName&&c.jsxs("span",{children:["(",k.channelUserName,")"]}),c.jsxs("span",{className:"text-muted-foreground/60",children:["Last: ",new Date(k.lastMessageAt).toLocaleString()]})]},k.id))})]})]}),c.jsxs("details",{className:"ml-4 sm:ml-44 text-sm text-muted-foreground",children:[c.jsx("summary",{className:"cursor-pointer hover:text-foreground",children:"Setup instructions"}),c.jsxs("ol",{className:"mt-2 ml-4 space-y-1 list-decimal",children:[c.jsxs("li",{children:["Open Telegram and message"," ",c.jsx("a",{href:"https://t.me/BotFather",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"@BotFather"})]}),c.jsxs("li",{children:["Send ",c.jsx("code",{className:"bg-muted px-1 rounded",children:"/newbot"})," and follow the prompts"]}),c.jsx("li",{children:"Copy the bot token provided by BotFather"}),c.jsx("li",{children:"Paste the token above and click Connect"}),c.jsx("li",{children:"Find your new bot in Telegram and start a chat"})]})]})]})}function xNt({isLoading:e=!1}){const{data:t,refetch:n}=aNt(),{data:r}=dNt(),i=oNt(),s=lNt(),a=cNt(),o=uNt(),l=!!(t?.config?.botToken&&t?.config?.appToken),[u,d]=x.useState(""),[f,h]=x.useState(""),[m,g]=x.useState(!1),y=t?.status==="connected",v=t?.status==="connecting",_=async A=>{try{A?l?(await s.mutateAsync(),n()):g(!0):(await a.mutateAsync(),g(!1),d(""),h(""),n())}catch{rt.error("Failed to toggle Slack")}},S=async()=>{if(!u.trim()){rt.error("Please enter a bot token");return}if(!f.trim()){rt.error("Please enter an app token");return}try{await i.mutateAsync({botToken:u.trim(),appToken:f.trim()}),g(!1),d(""),h(""),rt.success("Slack configuration saved"),n()}catch(A){rt.error(A instanceof Error?A.message:"Failed to connect Slack")}},E=async()=>{try{await o.mutateAsync(),rt.success("Slack disconnected")}catch{rt.error("Failed to disconnect Slack")}},T=()=>y?c.jsx(Z,{icon:hr,size:14,strokeWidth:2,className:"text-green-500"}):v?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin text-yellow-500"}):c.jsx(Z,{icon:Tn,size:14,strokeWidth:2,className:"text-muted-foreground"}),k=()=>y?t?.displayName?`Connected as ${t.displayName}`:"Connected":v?"Connecting...":"Disconnected",w=i.isPending||s.isPending||a.isPending||o.isPending;return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:"Slack"}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Xr,{checked:y||v||m,onCheckedChange:_,disabled:e||w}),c.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[T(),c.jsx("span",{className:"text-muted-foreground",children:k()})]})]})]}),m&&!y&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-3",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:"Bot Token (xoxb-...)"}),c.jsx(At,{type:"password",placeholder:"xoxb-your-bot-token",value:u,onChange:A=>d(A.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:"App Token (xapp-...)"}),c.jsx(At,{type:"password",placeholder:"xapp-your-app-token",value:f,onChange:A=>h(A.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(_e,{size:"sm",onClick:S,disabled:w||!u.trim()||!f.trim(),children:[i.isPending?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"mr-2 animate-spin"}):null,"Connect"]}),c.jsx(_e,{variant:"ghost",size:"sm",onClick:()=>{g(!1),d(""),h("")},disabled:w,children:"Cancel"})]})]}),y&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-3",children:[c.jsxs(_e,{variant:"outline",size:"sm",onClick:E,disabled:w,children:[c.jsx(Z,{icon:tD,size:14,strokeWidth:2,className:"mr-2"}),"Disconnect"]}),r&&r.length>0&&c.jsxs("div",{className:"mt-4",children:[c.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Active Conversations"}),c.jsx("div",{className:"space-y-1",children:r.map(A=>c.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[c.jsx("span",{className:"font-mono",children:A.channelUserId}),A.channelUserName&&c.jsxs("span",{children:["(",A.channelUserName,")"]}),c.jsxs("span",{className:"text-muted-foreground/60",children:["Last: ",new Date(A.lastMessageAt).toLocaleString()]})]},A.id))})]})]}),c.jsxs("details",{className:"ml-4 sm:ml-44 text-sm text-muted-foreground",children:[c.jsx("summary",{className:"cursor-pointer hover:text-foreground",children:"Setup instructions"}),c.jsxs("ol",{className:"mt-2 ml-4 space-y-1 list-decimal",children:[c.jsxs("li",{children:["Go to"," ",c.jsx("a",{href:"https://api.slack.com/apps",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"api.slack.com/apps"})," ","and create a new app"]}),c.jsxs("li",{children:["Under ",c.jsx("strong",{children:"Socket Mode"}),", enable it and create an App Token (xapp-...)"]}),c.jsxs("li",{children:["Under ",c.jsx("strong",{children:"OAuth & Permissions"}),", add these ",c.jsx("strong",{children:"Bot Token Scopes"}),":"," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"chat:write"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"commands"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"files:read"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"files:write"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"im:history"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"im:read"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"im:write"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"users:read"})]}),c.jsx("li",{children:"Install the app to your workspace to get the Bot Token (xoxb-...)"}),c.jsxs("li",{children:["Under ",c.jsx("strong",{children:"Event Subscriptions"}),", subscribe to ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"message.im"})]}),c.jsxs("li",{children:["Under ",c.jsx("strong",{children:"Slash Commands"}),", create these commands:"," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"/reset"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"/help"}),","," ",c.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"/info"})," ",c.jsx("span",{className:"text-muted-foreground/60",children:"(/status is reserved by Slack)"})]}),c.jsxs("li",{children:["Under ",c.jsx("strong",{children:"App Home"}),", enable ",c.jsx("strong",{children:"Messages Tab"})," and check ",c.jsx("em",{children:'"Allow users to send Slash commands and messages from the messages tab"'})]}),c.jsx("li",{children:"Paste both tokens above and click Connect"}),c.jsx("li",{children:"DM the bot in Slack to chat with the AI assistant"})]})]})]})}const yM=vc(),yp="";function k5(){return Jt({queryKey:["google","accounts"],queryFn:()=>ht(`${yp}/api/google/accounts`).then(e=>e.accounts)})}function uRe(){const e=It();return wt({mutationFn:({id:t,...n})=>ht(`${yp}/api/google/accounts/${t}`,{method:"PATCH",body:JSON.stringify(n)}),onSuccess:()=>{e.invalidateQueries({queryKey:["google"]})}})}function _Nt(){const e=It();return wt({mutationFn:t=>ht(`${yp}/api/google/accounts/${t}`,{method:"DELETE"}),onSuccess:()=>{e.invalidateQueries({queryKey:["google"]}),e.invalidateQueries({queryKey:["caldav"]})}})}function SNt(){const e=It();return wt({mutationFn:t=>ht(`${yp}/api/google/accounts/${t}/enable-calendar`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["google"]}),e.invalidateQueries({queryKey:["caldav"]})}})}function wNt(){const e=It();return wt({mutationFn:t=>ht(`${yp}/api/google/accounts/${t}/disable-calendar`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["google"]}),e.invalidateQueries({queryKey:["caldav"]})}})}function ENt(){const e=It();return wt({mutationFn:t=>ht(`${yp}/api/google/accounts/${t}/sync`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["google"]}),e.invalidateQueries({queryKey:["caldav"]})}})}function CNt(){const e=It();return wt({mutationFn:t=>ht(`${yp}/api/google/accounts/${t}/enable-gmail`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["google"]})}})}function kNt(){const e=It();return wt({mutationFn:t=>ht(`${yp}/api/google/accounts/${t}/disable-gmail`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["google"]})}})}function TNt(){return wt({mutationFn:async e=>{const t=new URLSearchParams;e.accountName&&t.set("accountName",e.accountName),e.accountId&&t.set("accountId",e.accountId),t.set("origin",window.location.origin);const n=`${yp}/api/google/oauth/authorize?${t.toString()}`;yM.info("Requesting OAuth authorize URL",{origin:window.location.origin,href:window.location.href,fetchUrl:n,accountName:e.accountName,accountId:e.accountId});const r=await ht(n);try{const i=new URL(r.authUrl);yM.info("Got OAuth auth URL from server",{authUrl:r.authUrl,redirect_uri:i.searchParams.get("redirect_uri"),client_id:i.searchParams.get("client_id"),scope:i.searchParams.get("scope"),state:i.searchParams.get("state")})}catch{yM.info("Got OAuth auth URL from server (unparseable)",{authUrl:r.authUrl})}return r}})}const Ede={"gmail.com":{imap:{host:"imap.gmail.com",port:993,secure:!0},note:"Requires an App Password. Go to Google Account > Security > 2-Step Verification > App passwords."},"googlemail.com":{imap:{host:"imap.gmail.com",port:993,secure:!0},note:"Requires an App Password. Go to Google Account > Security > 2-Step Verification > App passwords."},"outlook.com":{imap:{host:"outlook.office365.com",port:993,secure:!0}},"hotmail.com":{imap:{host:"outlook.office365.com",port:993,secure:!0}},"live.com":{imap:{host:"outlook.office365.com",port:993,secure:!0}},"yahoo.com":{imap:{host:"imap.mail.yahoo.com",port:993,secure:!0}},"icloud.com":{imap:{host:"imap.mail.me.com",port:993,secure:!0},note:"Requires an App-Specific Password from appleid.apple.com."}};function Cde(e){const t=e.split("@")[1]?.toLowerCase();return t&&Ede[t]?{...Ede[t],isKnown:!0}:{imap:{host:`imap.${t||"example.com"}`,port:993,secure:!0},isKnown:!1}}function ANt({isLoading:e=!1}){const{t}=Ot("settings"),[n,r]=x.useState("gmail");return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:t("imap.emailBackend","Email Backend")}),c.jsxs("div",{className:"flex gap-1 rounded-lg border p-0.5",children:[c.jsx("button",{type:"button",onClick:()=>r("gmail"),className:`rounded-md px-3 py-1 text-sm transition-colors ${n==="gmail"?"bg-destructive text-destructive-foreground":"text-muted-foreground hover:text-foreground"}`,children:t("google.gmail","Gmail API")}),c.jsx("button",{type:"button",onClick:()=>r("imap"),className:`rounded-md px-3 py-1 text-sm transition-colors ${n==="imap"?"bg-destructive text-destructive-foreground":"text-muted-foreground hover:text-foreground"}`,children:"IMAP"})]})]}),n==="imap"?c.jsx(NNt,{isLoading:e}):c.jsx(ONt,{})]})}function NNt({isLoading:e=!1}){const{t}=Ot("settings"),{data:n,refetch:r}=fNt(),i=hNt(),s=pNt(),a=mNt(),o=gNt(),l=!!n?.config?.imap?.host,[u,d]=x.useState(""),[f,h]=x.useState(""),[m,g]=x.useState(!1),[y,v]=x.useState(""),[_,S]=x.useState(993),[E,T]=x.useState(!0),[k,w]=x.useState(""),[A,R]=x.useState(""),[I,D]=x.useState(30),[j,F]=x.useState(null),z=n?.status==="connected",P=n?.status==="connecting",L=n?.enabled??!1,M=Cde(u);x.useEffect(()=>{if(n?.config){const ee=n.config;d(ee.imap?.user||""),h(ee.imap?.password||""),v(ee.imap?.host||""),S(ee.imap?.port||993),T(ee.imap?.secure??!0),w(ee.imap?.user||""),R(ee.imap?.password||""),D(ee.pollIntervalSeconds||30);const oe=Cde(ee.imap?.user||"");ee.imap?.host&&ee.imap.host!==oe.imap.host&&g(!0)}},[n?.config]);const $=()=>m?{imap:{host:y,port:_,secure:E,user:k,password:A},pollIntervalSeconds:I}:{imap:{...M.imap,user:u,password:f},pollIntervalSeconds:I},W=async()=>{const ee=$();F(null);try{const oe=await s.mutateAsync(ee);F(oe),oe.success?rt.success("Connection test successful"):rt.error(oe.error||"Connection test failed")}catch{rt.error("Failed to test credentials")}},Y=async()=>{const ee=$();try{await i.mutateAsync(ee),rt.success("Email configured successfully"),h(""),r()}catch{rt.error("Failed to configure email")}},q=async()=>{try{await a.mutateAsync()&&(rt.success("Email enabled"),r())}catch(ee){rt.error(ee instanceof Error?ee.message:"Failed to enable email")}},K=async()=>{try{await o.mutateAsync(),rt.success("Email disabled"),r()}catch{rt.error("Failed to disable email")}},X=async ee=>{ee?l&&await q():await K()},U=i.isPending||s.isPending||a.isPending||o.isPending,J=()=>z?c.jsx(Z,{icon:hr,size:14,strokeWidth:2,className:"text-green-500"}):P?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin text-yellow-500"}):c.jsx(Z,{icon:Tn,size:14,strokeWidth:2,className:"text-muted-foreground"}),te=()=>z?n?.displayName?`Connected as ${n.displayName}`:"Connected":P?"Connecting...":n?.status==="credentials_required"?"Credentials required":"Disconnected";return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:t("imap.label","IMAP Feed")}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Xr,{checked:L,onCheckedChange:X,disabled:e||U}),c.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[J(),c.jsx("span",{className:"text-muted-foreground",children:te()})]})]})]}),!z&&c.jsxs("div",{className:"ml-4 sm:ml-44 space-y-4 max-w-md",children:[!m&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ur,{htmlFor:"email",children:"Email Address"}),c.jsx(At,{id:"email",type:"email",placeholder:"assistant@example.com",value:u,onChange:ee=>d(ee.target.value)}),M.note&&u.includes("@")&&c.jsxs("p",{className:"text-xs text-muted-foreground flex items-start gap-1",children:[c.jsx(Z,{icon:wr,size:14,strokeWidth:2,className:"shrink-0 mt-0.5 text-yellow-500"}),M.note]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ur,{htmlFor:"password",children:u.includes("@gmail.com")||u.includes("@icloud.com")?"App Password":"Password"}),c.jsx(At,{id:"password",type:"password",placeholder:"Password",value:f,onChange:ee=>h(ee.target.value)})]}),u.includes("@")&&c.jsxs("div",{className:"text-xs text-muted-foreground",children:[c.jsxs("span",{children:["IMAP: ",M.imap.host,":",M.imap.port]}),!M.isKnown&&c.jsx("span",{className:"ml-2 text-yellow-600",children:"(auto-detected)"})]})]}),c.jsx("div",{className:"pt-2",children:c.jsx("button",{type:"button",onClick:()=>g(!m),className:"text-xs text-muted-foreground hover:text-foreground",children:m?"- Hide advanced settings":"+ Show advanced settings"})}),m&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"border-t border-border pt-4",children:[c.jsx("h4",{className:"text-sm font-medium mb-3",children:"IMAP Settings (Incoming)"}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{className:"col-span-2 space-y-2",children:[c.jsx(Ur,{htmlFor:"imapHost",children:"Host"}),c.jsx(At,{id:"imapHost",placeholder:"imap.gmail.com",value:y,onChange:ee=>v(ee.target.value)})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ur,{htmlFor:"imapPort",children:"Port"}),c.jsx(At,{id:"imapPort",type:"number",value:_||M.imap.port,onChange:ee=>S(parseInt(ee.target.value)||993)})]}),c.jsxs("div",{className:"flex items-end gap-2 pb-1",children:[c.jsx(Xr,{id:"imapSecure",checked:E,onCheckedChange:T}),c.jsx(Ur,{htmlFor:"imapSecure",children:"SSL/TLS"})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ur,{htmlFor:"imapUser",children:"Username"}),c.jsx(At,{id:"imapUser",placeholder:"you@gmail.com",value:k,onChange:ee=>w(ee.target.value)})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ur,{htmlFor:"imapPassword",children:"Password"}),c.jsx(At,{id:"imapPassword",type:"password",placeholder:"IMAP password or app password",value:A,onChange:ee=>R(ee.target.value)})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ur,{htmlFor:"pollInterval",children:"Check for new emails every"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(At,{id:"pollInterval",type:"number",className:"w-20",min:10,max:300,value:I,onChange:ee=>D(parseInt(ee.target.value)||30)}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"seconds"})]})]})]}),j&&c.jsxs("div",{className:`p-3 rounded-lg text-sm ${j.success?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Z,{icon:j.success?hr:Tn,size:16,strokeWidth:2}),c.jsx("span",{children:j.success?"Connection successful":"Connection failed"})]}),!j.success&&j.error&&c.jsx("p",{className:"mt-1 text-xs",children:j.error}),c.jsx("div",{className:"mt-2 text-xs space-y-1",children:c.jsxs("p",{children:["IMAP: ",j.imapOk?"OK":"Failed"]})})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(_e,{variant:"outline",size:"sm",onClick:W,disabled:U||(m?!y||!k||!A:!u||!f),children:[s.isPending?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"mr-2 animate-spin"}):c.jsx(Z,{icon:rm,size:14,strokeWidth:2,className:"mr-2"}),"Test Connection"]}),c.jsxs(_e,{size:"sm",onClick:Y,disabled:U||(m?!y||!k||!A:!u||!f),children:[i.isPending?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"mr-2 animate-spin"}):null,"Save & Enable"]})]})]}),L&&z&&c.jsx("div",{className:"ml-4 sm:ml-44 space-y-3",children:c.jsx(_e,{variant:"outline",size:"sm",onClick:K,disabled:U,children:t("imap.disableButton","Disable Email")})}),c.jsx("p",{className:"ml-4 sm:ml-44 text-xs text-muted-foreground",children:t("imap.description","Monitor an IMAP mailbox as a read-only feed. Incoming emails appear in the messaging timeline but no replies are sent.")})]})}function ONt(){const{t:e}=Ot("settings"),{data:t}=k5(),n=CNt(),r=kNt(),i=Tr(Qt.EMAIL_POLL_INTERVAL),s=DW(),[a,o]=x.useState(30);x.useEffect(()=>{i.data?.value!=null&&o(Number(i.data.value)||30)},[i.data?.value]);const l=()=>{const f=Math.max(5,Math.min(3600,a||30));o(f),s.mutate({key:Qt.EMAIL_POLL_INTERVAL,value:f})},u=async(f,h)=>{try{h?(await n.mutateAsync(f),rt.success(e("google.gmailEnabled","Gmail enabled"))):(await r.mutateAsync(f),rt.success(e("google.gmailDisabled","Gmail disabled")))}catch(m){rt.error(String(m))}},d=t?.some(f=>f.gmailEnabled);return!t||t.length===0?c.jsx("div",{className:"space-y-2 ml-4 sm:ml-44",children:c.jsxs("p",{className:"text-sm text-muted-foreground",children:[e("google.noAccountsGmail","No Google accounts connected.")," ",c.jsx(Pr,{to:"/settings",search:{tab:void 0},className:"text-accent underline underline-offset-2",children:e("google.addInGeneral","Add one in General settings")})]})}):c.jsxs("div",{className:"space-y-4",children:[t.map(f=>c.jsx(RNt,{account:f,onToggle:u},f.id)),d&&c.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[c.jsx(Ur,{htmlFor:"gmailPollInterval",children:e("imap.checkEvery","Check for new emails every")}),c.jsx(At,{id:"gmailPollInterval",type:"number",min:5,max:3600,value:a,onChange:f=>o(parseInt(f.target.value)||30),onBlur:l,onKeyDown:f=>{f.key==="Enter"&&f.currentTarget.blur()},className:"w-20 h-8"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:e("imap.seconds","seconds")})]}),c.jsx("p",{className:"text-xs text-muted-foreground",children:e("google.gmailDescription","Gmail API uses OAuth2 — no app passwords needed. Drafts are created for human review before sending.")})]})}function RNt({account:e,onToggle:t}){const{t:n}=Ot("settings"),r=uRe(),[i,s]=x.useState(e.sendAsEmail??e.email??""),a=async()=>{const o=i.trim(),l=e.sendAsEmail??e.email??"";if(o!==l)try{await r.mutateAsync({id:e.id,sendAsEmail:o||null}),rt.success(n("google.sendAsUpdated","Send-as address updated"))}catch(u){rt.error(String(u))}};return c.jsxs("div",{className:"border rounded-lg p-4 space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium text-sm",children:e.name}),e.email&&c.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:e.email})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-xs text-muted-foreground",children:n("google.monitorInbox","Monitor inbox")}),c.jsx(Xr,{checked:e.gmailEnabled??!1,onCheckedChange:o=>t(e.id,o)})]})]}),e.gmailEnabled&&c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("label",{className:"text-xs text-muted-foreground shrink-0",children:n("google.sendAs","Send as")}),c.jsx(At,{value:i,onChange:o=>s(o.target.value),onBlur:a,onKeyDown:o=>{o.key==="Enter"&&o.currentTarget.blur()},placeholder:e.email??n("google.sendAsPlaceholder","you@gmail.com"),className:"h-8 text-xs max-w-xs"}),c.jsx("span",{className:"text-xs text-muted-foreground",children:n("google.draftsOnly","(drafts only)")})]}),e.lastGmailSyncError&&c.jsxs("div",{className:"flex items-start gap-1.5",children:[c.jsx(Z,{icon:wr,className:"h-3.5 w-3.5 text-destructive mt-0.5"}),c.jsx("p",{className:"text-xs text-destructive",children:e.lastGmailSyncError})]})]})}const ka="";function INt(){return Jt({queryKey:["caldav","status"],queryFn:()=>ht(`${ka}/api/caldav/status`),refetchInterval:3e4})}function dRe(){return Jt({queryKey:["caldav","accounts"],queryFn:()=>ht(`${ka}/api/caldav/accounts`)})}function DNt(){const e=It();return wt({mutationFn:t=>ht(`${ka}/api/caldav/accounts`,{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function jNt(){const e=It();return wt({mutationFn:t=>ht(`${ka}/api/caldav/accounts/google`,{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function PNt(){const e=It();return wt({mutationFn:({id:t,...n})=>ht(`${ka}/api/caldav/accounts/${t}`,{method:"PATCH",body:JSON.stringify(n)}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function LNt(){const e=It();return wt({mutationFn:t=>ht(`${ka}/api/caldav/accounts/${t}`,{method:"DELETE"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function MNt(){const e=It();return wt({mutationFn:t=>ht(`${ka}/api/caldav/accounts/${t}/enable`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function FNt(){const e=It();return wt({mutationFn:t=>ht(`${ka}/api/caldav/accounts/${t}/disable`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function BNt(){const e=It();return wt({mutationFn:t=>ht(`${ka}/api/caldav/accounts/${t}/sync`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function $Nt(){return wt({mutationFn:e=>ht(`${ka}/api/caldav/accounts/${e}/oauth/authorize`)})}function zNt(){return Jt({queryKey:["caldav","copy-rules"],queryFn:()=>ht(`${ka}/api/caldav/copy-rules`)})}function UNt(){const e=It();return wt({mutationFn:t=>ht(`${ka}/api/caldav/copy-rules`,{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav","copy-rules"]})}})}function HNt(){const e=It();return wt({mutationFn:({id:t,...n})=>ht(`${ka}/api/caldav/copy-rules/${t}`,{method:"PATCH",body:JSON.stringify(n)}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav","copy-rules"]})}})}function VNt(){const e=It();return wt({mutationFn:t=>ht(`${ka}/api/caldav/copy-rules/${t}`,{method:"DELETE"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav","copy-rules"]})}})}function WNt(){const e=It();return wt({mutationFn:t=>ht(`${ka}/api/caldav/copy-rules/${t}/execute`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]})}})}function yZ(){return Jt({queryKey:["caldav","calendars"],queryFn:()=>ht(`${ka}/api/caldav/calendars`)})}function qNt(){const e=It();return wt({mutationFn:()=>ht(`${ka}/api/caldav/enable`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]}),e.invalidateQueries({queryKey:["config","caldav.enabled"]})}})}function GNt(){const e=It();return wt({mutationFn:()=>ht(`${ka}/api/caldav/disable`,{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["caldav"]}),e.invalidateQueries({queryKey:["config","caldav.enabled"]})}})}function fRe(e,t){return Jt({queryKey:["caldav","events",e,t],queryFn:()=>ht(`${ka}/api/caldav/events?from=${e}&to=${t}&source=live`),enabled:!!e&&!!t})}function KNt({isLoading:e=!1}){const{t}=Ot("settings"),{data:n,refetch:r}=INt(),{data:i}=dRe(),s=DNt(),a=jNt(),o=LNt(),l=MNt(),u=FNt(),d=BNt(),f=$Nt(),h=PNt(),m=qNt(),g=GNt(),y=RW(),[v,_]=x.useState(!1),[S,E]=x.useState(null),[T,k]=x.useState(""),[w,A]=x.useState("google"),[R,I]=x.useState(""),[D,j]=x.useState(""),[F,z]=x.useState(""),[P,L]=x.useState(""),[M,$]=x.useState("15"),[W,Y]=x.useState(""),[q,K]=x.useState(""),[X,U]=x.useState(""),[J,te]=x.useState("15"),[ee,oe]=x.useState(!1),[ae,se]=x.useState(null),ue=x.useRef(null),de=n?.connected===!0||(n?.accounts??[]).length>0;x.useEffect(()=>(ee&&ae&&(ue.current=setInterval(()=>{r()},2e3)),ee&&ae&&n?.accounts&&n.accounts.find(De=>De.id===ae)?.connected&&(oe(!1),se(null),_(!1),Y(""),K(""),U(""),rt.success(t("caldav.configured"))),()=>{ue.current&&(clearInterval(ue.current),ue.current=null)}),[ee,ae,n?.accounts,r,t]);const ce=async ye=>{try{ye?await m.mutateAsync():await g.mutateAsync(),r()}catch{rt.error(t("caldav.toggleFailed"))}},Ee=async ye=>{try{await d.mutateAsync(ye),rt.success(t("caldav.syncComplete")),r()}catch(De){rt.error(De instanceof Error?De.message:t("caldav.syncFailed"))}},Ie=async(ye,De)=>{try{De?await u.mutateAsync(ye):await l.mutateAsync(ye),r()}catch{rt.error(t("caldav.toggleFailed"))}},fe=async ye=>{try{await o.mutateAsync(ye),rt.success(t("caldav.disconnected")),r()}catch{rt.error(t("caldav.disconnectFailed"))}},be=async()=>{if(!D.trim()||!F.trim()||!P.trim()){rt.error(t("caldav.fillRequired"));return}try{await s.mutateAsync({name:R.trim()||F.trim(),serverUrl:D.trim(),username:F.trim(),password:P.trim(),syncIntervalMinutes:parseInt(M,10)||15}),_(!1),I(""),j(""),z(""),L(""),$("15"),rt.success(t("caldav.configured")),r()}catch(ye){rt.error(ye instanceof Error?ye.message:t("caldav.configureFailed"))}},ge=async()=>{if(!q.trim()||!X.trim()){rt.error(t("caldav.googleFillRequired"));return}try{const ye=await a.mutateAsync({name:W.trim()||"Google Calendar",googleClientId:q.trim(),googleClientSecret:X.trim(),syncIntervalMinutes:parseInt(J,10)||15}),{authUrl:De}=await f.mutateAsync(ye.id);window.open(De,"_blank","noopener"),rt.info(t("caldav.googleAuthStarted")),se(ye.id),oe(!0)}catch(ye){rt.error(ye instanceof Error?ye.message:t("caldav.configureFailed"))}},Ce=()=>{_(!1),oe(!1),se(null),I(""),j(""),z(""),L(""),$("15"),Y(""),K(""),U(""),te("15")},Re=s.isPending||a.isPending||f.isPending||h.isPending||o.isPending||l.isPending||u.isPending||d.isPending||m.isPending||g.isPending,xe=n?.accounts??[];return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:t("caldav.label")}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Xr,{checked:de,onCheckedChange:ce,disabled:e||Re}),m.isPending&&c.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin text-yellow-500"}),c.jsx("span",{className:"text-muted-foreground",children:t("caldav.statusConnecting")})]})]})]}),xe.length>0&&c.jsx("div",{className:"ml-4 sm:ml-44 space-y-2",children:xe.map(ye=>{const ve=i?.find(Oe=>Oe.id===ye.id)?.authType??"basic";return c.jsxs("div",{className:"flex items-center gap-3 rounded-md border px-3 py-2",children:[c.jsx("div",{className:"shrink-0",children:ye.syncing?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin text-yellow-500"}):ye.lastError?c.jsx(Z,{icon:Tn,size:14,strokeWidth:2,className:"text-red-500"}):ye.connected?c.jsx(Z,{icon:hr,size:14,strokeWidth:2,className:"text-green-500"}):c.jsx("span",{className:"inline-block h-3.5 w-3.5 rounded-full border border-muted-foreground/40"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[S===ye.id?c.jsx(At,{autoFocus:!0,value:T,onChange:Oe=>k(Oe.target.value),onFocus:Oe=>Oe.target.select(),onKeyDown:Oe=>{Oe.key==="Enter"?Oe.currentTarget.blur():Oe.key==="Escape"&&(E(null),k(""))},onBlur:()=>{const Oe=T.trim();Oe&&Oe!==ye.name&&h.mutate({id:ye.id,name:Oe},{onSuccess:()=>r()}),E(null),k("")},className:"h-6 w-48 text-sm font-medium px-1.5 py-0"}):c.jsx("span",{className:"text-sm font-medium truncate cursor-pointer hover:underline",onClick:()=>{E(ye.id),k(ye.name)},children:ye.name}),c.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:ve==="google-oauth"?"Google":"Basic"})]}),c.jsx("div",{className:"text-xs text-muted-foreground",children:ye.connected?`${ye.calendarCount} calendar${ye.calendarCount!==1?"s":""}`:ye.lastError?ye.lastError:ye.enabled?t("caldav.statusConnecting"):t("caldav.disabled")??"Disabled"})]}),c.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[c.jsx(_e,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>Ee(ye.id),disabled:Re||ye.syncing||!ye.enabled,title:t("caldav.syncButton"),children:c.jsx(Z,{icon:lp,size:14,strokeWidth:2,className:ye.syncing?"animate-spin":""})}),c.jsx(Xr,{checked:ye.enabled,onCheckedChange:()=>Ie(ye.id,ye.enabled),disabled:Re,className:"scale-75"}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",onClick:()=>fe(ye.id),disabled:Re,title:t("caldav.deleteAccount")??"Delete",children:c.jsx(Z,{icon:ks,size:14,strokeWidth:2})})]})]},ye.id)})}),!v&&c.jsx("div",{className:"ml-4 sm:ml-44",children:c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>_(!0),disabled:Re,children:[c.jsx(Z,{icon:Ic,size:14,strokeWidth:2,className:"mr-2"}),t("caldav.addAccount")]})}),v&&c.jsx("div",{className:"ml-4 sm:ml-44",children:c.jsxs(nl,{value:w,onValueChange:A,children:[c.jsxs(rl,{children:[c.jsx(In,{value:"google",children:t("caldav.tabGoogle")}),c.jsx(In,{value:"basic",children:t("caldav.tabBasic")})]}),c.jsx(jn,{value:"basic",children:c.jsxs("div",{className:"space-y-3 pt-2",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.accountName")}),c.jsx(At,{type:"text",placeholder:t("caldav.accountNamePlaceholder")??"My CalDAV Server",value:R,onChange:ye=>I(ye.target.value),className:"max-w-md text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.serverUrl")}),c.jsx(At,{type:"url",placeholder:t("caldav.serverUrlPlaceholder"),value:D,onChange:ye=>j(ye.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.username")}),c.jsx(At,{type:"text",placeholder:t("caldav.usernamePlaceholder"),value:F,onChange:ye=>z(ye.target.value),className:"max-w-md text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.password")}),c.jsx(At,{type:"password",placeholder:t("caldav.passwordPlaceholder"),value:P,onChange:ye=>L(ye.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.syncInterval")}),c.jsx(At,{type:"number",min:1,max:1440,value:M,onChange:ye=>$(ye.target.value),className:"w-24 text-sm"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(_e,{size:"sm",onClick:be,disabled:Re||!D.trim()||!F.trim()||!P.trim(),children:[s.isPending?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"mr-2 animate-spin"}):null,t("caldav.connectButton")]}),c.jsx(_e,{variant:"ghost",size:"sm",onClick:Ce,disabled:Re,children:t("caldav.cancelButton")})]})]})}),c.jsx(jn,{value:"google",children:c.jsxs("div",{className:"space-y-3 pt-2",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.accountName")}),c.jsx(At,{type:"text",placeholder:t("caldav.googleAccountNamePlaceholder")??"Google Calendar",value:W,onChange:ye=>Y(ye.target.value),className:"max-w-md text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.googleClientId")}),c.jsx(At,{type:"text",placeholder:t("caldav.googleClientIdPlaceholder"),value:q,onChange:ye=>K(ye.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.googleClientSecret")}),c.jsx(At,{type:"password",placeholder:t("caldav.googleClientSecretPlaceholder"),value:X,onChange:ye=>U(ye.target.value),className:"max-w-md font-mono text-sm"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"block text-xs text-muted-foreground",children:t("caldav.syncInterval")}),c.jsx(At,{type:"number",min:1,max:1440,value:J,onChange:ye=>te(ye.target.value),className:"w-24 text-sm"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(_e,{size:"sm",onClick:ge,disabled:Re||ee||!q.trim()||!X.trim(),children:[a.isPending||f.isPending||ee?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"mr-2 animate-spin"}):null,t("caldav.connectGoogleButton")]}),c.jsx(_e,{variant:"ghost",size:"sm",onClick:Ce,disabled:Re,children:t("caldav.cancelButton")})]}),c.jsxs("details",{className:"text-xs text-muted-foreground max-w-lg",children:[c.jsx("summary",{className:"cursor-pointer hover:text-foreground font-medium",children:t("caldav.googleSetupHelp")}),c.jsxs("ol",{className:"mt-2 space-y-1.5 list-none pl-0",children:[c.jsx("li",{children:t("caldav.googleStep1")}),c.jsx("li",{children:t("caldav.googleStep2")}),c.jsx("li",{children:t("caldav.googleStep3")}),c.jsx("li",{children:t("caldav.googleStep4")}),c.jsx("li",{children:t("caldav.googleStep5")}),c.jsx("li",{className:"pl-4 font-mono text-[11px] bg-muted/50 rounded px-2 py-1 w-fit",children:t("caldav.googleCallbackNote",{callbackUrl:`http://${window.location.hostname}:${y.data}/api/caldav/oauth/callback`})}),c.jsx("li",{children:t("caldav.googleStep6")})]})]})]})})]})}),c.jsxs("details",{className:"ml-4 sm:ml-44 text-sm text-muted-foreground",children:[c.jsx("summary",{className:"cursor-pointer hover:text-foreground",children:t("caldav.setupInstructions")}),c.jsxs("div",{className:"mt-2 space-y-2 text-xs",children:[c.jsx("p",{children:t("caldav.helpIntro")}),c.jsxs("ul",{className:"ml-4 list-disc space-y-1",children:[c.jsxs("li",{children:[c.jsx("strong",{children:"Nextcloud:"})," https://cloud.example.com/remote.php/dav"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"Radicale:"})," http://localhost:5232"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"Baikal:"})," https://baikal.example.com/dav.php"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"iCloud:"})," https://caldav.icloud.com (use app-specific password)"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"Google:"})," Use the Google Calendar tab with OAuth2"]})]}),c.jsx("p",{children:t("caldav.helpNote")})]})]})]})}function YNt({clientId:e,onClientIdChange:t,clientIdSaved:n,clientSecret:r,onClientSecretChange:i,clientSecretSaved:s,isLoading:a,onSaveCredentials:o}){const{t:l}=Ot("settings"),{data:u,refetch:d}=k5(),f=_Nt(),h=TNt(),m=uRe(),[g,y]=x.useState(!1),[v,_]=x.useState(""),[S,E]=x.useState(!1),[T,k]=x.useState(null),[w,A]=x.useState(""),[R,I]=x.useState(!1),[D,j]=x.useState(null),F=x.useRef(null),z=async()=>{if(!v.trim()){rt.error(l("google.nameRequired","Account name is required"));return}try{E(!0);const $=window.open("about:blank","_blank","width=600,height=700");try{await o?.();const W=await h.mutateAsync({accountName:v.trim()});$&&!$.closed?$.location.href=W.authUrl:window.location.href=W.authUrl}catch(W){throw $?.close(),W}F.current=setInterval(async()=>{const W=u?.length??0;await d(),((await d()).data?.length??0)>W&&(clearInterval(F.current),F.current=null,E(!1),y(!1),_(""),rt.success(l("google.accountAdded","Google account connected")))},2e3),setTimeout(()=>{F.current&&(clearInterval(F.current),F.current=null,E(!1))},12e4)}catch($){E(!1),rt.error(String($))}},P=async $=>{try{await f.mutateAsync($),rt.success(l("google.accountDeleted","Google account deleted"))}catch(W){rt.error(String(W))}},L=async $=>{try{await m.mutateAsync({id:$,name:w}),k(null),rt.success(l("common.saved","Saved"))}catch(W){rt.error(String(W))}},M=async $=>{try{j($);const W=window.open("about:blank","_blank","width=600,height=700");try{await o?.();const q=await h.mutateAsync({accountId:$});W&&!W.closed?W.location.href=q.authUrl:window.location.href=q.authUrl}catch(q){throw W?.close(),q}const Y=setInterval(async()=>{const{data:q}=await d(),K=q?.find(X=>X.id===$);K&&!K.needsReauth&&(clearInterval(Y),j(null),rt.success(l("google.accountReconnected","Google account reconnected")))},2e3);setTimeout(()=>{clearInterval(Y),j(null)},12e4)}catch(W){j(null),rt.error(String(W))}};return c.jsxs("div",{className:"space-y-4",children:[c.jsxs(ug,{open:R,onOpenChange:I,children:[c.jsxs(dg,{className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[c.jsx(Z,{icon:R?Ts:Bl,size:12,strokeWidth:2}),l("google.setupGuideTitle","How to set up Google OAuth credentials")]}),c.jsx(fg,{children:c.jsxs("ol",{className:"mt-2 ml-4 space-y-1.5 text-xs text-muted-foreground list-decimal list-outside",children:[c.jsx("li",{children:c.jsx(yS,{i18nKey:"google.setupGuideStep1",ns:"settings",defaults:"Go to <link>Google Cloud Console</link>",components:{link:c.jsx("a",{href:"https://console.cloud.google.com/",target:"_blank",rel:"noopener noreferrer",className:"text-accent underline underline-offset-2"})}})}),c.jsx("li",{children:l("google.setupGuideStep2","Create a new project (or select an existing one)")}),c.jsx("li",{children:c.jsx(yS,{i18nKey:"google.setupGuideStep3",ns:"settings",defaults:"Enable the <strong>Google Calendar API</strong> and <strong>Gmail API</strong>",components:{strong:c.jsx("strong",{className:"text-foreground"})}})}),c.jsx("li",{children:c.jsx(yS,{i18nKey:"google.setupGuideStep4",ns:"settings",defaults:"Go to <strong>APIs & Services \\u2192 Credentials</strong>",components:{strong:c.jsx("strong",{className:"text-foreground"})}})}),c.jsx("li",{children:c.jsx(yS,{i18nKey:"google.setupGuideStep5",ns:"settings",defaults:"Create an <strong>OAuth 2.0 Client ID</strong> (type: Web application)",components:{strong:c.jsx("strong",{className:"text-foreground"})}})}),c.jsx("li",{children:c.jsx(yS,{i18nKey:"google.setupGuideStep6",ns:"settings",defaults:"Add authorized redirect URI: <code>{{redirectUri}}</code>",values:{redirectUri:`${window.location.origin}/api/google/oauth/callback`},components:{code:c.jsx("code",{className:"bg-muted px-1 py-0.5 rounded text-[10px]"})}})}),c.jsx("li",{children:l("google.setupGuideStep7","Copy the Client ID and Client Secret into the fields below")})]})})]}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:l("fields.google.clientId","Google ID")}),c.jsx("div",{className:"flex flex-1 items-center gap-2",children:c.jsxs("div",{className:"relative flex-1",children:[c.jsx(At,{value:e,onChange:$=>t($.target.value),placeholder:"your-app.apps.googleusercontent.com",disabled:a,className:"flex-1 pr-8 font-mono text-sm"}),n&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(Z,{icon:hr,size:14,strokeWidth:2})})]})})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:l("fields.google.clientIdDescription","OAuth Client ID from Google Cloud Console")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:l("fields.google.clientSecret","Google Secret")}),c.jsx("div",{className:"flex flex-1 items-center gap-2",children:c.jsxs("div",{className:"relative flex-1",children:[c.jsx(At,{type:"password",value:r,onChange:$=>i($.target.value),placeholder:l("caldav.googleClientSecretPlaceholder"),disabled:a,className:"flex-1 pr-8 font-mono text-sm"}),s&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(Z,{icon:hr,size:14,strokeWidth:2})})]})})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:l("fields.google.clientSecretDescription","OAuth Client Secret for Google Calendar & Gmail")})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h3",{className:"text-sm font-medium",children:l("google.title","Google Accounts")}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>y(!g),children:[c.jsx(Z,{icon:Ic,className:"mr-1 h-3.5 w-3.5"}),l("google.addAccount","Add Google Account")]})]}),g&&c.jsxs("div",{className:"border rounded-lg p-4 space-y-3",children:[c.jsxs("div",{children:[c.jsx("label",{className:"text-xs text-muted-foreground",children:l("google.accountName","Account Name")}),c.jsx(At,{value:v,onChange:$=>_($.target.value),placeholder:"My Google Account",className:"mt-1"})]}),c.jsx("p",{className:"text-xs text-muted-foreground",children:l("google.oauthNote","You will be redirected to Google to authorize access to Calendar and Gmail.")}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(_e,{onClick:z,disabled:S||!v.trim(),size:"sm",children:S?c.jsxs(c.Fragment,{children:[c.jsx(Z,{icon:Nt,className:"mr-1 h-3.5 w-3.5 animate-spin"}),l("google.connecting","Connecting...")]}):l("google.connect","Connect with Google")}),c.jsx(_e,{variant:"ghost",size:"sm",onClick:()=>{y(!1),_(""),E(!1),F.current&&(clearInterval(F.current),F.current=null)},children:l("common:buttons.cancel","Cancel")})]})]}),(!u||u.length===0)&&!g&&c.jsx("p",{className:"text-sm text-muted-foreground",children:l("google.noAccounts","No Google accounts configured.")}),u?.map($=>c.jsxs("div",{className:"border rounded-lg p-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1",children:T===$.id?c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(At,{value:w,onChange:W=>A(W.target.value),className:"h-7 text-sm",autoFocus:!0,onKeyDown:W=>{W.key==="Enter"&&L($.id),W.key==="Escape"&&k(null)}}),c.jsx(_e,{variant:"ghost",size:"sm",onClick:()=>L($.id),children:c.jsx(Z,{icon:hr,className:"h-3.5 w-3.5"})}),c.jsx(_e,{variant:"ghost",size:"sm",onClick:()=>k(null),children:c.jsx(Z,{icon:Tn,className:"h-3.5 w-3.5"})})]}):c.jsxs("div",{className:"cursor-pointer",onClick:()=>{k($.id),A($.name)},children:[c.jsx("span",{className:"font-medium text-sm",children:$.name}),$.email&&c.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:$.email})]})}),c.jsx(_e,{variant:"ghost",size:"sm",onClick:()=>P($.id),title:l("google.delete","Delete"),children:c.jsx(Z,{icon:ks,className:"h-3.5 w-3.5 text-destructive"})})]}),$.needsReauth&&c.jsxs("div",{className:"mt-3 flex items-start gap-2 rounded-md bg-destructive/10 p-3",children:[c.jsx(Z,{icon:wr,className:"h-4 w-4 text-destructive mt-0.5 shrink-0"}),c.jsxs("div",{className:"flex-1 space-y-2",children:[c.jsx("p",{className:"text-xs text-destructive",children:l("google.authExpired","Authorization expired. Reconnect to resume sync.")}),c.jsx(_e,{variant:"outline",size:"sm",onClick:()=>M($.id),disabled:D===$.id,children:D===$.id?c.jsxs(c.Fragment,{children:[c.jsx(Z,{icon:Nt,className:"mr-1 h-3.5 w-3.5 animate-spin"}),l("google.reconnecting","Reconnecting...")]}):c.jsxs(c.Fragment,{children:[c.jsx(Z,{icon:aze,className:"mr-1 h-3.5 w-3.5"}),l("google.reconnect","Reconnect")]})})]})]})]},$.id))]})}function XNt(){const{t:e}=Ot("settings"),{data:t}=k5(),n=SNt(),r=wNt(),i=ENt(),s=async(o,l)=>{try{l?(await n.mutateAsync(o),rt.success(e("google.calendarEnabled","Calendar sync enabled"))):(await r.mutateAsync(o),rt.success(e("google.calendarDisabled","Calendar sync disabled")))}catch(u){rt.error(String(u))}},a=async o=>{try{await i.mutateAsync(o),rt.success(e("google.syncComplete","Calendar sync complete"))}catch(l){rt.error(String(l))}};return!t||t.length===0?c.jsxs("div",{className:"space-y-2",children:[c.jsx("h3",{className:"text-sm font-medium",children:e("google.calendarSync","Calendar Sync")}),c.jsxs("p",{className:"text-sm text-muted-foreground",children:[e("google.noAccountsCalendar","No Google accounts connected.")," ",c.jsx(Pr,{to:"/settings",search:{tab:void 0},className:"text-accent underline underline-offset-2",children:e("google.addInGeneral","Add one in General settings")})]})]}):c.jsxs("div",{className:"space-y-4",children:[c.jsx("h3",{className:"text-sm font-medium",children:e("google.calendarSync","Calendar Sync")}),t.map(o=>c.jsxs("div",{className:"border rounded-lg p-4 space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium text-sm",children:o.name}),o.email&&c.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:o.email})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(_e,{variant:"ghost",size:"sm",onClick:()=>a(o.id),disabled:!o.calendarEnabled||i.isPending,title:e("google.sync","Sync"),children:c.jsx(Z,{icon:i.isPending?Nt:lp,className:`h-3.5 w-3.5 ${i.isPending?"animate-spin":""}`})}),c.jsx(Xr,{checked:o.calendarEnabled??!1,onCheckedChange:l=>s(o.id,l)})]})]}),o.needsReauth&&c.jsxs("div",{className:"flex items-start gap-1.5",children:[c.jsx(Z,{icon:wr,className:"h-3.5 w-3.5 text-destructive mt-0.5"}),c.jsxs("p",{className:"text-xs text-destructive",children:[e("google.authExpiredCalendar","Authorization expired.")," ",c.jsx(Pr,{to:"/settings",search:{tab:void 0},className:"text-accent underline underline-offset-2",children:e("google.reconnectInGeneral","Reconnect in General settings")})]})]}),o.lastCalendarSyncError&&!o.needsReauth&&c.jsx("p",{className:"text-xs text-destructive",children:o.lastCalendarSyncError}),o.lastCalendarSyncAt&&!o.lastCalendarSyncError&&c.jsxs("p",{className:"text-xs text-muted-foreground",children:[e("google.lastSync","Last sync"),":"," ",new Date(o.lastCalendarSyncAt).toLocaleString()]})]},o.id))]})}function QNt({isLoading:e=!1}){const{t}=Ot("settings"),{data:n}=yZ(),{data:r}=dRe(),{data:i}=zNt(),s=UNt(),a=HNt(),o=VNt(),l=WNt(),[u,d]=x.useState(!1),[f,h]=x.useState(""),[m,g]=x.useState(""),[y,v]=x.useState(null);if(!n||n.length<2)return null;const _=new Map((r??[]).map(I=>[I.id,I])),S=new Map;for(const I of n){const D=I.accountId??"unknown";S.has(D)||S.set(D,[]),S.get(D).push(I)}const E=I=>n.find(j=>j.id===I)?.displayName??I,T=async()=>{if(!f||!m){rt.error(t("caldav.copyRulesSelectBoth"));return}if(f===m){rt.error(t("caldav.copyRulesSameCalendar"));return}try{await s.mutateAsync({sourceCalendarId:f,destCalendarId:m}),d(!1),h(""),g(""),rt.success(t("caldav.copyRuleCreated"))}catch(I){rt.error(I instanceof Error?I.message:t("caldav.copyRuleCreateFailed"))}},k=async(I,D)=>{try{await a.mutateAsync({id:I,enabled:D})}catch(j){rt.error(j instanceof Error?j.message:t("caldav.copyRuleUpdateFailed"))}},w=async I=>{try{await o.mutateAsync(I),rt.success(t("caldav.copyRuleDeleted"))}catch(D){rt.error(D instanceof Error?D.message:t("caldav.copyRuleDeleteFailed"))}},A=async I=>{v(I);try{const D=await l.mutateAsync(I);rt.success(t("caldav.copyRuleExecuted",{created:D.created,updated:D.updated}))}catch(D){rt.error(D instanceof Error?D.message:t("caldav.copyRuleExecuteFailed"))}finally{v(null)}},R=(I,D,j)=>c.jsxs("select",{id:j,value:I,onChange:F=>D(F.target.value),className:"h-9 rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring",children:[c.jsx("option",{value:"",children:t("caldav.copyRulesSelectCalendar")}),Array.from(S.entries()).map(([F,z])=>{const L=_.get(F)?.name??F;return c.jsx("optgroup",{label:L,children:z.map(M=>c.jsx("option",{value:M.id,children:M.displayName??M.id},M.id))},F)})]});return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h3",{className:"text-sm font-medium",children:t("caldav.copyRules")}),!u&&c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>d(!0),disabled:e,children:[c.jsx(Z,{icon:Ic,size:14,strokeWidth:2,className:"mr-1.5"}),t("caldav.addRule")]})]}),u&&c.jsxs("div",{className:"rounded-md border border-border p-3 space-y-3",children:[c.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("label",{htmlFor:"source-calendar",className:"text-xs text-muted-foreground",children:t("caldav.copyRulesSource")}),R(f,h,"source-calendar")]}),c.jsx("span",{className:"pb-2 text-sm text-muted-foreground",children:"→"}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("label",{htmlFor:"dest-calendar",className:"text-xs text-muted-foreground",children:t("caldav.copyRulesDest")}),R(m,g,"dest-calendar")]})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(_e,{size:"sm",onClick:T,disabled:s.isPending||!f||!m,children:[s.isPending&&c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"mr-1.5 animate-spin"}),t("caldav.addRule")]}),c.jsx(_e,{variant:"ghost",size:"sm",onClick:()=>{d(!1),h(""),g("")},disabled:s.isPending,children:t("caldav.cancelButton")})]})]}),i&&i.length>0?c.jsx("div",{className:"space-y-2",children:i.map(I=>{const D=y===I.id;return c.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-border px-3 py-2",children:[c.jsx(Xr,{checked:I.enabled!==!1,onCheckedChange:j=>k(I.id,j),disabled:a.isPending}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("span",{className:"text-sm",children:[E(I.sourceCalendarId),c.jsx("span",{className:"mx-1.5 text-muted-foreground",children:"→"}),E(I.destCalendarId)]}),I.lastExecutedAt&&c.jsx("p",{className:"text-xs text-muted-foreground",children:t("caldav.copyRulesLastRun",{time:new Date(I.lastExecutedAt).toLocaleString()})})]}),c.jsx(_e,{variant:"outline",size:"sm",onClick:()=>A(I.id),disabled:D||e,title:t("caldav.copyRulesRunNow"),children:D?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(Z,{icon:ix,size:14,strokeWidth:2})}),c.jsx(_e,{variant:"ghost",size:"sm",onClick:()=>w(I.id),disabled:o.isPending||e,title:t("caldav.copyRulesDelete"),children:c.jsx(Z,{icon:ks,size:14,strokeWidth:2,className:"text-destructive"})})]},I.id)})}):c.jsx("p",{className:"text-xs text-muted-foreground",children:t("caldav.copyRulesEmpty")})]})}const ZNt=["general","ai","messaging","calendar"],fU=xa("/settings/")({component:JNt,validateSearch:e=>({tab:ZNt.includes(e.tab)?e.tab:void 0})});function kl({title:e,children:t}){return c.jsxs("div",{className:"film-grain relative rounded-lg border border-border p-4 pt-6",style:{background:"var(--gradient-card)"},children:[c.jsx("span",{className:"absolute -top-2.5 left-3 rounded bg-card px-2 text-xs font-medium text-muted-foreground",children:e}),t]})}function JNt(){const{t:e}=Ot("settings"),{t}=Ot("common"),{tab:n}=fU.useSearch(),r=fU.useNavigate(),i=n||"general",s=He=>{const Wt=He;r({search:Rs=>({...Rs,tab:Wt==="general"?void 0:Wt}),replace:!0})},{data:a,isLoading:o}=RW(),{data:l,isLoading:u}=uD(),{data:d,isLoading:f}=dD(),{data:h,isLoading:m}=fD(),{data:g,isLoading:y}=hD(),{data:v,isLoading:_}=QWe(),{data:S}=ZWe(),{data:E}=JWe(),{data:T,isLoading:k}=NC(),{data:w,isLoading:A}=A1(),{data:R,isLoading:I}=jwe(),{data:D,isLoading:j}=Pwe(),{data:F,isLoading:z}=Lwe(),{data:P}=eqe(),{data:L,isLoading:M}=hqe(),{data:$,isLoading:W}=gqe(),{data:Y,isLoading:q}=rCe(),K=NJe(),{data:X}=yqe(),U=vqe(),{savedLanguage:J,changeLanguage:te}=sCe(),{theme:ee,changeTheme:oe}=dCe(),{data:ae,isLoading:se}=Mwe(),{data:ue,isLoading:de}=Fwe(),{data:ce,isLoading:Ee}=Bwe(),{data:Ie,isLoading:fe}=pD(),{data:be,isLoading:ge}=$we(),{data:Ce,isLoading:Re}=IW(),{data:xe,isLoading:ye}=rqe(),{data:De}=iqe(),{data:ve}=sqe(),{data:Oe,isLoading:Be}=aqe(),{data:Te,isLoading:je}=oqe(),{data:ie,isLoading:Ke}=lqe(),{data:lt,isLoading:Rt}=cqe(),{data:Ye,isLoading:ct}=uqe(),{data:Ve,isLoading:Et}=dqe(),{installed:$e}=yD(),{version:Qe}=xqe(),{data:pt,isLoading:at}=Sqe(),gt=wqe(),We=Eqe(),Xe=DW(),it=fqe(),ot=pqe(),St=bqe(),Xt=mqe(),en=(k5().data??[]).filter(He=>He.gmailEnabled),Fe=It(),[Ue,ut]=x.useState(""),[Kt,wn]=x.useState(""),[pr,Mr]=x.useState("vscode"),[qi,na]=x.useState(""),[ai,Ar]=x.useState(""),[mr,Ji]=x.useState(""),[hi,Bs]=x.useState(""),[es,ts]=x.useState(""),[nt,Fn]=x.useState("claude"),[rn,Yn]=x.useState(null),[Nr,oi]=x.useState("build"),[Jn,Fr]=x.useState("plan"),[sr,Br]=x.useState(!0),[Si,ml]=x.useState(""),[tn,Na]=x.useState(!1),[ns,Oa]=x.useState(!1),[nr,Ns]=x.useState(!0),[hs,Uu]=x.useState(!0),[$o,Bc]=x.useState(!0),[Ra,rs]=x.useState(!1),[wi,ps]=x.useState(!1),[zo,$c]=x.useState(""),[Ia,to]=x.useState(!1),[gl,qt]=x.useState(""),[Le,vt]=x.useState(!1),[pn,En]=x.useState(""),[on,_o]=x.useState(""),[ms,ra]=x.useState(!1),[gs,zc]=x.useState(!1),[bl,sc]=x.useState(!1),[N,H]=x.useState(""),[ne,le]=x.useState(!1),[Se,qe]=x.useState(!1),[Je,Dt]=x.useState(!1),[Mt,Rn]=x.useState(""),[Bn,Kr]=x.useState("glm-4.5-air"),[Bi,ac]=x.useState("glm-4.7"),[oc,bs]=x.useState("glm-4.7"),[Os,yl]=x.useState(""),[Uc,Tk]=x.useState(""),[Cp,tv]=x.useState("worktree"),[jd,Sg]=x.useState(!0),[wg,Ak]=x.useState(""),[E_,Nk]=x.useState(null),[Hc,Ok]=x.useState("claude"),[nv,Rk]=x.useState("sonnet"),[rv,Ik]=x.useState("haiku"),[Hu,Dk]=x.useState(null),[iv,jk]=x.useState(null),[sv,av]=x.useState("~/.fulcrum/documents"),[Eg,Pk]=x.useState(!1),[ov,C_]=x.useState("09:00"),[lv,Lk]=x.useState(""),[cv,Mk]=x.useState("18:00"),[uv,Fk]=x.useState(""),[k_,T_]=x.useState(!1),[Bk,Cg]=x.useState(!1),[kp,$k]=x.useState(!1),kg=x.useRef(null);x.useEffect(()=>{a!==void 0&&ut(String(a)),l!==void 0&&wn(l),d!==void 0&&Mr(d),h!==void 0&&na(h),g!==void 0&&Ar(String(g)),v!==void 0&&Ji(v),S!==void 0&&Bs(S),E!==void 0&&ts(E),T!==void 0&&Fn(T),w!==void 0&&Yn(w),R!==void 0&&oi(R),D!==void 0&&Fr(D),F!==void 0&&Br(F),P!==void 0&&ml(P??"")},[a,l,d,h,g,v,S,E,T,w,R,D,F,P]),x.useEffect(()=>{L&&(Ns(L.enabled),Uu(L.toast?.enabled??!0),Bc(L.desktop?.enabled??!0),rs(L.sound?.enabled??!1),Cg(!!L.sound?.customSoundFile),ps(L.slack?.enabled??!1),$c(L.slack?.webhookUrl??""),to(L.discord?.enabled??!1),qt(L.discord?.webhookUrl??""),vt(L.pushover?.enabled??!1),En(L.pushover?.appToken??""),_o(L.pushover?.userKey??""),ra(L.whatsapp?.enabled??!1),zc(L.telegram?.enabled??!1),sc(L.gmail?.enabled??!1),H(L.gmail?.googleAccountId??""),le(L.slack?.useMessagingChannel??!1),qe(L.discord?.useMessagingChannel??!1))},[L]),x.useEffect(()=>{$&&(Dt($.enabled),Rn($.apiKey??""),Kr($.haikuModel),ac($.sonnetModel),bs($.opusModel))},[$]),x.useEffect(()=>{Y?.cloudflareApiToken!==void 0&&yl(Y.cloudflareApiToken??""),Y?.cloudflareAccountId!==void 0&&Tk(Y.cloudflareAccountId??"")},[Y]),x.useEffect(()=>{ae!==void 0&&tv(ae),ue!==void 0&&Sg(ue),ce!==void 0&&Ak(ce??"")},[ae,ue,ce]),x.useEffect(()=>{Ie!==void 0&&Nk(Ie)},[Ie]),x.useEffect(()=>{be!==void 0&&Ok(be),Ce!==void 0&&Rk(Ce),xe!==void 0&&Ik(xe),De!==void 0&&Dk(De),ve!==void 0&&jk(ve),Oe!==void 0&&av(Oe)},[be,Ce,xe,De,ve,Oe]),x.useEffect(()=>{Te!==void 0&&Pk(Te),ie!==void 0&&C_(ie),lt!==void 0&&Lk(lt),Ye!==void 0&&Mk(Ye),Ve!==void 0&&Fk(Ve)},[Te,ie,lt,Ye,Ve]);const sn=o||u||f||m||y||_||k||A||I||j||z||M||W||q||se||de||Ee||fe||ge||Re||ye||Be||je||Ke||Rt||ct||Et,A_=$&&(Je!==$.enabled||Mt!==($.apiKey??"")||Bn!==$.haikuModel||Bi!==$.sonnetModel||oc!==$.opusModel),N_=Cp!==ae||jd!==ue||wg!==(ce??""),O_=E_!==Ie,Hf=Hc!==be||nv!==Ce||rv!==xe||Hu!==De||iv!==ve||sv!==Oe,zk=Eg!==Te||ov!==ie||lv!==lt||cv!==Ye||uv!==Ve,Uk=(()=>{const He=Y?.cloudflareApiToken??"",Wt=Y?.cloudflareAccountId??"",Rs=Os!==He&&!Os.match(/^•+$/),Ho=Uc!==Wt&&!Uc.match(/^•+$/);return Rs||Ho})(),Hk=L&&(nr!==L.enabled||hs!==(L.toast?.enabled??!0)||$o!==(L.desktop?.enabled??!0)||Ra!==(L.sound?.enabled??!1)||wi!==(L.slack?.enabled??!1)||zo!==(L.slack?.webhookUrl??"")||ne!==(L.slack?.useMessagingChannel??!1)||Ia!==(L.discord?.enabled??!1)||gl!==(L.discord?.webhookUrl??"")||Se!==(L.discord?.useMessagingChannel??!1)||Le!==(L.pushover?.enabled??!1)||pn!==(L.pushover?.appToken??"")||on!==(L.pushover?.userKey??"")||ms!==(L.whatsapp?.enabled??!1)||gs!==(L.telegram?.enabled??!1)||bl!==(L.gmail?.enabled??!1)||N!==(L.gmail?.googleAccountId??"")),Vk=pr!==d||qi!==h||ai!==String(g),Wk=nt!==T||rn!==(w??null)||Nr!==R||Jn!==D||sr!==F||Si!==(P??""),Tg=Ue!==String(a)||Kt!==l||mr!==v||hi!==S||es!==E||Wk||Vk||Hk||A_||Uk||N_||O_||Hf||zk,Ag=async()=>{const He=[];hi!==S&&He.push(Xe.mutateAsync({key:Qt.GOOGLE_CLIENT_ID,value:hi||null})),es!==E&&He.push(Xe.mutateAsync({key:Qt.GOOGLE_CLIENT_SECRET,value:es||null})),He.length>0&&await Promise.all(He)},Ej=async()=>{const He=[];if(Ue!==String(a)){const Wt=parseInt(Ue,10);!isNaN(Wt)&&Wt>=1&&Wt<=65535&&He.push(new Promise(Rs=>{Xe.mutate({key:Qt.PORT,value:Wt},{onSettled:Rs})}))}if(Kt!==l&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.DEFAULT_GIT_REPOS_DIR,value:Kt},{onSettled:Wt})})),pr!==d&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.EDITOR_APP,value:pr},{onSettled:Wt})})),qi!==h&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.EDITOR_HOST,value:qi},{onSettled:Wt})})),ai!==String(g)){const Wt=parseInt(ai,10);!isNaN(Wt)&&Wt>=1&&Wt<=65535&&He.push(new Promise(Rs=>{Xe.mutate({key:Qt.EDITOR_SSH_PORT,value:Wt},{onSettled:Rs})}))}if(mr!==v&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.GITHUB_PAT,value:mr},{onSettled:Wt})})),hi!==S&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.GOOGLE_CLIENT_ID,value:hi||null},{onSettled:Wt})})),es!==E&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.GOOGLE_CLIENT_SECRET,value:es||null},{onSettled:Wt})})),nt!==T&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.DEFAULT_AGENT,value:nt},{onSettled:Wt})})),rn!==(w??null)&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.OPENCODE_MODEL,value:rn},{onSettled:Wt})})),Nr!==R&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.OPENCODE_DEFAULT_AGENT,value:Nr},{onSettled:Wt})})),Jn!==D&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.OPENCODE_PLAN_AGENT,value:Jn},{onSettled:Wt})})),sr!==F&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.AGENT_AUTO_SCROLL_TO_BOTTOM,value:sr},{onSettled:Wt})})),Si!==(P??"")&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.CLAUDE_CODE_PATH,value:Si||null},{onSettled:Wt})})),Hk&&He.push(new Promise(Wt=>{ot.mutate({enabled:nr,toast:{enabled:hs},desktop:{enabled:$o},sound:{enabled:Ra},slack:{enabled:wi,webhookUrl:zo,useMessagingChannel:ne},discord:{enabled:Ia,webhookUrl:gl,useMessagingChannel:Se},pushover:{enabled:Le,appToken:pn,userKey:on},whatsapp:{enabled:ms},telegram:{enabled:gs},gmail:{enabled:bl,googleAccountId:N||void 0},_updatedAt:L?._updatedAt},{onSettled:Wt,onError:Rs=>{Rs instanceof zwe&&(rt.warning(e("notifications.conflictWarning")||"Settings changed elsewhere - refreshing"),Fe.invalidateQueries({queryKey:["config","notifications"]}))}})})),A_&&He.push(new Promise(Wt=>{St.mutate({enabled:Je,apiKey:Mt||null,haikuModel:Bn,sonnetModel:Bi,opusModel:oc},{onSettled:Wt})})),N_&&(Cp!==ae&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.DEFAULT_TASK_TYPE,value:Cp},{onSettled:Wt})})),jd!==ue&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.START_WORKTREE_TASKS_IMMEDIATELY,value:jd},{onSettled:Wt})})),wg!==(ce??"")&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.SCRATCH_STARTUP_SCRIPT,value:wg.trim()||null},{onSettled:Wt})}))),O_&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.TIMEZONE,value:E_},{onSettled:Wt})})),Hf&&(Hc!==be&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.ASSISTANT_PROVIDER,value:Hc},{onSettled:Wt})})),nv!==Ce&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.ASSISTANT_MODEL,value:nv},{onSettled:Wt})})),rv!==xe&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.ASSISTANT_OBSERVER_MODEL,value:rv},{onSettled:Wt})})),Hu!==De&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.ASSISTANT_OBSERVER_PROVIDER,value:Hu},{onSettled:Wt})})),iv!==ve&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.ASSISTANT_OBSERVER_OPENCODE_MODEL,value:iv},{onSettled:Wt})})),sv!==Oe&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.ASSISTANT_DOCUMENTS_DIR,value:sv},{onSettled:Wt})}))),zk&&(Eg!==Te&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.ASSISTANT_RITUALS_ENABLED,value:Eg},{onSettled:Wt})})),ov!==ie&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.ASSISTANT_MORNING_RITUAL_TIME,value:ov},{onSettled:Wt})})),lv!==lt&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.ASSISTANT_MORNING_RITUAL_PROMPT,value:lv},{onSettled:Wt})})),cv!==Ye&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.ASSISTANT_EVENING_RITUAL_TIME,value:cv},{onSettled:Wt})})),uv!==Ve&&He.push(new Promise(Wt=>{Xe.mutate({key:Qt.ASSISTANT_EVENING_RITUAL_PROMPT,value:uv},{onSettled:Wt})}))),Uk){const Wt=Y?.cloudflareApiToken??"",Rs=Y?.cloudflareAccountId??"",Ho={};Os!==Wt&&!Os.match(/^•+$/)&&(Ho.cloudflareApiToken=Os||null),Uc!==Rs&&!Uc.match(/^•+$/)&&(Ho.cloudflareAccountId=Uc||null),Object.keys(Ho).length>0&&He.push(new Promise(Vu=>{K.mutate(Ho,{onSettled:Vu})}))}await Promise.all(He),Oa(!0),setTimeout(()=>Oa(!1),2e3)},dv=()=>{it.mutate(Qt.PORT,{onSuccess:He=>{He.value!==null&&ut(String(He.value))}})},qk=()=>{it.mutate(Qt.DEFAULT_GIT_REPOS_DIR,{onSuccess:He=>{He.value&&wn(String(He.value))}})},Gk=()=>{it.mutate(Qt.EDITOR_APP,{onSuccess:He=>{He.value!==null&&He.value!==void 0&&Mr(He.value)}})},R_=()=>{it.mutate(Qt.EDITOR_HOST,{onSuccess:He=>{na(He.value!==null&&He.value!==void 0?String(He.value):"")}})},I_=()=>{it.mutate(Qt.EDITOR_SSH_PORT,{onSuccess:He=>{He.value!==null&&He.value!==void 0&&Ar(String(He.value))}})},Kk=()=>{it.mutate(Qt.GITHUB_PAT,{onSuccess:He=>{Ji(He.value!==null&&He.value!==void 0?String(He.value):"")}})},Yk=()=>{it.mutate(Qt.DEFAULT_AGENT,{onSuccess:He=>{Fn(He.value??"claude")}})},Xk=()=>{it.mutate(Qt.OPENCODE_MODEL,{onSuccess:He=>{Yn(He.value!==null&&He.value!==void 0?String(He.value):null)}})},Cj=()=>{it.mutate(Qt.OPENCODE_DEFAULT_AGENT,{onSuccess:He=>{oi(He.value??"build")}})},kj=()=>{it.mutate(Qt.OPENCODE_PLAN_AGENT,{onSuccess:He=>{Fr(He.value??"plan")}})},Vf=async He=>{Xt.mutate(He,{onSuccess:Wt=>{Wt.success?rt.success(e("notifications.testSuccess",{channel:He})):rt.error(e("notifications.testFailed",{channel:He,error:Wt.error}))},onError:Wt=>{rt.error(e("notifications.testFailed",{channel:He,error:Wt.message}))}})},Tj=async He=>{const Wt=He.target.files?.[0];if(Wt){$k(!0);try{const Rs=new FormData;Rs.append("file",Wt);const Ho=await fetch("/api/uploads/sound",{method:"POST",body:Rs});if(!Ho.ok){const Vu=await Ho.json();throw new Error(Vu.error||"Upload failed")}Cg(!0),rt.success(e("notifications.soundUploaded"))}catch(Rs){rt.error(e("notifications.soundUploadFailed",{error:Rs instanceof Error?Rs.message:"Unknown error"}))}finally{$k(!1),kg.current&&(kg.current.value="")}}},Aj=async()=>{try{if(!(await fetch("/api/uploads/sound",{method:"DELETE"})).ok)throw new Error("Delete failed");Cg(!1),rt.success(e("notifications.soundDeleted"))}catch{rt.error(e("notifications.soundDeleteFailed"))}},Uo=()=>{We.mutate(void 0,{onSuccess:()=>{rt.info(e("version.updateStarted"))},onError:()=>{rt.error(e("version.updateFailed"))}})};return c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsx("div",{className:"flex-1 overflow-hidden",children:c.jsxs(nl,{value:i,onValueChange:s,className:"flex h-full flex-col",children:[c.jsxs("div",{className:"film-grain relative flex shrink-0 items-center border-b border-border px-4",style:{background:"var(--gradient-header)"},children:[c.jsxs(rl,{className:"justify-start gap-1 bg-transparent rounded-none h-10",children:[c.jsxs(In,{value:"general",className:"gap-1.5 data-[state=active]:bg-muted",children:[c.jsx(Z,{icon:VO,size:14,strokeWidth:2}),c.jsx("span",{className:"max-sm:hidden",children:e("tabs.general")})]}),c.jsxs(In,{value:"ai",className:"gap-1.5 data-[state=active]:bg-muted",children:[c.jsx(Z,{icon:R_e,size:14,strokeWidth:2}),c.jsx("span",{className:"max-sm:hidden",children:e("tabs.ai")})]}),c.jsxs(In,{value:"messaging",className:"gap-1.5 data-[state=active]:bg-muted",children:[c.jsx(Z,{icon:yC,size:14,strokeWidth:2}),c.jsx("span",{className:"max-sm:hidden",children:e("tabs.messaging")})]}),c.jsxs(In,{value:"calendar",className:"gap-1.5 data-[state=active]:bg-muted",children:[c.jsx(Z,{icon:op,size:14,strokeWidth:2}),c.jsx("span",{className:"max-sm:hidden",children:e("tabs.calendar")})]})]}),c.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[Qe&&c.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:["v",Qe]}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",onClick:()=>gt.mutate(),disabled:at||gt.isPending,title:e("version.refresh"),"aria-label":e("version.refresh"),children:c.jsx(Z,{icon:lp,size:14,strokeWidth:2,className:gt.isPending?"animate-spin":""})}),at&&c.jsxs("div",{className:"flex h-6 items-center gap-1.5 rounded-full bg-muted/50 px-2.5 text-xs text-muted-foreground",children:[c.jsx(Z,{icon:Nt,size:12,strokeWidth:2,className:"animate-spin"}),c.jsx("span",{children:e("version.checkingForUpdates")})]}),pt?.updateAvailable&&pt.latestVersion&&c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("span",{className:"flex h-6 items-center gap-1.5 rounded-full bg-primary/10 px-2.5 text-xs font-medium text-primary border border-primary/20",children:[c.jsx(Z,{icon:lse,size:12,strokeWidth:2.5}),e("version.updateAvailable",{version:pt.latestVersion})]}),c.jsx(_e,{size:"sm",className:"h-6 gap-1.5 px-2.5 text-xs",disabled:We.isPending||We.isSuccess,onClick:Uo,children:We.isPending?c.jsxs(c.Fragment,{children:[c.jsx(Z,{icon:Nt,size:12,strokeWidth:2,className:"animate-spin"}),e("version.updating")]}):c.jsxs(c.Fragment,{children:[c.jsx(Z,{icon:lse,size:12,strokeWidth:2}),e("version.update")]})}),c.jsx(_e,{variant:"outline",size:"sm",className:"h-6 gap-1.5 px-2.5 text-xs",onClick:()=>{pt.releaseUrl&&window.open(pt.releaseUrl,"_blank")},children:e("version.viewRelease")})]}),!at&&pt&&!pt.updateAvailable&&c.jsxs("span",{className:"flex h-6 items-center gap-1.5 rounded-full bg-green-500/10 px-2.5 text-xs font-medium text-green-600 dark:text-green-400 border border-green-500/20",children:[c.jsx(Z,{icon:hr,size:12,strokeWidth:2.5}),e("version.upToDate")]})]})]}),c.jsx(jn,{value:"general",className:"flex-1 overflow-auto p-6",children:c.jsxs("div",{className:"mx-auto max-w-5xl space-y-4",children:[c.jsx(kl,{title:e("sections.appearance"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.language.label")}),c.jsxs(Qr,{value:J??"auto",onValueChange:He=>te(He==="auto"?null:He),children:[c.jsx(Jr,{className:"w-40",children:c.jsx(Zr,{})}),c.jsxs(ei,{children:[c.jsx(jt,{value:"auto",children:e("fields.language.options.auto")}),c.jsx(jt,{value:"en",children:e("fields.language.options.en")}),c.jsx(jt,{value:"zh",children:e("fields.language.options.zh")})]})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.language.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.theme.label")}),c.jsxs(Qr,{value:ee??"system",onValueChange:He=>oe(He),children:[c.jsx(Jr,{className:"w-40",children:c.jsx(Zr,{})}),c.jsxs(ei,{children:[c.jsx(jt,{value:"system",children:e("fields.theme.options.system")}),c.jsx(jt,{value:"light",children:e("fields.theme.options.light")}),c.jsx(jt,{value:"dark",children:e("fields.theme.options.dark")})]})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.theme.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.timezone.label")}),c.jsxs(Qr,{value:E_??"auto",onValueChange:He=>Nk(He==="auto"?null:He),children:[c.jsx(Jr,{className:"w-56",children:c.jsx(Zr,{})}),c.jsxs(ei,{children:[c.jsx(jt,{value:"auto",children:e("fields.timezone.options.auto")}),c.jsx(jt,{value:"America/New_York",children:"America/New_York (EST/EDT)"}),c.jsx(jt,{value:"America/Chicago",children:"America/Chicago (CST/CDT)"}),c.jsx(jt,{value:"America/Denver",children:"America/Denver (MST/MDT)"}),c.jsx(jt,{value:"America/Los_Angeles",children:"America/Los_Angeles (PST/PDT)"}),c.jsx(jt,{value:"America/Anchorage",children:"America/Anchorage (AKST/AKDT)"}),c.jsx(jt,{value:"Pacific/Honolulu",children:"Pacific/Honolulu (HST)"}),c.jsx(jt,{value:"Europe/London",children:"Europe/London (GMT/BST)"}),c.jsx(jt,{value:"Europe/Paris",children:"Europe/Paris (CET/CEST)"}),c.jsx(jt,{value:"Europe/Berlin",children:"Europe/Berlin (CET/CEST)"}),c.jsx(jt,{value:"Asia/Tokyo",children:"Asia/Tokyo (JST)"}),c.jsx(jt,{value:"Asia/Shanghai",children:"Asia/Shanghai (CST)"}),c.jsx(jt,{value:"Asia/Singapore",children:"Asia/Singapore (SGT)"}),c.jsx(jt,{value:"Australia/Sydney",children:"Australia/Sydney (AEST/AEDT)"}),c.jsx(jt,{value:"Pacific/Auckland",children:"Pacific/Auckland (NZST/NZDT)"}),c.jsx(jt,{value:"UTC",children:"UTC"})]})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.timezone.description")})]})]})}),c.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[c.jsx(kl,{title:e("sections.editor"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.editor.app.label")}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Qr,{value:pr,onValueChange:He=>Mr(He),children:[c.jsx(Jr,{className:"w-32",children:c.jsx(Zr,{})}),c.jsxs(ei,{children:[c.jsx(jt,{value:"vscode",children:"VS Code"}),c.jsx(jt,{value:"cursor",children:"Cursor"}),c.jsx(jt,{value:"windsurf",children:"Windsurf"}),c.jsx(jt,{value:"zed",children:"Zed"}),c.jsx(jt,{value:"antigravity",children:"Antigravity"})]})]}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:Gk,disabled:sn||it.isPending,title:t("buttons.reset"),children:c.jsx(Z,{icon:Bd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:e("fields.editor.app.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.editor.host.label")}),c.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[c.jsx(At,{value:qi,onChange:He=>na(He.target.value),placeholder:e("fields.editor.host.placeholder"),disabled:sn,className:"flex-1 font-mono text-sm"}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:R_,disabled:sn||it.isPending,title:t("buttons.reset"),children:c.jsx(Z,{icon:Bd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:e("fields.editor.host.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.editor.sshPort.label")}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(At,{type:"number",min:1,max:65535,value:ai,onChange:He=>Ar(He.target.value),placeholder:"22",disabled:sn,className:"w-20 font-mono text-sm"}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:I_,disabled:sn||it.isPending,title:t("buttons.reset"),children:c.jsx(Z,{icon:Bd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:e("fields.editor.sshPort.description")})]})]})}),c.jsx(kl,{title:e("sections.integrations"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.github.label")}),c.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[c.jsxs("div",{className:"relative flex-1",children:[c.jsx(At,{type:"password",value:mr,onChange:He=>Ji(He.target.value),placeholder:"ghp_...",disabled:sn,className:"flex-1 pr-8 font-mono text-sm"}),!!v&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(Z,{icon:hr,size:14,strokeWidth:2})})]}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:Kk,disabled:sn||it.isPending,title:t("buttons.reset"),children:c.jsx(Z,{icon:Bd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:e("fields.github.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.cloudflare.label")}),c.jsx("div",{className:"flex flex-1 items-center gap-2",children:c.jsxs("div",{className:"relative flex-1",children:[c.jsx(At,{type:"password",value:Os,onChange:He=>yl(He.target.value),placeholder:e("fields.cloudflare.placeholder"),disabled:sn,className:"flex-1 pr-8 font-mono text-sm"}),!!Y?.cloudflareApiToken&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(Z,{icon:hr,size:14,strokeWidth:2})})]})})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:e("fields.cloudflare.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:"Account ID"}),c.jsx("div",{className:"flex flex-1 items-center gap-2",children:c.jsxs("div",{className:"relative flex-1",children:[c.jsx(At,{type:"password",value:Uc,onChange:He=>Tk(He.target.value),placeholder:"CF Account ID",disabled:sn,className:"flex-1 pr-8 font-mono text-sm"}),!!Y?.cloudflareAccountId&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(Z,{icon:hr,size:14,strokeWidth:2})})]})})]}),c.jsxs("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:["Required for Cloudflare Tunnel. Find in your dashboard URL: dash.cloudflare.com/","<account_id>","/..."]})]}),c.jsx(YNt,{clientId:hi,onClientIdChange:Bs,clientIdSaved:!!S,clientSecret:es,onClientSecretChange:ts,clientSecretSaved:!!E,isLoading:sn,onSaveCredentials:Ag})]})})]}),c.jsx(kl,{title:e("sections.tasks"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.tasks.defaultType.label")}),c.jsxs(Qr,{value:Cp,onValueChange:He=>tv(He),children:[c.jsx(Jr,{className:"w-40",children:c.jsx(Zr,{children:He=>e(`fields.tasks.defaultType.options.${He}`)||He})}),c.jsxs(ei,{children:[c.jsx(jt,{value:"worktree",children:e("fields.tasks.defaultType.options.worktree")}),c.jsx(jt,{value:"manual",children:e("fields.tasks.defaultType.options.manual")}),c.jsx(jt,{value:"scratch",children:e("fields.tasks.defaultType.options.scratch")})]})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.tasks.defaultType.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.tasks.startImmediately.label")}),c.jsx(Xr,{checked:jd,onCheckedChange:Sg,disabled:sn})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.tasks.startImmediately.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0 sm:pt-2",children:e("fields.tasks.scratchStartupScript.label")}),c.jsx(Oc,{value:wg,onChange:He=>Ak(He.target.value),placeholder:"export ENV_VAR=value",className:"font-mono text-xs min-h-[60px]",rows:2,disabled:sn})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.tasks.scratchStartupScript.description")})]})]})}),c.jsx(kl,{title:e("sections.server"),children:c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.port.label")}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(At,{type:"number",min:1,max:65535,value:Ue,onChange:He=>ut(He.target.value),placeholder:"7777",disabled:sn,className:"w-24 font-mono text-sm"}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:dv,disabled:sn||it.isPending,title:t("buttons.reset"),children:c.jsx(Z,{icon:Bd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.port.description")})]})}),c.jsx(kl,{title:e("sections.paths"),children:c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.gitReposDir.label")}),c.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[c.jsx(At,{value:Kt,onChange:He=>wn(He.target.value),placeholder:"~/projects",disabled:sn,className:"flex-1 font-mono text-sm"}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Na(!0),disabled:sn,title:t("buttons.browse"),children:c.jsx(Z,{icon:Zs,size:14,strokeWidth:2})}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:qk,disabled:sn||it.isPending,title:t("buttons.reset"),children:c.jsx(Z,{icon:Bd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.gitReposDir.description")})]})}),X?.enabled&&c.jsx(kl,{title:e("sections.developer"),children:c.jsx("div",{className:"space-y-1",children:c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[c.jsx("div",{className:"flex-1",children:c.jsx("p",{className:"text-sm text-muted-foreground",children:e("developer.restartDescription")})}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>{const He=X?.startedAt;T_(!0),U.mutate(void 0,{onSuccess:()=>{(async()=>{for(let Ho=0;Ho<120;Ho++){await new Promise(Vu=>setTimeout(Vu,500));try{const Vu=await fetch("/api/config/developer-mode");if(Vu.ok&&(await Vu.json()).startedAt!==He){window.location.reload();return}}catch{}}T_(!1),rt.error(e("developer.restartFailed"),{description:e("developer.checkLogs")})})()},onError:Wt=>{T_(!1),rt.error(e("developer.restartFailed"),{description:Wt.message})}})},disabled:U.isPending||k_,className:"shrink-0 gap-2",children:[(U.isPending||k_)&&c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}),e(k_?"developer.restarting":"developer.restartButton")]})]})})})]})}),c.jsx(jn,{value:"ai",className:"flex-1 overflow-auto p-6",children:c.jsxs("div",{className:"mx-auto max-w-5xl space-y-4",children:[c.jsxs(kl,{title:e("sections.agent"),children:[c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.agent.default.label")}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Qr,{value:nt,onValueChange:He=>Fn(He),children:[c.jsx(Jr,{className:"w-40",children:c.jsx(Zr,{})}),c.jsx(ei,{children:Object.keys(Io).map(He=>c.jsx(jt,{value:He,children:Io[He]},He))})]}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:Yk,disabled:sn||it.isPending,title:t("buttons.reset"),children:c.jsx(Z,{icon:Bd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.agent.default.description")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.agent.opencodeModel.label")}),c.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[c.jsx(Bb,{value:rn,onChange:Yn,placeholder:e("fields.agent.opencodeModel.placeholder"),className:"w-64"}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:Xk,disabled:sn||it.isPending,title:t("buttons.reset"),children:c.jsx(Z,{icon:Bd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.agent.opencodeModel.description")})]})]}),c.jsxs(ug,{className:"mt-4 space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start",children:[c.jsxs(dg,{className:"group flex cursor-pointer items-center gap-1.5 text-left text-sm text-muted-foreground transition-colors hover:text-foreground sm:w-32 sm:shrink-0",children:[c.jsx(Z,{icon:Ts,size:12,strokeWidth:2,className:"shrink-0 transition-transform duration-200 group-data-[state=open]:rotate-180"}),c.jsx("span",{children:e("fields.agent.advancedAgentNames.label")})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:pt-0.5",children:e("fields.agent.advancedAgentNames.description")})]}),c.jsxs(fg,{className:"space-y-4 pt-2 sm:ml-32 sm:pl-2",children:[c.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-amber-500/20 bg-amber-500/10 p-3",children:[c.jsx(Z,{icon:wr,size:16,strokeWidth:2,className:"mt-0.5 shrink-0 text-amber-600 dark:text-amber-400"}),c.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:e("fields.agent.advancedAgentNames.warning")})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.agent.opencodeDefaultAgent.label")}),c.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[c.jsx(At,{value:Nr??"build",onChange:He=>oi(He.target.value),placeholder:"build",disabled:sn,className:"font-mono text-sm"}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:Cj,disabled:sn||it.isPending,title:t("buttons.reset"),children:c.jsx(Z,{icon:Bd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.agent.opencodeDefaultAgent.description")})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.agent.opencodePlanAgent.label")}),c.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[c.jsx(At,{value:Jn??"plan",onChange:He=>Fr(He.target.value),placeholder:"plan",disabled:sn,className:"font-mono text-sm"}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:kj,disabled:sn||it.isPending,title:t("buttons.reset"),children:c.jsx(Z,{icon:Bd,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.agent.opencodePlanAgent.description")})]})]})]}),c.jsxs("div",{className:"mt-4 space-y-1 border-t border-border pt-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.agent.autoScrollToBottom.label")}),c.jsx(Xr,{checked:sr,onCheckedChange:Br,disabled:sn})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.agent.autoScrollToBottom.description")})]}),c.jsxs("div",{className:"mt-4 space-y-1 border-t border-border pt-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.agent.claudeCodePath.label")}),c.jsx(At,{value:Si,onChange:He=>ml(He.target.value),placeholder:e("fields.agent.claudeCodePath.placeholder"),className:"flex-1",disabled:sn})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.agent.claudeCodePath.description")})]})]}),c.jsx(kl,{title:e("sections.assistant"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"grid gap-4 md:grid-cols-2 md:gap-x-8",children:[c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.provider.label")}),c.jsxs(Qr,{value:Hc,onValueChange:He=>Ok(He),children:[c.jsx(Jr,{className:"w-48",children:c.jsx(Zr,{})}),c.jsxs(ei,{children:[c.jsx(jt,{value:"claude",children:"Claude"}),$e&&c.jsx(jt,{value:"opencode",children:"OpenCode"})]})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.provider.description")})]}),Hc==="claude"&&c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.model.label")}),c.jsxs(Qr,{value:nv,onValueChange:He=>Rk(He),children:[c.jsx(Jr,{className:"w-48",children:c.jsx(Zr,{})}),c.jsx(ei,{children:Ise.map(He=>c.jsx(jt,{value:He,children:e(`fields.assistant.model.options.${He}`)},He))})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.model.description")})]}),Hc==="opencode"&&c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.opencodeModel.label")}),c.jsx(Bb,{value:w,onChange:He=>{Xe.mutate({key:Qt.OPENCODE_MODEL,value:He})},placeholder:e("fields.assistant.opencodeModel.placeholder"),className:"w-64"})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.opencodeModel.description")})]})]}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.observerProvider.label")}),c.jsxs(Qr,{value:Hu??"same-as-main",onValueChange:He=>Dk(He==="same-as-main"?null:He),children:[c.jsx(Jr,{className:"w-48",children:c.jsx(Zr,{})}),c.jsxs(ei,{children:[c.jsx(jt,{value:"same-as-main",children:e("fields.assistant.observerProvider.options.default")}),c.jsx(jt,{value:"claude",children:"Claude"}),$e&&c.jsx(jt,{value:"opencode",children:"OpenCode"})]})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.observerProvider.description")})]}),(Hu==="claude"||Hu===null&&Hc==="claude")&&c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.observerModel.label")}),c.jsxs(Qr,{value:rv,onValueChange:He=>Ik(He),children:[c.jsx(Jr,{className:"w-48",children:c.jsx(Zr,{})}),c.jsx(ei,{children:Ise.map(He=>c.jsx(jt,{value:He,children:e(`fields.assistant.observerModel.options.${He}`)},He))})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.observerModel.description")})]}),(Hu==="opencode"||Hu===null&&Hc==="opencode")&&$e&&c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.observerOpencodeModel.label")}),c.jsx(Bb,{value:iv,onChange:He=>jk(He),placeholder:e("fields.assistant.observerOpencodeModel.placeholder"),className:"w-64"})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.observerOpencodeModel.description")})]})]})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.customInstructions.label")}),c.jsx(Pr,{to:"/assistant",search:{tab:"memory"},children:c.jsx(_e,{variant:"outline",size:"sm",children:e("fields.assistant.customInstructions.openMemoryFile")})})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.customInstructions.memoryDescription")})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("fields.assistant.documentsDir.label")}),c.jsx(At,{value:sv,onChange:He=>av(He.target.value),placeholder:"~/.fulcrum/documents",disabled:sn,className:"w-64 font-mono text-sm"})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("fields.assistant.documentsDir.description")})]}),c.jsxs("div",{className:"border-t border-border pt-4 space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("concierge.rituals")}),c.jsx(Xr,{checked:Eg,onCheckedChange:Pk,disabled:sn})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("concierge.ritualsDescription")})]}),Eg&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("concierge.morningRitual")}),c.jsx(At,{type:"time",value:ov,onChange:He=>C_(He.target.value),disabled:sn,className:"w-32"})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("concierge.morningRitualDescription")})]}),c.jsx("div",{className:"sm:ml-32 sm:pl-2",children:c.jsx(Oc,{value:lv,onChange:He=>Lk(He.target.value),placeholder:e("concierge.morningRitualPromptPlaceholder"),disabled:sn,className:"min-h-[80px] text-sm"})})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-32 sm:shrink-0",children:e("concierge.eveningRitual")}),c.jsx(At,{type:"time",value:cv,onChange:He=>Mk(He.target.value),disabled:sn,className:"w-32"})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-32 sm:pl-2",children:e("concierge.eveningRitualDescription")})]}),c.jsx("div",{className:"sm:ml-32 sm:pl-2",children:c.jsx(Oc,{value:uv,onChange:He=>Fk(He.target.value),placeholder:e("concierge.eveningRitualPromptPlaceholder"),disabled:sn,className:"min-h-[80px] text-sm"})})]})]})]})}),c.jsx(kl,{title:e("sections.zai"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.zai.enable")}),c.jsx(Xr,{checked:Je,onCheckedChange:Dt,disabled:sn})]}),Je&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.zai.apiKey")}),c.jsxs("div",{className:"relative flex-1",children:[c.jsx(At,{type:"password",value:Mt,onChange:He=>Rn(He.target.value),placeholder:"zai_...",disabled:sn,className:"flex-1 pr-8 font-mono text-sm"}),!!$?.apiKey&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(Z,{icon:hr,size:14,strokeWidth:2})})]})]}),c.jsx("p",{className:"text-xs text-muted-foreground sm:ml-20 sm:pl-2",children:e("fields.zai.description")})]}),c.jsxs("div",{className:"space-y-3 border-t border-border pt-4",children:[c.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:e("fields.zai.modelMappings")}),c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.zai.haiku")}),c.jsx(At,{value:Bn,onChange:He=>Kr(He.target.value),placeholder:"glm-4.5-air",disabled:sn,className:"flex-1 font-mono text-sm"})]}),c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.zai.sonnet")}),c.jsx(At,{value:Bi,onChange:He=>ac(He.target.value),placeholder:"glm-4.7",disabled:sn,className:"flex-1 font-mono text-sm"})]}),c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-20 sm:shrink-0",children:e("fields.zai.opus")}),c.jsx(At,{value:oc,onChange:He=>bs(He.target.value),placeholder:"glm-4.7",disabled:sn,className:"flex-1 font-mono text-sm"})]})]})]})]})})]})}),c.jsx(jn,{value:"messaging",className:"flex-1 overflow-auto p-6",children:c.jsxs("div",{className:"mx-auto max-w-5xl space-y-4",children:[c.jsx(kl,{title:e("sections.notifications"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground sm:w-40 sm:shrink-0",children:e("notifications.enable")}),c.jsx(Xr,{checked:nr,onCheckedChange:Ns,disabled:sn})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Xr,{checked:hs,onCheckedChange:Uu,disabled:sn||!nr}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.toast")})]}),c.jsx("p",{className:"ml-10 text-xs text-muted-foreground",children:e("notifications.toastDescription")})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Xr,{checked:$o,onCheckedChange:Bc,disabled:sn||!nr}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.desktop")})]}),c.jsx("p",{className:"ml-10 text-xs text-muted-foreground",children:e("notifications.desktopDescription")})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Xr,{checked:Ra,onCheckedChange:rs,disabled:sn||!nr}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.sound")}),c.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[c.jsx("input",{ref:kg,type:"file",accept:"audio/mpeg,audio/mp3,audio/wav,audio/ogg",className:"hidden",onChange:Tj}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>kg.current?.click(),disabled:sn||!nr||!Ra||kp,title:e("notifications.uploadSound"),children:kp?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(Z,{icon:xze,size:14,strokeWidth:2})}),Bk&&c.jsx(_e,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:Aj,disabled:sn||!nr||!Ra,title:e("notifications.deleteSound"),children:c.jsx(Z,{icon:ks,size:14,strokeWidth:2})}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Vf("sound"),disabled:sn||!nr||!Ra||Xt.isPending,title:e("notifications.testSound"),children:Xt.isPending?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(Z,{icon:rm,size:14,strokeWidth:2})})]})]}),Bk&&c.jsx("p",{className:"ml-10 text-xs text-muted-foreground",children:e("notifications.customSoundActive")})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Xr,{checked:wi,onCheckedChange:ps,disabled:sn||!nr}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.slack")}),c.jsx(_e,{variant:"ghost",size:"icon",className:"ml-auto h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Vf("slack"),disabled:sn||!nr||!wi||!zo&&!ne||Xt.isPending,title:e("notifications.slack"),children:Xt.isPending?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(Z,{icon:rm,size:14,strokeWidth:2})})]}),wi&&c.jsxs("div",{className:"ml-6 space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Xr,{checked:ne,onCheckedChange:le,disabled:sn||!nr||!wi}),c.jsx("label",{className:"text-xs text-muted-foreground",children:e("notifications.useMessagingChannel")||"Use messaging channel"})]}),!ne&&c.jsxs("div",{className:"relative",children:[c.jsx(At,{type:"password",value:zo,onChange:He=>$c(He.target.value),placeholder:"https://hooks.slack.com/services/...",disabled:sn||!nr,className:"flex-1 pr-8 font-mono text-sm"}),!!L?.slack?.webhookUrl&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(Z,{icon:hr,size:14,strokeWidth:2})})]}),ne&&c.jsx("p",{className:"text-xs text-muted-foreground",children:e("notifications.messagingChannelNote")||"Sends via connected Slack messaging channel"})]})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Xr,{checked:Ia,onCheckedChange:to,disabled:sn||!nr}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.discord")}),c.jsx(_e,{variant:"ghost",size:"icon",className:"ml-auto h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Vf("discord"),disabled:sn||!nr||!Ia||!gl&&!Se||Xt.isPending,title:e("notifications.discord"),children:Xt.isPending?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(Z,{icon:rm,size:14,strokeWidth:2})})]}),Ia&&c.jsxs("div",{className:"ml-6 space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Xr,{checked:Se,onCheckedChange:qe,disabled:sn||!nr||!Ia}),c.jsx("label",{className:"text-xs text-muted-foreground",children:e("notifications.useMessagingChannel")||"Use messaging channel"})]}),!Se&&c.jsxs("div",{className:"relative",children:[c.jsx(At,{type:"password",value:gl,onChange:He=>qt(He.target.value),placeholder:"https://discord.com/api/webhooks/...",disabled:sn||!nr,className:"flex-1 pr-8 font-mono text-sm"}),!!L?.discord?.webhookUrl&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(Z,{icon:hr,size:14,strokeWidth:2})})]}),Se&&c.jsx("p",{className:"text-xs text-muted-foreground",children:e("notifications.messagingChannelNote")||"Sends via connected Discord messaging channel"})]})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Xr,{checked:Le,onCheckedChange:vt,disabled:sn||!nr}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.pushover")}),c.jsx(_e,{variant:"ghost",size:"icon",className:"ml-auto h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Vf("pushover"),disabled:sn||!nr||!Le||!pn||!on||Xt.isPending,title:e("notifications.pushover"),children:Xt.isPending?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(Z,{icon:rm,size:14,strokeWidth:2})})]}),Le&&c.jsxs("div",{className:"ml-6 space-y-2",children:[c.jsxs("div",{className:"relative",children:[c.jsx(At,{type:"password",value:pn,onChange:He=>En(He.target.value),placeholder:e("notifications.appToken"),disabled:sn||!nr,className:"flex-1 pr-8 font-mono text-sm"}),!!L?.pushover?.appToken&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(Z,{icon:hr,size:14,strokeWidth:2})})]}),c.jsxs("div",{className:"relative",children:[c.jsx(At,{type:"password",value:on,onChange:He=>_o(He.target.value),placeholder:e("notifications.userKey"),disabled:sn||!nr,className:"flex-1 pr-8 font-mono text-sm"}),!!L?.pushover?.userKey&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-green-500",children:c.jsx(Z,{icon:hr,size:14,strokeWidth:2})})]})]})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Xr,{checked:ms,onCheckedChange:ra,disabled:sn||!nr}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.whatsapp")||"WhatsApp"}),c.jsx(_e,{variant:"ghost",size:"icon",className:"ml-auto h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Vf("whatsapp"),disabled:sn||!nr||!ms||Xt.isPending,title:e("notifications.whatsapp")||"WhatsApp",children:Xt.isPending?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(Z,{icon:rm,size:14,strokeWidth:2})})]}),ms&&c.jsx("p",{className:"ml-10 text-xs text-muted-foreground",children:e("notifications.messagingChannelRequired")||"Requires connected WhatsApp messaging channel"})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Xr,{checked:gs,onCheckedChange:zc,disabled:sn||!nr}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.telegram")||"Telegram"}),c.jsx(_e,{variant:"ghost",size:"icon",className:"ml-auto h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Vf("telegram"),disabled:sn||!nr||!gs||Xt.isPending,title:e("notifications.telegram")||"Telegram",children:Xt.isPending?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(Z,{icon:rm,size:14,strokeWidth:2})})]}),gs&&c.jsx("p",{className:"ml-10 text-xs text-muted-foreground",children:e("notifications.messagingChannelRequired")||"Requires connected Telegram messaging channel"})]}),c.jsxs("div",{className:"space-y-2 pl-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Xr,{checked:bl,onCheckedChange:sc,disabled:sn||!nr}),c.jsx("label",{className:"text-sm text-muted-foreground",children:e("notifications.gmail")}),c.jsx(_e,{variant:"ghost",size:"icon",className:"ml-auto h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>Vf("gmail"),disabled:sn||!nr||!bl||Xt.isPending,title:e("notifications.gmail"),children:Xt.isPending?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(Z,{icon:rm,size:14,strokeWidth:2})})]}),bl&&c.jsxs("div",{className:"ml-10 space-y-2",children:[c.jsx("p",{className:"text-xs text-muted-foreground",children:e("notifications.gmailDescription")}),en.length>1&&c.jsxs(Qr,{value:N||"auto",onValueChange:He=>H(!He||He==="auto"?"":He),children:[c.jsx(Jr,{className:"h-8 w-60",children:c.jsx(Zr,{})}),c.jsxs(ei,{children:[c.jsx(jt,{value:"auto",children:e("notifications.gmailAutoResolve")}),en.map(He=>c.jsx(jt,{value:He.id,children:He.email||He.name},He.id))]})]}),en.length===0&&c.jsx("p",{className:"text-xs text-destructive",children:e("notifications.gmailNoAccounts")})]})]})]})}),c.jsx(kl,{title:"Channels",children:c.jsxs("div",{className:"space-y-8",children:[c.jsx("div",{className:"rounded-lg border border-border p-4",children:c.jsx(ANt,{isLoading:sn})}),c.jsx(bNt,{isLoading:sn}),c.jsx(yNt,{isLoading:sn}),c.jsx(vNt,{isLoading:sn}),c.jsx(xNt,{isLoading:sn})]})})]})}),c.jsx(jn,{value:"calendar",className:"flex-1 overflow-auto p-6",children:c.jsxs("div",{className:"mx-auto max-w-5xl space-y-4",children:[c.jsx(kl,{title:e("sections.googleCalendar","Google Calendar"),children:c.jsx(XNt,{})}),c.jsxs(kl,{title:e("sections.caldav"),children:[c.jsx(KNt,{isLoading:sn}),c.jsx(QNt,{isLoading:sn})]})]})})]})}),c.jsx("div",{className:"shrink-0 border-t border-border bg-background px-6 py-3",children:c.jsx("div",{className:"mx-auto flex max-w-5xl items-center justify-start",children:c.jsxs("div",{className:"flex items-center gap-2",children:[ns&&c.jsxs("span",{className:"flex items-center gap-1 text-xs text-accent",children:[c.jsx(Z,{icon:hr,size:12,strokeWidth:2}),t("status.saved")]}),c.jsx(_e,{size:"sm",onClick:Ej,disabled:!Tg||sn||Xe.isPending||ot.isPending||St.isPending||K.isPending,children:t("buttons.save")})]})})}),c.jsx(yh,{open:tn,onOpenChange:Na,onSelect:He=>wn(He),initialPath:Kt||void 0})]})}const eOt=xa("/review/")({beforeLoad:()=>{throw _3({to:"/monitoring",search:{tab:"review"}})},component:()=>null}),tOt=xa("/repositories/")({beforeLoad:()=>{throw _3({to:"/projects",search:{tab:"repositories"}})},component:()=>null});function nOt({open:e,onOpenChange:t,onCreated:n}){const{t:r}=Ot("projects"),i=Ni(),s=Uwe(),[a,o]=x.useState(""),[l,u]=x.useState(""),[d,f]=x.useState([]),[h,m]=x.useState(""),[g,y]=x.useState(!1),[v,_]=x.useState(null),S=x.useRef(null),{data:E=[]}=NW(h),T=E.filter(F=>!d.includes(F.name)),k=E.find(F=>F.name.toLowerCase()===h.toLowerCase()),w=h.trim()&&!k&&!d.includes(h.trim());x.useEffect(()=>{e&&(o(""),u(""),f([]),m(""),_(null),y(!1))},[e]),x.useEffect(()=>{const F=z=>{S.current&&!S.current.contains(z.target)&&y(!1)};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[]);const A=F=>{const z=F.trim();z&&!d.includes(z)&&f([...d,z]),m(""),y(!1)},R=F=>{f(d.filter(z=>z!==F))},I=F=>{F.key==="Enter"&&h.trim()?(F.preventDefault(),k&&!d.includes(k.name)?A(k.name):w&&A(h.trim())):F.key==="Escape"?(y(!1),m("")):F.key==="Backspace"&&!h&&d.length>0&&f(d.slice(0,-1))},D=async()=>{_(null);const F=a.trim();if(F)try{const z=await s.mutateAsync({name:F,description:l.trim()||void 0,tags:d.length>0?d:void 0});t(!1),n?n(z):i({to:"/projects/$projectId",params:{projectId:z.id}})}catch(z){_(z instanceof Error?z.message:"Failed to create project")}},j=F=>{F.key==="Enter"&&!F.shiftKey&&a.trim()&&(F.preventDefault(),D())};return c.jsx(Ya,{open:e,onOpenChange:t,children:c.jsxs(Xa,{className:"sm:max-w-md",children:[c.jsx(Lo,{children:c.jsx(Mo,{children:r("newProjectButton")})}),c.jsxs("div",{className:"space-y-4 py-2",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ur,{htmlFor:"project-name",children:r("newProject.projectName")}),c.jsx(At,{id:"project-name",value:a,onChange:F=>o(F.target.value),onKeyDown:j,placeholder:r("newProject.projectNamePlaceholder"),disabled:s.isPending,autoFocus:!0})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ur,{htmlFor:"project-description",children:r("newProject.description")}),c.jsx(Oc,{id:"project-description",value:l,onChange:F=>u(F.target.value),placeholder:r("newProject.descriptionPlaceholder"),disabled:s.isPending,rows:3})]}),c.jsxs("div",{className:"space-y-2",ref:S,children:[c.jsx(Ur,{children:"Tags"}),d.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:d.map(F=>c.jsxs(ir,{variant:"default",className:"pr-1 gap-1",children:[F,c.jsx("button",{type:"button",onClick:()=>R(F),className:"ml-0.5 hover:text-destructive transition-colors",children:c.jsx(Z,{icon:Tn,size:10})})]},F))}),c.jsxs("div",{className:"relative",children:[c.jsx(At,{value:h,onChange:F=>{m(F.target.value),y(!0)},onFocus:()=>y(!0),onKeyDown:I,placeholder:"Add tags...",disabled:s.isPending}),g&&(h||T.length>0)&&c.jsxs("div",{className:"absolute top-full left-0 right-0 mt-1 bg-popover border rounded-md shadow-lg z-50 max-h-48 overflow-y-auto",children:[T.map(F=>c.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm hover:bg-accent flex items-center justify-between",onClick:()=>A(F.name),children:[c.jsx("span",{children:F.name}),c.jsxs("span",{className:"text-xs text-muted-foreground",children:[F.taskCount+F.projectCount," uses"]})]},F.id)),w&&c.jsxs("button",{type:"button",className:Ae("w-full px-3 py-2 text-left text-sm hover:bg-accent flex items-center gap-2",T.length>0&&"border-t"),onClick:()=>A(h.trim()),children:[c.jsx(Z,{icon:Ic,size:14}),c.jsxs("span",{children:['Create "',h.trim(),'"']})]}),!w&&T.length===0&&h&&c.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"No matching tags"})]})]})]}),v&&c.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:[c.jsx(Z,{icon:wr,size:14,strokeWidth:2,className:"mt-0.5 shrink-0"}),c.jsx("span",{children:v})]})]}),c.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[c.jsx(_e,{variant:"outline",onClick:()=>t(!1),disabled:s.isPending,children:r("newProject.cancel")}),c.jsx(_e,{onClick:D,disabled:!a.trim()||s.isPending,children:s.isPending?c.jsxs(c.Fragment,{children:[c.jsx(Z,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin"}),r("newProject.creating")]}):r("newProject.create")})]})]})})}const hRe="";function rOt(e){return Jt({queryKey:["copier-questions",e],queryFn:()=>ht(`${hRe}/api/copier/questions?source=${encodeURIComponent(e)}`),enabled:!!e,staleTime:300*1e3,retry:!1})}function iOt(){const{data:e,...t}=Oy();return{...t,data:e?.filter(n=>n.isCopierTemplate)??[]}}function sOt(){const e=It();return wt({mutationFn:t=>ht(`${hRe}/api/copier/create`,{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{e.invalidateQueries({queryKey:["repositories"]}),e.invalidateQueries({queryKey:["projects"]})}})}function vM(e){return e.startsWith("git@")||e.startsWith("https://")||e.startsWith("http://")||e.startsWith("gh:")||e.startsWith("gl:")||e.startsWith("bb:")}function aOt(e){const t=e.replace(/\.git$/,"");if(t.startsWith("git@")){const n=t.match(/:([^/]+\/)?([^/]+)$/);if(n)return n[2]}else if(t.startsWith("gh:")||t.startsWith("gl:")||t.startsWith("bb:")){const n=t.split("/");if(n.length>0)return n[n.length-1]}else{const n=t.split("/");if(n.length>0)return n[n.length-1]}return t}function pRe({open:e,onOpenChange:t,projectId:n,initialTab:r="clone"}){const{t:i}=Ot("repositories"),{data:s}=uD(),{data:a}=Mc(),o=Hwe(),l=Rqe(),u=Iqe(),d=Uwe(),f=sOt(),[h,m]=x.useState(null),[g,y]=x.useState(""),[v,_]=x.useState(null),[S,E]=x.useState(!1),[T,k]=x.useState(""),w=n??h,[A,R]=x.useState(r),[I,D]=x.useState(""),[j,F]=x.useState(""),[z,P]=x.useState(""),[L,M]=x.useState(null),[$,W]=x.useState(!1),[Y,q]=x.useState(""),[K,X]=x.useState(null),[U,J]=x.useState(!1),[te,ee]=x.useState(""),[oe,ae]=x.useState(null),[se,ue]=x.useState(new Set),[de,ce]=x.useState(null),[Ee,Ie]=x.useState(!1),[fe,be]=x.useState(""),[ge,Ce]=x.useState(""),[Re,xe]=x.useState({}),[ye,De]=x.useState(""),[ve,Oe]=x.useState(""),[Be,Te]=x.useState(null),[je,ie]=x.useState(!0),[Ke,lt]=x.useState(!1),[Rt,Ye]=x.useState(new Set),[ct,Ve]=x.useState({open:!1,conflict:null,pendingAction:null}),{data:Et}=iOt(),$e=fe||ge,{data:Qe,isLoading:pt,error:at}=rOt(A==="template"&&$e?$e:null);x.useEffect(()=>{e&&(R(r),m(null),y(""),_(null),E(!1),k(""),D(""),F(""),P(""),M(null),q(""),X(null),ee(""),ae(null),ue(new Set),ce(null),be(""),Ce(""),xe({}),De(s||""),Oe(""),Te(null),ie(!0),Ye(new Set))},[e,r,s]);const gt=x.useMemo(()=>I.trim()?aOt(I.trim()):null,[I]);x.useEffect(()=>{gt&&!z&&P(gt)},[gt,z]);const We=j.trim()||s||"",Xe=te.trim()||s||"",it=x.useMemo(()=>{if(!I.trim()||!We)return null;const nt=z.trim()||gt||"";return nt?`${We}/${nt}`:null},[I,We,z,gt]),ot=x.useMemo(()=>oe?.filter(nt=>!nt.hasProject)??[],[oe]),St=o.isPending&&A==="clone",Xt=o.isPending&&A==="local",Vt=l.isPending||u.isPending,en=f.isPending,Fe=x.useMemo(()=>{if(!a)return[];if(!g.trim())return a;const nt=g.toLowerCase();return a.filter(Fn=>Fn.name.toLowerCase().includes(nt))},[a,g]),Ue=a?.find(nt=>nt.id===h),ut=async()=>{if(T.trim()){_(null);try{const nt=await d.mutateAsync({name:T.trim()});m(nt.id),E(!1),k("")}catch(nt){_(nt instanceof Error?nt.message:"Failed to create project")}}};x.useEffect(()=>{Qe?.questions&&xe(nt=>{const Fn={...nt};for(const rn of Qe.questions)Fn[rn.name]===void 0&&rn.default!==void 0&&(Fn[rn.name]=rn.default);return Fn})},[Qe]),x.useEffect(()=>{s&&!ye&&De(s)},[s,ye]);const Kt=Qe?.questions.filter(nt=>{if(nt.default!==void 0&&!(typeof nt.default=="string"&&nt.default.includes("{{")))return!1;const rn=Re[nt.name];return rn==null||rn===""})??[],wn=$e&&ve.trim()&&ye.trim()&&!pt&&Kt.length===0,pr=async(nt=!1)=>{if(!w){_("Please select a project first");return}M(null),_(null);const Fn=I.trim();if(!(!Fn||!vM(Fn)))try{await o.mutateAsync({projectId:w,url:Fn,targetDir:j.trim()||void 0,folderName:z.trim()||void 0,moveFromProject:nt}),t(!1)}catch(rn){const Yn=rn;Yn.conflict?.conflictProject?Ve({open:!0,conflict:Yn.conflict,pendingAction:()=>pr(!0)}):M(Yn.message||i("addModal.cloneFailed"))}},Mr=async(nt=!1)=>{if(!w){_("Please select a project first");return}X(null),_(null);const Fn=Y.trim();if(Fn)try{await o.mutateAsync({projectId:w,path:Fn,moveFromProject:nt}),t(!1)}catch(rn){const Yn=rn;Yn.conflict?.conflictProject?Ve({open:!0,conflict:Yn.conflict,pendingAction:()=>Mr(!0)}):X(Yn.message||i("addModal.createFailed"))}},qi=()=>{ce(null),ae(null),ue(new Set),l.mutate(Xe||void 0,{onSuccess:nt=>{ae(nt.repositories);const Fn=nt.repositories.filter(rn=>!rn.hasProject);ue(new Set(Fn.map(rn=>rn.path)))},onError:nt=>{ce(nt instanceof Error?nt.message:i("bulkAdd.scanFailed"))}})},na=nt=>{ue(Fn=>{const rn=new Set(Fn);return rn.has(nt)?rn.delete(nt):rn.add(nt),rn})},ai=()=>{ue(new Set(ot.map(nt=>nt.path)))},Ar=()=>{ue(new Set)},mr=async()=>{if(!w){_("Please select a project first");return}if(se.size===0)return;ce(null),_(null);let nt=0,Fn=0;for(const rn of se)try{await o.mutateAsync({projectId:w,path:rn}),nt++}catch{Fn++}Fn>0?ce(`Added ${nt} repositories, ${Fn} failed`):t(!1)},Ji=!!fe||je,hi=async()=>{if(!w){_("Please select a project first");return}Te(null),_(null);try{await f.mutateAsync({templateSource:$e,outputPath:ye,answers:Re,projectName:ve,trust:Ji,existingProjectId:w}),t(!1)}catch(nt){Te(nt instanceof Error?nt.message:"Failed to create from template")}},Bs=nt=>{const Fn=Re[nt.name],rn=oi=>xe(Jn=>({...Jn,[nt.name]:oi})),Nr=nt.default===void 0||typeof nt.default=="string"&&nt.default.includes("{{")?`${nt.name} *`:nt.name;switch(nt.type){case"bool":return c.jsxs($n,{children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ni,{checked:Fn,onCheckedChange:rn}),c.jsx(zn,{className:"cursor-pointer",children:Nr})]}),nt.help&&c.jsx(Pi,{children:nt.help})]},nt.name);case"int":case"float":return c.jsxs($n,{children:[c.jsx(zn,{children:Nr}),c.jsx(At,{type:"number",value:Fn,onChange:oi=>rn(nt.type==="int"?parseInt(oi.target.value):parseFloat(oi.target.value)),step:nt.type==="float"?"any":1}),nt.help&&c.jsx(Pi,{children:nt.help})]},nt.name);default:{if(nt.choices&&nt.choices.length>0)return c.jsxs($n,{children:[c.jsx(zn,{children:Nr}),c.jsxs(Qr,{value:String(Fn??""),onValueChange:rn,children:[c.jsx(Jr,{className:"w-full",children:c.jsx(Zr,{})}),c.jsx(ei,{children:nt.choices.map(sr=>c.jsx(jt,{value:String(sr.value),children:sr.label},String(sr.value)))})]}),nt.help&&c.jsx(Pi,{children:nt.help})]},nt.name);const oi=nt.type==="yaml"||nt.type==="json",Jn=nt.name.toLowerCase().includes("password"),Fr=Rt.has(nt.name);return c.jsxs($n,{children:[c.jsx(zn,{children:Nr}),oi?c.jsx(Oc,{value:String(Fn??""),onChange:sr=>rn(sr.target.value),rows:4}):Jn?c.jsxs("div",{className:"relative",children:[c.jsx(At,{type:Fr?"text":"password",value:String(Fn??""),onChange:sr=>rn(sr.target.value),className:"pr-8"}),c.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>{Ye(sr=>{const Br=new Set(sr);return Br.has(nt.name)?Br.delete(nt.name):Br.add(nt.name),Br})},children:c.jsx(Z,{icon:Fr?eSe:bC,size:14,strokeWidth:2})})]}):c.jsx(At,{value:String(Fn??""),onChange:sr=>rn(sr.target.value)}),nt.help&&c.jsx(Pi,{children:nt.help})]},nt.name)}}},es=()=>{t(!1)},ts=()=>n?null:c.jsxs("div",{className:"space-y-2 border-t border-border pt-4",children:[c.jsx(Ur,{children:"Add to Project"}),S?c.jsxs("div",{className:"flex gap-2",children:[c.jsx(At,{value:T,onChange:nt=>k(nt.target.value),placeholder:"New project name...",autoFocus:!0,onKeyDown:nt=>{nt.key==="Enter"?(nt.preventDefault(),ut()):nt.key==="Escape"&&(E(!1),k(""))},disabled:d.isPending}),c.jsx(_e,{size:"sm",onClick:ut,disabled:!T.trim()||d.isPending,children:d.isPending?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}):"Create"}),c.jsx(_e,{size:"sm",variant:"outline",onClick:()=>{E(!1),k("")},disabled:d.isPending,children:"Cancel"})]}):c.jsxs(ox,{value:h,onValueChange:nt=>{m(nt),_(null)},children:[c.jsx(lx,{placeholder:Ue?.name||"Select a project...",value:g,onChange:nt=>y(nt.target.value),className:"w-full"}),c.jsxs(cx,{children:[c.jsxs(ux,{children:[c.jsx(dx,{children:"No projects found"}),Fe.map(nt=>c.jsx(Rh,{value:nt.id,children:nt.name},nt.id))]}),c.jsx("div",{className:"border-t p-1",children:c.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground",onClick:()=>{E(!0),y("")},children:[c.jsx(Z,{icon:Ic,size:14,strokeWidth:2}),"Create new project"]})})]})]}),v&&c.jsxs("div",{className:"flex items-center gap-2 text-xs text-destructive",children:[c.jsx(Z,{icon:wr,size:12,strokeWidth:2}),v]})]});return c.jsxs(c.Fragment,{children:[c.jsx(Ya,{open:e,onOpenChange:t,children:c.jsxs(Xa,{className:"sm:max-w-2xl max-h-[80dvh] flex flex-col overflow-hidden",children:[c.jsx(Lo,{className:"shrink-0",children:c.jsx(Mo,{children:i("addRepository")})}),c.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 px-1",children:c.jsx("div",{className:"space-y-4",children:c.jsxs(nl,{value:A,onValueChange:R,children:[c.jsxs(rl,{className:"w-full",children:[c.jsx(In,{value:"clone",className:"flex-1",children:"Clone"}),c.jsx(In,{value:"local",className:"flex-1",children:"Local"}),c.jsx(In,{value:"scan",className:"flex-1",children:i("addModal.tabs.scan")}),c.jsx(In,{value:"template",className:"flex-1",children:i("addModal.tabs.template")})]}),c.jsxs(jn,{value:"clone",className:"space-y-4 pt-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ur,{children:"Git URL"}),c.jsxs("div",{className:"relative",children:[c.jsx(At,{value:I,onChange:nt=>{D(nt.target.value),M(null),vM(nt.target.value.trim())||P("")},placeholder:"https://github.com/user/repo.git",disabled:St,className:"pr-8"}),I&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2",children:c.jsx(Z,{icon:Ay,size:14,strokeWidth:2,className:"text-muted-foreground"})})]})]}),I.trim()&&c.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-muted/30 p-3",children:[c.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Clone Options"}),c.jsxs("div",{className:"space-y-1",children:[c.jsx(Ur,{className:"text-xs",children:"Clone to directory"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(At,{value:j,onChange:nt=>F(nt.target.value),placeholder:s||"~/",disabled:St,className:"flex-1 text-xs"}),c.jsx(_e,{type:"button",variant:"outline",size:"sm",onClick:()=>W(!0),disabled:St,children:"Browse"})]})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx(Ur,{className:"text-xs",children:"Folder name"}),c.jsx(At,{value:z,onChange:nt=>P(nt.target.value),placeholder:gt||"",disabled:St,className:"text-xs"})]}),it&&c.jsxs("div",{className:"rounded-md bg-background px-3 py-2 text-xs text-muted-foreground",children:["Will clone to: ",c.jsx("span",{className:"font-mono",children:it})]})]}),St&&c.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[c.jsx(Z,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin"}),"Cloning repository..."]}),L&&c.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:[c.jsx(Z,{icon:wr,size:14,strokeWidth:2,className:"mt-0.5 shrink-0"}),c.jsx("span",{children:L})]}),ts(),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(_e,{variant:"outline",onClick:es,disabled:St,children:i("addModal.cancel")}),c.jsx(_e,{onClick:()=>pr(!1),disabled:!I.trim()||!vM(I.trim())||St||!w,children:St?c.jsxs(c.Fragment,{children:[c.jsx(Z,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin"}),"Cloning..."]}):"Clone & Add"})]})]}),c.jsxs(jn,{value:"local",className:"space-y-4 pt-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ur,{children:"Repository path"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("div",{className:"relative flex-1",children:[c.jsx(At,{value:Y,onChange:nt=>{q(nt.target.value),X(null)},placeholder:"~/code/my-repo",disabled:Xt,className:"pr-8"}),Y&&c.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2",children:c.jsx(Z,{icon:Zs,size:14,strokeWidth:2,className:"text-muted-foreground"})})]}),c.jsx(_e,{type:"button",variant:"outline",size:"sm",onClick:()=>J(!0),disabled:Xt,children:"Browse"})]})]}),Xt&&c.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[c.jsx(Z,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin"}),"Adding repository..."]}),K&&c.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:[c.jsx(Z,{icon:wr,size:14,strokeWidth:2,className:"mt-0.5 shrink-0"}),c.jsx("span",{children:K})]}),ts(),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(_e,{variant:"outline",onClick:es,disabled:Xt,children:i("addModal.cancel")}),c.jsx(_e,{onClick:()=>Mr(!1),disabled:!Y.trim()||Xt||!w,children:Xt?c.jsxs(c.Fragment,{children:[c.jsx(Z,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin"}),"Adding..."]}):i("addModal.add")})]})]}),c.jsxs(jn,{value:"scan",className:"space-y-4 pt-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ur,{children:i("bulkAdd.directoryLabel")}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(At,{value:te,onChange:nt=>{ee(nt.target.value),ce(null),ae(null)},placeholder:s||i("bulkAdd.directoryPlaceholder"),disabled:Vt,className:"flex-1"}),c.jsx(_e,{type:"button",variant:"outline",size:"sm",onClick:()=>Ie(!0),disabled:Vt,children:i("bulkAdd.browse")}),c.jsxs(_e,{type:"button",size:"sm",onClick:qi,disabled:Vt||!Xe,children:[l.isPending?c.jsx(Z,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin"}):c.jsx(Z,{icon:cp,size:16,strokeWidth:2}),i("bulkAdd.scan")]})]})]}),oe!==null&&c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Ur,{className:"text-xs",children:i("bulkAdd.foundRepos",{count:oe.length})}),ot.length>0&&c.jsxs("div",{className:"flex gap-2 text-xs",children:[c.jsx("button",{type:"button",className:"text-primary hover:underline",onClick:ai,disabled:Vt,children:i("bulkAdd.selectAll")}),c.jsx("span",{className:"text-muted-foreground",children:"/"}),c.jsx("button",{type:"button",className:"text-primary hover:underline",onClick:Ar,disabled:Vt,children:i("bulkAdd.selectNone")})]})]}),oe.length===0?c.jsx("div",{className:"rounded-md bg-muted/50 px-3 py-4 text-center text-sm text-muted-foreground",children:i("bulkAdd.noReposFound")}):c.jsx("div",{className:"max-h-64 overflow-y-auto rounded-md border",children:oe.map(nt=>c.jsxs("div",{className:`flex items-center gap-3 border-b px-3 py-2 last:border-b-0 ${nt.hasProject?"bg-muted/30 opacity-60":""}`,children:[c.jsx(ni,{checked:se.has(nt.path),onCheckedChange:()=>na(nt.path),disabled:nt.hasProject||Vt}),c.jsx(Z,{icon:nt.hasProject?sl:Zs,size:16,strokeWidth:2,className:nt.hasProject?"text-green-500":"text-muted-foreground"}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("div",{className:"truncate text-sm font-medium",children:nt.name}),c.jsx("div",{className:"truncate text-xs text-muted-foreground",children:nt.path})]}),nt.hasProject&&c.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:i("bulkAdd.alreadyAdded")})]},nt.path))})]}),o.isPending&&A==="scan"&&c.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[c.jsx(Z,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin"}),i("bulkAdd.adding")]}),de&&c.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:[c.jsx(Z,{icon:wr,size:14,strokeWidth:2,className:"mt-0.5 shrink-0"}),c.jsx("span",{children:de})]}),ts(),se.size>0&&c.jsx(_e,{onClick:mr,disabled:se.size===0||Vt||o.isPending||!w,className:"w-full",children:i("bulkAdd.addSelected",{count:se.size})})]}),c.jsxs(jn,{value:"template",className:"space-y-4 pt-4",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:i("newProject.steps.template.sectionTitle")}),c.jsxs("div",{className:"text-xs text-muted-foreground",children:[i("newProject.steps.template.sectionDescription")," ",c.jsx("a",{href:"https://copier.readthedocs.io/",target:"_blank",rel:"noopener noreferrer",className:"underline hover:opacity-80",children:i("newProject.steps.template.learnMore")})]})]}),c.jsxs(qh,{children:[c.jsxs($n,{children:[c.jsx(zn,{children:i("newProject.steps.template.savedTemplates")}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Qr,{value:fe,onValueChange:nt=>{be(nt??""),Ce(""),xe({})},children:[c.jsx(Jr,{className:"w-full",children:c.jsx(Zr,{children:fe?Et?.find(nt=>nt.id===fe)?.displayName:c.jsx("span",{className:"text-muted-foreground",children:i("newProject.steps.template.selectTemplate")})})}),c.jsx(ei,{children:Et?.map(nt=>c.jsx(jt,{value:nt.id,children:nt.displayName},nt.id))})]}),fe&&c.jsx(_e,{type:"button",variant:"ghost",size:"sm",onClick:()=>{be(""),xe({})},disabled:en,className:"text-muted-foreground hover:text-foreground",children:"Clear"})]})]}),!fe&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"text-center text-muted-foreground text-xs py-1",children:i("newProject.steps.template.or")}),c.jsxs($n,{children:[c.jsx(zn,{children:i("newProject.steps.template.customUrl")}),c.jsx(At,{value:ge,onChange:nt=>{Ce(nt.target.value),be(""),xe({})},placeholder:"https://github.com/user/template or /path/to/template",disabled:en})]})]})]}),$e&&c.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-muted/30 p-3",children:[c.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:i("newProject.steps.questions.title")}),pt&&c.jsx("div",{className:"flex items-center justify-center py-4",children:c.jsx(Z,{icon:Nt,size:20,strokeWidth:2,className:"animate-spin text-muted-foreground"})}),at&&c.jsx("div",{className:"text-destructive text-sm py-2",children:at.message}),Qe&&c.jsx(qh,{children:Qe.questions.length===0?c.jsx("div",{className:"text-muted-foreground text-sm py-2",children:i("newProject.steps.questions.noQuestions")}):Qe.questions.map(Bs)})]}),$e&&!pt&&c.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-muted/30 p-3",children:[c.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:i("newProject.steps.output.title")}),c.jsxs($n,{children:[c.jsx(zn,{children:i("newProject.steps.output.projectName")}),c.jsx(At,{value:ve,onChange:nt=>Oe(nt.target.value),placeholder:"my-new-project",disabled:en})]}),c.jsxs($n,{children:[c.jsx(zn,{children:i("newProject.steps.output.outputDirectory")}),c.jsxs(_e,{type:"button",variant:"outline",className:"w-full justify-start font-normal",onClick:()=>lt(!0),disabled:en,children:[c.jsx(Z,{icon:Zs,size:14,strokeWidth:2,className:"mr-2"}),ye||i("newProject.steps.output.selectDirectory")]})]}),ve&&ye&&c.jsxs(Pi,{className:"font-mono text-xs",children:[i("newProject.steps.output.willCreate"),": ",ye,"/",ve]})]}),en&&c.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[c.jsx(Z,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin"}),i("newProject.steps.creating.inProgress")]}),Be&&c.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:[c.jsx(Z,{icon:wr,size:14,strokeWidth:2,className:"mt-0.5 shrink-0"}),c.jsx("span",{children:Be})]}),ts(),c.jsxs("div",{className:"flex items-center justify-between pt-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ni,{id:"trust-template",checked:je,onCheckedChange:nt=>ie(nt===!0),disabled:en}),c.jsx("label",{htmlFor:"trust-template",className:"text-xs text-muted-foreground cursor-pointer",children:i("newProject.steps.output.trust")})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(_e,{variant:"outline",onClick:es,disabled:en,children:i("addModal.cancel")}),c.jsxs(_e,{onClick:hi,disabled:!wn||en||!w,children:[en&&c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin mr-2"}),en?"Creating…":"Create & Add"]})]})]})]})]})})})]})}),c.jsx(ql,{open:ct.open,onOpenChange:nt=>{nt||Ve({open:!1,conflict:null,pendingAction:null})},children:c.jsxs(Gl,{children:[c.jsxs(Kl,{children:[c.jsx(Xl,{children:"Repository Already Assigned"}),c.jsxs(Ql,{children:['This repository is already in project "',ct.conflict?.conflictProject?.name,'". Would you like to move it to this project instead?']})]}),c.jsxs(Yl,{children:[c.jsx(Zl,{children:"Cancel"}),c.jsx(cg,{onClick:()=>{ct.pendingAction?.(),Ve({open:!1,conflict:null,pendingAction:null})},children:"Move to This Project"})]})]})}),c.jsx(yh,{open:$,onOpenChange:W,onSelect:nt=>{F(nt),W(!1)},initialPath:We||void 0}),c.jsx(yh,{open:U,onOpenChange:J,onSelect:nt=>{q(nt),J(!1)},initialPath:s||void 0}),c.jsx(yh,{open:Ee,onOpenChange:Ie,onSelect:nt=>{ee(nt),Ie(!1),ae(null),ue(new Set)},initialPath:Xe||void 0}),c.jsx(yh,{open:Ke,onOpenChange:lt,onSelect:nt=>{De(nt),lt(!1)},initialPath:ye||s||void 0})]})}const oOt=xa("/projects/")({component:uOt});function lOt({project:e,onAddRepo:t,onDeleteClick:n}){const{t:r}=Ot("projects"),i=e.repositories.length>0?e.repositories.length:e.repositoryId?1:0;return c.jsxs(xi,{className:"h-full group transition-colors hover:border-foreground/20",children:[c.jsx(Pr,{to:"/projects/$projectId",params:{projectId:e.id},className:"block",children:c.jsxs(Ms,{className:"flex flex-col items-start gap-3 py-4",children:[c.jsx("span",{className:"truncate font-medium group-hover:text-primary transition-colors",children:e.name}),e.description&&c.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:e.description}),e.tags&&e.tags.length>0&&c.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.tags.slice(0,3).map(s=>c.jsx(ir,{variant:"default",className:"text-[10px] px-1.5 py-0",style:s.color?{backgroundColor:s.color,color:"#fff"}:void 0,children:s.name},s.id)),e.tags.length>3&&c.jsxs(ir,{variant:"default",className:"text-[10px] px-1.5 py-0",children:["+",e.tags.length-3]})]}),c.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(Z,{icon:Zs,size:14,strokeWidth:2,className:"shrink-0 -translate-y-px"}),c.jsxs("span",{children:[i," ",i===1?"repository":"repositories"]})]}),c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(Z,{icon:iD,size:14,strokeWidth:2,className:"shrink-0 -translate-y-px"}),c.jsxs("span",{children:[e.taskCount??0," active ",e.taskCount===1?"task":"tasks"]})]})]})]})}),c.jsx(Ms,{className:"flex flex-col items-start pt-0 pb-4",children:c.jsxs("div",{className:"flex flex-wrap gap-1",children:[c.jsxs(_e,{variant:"outline",size:"sm",onClick:t,className:"text-muted-foreground hover:text-foreground",children:[c.jsx(Z,{icon:g$,size:14,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"max-sm:hidden",children:r("linkRepo")})]}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:n,className:"text-muted-foreground hover:text-destructive",title:r("delete.button"),children:[c.jsx(Z,{icon:ks,size:14,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"max-sm:hidden",children:r("delete.button")})]})]})})]})}function cOt({project:e,open:t,onOpenChange:n,onDelete:r}){const{t:i}=Ot("projects"),[s,a]=x.useState(!1),[o,l]=x.useState(!1),[u,d]=x.useState(!1),f=async()=>{d(!0);try{await r(s,o),n(!1)}finally{d(!1)}};return c.jsx(ql,{open:t,onOpenChange:n,children:c.jsxs(Gl,{children:[c.jsxs(Kl,{children:[c.jsx(Xl,{children:i("delete.title")}),c.jsx(Ql,{children:i("delete.description",{name:e?.name})})]}),c.jsxs("div",{className:"space-y-3 py-2",children:[e&&e.repositories.length>0&&c.jsx("div",{className:"rounded-md bg-amber-500/10 px-3 py-2 text-sm text-amber-600",children:i("delete.reposWarning",{count:e.repositories.length})}),e?.repository&&c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsx(ni,{id:"deleteDirectory",checked:s,onCheckedChange:h=>a(h===!0)}),c.jsx(Ur,{htmlFor:"deleteDirectory",className:"text-sm",children:i("delete.alsoDeleteDirectory")})]}),e?.app&&c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsx(ni,{id:"deleteApp",checked:o,onCheckedChange:h=>l(h===!0)}),c.jsx(Ur,{htmlFor:"deleteApp",className:"text-sm",children:i("delete.alsoDeleteApp")})]})]}),c.jsxs(Yl,{children:[c.jsx(Zl,{disabled:u,children:"Cancel"}),c.jsx(cg,{onClick:f,disabled:u,className:"bg-destructive hover:bg-destructive/90",children:i(u?"delete.deleting":"delete.button")})]})]})})}function uOt(){const{t:e}=Ot("projects"),t=Ni(),{data:n,isLoading:r,error:i}=Mc(),s=Wwe(),[a,o]=x.useState(null),[l,u]=x.useState(!1),[d,f]=x.useState(!1),[h,m]=x.useState(""),g=x.useMemo(()=>n?h?.trim()?n.map(v=>({project:v,score:Math.max(Ol(v.name,h),Ol(v.repository?.path??"",h),Ol(v.repository?.displayName??"",h))})).filter(({score:v})=>v>0).sort((v,_)=>_.score-v.score).map(({project:v})=>v):n:[],[n,h]),y=async(v,_)=>{a&&await s.mutateAsync({id:a.id,deleteDirectory:v,deleteApp:_})};return c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsxs("div",{className:"film-grain relative flex shrink-0 items-center gap-2 border-b border-border px-4 py-2",style:{background:"var(--gradient-header)"},children:[c.jsxs("div",{className:"relative min-w-0 flex-1 sm:max-w-64 sm:flex-none",children:[c.jsx(Z,{icon:cp,size:12,strokeWidth:2,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground"}),c.jsx(At,{value:h,onChange:v=>m(v.target.value),placeholder:e("searchPlaceholder"),className:"w-full pl-6"})]}),c.jsx("div",{className:"hidden sm:block flex-1"}),c.jsxs(_e,{size:"sm",variant:"outline",onClick:()=>f(!0),children:[c.jsx(Z,{icon:b$,size:16,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"max-sm:hidden",children:e("addRepo")})]}),c.jsxs(_e,{size:"sm",onClick:()=>u(!0),children:[c.jsx(Z,{icon:K_e,size:16,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"max-sm:hidden",children:e("newProjectButton")})]})]}),c.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[r&&c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(Z,{icon:Nt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}),i&&c.jsxs("div",{className:"flex items-center gap-3 py-6 text-destructive",children:[c.jsx(Z,{icon:wr,size:20,strokeWidth:2}),c.jsx("span",{className:"text-sm",children:e("error.failedToLoad",{message:i.message})})]}),!r&&!i&&n?.length===0&&c.jsx("div",{className:"py-12 text-muted-foreground",children:c.jsx("p",{className:"text-sm",children:e("empty.noProjects")})}),!r&&!i&&n&&n.length>0&&g.length===0&&c.jsx("div",{className:"py-12 text-muted-foreground",children:c.jsx("p",{className:"text-sm",children:e("empty.noMatches")})}),c.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:g.map(v=>c.jsx(lOt,{project:v,onAddRepo:()=>t({to:"/projects/$projectId",params:{projectId:v.id},search:{addRepo:!0}}),onDeleteClick:()=>o(v)},v.id))})]}),c.jsx(cOt,{project:a,open:a!==null,onOpenChange:v=>!v&&o(null),onDelete:y}),c.jsx(nOt,{open:l,onOpenChange:u}),c.jsx(pRe,{open:d,onOpenChange:f})]})}var xM,kde;function fl(){if(kde)return xM;kde=1;var e=Array.isArray;return xM=e,xM}var _M,Tde;function mRe(){if(Tde)return _M;Tde=1;var e=typeof eA=="object"&&eA&&eA.Object===Object&&eA;return _M=e,_M}var SM,Ade;function Nd(){if(Ade)return SM;Ade=1;var e=mRe(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return SM=n,SM}var wM,Nde;function n_(){if(Nde)return wM;Nde=1;var e=Nd(),t=e.Symbol;return wM=t,wM}var EM,Ode;function dOt(){if(Ode)return EM;Ode=1;var e=n_(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,i=e?e.toStringTag:void 0;function s(a){var o=n.call(a,i),l=a[i];try{a[i]=void 0;var u=!0}catch{}var d=r.call(a);return u&&(o?a[i]=l:delete a[i]),d}return EM=s,EM}var CM,Rde;function fOt(){if(Rde)return CM;Rde=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return CM=n,CM}var kM,Ide;function vp(){if(Ide)return kM;Ide=1;var e=n_(),t=dOt(),n=fOt(),r="[object Null]",i="[object Undefined]",s=e?e.toStringTag:void 0;function a(o){return o==null?o===void 0?i:r:s&&s in Object(o)?t(o):n(o)}return kM=a,kM}var TM,Dde;function Od(){if(Dde)return TM;Dde=1;function e(t){return t!=null&&typeof t=="object"}return TM=e,TM}var AM,jde;function r_(){if(jde)return AM;jde=1;var e=vp(),t=Od(),n="[object Symbol]";function r(i){return typeof i=="symbol"||t(i)&&e(i)==n}return AM=r,AM}var NM,Pde;function vZ(){if(Pde)return NM;Pde=1;var e=fl(),t=r_(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(s,a){if(e(s))return!1;var o=typeof s;return o=="number"||o=="symbol"||o=="boolean"||s==null||t(s)?!0:r.test(s)||!n.test(s)||a!=null&&s in Object(a)}return NM=i,NM}var OM,Lde;function Rd(){if(Lde)return OM;Lde=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return OM=e,OM}var RM,Mde;function xZ(){if(Mde)return RM;Mde=1;var e=vp(),t=Rd(),n="[object AsyncFunction]",r="[object Function]",i="[object GeneratorFunction]",s="[object Proxy]";function a(o){if(!t(o))return!1;var l=e(o);return l==r||l==i||l==n||l==s}return RM=a,RM}var IM,Fde;function hOt(){if(Fde)return IM;Fde=1;var e=Nd(),t=e["__core-js_shared__"];return IM=t,IM}var DM,Bde;function pOt(){if(Bde)return DM;Bde=1;var e=hOt(),t=(function(){var r=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""})();function n(r){return!!t&&t in r}return DM=n,DM}var jM,$de;function gRe(){if($de)return jM;$de=1;var e=Function.prototype,t=e.toString;function n(r){if(r!=null){try{return t.call(r)}catch{}try{return r+""}catch{}}return""}return jM=n,jM}var PM,zde;function mOt(){if(zde)return PM;zde=1;var e=xZ(),t=pOt(),n=Rd(),r=gRe(),i=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,a=Function.prototype,o=Object.prototype,l=a.toString,u=o.hasOwnProperty,d=RegExp("^"+l.call(u).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function f(h){if(!n(h)||t(h))return!1;var m=e(h)?d:s;return m.test(r(h))}return PM=f,PM}var LM,Ude;function gOt(){if(Ude)return LM;Ude=1;function e(t,n){return t?.[n]}return LM=e,LM}var MM,Hde;function Ky(){if(Hde)return MM;Hde=1;var e=mOt(),t=gOt();function n(r,i){var s=t(r,i);return e(s)?s:void 0}return MM=n,MM}var FM,Vde;function T5(){if(Vde)return FM;Vde=1;var e=Ky(),t=e(Object,"create");return FM=t,FM}var BM,Wde;function bOt(){if(Wde)return BM;Wde=1;var e=T5();function t(){this.__data__=e?e(null):{},this.size=0}return BM=t,BM}var $M,qde;function yOt(){if(qde)return $M;qde=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return $M=e,$M}var zM,Gde;function vOt(){if(Gde)return zM;Gde=1;var e=T5(),t="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function i(s){var a=this.__data__;if(e){var o=a[s];return o===t?void 0:o}return r.call(a,s)?a[s]:void 0}return zM=i,zM}var UM,Kde;function xOt(){if(Kde)return UM;Kde=1;var e=T5(),t=Object.prototype,n=t.hasOwnProperty;function r(i){var s=this.__data__;return e?s[i]!==void 0:n.call(s,i)}return UM=r,UM}var HM,Yde;function _Ot(){if(Yde)return HM;Yde=1;var e=T5(),t="__lodash_hash_undefined__";function n(r,i){var s=this.__data__;return this.size+=this.has(r)?0:1,s[r]=e&&i===void 0?t:i,this}return HM=n,HM}var VM,Xde;function SOt(){if(Xde)return VM;Xde=1;var e=bOt(),t=yOt(),n=vOt(),r=xOt(),i=_Ot();function s(a){var o=-1,l=a==null?0:a.length;for(this.clear();++o<l;){var u=a[o];this.set(u[0],u[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=r,s.prototype.set=i,VM=s,VM}var WM,Qde;function wOt(){if(Qde)return WM;Qde=1;function e(){this.__data__=[],this.size=0}return WM=e,WM}var qM,Zde;function A5(){if(Zde)return qM;Zde=1;function e(t,n){return t===n||t!==t&&n!==n}return qM=e,qM}var GM,Jde;function N5(){if(Jde)return GM;Jde=1;var e=A5();function t(n,r){for(var i=n.length;i--;)if(e(n[i][0],r))return i;return-1}return GM=t,GM}var KM,efe;function EOt(){if(efe)return KM;efe=1;var e=N5(),t=Array.prototype,n=t.splice;function r(i){var s=this.__data__,a=e(s,i);if(a<0)return!1;var o=s.length-1;return a==o?s.pop():n.call(s,a,1),--this.size,!0}return KM=r,KM}var YM,tfe;function COt(){if(tfe)return YM;tfe=1;var e=N5();function t(n){var r=this.__data__,i=e(r,n);return i<0?void 0:r[i][1]}return YM=t,YM}var XM,nfe;function kOt(){if(nfe)return XM;nfe=1;var e=N5();function t(n){return e(this.__data__,n)>-1}return XM=t,XM}var QM,rfe;function TOt(){if(rfe)return QM;rfe=1;var e=N5();function t(n,r){var i=this.__data__,s=e(i,n);return s<0?(++this.size,i.push([n,r])):i[s][1]=r,this}return QM=t,QM}var ZM,ife;function O5(){if(ife)return ZM;ife=1;var e=wOt(),t=EOt(),n=COt(),r=kOt(),i=TOt();function s(a){var o=-1,l=a==null?0:a.length;for(this.clear();++o<l;){var u=a[o];this.set(u[0],u[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=r,s.prototype.set=i,ZM=s,ZM}var JM,sfe;function _Z(){if(sfe)return JM;sfe=1;var e=Ky(),t=Nd(),n=e(t,"Map");return JM=n,JM}var e8,afe;function AOt(){if(afe)return e8;afe=1;var e=SOt(),t=O5(),n=_Z();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return e8=r,e8}var t8,ofe;function NOt(){if(ofe)return t8;ofe=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return t8=e,t8}var n8,lfe;function R5(){if(lfe)return n8;lfe=1;var e=NOt();function t(n,r){var i=n.__data__;return e(r)?i[typeof r=="string"?"string":"hash"]:i.map}return n8=t,n8}var r8,cfe;function OOt(){if(cfe)return r8;cfe=1;var e=R5();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return r8=t,r8}var i8,ufe;function ROt(){if(ufe)return i8;ufe=1;var e=R5();function t(n){return e(this,n).get(n)}return i8=t,i8}var s8,dfe;function IOt(){if(dfe)return s8;dfe=1;var e=R5();function t(n){return e(this,n).has(n)}return s8=t,s8}var a8,ffe;function DOt(){if(ffe)return a8;ffe=1;var e=R5();function t(n,r){var i=e(this,n),s=i.size;return i.set(n,r),this.size+=i.size==s?0:1,this}return a8=t,a8}var o8,hfe;function SZ(){if(hfe)return o8;hfe=1;var e=AOt(),t=OOt(),n=ROt(),r=IOt(),i=DOt();function s(a){var o=-1,l=a==null?0:a.length;for(this.clear();++o<l;){var u=a[o];this.set(u[0],u[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=r,s.prototype.set=i,o8=s,o8}var l8,pfe;function bRe(){if(pfe)return l8;pfe=1;var e=SZ(),t="Expected a function";function n(r,i){if(typeof r!="function"||i!=null&&typeof i!="function")throw new TypeError(t);var s=function(){var a=arguments,o=i?i.apply(this,a):a[0],l=s.cache;if(l.has(o))return l.get(o);var u=r.apply(this,a);return s.cache=l.set(o,u)||l,u};return s.cache=new(n.Cache||e),s}return n.Cache=e,l8=n,l8}var c8,mfe;function jOt(){if(mfe)return c8;mfe=1;var e=bRe(),t=500;function n(r){var i=e(r,function(a){return s.size===t&&s.clear(),a}),s=i.cache;return i}return c8=n,c8}var u8,gfe;function POt(){if(gfe)return u8;gfe=1;var e=jOt(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=e(function(i){var s=[];return i.charCodeAt(0)===46&&s.push(""),i.replace(t,function(a,o,l,u){s.push(l?u.replace(n,"$1"):o||a)}),s});return u8=r,u8}var d8,bfe;function I5(){if(bfe)return d8;bfe=1;function e(t,n){for(var r=-1,i=t==null?0:t.length,s=Array(i);++r<i;)s[r]=n(t[r],r,t);return s}return d8=e,d8}var f8,yfe;function LOt(){if(yfe)return f8;yfe=1;var e=n_(),t=I5(),n=fl(),r=r_(),i=e?e.prototype:void 0,s=i?i.toString:void 0;function a(o){if(typeof o=="string")return o;if(n(o))return t(o,a)+"";if(r(o))return s?s.call(o):"";var l=o+"";return l=="0"&&1/o==-1/0?"-0":l}return f8=a,f8}var h8,vfe;function yRe(){if(vfe)return h8;vfe=1;var e=LOt();function t(n){return n==null?"":e(n)}return h8=t,h8}var p8,xfe;function D5(){if(xfe)return p8;xfe=1;var e=fl(),t=vZ(),n=POt(),r=yRe();function i(s,a){return e(s)?s:t(s,a)?[s]:n(r(s))}return p8=i,p8}var m8,_fe;function fk(){if(_fe)return m8;_fe=1;var e=r_();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return m8=t,m8}var g8,Sfe;function j5(){if(Sfe)return g8;Sfe=1;var e=D5(),t=fk();function n(r,i){i=e(i,r);for(var s=0,a=i.length;r!=null&&s<a;)r=r[t(i[s++])];return s&&s==a?r:void 0}return g8=n,g8}var b8,wfe;function vRe(){if(wfe)return b8;wfe=1;var e=j5();function t(n,r,i){var s=n==null?void 0:e(n,r);return s===void 0?i:s}return b8=t,b8}var MOt=vRe();const qa=Kn(MOt);var y8,Efe;function FOt(){if(Efe)return y8;Efe=1;function e(t){return t==null}return y8=e,y8}var BOt=FOt();const Dn=Kn(BOt);var v8,Cfe;function $Ot(){if(Cfe)return v8;Cfe=1;var e=vp(),t=fl(),n=Od(),r="[object String]";function i(s){return typeof s=="string"||!t(s)&&n(s)&&e(s)==r}return v8=i,v8}var zOt=$Ot();const qm=Kn(zOt);var UOt=xZ();const hn=Kn(UOt);var HOt=Rd();const i_=Kn(HOt);var x8={exports:{}},ri={};var kfe;function VOt(){if(kfe)return ri;kfe=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),a=Symbol.for("react.context"),o=Symbol.for("react.server_context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),g;g=Symbol.for("react.module.reference");function y(v){if(typeof v=="object"&&v!==null){var _=v.$$typeof;switch(_){case e:switch(v=v.type,v){case n:case i:case r:case u:case d:return v;default:switch(v=v&&v.$$typeof,v){case o:case a:case l:case h:case f:case s:return v;default:return _}}case t:return _}}}return ri.ContextConsumer=a,ri.ContextProvider=s,ri.Element=e,ri.ForwardRef=l,ri.Fragment=n,ri.Lazy=h,ri.Memo=f,ri.Portal=t,ri.Profiler=i,ri.StrictMode=r,ri.Suspense=u,ri.SuspenseList=d,ri.isAsyncMode=function(){return!1},ri.isConcurrentMode=function(){return!1},ri.isContextConsumer=function(v){return y(v)===a},ri.isContextProvider=function(v){return y(v)===s},ri.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===e},ri.isForwardRef=function(v){return y(v)===l},ri.isFragment=function(v){return y(v)===n},ri.isLazy=function(v){return y(v)===h},ri.isMemo=function(v){return y(v)===f},ri.isPortal=function(v){return y(v)===t},ri.isProfiler=function(v){return y(v)===i},ri.isStrictMode=function(v){return y(v)===r},ri.isSuspense=function(v){return y(v)===u},ri.isSuspenseList=function(v){return y(v)===d},ri.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===n||v===i||v===r||v===u||v===d||v===m||typeof v=="object"&&v!==null&&(v.$$typeof===h||v.$$typeof===f||v.$$typeof===s||v.$$typeof===a||v.$$typeof===l||v.$$typeof===g||v.getModuleId!==void 0)},ri.typeOf=y,ri}var Tfe;function WOt(){return Tfe||(Tfe=1,x8.exports=VOt()),x8.exports}var qOt=WOt(),_8,Afe;function xRe(){if(Afe)return _8;Afe=1;var e=vp(),t=Od(),n="[object Number]";function r(i){return typeof i=="number"||t(i)&&e(i)==n}return _8=r,_8}var S8,Nfe;function GOt(){if(Nfe)return S8;Nfe=1;var e=xRe();function t(n){return e(n)&&n!=+n}return S8=t,S8}var KOt=GOt();const hg=Kn(KOt);var YOt=xRe();const _Re=Kn(YOt);var Ga=function(t){return t===0?0:t>0?1:-1},Tb=function(t){return qm(t)&&t.indexOf("%")===t.length-1},zt=function(t){return _Re(t)&&!hg(t)},XOt=function(t){return Dn(t)},va=function(t){return zt(t)||qm(t)},QOt=0,xp=function(t){var n=++QOt;return"".concat(t||"").concat(n)},el=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!zt(t)&&!qm(t))return r;var s;if(Tb(t)){var a=t.indexOf("%");s=n*parseFloat(t.slice(0,a))/100}else s=+t;return hg(s)&&(s=r),i&&s>n&&(s=n),s},pm=function(t){if(!t)return null;var n=Object.keys(t);return n&&n.length?t[n[0]]:null},ZOt=function(t){if(!Array.isArray(t))return!1;for(var n=t.length,r={},i=0;i<n;i++)if(!r[t[i]])r[t[i]]=!0;else return!0;return!1},rr=function(t,n){return zt(t)&&zt(n)?function(r){return t+r*(n-t)}:function(){return n}};function BR(e,t,n){return!e||!e.length?null:e.find(function(r){return r&&(typeof t=="function"?t(r):qa(r,t))===n})}var JOt=function(t){if(!t||!t.length)return null;for(var n=t.length,r=0,i=0,s=0,a=0,o=1/0,l=-1/0,u=0,d=0,f=0;f<n;f++)u=t[f].cx||0,d=t[f].cy||0,r+=u,i+=d,s+=u*d,a+=u*u,o=Math.min(o,u),l=Math.max(l,u);var h=n*a!==r*r?(n*s-r*i)/(n*a-r*r):0;return{xmin:o,xmax:l,a:h,b:(i-h*r)/n}},eRt=function(t,n){return zt(t)&&zt(n)?t-n:qm(t)&&qm(n)?t.localeCompare(n):t instanceof Date&&n instanceof Date?t.getTime()-n.getTime():String(t).localeCompare(String(n))};function Yb(e,t){for(var n in e)if({}.hasOwnProperty.call(e,n)&&(!{}.hasOwnProperty.call(t,n)||e[n]!==t[n]))return!1;for(var r in t)if({}.hasOwnProperty.call(t,r)&&!{}.hasOwnProperty.call(e,r))return!1;return!0}function hU(e){"@babel/helpers - typeof";return hU=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hU(e)}var tRt=["viewBox","children"],nRt=["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-errormessage","aria-expanded","aria-flowto","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","className","color","height","id","lang","max","media","method","min","name","style","target","width","role","tabIndex","accentHeight","accumulate","additive","alignmentBaseline","allowReorder","alphabetic","amplitude","arabicForm","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baselineShift","baseProfile","bbox","begin","bias","by","calcMode","capHeight","clip","clipPath","clipPathUnits","clipRule","colorInterpolation","colorInterpolationFilters","colorProfile","colorRendering","contentScriptType","contentStyleType","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominantBaseline","dur","dx","dy","edgeMode","elevation","enableBackground","end","exponent","externalResourcesRequired","fill","fillOpacity","fillRule","filter","filterRes","filterUnits","floodColor","floodOpacity","focusable","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","format","from","fx","fy","g1","g2","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","glyphRef","gradientTransform","gradientUnits","hanging","horizAdvX","horizOriginX","href","ideographic","imageRendering","in2","in","intercept","k1","k2","k3","k4","k","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lengthAdjust","letterSpacing","lightingColor","limitingConeAngle","local","markerEnd","markerHeight","markerMid","markerStart","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","mode","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overlinePosition","overlineThickness","paintOrder","panose1","pathLength","patternContentUnits","patternTransform","patternUnits","pointerEvents","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","renderingIntent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","seed","shapeRendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stopColor","stopOpacity","strikethroughPosition","strikethroughThickness","string","stroke","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeOpacity","strokeWidth","surfaceScale","systemLanguage","tableValues","targetX","targetY","textAnchor","textDecoration","textLength","textRendering","to","transform","u1","u2","underlinePosition","underlineThickness","unicode","unicodeBidi","unicodeRange","unitsPerEm","vAlphabetic","values","vectorEffect","version","vertAdvY","vertOriginX","vertOriginY","vHanging","vIdeographic","viewTarget","visibility","vMathematical","widths","wordSpacing","writingMode","x1","x2","x","xChannelSelector","xHeight","xlinkActuate","xlinkArcrole","xlinkHref","xlinkRole","xlinkShow","xlinkTitle","xlinkType","xmlBase","xmlLang","xmlns","xmlnsXlink","xmlSpace","y1","y2","y","yChannelSelector","z","zoomAndPan","ref","key","angle"],Ofe=["points","pathLength"],w8={svg:tRt,polygon:Ofe,polyline:Ofe},wZ=["dangerouslySetInnerHTML","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"],$R=function(t,n){if(!t||typeof t=="function"||typeof t=="boolean")return null;var r=t;if(x.isValidElement(t)&&(r=t.props),!i_(r))return null;var i={};return Object.keys(r).forEach(function(s){wZ.includes(s)&&(i[s]=n||function(a){return r[s](r,a)})}),i},rRt=function(t,n,r){return function(i){return t(n,r,i),null}},xd=function(t,n,r){if(!i_(t)||hU(t)!=="object")return null;var i=null;return Object.keys(t).forEach(function(s){var a=t[s];wZ.includes(s)&&typeof a=="function"&&(i||(i={}),i[s]=rRt(a,n,r))}),i},iRt=["children"],sRt=["children"];function Rfe(e,t){if(e==null)return{};var n=aRt(e,t),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function aRt(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function pU(e){"@babel/helpers - typeof";return pU=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pU(e)}var Ife={click:"onClick",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",mouseout:"onMouseOut",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",touchcancel:"onTouchCancel",touchend:"onTouchEnd",touchmove:"onTouchMove",touchstart:"onTouchStart",contextmenu:"onContextMenu",dblclick:"onDoubleClick"},Fh=function(t){return typeof t=="string"?t:t?t.displayName||t.name||"Component":""},Dfe=null,E8=null,P5=function e(t){if(t===Dfe&&Array.isArray(E8))return E8;var n=[];return x.Children.forEach(t,function(r){Dn(r)||(qOt.isFragment(r)?n=n.concat(e(r.props.children)):n.push(r))}),E8=n,Dfe=t,n};function uo(e,t){var n=[],r=[];return Array.isArray(t)?r=t.map(function(i){return Fh(i)}):r=[Fh(t)],P5(e).forEach(function(i){var s=qa(i,"type.displayName")||qa(i,"type.name");r.indexOf(s)!==-1&&n.push(i)}),n}function Ks(e,t){var n=uo(e,t);return n&&n[0]}var zR=function(t){if(!t||!t.props)return!1;var n=t.props,r=n.width,i=n.height;return!(!zt(r)||r<=0||!zt(i)||i<=0)},oRt=["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColormatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-url","foreignObject","g","glyph","glyphRef","hkern","image","line","lineGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"],SRe=function(t){return t&&t.type&&qm(t.type)&&oRt.indexOf(t.type)>=0},wRe=function(t){return t&&pU(t)==="object"&&"clipDot"in t},lRt=function(t,n,r,i){var s,a=(s=w8?.[i])!==null&&s!==void 0?s:[];return n.startsWith("data-")||!hn(t)&&(i&&a.includes(n)||nRt.includes(n))||r&&wZ.includes(n)},ERe=function(t){var n=[];return P5(t).forEach(function(r){SRe(r)&&n.push(r)}),n},nn=function(t,n,r){if(!t||typeof t=="function"||typeof t=="boolean")return null;var i=t;if(x.isValidElement(t)&&(i=t.props),!i_(i))return null;var s={};return Object.keys(i).forEach(function(a){var o;lRt((o=i)===null||o===void 0?void 0:o[a],a,n,r)&&(s[a]=i[a])}),s},mU=function e(t,n){if(t===n)return!0;var r=x.Children.count(t);if(r!==x.Children.count(n))return!1;if(r===0)return!0;if(r===1)return jfe(Array.isArray(t)?t[0]:t,Array.isArray(n)?n[0]:n);for(var i=0;i<r;i++){var s=t[i],a=n[i];if(Array.isArray(s)||Array.isArray(a)){if(!e(s,a))return!1}else if(!jfe(s,a))return!1}return!0},jfe=function(t,n){if(Dn(t)&&Dn(n))return!0;if(!Dn(t)&&!Dn(n)){var r=t.props||{},i=r.children,s=Rfe(r,iRt),a=n.props||{},o=a.children,l=Rfe(a,sRt);return i&&o?Yb(s,l)&&mU(i,o):!i&&!o?Yb(s,l):!1}return!1},Pfe=function(t,n){var r=[],i={};return P5(t).forEach(function(s,a){if(SRe(s))r.push(s);else if(s){var o=Fh(s.type),l=n[o]||{},u=l.handler,d=l.once;if(u&&(!d||!i[o])){var f=u(s,o,a);r.push(f),i[o]=!0}}}),r},cRt=function(t){var n=t&&t.type;return n&&Ife[n]?Ife[n]:null},uRt=function(t,n){return P5(n).indexOf(t)},dRt=["children","width","height","viewBox","className","style","title","desc"];function gU(){return gU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},gU.apply(this,arguments)}function fRt(e,t){if(e==null)return{};var n=hRt(e,t),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function hRt(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function f2(e){var t=e.children,n=e.width,r=e.height,i=e.viewBox,s=e.className,a=e.style,o=e.title,l=e.desc,u=fRt(e,dRt),d=i||{width:n,height:r,x:0,y:0},f=On("recharts-surface",s);return Q.createElement("svg",gU({},nn(u,!0,"svg"),{className:f,width:n,height:r,style:a,viewBox:"".concat(d.x," ").concat(d.y," ").concat(d.width," ").concat(d.height)}),Q.createElement("title",null,o),Q.createElement("desc",null,l),t)}var pRt=["children","className"];function bU(){return bU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},bU.apply(this,arguments)}function mRt(e,t){if(e==null)return{};var n=gRt(e,t),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function gRt(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var Cn=Q.forwardRef(function(e,t){var n=e.children,r=e.className,i=mRt(e,pRt),s=On("recharts-layer",r);return Q.createElement("g",bU({className:s},nn(i,!0),{ref:t}),n)}),md=function(t,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s]},C8,Lfe;function CRe(){if(Lfe)return C8;Lfe=1;function e(t,n,r){var i=-1,s=t.length;n<0&&(n=-n>s?0:s+n),r=r>s?s:r,r<0&&(r+=s),s=n>r?0:r-n>>>0,n>>>=0;for(var a=Array(s);++i<s;)a[i]=t[i+n];return a}return C8=e,C8}var k8,Mfe;function bRt(){if(Mfe)return k8;Mfe=1;var e=CRe();function t(n,r,i){var s=n.length;return i=i===void 0?s:i,!r&&i>=s?n:e(n,r,i)}return k8=t,k8}var T8,Ffe;function kRe(){if(Ffe)return T8;Ffe=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",i=t+n+r,s="\\ufe0e\\ufe0f",a="\\u200d",o=RegExp("["+a+e+i+s+"]");function l(u){return o.test(u)}return T8=l,T8}var A8,Bfe;function yRt(){if(Bfe)return A8;Bfe=1;function e(t){return t.split("")}return A8=e,A8}var N8,$fe;function vRt(){if($fe)return N8;$fe=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",i=t+n+r,s="\\ufe0e\\ufe0f",a="["+e+"]",o="["+i+"]",l="\\ud83c[\\udffb-\\udfff]",u="(?:"+o+"|"+l+")",d="[^"+e+"]",f="(?:\\ud83c[\\udde6-\\uddff]){2}",h="[\\ud800-\\udbff][\\udc00-\\udfff]",m="\\u200d",g=u+"?",y="["+s+"]?",v="(?:"+m+"(?:"+[d,f,h].join("|")+")"+y+g+")*",_=y+g+v,S="(?:"+[d+o+"?",o,f,h,a].join("|")+")",E=RegExp(l+"(?="+l+")|"+S+_,"g");function T(k){return k.match(E)||[]}return N8=T,N8}var O8,zfe;function xRt(){if(zfe)return O8;zfe=1;var e=yRt(),t=kRe(),n=vRt();function r(i){return t(i)?n(i):e(i)}return O8=r,O8}var R8,Ufe;function _Rt(){if(Ufe)return R8;Ufe=1;var e=bRt(),t=kRe(),n=xRt(),r=yRe();function i(s){return function(a){a=r(a);var o=t(a)?n(a):void 0,l=o?o[0]:a.charAt(0),u=o?e(o,1).join(""):a.slice(1);return l[s]()+u}}return R8=i,R8}var I8,Hfe;function SRt(){if(Hfe)return I8;Hfe=1;var e=_Rt(),t=e("toUpperCase");return I8=t,I8}var wRt=SRt();const L5=Kn(wRt);function ji(e){return function(){return e}}const TRe=Math.cos,UR=Math.sin,Id=Math.sqrt,HR=Math.PI,M5=2*HR,yU=Math.PI,vU=2*yU,sb=1e-6,ERt=vU-sb;function ARe(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function CRt(e){let t=Math.floor(e);if(!(t>=0))throw new Error(`invalid digits: ${e}`);if(t>15)return ARe;const n=10**t;return function(r){this._+=r[0];for(let i=1,s=r.length;i<s;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class kRt{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?ARe:CRt(t)}moveTo(t,n){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,n){this._append`L${this._x1=+t},${this._y1=+n}`}quadraticCurveTo(t,n,r,i){this._append`Q${+t},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(t,n,r,i,s,a){this._append`C${+t},${+n},${+r},${+i},${this._x1=+s},${this._y1=+a}`}arcTo(t,n,r,i,s){if(t=+t,n=+n,r=+r,i=+i,s=+s,s<0)throw new Error(`negative radius: ${s}`);let a=this._x1,o=this._y1,l=r-t,u=i-n,d=a-t,f=o-n,h=d*d+f*f;if(this._x1===null)this._append`M${this._x1=t},${this._y1=n}`;else if(h>sb)if(!(Math.abs(f*l-u*d)>sb)||!s)this._append`L${this._x1=t},${this._y1=n}`;else{let m=r-a,g=i-o,y=l*l+u*u,v=m*m+g*g,_=Math.sqrt(y),S=Math.sqrt(h),E=s*Math.tan((yU-Math.acos((y+h-v)/(2*_*S)))/2),T=E/S,k=E/_;Math.abs(T-1)>sb&&this._append`L${t+T*d},${n+T*f}`,this._append`A${s},${s},0,0,${+(f*m>d*g)},${this._x1=t+k*l},${this._y1=n+k*u}`}}arc(t,n,r,i,s,a){if(t=+t,n=+n,r=+r,a=!!a,r<0)throw new Error(`negative radius: ${r}`);let o=r*Math.cos(i),l=r*Math.sin(i),u=t+o,d=n+l,f=1^a,h=a?i-s:s-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>sb||Math.abs(this._y1-d)>sb)&&this._append`L${u},${d}`,r&&(h<0&&(h=h%vU+vU),h>ERt?this._append`A${r},${r},0,1,${f},${t-o},${n-l}A${r},${r},0,1,${f},${this._x1=u},${this._y1=d}`:h>sb&&this._append`A${r},${r},0,${+(h>=yU)},${f},${this._x1=t+r*Math.cos(s)},${this._y1=n+r*Math.sin(s)}`)}rect(t,n,r,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function EZ(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);t=r}return e},()=>new kRt(t)}function CZ(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function NRe(e){this._context=e}NRe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function F5(e){return new NRe(e)}function ORe(e){return e[0]}function RRe(e){return e[1]}function IRe(e,t){var n=ji(!0),r=null,i=F5,s=null,a=EZ(o);e=typeof e=="function"?e:e===void 0?ORe:ji(e),t=typeof t=="function"?t:t===void 0?RRe:ji(t);function o(l){var u,d=(l=CZ(l)).length,f,h=!1,m;for(r==null&&(s=i(m=a())),u=0;u<=d;++u)!(u<d&&n(f=l[u],u,l))===h&&((h=!h)?s.lineStart():s.lineEnd()),h&&s.point(+e(f,u,l),+t(f,u,l));if(m)return s=null,m+""||null}return o.x=function(l){return arguments.length?(e=typeof l=="function"?l:ji(+l),o):e},o.y=function(l){return arguments.length?(t=typeof l=="function"?l:ji(+l),o):t},o.defined=function(l){return arguments.length?(n=typeof l=="function"?l:ji(!!l),o):n},o.curve=function(l){return arguments.length?(i=l,r!=null&&(s=i(r)),o):i},o.context=function(l){return arguments.length?(l==null?r=s=null:s=i(r=l),o):r},o}function aN(e,t,n){var r=null,i=ji(!0),s=null,a=F5,o=null,l=EZ(u);e=typeof e=="function"?e:e===void 0?ORe:ji(+e),t=typeof t=="function"?t:ji(t===void 0?0:+t),n=typeof n=="function"?n:n===void 0?RRe:ji(+n);function u(f){var h,m,g,y=(f=CZ(f)).length,v,_=!1,S,E=new Array(y),T=new Array(y);for(s==null&&(o=a(S=l())),h=0;h<=y;++h){if(!(h<y&&i(v=f[h],h,f))===_)if(_=!_)m=h,o.areaStart(),o.lineStart();else{for(o.lineEnd(),o.lineStart(),g=h-1;g>=m;--g)o.point(E[g],T[g]);o.lineEnd(),o.areaEnd()}_&&(E[h]=+e(v,h,f),T[h]=+t(v,h,f),o.point(r?+r(v,h,f):E[h],n?+n(v,h,f):T[h]))}if(S)return o=null,S+""||null}function d(){return IRe().defined(i).curve(a).context(s)}return u.x=function(f){return arguments.length?(e=typeof f=="function"?f:ji(+f),r=null,u):e},u.x0=function(f){return arguments.length?(e=typeof f=="function"?f:ji(+f),u):e},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:ji(+f),u):r},u.y=function(f){return arguments.length?(t=typeof f=="function"?f:ji(+f),n=null,u):t},u.y0=function(f){return arguments.length?(t=typeof f=="function"?f:ji(+f),u):t},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:ji(+f),u):n},u.lineX0=u.lineY0=function(){return d().x(e).y(t)},u.lineY1=function(){return d().x(e).y(n)},u.lineX1=function(){return d().x(r).y(t)},u.defined=function(f){return arguments.length?(i=typeof f=="function"?f:ji(!!f),u):i},u.curve=function(f){return arguments.length?(a=f,s!=null&&(o=a(s)),u):a},u.context=function(f){return arguments.length?(f==null?s=o=null:o=a(s=f),u):s},u}class DRe{constructor(t,n){this._context=t,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,n){switch(t=+t,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,n,t,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,t,this._y0,t,n);break}}this._x0=t,this._y0=n}}function TRt(e){return new DRe(e,!0)}function ARt(e){return new DRe(e,!1)}const kZ={draw(e,t){const n=Id(t/HR);e.moveTo(n,0),e.arc(0,0,n,0,M5)}},NRt={draw(e,t){const n=Id(t/5)/2;e.moveTo(-3*n,-n),e.lineTo(-n,-n),e.lineTo(-n,-3*n),e.lineTo(n,-3*n),e.lineTo(n,-n),e.lineTo(3*n,-n),e.lineTo(3*n,n),e.lineTo(n,n),e.lineTo(n,3*n),e.lineTo(-n,3*n),e.lineTo(-n,n),e.lineTo(-3*n,n),e.closePath()}},jRe=Id(1/3),ORt=jRe*2,RRt={draw(e,t){const n=Id(t/ORt),r=n*jRe;e.moveTo(0,-n),e.lineTo(r,0),e.lineTo(0,n),e.lineTo(-r,0),e.closePath()}},IRt={draw(e,t){const n=Id(t),r=-n/2;e.rect(r,r,n,n)}},DRt=.8908130915292852,PRe=UR(HR/10)/UR(7*HR/10),jRt=UR(M5/10)*PRe,PRt=-TRe(M5/10)*PRe,LRt={draw(e,t){const n=Id(t*DRt),r=jRt*n,i=PRt*n;e.moveTo(0,-n),e.lineTo(r,i);for(let s=1;s<5;++s){const a=M5*s/5,o=TRe(a),l=UR(a);e.lineTo(l*n,-o*n),e.lineTo(o*r-l*i,l*r+o*i)}e.closePath()}},D8=Id(3),MRt={draw(e,t){const n=-Id(t/(D8*3));e.moveTo(0,n*2),e.lineTo(-D8*n,-n),e.lineTo(D8*n,-n),e.closePath()}},Jc=-.5,eu=Id(3)/2,xU=1/Id(12),FRt=(xU/2+1)*3,BRt={draw(e,t){const n=Id(t/FRt),r=n/2,i=n*xU,s=r,a=n*xU+n,o=-s,l=a;e.moveTo(r,i),e.lineTo(s,a),e.lineTo(o,l),e.lineTo(Jc*r-eu*i,eu*r+Jc*i),e.lineTo(Jc*s-eu*a,eu*s+Jc*a),e.lineTo(Jc*o-eu*l,eu*o+Jc*l),e.lineTo(Jc*r+eu*i,Jc*i-eu*r),e.lineTo(Jc*s+eu*a,Jc*a-eu*s),e.lineTo(Jc*o+eu*l,Jc*l-eu*o),e.closePath()}};function $Rt(e,t){let n=null,r=EZ(i);e=typeof e=="function"?e:ji(e||kZ),t=typeof t=="function"?t:ji(t===void 0?64:+t);function i(){let s;if(n||(n=s=r()),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),s)return n=null,s+""||null}return i.type=function(s){return arguments.length?(e=typeof s=="function"?s:ji(s),i):e},i.size=function(s){return arguments.length?(t=typeof s=="function"?s:ji(+s),i):t},i.context=function(s){return arguments.length?(n=s??null,i):n},i}function VR(){}function WR(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function LRe(e){this._context=e}LRe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:WR(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:WR(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function zRt(e){return new LRe(e)}function MRe(e){this._context=e}MRe.prototype={areaStart:VR,areaEnd:VR,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:WR(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function URt(e){return new MRe(e)}function FRe(e){this._context=e}FRe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:WR(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function HRt(e){return new FRe(e)}function BRe(e){this._context=e}BRe.prototype={areaStart:VR,areaEnd:VR,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function VRt(e){return new BRe(e)}function Vfe(e){return e<0?-1:1}function Wfe(e,t,n){var r=e._x1-e._x0,i=t-e._x1,s=(e._y1-e._y0)/(r||i<0&&-0),a=(n-e._y1)/(i||r<0&&-0),o=(s*i+a*r)/(r+i);return(Vfe(s)+Vfe(a))*Math.min(Math.abs(s),Math.abs(a),.5*Math.abs(o))||0}function qfe(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function j8(e,t,n){var r=e._x0,i=e._y0,s=e._x1,a=e._y1,o=(s-r)/3;e._context.bezierCurveTo(r+o,i+o*t,s-o,a-o*n,s,a)}function qR(e){this._context=e}qR.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:j8(this,this._t0,qfe(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,j8(this,qfe(this,n=Wfe(this,e,t)),n);break;default:j8(this,this._t0,n=Wfe(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function $Re(e){this._context=new zRe(e)}($Re.prototype=Object.create(qR.prototype)).point=function(e,t){qR.prototype.point.call(this,t,e)};function zRe(e){this._context=e}zRe.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,s){this._context.bezierCurveTo(t,e,r,n,s,i)}};function WRt(e){return new qR(e)}function qRt(e){return new $Re(e)}function URe(e){this._context=e}URe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=Gfe(e),i=Gfe(t),s=0,a=1;a<n;++s,++a)this._context.bezierCurveTo(r[0][s],i[0][s],r[1][s],i[1][s],e[a],t[a]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(e,t){this._x.push(+e),this._y.push(+t)}};function Gfe(e){var t,n=e.length-1,r,i=new Array(n),s=new Array(n),a=new Array(n);for(i[0]=0,s[0]=2,a[0]=e[0]+2*e[1],t=1;t<n-1;++t)i[t]=1,s[t]=4,a[t]=4*e[t]+2*e[t+1];for(i[n-1]=2,s[n-1]=7,a[n-1]=8*e[n-1]+e[n],t=1;t<n;++t)r=i[t]/s[t-1],s[t]-=r,a[t]-=r*a[t-1];for(i[n-1]=a[n-1]/s[n-1],t=n-2;t>=0;--t)i[t]=(a[t]-i[t+1])/s[t];for(s[n-1]=(e[n]+i[n-1])/2,t=0;t<n-1;++t)s[t]=2*e[t+1]-i[t+1];return[i,s]}function GRt(e){return new URe(e)}function B5(e,t){this._context=e,this._t=t}B5.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}}this._x=e,this._y=t}};function KRt(e){return new B5(e,.5)}function YRt(e){return new B5(e,0)}function XRt(e){return new B5(e,1)}function Ix(e,t){if((a=e.length)>1)for(var n=1,r,i,s=e[t[0]],a,o=s.length;n<a;++n)for(i=s,s=e[t[n]],r=0;r<o;++r)s[r][1]+=s[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function _U(e){for(var t=e.length,n=new Array(t);--t>=0;)n[t]=t;return n}function QRt(e,t){return e[t]}function ZRt(e){const t=[];return t.key=e,t}function JRt(){var e=ji([]),t=_U,n=Ix,r=QRt;function i(s){var a=Array.from(e.apply(this,arguments),ZRt),o,l=a.length,u=-1,d;for(const f of s)for(o=0,++u;o<l;++o)(a[o][u]=[0,+r(f,a[o].key,u,s)]).data=f;for(o=0,d=CZ(t(a));o<l;++o)a[d[o]].index=o;return n(a,d),a}return i.keys=function(s){return arguments.length?(e=typeof s=="function"?s:ji(Array.from(s)),i):e},i.value=function(s){return arguments.length?(r=typeof s=="function"?s:ji(+s),i):r},i.order=function(s){return arguments.length?(t=s==null?_U:typeof s=="function"?s:ji(Array.from(s)),i):t},i.offset=function(s){return arguments.length?(n=s??Ix,i):n},i}function eIt(e,t){if((r=e.length)>0){for(var n,r,i=0,s=e[0].length,a;i<s;++i){for(a=n=0;n<r;++n)a+=e[n][i][1]||0;if(a)for(n=0;n<r;++n)e[n][i][1]/=a}Ix(e,t)}}function tIt(e,t){if((i=e.length)>0){for(var n=0,r=e[t[0]],i,s=r.length;n<s;++n){for(var a=0,o=0;a<i;++a)o+=e[a][n][1]||0;r[n][1]+=r[n][0]=-o/2}Ix(e,t)}}function nIt(e,t){if(!(!((a=e.length)>0)||!((s=(i=e[t[0]]).length)>0))){for(var n=0,r=1,i,s,a;r<s;++r){for(var o=0,l=0,u=0;o<a;++o){for(var d=e[t[o]],f=d[r][1]||0,h=d[r-1][1]||0,m=(f-h)/2,g=0;g<o;++g){var y=e[t[g]],v=y[r][1]||0,_=y[r-1][1]||0;m+=v-_}l+=f,u+=m*f}i[r-1][1]+=i[r-1][0]=n,l&&(n-=u/l)}i[r-1][1]+=i[r-1][0]=n,Ix(e,t)}}function h2(e){"@babel/helpers - typeof";return h2=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h2(e)}var rIt=["type","size","sizeType"];function SU(){return SU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},SU.apply(this,arguments)}function Kfe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Yfe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Kfe(Object(n),!0).forEach(function(r){iIt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Kfe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function iIt(e,t,n){return t=sIt(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function sIt(e){var t=aIt(e,"string");return h2(t)=="symbol"?t:t+""}function aIt(e,t){if(h2(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(h2(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function oIt(e,t){if(e==null)return{};var n=lIt(e,t),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function lIt(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var HRe={symbolCircle:kZ,symbolCross:NRt,symbolDiamond:RRt,symbolSquare:IRt,symbolStar:LRt,symbolTriangle:MRt,symbolWye:BRt},cIt=Math.PI/180,uIt=function(t){var n="symbol".concat(L5(t));return HRe[n]||kZ},dIt=function(t,n,r){if(n==="area")return t;switch(r){case"cross":return 5*t*t/9;case"diamond":return .5*t*t/Math.sqrt(3);case"square":return t*t;case"star":{var i=18*cIt;return 1.25*t*t*(Math.tan(i)-Math.tan(i*2)*Math.pow(Math.tan(i),2))}case"triangle":return Math.sqrt(3)*t*t/4;case"wye":return(21-10*Math.sqrt(3))*t*t/8;default:return Math.PI*t*t/4}},fIt=function(t,n){HRe["symbol".concat(L5(t))]=n},hk=function(t){var n=t.type,r=n===void 0?"circle":n,i=t.size,s=i===void 0?64:i,a=t.sizeType,o=a===void 0?"area":a,l=oIt(t,rIt),u=Yfe(Yfe({},l),{},{type:r,size:s,sizeType:o}),d=function(){var v=uIt(r),_=$Rt().type(v).size(dIt(s,o,r));return _()},f=u.className,h=u.cx,m=u.cy,g=nn(u,!0);return h===+h&&m===+m&&s===+s?Q.createElement("path",SU({},g,{className:On("recharts-symbols",f),transform:"translate(".concat(h,", ").concat(m,")"),d:d()})):null};hk.registerSymbol=fIt;function Dx(e){"@babel/helpers - typeof";return Dx=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Dx(e)}function wU(){return wU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},wU.apply(this,arguments)}function Xfe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function hIt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Xfe(Object(n),!0).forEach(function(r){p2(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xfe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function pIt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function mIt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,WRe(r.key),r)}}function gIt(e,t,n){return t&&mIt(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function bIt(e,t,n){return t=GR(t),yIt(e,VRe()?Reflect.construct(t,n||[],GR(e).constructor):t.apply(e,n))}function yIt(e,t){if(t&&(Dx(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return vIt(e)}function vIt(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function VRe(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(VRe=function(){return!!e})()}function GR(e){return GR=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},GR(e)}function xIt(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&EU(e,t)}function EU(e,t){return EU=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},EU(e,t)}function p2(e,t,n){return t=WRe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function WRe(e){var t=_It(e,"string");return Dx(t)=="symbol"?t:t+""}function _It(e,t){if(Dx(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Dx(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var tu=32,TZ=(function(e){function t(){return pIt(this,t),bIt(this,t,arguments)}return xIt(t,e),gIt(t,[{key:"renderIcon",value:function(r){var i=this.props.inactiveColor,s=tu/2,a=tu/6,o=tu/3,l=r.inactive?i:r.color;if(r.type==="plainline")return Q.createElement("line",{strokeWidth:4,fill:"none",stroke:l,strokeDasharray:r.payload.strokeDasharray,x1:0,y1:s,x2:tu,y2:s,className:"recharts-legend-icon"});if(r.type==="line")return Q.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(s,"h").concat(o,`
140
140
  A`).concat(a,",").concat(a,",0,1,1,").concat(2*o,",").concat(s,`
@@ -325,7 +325,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
325
325
  `).forEach(v=>{const _=v.trim();if(!_||_.startsWith("#"))return;const S=_.indexOf("=");if(S>0){const E=_.slice(0,S).trim(),T=_.slice(S+1).trim();E&&(y[E]=T)}}),await n.mutateAsync({id:e.id,updates:{environmentVariables:y}}),o(i),u(!0),setTimeout(()=>u(!1),2e3)};return c.jsxs("div",{className:"rounded-lg border bg-background/80 backdrop-blur-sm p-4 space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:t("apps.environment.title")}),h&&c.jsxs("span",{className:"text-xs text-amber-500",children:["(",t("apps.environment.unsavedChanges"),")"]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(wh,{children:[c.jsx(Eh,{className:"p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",onClick:()=>f(!d),children:c.jsx(Z,{icon:d?eSe:bC,size:14,strokeWidth:2})}),c.jsx(Ch,{children:t(d?"apps.environment.showValues":"apps.environment.hideValues")})]}),h&&c.jsx(_e,{variant:"outline",size:"sm",onClick:()=>{s(a),u(!1)},children:t("apps.cancel")}),c.jsx(_e,{size:"sm",onClick:g,disabled:n.isPending||!h,children:n.isPending?c.jsxs(c.Fragment,{children:[c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}),t("status.saving")]}):l?c.jsxs(c.Fragment,{children:[c.jsx(Z,{icon:sl,size:14,strokeWidth:2,className:"text-green-500"}),t("status.saved")]}):t("apps.environment.save")})]})]}),d?c.jsx("div",{className:"font-mono text-sm min-h-[120px] rounded-md border bg-background px-3 py-2 cursor-pointer",onClick:()=>f(!1),children:m.length===0||m.length===1&&m[0].type==="empty"?c.jsx("span",{className:"text-muted-foreground",children:t("apps.environment.placeholder")}):m.map(y=>c.jsx("div",{className:"leading-6",children:y.type==="empty"?c.jsx("span",{children:" "}):y.type==="comment"||y.type==="other"?c.jsx("span",{className:"text-muted-foreground",children:y.text}):c.jsxs(c.Fragment,{children:[c.jsx("span",{style:{color:"var(--chart-1)"},children:"•".repeat(y.keyLen)}),c.jsx("span",{style:{color:"var(--chart-3)"},children:"•"}),c.jsx("span",{style:{color:"var(--chart-2)"},children:"•".repeat(y.valueLen)})]})},y.id))}):c.jsx(Oc,{value:i,onChange:y=>s(y.target.value),placeholder:t("apps.environment.placeholder"),className:"font-mono text-sm min-h-[120px]"})]})}function XZt({app:e,repoPath:t}){const{t:n}=Ot("common"),{data:r,isLoading:i,error:s}=CJe(t,e.composeFile),a=kJe(),o=tCe(),l=OJe(e.id),[u,d]=x.useState(""),[f,h]=x.useState(""),[m,g]=x.useState(!1),[y,v]=x.useState(!1);x.useEffect(()=>{r?.content!==void 0&&(d(r.content),h(r.content))},[r?.content]);const _=u!==f,S=x.useCallback(T=>{d(T),g(!1)},[]),E=x.useCallback(()=>{!t||!e.composeFile||a.mutate({repoPath:t,composeFile:e.composeFile,content:u},{onSuccess:()=>{h(u),g(!0),setTimeout(()=>g(!1),2e3),o.mutate(e.id)}})},[t,e.composeFile,e.id,u,a,o]);return i?c.jsxs("div",{className:"rounded-lg border bg-background/80 backdrop-blur-sm p-4",children:[c.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-3",children:n("apps.compose.title")}),c.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[c.jsx(Z,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin"}),c.jsx("span",{className:"text-sm",children:n("status.loading")})]})]}):s?c.jsxs("div",{className:"rounded-lg border bg-background/80 backdrop-blur-sm p-4",children:[c.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-3",children:n("apps.compose.title")}),c.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[c.jsx(Z,{icon:wr,size:16,strokeWidth:2}),c.jsx("span",{className:"text-sm",children:s.message})]})]}):c.jsxs("div",{className:"rounded-lg border bg-background/80 backdrop-blur-sm p-4 space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:n("apps.compose.title")}),_&&c.jsxs("span",{className:"text-xs text-amber-500",children:["(",n("apps.compose.unsavedChanges"),")"]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm text-muted-foreground",children:e.composeFile}),_&&c.jsx(_e,{variant:"outline",size:"sm",onClick:()=>{d(f),g(!1)},children:n("apps.cancel")}),c.jsx(_e,{size:"sm",onClick:E,disabled:a.isPending||!_,children:a.isPending?c.jsxs(c.Fragment,{children:[c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}),n("status.saving")]}):m?c.jsxs(c.Fragment,{children:[c.jsx(Z,{icon:sl,size:14,strokeWidth:2,className:"text-green-500"}),n("status.saved")]}):n("apps.compose.save")})]})]}),c.jsx("div",{className:"h-[400px] rounded-md border overflow-hidden",children:c.jsx(a3,{filePath:e.composeFile,content:u,onChange:S})}),c.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[c.jsx("span",{className:"text-xs text-muted-foreground",children:n("apps.compose.previewDescription")}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>{l.refetch(),v(!0)},children:[c.jsx(Z,{icon:bC,size:14,strokeWidth:2}),n("apps.compose.preview")]})]}),c.jsx(Ya,{open:y,onOpenChange:v,children:c.jsxs(Xa,{className:"max-w-4xl max-h-[80vh]",children:[c.jsxs(Lo,{children:[c.jsx(Mo,{children:n("apps.compose.generatedTitle")}),c.jsx(eg,{children:n("apps.compose.generatedDescription")})]}),c.jsx("div",{className:"h-[500px] rounded-md border overflow-hidden",children:l.error?c.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:c.jsxs("div",{className:"text-center space-y-2",children:[c.jsx(Z,{icon:wr,size:24,strokeWidth:2,className:"mx-auto text-destructive"}),c.jsx("p",{className:"text-sm",children:l.error.message})]})}):l.data?.content?c.jsx(a3,{filePath:"swarm-compose.yml",content:l.data.content,onChange:()=>{},readOnly:!0}):c.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:c.jsx(Z,{icon:Nt,size:24,strokeWidth:2,className:"animate-spin"})})})]})})]})}const QZt=/error|exception|failed|uncaught|fatal|crash|errno|reject/i,ZZt=/warning|deprecated|caution|unstable|⚠️/i,JZt=/successfully|completed|listening|connected|ready|started|✓|✅|done|healthy|pulled|created|recreated/i,eJt=/debug|version|config|import|GET|POST|PUT|DELETE/i;function tJt(e){return QZt.test(e)?"error":ZZt.test(e)?"warning":JZt.test(e)?"success":eJt.test(e)?"debug":"info"}function KJ(e){return e.split(`
326
326
  `).filter(t=>t.trim()).map(t=>({message:t,type:tJt(t)}))}var RB,L0e;function nJt(){if(L0e)return RB;L0e=1;var e=/["'&<>]/;RB=t;function t(n){var r=""+n,i=e.exec(r);if(!i)return r;var s,a="",o=0,l=0;for(o=i.index;o<r.length;o++){switch(r.charCodeAt(o)){case 34:s="&quot;";break;case 38:s="&amp;";break;case 39:s="&#39;";break;case 60:s="&lt;";break;case 62:s="&gt;";break;default:continue}l!==o&&(a+=r.substring(l,o)),l=o+1,a+=s}return l!==o?a+r.substring(l,o):a}return RB}var rJt=nJt();const iJt=Kn(rJt),Lr={black:"#2e3436",red:"#cc0000",green:"#4e9a06",yellow:"#c4a000",blue:"#3465a4",magenta:"#75507b",cyan:"#06989a",white:"#d3d7cf","bright-black":"#555753","bright-red":"#ef2929","bright-green":"#8ae234","bright-yellow":"#fce94f","bright-blue":"#729fcf","bright-magenta":"#ad7fa8","bright-cyan":"#34e2e2","bright-white":"#eeeeec"};function Gje({onlyFirst:e=!1}={}){const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}const sJt=/^(?:\x1b\[([\x3c-\x3f]?)([\d;]*)([\x20-\x2f]?[\x40-\x7e]))|(?:\x1b\[[\x20-\x7e]*([\x00-\x1f:]))/,aJt=/^\x1b\]8;[\x20-\x3a\x3c-\x7e]*;([\x21-\x7e]{0,512})(?:(?:\x1b\\)|(?:\x07))([\x20-\x7e]+)\x1b\]8;;(?:(?:\x1b\\)|(?:\x07))/,oJt=/(?:(\x1b\\)|(\x07))|([\x00-\x06]|[\x08-\x1a]|[\x1c-\x1f])/g;class lJt{constructor(t){this.lastIndex=0,this.input=t}next(){const t=this.input.substring(this.lastIndex),n=t.length;if(n===0)return{value:null,done:!0};const r={kind:0,text:"",url:""},i=t.indexOf("\x1B");if(i===-1)return r.kind=1,r.text=t,this.lastIndex+=n,{value:r,done:!1};if(i>0)return r.kind=1,r.text=t.slice(0,i),this.lastIndex+=i,{value:r,done:!1};if(n<3)return{value:null,done:!0};const s=t.charAt(1);if(s!=="["&&s!=="]"&&s!=="(")return r.kind=2,r.text=t[0],this.lastIndex+=1,{value:r,done:!1};if(s==="["){const a=t.match(sJt);return a===null?{value:null,done:!0}:a[4]?(r.kind=2,r.text=t[0],this.lastIndex+=1,{value:r,done:!1}):(a[1]!==""||a[3]!=="m"?r.kind=3:r.kind=4,r.text=a[2],this.lastIndex+=a[0].length,{value:r,done:!1})}if(s==="]"){if(n<4)return{value:null,done:!0};if(t.charAt(2)!=="8"||t.charAt(3)!==";")return r.kind=2,r.text=t[0],this.lastIndex+=1,{value:r,done:!1};const a=new RegExp(oJt);{const l=a.exec(t);if(l===null)return{value:null,done:!0};if(l[3])return r.kind=2,r.text=t[0],this.lastIndex+=1,{value:r,done:!1}}{const l=a.exec(t);if(l===null)return{value:null,done:!0};if(l[3])return r.kind=2,r.text=t[0],this.lastIndex+=1,{value:r,done:!1}}const o=t.match(aJt);return o===null?(r.kind=2,r.text=t[0],this.lastIndex+=1,{value:r,done:!1}):(r.kind=5,r.url=o[1],r.text=o[2],this.lastIndex+=o[0].length,{value:r,done:!1})}return s==="("?(r.kind=3,this.lastIndex+=3,{value:r,done:!1}):{value:null,done:!0}}[Symbol.iterator](){return this}}const Kje=14,pl=new Array(Kje);pl[0]="background-color";pl[1]="color";pl[2]="font-family";pl[3]="font-size";pl[4]="font-style";pl[5]="font-weight";pl[6]="opacity";pl[7]="outline";pl[8]="text-decoration";pl[9]="text-decoration-color";pl[10]="text-decoration-line";pl[11]="text-decoration-style";pl[12]="vertical-align";pl[13]="visibility";class Bo{constructor(){this.attrArray=new Array(Kje),this._size=0}get(t){return this.attrArray[t]}set(t,n){const r=this.attrArray[t];this.attrArray[t]=n,r===void 0&&n!==void 0&&(this._size+=1)}delete(t){const n=this.attrArray[t];this.attrArray[t]=void 0,n!==void 0&&(this._size-=1)}update(t){for(const n in t)if(t.hasOwnProperty(n)){const r=t[n];this.attrArray[n]=r,r!==void 0&&(this._size+=1)}}clear(){this.attrArray.fill(void 0),this._size=0}get size(){return this._size}toString(){let t="";return this.attrArray.forEach((n,r)=>{n!==void 0&&(t+=`${pl[r]}:${n};`)}),t}static delete(...t){return n=>{t.forEach(r=>{n.delete(r)})}}static appendVal(t,n){return r=>{const i=r.get(t),s=i?i.split(" "):[];s.includes(n)||s.push(n),r.set(t,s.join(" "))}}static removeVal(t,n){return r=>{const i=r.get(t);let s=i?i.split(" "):[];s=s.filter(a=>a!==n),s.length?r.set(t,s.join(" ")):r.delete(t)}}}Gje();Gje({onlyFirst:!0});const dn=new Array(108);dn[0]={5:"var(--ansi-bold-font-weight, 600)"};dn[1]={5:"var(--ansi-bold-font-weight, 600)"};dn[2]={6:"var(--ansi-dim-opacity, 0.7)"};dn[3]={4:"italic"};dn[4]=Bo.appendVal(8,"underline");dn[8]={13:"hidden"};dn[9]=Bo.appendVal(8,"line-through");dn[10]=Bo.delete(2);dn[11]={2:"var(--ansi-font-1)"};dn[12]={2:"var(--ansi-font-2)"};dn[13]={2:"var(--ansi-font-3)"};dn[14]={2:"var(--ansi-font-4)"};dn[15]={2:"var(--ansi-font-5)"};dn[16]={2:"var(--ansi-font-6)"};dn[17]={2:"var(--ansi-font-7)"};dn[18]={2:"var(--ansi-font-8)"};dn[19]={2:"var(--ansi-font-9)"};dn[21]={10:"underline",11:"double"};dn[22]=Bo.delete(5);dn[23]=Bo.delete(4);dn[24]=Bo.removeVal(8,"underline");dn[28]=Bo.delete(13);dn[29]=Bo.removeVal(8,"line-through");dn[30]={1:`var(--ansi-black, ${Lr.black})`};dn[31]={1:`var(--ansi-red, ${Lr.red})`};dn[32]={1:`var(--ansi-green, ${Lr.green})`};dn[33]={1:`var(--ansi-yellow, ${Lr.yellow})`};dn[34]={1:`var(--ansi-blue, ${Lr.blue})`};dn[35]={1:`var(--ansi-magenta, ${Lr.magenta})`};dn[36]={1:`var(--ansi-cyan, ${Lr.cyan})`};dn[37]={1:`var(--ansi-white, ${Lr.white})`};dn[39]=Bo.delete(1);dn[40]={0:`var(--ansi-black, ${Lr.black})`};dn[41]={0:`var(--ansi-red, ${Lr.red})`};dn[42]={0:`var(--ansi-green, ${Lr.green})`};dn[43]={0:`var(--ansi-yellow, ${Lr.yellow})`};dn[44]={0:`var(--ansi-blue, ${Lr.blue})`};dn[45]={0:`var(--ansi-magenta, ${Lr.magenta})`};dn[46]={0:`var(--ansi-cyan, ${Lr.cyan})`};dn[47]={0:`var(--ansi-white, ${Lr.white})`};dn[49]=Bo.delete(0);dn[51]={7:"var(--ansi-frame-outline, 1px solid)"};dn[53]=Bo.appendVal(8,"overline");dn[54]=Bo.delete(7);dn[55]=Bo.removeVal(8,"overline");dn[59]=Bo.delete(9);dn[73]={12:"super",3:"var(--ansi-superscript-font-size, 80%)"};dn[74]={12:"sub",3:"var(--ansi-subscript-font-size, 80%)"};dn[75]=Bo.delete(12,3);dn[90]={1:`var(--ansi-bright-black, ${Lr["bright-black"]})`};dn[91]={1:`var(--ansi-bright-red, ${Lr["bright-red"]})`};dn[92]={1:`var(--ansi-bright-green, ${Lr["bright-green"]})`};dn[93]={1:`var(--ansi-bright-yellow, ${Lr["bright-yellow"]})`};dn[94]={1:`var(--ansi-bright-blue, ${Lr["bright-blue"]})`};dn[95]={1:`var(--ansi-bright-magenta, ${Lr["bright-magenta"]})`};dn[96]={1:`var(--ansi-bright-cyan, ${Lr["bright-cyan"]})`};dn[97]={1:`var(--ansi-bright-white, ${Lr["bright-white"]})`};dn[100]={0:`var(--ansi-bright-black, ${Lr["bright-black"]})`};dn[101]={0:`var(--ansi-bright-red, ${Lr["bright-red"]})`};dn[102]={0:`var(--ansi-bright-green, ${Lr["bright-green"]})`};dn[103]={0:`var(--ansi-bright-yellow, ${Lr["bright-yellow"]})`};dn[104]={0:`var(--ansi-bright-blue, ${Lr["bright-blue"]})`};dn[105]={0:`var(--ansi-bright-magenta, ${Lr["bright-magenta"]})`};dn[106]={0:`var(--ansi-bright-cyan, ${Lr["bright-cyan"]})`};dn[107]={0:`var(--ansi-bright-white, ${Lr["bright-white"]})`};const xo=new Array(16);xo[0]="black";xo[1]="red";xo[2]="green";xo[3]="yellow";xo[4]="blue";xo[5]="magenta";xo[6]="cyan";xo[7]="white";xo[8]="bright-black";xo[9]="bright-red";xo[10]="bright-green";xo[11]="bright-yellow";xo[12]="bright-blue";xo[13]="bright-magenta";xo[14]="bright-cyan";xo[15]="bright-white";function Yje(e){switch(e){case"38":return 1;case"48":return 0;case"58":return 9;default:throw new Error("not implemented")}}function cJt(e,t){const n=e.text.split(";");if(n.length!==3)return;const r=Yje(n[0]),i=parseInt(n[2],10);if(0<=i&&i<=15){const s=xo[i];t.set(r,`var(--ansi-${s}, ${Lr[s]})`)}else if(16<=i&&i<=231){const s=i-16,a=[0,95,135,175,215,255],o=a[s/36%6|0],l=a[s/6%6|0],u=a[s%6];t.set(r,`rgb(${o},${l},${u})`)}else if(232<=i&&i<=255){const s=8+(i-232)*10;t.set(r,`var(--ansi-gray-${256-i}, rgb(${s},${s},${s}))`)}}function uJt(e,t){const n=e.text.split(";");if(n.length!==5)return;const r=Yje(n[0]),[,,i,s,a]=n;t.set(r,`rgb(${i},${s},${a})`)}function dJt(e,t){if(/^(38|48|58);(2|5);/.test(e.text)){e.text[3]==="2"?uJt(e,t):cJt(e,t);return}e.text.split(";").forEach(n=>{const r=parseInt(n||"0",10);if(r===0){t.clear();return}const i=dn[r];i&&(typeof i=="function"?i(t):t.update(i))})}class fJt{toHtml(t){const n=new Bo;let r="",i=!1;return Array.from(new lJt(t)).forEach(s=>{switch(s.kind){case 1:r+=iJt(s.text);break;case 4:i&&(r+="</span>",i=!1),dJt(s,n),n.size&&(r+=`<span style="${n.toString()}">`,i=!0);break}}),i&&(r+="</span>"),r}}const hJt=new fJt,pJt={error:{bg:"bg-red-500/10 hover:bg-red-500/15",badge:"bg-red-600/20 text-red-600 dark:bg-red-500/15 dark:text-red-400",border:"bg-red-500"},warning:{bg:"bg-yellow-500/10 hover:bg-yellow-500/15",badge:"bg-yellow-600/20 text-yellow-600 dark:bg-yellow-500/15 dark:text-yellow-400",border:"bg-yellow-500"},success:{bg:"bg-green-500/10 hover:bg-green-500/15",badge:"bg-emerald-600/20 text-emerald-600 dark:bg-emerald-500/15 dark:text-emerald-400",border:"bg-green-500"},info:{bg:"hover:bg-muted/50",badge:"bg-blue-600/20 text-blue-600 dark:bg-blue-500/15 dark:text-blue-400",border:"bg-blue-500"},debug:{bg:"bg-orange-500/10 hover:bg-orange-500/15",badge:"bg-orange-600/20 text-orange-600 dark:bg-orange-500/15 dark:text-orange-400",border:"bg-orange-500"}};function YJ({message:e,type:t}){const n=pJt[t],r=hJt.toHtml(e);return c.jsxs("div",{className:Ae("flex items-start gap-2 py-0.5 font-mono text-xs",n.bg),children:[c.jsx("div",{className:Ae("w-0.5 self-stretch rounded-full shrink-0",n.border)}),c.jsx("span",{className:Ae("shrink-0 rounded px-1 py-0.5 text-[10px] font-medium w-12 text-center",n.badge),children:t}),c.jsx("span",{className:"whitespace-pre-wrap break-all text-foreground",dangerouslySetInnerHTML:{__html:r}})]})}function mJt({appId:e,open:t,onOpenChange:n,deployStore:r}){const{t:i}=Ot("common"),[s,a]=x.useState(!1),o=x.useRef(null),l=J2e(),[u,d]=x.useState(()=>r.logsSnapshot),[f,h]=x.useState(r.typedStage),[m,g]=x.useState(r.error),[y,v]=x.useState(r.isDeploying);x.useEffect(()=>{d(r.logsSnapshot),h(r.typedStage),g(r.error),v(r.isDeploying);const k=mx(()=>r.logCount,()=>d(r.logsSnapshot)),w=mx(()=>({stage:r.typedStage,error:r.error,isDeploying:r.isDeploying}),A=>{h(A.stage),g(A.error),v(A.isDeploying)});return()=>{k(),w()}},[r]);const _=KJ(u.join(`
327
327
  `));x.useEffect(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[u.length]);const S=async()=>{await navigator.clipboard.writeText(u.join(`
328
- `)),a(!0),setTimeout(()=>a(!1),2e3)},E=async()=>{await l.mutateAsync(e)},T=k=>{switch(k){case"pulling":return i("apps.streaming.pulling");case"building":return i("apps.streaming.building");case"starting":return i("apps.streaming.starting");case"configuring":return i("apps.streaming.configuring");case"done":return i("apps.streaming.done");case"failed":return i("apps.streaming.failed");case"cancelled":return i("apps.streaming.cancelled");default:return i("apps.streaming.preparing")}};return c.jsx(Ya,{open:t,onOpenChange:n,children:c.jsxs(Xa,{className:"!max-w-[90vw] w-[90vw] h-[85vh] flex flex-col",children:[c.jsxs(Lo,{children:[c.jsxs(Mo,{className:"flex items-center gap-2",children:[i("apps.deployments.deployment"),y&&c.jsx(Z,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin"}),!y&&!m&&f==="done"&&c.jsx(Z,{icon:sl,size:16,strokeWidth:2,className:"text-green-500"}),m&&c.jsx(Z,{icon:wr,size:16,strokeWidth:2,className:"text-destructive"})]}),c.jsxs(eg,{className:"flex items-center gap-2",children:[T(f),y&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-muted-foreground",children:"|"}),c.jsxs(_e,{variant:"destructive",size:"sm",onClick:E,disabled:l.isPending,children:[l.isPending?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(Z,{icon:EE,size:14,strokeWidth:2}),l.isPending?i("apps.cancelling"):i("apps.cancelDeploy")]})]}),c.jsx("span",{className:"text-muted-foreground",children:"|"}),c.jsxs("span",{children:[_.length," ",i("apps.logs.lines")]}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:S,disabled:u.length===0,children:c.jsx(Z,{icon:s?sl:J3,size:14,strokeWidth:2,className:s?"text-green-500":""})})]})]}),c.jsxs("div",{ref:o,className:"flex-1 overflow-auto rounded-lg border bg-muted/30 p-2 custom-logs-scrollbar",children:[_.length>0?_.map((k,w)=>c.jsx(YJ,{message:k.message,type:k.type},w)):y?c.jsx("span",{className:"text-muted-foreground p-2",children:i("apps.streaming.waitingForLogs")}):c.jsx("span",{className:"text-muted-foreground p-2",children:i("apps.deployments.noBuildLogs")}),m&&c.jsxs("div",{className:"mt-2 p-2 rounded bg-destructive/10 text-destructive text-sm",children:[i("status.error"),": ",m]})]})]})})}function gJt(e,t){const n=new Date(e).getTime(),r=t?new Date(t).getTime():Date.now(),i=Math.floor((r-n)/1e3);if(i<60)return`${i}s`;const s=Math.floor(i/60),a=i%60;return a===0?`${s}m`:`${s}m ${a}s`}function bJt(e){const t=Date.now(),n=new Date(e).getTime(),r=t-n,i=Math.floor(r/6e4);if(i<1)return"just now";if(i<60)return`about ${i} min ago`;const s=Math.floor(i/60);return s<24?`about ${s}h ago`:`about ${Math.floor(s/24)}d ago`}function yJt({appId:e,deployStore:t,onViewStreamingLogs:n}){const{t:r}=Ot("common"),{data:i,isLoading:s}=wJe(e),[a,o]=x.useState(null),l=u=>{u.status==="building"||u.status==="pending"?((!t.isDeploying||t.appId!==e)&&t.watchDeployment(e),n()):o(u)};return s?c.jsx("div",{className:"flex items-center justify-center py-8",children:c.jsx(Z,{icon:Nt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}):c.jsxs("div",{children:[c.jsxs("div",{className:"mb-4",children:[c.jsx("h3",{className:"text-lg font-semibold",children:r("apps.deployments.title")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:r("apps.deployments.description")})]}),i?.length?c.jsx("div",{className:"border rounded-lg divide-y",children:i.map((u,d)=>c.jsx(vJt,{deployment:u,number:d+1,onViewLogs:()=>l(u)},u.id))}):c.jsx("div",{className:"py-8 text-center text-muted-foreground border rounded-lg",children:c.jsx("p",{children:r("apps.deployments.noDeployments")})}),c.jsx(xJt,{deployment:a,open:!!a,onOpenChange:u=>!u&&o(null)})]})}function vJt({deployment:e,number:t,onViewLogs:n}){const{t:r}=Ot("common"),i=e.status==="building"||e.status==="pending",[,s]=x.useState(0);x.useEffect(()=>{if(!i)return;const u=setInterval(()=>s(d=>d+1),1e3);return()=>clearInterval(u)},[i]);const a=()=>{switch(e.status){case"running":return{text:r("apps.deployments.statusDone"),color:"bg-green-500"};case"failed":return{text:r("apps.deployments.statusError"),color:"bg-red-500"};case"building":case"pending":return{text:r("apps.deployments.statusBuilding"),color:"bg-yellow-500"};default:return{text:e.status,color:"bg-gray-400"}}},{text:o,color:l}=a();return c.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("span",{className:"text-muted-foreground w-6",children:[t,"."]}),c.jsx("span",{className:"font-medium",children:o}),c.jsx("div",{className:`h-2 w-2 rounded-full ${l}`})]}),c.jsxs("div",{className:"flex items-center gap-4",children:[c.jsx("span",{className:"text-sm text-muted-foreground",children:bJt(e.startedAt)}),c.jsxs("span",{className:"text-sm text-muted-foreground tabular-nums",children:["⏱ ",gJt(e.startedAt,e.completedAt)]}),c.jsx(_e,{size:"sm",onClick:n,children:r("apps.deployments.view")})]})]})}function xJt({deployment:e,open:t,onOpenChange:n}){const{t:r}=Ot("common"),[i,s]=x.useState(!1),a=x.useMemo(()=>KJ(e?.buildLogs??""),[e?.buildLogs]),o=async()=>{e?.buildLogs&&(await navigator.clipboard.writeText(e.buildLogs),s(!0),setTimeout(()=>s(!1),2e3))};return c.jsx(Ya,{open:t,onOpenChange:n,children:c.jsxs(Xa,{className:"!max-w-[90vw] w-[90vw] h-[85vh] flex flex-col",children:[c.jsxs(Lo,{children:[c.jsx(Mo,{children:r("apps.deployments.deployment")}),c.jsxs(eg,{className:"flex items-center gap-2",children:[r("apps.deployments.seeDetails"),c.jsx("span",{className:"text-muted-foreground",children:"|"}),c.jsxs("span",{children:[a.length," ",r("apps.logs.lines")]}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:o,children:c.jsx(Z,{icon:i?sl:J3,size:14,strokeWidth:2,className:i?"text-green-500":""})})]})]}),c.jsx("div",{className:"flex-1 overflow-auto rounded-lg border bg-muted/30 p-2 custom-logs-scrollbar",children:a.length>0?a.map((l,u)=>c.jsx(YJ,{message:l.message,type:l.type},u)):c.jsx("span",{className:"text-muted-foreground p-2",children:r("apps.deployments.noBuildLogs")})})]})})}function _Jt({appId:e,services:t}){const{t:n}=Ot("common"),{data:r}=eCe(e),[i,s]=x.useState(),[a,o]=x.useState(100),{data:l,isLoading:u,refetch:d}=SJe(e,i,a),[f,h]=x.useState(!1),m=x.useMemo(()=>KJ(l?.logs??""),[l?.logs]),g=async()=>{l?.logs&&(await navigator.clipboard.writeText(l.logs),h(!0),setTimeout(()=>h(!1),2e3))},y=()=>{if(l?.logs){const _=new Blob([l.logs],{type:"text/plain"}),S=URL.createObjectURL(_),E=document.createElement("a");E.href=S,E.download=`${e}-${i??"all"}-logs.txt`,document.body.appendChild(E),E.click(),document.body.removeChild(E),URL.revokeObjectURL(S)}},v=r?.containers??[];return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"text-lg font-semibold",children:n("apps.logs.title")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:n("apps.logs.description")})]}),c.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[c.jsxs("select",{value:i??"",onChange:_=>s(_.target.value||void 0),className:"rounded-md border bg-background px-3 py-2 text-sm min-w-[240px]",children:[c.jsx("option",{value:"",children:n("apps.logs.allContainers")}),v.length>0?v.map(_=>c.jsxs("option",{value:_.service,children:[_.service," (",_.name.slice(-12),") [",_.status,"]"]},_.name)):t?.map(_=>c.jsx("option",{value:_.serviceName,children:_.serviceName},_.id))]}),c.jsxs("select",{value:a,onChange:_=>o(parseInt(_.target.value,10)),className:"rounded-md border bg-background px-3 py-2 text-sm",children:[c.jsxs("option",{value:50,children:["50 ",n("apps.logs.lines")]}),c.jsxs("option",{value:100,children:["100 ",n("apps.logs.lines")]}),c.jsxs("option",{value:500,children:["500 ",n("apps.logs.lines")]}),c.jsxs("option",{value:1e3,children:["1000 ",n("apps.logs.lines")]})]}),c.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[c.jsxs(_e,{variant:"outline",size:"sm",onClick:g,disabled:!l?.logs,children:[c.jsx(Z,{icon:f?sl:J3,size:14,strokeWidth:2,className:f?"text-green-500":""}),n(f?"apps.logs.copied":"apps.logs.copy")]}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:y,disabled:!l?.logs,children:[c.jsx(Z,{icon:xf,size:14,strokeWidth:2,className:"rotate-[-90deg]"}),n("apps.logs.download")]}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>d(),children:[c.jsx(Z,{icon:lp,size:14,strokeWidth:2}),n("apps.logs.refresh")]})]})]}),c.jsx("div",{className:"rounded-lg border bg-muted/80 p-2 overflow-auto max-h-[600px] min-h-[300px] custom-logs-scrollbar",children:u?c.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground p-2",children:[c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}),n("status.loading")]}):m.length>0?m.map((_,S)=>c.jsx(YJ,{message:_.message,type:_.type},S)):c.jsx("span",{className:"text-muted-foreground p-2",children:n("apps.logs.noLogs")})})]})}const M0e=["var(--chart-1)","var(--chart-2)","var(--chart-3)","var(--chart-4)","var(--chart-5)"];function SJt(e){const t=e.split("_");if(t.length>=2)return t[1].split(".")[0];const n=e.split(/[-_.]/);for(const r of n.slice(1))if(r&&!r.match(/^\d+$/)&&r.length>2)return r;return e}function wJt(e,t){const n=e.slice(0,8).toLowerCase().replace(/[^a-z0-9]/g,"");return t?`fulcrum-${t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").slice(0,20).replace(/-$/,"")}-${n}`:`fulcrum-${n}`}function F0e({data:e,label:t,totalValue:n,unit:r}){return c.jsxs("div",{className:"flex flex-col items-center",children:[c.jsxs("div",{className:"relative size-28",children:[c.jsx(HZ,{width:"100%",height:"100%",children:c.jsxs(r5e,{children:[c.jsx($f,{data:e,cx:"50%",cy:"50%",innerRadius:32,outerRadius:48,paddingAngle:2,dataKey:"value",stroke:"none",children:e.map((i,s)=>c.jsx(pg,{fill:i.color},`cell-${s}`))}),c.jsx(ha,{content:({active:i,payload:s})=>{if(i&&s&&s.length){const a=s[0].payload;return c.jsxs("div",{className:"bg-popover border rounded-md px-2 py-1 text-xs shadow-md",children:[c.jsx("p",{className:"font-medium",children:a.name}),c.jsxs("p",{className:"text-muted-foreground",children:[a.value.toFixed(1)," ",r]})]})}return null}})]})}),c.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[c.jsx("span",{className:"text-sm font-semibold tabular-nums",children:n}),c.jsx("span",{className:"text-[10px] text-muted-foreground",children:r})]})]}),c.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:t})]})}function EJt({containers:e}){const{t}=Ot("common"),n=e.reduce((o,l)=>o+l.cpuPercent,0),r=e.reduce((o,l)=>o+l.memoryMB,0),i=e.map((o,l)=>({name:SJt(o.name),cpu:o.cpuPercent,memory:o.memoryMB,color:M0e[l%M0e.length]})),s=i.map(o=>({name:o.name,value:o.cpu,color:o.color})),a=i.map(o=>({name:o.name,value:o.memory,color:o.color}));return c.jsxs(xi,{className:"p-4 mb-6",children:[c.jsx("h4",{className:"text-sm font-medium mb-4",children:t("apps.monitoring.serviceTotal")}),c.jsxs("div",{className:"flex items-center justify-center gap-8",children:[c.jsx(F0e,{data:s,label:t("apps.monitoring.cpu"),totalValue:n.toFixed(1),unit:"%"}),c.jsx(F0e,{data:a,label:t("apps.monitoring.memory"),totalValue:r.toFixed(0),unit:"MB"})]}),c.jsx("div",{className:"flex flex-wrap justify-center gap-x-4 gap-y-1 mt-4",children:i.map(o=>c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("div",{className:"size-2.5 rounded-full",style:{backgroundColor:o.color}}),c.jsx("span",{className:"text-xs text-muted-foreground",children:o.name})]},o.name))})]})}function CJt({appId:e,repoDisplayName:t}){const{t:n}=Ot("common"),{data:r,isLoading:i}=g5e(),s=x.useMemo(()=>{if(!r?.containers)return[];const a=`${wJt(e,t)}_`;return r.containers.filter(o=>o.name.toLowerCase().startsWith(a))},[r,e,t]);return i?c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(Z,{icon:Nt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}):r?.available?s.length===0?c.jsxs("div",{children:[c.jsxs("div",{className:"mb-4",children:[c.jsx("h3",{className:"text-lg font-semibold",children:n("apps.monitoring.title")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:n("apps.monitoring.description")})]}),c.jsx("div",{className:"py-8 text-center text-muted-foreground border rounded-lg",children:c.jsx("p",{children:n("apps.monitoring.noContainers")})})]}):c.jsxs("div",{children:[c.jsxs("div",{className:"mb-4",children:[c.jsx("h3",{className:"text-lg font-semibold",children:n("apps.monitoring.title")}),c.jsxs("p",{className:"text-sm text-muted-foreground",children:[n("apps.monitoring.description"),r.runtime&&c.jsxs("span",{className:"ml-1 text-xs",children:["(",r.runtime,")"]})]})]}),c.jsx(EJt,{containers:s})]}):c.jsxs("div",{children:[c.jsxs("div",{className:"mb-4",children:[c.jsx("h3",{className:"text-lg font-semibold",children:n("apps.monitoring.title")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:n("apps.monitoring.description")})]}),c.jsx("div",{className:"py-8 text-center text-muted-foreground border rounded-lg",children:c.jsx("p",{children:n("apps.monitoring.dockerUnavailable")})})]})}const kJt=Py(function(){const{t}=Ot("repositories"),n=Ot("projects").t,r=Ot("common").t,i=Ni(),s=It(),{repoId:a}=C3({from:"/repositories/$repoId"}),o=aC({from:"/repositories/$repoId"}),{data:l,isLoading:u,error:d}=Cqe(a),f=TJe(a),h=Yst(),{data:m}=nCe(),{data:g,isLoading:y}=EJe(a),v=_Je(),_=J2e(),S=Tqe(),E=xJe(),T=o.tab??"settings",k=T==="deploy"?o.subtab||"general":null,[w,A]=x.useState(!1),[R,I]=x.useState(!1),[D,j]=x.useState(!1),[F,z]=x.useState(!1),[P,L]=x.useState(!1),[M,$]=x.useState(""),[W,Y]=x.useState(!1),[q,K]=x.useState(!1),X=x.useRef(null),U=x.useRef(!1),J=h.isDeploying||f?.status==="building",te=f?.status==="running"||f?.status==="failed"||f?.status==="building",ee=!!f,oe=m&&!m.settings.cloudflareConfigured,{data:ae}=dD(),{data:se}=fD(),{data:ue}=hD(),[de,ce]=x.useState(null);x.useEffect(()=>{if(o.action==="deploy"&&f&&!U.current){U.current=!0,ce(f.id);const ie={};o.tab&&(ie.tab=o.tab),o.subtab&&(ie.subtab=o.subtab),i({to:"/repositories/$repoId",params:{repoId:a},search:ie,replace:!0})}},[o.action,f,a,i,o.tab,o.subtab]),x.useEffect(()=>{if(de){const ie=de;ce(null),h.deploy(ie),Y(!0)}},[de,h]),x.useEffect(()=>{U.current=!1},[a]);const Ee=()=>{if(!l?.path)return;const ie=fq(l.path,ae,se,ue);jl(ie)},Ie=x.useCallback(()=>{f&&(h.deploy(f.id),Y(!0))},[f,h]),fe=async()=>{f&&await v.mutateAsync(f.id)},be=async()=>{f&&await _.mutateAsync(f.id)},ge=x.useCallback(ie=>{Y(ie),!ie&&!h.isDeploying&&h.logs.length===0&&!h.error&&setTimeout(()=>h.reset(),300)},[h]),Ce=x.useCallback(()=>{l&&($(l.displayName),L(!0),setTimeout(()=>X.current?.select(),0))},[l]),Re=x.useCallback(()=>{L(!1),$("")},[]),xe=x.useCallback(()=>{L(!1),$("")},[]),ye=x.useCallback(ie=>{ie.key==="Enter"?(ie.preventDefault(),Re()):ie.key==="Escape"&&xe()},[Re,xe]),De=x.useCallback((ie,Ke)=>{const lt={};ie!=="settings"&&(lt.tab=ie),ie==="workspace"&&o.file&&(lt.file=o.file),ie==="deploy"&&Ke&&Ke!=="general"&&(lt.subtab=Ke),i({to:"/repositories/$repoId",params:{repoId:a},search:lt,replace:!0})},[i,a,o.file]),ve=x.useCallback(ie=>{De("deploy",ie)},[De]),Oe=x.useCallback(ie=>{i({to:"/repositories/$repoId",params:{repoId:a},search:{tab:"workspace",file:ie??void 0},replace:!0})},[i,a]),Be=x.useCallback(ie=>{if(l?.path&&f?.composeFile){const Ke=f.composeFile;(ie===Ke||ie.endsWith(`/${Ke}`))&&s.invalidateQueries({queryKey:["compose","file",l.path,f.composeFile]})}},[l?.path,f?.composeFile,s]),Te=async()=>{try{await S.mutateAsync({id:a,deleteDirectory:R,deleteApp:D}),i({to:"/repositories"})}catch(ie){rt.error(ie instanceof Error?ie.message:"Failed to delete repository")}},je=()=>{y||E.isPending||(g?.found?E.mutate({repositoryId:a,composeFile:g.file??void 0}):K(!0))};return u?c.jsx("div",{className:"flex h-full items-center justify-center",children:c.jsx(Z,{icon:Nt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}):d||!l?c.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4",children:[c.jsx(Z,{icon:wr,size:48,strokeWidth:1.5,className:"text-destructive"}),c.jsx("p",{className:"text-muted-foreground",children:d?.message??t("detailView.notFound")}),c.jsx(Pr,{to:"/repositories",children:c.jsxs(_e,{variant:"outline",children:[c.jsx(Z,{icon:xf,size:16,strokeWidth:2}),t("detailView.breadcrumb")]})})]}):c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsxs(nl,{value:T,onValueChange:ie=>De(ie),className:"flex h-full flex-col",children:[c.jsxs("div",{className:"film-grain relative shrink-0 border-b border-border",style:{background:"var(--gradient-header)"},children:[c.jsxs("div",{className:"flex items-center justify-between gap-4 px-4 py-2",children:[c.jsxs(sf,{children:[c.jsxs(af,{className:"flex items-center gap-2 sm:hidden",children:[c.jsx(Z,{icon:lW,size:18,strokeWidth:2}),c.jsx("span",{className:"text-sm font-medium",children:T==="deploy"&&k?`${n("detailView.tabs.deploy")} > ${n(`detailView.tabs.${k==="general"?"deployGeneral":k}`)}`:t(T==="settings"?"detailView.tabs.settings":"detailView.tabs.workspace")})]}),c.jsxs(of,{align:"start",children:[c.jsxs(ti,{onClick:()=>De("settings"),className:"gap-2",children:[c.jsx(Z,{icon:VO,size:14,strokeWidth:2}),t("detailView.tabs.settings")]}),c.jsxs(ti,{onClick:()=>De("workspace"),className:"gap-2",children:[c.jsx(Z,{icon:v$,size:14,strokeWidth:2}),t("detailView.tabs.workspace")]}),c.jsxs(ti,{onClick:()=>De("deploy","general"),className:"gap-2",children:[c.jsx(Z,{icon:vb,size:14,strokeWidth:2}),n("detailView.tabs.deploy")," > ",n("detailView.tabs.deployGeneral")]}),ee&&c.jsxs(c.Fragment,{children:[c.jsxs(ti,{onClick:()=>De("deploy","deployments"),className:"gap-2",children:[c.jsx(Z,{icon:vb,size:14,strokeWidth:2}),n("detailView.tabs.deploy")," > ",n("detailView.tabs.deployments")]}),c.jsxs(ti,{onClick:()=>De("deploy","logs"),className:"gap-2",children:[c.jsx(Z,{icon:dW,size:14,strokeWidth:2}),n("detailView.tabs.deploy")," > ",n("detailView.tabs.logs")]}),c.jsxs(ti,{onClick:()=>De("deploy","monitoring"),className:"gap-2",children:[c.jsx(Z,{icon:j_e,size:14,strokeWidth:2}),n("detailView.tabs.deploy")," > ",n("detailView.tabs.monitoring")]})]})]})]}),c.jsxs(rl,{variant:"line",className:"hidden sm:inline-flex",children:[c.jsxs(In,{value:"settings",className:"gap-1.5 px-3 py-1.5",children:[c.jsx(Z,{icon:VO,size:14,strokeWidth:2}),t("detailView.tabs.settings")]}),c.jsxs(In,{value:"workspace",className:"gap-1.5 px-3 py-1.5",children:[c.jsx(Z,{icon:v$,size:14,strokeWidth:2}),t("detailView.tabs.workspace")]}),c.jsxs(In,{value:"deploy",className:"gap-1.5 px-3 py-1.5",children:[c.jsx(Z,{icon:vb,size:14,strokeWidth:2}),n("detailView.tabs.deploy")]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(_e,{variant:"ghost",size:"sm",onClick:()=>z(!0),className:"text-muted-foreground hover:text-foreground",children:[c.jsx(Z,{icon:rD,size:14,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"hidden sm:inline",children:t("newTask")})]}),c.jsx(_e,{variant:"ghost",size:"sm",onClick:Ee,className:"text-muted-foreground hover:text-foreground hidden sm:flex",children:c.jsx(Z,{icon:tSe,size:14,strokeWidth:2,"data-slot":"icon"})}),c.jsx("div",{className:"h-4 w-px bg-border mx-1"}),c.jsx(hO,{worktreePath:l.path}),P?c.jsx(At,{ref:X,type:"text",value:M,onChange:ie=>$(ie.target.value),onBlur:Re,onKeyDown:ye,className:"font-medium text-sm bg-transparent border-b border-primary outline-none px-0.5 min-w-[100px] h-auto py-0",autoFocus:!0}):c.jsx("button",{type:"button",onClick:Ce,className:"font-medium text-sm hover:text-primary transition-colors cursor-pointer",title:"Click to edit",children:l.displayName}),l.projects&&l.projects.length>0&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-muted-foreground/50 text-xs",children:"in"}),c.jsxs(Pr,{to:"/projects/$projectId",params:{projectId:l.projects[0].id},className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[c.jsx(Z,{icon:SE,size:12,strokeWidth:2}),c.jsx("span",{children:l.projects[0].name})]})]}),ee&&c.jsx("div",{className:`h-2 w-2 rounded-full ${f.status==="running"?"bg-green-500":f.status==="building"?"bg-yellow-500":f.status==="failed"?"bg-red-500":"bg-gray-400"}`,title:f.status}),oe&&ee&&c.jsxs(wh,{children:[c.jsx(Eh,{className:"p-1 text-amber-500 hover:text-amber-400 transition-colors",children:c.jsx(Z,{icon:wr,size:14,strokeWidth:2})}),c.jsxs(Ch,{side:"bottom",className:"max-w-xs",children:[c.jsx("p",{className:"font-medium",children:r("apps.manualDnsRequired")}),c.jsx("p",{className:"text-muted-foreground mt-1",children:r("apps.manualDnsRequiredDesc")})]})]}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:()=>A(!0),children:c.jsx(Z,{icon:ks,size:14,strokeWidth:2})})]})]}),T==="deploy"&&ee&&c.jsx("div",{className:"bg-background/80 backdrop-blur-sm px-4 hidden sm:flex items-center border-t border-border",children:c.jsxs("div",{className:"flex gap-1",children:[c.jsx("button",{type:"button",onClick:()=>ve("general"),className:`px-3 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${k==="general"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:n("detailView.tabs.deployGeneral")}),ee&&c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",onClick:()=>ve("deployments"),className:`px-3 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${k==="deployments"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:n("detailView.tabs.deployments")}),c.jsx("button",{type:"button",onClick:()=>ve("logs"),className:`px-3 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${k==="logs"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:n("detailView.tabs.logs")}),c.jsx("button",{type:"button",onClick:()=>ve("monitoring"),className:`px-3 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${k==="monitoring"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:n("detailView.tabs.monitoring")})]})]})})]}),c.jsxs("div",{className:"flex-1 overflow-auto ",children:[c.jsx(jn,{value:"settings",className:"mt-0 h-full",children:c.jsx(qZt,{repository:l})}),c.jsx(jn,{value:"workspace",className:"mt-0 h-full",children:c.jsx(UZt,{repoPath:l.path,repoDisplayName:l.displayName,activeTab:T,file:o.file,onFileChange:Oe,onFileSaved:Be})}),c.jsx(jn,{value:"deploy",className:"mt-0 h-full",children:c.jsx(hp,{className:"h-full",children:c.jsx("div",{className:"p-4 mx-auto max-w-4xl",children:m&&!m.ready?c.jsx(HZt,{}):k==="general"?f?c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[c.jsx(GZt,{app:f,onDeploy:Ie,onStop:fe,onCancelDeploy:be,isBuilding:J,isRunning:te??!1,isStopPending:v.isPending,isCancelPending:_.isPending,deployStore:h}),c.jsx(KZt,{app:f,onDeploy:Ie})]}),c.jsx(YZt,{app:f}),c.jsx(XZt,{app:f,repoPath:l.path})]}):c.jsx("div",{className:"flex min-h-[calc(100vh-220px)] items-center justify-center",children:c.jsxs("div",{className:"text-center",children:[c.jsx(Z,{icon:vb,size:48,strokeWidth:1.5,className:"mx-auto text-muted-foreground mb-4"}),c.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:n("detailView.app.configureDeploymentDescription")}),c.jsxs(_e,{onClick:je,disabled:y||E.isPending,children:[c.jsx(Z,{icon:K_e,size:16,strokeWidth:2,"data-slot":"icon"}),E.isPending?n("detailView.app.configuring"):n("detailView.app.configureDeployment")]})]})}):ee&&k==="deployments"?c.jsx(yJt,{appId:f.id,deployStore:h,onViewStreamingLogs:()=>Y(!0)}):ee&&k==="logs"?c.jsx(_Jt,{appId:f.id,services:f.services}):ee&&k==="monitoring"?c.jsx(CJt,{appId:f.id,repoDisplayName:l.displayName}):null})})})]})]}),f&&c.jsx(mJt,{appId:f.id,open:W,onOpenChange:ge,deployStore:h}),c.jsx(XW,{open:F,onOpenChange:z,defaultRepository:{id:l.id,path:l.path,displayName:l.displayName,startupScript:l.startupScript,copyFiles:l.copyFiles,claudeOptions:l.claudeOptions,opencodeOptions:l.opencodeOptions,opencodeModel:l.opencodeModel,defaultAgent:l.defaultAgent},showTrigger:!1}),c.jsx(ql,{open:w,onOpenChange:A,children:c.jsxs(Gl,{children:[c.jsxs(Kl,{children:[c.jsx(Xl,{children:t("delete.title")}),c.jsx(Ql,{children:t("delete.description",{name:l.displayName})})]}),c.jsxs("div",{className:"space-y-3 py-2",children:[c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsx(ni,{id:"deleteDirectory",checked:R,onCheckedChange:ie=>I(ie===!0)}),c.jsx("label",{htmlFor:"deleteDirectory",className:"text-sm",children:t("delete.alsoDeleteDirectory")})]}),f&&c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsx(ni,{id:"deleteApp",checked:D,onCheckedChange:ie=>j(ie===!0)}),c.jsx("label",{htmlFor:"deleteApp",className:"text-sm",children:n("delete.alsoDeleteApp")})]})]}),c.jsxs(Yl,{children:[c.jsx(Zl,{children:r("apps.cancel")}),c.jsx(cg,{onClick:Te,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:S.isPending?t("delete.deleting"):t("delete.button")})]})]})}),c.jsx(Ya,{open:q,onOpenChange:K,children:c.jsxs(Xa,{children:[c.jsxs(Lo,{children:[c.jsx(Mo,{children:t("createAppDialog.title")}),c.jsx(eg,{children:t("createAppDialog.description")})]}),c.jsx("p",{className:"text-sm",children:t("createAppDialog.instructions")}),c.jsx("div",{className:"flex justify-end",children:c.jsx(_e,{onClick:()=>K(!1),children:t("createAppDialog.close")})})]})})]})});function TJt(){return c.jsx(Xst,{children:c.jsx(kJt,{})})}const AJt=xa("/repositories/$repoId")({validateSearch:e=>({tab:["settings","workspace","deploy"].includes(e.tab)?e.tab:void 0,subtab:["general","deployments","logs","monitoring"].includes(e.subtab)?e.subtab:void 0,action:e.action==="deploy"?"deploy":void 0,file:typeof e.file=="string"?e.file:void 0}),component:TJt});function NJt(e,t){const n=new Map;for(const r of t){const i=e.filter(s=>s.repoPath===r.path||s.repositoryId===r.id);n.set(r.id,i)}return n}function OJt({open:e,onOpenChange:t,projectId:n,projectName:r}){const{data:i}=Oy(),{data:s}=Mc(),a=Hwe(),[o,l]=x.useState(""),[u,d]=x.useState(new Set),[f,h]=x.useState(!1),m=x.useMemo(()=>{if(!i)return[];const w=new Map;if(s)for(const A of s)for(const R of A.repositories)w.set(R.id,{projectId:A.id,projectName:A.name});return i.map(A=>{const R=w.get(A.id);return{id:A.id,displayName:A.displayName,path:A.path,projectId:R?.projectId??null,projectName:R?.projectName??null}})},[i,s]),g=x.useMemo(()=>{if(!o.trim())return m;const w=o.toLowerCase();return m.filter(A=>A.displayName.toLowerCase().includes(w)||A.path.toLowerCase().includes(w))},[m,o]),v=g.filter(w=>u.has(w.id)).filter(w=>w.projectId&&w.projectId!==n),_=w=>{d(A=>{const R=new Set(A);return R.has(w)?R.delete(w):R.add(w),R})},S=()=>{const w=g.filter(A=>A.projectId!==n);d(new Set(w.map(A=>A.id)))},E=()=>{d(new Set)},T=async()=>{if(u.size===0)return;h(!0);let w=0,A=0;for(const R of u){const I=m.find(D=>D.id===R);if(I&&I.projectId!==n)try{await a.mutateAsync({projectId:n,repositoryId:R,moveFromProject:I.projectId!==null}),w++}catch{A++}}h(!1),A>0?rt.error(`Linked ${w} repositories, ${A} failed`):(rt.success(`Linked ${w} ${w===1?"repository":"repositories"}`),t(!1))},k=w=>{w&&(l(""),d(new Set)),t(w)};return c.jsx(Ya,{open:e,onOpenChange:k,children:c.jsxs(Xa,{className:"sm:max-w-xl max-h-[80dvh] flex flex-col overflow-hidden",children:[c.jsx(Lo,{className:"shrink-0",children:c.jsxs(Mo,{children:['Link Repositories to "',r,'"']})}),c.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-h-0 space-y-4",children:[c.jsxs("div",{className:"relative shrink-0",children:[c.jsx(Z,{icon:cp,size:14,strokeWidth:2,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),c.jsx(At,{value:o,onChange:w=>l(w.target.value),placeholder:"Search repositories...",className:"pl-9"})]}),c.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 rounded-md border",children:g.length===0?c.jsx("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:i?.length===0?"No repositories found in Fulcrum":"No repositories match your search"}):g.map(w=>{const A=w.projectId===n,R=w.projectId&&w.projectId!==n,I=u.has(w.id);return c.jsxs("div",{className:`flex items-start gap-3 px-3 py-3 border-b last:border-b-0 transition-colors ${A?"bg-muted/30 opacity-60":"hover:bg-muted/50 cursor-pointer"}`,onClick:()=>!A&&_(w.id),children:[c.jsx(ni,{checked:I,disabled:A,className:"mt-0.5 pointer-events-none"}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"font-medium truncate",children:w.displayName}),I&&R&&c.jsx(ir,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-amber-500/10 text-amber-600",children:"Will move"}),A&&c.jsx(ir,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"Already here"})]}),c.jsxs("div",{className:"flex items-center gap-1.5 mt-1 text-xs text-muted-foreground",children:[c.jsx(Z,{icon:Zs,size:12,strokeWidth:2,className:"shrink-0"}),c.jsx("span",{className:"truncate font-mono",children:w.path})]}),R&&c.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:["Currently in: ",w.projectName]}),!w.projectId&&c.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"Not in any project"})]})]},w.id)})}),v.length>0&&c.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-amber-500/10 px-3 py-2 text-xs text-amber-600 shrink-0",children:[c.jsx(Z,{icon:wr,size:14,strokeWidth:2,className:"mt-0.5 shrink-0"}),c.jsxs("span",{children:[v.length," ",v.length===1?"repository":"repositories"," will be moved from"," ",v.length===1?"another project":"other projects"]})]}),c.jsxs("div",{className:"flex items-center justify-between shrink-0 pt-2",children:[c.jsxs("div",{className:"flex gap-2 text-xs",children:[c.jsx("button",{type:"button",className:"text-primary hover:underline",onClick:S,children:"Select all"}),c.jsx("span",{className:"text-muted-foreground",children:"/"}),c.jsx("button",{type:"button",className:"text-primary hover:underline",onClick:E,children:"Clear"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(_e,{variant:"outline",onClick:()=>t(!1),disabled:f,children:"Cancel"}),c.jsx(_e,{onClick:T,disabled:u.size===0||f,children:f?c.jsxs(c.Fragment,{children:[c.jsx(Z,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin"}),"Linking..."]}):`Link ${u.size} ${u.size===1?"Repository":"Repositories"}`})]})]})]})]})})}function RJt({className:e,...t}){return c.jsx(VVe,{"data-slot":"radio-group",className:Ae("grid gap-3 w-full",e),...t})}function B0e({className:e,...t}){return c.jsx(zVe,{"data-slot":"radio-group-item",className:Ae("border-input text-primary dark:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/30 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 data-checked:bg-primary data-checked:border-primary flex size-4 rounded-full transition-none focus-visible:ring-[2px] aria-invalid:ring-[2px] group/radio-group-item peer relative aspect-square shrink-0 border outline-none after:absolute after:-inset-x-3 after:-inset-y-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:c.jsx(UVe,{"data-slot":"radio-group-indicator",className:"group-aria-invalid/radio-group-item:text-destructive flex size-4 items-center justify-center text-white",children:c.jsx(Z,{icon:q$e,strokeWidth:2,className:"absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 fill-current"})})})}function IJt({open:e,onOpenChange:t,projectId:n,repository:r}){const i=Nqe(),[s,a]=x.useState("unlink"),o=async()=>{if(r)try{await i.mutateAsync({projectId:n,repositoryId:r.id,deleteRecord:s==="delete"}),rt.success(s==="delete"?"Repository removed and deleted":"Repository unlinked from project"),t(!1)}catch(l){rt.error("Failed to remove repository",{description:l instanceof Error?l.message:"Unknown error"})}};return c.jsx(ql,{open:e,onOpenChange:t,children:c.jsxs(Gl,{children:[c.jsxs(Kl,{children:[c.jsx(Xl,{children:"Remove Repository"}),c.jsxs(Ql,{children:['Remove "',r?.displayName,'" from this project?']})]}),c.jsx("div",{className:"py-4",children:c.jsxs(RJt,{value:s,onValueChange:l=>a(l),className:"space-y-3",children:[c.jsxs("div",{className:"flex items-start space-x-3",children:[c.jsx(B0e,{value:"unlink",id:"unlink",className:"mt-1"}),c.jsxs("div",{className:"space-y-1",children:[c.jsx(Ur,{htmlFor:"unlink",className:"font-medium cursor-pointer",children:"Just unlink from project"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Repository record will be kept (can be added to another project later)"})]})]}),c.jsxs("div",{className:"flex items-start space-x-3",children:[c.jsx(B0e,{value:"delete",id:"delete",className:"mt-1"}),c.jsxs("div",{className:"space-y-1",children:[c.jsx(Ur,{htmlFor:"delete",className:"font-medium cursor-pointer",children:"Delete repository record"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Removes from project AND deletes the repository record (does not delete files on disk)"})]})]})]})}),c.jsxs(Yl,{children:[c.jsx(Zl,{disabled:i.isPending,children:"Cancel"}),c.jsx(_e,{variant:"destructive",onClick:o,disabled:i.isPending,children:i.isPending?c.jsxs(c.Fragment,{children:[c.jsx(Z,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin"}),"Removing..."]}):"Remove"})]})]})})}const vj="";function DJt(e){return Jt({queryKey:["project-attachments",e],queryFn:async()=>{const t=await fetch(`${vj}/api/projects/${e}/attachments`);if(!t.ok)throw new Error("Failed to fetch attachments");return t.json()},enabled:!!e})}function jJt(){const e=It();return wt({mutationFn:async({projectId:t,file:n})=>{const r=new FormData;r.append("file",n);const i=await fetch(`${vj}/api/projects/${t}/attachments`,{method:"POST",body:r});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.error||"Failed to upload attachment")}return i.json()},onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["project-attachments",n.projectId]}),e.invalidateQueries({queryKey:["projects"]}),e.invalidateQueries({queryKey:["project",n.projectId]})}})}function PJt(){const e=It();return wt({mutationFn:async({projectId:t,attachmentId:n})=>{const r=await fetch(`${vj}/api/projects/${t}/attachments/${n}`,{method:"DELETE"});if(!r.ok)throw new Error("Failed to delete attachment");return r.json()},onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["project-attachments",n.projectId]}),e.invalidateQueries({queryKey:["projects"]}),e.invalidateQueries({queryKey:["project",n.projectId]})}})}function LJt(e,t){return`${vj}/api/projects/${e}/attachments/${t}`}function MJt({project:e}){const{t}=Ot("projects"),n=Ot("repositories").t,r=Vwe(),[i,s]=x.useState(!1),[a,o]=x.useState(null),[l,u]=x.useState({}),[d,f]=x.useState({}),[h,m]=x.useState(null),[g,y]=x.useState(""),[v,_]=x.useState(!1);x.useEffect(()=>{e&&(o(e.defaultAgent??null),u(e.claudeOptions??{}),f(e.opencodeOptions??{}),m(e.opencodeModel??null),y(e.startupScript??""),_(!1))},[e]),x.useEffect(()=>{if(e){const T=a!==(e.defaultAgent??null)||JSON.stringify(l)!==JSON.stringify(e.claudeOptions??{})||JSON.stringify(d)!==JSON.stringify(e.opencodeOptions??{})||h!==(e.opencodeModel??null)||g!==(e.startupScript??"");_(T)}},[a,l,d,h,g,e]);const S=()=>{e&&r.mutate({id:e.id,updates:{defaultAgent:a,claudeOptions:Object.keys(l).length>0?l:null,opencodeOptions:Object.keys(d).length>0?d:null,opencodeModel:h,startupScript:g.trim()||null}},{onSuccess:()=>{rt.success(t("detailView.save")),_(!1)},onError:T=>{rt.error(n("detailView.failedToSave"),{description:T instanceof Error?T.message:"Unknown error"})}})},E=()=>{const T=[];a?T.push(`${t("agentSettings.summaryDefault")}: ${Io[a]}`):T.push(`${t("agentSettings.summaryDefault")}: ${t("agentSettings.inherit")}`);const k=Object.keys(l).length;k>0&&T.push(t("agentSettings.summaryClaudeOptions",{count:k}));const w=Object.keys(d).length;return w>0&&T.push(t("agentSettings.summaryOpencodeOptions",{count:w})),h&&T.push(`${t("agentSettings.summaryModel")}: ${h.split("/").pop()}`),T.join(" · ")};return c.jsxs(ug,{open:i,onOpenChange:s,className:"rounded-lg border bg-card",children:[c.jsxs("div",{className:"flex items-center justify-between p-4",children:[c.jsxs(dg,{className:"flex items-center gap-2 group",children:[c.jsx(Z,{icon:i?Ts:Bl,size:14,className:"text-muted-foreground"}),c.jsx("h2",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider group-hover:text-foreground transition-colors",children:t("detailView.general.agentTitle")}),!i&&c.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:E()})]}),i&&v&&c.jsxs(_e,{size:"sm",onClick:S,disabled:r.isPending,children:[c.jsx(Z,{icon:hr,size:14,strokeWidth:2,"data-slot":"icon"}),r.isPending?n("detailView.saving"):n("detailView.save")]})]}),c.jsx(fg,{children:c.jsxs("div",{className:"px-4 pb-4",children:[c.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:t("agentSettings.description")}),c.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[c.jsxs(qh,{children:[c.jsxs($n,{children:[c.jsx(zn,{children:t("detailView.general.defaultAgent")}),c.jsxs(Qr,{value:a??"inherit",onValueChange:T=>o(T==="inherit"?null:T),children:[c.jsx(Jr,{className:"w-full",children:c.jsx(Zr,{})}),c.jsxs(ei,{alignItemWithTrigger:!1,children:[c.jsx(jt,{value:"inherit",children:t("agentSettings.useGlobalDefault")}),Object.keys(Io).map(T=>c.jsx(jt,{value:T,children:Io[T]},T))]})]}),c.jsx(Pi,{children:n("detailView.settings.defaultAgentDescription")})]}),c.jsxs($n,{children:[c.jsx(zn,{children:t("agentSettings.startupScript")}),c.jsx(Pi,{className:"mb-2",children:t("agentSettings.startupScriptDescription")}),c.jsx(Oc,{value:g,onChange:T=>y(T.target.value),placeholder:"export ENV_VAR=value",className:"font-mono text-xs min-h-[60px]",rows:2})]}),c.jsxs($n,{children:[c.jsx(zn,{children:t("detailView.general.claudeOptions")}),c.jsx(Pi,{className:"mb-2",children:n("detailView.settings.claudeOptionsDescription")}),c.jsx(l3,{value:l,onChange:u})]})]}),c.jsxs(qh,{children:[c.jsxs($n,{children:[c.jsx(zn,{children:t("detailView.general.opencodeModel")}),c.jsx(Bb,{value:h,onChange:m,placeholder:n("detailView.settings.opencodeModelPlaceholder")}),c.jsx(Pi,{children:n("detailView.settings.opencodeModelDescription")})]}),c.jsxs($n,{children:[c.jsx(zn,{children:t("detailView.general.opencodeOptions")}),c.jsx(Pi,{className:"mb-2",children:n("detailView.settings.opencodeOptionsDescription")}),c.jsx(l3,{value:d,onChange:f})]})]})]})]})})]})}const Xje=xa("/projects/$projectId")({component:VJt}),FJt={TO_DO:"bg-muted-foreground/40",IN_PROGRESS:"bg-blue-500",IN_REVIEW:"bg-amber-500",DONE:"bg-green-500/40",CANCELED:"bg-muted-foreground/20"};function BJt({tasks:e}){const{t}=Ot("projects"),n=e.filter(s=>s.status!=="DONE"&&s.status!=="CANCELED").slice(0,8),r=e.filter(s=>s.status!=="DONE"&&s.status!=="CANCELED").length,i=e.filter(s=>s.status==="DONE"||s.status==="CANCELED").length;return c.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[c.jsx("div",{className:"flex items-center gap-0.5",children:n.length>0?n.map(s=>c.jsx("div",{className:Ae("w-1.5 h-1.5 rounded-full",FJt[s.status]),title:`${s.title} (${s.status})`},s.id)):Array.from({length:3}).map((s,a)=>c.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-muted"},a))}),c.jsxs("span",{children:[t("repoCard.activeCount",{count:r}),i>0&&` · ${t("repoCard.doneCount",{count:i})}`]})]})}function $Jt({repository:e,tasks:t,onRemove:n,onNewTask:r}){const i=Ni(),s=()=>{i({to:"/repositories/$repoId",params:{repoId:e.id},search:{tab:"settings"}})};return c.jsx(xi,{className:"group transition-colors hover:border-foreground/20 cursor-pointer",onClick:s,children:c.jsxs(Ms,{className:"py-3 px-4",children:[c.jsxs("div",{className:"flex items-start justify-between gap-2",children:[c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("h3",{className:"font-medium truncate group-hover:text-primary transition-colors",children:e.displayName}),c.jsx("div",{className:"flex items-center gap-1.5 mt-0.5 text-xs text-muted-foreground",children:c.jsx("span",{className:"truncate font-mono",children:e.path})})]}),c.jsx(_e,{variant:"ghost",size:"sm",onClick:a=>{a.stopPropagation(),n()},className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-opacity",children:c.jsx(Z,{icon:Tn,size:14,strokeWidth:2})})]}),c.jsx("div",{className:"mt-2",children:c.jsx(BJt,{tasks:t})}),c.jsxs("div",{className:"mt-3 flex items-center gap-1",children:[c.jsxs(wh,{children:[c.jsxs(Eh,{onClick:a=>{a.stopPropagation(),r()},className:"inline-flex items-center justify-center gap-1 whitespace-nowrap text-sm font-medium h-7 px-2 rounded-md border bg-background hover:bg-accent hover:text-accent-foreground text-muted-foreground",children:[c.jsx(Z,{icon:rD,size:14,strokeWidth:2}),c.jsx("span",{children:"Task"})]}),c.jsx(Ch,{children:"New Task"})]}),c.jsxs(wh,{children:[c.jsx(Eh,{onClick:a=>{a.stopPropagation(),i({to:"/repositories/$repoId",params:{repoId:e.id},search:{tab:"workspace"}})},className:"inline-flex items-center justify-center whitespace-nowrap text-sm font-medium h-7 px-2 rounded-md border bg-background hover:bg-accent hover:text-accent-foreground text-muted-foreground",children:c.jsx(Z,{icon:v$,size:14,strokeWidth:2})}),c.jsx(Ch,{children:"Open Workspace"})]}),c.jsxs(wh,{children:[c.jsx(Eh,{onClick:a=>{a.stopPropagation(),i({to:"/repositories/$repoId",params:{repoId:e.id},search:{tab:"deploy",action:"deploy"}})},className:"inline-flex items-center justify-center whitespace-nowrap text-sm font-medium h-7 px-2 rounded-md border bg-background hover:bg-accent hover:text-accent-foreground text-muted-foreground",children:c.jsx(Z,{icon:vb,size:14,strokeWidth:2})}),c.jsx(Ch,{children:"Deploy"})]}),c.jsxs(wh,{children:[c.jsx(Eh,{onClick:a=>{a.stopPropagation(),i({to:"/repositories/$repoId",params:{repoId:e.id},search:{tab:"settings"}})},className:"inline-flex items-center justify-center whitespace-nowrap text-sm font-medium h-7 px-2 rounded-md border bg-background hover:bg-accent hover:text-accent-foreground text-muted-foreground",children:c.jsx(Z,{icon:VO,size:14,strokeWidth:2})}),c.jsx(Ch,{children:"Settings"})]})]})]})})}function zJt({projectId:e,tags:t}){const{t:n}=Ot("projects"),[r,i]=x.useState(!1),[s,a]=x.useState(""),[o,l]=x.useState(!1),u=x.useRef(null),d=x.useRef(null),{data:f=[]}=NW(s),h=UWe(),m=HWe(),g=f.filter(E=>!t.some(T=>T.id===E.id)),y=f.find(E=>E.name.toLowerCase()===s.toLowerCase()),v=s.trim()&&!y;x.useEffect(()=>{const E=T=>{d.current&&!d.current.contains(T.target)&&(l(!1),i(!1),a(""))};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]);const _=async E=>{try{typeof E=="string"?await h.mutateAsync({projectId:e,name:E}):await h.mutateAsync({projectId:e,tagId:E.id}),a(""),l(!1),i(!1)}catch{}},S=E=>{E.key==="Enter"&&s.trim()?(E.preventDefault(),y&&!t.some(T=>T.id===y.id)?_(y):v&&_(s.trim())):E.key==="Escape"&&(l(!1),i(!1),a(""))};return c.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",ref:d,children:[t.map(E=>c.jsxs(ir,{variant:"default",className:"text-xs group/tag",children:[E.name,c.jsx("button",{onClick:()=>m.mutate({projectId:e,tagId:E.id}),className:"ml-1 opacity-0 group-hover/tag:opacity-100 hover:text-destructive transition-opacity",children:c.jsx(Z,{icon:Tn,size:10})})]},E.id)),r?c.jsxs("div",{className:"relative",children:[c.jsx(At,{ref:u,value:s,onChange:E=>{a(E.target.value),l(!0)},onFocus:()=>l(!0),onKeyDown:S,placeholder:n("detail.addTag"),className:"h-6 w-24 text-xs",autoFocus:!0}),o&&(s||g.length>0)&&c.jsxs("div",{className:"absolute top-full left-0 mt-1 w-48 bg-popover border rounded-md shadow-lg z-50 max-h-32 overflow-y-auto",children:[g.slice(0,5).map(E=>c.jsx("button",{className:"w-full px-2 py-1.5 text-left text-xs hover:bg-accent",onClick:()=>_(E),children:E.name},E.id)),v&&c.jsxs("button",{className:"w-full px-2 py-1.5 text-left text-xs hover:bg-accent flex items-center gap-1 border-t",onClick:()=>_(s.trim()),children:[c.jsx(Z,{icon:Ic,size:12}),n("detail.createTag",{tag:s.trim()})]})]})]}):c.jsx("button",{onClick:()=>{i(!0),setTimeout(()=>u.current?.focus(),0)},className:"h-5 w-5 rounded border border-dashed border-muted-foreground/50 flex items-center justify-center text-muted-foreground hover:text-foreground hover:border-foreground transition-colors",children:c.jsx(Z,{icon:Ic,size:12})})]})}function UJt({projectId:e,links:t}){const{t:n}=Ot("projects"),[r,i]=x.useState(!1),[s,a]=x.useState(""),[o,l]=x.useState(""),u=Dqe(),d=jqe(),f=()=>{const m=s.trim();if(m){try{new URL(m)}catch{rt.error(n("detail.errors.invalidUrl",{defaultValue:"Invalid URL"}),{description:n("detail.errors.invalidUrlDescription",{defaultValue:"Please enter a valid URL including the scheme (e.g., https://)"})});return}u.mutate({projectId:e,url:m,label:o.trim()||void 0},{onSuccess:()=>{a(""),l(""),i(!1)}})}},h=m=>{m.key==="Enter"?(m.preventDefault(),f()):m.key==="Escape"&&(i(!1),a(""),l(""))};return c.jsxs("div",{className:"space-y-2",children:[c.jsx("h3",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:n("detail.sections.links")}),c.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.map(m=>c.jsxs("div",{className:"group/link flex items-center",children:[c.jsxs("button",{onClick:()=>jl(m.url),className:"flex items-center gap-1.5 text-xs text-primary hover:underline",children:[c.jsx(Z,{icon:Ay,size:12}),c.jsx("span",{className:"max-w-32 truncate",children:m.label||m.url})]}),c.jsx("button",{onClick:()=>d.mutate({projectId:e,linkId:m.id}),className:"ml-1 opacity-0 group-hover/link:opacity-100 text-muted-foreground hover:text-destructive transition-opacity",children:c.jsx(Z,{icon:Tn,size:10})})]},m.id)),r?c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(At,{type:"url",value:s,onChange:m=>a(m.target.value),onKeyDown:h,placeholder:n("detail.urlPlaceholder"),className:"h-6 w-32 text-xs",autoFocus:!0}),c.jsx(At,{type:"text",value:o,onChange:m=>l(m.target.value),onKeyDown:h,placeholder:n("detail.labelPlaceholder"),className:"h-6 w-20 text-xs"}),c.jsx(_e,{size:"sm",className:"h-6 px-2 text-xs",onClick:f,children:n("detail.add")}),c.jsx(_e,{variant:"ghost",size:"sm",className:"h-6 px-1",onClick:()=>{i(!1),a(""),l("")},children:c.jsx(Z,{icon:Tn,size:12})})]}):c.jsxs("button",{onClick:()=>i(!0),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[c.jsx(Z,{icon:Ic,size:12}),c.jsx("span",{children:n("detail.add")})]})]})]})}function HJt({projectId:e}){const{t}=Ot("projects"),{data:n=[],isLoading:r}=DJt(e),i=jJt(),s=PJt(),a=x.useRef(null),[o,l]=x.useState(!1),u=x.useCallback(async y=>{if(!(!y||y.length===0))for(const v of Array.from(y))try{await i.mutateAsync({projectId:e,file:v})}catch{}},[e,i]),d=x.useCallback(y=>{y.preventDefault(),y.stopPropagation(),l(!0)},[]),f=x.useCallback(y=>{y.preventDefault(),y.stopPropagation(),l(!1)},[]),h=x.useCallback(y=>{y.preventDefault(),y.stopPropagation(),l(!1),u(y.dataTransfer.files)},[u]),m=y=>y==="application/pdf"?Y_e:y.startsWith("image/")?U_e:$_e,g=y=>y<1024?`${y}B`:y<1024*1024?`${(y/1024).toFixed(0)}KB`:`${(y/1024/1024).toFixed(1)}MB`;return r?c.jsxs("div",{className:"space-y-2",children:[c.jsx("h3",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:t("detail.sections.attachments")}),c.jsx("span",{className:"text-xs text-muted-foreground",children:t("detail.loading")})]}):c.jsxs("div",{className:"space-y-2",children:[c.jsx("h3",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:t("detail.sections.attachments")}),c.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.map(y=>{const v=m(y.mimeType);return c.jsxs("div",{className:"group/file flex items-center gap-1 text-xs",children:[c.jsxs("button",{onClick:()=>window.open(LJt(e,y.id),"_blank"),className:"flex items-center gap-1 text-muted-foreground hover:text-foreground",children:[c.jsx(Z,{icon:v,size:12}),c.jsx("span",{className:"max-w-24 truncate",children:y.filename}),c.jsxs("span",{className:"text-muted-foreground/70",children:["(",g(y.size),")"]})]}),c.jsx("button",{onClick:()=>s.mutate({projectId:e,attachmentId:y.id}),className:"opacity-0 group-hover/file:opacity-100 text-muted-foreground hover:text-destructive transition-opacity",children:c.jsx(Z,{icon:Tn,size:10})})]},y.id)}),c.jsx("input",{ref:a,type:"file",multiple:!0,className:"hidden",onChange:y=>u(y.target.files),accept:".pdf,.png,.jpg,.jpeg,.gif,.webp,.svg,.txt,.md,.doc,.docx,.xls,.xlsx,.json,.zip,.gz,.tar"}),c.jsxs("button",{onClick:()=>a.current?.click(),onDragOver:d,onDragLeave:f,onDrop:h,className:Ae("flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors px-2 py-1 border border-dashed rounded",o&&"border-primary bg-primary/5",i.isPending&&"opacity-50"),children:[c.jsx(Z,{icon:i.isPending?Nt:J_e,size:12,className:i.isPending?"animate-spin":""}),c.jsx("span",{children:i.isPending?t("detail.uploading"):t("detail.dropOrClickShort")})]})]})]})}function VJt(){const{t:e}=Ot("projects"),{projectId:t}=Xje.useParams(),n=Ls({select:fe=>fe.location}),r=Ni(),{data:i,isLoading:s,error:a}=Aqe(t),{data:o=[]}=cl(),l=Wwe(),u=Oqe(),d=Vwe(),[f,h]=x.useState(!1),[m,g]=x.useState(!1),[y,v]=x.useState(null),[_,S]=x.useState(!1),[E,T]=x.useState(""),k=x.useRef(null),[w,A]=x.useState(!1),[R,I]=x.useState(""),[D,j]=x.useState(!1),[F,z]=x.useState(!1),[P,L]=x.useState(""),M=x.useRef(null),[$,W]=x.useState(!1),[Y,q]=x.useState(!1),[K,X]=x.useState({open:!1,repository:null});x.useEffect(()=>{new URLSearchParams(n.search).get("addRepo")==="true"&&!$&&(W(!0),r({to:"/projects/$projectId",params:{projectId:t},replace:!0}))},[n.search,$,r,t]),x.useEffect(()=>{t&&u.mutate(t)},[t]);const U=x.useMemo(()=>NJt(o,i?.repositories??[]),[o,i?.repositories]),J=x.useMemo(()=>o.filter(fe=>fe.status!=="DONE"&&fe.status!=="CANCELED"&&(fe.projectId===t||i?.repositories.some(be=>be.path===fe.repoPath))),[o,t,i?.repositories]),te=x.useCallback(()=>{i&&(T(i.name),S(!0),setTimeout(()=>k.current?.select(),0))},[i]),ee=x.useCallback(()=>{const fe=E.trim();fe&&fe!==i?.name&&d.mutate({id:t,updates:{name:fe}}),S(!1)},[E,i?.name,t,d]),oe=x.useCallback(()=>{S(!1),T("")},[]),ae=x.useCallback(fe=>{fe.key==="Enter"?(fe.preventDefault(),ee()):fe.key==="Escape"&&oe()},[ee,oe]),se=x.useCallback(()=>{i&&(I(i.description||""),A(!0))},[i]),ue=x.useCallback(()=>{const fe=R.trim()||null;fe!==(i?.description||null)&&d.mutate({id:t,updates:{description:fe}}),A(!1)},[R,i?.description,t,d]),de=x.useCallback(()=>{i&&(L(i.notes||""),z(!0),j(!0),setTimeout(()=>M.current?.focus(),0))},[i]),ce=x.useCallback(()=>{const fe=P.trim()||null;fe!==(i?.notes||null)&&d.mutate({id:t,updates:{notes:fe}}),z(!1)},[P,i?.notes,t,d]),Ee=x.useCallback(()=>{z(!1),L("")},[]),Ie=async()=>{g(!0);try{await l.mutateAsync({id:t,deleteDirectory:!1,deleteApp:!1}),rt.success(e("delete.success")),h(!1),r({to:"/projects"})}catch(fe){rt.error(e("delete.error"),{description:fe instanceof Error?fe.message:"Unknown error"}),g(!1)}};return s?c.jsx("div",{className:"flex h-full items-center justify-center",children:c.jsx(Z,{icon:Nt,size:24,className:"animate-spin text-muted-foreground"})}):a||!i?c.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4",children:[c.jsx(Z,{icon:wr,size:24,className:"text-destructive"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:e("notFound")}),c.jsx(Pr,{to:"/projects",children:c.jsx(_e,{variant:"outline",size:"sm",children:e("backToProjects")})})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsxs("div",{className:"film-grain relative flex shrink-0 items-center justify-between gap-4 border-b border-border px-4 py-2",style:{background:"var(--gradient-header)"},children:[_?c.jsx(At,{ref:k,type:"text",value:E,onChange:fe=>T(fe.target.value),onBlur:ee,onKeyDown:ae,className:"font-medium text-sm bg-transparent border-b border-primary outline-none px-0.5 w-auto max-w-[200px] h-auto py-0",autoFocus:!0}):c.jsx("button",{type:"button",onClick:te,className:"font-medium text-sm hover:text-primary transition-colors cursor-pointer",title:e("detail.clickToEdit"),children:i.name}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsxs(_e,{variant:"ghost",size:"sm",onClick:()=>i.repositories.length>0&&v(i.repositories[0]),disabled:i.repositories.length===0,className:"text-muted-foreground hover:text-foreground",children:[c.jsx(Z,{icon:rD,size:14,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"hidden sm:inline",children:e("detail.actions.task")})]}),c.jsxs(_e,{variant:"ghost",size:"sm",onClick:()=>q(!0),className:"text-muted-foreground hover:text-foreground",children:[c.jsx(Z,{icon:b$,size:14,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"hidden sm:inline",children:e("detail.actions.repo")})]}),c.jsxs(_e,{variant:"ghost",size:"sm",onClick:()=>W(!0),className:"text-muted-foreground hover:text-foreground",children:[c.jsx(Z,{icon:g$,size:14,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"hidden sm:inline",children:e("detail.actions.link")})]})]}),c.jsx("div",{className:"flex items-center gap-2",children:c.jsx(_e,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:()=>h(!0),children:c.jsx(Z,{icon:ks,size:14,strokeWidth:2})})})]}),c.jsx("div",{className:"flex-1 overflow-auto p-6",children:c.jsxs("div",{className:"mx-auto max-w-5xl space-y-6 pb-6",children:[w?c.jsxs("div",{className:"flex items-start gap-2",children:[c.jsx(Oc,{value:R,onChange:fe=>I(fe.target.value),placeholder:e("detail.addDescription"),className:"min-h-[60px] text-sm flex-1",autoFocus:!0,onKeyDown:fe=>{fe.key==="Enter"&&fe.metaKey?ue():fe.key==="Escape"&&A(!1)}}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx(_e,{size:"sm",className:"h-7",onClick:ue,children:e("detail.save")}),c.jsx(_e,{variant:"ghost",size:"sm",className:"h-7",onClick:()=>A(!1),children:e("detail.cancel")})]})]}):i.description?c.jsx("p",{className:"text-sm text-muted-foreground cursor-pointer hover:text-foreground transition-colors",onClick:se,title:e("detail.clickToEdit"),children:i.description}):null,c.jsxs("section",{className:"rounded-lg border p-4 space-y-3 bg-card",children:[c.jsx("h2",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:e("detail.sections.repositories")}),i.repositories.length===0?c.jsx(xi,{className:"border-dashed",children:c.jsxs(Ms,{className:"py-6 text-center text-muted-foreground",children:[c.jsx("p",{className:"text-sm",children:e("detail.noRepositories")}),c.jsxs("div",{className:"mt-3 flex justify-center gap-2",children:[c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>q(!0),children:[c.jsx(Z,{icon:b$,size:14,"data-slot":"icon"}),e("addRepo")]}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>W(!0),children:[c.jsx(Z,{icon:g$,size:14,"data-slot":"icon"}),e("detail.linkExisting")]})]})]})}):c.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3",children:i.repositories.map(fe=>c.jsx($Jt,{repository:fe,tasks:U.get(fe.id)||[],onRemove:()=>X({open:!0,repository:fe}),onNewTask:()=>v(fe)},fe.id))})]}),c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[c.jsx("div",{className:"film-grain relative rounded-lg border p-4",style:{background:"var(--gradient-card)"},children:c.jsx(UJt,{projectId:t,links:i.links||[]})}),c.jsx("div",{className:"film-grain relative rounded-lg border p-4",style:{background:"var(--gradient-card)"},children:c.jsx(HJt,{projectId:t})})]}),c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[c.jsxs("div",{className:"film-grain relative rounded-lg border p-4 space-y-2",style:{background:"var(--gradient-card)"},children:[c.jsx("h3",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:e("detail.sections.tags")}),c.jsx(zJt,{projectId:t,tags:i.tags||[]})]}),c.jsxs(ug,{open:D,onOpenChange:j,className:"film-grain relative rounded-lg border p-4",style:{background:"var(--gradient-card)"},children:[c.jsxs(dg,{className:"flex items-center gap-2 w-full text-left group",children:[c.jsx(Z,{icon:D?Ts:Bl,size:14,className:"text-muted-foreground"}),c.jsx("h2",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider group-hover:text-foreground transition-colors",children:e("detail.sections.notes")}),!D&&i.notes&&c.jsxs("span",{className:"text-xs text-muted-foreground truncate max-w-xs",children:["— ",i.notes.split(`
328
+ `)),a(!0),setTimeout(()=>a(!1),2e3)},E=async()=>{await l.mutateAsync(e)},T=k=>{switch(k){case"pulling":return i("apps.streaming.pulling");case"building":return i("apps.streaming.building");case"starting":return i("apps.streaming.starting");case"configuring":return i("apps.streaming.configuring");case"done":return i("apps.streaming.done");case"failed":return i("apps.streaming.failed");case"cancelled":return i("apps.streaming.cancelled");default:return i("apps.streaming.preparing")}};return c.jsx(Ya,{open:t,onOpenChange:n,children:c.jsxs(Xa,{className:"!max-w-[90vw] w-[90vw] h-[85vh] flex flex-col",children:[c.jsxs(Lo,{children:[c.jsxs(Mo,{className:"flex items-center gap-2",children:[i("apps.deployments.deployment"),y&&c.jsx(Z,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin"}),!y&&!m&&f==="done"&&c.jsx(Z,{icon:sl,size:16,strokeWidth:2,className:"text-green-500"}),m&&c.jsx(Z,{icon:wr,size:16,strokeWidth:2,className:"text-destructive"})]}),c.jsxs(eg,{className:"flex items-center gap-2",children:[T(f),y&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-muted-foreground",children:"|"}),c.jsxs(_e,{variant:"destructive",size:"sm",onClick:E,disabled:l.isPending,children:[l.isPending?c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}):c.jsx(Z,{icon:EE,size:14,strokeWidth:2}),l.isPending?i("apps.cancelling"):i("apps.cancelDeploy")]})]}),c.jsx("span",{className:"text-muted-foreground",children:"|"}),c.jsxs("span",{children:[_.length," ",i("apps.logs.lines")]}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:S,disabled:u.length===0,children:c.jsx(Z,{icon:s?sl:J3,size:14,strokeWidth:2,className:s?"text-green-500":""})})]})]}),c.jsxs("div",{ref:o,className:"flex-1 overflow-auto rounded-lg border bg-muted/30 p-2 custom-logs-scrollbar",children:[_.length>0?_.map((k,w)=>c.jsx(YJ,{message:k.message,type:k.type},w)):y?c.jsx("span",{className:"text-muted-foreground p-2",children:i("apps.streaming.waitingForLogs")}):c.jsx("span",{className:"text-muted-foreground p-2",children:i("apps.deployments.noBuildLogs")}),m&&c.jsxs("div",{className:"mt-2 p-2 rounded bg-destructive/10 text-destructive text-sm",children:[i("status.error"),": ",m]})]})]})})}function gJt(e,t){const n=new Date(e).getTime(),r=t?new Date(t).getTime():Date.now(),i=Math.floor((r-n)/1e3);if(i<60)return`${i}s`;const s=Math.floor(i/60),a=i%60;return a===0?`${s}m`:`${s}m ${a}s`}function bJt(e){const t=Date.now(),n=new Date(e).getTime(),r=t-n,i=Math.floor(r/6e4);if(i<1)return"just now";if(i<60)return`about ${i} min ago`;const s=Math.floor(i/60);return s<24?`about ${s}h ago`:`about ${Math.floor(s/24)}d ago`}function yJt({appId:e,deployStore:t,onViewStreamingLogs:n}){const{t:r}=Ot("common"),{data:i,isLoading:s}=wJe(e),[a,o]=x.useState(null),l=u=>{u.status==="building"||u.status==="pending"?((!t.isDeploying||t.appId!==e)&&t.watchDeployment(e),n()):o(u)};return s?c.jsx("div",{className:"flex items-center justify-center py-8",children:c.jsx(Z,{icon:Nt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}):c.jsxs("div",{children:[c.jsxs("div",{className:"mb-4",children:[c.jsx("h3",{className:"text-lg font-semibold",children:r("apps.deployments.title")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:r("apps.deployments.description")})]}),i?.length?c.jsx("div",{className:"border rounded-lg divide-y",children:i.map((u,d)=>c.jsx(vJt,{deployment:u,number:d+1,onViewLogs:()=>l(u)},u.id))}):c.jsx("div",{className:"py-8 text-center text-muted-foreground border rounded-lg",children:c.jsx("p",{children:r("apps.deployments.noDeployments")})}),c.jsx(xJt,{deployment:a,open:!!a,onOpenChange:u=>!u&&o(null)})]})}function vJt({deployment:e,number:t,onViewLogs:n}){const{t:r}=Ot("common"),i=e.status==="building"||e.status==="pending",[,s]=x.useState(0);x.useEffect(()=>{if(!i)return;const u=setInterval(()=>s(d=>d+1),1e3);return()=>clearInterval(u)},[i]);const a=()=>{switch(e.status){case"running":return{text:r("apps.deployments.statusDone"),color:"bg-green-500"};case"failed":return{text:r("apps.deployments.statusError"),color:"bg-red-500"};case"building":case"pending":return{text:r("apps.deployments.statusBuilding"),color:"bg-yellow-500"};default:return{text:e.status,color:"bg-gray-400"}}},{text:o,color:l}=a();return c.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("span",{className:"text-muted-foreground w-6",children:[t,"."]}),c.jsx("span",{className:"font-medium",children:o}),c.jsx("div",{className:`h-2 w-2 rounded-full ${l}`})]}),c.jsxs("div",{className:"flex items-center gap-4",children:[c.jsx("span",{className:"text-sm text-muted-foreground",children:bJt(e.startedAt)}),c.jsxs("span",{className:"text-sm text-muted-foreground tabular-nums",children:["⏱ ",gJt(e.startedAt,e.completedAt)]}),c.jsx(_e,{size:"sm",onClick:n,children:r("apps.deployments.view")})]})]})}function xJt({deployment:e,open:t,onOpenChange:n}){const{t:r}=Ot("common"),[i,s]=x.useState(!1),a=x.useMemo(()=>KJ(e?.buildLogs??""),[e?.buildLogs]),o=async()=>{e?.buildLogs&&(await navigator.clipboard.writeText(e.buildLogs),s(!0),setTimeout(()=>s(!1),2e3))};return c.jsx(Ya,{open:t,onOpenChange:n,children:c.jsxs(Xa,{className:"!max-w-[90vw] w-[90vw] h-[85vh] flex flex-col",children:[c.jsxs(Lo,{children:[c.jsx(Mo,{children:r("apps.deployments.deployment")}),c.jsxs(eg,{className:"flex items-center gap-2",children:[r("apps.deployments.seeDetails"),c.jsx("span",{className:"text-muted-foreground",children:"|"}),c.jsxs("span",{children:[a.length," ",r("apps.logs.lines")]}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:o,children:c.jsx(Z,{icon:i?sl:J3,size:14,strokeWidth:2,className:i?"text-green-500":""})})]})]}),c.jsx("div",{className:"flex-1 overflow-auto rounded-lg border bg-muted/30 p-2 custom-logs-scrollbar",children:a.length>0?a.map((l,u)=>c.jsx(YJ,{message:l.message,type:l.type},u)):c.jsx("span",{className:"text-muted-foreground p-2",children:r("apps.deployments.noBuildLogs")})})]})})}function _Jt({appId:e,services:t}){const{t:n}=Ot("common"),{data:r}=eCe(e),[i,s]=x.useState(),[a,o]=x.useState(100),{data:l,isLoading:u,refetch:d}=SJe(e,i,a),[f,h]=x.useState(!1),m=x.useMemo(()=>KJ(l?.logs??""),[l?.logs]),g=async()=>{l?.logs&&(await navigator.clipboard.writeText(l.logs),h(!0),setTimeout(()=>h(!1),2e3))},y=()=>{if(l?.logs){const _=new Blob([l.logs],{type:"text/plain"}),S=URL.createObjectURL(_),E=document.createElement("a");E.href=S,E.download=`${e}-${i??"all"}-logs.txt`,document.body.appendChild(E),E.click(),document.body.removeChild(E),URL.revokeObjectURL(S)}},v=r?.containers??[];return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"text-lg font-semibold",children:n("apps.logs.title")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:n("apps.logs.description")})]}),c.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[c.jsxs("select",{value:i??"",onChange:_=>s(_.target.value||void 0),className:"rounded-md border bg-background px-3 py-2 text-sm min-w-[240px]",children:[c.jsx("option",{value:"",children:n("apps.logs.allContainers")}),v.length>0?v.map(_=>c.jsxs("option",{value:_.service,children:[_.service," (",_.name.slice(-12),") [",_.status,"]"]},_.name)):t?.map(_=>c.jsx("option",{value:_.serviceName,children:_.serviceName},_.id))]}),c.jsxs("select",{value:a,onChange:_=>o(parseInt(_.target.value,10)),className:"rounded-md border bg-background px-3 py-2 text-sm",children:[c.jsxs("option",{value:50,children:["50 ",n("apps.logs.lines")]}),c.jsxs("option",{value:100,children:["100 ",n("apps.logs.lines")]}),c.jsxs("option",{value:500,children:["500 ",n("apps.logs.lines")]}),c.jsxs("option",{value:1e3,children:["1000 ",n("apps.logs.lines")]})]}),c.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[c.jsxs(_e,{variant:"outline",size:"sm",onClick:g,disabled:!l?.logs,children:[c.jsx(Z,{icon:f?sl:J3,size:14,strokeWidth:2,className:f?"text-green-500":""}),n(f?"apps.logs.copied":"apps.logs.copy")]}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:y,disabled:!l?.logs,children:[c.jsx(Z,{icon:xf,size:14,strokeWidth:2,className:"rotate-[-90deg]"}),n("apps.logs.download")]}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>d(),children:[c.jsx(Z,{icon:lp,size:14,strokeWidth:2}),n("apps.logs.refresh")]})]})]}),c.jsx("div",{className:"rounded-lg border bg-muted/80 p-2 overflow-auto max-h-[600px] min-h-[300px] custom-logs-scrollbar",children:u?c.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground p-2",children:[c.jsx(Z,{icon:Nt,size:14,strokeWidth:2,className:"animate-spin"}),n("status.loading")]}):m.length>0?m.map((_,S)=>c.jsx(YJ,{message:_.message,type:_.type},S)):c.jsx("span",{className:"text-muted-foreground p-2",children:n("apps.logs.noLogs")})})]})}const M0e=["var(--chart-1)","var(--chart-2)","var(--chart-3)","var(--chart-4)","var(--chart-5)"];function SJt(e){const t=e.split("_");if(t.length>=2)return t[1].split(".")[0];const n=e.split(/[-_.]/);for(const r of n.slice(1))if(r&&!r.match(/^\d+$/)&&r.length>2)return r;return e}function wJt(e,t){const n=e.slice(0,8).toLowerCase().replace(/[^a-z0-9]/g,"");return t?`fulcrum-${t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").slice(0,20).replace(/-$/,"")}-${n}`:`fulcrum-${n}`}function F0e({data:e,label:t,totalValue:n,unit:r}){return c.jsxs("div",{className:"flex flex-col items-center",children:[c.jsxs("div",{className:"relative size-28",children:[c.jsx(HZ,{width:"100%",height:"100%",children:c.jsxs(r5e,{children:[c.jsx($f,{data:e,cx:"50%",cy:"50%",innerRadius:32,outerRadius:48,paddingAngle:2,dataKey:"value",stroke:"none",children:e.map((i,s)=>c.jsx(pg,{fill:i.color},`cell-${s}`))}),c.jsx(ha,{content:({active:i,payload:s})=>{if(i&&s&&s.length){const a=s[0].payload;return c.jsxs("div",{className:"bg-popover border rounded-md px-2 py-1 text-xs shadow-md",children:[c.jsx("p",{className:"font-medium",children:a.name}),c.jsxs("p",{className:"text-muted-foreground",children:[a.value.toFixed(1)," ",r]})]})}return null}})]})}),c.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[c.jsx("span",{className:"text-sm font-semibold tabular-nums",children:n}),c.jsx("span",{className:"text-[10px] text-muted-foreground",children:r})]})]}),c.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:t})]})}function EJt({containers:e}){const{t}=Ot("common"),n=e.reduce((o,l)=>o+l.cpuPercent,0),r=e.reduce((o,l)=>o+l.memoryMB,0),i=e.map((o,l)=>({name:SJt(o.name),cpu:o.cpuPercent,memory:o.memoryMB,color:M0e[l%M0e.length]})),s=i.map(o=>({name:o.name,value:o.cpu,color:o.color})),a=i.map(o=>({name:o.name,value:o.memory,color:o.color}));return c.jsxs(xi,{className:"p-4 mb-6",children:[c.jsx("h4",{className:"text-sm font-medium mb-4",children:t("apps.monitoring.serviceTotal")}),c.jsxs("div",{className:"flex items-center justify-center gap-8",children:[c.jsx(F0e,{data:s,label:t("apps.monitoring.cpu"),totalValue:n.toFixed(1),unit:"%"}),c.jsx(F0e,{data:a,label:t("apps.monitoring.memory"),totalValue:r.toFixed(0),unit:"MB"})]}),c.jsx("div",{className:"flex flex-wrap justify-center gap-x-4 gap-y-1 mt-4",children:i.map(o=>c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("div",{className:"size-2.5 rounded-full",style:{backgroundColor:o.color}}),c.jsx("span",{className:"text-xs text-muted-foreground",children:o.name})]},o.name))})]})}function CJt({appId:e,repoDisplayName:t}){const{t:n}=Ot("common"),{data:r,isLoading:i}=g5e(),s=x.useMemo(()=>{if(!r?.containers)return[];const a=`${wJt(e,t)}_`;return r.containers.filter(o=>o.name.toLowerCase().startsWith(a))},[r,e,t]);return i?c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(Z,{icon:Nt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}):r?.available?s.length===0?c.jsxs("div",{children:[c.jsxs("div",{className:"mb-4",children:[c.jsx("h3",{className:"text-lg font-semibold",children:n("apps.monitoring.title")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:n("apps.monitoring.description")})]}),c.jsx("div",{className:"py-8 text-center text-muted-foreground border rounded-lg",children:c.jsx("p",{children:n("apps.monitoring.noContainers")})})]}):c.jsxs("div",{children:[c.jsxs("div",{className:"mb-4",children:[c.jsx("h3",{className:"text-lg font-semibold",children:n("apps.monitoring.title")}),c.jsxs("p",{className:"text-sm text-muted-foreground",children:[n("apps.monitoring.description"),r.runtime&&c.jsxs("span",{className:"ml-1 text-xs",children:["(",r.runtime,")"]})]})]}),c.jsx(EJt,{containers:s})]}):c.jsxs("div",{children:[c.jsxs("div",{className:"mb-4",children:[c.jsx("h3",{className:"text-lg font-semibold",children:n("apps.monitoring.title")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:n("apps.monitoring.description")})]}),c.jsx("div",{className:"py-8 text-center text-muted-foreground border rounded-lg",children:c.jsx("p",{children:n("apps.monitoring.dockerUnavailable")})})]})}const kJt=Py(function(){const{t}=Ot("repositories"),n=Ot("projects").t,r=Ot("common").t,i=Ni(),s=It(),{repoId:a}=C3({from:"/repositories/$repoId"}),o=aC({from:"/repositories/$repoId"}),{data:l,isLoading:u,error:d}=Cqe(a),f=TJe(a),h=Yst(),{data:m}=nCe(),{data:g,isLoading:y}=EJe(a),v=_Je(),_=J2e(),S=Tqe(),E=xJe(),T=o.tab??"settings",k=T==="deploy"?o.subtab||"general":null,[w,A]=x.useState(!1),[R,I]=x.useState(!1),[D,j]=x.useState(!1),[F,z]=x.useState(!1),[P,L]=x.useState(!1),[M,$]=x.useState(""),[W,Y]=x.useState(!1),[q,K]=x.useState(!1),X=x.useRef(null),U=x.useRef(!1),J=h.isDeploying||f?.status==="building",te=f?.status==="running"||f?.status==="failed"||f?.status==="building",ee=!!f,oe=m&&!m.settings.cloudflareConfigured,{data:ae}=dD(),{data:se}=fD(),{data:ue}=hD(),[de,ce]=x.useState(null);x.useEffect(()=>{if(o.action==="deploy"&&f&&!U.current){U.current=!0,ce(f.id);const ie={};o.tab&&(ie.tab=o.tab),o.subtab&&(ie.subtab=o.subtab),i({to:"/repositories/$repoId",params:{repoId:a},search:ie,replace:!0})}},[o.action,f,a,i,o.tab,o.subtab]),x.useEffect(()=>{if(de){const ie=de;ce(null),h.deploy(ie),Y(!0)}},[de,h]),x.useEffect(()=>{U.current=!1},[a]);const Ee=()=>{if(!l?.path)return;const ie=fq(l.path,ae,se,ue);jl(ie)},Ie=x.useCallback(()=>{f&&(h.deploy(f.id),Y(!0))},[f,h]),fe=async()=>{f&&await v.mutateAsync(f.id)},be=async()=>{f&&await _.mutateAsync(f.id)},ge=x.useCallback(ie=>{Y(ie),!ie&&!h.isDeploying&&h.logs.length===0&&!h.error&&setTimeout(()=>h.reset(),300)},[h]),Ce=x.useCallback(()=>{l&&($(l.displayName),L(!0),setTimeout(()=>X.current?.select(),0))},[l]),Re=x.useCallback(()=>{L(!1),$("")},[]),xe=x.useCallback(()=>{L(!1),$("")},[]),ye=x.useCallback(ie=>{ie.key==="Enter"?(ie.preventDefault(),Re()):ie.key==="Escape"&&xe()},[Re,xe]),De=x.useCallback((ie,Ke)=>{const lt={};ie!=="settings"&&(lt.tab=ie),ie==="workspace"&&o.file&&(lt.file=o.file),ie==="deploy"&&Ke&&Ke!=="general"&&(lt.subtab=Ke),i({to:"/repositories/$repoId",params:{repoId:a},search:lt,replace:!0})},[i,a,o.file]),ve=x.useCallback(ie=>{De("deploy",ie)},[De]),Oe=x.useCallback(ie=>{i({to:"/repositories/$repoId",params:{repoId:a},search:{tab:"workspace",file:ie??void 0},replace:!0})},[i,a]),Be=x.useCallback(ie=>{if(l?.path&&f?.composeFile){const Ke=f.composeFile;(ie===Ke||ie.endsWith(`/${Ke}`))&&s.invalidateQueries({queryKey:["compose","file",l.path,f.composeFile]})}},[l?.path,f?.composeFile,s]),Te=async()=>{try{await S.mutateAsync({id:a,deleteDirectory:R,deleteApp:D}),i({to:"/repositories"})}catch(ie){rt.error(ie instanceof Error?ie.message:"Failed to delete repository")}},je=()=>{y||E.isPending||(g?.found?E.mutate({repositoryId:a,composeFile:g.file??void 0}):K(!0))};return u?c.jsx("div",{className:"flex h-full items-center justify-center",children:c.jsx(Z,{icon:Nt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}):d||!l?c.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4",children:[c.jsx(Z,{icon:wr,size:48,strokeWidth:1.5,className:"text-destructive"}),c.jsx("p",{className:"text-muted-foreground",children:d?.message??t("detailView.notFound")}),c.jsx(Pr,{to:"/repositories",children:c.jsxs(_e,{variant:"outline",children:[c.jsx(Z,{icon:xf,size:16,strokeWidth:2}),t("detailView.breadcrumb")]})})]}):c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsxs(nl,{value:T,onValueChange:ie=>De(ie),className:"flex h-full flex-col",children:[c.jsxs("div",{className:"film-grain relative shrink-0 border-b border-border",style:{background:"var(--gradient-header)"},children:[c.jsxs("div",{className:"flex items-center justify-between gap-4 px-4 py-2",children:[c.jsxs(sf,{children:[c.jsxs(af,{className:"flex items-center gap-2 sm:hidden",children:[c.jsx(Z,{icon:lW,size:18,strokeWidth:2}),c.jsx("span",{className:"text-sm font-medium",children:T==="deploy"&&k?`${n("detailView.tabs.deploy")} > ${n(`detailView.tabs.${k==="general"?"deployGeneral":k}`)}`:t(T==="settings"?"detailView.tabs.settings":"detailView.tabs.workspace")})]}),c.jsxs(of,{align:"start",children:[c.jsxs(ti,{onClick:()=>De("settings"),className:"gap-2",children:[c.jsx(Z,{icon:VO,size:14,strokeWidth:2}),t("detailView.tabs.settings")]}),c.jsxs(ti,{onClick:()=>De("workspace"),className:"gap-2",children:[c.jsx(Z,{icon:v$,size:14,strokeWidth:2}),t("detailView.tabs.workspace")]}),c.jsxs(ti,{onClick:()=>De("deploy","general"),className:"gap-2",children:[c.jsx(Z,{icon:vb,size:14,strokeWidth:2}),n("detailView.tabs.deploy")," > ",n("detailView.tabs.deployGeneral")]}),ee&&c.jsxs(c.Fragment,{children:[c.jsxs(ti,{onClick:()=>De("deploy","deployments"),className:"gap-2",children:[c.jsx(Z,{icon:vb,size:14,strokeWidth:2}),n("detailView.tabs.deploy")," > ",n("detailView.tabs.deployments")]}),c.jsxs(ti,{onClick:()=>De("deploy","logs"),className:"gap-2",children:[c.jsx(Z,{icon:dW,size:14,strokeWidth:2}),n("detailView.tabs.deploy")," > ",n("detailView.tabs.logs")]}),c.jsxs(ti,{onClick:()=>De("deploy","monitoring"),className:"gap-2",children:[c.jsx(Z,{icon:j_e,size:14,strokeWidth:2}),n("detailView.tabs.deploy")," > ",n("detailView.tabs.monitoring")]})]})]})]}),c.jsxs(rl,{variant:"line",className:"hidden sm:inline-flex",children:[c.jsxs(In,{value:"settings",className:"gap-1.5 px-3 py-1.5",children:[c.jsx(Z,{icon:VO,size:14,strokeWidth:2}),t("detailView.tabs.settings")]}),c.jsxs(In,{value:"workspace",className:"gap-1.5 px-3 py-1.5",children:[c.jsx(Z,{icon:v$,size:14,strokeWidth:2}),t("detailView.tabs.workspace")]}),c.jsxs(In,{value:"deploy",className:"gap-1.5 px-3 py-1.5",children:[c.jsx(Z,{icon:vb,size:14,strokeWidth:2}),n("detailView.tabs.deploy")]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(_e,{variant:"ghost",size:"sm",onClick:()=>z(!0),className:"text-muted-foreground hover:text-foreground",children:[c.jsx(Z,{icon:rD,size:14,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"hidden sm:inline",children:t("newTask")})]}),c.jsx(_e,{variant:"ghost",size:"sm",onClick:Ee,className:"text-muted-foreground hover:text-foreground hidden sm:flex",children:c.jsx(Z,{icon:tSe,size:14,strokeWidth:2,"data-slot":"icon"})}),c.jsx("div",{className:"h-4 w-px bg-border mx-1"}),c.jsx(hO,{worktreePath:l.path}),P?c.jsx(At,{ref:X,type:"text",value:M,onChange:ie=>$(ie.target.value),onBlur:Re,onKeyDown:ye,className:"font-medium text-sm bg-transparent border-b border-primary outline-none px-0.5 min-w-[100px] h-auto py-0",autoFocus:!0}):c.jsx("button",{type:"button",onClick:Ce,className:"font-medium text-sm hover:text-primary transition-colors cursor-pointer",title:"Click to edit",children:l.displayName}),l.projects&&l.projects.length>0&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-muted-foreground/50 text-xs",children:"in"}),c.jsxs(Pr,{to:"/projects/$projectId",params:{projectId:l.projects[0].id},className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[c.jsx(Z,{icon:SE,size:12,strokeWidth:2}),c.jsx("span",{children:l.projects[0].name})]})]}),ee&&c.jsx("div",{className:`h-2 w-2 rounded-full ${f.status==="running"?"bg-green-500":f.status==="building"?"bg-yellow-500":f.status==="failed"?"bg-red-500":"bg-gray-400"}`,title:f.status}),oe&&ee&&c.jsxs(wh,{children:[c.jsx(Eh,{className:"p-1 text-amber-500 hover:text-amber-400 transition-colors",children:c.jsx(Z,{icon:wr,size:14,strokeWidth:2})}),c.jsxs(Ch,{side:"bottom",className:"max-w-xs",children:[c.jsx("p",{className:"font-medium",children:r("apps.manualDnsRequired")}),c.jsx("p",{className:"text-muted-foreground mt-1",children:r("apps.manualDnsRequiredDesc")})]})]}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:()=>A(!0),children:c.jsx(Z,{icon:ks,size:14,strokeWidth:2})})]})]}),T==="deploy"&&ee&&c.jsx("div",{className:"bg-background/80 backdrop-blur-sm px-4 hidden sm:flex items-center border-t border-border",children:c.jsxs("div",{className:"flex gap-1",children:[c.jsx("button",{type:"button",onClick:()=>ve("general"),className:`px-3 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${k==="general"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:n("detailView.tabs.deployGeneral")}),ee&&c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",onClick:()=>ve("deployments"),className:`px-3 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${k==="deployments"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:n("detailView.tabs.deployments")}),c.jsx("button",{type:"button",onClick:()=>ve("logs"),className:`px-3 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${k==="logs"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:n("detailView.tabs.logs")}),c.jsx("button",{type:"button",onClick:()=>ve("monitoring"),className:`px-3 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${k==="monitoring"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:n("detailView.tabs.monitoring")})]})]})})]}),c.jsxs("div",{className:"flex-1 overflow-auto ",children:[c.jsx(jn,{value:"settings",className:"mt-0 h-full",children:c.jsx(qZt,{repository:l})}),c.jsx(jn,{value:"workspace",className:"mt-0 h-full",children:c.jsx(UZt,{repoPath:l.path,repoDisplayName:l.displayName,activeTab:T,file:o.file,onFileChange:Oe,onFileSaved:Be})}),c.jsx(jn,{value:"deploy",className:"mt-0 h-full",children:c.jsx(hp,{className:"h-full",children:c.jsx("div",{className:"p-4 mx-auto max-w-4xl",children:m&&!m.ready?c.jsx(HZt,{}):k==="general"?f?c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[c.jsx(GZt,{app:f,onDeploy:Ie,onStop:fe,onCancelDeploy:be,isBuilding:J,isRunning:te??!1,isStopPending:v.isPending,isCancelPending:_.isPending,deployStore:h}),c.jsx(KZt,{app:f,onDeploy:Ie})]}),c.jsx(YZt,{app:f}),c.jsx(XZt,{app:f,repoPath:l.path})]}):c.jsx("div",{className:"flex min-h-[calc(100vh-220px)] items-center justify-center",children:c.jsxs("div",{className:"text-center",children:[c.jsx(Z,{icon:vb,size:48,strokeWidth:1.5,className:"mx-auto text-muted-foreground mb-4"}),c.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:n("detailView.app.configureDeploymentDescription")}),c.jsxs(_e,{onClick:je,disabled:y||E.isPending,children:[c.jsx(Z,{icon:K_e,size:16,strokeWidth:2,"data-slot":"icon"}),E.isPending?n("detailView.app.configuring"):n("detailView.app.configureDeployment")]})]})}):ee&&k==="deployments"?c.jsx(yJt,{appId:f.id,deployStore:h,onViewStreamingLogs:()=>Y(!0)}):ee&&k==="logs"?c.jsx(_Jt,{appId:f.id,services:f.services}):ee&&k==="monitoring"?c.jsx(CJt,{appId:f.id,repoDisplayName:l.displayName}):null})})})]})]}),f&&c.jsx(mJt,{appId:f.id,open:W,onOpenChange:ge,deployStore:h}),c.jsx(XW,{open:F,onOpenChange:z,defaultRepository:{id:l.id,path:l.path,displayName:l.displayName,startupScript:l.startupScript,copyFiles:l.copyFiles,claudeOptions:l.claudeOptions,opencodeOptions:l.opencodeOptions,opencodeModel:l.opencodeModel,defaultAgent:l.defaultAgent},showTrigger:!1}),c.jsx(ql,{open:w,onOpenChange:A,children:c.jsxs(Gl,{children:[c.jsxs(Kl,{children:[c.jsx(Xl,{children:t("delete.title")}),c.jsx(Ql,{children:t("delete.description",{name:l.displayName})})]}),c.jsxs("div",{className:"space-y-3 py-2",children:[c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsx(ni,{id:"deleteDirectory",checked:R,onCheckedChange:ie=>I(ie===!0)}),c.jsx("label",{htmlFor:"deleteDirectory",className:"text-sm",children:t("delete.alsoDeleteDirectory")})]}),f&&c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsx(ni,{id:"deleteApp",checked:D,onCheckedChange:ie=>j(ie===!0)}),c.jsx("label",{htmlFor:"deleteApp",className:"text-sm",children:n("delete.alsoDeleteApp")})]})]}),c.jsxs(Yl,{children:[c.jsx(Zl,{children:r("apps.cancel")}),c.jsx(cg,{onClick:Te,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:S.isPending?t("delete.deleting"):t("delete.button")})]})]})}),c.jsx(Ya,{open:q,onOpenChange:K,children:c.jsxs(Xa,{children:[c.jsxs(Lo,{children:[c.jsx(Mo,{children:t("createAppDialog.title")}),c.jsx(eg,{children:t("createAppDialog.description")})]}),c.jsx("p",{className:"text-sm",children:t("createAppDialog.instructions")}),c.jsx("div",{className:"flex justify-end",children:c.jsx(_e,{onClick:()=>K(!1),children:t("createAppDialog.close")})})]})})]})});function TJt(){return c.jsx(Xst,{children:c.jsx(kJt,{})})}const AJt=xa("/repositories/$repoId")({validateSearch:e=>({tab:["settings","workspace","deploy"].includes(e.tab)?e.tab:void 0,subtab:["general","deployments","logs","monitoring"].includes(e.subtab)?e.subtab:void 0,action:e.action==="deploy"?"deploy":void 0,file:typeof e.file=="string"?e.file:void 0}),component:TJt});function NJt(e,t){const n=new Map;for(const r of t){const i=e.filter(s=>s.repoPath===r.path||s.repositoryId===r.id);n.set(r.id,i)}return n}function OJt({open:e,onOpenChange:t,projectId:n,projectName:r}){const{data:i}=Oy(),{data:s}=Mc(),a=Hwe(),[o,l]=x.useState(""),[u,d]=x.useState(new Set),[f,h]=x.useState(!1),m=x.useMemo(()=>{if(!i)return[];const w=new Map;if(s)for(const A of s)for(const R of A.repositories)w.set(R.id,{projectId:A.id,projectName:A.name});return i.map(A=>{const R=w.get(A.id);return{id:A.id,displayName:A.displayName,path:A.path,projectId:R?.projectId??null,projectName:R?.projectName??null}})},[i,s]),g=x.useMemo(()=>{if(!o.trim())return m;const w=o.toLowerCase();return m.filter(A=>A.displayName.toLowerCase().includes(w)||A.path.toLowerCase().includes(w))},[m,o]),v=g.filter(w=>u.has(w.id)).filter(w=>w.projectId&&w.projectId!==n),_=w=>{d(A=>{const R=new Set(A);return R.has(w)?R.delete(w):R.add(w),R})},S=()=>{const w=g.filter(A=>A.projectId!==n);d(new Set(w.map(A=>A.id)))},E=()=>{d(new Set)},T=async()=>{if(u.size===0)return;h(!0);let w=0,A=0;for(const R of u){const I=m.find(D=>D.id===R);if(I&&I.projectId!==n)try{await a.mutateAsync({projectId:n,repositoryId:R,moveFromProject:I.projectId!==null}),w++}catch{A++}}h(!1),A>0?rt.error(`Linked ${w} repositories, ${A} failed`):(rt.success(`Linked ${w} ${w===1?"repository":"repositories"}`),t(!1))},k=w=>{w&&(l(""),d(new Set)),t(w)};return c.jsx(Ya,{open:e,onOpenChange:k,children:c.jsxs(Xa,{className:"sm:max-w-xl max-h-[80dvh] flex flex-col overflow-hidden",children:[c.jsx(Lo,{className:"shrink-0",children:c.jsxs(Mo,{children:['Link Repositories to "',r,'"']})}),c.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-h-0 space-y-4",children:[c.jsxs("div",{className:"relative shrink-0",children:[c.jsx(Z,{icon:cp,size:14,strokeWidth:2,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),c.jsx(At,{value:o,onChange:w=>l(w.target.value),placeholder:"Search repositories...",className:"pl-9"})]}),c.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 rounded-md border",children:g.length===0?c.jsx("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:i?.length===0?"No repositories found in Fulcrum":"No repositories match your search"}):g.map(w=>{const A=w.projectId===n,R=w.projectId&&w.projectId!==n,I=u.has(w.id);return c.jsxs("div",{className:`flex items-start gap-3 px-3 py-3 border-b last:border-b-0 transition-colors ${A?"bg-muted/30 opacity-60":"hover:bg-muted/50 cursor-pointer"}`,onClick:()=>!A&&_(w.id),children:[c.jsx(ni,{checked:I,disabled:A,className:"mt-0.5 pointer-events-none"}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"font-medium truncate",children:w.displayName}),I&&R&&c.jsx(ir,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-amber-500/10 text-amber-600",children:"Will move"}),A&&c.jsx(ir,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"Already here"})]}),c.jsxs("div",{className:"flex items-center gap-1.5 mt-1 text-xs text-muted-foreground",children:[c.jsx(Z,{icon:Zs,size:12,strokeWidth:2,className:"shrink-0"}),c.jsx("span",{className:"truncate font-mono",children:w.path})]}),R&&c.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:["Currently in: ",w.projectName]}),!w.projectId&&c.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"Not in any project"})]})]},w.id)})}),v.length>0&&c.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-amber-500/10 px-3 py-2 text-xs text-amber-600 shrink-0",children:[c.jsx(Z,{icon:wr,size:14,strokeWidth:2,className:"mt-0.5 shrink-0"}),c.jsxs("span",{children:[v.length," ",v.length===1?"repository":"repositories"," will be moved from"," ",v.length===1?"another project":"other projects"]})]}),c.jsxs("div",{className:"flex items-center justify-between shrink-0 pt-2",children:[c.jsxs("div",{className:"flex gap-2 text-xs",children:[c.jsx("button",{type:"button",className:"text-primary hover:underline",onClick:S,children:"Select all"}),c.jsx("span",{className:"text-muted-foreground",children:"/"}),c.jsx("button",{type:"button",className:"text-primary hover:underline",onClick:E,children:"Clear"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(_e,{variant:"outline",onClick:()=>t(!1),disabled:f,children:"Cancel"}),c.jsx(_e,{onClick:T,disabled:u.size===0||f,children:f?c.jsxs(c.Fragment,{children:[c.jsx(Z,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin"}),"Linking..."]}):`Link ${u.size} ${u.size===1?"Repository":"Repositories"}`})]})]})]})]})})}function RJt({className:e,...t}){return c.jsx(VVe,{"data-slot":"radio-group",className:Ae("grid gap-3 w-full",e),...t})}function B0e({className:e,...t}){return c.jsx(zVe,{"data-slot":"radio-group-item",className:Ae("border-input text-primary dark:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/30 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 data-checked:bg-primary data-checked:border-primary flex size-4 rounded-full transition-none focus-visible:ring-[2px] aria-invalid:ring-[2px] group/radio-group-item peer relative aspect-square shrink-0 border outline-none after:absolute after:-inset-x-3 after:-inset-y-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:c.jsx(UVe,{"data-slot":"radio-group-indicator",className:"group-aria-invalid/radio-group-item:text-destructive flex size-4 items-center justify-center text-white",children:c.jsx(Z,{icon:q$e,strokeWidth:2,className:"absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 fill-current"})})})}function IJt({open:e,onOpenChange:t,projectId:n,repository:r}){const i=Nqe(),[s,a]=x.useState("unlink"),o=async()=>{if(r)try{await i.mutateAsync({projectId:n,repositoryId:r.id,deleteRecord:s==="delete"}),rt.success(s==="delete"?"Repository removed and deleted":"Repository unlinked from project"),t(!1)}catch(l){rt.error("Failed to remove repository",{description:l instanceof Error?l.message:"Unknown error"})}};return c.jsx(ql,{open:e,onOpenChange:t,children:c.jsxs(Gl,{children:[c.jsxs(Kl,{children:[c.jsx(Xl,{children:"Remove Repository"}),c.jsxs(Ql,{children:['Remove "',r?.displayName,'" from this project?']})]}),c.jsx("div",{className:"py-4",children:c.jsxs(RJt,{value:s,onValueChange:l=>a(l),className:"space-y-3",children:[c.jsxs("div",{className:"flex items-start space-x-3",children:[c.jsx(B0e,{value:"unlink",id:"unlink",className:"mt-1"}),c.jsxs("div",{className:"space-y-1",children:[c.jsx(Ur,{htmlFor:"unlink",className:"font-medium cursor-pointer",children:"Just unlink from project"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Repository record will be kept (can be added to another project later)"})]})]}),c.jsxs("div",{className:"flex items-start space-x-3",children:[c.jsx(B0e,{value:"delete",id:"delete",className:"mt-1"}),c.jsxs("div",{className:"space-y-1",children:[c.jsx(Ur,{htmlFor:"delete",className:"font-medium cursor-pointer",children:"Delete repository record"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Removes from project AND deletes the repository record (does not delete files on disk)"})]})]})]})}),c.jsxs(Yl,{children:[c.jsx(Zl,{disabled:i.isPending,children:"Cancel"}),c.jsx(_e,{variant:"destructive",onClick:o,disabled:i.isPending,children:i.isPending?c.jsxs(c.Fragment,{children:[c.jsx(Z,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin"}),"Removing..."]}):"Remove"})]})]})})}const vj="";function DJt(e){return Jt({queryKey:["project-attachments",e],queryFn:async()=>{const t=await fetch(`${vj}/api/projects/${e}/attachments`);if(!t.ok)throw new Error("Failed to fetch attachments");return t.json()},enabled:!!e})}function jJt(){const e=It();return wt({mutationFn:async({projectId:t,file:n})=>{const r=new FormData;r.append("file",n);const i=await fetch(`${vj}/api/projects/${t}/attachments`,{method:"POST",body:r});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.error||"Failed to upload attachment")}return i.json()},onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["project-attachments",n.projectId]}),e.invalidateQueries({queryKey:["projects"]}),e.invalidateQueries({queryKey:["project",n.projectId]})}})}function PJt(){const e=It();return wt({mutationFn:async({projectId:t,attachmentId:n})=>{const r=await fetch(`${vj}/api/projects/${t}/attachments/${n}`,{method:"DELETE"});if(!r.ok)throw new Error("Failed to delete attachment");return r.json()},onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["project-attachments",n.projectId]}),e.invalidateQueries({queryKey:["projects"]}),e.invalidateQueries({queryKey:["project",n.projectId]})}})}function LJt(e,t){return`${vj}/api/projects/${e}/attachments/${t}`}function MJt({project:e}){const{t}=Ot("projects"),n=Ot("repositories").t,r=Vwe(),[i,s]=x.useState(!1),[a,o]=x.useState(null),[l,u]=x.useState({}),[d,f]=x.useState({}),[h,m]=x.useState(null),[g,y]=x.useState(""),[v,_]=x.useState(!1);x.useEffect(()=>{e&&(o(e.defaultAgent??null),u(e.claudeOptions??{}),f(e.opencodeOptions??{}),m(e.opencodeModel??null),y(e.startupScript??""),_(!1))},[e]),x.useEffect(()=>{if(e){const T=a!==(e.defaultAgent??null)||JSON.stringify(l)!==JSON.stringify(e.claudeOptions??{})||JSON.stringify(d)!==JSON.stringify(e.opencodeOptions??{})||h!==(e.opencodeModel??null)||g!==(e.startupScript??"");_(T)}},[a,l,d,h,g,e]);const S=()=>{e&&r.mutate({id:e.id,updates:{defaultAgent:a,claudeOptions:Object.keys(l).length>0?l:null,opencodeOptions:Object.keys(d).length>0?d:null,opencodeModel:h,startupScript:g.trim()||null}},{onSuccess:()=>{rt.success(t("detailView.save")),_(!1)},onError:T=>{rt.error(n("detailView.failedToSave"),{description:T instanceof Error?T.message:"Unknown error"})}})},E=()=>{const T=[];a?T.push(`${t("agentSettings.summaryDefault")}: ${Io[a]}`):T.push(`${t("agentSettings.summaryDefault")}: ${t("agentSettings.inherit")}`);const k=Object.keys(l).length;k>0&&T.push(t("agentSettings.summaryClaudeOptions",{count:k}));const w=Object.keys(d).length;return w>0&&T.push(t("agentSettings.summaryOpencodeOptions",{count:w})),h&&T.push(`${t("agentSettings.summaryModel")}: ${h.split("/").pop()}`),T.join(" · ")};return c.jsxs(ug,{open:i,onOpenChange:s,className:"rounded-lg border bg-card",children:[c.jsxs("div",{className:"flex items-center justify-between p-4",children:[c.jsxs(dg,{className:"flex items-center gap-2 group",children:[c.jsx(Z,{icon:i?Ts:Bl,size:14,className:"text-muted-foreground"}),c.jsx("h2",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider group-hover:text-foreground transition-colors",children:t("detailView.general.agentTitle")}),!i&&c.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:E()})]}),i&&v&&c.jsxs(_e,{size:"sm",onClick:S,disabled:r.isPending,children:[c.jsx(Z,{icon:hr,size:14,strokeWidth:2,"data-slot":"icon"}),r.isPending?n("detailView.saving"):n("detailView.save")]})]}),c.jsx(fg,{children:c.jsxs("div",{className:"px-4 pb-4",children:[c.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:t("agentSettings.description")}),c.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[c.jsxs(qh,{children:[c.jsxs($n,{children:[c.jsx(zn,{children:t("detailView.general.defaultAgent")}),c.jsxs(Qr,{value:a??"inherit",onValueChange:T=>o(T==="inherit"?null:T),children:[c.jsx(Jr,{className:"w-full",children:c.jsx(Zr,{})}),c.jsxs(ei,{alignItemWithTrigger:!1,children:[c.jsx(jt,{value:"inherit",children:t("agentSettings.useGlobalDefault")}),Object.keys(Io).map(T=>c.jsx(jt,{value:T,children:Io[T]},T))]})]}),c.jsx(Pi,{children:n("detailView.settings.defaultAgentDescription")})]}),c.jsxs($n,{children:[c.jsx(zn,{children:t("agentSettings.startupScript")}),c.jsx(Pi,{className:"mb-2",children:t("agentSettings.startupScriptDescription")}),c.jsx(Oc,{value:g,onChange:T=>y(T.target.value),placeholder:"export ENV_VAR=value",className:"font-mono text-xs min-h-[60px]",rows:2})]}),c.jsxs($n,{children:[c.jsx(zn,{children:t("detailView.general.claudeOptions")}),c.jsx(Pi,{className:"mb-2",children:n("detailView.settings.claudeOptionsDescription")}),c.jsx(l3,{value:l,onChange:u})]})]}),c.jsxs(qh,{children:[c.jsxs($n,{children:[c.jsx(zn,{children:t("detailView.general.opencodeModel")}),c.jsx(Bb,{value:h,onChange:m,placeholder:n("detailView.settings.opencodeModelPlaceholder")}),c.jsx(Pi,{children:n("detailView.settings.opencodeModelDescription")})]}),c.jsxs($n,{children:[c.jsx(zn,{children:t("detailView.general.opencodeOptions")}),c.jsx(Pi,{className:"mb-2",children:n("detailView.settings.opencodeOptionsDescription")}),c.jsx(l3,{value:d,onChange:f})]})]})]})]})})]})}const Xje=xa("/projects/$projectId")({component:VJt}),FJt={TO_DO:"bg-muted-foreground/40",IN_PROGRESS:"bg-blue-500",IN_REVIEW:"bg-amber-500",DONE:"bg-green-500/40",CANCELED:"bg-muted-foreground/20"};function BJt({tasks:e}){const{t}=Ot("projects"),n=e.filter(s=>s.status!=="DONE"&&s.status!=="CANCELED").slice(0,8),r=e.filter(s=>s.status!=="DONE"&&s.status!=="CANCELED").length,i=e.filter(s=>s.status==="DONE"||s.status==="CANCELED").length;return c.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[c.jsx("div",{className:"flex items-center gap-0.5",children:n.length>0?n.map(s=>c.jsx("div",{className:Ae("w-1.5 h-1.5 rounded-full",FJt[s.status]),title:`${s.title} (${s.status})`},s.id)):Array.from({length:3}).map((s,a)=>c.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-muted"},a))}),c.jsxs("span",{children:[t("repoCard.activeCount",{count:r}),i>0&&` · ${t("repoCard.doneCount",{count:i})}`]})]})}function $Jt({repository:e,tasks:t,onRemove:n,onNewTask:r}){const i=Ni(),s=()=>{i({to:"/repositories/$repoId",params:{repoId:e.id},search:{tab:"settings"}})};return c.jsx(xi,{className:"group transition-colors hover:border-foreground/20 cursor-pointer",onClick:s,children:c.jsxs(Ms,{className:"py-3 px-4",children:[c.jsxs("div",{className:"flex items-start justify-between gap-2",children:[c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("h3",{className:"font-medium truncate group-hover:text-primary transition-colors",children:e.displayName}),c.jsx("div",{className:"flex items-center gap-1.5 mt-0.5 text-xs text-muted-foreground",children:c.jsx("span",{className:"truncate font-mono",children:e.path})})]}),c.jsx(_e,{variant:"ghost",size:"sm",onClick:a=>{a.stopPropagation(),n()},className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-opacity",children:c.jsx(Z,{icon:Tn,size:14,strokeWidth:2})})]}),c.jsx("div",{className:"mt-2",children:c.jsx(BJt,{tasks:t})}),c.jsxs("div",{className:"mt-3 flex items-center gap-1",children:[c.jsxs(wh,{children:[c.jsxs(Eh,{onClick:a=>{a.stopPropagation(),r()},className:"inline-flex items-center justify-center gap-1 whitespace-nowrap text-sm font-medium h-7 px-2 rounded-md border bg-background hover:bg-accent hover:text-accent-foreground text-muted-foreground",children:[c.jsx(Z,{icon:rD,size:14,strokeWidth:2}),c.jsx("span",{children:"Task"})]}),c.jsx(Ch,{children:"New Task"})]}),c.jsxs(wh,{children:[c.jsx(Eh,{onClick:a=>{a.stopPropagation(),i({to:"/repositories/$repoId",params:{repoId:e.id},search:{tab:"workspace"}})},className:"inline-flex items-center justify-center whitespace-nowrap text-sm font-medium h-7 px-2 rounded-md border bg-background hover:bg-accent hover:text-accent-foreground text-muted-foreground",children:c.jsx(Z,{icon:v$,size:14,strokeWidth:2})}),c.jsx(Ch,{children:"Open Workspace"})]}),c.jsxs(wh,{children:[c.jsx(Eh,{onClick:a=>{a.stopPropagation(),i({to:"/repositories/$repoId",params:{repoId:e.id},search:{tab:"deploy",action:"deploy"}})},className:"inline-flex items-center justify-center whitespace-nowrap text-sm font-medium h-7 px-2 rounded-md border bg-background hover:bg-accent hover:text-accent-foreground text-muted-foreground",children:c.jsx(Z,{icon:vb,size:14,strokeWidth:2})}),c.jsx(Ch,{children:"Deploy"})]}),c.jsxs(wh,{children:[c.jsx(Eh,{onClick:a=>{a.stopPropagation(),i({to:"/repositories/$repoId",params:{repoId:e.id},search:{tab:"settings"}})},className:"inline-flex items-center justify-center whitespace-nowrap text-sm font-medium h-7 px-2 rounded-md border bg-background hover:bg-accent hover:text-accent-foreground text-muted-foreground",children:c.jsx(Z,{icon:VO,size:14,strokeWidth:2})}),c.jsx(Ch,{children:"Settings"})]})]})]})})}function zJt({projectId:e,tags:t}){const{t:n}=Ot("projects"),[r,i]=x.useState(!1),[s,a]=x.useState(""),[o,l]=x.useState(!1),u=x.useRef(null),d=x.useRef(null),{data:f=[]}=NW(s),h=UWe(),m=HWe(),g=f.filter(E=>!t.some(T=>T.id===E.id)),y=f.find(E=>E.name.toLowerCase()===s.toLowerCase()),v=s.trim()&&!y;x.useEffect(()=>{const E=T=>{d.current&&!d.current.contains(T.target)&&(l(!1),i(!1),a(""))};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]);const _=async E=>{try{typeof E=="string"?await h.mutateAsync({projectId:e,name:E}):await h.mutateAsync({projectId:e,tagId:E.id}),a(""),l(!1),i(!1)}catch{}},S=E=>{E.key==="Enter"&&s.trim()?(E.preventDefault(),y&&!t.some(T=>T.id===y.id)?_(y):v&&_(s.trim())):E.key==="Escape"&&(l(!1),i(!1),a(""))};return c.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",ref:d,children:[t.map(E=>c.jsxs(ir,{variant:"default",className:"text-xs group/tag",children:[E.name,c.jsx("button",{onClick:()=>m.mutate({projectId:e,tagId:E.id}),className:"ml-1 opacity-0 group-hover/tag:opacity-100 hover:text-destructive transition-opacity",children:c.jsx(Z,{icon:Tn,size:10})})]},E.id)),r?c.jsxs("div",{className:"relative",children:[c.jsx(At,{ref:u,value:s,onChange:E=>{a(E.target.value),l(!0)},onFocus:()=>l(!0),onKeyDown:S,placeholder:n("detail.addTag"),className:"h-6 w-24 text-xs",autoFocus:!0}),o&&(s||g.length>0)&&c.jsxs("div",{className:"absolute top-full left-0 mt-1 w-48 bg-popover border rounded-md shadow-lg z-50 max-h-32 overflow-y-auto",children:[g.slice(0,5).map(E=>c.jsx("button",{className:"w-full px-2 py-1.5 text-left text-xs hover:bg-accent",onClick:()=>_(E),children:E.name},E.id)),v&&c.jsxs("button",{className:"w-full px-2 py-1.5 text-left text-xs hover:bg-accent flex items-center gap-1 border-t",onClick:()=>_(s.trim()),children:[c.jsx(Z,{icon:Ic,size:12}),n("detail.createTag",{tag:s.trim()})]})]})]}):c.jsx("button",{onClick:()=>{i(!0),setTimeout(()=>u.current?.focus(),0)},className:"h-5 w-5 rounded border border-dashed border-muted-foreground/50 flex items-center justify-center text-muted-foreground hover:text-foreground hover:border-foreground transition-colors",children:c.jsx(Z,{icon:Ic,size:12})})]})}function UJt({projectId:e,links:t}){const{t:n}=Ot("projects"),[r,i]=x.useState(!1),[s,a]=x.useState(""),[o,l]=x.useState(""),u=Dqe(),d=jqe(),f=()=>{const m=s.trim();if(m){try{new URL(m)}catch{rt.error(n("detail.errors.invalidUrl",{defaultValue:"Invalid URL"}),{description:n("detail.errors.invalidUrlDescription",{defaultValue:"Please enter a valid URL including the scheme (e.g., https://)"})});return}u.mutate({projectId:e,url:m,label:o.trim()||void 0},{onSuccess:()=>{a(""),l(""),i(!1)}})}},h=m=>{m.key==="Enter"?(m.preventDefault(),f()):m.key==="Escape"&&(i(!1),a(""),l(""))};return c.jsxs("div",{className:"space-y-2",children:[c.jsx("h3",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:n("detail.sections.links")}),c.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.map(m=>c.jsxs("div",{className:"group/link flex items-center",children:[c.jsxs("button",{onClick:()=>jl(m.url),className:"flex items-center gap-1.5 text-xs text-primary hover:underline",children:[c.jsx(Z,{icon:Ay,size:12}),c.jsx("span",{className:"max-w-32 truncate",children:m.label||m.url})]}),c.jsx("button",{onClick:()=>d.mutate({projectId:e,linkId:m.id}),className:"ml-1 opacity-0 group-hover/link:opacity-100 text-muted-foreground hover:text-destructive transition-opacity",children:c.jsx(Z,{icon:Tn,size:10})})]},m.id)),r?c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(At,{type:"url",value:s,onChange:m=>a(m.target.value),onKeyDown:h,placeholder:n("detail.urlPlaceholder"),className:"h-6 w-32 text-xs",autoFocus:!0}),c.jsx(At,{type:"text",value:o,onChange:m=>l(m.target.value),onKeyDown:h,placeholder:n("detail.labelPlaceholder"),className:"h-6 w-20 text-xs"}),c.jsx(_e,{size:"sm",className:"h-6 px-2 text-xs",onClick:f,children:n("detail.add")}),c.jsx(_e,{variant:"ghost",size:"sm",className:"h-6 px-1",onClick:()=>{i(!1),a(""),l("")},children:c.jsx(Z,{icon:Tn,size:12})})]}):c.jsxs("button",{onClick:()=>i(!0),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[c.jsx(Z,{icon:Ic,size:12}),c.jsx("span",{children:n("detail.add")})]})]})]})}function HJt({projectId:e}){const{t}=Ot("projects"),{data:n=[],isLoading:r}=DJt(e),i=jJt(),s=PJt(),a=x.useRef(null),[o,l]=x.useState(!1),u=x.useCallback(async y=>{if(!(!y||y.length===0))for(const v of Array.from(y))try{await i.mutateAsync({projectId:e,file:v})}catch{}},[e,i]),d=x.useCallback(y=>{y.preventDefault(),y.stopPropagation(),l(!0)},[]),f=x.useCallback(y=>{y.preventDefault(),y.stopPropagation(),l(!1)},[]),h=x.useCallback(y=>{y.preventDefault(),y.stopPropagation(),l(!1),u(y.dataTransfer.files)},[u]),m=y=>y==="application/pdf"?Y_e:y.startsWith("image/")?U_e:$_e,g=y=>y<1024?`${y}B`:y<1024*1024?`${(y/1024).toFixed(0)}KB`:`${(y/1024/1024).toFixed(1)}MB`;return r?c.jsxs("div",{className:"space-y-2",children:[c.jsx("h3",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:t("detail.sections.attachments")}),c.jsx("span",{className:"text-xs text-muted-foreground",children:t("detail.loading")})]}):c.jsxs("div",{className:"space-y-2",children:[c.jsx("h3",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:t("detail.sections.attachments")}),c.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.map(y=>{const v=m(y.mimeType);return c.jsxs("div",{className:"group/file flex items-center gap-1 text-xs",children:[c.jsxs("button",{onClick:()=>window.open(LJt(e,y.id),"_blank"),className:"flex items-center gap-1 text-muted-foreground hover:text-foreground",children:[c.jsx(Z,{icon:v,size:12}),c.jsx("span",{className:"max-w-24 truncate",children:y.filename}),c.jsxs("span",{className:"text-muted-foreground/70",children:["(",g(y.size),")"]})]}),c.jsx("button",{onClick:()=>s.mutate({projectId:e,attachmentId:y.id}),className:"opacity-0 group-hover/file:opacity-100 text-muted-foreground hover:text-destructive transition-opacity",children:c.jsx(Z,{icon:Tn,size:10})})]},y.id)}),c.jsx("input",{ref:a,type:"file",multiple:!0,className:"hidden",onChange:y=>u(y.target.files)}),c.jsxs("button",{onClick:()=>a.current?.click(),onDragOver:d,onDragLeave:f,onDrop:h,className:Ae("flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors px-2 py-1 border border-dashed rounded",o&&"border-primary bg-primary/5",i.isPending&&"opacity-50"),children:[c.jsx(Z,{icon:i.isPending?Nt:J_e,size:12,className:i.isPending?"animate-spin":""}),c.jsx("span",{children:i.isPending?t("detail.uploading"):t("detail.dropOrClickShort")})]})]})]})}function VJt(){const{t:e}=Ot("projects"),{projectId:t}=Xje.useParams(),n=Ls({select:fe=>fe.location}),r=Ni(),{data:i,isLoading:s,error:a}=Aqe(t),{data:o=[]}=cl(),l=Wwe(),u=Oqe(),d=Vwe(),[f,h]=x.useState(!1),[m,g]=x.useState(!1),[y,v]=x.useState(null),[_,S]=x.useState(!1),[E,T]=x.useState(""),k=x.useRef(null),[w,A]=x.useState(!1),[R,I]=x.useState(""),[D,j]=x.useState(!1),[F,z]=x.useState(!1),[P,L]=x.useState(""),M=x.useRef(null),[$,W]=x.useState(!1),[Y,q]=x.useState(!1),[K,X]=x.useState({open:!1,repository:null});x.useEffect(()=>{new URLSearchParams(n.search).get("addRepo")==="true"&&!$&&(W(!0),r({to:"/projects/$projectId",params:{projectId:t},replace:!0}))},[n.search,$,r,t]),x.useEffect(()=>{t&&u.mutate(t)},[t]);const U=x.useMemo(()=>NJt(o,i?.repositories??[]),[o,i?.repositories]),J=x.useMemo(()=>o.filter(fe=>fe.status!=="DONE"&&fe.status!=="CANCELED"&&(fe.projectId===t||i?.repositories.some(be=>be.path===fe.repoPath))),[o,t,i?.repositories]),te=x.useCallback(()=>{i&&(T(i.name),S(!0),setTimeout(()=>k.current?.select(),0))},[i]),ee=x.useCallback(()=>{const fe=E.trim();fe&&fe!==i?.name&&d.mutate({id:t,updates:{name:fe}}),S(!1)},[E,i?.name,t,d]),oe=x.useCallback(()=>{S(!1),T("")},[]),ae=x.useCallback(fe=>{fe.key==="Enter"?(fe.preventDefault(),ee()):fe.key==="Escape"&&oe()},[ee,oe]),se=x.useCallback(()=>{i&&(I(i.description||""),A(!0))},[i]),ue=x.useCallback(()=>{const fe=R.trim()||null;fe!==(i?.description||null)&&d.mutate({id:t,updates:{description:fe}}),A(!1)},[R,i?.description,t,d]),de=x.useCallback(()=>{i&&(L(i.notes||""),z(!0),j(!0),setTimeout(()=>M.current?.focus(),0))},[i]),ce=x.useCallback(()=>{const fe=P.trim()||null;fe!==(i?.notes||null)&&d.mutate({id:t,updates:{notes:fe}}),z(!1)},[P,i?.notes,t,d]),Ee=x.useCallback(()=>{z(!1),L("")},[]),Ie=async()=>{g(!0);try{await l.mutateAsync({id:t,deleteDirectory:!1,deleteApp:!1}),rt.success(e("delete.success")),h(!1),r({to:"/projects"})}catch(fe){rt.error(e("delete.error"),{description:fe instanceof Error?fe.message:"Unknown error"}),g(!1)}};return s?c.jsx("div",{className:"flex h-full items-center justify-center",children:c.jsx(Z,{icon:Nt,size:24,className:"animate-spin text-muted-foreground"})}):a||!i?c.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4",children:[c.jsx(Z,{icon:wr,size:24,className:"text-destructive"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:e("notFound")}),c.jsx(Pr,{to:"/projects",children:c.jsx(_e,{variant:"outline",size:"sm",children:e("backToProjects")})})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsxs("div",{className:"film-grain relative flex shrink-0 items-center justify-between gap-4 border-b border-border px-4 py-2",style:{background:"var(--gradient-header)"},children:[_?c.jsx(At,{ref:k,type:"text",value:E,onChange:fe=>T(fe.target.value),onBlur:ee,onKeyDown:ae,className:"font-medium text-sm bg-transparent border-b border-primary outline-none px-0.5 w-auto max-w-[200px] h-auto py-0",autoFocus:!0}):c.jsx("button",{type:"button",onClick:te,className:"font-medium text-sm hover:text-primary transition-colors cursor-pointer",title:e("detail.clickToEdit"),children:i.name}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsxs(_e,{variant:"ghost",size:"sm",onClick:()=>i.repositories.length>0&&v(i.repositories[0]),disabled:i.repositories.length===0,className:"text-muted-foreground hover:text-foreground",children:[c.jsx(Z,{icon:rD,size:14,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"hidden sm:inline",children:e("detail.actions.task")})]}),c.jsxs(_e,{variant:"ghost",size:"sm",onClick:()=>q(!0),className:"text-muted-foreground hover:text-foreground",children:[c.jsx(Z,{icon:b$,size:14,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"hidden sm:inline",children:e("detail.actions.repo")})]}),c.jsxs(_e,{variant:"ghost",size:"sm",onClick:()=>W(!0),className:"text-muted-foreground hover:text-foreground",children:[c.jsx(Z,{icon:g$,size:14,strokeWidth:2,"data-slot":"icon"}),c.jsx("span",{className:"hidden sm:inline",children:e("detail.actions.link")})]})]}),c.jsx("div",{className:"flex items-center gap-2",children:c.jsx(_e,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:()=>h(!0),children:c.jsx(Z,{icon:ks,size:14,strokeWidth:2})})})]}),c.jsx("div",{className:"flex-1 overflow-auto p-6",children:c.jsxs("div",{className:"mx-auto max-w-5xl space-y-6 pb-6",children:[w?c.jsxs("div",{className:"flex items-start gap-2",children:[c.jsx(Oc,{value:R,onChange:fe=>I(fe.target.value),placeholder:e("detail.addDescription"),className:"min-h-[60px] text-sm flex-1",autoFocus:!0,onKeyDown:fe=>{fe.key==="Enter"&&fe.metaKey?ue():fe.key==="Escape"&&A(!1)}}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx(_e,{size:"sm",className:"h-7",onClick:ue,children:e("detail.save")}),c.jsx(_e,{variant:"ghost",size:"sm",className:"h-7",onClick:()=>A(!1),children:e("detail.cancel")})]})]}):i.description?c.jsx("p",{className:"text-sm text-muted-foreground cursor-pointer hover:text-foreground transition-colors",onClick:se,title:e("detail.clickToEdit"),children:i.description}):null,c.jsxs("section",{className:"rounded-lg border p-4 space-y-3 bg-card",children:[c.jsx("h2",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:e("detail.sections.repositories")}),i.repositories.length===0?c.jsx(xi,{className:"border-dashed",children:c.jsxs(Ms,{className:"py-6 text-center text-muted-foreground",children:[c.jsx("p",{className:"text-sm",children:e("detail.noRepositories")}),c.jsxs("div",{className:"mt-3 flex justify-center gap-2",children:[c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>q(!0),children:[c.jsx(Z,{icon:b$,size:14,"data-slot":"icon"}),e("addRepo")]}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>W(!0),children:[c.jsx(Z,{icon:g$,size:14,"data-slot":"icon"}),e("detail.linkExisting")]})]})]})}):c.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3",children:i.repositories.map(fe=>c.jsx($Jt,{repository:fe,tasks:U.get(fe.id)||[],onRemove:()=>X({open:!0,repository:fe}),onNewTask:()=>v(fe)},fe.id))})]}),c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[c.jsx("div",{className:"film-grain relative rounded-lg border p-4",style:{background:"var(--gradient-card)"},children:c.jsx(UJt,{projectId:t,links:i.links||[]})}),c.jsx("div",{className:"film-grain relative rounded-lg border p-4",style:{background:"var(--gradient-card)"},children:c.jsx(HJt,{projectId:t})})]}),c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[c.jsxs("div",{className:"film-grain relative rounded-lg border p-4 space-y-2",style:{background:"var(--gradient-card)"},children:[c.jsx("h3",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:e("detail.sections.tags")}),c.jsx(zJt,{projectId:t,tags:i.tags||[]})]}),c.jsxs(ug,{open:D,onOpenChange:j,className:"film-grain relative rounded-lg border p-4",style:{background:"var(--gradient-card)"},children:[c.jsxs(dg,{className:"flex items-center gap-2 w-full text-left group",children:[c.jsx(Z,{icon:D?Ts:Bl,size:14,className:"text-muted-foreground"}),c.jsx("h2",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider group-hover:text-foreground transition-colors",children:e("detail.sections.notes")}),!D&&i.notes&&c.jsxs("span",{className:"text-xs text-muted-foreground truncate max-w-xs",children:["— ",i.notes.split(`
329
329
  `)[0]]})]}),c.jsx(fg,{className:"mt-3",children:F?c.jsxs("div",{className:"space-y-2",children:[c.jsx(Oc,{ref:M,value:P,onChange:fe=>L(fe.target.value),placeholder:e("detail.addNotes"),className:"min-h-[100px] text-sm",onKeyDown:fe=>{fe.key==="Enter"&&fe.metaKey?ce():fe.key==="Escape"&&Ee()}}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(_e,{size:"sm",onClick:ce,children:[c.jsx(Z,{icon:hr,size:12,"data-slot":"icon"}),e("detail.save")]}),c.jsx(_e,{variant:"ghost",size:"sm",onClick:Ee,children:e("detail.cancel")})]})]}):c.jsxs("div",{className:"flex items-start justify-between gap-4",children:[i.notes?c.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap flex-1",children:i.notes}):c.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("detail.noNotes")}),c.jsxs(_e,{variant:"ghost",size:"sm",className:"shrink-0 h-7 text-xs",onClick:de,children:[c.jsx(Z,{icon:X$e,size:12,"data-slot":"icon"}),e("detail.edit")]})]})})]})]}),c.jsx(MJt,{project:i}),c.jsxs("section",{className:"film-grain relative rounded-lg border p-4 space-y-3",style:{background:"var(--gradient-card)"},children:[c.jsx("h2",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:e("detail.sections.activeTasks")}),J.length===0?c.jsx("p",{className:"text-sm text-muted-foreground",children:e("detail.noActiveTasks")}):c.jsx("div",{className:"space-y-2",children:J.map(fe=>c.jsxs(Pr,{to:"/tasks/$taskId",params:{taskId:fe.id},className:"flex items-center gap-2 p-2 rounded-md border bg-background hover:bg-accent transition-colors",children:[c.jsx(ir,{variant:fe.status==="IN_PROGRESS"?"default":fe.status==="IN_REVIEW"?"secondary":"outline",className:"text-xs shrink-0",children:fe.status.replace("_"," ")}),c.jsx("span",{className:"text-sm truncate",children:fe.title}),fe.repoPath&&c.jsx("span",{className:"text-xs text-muted-foreground ml-auto truncate max-w-32",children:fe.repoPath.split("/").pop()})]},fe.id))})]})]})})]}),y&&c.jsx(XW,{open:y!==null,onOpenChange:fe=>!fe&&v(null),defaultRepository:y,showTrigger:!1}),c.jsx(ql,{open:f,onOpenChange:fe=>!m&&h(fe),children:c.jsxs(Gl,{children:[c.jsxs(Kl,{children:[c.jsx(Xl,{children:e("delete.title")}),c.jsx(Ql,{children:e("delete.confirmText",{name:i.name})})]}),c.jsxs(Yl,{children:[c.jsx(Zl,{disabled:m,children:e("delete.cancel")}),c.jsx(cg,{onClick:Ie,disabled:m,className:"bg-destructive hover:bg-destructive/90",children:m?c.jsxs(c.Fragment,{children:[c.jsx(Z,{icon:Nt,size:14,className:"animate-spin","data-slot":"icon"}),e("delete.deleting")]}):e("delete.confirm")})]})]})}),c.jsx(pRe,{open:Y,onOpenChange:q,projectId:t}),c.jsx(OJt,{open:$,onOpenChange:W,projectId:t,projectName:i.name}),c.jsx(IJt,{open:K.open,onOpenChange:fe=>X({open:fe,repository:fe?K.repository:null}),projectId:t,repository:K.repository})]})}const WJt=xa("/jobs/new")({component:qJt});function qJt(){const{t:e}=Ot("jobs"),t=Ni(),{data:n,isLoading:r}=uj(),i=wHt();x.useEffect(()=>{!r&&!n?.canCreate&&t({to:"/jobs"})},[r,n,t]);const[s,a]=x.useState(""),[o,l]=x.useState(""),[u,d]=x.useState(""),[f,h]=x.useState(""),[m,g]=x.useState(""),[y,v]=x.useState(!0),[_,S]=x.useState({}),E=()=>{const k={};return s.trim()?/^[a-zA-Z0-9_-]+$/.test(s)||(k.name="Name must contain only alphanumeric characters, hyphens, and underscores"):k.name="Name is required",o.trim()||(k.description="Description is required"),u.trim()||(k.schedule="Schedule is required"),f.trim()||(k.command="Command is required"),S(k),Object.keys(k).length===0},T=async k=>{if(k.preventDefault(),!!E())try{await i.mutateAsync({name:s.trim(),description:o.trim(),schedule:u.trim(),command:f.trim(),workingDirectory:m.trim()||void 0,persistent:y}),rt.success("Job created successfully"),t({to:"/jobs"})}catch(w){rt.error(w instanceof Error?w.message:"Failed to create job")}};return r||!n?.canCreate?c.jsx("div",{className:"flex h-full items-center justify-center",children:c.jsx(Z,{icon:Nt,size:24,strokeWidth:2,className:"animate-spin text-muted-foreground"})}):c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsxs("div",{className:"film-grain relative flex shrink-0 items-center gap-4 border-b border-border px-4 py-3",style:{background:"var(--gradient-header)"},children:[c.jsx(Pr,{to:"/jobs",className:"text-muted-foreground hover:text-foreground",children:c.jsx(Z,{icon:xf,size:20,strokeWidth:2})}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Z,{icon:Z3,size:20,strokeWidth:2,className:"text-muted-foreground"}),c.jsx("h1",{className:"text-lg font-semibold",children:e("create.title")})]})]}),c.jsx("div",{className:"flex-1 overflow-auto p-4",children:c.jsxs("form",{onSubmit:T,className:"mx-auto max-w-2xl space-y-6",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ur,{htmlFor:"name",children:e("create.name")}),c.jsx(At,{id:"name",value:s,onChange:k=>a(k.target.value),placeholder:e("create.namePlaceholder"),className:_.name?"border-destructive":""}),_.name?c.jsx("p",{className:"text-sm text-destructive",children:_.name}):c.jsx("p",{className:"text-sm text-muted-foreground",children:e("create.nameHelp")})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ur,{htmlFor:"description",children:e("create.description")}),c.jsx(At,{id:"description",value:o,onChange:k=>l(k.target.value),placeholder:e("create.descriptionPlaceholder"),className:_.description?"border-destructive":""}),_.description&&c.jsx("p",{className:"text-sm text-destructive",children:_.description})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ur,{htmlFor:"schedule",children:e("create.schedule")}),c.jsx(At,{id:"schedule",value:u,onChange:k=>d(k.target.value),placeholder:"*-*-* 02:00:00",className:_.schedule?"border-destructive":""}),_.schedule?c.jsx("p",{className:"text-sm text-destructive",children:_.schedule}):c.jsx("p",{className:"text-sm text-muted-foreground",children:e("create.scheduleHelp")}),c.jsxs("div",{className:"flex flex-wrap gap-2 text-xs",children:[c.jsx("span",{className:"text-muted-foreground",children:"Examples:"}),c.jsx("button",{type:"button",onClick:()=>d("daily"),className:"text-primary hover:underline",children:"daily"}),c.jsx("button",{type:"button",onClick:()=>d("weekly"),className:"text-primary hover:underline",children:"weekly"}),c.jsx("button",{type:"button",onClick:()=>d("*-*-* 02:00:00"),className:"text-primary hover:underline",children:"*-*-* 02:00:00"}),c.jsx("button",{type:"button",onClick:()=>d("Mon..Fri 09:00"),className:"text-primary hover:underline",children:"Mon..Fri 09:00"})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ur,{htmlFor:"command",children:e("create.command")}),c.jsx(Oc,{id:"command",value:f,onChange:k=>h(k.target.value),placeholder:e("create.commandPlaceholder"),className:`font-mono ${_.command?"border-destructive":""}`,rows:3}),_.command&&c.jsx("p",{className:"text-sm text-destructive",children:_.command})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ur,{htmlFor:"workingDir",children:e("create.workingDir")}),c.jsx(At,{id:"workingDir",value:m,onChange:k=>g(k.target.value),placeholder:e("create.workingDirPlaceholder")})]}),c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsx(ni,{id:"persistent",checked:y,onCheckedChange:k=>v(k===!0)}),c.jsxs("div",{className:"grid gap-1.5 leading-none",children:[c.jsx(Ur,{htmlFor:"persistent",className:"cursor-pointer",children:e("create.persistent")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:e("create.persistentHelp")})]})]}),c.jsxs("div",{className:"flex items-center justify-end gap-2 pt-4",children:[c.jsx(Pr,{to:"/jobs",children:c.jsx(_e,{type:"button",variant:"outline",children:e("create.cancel")})}),c.jsxs(_e,{type:"submit",disabled:i.isPending,children:[i.isPending&&c.jsx(Z,{icon:Nt,size:16,strokeWidth:2,className:"animate-spin","data-slot":"icon"}),e("create.create")]})]})]})})]})}const GJt="modulepreload",KJt=function(e){return"/"+e},$0e={},ke=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let l=function(u){return Promise.all(u.map(d=>Promise.resolve(d).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=a?.nonce||a?.getAttribute("nonce");i=l(n.map(u=>{if(u=KJt(u),u in $0e)return;$0e[u]=!0;const d=u.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${f}`))return;const h=document.createElement("link");if(h.rel=d?"stylesheet":GJt,d||(h.as="script"),h.crossOrigin="",h.href=u,o&&h.setAttribute("nonce",o),document.head.appendChild(h),d)return new Promise((m,g)=>{h.addEventListener("load",m),h.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${u}`)))})}))}function s(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return i.then(a=>{for(const o of a||[])o.status==="rejected"&&s(o.reason);return t().catch(s)})};let Xs=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function YJt(e){return XJ(e)}function XJ(e){return Array.isArray(e)?XJt(e):e instanceof RegExp?e:typeof e=="object"?QJt(e):e}function XJt(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=XJ(e[n]);return t}function QJt(e){let t={};for(let n in e)t[n]=XJ(e[n]);return t}function Qje(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function Zje(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?Zje(e.substring(0,e.length-1)):e.substr(~t+1)}var IB=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,AN=class{static hasCaptures(e){return e===null?!1:(IB.lastIndex=0,IB.test(e))}static replaceCaptures(e,t,n){return e.replace(IB,(r,i,s,a)=>{let o=n[parseInt(i||s,10)];if(o){let l=t.substring(o.start,o.end);for(;l[0]===".";)l=l.substring(1);switch(a){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return r})}};function Jje(e,t){return e<t?-1:e>t?1:0}function ePe(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let i=0;i<n;i++){let s=Jje(e[i],t[i]);if(s!==0)return s}return 0}return n-r}function z0e(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function tPe(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var nPe=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);const t=this.fn(e);return this.cache.set(e,t),t}},c3=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(een(e),t)}static createFromParsedTheme(e,t){return nen(e,t)}_cachedMatchRoot=new nPe(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;const t=e.scopeName,r=this._cachedMatchRoot.get(t).find(i=>ZJt(e.parent,i.parentScopes));return r?new rPe(r.fontStyle,r.foreground,r.background):null}},DB=class pO{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(const r of n)t=new pO(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new pO(n,t[r]);return n}push(t){return new pO(this,t)}getSegments(){let t=this;const n=[];for(;t;)n.push(t.scopeName),t=t.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){const n=[];let r=this;for(;r&&r!==t;)n.push(r.scopeName),r=r.parent;return r===t?n.reverse():void 0}};function ZJt(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],i=!1;if(r===">"){if(n===t.length-1)return!1;r=t[++n],i=!0}for(;e&&!JJt(e.scopeName,r);){if(i)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function JJt(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var rPe=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function een(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let i=0,s=t.length;i<s;i++){let a=t[i];if(!a.settings)continue;let o;if(typeof a.scope=="string"){let f=a.scope;f=f.replace(/^[,]+/,""),f=f.replace(/[,]+$/,""),o=f.split(",")}else Array.isArray(a.scope)?o=a.scope:o=[""];let l=-1;if(typeof a.settings.fontStyle=="string"){l=0;let f=a.settings.fontStyle.split(" ");for(let h=0,m=f.length;h<m;h++)switch(f[h]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let u=null;typeof a.settings.foreground=="string"&&z0e(a.settings.foreground)&&(u=a.settings.foreground);let d=null;typeof a.settings.background=="string"&&z0e(a.settings.background)&&(d=a.settings.background);for(let f=0,h=o.length;f<h;f++){let g=o[f].trim().split(" "),y=g[g.length-1],v=null;g.length>1&&(v=g.slice(0,g.length-1),v.reverse()),n[r++]=new ten(y,v,i,l,u,d)}}return n}var ten=class{constructor(e,t,n,r,i,s){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=i,this.background=s}},Oo=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(Oo||{});function nen(e,t){e.sort((l,u)=>{let d=Jje(l.scope,u.scope);return d!==0||(d=ePe(l.parentScopes,u.parentScopes),d!==0)?d:l.index-u.index});let n=0,r="#000000",i="#ffffff";for(;e.length>=1&&e[0].scope==="";){let l=e.shift();l.fontStyle!==-1&&(n=l.fontStyle),l.foreground!==null&&(r=l.foreground),l.background!==null&&(i=l.background)}let s=new ren(t),a=new rPe(n,s.getId(r),s.getId(i)),o=new sen(new tV(0,null,-1,0,0),[]);for(let l=0,u=e.length;l<u;l++){let d=e[l];o.insert(0,d.scope,d.parentScopes,d.fontStyle,s.getId(d.foreground),s.getId(d.background))}return new c3(s,a,o)}var ren=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},ien=Object.freeze([]),tV=class iPe{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,n,r,i,s){this.scopeDepth=t,this.parentScopes=n||ien,this.fontStyle=r,this.foreground=i,this.background=s}clone(){return new iPe(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let n=[];for(let r=0,i=t.length;r<i;r++)n[r]=t[r].clone();return n}acceptOverwrite(t,n,r,i){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),i!==0&&(this.background=i)}},sen=class nV{constructor(t,n=[],r={}){this._mainRule=t,this._children=r,this._rulesWithParentScopes=n}_rulesWithParentScopes;static _cmpBySpecificity(t,n){if(t.scopeDepth!==n.scopeDepth)return n.scopeDepth-t.scopeDepth;let r=0,i=0;for(;t.parentScopes[r]===">"&&r++,n.parentScopes[i]===">"&&i++,!(r>=t.parentScopes.length||i>=n.parentScopes.length);){const s=n.parentScopes[i].length-t.parentScopes[r].length;if(s!==0)return s;r++,i++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),i,s;if(r===-1?(i=t,s=""):(i=t.substring(0,r),s=t.substring(r+1)),this._children.hasOwnProperty(i))return this._children[i].match(s)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(nV._cmpBySpecificity),n}insert(t,n,r,i,s,a){if(n===""){this._doInsertHere(t,r,i,s,a);return}let o=n.indexOf("."),l,u;o===-1?(l=n,u=""):(l=n.substring(0,o),u=n.substring(o+1));let d;this._children.hasOwnProperty(l)?d=this._children[l]:(d=new nV(this._mainRule.clone(),tV.cloneArr(this._rulesWithParentScopes)),this._children[l]=d),d.insert(t+1,u,r,i,s,a)}_doInsertHere(t,n,r,i,s){if(n===null){this._mainRule.acceptOverwrite(t,r,i,s);return}for(let a=0,o=this._rulesWithParentScopes.length;a<o;a++){let l=this._rulesWithParentScopes[a];if(ePe(l.parentScopes,n)===0){l.acceptOverwrite(t,r,i,s);return}}r===-1&&(r=this._mainRule.fontStyle),i===0&&(i=this._mainRule.foreground),s===0&&(s=this._mainRule.background),this._rulesWithParentScopes.push(new tV(t,n,r,i,s))}},f1=class au{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=au.getLanguageId(t),r=au.getTokenType(t),i=au.getFontStyle(t),s=au.getForeground(t),a=au.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:i,foreground:s,background:a})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,n,r,i,s,a,o){let l=au.getLanguageId(t),u=au.getTokenType(t),d=au.containsBalancedBrackets(t)?1:0,f=au.getFontStyle(t),h=au.getForeground(t),m=au.getBackground(t);return n!==0&&(l=n),r!==8&&(u=r),i!==null&&(d=i?1:0),s!==-1&&(f=s),a!==0&&(h=a),o!==0&&(m=o),(l<<0|u<<8|d<<10|f<<11|h<<15|m<<24)>>>0}};function u3(e,t){const n=[],r=aen(e);let i=r.next();for(;i!==null;){let l=0;if(i.length===2&&i.charAt(1)===":"){switch(i.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=r.next()}let u=a();if(n.push({matcher:u,priority:l}),i!==",")break;i=r.next()}return n;function s(){if(i==="-"){i=r.next();const l=s();return u=>!!l&&!l(u)}if(i==="("){i=r.next();const l=o();return i===")"&&(i=r.next()),l}if(U0e(i)){const l=[];do l.push(i),i=r.next();while(U0e(i));return u=>t(l,u)}return null}function a(){const l=[];let u=s();for(;u;)l.push(u),u=s();return d=>l.every(f=>f(d))}function o(){const l=[];let u=a();for(;u&&(l.push(u),i==="|"||i===",");){do i=r.next();while(i==="|"||i===",");u=a()}return d=>l.some(f=>f(d))}}function U0e(e){return!!e&&!!e.match(/[\w\.:]+/)}function aen(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;const r=n[0];return n=t.exec(e),r}}}function sPe(e){typeof e.dispose=="function"&&e.dispose()}var tC=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},oen=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},len=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){const t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},cen=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new tC(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const e=this.Q;this.Q=[];const t=new len;for(const n of e)uen(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof tC){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function uen(e,t,n,r){const i=n.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const s=n.lookup(t);e instanceof tC?mO({baseGrammar:s,selfGrammar:i},r):rV(e.ruleName,{baseGrammar:s,selfGrammar:i,repository:i.repository},r);const a=n.injections(e.scopeName);if(a)for(const o of a)r.add(new tC(o))}function rV(e,t,n){if(t.repository&&t.repository[e]){const r=t.repository[e];d3([r],t,n)}}function mO(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&d3(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&d3(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function d3(e,t,n){for(const r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const i=r.repository?Qje({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&d3(r.patterns,{...t,repository:i},n);const s=r.include;if(!s)continue;const a=aPe(s);switch(a.kind){case 0:mO({...t,selfGrammar:t.baseGrammar},n);break;case 1:mO(t,n);break;case 2:rV(a.ruleName,{...t,repository:i},n);break;case 3:case 4:const o=a.scopeName===t.selfGrammar.scopeName?t.selfGrammar:a.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(o){const l={baseGrammar:t.baseGrammar,selfGrammar:o,repository:i};a.kind===4?rV(a.ruleName,l,n):mO(l,n)}else a.kind===4?n.add(new oen(a.scopeName,a.ruleName)):n.add(new tC(a.scopeName));break}}}var den=class{kind=0},fen=class{kind=1},hen=class{constructor(e){this.ruleName=e}kind=2},pen=class{constructor(e){this.scopeName=e}kind=3},men=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function aPe(e){if(e==="$base")return new den;if(e==="$self")return new fen;const t=e.indexOf("#");if(t===-1)return new pen(e);if(t===0)return new hen(e.substring(1));{const n=e.substring(0,t),r=e.substring(t+1);return new men(n,r)}}var gen=/\\(\d+)/,H0e=/\\(\d+)/g,ben=-1,oPe=-2;var kk=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=AN.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=AN.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${Zje(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:AN.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:AN.replaceCaptures(this._contentName,e,t)}},yen=class extends kk{retokenizeCapturedWithRuleId;constructor(e,t,n,r,i){super(e,t,n,r),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,n,r){throw new Error("Not supported!")}},ven=class extends kk{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,null),this._match=new nC(r,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new rC,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},V0e=class extends kk{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,r),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(const n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new rC,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},iV=class extends kk{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i,s,a,o,l,u){super(e,t,n,r),this._begin=new nC(i,this.id),this.beginCaptures=s,this._end=new nC(a||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=o,this.applyEndPatternLast=l||!1,this.patterns=u.patterns,this.hasMissingPatterns=u.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new rC;for(const n of this.patterns)e.getRule(n).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},f3=class extends kk{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,i,s,a,o,l){super(e,t,n,r),this._begin=new nC(i,this.id),this.beginCaptures=s,this.whileCaptures=o,this._while=new nC(a,oPe),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new rC;for(const t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new rC,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"￿"),this._cachedCompiledWhilePatterns}},lPe=class Eo{static createCaptureRule(t,n,r,i,s){return t.registerRule(a=>new yen(n,a,r,i,s))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(i=>{if(t.id=i,t.match)return new ven(t.$vscodeTextmateLocation,t.id,t.name,t.match,Eo._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=Qje({},r,t.repository));let s=t.patterns;return typeof s>"u"&&t.include&&(s=[{include:t.include}]),new V0e(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,Eo._compilePatterns(s,n,r))}return t.while?new f3(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Eo._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,Eo._compileCaptures(t.whileCaptures||t.captures,n,r),Eo._compilePatterns(t.patterns,n,r)):new iV(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Eo._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,Eo._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,Eo._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let i=[];if(t){let s=0;for(const a in t){if(a==="$vscodeTextmateLocation")continue;const o=parseInt(a,10);o>s&&(s=o)}for(let a=0;a<=s;a++)i[a]=null;for(const a in t){if(a==="$vscodeTextmateLocation")continue;const o=parseInt(a,10);let l=0;t[a].patterns&&(l=Eo.getCompiledRuleId(t[a],n,r)),i[o]=Eo.createCaptureRule(n,t[a].$vscodeTextmateLocation,t[a].name,t[a].contentName,l)}}return i}static _compilePatterns(t,n,r){let i=[];if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s];let l=-1;if(o.include){const u=aPe(o.include);switch(u.kind){case 0:case 1:l=Eo.getCompiledRuleId(r[o.include],n,r);break;case 2:let d=r[u.ruleName];d&&(l=Eo.getCompiledRuleId(d,n,r));break;case 3:case 4:const f=u.scopeName,h=u.kind===4?u.ruleName:null,m=n.getExternalGrammar(f,r);if(m)if(h){let g=m.repository[h];g&&(l=Eo.getCompiledRuleId(g,n,m.repository))}else l=Eo.getCompiledRuleId(m.repository.$self,n,m.repository);break}}else l=Eo.getCompiledRuleId(o,n,r);if(l!==-1){const u=n.getRule(l);let d=!1;if((u instanceof V0e||u instanceof iV||u instanceof f3)&&u.hasMissingPatterns&&u.patterns.length===0&&(d=!0),d)continue;i.push(l)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},nC=class cPe{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,n){if(t&&typeof t=="string"){const r=t.length;let i=0,s=[],a=!1;for(let o=0;o<r;o++)if(t.charAt(o)==="\\"&&o+1<r){const u=t.charAt(o+1);u==="z"?(s.push(t.substring(i,o)),s.push("$(?!\\n)(?<!\\n)"),i=o+2):(u==="A"||u==="G")&&(a=!0),o++}this.hasAnchor=a,i===0?this.source=t:(s.push(t.substring(i,r)),this.source=s.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=gen.test(this.source):this.hasBackReferences=!1}clone(){return new cPe(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(i=>t.substring(i.start,i.end));return H0e.lastIndex=0,this.source.replace(H0e,(i,s)=>tPe(r[parseInt(s,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],n=[],r=[],i=[],s,a,o,l;for(s=0,a=this.source.length;s<a;s++)o=this.source.charAt(s),t[s]=o,n[s]=o,r[s]=o,i[s]=o,o==="\\"&&s+1<a&&(l=this.source.charAt(s+1),l==="A"?(t[s+1]="￿",n[s+1]="￿",r[s+1]="A",i[s+1]="A"):l==="G"?(t[s+1]="￿",n[s+1]="G",r[s+1]="￿",i[s+1]="G"):(t[s+1]=l,n[s+1]=l,r[s+1]=l,i[s+1]=l),s++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:i.join("")}}resolveAnchors(t,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},rC=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(n=>n.source);this._cached=new W0e(e,t,this._items.map(n=>n.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){let r=this._items.map(i=>i.resolveAnchors(t,n));return new W0e(e,r,this._items.map(i=>i.ruleId))}},W0e=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
330
330
  `)}findNextMatchSync(e,t,n){const r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},jB=class{constructor(e,t){this.languageId=e,this.tokenType=t}},xen=class sV{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,n){this._defaultAttributes=new jB(t,8),this._embeddedLanguagesMatcher=new _en(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?sV._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new jB(0,0);_getBasicScopeAttributes=new nPe(t=>{const n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new jB(n,r)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){const n=t.match(sV.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},_en=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([n,r])=>tPe(n));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;const t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}},q0e=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function uPe(e,t,n,r,i,s,a,o){const l=t.content.length;let u=!1,d=-1;if(a){const m=Sen(e,t,n,r,i,s);i=m.stack,r=m.linePos,n=m.isFirstLine,d=m.anchorPosition}const f=Date.now();for(;!u;){if(o!==0&&Date.now()-f>o)return new q0e(i,!0);h()}return new q0e(i,!1);function h(){const m=wen(e,t,n,r,i,d);if(!m){s.produce(i,l),u=!0;return}const g=m.captureIndices,y=m.matchedRuleId,v=g&&g.length>0?g[0].end>r:!1;if(y===ben){const _=i.getRule(e);s.produce(i,g[0].start),i=i.withContentNameScopesList(i.nameScopesList),kw(e,t,n,i,s,_.endCaptures,g),s.produce(i,g[0].end);const S=i;if(i=i.parent,d=S.getAnchorPos(),!v&&S.getEnterPos()===r){i=S,s.produce(i,l),u=!0;return}}else{const _=e.getRule(y);s.produce(i,g[0].start);const S=i,E=_.getName(t.content,g),T=i.contentNameScopesList.pushAttributed(E,e);if(i=i.push(y,r,d,g[0].end===l,null,T,T),_ instanceof iV){const k=_;kw(e,t,n,i,s,k.beginCaptures,g),s.produce(i,g[0].end),d=g[0].end;const w=k.getContentName(t.content,g),A=T.pushAttributed(w,e);if(i=i.withContentNameScopesList(A),k.endHasBackReferences&&(i=i.withEndRule(k.getEndWithResolvedBackReferences(t.content,g))),!v&&S.hasSameRuleAs(i)){i=i.pop(),s.produce(i,l),u=!0;return}}else if(_ instanceof f3){const k=_;kw(e,t,n,i,s,k.beginCaptures,g),s.produce(i,g[0].end),d=g[0].end;const w=k.getContentName(t.content,g),A=T.pushAttributed(w,e);if(i=i.withContentNameScopesList(A),k.whileHasBackReferences&&(i=i.withEndRule(k.getWhileWithResolvedBackReferences(t.content,g))),!v&&S.hasSameRuleAs(i)){i=i.pop(),s.produce(i,l),u=!0;return}}else if(kw(e,t,n,i,s,_.captures,g),s.produce(i,g[0].end),i=i.pop(),!v){i=i.safePop(),s.produce(i,l),u=!0;return}}g[0].end>r&&(r=g[0].end,n=!1)}}function Sen(e,t,n,r,i,s){let a=i.beginRuleCapturedEOL?0:-1;const o=[];for(let l=i;l;l=l.pop()){const u=l.getRule(e);u instanceof f3&&o.push({rule:u,stack:l})}for(let l=o.pop();l;l=o.pop()){const{ruleScanner:u,findOptions:d}=ken(l.rule,e,l.stack.endRule,n,r===a),f=u.findNextMatchSync(t,r,d);if(f){if(f.ruleId!==oPe){i=l.stack.pop();break}f.captureIndices&&f.captureIndices.length&&(s.produce(l.stack,f.captureIndices[0].start),kw(e,t,n,l.stack,s,l.rule.whileCaptures,f.captureIndices),s.produce(l.stack,f.captureIndices[0].end),a=f.captureIndices[0].end,f.captureIndices[0].end>r&&(r=f.captureIndices[0].end,n=!1))}else{i=l.stack.pop();break}}return{stack:i,linePos:r,anchorPosition:a,isFirstLine:n}}function wen(e,t,n,r,i,s){const a=Een(e,t,n,r,i,s),o=e.getInjections();if(o.length===0)return a;const l=Cen(o,e,t,n,r,i,s);if(!l)return a;if(!a)return l;const u=a.captureIndices[0].start,d=l.captureIndices[0].start;return d<u||l.priorityMatch&&d===u?l:a}function Een(e,t,n,r,i,s){const a=i.getRule(e),{ruleScanner:o,findOptions:l}=dPe(a,e,i.endRule,n,r===s),u=o.findNextMatchSync(t,r,l);return u?{captureIndices:u.captureIndices,matchedRuleId:u.ruleId}:null}function Cen(e,t,n,r,i,s,a){let o=Number.MAX_VALUE,l=null,u,d=0;const f=s.contentNameScopesList.getScopeNames();for(let h=0,m=e.length;h<m;h++){const g=e[h];if(!g.matcher(f))continue;const y=t.getRule(g.ruleId),{ruleScanner:v,findOptions:_}=dPe(y,t,null,r,i===a),S=v.findNextMatchSync(n,i,_);if(!S)continue;const E=S.captureIndices[0].start;if(!(E>=o)&&(o=E,l=S.captureIndices,u=S.ruleId,d=g.priority,o===i))break}return l?{priorityMatch:d===-1,captureIndices:l,matchedRuleId:u}:null}function dPe(e,t,n,r,i){return{ruleScanner:e.compileAG(t,n,r,i),findOptions:0}}function ken(e,t,n,r,i){return{ruleScanner:e.compileWhileAG(t,n,r,i),findOptions:0}}function kw(e,t,n,r,i,s,a){if(s.length===0)return;const o=t.content,l=Math.min(s.length,a.length),u=[],d=a[0].end;for(let f=0;f<l;f++){const h=s[f];if(h===null)continue;const m=a[f];if(m.length===0)continue;if(m.start>d)break;for(;u.length>0&&u[u.length-1].endPos<=m.start;)i.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop();if(u.length>0?i.produceFromScopes(u[u.length-1].scopes,m.start):i.produce(r,m.start),h.retokenizeCapturedWithRuleId){const y=h.getName(o,a),v=r.contentNameScopesList.pushAttributed(y,e),_=h.getContentName(o,a),S=v.pushAttributed(_,e),E=r.push(h.retokenizeCapturedWithRuleId,m.start,-1,!1,null,v,S),T=e.createOnigString(o.substring(0,m.end));uPe(e,T,n&&m.start===0,m.start,E,i,!1,0),sPe(T);continue}const g=h.getName(o,a);if(g!==null){const v=(u.length>0?u[u.length-1].scopes:r.contentNameScopesList).pushAttributed(g,e);u.push(new Ten(v,m.end))}}for(;u.length>0;)i.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop()}var Ten=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function Aen(e,t,n,r,i,s,a,o){return new Oen(e,t,n,r,i,s,a,o)}function G0e(e,t,n,r,i){const s=u3(t,h3),a=lPe.getCompiledRuleId(n,r,i.repository);for(const o of s)e.push({debugSelector:t,matcher:o.matcher,ruleId:a,grammar:i,priority:o.priority})}function h3(e,t){if(t.length<e.length)return!1;let n=0;return e.every(r=>{for(let i=n;i<t.length;i++)if(Nen(t[i],r))return n=i+1,!0;return!1})}function Nen(e,t){if(!e)return!1;if(e===t)return!0;const n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]==="."}var Oen=class{constructor(e,t,n,r,i,s,a,o){if(this._rootScopeName=e,this.balancedBracketSelectors=s,this._onigLib=o,this._basicScopeAttributesProvider=new xen(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=a,this._grammar=K0e(t,null),this._injections=null,this._tokenTypeMatchers=[],i)for(const l of Object.keys(i)){const u=u3(l,h3);for(const d of u)this._tokenTypeMatchers.push({matcher:d.matcher,type:i[l]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(const e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){const e={lookup:i=>i===this._rootScopeName?this._grammar:this.getExternalGrammar(i),injections:i=>this._grammarRepository.injections(i)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){const i=r.injections;if(i)for(let a in i)G0e(t,a,i[a],this,r);const s=this._grammarRepository.injections(n);s&&s.forEach(a=>{const o=this.getExternalGrammar(a);if(o){const l=o.injectionSelector;l&&G0e(t,l,o,this,o)}})}return t.sort((i,s)=>i.priority-s.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){const t=++this._lastRuleId,n=e(t);return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){const n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=K0e(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){const r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){const r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){this._rootId===-1&&(this._rootId=lPe.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let i;if(!t||t===aV.NULL){i=!0;const u=this._basicScopeAttributesProvider.getDefaultAttributes(),d=this.themeProvider.getDefaults(),f=f1.set(0,u.languageId,u.tokenType,null,d.fontStyle,d.foregroundId,d.backgroundId),h=this.getRule(this._rootId).getName(null,null);let m;h?m=oE.createRootAndLookUpScopeName(h,f,this):m=oE.createRoot("unknown",f),t=new aV(null,this._rootId,-1,-1,!1,null,m,m)}else i=!1,t.reset();e=e+`
331
331
  `;const s=this.createOnigString(e),a=s.content.length,o=new Ien(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),l=uPe(this,s,i,0,t,o,!0,r);return sPe(s),{lineLength:a,lineTokens:o,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function K0e(e,t){return e=YJt(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var oE=class qd{constructor(t,n,r){this.parent=t,this.scopePath=n,this.tokenAttributes=r}static fromExtension(t,n){let r=t,i=t?.scopePath??null;for(const s of n)i=DB.push(i,s.scopeNames),r=new qd(r,i,s.encodedTokenAttributes);return r}static createRoot(t,n){return new qd(null,new DB(null,t),n)}static createRootAndLookUpScopeName(t,n,r){const i=r.getMetadataForScope(t),s=new DB(null,t),a=r.themeProvider.themeMatch(s),o=qd.mergeAttributes(n,i,a);return new qd(null,s,o)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return qd.equals(this,t)}static equals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.scopeName!==n.scopeName||t.tokenAttributes!==n.tokenAttributes)return!1;t=t.parent,n=n.parent}while(!0)}static mergeAttributes(t,n,r){let i=-1,s=0,a=0;return r!==null&&(i=r.fontStyle,s=r.foregroundId,a=r.backgroundId),f1.set(t,n.languageId,n.tokenType,null,i,s,a)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return qd._pushAttributed(this,t,n);const r=t.split(/ /g);let i=this;for(const s of r)i=qd._pushAttributed(i,s,n);return i}static _pushAttributed(t,n,r){const i=r.getMetadataForScope(n),s=t.scopePath.push(n),a=r.themeProvider.themeMatch(s),o=qd.mergeAttributes(t.tokenAttributes,i,a);return new qd(t,s,o)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){const n=[];let r=this;for(;r&&r!==t;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(r.parent?.scopePath??null)}),r=r.parent;return r===t?n.reverse():void 0}},aV=class ob{constructor(t,n,r,i,s,a,o,l){this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=s,this.endRule=a,this.nameScopesList=o,this.contentNameScopesList=l,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=i}_stackElementBrand=void 0;static NULL=new ob(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:ob._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?oE.equals(t.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.depth!==n.depth||t.ruleId!==n.ruleId||t.endRule!==n.endRule)return!1;t=t.parent,n=n.parent}while(!0)}clone(){return this}static _reset(t){for(;t;)t._enterPos=-1,t._anchorPos=-1,t=t.parent}reset(){ob._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,i,s,a,o){return new ob(this,t,n,r,i,s,a,o)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){const t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,n){return this.parent&&(n=this.parent._writeString(t,n)),t[n++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,n}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new ob(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(t){let n=this;for(;n&&n._enterPos===t._enterPos;){if(n.ruleId===t.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){const r=oE.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new ob(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,oE.fromExtension(r,n.contentNameScopesList))}},Ren=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):u3(n,h3).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>u3(n,h3).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(const t of this.unbalancedBracketScopes)if(t(e))return!1;for(const t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},Ien=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let r=e?.tokenAttributes??0,i=!1;if(this.balancedBracketSelectors?.matchesAlways&&(i=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const s=e?.getScopeNames()??[];for(const a of this._tokenTypeOverrides)a.matcher(s)&&(r=f1.set(r,0,a.type,null,-1,0,0));this.balancedBracketSelectors&&(i=this.balancedBracketSelectors.match(s))}if(i&&(r=f1.set(r,0,8,i,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=t;return}const n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let r=0,i=this._binaryTokens.length;r<i;r++)n[r]=this._binaryTokens[r];return n}},Den=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(const e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,i){if(!this._grammars.has(e)){let s=this._rawGrammars.get(e);if(!s)return null;this._grammars.set(e,Aen(e,s,t,n,r,i,this,this._onigLib))}return this._grammars.get(e)}},jen=class{_options;_syncRegistry;_ensureGrammarCache;constructor(t){this._options=t,this._syncRegistry=new Den(c3.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,n){this._syncRegistry.setTheme(c3.createFromRawTheme(t,n))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(t,n,r){return this.loadGrammarWithConfiguration(t,n,{embeddedLanguages:r})}loadGrammarWithConfiguration(t,n,r){return this._loadGrammar(t,n,r.embeddedLanguages,r.tokenTypes,new Ren(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,n,r,i,s){const a=new cen(this._syncRegistry,t);for(;a.Q.length>0;)a.Q.map(o=>this._loadSingleGrammar(o.scopeName)),a.processQueue();return this._grammarForScopeName(t,n,r,i,s)}_loadSingleGrammar(t){this._ensureGrammarCache.has(t)||(this._doLoadSingleGrammar(t),this._ensureGrammarCache.set(t,!0))}_doLoadSingleGrammar(t){const n=this._options.loadGrammar(t);if(n){const r=typeof this._options.getInjections=="function"?this._options.getInjections(t):void 0;this._syncRegistry.addGrammar(n,r)}}addGrammar(t,n=[],r=0,i=null){return this._syncRegistry.addGrammar(t,n),this._grammarForScopeName(t.scopeName,r,i)}_grammarForScopeName(t,n=0,r=null,i=null,s=null){return this._syncRegistry.grammarForScopeName(t,n,r,i,s)}},oV=aV.NULL;function p3(e,t){const n=typeof e=="string"?{}:{...e.colorReplacements},r=typeof e=="string"?e:e.name;for(const[i,s]of Object.entries(t?.colorReplacements||{}))typeof s=="string"?n[i]=s:i===r&&Object.assign(n,s);return n}function zm(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function Pen(e){return Array.isArray(e)?e:[e]}async function fPe(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function QJ(e){return!e||["plaintext","txt","text","plain"].includes(e)}function hPe(e){return e==="ansi"||QJ(e)}function ZJ(e){return e==="none"}function pPe(e){return ZJ(e)}function mPe(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(/\s+/g)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split(/\s+/g);for(const r of n)r&&!e.properties.class.includes(r)&&e.properties.class.push(r);return e}function xj(e,t=!1){if(e.length===0)return[["",0]];const n=e.split(/(\r?\n)/g);let r=0;const i=[];for(let s=0;s<n.length;s+=2){const a=t?n[s]+(n[s+1]||""):n[s];i.push([a,r]),r+=n[s].length,r+=n[s+1]?.length||0}return i}function Len(e){const t=xj(e,!0).map(([i])=>i);function n(i){if(i===e.length)return{line:t.length-1,character:t[t.length-1].length};let s=i,a=0;for(const o of t){if(s<o.length)break;s-=o.length,a++}return{line:a,character:s}}function r(i,s){let a=0;for(let o=0;o<i;o++)a+=t[o].length;return a+=s,a}return{lines:t,indexToPos:n,posToIndex:r}}const JJ="light-dark()",Men=["color","background-color"];function Fen(e,t){let n=0;const r=[];for(const i of t)i>n&&r.push({...e,content:e.content.slice(n,i),offset:e.offset+n}),n=i;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function Ben(e,t){const n=Array.from(t instanceof Set?t:new Set(t)).sort((r,i)=>r-i);return n.length?e.map(r=>r.flatMap(i=>{const s=n.filter(a=>i.offset<a&&a<i.offset+i.content.length).map(a=>a-i.offset).sort((a,o)=>a-o);return s.length?Fen(i,s):i})):e}function $en(e,t,n,r,i="css-vars"){const s={content:e.content,explanation:e.explanation,offset:e.offset},a=t.map(d=>m3(e.variants[d])),o=new Set(a.flatMap(d=>Object.keys(d))),l={},u=(d,f)=>{const h=f==="color"?"":f==="background-color"?"-bg":`-${f}`;return n+t[d]+(f==="color"?"":h)};return a.forEach((d,f)=>{for(const h of o){const m=d[h]||"inherit";if(f===0&&r&&Men.includes(h))if(r===JJ&&a.length>1){const g=t.findIndex(S=>S==="light"),y=t.findIndex(S=>S==="dark");if(g===-1||y===-1)throw new Xs('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const v=a[g][h]||"inherit",_=a[y][h]||"inherit";l[h]=`light-dark(${v}, ${_})`,i==="css-vars"&&(l[u(f,h)]=m)}else l[h]=m;else i==="css-vars"&&(l[u(f,h)]=m)}}),s.htmlStyle=l,s}function m3(e){const t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&Oo.Italic&&(t["font-style"]="italic"),e.fontStyle&Oo.Bold&&(t["font-weight"]="bold");const n=[];e.fontStyle&Oo.Underline&&n.push("underline"),e.fontStyle&Oo.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function lV(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}const gPe=new WeakMap;function _j(e,t){gPe.set(e,t)}function iC(e){return gPe.get(e)}class w_{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new w_(Object.fromEntries(Pen(n).map(r=>[r,oV])),t)}constructor(...t){if(t.length===2){const[n,r]=t;this.lang=r,this._stacks=n}else{const[n,r,i]=t;this.lang=r,this._stacks={[i]:n}}}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return zen(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}}function zen(e){const t=[],n=new Set;function r(i){if(n.has(i))return;n.add(i);const s=i?.nameScopesList?.scopeName;s&&t.push(s),i.parent&&r(i.parent)}return r(e),t}function Uen(e,t){if(!(e instanceof w_))throw new Xs("Invalid grammar state");return e.getInternalStack(t)}function Hen(){const e=new WeakMap;function t(n){if(!e.has(n.meta)){let r=function(a){if(typeof a=="number"){if(a<0||a>n.source.length)throw new Xs(`Invalid decoration offset: ${a}. Code length: ${n.source.length}`);return{...i.indexToPos(a),offset:a}}else{const o=i.lines[a.line];if(o===void 0)throw new Xs(`Invalid decoration position ${JSON.stringify(a)}. Lines length: ${i.lines.length}`);let l=a.character;if(l<0&&(l=o.length+l),l<0||l>o.length)throw new Xs(`Invalid decoration position ${JSON.stringify(a)}. Line ${a.line} length: ${o.length}`);return{...a,character:l,offset:i.posToIndex(a.line,l)}}};const i=Len(n.source),s=(n.options.decorations||[]).map(a=>({...a,start:r(a.start),end:r(a.end)}));Ven(s),e.set(n.meta,{decorations:s,converter:i,source:n.source})}return e.get(n.meta)}return{name:"shiki:decorations",tokens(n){if(!this.options.decorations?.length)return;const i=t(this).decorations.flatMap(a=>[a.start.offset,a.end.offset]);return Ben(n,i)},code(n){if(!this.options.decorations?.length)return;const r=t(this),i=Array.from(n.children).filter(d=>d.type==="element"&&d.tagName==="span");if(i.length!==r.converter.lines.length)throw new Xs(`Number of lines in code element (${i.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function s(d,f,h,m){const g=i[d];let y="",v=-1,_=-1;if(f===0&&(v=0),h===0&&(_=0),h===Number.POSITIVE_INFINITY&&(_=g.children.length),v===-1||_===-1)for(let E=0;E<g.children.length;E++)y+=bPe(g.children[E]),v===-1&&y.length===f&&(v=E+1),_===-1&&y.length===h&&(_=E+1);if(v===-1)throw new Xs(`Failed to find start index for decoration ${JSON.stringify(m.start)}`);if(_===-1)throw new Xs(`Failed to find end index for decoration ${JSON.stringify(m.end)}`);const S=g.children.slice(v,_);if(!m.alwaysWrap&&S.length===g.children.length)o(g,m,"line");else if(!m.alwaysWrap&&S.length===1&&S[0].type==="element")o(S[0],m,"token");else{const E={type:"element",tagName:"span",properties:{},children:S};o(E,m,"wrapper"),g.children.splice(v,S.length,E)}}function a(d,f){i[d]=o(i[d],f,"line")}function o(d,f,h){const m=f.properties||{},g=f.transform||(y=>y);return d.tagName=f.tagName||"span",d.properties={...d.properties,...m,class:d.properties.class},f.properties?.class&&mPe(d,f.properties.class),d=g(d,h)||d,d}const l=[],u=r.decorations.sort((d,f)=>f.start.offset-d.start.offset||d.end.offset-f.end.offset);for(const d of u){const{start:f,end:h}=d;if(f.line===h.line)s(f.line,f.character,h.character,d);else if(f.line<h.line){s(f.line,f.character,Number.POSITIVE_INFINITY,d);for(let m=f.line+1;m<h.line;m++)l.unshift(()=>a(m,d));s(h.line,0,h.character,d)}}l.forEach(d=>d())}}}function Ven(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new Xs(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){const i=e[r],s=n.start.offset<=i.start.offset&&i.start.offset<n.end.offset,a=n.start.offset<i.end.offset&&i.end.offset<=n.end.offset,o=i.start.offset<=n.start.offset&&n.start.offset<i.end.offset,l=i.start.offset<n.end.offset&&n.end.offset<=i.end.offset;if(s||a||o||l){if(s&&a||o&&l||o&&n.start.offset===n.end.offset||a&&i.start.offset===i.end.offset)continue;throw new Xs(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(i.start)} intersect.`)}}}}function bPe(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(bPe).join(""):""}const Wen=[Hen()];function g3(e){const t=qen(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...Wen]}function qen(e){const t=[],n=[],r=[];for(const i of e)switch(i.enforce){case"pre":t.push(i);break;case"post":n.push(i);break;default:r.push(i)}return{pre:t,post:n,normal:r}}var Rb=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],PB={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function Gen(e,t){const n=e.indexOf("\x1B",t);if(n!==-1&&e[n+1]==="["){const r=e.indexOf("m",n);if(r!==-1)return{sequence:e.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:e.length}}function Y0e(e){const t=e.shift();if(t==="2"){const n=e.splice(0,3).map(r=>Number.parseInt(r));return n.length!==3||n.some(r=>Number.isNaN(r))?void 0:{type:"rgb",rgb:n}}else if(t==="5"){const n=e.shift();if(n)return{type:"table",index:Number(n)}}}function Ken(e){const t=[];for(;e.length>0;){const n=e.shift();if(!n)continue;const r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:"resetAll"});else if(r<=9)PB[r]&&t.push({type:"setDecoration",value:PB[r]});else if(r<=29){const i=PB[r-20];i&&(t.push({type:"resetDecoration",value:i}),i==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:Rb[r-30]}});else if(r===38){const i=Y0e(e);i&&t.push({type:"setForegroundColor",value:i})}else if(r===39)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:Rb[r-40]}});else if(r===48){const i=Y0e(e);i&&t.push({type:"setBackgroundColor",value:i})}else r===49?t.push({type:"resetBackgroundColor"}):r===53?t.push({type:"setDecoration",value:"overline"}):r===55?t.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?t.push({type:"setForegroundColor",value:{type:"named",name:Rb[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:Rb[r-100+8]}})}return t}function Yen(){let e=null,t=null,n=new Set;return{parse(r){const i=[];let s=0;do{const a=Gen(r,s),o=a.sequence?r.substring(s,a.startPosition):r.substring(s);if(o.length>0&&i.push({value:o,foreground:e,background:t,decorations:new Set(n)}),a.sequence){const l=Ken(a.sequence);for(const u of l)u.type==="resetAll"?(e=null,t=null,n.clear()):u.type==="resetForegroundColor"?e=null:u.type==="resetBackgroundColor"?t=null:u.type==="resetDecoration"&&n.delete(u.value);for(const u of l)u.type==="setForegroundColor"?e=u.value:u.type==="setBackgroundColor"?t=u.value:u.type==="setDecoration"&&n.add(u.value)}s=a.position}while(s<r.length);return i}}}var Xen={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function Qen(e=Xen){function t(o){return e[o]}function n(o){return`#${o.map(l=>Math.max(0,Math.min(l,255)).toString(16).padStart(2,"0")).join("")}`}let r;function i(){if(r)return r;r=[];for(let u=0;u<Rb.length;u++)r.push(t(Rb[u]));let o=[0,95,135,175,215,255];for(let u=0;u<6;u++)for(let d=0;d<6;d++)for(let f=0;f<6;f++)r.push(n([o[u],o[d],o[f]]));let l=8;for(let u=0;u<24;u++,l+=10)r.push(n([l,l,l]));return r}function s(o){return i()[o]}function a(o){switch(o.type){case"named":return t(o.name);case"rgb":return n(o.rgb);case"table":return s(o.index)}}return{value:a}}const Zen={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function Jen(e,t,n){const r=p3(e,n),i=xj(t),s=Object.fromEntries(Rb.map(l=>{const u=`terminal.ansi${l[0].toUpperCase()}${l.substring(1)}`,d=e.colors?.[u];return[l,d||Zen[l]]})),a=Qen(s),o=Yen();return i.map(l=>o.parse(l[0]).map(u=>{let d,f;u.decorations.has("reverse")?(d=u.background?a.value(u.background):e.bg,f=u.foreground?a.value(u.foreground):e.fg):(d=u.foreground?a.value(u.foreground):e.fg,f=u.background?a.value(u.background):void 0),d=zm(d,r),f=zm(f,r),u.decorations.has("dim")&&(d=etn(d));let h=Oo.None;return u.decorations.has("bold")&&(h|=Oo.Bold),u.decorations.has("italic")&&(h|=Oo.Italic),u.decorations.has("underline")&&(h|=Oo.Underline),u.decorations.has("strikethrough")&&(h|=Oo.Strikethrough),{content:u.value,offset:l[1],color:d,bgColor:f,fontStyle:h}}))}function etn(e){const t=e.match(/#([0-9a-f]{3,8})/i);if(t){const r=t[1];if(r.length===8){const i=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${i}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){const i=r[0],s=r[1],a=r[2],o=r[3],l=Math.round(Number.parseInt(`${o}${o}`,16)/2).toString(16).padStart(2,"0");return`#${i}${i}${s}${s}${a}${a}${l}`}else if(r.length===3){const i=r[0],s=r[1],a=r[2];return`#${i}${i}${s}${s}${a}${a}80`}}}const n=e.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return n?`var(${n[1]}-dim)`:e}function eee(e,t,n={}){const{theme:r=e.getLoadedThemes()[0]}=n,i=e.resolveLangAlias(n.lang||"text");if(QJ(i)||ZJ(r))return xj(t).map(l=>[{content:l[0],offset:l[1]}]);const{theme:s,colorMap:a}=e.setTheme(r);if(i==="ansi")return Jen(s,t,n);const o=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==o.name)throw new Xs(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${o.name}"`);if(!n.grammarState.themes.includes(s.name))throw new Xs(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${s.name}"`)}return ntn(t,o,s,a,n)}function ttn(...e){if(e.length===2)return iC(e[1]);const[t,n,r={}]=e,{lang:i="text",theme:s=t.getLoadedThemes()[0]}=r;if(QJ(i)||ZJ(s))throw new Xs("Plain language does not have grammar state");if(i==="ansi")throw new Xs("ANSI language does not have grammar state");const{theme:a,colorMap:o}=t.setTheme(s),l=t.getLanguage(i);return new w_(tee(n,l,a,o,r).stateStack,l.name,a.name)}function ntn(e,t,n,r,i){const s=tee(e,t,n,r,i),a=new w_(s.stateStack,t.name,n.name);return _j(s.tokens,a),s.tokens}function tee(e,t,n,r,i){const s=p3(n,i),{tokenizeMaxLineLength:a=0,tokenizeTimeLimit:o=500}=i,l=xj(e);let u=i.grammarState?Uen(i.grammarState,n.name)??oV:i.grammarContextCode!=null?tee(i.grammarContextCode,t,n,r,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack:oV,d=[];const f=[];for(let h=0,m=l.length;h<m;h++){const[g,y]=l[h];if(g===""){d=[],f.push([]);continue}if(a>0&&g.length>=a){d=[],f.push([{content:g,offset:y,color:"",fontStyle:0}]);continue}let v,_,S;i.includeExplanation&&(v=t.tokenizeLine(g,u,o),_=v.tokens,S=0);const E=t.tokenizeLine2(g,u,o),T=E.tokens.length/2;for(let k=0;k<T;k++){const w=E.tokens[2*k],A=k+1<T?E.tokens[2*k+2]:g.length;if(w===A)continue;const R=E.tokens[2*k+1],I=zm(r[f1.getForeground(R)],s),D=f1.getFontStyle(R),j={content:g.substring(w,A),offset:y+w,color:I,fontStyle:D};if(i.includeExplanation){const F=[];if(i.includeExplanation!=="scopeName")for(const P of n.settings){let L;switch(typeof P.scope){case"string":L=P.scope.split(/,/).map(M=>M.trim());break;case"object":L=P.scope;break;default:continue}F.push({settings:P,selectors:L.map(M=>M.split(/ /))})}j.explanation=[];let z=0;for(;w+z<A;){const P=_[S],L=g.substring(P.startIndex,P.endIndex);z+=L.length,j.explanation.push({content:L,scopes:i.includeExplanation==="scopeName"?rtn(P.scopes):itn(F,P.scopes)}),S+=1}}d.push(j)}f.push(d),d=[],u=E.ruleStack}return{tokens:f,stateStack:u}}function rtn(e){return e.map(t=>({scopeName:t}))}function itn(e,t){const n=[];for(let r=0,i=t.length;r<i;r++){const s=t[r];n[r]={scopeName:s,themeMatches:atn(e,s,t.slice(0,r))}}return n}function X0e(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function stn(e,t,n){if(!X0e(e[e.length-1],t))return!1;let r=e.length-2,i=n.length-1;for(;r>=0&&i>=0;)X0e(e[r],n[i])&&(r-=1),i-=1;return r===-1}function atn(e,t,n){const r=[];for(const{selectors:i,settings:s}of e)for(const a of i)if(stn(a,t,n)){r.push(s);break}return r}function yPe(e,t,n){const r=Object.entries(n.themes).filter(l=>l[1]).map(l=>({color:l[0],theme:l[1]})),i=r.map(l=>{const u=eee(e,t,{...n,theme:l.theme}),d=iC(u),f=typeof l.theme=="string"?l.theme:l.theme.name;return{tokens:u,state:d,theme:f}}),s=otn(...i.map(l=>l.tokens)),a=s[0].map((l,u)=>l.map((d,f)=>{const h={content:d.content,variants:{},offset:d.offset};return"includeExplanation"in n&&n.includeExplanation&&(h.explanation=d.explanation),s.forEach((m,g)=>{const{content:y,explanation:v,offset:_,...S}=m[u][f];h.variants[r[g].color]=S}),h})),o=i[0].state?new w_(Object.fromEntries(i.map(l=>[l.theme,l.state?.getInternalStack(l.theme)])),i[0].state.lang):void 0;return o&&_j(a,o),a}function otn(...e){const t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){const i=e.map(l=>l[r]),s=t.map(()=>[]);t.forEach((l,u)=>l.push(s[u]));const a=i.map(()=>0),o=i.map(l=>l[0]);for(;o.every(l=>l);){const l=Math.min(...o.map(u=>u.content.length));for(let u=0;u<n;u++){const d=o[u];d.content.length===l?(s[u].push(d),a[u]+=1,o[u]=i[u][a[u]]):(s[u].push({...d,content:d.content.slice(0,l)}),o[u]={...d,content:d.content.slice(l),offset:d.offset+l})}}}return t}function b3(e,t,n){let r,i,s,a,o,l;if("themes"in n){const{defaultColor:u="light",cssVariablePrefix:d="--shiki-",colorsRendering:f="css-vars"}=n,h=Object.entries(n.themes).filter(_=>_[1]).map(_=>({color:_[0],theme:_[1]})).sort((_,S)=>_.color===u?-1:S.color===u?1:0);if(h.length===0)throw new Xs("`themes` option must not be empty");const m=yPe(e,t,n);if(l=iC(m),u&&JJ!==u&&!h.find(_=>_.color===u))throw new Xs(`\`themes\` option must contain the defaultColor key \`${u}\``);const g=h.map(_=>e.getTheme(_.theme)),y=h.map(_=>_.color);s=m.map(_=>_.map(S=>$en(S,y,d,u,f))),l&&_j(s,l);const v=h.map(_=>p3(_.theme,n));i=Q0e(h,g,v,d,u,"fg",f),r=Q0e(h,g,v,d,u,"bg",f),a=`shiki-themes ${g.map(_=>_.name).join(" ")}`,o=u?void 0:[i,r].join(";")}else if("theme"in n){const u=p3(n.theme,n);s=eee(e,t,n);const d=e.getTheme(n.theme);r=zm(d.bg,u),i=zm(d.fg,u),a=d.name,l=iC(s)}else throw new Xs("Invalid options, either `theme` or `themes` must be provided");return{tokens:s,fg:i,bg:r,themeName:a,rootStyle:o,grammarState:l}}function Q0e(e,t,n,r,i,s,a){return e.map((o,l)=>{const u=zm(t[l][s],n[l])||"inherit",d=`${r+o.color}${s==="bg"?"-bg":""}:${u}`;if(l===0&&i){if(i===JJ&&e.length>1){const f=e.findIndex(y=>y.color==="light"),h=e.findIndex(y=>y.color==="dark");if(f===-1||h===-1)throw new Xs('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const m=zm(t[f][s],n[f])||"inherit",g=zm(t[h][s],n[h])||"inherit";return`light-dark(${m}, ${g});${d}`}return u}return a==="css-vars"?d:null}).filter(o=>!!o).join(";")}function y3(e,t,n,r={meta:{},options:n,codeToHast:(i,s)=>y3(e,i,s),codeToTokens:(i,s)=>b3(e,i,s)}){let i=t;for(const g of g3(n))i=g.preprocess?.call(r,i,n)||i;let{tokens:s,fg:a,bg:o,themeName:l,rootStyle:u,grammarState:d}=b3(e,i,n);const{mergeWhitespaces:f=!0,mergeSameStyleTokens:h=!1}=n;f===!0?s=ctn(s):f==="never"&&(s=utn(s)),h&&(s=dtn(s));const m={...r,get source(){return i}};for(const g of g3(n))s=g.tokens?.call(m,s)||s;return ltn(s,{...n,fg:a,bg:o,themeName:l,rootStyle:n.rootStyle===!1?!1:n.rootStyle??u},m,d)}function ltn(e,t,n,r=iC(e)){const i=g3(t),s=[],a={type:"root",children:[]},{structure:o="classic",tabindex:l="0"}=t,u={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?u.style=t.rootStyle:u.style=`background-color:${t.bg};color:${t.fg}`),l!==!1&&l!=null&&(u.tabindex=l.toString());for(const[y,v]of Object.entries(t.meta||{}))y.startsWith("_")||(u[y]=v);let d={type:"element",tagName:"pre",properties:u,children:[]},f={type:"element",tagName:"code",properties:{},children:s};const h=[],m={...n,structure:o,addClassToHast:mPe,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return a},get pre(){return d},get code(){return f},get lines(){return h}};if(e.forEach((y,v)=>{v&&(o==="inline"?a.children.push({type:"element",tagName:"br",properties:{},children:[]}):o==="classic"&&s.push({type:"text",value:`