ralphx 0.3.4__py3-none-any.whl → 0.3.5__py3-none-any.whl

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.
Files changed (38) hide show
  1. ralphx/__init__.py +1 -1
  2. ralphx/api/routes/auth.py +703 -94
  3. ralphx/api/routes/config.py +3 -56
  4. ralphx/api/routes/export_import.py +6 -9
  5. ralphx/api/routes/loops.py +4 -4
  6. ralphx/api/routes/planning.py +19 -5
  7. ralphx/api/routes/templates.py +2 -2
  8. ralphx/api/routes/workflows.py +1 -22
  9. ralphx/cli.py +4 -1
  10. ralphx/core/auth.py +346 -171
  11. ralphx/core/database.py +588 -164
  12. ralphx/core/executor.py +0 -3
  13. ralphx/core/loop.py +15 -2
  14. ralphx/core/loop_templates.py +3 -3
  15. ralphx/core/planning_service.py +109 -21
  16. ralphx/core/preview.py +9 -25
  17. ralphx/core/project_db.py +124 -72
  18. ralphx/core/project_export.py +1 -5
  19. ralphx/core/project_import.py +14 -29
  20. ralphx/core/sample_project.py +1 -5
  21. ralphx/core/templates.py +9 -9
  22. ralphx/core/workflow_export.py +4 -7
  23. ralphx/core/workflow_import.py +3 -27
  24. ralphx/mcp/__init__.py +6 -2
  25. ralphx/mcp/registry.py +3 -3
  26. ralphx/mcp/tools/workflows.py +114 -32
  27. ralphx/mcp_server.py +6 -2
  28. ralphx/static/assets/index-0ovNnfOq.css +1 -0
  29. ralphx/static/assets/index-CY9s08ZB.js +251 -0
  30. ralphx/static/assets/index-CY9s08ZB.js.map +1 -0
  31. ralphx/static/index.html +2 -2
  32. {ralphx-0.3.4.dist-info → ralphx-0.3.5.dist-info}/METADATA +33 -12
  33. {ralphx-0.3.4.dist-info → ralphx-0.3.5.dist-info}/RECORD +35 -35
  34. ralphx/static/assets/index-CcRDyY3b.css +0 -1
  35. ralphx/static/assets/index-CcxfTosc.js +0 -251
  36. ralphx/static/assets/index-CcxfTosc.js.map +0 -1
  37. {ralphx-0.3.4.dist-info → ralphx-0.3.5.dist-info}/WHEEL +0 -0
  38. {ralphx-0.3.4.dist-info → ralphx-0.3.5.dist-info}/entry_points.txt +0 -0
@@ -1,251 +0,0 @@
1
- function Lg(t,s){for(var o=0;o<s.length;o++){const l=s[o];if(typeof l!="string"&&!Array.isArray(l)){for(const i in l)if(i!=="default"&&!(i in t)){const d=Object.getOwnPropertyDescriptor(l,i);d&&Object.defineProperty(t,i,d.get?d:{enumerable:!0,get:()=>l[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))l(i);new MutationObserver(i=>{for(const d of i)if(d.type==="childList")for(const u of d.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&l(u)}).observe(document,{childList:!0,subtree:!0});function o(i){const d={};return i.integrity&&(d.integrity=i.integrity),i.referrerPolicy&&(d.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?d.credentials="include":i.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function l(i){if(i.ep)return;i.ep=!0;const d=o(i);fetch(i.href,d)}})();function Nh(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ac={exports:{}},yo={},lc={exports:{}},Re={};/**
2
- * @license React
3
- * react.production.min.js
4
- *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var o0;function Eg(){if(o0)return Re;o0=1;var t=Symbol.for("react.element"),s=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),d=Symbol.for("react.provider"),u=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),y=Symbol.iterator;function b(L){return L===null||typeof L!="object"?null:(L=y&&L[y]||L["@@iterator"],typeof L=="function"?L:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,S={};function j(L,F,H){this.props=L,this.context=F,this.refs=S,this.updater=H||k}j.prototype.isReactComponent={},j.prototype.setState=function(L,F){if(typeof L!="object"&&typeof L!="function"&&L!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,L,F,"setState")},j.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function N(){}N.prototype=j.prototype;function T(L,F,H){this.props=L,this.context=F,this.refs=S,this.updater=H||k}var P=T.prototype=new N;P.constructor=T,_(P,j.prototype),P.isPureReactComponent=!0;var C=Array.isArray,E=Object.prototype.hasOwnProperty,I={current:null},M={key:!0,ref:!0,__self:!0,__source:!0};function q(L,F,H){var K,J={},he=null,_e=null;if(F!=null)for(K in F.ref!==void 0&&(_e=F.ref),F.key!==void 0&&(he=""+F.key),F)E.call(F,K)&&!M.hasOwnProperty(K)&&(J[K]=F[K]);var Ae=arguments.length-2;if(Ae===1)J.children=H;else if(1<Ae){for(var Pe=Array(Ae),pe=0;pe<Ae;pe++)Pe[pe]=arguments[pe+2];J.children=Pe}if(L&&L.defaultProps)for(K in Ae=L.defaultProps,Ae)J[K]===void 0&&(J[K]=Ae[K]);return{$$typeof:t,type:L,key:he,ref:_e,props:J,_owner:I.current}}function z(L,F){return{$$typeof:t,type:L.type,key:F,ref:L.ref,props:L.props,_owner:L._owner}}function U(L){return typeof L=="object"&&L!==null&&L.$$typeof===t}function O(L){var F={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(H){return F[H]})}var X=/\/+/g;function ee(L,F){return typeof L=="object"&&L!==null&&L.key!=null?O(""+L.key):F.toString(36)}function W(L,F,H,K,J){var he=typeof L;(he==="undefined"||he==="boolean")&&(L=null);var _e=!1;if(L===null)_e=!0;else switch(he){case"string":case"number":_e=!0;break;case"object":switch(L.$$typeof){case t:case s:_e=!0}}if(_e)return _e=L,J=J(_e),L=K===""?"."+ee(_e,0):K,C(J)?(H="",L!=null&&(H=L.replace(X,"$&/")+"/"),W(J,F,H,"",function(pe){return pe})):J!=null&&(U(J)&&(J=z(J,H+(!J.key||_e&&_e.key===J.key?"":(""+J.key).replace(X,"$&/")+"/")+L)),F.push(J)),1;if(_e=0,K=K===""?".":K+":",C(L))for(var Ae=0;Ae<L.length;Ae++){he=L[Ae];var Pe=K+ee(he,Ae);_e+=W(he,F,H,Pe,J)}else if(Pe=b(L),typeof Pe=="function")for(L=Pe.call(L),Ae=0;!(he=L.next()).done;)he=he.value,Pe=K+ee(he,Ae++),_e+=W(he,F,H,Pe,J);else if(he==="object")throw F=String(L),Error("Objects are not valid as a React child (found: "+(F==="[object Object]"?"object with keys {"+Object.keys(L).join(", ")+"}":F)+"). If you meant to render a collection of children, use an array instead.");return _e}function te(L,F,H){if(L==null)return L;var K=[],J=0;return W(L,K,"","",function(he){return F.call(H,he,J++)}),K}function D(L){if(L._status===-1){var F=L._result;F=F(),F.then(function(H){(L._status===0||L._status===-1)&&(L._status=1,L._result=H)},function(H){(L._status===0||L._status===-1)&&(L._status=2,L._result=H)}),L._status===-1&&(L._status=0,L._result=F)}if(L._status===1)return L._result.default;throw L._result}var R={current:null},Y={transition:null},ie={ReactCurrentDispatcher:R,ReactCurrentBatchConfig:Y,ReactCurrentOwner:I};function re(){throw Error("act(...) is not supported in production builds of React.")}return Re.Children={map:te,forEach:function(L,F,H){te(L,function(){F.apply(this,arguments)},H)},count:function(L){var F=0;return te(L,function(){F++}),F},toArray:function(L){return te(L,function(F){return F})||[]},only:function(L){if(!U(L))throw Error("React.Children.only expected to receive a single React element child.");return L}},Re.Component=j,Re.Fragment=o,Re.Profiler=i,Re.PureComponent=T,Re.StrictMode=l,Re.Suspense=x,Re.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ie,Re.act=re,Re.cloneElement=function(L,F,H){if(L==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+L+".");var K=_({},L.props),J=L.key,he=L.ref,_e=L._owner;if(F!=null){if(F.ref!==void 0&&(he=F.ref,_e=I.current),F.key!==void 0&&(J=""+F.key),L.type&&L.type.defaultProps)var Ae=L.type.defaultProps;for(Pe in F)E.call(F,Pe)&&!M.hasOwnProperty(Pe)&&(K[Pe]=F[Pe]===void 0&&Ae!==void 0?Ae[Pe]:F[Pe])}var Pe=arguments.length-2;if(Pe===1)K.children=H;else if(1<Pe){Ae=Array(Pe);for(var pe=0;pe<Pe;pe++)Ae[pe]=arguments[pe+2];K.children=Ae}return{$$typeof:t,type:L.type,key:J,ref:he,props:K,_owner:_e}},Re.createContext=function(L){return L={$$typeof:u,_currentValue:L,_currentValue2:L,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},L.Provider={$$typeof:d,_context:L},L.Consumer=L},Re.createElement=q,Re.createFactory=function(L){var F=q.bind(null,L);return F.type=L,F},Re.createRef=function(){return{current:null}},Re.forwardRef=function(L){return{$$typeof:h,render:L}},Re.isValidElement=U,Re.lazy=function(L){return{$$typeof:v,_payload:{_status:-1,_result:L},_init:D}},Re.memo=function(L,F){return{$$typeof:g,type:L,compare:F===void 0?null:F}},Re.startTransition=function(L){var F=Y.transition;Y.transition={};try{L()}finally{Y.transition=F}},Re.unstable_act=re,Re.useCallback=function(L,F){return R.current.useCallback(L,F)},Re.useContext=function(L){return R.current.useContext(L)},Re.useDebugValue=function(){},Re.useDeferredValue=function(L){return R.current.useDeferredValue(L)},Re.useEffect=function(L,F){return R.current.useEffect(L,F)},Re.useId=function(){return R.current.useId()},Re.useImperativeHandle=function(L,F,H){return R.current.useImperativeHandle(L,F,H)},Re.useInsertionEffect=function(L,F){return R.current.useInsertionEffect(L,F)},Re.useLayoutEffect=function(L,F){return R.current.useLayoutEffect(L,F)},Re.useMemo=function(L,F){return R.current.useMemo(L,F)},Re.useReducer=function(L,F,H){return R.current.useReducer(L,F,H)},Re.useRef=function(L){return R.current.useRef(L)},Re.useState=function(L){return R.current.useState(L)},Re.useSyncExternalStore=function(L,F,H){return R.current.useSyncExternalStore(L,F,H)},Re.useTransition=function(){return R.current.useTransition()},Re.version="18.3.1",Re}var a0;function Fc(){return a0||(a0=1,lc.exports=Eg()),lc.exports}/**
10
- * @license React
11
- * react-jsx-runtime.production.min.js
12
- *
13
- * Copyright (c) Facebook, Inc. and its affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var l0;function Tg(){if(l0)return yo;l0=1;var t=Fc(),s=Symbol.for("react.element"),o=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,d={key:!0,ref:!0,__self:!0,__source:!0};function u(h,x,g){var v,y={},b=null,k=null;g!==void 0&&(b=""+g),x.key!==void 0&&(b=""+x.key),x.ref!==void 0&&(k=x.ref);for(v in x)l.call(x,v)&&!d.hasOwnProperty(v)&&(y[v]=x[v]);if(h&&h.defaultProps)for(v in x=h.defaultProps,x)y[v]===void 0&&(y[v]=x[v]);return{$$typeof:s,type:h,key:b,ref:k,props:y,_owner:i.current}}return yo.Fragment=o,yo.jsx=u,yo.jsxs=u,yo}var i0;function Ag(){return i0||(i0=1,ac.exports=Tg()),ac.exports}var e=Ag(),p=Fc();const bn=Nh(p),Pg=Lg({__proto__:null,default:bn},[p]);var qa={},ic={exports:{}},Ut={},cc={exports:{}},dc={};/**
18
- * @license React
19
- * scheduler.production.min.js
20
- *
21
- * Copyright (c) Facebook, Inc. and its affiliates.
22
- *
23
- * This source code is licensed under the MIT license found in the
24
- * LICENSE file in the root directory of this source tree.
25
- */var c0;function Mg(){return c0||(c0=1,(function(t){function s(Y,ie){var re=Y.length;Y.push(ie);e:for(;0<re;){var L=re-1>>>1,F=Y[L];if(0<i(F,ie))Y[L]=ie,Y[re]=F,re=L;else break e}}function o(Y){return Y.length===0?null:Y[0]}function l(Y){if(Y.length===0)return null;var ie=Y[0],re=Y.pop();if(re!==ie){Y[0]=re;e:for(var L=0,F=Y.length,H=F>>>1;L<H;){var K=2*(L+1)-1,J=Y[K],he=K+1,_e=Y[he];if(0>i(J,re))he<F&&0>i(_e,J)?(Y[L]=_e,Y[he]=re,L=he):(Y[L]=J,Y[K]=re,L=K);else if(he<F&&0>i(_e,re))Y[L]=_e,Y[he]=re,L=he;else break e}}return ie}function i(Y,ie){var re=Y.sortIndex-ie.sortIndex;return re!==0?re:Y.id-ie.id}if(typeof performance=="object"&&typeof performance.now=="function"){var d=performance;t.unstable_now=function(){return d.now()}}else{var u=Date,h=u.now();t.unstable_now=function(){return u.now()-h}}var x=[],g=[],v=1,y=null,b=3,k=!1,_=!1,S=!1,j=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function P(Y){for(var ie=o(g);ie!==null;){if(ie.callback===null)l(g);else if(ie.startTime<=Y)l(g),ie.sortIndex=ie.expirationTime,s(x,ie);else break;ie=o(g)}}function C(Y){if(S=!1,P(Y),!_)if(o(x)!==null)_=!0,D(E);else{var ie=o(g);ie!==null&&R(C,ie.startTime-Y)}}function E(Y,ie){_=!1,S&&(S=!1,N(q),q=-1),k=!0;var re=b;try{for(P(ie),y=o(x);y!==null&&(!(y.expirationTime>ie)||Y&&!O());){var L=y.callback;if(typeof L=="function"){y.callback=null,b=y.priorityLevel;var F=L(y.expirationTime<=ie);ie=t.unstable_now(),typeof F=="function"?y.callback=F:y===o(x)&&l(x),P(ie)}else l(x);y=o(x)}if(y!==null)var H=!0;else{var K=o(g);K!==null&&R(C,K.startTime-ie),H=!1}return H}finally{y=null,b=re,k=!1}}var I=!1,M=null,q=-1,z=5,U=-1;function O(){return!(t.unstable_now()-U<z)}function X(){if(M!==null){var Y=t.unstable_now();U=Y;var ie=!0;try{ie=M(!0,Y)}finally{ie?ee():(I=!1,M=null)}}else I=!1}var ee;if(typeof T=="function")ee=function(){T(X)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,te=W.port2;W.port1.onmessage=X,ee=function(){te.postMessage(null)}}else ee=function(){j(X,0)};function D(Y){M=Y,I||(I=!0,ee())}function R(Y,ie){q=j(function(){Y(t.unstable_now())},ie)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(Y){Y.callback=null},t.unstable_continueExecution=function(){_||k||(_=!0,D(E))},t.unstable_forceFrameRate=function(Y){0>Y||125<Y?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):z=0<Y?Math.floor(1e3/Y):5},t.unstable_getCurrentPriorityLevel=function(){return b},t.unstable_getFirstCallbackNode=function(){return o(x)},t.unstable_next=function(Y){switch(b){case 1:case 2:case 3:var ie=3;break;default:ie=b}var re=b;b=ie;try{return Y()}finally{b=re}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(Y,ie){switch(Y){case 1:case 2:case 3:case 4:case 5:break;default:Y=3}var re=b;b=Y;try{return ie()}finally{b=re}},t.unstable_scheduleCallback=function(Y,ie,re){var L=t.unstable_now();switch(typeof re=="object"&&re!==null?(re=re.delay,re=typeof re=="number"&&0<re?L+re:L):re=L,Y){case 1:var F=-1;break;case 2:F=250;break;case 5:F=1073741823;break;case 4:F=1e4;break;default:F=5e3}return F=re+F,Y={id:v++,callback:ie,priorityLevel:Y,startTime:re,expirationTime:F,sortIndex:-1},re>L?(Y.sortIndex=re,s(g,Y),o(x)===null&&Y===o(g)&&(S?(N(q),q=-1):S=!0,R(C,re-L))):(Y.sortIndex=F,s(x,Y),_||k||(_=!0,D(E))),Y},t.unstable_shouldYield=O,t.unstable_wrapCallback=function(Y){var ie=b;return function(){var re=b;b=ie;try{return Y.apply(this,arguments)}finally{b=re}}}})(dc)),dc}var d0;function Rg(){return d0||(d0=1,cc.exports=Mg()),cc.exports}/**
26
- * @license React
27
- * react-dom.production.min.js
28
- *
29
- * Copyright (c) Facebook, Inc. and its affiliates.
30
- *
31
- * This source code is licensed under the MIT license found in the
32
- * LICENSE file in the root directory of this source tree.
33
- */var u0;function Ig(){if(u0)return Ut;u0=1;var t=Fc(),s=Rg();function o(r){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+r,a=1;a<arguments.length;a++)n+="&args[]="+encodeURIComponent(arguments[a]);return"Minified React error #"+r+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var l=new Set,i={};function d(r,n){u(r,n),u(r+"Capture",n)}function u(r,n){for(i[r]=n,r=0;r<n.length;r++)l.add(n[r])}var h=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),x=Object.prototype.hasOwnProperty,g=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},y={};function b(r){return x.call(y,r)?!0:x.call(v,r)?!1:g.test(r)?y[r]=!0:(v[r]=!0,!1)}function k(r,n,a,c){if(a!==null&&a.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return c?!1:a!==null?!a.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function _(r,n,a,c){if(n===null||typeof n>"u"||k(r,n,a,c))return!0;if(c)return!1;if(a!==null)switch(a.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function S(r,n,a,c,m,f,w){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=c,this.attributeNamespace=m,this.mustUseProperty=a,this.propertyName=r,this.type=n,this.sanitizeURL=f,this.removeEmptyString=w}var j={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){j[r]=new S(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var n=r[0];j[n]=new S(n,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){j[r]=new S(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){j[r]=new S(r,2,!1,r,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(r){j[r]=new S(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){j[r]=new S(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){j[r]=new S(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){j[r]=new S(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){j[r]=new S(r,5,!1,r.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function T(r){return r[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(r){var n=r.replace(N,T);j[n]=new S(n,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var n=r.replace(N,T);j[n]=new S(n,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var n=r.replace(N,T);j[n]=new S(n,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){j[r]=new S(r,1,!1,r.toLowerCase(),null,!1,!1)}),j.xlinkHref=new S("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){j[r]=new S(r,1,!1,r.toLowerCase(),null,!0,!0)});function P(r,n,a,c){var m=j.hasOwnProperty(n)?j[n]:null;(m!==null?m.type!==0:c||!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(_(n,a,m,c)&&(a=null),c||m===null?b(n)&&(a===null?r.removeAttribute(n):r.setAttribute(n,""+a)):m.mustUseProperty?r[m.propertyName]=a===null?m.type===3?!1:"":a:(n=m.attributeName,c=m.attributeNamespace,a===null?r.removeAttribute(n):(m=m.type,a=m===3||m===4&&a===!0?"":""+a,c?r.setAttributeNS(c,n,a):r.setAttribute(n,a))))}var C=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,E=Symbol.for("react.element"),I=Symbol.for("react.portal"),M=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),U=Symbol.for("react.provider"),O=Symbol.for("react.context"),X=Symbol.for("react.forward_ref"),ee=Symbol.for("react.suspense"),W=Symbol.for("react.suspense_list"),te=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),R=Symbol.for("react.offscreen"),Y=Symbol.iterator;function ie(r){return r===null||typeof r!="object"?null:(r=Y&&r[Y]||r["@@iterator"],typeof r=="function"?r:null)}var re=Object.assign,L;function F(r){if(L===void 0)try{throw Error()}catch(a){var n=a.stack.trim().match(/\n( *(at )?)/);L=n&&n[1]||""}return`
34
- `+L+r}var H=!1;function K(r,n){if(!r||H)return"";H=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(n)if(n=function(){throw Error()},Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(n,[])}catch(Q){var c=Q}Reflect.construct(r,[],n)}else{try{n.call()}catch(Q){c=Q}r.call(n.prototype)}else{try{throw Error()}catch(Q){c=Q}r()}}catch(Q){if(Q&&c&&typeof Q.stack=="string"){for(var m=Q.stack.split(`
35
- `),f=c.stack.split(`
36
- `),w=m.length-1,A=f.length-1;1<=w&&0<=A&&m[w]!==f[A];)A--;for(;1<=w&&0<=A;w--,A--)if(m[w]!==f[A]){if(w!==1||A!==1)do if(w--,A--,0>A||m[w]!==f[A]){var $=`
37
- `+m[w].replace(" at new "," at ");return r.displayName&&$.includes("<anonymous>")&&($=$.replace("<anonymous>",r.displayName)),$}while(1<=w&&0<=A);break}}}finally{H=!1,Error.prepareStackTrace=a}return(r=r?r.displayName||r.name:"")?F(r):""}function J(r){switch(r.tag){case 5:return F(r.type);case 16:return F("Lazy");case 13:return F("Suspense");case 19:return F("SuspenseList");case 0:case 2:case 15:return r=K(r.type,!1),r;case 11:return r=K(r.type.render,!1),r;case 1:return r=K(r.type,!0),r;default:return""}}function he(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case M:return"Fragment";case I:return"Portal";case z:return"Profiler";case q:return"StrictMode";case ee:return"Suspense";case W:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case O:return(r.displayName||"Context")+".Consumer";case U:return(r._context.displayName||"Context")+".Provider";case X:var n=r.render;return r=r.displayName,r||(r=n.displayName||n.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case te:return n=r.displayName||null,n!==null?n:he(r.type)||"Memo";case D:n=r._payload,r=r._init;try{return he(r(n))}catch{}}return null}function _e(r){var n=r.type;switch(r.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=n.render,r=r.displayName||r.name||"",n.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===q?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Ae(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function Pe(r){var n=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function pe(r){var n=Pe(r)?"checked":"value",a=Object.getOwnPropertyDescriptor(r.constructor.prototype,n),c=""+r[n];if(!r.hasOwnProperty(n)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var m=a.get,f=a.set;return Object.defineProperty(r,n,{configurable:!0,get:function(){return m.call(this)},set:function(w){c=""+w,f.call(this,w)}}),Object.defineProperty(r,n,{enumerable:a.enumerable}),{getValue:function(){return c},setValue:function(w){c=""+w},stopTracking:function(){r._valueTracker=null,delete r[n]}}}}function se(r){r._valueTracker||(r._valueTracker=pe(r))}function Ne(r){if(!r)return!1;var n=r._valueTracker;if(!n)return!0;var a=n.getValue(),c="";return r&&(c=Pe(r)?r.checked?"true":"false":r.value),r=c,r!==a?(n.setValue(r),!0):!1}function Le(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function ot(r,n){var a=n.checked;return re({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:a??r._wrapperState.initialChecked})}function wt(r,n){var a=n.defaultValue==null?"":n.defaultValue,c=n.checked!=null?n.checked:n.defaultChecked;a=Ae(n.value!=null?n.value:a),r._wrapperState={initialChecked:c,initialValue:a,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function ae(r,n){n=n.checked,n!=null&&P(r,"checked",n,!1)}function Ee(r,n){ae(r,n);var a=Ae(n.value),c=n.type;if(a!=null)c==="number"?(a===0&&r.value===""||r.value!=a)&&(r.value=""+a):r.value!==""+a&&(r.value=""+a);else if(c==="submit"||c==="reset"){r.removeAttribute("value");return}n.hasOwnProperty("value")?at(r,n.type,a):n.hasOwnProperty("defaultValue")&&at(r,n.type,Ae(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(r.defaultChecked=!!n.defaultChecked)}function Ve(r,n,a){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var c=n.type;if(!(c!=="submit"&&c!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+r._wrapperState.initialValue,a||n===r.value||(r.value=n),r.defaultValue=n}a=r.name,a!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,a!==""&&(r.name=a)}function at(r,n,a){(n!=="number"||Le(r.ownerDocument)!==r)&&(a==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+a&&(r.defaultValue=""+a))}var xt=Array.isArray;function bt(r,n,a,c){if(r=r.options,n){n={};for(var m=0;m<a.length;m++)n["$"+a[m]]=!0;for(a=0;a<r.length;a++)m=n.hasOwnProperty("$"+r[a].value),r[a].selected!==m&&(r[a].selected=m),m&&c&&(r[a].defaultSelected=!0)}else{for(a=""+Ae(a),n=null,m=0;m<r.length;m++){if(r[m].value===a){r[m].selected=!0,c&&(r[m].defaultSelected=!0);return}n!==null||r[m].disabled||(n=r[m])}n!==null&&(n.selected=!0)}}function ue(r,n){if(n.dangerouslySetInnerHTML!=null)throw Error(o(91));return re({},n,{value:void 0,defaultValue:void 0,children:""+r._wrapperState.initialValue})}function $e(r,n){var a=n.value;if(a==null){if(a=n.children,n=n.defaultValue,a!=null){if(n!=null)throw Error(o(92));if(xt(a)){if(1<a.length)throw Error(o(93));a=a[0]}n=a}n==null&&(n=""),a=n}r._wrapperState={initialValue:Ae(a)}}function Pt(r,n){var a=Ae(n.value),c=Ae(n.defaultValue);a!=null&&(a=""+a,a!==r.value&&(r.value=a),n.defaultValue==null&&r.defaultValue!==a&&(r.defaultValue=a)),c!=null&&(r.defaultValue=""+c)}function lt(r){var n=r.textContent;n===r._wrapperState.initialValue&&n!==""&&n!==null&&(r.value=n)}function cr(r){switch(r){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function jt(r,n){return r==null||r==="http://www.w3.org/1999/xhtml"?cr(n):r==="http://www.w3.org/2000/svg"&&n==="foreignObject"?"http://www.w3.org/1999/xhtml":r}var Ar,js=(function(r){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(n,a,c,m){MSApp.execUnsafeLocalFunction(function(){return r(n,a,c,m)})}:r})(function(r,n){if(r.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in r)r.innerHTML=n;else{for(Ar=Ar||document.createElement("div"),Ar.innerHTML="<svg>"+n.valueOf().toString()+"</svg>",n=Ar.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;n.firstChild;)r.appendChild(n.firstChild)}});function vr(r,n){if(n){var a=r.firstChild;if(a&&a===r.lastChild&&a.nodeType===3){a.nodeValue=n;return}}r.textContent=n}var wr={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Gs=["Webkit","ms","Moz","O"];Object.keys(wr).forEach(function(r){Gs.forEach(function(n){n=n+r.charAt(0).toUpperCase()+r.substring(1),wr[n]=wr[r]})});function Ns(r,n,a){return n==null||typeof n=="boolean"||n===""?"":a||typeof n!="number"||n===0||wr.hasOwnProperty(r)&&wr[r]?(""+n).trim():n+"px"}function ks(r,n){r=r.style;for(var a in n)if(n.hasOwnProperty(a)){var c=a.indexOf("--")===0,m=Ns(a,n[a],c);a==="float"&&(a="cssFloat"),c?r.setProperty(a,m):r[a]=m}}var Dt=re({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function dr(r,n){if(n){if(Dt[r]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,r));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function ne(r,n){if(r.indexOf("-")===-1)return typeof n.is=="string";switch(r){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Me=null;function Ie(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var be=null,Be=null,Pr=null;function Yt(r){if(r=ro(r)){if(typeof be!="function")throw Error(o(280));var n=r.stateNode;n&&(n=la(n),be(r.stateNode,r.type,n))}}function Nd(r){Be?Pr?Pr.push(r):Pr=[r]:Be=r}function kd(){if(Be){var r=Be,n=Pr;if(Pr=Be=null,Yt(r),n)for(r=0;r<n.length;r++)Yt(n[r])}}function Cd(r,n){return r(n)}function Sd(){}var Nl=!1;function _d(r,n,a){if(Nl)return r(n,a);Nl=!0;try{return Cd(r,n,a)}finally{Nl=!1,(Be!==null||Pr!==null)&&(Sd(),kd())}}function In(r,n){var a=r.stateNode;if(a===null)return null;var c=la(a);if(c===null)return null;a=c[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(r=r.type,c=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!c;break e;default:r=!1}if(r)return null;if(a&&typeof a!="function")throw Error(o(231,n,typeof a));return a}var kl=!1;if(h)try{var $n={};Object.defineProperty($n,"passive",{get:function(){kl=!0}}),window.addEventListener("test",$n,$n),window.removeEventListener("test",$n,$n)}catch{kl=!1}function Mx(r,n,a,c,m,f,w,A,$){var Q=Array.prototype.slice.call(arguments,3);try{n.apply(a,Q)}catch(le){this.onError(le)}}var Bn=!1,Oo=null,Fo=!1,Cl=null,Rx={onError:function(r){Bn=!0,Oo=r}};function Ix(r,n,a,c,m,f,w,A,$){Bn=!1,Oo=null,Mx.apply(Rx,arguments)}function $x(r,n,a,c,m,f,w,A,$){if(Ix.apply(this,arguments),Bn){if(Bn){var Q=Oo;Bn=!1,Oo=null}else throw Error(o(198));Fo||(Fo=!0,Cl=Q)}}function Cs(r){var n=r,a=r;if(r.alternate)for(;n.return;)n=n.return;else{r=n;do n=r,(n.flags&4098)!==0&&(a=n.return),r=n.return;while(r)}return n.tag===3?a:null}function Ld(r){if(r.tag===13){var n=r.memoizedState;if(n===null&&(r=r.alternate,r!==null&&(n=r.memoizedState)),n!==null)return n.dehydrated}return null}function Ed(r){if(Cs(r)!==r)throw Error(o(188))}function Bx(r){var n=r.alternate;if(!n){if(n=Cs(r),n===null)throw Error(o(188));return n!==r?null:r}for(var a=r,c=n;;){var m=a.return;if(m===null)break;var f=m.alternate;if(f===null){if(c=m.return,c!==null){a=c;continue}break}if(m.child===f.child){for(f=m.child;f;){if(f===a)return Ed(m),r;if(f===c)return Ed(m),n;f=f.sibling}throw Error(o(188))}if(a.return!==c.return)a=m,c=f;else{for(var w=!1,A=m.child;A;){if(A===a){w=!0,a=m,c=f;break}if(A===c){w=!0,c=m,a=f;break}A=A.sibling}if(!w){for(A=f.child;A;){if(A===a){w=!0,a=f,c=m;break}if(A===c){w=!0,c=f,a=m;break}A=A.sibling}if(!w)throw Error(o(189))}}if(a.alternate!==c)throw Error(o(190))}if(a.tag!==3)throw Error(o(188));return a.stateNode.current===a?r:n}function Td(r){return r=Bx(r),r!==null?Ad(r):null}function Ad(r){if(r.tag===5||r.tag===6)return r;for(r=r.child;r!==null;){var n=Ad(r);if(n!==null)return n;r=r.sibling}return null}var Pd=s.unstable_scheduleCallback,Md=s.unstable_cancelCallback,Dx=s.unstable_shouldYield,Ox=s.unstable_requestPaint,Xe=s.unstable_now,Fx=s.unstable_getCurrentPriorityLevel,Sl=s.unstable_ImmediatePriority,Rd=s.unstable_UserBlockingPriority,Wo=s.unstable_NormalPriority,Wx=s.unstable_LowPriority,Id=s.unstable_IdlePriority,zo=null,br=null;function zx(r){if(br&&typeof br.onCommitFiberRoot=="function")try{br.onCommitFiberRoot(zo,r,void 0,(r.current.flags&128)===128)}catch{}}var ur=Math.clz32?Math.clz32:Vx,Hx=Math.log,Ux=Math.LN2;function Vx(r){return r>>>=0,r===0?32:31-(Hx(r)/Ux|0)|0}var Ho=64,Uo=4194304;function Dn(r){switch(r&-r){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function Vo(r,n){var a=r.pendingLanes;if(a===0)return 0;var c=0,m=r.suspendedLanes,f=r.pingedLanes,w=a&268435455;if(w!==0){var A=w&~m;A!==0?c=Dn(A):(f&=w,f!==0&&(c=Dn(f)))}else w=a&~m,w!==0?c=Dn(w):f!==0&&(c=Dn(f));if(c===0)return 0;if(n!==0&&n!==c&&(n&m)===0&&(m=c&-c,f=n&-n,m>=f||m===16&&(f&4194240)!==0))return n;if((c&4)!==0&&(c|=a&16),n=r.entangledLanes,n!==0)for(r=r.entanglements,n&=c;0<n;)a=31-ur(n),m=1<<a,c|=r[a],n&=~m;return c}function qx(r,n){switch(r){case 1:case 2:case 4:return n+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Yx(r,n){for(var a=r.suspendedLanes,c=r.pingedLanes,m=r.expirationTimes,f=r.pendingLanes;0<f;){var w=31-ur(f),A=1<<w,$=m[w];$===-1?((A&a)===0||(A&c)!==0)&&(m[w]=qx(A,n)):$<=n&&(r.expiredLanes|=A),f&=~A}}function _l(r){return r=r.pendingLanes&-1073741825,r!==0?r:r&1073741824?1073741824:0}function $d(){var r=Ho;return Ho<<=1,(Ho&4194240)===0&&(Ho=64),r}function Ll(r){for(var n=[],a=0;31>a;a++)n.push(r);return n}function On(r,n,a){r.pendingLanes|=n,n!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,n=31-ur(n),r[n]=a}function Gx(r,n){var a=r.pendingLanes&~n;r.pendingLanes=n,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=n,r.mutableReadLanes&=n,r.entangledLanes&=n,n=r.entanglements;var c=r.eventTimes;for(r=r.expirationTimes;0<a;){var m=31-ur(a),f=1<<m;n[m]=0,c[m]=-1,r[m]=-1,a&=~f}}function El(r,n){var a=r.entangledLanes|=n;for(r=r.entanglements;a;){var c=31-ur(a),m=1<<c;m&n|r[c]&n&&(r[c]|=n),a&=~m}}var ze=0;function Bd(r){return r&=-r,1<r?4<r?(r&268435455)!==0?16:536870912:4:1}var Dd,Tl,Od,Fd,Wd,Al=!1,qo=[],qr=null,Yr=null,Gr=null,Fn=new Map,Wn=new Map,Kr=[],Kx="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function zd(r,n){switch(r){case"focusin":case"focusout":qr=null;break;case"dragenter":case"dragleave":Yr=null;break;case"mouseover":case"mouseout":Gr=null;break;case"pointerover":case"pointerout":Fn.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":Wn.delete(n.pointerId)}}function zn(r,n,a,c,m,f){return r===null||r.nativeEvent!==f?(r={blockedOn:n,domEventName:a,eventSystemFlags:c,nativeEvent:f,targetContainers:[m]},n!==null&&(n=ro(n),n!==null&&Tl(n)),r):(r.eventSystemFlags|=c,n=r.targetContainers,m!==null&&n.indexOf(m)===-1&&n.push(m),r)}function Jx(r,n,a,c,m){switch(n){case"focusin":return qr=zn(qr,r,n,a,c,m),!0;case"dragenter":return Yr=zn(Yr,r,n,a,c,m),!0;case"mouseover":return Gr=zn(Gr,r,n,a,c,m),!0;case"pointerover":var f=m.pointerId;return Fn.set(f,zn(Fn.get(f)||null,r,n,a,c,m)),!0;case"gotpointercapture":return f=m.pointerId,Wn.set(f,zn(Wn.get(f)||null,r,n,a,c,m)),!0}return!1}function Hd(r){var n=Ss(r.target);if(n!==null){var a=Cs(n);if(a!==null){if(n=a.tag,n===13){if(n=Ld(a),n!==null){r.blockedOn=n,Wd(r.priority,function(){Od(a)});return}}else if(n===3&&a.stateNode.current.memoizedState.isDehydrated){r.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}r.blockedOn=null}function Yo(r){if(r.blockedOn!==null)return!1;for(var n=r.targetContainers;0<n.length;){var a=Ml(r.domEventName,r.eventSystemFlags,n[0],r.nativeEvent);if(a===null){a=r.nativeEvent;var c=new a.constructor(a.type,a);Me=c,a.target.dispatchEvent(c),Me=null}else return n=ro(a),n!==null&&Tl(n),r.blockedOn=a,!1;n.shift()}return!0}function Ud(r,n,a){Yo(r)&&a.delete(n)}function Qx(){Al=!1,qr!==null&&Yo(qr)&&(qr=null),Yr!==null&&Yo(Yr)&&(Yr=null),Gr!==null&&Yo(Gr)&&(Gr=null),Fn.forEach(Ud),Wn.forEach(Ud)}function Hn(r,n){r.blockedOn===n&&(r.blockedOn=null,Al||(Al=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,Qx)))}function Un(r){function n(m){return Hn(m,r)}if(0<qo.length){Hn(qo[0],r);for(var a=1;a<qo.length;a++){var c=qo[a];c.blockedOn===r&&(c.blockedOn=null)}}for(qr!==null&&Hn(qr,r),Yr!==null&&Hn(Yr,r),Gr!==null&&Hn(Gr,r),Fn.forEach(n),Wn.forEach(n),a=0;a<Kr.length;a++)c=Kr[a],c.blockedOn===r&&(c.blockedOn=null);for(;0<Kr.length&&(a=Kr[0],a.blockedOn===null);)Hd(a),a.blockedOn===null&&Kr.shift()}var Ks=C.ReactCurrentBatchConfig,Go=!0;function Xx(r,n,a,c){var m=ze,f=Ks.transition;Ks.transition=null;try{ze=1,Pl(r,n,a,c)}finally{ze=m,Ks.transition=f}}function Zx(r,n,a,c){var m=ze,f=Ks.transition;Ks.transition=null;try{ze=4,Pl(r,n,a,c)}finally{ze=m,Ks.transition=f}}function Pl(r,n,a,c){if(Go){var m=Ml(r,n,a,c);if(m===null)Jl(r,n,c,Ko,a),zd(r,c);else if(Jx(m,r,n,a,c))c.stopPropagation();else if(zd(r,c),n&4&&-1<Kx.indexOf(r)){for(;m!==null;){var f=ro(m);if(f!==null&&Dd(f),f=Ml(r,n,a,c),f===null&&Jl(r,n,c,Ko,a),f===m)break;m=f}m!==null&&c.stopPropagation()}else Jl(r,n,c,null,a)}}var Ko=null;function Ml(r,n,a,c){if(Ko=null,r=Ie(c),r=Ss(r),r!==null)if(n=Cs(r),n===null)r=null;else if(a=n.tag,a===13){if(r=Ld(n),r!==null)return r;r=null}else if(a===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;r=null}else n!==r&&(r=null);return Ko=r,null}function Vd(r){switch(r){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Fx()){case Sl:return 1;case Rd:return 4;case Wo:case Wx:return 16;case Id:return 536870912;default:return 16}default:return 16}}var Jr=null,Rl=null,Jo=null;function qd(){if(Jo)return Jo;var r,n=Rl,a=n.length,c,m="value"in Jr?Jr.value:Jr.textContent,f=m.length;for(r=0;r<a&&n[r]===m[r];r++);var w=a-r;for(c=1;c<=w&&n[a-c]===m[f-c];c++);return Jo=m.slice(r,1<c?1-c:void 0)}function Qo(r){var n=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&n===13&&(r=13)):r=n,r===10&&(r=13),32<=r||r===13?r:0}function Xo(){return!0}function Yd(){return!1}function Gt(r){function n(a,c,m,f,w){this._reactName=a,this._targetInst=m,this.type=c,this.nativeEvent=f,this.target=w,this.currentTarget=null;for(var A in r)r.hasOwnProperty(A)&&(a=r[A],this[A]=a?a(f):f[A]);return this.isDefaultPrevented=(f.defaultPrevented!=null?f.defaultPrevented:f.returnValue===!1)?Xo:Yd,this.isPropagationStopped=Yd,this}return re(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Xo)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Xo)},persist:function(){},isPersistent:Xo}),n}var Js={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Il=Gt(Js),Vn=re({},Js,{view:0,detail:0}),ef=Gt(Vn),$l,Bl,qn,Zo=re({},Vn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ol,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==qn&&(qn&&r.type==="mousemove"?($l=r.screenX-qn.screenX,Bl=r.screenY-qn.screenY):Bl=$l=0,qn=r),$l)},movementY:function(r){return"movementY"in r?r.movementY:Bl}}),Gd=Gt(Zo),tf=re({},Zo,{dataTransfer:0}),rf=Gt(tf),sf=re({},Vn,{relatedTarget:0}),Dl=Gt(sf),nf=re({},Js,{animationName:0,elapsedTime:0,pseudoElement:0}),of=Gt(nf),af=re({},Js,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),lf=Gt(af),cf=re({},Js,{data:0}),Kd=Gt(cf),df={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},uf={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},mf={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function hf(r){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(r):(r=mf[r])?!!n[r]:!1}function Ol(){return hf}var pf=re({},Vn,{key:function(r){if(r.key){var n=df[r.key]||r.key;if(n!=="Unidentified")return n}return r.type==="keypress"?(r=Qo(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?uf[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ol,charCode:function(r){return r.type==="keypress"?Qo(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?Qo(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),xf=Gt(pf),ff=re({},Zo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Jd=Gt(ff),gf=re({},Vn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ol}),yf=Gt(gf),vf=re({},Js,{propertyName:0,elapsedTime:0,pseudoElement:0}),wf=Gt(vf),bf=re({},Zo,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),jf=Gt(bf),Nf=[9,13,27,32],Fl=h&&"CompositionEvent"in window,Yn=null;h&&"documentMode"in document&&(Yn=document.documentMode);var kf=h&&"TextEvent"in window&&!Yn,Qd=h&&(!Fl||Yn&&8<Yn&&11>=Yn),Xd=" ",Zd=!1;function eu(r,n){switch(r){case"keyup":return Nf.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function tu(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Qs=!1;function Cf(r,n){switch(r){case"compositionend":return tu(n);case"keypress":return n.which!==32?null:(Zd=!0,Xd);case"textInput":return r=n.data,r===Xd&&Zd?null:r;default:return null}}function Sf(r,n){if(Qs)return r==="compositionend"||!Fl&&eu(r,n)?(r=qd(),Jo=Rl=Jr=null,Qs=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return Qd&&n.locale!=="ko"?null:n.data;default:return null}}var _f={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function ru(r){var n=r&&r.nodeName&&r.nodeName.toLowerCase();return n==="input"?!!_f[r.type]:n==="textarea"}function su(r,n,a,c){Nd(c),n=na(n,"onChange"),0<n.length&&(a=new Il("onChange","change",null,a,c),r.push({event:a,listeners:n}))}var Gn=null,Kn=null;function Lf(r){bu(r,0)}function ea(r){var n=rn(r);if(Ne(n))return r}function Ef(r,n){if(r==="change")return n}var nu=!1;if(h){var Wl;if(h){var zl="oninput"in document;if(!zl){var ou=document.createElement("div");ou.setAttribute("oninput","return;"),zl=typeof ou.oninput=="function"}Wl=zl}else Wl=!1;nu=Wl&&(!document.documentMode||9<document.documentMode)}function au(){Gn&&(Gn.detachEvent("onpropertychange",lu),Kn=Gn=null)}function lu(r){if(r.propertyName==="value"&&ea(Kn)){var n=[];su(n,Kn,r,Ie(r)),_d(Lf,n)}}function Tf(r,n,a){r==="focusin"?(au(),Gn=n,Kn=a,Gn.attachEvent("onpropertychange",lu)):r==="focusout"&&au()}function Af(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return ea(Kn)}function Pf(r,n){if(r==="click")return ea(n)}function Mf(r,n){if(r==="input"||r==="change")return ea(n)}function Rf(r,n){return r===n&&(r!==0||1/r===1/n)||r!==r&&n!==n}var mr=typeof Object.is=="function"?Object.is:Rf;function Jn(r,n){if(mr(r,n))return!0;if(typeof r!="object"||r===null||typeof n!="object"||n===null)return!1;var a=Object.keys(r),c=Object.keys(n);if(a.length!==c.length)return!1;for(c=0;c<a.length;c++){var m=a[c];if(!x.call(n,m)||!mr(r[m],n[m]))return!1}return!0}function iu(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function cu(r,n){var a=iu(r);r=0;for(var c;a;){if(a.nodeType===3){if(c=r+a.textContent.length,r<=n&&c>=n)return{node:a,offset:n-r};r=c}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=iu(a)}}function du(r,n){return r&&n?r===n?!0:r&&r.nodeType===3?!1:n&&n.nodeType===3?du(r,n.parentNode):"contains"in r?r.contains(n):r.compareDocumentPosition?!!(r.compareDocumentPosition(n)&16):!1:!1}function uu(){for(var r=window,n=Le();n instanceof r.HTMLIFrameElement;){try{var a=typeof n.contentWindow.location.href=="string"}catch{a=!1}if(a)r=n.contentWindow;else break;n=Le(r.document)}return n}function Hl(r){var n=r&&r.nodeName&&r.nodeName.toLowerCase();return n&&(n==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||n==="textarea"||r.contentEditable==="true")}function If(r){var n=uu(),a=r.focusedElem,c=r.selectionRange;if(n!==a&&a&&a.ownerDocument&&du(a.ownerDocument.documentElement,a)){if(c!==null&&Hl(a)){if(n=c.start,r=c.end,r===void 0&&(r=n),"selectionStart"in a)a.selectionStart=n,a.selectionEnd=Math.min(r,a.value.length);else if(r=(n=a.ownerDocument||document)&&n.defaultView||window,r.getSelection){r=r.getSelection();var m=a.textContent.length,f=Math.min(c.start,m);c=c.end===void 0?f:Math.min(c.end,m),!r.extend&&f>c&&(m=c,c=f,f=m),m=cu(a,f);var w=cu(a,c);m&&w&&(r.rangeCount!==1||r.anchorNode!==m.node||r.anchorOffset!==m.offset||r.focusNode!==w.node||r.focusOffset!==w.offset)&&(n=n.createRange(),n.setStart(m.node,m.offset),r.removeAllRanges(),f>c?(r.addRange(n),r.extend(w.node,w.offset)):(n.setEnd(w.node,w.offset),r.addRange(n)))}}for(n=[],r=a;r=r.parentNode;)r.nodeType===1&&n.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof a.focus=="function"&&a.focus(),a=0;a<n.length;a++)r=n[a],r.element.scrollLeft=r.left,r.element.scrollTop=r.top}}var $f=h&&"documentMode"in document&&11>=document.documentMode,Xs=null,Ul=null,Qn=null,Vl=!1;function mu(r,n,a){var c=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Vl||Xs==null||Xs!==Le(c)||(c=Xs,"selectionStart"in c&&Hl(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),Qn&&Jn(Qn,c)||(Qn=c,c=na(Ul,"onSelect"),0<c.length&&(n=new Il("onSelect","select",null,n,a),r.push({event:n,listeners:c}),n.target=Xs)))}function ta(r,n){var a={};return a[r.toLowerCase()]=n.toLowerCase(),a["Webkit"+r]="webkit"+n,a["Moz"+r]="moz"+n,a}var Zs={animationend:ta("Animation","AnimationEnd"),animationiteration:ta("Animation","AnimationIteration"),animationstart:ta("Animation","AnimationStart"),transitionend:ta("Transition","TransitionEnd")},ql={},hu={};h&&(hu=document.createElement("div").style,"AnimationEvent"in window||(delete Zs.animationend.animation,delete Zs.animationiteration.animation,delete Zs.animationstart.animation),"TransitionEvent"in window||delete Zs.transitionend.transition);function ra(r){if(ql[r])return ql[r];if(!Zs[r])return r;var n=Zs[r],a;for(a in n)if(n.hasOwnProperty(a)&&a in hu)return ql[r]=n[a];return r}var pu=ra("animationend"),xu=ra("animationiteration"),fu=ra("animationstart"),gu=ra("transitionend"),yu=new Map,vu="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Qr(r,n){yu.set(r,n),d(n,[r])}for(var Yl=0;Yl<vu.length;Yl++){var Gl=vu[Yl],Bf=Gl.toLowerCase(),Df=Gl[0].toUpperCase()+Gl.slice(1);Qr(Bf,"on"+Df)}Qr(pu,"onAnimationEnd"),Qr(xu,"onAnimationIteration"),Qr(fu,"onAnimationStart"),Qr("dblclick","onDoubleClick"),Qr("focusin","onFocus"),Qr("focusout","onBlur"),Qr(gu,"onTransitionEnd"),u("onMouseEnter",["mouseout","mouseover"]),u("onMouseLeave",["mouseout","mouseover"]),u("onPointerEnter",["pointerout","pointerover"]),u("onPointerLeave",["pointerout","pointerover"]),d("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),d("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),d("onBeforeInput",["compositionend","keypress","textInput","paste"]),d("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),d("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),d("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Xn="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Of=new Set("cancel close invalid load scroll toggle".split(" ").concat(Xn));function wu(r,n,a){var c=r.type||"unknown-event";r.currentTarget=a,$x(c,n,void 0,r),r.currentTarget=null}function bu(r,n){n=(n&4)!==0;for(var a=0;a<r.length;a++){var c=r[a],m=c.event;c=c.listeners;e:{var f=void 0;if(n)for(var w=c.length-1;0<=w;w--){var A=c[w],$=A.instance,Q=A.currentTarget;if(A=A.listener,$!==f&&m.isPropagationStopped())break e;wu(m,A,Q),f=$}else for(w=0;w<c.length;w++){if(A=c[w],$=A.instance,Q=A.currentTarget,A=A.listener,$!==f&&m.isPropagationStopped())break e;wu(m,A,Q),f=$}}}if(Fo)throw r=Cl,Fo=!1,Cl=null,r}function qe(r,n){var a=n[ri];a===void 0&&(a=n[ri]=new Set);var c=r+"__bubble";a.has(c)||(ju(n,r,2,!1),a.add(c))}function Kl(r,n,a){var c=0;n&&(c|=4),ju(a,r,c,n)}var sa="_reactListening"+Math.random().toString(36).slice(2);function Zn(r){if(!r[sa]){r[sa]=!0,l.forEach(function(a){a!=="selectionchange"&&(Of.has(a)||Kl(a,!1,r),Kl(a,!0,r))});var n=r.nodeType===9?r:r.ownerDocument;n===null||n[sa]||(n[sa]=!0,Kl("selectionchange",!1,n))}}function ju(r,n,a,c){switch(Vd(n)){case 1:var m=Xx;break;case 4:m=Zx;break;default:m=Pl}a=m.bind(null,n,a,r),m=void 0,!kl||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(m=!0),c?m!==void 0?r.addEventListener(n,a,{capture:!0,passive:m}):r.addEventListener(n,a,!0):m!==void 0?r.addEventListener(n,a,{passive:m}):r.addEventListener(n,a,!1)}function Jl(r,n,a,c,m){var f=c;if((n&1)===0&&(n&2)===0&&c!==null)e:for(;;){if(c===null)return;var w=c.tag;if(w===3||w===4){var A=c.stateNode.containerInfo;if(A===m||A.nodeType===8&&A.parentNode===m)break;if(w===4)for(w=c.return;w!==null;){var $=w.tag;if(($===3||$===4)&&($=w.stateNode.containerInfo,$===m||$.nodeType===8&&$.parentNode===m))return;w=w.return}for(;A!==null;){if(w=Ss(A),w===null)return;if($=w.tag,$===5||$===6){c=f=w;continue e}A=A.parentNode}}c=c.return}_d(function(){var Q=f,le=Ie(a),de=[];e:{var oe=yu.get(r);if(oe!==void 0){var xe=Il,ge=r;switch(r){case"keypress":if(Qo(a)===0)break e;case"keydown":case"keyup":xe=xf;break;case"focusin":ge="focus",xe=Dl;break;case"focusout":ge="blur",xe=Dl;break;case"beforeblur":case"afterblur":xe=Dl;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":xe=Gd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":xe=rf;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":xe=yf;break;case pu:case xu:case fu:xe=of;break;case gu:xe=wf;break;case"scroll":xe=ef;break;case"wheel":xe=jf;break;case"copy":case"cut":case"paste":xe=lf;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":xe=Jd}var ye=(n&4)!==0,Ze=!ye&&r==="scroll",V=ye?oe!==null?oe+"Capture":null:oe;ye=[];for(var B=Q,G;B!==null;){G=B;var me=G.stateNode;if(G.tag===5&&me!==null&&(G=me,V!==null&&(me=In(B,V),me!=null&&ye.push(eo(B,me,G)))),Ze)break;B=B.return}0<ye.length&&(oe=new xe(oe,ge,null,a,le),de.push({event:oe,listeners:ye}))}}if((n&7)===0){e:{if(oe=r==="mouseover"||r==="pointerover",xe=r==="mouseout"||r==="pointerout",oe&&a!==Me&&(ge=a.relatedTarget||a.fromElement)&&(Ss(ge)||ge[Mr]))break e;if((xe||oe)&&(oe=le.window===le?le:(oe=le.ownerDocument)?oe.defaultView||oe.parentWindow:window,xe?(ge=a.relatedTarget||a.toElement,xe=Q,ge=ge?Ss(ge):null,ge!==null&&(Ze=Cs(ge),ge!==Ze||ge.tag!==5&&ge.tag!==6)&&(ge=null)):(xe=null,ge=Q),xe!==ge)){if(ye=Gd,me="onMouseLeave",V="onMouseEnter",B="mouse",(r==="pointerout"||r==="pointerover")&&(ye=Jd,me="onPointerLeave",V="onPointerEnter",B="pointer"),Ze=xe==null?oe:rn(xe),G=ge==null?oe:rn(ge),oe=new ye(me,B+"leave",xe,a,le),oe.target=Ze,oe.relatedTarget=G,me=null,Ss(le)===Q&&(ye=new ye(V,B+"enter",ge,a,le),ye.target=G,ye.relatedTarget=Ze,me=ye),Ze=me,xe&&ge)t:{for(ye=xe,V=ge,B=0,G=ye;G;G=en(G))B++;for(G=0,me=V;me;me=en(me))G++;for(;0<B-G;)ye=en(ye),B--;for(;0<G-B;)V=en(V),G--;for(;B--;){if(ye===V||V!==null&&ye===V.alternate)break t;ye=en(ye),V=en(V)}ye=null}else ye=null;xe!==null&&Nu(de,oe,xe,ye,!1),ge!==null&&Ze!==null&&Nu(de,Ze,ge,ye,!0)}}e:{if(oe=Q?rn(Q):window,xe=oe.nodeName&&oe.nodeName.toLowerCase(),xe==="select"||xe==="input"&&oe.type==="file")var ve=Ef;else if(ru(oe))if(nu)ve=Mf;else{ve=Af;var ke=Tf}else(xe=oe.nodeName)&&xe.toLowerCase()==="input"&&(oe.type==="checkbox"||oe.type==="radio")&&(ve=Pf);if(ve&&(ve=ve(r,Q))){su(de,ve,a,le);break e}ke&&ke(r,oe,Q),r==="focusout"&&(ke=oe._wrapperState)&&ke.controlled&&oe.type==="number"&&at(oe,"number",oe.value)}switch(ke=Q?rn(Q):window,r){case"focusin":(ru(ke)||ke.contentEditable==="true")&&(Xs=ke,Ul=Q,Qn=null);break;case"focusout":Qn=Ul=Xs=null;break;case"mousedown":Vl=!0;break;case"contextmenu":case"mouseup":case"dragend":Vl=!1,mu(de,a,le);break;case"selectionchange":if($f)break;case"keydown":case"keyup":mu(de,a,le)}var Ce;if(Fl)e:{switch(r){case"compositionstart":var Te="onCompositionStart";break e;case"compositionend":Te="onCompositionEnd";break e;case"compositionupdate":Te="onCompositionUpdate";break e}Te=void 0}else Qs?eu(r,a)&&(Te="onCompositionEnd"):r==="keydown"&&a.keyCode===229&&(Te="onCompositionStart");Te&&(Qd&&a.locale!=="ko"&&(Qs||Te!=="onCompositionStart"?Te==="onCompositionEnd"&&Qs&&(Ce=qd()):(Jr=le,Rl="value"in Jr?Jr.value:Jr.textContent,Qs=!0)),ke=na(Q,Te),0<ke.length&&(Te=new Kd(Te,r,null,a,le),de.push({event:Te,listeners:ke}),Ce?Te.data=Ce:(Ce=tu(a),Ce!==null&&(Te.data=Ce)))),(Ce=kf?Cf(r,a):Sf(r,a))&&(Q=na(Q,"onBeforeInput"),0<Q.length&&(le=new Kd("onBeforeInput","beforeinput",null,a,le),de.push({event:le,listeners:Q}),le.data=Ce))}bu(de,n)})}function eo(r,n,a){return{instance:r,listener:n,currentTarget:a}}function na(r,n){for(var a=n+"Capture",c=[];r!==null;){var m=r,f=m.stateNode;m.tag===5&&f!==null&&(m=f,f=In(r,a),f!=null&&c.unshift(eo(r,f,m)),f=In(r,n),f!=null&&c.push(eo(r,f,m))),r=r.return}return c}function en(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5);return r||null}function Nu(r,n,a,c,m){for(var f=n._reactName,w=[];a!==null&&a!==c;){var A=a,$=A.alternate,Q=A.stateNode;if($!==null&&$===c)break;A.tag===5&&Q!==null&&(A=Q,m?($=In(a,f),$!=null&&w.unshift(eo(a,$,A))):m||($=In(a,f),$!=null&&w.push(eo(a,$,A)))),a=a.return}w.length!==0&&r.push({event:n,listeners:w})}var Ff=/\r\n?/g,Wf=/\u0000|\uFFFD/g;function ku(r){return(typeof r=="string"?r:""+r).replace(Ff,`
38
- `).replace(Wf,"")}function oa(r,n,a){if(n=ku(n),ku(r)!==n&&a)throw Error(o(425))}function aa(){}var Ql=null,Xl=null;function Zl(r,n){return r==="textarea"||r==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var ei=typeof setTimeout=="function"?setTimeout:void 0,zf=typeof clearTimeout=="function"?clearTimeout:void 0,Cu=typeof Promise=="function"?Promise:void 0,Hf=typeof queueMicrotask=="function"?queueMicrotask:typeof Cu<"u"?function(r){return Cu.resolve(null).then(r).catch(Uf)}:ei;function Uf(r){setTimeout(function(){throw r})}function ti(r,n){var a=n,c=0;do{var m=a.nextSibling;if(r.removeChild(a),m&&m.nodeType===8)if(a=m.data,a==="/$"){if(c===0){r.removeChild(m),Un(n);return}c--}else a!=="$"&&a!=="$?"&&a!=="$!"||c++;a=m}while(a);Un(n)}function Xr(r){for(;r!=null;r=r.nextSibling){var n=r.nodeType;if(n===1||n===3)break;if(n===8){if(n=r.data,n==="$"||n==="$!"||n==="$?")break;if(n==="/$")return null}}return r}function Su(r){r=r.previousSibling;for(var n=0;r;){if(r.nodeType===8){var a=r.data;if(a==="$"||a==="$!"||a==="$?"){if(n===0)return r;n--}else a==="/$"&&n++}r=r.previousSibling}return null}var tn=Math.random().toString(36).slice(2),jr="__reactFiber$"+tn,to="__reactProps$"+tn,Mr="__reactContainer$"+tn,ri="__reactEvents$"+tn,Vf="__reactListeners$"+tn,qf="__reactHandles$"+tn;function Ss(r){var n=r[jr];if(n)return n;for(var a=r.parentNode;a;){if(n=a[Mr]||a[jr]){if(a=n.alternate,n.child!==null||a!==null&&a.child!==null)for(r=Su(r);r!==null;){if(a=r[jr])return a;r=Su(r)}return n}r=a,a=r.parentNode}return null}function ro(r){return r=r[jr]||r[Mr],!r||r.tag!==5&&r.tag!==6&&r.tag!==13&&r.tag!==3?null:r}function rn(r){if(r.tag===5||r.tag===6)return r.stateNode;throw Error(o(33))}function la(r){return r[to]||null}var si=[],sn=-1;function Zr(r){return{current:r}}function Ye(r){0>sn||(r.current=si[sn],si[sn]=null,sn--)}function He(r,n){sn++,si[sn]=r.current,r.current=n}var es={},St=Zr(es),Ot=Zr(!1),_s=es;function nn(r,n){var a=r.type.contextTypes;if(!a)return es;var c=r.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===n)return c.__reactInternalMemoizedMaskedChildContext;var m={},f;for(f in a)m[f]=n[f];return c&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=n,r.__reactInternalMemoizedMaskedChildContext=m),m}function Ft(r){return r=r.childContextTypes,r!=null}function ia(){Ye(Ot),Ye(St)}function _u(r,n,a){if(St.current!==es)throw Error(o(168));He(St,n),He(Ot,a)}function Lu(r,n,a){var c=r.stateNode;if(n=n.childContextTypes,typeof c.getChildContext!="function")return a;c=c.getChildContext();for(var m in c)if(!(m in n))throw Error(o(108,_e(r)||"Unknown",m));return re({},a,c)}function ca(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||es,_s=St.current,He(St,r),He(Ot,Ot.current),!0}function Eu(r,n,a){var c=r.stateNode;if(!c)throw Error(o(169));a?(r=Lu(r,n,_s),c.__reactInternalMemoizedMergedChildContext=r,Ye(Ot),Ye(St),He(St,r)):Ye(Ot),He(Ot,a)}var Rr=null,da=!1,ni=!1;function Tu(r){Rr===null?Rr=[r]:Rr.push(r)}function Yf(r){da=!0,Tu(r)}function ts(){if(!ni&&Rr!==null){ni=!0;var r=0,n=ze;try{var a=Rr;for(ze=1;r<a.length;r++){var c=a[r];do c=c(!0);while(c!==null)}Rr=null,da=!1}catch(m){throw Rr!==null&&(Rr=Rr.slice(r+1)),Pd(Sl,ts),m}finally{ze=n,ni=!1}}return null}var on=[],an=0,ua=null,ma=0,tr=[],rr=0,Ls=null,Ir=1,$r="";function Es(r,n){on[an++]=ma,on[an++]=ua,ua=r,ma=n}function Au(r,n,a){tr[rr++]=Ir,tr[rr++]=$r,tr[rr++]=Ls,Ls=r;var c=Ir;r=$r;var m=32-ur(c)-1;c&=~(1<<m),a+=1;var f=32-ur(n)+m;if(30<f){var w=m-m%5;f=(c&(1<<w)-1).toString(32),c>>=w,m-=w,Ir=1<<32-ur(n)+m|a<<m|c,$r=f+r}else Ir=1<<f|a<<m|c,$r=r}function oi(r){r.return!==null&&(Es(r,1),Au(r,1,0))}function ai(r){for(;r===ua;)ua=on[--an],on[an]=null,ma=on[--an],on[an]=null;for(;r===Ls;)Ls=tr[--rr],tr[rr]=null,$r=tr[--rr],tr[rr]=null,Ir=tr[--rr],tr[rr]=null}var Kt=null,Jt=null,Ge=!1,hr=null;function Pu(r,n){var a=ar(5,null,null,0);a.elementType="DELETED",a.stateNode=n,a.return=r,n=r.deletions,n===null?(r.deletions=[a],r.flags|=16):n.push(a)}function Mu(r,n){switch(r.tag){case 5:var a=r.type;return n=n.nodeType!==1||a.toLowerCase()!==n.nodeName.toLowerCase()?null:n,n!==null?(r.stateNode=n,Kt=r,Jt=Xr(n.firstChild),!0):!1;case 6:return n=r.pendingProps===""||n.nodeType!==3?null:n,n!==null?(r.stateNode=n,Kt=r,Jt=null,!0):!1;case 13:return n=n.nodeType!==8?null:n,n!==null?(a=Ls!==null?{id:Ir,overflow:$r}:null,r.memoizedState={dehydrated:n,treeContext:a,retryLane:1073741824},a=ar(18,null,null,0),a.stateNode=n,a.return=r,r.child=a,Kt=r,Jt=null,!0):!1;default:return!1}}function li(r){return(r.mode&1)!==0&&(r.flags&128)===0}function ii(r){if(Ge){var n=Jt;if(n){var a=n;if(!Mu(r,n)){if(li(r))throw Error(o(418));n=Xr(a.nextSibling);var c=Kt;n&&Mu(r,n)?Pu(c,a):(r.flags=r.flags&-4097|2,Ge=!1,Kt=r)}}else{if(li(r))throw Error(o(418));r.flags=r.flags&-4097|2,Ge=!1,Kt=r}}}function Ru(r){for(r=r.return;r!==null&&r.tag!==5&&r.tag!==3&&r.tag!==13;)r=r.return;Kt=r}function ha(r){if(r!==Kt)return!1;if(!Ge)return Ru(r),Ge=!0,!1;var n;if((n=r.tag!==3)&&!(n=r.tag!==5)&&(n=r.type,n=n!=="head"&&n!=="body"&&!Zl(r.type,r.memoizedProps)),n&&(n=Jt)){if(li(r))throw Iu(),Error(o(418));for(;n;)Pu(r,n),n=Xr(n.nextSibling)}if(Ru(r),r.tag===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(o(317));e:{for(r=r.nextSibling,n=0;r;){if(r.nodeType===8){var a=r.data;if(a==="/$"){if(n===0){Jt=Xr(r.nextSibling);break e}n--}else a!=="$"&&a!=="$!"&&a!=="$?"||n++}r=r.nextSibling}Jt=null}}else Jt=Kt?Xr(r.stateNode.nextSibling):null;return!0}function Iu(){for(var r=Jt;r;)r=Xr(r.nextSibling)}function ln(){Jt=Kt=null,Ge=!1}function ci(r){hr===null?hr=[r]:hr.push(r)}var Gf=C.ReactCurrentBatchConfig;function so(r,n,a){if(r=a.ref,r!==null&&typeof r!="function"&&typeof r!="object"){if(a._owner){if(a=a._owner,a){if(a.tag!==1)throw Error(o(309));var c=a.stateNode}if(!c)throw Error(o(147,r));var m=c,f=""+r;return n!==null&&n.ref!==null&&typeof n.ref=="function"&&n.ref._stringRef===f?n.ref:(n=function(w){var A=m.refs;w===null?delete A[f]:A[f]=w},n._stringRef=f,n)}if(typeof r!="string")throw Error(o(284));if(!a._owner)throw Error(o(290,r))}return r}function pa(r,n){throw r=Object.prototype.toString.call(n),Error(o(31,r==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":r))}function $u(r){var n=r._init;return n(r._payload)}function Bu(r){function n(V,B){if(r){var G=V.deletions;G===null?(V.deletions=[B],V.flags|=16):G.push(B)}}function a(V,B){if(!r)return null;for(;B!==null;)n(V,B),B=B.sibling;return null}function c(V,B){for(V=new Map;B!==null;)B.key!==null?V.set(B.key,B):V.set(B.index,B),B=B.sibling;return V}function m(V,B){return V=cs(V,B),V.index=0,V.sibling=null,V}function f(V,B,G){return V.index=G,r?(G=V.alternate,G!==null?(G=G.index,G<B?(V.flags|=2,B):G):(V.flags|=2,B)):(V.flags|=1048576,B)}function w(V){return r&&V.alternate===null&&(V.flags|=2),V}function A(V,B,G,me){return B===null||B.tag!==6?(B=ec(G,V.mode,me),B.return=V,B):(B=m(B,G),B.return=V,B)}function $(V,B,G,me){var ve=G.type;return ve===M?le(V,B,G.props.children,me,G.key):B!==null&&(B.elementType===ve||typeof ve=="object"&&ve!==null&&ve.$$typeof===D&&$u(ve)===B.type)?(me=m(B,G.props),me.ref=so(V,B,G),me.return=V,me):(me=Da(G.type,G.key,G.props,null,V.mode,me),me.ref=so(V,B,G),me.return=V,me)}function Q(V,B,G,me){return B===null||B.tag!==4||B.stateNode.containerInfo!==G.containerInfo||B.stateNode.implementation!==G.implementation?(B=tc(G,V.mode,me),B.return=V,B):(B=m(B,G.children||[]),B.return=V,B)}function le(V,B,G,me,ve){return B===null||B.tag!==7?(B=Bs(G,V.mode,me,ve),B.return=V,B):(B=m(B,G),B.return=V,B)}function de(V,B,G){if(typeof B=="string"&&B!==""||typeof B=="number")return B=ec(""+B,V.mode,G),B.return=V,B;if(typeof B=="object"&&B!==null){switch(B.$$typeof){case E:return G=Da(B.type,B.key,B.props,null,V.mode,G),G.ref=so(V,null,B),G.return=V,G;case I:return B=tc(B,V.mode,G),B.return=V,B;case D:var me=B._init;return de(V,me(B._payload),G)}if(xt(B)||ie(B))return B=Bs(B,V.mode,G,null),B.return=V,B;pa(V,B)}return null}function oe(V,B,G,me){var ve=B!==null?B.key:null;if(typeof G=="string"&&G!==""||typeof G=="number")return ve!==null?null:A(V,B,""+G,me);if(typeof G=="object"&&G!==null){switch(G.$$typeof){case E:return G.key===ve?$(V,B,G,me):null;case I:return G.key===ve?Q(V,B,G,me):null;case D:return ve=G._init,oe(V,B,ve(G._payload),me)}if(xt(G)||ie(G))return ve!==null?null:le(V,B,G,me,null);pa(V,G)}return null}function xe(V,B,G,me,ve){if(typeof me=="string"&&me!==""||typeof me=="number")return V=V.get(G)||null,A(B,V,""+me,ve);if(typeof me=="object"&&me!==null){switch(me.$$typeof){case E:return V=V.get(me.key===null?G:me.key)||null,$(B,V,me,ve);case I:return V=V.get(me.key===null?G:me.key)||null,Q(B,V,me,ve);case D:var ke=me._init;return xe(V,B,G,ke(me._payload),ve)}if(xt(me)||ie(me))return V=V.get(G)||null,le(B,V,me,ve,null);pa(B,me)}return null}function ge(V,B,G,me){for(var ve=null,ke=null,Ce=B,Te=B=0,yt=null;Ce!==null&&Te<G.length;Te++){Ce.index>Te?(yt=Ce,Ce=null):yt=Ce.sibling;var Oe=oe(V,Ce,G[Te],me);if(Oe===null){Ce===null&&(Ce=yt);break}r&&Ce&&Oe.alternate===null&&n(V,Ce),B=f(Oe,B,Te),ke===null?ve=Oe:ke.sibling=Oe,ke=Oe,Ce=yt}if(Te===G.length)return a(V,Ce),Ge&&Es(V,Te),ve;if(Ce===null){for(;Te<G.length;Te++)Ce=de(V,G[Te],me),Ce!==null&&(B=f(Ce,B,Te),ke===null?ve=Ce:ke.sibling=Ce,ke=Ce);return Ge&&Es(V,Te),ve}for(Ce=c(V,Ce);Te<G.length;Te++)yt=xe(Ce,V,Te,G[Te],me),yt!==null&&(r&&yt.alternate!==null&&Ce.delete(yt.key===null?Te:yt.key),B=f(yt,B,Te),ke===null?ve=yt:ke.sibling=yt,ke=yt);return r&&Ce.forEach(function(ds){return n(V,ds)}),Ge&&Es(V,Te),ve}function ye(V,B,G,me){var ve=ie(G);if(typeof ve!="function")throw Error(o(150));if(G=ve.call(G),G==null)throw Error(o(151));for(var ke=ve=null,Ce=B,Te=B=0,yt=null,Oe=G.next();Ce!==null&&!Oe.done;Te++,Oe=G.next()){Ce.index>Te?(yt=Ce,Ce=null):yt=Ce.sibling;var ds=oe(V,Ce,Oe.value,me);if(ds===null){Ce===null&&(Ce=yt);break}r&&Ce&&ds.alternate===null&&n(V,Ce),B=f(ds,B,Te),ke===null?ve=ds:ke.sibling=ds,ke=ds,Ce=yt}if(Oe.done)return a(V,Ce),Ge&&Es(V,Te),ve;if(Ce===null){for(;!Oe.done;Te++,Oe=G.next())Oe=de(V,Oe.value,me),Oe!==null&&(B=f(Oe,B,Te),ke===null?ve=Oe:ke.sibling=Oe,ke=Oe);return Ge&&Es(V,Te),ve}for(Ce=c(V,Ce);!Oe.done;Te++,Oe=G.next())Oe=xe(Ce,V,Te,Oe.value,me),Oe!==null&&(r&&Oe.alternate!==null&&Ce.delete(Oe.key===null?Te:Oe.key),B=f(Oe,B,Te),ke===null?ve=Oe:ke.sibling=Oe,ke=Oe);return r&&Ce.forEach(function(_g){return n(V,_g)}),Ge&&Es(V,Te),ve}function Ze(V,B,G,me){if(typeof G=="object"&&G!==null&&G.type===M&&G.key===null&&(G=G.props.children),typeof G=="object"&&G!==null){switch(G.$$typeof){case E:e:{for(var ve=G.key,ke=B;ke!==null;){if(ke.key===ve){if(ve=G.type,ve===M){if(ke.tag===7){a(V,ke.sibling),B=m(ke,G.props.children),B.return=V,V=B;break e}}else if(ke.elementType===ve||typeof ve=="object"&&ve!==null&&ve.$$typeof===D&&$u(ve)===ke.type){a(V,ke.sibling),B=m(ke,G.props),B.ref=so(V,ke,G),B.return=V,V=B;break e}a(V,ke);break}else n(V,ke);ke=ke.sibling}G.type===M?(B=Bs(G.props.children,V.mode,me,G.key),B.return=V,V=B):(me=Da(G.type,G.key,G.props,null,V.mode,me),me.ref=so(V,B,G),me.return=V,V=me)}return w(V);case I:e:{for(ke=G.key;B!==null;){if(B.key===ke)if(B.tag===4&&B.stateNode.containerInfo===G.containerInfo&&B.stateNode.implementation===G.implementation){a(V,B.sibling),B=m(B,G.children||[]),B.return=V,V=B;break e}else{a(V,B);break}else n(V,B);B=B.sibling}B=tc(G,V.mode,me),B.return=V,V=B}return w(V);case D:return ke=G._init,Ze(V,B,ke(G._payload),me)}if(xt(G))return ge(V,B,G,me);if(ie(G))return ye(V,B,G,me);pa(V,G)}return typeof G=="string"&&G!==""||typeof G=="number"?(G=""+G,B!==null&&B.tag===6?(a(V,B.sibling),B=m(B,G),B.return=V,V=B):(a(V,B),B=ec(G,V.mode,me),B.return=V,V=B),w(V)):a(V,B)}return Ze}var cn=Bu(!0),Du=Bu(!1),xa=Zr(null),fa=null,dn=null,di=null;function ui(){di=dn=fa=null}function mi(r){var n=xa.current;Ye(xa),r._currentValue=n}function hi(r,n,a){for(;r!==null;){var c=r.alternate;if((r.childLanes&n)!==n?(r.childLanes|=n,c!==null&&(c.childLanes|=n)):c!==null&&(c.childLanes&n)!==n&&(c.childLanes|=n),r===a)break;r=r.return}}function un(r,n){fa=r,di=dn=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&n)!==0&&(Wt=!0),r.firstContext=null)}function sr(r){var n=r._currentValue;if(di!==r)if(r={context:r,memoizedValue:n,next:null},dn===null){if(fa===null)throw Error(o(308));dn=r,fa.dependencies={lanes:0,firstContext:r}}else dn=dn.next=r;return n}var Ts=null;function pi(r){Ts===null?Ts=[r]:Ts.push(r)}function Ou(r,n,a,c){var m=n.interleaved;return m===null?(a.next=a,pi(n)):(a.next=m.next,m.next=a),n.interleaved=a,Br(r,c)}function Br(r,n){r.lanes|=n;var a=r.alternate;for(a!==null&&(a.lanes|=n),a=r,r=r.return;r!==null;)r.childLanes|=n,a=r.alternate,a!==null&&(a.childLanes|=n),a=r,r=r.return;return a.tag===3?a.stateNode:null}var rs=!1;function xi(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Fu(r,n){r=r.updateQueue,n.updateQueue===r&&(n.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function Dr(r,n){return{eventTime:r,lane:n,tag:0,payload:null,callback:null,next:null}}function ss(r,n,a){var c=r.updateQueue;if(c===null)return null;if(c=c.shared,(De&2)!==0){var m=c.pending;return m===null?n.next=n:(n.next=m.next,m.next=n),c.pending=n,Br(r,a)}return m=c.interleaved,m===null?(n.next=n,pi(c)):(n.next=m.next,m.next=n),c.interleaved=n,Br(r,a)}function ga(r,n,a){if(n=n.updateQueue,n!==null&&(n=n.shared,(a&4194240)!==0)){var c=n.lanes;c&=r.pendingLanes,a|=c,n.lanes=a,El(r,a)}}function Wu(r,n){var a=r.updateQueue,c=r.alternate;if(c!==null&&(c=c.updateQueue,a===c)){var m=null,f=null;if(a=a.firstBaseUpdate,a!==null){do{var w={eventTime:a.eventTime,lane:a.lane,tag:a.tag,payload:a.payload,callback:a.callback,next:null};f===null?m=f=w:f=f.next=w,a=a.next}while(a!==null);f===null?m=f=n:f=f.next=n}else m=f=n;a={baseState:c.baseState,firstBaseUpdate:m,lastBaseUpdate:f,shared:c.shared,effects:c.effects},r.updateQueue=a;return}r=a.lastBaseUpdate,r===null?a.firstBaseUpdate=n:r.next=n,a.lastBaseUpdate=n}function ya(r,n,a,c){var m=r.updateQueue;rs=!1;var f=m.firstBaseUpdate,w=m.lastBaseUpdate,A=m.shared.pending;if(A!==null){m.shared.pending=null;var $=A,Q=$.next;$.next=null,w===null?f=Q:w.next=Q,w=$;var le=r.alternate;le!==null&&(le=le.updateQueue,A=le.lastBaseUpdate,A!==w&&(A===null?le.firstBaseUpdate=Q:A.next=Q,le.lastBaseUpdate=$))}if(f!==null){var de=m.baseState;w=0,le=Q=$=null,A=f;do{var oe=A.lane,xe=A.eventTime;if((c&oe)===oe){le!==null&&(le=le.next={eventTime:xe,lane:0,tag:A.tag,payload:A.payload,callback:A.callback,next:null});e:{var ge=r,ye=A;switch(oe=n,xe=a,ye.tag){case 1:if(ge=ye.payload,typeof ge=="function"){de=ge.call(xe,de,oe);break e}de=ge;break e;case 3:ge.flags=ge.flags&-65537|128;case 0:if(ge=ye.payload,oe=typeof ge=="function"?ge.call(xe,de,oe):ge,oe==null)break e;de=re({},de,oe);break e;case 2:rs=!0}}A.callback!==null&&A.lane!==0&&(r.flags|=64,oe=m.effects,oe===null?m.effects=[A]:oe.push(A))}else xe={eventTime:xe,lane:oe,tag:A.tag,payload:A.payload,callback:A.callback,next:null},le===null?(Q=le=xe,$=de):le=le.next=xe,w|=oe;if(A=A.next,A===null){if(A=m.shared.pending,A===null)break;oe=A,A=oe.next,oe.next=null,m.lastBaseUpdate=oe,m.shared.pending=null}}while(!0);if(le===null&&($=de),m.baseState=$,m.firstBaseUpdate=Q,m.lastBaseUpdate=le,n=m.shared.interleaved,n!==null){m=n;do w|=m.lane,m=m.next;while(m!==n)}else f===null&&(m.shared.lanes=0);Ms|=w,r.lanes=w,r.memoizedState=de}}function zu(r,n,a){if(r=n.effects,n.effects=null,r!==null)for(n=0;n<r.length;n++){var c=r[n],m=c.callback;if(m!==null){if(c.callback=null,c=a,typeof m!="function")throw Error(o(191,m));m.call(c)}}}var no={},Nr=Zr(no),oo=Zr(no),ao=Zr(no);function As(r){if(r===no)throw Error(o(174));return r}function fi(r,n){switch(He(ao,n),He(oo,r),He(Nr,no),r=n.nodeType,r){case 9:case 11:n=(n=n.documentElement)?n.namespaceURI:jt(null,"");break;default:r=r===8?n.parentNode:n,n=r.namespaceURI||null,r=r.tagName,n=jt(n,r)}Ye(Nr),He(Nr,n)}function mn(){Ye(Nr),Ye(oo),Ye(ao)}function Hu(r){As(ao.current);var n=As(Nr.current),a=jt(n,r.type);n!==a&&(He(oo,r),He(Nr,a))}function gi(r){oo.current===r&&(Ye(Nr),Ye(oo))}var Ke=Zr(0);function va(r){for(var n=r;n!==null;){if(n.tag===13){var a=n.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||a.data==="$?"||a.data==="$!"))return n}else if(n.tag===19&&n.memoizedProps.revealOrder!==void 0){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===r)break;for(;n.sibling===null;){if(n.return===null||n.return===r)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var yi=[];function vi(){for(var r=0;r<yi.length;r++)yi[r]._workInProgressVersionPrimary=null;yi.length=0}var wa=C.ReactCurrentDispatcher,wi=C.ReactCurrentBatchConfig,Ps=0,Je=null,dt=null,ft=null,ba=!1,lo=!1,io=0,Kf=0;function _t(){throw Error(o(321))}function bi(r,n){if(n===null)return!1;for(var a=0;a<n.length&&a<r.length;a++)if(!mr(r[a],n[a]))return!1;return!0}function ji(r,n,a,c,m,f){if(Ps=f,Je=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,wa.current=r===null||r.memoizedState===null?Zf:eg,r=a(c,m),lo){f=0;do{if(lo=!1,io=0,25<=f)throw Error(o(301));f+=1,ft=dt=null,n.updateQueue=null,wa.current=tg,r=a(c,m)}while(lo)}if(wa.current=ka,n=dt!==null&&dt.next!==null,Ps=0,ft=dt=Je=null,ba=!1,n)throw Error(o(300));return r}function Ni(){var r=io!==0;return io=0,r}function kr(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ft===null?Je.memoizedState=ft=r:ft=ft.next=r,ft}function nr(){if(dt===null){var r=Je.alternate;r=r!==null?r.memoizedState:null}else r=dt.next;var n=ft===null?Je.memoizedState:ft.next;if(n!==null)ft=n,dt=r;else{if(r===null)throw Error(o(310));dt=r,r={memoizedState:dt.memoizedState,baseState:dt.baseState,baseQueue:dt.baseQueue,queue:dt.queue,next:null},ft===null?Je.memoizedState=ft=r:ft=ft.next=r}return ft}function co(r,n){return typeof n=="function"?n(r):n}function ki(r){var n=nr(),a=n.queue;if(a===null)throw Error(o(311));a.lastRenderedReducer=r;var c=dt,m=c.baseQueue,f=a.pending;if(f!==null){if(m!==null){var w=m.next;m.next=f.next,f.next=w}c.baseQueue=m=f,a.pending=null}if(m!==null){f=m.next,c=c.baseState;var A=w=null,$=null,Q=f;do{var le=Q.lane;if((Ps&le)===le)$!==null&&($=$.next={lane:0,action:Q.action,hasEagerState:Q.hasEagerState,eagerState:Q.eagerState,next:null}),c=Q.hasEagerState?Q.eagerState:r(c,Q.action);else{var de={lane:le,action:Q.action,hasEagerState:Q.hasEagerState,eagerState:Q.eagerState,next:null};$===null?(A=$=de,w=c):$=$.next=de,Je.lanes|=le,Ms|=le}Q=Q.next}while(Q!==null&&Q!==f);$===null?w=c:$.next=A,mr(c,n.memoizedState)||(Wt=!0),n.memoizedState=c,n.baseState=w,n.baseQueue=$,a.lastRenderedState=c}if(r=a.interleaved,r!==null){m=r;do f=m.lane,Je.lanes|=f,Ms|=f,m=m.next;while(m!==r)}else m===null&&(a.lanes=0);return[n.memoizedState,a.dispatch]}function Ci(r){var n=nr(),a=n.queue;if(a===null)throw Error(o(311));a.lastRenderedReducer=r;var c=a.dispatch,m=a.pending,f=n.memoizedState;if(m!==null){a.pending=null;var w=m=m.next;do f=r(f,w.action),w=w.next;while(w!==m);mr(f,n.memoizedState)||(Wt=!0),n.memoizedState=f,n.baseQueue===null&&(n.baseState=f),a.lastRenderedState=f}return[f,c]}function Uu(){}function Vu(r,n){var a=Je,c=nr(),m=n(),f=!mr(c.memoizedState,m);if(f&&(c.memoizedState=m,Wt=!0),c=c.queue,Si(Gu.bind(null,a,c,r),[r]),c.getSnapshot!==n||f||ft!==null&&ft.memoizedState.tag&1){if(a.flags|=2048,uo(9,Yu.bind(null,a,c,m,n),void 0,null),gt===null)throw Error(o(349));(Ps&30)!==0||qu(a,n,m)}return m}function qu(r,n,a){r.flags|=16384,r={getSnapshot:n,value:a},n=Je.updateQueue,n===null?(n={lastEffect:null,stores:null},Je.updateQueue=n,n.stores=[r]):(a=n.stores,a===null?n.stores=[r]:a.push(r))}function Yu(r,n,a,c){n.value=a,n.getSnapshot=c,Ku(n)&&Ju(r)}function Gu(r,n,a){return a(function(){Ku(n)&&Ju(r)})}function Ku(r){var n=r.getSnapshot;r=r.value;try{var a=n();return!mr(r,a)}catch{return!0}}function Ju(r){var n=Br(r,1);n!==null&&gr(n,r,1,-1)}function Qu(r){var n=kr();return typeof r=="function"&&(r=r()),n.memoizedState=n.baseState=r,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:co,lastRenderedState:r},n.queue=r,r=r.dispatch=Xf.bind(null,Je,r),[n.memoizedState,r]}function uo(r,n,a,c){return r={tag:r,create:n,destroy:a,deps:c,next:null},n=Je.updateQueue,n===null?(n={lastEffect:null,stores:null},Je.updateQueue=n,n.lastEffect=r.next=r):(a=n.lastEffect,a===null?n.lastEffect=r.next=r:(c=a.next,a.next=r,r.next=c,n.lastEffect=r)),r}function Xu(){return nr().memoizedState}function ja(r,n,a,c){var m=kr();Je.flags|=r,m.memoizedState=uo(1|n,a,void 0,c===void 0?null:c)}function Na(r,n,a,c){var m=nr();c=c===void 0?null:c;var f=void 0;if(dt!==null){var w=dt.memoizedState;if(f=w.destroy,c!==null&&bi(c,w.deps)){m.memoizedState=uo(n,a,f,c);return}}Je.flags|=r,m.memoizedState=uo(1|n,a,f,c)}function Zu(r,n){return ja(8390656,8,r,n)}function Si(r,n){return Na(2048,8,r,n)}function em(r,n){return Na(4,2,r,n)}function tm(r,n){return Na(4,4,r,n)}function rm(r,n){if(typeof n=="function")return r=r(),n(r),function(){n(null)};if(n!=null)return r=r(),n.current=r,function(){n.current=null}}function sm(r,n,a){return a=a!=null?a.concat([r]):null,Na(4,4,rm.bind(null,n,r),a)}function _i(){}function nm(r,n){var a=nr();n=n===void 0?null:n;var c=a.memoizedState;return c!==null&&n!==null&&bi(n,c[1])?c[0]:(a.memoizedState=[r,n],r)}function om(r,n){var a=nr();n=n===void 0?null:n;var c=a.memoizedState;return c!==null&&n!==null&&bi(n,c[1])?c[0]:(r=r(),a.memoizedState=[r,n],r)}function am(r,n,a){return(Ps&21)===0?(r.baseState&&(r.baseState=!1,Wt=!0),r.memoizedState=a):(mr(a,n)||(a=$d(),Je.lanes|=a,Ms|=a,r.baseState=!0),n)}function Jf(r,n){var a=ze;ze=a!==0&&4>a?a:4,r(!0);var c=wi.transition;wi.transition={};try{r(!1),n()}finally{ze=a,wi.transition=c}}function lm(){return nr().memoizedState}function Qf(r,n,a){var c=ls(r);if(a={lane:c,action:a,hasEagerState:!1,eagerState:null,next:null},im(r))cm(n,a);else if(a=Ou(r,n,a,c),a!==null){var m=Rt();gr(a,r,c,m),dm(a,n,c)}}function Xf(r,n,a){var c=ls(r),m={lane:c,action:a,hasEagerState:!1,eagerState:null,next:null};if(im(r))cm(n,m);else{var f=r.alternate;if(r.lanes===0&&(f===null||f.lanes===0)&&(f=n.lastRenderedReducer,f!==null))try{var w=n.lastRenderedState,A=f(w,a);if(m.hasEagerState=!0,m.eagerState=A,mr(A,w)){var $=n.interleaved;$===null?(m.next=m,pi(n)):(m.next=$.next,$.next=m),n.interleaved=m;return}}catch{}finally{}a=Ou(r,n,m,c),a!==null&&(m=Rt(),gr(a,r,c,m),dm(a,n,c))}}function im(r){var n=r.alternate;return r===Je||n!==null&&n===Je}function cm(r,n){lo=ba=!0;var a=r.pending;a===null?n.next=n:(n.next=a.next,a.next=n),r.pending=n}function dm(r,n,a){if((a&4194240)!==0){var c=n.lanes;c&=r.pendingLanes,a|=c,n.lanes=a,El(r,a)}}var ka={readContext:sr,useCallback:_t,useContext:_t,useEffect:_t,useImperativeHandle:_t,useInsertionEffect:_t,useLayoutEffect:_t,useMemo:_t,useReducer:_t,useRef:_t,useState:_t,useDebugValue:_t,useDeferredValue:_t,useTransition:_t,useMutableSource:_t,useSyncExternalStore:_t,useId:_t,unstable_isNewReconciler:!1},Zf={readContext:sr,useCallback:function(r,n){return kr().memoizedState=[r,n===void 0?null:n],r},useContext:sr,useEffect:Zu,useImperativeHandle:function(r,n,a){return a=a!=null?a.concat([r]):null,ja(4194308,4,rm.bind(null,n,r),a)},useLayoutEffect:function(r,n){return ja(4194308,4,r,n)},useInsertionEffect:function(r,n){return ja(4,2,r,n)},useMemo:function(r,n){var a=kr();return n=n===void 0?null:n,r=r(),a.memoizedState=[r,n],r},useReducer:function(r,n,a){var c=kr();return n=a!==void 0?a(n):n,c.memoizedState=c.baseState=n,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:n},c.queue=r,r=r.dispatch=Qf.bind(null,Je,r),[c.memoizedState,r]},useRef:function(r){var n=kr();return r={current:r},n.memoizedState=r},useState:Qu,useDebugValue:_i,useDeferredValue:function(r){return kr().memoizedState=r},useTransition:function(){var r=Qu(!1),n=r[0];return r=Jf.bind(null,r[1]),kr().memoizedState=r,[n,r]},useMutableSource:function(){},useSyncExternalStore:function(r,n,a){var c=Je,m=kr();if(Ge){if(a===void 0)throw Error(o(407));a=a()}else{if(a=n(),gt===null)throw Error(o(349));(Ps&30)!==0||qu(c,n,a)}m.memoizedState=a;var f={value:a,getSnapshot:n};return m.queue=f,Zu(Gu.bind(null,c,f,r),[r]),c.flags|=2048,uo(9,Yu.bind(null,c,f,a,n),void 0,null),a},useId:function(){var r=kr(),n=gt.identifierPrefix;if(Ge){var a=$r,c=Ir;a=(c&~(1<<32-ur(c)-1)).toString(32)+a,n=":"+n+"R"+a,a=io++,0<a&&(n+="H"+a.toString(32)),n+=":"}else a=Kf++,n=":"+n+"r"+a.toString(32)+":";return r.memoizedState=n},unstable_isNewReconciler:!1},eg={readContext:sr,useCallback:nm,useContext:sr,useEffect:Si,useImperativeHandle:sm,useInsertionEffect:em,useLayoutEffect:tm,useMemo:om,useReducer:ki,useRef:Xu,useState:function(){return ki(co)},useDebugValue:_i,useDeferredValue:function(r){var n=nr();return am(n,dt.memoizedState,r)},useTransition:function(){var r=ki(co)[0],n=nr().memoizedState;return[r,n]},useMutableSource:Uu,useSyncExternalStore:Vu,useId:lm,unstable_isNewReconciler:!1},tg={readContext:sr,useCallback:nm,useContext:sr,useEffect:Si,useImperativeHandle:sm,useInsertionEffect:em,useLayoutEffect:tm,useMemo:om,useReducer:Ci,useRef:Xu,useState:function(){return Ci(co)},useDebugValue:_i,useDeferredValue:function(r){var n=nr();return dt===null?n.memoizedState=r:am(n,dt.memoizedState,r)},useTransition:function(){var r=Ci(co)[0],n=nr().memoizedState;return[r,n]},useMutableSource:Uu,useSyncExternalStore:Vu,useId:lm,unstable_isNewReconciler:!1};function pr(r,n){if(r&&r.defaultProps){n=re({},n),r=r.defaultProps;for(var a in r)n[a]===void 0&&(n[a]=r[a]);return n}return n}function Li(r,n,a,c){n=r.memoizedState,a=a(c,n),a=a==null?n:re({},n,a),r.memoizedState=a,r.lanes===0&&(r.updateQueue.baseState=a)}var Ca={isMounted:function(r){return(r=r._reactInternals)?Cs(r)===r:!1},enqueueSetState:function(r,n,a){r=r._reactInternals;var c=Rt(),m=ls(r),f=Dr(c,m);f.payload=n,a!=null&&(f.callback=a),n=ss(r,f,m),n!==null&&(gr(n,r,m,c),ga(n,r,m))},enqueueReplaceState:function(r,n,a){r=r._reactInternals;var c=Rt(),m=ls(r),f=Dr(c,m);f.tag=1,f.payload=n,a!=null&&(f.callback=a),n=ss(r,f,m),n!==null&&(gr(n,r,m,c),ga(n,r,m))},enqueueForceUpdate:function(r,n){r=r._reactInternals;var a=Rt(),c=ls(r),m=Dr(a,c);m.tag=2,n!=null&&(m.callback=n),n=ss(r,m,c),n!==null&&(gr(n,r,c,a),ga(n,r,c))}};function um(r,n,a,c,m,f,w){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(c,f,w):n.prototype&&n.prototype.isPureReactComponent?!Jn(a,c)||!Jn(m,f):!0}function mm(r,n,a){var c=!1,m=es,f=n.contextType;return typeof f=="object"&&f!==null?f=sr(f):(m=Ft(n)?_s:St.current,c=n.contextTypes,f=(c=c!=null)?nn(r,m):es),n=new n(a,f),r.memoizedState=n.state!==null&&n.state!==void 0?n.state:null,n.updater=Ca,r.stateNode=n,n._reactInternals=r,c&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=m,r.__reactInternalMemoizedMaskedChildContext=f),n}function hm(r,n,a,c){r=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(a,c),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(a,c),n.state!==r&&Ca.enqueueReplaceState(n,n.state,null)}function Ei(r,n,a,c){var m=r.stateNode;m.props=a,m.state=r.memoizedState,m.refs={},xi(r);var f=n.contextType;typeof f=="object"&&f!==null?m.context=sr(f):(f=Ft(n)?_s:St.current,m.context=nn(r,f)),m.state=r.memoizedState,f=n.getDerivedStateFromProps,typeof f=="function"&&(Li(r,n,f,a),m.state=r.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof m.getSnapshotBeforeUpdate=="function"||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(n=m.state,typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount(),n!==m.state&&Ca.enqueueReplaceState(m,m.state,null),ya(r,a,m,c),m.state=r.memoizedState),typeof m.componentDidMount=="function"&&(r.flags|=4194308)}function hn(r,n){try{var a="",c=n;do a+=J(c),c=c.return;while(c);var m=a}catch(f){m=`
39
- Error generating stack: `+f.message+`
40
- `+f.stack}return{value:r,source:n,stack:m,digest:null}}function Ti(r,n,a){return{value:r,source:null,stack:a??null,digest:n??null}}function Ai(r,n){try{console.error(n.value)}catch(a){setTimeout(function(){throw a})}}var rg=typeof WeakMap=="function"?WeakMap:Map;function pm(r,n,a){a=Dr(-1,a),a.tag=3,a.payload={element:null};var c=n.value;return a.callback=function(){Pa||(Pa=!0,qi=c),Ai(r,n)},a}function xm(r,n,a){a=Dr(-1,a),a.tag=3;var c=r.type.getDerivedStateFromError;if(typeof c=="function"){var m=n.value;a.payload=function(){return c(m)},a.callback=function(){Ai(r,n)}}var f=r.stateNode;return f!==null&&typeof f.componentDidCatch=="function"&&(a.callback=function(){Ai(r,n),typeof c!="function"&&(os===null?os=new Set([this]):os.add(this));var w=n.stack;this.componentDidCatch(n.value,{componentStack:w!==null?w:""})}),a}function fm(r,n,a){var c=r.pingCache;if(c===null){c=r.pingCache=new rg;var m=new Set;c.set(n,m)}else m=c.get(n),m===void 0&&(m=new Set,c.set(n,m));m.has(a)||(m.add(a),r=fg.bind(null,r,n,a),n.then(r,r))}function gm(r){do{var n;if((n=r.tag===13)&&(n=r.memoizedState,n=n!==null?n.dehydrated!==null:!0),n)return r;r=r.return}while(r!==null);return null}function ym(r,n,a,c,m){return(r.mode&1)===0?(r===n?r.flags|=65536:(r.flags|=128,a.flags|=131072,a.flags&=-52805,a.tag===1&&(a.alternate===null?a.tag=17:(n=Dr(-1,1),n.tag=2,ss(a,n,1))),a.lanes|=1),r):(r.flags|=65536,r.lanes=m,r)}var sg=C.ReactCurrentOwner,Wt=!1;function Mt(r,n,a,c){n.child=r===null?Du(n,null,a,c):cn(n,r.child,a,c)}function vm(r,n,a,c,m){a=a.render;var f=n.ref;return un(n,m),c=ji(r,n,a,c,f,m),a=Ni(),r!==null&&!Wt?(n.updateQueue=r.updateQueue,n.flags&=-2053,r.lanes&=~m,Or(r,n,m)):(Ge&&a&&oi(n),n.flags|=1,Mt(r,n,c,m),n.child)}function wm(r,n,a,c,m){if(r===null){var f=a.type;return typeof f=="function"&&!Zi(f)&&f.defaultProps===void 0&&a.compare===null&&a.defaultProps===void 0?(n.tag=15,n.type=f,bm(r,n,f,c,m)):(r=Da(a.type,null,c,n,n.mode,m),r.ref=n.ref,r.return=n,n.child=r)}if(f=r.child,(r.lanes&m)===0){var w=f.memoizedProps;if(a=a.compare,a=a!==null?a:Jn,a(w,c)&&r.ref===n.ref)return Or(r,n,m)}return n.flags|=1,r=cs(f,c),r.ref=n.ref,r.return=n,n.child=r}function bm(r,n,a,c,m){if(r!==null){var f=r.memoizedProps;if(Jn(f,c)&&r.ref===n.ref)if(Wt=!1,n.pendingProps=c=f,(r.lanes&m)!==0)(r.flags&131072)!==0&&(Wt=!0);else return n.lanes=r.lanes,Or(r,n,m)}return Pi(r,n,a,c,m)}function jm(r,n,a){var c=n.pendingProps,m=c.children,f=r!==null?r.memoizedState:null;if(c.mode==="hidden")if((n.mode&1)===0)n.memoizedState={baseLanes:0,cachePool:null,transitions:null},He(xn,Qt),Qt|=a;else{if((a&1073741824)===0)return r=f!==null?f.baseLanes|a:a,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:r,cachePool:null,transitions:null},n.updateQueue=null,He(xn,Qt),Qt|=r,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=f!==null?f.baseLanes:a,He(xn,Qt),Qt|=c}else f!==null?(c=f.baseLanes|a,n.memoizedState=null):c=a,He(xn,Qt),Qt|=c;return Mt(r,n,m,a),n.child}function Nm(r,n){var a=n.ref;(r===null&&a!==null||r!==null&&r.ref!==a)&&(n.flags|=512,n.flags|=2097152)}function Pi(r,n,a,c,m){var f=Ft(a)?_s:St.current;return f=nn(n,f),un(n,m),a=ji(r,n,a,c,f,m),c=Ni(),r!==null&&!Wt?(n.updateQueue=r.updateQueue,n.flags&=-2053,r.lanes&=~m,Or(r,n,m)):(Ge&&c&&oi(n),n.flags|=1,Mt(r,n,a,m),n.child)}function km(r,n,a,c,m){if(Ft(a)){var f=!0;ca(n)}else f=!1;if(un(n,m),n.stateNode===null)_a(r,n),mm(n,a,c),Ei(n,a,c,m),c=!0;else if(r===null){var w=n.stateNode,A=n.memoizedProps;w.props=A;var $=w.context,Q=a.contextType;typeof Q=="object"&&Q!==null?Q=sr(Q):(Q=Ft(a)?_s:St.current,Q=nn(n,Q));var le=a.getDerivedStateFromProps,de=typeof le=="function"||typeof w.getSnapshotBeforeUpdate=="function";de||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(A!==c||$!==Q)&&hm(n,w,c,Q),rs=!1;var oe=n.memoizedState;w.state=oe,ya(n,c,w,m),$=n.memoizedState,A!==c||oe!==$||Ot.current||rs?(typeof le=="function"&&(Li(n,a,le,c),$=n.memoizedState),(A=rs||um(n,a,A,c,oe,$,Q))?(de||typeof w.UNSAFE_componentWillMount!="function"&&typeof w.componentWillMount!="function"||(typeof w.componentWillMount=="function"&&w.componentWillMount(),typeof w.UNSAFE_componentWillMount=="function"&&w.UNSAFE_componentWillMount()),typeof w.componentDidMount=="function"&&(n.flags|=4194308)):(typeof w.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=c,n.memoizedState=$),w.props=c,w.state=$,w.context=Q,c=A):(typeof w.componentDidMount=="function"&&(n.flags|=4194308),c=!1)}else{w=n.stateNode,Fu(r,n),A=n.memoizedProps,Q=n.type===n.elementType?A:pr(n.type,A),w.props=Q,de=n.pendingProps,oe=w.context,$=a.contextType,typeof $=="object"&&$!==null?$=sr($):($=Ft(a)?_s:St.current,$=nn(n,$));var xe=a.getDerivedStateFromProps;(le=typeof xe=="function"||typeof w.getSnapshotBeforeUpdate=="function")||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(A!==de||oe!==$)&&hm(n,w,c,$),rs=!1,oe=n.memoizedState,w.state=oe,ya(n,c,w,m);var ge=n.memoizedState;A!==de||oe!==ge||Ot.current||rs?(typeof xe=="function"&&(Li(n,a,xe,c),ge=n.memoizedState),(Q=rs||um(n,a,Q,c,oe,ge,$)||!1)?(le||typeof w.UNSAFE_componentWillUpdate!="function"&&typeof w.componentWillUpdate!="function"||(typeof w.componentWillUpdate=="function"&&w.componentWillUpdate(c,ge,$),typeof w.UNSAFE_componentWillUpdate=="function"&&w.UNSAFE_componentWillUpdate(c,ge,$)),typeof w.componentDidUpdate=="function"&&(n.flags|=4),typeof w.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof w.componentDidUpdate!="function"||A===r.memoizedProps&&oe===r.memoizedState||(n.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||A===r.memoizedProps&&oe===r.memoizedState||(n.flags|=1024),n.memoizedProps=c,n.memoizedState=ge),w.props=c,w.state=ge,w.context=$,c=Q):(typeof w.componentDidUpdate!="function"||A===r.memoizedProps&&oe===r.memoizedState||(n.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||A===r.memoizedProps&&oe===r.memoizedState||(n.flags|=1024),c=!1)}return Mi(r,n,a,c,f,m)}function Mi(r,n,a,c,m,f){Nm(r,n);var w=(n.flags&128)!==0;if(!c&&!w)return m&&Eu(n,a,!1),Or(r,n,f);c=n.stateNode,sg.current=n;var A=w&&typeof a.getDerivedStateFromError!="function"?null:c.render();return n.flags|=1,r!==null&&w?(n.child=cn(n,r.child,null,f),n.child=cn(n,null,A,f)):Mt(r,n,A,f),n.memoizedState=c.state,m&&Eu(n,a,!0),n.child}function Cm(r){var n=r.stateNode;n.pendingContext?_u(r,n.pendingContext,n.pendingContext!==n.context):n.context&&_u(r,n.context,!1),fi(r,n.containerInfo)}function Sm(r,n,a,c,m){return ln(),ci(m),n.flags|=256,Mt(r,n,a,c),n.child}var Ri={dehydrated:null,treeContext:null,retryLane:0};function Ii(r){return{baseLanes:r,cachePool:null,transitions:null}}function _m(r,n,a){var c=n.pendingProps,m=Ke.current,f=!1,w=(n.flags&128)!==0,A;if((A=w)||(A=r!==null&&r.memoizedState===null?!1:(m&2)!==0),A?(f=!0,n.flags&=-129):(r===null||r.memoizedState!==null)&&(m|=1),He(Ke,m&1),r===null)return ii(n),r=n.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?((n.mode&1)===0?n.lanes=1:r.data==="$!"?n.lanes=8:n.lanes=1073741824,null):(w=c.children,r=c.fallback,f?(c=n.mode,f=n.child,w={mode:"hidden",children:w},(c&1)===0&&f!==null?(f.childLanes=0,f.pendingProps=w):f=Oa(w,c,0,null),r=Bs(r,c,a,null),f.return=n,r.return=n,f.sibling=r,n.child=f,n.child.memoizedState=Ii(a),n.memoizedState=Ri,r):$i(n,w));if(m=r.memoizedState,m!==null&&(A=m.dehydrated,A!==null))return ng(r,n,w,c,A,m,a);if(f){f=c.fallback,w=n.mode,m=r.child,A=m.sibling;var $={mode:"hidden",children:c.children};return(w&1)===0&&n.child!==m?(c=n.child,c.childLanes=0,c.pendingProps=$,n.deletions=null):(c=cs(m,$),c.subtreeFlags=m.subtreeFlags&14680064),A!==null?f=cs(A,f):(f=Bs(f,w,a,null),f.flags|=2),f.return=n,c.return=n,c.sibling=f,n.child=c,c=f,f=n.child,w=r.child.memoizedState,w=w===null?Ii(a):{baseLanes:w.baseLanes|a,cachePool:null,transitions:w.transitions},f.memoizedState=w,f.childLanes=r.childLanes&~a,n.memoizedState=Ri,c}return f=r.child,r=f.sibling,c=cs(f,{mode:"visible",children:c.children}),(n.mode&1)===0&&(c.lanes=a),c.return=n,c.sibling=null,r!==null&&(a=n.deletions,a===null?(n.deletions=[r],n.flags|=16):a.push(r)),n.child=c,n.memoizedState=null,c}function $i(r,n){return n=Oa({mode:"visible",children:n},r.mode,0,null),n.return=r,r.child=n}function Sa(r,n,a,c){return c!==null&&ci(c),cn(n,r.child,null,a),r=$i(n,n.pendingProps.children),r.flags|=2,n.memoizedState=null,r}function ng(r,n,a,c,m,f,w){if(a)return n.flags&256?(n.flags&=-257,c=Ti(Error(o(422))),Sa(r,n,w,c)):n.memoizedState!==null?(n.child=r.child,n.flags|=128,null):(f=c.fallback,m=n.mode,c=Oa({mode:"visible",children:c.children},m,0,null),f=Bs(f,m,w,null),f.flags|=2,c.return=n,f.return=n,c.sibling=f,n.child=c,(n.mode&1)!==0&&cn(n,r.child,null,w),n.child.memoizedState=Ii(w),n.memoizedState=Ri,f);if((n.mode&1)===0)return Sa(r,n,w,null);if(m.data==="$!"){if(c=m.nextSibling&&m.nextSibling.dataset,c)var A=c.dgst;return c=A,f=Error(o(419)),c=Ti(f,c,void 0),Sa(r,n,w,c)}if(A=(w&r.childLanes)!==0,Wt||A){if(c=gt,c!==null){switch(w&-w){case 4:m=2;break;case 16:m=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:m=32;break;case 536870912:m=268435456;break;default:m=0}m=(m&(c.suspendedLanes|w))!==0?0:m,m!==0&&m!==f.retryLane&&(f.retryLane=m,Br(r,m),gr(c,r,m,-1))}return Xi(),c=Ti(Error(o(421))),Sa(r,n,w,c)}return m.data==="$?"?(n.flags|=128,n.child=r.child,n=gg.bind(null,r),m._reactRetry=n,null):(r=f.treeContext,Jt=Xr(m.nextSibling),Kt=n,Ge=!0,hr=null,r!==null&&(tr[rr++]=Ir,tr[rr++]=$r,tr[rr++]=Ls,Ir=r.id,$r=r.overflow,Ls=n),n=$i(n,c.children),n.flags|=4096,n)}function Lm(r,n,a){r.lanes|=n;var c=r.alternate;c!==null&&(c.lanes|=n),hi(r.return,n,a)}function Bi(r,n,a,c,m){var f=r.memoizedState;f===null?r.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:c,tail:a,tailMode:m}:(f.isBackwards=n,f.rendering=null,f.renderingStartTime=0,f.last=c,f.tail=a,f.tailMode=m)}function Em(r,n,a){var c=n.pendingProps,m=c.revealOrder,f=c.tail;if(Mt(r,n,c.children,a),c=Ke.current,(c&2)!==0)c=c&1|2,n.flags|=128;else{if(r!==null&&(r.flags&128)!==0)e:for(r=n.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Lm(r,a,n);else if(r.tag===19)Lm(r,a,n);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===n)break e;for(;r.sibling===null;){if(r.return===null||r.return===n)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}c&=1}if(He(Ke,c),(n.mode&1)===0)n.memoizedState=null;else switch(m){case"forwards":for(a=n.child,m=null;a!==null;)r=a.alternate,r!==null&&va(r)===null&&(m=a),a=a.sibling;a=m,a===null?(m=n.child,n.child=null):(m=a.sibling,a.sibling=null),Bi(n,!1,m,a,f);break;case"backwards":for(a=null,m=n.child,n.child=null;m!==null;){if(r=m.alternate,r!==null&&va(r)===null){n.child=m;break}r=m.sibling,m.sibling=a,a=m,m=r}Bi(n,!0,a,null,f);break;case"together":Bi(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function _a(r,n){(n.mode&1)===0&&r!==null&&(r.alternate=null,n.alternate=null,n.flags|=2)}function Or(r,n,a){if(r!==null&&(n.dependencies=r.dependencies),Ms|=n.lanes,(a&n.childLanes)===0)return null;if(r!==null&&n.child!==r.child)throw Error(o(153));if(n.child!==null){for(r=n.child,a=cs(r,r.pendingProps),n.child=a,a.return=n;r.sibling!==null;)r=r.sibling,a=a.sibling=cs(r,r.pendingProps),a.return=n;a.sibling=null}return n.child}function og(r,n,a){switch(n.tag){case 3:Cm(n),ln();break;case 5:Hu(n);break;case 1:Ft(n.type)&&ca(n);break;case 4:fi(n,n.stateNode.containerInfo);break;case 10:var c=n.type._context,m=n.memoizedProps.value;He(xa,c._currentValue),c._currentValue=m;break;case 13:if(c=n.memoizedState,c!==null)return c.dehydrated!==null?(He(Ke,Ke.current&1),n.flags|=128,null):(a&n.child.childLanes)!==0?_m(r,n,a):(He(Ke,Ke.current&1),r=Or(r,n,a),r!==null?r.sibling:null);He(Ke,Ke.current&1);break;case 19:if(c=(a&n.childLanes)!==0,(r.flags&128)!==0){if(c)return Em(r,n,a);n.flags|=128}if(m=n.memoizedState,m!==null&&(m.rendering=null,m.tail=null,m.lastEffect=null),He(Ke,Ke.current),c)break;return null;case 22:case 23:return n.lanes=0,jm(r,n,a)}return Or(r,n,a)}var Tm,Di,Am,Pm;Tm=function(r,n){for(var a=n.child;a!==null;){if(a.tag===5||a.tag===6)r.appendChild(a.stateNode);else if(a.tag!==4&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===n)break;for(;a.sibling===null;){if(a.return===null||a.return===n)return;a=a.return}a.sibling.return=a.return,a=a.sibling}},Di=function(){},Am=function(r,n,a,c){var m=r.memoizedProps;if(m!==c){r=n.stateNode,As(Nr.current);var f=null;switch(a){case"input":m=ot(r,m),c=ot(r,c),f=[];break;case"select":m=re({},m,{value:void 0}),c=re({},c,{value:void 0}),f=[];break;case"textarea":m=ue(r,m),c=ue(r,c),f=[];break;default:typeof m.onClick!="function"&&typeof c.onClick=="function"&&(r.onclick=aa)}dr(a,c);var w;a=null;for(Q in m)if(!c.hasOwnProperty(Q)&&m.hasOwnProperty(Q)&&m[Q]!=null)if(Q==="style"){var A=m[Q];for(w in A)A.hasOwnProperty(w)&&(a||(a={}),a[w]="")}else Q!=="dangerouslySetInnerHTML"&&Q!=="children"&&Q!=="suppressContentEditableWarning"&&Q!=="suppressHydrationWarning"&&Q!=="autoFocus"&&(i.hasOwnProperty(Q)?f||(f=[]):(f=f||[]).push(Q,null));for(Q in c){var $=c[Q];if(A=m!=null?m[Q]:void 0,c.hasOwnProperty(Q)&&$!==A&&($!=null||A!=null))if(Q==="style")if(A){for(w in A)!A.hasOwnProperty(w)||$&&$.hasOwnProperty(w)||(a||(a={}),a[w]="");for(w in $)$.hasOwnProperty(w)&&A[w]!==$[w]&&(a||(a={}),a[w]=$[w])}else a||(f||(f=[]),f.push(Q,a)),a=$;else Q==="dangerouslySetInnerHTML"?($=$?$.__html:void 0,A=A?A.__html:void 0,$!=null&&A!==$&&(f=f||[]).push(Q,$)):Q==="children"?typeof $!="string"&&typeof $!="number"||(f=f||[]).push(Q,""+$):Q!=="suppressContentEditableWarning"&&Q!=="suppressHydrationWarning"&&(i.hasOwnProperty(Q)?($!=null&&Q==="onScroll"&&qe("scroll",r),f||A===$||(f=[])):(f=f||[]).push(Q,$))}a&&(f=f||[]).push("style",a);var Q=f;(n.updateQueue=Q)&&(n.flags|=4)}},Pm=function(r,n,a,c){a!==c&&(n.flags|=4)};function mo(r,n){if(!Ge)switch(r.tailMode){case"hidden":n=r.tail;for(var a=null;n!==null;)n.alternate!==null&&(a=n),n=n.sibling;a===null?r.tail=null:a.sibling=null;break;case"collapsed":a=r.tail;for(var c=null;a!==null;)a.alternate!==null&&(c=a),a=a.sibling;c===null?n||r.tail===null?r.tail=null:r.tail.sibling=null:c.sibling=null}}function Lt(r){var n=r.alternate!==null&&r.alternate.child===r.child,a=0,c=0;if(n)for(var m=r.child;m!==null;)a|=m.lanes|m.childLanes,c|=m.subtreeFlags&14680064,c|=m.flags&14680064,m.return=r,m=m.sibling;else for(m=r.child;m!==null;)a|=m.lanes|m.childLanes,c|=m.subtreeFlags,c|=m.flags,m.return=r,m=m.sibling;return r.subtreeFlags|=c,r.childLanes=a,n}function ag(r,n,a){var c=n.pendingProps;switch(ai(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Lt(n),null;case 1:return Ft(n.type)&&ia(),Lt(n),null;case 3:return c=n.stateNode,mn(),Ye(Ot),Ye(St),vi(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(r===null||r.child===null)&&(ha(n)?n.flags|=4:r===null||r.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,hr!==null&&(Ki(hr),hr=null))),Di(r,n),Lt(n),null;case 5:gi(n);var m=As(ao.current);if(a=n.type,r!==null&&n.stateNode!=null)Am(r,n,a,c,m),r.ref!==n.ref&&(n.flags|=512,n.flags|=2097152);else{if(!c){if(n.stateNode===null)throw Error(o(166));return Lt(n),null}if(r=As(Nr.current),ha(n)){c=n.stateNode,a=n.type;var f=n.memoizedProps;switch(c[jr]=n,c[to]=f,r=(n.mode&1)!==0,a){case"dialog":qe("cancel",c),qe("close",c);break;case"iframe":case"object":case"embed":qe("load",c);break;case"video":case"audio":for(m=0;m<Xn.length;m++)qe(Xn[m],c);break;case"source":qe("error",c);break;case"img":case"image":case"link":qe("error",c),qe("load",c);break;case"details":qe("toggle",c);break;case"input":wt(c,f),qe("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!f.multiple},qe("invalid",c);break;case"textarea":$e(c,f),qe("invalid",c)}dr(a,f),m=null;for(var w in f)if(f.hasOwnProperty(w)){var A=f[w];w==="children"?typeof A=="string"?c.textContent!==A&&(f.suppressHydrationWarning!==!0&&oa(c.textContent,A,r),m=["children",A]):typeof A=="number"&&c.textContent!==""+A&&(f.suppressHydrationWarning!==!0&&oa(c.textContent,A,r),m=["children",""+A]):i.hasOwnProperty(w)&&A!=null&&w==="onScroll"&&qe("scroll",c)}switch(a){case"input":se(c),Ve(c,f,!0);break;case"textarea":se(c),lt(c);break;case"select":case"option":break;default:typeof f.onClick=="function"&&(c.onclick=aa)}c=m,n.updateQueue=c,c!==null&&(n.flags|=4)}else{w=m.nodeType===9?m:m.ownerDocument,r==="http://www.w3.org/1999/xhtml"&&(r=cr(a)),r==="http://www.w3.org/1999/xhtml"?a==="script"?(r=w.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild)):typeof c.is=="string"?r=w.createElement(a,{is:c.is}):(r=w.createElement(a),a==="select"&&(w=r,c.multiple?w.multiple=!0:c.size&&(w.size=c.size))):r=w.createElementNS(r,a),r[jr]=n,r[to]=c,Tm(r,n,!1,!1),n.stateNode=r;e:{switch(w=ne(a,c),a){case"dialog":qe("cancel",r),qe("close",r),m=c;break;case"iframe":case"object":case"embed":qe("load",r),m=c;break;case"video":case"audio":for(m=0;m<Xn.length;m++)qe(Xn[m],r);m=c;break;case"source":qe("error",r),m=c;break;case"img":case"image":case"link":qe("error",r),qe("load",r),m=c;break;case"details":qe("toggle",r),m=c;break;case"input":wt(r,c),m=ot(r,c),qe("invalid",r);break;case"option":m=c;break;case"select":r._wrapperState={wasMultiple:!!c.multiple},m=re({},c,{value:void 0}),qe("invalid",r);break;case"textarea":$e(r,c),m=ue(r,c),qe("invalid",r);break;default:m=c}dr(a,m),A=m;for(f in A)if(A.hasOwnProperty(f)){var $=A[f];f==="style"?ks(r,$):f==="dangerouslySetInnerHTML"?($=$?$.__html:void 0,$!=null&&js(r,$)):f==="children"?typeof $=="string"?(a!=="textarea"||$!=="")&&vr(r,$):typeof $=="number"&&vr(r,""+$):f!=="suppressContentEditableWarning"&&f!=="suppressHydrationWarning"&&f!=="autoFocus"&&(i.hasOwnProperty(f)?$!=null&&f==="onScroll"&&qe("scroll",r):$!=null&&P(r,f,$,w))}switch(a){case"input":se(r),Ve(r,c,!1);break;case"textarea":se(r),lt(r);break;case"option":c.value!=null&&r.setAttribute("value",""+Ae(c.value));break;case"select":r.multiple=!!c.multiple,f=c.value,f!=null?bt(r,!!c.multiple,f,!1):c.defaultValue!=null&&bt(r,!!c.multiple,c.defaultValue,!0);break;default:typeof m.onClick=="function"&&(r.onclick=aa)}switch(a){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}}c&&(n.flags|=4)}n.ref!==null&&(n.flags|=512,n.flags|=2097152)}return Lt(n),null;case 6:if(r&&n.stateNode!=null)Pm(r,n,r.memoizedProps,c);else{if(typeof c!="string"&&n.stateNode===null)throw Error(o(166));if(a=As(ao.current),As(Nr.current),ha(n)){if(c=n.stateNode,a=n.memoizedProps,c[jr]=n,(f=c.nodeValue!==a)&&(r=Kt,r!==null))switch(r.tag){case 3:oa(c.nodeValue,a,(r.mode&1)!==0);break;case 5:r.memoizedProps.suppressHydrationWarning!==!0&&oa(c.nodeValue,a,(r.mode&1)!==0)}f&&(n.flags|=4)}else c=(a.nodeType===9?a:a.ownerDocument).createTextNode(c),c[jr]=n,n.stateNode=c}return Lt(n),null;case 13:if(Ye(Ke),c=n.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(Ge&&Jt!==null&&(n.mode&1)!==0&&(n.flags&128)===0)Iu(),ln(),n.flags|=98560,f=!1;else if(f=ha(n),c!==null&&c.dehydrated!==null){if(r===null){if(!f)throw Error(o(318));if(f=n.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(o(317));f[jr]=n}else ln(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;Lt(n),f=!1}else hr!==null&&(Ki(hr),hr=null),f=!0;if(!f)return n.flags&65536?n:null}return(n.flags&128)!==0?(n.lanes=a,n):(c=c!==null,c!==(r!==null&&r.memoizedState!==null)&&c&&(n.child.flags|=8192,(n.mode&1)!==0&&(r===null||(Ke.current&1)!==0?ut===0&&(ut=3):Xi())),n.updateQueue!==null&&(n.flags|=4),Lt(n),null);case 4:return mn(),Di(r,n),r===null&&Zn(n.stateNode.containerInfo),Lt(n),null;case 10:return mi(n.type._context),Lt(n),null;case 17:return Ft(n.type)&&ia(),Lt(n),null;case 19:if(Ye(Ke),f=n.memoizedState,f===null)return Lt(n),null;if(c=(n.flags&128)!==0,w=f.rendering,w===null)if(c)mo(f,!1);else{if(ut!==0||r!==null&&(r.flags&128)!==0)for(r=n.child;r!==null;){if(w=va(r),w!==null){for(n.flags|=128,mo(f,!1),c=w.updateQueue,c!==null&&(n.updateQueue=c,n.flags|=4),n.subtreeFlags=0,c=a,a=n.child;a!==null;)f=a,r=c,f.flags&=14680066,w=f.alternate,w===null?(f.childLanes=0,f.lanes=r,f.child=null,f.subtreeFlags=0,f.memoizedProps=null,f.memoizedState=null,f.updateQueue=null,f.dependencies=null,f.stateNode=null):(f.childLanes=w.childLanes,f.lanes=w.lanes,f.child=w.child,f.subtreeFlags=0,f.deletions=null,f.memoizedProps=w.memoizedProps,f.memoizedState=w.memoizedState,f.updateQueue=w.updateQueue,f.type=w.type,r=w.dependencies,f.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),a=a.sibling;return He(Ke,Ke.current&1|2),n.child}r=r.sibling}f.tail!==null&&Xe()>fn&&(n.flags|=128,c=!0,mo(f,!1),n.lanes=4194304)}else{if(!c)if(r=va(w),r!==null){if(n.flags|=128,c=!0,a=r.updateQueue,a!==null&&(n.updateQueue=a,n.flags|=4),mo(f,!0),f.tail===null&&f.tailMode==="hidden"&&!w.alternate&&!Ge)return Lt(n),null}else 2*Xe()-f.renderingStartTime>fn&&a!==1073741824&&(n.flags|=128,c=!0,mo(f,!1),n.lanes=4194304);f.isBackwards?(w.sibling=n.child,n.child=w):(a=f.last,a!==null?a.sibling=w:n.child=w,f.last=w)}return f.tail!==null?(n=f.tail,f.rendering=n,f.tail=n.sibling,f.renderingStartTime=Xe(),n.sibling=null,a=Ke.current,He(Ke,c?a&1|2:a&1),n):(Lt(n),null);case 22:case 23:return Qi(),c=n.memoizedState!==null,r!==null&&r.memoizedState!==null!==c&&(n.flags|=8192),c&&(n.mode&1)!==0?(Qt&1073741824)!==0&&(Lt(n),n.subtreeFlags&6&&(n.flags|=8192)):Lt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function lg(r,n){switch(ai(n),n.tag){case 1:return Ft(n.type)&&ia(),r=n.flags,r&65536?(n.flags=r&-65537|128,n):null;case 3:return mn(),Ye(Ot),Ye(St),vi(),r=n.flags,(r&65536)!==0&&(r&128)===0?(n.flags=r&-65537|128,n):null;case 5:return gi(n),null;case 13:if(Ye(Ke),r=n.memoizedState,r!==null&&r.dehydrated!==null){if(n.alternate===null)throw Error(o(340));ln()}return r=n.flags,r&65536?(n.flags=r&-65537|128,n):null;case 19:return Ye(Ke),null;case 4:return mn(),null;case 10:return mi(n.type._context),null;case 22:case 23:return Qi(),null;case 24:return null;default:return null}}var La=!1,Et=!1,ig=typeof WeakSet=="function"?WeakSet:Set,fe=null;function pn(r,n){var a=r.ref;if(a!==null)if(typeof a=="function")try{a(null)}catch(c){Qe(r,n,c)}else a.current=null}function Oi(r,n,a){try{a()}catch(c){Qe(r,n,c)}}var Mm=!1;function cg(r,n){if(Ql=Go,r=uu(),Hl(r)){if("selectionStart"in r)var a={start:r.selectionStart,end:r.selectionEnd};else e:{a=(a=r.ownerDocument)&&a.defaultView||window;var c=a.getSelection&&a.getSelection();if(c&&c.rangeCount!==0){a=c.anchorNode;var m=c.anchorOffset,f=c.focusNode;c=c.focusOffset;try{a.nodeType,f.nodeType}catch{a=null;break e}var w=0,A=-1,$=-1,Q=0,le=0,de=r,oe=null;t:for(;;){for(var xe;de!==a||m!==0&&de.nodeType!==3||(A=w+m),de!==f||c!==0&&de.nodeType!==3||($=w+c),de.nodeType===3&&(w+=de.nodeValue.length),(xe=de.firstChild)!==null;)oe=de,de=xe;for(;;){if(de===r)break t;if(oe===a&&++Q===m&&(A=w),oe===f&&++le===c&&($=w),(xe=de.nextSibling)!==null)break;de=oe,oe=de.parentNode}de=xe}a=A===-1||$===-1?null:{start:A,end:$}}else a=null}a=a||{start:0,end:0}}else a=null;for(Xl={focusedElem:r,selectionRange:a},Go=!1,fe=n;fe!==null;)if(n=fe,r=n.child,(n.subtreeFlags&1028)!==0&&r!==null)r.return=n,fe=r;else for(;fe!==null;){n=fe;try{var ge=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(ge!==null){var ye=ge.memoizedProps,Ze=ge.memoizedState,V=n.stateNode,B=V.getSnapshotBeforeUpdate(n.elementType===n.type?ye:pr(n.type,ye),Ze);V.__reactInternalSnapshotBeforeUpdate=B}break;case 3:var G=n.stateNode.containerInfo;G.nodeType===1?G.textContent="":G.nodeType===9&&G.documentElement&&G.removeChild(G.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(me){Qe(n,n.return,me)}if(r=n.sibling,r!==null){r.return=n.return,fe=r;break}fe=n.return}return ge=Mm,Mm=!1,ge}function ho(r,n,a){var c=n.updateQueue;if(c=c!==null?c.lastEffect:null,c!==null){var m=c=c.next;do{if((m.tag&r)===r){var f=m.destroy;m.destroy=void 0,f!==void 0&&Oi(n,a,f)}m=m.next}while(m!==c)}}function Ea(r,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var a=n=n.next;do{if((a.tag&r)===r){var c=a.create;a.destroy=c()}a=a.next}while(a!==n)}}function Fi(r){var n=r.ref;if(n!==null){var a=r.stateNode;switch(r.tag){case 5:r=a;break;default:r=a}typeof n=="function"?n(r):n.current=r}}function Rm(r){var n=r.alternate;n!==null&&(r.alternate=null,Rm(n)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(n=r.stateNode,n!==null&&(delete n[jr],delete n[to],delete n[ri],delete n[Vf],delete n[qf])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function Im(r){return r.tag===5||r.tag===3||r.tag===4}function $m(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Im(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Wi(r,n,a){var c=r.tag;if(c===5||c===6)r=r.stateNode,n?a.nodeType===8?a.parentNode.insertBefore(r,n):a.insertBefore(r,n):(a.nodeType===8?(n=a.parentNode,n.insertBefore(r,a)):(n=a,n.appendChild(r)),a=a._reactRootContainer,a!=null||n.onclick!==null||(n.onclick=aa));else if(c!==4&&(r=r.child,r!==null))for(Wi(r,n,a),r=r.sibling;r!==null;)Wi(r,n,a),r=r.sibling}function zi(r,n,a){var c=r.tag;if(c===5||c===6)r=r.stateNode,n?a.insertBefore(r,n):a.appendChild(r);else if(c!==4&&(r=r.child,r!==null))for(zi(r,n,a),r=r.sibling;r!==null;)zi(r,n,a),r=r.sibling}var Nt=null,xr=!1;function ns(r,n,a){for(a=a.child;a!==null;)Bm(r,n,a),a=a.sibling}function Bm(r,n,a){if(br&&typeof br.onCommitFiberUnmount=="function")try{br.onCommitFiberUnmount(zo,a)}catch{}switch(a.tag){case 5:Et||pn(a,n);case 6:var c=Nt,m=xr;Nt=null,ns(r,n,a),Nt=c,xr=m,Nt!==null&&(xr?(r=Nt,a=a.stateNode,r.nodeType===8?r.parentNode.removeChild(a):r.removeChild(a)):Nt.removeChild(a.stateNode));break;case 18:Nt!==null&&(xr?(r=Nt,a=a.stateNode,r.nodeType===8?ti(r.parentNode,a):r.nodeType===1&&ti(r,a),Un(r)):ti(Nt,a.stateNode));break;case 4:c=Nt,m=xr,Nt=a.stateNode.containerInfo,xr=!0,ns(r,n,a),Nt=c,xr=m;break;case 0:case 11:case 14:case 15:if(!Et&&(c=a.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){m=c=c.next;do{var f=m,w=f.destroy;f=f.tag,w!==void 0&&((f&2)!==0||(f&4)!==0)&&Oi(a,n,w),m=m.next}while(m!==c)}ns(r,n,a);break;case 1:if(!Et&&(pn(a,n),c=a.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=a.memoizedProps,c.state=a.memoizedState,c.componentWillUnmount()}catch(A){Qe(a,n,A)}ns(r,n,a);break;case 21:ns(r,n,a);break;case 22:a.mode&1?(Et=(c=Et)||a.memoizedState!==null,ns(r,n,a),Et=c):ns(r,n,a);break;default:ns(r,n,a)}}function Dm(r){var n=r.updateQueue;if(n!==null){r.updateQueue=null;var a=r.stateNode;a===null&&(a=r.stateNode=new ig),n.forEach(function(c){var m=yg.bind(null,r,c);a.has(c)||(a.add(c),c.then(m,m))})}}function fr(r,n){var a=n.deletions;if(a!==null)for(var c=0;c<a.length;c++){var m=a[c];try{var f=r,w=n,A=w;e:for(;A!==null;){switch(A.tag){case 5:Nt=A.stateNode,xr=!1;break e;case 3:Nt=A.stateNode.containerInfo,xr=!0;break e;case 4:Nt=A.stateNode.containerInfo,xr=!0;break e}A=A.return}if(Nt===null)throw Error(o(160));Bm(f,w,m),Nt=null,xr=!1;var $=m.alternate;$!==null&&($.return=null),m.return=null}catch(Q){Qe(m,n,Q)}}if(n.subtreeFlags&12854)for(n=n.child;n!==null;)Om(n,r),n=n.sibling}function Om(r,n){var a=r.alternate,c=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:if(fr(n,r),Cr(r),c&4){try{ho(3,r,r.return),Ea(3,r)}catch(ye){Qe(r,r.return,ye)}try{ho(5,r,r.return)}catch(ye){Qe(r,r.return,ye)}}break;case 1:fr(n,r),Cr(r),c&512&&a!==null&&pn(a,a.return);break;case 5:if(fr(n,r),Cr(r),c&512&&a!==null&&pn(a,a.return),r.flags&32){var m=r.stateNode;try{vr(m,"")}catch(ye){Qe(r,r.return,ye)}}if(c&4&&(m=r.stateNode,m!=null)){var f=r.memoizedProps,w=a!==null?a.memoizedProps:f,A=r.type,$=r.updateQueue;if(r.updateQueue=null,$!==null)try{A==="input"&&f.type==="radio"&&f.name!=null&&ae(m,f),ne(A,w);var Q=ne(A,f);for(w=0;w<$.length;w+=2){var le=$[w],de=$[w+1];le==="style"?ks(m,de):le==="dangerouslySetInnerHTML"?js(m,de):le==="children"?vr(m,de):P(m,le,de,Q)}switch(A){case"input":Ee(m,f);break;case"textarea":Pt(m,f);break;case"select":var oe=m._wrapperState.wasMultiple;m._wrapperState.wasMultiple=!!f.multiple;var xe=f.value;xe!=null?bt(m,!!f.multiple,xe,!1):oe!==!!f.multiple&&(f.defaultValue!=null?bt(m,!!f.multiple,f.defaultValue,!0):bt(m,!!f.multiple,f.multiple?[]:"",!1))}m[to]=f}catch(ye){Qe(r,r.return,ye)}}break;case 6:if(fr(n,r),Cr(r),c&4){if(r.stateNode===null)throw Error(o(162));m=r.stateNode,f=r.memoizedProps;try{m.nodeValue=f}catch(ye){Qe(r,r.return,ye)}}break;case 3:if(fr(n,r),Cr(r),c&4&&a!==null&&a.memoizedState.isDehydrated)try{Un(n.containerInfo)}catch(ye){Qe(r,r.return,ye)}break;case 4:fr(n,r),Cr(r);break;case 13:fr(n,r),Cr(r),m=r.child,m.flags&8192&&(f=m.memoizedState!==null,m.stateNode.isHidden=f,!f||m.alternate!==null&&m.alternate.memoizedState!==null||(Vi=Xe())),c&4&&Dm(r);break;case 22:if(le=a!==null&&a.memoizedState!==null,r.mode&1?(Et=(Q=Et)||le,fr(n,r),Et=Q):fr(n,r),Cr(r),c&8192){if(Q=r.memoizedState!==null,(r.stateNode.isHidden=Q)&&!le&&(r.mode&1)!==0)for(fe=r,le=r.child;le!==null;){for(de=fe=le;fe!==null;){switch(oe=fe,xe=oe.child,oe.tag){case 0:case 11:case 14:case 15:ho(4,oe,oe.return);break;case 1:pn(oe,oe.return);var ge=oe.stateNode;if(typeof ge.componentWillUnmount=="function"){c=oe,a=oe.return;try{n=c,ge.props=n.memoizedProps,ge.state=n.memoizedState,ge.componentWillUnmount()}catch(ye){Qe(c,a,ye)}}break;case 5:pn(oe,oe.return);break;case 22:if(oe.memoizedState!==null){zm(de);continue}}xe!==null?(xe.return=oe,fe=xe):zm(de)}le=le.sibling}e:for(le=null,de=r;;){if(de.tag===5){if(le===null){le=de;try{m=de.stateNode,Q?(f=m.style,typeof f.setProperty=="function"?f.setProperty("display","none","important"):f.display="none"):(A=de.stateNode,$=de.memoizedProps.style,w=$!=null&&$.hasOwnProperty("display")?$.display:null,A.style.display=Ns("display",w))}catch(ye){Qe(r,r.return,ye)}}}else if(de.tag===6){if(le===null)try{de.stateNode.nodeValue=Q?"":de.memoizedProps}catch(ye){Qe(r,r.return,ye)}}else if((de.tag!==22&&de.tag!==23||de.memoizedState===null||de===r)&&de.child!==null){de.child.return=de,de=de.child;continue}if(de===r)break e;for(;de.sibling===null;){if(de.return===null||de.return===r)break e;le===de&&(le=null),de=de.return}le===de&&(le=null),de.sibling.return=de.return,de=de.sibling}}break;case 19:fr(n,r),Cr(r),c&4&&Dm(r);break;case 21:break;default:fr(n,r),Cr(r)}}function Cr(r){var n=r.flags;if(n&2){try{e:{for(var a=r.return;a!==null;){if(Im(a)){var c=a;break e}a=a.return}throw Error(o(160))}switch(c.tag){case 5:var m=c.stateNode;c.flags&32&&(vr(m,""),c.flags&=-33);var f=$m(r);zi(r,f,m);break;case 3:case 4:var w=c.stateNode.containerInfo,A=$m(r);Wi(r,A,w);break;default:throw Error(o(161))}}catch($){Qe(r,r.return,$)}r.flags&=-3}n&4096&&(r.flags&=-4097)}function dg(r,n,a){fe=r,Fm(r)}function Fm(r,n,a){for(var c=(r.mode&1)!==0;fe!==null;){var m=fe,f=m.child;if(m.tag===22&&c){var w=m.memoizedState!==null||La;if(!w){var A=m.alternate,$=A!==null&&A.memoizedState!==null||Et;A=La;var Q=Et;if(La=w,(Et=$)&&!Q)for(fe=m;fe!==null;)w=fe,$=w.child,w.tag===22&&w.memoizedState!==null?Hm(m):$!==null?($.return=w,fe=$):Hm(m);for(;f!==null;)fe=f,Fm(f),f=f.sibling;fe=m,La=A,Et=Q}Wm(r)}else(m.subtreeFlags&8772)!==0&&f!==null?(f.return=m,fe=f):Wm(r)}}function Wm(r){for(;fe!==null;){var n=fe;if((n.flags&8772)!==0){var a=n.alternate;try{if((n.flags&8772)!==0)switch(n.tag){case 0:case 11:case 15:Et||Ea(5,n);break;case 1:var c=n.stateNode;if(n.flags&4&&!Et)if(a===null)c.componentDidMount();else{var m=n.elementType===n.type?a.memoizedProps:pr(n.type,a.memoizedProps);c.componentDidUpdate(m,a.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var f=n.updateQueue;f!==null&&zu(n,f,c);break;case 3:var w=n.updateQueue;if(w!==null){if(a=null,n.child!==null)switch(n.child.tag){case 5:a=n.child.stateNode;break;case 1:a=n.child.stateNode}zu(n,w,a)}break;case 5:var A=n.stateNode;if(a===null&&n.flags&4){a=A;var $=n.memoizedProps;switch(n.type){case"button":case"input":case"select":case"textarea":$.autoFocus&&a.focus();break;case"img":$.src&&(a.src=$.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(n.memoizedState===null){var Q=n.alternate;if(Q!==null){var le=Q.memoizedState;if(le!==null){var de=le.dehydrated;de!==null&&Un(de)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(o(163))}Et||n.flags&512&&Fi(n)}catch(oe){Qe(n,n.return,oe)}}if(n===r){fe=null;break}if(a=n.sibling,a!==null){a.return=n.return,fe=a;break}fe=n.return}}function zm(r){for(;fe!==null;){var n=fe;if(n===r){fe=null;break}var a=n.sibling;if(a!==null){a.return=n.return,fe=a;break}fe=n.return}}function Hm(r){for(;fe!==null;){var n=fe;try{switch(n.tag){case 0:case 11:case 15:var a=n.return;try{Ea(4,n)}catch($){Qe(n,a,$)}break;case 1:var c=n.stateNode;if(typeof c.componentDidMount=="function"){var m=n.return;try{c.componentDidMount()}catch($){Qe(n,m,$)}}var f=n.return;try{Fi(n)}catch($){Qe(n,f,$)}break;case 5:var w=n.return;try{Fi(n)}catch($){Qe(n,w,$)}}}catch($){Qe(n,n.return,$)}if(n===r){fe=null;break}var A=n.sibling;if(A!==null){A.return=n.return,fe=A;break}fe=n.return}}var ug=Math.ceil,Ta=C.ReactCurrentDispatcher,Hi=C.ReactCurrentOwner,or=C.ReactCurrentBatchConfig,De=0,gt=null,it=null,kt=0,Qt=0,xn=Zr(0),ut=0,po=null,Ms=0,Aa=0,Ui=0,xo=null,zt=null,Vi=0,fn=1/0,Fr=null,Pa=!1,qi=null,os=null,Ma=!1,as=null,Ra=0,fo=0,Yi=null,Ia=-1,$a=0;function Rt(){return(De&6)!==0?Xe():Ia!==-1?Ia:Ia=Xe()}function ls(r){return(r.mode&1)===0?1:(De&2)!==0&&kt!==0?kt&-kt:Gf.transition!==null?($a===0&&($a=$d()),$a):(r=ze,r!==0||(r=window.event,r=r===void 0?16:Vd(r.type)),r)}function gr(r,n,a,c){if(50<fo)throw fo=0,Yi=null,Error(o(185));On(r,a,c),((De&2)===0||r!==gt)&&(r===gt&&((De&2)===0&&(Aa|=a),ut===4&&is(r,kt)),Ht(r,c),a===1&&De===0&&(n.mode&1)===0&&(fn=Xe()+500,da&&ts()))}function Ht(r,n){var a=r.callbackNode;Yx(r,n);var c=Vo(r,r===gt?kt:0);if(c===0)a!==null&&Md(a),r.callbackNode=null,r.callbackPriority=0;else if(n=c&-c,r.callbackPriority!==n){if(a!=null&&Md(a),n===1)r.tag===0?Yf(Vm.bind(null,r)):Tu(Vm.bind(null,r)),Hf(function(){(De&6)===0&&ts()}),a=null;else{switch(Bd(c)){case 1:a=Sl;break;case 4:a=Rd;break;case 16:a=Wo;break;case 536870912:a=Id;break;default:a=Wo}a=Zm(a,Um.bind(null,r))}r.callbackPriority=n,r.callbackNode=a}}function Um(r,n){if(Ia=-1,$a=0,(De&6)!==0)throw Error(o(327));var a=r.callbackNode;if(gn()&&r.callbackNode!==a)return null;var c=Vo(r,r===gt?kt:0);if(c===0)return null;if((c&30)!==0||(c&r.expiredLanes)!==0||n)n=Ba(r,c);else{n=c;var m=De;De|=2;var f=Ym();(gt!==r||kt!==n)&&(Fr=null,fn=Xe()+500,Is(r,n));do try{pg();break}catch(A){qm(r,A)}while(!0);ui(),Ta.current=f,De=m,it!==null?n=0:(gt=null,kt=0,n=ut)}if(n!==0){if(n===2&&(m=_l(r),m!==0&&(c=m,n=Gi(r,m))),n===1)throw a=po,Is(r,0),is(r,c),Ht(r,Xe()),a;if(n===6)is(r,c);else{if(m=r.current.alternate,(c&30)===0&&!mg(m)&&(n=Ba(r,c),n===2&&(f=_l(r),f!==0&&(c=f,n=Gi(r,f))),n===1))throw a=po,Is(r,0),is(r,c),Ht(r,Xe()),a;switch(r.finishedWork=m,r.finishedLanes=c,n){case 0:case 1:throw Error(o(345));case 2:$s(r,zt,Fr);break;case 3:if(is(r,c),(c&130023424)===c&&(n=Vi+500-Xe(),10<n)){if(Vo(r,0)!==0)break;if(m=r.suspendedLanes,(m&c)!==c){Rt(),r.pingedLanes|=r.suspendedLanes&m;break}r.timeoutHandle=ei($s.bind(null,r,zt,Fr),n);break}$s(r,zt,Fr);break;case 4:if(is(r,c),(c&4194240)===c)break;for(n=r.eventTimes,m=-1;0<c;){var w=31-ur(c);f=1<<w,w=n[w],w>m&&(m=w),c&=~f}if(c=m,c=Xe()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*ug(c/1960))-c,10<c){r.timeoutHandle=ei($s.bind(null,r,zt,Fr),c);break}$s(r,zt,Fr);break;case 5:$s(r,zt,Fr);break;default:throw Error(o(329))}}}return Ht(r,Xe()),r.callbackNode===a?Um.bind(null,r):null}function Gi(r,n){var a=xo;return r.current.memoizedState.isDehydrated&&(Is(r,n).flags|=256),r=Ba(r,n),r!==2&&(n=zt,zt=a,n!==null&&Ki(n)),r}function Ki(r){zt===null?zt=r:zt.push.apply(zt,r)}function mg(r){for(var n=r;;){if(n.flags&16384){var a=n.updateQueue;if(a!==null&&(a=a.stores,a!==null))for(var c=0;c<a.length;c++){var m=a[c],f=m.getSnapshot;m=m.value;try{if(!mr(f(),m))return!1}catch{return!1}}}if(a=n.child,n.subtreeFlags&16384&&a!==null)a.return=n,n=a;else{if(n===r)break;for(;n.sibling===null;){if(n.return===null||n.return===r)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function is(r,n){for(n&=~Ui,n&=~Aa,r.suspendedLanes|=n,r.pingedLanes&=~n,r=r.expirationTimes;0<n;){var a=31-ur(n),c=1<<a;r[a]=-1,n&=~c}}function Vm(r){if((De&6)!==0)throw Error(o(327));gn();var n=Vo(r,0);if((n&1)===0)return Ht(r,Xe()),null;var a=Ba(r,n);if(r.tag!==0&&a===2){var c=_l(r);c!==0&&(n=c,a=Gi(r,c))}if(a===1)throw a=po,Is(r,0),is(r,n),Ht(r,Xe()),a;if(a===6)throw Error(o(345));return r.finishedWork=r.current.alternate,r.finishedLanes=n,$s(r,zt,Fr),Ht(r,Xe()),null}function Ji(r,n){var a=De;De|=1;try{return r(n)}finally{De=a,De===0&&(fn=Xe()+500,da&&ts())}}function Rs(r){as!==null&&as.tag===0&&(De&6)===0&&gn();var n=De;De|=1;var a=or.transition,c=ze;try{if(or.transition=null,ze=1,r)return r()}finally{ze=c,or.transition=a,De=n,(De&6)===0&&ts()}}function Qi(){Qt=xn.current,Ye(xn)}function Is(r,n){r.finishedWork=null,r.finishedLanes=0;var a=r.timeoutHandle;if(a!==-1&&(r.timeoutHandle=-1,zf(a)),it!==null)for(a=it.return;a!==null;){var c=a;switch(ai(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&ia();break;case 3:mn(),Ye(Ot),Ye(St),vi();break;case 5:gi(c);break;case 4:mn();break;case 13:Ye(Ke);break;case 19:Ye(Ke);break;case 10:mi(c.type._context);break;case 22:case 23:Qi()}a=a.return}if(gt=r,it=r=cs(r.current,null),kt=Qt=n,ut=0,po=null,Ui=Aa=Ms=0,zt=xo=null,Ts!==null){for(n=0;n<Ts.length;n++)if(a=Ts[n],c=a.interleaved,c!==null){a.interleaved=null;var m=c.next,f=a.pending;if(f!==null){var w=f.next;f.next=m,c.next=w}a.pending=c}Ts=null}return r}function qm(r,n){do{var a=it;try{if(ui(),wa.current=ka,ba){for(var c=Je.memoizedState;c!==null;){var m=c.queue;m!==null&&(m.pending=null),c=c.next}ba=!1}if(Ps=0,ft=dt=Je=null,lo=!1,io=0,Hi.current=null,a===null||a.return===null){ut=1,po=n,it=null;break}e:{var f=r,w=a.return,A=a,$=n;if(n=kt,A.flags|=32768,$!==null&&typeof $=="object"&&typeof $.then=="function"){var Q=$,le=A,de=le.tag;if((le.mode&1)===0&&(de===0||de===11||de===15)){var oe=le.alternate;oe?(le.updateQueue=oe.updateQueue,le.memoizedState=oe.memoizedState,le.lanes=oe.lanes):(le.updateQueue=null,le.memoizedState=null)}var xe=gm(w);if(xe!==null){xe.flags&=-257,ym(xe,w,A,f,n),xe.mode&1&&fm(f,Q,n),n=xe,$=Q;var ge=n.updateQueue;if(ge===null){var ye=new Set;ye.add($),n.updateQueue=ye}else ge.add($);break e}else{if((n&1)===0){fm(f,Q,n),Xi();break e}$=Error(o(426))}}else if(Ge&&A.mode&1){var Ze=gm(w);if(Ze!==null){(Ze.flags&65536)===0&&(Ze.flags|=256),ym(Ze,w,A,f,n),ci(hn($,A));break e}}f=$=hn($,A),ut!==4&&(ut=2),xo===null?xo=[f]:xo.push(f),f=w;do{switch(f.tag){case 3:f.flags|=65536,n&=-n,f.lanes|=n;var V=pm(f,$,n);Wu(f,V);break e;case 1:A=$;var B=f.type,G=f.stateNode;if((f.flags&128)===0&&(typeof B.getDerivedStateFromError=="function"||G!==null&&typeof G.componentDidCatch=="function"&&(os===null||!os.has(G)))){f.flags|=65536,n&=-n,f.lanes|=n;var me=xm(f,A,n);Wu(f,me);break e}}f=f.return}while(f!==null)}Km(a)}catch(ve){n=ve,it===a&&a!==null&&(it=a=a.return);continue}break}while(!0)}function Ym(){var r=Ta.current;return Ta.current=ka,r===null?ka:r}function Xi(){(ut===0||ut===3||ut===2)&&(ut=4),gt===null||(Ms&268435455)===0&&(Aa&268435455)===0||is(gt,kt)}function Ba(r,n){var a=De;De|=2;var c=Ym();(gt!==r||kt!==n)&&(Fr=null,Is(r,n));do try{hg();break}catch(m){qm(r,m)}while(!0);if(ui(),De=a,Ta.current=c,it!==null)throw Error(o(261));return gt=null,kt=0,ut}function hg(){for(;it!==null;)Gm(it)}function pg(){for(;it!==null&&!Dx();)Gm(it)}function Gm(r){var n=Xm(r.alternate,r,Qt);r.memoizedProps=r.pendingProps,n===null?Km(r):it=n,Hi.current=null}function Km(r){var n=r;do{var a=n.alternate;if(r=n.return,(n.flags&32768)===0){if(a=ag(a,n,Qt),a!==null){it=a;return}}else{if(a=lg(a,n),a!==null){a.flags&=32767,it=a;return}if(r!==null)r.flags|=32768,r.subtreeFlags=0,r.deletions=null;else{ut=6,it=null;return}}if(n=n.sibling,n!==null){it=n;return}it=n=r}while(n!==null);ut===0&&(ut=5)}function $s(r,n,a){var c=ze,m=or.transition;try{or.transition=null,ze=1,xg(r,n,a,c)}finally{or.transition=m,ze=c}return null}function xg(r,n,a,c){do gn();while(as!==null);if((De&6)!==0)throw Error(o(327));a=r.finishedWork;var m=r.finishedLanes;if(a===null)return null;if(r.finishedWork=null,r.finishedLanes=0,a===r.current)throw Error(o(177));r.callbackNode=null,r.callbackPriority=0;var f=a.lanes|a.childLanes;if(Gx(r,f),r===gt&&(it=gt=null,kt=0),(a.subtreeFlags&2064)===0&&(a.flags&2064)===0||Ma||(Ma=!0,Zm(Wo,function(){return gn(),null})),f=(a.flags&15990)!==0,(a.subtreeFlags&15990)!==0||f){f=or.transition,or.transition=null;var w=ze;ze=1;var A=De;De|=4,Hi.current=null,cg(r,a),Om(a,r),If(Xl),Go=!!Ql,Xl=Ql=null,r.current=a,dg(a),Ox(),De=A,ze=w,or.transition=f}else r.current=a;if(Ma&&(Ma=!1,as=r,Ra=m),f=r.pendingLanes,f===0&&(os=null),zx(a.stateNode),Ht(r,Xe()),n!==null)for(c=r.onRecoverableError,a=0;a<n.length;a++)m=n[a],c(m.value,{componentStack:m.stack,digest:m.digest});if(Pa)throw Pa=!1,r=qi,qi=null,r;return(Ra&1)!==0&&r.tag!==0&&gn(),f=r.pendingLanes,(f&1)!==0?r===Yi?fo++:(fo=0,Yi=r):fo=0,ts(),null}function gn(){if(as!==null){var r=Bd(Ra),n=or.transition,a=ze;try{if(or.transition=null,ze=16>r?16:r,as===null)var c=!1;else{if(r=as,as=null,Ra=0,(De&6)!==0)throw Error(o(331));var m=De;for(De|=4,fe=r.current;fe!==null;){var f=fe,w=f.child;if((fe.flags&16)!==0){var A=f.deletions;if(A!==null){for(var $=0;$<A.length;$++){var Q=A[$];for(fe=Q;fe!==null;){var le=fe;switch(le.tag){case 0:case 11:case 15:ho(8,le,f)}var de=le.child;if(de!==null)de.return=le,fe=de;else for(;fe!==null;){le=fe;var oe=le.sibling,xe=le.return;if(Rm(le),le===Q){fe=null;break}if(oe!==null){oe.return=xe,fe=oe;break}fe=xe}}}var ge=f.alternate;if(ge!==null){var ye=ge.child;if(ye!==null){ge.child=null;do{var Ze=ye.sibling;ye.sibling=null,ye=Ze}while(ye!==null)}}fe=f}}if((f.subtreeFlags&2064)!==0&&w!==null)w.return=f,fe=w;else e:for(;fe!==null;){if(f=fe,(f.flags&2048)!==0)switch(f.tag){case 0:case 11:case 15:ho(9,f,f.return)}var V=f.sibling;if(V!==null){V.return=f.return,fe=V;break e}fe=f.return}}var B=r.current;for(fe=B;fe!==null;){w=fe;var G=w.child;if((w.subtreeFlags&2064)!==0&&G!==null)G.return=w,fe=G;else e:for(w=B;fe!==null;){if(A=fe,(A.flags&2048)!==0)try{switch(A.tag){case 0:case 11:case 15:Ea(9,A)}}catch(ve){Qe(A,A.return,ve)}if(A===w){fe=null;break e}var me=A.sibling;if(me!==null){me.return=A.return,fe=me;break e}fe=A.return}}if(De=m,ts(),br&&typeof br.onPostCommitFiberRoot=="function")try{br.onPostCommitFiberRoot(zo,r)}catch{}c=!0}return c}finally{ze=a,or.transition=n}}return!1}function Jm(r,n,a){n=hn(a,n),n=pm(r,n,1),r=ss(r,n,1),n=Rt(),r!==null&&(On(r,1,n),Ht(r,n))}function Qe(r,n,a){if(r.tag===3)Jm(r,r,a);else for(;n!==null;){if(n.tag===3){Jm(n,r,a);break}else if(n.tag===1){var c=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(os===null||!os.has(c))){r=hn(a,r),r=xm(n,r,1),n=ss(n,r,1),r=Rt(),n!==null&&(On(n,1,r),Ht(n,r));break}}n=n.return}}function fg(r,n,a){var c=r.pingCache;c!==null&&c.delete(n),n=Rt(),r.pingedLanes|=r.suspendedLanes&a,gt===r&&(kt&a)===a&&(ut===4||ut===3&&(kt&130023424)===kt&&500>Xe()-Vi?Is(r,0):Ui|=a),Ht(r,n)}function Qm(r,n){n===0&&((r.mode&1)===0?n=1:(n=Uo,Uo<<=1,(Uo&130023424)===0&&(Uo=4194304)));var a=Rt();r=Br(r,n),r!==null&&(On(r,n,a),Ht(r,a))}function gg(r){var n=r.memoizedState,a=0;n!==null&&(a=n.retryLane),Qm(r,a)}function yg(r,n){var a=0;switch(r.tag){case 13:var c=r.stateNode,m=r.memoizedState;m!==null&&(a=m.retryLane);break;case 19:c=r.stateNode;break;default:throw Error(o(314))}c!==null&&c.delete(n),Qm(r,a)}var Xm;Xm=function(r,n,a){if(r!==null)if(r.memoizedProps!==n.pendingProps||Ot.current)Wt=!0;else{if((r.lanes&a)===0&&(n.flags&128)===0)return Wt=!1,og(r,n,a);Wt=(r.flags&131072)!==0}else Wt=!1,Ge&&(n.flags&1048576)!==0&&Au(n,ma,n.index);switch(n.lanes=0,n.tag){case 2:var c=n.type;_a(r,n),r=n.pendingProps;var m=nn(n,St.current);un(n,a),m=ji(null,n,c,r,m,a);var f=Ni();return n.flags|=1,typeof m=="object"&&m!==null&&typeof m.render=="function"&&m.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Ft(c)?(f=!0,ca(n)):f=!1,n.memoizedState=m.state!==null&&m.state!==void 0?m.state:null,xi(n),m.updater=Ca,n.stateNode=m,m._reactInternals=n,Ei(n,c,r,a),n=Mi(null,n,c,!0,f,a)):(n.tag=0,Ge&&f&&oi(n),Mt(null,n,m,a),n=n.child),n;case 16:c=n.elementType;e:{switch(_a(r,n),r=n.pendingProps,m=c._init,c=m(c._payload),n.type=c,m=n.tag=wg(c),r=pr(c,r),m){case 0:n=Pi(null,n,c,r,a);break e;case 1:n=km(null,n,c,r,a);break e;case 11:n=vm(null,n,c,r,a);break e;case 14:n=wm(null,n,c,pr(c.type,r),a);break e}throw Error(o(306,c,""))}return n;case 0:return c=n.type,m=n.pendingProps,m=n.elementType===c?m:pr(c,m),Pi(r,n,c,m,a);case 1:return c=n.type,m=n.pendingProps,m=n.elementType===c?m:pr(c,m),km(r,n,c,m,a);case 3:e:{if(Cm(n),r===null)throw Error(o(387));c=n.pendingProps,f=n.memoizedState,m=f.element,Fu(r,n),ya(n,c,null,a);var w=n.memoizedState;if(c=w.element,f.isDehydrated)if(f={element:c,isDehydrated:!1,cache:w.cache,pendingSuspenseBoundaries:w.pendingSuspenseBoundaries,transitions:w.transitions},n.updateQueue.baseState=f,n.memoizedState=f,n.flags&256){m=hn(Error(o(423)),n),n=Sm(r,n,c,a,m);break e}else if(c!==m){m=hn(Error(o(424)),n),n=Sm(r,n,c,a,m);break e}else for(Jt=Xr(n.stateNode.containerInfo.firstChild),Kt=n,Ge=!0,hr=null,a=Du(n,null,c,a),n.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(ln(),c===m){n=Or(r,n,a);break e}Mt(r,n,c,a)}n=n.child}return n;case 5:return Hu(n),r===null&&ii(n),c=n.type,m=n.pendingProps,f=r!==null?r.memoizedProps:null,w=m.children,Zl(c,m)?w=null:f!==null&&Zl(c,f)&&(n.flags|=32),Nm(r,n),Mt(r,n,w,a),n.child;case 6:return r===null&&ii(n),null;case 13:return _m(r,n,a);case 4:return fi(n,n.stateNode.containerInfo),c=n.pendingProps,r===null?n.child=cn(n,null,c,a):Mt(r,n,c,a),n.child;case 11:return c=n.type,m=n.pendingProps,m=n.elementType===c?m:pr(c,m),vm(r,n,c,m,a);case 7:return Mt(r,n,n.pendingProps,a),n.child;case 8:return Mt(r,n,n.pendingProps.children,a),n.child;case 12:return Mt(r,n,n.pendingProps.children,a),n.child;case 10:e:{if(c=n.type._context,m=n.pendingProps,f=n.memoizedProps,w=m.value,He(xa,c._currentValue),c._currentValue=w,f!==null)if(mr(f.value,w)){if(f.children===m.children&&!Ot.current){n=Or(r,n,a);break e}}else for(f=n.child,f!==null&&(f.return=n);f!==null;){var A=f.dependencies;if(A!==null){w=f.child;for(var $=A.firstContext;$!==null;){if($.context===c){if(f.tag===1){$=Dr(-1,a&-a),$.tag=2;var Q=f.updateQueue;if(Q!==null){Q=Q.shared;var le=Q.pending;le===null?$.next=$:($.next=le.next,le.next=$),Q.pending=$}}f.lanes|=a,$=f.alternate,$!==null&&($.lanes|=a),hi(f.return,a,n),A.lanes|=a;break}$=$.next}}else if(f.tag===10)w=f.type===n.type?null:f.child;else if(f.tag===18){if(w=f.return,w===null)throw Error(o(341));w.lanes|=a,A=w.alternate,A!==null&&(A.lanes|=a),hi(w,a,n),w=f.sibling}else w=f.child;if(w!==null)w.return=f;else for(w=f;w!==null;){if(w===n){w=null;break}if(f=w.sibling,f!==null){f.return=w.return,w=f;break}w=w.return}f=w}Mt(r,n,m.children,a),n=n.child}return n;case 9:return m=n.type,c=n.pendingProps.children,un(n,a),m=sr(m),c=c(m),n.flags|=1,Mt(r,n,c,a),n.child;case 14:return c=n.type,m=pr(c,n.pendingProps),m=pr(c.type,m),wm(r,n,c,m,a);case 15:return bm(r,n,n.type,n.pendingProps,a);case 17:return c=n.type,m=n.pendingProps,m=n.elementType===c?m:pr(c,m),_a(r,n),n.tag=1,Ft(c)?(r=!0,ca(n)):r=!1,un(n,a),mm(n,c,m),Ei(n,c,m,a),Mi(null,n,c,!0,r,a);case 19:return Em(r,n,a);case 22:return jm(r,n,a)}throw Error(o(156,n.tag))};function Zm(r,n){return Pd(r,n)}function vg(r,n,a,c){this.tag=r,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ar(r,n,a,c){return new vg(r,n,a,c)}function Zi(r){return r=r.prototype,!(!r||!r.isReactComponent)}function wg(r){if(typeof r=="function")return Zi(r)?1:0;if(r!=null){if(r=r.$$typeof,r===X)return 11;if(r===te)return 14}return 2}function cs(r,n){var a=r.alternate;return a===null?(a=ar(r.tag,n,r.key,r.mode),a.elementType=r.elementType,a.type=r.type,a.stateNode=r.stateNode,a.alternate=r,r.alternate=a):(a.pendingProps=n,a.type=r.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=r.flags&14680064,a.childLanes=r.childLanes,a.lanes=r.lanes,a.child=r.child,a.memoizedProps=r.memoizedProps,a.memoizedState=r.memoizedState,a.updateQueue=r.updateQueue,n=r.dependencies,a.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},a.sibling=r.sibling,a.index=r.index,a.ref=r.ref,a}function Da(r,n,a,c,m,f){var w=2;if(c=r,typeof r=="function")Zi(r)&&(w=1);else if(typeof r=="string")w=5;else e:switch(r){case M:return Bs(a.children,m,f,n);case q:w=8,m|=8;break;case z:return r=ar(12,a,n,m|2),r.elementType=z,r.lanes=f,r;case ee:return r=ar(13,a,n,m),r.elementType=ee,r.lanes=f,r;case W:return r=ar(19,a,n,m),r.elementType=W,r.lanes=f,r;case R:return Oa(a,m,f,n);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case U:w=10;break e;case O:w=9;break e;case X:w=11;break e;case te:w=14;break e;case D:w=16,c=null;break e}throw Error(o(130,r==null?r:typeof r,""))}return n=ar(w,a,n,m),n.elementType=r,n.type=c,n.lanes=f,n}function Bs(r,n,a,c){return r=ar(7,r,c,n),r.lanes=a,r}function Oa(r,n,a,c){return r=ar(22,r,c,n),r.elementType=R,r.lanes=a,r.stateNode={isHidden:!1},r}function ec(r,n,a){return r=ar(6,r,null,n),r.lanes=a,r}function tc(r,n,a){return n=ar(4,r.children!==null?r.children:[],r.key,n),n.lanes=a,n.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},n}function bg(r,n,a,c,m){this.tag=n,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ll(0),this.expirationTimes=Ll(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ll(0),this.identifierPrefix=c,this.onRecoverableError=m,this.mutableSourceEagerHydrationData=null}function rc(r,n,a,c,m,f,w,A,$){return r=new bg(r,n,a,A,$),n===1?(n=1,f===!0&&(n|=8)):n=0,f=ar(3,null,null,n),r.current=f,f.stateNode=r,f.memoizedState={element:c,isDehydrated:a,cache:null,transitions:null,pendingSuspenseBoundaries:null},xi(f),r}function jg(r,n,a){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:I,key:c==null?null:""+c,children:r,containerInfo:n,implementation:a}}function e0(r){if(!r)return es;r=r._reactInternals;e:{if(Cs(r)!==r||r.tag!==1)throw Error(o(170));var n=r;do{switch(n.tag){case 3:n=n.stateNode.context;break e;case 1:if(Ft(n.type)){n=n.stateNode.__reactInternalMemoizedMergedChildContext;break e}}n=n.return}while(n!==null);throw Error(o(171))}if(r.tag===1){var a=r.type;if(Ft(a))return Lu(r,a,n)}return n}function t0(r,n,a,c,m,f,w,A,$){return r=rc(a,c,!0,r,m,f,w,A,$),r.context=e0(null),a=r.current,c=Rt(),m=ls(a),f=Dr(c,m),f.callback=n??null,ss(a,f,m),r.current.lanes=m,On(r,m,c),Ht(r,c),r}function Fa(r,n,a,c){var m=n.current,f=Rt(),w=ls(m);return a=e0(a),n.context===null?n.context=a:n.pendingContext=a,n=Dr(f,w),n.payload={element:r},c=c===void 0?null:c,c!==null&&(n.callback=c),r=ss(m,n,w),r!==null&&(gr(r,m,w,f),ga(r,m,w)),w}function Wa(r){if(r=r.current,!r.child)return null;switch(r.child.tag){case 5:return r.child.stateNode;default:return r.child.stateNode}}function r0(r,n){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var a=r.retryLane;r.retryLane=a!==0&&a<n?a:n}}function sc(r,n){r0(r,n),(r=r.alternate)&&r0(r,n)}function Ng(){return null}var s0=typeof reportError=="function"?reportError:function(r){console.error(r)};function nc(r){this._internalRoot=r}za.prototype.render=nc.prototype.render=function(r){var n=this._internalRoot;if(n===null)throw Error(o(409));Fa(r,n,null,null)},za.prototype.unmount=nc.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var n=r.containerInfo;Rs(function(){Fa(null,r,null,null)}),n[Mr]=null}};function za(r){this._internalRoot=r}za.prototype.unstable_scheduleHydration=function(r){if(r){var n=Fd();r={blockedOn:null,target:r,priority:n};for(var a=0;a<Kr.length&&n!==0&&n<Kr[a].priority;a++);Kr.splice(a,0,r),a===0&&Hd(r)}};function oc(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function Ha(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11&&(r.nodeType!==8||r.nodeValue!==" react-mount-point-unstable "))}function n0(){}function kg(r,n,a,c,m){if(m){if(typeof c=="function"){var f=c;c=function(){var Q=Wa(w);f.call(Q)}}var w=t0(n,c,r,0,null,!1,!1,"",n0);return r._reactRootContainer=w,r[Mr]=w.current,Zn(r.nodeType===8?r.parentNode:r),Rs(),w}for(;m=r.lastChild;)r.removeChild(m);if(typeof c=="function"){var A=c;c=function(){var Q=Wa($);A.call(Q)}}var $=rc(r,0,!1,null,null,!1,!1,"",n0);return r._reactRootContainer=$,r[Mr]=$.current,Zn(r.nodeType===8?r.parentNode:r),Rs(function(){Fa(n,$,a,c)}),$}function Ua(r,n,a,c,m){var f=a._reactRootContainer;if(f){var w=f;if(typeof m=="function"){var A=m;m=function(){var $=Wa(w);A.call($)}}Fa(n,w,r,m)}else w=kg(a,n,r,m,c);return Wa(w)}Dd=function(r){switch(r.tag){case 3:var n=r.stateNode;if(n.current.memoizedState.isDehydrated){var a=Dn(n.pendingLanes);a!==0&&(El(n,a|1),Ht(n,Xe()),(De&6)===0&&(fn=Xe()+500,ts()))}break;case 13:Rs(function(){var c=Br(r,1);if(c!==null){var m=Rt();gr(c,r,1,m)}}),sc(r,1)}},Tl=function(r){if(r.tag===13){var n=Br(r,134217728);if(n!==null){var a=Rt();gr(n,r,134217728,a)}sc(r,134217728)}},Od=function(r){if(r.tag===13){var n=ls(r),a=Br(r,n);if(a!==null){var c=Rt();gr(a,r,n,c)}sc(r,n)}},Fd=function(){return ze},Wd=function(r,n){var a=ze;try{return ze=r,n()}finally{ze=a}},be=function(r,n,a){switch(n){case"input":if(Ee(r,a),n=a.name,a.type==="radio"&&n!=null){for(a=r;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll("input[name="+JSON.stringify(""+n)+'][type="radio"]'),n=0;n<a.length;n++){var c=a[n];if(c!==r&&c.form===r.form){var m=la(c);if(!m)throw Error(o(90));Ne(c),Ee(c,m)}}}break;case"textarea":Pt(r,a);break;case"select":n=a.value,n!=null&&bt(r,!!a.multiple,n,!1)}},Cd=Ji,Sd=Rs;var Cg={usingClientEntryPoint:!1,Events:[ro,rn,la,Nd,kd,Ji]},go={findFiberByHostInstance:Ss,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Sg={bundleType:go.bundleType,version:go.version,rendererPackageName:go.rendererPackageName,rendererConfig:go.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:C.ReactCurrentDispatcher,findHostInstanceByFiber:function(r){return r=Td(r),r===null?null:r.stateNode},findFiberByHostInstance:go.findFiberByHostInstance||Ng,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Va=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Va.isDisabled&&Va.supportsFiber)try{zo=Va.inject(Sg),br=Va}catch{}}return Ut.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Cg,Ut.createPortal=function(r,n){var a=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!oc(n))throw Error(o(200));return jg(r,n,null,a)},Ut.createRoot=function(r,n){if(!oc(r))throw Error(o(299));var a=!1,c="",m=s0;return n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(c=n.identifierPrefix),n.onRecoverableError!==void 0&&(m=n.onRecoverableError)),n=rc(r,1,!1,null,null,a,!1,c,m),r[Mr]=n.current,Zn(r.nodeType===8?r.parentNode:r),new nc(n)},Ut.findDOMNode=function(r){if(r==null)return null;if(r.nodeType===1)return r;var n=r._reactInternals;if(n===void 0)throw typeof r.render=="function"?Error(o(188)):(r=Object.keys(r).join(","),Error(o(268,r)));return r=Td(n),r=r===null?null:r.stateNode,r},Ut.flushSync=function(r){return Rs(r)},Ut.hydrate=function(r,n,a){if(!Ha(n))throw Error(o(200));return Ua(null,r,n,!0,a)},Ut.hydrateRoot=function(r,n,a){if(!oc(r))throw Error(o(405));var c=a!=null&&a.hydratedSources||null,m=!1,f="",w=s0;if(a!=null&&(a.unstable_strictMode===!0&&(m=!0),a.identifierPrefix!==void 0&&(f=a.identifierPrefix),a.onRecoverableError!==void 0&&(w=a.onRecoverableError)),n=t0(n,null,r,1,a??null,m,!1,f,w),r[Mr]=n.current,Zn(r),c)for(r=0;r<c.length;r++)a=c[r],m=a._getVersion,m=m(a._source),n.mutableSourceEagerHydrationData==null?n.mutableSourceEagerHydrationData=[a,m]:n.mutableSourceEagerHydrationData.push(a,m);return new za(n)},Ut.render=function(r,n,a){if(!Ha(n))throw Error(o(200));return Ua(null,r,n,!1,a)},Ut.unmountComponentAtNode=function(r){if(!Ha(r))throw Error(o(40));return r._reactRootContainer?(Rs(function(){Ua(null,null,r,!1,function(){r._reactRootContainer=null,r[Mr]=null})}),!0):!1},Ut.unstable_batchedUpdates=Ji,Ut.unstable_renderSubtreeIntoContainer=function(r,n,a,c){if(!Ha(a))throw Error(o(200));if(r==null||r._reactInternals===void 0)throw Error(o(38));return Ua(r,n,a,!1,c)},Ut.version="18.3.1-next-f1338f8080-20240426",Ut}var m0;function kh(){if(m0)return ic.exports;m0=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(s){console.error(s)}}return t(),ic.exports=Ig(),ic.exports}var h0;function $g(){if(h0)return qa;h0=1;var t=kh();return qa.createRoot=t.createRoot,qa.hydrateRoot=t.hydrateRoot,qa}var Bg=$g();const Dg=Nh(Bg);kh();/**
41
- * @remix-run/router v1.23.2
42
- *
43
- * Copyright (c) Remix Software Inc.
44
- *
45
- * This source code is licensed under the MIT license found in the
46
- * LICENSE.md file in the root directory of this source tree.
47
- *
48
- * @license MIT
49
- */function ko(){return ko=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var o=arguments[s];for(var l in o)Object.prototype.hasOwnProperty.call(o,l)&&(t[l]=o[l])}return t},ko.apply(this,arguments)}var ms;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(ms||(ms={}));const p0="popstate";function Og(t){t===void 0&&(t={});function s(l,i){let{pathname:d,search:u,hash:h}=l.location;return Nc("",{pathname:d,search:u,hash:h},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function o(l,i){return typeof i=="string"?i:Xa(i)}return Wg(s,o,null,t)}function st(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function Wc(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function Fg(){return Math.random().toString(36).substr(2,8)}function x0(t,s){return{usr:t.state,key:t.key,idx:s}}function Nc(t,s,o,l){return o===void 0&&(o=null),ko({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof s=="string"?Ln(s):s,{state:o,key:s&&s.key||l||Fg()})}function Xa(t){let{pathname:s="/",search:o="",hash:l=""}=t;return o&&o!=="?"&&(s+=o.charAt(0)==="?"?o:"?"+o),l&&l!=="#"&&(s+=l.charAt(0)==="#"?l:"#"+l),s}function Ln(t){let s={};if(t){let o=t.indexOf("#");o>=0&&(s.hash=t.substr(o),t=t.substr(0,o));let l=t.indexOf("?");l>=0&&(s.search=t.substr(l),t=t.substr(0,l)),t&&(s.pathname=t)}return s}function Wg(t,s,o,l){l===void 0&&(l={});let{window:i=document.defaultView,v5Compat:d=!1}=l,u=i.history,h=ms.Pop,x=null,g=v();g==null&&(g=0,u.replaceState(ko({},u.state,{idx:g}),""));function v(){return(u.state||{idx:null}).idx}function y(){h=ms.Pop;let j=v(),N=j==null?null:j-g;g=j,x&&x({action:h,location:S.location,delta:N})}function b(j,N){h=ms.Push;let T=Nc(S.location,j,N);g=v()+1;let P=x0(T,g),C=S.createHref(T);try{u.pushState(P,"",C)}catch(E){if(E instanceof DOMException&&E.name==="DataCloneError")throw E;i.location.assign(C)}d&&x&&x({action:h,location:S.location,delta:1})}function k(j,N){h=ms.Replace;let T=Nc(S.location,j,N);g=v();let P=x0(T,g),C=S.createHref(T);u.replaceState(P,"",C),d&&x&&x({action:h,location:S.location,delta:0})}function _(j){let N=i.location.origin!=="null"?i.location.origin:i.location.href,T=typeof j=="string"?j:Xa(j);return T=T.replace(/ $/,"%20"),st(N,"No window.location.(origin|href) available to create URL for href: "+T),new URL(T,N)}let S={get action(){return h},get location(){return t(i,u)},listen(j){if(x)throw new Error("A history only accepts one active listener");return i.addEventListener(p0,y),x=j,()=>{i.removeEventListener(p0,y),x=null}},createHref(j){return s(i,j)},createURL:_,encodeLocation(j){let N=_(j);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:b,replace:k,go(j){return u.go(j)}};return S}var f0;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(f0||(f0={}));function zg(t,s,o){return o===void 0&&(o="/"),Hg(t,s,o)}function Hg(t,s,o,l){let i=typeof s=="string"?Ln(s):s,d=zc(i.pathname||"/",o);if(d==null)return null;let u=Ch(t);Ug(u);let h=null;for(let x=0;h==null&&x<u.length;++x){let g=ry(d);h=Zg(u[x],g)}return h}function Ch(t,s,o,l){s===void 0&&(s=[]),o===void 0&&(o=[]),l===void 0&&(l="");let i=(d,u,h)=>{let x={relativePath:h===void 0?d.path||"":h,caseSensitive:d.caseSensitive===!0,childrenIndex:u,route:d};x.relativePath.startsWith("/")&&(st(x.relativePath.startsWith(l),'Absolute route path "'+x.relativePath+'" nested under path '+('"'+l+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),x.relativePath=x.relativePath.slice(l.length));let g=gs([l,x.relativePath]),v=o.concat(x);d.children&&d.children.length>0&&(st(d.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+g+'".')),Ch(d.children,s,v,g)),!(d.path==null&&!d.index)&&s.push({path:g,score:Qg(g,d.index),routesMeta:v})};return t.forEach((d,u)=>{var h;if(d.path===""||!((h=d.path)!=null&&h.includes("?")))i(d,u);else for(let x of Sh(d.path))i(d,u,x)}),s}function Sh(t){let s=t.split("/");if(s.length===0)return[];let[o,...l]=s,i=o.endsWith("?"),d=o.replace(/\?$/,"");if(l.length===0)return i?[d,""]:[d];let u=Sh(l.join("/")),h=[];return h.push(...u.map(x=>x===""?d:[d,x].join("/"))),i&&h.push(...u),h.map(x=>t.startsWith("/")&&x===""?"/":x)}function Ug(t){t.sort((s,o)=>s.score!==o.score?o.score-s.score:Xg(s.routesMeta.map(l=>l.childrenIndex),o.routesMeta.map(l=>l.childrenIndex)))}const Vg=/^:[\w-]+$/,qg=3,Yg=2,Gg=1,Kg=10,Jg=-2,g0=t=>t==="*";function Qg(t,s){let o=t.split("/"),l=o.length;return o.some(g0)&&(l+=Jg),s&&(l+=Yg),o.filter(i=>!g0(i)).reduce((i,d)=>i+(Vg.test(d)?qg:d===""?Gg:Kg),l)}function Xg(t,s){return t.length===s.length&&t.slice(0,-1).every((l,i)=>l===s[i])?t[t.length-1]-s[s.length-1]:0}function Zg(t,s,o){let{routesMeta:l}=t,i={},d="/",u=[];for(let h=0;h<l.length;++h){let x=l[h],g=h===l.length-1,v=d==="/"?s:s.slice(d.length)||"/",y=ey({path:x.relativePath,caseSensitive:x.caseSensitive,end:g},v),b=x.route;if(!y)return null;Object.assign(i,y.params),u.push({params:i,pathname:gs([d,y.pathname]),pathnameBase:ly(gs([d,y.pathnameBase])),route:b}),y.pathnameBase!=="/"&&(d=gs([d,y.pathnameBase]))}return u}function ey(t,s){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[o,l]=ty(t.path,t.caseSensitive,t.end),i=s.match(o);if(!i)return null;let d=i[0],u=d.replace(/(.)\/+$/,"$1"),h=i.slice(1);return{params:l.reduce((g,v,y)=>{let{paramName:b,isOptional:k}=v;if(b==="*"){let S=h[y]||"";u=d.slice(0,d.length-S.length).replace(/(.)\/+$/,"$1")}const _=h[y];return k&&!_?g[b]=void 0:g[b]=(_||"").replace(/%2F/g,"/"),g},{}),pathname:d,pathnameBase:u,pattern:t}}function ty(t,s,o){s===void 0&&(s=!1),o===void 0&&(o=!0),Wc(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let l=[],i="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(u,h,x)=>(l.push({paramName:h,isOptional:x!=null}),x?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(l.push({paramName:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):o?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,s?void 0:"i"),l]}function ry(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return Wc(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+s+").")),t}}function zc(t,s){if(s==="/")return t;if(!t.toLowerCase().startsWith(s.toLowerCase()))return null;let o=s.endsWith("/")?s.length-1:s.length,l=t.charAt(o);return l&&l!=="/"?null:t.slice(o)||"/"}const sy=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ny=t=>sy.test(t);function oy(t,s){s===void 0&&(s="/");let{pathname:o,search:l="",hash:i=""}=typeof t=="string"?Ln(t):t,d;if(o)if(ny(o))d=o;else{if(o.includes("//")){let u=o;o=o.replace(/\/\/+/g,"/"),Wc(!1,"Pathnames cannot have embedded double slashes - normalizing "+(u+" -> "+o))}o.startsWith("/")?d=y0(o.substring(1),"/"):d=y0(o,s)}else d=s;return{pathname:d,search:iy(l),hash:cy(i)}}function y0(t,s){let o=s.replace(/\/+$/,"").split("/");return t.split("/").forEach(i=>{i===".."?o.length>1&&o.pop():i!=="."&&o.push(i)}),o.length>1?o.join("/"):"/"}function uc(t,s,o,l){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+s+"` field ["+JSON.stringify(l)+"]. Please separate it out to the ")+("`to."+o+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function ay(t){return t.filter((s,o)=>o===0||s.route.path&&s.route.path.length>0)}function Hc(t,s){let o=ay(t);return s?o.map((l,i)=>i===o.length-1?l.pathname:l.pathnameBase):o.map(l=>l.pathnameBase)}function Uc(t,s,o,l){l===void 0&&(l=!1);let i;typeof t=="string"?i=Ln(t):(i=ko({},t),st(!i.pathname||!i.pathname.includes("?"),uc("?","pathname","search",i)),st(!i.pathname||!i.pathname.includes("#"),uc("#","pathname","hash",i)),st(!i.search||!i.search.includes("#"),uc("#","search","hash",i)));let d=t===""||i.pathname==="",u=d?"/":i.pathname,h;if(u==null)h=o;else{let y=s.length-1;if(!l&&u.startsWith("..")){let b=u.split("/");for(;b[0]==="..";)b.shift(),y-=1;i.pathname=b.join("/")}h=y>=0?s[y]:"/"}let x=oy(i,h),g=u&&u!=="/"&&u.endsWith("/"),v=(d||u===".")&&o.endsWith("/");return!x.pathname.endsWith("/")&&(g||v)&&(x.pathname+="/"),x}const gs=t=>t.join("/").replace(/\/\/+/g,"/"),ly=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),iy=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,cy=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function dy(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const _h=["post","put","patch","delete"];new Set(_h);const uy=["get",..._h];new Set(uy);/**
50
- * React Router v6.30.3
51
- *
52
- * Copyright (c) Remix Software Inc.
53
- *
54
- * This source code is licensed under the MIT license found in the
55
- * LICENSE.md file in the root directory of this source tree.
56
- *
57
- * @license MIT
58
- */function Co(){return Co=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var o=arguments[s];for(var l in o)Object.prototype.hasOwnProperty.call(o,l)&&(t[l]=o[l])}return t},Co.apply(this,arguments)}const Vc=p.createContext(null),my=p.createContext(null),ws=p.createContext(null),xl=p.createContext(null),Er=p.createContext({outlet:null,matches:[],isDataRoute:!1}),Lh=p.createContext(null);function hy(t,s){let{relative:o}=s===void 0?{}:s;En()||st(!1);let{basename:l,navigator:i}=p.useContext(ws),{hash:d,pathname:u,search:h}=Th(t,{relative:o}),x=u;return l!=="/"&&(x=u==="/"?l:gs([l,u])),i.createHref({pathname:x,search:h,hash:d})}function En(){return p.useContext(xl)!=null}function bs(){return En()||st(!1),p.useContext(xl).location}function Eh(t){p.useContext(ws).static||p.useLayoutEffect(t)}function ir(){let{isDataRoute:t}=p.useContext(Er);return t?Ly():py()}function py(){En()||st(!1);let t=p.useContext(Vc),{basename:s,future:o,navigator:l}=p.useContext(ws),{matches:i}=p.useContext(Er),{pathname:d}=bs(),u=JSON.stringify(Hc(i,o.v7_relativeSplatPath)),h=p.useRef(!1);return Eh(()=>{h.current=!0}),p.useCallback(function(g,v){if(v===void 0&&(v={}),!h.current)return;if(typeof g=="number"){l.go(g);return}let y=Uc(g,JSON.parse(u),d,v.relative==="path");t==null&&s!=="/"&&(y.pathname=y.pathname==="/"?s:gs([s,y.pathname])),(v.replace?l.replace:l.push)(y,v.state,v)},[s,l,u,d,t])}const xy=p.createContext(null);function fy(t){let s=p.useContext(Er).outlet;return s&&p.createElement(xy.Provider,{value:t},s)}function yr(){let{matches:t}=p.useContext(Er),s=t[t.length-1];return s?s.params:{}}function Th(t,s){let{relative:o}=s===void 0?{}:s,{future:l}=p.useContext(ws),{matches:i}=p.useContext(Er),{pathname:d}=bs(),u=JSON.stringify(Hc(i,l.v7_relativeSplatPath));return p.useMemo(()=>Uc(t,JSON.parse(u),d,o==="path"),[t,u,d,o])}function gy(t,s){return yy(t,s)}function yy(t,s,o,l){En()||st(!1);let{navigator:i}=p.useContext(ws),{matches:d}=p.useContext(Er),u=d[d.length-1],h=u?u.params:{};u&&u.pathname;let x=u?u.pathnameBase:"/";u&&u.route;let g=bs(),v;if(s){var y;let j=typeof s=="string"?Ln(s):s;x==="/"||(y=j.pathname)!=null&&y.startsWith(x)||st(!1),v=j}else v=g;let b=v.pathname||"/",k=b;if(x!=="/"){let j=x.replace(/^\//,"").split("/");k="/"+b.replace(/^\//,"").split("/").slice(j.length).join("/")}let _=zg(t,{pathname:k}),S=Ny(_&&_.map(j=>Object.assign({},j,{params:Object.assign({},h,j.params),pathname:gs([x,i.encodeLocation?i.encodeLocation(j.pathname).pathname:j.pathname]),pathnameBase:j.pathnameBase==="/"?x:gs([x,i.encodeLocation?i.encodeLocation(j.pathnameBase).pathname:j.pathnameBase])})),d,o,l);return s&&S?p.createElement(xl.Provider,{value:{location:Co({pathname:"/",search:"",hash:"",state:null,key:"default"},v),navigationType:ms.Pop}},S):S}function vy(){let t=_y(),s=dy(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),o=t instanceof Error?t.stack:null,i={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return p.createElement(p.Fragment,null,p.createElement("h2",null,"Unexpected Application Error!"),p.createElement("h3",{style:{fontStyle:"italic"}},s),o?p.createElement("pre",{style:i},o):null,null)}const wy=p.createElement(vy,null);class by extends p.Component{constructor(s){super(s),this.state={location:s.location,revalidation:s.revalidation,error:s.error}}static getDerivedStateFromError(s){return{error:s}}static getDerivedStateFromProps(s,o){return o.location!==s.location||o.revalidation!=="idle"&&s.revalidation==="idle"?{error:s.error,location:s.location,revalidation:s.revalidation}:{error:s.error!==void 0?s.error:o.error,location:o.location,revalidation:s.revalidation||o.revalidation}}componentDidCatch(s,o){console.error("React Router caught the following error during render",s,o)}render(){return this.state.error!==void 0?p.createElement(Er.Provider,{value:this.props.routeContext},p.createElement(Lh.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function jy(t){let{routeContext:s,match:o,children:l}=t,i=p.useContext(Vc);return i&&i.static&&i.staticContext&&(o.route.errorElement||o.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=o.route.id),p.createElement(Er.Provider,{value:s},l)}function Ny(t,s,o,l){var i;if(s===void 0&&(s=[]),o===void 0&&(o=null),l===void 0&&(l=null),t==null){var d;if(!o)return null;if(o.errors)t=o.matches;else if((d=l)!=null&&d.v7_partialHydration&&s.length===0&&!o.initialized&&o.matches.length>0)t=o.matches;else return null}let u=t,h=(i=o)==null?void 0:i.errors;if(h!=null){let v=u.findIndex(y=>y.route.id&&(h==null?void 0:h[y.route.id])!==void 0);v>=0||st(!1),u=u.slice(0,Math.min(u.length,v+1))}let x=!1,g=-1;if(o&&l&&l.v7_partialHydration)for(let v=0;v<u.length;v++){let y=u[v];if((y.route.HydrateFallback||y.route.hydrateFallbackElement)&&(g=v),y.route.id){let{loaderData:b,errors:k}=o,_=y.route.loader&&b[y.route.id]===void 0&&(!k||k[y.route.id]===void 0);if(y.route.lazy||_){x=!0,g>=0?u=u.slice(0,g+1):u=[u[0]];break}}}return u.reduceRight((v,y,b)=>{let k,_=!1,S=null,j=null;o&&(k=h&&y.route.id?h[y.route.id]:void 0,S=y.route.errorElement||wy,x&&(g<0&&b===0?(Ey("route-fallback"),_=!0,j=null):g===b&&(_=!0,j=y.route.hydrateFallbackElement||null)));let N=s.concat(u.slice(0,b+1)),T=()=>{let P;return k?P=S:_?P=j:y.route.Component?P=p.createElement(y.route.Component,null):y.route.element?P=y.route.element:P=v,p.createElement(jy,{match:y,routeContext:{outlet:v,matches:N,isDataRoute:o!=null},children:P})};return o&&(y.route.ErrorBoundary||y.route.errorElement||b===0)?p.createElement(by,{location:o.location,revalidation:o.revalidation,component:S,error:k,children:T(),routeContext:{outlet:null,matches:N,isDataRoute:!0}}):T()},null)}var Ah=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(Ah||{}),Ph=(function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t})(Ph||{});function ky(t){let s=p.useContext(Vc);return s||st(!1),s}function Cy(t){let s=p.useContext(my);return s||st(!1),s}function Sy(t){let s=p.useContext(Er);return s||st(!1),s}function Mh(t){let s=Sy(),o=s.matches[s.matches.length-1];return o.route.id||st(!1),o.route.id}function _y(){var t;let s=p.useContext(Lh),o=Cy(),l=Mh();return s!==void 0?s:(t=o.errors)==null?void 0:t[l]}function Ly(){let{router:t}=ky(Ah.UseNavigateStable),s=Mh(Ph.UseNavigateStable),o=p.useRef(!1);return Eh(()=>{o.current=!0}),p.useCallback(function(i,d){d===void 0&&(d={}),o.current&&(typeof i=="number"?t.navigate(i):t.navigate(i,Co({fromRouteId:s},d)))},[t,s])}const v0={};function Ey(t,s,o){v0[t]||(v0[t]=!0)}function Ty(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function w0(t){let{to:s,replace:o,state:l,relative:i}=t;En()||st(!1);let{future:d,static:u}=p.useContext(ws),{matches:h}=p.useContext(Er),{pathname:x}=bs(),g=ir(),v=Uc(s,Hc(h,d.v7_relativeSplatPath),x,i==="path"),y=JSON.stringify(v);return p.useEffect(()=>g(JSON.parse(y),{replace:o,state:l,relative:i}),[g,y,i,o,l]),null}function Ay(t){return fy(t.context)}function mt(t){st(!1)}function Py(t){let{basename:s="/",children:o=null,location:l,navigationType:i=ms.Pop,navigator:d,static:u=!1,future:h}=t;En()&&st(!1);let x=s.replace(/^\/*/,"/"),g=p.useMemo(()=>({basename:x,navigator:d,static:u,future:Co({v7_relativeSplatPath:!1},h)}),[x,h,d,u]);typeof l=="string"&&(l=Ln(l));let{pathname:v="/",search:y="",hash:b="",state:k=null,key:_="default"}=l,S=p.useMemo(()=>{let j=zc(v,x);return j==null?null:{location:{pathname:j,search:y,hash:b,state:k,key:_},navigationType:i}},[x,v,y,b,k,_,i]);return S==null?null:p.createElement(ws.Provider,{value:g},p.createElement(xl.Provider,{children:o,value:S}))}function My(t){let{children:s,location:o}=t;return gy(kc(s),o)}new Promise(()=>{});function kc(t,s){s===void 0&&(s=[]);let o=[];return p.Children.forEach(t,(l,i)=>{if(!p.isValidElement(l))return;let d=[...s,i];if(l.type===p.Fragment){o.push.apply(o,kc(l.props.children,d));return}l.type!==mt&&st(!1),!l.props.index||!l.props.children||st(!1);let u={id:l.props.id||d.join("-"),caseSensitive:l.props.caseSensitive,element:l.props.element,Component:l.props.Component,index:l.props.index,path:l.props.path,loader:l.props.loader,action:l.props.action,errorElement:l.props.errorElement,ErrorBoundary:l.props.ErrorBoundary,hasErrorBoundary:l.props.ErrorBoundary!=null||l.props.errorElement!=null,shouldRevalidate:l.props.shouldRevalidate,handle:l.props.handle,lazy:l.props.lazy};l.props.children&&(u.children=kc(l.props.children,d)),o.push(u)}),o}/**
59
- * React Router DOM v6.30.3
60
- *
61
- * Copyright (c) Remix Software Inc.
62
- *
63
- * This source code is licensed under the MIT license found in the
64
- * LICENSE.md file in the root directory of this source tree.
65
- *
66
- * @license MIT
67
- */function Cc(){return Cc=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var o=arguments[s];for(var l in o)Object.prototype.hasOwnProperty.call(o,l)&&(t[l]=o[l])}return t},Cc.apply(this,arguments)}function Ry(t,s){if(t==null)return{};var o={},l=Object.keys(t),i,d;for(d=0;d<l.length;d++)i=l[d],!(s.indexOf(i)>=0)&&(o[i]=t[i]);return o}function Iy(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function $y(t,s){return t.button===0&&(!s||s==="_self")&&!Iy(t)}function Sc(t){return t===void 0&&(t=""),new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((s,o)=>{let l=t[o];return s.concat(Array.isArray(l)?l.map(i=>[o,i]):[[o,l]])},[]))}function By(t,s){let o=Sc(t);return s&&s.forEach((l,i)=>{o.has(i)||s.getAll(i).forEach(d=>{o.append(i,d)})}),o}const Dy=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],Oy="6";try{window.__reactRouterVersion=Oy}catch{}const Fy="startTransition",b0=Pg[Fy];function Wy(t){let{basename:s,children:o,future:l,window:i}=t,d=p.useRef();d.current==null&&(d.current=Og({window:i,v5Compat:!0}));let u=d.current,[h,x]=p.useState({action:u.action,location:u.location}),{v7_startTransition:g}=l||{},v=p.useCallback(y=>{g&&b0?b0(()=>x(y)):x(y)},[x,g]);return p.useLayoutEffect(()=>u.listen(v),[u,v]),p.useEffect(()=>Ty(l),[l]),p.createElement(Py,{basename:s,children:o,location:h.location,navigationType:h.action,navigator:u,future:l})}const zy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Hy=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Se=p.forwardRef(function(s,o){let{onClick:l,relative:i,reloadDocument:d,replace:u,state:h,target:x,to:g,preventScrollReset:v,viewTransition:y}=s,b=Ry(s,Dy),{basename:k}=p.useContext(ws),_,S=!1;if(typeof g=="string"&&Hy.test(g)&&(_=g,zy))try{let P=new URL(window.location.href),C=g.startsWith("//")?new URL(P.protocol+g):new URL(g),E=zc(C.pathname,k);C.origin===P.origin&&E!=null?g=E+C.search+C.hash:S=!0}catch{}let j=hy(g,{relative:i}),N=Uy(g,{replace:u,state:h,target:x,preventScrollReset:v,relative:i,viewTransition:y});function T(P){l&&l(P),P.defaultPrevented||N(P)}return p.createElement("a",Cc({},b,{href:_||j,onClick:S||d?l:T,ref:o,target:x}))});var j0;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(j0||(j0={}));var N0;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(N0||(N0={}));function Uy(t,s){let{target:o,replace:l,state:i,preventScrollReset:d,relative:u,viewTransition:h}=s===void 0?{}:s,x=ir(),g=bs(),v=Th(t,{relative:u});return p.useCallback(y=>{if($y(y,o)){y.preventDefault();let b=l!==void 0?l:Xa(g)===Xa(v);x(t,{replace:b,state:i,preventScrollReset:d,relative:u,viewTransition:h})}},[g,x,v,l,i,o,t,d,u,h])}function Vy(t){let s=p.useRef(Sc(t)),o=p.useRef(!1),l=bs(),i=p.useMemo(()=>By(l.search,o.current?null:s.current),[l.search]),d=ir(),u=p.useCallback((h,x)=>{const g=Sc(typeof h=="function"?h(i):h);o.current=!0,d("?"+g,x)},[d,i]);return[i,u]}const k0=t=>{let s;const o=new Set,l=(g,v)=>{const y=typeof g=="function"?g(s):g;if(!Object.is(y,s)){const b=s;s=v??(typeof y!="object"||y===null)?y:Object.assign({},s,y),o.forEach(k=>k(s,b))}},i=()=>s,h={setState:l,getState:i,getInitialState:()=>x,subscribe:g=>(o.add(g),()=>o.delete(g))},x=s=t(l,i,h);return h},qy=(t=>t?k0(t):k0),Yy=t=>t;function Gy(t,s=Yy){const o=bn.useSyncExternalStore(t.subscribe,bn.useCallback(()=>s(t.getState()),[t,s]),bn.useCallback(()=>s(t.getInitialState()),[t,s]));return bn.useDebugValue(o),o}const C0=t=>{const s=qy(t),o=l=>Gy(s,l);return Object.assign(o,s),o},Ky=(t=>t?C0(t):C0),Us="/api";class Tn extends Error{constructor(s,o,l){super(s),this.status=o,this.code=l,this.name="APIError"}}async function ce(t,s={}){var i,d;const o=`${Us}${t}`,l=await fetch(o,{...s,headers:{"Content-Type":"application/json",...s.headers}});if(!l.ok){const u=await l.json().catch(()=>({})),h=((i=u.error)==null?void 0:i.message)||u.detail||l.statusText;throw new Tn(h,l.status,(d=u.error)==null?void 0:d.code)}if(l.status!==204)return l.json()}async function Rh(){return ce("/health")}async function _c(){return ce("/projects")}async function Vs(t){return ce(`/projects/${t}`)}async function Jy(t){return ce("/projects",{method:"POST",body:JSON.stringify(t)})}async function Qy(t){return ce(`/projects/${t}`,{method:"DELETE"})}async function Xy(t="^e2e-",s=!0){return ce("/projects/cleanup",{method:"POST",body:JSON.stringify({pattern:t,dry_run:s})})}async function qc(t){return ce(`/projects/${t}/loops`)}async function S0(t,s){return ce(`/projects/${t}/loops/${s}`)}async function Ih(t,s){return ce(`/projects/${t}/loops/${s}/status`)}async function Lc(t,s,o){return ce(`/projects/${t}/loops/${s}/start`,{method:"POST",body:JSON.stringify(o||{})})}async function Zy(t,s){return ce(`/projects/${t}/loops/${s}/phases`)}async function ev(t,s){return ce(`/projects/${t}/loops/${s}/stop`,{method:"POST"})}async function tv(t,s){return ce(`/projects/${t}/loops/${s}/pause`,{method:"POST"})}async function rv(t,s){return ce(`/projects/${t}/loops/${s}/resume`,{method:"POST"})}async function sv(t,s){return ce(`/projects/${t}/loops/${s}`,{method:"DELETE"})}async function nv(t,s){return ce(`/projects/${t}/loops/${s}/config`)}async function ov(t,s,o){return ce(`/projects/${t}/loops/${s}/config`,{method:"PUT",body:JSON.stringify({content:o})})}async function Ao(t,s){const o=new URLSearchParams;s!=null&&s.status&&o.set("status",s.status),s!=null&&s.category&&o.set("category",s.category),s!=null&&s.workflow_id&&o.set("workflow_id",s.workflow_id),s!=null&&s.source_step_id&&o.set("source_step_id",s.source_step_id.toString()),s!=null&&s.limit&&o.set("limit",s.limit.toString()),s!=null&&s.offset&&o.set("offset",s.offset.toString());const l=o.toString();return ce(`/projects/${t}/items${l?`?${l}`:""}`)}async function av(t,s){return ce(`/projects/${t}/items/${s}`)}async function Yc(t,s){return ce(`/projects/${t}/items`,{method:"POST",body:JSON.stringify(s)})}async function Gc(t,s,o){return ce(`/projects/${t}/items/${s}`,{method:"PATCH",body:JSON.stringify(o)})}async function lv(t,s,o){const l=await av(t,s);return Yc(t,{workflow_id:l.workflow_id,source_step_id:l.source_step_id,title:(o==null?void 0:o.title)??(l.title?`${l.title} (copy)`:void 0),content:(o==null?void 0:o.content)??l.content,category:(o==null?void 0:o.category)??l.category,priority:(o==null?void 0:o.priority)??l.priority,dependencies:(o==null?void 0:o.dependencies)??l.dependencies,metadata:l.metadata})}async function $h(t,s){return ce(`/projects/${t}/items/${s}`,{method:"DELETE"})}async function iv(t){return ce(`/projects/${t}/items/stats`)}async function cv(t){const s=t?`?path=${encodeURIComponent(t)}`:"";return ce(`/filesystem/browse${s}`)}async function _0(t,s){return ce(`/projects/${t}/loops/${s}/ready-check`)}async function dv(t,s){return ce(`/projects/${t}/loops/${s}/ready-check`,{method:"POST"})}async function uv(t,s,o,l){return ce(`/projects/${t}/loops/${s}/ready-check/answers`,{method:"POST",body:JSON.stringify({questions:o,answers:l})})}async function mv(t,s){return ce(`/projects/${t}/runs`)}async function hv(t,s){return ce(`/projects/${t}/runs/${s}`)}async function pv(){return ce("/templates")}async function xv(t){return ce(`/templates/${t}`)}async function fv(t){return ce(`/step-prompts/${t}`)}async function gv(){return ce("/projects/permission-templates")}async function yv(t,s){return ce(`/projects/${t}/loops/${s}/permissions`)}async function L0(t,s,o){return ce(`/projects/${t}/loops/${s}/permissions`,{method:"PUT",body:JSON.stringify(o)})}async function vv(t,s){return ce(`/projects/${t}/loops/${s}/permissions`,{method:"DELETE"})}async function wv(t,s){return ce(`/projects/${t}/loops/${s}/inputs`)}async function bv(t,s,o){var d,u;const l=new FormData;l.append("file",o);const i=await fetch(`${Us}/projects/${t}/loops/${s}/inputs/upload`,{method:"POST",body:l});if(!i.ok){const h=await i.json().catch(()=>({})),x=((d=h.error)==null?void 0:d.message)||h.detail||i.statusText;throw new Tn(x,i.status,(u=h.error)==null?void 0:u.code)}return i.json()}async function jv(t,s,o,l,i){return ce(`/projects/${t}/loops/${s}/inputs/paste`,{method:"POST",body:JSON.stringify({content:o,filename:l,tag:i})})}async function Nv(t,s,o){return ce(`/projects/${t}/loops/${s}/inputs/${encodeURIComponent(o)}`,{method:"DELETE"})}async function kv(t,s,o){return ce(`/projects/${t}/loops/${s}/preview`,{method:"POST",body:JSON.stringify(o||{})})}async function mc(t,s){const o=s?`?path=${encodeURIComponent(s)}`:"";return ce(`/projects/${t}/files/browse${o}`)}async function Cv(t){const s=t?`?loop_type=${encodeURIComponent(t)}`:"";return ce(`/projects/input-templates${s}`)}async function Sv(t){return ce(`/projects/input-templates/${encodeURIComponent(t)}`)}async function _v(t,s,o,l){return ce(`/projects/${t}/loops/${s}/inputs/apply-template`,{method:"POST",body:JSON.stringify({template_id:o,custom_filename:l})})}async function Lv(t,s,o){return ce(`/projects/${t}/loops/${s}/inputs/validate?loop_type=${encodeURIComponent(o)}`)}async function Ec(t){const s=t?`?project_path=${encodeURIComponent(t)}`:"";return ce(`/auth/status${s}`)}async function Bh(t){return ce("/auth/login",{method:"POST",body:JSON.stringify(t)})}async function Dh(t){return ce("/auth/logout",{method:"POST",body:JSON.stringify(t)})}async function Ev(t){return ce("/auth/refresh",{method:"POST",body:JSON.stringify(t)})}async function Tv(t="global",s){const o=new URLSearchParams({scope:t});return s&&o.set("project_path",s),ce(`/auth/credentials/export?${o}`)}async function Av(t){return ce("/auth/validate")}async function Oh(t){const s=new URLSearchParams;t&&s.set("project_path",t);const o=`/auth/usage${s.toString()?"?"+s:""}`;return ce(o)}async function Pv(t={}){const s=new URLSearchParams;return t.level&&s.set("level",t.level),t.category&&s.set("category",t.category),t.event&&s.set("event",t.event),t.project_id&&s.set("project_id",t.project_id),t.run_id&&s.set("run_id",t.run_id),t.since&&s.set("since",t.since),t.until&&s.set("until",t.until),t.limit&&s.set("limit",String(t.limit)),t.offset&&s.set("offset",String(t.offset)),ce(`/logs?${s}`)}async function Mv(){return ce("/logs/stats")}async function E0(t,s,o=!1){return ce(`/projects/${t}/loops/${s}/resources${o?"?include_content=true":""}`)}async function Rv(t,s,o){return ce(`/projects/${t}/loops/${s}/resources`,{method:"POST",body:JSON.stringify(o)})}async function T0(t,s,o,l){return ce(`/projects/${t}/loops/${s}/resources/${o}`,{method:"PATCH",body:JSON.stringify(l)})}async function Iv(t,s,o){return ce(`/projects/${t}/loops/${s}/resources/${o}`,{method:"DELETE"})}async function Za(t,s){const o=new URLSearchParams;s!=null&&s.status&&o.set("status_filter",s.status),s!=null&&s.include_archived&&o.set("include_archived","true"),s!=null&&s.archived_only&&o.set("archived_only","true");const l=o.toString();return ce(`/projects/${t}/workflows${l?`?${l}`:""}`)}async function Po(t,s){return ce(`/projects/${t}/workflows/${s}`)}async function $v(t,s){return ce(`/projects/${t}/workflows`,{method:"POST",body:JSON.stringify(s)})}async function Bv(t,s,o){return ce(`/projects/${t}/workflows/${s}`,{method:"PATCH",body:JSON.stringify(o)})}async function Dv(t,s){return ce(`/projects/${t}/workflows/${s}`,{method:"DELETE"})}async function Ov(t,s){return ce(`/projects/${t}/workflows/${s}/archive`,{method:"POST"})}async function Fv(t,s){return ce(`/projects/${t}/workflows/${s}/restore`,{method:"POST"})}async function Wv(t,s){return ce(`/projects/${t}/workflows/${s}/start`,{method:"POST"})}async function Fh(t,s){return ce(`/projects/${t}/workflows/${s}/stop`,{method:"POST"})}async function Wh(t,s,o){return ce(`/projects/${t}/workflows/${s}/run-specific-step/${o}`,{method:"POST"})}async function zv(t,s,o){return ce(`/projects/${t}/workflows/${s}/advance`,{method:"POST",body:JSON.stringify(o||{})})}async function Hv(t,s,o){return ce(`/projects/${t}/workflows/${s}/steps`,{method:"POST",body:JSON.stringify(o)})}async function Uv(t,s,o,l){return ce(`/projects/${t}/workflows/${s}/steps/${o}`,{method:"PATCH",body:JSON.stringify(l)})}async function Vv(t,s,o){return ce(`/projects/${t}/workflows/${s}/steps/${o}/archive`,{method:"POST"})}async function qv(t,s,o){return ce(`/projects/${t}/workflows/${s}/steps/${o}/restore`,{method:"POST"})}async function Yv(t,s){return ce(`/projects/${t}/workflows/${s}/steps/archived`)}async function zh(t,s,o){return ce(`/projects/${t}/workflows/${s}/steps/${o}`,{method:"DELETE"})}async function Gv(t,s,o){return ce(`/projects/${t}/workflows/${s}/steps/reorder`,{method:"POST",body:JSON.stringify({step_ids:o})})}async function Kv(t,s){return ce(`/projects/${t}/workflows/${s}/planning`)}async function Jv(t,s,o){return ce(`/projects/${t}/workflows/${s}/planning/message`,{method:"POST",body:JSON.stringify({content:o})})}async function Qv(t,s,o){return ce(`/projects/${t}/workflows/${s}/planning/complete`,{method:"POST",body:JSON.stringify(o||{})})}function Xv(t,s){return new EventSource(`${Us}/projects/${t}/workflows/${s}/planning/stream`)}async function fl(t,s,o){const i=new URLSearchParams().toString();return ce(`/projects/${t}/workflows/${s}/resources${i?`?${i}`:""}`)}async function Kc(t,s,o){return ce(`/projects/${t}/workflows/${s}/resources`,{method:"POST",body:JSON.stringify(o)})}async function So(t,s,o,l){return ce(`/projects/${t}/workflows/${s}/resources/${o}`,{method:"PATCH",body:JSON.stringify(l)})}async function Hh(t,s,o){return ce(`/projects/${t}/workflows/${s}/resources/${o}`,{method:"DELETE"})}async function Zv(t,s,o,l){const d=new URLSearchParams().toString();return ce(`/projects/${t}/workflows/${s}/resources/${o}/versions${d?`?${d}`:""}`)}async function e2(t,s,o,l){return ce(`/projects/${t}/workflows/${s}/resources/${o}/versions/${l}/restore`,{method:"POST"})}async function Uh(t,s,o){return ce(`/projects/${t}/workflows/${s}/resources/import/${o}`,{method:"POST"})}async function t2(t,s,o){return ce(`/projects/${t}/workflows/${s}/steps/${o}/resources`)}async function r2(t,s,o,l){return ce(`/projects/${t}/workflows/${s}/steps/${o}/resources`,{method:"POST",body:JSON.stringify(l)})}async function s2(t,s,o,l){return ce(`/projects/${t}/workflows/${s}/steps/${o}/resources/${l}`,{method:"DELETE"})}async function n2(t,s,o,l){return ce(`/projects/${t}/workflows/${s}/steps/${o}/resources/disable/${l}`,{method:"POST"})}async function o2(t,s,o,l){return ce(`/projects/${t}/workflows/${s}/steps/${o}/resources/disable/${l}`,{method:"DELETE"})}async function a2(t,s,o){return ce(`/projects/${t}/workflows/${s}/steps/${o}/preview-prompt`)}async function Jc(t,s){const l=new URLSearchParams().toString();return ce(`/projects/${t}/project-resources${l?`?${l}`:""}`)}async function l2(t,s){return ce(`/projects/${t}/project-resources`,{method:"POST",body:JSON.stringify(s)})}async function A0(t,s,o){return ce(`/projects/${t}/project-resources/${s}`,{method:"PATCH",body:JSON.stringify(o)})}async function i2(t,s){return ce(`/projects/${t}/project-resources/${s}`,{method:"DELETE"})}async function c2(t){return ce(`/projects/${t}/settings`)}async function d2(t,s){return ce(`/projects/${t}/settings`,{method:"PATCH",body:JSON.stringify(s)})}async function u2(t){return ce(`/projects/${t}/import-formats`)}async function m2(t,s,o,l,i,d){var g,v;const u=new FormData;u.append("file",i);const h=new URLSearchParams({format_id:l,workflow_id:s,source_step_id:o.toString()}),x=await fetch(`${Us}/projects/${t}/import-jsonl?${h}`,{method:"POST",body:u});if(!x.ok){const y=await x.json().catch(()=>({})),b=((g=y.error)==null?void 0:g.message)||y.detail||x.statusText;throw new Tn(b,x.status,(v=y.error)==null?void 0:v.code)}return x.json()}function Qc(t){return{pending:"Queued",completed:"Ready",claimed:"In Progress",in_progress:"In Progress",processed:"Done",failed:"Failed",skipped:"Skipped",duplicate:"Duplicate",external:"External",rejected:"Rejected"}[t]||t.charAt(0).toUpperCase()+t.slice(1)}function Xc(t){return{pending:"bg-blue-500/20 text-blue-400",completed:"bg-cyan-500/20 text-cyan-400",claimed:"bg-yellow-500/20 text-yellow-400",in_progress:"bg-yellow-500/20 text-yellow-400",processed:"bg-green-500/20 text-green-400",failed:"bg-red-500/20 text-red-400",skipped:"bg-gray-500/20 text-gray-400",duplicate:"bg-orange-500/20 text-orange-400",external:"bg-purple-500/20 text-purple-400",rejected:"bg-red-500/20 text-red-400"}[t]||"bg-gray-500/20 text-gray-400"}async function h2(t,s){return ce(`/projects/${t}/workflows/${s}/export/preview`)}async function p2(t,s,o={}){var i,d;const l=await fetch(`${Us}/projects/${t}/workflows/${s}/export`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!l.ok){const u=await l.json().catch(()=>({})),h=((i=u.error)==null?void 0:i.message)||u.detail||l.statusText;throw new Tn(h,l.status,(d=u.error)==null?void 0:d.code)}return l.blob()}async function P0(t,s){var i,d;const o=new FormData;o.append("file",s);const l=await fetch(`${Us}/projects/${t}/workflows/import/preview`,{method:"POST",body:o});if(!l.ok){const u=await l.json().catch(()=>({})),h=((i=u.error)==null?void 0:i.message)||u.detail||l.statusText;throw new Tn(h,l.status,(d=u.error)==null?void 0:d.code)}return l.json()}async function x2(t,s,o={}){var u,h,x,g;const l=new FormData;l.append("file",s);const i=new URLSearchParams;o.conflict_resolution&&i.set("conflict_resolution",o.conflict_resolution),o.import_items!==void 0&&i.set("import_items",o.import_items.toString()),o.import_resources!==void 0&&i.set("import_resources",o.import_resources.toString()),o.import_planning!==void 0&&i.set("import_planning",o.import_planning.toString()),o.import_runs!==void 0&&i.set("import_runs",o.import_runs.toString()),(u=o.selected_steps)!=null&&u.length&&i.set("selected_steps",o.selected_steps.join(",")),(h=o.selected_resource_ids)!=null&&h.length&&i.set("selected_resource_ids",o.selected_resource_ids.join(","));const d=await fetch(`${Us}/projects/${t}/workflows/import?${i}`,{method:"POST",body:l});if(!d.ok){const v=await d.json().catch(()=>({})),y=((x=v.error)==null?void 0:x.message)||v.detail||d.statusText;throw new Tn(y,d.status,(g=v.error)==null?void 0:g.code)}return d.json()}const Tr=Ky(t=>({projects:[],selectedProject:null,projectsLoading:!1,projectsError:null,loops:[],selectedLoop:null,loopsLoading:!1,items:[],itemsLoading:!1,itemsTotal:0,setProjects:s=>t({projects:s}),setSelectedProject:s=>t({selectedProject:s}),setProjectsLoading:s=>t({projectsLoading:s}),setProjectsError:s=>t({projectsError:s}),setLoops:s=>t({loops:s}),setSelectedLoop:s=>t({selectedLoop:s}),setLoopsLoading:s=>t({loopsLoading:s}),setItems:(s,o)=>t({items:s,itemsTotal:o}),setItemsLoading:s=>t({itemsLoading:s}),updateLoop:(s,o)=>t(l=>{var i;return{loops:l.loops.map(d=>d.name===s?{...d,...o}:d),selectedLoop:((i=l.selectedLoop)==null?void 0:i.name)===s?{...l.selectedLoop,...o}:l.selectedLoop}}),addItem:s=>t(o=>({items:[s,...o.items],itemsTotal:o.itemsTotal+1})),loadProjects:async()=>{t({projectsLoading:!0,projectsError:null});try{const s=await _c();t({projects:s,projectsLoading:!1})}catch(s){t({projectsError:s instanceof Error?s.message:"Failed to load projects",projectsLoading:!1})}}}));function f2(){const{slug:t,workflowId:s}=yr(),o=bs(),{projects:l,projectsLoading:i,projectsError:d,loadProjects:u}=Tr(),[h,x]=p.useState(null),[g,v]=p.useState({});p.useEffect(()=>{u()},[u]),p.useEffect(()=>{t&&x(t)},[t]),p.useEffect(()=>{!h||g[h]||Za(h).then(b=>{v(k=>({...k,[h]:b}))}).catch(()=>{v(b=>({...b,[h]:[]}))})},[h,g]);const y=o.pathname.endsWith("/settings");return e.jsxs("aside",{className:"w-64 bg-gray-800 border-r border-gray-700 flex flex-col",children:[e.jsx("div",{className:"p-4 border-b border-gray-700",children:e.jsxs(Se,{to:"/",className:"flex items-center space-x-2",children:[e.jsx("div",{className:"w-8 h-8 bg-primary-600 rounded-lg flex items-center justify-center",children:e.jsx("span",{className:"text-white font-bold",children:"R"})}),e.jsx("span",{className:"text-xl font-semibold text-white",children:"RalphX"})]})}),e.jsxs("nav",{className:"flex-1 overflow-y-auto p-4",children:[e.jsx("h3",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider mb-3",children:"Projects"}),i&&e.jsx("div",{className:"text-gray-400 text-sm",children:"Loading..."}),d&&e.jsx("div",{className:"text-red-400 text-sm",children:d}),!i&&!d&&l.length===0&&e.jsx("div",{className:"text-gray-500 text-sm",children:"No projects yet"}),e.jsx("ul",{className:"space-y-1",children:l.map(b=>{const k=h===b.slug,_=t===b.slug,j=(g[b.slug]||[]).filter(N=>N.status==="active"||N.status==="draft"||N.status==="paused");return e.jsxs("li",{children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("button",{onClick:()=>x(k?null:b.slug),className:"p-1 text-gray-500 hover:text-white","aria-label":k?"Collapse":"Expand",children:e.jsx("svg",{className:`w-4 h-4 transition-transform ${k?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),e.jsx(Se,{to:`/projects/${b.slug}`,className:`flex-1 block px-2 py-2 rounded-md text-sm transition-colors ${_&&!s&&!y?"bg-primary-600 text-white":"text-gray-300 hover:bg-gray-700 hover:text-white"}`,children:e.jsx("div",{className:"font-medium",children:b.name})})]}),k&&e.jsxs("div",{className:"ml-6 mt-1 space-y-1",children:[j.length>0?j.slice(0,5).map(N=>{const T=N.steps.find(P=>P.step_number===N.current_step);return e.jsxs(Se,{to:`/projects/${b.slug}/workflows/${N.id}`,className:`block px-2 py-1.5 rounded text-xs transition-colors ${s===N.id?"bg-gray-700 text-white":"text-gray-400 hover:bg-gray-700 hover:text-white"}`,children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${N.status==="active"?"bg-green-400 animate-pulse":"bg-gray-500"}`}),e.jsx("span",{className:"truncate",children:N.name})]}),T&&N.status==="active"&&e.jsxs("div",{className:"ml-4 mt-0.5 text-[10px] text-gray-500 truncate",children:["Step ",N.current_step,": ",T.name]})]},N.id)}):e.jsx("div",{className:"px-2 py-1 text-xs text-gray-500",children:"No active workflows"}),j.length>5&&e.jsxs(Se,{to:`/projects/${b.slug}`,className:"block px-2 py-1 text-xs text-gray-500 hover:text-gray-400",children:["+",j.length-5," more"]}),e.jsx(Se,{to:`/projects/${b.slug}/settings`,className:`block px-2 py-1.5 rounded text-xs transition-colors ${y&&t===b.slug?"bg-gray-700 text-white":"text-gray-500 hover:bg-gray-700 hover:text-gray-300"}`,children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),e.jsx("span",{children:"Settings"})]})})]})]},b.slug)})})]}),e.jsxs("div",{className:"p-4 border-t border-gray-700 space-y-2",children:[e.jsxs(Se,{to:"/logs",className:"flex items-center space-x-2 text-sm text-gray-400 hover:text-white transition-colors",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),e.jsx("span",{children:"Logs"})]}),e.jsxs(Se,{to:"/wiki",className:"flex items-center space-x-2 text-sm text-gray-400 hover:text-white transition-colors",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"})}),e.jsx("span",{children:"Wiki"})]}),e.jsxs(Se,{to:"/settings",className:"flex items-center space-x-2 text-sm text-gray-400 hover:text-white transition-colors",children:[e.jsxs("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),e.jsx("span",{children:"Settings"})]})]})]})}function g2(){return e.jsxs("div",{className:"flex h-screen bg-gray-900",children:[e.jsx(f2,{}),e.jsx("main",{className:"flex-1 overflow-auto",children:e.jsx(Ay,{})})]})}function y2({initialPath:t,onSelect:s,onCancel:o}){const[l,i]=p.useState(t||""),[d,u]=p.useState([]),[h,x]=p.useState(!1),[g,v]=p.useState(null),[y,b]=p.useState(!0),[k,_]=p.useState(null);p.useEffect(()=>{async function N(){b(!0),_(null);try{const T=await cv(l||void 0);i(T.path),u(T.directories),x(T.canGoUp),v(T.parent)}catch(T){_(T instanceof Error?T.message:"Failed to browse directory")}finally{b(!1)}}N()},[l]);const S=N=>{i(`${l}/${N}`)},j=()=>{g&&i(g)};return e.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-gray-800 rounded-lg w-full max-w-lg max-h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b border-gray-700",children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Directory"}),e.jsx("div",{className:"mt-2 text-sm text-gray-400 font-mono truncate",children:l})]}),e.jsx("div",{className:"flex-1 overflow-auto p-2",children:y?e.jsx("div",{className:"p-4 text-center text-gray-400",children:"Loading..."}):k?e.jsx("div",{className:"p-4 text-center text-red-400",children:k}):e.jsxs("div",{className:"space-y-1",children:[h&&e.jsxs("button",{onClick:j,className:"w-full flex items-center space-x-2 px-3 py-2 rounded hover:bg-gray-700 text-left",children:[e.jsx("svg",{className:"w-5 h-5 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 17l-5-5m0 0l5-5m-5 5h12"})}),e.jsx("span",{className:"text-gray-300",children:".."})]}),d.length===0&&!h?e.jsx("div",{className:"p-4 text-center text-gray-500",children:"No subdirectories"}):d.map(N=>e.jsxs("button",{onClick:()=>S(N),className:"w-full flex items-center space-x-2 px-3 py-2 rounded hover:bg-gray-700 text-left",children:[e.jsx("svg",{className:"w-5 h-5 text-primary-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),e.jsx("span",{className:"text-gray-200",children:N})]},N))]})}),e.jsxs("div",{className:"p-4 border-t border-gray-700 flex justify-end space-x-3",children:[e.jsx("button",{onClick:o,className:"px-4 py-2 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600",children:"Cancel"}),e.jsx("button",{onClick:()=>s(l),className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500",children:"Select This Folder"})]})]})})}function v2({onClose:t,onSuccess:s}){const[o,l]=p.useState(""),[i,d]=p.useState(""),[u,h]=p.useState(!1),[x,g]=p.useState(!1),[v,y]=p.useState(null),b=async _=>{if(_.preventDefault(),!o.trim()){y("Path is required");return}g(!0),y(null);try{await Jy({path:o.trim(),name:i.trim()||void 0}),s(),t()}catch(S){y(S instanceof Error?S.message:"Failed to create project")}finally{g(!1)}},k=_=>{if(l(_),h(!1),!i){const S=_.split("/");d(S[S.length-1]||"")}};return u?e.jsx(y2,{initialPath:o||void 0,onSelect:k,onCancel:()=>h(!1)}):e.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-gray-800 rounded-lg w-full max-w-md",children:[e.jsxs("div",{className:"p-4 border-b border-gray-700",children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:"Add Project"}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Add an existing folder as a RalphX project"})]}),e.jsxs("form",{onSubmit:b,className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Project Path"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx("input",{type:"text",value:o,onChange:_=>l(_.target.value),placeholder:"/home/user/my-project",className:"flex-1 px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white placeholder-gray-400 focus:outline-none focus:border-primary-500"}),e.jsx("button",{type:"button",onClick:()=>h(!0),className:"px-3 py-2 bg-gray-700 border border-gray-600 rounded text-gray-300 hover:bg-gray-600",children:"Browse"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Project Name (optional)"}),e.jsx("input",{type:"text",value:i,onChange:_=>d(_.target.value),placeholder:"Auto-generated from path",className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white placeholder-gray-400 focus:outline-none focus:border-primary-500"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Leave empty to use the folder name"})]}),v&&e.jsx("div",{className:"p-3 bg-red-900/30 border border-red-800 rounded text-sm text-red-400",children:v}),e.jsxs("div",{className:"flex justify-end space-x-3 pt-2",children:[e.jsx("button",{type:"button",onClick:t,disabled:x,className:"px-4 py-2 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600 disabled:opacity-50",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:x||!o.trim(),className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500 disabled:opacity-50",children:x?"Adding...":"Add Project"})]})]})]})})}function w2({content:t,children:s,position:o="top",delay:l=200,id:i}){const[d,u]=p.useState(!1),[h,x]=p.useState({x:0,y:0}),g=p.useRef(null),v=p.useRef(null),y=p.useRef(null),b=p.useId(),k=i||`tooltip-${b}`,_=()=>{y.current=setTimeout(()=>{u(!0)},l)},S=()=>{y.current&&clearTimeout(y.current),u(!1)};return p.useEffect(()=>{if(d&&g.current&&v.current){const j=g.current.getBoundingClientRect(),N=v.current.getBoundingClientRect();let T=0,P=0;switch(o){case"top":T=j.left+j.width/2-N.width/2,P=j.top-N.height-8;break;case"bottom":T=j.left+j.width/2-N.width/2,P=j.bottom+8;break;case"left":T=j.left-N.width-8,P=j.top+j.height/2-N.height/2;break;case"right":T=j.right+8,P=j.top+j.height/2-N.height/2;break}const C=8;T=Math.max(C,Math.min(T,window.innerWidth-N.width-C)),P=Math.max(C,Math.min(P,window.innerHeight-N.height-C)),x({x:T,y:P})}},[d,o]),p.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]),e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:g,onMouseEnter:_,onMouseLeave:S,onFocus:_,onBlur:S,className:"inline-flex","aria-describedby":d?k:void 0,children:s}),d&&e.jsx("div",{ref:v,id:k,role:"tooltip",className:"fixed z-50 px-3 py-2 text-sm bg-gray-900 text-gray-200 rounded-lg shadow-lg border border-gray-700 max-w-xs",style:{left:h.x,top:h.y},children:t})]})}const b2={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"};function zr({content:t,position:s="top",size:o="md",className:l=""}){return e.jsx(w2,{content:t,position:s,children:e.jsx("button",{type:"button",className:`inline-flex items-center justify-center rounded-full text-gray-400 hover:text-gray-300 hover:bg-gray-700/50 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 focus:ring-offset-gray-800 ${l}`,"aria-label":"Help",children:e.jsx("svg",{className:b2[o],fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})})})}const j2=[{title:"Create a Project",description:"Point RalphX at a directory to start managing workflows for that codebase.",icon:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"},{title:"Create a Workflow",description:"Set up workflows that define how Claude processes your work items.",icon:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"},{title:"Add Items",description:"Create items for your workflows to process - stories, tasks, or any work units you define.",icon:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"},{title:"Run Your Workflow",description:"Start the workflow and watch as Claude processes items according to your configuration.",icon:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"}];function N2({onDismiss:t,storageKey:s="ralphx-onboarding-dismissed"}){const[o,l]=p.useState(!1);p.useEffect(()=>{try{const d=localStorage.getItem(s)==="true";l(d)}catch{}},[s]);const i=()=>{try{localStorage.setItem(s,"true")}catch{}l(!0),t==null||t()};return o?null:e.jsxs("div",{className:"bg-gradient-to-r from-primary-900/30 to-purple-900/30 border border-primary-800/50 rounded-lg p-6 mb-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-white mb-1",children:"Welcome to RalphX"}),e.jsx("p",{className:"text-gray-400",children:"Get started with AI-powered development workflows in a few simple steps."})]}),e.jsx("button",{onClick:i,className:"text-gray-400 hover:text-white p-1","aria-label":"Dismiss getting started guide",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:j2.map((d,u)=>e.jsxs("div",{className:"bg-gray-800/50 rounded-lg p-4 border border-gray-700/50",children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary-600/20 text-primary-400 flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-bold",children:u+1})}),e.jsx("svg",{className:"w-5 h-5 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:d.icon})})]}),e.jsx("h3",{className:"text-sm font-medium text-white mb-1",children:d.title}),e.jsx("p",{className:"text-xs text-gray-400",children:d.description})]},d.title))}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-700/50 flex items-center justify-between",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Need help? Check out the documentation or ask in the community."}),e.jsx("button",{onClick:i,className:"text-xs text-primary-400 hover:text-primary-300",children:"Don't show this again"})]})]})}const Tc={folder:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z",document:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z",inbox:"M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"};function Ac({icon:t,title:s,description:o,action:l,children:i}){return e.jsxs("div",{className:"text-center py-12 px-6",children:[t&&e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-gray-700/50 flex items-center justify-center mb-4",children:typeof t=="string"?e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:t})}):t}),e.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:s}),o&&e.jsx("p",{className:"text-gray-400 max-w-sm mx-auto mb-6",children:o}),l&&e.jsxs("button",{onClick:l.onClick,className:"inline-flex items-center space-x-2 px-4 py-2 bg-primary-600 text-white rounded hover:bg-primary-500 transition-colors",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),e.jsx("span",{children:l.label})]}),i]})}function zs(t){return!t.endsWith("Z")&&!t.includes("+")&&!t.includes("-",10)?new Date(t+"Z"):new Date(t)}function Vh(t){return t?zs(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}function k2(t){if(!t)return"";const s=zs(t),o=new Date;return s.toDateString()===o.toDateString()?s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}):s.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Zc(t,s=!1){if(!t)return"";const o=zs(t);return s?o.toLocaleDateString([],{month:"short",day:"numeric",year:"numeric"}):o.toLocaleDateString([],{month:"short",day:"numeric"})}function hs(t){return t?zs(t).toLocaleString():""}function ed(t,s=""){if(!t)return s;const o=zs(t),i=new Date().getTime()-o.getTime(),d=Math.floor(i/1e3),u=Math.floor(d/60),h=Math.floor(u/60),x=Math.floor(h/24);return d<60?"just now":u<60?`${u}m ago`:h<48?`${h}h ago`:x<7?`${x}d ago`:Zc(t)}function C2(){const{projects:t,projectsLoading:s,projectsError:o,loadProjects:l}=Tr(),[i,d]=p.useState(null),[u,h]=p.useState(!1),[x,g]=p.useState(!1);return p.useEffect(()=>{Rh().then(d).catch(()=>{d(null),h(!0)})},[]),e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold text-white mb-2",children:"Dashboard"}),e.jsx("p",{className:"text-gray-400",children:"Manage your RalphX projects and workflows"})]}),u&&!i&&e.jsx("div",{className:"card mb-6 bg-red-900/20 border border-red-800",role:"alert",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-red-400",children:"API Unavailable"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Unable to connect to the backend API"})]}),e.jsx("div",{className:"flex items-center space-x-4",children:e.jsx("span",{className:"text-sm text-red-400",children:"offline"})})]})}),i&&e.jsx("div",{className:"card mb-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-white",children:"API Status"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Backend health check"})]}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("span",{className:`text-sm ${i.status==="healthy"?"text-green-400":"text-red-400"}`,children:i.status}),e.jsxs("span",{className:"text-sm text-gray-500",children:["v",i.version]})]})]})}),e.jsx(N2,{}),x&&e.jsx(v2,{onClose:()=>g(!1),onSuccess:()=>l()}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-xl font-semibold text-white",children:"Projects"}),e.jsxs("button",{onClick:()=>g(!0),className:"flex items-center space-x-2 px-4 py-2 bg-primary-600 text-white rounded hover:bg-primary-500 transition-colors",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),e.jsx("span",{children:"Add Project"})]})]}),s?e.jsx("div",{className:"text-gray-400","aria-live":"polite",children:"Loading projects..."}):o?e.jsxs("div",{className:"card bg-red-900/20 border border-red-800",role:"alert",children:[e.jsx("p",{className:"text-red-400 mb-2",children:o}),e.jsx("p",{className:"text-sm text-gray-400",children:"Unable to load projects. Check that the API is running."})]}):t.length===0?e.jsx("div",{className:"card",children:e.jsx(Ac,{icon:Tc.folder,title:"No projects yet",description:"Create your first project to start building AI-powered development workflows.",action:{label:"Add Project",onClick:()=>g(!0)},children:e.jsxs("p",{className:"text-xs text-gray-500 mt-4",children:["Or use the CLI: ",e.jsx("code",{className:"bg-gray-700 px-2 py-1 rounded",children:"ralphx add /path/to/project"})]})})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:t.map(v=>e.jsxs(Se,{to:`/projects/${v.slug}`,className:"card hover:bg-gray-700 transition-colors",children:[e.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:v.name}),e.jsx("p",{className:"text-sm text-gray-400 truncate mb-3",children:v.path}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Added: ",Zc(v.created_at)]})]},v.slug))})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"text-3xl font-bold text-primary-400",children:t.length}),e.jsx("div",{className:"text-sm text-gray-400",children:"Total Projects"})]}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"text-3xl font-bold text-green-400",children:"0"}),e.jsx("div",{className:"text-sm text-gray-400",children:"Active Workflows"})]}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"text-3xl font-bold text-yellow-400",children:"0"}),e.jsx("div",{className:"text-sm text-gray-400",children:"Pending Items"})]})]})]})}/*!
68
- * sweetalert2 v11.26.17
69
- * Released under the MIT License.
70
- */function qh(t,s,o){if(typeof t=="function"?t===s:t.has(s))return arguments.length<3?s:o;throw new TypeError("Private element is not present on this object")}function S2(t,s){if(s.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function M0(t,s){return t.get(qh(t,s))}function _2(t,s,o){S2(t,s),s.set(t,o)}function L2(t,s,o){return t.set(qh(t,s),o),o}const E2=100,we={},T2=()=>{we.previousActiveElement instanceof HTMLElement?(we.previousActiveElement.focus(),we.previousActiveElement=null):document.body&&document.body.focus()},A2=t=>new Promise(s=>{if(!t)return s();const o=window.scrollX,l=window.scrollY;we.restoreFocusTimeout=setTimeout(()=>{T2(),s()},E2),window.scrollTo(o,l)}),Yh="swal2-",P2=["container","shown","height-auto","iosfix","popup","modal","no-backdrop","no-transition","toast","toast-shown","show","hide","close","title","html-container","actions","confirm","deny","cancel","footer","icon","icon-content","image","input","file","range","select","radio","checkbox","label","textarea","inputerror","input-label","validation-message","progress-steps","active-progress-step","progress-step","progress-step-line","loader","loading","styled","top","top-start","top-end","top-left","top-right","center","center-start","center-end","center-left","center-right","bottom","bottom-start","bottom-end","bottom-left","bottom-right","grow-row","grow-column","grow-fullscreen","rtl","timer-progress-bar","timer-progress-bar-container","scrollbar-measure","icon-success","icon-warning","icon-info","icon-question","icon-error","draggable","dragging"],Z=P2.reduce((t,s)=>(t[s]=Yh+s,t),{}),M2=["success","warning","info","question","error"],el=M2.reduce((t,s)=>(t[s]=Yh+s,t),{}),Gh="SweetAlert2:",td=t=>t.charAt(0).toUpperCase()+t.slice(1),$t=t=>{console.warn(`${Gh} ${typeof t=="object"?t.join(" "):t}`)},qs=t=>{console.error(`${Gh} ${t}`)},R0=[],R2=t=>{R0.includes(t)||(R0.push(t),$t(t))},Kh=(t,s=null)=>{R2(`"${t}" is deprecated and will be removed in the next major release.${s?` Use "${s}" instead.`:""}`)},gl=t=>typeof t=="function"?t():t,rd=t=>t&&typeof t.toPromise=="function",Mo=t=>rd(t)?t.toPromise():Promise.resolve(t),sd=t=>t&&Promise.resolve(t)===t,Bt=()=>document.body.querySelector(`.${Z.container}`),Ro=t=>{const s=Bt();return s?s.querySelector(t):null},Zt=t=>Ro(`.${t}`),We=()=>Zt(Z.popup),An=()=>Zt(Z.icon),I2=()=>Zt(Z["icon-content"]),Jh=()=>Zt(Z.title),nd=()=>Zt(Z["html-container"]),Qh=()=>Zt(Z.image),od=()=>Zt(Z["progress-steps"]),yl=()=>Zt(Z["validation-message"]),Lr=()=>Ro(`.${Z.actions} .${Z.confirm}`),Pn=()=>Ro(`.${Z.actions} .${Z.cancel}`),Ys=()=>Ro(`.${Z.actions} .${Z.deny}`),$2=()=>Zt(Z["input-label"]),Mn=()=>Ro(`.${Z.loader}`),Io=()=>Zt(Z.actions),Xh=()=>Zt(Z.footer),vl=()=>Zt(Z["timer-progress-bar"]),ad=()=>Zt(Z.close),B2=`
71
- a[href],
72
- area[href],
73
- input:not([disabled]),
74
- select:not([disabled]),
75
- textarea:not([disabled]),
76
- button:not([disabled]),
77
- iframe,
78
- object,
79
- embed,
80
- [tabindex="0"],
81
- [contenteditable],
82
- audio[controls],
83
- video[controls],
84
- summary
85
- `,ld=()=>{const t=We();if(!t)return[];const s=t.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])'),o=Array.from(s).sort((d,u)=>{const h=parseInt(d.getAttribute("tabindex")||"0"),x=parseInt(u.getAttribute("tabindex")||"0");return h>x?1:h<x?-1:0}),l=t.querySelectorAll(B2),i=Array.from(l).filter(d=>d.getAttribute("tabindex")!=="-1");return[...new Set(o.concat(i))].filter(d=>qt(d))},id=()=>Ur(document.body,Z.shown)&&!Ur(document.body,Z["toast-shown"])&&!Ur(document.body,Z["no-backdrop"]),wl=()=>{const t=We();return t?Ur(t,Z.toast):!1},D2=()=>{const t=We();return t?t.hasAttribute("data-loading"):!1},er=(t,s)=>{if(t.textContent="",s){const l=new DOMParser().parseFromString(s,"text/html"),i=l.querySelector("head");i&&Array.from(i.childNodes).forEach(u=>{t.appendChild(u)});const d=l.querySelector("body");d&&Array.from(d.childNodes).forEach(u=>{u instanceof HTMLVideoElement||u instanceof HTMLAudioElement?t.appendChild(u.cloneNode(!0)):t.appendChild(u)})}},Ur=(t,s)=>{if(!s)return!1;const o=s.split(/\s+/);for(let l=0;l<o.length;l++)if(!t.classList.contains(o[l]))return!1;return!0},O2=(t,s)=>{Array.from(t.classList).forEach(o=>{!Object.values(Z).includes(o)&&!Object.values(el).includes(o)&&!Object.values(s.showClass||{}).includes(o)&&t.classList.remove(o)})},Xt=(t,s,o)=>{if(O2(t,s),!s.customClass)return;const l=s.customClass[o];if(l){if(typeof l!="string"&&!l.forEach){$t(`Invalid type of customClass.${o}! Expected string or iterable object, got "${typeof l}"`);return}Fe(t,l)}},bl=(t,s)=>{if(!s)return null;switch(s){case"select":case"textarea":case"file":return t.querySelector(`.${Z.popup} > .${Z[s]}`);case"checkbox":return t.querySelector(`.${Z.popup} > .${Z.checkbox} input`);case"radio":return t.querySelector(`.${Z.popup} > .${Z.radio} input:checked`)||t.querySelector(`.${Z.popup} > .${Z.radio} input:first-child`);case"range":return t.querySelector(`.${Z.popup} > .${Z.range} input`);default:return t.querySelector(`.${Z.popup} > .${Z.input}`)}},Zh=t=>{if(t.focus(),t.type!=="file"){const s=t.value;t.value="",t.value=s}},ep=(t,s,o)=>{!t||!s||(typeof s=="string"&&(s=s.split(/\s+/).filter(Boolean)),s.forEach(l=>{Array.isArray(t)?t.forEach(i=>{o?i.classList.add(l):i.classList.remove(l)}):o?t.classList.add(l):t.classList.remove(l)}))},Fe=(t,s)=>{ep(t,s,!0)},lr=(t,s)=>{ep(t,s,!1)},ps=(t,s)=>{const o=Array.from(t.children);for(let l=0;l<o.length;l++){const i=o[l];if(i instanceof HTMLElement&&Ur(i,s))return i}},Fs=(t,s,o)=>{o===`${parseInt(`${o}`)}`&&(o=parseInt(o)),o||parseInt(`${o}`)===0?t.style.setProperty(s,typeof o=="number"?`${o}px`:o):t.style.removeProperty(s)},vt=(t,s="flex")=>{t&&(t.style.display=s)},Tt=t=>{t&&(t.style.display="none")},cd=(t,s="block")=>{t&&new MutationObserver(()=>{$o(t,t.innerHTML,s)}).observe(t,{childList:!0,subtree:!0})},I0=(t,s,o,l)=>{const i=t.querySelector(s);i&&i.style.setProperty(o,l)},$o=(t,s,o="flex")=>{s?vt(t,o):Tt(t)},qt=t=>!!(t&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)),F2=()=>!qt(Lr())&&!qt(Ys())&&!qt(Pn()),Pc=t=>t.scrollHeight>t.clientHeight,W2=(t,s)=>{let o=t;for(;o&&o!==s;){if(Pc(o))return!0;o=o.parentElement}return!1},tp=t=>{const s=window.getComputedStyle(t),o=parseFloat(s.getPropertyValue("animation-duration")||"0"),l=parseFloat(s.getPropertyValue("transition-duration")||"0");return o>0||l>0},dd=(t,s=!1)=>{const o=vl();o&&qt(o)&&(s&&(o.style.transition="none",o.style.width="100%"),setTimeout(()=>{o.style.transition=`width ${t/1e3}s linear`,o.style.width="0%"},10))},z2=()=>{const t=vl();if(!t)return;const s=parseInt(window.getComputedStyle(t).width);t.style.removeProperty("transition"),t.style.width="100%";const o=parseInt(window.getComputedStyle(t).width),l=s/o*100;t.style.width=`${l}%`},H2=()=>typeof window>"u"||typeof document>"u",U2=`
86
- <div aria-labelledby="${Z.title}" aria-describedby="${Z["html-container"]}" class="${Z.popup}" tabindex="-1">
87
- <button type="button" class="${Z.close}"></button>
88
- <ul class="${Z["progress-steps"]}"></ul>
89
- <div class="${Z.icon}"></div>
90
- <img class="${Z.image}" />
91
- <h2 class="${Z.title}" id="${Z.title}"></h2>
92
- <div class="${Z["html-container"]}" id="${Z["html-container"]}"></div>
93
- <input class="${Z.input}" id="${Z.input}" />
94
- <input type="file" class="${Z.file}" />
95
- <div class="${Z.range}">
96
- <input type="range" />
97
- <output></output>
98
- </div>
99
- <select class="${Z.select}" id="${Z.select}"></select>
100
- <div class="${Z.radio}"></div>
101
- <label class="${Z.checkbox}">
102
- <input type="checkbox" id="${Z.checkbox}" />
103
- <span class="${Z.label}"></span>
104
- </label>
105
- <textarea class="${Z.textarea}" id="${Z.textarea}"></textarea>
106
- <div class="${Z["validation-message"]}" id="${Z["validation-message"]}"></div>
107
- <div class="${Z.actions}">
108
- <div class="${Z.loader}"></div>
109
- <button type="button" class="${Z.confirm}"></button>
110
- <button type="button" class="${Z.deny}"></button>
111
- <button type="button" class="${Z.cancel}"></button>
112
- </div>
113
- <div class="${Z.footer}"></div>
114
- <div class="${Z["timer-progress-bar-container"]}">
115
- <div class="${Z["timer-progress-bar"]}"></div>
116
- </div>
117
- </div>
118
- `.replace(/(^|\n)\s*/g,""),V2=()=>{const t=Bt();return t?(t.remove(),lr([document.documentElement,document.body],[Z["no-backdrop"],Z["toast-shown"],Z["has-column"]]),!0):!1},Ds=()=>{we.currentInstance&&we.currentInstance.resetValidationMessage()},q2=()=>{const t=We();if(!t)return;const s=ps(t,Z.input),o=ps(t,Z.file),l=t.querySelector(`.${Z.range} input`),i=t.querySelector(`.${Z.range} output`),d=ps(t,Z.select),u=t.querySelector(`.${Z.checkbox} input`),h=ps(t,Z.textarea);s&&(s.oninput=Ds),o&&(o.onchange=Ds),d&&(d.onchange=Ds),u&&(u.onchange=Ds),h&&(h.oninput=Ds),l&&i&&(l.oninput=()=>{Ds(),i.value=l.value},l.onchange=()=>{Ds(),i.value=l.value})},Y2=t=>{if(typeof t=="string"){const s=document.querySelector(t);if(!s)throw new Error(`Target element "${t}" not found`);return s}return t},G2=t=>{const s=We();s&&(s.setAttribute("role",t.toast?"alert":"dialog"),s.setAttribute("aria-live",t.toast?"polite":"assertive"),t.toast||s.setAttribute("aria-modal","true"))},K2=t=>{window.getComputedStyle(t).direction==="rtl"&&(Fe(Bt(),Z.rtl),we.isRTL=!0)},J2=t=>{const s=V2();if(H2()){qs("SweetAlert2 requires document to initialize");return}const o=document.createElement("div");o.className=Z.container,s&&Fe(o,Z["no-transition"]),er(o,U2),o.dataset.swal2Theme=t.theme;const l=Y2(t.target||"body");l.appendChild(o),t.topLayer&&(o.setAttribute("popover",""),o.showPopover()),G2(t),K2(l),q2()},ud=(t,s)=>{t instanceof HTMLElement?s.appendChild(t):typeof t=="object"?Q2(t,s):t&&er(s,t)},Q2=(t,s)=>{"jquery"in t?X2(s,t):er(s,t.toString())},X2=(t,s)=>{if(t.textContent="",0 in s)for(let o=0;o in s;o++)t.appendChild(s[o].cloneNode(!0));else t.appendChild(s.cloneNode(!0))},Z2=(t,s)=>{const o=Io(),l=Mn();!o||!l||(!s.showConfirmButton&&!s.showDenyButton&&!s.showCancelButton?Tt(o):vt(o),Xt(o,s,"actions"),ew(o,l,s),er(l,s.loaderHtml||""),Xt(l,s,"loader"))};function ew(t,s,o){const l=Lr(),i=Ys(),d=Pn();!l||!i||!d||(pc(l,"confirm",o),pc(i,"deny",o),pc(d,"cancel",o),tw(l,i,d,o),o.reverseButtons&&(o.toast?(t.insertBefore(d,l),t.insertBefore(i,l)):(t.insertBefore(d,s),t.insertBefore(i,s),t.insertBefore(l,s))))}function tw(t,s,o,l){if(!l.buttonsStyling){lr([t,s,o],Z.styled);return}Fe([t,s,o],Z.styled),l.confirmButtonColor&&t.style.setProperty("--swal2-confirm-button-background-color",l.confirmButtonColor),l.denyButtonColor&&s.style.setProperty("--swal2-deny-button-background-color",l.denyButtonColor),l.cancelButtonColor&&o.style.setProperty("--swal2-cancel-button-background-color",l.cancelButtonColor),hc(t),hc(s),hc(o)}function hc(t){const s=window.getComputedStyle(t);if(s.getPropertyValue("--swal2-action-button-focus-box-shadow"))return;const o=s.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/,"rgba($1, $2, $3, 0.5)");t.style.setProperty("--swal2-action-button-focus-box-shadow",s.getPropertyValue("--swal2-outline").replace(/ rgba\(.*/,` ${o}`))}function pc(t,s,o){const l=td(s);$o(t,o[`show${l}Button`],"inline-block"),er(t,o[`${s}ButtonText`]||""),t.setAttribute("aria-label",o[`${s}ButtonAriaLabel`]||""),t.className=Z[s],Xt(t,o,`${s}Button`)}const rw=(t,s)=>{const o=ad();o&&(er(o,s.closeButtonHtml||""),Xt(o,s,"closeButton"),$o(o,s.showCloseButton),o.setAttribute("aria-label",s.closeButtonAriaLabel||""))},sw=(t,s)=>{const o=Bt();o&&(nw(o,s.backdrop),ow(o,s.position),aw(o,s.grow),Xt(o,s,"container"))};function nw(t,s){typeof s=="string"?t.style.background=s:s||Fe([document.documentElement,document.body],Z["no-backdrop"])}function ow(t,s){s&&(s in Z?Fe(t,Z[s]):($t('The "position" parameter is not valid, defaulting to "center"'),Fe(t,Z.center)))}function aw(t,s){s&&Fe(t,Z[`grow-${s}`])}var Ue={innerParams:new WeakMap,domCache:new WeakMap};const lw=["input","file","range","select","radio","checkbox","textarea"],iw=(t,s)=>{const o=We();if(!o)return;const l=Ue.innerParams.get(t),i=!l||s.input!==l.input;lw.forEach(d=>{const u=ps(o,Z[d]);u&&(uw(d,s.inputAttributes),u.className=Z[d],i&&Tt(u))}),s.input&&(i&&cw(s),mw(s))},cw=t=>{if(!t.input)return;if(!et[t.input]){qs(`Unexpected type of input! Expected ${Object.keys(et).join(" | ")}, got "${t.input}"`);return}const s=rp(t.input);if(!s)return;const o=et[t.input](s,t);vt(s),t.inputAutoFocus&&setTimeout(()=>{Zh(o)})},dw=t=>{for(let s=0;s<t.attributes.length;s++){const o=t.attributes[s].name;["id","type","value","style"].includes(o)||t.removeAttribute(o)}},uw=(t,s)=>{const o=We();if(!o)return;const l=bl(o,t);if(l){dw(l);for(const i in s)l.setAttribute(i,s[i])}},mw=t=>{if(!t.input)return;const s=rp(t.input);s&&Xt(s,t,"input")},md=(t,s)=>{!t.placeholder&&s.inputPlaceholder&&(t.placeholder=s.inputPlaceholder)},Bo=(t,s,o)=>{if(o.inputLabel){const l=document.createElement("label"),i=Z["input-label"];l.setAttribute("for",t.id),l.className=i,typeof o.customClass=="object"&&Fe(l,o.customClass.inputLabel),l.innerText=o.inputLabel,s.insertAdjacentElement("beforebegin",l)}},rp=t=>{const s=We();if(s)return ps(s,Z[t]||Z.input)},tl=(t,s)=>{["string","number"].includes(typeof s)?t.value=`${s}`:sd(s)||$t(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof s}"`)},et={};et.text=et.email=et.password=et.number=et.tel=et.url=et.search=et.date=et["datetime-local"]=et.time=et.week=et.month=(t,s)=>{const o=t;return tl(o,s.inputValue),Bo(o,o,s),md(o,s),o.type=s.input,o};et.file=(t,s)=>{const o=t;return Bo(o,o,s),md(o,s),o};et.range=(t,s)=>{const o=t,l=o.querySelector("input"),i=o.querySelector("output");return l&&(tl(l,s.inputValue),l.type=s.input,Bo(l,t,s)),i&&tl(i,s.inputValue),t};et.select=(t,s)=>{const o=t;if(o.textContent="",s.inputPlaceholder){const l=document.createElement("option");er(l,s.inputPlaceholder),l.value="",l.disabled=!0,l.selected=!0,o.appendChild(l)}return Bo(o,o,s),o};et.radio=t=>{const s=t;return s.textContent="",t};et.checkbox=(t,s)=>{const o=We();if(!o)throw new Error("Popup not found");const l=bl(o,"checkbox");if(!l)throw new Error("Checkbox input not found");l.value="1",l.checked=!!s.inputValue;const d=t.querySelector("span");if(d){const u=s.inputPlaceholder||s.inputLabel;u&&er(d,u)}return l};et.textarea=(t,s)=>{const o=t;tl(o,s.inputValue),md(o,s),Bo(o,o,s);const l=i=>parseInt(window.getComputedStyle(i).marginLeft)+parseInt(window.getComputedStyle(i).marginRight);return setTimeout(()=>{if("MutationObserver"in window){const i=We();if(!i)return;const d=parseInt(window.getComputedStyle(i).width),u=()=>{if(!document.body.contains(o))return;const h=o.offsetWidth+l(o),x=We();x&&(h>d?x.style.width=`${h}px`:Fs(x,"width",s.width))};new MutationObserver(u).observe(o,{attributes:!0,attributeFilter:["style"]})}}),o};const hw=(t,s)=>{const o=nd();o&&(cd(o),Xt(o,s,"htmlContainer"),s.html?(ud(s.html,o),vt(o,"block")):s.text?(o.textContent=s.text,vt(o,"block")):Tt(o),iw(t,s))},pw=(t,s)=>{const o=Xh();o&&(cd(o),$o(o,!!s.footer,"block"),s.footer&&ud(s.footer,o),Xt(o,s,"footer"))},xw=(t,s)=>{const o=Ue.innerParams.get(t),l=An();if(!l)return;if(o&&s.icon===o.icon){B0(l,s),$0(l,s);return}if(!s.icon&&!s.iconHtml){Tt(l);return}if(s.icon&&Object.keys(el).indexOf(s.icon)===-1){qs(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${s.icon}"`),Tt(l);return}vt(l),B0(l,s),$0(l,s),Fe(l,s.showClass&&s.showClass.icon),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",sp)},$0=(t,s)=>{for(const[o,l]of Object.entries(el))s.icon!==o&&lr(t,l);Fe(t,s.icon&&el[s.icon]),yw(t,s),sp(),Xt(t,s,"icon")},sp=()=>{const t=We();if(!t)return;const s=window.getComputedStyle(t).getPropertyValue("background-color"),o=t.querySelectorAll("[class^=swal2-success-circular-line], .swal2-success-fix");for(let l=0;l<o.length;l++)o[l].style.backgroundColor=s},fw=t=>`
119
- ${t.animation?'<div class="swal2-success-circular-line-left"></div>':""}
120
- <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
121
- <div class="swal2-success-ring"></div>
122
- ${t.animation?'<div class="swal2-success-fix"></div>':""}
123
- ${t.animation?'<div class="swal2-success-circular-line-right"></div>':""}
124
- `,gw=`
125
- <span class="swal2-x-mark">
126
- <span class="swal2-x-mark-line-left"></span>
127
- <span class="swal2-x-mark-line-right"></span>
128
- </span>
129
- `,B0=(t,s)=>{if(!s.icon&&!s.iconHtml)return;let o=t.innerHTML,l="";s.iconHtml?l=D0(s.iconHtml):s.icon==="success"?(l=fw(s),o=o.replace(/ style=".*?"/g,"")):s.icon==="error"?l=gw:s.icon&&(l=D0({question:"?",warning:"!",info:"i"}[s.icon])),o.trim()!==l.trim()&&er(t,l)},yw=(t,s)=>{if(s.iconColor){t.style.color=s.iconColor,t.style.borderColor=s.iconColor;for(const o of[".swal2-success-line-tip",".swal2-success-line-long",".swal2-x-mark-line-left",".swal2-x-mark-line-right"])I0(t,o,"background-color",s.iconColor);I0(t,".swal2-success-ring","border-color",s.iconColor)}},D0=t=>`<div class="${Z["icon-content"]}">${t}</div>`,vw=(t,s)=>{const o=Qh();if(o){if(!s.imageUrl){Tt(o);return}vt(o,""),o.setAttribute("src",s.imageUrl),o.setAttribute("alt",s.imageAlt||""),Fs(o,"width",s.imageWidth),Fs(o,"height",s.imageHeight),o.className=Z.image,Xt(o,s,"image")}};let hd=!1,np=0,op=0,ap=0,lp=0;const ww=t=>{t.addEventListener("mousedown",rl),document.body.addEventListener("mousemove",sl),t.addEventListener("mouseup",nl),t.addEventListener("touchstart",rl),document.body.addEventListener("touchmove",sl),t.addEventListener("touchend",nl)},bw=t=>{t.removeEventListener("mousedown",rl),document.body.removeEventListener("mousemove",sl),t.removeEventListener("mouseup",nl),t.removeEventListener("touchstart",rl),document.body.removeEventListener("touchmove",sl),t.removeEventListener("touchend",nl)},rl=t=>{const s=We();if(!s)return;const o=An();if(t.target===s||o&&o.contains(t.target)){hd=!0;const l=ip(t);np=l.clientX,op=l.clientY,ap=parseInt(s.style.insetInlineStart)||0,lp=parseInt(s.style.insetBlockStart)||0,Fe(s,"swal2-dragging")}},sl=t=>{const s=We();if(s&&hd){let{clientX:o,clientY:l}=ip(t);const i=o-np;s.style.insetInlineStart=`${ap+(we.isRTL?-i:i)}px`,s.style.insetBlockStart=`${lp+(l-op)}px`}},nl=()=>{const t=We();hd=!1,lr(t,"swal2-dragging")},ip=t=>{let s=0,o=0;return t.type.startsWith("mouse")?(s=t.clientX,o=t.clientY):t.type.startsWith("touch")&&(s=t.touches[0].clientX,o=t.touches[0].clientY),{clientX:s,clientY:o}},jw=(t,s)=>{const o=Bt(),l=We();if(!(!o||!l)){if(s.toast){Fs(o,"width",s.width),l.style.width="100%";const i=Mn();i&&l.insertBefore(i,An())}else Fs(l,"width",s.width);Fs(l,"padding",s.padding),s.color&&(l.style.color=s.color),s.background&&(l.style.background=s.background),Tt(yl()),Nw(l,s),s.draggable&&!s.toast?(Fe(l,Z.draggable),ww(l)):(lr(l,Z.draggable),bw(l))}},Nw=(t,s)=>{const o=s.showClass||{};t.className=`${Z.popup} ${qt(t)?o.popup:""}`,s.toast?(Fe([document.documentElement,document.body],Z["toast-shown"]),Fe(t,Z.toast)):Fe(t,Z.modal),Xt(t,s,"popup"),typeof s.customClass=="string"&&Fe(t,s.customClass),s.icon&&Fe(t,Z[`icon-${s.icon}`])},kw=(t,s)=>{const o=od();if(!o)return;const{progressSteps:l,currentProgressStep:i}=s;if(!l||l.length===0||i===void 0){Tt(o);return}vt(o),o.textContent="",i>=l.length&&$t("Invalid currentProgressStep parameter, it should be less than progressSteps.length (currentProgressStep like JS arrays starts from 0)"),l.forEach((d,u)=>{const h=Cw(d);if(o.appendChild(h),u===i&&Fe(h,Z["active-progress-step"]),u!==l.length-1){const x=Sw(s);o.appendChild(x)}})},Cw=t=>{const s=document.createElement("li");return Fe(s,Z["progress-step"]),er(s,t),s},Sw=t=>{const s=document.createElement("li");return Fe(s,Z["progress-step-line"]),t.progressStepsDistance&&Fs(s,"width",t.progressStepsDistance),s},_w=(t,s)=>{const o=Jh();o&&(cd(o),$o(o,!!(s.title||s.titleText),"block"),s.title&&ud(s.title,o),s.titleText&&(o.innerText=s.titleText),Xt(o,s,"title"))},cp=(t,s)=>{var o;jw(t,s),sw(t,s),kw(t,s),xw(t,s),vw(t,s),_w(t,s),rw(t,s),hw(t,s),Z2(t,s),pw(t,s);const l=We();typeof s.didRender=="function"&&l&&s.didRender(l),(o=we.eventEmitter)===null||o===void 0||o.emit("didRender",l)},Lw=()=>qt(We()),dp=()=>{var t;return(t=Lr())===null||t===void 0?void 0:t.click()},Ew=()=>{var t;return(t=Ys())===null||t===void 0?void 0:t.click()},Tw=()=>{var t;return(t=Pn())===null||t===void 0?void 0:t.click()},Rn=Object.freeze({cancel:"cancel",backdrop:"backdrop",close:"close",esc:"esc",timer:"timer"}),up=t=>{if(t.keydownTarget&&t.keydownHandlerAdded&&t.keydownHandler){const s=t.keydownHandler;t.keydownTarget.removeEventListener("keydown",s,{capture:t.keydownListenerCapture}),t.keydownHandlerAdded=!1}},Aw=(t,s,o)=>{if(up(t),!s.toast){const l=d=>Mw(s,d,o);t.keydownHandler=l;const i=s.keydownListenerCapture?window:We();if(i){t.keydownTarget=i,t.keydownListenerCapture=s.keydownListenerCapture;const d=l;t.keydownTarget.addEventListener("keydown",d,{capture:t.keydownListenerCapture}),t.keydownHandlerAdded=!0}}},Mc=(t,s)=>{var o;const l=ld();if(l.length){t=t+s,t===-2&&(t=l.length-1),t===l.length?t=0:t===-1&&(t=l.length-1),l[t].focus();return}(o=We())===null||o===void 0||o.focus()},mp=["ArrowRight","ArrowDown"],Pw=["ArrowLeft","ArrowUp"],Mw=(t,s,o)=>{t&&(s.isComposing||s.keyCode===229||(t.stopKeydownPropagation&&s.stopPropagation(),s.key==="Enter"?Rw(s,t):s.key==="Tab"?Iw(s):[...mp,...Pw].includes(s.key)?$w(s.key):s.key==="Escape"&&Bw(s,t,o)))},Rw=(t,s)=>{if(!gl(s.allowEnterKey))return;const o=We();if(!o||!s.input)return;const l=bl(o,s.input);if(t.target&&l&&t.target instanceof HTMLElement&&t.target.outerHTML===l.outerHTML){if(["textarea","file"].includes(s.input))return;dp(),t.preventDefault()}},Iw=t=>{const s=t.target,o=ld();let l=-1;for(let i=0;i<o.length;i++)if(s===o[i]){l=i;break}t.shiftKey?Mc(l,-1):Mc(l,1),t.stopPropagation(),t.preventDefault()},$w=t=>{const s=Io(),o=Lr(),l=Ys(),i=Pn();if(!s||!o||!l||!i)return;const d=[o,l,i];if(document.activeElement instanceof HTMLElement&&!d.includes(document.activeElement))return;const u=mp.includes(t)?"nextElementSibling":"previousElementSibling";let h=document.activeElement;if(h){for(let x=0;x<s.children.length;x++){if(h=h[u],!h)return;if(h instanceof HTMLButtonElement&&qt(h))break}h instanceof HTMLButtonElement&&h.focus()}},Bw=(t,s,o)=>{t.preventDefault(),gl(s.allowEscapeKey)&&o(Rn.esc)};var Cn={swalPromiseResolve:new WeakMap,swalPromiseReject:new WeakMap};const Dw=()=>{const t=Bt();Array.from(document.body.children).forEach(o=>{o.contains(t)||(o.hasAttribute("aria-hidden")&&o.setAttribute("data-previous-aria-hidden",o.getAttribute("aria-hidden")||""),o.setAttribute("aria-hidden","true"))})},hp=()=>{Array.from(document.body.children).forEach(s=>{s.hasAttribute("data-previous-aria-hidden")?(s.setAttribute("aria-hidden",s.getAttribute("data-previous-aria-hidden")||""),s.removeAttribute("data-previous-aria-hidden")):s.removeAttribute("aria-hidden")})},pp=typeof window<"u"&&!!window.GestureEvent,Ow=()=>{if(pp&&!Ur(document.body,Z.iosfix)){const t=document.body.scrollTop;document.body.style.top=`${t*-1}px`,Fe(document.body,Z.iosfix),Fw()}},Fw=()=>{const t=Bt();if(!t)return;let s;t.ontouchstart=o=>{s=Ww(o)},t.ontouchmove=o=>{s&&(o.preventDefault(),o.stopPropagation())}},Ww=t=>{const s=t.target,o=Bt(),l=nd();return!o||!l||zw(t)||Hw(t)?!1:s===o||!Pc(o)&&s instanceof HTMLElement&&!W2(s,l)&&s.tagName!=="INPUT"&&s.tagName!=="TEXTAREA"&&!(Pc(l)&&l.contains(s))},zw=t=>!!(t.touches&&t.touches.length&&t.touches[0].touchType==="stylus"),Hw=t=>t.touches&&t.touches.length>1,Uw=()=>{if(Ur(document.body,Z.iosfix)){const t=parseInt(document.body.style.top,10);lr(document.body,Z.iosfix),document.body.style.top="",document.body.scrollTop=t*-1}},Vw=()=>{const t=document.createElement("div");t.className=Z["scrollbar-measure"],document.body.appendChild(t);const s=t.getBoundingClientRect().width-t.clientWidth;return document.body.removeChild(t),s};let kn=null;const qw=t=>{kn===null&&(document.body.scrollHeight>window.innerHeight||t==="scroll")&&(kn=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right")),document.body.style.paddingRight=`${kn+Vw()}px`)},Yw=()=>{kn!==null&&(document.body.style.paddingRight=`${kn}px`,kn=null)};function xp(t,s,o,l){wl()?O0(t,l):(A2(o).then(()=>O0(t,l)),up(we)),pp?(s.setAttribute("style","display:none !important"),s.removeAttribute("class"),s.innerHTML=""):s.remove(),id()&&(Yw(),Uw(),hp()),Gw()}function Gw(){lr([document.documentElement,document.body],[Z.shown,Z["height-auto"],Z["no-backdrop"],Z["toast-shown"]])}function xs(t){t=Jw(t);const s=Cn.swalPromiseResolve.get(this),o=Kw(this);this.isAwaitingPromise?t.isDismissed||(Do(this),s(t)):o&&s(t)}const Kw=t=>{const s=We();if(!s)return!1;const o=Ue.innerParams.get(t);if(!o||Ur(s,o.hideClass.popup))return!1;lr(s,o.showClass.popup),Fe(s,o.hideClass.popup);const l=Bt();return lr(l,o.showClass.backdrop),Fe(l,o.hideClass.backdrop),Qw(t,s,o),!0};function fp(t){const s=Cn.swalPromiseReject.get(this);Do(this),s&&s(t)}const Do=t=>{t.isAwaitingPromise&&(delete t.isAwaitingPromise,Ue.innerParams.get(t)||t._destroy())},Jw=t=>typeof t>"u"?{isConfirmed:!1,isDenied:!1,isDismissed:!0}:Object.assign({isConfirmed:!1,isDenied:!1,isDismissed:!1},t),Qw=(t,s,o)=>{var l;const i=Bt(),d=tp(s);typeof o.willClose=="function"&&o.willClose(s),(l=we.eventEmitter)===null||l===void 0||l.emit("willClose",s),d&&i?Xw(t,s,i,!!o.returnFocus,o.didClose):i&&xp(t,i,!!o.returnFocus,o.didClose)},Xw=(t,s,o,l,i)=>{we.swalCloseEventFinishedCallback=xp.bind(null,t,o,l,i);const d=function(u){if(u.target===s){var h;(h=we.swalCloseEventFinishedCallback)===null||h===void 0||h.call(we),delete we.swalCloseEventFinishedCallback,s.removeEventListener("animationend",d),s.removeEventListener("transitionend",d)}};s.addEventListener("animationend",d),s.addEventListener("transitionend",d)},O0=(t,s)=>{setTimeout(()=>{var o;typeof s=="function"&&s.bind(t.params)(),(o=we.eventEmitter)===null||o===void 0||o.emit("didClose"),t._destroy&&t._destroy()})},Sn=t=>{let s=We();if(s||new rt,s=We(),!s)return;const o=Mn();wl()?Tt(An()):Zw(s,t),vt(o),s.setAttribute("data-loading","true"),s.setAttribute("aria-busy","true"),s.focus()},Zw=(t,s)=>{const o=Io(),l=Mn();!o||!l||(!s&&qt(Lr())&&(s=Lr()),vt(o),s&&(Tt(s),l.setAttribute("data-button-to-replace",s.className),o.insertBefore(l,s)),Fe([t,o],Z.loading))},eb=(t,s)=>{s.input==="select"||s.input==="radio"?ob(t,s):["text","email","number","tel","textarea"].some(o=>o===s.input)&&(rd(s.inputValue)||sd(s.inputValue))&&(Sn(Lr()),ab(t,s))},tb=(t,s)=>{const o=t.getInput();if(!o)return null;switch(s.input){case"checkbox":return rb(o);case"radio":return sb(o);case"file":return nb(o);default:return s.inputAutoTrim?o.value.trim():o.value}},rb=t=>t.checked?1:0,sb=t=>t.checked?t.value:null,nb=t=>t.files&&t.files.length?t.getAttribute("multiple")!==null?t.files:t.files[0]:null,ob=(t,s)=>{const o=We();if(!o)return;const l=i=>{s.input==="select"?lb(o,ol(i),s):s.input==="radio"&&ib(o,ol(i),s)};rd(s.inputOptions)||sd(s.inputOptions)?(Sn(Lr()),Mo(s.inputOptions).then(i=>{t.hideLoading(),l(i)})):typeof s.inputOptions=="object"?l(s.inputOptions):qs(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof s.inputOptions}`)},ab=(t,s)=>{const o=t.getInput();o&&(Tt(o),Mo(s.inputValue).then(l=>{o.value=s.input==="number"?`${parseFloat(l)||0}`:`${l}`,vt(o),o.focus(),t.hideLoading()}).catch(l=>{qs(`Error in inputValue promise: ${l}`),o.value="",vt(o),o.focus(),t.hideLoading()}))};function lb(t,s,o){const l=ps(t,Z.select);if(!l)return;const i=(d,u,h)=>{const x=document.createElement("option");x.value=h,er(x,u),x.selected=gp(h,o.inputValue),d.appendChild(x)};s.forEach(d=>{const u=d[0],h=d[1];if(Array.isArray(h)){const x=document.createElement("optgroup");x.label=u,x.disabled=!1,l.appendChild(x),h.forEach(g=>i(x,g[1],g[0]))}else i(l,h,u)}),l.focus()}function ib(t,s,o){const l=ps(t,Z.radio);if(!l)return;s.forEach(d=>{const u=d[0],h=d[1],x=document.createElement("input"),g=document.createElement("label");x.type="radio",x.name=Z.radio,x.value=u,gp(u,o.inputValue)&&(x.checked=!0);const v=document.createElement("span");er(v,h),v.className=Z.label,g.appendChild(x),g.appendChild(v),l.appendChild(g)});const i=l.querySelectorAll("input");i.length&&i[0].focus()}const ol=t=>{const s=[];return t instanceof Map?t.forEach((o,l)=>{let i=o;typeof i=="object"&&(i=ol(i)),s.push([l,i])}):Object.keys(t).forEach(o=>{let l=t[o];typeof l=="object"&&(l=ol(l)),s.push([o,l])}),s},gp=(t,s)=>!!s&&s!==null&&s!==void 0&&s.toString()===t.toString(),cb=t=>{const s=Ue.innerParams.get(t);t.disableButtons(),s.input?yp(t,"confirm"):xd(t,!0)},db=t=>{const s=Ue.innerParams.get(t);t.disableButtons(),s.returnInputValueOnDeny?yp(t,"deny"):pd(t,!1)},ub=(t,s)=>{t.disableButtons(),s(Rn.cancel)},yp=(t,s)=>{const o=Ue.innerParams.get(t);if(!o.input){qs(`The "input" parameter is needed to be set when using returnInputValueOn${td(s)}`);return}const l=t.getInput(),i=tb(t,o);o.inputValidator?mb(t,i,s):l&&!l.checkValidity()?(t.enableButtons(),t.showValidationMessage(o.validationMessage||l.validationMessage)):s==="deny"?pd(t,i):xd(t,i)},mb=(t,s,o)=>{const l=Ue.innerParams.get(t);t.disableInput(),Promise.resolve().then(()=>Mo(l.inputValidator(s,l.validationMessage))).then(d=>{t.enableButtons(),t.enableInput(),d?t.showValidationMessage(d):o==="deny"?pd(t,s):xd(t,s)})},pd=(t,s)=>{const o=Ue.innerParams.get(t);o.showLoaderOnDeny&&Sn(Ys()),o.preDeny?(t.isAwaitingPromise=!0,Promise.resolve().then(()=>Mo(o.preDeny(s,o.validationMessage))).then(i=>{i===!1?(t.hideLoading(),Do(t)):t.close({isDenied:!0,value:typeof i>"u"?s:i})}).catch(i=>vp(t,i))):t.close({isDenied:!0,value:s})},F0=(t,s)=>{t.close({isConfirmed:!0,value:s})},vp=(t,s)=>{t.rejectPromise(s)},xd=(t,s)=>{const o=Ue.innerParams.get(t);o.showLoaderOnConfirm&&Sn(),o.preConfirm?(t.resetValidationMessage(),t.isAwaitingPromise=!0,Promise.resolve().then(()=>Mo(o.preConfirm(s,o.validationMessage))).then(i=>{qt(yl())||i===!1?(t.hideLoading(),Do(t)):F0(t,typeof i>"u"?s:i)}).catch(i=>vp(t,i))):F0(t,s)};function al(){const t=Ue.innerParams.get(this);if(!t)return;const s=Ue.domCache.get(this);Tt(s.loader),wl()?t.icon&&vt(An()):hb(s),lr([s.popup,s.actions],Z.loading),s.popup.removeAttribute("aria-busy"),s.popup.removeAttribute("data-loading"),s.confirmButton.disabled=!1,s.denyButton.disabled=!1,s.cancelButton.disabled=!1}const hb=t=>{const s=t.loader.getAttribute("data-button-to-replace"),o=s?t.popup.getElementsByClassName(s):[];o.length?vt(o[0],"inline-block"):F2()&&Tt(t.actions)};function wp(){const t=Ue.innerParams.get(this),s=Ue.domCache.get(this);return s?bl(s.popup,t.input):null}function bp(t,s,o){const l=Ue.domCache.get(t);s.forEach(i=>{l[i].disabled=o})}function jp(t,s){const o=We();if(!(!o||!t))if(t.type==="radio"){const l=o.querySelectorAll(`[name="${Z.radio}"]`);for(let i=0;i<l.length;i++)l[i].disabled=s}else t.disabled=s}function Np(){bp(this,["confirmButton","denyButton","cancelButton"],!1)}function kp(){bp(this,["confirmButton","denyButton","cancelButton"],!0)}function Cp(){jp(this.getInput(),!1)}function Sp(){jp(this.getInput(),!0)}function _p(t){const s=Ue.domCache.get(this),o=Ue.innerParams.get(this);er(s.validationMessage,t),s.validationMessage.className=Z["validation-message"],o.customClass&&o.customClass.validationMessage&&Fe(s.validationMessage,o.customClass.validationMessage),vt(s.validationMessage);const l=this.getInput();l&&(l.setAttribute("aria-invalid","true"),l.setAttribute("aria-describedby",Z["validation-message"]),Zh(l),Fe(l,Z.inputerror))}function Lp(){const t=Ue.domCache.get(this);t.validationMessage&&Tt(t.validationMessage);const s=this.getInput();s&&(s.removeAttribute("aria-invalid"),s.removeAttribute("aria-describedby"),lr(s,Z.inputerror))}const fs={title:"",titleText:"",text:"",html:"",footer:"",icon:void 0,iconColor:void 0,iconHtml:void 0,template:void 0,toast:!1,draggable:!1,animation:!0,theme:"light",showClass:{popup:"swal2-show",backdrop:"swal2-backdrop-show",icon:"swal2-icon-show"},hideClass:{popup:"swal2-hide",backdrop:"swal2-backdrop-hide",icon:"swal2-icon-hide"},customClass:{},target:"body",color:void 0,backdrop:!0,heightAuto:!0,allowOutsideClick:!0,allowEscapeKey:!0,allowEnterKey:!0,stopKeydownPropagation:!0,keydownListenerCapture:!1,showConfirmButton:!0,showDenyButton:!1,showCancelButton:!1,preConfirm:void 0,preDeny:void 0,confirmButtonText:"OK",confirmButtonAriaLabel:"",confirmButtonColor:void 0,denyButtonText:"No",denyButtonAriaLabel:"",denyButtonColor:void 0,cancelButtonText:"Cancel",cancelButtonAriaLabel:"",cancelButtonColor:void 0,buttonsStyling:!0,reverseButtons:!1,focusConfirm:!0,focusDeny:!1,focusCancel:!1,returnFocus:!0,showCloseButton:!1,closeButtonHtml:"&times;",closeButtonAriaLabel:"Close this dialog",loaderHtml:"",showLoaderOnConfirm:!1,showLoaderOnDeny:!1,imageUrl:void 0,imageWidth:void 0,imageHeight:void 0,imageAlt:"",timer:void 0,timerProgressBar:!1,width:void 0,padding:void 0,background:void 0,input:void 0,inputPlaceholder:"",inputLabel:"",inputValue:"",inputOptions:{},inputAutoFocus:!0,inputAutoTrim:!0,inputAttributes:{},inputValidator:void 0,returnInputValueOnDeny:!1,validationMessage:void 0,grow:!1,position:"center",progressSteps:[],currentProgressStep:void 0,progressStepsDistance:void 0,willOpen:void 0,didOpen:void 0,didRender:void 0,willClose:void 0,didClose:void 0,didDestroy:void 0,scrollbarPadding:!0,topLayer:!1},pb=["allowEscapeKey","allowOutsideClick","background","buttonsStyling","cancelButtonAriaLabel","cancelButtonColor","cancelButtonText","closeButtonAriaLabel","closeButtonHtml","color","confirmButtonAriaLabel","confirmButtonColor","confirmButtonText","currentProgressStep","customClass","denyButtonAriaLabel","denyButtonColor","denyButtonText","didClose","didDestroy","draggable","footer","hideClass","html","icon","iconColor","iconHtml","imageAlt","imageHeight","imageUrl","imageWidth","preConfirm","preDeny","progressSteps","returnFocus","reverseButtons","showCancelButton","showCloseButton","showConfirmButton","showDenyButton","text","title","titleText","theme","willClose"],xb={allowEnterKey:void 0},fb=["allowOutsideClick","allowEnterKey","backdrop","draggable","focusConfirm","focusDeny","focusCancel","returnFocus","heightAuto","keydownListenerCapture"],Ep=t=>Object.prototype.hasOwnProperty.call(fs,t),Tp=t=>pb.indexOf(t)!==-1,Ap=t=>xb[t],gb=t=>{Ep(t)||$t(`Unknown parameter "${t}"`)},yb=t=>{fb.includes(t)&&$t(`The parameter "${t}" is incompatible with toasts`)},vb=t=>{const s=Ap(t);s&&Kh(t,s)},Pp=t=>{t.backdrop===!1&&t.allowOutsideClick&&$t('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`'),t.theme&&!["light","dark","auto","minimal","borderless","bootstrap-4","bootstrap-4-light","bootstrap-4-dark","bootstrap-5","bootstrap-5-light","bootstrap-5-dark","material-ui","material-ui-light","material-ui-dark","embed-iframe","bulma","bulma-light","bulma-dark"].includes(t.theme)&&$t(`Invalid theme "${t.theme}"`);for(const s in t)gb(s),t.toast&&yb(s),vb(s)};function Mp(t){const s=Bt(),o=We(),l=Ue.innerParams.get(this);if(!o||Ur(o,l.hideClass.popup)){$t("You're trying to update the closed or closing popup, that won't work. Use the update() method in preConfirm parameter or show a new popup.");return}const i=wb(t),d=Object.assign({},l,i);Pp(d),s&&(s.dataset.swal2Theme=d.theme),cp(this,d),Ue.innerParams.set(this,d),Object.defineProperties(this,{params:{value:Object.assign({},this.params,t),writable:!1,enumerable:!0}})}const wb=t=>{const s={};return Object.keys(t).forEach(o=>{if(Tp(o)){const l=t;s[o]=l[o]}else $t(`Invalid parameter to update: ${o}`)}),s};function Rp(){var t;const s=Ue.domCache.get(this),o=Ue.innerParams.get(this);if(!o){Ip(this);return}s.popup&&we.swalCloseEventFinishedCallback&&(we.swalCloseEventFinishedCallback(),delete we.swalCloseEventFinishedCallback),typeof o.didDestroy=="function"&&o.didDestroy(),(t=we.eventEmitter)===null||t===void 0||t.emit("didDestroy"),bb(this)}const bb=t=>{Ip(t),delete t.params,delete we.keydownHandler,delete we.keydownTarget,delete we.currentInstance},Ip=t=>{t.isAwaitingPromise?(xc(Ue,t),t.isAwaitingPromise=!0):(xc(Cn,t),xc(Ue,t),delete t.isAwaitingPromise,delete t.disableButtons,delete t.enableButtons,delete t.getInput,delete t.disableInput,delete t.enableInput,delete t.hideLoading,delete t.disableLoading,delete t.showValidationMessage,delete t.resetValidationMessage,delete t.close,delete t.closePopup,delete t.closeModal,delete t.closeToast,delete t.rejectPromise,delete t.update,delete t._destroy)},xc=(t,s)=>{for(const o in t)t[o].delete(s)};var jb=Object.freeze({__proto__:null,_destroy:Rp,close:xs,closeModal:xs,closePopup:xs,closeToast:xs,disableButtons:kp,disableInput:Sp,disableLoading:al,enableButtons:Np,enableInput:Cp,getInput:wp,handleAwaitingPromise:Do,hideLoading:al,rejectPromise:fp,resetValidationMessage:Lp,showValidationMessage:_p,update:Mp});const Nb=(t,s,o)=>{t.toast?kb(t,s,o):(Sb(s),_b(s),Lb(t,s,o))},kb=(t,s,o)=>{s.popup.onclick=()=>{t&&(Cb(t)||t.timer||t.input)||o(Rn.close)}},Cb=t=>!!(t.showConfirmButton||t.showDenyButton||t.showCancelButton||t.showCloseButton);let ll=!1;const Sb=t=>{t.popup.onmousedown=()=>{t.container.onmouseup=function(s){t.container.onmouseup=()=>{},s.target===t.container&&(ll=!0)}}},_b=t=>{t.container.onmousedown=s=>{s.target===t.container&&s.preventDefault(),t.popup.onmouseup=function(o){t.popup.onmouseup=()=>{},(o.target===t.popup||o.target instanceof HTMLElement&&t.popup.contains(o.target))&&(ll=!0)}}},Lb=(t,s,o)=>{s.container.onclick=l=>{if(ll){ll=!1;return}l.target===s.container&&gl(t.allowOutsideClick)&&o(Rn.backdrop)}},Eb=t=>typeof t=="object"&&t.jquery,W0=t=>t instanceof Element||Eb(t),Tb=t=>{const s={};return typeof t[0]=="object"&&!W0(t[0])?Object.assign(s,t[0]):["title","html","icon"].forEach((o,l)=>{const i=t[l];typeof i=="string"||W0(i)?s[o]=i:i!==void 0&&qs(`Unexpected type of ${o}! Expected "string" or "Element", got ${typeof i}`)}),s};function Ab(...t){return new this(...t)}function Pb(t){class s extends this{_main(l,i){return super._main(l,Object.assign({},t,i))}}return s}const Mb=()=>we.timeout&&we.timeout.getTimerLeft(),$p=()=>{if(we.timeout)return z2(),we.timeout.stop()},Bp=()=>{if(we.timeout){const t=we.timeout.start();return dd(t),t}},Rb=()=>{const t=we.timeout;return t&&(t.running?$p():Bp())},Ib=t=>{if(we.timeout){const s=we.timeout.increase(t);return dd(s,!0),s}},$b=()=>!!(we.timeout&&we.timeout.isRunning());let z0=!1;const Rc={};function Bb(t="data-swal-template"){Rc[t]=this,z0||(document.body.addEventListener("click",Db),z0=!0)}const Db=t=>{for(let s=t.target;s&&s!==document;s=s.parentNode)for(const o in Rc){const l=s.getAttribute&&s.getAttribute(o);if(l){Rc[o].fire({template:l});return}}};class Ob{constructor(){this.events={}}_getHandlersByEventName(s){return typeof this.events[s]>"u"&&(this.events[s]=[]),this.events[s]}on(s,o){const l=this._getHandlersByEventName(s);l.includes(o)||l.push(o)}once(s,o){const l=(...i)=>{this.removeListener(s,l),o.apply(this,i)};this.on(s,l)}emit(s,...o){this._getHandlersByEventName(s).forEach(l=>{try{l.apply(this,o)}catch(i){console.error(i)}})}removeListener(s,o){const l=this._getHandlersByEventName(s),i=l.indexOf(o);i>-1&&l.splice(i,1)}removeAllListeners(s){this.events[s]!==void 0&&(this.events[s].length=0)}reset(){this.events={}}}we.eventEmitter=new Ob;const Fb=(t,s)=>{we.eventEmitter&&we.eventEmitter.on(t,s)},Wb=(t,s)=>{we.eventEmitter&&we.eventEmitter.once(t,s)},zb=(t,s)=>{if(we.eventEmitter){if(!t){we.eventEmitter.reset();return}s?we.eventEmitter.removeListener(t,s):we.eventEmitter.removeAllListeners(t)}};var Hb=Object.freeze({__proto__:null,argsToParams:Tb,bindClickHandler:Bb,clickCancel:Tw,clickConfirm:dp,clickDeny:Ew,enableLoading:Sn,fire:Ab,getActions:Io,getCancelButton:Pn,getCloseButton:ad,getConfirmButton:Lr,getContainer:Bt,getDenyButton:Ys,getFocusableElements:ld,getFooter:Xh,getHtmlContainer:nd,getIcon:An,getIconContent:I2,getImage:Qh,getInputLabel:$2,getLoader:Mn,getPopup:We,getProgressSteps:od,getTimerLeft:Mb,getTimerProgressBar:vl,getTitle:Jh,getValidationMessage:yl,increaseTimer:Ib,isDeprecatedParameter:Ap,isLoading:D2,isTimerRunning:$b,isUpdatableParameter:Tp,isValidParameter:Ep,isVisible:Lw,mixin:Pb,off:zb,on:Fb,once:Wb,resumeTimer:Bp,showLoading:Sn,stopTimer:$p,toggleTimer:Rb});class Ub{constructor(s,o){this.callback=s,this.remaining=o,this.running=!1,this.start()}start(){return this.running||(this.running=!0,this.started=new Date,this.id=setTimeout(this.callback,this.remaining)),this.remaining}stop(){return this.started&&this.running&&(this.running=!1,clearTimeout(this.id),this.remaining-=new Date().getTime()-this.started.getTime()),this.remaining}increase(s){const o=this.running;return o&&this.stop(),this.remaining+=s,o&&this.start(),this.remaining}getTimerLeft(){return this.running&&(this.stop(),this.start()),this.remaining}isRunning(){return this.running}}const Dp=["swal-title","swal-html","swal-footer"],Vb=t=>{const s=typeof t.template=="string"?document.querySelector(t.template):t.template;if(!s)return{};const o=s.content;return Zb(o),Object.assign(qb(o),Yb(o),Gb(o),Kb(o),Jb(o),Qb(o),Xb(o,Dp))},qb=t=>{const s={};return Array.from(t.querySelectorAll("swal-param")).forEach(l=>{Hs(l,["name","value"]);const i=l.getAttribute("name"),d=l.getAttribute("value");!i||!d||(i in fs&&typeof fs[i]=="boolean"?s[i]=d!=="false":i in fs&&typeof fs[i]=="object"?s[i]=JSON.parse(d):s[i]=d)}),s},Yb=t=>{const s={};return Array.from(t.querySelectorAll("swal-function-param")).forEach(l=>{const i=l.getAttribute("name"),d=l.getAttribute("value");!i||!d||(s[i]=new Function(`return ${d}`)())}),s},Gb=t=>{const s={};return Array.from(t.querySelectorAll("swal-button")).forEach(l=>{Hs(l,["type","color","aria-label"]);const i=l.getAttribute("type");if(!(!i||!["confirm","cancel","deny"].includes(i))){if(s[`${i}ButtonText`]=l.innerHTML,s[`show${td(i)}Button`]=!0,l.hasAttribute("color")){const d=l.getAttribute("color");d!==null&&(s[`${i}ButtonColor`]=d)}if(l.hasAttribute("aria-label")){const d=l.getAttribute("aria-label");d!==null&&(s[`${i}ButtonAriaLabel`]=d)}}}),s},Kb=t=>{const s={},o=t.querySelector("swal-image");return o&&(Hs(o,["src","width","height","alt"]),o.hasAttribute("src")&&(s.imageUrl=o.getAttribute("src")||void 0),o.hasAttribute("width")&&(s.imageWidth=o.getAttribute("width")||void 0),o.hasAttribute("height")&&(s.imageHeight=o.getAttribute("height")||void 0),o.hasAttribute("alt")&&(s.imageAlt=o.getAttribute("alt")||void 0)),s},Jb=t=>{const s={},o=t.querySelector("swal-icon");return o&&(Hs(o,["type","color"]),o.hasAttribute("type")&&(s.icon=o.getAttribute("type")),o.hasAttribute("color")&&(s.iconColor=o.getAttribute("color")),s.iconHtml=o.innerHTML),s},Qb=t=>{const s={},o=t.querySelector("swal-input");o&&(Hs(o,["type","label","placeholder","value"]),s.input=o.getAttribute("type")||"text",o.hasAttribute("label")&&(s.inputLabel=o.getAttribute("label")),o.hasAttribute("placeholder")&&(s.inputPlaceholder=o.getAttribute("placeholder")),o.hasAttribute("value")&&(s.inputValue=o.getAttribute("value")));const l=Array.from(t.querySelectorAll("swal-input-option"));return l.length&&(s.inputOptions={},l.forEach(i=>{Hs(i,["value"]);const d=i.getAttribute("value");if(!d)return;const u=i.innerHTML;s.inputOptions[d]=u})),s},Xb=(t,s)=>{const o={};for(const l in s){const i=s[l],d=t.querySelector(i);d&&(Hs(d,[]),o[i.replace(/^swal-/,"")]=d.innerHTML.trim())}return o},Zb=t=>{const s=Dp.concat(["swal-param","swal-function-param","swal-button","swal-image","swal-icon","swal-input","swal-input-option"]);Array.from(t.children).forEach(o=>{const l=o.tagName.toLowerCase();s.includes(l)||$t(`Unrecognized element <${l}>`)})},Hs=(t,s)=>{Array.from(t.attributes).forEach(o=>{s.indexOf(o.name)===-1&&$t([`Unrecognized attribute "${o.name}" on <${t.tagName.toLowerCase()}>.`,`${s.length?`Allowed attributes are: ${s.join(", ")}`:"To set the value, use HTML within the element."}`])})},Op=10,ej=t=>{var s,o;const l=Bt(),i=We();if(!l||!i)return;typeof t.willOpen=="function"&&t.willOpen(i),(s=we.eventEmitter)===null||s===void 0||s.emit("willOpen",i);const u=window.getComputedStyle(document.body).overflowY;if(sj(l,i,t),setTimeout(()=>{tj(l,i)},Op),id()&&(rj(l,t.scrollbarPadding!==void 0?t.scrollbarPadding:!1,u),Dw()),!wl()&&!we.previousActiveElement&&(we.previousActiveElement=document.activeElement),typeof t.didOpen=="function"){const h=t.didOpen;setTimeout(()=>h(i))}(o=we.eventEmitter)===null||o===void 0||o.emit("didOpen",i)},il=t=>{const s=We();if(!s||t.target!==s)return;const o=Bt();o&&(s.removeEventListener("animationend",il),s.removeEventListener("transitionend",il),o.style.overflowY="auto",lr(o,Z["no-transition"]))},tj=(t,s)=>{tp(s)?(t.style.overflowY="hidden",s.addEventListener("animationend",il),s.addEventListener("transitionend",il)):t.style.overflowY="auto"},rj=(t,s,o)=>{Ow(),s&&o!=="hidden"&&qw(o),setTimeout(()=>{t.scrollTop=0})},sj=(t,s,o)=>{var l;(l=o.showClass)!==null&&l!==void 0&&l.backdrop&&Fe(t,o.showClass.backdrop),o.animation?(s.style.setProperty("opacity","0","important"),vt(s,"grid"),setTimeout(()=>{var i;(i=o.showClass)!==null&&i!==void 0&&i.popup&&Fe(s,o.showClass.popup),s.style.removeProperty("opacity")},Op)):vt(s,"grid"),Fe([document.documentElement,document.body],Z.shown),o.heightAuto&&o.backdrop&&!o.toast&&Fe([document.documentElement,document.body],Z["height-auto"])};var H0={email:(t,s)=>/^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(t)?Promise.resolve():Promise.resolve(s||"Invalid email address"),url:(t,s)=>/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)$/.test(t)?Promise.resolve():Promise.resolve(s||"Invalid URL")};function nj(t){t.inputValidator||(t.input==="email"&&(t.inputValidator=H0.email),t.input==="url"&&(t.inputValidator=H0.url))}function oj(t){(!t.target||typeof t.target=="string"&&!document.querySelector(t.target)||typeof t.target!="string"&&!t.target.appendChild)&&($t('Target parameter is not valid, defaulting to "body"'),t.target="body")}function aj(t){nj(t),t.showLoaderOnConfirm&&!t.preConfirm&&$t(`showLoaderOnConfirm is set to true, but preConfirm is not defined.
130
- showLoaderOnConfirm should be used together with preConfirm, see usage example:
131
- https://sweetalert2.github.io/#ajax-request`),oj(t),typeof t.title=="string"&&(t.title=t.title.split(`
132
- `).join("<br />")),J2(t)}let Sr;var Ya=new WeakMap;class nt{constructor(...s){if(_2(this,Ya,Promise.resolve({isConfirmed:!1,isDenied:!1,isDismissed:!0})),typeof window>"u")return;Sr=this;const o=Object.freeze(this.constructor.argsToParams(s));this.params=o,this.isAwaitingPromise=!1,L2(Ya,this,this._main(Sr.params))}_main(s,o={}){if(Pp(Object.assign({},o,s)),we.currentInstance){const d=Cn.swalPromiseResolve.get(we.currentInstance),{isAwaitingPromise:u}=we.currentInstance;we.currentInstance._destroy(),u||d({isDismissed:!0}),id()&&hp()}we.currentInstance=Sr;const l=ij(s,o);aj(l),Object.freeze(l),we.timeout&&(we.timeout.stop(),delete we.timeout),clearTimeout(we.restoreFocusTimeout);const i=cj(Sr);return cp(Sr,l),Ue.innerParams.set(Sr,l),lj(Sr,i,l)}then(s){return M0(Ya,this).then(s)}finally(s){return M0(Ya,this).finally(s)}}const lj=(t,s,o)=>new Promise((l,i)=>{const d=u=>{t.close({isDismissed:!0,dismiss:u,isConfirmed:!1,isDenied:!1})};Cn.swalPromiseResolve.set(t,l),Cn.swalPromiseReject.set(t,i),s.confirmButton.onclick=()=>{cb(t)},s.denyButton.onclick=()=>{db(t)},s.cancelButton.onclick=()=>{ub(t,d)},s.closeButton.onclick=()=>{d(Rn.close)},Nb(o,s,d),Aw(we,o,d),eb(t,o),ej(o),dj(we,o,d),uj(s,o),setTimeout(()=>{s.container.scrollTop=0})}),ij=(t,s)=>{const o=Vb(t),l=Object.assign({},fs,s,o,t);return l.showClass=Object.assign({},fs.showClass,l.showClass),l.hideClass=Object.assign({},fs.hideClass,l.hideClass),l.animation===!1&&(l.showClass={backdrop:"swal2-noanimation"},l.hideClass={}),l},cj=t=>{const s={popup:We(),container:Bt(),actions:Io(),confirmButton:Lr(),denyButton:Ys(),cancelButton:Pn(),loader:Mn(),closeButton:ad(),validationMessage:yl(),progressSteps:od()};return Ue.domCache.set(t,s),s},dj=(t,s,o)=>{const l=vl();Tt(l),s.timer&&(t.timeout=new Ub(()=>{o("timer"),delete t.timeout},s.timer),s.timerProgressBar&&l&&(vt(l),Xt(l,s,"timerProgressBar"),setTimeout(()=>{t.timeout&&t.timeout.running&&dd(s.timer)})))},uj=(t,s)=>{if(!s.toast){if(!gl(s.allowEnterKey)){Kh("allowEnterKey"),pj();return}mj(t)||hj(t,s)||Mc(-1,1)}},mj=t=>{const s=Array.from(t.popup.querySelectorAll("[autofocus]"));for(const o of s)if(o instanceof HTMLElement&&qt(o))return o.focus(),!0;return!1},hj=(t,s)=>s.focusDeny&&qt(t.denyButton)?(t.denyButton.focus(),!0):s.focusCancel&&qt(t.cancelButton)?(t.cancelButton.focus(),!0):s.focusConfirm&&qt(t.confirmButton)?(t.confirmButton.focus(),!0):!1,pj=()=>{document.activeElement instanceof HTMLElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur()};nt.prototype.disableButtons=kp;nt.prototype.enableButtons=Np;nt.prototype.getInput=wp;nt.prototype.disableInput=Sp;nt.prototype.enableInput=Cp;nt.prototype.hideLoading=al;nt.prototype.disableLoading=al;nt.prototype.showValidationMessage=_p;nt.prototype.resetValidationMessage=Lp;nt.prototype.close=xs;nt.prototype.closePopup=xs;nt.prototype.closeModal=xs;nt.prototype.closeToast=xs;nt.prototype.rejectPromise=fp;nt.prototype.update=Mp;nt.prototype._destroy=Rp;Object.assign(nt,Hb);Object.keys(jb).forEach(t=>{nt[t]=function(...s){if(Sr&&Sr[t])return Sr[t](...s)}});nt.DismissReason=Rn;nt.version="11.26.17";const rt=nt;rt.default=rt;typeof document<"u"&&(function(t,s){var o=t.createElement("style");if(t.getElementsByTagName("head")[0].appendChild(o),o.styleSheet)o.styleSheet.disabled||(o.styleSheet.cssText=s);else try{o.innerHTML=s}catch{o.innerText=s}})(document,':root{--swal2-outline: 0 0 0 3px rgba(100, 150, 200, 0.5);--swal2-container-padding: 0.625em;--swal2-backdrop: rgba(0, 0, 0, 0.4);--swal2-backdrop-transition: background-color 0.15s;--swal2-width: 32em;--swal2-padding: 0 0 1.25em;--swal2-border: none;--swal2-border-radius: 0.3125rem;--swal2-background: white;--swal2-color: #545454;--swal2-show-animation: swal2-show 0.3s;--swal2-hide-animation: swal2-hide 0.15s forwards;--swal2-icon-zoom: 1;--swal2-icon-animations: true;--swal2-title-padding: 0.8em 1em 0;--swal2-html-container-padding: 1em 1.6em 0.3em;--swal2-input-border: 1px solid #d9d9d9;--swal2-input-border-radius: 0.1875em;--swal2-input-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-background: transparent;--swal2-input-transition: border-color 0.2s, box-shadow 0.2s;--swal2-input-hover-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-focus-border: 1px solid #b4dbed;--swal2-input-focus-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px rgba(100, 150, 200, 0.5);--swal2-progress-step-background: #add8e6;--swal2-validation-message-background: #f0f0f0;--swal2-validation-message-color: #666;--swal2-footer-border-color: #eee;--swal2-footer-background: transparent;--swal2-footer-color: inherit;--swal2-timer-progress-bar-background: rgba(0, 0, 0, 0.3);--swal2-close-button-position: initial;--swal2-close-button-inset: auto;--swal2-close-button-font-size: 2.5em;--swal2-close-button-color: #ccc;--swal2-close-button-transition: color 0.2s, box-shadow 0.2s;--swal2-close-button-outline: initial;--swal2-close-button-box-shadow: inset 0 0 0 3px transparent;--swal2-close-button-focus-box-shadow: inset var(--swal2-outline);--swal2-close-button-hover-transform: none;--swal2-actions-justify-content: center;--swal2-actions-width: auto;--swal2-actions-margin: 1.25em auto 0;--swal2-actions-padding: 0;--swal2-actions-border-radius: 0;--swal2-actions-background: transparent;--swal2-action-button-transition: background-color 0.2s, box-shadow 0.2s;--swal2-action-button-hover: black 10%;--swal2-action-button-active: black 10%;--swal2-confirm-button-box-shadow: none;--swal2-confirm-button-border-radius: 0.25em;--swal2-confirm-button-background-color: #7066e0;--swal2-confirm-button-color: #fff;--swal2-deny-button-box-shadow: none;--swal2-deny-button-border-radius: 0.25em;--swal2-deny-button-background-color: #dc3741;--swal2-deny-button-color: #fff;--swal2-cancel-button-box-shadow: none;--swal2-cancel-button-border-radius: 0.25em;--swal2-cancel-button-background-color: #6e7881;--swal2-cancel-button-color: #fff;--swal2-toast-show-animation: swal2-toast-show 0.5s;--swal2-toast-hide-animation: swal2-toast-hide 0.1s forwards;--swal2-toast-border: none;--swal2-toast-box-shadow: 0 0 1px hsl(0deg 0% 0% / 0.075), 0 1px 2px hsl(0deg 0% 0% / 0.075), 1px 2px 4px hsl(0deg 0% 0% / 0.075), 1px 3px 8px hsl(0deg 0% 0% / 0.075), 2px 4px 16px hsl(0deg 0% 0% / 0.075)}[data-swal2-theme=dark]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}@media(prefers-color-scheme: dark){[data-swal2-theme=auto]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow:hidden}body.swal2-height-auto{height:auto !important}body.swal2-no-backdrop .swal2-container{background-color:rgba(0,0,0,0) !important;pointer-events:none}body.swal2-no-backdrop .swal2-container .swal2-popup{pointer-events:all}body.swal2-no-backdrop .swal2-container .swal2-modal{box-shadow:0 0 10px var(--swal2-backdrop)}body.swal2-toast-shown .swal2-container{box-sizing:border-box;width:360px;max-width:100%;background-color:rgba(0,0,0,0);pointer-events:none}body.swal2-toast-shown .swal2-container.swal2-top{inset:0 auto auto 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-top-end,body.swal2-toast-shown .swal2-container.swal2-top-right{inset:0 0 auto auto}body.swal2-toast-shown .swal2-container.swal2-top-start,body.swal2-toast-shown .swal2-container.swal2-top-left{inset:0 auto auto 0}body.swal2-toast-shown .swal2-container.swal2-center-start,body.swal2-toast-shown .swal2-container.swal2-center-left{inset:50% auto auto 0;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-center{inset:50% auto auto 50%;transform:translate(-50%, -50%)}body.swal2-toast-shown .swal2-container.swal2-center-end,body.swal2-toast-shown .swal2-container.swal2-center-right{inset:50% 0 auto auto;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-start,body.swal2-toast-shown .swal2-container.swal2-bottom-left{inset:auto auto 0 0}body.swal2-toast-shown .swal2-container.swal2-bottom{inset:auto auto 0 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-end,body.swal2-toast-shown .swal2-container.swal2-bottom-right{inset:auto 0 0 auto}@media print{body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow-y:scroll !important}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown)>[aria-hidden=true]{display:none}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown) .swal2-container{position:static !important}}div:where(.swal2-container){display:grid;position:fixed;z-index:1060;inset:0;box-sizing:border-box;grid-template-areas:"top-start top top-end" "center-start center center-end" "bottom-start bottom-center bottom-end";grid-template-rows:minmax(min-content, auto) minmax(min-content, auto) minmax(min-content, auto);height:100%;padding:var(--swal2-container-padding);overflow-x:hidden;transition:var(--swal2-backdrop-transition);-webkit-overflow-scrolling:touch}div:where(.swal2-container).swal2-backdrop-show,div:where(.swal2-container).swal2-noanimation{background:var(--swal2-backdrop)}div:where(.swal2-container).swal2-backdrop-hide{background:rgba(0,0,0,0) !important}div:where(.swal2-container).swal2-top-start,div:where(.swal2-container).swal2-center-start,div:where(.swal2-container).swal2-bottom-start{grid-template-columns:minmax(0, 1fr) auto auto}div:where(.swal2-container).swal2-top,div:where(.swal2-container).swal2-center,div:where(.swal2-container).swal2-bottom{grid-template-columns:auto minmax(0, 1fr) auto}div:where(.swal2-container).swal2-top-end,div:where(.swal2-container).swal2-center-end,div:where(.swal2-container).swal2-bottom-end{grid-template-columns:auto auto minmax(0, 1fr)}div:where(.swal2-container).swal2-top-start>.swal2-popup{align-self:start}div:where(.swal2-container).swal2-top>.swal2-popup{grid-column:2;place-self:start center}div:where(.swal2-container).swal2-top-end>.swal2-popup,div:where(.swal2-container).swal2-top-right>.swal2-popup{grid-column:3;place-self:start end}div:where(.swal2-container).swal2-center-start>.swal2-popup,div:where(.swal2-container).swal2-center-left>.swal2-popup{grid-row:2;align-self:center}div:where(.swal2-container).swal2-center>.swal2-popup{grid-column:2;grid-row:2;place-self:center center}div:where(.swal2-container).swal2-center-end>.swal2-popup,div:where(.swal2-container).swal2-center-right>.swal2-popup{grid-column:3;grid-row:2;place-self:center end}div:where(.swal2-container).swal2-bottom-start>.swal2-popup,div:where(.swal2-container).swal2-bottom-left>.swal2-popup{grid-column:1;grid-row:3;align-self:end}div:where(.swal2-container).swal2-bottom>.swal2-popup{grid-column:2;grid-row:3;place-self:end center}div:where(.swal2-container).swal2-bottom-end>.swal2-popup,div:where(.swal2-container).swal2-bottom-right>.swal2-popup{grid-column:3;grid-row:3;place-self:end end}div:where(.swal2-container).swal2-grow-row>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-column:1/4;width:100%}div:where(.swal2-container).swal2-grow-column>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-row:1/4;align-self:stretch}div:where(.swal2-container).swal2-no-transition{transition:none !important}div:where(.swal2-container)[popover]{width:auto;border:0}div:where(.swal2-container) div:where(.swal2-popup){display:none;position:relative;box-sizing:border-box;grid-template-columns:minmax(0, 100%);width:var(--swal2-width);max-width:100%;padding:var(--swal2-padding);border:var(--swal2-border);border-radius:var(--swal2-border-radius);background:var(--swal2-background);color:var(--swal2-color);font-family:inherit;font-size:1rem;container-name:swal2-popup}div:where(.swal2-container) div:where(.swal2-popup):focus{outline:none}div:where(.swal2-container) div:where(.swal2-popup).swal2-loading{overflow-y:hidden}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable{cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable div:where(.swal2-icon){cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging{cursor:grabbing}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging div:where(.swal2-icon){cursor:grabbing}div:where(.swal2-container) h2:where(.swal2-title){position:relative;max-width:100%;margin:0;padding:var(--swal2-title-padding);color:inherit;font-size:1.875em;font-weight:600;text-align:center;text-transform:none;overflow-wrap:break-word;cursor:initial}div:where(.swal2-container) div:where(.swal2-actions){display:flex;z-index:1;box-sizing:border-box;flex-wrap:wrap;align-items:center;justify-content:var(--swal2-actions-justify-content);width:var(--swal2-actions-width);margin:var(--swal2-actions-margin);padding:var(--swal2-actions-padding);border-radius:var(--swal2-actions-border-radius);background:var(--swal2-actions-background)}div:where(.swal2-container) div:where(.swal2-loader){display:none;align-items:center;justify-content:center;width:2.2em;height:2.2em;margin:0 1.875em;animation:swal2-rotate-loading 1.5s linear 0s infinite normal;border-width:.25em;border-style:solid;border-radius:100%;border-color:#2778c4 rgba(0,0,0,0) #2778c4 rgba(0,0,0,0)}div:where(.swal2-container) button:where(.swal2-styled){margin:.3125em;padding:.625em 1.1em;transition:var(--swal2-action-button-transition);border:none;box-shadow:0 0 0 3px rgba(0,0,0,0);font-weight:500}div:where(.swal2-container) button:where(.swal2-styled):not([disabled]){cursor:pointer}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm){border-radius:var(--swal2-confirm-button-border-radius);background:initial;background-color:var(--swal2-confirm-button-background-color);box-shadow:var(--swal2-confirm-button-box-shadow);color:var(--swal2-confirm-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):hover{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):active{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny){border-radius:var(--swal2-deny-button-border-radius);background:initial;background-color:var(--swal2-deny-button-background-color);box-shadow:var(--swal2-deny-button-box-shadow);color:var(--swal2-deny-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):hover{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):active{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel){border-radius:var(--swal2-cancel-button-border-radius);background:initial;background-color:var(--swal2-cancel-button-background-color);box-shadow:var(--swal2-cancel-button-box-shadow);color:var(--swal2-cancel-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):hover{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):active{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):focus-visible{outline:none;box-shadow:var(--swal2-action-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-styled)[disabled]:not(.swal2-loading){opacity:.4}div:where(.swal2-container) button:where(.swal2-styled)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-footer){margin:1em 0 0;padding:1em 1em 0;border-top:1px solid var(--swal2-footer-border-color);background:var(--swal2-footer-background);color:var(--swal2-footer-color);font-size:1em;text-align:center;cursor:initial}div:where(.swal2-container) .swal2-timer-progress-bar-container{position:absolute;right:0;bottom:0;left:0;grid-column:auto !important;overflow:hidden;border-bottom-right-radius:var(--swal2-border-radius);border-bottom-left-radius:var(--swal2-border-radius)}div:where(.swal2-container) div:where(.swal2-timer-progress-bar){width:100%;height:.25em;background:var(--swal2-timer-progress-bar-background)}div:where(.swal2-container) img:where(.swal2-image){max-width:100%;margin:2em auto 1em;cursor:initial}div:where(.swal2-container) button:where(.swal2-close){position:var(--swal2-close-button-position);inset:var(--swal2-close-button-inset);z-index:2;align-items:center;justify-content:center;width:1.2em;height:1.2em;margin-top:0;margin-right:0;margin-bottom:-1.2em;padding:0;overflow:hidden;transition:var(--swal2-close-button-transition);border:none;border-radius:var(--swal2-border-radius);outline:var(--swal2-close-button-outline);background:rgba(0,0,0,0);color:var(--swal2-close-button-color);font-family:monospace;font-size:var(--swal2-close-button-font-size);cursor:pointer;justify-self:end}div:where(.swal2-container) button:where(.swal2-close):hover{transform:var(--swal2-close-button-hover-transform);background:rgba(0,0,0,0);color:#f27474}div:where(.swal2-container) button:where(.swal2-close):focus-visible{outline:none;box-shadow:var(--swal2-close-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-close)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-html-container){z-index:1;justify-content:center;margin:0;padding:var(--swal2-html-container-padding);overflow:auto;color:inherit;font-size:1.125em;font-weight:normal;line-height:normal;text-align:center;overflow-wrap:break-word;word-break:break-word;cursor:initial}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea),div:where(.swal2-container) select:where(.swal2-select),div:where(.swal2-container) div:where(.swal2-radio),div:where(.swal2-container) label:where(.swal2-checkbox){margin:1em 2em 3px}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea){box-sizing:border-box;width:auto;transition:var(--swal2-input-transition);border:var(--swal2-input-border);border-radius:var(--swal2-input-border-radius);background:var(--swal2-input-background);box-shadow:var(--swal2-input-box-shadow);color:inherit;font-size:1.125em}div:where(.swal2-container) input:where(.swal2-input).swal2-inputerror,div:where(.swal2-container) input:where(.swal2-file).swal2-inputerror,div:where(.swal2-container) textarea:where(.swal2-textarea).swal2-inputerror{border-color:#f27474 !important;box-shadow:0 0 2px #f27474 !important}div:where(.swal2-container) input:where(.swal2-input):hover,div:where(.swal2-container) input:where(.swal2-file):hover,div:where(.swal2-container) textarea:where(.swal2-textarea):hover{box-shadow:var(--swal2-input-hover-box-shadow)}div:where(.swal2-container) input:where(.swal2-input):focus,div:where(.swal2-container) input:where(.swal2-file):focus,div:where(.swal2-container) textarea:where(.swal2-textarea):focus{border:var(--swal2-input-focus-border);outline:none;box-shadow:var(--swal2-input-focus-box-shadow)}div:where(.swal2-container) input:where(.swal2-input)::placeholder,div:where(.swal2-container) input:where(.swal2-file)::placeholder,div:where(.swal2-container) textarea:where(.swal2-textarea)::placeholder{color:#ccc}div:where(.swal2-container) .swal2-range{margin:1em 2em 3px;background:var(--swal2-background)}div:where(.swal2-container) .swal2-range input{width:80%}div:where(.swal2-container) .swal2-range output{width:20%;color:inherit;font-weight:600;text-align:center}div:where(.swal2-container) .swal2-range input,div:where(.swal2-container) .swal2-range output{height:2.625em;padding:0;font-size:1.125em;line-height:2.625em}div:where(.swal2-container) .swal2-input{height:2.625em;padding:0 .75em}div:where(.swal2-container) .swal2-file{width:75%;margin-right:auto;margin-left:auto;background:var(--swal2-input-background);font-size:1.125em}div:where(.swal2-container) .swal2-textarea{height:6.75em;padding:.75em}div:where(.swal2-container) .swal2-select{min-width:50%;max-width:100%;padding:.375em .625em;background:var(--swal2-input-background);color:inherit;font-size:1.125em}div:where(.swal2-container) .swal2-radio,div:where(.swal2-container) .swal2-checkbox{align-items:center;justify-content:center;background:var(--swal2-background);color:inherit}div:where(.swal2-container) .swal2-radio label,div:where(.swal2-container) .swal2-checkbox label{margin:0 .6em;font-size:1.125em}div:where(.swal2-container) .swal2-radio input,div:where(.swal2-container) .swal2-checkbox input{flex-shrink:0;margin:0 .4em}div:where(.swal2-container) label:where(.swal2-input-label){display:flex;justify-content:center;margin:1em auto 0}div:where(.swal2-container) div:where(.swal2-validation-message){align-items:center;justify-content:center;margin:1em 0 0;padding:.625em;overflow:hidden;background:var(--swal2-validation-message-background);color:var(--swal2-validation-message-color);font-size:1em;font-weight:300}div:where(.swal2-container) div:where(.swal2-validation-message)::before{content:"!";display:inline-block;width:1.5em;min-width:1.5em;height:1.5em;margin:0 .625em;border-radius:50%;background-color:#f27474;color:#fff;font-weight:600;line-height:1.5em;text-align:center}div:where(.swal2-container) .swal2-progress-steps{flex-wrap:wrap;align-items:center;max-width:100%;margin:1.25em auto;padding:0;background:rgba(0,0,0,0);font-weight:600}div:where(.swal2-container) .swal2-progress-steps li{display:inline-block;position:relative}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step{z-index:20;flex-shrink:0;width:2em;height:2em;border-radius:2em;background:#2778c4;color:#fff;line-height:2em;text-align:center}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:#2778c4}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step{background:var(--swal2-progress-step-background);color:#fff}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step-line{background:var(--swal2-progress-step-background)}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step-line{z-index:10;flex-shrink:0;width:2.5em;height:.4em;margin:0 -1px;background:#2778c4}div:where(.swal2-icon){position:relative;box-sizing:content-box;justify-content:center;width:5em;height:5em;margin:2.5em auto .6em;zoom:var(--swal2-icon-zoom);border:.25em solid rgba(0,0,0,0);border-radius:50%;border-color:#000;font-family:inherit;line-height:5em;cursor:default;user-select:none}div:where(.swal2-icon) .swal2-icon-content{display:flex;align-items:center;font-size:3.75em}div:where(.swal2-icon).swal2-error{border-color:#f27474;color:#f27474}div:where(.swal2-icon).swal2-error .swal2-x-mark{position:relative;flex-grow:1}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line]{display:block;position:absolute;top:2.3125em;width:2.9375em;height:.3125em;border-radius:.125em;background-color:#f27474}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=left]{left:1.0625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=right]{right:1em;transform:rotate(-45deg)}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-error.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-error.swal2-icon-show .swal2-x-mark{animation:swal2-animate-error-x-mark .5s}}div:where(.swal2-icon).swal2-warning{border-color:#f8bb86;color:#f8bb86}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-warning.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-warning.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .5s}}div:where(.swal2-icon).swal2-info{border-color:#3fc3ee;color:#3fc3ee}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-info.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-info.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .8s}}div:where(.swal2-icon).swal2-question{border-color:#87adbd;color:#87adbd}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-question.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-question.swal2-icon-show .swal2-icon-content{animation:swal2-animate-question-mark .8s}}div:where(.swal2-icon).swal2-success{border-color:#a5dc86;color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line]{position:absolute;width:3.75em;height:7.5em;border-radius:50%}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.4375em;left:-2.0635em;transform:rotate(-45deg);transform-origin:3.75em 3.75em;border-radius:7.5em 0 0 7.5em}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.6875em;left:1.875em;transform:rotate(-45deg);transform-origin:0 3.75em;border-radius:0 7.5em 7.5em 0}div:where(.swal2-icon).swal2-success .swal2-success-ring{position:absolute;z-index:2;top:-0.25em;left:-0.25em;box-sizing:content-box;width:100%;height:100%;border:.25em solid rgba(165,220,134,.3);border-radius:50%}div:where(.swal2-icon).swal2-success .swal2-success-fix{position:absolute;z-index:1;top:.5em;left:1.625em;width:.4375em;height:5.625em;transform:rotate(-45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line]{display:block;position:absolute;z-index:2;height:.3125em;border-radius:.125em;background-color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=tip]{top:2.875em;left:.8125em;width:1.5625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=long]{top:2.375em;right:.5em;width:2.9375em;transform:rotate(-45deg)}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-animate-success-line-tip .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-animate-success-line-long .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-circular-line-right{animation:swal2-rotate-success-circular-line 4.25s ease-in}}[class^=swal2]{-webkit-tap-highlight-color:rgba(0,0,0,0)}.swal2-show{animation:var(--swal2-show-animation)}.swal2-hide{animation:var(--swal2-hide-animation)}.swal2-noanimation{transition:none}.swal2-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}.swal2-rtl .swal2-close{margin-right:initial;margin-left:0}.swal2-rtl .swal2-timer-progress-bar{right:0;left:auto}.swal2-toast{box-sizing:border-box;grid-column:1/4 !important;grid-row:1/4 !important;grid-template-columns:min-content auto min-content;padding:1em;overflow-y:hidden;border:var(--swal2-toast-border);background:var(--swal2-background);box-shadow:var(--swal2-toast-box-shadow);pointer-events:all}.swal2-toast>*{grid-column:2}.swal2-toast h2:where(.swal2-title){margin:.5em 1em;padding:0;font-size:1em;text-align:initial}.swal2-toast .swal2-loading{justify-content:center}.swal2-toast input:where(.swal2-input){height:2em;margin:.5em;font-size:1em}.swal2-toast .swal2-validation-message{font-size:1em}.swal2-toast div:where(.swal2-footer){margin:.5em 0 0;padding:.5em 0 0;font-size:.8em}.swal2-toast button:where(.swal2-close){grid-column:3/3;grid-row:1/99;align-self:center;width:.8em;height:.8em;margin:0;font-size:2em}.swal2-toast div:where(.swal2-html-container){margin:.5em 1em;padding:0;overflow:initial;font-size:1em;text-align:initial}.swal2-toast div:where(.swal2-html-container):empty{padding:0}.swal2-toast .swal2-loader{grid-column:1;grid-row:1/99;align-self:center;width:2em;height:2em;margin:.25em}.swal2-toast .swal2-icon{grid-column:1;grid-row:1/99;align-self:center;width:2em;min-width:2em;height:2em;margin:0 .5em 0 0}.swal2-toast .swal2-icon .swal2-icon-content{display:flex;align-items:center;font-size:1.8em;font-weight:bold}.swal2-toast .swal2-icon.swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line]{top:.875em;width:1.375em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:.3125em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:.3125em}.swal2-toast div:where(.swal2-actions){justify-content:flex-start;height:auto;margin:0;margin-top:.5em;padding:0 .5em}.swal2-toast button:where(.swal2-styled){margin:.25em .5em;padding:.4em .6em;font-size:1em}.swal2-toast .swal2-success{border-color:#a5dc86}.swal2-toast .swal2-success [class^=swal2-success-circular-line]{position:absolute;width:1.6em;height:3em;border-radius:50%}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.8em;left:-0.5em;transform:rotate(-45deg);transform-origin:2em 2em;border-radius:4em 0 0 4em}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.25em;left:.9375em;transform-origin:0 1.5em;border-radius:0 4em 4em 0}.swal2-toast .swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-success .swal2-success-fix{top:0;left:.4375em;width:.4375em;height:2.6875em}.swal2-toast .swal2-success [class^=swal2-success-line]{height:.3125em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=tip]{top:1.125em;left:.1875em;width:.75em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=long]{top:.9375em;right:.1875em;width:1.375em}@container swal2-popup style(--swal2-icon-animations:true){.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-toast-animate-success-line-tip .75s}.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-toast-animate-success-line-long .75s}}.swal2-toast.swal2-show{animation:var(--swal2-toast-show-animation)}.swal2-toast.swal2-hide{animation:var(--swal2-toast-hide-animation)}@keyframes swal2-show{0%{transform:translate3d(0, -50px, 0) scale(0.9);opacity:0}100%{transform:translate3d(0, 0, 0) scale(1);opacity:1}}@keyframes swal2-hide{0%{transform:translate3d(0, 0, 0) scale(1);opacity:1}100%{transform:translate3d(0, -50px, 0) scale(0.9);opacity:0}}@keyframes swal2-animate-success-line-tip{0%{top:1.1875em;left:.0625em;width:0}54%{top:1.0625em;left:.125em;width:0}70%{top:2.1875em;left:-0.375em;width:3.125em}84%{top:3em;left:1.3125em;width:1.0625em}100%{top:2.8125em;left:.8125em;width:1.5625em}}@keyframes swal2-animate-success-line-long{0%{top:3.375em;right:2.875em;width:0}65%{top:3.375em;right:2.875em;width:0}84%{top:2.1875em;right:0;width:3.4375em}100%{top:2.375em;right:.5em;width:2.9375em}}@keyframes swal2-rotate-success-circular-line{0%{transform:rotate(-45deg)}5%{transform:rotate(-45deg)}12%{transform:rotate(-405deg)}100%{transform:rotate(-405deg)}}@keyframes swal2-animate-error-x-mark{0%{margin-top:1.625em;transform:scale(0.4);opacity:0}50%{margin-top:1.625em;transform:scale(0.4);opacity:0}80%{margin-top:-0.375em;transform:scale(1.15)}100%{margin-top:0;transform:scale(1);opacity:1}}@keyframes swal2-animate-error-icon{0%{transform:rotateX(100deg);opacity:0}100%{transform:rotateX(0deg);opacity:1}}@keyframes swal2-rotate-loading{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}@keyframes swal2-animate-question-mark{0%{transform:rotateY(-360deg)}100%{transform:rotateY(0)}}@keyframes swal2-animate-i-mark{0%{transform:rotateZ(45deg);opacity:0}25%{transform:rotateZ(-25deg);opacity:.4}50%{transform:rotateZ(15deg);opacity:.8}75%{transform:rotateZ(-5deg);opacity:1}100%{transform:rotateX(0);opacity:1}}@keyframes swal2-toast-show{0%{transform:translateY(-0.625em) rotateZ(2deg)}33%{transform:translateY(0) rotateZ(-2deg)}66%{transform:translateY(0.3125em) rotateZ(2deg)}100%{transform:translateY(0) rotateZ(0deg)}}@keyframes swal2-toast-hide{100%{transform:rotateZ(1deg);opacity:0}}@keyframes swal2-toast-animate-success-line-tip{0%{top:.5625em;left:.0625em;width:0}54%{top:.125em;left:.125em;width:0}70%{top:.625em;left:-0.25em;width:1.625em}84%{top:1.0625em;left:.75em;width:.5em}100%{top:1.125em;left:.1875em;width:.75em}}@keyframes swal2-toast-animate-success-line-long{0%{top:1.625em;right:1.375em;width:0}65%{top:1.25em;right:.9375em;width:0}84%{top:.9375em;right:0;width:1.125em}100%{top:.9375em;right:.1875em;width:1.375em}}');const xj=[{templateId:"build-product",title:"Build from Scratch",description:"Start with an idea. Claude helps you plan, design, and build step by step.",stepCount:"3 steps",recommended:!0,icon:e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"})})},{templateId:"from-design-doc",title:"I Have a Design Doc",description:"Upload your design document. Claude generates stories and implements them.",stepCount:"2 steps",requiresInput:"design_doc",icon:e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})},{templateId:"from-stories",title:"I Have User Stories",description:"Import your existing stories. Claude implements them one by one.",stepCount:"1 step",requiresInput:"stories",icon:e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01"})})},{templateId:"planning-only",title:"Just Plan",description:"Create a design document through interactive planning with Claude.",stepCount:"1 step",icon:e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}];function U0({projectSlug:t,onWorkflowCreated:s}){const o=ir(),l=p.useRef(null),[i,d]=p.useState(null),[u,h]=p.useState(null),[x,g]=p.useState(null),[v,y]=p.useState("name"),[b,k]=p.useState(""),[_,S]=p.useState(!1),[j,N]=p.useState(""),[T,P]=p.useState(null),C=O=>{g(O),y("name"),k(""),S(!1),N(""),P(null),h(null)},E=()=>{g(null),y("name"),h(null)},I=()=>{b.trim()&&(x!=null&&x.requiresInput?y("input"):q())},M=O=>{var W;const X=(W=O.target.files)==null?void 0:W[0];if(!X)return;const ee=new FileReader;ee.onload=te=>{var R;const D=(R=te.target)==null?void 0:R.result;N(D),P(X.name)},ee.readAsText(X)},q=async()=>{if(!x||!b.trim())return;if(x.requiresInput&&!j.trim()){h(`Please provide your ${x.requiresInput==="design_doc"?"design document":"user stories"}`);return}d(x.templateId),y("creating"),h(null);let O=null;try{if(O=await $v(t,{template_id:x.templateId,name:b.trim(),config:_?{architecture_first:!0}:void 0}),j.trim()&&x.requiresInput){const X=x.requiresInput==="design_doc"?"design_doc":"input_file",ee=x.requiresInput==="design_doc"?"Design Document":"Imported Stories";try{await Kc(t,O.id,{resource_type:X,name:ee,content:j.trim(),source:"upload"})}catch(W){console.error("Failed to upload resource:",W),g(null),s==null||s(),o(`/projects/${t}/workflows/${O.id}`);return}}g(null),s==null||s(),o(`/projects/${t}/workflows/${O.id}`)}catch(X){h(X instanceof Error?X.message:"Failed to create workflow"),O||y(x.requiresInput?"input":"name")}finally{d(null)}},z=()=>x&&x.requiresInput?2:1,U=()=>v==="name"?1:2;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-white mb-2",children:"What would you like to do?"}),e.jsx("p",{className:"text-gray-400",children:"Choose how you want to start your project"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:xj.map(O=>e.jsx("button",{onClick:()=>C(O),disabled:i!==null,className:`p-6 rounded-lg border text-left transition-all group ${O.recommended?"bg-primary-900/20 border-primary-600 hover:border-primary-500":"bg-gray-800 border-gray-700 hover:border-gray-600"} ${i!==null?"opacity-50 cursor-not-allowed":""}`,children:e.jsxs("div",{className:"flex items-start space-x-4",children:[e.jsx("div",{className:`w-12 h-12 rounded-lg flex items-center justify-center flex-shrink-0 ${O.recommended?"bg-primary-600":"bg-gray-700"}`,children:e.jsx("span",{className:O.recommended?"text-white":"text-gray-300",children:O.icon})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h3",{className:`text-lg font-semibold transition-colors ${O.recommended?"text-white group-hover:text-primary-300":"text-white group-hover:text-gray-200"}`,children:O.title}),O.recommended&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-primary-600 text-primary-100",children:"Recommended"})]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:O.description}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:O.stepCount})]}),e.jsx("svg",{className:"w-5 h-5 text-gray-500 group-hover:text-gray-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})},O.templateId))}),x&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-gray-800 rounded-lg border border-gray-700 p-6 max-w-lg w-full mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:v==="name"?`Create ${x.title} Workflow`:v==="input"&&x.requiresInput==="design_doc"?"Upload Design Document":v==="input"&&x.requiresInput==="stories"?"Import User Stories":"Creating Workflow..."}),z()>1&&v!=="creating"&&e.jsxs("span",{className:"text-sm text-gray-400",children:["Step ",U()," of ",z()]})]}),v==="name"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"workflow-name",className:"block text-sm font-medium text-gray-300 mb-1",children:"Workflow Name"}),e.jsx("input",{id:"workflow-name",type:"text",value:b,onChange:O=>k(O.target.value),placeholder:"e.g., My Awesome App",className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white placeholder-gray-400 focus:outline-none focus:border-primary-500",autoFocus:!0,onKeyDown:O=>{O.key==="Enter"&&b.trim()&&I()}})]}),x.templateId==="build-product"&&e.jsxs("div",{className:"flex items-start space-x-3 p-3 bg-gray-700/50 rounded",children:[e.jsx("input",{id:"new-project",type:"checkbox",checked:_,onChange:O=>S(O.target.checked),className:"mt-1 rounded bg-gray-600 border-gray-500"}),e.jsxs("label",{htmlFor:"new-project",className:"text-sm text-gray-300",children:[e.jsx("span",{className:"font-medium",children:"This is a new project"}),e.jsx("p",{className:"text-gray-400 mt-0.5",children:"Build foundation architecture first by grouping initial stories together"})]})]}),u&&e.jsx("div",{className:"p-3 bg-red-900/30 border border-red-800 rounded text-sm text-red-400",children:u}),e.jsxs("div",{className:"flex justify-end space-x-3 pt-2",children:[e.jsx("button",{onClick:E,className:"px-4 py-2 text-sm text-gray-400 hover:text-white",children:"Cancel"}),e.jsx("button",{onClick:I,disabled:!b.trim(),className:"px-4 py-2 text-sm bg-primary-600 text-white rounded hover:bg-primary-500 disabled:opacity-50 disabled:cursor-not-allowed",children:x.requiresInput?"Next":"Create Workflow"})]})]}),v==="input"&&x.requiresInput&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-gray-400",children:x.requiresInput==="design_doc"?"Claude will use your design document to generate implementation stories.":"Paste your user stories below. Claude will implement them one by one."}),e.jsxs("div",{onClick:()=>{var O;return(O=l.current)==null?void 0:O.click()},className:"border-2 border-dashed border-gray-600 rounded-lg p-6 text-center hover:border-gray-500 cursor-pointer transition-colors",children:[e.jsx("input",{ref:l,type:"file",accept:".md,.txt,.json,.jsonl",onChange:M,className:"hidden"}),e.jsx("svg",{className:"w-8 h-8 mx-auto text-gray-500 mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),T?e.jsx("p",{className:"text-sm text-primary-400",children:T}):e.jsx("p",{className:"text-sm text-gray-400",children:"Click to upload a file (.md, .txt, .json, .jsonl)"})]}),e.jsx("div",{className:"text-center text-sm text-gray-500",children:"or paste below"}),e.jsx("textarea",{value:j,onChange:O=>{N(O.target.value),P(null)},placeholder:x.requiresInput==="design_doc"?`# My Product
133
-
134
- ## Overview
135
- ...`:`As a user, I want to...
136
-
137
- As an admin, I want to...`,rows:8,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white placeholder-gray-400 focus:outline-none focus:border-primary-500 font-mono text-sm resize-none"}),x.requiresInput==="stories"&&e.jsx("p",{className:"text-xs text-gray-500",children:"Supports: Plain text (one story per line), Markdown lists, or JSONL format"}),u&&e.jsx("div",{className:"p-3 bg-red-900/30 border border-red-800 rounded text-sm text-red-400",children:u}),e.jsxs("div",{className:"flex justify-between pt-2",children:[e.jsx("button",{onClick:()=>y("name"),className:"px-4 py-2 text-sm text-gray-400 hover:text-white",children:"Back"}),e.jsxs("div",{className:"flex space-x-3",children:[e.jsx("button",{onClick:E,className:"px-4 py-2 text-sm text-gray-400 hover:text-white",children:"Cancel"}),e.jsx("button",{onClick:q,disabled:!j.trim()||i!==null,className:"px-4 py-2 text-sm bg-primary-600 text-white rounded hover:bg-primary-500 disabled:opacity-50 disabled:cursor-not-allowed",children:i?"Creating...":"Start Workflow"})]})]})]}),v==="creating"&&e.jsxs("div",{className:"py-8 text-center",children:[e.jsx("div",{className:"w-12 h-12 border-4 border-primary-600 border-t-transparent rounded-full animate-spin mx-auto mb-4"}),e.jsx("p",{className:"text-gray-300",children:"Creating your workflow..."}),x.requiresInput&&j&&e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Uploading resources..."})]})]})})]})}function V0({workflow:t,projectSlug:s}){const o=t.steps||[],l=o.filter(k=>k.status==="completed").length,i=o.length,d=i>0?l/i*100:0,u=o.find(k=>k.step_number===t.current_step),h=(u==null?void 0:u.step_type)==="interactive",x=o.some(k=>k.has_active_run===!0),v=t.status==="active"?x?"running":"idle":t.status,y={draft:"bg-gray-600 text-gray-200",running:"bg-green-600 text-green-100",idle:"bg-amber-600 text-amber-100",active:"bg-green-600 text-green-100",paused:"bg-yellow-600 text-yellow-100",completed:"bg-blue-600 text-blue-100",failed:"bg-red-600 text-red-100"},b={pending:e.jsx("div",{className:"w-3 h-3 rounded-full border-2 border-gray-500"}),active:e.jsx("div",{className:"w-3 h-3 rounded-full bg-green-500 animate-pulse"}),completed:e.jsx("svg",{className:"w-3 h-3 text-green-400",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),skipped:e.jsx("svg",{className:"w-3 h-3 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})};return e.jsxs(Se,{to:`/projects/${s}/workflows/${t.id}`,className:"block p-5 rounded-lg bg-gray-800 border border-gray-700 hover:border-gray-600 transition-all group",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-white group-hover:text-primary-300 transition-colors truncate",children:t.name}),e.jsxs("p",{className:"text-sm text-gray-400 mt-0.5",children:["Step ",t.current_step," of ",i]})]}),e.jsx("span",{className:`text-xs px-2 py-1 rounded ${y[v]||y.draft}`,children:v.charAt(0).toUpperCase()+v.slice(1)})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex justify-between text-xs text-gray-400 mb-1",children:[e.jsxs("span",{children:[l," of ",i," steps complete"]}),e.jsxs("span",{children:[Math.round(d),"%"]})]}),e.jsx("div",{className:"h-2 bg-gray-700 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-primary-600 to-primary-400 transition-all duration-500",style:{width:`${d}%`}})})]}),e.jsxs("div",{className:"space-y-2",children:[o.slice(0,4).map(k=>e.jsxs("div",{className:`flex items-center space-x-3 text-sm ${k.step_number===t.current_step?"text-white":k.status==="completed"?"text-gray-400":"text-gray-500"}`,children:[e.jsx("div",{className:"flex-shrink-0",children:b[k.status]||b.pending}),e.jsx("span",{className:"truncate",children:k.name}),k.step_number===t.current_step&&e.jsx("span",{className:"flex-shrink-0 text-xs px-1.5 py-0.5 rounded bg-gray-700 text-gray-300",children:k.has_active_run?"Running":h?"Interactive":"Ready"})]},k.id)),o.length>4&&e.jsxs("div",{className:"text-xs text-gray-500 pl-6",children:["+",o.length-4," more steps"]})]}),u&&t.status==="active"&&e.jsx("div",{className:"mt-4 pt-4 border-t border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-gray-400",children:h?"Continue planning...":"View progress..."}),e.jsx("svg",{className:"w-4 h-4 text-gray-500 group-hover:text-primary-400 transition-colors",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})})]})}function fj({projectSlug:t,onClose:s,onImported:o}){const[l,i]=p.useState("upload"),[d,u]=p.useState(null),[h,x]=p.useState(null),[g,v]=p.useState(!1),[y,b]=p.useState(null),k=p.useRef(null),[_,S]=p.useState(new Set),[j,N]=p.useState(new Set),[T,P]=p.useState(!0),[C,E]=p.useState(!1),[I,M]=p.useState("rename");p.useEffect(()=>{h&&(S(new Set(h.steps.map(D=>D.step_number))),N(new Set(h.resources.map(D=>D.id))))},[h]);const q=async D=>{var Y;const R=(Y=D.target.files)==null?void 0:Y[0];if(R){u(R),b(null),v(!0);try{const ie=await P0(t,R);x(ie),i("preview")}catch(ie){b(ie instanceof Error?ie.message:"Failed to read file")}finally{v(!1)}}},z=async()=>{if(d){i("importing"),b(null);try{const D={conflict_resolution:I,import_items:_.size>0,import_resources:j.size>0,import_planning:T,import_runs:C,selected_steps:Array.from(_),selected_resource_ids:Array.from(j)},R=await x2(t,d,D);o(R)}catch(D){b(D instanceof Error?D.message:"Import failed"),i("preview")}}},U=async D=>{D.preventDefault();const R=D.dataTransfer.files[0];if(R!=null&&R.name.endsWith(".zip")){u(R),b(null),v(!0);try{const Y=await P0(t,R);x(Y),i("preview")}catch(Y){b(Y instanceof Error?Y.message:"Failed to read file")}finally{v(!1)}}else b("Please drop a .ralphx.zip file")},O=D=>{S(R=>{const Y=new Set(R);return Y.has(D)?Y.delete(D):Y.add(D),Y})},X=D=>{N(R=>{const Y=new Set(R);return Y.has(D)?Y.delete(D):Y.add(D),Y})},ee=()=>{h&&(_.size===h.steps.length?S(new Set):S(new Set(h.steps.map(D=>D.step_number))))},W=()=>{h&&(j.size===h.resources.length?N(new Set):N(new Set(h.resources.map(D=>D.id))))},te=h?h.steps.filter(D=>_.has(D.step_number)).reduce((D,R)=>D+R.items_count,0):0;return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:s,onKeyDown:D=>D.key==="Escape"&&s(),role:"dialog","aria-modal":"true","aria-labelledby":"import-workflow-dialog-title",children:e.jsxs("div",{className:"card max-w-lg w-full mx-4 max-h-[90vh] overflow-y-auto",onClick:D=>D.stopPropagation(),children:[e.jsx("h3",{id:"import-workflow-dialog-title",className:"text-xl font-semibold text-white mb-4",children:"Import Workflow"}),e.jsxs("div",{className:"flex items-center justify-center mb-6 text-sm",children:[e.jsx("span",{className:`${l==="upload"?"text-cyan-400 font-medium":"text-gray-500"}`,children:"1. Upload"}),e.jsx("span",{className:"mx-2 text-gray-600",children:"→"}),e.jsx("span",{className:`${l==="preview"?"text-cyan-400 font-medium":"text-gray-500"}`,children:"2. Preview"}),e.jsx("span",{className:"mx-2 text-gray-600",children:"→"}),e.jsx("span",{className:`${l==="importing"?"text-cyan-400 font-medium":"text-gray-500"}`,children:"3. Import"})]}),y&&e.jsx("div",{className:"mb-4 p-3 rounded bg-red-900/30 border border-red-800 text-red-400 text-sm",children:y}),l==="upload"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-2 border-dashed border-gray-700 rounded-lg p-8 text-center cursor-pointer hover:border-gray-600 transition-colors",onClick:()=>{var D;return(D=k.current)==null?void 0:D.click()},onDrop:U,onDragOver:D=>D.preventDefault(),children:[e.jsx("input",{ref:k,type:"file",accept:".zip",onChange:q,className:"hidden"}),g?e.jsxs("div",{children:[e.jsx("svg",{className:"w-10 h-10 mx-auto text-cyan-400 mb-3 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),e.jsx("p",{className:"text-gray-400",children:"Reading file..."})]}):e.jsxs("div",{children:[e.jsx("svg",{className:"w-10 h-10 mx-auto text-gray-500 mb-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),e.jsx("p",{className:"text-white font-medium",children:"Drop a workflow export here"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"or click to browse"}),e.jsx("p",{className:"text-xs text-gray-600 mt-2",children:"Accepts .ralphx.zip files"})]})]}),e.jsx("div",{className:"flex justify-end mt-6",children:e.jsx("button",{onClick:s,className:"px-4 py-2 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 transition-colors",children:"Cancel"})})]}),l==="preview"&&h&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6 p-4 rounded-lg bg-gray-800/50 border border-gray-700",children:[e.jsx("h4",{className:"font-medium text-white mb-2",children:h.workflow_name}),e.jsxs("div",{className:"text-sm text-gray-400",children:[e.jsxs("span",{children:["Exported: ",new Date(h.exported_at).toLocaleDateString()]}),e.jsx("span",{className:"mx-2",children:"•"}),e.jsxs("span",{children:["RalphX ",h.ralphx_version]})]})]}),!h.is_compatible&&e.jsxs("div",{className:"mb-4 p-3 rounded bg-red-900/30 border border-red-800 text-red-400 text-sm",children:[e.jsx("strong",{children:"Compatibility Issues"}),e.jsx("ul",{className:"list-disc list-inside mt-1",children:h.compatibility_notes.map((D,R)=>e.jsx("li",{children:D},R))})]}),h.is_compatible&&h.compatibility_notes.length>0&&e.jsxs("div",{className:"mb-4 p-3 rounded bg-yellow-900/20 border border-yellow-800 text-yellow-400 text-sm",children:[e.jsx("strong",{children:"Notes"}),e.jsx("ul",{className:"list-disc list-inside mt-1",children:h.compatibility_notes.map((D,R)=>e.jsx("li",{children:D},R))})]}),h.potential_secrets_detected&&e.jsx("div",{className:"mb-4 p-3 rounded bg-yellow-900/30 border border-yellow-700 text-yellow-400 text-sm",children:e.jsxs("div",{className:"flex items-start space-x-2",children:[e.jsx("svg",{className:"w-5 h-5 flex-shrink-0 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),e.jsx("span",{children:"This export may contain secrets or credentials."})]})}),e.jsxs("div",{className:"mb-6 space-y-2",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-3",children:"Select what to import:"}),h.steps.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:_.size===h.steps.length&&h.steps.length>0,ref:D=>{D&&(D.indeterminate=_.size>0&&_.size<h.steps.length)},onChange:ee,className:"w-4 h-4 rounded border-gray-600 bg-gray-800 text-cyan-500 focus:ring-cyan-500"}),e.jsxs("span",{className:"text-gray-300",children:["Steps (",h.steps.length,")"]})]}),e.jsx("div",{className:"ml-7 space-y-1",children:h.steps.map(D=>e.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:_.has(D.step_number),onChange:()=>O(D.step_number),className:"w-4 h-4 rounded border-gray-600 bg-gray-800 text-cyan-500 focus:ring-cyan-500"}),e.jsxs("span",{className:"text-gray-400",children:[D.name," - ",e.jsxs("span",{className:"text-gray-500",children:[D.items_count," items"]})]})]},D.step_number))})]}),h.resources.length>0&&e.jsxs("div",{className:"space-y-1 mt-3",children:[e.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:j.size===h.resources.length&&h.resources.length>0,ref:D=>{D&&(D.indeterminate=j.size>0&&j.size<h.resources.length)},onChange:W,className:"w-4 h-4 rounded border-gray-600 bg-gray-800 text-cyan-500 focus:ring-cyan-500"}),e.jsxs("span",{className:"text-gray-300",children:["Resources (",h.resources.length,")"]})]}),e.jsx("div",{className:"ml-7 space-y-1",children:h.resources.map(D=>e.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:j.has(D.id),onChange:()=>X(D.id),className:"w-4 h-4 rounded border-gray-600 bg-gray-800 text-cyan-500 focus:ring-cyan-500"}),e.jsxs("span",{className:"text-gray-400",children:[D.name,e.jsxs("span",{className:"text-gray-600 text-xs ml-2",children:["(",D.resource_type,")"]})]})]},D.id))})]}),h.has_planning_session&&e.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer mt-3",children:[e.jsx("input",{type:"checkbox",checked:T,onChange:D=>P(D.target.checked),className:"w-4 h-4 rounded border-gray-600 bg-gray-800 text-cyan-500 focus:ring-cyan-500"}),e.jsx("span",{className:"text-gray-300",children:"Planning Session"})]}),h.has_runs&&e.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:C,onChange:D=>E(D.target.checked),className:"w-4 h-4 rounded border-gray-600 bg-gray-800 text-cyan-500 focus:ring-cyan-500"}),e.jsx("span",{className:"text-gray-300",children:"Execution History"})]})]}),e.jsxs("div",{className:"mb-4 text-sm text-gray-500",children:["Will import: ",_.size," step",_.size!==1?"s":""," (",te," items), ",j.size," resource",j.size!==1?"s":"",T&&h.has_planning_session?", planning session":"",C&&h.has_runs?", execution history":""]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-2",children:"If conflicts occur"}),e.jsxs("select",{value:I,onChange:D=>M(D.target.value),className:"w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-white",children:[e.jsx("option",{value:"rename",children:"Rename (add suffix)"}),e.jsx("option",{value:"skip",children:"Skip conflicting items"}),e.jsx("option",{value:"overwrite",children:"Overwrite existing"})]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("button",{onClick:()=>{i("upload"),u(null),x(null)},className:"px-4 py-2 text-gray-400 hover:text-white transition-colors",children:"Choose different file"}),e.jsxs("div",{className:"flex space-x-3",children:[e.jsx("button",{onClick:s,className:"px-4 py-2 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:z,disabled:!h.is_compatible||_.size===0&&j.size===0,className:"px-4 py-2 bg-cyan-600 text-white rounded hover:bg-cyan-500 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-2",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})}),e.jsx("span",{children:"Import as New Workflow"})]})]})]})]}),l==="importing"&&e.jsxs("div",{className:"py-8 text-center",children:[e.jsx("svg",{className:"w-12 h-12 mx-auto text-cyan-400 mb-4 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),e.jsx("p",{className:"text-white font-medium",children:"Importing workflow..."}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"This may take a moment"})]})]})})}function gj(){const{slug:t}=yr(),s=ir(),{selectedProject:o,setSelectedProject:l,setLoops:i,setLoopsLoading:d}=Tr(),[u,h]=p.useState(null),[x,g]=p.useState([]),[v,y]=p.useState([]),[b,k]=p.useState(!0),[_,S]=p.useState(!1),[j,N]=p.useState(!1),[T,P]=p.useState(!1),[C,E]=p.useState(null),I=p.useCallback(async()=>{if(t){k(!0);try{const W=await Za(t);g(W);const te=await Za(t,{archived_only:!0});y(te)}catch{g([]),y([])}finally{k(!1)}}},[t]),M=p.useCallback(async()=>{if(t){d(!0);try{const W=await qc(t),te=W.filter(R=>!R.workflow_id);S(te.length>0);const D=await Promise.all(W.map(async R=>{try{const Y=await Ih(t,R.name);return{...R,is_running:Y.is_running,current_iteration:Y.current_iteration,current_mode:Y.current_mode}}catch{return{...R,is_running:!1}}}));i(D)}catch{i([])}finally{d(!1)}}},[t,i,d]);p.useEffect(()=>{if(!t)return;l(null),g([]);async function W(){h(null);try{const te=await Vs(t);l(te)}catch(te){h(te instanceof Error?te.message:"Failed to load project")}}W(),I(),M()},[t,l,I,M]);const q=async(W,te)=>{if(!(!t||!(await rt.fire({title:"Restore Workflow?",text:`Restore "${te}" from the archive?`,icon:"question",showCancelButton:!0,confirmButtonColor:"var(--color-primary)",cancelButtonColor:"var(--color-slate)",confirmButtonText:"Restore",cancelButtonText:"Cancel",background:"var(--color-surface)",color:"var(--color-text-primary)"})).isConfirmed))try{await Fv(t,W),I()}catch(R){rt.fire({title:"Error",text:R instanceof Error?R.message:"Failed to restore workflow",icon:"error",background:"var(--color-surface)",color:"var(--color-text-primary)"})}},z=async(W,te)=>{if(!(!t||!(await rt.fire({title:"Permanently Delete?",html:`<p>This will permanently delete "<strong>${te}</strong>" and all its data.</p><p class="mt-2 text-red-400">This action cannot be undone.</p>`,icon:"warning",showCancelButton:!0,confirmButtonColor:"var(--color-rose)",cancelButtonColor:"var(--color-slate)",confirmButtonText:"Delete Forever",cancelButtonText:"Cancel",background:"var(--color-surface)",color:"var(--color-text-primary)"})).isConfirmed))try{await Dv(t,W),I()}catch(R){rt.fire({title:"Error",text:R instanceof Error?R.message:"Failed to delete workflow",icon:"error",background:"var(--color-surface)",color:"var(--color-text-primary)"})}};if(u)return e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"card bg-red-900/20 border border-red-800",children:[e.jsx("h2",{className:"text-lg font-semibold text-red-400 mb-2",children:"Error"}),e.jsx("p",{className:"text-gray-300",children:u}),e.jsx(Se,{to:"/",className:"btn-secondary mt-4 inline-block",children:"Back to Dashboard"})]})});if(!o)return e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"text-gray-400",children:"Loading project..."})});const U=x.filter(W=>W.status==="active"||W.status==="draft"||W.status==="paused"),O=x.filter(W=>W.status==="completed"),ee=!(x.length>0)&&!b;return e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[e.jsx(Se,{to:"/",className:"hover:text-white",children:"Dashboard"}),e.jsx("span",{children:"/"}),e.jsx("span",{className:"text-white",children:o.name})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-white mb-2",children:o.name}),e.jsx("p",{className:"text-gray-400",children:o.path})]}),e.jsxs(Se,{to:`/projects/${t}/settings`,className:"flex items-center space-x-2 px-4 py-2 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 transition-colors",children:[e.jsxs("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),e.jsx("span",{children:"Settings"})]})]})]}),o.stats&&e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-8",children:[e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"text-2xl font-bold text-primary-400",children:x.length}),e.jsx("div",{className:"text-sm text-gray-400",children:"Workflows"})]}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"text-2xl font-bold text-green-400",children:U.length}),e.jsx("div",{className:"text-sm text-gray-400",children:"Active"})]}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"text-2xl font-bold text-yellow-400",children:o.stats.pending_items}),e.jsx("div",{className:"text-sm text-gray-400",children:"Pending Items"})]}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"text-2xl font-bold text-blue-400",children:o.stats.completed_items}),e.jsx("div",{className:"text-sm text-gray-400",children:"Completed Items"})]})]}),ee&&e.jsx("div",{className:"mb-8 p-6 rounded-xl bg-gradient-to-br from-gray-800 to-gray-900 border border-gray-700",children:e.jsx(U0,{projectSlug:t,onWorkflowCreated:I})}),U.length>0&&e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-xl font-semibold text-white",children:"Active Workflows"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("button",{onClick:()=>P(!0),className:"flex items-center space-x-2 px-4 py-2 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 text-sm",title:"Import workflow from .ralphx.zip file",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})}),e.jsx("span",{children:"Import Workflow"})]}),e.jsxs("button",{onClick:()=>N(!0),className:"flex items-center space-x-2 px-4 py-2 bg-primary-600 text-white rounded hover:bg-primary-500 text-sm",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),e.jsx("span",{children:"New Workflow"})]})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:U.map(W=>e.jsx(V0,{workflow:W,projectSlug:t},W.id))})]}),O.length>0&&e.jsx("div",{className:"mb-8",children:e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"flex items-center justify-between cursor-pointer mb-4",children:[e.jsxs("h2",{className:"text-xl font-semibold text-white",children:["Completed Workflows",e.jsxs("span",{className:"ml-2 text-sm font-normal text-gray-400",children:["(",O.length,")"]})]}),e.jsx("svg",{className:"w-5 h-5 text-gray-400 group-open:rotate-180 transition-transform",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:O.map(W=>e.jsx(V0,{workflow:W,projectSlug:t},W.id))})]})}),v.length>0&&e.jsx("div",{className:"mb-8",children:e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"flex items-center justify-between cursor-pointer mb-4",children:[e.jsxs("h2",{className:"text-xl font-semibold text-gray-400",children:[e.jsx("svg",{className:"w-5 h-5 inline-block mr-2 -mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4"})}),"Archived",e.jsxs("span",{className:"ml-2 text-sm font-normal",children:["(",v.length,")"]})]}),e.jsx("svg",{className:"w-5 h-5 text-gray-400 group-open:rotate-180 transition-transform",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),e.jsx("div",{className:"space-y-2",children:v.map(W=>e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-gray-800/50 border border-gray-700/50",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-400 truncate",children:W.name}),e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["Archived ",W.archived_at?new Date(W.archived_at).toLocaleDateString():""]})]}),e.jsxs("div",{className:"flex items-center space-x-2 ml-4",children:[e.jsx("button",{onClick:()=>q(W.id,W.name),className:"px-3 py-1.5 text-xs font-medium text-primary-400 bg-primary-900/30 rounded hover:bg-primary-900/50 transition-colors",children:"Restore"}),e.jsx("button",{onClick:()=>z(W.id,W.name),className:"px-3 py-1.5 text-xs font-medium text-red-400 bg-red-900/30 rounded hover:bg-red-900/50 transition-colors",children:"Delete"})]})]},W.id))})]})}),_&&e.jsx("div",{className:"mb-8 p-4 rounded-lg bg-gray-800 border border-gray-700",children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("svg",{className:"w-5 h-5 text-yellow-400 flex-shrink-0 mt-0.5",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-sm font-medium text-white",children:"Legacy Loops Detected"}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"You have standalone loops that aren't part of a workflow. These can be migrated to workflows for better organization."})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Se,{to:`/projects/${t}/dashboard`,className:"p-4 rounded-lg bg-gray-800 border border-gray-700 hover:border-gray-600 transition-colors group",children:e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("svg",{className:"w-6 h-6 text-gray-400 group-hover:text-primary-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})}),e.jsx("span",{className:"text-sm text-gray-300 group-hover:text-white",children:"Project Dashboard"})]})}),e.jsx(Se,{to:`/projects/${t}/runs`,className:"p-4 rounded-lg bg-gray-800 border border-gray-700 hover:border-gray-600 transition-colors group",children:e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("svg",{className:"w-6 h-6 text-gray-400 group-hover:text-primary-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("span",{className:"text-sm text-gray-300 group-hover:text-white",children:"Run History"})]})}),e.jsx(Se,{to:`/projects/${t}/settings?tab=resources`,className:"p-4 rounded-lg bg-gray-800 border border-gray-700 hover:border-gray-600 transition-colors group",children:e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("svg",{className:"w-6 h-6 text-gray-400 group-hover:text-primary-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4"})}),e.jsx("span",{className:"text-sm text-gray-300 group-hover:text-white",children:"Shared Resources"})]})}),e.jsx(Se,{to:`/projects/${t}/settings?tab=auth`,className:"p-4 rounded-lg bg-gray-800 border border-gray-700 hover:border-gray-600 transition-colors group",children:e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("svg",{className:"w-6 h-6 text-gray-400 group-hover:text-primary-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})}),e.jsx("span",{className:"text-sm text-gray-300 group-hover:text-white",children:"Authentication"})]})})]}),j&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-gray-900 rounded-xl border border-gray-700 p-6 max-w-2xl w-full mx-4 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-xl font-semibold text-white",children:"Create New Workflow"}),e.jsx("button",{onClick:()=>N(!1),className:"text-gray-400 hover:text-white",children:e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx(U0,{projectSlug:t,onWorkflowCreated:()=>{N(!1),I()}})]})}),T&&e.jsx(fj,{projectSlug:t,onClose:()=>P(!1),onImported:W=>{E(W),P(!1),I(),s(`/projects/${t}/workflows/${W.workflow_id}`)}}),C&&e.jsx("div",{className:"fixed bottom-6 right-6 p-4 rounded-lg bg-green-900/90 border border-green-700 shadow-lg max-w-sm z-50",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-green-400 font-medium",children:"Import Complete"}),e.jsxs("p",{className:"text-sm text-gray-300 mt-1",children:['"',C.workflow_name,'" imported successfully']}),e.jsxs("p",{className:"text-xs text-gray-400 mt-1",children:[C.steps_created," steps, ",C.items_imported," items, ",C.resources_created," resources"]}),C.warnings.length>0&&e.jsxs("p",{className:"text-sm text-yellow-400 mt-1",children:[C.warnings.length," warning(s)"]})]}),e.jsx("button",{onClick:()=>E(null),className:"text-gray-400 hover:text-white ml-4",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})]})}function yj({projectSlug:t,loopName:s,loopType:o,isRunning:l,isPaused:i,onStatusChange:d}){const[u,h]=p.useState(!1),[x,g]=p.useState(null),[v,y]=p.useState(!1),[b,k]=p.useState(null),_=p.useRef(null);p.useEffect(()=>{if(!v)return;const W=te=>{_.current&&!_.current.contains(te.target)&&y(!1)};return document.addEventListener("mousedown",W),()=>document.removeEventListener("mousedown",W)},[v]);const[S,j]=p.useState(void 0),[N,T]=p.useState(void 0),[P,C]=p.useState(!0),[E,I]=p.useState(!1),[M,q]=p.useState(10);p.useEffect(()=>{if(o!=="consumer"||l)return;let W=!0;return Zy(t,s).then(te=>{W&&k(te)}).catch(()=>{W&&k(null)}),()=>{W=!1}},[t,s,o,l]);const z=async W=>{h(!0),g(null);try{await W(),d==null||d()}catch(te){g(te instanceof Error?te.message:"Action failed")}finally{h(!1)}},U=async()=>{(await rt.fire({title:"Stop Loop?",text:"This will stop the current execution. You can resume later.",icon:"warning",showCancelButton:!0,confirmButtonColor:"var(--color-rose)",cancelButtonColor:"var(--color-slate)",confirmButtonText:"Stop",cancelButtonText:"Cancel",background:"var(--color-surface)",color:"var(--color-text-primary)"})).isConfirmed&&await z(()=>ev(t,s))},O=async()=>{(await rt.fire({title:"Start Loop?",text:"This will begin executing the loop.",icon:"question",showCancelButton:!0,confirmButtonColor:"var(--color-primary)",cancelButtonColor:"var(--color-slate)",confirmButtonText:"Start",cancelButtonText:"Cancel",background:"var(--color-surface)",color:"var(--color-text-primary)"})).isConfirmed&&await z(()=>Lc(t,s))},X=async()=>{const W={};S!==void 0&&(W.phase=S),N&&(W.category=N),W.respect_dependencies=P,W.batch_mode=E,E&&(W.batch_size=M),await z(()=>Lc(t,s,W)),y(!1)},ee=o==="consumer"||(b==null?void 0:b.source_step_id);return e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[!l&&e.jsx(e.Fragment,{children:ee&&b&&b.total_items>0?e.jsxs("div",{className:"relative",ref:_,children:[e.jsxs("button",{onClick:()=>y(!v),className:"btn-primary disabled:opacity-50 flex items-center space-x-2","aria-haspopup":"true","aria-expanded":v,"aria-label":"Start loop with options",children:[e.jsx(fc,{}),e.jsx("span",{children:"Start"}),e.jsx(wj,{})]}),v&&e.jsx("div",{className:"absolute top-full left-0 mt-2 w-80 bg-gray-800 border border-gray-700 rounded-lg shadow-lg z-50 p-4",children:e.jsxs("div",{className:"space-y-4",children:[b.phases.length>0&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"phaseSelect",className:"block text-sm font-medium text-gray-300 mb-1",children:"Phase"}),e.jsxs("select",{id:"phaseSelect",value:S??"",onChange:W=>j(W.target.value?parseInt(W.target.value):void 0),className:"w-full bg-gray-700 border border-gray-600 rounded px-3 py-2 text-white text-sm",children:[e.jsx("option",{value:"",children:"All Phases"}),b.phases.map(W=>e.jsxs("option",{value:W.phase_number,children:["Phase ",W.phase_number," (",W.pending_count," pending / ",W.item_count," total)"]},W.phase_number))]})]}),b.categories.length>0&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"categorySelect",className:"block text-sm font-medium text-gray-300 mb-1",children:"Category"}),e.jsxs("select",{id:"categorySelect",value:N??"",onChange:W=>T(W.target.value||void 0),className:"w-full bg-gray-700 border border-gray-600 rounded px-3 py-2 text-white text-sm",children:[e.jsx("option",{value:"",children:"All Categories"}),b.categories.map(W=>e.jsxs("option",{value:W.name,children:[W.name.toUpperCase()," (",W.pending_count," pending / ",W.item_count," total)"]},W.name))]})]}),b.has_dependencies&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"respectDeps",checked:P,onChange:W=>C(W.target.checked),className:"rounded bg-gray-700 border-gray-600"}),e.jsx("label",{htmlFor:"respectDeps",className:"text-sm text-gray-300",children:"Respect dependency order"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"batchMode",checked:E,onChange:W=>I(W.target.checked),className:"rounded bg-gray-700 border-gray-600"}),e.jsx("label",{htmlFor:"batchMode",className:"text-sm text-gray-300",children:"Batch mode (implement multiple together)"})]}),E&&e.jsxs("div",{className:"ml-6",children:[e.jsx("label",{htmlFor:"batchSizeInput",className:"block text-xs text-gray-400 mb-1",children:"Batch size"}),e.jsx("input",{id:"batchSizeInput",type:"number",min:1,max:50,value:M,onChange:W=>q(Math.min(50,Math.max(1,parseInt(W.target.value)||10))),className:"w-20 bg-gray-700 border border-gray-600 rounded px-2 py-1 text-white text-sm"})]})]}),b.warnings&&b.warnings.length>0&&e.jsx("div",{className:"space-y-1",children:b.warnings.map((W,te)=>e.jsxs("div",{className:"text-xs text-yellow-400 flex items-start space-x-1",children:[e.jsx(bj,{}),e.jsx("span",{children:W})]},te))}),e.jsxs("div",{className:"text-xs text-gray-400 border-t border-gray-700 pt-2",children:[b.total_items," total items",b.workflow_id&&` from workflow ${b.workflow_id.slice(0,8)}`,b.graph_stats.items_with_dependencies>0&&e.jsxs("span",{children:[" | ",b.graph_stats.items_with_dependencies," with dependencies"]})]}),e.jsxs("div",{className:"flex justify-end space-x-2 pt-2 border-t border-gray-700",children:[e.jsx("button",{onClick:()=>y(!1),className:"px-3 py-1.5 text-sm text-gray-400 hover:text-white",children:"Cancel"}),e.jsx("button",{onClick:X,disabled:u,className:"px-4 py-1.5 text-sm bg-green-600 hover:bg-green-700 text-white rounded disabled:opacity-50",children:u?"Starting...":"Start Loop"})]})]})})]}):e.jsxs("button",{onClick:O,disabled:u,className:"btn-primary disabled:opacity-50 flex items-center space-x-2",children:[e.jsx(fc,{}),e.jsx("span",{children:"Start"})]})}),l&&!i&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>z(()=>tv(t,s)),disabled:u,className:"btn-secondary disabled:opacity-50 flex items-center space-x-2",children:[e.jsx(vj,{}),e.jsx("span",{children:"Pause"})]}),e.jsxs("button",{onClick:U,disabled:u,className:"btn-danger disabled:opacity-50 flex items-center space-x-2",children:[e.jsx(q0,{}),e.jsx("span",{children:"Stop"})]})]}),l&&i&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>z(()=>rv(t,s)),disabled:u,className:"btn-primary disabled:opacity-50 flex items-center space-x-2",children:[e.jsx(fc,{}),e.jsx("span",{children:"Resume"})]}),e.jsxs("button",{onClick:U,disabled:u,className:"btn-danger disabled:opacity-50 flex items-center space-x-2",children:[e.jsx(q0,{}),e.jsx("span",{children:"Stop"})]})]}),u&&e.jsx("span",{className:"text-sm text-gray-400 animate-pulse",children:"Processing..."})]}),x&&e.jsx("div",{className:"mt-2 text-sm text-red-400",role:"alert",children:x})]})}function fc(){return e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM9.555 7.168A1 1 0 008 8v4a1 1 0 001.555.832l3-2a1 1 0 000-1.664l-3-2z",clipRule:"evenodd"})})}function vj(){return e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zM7 8a1 1 0 012 0v4a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v4a1 1 0 102 0V8a1 1 0 00-1-1z",clipRule:"evenodd"})})}function q0(){return e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8 7a1 1 0 00-1 1v4a1 1 0 001 1h4a1 1 0 001-1V8a1 1 0 00-1-1H8z",clipRule:"evenodd"})})}function wj(){return e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})})}function bj(){return e.jsx("svg",{className:"w-4 h-4 flex-shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})}function jj({value:t,max:s=100,label:o,showPercent:l=!1,size:i="md",color:d="primary"}){const u=Math.min(100,Math.max(0,t/s*100)),h={sm:"h-1",md:"h-2",lg:"h-3"},x={primary:"bg-primary-500",green:"bg-green-500",yellow:"bg-yellow-500",red:"bg-red-500"};return e.jsxs("div",{className:"w-full",children:[(o||l)&&e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[o&&e.jsx("span",{className:"text-xs text-gray-400",children:o}),l&&e.jsxs("span",{className:"text-xs text-gray-400",children:[Math.round(u),"%"]})]}),e.jsx("div",{className:`w-full bg-gray-700 rounded-full overflow-hidden ${h[i]}`,children:e.jsx("div",{className:`${h[i]} ${x[d]} rounded-full transition-all duration-300`,style:{width:`${u}%`}})})]})}function Fp({url:t,enabled:s=!0,onEvent:o,onError:l,onOpen:i,retryInterval:d=3e3,maxRetries:u=5,maxStoredEvents:h=1e3}){const[x,g]=p.useState([]),[v,y]=p.useState(!1),[b,k]=p.useState(null),_=p.useRef(null),S=p.useRef(0),j=p.useRef(null),N=p.useCallback(()=>{g([])},[]),T=p.useCallback(()=>{j.current&&(clearTimeout(j.current),j.current=null),_.current&&(_.current.close(),_.current=null),y(!1)},[]),P=p.useCallback(()=>{T(),k(null);try{const C=new EventSource(t);_.current=C,C.onopen=()=>{y(!0),k(null),S.current=0,i==null||i()},C.onerror=I=>{y(!1),l==null||l(I),S.current<u?(S.current+=1,k(`Connection lost. Retrying (${S.current}/${u})...`),j.current=setTimeout(P,d)):(k("Connection failed after maximum retries"),C.close())},["connected","status","text","tool_call","tool_result","init","complete","error","heartbeat","info","session_start","disconnected"].forEach(I=>{C.addEventListener(I,M=>{try{const q=JSON.parse(M.data),z={type:I,data:q,timestamp:new Date};g(U=>{const O=[...U,z];return O.length>h?O.slice(-h):O}),o==null||o(z)}catch{}})})}catch(C){k(C instanceof Error?C.message:"Failed to connect")}},[t,T,i,l,o,u,d,h]);return p.useEffect(()=>(s?P():T(),()=>{T()}),[s,P,T]),{events:x,isConnected:v,error:b,connect:P,disconnect:T,clearEvents:N}}function Wp({projectSlug:t,loopName:s,sessionId:o,enabled:l=!0,maxEvents:i=500}){const[d,u]=p.useState(!0),[h,x]=p.useState(!1),g=p.useRef(null);let v=`/api/projects/${t}`;o?v+=`/sessions/${o}/tail`:s?v+=`/loops/${s}/stream`:v="";const{events:y,isConnected:b,error:k,connect:_,disconnect:S,clearEvents:j}=Fp({url:v,enabled:l&&!h&&!!v});p.useEffect(()=>{d&&g.current&&(g.current.scrollTop=g.current.scrollHeight)},[y,d]);const N=y.slice(-i),T=()=>{h?(x(!1),_()):(x(!0),S())},[P,C]=p.useState("idle"),E=async()=>{const I=N.map(M=>Cj(M)).join(`
138
- `);try{await navigator.clipboard.writeText(I),C("success"),setTimeout(()=>C("idle"),2e3)}catch{C("error"),setTimeout(()=>C("idle"),2e3)}};return v?e.jsxs("div",{className:"card flex flex-col h-[500px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:"Live Output"}),e.jsx(Nj,{isConnected:b,isPaused:h})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>u(!d),className:`px-3 py-1 text-sm rounded ${d?"bg-primary-600 text-white":"bg-gray-700 text-gray-300"}`,children:"Auto-scroll"}),e.jsx("button",{onClick:T,className:`px-3 py-1 text-sm rounded ${h?"bg-yellow-600 text-white":"bg-gray-700 text-gray-300"}`,children:h?"Resume":"Pause"}),e.jsx("button",{onClick:E,className:`px-3 py-1 text-sm rounded ${P==="success"?"bg-green-700 text-green-200":P==="error"?"bg-red-700 text-red-200":"bg-gray-700 text-gray-300 hover:bg-gray-600"}`,children:P==="success"?"Copied!":P==="error"?"Failed":"Copy"}),e.jsx("button",{onClick:j,className:"px-3 py-1 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600",children:"Clear"})]})]}),k&&e.jsx("div",{className:"mb-2 px-3 py-2 bg-red-900/30 border border-red-800 rounded text-sm text-red-400 flex-shrink-0",children:k}),e.jsx("div",{ref:g,className:"flex-1 overflow-auto bg-gray-900 rounded font-mono text-sm",children:N.length===0?e.jsx("div",{className:"p-4 text-gray-500 text-center",children:b?"Waiting for events...":"Not connected"}):e.jsx("div",{className:"p-2 space-y-1",children:N.map((I,M)=>e.jsx(kj,{event:I},M))})}),e.jsxs("div",{className:"mt-2 text-xs text-gray-500 flex-shrink-0",children:[N.length," events",y.length>i&&` (${y.length-i} truncated)`]})]}):e.jsx("div",{className:"card text-center py-8",children:e.jsx("p",{className:"text-gray-400",children:"No session or loop specified"})})}function Nj({isConnected:t,isPaused:s}){return s?e.jsxs("span",{className:"flex items-center space-x-1.5 text-sm text-yellow-400",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-yellow-400"}),e.jsx("span",{children:"Paused"})]}):e.jsxs("span",{className:`flex items-center space-x-1.5 text-sm ${t?"text-green-400":"text-gray-400"}`,children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${t?"bg-green-400 animate-pulse":"bg-gray-500"}`}),e.jsx("span",{children:t?"Connected":"Disconnected"})]})}function kj({event:t}){const s=t.timestamp.toLocaleTimeString();switch(t.type){case"text":return e.jsxs("div",{className:"text-gray-200 whitespace-pre-wrap",children:[e.jsx("span",{className:"text-gray-500 mr-2",children:s}),String(t.data.content||"")]});case"tool_call":return e.jsxs("div",{className:"text-blue-400",children:[e.jsx("span",{className:"text-gray-500 mr-2",children:s}),e.jsx("span",{className:"font-semibold",children:"Tool:"})," ",String(t.data.name||"unknown"),t.data.input?e.jsxs("span",{className:"text-gray-400 ml-2",children:[JSON.stringify(t.data.input).slice(0,100),"..."]}):null]});case"tool_result":return e.jsxs("div",{className:"text-green-400",children:[e.jsx("span",{className:"text-gray-500 mr-2",children:s}),e.jsx("span",{className:"font-semibold",children:"Result:"})," ",String(t.data.result||"").slice(0,200),String(t.data.result||"").length>200&&"..."]});case"error":return e.jsxs("div",{className:"text-red-400",children:[e.jsx("span",{className:"text-gray-500 mr-2",children:s}),e.jsx("span",{className:"font-semibold",children:"Error:"})," ",String(t.data.message||"Unknown error")]});case"status":return e.jsxs("div",{className:"text-yellow-400",children:[e.jsx("span",{className:"text-gray-500 mr-2",children:s}),e.jsx("span",{className:"font-semibold",children:"Status:"})," ",String(t.data.status||""),t.data.iteration?` (iteration ${String(t.data.iteration)})`:null]});case"connected":case"session_start":return e.jsxs("div",{className:"text-primary-400",children:[e.jsx("span",{className:"text-gray-500 mr-2",children:s}),e.jsx("span",{className:"font-semibold",children:"Connected"})]});case"complete":return e.jsxs("div",{className:"text-green-400 font-semibold",children:[e.jsx("span",{className:"text-gray-500 mr-2",children:s}),"Session Complete"]});case"heartbeat":return null;case"info":return e.jsxs("div",{className:"text-gray-400",children:[e.jsx("span",{className:"text-gray-500 mr-2",children:s}),String(t.data.message||"")]});default:return e.jsxs("div",{className:"text-gray-500",children:[e.jsx("span",{className:"mr-2",children:s}),"[",t.type,"] ",JSON.stringify(t.data).slice(0,100)]})}}function Cj(t){const s=t.timestamp.toISOString();switch(t.type){case"text":return`[${s}] ${t.data.content}`;case"tool_call":return`[${s}] Tool: ${t.data.name}`;case"tool_result":return`[${s}] Result: ${String(t.data.result).slice(0,500)}`;case"error":return`[${s}] Error: ${t.data.message}`;default:return`[${s}] [${t.type}] ${JSON.stringify(t.data)}`}}/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function zp(t){return typeof t>"u"||t===null}function Sj(t){return typeof t=="object"&&t!==null}function _j(t){return Array.isArray(t)?t:zp(t)?[]:[t]}function Lj(t,s){var o,l,i,d;if(s)for(d=Object.keys(s),o=0,l=d.length;o<l;o+=1)i=d[o],t[i]=s[i];return t}function Ej(t,s){var o="",l;for(l=0;l<s;l+=1)o+=t;return o}function Tj(t){return t===0&&Number.NEGATIVE_INFINITY===1/t}var Aj=zp,Pj=Sj,Mj=_j,Rj=Ej,Ij=Tj,$j=Lj,pt={isNothing:Aj,isObject:Pj,toArray:Mj,repeat:Rj,isNegativeZero:Ij,extend:$j};function Hp(t,s){var o="",l=t.reason||"(unknown reason)";return t.mark?(t.mark.name&&(o+='in "'+t.mark.name+'" '),o+="("+(t.mark.line+1)+":"+(t.mark.column+1)+")",!s&&t.mark.snippet&&(o+=`
139
-
140
- `+t.mark.snippet),l+" "+o):l}function _o(t,s){Error.call(this),this.name="YAMLException",this.reason=t,this.mark=s,this.message=Hp(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}_o.prototype=Object.create(Error.prototype);_o.prototype.constructor=_o;_o.prototype.toString=function(s){return this.name+": "+Hp(this,s)};var It=_o;function gc(t,s,o,l,i){var d="",u="",h=Math.floor(i/2)-1;return l-s>h&&(d=" ... ",s=l-h+d.length),o-l>h&&(u=" ...",o=l+h-u.length),{str:d+t.slice(s,o).replace(/\t/g,"→")+u,pos:l-s+d.length}}function yc(t,s){return pt.repeat(" ",s-t.length)+t}function Bj(t,s){if(s=Object.create(s||null),!t.buffer)return null;s.maxLength||(s.maxLength=79),typeof s.indent!="number"&&(s.indent=1),typeof s.linesBefore!="number"&&(s.linesBefore=3),typeof s.linesAfter!="number"&&(s.linesAfter=2);for(var o=/\r?\n|\r|\0/g,l=[0],i=[],d,u=-1;d=o.exec(t.buffer);)i.push(d.index),l.push(d.index+d[0].length),t.position<=d.index&&u<0&&(u=l.length-2);u<0&&(u=l.length-1);var h="",x,g,v=Math.min(t.line+s.linesAfter,i.length).toString().length,y=s.maxLength-(s.indent+v+3);for(x=1;x<=s.linesBefore&&!(u-x<0);x++)g=gc(t.buffer,l[u-x],i[u-x],t.position-(l[u]-l[u-x]),y),h=pt.repeat(" ",s.indent)+yc((t.line-x+1).toString(),v)+" | "+g.str+`
141
- `+h;for(g=gc(t.buffer,l[u],i[u],t.position,y),h+=pt.repeat(" ",s.indent)+yc((t.line+1).toString(),v)+" | "+g.str+`
142
- `,h+=pt.repeat("-",s.indent+v+3+g.pos)+`^
143
- `,x=1;x<=s.linesAfter&&!(u+x>=i.length);x++)g=gc(t.buffer,l[u+x],i[u+x],t.position-(l[u]-l[u+x]),y),h+=pt.repeat(" ",s.indent)+yc((t.line+x+1).toString(),v)+" | "+g.str+`
144
- `;return h.replace(/\n$/,"")}var Dj=Bj,Oj=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Fj=["scalar","sequence","mapping"];function Wj(t){var s={};return t!==null&&Object.keys(t).forEach(function(o){t[o].forEach(function(l){s[String(l)]=o})}),s}function zj(t,s){if(s=s||{},Object.keys(s).forEach(function(o){if(Oj.indexOf(o)===-1)throw new It('Unknown option "'+o+'" is met in definition of "'+t+'" YAML type.')}),this.options=s,this.tag=t,this.kind=s.kind||null,this.resolve=s.resolve||function(){return!0},this.construct=s.construct||function(o){return o},this.instanceOf=s.instanceOf||null,this.predicate=s.predicate||null,this.represent=s.represent||null,this.representName=s.representName||null,this.defaultStyle=s.defaultStyle||null,this.multi=s.multi||!1,this.styleAliases=Wj(s.styleAliases||null),Fj.indexOf(this.kind)===-1)throw new It('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')}var Ct=zj;function Y0(t,s){var o=[];return t[s].forEach(function(l){var i=o.length;o.forEach(function(d,u){d.tag===l.tag&&d.kind===l.kind&&d.multi===l.multi&&(i=u)}),o[i]=l}),o}function Hj(){var t={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},s,o;function l(i){i.multi?(t.multi[i.kind].push(i),t.multi.fallback.push(i)):t[i.kind][i.tag]=t.fallback[i.tag]=i}for(s=0,o=arguments.length;s<o;s+=1)arguments[s].forEach(l);return t}function Ic(t){return this.extend(t)}Ic.prototype.extend=function(s){var o=[],l=[];if(s instanceof Ct)l.push(s);else if(Array.isArray(s))l=l.concat(s);else if(s&&(Array.isArray(s.implicit)||Array.isArray(s.explicit)))s.implicit&&(o=o.concat(s.implicit)),s.explicit&&(l=l.concat(s.explicit));else throw new It("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");o.forEach(function(d){if(!(d instanceof Ct))throw new It("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(d.loadKind&&d.loadKind!=="scalar")throw new It("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(d.multi)throw new It("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),l.forEach(function(d){if(!(d instanceof Ct))throw new It("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var i=Object.create(Ic.prototype);return i.implicit=(this.implicit||[]).concat(o),i.explicit=(this.explicit||[]).concat(l),i.compiledImplicit=Y0(i,"implicit"),i.compiledExplicit=Y0(i,"explicit"),i.compiledTypeMap=Hj(i.compiledImplicit,i.compiledExplicit),i};var Up=Ic,Vp=new Ct("tag:yaml.org,2002:str",{kind:"scalar",construct:function(t){return t!==null?t:""}}),qp=new Ct("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(t){return t!==null?t:[]}}),Yp=new Ct("tag:yaml.org,2002:map",{kind:"mapping",construct:function(t){return t!==null?t:{}}}),Gp=new Up({explicit:[Vp,qp,Yp]});function Uj(t){if(t===null)return!0;var s=t.length;return s===1&&t==="~"||s===4&&(t==="null"||t==="Null"||t==="NULL")}function Vj(){return null}function qj(t){return t===null}var Kp=new Ct("tag:yaml.org,2002:null",{kind:"scalar",resolve:Uj,construct:Vj,predicate:qj,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function Yj(t){if(t===null)return!1;var s=t.length;return s===4&&(t==="true"||t==="True"||t==="TRUE")||s===5&&(t==="false"||t==="False"||t==="FALSE")}function Gj(t){return t==="true"||t==="True"||t==="TRUE"}function Kj(t){return Object.prototype.toString.call(t)==="[object Boolean]"}var Jp=new Ct("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Yj,construct:Gj,predicate:Kj,represent:{lowercase:function(t){return t?"true":"false"},uppercase:function(t){return t?"TRUE":"FALSE"},camelcase:function(t){return t?"True":"False"}},defaultStyle:"lowercase"});function Jj(t){return 48<=t&&t<=57||65<=t&&t<=70||97<=t&&t<=102}function Qj(t){return 48<=t&&t<=55}function Xj(t){return 48<=t&&t<=57}function Zj(t){if(t===null)return!1;var s=t.length,o=0,l=!1,i;if(!s)return!1;if(i=t[o],(i==="-"||i==="+")&&(i=t[++o]),i==="0"){if(o+1===s)return!0;if(i=t[++o],i==="b"){for(o++;o<s;o++)if(i=t[o],i!=="_"){if(i!=="0"&&i!=="1")return!1;l=!0}return l&&i!=="_"}if(i==="x"){for(o++;o<s;o++)if(i=t[o],i!=="_"){if(!Jj(t.charCodeAt(o)))return!1;l=!0}return l&&i!=="_"}if(i==="o"){for(o++;o<s;o++)if(i=t[o],i!=="_"){if(!Qj(t.charCodeAt(o)))return!1;l=!0}return l&&i!=="_"}}if(i==="_")return!1;for(;o<s;o++)if(i=t[o],i!=="_"){if(!Xj(t.charCodeAt(o)))return!1;l=!0}return!(!l||i==="_")}function e1(t){var s=t,o=1,l;if(s.indexOf("_")!==-1&&(s=s.replace(/_/g,"")),l=s[0],(l==="-"||l==="+")&&(l==="-"&&(o=-1),s=s.slice(1),l=s[0]),s==="0")return 0;if(l==="0"){if(s[1]==="b")return o*parseInt(s.slice(2),2);if(s[1]==="x")return o*parseInt(s.slice(2),16);if(s[1]==="o")return o*parseInt(s.slice(2),8)}return o*parseInt(s,10)}function t1(t){return Object.prototype.toString.call(t)==="[object Number]"&&t%1===0&&!pt.isNegativeZero(t)}var Qp=new Ct("tag:yaml.org,2002:int",{kind:"scalar",resolve:Zj,construct:e1,predicate:t1,represent:{binary:function(t){return t>=0?"0b"+t.toString(2):"-0b"+t.toString(2).slice(1)},octal:function(t){return t>=0?"0o"+t.toString(8):"-0o"+t.toString(8).slice(1)},decimal:function(t){return t.toString(10)},hexadecimal:function(t){return t>=0?"0x"+t.toString(16).toUpperCase():"-0x"+t.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),r1=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s1(t){return!(t===null||!r1.test(t)||t[t.length-1]==="_")}function n1(t){var s,o;return s=t.replace(/_/g,"").toLowerCase(),o=s[0]==="-"?-1:1,"+-".indexOf(s[0])>=0&&(s=s.slice(1)),s===".inf"?o===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:s===".nan"?NaN:o*parseFloat(s,10)}var o1=/^[-+]?[0-9]+e/;function a1(t,s){var o;if(isNaN(t))switch(s){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(s){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(s){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(pt.isNegativeZero(t))return"-0.0";return o=t.toString(10),o1.test(o)?o.replace("e",".e"):o}function l1(t){return Object.prototype.toString.call(t)==="[object Number]"&&(t%1!==0||pt.isNegativeZero(t))}var Xp=new Ct("tag:yaml.org,2002:float",{kind:"scalar",resolve:s1,construct:n1,predicate:l1,represent:a1,defaultStyle:"lowercase"}),Zp=Gp.extend({implicit:[Kp,Jp,Qp,Xp]}),ex=Zp,tx=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),rx=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function i1(t){return t===null?!1:tx.exec(t)!==null||rx.exec(t)!==null}function c1(t){var s,o,l,i,d,u,h,x=0,g=null,v,y,b;if(s=tx.exec(t),s===null&&(s=rx.exec(t)),s===null)throw new Error("Date resolve error");if(o=+s[1],l=+s[2]-1,i=+s[3],!s[4])return new Date(Date.UTC(o,l,i));if(d=+s[4],u=+s[5],h=+s[6],s[7]){for(x=s[7].slice(0,3);x.length<3;)x+="0";x=+x}return s[9]&&(v=+s[10],y=+(s[11]||0),g=(v*60+y)*6e4,s[9]==="-"&&(g=-g)),b=new Date(Date.UTC(o,l,i,d,u,h,x)),g&&b.setTime(b.getTime()-g),b}function d1(t){return t.toISOString()}var sx=new Ct("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:i1,construct:c1,instanceOf:Date,represent:d1});function u1(t){return t==="<<"||t===null}var nx=new Ct("tag:yaml.org,2002:merge",{kind:"scalar",resolve:u1}),fd=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
145
- \r`;function m1(t){if(t===null)return!1;var s,o,l=0,i=t.length,d=fd;for(o=0;o<i;o++)if(s=d.indexOf(t.charAt(o)),!(s>64)){if(s<0)return!1;l+=6}return l%8===0}function h1(t){var s,o,l=t.replace(/[\r\n=]/g,""),i=l.length,d=fd,u=0,h=[];for(s=0;s<i;s++)s%4===0&&s&&(h.push(u>>16&255),h.push(u>>8&255),h.push(u&255)),u=u<<6|d.indexOf(l.charAt(s));return o=i%4*6,o===0?(h.push(u>>16&255),h.push(u>>8&255),h.push(u&255)):o===18?(h.push(u>>10&255),h.push(u>>2&255)):o===12&&h.push(u>>4&255),new Uint8Array(h)}function p1(t){var s="",o=0,l,i,d=t.length,u=fd;for(l=0;l<d;l++)l%3===0&&l&&(s+=u[o>>18&63],s+=u[o>>12&63],s+=u[o>>6&63],s+=u[o&63]),o=(o<<8)+t[l];return i=d%3,i===0?(s+=u[o>>18&63],s+=u[o>>12&63],s+=u[o>>6&63],s+=u[o&63]):i===2?(s+=u[o>>10&63],s+=u[o>>4&63],s+=u[o<<2&63],s+=u[64]):i===1&&(s+=u[o>>2&63],s+=u[o<<4&63],s+=u[64],s+=u[64]),s}function x1(t){return Object.prototype.toString.call(t)==="[object Uint8Array]"}var ox=new Ct("tag:yaml.org,2002:binary",{kind:"scalar",resolve:m1,construct:h1,predicate:x1,represent:p1}),f1=Object.prototype.hasOwnProperty,g1=Object.prototype.toString;function y1(t){if(t===null)return!0;var s=[],o,l,i,d,u,h=t;for(o=0,l=h.length;o<l;o+=1){if(i=h[o],u=!1,g1.call(i)!=="[object Object]")return!1;for(d in i)if(f1.call(i,d))if(!u)u=!0;else return!1;if(!u)return!1;if(s.indexOf(d)===-1)s.push(d);else return!1}return!0}function v1(t){return t!==null?t:[]}var ax=new Ct("tag:yaml.org,2002:omap",{kind:"sequence",resolve:y1,construct:v1}),w1=Object.prototype.toString;function b1(t){if(t===null)return!0;var s,o,l,i,d,u=t;for(d=new Array(u.length),s=0,o=u.length;s<o;s+=1){if(l=u[s],w1.call(l)!=="[object Object]"||(i=Object.keys(l),i.length!==1))return!1;d[s]=[i[0],l[i[0]]]}return!0}function j1(t){if(t===null)return[];var s,o,l,i,d,u=t;for(d=new Array(u.length),s=0,o=u.length;s<o;s+=1)l=u[s],i=Object.keys(l),d[s]=[i[0],l[i[0]]];return d}var lx=new Ct("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:b1,construct:j1}),N1=Object.prototype.hasOwnProperty;function k1(t){if(t===null)return!0;var s,o=t;for(s in o)if(N1.call(o,s)&&o[s]!==null)return!1;return!0}function C1(t){return t!==null?t:{}}var ix=new Ct("tag:yaml.org,2002:set",{kind:"mapping",resolve:k1,construct:C1}),gd=ex.extend({implicit:[sx,nx],explicit:[ox,ax,lx,ix]}),vs=Object.prototype.hasOwnProperty,cl=1,cx=2,dx=3,dl=4,vc=1,S1=2,G0=3,_1=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,L1=/[\x85\u2028\u2029]/,E1=/[,\[\]\{\}]/,ux=/^(?:!|!!|![a-z\-]+!)$/i,mx=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function K0(t){return Object.prototype.toString.call(t)}function _r(t){return t===10||t===13}function Ws(t){return t===9||t===32}function Vt(t){return t===9||t===32||t===10||t===13}function jn(t){return t===44||t===91||t===93||t===123||t===125}function T1(t){var s;return 48<=t&&t<=57?t-48:(s=t|32,97<=s&&s<=102?s-97+10:-1)}function A1(t){return t===120?2:t===117?4:t===85?8:0}function P1(t){return 48<=t&&t<=57?t-48:-1}function J0(t){return t===48?"\0":t===97?"\x07":t===98?"\b":t===116||t===9?" ":t===110?`
146
- `:t===118?"\v":t===102?"\f":t===114?"\r":t===101?"\x1B":t===32?" ":t===34?'"':t===47?"/":t===92?"\\":t===78?"…":t===95?" ":t===76?"\u2028":t===80?"\u2029":""}function M1(t){return t<=65535?String.fromCharCode(t):String.fromCharCode((t-65536>>10)+55296,(t-65536&1023)+56320)}function hx(t,s,o){s==="__proto__"?Object.defineProperty(t,s,{configurable:!0,enumerable:!0,writable:!0,value:o}):t[s]=o}var px=new Array(256),xx=new Array(256);for(var yn=0;yn<256;yn++)px[yn]=J0(yn)?1:0,xx[yn]=J0(yn);function R1(t,s){this.input=t,this.filename=s.filename||null,this.schema=s.schema||gd,this.onWarning=s.onWarning||null,this.legacy=s.legacy||!1,this.json=s.json||!1,this.listener=s.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=t.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function fx(t,s){var o={name:t.filename,buffer:t.input.slice(0,-1),position:t.position,line:t.line,column:t.position-t.lineStart};return o.snippet=Dj(o),new It(s,o)}function je(t,s){throw fx(t,s)}function ul(t,s){t.onWarning&&t.onWarning.call(null,fx(t,s))}var Q0={YAML:function(s,o,l){var i,d,u;s.version!==null&&je(s,"duplication of %YAML directive"),l.length!==1&&je(s,"YAML directive accepts exactly one argument"),i=/^([0-9]+)\.([0-9]+)$/.exec(l[0]),i===null&&je(s,"ill-formed argument of the YAML directive"),d=parseInt(i[1],10),u=parseInt(i[2],10),d!==1&&je(s,"unacceptable YAML version of the document"),s.version=l[0],s.checkLineBreaks=u<2,u!==1&&u!==2&&ul(s,"unsupported YAML version of the document")},TAG:function(s,o,l){var i,d;l.length!==2&&je(s,"TAG directive accepts exactly two arguments"),i=l[0],d=l[1],ux.test(i)||je(s,"ill-formed tag handle (first argument) of the TAG directive"),vs.call(s.tagMap,i)&&je(s,'there is a previously declared suffix for "'+i+'" tag handle'),mx.test(d)||je(s,"ill-formed tag prefix (second argument) of the TAG directive");try{d=decodeURIComponent(d)}catch{je(s,"tag prefix is malformed: "+d)}s.tagMap[i]=d}};function ys(t,s,o,l){var i,d,u,h;if(s<o){if(h=t.input.slice(s,o),l)for(i=0,d=h.length;i<d;i+=1)u=h.charCodeAt(i),u===9||32<=u&&u<=1114111||je(t,"expected valid JSON character");else _1.test(h)&&je(t,"the stream contains non-printable characters");t.result+=h}}function X0(t,s,o,l){var i,d,u,h;for(pt.isObject(o)||je(t,"cannot merge mappings; the provided source object is unacceptable"),i=Object.keys(o),u=0,h=i.length;u<h;u+=1)d=i[u],vs.call(s,d)||(hx(s,d,o[d]),l[d]=!0)}function Nn(t,s,o,l,i,d,u,h,x){var g,v;if(Array.isArray(i))for(i=Array.prototype.slice.call(i),g=0,v=i.length;g<v;g+=1)Array.isArray(i[g])&&je(t,"nested arrays are not supported inside keys"),typeof i=="object"&&K0(i[g])==="[object Object]"&&(i[g]="[object Object]");if(typeof i=="object"&&K0(i)==="[object Object]"&&(i="[object Object]"),i=String(i),s===null&&(s={}),l==="tag:yaml.org,2002:merge")if(Array.isArray(d))for(g=0,v=d.length;g<v;g+=1)X0(t,s,d[g],o);else X0(t,s,d,o);else!t.json&&!vs.call(o,i)&&vs.call(s,i)&&(t.line=u||t.line,t.lineStart=h||t.lineStart,t.position=x||t.position,je(t,"duplicated mapping key")),hx(s,i,d),delete o[i];return s}function yd(t){var s;s=t.input.charCodeAt(t.position),s===10?t.position++:s===13?(t.position++,t.input.charCodeAt(t.position)===10&&t.position++):je(t,"a line break is expected"),t.line+=1,t.lineStart=t.position,t.firstTabInLine=-1}function ct(t,s,o){for(var l=0,i=t.input.charCodeAt(t.position);i!==0;){for(;Ws(i);)i===9&&t.firstTabInLine===-1&&(t.firstTabInLine=t.position),i=t.input.charCodeAt(++t.position);if(s&&i===35)do i=t.input.charCodeAt(++t.position);while(i!==10&&i!==13&&i!==0);if(_r(i))for(yd(t),i=t.input.charCodeAt(t.position),l++,t.lineIndent=0;i===32;)t.lineIndent++,i=t.input.charCodeAt(++t.position);else break}return o!==-1&&l!==0&&t.lineIndent<o&&ul(t,"deficient indentation"),l}function jl(t){var s=t.position,o;return o=t.input.charCodeAt(s),!!((o===45||o===46)&&o===t.input.charCodeAt(s+1)&&o===t.input.charCodeAt(s+2)&&(s+=3,o=t.input.charCodeAt(s),o===0||Vt(o)))}function vd(t,s){s===1?t.result+=" ":s>1&&(t.result+=pt.repeat(`
147
- `,s-1))}function I1(t,s,o){var l,i,d,u,h,x,g,v,y=t.kind,b=t.result,k;if(k=t.input.charCodeAt(t.position),Vt(k)||jn(k)||k===35||k===38||k===42||k===33||k===124||k===62||k===39||k===34||k===37||k===64||k===96||(k===63||k===45)&&(i=t.input.charCodeAt(t.position+1),Vt(i)||o&&jn(i)))return!1;for(t.kind="scalar",t.result="",d=u=t.position,h=!1;k!==0;){if(k===58){if(i=t.input.charCodeAt(t.position+1),Vt(i)||o&&jn(i))break}else if(k===35){if(l=t.input.charCodeAt(t.position-1),Vt(l))break}else{if(t.position===t.lineStart&&jl(t)||o&&jn(k))break;if(_r(k))if(x=t.line,g=t.lineStart,v=t.lineIndent,ct(t,!1,-1),t.lineIndent>=s){h=!0,k=t.input.charCodeAt(t.position);continue}else{t.position=u,t.line=x,t.lineStart=g,t.lineIndent=v;break}}h&&(ys(t,d,u,!1),vd(t,t.line-x),d=u=t.position,h=!1),Ws(k)||(u=t.position+1),k=t.input.charCodeAt(++t.position)}return ys(t,d,u,!1),t.result?!0:(t.kind=y,t.result=b,!1)}function $1(t,s){var o,l,i;if(o=t.input.charCodeAt(t.position),o!==39)return!1;for(t.kind="scalar",t.result="",t.position++,l=i=t.position;(o=t.input.charCodeAt(t.position))!==0;)if(o===39)if(ys(t,l,t.position,!0),o=t.input.charCodeAt(++t.position),o===39)l=t.position,t.position++,i=t.position;else return!0;else _r(o)?(ys(t,l,i,!0),vd(t,ct(t,!1,s)),l=i=t.position):t.position===t.lineStart&&jl(t)?je(t,"unexpected end of the document within a single quoted scalar"):(t.position++,i=t.position);je(t,"unexpected end of the stream within a single quoted scalar")}function B1(t,s){var o,l,i,d,u,h;if(h=t.input.charCodeAt(t.position),h!==34)return!1;for(t.kind="scalar",t.result="",t.position++,o=l=t.position;(h=t.input.charCodeAt(t.position))!==0;){if(h===34)return ys(t,o,t.position,!0),t.position++,!0;if(h===92){if(ys(t,o,t.position,!0),h=t.input.charCodeAt(++t.position),_r(h))ct(t,!1,s);else if(h<256&&px[h])t.result+=xx[h],t.position++;else if((u=A1(h))>0){for(i=u,d=0;i>0;i--)h=t.input.charCodeAt(++t.position),(u=T1(h))>=0?d=(d<<4)+u:je(t,"expected hexadecimal character");t.result+=M1(d),t.position++}else je(t,"unknown escape sequence");o=l=t.position}else _r(h)?(ys(t,o,l,!0),vd(t,ct(t,!1,s)),o=l=t.position):t.position===t.lineStart&&jl(t)?je(t,"unexpected end of the document within a double quoted scalar"):(t.position++,l=t.position)}je(t,"unexpected end of the stream within a double quoted scalar")}function D1(t,s){var o=!0,l,i,d,u=t.tag,h,x=t.anchor,g,v,y,b,k,_=Object.create(null),S,j,N,T;if(T=t.input.charCodeAt(t.position),T===91)v=93,k=!1,h=[];else if(T===123)v=125,k=!0,h={};else return!1;for(t.anchor!==null&&(t.anchorMap[t.anchor]=h),T=t.input.charCodeAt(++t.position);T!==0;){if(ct(t,!0,s),T=t.input.charCodeAt(t.position),T===v)return t.position++,t.tag=u,t.anchor=x,t.kind=k?"mapping":"sequence",t.result=h,!0;o?T===44&&je(t,"expected the node content, but found ','"):je(t,"missed comma between flow collection entries"),j=S=N=null,y=b=!1,T===63&&(g=t.input.charCodeAt(t.position+1),Vt(g)&&(y=b=!0,t.position++,ct(t,!0,s))),l=t.line,i=t.lineStart,d=t.position,_n(t,s,cl,!1,!0),j=t.tag,S=t.result,ct(t,!0,s),T=t.input.charCodeAt(t.position),(b||t.line===l)&&T===58&&(y=!0,T=t.input.charCodeAt(++t.position),ct(t,!0,s),_n(t,s,cl,!1,!0),N=t.result),k?Nn(t,h,_,j,S,N,l,i,d):y?h.push(Nn(t,null,_,j,S,N,l,i,d)):h.push(S),ct(t,!0,s),T=t.input.charCodeAt(t.position),T===44?(o=!0,T=t.input.charCodeAt(++t.position)):o=!1}je(t,"unexpected end of the stream within a flow collection")}function O1(t,s){var o,l,i=vc,d=!1,u=!1,h=s,x=0,g=!1,v,y;if(y=t.input.charCodeAt(t.position),y===124)l=!1;else if(y===62)l=!0;else return!1;for(t.kind="scalar",t.result="";y!==0;)if(y=t.input.charCodeAt(++t.position),y===43||y===45)vc===i?i=y===43?G0:S1:je(t,"repeat of a chomping mode identifier");else if((v=P1(y))>=0)v===0?je(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):u?je(t,"repeat of an indentation width identifier"):(h=s+v-1,u=!0);else break;if(Ws(y)){do y=t.input.charCodeAt(++t.position);while(Ws(y));if(y===35)do y=t.input.charCodeAt(++t.position);while(!_r(y)&&y!==0)}for(;y!==0;){for(yd(t),t.lineIndent=0,y=t.input.charCodeAt(t.position);(!u||t.lineIndent<h)&&y===32;)t.lineIndent++,y=t.input.charCodeAt(++t.position);if(!u&&t.lineIndent>h&&(h=t.lineIndent),_r(y)){x++;continue}if(t.lineIndent<h){i===G0?t.result+=pt.repeat(`
148
- `,d?1+x:x):i===vc&&d&&(t.result+=`
149
- `);break}for(l?Ws(y)?(g=!0,t.result+=pt.repeat(`
150
- `,d?1+x:x)):g?(g=!1,t.result+=pt.repeat(`
151
- `,x+1)):x===0?d&&(t.result+=" "):t.result+=pt.repeat(`
152
- `,x):t.result+=pt.repeat(`
153
- `,d?1+x:x),d=!0,u=!0,x=0,o=t.position;!_r(y)&&y!==0;)y=t.input.charCodeAt(++t.position);ys(t,o,t.position,!1)}return!0}function Z0(t,s){var o,l=t.tag,i=t.anchor,d=[],u,h=!1,x;if(t.firstTabInLine!==-1)return!1;for(t.anchor!==null&&(t.anchorMap[t.anchor]=d),x=t.input.charCodeAt(t.position);x!==0&&(t.firstTabInLine!==-1&&(t.position=t.firstTabInLine,je(t,"tab characters must not be used in indentation")),!(x!==45||(u=t.input.charCodeAt(t.position+1),!Vt(u))));){if(h=!0,t.position++,ct(t,!0,-1)&&t.lineIndent<=s){d.push(null),x=t.input.charCodeAt(t.position);continue}if(o=t.line,_n(t,s,dx,!1,!0),d.push(t.result),ct(t,!0,-1),x=t.input.charCodeAt(t.position),(t.line===o||t.lineIndent>s)&&x!==0)je(t,"bad indentation of a sequence entry");else if(t.lineIndent<s)break}return h?(t.tag=l,t.anchor=i,t.kind="sequence",t.result=d,!0):!1}function F1(t,s,o){var l,i,d,u,h,x,g=t.tag,v=t.anchor,y={},b=Object.create(null),k=null,_=null,S=null,j=!1,N=!1,T;if(t.firstTabInLine!==-1)return!1;for(t.anchor!==null&&(t.anchorMap[t.anchor]=y),T=t.input.charCodeAt(t.position);T!==0;){if(!j&&t.firstTabInLine!==-1&&(t.position=t.firstTabInLine,je(t,"tab characters must not be used in indentation")),l=t.input.charCodeAt(t.position+1),d=t.line,(T===63||T===58)&&Vt(l))T===63?(j&&(Nn(t,y,b,k,_,null,u,h,x),k=_=S=null),N=!0,j=!0,i=!0):j?(j=!1,i=!0):je(t,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),t.position+=1,T=l;else{if(u=t.line,h=t.lineStart,x=t.position,!_n(t,o,cx,!1,!0))break;if(t.line===d){for(T=t.input.charCodeAt(t.position);Ws(T);)T=t.input.charCodeAt(++t.position);if(T===58)T=t.input.charCodeAt(++t.position),Vt(T)||je(t,"a whitespace character is expected after the key-value separator within a block mapping"),j&&(Nn(t,y,b,k,_,null,u,h,x),k=_=S=null),N=!0,j=!1,i=!1,k=t.tag,_=t.result;else if(N)je(t,"can not read an implicit mapping pair; a colon is missed");else return t.tag=g,t.anchor=v,!0}else if(N)je(t,"can not read a block mapping entry; a multiline key may not be an implicit key");else return t.tag=g,t.anchor=v,!0}if((t.line===d||t.lineIndent>s)&&(j&&(u=t.line,h=t.lineStart,x=t.position),_n(t,s,dl,!0,i)&&(j?_=t.result:S=t.result),j||(Nn(t,y,b,k,_,S,u,h,x),k=_=S=null),ct(t,!0,-1),T=t.input.charCodeAt(t.position)),(t.line===d||t.lineIndent>s)&&T!==0)je(t,"bad indentation of a mapping entry");else if(t.lineIndent<s)break}return j&&Nn(t,y,b,k,_,null,u,h,x),N&&(t.tag=g,t.anchor=v,t.kind="mapping",t.result=y),N}function W1(t){var s,o=!1,l=!1,i,d,u;if(u=t.input.charCodeAt(t.position),u!==33)return!1;if(t.tag!==null&&je(t,"duplication of a tag property"),u=t.input.charCodeAt(++t.position),u===60?(o=!0,u=t.input.charCodeAt(++t.position)):u===33?(l=!0,i="!!",u=t.input.charCodeAt(++t.position)):i="!",s=t.position,o){do u=t.input.charCodeAt(++t.position);while(u!==0&&u!==62);t.position<t.length?(d=t.input.slice(s,t.position),u=t.input.charCodeAt(++t.position)):je(t,"unexpected end of the stream within a verbatim tag")}else{for(;u!==0&&!Vt(u);)u===33&&(l?je(t,"tag suffix cannot contain exclamation marks"):(i=t.input.slice(s-1,t.position+1),ux.test(i)||je(t,"named tag handle cannot contain such characters"),l=!0,s=t.position+1)),u=t.input.charCodeAt(++t.position);d=t.input.slice(s,t.position),E1.test(d)&&je(t,"tag suffix cannot contain flow indicator characters")}d&&!mx.test(d)&&je(t,"tag name cannot contain such characters: "+d);try{d=decodeURIComponent(d)}catch{je(t,"tag name is malformed: "+d)}return o?t.tag=d:vs.call(t.tagMap,i)?t.tag=t.tagMap[i]+d:i==="!"?t.tag="!"+d:i==="!!"?t.tag="tag:yaml.org,2002:"+d:je(t,'undeclared tag handle "'+i+'"'),!0}function z1(t){var s,o;if(o=t.input.charCodeAt(t.position),o!==38)return!1;for(t.anchor!==null&&je(t,"duplication of an anchor property"),o=t.input.charCodeAt(++t.position),s=t.position;o!==0&&!Vt(o)&&!jn(o);)o=t.input.charCodeAt(++t.position);return t.position===s&&je(t,"name of an anchor node must contain at least one character"),t.anchor=t.input.slice(s,t.position),!0}function H1(t){var s,o,l;if(l=t.input.charCodeAt(t.position),l!==42)return!1;for(l=t.input.charCodeAt(++t.position),s=t.position;l!==0&&!Vt(l)&&!jn(l);)l=t.input.charCodeAt(++t.position);return t.position===s&&je(t,"name of an alias node must contain at least one character"),o=t.input.slice(s,t.position),vs.call(t.anchorMap,o)||je(t,'unidentified alias "'+o+'"'),t.result=t.anchorMap[o],ct(t,!0,-1),!0}function _n(t,s,o,l,i){var d,u,h,x=1,g=!1,v=!1,y,b,k,_,S,j;if(t.listener!==null&&t.listener("open",t),t.tag=null,t.anchor=null,t.kind=null,t.result=null,d=u=h=dl===o||dx===o,l&&ct(t,!0,-1)&&(g=!0,t.lineIndent>s?x=1:t.lineIndent===s?x=0:t.lineIndent<s&&(x=-1)),x===1)for(;W1(t)||z1(t);)ct(t,!0,-1)?(g=!0,h=d,t.lineIndent>s?x=1:t.lineIndent===s?x=0:t.lineIndent<s&&(x=-1)):h=!1;if(h&&(h=g||i),(x===1||dl===o)&&(cl===o||cx===o?S=s:S=s+1,j=t.position-t.lineStart,x===1?h&&(Z0(t,j)||F1(t,j,S))||D1(t,S)?v=!0:(u&&O1(t,S)||$1(t,S)||B1(t,S)?v=!0:H1(t)?(v=!0,(t.tag!==null||t.anchor!==null)&&je(t,"alias node should not have any properties")):I1(t,S,cl===o)&&(v=!0,t.tag===null&&(t.tag="?")),t.anchor!==null&&(t.anchorMap[t.anchor]=t.result)):x===0&&(v=h&&Z0(t,j))),t.tag===null)t.anchor!==null&&(t.anchorMap[t.anchor]=t.result);else if(t.tag==="?"){for(t.result!==null&&t.kind!=="scalar"&&je(t,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+t.kind+'"'),y=0,b=t.implicitTypes.length;y<b;y+=1)if(_=t.implicitTypes[y],_.resolve(t.result)){t.result=_.construct(t.result),t.tag=_.tag,t.anchor!==null&&(t.anchorMap[t.anchor]=t.result);break}}else if(t.tag!=="!"){if(vs.call(t.typeMap[t.kind||"fallback"],t.tag))_=t.typeMap[t.kind||"fallback"][t.tag];else for(_=null,k=t.typeMap.multi[t.kind||"fallback"],y=0,b=k.length;y<b;y+=1)if(t.tag.slice(0,k[y].tag.length)===k[y].tag){_=k[y];break}_||je(t,"unknown tag !<"+t.tag+">"),t.result!==null&&_.kind!==t.kind&&je(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+_.kind+'", not "'+t.kind+'"'),_.resolve(t.result,t.tag)?(t.result=_.construct(t.result,t.tag),t.anchor!==null&&(t.anchorMap[t.anchor]=t.result)):je(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")}return t.listener!==null&&t.listener("close",t),t.tag!==null||t.anchor!==null||v}function U1(t){var s=t.position,o,l,i,d=!1,u;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap=Object.create(null),t.anchorMap=Object.create(null);(u=t.input.charCodeAt(t.position))!==0&&(ct(t,!0,-1),u=t.input.charCodeAt(t.position),!(t.lineIndent>0||u!==37));){for(d=!0,u=t.input.charCodeAt(++t.position),o=t.position;u!==0&&!Vt(u);)u=t.input.charCodeAt(++t.position);for(l=t.input.slice(o,t.position),i=[],l.length<1&&je(t,"directive name must not be less than one character in length");u!==0;){for(;Ws(u);)u=t.input.charCodeAt(++t.position);if(u===35){do u=t.input.charCodeAt(++t.position);while(u!==0&&!_r(u));break}if(_r(u))break;for(o=t.position;u!==0&&!Vt(u);)u=t.input.charCodeAt(++t.position);i.push(t.input.slice(o,t.position))}u!==0&&yd(t),vs.call(Q0,l)?Q0[l](t,l,i):ul(t,'unknown document directive "'+l+'"')}if(ct(t,!0,-1),t.lineIndent===0&&t.input.charCodeAt(t.position)===45&&t.input.charCodeAt(t.position+1)===45&&t.input.charCodeAt(t.position+2)===45?(t.position+=3,ct(t,!0,-1)):d&&je(t,"directives end mark is expected"),_n(t,t.lineIndent-1,dl,!1,!0),ct(t,!0,-1),t.checkLineBreaks&&L1.test(t.input.slice(s,t.position))&&ul(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&jl(t)){t.input.charCodeAt(t.position)===46&&(t.position+=3,ct(t,!0,-1));return}if(t.position<t.length-1)je(t,"end of the stream or a document separator is expected");else return}function gx(t,s){t=String(t),s=s||{},t.length!==0&&(t.charCodeAt(t.length-1)!==10&&t.charCodeAt(t.length-1)!==13&&(t+=`
154
- `),t.charCodeAt(0)===65279&&(t=t.slice(1)));var o=new R1(t,s),l=t.indexOf("\0");for(l!==-1&&(o.position=l,je(o,"null byte is not allowed in input")),o.input+="\0";o.input.charCodeAt(o.position)===32;)o.lineIndent+=1,o.position+=1;for(;o.position<o.length-1;)U1(o);return o.documents}function V1(t,s,o){s!==null&&typeof s=="object"&&typeof o>"u"&&(o=s,s=null);var l=gx(t,o);if(typeof s!="function")return l;for(var i=0,d=l.length;i<d;i+=1)s(l[i])}function q1(t,s){var o=gx(t,s);if(o.length!==0){if(o.length===1)return o[0];throw new It("expected a single document in the stream, but found more")}}var Y1=V1,G1=q1,yx={loadAll:Y1,load:G1},vx=Object.prototype.toString,wx=Object.prototype.hasOwnProperty,wd=65279,K1=9,Lo=10,J1=13,Q1=32,X1=33,Z1=34,$c=35,e4=37,t4=38,r4=39,s4=42,bx=44,n4=45,ml=58,o4=61,a4=62,l4=63,i4=64,jx=91,Nx=93,c4=96,kx=123,d4=124,Cx=125,At={};At[0]="\\0";At[7]="\\a";At[8]="\\b";At[9]="\\t";At[10]="\\n";At[11]="\\v";At[12]="\\f";At[13]="\\r";At[27]="\\e";At[34]='\\"';At[92]="\\\\";At[133]="\\N";At[160]="\\_";At[8232]="\\L";At[8233]="\\P";var u4=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],m4=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function h4(t,s){var o,l,i,d,u,h,x;if(s===null)return{};for(o={},l=Object.keys(s),i=0,d=l.length;i<d;i+=1)u=l[i],h=String(s[u]),u.slice(0,2)==="!!"&&(u="tag:yaml.org,2002:"+u.slice(2)),x=t.compiledTypeMap.fallback[u],x&&wx.call(x.styleAliases,h)&&(h=x.styleAliases[h]),o[u]=h;return o}function p4(t){var s,o,l;if(s=t.toString(16).toUpperCase(),t<=255)o="x",l=2;else if(t<=65535)o="u",l=4;else if(t<=4294967295)o="U",l=8;else throw new It("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+o+pt.repeat("0",l-s.length)+s}var x4=1,Eo=2;function f4(t){this.schema=t.schema||gd,this.indent=Math.max(1,t.indent||2),this.noArrayIndent=t.noArrayIndent||!1,this.skipInvalid=t.skipInvalid||!1,this.flowLevel=pt.isNothing(t.flowLevel)?-1:t.flowLevel,this.styleMap=h4(this.schema,t.styles||null),this.sortKeys=t.sortKeys||!1,this.lineWidth=t.lineWidth||80,this.noRefs=t.noRefs||!1,this.noCompatMode=t.noCompatMode||!1,this.condenseFlow=t.condenseFlow||!1,this.quotingType=t.quotingType==='"'?Eo:x4,this.forceQuotes=t.forceQuotes||!1,this.replacer=typeof t.replacer=="function"?t.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function eh(t,s){for(var o=pt.repeat(" ",s),l=0,i=-1,d="",u,h=t.length;l<h;)i=t.indexOf(`
155
- `,l),i===-1?(u=t.slice(l),l=h):(u=t.slice(l,i+1),l=i+1),u.length&&u!==`
156
- `&&(d+=o),d+=u;return d}function Bc(t,s){return`
157
- `+pt.repeat(" ",t.indent*s)}function g4(t,s){var o,l,i;for(o=0,l=t.implicitTypes.length;o<l;o+=1)if(i=t.implicitTypes[o],i.resolve(s))return!0;return!1}function hl(t){return t===Q1||t===K1}function To(t){return 32<=t&&t<=126||161<=t&&t<=55295&&t!==8232&&t!==8233||57344<=t&&t<=65533&&t!==wd||65536<=t&&t<=1114111}function th(t){return To(t)&&t!==wd&&t!==J1&&t!==Lo}function rh(t,s,o){var l=th(t),i=l&&!hl(t);return(o?l:l&&t!==bx&&t!==jx&&t!==Nx&&t!==kx&&t!==Cx)&&t!==$c&&!(s===ml&&!i)||th(s)&&!hl(s)&&t===$c||s===ml&&i}function y4(t){return To(t)&&t!==wd&&!hl(t)&&t!==n4&&t!==l4&&t!==ml&&t!==bx&&t!==jx&&t!==Nx&&t!==kx&&t!==Cx&&t!==$c&&t!==t4&&t!==s4&&t!==X1&&t!==d4&&t!==o4&&t!==a4&&t!==r4&&t!==Z1&&t!==e4&&t!==i4&&t!==c4}function v4(t){return!hl(t)&&t!==ml}function bo(t,s){var o=t.charCodeAt(s),l;return o>=55296&&o<=56319&&s+1<t.length&&(l=t.charCodeAt(s+1),l>=56320&&l<=57343)?(o-55296)*1024+l-56320+65536:o}function Sx(t){var s=/^\n* /;return s.test(t)}var _x=1,Dc=2,Lx=3,Ex=4,wn=5;function w4(t,s,o,l,i,d,u,h){var x,g=0,v=null,y=!1,b=!1,k=l!==-1,_=-1,S=y4(bo(t,0))&&v4(bo(t,t.length-1));if(s||u)for(x=0;x<t.length;g>=65536?x+=2:x++){if(g=bo(t,x),!To(g))return wn;S=S&&rh(g,v,h),v=g}else{for(x=0;x<t.length;g>=65536?x+=2:x++){if(g=bo(t,x),g===Lo)y=!0,k&&(b=b||x-_-1>l&&t[_+1]!==" ",_=x);else if(!To(g))return wn;S=S&&rh(g,v,h),v=g}b=b||k&&x-_-1>l&&t[_+1]!==" "}return!y&&!b?S&&!u&&!i(t)?_x:d===Eo?wn:Dc:o>9&&Sx(t)?wn:u?d===Eo?wn:Dc:b?Ex:Lx}function b4(t,s,o,l,i){t.dump=(function(){if(s.length===0)return t.quotingType===Eo?'""':"''";if(!t.noCompatMode&&(u4.indexOf(s)!==-1||m4.test(s)))return t.quotingType===Eo?'"'+s+'"':"'"+s+"'";var d=t.indent*Math.max(1,o),u=t.lineWidth===-1?-1:Math.max(Math.min(t.lineWidth,40),t.lineWidth-d),h=l||t.flowLevel>-1&&o>=t.flowLevel;function x(g){return g4(t,g)}switch(w4(s,h,t.indent,u,x,t.quotingType,t.forceQuotes&&!l,i)){case _x:return s;case Dc:return"'"+s.replace(/'/g,"''")+"'";case Lx:return"|"+sh(s,t.indent)+nh(eh(s,d));case Ex:return">"+sh(s,t.indent)+nh(eh(j4(s,u),d));case wn:return'"'+N4(s)+'"';default:throw new It("impossible error: invalid scalar style")}})()}function sh(t,s){var o=Sx(t)?String(s):"",l=t[t.length-1]===`
158
- `,i=l&&(t[t.length-2]===`
159
- `||t===`
160
- `),d=i?"+":l?"":"-";return o+d+`
161
- `}function nh(t){return t[t.length-1]===`
162
- `?t.slice(0,-1):t}function j4(t,s){for(var o=/(\n+)([^\n]*)/g,l=(function(){var g=t.indexOf(`
163
- `);return g=g!==-1?g:t.length,o.lastIndex=g,oh(t.slice(0,g),s)})(),i=t[0]===`
164
- `||t[0]===" ",d,u;u=o.exec(t);){var h=u[1],x=u[2];d=x[0]===" ",l+=h+(!i&&!d&&x!==""?`
165
- `:"")+oh(x,s),i=d}return l}function oh(t,s){if(t===""||t[0]===" ")return t;for(var o=/ [^ ]/g,l,i=0,d,u=0,h=0,x="";l=o.exec(t);)h=l.index,h-i>s&&(d=u>i?u:h,x+=`
166
- `+t.slice(i,d),i=d+1),u=h;return x+=`
167
- `,t.length-i>s&&u>i?x+=t.slice(i,u)+`
168
- `+t.slice(u+1):x+=t.slice(i),x.slice(1)}function N4(t){for(var s="",o=0,l,i=0;i<t.length;o>=65536?i+=2:i++)o=bo(t,i),l=At[o],!l&&To(o)?(s+=t[i],o>=65536&&(s+=t[i+1])):s+=l||p4(o);return s}function k4(t,s,o){var l="",i=t.tag,d,u,h;for(d=0,u=o.length;d<u;d+=1)h=o[d],t.replacer&&(h=t.replacer.call(o,String(d),h)),(Vr(t,s,h,!1,!1)||typeof h>"u"&&Vr(t,s,null,!1,!1))&&(l!==""&&(l+=","+(t.condenseFlow?"":" ")),l+=t.dump);t.tag=i,t.dump="["+l+"]"}function ah(t,s,o,l){var i="",d=t.tag,u,h,x;for(u=0,h=o.length;u<h;u+=1)x=o[u],t.replacer&&(x=t.replacer.call(o,String(u),x)),(Vr(t,s+1,x,!0,!0,!1,!0)||typeof x>"u"&&Vr(t,s+1,null,!0,!0,!1,!0))&&((!l||i!=="")&&(i+=Bc(t,s)),t.dump&&Lo===t.dump.charCodeAt(0)?i+="-":i+="- ",i+=t.dump);t.tag=d,t.dump=i||"[]"}function C4(t,s,o){var l="",i=t.tag,d=Object.keys(o),u,h,x,g,v;for(u=0,h=d.length;u<h;u+=1)v="",l!==""&&(v+=", "),t.condenseFlow&&(v+='"'),x=d[u],g=o[x],t.replacer&&(g=t.replacer.call(o,x,g)),Vr(t,s,x,!1,!1)&&(t.dump.length>1024&&(v+="? "),v+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),Vr(t,s,g,!1,!1)&&(v+=t.dump,l+=v));t.tag=i,t.dump="{"+l+"}"}function S4(t,s,o,l){var i="",d=t.tag,u=Object.keys(o),h,x,g,v,y,b;if(t.sortKeys===!0)u.sort();else if(typeof t.sortKeys=="function")u.sort(t.sortKeys);else if(t.sortKeys)throw new It("sortKeys must be a boolean or a function");for(h=0,x=u.length;h<x;h+=1)b="",(!l||i!=="")&&(b+=Bc(t,s)),g=u[h],v=o[g],t.replacer&&(v=t.replacer.call(o,g,v)),Vr(t,s+1,g,!0,!0,!0)&&(y=t.tag!==null&&t.tag!=="?"||t.dump&&t.dump.length>1024,y&&(t.dump&&Lo===t.dump.charCodeAt(0)?b+="?":b+="? "),b+=t.dump,y&&(b+=Bc(t,s)),Vr(t,s+1,v,!0,y)&&(t.dump&&Lo===t.dump.charCodeAt(0)?b+=":":b+=": ",b+=t.dump,i+=b));t.tag=d,t.dump=i||"{}"}function lh(t,s,o){var l,i,d,u,h,x;for(i=o?t.explicitTypes:t.implicitTypes,d=0,u=i.length;d<u;d+=1)if(h=i[d],(h.instanceOf||h.predicate)&&(!h.instanceOf||typeof s=="object"&&s instanceof h.instanceOf)&&(!h.predicate||h.predicate(s))){if(o?h.multi&&h.representName?t.tag=h.representName(s):t.tag=h.tag:t.tag="?",h.represent){if(x=t.styleMap[h.tag]||h.defaultStyle,vx.call(h.represent)==="[object Function]")l=h.represent(s,x);else if(wx.call(h.represent,x))l=h.represent[x](s,x);else throw new It("!<"+h.tag+'> tag resolver accepts not "'+x+'" style');t.dump=l}return!0}return!1}function Vr(t,s,o,l,i,d,u){t.tag=null,t.dump=o,lh(t,o,!1)||lh(t,o,!0);var h=vx.call(t.dump),x=l,g;l&&(l=t.flowLevel<0||t.flowLevel>s);var v=h==="[object Object]"||h==="[object Array]",y,b;if(v&&(y=t.duplicates.indexOf(o),b=y!==-1),(t.tag!==null&&t.tag!=="?"||b||t.indent!==2&&s>0)&&(i=!1),b&&t.usedDuplicates[y])t.dump="*ref_"+y;else{if(v&&b&&!t.usedDuplicates[y]&&(t.usedDuplicates[y]=!0),h==="[object Object]")l&&Object.keys(t.dump).length!==0?(S4(t,s,t.dump,i),b&&(t.dump="&ref_"+y+t.dump)):(C4(t,s,t.dump),b&&(t.dump="&ref_"+y+" "+t.dump));else if(h==="[object Array]")l&&t.dump.length!==0?(t.noArrayIndent&&!u&&s>0?ah(t,s-1,t.dump,i):ah(t,s,t.dump,i),b&&(t.dump="&ref_"+y+t.dump)):(k4(t,s,t.dump),b&&(t.dump="&ref_"+y+" "+t.dump));else if(h==="[object String]")t.tag!=="?"&&b4(t,t.dump,s,d,x);else{if(h==="[object Undefined]")return!1;if(t.skipInvalid)return!1;throw new It("unacceptable kind of an object to dump "+h)}t.tag!==null&&t.tag!=="?"&&(g=encodeURI(t.tag[0]==="!"?t.tag.slice(1):t.tag).replace(/!/g,"%21"),t.tag[0]==="!"?g="!"+g:g.slice(0,18)==="tag:yaml.org,2002:"?g="!!"+g.slice(18):g="!<"+g+">",t.dump=g+" "+t.dump)}return!0}function _4(t,s){var o=[],l=[],i,d;for(Oc(t,o,l),i=0,d=l.length;i<d;i+=1)s.duplicates.push(o[l[i]]);s.usedDuplicates=new Array(d)}function Oc(t,s,o){var l,i,d;if(t!==null&&typeof t=="object")if(i=s.indexOf(t),i!==-1)o.indexOf(i)===-1&&o.push(i);else if(s.push(t),Array.isArray(t))for(i=0,d=t.length;i<d;i+=1)Oc(t[i],s,o);else for(l=Object.keys(t),i=0,d=l.length;i<d;i+=1)Oc(t[l[i]],s,o)}function L4(t,s){s=s||{};var o=new f4(s);o.noRefs||_4(t,o);var l=t;return o.replacer&&(l=o.replacer.call({"":l},"",l)),Vr(o,0,l,!0,!0)?o.dump+`
169
- `:""}var E4=L4,T4={dump:E4};function bd(t,s){return function(){throw new Error("Function yaml."+t+" is removed in js-yaml 4. Use yaml."+s+" instead, which is now safe by default.")}}var A4=Ct,P4=Up,M4=Gp,R4=Zp,I4=ex,$4=gd,B4=yx.load,D4=yx.loadAll,O4=T4.dump,F4=It,W4={binary:ox,float:Xp,map:Yp,null:Kp,pairs:lx,set:ix,timestamp:sx,bool:Jp,int:Qp,merge:nx,omap:ax,seq:qp,str:Vp},z4=bd("safeLoad","load"),H4=bd("safeLoadAll","loadAll"),U4=bd("safeDump","dump"),Ga={Type:A4,Schema:P4,FAILSAFE_SCHEMA:M4,JSON_SCHEMA:R4,CORE_SCHEMA:I4,DEFAULT_SCHEMA:$4,load:B4,loadAll:D4,dump:O4,YAMLException:F4,types:W4,safeLoad:z4,safeLoadAll:H4,safeDump:U4};const V4={output:{singular:"item",plural:"items",description:""}},q4={strategy:"fixed"},Y4={max_iterations:10,max_runtime_seconds:3600,max_consecutive_errors:3,cooldown_between_iterations:5},Tx={name:"",display_name:"",type:"generator",description:"",item_types:V4,modes:[],mode_selection:q4,limits:Y4};function wc(t){var o,l,i,d;const s={...Tx};if(typeof t.name=="string"&&(s.name=t.name),typeof t.display_name=="string"&&(s.display_name=t.display_name),typeof t.description=="string"&&(s.description=t.description),(t.type==="generator"||t.type==="consumer"||t.type==="hybrid")&&(s.type=t.type),t.item_types&&typeof t.item_types=="object"){const u=t.item_types;if(s.item_types={output:{singular:((o=u.output)==null?void 0:o.singular)||"item",plural:((l=u.output)==null?void 0:l.plural)||"items",description:((i=u.output)==null?void 0:i.description)||"",source:(d=u.output)==null?void 0:d.source}},u.input&&typeof u.input=="object"){const h=u.input;s.item_types.input={singular:h.singular||"item",plural:h.plural||"items",description:h.description||"",source:h.source}}}if(t.modes&&typeof t.modes=="object"){const u=t.modes;s.modes=Object.entries(u).map(([h,x])=>{const g=x;return{name:h,description:g.description||"",model:g.model||"claude-sonnet-4-20250514",timeout:typeof g.timeout=="number"?g.timeout:300,tools:Array.isArray(g.tools)?g.tools:[],prompt_template:g.prompt_template||""}})}if(t.mode_selection&&typeof t.mode_selection=="object"){const u=t.mode_selection;s.mode_selection={strategy:u.strategy||"fixed",fixed_mode:u.fixed_mode,weights:u.weights}}if(t.limits&&typeof t.limits=="object"){const u=t.limits;s.limits={max_iterations:typeof u.max_iterations=="number"?u.max_iterations:10,max_runtime_seconds:typeof u.max_runtime_seconds=="number"?u.max_runtime_seconds:3600,max_consecutive_errors:typeof u.max_consecutive_errors=="number"?u.max_consecutive_errors:3,cooldown_between_iterations:typeof u.cooldown_between_iterations=="number"?u.cooldown_between_iterations:5}}return s}function ih(t){const s={name:t.name,display_name:t.display_name,type:t.type};t.description&&(s.description=t.description);const o={output:{singular:t.item_types.output.singular,plural:t.item_types.output.plural}};t.item_types.output.description&&(o.output.description=t.item_types.output.description),t.item_types.input&&(o.input={singular:t.item_types.input.singular,plural:t.item_types.input.plural},t.item_types.input.description&&(o.input.description=t.item_types.input.description),t.item_types.input.source&&(o.input.source=t.item_types.input.source)),s.item_types=o;const l={};for(const d of t.modes)l[d.name]={description:d.description,model:d.model,timeout:d.timeout,prompt_template:d.prompt_template},d.tools.length>0&&(l[d.name].tools=d.tools);s.modes=l;const i={strategy:t.mode_selection.strategy};return t.mode_selection.strategy==="fixed"&&t.mode_selection.fixed_mode&&(i.fixed_mode=t.mode_selection.fixed_mode),t.mode_selection.strategy==="weighted_random"&&t.mode_selection.weights&&(i.weights=t.mode_selection.weights),s.mode_selection=i,s.limits={max_iterations:t.limits.max_iterations,max_runtime_seconds:t.limits.max_runtime_seconds,max_consecutive_errors:t.limits.max_consecutive_errors,cooldown_between_iterations:t.limits.cooldown_between_iterations},s}const Hr={loopName:{body:"A unique identifier for this loop. Use lowercase letters, numbers, hyphens, and underscores only. This will be used in API calls and file names."},displayName:{body:"A human-readable name for this loop that will be shown in the UI."},loopType:{body:"Generator loops create new items. Consumer loops process items from other loops. Hybrid loops do both."},itemTypes:{body:'Define what your loop calls its items. For example, a research loop might output "stories" while an implementation loop outputs "implementations".'},sourceLoop:{body:"For consumer loops, specify which loop's output items to process. The source loop must exist in the same project."},maxIterations:{body:"Maximum number of iterations before the loop stops. Set to 0 for unlimited (consumer loops will process all available items)."},maxRuntime:{body:"Maximum total runtime in seconds. The loop will stop after this time even if max iterations hasn't been reached."},maxErrors:{body:"Stop the loop if this many iterations fail in a row. Helps prevent infinite loops when there's a systemic issue."},cooldown:{body:"Seconds to wait between iterations. Useful for rate limiting or allowing external processes to complete."}};function G4({name:t,displayName:s,type:o,description:l,isNewLoop:i,onChange:d}){const u=h=>{const x={display_name:h};if(i&&!t){const g=h.toLowerCase().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").substring(0,50);x.name=g}d(x)};return e.jsxs("section",{children:[e.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center",children:[e.jsx("span",{className:"w-8 h-8 rounded-full bg-primary-600 text-white flex items-center justify-center text-sm font-bold mr-3",children:"1"}),"Basic Information"]}),e.jsxs("div",{className:"space-y-4 pl-11",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"display_name",className:"block text-sm font-medium text-gray-300 mb-1",children:["Display Name ",e.jsx("span",{className:"text-red-400",children:"*"}),e.jsx(zr,{content:Hr.displayName.body,size:"sm",className:"ml-1"})]}),e.jsx("input",{id:"display_name",type:"text",value:s,onChange:h=>u(h.target.value),placeholder:"e.g., Research Loop",className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white placeholder-gray-400 focus:outline-none focus:border-primary-500"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Human-readable name shown in the UI"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"name",className:"block text-sm font-medium text-gray-300 mb-1",children:["Slug ",e.jsx("span",{className:"text-red-400",children:"*"}),e.jsx(zr,{content:Hr.loopName.body,size:"sm",className:"ml-1"})]}),e.jsx("input",{id:"name",type:"text",value:t,onChange:h=>d({name:h.target.value}),placeholder:"e.g., research",disabled:!i,className:`w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white placeholder-gray-400 focus:outline-none focus:border-primary-500 font-mono ${i?"":"opacity-60 cursor-not-allowed"}`}),e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:i?"Unique identifier (lowercase letters, numbers, hyphens, underscores)":"Slug cannot be changed after creation"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:["Loop Type ",e.jsx("span",{className:"text-red-400",children:"*"}),e.jsx(zr,{content:Hr.loopType.body,size:"sm",className:"ml-1"})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:[{value:"generator",label:"Generator",description:"Creates new items from prompts"},{value:"consumer",label:"Consumer",description:"Processes items from another loop"},{value:"hybrid",label:"Hybrid",description:"Both consumes and generates items"}].map(h=>e.jsxs("button",{type:"button",onClick:()=>d({type:h.value}),className:`p-3 rounded-lg border text-left transition-colors ${o===h.value?"border-primary-500 bg-primary-900/30":"border-gray-600 bg-gray-700 hover:border-gray-500"}`,children:[e.jsx("div",{className:"font-medium text-white",children:h.label}),e.jsx("div",{className:"text-xs text-gray-400 mt-1",children:h.description})]},h.value))})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"description",className:"block text-sm font-medium text-gray-300 mb-1",children:"Description"}),e.jsx("textarea",{id:"description",value:l,onChange:h=>d({description:h.target.value}),placeholder:"Brief description of what this loop does...",rows:2,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white placeholder-gray-400 focus:outline-none focus:border-primary-500 resize-none"})]})]})]})}function ch({label:t,config:s,showSource:o=!1,availableLoops:l=[],onChange:i}){return e.jsxs("div",{className:"p-4 bg-gray-700/50 rounded-lg border border-gray-600",children:[e.jsx("h5",{className:"text-sm font-medium text-white mb-3",children:t}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-400 mb-1",children:"Singular"}),e.jsx("input",{type:"text",value:s.singular,onChange:d=>i({...s,singular:d.target.value}),placeholder:"e.g., story",className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-sm text-white placeholder-gray-400 focus:outline-none focus:border-primary-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-400 mb-1",children:"Plural"}),e.jsx("input",{type:"text",value:s.plural,onChange:d=>i({...s,plural:d.target.value}),placeholder:"e.g., stories",className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-sm text-white placeholder-gray-400 focus:outline-none focus:border-primary-500"})]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"block text-xs text-gray-400 mb-1",children:"Description"}),e.jsx("input",{type:"text",value:s.description,onChange:d=>i({...s,description:d.target.value}),placeholder:"e.g., User stories with acceptance criteria",className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-sm text-white placeholder-gray-400 focus:outline-none focus:border-primary-500"})]}),o&&e.jsxs("div",{className:"mt-3",children:[e.jsxs("label",{className:"block text-xs text-gray-400 mb-1",children:["Source Loop",e.jsx(zr,{content:Hr.sourceLoop.body,size:"sm",className:"ml-1"})]}),e.jsxs("select",{value:s.source||"",onChange:d=>i({...s,source:d.target.value||void 0}),className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-sm text-white focus:outline-none focus:border-primary-500",children:[e.jsx("option",{value:"",children:"Select a source loop..."}),l.map(d=>e.jsx("option",{value:d,children:d},d))]}),e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Which loop's output items should this loop consume?"})]})]})}function K4({itemTypes:t,loopType:s,availableLoops:o,onChange:l}){const i=s==="consumer"||s==="hybrid",d=g=>{l({...t,output:g})},u=g=>{l({...t,input:g})},h=()=>{l({...t,input:{singular:"item",plural:"items",description:""}})},x=()=>{const{input:g,...v}=t;l({...v,output:t.output})};return e.jsxs("section",{children:[e.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center",children:[e.jsx("span",{className:"w-8 h-8 rounded-full bg-primary-600 text-white flex items-center justify-center text-sm font-bold mr-3",children:"2"}),"Item Types",e.jsx(zr,{content:Hr.itemTypes.body,size:"sm",className:"ml-2"})]}),e.jsxs("div",{className:"space-y-4 pl-11",children:[e.jsx("p",{className:"text-sm text-gray-400",children:"Configure how items are named in the UI. This helps make the interface more intuitive for your specific use case."}),i&&e.jsx("div",{children:t.input?e.jsxs("div",{className:"relative",children:[e.jsx(ch,{label:"Input Item Type",config:t.input,showSource:!0,availableLoops:o,onChange:u}),e.jsx("button",{type:"button",onClick:x,className:"absolute top-2 right-2 text-gray-400 hover:text-red-400",title:"Remove input type",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}):e.jsxs("button",{type:"button",onClick:h,className:"w-full p-4 border-2 border-dashed border-gray-600 rounded-lg text-gray-400 hover:border-gray-500 hover:text-gray-300 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),e.jsx("span",{children:"Add Input Item Type"})]}),e.jsx("p",{className:"text-xs mt-1",children:"Define the items this loop will consume from another loop"})]})}),i&&t.input&&e.jsx("div",{className:"flex justify-center py-2",children:e.jsx("svg",{className:"w-6 h-6 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})})}),e.jsx(ch,{label:"Output Item Type",config:t.output,onChange:d}),e.jsx("div",{className:"p-3 bg-gray-700/30 rounded-lg border border-gray-600/50",children:e.jsxs("div",{className:"flex items-start space-x-2",children:[e.jsx("svg",{className:"w-5 h-5 text-primary-400 flex-shrink-0 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{className:"text-xs text-gray-400",children:[e.jsx("strong",{className:"text-gray-300",children:"Example usage:"}),' For a research loop that generates user stories, set Output to singular: "story", plural: "stories". The UI will show "Add Story" instead of "Add Item".']})]})})]})]})}const dh=[{value:"claude-sonnet-4-20250514",label:"Claude Sonnet 4"},{value:"claude-opus-4-20250514",label:"Claude Opus 4"},{value:"claude-3-5-haiku-20241022",label:"Claude 3.5 Haiku"}];function J4({mode:t,isExpanded:s,onToggle:o,onChange:l,onDelete:i}){var x;const[d,u]=p.useState(!1),h=()=>{d?i():(u(!0),setTimeout(()=>u(!1),3e3))};return e.jsxs("div",{className:"border border-gray-600 rounded-lg bg-gray-700/50 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 cursor-pointer hover:bg-gray-700/70 transition-colors",onClick:o,children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("svg",{className:`w-5 h-5 text-gray-400 transition-transform ${s?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-white",children:t.name||e.jsx("span",{className:"text-gray-400 italic",children:"Unnamed mode"})}),e.jsxs("div",{className:"text-xs text-gray-400",children:[((x=dh.find(g=>g.value===t.model))==null?void 0:x.label)||t.model," · ",t.timeout,"s timeout"]})]})]}),e.jsx("button",{onClick:g=>{g.stopPropagation(),h()},className:`px-2 py-1 text-sm rounded transition-colors ${d?"bg-red-800 text-red-200 hover:bg-red-700":"text-gray-400 hover:text-red-400 hover:bg-gray-600"}`,children:d?"Confirm Delete":"Delete"})]}),s&&e.jsxs("div",{className:"p-4 border-t border-gray-600 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:["Mode Name ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",value:t.name,onChange:g=>l({...t,name:g.target.value}),placeholder:"e.g., turbo, deep, default",className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-sm text-white placeholder-gray-400 focus:outline-none focus:border-primary-500 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Description"}),e.jsx("input",{type:"text",value:t.description,onChange:g=>l({...t,description:g.target.value}),placeholder:"Brief description of this mode's purpose",className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-sm text-white placeholder-gray-400 focus:outline-none focus:border-primary-500"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Model"}),e.jsx("select",{value:t.model,onChange:g=>l({...t,model:g.target.value}),className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-sm text-white focus:outline-none focus:border-primary-500",children:dh.map(g=>e.jsx("option",{value:g.value,children:g.label},g.value))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Timeout (seconds)"}),e.jsx("input",{type:"number",value:t.timeout,onChange:g=>l({...t,timeout:parseInt(g.target.value)||300}),min:1,max:7200,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-sm text-white focus:outline-none focus:border-primary-500"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:["Prompt Template ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",value:t.prompt_template,onChange:g=>l({...t,prompt_template:g.target.value}),placeholder:"prompts/research.md",className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-sm text-white placeholder-gray-400 focus:outline-none focus:border-primary-500 font-mono"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Path to the prompt template file relative to .ralphx/ directory"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Tools (optional)"}),e.jsx("input",{type:"text",value:t.tools.join(", "),onChange:g=>l({...t,tools:g.target.value.split(",").map(v=>v.trim()).filter(Boolean)}),placeholder:"read_file, write_file, execute_command",className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-sm text-white placeholder-gray-400 focus:outline-none focus:border-primary-500"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Comma-separated list of tool names available to this mode"})]})]})]})}function Q4({modes:t,onChange:s}){const[o,l]=p.useState(t.length===0?null:0),i=p.useCallback((h,x)=>{const g=[...t];g[h]=x,s(g)},[t,s]),d=p.useCallback(h=>{const x=t.filter((g,v)=>v!==h);s(x),o===h?l(x.length>0?0:null):o!==null&&o>h&&l(o-1)},[t,s,o]),u=()=>{const h={name:`mode_${t.length+1}`,description:"",model:"claude-sonnet-4-20250514",timeout:300,tools:[],prompt_template:""};s([...t,h]),l(t.length)};return e.jsxs("section",{children:[e.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center",children:[e.jsx("span",{className:"w-8 h-8 rounded-full bg-primary-600 text-white flex items-center justify-center text-sm font-bold mr-3",children:"3"}),"Modes"]}),e.jsxs("div",{className:"space-y-3 pl-11",children:[e.jsx("p",{className:"text-sm text-gray-400",children:"Modes define different LLM configurations for your loop. Each iteration uses one mode based on the selection strategy."}),t.length===0?e.jsxs("div",{className:"p-4 border-2 border-dashed border-gray-600 rounded-lg text-center",children:[e.jsx("p",{className:"text-gray-400 mb-2",children:"No modes configured"}),e.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"At least one mode is required for the loop to run"})]}):e.jsx("div",{className:"space-y-2",children:t.map((h,x)=>e.jsx(J4,{mode:h,isExpanded:o===x,onToggle:()=>l(o===x?null:x),onChange:g=>i(x,g),onDelete:()=>d(x)},h.name||`unnamed_mode_${x}`))}),e.jsxs("button",{type:"button",onClick:u,className:"w-full p-3 border-2 border-dashed border-gray-600 rounded-lg text-gray-400 hover:border-gray-500 hover:text-gray-300 transition-colors flex items-center justify-center space-x-2",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),e.jsx("span",{children:"Add Mode"})]})]})]})}function X4({strategy:t,modes:s,onChange:o}){var h;const l=x=>{const g={strategy:x};if(x==="fixed"&&s.length>0&&(g.fixed_mode=s[0].name),x==="weighted_random"){const v={},y=Math.floor(100/s.length);s.forEach(b=>{v[b.name]=y}),g.weights=v}o(g)},i=x=>{o({...t,fixed_mode:x})},d=(x,g)=>{o({...t,weights:{...t.weights,[x]:g}})},u=t.weights?Object.values(t.weights).reduce((x,g)=>x+g,0):0;return e.jsxs("section",{children:[e.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center",children:[e.jsx("span",{className:"w-8 h-8 rounded-full bg-primary-600 text-white flex items-center justify-center text-sm font-bold mr-3",children:"4"}),"Mode Selection Strategy"]}),e.jsxs("div",{className:"space-y-4 pl-11",children:[e.jsx("p",{className:"text-sm text-gray-400",children:"Choose how the loop selects which mode to use for each iteration."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:"flex items-start space-x-3 p-3 bg-gray-700/50 rounded-lg border border-gray-600 cursor-pointer hover:bg-gray-700/70 transition-colors",children:[e.jsx("input",{type:"radio",name:"strategy",checked:t.strategy==="fixed",onChange:()=>l("fixed"),className:"mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-white",children:"Fixed"}),e.jsx("div",{className:"text-xs text-gray-400 mt-1",children:"Always use the same mode for every iteration"}),t.strategy==="fixed"&&s.length>0&&e.jsx("select",{value:t.fixed_mode||((h=s[0])==null?void 0:h.name)||"",onChange:x=>i(x.target.value),className:"mt-2 w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-sm text-white focus:outline-none focus:border-primary-500",children:s.map(x=>e.jsx("option",{value:x.name,children:x.name},x.name))})]})]}),e.jsxs("label",{className:"flex items-start space-x-3 p-3 bg-gray-700/50 rounded-lg border border-gray-600 cursor-pointer hover:bg-gray-700/70 transition-colors",children:[e.jsx("input",{type:"radio",name:"strategy",checked:t.strategy==="random",onChange:()=>l("random"),className:"mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-white",children:"Random"}),e.jsx("div",{className:"text-xs text-gray-400 mt-1",children:"Randomly select a mode with equal probability"})]})]}),e.jsxs("label",{className:"flex items-start space-x-3 p-3 bg-gray-700/50 rounded-lg border border-gray-600 cursor-pointer hover:bg-gray-700/70 transition-colors",children:[e.jsx("input",{type:"radio",name:"strategy",checked:t.strategy==="weighted_random",onChange:()=>l("weighted_random"),className:"mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-white",children:"Weighted Random"}),e.jsx("div",{className:"text-xs text-gray-400 mt-1",children:"Randomly select a mode based on specified weights"}),t.strategy==="weighted_random"&&s.length>0&&e.jsxs("div",{className:"mt-3 space-y-2",children:[s.map(x=>{var y;const g=((y=t.weights)==null?void 0:y[x.name])||0,v=u>0?(g/u*100).toFixed(0):0;return e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("span",{className:"text-sm text-gray-300 w-24 truncate",title:x.name,children:x.name}),e.jsx("input",{type:"range",min:0,max:100,value:g,onChange:b=>d(x.name,parseInt(b.target.value)),className:"flex-1 h-2 bg-gray-600 rounded-lg appearance-none cursor-pointer accent-primary-500"}),e.jsxs("span",{className:"text-sm text-gray-400 w-16 text-right",children:[v,"%"]})]},x.name)}),u!==100&&e.jsx("p",{className:"text-xs text-yellow-400 mt-2",children:"Weights will be normalized to 100%"})]})]})]})]}),s.length===0&&e.jsx("p",{className:"text-sm text-yellow-400",children:"Add at least one mode to configure the selection strategy"})]})]})}function Z4({limits:t,onChange:s}){const o=(i,d)=>{s({...t,[i]:d})},l=i=>{if(i<60)return`${i}s`;if(i<3600)return`${Math.floor(i/60)}m`;const d=Math.floor(i/3600),u=Math.floor(i%3600/60);return u>0?`${d}h ${u}m`:`${d}h`};return e.jsxs("section",{children:[e.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center",children:[e.jsx("span",{className:"w-8 h-8 rounded-full bg-primary-600 text-white flex items-center justify-center text-sm font-bold mr-3",children:"5"}),"Execution Limits"]}),e.jsxs("div",{className:"space-y-4 pl-11",children:[e.jsx("p",{className:"text-sm text-gray-400",children:"Set safety limits to prevent runaway loops and manage resource usage."}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-4 bg-gray-700/50 rounded-lg border border-gray-600",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:["Max Iterations",e.jsx(zr,{content:Hr.maxIterations.body,size:"sm",className:"ml-1"})]}),e.jsx("input",{type:"number",value:t.max_iterations,onChange:i=>o("max_iterations",parseInt(i.target.value)||0),min:0,max:1e4,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white focus:outline-none focus:border-primary-500"}),e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:t.max_iterations===0?"Unlimited iterations":`Loop will stop after ${t.max_iterations} iterations`})]}),e.jsxs("div",{className:"p-4 bg-gray-700/50 rounded-lg border border-gray-600",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:["Max Runtime",e.jsx(zr,{content:Hr.maxRuntime.body,size:"sm",className:"ml-1"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"number",value:t.max_runtime_seconds,onChange:i=>o("max_runtime_seconds",parseInt(i.target.value)||0),min:0,max:86400,className:"flex-1 px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white focus:outline-none focus:border-primary-500"}),e.jsx("span",{className:"text-sm text-gray-400",children:"seconds"})]}),e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:t.max_runtime_seconds===0?"Unlimited runtime":`Loop will stop after ${l(t.max_runtime_seconds)}`})]}),e.jsxs("div",{className:"p-4 bg-gray-700/50 rounded-lg border border-gray-600",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:["Max Consecutive Errors",e.jsx(zr,{content:Hr.maxErrors.body,size:"sm",className:"ml-1"})]}),e.jsx("input",{type:"number",value:t.max_consecutive_errors,onChange:i=>o("max_consecutive_errors",parseInt(i.target.value)||1),min:1,max:100,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white focus:outline-none focus:border-primary-500"}),e.jsxs("p",{className:"mt-2 text-xs text-gray-500",children:["Loop stops if ",t.max_consecutive_errors," errors occur in a row"]})]}),e.jsxs("div",{className:"p-4 bg-gray-700/50 rounded-lg border border-gray-600",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:["Cooldown Between Iterations",e.jsx(zr,{content:Hr.cooldown.body,size:"sm",className:"ml-1"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"number",value:t.cooldown_between_iterations,onChange:i=>o("cooldown_between_iterations",parseInt(i.target.value)||0),min:0,max:3600,className:"flex-1 px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white focus:outline-none focus:border-primary-500"}),e.jsx("span",{className:"text-sm text-gray-400",children:"seconds"})]}),e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"Wait time between each iteration"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-2",children:[e.jsx("span",{className:"text-sm text-gray-400 mr-2",children:"Quick presets:"}),e.jsx("button",{type:"button",onClick:()=>s({max_iterations:10,max_runtime_seconds:3600,max_consecutive_errors:3,cooldown_between_iterations:5}),className:"px-3 py-1 text-xs rounded bg-gray-700 text-gray-300 hover:bg-gray-600 transition-colors",children:"Quick test (10 iter)"}),e.jsx("button",{type:"button",onClick:()=>s({max_iterations:100,max_runtime_seconds:28800,max_consecutive_errors:5,cooldown_between_iterations:5}),className:"px-3 py-1 text-xs rounded bg-gray-700 text-gray-300 hover:bg-gray-600 transition-colors",children:"Standard (100 iter, 8h)"}),e.jsx("button",{type:"button",onClick:()=>s({max_iterations:0,max_runtime_seconds:86400,max_consecutive_errors:10,cooldown_between_iterations:10}),className:"px-3 py-1 text-xs rounded bg-gray-700 text-gray-300 hover:bg-gray-600 transition-colors",children:"Long run (unlimited, 24h)"})]})]})]})}function eN({content:t,error:s,onChange:o}){const[l,i]=p.useState("idle"),d=async()=>{try{await navigator.clipboard.writeText(t),i("copied"),setTimeout(()=>i("idle"),2e3)}catch{i("failed"),setTimeout(()=>i("idle"),2e3)}};return e.jsxs("div",{className:"h-full flex flex-col",children:[s&&e.jsx("div",{id:"yaml-error",role:"alert",className:"p-3 bg-red-900/30 border-b border-red-800 text-sm text-red-400",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("span",{children:s})]})}),e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-gray-700/50 border-b border-gray-700",children:[e.jsx("span",{className:"text-sm text-gray-400",children:"YAML Configuration"}),e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx("button",{type:"button",onClick:d,className:`px-2 py-1 text-xs rounded transition-colors ${l==="copied"?"bg-green-700 text-green-200":l==="failed"?"bg-red-700 text-red-200":"bg-gray-700 text-gray-300 hover:bg-gray-600"}`,title:"Copy to clipboard","aria-live":"polite",children:l==="copied"?"Copied!":l==="failed"?"Failed":"Copy"})})]}),e.jsxs("div",{className:"flex-1 p-4",children:[e.jsx("label",{htmlFor:"yaml-editor",className:"sr-only",children:"YAML Configuration Editor"}),e.jsx("textarea",{id:"yaml-editor",value:t,onChange:u=>o(u.target.value),className:`w-full h-full min-h-[400px] px-4 py-3 bg-gray-900 border rounded font-mono text-sm text-gray-200 focus:outline-none resize-none ${s?"border-red-600 focus:border-red-500":"border-gray-700 focus:border-primary-500"}`,spellCheck:!1,placeholder:"# Enter your loop configuration in YAML format...","aria-invalid":s?"true":"false","aria-describedby":s?"yaml-error":void 0})]}),e.jsx("div",{className:"p-4 bg-gray-700/30 border-t border-gray-700",children:e.jsxs("div",{className:"text-xs text-gray-500",children:[e.jsx("strong",{className:"text-gray-400",children:"Tip:"})," Fix any YAML errors before switching to the Visual Editor or saving. Valid YAML will automatically sync when you switch tabs."]})})]})}const uh={discovery:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z",execution:"M13 10V3L4 14h7v7l9-11h-7z",generation:"M12 4v16m8-8H4",processing:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"},tN={generator:"bg-green-600",consumer:"bg-blue-600",hybrid:"bg-purple-600"};function rN({onSelect:t,onClose:s}){const[o,l]=p.useState([]),[i,d]=p.useState(!0),[u,h]=p.useState(null),[x,g]=p.useState(null),[v,y]=p.useState(!1),b=p.useRef(null),k=p.useRef(null),_=p.useCallback(T=>{T.key==="Escape"&&s()},[s]);p.useEffect(()=>{S()},[]),p.useEffect(()=>{var T;return document.addEventListener("keydown",_),(T=k.current)==null||T.focus(),()=>{document.removeEventListener("keydown",_)}},[_]);const S=async()=>{try{d(!0),h(null);const T=await pv();l(T.templates)}catch(T){h(T instanceof Error?T.message:"Failed to load templates")}finally{d(!1)}},j=async T=>{try{g(T),y(!0);const P=await xv(T);t(P.config,P.config_yaml)}catch(P){h(P instanceof Error?P.message:"Failed to load template"),g(null)}finally{y(!1)}},N=()=>{t({},"")};return e.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",role:"dialog","aria-modal":"true","aria-labelledby":"template-selector-title",children:e.jsxs("div",{ref:b,className:"bg-gray-800 rounded-lg w-full max-w-3xl max-h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b border-gray-700 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{id:"template-selector-title",className:"text-lg font-semibold text-white",children:"Choose a Template"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Start with a pre-configured template or create from scratch"})]}),e.jsx("button",{ref:k,onClick:s,className:"text-gray-400 hover:text-white","aria-label":"Close template selector",children:e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:i?e.jsx("div",{className:"flex items-center justify-center h-48",role:"status","aria-label":"Loading templates",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary-500"})}):u?e.jsxs("div",{className:"p-4 bg-red-900/30 border border-red-800 rounded text-red-400",role:"alert",children:[u,e.jsx("button",{onClick:S,className:"ml-2 underline hover:no-underline",children:"Retry"})]}):e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx("button",{onClick:N,className:"p-4 border-2 border-dashed border-gray-600 rounded-lg hover:border-gray-500 hover:bg-gray-700/30 transition-all text-left group",children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-gray-700 group-hover:bg-gray-600 transition-colors",children:e.jsx("svg",{className:"w-6 h-6 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-medium text-white group-hover:text-primary-400 transition-colors",children:"Start from Scratch"}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Create a custom loop configuration with all fields empty"})]})]})}),o.map(T=>e.jsx("button",{onClick:()=>j(T.name),disabled:v,className:`p-4 border border-gray-700 rounded-lg hover:border-gray-500 hover:bg-gray-700/30 transition-all text-left group ${x===T.name?"border-primary-500 bg-gray-700/50":""} ${v?"opacity-50 cursor-not-allowed":""}`,children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-gray-700 group-hover:bg-gray-600 transition-colors",children:e.jsx("svg",{className:"w-6 h-6 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:uh[T.category]||uh.generation})})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h4",{className:"font-medium text-white group-hover:text-primary-400 transition-colors",children:T.display_name}),e.jsx("span",{className:`px-2 py-0.5 text-xs rounded ${tN[T.type]||"bg-gray-600"} text-white`,children:T.type})]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:T.description}),x===T.name&&v&&e.jsxs("div",{className:"mt-2 flex items-center text-sm text-primary-400",children:[e.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Loading template..."]})]})]})},T.name))]})}),e.jsx("div",{className:"p-4 border-t border-gray-700",children:e.jsx("p",{className:"text-xs text-gray-500",children:"Templates provide pre-configured settings. You can customize all values after selection."})})]})})}function sN({projectSlug:t,loopName:s,loopType:o}){const[l,i]=p.useState(null),[d,u]=p.useState(!0),[h,x]=p.useState(null),[g,v]=p.useState(null),[y,b]=p.useState(!0),[k,_]=p.useState(null),[S,j]=p.useState([]),[N,T]=p.useState(new Set(["rendered"]));p.useEffect(()=>{o==="consumer"&&Ao(t,{status:"pending",limit:10}).then(I=>j(I.items)).catch(()=>{})},[t,o]);const P=p.useCallback(async()=>{u(!0),x(null);try{const I=await kv(t,s,{mode:g||void 0,sample_item_id:k||void 0,include_annotations:y,use_first_pending:!k});i(I)}catch(I){x(I instanceof Error?I.message:"Failed to load preview")}finally{u(!1)}},[t,s,g,k,y]);p.useEffect(()=>{P()},[P]);const C=I=>{T(M=>{const q=new Set(M);return q.has(I)?q.delete(I):q.add(I),q})},E=I=>{navigator.clipboard.writeText(I)};return d?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary-500"})}):h?e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"p-4 bg-red-900/30 border border-red-800 rounded text-red-400",children:h}),e.jsx("button",{onClick:P,className:"mt-4 px-4 py-2 bg-gray-700 text-white rounded hover:bg-gray-600",children:"Retry"})]}):l?e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"bg-gray-700/50 rounded-lg p-4",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-3",children:"Preview Options"}),e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-400 mb-1",children:"Mode"}),e.jsxs("select",{value:g||"",onChange:I=>v(I.target.value||null),className:"bg-gray-800 text-white text-sm rounded px-3 py-1.5 border border-gray-600",children:[e.jsx("option",{value:"",children:"All Modes"}),l.modes.map(I=>e.jsx("option",{value:I.mode_name,children:I.mode_name},I.mode_name))]})]}),l.loop_type==="consumer"&&S.length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-400 mb-1",children:"Sample Item"}),e.jsxs("select",{value:k||"",onChange:I=>_(I.target.value||null),className:"bg-gray-800 text-white text-sm rounded px-3 py-1.5 border border-gray-600 max-w-xs",children:[e.jsx("option",{value:"",children:"Auto (first pending)"}),S.map(I=>e.jsxs("option",{value:I.id,children:[I.content.substring(0,50),"..."]},I.id))]})]}),e.jsx("div",{className:"flex items-center",children:e.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:y,onChange:I=>b(I.target.checked),className:"rounded bg-gray-800 border-gray-600"}),e.jsx("span",{className:"text-sm text-gray-300",children:"Show Section Markers"})]})}),e.jsx("button",{onClick:P,className:"ml-auto px-3 py-1.5 bg-primary-600 text-white text-sm rounded hover:bg-primary-500",children:"Refresh Preview"})]})]}),e.jsxs("div",{className:"bg-gray-700/50 rounded-lg p-4",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-3",children:"Loop Overview"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-400",children:"Type:"}),e.jsx("span",{className:"ml-2 text-white capitalize",children:l.loop_type})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-400",children:"Strategy:"}),e.jsx("span",{className:"ml-2 text-white",children:l.mode_selection_strategy.replace("_"," ")})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-400",children:"Modes:"}),e.jsx("span",{className:"ml-2 text-white",children:l.modes.length})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-400",children:"Resources:"}),e.jsx("span",{className:"ml-2 text-white",children:l.resources_used.length})]})]}),e.jsx("p",{className:"mt-3 text-sm text-gray-400",children:l.strategy_explanation})]}),l.resources_used.length>0&&e.jsxs("div",{className:"bg-gray-700/50 rounded-lg p-4",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-2",children:"Resources Injected"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.resources_used.map(I=>e.jsx("span",{className:"px-2 py-1 text-xs bg-blue-900/30 text-blue-400 rounded",children:I},I))})]}),Object.keys(l.template_variables).length>0&&e.jsxs("div",{className:"bg-gray-700/50 rounded-lg p-4",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-2",children:"Template Variables"}),e.jsx("div",{className:"space-y-1",children:Object.entries(l.template_variables).map(([I,M])=>e.jsxs("div",{className:"flex text-sm",children:[e.jsx("code",{className:"text-yellow-400 font-mono",children:I}),e.jsx("span",{className:"mx-2 text-gray-500",children:"="}),e.jsx("span",{className:"text-gray-300 truncate",children:M})]},I))})]}),l.warnings.length>0&&e.jsxs("div",{className:"bg-yellow-900/20 border border-yellow-800/50 rounded-lg p-4",children:[e.jsx("h4",{className:"text-sm font-medium text-yellow-400 mb-2",children:"Warnings"}),e.jsx("ul",{className:"list-disc list-inside text-sm text-yellow-300 space-y-1",children:l.warnings.map((I,M)=>e.jsx("li",{children:I},M))})]}),l.modes.map(I=>e.jsx(nN,{modePreview:I,expandedSections:N,onToggleSection:C,onCopy:E},I.mode_name)),l.sample_item&&e.jsxs("div",{className:"bg-gray-700/50 rounded-lg p-4",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-2",children:"Sample Item Used"}),e.jsx("pre",{className:"text-xs text-gray-400 bg-gray-900 p-3 rounded overflow-x-auto",children:JSON.stringify(l.sample_item,null,2)})]})]}):null}function nN({modePreview:t,expandedSections:s,onToggleSection:o,onCopy:l}){const i=`rendered-${t.mode_name}`,d=`sections-${t.mode_name}`;return e.jsxs("div",{className:"bg-gray-700/50 rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-gray-600",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-white font-medium",children:t.mode_name}),e.jsxs("p",{className:"text-sm text-gray-400",children:["Model: ",t.model," | Timeout: ",t.timeout,"s | Tools: ",t.tools.length>0?t.tools.join(", "):"None"]})]}),e.jsxs("div",{className:"text-right text-sm",children:[e.jsxs("div",{className:"text-gray-300",children:["~",t.token_estimate.toLocaleString()," tokens"]}),e.jsxs("div",{className:"text-gray-500",children:[t.total_length.toLocaleString()," chars"]})]})]}),t.warnings.length>0&&e.jsx("div",{className:"mt-2 p-2 bg-yellow-900/20 rounded text-sm text-yellow-400",children:t.warnings.join(", ")})]}),e.jsxs("div",{className:"border-b border-gray-600",children:[e.jsxs("button",{onClick:()=>o(d),className:"w-full px-4 py-2 text-left text-sm text-gray-400 hover:bg-gray-600/30 flex items-center justify-between",children:[e.jsxs("span",{children:["Section Breakdown (",t.sections.length," sections)"]}),e.jsx("svg",{className:`w-4 h-4 transition-transform ${s.has(d)?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),s.has(d)&&e.jsx("div",{className:"px-4 pb-4 space-y-2",children:t.sections.map((u,h)=>e.jsxs("div",{className:"p-2 bg-gray-800 rounded text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("span",{className:"text-gray-400",children:["[",u.position.toUpperCase(),"]"]}),e.jsxs("span",{className:"text-xs text-gray-500",children:[u.source," ",u.source_name&&`(${u.source_name})`]})]}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Lines ",u.start_line,"-",u.end_line," | ",u.content.length," chars"]})]},h))})]}),e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>o(i),className:"w-full px-4 py-2 text-left text-sm text-gray-400 hover:bg-gray-600/30 flex items-center justify-between",children:[e.jsx("span",{children:"Rendered Prompt"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:u=>{u.stopPropagation(),l(t.rendered_prompt)},className:"text-xs px-2 py-1 bg-gray-600 hover:bg-gray-500 rounded",children:"Copy"}),e.jsx("svg",{className:`w-4 h-4 transition-transform ${s.has(i)?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),s.has(i)&&e.jsx("div",{className:"p-4",children:e.jsx("pre",{className:"text-xs text-gray-300 bg-gray-900 p-4 rounded overflow-x-auto whitespace-pre-wrap max-h-96 overflow-y-auto font-mono",children:t.rendered_prompt})})]})]})}function oN({projectSlug:t,loopName:s,initialYaml:o,availableLoops:l=[],onClose:i,onSave:d}){const[u,h]=p.useState("visual"),[x,g]=p.useState(Tx),[v,y]=p.useState(""),[b,k]=p.useState(null),[_,S]=p.useState(!1),[j,N]=p.useState(null),[T,P]=p.useState(""),C=!s,[E,I]=p.useState(C&&!o);p.useEffect(()=>{if(o){y(o),P(o);try{const D=Ga.load(o);g(wc(D)),k(null)}catch(D){k(D instanceof Error?D.message:"Invalid YAML")}}},[o]);const M=p.useCallback(()=>{try{const D=ih(x),R=Ga.dump(D,{indent:2,lineWidth:-1,noRefs:!0,sortKeys:!1});y(R),k(null)}catch(D){console.error("Failed to convert form state to YAML:",D)}},[x]),q=p.useCallback(()=>{if(!v.trim())return k("YAML content is empty"),!1;try{const D=Ga.load(v);return typeof D!="object"||D===null?(k("YAML must be an object"),!1):(g(wc(D)),k(null),!0)}catch(D){return k(D instanceof Error?D.message:"Invalid YAML"),!1}},[v]);p.useEffect(()=>{if(u==="visual"){const D=setTimeout(M,100);return()=>clearTimeout(D)}},[u,x,M]);const z=D=>{if(D==="yaml"&&u==="visual")M();else if(D==="visual"&&u==="yaml"){if(!q())return}else if(D==="preview"&&u==="yaml"){if(!q())return}else D==="preview"&&u==="visual"&&M();h(D)},U=p.useMemo(()=>v!==T,[v,T]),O=p.useCallback(()=>{if(!x.name.trim())return"Loop name is required";if(!/^[a-z0-9_-]+$/.test(x.name))return"Loop name must contain only lowercase letters, numbers, hyphens, and underscores";if(!x.display_name.trim())return"Display name is required";if(x.modes.length===0)return"At least one mode is required";const D=new Set;for(const R of x.modes){if(!R.name.trim())return"All modes must have a name";if(D.has(R.name))return`Duplicate mode name: "${R.name}". Each mode must have a unique name.`;if(D.add(R.name),!R.prompt_template.trim())return`Mode "${R.name}" must have a prompt template`}return x.mode_selection.strategy==="fixed"&&!x.mode_selection.fixed_mode&&x.modes.length>0?"Fixed strategy requires selecting a mode":null},[x]),X=async()=>{let D;if(u==="visual")try{const Y=ih(x);D=Ga.dump(Y,{indent:2,lineWidth:-1,noRefs:!0,sortKeys:!1}),y(D),k(null)}catch{N("Failed to generate YAML from form");return}else{if(!q()){N("Fix YAML errors before saving");return}D=v}const R=O();if(R){N(R);return}S(!0),N(null);try{await d(D)}catch(Y){N(Y instanceof Error?Y.message:"Failed to save")}finally{S(!1)}},ee=()=>{U&&!window.confirm("Discard unsaved changes?")||i()},W=p.useCallback(D=>{g(R=>({...R,...D}))},[]),te=p.useCallback((D,R)=>{I(!1),R&&Object.keys(D).length>0&&(y(R),g(wc(D)),k(null))},[]);return E?e.jsx(rN,{onSelect:te,onClose:i}):e.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-gray-800 rounded-lg w-full max-w-4xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b border-gray-700 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:C?"Create New Loop":`Edit Loop: ${s}`}),e.jsxs("p",{className:"text-sm text-gray-400",children:["Project: ",t]})]}),e.jsx("button",{onClick:ee,className:"text-gray-400 hover:text-white","aria-label":"Close",children:e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"flex border-b border-gray-700",children:[e.jsx("button",{onClick:()=>z("visual"),className:`px-6 py-3 text-sm font-medium transition-colors ${u==="visual"?"text-white border-b-2 border-primary-500 bg-gray-700/50":"text-gray-400 hover:text-white hover:bg-gray-700/30"}`,children:"Visual Editor"}),e.jsxs("button",{onClick:()=>z("yaml"),className:`px-6 py-3 text-sm font-medium transition-colors ${u==="yaml"?"text-white border-b-2 border-primary-500 bg-gray-700/50":"text-gray-400 hover:text-white hover:bg-gray-700/30"}`,children:["YAML Source",b&&e.jsx("span",{className:"ml-2 w-2 h-2 inline-block rounded-full bg-red-500",title:"YAML has errors"})]}),!C&&s&&e.jsx("button",{onClick:()=>z("preview"),className:`px-6 py-3 text-sm font-medium transition-colors ${u==="preview"?"text-white border-b-2 border-primary-500 bg-gray-700/50":"text-gray-400 hover:text-white hover:bg-gray-700/30"}`,children:"Preview"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:u==="visual"?e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsx(G4,{name:x.name,displayName:x.display_name,type:x.type,description:x.description,isNewLoop:C,onChange:D=>W(D)}),e.jsx(K4,{itemTypes:x.item_types,loopType:x.type,availableLoops:l.filter(D=>D!==x.name),onChange:D=>W({item_types:D})}),e.jsx(Q4,{modes:x.modes,onChange:D=>W({modes:D})}),e.jsx(X4,{strategy:x.mode_selection,modes:x.modes,onChange:D=>W({mode_selection:D})}),e.jsx(Z4,{limits:x.limits,onChange:D=>W({limits:D})})]}):u==="yaml"?e.jsx(eN,{content:v,error:b,onChange:y}):u==="preview"&&s?e.jsx(sN,{projectSlug:t,loopName:s,loopType:x.type}):null}),j&&e.jsx("div",{className:"px-4 pb-2",children:e.jsx("div",{className:"p-3 bg-red-900/30 border border-red-800 rounded text-sm text-red-400",children:j})}),e.jsxs("div",{className:"p-4 border-t border-gray-700 flex items-center justify-between",children:[e.jsx("div",{className:"text-sm text-gray-500",children:U?e.jsx("span",{className:"text-yellow-400",children:"Unsaved changes"}):e.jsx("span",{children:"No changes"})}),e.jsxs("div",{className:"flex space-x-3",children:[e.jsx("button",{onClick:ee,disabled:_,className:"px-4 py-2 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600 disabled:opacity-50",children:"Cancel"}),e.jsx("button",{onClick:X,disabled:_||!!b,className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500 disabled:opacity-50",children:_?"Saving...":C?"Create Loop":"Save Changes"})]})]})]})})}const aN={master_design:"Master Design",story_instructions:"Story Instructions",stories:"Stories (JSONL)",guardrails:"Guardrails",reference:"Reference"};function lN({loopType:t,onSelect:s,onCancel:o}){const[l,i]=p.useState([]),[d,u]=p.useState(!0),[h,x]=p.useState(null),[g,v]=p.useState(null),[y,b]=p.useState(null),[k,_]=p.useState(!1);p.useEffect(()=>{S()},[t]);const S=async()=>{u(!0),x(null);try{const T=await Cv(t);i(T),T.length>0&&j(T[0])}catch(T){x(T instanceof Error?T.message:"Failed to load templates")}finally{u(!1)}},j=async T=>{v(T),_(!0);try{const P=await Sv(T.id);b(P.content)}catch{b("Failed to load template content")}finally{_(!1)}},N=()=>{g&&s(g.id)};return e.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-gray-800 rounded-lg w-full max-w-4xl h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b border-gray-700 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:"Input Templates"}),e.jsxs("p",{className:"text-sm text-gray-400 mt-1",children:["Pre-curated inputs for ",t," loops"]})]}),e.jsx("button",{onClick:o,className:"p-1 text-gray-400 hover:text-white","aria-label":"Close",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsx("div",{className:"w-1/3 border-r border-gray-700 overflow-y-auto",children:d?e.jsx("div",{className:"p-4 text-gray-400",children:"Loading templates..."}):h?e.jsx("div",{className:"p-4 text-red-400",children:h}):l.length===0?e.jsxs("div",{className:"p-4 text-gray-400",children:["No templates available for ",t," loops"]}):e.jsx("div",{className:"p-2 space-y-2",children:l.map(T=>e.jsxs("button",{onClick:()=>j(T),className:`w-full text-left p-3 rounded transition-colors ${(g==null?void 0:g.id)===T.id?"bg-primary-600/30 border border-primary-500":"bg-gray-700/50 border border-transparent hover:bg-gray-700"}`,children:[e.jsx("div",{className:"font-medium text-white",children:T.name}),e.jsx("div",{className:"text-sm text-gray-400 mt-1",children:T.description}),e.jsxs("div",{className:"mt-2 flex items-center space-x-2",children:[e.jsx("span",{className:"px-2 py-0.5 text-xs bg-gray-600 rounded",children:aN[T.tag]||T.tag}),e.jsx("span",{className:"text-xs text-gray-500",children:T.filename})]})]},T.id))})}),e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsx("div",{className:"p-3 border-b border-gray-700",children:e.jsx("span",{className:"text-sm font-medium text-gray-300",children:"Preview"})}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:k?e.jsx("div",{className:"text-gray-400",children:"Loading..."}):y?e.jsx("pre",{className:"text-sm text-gray-300 whitespace-pre-wrap font-mono",children:y}):e.jsx("div",{className:"text-gray-400",children:"Select a template to preview"})})]})]}),e.jsxs("div",{className:"p-4 border-t border-gray-700 flex justify-end space-x-3",children:[e.jsx("button",{onClick:o,className:"px-4 py-2 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600",children:"Cancel"}),e.jsx("button",{onClick:N,disabled:!g,className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500 disabled:opacity-50",children:"Apply Template"})]})]})})}const No=[{value:"loop_template",label:"Loop Template",description:"The main prompt that drives this loop - tells Claude what to do",position:"template_body"},{value:"design_doc",label:"Design Doc",description:"Project requirements, specs, or PRD - gives Claude context about what to build",position:"after_design_doc"},{value:"guardrails",label:"Guardrails",description:"Quality rules and constraints - keeps Claude on track",position:"before_task"},{value:"custom",label:"Custom Resource",description:"Any other context you want to inject into the prompt",position:"after_task"}],iN=[{value:"system",label:"Use Default",description:"Use the built-in RalphX template",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})},{value:"project_file",label:"From Project",description:"Import from your codebase",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})})},{value:"loop_ref",label:"From Loop",description:"Reference another loop",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})},{value:"inline",label:"Write Custom",description:"Create from scratch",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}],bc={loop_template:e.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),design_doc:e.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),guardrails:e.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})}),custom:e.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4"})})};function cN({addForm:t,setAddForm:s,onClose:o,onCreate:l,openFileBrowser:i,otherLoops:d,loopResources:u}){const[h,x]=p.useState("type"),g=No.find(_=>_.value===t.resource_type),v=t.resource_type==="loop_template"||t.resource_type==="guardrails",y=()=>t.source_type==="system"?!0:t.source_type==="project_file"?!!t.source_path:t.source_type==="loop_ref"?!!t.source_loop&&!!t.source_resource_id:t.source_type==="inline"?!!t.inline_content:!1,b=()=>{h==="config"?x("source"):h==="source"&&x("type")},k=()=>{h==="type"?x("source"):h==="source"&&(t.source_type==="system"?l():x("config"))};return e.jsx("div",{className:"fixed inset-0 bg-black/70 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-[#1a1d23] rounded-xl w-full max-w-2xl shadow-2xl border border-gray-800/50 overflow-hidden",style:{animation:"modalSlideIn 0.2s ease-out"},children:[e.jsx("style",{children:`
170
- @keyframes modalSlideIn {
171
- from { opacity: 0; transform: scale(0.95) translateY(10px); }
172
- to { opacity: 1; transform: scale(1) translateY(0); }
173
- }
174
- @keyframes fadeIn {
175
- from { opacity: 0; transform: translateX(10px); }
176
- to { opacity: 1; transform: translateX(0); }
177
- }
178
- .step-content { animation: fadeIn 0.15s ease-out; }
179
- `}),e.jsxs("div",{className:"px-6 py-4 border-b border-gray-800/50 flex items-center justify-between bg-gradient-to-r from-gray-900/50 to-transparent",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-white tracking-tight",children:"Add Resource"}),e.jsx("div",{className:"flex items-center gap-1.5",children:["type","source","config"].map((_,S)=>e.jsx("div",{className:`h-1.5 rounded-full transition-all duration-300 ${_===h?"w-6 bg-blue-500":["type","source","config"].indexOf(h)>S?"w-1.5 bg-blue-500/50":"w-1.5 bg-gray-700"}`},_))})]}),e.jsx("button",{onClick:o,className:"p-1.5 text-gray-500 hover:text-white hover:bg-gray-800 rounded-lg transition-colors",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"p-6",children:[h==="type"&&e.jsxs("div",{className:"step-content",children:[e.jsx("p",{className:"text-gray-400 text-sm mb-5",children:"What are you adding?"}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:No.map(_=>e.jsxs("button",{onClick:()=>s({...t,resource_type:_.value}),className:`group relative p-4 rounded-lg text-left transition-all duration-150 ${t.resource_type===_.value?"bg-blue-500/10 border-2 border-blue-500/50 shadow-lg shadow-blue-500/10":"bg-gray-800/30 border border-gray-700/50 hover:border-gray-600 hover:bg-gray-800/50"}`,children:[e.jsx("div",{className:`mb-3 p-2 rounded-lg inline-block ${t.resource_type===_.value?"bg-blue-500/20 text-blue-400":"bg-gray-700/50 text-gray-400 group-hover:text-gray-300"}`,children:bc[_.value]}),e.jsx("div",{className:"font-medium text-white mb-1",children:_.label}),e.jsx("div",{className:"text-xs text-gray-500 leading-relaxed",children:_.description}),t.resource_type===_.value&&e.jsx("div",{className:"absolute top-3 right-3 w-2 h-2 rounded-full bg-blue-500"})]},_.value))})]}),h==="source"&&e.jsxs("div",{className:"step-content",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx("div",{className:"p-1.5 rounded bg-blue-500/20 text-blue-400",children:bc[t.resource_type]}),e.jsxs("span",{className:"text-sm text-gray-400",children:[g==null?void 0:g.label," ",e.jsx("span",{className:"text-gray-600",children:"→"})," Choose source"]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:iN.filter(_=>_.value!=="system"||v).map(_=>e.jsxs("button",{onClick:()=>s({...t,source_type:_.value}),className:`group p-4 rounded-lg text-left transition-all duration-150 ${t.source_type===_.value?"bg-blue-500/10 border-2 border-blue-500/50":"bg-gray-800/30 border border-gray-700/50 hover:border-gray-600 hover:bg-gray-800/50"}`,children:[e.jsx("div",{className:`mb-2 ${t.source_type===_.value?"text-blue-400":"text-gray-500 group-hover:text-gray-400"}`,children:_.icon}),e.jsx("div",{className:"font-medium text-white text-sm",children:_.label}),e.jsx("div",{className:"text-xs text-gray-500 mt-0.5",children:_.description})]},_.value))}),t.source_type==="project_file"&&e.jsx("div",{className:"mt-4 pt-4 border-t border-gray-800/50",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:t.source_path,onChange:_=>s({...t,source_path:_.target.value}),placeholder:"path/to/file.md",className:"flex-1 px-3 py-2.5 bg-gray-900/50 text-white rounded-lg border border-gray-700/50 focus:border-blue-500/50 focus:outline-none focus:ring-1 focus:ring-blue-500/30 text-sm font-mono placeholder-gray-600"}),e.jsx("button",{onClick:i,className:"px-4 py-2.5 bg-gray-700/50 text-white rounded-lg hover:bg-gray-700 transition-colors text-sm font-medium",children:"Browse"})]})}),t.source_type==="loop_ref"&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-800/50 space-y-3",children:[e.jsxs("select",{value:t.source_loop,onChange:_=>s({...t,source_loop:_.target.value,source_resource_id:null}),className:"w-full px-3 py-2.5 bg-gray-900/50 text-white rounded-lg border border-gray-700/50 focus:border-blue-500/50 focus:outline-none text-sm",children:[e.jsx("option",{value:"",children:"Select a loop..."}),d.map(_=>e.jsx("option",{value:_.name,children:_.display_name||_.name},_.name))]}),t.source_loop&&u.length>0&&e.jsxs("select",{value:t.source_resource_id||"",onChange:_=>s({...t,source_resource_id:_.target.value?parseInt(_.target.value):null}),className:"w-full px-3 py-2.5 bg-gray-900/50 text-white rounded-lg border border-gray-700/50 focus:border-blue-500/50 focus:outline-none text-sm",children:[e.jsx("option",{value:"",children:"Select a resource..."}),u.map(_=>e.jsxs("option",{value:_.id,children:[_.name," (",_.resource_type,")"]},_.id))]})]}),t.source_type==="inline"&&e.jsx("div",{className:"mt-4 pt-4 border-t border-gray-800/50",children:e.jsx("textarea",{value:t.inline_content,onChange:_=>s({...t,inline_content:_.target.value}),placeholder:"# Your content here...",rows:6,className:"w-full px-3 py-2.5 bg-gray-900/50 text-white rounded-lg border border-gray-700/50 focus:border-blue-500/50 focus:outline-none focus:ring-1 focus:ring-blue-500/30 text-sm font-mono placeholder-gray-600 resize-none"})})]}),h==="config"&&e.jsxs("div",{className:"step-content",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx("div",{className:"p-1.5 rounded bg-blue-500/20 text-blue-400",children:bc[t.resource_type]}),e.jsxs("span",{className:"text-sm text-gray-400",children:[g==null?void 0:g.label," ",e.jsx("span",{className:"text-gray-600",children:"→"})," Final details"]})]}),e.jsxs("div",{className:"bg-gray-800/30 rounded-lg p-4 border border-gray-700/30 mb-4",children:[e.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wider mb-1",children:"Source"}),e.jsxs("div",{className:"text-white font-mono text-sm",children:[t.source_type==="project_file"&&t.source_path,t.source_type==="loop_ref"&&`${t.source_loop} → resource`,t.source_type==="inline"&&`${t.inline_content.slice(0,50)}...`]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 uppercase tracking-wider mb-2",children:"Name (optional)"}),e.jsx("input",{type:"text",value:t.name,onChange:_=>s({...t,name:_.target.value}),placeholder:"Auto-generated if empty",className:"w-full px-3 py-2.5 bg-gray-900/50 text-white rounded-lg border border-gray-700/50 focus:border-blue-500/50 focus:outline-none focus:ring-1 focus:ring-blue-500/30 text-sm placeholder-gray-600"})]})]})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-800/50 flex items-center justify-between bg-gray-900/30",children:[e.jsx("button",{onClick:h==="type"?o:b,className:"px-4 py-2 text-gray-400 hover:text-white transition-colors text-sm",children:h==="type"?"Cancel":"← Back"}),h==="config"?e.jsx("button",{onClick:l,className:"px-5 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-500 transition-colors text-sm font-medium",children:"Add Resource"}):e.jsx("button",{onClick:k,disabled:h==="source"&&!y()&&t.source_type!=="system",className:"px-5 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-500 transition-colors text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:h==="source"&&t.source_type==="system"?"Add Resource":"Continue →"})]})]})})}function dN({projectSlug:t,loopName:s,loopType:o}){const[l,i]=p.useState([]),[d,u]=p.useState(!0),[h,x]=p.useState(null),[g,v]=p.useState(!1),[y,b]=p.useState({resource_type:"design_doc",name:"",source_type:"project_file",source_path:"",source_loop:"",source_resource_id:null,inline_content:""}),[k,_]=p.useState(!1),[S,j]=p.useState(""),[N,T]=p.useState([]),[P,C]=p.useState([]),[E,I]=p.useState(!1),[M,q]=p.useState(null),[z,U]=p.useState([]),[O,X]=p.useState([]),[ee,W]=p.useState(null),[te,D]=p.useState(""),R=p.useCallback(async()=>{u(!0),x(null);try{const se=await E0(t,s,!0);i(se)}catch(se){x(se instanceof Error?se.message:"Failed to load resources")}finally{u(!1)}},[t,s]);p.useEffect(()=>{R()},[R]),p.useEffect(()=>{async function se(){try{const Ne=await qc(t);U(Ne.filter(Le=>Le.name!==s))}catch{}}se()},[t,s]),p.useEffect(()=>{async function se(){if(y.source_loop)try{const Ne=await E0(t,y.source_loop,!1);X(Ne)}catch{X([])}else X([])}se()},[t,y.source_loop]);const Y=async()=>{_(!0);try{const se=await mc(t);j(se.relative_path||""),T(se.directories),C(se.files),I(se.canGoUp),q(se.parent)}catch(se){x(se instanceof Error?se.message:"Failed to browse files")}},ie=async se=>{try{const Ne=S?`${S}/${se}`:se,Le=await mc(t,Ne);j(Le.relative_path||Ne),T(Le.directories),C(Le.files),I(Le.canGoUp),q(Le.parent)}catch(Ne){x(Ne instanceof Error?Ne.message:"Failed to navigate")}},re=async()=>{if(M!==null)try{const se=await mc(t,M||void 0);j(se.relative_path||""),T(se.directories),C(se.files),I(se.canGoUp),q(se.parent)}catch(se){x(se instanceof Error?se.message:"Failed to navigate")}},L=se=>{const Ne=S?`${S}/${se}`:se;b({...y,source_path:Ne,name:se.replace(/\.[^/.]+$/,"")}),_(!1)},F=async()=>{const se=No.find(Le=>Le.value===y.resource_type),Ne={resource_type:y.resource_type,name:y.name||y.resource_type,injection_position:(se==null?void 0:se.position)||"after_design_doc",source_type:y.source_type};y.source_type==="project_file"?Ne.source_path=y.source_path:y.source_type==="loop_ref"?(Ne.source_loop=y.source_loop,Ne.source_resource_id=y.source_resource_id||void 0):y.source_type==="inline"&&(Ne.inline_content=y.inline_content);try{await Rv(t,s,Ne),await R(),v(!1),b({resource_type:"design_doc",name:"",source_type:"project_file",source_path:"",source_loop:"",source_resource_id:null,inline_content:""})}catch(Le){x(Le instanceof Error?Le.message:"Failed to create resource")}},H=async se=>{try{await T0(t,s,se.id,{enabled:!se.enabled}),await R()}catch(Ne){x(Ne instanceof Error?Ne.message:"Failed to update")}},K=async se=>{se.source_type==="inline"&&(W(se),D(se.content||""))},J=async()=>{if(ee)try{await T0(t,s,ee.id,{inline_content:te}),await R(),W(null)}catch(se){x(se instanceof Error?se.message:"Failed to save")}},he=async se=>{if(window.confirm(`Remove "${se.name}"? This won't delete any project files.`))try{await Iv(t,s,se.id),await R()}catch(Ne){x(Ne instanceof Error?Ne.message:"Failed to delete")}},_e=se=>{switch(se.source_type){case"system":return"Using default template";case"project_file":return se.source_path||"From project file";case"loop_ref":return`From loop: ${se.source_loop}`;case"project_resource":return"From project resource";case"inline":return"Custom content";default:return se.source_type}},Pe=o==="planning"?["loop_template","design_doc","guardrails"]:o==="implementation"?["loop_template","design_doc","guardrails"]:["loop_template"],pe=se=>l.some(Ne=>Ne.resource_type===se&&Ne.enabled);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:"Loop Resources"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Resources are injected into the prompt when this loop runs"})]}),e.jsx("button",{onClick:()=>v(!0),className:"px-3 py-1.5 text-sm bg-primary-600 text-white rounded hover:bg-primary-500",children:"Add Resource"})]}),e.jsxs("div",{className:"p-4 bg-gray-800/50 rounded-lg border border-gray-700",children:[e.jsx("h4",{className:"text-sm font-medium text-white mb-3",children:"Quick Setup"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Pe.map(se=>{const Ne=No.find(ot=>ot.value===se),Le=pe(se);return e.jsxs("button",{onClick:()=>{Le||(b({resource_type:se,name:"",source_type:se==="loop_template"||se==="guardrails"?"system":"project_file",source_path:"",source_loop:"",source_resource_id:null,inline_content:""}),v(!0))},disabled:Le,className:`flex items-center gap-2 px-3 py-1.5 rounded text-sm transition-all ${Le?"bg-green-900/30 border border-green-800 text-green-400 cursor-default":"bg-gray-700 border border-gray-600 text-gray-400 hover:bg-gray-600 hover:text-gray-300 cursor-pointer"}`,children:[Le?e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),e.jsx("span",{children:(Ne==null?void 0:Ne.label)||se})]},se)})})]}),h&&e.jsxs("div",{className:"p-3 bg-red-900/30 border border-red-800 rounded text-sm text-red-400",children:[h,e.jsx("button",{onClick:()=>x(null),className:"ml-2 underline",children:"Dismiss"})]}),d?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary-500"})}):l.length===0?e.jsxs("div",{className:"text-center py-8 text-gray-400 bg-gray-800/30 rounded-lg border border-dashed border-gray-700",children:[e.jsx("p",{className:"mb-2",children:"No resources configured for this loop yet."}),e.jsx("p",{className:"text-sm",children:"Add a loop template and design doc to get started."})]}):e.jsx("div",{className:"space-y-3",children:l.map(se=>{var Ne;return e.jsx("div",{className:`p-4 rounded-lg border ${se.enabled?"bg-gray-800/50 border-gray-700":"bg-gray-800/20 border-gray-800 opacity-60"}`,children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("button",{onClick:()=>H(se),className:`mt-1 w-4 h-4 rounded border flex-shrink-0 ${se.enabled?"bg-green-500 border-green-500":"bg-transparent border-gray-500"}`,title:se.enabled?"Enabled - click to disable":"Disabled - click to enable"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-white font-medium",children:se.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-gray-700 text-gray-400",children:((Ne=No.find(Le=>Le.value===se.resource_type))==null?void 0:Ne.label)||se.resource_type})]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:_e(se)}),se.content&&e.jsxs("p",{className:"text-xs text-gray-600 mt-1 truncate max-w-lg",children:[se.content.slice(0,100),"..."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[se.source_type==="inline"&&e.jsx("button",{onClick:()=>K(se),className:"px-2 py-1 text-xs bg-gray-700 text-white rounded hover:bg-gray-600",children:"Edit"}),e.jsx("button",{onClick:()=>he(se),className:"px-2 py-1 text-xs bg-red-900/30 text-red-400 rounded hover:bg-red-900/50",children:"Remove"})]})]})},se.id)})}),g&&e.jsx(cN,{addForm:y,setAddForm:b,onClose:()=>v(!1),onCreate:F,openFileBrowser:Y,otherLoops:z,loopResources:O}),k&&e.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",children:e.jsxs("div",{className:"bg-gray-800 rounded-lg w-full max-w-md mx-4",children:[e.jsxs("div",{className:"p-4 border-b border-gray-700 flex justify-between items-center",children:[e.jsx("h4",{className:"font-medium text-white",children:"Select File"}),e.jsx("button",{onClick:()=>_(!1),className:"text-gray-400 hover:text-white",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"p-4",children:[e.jsx("div",{className:"text-sm text-gray-400 mb-2",children:S||"/ (project root)"}),e.jsxs("div",{className:"max-h-64 overflow-y-auto space-y-1",children:[E&&e.jsx("button",{onClick:re,className:"w-full text-left px-3 py-2 bg-gray-700 rounded hover:bg-gray-600 text-gray-300",children:".."}),N.map(se=>e.jsxs("button",{onClick:()=>ie(se),className:"w-full text-left px-3 py-2 bg-gray-700 rounded hover:bg-gray-600 text-white",children:[se,"/"]},se)),P.map(se=>e.jsx("button",{onClick:()=>L(se.name),className:"w-full text-left px-3 py-2 bg-gray-700 rounded hover:bg-gray-600 text-white",children:se.name},se.name))]})]})]})}),ee&&e.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-gray-800 rounded-lg w-full max-w-3xl mx-4 max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b border-gray-700 flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Edit: ",ee.name]}),e.jsx("button",{onClick:()=>W(null),className:"text-gray-400 hover:text-white",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"flex-1 p-4 overflow-y-auto",children:e.jsx("textarea",{value:te,onChange:se=>D(se.target.value),className:"w-full h-80 bg-gray-900 text-white font-mono text-sm p-4 rounded border border-gray-700"})}),e.jsxs("div",{className:"p-4 border-t border-gray-700 flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>W(null),className:"px-4 py-2 text-gray-400 hover:text-white",children:"Cancel"}),e.jsx("button",{onClick:J,className:"px-4 py-2 bg-primary-600 text-white rounded hover:bg-primary-500",children:"Save"})]})]})})]})}function uN({projectSlug:t,loopName:s,onClose:o,onComplete:l}){const[i,d]=p.useState("analyzing"),[u,h]=p.useState([]),[x,g]=p.useState({}),[v,y]=p.useState(""),[b,k]=p.useState(null),[_,S]=p.useState(0),j=p.useCallback(E=>{E.key==="Escape"&&i!=="saving"&&i!=="analyzing"&&o()},[o,i]);p.useEffect(()=>(document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)),[j]),p.useEffect(()=>{let E=!1,I=null;const M=z=>{if(z.status==="ready")return d("ready"),y(z.assessment||"Ready to start"),!0;if(z.status==="questions"){const U=Array.isArray(z.questions)?z.questions:[];if(U.length===0)d("ready"),y(z.assessment||"No clarifications needed");else{d("questions"),h(U),y(z.assessment||"");const O={};U.forEach(X=>{O[X.id]=""}),g(O)}return!0}else return z.status==="analyzing"?!1:(d("error"),k(`Unexpected response status: ${z.status}`),!0)},q=async()=>{try{const z=await dv(t,s);if(E)return;!M(z)&&!E&&(I=setTimeout(q,2e3))}catch(z){if(E)return;d("error"),k(z instanceof Error?z.message:"Failed to run ready check")}};return q(),()=>{E=!0,I&&clearTimeout(I)}},[t,s,_]);const N=(E,I)=>{g(M=>({...M,[E]:I}))},T=u.every(E=>{var I;return(I=x[E.id])==null?void 0:I.trim()}),P=async E=>{if(T){d("saving");try{const I=u.map(M=>({question_id:M.id,answer:x[M.id]}));await uv(t,s,u,I),l(E)}catch(I){d("error"),k(I instanceof Error?I.message:"Failed to save answers")}}},C=E=>{E.target===E.currentTarget&&i!=="saving"&&i!=="analyzing"&&o()};return e.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:C,children:e.jsxs("div",{className:"bg-gray-800 rounded-lg max-w-2xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-700",children:[e.jsx("h2",{className:"text-xl font-semibold text-white",children:"Pre-Flight Ready Check"}),i!=="saving"&&i!=="analyzing"&&e.jsx("button",{onClick:o,className:"text-gray-400 hover:text-white text-2xl leading-none","aria-label":"Close modal",children:"×"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[i==="analyzing"&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"animate-spin w-8 h-8 border-2 border-primary-500 border-t-transparent rounded-full mx-auto mb-4"}),e.jsx("p",{className:"text-gray-300",children:"Analyzing loop configuration..."}),e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Claude is reviewing your resources and configuration"})]}),i==="ready"&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 bg-green-500/20 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx("svg",{className:"w-8 h-8 text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"Ready to Start"}),e.jsx("p",{className:"text-gray-400",children:v})]}),i==="questions"&&e.jsxs("div",{className:"space-y-6",children:[v&&e.jsx("div",{className:"bg-gray-700/50 rounded-lg p-4 mb-4",children:e.jsx("p",{className:"text-sm text-gray-300",children:v})}),e.jsxs("p",{className:"text-gray-300",children:["Claude has ",u.length," question",u.length!==1?"s":""," before starting:"]}),u.map((E,I)=>e.jsxs("div",{className:"bg-gray-700/30 rounded-lg p-4",children:[e.jsx("div",{className:"flex items-start gap-3 mb-3",children:e.jsxs("span",{className:"bg-primary-500/20 text-primary-400 px-2 py-0.5 rounded text-sm font-medium",children:[I+1,". ",E.category]})}),e.jsxs("div",{className:"bg-gray-800 rounded p-3 mb-3",children:[e.jsx("p",{className:"text-gray-200",children:E.question}),E.context&&e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:E.context})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Your answer:"}),e.jsx("textarea",{value:x[E.id]||"",onChange:M=>N(E.id,M.target.value),className:"w-full bg-gray-700 border border-gray-600 rounded px-3 py-2 text-white resize-none",rows:3,maxLength:1e4,placeholder:"Enter your answer..."})]})]},E.id))]}),i==="saving"&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"animate-spin w-8 h-8 border-2 border-primary-500 border-t-transparent rounded-full mx-auto mb-4"}),e.jsx("p",{className:"text-gray-300",children:"Saving your answers..."})]}),i==="error"&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 bg-red-500/20 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx("svg",{className:"w-8 h-8 text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),e.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"Error"}),e.jsx("p",{className:"text-red-400",children:b}),e.jsxs("div",{className:"mt-4 flex justify-center gap-3",children:[e.jsx("button",{onClick:o,className:"px-4 py-2 bg-gray-700 hover:bg-gray-600 rounded text-white",children:"Close"}),e.jsx("button",{onClick:()=>{k(null),d("analyzing"),S(E=>E+1)},className:"px-4 py-2 bg-primary-600 hover:bg-primary-500 rounded text-white",children:"Retry"})]})]})]}),(i==="questions"||i==="ready")&&e.jsxs("div",{className:"px-6 py-4 border-t border-gray-700 flex justify-end gap-3",children:[i==="ready"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:o,className:"px-4 py-2 text-gray-400 hover:text-white",children:"Close"}),e.jsx("button",{onClick:()=>l(!0),className:"px-4 py-2 bg-primary-600 hover:bg-primary-500 rounded text-white",children:"Start Loop"})]}),i==="questions"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:o,className:"px-4 py-2 text-gray-400 hover:text-white",children:"Cancel"}),e.jsx("button",{onClick:()=>P(!1),disabled:!T,className:"px-4 py-2 bg-gray-700 hover:bg-gray-600 rounded text-white disabled:opacity-50 disabled:cursor-not-allowed",children:"Save Without Starting"}),e.jsx("button",{onClick:()=>P(!0),disabled:!T,className:"px-4 py-2 bg-primary-600 hover:bg-primary-500 rounded text-white disabled:opacity-50 disabled:cursor-not-allowed",children:"Save & Start Loop"})]})]})]})})}const us={background:"#1f2937",text:"#f3f4f6",confirmButton:"#8b5cf6",cancelButton:"#4b5563",denyButton:"#ef4444"},jd={background:us.background,color:us.text,confirmButtonColor:us.confirmButton,cancelButtonColor:us.cancelButton,denyButtonColor:us.denyButton},vo=rt.mixin({toast:!0,position:"bottom-right",showConfirmButton:!1,timer:5e3,timerProgressBar:!0,...jd,didOpen:t=>{t.onmouseenter=rt.stopTimer,t.onmouseleave=rt.resumeTimer}}),mh=rt.mixin({...jd,showCancelButton:!0,confirmButtonText:"Confirm",cancelButtonText:"Cancel",reverseButtons:!0}),jc={success:(t,s)=>vo.fire({icon:"success",title:s||t,text:s?t:void 0}),error:(t,s)=>vo.fire({icon:"error",title:s||"Error",text:t}),warning:(t,s)=>vo.fire({icon:"warning",title:s||t,text:s?t:void 0}),info:(t,s)=>vo.fire({icon:"info",title:s||t,text:s?t:void 0}),loopComplete:(t,s,o)=>{const l={success:"success",stopped:"warning",error:"error"},i={success:"Loop Completed",stopped:"Loop Stopped",error:"Loop Error"};return vo.fire({icon:l[o],title:i[o],text:`${t} finished at iteration ${s}`})}},mN={simple:(t,s)=>mh.fire({title:t,text:s,icon:"question"}),danger:(t,s)=>mh.fire({title:t,text:s,icon:"warning",confirmButtonColor:us.denyButton,confirmButtonText:"Delete"}),typeToDelete:async(t,s="item")=>(await rt.fire({...jd,title:`Delete ${s}?`,html:`
180
- <div style="text-align: left; color: ${us.text};">
181
- <div style="background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3); border-radius: 8px; padding: 12px; margin-bottom: 16px;">
182
- <p style="color: #f87171; margin: 0; font-size: 14px;">
183
- This action cannot be undone. This will permanently delete the ${s} and all associated data.
184
- </p>
185
- </div>
186
- <p style="margin-bottom: 8px;">
187
- To confirm, type: <code style="background: #374151; padding: 2px 8px; border-radius: 4px; color: #f87171;">${t}</code>
188
- </p>
189
- </div>
190
- `,input:"text",inputPlaceholder:`Type ${s} name to confirm`,inputAttributes:{autocapitalize:"off",autocomplete:"off"},showCancelButton:!0,confirmButtonText:"Delete",confirmButtonColor:us.denyButton,cancelButtonText:"Cancel",reverseButtons:!0,preConfirm:l=>l!==t?(rt.showValidationMessage(`Please type "${t}" to confirm`),!1):!0})).isConfirmed},hh={master_design:"Master Design",story_instructions:"Story Instructions",stories:"Stories (JSONL)",guardrails:"Guardrails",reference:"Reference"};function hN(){const{slug:t,loopName:s}=yr(),o=ir(),{selectedProject:l,setSelectedProject:i,items:d,itemsTotal:u,itemsLoading:h,setItems:x,setItemsLoading:g}=Tr(),[v,y]=p.useState(null),[b,k]=p.useState(null),[_,S]=p.useState(null),[j,N]=p.useState(null),[T,P]=p.useState(!1),[C,E]=p.useState(""),[I,M]=p.useState([]),[q,z]=p.useState("overview"),[U,O]=p.useState([]),[X,ee]=p.useState(!1),[W,te]=p.useState(!1),[D,R]=p.useState(""),[Y,ie]=p.useState(""),[re,L]=p.useState(""),[F,H]=p.useState(!1),[K,J]=p.useState(!1),[he,_e]=p.useState(null),[Ae,Pe]=p.useState(!1),[pe,se]=p.useState(null),Ne=p.useRef(null),[Le,ot]=p.useState(null),[wt,ae]=p.useState(!1),[Ee,Ve]=p.useState(""),[at,xt]=p.useState(""),[bt,ue]=p.useState(0),[$e,Pt]=p.useState([]),lt=p.useCallback(async()=>{if(!(!t||!s))try{const ne=await Ih(t,s);k(ne)}catch{k({is_running:!1})}},[t,s]),cr=p.useCallback(async(ne=!1)=>{if(!t||!s)return;g(!0);const Me=ne?0:bt;ne&&ue(0);try{const Ie=await Ao(t,{status:Ee||void 0,category:at||void 0,limit:50,offset:Me});x(Me===0?Ie.items:[...d,...Ie.items],Ie.total);const be=new Set;Ie.items.forEach(Be=>{Be.category&&be.add(Be.category)}),Pt(Me===0?Array.from(be).sort():Be=>Array.from(new Set([...Be,...be])).sort())}catch{x([],0)}finally{g(!1)}},[t,s,x,g,Ee,at,bt,d]),jt=p.useCallback(async()=>{if(!(!t||!s||!v)){ee(!0);try{const ne=await wv(t,s);O(ne);const Me=v.type==="generator"?"planning":"implementation",Ie=await Lv(t,s,Me);se(Ie)}catch{O([]),se(null)}finally{ee(!1)}}},[t,s,v]),Ar=p.useCallback(async ne=>{if(!(!t||!s)){H(!0),N(null);try{await bv(t,s,ne),await jt()}catch(Me){N(Me instanceof Error?Me.message:"Upload failed")}finally{H(!1)}}},[t,s,jt]),js=p.useCallback(async()=>{if(!(!t||!s||!D||!Y)){J(!0),N(null);try{await jv(t,s,D,Y,re||void 0),R(""),ie(""),L(""),te(!1),await jt()}catch(ne){N(ne instanceof Error?ne.message:"Import failed")}finally{J(!1)}}},[t,s,D,Y,re,jt]),vr=p.useCallback(async ne=>{if(!(!t||!s)){Pe(!1),N(null);try{await _v(t,s,ne),await jt()}catch(Me){N(Me instanceof Error?Me.message:"Failed to apply template")}}},[t,s,jt]),wr=p.useCallback(async ne=>{if(!(!t||!s)&&confirm(`Delete ${ne}?`)){_e(ne),N(null);try{await Nv(t,s,ne),await jt()}catch(Me){N(Me instanceof Error?Me.message:"Delete failed")}finally{_e(null)}}},[t,s,jt]);p.useEffect(()=>{if(!t||!s)return;y(null),k(null),x([],0);async function ne(){S(null);try{const[Ie,be]=await Promise.all([Vs(t),S0(t,s)]);i(Ie),y(be),await lt()}catch(Ie){S(Ie instanceof Error?Ie.message:"Failed to load")}}ne();const Me=setInterval(lt,3e3);return()=>clearInterval(Me)},[t,s,i,lt,x]),p.useEffect(()=>{if(!t||!s)return;async function ne(){try{const Me=await _0(t,s);ot(Me)}catch{ot({has_qa:!1,qa_count:0,qa_summary:[]})}}ne()},[t,s]),p.useEffect(()=>{q==="items"?cr(!0):q==="inputs"&&jt()},[q,jt]),p.useEffect(()=>{q==="items"&&t&&s&&cr(!0)},[Ee,at]),p.useEffect(()=>{if(!W)return;const ne=Me=>{Me.key==="Escape"&&!K&&te(!1)};return document.addEventListener("keydown",ne),()=>document.removeEventListener("keydown",ne)},[W,K]);const Gs=p.useCallback(async()=>{if(!(!t||!s)){N(null);try{const[ne,Me]=await Promise.all([nv(t,s),qc(t)]);E(ne.content),M(Me.map(Ie=>Ie.name)),P(!0)}catch(ne){N(ne instanceof Error?ne.message:"Failed to load config")}}},[t,s]),Ns=p.useCallback(async ne=>{if(!t||!s)return;await ov(t,s,ne);const Me=await S0(t,s);y(Me),P(!1)},[t,s]),ks=p.useCallback(async()=>{if(!t||!s||!v)return;if(b!=null&&b.is_running){jc.error("Cannot delete a running loop. Stop it first.");return}if(await mN.typeToDelete(s,"loop"))try{await sv(t,s),jc.success(`Loop "${v.display_name}" deleted`),o(`/projects/${t}`)}catch(Me){jc.error(Me instanceof Error?Me.message:"Failed to delete loop")}},[t,s,v,b==null?void 0:b.is_running,o]);if(_)return e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"card bg-red-900/20 border border-red-800",children:[e.jsx("h2",{className:"text-lg font-semibold text-red-400 mb-2",children:"Error"}),e.jsx("p",{className:"text-gray-300 mb-4",children:_}),e.jsxs(Se,{to:t?`/projects/${t}`:"/",className:"btn-secondary inline-block",children:["Back to ",t?"Project":"Dashboard"]})]})});if(!v||!l)return e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"text-gray-400",children:"Loading..."})});const Dt=(b==null?void 0:b.is_running)||!1,dr=(b==null?void 0:b.status)==="paused";return e.jsxs("div",{className:"p-6",children:[T&&e.jsx(oN,{projectSlug:t,loopName:s,initialYaml:C,availableLoops:I,onClose:()=>P(!1),onSave:Ns}),e.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[e.jsx(Se,{to:"/",className:"hover:text-white",children:"Dashboard"}),e.jsx("span",{children:"/"}),e.jsx(Se,{to:`/projects/${t}`,className:"hover:text-white",children:l.name}),e.jsx("span",{children:"/"}),e.jsx("span",{className:"text-white",children:v.display_name})]}),e.jsxs("div",{className:"flex items-center justify-between mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-white mb-2",children:v.display_name}),e.jsxs("p",{className:"text-gray-400",children:["Type: ",v.type]}),e.jsxs("p",{className:"text-gray-500 text-sm font-mono",children:["ID: ",v.name]})]}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsxs("button",{onClick:Gs,className:"flex items-center space-x-2 px-4 py-2 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 transition-colors",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})}),e.jsx("span",{children:"Edit Config"})]}),e.jsxs("button",{onClick:ks,className:"flex items-center space-x-2 px-4 py-2 bg-red-900/30 text-red-400 rounded hover:bg-red-900/50 border border-red-800/50 transition-colors",title:"Delete this loop",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})}),e.jsx("span",{children:"Delete"})]}),e.jsx(yj,{projectSlug:t,loopName:s,isRunning:Dt,isPaused:dr,onStatusChange:lt})]})]}),j&&e.jsxs("div",{className:"mb-6 p-3 bg-red-900/30 border border-red-800 rounded flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-red-400",children:j}),e.jsx("button",{onClick:()=>N(null),className:"text-red-400 hover:text-red-300",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"border-b border-gray-700 mb-6",children:e.jsx("nav",{className:"flex space-x-8",children:["overview","items","inputs","resources","runs"].map(ne=>e.jsx("button",{onClick:()=>z(ne),className:`pb-4 px-1 border-b-2 font-medium text-sm transition-colors ${q===ne?"border-primary-500 text-primary-400":"border-transparent text-gray-400 hover:text-gray-300 hover:border-gray-500"}`,children:ne.charAt(0).toUpperCase()+ne.slice(1)},ne))})}),wt&&e.jsx(uN,{projectSlug:t,loopName:s,onClose:()=>ae(!1),onComplete:async ne=>{ae(!1);try{const Me=await _0(t,s);ot(Me)}catch{}if(ne)try{await Lc(t,s,{force:!0}),lt()}catch(Me){N(Me instanceof Error?Me.message:"Failed to start loop")}}}),q==="overview"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"card mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold text-white",children:"Pre-Flight Check"}),Le!=null&&Le.has_qa?e.jsxs("span",{className:"text-green-400 text-sm flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Complete"]}):e.jsxs("span",{className:"text-yellow-400 text-sm flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),"Required"]})]}),Le!=null&&Le.has_qa?e.jsxs("div",{className:"mt-3",children:[e.jsxs("p",{className:"text-sm text-gray-400 mb-2",children:[Le.qa_count," clarification",Le.qa_count!==1?"s":""," recorded",Le.last_updated&&e.jsxs(e.Fragment,{children:[" • Last updated ",Zc(Le.last_updated)]})]}),Le.qa_summary.length>0&&e.jsx("ul",{className:"text-sm text-gray-500 space-y-1 mb-3",children:Le.qa_summary.map((ne,Me)=>e.jsxs("li",{children:["• ",ne]},Me))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>ae(!0),className:"text-sm text-primary-400 hover:text-primary-300",children:"View / Edit"}),e.jsx("button",{onClick:()=>ae(!0),className:"text-sm text-gray-400 hover:text-gray-300",children:"Run Again"})]})]}):e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"text-sm text-gray-400 mb-3",children:"Run a Ready Check before starting to ensure Claude understands the task. This helps catch ambiguities and missing context."}),e.jsx("button",{onClick:()=>ae(!0),className:"px-4 py-2 bg-primary-600 hover:bg-primary-500 rounded text-white text-sm",children:"Run Ready Check"})]})]}),e.jsxs("div",{className:"card mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("h2",{className:"text-lg font-semibold text-white",children:"Status"})}),e.jsx("div",{className:"flex items-center space-x-4",children:e.jsxs("span",{className:`flex items-center space-x-2 ${Dt?dr?"text-yellow-400":"text-green-400":"text-gray-400"}`,children:[e.jsx("span",{className:`w-3 h-3 rounded-full ${Dt?dr?"bg-yellow-400":"bg-green-400 animate-pulse":"bg-gray-500"}`}),e.jsx("span",{children:Dt?dr?"Paused":"Running":"Stopped"})]})})]}),(b==null?void 0:b.current_iteration)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-4",children:e.jsx(jj,{value:b.current_iteration,max:100,label:`Progress: Iteration ${b.current_iteration}`,showPercent:!0,size:"md",color:Dt?dr?"yellow":"green":"primary"})}),e.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-400",children:"Iteration"}),e.jsx("div",{className:"text-xl font-semibold text-white",children:b.current_iteration})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-400",children:"Mode"}),e.jsx("div",{className:"text-xl font-semibold text-white",children:b.current_mode||"-"})]})]})]})]}),e.jsxs("div",{className:"card mb-6",children:[e.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Modes"}),e.jsx("div",{className:"space-y-2",children:v.modes.map(ne=>e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-md ${(b==null?void 0:b.current_mode)===ne.name?"bg-primary-900/30 border border-primary-600":"bg-gray-700"}`,children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-white",children:ne.name}),e.jsxs("div",{className:"text-sm text-gray-400",children:["Model: ",ne.model]})]}),e.jsxs("div",{className:"text-sm text-gray-400",children:["Timeout: ",ne.timeout,"s"]})]},ne.name))})]}),Dt&&e.jsx("div",{className:"mb-6",children:e.jsx(Wp,{projectSlug:t,loopName:s,enabled:Dt})})]}),q==="items"&&e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-white",children:"Items"}),e.jsxs("span",{className:"text-sm text-gray-400",children:[u," items"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4 pb-4 border-b border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-gray-400",children:"Status:"}),e.jsxs("select",{value:Ee,onChange:ne=>Ve(ne.target.value),className:"px-2 py-1 bg-gray-700 border border-gray-600 rounded text-sm text-white",children:[e.jsx("option",{value:"",children:"All"}),e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"completed",children:"Completed"}),e.jsx("option",{value:"in_progress",children:"In Progress"}),e.jsx("option",{value:"failed",children:"Failed"}),e.jsx("option",{value:"skipped",children:"Skipped"}),e.jsx("option",{value:"dup",children:"Duplicate"}),e.jsx("option",{value:"external",children:"External"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-gray-400",children:"Category:"}),e.jsxs("select",{value:at,onChange:ne=>xt(ne.target.value),className:"px-2 py-1 bg-gray-700 border border-gray-600 rounded text-sm text-white",children:[e.jsx("option",{value:"",children:"All"}),$e.map(ne=>e.jsx("option",{value:ne,children:ne},ne))]})]}),(Ee||at)&&e.jsx("button",{onClick:()=>{Ve(""),xt("")},className:"text-sm text-gray-400 hover:text-white",children:"Clear filters"})]}),h&&d.length===0?e.jsx("div",{className:"text-gray-400",children:"Loading items..."}):d.length===0?e.jsx(Ac,{icon:Tc.inbox,title:"No items yet",description:Ee||at?"No items match the current filters.":"Items generated by this loop will appear here."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2",children:d.map(ne=>e.jsxs("div",{className:"p-3 bg-gray-700 rounded-md",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-gray-500 font-mono",children:ne.id}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${ne.status==="completed"?"bg-green-900 text-green-300":ne.status==="pending"?"bg-yellow-900 text-yellow-300":ne.status==="in_progress"?"bg-blue-900 text-blue-300":ne.status==="failed"?"bg-red-900 text-red-300":"bg-gray-600 text-gray-300"}`,children:ne.status})]}),ne.category&&e.jsx("span",{className:"text-xs text-gray-400",children:ne.category})]}),e.jsx("p",{className:"text-sm text-gray-200 line-clamp-2",children:ne.content})]},ne.id))}),d.length<u&&e.jsx("div",{className:"mt-4 text-center",children:e.jsx("button",{onClick:()=>{ue(d.length),cr(!1)},disabled:h,className:"px-4 py-2 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 disabled:opacity-50",children:h?"Loading...":`Load More (${d.length} of ${u})`})})]})]}),q==="inputs"&&e.jsxs("div",{className:"space-y-4",children:[pe&&!pe.valid&&e.jsx("div",{className:"p-4 bg-yellow-900/30 border border-yellow-700 rounded-lg",children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("svg",{className:"w-5 h-5 text-yellow-400 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-yellow-300",children:"Missing required inputs"}),e.jsx("div",{className:"mt-2 space-y-2",children:pe.missing_tags.map(ne=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-yellow-400 text-sm",children:hh[ne]||ne}),e.jsx("button",{onClick:()=>Pe(!0),className:"text-xs px-2 py-1 bg-yellow-800/50 text-yellow-300 rounded hover:bg-yellow-800",children:"Add from Templates"})]},ne))}),e.jsx("p",{className:"text-xs text-yellow-500 mt-2",children:"Add required inputs or use force start to skip validation."})]})]})}),e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-white",children:"Input Files"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>Pe(!0),className:"px-3 py-1.5 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 text-sm",children:"Browse Templates"}),e.jsx("button",{onClick:()=>te(!0),className:"px-3 py-1.5 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 text-sm",children:"Paste Content"}),e.jsx("button",{onClick:()=>{var ne;return(ne=Ne.current)==null?void 0:ne.click()},disabled:F,className:"px-3 py-1.5 bg-primary-600 text-white rounded hover:bg-primary-500 text-sm disabled:opacity-50",children:F?"Uploading...":"Upload File"}),e.jsx("input",{ref:Ne,type:"file",className:"hidden",accept:".md,.txt,.json,.jsonl",onChange:ne=>{var Ie;const Me=(Ie=ne.target.files)==null?void 0:Ie[0];Me&&Ar(Me),ne.target.value=""}})]})]}),X?e.jsx("div",{className:"text-gray-400",children:"Loading..."}):U.length===0?e.jsx(Ac,{icon:Tc.document,title:"No input files",description:"Upload design documents, requirements, or other files for this loop to process.",action:{label:"Browse Templates",onClick:()=>Pe(!0)}}):e.jsx("div",{className:"space-y-2",children:U.map(ne=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-700 rounded-md",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-white",children:ne.name}),e.jsxs("div",{className:"text-xs text-gray-400",children:[(ne.size/1024).toFixed(1)," KB"]})]}),ne.tag&&e.jsx("span",{className:"px-2 py-0.5 text-xs bg-gray-600 text-gray-300 rounded",children:hh[ne.tag]||ne.tag})]}),e.jsx("button",{onClick:()=>wr(ne.name),disabled:he===ne.name,className:"p-1 text-gray-400 hover:text-red-400 disabled:opacity-50",title:"Delete",children:he===ne.name?e.jsxs("svg",{className:"w-5 h-5 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]},ne.name))})]})]}),q==="resources"&&v&&e.jsx("div",{className:"card",children:e.jsx(dN,{projectSlug:t,loopName:s,loopType:v.type==="generator"?"planning":"implementation"})}),q==="runs"&&e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Run History"}),e.jsx(Se,{to:`/projects/${t}/runs?loop=${s}`,className:"text-primary-400 hover:text-primary-300",children:"View all runs for this loop"})]}),W&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:ne=>{ne.target===ne.currentTarget&&!K&&te(!1)},children:e.jsxs("div",{className:"bg-gray-800 rounded-lg p-6 w-full max-w-lg mx-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Paste Content"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Filename"}),e.jsx("input",{type:"text",value:Y,onChange:ne=>ie(ne.target.value),placeholder:"design-doc.md",className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white",disabled:K})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Tag (optional)"}),e.jsxs("select",{value:re,onChange:ne=>L(ne.target.value),className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white",disabled:K,children:[e.jsx("option",{value:"",children:"No tag"}),e.jsx("option",{value:"master_design",children:"Master Design"}),e.jsx("option",{value:"story_instructions",children:"Story Instructions"}),e.jsx("option",{value:"stories",children:"Stories (JSONL)"}),e.jsx("option",{value:"guardrails",children:"Guardrails"}),e.jsx("option",{value:"reference",children:"Reference"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Content"}),e.jsx("textarea",{value:D,onChange:ne=>R(ne.target.value),placeholder:"Paste your content here...",rows:10,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white font-mono text-sm",disabled:K})]})]}),e.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[e.jsx("button",{onClick:()=>te(!1),disabled:K,className:"px-4 py-2 text-gray-400 hover:text-white disabled:opacity-50",children:"Cancel"}),e.jsx("button",{onClick:js,disabled:!D||!Y||K,className:"px-4 py-2 bg-primary-600 text-white rounded hover:bg-primary-500 disabled:opacity-50 disabled:cursor-not-allowed",children:K?"Importing...":"Import"})]})]})}),Ae&&v&&e.jsx(lN,{loopType:v.type==="generator"?"planning":"implementation",onSelect:vr,onCancel:()=>Pe(!1)})]})}function pN({projectSlug:t,item:s,onUpdate:o,terminology:l}){const[i,d]=p.useState(!1),[u,h]=p.useState(!1),[x,g]=p.useState(null),v=(l==null?void 0:l.singular)||s.item_type||"item",y=async k=>{h(!0),g(null);try{await Gc(t,s.id,{status:k}),o()}catch(_){g(_ instanceof Error?_.message:"Failed to update item")}finally{h(!1)}},b=async()=>{if(window.confirm("Are you sure you want to delete this item?")){h(!0),g(null);try{await $h(t,s.id),o()}catch(k){g(k instanceof Error?k.message:"Failed to delete item")}finally{h(!1)}}};return e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center flex-wrap gap-2",children:[e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${Xc(s.status)}`,children:Qc(s.status)}),s.phase!==void 0&&e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded bg-indigo-900 text-indigo-300",title:"Phase",children:["Phase ",s.phase]}),s.workflow_id&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-gray-700 text-gray-300",title:"Workflow ID",children:s.workflow_id.slice(0,8)}),s.source_step_id&&e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded bg-indigo-900/50 text-indigo-300",title:"Source step",children:["Step ",s.source_step_id]}),s.item_type&&s.item_type!=="item"&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-primary-900 text-primary-300",title:"Item type",children:v}),s.category&&e.jsx("span",{className:"text-xs text-gray-400",children:s.category.toUpperCase()}),s.priority!==void 0&&s.priority>0&&e.jsxs("span",{className:"text-xs text-primary-400",children:["P",s.priority]}),s.dependencies&&s.dependencies.length>0&&e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded bg-gray-700 text-gray-400",title:`Depends on: ${s.dependencies.join(", ")}`,children:[s.dependencies.length," dep",s.dependencies.length>1?"s":""]}),s.claimed_by&&e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded bg-blue-900/50 text-blue-300",title:"Claimed by",children:["Claimed: ",s.claimed_by]}),s.duplicate_of&&e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded bg-orange-900/50 text-orange-300",title:"Duplicate of",children:["Dup of: ",s.duplicate_of]})]}),e.jsx("button",{onClick:()=>d(!i),className:"text-gray-400 hover:text-white","aria-expanded":i,"aria-label":i?"Collapse item details":"Expand item details",children:e.jsx("svg",{className:`w-5 h-5 transition-transform ${i?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}),s.title&&e.jsx("h4",{className:"text-sm font-medium text-white mb-1",children:s.title}),e.jsx("p",{className:`text-sm text-gray-200 ${i?"":"line-clamp-2"}`,children:s.content}),s.skip_reason&&e.jsxs("p",{className:"text-xs text-gray-400 mt-1 italic",children:["Skip reason: ",s.skip_reason]}),i&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-700",children:[s.dependencies&&s.dependencies.length>0&&e.jsxs("div",{className:"mb-4 p-3 bg-gray-700/50 rounded",children:[e.jsx("div",{className:"text-xs font-medium text-gray-400 mb-2",children:"Dependencies"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:s.dependencies.map(k=>e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-gray-600 text-gray-300",children:k},k))})]}),e.jsxs("div",{className:"text-xs text-gray-500 mb-4 space-y-1",children:[e.jsxs("div",{children:["Created: ",hs(s.created_at)]}),e.jsxs("div",{children:["Updated: ",hs(s.updated_at)]}),s.claimed_at&&e.jsxs("div",{children:["Claimed: ",hs(s.claimed_at)]}),s.processed_at&&e.jsxs("div",{children:["Processed: ",hs(s.processed_at)]}),e.jsxs("div",{children:["ID: ",s.id]}),s.workflow_id&&e.jsxs("div",{children:["Workflow: ",s.workflow_id]}),s.source_step_id!==void 0&&e.jsxs("div",{children:["Source Step: ",s.source_step_id]}),s.item_type&&e.jsxs("div",{children:["Type: ",v]}),s.phase!==void 0&&e.jsxs("div",{children:["Phase: ",s.phase]}),s.duplicate_of&&e.jsxs("div",{children:["Duplicate of: ",s.duplicate_of]}),s.skip_reason&&e.jsxs("div",{children:["Skip reason: ",s.skip_reason]})]}),x&&e.jsx("div",{className:"mb-3 px-3 py-2 bg-red-900/30 border border-red-800 rounded text-xs text-red-400",role:"alert",children:x}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.status!=="completed"&&e.jsx("button",{onClick:()=>y("completed"),disabled:u,className:"px-3 py-1 text-xs rounded bg-green-800 text-green-200 hover:bg-green-700 disabled:opacity-50",children:"Mark Complete"}),s.status!=="rejected"&&e.jsx("button",{onClick:()=>y("rejected"),disabled:u,className:"px-3 py-1 text-xs rounded bg-red-800 text-red-200 hover:bg-red-700 disabled:opacity-50",children:"Reject"}),s.status!=="pending"&&e.jsx("button",{onClick:()=>y("pending"),disabled:u,className:"px-3 py-1 text-xs rounded bg-yellow-800 text-yellow-200 hover:bg-yellow-700 disabled:opacity-50",children:"Reset to Pending"}),e.jsx("button",{onClick:b,disabled:u,className:"px-3 py-1 text-xs rounded bg-gray-700 text-gray-300 hover:bg-gray-600 disabled:opacity-50",children:"Delete"})]})]})]})}function xN({status:t,category:s,categories:o,onStatusChange:l,onCategoryChange:i}){const d=["all","pending","in_progress","completed","rejected"];return e.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Status"}),e.jsx("select",{value:t,onChange:u=>l(u.target.value),className:"px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white text-sm focus:outline-none focus:border-primary-500",children:d.map(u=>e.jsx("option",{value:u,children:u==="all"?"All Statuses":u.replace("_"," ")},u))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Category"}),e.jsxs("select",{value:s,onChange:u=>i(u.target.value),className:"px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white text-sm focus:outline-none focus:border-primary-500",children:[e.jsx("option",{value:"",children:"All Categories"}),o.map(u=>e.jsx("option",{value:u,children:u},u))]})]})]})}function fN(){const{slug:t,workflowId:s}=yr(),{selectedProject:o,setSelectedProject:l}=Tr(),[i,d]=p.useState(null),[u,h]=p.useState([]),[x,g]=p.useState(0),[v,y]=p.useState(!0),[b,k]=p.useState(null),[_,S]=p.useState("all"),[j,N]=p.useState(""),[T,P]=p.useState([]),[C,E]=p.useState(0),I=20,[M,q]=p.useState(!1),[z,U]=p.useState(""),[O,X]=p.useState(""),[ee,W]=p.useState(!1),te=p.useCallback(async()=>{if(!(!t||!s)){y(!0),k(null);try{const L=await Ao(t,{status:_==="all"?void 0:_,category:j||void 0,workflow_id:s,limit:I,offset:C});h(L.items),g(L.total);const F=new Set;L.items.forEach(H=>{H.category&&F.add(H.category)}),P(Array.from(F).sort())}catch(L){k(L instanceof Error?L.message:"Failed to load items")}finally{y(!1)}}},[t,s,_,j,C]);p.useEffect(()=>{async function L(){if(!(!t||!s))try{const[F,H]=await Promise.all([Vs(t),Po(t,s)]);l(F),d(H)}catch(F){k(F instanceof Error?F.message:"Failed to load data")}}L()},[t,s,l]),p.useEffect(()=>{te()},[te]);const D=async L=>{if(L.preventDefault(),!t||!s||!i||!z.trim())return;const F=i.steps.find(H=>H.step_number===i.current_step);if(!F){k("No active workflow step found. Cannot add items.");return}W(!0);try{await Yc(t,{content:z.trim(),workflow_id:s,source_step_id:F.id,category:O.trim()||void 0}),U(""),X(""),q(!1),te()}catch(H){k(H instanceof Error?H.message:"Failed to add item")}finally{W(!1)}},R=Math.ceil(x/I),Y=Math.floor(C/I)+1,ie={pending:u.filter(L=>L.status==="pending").length,in_progress:u.filter(L=>L.status==="in_progress").length,completed:u.filter(L=>L.status==="completed").length},re=x>0?Math.round(ie.completed/x*100):0;return v&&!i?e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"text-gray-400",children:"Loading..."})}):e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[e.jsx(Se,{to:"/",className:"hover:text-white",children:"Dashboard"}),e.jsx("span",{children:"/"}),e.jsx(Se,{to:`/projects/${t}`,className:"hover:text-white",children:(o==null?void 0:o.name)||t}),e.jsx("span",{children:"/"}),e.jsx(Se,{to:`/projects/${t}/workflows/${s}`,className:"hover:text-white",children:(i==null?void 0:i.name)||"Workflow"}),e.jsx("span",{children:"/"}),e.jsx("span",{className:"text-white",children:"Work Items"})]}),e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-white mb-1",children:"Work Items"}),e.jsxs("p",{className:"text-gray-400",children:[x," item",x!==1?"s":""," in this workflow"]})]}),e.jsxs("button",{onClick:()=>q(!0),className:"flex items-center space-x-2 px-4 py-2 bg-primary-600 text-white rounded hover:bg-primary-500",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),e.jsx("span",{children:"Add Item"})]})]}),e.jsxs("div",{className:"card mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center space-x-6 text-sm",children:[e.jsxs("span",{className:"text-gray-400",children:[x," total"]}),e.jsx("span",{className:"text-gray-600",children:"|"}),e.jsxs("span",{className:"text-green-400",children:[ie.completed," completed"]}),e.jsx("span",{className:"text-gray-600",children:"|"}),e.jsxs("span",{className:"text-yellow-400",children:[ie.in_progress," in progress"]}),e.jsx("span",{className:"text-gray-600",children:"|"}),e.jsxs("span",{className:"text-gray-400",children:[ie.pending," pending"]})]}),e.jsxs("span",{className:"text-sm text-gray-400",children:[re,"%"]})]}),e.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2",children:e.jsx("div",{className:"bg-green-500 h-2 rounded-full transition-all duration-300",style:{width:`${re}%`}})})]}),M&&e.jsxs("div",{className:"card mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Add New Item"}),e.jsxs("form",{onSubmit:D,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"new-content",className:"block text-sm font-medium text-gray-300 mb-1",children:"Content"}),e.jsx("textarea",{id:"new-content",value:z,onChange:L=>U(L.target.value),placeholder:"Item content...",rows:3,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white placeholder-gray-400 focus:outline-none focus:border-primary-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"new-category",className:"block text-sm font-medium text-gray-300 mb-1",children:"Category (optional)"}),e.jsx("input",{id:"new-category",type:"text",value:O,onChange:L=>X(L.target.value),placeholder:"e.g., FND, API, UI",className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white placeholder-gray-400 focus:outline-none focus:border-primary-500"})]}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{type:"button",onClick:()=>q(!1),className:"px-4 py-2 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:ee||!z.trim(),className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500 disabled:opacity-50",children:ee?"Adding...":"Add Item"})]})]})]}),e.jsx("div",{className:"mb-4",children:e.jsx(xN,{status:_,category:j,categories:T,onStatusChange:L=>{S(L),E(0)},onCategoryChange:L=>{N(L),E(0)}})}),b&&e.jsx("div",{className:"mb-4 p-3 bg-red-900/30 border border-red-800 rounded text-red-400",role:"alert",children:b}),v?e.jsx("div",{className:"text-gray-400","aria-live":"polite",children:"Loading items..."}):u.length===0?e.jsxs("div",{className:"card text-center py-8",children:[e.jsx("p",{className:"text-gray-400",children:"No items found"}),(_!=="all"||j)&&e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Try changing your filters"})]}):e.jsx("div",{className:"space-y-3",children:u.map(L=>e.jsx(pN,{projectSlug:t,item:L,onUpdate:te},L.id))}),R>1&&e.jsxs("nav",{className:"mt-6 flex items-center justify-between","aria-label":"Pagination",children:[e.jsxs("div",{className:"text-sm text-gray-400",children:["Showing ",C+1,"-",Math.min(C+I,x)," of ",x]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>E(Math.max(0,C-I)),disabled:C===0,className:"px-3 py-1 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600 disabled:opacity-50","aria-label":"Previous page",children:"Previous"}),e.jsxs("span",{className:"text-sm text-gray-400","aria-current":"page",children:["Page ",Y," of ",R]}),e.jsx("button",{onClick:()=>E(C+I),disabled:C+I>=x,className:"px-3 py-1 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600 disabled:opacity-50","aria-label":"Next page",children:"Next"})]})]})]})}function gN(){const{slug:t,workflowId:s}=yr(),{selectedProject:o,setSelectedProject:l}=Tr(),[i,d]=p.useState(null),[u,h]=p.useState([]),[x,g]=p.useState([]),[v,y]=p.useState(!0),[b,k]=p.useState(null),[_,S]=p.useState("all"),[j,N]=p.useState(!1),[T,P]=p.useState(!1),[C,E]=p.useState({name:"",resource_type:"guardrail",content:""}),[I,M]=p.useState(!1),[q,z]=p.useState(null),[U,O]=p.useState(""),[X,ee]=p.useState(!1),W=p.useCallback(async()=>{if(!(!t||!s)){y(!0),k(null);try{const[K,J,he,_e]=await Promise.all([Vs(t),Po(t,s),fl(t,s),Jc(t)]);l(K),d(J),h(he),g(_e)}catch(K){k(K instanceof Error?K.message:"Failed to load resources")}finally{y(!1)}}},[t,s,l]);p.useEffect(()=>{W()},[W]);const te=_==="all"?u:u.filter(K=>K.resource_type===_),D=async K=>{if(K.preventDefault(),!(!t||!s||!C.name.trim()||!C.content.trim())){M(!0);try{await Kc(t,s,{name:C.name.trim(),resource_type:C.resource_type,content:C.content.trim(),source:"manual"}),E({name:"",resource_type:"guardrail",content:""}),N(!1),W()}catch(J){k(J instanceof Error?J.message:"Failed to add resource")}finally{M(!1)}}},R=async K=>{if(!(!t||!s))try{await Uh(t,s,K.id),P(!1),W()}catch(J){k(J instanceof Error?J.message:"Failed to import resource")}},Y=async()=>{if(!(!t||!s||!q)){ee(!0);try{await So(t,s,q.id,{content:U}),z(null),W()}catch(K){k(K instanceof Error?K.message:"Failed to save resource")}finally{ee(!1)}}},ie=async K=>{if(!(!t||!s))try{await So(t,s,K.id,{enabled:!K.enabled}),W()}catch(J){k(J instanceof Error?J.message:"Failed to update resource")}},re=async K=>{if(!(!t||!s)&&confirm(`Delete "${K.name}"? This cannot be undone.`))try{await Hh(t,s,K.id),W()}catch(J){k(J instanceof Error?J.message:"Failed to delete resource")}},L=K=>{switch(K){case"design_doc":return"Design Document";case"guardrail":return"Guardrail";case"input_file":return"Input File";case"prompt":return"Prompt";default:return K}},F=K=>{switch(K){case"design_doc":return e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})});case"guardrail":return e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})});default:return e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})})}},H=[{key:"all",label:"All"},{key:"design_doc",label:"Design Doc"},{key:"guardrail",label:"Guardrails"},{key:"input_file",label:"Input Files"}];return v?e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"text-gray-400",children:"Loading resources..."})}):e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[e.jsx(Se,{to:"/",className:"hover:text-white",children:"Dashboard"}),e.jsx("span",{children:"/"}),e.jsx(Se,{to:`/projects/${t}`,className:"hover:text-white",children:(o==null?void 0:o.name)||t}),e.jsx("span",{children:"/"}),e.jsx(Se,{to:`/projects/${t}/workflows/${s}`,className:"hover:text-white",children:(i==null?void 0:i.name)||"Workflow"}),e.jsx("span",{children:"/"}),e.jsx("span",{className:"text-white",children:"Resources"})]}),e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-white mb-1",children:"Resources"}),e.jsxs("p",{className:"text-gray-400",children:[u.length," resource",u.length!==1?"s":""," for this workflow"]})]}),e.jsxs("div",{className:"flex space-x-3",children:[e.jsxs("button",{onClick:()=>P(!0),className:"flex items-center space-x-2 px-4 py-2 bg-gray-700 text-gray-300 rounded hover:bg-gray-600",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})}),e.jsx("span",{children:"Import from Library"})]}),e.jsxs("button",{onClick:()=>N(!0),className:"flex items-center space-x-2 px-4 py-2 bg-primary-600 text-white rounded hover:bg-primary-500",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),e.jsx("span",{children:"Add Resource"})]})]})]}),b&&e.jsx("div",{className:"mb-4 p-3 bg-red-900/30 border border-red-800 rounded text-red-400",children:b}),e.jsx("div",{className:"flex space-x-1 mb-6 border-b border-gray-700",children:H.map(K=>e.jsx("button",{onClick:()=>S(K.key),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${_===K.key?"border-primary-500 text-white":"border-transparent text-gray-400 hover:text-gray-300"}`,children:K.label},K.key))}),te.length===0?e.jsxs("div",{className:"card text-center py-8",children:[e.jsx("p",{className:"text-gray-400",children:"No resources found"}),e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Add resources to provide context for Claude during execution."})]}):e.jsx("div",{className:"space-y-3",children:te.map(K=>e.jsxs("div",{className:"card flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start space-x-4",children:[e.jsx("div",{className:`p-2 rounded ${K.enabled?"bg-primary-500/20 text-primary-400":"bg-gray-700 text-gray-500"}`,children:F(K.resource_type)}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium text-white",children:K.name}),e.jsxs("div",{className:"flex items-center space-x-4 text-sm text-gray-400 mt-1",children:[e.jsx("span",{children:L(K.resource_type)}),K.source&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-600",children:"|"}),e.jsxs("span",{children:["Source: ",K.source]})]})]}),K.content&&e.jsxs("p",{className:"text-sm text-gray-500 mt-2 line-clamp-2",children:[K.content.slice(0,200),K.content.length>200&&"..."]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>ie(K),className:`px-3 py-1 text-sm rounded ${K.enabled?"bg-green-600/20 text-green-400":"bg-gray-700 text-gray-500"}`,children:K.enabled?"Enabled":"Disabled"}),e.jsx("button",{onClick:()=>{z(K),O(K.content||"")},className:"px-3 py-1 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600",children:"View"}),e.jsx("button",{onClick:()=>re(K),className:"px-3 py-1 text-sm rounded bg-red-900/30 text-red-400 hover:bg-red-900/50",children:"Delete"})]})]},K.id))}),e.jsx("div",{className:"mt-8 p-4 bg-gray-800/50 border border-gray-700 rounded",children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("svg",{className:"w-5 h-5 text-yellow-500 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{className:"text-sm text-gray-400",children:[e.jsx("p",{className:"font-medium text-gray-300 mb-1",children:"About Workflow Resources"}),e.jsx("p",{children:"Resources are injected into Claude's context during execution. Design documents provide the overall vision, guardrails set boundaries, and input files provide additional context."})]})]})}),j&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-gray-800 rounded-lg p-6 w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"Add Resource"}),e.jsxs("form",{onSubmit:D,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Resource Type"}),e.jsxs("select",{value:C.resource_type,onChange:K=>E({...C,resource_type:K.target.value}),className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white",children:[e.jsx("option",{value:"guardrail",children:"Guardrail"}),e.jsx("option",{value:"design_doc",children:"Design Document"}),e.jsx("option",{value:"input_file",children:"Input File"}),e.jsx("option",{value:"prompt",children:"Prompt"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Name"}),e.jsx("input",{type:"text",value:C.name,onChange:K=>E({...C,name:K.target.value}),placeholder:"e.g., Code Style Guidelines",className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white placeholder-gray-400"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Content"}),e.jsx("textarea",{value:C.content,onChange:K=>E({...C,content:K.target.value}),placeholder:"Resource content...",rows:10,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white placeholder-gray-400 font-mono text-sm"})]}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{type:"button",onClick:()=>N(!1),className:"px-4 py-2 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:I||!C.name.trim()||!C.content.trim(),className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500 disabled:opacity-50",children:I?"Adding...":"Add Resource"})]})]})]})}),T&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-gray-800 rounded-lg p-6 w-full max-w-lg",children:[e.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"Import from Project Library"}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Select a resource from the project's shared library to add to this workflow."}),x.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-gray-400",children:"No shared resources in project library"}),e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Add resources to the project library in Project Settings."})]}):e.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:x.map(K=>e.jsx("button",{onClick:()=>R(K),className:"w-full p-3 bg-gray-700 rounded hover:bg-gray-600 text-left",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-white font-medium",children:K.name}),e.jsx("p",{className:"text-sm text-gray-400",children:L(K.resource_type)})]}),K.auto_inherit&&e.jsx("span",{className:"text-xs bg-primary-500/20 text-primary-400 px-2 py-1 rounded",children:"Auto-inherit"})]})},K.id))}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx("button",{onClick:()=>P(!1),className:"px-4 py-2 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600",children:"Close"})})]})}),q&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-gray-800 rounded-lg p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-xl font-bold text-white",children:q.name}),e.jsx("span",{className:"text-sm bg-gray-700 text-gray-400 px-2 py-1 rounded",children:L(q.resource_type)})]}),e.jsx("textarea",{value:U,onChange:K=>O(K.target.value),rows:20,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white font-mono text-sm"}),e.jsxs("div",{className:"flex justify-end space-x-3 mt-4",children:[e.jsx("button",{onClick:()=>z(null),className:"px-4 py-2 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600",children:"Cancel"}),e.jsx("button",{onClick:Y,disabled:X,className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500 disabled:opacity-50",children:X?"Saving...":"Save Changes"})]})]})})]})}function yN({workflowName:t,onBack:s,onSave:o,saving:l,dirty:i}){return e.jsx("div",{className:"sticky top-0 z-10 bg-gray-900 border-b border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between px-6 py-4",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsxs("button",{onClick:s,className:"flex items-center space-x-2 text-gray-400 hover:text-white transition-colors",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 19l-7-7m0 0l7-7m-7 7h18"})}),e.jsx("span",{children:"Back to Workflow"})]}),e.jsx("div",{className:"h-6 w-px bg-gray-700"}),e.jsx("h1",{className:"text-xl font-semibold text-white truncate max-w-md",children:t||"Untitled Workflow"}),i&&e.jsx("span",{className:"px-2 py-0.5 text-xs rounded bg-yellow-900/50 text-yellow-400 border border-yellow-700/50",children:"Unsaved"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsxs("span",{className:"text-xs text-gray-500",children:[navigator.platform.includes("Mac")?"⌘":"Ctrl","+S to save"]}),e.jsx("button",{onClick:o,disabled:l||!i,className:`flex items-center space-x-2 px-4 py-2 rounded-lg font-medium transition-colors ${i?"bg-primary-600 text-white hover:bg-primary-500":"bg-gray-700 text-gray-400 cursor-not-allowed"} disabled:opacity-50`,children:l?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),e.jsx("span",{children:"Saving..."})]}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{children:"Save Changes"})]})})]})]})})}function Ka(t){return t?Math.ceil(t.length/4):0}function vN(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Ja(t){return t<1e3?`${t}`:`${(t/1e3).toFixed(1)}k`}const ph={design_doc:{label:"Design Doc",color:"text-purple-400 bg-purple-500/10 border-purple-500/30",icon:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})},guardrail:{label:"Guideline",color:"text-amber-400 bg-amber-500/10 border-amber-500/30",icon:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})})},input:{label:"Input File",color:"text-blue-400 bg-blue-500/10 border-blue-500/30",icon:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})})},prompt:{label:"Prompt",color:"text-emerald-400 bg-emerald-500/10 border-emerald-500/30",icon:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}};function wN({workflow:t,workflowName:s,onNameChange:o,steps:l,resources:i,onViewResources:d}){var _;const[u,h]=p.useState(null);p.useEffect(()=>{if(!u)return;const S=j=>{j.key==="Escape"&&h(null)};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[u]);const x=i.reduce((S,j)=>{var N;return S+(((N=j.content)==null?void 0:N.length)??0)},0),g=i.reduce((S,j)=>S+Ka(j.content),0),v=i.filter(S=>S.enabled),y=i.reduce((S,j)=>(S[j.resource_type]||(S[j.resource_type]=[]),S[j.resource_type].push(j),S),{}),b=Math.min(g/2e5*100,100),k=i.some(S=>S.resource_type==="design_doc"&&S.enabled);return e.jsxs("div",{className:"max-w-3xl space-y-6",children:[e.jsxs("div",{className:"card",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Workflow Name"}),e.jsx("input",{type:"text",value:s,onChange:S=>o(S.target.value),className:"w-full px-4 py-3 bg-gray-800 border border-gray-600 rounded-lg text-white text-lg placeholder-gray-500 focus:outline-none focus:border-primary-500",placeholder:"Enter workflow name"}),e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"Give your workflow a clear, descriptive name that reflects its purpose."})]}),e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Resources"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-xs text-gray-500",children:[v.length," of ",i.length," enabled"]}),d&&e.jsx("button",{onClick:d,className:"text-xs text-primary-400 hover:text-primary-300",children:"Manage →"})]})]}),i.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("svg",{className:"w-10 h-10 mx-auto text-gray-600 mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),e.jsx("p",{className:"text-sm text-gray-500",children:"No resources attached"}),d?e.jsx("button",{onClick:d,className:"text-xs text-primary-400 hover:text-primary-300 mt-2",children:"+ Add resources"}):e.jsx("p",{className:"text-xs text-gray-600 mt-1",children:"Add resources in the Resources tab"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-400 mb-1",children:[e.jsx("span",{children:"Context Usage"}),e.jsxs("span",{children:[Ja(g)," tokens (",vN(x),")"]})]}),e.jsx("div",{className:"h-2 bg-gray-700 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full transition-all duration-300 ${b>75?"bg-red-500":b>50?"bg-amber-500":"bg-emerald-500"}`,style:{width:`${Math.max(b,1)}%`}})}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500 mt-1",children:[e.jsxs("span",{children:[b.toFixed(1),"% of ~200k context"]}),b>50&&e.jsx("span",{className:"text-amber-400",children:"Consider trimming resources"})]})]}),e.jsx("div",{className:"space-y-3",children:Object.entries(y).map(([S,j])=>{const N=ph[S]||{label:S,color:"text-gray-400 bg-gray-500/10 border-gray-500/30",icon:e.jsx("span",{className:"w-4 h-4",children:"📄"})},T=j.reduce((P,C)=>P+Ka(C.content),0);return e.jsxs("div",{className:"rounded-lg bg-gray-800/50 border border-gray-700 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`p-1.5 rounded border ${N.color}`,children:N.icon}),e.jsx("span",{className:"text-sm font-medium text-gray-300",children:N.label}),e.jsxs("span",{className:"text-xs text-gray-500",children:["(",j.length,")"]})]}),e.jsxs("span",{className:"text-xs text-gray-500",children:["~",Ja(T)," tokens"]})]}),e.jsx("div",{className:"space-y-1",children:j.map(P=>{const C=Ka(P.content);return e.jsxs("button",{onClick:()=>h(P),className:`w-full flex items-center justify-between text-xs py-1.5 px-2 rounded hover:bg-gray-700/50 transition-colors ${P.enabled?"text-gray-300":"text-gray-500 opacity-60"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[!P.enabled&&e.jsx("span",{className:"text-gray-600",title:"Disabled",children:"●"}),e.jsx("span",{className:"truncate text-left",children:P.name})]}),e.jsxs("span",{className:"text-gray-500 flex-shrink-0 ml-2",children:[Ja(C)," tok"]})]},P.id)})})]},S)})})]})]}),e.jsxs("div",{className:"card",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-3",children:"Step Progress"}),l.length===0?e.jsx("p",{className:"text-sm text-gray-500",children:"No steps configured"}):e.jsx("div",{className:"space-y-2",children:l.map(S=>{const j=S.iterations_target!=null,N=S.iterations_completed??0,T=S.iterations_target??0,P=j&&T>0?Math.min(N/T*100,100):0,C=S.has_active_run;return e.jsxs("div",{className:"rounded-lg bg-gray-800/50 border border-gray-700 p-3",children:[e.jsx("div",{className:"flex items-center justify-between mb-1",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-gray-500",children:[S.step_number,"."]}),e.jsx("span",{className:"text-sm text-gray-300",children:S.name}),e.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${S.step_type==="autonomous"?"bg-blue-500/20 text-blue-400":"bg-purple-500/20 text-purple-400"}`,children:S.step_type==="autonomous"?"Auto":"Chat"}),C&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-emerald-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-emerald-400 rounded-full animate-pulse"}),"Running"]})]})}),e.jsx("div",{className:"flex items-center gap-2 text-xs",children:j?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 h-1.5 bg-gray-700 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full transition-all ${P>=100?"bg-emerald-500":"bg-blue-500"}`,style:{width:`${P}%`}})}),e.jsxs("span",{className:"text-gray-400",children:[N," / ",T]})]}):e.jsx("span",{className:"text-gray-500",children:N>0?`${N} cycles completed`:"Not started"})})]},S.id)})})]}),e.jsxs("div",{className:"card",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-3",children:"Configuration"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[k?e.jsx("svg",{className:"w-5 h-5 text-emerald-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}):e.jsx("svg",{className:"w-5 h-5 text-amber-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),e.jsx("span",{className:"text-gray-300",children:"Design Document"})]}),e.jsx("span",{className:`text-sm ${k?"text-emerald-400":"text-amber-400"}`,children:k?"Added":"Missing"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[l.length>0?e.jsx("svg",{className:"w-5 h-5 text-emerald-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}):e.jsx("svg",{className:"w-5 h-5 text-amber-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),e.jsx("span",{className:"text-gray-300",children:"Steps"})]}),e.jsx("span",{className:`text-sm ${l.length>0?"text-emerald-400":"text-amber-400"}`,children:l.length>0?`${l.length} configured`:"None"})]})]})]}),e.jsxs("div",{className:"rounded-lg bg-gray-800/50 border border-gray-700 p-4",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-2",children:"Getting Started"}),e.jsxs("ul",{className:"text-sm text-gray-400 space-y-2",children:[e.jsxs("li",{className:"flex items-start space-x-2",children:[e.jsx("span",{className:"text-primary-400",children:"1."}),e.jsxs("span",{children:["Add a ",e.jsx("strong",{children:"Design Document"})," in the Resources tab to guide Claude's work"]})]}),e.jsxs("li",{className:"flex items-start space-x-2",children:[e.jsx("span",{className:"text-primary-400",children:"2."}),e.jsxs("span",{children:["Configure your ",e.jsx("strong",{children:"Steps"})," - use Chat steps for planning and Automated steps for execution"]})]}),e.jsxs("li",{className:"flex items-start space-x-2",children:[e.jsx("span",{className:"text-primary-400",children:"3."}),e.jsxs("span",{children:["Add ",e.jsx("strong",{children:"Guidelines"})," to set boundaries and coding standards"]})]}),e.jsxs("li",{className:"flex items-start space-x-2",children:[e.jsx("span",{className:"text-primary-400",children:"4."}),e.jsx("span",{children:"Save your changes and return to the workflow to start execution"})]})]})]}),u&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:S=>{S.target===S.currentTarget&&h(null)},children:e.jsxs("div",{className:"bg-gray-800 rounded-xl border border-gray-600 w-full max-w-3xl mx-4 max-h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:u.name}),e.jsxs("p",{className:"text-xs text-gray-400 mt-0.5",children:[((_=ph[u.resource_type])==null?void 0:_.label)||u.resource_type," • ",Ja(Ka(u.content))," tokens",!u.enabled&&" • Disabled"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[d&&e.jsx("button",{onClick:()=>{h(null),d()},className:"px-3 py-1.5 text-sm bg-gray-700 text-gray-300 rounded-lg hover:bg-gray-600",children:"Edit"}),e.jsx("button",{onClick:()=>h(null),className:"p-1.5 text-gray-400 hover:text-white rounded-lg hover:bg-gray-700",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:u.content?e.jsx("pre",{className:"text-sm text-gray-300 whitespace-pre-wrap font-mono leading-relaxed",children:u.content}):e.jsx("p",{className:"text-gray-500 text-center py-8",children:"No content"})})]})})]})}function bN({steps:t,selectedIndex:s,onSelect:o,onAdd:l,onMove:i}){const d=x=>x==="interactive"?"Chat":"Automated",u=x=>x==="interactive"?"bg-violet-900/50 text-violet-400 border-violet-700/50":"bg-emerald-900/50 text-emerald-400 border-emerald-700/50",h=x=>{switch(x){case"completed":return e.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400",title:"Completed"});case"active":return e.jsx("span",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse",title:"Active"});case"pending":default:return e.jsx("span",{className:"w-2 h-2 rounded-full bg-gray-500",title:"Pending"})}};return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-300 uppercase tracking-wide",children:"Steps"}),e.jsx("button",{onClick:l,className:"p-1.5 rounded-lg bg-primary-600/20 text-primary-400 hover:bg-primary-600/30 transition-colors",title:"Add Step",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2",children:[t.map((x,g)=>{var v;return e.jsxs("div",{onClick:()=>o(g),className:`group relative p-3 rounded-lg border cursor-pointer transition-all ${s===g?"bg-primary-900/30 border-primary-600":"bg-gray-800 border-gray-700 hover:border-gray-600"}`,children:[e.jsx("div",{className:"absolute -left-2 -top-2 w-6 h-6 rounded-full bg-gray-700 border-2 border-gray-900 flex items-center justify-center",children:e.jsx("span",{className:"text-xs font-medium text-gray-300",children:g+1})}),e.jsxs("div",{className:"ml-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[h(x.status),e.jsx("span",{className:"font-medium text-white truncate flex-1",children:x.name||"Untitled Step"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded border ${u(x.step_type)}`,children:d(x.step_type)}),((v=x.config)==null?void 0:v.model)&&x.step_type==="autonomous"&&e.jsx("span",{className:"text-xs text-gray-500",children:x.config.model})]})]}),t.length>1&&e.jsxs("div",{className:`absolute right-2 top-1/2 -translate-y-1/2 flex flex-col ${s===g?"opacity-100":"opacity-0 group-hover:opacity-100"} transition-opacity`,children:[e.jsx("button",{onClick:y=>{y.stopPropagation(),i(g,"up")},disabled:g===0,className:"p-0.5 text-gray-500 hover:text-white disabled:opacity-20 disabled:cursor-not-allowed",title:"Move up",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),e.jsx("button",{onClick:y=>{y.stopPropagation(),i(g,"down")},disabled:g===t.length-1,className:"p-0.5 text-gray-500 hover:text-white disabled:opacity-20 disabled:cursor-not-allowed",title:"Move down",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})]},x.id||`new-${g}`)}),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 text-sm",children:"No steps yet"})]}),e.jsxs("button",{onClick:l,className:"mt-3 w-full py-2 px-3 rounded-lg border-2 border-dashed border-gray-700 text-gray-400 hover:border-primary-600 hover:text-primary-400 transition-colors flex items-center justify-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),e.jsx("span",{className:"text-sm",children:"Add Step"})]})]})}function Ax({isOpen:t,title:s,message:o,details:l,confirmLabel:i="Confirm",cancelLabel:d="Cancel",variant:u="default",typeToConfirm:h,onConfirm:x,onCancel:g}){const v=p.useRef(null),y=p.useRef(null),[b,k]=p.useState("");p.useEffect(()=>{t&&k("")},[t]),p.useEffect(()=>{t&&(h&&y.current?y.current.focus():v.current&&v.current.focus())},[t,h]);const _=!h||b===h;if(p.useEffect(()=>{if(!t)return;const j=N=>{N.key==="Escape"&&g()};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[t,g]),!t)return null;const S=u==="danger";return e.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50 animate-in fade-in duration-150",onClick:j=>{j.target===j.currentTarget&&g()},children:e.jsxs("div",{className:"bg-gray-800 rounded-xl border border-gray-600 shadow-2xl w-full max-w-md mx-4 animate-in zoom-in-95 duration-150",children:[e.jsxs("div",{className:"flex items-start gap-4 p-6 pb-4",children:[S?e.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:e.jsx("svg",{className:"w-5 h-5 text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}):e.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-primary-500/20 flex items-center justify-center",children:e.jsx("svg",{className:"w-5 h-5 text-primary-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:s}),e.jsx("p",{className:"mt-1 text-sm text-gray-400",children:o})]})]}),l&&e.jsx("div",{className:"px-6 pb-4",children:e.jsx("div",{className:`p-3 rounded-lg text-sm ${S?"bg-red-900/20 border border-red-800/50 text-red-300":"bg-gray-700 text-gray-300"}`,children:l})}),h&&e.jsxs("div",{className:"px-6 pb-4",children:[e.jsxs("label",{className:"block text-sm text-gray-400 mb-2",children:["Type ",e.jsx("span",{className:"font-mono font-semibold text-white bg-gray-700 px-1.5 py-0.5 rounded",children:h})," to confirm"]}),e.jsx("input",{ref:y,type:"text",value:b,onChange:j=>k(j.target.value),onKeyDown:j=>{j.key==="Enter"&&_&&x()},placeholder:h,className:"w-full px-3 py-2 bg-gray-900 border border-gray-600 rounded-lg text-white placeholder-gray-600 focus:outline-none focus:border-red-500 font-mono",autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{className:"flex justify-end gap-3 px-6 py-4 bg-gray-900/50 rounded-b-xl border-t border-gray-700",children:[e.jsx("button",{onClick:g,className:"px-4 py-2 text-sm font-medium text-gray-300 hover:text-white bg-gray-700 hover:bg-gray-600 rounded-lg transition-colors",children:d}),e.jsx("button",{ref:v,onClick:x,disabled:!_,className:`px-4 py-2 text-sm font-medium rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${S?"bg-red-600 hover:bg-red-500 text-white disabled:hover:bg-red-600":"bg-primary-600 hover:bg-primary-500 text-white disabled:hover:bg-primary-600"}`,children:i})]})]})})}const jN={generator:["{{existing_stories}}"],consumer:["{{input_item.title}}","{{input_item.content}}"]},NN={generator:["{{existing_stories}}","{{total_stories}}","{{category_stats}}","{{inputs_list}}","{{input_item.title}}"],consumer:["{{input_item.title}}","{{input_item.content}}","{{input_item.metadata}}","{{implemented_summary}}"]};function kN(t,s,o){const l={isValid:!0,missingRequired:[],missingOptional:[],warnings:[]};if(!t||!t.trim())return l;let i,d;o&&o.length>0?(i=o.filter(u=>u.required).map(u=>u.name),d=o.map(u=>u.name)):(i=jN[s]||[],d=NN[s]||[]);for(const u of i)t.includes(u)||(l.missingRequired.push(u),l.isValid=!1);for(const u of d)!i.includes(u)&&!t.includes(u)&&l.missingOptional.push(u);return l.missingRequired.length>0&&l.warnings.push(`Missing required template variable${l.missingRequired.length>1?"s":""}: ${l.missingRequired.join(", ")}. The step may not work correctly.`),l.missingOptional.length>0&&l.missingOptional.length<=2&&l.warnings.push(`Optional variable${l.missingOptional.length>1?"s":""} not used: ${l.missingOptional.join(", ")}`),l}function CN(t,s){if(!t||!t.trim())return!1;const o=t.trim().replace(/\s+/g," "),l=s.trim().replace(/\s+/g," ");return o!==l}const jo={design_doc:{label:"Build Design Doc",description:"Interactive chat to create a PRD or design document",icon:"chat",step_type:"interactive",loopType:"design_doc",defaultTools:[],defaults:{model:"opus",timeout:600}},generator:{label:"Generate Stories (Extract)",description:"Extract user stories from design documents",icon:"list",step_type:"autonomous",loopType:"generator",defaultTools:["WebSearch","WebFetch"],defaults:{model:"opus",timeout:600,max_iterations:100,cooldown_between_iterations:5,max_consecutive_errors:5}},webgen_requirements:{label:"Generate Stories (WebSearch)",description:"Discover missing requirements via web research",icon:"search",step_type:"autonomous",loopType:"generator",template:"webgen_requirements",defaultTools:["WebSearch","WebFetch"],defaults:{model:"opus",timeout:900,max_iterations:15,cooldown_between_iterations:15,max_consecutive_errors:3}},consumer:{label:"Implementation",description:"Consumes stories and commits code to git",icon:"code",step_type:"autonomous",loopType:"consumer",defaultTools:["Read","Write","Edit","Bash","Glob","Grep"],defaults:{model:"opus",timeout:1800,max_iterations:50,cooldown_between_iterations:5,max_consecutive_errors:3}}},SN=[{id:"WebSearch",label:"WebSearch",description:"Web search for research"},{id:"WebFetch",label:"WebFetch",description:"Fetch web page content"},{id:"Read",label:"Read",description:"Read files from the codebase"},{id:"Write",label:"Write",description:"Write new files"},{id:"Edit",label:"Edit",description:"Edit existing files"},{id:"Bash",label:"Bash",description:"Run shell commands"},{id:"Glob",label:"Glob",description:"File pattern matching"},{id:"Grep",label:"Grep",description:"Search file contents"},{id:"NotebookEdit",label:"NotebookEdit",description:"Edit Jupyter notebooks"}],vn={max_iterations:100,cooldown_between_iterations:5,max_consecutive_errors:5};function _N(t){var l,i;const s=(l=t.config)==null?void 0:l.loopType,o=(i=t.config)==null?void 0:i.template;return s==="design_doc"||t.step_type==="interactive"?"design_doc":o==="webgen_requirements"?"webgen_requirements":s==="generator"||s==="planning"?"generator":"consumer"}function LN(t,s){const o=jo[s],l=o.defaults,i=t.config||{},d=[];if(i.model&&i.model!==l.model&&d.push(`AI Model (${i.model})`),i.timeout&&i.timeout!==l.timeout&&d.push(`Timeout (${i.timeout}s)`),i.max_iterations!==void 0&&i.max_iterations!==l.max_iterations&&d.push(`Max Iterations (${i.max_iterations})`),i.cooldown_between_iterations!==void 0&&i.cooldown_between_iterations!==l.cooldown_between_iterations&&d.push(`Cooldown (${i.cooldown_between_iterations}s)`),i.max_consecutive_errors!==void 0&&i.max_consecutive_errors!==l.max_consecutive_errors&&d.push(`Max Errors (${i.max_consecutive_errors})`),i.customPrompt&&d.push("Custom AI Instructions"),i.allowedTools!==void 0){const u=[...o.defaultTools].sort(),h=[...i.allowedTools].sort();JSON.stringify(h)!==JSON.stringify(u)&&d.push("Tool Selection")}return d}function EN({step:t,onChange:s}){var Pe,pe,se,Ne,Le,ot,wt,ae,Ee,Ve,at,xt,bt;const o=_N(t),l=jo[o],d=(t.iterations_completed||0)>0||(t.items_generated||0)>0,[u,h]=p.useState(!1),[x,g]=p.useState(""),[v,y]=p.useState([]),[b,k]=p.useState(!1),[_,S]=p.useState(null),[j,N]=p.useState(!1),[T,P]=p.useState(!1),[C,E]=p.useState(!1),[I,M]=p.useState(null),[q,z]=p.useState([]),U=!!((Pe=t.config)!=null&&Pe.customPrompt),O=((pe=t.config)==null?void 0:pe.customPrompt)||x,X=((se=t.config)==null?void 0:se.loopType)||"consumer",ee=U?kN(((Ne=t.config)==null?void 0:Ne.customPrompt)||"",X,v):{isValid:!0,warnings:[]},W=t.status==="active"&&t.has_active_run,te=!W,D=p.useCallback(async()=>{if(t.step_type==="autonomous"&&o!=="design_doc"){k(!0),S(null);try{const ue=await fv(X);g(ue.prompt),y(ue.variables)}catch(ue){S("Failed to load default prompt"),console.error("Error fetching default prompt:",ue)}finally{k(!1)}}},[t.step_type,o,X]);p.useEffect(()=>{D()},[D]);const R=p.useCallback(ue=>{s({...t,config:{...t.config,...ue}})},[s,t]);p.useEffect(()=>{var ue;(ue=t.config)!=null&&ue.customPrompt&&o==="design_doc"&&R({customPrompt:void 0})},[o,(Le=t.config)==null?void 0:Le.customPrompt,R]);const Y=ue=>{var Pt,lt;const $e=jo[ue];s({...t,step_type:$e.step_type,config:{description:(Pt=t.config)==null?void 0:Pt.description,skippable:(lt=t.config)==null?void 0:lt.skippable,loopType:$e.loopType,template:$e.template,allowedTools:$e.defaultTools,model:$e.defaults.model,timeout:$e.defaults.timeout,max_iterations:$e.defaults.max_iterations,cooldown_between_iterations:$e.defaults.cooldown_between_iterations,max_consecutive_errors:$e.defaults.max_consecutive_errors,customPrompt:void 0}})},ie=ue=>{if(d||ue===o)return;const $e=LN(t,o);$e.length>0?(z($e),M(ue),E(!0)):Y(ue)},re=()=>{I&&Y(I),E(!1),M(null),z([])},L=()=>{E(!1),M(null),z([])},F=ue=>{var lt;const $e=((lt=t.config)==null?void 0:lt.allowedTools)||[],Pt=$e.includes(ue)?$e.filter(cr=>cr!==ue):[...$e,ue];R({allowedTools:Pt})},H=()=>{R({allowedTools:l.defaultTools})},K=ue=>{te&&(CN(ue,x)?R({customPrompt:ue}):R({customPrompt:void 0}))},J=ue=>{te&&(ue?R({customPrompt:x}):P(!0))},he=()=>{R({customPrompt:void 0}),P(!1)},_e=ue=>l.defaultTools.includes(ue),Ae=ue=>{switch(ue){case"chat":return e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})});case"list":return e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01"})});case"search":return e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})});case"code":return e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})})}};return e.jsxs("div",{className:"space-y-6 max-w-2xl",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Step Name"}),e.jsx("input",{type:"text",value:t.name,onChange:ue=>s({...t,name:ue.target.value}),className:"w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:border-primary-500",placeholder:"e.g., Story Generation, Implementation"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300",children:"What should this step do?"}),d&&e.jsxs("span",{className:"text-xs text-amber-400 flex items-center gap-1",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})}),"Locked after running iterations"]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:Object.entries(jo).map(([ue,$e])=>e.jsxs("button",{type:"button",onClick:()=>ie(ue),disabled:d,className:`p-4 rounded-lg border text-left transition-colors ${d?o===ue?"bg-gray-800/50 border-gray-600 cursor-not-allowed":"bg-gray-800/30 border-gray-700/50 cursor-not-allowed opacity-50":o===ue?ue==="design_doc"?"bg-violet-900/30 border-violet-600":ue==="generator"?"bg-blue-900/30 border-blue-600":ue==="webgen_requirements"?"bg-cyan-900/30 border-cyan-600":"bg-emerald-900/30 border-emerald-600":"bg-gray-800 border-gray-700 hover:border-gray-600"}`,children:[e.jsx("div",{className:`flex items-center gap-2 mb-2 ${d?"text-gray-500":o===ue?ue==="design_doc"?"text-violet-400":ue==="generator"?"text-blue-400":ue==="webgen_requirements"?"text-cyan-400":"text-emerald-400":"text-gray-400"}`,children:Ae($e.icon)}),e.jsx("div",{className:`font-medium text-sm mb-1 ${d?"text-gray-400":"text-white"}`,children:$e.label}),e.jsx("p",{className:`text-xs ${d?"text-gray-600":o===ue?"text-gray-300":"text-gray-500"}`,children:$e.description})]},ue))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Description"}),e.jsx("textarea",{value:((ot=t.config)==null?void 0:ot.description)||"",onChange:ue=>R({description:ue.target.value}),className:"w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:border-primary-500 h-20 resize-none",placeholder:"What does this step do?"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("input",{type:"checkbox",id:"skippable",checked:((wt=t.config)==null?void 0:wt.skippable)||!1,onChange:ue=>R({skippable:ue.target.checked}),className:"w-4 h-4 rounded border-gray-600 bg-gray-700 text-primary-600 focus:ring-primary-500"}),e.jsx("label",{htmlFor:"skippable",className:"text-sm text-gray-300",children:"Allow skipping this step"})]}),t.step_type==="autonomous"&&e.jsxs("div",{className:"border-t border-gray-700 pt-6 space-y-6",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-300 uppercase tracking-wide",children:"Execution Settings"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"AI Model"}),e.jsxs("select",{value:((ae=t.config)==null?void 0:ae.model)||"opus",onChange:ue=>R({model:ue.target.value}),className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white focus:outline-none focus:border-primary-500",children:[e.jsx("option",{value:"opus",children:"Opus (Most Capable)"}),e.jsx("option",{value:"sonnet",children:"Sonnet (Balanced)"}),e.jsx("option",{value:"sonnet-1m",children:"Sonnet Extended (1M tokens)"}),e.jsx("option",{value:"haiku",children:"Haiku (Fast)"})]}),((Ee=t.config)==null?void 0:Ee.model)==="sonnet-1m"&&e.jsx("div",{className:"text-amber-400 text-xs mt-2 p-2 bg-amber-900/20 border border-amber-800/50 rounded",children:e.jsxs("div",{className:"flex items-start gap-1.5",children:[e.jsx("svg",{className:"w-4 h-4 flex-shrink-0 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),e.jsxs("span",{children:["Extended context is not available to all accounts. Only use this if you have already tested ",e.jsx("code",{className:"bg-amber-900/50 px-1 rounded",children:"--model sonnet"})," with large contexts in Claude Code and confirmed it works."]})]})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Timeout (seconds)"}),e.jsx("input",{type:"number",value:((Ve=t.config)==null?void 0:Ve.timeout)||600,onChange:ue=>R({timeout:parseInt(ue.target.value)||600}),min:60,max:7200,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white focus:outline-none focus:border-primary-500"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400",children:"Available Tools"}),e.jsxs("button",{type:"button",onClick:H,className:"text-xs text-primary-400 hover:text-primary-300 flex items-center gap-1",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"Reset to template defaults"]})]}),e.jsxs("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-3",children:[e.jsxs("div",{className:"text-xs text-gray-500 mb-3",children:["Template: ",l.label]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:SN.map(ue=>{var lt;const $e=(((lt=t.config)==null?void 0:lt.allowedTools)||[]).includes(ue.id),Pt=_e(ue.id);return e.jsxs("label",{className:`flex items-start gap-2 p-2 rounded cursor-pointer hover:bg-gray-700/50 ${$e?"text-white":"text-gray-500"}`,children:[e.jsx("input",{type:"checkbox",checked:$e,onChange:()=>F(ue.id),className:"mt-0.5 w-4 h-4 rounded border-gray-600 bg-gray-700 text-primary-600 focus:ring-primary-500"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-1",children:[ue.label,Pt&&e.jsx("span",{className:"text-xs text-primary-400",title:"In template defaults",children:"*"})]}),e.jsx("div",{className:"text-xs text-gray-500 truncate",children:ue.description})]})]},ue.id)})})]})]}),e.jsxs("div",{className:"border-t border-gray-700 pt-6",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-4",children:"Run Cycle Limits"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Max Run Cycles"}),e.jsx("input",{type:"number",value:((at=t.config)==null?void 0:at.max_iterations)??"",onChange:ue=>R({max_iterations:ue.target.value?parseInt(ue.target.value):void 0}),placeholder:String(vn.max_iterations),min:0,max:1e4,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white focus:outline-none focus:border-primary-500 placeholder-gray-500"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Default: ",vn.max_iterations," (0 = unlimited)"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Cooldown (sec)"}),e.jsx("input",{type:"number",value:((xt=t.config)==null?void 0:xt.cooldown_between_iterations)??"",onChange:ue=>R({cooldown_between_iterations:ue.target.value?parseInt(ue.target.value):void 0}),placeholder:String(vn.cooldown_between_iterations),min:0,max:300,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white focus:outline-none focus:border-primary-500 placeholder-gray-500"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Default: ",vn.cooldown_between_iterations,"s"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Max Errors"}),e.jsx("input",{type:"number",value:((bt=t.config)==null?void 0:bt.max_consecutive_errors)??"",onChange:ue=>R({max_consecutive_errors:ue.target.value?parseInt(ue.target.value):void 0}),placeholder:String(vn.max_consecutive_errors),min:1,max:100,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white focus:outline-none focus:border-primary-500 placeholder-gray-500"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Default: ",vn.max_consecutive_errors]})]})]})]}),e.jsxs("div",{className:"border-t border-gray-700 pt-6",children:[e.jsxs("button",{type:"button",onClick:()=>h(!u),className:"w-full flex items-center justify-between text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300",children:"AI Instructions (Advanced)"}),U&&e.jsx("span",{className:"px-2 py-0.5 bg-amber-900/30 text-amber-400 text-xs rounded-full",children:"customized"})]}),e.jsx("svg",{className:`w-5 h-5 text-gray-400 transition-transform ${u?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),u&&e.jsxs("div",{className:"mt-4 space-y-4",children:[W&&e.jsxs("div",{className:"p-3 bg-red-900/20 border border-red-800/50 rounded-lg text-red-400 text-sm flex items-start gap-2",children:[e.jsx("svg",{className:"w-5 h-5 flex-shrink-0 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),e.jsx("span",{children:"Cannot edit while step is running. Stop the step to make changes."})]}),U?e.jsx("div",{className:"p-3 bg-amber-900/20 border border-amber-800/50 rounded-lg",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("svg",{className:"w-5 h-5 text-amber-400 flex-shrink-0 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),e.jsxs("div",{className:"text-amber-400 text-sm",children:[e.jsx("strong",{children:"ADVANCED:"})," Editing these instructions can break the step. Only modify if you understand the template variables below."]})]})}):e.jsxs("div",{className:"p-3 bg-gray-800/50 border border-gray-700 rounded-lg text-gray-400 text-sm",children:["This is the recommended prompt for ",o==="generator"?"Generator (Story Extraction)":"Consumer (Implementation)"," steps."]}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("button",{type:"button",onClick:()=>N(!j),className:"text-xs text-primary-400 hover:text-primary-300 flex items-center gap-1",children:[e.jsx("svg",{className:`w-4 h-4 transition-transform ${j?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),j?"Hide":"View"," Template Variables"]})}),j&&e.jsxs("div",{className:"bg-gray-900 border border-gray-700 rounded-lg p-3 text-xs",children:[e.jsx("div",{className:"font-medium text-gray-300 mb-2",children:"Available Template Variables:"}),b?e.jsx("div",{className:"text-gray-500",children:"Loading..."}):v.length>0?e.jsx("div",{className:"space-y-2",children:v.map(ue=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("code",{className:`px-1.5 py-0.5 rounded font-mono ${ue.required?"bg-amber-900/30 text-amber-400":"bg-gray-800 text-gray-400"}`,children:ue.name}),e.jsxs("span",{className:"text-gray-500",children:[ue.description,ue.required&&e.jsx("span",{className:"text-amber-400 ml-1",children:"(required)"})]})]},ue.name))}):e.jsx("div",{className:"text-gray-500",children:"No variables available"})]}),_&&e.jsxs("div",{className:"p-3 bg-red-900/20 border border-red-800/50 rounded-lg text-red-400 text-sm flex items-center justify-between",children:[e.jsx("span",{children:_}),e.jsx("button",{type:"button",onClick:D,className:"text-red-300 hover:text-red-200 underline",children:"Retry"})]}),U&&ee.warnings.length>0&&e.jsxs("div",{className:"p-3 bg-amber-900/20 border border-amber-800/50 rounded-lg text-sm",children:[e.jsxs("div",{className:"font-medium text-amber-400 mb-1 flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01"})}),"Validation Warnings:"]}),e.jsx("ul",{className:"text-amber-400/80 space-y-1",children:ee.warnings.map((ue,$e)=>e.jsx("li",{children:ue},$e))})]}),e.jsx("div",{children:b?e.jsx("div",{className:"h-64 bg-gray-800 border border-gray-700 rounded-lg flex items-center justify-center",children:e.jsx("div",{className:"text-gray-500",children:"Loading default prompt..."})}):e.jsx("textarea",{value:O,onChange:ue=>K(ue.target.value),readOnly:!U||!te,className:`w-full h-64 px-4 py-3 bg-gray-800 border rounded-lg text-white font-mono text-sm focus:outline-none resize-y ${!U||!te?"border-gray-700 cursor-not-allowed opacity-75":ee.isValid?"border-gray-600 focus:border-primary-500":"border-amber-600 focus:border-amber-500"}`,placeholder:"AI instructions for this step..."})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:U,onChange:ue=>J(ue.target.checked),disabled:!te,className:"w-4 h-4 rounded border-gray-600 bg-gray-700 text-primary-600 focus:ring-primary-500 disabled:opacity-50"}),e.jsx("span",{className:`text-sm ${te?"text-gray-300":"text-gray-500"}`,children:"Use Custom Instructions"})]}),U&&te&&e.jsxs("button",{type:"button",onClick:()=>P(!0),className:"text-sm text-red-400 hover:text-red-300 flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"Reset to Default"]})]}),T&&e.jsxs("div",{className:"p-4 bg-gray-900 border border-gray-600 rounded-lg",children:[e.jsx("div",{className:"text-white mb-3",children:"Reset to default instructions?"}),e.jsx("p",{className:"text-gray-400 text-sm mb-4",children:"This will discard your custom instructions. This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>P(!1),className:"px-3 py-1.5 text-sm text-gray-400 hover:text-white",children:"Cancel"}),e.jsx("button",{type:"button",onClick:he,className:"px-3 py-1.5 text-sm bg-red-600 text-white rounded hover:bg-red-500",children:"Reset"})]})]})]})]})]}),C&&I&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-gray-800 border border-gray-600 rounded-lg p-6 max-w-md mx-4",children:[e.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"Change Step Type?"}),e.jsxs("p",{className:"text-gray-400 text-sm mb-4",children:["Switching to ",e.jsx("strong",{className:"text-white",children:jo[I].label})," will reset the following settings to defaults:"]}),e.jsx("ul",{className:"text-amber-400 text-sm mb-4 list-disc list-inside space-y-1",children:q.map((ue,$e)=>e.jsx("li",{children:ue},$e))}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:L,className:"px-4 py-2 text-gray-400 hover:text-white transition-colors",children:"Cancel"}),e.jsx("button",{type:"button",onClick:re,className:"px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-500 transition-colors",children:"Change Type"})]})]})})]})}function TN({projectSlug:t,loopName:s,onClose:o,onSave:l}){var U;const[i,d]=p.useState(!0),[u,h]=p.useState(!1),[x,g]=p.useState(null),[v,y]=p.useState(null),[b,k]=p.useState([]),[_,S]=p.useState(""),[j,N]=p.useState("template"),[T,P]=p.useState(""),[C,E]=p.useState(null),I=p.useCallback(async()=>{d(!0),g(null);try{const[O,X]=await Promise.all([yv(t,s),gv()]);if(y(O),k(X),O.source==="template"&&O.template_id)S(O.template_id),N("template");else if(O.source==="custom")N("custom");else{const ee=X.length>0?X[0].id:O.template_id||"";S(ee),N("template")}P(JSON.stringify(O.permissions,null,2))}catch(O){g(O instanceof Error?O.message:"Failed to load permissions")}finally{d(!1)}},[t,s]);p.useEffect(()=>{I()},[I]),p.useEffect(()=>{const O=X=>{X.key==="Escape"&&!u&&o()};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[o,u]),p.useEffect(()=>{if(j==="custom")try{JSON.parse(T),E(null)}catch{E("Invalid JSON syntax")}else E(null)},[T,j]);const M=async()=>{h(!0),g(null);try{if(j==="template")await L0(t,s,{template_id:_,permissions:{allow:[]}});else{const O=JSON.parse(T);await L0(t,s,{permissions:O})}l==null||l(),o()}catch(O){g(O instanceof Error?O.message:"Failed to save permissions")}finally{h(!1)}},q=async()=>{if(confirm("Reset to default permissions? This will remove any custom settings.")){h(!0),g(null);try{await vv(t,s),await I()}catch(O){g(O instanceof Error?O.message:"Failed to reset permissions")}finally{h(!1)}}},z=O=>{S(O)};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-gray-900 rounded-xl border border-gray-700 w-full max-w-2xl mx-4 max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-700",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-white",children:"Edit Loop Permissions"}),e.jsxs("p",{className:"text-sm text-gray-400 mt-1",children:["Configure Claude Code permissions for ",e.jsx("span",{className:"text-primary-400",children:s})]})]}),e.jsx("button",{onClick:o,className:"text-gray-400 hover:text-white","aria-label":"Close",children:e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:i?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary-500"})}):x?e.jsx("div",{className:"p-4 bg-red-900/20 border border-red-800 rounded-lg text-red-400",children:x}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-4 bg-gray-800 rounded-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-gray-400",children:"Current Source:"}),e.jsx("span",{className:`ml-2 px-2 py-0.5 rounded text-xs font-medium ${(v==null?void 0:v.source)==="custom"?"bg-purple-500/20 text-purple-400":(v==null?void 0:v.source)==="template"?"bg-blue-500/20 text-blue-400":"bg-gray-700 text-gray-400"}`,children:(v==null?void 0:v.source)==="custom"?"Custom":(v==null?void 0:v.source)==="template"?`Template: ${v==null?void 0:v.template_id}`:"Default"})]}),(v==null?void 0:v.has_custom)&&e.jsx("button",{onClick:q,disabled:u,className:"text-sm text-gray-400 hover:text-red-400",children:"Reset to Default"})]})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx("button",{onClick:()=>N("template"),className:`flex-1 py-2 px-4 rounded-lg text-sm font-medium transition-colors ${j==="template"?"bg-primary-600 text-white":"bg-gray-800 text-gray-400 hover:text-white"}`,children:"Use Template"}),e.jsx("button",{onClick:()=>N("custom"),className:`flex-1 py-2 px-4 rounded-lg text-sm font-medium transition-colors ${j==="custom"?"bg-primary-600 text-white":"bg-gray-800 text-gray-400 hover:text-white"}`,children:"Custom Permissions"})]}),j==="template"&&e.jsx("div",{className:"space-y-4",children:b.length===0?e.jsxs("div",{className:"p-4 bg-gray-800/50 rounded-lg text-center text-gray-400",children:[e.jsx("p",{children:"No permission templates available."}),e.jsx("p",{className:"text-sm mt-1",children:"Switch to Custom mode to define permissions manually."})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Select Template"}),e.jsx("select",{value:_,onChange:O=>z(O.target.value),className:"w-full px-4 py-2 bg-gray-800 border border-gray-600 rounded-lg text-white focus:outline-none focus:border-primary-500",children:b.map(O=>e.jsx("option",{value:O.id,children:O.name},O.id))})]}),b.find(O=>O.id===_)&&e.jsx("div",{className:"p-4 bg-gray-800/50 rounded-lg",children:e.jsx("p",{className:"text-sm text-gray-400",children:(U=b.find(O=>O.id===_))==null?void 0:U.description})})]})}),j==="custom"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Permissions JSON"}),e.jsx("textarea",{value:T,onChange:O=>P(O.target.value),rows:16,className:`w-full px-3 py-2 bg-gray-800 border rounded-lg text-white font-mono text-sm resize-none focus:outline-none ${C?"border-red-600 focus:border-red-500":"border-gray-600 focus:border-primary-500"}`,placeholder:'{"allow": ["Read(**)", "Write(**)", ...], "deny": []}'}),C&&e.jsx("p",{className:"mt-1 text-sm text-red-400",children:C})]}),e.jsxs("div",{className:"p-4 bg-gray-800/50 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-2",children:"Common Patterns"}),e.jsxs("div",{className:"text-xs text-gray-500 space-y-1 font-mono",children:[e.jsx("div",{children:"Read(**) - Read any file"}),e.jsx("div",{children:"Write(**) - Write any file"}),e.jsx("div",{children:"Edit(**) - Edit any file"}),e.jsx("div",{children:"Bash(*) - Run any bash command"}),e.jsx("div",{children:"Bash(git *) - Run git commands only"}),e.jsx("div",{children:"WebSearch - Enable web search"})]})]})]})]})}),e.jsxs("div",{className:"flex items-center justify-end space-x-3 p-6 border-t border-gray-700",children:[e.jsx("button",{onClick:o,className:"px-4 py-2 bg-gray-700 text-gray-300 rounded-lg hover:bg-gray-600",children:"Cancel"}),e.jsx("button",{onClick:M,disabled:u||i||j==="custom"&&!!C||j==="template"&&b.length===0,className:"px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-500 disabled:opacity-50",children:u?"Saving...":"Save Permissions"})]})]})})}function AN({projectSlug:t,workflowId:s,step:o,onChange:l,onClone:i,onArchive:d,onError:u}){var K;const[h,x]=p.useState("settings"),[g,v]=p.useState([]),[y,b]=p.useState([]),[k,_]=p.useState(!1),[S,j]=p.useState(!1),[N,T]=p.useState(!1),[P,C]=p.useState({name:"",resource_type:"guardrail",content:""}),[E,I]=p.useState(!1),[M,q]=p.useState(null),[z,U]=p.useState(!1),[O,X]=p.useState(!1),[ee,W]=p.useState(!1);p.useEffect(()=>{x("settings")},[o.id]),p.useEffect(()=>{if(!(N||E||O))return;const he=_e=>{_e.key==="Escape"&&(N?T(!1):E?I(!1):O&&X(!1))};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[N,E,O]);const te=p.useCallback(async()=>{if(o.id){_(!0);try{const[J,he]=await Promise.all([fl(t,s),t2(t,s,o.id)]);v(J),b(he)}catch(J){u(J instanceof Error?J.message:"Failed to load resources")}finally{_(!1)}}},[t,s,o.id,u]);p.useEffect(()=>{h==="resources"&&o.id&&te()},[h,o.id,te]);const D=async J=>{if(!(!o.id||S)){j(!0);try{y.find(_e=>_e.workflow_resource_id===J.id&&_e.mode==="disable")?await o2(t,s,o.id,J.id):await n2(t,s,o.id,J.id),await te()}catch(he){u(he instanceof Error?he.message:"Failed to toggle resource")}finally{j(!1)}}},R=J=>y.some(he=>he.workflow_resource_id===J&&he.mode==="disable"),Y=async J=>{if(J.preventDefault(),!(!o.id||!P.name.trim()||!P.content.trim())&&!S){j(!0);try{await r2(t,s,o.id,{mode:"add",resource_type:P.resource_type,name:P.name.trim(),content:P.content.trim()}),C({name:"",resource_type:"guardrail",content:""}),T(!1),await te()}catch(he){u(he instanceof Error?he.message:"Failed to add step resource")}finally{j(!1)}}},ie=async J=>{if(!(!o.id||S)&&confirm("Delete this step resource?")){j(!0);try{await s2(t,s,o.id,J.id),await te()}catch(he){u(he instanceof Error?he.message:"Failed to delete step resource")}finally{j(!1)}}},re=async()=>{if(o.id){U(!0);try{const J=await a2(t,s,o.id);q(J),I(!0)}catch(J){u(J instanceof Error?J.message:"Failed to load preview")}finally{U(!1)}}},L=J=>{switch(J){case"design_doc":return"Design Document";case"guardrail":return"Guideline";case"input_file":return"Input File";case"prompt":return"Prompt";default:return J}},F=J=>{switch(J){case"design_doc":return e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})});case"guardrail":return e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})});default:return e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})})}},H=[{key:"settings",label:"Settings"},{key:"resources",label:"Resources",disabled:!o.id||o.step_type!=="autonomous"},{key:"permissions",label:"Permissions",disabled:!o.id||o.step_type!=="autonomous"}];return e.jsxs("div",{className:"card h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 pb-4 border-b border-gray-700",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Step ",o.step_number,": ",o.name||"Untitled"]}),e.jsxs("p",{className:"text-sm text-gray-400 mt-1",children:[o.step_type==="interactive"?"Chat Step":"Automated Step",((K=o.config)==null?void 0:K.model)&&o.step_type==="autonomous"&&` (${o.config.model})`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!o.id&&e.jsx("span",{className:"px-2 py-1 text-xs rounded bg-yellow-900/50 text-yellow-400 border border-yellow-700/50",children:"Save workflow to enable all features"}),e.jsx("button",{onClick:i,className:"px-3 py-1.5 text-sm text-gray-400 hover:text-white bg-gray-700 hover:bg-gray-600 rounded transition-colors",title:"Clone step",children:"Clone"}),e.jsx("button",{onClick:()=>W(!0),className:"px-3 py-1.5 text-sm text-red-400 hover:text-red-300 bg-gray-700 hover:bg-red-900/30 rounded transition-colors",title:"Archive step",children:"Archive"})]})]}),o.step_type==="autonomous"&&e.jsx("div",{className:"flex space-x-1 border-b border-gray-700 mb-4",children:H.map(J=>e.jsx("button",{onClick:()=>!J.disabled&&x(J.key),disabled:J.disabled,className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${h===J.key?"border-primary-500 text-white":J.disabled?"border-transparent text-gray-600 cursor-not-allowed":"border-transparent text-gray-400 hover:text-gray-300"}`,children:J.label},J.key))}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[(h==="settings"||o.step_type==="interactive")&&e.jsx(EN,{step:o,onChange:l}),h==="resources"&&o.step_type==="autonomous"&&o.id&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300",children:"Inherited from Workflow"}),e.jsxs("button",{onClick:re,disabled:z,className:"flex items-center space-x-1 text-sm text-primary-400 hover:text-primary-300 disabled:opacity-50",children:[e.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]}),e.jsx("span",{children:z?"Loading...":"Preview Prompt"})]})]}),k?e.jsx("div",{className:"text-center py-4 text-gray-500",children:"Loading resources..."}):g.length===0?e.jsx("div",{className:"text-center py-4 text-gray-500",children:"No workflow resources. Add resources in the Resources tab."}):e.jsx("div",{className:"space-y-2",children:g.map(J=>{const he=R(J.id);return e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border ${he?"bg-gray-800/50 border-gray-700 opacity-60":"bg-gray-700 border-gray-600"}`,children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:`p-2 rounded ${he?"bg-gray-700 text-gray-500":"bg-primary-500/20 text-primary-400"}`,children:F(J.resource_type)}),e.jsxs("div",{children:[e.jsx("div",{className:`font-medium ${he?"text-gray-500":"text-white"}`,children:J.name}),e.jsxs("div",{className:"text-xs text-gray-500",children:[L(J.resource_type),he&&" — disabled for this step"]})]})]}),e.jsx("button",{onClick:()=>D(J),disabled:S,className:`px-3 py-1 text-xs rounded transition-colors ${he?"bg-gray-700 text-gray-400 hover:bg-gray-600":"bg-green-600/20 text-green-400 hover:bg-green-600/30"}`,children:he?"Enable":"Enabled"})]},J.id)})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300",children:"Step-Specific Resources"}),e.jsxs("button",{onClick:()=>T(!0),className:"flex items-center space-x-1 text-sm text-primary-400 hover:text-primary-300",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),e.jsx("span",{children:"Add Resource"})]})]}),y.filter(J=>J.mode==="add").length===0?e.jsx("div",{className:"text-center py-4 text-gray-500 text-sm",children:"No step-specific resources. These are additional resources only used by this step."}):e.jsx("div",{className:"space-y-2",children:y.filter(J=>J.mode==="add").map(J=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-700 rounded-lg border border-gray-600",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"p-2 rounded bg-blue-500/20 text-blue-400",children:F(J.resource_type||"custom")}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-white",children:J.name}),e.jsxs("div",{className:"text-xs text-gray-500",children:[L(J.resource_type||"custom")," — step-specific"]})]})]}),e.jsx("button",{onClick:()=>ie(J),disabled:S,className:"p-1 text-gray-400 hover:text-red-400 disabled:opacity-50",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]},J.id))})]})]}),h==="permissions"&&o.step_type==="autonomous"&&o.id&&e.jsx("div",{children:o.loop_name?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-gray-400",children:"Configure which tools and file operations Claude can use during this step's execution."}),e.jsxs("button",{type:"button",onClick:()=>X(!0),className:"flex items-center space-x-2 px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-500",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})}),e.jsx("span",{children:"Edit Claude Code Permissions"})]})]}):e.jsxs("div",{className:"flex items-start space-x-3 p-4 bg-gray-700 rounded-lg",children:[e.jsx("svg",{className:"w-5 h-5 text-gray-400 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-300",children:"Permissions can be configured after the step is started for the first time."}),e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Start the workflow to create the execution environment, then return here to configure permissions."})]})]})})]}),N&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:J=>{J.target===J.currentTarget&&T(!1)},children:e.jsxs("div",{className:"bg-gray-800 rounded-xl border border-gray-600 p-6 w-full max-w-lg mx-4 max-h-[80vh] overflow-y-auto",children:[e.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Add Step Resource"}),e.jsxs("form",{onSubmit:Y,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Resource Type"}),e.jsxs("select",{value:P.resource_type,onChange:J=>C({...P,resource_type:J.target.value}),className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white focus:outline-none focus:border-primary-500",children:[e.jsx("option",{value:"guardrail",children:"Guideline"}),e.jsx("option",{value:"design_doc",children:"Design Document"}),e.jsx("option",{value:"input_file",children:"Input File"}),e.jsx("option",{value:"prompt",children:"Prompt"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Name"}),e.jsx("input",{type:"text",value:P.name,onChange:J=>C({...P,name:J.target.value}),placeholder:"e.g., Step-Specific Guidelines",className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:border-primary-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Content"}),e.jsx("textarea",{value:P.content,onChange:J=>C({...P,content:J.target.value}),placeholder:"Resource content...",rows:8,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:border-primary-500 font-mono text-sm resize-none"})]}),e.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[e.jsx("button",{type:"button",onClick:()=>T(!1),className:"px-4 py-2 bg-gray-700 text-gray-300 rounded-lg hover:bg-gray-600",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:!P.name.trim()||!P.content.trim()||S,className:"px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-500 disabled:opacity-50",children:S?"Adding...":"Add Resource"})]})]})]})}),E&&M&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:J=>{J.target===J.currentTarget&&I(!1)},children:e.jsxs("div",{className:"bg-gray-800 rounded-xl border border-gray-600 w-full max-w-4xl mx-4 max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-600",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:"Prompt Preview"}),e.jsxs("p",{className:"text-sm text-gray-400 mt-1",children:[M.resources_used.length," resources • ~",M.total_tokens_estimate.toLocaleString()," tokens"]})]}),e.jsx("button",{onClick:()=>I(!1),className:"text-gray-400 hover:text-white",children:e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-4",children:M.prompt_sections.length===0?e.jsx("div",{className:"text-center py-8 text-gray-500",children:"No resources will be injected for this step."}):M.prompt_sections.map((J,he)=>e.jsxs("div",{className:"border border-gray-600 rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-gray-700 border-b border-gray-600",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("span",{className:"text-sm font-medium text-white",children:J.resource_name}),e.jsx("span",{className:"text-xs bg-gray-600 text-gray-300 px-2 py-0.5 rounded",children:J.resource_type})]}),e.jsx("span",{className:"text-xs text-gray-500",children:J.position})]}),e.jsx("pre",{className:"p-4 text-sm text-gray-300 overflow-x-auto bg-gray-900 max-h-64",children:J.content.length>2e3?J.content.slice(0,2e3)+`
191
- ... (truncated)`:J.content})]},he))}),e.jsx("div",{className:"flex justify-end p-6 border-t border-gray-600",children:e.jsx("button",{onClick:()=>I(!1),className:"px-4 py-2 bg-gray-700 text-gray-300 rounded-lg hover:bg-gray-600",children:"Close"})})]})}),O&&o.loop_name&&e.jsx(TN,{projectSlug:t,loopName:o.loop_name,onClose:()=>X(!1),onSave:()=>{}}),e.jsx(Ax,{isOpen:ee,title:`Archive "${o.name}"?`,message:"This step will be moved to the trash and can be recovered later.",details:(o.iterations_completed||0)>0||(o.items_generated||0)>0?`This step has ${o.iterations_completed||0} iterations and ${o.items_generated||0} items generated. These will be preserved.`:void 0,confirmLabel:"Archive Step",variant:"danger",onConfirm:()=>{W(!1),d()},onCancel:()=>W(!1)})]})}function PN({archivedSteps:t,loading:s,onRestore:o,onPermanentlyDelete:l}){const[i,d]=p.useState(!1),[u,h]=p.useState(null),[x,g]=p.useState(null);return!s&&t.length===0?null:e.jsxs("div",{className:"mt-4 border-t border-gray-700 pt-4",children:[e.jsxs("button",{onClick:()=>d(!i),className:"w-full flex items-center justify-between px-2 py-1 text-sm text-gray-400 hover:text-gray-300 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})}),e.jsxs("span",{children:["Trash (",t.length,")"]})]}),e.jsx("svg",{className:`w-4 h-4 transition-transform ${i?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),i&&e.jsx("div",{className:"mt-2 space-y-2",children:s?e.jsx("div",{className:"text-center py-2 text-gray-500 text-sm",children:"Loading..."}):t.map(v=>e.jsxs("div",{className:"flex items-center justify-between py-2 px-3 bg-gray-800/50 rounded",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("span",{className:"text-gray-500 text-xs mr-2",children:["#",v.step_number]}),e.jsx("span",{className:"text-gray-400 text-sm truncate",children:v.name})]}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0 ml-2",children:[e.jsx("button",{onClick:async()=>{g(v.id);try{await o(v)}finally{g(null)}},disabled:x!==null,className:"px-2 py-1 text-xs text-primary-400 hover:text-primary-300 bg-gray-700 hover:bg-gray-600 rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Restore step to original position",children:x===v.id?"Restoring...":"Restore"}),e.jsx("button",{onClick:()=>h(v),disabled:x!==null,className:"px-2 py-1 text-xs text-red-400 hover:text-red-300 bg-gray-700 hover:bg-red-900/30 rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Permanently delete step",children:x===v.id?"Deleting...":"Delete"})]})]},v.id))}),e.jsx(Ax,{isOpen:u!==null,title:`Permanently delete "${u==null?void 0:u.name}"?`,message:"This action cannot be undone. The step and all its data will be permanently removed.",confirmLabel:"Delete Forever",variant:"danger",typeToConfirm:"delete",onConfirm:async()=>{if(u){const v=u;h(null),g(v.id);try{await l(v)}finally{g(null)}}},onCancel:()=>h(null)})]})}function MN({projectSlug:t,workflowId:s,steps:o,onStepsChange:l,onError:i}){const[d,u]=p.useState(o.length>0?0:null),[h,x]=p.useState([]),[g,v]=p.useState(!1),y=d!==null?o[d]:null,b=p.useCallback(async()=>{if(s){v(!0);try{const C=await Yv(t,s);x(C)}catch(C){console.error("Failed to load archived steps:",C)}finally{v(!1)}}},[t,s]);p.useEffect(()=>{b()},[b]);const k=()=>{const C={id:0,workflow_id:s,step_number:o.length+1,name:"New Step",step_type:"autonomous",status:"pending",config:{description:"",skippable:!1,loopType:"consumer",model:"opus",timeout:600,allowedTools:["Read","Write","Edit","Bash","Glob","Grep"]}};l([...o,C]),u(o.length)},_=C=>{const E=o[C],I={id:0,workflow_id:s,step_number:o.length+1,name:`${E.name} (Copy)`,step_type:E.step_type,status:"pending",config:{...E.config},iterations_completed:0,items_generated:0};l([...o,I]),u(o.length)},S=async C=>{const E=o[C];if(!E.id){const I=o.filter((M,q)=>q!==C);l(I),d===C?u(I.length>0?Math.max(0,C-1):null):d!==null&&d>C&&u(d-1);return}try{await Vv(t,s,E.id);const I=o.filter((M,q)=>q!==C);l(I),x(M=>[...M,{...E,archived_at:new Date().toISOString()}]),d===C?u(I.length>0?Math.max(0,C-1):null):d!==null&&d>C&&u(d-1)}catch(I){i(I instanceof Error?I.message:"Failed to archive step")}},j=async C=>{try{const E=await qv(t,s,C.id);x(q=>q.filter(z=>z.id!==C.id));const I=[...o],M=I.findIndex(q=>q.step_number>E.step_number);M===-1?I.push(E):I.splice(M,0,E),l(I)}catch(E){i(E instanceof Error?E.message:"Failed to restore step")}},N=async C=>{try{await zh(t,s,C.id),x(E=>E.filter(I=>I.id!==C.id))}catch(E){i(E instanceof Error?E.message:"Failed to delete step")}},T=(C,E)=>{const I=E==="up"?C-1:C+1;if(I<0||I>=o.length)return;const M=[...o],[q]=M.splice(C,1);M.splice(I,0,q),l(M),d===C?u(I):d===I&&u(C)},P=C=>{if(d===null)return;const E=[...o];E[d]=C,l(E)};return e.jsxs("div",{className:"flex gap-6 h-[calc(100vh-220px)]",children:[e.jsxs("div",{className:"w-64 flex-shrink-0 flex flex-col",children:[e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(bN,{steps:o,selectedIndex:d,onSelect:u,onAdd:k,onMove:T})}),e.jsx(PN,{archivedSteps:h,loading:g,onRestore:j,onPermanentlyDelete:N})]}),e.jsx("div",{className:"flex-1 min-w-0",children:y?e.jsx(AN,{projectSlug:t,workflowId:s,step:y,onChange:P,onClone:()=>_(d),onArchive:()=>S(d),onError:i}):e.jsx("div",{className:"h-full flex items-center justify-center card",children:e.jsxs("div",{className:"text-center",children:[e.jsx("svg",{className:"w-16 h-16 mx-auto text-gray-600 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),e.jsx("h3",{className:"text-lg font-medium text-gray-300 mb-2",children:"No Steps Yet"}),e.jsx("p",{className:"text-gray-500 mb-4",children:"Add your first step to define your workflow."}),e.jsx("button",{onClick:k,className:"px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-500",children:"Add First Step"})]})})})]})}function RN({projectSlug:t,workflowId:s,resources:o,projectResources:l,onResourcesChange:i,onError:d}){const[u,h]=p.useState(!1),[x,g]=p.useState(!1),[v,y]=p.useState(!1),[b,k]=p.useState(null),[_,S]=p.useState(""),[j,N]=p.useState({name:"",resource_type:"guardrail",content:""});p.useEffect(()=>{if(!(x||v||b!==null))return;const Y=ie=>{ie.key==="Escape"&&(x?(g(!1),N({name:"",resource_type:"guardrail",content:""})):v?y(!1):b&&k(null))};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[x,v,b]);const T=async R=>{if(R.preventDefault(),!(!j.name.trim()||!j.content.trim())&&!u){h(!0);try{await Kc(t,s,{name:j.name.trim(),resource_type:j.resource_type,content:j.content.trim(),source:"manual"}),N({name:"",resource_type:"guardrail",content:""}),g(!1),i()}catch(Y){d(Y instanceof Error?Y.message:"Failed to add resource")}finally{h(!1)}}},P=async R=>{if(!u){h(!0);try{await Uh(t,s,R.id),y(!1),i()}catch(Y){d(Y instanceof Error?Y.message:"Failed to import resource")}finally{h(!1)}}},C=async R=>{if(!u){h(!0);try{await So(t,s,R.id,{enabled:!R.enabled}),i()}catch(Y){d(Y instanceof Error?Y.message:"Failed to update resource")}finally{h(!1)}}},E=async()=>{if(b&&!u){h(!0);try{await So(t,s,b.id,{content:_}),k(null),i()}catch(R){d(R instanceof Error?R.message:"Failed to save resource")}finally{h(!1)}}},I=async R=>{if(confirm(`Delete "${R.name}"? This cannot be undone.`)&&!u){h(!0);try{await Hh(t,s,R.id),i()}catch(Y){d(Y instanceof Error?Y.message:"Failed to delete resource")}finally{h(!1)}}},M=R=>{switch(R){case"design_doc":return"Design Document";case"guardrail":return"Guideline";case"input_file":return"Input File";case"prompt":return"Prompt";default:return R}},q=R=>{switch(R){case"design_doc":return e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})});case"guardrail":return e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})});default:return e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})})}},z=new Set(o.filter(R=>R.source_id).map(R=>R.source_id)),U=l.filter(R=>!z.has(R.id)),O=o.filter(R=>R.resource_type==="design_doc"),X=o.filter(R=>R.resource_type==="guardrail"),ee=o.filter(R=>R.resource_type==="input_file"),W=o.filter(R=>R.resource_type==="prompt"),te=o.filter(R=>!["design_doc","guardrail","input_file","prompt"].includes(R.resource_type)),D=(R,Y,ie)=>Y.length===0?null:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"flex items-center gap-2 text-sm font-medium text-gray-300",children:[ie,R,e.jsxs("span",{className:"text-gray-500",children:["(",Y.length,")"]})]}),e.jsx("div",{className:"space-y-2",children:Y.map(re=>e.jsxs("div",{className:"flex items-start space-x-3 p-4 bg-gray-800 rounded-lg border border-gray-700",children:[e.jsx("div",{className:`p-2 rounded ${re.enabled?"bg-primary-500/20 text-primary-400":"bg-gray-700 text-gray-500"}`,children:q(re.resource_type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-white truncate",children:re.name}),e.jsxs("div",{className:"text-xs text-gray-400",children:[M(re.resource_type),re.source&&` • ${re.source}`]}),re.content&&e.jsx("p",{className:"text-xs text-gray-500 mt-1 line-clamp-2",children:re.content.length>150?`${re.content.slice(0,150)}...`:re.content})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>C(re),disabled:u,className:`px-2 py-1 text-xs rounded disabled:opacity-50 ${re.enabled?"bg-green-600/20 text-green-400":"bg-gray-700 text-gray-500"}`,children:re.enabled?"On":"Off"}),e.jsx("button",{onClick:()=>{k(re),S(re.content||"")},disabled:u,className:"p-1 text-gray-400 hover:text-white disabled:opacity-50",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),e.jsx("button",{onClick:()=>I(re),disabled:u,className:"p-1 text-gray-400 hover:text-red-400 disabled:opacity-50",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})]},re.id))})]});return e.jsxs("div",{className:"max-w-4xl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-white",children:"Workflow Resources"}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"These resources are available to all steps in this workflow"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("button",{onClick:()=>y(!0),className:"flex items-center space-x-1 px-3 py-2 bg-gray-700 text-gray-300 rounded-lg hover:bg-gray-600",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})}),e.jsx("span",{children:"Import from Library"})]}),e.jsxs("button",{onClick:()=>g(!0),className:"flex items-center space-x-1 px-3 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-500",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),e.jsx("span",{children:"Add Resource"})]})]})]}),o.length===0?e.jsxs("div",{className:"text-center py-12 card",children:[e.jsx("svg",{className:"w-16 h-16 mx-auto text-gray-600 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),e.jsx("h3",{className:"text-lg font-medium text-gray-300 mb-2",children:"No Resources Yet"}),e.jsx("p",{className:"text-gray-500 mb-4 max-w-md mx-auto",children:"Add design documents, guidelines, or other context to help Claude understand your project."}),e.jsxs("div",{className:"flex items-center justify-center space-x-3",children:[e.jsx("button",{onClick:()=>y(!0),className:"px-4 py-2 bg-gray-700 text-gray-300 rounded-lg hover:bg-gray-600",children:"Import from Library"}),e.jsx("button",{onClick:()=>g(!0),className:"px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-500",children:"Add Resource"})]})]}):e.jsxs("div",{className:"space-y-6",children:[D("Design Documents",O,e.jsx("svg",{className:"w-4 h-4 text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})),D("Guidelines",X,e.jsx("svg",{className:"w-4 h-4 text-violet-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})})),D("Input Files",ee,e.jsx("svg",{className:"w-4 h-4 text-emerald-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})})),D("Prompts",W,e.jsx("svg",{className:"w-4 h-4 text-amber-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})),D("Other",te,e.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h7"})}))]}),x&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:R=>{R.target===R.currentTarget&&(g(!1),N({name:"",resource_type:"guardrail",content:""}))},children:e.jsxs("div",{className:"bg-gray-800 rounded-xl border border-gray-600 p-6 w-full max-w-lg mx-4 max-h-[80vh] overflow-y-auto",children:[e.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Add Resource"}),e.jsxs("form",{onSubmit:T,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Resource Type"}),e.jsxs("select",{value:j.resource_type,onChange:R=>N({...j,resource_type:R.target.value}),className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white focus:outline-none focus:border-primary-500",children:[e.jsx("option",{value:"design_doc",children:"Design Document"}),e.jsx("option",{value:"guardrail",children:"Guideline"}),e.jsx("option",{value:"input_file",children:"Input File"}),e.jsx("option",{value:"prompt",children:"Prompt"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Name"}),e.jsx("input",{type:"text",value:j.name,onChange:R=>N({...j,name:R.target.value}),placeholder:"e.g., Code Style Guidelines",className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:border-primary-500"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:["Upload File ",e.jsx("span",{className:"text-gray-500 font-normal",children:"(optional)"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("label",{className:"flex-1 flex items-center justify-center gap-2 px-4 py-3 bg-gray-700 border border-gray-600 border-dashed rounded-lg cursor-pointer hover:bg-gray-650 hover:border-gray-500 transition-colors",children:[e.jsx("svg",{className:"w-5 h-5 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),e.jsx("span",{className:"text-sm text-gray-400",children:"Click to upload .md, .txt, or .json"}),e.jsx("input",{type:"file",accept:".md,.txt,.json,.markdown",className:"hidden",onChange:R=>{var ie;const Y=(ie=R.target.files)==null?void 0:ie[0];if(Y){if(!j.name.trim()){const L=Y.name.replace(/\.[^/.]+$/,"");N(F=>({...F,name:L}))}const re=new FileReader;re.onload=L=>{var H;const F=(H=L.target)==null?void 0:H.result;N(K=>({...K,content:F}))},re.readAsText(Y)}R.target.value=""}})]})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Content"}),e.jsx("textarea",{value:j.content,onChange:R=>N({...j,content:R.target.value}),placeholder:"Paste content here or upload a file above...",rows:10,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:border-primary-500 font-mono text-sm resize-none"}),j.content&&e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[j.content.length.toLocaleString()," characters"]})]}),e.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[e.jsx("button",{type:"button",onClick:()=>{g(!1),N({name:"",resource_type:"guardrail",content:""})},className:"px-4 py-2 bg-gray-700 text-gray-300 rounded-lg hover:bg-gray-600",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:!j.name.trim()||!j.content.trim()||u,className:"px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-500 disabled:opacity-50",children:u?"Adding...":"Add Resource"})]})]})]})}),v&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:R=>{R.target===R.currentTarget&&y(!1)},children:e.jsxs("div",{className:"bg-gray-800 rounded-xl border border-gray-600 p-6 w-full max-w-lg mx-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Import from Project Library"}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Select a resource from the project's shared library."}),U.length===0?e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-gray-400",children:l.length===0?"No shared resources in project library":"All project resources are already imported"})}):e.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:U.map(R=>e.jsx("button",{onClick:()=>P(R),disabled:u,className:"w-full p-3 bg-gray-700 rounded-lg hover:bg-gray-600 text-left disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-white font-medium",children:R.name}),e.jsx("p",{className:"text-sm text-gray-400",children:M(R.resource_type)})]}),R.auto_inherit&&e.jsx("span",{className:"text-xs bg-primary-500/20 text-primary-400 px-2 py-1 rounded",children:"Auto"})]})},R.id))}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx("button",{onClick:()=>y(!1),className:"px-4 py-2 bg-gray-700 text-gray-300 rounded-lg hover:bg-gray-600",children:"Close"})})]})}),b&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:R=>{R.target===R.currentTarget&&k(null)},children:e.jsxs("div",{className:"bg-gray-800 rounded-xl border border-gray-600 p-6 w-full max-w-2xl mx-4 max-h-[80vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:b.name}),e.jsx("span",{className:"text-sm bg-gray-700 text-gray-400 px-2 py-1 rounded",children:M(b.resource_type)})]}),e.jsx("textarea",{value:_,onChange:R=>S(R.target.value),rows:16,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white font-mono text-sm resize-none"}),e.jsxs("div",{className:"flex justify-end space-x-3 mt-4",children:[e.jsx("button",{onClick:()=>k(null),className:"px-4 py-2 bg-gray-700 text-gray-300 rounded-lg hover:bg-gray-600",children:"Cancel"}),e.jsx("button",{onClick:E,disabled:u,className:"px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-500 disabled:opacity-50",children:u?"Saving...":"Save Changes"})]})]})})]})}function IN({workflow:t,projectSlug:s,onWorkflowUpdate:o,onError:l}){const i=ir();return e.jsxs("div",{className:"max-w-2xl space-y-6",children:[e.jsxs("div",{className:"card",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-300 uppercase tracking-wide mb-4",children:"Workflow Information"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-500 mb-1",children:"Workflow ID"}),e.jsx("div",{className:"text-white font-mono text-sm",children:t.id})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-500 mb-1",children:"Status"}),e.jsx("div",{className:"text-white",children:t.status})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-500 mb-1",children:"Current Step"}),e.jsxs("div",{className:"text-white",children:[t.current_step," of ",t.steps.length]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-500 mb-1",children:"Steps"}),e.jsx("div",{className:"text-white",children:t.steps.length})]})]})]}),e.jsxs("div",{className:"card",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-300 uppercase tracking-wide mb-4",children:"Auto-Advance Rules"}),e.jsx("div",{className:"rounded-lg bg-gray-800 border border-gray-700 p-4",children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("svg",{className:"w-5 h-5 text-gray-400 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-300",children:"Auto-advance rules let you define when a workflow should automatically move to the next step."}),e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:'Coming soon: Configure conditions like "advance when all items are completed" or "advance after approval".'})]})]})})]}),e.jsxs("div",{className:"card border-red-900/50",children:[e.jsx("h3",{className:"text-sm font-medium text-red-400 uppercase tracking-wide mb-4",children:"Danger Zone"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-white font-medium",children:"Reset Workflow"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Reset the workflow to its initial state. All progress will be lost."})]}),e.jsx("button",{onClick:()=>{confirm("Are you sure you want to reset this workflow? All progress will be lost.")&&alert("Workflow reset is not yet implemented")},className:"px-4 py-2 bg-red-900/30 text-red-400 rounded-lg hover:bg-red-900/50 border border-red-800/50",children:"Reset"})]}),e.jsx("div",{className:"border-t border-red-900/30"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-white font-medium",children:"Archive Workflow"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Move this workflow to the archive. You can restore it later."})]}),e.jsx("button",{onClick:()=>{i(`/projects/${s}/workflows/${t.id}`)},className:"px-4 py-2 bg-gray-700 text-gray-300 rounded-lg hover:bg-gray-600",children:"Archive"})]})]})]}),e.jsxs("div",{className:"rounded-lg bg-gray-800/50 border border-gray-700 p-4",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-2",children:"Tips"}),e.jsxs("ul",{className:"text-sm text-gray-400 space-y-2",children:[e.jsxs("li",{className:"flex items-start space-x-2",children:[e.jsx("span",{className:"text-primary-400",children:"•"}),e.jsxs("span",{children:["Use keyboard shortcut ",e.jsx("kbd",{className:"px-1.5 py-0.5 bg-gray-700 rounded text-xs",children:"Cmd+S"})," to save changes quickly"]})]}),e.jsxs("li",{className:"flex items-start space-x-2",children:[e.jsx("span",{className:"text-primary-400",children:"•"}),e.jsxs("span",{children:["Press ",e.jsx("kbd",{className:"px-1.5 py-0.5 bg-gray-700 rounded text-xs",children:"Esc"})," to return to the workflow detail view"]})]}),e.jsxs("li",{className:"flex items-start space-x-2",children:[e.jsx("span",{className:"text-primary-400",children:"•"}),e.jsx("span",{children:"Add a design document to help Claude understand your project requirements"})]}),e.jsxs("li",{className:"flex items-start space-x-2",children:[e.jsx("span",{className:"text-primary-400",children:"•"}),e.jsx("span",{children:"Configure guidelines to set boundaries and coding standards for Claude"})]})]})]})]})}function $N(){const{slug:t,workflowId:s}=yr(),o=ir(),[l,i]=p.useState(null),[d,u]=p.useState(!0),[h,x]=p.useState(null),[g,v]=p.useState(""),[y,b]=p.useState([]),[k,_]=p.useState([]),[S,j]=p.useState([]),[N,T]=p.useState("overview"),[P,C]=p.useState(!1),[E,I]=p.useState(!1),M=p.useCallback(async()=>{if(!(!t||!s))try{const X=await Po(t,s);i(X),v(X.name),b([...X.steps]),x(null)}catch(X){x(X instanceof Error?X.message:"Failed to load workflow")}finally{u(!1)}},[t,s]),q=p.useCallback(async()=>{if(!(!t||!s||!l))try{const[X,ee]=await Promise.all([fl(t,l.id),Jc(t)]);_(X),j(ee)}catch(X){x(X instanceof Error?X.message:"Failed to load resources")}},[t,s,l]);p.useEffect(()=>{M()},[M]),p.useEffect(()=>{l&&q()},[l,q]),p.useEffect(()=>{if(!l)return;const X=g!==l.name,ee=JSON.stringify(y)!==JSON.stringify(l.steps);I(X||ee)},[l,g,y]),p.useEffect(()=>{const X=ee=>{E&&(ee.preventDefault(),ee.returnValue="")};return window.addEventListener("beforeunload",X),()=>window.removeEventListener("beforeunload",X)},[E]);const z=p.useCallback(async()=>{var X,ee,W,te,D,R,Y,ie,re,L,F,H,K,J,he,_e,Ae,Pe,pe,se,Ne,Le,ot,wt,ae,Ee,Ve,at,xt,bt,ue,$e,Pt,lt,cr,jt,Ar,js,vr,wr,Gs,Ns,ks;if(!(!l||!t)){C(!0),x(null);try{g!==l.name&&await Bv(t,l.id,{name:g});const Dt=new Set(l.steps.map(Ie=>Ie.id)),dr=new Set(y.filter(Ie=>Ie.id).map(Ie=>Ie.id));for(const Ie of l.steps)dr.has(Ie.id)||await zh(t,l.id,Ie.id);const ne=[];for(let Ie=0;Ie<y.length;Ie++){const be=y[Ie];if(!be.id||!Dt.has(be.id)){const Be={name:be.name,step_type:be.step_type,description:(X=be.config)==null?void 0:X.description,skippable:(ee=be.config)==null?void 0:ee.skippable,loop_type:(W=be.config)==null?void 0:W.loopType,template:(te=be.config)==null?void 0:te.template};be.step_type==="autonomous"&&(Be.model=(D=be.config)==null?void 0:D.model,Be.timeout=(R=be.config)==null?void 0:R.timeout,Be.allowed_tools=(Y=be.config)==null?void 0:Y.allowedTools,Be.max_iterations=(ie=be.config)==null?void 0:ie.max_iterations,Be.cooldown_between_iterations=(re=be.config)==null?void 0:re.cooldown_between_iterations,Be.max_consecutive_errors=(L=be.config)==null?void 0:L.max_consecutive_errors);const Pr=await Hv(t,l.id,Be);ne.push(Pr.id)}else{const Be=l.steps.find(Yt=>Yt.id===be.id);if(Be&&(Be.name!==be.name||Be.step_type!==be.step_type||((F=Be.config)==null?void 0:F.description)!==((H=be.config)==null?void 0:H.description)||((K=Be.config)==null?void 0:K.skippable)!==((J=be.config)==null?void 0:J.skippable)||((he=Be.config)==null?void 0:he.loopType)!==((_e=be.config)==null?void 0:_e.loopType)||((Ae=Be.config)==null?void 0:Ae.template)!==((Pe=be.config)==null?void 0:Pe.template)||((pe=Be.config)==null?void 0:pe.model)!==((se=be.config)==null?void 0:se.model)||((Ne=Be.config)==null?void 0:Ne.timeout)!==((Le=be.config)==null?void 0:Le.timeout)||JSON.stringify((ot=Be.config)==null?void 0:ot.allowedTools)!==JSON.stringify((wt=be.config)==null?void 0:wt.allowedTools)||((ae=Be.config)==null?void 0:ae.max_iterations)!==((Ee=be.config)==null?void 0:Ee.max_iterations)||((Ve=Be.config)==null?void 0:Ve.cooldown_between_iterations)!==((at=be.config)==null?void 0:at.cooldown_between_iterations)||((xt=Be.config)==null?void 0:xt.max_consecutive_errors)!==((bt=be.config)==null?void 0:bt.max_consecutive_errors)||((ue=Be.config)==null?void 0:ue.customPrompt)!==(($e=be.config)==null?void 0:$e.customPrompt))){const Yt={name:be.name,step_type:be.step_type,description:(Pt=be.config)==null?void 0:Pt.description,skippable:(lt=be.config)==null?void 0:lt.skippable,loop_type:(cr=be.config)==null?void 0:cr.loopType,template:((jt=be.config)==null?void 0:jt.template)||""};be.step_type==="autonomous"&&(Yt.model=(Ar=be.config)==null?void 0:Ar.model,Yt.timeout=(js=be.config)==null?void 0:js.timeout,Yt.allowed_tools=(vr=be.config)==null?void 0:vr.allowedTools,Yt.max_iterations=(wr=be.config)==null?void 0:wr.max_iterations,Yt.cooldown_between_iterations=(Gs=be.config)==null?void 0:Gs.cooldown_between_iterations,Yt.max_consecutive_errors=(Ns=be.config)==null?void 0:Ns.max_consecutive_errors,((ks=be.config)==null?void 0:ks.customPrompt)!==void 0&&(Yt.custom_prompt=be.config.customPrompt||"")),await Uv(t,l.id,be.id,Yt)}ne.push(be.id)}}const Me=l.steps.map(Ie=>Ie.id);JSON.stringify(Me)!==JSON.stringify(ne)&&await Gv(t,l.id,ne),await M(),I(!1)}catch(Dt){x(Dt instanceof Error?Dt.message:"Failed to save workflow")}finally{C(!1)}}},[l,t,g,y,M]),U=p.useCallback(()=>{E&&!window.confirm("You have unsaved changes. Are you sure you want to leave?")||o(`/projects/${t}/workflows/${s}`)},[E,o,t,s]);if(p.useEffect(()=>{const X=ee=>{document.querySelector(".fixed.inset-0.bg-black\\/50")||((ee.metaKey||ee.ctrlKey)&&ee.key==="s"&&(ee.preventDefault(),E&&!P&&z()),ee.key==="Escape"&&U())};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[E,P,z,U]),d)return e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"text-gray-400",children:"Loading workflow..."})});if(h&&!l)return e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"card bg-red-900/20 border border-red-800",children:[e.jsx("h2",{className:"text-lg font-semibold text-red-400 mb-2",children:"Error"}),e.jsx("p",{className:"text-gray-300",children:h}),e.jsx(Se,{to:`/projects/${t}`,className:"btn-secondary mt-4 inline-block",children:"Back to Project"})]})});if(!l)return e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"card",children:e.jsx("p",{className:"text-gray-400",children:"Workflow not found"})})});const O=[{key:"overview",label:"Overview"},{key:"steps",label:"Steps"},{key:"resources",label:"Resources"},{key:"settings",label:"Settings"}];return e.jsxs("div",{className:"min-h-screen",children:[e.jsx(yN,{workflowName:g,onBack:U,onSave:z,saving:P,dirty:E}),h&&e.jsx("div",{className:"mx-6 mt-4 p-4 rounded-lg bg-red-900/20 border border-red-800",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-red-400 text-sm",children:h}),e.jsx("button",{onClick:()=>x(null),className:"text-red-400 hover:text-red-300",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),e.jsx("div",{className:"border-b border-gray-700 px-6",children:e.jsx("nav",{className:"flex space-x-8",children:O.map(X=>e.jsxs("button",{onClick:()=>T(X.key),className:`pb-4 px-1 border-b-2 font-medium text-sm transition-colors ${N===X.key?"border-primary-500 text-primary-400":"border-transparent text-gray-400 hover:text-gray-300 hover:border-gray-500"}`,children:[X.label,X.key==="steps"&&` (${y.length})`,X.key==="resources"&&k.length>0&&` (${k.length})`]},X.key))})}),e.jsxs("div",{className:"p-6",children:[N==="overview"&&e.jsx(wN,{workflow:l,workflowName:g,onNameChange:X=>v(X),steps:y,resources:k,onViewResources:()=>T("resources")}),N==="steps"&&e.jsx(MN,{projectSlug:t,workflowId:l.id,steps:y,onStepsChange:X=>b(X),onError:X=>x(X)}),N==="resources"&&e.jsx(RN,{projectSlug:t,workflowId:l.id,resources:k,projectResources:S,onResourcesChange:q,onError:X=>x(X)}),N==="settings"&&e.jsx(IN,{workflow:l,projectSlug:t,onWorkflowUpdate:M,onError:X=>x(X)})]})]})}function BN(){const{slug:t}=yr(),[s,o]=Vy(),{selectedProject:l,setSelectedProject:i}=Tr(),[d,u]=p.useState(null),[h,x]=p.useState(null),[g,v]=p.useState([]),[y,b]=p.useState(null),[k,_]=p.useState(!0),[S,j]=p.useState(null),[N,T]=p.useState(!1),[P,C]=p.useState(!1),E=s.get("tab"),M=E&&["auth","resources","defaults"].includes(E)?E:"auth",[q,z]=p.useState(M),U=ae=>{z(ae),o({tab:ae})},[O,X]=p.useState(!1),[ee,W]=p.useState({name:"",resource_type:"guardrail",content:"",description:"",auto_inherit:!0}),[te,D]=p.useState(!1),[R,Y]=p.useState(null),[ie,re]=p.useState(""),[L,F]=p.useState(!1),H=p.useCallback(async()=>{if(t){_(!0),j(null);try{const[ae,Ee,Ve,at]=await Promise.all([Vs(t),Ec(),Jc(t),c2(t)]);i(ae),u(Ee),v(Ve),b(at),Ee!=null&&Ee.connected&&!(Ee!=null&&Ee.is_expired)&&Oh().then(x).catch(()=>x(null))}catch(ae){j(ae instanceof Error?ae.message:"Failed to load settings")}finally{_(!1)}}},[t,i]);p.useEffect(()=>{H()},[H]);const K=async()=>{T(!0),j(null);try{await Bh({scope:"global"}),setTimeout(()=>{H(),T(!1)},2e3)}catch(ae){j(ae instanceof Error?ae.message:"Failed to start login"),T(!1)}},J=async()=>{if(confirm("Are you sure you want to disconnect your authentication?"))try{await Dh({scope:"global"}),H()}catch(ae){j(ae instanceof Error?ae.message:"Failed to logout")}},he=async ae=>{if(ae.preventDefault(),!(!t||!ee.name.trim()||!ee.content.trim())){D(!0);try{await l2(t,{name:ee.name.trim(),resource_type:ee.resource_type,content:ee.content.trim(),description:ee.description.trim()||void 0,auto_inherit:ee.auto_inherit}),W({name:"",resource_type:"guardrail",content:"",description:"",auto_inherit:!0}),X(!1),H()}catch(Ee){j(Ee instanceof Error?Ee.message:"Failed to add resource")}finally{D(!1)}}},_e=async()=>{if(!(!t||!R)){F(!0);try{await A0(t,R.id,{content:ie}),Y(null),H()}catch(ae){j(ae instanceof Error?ae.message:"Failed to save resource")}finally{F(!1)}}},Ae=async ae=>{if(t)try{await A0(t,ae.id,{auto_inherit:!ae.auto_inherit}),H()}catch(Ee){j(Ee instanceof Error?Ee.message:"Failed to update resource")}},Pe=async ae=>{if(t&&confirm(`Delete "${ae.name}"? This cannot be undone.`))try{await i2(t,ae.id),H()}catch(Ee){j(Ee instanceof Error?Ee.message:"Failed to delete resource")}},pe=async(ae,Ee)=>{if(!(!t||!y)){b({...y,[ae]:Ee}),C(!0);try{const Ve=await d2(t,{[ae]:Ee});b(Ve)}catch(Ve){b({...y,[ae]:!Ee}),j(Ve instanceof Error?Ve.message:"Failed to save setting")}finally{C(!1)}}},se=ae=>{switch(ae){case"design_doc":return"Design Document";case"guardrail":return"Guardrail";case"prompt":return"Prompt Template";default:return ae}},Ne=ae=>ae>=80?"text-rose-400":ae>=50?"text-amber-400":"text-emerald-400",Le=ae=>ae>=80?"bg-gradient-to-r from-rose-500 to-rose-400":ae>=50?"bg-gradient-to-r from-amber-500 to-amber-400":"bg-gradient-to-r from-emerald-500 to-emerald-400",ot=ae=>{if(!ae)return"";const Ee=new Date(ae),Ve=new Date,at=Ee.toDateString()===Ve.toDateString(),xt=new Date(Ve);xt.setDate(xt.getDate()+1);const bt=Ee.toDateString()===xt.toDateString(),ue=Ee.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return at?`today at ${ue}`:bt?`tomorrow at ${ue}`:Ee.toLocaleDateString([],{month:"short",day:"numeric"})+` at ${ue}`},wt=[{key:"auth",label:"Authentication"},{key:"resources",label:"Shared Resources"},{key:"defaults",label:"Defaults"}];return k?e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"text-gray-400",children:"Loading settings..."})}):e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[e.jsx(Se,{to:"/",className:"hover:text-white",children:"Dashboard"}),e.jsx("span",{children:"/"}),e.jsx(Se,{to:`/projects/${t}`,className:"hover:text-white",children:(l==null?void 0:l.name)||t}),e.jsx("span",{children:"/"}),e.jsx("span",{className:"text-white",children:"Settings"})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-3xl font-bold text-white mb-1",children:"Project Settings"}),e.jsx("p",{className:"text-gray-400",children:"Configure authentication and shared resources for all workflows."})]}),S&&e.jsx("div",{className:"mb-4 p-3 bg-red-900/30 border border-red-800 rounded text-red-400",children:S}),e.jsx("div",{className:"flex space-x-1 mb-6 border-b border-gray-700",children:wt.map(ae=>e.jsx("button",{onClick:()=>U(ae.key),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${q===ae.key?"border-primary-500 text-white":"border-transparent text-gray-400 hover:text-gray-300"}`,children:ae.label},ae.key))}),q==="auth"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Claude Authentication"}),d!=null&&d.connected?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"w-3 h-3 rounded-full bg-green-500"}),e.jsx("span",{className:"text-green-400",children:"Connected"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-400",children:"Email:"}),e.jsx("span",{className:"text-white ml-2",children:d.email||"N/A"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-400",children:"Subscription:"}),e.jsx("span",{className:"text-white ml-2",children:d.subscription_type||"N/A"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-400",children:"Scope:"}),e.jsx("span",{className:"text-white ml-2",children:d.scope||"global"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-400",children:"Rate Limit:"}),e.jsx("span",{className:"text-white ml-2",children:d.rate_limit_tier||"N/A"})]}),(h==null?void 0:h.success)&&e.jsxs("div",{className:"col-span-2 mt-2 pt-3 border-t border-gray-700",children:[e.jsx("p",{className:"text-gray-400 text-sm font-medium mb-2",children:"API Usage"}),e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-gray-400 text-sm",children:"5-hour"}),e.jsxs("span",{className:`text-sm font-semibold ${Ne(h.five_hour_utilization||0)}`,children:[Math.round(Math.min(100,h.five_hour_utilization||0)),"%"]})]}),e.jsx("div",{className:"h-3 bg-gray-700/50 rounded-full overflow-hidden shadow-inner",children:e.jsx("div",{className:`h-full rounded-full shadow-sm ${Le(h.five_hour_utilization||0)}`,style:{width:`${Math.min(100,h.five_hour_utilization||0)}%`}})}),h.five_hour_resets_at&&e.jsxs("p",{className:"text-gray-500 text-xs mt-1",children:["Resets ",ot(h.five_hour_resets_at)]})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-gray-400 text-sm",children:"7-day"}),e.jsxs("span",{className:`text-sm font-semibold ${Ne(h.seven_day_utilization||0)}`,children:[Math.round(Math.min(100,h.seven_day_utilization||0)),"%"]})]}),e.jsx("div",{className:"h-3 bg-gray-700/50 rounded-full overflow-hidden shadow-inner",children:e.jsx("div",{className:`h-full rounded-full shadow-sm ${Le(h.seven_day_utilization||0)}`,style:{width:`${Math.min(100,h.seven_day_utilization||0)}%`}})}),h.seven_day_resets_at&&e.jsxs("p",{className:"text-gray-500 text-xs mt-1",children:["Resets ",ot(h.seven_day_resets_at)]})]})]})]})]}),e.jsx("button",{onClick:J,className:"px-4 py-2 text-sm rounded bg-red-900/30 text-red-400 hover:bg-red-900/50",children:"Disconnect"})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"w-3 h-3 rounded-full bg-gray-500"}),e.jsx("span",{className:"text-gray-400",children:"Not connected"})]}),e.jsx("p",{className:"text-sm text-gray-500",children:"Connect your Claude account to enable AI-powered features."}),e.jsx("button",{onClick:K,disabled:N,className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500 disabled:opacity-50",children:N?"Connecting...":"Connect Claude Account"})]})]}),e.jsx("div",{className:"p-4 bg-gray-800/50 border border-gray-700 rounded",children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("svg",{className:"w-5 h-5 text-yellow-500 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{className:"text-sm text-gray-400",children:[e.jsx("p",{className:"font-medium text-gray-300 mb-1",children:"About Authentication"}),e.jsx("p",{children:"Authentication is shared across all workflows in this project. Claude uses these credentials to interact with the Claude API."})]})]})})]}),q==="resources"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-white",children:"Shared Resource Library"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Resources here can be imported into any workflow."})]}),e.jsxs("button",{onClick:()=>X(!0),className:"flex items-center space-x-2 px-4 py-2 bg-primary-600 text-white rounded hover:bg-primary-500",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),e.jsx("span",{children:"Add Shared Resource"})]})]}),g.length===0?e.jsxs("div",{className:"card text-center py-8",children:[e.jsx("p",{className:"text-gray-400",children:"No shared resources yet"}),e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Add resources to the library to share across workflows."})]}):e.jsx("div",{className:"space-y-3",children:g.map(ae=>e.jsxs("div",{className:"card flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start space-x-4",children:[e.jsx("div",{className:"p-2 rounded bg-primary-500/20 text-primary-400",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium text-white",children:ae.name}),e.jsx("div",{className:"flex items-center space-x-4 text-sm text-gray-400 mt-1",children:e.jsx("span",{children:se(ae.resource_type)})}),ae.description&&e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:ae.description})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>Ae(ae),className:`px-3 py-1 text-sm rounded ${ae.auto_inherit?"bg-primary-600/20 text-primary-400":"bg-gray-700 text-gray-500"}`,children:ae.auto_inherit?"Auto-inherit":"Manual"}),e.jsx("button",{onClick:()=>{Y(ae),re(ae.content||"")},className:"px-3 py-1 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600",children:"View"}),e.jsx("button",{onClick:()=>Pe(ae),className:"px-3 py-1 text-sm rounded bg-red-900/30 text-red-400 hover:bg-red-900/50",children:"Delete"})]})]},ae.id))}),e.jsx("div",{className:"p-4 bg-gray-800/50 border border-gray-700 rounded",children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("svg",{className:"w-5 h-5 text-yellow-500 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{className:"text-sm text-gray-400",children:[e.jsx("p",{className:"font-medium text-gray-300 mb-1",children:"About Auto-inherit"}),e.jsx("p",{children:'Resources marked as "auto-inherit" are automatically added to new workflows. This is useful for company-wide guardrails or standards.'})]})]})})]}),q==="defaults"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-white",children:"Default Settings for New Workflows"}),P&&e.jsx("span",{className:"text-sm text-gray-400",children:"Saving..."})]}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"These settings are applied to new workflows by default."}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:(y==null?void 0:y.auto_inherit_guardrails)??!0,onChange:ae=>pe("auto_inherit_guardrails",ae.target.checked),disabled:P,className:"w-4 h-4 rounded bg-gray-700 border-gray-600 text-primary-500 focus:ring-primary-500 cursor-pointer disabled:opacity-50"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-300",children:"Auto-inherit shared guardrails"}),e.jsx("p",{className:"text-xs text-gray-500",children:"New workflows automatically receive guardrails marked as auto-inherit"})]})]}),e.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:(y==null?void 0:y.require_design_doc)??!1,onChange:ae=>pe("require_design_doc",ae.target.checked),disabled:P,className:"w-4 h-4 rounded bg-gray-700 border-gray-600 text-primary-500 focus:ring-primary-500 cursor-pointer disabled:opacity-50"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-300",children:"Require design document before implementation"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Blocks autonomous steps until a design document is attached"})]})]}),e.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:(y==null?void 0:y.architecture_first_mode)??!1,onChange:ae=>pe("architecture_first_mode",ae.target.checked),disabled:P,className:"w-4 h-4 rounded bg-gray-700 border-gray-600 text-primary-500 focus:ring-primary-500 cursor-pointer disabled:opacity-50"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-300",children:"Enable architecture-first mode"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Prioritizes planning and design steps in new workflows"})]})]})]})]}),e.jsx("div",{className:"p-4 bg-gray-800/50 border border-gray-700 rounded",children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("svg",{className:"w-5 h-5 text-green-400 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{className:"text-sm text-gray-400",children:[e.jsx("p",{className:"font-medium text-gray-300 mb-1",children:"Settings Auto-Save"}),e.jsx("p",{children:"Changes are saved automatically when you toggle a setting."})]})]})})]}),O&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-gray-800 rounded-lg p-6 w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"Add Shared Resource"}),e.jsxs("form",{onSubmit:he,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Resource Type"}),e.jsxs("select",{value:ee.resource_type,onChange:ae=>W({...ee,resource_type:ae.target.value}),className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white",children:[e.jsx("option",{value:"guardrail",children:"Guardrail"}),e.jsx("option",{value:"prompt",children:"Prompt Template"}),e.jsx("option",{value:"design_doc",children:"Design Template"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Name"}),e.jsx("input",{type:"text",value:ee.name,onChange:ae=>W({...ee,name:ae.target.value}),placeholder:"e.g., HIPAA Compliance Guidelines",className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white placeholder-gray-400"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Description (optional)"}),e.jsx("input",{type:"text",value:ee.description,onChange:ae=>W({...ee,description:ae.target.value}),placeholder:"Brief description...",className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white placeholder-gray-400"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Content"}),e.jsx("textarea",{value:ee.content,onChange:ae=>W({...ee,content:ae.target.value}),placeholder:"Resource content...",rows:10,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white placeholder-gray-400 font-mono text-sm"})]}),e.jsxs("label",{className:"flex items-center space-x-3",children:[e.jsx("input",{type:"checkbox",checked:ee.auto_inherit,onChange:ae=>W({...ee,auto_inherit:ae.target.checked}),className:"w-4 h-4 rounded bg-gray-700 border-gray-600 text-primary-500 focus:ring-primary-500"}),e.jsx("span",{className:"text-gray-300",children:"Auto-add to new workflows"})]}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{type:"button",onClick:()=>X(!1),className:"px-4 py-2 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:te||!ee.name.trim()||!ee.content.trim(),className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500 disabled:opacity-50",children:te?"Adding...":"Add Resource"})]})]})]})}),R&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-gray-800 rounded-lg p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-xl font-bold text-white",children:R.name}),e.jsx("span",{className:"text-sm bg-gray-700 text-gray-400 px-2 py-1 rounded",children:se(R.resource_type)})]}),e.jsx("textarea",{value:ie,onChange:ae=>re(ae.target.value),rows:20,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white font-mono text-sm"}),e.jsxs("div",{className:"flex justify-end space-x-3 mt-4",children:[e.jsx("button",{onClick:()=>Y(null),className:"px-4 py-2 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600",children:"Cancel"}),e.jsx("button",{onClick:_e,disabled:L,className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500 disabled:opacity-50",children:L?"Saving...":"Save Changes"})]})]})})]})}function xh(){const{slug:t}=yr(),{selectedProject:s,setSelectedProject:o}=Tr(),[l,i]=p.useState([]),[d,u]=p.useState(!0),[h,x]=p.useState(null),[g,v]=p.useState(null),[y,b]=p.useState([]),[k,_]=p.useState(!1),[S,j]=p.useState(null),N=p.useCallback(async()=>{if(t){u(!0),x(null);try{const C=await mv(t);i(C)}catch(C){x(C instanceof Error?C.message:"Failed to load runs")}finally{u(!1)}}},[t]);p.useEffect(()=>{if(!t)return;async function C(){try{const E=await Vs(t);o(E)}catch{}}C(),N()},[t,o,N]);const T=async C=>{if(g===C){v(null),b([]);return}v(C),_(!0);try{const E=await hv(t,C);b(E.sessions)}catch{b([])}finally{_(!1)}},P={running:"bg-green-900 text-green-300",completed:"bg-blue-900 text-blue-300",stopped:"bg-yellow-900 text-yellow-300",failed:"bg-red-900 text-red-300"};return e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[e.jsx(Se,{to:"/",className:"hover:text-white",children:"Dashboard"}),e.jsx("span",{children:"/"}),e.jsx(Se,{to:`/projects/${t}`,className:"hover:text-white",children:(s==null?void 0:s.name)||t}),e.jsx("span",{children:"/"}),e.jsx("span",{className:"text-white",children:"Run History"})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-3xl font-bold text-white mb-1",children:"Run History"}),e.jsxs("p",{className:"text-gray-400",children:[l.length," total runs"]})]}),S&&e.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-gray-800 rounded-lg w-full max-w-4xl max-h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b border-gray-700 flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:"Session Output"}),e.jsx("button",{onClick:()=>j(null),className:"text-gray-400 hover:text-white",children:e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(Wp,{projectSlug:t,sessionId:S,enabled:!0})})]})}),h&&e.jsx("div",{className:"mb-4 p-3 bg-red-900/30 border border-red-800 rounded text-red-400",children:h}),d?e.jsx("div",{className:"text-gray-400",children:"Loading runs..."}):l.length===0?e.jsxs("div",{className:"card text-center py-8",children:[e.jsx("p",{className:"text-gray-400",children:"No runs yet"}),e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Start a loop to create run history"})]}):e.jsx("div",{className:"space-y-2",children:l.map(C=>e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"flex items-center justify-between cursor-pointer",onClick:()=>T(C.id),children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${P[C.status]||"bg-gray-600 text-gray-300"}`,children:C.status}),e.jsx("span",{className:"font-medium text-white",children:C.loop_name})]}),e.jsxs("div",{className:"flex items-center space-x-4 text-sm text-gray-400",children:[e.jsxs("span",{children:[C.iterations_completed," iterations"]}),e.jsxs("span",{children:[C.items_processed," items"]}),e.jsx("span",{children:hs(C.started_at)}),e.jsx("svg",{className:`w-5 h-5 transition-transform ${g===C.id?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),g===C.id&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-700",children:[k?e.jsx("div",{className:"text-gray-400 text-sm",children:"Loading sessions..."}):y.length===0?e.jsx("div",{className:"text-gray-500 text-sm",children:"No sessions recorded"}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium text-gray-300 mb-2",children:"Sessions"}),y.map(E=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-700 rounded",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${P[E.status]||"bg-gray-600 text-gray-300"}`,children:E.status}),e.jsxs("span",{className:"text-sm text-gray-300",children:["Iteration ",E.iteration]}),E.mode&&e.jsxs("span",{className:"text-sm text-gray-400",children:["Mode: ",E.mode]})]}),e.jsxs("div",{className:"flex items-center space-x-4",children:[E.duration_seconds!==void 0&&e.jsxs("span",{className:"text-sm text-gray-400",children:[E.duration_seconds.toFixed(1),"s"]}),e.jsx("button",{onClick:I=>{I.stopPropagation(),j(E.session_id)},className:"text-xs px-2 py-1 rounded bg-primary-600 text-white hover:bg-primary-500",children:"View Output"})]})]},E.session_id))]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-600 text-xs text-gray-500",children:[e.jsxs("div",{children:["Run ID: ",C.id]}),C.ended_at&&e.jsxs("div",{children:["Ended: ",hs(C.ended_at)]})]})]})]},C.id))})]})}function DN({projectPath:t,validationResult:s,onLoginSuccess:o}){const[l,i]=p.useState(null),[d,u]=p.useState(!0),[h,x]=p.useState(!1),[g,v]=p.useState(null),[y,b]=p.useState(t?"project":"global"),[k,_]=p.useState(!1),[S,j]=p.useState(null),[N,T]=p.useState(!1),[P,C]=p.useState(!1),[E,I]=p.useState(null),[M,q]=p.useState(!1),z=p.useRef(null),U=p.useRef(null),O=async()=>{try{const F=await Ec(t);i(F),v(null)}catch{v("Failed to check auth status")}finally{u(!1)}};p.useEffect(()=>{O();const F=setInterval(O,5e3);return()=>{clearInterval(F),z.current&&clearInterval(z.current),U.current&&clearTimeout(U.current)}},[t]),p.useEffect(()=>{l!=null&&l.connected&&!(l!=null&&l.is_expired)&&(q(!0),Oh(t).then(I).catch(()=>I(null)).finally(()=>q(!1)))},[l==null?void 0:l.connected,l==null?void 0:l.is_expired,t]);const X=async()=>{x(!0),v(null);const F=t&&y==="project"?"project":"global";try{const H=await Bh({scope:F,project_path:t});if(!H.success){v(H.error||"Failed to start login"),x(!1);return}z.current=window.setInterval(async()=>{try{const K=await Ec(t);K.connected&&!K.is_expired&&(i(K),z.current&&clearInterval(z.current),U.current&&clearTimeout(U.current),x(!1),o==null||o())}catch{}},1e3),U.current=window.setTimeout(()=>{z.current&&clearInterval(z.current),x(!1),v("Login timed out. Please try again.")},12e4)}catch{v("Failed to start login"),x(!1)}},ee=async()=>{try{const F=(l==null?void 0:l.scope)||"global";await Dh({scope:F,project_path:t}),await O()}catch{v("Failed to logout")}},W=async()=>{C(!0),v(null);try{const F=(l==null?void 0:l.scope)||"global",H=await Ev({scope:F,project_path:t});H.success?await O():H.needs_relogin?v('Session expired. Please click "Re-login" to authenticate again.'):v(H.error||"Failed to refresh token")}catch{v("Failed to refresh token")}finally{C(!1)}},te=async()=>{T(!0);try{const F=(l==null?void 0:l.scope)||"global",H=await Tv(F,t);j(H),_(!0)}catch{v("Failed to export credentials")}finally{T(!1)}},D=()=>{if(!(S!=null&&S.credentials))return;const F=JSON.stringify(S.credentials,null,2),H=new Blob([F],{type:"application/json"}),K=URL.createObjectURL(H),J=document.createElement("a");J.href=K,J.download=`credentials-${S.scope||"global"}.json`,document.body.appendChild(J),J.click(),document.body.removeChild(J),URL.revokeObjectURL(K)},R=()=>{if(!(S!=null&&S.credentials))return;const F=JSON.stringify(S.credentials,null,2);navigator.clipboard.writeText(F)},Y=F=>{if(!F)return"Unknown";const H=Math.floor(F/3600),K=Math.floor(F%3600/60);return H>0?`${H}h ${K}m`:`${K}m`},ie=F=>F>=80?"text-rose-400":F>=50?"text-amber-400":"text-emerald-400",re=F=>F>=80?"bg-gradient-to-r from-rose-500 to-rose-400":F>=50?"bg-gradient-to-r from-amber-500 to-amber-400":"bg-gradient-to-r from-emerald-500 to-emerald-400",L=F=>{if(!F)return"";const H=new Date(F),K=new Date,J=H.toDateString()===K.toDateString(),he=new Date(K);he.setDate(he.getDate()+1);const _e=H.toDateString()===he.toDateString(),Ae=H.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return J?`today at ${Ae}`:_e?`tomorrow at ${Ae}`:H.toLocaleDateString([],{month:"short",day:"numeric"})+` at ${Ae}`};return d?e.jsxs("div",{className:"bg-gray-800 rounded-lg p-6 animate-pulse",children:[e.jsx("div",{className:"h-6 bg-gray-700 rounded w-1/3 mb-4"}),e.jsx("div",{className:"h-4 bg-gray-700 rounded w-1/2"})]}):e.jsxs("div",{className:"bg-gray-800 rounded-lg p-6",children:[e.jsx("h3",{className:"text-lg font-semibold mb-4 text-white",children:"Claude Authentication"}),g&&e.jsx("div",{className:"mb-4 p-3 bg-red-900/50 border border-red-700 rounded text-red-200 text-sm",children:g}),l!=null&&l.connected&&!(l!=null&&l.is_expired)?e.jsxs("div",{className:"space-y-3",children:[l.email&&e.jsxs("p",{className:"text-gray-300 text-sm",children:["Logged in as ",e.jsx("span",{className:"text-white font-medium",children:l.email})]}),s&&!s.valid?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 bg-yellow-500 rounded-full"}),e.jsx("span",{className:"text-yellow-400",children:"Token Invalid"}),e.jsxs("span",{className:"text-gray-500 text-sm",children:["(",l.scope==="project"?"Project":"Global",")"]})]}),e.jsxs("div",{className:"bg-yellow-500/10 border border-yellow-500 rounded p-3",children:[e.jsx("p",{className:"text-yellow-300/80 text-sm",children:s.error||"Token validation failed"}),e.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"Please re-login to get fresh credentials."})]})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full"}),e.jsx("span",{className:"text-green-400",children:"Connected"}),l.using_global_fallback?e.jsx("span",{className:"text-yellow-400 text-sm",children:"(Using Global Account)"}):e.jsxs("span",{className:"text-gray-500 text-sm",children:["(",l.scope==="project"?"Project":"Global",")"]})]}),l.using_global_fallback&&t&&e.jsxs("div",{className:"mt-3 p-3 bg-gray-700/50 rounded border border-gray-600",children:[e.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"This project is using your global Claude account."}),e.jsx("button",{onClick:()=>{b("project"),X()},className:"px-3 py-1.5 bg-blue-600 hover:bg-blue-500 text-white text-sm rounded transition-colors disabled:opacity-50",disabled:h,children:h?"Waiting...":"Use Different Account for This Project"})]}),(!s||s.valid)&&e.jsxs(e.Fragment,{children:[l.subscription_type&&e.jsxs("p",{className:"text-gray-400 text-sm",children:["Plan: ",e.jsx("span",{className:"text-white capitalize",children:l.subscription_type})]}),l.rate_limit_tier&&e.jsxs("p",{className:"text-gray-400 text-sm",children:["Tier: ",e.jsx("span",{className:"text-white",children:l.rate_limit_tier})]}),(M||(E==null?void 0:E.success))&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-gray-400 text-sm font-medium",children:"API Usage"}),M?e.jsx("div",{className:"text-gray-500",children:"loading..."}):e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-gray-400 text-sm",children:"5-hour window"}),e.jsxs("span",{className:`text-sm font-semibold ${ie((E==null?void 0:E.five_hour_utilization)||0)}`,children:[Math.round(Math.min(100,(E==null?void 0:E.five_hour_utilization)||0)),"%"]})]}),e.jsx("div",{className:"h-3 bg-gray-700/50 rounded-full overflow-hidden shadow-inner",children:e.jsx("div",{className:`h-full rounded-full shadow-sm ${re((E==null?void 0:E.five_hour_utilization)||0)}`,style:{width:`${Math.min(100,(E==null?void 0:E.five_hour_utilization)||0)}%`}})}),(E==null?void 0:E.five_hour_resets_at)&&e.jsxs("p",{className:"text-gray-500 text-xs mt-1",children:["Resets ",L(E.five_hour_resets_at)]})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-gray-400 text-sm",children:"7-day window"}),e.jsxs("span",{className:`text-sm font-semibold ${ie((E==null?void 0:E.seven_day_utilization)||0)}`,children:[Math.round(Math.min(100,(E==null?void 0:E.seven_day_utilization)||0)),"%"]})]}),e.jsx("div",{className:"h-3 bg-gray-700/50 rounded-full overflow-hidden shadow-inner",children:e.jsx("div",{className:`h-full rounded-full shadow-sm ${re((E==null?void 0:E.seven_day_utilization)||0)}`,style:{width:`${Math.min(100,(E==null?void 0:E.seven_day_utilization)||0)}%`}})}),(E==null?void 0:E.seven_day_resets_at)&&e.jsxs("p",{className:"text-gray-500 text-xs mt-1",children:["Resets ",L(E.seven_day_resets_at)]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-gray-400 text-sm",children:["Expires in: ",e.jsx("span",{className:"text-white",children:Y(l.expires_in_seconds)})]}),e.jsx("p",{className:"text-gray-500 text-xs",children:"Auto-refreshes every 30 min when less than 4 hours remain"})]})]}),e.jsx("div",{className:"flex gap-2 pt-2 flex-wrap",children:s&&!s.valid?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:X,className:"px-3 py-1.5 bg-blue-600 hover:bg-blue-500 text-white text-sm rounded transition-colors disabled:opacity-50",disabled:h,children:h?"Waiting...":"Re-login"}),e.jsx("button",{onClick:ee,className:"px-3 py-1.5 bg-gray-700 hover:bg-gray-600 text-white text-sm rounded transition-colors",children:"Logout"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:W,className:"px-3 py-1.5 bg-blue-600 hover:bg-blue-500 text-white text-sm rounded transition-colors disabled:opacity-50",disabled:P,title:"Get a fresh token now",children:P?"Refreshing...":"Refresh Token"}),e.jsx("button",{onClick:X,className:"px-3 py-1.5 bg-gray-700 hover:bg-gray-600 text-white text-sm rounded transition-colors disabled:opacity-50",disabled:h,children:h?"Waiting...":"Re-login"}),e.jsx("button",{onClick:te,className:"px-3 py-1.5 bg-gray-700 hover:bg-gray-600 text-white text-sm rounded transition-colors disabled:opacity-50",disabled:N,children:N?"Loading...":"View Credentials"}),e.jsx("button",{onClick:ee,className:"px-3 py-1.5 bg-red-900/50 hover:bg-red-800/50 text-red-200 text-sm rounded transition-colors",children:"Logout"})]})}),k&&S&&e.jsxs("div",{className:"mt-4 p-4 bg-gray-900 rounded-lg border border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h4",{className:"text-sm font-medium text-gray-300",children:["Credentials JSON (",S.scope,")",S.email&&e.jsxs("span",{className:"text-gray-500 ml-2",children:["- ",S.email]})]}),e.jsx("button",{onClick:()=>_(!1),className:"text-gray-500 hover:text-gray-300 text-lg leading-none",children:"×"})]}),S.success&&S.credentials?e.jsxs(e.Fragment,{children:[e.jsx("pre",{className:"text-xs text-gray-400 bg-gray-950 p-3 rounded overflow-x-auto max-h-64 overflow-y-auto",children:JSON.stringify(S.credentials,null,2)}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsx("button",{onClick:R,className:"px-3 py-1.5 bg-blue-600 hover:bg-blue-500 text-white text-sm rounded transition-colors",children:"Copy to Clipboard"}),e.jsx("button",{onClick:D,className:"px-3 py-1.5 bg-gray-700 hover:bg-gray-600 text-white text-sm rounded transition-colors",children:"Download JSON"})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"Save to ~/.claude/.credentials.json for use with Claude CLI"})]}):e.jsx("p",{className:"text-red-400 text-sm",children:S.error||"No credentials found"})]})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${l!=null&&l.is_expired?"bg-yellow-500":"bg-gray-500"}`}),e.jsx("span",{className:l!=null&&l.is_expired?"text-yellow-400":"text-gray-400",children:l!=null&&l.is_expired?"Token Expired":"Not Connected"})]}),e.jsx("p",{className:"text-gray-400 text-sm",children:l!=null&&l.is_expired?"Your session has expired. Please login again.":"Login to use your Claude subscription for loops."}),t&&e.jsxs("div",{className:"flex gap-4 text-sm",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"scope",checked:y==="project",onChange:()=>b("project"),className:"accent-blue-500"}),e.jsx("span",{className:"text-gray-300",children:"This project only"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"scope",checked:y==="global",onChange:()=>b("global"),className:"accent-blue-500"}),e.jsx("span",{className:"text-gray-300",children:"Global (all projects)"})]})]}),e.jsx("button",{onClick:X,className:"px-4 py-2 bg-blue-600 hover:bg-blue-500 text-white rounded transition-colors disabled:opacity-50",disabled:h,children:h?"Waiting for browser...":"Login with Claude"})]})]})}function ON(){const{loadProjects:t}=Tr(),[s,o]=p.useState(null),[l,i]=p.useState([]),[d,u]=p.useState(!0),[h,x]=p.useState(null),[g,v]=p.useState(null),[y,b]=p.useState(null),[k,_]=p.useState(!1),[S,j]=p.useState(null);p.useEffect(()=>{async function C(){u(!0);try{const[E,I]=await Promise.all([Rh().catch(()=>null),_c().catch(()=>[])]);o(E),i(I)}finally{u(!1)}}C()},[]);const N=async()=>{try{const C=await Av();j(C)}catch{j({valid:!1,error:"Failed to validate credentials"})}};p.useEffect(()=>{N()},[]);const T=async C=>{if(window.confirm(`Are you sure you want to remove project "${C}"? This will not delete any files.`)){x(C),v(null);try{await Qy(C),i(l.filter(E=>E.slug!==C)),t()}catch(E){v(E instanceof Error?E.message:"Failed to remove project")}finally{x(null)}}},P=async C=>{_(!0),b(null),v(null);try{const E=await Xy("^e2e-",C);if(b(E),!C&&(E.deleted.length>0||E.failed.length>0)){const I=await _c().catch(()=>[]);i(I),t()}}catch(E){v(E instanceof Error?E.message:"Cleanup failed")}finally{_(!1)}};return e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[e.jsx(Se,{to:"/",className:"hover:text-white",children:"Dashboard"}),e.jsx("span",{children:"/"}),e.jsx("span",{className:"text-white",children:"Settings"})]}),e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold text-white mb-2",children:"Settings"}),e.jsx("p",{className:"text-gray-400",children:"Manage RalphX configuration and projects"})]}),d?e.jsx("div",{className:"text-gray-400",children:"Loading..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"System Information"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-gray-700",children:[e.jsx("span",{className:"text-gray-400",children:"API Status"}),e.jsx("span",{className:`${(s==null?void 0:s.status)==="healthy"?"text-green-400":"text-red-400"}`,children:(s==null?void 0:s.status)||"unavailable"})]}),e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-gray-700",children:[e.jsx("span",{className:"text-gray-400",children:"Version"}),e.jsx("span",{className:"text-white font-mono",children:(s==null?void 0:s.version)||"-"})]}),e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-gray-700",children:[e.jsx("span",{className:"text-gray-400",children:"Workspace"}),e.jsx("span",{className:"text-white font-mono text-sm",children:"~/.ralphx"})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-gray-400",children:"Projects Registered"}),e.jsx("span",{className:"text-white",children:l.length})]})]})]}),e.jsx(DN,{validationResult:S,onLoginSuccess:N}),e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Cleanup Test Data"}),e.jsx("p",{className:"text-gray-400 text-sm mb-4",children:"Remove orphaned test projects (e2e-test-*, e2e-loop-*, e2e-remove-*) left behind by E2E tests."}),e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("button",{onClick:()=>P(!0),disabled:k,className:"px-4 py-2 rounded bg-gray-700 text-gray-200 hover:bg-gray-600 disabled:opacity-50",children:k?"Scanning...":"Preview Cleanup"}),e.jsx("button",{onClick:()=>P(!1),disabled:k,className:"px-4 py-2 rounded bg-red-800 text-red-200 hover:bg-red-700 disabled:opacity-50",children:k?"Cleaning...":"Clean Up Now"})]}),y&&e.jsxs("div",{className:"mt-4 space-y-2",children:[y.deleted.length>0&&e.jsxs("div",{className:`p-3 rounded ${y.dry_run?"bg-yellow-900/30 border border-yellow-800":"bg-green-900/30 border border-green-800"}`,children:[e.jsx("div",{className:`text-sm font-medium ${y.dry_run?"text-yellow-400":"text-green-400"}`,children:y.dry_run?"Preview (will be deleted):":"Deleted:"}),e.jsx("ul",{className:"text-gray-300 text-sm mt-1 font-mono",children:y.deleted.map(C=>e.jsx("li",{children:C},C))})]}),y.failed&&y.failed.length>0&&e.jsxs("div",{className:"p-3 rounded bg-red-900/30 border border-red-800",children:[e.jsx("div",{className:"text-sm font-medium text-red-400",children:"Failed to delete (check server logs):"}),e.jsx("ul",{className:"text-gray-300 text-sm mt-1 font-mono",children:y.failed.map(C=>e.jsx("li",{children:C},C))})]}),y.deleted.length===0&&(!y.failed||y.failed.length===0)&&e.jsx("div",{className:"p-3 rounded bg-gray-800 border border-gray-700",children:e.jsx("p",{className:"text-gray-400 text-sm",children:"No matching projects found"})})]})]}),e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Registered Projects"}),g&&e.jsx("div",{className:"mb-4 px-3 py-2 bg-red-900/30 border border-red-800 rounded text-sm text-red-400",children:g}),l.length===0?e.jsx("p",{className:"text-gray-400",children:"No projects registered"}):e.jsx("div",{className:"space-y-2",children:l.map(C=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-700 rounded",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-white",children:C.name}),e.jsx("div",{className:"text-sm text-gray-400 font-mono",children:C.path})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Se,{to:`/projects/${C.slug}`,className:"px-3 py-1 text-sm rounded bg-primary-600 text-white hover:bg-primary-500",children:"View"}),e.jsx("button",{onClick:()=>T(C.slug),disabled:h===C.slug,className:"px-3 py-1 text-sm rounded bg-red-800 text-red-200 hover:bg-red-700 disabled:opacity-50",children:h===C.slug?"Removing...":"Remove"})]})]},C.slug))})]}),e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Documentation"}),e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-gray-300 font-medium",children:"Configuration Files"}),e.jsxs("p",{className:"text-gray-400 mt-1",children:["Loop configurations are stored in ",e.jsx("code",{className:"bg-gray-700 px-1 rounded",children:".ralphx/loops/"})," as YAML files."]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-gray-300 font-medium",children:"CLI Commands"}),e.jsxs("ul",{className:"text-gray-400 mt-1 space-y-1 font-mono text-xs",children:[e.jsx("li",{children:"ralphx add <path> - Add a project"}),e.jsx("li",{children:"ralphx list - List projects"}),e.jsx("li",{children:"ralphx run <slug> <loop> - Run a loop"}),e.jsx("li",{children:"ralphx serve - Start the web server"}),e.jsx("li",{children:"ralphx mcp - Start MCP server for Claude Code"})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-gray-300 font-medium",children:"MCP Integration"}),e.jsx("p",{className:"text-gray-400 mt-1",children:"Add RalphX to Claude Code:"}),e.jsx("code",{className:"block mt-1 px-3 py-2 bg-gray-700 rounded text-xs font-mono text-gray-300",children:"pip install ralphx"}),e.jsx("code",{className:"block mt-1 px-3 py-2 bg-gray-700 rounded text-xs font-mono text-gray-300",children:"claude mcp add ralphx -- ralphx mcp"})]})]})]})]})]})}const FN={DEBUG:"bg-gray-600 text-gray-300",INFO:"bg-blue-600 text-blue-100",WARNING:"bg-yellow-600 text-yellow-100",ERROR:"bg-red-600 text-red-100"},WN={system:"text-gray-400",auth:"text-purple-400",loop:"text-green-400",run:"text-blue-400",iteration:"text-cyan-400"};function zN(){const[t,s]=p.useState([]),[o,l]=p.useState(null),[i,d]=p.useState(!0),[u,h]=p.useState(null),[x,g]=p.useState(""),[v,y]=p.useState(""),[b]=p.useState(100),[k,_]=p.useState(0),[S,j]=p.useState(!1),[N,T]=p.useState(null),[P,C]=p.useState(!1),E=p.useRef(!1),I=p.useRef(!0),M=p.useCallback(async()=>{if(!E.current){E.current=!0,I.current?d(!0):C(!0),h(null);try{const U={limit:b,offset:k};x&&(U.level=x),v&&(U.category=v);const[O,X]=await Promise.all([Pv(U),Mv()]);s(O.logs),l(X),I.current=!1}catch(U){h(U instanceof Error?U.message:"Failed to load logs")}finally{d(!1),C(!1),E.current=!1}}},[x,v,b,k]);p.useEffect(()=>{M()},[M]),p.useEffect(()=>{if(!S)return;const U=setInterval(M,1e4);return()=>clearInterval(U)},[S,M]);const q=U=>zs(U).toLocaleString(),z=U=>{const O=Math.floor((Date.now()-zs(U).getTime())/1e3);if(O<60)return`${O}s ago`;const X=Math.floor(O/60);if(X<60)return`${X}m ago`;const ee=Math.floor(X/60);return ee<24?`${ee}h ago`:`${Math.floor(ee/24)}d ago`};return e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[e.jsx(Se,{to:"/",className:"hover:text-white",children:"Dashboard"}),e.jsx("span",{children:"/"}),e.jsx("span",{className:"text-white",children:"Logs"})]}),e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-white mb-1",children:"Logs"}),e.jsxs("p",{className:"text-gray-400",children:[(o==null?void 0:o.total)??0," total entries",o!=null&&o.recent_errors_24h?e.jsxs("span",{className:"text-red-400 ml-2",children:["(",o.recent_errors_24h," errors in last 24h)"]}):null]})]}),e.jsxs("div",{className:"flex items-center space-x-4",children:[P&&e.jsxs("span",{className:"text-sm text-gray-400 flex items-center",children:[e.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Refreshing..."]}),e.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:S,onChange:U=>j(U.target.checked),className:"form-checkbox bg-gray-700 border-gray-600 text-primary-500 rounded"}),e.jsx("span",{className:"text-gray-300 text-sm",children:"Auto-refresh"})]})]})]}),o&&e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-6",children:[e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"text-2xl font-bold text-white",children:o.total}),e.jsx("div",{className:"text-sm text-gray-400",children:"Total Entries"})]}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"text-2xl font-bold text-red-400",children:o.by_level.ERROR||0}),e.jsx("div",{className:"text-sm text-gray-400",children:"Errors"})]}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"text-2xl font-bold text-yellow-400",children:o.by_level.WARNING||0}),e.jsx("div",{className:"text-sm text-gray-400",children:"Warnings"})]}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"text-2xl font-bold text-blue-400",children:o.by_level.INFO||0}),e.jsx("div",{className:"text-sm text-gray-400",children:"Info"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-4 mb-4",children:[e.jsxs("select",{value:x,onChange:U=>{g(U.target.value),_(0)},className:"bg-gray-700 border border-gray-600 rounded px-3 py-2 text-white text-sm","aria-label":"Filter by level",children:[e.jsx("option",{value:"",children:"All Levels"}),e.jsx("option",{value:"ERROR",children:"ERROR"}),e.jsx("option",{value:"WARNING",children:"WARNING"}),e.jsx("option",{value:"INFO",children:"INFO"}),e.jsx("option",{value:"DEBUG",children:"DEBUG"})]}),e.jsxs("select",{value:v,onChange:U=>{y(U.target.value),_(0)},className:"bg-gray-700 border border-gray-600 rounded px-3 py-2 text-white text-sm","aria-label":"Filter by category",children:[e.jsx("option",{value:"",children:"All Categories"}),e.jsx("option",{value:"system",children:"system"}),e.jsx("option",{value:"auth",children:"auth"}),e.jsx("option",{value:"loop",children:"loop"}),e.jsx("option",{value:"run",children:"run"}),e.jsx("option",{value:"iteration",children:"iteration"})]}),e.jsx("button",{onClick:()=>M(),disabled:P,className:"px-3 py-2 bg-gray-700 hover:bg-gray-600 disabled:opacity-50 rounded text-white text-sm","aria-label":"Refresh logs",children:"Refresh"})]}),u&&e.jsx("div",{className:"mb-4 p-3 bg-red-900/30 border border-red-800 rounded text-red-400",children:u}),i&&t.length===0?e.jsx("div",{className:"text-gray-400",children:"Loading logs..."}):t.length===0?e.jsxs("div",{className:"card text-center py-8",children:[e.jsx("p",{className:"text-gray-400",children:"No logs found"}),e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Activity will appear here as you use the system"})]}):e.jsx("div",{className:"space-y-1",children:t.map(U=>e.jsxs("div",{className:"card !py-2",children:[e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":N===U.id,"aria-label":`${U.level} ${U.category||"unknown"}.${U.event||"unknown"}: ${U.message}`,className:"flex items-center justify-between cursor-pointer focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-opacity-50 rounded",onClick:()=>T(N===U.id?null:U.id),onKeyDown:O=>{(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),T(N===U.id?null:U.id))},children:[e.jsxs("div",{className:"flex items-center space-x-3 flex-1 min-w-0",children:[e.jsx("span",{className:`text-xs px-2 py-0.5 rounded font-medium ${FN[U.level]||"bg-gray-600 text-gray-300"}`,children:U.level}),e.jsxs("span",{className:`text-sm font-mono ${WN[U.category||""]||"text-gray-400"}`,children:[U.category||"unknown",".",U.event||"unknown"]}),e.jsx("span",{className:"text-sm text-gray-300 truncate",children:U.message})]}),e.jsxs("div",{className:"flex items-center space-x-4 text-xs text-gray-500 ml-4",children:[e.jsx("span",{title:q(U.timestamp),children:z(U.timestamp)}),U.metadata&&e.jsx("svg",{className:`w-4 h-4 transition-transform ${N===U.id?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),N===U.id&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-gray-700",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs text-gray-400",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Timestamp:"})," ",q(U.timestamp)]}),U.project_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Project:"})," ",U.project_id]}),U.run_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Run:"})," ",U.run_id]})]}),U.metadata&&e.jsxs("div",{className:"mt-2",children:[e.jsx("span",{className:"text-xs text-gray-500",children:"Metadata:"}),e.jsx("pre",{className:"mt-1 p-2 bg-gray-900 rounded text-xs text-gray-300 overflow-x-auto overflow-y-auto max-h-64",children:JSON.stringify(U.metadata,null,2)})]})]})]},U.id))}),t.length>0&&e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("div",{className:"text-sm text-gray-400",children:["Showing ",k+1," - ",k+t.length," of ",(o==null?void 0:o.total)??t.length]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>_(Math.max(0,k-b)),disabled:k===0,className:"px-3 py-1 bg-gray-700 hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed rounded text-sm text-white",children:"Previous"}),e.jsx("button",{onClick:()=>_(k+b),disabled:t.length<b,className:"px-3 py-1 bg-gray-700 hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed rounded text-sm text-white",children:"Next"})]})]})]})}const HN={opus:{label:"Opus",color:"text-purple-400"},sonnet:{label:"Sonnet",color:"text-cyan-400"},"sonnet-1m":{label:"Sonnet 1M",color:"text-cyan-400"},haiku:{label:"Haiku",color:"text-emerald-400"}};function UN({step:t,isCurrent:s,projectSlug:o,workflowId:l,onRun:i,onStop:d,onItemsClick:u,isRunning:h}){var M,q,z,U;const x=ir(),g=((M=t.config)==null?void 0:M.loopType)==="generator",v=((q=t.config)==null?void 0:q.loopType)==="consumer",y=t.input_items,b=y&&y.total>0,k=t.has_active_run===!0,_=(z=t.config)==null?void 0:z.model,S=_?HN[_]||{label:_,color:"text-gray-400"}:null,j=t.has_guardrails,N=(y==null?void 0:y.failed)??0,T=()=>{x(`/projects/${o}/workflows/${l}/steps/${t.step_number}`)},P=()=>k?e.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse shadow-[0_0_8px_var(--color-emerald)]"}):t.status==="completed"?e.jsx("svg",{className:"w-4 h-4 text-cyan-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):t.status==="active"?e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-400"}):e.jsx("span",{className:"w-2 h-2 rounded-full bg-gray-600"}),E=(t.iterations_completed??0)>0?t.completed_at||t.started_at:null,I=()=>{if(g){const O=t.items_generated??0;return e.jsxs("span",{className:`font-mono ${u&&O>0?"cursor-pointer hover:text-cyan-400":""}`,onClick:X=>{u&&O>0&&(X.stopPropagation(),u())},children:[e.jsx("span",{className:"text-[var(--color-text-primary)] font-semibold",children:O}),e.jsx("span",{className:"text-[var(--color-text-muted)] ml-1",children:"items"})]})}return v&&b?e.jsxs("div",{className:"font-mono text-right",children:[e.jsx("span",{className:"text-[var(--color-text-primary)] font-semibold",children:y.completed}),e.jsxs("span",{className:"text-[var(--color-text-muted)]",children:["/",y.total]}),N>0&&e.jsxs("span",{className:"text-red-400 ml-2",title:`${N} failed`,children:["(",N," err)"]})]}):e.jsx("span",{className:"text-[var(--color-text-muted)]",children:"—"})};return e.jsxs("div",{onClick:T,className:`group relative flex items-center gap-4 px-4 py-3 rounded-lg border cursor-pointer transition-all
192
- ${s?"border-cyan-500/50 bg-cyan-500/5":"border-[var(--color-border)] bg-[var(--color-surface)] hover:border-[var(--color-border-bright)] hover:bg-[var(--color-elevated)]"}
193
- ${k?"border-emerald-500/50 bg-emerald-500/5":""}
194
- `,children:[e.jsx("div",{className:"flex items-center gap-3 w-8",children:e.jsx(P,{})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs font-mono text-[var(--color-text-muted)]",children:[t.step_number,"."]}),e.jsx("span",{className:"font-medium text-[var(--color-text-primary)] truncate",children:t.name}),S&&e.jsx("span",{className:`text-[10px] font-mono ${S.color}`,title:`Using ${S.label} model`,children:S.label}),j&&e.jsx("span",{className:"text-[10px] text-amber-400",title:"Has guardrails configured",children:e.jsx("svg",{className:"w-3 h-3 inline",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M2.166 4.999A11.954 11.954 0 0010 1.944 11.954 11.954 0 0017.834 5c.11.65.166 1.32.166 2.001 0 5.225-3.34 9.67-8 11.317C5.34 16.67 2 12.225 2 7c0-.682.057-1.35.166-2.001zm11.541 3.708a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})})]}),((U=t.config)==null?void 0:U.description)&&e.jsx("p",{className:"text-xs text-[var(--color-text-muted)] truncate mt-0.5",children:t.config.description})]}),e.jsx("div",{className:"w-24 text-right text-sm",children:e.jsx(I,{})}),e.jsxs("div",{className:"w-24 text-right text-sm font-mono",children:[e.jsx("span",{className:"text-[var(--color-text-primary)]",children:t.iterations_completed??0}),t.iterations_target?e.jsxs("span",{className:"text-[var(--color-text-muted)]",children:["/",t.iterations_target]}):e.jsx("span",{className:"text-[var(--color-text-muted)] ml-1 text-xs",children:"cyc"})]}),e.jsx("div",{className:"w-24 text-right text-xs text-[var(--color-text-muted)]",children:ed(E,"Never")}),v&&b&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-[var(--color-border)] rounded-b-lg overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-cyan-500 to-emerald-500 transition-all",style:{width:`${y.completed/y.total*100}%`}})}),e.jsx("div",{className:"w-20 flex justify-end",children:k?d&&e.jsx("button",{onClick:O=>{O.stopPropagation(),d()},disabled:h,className:"px-3 py-1 text-xs font-medium bg-red-600/80 hover:bg-red-500 text-white rounded transition-colors disabled:opacity-50",children:"Stop"}):i&&e.jsx("button",{onClick:O=>{O.stopPropagation(),i()},disabled:h,className:"px-3 py-1 text-xs font-medium bg-[var(--color-elevated)] hover:bg-cyan-600 text-[var(--color-text-secondary)] hover:text-white border border-[var(--color-border)] hover:border-cyan-500 rounded transition-all opacity-0 group-hover:opacity-100",children:"Run"})})]})}function VN({steps:t,currentStep:s,projectSlug:o,workflowId:l,onRunStep:i,onStopStep:d,onItemsClick:u,isRunning:h}){return e.jsxs("div",{className:"space-y-2",children:[t.length>0&&e.jsxs("div",{className:"flex items-center gap-4 px-4 py-2 text-[10px] font-semibold text-[var(--color-text-muted)] uppercase tracking-wider",children:[e.jsx("div",{className:"w-8"}),e.jsx("div",{className:"flex-1",children:"Step"}),e.jsx("div",{className:"w-24 text-right",children:"Output"}),e.jsx("div",{className:"w-24 text-right",children:"Cycles"}),e.jsx("div",{className:"w-24 text-right",children:"Last Run"}),e.jsx("div",{className:"w-20"})]}),t.map(x=>e.jsx(UN,{step:x,isCurrent:x.step_number===s,projectSlug:o,workflowId:l,onRun:i?()=>i(x.step_number):void 0,onStop:d?()=>d(x.step_number):void 0,onItemsClick:u?()=>u(x.id):void 0,isRunning:h},x.id)),t.length===0&&e.jsxs("div",{className:"text-center py-12 text-[var(--color-text-muted)]",children:[e.jsx("svg",{className:"w-12 h-12 mx-auto mb-4 text-[var(--color-border)]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),e.jsx("p",{children:"No steps configured yet."}),e.jsx("p",{className:"text-sm mt-1",children:"Add steps in the workflow editor."})]})]})}function qN(t){return t?Math.ceil(t.length/4):0}function YN(t){return t<1e3?`${t}`:`${(t/1e3).toFixed(1)}k`}function GN(t){const s=t.map(d=>d.name.toLowerCase()),o=t.map(d=>{var u;return(((u=d.config)==null?void 0:u.description)||"").toLowerCase()}),l=[...s,...o].join(" "),i=(d,u)=>new RegExp(`\\b${u}\\b`,"i").test(d);return i(l,"story")||i(l,"stories")||i(l,"prd")||i(l,"user stories")||i(l,"requirements")?"new_product":i(l,"feature")&&(i(l,"implement")||i(l,"build"))?"feature":i(l,"bug")||i(l,"bugs")||i(l,"defect")||i(l,"bugfix")||i(l,"triage")?"bug_fix":i(l,"dependency")||i(l,"tech debt")||i(l,"maintenance")||i(l,"upgrade")?"maintenance":i(l,"ticket")||i(l,"support")||i(l,"customer")||i(l,"resolution")?"support":"generic"}function fh(t,s=!0){return{new_product:["story","stories"],feature:["task","tasks"],bug_fix:["bug","bugs"],maintenance:["item","items"],support:["ticket","tickets"],generic:["item","items"]}[t][s?1:0]}function KN(t){return{new_product:"discovered",feature:"identified",bug_fix:"triaged",maintenance:"found",support:"received",generic:"generated"}[t]}function JN(t){return{new_product:"implemented",feature:"completed",bug_fix:"fixed",maintenance:"addressed",support:"resolved",generic:"processed"}[t]}function QN(t){var M;const s=t.steps||[],o=GN(s),l=s.filter(q=>{var z;return((z=q.config)==null?void 0:z.loopType)==="generator"}),i=s.filter(q=>{var z;return((z=q.config)==null?void 0:z.loopType)==="consumer"}),d=l.reduce((q,z)=>q+(z.items_generated||0),0),u=i.reduce((q,z)=>{var U;return q+(((U=z.input_items)==null?void 0:U.completed)||0)},0),h=i.reduce((q,z)=>{var U;return q+(((U=z.input_items)==null?void 0:U.total)||0)},0),x=s.reduce((q,z)=>q+(z.iterations_completed||0),0),g=s.some(q=>q.has_active_run),v=s.find(q=>q.has_active_run),y=s.map(q=>q.completed_at||q.started_at).filter(Boolean).sort().reverse()[0];let b;t.status==="completed"?b="complete":d===0?b="discovery":u===0&&h>0?b="ready":u<h?b=u/h>.8?"finishing":"in_progress":d>0&&l.some(q=>q.status!=="completed")?b="discovery":b="complete";const k=fh(o),_=fh(o,!1),S=KN(o),j=JN(o);let N,T,P,C,E,I;if(g&&v)((M=v.config)==null?void 0:M.loopType)==="generator"?(N=o==="new_product"?"Discovering":o==="bug_fix"?"Triaging":o==="support"?"Processing":"Generating",T=`${v.name} in progress...`):(N=o==="new_product"?"Building":o==="bug_fix"?"Fixing":o==="support"?"Resolving":"Processing",T=`Working on ${v.name.toLowerCase()}...`),P="text-emerald-400",C="bg-emerald-400 animate-pulse";else if(t.status==="completed")N="Complete",T=`All ${k} ${j}`,P="text-blue-400",C="bg-blue-400";else if(t.status==="draft")N="Ready",T="Workflow not started",P="text-gray-400",C="bg-gray-500";else if(b==="discovery")N="Paused",T=d>0?`${d} ${k} ${S} so far`:`Ready to discover ${k}`,P="text-amber-400",C="bg-amber-400";else if(b==="ready")N="Ready to build",T=`${h} ${k} queued for ${o==="bug_fix"?"fixing":"implementation"}`,P="text-cyan-400",C="bg-cyan-400";else if(b==="in_progress"||b==="finishing"){const q=h-u,z=Math.round(u/h*100);N="Paused",T=`${q} ${q===1?_:k} remaining (${z}% done)`,P="text-amber-400",C="bg-amber-400"}else N="Idle",T="Ready to continue",P="text-gray-400",C="bg-gray-500";return o==="new_product"||o==="feature"?(E={label:u>0?`${k} ${j}`:`${k} ${S}`,value:u>0?`${u}/${h}`:d,subtext:u>0&&h>0?`${Math.round(u/h*100)}%`:void 0},d>0&&u===0&&(I={label:"ready to build",value:h||d})):o==="bug_fix"?(E={label:u>0?"bugs fixed":"bugs triaged",value:u>0?`${u}/${h}`:d},h>0&&(I={label:"remaining",value:h-u})):o==="support"?(E={label:"tickets resolved",value:u>0?`${u}/${h}`:"0"},d>0&&(I={label:"received",value:d})):E={label:u>0?"processed":"generated",value:u>0?`${u}/${h}`:d},{type:o,stage:b,generators:l,consumers:i,totalGenerated:d,totalProcessed:u,totalToProcess:h,totalIterations:x,isRunning:g,runningStep:v,lastActivity:y,primaryMetric:E,secondaryMetric:I,statusMessage:N,statusDetail:T,statusColor:P,dotClass:C}}function XN({workflow:t,resources:s,projectSlug:o,workflowId:l,onResourceUpdate:i}){const[d,u]=p.useState(null),[h,x]=p.useState(null),[g,v]=p.useState(""),[y,b]=p.useState(""),[k,_]=p.useState(!1),[S,j]=p.useState(null),[N,T]=p.useState(!1),[P,C]=p.useState(null),[E,I]=p.useState(null),[M,q]=p.useState([]),[z,U]=p.useState(0),[O,X]=p.useState(!1),[ee,W]=p.useState(null),[te,D]=p.useState(!1);p.useEffect(()=>{if(P){const pe=setTimeout(()=>C(null),3e3);return()=>clearTimeout(pe)}},[P]);const R=QN(t),Y=s.filter(pe=>pe.enabled),ie=Y.filter(pe=>pe.resource_type==="design_doc"),re=Y.filter(pe=>pe.resource_type==="guardrail"),L=Y.filter(pe=>pe.resource_type==="input_file"||pe.resource_type==="input"),F=Y.filter(pe=>pe.resource_type==="prompt"),H=pe=>new Date(pe).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),K=(pe,se)=>{se.stopPropagation(),x(pe),v(pe.content||""),b(pe.updated_at),j(null),u(null)},J=()=>T(!0),he=async()=>{if(!(!h||!i)){_(!0),j(null),T(!1);try{await i(h.id,g,y),C({message:"Version saved",type:"success"}),x(null)}catch(pe){const se=pe instanceof Error?pe.message:"Failed to save";se.includes("modified in another session")||se.includes("409")?j("Resource was modified in another session. Please reload."):j(se)}finally{_(!1)}}},_e=async(pe,se)=>{se.stopPropagation(),I(pe),X(!0),W(null),u(null);try{const Ne=await Zv(o,l,pe.id);q(Ne.versions),U(Ne.total)}catch(Ne){console.error("Failed to load versions:",Ne),q([]),U(0)}finally{X(!1)}},Ae=async pe=>{if(E){D(!0);try{await e2(o,l,E.id,pe.id),C({message:"Version restored",type:"success"}),I(null),W(null)}catch(se){console.error("Failed to restore version:",se),C({message:"Failed to restore version",type:"error"})}finally{D(!1)}}},Pe=({resources:pe,label:se,colorClass:Ne,icon:Le})=>{if(pe.length===0)return null;const ot=pe.reduce((ae,Ee)=>ae+qN(Ee.content),0),wt=d&&pe.some(ae=>ae.id===d.id);return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>u(wt?null:pe[0]),className:`flex items-center gap-3 px-4 py-3 rounded-lg border transition-all hover:border-[var(--color-border-bright)] ${wt?"border-[var(--color-border-bright)] bg-[var(--color-elevated)]":"border-[var(--color-border)] bg-[var(--color-surface)]"}`,children:[e.jsx("span",{className:Ne,children:Le}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--color-text-primary)]",children:pe.length===1?pe[0].name:se}),e.jsxs("div",{className:"text-xs text-[var(--color-text-muted)] flex items-center gap-2",children:[pe.length>1&&e.jsxs("span",{children:[pe.length," files"]}),e.jsxs("span",{children:[YN(ot)," tokens"]})]})]}),e.jsx("svg",{className:`w-4 h-4 text-[var(--color-text-muted)] transition-transform ml-2 ${wt?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),wt&&e.jsx("div",{className:"absolute top-full left-0 mt-2 w-96 bg-[var(--color-surface)] border border-[var(--color-border)] rounded-lg shadow-xl z-20 max-h-[400px] overflow-hidden",children:pe.map(ae=>{var Ee;return e.jsx("div",{className:"border-b border-[var(--color-border)] last:border-b-0",children:e.jsxs("div",{className:"p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--color-text-primary)]",children:ae.name}),e.jsxs("div",{className:"flex items-center gap-1",children:[i&&e.jsx("button",{onClick:Ve=>K(ae,Ve),className:"px-2 py-0.5 text-[10px] text-cyan-400 hover:text-cyan-300 hover:bg-cyan-500/10 rounded",children:"Edit"}),e.jsx("button",{onClick:Ve=>_e(ae,Ve),className:"px-2 py-0.5 text-[10px] text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)] hover:bg-[var(--color-elevated)] rounded",children:"History"})]})]}),e.jsxs("pre",{className:"text-[10px] text-[var(--color-text-muted)] whitespace-pre-wrap font-mono bg-[var(--color-deep)] p-2 rounded max-h-[150px] overflow-y-auto",children:[(ae.content||"").slice(0,800),(((Ee=ae.content)==null?void 0:Ee.length)||0)>800?"...":""]})]})},ae.id)})})]})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"card-panel mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${R.dotClass}`}),e.jsx("span",{className:`text-sm font-semibold ${R.statusColor}`,children:R.statusMessage})]}),e.jsx("span",{className:"text-sm text-[var(--color-text-secondary)]",children:R.statusDetail}),R.lastActivity&&e.jsxs("span",{className:"text-xs text-[var(--color-text-muted)] border-l border-[var(--color-border)] pl-4",children:["Last: ",ed(R.lastActivity,"Never")]})]}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:"text-xl font-bold text-[var(--color-text-primary)] font-mono",children:[R.primaryMetric.value,R.primaryMetric.subtext&&e.jsx("span",{className:"text-sm text-[var(--color-text-muted)] ml-1",children:R.primaryMetric.subtext})]}),e.jsx("div",{className:"text-[10px] text-[var(--color-text-muted)] uppercase tracking-wider",children:R.primaryMetric.label})]}),R.secondaryMetric&&e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-xl font-bold text-[var(--color-text-primary)] font-mono",children:R.secondaryMetric.value}),e.jsx("div",{className:"text-[10px] text-[var(--color-text-muted)] uppercase tracking-wider",children:R.secondaryMetric.label})]}),R.totalIterations>0&&e.jsxs("div",{className:"text-right border-l border-[var(--color-border)] pl-6",children:[e.jsx("div",{className:"text-lg font-bold text-[var(--color-text-secondary)] font-mono",children:R.totalIterations}),e.jsx("div",{className:"text-[10px] text-[var(--color-text-muted)] uppercase tracking-wider",children:"cycles"})]})]})]}),R.totalToProcess>0&&e.jsx("div",{className:"h-1 bg-[var(--color-border)]",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-cyan-500 to-emerald-500 transition-all duration-500",style:{width:`${R.totalProcessed/R.totalToProcess*100}%`}})})]}),Y.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"text-xs font-semibold text-[var(--color-text-muted)] uppercase tracking-wider mb-3",children:"Resources"}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(Pe,{resources:ie,label:"Design Docs",colorClass:"text-purple-400",icon:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),e.jsx(Pe,{resources:re,label:"Guidelines",colorClass:"text-amber-400",icon:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx(Pe,{resources:L,label:"Inputs",colorClass:"text-blue-400",icon:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})})}),e.jsx(Pe,{resources:F,label:"Prompts",colorClass:"text-emerald-400",icon:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})})]})]}),d&&e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>u(null)}),h&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-[var(--color-surface)] border border-[var(--color-border)] rounded-lg w-full max-w-2xl max-h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--color-border)]",children:[e.jsxs("h3",{className:"text-lg font-medium text-[var(--color-text-primary)]",children:["Edit: ",h.name]}),e.jsx("button",{onClick:()=>x(null),className:"text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)]",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"p-4 flex-1 overflow-auto",children:[S&&e.jsx("div",{className:"mb-4 p-3 rounded bg-red-900/20 border border-red-800 text-red-400 text-sm",children:S}),e.jsx("textarea",{value:g,onChange:pe=>v(pe.target.value),className:"w-full h-[300px] p-3 bg-[var(--color-elevated)] border border-[var(--color-border)] rounded text-sm text-[var(--color-text-primary)] font-mono resize-none focus:outline-none focus:border-cyan-500"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 px-4 py-3 border-t border-[var(--color-border)]",children:[e.jsx("button",{onClick:()=>x(null),className:"px-4 py-2 text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)]",children:"Cancel"}),e.jsx("button",{onClick:J,disabled:k||g===(h.content||""),className:"px-4 py-2 text-sm bg-cyan-600 text-white rounded hover:bg-cyan-500 disabled:opacity-50 disabled:cursor-not-allowed",children:k?"Saving...":"Save"})]})]})}),N&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-[var(--color-surface)] border border-[var(--color-border)] rounded-lg p-6 max-w-md",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-500/20 flex items-center justify-center",children:e.jsx("svg",{className:"w-5 h-5 text-amber-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx("h3",{className:"text-lg font-medium text-[var(--color-text-primary)]",children:"Save Changes?"})]}),e.jsxs("p",{className:"text-sm text-[var(--color-text-secondary)] mb-6",children:["This will update the resource for ",e.jsx("strong",{children:"ALL steps"})," in this workflow."]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>T(!1),className:"px-4 py-2 text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)]",children:"Cancel"}),e.jsx("button",{onClick:he,disabled:k,className:"px-4 py-2 text-sm bg-cyan-600 text-white rounded hover:bg-cyan-500 disabled:opacity-50",children:k?"Saving...":"Save"})]})]})}),E&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-[var(--color-surface)] border border-[var(--color-border)] rounded-lg w-full max-w-3xl max-h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--color-border)]",children:[e.jsxs("h3",{className:"text-lg font-medium text-[var(--color-text-primary)]",children:["History: ",E.name]}),e.jsx("button",{onClick:()=>{I(null),W(null)},className:"text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)]",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:O?e.jsx("div",{className:"text-center py-8 text-[var(--color-text-muted)]",children:"Loading..."}):M.length===0?e.jsx("div",{className:"text-center py-8 text-[var(--color-text-muted)]",children:"No history yet."}):e.jsxs("div",{className:"space-y-3",children:[M.map(pe=>e.jsxs("div",{className:`p-3 rounded border ${(ee==null?void 0:ee.id)===pe.id?"border-cyan-500 bg-cyan-500/10":"border-[var(--color-border)] hover:border-[var(--color-border-bright)]"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-sm font-medium text-[var(--color-text-primary)]",children:["Version ",pe.version_number]}),e.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:H(pe.created_at)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>W((ee==null?void 0:ee.id)===pe.id?null:pe),className:"px-2 py-1 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)] hover:bg-[var(--color-elevated)] rounded",children:(ee==null?void 0:ee.id)===pe.id?"Hide":"Preview"}),e.jsx("button",{onClick:()=>Ae(pe),disabled:te,className:"px-2 py-1 text-xs text-cyan-400 hover:text-cyan-300 hover:bg-cyan-500/10 rounded disabled:opacity-50",children:te?"Restoring...":"Restore"})]}),(ee==null?void 0:ee.id)===pe.id&&e.jsx("pre",{className:"mt-3 text-xs text-[var(--color-text-secondary)] whitespace-pre-wrap font-mono bg-[var(--color-elevated)] p-3 rounded max-h-[200px] overflow-y-auto",children:pe.content||"(empty)"})]},pe.id)),z>M.length&&e.jsxs("div",{className:"text-center text-xs text-[var(--color-text-muted)] py-2",children:["Showing ",M.length," of ",z]})]})})]})}),P&&e.jsx("div",{className:`fixed bottom-6 right-6 px-4 py-3 rounded-lg shadow-lg ${P.type==="success"?"bg-green-900/90 border border-green-700 text-green-400":"bg-red-900/90 border border-red-700 text-red-400"}`,children:P.message})]})}function ZN({projectSlug:t,item:s,onUpdate:o,onEdit:l,onDuplicate:i}){var j;const[d,u]=p.useState(!1),[h,x]=p.useState(!1),[g,v]=p.useState(null),[y,b]=p.useState(!1),k=async N=>{x(!0),v(null);try{await Gc(t,s.id,{status:N}),o()}catch(T){v(T instanceof Error?T.message:"Failed to update item")}finally{x(!1)}},_=async()=>{if(window.confirm("Are you sure you want to delete this item?")){x(!0),v(null);try{await $h(t,s.id),o()}catch(N){v(N instanceof Error?N.message:"Failed to delete item")}finally{x(!1)}}},S=s.id.includes("-")?s.id.split("-")[0].toUpperCase()+"-"+((j=s.id.split("-")[1])==null?void 0:j.slice(0,3).toUpperCase()):s.id.slice(0,8).toUpperCase();return e.jsxs("div",{className:"border-b border-[var(--color-border)] last:border-b-0",children:[e.jsxs("div",{className:`flex items-center gap-4 px-4 py-3 cursor-pointer hover:bg-[var(--color-elevated)] transition-colors ${d?"bg-[var(--color-elevated)]":""}`,onClick:()=>{d&&b(!1),u(!d)},children:[e.jsx("div",{className:"w-24 flex-shrink-0",children:e.jsx("span",{className:"font-mono text-xs text-[var(--color-text-muted)]",children:S})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-sm text-[var(--color-text-primary)] truncate",children:s.title||s.content.slice(0,80)})}),e.jsx("div",{className:"w-28 flex-shrink-0",children:e.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${Xc(s.status)}`,children:Qc(s.status)})}),e.jsx("div",{className:"w-20 flex-shrink-0",children:s.category&&e.jsx("span",{className:"text-xs text-[var(--color-text-muted)] uppercase",children:s.category})}),e.jsx("div",{className:"w-20 flex-shrink-0 text-right",children:e.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:ed(s.created_at)})}),e.jsx("div",{className:"w-6 flex-shrink-0",children:e.jsx("svg",{className:`w-4 h-4 text-[var(--color-text-muted)] transition-transform ${d?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}),d&&e.jsxs("div",{className:"px-4 py-4 bg-[var(--color-surface)] border-t border-[var(--color-border)]",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h4",{className:"text-xs font-medium text-[var(--color-text-muted)] mb-2 uppercase tracking-wide",children:"Content"}),e.jsx("p",{className:"text-sm text-[var(--color-text-secondary)] whitespace-pre-wrap",children:s.content})]}),s.dependencies&&s.dependencies.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("h4",{className:"text-xs font-medium text-[var(--color-text-muted)] mb-2 uppercase tracking-wide",children:"Dependencies"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:s.dependencies.map(N=>e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-[var(--color-elevated)] text-[var(--color-text-secondary)]",children:N},N))})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[var(--color-text-muted)]",children:"Created:"}),e.jsx("span",{className:"ml-1 text-[var(--color-text-secondary)]",children:hs(s.created_at)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[var(--color-text-muted)]",children:"Updated:"}),e.jsx("span",{className:"ml-1 text-[var(--color-text-secondary)]",children:hs(s.updated_at)})]}),s.phase!==void 0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[var(--color-text-muted)]",children:"Phase:"}),e.jsx("span",{className:"ml-1 text-[var(--color-text-secondary)]",children:s.phase})]}),s.priority!==void 0&&s.priority>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[var(--color-text-muted)]",children:"Priority:"}),e.jsxs("span",{className:"ml-1 text-[var(--color-text-secondary)]",children:["P",s.priority]})]}),s.claimed_by&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[var(--color-text-muted)]",children:"Claimed by:"}),e.jsx("span",{className:"ml-1 text-[var(--color-text-secondary)]",children:s.claimed_by})]}),s.duplicate_of&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[var(--color-text-muted)]",children:"Duplicate of:"}),e.jsx("span",{className:"ml-1 text-[var(--color-text-secondary)]",children:s.duplicate_of})]})]}),g&&e.jsx("div",{className:"mb-4 px-3 py-2 bg-red-900/30 border border-red-800 rounded text-xs text-red-400",role:"alert",children:g}),e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:y?e.jsxs(e.Fragment,{children:[l&&e.jsx("button",{onClick:N=>{N.stopPropagation(),l(s)},disabled:h,className:"px-3 py-1.5 text-xs rounded bg-cyan-600/20 text-cyan-400 hover:bg-cyan-600/30 disabled:opacity-50 transition-colors",children:"Edit"}),i&&e.jsx("button",{onClick:N=>{N.stopPropagation(),i(s)},disabled:h,className:"px-3 py-1.5 text-xs rounded bg-purple-600/20 text-purple-400 hover:bg-purple-600/30 disabled:opacity-50 transition-colors",children:"Duplicate"}),e.jsx("div",{className:"w-px h-6 bg-[var(--color-border)] self-center mx-1"}),s.status!=="processed"&&e.jsx("button",{onClick:N=>{N.stopPropagation(),k("processed")},disabled:h,className:"px-3 py-1.5 text-xs rounded bg-green-600/20 text-green-400 hover:bg-green-600/30 disabled:opacity-50 transition-colors",children:"Mark Done"}),s.status!=="skipped"&&e.jsx("button",{onClick:N=>{N.stopPropagation(),k("skipped")},disabled:h,className:"px-3 py-1.5 text-xs rounded bg-gray-600/20 text-gray-400 hover:bg-gray-600/30 disabled:opacity-50 transition-colors",children:"Skip"}),s.status!=="pending"&&e.jsx("button",{onClick:N=>{N.stopPropagation(),k("pending")},disabled:h,className:"px-3 py-1.5 text-xs rounded bg-blue-600/20 text-blue-400 hover:bg-blue-600/30 disabled:opacity-50 transition-colors",children:"Reset to Queued"}),e.jsx("button",{onClick:N=>{N.stopPropagation(),_()},disabled:h,className:"px-3 py-1.5 text-xs rounded bg-red-600/20 text-red-400 hover:bg-red-600/30 disabled:opacity-50 transition-colors",children:"Delete"}),e.jsx("div",{className:"w-px h-6 bg-[var(--color-border)] self-center mx-1"}),e.jsx("button",{onClick:N=>{N.stopPropagation(),b(!1)},className:"px-2 py-1.5 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] transition-colors",title:"Hide actions",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}):e.jsx("button",{onClick:N=>{N.stopPropagation(),b(!0)},className:"px-3 py-1.5 text-xs rounded border border-[var(--color-border)] text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] hover:border-[var(--color-border-hover)] transition-colors",children:"Enable Actions"})})]})]})}const gh={title:"",content:"",category:"",priority:0,dependencies:[]};function ek({isOpen:t,onClose:s,onSave:o,item:l,mode:i,existingCategories:d=[]}){const[u,h]=p.useState(gh),[x,g]=p.useState(""),[v,y]=p.useState(!1),[b,k]=p.useState(null);p.useEffect(()=>{t&&(h(l&&(i==="edit"||i==="duplicate")?{title:i==="duplicate"&&l.title?`${l.title} (copy)`:l.title||"",content:l.content,category:l.category||"",priority:l.priority||0,dependencies:l.dependencies||[]}:gh),g(""),k(null))},[t,l,i]);const _=async P=>{if(P.preventDefault(),k(null),!u.content.trim()){k("Content is required");return}y(!0);try{await o(u),s()}catch(C){k(C instanceof Error?C.message:"Failed to save")}finally{y(!1)}},S=()=>{const P=x.trim().toUpperCase();P&&!u.dependencies.includes(P)&&(h(C=>({...C,dependencies:[...C.dependencies,P]})),g(""))},j=P=>{h(C=>({...C,dependencies:C.dependencies.filter(E=>E!==P)}))},N=P=>{P.key==="Enter"&&(P.preventDefault(),S())};if(!t)return null;const T=i==="create"?"Create New Item":i==="duplicate"?"Duplicate Item":"Edit Item";return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:s}),e.jsxs("div",{className:"relative w-full max-w-2xl max-h-[90vh] overflow-y-auto bg-[var(--color-elevated)] border border-[var(--color-border)] rounded-lg shadow-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--color-border)]",children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--color-text-primary)]",children:T}),e.jsx("button",{onClick:s,className:"p-1 hover:bg-[var(--color-border)] rounded transition-colors",children:e.jsx("svg",{className:"w-5 h-5 text-[var(--color-text-muted)]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("form",{onSubmit:_,className:"p-4 space-y-4",children:[b&&e.jsx("div",{className:"p-3 bg-red-500/10 border border-red-500/20 rounded text-red-400 text-sm",children:b}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--color-text-secondary)] mb-1",children:"Title (optional)"}),e.jsx("input",{type:"text",value:u.title,onChange:P=>h(C=>({...C,title:P.target.value})),className:`w-full px-3 py-2 bg-[var(--color-base)] border border-[var(--color-border)] rounded
195
- text-[var(--color-text-primary)] placeholder-[var(--color-text-muted)]
196
- focus:outline-none focus:border-cyan-500`,placeholder:"e.g., FND-001: Add user authentication"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--color-text-secondary)] mb-1",children:["Content ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("textarea",{value:u.content,onChange:P=>h(C=>({...C,content:P.target.value})),rows:8,className:`w-full px-3 py-2 bg-[var(--color-base)] border border-[var(--color-border)] rounded
197
- text-[var(--color-text-primary)] placeholder-[var(--color-text-muted)] font-mono text-sm
198
- focus:outline-none focus:border-cyan-500 resize-y`,placeholder:"Describe the work item...",required:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--color-text-secondary)] mb-1",children:"Category"}),e.jsx("input",{type:"text",list:"categories",value:u.category,onChange:P=>h(C=>({...C,category:P.target.value})),className:`w-full px-3 py-2 bg-[var(--color-base)] border border-[var(--color-border)] rounded
199
- text-[var(--color-text-primary)] placeholder-[var(--color-text-muted)]
200
- focus:outline-none focus:border-cyan-500`,placeholder:"e.g., FND, API, UI"}),e.jsx("datalist",{id:"categories",children:d.map(P=>e.jsx("option",{value:P},P))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--color-text-secondary)] mb-1",children:"Priority"}),e.jsx("input",{type:"number",value:u.priority,onChange:P=>h(C=>({...C,priority:parseInt(P.target.value)||0})),min:0,max:100,className:`w-full px-3 py-2 bg-[var(--color-base)] border border-[var(--color-border)] rounded
201
- text-[var(--color-text-primary)]
202
- focus:outline-none focus:border-cyan-500`}),e.jsx("p",{className:"text-xs text-[var(--color-text-muted)] mt-1",children:"0 = lowest, 100 = highest"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--color-text-secondary)] mb-1",children:"Dependencies"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{type:"text",value:x,onChange:P=>g(P.target.value),onKeyDown:N,className:`flex-1 px-3 py-2 bg-[var(--color-base)] border border-[var(--color-border)] rounded
203
- text-[var(--color-text-primary)] placeholder-[var(--color-text-muted)]
204
- focus:outline-none focus:border-cyan-500`,placeholder:"e.g., FND-001"}),e.jsx("button",{type:"button",onClick:S,className:`px-3 py-2 bg-[var(--color-border)] hover:bg-[var(--color-border-hover)] rounded
205
- text-[var(--color-text-secondary)] transition-colors`,children:"Add"})]}),u.dependencies.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:u.dependencies.map(P=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-blue-500/20 text-blue-400 rounded text-sm",children:[P,e.jsx("button",{type:"button",onClick:()=>j(P),className:"hover:text-blue-200",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},P))})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t border-[var(--color-border)]",children:[e.jsx("button",{type:"button",onClick:s,className:`px-4 py-2 text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)]
206
- hover:bg-[var(--color-border)] rounded transition-colors`,children:"Cancel"}),e.jsx("button",{type:"submit",disabled:v,className:`px-4 py-2 bg-cyan-600 hover:bg-cyan-500 text-white rounded
207
- transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:v?"Saving...":i==="create"?"Create":i==="duplicate"?"Duplicate":"Save Changes"})]})]})]})]})}function tk({projectSlug:t,workflowId:s,steps:o,onClose:l,onImported:i}){const[d,u]=p.useState([]),[h,x]=p.useState(""),[g,v]=p.useState(null),[y,b]=p.useState(null),[k,_]=p.useState(!1),[S,j]=p.useState(null),N=p.useRef(null),[T,P]=p.useState(0);p.useEffect(()=>{async function M(){try{const z=await u2(t);u(z);const U=z.find(O=>O.id==="hank_prd");U?x(U.id):z.length>0&&x(z[0].id)}catch{j("Failed to load import formats")}}async function q(){try{const z=await Ao(t,{workflow_id:s,limit:1});P(z.total)}catch(z){console.warn("Could not load existing items count:",z)}}M(),q()},[t,s]),p.useEffect(()=>{const M=o.find(q=>{var z,U;return q.step_type==="autonomous"&&(((z=q.config)==null?void 0:z.loopType)==="consumer"||!((U=q.config)!=null&&U.loopType))});M?v(M.id):o.length>0&&v(o[0].id)},[o]);const C=M=>{var z;const q=(z=M.target.files)==null?void 0:z[0];q&&(b(q),j(null))},E=async()=>{if(!y||!h||g===null){j("Please select a file, format, and target step");return}_(!0),j(null);try{const M=await m2(t,s,g,h,y);i(M)}catch(M){j(M instanceof Error?M.message:"Import failed")}finally{_(!1)}},I=d.find(M=>M.id===h);return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:l,onKeyDown:M=>M.key==="Escape"&&l(),role:"dialog","aria-modal":"true","aria-labelledby":"import-dialog-title",children:e.jsxs("div",{className:"card max-w-lg w-full mx-4 max-h-[90vh] overflow-y-auto",onClick:M=>M.stopPropagation(),children:[e.jsx("h3",{id:"import-dialog-title",className:"text-xl font-semibold text-white mb-4",children:"Import Work Items (JSONL)"}),S&&e.jsx("div",{className:"mb-4 p-3 rounded bg-red-900/30 border border-red-800 text-red-400 text-sm",children:S}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Import Format"}),e.jsx("select",{value:h,onChange:M=>x(M.target.value),className:"w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-white",children:d.map(M=>e.jsx("option",{value:M.id,children:M.label},M.id))}),(I==null?void 0:I.description)&&e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:I.description})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Target Step"}),e.jsx("select",{value:g??"",onChange:M=>v(Number(M.target.value)),className:"w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-white",children:o.map(M=>e.jsxs("option",{value:M.id,children:["Step ",M.step_number,": ",M.name,M.step_type==="autonomous"?" (Consumer)":""]},M.id))}),e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Items will be available to this step for processing"})]}),T>0&&e.jsx("div",{className:"mb-4 p-4 rounded-lg border bg-gray-800/50 border-gray-700",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("svg",{className:"w-5 h-5 text-cyan-400 flex-shrink-0 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-gray-300",children:["This workflow already has ",T," item",T!==1?"s":"","."]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"New items will be added alongside existing ones. Items with duplicate IDs will be skipped."})]})]})}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"JSONL File"}),e.jsxs("div",{className:"border-2 border-dashed border-gray-700 rounded-lg p-6 text-center cursor-pointer hover:border-gray-600 transition-colors",onClick:()=>{var M;return(M=N.current)==null?void 0:M.click()},children:[e.jsx("input",{ref:N,type:"file",accept:".jsonl,.json",onChange:C,className:"hidden"}),y?e.jsxs("div",{children:[e.jsx("svg",{className:"w-8 h-8 mx-auto text-green-400 mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("p",{className:"text-white font-medium",children:y.name}),e.jsxs("p",{className:"text-sm text-gray-500",children:[(y.size/1024).toFixed(1)," KB"]})]}):e.jsxs("div",{children:[e.jsx("svg",{className:"w-8 h-8 mx-auto text-gray-500 mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),e.jsx("p",{className:"text-gray-400",children:"Click to select a JSONL file"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"or drag and drop"})]})]})]}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:l,className:"px-4 py-2 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:E,disabled:k||!y||!h||g===null,className:"px-4 py-2 text-white rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed bg-primary-600 hover:bg-primary-500",children:k?"Importing...":"Import Items"})]})]})})}const wo=50,rk=[{value:"",label:"All Statuses"},{value:"pending",label:"Queued"},{value:"completed",label:"Ready"},{value:"claimed",label:"In Progress"},{value:"processed",label:"Done"},{value:"failed",label:"Failed"},{value:"skipped",label:"Skipped"},{value:"duplicate",label:"Duplicate"}];function Px({projectSlug:t,workflowId:s,sourceStepId:o,steps:l,onImported:i}){const[d,u]=p.useState([]),[h,x]=p.useState(0),[g,v]=p.useState(!0),[y,b]=p.useState(null),[k,_]=p.useState(""),[S,j]=p.useState(""),[N,T]=p.useState(""),[P,C]=p.useState(0),[E,I]=p.useState([]),[M,q]=p.useState(!1),[z,U]=p.useState("create"),[O,X]=p.useState(null),[ee,W]=p.useState(!1),te=p.useCallback(async()=>{v(!0),b(null);try{const H=await Ao(t,{workflow_id:s,source_step_id:o,status:k||void 0,category:S||void 0,limit:wo,offset:P*wo});if(u(H.items),x(H.total),P===0&&H.items.length>0){const K=[...new Set(H.items.map(J=>J.category).filter(Boolean))];I(K.sort())}}catch(H){b(H instanceof Error?H.message:"Failed to load items")}finally{v(!1)}},[t,s,o,k,S,P]);p.useEffect(()=>{te()},[te]),p.useEffect(()=>{C(0)},[k,S]);const D=()=>{X(null),U("create"),q(!0)},R=H=>{X(H),U("edit"),q(!0)},Y=H=>{X(H),U("duplicate"),q(!0)},ie=async H=>{const K=(O==null?void 0:O.source_step_id)||o||0;z==="create"?await Yc(t,{workflow_id:s,source_step_id:K,title:H.title||void 0,content:H.content,category:H.category||void 0,priority:H.priority||void 0,dependencies:H.dependencies.length>0?H.dependencies:void 0}):z==="edit"&&O?await Gc(t,O.id,{title:H.title||void 0,content:H.content,category:H.category||void 0,priority:H.priority,dependencies:H.dependencies}):z==="duplicate"&&O&&await lv(t,O.id,{title:H.title||void 0,content:H.content,category:H.category||void 0,priority:H.priority,dependencies:H.dependencies.length>0?H.dependencies:void 0}),te()},re=N?d.filter(H=>{var K;return((K=H.title)==null?void 0:K.toLowerCase().includes(N.toLowerCase()))||H.content.toLowerCase().includes(N.toLowerCase())||H.id.toLowerCase().includes(N.toLowerCase())}):d,L=Math.ceil(h/wo),F=d.reduce((H,K)=>(H[K.status]=(H[K.status]||0)+1,H),{});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--color-text-primary)]",children:"Work Items"}),e.jsxs("span",{className:"text-sm text-[var(--color-text-muted)]",children:[h," total"]}),e.jsx("button",{onClick:D,className:"px-3 py-1.5 text-sm font-medium bg-cyan-600 hover:bg-cyan-500 text-white rounded transition-colors",children:"+ Add Item"}),e.jsxs("button",{onClick:()=>W(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium bg-gray-700 hover:bg-gray-600 text-gray-300 rounded transition-colors",title:"Import work items from JSONL file",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})}),"Import Items"]})]}),e.jsx("div",{className:"flex items-center gap-2",children:Object.entries(F).map(([H,K])=>e.jsxs("button",{onClick:()=>_(k===H?"":H),className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors
208
- ${k===H?"ring-2 ring-offset-1 ring-offset-[var(--color-surface)]":""}
209
- ${Xc(H)}`,children:[e.jsx("span",{children:Qc(H)}),e.jsx("span",{className:"opacity-75",children:K})]},H))})]}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsx("div",{className:"flex-1 min-w-[200px] max-w-md",children:e.jsx("input",{type:"text",placeholder:"Search by title, content, or ID...",value:N,onChange:H=>T(H.target.value),className:`w-full px-3 py-2 text-sm bg-[var(--color-elevated)] border border-[var(--color-border)] rounded-lg
210
- text-[var(--color-text-primary)] placeholder-[var(--color-text-muted)]
211
- focus:outline-none focus:ring-2 focus:ring-cyan-500/50`})}),e.jsx("select",{value:k,onChange:H=>_(H.target.value),className:`px-3 py-2 text-sm bg-[var(--color-elevated)] border border-[var(--color-border)] rounded-lg
212
- text-[var(--color-text-primary)]
213
- focus:outline-none focus:ring-2 focus:ring-cyan-500/50`,children:rk.map(H=>e.jsx("option",{value:H.value,children:H.label},H.value))}),E.length>0&&e.jsxs("select",{value:S,onChange:H=>j(H.target.value),className:`px-3 py-2 text-sm bg-[var(--color-elevated)] border border-[var(--color-border)] rounded-lg
214
- text-[var(--color-text-primary)]
215
- focus:outline-none focus:ring-2 focus:ring-cyan-500/50`,children:[e.jsx("option",{value:"",children:"All Categories"}),E.map(H=>e.jsx("option",{value:H,children:H.toUpperCase()},H))]}),(k||S||N)&&e.jsx("button",{onClick:()=>{_(""),j(""),T("")},className:"px-3 py-2 text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)] transition-colors",children:"Clear filters"})]}),y&&e.jsx("div",{className:"p-4 bg-red-900/20 border border-red-800 rounded-lg text-red-400",children:y}),g&&e.jsx("div",{className:"py-8 text-center text-[var(--color-text-muted)]",children:"Loading items..."}),!g&&re.length>0&&e.jsxs("div",{className:"bg-[var(--color-elevated)] border border-[var(--color-border)] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-4 px-4 py-3 bg-[var(--color-surface)] border-b border-[var(--color-border)] text-xs font-medium text-[var(--color-text-muted)] uppercase tracking-wide",children:[e.jsx("div",{className:"w-24 flex-shrink-0",children:"ID"}),e.jsx("div",{className:"flex-1",children:"Title"}),e.jsx("div",{className:"w-28 flex-shrink-0",children:"Status"}),e.jsx("div",{className:"w-20 flex-shrink-0",children:"Category"}),e.jsx("div",{className:"w-20 flex-shrink-0 text-right",children:"Created"}),e.jsx("div",{className:"w-6 flex-shrink-0"})]}),re.map(H=>e.jsx(ZN,{projectSlug:t,item:H,onUpdate:te,onEdit:R,onDuplicate:Y},H.id))]}),!g&&re.length===0&&e.jsxs("div",{className:"py-12 text-center",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-[var(--color-elevated)] flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-[var(--color-text-muted)]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})})}),e.jsx("p",{className:"text-[var(--color-text-muted)]",children:k||S||N?"No items match your filters":"No work items yet"})]}),L>1&&e.jsxs("div",{className:"flex items-center justify-between pt-4",children:[e.jsxs("div",{className:"text-sm text-[var(--color-text-muted)]",children:["Showing ",P*wo+1,"-",Math.min((P+1)*wo,h)," of ",h]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>C(H=>Math.max(0,H-1)),disabled:P===0,className:`px-3 py-1.5 text-sm bg-[var(--color-elevated)] border border-[var(--color-border)] rounded
216
- text-[var(--color-text-secondary)] hover:bg-[var(--color-surface)]
217
- disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:"Previous"}),e.jsxs("span",{className:"text-sm text-[var(--color-text-muted)]",children:["Page ",P+1," of ",L]}),e.jsx("button",{onClick:()=>C(H=>Math.min(L-1,H+1)),disabled:P>=L-1,className:`px-3 py-1.5 text-sm bg-[var(--color-elevated)] border border-[var(--color-border)] rounded
218
- text-[var(--color-text-secondary)] hover:bg-[var(--color-surface)]
219
- disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:"Next"})]})]}),e.jsx(ek,{isOpen:M,onClose:()=>q(!1),onSave:ie,item:O,mode:z,workflowId:s,sourceStepId:o||0,existingCategories:E}),ee&&e.jsx(tk,{projectSlug:t,workflowId:s,steps:l,onClose:()=>W(!1),onImported:H=>{W(!1),te(),i==null||i(H)}})]})}function sk({projectSlug:t,workflowId:s,workflowName:o,onClose:l}){const[i,d]=p.useState(null),[u,h]=p.useState(!0),[x,g]=p.useState(!1),[v,y]=p.useState(null),[b,k]=p.useState(!1),[_,S]=p.useState(!0),[j,N]=p.useState(!0);p.useEffect(()=>{async function C(){try{const E=await h2(t,s);d(E)}catch(E){y(E instanceof Error?E.message:"Failed to load export preview")}finally{h(!1)}}C()},[t,s]);const T=async()=>{g(!0),y(null);try{const E=await p2(t,s,{include_runs:b,include_planning:_,strip_secrets:j}),I=URL.createObjectURL(E),M=document.createElement("a");M.href=I,M.download=`workflow-${(i==null?void 0:i.workflow_namespace)||s}-${new Date().toISOString().slice(0,10)}.ralphx.zip`,document.body.appendChild(M),M.click(),document.body.removeChild(M),URL.revokeObjectURL(I),l()}catch(C){y(C instanceof Error?C.message:"Export failed")}finally{g(!1)}},P=C=>C<1024?`${C} B`:C<1024*1024?`${(C/1024).toFixed(1)} KB`:`${(C/(1024*1024)).toFixed(1)} MB`;return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:l,onKeyDown:C=>C.key==="Escape"&&l(),role:"dialog","aria-modal":"true","aria-labelledby":"export-dialog-title",children:e.jsxs("div",{className:"card max-w-lg w-full mx-4 max-h-[90vh] overflow-y-auto",onClick:C=>C.stopPropagation(),children:[e.jsx("h3",{id:"export-dialog-title",className:"text-xl font-semibold text-white mb-4",children:"Export Workflow"}),v&&e.jsx("div",{className:"mb-4 p-3 rounded bg-red-900/30 border border-red-800 text-red-400 text-sm",children:v}),u?e.jsx("div",{className:"py-8 text-center text-gray-400",children:"Loading export preview..."}):i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6 p-4 rounded-lg bg-gray-800/50 border border-gray-700",children:[e.jsx("h4",{className:"font-medium text-white mb-2",children:o}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsx("div",{className:"text-gray-400",children:"Steps:"}),e.jsx("div",{className:"text-white",children:i.steps_count}),e.jsx("div",{className:"text-gray-400",children:"Items:"}),e.jsx("div",{className:"text-white",children:i.items_total}),e.jsx("div",{className:"text-gray-400",children:"Resources:"}),e.jsx("div",{className:"text-white",children:i.resources_count}),e.jsx("div",{className:"text-gray-400",children:"Estimated Size:"}),e.jsx("div",{className:"text-white",children:P(i.estimated_size_bytes)})]})]}),i.potential_secrets_detected&&e.jsx("div",{className:"mb-4 p-3 rounded bg-yellow-900/30 border border-yellow-700 text-yellow-400 text-sm",children:e.jsxs("div",{className:"flex items-start space-x-2",children:[e.jsx("svg",{className:"w-5 h-5 flex-shrink-0 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),e.jsxs("div",{children:[e.jsx("strong",{children:"Potential secrets detected!"}),e.jsx("p",{className:"mt-1 text-yellow-300/80",children:'API keys or credentials may be present in the workflow content. "Strip secrets" is enabled by default.'})]})]})}),e.jsxs("div",{className:"mb-6 space-y-3",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-300",children:"Export Options"}),e.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:_,onChange:C=>S(C.target.checked),className:"w-4 h-4 rounded border-gray-600 bg-gray-800 text-cyan-500 focus:ring-cyan-500"}),e.jsxs("span",{className:"text-gray-300",children:["Include planning session",i.has_planning_session&&e.jsx("span",{className:"text-gray-500 ml-1",children:"(available)"})]})]}),e.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:b,onChange:C=>k(C.target.checked),className:"w-4 h-4 rounded border-gray-600 bg-gray-800 text-cyan-500 focus:ring-cyan-500"}),e.jsxs("span",{className:"text-gray-300",children:["Include execution history",i.runs_count>0&&e.jsxs("span",{className:"text-gray-500 ml-1",children:["(",i.runs_count," runs)"]})]})]}),e.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:j,onChange:C=>N(C.target.checked),className:"w-4 h-4 rounded border-gray-600 bg-gray-800 text-cyan-500 focus:ring-cyan-500"}),e.jsx("span",{className:"text-gray-300",children:"Strip potential secrets (recommended)"})]})]}),i.warnings.length>0&&e.jsxs("div",{className:"mb-4 p-3 rounded bg-yellow-900/20 border border-yellow-800 text-sm",children:[e.jsx("h5",{className:"text-yellow-400 font-medium mb-1",children:"Warnings"}),e.jsx("ul",{className:"list-disc list-inside text-yellow-300/80",children:i.warnings.map((C,E)=>e.jsx("li",{children:C},E))})]})]}):null,e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:l,className:"px-4 py-2 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:T,disabled:u||x||!i,className:"px-4 py-2 bg-cyan-600 text-white rounded hover:bg-cyan-500 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-2",children:x?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-4 h-4 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),e.jsx("span",{children:"Exporting..."})]}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),e.jsx("span",{children:"Export"})]})})]})]})})}function nk(){const{slug:t,workflowId:s}=yr(),o=ir(),[l,i]=p.useState(null),[d,u]=p.useState([]),[h,x]=p.useState(!0),[g,v]=p.useState(null),[y,b]=p.useState(!1),[k,_]=p.useState(!1),[S,j]=p.useState(null),[N,T]=p.useState("steps"),[P,C]=p.useState(void 0),E=p.useCallback(async()=>{if(!(!t||!s))try{const[L,F]=await Promise.all([Po(t,s),fl(t,s)]);i(L),u(F),v(null)}catch(L){v(L instanceof Error?L.message:"Failed to load workflow")}finally{x(!1)}},[t,s]);p.useEffect(()=>{E()},[E]),p.useEffect(()=>{if(!l||l.status==="completed"||l.status==="draft")return;const L=setInterval(E,2e3);return()=>clearInterval(L)},[l,E]);const I=async()=>{(await rt.fire({title:"Run All Ralph Loops?",text:"This will begin executing all Ralph loops in the workflow from the current step.",icon:"question",showCancelButton:!0,confirmButtonColor:"var(--color-primary)",cancelButtonColor:"var(--color-slate)",confirmButtonText:"Run Full Workflow Ralph Loops",cancelButtonText:"Cancel",background:"var(--color-surface)",color:"var(--color-text-primary)"})).isConfirmed&&await M()},M=async()=>{if(!(!t||!s)){b(!0);try{const L=await Wv(t,s);i(L)}catch(L){v(L instanceof Error?L.message:"Failed to start workflow")}finally{b(!1)}}},q=async()=>{if(!(!t||!s||!(await rt.fire({title:"Stop Workflow?",text:"This will stop the current execution. You can resume later.",icon:"warning",showCancelButton:!0,confirmButtonColor:"var(--color-rose)",cancelButtonColor:"var(--color-slate)",confirmButtonText:"Stop",cancelButtonText:"Cancel",background:"var(--color-surface)",color:"var(--color-text-primary)"})).isConfirmed)){b(!0);try{const F=await Fh(t,s);i(F)}catch(F){v(F instanceof Error?F.message:"Failed to stop workflow")}finally{b(!1)}}},z=async()=>{if(!(!t||!s||!(await rt.fire({title:"Archive Workflow?",text:"This workflow will be moved to the archive. You can restore it later from project settings.",icon:"info",showCancelButton:!0,confirmButtonColor:"var(--color-primary)",cancelButtonColor:"var(--color-slate)",confirmButtonText:"Archive",cancelButtonText:"Cancel",background:"var(--color-surface)",color:"var(--color-text-primary)"})).isConfirmed)){b(!0);try{await Ov(t,s),o(`/projects/${t}/workflows`)}catch(F){v(F instanceof Error?F.message:"Failed to archive workflow"),b(!1)}}},U=async L=>{var K;if(!t||!s)return;const F=((K=((l==null?void 0:l.steps)||[]).find(J=>J.step_number===L))==null?void 0:K.name)||`Step ${L}`;if((await rt.fire({title:"Run Ralph Loop?",text:`Start executing "${F}"?`,icon:"question",showCancelButton:!0,confirmButtonColor:"var(--color-primary)",cancelButtonColor:"var(--color-slate)",confirmButtonText:"Run Ralph Loop",cancelButtonText:"Cancel",background:"var(--color-surface)",color:"var(--color-text-primary)"})).isConfirmed){b(!0);try{const J=await Wh(t,s,L);i(J)}catch(J){v(J instanceof Error?J.message:"Failed to run step")}finally{b(!1)}}},O=async L=>{await q()},X=L=>{C(L),T("items")},ee=async(L,F,H)=>{!t||!s||(await So(t,s,L,{content:F,expected_updated_at:H}),await E())};if(h)return e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"text-gray-400",children:"Loading workflow..."})});if(g&&!l)return e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"card bg-red-900/20 border border-red-800",children:[e.jsx("h2",{className:"text-lg font-semibold text-red-400 mb-2",children:"Error"}),e.jsx("p",{className:"text-gray-300",children:g}),e.jsx(Se,{to:`/projects/${t}/workflows`,className:"btn-secondary mt-4 inline-block",children:"Back to Workflows"})]})});if(!l)return e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"card",children:e.jsx("p",{className:"text-gray-400",children:"Workflow not found"})})});const W=l.steps||[],te=W.some(L=>L.has_active_run===!0),R=l.status==="active"?te?"running":"idle":l.status,Y=l.status!=="completed"&&!te,ie=te,re={draft:"bg-gray-600",running:"bg-green-600",idle:"bg-amber-600",active:"bg-green-600",paused:"bg-yellow-600",completed:"bg-blue-600",failed:"bg-red-600"};return e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[e.jsx(Se,{to:"/",className:"hover:text-white",children:"Dashboard"}),e.jsx("span",{children:"/"}),e.jsx(Se,{to:`/projects/${t}`,className:"hover:text-white",children:t}),e.jsx("span",{children:"/"}),e.jsx(Se,{to:`/projects/${t}/workflows`,className:"hover:text-white",children:"Workflows"}),e.jsx("span",{children:"/"}),e.jsx("span",{className:"text-white",children:l.name})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("h1",{className:"text-3xl font-bold text-white",children:l.name}),e.jsx("span",{className:`px-3 py-1 rounded-full text-sm font-medium text-white ${re[R]}`,children:R.charAt(0).toUpperCase()+R.slice(1)})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[Y&&e.jsxs("button",{onClick:I,disabled:y,title:"Execute all steps in sequence from the current position",className:"flex items-center space-x-2 px-4 py-2 bg-green-600 text-white rounded hover:bg-green-500 transition-colors disabled:opacity-50",children:[e.jsxs("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})]}),e.jsx("span",{children:"Run Full Workflow Ralph Loops"})]}),ie&&e.jsxs("button",{onClick:q,disabled:y,title:"Stop all running steps immediately",className:"flex items-center space-x-2 px-4 py-2 bg-red-600 text-white rounded hover:bg-red-500 transition-colors disabled:opacity-50",children:[e.jsxs("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 10a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z"})]}),e.jsx("span",{children:"Stop Workflow"})]}),e.jsxs("button",{onClick:()=>_(!0),className:"flex items-center space-x-2 px-4 py-2 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 transition-colors",title:"Export workflow to shareable ZIP file",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),e.jsx("span",{children:"Export Workflow"})]}),e.jsxs("button",{onClick:()=>o(`/projects/${t}/workflows/${s}/edit`),title:"Modify workflow steps, resources, and configuration",className:"flex items-center space-x-2 px-4 py-2 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 transition-colors",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})}),e.jsx("span",{children:"Edit"})]}),e.jsxs("button",{onClick:z,className:"flex items-center space-x-2 px-4 py-2 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 transition-colors",title:"Move workflow to archive (can be restored later)",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4"})}),e.jsx("span",{children:"Archive"})]})]})]})]}),g&&l&&e.jsx("div",{className:"mb-6 p-4 rounded-lg bg-red-900/20 border border-red-800",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-red-400 text-sm",children:g}),e.jsx("button",{onClick:()=>v(null),className:"text-red-400 hover:text-red-300","aria-label":"Dismiss error",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),e.jsxs("div",{className:"flex border-b border-[var(--color-border)] mb-6",children:[e.jsxs("button",{onClick:()=>T("steps"),className:`px-4 py-3 text-sm font-medium transition-colors relative
220
- ${N==="steps"?"text-cyan-400":"text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)]"}`,children:["Steps",N==="steps"&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-cyan-500"})]}),e.jsxs("button",{onClick:()=>{T("items"),C(void 0)},className:`px-4 py-3 text-sm font-medium transition-colors relative flex items-center gap-2
221
- ${N==="items"?"text-cyan-400":"text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)]"}`,children:["Items",W.reduce((L,F)=>L+(F.items_generated||0),0)>0&&e.jsx("span",{className:"px-1.5 py-0.5 text-xs rounded-full bg-cyan-500/20 text-cyan-400",children:W.reduce((L,F)=>L+(F.items_generated||0),0)}),N==="items"&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-cyan-500"})]})]}),N==="items"&&e.jsx("div",{className:"card",children:e.jsx(Px,{projectSlug:t,workflowId:s,sourceStepId:P,steps:W,onImported:L=>{j(L),E()}})}),N==="steps"&&e.jsxs("div",{children:[e.jsx(XN,{workflow:l,resources:d,projectSlug:t,workflowId:s,onResourceUpdate:ee}),e.jsx("div",{className:"text-xs font-semibold text-[var(--color-text-muted)] uppercase tracking-wider mb-3",children:"Steps"}),e.jsx(VN,{steps:W,currentStep:l.current_step,projectSlug:t,workflowId:s,onRunStep:U,onStopStep:O,onItemsClick:X,isRunning:y}),l.status==="completed"&&e.jsxs("div",{className:"card text-center py-8 mt-6",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-blue-900/30 flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsx("h3",{className:"text-xl font-semibold text-white mb-2",children:"Workflow Complete!"}),e.jsx("p",{className:"text-gray-400",children:"All steps have been completed successfully."})]})]}),k&&e.jsx(sk,{projectSlug:t,workflowId:s,workflowName:l.name,onClose:()=>_(!1)}),S&&e.jsx("div",{className:"fixed bottom-6 right-6 p-4 rounded-lg bg-green-900/90 border border-green-700 shadow-lg max-w-sm",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-green-400 font-medium",children:"Import Complete"}),e.jsxs("p",{className:"text-sm text-gray-300 mt-1",children:["Imported ",S.imported," items",S.skipped>0&&`, skipped ${S.skipped}`]}),S.errors.length>0&&e.jsxs("p",{className:"text-sm text-yellow-400 mt-1",children:[S.errors.length," error(s)"]})]}),e.jsx("button",{onClick:()=>j(null),className:"text-gray-400 hover:text-white ml-4",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})]})}function yh({message:t,isStreaming:s=!1}){const o=t.role==="user",l=u=>u.split(/\n\n+/).map((x,g)=>{if(/^\d+\.\s/.test(x)){const y=x.split(/\n(?=\d+\.\s)/);return e.jsx("ol",{className:"list-decimal list-inside space-y-1 mb-4",children:y.map((b,k)=>{const _=b.replace(/^\d+\.\s/,"");return e.jsx("li",{children:d(_)},k)})},g)}if(/^[-*]\s/.test(x)){const y=x.split(/\n(?=[-*]\s)/);return e.jsx("ul",{className:"list-disc list-inside space-y-1 mb-4",children:y.map((b,k)=>{const _=b.replace(/^[-*]\s/,"");return e.jsx("li",{children:d(_)},k)})},g)}const v=x.match(/^(#{1,3})\s+(.+)$/);if(v){const y=v[1].length,b=v[2],k=y===1?"text-lg font-bold mb-2":y===2?"text-base font-semibold mb-2":"text-sm font-medium mb-1";return e.jsx("div",{className:k,children:d(b)},g)}return e.jsx("p",{className:"mb-4 last:mb-0",children:d(x)},g)}),i=u=>u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"),d=u=>{let h=i(u);return h=h.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),h=h.replace(/\*(.+?)\*/g,"<em>$1</em>"),h=h.replace(/`(.+?)`/g,'<code class="px-1 py-0.5 bg-gray-700 rounded text-sm">$1</code>'),e.jsx("span",{dangerouslySetInnerHTML:{__html:h}})};return e.jsx("div",{className:`flex ${o?"justify-end":"justify-start"}`,children:e.jsxs("div",{className:`max-w-[80%] rounded-lg px-4 py-3 ${o?"bg-primary-600 text-white":"bg-gray-800 border border-gray-700 text-gray-200"}`,children:[e.jsxs("div",{className:`text-xs mb-2 ${o?"text-primary-200":"text-gray-500"}`,children:[o?"You":"Claude",s&&e.jsx("span",{className:"ml-2 animate-pulse",children:"typing..."})]}),e.jsx("div",{className:"text-sm leading-relaxed",children:l(t.content)}),t.timestamp&&e.jsx("div",{className:`text-xs mt-2 ${o?"text-primary-200":"text-gray-500"}`,children:Vh(t.timestamp)})]})})}function ok({artifacts:t}){var d,u;const[s,o]=p.useState("design_doc"),l=[{id:"design_doc",label:"Design Document",content:t.design_doc},{id:"guardrails",label:"Guardrails",content:t.guardrails}].filter(h=>h.content);if(l.length===0)return null;const i=((d=l.find(h=>h.id===s))==null?void 0:d.content)||((u=l[0])==null?void 0:u.content);return e.jsxs("div",{className:"mt-4 rounded-lg border border-gray-700 overflow-hidden",children:[e.jsx("div",{className:"flex border-b border-gray-700 bg-gray-800",children:l.map(h=>e.jsx("button",{onClick:()=>o(h.id),className:`px-4 py-2 text-sm font-medium transition-colors ${s===h.id?"text-white bg-gray-700 border-b-2 border-primary-500":"text-gray-400 hover:text-white hover:bg-gray-700/50"}`,children:h.label},h.id))}),e.jsx("div",{className:"p-4 bg-gray-900 max-h-96 overflow-y-auto",children:e.jsx("pre",{className:"text-sm text-gray-300 whitespace-pre-wrap font-mono",children:i})})]})}function ak({projectSlug:t,workflowId:s,onComplete:o}){const[l,i]=p.useState(null),[d,u]=p.useState(""),[h,x]=p.useState(!0),[g,v]=p.useState(!1),[y,b]=p.useState(!1),[k,_]=p.useState(""),[S,j]=p.useState(null),[N,T]=p.useState(!1),[P,C]=p.useState(!1),E=p.useRef(null),I=p.useRef(null),M=p.useRef(null);p.useEffect(()=>()=>{M.current&&(M.current.close(),M.current=null)},[]);const q=()=>{var te;(te=E.current)==null||te.scrollIntoView({behavior:"smooth"})},z=p.useCallback(async()=>{try{const te=await Kv(t,s);i(te),j(null)}catch(te){j(te instanceof Error?te.message:"Failed to load session")}finally{x(!1)}},[t,s]);p.useEffect(()=>{z()},[z]),p.useEffect(()=>{q()},[l==null?void 0:l.messages,k]);const U=async()=>{if(!d.trim()||g||y)return;const te=d.trim();u(""),v(!0),j(null);try{const D=await Jv(t,s,te);i(D),b(!0),_(""),M.current&&M.current.close();const R=Xv(t,s);M.current=R,R.onmessage=Y=>{try{const ie=JSON.parse(Y.data);ie.type==="content"?_(re=>re+ie.content):ie.type==="error"?(R.close(),M.current=null,b(!1),j(ie.message||"An error occurred")):ie.type==="done"&&(R.close(),M.current=null,b(!1),z())}catch(ie){console.error("Failed to parse SSE event:",ie,Y.data)}},R.onerror=()=>{R.close(),M.current=null,b(!1),j("Connection lost. Please try again.")}}catch(D){j(D instanceof Error?D.message:"Failed to send message")}finally{v(!1)}},O=te=>{te.key==="Enter"&&!te.shiftKey&&(te.preventDefault(),U())},X=async()=>{if(l){C(!0);try{await Qv(t,s,l.artifacts),o()}catch(te){j(te instanceof Error?te.message:"Failed to complete session"),C(!1)}}};if(h)return e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"text-gray-400",children:"Loading planning session..."})});if(S&&!l)return e.jsx("div",{className:"p-4 rounded-lg bg-red-900/20 border border-red-800 text-red-400",children:S});const ee=l&&l.messages.length>0,W=(l==null?void 0:l.artifacts)&&(l.artifacts.design_doc||l.artifacts.guardrails);return e.jsxs("div",{className:"flex flex-col h-[600px]",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto space-y-4 mb-4 pr-2",children:[!ee&&!y&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-primary-900/30 flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-primary-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})})}),e.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Let's plan your project"}),e.jsx("p",{className:"text-gray-400 max-w-md mx-auto",children:"Describe what you want to build, and I'll help you create a detailed design document."})]}),l==null?void 0:l.messages.map((te,D)=>e.jsx(yh,{message:te},D)),y&&k&&e.jsx(yh,{message:{role:"assistant",content:k,timestamp:new Date().toISOString()},isStreaming:!0}),g&&!y&&e.jsxs("div",{className:"flex items-center space-x-2 text-gray-400",children:[e.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce"}),e.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),e.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]}),e.jsx("div",{ref:E})]}),S&&e.jsx("div",{className:"mb-4 p-3 rounded-lg bg-red-900/20 border border-red-800 text-red-400 text-sm",children:S}),W&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("button",{onClick:()=>T(!N),className:"flex items-center space-x-2 text-sm text-primary-400 hover:text-primary-300",children:[e.jsx("svg",{className:`w-4 h-4 transition-transform ${N?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),e.jsx("span",{children:"View Generated Artifacts"})]}),N&&(l==null?void 0:l.artifacts)&&e.jsx(ok,{artifacts:l.artifacts})]}),e.jsxs("div",{className:"border-t border-gray-700 pt-4",children:[e.jsxs("div",{className:"flex items-end space-x-3",children:[e.jsx("div",{className:"flex-1",children:e.jsx("textarea",{ref:I,value:d,onChange:te=>u(te.target.value),onKeyDown:O,placeholder:"Describe your project or answer questions...",rows:3,className:"w-full px-4 py-3 bg-gray-800 border border-gray-700 rounded-lg text-white placeholder-gray-500 focus:border-primary-500 focus:ring-1 focus:ring-primary-500 resize-none",disabled:g||y})}),e.jsx("div",{className:"flex flex-col space-y-2",children:e.jsx("button",{onClick:U,disabled:!d.trim()||g||y,className:"px-4 py-3 bg-primary-600 text-white rounded-lg hover:bg-primary-500 transition-colors disabled:opacity-50",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})})})]}),ee&&e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx("button",{onClick:X,disabled:P||g||y,className:"flex items-center space-x-2 px-4 py-2 bg-green-600 text-white rounded hover:bg-green-500 transition-colors disabled:opacity-50",children:P?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),e.jsx("span",{children:"Completing..."})]}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{children:"Complete Planning"})]})})})]})]})}let lk=0;function ik(){return Date.now()*1e3+lk++%1e3}function ck({projectSlug:t,loopName:s,enabled:o=!0,pollInterval:l=5e3}){const[i,d]=p.useState({}),[u,h]=p.useState(!0),[x,g]=p.useState(null),v=p.useRef(null),y=p.useRef({runId:null,iteration:null}),b=p.useCallback(async()=>{if(o)try{const j=await fetch(`/api/projects/${t}/loops/${s}/events/grouped`);if(!j.ok)throw new Error(`Failed to fetch events: ${j.statusText}`);const N=await j.json();d(N.runs||{});for(const[T,P]of Object.entries(N.runs))if(P.status==="running"||P.status==="paused"){y.current.runId=T;const C=Object.keys(P.iterations).map(Number);C.length>0&&(y.current.iteration=Math.max(...C));break}g(null)}catch(j){g(j instanceof Error?j.message:"Failed to load events")}finally{h(!1)}},[t,s,o]),k=p.useCallback(j=>{const{type:N,data:T}=j;if(["heartbeat","connected","disconnected"].includes(N))return;const P=T.run_id,C=T.iteration;if((!P||C===void 0)&&(!y.current.runId||!y.current.iteration))return;const E=P||y.current.runId,I=C??y.current.iteration;y.current.runId=E,y.current.iteration=I;const M={id:ik(),session_id:T.session_id||"",event_type:N,timestamp:new Date().toISOString(),content:T.content,tool_name:T.name,tool_input:T.input,tool_result:T.result,error_message:T.message};d(q=>{const z={...q};return z[E]||(z[E]={status:"running",loop_name:s,started_at:null,completed_at:null,iterations_completed:0,iterations:{}}),z[E].iterations[I]||(z[E].iterations[I]={session_id:T.session_id||"",mode:null,status:"active",is_live:!0,events:[]}),z[E].iterations[I].events=[...z[E].iterations[I].events,M],z[E].iterations[I].is_live=!0,N==="status"&&(z[E].status=T.status||z[E].status,y.current.iteration=T.iteration||I),N==="complete"&&(z[E].iterations[I].is_live=!1,z[E].iterations[I].status="completed"),z})},[]),_=o?`/api/projects/${t}/loops/${s}/stream`:"",{isConnected:S}=Fp({url:_,enabled:o&&!!_,onEvent:k,maxStoredEvents:0});return p.useEffect(()=>{b();const j=()=>{v.current=setTimeout(()=>{b(),j()},l)};return j(),()=>{v.current&&clearTimeout(v.current)}},[b,l]),{runs:i,loading:u,error:x,isConnected:S,refresh:b}}function dk(t){let s=0;for(const o of Object.values(t))for(const l of Object.values(o.iterations))s+=l.events.length;return s}function uk(t){let s=0;for(const o of Object.values(t.iterations))s+=o.events.length;return s}function vh({projectSlug:t,loopName:s,enabled:o=!0}){const{runs:l,loading:i,error:d,isConnected:u,refresh:h}=ck({projectSlug:t,loopName:s,enabled:o}),[x,g]=p.useState(new Set),[v,y]=p.useState(new Set),[b,k]=p.useState(new Set),_=p.useRef(null),S=p.useRef(!1),j=p.useRef(!1),N=p.useRef(0);p.useEffect(()=>{if(S.current||Object.keys(l).length===0)return;S.current=!0;const z=new Set,U=new Set,O=Object.entries(l).sort(([,X],[,ee])=>{const W=X.started_at?new Date(X.started_at).getTime():0,te=ee.started_at?new Date(ee.started_at).getTime():0;return W-te});for(let X=O.length-1;X>=0;X--){const[ee,W]=O[X];if(W.status==="running"||W.status==="paused"){z.add(ee),Object.entries(W.iterations).forEach(([te,D])=>{D.is_live&&U.add(`${ee}-${te}`)});break}}g(z),y(U)},[l]);const T=p.useCallback(()=>{if(!_.current)return;const{scrollTop:z,scrollHeight:U,clientHeight:O}=_.current,X=U-z-O<50;j.current=!X,N.current=z},[]);p.useEffect(()=>{!_.current||j.current||(_.current.scrollTop=_.current.scrollHeight)},[l]);const P=p.useCallback(z=>{g(U=>{const O=new Set(U);return O.has(z)?O.delete(z):O.add(z),O})},[]),C=p.useCallback((z,U)=>{const O=`${z}-${U}`;y(X=>{const ee=new Set(X);return ee.has(O)?ee.delete(O):ee.add(O),ee})},[]),E=p.useCallback(z=>{k(U=>{const O=new Set(U);return O.has(z)?O.delete(z):O.add(z),O})},[]),I=p.useCallback(()=>{const z=new Set(Object.keys(l)),U=new Set;Object.entries(l).forEach(([O,X])=>{Object.keys(X.iterations).forEach(ee=>{U.add(`${O}-${ee}`)})}),g(z),y(U)},[l]),M=p.useCallback(()=>{g(new Set),y(new Set),k(new Set)},[]);if(d)return e.jsxs("div",{className:"card-panel p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 text-[var(--color-rose)]",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),e.jsx("span",{className:"font-medium",children:d})]}),e.jsx("button",{onClick:h,className:"mt-4 btn-secondary",children:"Retry"})]});const q=Object.entries(l).sort(([,z],[,U])=>{const O=z.started_at?new Date(z.started_at).getTime():0,X=U.started_at?new Date(U.started_at).getTime():0;return O-X});return e.jsxs("div",{className:"card-panel overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-[var(--color-border)] bg-[var(--color-surface)]/50",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-[var(--color-violet)]/20 flex items-center justify-center",children:e.jsx("svg",{className:"w-4 h-4 text-[var(--color-violet)]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-[var(--color-text-primary)]",children:"Session Log"}),e.jsx("div",{className:"flex items-center gap-2 text-xs",children:u?e.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--color-emerald)]",children:[e.jsx("span",{className:"status-dot status-dot-running"}),"Live"]}):e.jsx("span",{className:"text-[var(--color-text-muted)]",children:"Disconnected"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:I,className:"px-3 py-1.5 text-xs font-medium text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] hover:bg-[var(--color-elevated)] rounded-md transition-colors",children:"Expand All"}),e.jsx("button",{onClick:M,className:"px-3 py-1.5 text-xs font-medium text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] hover:bg-[var(--color-elevated)] rounded-md transition-colors",children:"Collapse"})]})]}),e.jsx("div",{ref:_,onScroll:T,className:"max-h-[500px] overflow-y-auto custom-scrollbar",children:i?e.jsxs("div",{className:"flex items-center justify-center py-12 text-[var(--color-text-muted)]",children:[e.jsxs("svg",{className:"w-5 h-5 animate-spin mr-3",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Loading session history..."]}):q.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-[var(--color-text-muted)]",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[var(--color-elevated)] flex items-center justify-center mb-3",children:e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),e.jsx("p",{className:"font-medium",children:"No session history yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Events will appear here when the step runs"})]}):e.jsx("div",{className:"p-3 space-y-1",children:q.map(([z,U],O)=>e.jsx(hk,{runId:z,run:U,isExpanded:x.has(z),expandedIterations:v,expandedEvents:b,onToggleRun:P,onToggleIteration:C,onToggleEvent:E,index:O},z))})}),e.jsxs("div",{className:"px-5 py-3 text-xs font-mono text-[var(--color-text-muted)] border-t border-[var(--color-border)] bg-[var(--color-deep)]",children:[e.jsx("span",{className:"text-[var(--color-cyan)]",children:dk(l)})," events across"," ",e.jsx("span",{className:"text-[var(--color-cyan)]",children:Object.keys(l).length})," runs"]})]})}function mk(t){const s=t.match(/_step(\d+)$/);return s?parseInt(s[1],10):null}function hk({runId:t,run:s,isExpanded:o,expandedIterations:l,expandedEvents:i,onToggleRun:d,onToggleIteration:u,onToggleEvent:h,index:x}){const g=uk(s),v=mk(s.loop_name),y=s.completed_at||s.started_at,b=k2(y),k=()=>{switch(s.status){case"running":return"status-dot-running";case"paused":return"status-dot-paused";case"completed":return"status-dot-completed";case"aborted":return"status-dot-aborted";default:return""}},_=()=>{switch(s.status){case"running":return"badge-running";case"paused":return"badge-pending";case"completed":return"badge-completed";case"aborted":return"badge-aborted";default:return"badge-pending"}},S=Object.entries(s.iterations).map(([j,N])=>[parseInt(j,10),N]).sort(([j],[N])=>j-N);return e.jsxs("div",{className:`animate-fade-in-up stagger-${Math.min(x+1,5)}`,style:{opacity:0},children:[e.jsxs("button",{onClick:()=>d(t),className:"flex items-center gap-3 w-full py-2.5 px-3 hover:bg-[var(--color-elevated)] rounded-lg transition-colors group",children:[e.jsx("svg",{className:`w-4 h-4 text-[var(--color-text-muted)] transition-transform duration-200 ${o?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),e.jsx("span",{className:`status-dot ${k()}`}),e.jsxs("span",{className:"font-mono text-sm text-[var(--color-text-primary)]",children:["Run #",x+1]}),v&&e.jsxs("span",{className:"px-2 py-0.5 text-xs font-mono bg-[var(--color-violet)]/20 text-[var(--color-violet)] rounded border border-[var(--color-violet)]/30",children:["Step ",v]}),e.jsx("span",{className:`badge ${_()} ml-1`,children:s.status}),e.jsxs("span",{className:"ml-auto flex items-center gap-3 font-mono text-xs text-[var(--color-text-muted)]",children:[b&&e.jsx("span",{title:"Last update",children:b}),e.jsxs("span",{className:"text-[var(--color-text-muted)]/60",children:[g," events"]})]})]}),e.jsx("div",{className:`overflow-hidden transition-all duration-300 ${o?"max-h-[3000px] opacity-100":"max-h-0 opacity-0"}`,children:e.jsx("div",{className:"ml-4 pl-4 border-l-2 border-[var(--color-border)] space-y-0.5",children:S.map(([j,N])=>e.jsx(pk,{runId:t,iteration:j,data:N,isExpanded:l.has(`${t}-${j}`),expandedEvents:i,onToggle:()=>u(t,j),onToggleEvent:h},`${t}-${j}`))})})]})}function pk({runId:t,iteration:s,data:o,isExpanded:l,expandedEvents:i,onToggle:d,onToggleEvent:u}){return e.jsxs("div",{children:[e.jsxs("button",{onClick:d,className:"flex items-center gap-2 w-full py-2 px-3 hover:bg-[var(--color-elevated)] rounded-md transition-colors",children:[e.jsx("svg",{className:`w-3.5 h-3.5 text-[var(--color-text-muted)] transition-transform duration-200 ${l?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),o.is_live?e.jsx("span",{className:"status-dot status-dot-running"}):e.jsx("svg",{className:"w-4 h-4 text-[var(--color-emerald)]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsxs("span",{className:"font-mono text-sm text-[var(--color-text-secondary)]",children:["Iteration ",e.jsx("span",{className:"text-[var(--color-text-primary)]",children:s})]}),o.mode&&e.jsxs("span",{className:"text-xs text-[var(--color-text-muted)]",children:["(",o.mode,")"]}),e.jsxs("span",{className:"ml-auto font-mono text-xs text-[var(--color-text-muted)]",children:[o.events.length," events"]})]}),e.jsx("div",{className:`overflow-hidden transition-all duration-200 ${l?"max-h-[2000px] opacity-100":"max-h-0 opacity-0"}`,children:e.jsx("div",{className:"ml-4 pl-4 border-l border-[var(--color-border)]/50 space-y-0.5 py-1",children:o.events.map((h,x)=>{const g=`${h.id}-${x}`;return e.jsx(xk,{event:h,isExpanded:i.has(h.id),isLive:o.is_live&&x===o.events.length-1,onToggle:()=>u(h.id)},g)})})})]})}const wh={text:{icon:"💬",color:"text-[var(--color-text-secondary)]",bg:"bg-[var(--color-elevated)]"},tool_call:{icon:"🔧",color:"text-[var(--color-cyan)]",bg:"bg-[var(--color-cyan)]/10"},tool_result:{icon:"✓",color:"text-[var(--color-emerald)]",bg:"bg-[var(--color-emerald)]/10"},error:{icon:"✕",color:"text-[var(--color-rose)]",bg:"bg-[var(--color-rose)]/10"},init:{icon:"⚡",color:"text-[var(--color-violet)]",bg:"bg-[var(--color-violet)]/10"},complete:{icon:"✓",color:"text-[var(--color-emerald)]",bg:"bg-[var(--color-emerald)]/10"},session_start:{icon:"▶",color:"text-[var(--color-amber)]",bg:"bg-[var(--color-amber)]/10"},status:{icon:"◉",color:"text-[var(--color-amber)]",bg:"bg-[var(--color-amber)]/10"}};function xk({event:t,isExpanded:s,isLive:o,onToggle:l}){const i=wh[t.event_type]||wh.text,d=vk(t,40),u=wk(t),h=p.useRef(null),x=Vh(t.timestamp);return p.useEffect(()=>{s&&h.current&&setTimeout(()=>{var g;(g=h.current)==null||g.scrollIntoView({behavior:"smooth",block:"nearest"})},50)},[s]),e.jsxs("div",{children:[e.jsxs("button",{onClick:u?l:void 0,className:`flex items-center gap-2 w-full py-1.5 px-2 rounded text-sm transition-colors ${u?"hover:bg-[var(--color-elevated)] cursor-pointer":"cursor-default"}`,children:[u&&e.jsx("svg",{className:`w-3 h-3 text-[var(--color-text-muted)] transition-transform duration-200 ${s?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),!u&&e.jsx("span",{className:"w-3"}),e.jsx("span",{className:`w-5 h-5 rounded flex items-center justify-center text-xs ${i.bg}`,children:i.icon}),e.jsx("span",{className:`font-mono text-xs ${i.color} truncate flex-1 text-left`,children:t.tool_name||pl(d,35)}),e.jsx("span",{className:"font-mono text-xs text-[var(--color-text-muted)]",children:x}),o&&e.jsx("span",{className:"status-dot status-dot-running ml-1"})]}),u&&e.jsx("div",{ref:h,className:`overflow-hidden transition-all duration-200 ${s?"max-h-96 opacity-100":"max-h-0 opacity-0"}`,children:e.jsx("div",{className:"ml-8 mr-2 mb-2 p-3 bg-[var(--color-deep)] rounded-lg border border-[var(--color-border)]",children:e.jsx(yk,{event:t})})})]})}function fk({content:t}){const s=t.match(/```json\s*([\s\S]*?)```/);if(s){const o=t.slice(0,s.index).trim(),l=s[1].trim(),i=t.slice((s.index||0)+s[0].length).trim();let d=null;try{d=JSON.parse(l)}catch{}const u=d&&typeof d=="object"&&"stories"in d;return e.jsxs("div",{className:"space-y-3",children:[o&&e.jsx("p",{className:"text-sm text-[var(--color-text-secondary)]",children:o}),u?e.jsx(gk,{stories:d.stories}):d?e.jsx("div",{className:"p-3 bg-[var(--color-void)] rounded-lg border border-[var(--color-border)]",children:e.jsx("pre",{className:"text-xs font-mono text-[var(--color-text-secondary)] overflow-auto max-h-48 custom-scrollbar",children:JSON.stringify(d,null,2)})}):e.jsx("div",{className:"p-3 bg-[var(--color-void)] rounded-lg border border-[var(--color-border)]",children:e.jsx("pre",{className:"text-xs font-mono text-[var(--color-text-secondary)] overflow-auto max-h-48 custom-scrollbar whitespace-pre-wrap",children:l})}),i&&e.jsx("p",{className:"text-sm text-[var(--color-text-secondary)]",children:i})]})}return e.jsx("p",{className:"text-sm text-[var(--color-text-secondary)] whitespace-pre-wrap",children:t})}function gk({stories:t}){const[s,o]=p.useState(!1),l=s?t:t.slice(0,2),i=t.length>2;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-mono text-[var(--color-emerald)] uppercase tracking-wider",children:[t.length," User ",t.length===1?"Story":"Stories"]}),i&&e.jsx("button",{onClick:()=>o(!s),className:"text-xs text-[var(--color-cyan)] hover:underline",children:s?"Show less":`Show all ${t.length}`})]}),e.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto custom-scrollbar",children:l.map((d,u)=>e.jsx("div",{className:"p-3 bg-[var(--color-void)] rounded-lg border border-[var(--color-border)]",children:e.jsxs("div",{className:"flex items-start gap-2",children:[d.id&&e.jsx("span",{className:"px-1.5 py-0.5 text-xs font-mono bg-[var(--color-cyan)]/20 text-[var(--color-cyan)] rounded",children:d.id}),e.jsxs("div",{className:"flex-1 min-w-0",children:[d.title&&e.jsx("div",{className:"font-medium text-sm text-[var(--color-text-primary)] mb-1",children:d.title}),d.content&&e.jsx("p",{className:"text-xs text-[var(--color-text-secondary)] line-clamp-2",children:d.content})]})]})},d.id||u))})]})}function yk({event:t}){const[s,o]=p.useState(!0);switch(t.event_type){case"text":return e.jsx(fk,{content:t.content||""});case"tool_call":return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"font-mono text-sm font-semibold text-[var(--color-cyan)]",children:t.tool_name})}),t.tool_input&&e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>o(!s),className:"flex items-center gap-1 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] transition-colors",children:[e.jsx("svg",{className:`w-3 h-3 transition-transform ${s?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),s?"Hide":"Show"," Input"]}),s&&e.jsx("pre",{className:"mt-2 p-2 bg-[var(--color-void)] rounded text-xs font-mono overflow-auto max-h-48 text-[var(--color-text-secondary)] custom-scrollbar",children:JSON.stringify(t.tool_input,null,2)})]})]});case"tool_result":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"font-mono text-sm font-semibold text-[var(--color-emerald)]",children:[t.tool_name," → result"]}),e.jsx("pre",{className:"p-2 bg-[var(--color-void)] rounded text-xs font-mono overflow-auto max-h-48 text-[var(--color-text-secondary)] custom-scrollbar whitespace-pre-wrap",children:pl(t.tool_result||"",1e3)})]});case"error":return e.jsx("div",{className:"text-[var(--color-rose)] text-sm font-mono",children:t.error_message||"Unknown error"});default:return e.jsx("pre",{className:"text-xs font-mono text-[var(--color-text-muted)] overflow-auto max-h-48 custom-scrollbar",children:JSON.stringify(t,null,2)})}}function vk(t,s){return t.tool_name?t.tool_name:t.content?pl(t.content.replace(/\n/g," "),s):t.error_message?pl(t.error_message,s):t.event_type}function pl(t,s){return t?t.length<=s?t:t.slice(0,s)+"...":""}function wk(t){return!!(t.event_type==="text"&&t.content&&t.content.length>40||t.event_type==="tool_call"&&t.tool_input||t.event_type==="tool_result"&&t.tool_result||t.event_type==="error"&&t.error_message)}function bk(){var X,ee;const{slug:t,workflowId:s,stepNumber:o}=yr(),l=ir(),[i,d]=p.useState(null),[u,h]=p.useState(!0),[x,g]=p.useState(null),[v,y]=p.useState(!1),[b,k]=p.useState("overview"),_=o?parseInt(o,10):null,S=p.useCallback(async()=>{if(!(!t||!s))try{const W=await Po(t,s);d(W),g(null)}catch(W){g(W instanceof Error?W.message:"Failed to load workflow")}finally{h(!1)}},[t,s]);p.useEffect(()=>{S()},[S]),p.useEffect(()=>{var D;if(!i)return;const W=(D=i.steps)==null?void 0:D.find(R=>R.step_number===_);if(!(W!=null&&W.has_active_run))return;const te=setInterval(S,2e3);return()=>clearInterval(te)},[i,_,S]);const N=((i==null?void 0:i.steps)||[]).find(W=>W.step_number===_);p.useEffect(()=>{!u&&i&&!N&&l(`/projects/${t}/workflows/${s}`,{replace:!0})},[u,i,N,l,t,s]),p.useEffect(()=>{N!=null&&N.archived_at&&l(`/projects/${t}/workflows/${s}`,{replace:!0})},[N,l,t,s]);const T=async()=>{if(!t||!s||!_)return;const W=(N==null?void 0:N.name)||`Step ${_}`;if((await rt.fire({title:"Run Ralph Loop?",text:`Start executing "${W}"?`,icon:"question",showCancelButton:!0,confirmButtonColor:"var(--color-primary)",cancelButtonColor:"var(--color-slate)",confirmButtonText:"Run Ralph Loop",cancelButtonText:"Cancel",background:"var(--color-surface)",color:"var(--color-text-primary)"})).isConfirmed){y(!0);try{const D=await Wh(t,s,_);d(D)}catch(D){g(D instanceof Error?D.message:"Failed to run step")}finally{y(!1)}}},P=async()=>{if(!(!t||!s||!(await rt.fire({title:"Stop Step?",text:"This will stop the current execution. You can resume later.",icon:"warning",showCancelButton:!0,confirmButtonColor:"var(--color-rose)",cancelButtonColor:"var(--color-slate)",confirmButtonText:"Stop",cancelButtonText:"Cancel",background:"var(--color-surface)",color:"var(--color-text-primary)"})).isConfirmed)){y(!0);try{const te=await Fh(t,s);d(te)}catch(te){g(te instanceof Error?te.message:"Failed to stop step")}finally{y(!1)}}},C=async(W=!1)=>{if(!(!t||!s)){y(!0);try{const te=await zv(t,s,{skip_current:W});d(te)}catch(te){g(te instanceof Error?te.message:"Failed to advance workflow")}finally{y(!1)}}};if(u)return e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-4 w-64 bg-[var(--color-elevated)] rounded"}),e.jsx("div",{className:"h-8 w-96 bg-[var(--color-elevated)] rounded"}),e.jsx("div",{className:"h-64 bg-[var(--color-elevated)] rounded"})]})});if(x&&!i)return e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"card bg-red-900/20 border border-red-800",children:[e.jsx("h2",{className:"text-lg font-semibold text-red-400 mb-2",children:"Error"}),e.jsx("p",{className:"text-gray-300",children:x}),e.jsx(Se,{to:`/projects/${t}/workflows/${s}`,className:"btn-secondary mt-4 inline-block",children:"Back to Workflow"})]})});if(!i||!N)return null;const E=N.step_type==="interactive",I=N.step_type==="autonomous",M=N.has_active_run===!0,q=N.step_number===i.current_step&&N.status==="active",z=N.items_generated||0,U=()=>{if(M)return"bg-green-600";switch(N.status){case"completed":return"bg-blue-600";case"active":return"bg-amber-600";case"skipped":return"bg-gray-600";default:return"bg-gray-600"}},O=()=>{if(M)return"Running";switch(N.status){case"completed":return"Completed";case"active":return"Active";case"skipped":return"Skipped";default:return"Pending"}};return e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[e.jsxs(Se,{to:`/projects/${t}/workflows/${s}`,className:"flex items-center gap-1 hover:text-white transition-colors",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),"Back to Workflow"]}),e.jsx("span",{children:"/"}),e.jsx(Se,{to:"/",className:"hover:text-white",children:"Dashboard"}),e.jsx("span",{children:"/"}),e.jsx(Se,{to:`/projects/${t}`,className:"hover:text-white",children:t}),e.jsx("span",{children:"/"}),e.jsx(Se,{to:`/projects/${t}/workflows/${s}`,className:"hover:text-white",children:i.name}),e.jsx("span",{children:"/"}),e.jsxs("span",{className:"text-white",children:["Step ",N.step_number]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsxs("h1",{className:"text-2xl font-bold text-white",children:["Step ",N.step_number,": ",N.name]}),e.jsx("span",{className:`px-3 py-1 rounded-full text-sm font-medium text-white ${U()}`,children:O()}),e.jsx("span",{className:"px-2 py-1 text-xs font-medium bg-[var(--color-elevated)] text-[var(--color-text-muted)] rounded",children:E?"Chat":"Auto"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[!M&&i.status!=="completed"&&e.jsxs("button",{onClick:T,disabled:v,className:"flex items-center space-x-2 px-4 py-2 bg-green-600 text-white rounded hover:bg-green-500 transition-colors disabled:opacity-50",children:[e.jsxs("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})]}),e.jsx("span",{children:"Run"})]}),M&&e.jsxs("button",{onClick:P,disabled:v,className:"flex items-center space-x-2 px-4 py-2 bg-red-600 text-white rounded hover:bg-red-500 transition-colors disabled:opacity-50",children:[e.jsxs("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 10a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z"})]}),e.jsx("span",{children:"Stop"})]}),e.jsxs("button",{onClick:()=>l(`/projects/${t}/workflows/${s}/edit`),className:"flex items-center space-x-2 px-4 py-2 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 transition-colors",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})}),e.jsx("span",{children:"Edit"})]})]})]}),((X=N.config)==null?void 0:X.description)&&e.jsx("p",{className:"mt-2 text-gray-400",children:N.config.description})]}),x&&i&&e.jsx("div",{className:"mb-6 p-4 rounded-lg bg-red-900/20 border border-red-800",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-red-400 text-sm",children:x}),e.jsx("button",{onClick:()=>g(null),className:"text-red-400 hover:text-red-300","aria-label":"Dismiss error",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),e.jsxs("div",{className:"flex border-b border-[var(--color-border)] mb-6",children:[e.jsxs("button",{onClick:()=>k("overview"),className:`px-4 py-3 text-sm font-medium transition-colors relative
222
- ${b==="overview"?"text-cyan-400":"text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)]"}`,children:["Overview",b==="overview"&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-cyan-500"})]}),I&&e.jsxs("button",{onClick:()=>k("logs"),className:`px-4 py-3 text-sm font-medium transition-colors relative
223
- ${b==="logs"?"text-cyan-400":"text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)]"}`,children:["Logs",M&&e.jsx("span",{className:"ml-2 w-2 h-2 bg-green-500 rounded-full inline-block animate-pulse"}),b==="logs"&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-cyan-500"})]}),e.jsxs("button",{onClick:()=>k("items"),className:`px-4 py-3 text-sm font-medium transition-colors relative flex items-center gap-2
224
- ${b==="items"?"text-cyan-400":"text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)]"}`,children:["Items",z>0&&e.jsx("span",{className:"px-1.5 py-0.5 text-xs rounded-full bg-cyan-500/20 text-cyan-400",children:z}),b==="items"&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-cyan-500"})]})]}),b==="overview"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Step Configuration"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wide mb-1",children:"Type"}),e.jsx("div",{className:"text-[var(--color-text-primary)]",children:E?"Interactive (Chat)":"Autonomous (Auto)"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wide mb-1",children:"Status"}),e.jsx("div",{className:"text-[var(--color-text-primary)]",children:O()})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wide mb-1",children:"Iterations"}),e.jsx("div",{className:"text-[var(--color-text-primary)]",children:N.iterations_completed||0})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wide mb-1",children:"Items Generated"}),e.jsx("div",{className:"text-[var(--color-text-primary)]",children:z})]})]}),q&&((ee=N.config)==null?void 0:ee.skippable)&&e.jsx("div",{className:"mt-4 pt-4 border-t border-[var(--color-border)]",children:e.jsx("button",{onClick:()=>C(!0),disabled:v,className:"text-sm text-gray-400 hover:text-white transition-colors",children:"Skip this step"})})]}),E&&q&&e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Planning Chat"}),e.jsx(ak,{projectSlug:t,workflowId:s,onComplete:S})]}),E&&!q&&e.jsxs("div",{className:"card text-center py-8",children:[N.status==="pending"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-gray-800 flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsx("p",{className:"text-gray-400",children:"This step hasn't started yet."})]}),N.status==="completed"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-green-900/30 flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("p",{className:"text-green-400",children:"Step completed!"})]})]}),I&&N.loop_name&&e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-white",children:"Session Logs"}),e.jsx("button",{onClick:()=>k("logs"),className:"text-sm text-cyan-400 hover:text-cyan-300 transition-colors",children:"View Full Logs"})]}),e.jsx(vh,{projectSlug:t,loopName:N.loop_name,enabled:!0})]}),I&&!N.loop_name&&N.status==="pending"&&e.jsxs("div",{className:"card text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-gray-800 flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})})}),e.jsx("p",{className:"text-gray-400",children:"This autonomous step hasn't been configured yet."}),e.jsx("p",{className:"text-gray-500 text-sm mt-2",children:"Run the step to initialize it."})]})]}),b==="logs"&&I&&e.jsx("div",{className:"card",children:N.loop_name?e.jsx(vh,{projectSlug:t,loopName:N.loop_name,enabled:!0}):e.jsxs("div",{className:"text-center py-12 text-gray-400",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-3 rounded-full bg-gray-800 flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),e.jsx("p",{children:"No executions yet"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Run the step to see logs here"})]})}),b==="items"&&e.jsx("div",{className:"card",children:e.jsx(Px,{projectSlug:t,workflowId:s,sourceStepId:N.id,steps:(i==null?void 0:i.steps)||[],onImported:()=>S()})})]})}function jk(){var C,E,I;const{slug:t}=yr(),{selectedProject:s,setSelectedProject:o}=Tr(),[l,i]=p.useState([]),[d,u]=p.useState(null),[h,x]=p.useState(!0),[g,v]=p.useState(null),y=p.useCallback(async()=>{if(t){x(!0),v(null);try{const[M,q,z]=await Promise.all([Vs(t),Za(t),iv(t)]);o(M),i(q),u(z)}catch(M){v(M instanceof Error?M.message:"Failed to load dashboard")}finally{x(!1)}}},[t,o]);if(p.useEffect(()=>{y()},[y]),h)return e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"text-gray-400",children:"Loading dashboard..."})});if(g)return e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"card bg-red-900/20 border border-red-800",children:[e.jsx("h2",{className:"text-lg font-semibold text-red-400 mb-2",children:"Error"}),e.jsx("p",{className:"text-gray-300",children:g}),e.jsx(Se,{to:"/",className:"btn-secondary mt-4 inline-block",children:"Back to Dashboard"})]})});const b=l.map(M=>({id:M.id,name:M.name,status:M.status,current_step:M.current_step,total_steps:M.steps.length,progress:M.steps.length>0?Math.round(M.steps.filter(q=>q.status==="completed").length/M.steps.length*100):0})),k=b.filter(M=>M.status==="active"||M.status==="draft"||M.status==="paused"),_=b.filter(M=>M.status==="completed"),S=(d==null?void 0:d.total)||0,j=((C=d==null?void 0:d.by_status)==null?void 0:C.completed)||0,N=((E=d==null?void 0:d.by_status)==null?void 0:E.in_progress)||0,T=((I=d==null?void 0:d.by_status)==null?void 0:I.pending)||0,P=S>0?Math.round(j/S*100):0;return e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[e.jsx(Se,{to:"/",className:"hover:text-white",children:"Dashboard"}),e.jsx("span",{children:"/"}),e.jsx(Se,{to:`/projects/${t}`,className:"hover:text-white",children:(s==null?void 0:s.name)||t}),e.jsx("span",{children:"/"}),e.jsx("span",{className:"text-white",children:"Project Dashboard"})]}),e.jsxs("div",{className:"flex items-center justify-between mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-white mb-2",children:"Project Dashboard"}),e.jsx("p",{className:"text-gray-400",children:"Cross-workflow visibility and progress tracking"})]}),e.jsxs(Se,{to:`/projects/${t}`,className:"flex items-center space-x-2 px-4 py-2 bg-gray-700 text-gray-300 rounded hover:bg-gray-600",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"})}),e.jsx("span",{children:"Workflows View"})]})]}),e.jsxs("div",{className:"card mb-8",children:[e.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Overall Progress"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4 mb-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-primary-400",children:l.length}),e.jsx("div",{className:"text-sm text-gray-400",children:"Total Workflows"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-green-400",children:k.length}),e.jsx("div",{className:"text-sm text-gray-400",children:"Active"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-blue-400",children:_.length}),e.jsx("div",{className:"text-sm text-gray-400",children:"Completed"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-yellow-400",children:S}),e.jsx("div",{className:"text-sm text-gray-400",children:"Total Items"})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"text-3xl font-bold text-white",children:[P,"%"]}),e.jsx("div",{className:"text-sm text-gray-400",children:"Items Complete"})]})]}),e.jsx("div",{className:"w-full bg-gray-700 rounded-full h-3",children:e.jsx("div",{className:"bg-gradient-to-r from-primary-600 to-green-500 h-3 rounded-full transition-all duration-500",style:{width:`${P}%`}})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mb-8",children:[e.jsxs("div",{className:"card",children:[e.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Item Status"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-gray-300",children:"Completed"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"w-32 bg-gray-700 rounded-full h-2",children:e.jsx("div",{className:"bg-green-500 h-2 rounded-full",style:{width:`${S>0?j/S*100:0}%`}})}),e.jsx("span",{className:"text-green-400 w-12 text-right",children:j})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-gray-300",children:"In Progress"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"w-32 bg-gray-700 rounded-full h-2",children:e.jsx("div",{className:"bg-yellow-500 h-2 rounded-full",style:{width:`${S>0?N/S*100:0}%`}})}),e.jsx("span",{className:"text-yellow-400 w-12 text-right",children:N})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-gray-300",children:"Pending"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"w-32 bg-gray-700 rounded-full h-2",children:e.jsx("div",{className:"bg-gray-500 h-2 rounded-full",style:{width:`${S>0?T/S*100:0}%`}})}),e.jsx("span",{className:"text-gray-400 w-12 text-right",children:T})]})]})]})]}),e.jsxs("div",{className:"card",children:[e.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Items by Category"}),d!=null&&d.by_category&&Object.keys(d.by_category).length>0?e.jsx("div",{className:"space-y-2",children:Object.entries(d.by_category).sort(([,M],[,q])=>q-M).slice(0,6).map(([M,q])=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-gray-300 text-sm font-mono",children:M||"Uncategorized"}),e.jsx("span",{className:"text-primary-400",children:q})]},M))}):e.jsx("p",{className:"text-gray-500 text-sm",children:"No categories yet"})]})]}),e.jsxs("div",{className:"card",children:[e.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Workflow Progress"}),l.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-gray-400",children:"No workflows yet"}),e.jsx(Se,{to:`/projects/${t}`,className:"text-primary-400 hover:text-primary-300 text-sm mt-2 inline-block",children:"Create your first workflow"})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-sm text-gray-400 border-b border-gray-700",children:[e.jsx("th",{className:"pb-3 pr-4",children:"Workflow"}),e.jsx("th",{className:"pb-3 pr-4",children:"Status"}),e.jsx("th",{className:"pb-3 pr-4",children:"Step"}),e.jsx("th",{className:"pb-3 pr-4",children:"Progress"}),e.jsx("th",{className:"pb-3"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-700",children:b.map(M=>e.jsxs("tr",{className:"hover:bg-gray-800/50",children:[e.jsx("td",{className:"py-3 pr-4",children:e.jsx(Se,{to:`/projects/${t}/workflows/${M.id}`,className:"text-white hover:text-primary-400 font-medium",children:M.name})}),e.jsx("td",{className:"py-3 pr-4",children:e.jsx("span",{className:`px-2 py-1 text-xs rounded ${M.status==="completed"?"bg-green-900/30 text-green-400":M.status==="active"?"bg-blue-900/30 text-blue-400":"bg-gray-700 text-gray-400"}`,children:M.status})}),e.jsxs("td",{className:"py-3 pr-4 text-gray-400 text-sm",children:[M.current_step," / ",M.total_steps]}),e.jsx("td",{className:"py-3 pr-4",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"w-24 bg-gray-700 rounded-full h-2",children:e.jsx("div",{className:`h-2 rounded-full ${M.status==="completed"?"bg-green-500":"bg-primary-500"}`,style:{width:`${M.progress}%`}})}),e.jsxs("span",{className:"text-sm text-gray-400",children:[M.progress,"%"]})]})}),e.jsx("td",{className:"py-3 text-right",children:e.jsx(Se,{to:`/projects/${t}/workflows/${M.id}`,className:"text-primary-400 hover:text-primary-300 text-sm",children:"View"})})]},M.id))})]})})]})]})}function ht({title:t,description:s,prompt:o,variant:l="primary"}){const[i,d]=p.useState(!1),[u,h]=p.useState(!1),x=async()=>{await navigator.clipboard.writeText(o),d(!0),setTimeout(()=>d(!1),2e3)},g=l==="primary"?"border-cyan-500/30 hover:border-cyan-500/50":"border-violet-500/30 hover:border-violet-500/50",v=l==="primary"?"bg-cyan-500/10":"bg-violet-500/10";return e.jsxs("div",{className:`rounded-lg border ${g} overflow-hidden transition-colors`,children:[e.jsxs("div",{className:`${v} px-4 py-3 flex items-center justify-between`,children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("svg",{className:"w-4 h-4 text-cyan-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),e.jsx("span",{className:"text-sm font-medium text-gray-200",children:t})]}),e.jsx("button",{onClick:x,className:`flex items-center space-x-1.5 px-3 py-1.5 rounded text-xs font-medium transition-all ${i?"bg-emerald-500/20 text-emerald-400 border border-emerald-500/30":"bg-gray-700/50 text-gray-300 hover:bg-gray-600/50 border border-gray-600"}`,children:i?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{children:"Copied!"})]}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})}),e.jsx("span",{children:"Copy"})]})})]}),e.jsx("div",{className:"bg-gray-900/70 p-4",children:e.jsx("pre",{className:"text-sm text-gray-300 font-mono whitespace-pre-wrap leading-relaxed",children:o})}),s&&e.jsxs("div",{className:"border-t border-gray-700/50",children:[e.jsxs("button",{onClick:()=>h(!u),className:"w-full px-4 py-2 flex items-center justify-between text-xs text-gray-500 hover:text-gray-400 hover:bg-gray-800/30 transition-colors",children:[e.jsx("span",{children:"What this does"}),e.jsx("svg",{className:`w-4 h-4 transition-transform ${u?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),u&&e.jsx("div",{className:"px-4 pb-3 text-sm text-gray-400",children:s})]})]})}function tt({icon:t,title:s,description:o,children:l,id:i}){return e.jsxs("section",{id:i,className:"mb-10",children:[e.jsxs("div",{className:"flex items-start space-x-3 mb-4",children:[e.jsx("div",{className:"p-2 rounded-lg bg-cyan-500/10 text-cyan-400 mt-0.5",children:t}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-white",children:s}),o&&e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:o})]})]}),e.jsx("div",{className:"ml-12",children:l})]})}function Qa({steps:t}){return e.jsx("div",{className:"space-y-4",children:t.map((s,o)=>e.jsxs("div",{className:"flex space-x-4",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-cyan-500/20 border border-cyan-500/30 flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-semibold text-cyan-400",children:o+1})}),e.jsxs("div",{className:"flex-1 pt-1",children:[e.jsx("h4",{className:"text-sm font-medium text-white mb-1",children:s.title}),e.jsx("div",{className:"text-sm text-gray-400",children:s.description})]})]},o))})}function Os({icon:t,title:s,description:o,color:l="cyan"}){const d={cyan:{bg:"bg-cyan-500/10",border:"border-cyan-500/20 hover:border-cyan-500/40",iconBg:"bg-cyan-500/20",iconText:"text-cyan-400"},emerald:{bg:"bg-emerald-500/10",border:"border-emerald-500/20 hover:border-emerald-500/40",iconBg:"bg-emerald-500/20",iconText:"text-emerald-400"},amber:{bg:"bg-amber-500/10",border:"border-amber-500/20 hover:border-amber-500/40",iconBg:"bg-amber-500/20",iconText:"text-amber-400"},violet:{bg:"bg-violet-500/10",border:"border-violet-500/20 hover:border-violet-500/40",iconBg:"bg-violet-500/20",iconText:"text-violet-400"}}[l];return e.jsxs("div",{className:`rounded-lg border ${d.border} ${d.bg} p-4 transition-colors`,children:[e.jsx("div",{className:`w-10 h-10 rounded-lg ${d.iconBg} ${d.iconText} flex items-center justify-center mb-3`,children:t}),e.jsx("h3",{className:"text-sm font-semibold text-white mb-1",children:s}),e.jsx("p",{className:"text-xs text-gray-400 leading-relaxed",children:o})]})}function Wr({question:t,children:s,defaultOpen:o=!1}){const[l,i]=p.useState(o);return e.jsxs("div",{className:"border border-gray-700/50 rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>i(!l),className:"w-full px-4 py-3 flex items-center justify-between text-left bg-gray-800/30 hover:bg-gray-800/50 transition-colors",children:[e.jsx("span",{className:"text-sm font-medium text-gray-200",children:t}),e.jsx("svg",{className:`w-5 h-5 text-gray-500 transition-transform ${l?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),l&&e.jsx("div",{className:"px-4 py-3 text-sm text-gray-400 border-t border-gray-700/50 bg-gray-900/30",children:s})]})}function bh(){return e.jsxs("div",{className:"space-y-8",children:[e.jsx(tt,{id:"claude-code",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),title:"What is Claude Code?",description:"Understanding the tool that powers your RalphX workflows",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-gray-300",children:[e.jsx("strong",{className:"text-white",children:"Claude Code"})," is a command-line assistant that can read and write files, run commands, and help you build software. It's like having an expert developer available in your terminal."]}),e.jsxs("div",{className:"bg-gray-800/50 rounded-lg p-4 border border-gray-700/50",children:[e.jsx("h4",{className:"text-sm font-medium text-white mb-3",children:"How to install"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-400 mb-1",children:"macOS / Linux / WSL:"}),e.jsx("div",{className:"bg-gray-900 rounded p-3 font-mono text-sm text-cyan-400",children:"curl -fsSL https://claude.ai/install.sh | bash"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-400 mb-1",children:"Windows (PowerShell):"}),e.jsx("div",{className:"bg-gray-900 rounded p-3 font-mono text-sm text-cyan-400",children:"irm https://claude.ai/install.ps1 | iex"})]})]}),e.jsxs("p",{className:"text-xs text-gray-500 mt-3",children:["Visit"," ",e.jsx("a",{href:"https://code.claude.com/docs/en/setup",target:"_blank",rel:"noopener noreferrer",className:"text-cyan-400 hover:underline",children:"Claude Code documentation"})," ","for more options including Homebrew and WinGet."]})]}),e.jsx(Qa,{steps:[{title:"Open your terminal",description:'On Mac: Press Cmd+Space, type "Terminal", press Enter. On Windows: Press Win+R, type "cmd", press Enter.'},{title:'Type "claude" and press Enter',description:"This starts Claude Code. You'll see a prompt where you can type or paste commands."},{title:"Copy a prompt from this wiki",description:'Click the "Copy" button on any prompt block below.'},{title:"Paste into Claude Code",description:"Press Ctrl+V (or Cmd+V on Mac) to paste, then press Enter. Claude will handle the rest!"}]})]})}),e.jsx(tt,{id:"concepts",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19.428 15.428a2 2 0 00-1.022-.547l-2.387-.477a6 6 0 00-3.86.517l-.318.158a6 6 0 01-3.86.517L6.05 15.21a2 2 0 00-1.806.547M8 4h8l-1 1v5.172a2 2 0 00.586 1.414l5 5c1.26 1.26.367 3.414-1.415 3.414H4.828c-1.782 0-2.674-2.154-1.414-3.414l5-5A2 2 0 009 10.172V5L8 4z"})}),title:"Key Concepts",description:"The building blocks of RalphX",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Os,{icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),title:"Project",description:"A folder on your computer that contains code you want to work on. Each project can have multiple workflows.",color:"cyan"}),e.jsx(Os,{icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),title:"Workflow",description:"A sequence of steps to accomplish something. Workflows can plan features, implement code, research topics, or generate docs.",color:"emerald"}),e.jsx(Os,{icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})}),title:"Step",description:"One stage in a workflow. For example: 'Generate user stories', then 'Review and prioritize', then 'Implement features'.",color:"amber"}),e.jsx(Os,{icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),title:"Work Item",description:"A specific task to complete. Could be a user story, bug fix, or any unit of work that Claude will tackle.",color:"violet"})]})}),e.jsx(tt,{id:"first-workflow",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),title:"Your First Workflow",description:"Create a workflow in seconds with this prompt",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-gray-400 text-sm",children:"Copy this prompt and paste it into Claude Code. It will ask you a few questions, then set everything up automatically."}),e.jsx(ht,{title:"Create your first workflow",description:"This prompt guides you through creating a project and workflow by asking what you want to build and what type of workflow you need.",prompt:`Help me set up my first RalphX workflow. Ask me:
225
- 1. What project folder should we use?
226
- 2. What do I want to build or accomplish?
227
- 3. Should this be a planning workflow (generate tasks) or implementation workflow (build features)?
228
-
229
- Then create the project and workflow for me.`})]})})]})}function Nk(){return e.jsxs("div",{className:"space-y-8",children:[e.jsx(tt,{id:"planning",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01"})}),title:"Planning Workflow",description:"Generate user stories and break down complex projects",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-gray-400 text-sm",children:"Use a planning workflow when you have an idea but need to break it down into actionable tasks. Claude will analyze your requirements and generate a prioritized list of user stories."}),e.jsx(ht,{title:"Create a planning workflow",description:"Sets up a workflow that will generate user stories and break down your project into manageable tasks.",prompt:`Help me create a planning workflow in RalphX. Ask me what I want
230
- to build, then set up a workflow that will generate user stories
231
- and break down the work into manageable tasks.`}),e.jsxs("div",{className:"text-xs text-gray-500",children:[e.jsx("strong",{children:"Best for:"})," New features, product ideas, project kickoffs"]})]})}),e.jsx(tt,{id:"implementation",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),title:"Implementation Workflow",description:"Write code and build features automatically",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-gray-400 text-sm",children:"Use an implementation workflow when you have tasks ready and want Claude to build them. It will work through each item, writing code and committing changes."}),e.jsx(ht,{title:"Create an implementation workflow",description:"Sets up a workflow that will implement your tasks one by one, writing code and committing as it goes.",prompt:`Help me create an implementation workflow in RalphX. I have user
232
- stories/tasks ready. Set up a workflow that will implement them
233
- one by one, committing code as it goes.`}),e.jsxs("div",{className:"text-xs text-gray-500",children:[e.jsx("strong",{children:"Best for:"})," Building features, fixing bugs, code improvements"]})]})}),e.jsx(tt,{id:"research",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),title:"Research Workflow",description:"Investigate topics and gather information",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-gray-400 text-sm",children:"Use a research workflow when you need to explore a topic, compare options, or gather information before making decisions."}),e.jsx(ht,{title:"Create a research workflow",description:"Sets up a workflow that will investigate a topic and summarize findings.",prompt:`Help me create a research workflow in RalphX. Ask me what topic
234
- I want to research, then set up a workflow that will investigate
235
- it and summarize findings.`}),e.jsxs("div",{className:"text-xs text-gray-500",children:[e.jsx("strong",{children:"Best for:"})," Technology comparisons, library selection, architecture decisions"]})]})}),e.jsx(tt,{id:"documentation",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),title:"Documentation Workflow",description:"Generate docs for your code automatically",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-gray-400 text-sm",children:"Use a documentation workflow to generate READMEs, API docs, or any other documentation your project needs."}),e.jsx(ht,{title:"Create a documentation workflow",description:"Sets up a workflow to analyze your code and generate documentation.",prompt:`Help me create a documentation workflow in RalphX. Ask me what
236
- code/project needs documentation, then set up a workflow to
237
- generate docs automatically.`}),e.jsxs("div",{className:"text-xs text-gray-500",children:[e.jsx("strong",{children:"Best for:"})," README files, API documentation, code comments"]})]})}),e.jsx(tt,{id:"custom",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4"})}),title:"Custom Workflow",description:"Design a workflow for your specific needs",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-gray-400 text-sm",children:"Not sure what type of workflow you need? Describe what you want to accomplish and Claude will help design the right workflow for you."}),e.jsx(ht,{title:"Create a custom workflow",description:"Describes your goal and lets Claude design the appropriate workflow.",prompt:`Help me create a custom RalphX workflow. Here's what I want to
238
- accomplish: [describe your goal here]
239
-
240
- Help me figure out what steps and work items would make sense,
241
- then create the workflow.`,variant:"secondary"})]})})]})}function kk(){return e.jsxs("div",{className:"space-y-8",children:[e.jsx(tt,{id:"dashboard",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 5a1 1 0 011-1h14a1 1 0 011 1v2a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM4 13a1 1 0 011-1h6a1 1 0 011 1v6a1 1 0 01-1 1H5a1 1 0 01-1-1v-6zM16 13a1 1 0 011-1h2a1 1 0 011 1v6a1 1 0 01-1 1h-2a1 1 0 01-1-1v-6z"})}),title:"Understanding the Dashboard",description:"What the different parts of RalphX show you",children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"bg-gray-800/30 rounded-lg p-4 border border-gray-700/50",children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-emerald-400 animate-pulse"}),e.jsx("span",{className:"text-sm font-medium text-white",children:"Active Workflow"})]}),e.jsx("p",{className:"text-xs text-gray-400",children:"A green pulsing dot means the workflow is currently running. Claude is actively working on tasks."})]}),e.jsxs("div",{className:"bg-gray-800/30 rounded-lg p-4 border border-gray-700/50",children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-amber-400"}),e.jsx("span",{className:"text-sm font-medium text-white",children:"Paused Workflow"})]}),e.jsx("p",{className:"text-xs text-gray-400",children:"An amber dot means the workflow is paused. It's waiting for you to resume or make changes."})]}),e.jsxs("div",{className:"bg-gray-800/30 rounded-lg p-4 border border-gray-700/50",children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-gray-500"}),e.jsx("span",{className:"text-sm font-medium text-white",children:"Completed/Draft"})]}),e.jsx("p",{className:"text-xs text-gray-400",children:"A gray dot means the workflow is either complete or still in draft mode (not yet started)."})]})]})})}),e.jsx(tt,{id:"management",icon:e.jsxs("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),title:"Managing Workflows",description:"Control your running workflows",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(ht,{title:"Stop a workflow",description:"Gracefully stops the currently running workflow, finishing any in-progress task.",prompt:"Stop my currently running RalphX workflow gracefully."}),e.jsx(ht,{title:"Pause and review",description:"Pauses the workflow so you can review what's been done before continuing.",prompt:"Pause the workflow so I can review progress, then resume when ready."}),e.jsx(ht,{title:"Check progress",description:"Shows what the workflow has accomplished so far.",prompt:`Show me what my workflow has accomplished so far - list the
242
- work items and their status.`}),e.jsx(ht,{title:"Delete a workflow",description:"Removes a workflow (will ask for confirmation first).",prompt:"Delete the workflow named [X] - ask me to confirm first.",variant:"secondary"})]})}),e.jsx(tt,{id:"troubleshooting",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),title:"Troubleshooting",description:"Fix common issues",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(ht,{title:"Diagnose a stuck workflow",description:"Checks logs and status to figure out why a workflow isn't progressing.",prompt:`My RalphX workflow seems stuck. Help me diagnose what's wrong
243
- by checking the logs and status.`}),e.jsx(ht,{title:"Handle a failed work item",description:"Investigates why a task failed and helps you retry or skip it.",prompt:`A work item failed. Help me understand why and either retry it
244
- or skip it.`}),e.jsx(ht,{title:"RalphX won't start",description:"Checks dependencies and configuration to fix startup issues.",prompt:`RalphX isn't starting properly. Help me troubleshoot the issue
245
- by checking if all dependencies are installed and the server can start.`})]})}),e.jsx(tt,{id:"faq",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),title:"Frequently Asked Questions",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(Wr,{question:"Can I run multiple workflows at once?",children:"Yes! Each workflow runs independently. You can have a planning workflow for one feature while an implementation workflow builds another."}),e.jsx(Wr,{question:"What happens if I close my browser?",children:"RalphX continues running in the background (as long as the terminal running ./dev.sh stays open). When you come back, you'll see the current state of all workflows."}),e.jsx(Wr,{question:"Can I edit work items while a workflow is running?",children:"Yes, but be careful - editing items that are currently being processed might cause issues. It's best to pause the workflow first, make your changes, then resume."}),e.jsx(Wr,{question:"How do I add more tasks to a running workflow?",children:'You can add work items through the UI by clicking into a workflow and using the "Add Item" button, or ask Claude to add items using a prompt.'}),e.jsx(Wr,{question:"What if Claude makes a mistake?",children:"You can always revert changes using git. RalphX commits changes incrementally, so you can use git log to see what was changed and git revert to undo specific commits."})]})})]})}function Ck(){return e.jsxs("div",{className:"space-y-8",children:[e.jsx("div",{className:"bg-rose-500/10 border border-rose-500/30 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("svg",{className:"w-5 h-5 text-rose-400 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-rose-300",children:"Security Notice"}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Remote access means your RalphX instance can be reached from outside your home network. This is convenient but requires careful security setup. Follow the recommendations below."})]})]})}),e.jsx(tt,{id:"tailscale",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})}),title:"Option 1: Tailscale (Recommended)",description:"Simple, secure VPN that just works",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-gray-400 text-sm",children:"Tailscale creates a private network between your devices. It's the easiest way to securely access RalphX from your phone or another computer. No port forwarding or complex setup required."}),e.jsx(ht,{title:"Set up Tailscale",description:"Walks you through installing Tailscale and configuring secure access.",prompt:`Help me set up Tailscale so I can access RalphX from my phone.
246
- Walk me through each step, enable MFA on my Tailscale account,
247
- and verify it's working securely.`}),e.jsxs("div",{className:"bg-cyan-500/10 border border-cyan-500/30 rounded-lg p-4",children:[e.jsx("h4",{className:"text-sm font-medium text-cyan-300 mb-2",children:"Security Tips for Tailscale"}),e.jsxs("ul",{className:"text-sm text-gray-400 space-y-2",children:[e.jsxs("li",{className:"flex items-start space-x-2",children:[e.jsx("svg",{className:"w-4 h-4 text-cyan-400 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsxs("span",{children:[e.jsx("strong",{children:"Enable MFA"})," on your Tailscale account (strongly recommended)"]})]}),e.jsxs("li",{className:"flex items-start space-x-2",children:[e.jsx("svg",{className:"w-4 h-4 text-cyan-400 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{children:"By default, all your devices can connect - that's usually fine for personal use"})]}),e.jsxs("li",{className:"flex items-start space-x-2",children:[e.jsx("svg",{className:"w-4 h-4 text-cyan-400 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{children:"If you have many devices, consider ACLs to limit which can access RalphX"})]})]})]})]})}),e.jsx(tt,{id:"cloudflare",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 15a4 4 0 004 4h9a5 5 0 10-.1-9.999 5.002 5.002 0 10-9.78 2.096A4.001 4.001 0 003 15z"})}),title:"Option 2: Cloudflare Tunnel",description:"Custom domain with enterprise-grade security",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-gray-400 text-sm",children:"Cloudflare Tunnel lets you access RalphX via a custom domain (like ralph.yourdomain.com). Requires a domain name and more setup, but provides additional security features."}),e.jsx(ht,{title:"Set up Cloudflare Tunnel",description:"Configures a Cloudflare Tunnel with authentication so only you can access it.",prompt:`Help me set up a Cloudflare Tunnel for RalphX with authentication
248
- so only I can access it. Ask me about my domain, set up the tunnel,
249
- AND configure Cloudflare Access so I need to log in to reach it.`}),e.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/30 rounded-lg p-4",children:[e.jsx("h4",{className:"text-sm font-medium text-amber-300 mb-2",children:"Security Tips for Cloudflare"}),e.jsxs("ul",{className:"text-sm text-gray-400 space-y-2",children:[e.jsxs("li",{className:"flex items-start space-x-2",children:[e.jsx("svg",{className:"w-4 h-4 text-amber-400 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),e.jsxs("span",{children:[e.jsx("strong",{children:"ALWAYS set up Cloudflare Access"})," - without it, anyone with your URL can access RalphX"]})]}),e.jsxs("li",{className:"flex items-start space-x-2",children:[e.jsx("svg",{className:"w-4 h-4 text-amber-400 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),e.jsx("span",{children:"Use your email as the only allowed login"})]}),e.jsxs("li",{className:"flex items-start space-x-2",children:[e.jsx("svg",{className:"w-4 h-4 text-amber-400 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),e.jsx("span",{children:"The prompt above includes auth setup - don't skip it"})]})]})]})]})}),e.jsx(tt,{id:"verify",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})}),title:"Verify Your Setup",description:"Make sure everything is secure",children:e.jsx("div",{className:"space-y-4",children:e.jsx(ht,{title:"Verify remote access security",description:"Checks that your remote access setup is working and properly secured.",prompt:`Check if my remote access setup is working correctly and securely.
250
- Verify I need to authenticate to access RalphX remotely.`})})}),e.jsx(tt,{id:"remote-faq",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),title:"Remote Access FAQ",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs(Wr,{question:"Which option should I choose?",children:[e.jsx("strong",{children:"Choose Tailscale"})," if you want the simplest setup with excellent security. It works great for personal use and requires no domain name.",e.jsx("br",{}),e.jsx("br",{}),e.jsx("strong",{children:"Choose Cloudflare"})," if you want a custom domain (like ralph.yourdomain.com) or need enterprise-grade access controls."]}),e.jsx(Wr,{question:"Is remote access safe?",children:"Both options are secure when set up correctly. The key is authentication - make sure you need to log in to access RalphX. Never expose RalphX directly to the internet without authentication."}),e.jsx(Wr,{question:"Can I use both Tailscale and Cloudflare?",children:"Yes! Some users use Tailscale for personal devices and Cloudflare for sharing with team members. The setups don't conflict."}),e.jsx(Wr,{question:"What if I don't need remote access?",children:"That's fine! RalphX works perfectly fine on localhost. Remote access is optional and only needed if you want to monitor workflows from your phone or another location."})]})})]})}function Sk(){return e.jsxs("div",{className:"space-y-8",children:[e.jsx(tt,{id:"overview",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})}),title:"Backup & Import Overview",description:"Save your workflows and share them with others",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-gray-300",children:["RalphX lets you ",e.jsx("strong",{className:"text-white",children:"export workflows"})," as portable backup files and ",e.jsx("strong",{className:"text-white",children:"import items"})," from external sources."]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Os,{icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),title:"Export Workflow",description:"Download your entire workflow as a .ralphx.zip file. Includes all steps, items, and resources.",color:"cyan"}),e.jsx(Os,{icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})}),title:"Import Workflow",description:"Create a new workflow from a .ralphx.zip file that someone shared with you.",color:"emerald"}),e.jsx(Os,{icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),title:"Import Items",description:"Add user stories or tasks from a JSONL file. Great for bulk importing from other tools.",color:"amber"})]})]})}),e.jsx(tt,{id:"export-workflow",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),title:"Export a Workflow",description:"Create a backup or share your workflow with others",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(Qa,{steps:[{title:"Open your workflow",description:"Go to the workflow you want to export from your project dashboard."},{title:'Click "Export Workflow"',description:"Find the button in the workflow header, next to Edit and Archive."},{title:"Download the file",description:"Your browser will download a .ralphx.zip file containing everything."}]}),e.jsxs("div",{className:"bg-gray-800/50 rounded-lg p-4 border border-gray-700/50",children:[e.jsx("h4",{className:"text-sm font-medium text-white mb-3",children:"What's included in the export?"}),e.jsxs("ul",{className:"space-y-2 text-sm text-gray-300",children:[e.jsxs("li",{className:"flex items-start space-x-2",children:[e.jsx("span",{className:"text-cyan-400 mt-0.5",children:"•"}),e.jsxs("span",{children:[e.jsx("strong",{className:"text-white",children:"Workflow definition"})," - Name, steps, and configuration"]})]}),e.jsxs("li",{className:"flex items-start space-x-2",children:[e.jsx("span",{className:"text-cyan-400 mt-0.5",children:"•"}),e.jsxs("span",{children:[e.jsx("strong",{className:"text-white",children:"All work items"})," - User stories, tasks, bugs"]})]}),e.jsxs("li",{className:"flex items-start space-x-2",children:[e.jsx("span",{className:"text-cyan-400 mt-0.5",children:"•"}),e.jsxs("span",{children:[e.jsx("strong",{className:"text-white",children:"Resources"})," - Design docs, guardrails, instructions"]})]}),e.jsxs("li",{className:"flex items-start space-x-2",children:[e.jsx("span",{className:"text-cyan-400 mt-0.5",children:"•"}),e.jsxs("span",{children:[e.jsx("strong",{className:"text-white",children:"Planning sessions"})," - Research and planning artifacts"]})]})]})]}),e.jsx("div",{className:"bg-amber-500/10 border border-amber-500/30 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("svg",{className:"w-5 h-5 text-amber-400 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-amber-400",children:"Security Note"}),e.jsx("p",{className:"text-sm text-gray-300 mt-1",children:"By default, RalphX automatically removes detected secrets (API keys, tokens, passwords) from exports. Always review exported files before sharing publicly."})]})]})}),e.jsx(ht,{title:"Export via Claude Code",description:"You can also export workflows through Claude Code with MCP.",prompt:'Export the workflow "my-feature" from my project as a backup file.'})]})}),e.jsx(tt,{id:"import-workflow",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})}),title:"Import a Workflow",description:"Create a new workflow from a backup file",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(Qa,{steps:[{title:"Go to your project dashboard",description:"Navigate to the project where you want to import the workflow."},{title:'Click "Import Workflow"',description:'Find the button in the Active Workflows section, next to "New Workflow". You need at least one existing workflow to see this button.'},{title:"Select the .ralphx.zip file",description:"Choose the file you received or downloaded earlier."},{title:"Review and confirm",description:"Check the preview to see what will be imported, then click Import."}]}),e.jsxs("div",{className:"bg-gray-800/50 rounded-lg p-4 border border-gray-700/50",children:[e.jsx("h4",{className:"text-sm font-medium text-white mb-3",children:"What happens during import?"}),e.jsxs("ul",{className:"space-y-2 text-sm text-gray-300",children:[e.jsxs("li",{className:"flex items-start space-x-2",children:[e.jsx("span",{className:"text-emerald-400 mt-0.5",children:"•"}),e.jsxs("span",{children:["A ",e.jsx("strong",{className:"text-white",children:"new workflow"})," is created (doesn't overwrite existing)"]})]}),e.jsxs("li",{className:"flex items-start space-x-2",children:[e.jsx("span",{className:"text-emerald-400 mt-0.5",children:"•"}),e.jsxs("span",{children:["All items start fresh with ",e.jsx("strong",{className:"text-white",children:"pending status"})]})]}),e.jsxs("li",{className:"flex items-start space-x-2",children:[e.jsx("span",{className:"text-emerald-400 mt-0.5",children:"•"}),e.jsxs("span",{children:["If the name exists, a ",e.jsx("strong",{className:"text-white",children:"number suffix"})," is added automatically"]})]})]})]}),e.jsx(ht,{title:"Import via Claude Code",description:"Import a workflow backup file through Claude Code.",prompt:"Import the workflow from the file workflow-backup.ralphx.zip into my current project."})]})}),e.jsx(tt,{id:"import-items",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),title:"Import Items (Advanced)",description:"Bulk import user stories or tasks from a JSONL file",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-gray-800/50 rounded-lg p-4 border border-gray-700/50",children:e.jsxs("p",{className:"text-sm text-gray-300",children:[e.jsx("strong",{className:"text-white",children:"Most users don't need this."})," Claude can generate user stories from your design doc automatically. Item import is for power users who have stories in external tools or want to use predefined templates."]})}),e.jsx(Qa,{steps:[{title:"Open your workflow",description:"Go to the workflow where you want to add items."},{title:"Go to the Items tab",description:'Click the "Items" tab to see work items for this workflow.'},{title:'Click "Import Items"',description:"Find the button in the Items tab header."},{title:"Select your .jsonl file",description:"Each line in the file should be a JSON object representing one item."}]}),e.jsxs("div",{className:"bg-gray-800/50 rounded-lg p-4 border border-gray-700/50",children:[e.jsx("h4",{className:"text-sm font-medium text-white mb-3",children:"JSONL File Format"}),e.jsx("p",{className:"text-xs text-gray-400 mb-2",children:"Each line is one item. Required: id. Highly recommended: title, content, acceptance_criteria."}),e.jsx("div",{className:"bg-gray-900 rounded p-3 font-mono text-xs text-gray-300 overflow-x-auto whitespace-pre-wrap break-all",children:e.jsx("div",{className:"text-cyan-400",children:'{"id": "USR-001", "title": "User login", "content": "As a user, I want to log in so I can access my account.", "priority": 1, "acceptance_criteria": ["Login form with email and password fields", "Validates credentials against database", "Shows error message for invalid credentials", "Redirects to dashboard on success"]}'})})]}),e.jsx("div",{className:"bg-amber-500/10 border border-amber-500/30 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("svg",{className:"w-5 h-5 text-amber-400 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-amber-400",children:"Acceptance Criteria are Important"}),e.jsxs("p",{className:"text-sm text-gray-300 mt-1",children:["The ",e.jsx("code",{className:"text-cyan-400",children:"acceptance_criteria"})," field tells Claude how to verify each story is complete. Without it, implementation may be incomplete or miss requirements. Include 2-5 testable criteria per story."]})]})]})}),e.jsxs("div",{className:"bg-gray-800/50 rounded-lg p-4 border border-gray-700/50",children:[e.jsx("h4",{className:"text-sm font-medium text-white mb-3",children:"Available Fields"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{className:"text-gray-300",children:[e.jsx("code",{className:"text-cyan-400",children:"id"})," - Unique identifier (required)"]}),e.jsxs("div",{className:"text-gray-300",children:[e.jsx("code",{className:"text-cyan-400",children:"title"})," - Short title"]}),e.jsxs("div",{className:"text-gray-300",children:[e.jsx("code",{className:"text-cyan-400",children:"content"})," - Full description"]}),e.jsxs("div",{className:"text-gray-300",children:[e.jsx("code",{className:"text-cyan-400",children:"acceptance_criteria"})," - Array of testable criteria"]}),e.jsxs("div",{className:"text-gray-300",children:[e.jsx("code",{className:"text-cyan-400",children:"priority"})," - 1-5 (1 = highest)"]}),e.jsxs("div",{className:"text-gray-300",children:[e.jsx("code",{className:"text-cyan-400",children:"category"})," - Grouping category"]}),e.jsxs("div",{className:"text-gray-300",children:[e.jsx("code",{className:"text-cyan-400",children:"item_type"})," - story, task, bug"]}),e.jsxs("div",{className:"text-gray-300",children:[e.jsx("code",{className:"text-cyan-400",children:"dependencies"})," - Array of item IDs"]})]})]}),e.jsx("div",{className:"bg-cyan-500/10 border border-cyan-500/30 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("svg",{className:"w-5 h-5 text-cyan-400 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-cyan-400",children:"Duplicate Handling"}),e.jsx("p",{className:"text-sm text-gray-300 mt-1",children:"If your workflow already has items, new items are added alongside them. Items with duplicate IDs are skipped to prevent conflicts."})]})]})}),e.jsx(ht,{title:"Import items via Claude Code",description:"Import user stories from a JSONL file through Claude Code.",prompt:'Import the user stories from stories.jsonl into step 1 of my "feature-workflow" workflow.'})]})}),e.jsx(tt,{id:"quick-reference",icon:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})}),title:"Quick Reference",description:"Where to find each feature",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-700",children:[e.jsx("th",{className:"text-left py-2 text-gray-400 font-medium",children:"Action"}),e.jsx("th",{className:"text-left py-2 text-gray-400 font-medium",children:"Location"}),e.jsx("th",{className:"text-left py-2 text-gray-400 font-medium",children:"File Type"})]})}),e.jsxs("tbody",{className:"text-gray-300",children:[e.jsxs("tr",{className:"border-b border-gray-800",children:[e.jsx("td",{className:"py-2",children:"Export Workflow"}),e.jsx("td",{className:"py-2",children:"Workflow Detail → Header"}),e.jsx("td",{className:"py-2",children:e.jsx("code",{className:"text-cyan-400",children:".ralphx.zip"})})]}),e.jsxs("tr",{className:"border-b border-gray-800",children:[e.jsx("td",{className:"py-2",children:"Import Workflow"}),e.jsx("td",{className:"py-2",children:"Project Dashboard → Active Workflows"}),e.jsx("td",{className:"py-2",children:e.jsx("code",{className:"text-cyan-400",children:".ralphx.zip"})})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"py-2",children:"Import Items"}),e.jsx("td",{className:"py-2",children:"Workflow Detail → Items Tab"}),e.jsx("td",{className:"py-2",children:e.jsx("code",{className:"text-cyan-400",children:".jsonl"})})]})]})]})})})]})}const jh=[{id:"getting-started",label:"Getting Started",icon:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})},{id:"use-cases",label:"Use Cases",icon:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})},{id:"monitoring",label:"Monitoring",icon:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})},{id:"remote-access",label:"Remote Access",icon:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})})},{id:"backup-import",label:"Backup & Import",icon:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})})}];function _k(){const t=bs(),s=ir(),o=()=>{const h=t.hash.replace("#",""),x=jh.find(g=>g.id===h);return x?x.id:"getting-started"},[l,i]=p.useState(o);p.useEffect(()=>{i(o())},[t.hash]);const d=h=>{i(h),s(`/wiki#${h}`,{replace:!0})},u=()=>{switch(l){case"getting-started":return e.jsx(bh,{});case"use-cases":return e.jsx(Nk,{});case"monitoring":return e.jsx(kk,{});case"remote-access":return e.jsx(Ck,{});case"backup-import":return e.jsx(Sk,{});default:return e.jsx(bh,{})}};return e.jsxs("div",{className:"min-h-screen",children:[e.jsxs("div",{className:"border-b border-gray-700/50 bg-gray-900/30",children:[e.jsx("div",{className:"max-w-4xl mx-auto px-6 py-8",children:e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx("div",{className:"p-2 rounded-lg bg-cyan-500/20",children:e.jsx("svg",{className:"w-6 h-6 text-cyan-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"})})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-white",children:"Wiki"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Learn how to use RalphX with step-by-step guides"})]})]})}),e.jsx("div",{className:"max-w-4xl mx-auto px-6",children:e.jsx("div",{className:"flex space-x-1 overflow-x-auto pb-px",children:jh.map(h=>e.jsxs("button",{onClick:()=>d(h.id),className:`flex items-center space-x-2 px-4 py-3 text-sm font-medium whitespace-nowrap transition-colors border-b-2 ${l===h.id?"text-cyan-400 border-cyan-400":"text-gray-400 border-transparent hover:text-gray-200 hover:border-gray-600"}`,children:[h.icon,e.jsx("span",{children:h.label})]},h.id))})})]}),e.jsx("div",{className:"max-w-4xl mx-auto px-6 py-8",children:u()})]})}function Lk(){return e.jsx(My,{children:e.jsxs(mt,{path:"/",element:e.jsx(g2,{}),children:[e.jsx(mt,{index:!0,element:e.jsx(C2,{})}),e.jsx(mt,{path:"projects/:slug",element:e.jsx(gj,{})}),e.jsx(mt,{path:"projects/:slug/dashboard",element:e.jsx(jk,{})}),e.jsx(mt,{path:"projects/:slug/settings",element:e.jsx(BN,{})}),e.jsx(mt,{path:"projects/:slug/items",element:e.jsx(w0,{to:"..",replace:!0})}),e.jsx(mt,{path:"projects/:slug/runs",element:e.jsx(xh,{})}),e.jsx(mt,{path:"projects/:slug/loops/:loopName",element:e.jsx(hN,{})}),e.jsx(mt,{path:"projects/:slug/workflows",element:e.jsx(w0,{to:"..",replace:!0})}),e.jsx(mt,{path:"projects/:slug/workflows/:workflowId",element:e.jsx(nk,{})}),e.jsx(mt,{path:"projects/:slug/workflows/:workflowId/steps/:stepNumber",element:e.jsx(bk,{})}),e.jsx(mt,{path:"projects/:slug/workflows/:workflowId/edit",element:e.jsx($N,{})}),e.jsx(mt,{path:"projects/:slug/workflows/:workflowId/items",element:e.jsx(fN,{})}),e.jsx(mt,{path:"projects/:slug/workflows/:workflowId/resources",element:e.jsx(gN,{})}),e.jsx(mt,{path:"projects/:slug/workflows/:workflowId/runs",element:e.jsx(xh,{})}),e.jsx(mt,{path:"wiki",element:e.jsx(_k,{})}),e.jsx(mt,{path:"logs",element:e.jsx(zN,{})}),e.jsx(mt,{path:"settings",element:e.jsx(ON,{})})]})})}Dg.createRoot(document.getElementById("root")).render(e.jsx(bn.StrictMode,{children:e.jsx(Wy,{children:e.jsx(Lk,{})})}));
251
- //# sourceMappingURL=index-CcxfTosc.js.map