ralphx 0.3.5__py3-none-any.whl → 0.4.1__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 (39) hide show
  1. ralphx/__init__.py +1 -1
  2. ralphx/adapters/base.py +18 -2
  3. ralphx/adapters/claude_cli.py +415 -350
  4. ralphx/api/routes/auth.py +105 -32
  5. ralphx/api/routes/items.py +4 -0
  6. ralphx/api/routes/loops.py +101 -15
  7. ralphx/api/routes/planning.py +866 -17
  8. ralphx/api/routes/resources.py +528 -6
  9. ralphx/api/routes/stream.py +161 -114
  10. ralphx/api/routes/templates.py +1 -0
  11. ralphx/api/routes/workflows.py +257 -25
  12. ralphx/core/auth.py +32 -7
  13. ralphx/core/checkpoint.py +118 -0
  14. ralphx/core/executor.py +292 -85
  15. ralphx/core/loop_templates.py +59 -14
  16. ralphx/core/planning_iteration_executor.py +633 -0
  17. ralphx/core/planning_service.py +11 -4
  18. ralphx/core/project_db.py +835 -85
  19. ralphx/core/resources.py +28 -2
  20. ralphx/core/session.py +62 -10
  21. ralphx/core/templates.py +74 -87
  22. ralphx/core/workflow_executor.py +35 -3
  23. ralphx/mcp/tools/diagnostics.py +1 -1
  24. ralphx/mcp/tools/monitoring.py +10 -16
  25. ralphx/mcp/tools/workflows.py +5 -5
  26. ralphx/models/loop.py +1 -1
  27. ralphx/models/session.py +5 -0
  28. ralphx/static/assets/index-DnihHetG.js +265 -0
  29. ralphx/static/assets/index-DnihHetG.js.map +1 -0
  30. ralphx/static/assets/index-nIDWmtzm.css +1 -0
  31. ralphx/static/index.html +2 -2
  32. ralphx/templates/loop_templates/consumer.md +2 -2
  33. {ralphx-0.3.5.dist-info → ralphx-0.4.1.dist-info}/METADATA +1 -1
  34. {ralphx-0.3.5.dist-info → ralphx-0.4.1.dist-info}/RECORD +36 -35
  35. ralphx/static/assets/index-0ovNnfOq.css +0 -1
  36. ralphx/static/assets/index-CY9s08ZB.js +0 -251
  37. ralphx/static/assets/index-CY9s08ZB.js.map +0 -1
  38. {ralphx-0.3.5.dist-info → ralphx-0.4.1.dist-info}/WHEEL +0 -0
  39. {ralphx-0.3.5.dist-info → ralphx-0.4.1.dist-info}/entry_points.txt +0 -0
@@ -1,251 +0,0 @@
1
- function Sg(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:{}},Pe={};/**
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 n0;function _g(){if(n0)return Pe;n0=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"),p=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),y=Symbol.iterator;function b(E){return E===null||typeof E!="object"?null:(E=y&&E[y]||E["@@iterator"],typeof E=="function"?E:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,S={};function N(E,G,X){this.props=E,this.context=G,this.refs=S,this.updater=X||k}N.prototype.isReactComponent={},N.prototype.setState=function(E,G){if(typeof E!="object"&&typeof E!="function"&&E!=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,E,G,"setState")},N.prototype.forceUpdate=function(E){this.updater.enqueueForceUpdate(this,E,"forceUpdate")};function j(){}j.prototype=N.prototype;function L(E,G,X){this.props=E,this.context=G,this.refs=S,this.updater=X||k}var M=L.prototype=new j;M.constructor=L,C(M,N.prototype),M.isPureReactComponent=!0;var _=Array.isArray,$=Object.prototype.hasOwnProperty,I={current:null},P={key:!0,ref:!0,__self:!0,__source:!0};function V(E,G,X){var ee,F={},me=null,Ne=null;if(G!=null)for(ee in G.ref!==void 0&&(Ne=G.ref),G.key!==void 0&&(me=""+G.key),G)$.call(G,ee)&&!P.hasOwnProperty(ee)&&(F[ee]=G[ee]);var Ae=arguments.length-2;if(Ae===1)F.children=X;else if(1<Ae){for(var Ee=Array(Ae),he=0;he<Ae;he++)Ee[he]=arguments[he+2];F.children=Ee}if(E&&E.defaultProps)for(ee in Ae=E.defaultProps,Ae)F[ee]===void 0&&(F[ee]=Ae[ee]);return{$$typeof:t,type:E,key:me,ref:Ne,props:F,_owner:I.current}}function B(E,G){return{$$typeof:t,type:E.type,key:G,ref:E.ref,props:E.props,_owner:E._owner}}function U(E){return typeof E=="object"&&E!==null&&E.$$typeof===t}function z(E){var G={"=":"=0",":":"=2"};return"$"+E.replace(/[=:]/g,function(X){return G[X]})}var T=/\/+/g;function Z(E,G){return typeof E=="object"&&E!==null&&E.key!=null?z(""+E.key):G.toString(36)}function W(E,G,X,ee,F){var me=typeof E;(me==="undefined"||me==="boolean")&&(E=null);var Ne=!1;if(E===null)Ne=!0;else switch(me){case"string":case"number":Ne=!0;break;case"object":switch(E.$$typeof){case t:case s:Ne=!0}}if(Ne)return Ne=E,F=F(Ne),E=ee===""?"."+Z(Ne,0):ee,_(F)?(X="",E!=null&&(X=E.replace(T,"$&/")+"/"),W(F,G,X,"",function(he){return he})):F!=null&&(U(F)&&(F=B(F,X+(!F.key||Ne&&Ne.key===F.key?"":(""+F.key).replace(T,"$&/")+"/")+E)),G.push(F)),1;if(Ne=0,ee=ee===""?".":ee+":",_(E))for(var Ae=0;Ae<E.length;Ae++){me=E[Ae];var Ee=ee+Z(me,Ae);Ne+=W(me,G,X,Ee,F)}else if(Ee=b(E),typeof Ee=="function")for(E=Ee.call(E),Ae=0;!(me=E.next()).done;)me=me.value,Ee=ee+Z(me,Ae++),Ne+=W(me,G,X,Ee,F);else if(me==="object")throw G=String(E),Error("Objects are not valid as a React child (found: "+(G==="[object Object]"?"object with keys {"+Object.keys(E).join(", ")+"}":G)+"). If you meant to render a collection of children, use an array instead.");return Ne}function Q(E,G,X){if(E==null)return E;var ee=[],F=0;return W(E,ee,"","",function(me){return G.call(X,me,F++)}),ee}function O(E){if(E._status===-1){var G=E._result;G=G(),G.then(function(X){(E._status===0||E._status===-1)&&(E._status=1,E._result=X)},function(X){(E._status===0||E._status===-1)&&(E._status=2,E._result=X)}),E._status===-1&&(E._status=0,E._result=G)}if(E._status===1)return E._result.default;throw E._result}var R={current:null},Y={transition:null},ie={ReactCurrentDispatcher:R,ReactCurrentBatchConfig:Y,ReactCurrentOwner:I};function se(){throw Error("act(...) is not supported in production builds of React.")}return Pe.Children={map:Q,forEach:function(E,G,X){Q(E,function(){G.apply(this,arguments)},X)},count:function(E){var G=0;return Q(E,function(){G++}),G},toArray:function(E){return Q(E,function(G){return G})||[]},only:function(E){if(!U(E))throw Error("React.Children.only expected to receive a single React element child.");return E}},Pe.Component=N,Pe.Fragment=o,Pe.Profiler=i,Pe.PureComponent=L,Pe.StrictMode=l,Pe.Suspense=p,Pe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ie,Pe.act=se,Pe.cloneElement=function(E,G,X){if(E==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+E+".");var ee=C({},E.props),F=E.key,me=E.ref,Ne=E._owner;if(G!=null){if(G.ref!==void 0&&(me=G.ref,Ne=I.current),G.key!==void 0&&(F=""+G.key),E.type&&E.type.defaultProps)var Ae=E.type.defaultProps;for(Ee in G)$.call(G,Ee)&&!P.hasOwnProperty(Ee)&&(ee[Ee]=G[Ee]===void 0&&Ae!==void 0?Ae[Ee]:G[Ee])}var Ee=arguments.length-2;if(Ee===1)ee.children=X;else if(1<Ee){Ae=Array(Ee);for(var he=0;he<Ee;he++)Ae[he]=arguments[he+2];ee.children=Ae}return{$$typeof:t,type:E.type,key:F,ref:me,props:ee,_owner:Ne}},Pe.createContext=function(E){return E={$$typeof:u,_currentValue:E,_currentValue2:E,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},E.Provider={$$typeof:d,_context:E},E.Consumer=E},Pe.createElement=V,Pe.createFactory=function(E){var G=V.bind(null,E);return G.type=E,G},Pe.createRef=function(){return{current:null}},Pe.forwardRef=function(E){return{$$typeof:h,render:E}},Pe.isValidElement=U,Pe.lazy=function(E){return{$$typeof:v,_payload:{_status:-1,_result:E},_init:O}},Pe.memo=function(E,G){return{$$typeof:g,type:E,compare:G===void 0?null:G}},Pe.startTransition=function(E){var G=Y.transition;Y.transition={};try{E()}finally{Y.transition=G}},Pe.unstable_act=se,Pe.useCallback=function(E,G){return R.current.useCallback(E,G)},Pe.useContext=function(E){return R.current.useContext(E)},Pe.useDebugValue=function(){},Pe.useDeferredValue=function(E){return R.current.useDeferredValue(E)},Pe.useEffect=function(E,G){return R.current.useEffect(E,G)},Pe.useId=function(){return R.current.useId()},Pe.useImperativeHandle=function(E,G,X){return R.current.useImperativeHandle(E,G,X)},Pe.useInsertionEffect=function(E,G){return R.current.useInsertionEffect(E,G)},Pe.useLayoutEffect=function(E,G){return R.current.useLayoutEffect(E,G)},Pe.useMemo=function(E,G){return R.current.useMemo(E,G)},Pe.useReducer=function(E,G,X){return R.current.useReducer(E,G,X)},Pe.useRef=function(E){return R.current.useRef(E)},Pe.useState=function(E){return R.current.useState(E)},Pe.useSyncExternalStore=function(E,G,X){return R.current.useSyncExternalStore(E,G,X)},Pe.useTransition=function(){return R.current.useTransition()},Pe.version="18.3.1",Pe}var o0;function Oc(){return o0||(o0=1,lc.exports=_g()),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 a0;function Lg(){if(a0)return yo;a0=1;var t=Oc(),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,p,g){var v,y={},b=null,k=null;g!==void 0&&(b=""+g),p.key!==void 0&&(b=""+p.key),p.ref!==void 0&&(k=p.ref);for(v in p)l.call(p,v)&&!d.hasOwnProperty(v)&&(y[v]=p[v]);if(h&&h.defaultProps)for(v in p=h.defaultProps,p)y[v]===void 0&&(y[v]=p[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 l0;function Eg(){return l0||(l0=1,ac.exports=Lg()),ac.exports}var e=Eg(),x=Oc();const bn=Nh(x),Tg=Sg({__proto__:null,default:bn},[x]);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 i0;function Ag(){return i0||(i0=1,(function(t){function s(Y,ie){var se=Y.length;Y.push(ie);e:for(;0<se;){var E=se-1>>>1,G=Y[E];if(0<i(G,ie))Y[E]=ie,Y[se]=G,se=E;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],se=Y.pop();if(se!==ie){Y[0]=se;e:for(var E=0,G=Y.length,X=G>>>1;E<X;){var ee=2*(E+1)-1,F=Y[ee],me=ee+1,Ne=Y[me];if(0>i(F,se))me<G&&0>i(Ne,F)?(Y[E]=Ne,Y[me]=se,E=me):(Y[E]=F,Y[ee]=se,E=ee);else if(me<G&&0>i(Ne,se))Y[E]=Ne,Y[me]=se,E=me;else break e}}return ie}function i(Y,ie){var se=Y.sortIndex-ie.sortIndex;return se!==0?se: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 p=[],g=[],v=1,y=null,b=3,k=!1,C=!1,S=!1,N=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function M(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(p,ie);else break;ie=o(g)}}function _(Y){if(S=!1,M(Y),!C)if(o(p)!==null)C=!0,O($);else{var ie=o(g);ie!==null&&R(_,ie.startTime-Y)}}function $(Y,ie){C=!1,S&&(S=!1,j(V),V=-1),k=!0;var se=b;try{for(M(ie),y=o(p);y!==null&&(!(y.expirationTime>ie)||Y&&!z());){var E=y.callback;if(typeof E=="function"){y.callback=null,b=y.priorityLevel;var G=E(y.expirationTime<=ie);ie=t.unstable_now(),typeof G=="function"?y.callback=G:y===o(p)&&l(p),M(ie)}else l(p);y=o(p)}if(y!==null)var X=!0;else{var ee=o(g);ee!==null&&R(_,ee.startTime-ie),X=!1}return X}finally{y=null,b=se,k=!1}}var I=!1,P=null,V=-1,B=5,U=-1;function z(){return!(t.unstable_now()-U<B)}function T(){if(P!==null){var Y=t.unstable_now();U=Y;var ie=!0;try{ie=P(!0,Y)}finally{ie?Z():(I=!1,P=null)}}else I=!1}var Z;if(typeof L=="function")Z=function(){L(T)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,Q=W.port2;W.port1.onmessage=T,Z=function(){Q.postMessage(null)}}else Z=function(){N(T,0)};function O(Y){P=Y,I||(I=!0,Z())}function R(Y,ie){V=N(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(){C||k||(C=!0,O($))},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"):B=0<Y?Math.floor(1e3/Y):5},t.unstable_getCurrentPriorityLevel=function(){return b},t.unstable_getFirstCallbackNode=function(){return o(p)},t.unstable_next=function(Y){switch(b){case 1:case 2:case 3:var ie=3;break;default:ie=b}var se=b;b=ie;try{return Y()}finally{b=se}},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 se=b;b=Y;try{return ie()}finally{b=se}},t.unstable_scheduleCallback=function(Y,ie,se){var E=t.unstable_now();switch(typeof se=="object"&&se!==null?(se=se.delay,se=typeof se=="number"&&0<se?E+se:E):se=E,Y){case 1:var G=-1;break;case 2:G=250;break;case 5:G=1073741823;break;case 4:G=1e4;break;default:G=5e3}return G=se+G,Y={id:v++,callback:ie,priorityLevel:Y,startTime:se,expirationTime:G,sortIndex:-1},se>E?(Y.sortIndex=se,s(g,Y),o(p)===null&&Y===o(g)&&(S?(j(V),V=-1):S=!0,R(_,se-E))):(Y.sortIndex=G,s(p,Y),C||k||(C=!0,O($))),Y},t.unstable_shouldYield=z,t.unstable_wrapCallback=function(Y){var ie=b;return function(){var se=b;b=ie;try{return Y.apply(this,arguments)}finally{b=se}}}})(dc)),dc}var c0;function Pg(){return c0||(c0=1,cc.exports=Ag()),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 d0;function Mg(){if(d0)return Ut;d0=1;var t=Oc(),s=Pg();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"),p=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 p.call(y,r)?!0:p.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 C(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 N={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){N[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];N[n]=new S(n,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){N[r]=new S(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){N[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){N[r]=new S(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){N[r]=new S(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){N[r]=new S(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){N[r]=new S(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){N[r]=new S(r,5,!1,r.toLowerCase(),null,!1,!1)});var j=/[\-:]([a-z])/g;function L(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(j,L);N[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(j,L);N[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(j,L);N[n]=new S(n,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){N[r]=new S(r,1,!1,r.toLowerCase(),null,!1,!1)}),N.xlinkHref=new S("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){N[r]=new S(r,1,!1,r.toLowerCase(),null,!0,!0)});function M(r,n,a,c){var m=N.hasOwnProperty(n)?N[n]:null;(m!==null?m.type!==0:c||!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(C(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 _=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,$=Symbol.for("react.element"),I=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),V=Symbol.for("react.strict_mode"),B=Symbol.for("react.profiler"),U=Symbol.for("react.provider"),z=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),Z=Symbol.for("react.suspense"),W=Symbol.for("react.suspense_list"),Q=Symbol.for("react.memo"),O=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 se=Object.assign,E;function G(r){if(E===void 0)try{throw Error()}catch(a){var n=a.stack.trim().match(/\n( *(at )?)/);E=n&&n[1]||""}return`
34
- `+E+r}var X=!1;function ee(r,n){if(!r||X)return"";X=!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(J){var c=J}Reflect.construct(r,[],n)}else{try{n.call()}catch(J){c=J}r.call(n.prototype)}else{try{throw Error()}catch(J){c=J}r()}}catch(J){if(J&&c&&typeof J.stack=="string"){for(var m=J.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 D=`
37
- `+m[w].replace(" at new "," at ");return r.displayName&&D.includes("<anonymous>")&&(D=D.replace("<anonymous>",r.displayName)),D}while(1<=w&&0<=A);break}}}finally{X=!1,Error.prepareStackTrace=a}return(r=r?r.displayName||r.name:"")?G(r):""}function F(r){switch(r.tag){case 5:return G(r.type);case 16:return G("Lazy");case 13:return G("Suspense");case 19:return G("SuspenseList");case 0:case 2:case 15:return r=ee(r.type,!1),r;case 11:return r=ee(r.type.render,!1),r;case 1:return r=ee(r.type,!0),r;default:return""}}function me(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 P:return"Fragment";case I:return"Portal";case B:return"Profiler";case V:return"StrictMode";case Z:return"Suspense";case W:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case z:return(r.displayName||"Context")+".Consumer";case U:return(r._context.displayName||"Context")+".Provider";case T:var n=r.render;return r=r.displayName,r||(r=n.displayName||n.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case Q:return n=r.displayName||null,n!==null?n:me(r.type)||"Memo";case O:n=r._payload,r=r._init;try{return me(r(n))}catch{}}return null}function Ne(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 me(n);case 8:return n===V?"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 Ee(r){var n=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function he(r){var n=Ee(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 re(r){r._valueTracker||(r._valueTracker=he(r))}function ke(r){if(!r)return!1;var n=r._valueTracker;if(!n)return!0;var a=n.getValue(),c="";return r&&(c=Ee(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 ft(r,n){var a=n.checked;return se({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:a??r._wrapperState.initialChecked})}function Lt(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 He(r,n){n=n.checked,n!=null&&M(r,"checked",n,!1)}function Qe(r,n){He(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")?bt(r,n.type,a):n.hasOwnProperty("defaultValue")&&bt(r,n.type,Ae(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(r.defaultChecked=!!n.defaultChecked)}function Et(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 bt(r,n,a){(n!=="number"||Le(r.ownerDocument)!==r)&&(a==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+a&&(r.defaultValue=""+a))}var Bt=Array.isArray;function Tt(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 de(r,n){if(n.dangerouslySetInnerHTML!=null)throw Error(o(91));return se({},n,{value:void 0,defaultValue:void 0,children:""+r._wrapperState.initialValue})}function Re(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(Bt(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 At(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 nt(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 gt(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=se({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 oe(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 Te=null;function Me(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var we=null,Ie=null,Pr=null;function Yt(r){if(r=ro(r)){if(typeof we!="function")throw Error(o(280));var n=r.stateNode;n&&(n=la(n),we(r.stateNode,r.type,n))}}function jd(r){Ie?Pr?Pr.push(r):Pr=[r]:Ie=r}function Nd(){if(Ie){var r=Ie,n=Pr;if(Pr=Ie=null,Yt(r),n)for(r=0;r<n.length;r++)Yt(n[r])}}function kd(r,n){return r(n)}function Cd(){}var Nl=!1;function Sd(r,n,a){if(Nl)return r(n,a);Nl=!0;try{return kd(r,n,a)}finally{Nl=!1,(Ie!==null||Pr!==null)&&(Cd(),Nd())}}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 Ax(r,n,a,c,m,f,w,A,D){var J=Array.prototype.slice.call(arguments,3);try{n.apply(a,J)}catch(le){this.onError(le)}}var Bn=!1,Oo=null,Wo=!1,Cl=null,Px={onError:function(r){Bn=!0,Oo=r}};function Mx(r,n,a,c,m,f,w,A,D){Bn=!1,Oo=null,Ax.apply(Px,arguments)}function Rx(r,n,a,c,m,f,w,A,D){if(Mx.apply(this,arguments),Bn){if(Bn){var J=Oo;Bn=!1,Oo=null}else throw Error(o(198));Wo||(Wo=!0,Cl=J)}}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 _d(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 Ld(r){if(Cs(r)!==r)throw Error(o(188))}function Ix(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 Ld(m),r;if(f===c)return Ld(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 Ed(r){return r=Ix(r),r!==null?Td(r):null}function Td(r){if(r.tag===5||r.tag===6)return r;for(r=r.child;r!==null;){var n=Td(r);if(n!==null)return n;r=r.sibling}return null}var Ad=s.unstable_scheduleCallback,Pd=s.unstable_cancelCallback,$x=s.unstable_shouldYield,Bx=s.unstable_requestPaint,Je=s.unstable_now,Dx=s.unstable_getCurrentPriorityLevel,Sl=s.unstable_ImmediatePriority,Md=s.unstable_UserBlockingPriority,Fo=s.unstable_NormalPriority,Ox=s.unstable_LowPriority,Rd=s.unstable_IdlePriority,zo=null,br=null;function Wx(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:Hx,Fx=Math.log,zx=Math.LN2;function Hx(r){return r>>>=0,r===0?32:31-(Fx(r)/zx|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 Ux(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 Vx(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,D=m[w];D===-1?((A&a)===0||(A&c)!==0)&&(m[w]=Ux(A,n)):D<=n&&(r.expiredLanes|=A),f&=~A}}function _l(r){return r=r.pendingLanes&-1073741825,r!==0?r:r&1073741824?1073741824:0}function Id(){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 qx(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 We=0;function $d(r){return r&=-r,1<r?4<r?(r&268435455)!==0?16:536870912:4:1}var Bd,Tl,Dd,Od,Wd,Al=!1,qo=[],qr=null,Yr=null,Gr=null,Wn=new Map,Fn=new Map,Kr=[],Yx="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 Fd(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":Wn.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":Fn.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 Gx(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 Wn.set(f,zn(Wn.get(f)||null,r,n,a,c,m)),!0;case"gotpointercapture":return f=m.pointerId,Fn.set(f,zn(Fn.get(f)||null,r,n,a,c,m)),!0}return!1}function zd(r){var n=Ss(r.target);if(n!==null){var a=Cs(n);if(a!==null){if(n=a.tag,n===13){if(n=_d(a),n!==null){r.blockedOn=n,Wd(r.priority,function(){Dd(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);Te=c,a.target.dispatchEvent(c),Te=null}else return n=ro(a),n!==null&&Tl(n),r.blockedOn=a,!1;n.shift()}return!0}function Hd(r,n,a){Yo(r)&&a.delete(n)}function Kx(){Al=!1,qr!==null&&Yo(qr)&&(qr=null),Yr!==null&&Yo(Yr)&&(Yr=null),Gr!==null&&Yo(Gr)&&(Gr=null),Wn.forEach(Hd),Fn.forEach(Hd)}function Hn(r,n){r.blockedOn===n&&(r.blockedOn=null,Al||(Al=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,Kx)))}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),Wn.forEach(n),Fn.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);)zd(a),a.blockedOn===null&&Kr.shift()}var Ks=_.ReactCurrentBatchConfig,Go=!0;function Qx(r,n,a,c){var m=We,f=Ks.transition;Ks.transition=null;try{We=1,Pl(r,n,a,c)}finally{We=m,Ks.transition=f}}function Jx(r,n,a,c){var m=We,f=Ks.transition;Ks.transition=null;try{We=4,Pl(r,n,a,c)}finally{We=m,Ks.transition=f}}function Pl(r,n,a,c){if(Go){var m=Ml(r,n,a,c);if(m===null)Ql(r,n,c,Ko,a),Fd(r,c);else if(Gx(m,r,n,a,c))c.stopPropagation();else if(Fd(r,c),n&4&&-1<Yx.indexOf(r)){for(;m!==null;){var f=ro(m);if(f!==null&&Bd(f),f=Ml(r,n,a,c),f===null&&Ql(r,n,c,Ko,a),f===m)break;m=f}m!==null&&c.stopPropagation()}else Ql(r,n,c,null,a)}}var Ko=null;function Ml(r,n,a,c){if(Ko=null,r=Me(c),r=Ss(r),r!==null)if(n=Cs(r),n===null)r=null;else if(a=n.tag,a===13){if(r=_d(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 Ud(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(Dx()){case Sl:return 1;case Md:return 4;case Fo:case Ox:return 16;case Rd:return 536870912;default:return 16}default:return 16}}var Qr=null,Rl=null,Qo=null;function Vd(){if(Qo)return Qo;var r,n=Rl,a=n.length,c,m="value"in Qr?Qr.value:Qr.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 Qo=m.slice(r,1<c?1-c:void 0)}function Jo(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 qd(){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:qd,this.isPropagationStopped=qd,this}return se(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 Qs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Il=Gt(Qs),Vn=se({},Qs,{view:0,detail:0}),Xx=Gt(Vn),$l,Bl,qn,Zo=se({},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}}),Yd=Gt(Zo),Zx=se({},Zo,{dataTransfer:0}),ef=Gt(Zx),tf=se({},Vn,{relatedTarget:0}),Dl=Gt(tf),rf=se({},Qs,{animationName:0,elapsedTime:0,pseudoElement:0}),sf=Gt(rf),nf=se({},Qs,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),of=Gt(nf),af=se({},Qs,{data:0}),Gd=Gt(af),lf={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},cf={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"},df={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function uf(r){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(r):(r=df[r])?!!n[r]:!1}function Ol(){return uf}var mf=se({},Vn,{key:function(r){if(r.key){var n=lf[r.key]||r.key;if(n!=="Unidentified")return n}return r.type==="keypress"?(r=Jo(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?cf[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"?Jo(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?Jo(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),hf=Gt(mf),pf=se({},Zo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Kd=Gt(pf),xf=se({},Vn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ol}),ff=Gt(xf),gf=se({},Qs,{propertyName:0,elapsedTime:0,pseudoElement:0}),yf=Gt(gf),vf=se({},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}),wf=Gt(vf),bf=[9,13,27,32],Wl=h&&"CompositionEvent"in window,Yn=null;h&&"documentMode"in document&&(Yn=document.documentMode);var jf=h&&"TextEvent"in window&&!Yn,Qd=h&&(!Wl||Yn&&8<Yn&&11>=Yn),Jd=" ",Xd=!1;function Zd(r,n){switch(r){case"keyup":return bf.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function eu(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Js=!1;function Nf(r,n){switch(r){case"compositionend":return eu(n);case"keypress":return n.which!==32?null:(Xd=!0,Jd);case"textInput":return r=n.data,r===Jd&&Xd?null:r;default:return null}}function kf(r,n){if(Js)return r==="compositionend"||!Wl&&Zd(r,n)?(r=Vd(),Qo=Rl=Qr=null,Js=!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 Cf={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 tu(r){var n=r&&r.nodeName&&r.nodeName.toLowerCase();return n==="input"?!!Cf[r.type]:n==="textarea"}function ru(r,n,a,c){jd(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 Sf(r){wu(r,0)}function ea(r){var n=rn(r);if(ke(n))return r}function _f(r,n){if(r==="change")return n}var su=!1;if(h){var Fl;if(h){var zl="oninput"in document;if(!zl){var nu=document.createElement("div");nu.setAttribute("oninput","return;"),zl=typeof nu.oninput=="function"}Fl=zl}else Fl=!1;su=Fl&&(!document.documentMode||9<document.documentMode)}function ou(){Gn&&(Gn.detachEvent("onpropertychange",au),Kn=Gn=null)}function au(r){if(r.propertyName==="value"&&ea(Kn)){var n=[];ru(n,Kn,r,Me(r)),Sd(Sf,n)}}function Lf(r,n,a){r==="focusin"?(ou(),Gn=n,Kn=a,Gn.attachEvent("onpropertychange",au)):r==="focusout"&&ou()}function Ef(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return ea(Kn)}function Tf(r,n){if(r==="click")return ea(n)}function Af(r,n){if(r==="input"||r==="change")return ea(n)}function Pf(r,n){return r===n&&(r!==0||1/r===1/n)||r!==r&&n!==n}var mr=typeof Object.is=="function"?Object.is:Pf;function Qn(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(!p.call(n,m)||!mr(r[m],n[m]))return!1}return!0}function lu(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function iu(r,n){var a=lu(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=lu(a)}}function cu(r,n){return r&&n?r===n?!0:r&&r.nodeType===3?!1:n&&n.nodeType===3?cu(r,n.parentNode):"contains"in r?r.contains(n):r.compareDocumentPosition?!!(r.compareDocumentPosition(n)&16):!1:!1}function du(){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 Mf(r){var n=du(),a=r.focusedElem,c=r.selectionRange;if(n!==a&&a&&a.ownerDocument&&cu(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=iu(a,f);var w=iu(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 Rf=h&&"documentMode"in document&&11>=document.documentMode,Xs=null,Ul=null,Jn=null,Vl=!1;function uu(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}),Jn&&Qn(Jn,c)||(Jn=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={},mu={};h&&(mu=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 mu)return ql[r]=n[a];return r}var hu=ra("animationend"),pu=ra("animationiteration"),xu=ra("animationstart"),fu=ra("transitionend"),gu=new Map,yu="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 Jr(r,n){gu.set(r,n),d(n,[r])}for(var Yl=0;Yl<yu.length;Yl++){var Gl=yu[Yl],If=Gl.toLowerCase(),$f=Gl[0].toUpperCase()+Gl.slice(1);Jr(If,"on"+$f)}Jr(hu,"onAnimationEnd"),Jr(pu,"onAnimationIteration"),Jr(xu,"onAnimationStart"),Jr("dblclick","onDoubleClick"),Jr("focusin","onFocus"),Jr("focusout","onBlur"),Jr(fu,"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(" "),Bf=new Set("cancel close invalid load scroll toggle".split(" ").concat(Xn));function vu(r,n,a){var c=r.type||"unknown-event";r.currentTarget=a,Rx(c,n,void 0,r),r.currentTarget=null}function wu(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],D=A.instance,J=A.currentTarget;if(A=A.listener,D!==f&&m.isPropagationStopped())break e;vu(m,A,J),f=D}else for(w=0;w<c.length;w++){if(A=c[w],D=A.instance,J=A.currentTarget,A=A.listener,D!==f&&m.isPropagationStopped())break e;vu(m,A,J),f=D}}}if(Wo)throw r=Cl,Wo=!1,Cl=null,r}function Ue(r,n){var a=n[ri];a===void 0&&(a=n[ri]=new Set);var c=r+"__bubble";a.has(c)||(bu(n,r,2,!1),a.add(c))}function Kl(r,n,a){var c=0;n&&(c|=4),bu(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"&&(Bf.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 bu(r,n,a,c){switch(Ud(n)){case 1:var m=Qx;break;case 4:m=Jx;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 Ql(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 D=w.tag;if((D===3||D===4)&&(D=w.stateNode.containerInfo,D===m||D.nodeType===8&&D.parentNode===m))return;w=w.return}for(;A!==null;){if(w=Ss(A),w===null)return;if(D=w.tag,D===5||D===6){c=f=w;continue e}A=A.parentNode}}c=c.return}Sd(function(){var J=f,le=Me(a),ce=[];e:{var ae=gu.get(r);if(ae!==void 0){var pe=Il,fe=r;switch(r){case"keypress":if(Jo(a)===0)break e;case"keydown":case"keyup":pe=hf;break;case"focusin":fe="focus",pe=Dl;break;case"focusout":fe="blur",pe=Dl;break;case"beforeblur":case"afterblur":pe=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":pe=Yd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":pe=ef;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":pe=ff;break;case hu:case pu:case xu:pe=sf;break;case fu:pe=yf;break;case"scroll":pe=Xx;break;case"wheel":pe=wf;break;case"copy":case"cut":case"paste":pe=of;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":pe=Kd}var ge=(n&4)!==0,Xe=!ge&&r==="scroll",q=ge?ae!==null?ae+"Capture":null:ae;ge=[];for(var H=J,K;H!==null;){K=H;var ue=K.stateNode;if(K.tag===5&&ue!==null&&(K=ue,q!==null&&(ue=In(H,q),ue!=null&&ge.push(eo(H,ue,K)))),Xe)break;H=H.return}0<ge.length&&(ae=new pe(ae,fe,null,a,le),ce.push({event:ae,listeners:ge}))}}if((n&7)===0){e:{if(ae=r==="mouseover"||r==="pointerover",pe=r==="mouseout"||r==="pointerout",ae&&a!==Te&&(fe=a.relatedTarget||a.fromElement)&&(Ss(fe)||fe[Mr]))break e;if((pe||ae)&&(ae=le.window===le?le:(ae=le.ownerDocument)?ae.defaultView||ae.parentWindow:window,pe?(fe=a.relatedTarget||a.toElement,pe=J,fe=fe?Ss(fe):null,fe!==null&&(Xe=Cs(fe),fe!==Xe||fe.tag!==5&&fe.tag!==6)&&(fe=null)):(pe=null,fe=J),pe!==fe)){if(ge=Yd,ue="onMouseLeave",q="onMouseEnter",H="mouse",(r==="pointerout"||r==="pointerover")&&(ge=Kd,ue="onPointerLeave",q="onPointerEnter",H="pointer"),Xe=pe==null?ae:rn(pe),K=fe==null?ae:rn(fe),ae=new ge(ue,H+"leave",pe,a,le),ae.target=Xe,ae.relatedTarget=K,ue=null,Ss(le)===J&&(ge=new ge(q,H+"enter",fe,a,le),ge.target=K,ge.relatedTarget=Xe,ue=ge),Xe=ue,pe&&fe)t:{for(ge=pe,q=fe,H=0,K=ge;K;K=en(K))H++;for(K=0,ue=q;ue;ue=en(ue))K++;for(;0<H-K;)ge=en(ge),H--;for(;0<K-H;)q=en(q),K--;for(;H--;){if(ge===q||q!==null&&ge===q.alternate)break t;ge=en(ge),q=en(q)}ge=null}else ge=null;pe!==null&&ju(ce,ae,pe,ge,!1),fe!==null&&Xe!==null&&ju(ce,Xe,fe,ge,!0)}}e:{if(ae=J?rn(J):window,pe=ae.nodeName&&ae.nodeName.toLowerCase(),pe==="select"||pe==="input"&&ae.type==="file")var ye=_f;else if(tu(ae))if(su)ye=Af;else{ye=Ef;var Ce=Lf}else(pe=ae.nodeName)&&pe.toLowerCase()==="input"&&(ae.type==="checkbox"||ae.type==="radio")&&(ye=Tf);if(ye&&(ye=ye(r,J))){ru(ce,ye,a,le);break e}Ce&&Ce(r,ae,J),r==="focusout"&&(Ce=ae._wrapperState)&&Ce.controlled&&ae.type==="number"&&bt(ae,"number",ae.value)}switch(Ce=J?rn(J):window,r){case"focusin":(tu(Ce)||Ce.contentEditable==="true")&&(Xs=Ce,Ul=J,Jn=null);break;case"focusout":Jn=Ul=Xs=null;break;case"mousedown":Vl=!0;break;case"contextmenu":case"mouseup":case"dragend":Vl=!1,uu(ce,a,le);break;case"selectionchange":if(Rf)break;case"keydown":case"keyup":uu(ce,a,le)}var Se;if(Wl)e:{switch(r){case"compositionstart":var _e="onCompositionStart";break e;case"compositionend":_e="onCompositionEnd";break e;case"compositionupdate":_e="onCompositionUpdate";break e}_e=void 0}else Js?Zd(r,a)&&(_e="onCompositionEnd"):r==="keydown"&&a.keyCode===229&&(_e="onCompositionStart");_e&&(Qd&&a.locale!=="ko"&&(Js||_e!=="onCompositionStart"?_e==="onCompositionEnd"&&Js&&(Se=Vd()):(Qr=le,Rl="value"in Qr?Qr.value:Qr.textContent,Js=!0)),Ce=na(J,_e),0<Ce.length&&(_e=new Gd(_e,r,null,a,le),ce.push({event:_e,listeners:Ce}),Se?_e.data=Se:(Se=eu(a),Se!==null&&(_e.data=Se)))),(Se=jf?Nf(r,a):kf(r,a))&&(J=na(J,"onBeforeInput"),0<J.length&&(le=new Gd("onBeforeInput","beforeinput",null,a,le),ce.push({event:le,listeners:J}),le.data=Se))}wu(ce,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 ju(r,n,a,c,m){for(var f=n._reactName,w=[];a!==null&&a!==c;){var A=a,D=A.alternate,J=A.stateNode;if(D!==null&&D===c)break;A.tag===5&&J!==null&&(A=J,m?(D=In(a,f),D!=null&&w.unshift(eo(a,D,A))):m||(D=In(a,f),D!=null&&w.push(eo(a,D,A)))),a=a.return}w.length!==0&&r.push({event:n,listeners:w})}var Df=/\r\n?/g,Of=/\u0000|\uFFFD/g;function Nu(r){return(typeof r=="string"?r:""+r).replace(Df,`
38
- `).replace(Of,"")}function oa(r,n,a){if(n=Nu(n),Nu(r)!==n&&a)throw Error(o(425))}function aa(){}var Jl=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,Wf=typeof clearTimeout=="function"?clearTimeout:void 0,ku=typeof Promise=="function"?Promise:void 0,Ff=typeof queueMicrotask=="function"?queueMicrotask:typeof ku<"u"?function(r){return ku.resolve(null).then(r).catch(zf)}:ei;function zf(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 Cu(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,Hf="__reactListeners$"+tn,Uf="__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=Cu(r);r!==null;){if(a=r[jr])return a;r=Cu(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 Ve(r){0>sn||(r.current=si[sn],si[sn]=null,sn--)}function Fe(r,n){sn++,si[sn]=r.current,r.current=n}var es={},jt=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 Wt(r){return r=r.childContextTypes,r!=null}function ia(){Ve(Ot),Ve(jt)}function Su(r,n,a){if(jt.current!==es)throw Error(o(168));Fe(jt,n),Fe(Ot,a)}function _u(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,Ne(r)||"Unknown",m));return se({},a,c)}function ca(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||es,_s=jt.current,Fe(jt,r),Fe(Ot,Ot.current),!0}function Lu(r,n,a){var c=r.stateNode;if(!c)throw Error(o(169));a?(r=_u(r,n,_s),c.__reactInternalMemoizedMergedChildContext=r,Ve(Ot),Ve(jt),Fe(jt,r)):Ve(Ot),Fe(Ot,a)}var Rr=null,da=!1,ni=!1;function Eu(r){Rr===null?Rr=[r]:Rr.push(r)}function Vf(r){da=!0,Eu(r)}function ts(){if(!ni&&Rr!==null){ni=!0;var r=0,n=We;try{var a=Rr;for(We=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)),Ad(Sl,ts),m}finally{We=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 Tu(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),Tu(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,Qt=null,qe=!1,hr=null;function Au(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 Pu(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,Qt=Xr(n.firstChild),!0):!1;case 6:return n=r.pendingProps===""||n.nodeType!==3?null:n,n!==null?(r.stateNode=n,Kt=r,Qt=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,Qt=null,!0):!1;default:return!1}}function li(r){return(r.mode&1)!==0&&(r.flags&128)===0}function ii(r){if(qe){var n=Qt;if(n){var a=n;if(!Pu(r,n)){if(li(r))throw Error(o(418));n=Xr(a.nextSibling);var c=Kt;n&&Pu(r,n)?Au(c,a):(r.flags=r.flags&-4097|2,qe=!1,Kt=r)}}else{if(li(r))throw Error(o(418));r.flags=r.flags&-4097|2,qe=!1,Kt=r}}}function Mu(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(!qe)return Mu(r),qe=!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=Qt)){if(li(r))throw Ru(),Error(o(418));for(;n;)Au(r,n),n=Xr(n.nextSibling)}if(Mu(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){Qt=Xr(r.nextSibling);break e}n--}else a!=="$"&&a!=="$!"&&a!=="$?"||n++}r=r.nextSibling}Qt=null}}else Qt=Kt?Xr(r.stateNode.nextSibling):null;return!0}function Ru(){for(var r=Qt;r;)r=Xr(r.nextSibling)}function ln(){Qt=Kt=null,qe=!1}function ci(r){hr===null?hr=[r]:hr.push(r)}var qf=_.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 Iu(r){var n=r._init;return n(r._payload)}function $u(r){function n(q,H){if(r){var K=q.deletions;K===null?(q.deletions=[H],q.flags|=16):K.push(H)}}function a(q,H){if(!r)return null;for(;H!==null;)n(q,H),H=H.sibling;return null}function c(q,H){for(q=new Map;H!==null;)H.key!==null?q.set(H.key,H):q.set(H.index,H),H=H.sibling;return q}function m(q,H){return q=cs(q,H),q.index=0,q.sibling=null,q}function f(q,H,K){return q.index=K,r?(K=q.alternate,K!==null?(K=K.index,K<H?(q.flags|=2,H):K):(q.flags|=2,H)):(q.flags|=1048576,H)}function w(q){return r&&q.alternate===null&&(q.flags|=2),q}function A(q,H,K,ue){return H===null||H.tag!==6?(H=ec(K,q.mode,ue),H.return=q,H):(H=m(H,K),H.return=q,H)}function D(q,H,K,ue){var ye=K.type;return ye===P?le(q,H,K.props.children,ue,K.key):H!==null&&(H.elementType===ye||typeof ye=="object"&&ye!==null&&ye.$$typeof===O&&Iu(ye)===H.type)?(ue=m(H,K.props),ue.ref=so(q,H,K),ue.return=q,ue):(ue=Da(K.type,K.key,K.props,null,q.mode,ue),ue.ref=so(q,H,K),ue.return=q,ue)}function J(q,H,K,ue){return H===null||H.tag!==4||H.stateNode.containerInfo!==K.containerInfo||H.stateNode.implementation!==K.implementation?(H=tc(K,q.mode,ue),H.return=q,H):(H=m(H,K.children||[]),H.return=q,H)}function le(q,H,K,ue,ye){return H===null||H.tag!==7?(H=Bs(K,q.mode,ue,ye),H.return=q,H):(H=m(H,K),H.return=q,H)}function ce(q,H,K){if(typeof H=="string"&&H!==""||typeof H=="number")return H=ec(""+H,q.mode,K),H.return=q,H;if(typeof H=="object"&&H!==null){switch(H.$$typeof){case $:return K=Da(H.type,H.key,H.props,null,q.mode,K),K.ref=so(q,null,H),K.return=q,K;case I:return H=tc(H,q.mode,K),H.return=q,H;case O:var ue=H._init;return ce(q,ue(H._payload),K)}if(Bt(H)||ie(H))return H=Bs(H,q.mode,K,null),H.return=q,H;pa(q,H)}return null}function ae(q,H,K,ue){var ye=H!==null?H.key:null;if(typeof K=="string"&&K!==""||typeof K=="number")return ye!==null?null:A(q,H,""+K,ue);if(typeof K=="object"&&K!==null){switch(K.$$typeof){case $:return K.key===ye?D(q,H,K,ue):null;case I:return K.key===ye?J(q,H,K,ue):null;case O:return ye=K._init,ae(q,H,ye(K._payload),ue)}if(Bt(K)||ie(K))return ye!==null?null:le(q,H,K,ue,null);pa(q,K)}return null}function pe(q,H,K,ue,ye){if(typeof ue=="string"&&ue!==""||typeof ue=="number")return q=q.get(K)||null,A(H,q,""+ue,ye);if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case $:return q=q.get(ue.key===null?K:ue.key)||null,D(H,q,ue,ye);case I:return q=q.get(ue.key===null?K:ue.key)||null,J(H,q,ue,ye);case O:var Ce=ue._init;return pe(q,H,K,Ce(ue._payload),ye)}if(Bt(ue)||ie(ue))return q=q.get(K)||null,le(H,q,ue,ye,null);pa(H,ue)}return null}function fe(q,H,K,ue){for(var ye=null,Ce=null,Se=H,_e=H=0,pt=null;Se!==null&&_e<K.length;_e++){Se.index>_e?(pt=Se,Se=null):pt=Se.sibling;var Be=ae(q,Se,K[_e],ue);if(Be===null){Se===null&&(Se=pt);break}r&&Se&&Be.alternate===null&&n(q,Se),H=f(Be,H,_e),Ce===null?ye=Be:Ce.sibling=Be,Ce=Be,Se=pt}if(_e===K.length)return a(q,Se),qe&&Es(q,_e),ye;if(Se===null){for(;_e<K.length;_e++)Se=ce(q,K[_e],ue),Se!==null&&(H=f(Se,H,_e),Ce===null?ye=Se:Ce.sibling=Se,Ce=Se);return qe&&Es(q,_e),ye}for(Se=c(q,Se);_e<K.length;_e++)pt=pe(Se,q,_e,K[_e],ue),pt!==null&&(r&&pt.alternate!==null&&Se.delete(pt.key===null?_e:pt.key),H=f(pt,H,_e),Ce===null?ye=pt:Ce.sibling=pt,Ce=pt);return r&&Se.forEach(function(ds){return n(q,ds)}),qe&&Es(q,_e),ye}function ge(q,H,K,ue){var ye=ie(K);if(typeof ye!="function")throw Error(o(150));if(K=ye.call(K),K==null)throw Error(o(151));for(var Ce=ye=null,Se=H,_e=H=0,pt=null,Be=K.next();Se!==null&&!Be.done;_e++,Be=K.next()){Se.index>_e?(pt=Se,Se=null):pt=Se.sibling;var ds=ae(q,Se,Be.value,ue);if(ds===null){Se===null&&(Se=pt);break}r&&Se&&ds.alternate===null&&n(q,Se),H=f(ds,H,_e),Ce===null?ye=ds:Ce.sibling=ds,Ce=ds,Se=pt}if(Be.done)return a(q,Se),qe&&Es(q,_e),ye;if(Se===null){for(;!Be.done;_e++,Be=K.next())Be=ce(q,Be.value,ue),Be!==null&&(H=f(Be,H,_e),Ce===null?ye=Be:Ce.sibling=Be,Ce=Be);return qe&&Es(q,_e),ye}for(Se=c(q,Se);!Be.done;_e++,Be=K.next())Be=pe(Se,q,_e,Be.value,ue),Be!==null&&(r&&Be.alternate!==null&&Se.delete(Be.key===null?_e:Be.key),H=f(Be,H,_e),Ce===null?ye=Be:Ce.sibling=Be,Ce=Be);return r&&Se.forEach(function(Cg){return n(q,Cg)}),qe&&Es(q,_e),ye}function Xe(q,H,K,ue){if(typeof K=="object"&&K!==null&&K.type===P&&K.key===null&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case $:e:{for(var ye=K.key,Ce=H;Ce!==null;){if(Ce.key===ye){if(ye=K.type,ye===P){if(Ce.tag===7){a(q,Ce.sibling),H=m(Ce,K.props.children),H.return=q,q=H;break e}}else if(Ce.elementType===ye||typeof ye=="object"&&ye!==null&&ye.$$typeof===O&&Iu(ye)===Ce.type){a(q,Ce.sibling),H=m(Ce,K.props),H.ref=so(q,Ce,K),H.return=q,q=H;break e}a(q,Ce);break}else n(q,Ce);Ce=Ce.sibling}K.type===P?(H=Bs(K.props.children,q.mode,ue,K.key),H.return=q,q=H):(ue=Da(K.type,K.key,K.props,null,q.mode,ue),ue.ref=so(q,H,K),ue.return=q,q=ue)}return w(q);case I:e:{for(Ce=K.key;H!==null;){if(H.key===Ce)if(H.tag===4&&H.stateNode.containerInfo===K.containerInfo&&H.stateNode.implementation===K.implementation){a(q,H.sibling),H=m(H,K.children||[]),H.return=q,q=H;break e}else{a(q,H);break}else n(q,H);H=H.sibling}H=tc(K,q.mode,ue),H.return=q,q=H}return w(q);case O:return Ce=K._init,Xe(q,H,Ce(K._payload),ue)}if(Bt(K))return fe(q,H,K,ue);if(ie(K))return ge(q,H,K,ue);pa(q,K)}return typeof K=="string"&&K!==""||typeof K=="number"?(K=""+K,H!==null&&H.tag===6?(a(q,H.sibling),H=m(H,K),H.return=q,q=H):(a(q,H),H=ec(K,q.mode,ue),H.return=q,q=H),w(q)):a(q,H)}return Xe}var cn=$u(!0),Bu=$u(!1),xa=Zr(null),fa=null,dn=null,di=null;function ui(){di=dn=fa=null}function mi(r){var n=xa.current;Ve(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&&(Ft=!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 Du(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 Ou(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,($e&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 D=A,J=D.next;D.next=null,w===null?f=J:w.next=J,w=D;var le=r.alternate;le!==null&&(le=le.updateQueue,A=le.lastBaseUpdate,A!==w&&(A===null?le.firstBaseUpdate=J:A.next=J,le.lastBaseUpdate=D))}if(f!==null){var ce=m.baseState;w=0,le=J=D=null,A=f;do{var ae=A.lane,pe=A.eventTime;if((c&ae)===ae){le!==null&&(le=le.next={eventTime:pe,lane:0,tag:A.tag,payload:A.payload,callback:A.callback,next:null});e:{var fe=r,ge=A;switch(ae=n,pe=a,ge.tag){case 1:if(fe=ge.payload,typeof fe=="function"){ce=fe.call(pe,ce,ae);break e}ce=fe;break e;case 3:fe.flags=fe.flags&-65537|128;case 0:if(fe=ge.payload,ae=typeof fe=="function"?fe.call(pe,ce,ae):fe,ae==null)break e;ce=se({},ce,ae);break e;case 2:rs=!0}}A.callback!==null&&A.lane!==0&&(r.flags|=64,ae=m.effects,ae===null?m.effects=[A]:ae.push(A))}else pe={eventTime:pe,lane:ae,tag:A.tag,payload:A.payload,callback:A.callback,next:null},le===null?(J=le=pe,D=ce):le=le.next=pe,w|=ae;if(A=A.next,A===null){if(A=m.shared.pending,A===null)break;ae=A,A=ae.next,ae.next=null,m.lastBaseUpdate=ae,m.shared.pending=null}}while(!0);if(le===null&&(D=ce),m.baseState=D,m.firstBaseUpdate=J,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=ce}}function Fu(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(Fe(ao,n),Fe(oo,r),Fe(Nr,no),r=n.nodeType,r){case 9:case 11:n=(n=n.documentElement)?n.namespaceURI:gt(null,"");break;default:r=r===8?n.parentNode:n,n=r.namespaceURI||null,r=r.tagName,n=gt(n,r)}Ve(Nr),Fe(Nr,n)}function mn(){Ve(Nr),Ve(oo),Ve(ao)}function zu(r){As(ao.current);var n=As(Nr.current),a=gt(n,r.type);n!==a&&(Fe(oo,r),Fe(Nr,a))}function gi(r){oo.current===r&&(Ve(Nr),Ve(oo))}var Ye=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=_.ReactCurrentDispatcher,wi=_.ReactCurrentBatchConfig,Ps=0,Ge=null,lt=null,mt=null,ba=!1,lo=!1,io=0,Yf=0;function Nt(){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,Ge=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,wa.current=r===null||r.memoizedState===null?Jf:Xf,r=a(c,m),lo){f=0;do{if(lo=!1,io=0,25<=f)throw Error(o(301));f+=1,mt=lt=null,n.updateQueue=null,wa.current=Zf,r=a(c,m)}while(lo)}if(wa.current=ka,n=lt!==null&&lt.next!==null,Ps=0,mt=lt=Ge=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 mt===null?Ge.memoizedState=mt=r:mt=mt.next=r,mt}function nr(){if(lt===null){var r=Ge.alternate;r=r!==null?r.memoizedState:null}else r=lt.next;var n=mt===null?Ge.memoizedState:mt.next;if(n!==null)mt=n,lt=r;else{if(r===null)throw Error(o(310));lt=r,r={memoizedState:lt.memoizedState,baseState:lt.baseState,baseQueue:lt.baseQueue,queue:lt.queue,next:null},mt===null?Ge.memoizedState=mt=r:mt=mt.next=r}return mt}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=lt,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,D=null,J=f;do{var le=J.lane;if((Ps&le)===le)D!==null&&(D=D.next={lane:0,action:J.action,hasEagerState:J.hasEagerState,eagerState:J.eagerState,next:null}),c=J.hasEagerState?J.eagerState:r(c,J.action);else{var ce={lane:le,action:J.action,hasEagerState:J.hasEagerState,eagerState:J.eagerState,next:null};D===null?(A=D=ce,w=c):D=D.next=ce,Ge.lanes|=le,Ms|=le}J=J.next}while(J!==null&&J!==f);D===null?w=c:D.next=A,mr(c,n.memoizedState)||(Ft=!0),n.memoizedState=c,n.baseState=w,n.baseQueue=D,a.lastRenderedState=c}if(r=a.interleaved,r!==null){m=r;do f=m.lane,Ge.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)||(Ft=!0),n.memoizedState=f,n.baseQueue===null&&(n.baseState=f),a.lastRenderedState=f}return[f,c]}function Hu(){}function Uu(r,n){var a=Ge,c=nr(),m=n(),f=!mr(c.memoizedState,m);if(f&&(c.memoizedState=m,Ft=!0),c=c.queue,Si(Yu.bind(null,a,c,r),[r]),c.getSnapshot!==n||f||mt!==null&&mt.memoizedState.tag&1){if(a.flags|=2048,uo(9,qu.bind(null,a,c,m,n),void 0,null),ht===null)throw Error(o(349));(Ps&30)!==0||Vu(a,n,m)}return m}function Vu(r,n,a){r.flags|=16384,r={getSnapshot:n,value:a},n=Ge.updateQueue,n===null?(n={lastEffect:null,stores:null},Ge.updateQueue=n,n.stores=[r]):(a=n.stores,a===null?n.stores=[r]:a.push(r))}function qu(r,n,a,c){n.value=a,n.getSnapshot=c,Gu(n)&&Ku(r)}function Yu(r,n,a){return a(function(){Gu(n)&&Ku(r)})}function Gu(r){var n=r.getSnapshot;r=r.value;try{var a=n();return!mr(r,a)}catch{return!0}}function Ku(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=Qf.bind(null,Ge,r),[n.memoizedState,r]}function uo(r,n,a,c){return r={tag:r,create:n,destroy:a,deps:c,next:null},n=Ge.updateQueue,n===null?(n={lastEffect:null,stores:null},Ge.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 Ju(){return nr().memoizedState}function ja(r,n,a,c){var m=kr();Ge.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(lt!==null){var w=lt.memoizedState;if(f=w.destroy,c!==null&&bi(c,w.deps)){m.memoizedState=uo(n,a,f,c);return}}Ge.flags|=r,m.memoizedState=uo(1|n,a,f,c)}function Xu(r,n){return ja(8390656,8,r,n)}function Si(r,n){return Na(2048,8,r,n)}function Zu(r,n){return Na(4,2,r,n)}function em(r,n){return Na(4,4,r,n)}function tm(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 rm(r,n,a){return a=a!=null?a.concat([r]):null,Na(4,4,tm.bind(null,n,r),a)}function _i(){}function sm(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 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]:(r=r(),a.memoizedState=[r,n],r)}function om(r,n,a){return(Ps&21)===0?(r.baseState&&(r.baseState=!1,Ft=!0),r.memoizedState=a):(mr(a,n)||(a=Id(),Ge.lanes|=a,Ms|=a,r.baseState=!0),n)}function Gf(r,n){var a=We;We=a!==0&&4>a?a:4,r(!0);var c=wi.transition;wi.transition={};try{r(!1),n()}finally{We=a,wi.transition=c}}function am(){return nr().memoizedState}function Kf(r,n,a){var c=ls(r);if(a={lane:c,action:a,hasEagerState:!1,eagerState:null,next:null},lm(r))im(n,a);else if(a=Du(r,n,a,c),a!==null){var m=Mt();gr(a,r,c,m),cm(a,n,c)}}function Qf(r,n,a){var c=ls(r),m={lane:c,action:a,hasEagerState:!1,eagerState:null,next:null};if(lm(r))im(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 D=n.interleaved;D===null?(m.next=m,pi(n)):(m.next=D.next,D.next=m),n.interleaved=m;return}}catch{}finally{}a=Du(r,n,m,c),a!==null&&(m=Mt(),gr(a,r,c,m),cm(a,n,c))}}function lm(r){var n=r.alternate;return r===Ge||n!==null&&n===Ge}function im(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 cm(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:Nt,useContext:Nt,useEffect:Nt,useImperativeHandle:Nt,useInsertionEffect:Nt,useLayoutEffect:Nt,useMemo:Nt,useReducer:Nt,useRef:Nt,useState:Nt,useDebugValue:Nt,useDeferredValue:Nt,useTransition:Nt,useMutableSource:Nt,useSyncExternalStore:Nt,useId:Nt,unstable_isNewReconciler:!1},Jf={readContext:sr,useCallback:function(r,n){return kr().memoizedState=[r,n===void 0?null:n],r},useContext:sr,useEffect:Xu,useImperativeHandle:function(r,n,a){return a=a!=null?a.concat([r]):null,ja(4194308,4,tm.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=Kf.bind(null,Ge,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=Gf.bind(null,r[1]),kr().memoizedState=r,[n,r]},useMutableSource:function(){},useSyncExternalStore:function(r,n,a){var c=Ge,m=kr();if(qe){if(a===void 0)throw Error(o(407));a=a()}else{if(a=n(),ht===null)throw Error(o(349));(Ps&30)!==0||Vu(c,n,a)}m.memoizedState=a;var f={value:a,getSnapshot:n};return m.queue=f,Xu(Yu.bind(null,c,f,r),[r]),c.flags|=2048,uo(9,qu.bind(null,c,f,a,n),void 0,null),a},useId:function(){var r=kr(),n=ht.identifierPrefix;if(qe){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=Yf++,n=":"+n+"r"+a.toString(32)+":";return r.memoizedState=n},unstable_isNewReconciler:!1},Xf={readContext:sr,useCallback:sm,useContext:sr,useEffect:Si,useImperativeHandle:rm,useInsertionEffect:Zu,useLayoutEffect:em,useMemo:nm,useReducer:ki,useRef:Ju,useState:function(){return ki(co)},useDebugValue:_i,useDeferredValue:function(r){var n=nr();return om(n,lt.memoizedState,r)},useTransition:function(){var r=ki(co)[0],n=nr().memoizedState;return[r,n]},useMutableSource:Hu,useSyncExternalStore:Uu,useId:am,unstable_isNewReconciler:!1},Zf={readContext:sr,useCallback:sm,useContext:sr,useEffect:Si,useImperativeHandle:rm,useInsertionEffect:Zu,useLayoutEffect:em,useMemo:nm,useReducer:Ci,useRef:Ju,useState:function(){return Ci(co)},useDebugValue:_i,useDeferredValue:function(r){var n=nr();return lt===null?n.memoizedState=r:om(n,lt.memoizedState,r)},useTransition:function(){var r=Ci(co)[0],n=nr().memoizedState;return[r,n]},useMutableSource:Hu,useSyncExternalStore:Uu,useId:am,unstable_isNewReconciler:!1};function pr(r,n){if(r&&r.defaultProps){n=se({},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:se({},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=Mt(),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=Mt(),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=Mt(),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 dm(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?!Qn(a,c)||!Qn(m,f):!0}function um(r,n,a){var c=!1,m=es,f=n.contextType;return typeof f=="object"&&f!==null?f=sr(f):(m=Wt(n)?_s:jt.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 mm(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=Wt(n)?_s:jt.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+=F(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 eg=typeof WeakMap=="function"?WeakMap:Map;function hm(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 pm(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 xm(r,n,a){var c=r.pingCache;if(c===null){c=r.pingCache=new eg;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=pg.bind(null,r,n,a),n.then(r,r))}function fm(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 gm(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 tg=_.ReactCurrentOwner,Ft=!1;function Pt(r,n,a,c){n.child=r===null?Bu(n,null,a,c):cn(n,r.child,a,c)}function ym(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&&!Ft?(n.updateQueue=r.updateQueue,n.flags&=-2053,r.lanes&=~m,Or(r,n,m)):(qe&&a&&oi(n),n.flags|=1,Pt(r,n,c,m),n.child)}function vm(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,wm(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:Qn,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 wm(r,n,a,c,m){if(r!==null){var f=r.memoizedProps;if(Qn(f,c)&&r.ref===n.ref)if(Ft=!1,n.pendingProps=c=f,(r.lanes&m)!==0)(r.flags&131072)!==0&&(Ft=!0);else return n.lanes=r.lanes,Or(r,n,m)}return Pi(r,n,a,c,m)}function bm(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},Fe(xn,Jt),Jt|=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,Fe(xn,Jt),Jt|=r,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=f!==null?f.baseLanes:a,Fe(xn,Jt),Jt|=c}else f!==null?(c=f.baseLanes|a,n.memoizedState=null):c=a,Fe(xn,Jt),Jt|=c;return Pt(r,n,m,a),n.child}function jm(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=Wt(a)?_s:jt.current;return f=nn(n,f),un(n,m),a=ji(r,n,a,c,f,m),c=Ni(),r!==null&&!Ft?(n.updateQueue=r.updateQueue,n.flags&=-2053,r.lanes&=~m,Or(r,n,m)):(qe&&c&&oi(n),n.flags|=1,Pt(r,n,a,m),n.child)}function Nm(r,n,a,c,m){if(Wt(a)){var f=!0;ca(n)}else f=!1;if(un(n,m),n.stateNode===null)_a(r,n),um(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 D=w.context,J=a.contextType;typeof J=="object"&&J!==null?J=sr(J):(J=Wt(a)?_s:jt.current,J=nn(n,J));var le=a.getDerivedStateFromProps,ce=typeof le=="function"||typeof w.getSnapshotBeforeUpdate=="function";ce||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(A!==c||D!==J)&&mm(n,w,c,J),rs=!1;var ae=n.memoizedState;w.state=ae,ya(n,c,w,m),D=n.memoizedState,A!==c||ae!==D||Ot.current||rs?(typeof le=="function"&&(Li(n,a,le,c),D=n.memoizedState),(A=rs||dm(n,a,A,c,ae,D,J))?(ce||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=D),w.props=c,w.state=D,w.context=J,c=A):(typeof w.componentDidMount=="function"&&(n.flags|=4194308),c=!1)}else{w=n.stateNode,Ou(r,n),A=n.memoizedProps,J=n.type===n.elementType?A:pr(n.type,A),w.props=J,ce=n.pendingProps,ae=w.context,D=a.contextType,typeof D=="object"&&D!==null?D=sr(D):(D=Wt(a)?_s:jt.current,D=nn(n,D));var pe=a.getDerivedStateFromProps;(le=typeof pe=="function"||typeof w.getSnapshotBeforeUpdate=="function")||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(A!==ce||ae!==D)&&mm(n,w,c,D),rs=!1,ae=n.memoizedState,w.state=ae,ya(n,c,w,m);var fe=n.memoizedState;A!==ce||ae!==fe||Ot.current||rs?(typeof pe=="function"&&(Li(n,a,pe,c),fe=n.memoizedState),(J=rs||dm(n,a,J,c,ae,fe,D)||!1)?(le||typeof w.UNSAFE_componentWillUpdate!="function"&&typeof w.componentWillUpdate!="function"||(typeof w.componentWillUpdate=="function"&&w.componentWillUpdate(c,fe,D),typeof w.UNSAFE_componentWillUpdate=="function"&&w.UNSAFE_componentWillUpdate(c,fe,D)),typeof w.componentDidUpdate=="function"&&(n.flags|=4),typeof w.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof w.componentDidUpdate!="function"||A===r.memoizedProps&&ae===r.memoizedState||(n.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||A===r.memoizedProps&&ae===r.memoizedState||(n.flags|=1024),n.memoizedProps=c,n.memoizedState=fe),w.props=c,w.state=fe,w.context=D,c=J):(typeof w.componentDidUpdate!="function"||A===r.memoizedProps&&ae===r.memoizedState||(n.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||A===r.memoizedProps&&ae===r.memoizedState||(n.flags|=1024),c=!1)}return Mi(r,n,a,c,f,m)}function Mi(r,n,a,c,m,f){jm(r,n);var w=(n.flags&128)!==0;if(!c&&!w)return m&&Lu(n,a,!1),Or(r,n,f);c=n.stateNode,tg.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)):Pt(r,n,A,f),n.memoizedState=c.state,m&&Lu(n,a,!0),n.child}function km(r){var n=r.stateNode;n.pendingContext?Su(r,n.pendingContext,n.pendingContext!==n.context):n.context&&Su(r,n.context,!1),fi(r,n.containerInfo)}function Cm(r,n,a,c,m){return ln(),ci(m),n.flags|=256,Pt(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 Sm(r,n,a){var c=n.pendingProps,m=Ye.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),Fe(Ye,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 rg(r,n,w,c,A,m,a);if(f){f=c.fallback,w=n.mode,m=r.child,A=m.sibling;var D={mode:"hidden",children:c.children};return(w&1)===0&&n.child!==m?(c=n.child,c.childLanes=0,c.pendingProps=D,n.deletions=null):(c=cs(m,D),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 rg(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,Ft||A){if(c=ht,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=xg.bind(null,r),m._reactRetry=n,null):(r=f.treeContext,Qt=Xr(m.nextSibling),Kt=n,qe=!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 _m(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 Lm(r,n,a){var c=n.pendingProps,m=c.revealOrder,f=c.tail;if(Pt(r,n,c.children,a),c=Ye.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&&_m(r,a,n);else if(r.tag===19)_m(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(Fe(Ye,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 sg(r,n,a){switch(n.tag){case 3:km(n),ln();break;case 5:zu(n);break;case 1:Wt(n.type)&&ca(n);break;case 4:fi(n,n.stateNode.containerInfo);break;case 10:var c=n.type._context,m=n.memoizedProps.value;Fe(xa,c._currentValue),c._currentValue=m;break;case 13:if(c=n.memoizedState,c!==null)return c.dehydrated!==null?(Fe(Ye,Ye.current&1),n.flags|=128,null):(a&n.child.childLanes)!==0?Sm(r,n,a):(Fe(Ye,Ye.current&1),r=Or(r,n,a),r!==null?r.sibling:null);Fe(Ye,Ye.current&1);break;case 19:if(c=(a&n.childLanes)!==0,(r.flags&128)!==0){if(c)return Lm(r,n,a);n.flags|=128}if(m=n.memoizedState,m!==null&&(m.rendering=null,m.tail=null,m.lastEffect=null),Fe(Ye,Ye.current),c)break;return null;case 22:case 23:return n.lanes=0,bm(r,n,a)}return Or(r,n,a)}var Em,Di,Tm,Am;Em=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(){},Tm=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=ft(r,m),c=ft(r,c),f=[];break;case"select":m=se({},m,{value:void 0}),c=se({},c,{value:void 0}),f=[];break;case"textarea":m=de(r,m),c=de(r,c),f=[];break;default:typeof m.onClick!="function"&&typeof c.onClick=="function"&&(r.onclick=aa)}dr(a,c);var w;a=null;for(J in m)if(!c.hasOwnProperty(J)&&m.hasOwnProperty(J)&&m[J]!=null)if(J==="style"){var A=m[J];for(w in A)A.hasOwnProperty(w)&&(a||(a={}),a[w]="")}else J!=="dangerouslySetInnerHTML"&&J!=="children"&&J!=="suppressContentEditableWarning"&&J!=="suppressHydrationWarning"&&J!=="autoFocus"&&(i.hasOwnProperty(J)?f||(f=[]):(f=f||[]).push(J,null));for(J in c){var D=c[J];if(A=m!=null?m[J]:void 0,c.hasOwnProperty(J)&&D!==A&&(D!=null||A!=null))if(J==="style")if(A){for(w in A)!A.hasOwnProperty(w)||D&&D.hasOwnProperty(w)||(a||(a={}),a[w]="");for(w in D)D.hasOwnProperty(w)&&A[w]!==D[w]&&(a||(a={}),a[w]=D[w])}else a||(f||(f=[]),f.push(J,a)),a=D;else J==="dangerouslySetInnerHTML"?(D=D?D.__html:void 0,A=A?A.__html:void 0,D!=null&&A!==D&&(f=f||[]).push(J,D)):J==="children"?typeof D!="string"&&typeof D!="number"||(f=f||[]).push(J,""+D):J!=="suppressContentEditableWarning"&&J!=="suppressHydrationWarning"&&(i.hasOwnProperty(J)?(D!=null&&J==="onScroll"&&Ue("scroll",r),f||A===D||(f=[])):(f=f||[]).push(J,D))}a&&(f=f||[]).push("style",a);var J=f;(n.updateQueue=J)&&(n.flags|=4)}},Am=function(r,n,a,c){a!==c&&(n.flags|=4)};function mo(r,n){if(!qe)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 kt(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 ng(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 kt(n),null;case 1:return Wt(n.type)&&ia(),kt(n),null;case 3:return c=n.stateNode,mn(),Ve(Ot),Ve(jt),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),kt(n),null;case 5:gi(n);var m=As(ao.current);if(a=n.type,r!==null&&n.stateNode!=null)Tm(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 kt(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":Ue("cancel",c),Ue("close",c);break;case"iframe":case"object":case"embed":Ue("load",c);break;case"video":case"audio":for(m=0;m<Xn.length;m++)Ue(Xn[m],c);break;case"source":Ue("error",c);break;case"img":case"image":case"link":Ue("error",c),Ue("load",c);break;case"details":Ue("toggle",c);break;case"input":Lt(c,f),Ue("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!f.multiple},Ue("invalid",c);break;case"textarea":Re(c,f),Ue("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"&&Ue("scroll",c)}switch(a){case"input":re(c),Et(c,f,!0);break;case"textarea":re(c),nt(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,Em(r,n,!1,!1),n.stateNode=r;e:{switch(w=oe(a,c),a){case"dialog":Ue("cancel",r),Ue("close",r),m=c;break;case"iframe":case"object":case"embed":Ue("load",r),m=c;break;case"video":case"audio":for(m=0;m<Xn.length;m++)Ue(Xn[m],r);m=c;break;case"source":Ue("error",r),m=c;break;case"img":case"image":case"link":Ue("error",r),Ue("load",r),m=c;break;case"details":Ue("toggle",r),m=c;break;case"input":Lt(r,c),m=ft(r,c),Ue("invalid",r);break;case"option":m=c;break;case"select":r._wrapperState={wasMultiple:!!c.multiple},m=se({},c,{value:void 0}),Ue("invalid",r);break;case"textarea":Re(r,c),m=de(r,c),Ue("invalid",r);break;default:m=c}dr(a,m),A=m;for(f in A)if(A.hasOwnProperty(f)){var D=A[f];f==="style"?ks(r,D):f==="dangerouslySetInnerHTML"?(D=D?D.__html:void 0,D!=null&&js(r,D)):f==="children"?typeof D=="string"?(a!=="textarea"||D!=="")&&vr(r,D):typeof D=="number"&&vr(r,""+D):f!=="suppressContentEditableWarning"&&f!=="suppressHydrationWarning"&&f!=="autoFocus"&&(i.hasOwnProperty(f)?D!=null&&f==="onScroll"&&Ue("scroll",r):D!=null&&M(r,f,D,w))}switch(a){case"input":re(r),Et(r,c,!1);break;case"textarea":re(r),nt(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?Tt(r,!!c.multiple,f,!1):c.defaultValue!=null&&Tt(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 kt(n),null;case 6:if(r&&n.stateNode!=null)Am(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 kt(n),null;case 13:if(Ve(Ye),c=n.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(qe&&Qt!==null&&(n.mode&1)!==0&&(n.flags&128)===0)Ru(),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;kt(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||(Ye.current&1)!==0?it===0&&(it=3):Xi())),n.updateQueue!==null&&(n.flags|=4),kt(n),null);case 4:return mn(),Di(r,n),r===null&&Zn(n.stateNode.containerInfo),kt(n),null;case 10:return mi(n.type._context),kt(n),null;case 17:return Wt(n.type)&&ia(),kt(n),null;case 19:if(Ve(Ye),f=n.memoizedState,f===null)return kt(n),null;if(c=(n.flags&128)!==0,w=f.rendering,w===null)if(c)mo(f,!1);else{if(it!==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 Fe(Ye,Ye.current&1|2),n.child}r=r.sibling}f.tail!==null&&Je()>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&&!qe)return kt(n),null}else 2*Je()-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=Je(),n.sibling=null,a=Ye.current,Fe(Ye,c?a&1|2:a&1),n):(kt(n),null);case 22:case 23:return Ji(),c=n.memoizedState!==null,r!==null&&r.memoizedState!==null!==c&&(n.flags|=8192),c&&(n.mode&1)!==0?(Jt&1073741824)!==0&&(kt(n),n.subtreeFlags&6&&(n.flags|=8192)):kt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function og(r,n){switch(ai(n),n.tag){case 1:return Wt(n.type)&&ia(),r=n.flags,r&65536?(n.flags=r&-65537|128,n):null;case 3:return mn(),Ve(Ot),Ve(jt),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(Ve(Ye),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 Ve(Ye),null;case 4:return mn(),null;case 10:return mi(n.type._context),null;case 22:case 23:return Ji(),null;case 24:return null;default:return null}}var La=!1,Ct=!1,ag=typeof WeakSet=="function"?WeakSet:Set,xe=null;function pn(r,n){var a=r.ref;if(a!==null)if(typeof a=="function")try{a(null)}catch(c){Ke(r,n,c)}else a.current=null}function Oi(r,n,a){try{a()}catch(c){Ke(r,n,c)}}var Pm=!1;function lg(r,n){if(Jl=Go,r=du(),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,D=-1,J=0,le=0,ce=r,ae=null;t:for(;;){for(var pe;ce!==a||m!==0&&ce.nodeType!==3||(A=w+m),ce!==f||c!==0&&ce.nodeType!==3||(D=w+c),ce.nodeType===3&&(w+=ce.nodeValue.length),(pe=ce.firstChild)!==null;)ae=ce,ce=pe;for(;;){if(ce===r)break t;if(ae===a&&++J===m&&(A=w),ae===f&&++le===c&&(D=w),(pe=ce.nextSibling)!==null)break;ce=ae,ae=ce.parentNode}ce=pe}a=A===-1||D===-1?null:{start:A,end:D}}else a=null}a=a||{start:0,end:0}}else a=null;for(Xl={focusedElem:r,selectionRange:a},Go=!1,xe=n;xe!==null;)if(n=xe,r=n.child,(n.subtreeFlags&1028)!==0&&r!==null)r.return=n,xe=r;else for(;xe!==null;){n=xe;try{var fe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(fe!==null){var ge=fe.memoizedProps,Xe=fe.memoizedState,q=n.stateNode,H=q.getSnapshotBeforeUpdate(n.elementType===n.type?ge:pr(n.type,ge),Xe);q.__reactInternalSnapshotBeforeUpdate=H}break;case 3:var K=n.stateNode.containerInfo;K.nodeType===1?K.textContent="":K.nodeType===9&&K.documentElement&&K.removeChild(K.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(ue){Ke(n,n.return,ue)}if(r=n.sibling,r!==null){r.return=n.return,xe=r;break}xe=n.return}return fe=Pm,Pm=!1,fe}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 Wi(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 Mm(r){var n=r.alternate;n!==null&&(r.alternate=null,Mm(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[Hf],delete n[Uf])),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 Rm(r){return r.tag===5||r.tag===3||r.tag===4}function Im(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Rm(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 Fi(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(Fi(r,n,a),r=r.sibling;r!==null;)Fi(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 yt=null,xr=!1;function ns(r,n,a){for(a=a.child;a!==null;)$m(r,n,a),a=a.sibling}function $m(r,n,a){if(br&&typeof br.onCommitFiberUnmount=="function")try{br.onCommitFiberUnmount(zo,a)}catch{}switch(a.tag){case 5:Ct||pn(a,n);case 6:var c=yt,m=xr;yt=null,ns(r,n,a),yt=c,xr=m,yt!==null&&(xr?(r=yt,a=a.stateNode,r.nodeType===8?r.parentNode.removeChild(a):r.removeChild(a)):yt.removeChild(a.stateNode));break;case 18:yt!==null&&(xr?(r=yt,a=a.stateNode,r.nodeType===8?ti(r.parentNode,a):r.nodeType===1&&ti(r,a),Un(r)):ti(yt,a.stateNode));break;case 4:c=yt,m=xr,yt=a.stateNode.containerInfo,xr=!0,ns(r,n,a),yt=c,xr=m;break;case 0:case 11:case 14:case 15:if(!Ct&&(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(!Ct&&(pn(a,n),c=a.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=a.memoizedProps,c.state=a.memoizedState,c.componentWillUnmount()}catch(A){Ke(a,n,A)}ns(r,n,a);break;case 21:ns(r,n,a);break;case 22:a.mode&1?(Ct=(c=Ct)||a.memoizedState!==null,ns(r,n,a),Ct=c):ns(r,n,a);break;default:ns(r,n,a)}}function Bm(r){var n=r.updateQueue;if(n!==null){r.updateQueue=null;var a=r.stateNode;a===null&&(a=r.stateNode=new ag),n.forEach(function(c){var m=fg.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:yt=A.stateNode,xr=!1;break e;case 3:yt=A.stateNode.containerInfo,xr=!0;break e;case 4:yt=A.stateNode.containerInfo,xr=!0;break e}A=A.return}if(yt===null)throw Error(o(160));$m(f,w,m),yt=null,xr=!1;var D=m.alternate;D!==null&&(D.return=null),m.return=null}catch(J){Ke(m,n,J)}}if(n.subtreeFlags&12854)for(n=n.child;n!==null;)Dm(n,r),n=n.sibling}function Dm(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(ge){Ke(r,r.return,ge)}try{ho(5,r,r.return)}catch(ge){Ke(r,r.return,ge)}}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(ge){Ke(r,r.return,ge)}}if(c&4&&(m=r.stateNode,m!=null)){var f=r.memoizedProps,w=a!==null?a.memoizedProps:f,A=r.type,D=r.updateQueue;if(r.updateQueue=null,D!==null)try{A==="input"&&f.type==="radio"&&f.name!=null&&He(m,f),oe(A,w);var J=oe(A,f);for(w=0;w<D.length;w+=2){var le=D[w],ce=D[w+1];le==="style"?ks(m,ce):le==="dangerouslySetInnerHTML"?js(m,ce):le==="children"?vr(m,ce):M(m,le,ce,J)}switch(A){case"input":Qe(m,f);break;case"textarea":At(m,f);break;case"select":var ae=m._wrapperState.wasMultiple;m._wrapperState.wasMultiple=!!f.multiple;var pe=f.value;pe!=null?Tt(m,!!f.multiple,pe,!1):ae!==!!f.multiple&&(f.defaultValue!=null?Tt(m,!!f.multiple,f.defaultValue,!0):Tt(m,!!f.multiple,f.multiple?[]:"",!1))}m[to]=f}catch(ge){Ke(r,r.return,ge)}}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(ge){Ke(r,r.return,ge)}}break;case 3:if(fr(n,r),Cr(r),c&4&&a!==null&&a.memoizedState.isDehydrated)try{Un(n.containerInfo)}catch(ge){Ke(r,r.return,ge)}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=Je())),c&4&&Bm(r);break;case 22:if(le=a!==null&&a.memoizedState!==null,r.mode&1?(Ct=(J=Ct)||le,fr(n,r),Ct=J):fr(n,r),Cr(r),c&8192){if(J=r.memoizedState!==null,(r.stateNode.isHidden=J)&&!le&&(r.mode&1)!==0)for(xe=r,le=r.child;le!==null;){for(ce=xe=le;xe!==null;){switch(ae=xe,pe=ae.child,ae.tag){case 0:case 11:case 14:case 15:ho(4,ae,ae.return);break;case 1:pn(ae,ae.return);var fe=ae.stateNode;if(typeof fe.componentWillUnmount=="function"){c=ae,a=ae.return;try{n=c,fe.props=n.memoizedProps,fe.state=n.memoizedState,fe.componentWillUnmount()}catch(ge){Ke(c,a,ge)}}break;case 5:pn(ae,ae.return);break;case 22:if(ae.memoizedState!==null){Fm(ce);continue}}pe!==null?(pe.return=ae,xe=pe):Fm(ce)}le=le.sibling}e:for(le=null,ce=r;;){if(ce.tag===5){if(le===null){le=ce;try{m=ce.stateNode,J?(f=m.style,typeof f.setProperty=="function"?f.setProperty("display","none","important"):f.display="none"):(A=ce.stateNode,D=ce.memoizedProps.style,w=D!=null&&D.hasOwnProperty("display")?D.display:null,A.style.display=Ns("display",w))}catch(ge){Ke(r,r.return,ge)}}}else if(ce.tag===6){if(le===null)try{ce.stateNode.nodeValue=J?"":ce.memoizedProps}catch(ge){Ke(r,r.return,ge)}}else if((ce.tag!==22&&ce.tag!==23||ce.memoizedState===null||ce===r)&&ce.child!==null){ce.child.return=ce,ce=ce.child;continue}if(ce===r)break e;for(;ce.sibling===null;){if(ce.return===null||ce.return===r)break e;le===ce&&(le=null),ce=ce.return}le===ce&&(le=null),ce.sibling.return=ce.return,ce=ce.sibling}}break;case 19:fr(n,r),Cr(r),c&4&&Bm(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(Rm(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=Im(r);zi(r,f,m);break;case 3:case 4:var w=c.stateNode.containerInfo,A=Im(r);Fi(r,A,w);break;default:throw Error(o(161))}}catch(D){Ke(r,r.return,D)}r.flags&=-3}n&4096&&(r.flags&=-4097)}function ig(r,n,a){xe=r,Om(r)}function Om(r,n,a){for(var c=(r.mode&1)!==0;xe!==null;){var m=xe,f=m.child;if(m.tag===22&&c){var w=m.memoizedState!==null||La;if(!w){var A=m.alternate,D=A!==null&&A.memoizedState!==null||Ct;A=La;var J=Ct;if(La=w,(Ct=D)&&!J)for(xe=m;xe!==null;)w=xe,D=w.child,w.tag===22&&w.memoizedState!==null?zm(m):D!==null?(D.return=w,xe=D):zm(m);for(;f!==null;)xe=f,Om(f),f=f.sibling;xe=m,La=A,Ct=J}Wm(r)}else(m.subtreeFlags&8772)!==0&&f!==null?(f.return=m,xe=f):Wm(r)}}function Wm(r){for(;xe!==null;){var n=xe;if((n.flags&8772)!==0){var a=n.alternate;try{if((n.flags&8772)!==0)switch(n.tag){case 0:case 11:case 15:Ct||Ea(5,n);break;case 1:var c=n.stateNode;if(n.flags&4&&!Ct)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&&Fu(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}Fu(n,w,a)}break;case 5:var A=n.stateNode;if(a===null&&n.flags&4){a=A;var D=n.memoizedProps;switch(n.type){case"button":case"input":case"select":case"textarea":D.autoFocus&&a.focus();break;case"img":D.src&&(a.src=D.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(n.memoizedState===null){var J=n.alternate;if(J!==null){var le=J.memoizedState;if(le!==null){var ce=le.dehydrated;ce!==null&&Un(ce)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(o(163))}Ct||n.flags&512&&Wi(n)}catch(ae){Ke(n,n.return,ae)}}if(n===r){xe=null;break}if(a=n.sibling,a!==null){a.return=n.return,xe=a;break}xe=n.return}}function Fm(r){for(;xe!==null;){var n=xe;if(n===r){xe=null;break}var a=n.sibling;if(a!==null){a.return=n.return,xe=a;break}xe=n.return}}function zm(r){for(;xe!==null;){var n=xe;try{switch(n.tag){case 0:case 11:case 15:var a=n.return;try{Ea(4,n)}catch(D){Ke(n,a,D)}break;case 1:var c=n.stateNode;if(typeof c.componentDidMount=="function"){var m=n.return;try{c.componentDidMount()}catch(D){Ke(n,m,D)}}var f=n.return;try{Wi(n)}catch(D){Ke(n,f,D)}break;case 5:var w=n.return;try{Wi(n)}catch(D){Ke(n,w,D)}}}catch(D){Ke(n,n.return,D)}if(n===r){xe=null;break}var A=n.sibling;if(A!==null){A.return=n.return,xe=A;break}xe=n.return}}var cg=Math.ceil,Ta=_.ReactCurrentDispatcher,Hi=_.ReactCurrentOwner,or=_.ReactCurrentBatchConfig,$e=0,ht=null,ot=null,vt=0,Jt=0,xn=Zr(0),it=0,po=null,Ms=0,Aa=0,Ui=0,xo=null,zt=null,Vi=0,fn=1/0,Wr=null,Pa=!1,qi=null,os=null,Ma=!1,as=null,Ra=0,fo=0,Yi=null,Ia=-1,$a=0;function Mt(){return($e&6)!==0?Je():Ia!==-1?Ia:Ia=Je()}function ls(r){return(r.mode&1)===0?1:($e&2)!==0&&vt!==0?vt&-vt:qf.transition!==null?($a===0&&($a=Id()),$a):(r=We,r!==0||(r=window.event,r=r===void 0?16:Ud(r.type)),r)}function gr(r,n,a,c){if(50<fo)throw fo=0,Yi=null,Error(o(185));On(r,a,c),(($e&2)===0||r!==ht)&&(r===ht&&(($e&2)===0&&(Aa|=a),it===4&&is(r,vt)),Ht(r,c),a===1&&$e===0&&(n.mode&1)===0&&(fn=Je()+500,da&&ts()))}function Ht(r,n){var a=r.callbackNode;Vx(r,n);var c=Vo(r,r===ht?vt:0);if(c===0)a!==null&&Pd(a),r.callbackNode=null,r.callbackPriority=0;else if(n=c&-c,r.callbackPriority!==n){if(a!=null&&Pd(a),n===1)r.tag===0?Vf(Um.bind(null,r)):Eu(Um.bind(null,r)),Ff(function(){($e&6)===0&&ts()}),a=null;else{switch($d(c)){case 1:a=Sl;break;case 4:a=Md;break;case 16:a=Fo;break;case 536870912:a=Rd;break;default:a=Fo}a=Xm(a,Hm.bind(null,r))}r.callbackPriority=n,r.callbackNode=a}}function Hm(r,n){if(Ia=-1,$a=0,($e&6)!==0)throw Error(o(327));var a=r.callbackNode;if(gn()&&r.callbackNode!==a)return null;var c=Vo(r,r===ht?vt:0);if(c===0)return null;if((c&30)!==0||(c&r.expiredLanes)!==0||n)n=Ba(r,c);else{n=c;var m=$e;$e|=2;var f=qm();(ht!==r||vt!==n)&&(Wr=null,fn=Je()+500,Is(r,n));do try{mg();break}catch(A){Vm(r,A)}while(!0);ui(),Ta.current=f,$e=m,ot!==null?n=0:(ht=null,vt=0,n=it)}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,Je()),a;if(n===6)is(r,c);else{if(m=r.current.alternate,(c&30)===0&&!dg(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,Je()),a;switch(r.finishedWork=m,r.finishedLanes=c,n){case 0:case 1:throw Error(o(345));case 2:$s(r,zt,Wr);break;case 3:if(is(r,c),(c&130023424)===c&&(n=Vi+500-Je(),10<n)){if(Vo(r,0)!==0)break;if(m=r.suspendedLanes,(m&c)!==c){Mt(),r.pingedLanes|=r.suspendedLanes&m;break}r.timeoutHandle=ei($s.bind(null,r,zt,Wr),n);break}$s(r,zt,Wr);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=Je()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*cg(c/1960))-c,10<c){r.timeoutHandle=ei($s.bind(null,r,zt,Wr),c);break}$s(r,zt,Wr);break;case 5:$s(r,zt,Wr);break;default:throw Error(o(329))}}}return Ht(r,Je()),r.callbackNode===a?Hm.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 dg(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 Um(r){if(($e&6)!==0)throw Error(o(327));gn();var n=Vo(r,0);if((n&1)===0)return Ht(r,Je()),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,Je()),a;if(a===6)throw Error(o(345));return r.finishedWork=r.current.alternate,r.finishedLanes=n,$s(r,zt,Wr),Ht(r,Je()),null}function Qi(r,n){var a=$e;$e|=1;try{return r(n)}finally{$e=a,$e===0&&(fn=Je()+500,da&&ts())}}function Rs(r){as!==null&&as.tag===0&&($e&6)===0&&gn();var n=$e;$e|=1;var a=or.transition,c=We;try{if(or.transition=null,We=1,r)return r()}finally{We=c,or.transition=a,$e=n,($e&6)===0&&ts()}}function Ji(){Jt=xn.current,Ve(xn)}function Is(r,n){r.finishedWork=null,r.finishedLanes=0;var a=r.timeoutHandle;if(a!==-1&&(r.timeoutHandle=-1,Wf(a)),ot!==null)for(a=ot.return;a!==null;){var c=a;switch(ai(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&ia();break;case 3:mn(),Ve(Ot),Ve(jt),vi();break;case 5:gi(c);break;case 4:mn();break;case 13:Ve(Ye);break;case 19:Ve(Ye);break;case 10:mi(c.type._context);break;case 22:case 23:Ji()}a=a.return}if(ht=r,ot=r=cs(r.current,null),vt=Jt=n,it=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 Vm(r,n){do{var a=ot;try{if(ui(),wa.current=ka,ba){for(var c=Ge.memoizedState;c!==null;){var m=c.queue;m!==null&&(m.pending=null),c=c.next}ba=!1}if(Ps=0,mt=lt=Ge=null,lo=!1,io=0,Hi.current=null,a===null||a.return===null){it=1,po=n,ot=null;break}e:{var f=r,w=a.return,A=a,D=n;if(n=vt,A.flags|=32768,D!==null&&typeof D=="object"&&typeof D.then=="function"){var J=D,le=A,ce=le.tag;if((le.mode&1)===0&&(ce===0||ce===11||ce===15)){var ae=le.alternate;ae?(le.updateQueue=ae.updateQueue,le.memoizedState=ae.memoizedState,le.lanes=ae.lanes):(le.updateQueue=null,le.memoizedState=null)}var pe=fm(w);if(pe!==null){pe.flags&=-257,gm(pe,w,A,f,n),pe.mode&1&&xm(f,J,n),n=pe,D=J;var fe=n.updateQueue;if(fe===null){var ge=new Set;ge.add(D),n.updateQueue=ge}else fe.add(D);break e}else{if((n&1)===0){xm(f,J,n),Xi();break e}D=Error(o(426))}}else if(qe&&A.mode&1){var Xe=fm(w);if(Xe!==null){(Xe.flags&65536)===0&&(Xe.flags|=256),gm(Xe,w,A,f,n),ci(hn(D,A));break e}}f=D=hn(D,A),it!==4&&(it=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 q=hm(f,D,n);Wu(f,q);break e;case 1:A=D;var H=f.type,K=f.stateNode;if((f.flags&128)===0&&(typeof H.getDerivedStateFromError=="function"||K!==null&&typeof K.componentDidCatch=="function"&&(os===null||!os.has(K)))){f.flags|=65536,n&=-n,f.lanes|=n;var ue=pm(f,A,n);Wu(f,ue);break e}}f=f.return}while(f!==null)}Gm(a)}catch(ye){n=ye,ot===a&&a!==null&&(ot=a=a.return);continue}break}while(!0)}function qm(){var r=Ta.current;return Ta.current=ka,r===null?ka:r}function Xi(){(it===0||it===3||it===2)&&(it=4),ht===null||(Ms&268435455)===0&&(Aa&268435455)===0||is(ht,vt)}function Ba(r,n){var a=$e;$e|=2;var c=qm();(ht!==r||vt!==n)&&(Wr=null,Is(r,n));do try{ug();break}catch(m){Vm(r,m)}while(!0);if(ui(),$e=a,Ta.current=c,ot!==null)throw Error(o(261));return ht=null,vt=0,it}function ug(){for(;ot!==null;)Ym(ot)}function mg(){for(;ot!==null&&!$x();)Ym(ot)}function Ym(r){var n=Jm(r.alternate,r,Jt);r.memoizedProps=r.pendingProps,n===null?Gm(r):ot=n,Hi.current=null}function Gm(r){var n=r;do{var a=n.alternate;if(r=n.return,(n.flags&32768)===0){if(a=ng(a,n,Jt),a!==null){ot=a;return}}else{if(a=og(a,n),a!==null){a.flags&=32767,ot=a;return}if(r!==null)r.flags|=32768,r.subtreeFlags=0,r.deletions=null;else{it=6,ot=null;return}}if(n=n.sibling,n!==null){ot=n;return}ot=n=r}while(n!==null);it===0&&(it=5)}function $s(r,n,a){var c=We,m=or.transition;try{or.transition=null,We=1,hg(r,n,a,c)}finally{or.transition=m,We=c}return null}function hg(r,n,a,c){do gn();while(as!==null);if(($e&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(qx(r,f),r===ht&&(ot=ht=null,vt=0),(a.subtreeFlags&2064)===0&&(a.flags&2064)===0||Ma||(Ma=!0,Xm(Fo,function(){return gn(),null})),f=(a.flags&15990)!==0,(a.subtreeFlags&15990)!==0||f){f=or.transition,or.transition=null;var w=We;We=1;var A=$e;$e|=4,Hi.current=null,lg(r,a),Dm(a,r),Mf(Xl),Go=!!Jl,Xl=Jl=null,r.current=a,ig(a),Bx(),$e=A,We=w,or.transition=f}else r.current=a;if(Ma&&(Ma=!1,as=r,Ra=m),f=r.pendingLanes,f===0&&(os=null),Wx(a.stateNode),Ht(r,Je()),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=$d(Ra),n=or.transition,a=We;try{if(or.transition=null,We=16>r?16:r,as===null)var c=!1;else{if(r=as,as=null,Ra=0,($e&6)!==0)throw Error(o(331));var m=$e;for($e|=4,xe=r.current;xe!==null;){var f=xe,w=f.child;if((xe.flags&16)!==0){var A=f.deletions;if(A!==null){for(var D=0;D<A.length;D++){var J=A[D];for(xe=J;xe!==null;){var le=xe;switch(le.tag){case 0:case 11:case 15:ho(8,le,f)}var ce=le.child;if(ce!==null)ce.return=le,xe=ce;else for(;xe!==null;){le=xe;var ae=le.sibling,pe=le.return;if(Mm(le),le===J){xe=null;break}if(ae!==null){ae.return=pe,xe=ae;break}xe=pe}}}var fe=f.alternate;if(fe!==null){var ge=fe.child;if(ge!==null){fe.child=null;do{var Xe=ge.sibling;ge.sibling=null,ge=Xe}while(ge!==null)}}xe=f}}if((f.subtreeFlags&2064)!==0&&w!==null)w.return=f,xe=w;else e:for(;xe!==null;){if(f=xe,(f.flags&2048)!==0)switch(f.tag){case 0:case 11:case 15:ho(9,f,f.return)}var q=f.sibling;if(q!==null){q.return=f.return,xe=q;break e}xe=f.return}}var H=r.current;for(xe=H;xe!==null;){w=xe;var K=w.child;if((w.subtreeFlags&2064)!==0&&K!==null)K.return=w,xe=K;else e:for(w=H;xe!==null;){if(A=xe,(A.flags&2048)!==0)try{switch(A.tag){case 0:case 11:case 15:Ea(9,A)}}catch(ye){Ke(A,A.return,ye)}if(A===w){xe=null;break e}var ue=A.sibling;if(ue!==null){ue.return=A.return,xe=ue;break e}xe=A.return}}if($e=m,ts(),br&&typeof br.onPostCommitFiberRoot=="function")try{br.onPostCommitFiberRoot(zo,r)}catch{}c=!0}return c}finally{We=a,or.transition=n}}return!1}function Km(r,n,a){n=hn(a,n),n=hm(r,n,1),r=ss(r,n,1),n=Mt(),r!==null&&(On(r,1,n),Ht(r,n))}function Ke(r,n,a){if(r.tag===3)Km(r,r,a);else for(;n!==null;){if(n.tag===3){Km(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=pm(n,r,1),n=ss(n,r,1),r=Mt(),n!==null&&(On(n,1,r),Ht(n,r));break}}n=n.return}}function pg(r,n,a){var c=r.pingCache;c!==null&&c.delete(n),n=Mt(),r.pingedLanes|=r.suspendedLanes&a,ht===r&&(vt&a)===a&&(it===4||it===3&&(vt&130023424)===vt&&500>Je()-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=Mt();r=Br(r,n),r!==null&&(On(r,n,a),Ht(r,a))}function xg(r){var n=r.memoizedState,a=0;n!==null&&(a=n.retryLane),Qm(r,a)}function fg(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 Jm;Jm=function(r,n,a){if(r!==null)if(r.memoizedProps!==n.pendingProps||Ot.current)Ft=!0;else{if((r.lanes&a)===0&&(n.flags&128)===0)return Ft=!1,sg(r,n,a);Ft=(r.flags&131072)!==0}else Ft=!1,qe&&(n.flags&1048576)!==0&&Tu(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,jt.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,Wt(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,qe&&f&&oi(n),Pt(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=yg(c),r=pr(c,r),m){case 0:n=Pi(null,n,c,r,a);break e;case 1:n=Nm(null,n,c,r,a);break e;case 11:n=ym(null,n,c,r,a);break e;case 14:n=vm(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),Nm(r,n,c,m,a);case 3:e:{if(km(n),r===null)throw Error(o(387));c=n.pendingProps,f=n.memoizedState,m=f.element,Ou(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=Cm(r,n,c,a,m);break e}else if(c!==m){m=hn(Error(o(424)),n),n=Cm(r,n,c,a,m);break e}else for(Qt=Xr(n.stateNode.containerInfo.firstChild),Kt=n,qe=!0,hr=null,a=Bu(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}Pt(r,n,c,a)}n=n.child}return n;case 5:return zu(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),jm(r,n),Pt(r,n,w,a),n.child;case 6:return r===null&&ii(n),null;case 13:return Sm(r,n,a);case 4:return fi(n,n.stateNode.containerInfo),c=n.pendingProps,r===null?n.child=cn(n,null,c,a):Pt(r,n,c,a),n.child;case 11:return c=n.type,m=n.pendingProps,m=n.elementType===c?m:pr(c,m),ym(r,n,c,m,a);case 7:return Pt(r,n,n.pendingProps,a),n.child;case 8:return Pt(r,n,n.pendingProps.children,a),n.child;case 12:return Pt(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,Fe(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 D=A.firstContext;D!==null;){if(D.context===c){if(f.tag===1){D=Dr(-1,a&-a),D.tag=2;var J=f.updateQueue;if(J!==null){J=J.shared;var le=J.pending;le===null?D.next=D:(D.next=le.next,le.next=D),J.pending=D}}f.lanes|=a,D=f.alternate,D!==null&&(D.lanes|=a),hi(f.return,a,n),A.lanes|=a;break}D=D.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}Pt(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,Pt(r,n,c,a),n.child;case 14:return c=n.type,m=pr(c,n.pendingProps),m=pr(c.type,m),vm(r,n,c,m,a);case 15:return wm(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,Wt(c)?(r=!0,ca(n)):r=!1,un(n,a),um(n,c,m),Ei(n,c,m,a),Mi(null,n,c,!0,r,a);case 19:return Lm(r,n,a);case 22:return bm(r,n,a)}throw Error(o(156,n.tag))};function Xm(r,n){return Ad(r,n)}function gg(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 gg(r,n,a,c)}function Zi(r){return r=r.prototype,!(!r||!r.isReactComponent)}function yg(r){if(typeof r=="function")return Zi(r)?1:0;if(r!=null){if(r=r.$$typeof,r===T)return 11;if(r===Q)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 P:return Bs(a.children,m,f,n);case V:w=8,m|=8;break;case B:return r=ar(12,a,n,m|2),r.elementType=B,r.lanes=f,r;case Z:return r=ar(13,a,n,m),r.elementType=Z,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 z:w=9;break e;case T:w=11;break e;case Q:w=14;break e;case O: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 vg(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,D){return r=new vg(r,n,a,A,D),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 wg(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 Zm(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(Wt(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(Wt(a))return _u(r,a,n)}return n}function e0(r,n,a,c,m,f,w,A,D){return r=rc(a,c,!0,r,m,f,w,A,D),r.context=Zm(null),a=r.current,c=Mt(),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 Wa(r,n,a,c){var m=n.current,f=Mt(),w=ls(m);return a=Zm(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 Fa(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 t0(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){t0(r,n),(r=r.alternate)&&t0(r,n)}function bg(){return null}var r0=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));Wa(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(){Wa(null,r,null,null)}),n[Mr]=null}};function za(r){this._internalRoot=r}za.prototype.unstable_scheduleHydration=function(r){if(r){var n=Od();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&&zd(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 s0(){}function jg(r,n,a,c,m){if(m){if(typeof c=="function"){var f=c;c=function(){var J=Fa(w);f.call(J)}}var w=e0(n,c,r,0,null,!1,!1,"",s0);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 J=Fa(D);A.call(J)}}var D=rc(r,0,!1,null,null,!1,!1,"",s0);return r._reactRootContainer=D,r[Mr]=D.current,Zn(r.nodeType===8?r.parentNode:r),Rs(function(){Wa(n,D,a,c)}),D}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 D=Fa(w);A.call(D)}}Wa(n,w,r,m)}else w=jg(a,n,r,m,c);return Fa(w)}Bd=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,Je()),($e&6)===0&&(fn=Je()+500,ts()))}break;case 13:Rs(function(){var c=Br(r,1);if(c!==null){var m=Mt();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=Mt();gr(n,r,134217728,a)}sc(r,134217728)}},Dd=function(r){if(r.tag===13){var n=ls(r),a=Br(r,n);if(a!==null){var c=Mt();gr(a,r,n,c)}sc(r,n)}},Od=function(){return We},Wd=function(r,n){var a=We;try{return We=r,n()}finally{We=a}},we=function(r,n,a){switch(n){case"input":if(Qe(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));ke(c),Qe(c,m)}}}break;case"textarea":At(r,a);break;case"select":n=a.value,n!=null&&Tt(r,!!a.multiple,n,!1)}},kd=Qi,Cd=Rs;var Ng={usingClientEntryPoint:!1,Events:[ro,rn,la,jd,Nd,Qi]},go={findFiberByHostInstance:Ss,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},kg={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:_.ReactCurrentDispatcher,findHostInstanceByFiber:function(r){return r=Ed(r),r===null?null:r.stateNode},findFiberByHostInstance:go.findFiberByHostInstance||bg,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(kg),br=Va}catch{}}return Ut.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Ng,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 wg(r,n,null,a)},Ut.createRoot=function(r,n){if(!oc(r))throw Error(o(299));var a=!1,c="",m=r0;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=Ed(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=r0;if(a!=null&&(a.unstable_strictMode===!0&&(m=!0),a.identifierPrefix!==void 0&&(f=a.identifierPrefix),a.onRecoverableError!==void 0&&(w=a.onRecoverableError)),n=e0(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=Qi,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 u0;function kh(){if(u0)return ic.exports;u0=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=Mg(),ic.exports}var m0;function Rg(){if(m0)return qa;m0=1;var t=kh();return qa.createRoot=t.createRoot,qa.hydrateRoot=t.hydrateRoot,qa}var Ig=Rg();const $g=Nh(Ig);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 h0="popstate";function Bg(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 Og(s,o,null,t)}function rt(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 Dg(){return Math.random().toString(36).substr(2,8)}function p0(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||Dg()})}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 Og(t,s,o,l){l===void 0&&(l={});let{window:i=document.defaultView,v5Compat:d=!1}=l,u=i.history,h=ms.Pop,p=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 N=v(),j=N==null?null:N-g;g=N,p&&p({action:h,location:S.location,delta:j})}function b(N,j){h=ms.Push;let L=Nc(S.location,N,j);g=v()+1;let M=p0(L,g),_=S.createHref(L);try{u.pushState(M,"",_)}catch($){if($ instanceof DOMException&&$.name==="DataCloneError")throw $;i.location.assign(_)}d&&p&&p({action:h,location:S.location,delta:1})}function k(N,j){h=ms.Replace;let L=Nc(S.location,N,j);g=v();let M=p0(L,g),_=S.createHref(L);u.replaceState(M,"",_),d&&p&&p({action:h,location:S.location,delta:0})}function C(N){let j=i.location.origin!=="null"?i.location.origin:i.location.href,L=typeof N=="string"?N:Xa(N);return L=L.replace(/ $/,"%20"),rt(j,"No window.location.(origin|href) available to create URL for href: "+L),new URL(L,j)}let S={get action(){return h},get location(){return t(i,u)},listen(N){if(p)throw new Error("A history only accepts one active listener");return i.addEventListener(h0,y),p=N,()=>{i.removeEventListener(h0,y),p=null}},createHref(N){return s(i,N)},createURL:C,encodeLocation(N){let j=C(N);return{pathname:j.pathname,search:j.search,hash:j.hash}},push:b,replace:k,go(N){return u.go(N)}};return S}var x0;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(x0||(x0={}));function Wg(t,s,o){return o===void 0&&(o="/"),Fg(t,s,o)}function Fg(t,s,o,l){let i=typeof s=="string"?Ln(s):s,d=Fc(i.pathname||"/",o);if(d==null)return null;let u=Ch(t);zg(u);let h=null;for(let p=0;h==null&&p<u.length;++p){let g=ey(d);h=Jg(u[p],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 p={relativePath:h===void 0?d.path||"":h,caseSensitive:d.caseSensitive===!0,childrenIndex:u,route:d};p.relativePath.startsWith("/")&&(rt(p.relativePath.startsWith(l),'Absolute route path "'+p.relativePath+'" nested under path '+('"'+l+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),p.relativePath=p.relativePath.slice(l.length));let g=gs([l,p.relativePath]),v=o.concat(p);d.children&&d.children.length>0&&(rt(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:Kg(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 p of Sh(d.path))i(d,u,p)}),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(p=>p===""?d:[d,p].join("/"))),i&&h.push(...u),h.map(p=>t.startsWith("/")&&p===""?"/":p)}function zg(t){t.sort((s,o)=>s.score!==o.score?o.score-s.score:Qg(s.routesMeta.map(l=>l.childrenIndex),o.routesMeta.map(l=>l.childrenIndex)))}const Hg=/^:[\w-]+$/,Ug=3,Vg=2,qg=1,Yg=10,Gg=-2,f0=t=>t==="*";function Kg(t,s){let o=t.split("/"),l=o.length;return o.some(f0)&&(l+=Gg),s&&(l+=Vg),o.filter(i=>!f0(i)).reduce((i,d)=>i+(Hg.test(d)?Ug:d===""?qg:Yg),l)}function Qg(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 Jg(t,s,o){let{routesMeta:l}=t,i={},d="/",u=[];for(let h=0;h<l.length;++h){let p=l[h],g=h===l.length-1,v=d==="/"?s:s.slice(d.length)||"/",y=Xg({path:p.relativePath,caseSensitive:p.caseSensitive,end:g},v),b=p.route;if(!y)return null;Object.assign(i,y.params),u.push({params:i,pathname:gs([d,y.pathname]),pathnameBase:oy(gs([d,y.pathnameBase])),route:b}),y.pathnameBase!=="/"&&(d=gs([d,y.pathnameBase]))}return u}function Xg(t,s){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[o,l]=Zg(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 C=h[y];return k&&!C?g[b]=void 0:g[b]=(C||"").replace(/%2F/g,"/"),g},{}),pathname:d,pathnameBase:u,pattern:t}}function Zg(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,p)=>(l.push({paramName:h,isOptional:p!=null}),p?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(l.push({paramName:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):o?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,s?void 0:"i"),l]}function ey(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 Fc(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 ty=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ry=t=>ty.test(t);function sy(t,s){s===void 0&&(s="/");let{pathname:o,search:l="",hash:i=""}=typeof t=="string"?Ln(t):t,d;if(o)if(ry(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=g0(o.substring(1),"/"):d=g0(o,s)}else d=s;return{pathname:d,search:ay(l),hash:ly(i)}}function g0(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 ny(t){return t.filter((s,o)=>o===0||s.route.path&&s.route.path.length>0)}function zc(t,s){let o=ny(t);return s?o.map((l,i)=>i===o.length-1?l.pathname:l.pathnameBase):o.map(l=>l.pathnameBase)}function Hc(t,s,o,l){l===void 0&&(l=!1);let i;typeof t=="string"?i=Ln(t):(i=ko({},t),rt(!i.pathname||!i.pathname.includes("?"),uc("?","pathname","search",i)),rt(!i.pathname||!i.pathname.includes("#"),uc("#","pathname","hash",i)),rt(!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 p=sy(i,h),g=u&&u!=="/"&&u.endsWith("/"),v=(d||u===".")&&o.endsWith("/");return!p.pathname.endsWith("/")&&(g||v)&&(p.pathname+="/"),p}const gs=t=>t.join("/").replace(/\/\/+/g,"/"),oy=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),ay=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,ly=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function iy(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 cy=["get",..._h];new Set(cy);/**
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 Uc=x.createContext(null),dy=x.createContext(null),ws=x.createContext(null),xl=x.createContext(null),Er=x.createContext({outlet:null,matches:[],isDataRoute:!1}),Lh=x.createContext(null);function uy(t,s){let{relative:o}=s===void 0?{}:s;En()||rt(!1);let{basename:l,navigator:i}=x.useContext(ws),{hash:d,pathname:u,search:h}=Th(t,{relative:o}),p=u;return l!=="/"&&(p=u==="/"?l:gs([l,u])),i.createHref({pathname:p,search:h,hash:d})}function En(){return x.useContext(xl)!=null}function bs(){return En()||rt(!1),x.useContext(xl).location}function Eh(t){x.useContext(ws).static||x.useLayoutEffect(t)}function ir(){let{isDataRoute:t}=x.useContext(Er);return t?Sy():my()}function my(){En()||rt(!1);let t=x.useContext(Uc),{basename:s,future:o,navigator:l}=x.useContext(ws),{matches:i}=x.useContext(Er),{pathname:d}=bs(),u=JSON.stringify(zc(i,o.v7_relativeSplatPath)),h=x.useRef(!1);return Eh(()=>{h.current=!0}),x.useCallback(function(g,v){if(v===void 0&&(v={}),!h.current)return;if(typeof g=="number"){l.go(g);return}let y=Hc(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 hy=x.createContext(null);function py(t){let s=x.useContext(Er).outlet;return s&&x.createElement(hy.Provider,{value:t},s)}function yr(){let{matches:t}=x.useContext(Er),s=t[t.length-1];return s?s.params:{}}function Th(t,s){let{relative:o}=s===void 0?{}:s,{future:l}=x.useContext(ws),{matches:i}=x.useContext(Er),{pathname:d}=bs(),u=JSON.stringify(zc(i,l.v7_relativeSplatPath));return x.useMemo(()=>Hc(t,JSON.parse(u),d,o==="path"),[t,u,d,o])}function xy(t,s){return fy(t,s)}function fy(t,s,o,l){En()||rt(!1);let{navigator:i}=x.useContext(ws),{matches:d}=x.useContext(Er),u=d[d.length-1],h=u?u.params:{};u&&u.pathname;let p=u?u.pathnameBase:"/";u&&u.route;let g=bs(),v;if(s){var y;let N=typeof s=="string"?Ln(s):s;p==="/"||(y=N.pathname)!=null&&y.startsWith(p)||rt(!1),v=N}else v=g;let b=v.pathname||"/",k=b;if(p!=="/"){let N=p.replace(/^\//,"").split("/");k="/"+b.replace(/^\//,"").split("/").slice(N.length).join("/")}let C=Wg(t,{pathname:k}),S=by(C&&C.map(N=>Object.assign({},N,{params:Object.assign({},h,N.params),pathname:gs([p,i.encodeLocation?i.encodeLocation(N.pathname).pathname:N.pathname]),pathnameBase:N.pathnameBase==="/"?p:gs([p,i.encodeLocation?i.encodeLocation(N.pathnameBase).pathname:N.pathnameBase])})),d,o,l);return s&&S?x.createElement(xl.Provider,{value:{location:Co({pathname:"/",search:"",hash:"",state:null,key:"default"},v),navigationType:ms.Pop}},S):S}function gy(){let t=Cy(),s=iy(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 x.createElement(x.Fragment,null,x.createElement("h2",null,"Unexpected Application Error!"),x.createElement("h3",{style:{fontStyle:"italic"}},s),o?x.createElement("pre",{style:i},o):null,null)}const yy=x.createElement(gy,null);class vy extends x.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?x.createElement(Er.Provider,{value:this.props.routeContext},x.createElement(Lh.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function wy(t){let{routeContext:s,match:o,children:l}=t,i=x.useContext(Uc);return i&&i.static&&i.staticContext&&(o.route.errorElement||o.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=o.route.id),x.createElement(Er.Provider,{value:s},l)}function by(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||rt(!1),u=u.slice(0,Math.min(u.length,v+1))}let p=!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,C=y.route.loader&&b[y.route.id]===void 0&&(!k||k[y.route.id]===void 0);if(y.route.lazy||C){p=!0,g>=0?u=u.slice(0,g+1):u=[u[0]];break}}}return u.reduceRight((v,y,b)=>{let k,C=!1,S=null,N=null;o&&(k=h&&y.route.id?h[y.route.id]:void 0,S=y.route.errorElement||yy,p&&(g<0&&b===0?(_y("route-fallback"),C=!0,N=null):g===b&&(C=!0,N=y.route.hydrateFallbackElement||null)));let j=s.concat(u.slice(0,b+1)),L=()=>{let M;return k?M=S:C?M=N:y.route.Component?M=x.createElement(y.route.Component,null):y.route.element?M=y.route.element:M=v,x.createElement(wy,{match:y,routeContext:{outlet:v,matches:j,isDataRoute:o!=null},children:M})};return o&&(y.route.ErrorBoundary||y.route.errorElement||b===0)?x.createElement(vy,{location:o.location,revalidation:o.revalidation,component:S,error:k,children:L(),routeContext:{outlet:null,matches:j,isDataRoute:!0}}):L()},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 jy(t){let s=x.useContext(Uc);return s||rt(!1),s}function Ny(t){let s=x.useContext(dy);return s||rt(!1),s}function ky(t){let s=x.useContext(Er);return s||rt(!1),s}function Mh(t){let s=ky(),o=s.matches[s.matches.length-1];return o.route.id||rt(!1),o.route.id}function Cy(){var t;let s=x.useContext(Lh),o=Ny(),l=Mh();return s!==void 0?s:(t=o.errors)==null?void 0:t[l]}function Sy(){let{router:t}=jy(Ah.UseNavigateStable),s=Mh(Ph.UseNavigateStable),o=x.useRef(!1);return Eh(()=>{o.current=!0}),x.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 y0={};function _y(t,s,o){y0[t]||(y0[t]=!0)}function Ly(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function v0(t){let{to:s,replace:o,state:l,relative:i}=t;En()||rt(!1);let{future:d,static:u}=x.useContext(ws),{matches:h}=x.useContext(Er),{pathname:p}=bs(),g=ir(),v=Hc(s,zc(h,d.v7_relativeSplatPath),p,i==="path"),y=JSON.stringify(v);return x.useEffect(()=>g(JSON.parse(y),{replace:o,state:l,relative:i}),[g,y,i,o,l]),null}function Ey(t){return py(t.context)}function ct(t){rt(!1)}function Ty(t){let{basename:s="/",children:o=null,location:l,navigationType:i=ms.Pop,navigator:d,static:u=!1,future:h}=t;En()&&rt(!1);let p=s.replace(/^\/*/,"/"),g=x.useMemo(()=>({basename:p,navigator:d,static:u,future:Co({v7_relativeSplatPath:!1},h)}),[p,h,d,u]);typeof l=="string"&&(l=Ln(l));let{pathname:v="/",search:y="",hash:b="",state:k=null,key:C="default"}=l,S=x.useMemo(()=>{let N=Fc(v,p);return N==null?null:{location:{pathname:N,search:y,hash:b,state:k,key:C},navigationType:i}},[p,v,y,b,k,C,i]);return S==null?null:x.createElement(ws.Provider,{value:g},x.createElement(xl.Provider,{children:o,value:S}))}function Ay(t){let{children:s,location:o}=t;return xy(kc(s),o)}new Promise(()=>{});function kc(t,s){s===void 0&&(s=[]);let o=[];return x.Children.forEach(t,(l,i)=>{if(!x.isValidElement(l))return;let d=[...s,i];if(l.type===x.Fragment){o.push.apply(o,kc(l.props.children,d));return}l.type!==ct&&rt(!1),!l.props.index||!l.props.children||rt(!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 Py(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 My(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Ry(t,s){return t.button===0&&(!s||s==="_self")&&!My(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 Iy(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 $y=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],By="6";try{window.__reactRouterVersion=By}catch{}const Dy="startTransition",w0=Tg[Dy];function Oy(t){let{basename:s,children:o,future:l,window:i}=t,d=x.useRef();d.current==null&&(d.current=Bg({window:i,v5Compat:!0}));let u=d.current,[h,p]=x.useState({action:u.action,location:u.location}),{v7_startTransition:g}=l||{},v=x.useCallback(y=>{g&&w0?w0(()=>p(y)):p(y)},[p,g]);return x.useLayoutEffect(()=>u.listen(v),[u,v]),x.useEffect(()=>Ly(l),[l]),x.createElement(Ty,{basename:s,children:o,location:h.location,navigationType:h.action,navigator:u,future:l})}const Wy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Fy=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,je=x.forwardRef(function(s,o){let{onClick:l,relative:i,reloadDocument:d,replace:u,state:h,target:p,to:g,preventScrollReset:v,viewTransition:y}=s,b=Py(s,$y),{basename:k}=x.useContext(ws),C,S=!1;if(typeof g=="string"&&Fy.test(g)&&(C=g,Wy))try{let M=new URL(window.location.href),_=g.startsWith("//")?new URL(M.protocol+g):new URL(g),$=Fc(_.pathname,k);_.origin===M.origin&&$!=null?g=$+_.search+_.hash:S=!0}catch{}let N=uy(g,{relative:i}),j=zy(g,{replace:u,state:h,target:p,preventScrollReset:v,relative:i,viewTransition:y});function L(M){l&&l(M),M.defaultPrevented||j(M)}return x.createElement("a",Cc({},b,{href:C||N,onClick:S||d?l:L,ref:o,target:p}))});var b0;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(b0||(b0={}));var j0;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(j0||(j0={}));function zy(t,s){let{target:o,replace:l,state:i,preventScrollReset:d,relative:u,viewTransition:h}=s===void 0?{}:s,p=ir(),g=bs(),v=Th(t,{relative:u});return x.useCallback(y=>{if(Ry(y,o)){y.preventDefault();let b=l!==void 0?l:Xa(g)===Xa(v);p(t,{replace:b,state:i,preventScrollReset:d,relative:u,viewTransition:h})}},[g,p,v,l,i,o,t,d,u,h])}function Hy(t){let s=x.useRef(Sc(t)),o=x.useRef(!1),l=bs(),i=x.useMemo(()=>Iy(l.search,o.current?null:s.current),[l.search]),d=ir(),u=x.useCallback((h,p)=>{const g=Sc(typeof h=="function"?h(i):h);o.current=!0,d("?"+g,p)},[d,i]);return[i,u]}const N0=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:()=>p,subscribe:g=>(o.add(g),()=>o.delete(g))},p=s=t(l,i,h);return h},Uy=(t=>t?N0(t):N0),Vy=t=>t;function qy(t,s=Vy){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 k0=t=>{const s=Uy(t),o=l=>qy(s,l);return Object.assign(o,s),o},Yy=(t=>t?k0(t):k0),Us="/api";class Tn extends Error{constructor(s,o,l){super(s),this.status=o,this.code=l,this.name="APIError"}}async function ne(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 ne("/health")}async function _c(){return ne("/projects")}async function Vs(t){return ne(`/projects/${t}`)}async function Gy(t){return ne("/projects",{method:"POST",body:JSON.stringify(t)})}async function Ky(t){return ne(`/projects/${t}`,{method:"DELETE"})}async function Qy(t="^e2e-",s=!0){return ne("/projects/cleanup",{method:"POST",body:JSON.stringify({pattern:t,dry_run:s})})}async function Vc(t){return ne(`/projects/${t}/loops`)}async function C0(t,s){return ne(`/projects/${t}/loops/${s}`)}async function Ih(t,s){return ne(`/projects/${t}/loops/${s}/status`)}async function Lc(t,s,o){return ne(`/projects/${t}/loops/${s}/start`,{method:"POST",body:JSON.stringify(o||{})})}async function Jy(t,s){return ne(`/projects/${t}/loops/${s}/phases`)}async function Xy(t,s){return ne(`/projects/${t}/loops/${s}/stop`,{method:"POST"})}async function Zy(t,s){return ne(`/projects/${t}/loops/${s}/pause`,{method:"POST"})}async function ev(t,s){return ne(`/projects/${t}/loops/${s}/resume`,{method:"POST"})}async function tv(t,s){return ne(`/projects/${t}/loops/${s}`,{method:"DELETE"})}async function rv(t,s){return ne(`/projects/${t}/loops/${s}/config`)}async function sv(t,s,o){return ne(`/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 ne(`/projects/${t}/items${l?`?${l}`:""}`)}async function nv(t,s){return ne(`/projects/${t}/items/${s}`)}async function qc(t,s){return ne(`/projects/${t}/items`,{method:"POST",body:JSON.stringify(s)})}async function Yc(t,s,o){return ne(`/projects/${t}/items/${s}`,{method:"PATCH",body:JSON.stringify(o)})}async function ov(t,s,o){const l=await nv(t,s);return qc(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 ne(`/projects/${t}/items/${s}`,{method:"DELETE"})}async function av(t){return ne(`/projects/${t}/items/stats`)}async function lv(t){const s=t?`?path=${encodeURIComponent(t)}`:"";return ne(`/filesystem/browse${s}`)}async function S0(t,s){return ne(`/projects/${t}/loops/${s}/ready-check`)}async function iv(t,s){return ne(`/projects/${t}/loops/${s}/ready-check`,{method:"POST"})}async function cv(t,s,o,l){return ne(`/projects/${t}/loops/${s}/ready-check/answers`,{method:"POST",body:JSON.stringify({questions:o,answers:l})})}async function dv(t,s){return ne(`/projects/${t}/runs`)}async function uv(t,s){return ne(`/projects/${t}/runs/${s}`)}async function mv(){return ne("/templates")}async function hv(t){return ne(`/templates/${t}`)}async function pv(t){return ne(`/step-prompts/${t}`)}async function xv(){return ne("/projects/permission-templates")}async function fv(t,s){return ne(`/projects/${t}/loops/${s}/permissions`)}async function _0(t,s,o){return ne(`/projects/${t}/loops/${s}/permissions`,{method:"PUT",body:JSON.stringify(o)})}async function gv(t,s){return ne(`/projects/${t}/loops/${s}/permissions`,{method:"DELETE"})}async function yv(t,s){return ne(`/projects/${t}/loops/${s}/inputs`)}async function vv(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(()=>({})),p=((d=h.error)==null?void 0:d.message)||h.detail||i.statusText;throw new Tn(p,i.status,(u=h.error)==null?void 0:u.code)}return i.json()}async function wv(t,s,o,l,i){return ne(`/projects/${t}/loops/${s}/inputs/paste`,{method:"POST",body:JSON.stringify({content:o,filename:l,tag:i})})}async function bv(t,s,o){return ne(`/projects/${t}/loops/${s}/inputs/${encodeURIComponent(o)}`,{method:"DELETE"})}async function jv(t,s,o){return ne(`/projects/${t}/loops/${s}/preview`,{method:"POST",body:JSON.stringify(o||{})})}async function mc(t,s){const o=s?`?path=${encodeURIComponent(s)}`:"";return ne(`/projects/${t}/files/browse${o}`)}async function Nv(t){const s=t?`?loop_type=${encodeURIComponent(t)}`:"";return ne(`/projects/input-templates${s}`)}async function kv(t){return ne(`/projects/input-templates/${encodeURIComponent(t)}`)}async function Cv(t,s,o,l){return ne(`/projects/${t}/loops/${s}/inputs/apply-template`,{method:"POST",body:JSON.stringify({template_id:o,custom_filename:l})})}async function Sv(t,s,o){return ne(`/projects/${t}/loops/${s}/inputs/validate?loop_type=${encodeURIComponent(o)}`)}async function Bh(t=!1){return ne(`/auth/accounts${t?"?include_inactive=true":""}`)}async function _v(t){const s=t?`?expected_email=${encodeURIComponent(t)}`:"";return ne(`/auth/accounts/add${s}`,{method:"POST"})}async function Lv(t){return ne(`/auth/flow/${t}`)}async function Ev(t,s){return ne(`/auth/accounts/${t}`,{method:"PATCH",body:JSON.stringify(s)})}async function Tv(t){return ne(`/auth/accounts/${t}`,{method:"DELETE"})}async function Av(t){return ne(`/auth/accounts/${t}/set-default`,{method:"POST"})}async function Pv(t){return ne(`/auth/accounts/${t}/refresh`,{method:"POST"})}async function Mv(t){return ne(`/auth/accounts/${t}/refresh-usage`,{method:"POST"})}async function Rv(t){return ne(`/auth/accounts/${t}/validate`,{method:"POST"})}async function Iv(){return ne("/auth/accounts/refresh-all-usage",{method:"POST"})}async function $v(t){return ne(`/auth/projects/${t}/account`)}async function L0(t,s){return ne(`/auth/projects/${t}/account`,{method:"POST",body:JSON.stringify(s)})}async function Bv(t){return ne(`/auth/projects/${t}/account`,{method:"DELETE"})}async function Dv(t){return ne(`/auth/projects/${t}/effective-account`)}async function Ov(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)),ne(`/logs?${s}`)}async function Wv(){return ne("/logs/stats")}async function E0(t,s,o=!1){return ne(`/projects/${t}/loops/${s}/resources${o?"?include_content=true":""}`)}async function Fv(t,s,o){return ne(`/projects/${t}/loops/${s}/resources`,{method:"POST",body:JSON.stringify(o)})}async function T0(t,s,o,l){return ne(`/projects/${t}/loops/${s}/resources/${o}`,{method:"PATCH",body:JSON.stringify(l)})}async function zv(t,s,o){return ne(`/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 ne(`/projects/${t}/workflows${l?`?${l}`:""}`)}async function Po(t,s){return ne(`/projects/${t}/workflows/${s}`)}async function Hv(t,s){return ne(`/projects/${t}/workflows`,{method:"POST",body:JSON.stringify(s)})}async function Uv(t,s,o){return ne(`/projects/${t}/workflows/${s}`,{method:"PATCH",body:JSON.stringify(o)})}async function Vv(t,s){return ne(`/projects/${t}/workflows/${s}`,{method:"DELETE"})}async function qv(t,s){return ne(`/projects/${t}/workflows/${s}/archive`,{method:"POST"})}async function Yv(t,s){return ne(`/projects/${t}/workflows/${s}/restore`,{method:"POST"})}async function Gv(t,s){return ne(`/projects/${t}/workflows/${s}/start`,{method:"POST"})}async function Dh(t,s){return ne(`/projects/${t}/workflows/${s}/stop`,{method:"POST"})}async function Oh(t,s,o){return ne(`/projects/${t}/workflows/${s}/run-specific-step/${o}`,{method:"POST"})}async function Kv(t,s,o){return ne(`/projects/${t}/workflows/${s}/advance`,{method:"POST",body:JSON.stringify(o||{})})}async function Qv(t,s,o){return ne(`/projects/${t}/workflows/${s}/steps`,{method:"POST",body:JSON.stringify(o)})}async function Jv(t,s,o,l){return ne(`/projects/${t}/workflows/${s}/steps/${o}`,{method:"PATCH",body:JSON.stringify(l)})}async function Xv(t,s,o){return ne(`/projects/${t}/workflows/${s}/steps/${o}/archive`,{method:"POST"})}async function Zv(t,s,o){return ne(`/projects/${t}/workflows/${s}/steps/${o}/restore`,{method:"POST"})}async function e2(t,s){return ne(`/projects/${t}/workflows/${s}/steps/archived`)}async function Wh(t,s,o){return ne(`/projects/${t}/workflows/${s}/steps/${o}`,{method:"DELETE"})}async function t2(t,s,o){return ne(`/projects/${t}/workflows/${s}/steps/reorder`,{method:"POST",body:JSON.stringify({step_ids:o})})}async function r2(t,s){return ne(`/projects/${t}/workflows/${s}/planning`)}async function s2(t,s,o){return ne(`/projects/${t}/workflows/${s}/planning/message`,{method:"POST",body:JSON.stringify({content:o})})}async function n2(t,s,o){return ne(`/projects/${t}/workflows/${s}/planning/complete`,{method:"POST",body:JSON.stringify(o||{})})}function o2(t,s){return new EventSource(`${Us}/projects/${t}/workflows/${s}/planning/stream`)}async function fl(t,s,o){const i=new URLSearchParams().toString();return ne(`/projects/${t}/workflows/${s}/resources${i?`?${i}`:""}`)}async function Gc(t,s,o){return ne(`/projects/${t}/workflows/${s}/resources`,{method:"POST",body:JSON.stringify(o)})}async function So(t,s,o,l){return ne(`/projects/${t}/workflows/${s}/resources/${o}`,{method:"PATCH",body:JSON.stringify(l)})}async function Fh(t,s,o){return ne(`/projects/${t}/workflows/${s}/resources/${o}`,{method:"DELETE"})}async function a2(t,s,o,l){const d=new URLSearchParams().toString();return ne(`/projects/${t}/workflows/${s}/resources/${o}/versions${d?`?${d}`:""}`)}async function l2(t,s,o,l){return ne(`/projects/${t}/workflows/${s}/resources/${o}/versions/${l}/restore`,{method:"POST"})}async function zh(t,s,o){return ne(`/projects/${t}/workflows/${s}/resources/import/${o}`,{method:"POST"})}async function i2(t,s,o){return ne(`/projects/${t}/workflows/${s}/steps/${o}/resources`)}async function c2(t,s,o,l){return ne(`/projects/${t}/workflows/${s}/steps/${o}/resources`,{method:"POST",body:JSON.stringify(l)})}async function d2(t,s,o,l){return ne(`/projects/${t}/workflows/${s}/steps/${o}/resources/${l}`,{method:"DELETE"})}async function u2(t,s,o,l){return ne(`/projects/${t}/workflows/${s}/steps/${o}/resources/disable/${l}`,{method:"POST"})}async function m2(t,s,o,l){return ne(`/projects/${t}/workflows/${s}/steps/${o}/resources/disable/${l}`,{method:"DELETE"})}async function h2(t,s,o){return ne(`/projects/${t}/workflows/${s}/steps/${o}/preview-prompt`)}async function Kc(t,s){const l=new URLSearchParams().toString();return ne(`/projects/${t}/project-resources${l?`?${l}`:""}`)}async function p2(t,s){return ne(`/projects/${t}/project-resources`,{method:"POST",body:JSON.stringify(s)})}async function A0(t,s,o){return ne(`/projects/${t}/project-resources/${s}`,{method:"PATCH",body:JSON.stringify(o)})}async function x2(t,s){return ne(`/projects/${t}/project-resources/${s}`,{method:"DELETE"})}async function f2(t){return ne(`/projects/${t}/settings`)}async function g2(t,s){return ne(`/projects/${t}/settings`,{method:"PATCH",body:JSON.stringify(s)})}async function y2(t){return ne(`/projects/${t}/import-formats`)}async function v2(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()}),p=await fetch(`${Us}/projects/${t}/import-jsonl?${h}`,{method:"POST",body:u});if(!p.ok){const y=await p.json().catch(()=>({})),b=((g=y.error)==null?void 0:g.message)||y.detail||p.statusText;throw new Tn(b,p.status,(v=y.error)==null?void 0:v.code)}return p.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 Jc(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 w2(t,s){return ne(`/projects/${t}/workflows/${s}/export/preview`)}async function b2(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 j2(t,s,o={}){var u,h,p,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=((p=v.error)==null?void 0:p.message)||v.detail||d.statusText;throw new Tn(y,d.status,(g=v.error)==null?void 0:g.code)}return d.json()}const Tr=Yy(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 N2(){const{slug:t,workflowId:s}=yr(),o=bs(),{projects:l,projectsLoading:i,projectsError:d,loadProjects:u}=Tr(),[h,p]=x.useState(null),[g,v]=x.useState({});x.useEffect(()=>{u()},[u]),x.useEffect(()=>{t&&p(t)},[t]),x.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(je,{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,C=t===b.slug,N=(g[b.slug]||[]).filter(j=>j.status==="active"||j.status==="draft"||j.status==="paused");return e.jsxs("li",{children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("button",{onClick:()=>p(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(je,{to:`/projects/${b.slug}`,className:`flex-1 block px-2 py-2 rounded-md text-sm transition-colors ${C&&!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:[N.length>0?N.slice(0,5).map(j=>{const L=j.steps.find(M=>M.step_number===j.current_step);return e.jsxs(je,{to:`/projects/${b.slug}/workflows/${j.id}`,className:`block px-2 py-1.5 rounded text-xs transition-colors ${s===j.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 ${j.status==="active"?"bg-green-400 animate-pulse":"bg-gray-500"}`}),e.jsx("span",{className:"truncate",children:j.name})]}),L&&j.status==="active"&&e.jsxs("div",{className:"ml-4 mt-0.5 text-[10px] text-gray-500 truncate",children:["Step ",j.current_step,": ",L.name]})]},j.id)}):e.jsx("div",{className:"px-2 py-1 text-xs text-gray-500",children:"No active workflows"}),N.length>5&&e.jsxs(je,{to:`/projects/${b.slug}`,className:"block px-2 py-1 text-xs text-gray-500 hover:text-gray-400",children:["+",N.length-5," more"]}),e.jsx(je,{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(je,{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(je,{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(je,{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 k2(){return e.jsxs("div",{className:"flex h-screen bg-gray-900",children:[e.jsx(N2,{}),e.jsx("main",{className:"flex-1 overflow-auto",children:e.jsx(Ey,{})})]})}function C2({initialPath:t,onSelect:s,onCancel:o}){const[l,i]=x.useState(t||""),[d,u]=x.useState([]),[h,p]=x.useState(!1),[g,v]=x.useState(null),[y,b]=x.useState(!0),[k,C]=x.useState(null);x.useEffect(()=>{async function j(){b(!0),C(null);try{const L=await lv(l||void 0);i(L.path),u(L.directories),p(L.canGoUp),v(L.parent)}catch(L){C(L instanceof Error?L.message:"Failed to browse directory")}finally{b(!1)}}j()},[l]);const S=j=>{i(`${l}/${j}`)},N=()=>{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: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-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(j=>e.jsxs("button",{onClick:()=>S(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-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:j})]},j))]})}),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 S2({onClose:t,onSuccess:s}){const[o,l]=x.useState(""),[i,d]=x.useState(""),[u,h]=x.useState(!1),[p,g]=x.useState(!1),[v,y]=x.useState(null),b=async C=>{if(C.preventDefault(),!o.trim()){y("Path is required");return}g(!0),y(null);try{await Gy({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=C=>{if(l(C),h(!1),!i){const S=C.split("/");d(S[S.length-1]||"")}};return u?e.jsx(C2,{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:C=>l(C.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:C=>d(C.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:p,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:p||!o.trim(),className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500 disabled:opacity-50",children:p?"Adding...":"Add Project"})]})]})]})})}function _2({content:t,children:s,position:o="top",delay:l=200,id:i}){const[d,u]=x.useState(!1),[h,p]=x.useState({x:0,y:0}),g=x.useRef(null),v=x.useRef(null),y=x.useRef(null),b=x.useId(),k=i||`tooltip-${b}`,C=()=>{y.current=setTimeout(()=>{u(!0)},l)},S=()=>{y.current&&clearTimeout(y.current),u(!1)};return x.useEffect(()=>{if(d&&g.current&&v.current){const N=g.current.getBoundingClientRect(),j=v.current.getBoundingClientRect();let L=0,M=0;switch(o){case"top":L=N.left+N.width/2-j.width/2,M=N.top-j.height-8;break;case"bottom":L=N.left+N.width/2-j.width/2,M=N.bottom+8;break;case"left":L=N.left-j.width-8,M=N.top+N.height/2-j.height/2;break;case"right":L=N.right+8,M=N.top+N.height/2-j.height/2;break}const _=8;L=Math.max(_,Math.min(L,window.innerWidth-j.width-_)),M=Math.max(_,Math.min(M,window.innerHeight-j.height-_)),p({x:L,y:M})}},[d,o]),x.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]),e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:g,onMouseEnter:C,onMouseLeave:S,onFocus:C,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 L2={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(_2,{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:L2[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 E2=[{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 T2({onDismiss:t,storageKey:s="ralphx-onboarding-dismissed"}){const[o,l]=x.useState(!1);x.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:E2.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 Ec={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 Tc({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 Hh(t){return t?zs(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}function A2(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 Xc(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 Zc(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),p=Math.floor(h/24);return d<60?"just now":u<60?`${u}m ago`:h<48?`${h}h ago`:p<7?`${p}d ago`:Xc(t)}function P2(){const{projects:t,projectsLoading:s,projectsError:o,loadProjects:l}=Tr(),[i,d]=x.useState(null),[u,h]=x.useState(!1),[p,g]=x.useState(!1);return x.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(T2,{}),p&&e.jsx(S2,{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(Tc,{icon:Ec.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(je,{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: ",Xc(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 Uh(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 M2(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(Uh(t,s))}function R2(t,s,o){M2(t,s),s.set(t,o)}function I2(t,s,o){return t.set(Uh(t,s),o),o}const $2=100,ve={},B2=()=>{ve.previousActiveElement instanceof HTMLElement?(ve.previousActiveElement.focus(),ve.previousActiveElement=null):document.body&&document.body.focus()},D2=t=>new Promise(s=>{if(!t)return s();const o=window.scrollX,l=window.scrollY;ve.restoreFocusTimeout=setTimeout(()=>{B2(),s()},$2),window.scrollTo(o,l)}),Vh="swal2-",O2=["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"],te=O2.reduce((t,s)=>(t[s]=Vh+s,t),{}),W2=["success","warning","info","question","error"],el=W2.reduce((t,s)=>(t[s]=Vh+s,t),{}),qh="SweetAlert2:",ed=t=>t.charAt(0).toUpperCase()+t.slice(1),It=t=>{console.warn(`${qh} ${typeof t=="object"?t.join(" "):t}`)},qs=t=>{console.error(`${qh} ${t}`)},R0=[],F2=t=>{R0.includes(t)||(R0.push(t),It(t))},Yh=(t,s=null)=>{F2(`"${t}" is deprecated and will be removed in the next major release.${s?` Use "${s}" instead.`:""}`)},gl=t=>typeof t=="function"?t():t,td=t=>t&&typeof t.toPromise=="function",Mo=t=>td(t)?t.toPromise():Promise.resolve(t),rd=t=>t&&Promise.resolve(t)===t,$t=()=>document.body.querySelector(`.${te.container}`),Ro=t=>{const s=$t();return s?s.querySelector(t):null},Zt=t=>Ro(`.${t}`),Oe=()=>Zt(te.popup),An=()=>Zt(te.icon),z2=()=>Zt(te["icon-content"]),Gh=()=>Zt(te.title),sd=()=>Zt(te["html-container"]),Kh=()=>Zt(te.image),nd=()=>Zt(te["progress-steps"]),yl=()=>Zt(te["validation-message"]),Lr=()=>Ro(`.${te.actions} .${te.confirm}`),Pn=()=>Ro(`.${te.actions} .${te.cancel}`),Ys=()=>Ro(`.${te.actions} .${te.deny}`),H2=()=>Zt(te["input-label"]),Mn=()=>Ro(`.${te.loader}`),Io=()=>Zt(te.actions),Qh=()=>Zt(te.footer),vl=()=>Zt(te["timer-progress-bar"]),od=()=>Zt(te.close),U2=`
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
- `,ad=()=>{const t=Oe();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"),p=parseInt(u.getAttribute("tabindex")||"0");return h>p?1:h<p?-1:0}),l=t.querySelectorAll(U2),i=Array.from(l).filter(d=>d.getAttribute("tabindex")!=="-1");return[...new Set(o.concat(i))].filter(d=>qt(d))},ld=()=>Ur(document.body,te.shown)&&!Ur(document.body,te["toast-shown"])&&!Ur(document.body,te["no-backdrop"]),wl=()=>{const t=Oe();return t?Ur(t,te.toast):!1},V2=()=>{const t=Oe();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},q2=(t,s)=>{Array.from(t.classList).forEach(o=>{!Object.values(te).includes(o)&&!Object.values(el).includes(o)&&!Object.values(s.showClass||{}).includes(o)&&t.classList.remove(o)})},Xt=(t,s,o)=>{if(q2(t,s),!s.customClass)return;const l=s.customClass[o];if(l){if(typeof l!="string"&&!l.forEach){It(`Invalid type of customClass.${o}! Expected string or iterable object, got "${typeof l}"`);return}De(t,l)}},bl=(t,s)=>{if(!s)return null;switch(s){case"select":case"textarea":case"file":return t.querySelector(`.${te.popup} > .${te[s]}`);case"checkbox":return t.querySelector(`.${te.popup} > .${te.checkbox} input`);case"radio":return t.querySelector(`.${te.popup} > .${te.radio} input:checked`)||t.querySelector(`.${te.popup} > .${te.radio} input:first-child`);case"range":return t.querySelector(`.${te.popup} > .${te.range} input`);default:return t.querySelector(`.${te.popup} > .${te.input}`)}},Jh=t=>{if(t.focus(),t.type!=="file"){const s=t.value;t.value="",t.value=s}},Xh=(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)}))},De=(t,s)=>{Xh(t,s,!0)},lr=(t,s)=>{Xh(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}},Ws=(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)},xt=(t,s="flex")=>{t&&(t.style.display=s)},St=t=>{t&&(t.style.display="none")},id=(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?xt(t,o):St(t)},qt=t=>!!(t&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)),Y2=()=>!qt(Lr())&&!qt(Ys())&&!qt(Pn()),Ac=t=>t.scrollHeight>t.clientHeight,G2=(t,s)=>{let o=t;for(;o&&o!==s;){if(Ac(o))return!0;o=o.parentElement}return!1},Zh=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},cd=(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))},K2=()=>{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}%`},Q2=()=>typeof window>"u"||typeof document>"u",J2=`
86
- <div aria-labelledby="${te.title}" aria-describedby="${te["html-container"]}" class="${te.popup}" tabindex="-1">
87
- <button type="button" class="${te.close}"></button>
88
- <ul class="${te["progress-steps"]}"></ul>
89
- <div class="${te.icon}"></div>
90
- <img class="${te.image}" />
91
- <h2 class="${te.title}" id="${te.title}"></h2>
92
- <div class="${te["html-container"]}" id="${te["html-container"]}"></div>
93
- <input class="${te.input}" id="${te.input}" />
94
- <input type="file" class="${te.file}" />
95
- <div class="${te.range}">
96
- <input type="range" />
97
- <output></output>
98
- </div>
99
- <select class="${te.select}" id="${te.select}"></select>
100
- <div class="${te.radio}"></div>
101
- <label class="${te.checkbox}">
102
- <input type="checkbox" id="${te.checkbox}" />
103
- <span class="${te.label}"></span>
104
- </label>
105
- <textarea class="${te.textarea}" id="${te.textarea}"></textarea>
106
- <div class="${te["validation-message"]}" id="${te["validation-message"]}"></div>
107
- <div class="${te.actions}">
108
- <div class="${te.loader}"></div>
109
- <button type="button" class="${te.confirm}"></button>
110
- <button type="button" class="${te.deny}"></button>
111
- <button type="button" class="${te.cancel}"></button>
112
- </div>
113
- <div class="${te.footer}"></div>
114
- <div class="${te["timer-progress-bar-container"]}">
115
- <div class="${te["timer-progress-bar"]}"></div>
116
- </div>
117
- </div>
118
- `.replace(/(^|\n)\s*/g,""),X2=()=>{const t=$t();return t?(t.remove(),lr([document.documentElement,document.body],[te["no-backdrop"],te["toast-shown"],te["has-column"]]),!0):!1},Ds=()=>{ve.currentInstance&&ve.currentInstance.resetValidationMessage()},Z2=()=>{const t=Oe();if(!t)return;const s=ps(t,te.input),o=ps(t,te.file),l=t.querySelector(`.${te.range} input`),i=t.querySelector(`.${te.range} output`),d=ps(t,te.select),u=t.querySelector(`.${te.checkbox} input`),h=ps(t,te.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})},ew=t=>{if(typeof t=="string"){const s=document.querySelector(t);if(!s)throw new Error(`Target element "${t}" not found`);return s}return t},tw=t=>{const s=Oe();s&&(s.setAttribute("role",t.toast?"alert":"dialog"),s.setAttribute("aria-live",t.toast?"polite":"assertive"),t.toast||s.setAttribute("aria-modal","true"))},rw=t=>{window.getComputedStyle(t).direction==="rtl"&&(De($t(),te.rtl),ve.isRTL=!0)},sw=t=>{const s=X2();if(Q2()){qs("SweetAlert2 requires document to initialize");return}const o=document.createElement("div");o.className=te.container,s&&De(o,te["no-transition"]),er(o,J2),o.dataset.swal2Theme=t.theme;const l=ew(t.target||"body");l.appendChild(o),t.topLayer&&(o.setAttribute("popover",""),o.showPopover()),tw(t),rw(l),Z2()},dd=(t,s)=>{t instanceof HTMLElement?s.appendChild(t):typeof t=="object"?nw(t,s):t&&er(s,t)},nw=(t,s)=>{"jquery"in t?ow(s,t):er(s,t.toString())},ow=(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))},aw=(t,s)=>{const o=Io(),l=Mn();!o||!l||(!s.showConfirmButton&&!s.showDenyButton&&!s.showCancelButton?St(o):xt(o),Xt(o,s,"actions"),lw(o,l,s),er(l,s.loaderHtml||""),Xt(l,s,"loader"))};function lw(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),iw(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 iw(t,s,o,l){if(!l.buttonsStyling){lr([t,s,o],te.styled);return}De([t,s,o],te.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=ed(s);$o(t,o[`show${l}Button`],"inline-block"),er(t,o[`${s}ButtonText`]||""),t.setAttribute("aria-label",o[`${s}ButtonAriaLabel`]||""),t.className=te[s],Xt(t,o,`${s}Button`)}const cw=(t,s)=>{const o=od();o&&(er(o,s.closeButtonHtml||""),Xt(o,s,"closeButton"),$o(o,s.showCloseButton),o.setAttribute("aria-label",s.closeButtonAriaLabel||""))},dw=(t,s)=>{const o=$t();o&&(uw(o,s.backdrop),mw(o,s.position),hw(o,s.grow),Xt(o,s,"container"))};function uw(t,s){typeof s=="string"?t.style.background=s:s||De([document.documentElement,document.body],te["no-backdrop"])}function mw(t,s){s&&(s in te?De(t,te[s]):(It('The "position" parameter is not valid, defaulting to "center"'),De(t,te.center)))}function hw(t,s){s&&De(t,te[`grow-${s}`])}var ze={innerParams:new WeakMap,domCache:new WeakMap};const pw=["input","file","range","select","radio","checkbox","textarea"],xw=(t,s)=>{const o=Oe();if(!o)return;const l=ze.innerParams.get(t),i=!l||s.input!==l.input;pw.forEach(d=>{const u=ps(o,te[d]);u&&(yw(d,s.inputAttributes),u.className=te[d],i&&St(u))}),s.input&&(i&&fw(s),vw(s))},fw=t=>{if(!t.input)return;if(!Ze[t.input]){qs(`Unexpected type of input! Expected ${Object.keys(Ze).join(" | ")}, got "${t.input}"`);return}const s=ep(t.input);if(!s)return;const o=Ze[t.input](s,t);xt(s),t.inputAutoFocus&&setTimeout(()=>{Jh(o)})},gw=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)}},yw=(t,s)=>{const o=Oe();if(!o)return;const l=bl(o,t);if(l){gw(l);for(const i in s)l.setAttribute(i,s[i])}},vw=t=>{if(!t.input)return;const s=ep(t.input);s&&Xt(s,t,"input")},ud=(t,s)=>{!t.placeholder&&s.inputPlaceholder&&(t.placeholder=s.inputPlaceholder)},Bo=(t,s,o)=>{if(o.inputLabel){const l=document.createElement("label"),i=te["input-label"];l.setAttribute("for",t.id),l.className=i,typeof o.customClass=="object"&&De(l,o.customClass.inputLabel),l.innerText=o.inputLabel,s.insertAdjacentElement("beforebegin",l)}},ep=t=>{const s=Oe();if(s)return ps(s,te[t]||te.input)},tl=(t,s)=>{["string","number"].includes(typeof s)?t.value=`${s}`:rd(s)||It(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof s}"`)},Ze={};Ze.text=Ze.email=Ze.password=Ze.number=Ze.tel=Ze.url=Ze.search=Ze.date=Ze["datetime-local"]=Ze.time=Ze.week=Ze.month=(t,s)=>{const o=t;return tl(o,s.inputValue),Bo(o,o,s),ud(o,s),o.type=s.input,o};Ze.file=(t,s)=>{const o=t;return Bo(o,o,s),ud(o,s),o};Ze.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};Ze.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};Ze.radio=t=>{const s=t;return s.textContent="",t};Ze.checkbox=(t,s)=>{const o=Oe();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};Ze.textarea=(t,s)=>{const o=t;tl(o,s.inputValue),ud(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=Oe();if(!i)return;const d=parseInt(window.getComputedStyle(i).width),u=()=>{if(!document.body.contains(o))return;const h=o.offsetWidth+l(o),p=Oe();p&&(h>d?p.style.width=`${h}px`:Ws(p,"width",s.width))};new MutationObserver(u).observe(o,{attributes:!0,attributeFilter:["style"]})}}),o};const ww=(t,s)=>{const o=sd();o&&(id(o),Xt(o,s,"htmlContainer"),s.html?(dd(s.html,o),xt(o,"block")):s.text?(o.textContent=s.text,xt(o,"block")):St(o),xw(t,s))},bw=(t,s)=>{const o=Qh();o&&(id(o),$o(o,!!s.footer,"block"),s.footer&&dd(s.footer,o),Xt(o,s,"footer"))},jw=(t,s)=>{const o=ze.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){St(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}"`),St(l);return}xt(l),B0(l,s),$0(l,s),De(l,s.showClass&&s.showClass.icon),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",tp)},$0=(t,s)=>{for(const[o,l]of Object.entries(el))s.icon!==o&&lr(t,l);De(t,s.icon&&el[s.icon]),Cw(t,s),tp(),Xt(t,s,"icon")},tp=()=>{const t=Oe();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},Nw=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
- `,kw=`
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=Nw(s),o=o.replace(/ style=".*?"/g,"")):s.icon==="error"?l=kw:s.icon&&(l=D0({question:"?",warning:"!",info:"i"}[s.icon])),o.trim()!==l.trim()&&er(t,l)},Cw=(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="${te["icon-content"]}">${t}</div>`,Sw=(t,s)=>{const o=Kh();if(o){if(!s.imageUrl){St(o);return}xt(o,""),o.setAttribute("src",s.imageUrl),o.setAttribute("alt",s.imageAlt||""),Ws(o,"width",s.imageWidth),Ws(o,"height",s.imageHeight),o.className=te.image,Xt(o,s,"image")}};let md=!1,rp=0,sp=0,np=0,op=0;const _w=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)},Lw=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=Oe();if(!s)return;const o=An();if(t.target===s||o&&o.contains(t.target)){md=!0;const l=ap(t);rp=l.clientX,sp=l.clientY,np=parseInt(s.style.insetInlineStart)||0,op=parseInt(s.style.insetBlockStart)||0,De(s,"swal2-dragging")}},sl=t=>{const s=Oe();if(s&&md){let{clientX:o,clientY:l}=ap(t);const i=o-rp;s.style.insetInlineStart=`${np+(ve.isRTL?-i:i)}px`,s.style.insetBlockStart=`${op+(l-sp)}px`}},nl=()=>{const t=Oe();md=!1,lr(t,"swal2-dragging")},ap=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}},Ew=(t,s)=>{const o=$t(),l=Oe();if(!(!o||!l)){if(s.toast){Ws(o,"width",s.width),l.style.width="100%";const i=Mn();i&&l.insertBefore(i,An())}else Ws(l,"width",s.width);Ws(l,"padding",s.padding),s.color&&(l.style.color=s.color),s.background&&(l.style.background=s.background),St(yl()),Tw(l,s),s.draggable&&!s.toast?(De(l,te.draggable),_w(l)):(lr(l,te.draggable),Lw(l))}},Tw=(t,s)=>{const o=s.showClass||{};t.className=`${te.popup} ${qt(t)?o.popup:""}`,s.toast?(De([document.documentElement,document.body],te["toast-shown"]),De(t,te.toast)):De(t,te.modal),Xt(t,s,"popup"),typeof s.customClass=="string"&&De(t,s.customClass),s.icon&&De(t,te[`icon-${s.icon}`])},Aw=(t,s)=>{const o=nd();if(!o)return;const{progressSteps:l,currentProgressStep:i}=s;if(!l||l.length===0||i===void 0){St(o);return}xt(o),o.textContent="",i>=l.length&&It("Invalid currentProgressStep parameter, it should be less than progressSteps.length (currentProgressStep like JS arrays starts from 0)"),l.forEach((d,u)=>{const h=Pw(d);if(o.appendChild(h),u===i&&De(h,te["active-progress-step"]),u!==l.length-1){const p=Mw(s);o.appendChild(p)}})},Pw=t=>{const s=document.createElement("li");return De(s,te["progress-step"]),er(s,t),s},Mw=t=>{const s=document.createElement("li");return De(s,te["progress-step-line"]),t.progressStepsDistance&&Ws(s,"width",t.progressStepsDistance),s},Rw=(t,s)=>{const o=Gh();o&&(id(o),$o(o,!!(s.title||s.titleText),"block"),s.title&&dd(s.title,o),s.titleText&&(o.innerText=s.titleText),Xt(o,s,"title"))},lp=(t,s)=>{var o;Ew(t,s),dw(t,s),Aw(t,s),jw(t,s),Sw(t,s),Rw(t,s),cw(t,s),ww(t,s),aw(t,s),bw(t,s);const l=Oe();typeof s.didRender=="function"&&l&&s.didRender(l),(o=ve.eventEmitter)===null||o===void 0||o.emit("didRender",l)},Iw=()=>qt(Oe()),ip=()=>{var t;return(t=Lr())===null||t===void 0?void 0:t.click()},$w=()=>{var t;return(t=Ys())===null||t===void 0?void 0:t.click()},Bw=()=>{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"}),cp=t=>{if(t.keydownTarget&&t.keydownHandlerAdded&&t.keydownHandler){const s=t.keydownHandler;t.keydownTarget.removeEventListener("keydown",s,{capture:t.keydownListenerCapture}),t.keydownHandlerAdded=!1}},Dw=(t,s,o)=>{if(cp(t),!s.toast){const l=d=>Ww(s,d,o);t.keydownHandler=l;const i=s.keydownListenerCapture?window:Oe();if(i){t.keydownTarget=i,t.keydownListenerCapture=s.keydownListenerCapture;const d=l;t.keydownTarget.addEventListener("keydown",d,{capture:t.keydownListenerCapture}),t.keydownHandlerAdded=!0}}},Pc=(t,s)=>{var o;const l=ad();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=Oe())===null||o===void 0||o.focus()},dp=["ArrowRight","ArrowDown"],Ow=["ArrowLeft","ArrowUp"],Ww=(t,s,o)=>{t&&(s.isComposing||s.keyCode===229||(t.stopKeydownPropagation&&s.stopPropagation(),s.key==="Enter"?Fw(s,t):s.key==="Tab"?zw(s):[...dp,...Ow].includes(s.key)?Hw(s.key):s.key==="Escape"&&Uw(s,t,o)))},Fw=(t,s)=>{if(!gl(s.allowEnterKey))return;const o=Oe();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;ip(),t.preventDefault()}},zw=t=>{const s=t.target,o=ad();let l=-1;for(let i=0;i<o.length;i++)if(s===o[i]){l=i;break}t.shiftKey?Pc(l,-1):Pc(l,1),t.stopPropagation(),t.preventDefault()},Hw=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=dp.includes(t)?"nextElementSibling":"previousElementSibling";let h=document.activeElement;if(h){for(let p=0;p<s.children.length;p++){if(h=h[u],!h)return;if(h instanceof HTMLButtonElement&&qt(h))break}h instanceof HTMLButtonElement&&h.focus()}},Uw=(t,s,o)=>{t.preventDefault(),gl(s.allowEscapeKey)&&o(Rn.esc)};var Cn={swalPromiseResolve:new WeakMap,swalPromiseReject:new WeakMap};const Vw=()=>{const t=$t();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"))})},up=()=>{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")})},mp=typeof window<"u"&&!!window.GestureEvent,qw=()=>{if(mp&&!Ur(document.body,te.iosfix)){const t=document.body.scrollTop;document.body.style.top=`${t*-1}px`,De(document.body,te.iosfix),Yw()}},Yw=()=>{const t=$t();if(!t)return;let s;t.ontouchstart=o=>{s=Gw(o)},t.ontouchmove=o=>{s&&(o.preventDefault(),o.stopPropagation())}},Gw=t=>{const s=t.target,o=$t(),l=sd();return!o||!l||Kw(t)||Qw(t)?!1:s===o||!Ac(o)&&s instanceof HTMLElement&&!G2(s,l)&&s.tagName!=="INPUT"&&s.tagName!=="TEXTAREA"&&!(Ac(l)&&l.contains(s))},Kw=t=>!!(t.touches&&t.touches.length&&t.touches[0].touchType==="stylus"),Qw=t=>t.touches&&t.touches.length>1,Jw=()=>{if(Ur(document.body,te.iosfix)){const t=parseInt(document.body.style.top,10);lr(document.body,te.iosfix),document.body.style.top="",document.body.scrollTop=t*-1}},Xw=()=>{const t=document.createElement("div");t.className=te["scrollbar-measure"],document.body.appendChild(t);const s=t.getBoundingClientRect().width-t.clientWidth;return document.body.removeChild(t),s};let kn=null;const Zw=t=>{kn===null&&(document.body.scrollHeight>window.innerHeight||t==="scroll")&&(kn=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right")),document.body.style.paddingRight=`${kn+Xw()}px`)},eb=()=>{kn!==null&&(document.body.style.paddingRight=`${kn}px`,kn=null)};function hp(t,s,o,l){wl()?O0(t,l):(D2(o).then(()=>O0(t,l)),cp(ve)),mp?(s.setAttribute("style","display:none !important"),s.removeAttribute("class"),s.innerHTML=""):s.remove(),ld()&&(eb(),Jw(),up()),tb()}function tb(){lr([document.documentElement,document.body],[te.shown,te["height-auto"],te["no-backdrop"],te["toast-shown"]])}function xs(t){t=sb(t);const s=Cn.swalPromiseResolve.get(this),o=rb(this);this.isAwaitingPromise?t.isDismissed||(Do(this),s(t)):o&&s(t)}const rb=t=>{const s=Oe();if(!s)return!1;const o=ze.innerParams.get(t);if(!o||Ur(s,o.hideClass.popup))return!1;lr(s,o.showClass.popup),De(s,o.hideClass.popup);const l=$t();return lr(l,o.showClass.backdrop),De(l,o.hideClass.backdrop),nb(t,s,o),!0};function pp(t){const s=Cn.swalPromiseReject.get(this);Do(this),s&&s(t)}const Do=t=>{t.isAwaitingPromise&&(delete t.isAwaitingPromise,ze.innerParams.get(t)||t._destroy())},sb=t=>typeof t>"u"?{isConfirmed:!1,isDenied:!1,isDismissed:!0}:Object.assign({isConfirmed:!1,isDenied:!1,isDismissed:!1},t),nb=(t,s,o)=>{var l;const i=$t(),d=Zh(s);typeof o.willClose=="function"&&o.willClose(s),(l=ve.eventEmitter)===null||l===void 0||l.emit("willClose",s),d&&i?ob(t,s,i,!!o.returnFocus,o.didClose):i&&hp(t,i,!!o.returnFocus,o.didClose)},ob=(t,s,o,l,i)=>{ve.swalCloseEventFinishedCallback=hp.bind(null,t,o,l,i);const d=function(u){if(u.target===s){var h;(h=ve.swalCloseEventFinishedCallback)===null||h===void 0||h.call(ve),delete ve.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=ve.eventEmitter)===null||o===void 0||o.emit("didClose"),t._destroy&&t._destroy()})},Sn=t=>{let s=Oe();if(s||new tt,s=Oe(),!s)return;const o=Mn();wl()?St(An()):ab(s,t),xt(o),s.setAttribute("data-loading","true"),s.setAttribute("aria-busy","true"),s.focus()},ab=(t,s)=>{const o=Io(),l=Mn();!o||!l||(!s&&qt(Lr())&&(s=Lr()),xt(o),s&&(St(s),l.setAttribute("data-button-to-replace",s.className),o.insertBefore(l,s)),De([t,o],te.loading))},lb=(t,s)=>{s.input==="select"||s.input==="radio"?mb(t,s):["text","email","number","tel","textarea"].some(o=>o===s.input)&&(td(s.inputValue)||rd(s.inputValue))&&(Sn(Lr()),hb(t,s))},ib=(t,s)=>{const o=t.getInput();if(!o)return null;switch(s.input){case"checkbox":return cb(o);case"radio":return db(o);case"file":return ub(o);default:return s.inputAutoTrim?o.value.trim():o.value}},cb=t=>t.checked?1:0,db=t=>t.checked?t.value:null,ub=t=>t.files&&t.files.length?t.getAttribute("multiple")!==null?t.files:t.files[0]:null,mb=(t,s)=>{const o=Oe();if(!o)return;const l=i=>{s.input==="select"?pb(o,ol(i),s):s.input==="radio"&&xb(o,ol(i),s)};td(s.inputOptions)||rd(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}`)},hb=(t,s)=>{const o=t.getInput();o&&(St(o),Mo(s.inputValue).then(l=>{o.value=s.input==="number"?`${parseFloat(l)||0}`:`${l}`,xt(o),o.focus(),t.hideLoading()}).catch(l=>{qs(`Error in inputValue promise: ${l}`),o.value="",xt(o),o.focus(),t.hideLoading()}))};function pb(t,s,o){const l=ps(t,te.select);if(!l)return;const i=(d,u,h)=>{const p=document.createElement("option");p.value=h,er(p,u),p.selected=xp(h,o.inputValue),d.appendChild(p)};s.forEach(d=>{const u=d[0],h=d[1];if(Array.isArray(h)){const p=document.createElement("optgroup");p.label=u,p.disabled=!1,l.appendChild(p),h.forEach(g=>i(p,g[1],g[0]))}else i(l,h,u)}),l.focus()}function xb(t,s,o){const l=ps(t,te.radio);if(!l)return;s.forEach(d=>{const u=d[0],h=d[1],p=document.createElement("input"),g=document.createElement("label");p.type="radio",p.name=te.radio,p.value=u,xp(u,o.inputValue)&&(p.checked=!0);const v=document.createElement("span");er(v,h),v.className=te.label,g.appendChild(p),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},xp=(t,s)=>!!s&&s!==null&&s!==void 0&&s.toString()===t.toString(),fb=t=>{const s=ze.innerParams.get(t);t.disableButtons(),s.input?fp(t,"confirm"):pd(t,!0)},gb=t=>{const s=ze.innerParams.get(t);t.disableButtons(),s.returnInputValueOnDeny?fp(t,"deny"):hd(t,!1)},yb=(t,s)=>{t.disableButtons(),s(Rn.cancel)},fp=(t,s)=>{const o=ze.innerParams.get(t);if(!o.input){qs(`The "input" parameter is needed to be set when using returnInputValueOn${ed(s)}`);return}const l=t.getInput(),i=ib(t,o);o.inputValidator?vb(t,i,s):l&&!l.checkValidity()?(t.enableButtons(),t.showValidationMessage(o.validationMessage||l.validationMessage)):s==="deny"?hd(t,i):pd(t,i)},vb=(t,s,o)=>{const l=ze.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"?hd(t,s):pd(t,s)})},hd=(t,s)=>{const o=ze.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=>gp(t,i))):t.close({isDenied:!0,value:s})},W0=(t,s)=>{t.close({isConfirmed:!0,value:s})},gp=(t,s)=>{t.rejectPromise(s)},pd=(t,s)=>{const o=ze.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)):W0(t,typeof i>"u"?s:i)}).catch(i=>gp(t,i))):W0(t,s)};function al(){const t=ze.innerParams.get(this);if(!t)return;const s=ze.domCache.get(this);St(s.loader),wl()?t.icon&&xt(An()):wb(s),lr([s.popup,s.actions],te.loading),s.popup.removeAttribute("aria-busy"),s.popup.removeAttribute("data-loading"),s.confirmButton.disabled=!1,s.denyButton.disabled=!1,s.cancelButton.disabled=!1}const wb=t=>{const s=t.loader.getAttribute("data-button-to-replace"),o=s?t.popup.getElementsByClassName(s):[];o.length?xt(o[0],"inline-block"):Y2()&&St(t.actions)};function yp(){const t=ze.innerParams.get(this),s=ze.domCache.get(this);return s?bl(s.popup,t.input):null}function vp(t,s,o){const l=ze.domCache.get(t);s.forEach(i=>{l[i].disabled=o})}function wp(t,s){const o=Oe();if(!(!o||!t))if(t.type==="radio"){const l=o.querySelectorAll(`[name="${te.radio}"]`);for(let i=0;i<l.length;i++)l[i].disabled=s}else t.disabled=s}function bp(){vp(this,["confirmButton","denyButton","cancelButton"],!1)}function jp(){vp(this,["confirmButton","denyButton","cancelButton"],!0)}function Np(){wp(this.getInput(),!1)}function kp(){wp(this.getInput(),!0)}function Cp(t){const s=ze.domCache.get(this),o=ze.innerParams.get(this);er(s.validationMessage,t),s.validationMessage.className=te["validation-message"],o.customClass&&o.customClass.validationMessage&&De(s.validationMessage,o.customClass.validationMessage),xt(s.validationMessage);const l=this.getInput();l&&(l.setAttribute("aria-invalid","true"),l.setAttribute("aria-describedby",te["validation-message"]),Jh(l),De(l,te.inputerror))}function Sp(){const t=ze.domCache.get(this);t.validationMessage&&St(t.validationMessage);const s=this.getInput();s&&(s.removeAttribute("aria-invalid"),s.removeAttribute("aria-describedby"),lr(s,te.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},bb=["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"],jb={allowEnterKey:void 0},Nb=["allowOutsideClick","allowEnterKey","backdrop","draggable","focusConfirm","focusDeny","focusCancel","returnFocus","heightAuto","keydownListenerCapture"],_p=t=>Object.prototype.hasOwnProperty.call(fs,t),Lp=t=>bb.indexOf(t)!==-1,Ep=t=>jb[t],kb=t=>{_p(t)||It(`Unknown parameter "${t}"`)},Cb=t=>{Nb.includes(t)&&It(`The parameter "${t}" is incompatible with toasts`)},Sb=t=>{const s=Ep(t);s&&Yh(t,s)},Tp=t=>{t.backdrop===!1&&t.allowOutsideClick&&It('"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)&&It(`Invalid theme "${t.theme}"`);for(const s in t)kb(s),t.toast&&Cb(s),Sb(s)};function Ap(t){const s=$t(),o=Oe(),l=ze.innerParams.get(this);if(!o||Ur(o,l.hideClass.popup)){It("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=_b(t),d=Object.assign({},l,i);Tp(d),s&&(s.dataset.swal2Theme=d.theme),lp(this,d),ze.innerParams.set(this,d),Object.defineProperties(this,{params:{value:Object.assign({},this.params,t),writable:!1,enumerable:!0}})}const _b=t=>{const s={};return Object.keys(t).forEach(o=>{if(Lp(o)){const l=t;s[o]=l[o]}else It(`Invalid parameter to update: ${o}`)}),s};function Pp(){var t;const s=ze.domCache.get(this),o=ze.innerParams.get(this);if(!o){Mp(this);return}s.popup&&ve.swalCloseEventFinishedCallback&&(ve.swalCloseEventFinishedCallback(),delete ve.swalCloseEventFinishedCallback),typeof o.didDestroy=="function"&&o.didDestroy(),(t=ve.eventEmitter)===null||t===void 0||t.emit("didDestroy"),Lb(this)}const Lb=t=>{Mp(t),delete t.params,delete ve.keydownHandler,delete ve.keydownTarget,delete ve.currentInstance},Mp=t=>{t.isAwaitingPromise?(xc(ze,t),t.isAwaitingPromise=!0):(xc(Cn,t),xc(ze,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 Eb=Object.freeze({__proto__:null,_destroy:Pp,close:xs,closeModal:xs,closePopup:xs,closeToast:xs,disableButtons:jp,disableInput:kp,disableLoading:al,enableButtons:bp,enableInput:Np,getInput:yp,handleAwaitingPromise:Do,hideLoading:al,rejectPromise:pp,resetValidationMessage:Sp,showValidationMessage:Cp,update:Ap});const Tb=(t,s,o)=>{t.toast?Ab(t,s,o):(Mb(s),Rb(s),Ib(t,s,o))},Ab=(t,s,o)=>{s.popup.onclick=()=>{t&&(Pb(t)||t.timer||t.input)||o(Rn.close)}},Pb=t=>!!(t.showConfirmButton||t.showDenyButton||t.showCancelButton||t.showCloseButton);let ll=!1;const Mb=t=>{t.popup.onmousedown=()=>{t.container.onmouseup=function(s){t.container.onmouseup=()=>{},s.target===t.container&&(ll=!0)}}},Rb=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)}}},Ib=(t,s,o)=>{s.container.onclick=l=>{if(ll){ll=!1;return}l.target===s.container&&gl(t.allowOutsideClick)&&o(Rn.backdrop)}},$b=t=>typeof t=="object"&&t.jquery,F0=t=>t instanceof Element||$b(t),Bb=t=>{const s={};return typeof t[0]=="object"&&!F0(t[0])?Object.assign(s,t[0]):["title","html","icon"].forEach((o,l)=>{const i=t[l];typeof i=="string"||F0(i)?s[o]=i:i!==void 0&&qs(`Unexpected type of ${o}! Expected "string" or "Element", got ${typeof i}`)}),s};function Db(...t){return new this(...t)}function Ob(t){class s extends this{_main(l,i){return super._main(l,Object.assign({},t,i))}}return s}const Wb=()=>ve.timeout&&ve.timeout.getTimerLeft(),Rp=()=>{if(ve.timeout)return K2(),ve.timeout.stop()},Ip=()=>{if(ve.timeout){const t=ve.timeout.start();return cd(t),t}},Fb=()=>{const t=ve.timeout;return t&&(t.running?Rp():Ip())},zb=t=>{if(ve.timeout){const s=ve.timeout.increase(t);return cd(s,!0),s}},Hb=()=>!!(ve.timeout&&ve.timeout.isRunning());let z0=!1;const Mc={};function Ub(t="data-swal-template"){Mc[t]=this,z0||(document.body.addEventListener("click",Vb),z0=!0)}const Vb=t=>{for(let s=t.target;s&&s!==document;s=s.parentNode)for(const o in Mc){const l=s.getAttribute&&s.getAttribute(o);if(l){Mc[o].fire({template:l});return}}};class qb{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={}}}ve.eventEmitter=new qb;const Yb=(t,s)=>{ve.eventEmitter&&ve.eventEmitter.on(t,s)},Gb=(t,s)=>{ve.eventEmitter&&ve.eventEmitter.once(t,s)},Kb=(t,s)=>{if(ve.eventEmitter){if(!t){ve.eventEmitter.reset();return}s?ve.eventEmitter.removeListener(t,s):ve.eventEmitter.removeAllListeners(t)}};var Qb=Object.freeze({__proto__:null,argsToParams:Bb,bindClickHandler:Ub,clickCancel:Bw,clickConfirm:ip,clickDeny:$w,enableLoading:Sn,fire:Db,getActions:Io,getCancelButton:Pn,getCloseButton:od,getConfirmButton:Lr,getContainer:$t,getDenyButton:Ys,getFocusableElements:ad,getFooter:Qh,getHtmlContainer:sd,getIcon:An,getIconContent:z2,getImage:Kh,getInputLabel:H2,getLoader:Mn,getPopup:Oe,getProgressSteps:nd,getTimerLeft:Wb,getTimerProgressBar:vl,getTitle:Gh,getValidationMessage:yl,increaseTimer:zb,isDeprecatedParameter:Ep,isLoading:V2,isTimerRunning:Hb,isUpdatableParameter:Lp,isValidParameter:_p,isVisible:Iw,mixin:Ob,off:Kb,on:Yb,once:Gb,resumeTimer:Ip,showLoading:Sn,stopTimer:Rp,toggleTimer:Fb});class Jb{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 $p=["swal-title","swal-html","swal-footer"],Xb=t=>{const s=typeof t.template=="string"?document.querySelector(t.template):t.template;if(!s)return{};const o=s.content;return aj(o),Object.assign(Zb(o),ej(o),tj(o),rj(o),sj(o),nj(o),oj(o,$p))},Zb=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},ej=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},tj=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${ed(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},rj=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},sj=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},nj=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},oj=(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},aj=t=>{const s=$p.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)||It(`Unrecognized element <${l}>`)})},Hs=(t,s)=>{Array.from(t.attributes).forEach(o=>{s.indexOf(o.name)===-1&&It([`Unrecognized attribute "${o.name}" on <${t.tagName.toLowerCase()}>.`,`${s.length?`Allowed attributes are: ${s.join(", ")}`:"To set the value, use HTML within the element."}`])})},Bp=10,lj=t=>{var s,o;const l=$t(),i=Oe();if(!l||!i)return;typeof t.willOpen=="function"&&t.willOpen(i),(s=ve.eventEmitter)===null||s===void 0||s.emit("willOpen",i);const u=window.getComputedStyle(document.body).overflowY;if(dj(l,i,t),setTimeout(()=>{ij(l,i)},Bp),ld()&&(cj(l,t.scrollbarPadding!==void 0?t.scrollbarPadding:!1,u),Vw()),!wl()&&!ve.previousActiveElement&&(ve.previousActiveElement=document.activeElement),typeof t.didOpen=="function"){const h=t.didOpen;setTimeout(()=>h(i))}(o=ve.eventEmitter)===null||o===void 0||o.emit("didOpen",i)},il=t=>{const s=Oe();if(!s||t.target!==s)return;const o=$t();o&&(s.removeEventListener("animationend",il),s.removeEventListener("transitionend",il),o.style.overflowY="auto",lr(o,te["no-transition"]))},ij=(t,s)=>{Zh(s)?(t.style.overflowY="hidden",s.addEventListener("animationend",il),s.addEventListener("transitionend",il)):t.style.overflowY="auto"},cj=(t,s,o)=>{qw(),s&&o!=="hidden"&&Zw(o),setTimeout(()=>{t.scrollTop=0})},dj=(t,s,o)=>{var l;(l=o.showClass)!==null&&l!==void 0&&l.backdrop&&De(t,o.showClass.backdrop),o.animation?(s.style.setProperty("opacity","0","important"),xt(s,"grid"),setTimeout(()=>{var i;(i=o.showClass)!==null&&i!==void 0&&i.popup&&De(s,o.showClass.popup),s.style.removeProperty("opacity")},Bp)):xt(s,"grid"),De([document.documentElement,document.body],te.shown),o.heightAuto&&o.backdrop&&!o.toast&&De([document.documentElement,document.body],te["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 uj(t){t.inputValidator||(t.input==="email"&&(t.inputValidator=H0.email),t.input==="url"&&(t.inputValidator=H0.url))}function mj(t){(!t.target||typeof t.target=="string"&&!document.querySelector(t.target)||typeof t.target!="string"&&!t.target.appendChild)&&(It('Target parameter is not valid, defaulting to "body"'),t.target="body")}function hj(t){uj(t),t.showLoaderOnConfirm&&!t.preConfirm&&It(`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`),mj(t),typeof t.title=="string"&&(t.title=t.title.split(`
132
- `).join("<br />")),sw(t)}let Sr;var Ya=new WeakMap;class st{constructor(...s){if(R2(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,I2(Ya,this,this._main(Sr.params))}_main(s,o={}){if(Tp(Object.assign({},o,s)),ve.currentInstance){const d=Cn.swalPromiseResolve.get(ve.currentInstance),{isAwaitingPromise:u}=ve.currentInstance;ve.currentInstance._destroy(),u||d({isDismissed:!0}),ld()&&up()}ve.currentInstance=Sr;const l=xj(s,o);hj(l),Object.freeze(l),ve.timeout&&(ve.timeout.stop(),delete ve.timeout),clearTimeout(ve.restoreFocusTimeout);const i=fj(Sr);return lp(Sr,l),ze.innerParams.set(Sr,l),pj(Sr,i,l)}then(s){return M0(Ya,this).then(s)}finally(s){return M0(Ya,this).finally(s)}}const pj=(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=()=>{fb(t)},s.denyButton.onclick=()=>{gb(t)},s.cancelButton.onclick=()=>{yb(t,d)},s.closeButton.onclick=()=>{d(Rn.close)},Tb(o,s,d),Dw(ve,o,d),lb(t,o),lj(o),gj(ve,o,d),yj(s,o),setTimeout(()=>{s.container.scrollTop=0})}),xj=(t,s)=>{const o=Xb(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},fj=t=>{const s={popup:Oe(),container:$t(),actions:Io(),confirmButton:Lr(),denyButton:Ys(),cancelButton:Pn(),loader:Mn(),closeButton:od(),validationMessage:yl(),progressSteps:nd()};return ze.domCache.set(t,s),s},gj=(t,s,o)=>{const l=vl();St(l),s.timer&&(t.timeout=new Jb(()=>{o("timer"),delete t.timeout},s.timer),s.timerProgressBar&&l&&(xt(l),Xt(l,s,"timerProgressBar"),setTimeout(()=>{t.timeout&&t.timeout.running&&cd(s.timer)})))},yj=(t,s)=>{if(!s.toast){if(!gl(s.allowEnterKey)){Yh("allowEnterKey"),bj();return}vj(t)||wj(t,s)||Pc(-1,1)}},vj=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},wj=(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,bj=()=>{document.activeElement instanceof HTMLElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur()};st.prototype.disableButtons=jp;st.prototype.enableButtons=bp;st.prototype.getInput=yp;st.prototype.disableInput=kp;st.prototype.enableInput=Np;st.prototype.hideLoading=al;st.prototype.disableLoading=al;st.prototype.showValidationMessage=Cp;st.prototype.resetValidationMessage=Sp;st.prototype.close=xs;st.prototype.closePopup=xs;st.prototype.closeModal=xs;st.prototype.closeToast=xs;st.prototype.rejectPromise=pp;st.prototype.update=Ap;st.prototype._destroy=Pp;Object.assign(st,Qb);Object.keys(Eb).forEach(t=>{st[t]=function(...s){if(Sr&&Sr[t])return Sr[t](...s)}});st.DismissReason=Rn;st.version="11.26.17";const tt=st;tt.default=tt;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 jj=[{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=x.useRef(null),[i,d]=x.useState(null),[u,h]=x.useState(null),[p,g]=x.useState(null),[v,y]=x.useState("name"),[b,k]=x.useState(""),[C,S]=x.useState(!1),[N,j]=x.useState(""),[L,M]=x.useState(null),_=z=>{g(z),y("name"),k(""),S(!1),j(""),M(null),h(null)},$=()=>{g(null),y("name"),h(null)},I=()=>{b.trim()&&(p!=null&&p.requiresInput?y("input"):V())},P=z=>{var W;const T=(W=z.target.files)==null?void 0:W[0];if(!T)return;const Z=new FileReader;Z.onload=Q=>{var R;const O=(R=Q.target)==null?void 0:R.result;j(O),M(T.name)},Z.readAsText(T)},V=async()=>{if(!p||!b.trim())return;if(p.requiresInput&&!N.trim()){h(`Please provide your ${p.requiresInput==="design_doc"?"design document":"user stories"}`);return}d(p.templateId),y("creating"),h(null);let z=null;try{if(z=await Hv(t,{template_id:p.templateId,name:b.trim(),config:C?{architecture_first:!0}:void 0}),N.trim()&&p.requiresInput){const T=p.requiresInput==="design_doc"?"design_doc":"input_file",Z=p.requiresInput==="design_doc"?"Design Document":"Imported Stories";try{await Gc(t,z.id,{resource_type:T,name:Z,content:N.trim(),source:"upload"})}catch(W){console.error("Failed to upload resource:",W),g(null),s==null||s(),o(`/projects/${t}/workflows/${z.id}`);return}}g(null),s==null||s(),o(`/projects/${t}/workflows/${z.id}`)}catch(T){h(T instanceof Error?T.message:"Failed to create workflow"),z||y(p.requiresInput?"input":"name")}finally{d(null)}},B=()=>p&&p.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:jj.map(z=>e.jsx("button",{onClick:()=>_(z),disabled:i!==null,className:`p-6 rounded-lg border text-left transition-all group ${z.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 ${z.recommended?"bg-primary-600":"bg-gray-700"}`,children:e.jsx("span",{className:z.recommended?"text-white":"text-gray-300",children:z.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 ${z.recommended?"text-white group-hover:text-primary-300":"text-white group-hover:text-gray-200"}`,children:z.title}),z.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:z.description}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:z.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"})})]})},z.templateId))}),p&&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 ${p.title} Workflow`:v==="input"&&p.requiresInput==="design_doc"?"Upload Design Document":v==="input"&&p.requiresInput==="stories"?"Import User Stories":"Creating Workflow..."}),B()>1&&v!=="creating"&&e.jsxs("span",{className:"text-sm text-gray-400",children:["Step ",U()," of ",B()]})]}),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:z=>k(z.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:z=>{z.key==="Enter"&&b.trim()&&I()}})]}),p.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:C,onChange:z=>S(z.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:$,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:p.requiresInput?"Next":"Create Workflow"})]})]}),v==="input"&&p.requiresInput&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-gray-400",children:p.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 z;return(z=l.current)==null?void 0:z.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:P,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"})}),L?e.jsx("p",{className:"text-sm text-primary-400",children:L}):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:N,onChange:z=>{j(z.target.value),M(null)},placeholder:p.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"}),p.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:$,className:"px-4 py-2 text-sm text-gray-400 hover:text-white",children:"Cancel"}),e.jsx("button",{onClick:V,disabled:!N.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..."}),p.requiresInput&&N&&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",p=o.some(k=>k.has_active_run===!0),v=t.status==="active"?p?"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(je,{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 Nj({projectSlug:t,onClose:s,onImported:o}){const[l,i]=x.useState("upload"),[d,u]=x.useState(null),[h,p]=x.useState(null),[g,v]=x.useState(!1),[y,b]=x.useState(null),k=x.useRef(null),[C,S]=x.useState(new Set),[N,j]=x.useState(new Set),[L,M]=x.useState(!0),[_,$]=x.useState(!1),[I,P]=x.useState("rename");x.useEffect(()=>{h&&(S(new Set(h.steps.map(O=>O.step_number))),j(new Set(h.resources.map(O=>O.id))))},[h]);const V=async O=>{var Y;const R=(Y=O.target.files)==null?void 0:Y[0];if(R){u(R),b(null),v(!0);try{const ie=await P0(t,R);p(ie),i("preview")}catch(ie){b(ie instanceof Error?ie.message:"Failed to read file")}finally{v(!1)}}},B=async()=>{if(d){i("importing"),b(null);try{const O={conflict_resolution:I,import_items:C.size>0,import_resources:N.size>0,import_planning:L,import_runs:_,selected_steps:Array.from(C),selected_resource_ids:Array.from(N)},R=await j2(t,d,O);o(R)}catch(O){b(O instanceof Error?O.message:"Import failed"),i("preview")}}},U=async O=>{O.preventDefault();const R=O.dataTransfer.files[0];if(R!=null&&R.name.endsWith(".zip")){u(R),b(null),v(!0);try{const Y=await P0(t,R);p(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")},z=O=>{S(R=>{const Y=new Set(R);return Y.has(O)?Y.delete(O):Y.add(O),Y})},T=O=>{j(R=>{const Y=new Set(R);return Y.has(O)?Y.delete(O):Y.add(O),Y})},Z=()=>{h&&(C.size===h.steps.length?S(new Set):S(new Set(h.steps.map(O=>O.step_number))))},W=()=>{h&&(N.size===h.resources.length?j(new Set):j(new Set(h.resources.map(O=>O.id))))},Q=h?h.steps.filter(O=>C.has(O.step_number)).reduce((O,R)=>O+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:O=>O.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:O=>O.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 O;return(O=k.current)==null?void 0:O.click()},onDrop:U,onDragOver:O=>O.preventDefault(),children:[e.jsx("input",{ref:k,type:"file",accept:".zip",onChange:V,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((O,R)=>e.jsx("li",{children:O},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((O,R)=>e.jsx("li",{children:O},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:C.size===h.steps.length&&h.steps.length>0,ref:O=>{O&&(O.indeterminate=C.size>0&&C.size<h.steps.length)},onChange:Z,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(O=>e.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:C.has(O.step_number),onChange:()=>z(O.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:[O.name," - ",e.jsxs("span",{className:"text-gray-500",children:[O.items_count," items"]})]})]},O.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:N.size===h.resources.length&&h.resources.length>0,ref:O=>{O&&(O.indeterminate=N.size>0&&N.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(O=>e.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:N.has(O.id),onChange:()=>T(O.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:[O.name,e.jsxs("span",{className:"text-gray-600 text-xs ml-2",children:["(",O.resource_type,")"]})]})]},O.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:L,onChange:O=>M(O.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:_,onChange:O=>$(O.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: ",C.size," step",C.size!==1?"s":""," (",Q," items), ",N.size," resource",N.size!==1?"s":"",L&&h.has_planning_session?", planning session":"",_&&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:O=>P(O.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),p(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:B,disabled:!h.is_compatible||C.size===0&&N.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 kj(){const{slug:t}=yr(),s=ir(),{selectedProject:o,setSelectedProject:l,setLoops:i,setLoopsLoading:d}=Tr(),[u,h]=x.useState(null),[p,g]=x.useState([]),[v,y]=x.useState([]),[b,k]=x.useState(!0),[C,S]=x.useState(!1),[N,j]=x.useState(!1),[L,M]=x.useState(!1),[_,$]=x.useState(null),I=x.useCallback(async()=>{if(t){k(!0);try{const W=await Za(t);g(W);const Q=await Za(t,{archived_only:!0});y(Q)}catch{g([]),y([])}finally{k(!1)}}},[t]),P=x.useCallback(async()=>{if(t){d(!0);try{const W=await Vc(t),Q=W.filter(R=>!R.workflow_id);S(Q.length>0);const O=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(O)}catch{i([])}finally{d(!1)}}},[t,i,d]);x.useEffect(()=>{if(!t)return;l(null),g([]);async function W(){h(null);try{const Q=await Vs(t);l(Q)}catch(Q){h(Q instanceof Error?Q.message:"Failed to load project")}}W(),I(),P()},[t,l,I,P]);const V=async(W,Q)=>{if(!(!t||!(await tt.fire({title:"Restore Workflow?",text:`Restore "${Q}" 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 Yv(t,W),I()}catch(R){tt.fire({title:"Error",text:R instanceof Error?R.message:"Failed to restore workflow",icon:"error",background:"var(--color-surface)",color:"var(--color-text-primary)"})}},B=async(W,Q)=>{if(!(!t||!(await tt.fire({title:"Permanently Delete?",html:`<p>This will permanently delete "<strong>${Q}</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 Vv(t,W),I()}catch(R){tt.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(je,{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=p.filter(W=>W.status==="active"||W.status==="draft"||W.status==="paused"),z=p.filter(W=>W.status==="completed"),Z=!(p.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(je,{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(je,{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:p.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"})]})]}),Z&&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:()=>M(!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:()=>j(!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))})]}),z.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:["(",z.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:z.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:()=>V(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:()=>B(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))})]})}),C&&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(je,{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(je,{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(je,{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(je,{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"})]})})]}),N&&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:()=>j(!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:()=>{j(!1),I()}})]})}),L&&e.jsx(Nj,{projectSlug:t,onClose:()=>M(!1),onImported:W=>{$(W),M(!1),I(),s(`/projects/${t}/workflows/${W.workflow_id}`)}}),_&&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:['"',_.workflow_name,'" imported successfully']}),e.jsxs("p",{className:"text-xs text-gray-400 mt-1",children:[_.steps_created," steps, ",_.items_imported," items, ",_.resources_created," resources"]}),_.warnings.length>0&&e.jsxs("p",{className:"text-sm text-yellow-400 mt-1",children:[_.warnings.length," warning(s)"]})]}),e.jsx("button",{onClick:()=>$(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 Cj({projectSlug:t,loopName:s,loopType:o,isRunning:l,isPaused:i,onStatusChange:d}){const[u,h]=x.useState(!1),[p,g]=x.useState(null),[v,y]=x.useState(!1),[b,k]=x.useState(null),C=x.useRef(null);x.useEffect(()=>{if(!v)return;const W=Q=>{C.current&&!C.current.contains(Q.target)&&y(!1)};return document.addEventListener("mousedown",W),()=>document.removeEventListener("mousedown",W)},[v]);const[S,N]=x.useState(void 0),[j,L]=x.useState(void 0),[M,_]=x.useState(!0),[$,I]=x.useState(!1),[P,V]=x.useState(10);x.useEffect(()=>{if(o!=="consumer"||l)return;let W=!0;return Jy(t,s).then(Q=>{W&&k(Q)}).catch(()=>{W&&k(null)}),()=>{W=!1}},[t,s,o,l]);const B=async W=>{h(!0),g(null);try{await W(),d==null||d()}catch(Q){g(Q instanceof Error?Q.message:"Action failed")}finally{h(!1)}},U=async()=>{(await tt.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 B(()=>Xy(t,s))},z=async()=>{(await tt.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 B(()=>Lc(t,s))},T=async()=>{const W={};S!==void 0&&(W.phase=S),j&&(W.category=j),W.respect_dependencies=M,W.batch_mode=$,$&&(W.batch_size=P),await B(()=>Lc(t,s,W)),y(!1)},Z=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:Z&&b&&b.total_items>0?e.jsxs("div",{className:"relative",ref:C,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(_j,{})]}),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=>N(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:j??"",onChange:W=>L(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:M,onChange:W=>_(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:$,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.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:P,onChange:W=>V(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,Q)=>e.jsxs("div",{className:"text-xs text-yellow-400 flex items-start space-x-1",children:[e.jsx(Lj,{}),e.jsx("span",{children:W})]},Q))}),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:T,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:z,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:()=>B(()=>Zy(t,s)),disabled:u,className:"btn-secondary disabled:opacity-50 flex items-center space-x-2",children:[e.jsx(Sj,{}),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:()=>B(()=>ev(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..."})]}),p&&e.jsx("div",{className:"mt-2 text-sm text-red-400",role:"alert",children:p})]})}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 Sj(){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 _j(){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 Lj(){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 Ej({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"},p={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]} ${p[d]} rounded-full transition-all duration-300`,style:{width:`${u}%`}})})]})}function Dp({url:t,enabled:s=!0,onEvent:o,onError:l,onOpen:i,retryInterval:d=3e3,maxRetries:u=5,maxStoredEvents:h=1e3}){const[p,g]=x.useState([]),[v,y]=x.useState(!1),[b,k]=x.useState(null),C=x.useRef(null),S=x.useRef(0),N=x.useRef(null),j=x.useCallback(()=>{g([])},[]),L=x.useCallback(()=>{N.current&&(clearTimeout(N.current),N.current=null),C.current&&(C.current.close(),C.current=null),y(!1)},[]),M=x.useCallback(()=>{L(),k(null);try{const _=new EventSource(t);C.current=_,_.onopen=()=>{y(!0),k(null),S.current=0,i==null||i()},_.onerror=I=>{y(!1),l==null||l(I),S.current<u?(S.current+=1,k(`Connection lost. Retrying (${S.current}/${u})...`),N.current=setTimeout(M,d)):(k("Connection failed after maximum retries"),_.close())},["connected","status","text","tool_call","tool_result","init","complete","error","heartbeat","info","session_start","disconnected"].forEach(I=>{_.addEventListener(I,P=>{try{const V=JSON.parse(P.data),B={type:I,data:V,timestamp:new Date};g(U=>{const z=[...U,B];return z.length>h?z.slice(-h):z}),o==null||o(B)}catch{}})})}catch(_){k(_ instanceof Error?_.message:"Failed to connect")}},[t,L,i,l,o,u,d,h]);return x.useEffect(()=>(s?M():L(),()=>{L()}),[s,M,L]),{events:p,isConnected:v,error:b,connect:M,disconnect:L,clearEvents:j}}function Op({projectSlug:t,loopName:s,sessionId:o,enabled:l=!0,maxEvents:i=500}){const[d,u]=x.useState(!0),[h,p]=x.useState(!1),g=x.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:C,disconnect:S,clearEvents:N}=Dp({url:v,enabled:l&&!h&&!!v});x.useEffect(()=>{d&&g.current&&(g.current.scrollTop=g.current.scrollHeight)},[y,d]);const j=y.slice(-i),L=()=>{h?(p(!1),C()):(p(!0),S())},[M,_]=x.useState("idle"),$=async()=>{const I=j.map(P=>Pj(P)).join(`
138
- `);try{await navigator.clipboard.writeText(I),_("success"),setTimeout(()=>_("idle"),2e3)}catch{_("error"),setTimeout(()=>_("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(Tj,{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:L,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:$,className:`px-3 py-1 text-sm rounded ${M==="success"?"bg-green-700 text-green-200":M==="error"?"bg-red-700 text-red-200":"bg-gray-700 text-gray-300 hover:bg-gray-600"}`,children:M==="success"?"Copied!":M==="error"?"Failed":"Copy"}),e.jsx("button",{onClick:N,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:j.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:j.map((I,P)=>e.jsx(Aj,{event:I},P))})}),e.jsxs("div",{className:"mt-2 text-xs text-gray-500 flex-shrink-0",children:[j.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 Tj({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 Aj({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 Pj(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 Wp(t){return typeof t>"u"||t===null}function Mj(t){return typeof t=="object"&&t!==null}function Rj(t){return Array.isArray(t)?t:Wp(t)?[]:[t]}function Ij(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 $j(t,s){var o="",l;for(l=0;l<s;l+=1)o+=t;return o}function Bj(t){return t===0&&Number.NEGATIVE_INFINITY===1/t}var Dj=Wp,Oj=Mj,Wj=Rj,Fj=$j,zj=Bj,Hj=Ij,ut={isNothing:Dj,isObject:Oj,toArray:Wj,repeat:Fj,isNegativeZero:zj,extend:Hj};function Fp(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=Fp(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+": "+Fp(this,s)};var Rt=_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 ut.repeat(" ",s-t.length)+t}function Uj(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="",p,g,v=Math.min(t.line+s.linesAfter,i.length).toString().length,y=s.maxLength-(s.indent+v+3);for(p=1;p<=s.linesBefore&&!(u-p<0);p++)g=gc(t.buffer,l[u-p],i[u-p],t.position-(l[u]-l[u-p]),y),h=ut.repeat(" ",s.indent)+yc((t.line-p+1).toString(),v)+" | "+g.str+`
141
- `+h;for(g=gc(t.buffer,l[u],i[u],t.position,y),h+=ut.repeat(" ",s.indent)+yc((t.line+1).toString(),v)+" | "+g.str+`
142
- `,h+=ut.repeat("-",s.indent+v+3+g.pos)+`^
143
- `,p=1;p<=s.linesAfter&&!(u+p>=i.length);p++)g=gc(t.buffer,l[u+p],i[u+p],t.position-(l[u]-l[u+p]),y),h+=ut.repeat(" ",s.indent)+yc((t.line+p+1).toString(),v)+" | "+g.str+`
144
- `;return h.replace(/\n$/,"")}var Vj=Uj,qj=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Yj=["scalar","sequence","mapping"];function Gj(t){var s={};return t!==null&&Object.keys(t).forEach(function(o){t[o].forEach(function(l){s[String(l)]=o})}),s}function Kj(t,s){if(s=s||{},Object.keys(s).forEach(function(o){if(qj.indexOf(o)===-1)throw new Rt('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=Gj(s.styleAliases||null),Yj.indexOf(this.kind)===-1)throw new Rt('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')}var wt=Kj;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 Qj(){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 Rc(t){return this.extend(t)}Rc.prototype.extend=function(s){var o=[],l=[];if(s instanceof wt)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 Rt("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");o.forEach(function(d){if(!(d instanceof wt))throw new Rt("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(d.loadKind&&d.loadKind!=="scalar")throw new Rt("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 Rt("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 wt))throw new Rt("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var i=Object.create(Rc.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=Qj(i.compiledImplicit,i.compiledExplicit),i};var zp=Rc,Hp=new wt("tag:yaml.org,2002:str",{kind:"scalar",construct:function(t){return t!==null?t:""}}),Up=new wt("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(t){return t!==null?t:[]}}),Vp=new wt("tag:yaml.org,2002:map",{kind:"mapping",construct:function(t){return t!==null?t:{}}}),qp=new zp({explicit:[Hp,Up,Vp]});function Jj(t){if(t===null)return!0;var s=t.length;return s===1&&t==="~"||s===4&&(t==="null"||t==="Null"||t==="NULL")}function Xj(){return null}function Zj(t){return t===null}var Yp=new wt("tag:yaml.org,2002:null",{kind:"scalar",resolve:Jj,construct:Xj,predicate:Zj,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function e1(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 t1(t){return t==="true"||t==="True"||t==="TRUE"}function r1(t){return Object.prototype.toString.call(t)==="[object Boolean]"}var Gp=new wt("tag:yaml.org,2002:bool",{kind:"scalar",resolve:e1,construct:t1,predicate:r1,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 s1(t){return 48<=t&&t<=57||65<=t&&t<=70||97<=t&&t<=102}function n1(t){return 48<=t&&t<=55}function o1(t){return 48<=t&&t<=57}function a1(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(!s1(t.charCodeAt(o)))return!1;l=!0}return l&&i!=="_"}if(i==="o"){for(o++;o<s;o++)if(i=t[o],i!=="_"){if(!n1(t.charCodeAt(o)))return!1;l=!0}return l&&i!=="_"}}if(i==="_")return!1;for(;o<s;o++)if(i=t[o],i!=="_"){if(!o1(t.charCodeAt(o)))return!1;l=!0}return!(!l||i==="_")}function l1(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 i1(t){return Object.prototype.toString.call(t)==="[object Number]"&&t%1===0&&!ut.isNegativeZero(t)}var Kp=new wt("tag:yaml.org,2002:int",{kind:"scalar",resolve:a1,construct:l1,predicate:i1,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"]}}),c1=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function d1(t){return!(t===null||!c1.test(t)||t[t.length-1]==="_")}function u1(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 m1=/^[-+]?[0-9]+e/;function h1(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(ut.isNegativeZero(t))return"-0.0";return o=t.toString(10),m1.test(o)?o.replace("e",".e"):o}function p1(t){return Object.prototype.toString.call(t)==="[object Number]"&&(t%1!==0||ut.isNegativeZero(t))}var Qp=new wt("tag:yaml.org,2002:float",{kind:"scalar",resolve:d1,construct:u1,predicate:p1,represent:h1,defaultStyle:"lowercase"}),Jp=qp.extend({implicit:[Yp,Gp,Kp,Qp]}),Xp=Jp,Zp=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),ex=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 x1(t){return t===null?!1:Zp.exec(t)!==null||ex.exec(t)!==null}function f1(t){var s,o,l,i,d,u,h,p=0,g=null,v,y,b;if(s=Zp.exec(t),s===null&&(s=ex.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(p=s[7].slice(0,3);p.length<3;)p+="0";p=+p}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,p)),g&&b.setTime(b.getTime()-g),b}function g1(t){return t.toISOString()}var tx=new wt("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:x1,construct:f1,instanceOf:Date,represent:g1});function y1(t){return t==="<<"||t===null}var rx=new wt("tag:yaml.org,2002:merge",{kind:"scalar",resolve:y1}),xd=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
145
- \r`;function v1(t){if(t===null)return!1;var s,o,l=0,i=t.length,d=xd;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 w1(t){var s,o,l=t.replace(/[\r\n=]/g,""),i=l.length,d=xd,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 b1(t){var s="",o=0,l,i,d=t.length,u=xd;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 j1(t){return Object.prototype.toString.call(t)==="[object Uint8Array]"}var sx=new wt("tag:yaml.org,2002:binary",{kind:"scalar",resolve:v1,construct:w1,predicate:j1,represent:b1}),N1=Object.prototype.hasOwnProperty,k1=Object.prototype.toString;function C1(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,k1.call(i)!=="[object Object]")return!1;for(d in i)if(N1.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 S1(t){return t!==null?t:[]}var nx=new wt("tag:yaml.org,2002:omap",{kind:"sequence",resolve:C1,construct:S1}),_1=Object.prototype.toString;function L1(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],_1.call(l)!=="[object Object]"||(i=Object.keys(l),i.length!==1))return!1;d[s]=[i[0],l[i[0]]]}return!0}function E1(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 ox=new wt("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:L1,construct:E1}),T1=Object.prototype.hasOwnProperty;function A1(t){if(t===null)return!0;var s,o=t;for(s in o)if(T1.call(o,s)&&o[s]!==null)return!1;return!0}function P1(t){return t!==null?t:{}}var ax=new wt("tag:yaml.org,2002:set",{kind:"mapping",resolve:A1,construct:P1}),fd=Xp.extend({implicit:[tx,rx],explicit:[sx,nx,ox,ax]}),vs=Object.prototype.hasOwnProperty,cl=1,lx=2,ix=3,dl=4,vc=1,M1=2,G0=3,R1=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,I1=/[\x85\u2028\u2029]/,$1=/[,\[\]\{\}]/,cx=/^(?:!|!!|![a-z\-]+!)$/i,dx=/^(?:!|[^,\[\]\{\}])(?:%[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 Fs(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 B1(t){var s;return 48<=t&&t<=57?t-48:(s=t|32,97<=s&&s<=102?s-97+10:-1)}function D1(t){return t===120?2:t===117?4:t===85?8:0}function O1(t){return 48<=t&&t<=57?t-48:-1}function Q0(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 W1(t){return t<=65535?String.fromCharCode(t):String.fromCharCode((t-65536>>10)+55296,(t-65536&1023)+56320)}function ux(t,s,o){s==="__proto__"?Object.defineProperty(t,s,{configurable:!0,enumerable:!0,writable:!0,value:o}):t[s]=o}var mx=new Array(256),hx=new Array(256);for(var yn=0;yn<256;yn++)mx[yn]=Q0(yn)?1:0,hx[yn]=Q0(yn);function F1(t,s){this.input=t,this.filename=s.filename||null,this.schema=s.schema||fd,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 px(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=Vj(o),new Rt(s,o)}function be(t,s){throw px(t,s)}function ul(t,s){t.onWarning&&t.onWarning.call(null,px(t,s))}var J0={YAML:function(s,o,l){var i,d,u;s.version!==null&&be(s,"duplication of %YAML directive"),l.length!==1&&be(s,"YAML directive accepts exactly one argument"),i=/^([0-9]+)\.([0-9]+)$/.exec(l[0]),i===null&&be(s,"ill-formed argument of the YAML directive"),d=parseInt(i[1],10),u=parseInt(i[2],10),d!==1&&be(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&&be(s,"TAG directive accepts exactly two arguments"),i=l[0],d=l[1],cx.test(i)||be(s,"ill-formed tag handle (first argument) of the TAG directive"),vs.call(s.tagMap,i)&&be(s,'there is a previously declared suffix for "'+i+'" tag handle'),dx.test(d)||be(s,"ill-formed tag prefix (second argument) of the TAG directive");try{d=decodeURIComponent(d)}catch{be(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||be(t,"expected valid JSON character");else R1.test(h)&&be(t,"the stream contains non-printable characters");t.result+=h}}function X0(t,s,o,l){var i,d,u,h;for(ut.isObject(o)||be(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)||(ux(s,d,o[d]),l[d]=!0)}function Nn(t,s,o,l,i,d,u,h,p){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])&&be(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=p||t.position,be(t,"duplicated mapping key")),ux(s,i,d),delete o[i];return s}function gd(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++):be(t,"a line break is expected"),t.line+=1,t.lineStart=t.position,t.firstTabInLine=-1}function at(t,s,o){for(var l=0,i=t.input.charCodeAt(t.position);i!==0;){for(;Fs(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(gd(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 yd(t,s){s===1?t.result+=" ":s>1&&(t.result+=ut.repeat(`
147
- `,s-1))}function z1(t,s,o){var l,i,d,u,h,p,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(p=t.line,g=t.lineStart,v=t.lineIndent,at(t,!1,-1),t.lineIndent>=s){h=!0,k=t.input.charCodeAt(t.position);continue}else{t.position=u,t.line=p,t.lineStart=g,t.lineIndent=v;break}}h&&(ys(t,d,u,!1),yd(t,t.line-p),d=u=t.position,h=!1),Fs(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 H1(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),yd(t,at(t,!1,s)),l=i=t.position):t.position===t.lineStart&&jl(t)?be(t,"unexpected end of the document within a single quoted scalar"):(t.position++,i=t.position);be(t,"unexpected end of the stream within a single quoted scalar")}function U1(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))at(t,!1,s);else if(h<256&&mx[h])t.result+=hx[h],t.position++;else if((u=D1(h))>0){for(i=u,d=0;i>0;i--)h=t.input.charCodeAt(++t.position),(u=B1(h))>=0?d=(d<<4)+u:be(t,"expected hexadecimal character");t.result+=W1(d),t.position++}else be(t,"unknown escape sequence");o=l=t.position}else _r(h)?(ys(t,o,l,!0),yd(t,at(t,!1,s)),o=l=t.position):t.position===t.lineStart&&jl(t)?be(t,"unexpected end of the document within a double quoted scalar"):(t.position++,l=t.position)}be(t,"unexpected end of the stream within a double quoted scalar")}function V1(t,s){var o=!0,l,i,d,u=t.tag,h,p=t.anchor,g,v,y,b,k,C=Object.create(null),S,N,j,L;if(L=t.input.charCodeAt(t.position),L===91)v=93,k=!1,h=[];else if(L===123)v=125,k=!0,h={};else return!1;for(t.anchor!==null&&(t.anchorMap[t.anchor]=h),L=t.input.charCodeAt(++t.position);L!==0;){if(at(t,!0,s),L=t.input.charCodeAt(t.position),L===v)return t.position++,t.tag=u,t.anchor=p,t.kind=k?"mapping":"sequence",t.result=h,!0;o?L===44&&be(t,"expected the node content, but found ','"):be(t,"missed comma between flow collection entries"),N=S=j=null,y=b=!1,L===63&&(g=t.input.charCodeAt(t.position+1),Vt(g)&&(y=b=!0,t.position++,at(t,!0,s))),l=t.line,i=t.lineStart,d=t.position,_n(t,s,cl,!1,!0),N=t.tag,S=t.result,at(t,!0,s),L=t.input.charCodeAt(t.position),(b||t.line===l)&&L===58&&(y=!0,L=t.input.charCodeAt(++t.position),at(t,!0,s),_n(t,s,cl,!1,!0),j=t.result),k?Nn(t,h,C,N,S,j,l,i,d):y?h.push(Nn(t,null,C,N,S,j,l,i,d)):h.push(S),at(t,!0,s),L=t.input.charCodeAt(t.position),L===44?(o=!0,L=t.input.charCodeAt(++t.position)):o=!1}be(t,"unexpected end of the stream within a flow collection")}function q1(t,s){var o,l,i=vc,d=!1,u=!1,h=s,p=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:M1:be(t,"repeat of a chomping mode identifier");else if((v=O1(y))>=0)v===0?be(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):u?be(t,"repeat of an indentation width identifier"):(h=s+v-1,u=!0);else break;if(Fs(y)){do y=t.input.charCodeAt(++t.position);while(Fs(y));if(y===35)do y=t.input.charCodeAt(++t.position);while(!_r(y)&&y!==0)}for(;y!==0;){for(gd(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)){p++;continue}if(t.lineIndent<h){i===G0?t.result+=ut.repeat(`
148
- `,d?1+p:p):i===vc&&d&&(t.result+=`
149
- `);break}for(l?Fs(y)?(g=!0,t.result+=ut.repeat(`
150
- `,d?1+p:p)):g?(g=!1,t.result+=ut.repeat(`
151
- `,p+1)):p===0?d&&(t.result+=" "):t.result+=ut.repeat(`
152
- `,p):t.result+=ut.repeat(`
153
- `,d?1+p:p),d=!0,u=!0,p=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,p;if(t.firstTabInLine!==-1)return!1;for(t.anchor!==null&&(t.anchorMap[t.anchor]=d),p=t.input.charCodeAt(t.position);p!==0&&(t.firstTabInLine!==-1&&(t.position=t.firstTabInLine,be(t,"tab characters must not be used in indentation")),!(p!==45||(u=t.input.charCodeAt(t.position+1),!Vt(u))));){if(h=!0,t.position++,at(t,!0,-1)&&t.lineIndent<=s){d.push(null),p=t.input.charCodeAt(t.position);continue}if(o=t.line,_n(t,s,ix,!1,!0),d.push(t.result),at(t,!0,-1),p=t.input.charCodeAt(t.position),(t.line===o||t.lineIndent>s)&&p!==0)be(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 Y1(t,s,o){var l,i,d,u,h,p,g=t.tag,v=t.anchor,y={},b=Object.create(null),k=null,C=null,S=null,N=!1,j=!1,L;if(t.firstTabInLine!==-1)return!1;for(t.anchor!==null&&(t.anchorMap[t.anchor]=y),L=t.input.charCodeAt(t.position);L!==0;){if(!N&&t.firstTabInLine!==-1&&(t.position=t.firstTabInLine,be(t,"tab characters must not be used in indentation")),l=t.input.charCodeAt(t.position+1),d=t.line,(L===63||L===58)&&Vt(l))L===63?(N&&(Nn(t,y,b,k,C,null,u,h,p),k=C=S=null),j=!0,N=!0,i=!0):N?(N=!1,i=!0):be(t,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),t.position+=1,L=l;else{if(u=t.line,h=t.lineStart,p=t.position,!_n(t,o,lx,!1,!0))break;if(t.line===d){for(L=t.input.charCodeAt(t.position);Fs(L);)L=t.input.charCodeAt(++t.position);if(L===58)L=t.input.charCodeAt(++t.position),Vt(L)||be(t,"a whitespace character is expected after the key-value separator within a block mapping"),N&&(Nn(t,y,b,k,C,null,u,h,p),k=C=S=null),j=!0,N=!1,i=!1,k=t.tag,C=t.result;else if(j)be(t,"can not read an implicit mapping pair; a colon is missed");else return t.tag=g,t.anchor=v,!0}else if(j)be(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)&&(N&&(u=t.line,h=t.lineStart,p=t.position),_n(t,s,dl,!0,i)&&(N?C=t.result:S=t.result),N||(Nn(t,y,b,k,C,S,u,h,p),k=C=S=null),at(t,!0,-1),L=t.input.charCodeAt(t.position)),(t.line===d||t.lineIndent>s)&&L!==0)be(t,"bad indentation of a mapping entry");else if(t.lineIndent<s)break}return N&&Nn(t,y,b,k,C,null,u,h,p),j&&(t.tag=g,t.anchor=v,t.kind="mapping",t.result=y),j}function G1(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&&be(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)):be(t,"unexpected end of the stream within a verbatim tag")}else{for(;u!==0&&!Vt(u);)u===33&&(l?be(t,"tag suffix cannot contain exclamation marks"):(i=t.input.slice(s-1,t.position+1),cx.test(i)||be(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),$1.test(d)&&be(t,"tag suffix cannot contain flow indicator characters")}d&&!dx.test(d)&&be(t,"tag name cannot contain such characters: "+d);try{d=decodeURIComponent(d)}catch{be(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:be(t,'undeclared tag handle "'+i+'"'),!0}function K1(t){var s,o;if(o=t.input.charCodeAt(t.position),o!==38)return!1;for(t.anchor!==null&&be(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&&be(t,"name of an anchor node must contain at least one character"),t.anchor=t.input.slice(s,t.position),!0}function Q1(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&&be(t,"name of an alias node must contain at least one character"),o=t.input.slice(s,t.position),vs.call(t.anchorMap,o)||be(t,'unidentified alias "'+o+'"'),t.result=t.anchorMap[o],at(t,!0,-1),!0}function _n(t,s,o,l,i){var d,u,h,p=1,g=!1,v=!1,y,b,k,C,S,N;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||ix===o,l&&at(t,!0,-1)&&(g=!0,t.lineIndent>s?p=1:t.lineIndent===s?p=0:t.lineIndent<s&&(p=-1)),p===1)for(;G1(t)||K1(t);)at(t,!0,-1)?(g=!0,h=d,t.lineIndent>s?p=1:t.lineIndent===s?p=0:t.lineIndent<s&&(p=-1)):h=!1;if(h&&(h=g||i),(p===1||dl===o)&&(cl===o||lx===o?S=s:S=s+1,N=t.position-t.lineStart,p===1?h&&(Z0(t,N)||Y1(t,N,S))||V1(t,S)?v=!0:(u&&q1(t,S)||H1(t,S)||U1(t,S)?v=!0:Q1(t)?(v=!0,(t.tag!==null||t.anchor!==null)&&be(t,"alias node should not have any properties")):z1(t,S,cl===o)&&(v=!0,t.tag===null&&(t.tag="?")),t.anchor!==null&&(t.anchorMap[t.anchor]=t.result)):p===0&&(v=h&&Z0(t,N))),t.tag===null)t.anchor!==null&&(t.anchorMap[t.anchor]=t.result);else if(t.tag==="?"){for(t.result!==null&&t.kind!=="scalar"&&be(t,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+t.kind+'"'),y=0,b=t.implicitTypes.length;y<b;y+=1)if(C=t.implicitTypes[y],C.resolve(t.result)){t.result=C.construct(t.result),t.tag=C.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))C=t.typeMap[t.kind||"fallback"][t.tag];else for(C=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){C=k[y];break}C||be(t,"unknown tag !<"+t.tag+">"),t.result!==null&&C.kind!==t.kind&&be(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+C.kind+'", not "'+t.kind+'"'),C.resolve(t.result,t.tag)?(t.result=C.construct(t.result,t.tag),t.anchor!==null&&(t.anchorMap[t.anchor]=t.result)):be(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 J1(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&&(at(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&&be(t,"directive name must not be less than one character in length");u!==0;){for(;Fs(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&&gd(t),vs.call(J0,l)?J0[l](t,l,i):ul(t,'unknown document directive "'+l+'"')}if(at(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,at(t,!0,-1)):d&&be(t,"directives end mark is expected"),_n(t,t.lineIndent-1,dl,!1,!0),at(t,!0,-1),t.checkLineBreaks&&I1.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,at(t,!0,-1));return}if(t.position<t.length-1)be(t,"end of the stream or a document separator is expected");else return}function xx(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 F1(t,s),l=t.indexOf("\0");for(l!==-1&&(o.position=l,be(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;)J1(o);return o.documents}function X1(t,s,o){s!==null&&typeof s=="object"&&typeof o>"u"&&(o=s,s=null);var l=xx(t,o);if(typeof s!="function")return l;for(var i=0,d=l.length;i<d;i+=1)s(l[i])}function Z1(t,s){var o=xx(t,s);if(o.length!==0){if(o.length===1)return o[0];throw new Rt("expected a single document in the stream, but found more")}}var e4=X1,t4=Z1,fx={loadAll:e4,load:t4},gx=Object.prototype.toString,yx=Object.prototype.hasOwnProperty,vd=65279,r4=9,Lo=10,s4=13,n4=32,o4=33,a4=34,Ic=35,l4=37,i4=38,c4=39,d4=42,vx=44,u4=45,ml=58,m4=61,h4=62,p4=63,x4=64,wx=91,bx=93,f4=96,jx=123,g4=124,Nx=125,_t={};_t[0]="\\0";_t[7]="\\a";_t[8]="\\b";_t[9]="\\t";_t[10]="\\n";_t[11]="\\v";_t[12]="\\f";_t[13]="\\r";_t[27]="\\e";_t[34]='\\"';_t[92]="\\\\";_t[133]="\\N";_t[160]="\\_";_t[8232]="\\L";_t[8233]="\\P";var y4=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],v4=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function w4(t,s){var o,l,i,d,u,h,p;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)),p=t.compiledTypeMap.fallback[u],p&&yx.call(p.styleAliases,h)&&(h=p.styleAliases[h]),o[u]=h;return o}function b4(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 Rt("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+o+ut.repeat("0",l-s.length)+s}var j4=1,Eo=2;function N4(t){this.schema=t.schema||fd,this.indent=Math.max(1,t.indent||2),this.noArrayIndent=t.noArrayIndent||!1,this.skipInvalid=t.skipInvalid||!1,this.flowLevel=ut.isNothing(t.flowLevel)?-1:t.flowLevel,this.styleMap=w4(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:j4,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=ut.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 $c(t,s){return`
157
- `+ut.repeat(" ",t.indent*s)}function k4(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===n4||t===r4}function To(t){return 32<=t&&t<=126||161<=t&&t<=55295&&t!==8232&&t!==8233||57344<=t&&t<=65533&&t!==vd||65536<=t&&t<=1114111}function th(t){return To(t)&&t!==vd&&t!==s4&&t!==Lo}function rh(t,s,o){var l=th(t),i=l&&!hl(t);return(o?l:l&&t!==vx&&t!==wx&&t!==bx&&t!==jx&&t!==Nx)&&t!==Ic&&!(s===ml&&!i)||th(s)&&!hl(s)&&t===Ic||s===ml&&i}function C4(t){return To(t)&&t!==vd&&!hl(t)&&t!==u4&&t!==p4&&t!==ml&&t!==vx&&t!==wx&&t!==bx&&t!==jx&&t!==Nx&&t!==Ic&&t!==i4&&t!==d4&&t!==o4&&t!==g4&&t!==m4&&t!==h4&&t!==c4&&t!==a4&&t!==l4&&t!==x4&&t!==f4}function S4(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 kx(t){var s=/^\n* /;return s.test(t)}var Cx=1,Bc=2,Sx=3,_x=4,wn=5;function _4(t,s,o,l,i,d,u,h){var p,g=0,v=null,y=!1,b=!1,k=l!==-1,C=-1,S=C4(bo(t,0))&&S4(bo(t,t.length-1));if(s||u)for(p=0;p<t.length;g>=65536?p+=2:p++){if(g=bo(t,p),!To(g))return wn;S=S&&rh(g,v,h),v=g}else{for(p=0;p<t.length;g>=65536?p+=2:p++){if(g=bo(t,p),g===Lo)y=!0,k&&(b=b||p-C-1>l&&t[C+1]!==" ",C=p);else if(!To(g))return wn;S=S&&rh(g,v,h),v=g}b=b||k&&p-C-1>l&&t[C+1]!==" "}return!y&&!b?S&&!u&&!i(t)?Cx:d===Eo?wn:Bc:o>9&&kx(t)?wn:u?d===Eo?wn:Bc:b?_x:Sx}function L4(t,s,o,l,i){t.dump=(function(){if(s.length===0)return t.quotingType===Eo?'""':"''";if(!t.noCompatMode&&(y4.indexOf(s)!==-1||v4.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 p(g){return k4(t,g)}switch(_4(s,h,t.indent,u,p,t.quotingType,t.forceQuotes&&!l,i)){case Cx:return s;case Bc:return"'"+s.replace(/'/g,"''")+"'";case Sx:return"|"+sh(s,t.indent)+nh(eh(s,d));case _x:return">"+sh(s,t.indent)+nh(eh(E4(s,u),d));case wn:return'"'+T4(s)+'"';default:throw new Rt("impossible error: invalid scalar style")}})()}function sh(t,s){var o=kx(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 E4(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],p=u[2];d=p[0]===" ",l+=h+(!i&&!d&&p!==""?`
165
- `:"")+oh(p,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,p="";l=o.exec(t);)h=l.index,h-i>s&&(d=u>i?u:h,p+=`
166
- `+t.slice(i,d),i=d+1),u=h;return p+=`
167
- `,t.length-i>s&&u>i?p+=t.slice(i,u)+`
168
- `+t.slice(u+1):p+=t.slice(i),p.slice(1)}function T4(t){for(var s="",o=0,l,i=0;i<t.length;o>=65536?i+=2:i++)o=bo(t,i),l=_t[o],!l&&To(o)?(s+=t[i],o>=65536&&(s+=t[i+1])):s+=l||b4(o);return s}function A4(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,p;for(u=0,h=o.length;u<h;u+=1)p=o[u],t.replacer&&(p=t.replacer.call(o,String(u),p)),(Vr(t,s+1,p,!0,!0,!1,!0)||typeof p>"u"&&Vr(t,s+1,null,!0,!0,!1,!0))&&((!l||i!=="")&&(i+=$c(t,s)),t.dump&&Lo===t.dump.charCodeAt(0)?i+="-":i+="- ",i+=t.dump);t.tag=d,t.dump=i||"[]"}function P4(t,s,o){var l="",i=t.tag,d=Object.keys(o),u,h,p,g,v;for(u=0,h=d.length;u<h;u+=1)v="",l!==""&&(v+=", "),t.condenseFlow&&(v+='"'),p=d[u],g=o[p],t.replacer&&(g=t.replacer.call(o,p,g)),Vr(t,s,p,!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 M4(t,s,o,l){var i="",d=t.tag,u=Object.keys(o),h,p,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 Rt("sortKeys must be a boolean or a function");for(h=0,p=u.length;h<p;h+=1)b="",(!l||i!=="")&&(b+=$c(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+=$c(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,p;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(p=t.styleMap[h.tag]||h.defaultStyle,gx.call(h.represent)==="[object Function]")l=h.represent(s,p);else if(yx.call(h.represent,p))l=h.represent[p](s,p);else throw new Rt("!<"+h.tag+'> tag resolver accepts not "'+p+'" 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=gx.call(t.dump),p=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?(M4(t,s,t.dump,i),b&&(t.dump="&ref_"+y+t.dump)):(P4(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)):(A4(t,s,t.dump),b&&(t.dump="&ref_"+y+" "+t.dump));else if(h==="[object String]")t.tag!=="?"&&L4(t,t.dump,s,d,p);else{if(h==="[object Undefined]")return!1;if(t.skipInvalid)return!1;throw new Rt("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 R4(t,s){var o=[],l=[],i,d;for(Dc(t,o,l),i=0,d=l.length;i<d;i+=1)s.duplicates.push(o[l[i]]);s.usedDuplicates=new Array(d)}function Dc(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)Dc(t[i],s,o);else for(l=Object.keys(t),i=0,d=l.length;i<d;i+=1)Dc(t[l[i]],s,o)}function I4(t,s){s=s||{};var o=new N4(s);o.noRefs||R4(t,o);var l=t;return o.replacer&&(l=o.replacer.call({"":l},"",l)),Vr(o,0,l,!0,!0)?o.dump+`
169
- `:""}var $4=I4,B4={dump:$4};function wd(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 D4=wt,O4=zp,W4=qp,F4=Jp,z4=Xp,H4=fd,U4=fx.load,V4=fx.loadAll,q4=B4.dump,Y4=Rt,G4={binary:sx,float:Qp,map:Vp,null:Yp,pairs:ox,set:ax,timestamp:tx,bool:Gp,int:Kp,merge:rx,omap:nx,seq:Up,str:Hp},K4=wd("safeLoad","load"),Q4=wd("safeLoadAll","loadAll"),J4=wd("safeDump","dump"),Ga={Type:D4,Schema:O4,FAILSAFE_SCHEMA:W4,JSON_SCHEMA:F4,CORE_SCHEMA:z4,DEFAULT_SCHEMA:H4,load:U4,loadAll:V4,dump:q4,YAMLException:Y4,types:G4,safeLoad:K4,safeLoadAll:Q4,safeDump:J4};const X4={output:{singular:"item",plural:"items",description:""}},Z4={strategy:"fixed"},eN={max_iterations:10,max_runtime_seconds:3600,max_consecutive_errors:3,cooldown_between_iterations:5},Lx={name:"",display_name:"",type:"generator",description:"",item_types:X4,modes:[],mode_selection:Z4,limits:eN};function wc(t){var o,l,i,d;const s={...Lx};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,p])=>{const g=p;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 tN({name:t,displayName:s,type:o,description:l,isNewLoop:i,onChange:d}){const u=h=>{const p={display_name:h};if(i&&!t){const g=h.toLowerCase().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").substring(0,50);p.name=g}d(p)};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 rN({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:""}})},p=()=>{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:p,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 sN({mode:t,isExpanded:s,onToggle:o,onChange:l,onDelete:i}){var p;const[d,u]=x.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:[((p=dh.find(g=>g.value===t.model))==null?void 0:p.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 nN({modes:t,onChange:s}){const[o,l]=x.useState(t.length===0?null:0),i=x.useCallback((h,p)=>{const g=[...t];g[h]=p,s(g)},[t,s]),d=x.useCallback(h=>{const p=t.filter((g,v)=>v!==h);s(p),o===h?l(p.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,p)=>e.jsx(sN,{mode:h,isExpanded:o===p,onToggle:()=>l(o===p?null:p),onChange:g=>i(p,g),onDelete:()=>d(p)},h.name||`unnamed_mode_${p}`))}),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 oN({strategy:t,modes:s,onChange:o}){var h;const l=p=>{const g={strategy:p};if(p==="fixed"&&s.length>0&&(g.fixed_mode=s[0].name),p==="weighted_random"){const v={},y=Math.floor(100/s.length);s.forEach(b=>{v[b.name]=y}),g.weights=v}o(g)},i=p=>{o({...t,fixed_mode:p})},d=(p,g)=>{o({...t,weights:{...t.weights,[p]:g}})},u=t.weights?Object.values(t.weights).reduce((p,g)=>p+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:p=>i(p.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(p=>e.jsx("option",{value:p.name,children:p.name},p.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(p=>{var y;const g=((y=t.weights)==null?void 0:y[p.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:p.name,children:p.name}),e.jsx("input",{type:"range",min:0,max:100,value:g,onChange:b=>d(p.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,"%"]})]},p.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 aN({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 lN({content:t,error:s,onChange:o}){const[l,i]=x.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"},iN={generator:"bg-green-600",consumer:"bg-blue-600",hybrid:"bg-purple-600"};function cN({onSelect:t,onClose:s}){const[o,l]=x.useState([]),[i,d]=x.useState(!0),[u,h]=x.useState(null),[p,g]=x.useState(null),[v,y]=x.useState(!1),b=x.useRef(null),k=x.useRef(null),C=x.useCallback(L=>{L.key==="Escape"&&s()},[s]);x.useEffect(()=>{S()},[]),x.useEffect(()=>{var L;return document.addEventListener("keydown",C),(L=k.current)==null||L.focus(),()=>{document.removeEventListener("keydown",C)}},[C]);const S=async()=>{try{d(!0),h(null);const L=await mv();l(L.templates)}catch(L){h(L instanceof Error?L.message:"Failed to load templates")}finally{d(!1)}},N=async L=>{try{g(L),y(!0);const M=await hv(L);t(M.config,M.config_yaml)}catch(M){h(M instanceof Error?M.message:"Failed to load template"),g(null)}finally{y(!1)}},j=()=>{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:j,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(L=>e.jsx("button",{onClick:()=>N(L.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 ${p===L.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[L.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:L.display_name}),e.jsx("span",{className:`px-2 py-0.5 text-xs rounded ${iN[L.type]||"bg-gray-600"} text-white`,children:L.type})]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:L.description}),p===L.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..."]})]})]})},L.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 dN({projectSlug:t,loopName:s,loopType:o}){const[l,i]=x.useState(null),[d,u]=x.useState(!0),[h,p]=x.useState(null),[g,v]=x.useState(null),[y,b]=x.useState(!0),[k,C]=x.useState(null),[S,N]=x.useState([]),[j,L]=x.useState(new Set(["rendered"]));x.useEffect(()=>{o==="consumer"&&Ao(t,{status:"pending",limit:10}).then(I=>N(I.items)).catch(()=>{})},[t,o]);const M=x.useCallback(async()=>{u(!0),p(null);try{const I=await jv(t,s,{mode:g||void 0,sample_item_id:k||void 0,include_annotations:y,use_first_pending:!k});i(I)}catch(I){p(I instanceof Error?I.message:"Failed to load preview")}finally{u(!1)}},[t,s,g,k,y]);x.useEffect(()=>{M()},[M]);const _=I=>{L(P=>{const V=new Set(P);return V.has(I)?V.delete(I):V.add(I),V})},$=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:M,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=>C(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:M,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,P])=>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:P})]},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,P)=>e.jsx("li",{children:I},P))})]}),l.modes.map(I=>e.jsx(uN,{modePreview:I,expandedSections:j,onToggleSection:_,onCopy:$},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 uN({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 mN({projectSlug:t,loopName:s,initialYaml:o,availableLoops:l=[],onClose:i,onSave:d}){const[u,h]=x.useState("visual"),[p,g]=x.useState(Lx),[v,y]=x.useState(""),[b,k]=x.useState(null),[C,S]=x.useState(!1),[N,j]=x.useState(null),[L,M]=x.useState(""),_=!s,[$,I]=x.useState(_&&!o);x.useEffect(()=>{if(o){y(o),M(o);try{const O=Ga.load(o);g(wc(O)),k(null)}catch(O){k(O instanceof Error?O.message:"Invalid YAML")}}},[o]);const P=x.useCallback(()=>{try{const O=ih(p),R=Ga.dump(O,{indent:2,lineWidth:-1,noRefs:!0,sortKeys:!1});y(R),k(null)}catch(O){console.error("Failed to convert form state to YAML:",O)}},[p]),V=x.useCallback(()=>{if(!v.trim())return k("YAML content is empty"),!1;try{const O=Ga.load(v);return typeof O!="object"||O===null?(k("YAML must be an object"),!1):(g(wc(O)),k(null),!0)}catch(O){return k(O instanceof Error?O.message:"Invalid YAML"),!1}},[v]);x.useEffect(()=>{if(u==="visual"){const O=setTimeout(P,100);return()=>clearTimeout(O)}},[u,p,P]);const B=O=>{if(O==="yaml"&&u==="visual")P();else if(O==="visual"&&u==="yaml"){if(!V())return}else if(O==="preview"&&u==="yaml"){if(!V())return}else O==="preview"&&u==="visual"&&P();h(O)},U=x.useMemo(()=>v!==L,[v,L]),z=x.useCallback(()=>{if(!p.name.trim())return"Loop name is required";if(!/^[a-z0-9_-]+$/.test(p.name))return"Loop name must contain only lowercase letters, numbers, hyphens, and underscores";if(!p.display_name.trim())return"Display name is required";if(p.modes.length===0)return"At least one mode is required";const O=new Set;for(const R of p.modes){if(!R.name.trim())return"All modes must have a name";if(O.has(R.name))return`Duplicate mode name: "${R.name}". Each mode must have a unique name.`;if(O.add(R.name),!R.prompt_template.trim())return`Mode "${R.name}" must have a prompt template`}return p.mode_selection.strategy==="fixed"&&!p.mode_selection.fixed_mode&&p.modes.length>0?"Fixed strategy requires selecting a mode":null},[p]),T=async()=>{let O;if(u==="visual")try{const Y=ih(p);O=Ga.dump(Y,{indent:2,lineWidth:-1,noRefs:!0,sortKeys:!1}),y(O),k(null)}catch{j("Failed to generate YAML from form");return}else{if(!V()){j("Fix YAML errors before saving");return}O=v}const R=z();if(R){j(R);return}S(!0),j(null);try{await d(O)}catch(Y){j(Y instanceof Error?Y.message:"Failed to save")}finally{S(!1)}},Z=()=>{U&&!window.confirm("Discard unsaved changes?")||i()},W=x.useCallback(O=>{g(R=>({...R,...O}))},[]),Q=x.useCallback((O,R)=>{I(!1),R&&Object.keys(O).length>0&&(y(R),g(wc(O)),k(null))},[]);return $?e.jsx(cN,{onSelect:Q,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:_?"Create New Loop":`Edit Loop: ${s}`}),e.jsxs("p",{className:"text-sm text-gray-400",children:["Project: ",t]})]}),e.jsx("button",{onClick:Z,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:()=>B("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:()=>B("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"})]}),!_&&s&&e.jsx("button",{onClick:()=>B("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(tN,{name:p.name,displayName:p.display_name,type:p.type,description:p.description,isNewLoop:_,onChange:O=>W(O)}),e.jsx(rN,{itemTypes:p.item_types,loopType:p.type,availableLoops:l.filter(O=>O!==p.name),onChange:O=>W({item_types:O})}),e.jsx(nN,{modes:p.modes,onChange:O=>W({modes:O})}),e.jsx(oN,{strategy:p.mode_selection,modes:p.modes,onChange:O=>W({mode_selection:O})}),e.jsx(aN,{limits:p.limits,onChange:O=>W({limits:O})})]}):u==="yaml"?e.jsx(lN,{content:v,error:b,onChange:y}):u==="preview"&&s?e.jsx(dN,{projectSlug:t,loopName:s,loopType:p.type}):null}),N&&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:N})}),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:Z,disabled:C,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:T,disabled:C||!!b,className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500 disabled:opacity-50",children:C?"Saving...":_?"Create Loop":"Save Changes"})]})]})]})})}const hN={master_design:"Master Design",story_instructions:"Story Instructions",stories:"Stories (JSONL)",guardrails:"Guardrails",reference:"Reference"};function pN({loopType:t,onSelect:s,onCancel:o}){const[l,i]=x.useState([]),[d,u]=x.useState(!0),[h,p]=x.useState(null),[g,v]=x.useState(null),[y,b]=x.useState(null),[k,C]=x.useState(!1);x.useEffect(()=>{S()},[t]);const S=async()=>{u(!0),p(null);try{const L=await Nv(t);i(L),L.length>0&&N(L[0])}catch(L){p(L instanceof Error?L.message:"Failed to load templates")}finally{u(!1)}},N=async L=>{v(L),C(!0);try{const M=await kv(L.id);b(M.content)}catch{b("Failed to load template content")}finally{C(!1)}},j=()=>{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(L=>e.jsxs("button",{onClick:()=>N(L),className:`w-full text-left p-3 rounded transition-colors ${(g==null?void 0:g.id)===L.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:L.name}),e.jsx("div",{className:"text-sm text-gray-400 mt-1",children:L.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:hN[L.tag]||L.tag}),e.jsx("span",{className:"text-xs text-gray-500",children:L.filename})]})]},L.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:j,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"}],xN=[{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 fN({addForm:t,setAddForm:s,onClose:o,onCreate:l,openFileBrowser:i,otherLoops:d,loopResources:u}){const[h,p]=x.useState("type"),g=No.find(C=>C.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"?p("source"):h==="source"&&p("type")},k=()=>{h==="type"?p("source"):h==="source"&&(t.source_type==="system"?l():p("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((C,S)=>e.jsx("div",{className:`h-1.5 rounded-full transition-all duration-300 ${C===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"}`},C))})]}),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(C=>e.jsxs("button",{onClick:()=>s({...t,resource_type:C.value}),className:`group relative p-4 rounded-lg text-left transition-all duration-150 ${t.resource_type===C.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===C.value?"bg-blue-500/20 text-blue-400":"bg-gray-700/50 text-gray-400 group-hover:text-gray-300"}`,children:bc[C.value]}),e.jsx("div",{className:"font-medium text-white mb-1",children:C.label}),e.jsx("div",{className:"text-xs text-gray-500 leading-relaxed",children:C.description}),t.resource_type===C.value&&e.jsx("div",{className:"absolute top-3 right-3 w-2 h-2 rounded-full bg-blue-500"})]},C.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:xN.filter(C=>C.value!=="system"||v).map(C=>e.jsxs("button",{onClick:()=>s({...t,source_type:C.value}),className:`group p-4 rounded-lg text-left transition-all duration-150 ${t.source_type===C.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===C.value?"text-blue-400":"text-gray-500 group-hover:text-gray-400"}`,children:C.icon}),e.jsx("div",{className:"font-medium text-white text-sm",children:C.label}),e.jsx("div",{className:"text-xs text-gray-500 mt-0.5",children:C.description})]},C.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:C=>s({...t,source_path:C.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:C=>s({...t,source_loop:C.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(C=>e.jsx("option",{value:C.name,children:C.display_name||C.name},C.name))]}),t.source_loop&&u.length>0&&e.jsxs("select",{value:t.source_resource_id||"",onChange:C=>s({...t,source_resource_id:C.target.value?parseInt(C.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(C=>e.jsxs("option",{value:C.id,children:[C.name," (",C.resource_type,")"]},C.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:C=>s({...t,inline_content:C.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:C=>s({...t,name:C.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 gN({projectSlug:t,loopName:s,loopType:o}){const[l,i]=x.useState([]),[d,u]=x.useState(!0),[h,p]=x.useState(null),[g,v]=x.useState(!1),[y,b]=x.useState({resource_type:"design_doc",name:"",source_type:"project_file",source_path:"",source_loop:"",source_resource_id:null,inline_content:""}),[k,C]=x.useState(!1),[S,N]=x.useState(""),[j,L]=x.useState([]),[M,_]=x.useState([]),[$,I]=x.useState(!1),[P,V]=x.useState(null),[B,U]=x.useState([]),[z,T]=x.useState([]),[Z,W]=x.useState(null),[Q,O]=x.useState(""),R=x.useCallback(async()=>{u(!0),p(null);try{const re=await E0(t,s,!0);i(re)}catch(re){p(re instanceof Error?re.message:"Failed to load resources")}finally{u(!1)}},[t,s]);x.useEffect(()=>{R()},[R]),x.useEffect(()=>{async function re(){try{const ke=await Vc(t);U(ke.filter(Le=>Le.name!==s))}catch{}}re()},[t,s]),x.useEffect(()=>{async function re(){if(y.source_loop)try{const ke=await E0(t,y.source_loop,!1);T(ke)}catch{T([])}else T([])}re()},[t,y.source_loop]);const Y=async()=>{C(!0);try{const re=await mc(t);N(re.relative_path||""),L(re.directories),_(re.files),I(re.canGoUp),V(re.parent)}catch(re){p(re instanceof Error?re.message:"Failed to browse files")}},ie=async re=>{try{const ke=S?`${S}/${re}`:re,Le=await mc(t,ke);N(Le.relative_path||ke),L(Le.directories),_(Le.files),I(Le.canGoUp),V(Le.parent)}catch(ke){p(ke instanceof Error?ke.message:"Failed to navigate")}},se=async()=>{if(P!==null)try{const re=await mc(t,P||void 0);N(re.relative_path||""),L(re.directories),_(re.files),I(re.canGoUp),V(re.parent)}catch(re){p(re instanceof Error?re.message:"Failed to navigate")}},E=re=>{const ke=S?`${S}/${re}`:re;b({...y,source_path:ke,name:re.replace(/\.[^/.]+$/,"")}),C(!1)},G=async()=>{const re=No.find(Le=>Le.value===y.resource_type),ke={resource_type:y.resource_type,name:y.name||y.resource_type,injection_position:(re==null?void 0:re.position)||"after_design_doc",source_type:y.source_type};y.source_type==="project_file"?ke.source_path=y.source_path:y.source_type==="loop_ref"?(ke.source_loop=y.source_loop,ke.source_resource_id=y.source_resource_id||void 0):y.source_type==="inline"&&(ke.inline_content=y.inline_content);try{await Fv(t,s,ke),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){p(Le instanceof Error?Le.message:"Failed to create resource")}},X=async re=>{try{await T0(t,s,re.id,{enabled:!re.enabled}),await R()}catch(ke){p(ke instanceof Error?ke.message:"Failed to update")}},ee=async re=>{re.source_type==="inline"&&(W(re),O(re.content||""))},F=async()=>{if(Z)try{await T0(t,s,Z.id,{inline_content:Q}),await R(),W(null)}catch(re){p(re instanceof Error?re.message:"Failed to save")}},me=async re=>{if(window.confirm(`Remove "${re.name}"? This won't delete any project files.`))try{await zv(t,s,re.id),await R()}catch(ke){p(ke instanceof Error?ke.message:"Failed to delete")}},Ne=re=>{switch(re.source_type){case"system":return"Using default template";case"project_file":return re.source_path||"From project file";case"loop_ref":return`From loop: ${re.source_loop}`;case"project_resource":return"From project resource";case"inline":return"Custom content";default:return re.source_type}},Ee=o==="planning"?["loop_template","design_doc","guardrails"]:o==="implementation"?["loop_template","design_doc","guardrails"]:["loop_template"],he=re=>l.some(ke=>ke.resource_type===re&&ke.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:Ee.map(re=>{const ke=No.find(ft=>ft.value===re),Le=he(re);return e.jsxs("button",{onClick:()=>{Le||(b({resource_type:re,name:"",source_type:re==="loop_template"||re==="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:(ke==null?void 0:ke.label)||re})]},re)})})]}),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:()=>p(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(re=>{var ke;return e.jsx("div",{className:`p-4 rounded-lg border ${re.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:()=>X(re),className:`mt-1 w-4 h-4 rounded border flex-shrink-0 ${re.enabled?"bg-green-500 border-green-500":"bg-transparent border-gray-500"}`,title:re.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:re.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-gray-700 text-gray-400",children:((ke=No.find(Le=>Le.value===re.resource_type))==null?void 0:ke.label)||re.resource_type})]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:Ne(re)}),re.content&&e.jsxs("p",{className:"text-xs text-gray-600 mt-1 truncate max-w-lg",children:[re.content.slice(0,100),"..."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[re.source_type==="inline"&&e.jsx("button",{onClick:()=>ee(re),className:"px-2 py-1 text-xs bg-gray-700 text-white rounded hover:bg-gray-600",children:"Edit"}),e.jsx("button",{onClick:()=>me(re),className:"px-2 py-1 text-xs bg-red-900/30 text-red-400 rounded hover:bg-red-900/50",children:"Remove"})]})]})},re.id)})}),g&&e.jsx(fN,{addForm:y,setAddForm:b,onClose:()=>v(!1),onCreate:G,openFileBrowser:Y,otherLoops:B,loopResources:z}),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:()=>C(!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.jsx("button",{onClick:se,className:"w-full text-left px-3 py-2 bg-gray-700 rounded hover:bg-gray-600 text-gray-300",children:".."}),j.map(re=>e.jsxs("button",{onClick:()=>ie(re),className:"w-full text-left px-3 py-2 bg-gray-700 rounded hover:bg-gray-600 text-white",children:[re,"/"]},re)),M.map(re=>e.jsx("button",{onClick:()=>E(re.name),className:"w-full text-left px-3 py-2 bg-gray-700 rounded hover:bg-gray-600 text-white",children:re.name},re.name))]})]})]})}),Z&&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: ",Z.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:Q,onChange:re=>O(re.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:F,className:"px-4 py-2 bg-primary-600 text-white rounded hover:bg-primary-500",children:"Save"})]})]})})]})}function yN({projectSlug:t,loopName:s,onClose:o,onComplete:l}){const[i,d]=x.useState("analyzing"),[u,h]=x.useState([]),[p,g]=x.useState({}),[v,y]=x.useState(""),[b,k]=x.useState(null),[C,S]=x.useState(0),N=x.useCallback($=>{$.key==="Escape"&&i!=="saving"&&i!=="analyzing"&&o()},[o,i]);x.useEffect(()=>(document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)),[N]),x.useEffect(()=>{let $=!1,I=null;const P=B=>{if(B.status==="ready")return d("ready"),y(B.assessment||"Ready to start"),!0;if(B.status==="questions"){const U=Array.isArray(B.questions)?B.questions:[];if(U.length===0)d("ready"),y(B.assessment||"No clarifications needed");else{d("questions"),h(U),y(B.assessment||"");const z={};U.forEach(T=>{z[T.id]=""}),g(z)}return!0}else return B.status==="analyzing"?!1:(d("error"),k(`Unexpected response status: ${B.status}`),!0)},V=async()=>{try{const B=await iv(t,s);if($)return;!P(B)&&!$&&(I=setTimeout(V,2e3))}catch(B){if($)return;d("error"),k(B instanceof Error?B.message:"Failed to run ready check")}};return V(),()=>{$=!0,I&&clearTimeout(I)}},[t,s,C]);const j=($,I)=>{g(P=>({...P,[$]:I}))},L=u.every($=>{var I;return(I=p[$.id])==null?void 0:I.trim()}),M=async $=>{if(L){d("saving");try{const I=u.map(P=>({question_id:P.id,answer:p[P.id]}));await cv(t,s,u,I),l($)}catch(I){d("error"),k(I instanceof Error?I.message:"Failed to save answers")}}},_=$=>{$.target===$.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:_,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(($,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,". ",$.category]})}),e.jsxs("div",{className:"bg-gray-800 rounded p-3 mb-3",children:[e.jsx("p",{className:"text-gray-200",children:$.question}),$.context&&e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:$.context})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Your answer:"}),e.jsx("textarea",{value:p[$.id]||"",onChange:P=>j($.id,P.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..."})]})]},$.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($=>$+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:()=>M(!1),disabled:!L,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:()=>M(!0),disabled:!L,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"},bd={background:us.background,color:us.text,confirmButtonColor:us.confirmButton,cancelButtonColor:us.cancelButton,denyButtonColor:us.denyButton},vo=tt.mixin({toast:!0,position:"bottom-right",showConfirmButton:!1,timer:5e3,timerProgressBar:!0,...bd,didOpen:t=>{t.onmouseenter=tt.stopTimer,t.onmouseleave=tt.resumeTimer}}),mh=tt.mixin({...bd,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}`})}},vN={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 tt.fire({...bd,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?(tt.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 wN(){const{slug:t,loopName:s}=yr(),o=ir(),{selectedProject:l,setSelectedProject:i,items:d,itemsTotal:u,itemsLoading:h,setItems:p,setItemsLoading:g}=Tr(),[v,y]=x.useState(null),[b,k]=x.useState(null),[C,S]=x.useState(null),[N,j]=x.useState(null),[L,M]=x.useState(!1),[_,$]=x.useState(""),[I,P]=x.useState([]),[V,B]=x.useState("overview"),[U,z]=x.useState([]),[T,Z]=x.useState(!1),[W,Q]=x.useState(!1),[O,R]=x.useState(""),[Y,ie]=x.useState(""),[se,E]=x.useState(""),[G,X]=x.useState(!1),[ee,F]=x.useState(!1),[me,Ne]=x.useState(null),[Ae,Ee]=x.useState(!1),[he,re]=x.useState(null),ke=x.useRef(null),[Le,ft]=x.useState(null),[Lt,He]=x.useState(!1),[Qe,Et]=x.useState(""),[bt,Bt]=x.useState(""),[Tt,de]=x.useState(0),[Re,At]=x.useState([]),nt=x.useCallback(async()=>{if(!(!t||!s))try{const oe=await Ih(t,s);k(oe)}catch{k({is_running:!1})}},[t,s]),cr=x.useCallback(async(oe=!1)=>{if(!t||!s)return;g(!0);const Te=oe?0:Tt;oe&&de(0);try{const Me=await Ao(t,{status:Qe||void 0,category:bt||void 0,limit:50,offset:Te});p(Te===0?Me.items:[...d,...Me.items],Me.total);const we=new Set;Me.items.forEach(Ie=>{Ie.category&&we.add(Ie.category)}),At(Te===0?Array.from(we).sort():Ie=>Array.from(new Set([...Ie,...we])).sort())}catch{p([],0)}finally{g(!1)}},[t,s,p,g,Qe,bt,Tt,d]),gt=x.useCallback(async()=>{if(!(!t||!s||!v)){Z(!0);try{const oe=await yv(t,s);z(oe);const Te=v.type==="generator"?"planning":"implementation",Me=await Sv(t,s,Te);re(Me)}catch{z([]),re(null)}finally{Z(!1)}}},[t,s,v]),Ar=x.useCallback(async oe=>{if(!(!t||!s)){X(!0),j(null);try{await vv(t,s,oe),await gt()}catch(Te){j(Te instanceof Error?Te.message:"Upload failed")}finally{X(!1)}}},[t,s,gt]),js=x.useCallback(async()=>{if(!(!t||!s||!O||!Y)){F(!0),j(null);try{await wv(t,s,O,Y,se||void 0),R(""),ie(""),E(""),Q(!1),await gt()}catch(oe){j(oe instanceof Error?oe.message:"Import failed")}finally{F(!1)}}},[t,s,O,Y,se,gt]),vr=x.useCallback(async oe=>{if(!(!t||!s)){Ee(!1),j(null);try{await Cv(t,s,oe),await gt()}catch(Te){j(Te instanceof Error?Te.message:"Failed to apply template")}}},[t,s,gt]),wr=x.useCallback(async oe=>{if(!(!t||!s)&&confirm(`Delete ${oe}?`)){Ne(oe),j(null);try{await bv(t,s,oe),await gt()}catch(Te){j(Te instanceof Error?Te.message:"Delete failed")}finally{Ne(null)}}},[t,s,gt]);x.useEffect(()=>{if(!t||!s)return;y(null),k(null),p([],0);async function oe(){S(null);try{const[Me,we]=await Promise.all([Vs(t),C0(t,s)]);i(Me),y(we),await nt()}catch(Me){S(Me instanceof Error?Me.message:"Failed to load")}}oe();const Te=setInterval(nt,3e3);return()=>clearInterval(Te)},[t,s,i,nt,p]),x.useEffect(()=>{if(!t||!s)return;async function oe(){try{const Te=await S0(t,s);ft(Te)}catch{ft({has_qa:!1,qa_count:0,qa_summary:[]})}}oe()},[t,s]),x.useEffect(()=>{V==="items"?cr(!0):V==="inputs"&&gt()},[V,gt]),x.useEffect(()=>{V==="items"&&t&&s&&cr(!0)},[Qe,bt]),x.useEffect(()=>{if(!W)return;const oe=Te=>{Te.key==="Escape"&&!ee&&Q(!1)};return document.addEventListener("keydown",oe),()=>document.removeEventListener("keydown",oe)},[W,ee]);const Gs=x.useCallback(async()=>{if(!(!t||!s)){j(null);try{const[oe,Te]=await Promise.all([rv(t,s),Vc(t)]);$(oe.content),P(Te.map(Me=>Me.name)),M(!0)}catch(oe){j(oe instanceof Error?oe.message:"Failed to load config")}}},[t,s]),Ns=x.useCallback(async oe=>{if(!t||!s)return;await sv(t,s,oe);const Te=await C0(t,s);y(Te),M(!1)},[t,s]),ks=x.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 vN.typeToDelete(s,"loop"))try{await tv(t,s),jc.success(`Loop "${v.display_name}" deleted`),o(`/projects/${t}`)}catch(Te){jc.error(Te instanceof Error?Te.message:"Failed to delete loop")}},[t,s,v,b==null?void 0:b.is_running,o]);if(C)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:C}),e.jsxs(je,{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:[L&&e.jsx(mN,{projectSlug:t,loopName:s,initialYaml:_,availableLoops:I,onClose:()=>M(!1),onSave:Ns}),e.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[e.jsx(je,{to:"/",className:"hover:text-white",children:"Dashboard"}),e.jsx("span",{children:"/"}),e.jsx(je,{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(Cj,{projectSlug:t,loopName:s,isRunning:Dt,isPaused:dr,onStatusChange:nt})]})]}),N&&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:N}),e.jsx("button",{onClick:()=>j(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(oe=>e.jsx("button",{onClick:()=>B(oe),className:`pb-4 px-1 border-b-2 font-medium text-sm transition-colors ${V===oe?"border-primary-500 text-primary-400":"border-transparent text-gray-400 hover:text-gray-300 hover:border-gray-500"}`,children:oe.charAt(0).toUpperCase()+oe.slice(1)},oe))})}),Lt&&e.jsx(yN,{projectSlug:t,loopName:s,onClose:()=>He(!1),onComplete:async oe=>{He(!1);try{const Te=await S0(t,s);ft(Te)}catch{}if(oe)try{await Lc(t,s,{force:!0}),nt()}catch(Te){j(Te instanceof Error?Te.message:"Failed to start loop")}}}),V==="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 ",Xc(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((oe,Te)=>e.jsxs("li",{children:["• ",oe]},Te))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>He(!0),className:"text-sm text-primary-400 hover:text-primary-300",children:"View / Edit"}),e.jsx("button",{onClick:()=>He(!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:()=>He(!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(Ej,{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(oe=>e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-md ${(b==null?void 0:b.current_mode)===oe.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:oe.name}),e.jsxs("div",{className:"text-sm text-gray-400",children:["Model: ",oe.model]})]}),e.jsxs("div",{className:"text-sm text-gray-400",children:["Timeout: ",oe.timeout,"s"]})]},oe.name))})]}),Dt&&e.jsx("div",{className:"mb-6",children:e.jsx(Op,{projectSlug:t,loopName:s,enabled:Dt})})]}),V==="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:Qe,onChange:oe=>Et(oe.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:bt,onChange:oe=>Bt(oe.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"}),Re.map(oe=>e.jsx("option",{value:oe,children:oe},oe))]})]}),(Qe||bt)&&e.jsx("button",{onClick:()=>{Et(""),Bt("")},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(Tc,{icon:Ec.inbox,title:"No items yet",description:Qe||bt?"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(oe=>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:oe.id}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${oe.status==="completed"?"bg-green-900 text-green-300":oe.status==="pending"?"bg-yellow-900 text-yellow-300":oe.status==="in_progress"?"bg-blue-900 text-blue-300":oe.status==="failed"?"bg-red-900 text-red-300":"bg-gray-600 text-gray-300"}`,children:oe.status})]}),oe.category&&e.jsx("span",{className:"text-xs text-gray-400",children:oe.category})]}),e.jsx("p",{className:"text-sm text-gray-200 line-clamp-2",children:oe.content})]},oe.id))}),d.length<u&&e.jsx("div",{className:"mt-4 text-center",children:e.jsx("button",{onClick:()=>{de(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})`})})]})]}),V==="inputs"&&e.jsxs("div",{className:"space-y-4",children:[he&&!he.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:he.missing_tags.map(oe=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-yellow-400 text-sm",children:hh[oe]||oe}),e.jsx("button",{onClick:()=>Ee(!0),className:"text-xs px-2 py-1 bg-yellow-800/50 text-yellow-300 rounded hover:bg-yellow-800",children:"Add from Templates"})]},oe))}),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:()=>Ee(!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:()=>Q(!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 oe;return(oe=ke.current)==null?void 0:oe.click()},disabled:G,className:"px-3 py-1.5 bg-primary-600 text-white rounded hover:bg-primary-500 text-sm disabled:opacity-50",children:G?"Uploading...":"Upload File"}),e.jsx("input",{ref:ke,type:"file",className:"hidden",accept:".md,.txt,.json,.jsonl",onChange:oe=>{var Me;const Te=(Me=oe.target.files)==null?void 0:Me[0];Te&&Ar(Te),oe.target.value=""}})]})]}),T?e.jsx("div",{className:"text-gray-400",children:"Loading..."}):U.length===0?e.jsx(Tc,{icon:Ec.document,title:"No input files",description:"Upload design documents, requirements, or other files for this loop to process.",action:{label:"Browse Templates",onClick:()=>Ee(!0)}}):e.jsx("div",{className:"space-y-2",children:U.map(oe=>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:oe.name}),e.jsxs("div",{className:"text-xs text-gray-400",children:[(oe.size/1024).toFixed(1)," KB"]})]}),oe.tag&&e.jsx("span",{className:"px-2 py-0.5 text-xs bg-gray-600 text-gray-300 rounded",children:hh[oe.tag]||oe.tag})]}),e.jsx("button",{onClick:()=>wr(oe.name),disabled:me===oe.name,className:"p-1 text-gray-400 hover:text-red-400 disabled:opacity-50",title:"Delete",children:me===oe.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"})})})]},oe.name))})]})]}),V==="resources"&&v&&e.jsx("div",{className:"card",children:e.jsx(gN,{projectSlug:t,loopName:s,loopType:v.type==="generator"?"planning":"implementation"})}),V==="runs"&&e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Run History"}),e.jsx(je,{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:oe=>{oe.target===oe.currentTarget&&!ee&&Q(!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:oe=>ie(oe.target.value),placeholder:"design-doc.md",className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white",disabled:ee})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Tag (optional)"}),e.jsxs("select",{value:se,onChange:oe=>E(oe.target.value),className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white",disabled:ee,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:O,onChange:oe=>R(oe.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:ee})]})]}),e.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[e.jsx("button",{onClick:()=>Q(!1),disabled:ee,className:"px-4 py-2 text-gray-400 hover:text-white disabled:opacity-50",children:"Cancel"}),e.jsx("button",{onClick:js,disabled:!O||!Y||ee,className:"px-4 py-2 bg-primary-600 text-white rounded hover:bg-primary-500 disabled:opacity-50 disabled:cursor-not-allowed",children:ee?"Importing...":"Import"})]})]})}),Ae&&v&&e.jsx(pN,{loopType:v.type==="generator"?"planning":"implementation",onSelect:vr,onCancel:()=>Ee(!1)})]})}function bN({projectSlug:t,item:s,onUpdate:o,terminology:l}){const[i,d]=x.useState(!1),[u,h]=x.useState(!1),[p,g]=x.useState(null),v=(l==null?void 0:l.singular)||s.item_type||"item",y=async k=>{h(!0),g(null);try{await Yc(t,s.id,{status:k}),o()}catch(C){g(C instanceof Error?C.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 ${Jc(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]})]}),p&&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:p}),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 jN({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 NN(){const{slug:t,workflowId:s}=yr(),{selectedProject:o,setSelectedProject:l}=Tr(),[i,d]=x.useState(null),[u,h]=x.useState([]),[p,g]=x.useState(0),[v,y]=x.useState(!0),[b,k]=x.useState(null),[C,S]=x.useState("all"),[N,j]=x.useState(""),[L,M]=x.useState([]),[_,$]=x.useState(0),I=20,[P,V]=x.useState(!1),[B,U]=x.useState(""),[z,T]=x.useState(""),[Z,W]=x.useState(!1),Q=x.useCallback(async()=>{if(!(!t||!s)){y(!0),k(null);try{const E=await Ao(t,{status:C==="all"?void 0:C,category:N||void 0,workflow_id:s,limit:I,offset:_});h(E.items),g(E.total);const G=new Set;E.items.forEach(X=>{X.category&&G.add(X.category)}),M(Array.from(G).sort())}catch(E){k(E instanceof Error?E.message:"Failed to load items")}finally{y(!1)}}},[t,s,C,N,_]);x.useEffect(()=>{async function E(){if(!(!t||!s))try{const[G,X]=await Promise.all([Vs(t),Po(t,s)]);l(G),d(X)}catch(G){k(G instanceof Error?G.message:"Failed to load data")}}E()},[t,s,l]),x.useEffect(()=>{Q()},[Q]);const O=async E=>{if(E.preventDefault(),!t||!s||!i||!B.trim())return;const G=i.steps.find(X=>X.step_number===i.current_step);if(!G){k("No active workflow step found. Cannot add items.");return}W(!0);try{await qc(t,{content:B.trim(),workflow_id:s,source_step_id:G.id,category:z.trim()||void 0}),U(""),T(""),V(!1),Q()}catch(X){k(X instanceof Error?X.message:"Failed to add item")}finally{W(!1)}},R=Math.ceil(p/I),Y=Math.floor(_/I)+1,ie={pending:u.filter(E=>E.status==="pending").length,in_progress:u.filter(E=>E.status==="in_progress").length,completed:u.filter(E=>E.status==="completed").length},se=p>0?Math.round(ie.completed/p*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(je,{to:"/",className:"hover:text-white",children:"Dashboard"}),e.jsx("span",{children:"/"}),e.jsx(je,{to:`/projects/${t}`,className:"hover:text-white",children:(o==null?void 0:o.name)||t}),e.jsx("span",{children:"/"}),e.jsx(je,{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:[p," item",p!==1?"s":""," in this workflow"]})]}),e.jsxs("button",{onClick:()=>V(!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:[p," 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:[se,"%"]})]}),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:`${se}%`}})})]}),P&&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:O,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:B,onChange:E=>U(E.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:z,onChange:E=>T(E.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:()=>V(!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:Z||!B.trim(),className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500 disabled:opacity-50",children:Z?"Adding...":"Add Item"})]})]})]}),e.jsx("div",{className:"mb-4",children:e.jsx(jN,{status:C,category:N,categories:L,onStatusChange:E=>{S(E),$(0)},onCategoryChange:E=>{j(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"}),(C!=="all"||N)&&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(E=>e.jsx(bN,{projectSlug:t,item:E,onUpdate:Q},E.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 ",_+1,"-",Math.min(_+I,p)," of ",p]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>$(Math.max(0,_-I)),disabled:_===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:()=>$(_+I),disabled:_+I>=p,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 kN(){const{slug:t,workflowId:s}=yr(),{selectedProject:o,setSelectedProject:l}=Tr(),[i,d]=x.useState(null),[u,h]=x.useState([]),[p,g]=x.useState([]),[v,y]=x.useState(!0),[b,k]=x.useState(null),[C,S]=x.useState("all"),[N,j]=x.useState(!1),[L,M]=x.useState(!1),[_,$]=x.useState({name:"",resource_type:"guardrail",content:""}),[I,P]=x.useState(!1),[V,B]=x.useState(null),[U,z]=x.useState(""),[T,Z]=x.useState(!1),W=x.useCallback(async()=>{if(!(!t||!s)){y(!0),k(null);try{const[ee,F,me,Ne]=await Promise.all([Vs(t),Po(t,s),fl(t,s),Kc(t)]);l(ee),d(F),h(me),g(Ne)}catch(ee){k(ee instanceof Error?ee.message:"Failed to load resources")}finally{y(!1)}}},[t,s,l]);x.useEffect(()=>{W()},[W]);const Q=C==="all"?u:u.filter(ee=>ee.resource_type===C),O=async ee=>{if(ee.preventDefault(),!(!t||!s||!_.name.trim()||!_.content.trim())){P(!0);try{await Gc(t,s,{name:_.name.trim(),resource_type:_.resource_type,content:_.content.trim(),source:"manual"}),$({name:"",resource_type:"guardrail",content:""}),j(!1),W()}catch(F){k(F instanceof Error?F.message:"Failed to add resource")}finally{P(!1)}}},R=async ee=>{if(!(!t||!s))try{await zh(t,s,ee.id),M(!1),W()}catch(F){k(F instanceof Error?F.message:"Failed to import resource")}},Y=async()=>{if(!(!t||!s||!V)){Z(!0);try{await So(t,s,V.id,{content:U}),B(null),W()}catch(ee){k(ee instanceof Error?ee.message:"Failed to save resource")}finally{Z(!1)}}},ie=async ee=>{if(!(!t||!s))try{await So(t,s,ee.id,{enabled:!ee.enabled}),W()}catch(F){k(F instanceof Error?F.message:"Failed to update resource")}},se=async ee=>{if(!(!t||!s)&&confirm(`Delete "${ee.name}"? This cannot be undone.`))try{await Fh(t,s,ee.id),W()}catch(F){k(F instanceof Error?F.message:"Failed to delete resource")}},E=ee=>{switch(ee){case"design_doc":return"Design Document";case"guardrail":return"Guardrail";case"input_file":return"Input File";case"prompt":return"Prompt";default:return ee}},G=ee=>{switch(ee){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"})})}},X=[{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(je,{to:"/",className:"hover:text-white",children:"Dashboard"}),e.jsx("span",{children:"/"}),e.jsx(je,{to:`/projects/${t}`,className:"hover:text-white",children:(o==null?void 0:o.name)||t}),e.jsx("span",{children:"/"}),e.jsx(je,{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:()=>M(!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:()=>j(!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:X.map(ee=>e.jsx("button",{onClick:()=>S(ee.key),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${C===ee.key?"border-primary-500 text-white":"border-transparent text-gray-400 hover:text-gray-300"}`,children:ee.label},ee.key))}),Q.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:Q.map(ee=>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 ${ee.enabled?"bg-primary-500/20 text-primary-400":"bg-gray-700 text-gray-500"}`,children:G(ee.resource_type)}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium text-white",children:ee.name}),e.jsxs("div",{className:"flex items-center space-x-4 text-sm text-gray-400 mt-1",children:[e.jsx("span",{children:E(ee.resource_type)}),ee.source&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-600",children:"|"}),e.jsxs("span",{children:["Source: ",ee.source]})]})]}),ee.content&&e.jsxs("p",{className:"text-sm text-gray-500 mt-2 line-clamp-2",children:[ee.content.slice(0,200),ee.content.length>200&&"..."]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>ie(ee),className:`px-3 py-1 text-sm rounded ${ee.enabled?"bg-green-600/20 text-green-400":"bg-gray-700 text-gray-500"}`,children:ee.enabled?"Enabled":"Disabled"}),e.jsx("button",{onClick:()=>{B(ee),z(ee.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:()=>se(ee),className:"px-3 py-1 text-sm rounded bg-red-900/30 text-red-400 hover:bg-red-900/50",children:"Delete"})]})]},ee.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."})]})]})}),N&&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:O,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:_.resource_type,onChange:ee=>$({..._,resource_type:ee.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:_.name,onChange:ee=>$({..._,name:ee.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:_.content,onChange:ee=>$({..._,content:ee.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:()=>j(!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||!_.name.trim()||!_.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"})]})]})]})}),L&&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."}),p.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:p.map(ee=>e.jsx("button",{onClick:()=>R(ee),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:ee.name}),e.jsx("p",{className:"text-sm text-gray-400",children:E(ee.resource_type)})]}),ee.auto_inherit&&e.jsx("span",{className:"text-xs bg-primary-500/20 text-primary-400 px-2 py-1 rounded",children:"Auto-inherit"})]})},ee.id))}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx("button",{onClick:()=>M(!1),className:"px-4 py-2 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600",children:"Close"})})]})}),V&&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:V.name}),e.jsx("span",{className:"text-sm bg-gray-700 text-gray-400 px-2 py-1 rounded",children:E(V.resource_type)})]}),e.jsx("textarea",{value:U,onChange:ee=>z(ee.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:()=>B(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:T,className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500 disabled:opacity-50",children:T?"Saving...":"Save Changes"})]})]})})]})}function CN({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 SN(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Qa(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 _N({workflow:t,workflowName:s,onNameChange:o,steps:l,resources:i,onViewResources:d}){var C;const[u,h]=x.useState(null);x.useEffect(()=>{if(!u)return;const S=N=>{N.key==="Escape"&&h(null)};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[u]);const p=i.reduce((S,N)=>{var j;return S+(((j=N.content)==null?void 0:j.length)??0)},0),g=i.reduce((S,N)=>S+Ka(N.content),0),v=i.filter(S=>S.enabled),y=i.reduce((S,N)=>(S[N.resource_type]||(S[N.resource_type]=[]),S[N.resource_type].push(N),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:[Qa(g)," tokens (",SN(p),")"]})]}),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,N])=>{const j=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:"📄"})},L=N.reduce((M,_)=>M+Ka(_.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 ${j.color}`,children:j.icon}),e.jsx("span",{className:"text-sm font-medium text-gray-300",children:j.label}),e.jsxs("span",{className:"text-xs text-gray-500",children:["(",N.length,")"]})]}),e.jsxs("span",{className:"text-xs text-gray-500",children:["~",Qa(L)," tokens"]})]}),e.jsx("div",{className:"space-y-1",children:N.map(M=>{const _=Ka(M.content);return e.jsxs("button",{onClick:()=>h(M),className:`w-full flex items-center justify-between text-xs py-1.5 px-2 rounded hover:bg-gray-700/50 transition-colors ${M.enabled?"text-gray-300":"text-gray-500 opacity-60"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[!M.enabled&&e.jsx("span",{className:"text-gray-600",title:"Disabled",children:"●"}),e.jsx("span",{className:"truncate text-left",children:M.name})]}),e.jsxs("span",{className:"text-gray-500 flex-shrink-0 ml-2",children:[Qa(_)," tok"]})]},M.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 N=S.iterations_target!=null,j=S.iterations_completed??0,L=S.iterations_target??0,M=N&&L>0?Math.min(j/L*100,100):0,_=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"}),_&&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:N?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 ${M>=100?"bg-emerald-500":"bg-blue-500"}`,style:{width:`${M}%`}})}),e.jsxs("span",{className:"text-gray-400",children:[j," / ",L]})]}):e.jsx("span",{className:"text-gray-500",children:j>0?`${j} 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:[((C=ph[u.resource_type])==null?void 0:C.label)||u.resource_type," • ",Qa(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 LN({steps:t,selectedIndex:s,onSelect:o,onAdd:l,onMove:i}){const d=p=>p==="interactive"?"Chat":"Automated",u=p=>p==="interactive"?"bg-violet-900/50 text-violet-400 border-violet-700/50":"bg-emerald-900/50 text-emerald-400 border-emerald-700/50",h=p=>{switch(p){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((p,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(p.status),e.jsx("span",{className:"font-medium text-white truncate flex-1",children:p.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(p.step_type)}`,children:d(p.step_type)}),((v=p.config)==null?void 0:v.model)&&p.step_type==="autonomous"&&e.jsx("span",{className:"text-xs text-gray-500",children:p.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"})})})]})]},p.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 Ex({isOpen:t,title:s,message:o,details:l,confirmLabel:i="Confirm",cancelLabel:d="Cancel",variant:u="default",typeToConfirm:h,onConfirm:p,onCancel:g}){const v=x.useRef(null),y=x.useRef(null),[b,k]=x.useState("");x.useEffect(()=>{t&&k("")},[t]),x.useEffect(()=>{t&&(h&&y.current?y.current.focus():v.current&&v.current.focus())},[t,h]);const C=!h||b===h;if(x.useEffect(()=>{if(!t)return;const N=j=>{j.key==="Escape"&&g()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[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:N=>{N.target===N.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:N=>k(N.target.value),onKeyDown:N=>{N.key==="Enter"&&C&&p()},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:p,disabled:!C,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 EN={generator:["{{existing_stories}}"],consumer:["{{input_item.title}}","{{input_item.content}}"]},TN={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 AN(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=EN[s]||[],d=TN[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 PN(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 with web research to create a comprehensive design document",icon:"chat",step_type:"interactive",loopType:"design_doc",defaultTools:["WebSearch","WebFetch","Bash","Read","Glob","Grep"],defaults:{model:"opus",timeout:300}},extractgen_requirements:{label:"Generate Stories (Extract)",description:"Extract user stories from design documents",icon:"list",step_type:"autonomous",loopType:"generator",template:"extractgen_requirements",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}},implementation:{label:"Implementation",description:"Consumes stories and commits code to git",icon:"code",step_type:"autonomous",loopType:"consumer",template:"implementation",defaultTools:["Read","Write","Edit","Bash","Glob","Grep"],defaults:{model:"opus",timeout:1800,max_iterations:50,cooldown_between_iterations:5,max_consecutive_errors:3}}},MN=[{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 RN(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":o==="extractgen_requirements"||o==="research"||s==="generator"||s==="planning"?"extractgen_requirements":"implementation"}function IN(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 $N({step:t,onChange:s}){var Ee,he,re,ke,Le,ft,Lt,He,Qe,Et,bt,Bt,Tt;const o=RN(t),l=jo[o],d=(t.iterations_completed||0)>0||(t.items_generated||0)>0,[u,h]=x.useState(!1),[p,g]=x.useState(""),[v,y]=x.useState([]),[b,k]=x.useState(!1),[C,S]=x.useState(null),[N,j]=x.useState(!1),[L,M]=x.useState(!1),[_,$]=x.useState(!1),[I,P]=x.useState(null),[V,B]=x.useState([]),U=!!((Ee=t.config)!=null&&Ee.customPrompt),z=((he=t.config)==null?void 0:he.customPrompt)||p,T=((re=t.config)==null?void 0:re.loopType)||"consumer",Z=U?AN(((ke=t.config)==null?void 0:ke.customPrompt)||"",T,v):{isValid:!0,warnings:[]},W=t.status==="active"&&t.has_active_run,Q=!W,O=x.useCallback(async()=>{if(t.step_type==="autonomous"&&o!=="design_doc"){k(!0),S(null);try{const de=await pv(T);g(de.prompt),y(de.variables)}catch(de){S("Failed to load default prompt"),console.error("Error fetching default prompt:",de)}finally{k(!1)}}},[t.step_type,o,T]);x.useEffect(()=>{O()},[O]);const R=x.useCallback(de=>{s({...t,config:{...t.config,...de}})},[s,t]);x.useEffect(()=>{var de;(de=t.config)!=null&&de.customPrompt&&o==="design_doc"&&R({customPrompt:void 0})},[o,(Le=t.config)==null?void 0:Le.customPrompt,R]);const Y=de=>{var At,nt;const Re=jo[de];s({...t,step_type:Re.step_type,config:{description:(At=t.config)==null?void 0:At.description,skippable:(nt=t.config)==null?void 0:nt.skippable,loopType:Re.loopType,template:Re.template,allowedTools:Re.defaultTools,model:Re.defaults.model,timeout:Re.defaults.timeout,max_iterations:Re.defaults.max_iterations,cooldown_between_iterations:Re.defaults.cooldown_between_iterations,max_consecutive_errors:Re.defaults.max_consecutive_errors,customPrompt:void 0}})},ie=de=>{if(d||de===o)return;const Re=IN(t,o);Re.length>0?(B(Re),P(de),$(!0)):Y(de)},se=()=>{I&&Y(I),$(!1),P(null),B([])},E=()=>{$(!1),P(null),B([])},G=de=>{var nt;const Re=((nt=t.config)==null?void 0:nt.allowedTools)||[],At=Re.includes(de)?Re.filter(cr=>cr!==de):[...Re,de];R({allowedTools:At})},X=()=>{R({allowedTools:l.defaultTools})},ee=de=>{Q&&(PN(de,p)?R({customPrompt:de}):R({customPrompt:void 0}))},F=de=>{Q&&(de?R({customPrompt:p}):M(!0))},me=()=>{R({customPrompt:void 0}),M(!1)},Ne=de=>l.defaultTools.includes(de),Ae=de=>{switch(de){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:de=>s({...t,name:de.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(([de,Re])=>e.jsxs("button",{type:"button",onClick:()=>ie(de),disabled:d,className:`p-4 rounded-lg border text-left transition-colors ${d?o===de?"bg-gray-800/50 border-gray-600 cursor-not-allowed":"bg-gray-800/30 border-gray-700/50 cursor-not-allowed opacity-50":o===de?de==="design_doc"?"bg-violet-900/30 border-violet-600":de==="extractgen_requirements"?"bg-blue-900/30 border-blue-600":de==="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===de?de==="design_doc"?"text-violet-400":de==="extractgen_requirements"?"text-blue-400":de==="webgen_requirements"?"text-cyan-400":"text-emerald-400":"text-gray-400"}`,children:Ae(Re.icon)}),e.jsx("div",{className:`font-medium text-sm mb-1 ${d?"text-gray-400":"text-white"}`,children:Re.label}),e.jsx("p",{className:`text-xs ${d?"text-gray-600":o===de?"text-gray-300":"text-gray-500"}`,children:Re.description})]},de))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Description"}),e.jsx("textarea",{value:((ft=t.config)==null?void 0:ft.description)||"",onChange:de=>R({description:de.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:((Lt=t.config)==null?void 0:Lt.skippable)||!1,onChange:de=>R({skippable:de.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:((He=t.config)==null?void 0:He.model)||"opus",onChange:de=>R({model:de.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)"})]}),((Qe=t.config)==null?void 0:Qe.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:((Et=t.config)==null?void 0:Et.timeout)||600,onChange:de=>R({timeout:parseInt(de.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:X,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:MN.map(de=>{var nt;const Re=(((nt=t.config)==null?void 0:nt.allowedTools)||[]).includes(de.id),At=Ne(de.id);return e.jsxs("label",{className:`flex items-start gap-2 p-2 rounded cursor-pointer hover:bg-gray-700/50 ${Re?"text-white":"text-gray-500"}`,children:[e.jsx("input",{type:"checkbox",checked:Re,onChange:()=>G(de.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:[de.label,At&&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:de.description})]})]},de.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:((bt=t.config)==null?void 0:bt.max_iterations)??"",onChange:de=>R({max_iterations:de.target.value?parseInt(de.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:((Bt=t.config)==null?void 0:Bt.cooldown_between_iterations)??"",onChange:de=>R({cooldown_between_iterations:de.target.value?parseInt(de.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:((Tt=t.config)==null?void 0:Tt.max_consecutive_errors)??"",onChange:de=>R({max_consecutive_errors:de.target.value?parseInt(de.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==="extractgen_requirements"?"Extract Requirements (Story Extraction)":"Implementation"," steps."]}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("button",{type:"button",onClick:()=>j(!N),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 ${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"})}),N?"Hide":"View"," Template Variables"]})}),N&&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(de=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("code",{className:`px-1.5 py-0.5 rounded font-mono ${de.required?"bg-amber-900/30 text-amber-400":"bg-gray-800 text-gray-400"}`,children:de.name}),e.jsxs("span",{className:"text-gray-500",children:[de.description,de.required&&e.jsx("span",{className:"text-amber-400 ml-1",children:"(required)"})]})]},de.name))}):e.jsx("div",{className:"text-gray-500",children:"No variables available"})]}),C&&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:C}),e.jsx("button",{type:"button",onClick:O,className:"text-red-300 hover:text-red-200 underline",children:"Retry"})]}),U&&Z.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:Z.warnings.map((de,Re)=>e.jsx("li",{children:de},Re))})]}),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:z,onChange:de=>ee(de.target.value),readOnly:!U||!Q,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||!Q?"border-gray-700 cursor-not-allowed opacity-75":Z.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:de=>F(de.target.checked),disabled:!Q,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 ${Q?"text-gray-300":"text-gray-500"}`,children:"Use Custom Instructions"})]}),U&&Q&&e.jsxs("button",{type:"button",onClick:()=>M(!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"]})]}),L&&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:()=>M(!1),className:"px-3 py-1.5 text-sm text-gray-400 hover:text-white",children:"Cancel"}),e.jsx("button",{type:"button",onClick:me,className:"px-3 py-1.5 text-sm bg-red-600 text-white rounded hover:bg-red-500",children:"Reset"})]})]})]})]})]}),_&&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:V.map((de,Re)=>e.jsx("li",{children:de},Re))}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:E,className:"px-4 py-2 text-gray-400 hover:text-white transition-colors",children:"Cancel"}),e.jsx("button",{type:"button",onClick:se,className:"px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-500 transition-colors",children:"Change Type"})]})]})})]})}function BN({projectSlug:t,loopName:s,onClose:o,onSave:l}){var U;const[i,d]=x.useState(!0),[u,h]=x.useState(!1),[p,g]=x.useState(null),[v,y]=x.useState(null),[b,k]=x.useState([]),[C,S]=x.useState(""),[N,j]=x.useState("template"),[L,M]=x.useState(""),[_,$]=x.useState(null),I=x.useCallback(async()=>{d(!0),g(null);try{const[z,T]=await Promise.all([fv(t,s),xv()]);if(y(z),k(T),z.source==="template"&&z.template_id)S(z.template_id),j("template");else if(z.source==="custom")j("custom");else{const Z=T.length>0?T[0].id:z.template_id||"";S(Z),j("template")}M(JSON.stringify(z.permissions,null,2))}catch(z){g(z instanceof Error?z.message:"Failed to load permissions")}finally{d(!1)}},[t,s]);x.useEffect(()=>{I()},[I]),x.useEffect(()=>{const z=T=>{T.key==="Escape"&&!u&&o()};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[o,u]),x.useEffect(()=>{if(N==="custom")try{JSON.parse(L),$(null)}catch{$("Invalid JSON syntax")}else $(null)},[L,N]);const P=async()=>{h(!0),g(null);try{if(N==="template")await _0(t,s,{template_id:C,permissions:{allow:[]}});else{const z=JSON.parse(L);await _0(t,s,{permissions:z})}l==null||l(),o()}catch(z){g(z instanceof Error?z.message:"Failed to save permissions")}finally{h(!1)}},V=async()=>{if(confirm("Reset to default permissions? This will remove any custom settings.")){h(!0),g(null);try{await gv(t,s),await I()}catch(z){g(z instanceof Error?z.message:"Failed to reset permissions")}finally{h(!1)}}},B=z=>{S(z)};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"})}):p?e.jsx("div",{className:"p-4 bg-red-900/20 border border-red-800 rounded-lg text-red-400",children:p}):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:V,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:()=>j("template"),className:`flex-1 py-2 px-4 rounded-lg text-sm font-medium transition-colors ${N==="template"?"bg-primary-600 text-white":"bg-gray-800 text-gray-400 hover:text-white"}`,children:"Use Template"}),e.jsx("button",{onClick:()=>j("custom"),className:`flex-1 py-2 px-4 rounded-lg text-sm font-medium transition-colors ${N==="custom"?"bg-primary-600 text-white":"bg-gray-800 text-gray-400 hover:text-white"}`,children:"Custom Permissions"})]}),N==="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:C,onChange:z=>B(z.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(z=>e.jsx("option",{value:z.id,children:z.name},z.id))})]}),b.find(z=>z.id===C)&&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(z=>z.id===C))==null?void 0:U.description})})]})}),N==="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:L,onChange:z=>M(z.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 ${_?"border-red-600 focus:border-red-500":"border-gray-600 focus:border-primary-500"}`,placeholder:'{"allow": ["Read(**)", "Write(**)", ...], "deny": []}'}),_&&e.jsx("p",{className:"mt-1 text-sm text-red-400",children:_})]}),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:P,disabled:u||i||N==="custom"&&!!_||N==="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 DN({projectSlug:t,workflowId:s,step:o,onChange:l,onClone:i,onArchive:d,onError:u}){var ee;const[h,p]=x.useState("settings"),[g,v]=x.useState([]),[y,b]=x.useState([]),[k,C]=x.useState(!1),[S,N]=x.useState(!1),[j,L]=x.useState(!1),[M,_]=x.useState({name:"",resource_type:"guardrail",content:""}),[$,I]=x.useState(!1),[P,V]=x.useState(null),[B,U]=x.useState(!1),[z,T]=x.useState(!1),[Z,W]=x.useState(!1);x.useEffect(()=>{p("settings")},[o.id]),x.useEffect(()=>{if(!(j||$||z))return;const me=Ne=>{Ne.key==="Escape"&&(j?L(!1):$?I(!1):z&&T(!1))};return window.addEventListener("keydown",me),()=>window.removeEventListener("keydown",me)},[j,$,z]);const Q=x.useCallback(async()=>{if(o.id){C(!0);try{const[F,me]=await Promise.all([fl(t,s),i2(t,s,o.id)]);v(F),b(me)}catch(F){u(F instanceof Error?F.message:"Failed to load resources")}finally{C(!1)}}},[t,s,o.id,u]);x.useEffect(()=>{h==="resources"&&o.id&&Q()},[h,o.id,Q]);const O=async F=>{if(!(!o.id||S)){N(!0);try{y.find(Ne=>Ne.workflow_resource_id===F.id&&Ne.mode==="disable")?await m2(t,s,o.id,F.id):await u2(t,s,o.id,F.id),await Q()}catch(me){u(me instanceof Error?me.message:"Failed to toggle resource")}finally{N(!1)}}},R=F=>y.some(me=>me.workflow_resource_id===F&&me.mode==="disable"),Y=async F=>{if(F.preventDefault(),!(!o.id||!M.name.trim()||!M.content.trim())&&!S){N(!0);try{await c2(t,s,o.id,{mode:"add",resource_type:M.resource_type,name:M.name.trim(),content:M.content.trim()}),_({name:"",resource_type:"guardrail",content:""}),L(!1),await Q()}catch(me){u(me instanceof Error?me.message:"Failed to add step resource")}finally{N(!1)}}},ie=async F=>{if(!(!o.id||S)&&confirm("Delete this step resource?")){N(!0);try{await d2(t,s,o.id,F.id),await Q()}catch(me){u(me instanceof Error?me.message:"Failed to delete step resource")}finally{N(!1)}}},se=async()=>{if(o.id){U(!0);try{const F=await h2(t,s,o.id);V(F),I(!0)}catch(F){u(F instanceof Error?F.message:"Failed to load preview")}finally{U(!1)}}},E=F=>{switch(F){case"design_doc":return"Design Document";case"guardrail":return"Guideline";case"input_file":return"Input File";case"prompt":return"Prompt";default:return F}},G=F=>{switch(F){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"})})}},X=[{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",((ee=o.config)==null?void 0:ee.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:X.map(F=>e.jsx("button",{onClick:()=>!F.disabled&&p(F.key),disabled:F.disabled,className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${h===F.key?"border-primary-500 text-white":F.disabled?"border-transparent text-gray-600 cursor-not-allowed":"border-transparent text-gray-400 hover:text-gray-300"}`,children:F.label},F.key))}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[(h==="settings"||o.step_type==="interactive")&&e.jsx($N,{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:se,disabled:B,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:B?"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(F=>{const me=R(F.id);return e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border ${me?"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 ${me?"bg-gray-700 text-gray-500":"bg-primary-500/20 text-primary-400"}`,children:G(F.resource_type)}),e.jsxs("div",{children:[e.jsx("div",{className:`font-medium ${me?"text-gray-500":"text-white"}`,children:F.name}),e.jsxs("div",{className:"text-xs text-gray-500",children:[E(F.resource_type),me&&" — disabled for this step"]})]})]}),e.jsx("button",{onClick:()=>O(F),disabled:S,className:`px-3 py-1 text-xs rounded transition-colors ${me?"bg-gray-700 text-gray-400 hover:bg-gray-600":"bg-green-600/20 text-green-400 hover:bg-green-600/30"}`,children:me?"Enable":"Enabled"})]},F.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:()=>L(!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(F=>F.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(F=>F.mode==="add").map(F=>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:G(F.resource_type||"custom")}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-white",children:F.name}),e.jsxs("div",{className:"text-xs text-gray-500",children:[E(F.resource_type||"custom")," — step-specific"]})]})]}),e.jsx("button",{onClick:()=>ie(F),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"})})})]},F.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:()=>T(!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."})]})]})})]}),j&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:F=>{F.target===F.currentTarget&&L(!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:M.resource_type,onChange:F=>_({...M,resource_type:F.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:M.name,onChange:F=>_({...M,name:F.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:M.content,onChange:F=>_({...M,content:F.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:()=>L(!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:!M.name.trim()||!M.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"})]})]})]})}),$&&P&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:F=>{F.target===F.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:[P.resources_used.length," resources • ~",P.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:P.prompt_sections.length===0?e.jsx("div",{className:"text-center py-8 text-gray-500",children:"No resources will be injected for this step."}):P.prompt_sections.map((F,me)=>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:F.resource_name}),e.jsx("span",{className:"text-xs bg-gray-600 text-gray-300 px-2 py-0.5 rounded",children:F.resource_type})]}),e.jsx("span",{className:"text-xs text-gray-500",children:F.position})]}),e.jsx("pre",{className:"p-4 text-sm text-gray-300 overflow-x-auto bg-gray-900 max-h-64",children:F.content.length>2e3?F.content.slice(0,2e3)+`
191
- ... (truncated)`:F.content})]},me))}),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"})})]})}),z&&o.loop_name&&e.jsx(BN,{projectSlug:t,loopName:o.loop_name,onClose:()=>T(!1),onSave:()=>{}}),e.jsx(Ex,{isOpen:Z,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 ON({archivedSteps:t,loading:s,onRestore:o,onPermanentlyDelete:l}){const[i,d]=x.useState(!1),[u,h]=x.useState(null),[p,g]=x.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:p!==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:p===v.id?"Restoring...":"Restore"}),e.jsx("button",{onClick:()=>h(v),disabled:p!==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:p===v.id?"Deleting...":"Delete"})]})]},v.id))}),e.jsx(Ex,{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 WN({projectSlug:t,workflowId:s,steps:o,onStepsChange:l,onError:i}){const[d,u]=x.useState(o.length>0?0:null),[h,p]=x.useState([]),[g,v]=x.useState(!1),y=d!==null?o[d]:null,b=x.useCallback(async()=>{if(s){v(!0);try{const _=await e2(t,s);p(_)}catch(_){console.error("Failed to load archived steps:",_)}finally{v(!1)}}},[t,s]);x.useEffect(()=>{b()},[b]);const k=()=>{const _={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,_]),u(o.length)},C=_=>{const $=o[_],I={id:0,workflow_id:s,step_number:o.length+1,name:`${$.name} (Copy)`,step_type:$.step_type,status:"pending",config:{...$.config},iterations_completed:0,items_generated:0};l([...o,I]),u(o.length)},S=async _=>{const $=o[_];if(!$.id){const I=o.filter((P,V)=>V!==_);l(I),d===_?u(I.length>0?Math.max(0,_-1):null):d!==null&&d>_&&u(d-1);return}try{await Xv(t,s,$.id);const I=o.filter((P,V)=>V!==_);l(I),p(P=>[...P,{...$,archived_at:new Date().toISOString()}]),d===_?u(I.length>0?Math.max(0,_-1):null):d!==null&&d>_&&u(d-1)}catch(I){i(I instanceof Error?I.message:"Failed to archive step")}},N=async _=>{try{const $=await Zv(t,s,_.id);p(V=>V.filter(B=>B.id!==_.id));const I=[...o],P=I.findIndex(V=>V.step_number>$.step_number);P===-1?I.push($):I.splice(P,0,$),l(I)}catch($){i($ instanceof Error?$.message:"Failed to restore step")}},j=async _=>{try{await Wh(t,s,_.id),p($=>$.filter(I=>I.id!==_.id))}catch($){i($ instanceof Error?$.message:"Failed to delete step")}},L=(_,$)=>{const I=$==="up"?_-1:_+1;if(I<0||I>=o.length)return;const P=[...o],[V]=P.splice(_,1);P.splice(I,0,V),l(P),d===_?u(I):d===I&&u(_)},M=_=>{if(d===null)return;const $=[...o];$[d]=_,l($)};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(LN,{steps:o,selectedIndex:d,onSelect:u,onAdd:k,onMove:L})}),e.jsx(ON,{archivedSteps:h,loading:g,onRestore:N,onPermanentlyDelete:j})]}),e.jsx("div",{className:"flex-1 min-w-0",children:y?e.jsx(DN,{projectSlug:t,workflowId:s,step:y,onChange:M,onClone:()=>C(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 FN({projectSlug:t,workflowId:s,resources:o,projectResources:l,onResourcesChange:i,onError:d}){const[u,h]=x.useState(!1),[p,g]=x.useState(!1),[v,y]=x.useState(!1),[b,k]=x.useState(null),[C,S]=x.useState(""),[N,j]=x.useState({name:"",resource_type:"guardrail",content:""});x.useEffect(()=>{if(!(p||v||b!==null))return;const Y=ie=>{ie.key==="Escape"&&(p?(g(!1),j({name:"",resource_type:"guardrail",content:""})):v?y(!1):b&&k(null))};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[p,v,b]);const L=async R=>{if(R.preventDefault(),!(!N.name.trim()||!N.content.trim())&&!u){h(!0);try{await Gc(t,s,{name:N.name.trim(),resource_type:N.resource_type,content:N.content.trim(),source:"manual"}),j({name:"",resource_type:"guardrail",content:""}),g(!1),i()}catch(Y){d(Y instanceof Error?Y.message:"Failed to add resource")}finally{h(!1)}}},M=async R=>{if(!u){h(!0);try{await zh(t,s,R.id),y(!1),i()}catch(Y){d(Y instanceof Error?Y.message:"Failed to import resource")}finally{h(!1)}}},_=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)}}},$=async()=>{if(b&&!u){h(!0);try{await So(t,s,b.id,{content:C}),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 Fh(t,s,R.id),i()}catch(Y){d(Y instanceof Error?Y.message:"Failed to delete resource")}finally{h(!1)}}},P=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}},V=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"})})}},B=new Set(o.filter(R=>R.source_id).map(R=>R.source_id)),U=l.filter(R=>!B.has(R.id)),z=o.filter(R=>R.resource_type==="design_doc"),T=o.filter(R=>R.resource_type==="guardrail"),Z=o.filter(R=>R.resource_type==="input_file"),W=o.filter(R=>R.resource_type==="prompt"),Q=o.filter(R=>!["design_doc","guardrail","input_file","prompt"].includes(R.resource_type)),O=(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(se=>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 ${se.enabled?"bg-primary-500/20 text-primary-400":"bg-gray-700 text-gray-500"}`,children:V(se.resource_type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-white truncate",children:se.name}),e.jsxs("div",{className:"text-xs text-gray-400",children:[P(se.resource_type),se.source&&` • ${se.source}`]}),se.content&&e.jsx("p",{className:"text-xs text-gray-500 mt-1 line-clamp-2",children:se.content.length>150?`${se.content.slice(0,150)}...`:se.content})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>_(se),disabled:u,className:`px-2 py-1 text-xs rounded disabled:opacity-50 ${se.enabled?"bg-green-600/20 text-green-400":"bg-gray-700 text-gray-500"}`,children:se.enabled?"On":"Off"}),e.jsx("button",{onClick:()=>{k(se),S(se.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(se),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"})})})]})]},se.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:[O("Design Documents",z,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"})})),O("Guidelines",T,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"})})),O("Input Files",Z,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"})})),O("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"})})),O("Other",Q,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"})}))]}),p&&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),j({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:L,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:N.resource_type,onChange:R=>j({...N,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:N.name,onChange:R=>j({...N,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(!N.name.trim()){const E=Y.name.replace(/\.[^/.]+$/,"");j(G=>({...G,name:E}))}const se=new FileReader;se.onload=E=>{var X;const G=(X=E.target)==null?void 0:X.result;j(ee=>({...ee,content:G}))},se.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:N.content,onChange:R=>j({...N,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"}),N.content&&e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[N.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),j({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:!N.name.trim()||!N.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:()=>M(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:P(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:P(b.resource_type)})]}),e.jsx("textarea",{value:C,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:$,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 zN({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 HN(){const{slug:t,workflowId:s}=yr(),o=ir(),[l,i]=x.useState(null),[d,u]=x.useState(!0),[h,p]=x.useState(null),[g,v]=x.useState(""),[y,b]=x.useState([]),[k,C]=x.useState([]),[S,N]=x.useState([]),[j,L]=x.useState("overview"),[M,_]=x.useState(!1),[$,I]=x.useState(!1),P=x.useCallback(async()=>{if(!(!t||!s))try{const T=await Po(t,s);i(T),v(T.name),b([...T.steps]),p(null)}catch(T){p(T instanceof Error?T.message:"Failed to load workflow")}finally{u(!1)}},[t,s]),V=x.useCallback(async()=>{if(!(!t||!s||!l))try{const[T,Z]=await Promise.all([fl(t,l.id),Kc(t)]);C(T),N(Z)}catch(T){p(T instanceof Error?T.message:"Failed to load resources")}},[t,s,l]);x.useEffect(()=>{P()},[P]),x.useEffect(()=>{l&&V()},[l,V]),x.useEffect(()=>{if(!l)return;const T=g!==l.name,Z=JSON.stringify(y)!==JSON.stringify(l.steps);I(T||Z)},[l,g,y]),x.useEffect(()=>{const T=Z=>{$&&(Z.preventDefault(),Z.returnValue="")};return window.addEventListener("beforeunload",T),()=>window.removeEventListener("beforeunload",T)},[$]);const B=x.useCallback(async()=>{var T,Z,W,Q,O,R,Y,ie,se,E,G,X,ee,F,me,Ne,Ae,Ee,he,re,ke,Le,ft,Lt,He,Qe,Et,bt,Bt,Tt,de,Re,At,nt,cr,gt,Ar,js,vr,wr,Gs,Ns,ks;if(!(!l||!t)){_(!0),p(null);try{g!==l.name&&await Uv(t,l.id,{name:g});const Dt=new Set(l.steps.map(Me=>Me.id)),dr=new Set(y.filter(Me=>Me.id).map(Me=>Me.id));for(const Me of l.steps)dr.has(Me.id)||await Wh(t,l.id,Me.id);const oe=[];for(let Me=0;Me<y.length;Me++){const we=y[Me];if(!we.id||!Dt.has(we.id)){const Ie={name:we.name,step_type:we.step_type,description:(T=we.config)==null?void 0:T.description,skippable:(Z=we.config)==null?void 0:Z.skippable,loop_type:(W=we.config)==null?void 0:W.loopType,template:(Q=we.config)==null?void 0:Q.template};we.step_type==="autonomous"&&(Ie.model=(O=we.config)==null?void 0:O.model,Ie.timeout=(R=we.config)==null?void 0:R.timeout,Ie.allowed_tools=(Y=we.config)==null?void 0:Y.allowedTools,Ie.max_iterations=(ie=we.config)==null?void 0:ie.max_iterations,Ie.cooldown_between_iterations=(se=we.config)==null?void 0:se.cooldown_between_iterations,Ie.max_consecutive_errors=(E=we.config)==null?void 0:E.max_consecutive_errors);const Pr=await Qv(t,l.id,Ie);oe.push(Pr.id)}else{const Ie=l.steps.find(Yt=>Yt.id===we.id);if(Ie&&(Ie.name!==we.name||Ie.step_type!==we.step_type||((G=Ie.config)==null?void 0:G.description)!==((X=we.config)==null?void 0:X.description)||((ee=Ie.config)==null?void 0:ee.skippable)!==((F=we.config)==null?void 0:F.skippable)||((me=Ie.config)==null?void 0:me.loopType)!==((Ne=we.config)==null?void 0:Ne.loopType)||((Ae=Ie.config)==null?void 0:Ae.template)!==((Ee=we.config)==null?void 0:Ee.template)||((he=Ie.config)==null?void 0:he.model)!==((re=we.config)==null?void 0:re.model)||((ke=Ie.config)==null?void 0:ke.timeout)!==((Le=we.config)==null?void 0:Le.timeout)||JSON.stringify((ft=Ie.config)==null?void 0:ft.allowedTools)!==JSON.stringify((Lt=we.config)==null?void 0:Lt.allowedTools)||((He=Ie.config)==null?void 0:He.max_iterations)!==((Qe=we.config)==null?void 0:Qe.max_iterations)||((Et=Ie.config)==null?void 0:Et.cooldown_between_iterations)!==((bt=we.config)==null?void 0:bt.cooldown_between_iterations)||((Bt=Ie.config)==null?void 0:Bt.max_consecutive_errors)!==((Tt=we.config)==null?void 0:Tt.max_consecutive_errors)||((de=Ie.config)==null?void 0:de.customPrompt)!==((Re=we.config)==null?void 0:Re.customPrompt))){const Yt={name:we.name,step_type:we.step_type,description:(At=we.config)==null?void 0:At.description,skippable:(nt=we.config)==null?void 0:nt.skippable,loop_type:(cr=we.config)==null?void 0:cr.loopType,template:((gt=we.config)==null?void 0:gt.template)||""};we.step_type==="autonomous"&&(Yt.model=(Ar=we.config)==null?void 0:Ar.model,Yt.timeout=(js=we.config)==null?void 0:js.timeout,Yt.allowed_tools=(vr=we.config)==null?void 0:vr.allowedTools,Yt.max_iterations=(wr=we.config)==null?void 0:wr.max_iterations,Yt.cooldown_between_iterations=(Gs=we.config)==null?void 0:Gs.cooldown_between_iterations,Yt.max_consecutive_errors=(Ns=we.config)==null?void 0:Ns.max_consecutive_errors,((ks=we.config)==null?void 0:ks.customPrompt)!==void 0&&(Yt.custom_prompt=we.config.customPrompt||"")),await Jv(t,l.id,we.id,Yt)}oe.push(we.id)}}const Te=l.steps.map(Me=>Me.id);JSON.stringify(Te)!==JSON.stringify(oe)&&await t2(t,l.id,oe),await P(),I(!1)}catch(Dt){p(Dt instanceof Error?Dt.message:"Failed to save workflow")}finally{_(!1)}}},[l,t,g,y,P]),U=x.useCallback(()=>{$&&!window.confirm("You have unsaved changes. Are you sure you want to leave?")||o(`/projects/${t}/workflows/${s}`)},[$,o,t,s]);if(x.useEffect(()=>{const T=Z=>{document.querySelector(".fixed.inset-0.bg-black\\/50")||((Z.metaKey||Z.ctrlKey)&&Z.key==="s"&&(Z.preventDefault(),$&&!M&&B()),Z.key==="Escape"&&U())};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[$,M,B,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(je,{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 z=[{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(CN,{workflowName:g,onBack:U,onSave:B,saving:M,dirty:$}),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:()=>p(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:z.map(T=>e.jsxs("button",{onClick:()=>L(T.key),className:`pb-4 px-1 border-b-2 font-medium text-sm transition-colors ${j===T.key?"border-primary-500 text-primary-400":"border-transparent text-gray-400 hover:text-gray-300 hover:border-gray-500"}`,children:[T.label,T.key==="steps"&&` (${y.length})`,T.key==="resources"&&k.length>0&&` (${k.length})`]},T.key))})}),e.jsxs("div",{className:"p-6",children:[j==="overview"&&e.jsx(_N,{workflow:l,workflowName:g,onNameChange:T=>v(T),steps:y,resources:k,onViewResources:()=>L("resources")}),j==="steps"&&e.jsx(WN,{projectSlug:t,workflowId:l.id,steps:y,onStepsChange:T=>b(T),onError:T=>p(T)}),j==="resources"&&e.jsx(FN,{projectSlug:t,workflowId:l.id,resources:k,projectResources:S,onResourcesChange:V,onError:T=>p(T)}),j==="settings"&&e.jsx(zN,{workflow:l,projectSlug:t,onWorkflowUpdate:P,onError:T=>p(T)})]})]})}function UN({projectId:t,onAccountChange:s}){const[o,l]=x.useState([]),[i,d]=x.useState(null),[u,h]=x.useState(!0),[p,g]=x.useState(!1),[v,y]=x.useState(null),[b,k]=x.useState("default"),[C,S]=x.useState(!0),N=async()=>{h(!0);try{const[B,U,z]=await Promise.all([Bh(),$v(t),Dv(t)]);l(B),d(z),U?(k(U.account_id),S(U.allow_fallback)):(k("default"),S(!0)),y(null)}catch{y("Failed to load account settings")}finally{h(!1)}};x.useEffect(()=>{N()},[t]);const j=async B=>{const U=B==="default"?"default":parseInt(B,10);k(U),g(!0),y(null);try{U==="default"?await Bv(t):await L0(t,{account_id:U,allow_fallback:C}),await N(),s==null||s()}catch(z){y(z instanceof Error?z.message:"Failed to update account"),N()}finally{g(!1)}},L=async B=>{if(S(B),b!=="default"){g(!0);try{await L0(t,{account_id:b,allow_fallback:B}),s==null||s()}catch{y("Failed to update fallback setting"),S(!B)}finally{g(!1)}}},M=B=>B>=90?"bg-red-500":B>=71?"bg-yellow-500":"bg-green-500",_=B=>B>=90?"text-red-400":B>=71?"text-yellow-400":"text-green-400",$=B=>{if(!B)return"";const U=new Date(B),z=new Date,T=U.toDateString()===z.toDateString(),Z=new Date(z);Z.setDate(Z.getDate()+1);const W=U.toDateString()===Z.toDateString(),Q=U.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return T?Q:W?`tomorrow ${Q}`:U.toLocaleDateString([],{month:"short",day:"numeric"})},I=B=>B?e.jsxs("span",{className:`text-xs ${_(B.five_hour)}`,children:["5h: ",Math.round(B.five_hour),"% · 7d: ",Math.round(B.seven_day),"%"]}):null,P=()=>o.find(B=>B.is_default);if(u)return e.jsxs("div",{className:"card 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"})]});if(o.length===0)return e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Claude Account"}),e.jsxs("div",{className:"text-center py-6",children:[e.jsx("svg",{className:"w-10 h-10 text-gray-600 mx-auto mb-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M18 9v3m0 0v3m0-3h3m-3 0h-3m-2-5a4 4 0 11-8 0 4 4 0 018 0zM3 20a6 6 0 0112 0v1H3v-1z"})}),e.jsx("p",{className:"text-gray-400 mb-3",children:"No Claude accounts connected"}),e.jsx(je,{to:"/settings",className:"text-primary-400 hover:text-primary-300 text-sm",children:"Connect an account in Settings →"})]})]});const V=P();return e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Claude Account"}),v&&e.jsxs("div",{className:"mb-4 p-3 bg-red-900/30 border border-red-800 rounded text-red-400 text-sm",children:[v,e.jsx("button",{onClick:()=>y(null),className:"ml-2 text-red-300 hover:text-red-200",children:"×"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-400 mb-2",children:"Account for this project"}),e.jsxs("select",{value:b,onChange:B=>j(B.target.value),disabled:p,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white disabled:opacity-50",children:[e.jsxs("option",{value:"default",children:["Use default account",V&&` (${V.email})`]}),o.map(B=>e.jsxs("option",{value:B.id,disabled:!B.is_active,children:[B.display_name||B.email,B.is_default&&" ⭐",!B.is_active&&" (disabled)",B.usage&&` — 5h: ${Math.round(B.usage.five_hour)}%`]},B.id))]})]}),b==="default"&&V&&e.jsxs("div",{className:"p-3 bg-gray-700/50 rounded border border-gray-600",children:[e.jsx("p",{className:"text-sm text-gray-400 mb-1",children:"Currently using:"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-white",children:V.email}),V.usage&&I(V.usage)]})]}),e.jsxs("label",{className:"flex items-start space-x-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:C,onChange:B=>L(B.target.checked),disabled:p,className:"mt-1 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:"Allow fallback when account reaches usage limit"}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"When rate limited (429), automatically retry with another account that has available capacity"})]})]}),i&&e.jsxs("div",{className:"pt-4 border-t border-gray-700",children:[e.jsx("p",{className:"text-sm text-gray-400 mb-2",children:"Effective Account"}),e.jsxs("div",{className:"p-3 bg-gray-800 rounded border border-gray-700",children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("span",{className:"text-white font-medium",children:i.email}),i.subscription_type&&e.jsxs("span",{className:"text-xs text-gray-500 capitalize",children:["· ",i.subscription_type]})]})}),i.usage&&e.jsxs("div",{className:"flex gap-4 mt-3",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-xs",children:"5h"}),e.jsxs("span",{className:`text-xs font-medium ${_(i.usage.five_hour)}`,children:[Math.round(i.usage.five_hour),"%"]})]}),e.jsx("div",{className:"h-1.5 bg-gray-600 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full ${M(i.usage.five_hour)}`,style:{width:`${Math.min(100,i.usage.five_hour)}%`}})}),i.usage.five_hour_resets_at&&e.jsxs("p",{className:"text-gray-500 text-xs mt-0.5",children:["resets ",$(i.usage.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-xs",children:"7d"}),e.jsxs("span",{className:`text-xs font-medium ${_(i.usage.seven_day)}`,children:[Math.round(i.usage.seven_day),"%"]})]}),e.jsx("div",{className:"h-1.5 bg-gray-600 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full ${M(i.usage.seven_day)}`,style:{width:`${Math.min(100,i.usage.seven_day)}%`}})}),i.usage.seven_day_resets_at&&e.jsxs("p",{className:"text-gray-500 text-xs mt-0.5",children:["resets ",$(i.usage.seven_day_resets_at)]})]})]})]})]}),e.jsx("div",{className:"pt-2",children:e.jsx(je,{to:"/settings",className:"text-sm text-primary-400 hover:text-primary-300",children:"Manage accounts in Settings →"})})]})]})}function VN(){const{slug:t}=yr(),[s,o]=Hy(),{selectedProject:l,setSelectedProject:i}=Tr(),[d,u]=x.useState([]),[h,p]=x.useState(null),[g,v]=x.useState(!0),[y,b]=x.useState(null),[k,C]=x.useState(!1),S=s.get("tab"),j=S&&["auth","resources","defaults"].includes(S)?S:"auth",[L,M]=x.useState(j),_=F=>{M(F),o({tab:F})},[$,I]=x.useState(!1),[P,V]=x.useState({name:"",resource_type:"guardrail",content:"",description:"",auto_inherit:!0}),[B,U]=x.useState(!1),[z,T]=x.useState(null),[Z,W]=x.useState(""),[Q,O]=x.useState(!1),R=x.useCallback(async()=>{if(t){v(!0),b(null);try{const[F,me,Ne]=await Promise.all([Vs(t),Kc(t),f2(t)]);i(F),u(me),p(Ne)}catch(F){b(F instanceof Error?F.message:"Failed to load settings")}finally{v(!1)}}},[t,i]);x.useEffect(()=>{R()},[R]);const Y=async F=>{if(F.preventDefault(),!(!t||!P.name.trim()||!P.content.trim())){U(!0);try{await p2(t,{name:P.name.trim(),resource_type:P.resource_type,content:P.content.trim(),description:P.description.trim()||void 0,auto_inherit:P.auto_inherit}),V({name:"",resource_type:"guardrail",content:"",description:"",auto_inherit:!0}),I(!1),R()}catch(me){b(me instanceof Error?me.message:"Failed to add resource")}finally{U(!1)}}},ie=async()=>{if(!(!t||!z)){O(!0);try{await A0(t,z.id,{content:Z}),T(null),R()}catch(F){b(F instanceof Error?F.message:"Failed to save resource")}finally{O(!1)}}},se=async F=>{if(t)try{await A0(t,F.id,{auto_inherit:!F.auto_inherit}),R()}catch(me){b(me instanceof Error?me.message:"Failed to update resource")}},E=async F=>{if(t&&confirm(`Delete "${F.name}"? This cannot be undone.`))try{await x2(t,F.id),R()}catch(me){b(me instanceof Error?me.message:"Failed to delete resource")}},G=async(F,me)=>{if(!(!t||!h)){p({...h,[F]:me}),C(!0);try{const Ne=await g2(t,{[F]:me});p(Ne)}catch(Ne){p({...h,[F]:!me}),b(Ne instanceof Error?Ne.message:"Failed to save setting")}finally{C(!1)}}},X=F=>{switch(F){case"design_doc":return"Design Document";case"guardrail":return"Guardrail";case"prompt":return"Prompt Template";default:return F}},ee=[{key:"auth",label:"Authentication"},{key:"resources",label:"Shared Resources"},{key:"defaults",label:"Defaults"}];return g?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(je,{to:"/",className:"hover:text-white",children:"Dashboard"}),e.jsx("span",{children:"/"}),e.jsx(je,{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."})]}),y&&e.jsx("div",{className:"mb-4 p-3 bg-red-900/30 border border-red-800 rounded text-red-400",children:y}),e.jsx("div",{className:"flex space-x-1 mb-6 border-b border-gray-700",children:ee.map(F=>e.jsx("button",{onClick:()=>_(F.key),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${L===F.key?"border-primary-500 text-white":"border-transparent text-gray-400 hover:text-gray-300"}`,children:F.label},F.key))}),L==="auth"&&l&&e.jsx("div",{className:"space-y-6",children:e.jsx(UN,{projectId:l.id})}),L==="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:()=>I(!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"})]})]}),d.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:d.map(F=>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:F.name}),e.jsx("div",{className:"flex items-center space-x-4 text-sm text-gray-400 mt-1",children:e.jsx("span",{children:X(F.resource_type)})}),F.description&&e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:F.description})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>se(F),className:`px-3 py-1 text-sm rounded ${F.auto_inherit?"bg-primary-600/20 text-primary-400":"bg-gray-700 text-gray-500"}`,children:F.auto_inherit?"Auto-inherit":"Manual"}),e.jsx("button",{onClick:()=>{T(F),W(F.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:()=>E(F),className:"px-3 py-1 text-sm rounded bg-red-900/30 text-red-400 hover:bg-red-900/50",children:"Delete"})]})]},F.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.'})]})]})})]}),L==="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"}),k&&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:(h==null?void 0:h.auto_inherit_guardrails)??!0,onChange:F=>G("auto_inherit_guardrails",F.target.checked),disabled:k,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:(h==null?void 0:h.require_design_doc)??!1,onChange:F=>G("require_design_doc",F.target.checked),disabled:k,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:(h==null?void 0:h.architecture_first_mode)??!1,onChange:F=>G("architecture_first_mode",F.target.checked),disabled:k,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."})]})]})})]}),$&&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: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:F=>V({...P,resource_type:F.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:P.name,onChange:F=>V({...P,name:F.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:P.description,onChange:F=>V({...P,description:F.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:P.content,onChange:F=>V({...P,content:F.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:P.auto_inherit,onChange:F=>V({...P,auto_inherit:F.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:()=>I(!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:B||!P.name.trim()||!P.content.trim(),className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500 disabled:opacity-50",children:B?"Adding...":"Add Resource"})]})]})]})}),z&&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:z.name}),e.jsx("span",{className:"text-sm bg-gray-700 text-gray-400 px-2 py-1 rounded",children:X(z.resource_type)})]}),e.jsx("textarea",{value:Z,onChange:F=>W(F.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:()=>T(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:ie,disabled:Q,className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500 disabled:opacity-50",children:Q?"Saving...":"Save Changes"})]})]})})]})}function xh(){const{slug:t}=yr(),{selectedProject:s,setSelectedProject:o}=Tr(),[l,i]=x.useState([]),[d,u]=x.useState(!0),[h,p]=x.useState(null),[g,v]=x.useState(null),[y,b]=x.useState([]),[k,C]=x.useState(!1),[S,N]=x.useState(null),j=x.useCallback(async()=>{if(t){u(!0),p(null);try{const _=await dv(t);i(_)}catch(_){p(_ instanceof Error?_.message:"Failed to load runs")}finally{u(!1)}}},[t]);x.useEffect(()=>{if(!t)return;async function _(){try{const $=await Vs(t);o($)}catch{}}_(),j()},[t,o,j]);const L=async _=>{if(g===_){v(null),b([]);return}v(_),C(!0);try{const $=await uv(t,_);b($.sessions)}catch{b([])}finally{C(!1)}},M={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(je,{to:"/",className:"hover:text-white",children:"Dashboard"}),e.jsx("span",{children:"/"}),e.jsx(je,{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:()=>N(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(Op,{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(_=>e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"flex items-center justify-between cursor-pointer",onClick:()=>L(_.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 ${M[_.status]||"bg-gray-600 text-gray-300"}`,children:_.status}),e.jsx("span",{className:"font-medium text-white",children:_.loop_name})]}),e.jsxs("div",{className:"flex items-center space-x-4 text-sm text-gray-400",children:[e.jsxs("span",{children:[_.iterations_completed," iterations"]}),e.jsxs("span",{children:[_.items_processed," items"]}),e.jsx("span",{children:hs(_.started_at)}),e.jsx("svg",{className:`w-5 h-5 transition-transform ${g===_.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===_.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.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 ${M[$.status]||"bg-gray-600 text-gray-300"}`,children:$.status}),e.jsxs("span",{className:"text-sm text-gray-300",children:["Iteration ",$.iteration]}),$.mode&&e.jsxs("span",{className:"text-sm text-gray-400",children:["Mode: ",$.mode]})]}),e.jsxs("div",{className:"flex items-center space-x-4",children:[$.duration_seconds!==void 0&&e.jsxs("span",{className:"text-sm text-gray-400",children:[$.duration_seconds.toFixed(1),"s"]}),e.jsx("button",{onClick:I=>{I.stopPropagation(),N($.session_id)},className:"text-xs px-2 py-1 rounded bg-primary-600 text-white hover:bg-primary-500",children:"View Output"})]})]},$.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: ",_.id]}),_.ended_at&&e.jsxs("div",{children:["Ended: ",hs(_.ended_at)]})]})]})]},_.id))})]})}function qN({onAccountChange:t}){const[s,o]=x.useState([]),[l,i]=x.useState(!0),[d,u]=x.useState(null),[h,p]=x.useState(!1),[g,v]=x.useState(null),[y,b]=x.useState(new Set),k=x.useRef(null),C=x.useRef(null),S=x.useRef(new Set),N=x.useRef(!0),j=async(T=!1)=>{try{const Z=await Bh(!0);if(o(Z),u(null),T){const W=Date.now()/1e3,Q=300;Z.some(R=>!R.usage||!R.usage_cached_at||W-R.usage_cached_at>Q)&&Iv().then(()=>j(!1)).catch(()=>{})}}catch{u("Failed to load accounts")}finally{i(!1)}};x.useEffect(()=>{N.current=!0,j(!0);const T=setInterval(()=>j(!1),3e4);return()=>{N.current=!1,clearInterval(T),k.current&&clearInterval(k.current),C.current&&clearTimeout(C.current)}},[]),x.useEffect(()=>{if(l||s.length===0)return;const T=Date.now()/1e3-300,Z=s.filter(W=>!(S.current.has(W.id)||W.last_validated_at&&W.last_validated_at>T||W.is_expired||!W.is_active));Z.length!==0&&Z.forEach(async W=>{if(S.current.add(W.id),!!N.current){b(Q=>new Set(Q).add(W.id));try{await Rv(W.id)}catch{}finally{N.current&&(b(Q=>{const O=new Set(Q);return O.delete(W.id),O}),await j(!1))}}})},[l,s]);const L=async T=>{p(!0),u(null);try{const Z=await _v(T);if(!Z.success||!Z.flow_id){u(Z.error||"Failed to start login"),p(!1);return}const W=Z.flow_id;k.current=window.setInterval(async()=>{try{const Q=await Lv(W);if(Q.status==="completed"&&Q.result){k.current&&clearInterval(k.current),C.current&&clearTimeout(C.current);const O=Q.result;if(!O.success){u(O.error||"OAuth flow failed"),p(!1);return}O.email_mismatch&&O.message&&u(`⚠️ ${O.message}`),await j(),p(!1),t==null||t()}else Q.status==="error"?(k.current&&clearInterval(k.current),C.current&&clearTimeout(C.current),u(Q.error||"OAuth flow failed"),p(!1)):Q.status==="not_found"&&(k.current&&clearInterval(k.current),C.current&&clearTimeout(C.current),u("OAuth flow expired. Please try again."),p(!1))}catch{}},1e3),C.current=window.setTimeout(()=>{k.current&&clearInterval(k.current),p(!1),u("Account linking timed out. Please try again.")},12e4)}catch{u("Failed to start account linking"),p(!1)}},M=async T=>{const Z=s.filter(Q=>Q.id!==T.id).length>0;if(T.is_default&&Z){u("Cannot delete default account. Set another account as default first.");return}const W=T.projects_using>0?`Remove ${T.email}? ${T.projects_using} project(s) will need to use default.`:`Remove ${T.email}?`;if(window.confirm(W)){v(T.id);try{await Tv(T.id),await j(),t==null||t()}catch(Q){const O=Q instanceof Error?Q.message:"Failed to remove account";u(O)}finally{v(null)}}},_=async T=>{v(T);try{await Av(T),await j(),t==null||t()}catch{u("Failed to set default account")}finally{v(null)}},$=async T=>{v(T);try{const Z=await Pv(T);Z.success?await j():u(Z.message||"Failed to refresh token")}catch{u("Failed to refresh token")}finally{v(null)}},I=async T=>{v(T);try{await Mv(T),await j()}catch{}finally{v(null)}},P=async T=>{v(T.id);try{await Ev(T.id,{is_active:!T.is_active}),await j(),t==null||t()}catch{u("Failed to update account")}finally{v(null)}},V=T=>T>=90?"bg-red-500":T>=71?"bg-yellow-500":"bg-green-500",B=T=>T>=90?"text-red-400":T>=71?"text-yellow-400":"text-green-400",U=T=>{if(!T)return"";const Z=new Date(T),W=new Date,Q=Z.toDateString()===W.toDateString(),O=new Date(W);O.setDate(O.getDate()+1);const R=Z.toDateString()===O.toDateString(),Y=Z.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return Q?Y:R?`tomorrow ${Y}`:Z.toLocaleDateString([],{month:"short",day:"numeric"})},z=T=>{if(!T)return"never";const Z=Date.now()-T*1e3,W=Math.floor(Z/6e4);return W<1?"just now":W<60?`${W}m ago`:`${Math.floor(W/60)}h ago`};return l?e.jsxs("div",{className:"card 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"})]}):s.length===0?e.jsx("div",{className:"card",children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("svg",{className:"w-12 h-12 text-gray-600 mx-auto mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M18 9v3m0 0v3m0-3h3m-3 0h-3m-2-5a4 4 0 11-8 0 4 4 0 018 0zM3 20a6 6 0 0112 0v1H3v-1z"})}),e.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Claude accounts connected"}),e.jsx("p",{className:"text-gray-400 mb-4",children:"Connect your Claude account to start running workflows automatically."}),e.jsx("button",{onClick:()=>L(),disabled:h,className:"px-4 py-2 bg-primary-600 text-white rounded hover:bg-primary-500 disabled:opacity-50",children:h?"Waiting for browser...":"+ Connect Account"})]})}):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:"Claude Accounts"}),e.jsxs("button",{onClick:()=>L(),disabled:h,className:"flex items-center space-x-1 px-3 py-1.5 bg-primary-600 text-white text-sm rounded hover:bg-primary-500 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:"M12 4v16m8-8H4"})}),e.jsx("span",{children:h?"Waiting...":"Add Account"})]})]}),d&&e.jsxs("div",{className:`mb-4 p-3 rounded text-sm ${d.startsWith("⚠️")?"bg-yellow-900/30 border border-yellow-800 text-yellow-400":"bg-red-900/30 border border-red-800 text-red-400"}`,children:[d,e.jsx("button",{onClick:()=>u(null),className:`ml-2 ${d.startsWith("⚠️")?"text-yellow-300 hover:text-yellow-200":"text-red-300 hover:text-red-200"}`,children:"×"})]}),e.jsx("div",{className:"space-y-3",children:s.map(T=>e.jsxs("div",{className:`p-4 rounded-lg border ${T.is_expired?"bg-yellow-900/10 border-yellow-800/50":T.validation_status==="invalid"?"bg-orange-900/10 border-orange-800/50":T.is_active?"bg-gray-700/50 border-gray-600":"bg-gray-800/50 border-gray-700 opacity-60"}`,children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${y.has(T.id)?"bg-blue-500 animate-pulse":T.is_expired||T.validation_status==="invalid"?"bg-yellow-500":T.is_active?"bg-green-500":"bg-gray-500"}`}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("span",{className:"text-white font-medium text-base",children:T.email}),T.is_default&&e.jsx("span",{className:"px-1.5 py-0.5 bg-primary-600/30 text-primary-400 text-xs rounded font-medium",children:"DEFAULT"}),y.has(T.id)&&e.jsx("span",{className:"px-1.5 py-0.5 bg-blue-600/30 text-blue-400 text-xs rounded font-medium",children:"CHECKING..."}),T.validation_status==="invalid"&&!T.is_expired&&!y.has(T.id)&&e.jsx("span",{className:"px-1.5 py-0.5 bg-orange-600/30 text-orange-400 text-xs rounded font-medium",children:"TOKEN INVALID"}),T.is_expired&&e.jsx("span",{className:"px-1.5 py-0.5 bg-yellow-600/30 text-yellow-400 text-xs rounded font-medium",children:"EXPIRED"}),!T.is_active&&e.jsx("span",{className:"px-1.5 py-0.5 bg-gray-600/30 text-gray-400 text-xs rounded font-medium",children:"DISABLED"})]}),e.jsxs("div",{className:"text-gray-400 text-sm mt-0.5 flex items-center gap-2",children:[T.subscription_type?e.jsx("span",{className:"capitalize font-medium text-gray-300",children:T.subscription_type}):e.jsx("span",{className:"text-gray-500",children:"Unknown plan"}),e.jsx("span",{className:"text-gray-600",children:"·"}),e.jsxs("span",{children:[T.projects_using," project",T.projects_using!==1?"s":""]}),T.display_name&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-600",children:"·"}),e.jsx("span",{className:"text-gray-500",children:T.display_name})]})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-1",children:[T.is_expired||T.validation_status==="invalid"&&!y.has(T.id)?e.jsx("button",{onClick:()=>L(T.email),disabled:h,className:`px-2 py-1 text-sm text-white rounded disabled:opacity-50 ${T.is_expired?"bg-yellow-600 hover:bg-yellow-500":"bg-orange-600 hover:bg-orange-500"}`,children:"Re-auth"}):e.jsxs(e.Fragment,{children:[!T.is_default&&T.is_active&&e.jsx("button",{onClick:()=>_(T.id),disabled:g===T.id,className:"px-2 py-1 text-xs text-gray-400 hover:text-white hover:bg-gray-600 rounded",title:"Set as default",children:"Set Default"}),e.jsx("button",{onClick:()=>$(T.id),disabled:g===T.id,className:"p-1 text-gray-400 hover:text-white hover:bg-gray-600 rounded",title:"Refresh token",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"})})}),e.jsx("button",{onClick:()=>P(T),disabled:g===T.id,className:"p-1 text-gray-400 hover:text-white hover:bg-gray-600 rounded",title:T.is_active?"Disable account":"Enable account",children:T.is_active?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:"M10 9v6m4-6v6m7-3a9 9 0 11-18 0 9 9 0 0118 0z"})}):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:"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("button",{onClick:()=>M(T),disabled:g===T.id,className:"p-1 text-gray-400 hover:text-red-400 hover:bg-red-900/30 rounded",title:"Remove account",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"})})})]})]}),!T.is_expired&&T.validation_status!=="invalid"&&e.jsx("div",{className:"mt-3 pt-3 border-t border-gray-600/50",children:T.usage?e.jsxs(e.Fragment,{children:[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-xs font-medium",children:"5-hour limit"}),e.jsxs("span",{className:`text-sm font-semibold ${B(T.usage.five_hour)}`,children:[Math.round(T.usage.five_hour),"% used"]})]}),e.jsx("div",{className:"h-2 bg-gray-600 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all ${V(T.usage.five_hour)}`,style:{width:`${Math.min(100,T.usage.five_hour)}%`}})}),T.usage.five_hour_resets_at&&e.jsxs("p",{className:"text-gray-500 text-xs mt-1",children:["Resets ",U(T.usage.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-xs font-medium",children:"7-day limit"}),e.jsxs("span",{className:`text-sm font-semibold ${B(T.usage.seven_day)}`,children:[Math.round(T.usage.seven_day),"% used"]})]}),e.jsx("div",{className:"h-2 bg-gray-600 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all ${V(T.usage.seven_day)}`,style:{width:`${Math.min(100,T.usage.seven_day)}%`}})}),T.usage.seven_day_resets_at&&e.jsxs("p",{className:"text-gray-500 text-xs mt-1",children:["Resets ",U(T.usage.seven_day_resets_at)]})]})]}),T.usage_cached_at&&e.jsxs("button",{onClick:()=>I(T.id),disabled:g===T.id,className:"text-gray-500 text-xs mt-2 hover:text-gray-400 flex items-center gap-1",children:[e.jsx("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:"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"})}),"Updated ",z(T.usage_cached_at)]})]}):e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-gray-500 text-sm",children:"Usage data not available"}),e.jsxs("button",{onClick:()=>I(T.id),disabled:g===T.id,className:"text-xs text-primary-400 hover:text-primary-300 disabled:opacity-50 flex items-center gap-1",children:[e.jsx("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:"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"})}),"Fetch usage"]})]})}),T.validation_status==="invalid"&&!T.is_expired&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-600/50",children:[e.jsx("p",{className:"text-orange-400 text-sm",children:"Token validation failed. Please re-authenticate to continue using this account."}),T.last_error&&e.jsx("p",{className:"text-gray-500 text-xs mt-1",children:T.last_error})]}),T.last_error&&T.validation_status!=="invalid"&&e.jsx("div",{className:"mt-3 pt-3 border-t border-gray-600/50",children:e.jsx("p",{className:"text-red-400 text-xs",children:T.last_error})})]},T.id))}),e.jsx("div",{className:"mt-4 p-3 bg-gray-800/50 border border-gray-700 rounded",children:e.jsxs("div",{className:"flex items-start space-x-2",children:[e.jsx("svg",{className:"w-4 h-4 text-gray-500 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.jsx("p",{className:"text-gray-400 text-xs",children:"The default account is used for all projects without an explicit account assignment. When a project hits its usage limit, RalphX can automatically fall back to other accounts."})]})})]})}function YN(){const{loadProjects:t}=Tr(),[s,o]=x.useState(null),[l,i]=x.useState([]),[d,u]=x.useState(!0),[h,p]=x.useState(null),[g,v]=x.useState(null),[y,b]=x.useState(null),[k,C]=x.useState(!1);x.useEffect(()=>{async function j(){u(!0);try{const[L,M]=await Promise.all([Rh().catch(()=>null),_c().catch(()=>[])]);o(L),i(M)}finally{u(!1)}}j()},[]);const S=async j=>{if(window.confirm(`Are you sure you want to remove project "${j}"? This will not delete any files.`)){p(j),v(null);try{await Ky(j),i(l.filter(L=>L.slug!==j)),t()}catch(L){v(L instanceof Error?L.message:"Failed to remove project")}finally{p(null)}}},N=async j=>{C(!0),b(null),v(null);try{const L=await Qy("^e2e-",j);if(b(L),!j&&(L.deleted.length>0||L.failed.length>0)){const M=await _c().catch(()=>[]);i(M),t()}}catch(L){v(L instanceof Error?L.message:"Cleanup failed")}finally{C(!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(je,{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(qN,{}),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:()=>N(!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:()=>N(!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(j=>e.jsx("li",{children:j},j))})]}),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(j=>e.jsx("li",{children:j},j))})]}),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(j=>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:j.name}),e.jsx("div",{className:"text-sm text-gray-400 font-mono",children:j.path})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(je,{to:`/projects/${j.slug}`,className:"px-3 py-1 text-sm rounded bg-primary-600 text-white hover:bg-primary-500",children:"View"}),e.jsx("button",{onClick:()=>S(j.slug),disabled:h===j.slug,className:"px-3 py-1 text-sm rounded bg-red-800 text-red-200 hover:bg-red-700 disabled:opacity-50",children:h===j.slug?"Removing...":"Remove"})]})]},j.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 -e PYTHONDONTWRITEBYTECODE=1 -- "$(which ralphx)" mcp'}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Windows: run ",e.jsx("code",{className:"bg-gray-600 px-1 rounded",children:"where.exe ralphx"})," to find path, then use that instead of $(which ralphx)"]})]})]})]})]})]})}const GN={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"},KN={system:"text-gray-400",auth:"text-purple-400",loop:"text-green-400",run:"text-blue-400",iteration:"text-cyan-400"};function QN(){const[t,s]=x.useState([]),[o,l]=x.useState(null),[i,d]=x.useState(!0),[u,h]=x.useState(null),[p,g]=x.useState(""),[v,y]=x.useState(""),[b]=x.useState(100),[k,C]=x.useState(0),[S,N]=x.useState(!1),[j,L]=x.useState(null),[M,_]=x.useState(!1),$=x.useRef(!1),I=x.useRef(!0),P=x.useCallback(async()=>{if(!$.current){$.current=!0,I.current?d(!0):_(!0),h(null);try{const U={limit:b,offset:k};p&&(U.level=p),v&&(U.category=v);const[z,T]=await Promise.all([Ov(U),Wv()]);s(z.logs),l(T),I.current=!1}catch(U){h(U instanceof Error?U.message:"Failed to load logs")}finally{d(!1),_(!1),$.current=!1}}},[p,v,b,k]);x.useEffect(()=>{P()},[P]),x.useEffect(()=>{if(!S)return;const U=setInterval(P,1e4);return()=>clearInterval(U)},[S,P]);const V=U=>zs(U).toLocaleString(),B=U=>{const z=Math.floor((Date.now()-zs(U).getTime())/1e3);if(z<60)return`${z}s ago`;const T=Math.floor(z/60);if(T<60)return`${T}m ago`;const Z=Math.floor(T/60);return Z<24?`${Z}h ago`:`${Math.floor(Z/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(je,{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:[M&&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=>N(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:p,onChange:U=>{g(U.target.value),C(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),C(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:()=>P(),disabled:M,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":j===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:()=>L(j===U.id?null:U.id),onKeyDown:z=>{(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),L(j===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 ${GN[U.level]||"bg-gray-600 text-gray-300"}`,children:U.level}),e.jsxs("span",{className:`text-sm font-mono ${KN[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:V(U.timestamp),children:B(U.timestamp)}),U.metadata&&e.jsx("svg",{className:`w-4 h-4 transition-transform ${j===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"})})]})]}),j===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:"})," ",V(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:()=>C(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:()=>C(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 JN={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 XN({step:t,isCurrent:s,projectSlug:o,workflowId:l,onRun:i,onStop:d,onItemsClick:u,isRunning:h}){var P,V,B,U;const p=ir(),g=((P=t.config)==null?void 0:P.loopType)==="generator",v=((V=t.config)==null?void 0:V.loopType)==="consumer",y=t.input_items,b=y&&y.total>0,k=t.has_active_run===!0,C=(B=t.config)==null?void 0:B.model,S=C?JN[C]||{label:C,color:"text-gray-400"}:null,N=t.has_guardrails,j=(y==null?void 0:y.failed)??0,L=()=>{p(`/projects/${o}/workflows/${l}/steps/${t.step_number}`)},M=()=>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"}),$=(t.iterations_completed??0)>0?t.completed_at||t.started_at:null,I=()=>{if(g){const z=t.items_generated??0;return e.jsxs("span",{className:`font-mono ${u&&z>0?"cursor-pointer hover:text-cyan-400":""}`,onClick:T=>{u&&z>0&&(T.stopPropagation(),u())},children:[e.jsx("span",{className:"text-[var(--color-text-primary)] font-semibold",children:z}),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]}),j>0&&e.jsxs("span",{className:"text-red-400 ml-2",title:`${j} failed`,children:["(",j," err)"]})]}):e.jsx("span",{className:"text-[var(--color-text-muted)]",children:"—"})};return e.jsxs("div",{onClick:L,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(M,{})}),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}),N&&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:Zc($,"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:z=>{z.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:z=>{z.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 ZN({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(p=>e.jsx(XN,{step:p,isCurrent:p.step_number===s,projectSlug:o,workflowId:l,onRun:i?()=>i(p.step_number):void 0,onStop:d?()=>d(p.step_number):void 0,onItemsClick:u?()=>u(p.id):void 0,isRunning:h},p.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 ek(t){return t?Math.ceil(t.length/4):0}function tk(t){return t<1e3?`${t}`:`${(t/1e3).toFixed(1)}k`}function rk(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 sk(t){return{new_product:"discovered",feature:"identified",bug_fix:"triaged",maintenance:"found",support:"received",generic:"generated"}[t]}function nk(t){return{new_product:"implemented",feature:"completed",bug_fix:"fixed",maintenance:"addressed",support:"resolved",generic:"processed"}[t]}function ok(t){var P;const s=t.steps||[],o=rk(s),l=s.filter(V=>{var B;return((B=V.config)==null?void 0:B.loopType)==="generator"}),i=s.filter(V=>{var B;return((B=V.config)==null?void 0:B.loopType)==="consumer"}),d=l.reduce((V,B)=>V+(B.items_generated||0),0),u=i.reduce((V,B)=>{var U;return V+(((U=B.input_items)==null?void 0:U.completed)||0)},0),h=i.reduce((V,B)=>{var U;return V+(((U=B.input_items)==null?void 0:U.total)||0)},0),p=s.reduce((V,B)=>V+(B.iterations_completed||0),0),g=s.some(V=>V.has_active_run),v=s.find(V=>V.has_active_run),y=s.map(V=>V.completed_at||V.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(V=>V.status!=="completed")?b="discovery":b="complete";const k=fh(o),C=fh(o,!1),S=sk(o),N=nk(o);let j,L,M,_,$,I;if(g&&v)((P=v.config)==null?void 0:P.loopType)==="generator"?(j=o==="new_product"?"Discovering":o==="bug_fix"?"Triaging":o==="support"?"Processing":"Generating",L=`${v.name} in progress...`):(j=o==="new_product"?"Building":o==="bug_fix"?"Fixing":o==="support"?"Resolving":"Processing",L=`Working on ${v.name.toLowerCase()}...`),M="text-emerald-400",_="bg-emerald-400 animate-pulse";else if(t.status==="completed")j="Complete",L=`All ${k} ${N}`,M="text-blue-400",_="bg-blue-400";else if(t.status==="draft")j="Ready",L="Workflow not started",M="text-gray-400",_="bg-gray-500";else if(b==="discovery")j="Paused",L=d>0?`${d} ${k} ${S} so far`:`Ready to discover ${k}`,M="text-amber-400",_="bg-amber-400";else if(b==="ready")j="Ready to build",L=`${h} ${k} queued for ${o==="bug_fix"?"fixing":"implementation"}`,M="text-cyan-400",_="bg-cyan-400";else if(b==="in_progress"||b==="finishing"){const V=h-u,B=Math.round(u/h*100);j="Paused",L=`${V} ${V===1?C:k} remaining (${B}% done)`,M="text-amber-400",_="bg-amber-400"}else j="Idle",L="Ready to continue",M="text-gray-400",_="bg-gray-500";return o==="new_product"||o==="feature"?($={label:u>0?`${k} ${N}`:`${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"?($={label:u>0?"bugs fixed":"bugs triaged",value:u>0?`${u}/${h}`:d},h>0&&(I={label:"remaining",value:h-u})):o==="support"?($={label:"tickets resolved",value:u>0?`${u}/${h}`:"0"},d>0&&(I={label:"received",value:d})):$={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:p,isRunning:g,runningStep:v,lastActivity:y,primaryMetric:$,secondaryMetric:I,statusMessage:j,statusDetail:L,statusColor:M,dotClass:_}}function ak({workflow:t,resources:s,projectSlug:o,workflowId:l,onResourceUpdate:i}){const[d,u]=x.useState(null),[h,p]=x.useState(null),[g,v]=x.useState(""),[y,b]=x.useState(""),[k,C]=x.useState(!1),[S,N]=x.useState(null),[j,L]=x.useState(!1),[M,_]=x.useState(null),[$,I]=x.useState(null),[P,V]=x.useState([]),[B,U]=x.useState(0),[z,T]=x.useState(!1),[Z,W]=x.useState(null),[Q,O]=x.useState(!1);x.useEffect(()=>{if(M){const he=setTimeout(()=>_(null),3e3);return()=>clearTimeout(he)}},[M]);const R=ok(t),Y=s.filter(he=>he.enabled),ie=Y.filter(he=>he.resource_type==="design_doc"),se=Y.filter(he=>he.resource_type==="guardrail"),E=Y.filter(he=>he.resource_type==="input_file"||he.resource_type==="input"),G=Y.filter(he=>he.resource_type==="prompt"),X=he=>new Date(he).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),ee=(he,re)=>{re.stopPropagation(),p(he),v(he.content||""),b(he.updated_at),N(null),u(null)},F=()=>L(!0),me=async()=>{if(!(!h||!i)){C(!0),N(null),L(!1);try{await i(h.id,g,y),_({message:"Version saved",type:"success"}),p(null)}catch(he){const re=he instanceof Error?he.message:"Failed to save";re.includes("modified in another session")||re.includes("409")?N("Resource was modified in another session. Please reload."):N(re)}finally{C(!1)}}},Ne=async(he,re)=>{re.stopPropagation(),I(he),T(!0),W(null),u(null);try{const ke=await a2(o,l,he.id);V(ke.versions),U(ke.total)}catch(ke){console.error("Failed to load versions:",ke),V([]),U(0)}finally{T(!1)}},Ae=async he=>{if($){O(!0);try{await l2(o,l,$.id,he.id),_({message:"Version restored",type:"success"}),I(null),W(null)}catch(re){console.error("Failed to restore version:",re),_({message:"Failed to restore version",type:"error"})}finally{O(!1)}}},Ee=({resources:he,label:re,colorClass:ke,icon:Le})=>{if(he.length===0)return null;const ft=he.reduce((He,Qe)=>He+ek(Qe.content),0),Lt=d&&he.some(He=>He.id===d.id);return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>u(Lt?null:he[0]),className:`flex items-center gap-3 px-4 py-3 rounded-lg border transition-all hover:border-[var(--color-border-bright)] ${Lt?"border-[var(--color-border-bright)] bg-[var(--color-elevated)]":"border-[var(--color-border)] bg-[var(--color-surface)]"}`,children:[e.jsx("span",{className:ke,children:Le}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--color-text-primary)]",children:he.length===1?he[0].name:re}),e.jsxs("div",{className:"text-xs text-[var(--color-text-muted)] flex items-center gap-2",children:[he.length>1&&e.jsxs("span",{children:[he.length," files"]}),e.jsxs("span",{children:[tk(ft)," tokens"]})]})]}),e.jsx("svg",{className:`w-4 h-4 text-[var(--color-text-muted)] transition-transform ml-2 ${Lt?"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"})})]}),Lt&&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:he.map(He=>{var Qe;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:He.name}),e.jsxs("div",{className:"flex items-center gap-1",children:[i&&e.jsx("button",{onClick:Et=>ee(He,Et),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:Et=>Ne(He,Et),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:[(He.content||"").slice(0,800),(((Qe=He.content)==null?void 0:Qe.length)||0)>800?"...":""]})]})},He.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: ",Zc(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(Ee,{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(Ee,{resources:se,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(Ee,{resources:E,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(Ee,{resources:G,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:()=>p(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:he=>v(he.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:()=>p(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:F,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"})]})]})}),j&&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:()=>L(!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:me,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.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: ",$.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:z?e.jsx("div",{className:"text-center py-8 text-[var(--color-text-muted)]",children:"Loading..."}):P.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:[P.map(he=>e.jsxs("div",{className:`p-3 rounded border ${(Z==null?void 0:Z.id)===he.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 ",he.version_number]}),e.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:X(he.created_at)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>W((Z==null?void 0:Z.id)===he.id?null:he),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:(Z==null?void 0:Z.id)===he.id?"Hide":"Preview"}),e.jsx("button",{onClick:()=>Ae(he),disabled:Q,className:"px-2 py-1 text-xs text-cyan-400 hover:text-cyan-300 hover:bg-cyan-500/10 rounded disabled:opacity-50",children:Q?"Restoring...":"Restore"})]}),(Z==null?void 0:Z.id)===he.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:he.content||"(empty)"})]},he.id)),B>P.length&&e.jsxs("div",{className:"text-center text-xs text-[var(--color-text-muted)] py-2",children:["Showing ",P.length," of ",B]})]})})]})}),M&&e.jsx("div",{className:`fixed bottom-6 right-6 px-4 py-3 rounded-lg shadow-lg ${M.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:M.message})]})}function lk({projectSlug:t,item:s,onUpdate:o,onEdit:l,onDuplicate:i}){var N;const[d,u]=x.useState(!1),[h,p]=x.useState(!1),[g,v]=x.useState(null),[y,b]=x.useState(!1),k=async j=>{p(!0),v(null);try{await Yc(t,s.id,{status:j}),o()}catch(L){v(L instanceof Error?L.message:"Failed to update item")}finally{p(!1)}},C=async()=>{if(window.confirm("Are you sure you want to delete this item?")){p(!0),v(null);try{await $h(t,s.id),o()}catch(j){v(j instanceof Error?j.message:"Failed to delete item")}finally{p(!1)}}},S=s.id.includes("-")?s.id.split("-")[0].toUpperCase()+"-"+((N=s.id.split("-")[1])==null?void 0:N.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 ${Jc(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:Zc(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(j=>e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-[var(--color-elevated)] text-[var(--color-text-secondary)]",children:j},j))})]}),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:j=>{j.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:j=>{j.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:j=>{j.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:j=>{j.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:j=>{j.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:j=>{j.stopPropagation(),C()},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:j=>{j.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:j=>{j.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 ik({isOpen:t,onClose:s,onSave:o,item:l,mode:i,existingCategories:d=[]}){const[u,h]=x.useState(gh),[p,g]=x.useState(""),[v,y]=x.useState(!1),[b,k]=x.useState(null);x.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 C=async M=>{if(M.preventDefault(),k(null),!u.content.trim()){k("Content is required");return}y(!0);try{await o(u),s()}catch(_){k(_ instanceof Error?_.message:"Failed to save")}finally{y(!1)}},S=()=>{const M=p.trim().toUpperCase();M&&!u.dependencies.includes(M)&&(h(_=>({..._,dependencies:[..._.dependencies,M]})),g(""))},N=M=>{h(_=>({..._,dependencies:_.dependencies.filter($=>$!==M)}))},j=M=>{M.key==="Enter"&&(M.preventDefault(),S())};if(!t)return null;const L=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:L}),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:C,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:M=>h(_=>({..._,title:M.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:M=>h(_=>({..._,content:M.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:M=>h(_=>({..._,category:M.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(M=>e.jsx("option",{value:M},M))})]}),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:M=>h(_=>({..._,priority:parseInt(M.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:p,onChange:M=>g(M.target.value),onKeyDown:j,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(M=>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:[M,e.jsx("button",{type:"button",onClick:()=>N(M),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"})})})]},M))})]}),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 ck({projectSlug:t,workflowId:s,steps:o,onClose:l,onImported:i}){const[d,u]=x.useState([]),[h,p]=x.useState(""),[g,v]=x.useState(null),[y,b]=x.useState(null),[k,C]=x.useState(!1),[S,N]=x.useState(null),j=x.useRef(null),[L,M]=x.useState(0);x.useEffect(()=>{async function P(){try{const B=await y2(t);u(B);const U=B.find(z=>z.id==="hank_prd");U?p(U.id):B.length>0&&p(B[0].id)}catch{N("Failed to load import formats")}}async function V(){try{const B=await Ao(t,{workflow_id:s,limit:1});M(B.total)}catch(B){console.warn("Could not load existing items count:",B)}}P(),V()},[t,s]),x.useEffect(()=>{const P=o.find(V=>{var B,U;return V.step_type==="autonomous"&&(((B=V.config)==null?void 0:B.loopType)==="consumer"||!((U=V.config)!=null&&U.loopType))});P?v(P.id):o.length>0&&v(o[0].id)},[o]);const _=P=>{var B;const V=(B=P.target.files)==null?void 0:B[0];V&&(b(V),N(null))},$=async()=>{if(!y||!h||g===null){N("Please select a file, format, and target step");return}C(!0),N(null);try{const P=await v2(t,s,g,h,y);i(P)}catch(P){N(P instanceof Error?P.message:"Import failed")}finally{C(!1)}},I=d.find(P=>P.id===h);return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:l,onKeyDown:P=>P.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:P=>P.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:P=>p(P.target.value),className:"w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-white",children:d.map(P=>e.jsx("option",{value:P.id,children:P.label},P.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:P=>v(Number(P.target.value)),className:"w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-white",children:o.map(P=>e.jsxs("option",{value:P.id,children:["Step ",P.step_number,": ",P.name,P.step_type==="autonomous"?" (Consumer)":""]},P.id))}),e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Items will be available to this step for processing"})]}),L>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 ",L," item",L!==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 P;return(P=j.current)==null?void 0:P.click()},children:[e.jsx("input",{ref:j,type:"file",accept:".jsonl,.json",onChange:_,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:$,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,dk=[{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 Tx({projectSlug:t,workflowId:s,sourceStepId:o,steps:l,onImported:i}){const[d,u]=x.useState([]),[h,p]=x.useState(0),[g,v]=x.useState(!0),[y,b]=x.useState(null),[k,C]=x.useState(""),[S,N]=x.useState(""),[j,L]=x.useState(""),[M,_]=x.useState(0),[$,I]=x.useState([]),[P,V]=x.useState(!1),[B,U]=x.useState("create"),[z,T]=x.useState(null),[Z,W]=x.useState(!1),Q=x.useCallback(async()=>{v(!0),b(null);try{const X=await Ao(t,{workflow_id:s,source_step_id:o,status:k||void 0,category:S||void 0,limit:wo,offset:M*wo});if(u(X.items),p(X.total),M===0&&X.items.length>0){const ee=[...new Set(X.items.map(F=>F.category).filter(Boolean))];I(ee.sort())}}catch(X){b(X instanceof Error?X.message:"Failed to load items")}finally{v(!1)}},[t,s,o,k,S,M]);x.useEffect(()=>{Q()},[Q]),x.useEffect(()=>{_(0)},[k,S]);const O=()=>{T(null),U("create"),V(!0)},R=X=>{T(X),U("edit"),V(!0)},Y=X=>{T(X),U("duplicate"),V(!0)},ie=async X=>{const ee=(z==null?void 0:z.source_step_id)||o||0;B==="create"?await qc(t,{workflow_id:s,source_step_id:ee,title:X.title||void 0,content:X.content,category:X.category||void 0,priority:X.priority||void 0,dependencies:X.dependencies.length>0?X.dependencies:void 0}):B==="edit"&&z?await Yc(t,z.id,{title:X.title||void 0,content:X.content,category:X.category||void 0,priority:X.priority,dependencies:X.dependencies}):B==="duplicate"&&z&&await ov(t,z.id,{title:X.title||void 0,content:X.content,category:X.category||void 0,priority:X.priority,dependencies:X.dependencies.length>0?X.dependencies:void 0}),Q()},se=j?d.filter(X=>{var ee;return((ee=X.title)==null?void 0:ee.toLowerCase().includes(j.toLowerCase()))||X.content.toLowerCase().includes(j.toLowerCase())||X.id.toLowerCase().includes(j.toLowerCase())}):d,E=Math.ceil(h/wo),G=d.reduce((X,ee)=>(X[ee.status]=(X[ee.status]||0)+1,X),{});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:O,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(G).map(([X,ee])=>e.jsxs("button",{onClick:()=>C(k===X?"":X),className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors
208
- ${k===X?"ring-2 ring-offset-1 ring-offset-[var(--color-surface)]":""}
209
- ${Jc(X)}`,children:[e.jsx("span",{children:Qc(X)}),e.jsx("span",{className:"opacity-75",children:ee})]},X))})]}),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:j,onChange:X=>L(X.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:X=>C(X.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:dk.map(X=>e.jsx("option",{value:X.value,children:X.label},X.value))}),$.length>0&&e.jsxs("select",{value:S,onChange:X=>N(X.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"}),$.map(X=>e.jsx("option",{value:X,children:X.toUpperCase()},X))]}),(k||S||j)&&e.jsx("button",{onClick:()=>{C(""),N(""),L("")},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&&se.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"})]}),se.map(X=>e.jsx(lk,{projectSlug:t,item:X,onUpdate:Q,onEdit:R,onDuplicate:Y},X.id))]}),!g&&se.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||j?"No items match your filters":"No work items yet"})]}),E>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 ",M*wo+1,"-",Math.min((M+1)*wo,h)," of ",h]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>_(X=>Math.max(0,X-1)),disabled:M===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 ",M+1," of ",E]}),e.jsx("button",{onClick:()=>_(X=>Math.min(E-1,X+1)),disabled:M>=E-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(ik,{isOpen:P,onClose:()=>V(!1),onSave:ie,item:z,mode:B,workflowId:s,sourceStepId:o||0,existingCategories:$}),Z&&e.jsx(ck,{projectSlug:t,workflowId:s,steps:l,onClose:()=>W(!1),onImported:X=>{W(!1),Q(),i==null||i(X)}})]})}function uk({projectSlug:t,workflowId:s,workflowName:o,onClose:l}){const[i,d]=x.useState(null),[u,h]=x.useState(!0),[p,g]=x.useState(!1),[v,y]=x.useState(null),[b,k]=x.useState(!1),[C,S]=x.useState(!0),[N,j]=x.useState(!0);x.useEffect(()=>{async function _(){try{const $=await w2(t,s);d($)}catch($){y($ instanceof Error?$.message:"Failed to load export preview")}finally{h(!1)}}_()},[t,s]);const L=async()=>{g(!0),y(null);try{const $=await b2(t,s,{include_runs:b,include_planning:C,strip_secrets:N}),I=URL.createObjectURL($),P=document.createElement("a");P.href=I,P.download=`workflow-${(i==null?void 0:i.workflow_id)||s}-${new Date().toISOString().slice(0,10)}.ralphx.zip`,document.body.appendChild(P),P.click(),document.body.removeChild(P),URL.revokeObjectURL(I),l()}catch(_){y(_ instanceof Error?_.message:"Export failed")}finally{g(!1)}},M=_=>_<1024?`${_} B`:_<1024*1024?`${(_/1024).toFixed(1)} KB`:`${(_/(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:_=>_.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:_=>_.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:M(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:C,onChange:_=>S(_.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:_=>k(_.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:N,onChange:_=>j(_.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((_,$)=>e.jsx("li",{children:_},$))})]})]}):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:L,disabled:u||p||!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:p?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 mk(){const{slug:t,workflowId:s}=yr(),o=ir(),[l,i]=x.useState(null),[d,u]=x.useState([]),[h,p]=x.useState(!0),[g,v]=x.useState(null),[y,b]=x.useState(!1),[k,C]=x.useState(!1),[S,N]=x.useState(null),[j,L]=x.useState("steps"),[M,_]=x.useState(void 0),$=x.useCallback(async()=>{if(!(!t||!s))try{const[E,G]=await Promise.all([Po(t,s),fl(t,s)]);i(E),u(G),v(null)}catch(E){v(E instanceof Error?E.message:"Failed to load workflow")}finally{p(!1)}},[t,s]);x.useEffect(()=>{$()},[$]),x.useEffect(()=>{if(!l||l.status==="completed"||l.status==="draft")return;const E=setInterval($,2e3);return()=>clearInterval(E)},[l,$]);const I=async()=>{(await tt.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 P()},P=async()=>{if(!(!t||!s)){b(!0);try{const E=await Gv(t,s);i(E)}catch(E){v(E instanceof Error?E.message:"Failed to start workflow")}finally{b(!1)}}},V=async()=>{if(!(!t||!s||!(await tt.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 G=await Dh(t,s);i(G)}catch(G){v(G instanceof Error?G.message:"Failed to stop workflow")}finally{b(!1)}}},B=async()=>{if(!(!t||!s||!(await tt.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 qv(t,s),o(`/projects/${t}/workflows`)}catch(G){v(G instanceof Error?G.message:"Failed to archive workflow"),b(!1)}}},U=async E=>{var ee;if(!t||!s)return;const G=((ee=((l==null?void 0:l.steps)||[]).find(F=>F.step_number===E))==null?void 0:ee.name)||`Step ${E}`;if((await tt.fire({title:"Run Ralph Loop?",text:`Start executing "${G}"?`,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 F=await Oh(t,s,E);i(F)}catch(F){v(F instanceof Error?F.message:"Failed to run step")}finally{b(!1)}}},z=async E=>{await V()},T=E=>{_(E),L("items")},Z=async(E,G,X)=>{!t||!s||(await So(t,s,E,{content:G,expected_updated_at:X}),await $())};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(je,{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||[],Q=W.some(E=>E.has_active_run===!0),R=l.status==="active"?Q?"running":"idle":l.status,Y=l.status!=="completed"&&!Q,ie=Q,se={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(je,{to:"/",className:"hover:text-white",children:"Dashboard"}),e.jsx("span",{children:"/"}),e.jsx(je,{to:`/projects/${t}`,className:"hover:text-white",children:t}),e.jsx("span",{children:"/"}),e.jsx(je,{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 ${se[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:V,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:()=>C(!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:B,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:()=>L("steps"),className:`px-4 py-3 text-sm font-medium transition-colors relative
220
- ${j==="steps"?"text-cyan-400":"text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)]"}`,children:["Steps",j==="steps"&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-cyan-500"})]}),e.jsxs("button",{onClick:()=>{L("items"),_(void 0)},className:`px-4 py-3 text-sm font-medium transition-colors relative flex items-center gap-2
221
- ${j==="items"?"text-cyan-400":"text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)]"}`,children:["Items",W.reduce((E,G)=>E+(G.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((E,G)=>E+(G.items_generated||0),0)}),j==="items"&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-cyan-500"})]})]}),j==="items"&&e.jsx("div",{className:"card",children:e.jsx(Tx,{projectSlug:t,workflowId:s,sourceStepId:M,steps:W,onImported:E=>{N(E),$()}})}),j==="steps"&&e.jsxs("div",{children:[e.jsx(ak,{workflow:l,resources:d,projectSlug:t,workflowId:s,onResourceUpdate:Z}),e.jsx("div",{className:"text-xs font-semibold text-[var(--color-text-muted)] uppercase tracking-wider mb-3",children:"Steps"}),e.jsx(ZN,{steps:W,currentStep:l.current_step,projectSlug:t,workflowId:s,onRunStep:U,onStopStep:z,onItemsClick:T,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(uk,{projectSlug:t,workflowId:s,workflowName:l.name,onClose:()=>C(!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:()=>N(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((p,g)=>{if(/^\d+\.\s/.test(p)){const y=p.split(/\n(?=\d+\.\s)/);return e.jsx("ol",{className:"list-decimal list-inside space-y-1 mb-4",children:y.map((b,k)=>{const C=b.replace(/^\d+\.\s/,"");return e.jsx("li",{children:d(C)},k)})},g)}if(/^[-*]\s/.test(p)){const y=p.split(/\n(?=[-*]\s)/);return e.jsx("ul",{className:"list-disc list-inside space-y-1 mb-4",children:y.map((b,k)=>{const C=b.replace(/^[-*]\s/,"");return e.jsx("li",{children:d(C)},k)})},g)}const v=p.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(p)},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:Hh(t.timestamp)})]})})}function hk({artifacts:t}){var d,u;const[s,o]=x.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 pk({projectSlug:t,workflowId:s,onComplete:o}){const[l,i]=x.useState(null),[d,u]=x.useState(""),[h,p]=x.useState(!0),[g,v]=x.useState(!1),[y,b]=x.useState(!1),[k,C]=x.useState(""),[S,N]=x.useState(null),[j,L]=x.useState(!1),[M,_]=x.useState(!1),$=x.useRef(null),I=x.useRef(null),P=x.useRef(null);x.useEffect(()=>()=>{P.current&&(P.current.close(),P.current=null)},[]);const V=()=>{var Q;(Q=$.current)==null||Q.scrollIntoView({behavior:"smooth"})},B=x.useCallback(async()=>{try{const Q=await r2(t,s);i(Q),N(null)}catch(Q){N(Q instanceof Error?Q.message:"Failed to load session")}finally{p(!1)}},[t,s]);x.useEffect(()=>{B()},[B]),x.useEffect(()=>{V()},[l==null?void 0:l.messages,k]);const U=async()=>{if(!d.trim()||g||y)return;const Q=d.trim();u(""),v(!0),N(null);try{const O=await s2(t,s,Q);i(O),b(!0),C(""),P.current&&P.current.close();const R=o2(t,s);P.current=R,R.onmessage=Y=>{try{const ie=JSON.parse(Y.data);ie.type==="content"?C(se=>se+ie.content):ie.type==="error"?(R.close(),P.current=null,b(!1),N(ie.message||"An error occurred")):ie.type==="done"&&(R.close(),P.current=null,b(!1),B())}catch(ie){console.error("Failed to parse SSE event:",ie,Y.data)}},R.onerror=()=>{R.close(),P.current=null,b(!1),N("Connection lost. Please try again.")}}catch(O){N(O instanceof Error?O.message:"Failed to send message")}finally{v(!1)}},z=Q=>{Q.key==="Enter"&&!Q.shiftKey&&(Q.preventDefault(),U())},T=async()=>{if(l){_(!0);try{await n2(t,s,l.artifacts),o()}catch(Q){N(Q instanceof Error?Q.message:"Failed to complete session"),_(!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 Z=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:[!Z&&!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((Q,O)=>e.jsx(yh,{message:Q},O)),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:$})]}),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:()=>L(!j),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 ${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"})}),e.jsx("span",{children:"View Generated Artifacts"})]}),j&&(l==null?void 0:l.artifacts)&&e.jsx(hk,{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:Q=>u(Q.target.value),onKeyDown:z,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"})})})})]}),Z&&e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx("button",{onClick:T,disabled:M||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:M?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 xk=0;function fk(){return Date.now()*1e3+xk++%1e3}function gk({projectSlug:t,loopName:s,enabled:o=!0,pollInterval:l=5e3}){const[i,d]=x.useState({}),[u,h]=x.useState(!0),[p,g]=x.useState(null),v=x.useRef(null),y=x.useRef({runId:null,iteration:null}),b=x.useCallback(async()=>{if(o)try{const N=await fetch(`/api/projects/${t}/loops/${s}/events/grouped`);if(!N.ok)throw new Error(`Failed to fetch events: ${N.statusText}`);const j=await N.json();d(j.runs||{});for(const[L,M]of Object.entries(j.runs))if(M.status==="running"||M.status==="paused"){y.current.runId=L;const _=Object.keys(M.iterations).map(Number);_.length>0&&(y.current.iteration=Math.max(..._));break}g(null)}catch(N){g(N instanceof Error?N.message:"Failed to load events")}finally{h(!1)}},[t,s,o]),k=x.useCallback(N=>{const{type:j,data:L}=N;if(["heartbeat","connected","disconnected"].includes(j))return;const M=L.run_id,_=L.iteration;if((!M||_===void 0)&&(!y.current.runId||!y.current.iteration))return;const $=M||y.current.runId,I=_??y.current.iteration;y.current.runId=$,y.current.iteration=I;const P={id:fk(),session_id:L.session_id||"",event_type:j,timestamp:new Date().toISOString(),content:L.content,tool_name:L.name,tool_input:L.input,tool_result:L.result,error_message:L.message};d(V=>{const B={...V};return B[$]||(B[$]={status:"running",loop_name:s,started_at:null,completed_at:null,iterations_completed:0,iterations:{}}),B[$].iterations[I]||(B[$].iterations[I]={session_id:L.session_id||"",mode:null,status:"active",is_live:!0,events:[]}),B[$].iterations[I].events=[...B[$].iterations[I].events,P],B[$].iterations[I].is_live=!0,j==="status"&&(B[$].status=L.status||B[$].status,y.current.iteration=L.iteration||I),j==="complete"&&(B[$].iterations[I].is_live=!1,B[$].iterations[I].status="completed"),B})},[]),C=o?`/api/projects/${t}/loops/${s}/stream`:"",{isConnected:S}=Dp({url:C,enabled:o&&!!C,onEvent:k,maxStoredEvents:0});return x.useEffect(()=>{b();const N=()=>{v.current=setTimeout(()=>{b(),N()},l)};return N(),()=>{v.current&&clearTimeout(v.current)}},[b,l]),{runs:i,loading:u,error:p,isConnected:S,refresh:b}}function yk(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 vk(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}=gk({projectSlug:t,loopName:s,enabled:o}),[p,g]=x.useState(new Set),[v,y]=x.useState(new Set),[b,k]=x.useState(new Set),C=x.useRef(null),S=x.useRef(!1),N=x.useRef(!1),j=x.useRef(0);x.useEffect(()=>{if(S.current||Object.keys(l).length===0)return;S.current=!0;const B=new Set,U=new Set,z=Object.entries(l).sort(([,T],[,Z])=>{const W=T.started_at?new Date(T.started_at).getTime():0,Q=Z.started_at?new Date(Z.started_at).getTime():0;return W-Q});for(let T=z.length-1;T>=0;T--){const[Z,W]=z[T];if(W.status==="running"||W.status==="paused"){B.add(Z),Object.entries(W.iterations).forEach(([Q,O])=>{O.is_live&&U.add(`${Z}-${Q}`)});break}}g(B),y(U)},[l]);const L=x.useCallback(()=>{if(!C.current)return;const{scrollTop:B,scrollHeight:U,clientHeight:z}=C.current,T=U-B-z<50;N.current=!T,j.current=B},[]);x.useEffect(()=>{!C.current||N.current||(C.current.scrollTop=C.current.scrollHeight)},[l]);const M=x.useCallback(B=>{g(U=>{const z=new Set(U);return z.has(B)?z.delete(B):z.add(B),z})},[]),_=x.useCallback((B,U)=>{const z=`${B}-${U}`;y(T=>{const Z=new Set(T);return Z.has(z)?Z.delete(z):Z.add(z),Z})},[]),$=x.useCallback(B=>{k(U=>{const z=new Set(U);return z.has(B)?z.delete(B):z.add(B),z})},[]),I=x.useCallback(()=>{const B=new Set(Object.keys(l)),U=new Set;Object.entries(l).forEach(([z,T])=>{Object.keys(T.iterations).forEach(Z=>{U.add(`${z}-${Z}`)})}),g(B),y(U)},[l]),P=x.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 V=Object.entries(l).sort(([,B],[,U])=>{const z=B.started_at?new Date(B.started_at).getTime():0,T=U.started_at?new Date(U.started_at).getTime():0;return z-T});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:P,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:C,onScroll:L,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..."]}):V.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:V.map(([B,U],z)=>e.jsx(bk,{runId:B,run:U,isExpanded:p.has(B),expandedIterations:v,expandedEvents:b,onToggleRun:M,onToggleIteration:_,onToggleEvent:$,index:z},B))})}),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:yk(l)})," events across"," ",e.jsx("span",{className:"text-[var(--color-cyan)]",children:Object.keys(l).length})," runs"]})]})}function wk(t){const s=t.match(/_step(\d+)$/);return s?parseInt(s[1],10):null}function bk({runId:t,run:s,isExpanded:o,expandedIterations:l,expandedEvents:i,onToggleRun:d,onToggleIteration:u,onToggleEvent:h,index:p}){const g=vk(s),v=wk(s.loop_name),y=s.completed_at||s.started_at,b=A2(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""}},C=()=>{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(([N,j])=>[parseInt(N,10),j]).sort(([N],[j])=>N-j);return e.jsxs("div",{className:`animate-fade-in-up stagger-${Math.min(p+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 #",p+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 ${C()} 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(([N,j])=>e.jsx(jk,{runId:t,iteration:N,data:j,isExpanded:l.has(`${t}-${N}`),expandedEvents:i,onToggle:()=>u(t,N),onToggleEvent:h},`${t}-${N}`))})})]})}function jk({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,p)=>{const g=`${h.id}-${p}`;return e.jsx(Nk,{event:h,isExpanded:i.has(h.id),isLive:o.is_live&&p===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 Nk({event:t,isExpanded:s,isLive:o,onToggle:l}){const i=wh[t.event_type]||wh.text,d=_k(t,40),u=Lk(t),h=x.useRef(null),p=Hh(t.timestamp);return x.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:p}),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(Sk,{event:t})})})]})}function kk({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(Ck,{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 Ck({stories:t}){const[s,o]=x.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 Sk({event:t}){const[s,o]=x.useState(!0);switch(t.event_type){case"text":return e.jsx(kk,{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 _k(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 Lk(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 Ek(){var T,Z;const{slug:t,workflowId:s,stepNumber:o}=yr(),l=ir(),[i,d]=x.useState(null),[u,h]=x.useState(!0),[p,g]=x.useState(null),[v,y]=x.useState(!1),[b,k]=x.useState("overview"),C=o?parseInt(o,10):null,S=x.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]);x.useEffect(()=>{S()},[S]),x.useEffect(()=>{var O;if(!i)return;const W=(O=i.steps)==null?void 0:O.find(R=>R.step_number===C);if(!(W!=null&&W.has_active_run))return;const Q=setInterval(S,2e3);return()=>clearInterval(Q)},[i,C,S]);const j=((i==null?void 0:i.steps)||[]).find(W=>W.step_number===C);x.useEffect(()=>{!u&&i&&!j&&l(`/projects/${t}/workflows/${s}`,{replace:!0})},[u,i,j,l,t,s]),x.useEffect(()=>{j!=null&&j.archived_at&&l(`/projects/${t}/workflows/${s}`,{replace:!0})},[j,l,t,s]);const L=async()=>{if(!t||!s||!C)return;const W=(j==null?void 0:j.name)||`Step ${C}`;if((await tt.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 O=await Oh(t,s,C);d(O)}catch(O){g(O instanceof Error?O.message:"Failed to run step")}finally{y(!1)}}},M=async()=>{if(!(!t||!s||!(await tt.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 Q=await Dh(t,s);d(Q)}catch(Q){g(Q instanceof Error?Q.message:"Failed to stop step")}finally{y(!1)}}},_=async(W=!1)=>{if(!(!t||!s)){y(!0);try{const Q=await Kv(t,s,{skip_current:W});d(Q)}catch(Q){g(Q instanceof Error?Q.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(p&&!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:p}),e.jsx(je,{to:`/projects/${t}/workflows/${s}`,className:"btn-secondary mt-4 inline-block",children:"Back to Workflow"})]})});if(!i||!j)return null;const $=j.step_type==="interactive",I=j.step_type==="autonomous",P=j.has_active_run===!0,V=j.step_number===i.current_step&&j.status==="active",B=j.items_generated||0,U=()=>{if(P)return"bg-green-600";switch(j.status){case"completed":return"bg-blue-600";case"active":return"bg-amber-600";case"skipped":return"bg-gray-600";default:return"bg-gray-600"}},z=()=>{if(P)return"Running";switch(j.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(je,{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(je,{to:"/",className:"hover:text-white",children:"Dashboard"}),e.jsx("span",{children:"/"}),e.jsx(je,{to:`/projects/${t}`,className:"hover:text-white",children:t}),e.jsx("span",{children:"/"}),e.jsx(je,{to:`/projects/${t}/workflows/${s}`,className:"hover:text-white",children:i.name}),e.jsx("span",{children:"/"}),e.jsxs("span",{className:"text-white",children:["Step ",j.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 ",j.step_number,": ",j.name]}),e.jsx("span",{className:`px-3 py-1 rounded-full text-sm font-medium text-white ${U()}`,children:z()}),e.jsx("span",{className:"px-2 py-1 text-xs font-medium bg-[var(--color-elevated)] text-[var(--color-text-muted)] rounded",children:$?"Chat":"Auto"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[!P&&i.status!=="completed"&&e.jsxs("button",{onClick:L,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"})]}),P&&e.jsxs("button",{onClick:M,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"})]})]})]}),((T=j.config)==null?void 0:T.description)&&e.jsx("p",{className:"mt-2 text-gray-400",children:j.config.description})]}),p&&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:p}),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",P&&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",B>0&&e.jsx("span",{className:"px-1.5 py-0.5 text-xs rounded-full bg-cyan-500/20 text-cyan-400",children:B}),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:$?"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:z()})]}),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:j.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:B})]})]}),V&&((Z=j.config)==null?void 0:Z.skippable)&&e.jsx("div",{className:"mt-4 pt-4 border-t border-[var(--color-border)]",children:e.jsx("button",{onClick:()=>_(!0),disabled:v,className:"text-sm text-gray-400 hover:text-white transition-colors",children:"Skip this step"})})]}),$&&V&&e.jsxs("div",{className:"card",children:[e.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Planning Chat"}),e.jsx(pk,{projectSlug:t,workflowId:s,onComplete:S})]}),$&&!V&&e.jsxs("div",{className:"card text-center py-8",children:[j.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."})]}),j.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&&j.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:j.loop_name,enabled:!0})]}),I&&!j.loop_name&&j.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:j.loop_name?e.jsx(vh,{projectSlug:t,loopName:j.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(Tx,{projectSlug:t,workflowId:s,sourceStepId:j.id,steps:(i==null?void 0:i.steps)||[],onImported:()=>S()})})]})}function Tk(){var _,$,I;const{slug:t}=yr(),{selectedProject:s,setSelectedProject:o}=Tr(),[l,i]=x.useState([]),[d,u]=x.useState(null),[h,p]=x.useState(!0),[g,v]=x.useState(null),y=x.useCallback(async()=>{if(t){p(!0),v(null);try{const[P,V,B]=await Promise.all([Vs(t),Za(t),av(t)]);o(P),i(V),u(B)}catch(P){v(P instanceof Error?P.message:"Failed to load dashboard")}finally{p(!1)}}},[t,o]);if(x.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(je,{to:"/",className:"btn-secondary mt-4 inline-block",children:"Back to Dashboard"})]})});const b=l.map(P=>({id:P.id,name:P.name,status:P.status,current_step:P.current_step,total_steps:P.steps.length,progress:P.steps.length>0?Math.round(P.steps.filter(V=>V.status==="completed").length/P.steps.length*100):0})),k=b.filter(P=>P.status==="active"||P.status==="draft"||P.status==="paused"),C=b.filter(P=>P.status==="completed"),S=(d==null?void 0:d.total)||0,N=((_=d==null?void 0:d.by_status)==null?void 0:_.completed)||0,j=(($=d==null?void 0:d.by_status)==null?void 0:$.in_progress)||0,L=((I=d==null?void 0:d.by_status)==null?void 0:I.pending)||0,M=S>0?Math.round(N/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(je,{to:"/",className:"hover:text-white",children:"Dashboard"}),e.jsx("span",{children:"/"}),e.jsx(je,{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(je,{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:C.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:[M,"%"]}),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:`${M}%`}})})]}),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?N/S*100:0}%`}})}),e.jsx("span",{className:"text-green-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:"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?j/S*100:0}%`}})}),e.jsx("span",{className:"text-yellow-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:"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?L/S*100:0}%`}})}),e.jsx("span",{className:"text-gray-400 w-12 text-right",children:L})]})]})]})]}),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(([,P],[,V])=>V-P).slice(0,6).map(([P,V])=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-gray-300 text-sm font-mono",children:P||"Uncategorized"}),e.jsx("span",{className:"text-primary-400",children:V})]},P))}):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(je,{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(P=>e.jsxs("tr",{className:"hover:bg-gray-800/50",children:[e.jsx("td",{className:"py-3 pr-4",children:e.jsx(je,{to:`/projects/${t}/workflows/${P.id}`,className:"text-white hover:text-primary-400 font-medium",children:P.name})}),e.jsx("td",{className:"py-3 pr-4",children:e.jsx("span",{className:`px-2 py-1 text-xs rounded ${P.status==="completed"?"bg-green-900/30 text-green-400":P.status==="active"?"bg-blue-900/30 text-blue-400":"bg-gray-700 text-gray-400"}`,children:P.status})}),e.jsxs("td",{className:"py-3 pr-4 text-gray-400 text-sm",children:[P.current_step," / ",P.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 ${P.status==="completed"?"bg-green-500":"bg-primary-500"}`,style:{width:`${P.progress}%`}})}),e.jsxs("span",{className:"text-sm text-gray-400",children:[P.progress,"%"]})]})}),e.jsx("td",{className:"py-3 text-right",children:e.jsx(je,{to:`/projects/${t}/workflows/${P.id}`,className:"text-primary-400 hover:text-primary-300 text-sm",children:"View"})})]},P.id))})]})})]})]})}function dt({title:t,description:s,prompt:o,variant:l="primary"}){const[i,d]=x.useState(!1),[u,h]=x.useState(!1),p=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:p,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 et({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 Ja({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 Fr({question:t,children:s,defaultOpen:o=!1}){const[l,i]=x.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(et,{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(Ja,{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(et,{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(et,{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(dt,{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 Ak(){return e.jsxs("div",{className:"space-y-8",children:[e.jsx(et,{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(dt,{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(et,{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(dt,{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(et,{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(dt,{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(et,{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(dt,{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(et,{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(dt,{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 Pk(){return e.jsxs("div",{className:"space-y-8",children:[e.jsx(et,{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(et,{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(dt,{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(dt,{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(dt,{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(dt,{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(et,{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(dt,{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(dt,{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(dt,{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(et,{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(Fr,{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(Fr,{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(Fr,{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(Fr,{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(Fr,{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 Mk(){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(et,{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(dt,{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(et,{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(dt,{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(et,{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(dt,{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(et,{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(Fr,{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(Fr,{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(Fr,{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(Fr,{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 Rk(){return e.jsxs("div",{className:"space-y-8",children:[e.jsx(et,{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(et,{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(Ja,{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(dt,{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(et,{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(Ja,{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(dt,{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(et,{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(Ja,{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(dt,{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(et,{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 Ik(){const t=bs(),s=ir(),o=()=>{const h=t.hash.replace("#",""),p=jh.find(g=>g.id===h);return p?p.id:"getting-started"},[l,i]=x.useState(o);x.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(Ak,{});case"monitoring":return e.jsx(Pk,{});case"remote-access":return e.jsx(Mk,{});case"backup-import":return e.jsx(Rk,{});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 $k(){return e.jsx(Ay,{children:e.jsxs(ct,{path:"/",element:e.jsx(k2,{}),children:[e.jsx(ct,{index:!0,element:e.jsx(P2,{})}),e.jsx(ct,{path:"projects/:slug",element:e.jsx(kj,{})}),e.jsx(ct,{path:"projects/:slug/dashboard",element:e.jsx(Tk,{})}),e.jsx(ct,{path:"projects/:slug/settings",element:e.jsx(VN,{})}),e.jsx(ct,{path:"projects/:slug/items",element:e.jsx(v0,{to:"..",replace:!0})}),e.jsx(ct,{path:"projects/:slug/runs",element:e.jsx(xh,{})}),e.jsx(ct,{path:"projects/:slug/loops/:loopName",element:e.jsx(wN,{})}),e.jsx(ct,{path:"projects/:slug/workflows",element:e.jsx(v0,{to:"..",replace:!0})}),e.jsx(ct,{path:"projects/:slug/workflows/:workflowId",element:e.jsx(mk,{})}),e.jsx(ct,{path:"projects/:slug/workflows/:workflowId/steps/:stepNumber",element:e.jsx(Ek,{})}),e.jsx(ct,{path:"projects/:slug/workflows/:workflowId/edit",element:e.jsx(HN,{})}),e.jsx(ct,{path:"projects/:slug/workflows/:workflowId/items",element:e.jsx(NN,{})}),e.jsx(ct,{path:"projects/:slug/workflows/:workflowId/resources",element:e.jsx(kN,{})}),e.jsx(ct,{path:"projects/:slug/workflows/:workflowId/runs",element:e.jsx(xh,{})}),e.jsx(ct,{path:"wiki",element:e.jsx(Ik,{})}),e.jsx(ct,{path:"logs",element:e.jsx(QN,{})}),e.jsx(ct,{path:"settings",element:e.jsx(YN,{})})]})})}$g.createRoot(document.getElementById("root")).render(e.jsx(bn.StrictMode,{children:e.jsx(Oy,{children:e.jsx($k,{})})}));
251
- //# sourceMappingURL=index-CY9s08ZB.js.map