ralphx 0.3.4__py3-none-any.whl → 0.4.0__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.
- ralphx/__init__.py +1 -1
- ralphx/adapters/base.py +10 -2
- ralphx/adapters/claude_cli.py +222 -82
- ralphx/api/routes/auth.py +780 -98
- ralphx/api/routes/config.py +3 -56
- ralphx/api/routes/export_import.py +6 -9
- ralphx/api/routes/loops.py +4 -4
- ralphx/api/routes/planning.py +882 -19
- ralphx/api/routes/resources.py +528 -6
- ralphx/api/routes/stream.py +58 -56
- ralphx/api/routes/templates.py +2 -2
- ralphx/api/routes/workflows.py +258 -47
- ralphx/cli.py +4 -1
- ralphx/core/auth.py +372 -172
- ralphx/core/database.py +588 -164
- ralphx/core/executor.py +170 -19
- ralphx/core/loop.py +15 -2
- ralphx/core/loop_templates.py +29 -3
- ralphx/core/planning_iteration_executor.py +633 -0
- ralphx/core/planning_service.py +119 -24
- ralphx/core/preview.py +9 -25
- ralphx/core/project_db.py +864 -121
- ralphx/core/project_export.py +1 -5
- ralphx/core/project_import.py +14 -29
- ralphx/core/resources.py +28 -2
- ralphx/core/sample_project.py +1 -5
- ralphx/core/templates.py +9 -9
- ralphx/core/workflow_executor.py +32 -3
- ralphx/core/workflow_export.py +4 -7
- ralphx/core/workflow_import.py +3 -27
- ralphx/mcp/__init__.py +6 -2
- ralphx/mcp/registry.py +3 -3
- ralphx/mcp/tools/diagnostics.py +1 -1
- ralphx/mcp/tools/monitoring.py +10 -16
- ralphx/mcp/tools/workflows.py +115 -33
- ralphx/mcp_server.py +6 -2
- ralphx/static/assets/index-BuLI7ffn.css +1 -0
- ralphx/static/assets/index-DWvlqOTb.js +264 -0
- ralphx/static/assets/index-DWvlqOTb.js.map +1 -0
- ralphx/static/index.html +2 -2
- ralphx/templates/loop_templates/consumer.md +2 -2
- {ralphx-0.3.4.dist-info → ralphx-0.4.0.dist-info}/METADATA +33 -12
- {ralphx-0.3.4.dist-info → ralphx-0.4.0.dist-info}/RECORD +45 -44
- ralphx/static/assets/index-CcRDyY3b.css +0 -1
- ralphx/static/assets/index-CcxfTosc.js +0 -251
- ralphx/static/assets/index-CcxfTosc.js.map +0 -1
- {ralphx-0.3.4.dist-info → ralphx-0.4.0.dist-info}/WHEEL +0 -0
- {ralphx-0.3.4.dist-info → ralphx-0.4.0.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
function S2(e,r){for(var s=0;s<r.length;s++){const a=r[s];if(typeof a!="string"&&!Array.isArray(a)){for(const o in a)if(o!=="default"&&!(o in e)){const c=Object.getOwnPropertyDescriptor(a,o);c&&Object.defineProperty(e,o,c.get?c:{enumerable:!0,get:()=>a[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))a(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&a(d)}).observe(document,{childList:!0,subtree:!0});function s(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function a(o){if(o.ep)return;o.ep=!0;const c=s(o);fetch(o.href,c)}})();function ul(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var id={exports:{}},Ki={},ad={exports:{}},Ue={};/**
|
|
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 R0;function _2(){if(R0)return Ue;R0=1;var e=Symbol.for("react.element"),r=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),d=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),g=Symbol.iterator;function b(L){return L===null||typeof L!="object"?null:(L=g&&L[g]||L["@@iterator"],typeof L=="function"?L:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,T={};function N(L,q,S){this.props=L,this.context=q,this.refs=T,this.updater=S||v}N.prototype.isReactComponent={},N.prototype.setState=function(L,q){if(typeof L!="object"&&typeof L!="function"&&L!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,L,q,"setState")},N.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function j(){}j.prototype=N.prototype;function A(L,q,S){this.props=L,this.context=q,this.refs=T,this.updater=S||v}var M=A.prototype=new j;M.constructor=A,k(M,N.prototype),M.isPureReactComponent=!0;var _=Array.isArray,z=Object.prototype.hasOwnProperty,P={current:null},$={key:!0,ref:!0,__self:!0,__source:!0};function V(L,q,S){var G,re={},ee=null,ge=null;if(q!=null)for(G in q.ref!==void 0&&(ge=q.ref),q.key!==void 0&&(ee=""+q.key),q)z.call(q,G)&&!$.hasOwnProperty(G)&&(re[G]=q[G]);var je=arguments.length-2;if(je===1)re.children=S;else if(1<je){for(var Le=Array(je),ve=0;ve<je;ve++)Le[ve]=arguments[ve+2];re.children=Le}if(L&&L.defaultProps)for(G in je=L.defaultProps,je)re[G]===void 0&&(re[G]=je[G]);return{$$typeof:e,type:L,key:ee,ref:ge,props:re,_owner:P.current}}function B(L,q){return{$$typeof:e,type:L.type,key:q,ref:L.ref,props:L.props,_owner:L._owner}}function U(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function D(L){var q={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(S){return q[S]})}var R=/\/+/g;function X(L,q){return typeof L=="object"&&L!==null&&L.key!=null?D(""+L.key):q.toString(36)}function I(L,q,S,G,re){var ee=typeof L;(ee==="undefined"||ee==="boolean")&&(L=null);var ge=!1;if(L===null)ge=!0;else switch(ee){case"string":case"number":ge=!0;break;case"object":switch(L.$$typeof){case e:case r:ge=!0}}if(ge)return ge=L,re=re(ge),L=G===""?"."+X(ge,0):G,_(re)?(S="",L!=null&&(S=L.replace(R,"$&/")+"/"),I(re,q,S,"",function(ve){return ve})):re!=null&&(U(re)&&(re=B(re,S+(!re.key||ge&&ge.key===re.key?"":(""+re.key).replace(R,"$&/")+"/")+L)),q.push(re)),1;if(ge=0,G=G===""?".":G+":",_(L))for(var je=0;je<L.length;je++){ee=L[je];var Le=G+X(ee,je);ge+=I(ee,q,S,Le,re)}else if(Le=b(L),typeof Le=="function")for(L=Le.call(L),je=0;!(ee=L.next()).done;)ee=ee.value,Le=G+X(ee,je++),ge+=I(ee,q,S,Le,re);else if(ee==="object")throw q=String(L),Error("Objects are not valid as a React child (found: "+(q==="[object Object]"?"object with keys {"+Object.keys(L).join(", ")+"}":q)+"). If you meant to render a collection of children, use an array instead.");return ge}function H(L,q,S){if(L==null)return L;var G=[],re=0;return I(L,G,"","",function(ee){return q.call(S,ee,re++)}),G}function W(L){if(L._status===-1){var q=L._result;q=q(),q.then(function(S){(L._status===0||L._status===-1)&&(L._status=1,L._result=S)},function(S){(L._status===0||L._status===-1)&&(L._status=2,L._result=S)}),L._status===-1&&(L._status=0,L._result=q)}if(L._status===1)return L._result.default;throw L._result}var J={current:null},Z={transition:null},de={ReactCurrentDispatcher:J,ReactCurrentBatchConfig:Z,ReactCurrentOwner:P};function E(){throw Error("act(...) is not supported in production builds of React.")}return Ue.Children={map:H,forEach:function(L,q,S){H(L,function(){q.apply(this,arguments)},S)},count:function(L){var q=0;return H(L,function(){q++}),q},toArray:function(L){return H(L,function(q){return q})||[]},only:function(L){if(!U(L))throw Error("React.Children.only expected to receive a single React element child.");return L}},Ue.Component=N,Ue.Fragment=s,Ue.Profiler=o,Ue.PureComponent=A,Ue.StrictMode=a,Ue.Suspense=h,Ue.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=de,Ue.act=E,Ue.cloneElement=function(L,q,S){if(L==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+L+".");var G=k({},L.props),re=L.key,ee=L.ref,ge=L._owner;if(q!=null){if(q.ref!==void 0&&(ee=q.ref,ge=P.current),q.key!==void 0&&(re=""+q.key),L.type&&L.type.defaultProps)var je=L.type.defaultProps;for(Le in q)z.call(q,Le)&&!$.hasOwnProperty(Le)&&(G[Le]=q[Le]===void 0&&je!==void 0?je[Le]:q[Le])}var Le=arguments.length-2;if(Le===1)G.children=S;else if(1<Le){je=Array(Le);for(var ve=0;ve<Le;ve++)je[ve]=arguments[ve+2];G.children=je}return{$$typeof:e,type:L.type,key:re,ref:ee,props:G,_owner:ge}},Ue.createContext=function(L){return L={$$typeof:d,_currentValue:L,_currentValue2:L,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},L.Provider={$$typeof:c,_context:L},L.Consumer=L},Ue.createElement=V,Ue.createFactory=function(L){var q=V.bind(null,L);return q.type=L,q},Ue.createRef=function(){return{current:null}},Ue.forwardRef=function(L){return{$$typeof:u,render:L}},Ue.isValidElement=U,Ue.lazy=function(L){return{$$typeof:x,_payload:{_status:-1,_result:L},_init:W}},Ue.memo=function(L,q){return{$$typeof:p,type:L,compare:q===void 0?null:q}},Ue.startTransition=function(L){var q=Z.transition;Z.transition={};try{L()}finally{Z.transition=q}},Ue.unstable_act=E,Ue.useCallback=function(L,q){return J.current.useCallback(L,q)},Ue.useContext=function(L){return J.current.useContext(L)},Ue.useDebugValue=function(){},Ue.useDeferredValue=function(L){return J.current.useDeferredValue(L)},Ue.useEffect=function(L,q){return J.current.useEffect(L,q)},Ue.useId=function(){return J.current.useId()},Ue.useImperativeHandle=function(L,q,S){return J.current.useImperativeHandle(L,q,S)},Ue.useInsertionEffect=function(L,q){return J.current.useInsertionEffect(L,q)},Ue.useLayoutEffect=function(L,q){return J.current.useLayoutEffect(L,q)},Ue.useMemo=function(L,q){return J.current.useMemo(L,q)},Ue.useReducer=function(L,q,S){return J.current.useReducer(L,q,S)},Ue.useRef=function(L){return J.current.useRef(L)},Ue.useState=function(L){return J.current.useState(L)},Ue.useSyncExternalStore=function(L,q,S){return J.current.useSyncExternalStore(L,q,S)},Ue.useTransition=function(){return J.current.useTransition()},Ue.version="18.3.1",Ue}var $0;function lu(){return $0||($0=1,ad.exports=_2()),ad.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 D0;function L2(){if(D0)return Ki;D0=1;var e=lu(),r=Symbol.for("react.element"),s=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function d(u,h,p){var x,g={},b=null,v=null;p!==void 0&&(b=""+p),h.key!==void 0&&(b=""+h.key),h.ref!==void 0&&(v=h.ref);for(x in h)a.call(h,x)&&!c.hasOwnProperty(x)&&(g[x]=h[x]);if(u&&u.defaultProps)for(x in h=u.defaultProps,h)g[x]===void 0&&(g[x]=h[x]);return{$$typeof:r,type:u,key:b,ref:v,props:g,_owner:o.current}}return Ki.Fragment=s,Ki.jsx=d,Ki.jsxs=d,Ki}var B0;function E2(){return B0||(B0=1,id.exports=L2()),id.exports}var t=E2(),y=lu();const Ks=ul(y),T2=S2({__proto__:null,default:Ks},[y]);var Mo={},od={exports:{}},hr={},ld={exports:{}},cd={};/**
|
|
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 z0;function A2(){return z0||(z0=1,(function(e){function r(Z,de){var E=Z.length;Z.push(de);e:for(;0<E;){var L=E-1>>>1,q=Z[L];if(0<o(q,de))Z[L]=de,Z[E]=q,E=L;else break e}}function s(Z){return Z.length===0?null:Z[0]}function a(Z){if(Z.length===0)return null;var de=Z[0],E=Z.pop();if(E!==de){Z[0]=E;e:for(var L=0,q=Z.length,S=q>>>1;L<S;){var G=2*(L+1)-1,re=Z[G],ee=G+1,ge=Z[ee];if(0>o(re,E))ee<q&&0>o(ge,re)?(Z[L]=ge,Z[ee]=E,L=ee):(Z[L]=re,Z[G]=E,L=G);else if(ee<q&&0>o(ge,E))Z[L]=ge,Z[ee]=E,L=ee;else break e}}return de}function o(Z,de){var E=Z.sortIndex-de.sortIndex;return E!==0?E:Z.id-de.id}if(typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var d=Date,u=d.now();e.unstable_now=function(){return d.now()-u}}var h=[],p=[],x=1,g=null,b=3,v=!1,k=!1,T=!1,N=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,A=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(Z){for(var de=s(p);de!==null;){if(de.callback===null)a(p);else if(de.startTime<=Z)a(p),de.sortIndex=de.expirationTime,r(h,de);else break;de=s(p)}}function _(Z){if(T=!1,M(Z),!k)if(s(h)!==null)k=!0,W(z);else{var de=s(p);de!==null&&J(_,de.startTime-Z)}}function z(Z,de){k=!1,T&&(T=!1,j(V),V=-1),v=!0;var E=b;try{for(M(de),g=s(h);g!==null&&(!(g.expirationTime>de)||Z&&!D());){var L=g.callback;if(typeof L=="function"){g.callback=null,b=g.priorityLevel;var q=L(g.expirationTime<=de);de=e.unstable_now(),typeof q=="function"?g.callback=q:g===s(h)&&a(h),M(de)}else a(h);g=s(h)}if(g!==null)var S=!0;else{var G=s(p);G!==null&&J(_,G.startTime-de),S=!1}return S}finally{g=null,b=E,v=!1}}var P=!1,$=null,V=-1,B=5,U=-1;function D(){return!(e.unstable_now()-U<B)}function R(){if($!==null){var Z=e.unstable_now();U=Z;var de=!0;try{de=$(!0,Z)}finally{de?X():(P=!1,$=null)}}else P=!1}var X;if(typeof A=="function")X=function(){A(R)};else if(typeof MessageChannel<"u"){var I=new MessageChannel,H=I.port2;I.port1.onmessage=R,X=function(){H.postMessage(null)}}else X=function(){N(R,0)};function W(Z){$=Z,P||(P=!0,X())}function J(Z,de){V=N(function(){Z(e.unstable_now())},de)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(Z){Z.callback=null},e.unstable_continueExecution=function(){k||v||(k=!0,W(z))},e.unstable_forceFrameRate=function(Z){0>Z||125<Z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):B=0<Z?Math.floor(1e3/Z):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_getFirstCallbackNode=function(){return s(h)},e.unstable_next=function(Z){switch(b){case 1:case 2:case 3:var de=3;break;default:de=b}var E=b;b=de;try{return Z()}finally{b=E}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(Z,de){switch(Z){case 1:case 2:case 3:case 4:case 5:break;default:Z=3}var E=b;b=Z;try{return de()}finally{b=E}},e.unstable_scheduleCallback=function(Z,de,E){var L=e.unstable_now();switch(typeof E=="object"&&E!==null?(E=E.delay,E=typeof E=="number"&&0<E?L+E:L):E=L,Z){case 1:var q=-1;break;case 2:q=250;break;case 5:q=1073741823;break;case 4:q=1e4;break;default:q=5e3}return q=E+q,Z={id:x++,callback:de,priorityLevel:Z,startTime:E,expirationTime:q,sortIndex:-1},E>L?(Z.sortIndex=E,r(p,Z),s(h)===null&&Z===s(p)&&(T?(j(V),V=-1):T=!0,J(_,E-L))):(Z.sortIndex=q,r(h,Z),k||v||(k=!0,W(z))),Z},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(Z){var de=b;return function(){var E=b;b=de;try{return Z.apply(this,arguments)}finally{b=E}}}})(cd)),cd}var O0;function P2(){return O0||(O0=1,ld.exports=A2()),ld.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 F0;function I2(){if(F0)return hr;F0=1;var e=lu(),r=P2();function s(n){for(var i="https://reactjs.org/docs/error-decoder.html?invariant="+n,l=1;l<arguments.length;l++)i+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+n+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var a=new Set,o={};function c(n,i){d(n,i),d(n+"Capture",i)}function d(n,i){for(o[n]=i,n=0;n<i.length;n++)a.add(i[n])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),h=Object.prototype.hasOwnProperty,p=/^[: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]*$/,x={},g={};function b(n){return h.call(g,n)?!0:h.call(x,n)?!1:p.test(n)?g[n]=!0:(x[n]=!0,!1)}function v(n,i,l,m){if(l!==null&&l.type===0)return!1;switch(typeof i){case"function":case"symbol":return!0;case"boolean":return m?!1:l!==null?!l.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function k(n,i,l,m){if(i===null||typeof i>"u"||v(n,i,l,m))return!0;if(m)return!1;if(l!==null)switch(l.type){case 3:return!i;case 4:return i===!1;case 5:return isNaN(i);case 6:return isNaN(i)||1>i}return!1}function T(n,i,l,m,f,w,C){this.acceptsBooleans=i===2||i===3||i===4,this.attributeName=m,this.attributeNamespace=f,this.mustUseProperty=l,this.propertyName=n,this.type=i,this.sanitizeURL=w,this.removeEmptyString=C}var N={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){N[n]=new T(n,0,!1,n,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var i=n[0];N[i]=new T(i,1,!1,n[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(n){N[n]=new T(n,2,!1,n.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){N[n]=new T(n,2,!1,n,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(n){N[n]=new T(n,3,!1,n.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(n){N[n]=new T(n,3,!0,n,null,!1,!1)}),["capture","download"].forEach(function(n){N[n]=new T(n,4,!1,n,null,!1,!1)}),["cols","rows","size","span"].forEach(function(n){N[n]=new T(n,6,!1,n,null,!1,!1)}),["rowSpan","start"].forEach(function(n){N[n]=new T(n,5,!1,n.toLowerCase(),null,!1,!1)});var j=/[\-:]([a-z])/g;function A(n){return n[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(n){var i=n.replace(j,A);N[i]=new T(i,1,!1,n,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var i=n.replace(j,A);N[i]=new T(i,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(n){var i=n.replace(j,A);N[i]=new T(i,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(n){N[n]=new T(n,1,!1,n.toLowerCase(),null,!1,!1)}),N.xlinkHref=new T("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(n){N[n]=new T(n,1,!1,n.toLowerCase(),null,!0,!0)});function M(n,i,l,m){var f=N.hasOwnProperty(i)?N[i]:null;(f!==null?f.type!==0:m||!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=="N")&&(k(i,l,f,m)&&(l=null),m||f===null?b(i)&&(l===null?n.removeAttribute(i):n.setAttribute(i,""+l)):f.mustUseProperty?n[f.propertyName]=l===null?f.type===3?!1:"":l:(i=f.attributeName,m=f.attributeNamespace,l===null?n.removeAttribute(i):(f=f.type,l=f===3||f===4&&l===!0?"":""+l,m?n.setAttributeNS(m,i,l):n.setAttribute(i,l))))}var _=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,z=Symbol.for("react.element"),P=Symbol.for("react.portal"),$=Symbol.for("react.fragment"),V=Symbol.for("react.strict_mode"),B=Symbol.for("react.profiler"),U=Symbol.for("react.provider"),D=Symbol.for("react.context"),R=Symbol.for("react.forward_ref"),X=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),J=Symbol.for("react.offscreen"),Z=Symbol.iterator;function de(n){return n===null||typeof n!="object"?null:(n=Z&&n[Z]||n["@@iterator"],typeof n=="function"?n:null)}var E=Object.assign,L;function q(n){if(L===void 0)try{throw Error()}catch(l){var i=l.stack.trim().match(/\n( *(at )?)/);L=i&&i[1]||""}return`
|
|
34
|
+
`+L+n}var S=!1;function G(n,i){if(!n||S)return"";S=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(i)if(i=function(){throw Error()},Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(i,[])}catch(se){var m=se}Reflect.construct(n,[],i)}else{try{i.call()}catch(se){m=se}n.call(i.prototype)}else{try{throw Error()}catch(se){m=se}n()}}catch(se){if(se&&m&&typeof se.stack=="string"){for(var f=se.stack.split(`
|
|
35
|
+
`),w=m.stack.split(`
|
|
36
|
+
`),C=f.length-1,O=w.length-1;1<=C&&0<=O&&f[C]!==w[O];)O--;for(;1<=C&&0<=O;C--,O--)if(f[C]!==w[O]){if(C!==1||O!==1)do if(C--,O--,0>O||f[C]!==w[O]){var Y=`
|
|
37
|
+
`+f[C].replace(" at new "," at ");return n.displayName&&Y.includes("<anonymous>")&&(Y=Y.replace("<anonymous>",n.displayName)),Y}while(1<=C&&0<=O);break}}}finally{S=!1,Error.prepareStackTrace=l}return(n=n?n.displayName||n.name:"")?q(n):""}function re(n){switch(n.tag){case 5:return q(n.type);case 16:return q("Lazy");case 13:return q("Suspense");case 19:return q("SuspenseList");case 0:case 2:case 15:return n=G(n.type,!1),n;case 11:return n=G(n.type.render,!1),n;case 1:return n=G(n.type,!0),n;default:return""}}function ee(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case $:return"Fragment";case P:return"Portal";case B:return"Profiler";case V:return"StrictMode";case X:return"Suspense";case I:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case D:return(n.displayName||"Context")+".Consumer";case U:return(n._context.displayName||"Context")+".Provider";case R:var i=n.render;return n=n.displayName,n||(n=i.displayName||i.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case H:return i=n.displayName||null,i!==null?i:ee(n.type)||"Memo";case W:i=n._payload,n=n._init;try{return ee(n(i))}catch{}}return null}function ge(n){var i=n.type;switch(n.tag){case 24:return"Cache";case 9:return(i.displayName||"Context")+".Consumer";case 10:return(i._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=i.render,n=n.displayName||n.name||"",i.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return i;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ee(i);case 8:return i===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 i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i}return null}function je(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Le(n){var i=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function ve(n){var i=Le(n)?"checked":"value",l=Object.getOwnPropertyDescriptor(n.constructor.prototype,i),m=""+n[i];if(!n.hasOwnProperty(i)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var f=l.get,w=l.set;return Object.defineProperty(n,i,{configurable:!0,get:function(){return f.call(this)},set:function(C){m=""+C,w.call(this,C)}}),Object.defineProperty(n,i,{enumerable:l.enumerable}),{getValue:function(){return m},setValue:function(C){m=""+C},stopTracking:function(){n._valueTracker=null,delete n[i]}}}}function F(n){n._valueTracker||(n._valueTracker=ve(n))}function he(n){if(!n)return!1;var i=n._valueTracker;if(!i)return!0;var l=i.getValue(),m="";return n&&(m=Le(n)?n.checked?"true":"false":n.value),n=m,n!==l?(i.setValue(n),!0):!1}function ue(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function Oe(n,i){var l=i.checked;return E({},i,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??n._wrapperState.initialChecked})}function Se(n,i){var l=i.defaultValue==null?"":i.defaultValue,m=i.checked!=null?i.checked:i.defaultChecked;l=je(i.value!=null?i.value:l),n._wrapperState={initialChecked:m,initialValue:l,controlled:i.type==="checkbox"||i.type==="radio"?i.checked!=null:i.value!=null}}function We(n,i){i=i.checked,i!=null&&M(n,"checked",i,!1)}function qe(n,i){We(n,i);var l=je(i.value),m=i.type;if(l!=null)m==="number"?(l===0&&n.value===""||n.value!=l)&&(n.value=""+l):n.value!==""+l&&(n.value=""+l);else if(m==="submit"||m==="reset"){n.removeAttribute("value");return}i.hasOwnProperty("value")?ft(n,i.type,l):i.hasOwnProperty("defaultValue")&&ft(n,i.type,je(i.defaultValue)),i.checked==null&&i.defaultChecked!=null&&(n.defaultChecked=!!i.defaultChecked)}function tt(n,i,l){if(i.hasOwnProperty("value")||i.hasOwnProperty("defaultValue")){var m=i.type;if(!(m!=="submit"&&m!=="reset"||i.value!==void 0&&i.value!==null))return;i=""+n._wrapperState.initialValue,l||i===n.value||(n.value=i),n.defaultValue=i}l=n.name,l!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,l!==""&&(n.name=l)}function ft(n,i,l){(i!=="number"||ue(n.ownerDocument)!==n)&&(l==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+l&&(n.defaultValue=""+l))}var Rt=Array.isArray;function $t(n,i,l,m){if(n=n.options,i){i={};for(var f=0;f<l.length;f++)i["$"+l[f]]=!0;for(l=0;l<n.length;l++)f=i.hasOwnProperty("$"+n[l].value),n[l].selected!==f&&(n[l].selected=f),f&&m&&(n[l].defaultSelected=!0)}else{for(l=""+je(l),i=null,f=0;f<n.length;f++){if(n[f].value===l){n[f].selected=!0,m&&(n[f].defaultSelected=!0);return}i!==null||n[f].disabled||(i=n[f])}i!==null&&(i.selected=!0)}}function Zt(n,i){if(i.dangerouslySetInnerHTML!=null)throw Error(s(91));return E({},i,{value:void 0,defaultValue:void 0,children:""+n._wrapperState.initialValue})}function ar(n,i){var l=i.value;if(l==null){if(l=i.children,i=i.defaultValue,l!=null){if(i!=null)throw Error(s(92));if(Rt(l)){if(1<l.length)throw Error(s(93));l=l[0]}i=l}i==null&&(i=""),l=i}n._wrapperState={initialValue:je(l)}}function er(n,i){var l=je(i.value),m=je(i.defaultValue);l!=null&&(l=""+l,l!==n.value&&(n.value=l),i.defaultValue==null&&n.defaultValue!==l&&(n.defaultValue=l)),m!=null&&(n.defaultValue=""+m)}function Et(n){var i=n.textContent;i===n._wrapperState.initialValue&&i!==""&&i!==null&&(n.value=i)}function ae(n){switch(n){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 Q(n,i){return n==null||n==="http://www.w3.org/1999/xhtml"?ae(i):n==="http://www.w3.org/2000/svg"&&i==="foreignObject"?"http://www.w3.org/1999/xhtml":n}var fe,be=(function(n){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(i,l,m,f){MSApp.execUnsafeLocalFunction(function(){return n(i,l,m,f)})}:n})(function(n,i){if(n.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in n)n.innerHTML=i;else{for(fe=fe||document.createElement("div"),fe.innerHTML="<svg>"+i.valueOf().toString()+"</svg>",i=fe.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;i.firstChild;)n.appendChild(i.firstChild)}});function Me(n,i){if(i){var l=n.firstChild;if(l&&l===n.lastChild&&l.nodeType===3){l.nodeValue=i;return}}n.textContent=i}var Ve={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},Ye=["Webkit","ms","Moz","O"];Object.keys(Ve).forEach(function(n){Ye.forEach(function(i){i=i+n.charAt(0).toUpperCase()+n.substring(1),Ve[i]=Ve[n]})});function Ct(n,i,l){return i==null||typeof i=="boolean"||i===""?"":l||typeof i!="number"||i===0||Ve.hasOwnProperty(n)&&Ve[n]?(""+i).trim():i+"px"}function Vt(n,i){n=n.style;for(var l in i)if(i.hasOwnProperty(l)){var m=l.indexOf("--")===0,f=Ct(l,i[l],m);l==="float"&&(l="cssFloat"),m?n.setProperty(l,f):n[l]=f}}var yt=E({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 rt(n,i){if(i){if(yt[n]&&(i.children!=null||i.dangerouslySetInnerHTML!=null))throw Error(s(137,n));if(i.dangerouslySetInnerHTML!=null){if(i.children!=null)throw Error(s(60));if(typeof i.dangerouslySetInnerHTML!="object"||!("__html"in i.dangerouslySetInnerHTML))throw Error(s(61))}if(i.style!=null&&typeof i.style!="object")throw Error(s(62))}}function ce(n,i){if(n.indexOf("-")===-1)return typeof i.is=="string";switch(n){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 Ae=null;function ie(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var Fe=null,dt=null,Ke=null;function vr(n){if(n=Mi(n)){if(typeof Fe!="function")throw Error(s(280));var i=n.stateNode;i&&(i=Ga(i),Fe(n.stateNode,n.type,i))}}function or(n){dt?Ke?Ke.push(n):Ke=[n]:dt=n}function an(){if(dt){var n=dt,i=Ke;if(Ke=dt=null,vr(n),i)for(n=0;n<i.length;n++)vr(i[n])}}function mt(n,i){return n(i)}function Pe(){}var et=!1;function hi(n,i,l){if(et)return n(i,l);et=!0;try{return mt(n,i,l)}finally{et=!1,(dt!==null||Ke!==null)&&(Pe(),an())}}function Ft(n,i){var l=n.stateNode;if(l===null)return null;var m=Ga(l);if(m===null)return null;l=m[i];e:switch(i){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(m=!m.disabled)||(n=n.type,m=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!m;break e;default:n=!1}if(n)return null;if(l&&typeof l!="function")throw Error(s(231,i,typeof l));return l}var kl=!1;if(u)try{var pi={};Object.defineProperty(pi,"passive",{get:function(){kl=!0}}),window.addEventListener("test",pi,pi),window.removeEventListener("test",pi,pi)}catch{kl=!1}function Py(n,i,l,m,f,w,C,O,Y){var se=Array.prototype.slice.call(arguments,3);try{i.apply(l,se)}catch(pe){this.onError(pe)}}var fi=!1,Sa=null,_a=!1,Nl=null,Iy={onError:function(n){fi=!0,Sa=n}};function My(n,i,l,m,f,w,C,O,Y){fi=!1,Sa=null,Py.apply(Iy,arguments)}function Ry(n,i,l,m,f,w,C,O,Y){if(My.apply(this,arguments),fi){if(fi){var se=Sa;fi=!1,Sa=null}else throw Error(s(198));_a||(_a=!0,Nl=se)}}function Xn(n){var i=n,l=n;if(n.alternate)for(;i.return;)i=i.return;else{n=i;do i=n,(i.flags&4098)!==0&&(l=i.return),n=i.return;while(n)}return i.tag===3?l:null}function sm(n){if(n.tag===13){var i=n.memoizedState;if(i===null&&(n=n.alternate,n!==null&&(i=n.memoizedState)),i!==null)return i.dehydrated}return null}function im(n){if(Xn(n)!==n)throw Error(s(188))}function $y(n){var i=n.alternate;if(!i){if(i=Xn(n),i===null)throw Error(s(188));return i!==n?null:n}for(var l=n,m=i;;){var f=l.return;if(f===null)break;var w=f.alternate;if(w===null){if(m=f.return,m!==null){l=m;continue}break}if(f.child===w.child){for(w=f.child;w;){if(w===l)return im(f),n;if(w===m)return im(f),i;w=w.sibling}throw Error(s(188))}if(l.return!==m.return)l=f,m=w;else{for(var C=!1,O=f.child;O;){if(O===l){C=!0,l=f,m=w;break}if(O===m){C=!0,m=f,l=w;break}O=O.sibling}if(!C){for(O=w.child;O;){if(O===l){C=!0,l=w,m=f;break}if(O===m){C=!0,m=w,l=f;break}O=O.sibling}if(!C)throw Error(s(189))}}if(l.alternate!==m)throw Error(s(190))}if(l.tag!==3)throw Error(s(188));return l.stateNode.current===l?n:i}function am(n){return n=$y(n),n!==null?om(n):null}function om(n){if(n.tag===5||n.tag===6)return n;for(n=n.child;n!==null;){var i=om(n);if(i!==null)return i;n=n.sibling}return null}var lm=r.unstable_scheduleCallback,cm=r.unstable_cancelCallback,Dy=r.unstable_shouldYield,By=r.unstable_requestPaint,vt=r.unstable_now,zy=r.unstable_getCurrentPriorityLevel,Cl=r.unstable_ImmediatePriority,dm=r.unstable_UserBlockingPriority,La=r.unstable_NormalPriority,Oy=r.unstable_LowPriority,um=r.unstable_IdlePriority,Ea=null,qr=null;function Fy(n){if(qr&&typeof qr.onCommitFiberRoot=="function")try{qr.onCommitFiberRoot(Ea,n,void 0,(n.current.flags&128)===128)}catch{}}var Br=Math.clz32?Math.clz32:Uy,Wy=Math.log,Hy=Math.LN2;function Uy(n){return n>>>=0,n===0?32:31-(Wy(n)/Hy|0)|0}var Ta=64,Aa=4194304;function xi(n){switch(n&-n){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 n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function Pa(n,i){var l=n.pendingLanes;if(l===0)return 0;var m=0,f=n.suspendedLanes,w=n.pingedLanes,C=l&268435455;if(C!==0){var O=C&~f;O!==0?m=xi(O):(w&=C,w!==0&&(m=xi(w)))}else C=l&~f,C!==0?m=xi(C):w!==0&&(m=xi(w));if(m===0)return 0;if(i!==0&&i!==m&&(i&f)===0&&(f=m&-m,w=i&-i,f>=w||f===16&&(w&4194240)!==0))return i;if((m&4)!==0&&(m|=l&16),i=n.entangledLanes,i!==0)for(n=n.entanglements,i&=m;0<i;)l=31-Br(i),f=1<<l,m|=n[l],i&=~f;return m}function Vy(n,i){switch(n){case 1:case 2:case 4:return i+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 i+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 qy(n,i){for(var l=n.suspendedLanes,m=n.pingedLanes,f=n.expirationTimes,w=n.pendingLanes;0<w;){var C=31-Br(w),O=1<<C,Y=f[C];Y===-1?((O&l)===0||(O&m)!==0)&&(f[C]=Vy(O,i)):Y<=i&&(n.expiredLanes|=O),w&=~O}}function Sl(n){return n=n.pendingLanes&-1073741825,n!==0?n:n&1073741824?1073741824:0}function mm(){var n=Ta;return Ta<<=1,(Ta&4194240)===0&&(Ta=64),n}function _l(n){for(var i=[],l=0;31>l;l++)i.push(n);return i}function gi(n,i,l){n.pendingLanes|=i,i!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,i=31-Br(i),n[i]=l}function Yy(n,i){var l=n.pendingLanes&~i;n.pendingLanes=i,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=i,n.mutableReadLanes&=i,n.entangledLanes&=i,i=n.entanglements;var m=n.eventTimes;for(n=n.expirationTimes;0<l;){var f=31-Br(l),w=1<<f;i[f]=0,m[f]=-1,n[f]=-1,l&=~w}}function Ll(n,i){var l=n.entangledLanes|=i;for(n=n.entanglements;l;){var m=31-Br(l),f=1<<m;f&i|n[m]&i&&(n[m]|=i),l&=~f}}var nt=0;function hm(n){return n&=-n,1<n?4<n?(n&268435455)!==0?16:536870912:4:1}var pm,El,fm,xm,gm,Tl=!1,Ia=[],wn=null,bn=null,jn=null,yi=new Map,vi=new Map,kn=[],Gy="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 ym(n,i){switch(n){case"focusin":case"focusout":wn=null;break;case"dragenter":case"dragleave":bn=null;break;case"mouseover":case"mouseout":jn=null;break;case"pointerover":case"pointerout":yi.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":vi.delete(i.pointerId)}}function wi(n,i,l,m,f,w){return n===null||n.nativeEvent!==w?(n={blockedOn:i,domEventName:l,eventSystemFlags:m,nativeEvent:w,targetContainers:[f]},i!==null&&(i=Mi(i),i!==null&&El(i)),n):(n.eventSystemFlags|=m,i=n.targetContainers,f!==null&&i.indexOf(f)===-1&&i.push(f),n)}function Ky(n,i,l,m,f){switch(i){case"focusin":return wn=wi(wn,n,i,l,m,f),!0;case"dragenter":return bn=wi(bn,n,i,l,m,f),!0;case"mouseover":return jn=wi(jn,n,i,l,m,f),!0;case"pointerover":var w=f.pointerId;return yi.set(w,wi(yi.get(w)||null,n,i,l,m,f)),!0;case"gotpointercapture":return w=f.pointerId,vi.set(w,wi(vi.get(w)||null,n,i,l,m,f)),!0}return!1}function vm(n){var i=Zn(n.target);if(i!==null){var l=Xn(i);if(l!==null){if(i=l.tag,i===13){if(i=sm(l),i!==null){n.blockedOn=i,gm(n.priority,function(){fm(l)});return}}else if(i===3&&l.stateNode.current.memoizedState.isDehydrated){n.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}n.blockedOn=null}function Ma(n){if(n.blockedOn!==null)return!1;for(var i=n.targetContainers;0<i.length;){var l=Pl(n.domEventName,n.eventSystemFlags,i[0],n.nativeEvent);if(l===null){l=n.nativeEvent;var m=new l.constructor(l.type,l);Ae=m,l.target.dispatchEvent(m),Ae=null}else return i=Mi(l),i!==null&&El(i),n.blockedOn=l,!1;i.shift()}return!0}function wm(n,i,l){Ma(n)&&l.delete(i)}function Qy(){Tl=!1,wn!==null&&Ma(wn)&&(wn=null),bn!==null&&Ma(bn)&&(bn=null),jn!==null&&Ma(jn)&&(jn=null),yi.forEach(wm),vi.forEach(wm)}function bi(n,i){n.blockedOn===i&&(n.blockedOn=null,Tl||(Tl=!0,r.unstable_scheduleCallback(r.unstable_NormalPriority,Qy)))}function ji(n){function i(f){return bi(f,n)}if(0<Ia.length){bi(Ia[0],n);for(var l=1;l<Ia.length;l++){var m=Ia[l];m.blockedOn===n&&(m.blockedOn=null)}}for(wn!==null&&bi(wn,n),bn!==null&&bi(bn,n),jn!==null&&bi(jn,n),yi.forEach(i),vi.forEach(i),l=0;l<kn.length;l++)m=kn[l],m.blockedOn===n&&(m.blockedOn=null);for(;0<kn.length&&(l=kn[0],l.blockedOn===null);)vm(l),l.blockedOn===null&&kn.shift()}var js=_.ReactCurrentBatchConfig,Ra=!0;function Jy(n,i,l,m){var f=nt,w=js.transition;js.transition=null;try{nt=1,Al(n,i,l,m)}finally{nt=f,js.transition=w}}function Xy(n,i,l,m){var f=nt,w=js.transition;js.transition=null;try{nt=4,Al(n,i,l,m)}finally{nt=f,js.transition=w}}function Al(n,i,l,m){if(Ra){var f=Pl(n,i,l,m);if(f===null)Kl(n,i,m,$a,l),ym(n,m);else if(Ky(f,n,i,l,m))m.stopPropagation();else if(ym(n,m),i&4&&-1<Gy.indexOf(n)){for(;f!==null;){var w=Mi(f);if(w!==null&&pm(w),w=Pl(n,i,l,m),w===null&&Kl(n,i,m,$a,l),w===f)break;f=w}f!==null&&m.stopPropagation()}else Kl(n,i,m,null,l)}}var $a=null;function Pl(n,i,l,m){if($a=null,n=ie(m),n=Zn(n),n!==null)if(i=Xn(n),i===null)n=null;else if(l=i.tag,l===13){if(n=sm(i),n!==null)return n;n=null}else if(l===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;n=null}else i!==n&&(n=null);return $a=n,null}function bm(n){switch(n){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(zy()){case Cl:return 1;case dm:return 4;case La:case Oy:return 16;case um:return 536870912;default:return 16}default:return 16}}var Nn=null,Il=null,Da=null;function jm(){if(Da)return Da;var n,i=Il,l=i.length,m,f="value"in Nn?Nn.value:Nn.textContent,w=f.length;for(n=0;n<l&&i[n]===f[n];n++);var C=l-n;for(m=1;m<=C&&i[l-m]===f[w-m];m++);return Da=f.slice(n,1<m?1-m:void 0)}function Ba(n){var i=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&i===13&&(n=13)):n=i,n===10&&(n=13),32<=n||n===13?n:0}function za(){return!0}function km(){return!1}function wr(n){function i(l,m,f,w,C){this._reactName=l,this._targetInst=f,this.type=m,this.nativeEvent=w,this.target=C,this.currentTarget=null;for(var O in n)n.hasOwnProperty(O)&&(l=n[O],this[O]=l?l(w):w[O]);return this.isDefaultPrevented=(w.defaultPrevented!=null?w.defaultPrevented:w.returnValue===!1)?za:km,this.isPropagationStopped=km,this}return E(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=za)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=za)},persist:function(){},isPersistent:za}),i}var ks={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ml=wr(ks),ki=E({},ks,{view:0,detail:0}),Zy=wr(ki),Rl,$l,Ni,Oa=E({},ki,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Bl,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==Ni&&(Ni&&n.type==="mousemove"?(Rl=n.screenX-Ni.screenX,$l=n.screenY-Ni.screenY):$l=Rl=0,Ni=n),Rl)},movementY:function(n){return"movementY"in n?n.movementY:$l}}),Nm=wr(Oa),ev=E({},Oa,{dataTransfer:0}),tv=wr(ev),rv=E({},ki,{relatedTarget:0}),Dl=wr(rv),nv=E({},ks,{animationName:0,elapsedTime:0,pseudoElement:0}),sv=wr(nv),iv=E({},ks,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),av=wr(iv),ov=E({},ks,{data:0}),Cm=wr(ov),lv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},cv={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"},dv={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function uv(n){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(n):(n=dv[n])?!!i[n]:!1}function Bl(){return uv}var mv=E({},ki,{key:function(n){if(n.key){var i=lv[n.key]||n.key;if(i!=="Unidentified")return i}return n.type==="keypress"?(n=Ba(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?cv[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Bl,charCode:function(n){return n.type==="keypress"?Ba(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?Ba(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),hv=wr(mv),pv=E({},Oa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Sm=wr(pv),fv=E({},ki,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Bl}),xv=wr(fv),gv=E({},ks,{propertyName:0,elapsedTime:0,pseudoElement:0}),yv=wr(gv),vv=E({},Oa,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),wv=wr(vv),bv=[9,13,27,32],zl=u&&"CompositionEvent"in window,Ci=null;u&&"documentMode"in document&&(Ci=document.documentMode);var jv=u&&"TextEvent"in window&&!Ci,_m=u&&(!zl||Ci&&8<Ci&&11>=Ci),Lm=" ",Em=!1;function Tm(n,i){switch(n){case"keyup":return bv.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Am(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Ns=!1;function kv(n,i){switch(n){case"compositionend":return Am(i);case"keypress":return i.which!==32?null:(Em=!0,Lm);case"textInput":return n=i.data,n===Lm&&Em?null:n;default:return null}}function Nv(n,i){if(Ns)return n==="compositionend"||!zl&&Tm(n,i)?(n=jm(),Da=Il=Nn=null,Ns=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1<i.char.length)return i.char;if(i.which)return String.fromCharCode(i.which)}return null;case"compositionend":return _m&&i.locale!=="ko"?null:i.data;default:return null}}var Cv={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 Pm(n){var i=n&&n.nodeName&&n.nodeName.toLowerCase();return i==="input"?!!Cv[n.type]:i==="textarea"}function Im(n,i,l,m){or(m),i=Va(i,"onChange"),0<i.length&&(l=new Ml("onChange","change",null,l,m),n.push({event:l,listeners:i}))}var Si=null,_i=null;function Sv(n){Jm(n,0)}function Fa(n){var i=Es(n);if(he(i))return n}function _v(n,i){if(n==="change")return i}var Mm=!1;if(u){var Ol;if(u){var Fl="oninput"in document;if(!Fl){var Rm=document.createElement("div");Rm.setAttribute("oninput","return;"),Fl=typeof Rm.oninput=="function"}Ol=Fl}else Ol=!1;Mm=Ol&&(!document.documentMode||9<document.documentMode)}function $m(){Si&&(Si.detachEvent("onpropertychange",Dm),_i=Si=null)}function Dm(n){if(n.propertyName==="value"&&Fa(_i)){var i=[];Im(i,_i,n,ie(n)),hi(Sv,i)}}function Lv(n,i,l){n==="focusin"?($m(),Si=i,_i=l,Si.attachEvent("onpropertychange",Dm)):n==="focusout"&&$m()}function Ev(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return Fa(_i)}function Tv(n,i){if(n==="click")return Fa(i)}function Av(n,i){if(n==="input"||n==="change")return Fa(i)}function Pv(n,i){return n===i&&(n!==0||1/n===1/i)||n!==n&&i!==i}var zr=typeof Object.is=="function"?Object.is:Pv;function Li(n,i){if(zr(n,i))return!0;if(typeof n!="object"||n===null||typeof i!="object"||i===null)return!1;var l=Object.keys(n),m=Object.keys(i);if(l.length!==m.length)return!1;for(m=0;m<l.length;m++){var f=l[m];if(!h.call(i,f)||!zr(n[f],i[f]))return!1}return!0}function Bm(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function zm(n,i){var l=Bm(n);n=0;for(var m;l;){if(l.nodeType===3){if(m=n+l.textContent.length,n<=i&&m>=i)return{node:l,offset:i-n};n=m}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Bm(l)}}function Om(n,i){return n&&i?n===i?!0:n&&n.nodeType===3?!1:i&&i.nodeType===3?Om(n,i.parentNode):"contains"in n?n.contains(i):n.compareDocumentPosition?!!(n.compareDocumentPosition(i)&16):!1:!1}function Fm(){for(var n=window,i=ue();i instanceof n.HTMLIFrameElement;){try{var l=typeof i.contentWindow.location.href=="string"}catch{l=!1}if(l)n=i.contentWindow;else break;i=ue(n.document)}return i}function Wl(n){var i=n&&n.nodeName&&n.nodeName.toLowerCase();return i&&(i==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||i==="textarea"||n.contentEditable==="true")}function Iv(n){var i=Fm(),l=n.focusedElem,m=n.selectionRange;if(i!==l&&l&&l.ownerDocument&&Om(l.ownerDocument.documentElement,l)){if(m!==null&&Wl(l)){if(i=m.start,n=m.end,n===void 0&&(n=i),"selectionStart"in l)l.selectionStart=i,l.selectionEnd=Math.min(n,l.value.length);else if(n=(i=l.ownerDocument||document)&&i.defaultView||window,n.getSelection){n=n.getSelection();var f=l.textContent.length,w=Math.min(m.start,f);m=m.end===void 0?w:Math.min(m.end,f),!n.extend&&w>m&&(f=m,m=w,w=f),f=zm(l,w);var C=zm(l,m);f&&C&&(n.rangeCount!==1||n.anchorNode!==f.node||n.anchorOffset!==f.offset||n.focusNode!==C.node||n.focusOffset!==C.offset)&&(i=i.createRange(),i.setStart(f.node,f.offset),n.removeAllRanges(),w>m?(n.addRange(i),n.extend(C.node,C.offset)):(i.setEnd(C.node,C.offset),n.addRange(i)))}}for(i=[],n=l;n=n.parentNode;)n.nodeType===1&&i.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof l.focus=="function"&&l.focus(),l=0;l<i.length;l++)n=i[l],n.element.scrollLeft=n.left,n.element.scrollTop=n.top}}var Mv=u&&"documentMode"in document&&11>=document.documentMode,Cs=null,Hl=null,Ei=null,Ul=!1;function Wm(n,i,l){var m=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Ul||Cs==null||Cs!==ue(m)||(m=Cs,"selectionStart"in m&&Wl(m)?m={start:m.selectionStart,end:m.selectionEnd}:(m=(m.ownerDocument&&m.ownerDocument.defaultView||window).getSelection(),m={anchorNode:m.anchorNode,anchorOffset:m.anchorOffset,focusNode:m.focusNode,focusOffset:m.focusOffset}),Ei&&Li(Ei,m)||(Ei=m,m=Va(Hl,"onSelect"),0<m.length&&(i=new Ml("onSelect","select",null,i,l),n.push({event:i,listeners:m}),i.target=Cs)))}function Wa(n,i){var l={};return l[n.toLowerCase()]=i.toLowerCase(),l["Webkit"+n]="webkit"+i,l["Moz"+n]="moz"+i,l}var Ss={animationend:Wa("Animation","AnimationEnd"),animationiteration:Wa("Animation","AnimationIteration"),animationstart:Wa("Animation","AnimationStart"),transitionend:Wa("Transition","TransitionEnd")},Vl={},Hm={};u&&(Hm=document.createElement("div").style,"AnimationEvent"in window||(delete Ss.animationend.animation,delete Ss.animationiteration.animation,delete Ss.animationstart.animation),"TransitionEvent"in window||delete Ss.transitionend.transition);function Ha(n){if(Vl[n])return Vl[n];if(!Ss[n])return n;var i=Ss[n],l;for(l in i)if(i.hasOwnProperty(l)&&l in Hm)return Vl[n]=i[l];return n}var Um=Ha("animationend"),Vm=Ha("animationiteration"),qm=Ha("animationstart"),Ym=Ha("transitionend"),Gm=new Map,Km="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 Cn(n,i){Gm.set(n,i),c(i,[n])}for(var ql=0;ql<Km.length;ql++){var Yl=Km[ql],Rv=Yl.toLowerCase(),$v=Yl[0].toUpperCase()+Yl.slice(1);Cn(Rv,"on"+$v)}Cn(Um,"onAnimationEnd"),Cn(Vm,"onAnimationIteration"),Cn(qm,"onAnimationStart"),Cn("dblclick","onDoubleClick"),Cn("focusin","onFocus"),Cn("focusout","onBlur"),Cn(Ym,"onTransitionEnd"),d("onMouseEnter",["mouseout","mouseover"]),d("onMouseLeave",["mouseout","mouseover"]),d("onPointerEnter",["pointerout","pointerover"]),d("onPointerLeave",["pointerout","pointerover"]),c("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),c("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),c("onBeforeInput",["compositionend","keypress","textInput","paste"]),c("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),c("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),c("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ti="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(" "),Dv=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ti));function Qm(n,i,l){var m=n.type||"unknown-event";n.currentTarget=l,Ry(m,i,void 0,n),n.currentTarget=null}function Jm(n,i){i=(i&4)!==0;for(var l=0;l<n.length;l++){var m=n[l],f=m.event;m=m.listeners;e:{var w=void 0;if(i)for(var C=m.length-1;0<=C;C--){var O=m[C],Y=O.instance,se=O.currentTarget;if(O=O.listener,Y!==w&&f.isPropagationStopped())break e;Qm(f,O,se),w=Y}else for(C=0;C<m.length;C++){if(O=m[C],Y=O.instance,se=O.currentTarget,O=O.listener,Y!==w&&f.isPropagationStopped())break e;Qm(f,O,se),w=Y}}}if(_a)throw n=Nl,_a=!1,Nl=null,n}function lt(n,i){var l=i[tc];l===void 0&&(l=i[tc]=new Set);var m=n+"__bubble";l.has(m)||(Xm(i,n,2,!1),l.add(m))}function Gl(n,i,l){var m=0;i&&(m|=4),Xm(l,n,m,i)}var Ua="_reactListening"+Math.random().toString(36).slice(2);function Ai(n){if(!n[Ua]){n[Ua]=!0,a.forEach(function(l){l!=="selectionchange"&&(Dv.has(l)||Gl(l,!1,n),Gl(l,!0,n))});var i=n.nodeType===9?n:n.ownerDocument;i===null||i[Ua]||(i[Ua]=!0,Gl("selectionchange",!1,i))}}function Xm(n,i,l,m){switch(bm(i)){case 1:var f=Jy;break;case 4:f=Xy;break;default:f=Al}l=f.bind(null,i,l,n),f=void 0,!kl||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(f=!0),m?f!==void 0?n.addEventListener(i,l,{capture:!0,passive:f}):n.addEventListener(i,l,!0):f!==void 0?n.addEventListener(i,l,{passive:f}):n.addEventListener(i,l,!1)}function Kl(n,i,l,m,f){var w=m;if((i&1)===0&&(i&2)===0&&m!==null)e:for(;;){if(m===null)return;var C=m.tag;if(C===3||C===4){var O=m.stateNode.containerInfo;if(O===f||O.nodeType===8&&O.parentNode===f)break;if(C===4)for(C=m.return;C!==null;){var Y=C.tag;if((Y===3||Y===4)&&(Y=C.stateNode.containerInfo,Y===f||Y.nodeType===8&&Y.parentNode===f))return;C=C.return}for(;O!==null;){if(C=Zn(O),C===null)return;if(Y=C.tag,Y===5||Y===6){m=w=C;continue e}O=O.parentNode}}m=m.return}hi(function(){var se=w,pe=ie(l),xe=[];e:{var me=Gm.get(n);if(me!==void 0){var ke=Ml,Ce=n;switch(n){case"keypress":if(Ba(l)===0)break e;case"keydown":case"keyup":ke=hv;break;case"focusin":Ce="focus",ke=Dl;break;case"focusout":Ce="blur",ke=Dl;break;case"beforeblur":case"afterblur":ke=Dl;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ke=Nm;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ke=tv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ke=xv;break;case Um:case Vm:case qm:ke=sv;break;case Ym:ke=yv;break;case"scroll":ke=Zy;break;case"wheel":ke=wv;break;case"copy":case"cut":case"paste":ke=av;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ke=Sm}var _e=(i&4)!==0,wt=!_e&&n==="scroll",te=_e?me!==null?me+"Capture":null:me;_e=[];for(var K=se,ne;K!==null;){ne=K;var we=ne.stateNode;if(ne.tag===5&&we!==null&&(ne=we,te!==null&&(we=Ft(K,te),we!=null&&_e.push(Pi(K,we,ne)))),wt)break;K=K.return}0<_e.length&&(me=new ke(me,Ce,null,l,pe),xe.push({event:me,listeners:_e}))}}if((i&7)===0){e:{if(me=n==="mouseover"||n==="pointerover",ke=n==="mouseout"||n==="pointerout",me&&l!==Ae&&(Ce=l.relatedTarget||l.fromElement)&&(Zn(Ce)||Ce[on]))break e;if((ke||me)&&(me=pe.window===pe?pe:(me=pe.ownerDocument)?me.defaultView||me.parentWindow:window,ke?(Ce=l.relatedTarget||l.toElement,ke=se,Ce=Ce?Zn(Ce):null,Ce!==null&&(wt=Xn(Ce),Ce!==wt||Ce.tag!==5&&Ce.tag!==6)&&(Ce=null)):(ke=null,Ce=se),ke!==Ce)){if(_e=Nm,we="onMouseLeave",te="onMouseEnter",K="mouse",(n==="pointerout"||n==="pointerover")&&(_e=Sm,we="onPointerLeave",te="onPointerEnter",K="pointer"),wt=ke==null?me:Es(ke),ne=Ce==null?me:Es(Ce),me=new _e(we,K+"leave",ke,l,pe),me.target=wt,me.relatedTarget=ne,we=null,Zn(pe)===se&&(_e=new _e(te,K+"enter",Ce,l,pe),_e.target=ne,_e.relatedTarget=wt,we=_e),wt=we,ke&&Ce)t:{for(_e=ke,te=Ce,K=0,ne=_e;ne;ne=_s(ne))K++;for(ne=0,we=te;we;we=_s(we))ne++;for(;0<K-ne;)_e=_s(_e),K--;for(;0<ne-K;)te=_s(te),ne--;for(;K--;){if(_e===te||te!==null&&_e===te.alternate)break t;_e=_s(_e),te=_s(te)}_e=null}else _e=null;ke!==null&&Zm(xe,me,ke,_e,!1),Ce!==null&&wt!==null&&Zm(xe,wt,Ce,_e,!0)}}e:{if(me=se?Es(se):window,ke=me.nodeName&&me.nodeName.toLowerCase(),ke==="select"||ke==="input"&&me.type==="file")var Ee=_v;else if(Pm(me))if(Mm)Ee=Av;else{Ee=Ev;var $e=Lv}else(ke=me.nodeName)&&ke.toLowerCase()==="input"&&(me.type==="checkbox"||me.type==="radio")&&(Ee=Tv);if(Ee&&(Ee=Ee(n,se))){Im(xe,Ee,l,pe);break e}$e&&$e(n,me,se),n==="focusout"&&($e=me._wrapperState)&&$e.controlled&&me.type==="number"&&ft(me,"number",me.value)}switch($e=se?Es(se):window,n){case"focusin":(Pm($e)||$e.contentEditable==="true")&&(Cs=$e,Hl=se,Ei=null);break;case"focusout":Ei=Hl=Cs=null;break;case"mousedown":Ul=!0;break;case"contextmenu":case"mouseup":case"dragend":Ul=!1,Wm(xe,l,pe);break;case"selectionchange":if(Mv)break;case"keydown":case"keyup":Wm(xe,l,pe)}var De;if(zl)e:{switch(n){case"compositionstart":var Be="onCompositionStart";break e;case"compositionend":Be="onCompositionEnd";break e;case"compositionupdate":Be="onCompositionUpdate";break e}Be=void 0}else Ns?Tm(n,l)&&(Be="onCompositionEnd"):n==="keydown"&&l.keyCode===229&&(Be="onCompositionStart");Be&&(_m&&l.locale!=="ko"&&(Ns||Be!=="onCompositionStart"?Be==="onCompositionEnd"&&Ns&&(De=jm()):(Nn=pe,Il="value"in Nn?Nn.value:Nn.textContent,Ns=!0)),$e=Va(se,Be),0<$e.length&&(Be=new Cm(Be,n,null,l,pe),xe.push({event:Be,listeners:$e}),De?Be.data=De:(De=Am(l),De!==null&&(Be.data=De)))),(De=jv?kv(n,l):Nv(n,l))&&(se=Va(se,"onBeforeInput"),0<se.length&&(pe=new Cm("onBeforeInput","beforeinput",null,l,pe),xe.push({event:pe,listeners:se}),pe.data=De))}Jm(xe,i)})}function Pi(n,i,l){return{instance:n,listener:i,currentTarget:l}}function Va(n,i){for(var l=i+"Capture",m=[];n!==null;){var f=n,w=f.stateNode;f.tag===5&&w!==null&&(f=w,w=Ft(n,l),w!=null&&m.unshift(Pi(n,w,f)),w=Ft(n,i),w!=null&&m.push(Pi(n,w,f))),n=n.return}return m}function _s(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5);return n||null}function Zm(n,i,l,m,f){for(var w=i._reactName,C=[];l!==null&&l!==m;){var O=l,Y=O.alternate,se=O.stateNode;if(Y!==null&&Y===m)break;O.tag===5&&se!==null&&(O=se,f?(Y=Ft(l,w),Y!=null&&C.unshift(Pi(l,Y,O))):f||(Y=Ft(l,w),Y!=null&&C.push(Pi(l,Y,O)))),l=l.return}C.length!==0&&n.push({event:i,listeners:C})}var Bv=/\r\n?/g,zv=/\u0000|\uFFFD/g;function eh(n){return(typeof n=="string"?n:""+n).replace(Bv,`
|
|
38
|
+
`).replace(zv,"")}function qa(n,i,l){if(i=eh(i),eh(n)!==i&&l)throw Error(s(425))}function Ya(){}var Ql=null,Jl=null;function Xl(n,i){return n==="textarea"||n==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var Zl=typeof setTimeout=="function"?setTimeout:void 0,Ov=typeof clearTimeout=="function"?clearTimeout:void 0,th=typeof Promise=="function"?Promise:void 0,Fv=typeof queueMicrotask=="function"?queueMicrotask:typeof th<"u"?function(n){return th.resolve(null).then(n).catch(Wv)}:Zl;function Wv(n){setTimeout(function(){throw n})}function ec(n,i){var l=i,m=0;do{var f=l.nextSibling;if(n.removeChild(l),f&&f.nodeType===8)if(l=f.data,l==="/$"){if(m===0){n.removeChild(f),ji(i);return}m--}else l!=="$"&&l!=="$?"&&l!=="$!"||m++;l=f}while(l);ji(i)}function Sn(n){for(;n!=null;n=n.nextSibling){var i=n.nodeType;if(i===1||i===3)break;if(i===8){if(i=n.data,i==="$"||i==="$!"||i==="$?")break;if(i==="/$")return null}}return n}function rh(n){n=n.previousSibling;for(var i=0;n;){if(n.nodeType===8){var l=n.data;if(l==="$"||l==="$!"||l==="$?"){if(i===0)return n;i--}else l==="/$"&&i++}n=n.previousSibling}return null}var Ls=Math.random().toString(36).slice(2),Yr="__reactFiber$"+Ls,Ii="__reactProps$"+Ls,on="__reactContainer$"+Ls,tc="__reactEvents$"+Ls,Hv="__reactListeners$"+Ls,Uv="__reactHandles$"+Ls;function Zn(n){var i=n[Yr];if(i)return i;for(var l=n.parentNode;l;){if(i=l[on]||l[Yr]){if(l=i.alternate,i.child!==null||l!==null&&l.child!==null)for(n=rh(n);n!==null;){if(l=n[Yr])return l;n=rh(n)}return i}n=l,l=n.parentNode}return null}function Mi(n){return n=n[Yr]||n[on],!n||n.tag!==5&&n.tag!==6&&n.tag!==13&&n.tag!==3?null:n}function Es(n){if(n.tag===5||n.tag===6)return n.stateNode;throw Error(s(33))}function Ga(n){return n[Ii]||null}var rc=[],Ts=-1;function _n(n){return{current:n}}function ct(n){0>Ts||(n.current=rc[Ts],rc[Ts]=null,Ts--)}function st(n,i){Ts++,rc[Ts]=n.current,n.current=i}var Ln={},qt=_n(Ln),lr=_n(!1),es=Ln;function As(n,i){var l=n.type.contextTypes;if(!l)return Ln;var m=n.stateNode;if(m&&m.__reactInternalMemoizedUnmaskedChildContext===i)return m.__reactInternalMemoizedMaskedChildContext;var f={},w;for(w in l)f[w]=i[w];return m&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=i,n.__reactInternalMemoizedMaskedChildContext=f),f}function cr(n){return n=n.childContextTypes,n!=null}function Ka(){ct(lr),ct(qt)}function nh(n,i,l){if(qt.current!==Ln)throw Error(s(168));st(qt,i),st(lr,l)}function sh(n,i,l){var m=n.stateNode;if(i=i.childContextTypes,typeof m.getChildContext!="function")return l;m=m.getChildContext();for(var f in m)if(!(f in i))throw Error(s(108,ge(n)||"Unknown",f));return E({},l,m)}function Qa(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||Ln,es=qt.current,st(qt,n),st(lr,lr.current),!0}function ih(n,i,l){var m=n.stateNode;if(!m)throw Error(s(169));l?(n=sh(n,i,es),m.__reactInternalMemoizedMergedChildContext=n,ct(lr),ct(qt),st(qt,n)):ct(lr),st(lr,l)}var ln=null,Ja=!1,nc=!1;function ah(n){ln===null?ln=[n]:ln.push(n)}function Vv(n){Ja=!0,ah(n)}function En(){if(!nc&&ln!==null){nc=!0;var n=0,i=nt;try{var l=ln;for(nt=1;n<l.length;n++){var m=l[n];do m=m(!0);while(m!==null)}ln=null,Ja=!1}catch(f){throw ln!==null&&(ln=ln.slice(n+1)),lm(Cl,En),f}finally{nt=i,nc=!1}}return null}var Ps=[],Is=0,Xa=null,Za=0,Er=[],Tr=0,ts=null,cn=1,dn="";function rs(n,i){Ps[Is++]=Za,Ps[Is++]=Xa,Xa=n,Za=i}function oh(n,i,l){Er[Tr++]=cn,Er[Tr++]=dn,Er[Tr++]=ts,ts=n;var m=cn;n=dn;var f=32-Br(m)-1;m&=~(1<<f),l+=1;var w=32-Br(i)+f;if(30<w){var C=f-f%5;w=(m&(1<<C)-1).toString(32),m>>=C,f-=C,cn=1<<32-Br(i)+f|l<<f|m,dn=w+n}else cn=1<<w|l<<f|m,dn=n}function sc(n){n.return!==null&&(rs(n,1),oh(n,1,0))}function ic(n){for(;n===Xa;)Xa=Ps[--Is],Ps[Is]=null,Za=Ps[--Is],Ps[Is]=null;for(;n===ts;)ts=Er[--Tr],Er[Tr]=null,dn=Er[--Tr],Er[Tr]=null,cn=Er[--Tr],Er[Tr]=null}var br=null,jr=null,ut=!1,Or=null;function lh(n,i){var l=Mr(5,null,null,0);l.elementType="DELETED",l.stateNode=i,l.return=n,i=n.deletions,i===null?(n.deletions=[l],n.flags|=16):i.push(l)}function ch(n,i){switch(n.tag){case 5:var l=n.type;return i=i.nodeType!==1||l.toLowerCase()!==i.nodeName.toLowerCase()?null:i,i!==null?(n.stateNode=i,br=n,jr=Sn(i.firstChild),!0):!1;case 6:return i=n.pendingProps===""||i.nodeType!==3?null:i,i!==null?(n.stateNode=i,br=n,jr=null,!0):!1;case 13:return i=i.nodeType!==8?null:i,i!==null?(l=ts!==null?{id:cn,overflow:dn}:null,n.memoizedState={dehydrated:i,treeContext:l,retryLane:1073741824},l=Mr(18,null,null,0),l.stateNode=i,l.return=n,n.child=l,br=n,jr=null,!0):!1;default:return!1}}function ac(n){return(n.mode&1)!==0&&(n.flags&128)===0}function oc(n){if(ut){var i=jr;if(i){var l=i;if(!ch(n,i)){if(ac(n))throw Error(s(418));i=Sn(l.nextSibling);var m=br;i&&ch(n,i)?lh(m,l):(n.flags=n.flags&-4097|2,ut=!1,br=n)}}else{if(ac(n))throw Error(s(418));n.flags=n.flags&-4097|2,ut=!1,br=n}}}function dh(n){for(n=n.return;n!==null&&n.tag!==5&&n.tag!==3&&n.tag!==13;)n=n.return;br=n}function eo(n){if(n!==br)return!1;if(!ut)return dh(n),ut=!0,!1;var i;if((i=n.tag!==3)&&!(i=n.tag!==5)&&(i=n.type,i=i!=="head"&&i!=="body"&&!Xl(n.type,n.memoizedProps)),i&&(i=jr)){if(ac(n))throw uh(),Error(s(418));for(;i;)lh(n,i),i=Sn(i.nextSibling)}if(dh(n),n.tag===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(s(317));e:{for(n=n.nextSibling,i=0;n;){if(n.nodeType===8){var l=n.data;if(l==="/$"){if(i===0){jr=Sn(n.nextSibling);break e}i--}else l!=="$"&&l!=="$!"&&l!=="$?"||i++}n=n.nextSibling}jr=null}}else jr=br?Sn(n.stateNode.nextSibling):null;return!0}function uh(){for(var n=jr;n;)n=Sn(n.nextSibling)}function Ms(){jr=br=null,ut=!1}function lc(n){Or===null?Or=[n]:Or.push(n)}var qv=_.ReactCurrentBatchConfig;function Ri(n,i,l){if(n=l.ref,n!==null&&typeof n!="function"&&typeof n!="object"){if(l._owner){if(l=l._owner,l){if(l.tag!==1)throw Error(s(309));var m=l.stateNode}if(!m)throw Error(s(147,n));var f=m,w=""+n;return i!==null&&i.ref!==null&&typeof i.ref=="function"&&i.ref._stringRef===w?i.ref:(i=function(C){var O=f.refs;C===null?delete O[w]:O[w]=C},i._stringRef=w,i)}if(typeof n!="string")throw Error(s(284));if(!l._owner)throw Error(s(290,n))}return n}function to(n,i){throw n=Object.prototype.toString.call(i),Error(s(31,n==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":n))}function mh(n){var i=n._init;return i(n._payload)}function hh(n){function i(te,K){if(n){var ne=te.deletions;ne===null?(te.deletions=[K],te.flags|=16):ne.push(K)}}function l(te,K){if(!n)return null;for(;K!==null;)i(te,K),K=K.sibling;return null}function m(te,K){for(te=new Map;K!==null;)K.key!==null?te.set(K.key,K):te.set(K.index,K),K=K.sibling;return te}function f(te,K){return te=Dn(te,K),te.index=0,te.sibling=null,te}function w(te,K,ne){return te.index=ne,n?(ne=te.alternate,ne!==null?(ne=ne.index,ne<K?(te.flags|=2,K):ne):(te.flags|=2,K)):(te.flags|=1048576,K)}function C(te){return n&&te.alternate===null&&(te.flags|=2),te}function O(te,K,ne,we){return K===null||K.tag!==6?(K=Zc(ne,te.mode,we),K.return=te,K):(K=f(K,ne),K.return=te,K)}function Y(te,K,ne,we){var Ee=ne.type;return Ee===$?pe(te,K,ne.props.children,we,ne.key):K!==null&&(K.elementType===Ee||typeof Ee=="object"&&Ee!==null&&Ee.$$typeof===W&&mh(Ee)===K.type)?(we=f(K,ne.props),we.ref=Ri(te,K,ne),we.return=te,we):(we=So(ne.type,ne.key,ne.props,null,te.mode,we),we.ref=Ri(te,K,ne),we.return=te,we)}function se(te,K,ne,we){return K===null||K.tag!==4||K.stateNode.containerInfo!==ne.containerInfo||K.stateNode.implementation!==ne.implementation?(K=ed(ne,te.mode,we),K.return=te,K):(K=f(K,ne.children||[]),K.return=te,K)}function pe(te,K,ne,we,Ee){return K===null||K.tag!==7?(K=ds(ne,te.mode,we,Ee),K.return=te,K):(K=f(K,ne),K.return=te,K)}function xe(te,K,ne){if(typeof K=="string"&&K!==""||typeof K=="number")return K=Zc(""+K,te.mode,ne),K.return=te,K;if(typeof K=="object"&&K!==null){switch(K.$$typeof){case z:return ne=So(K.type,K.key,K.props,null,te.mode,ne),ne.ref=Ri(te,null,K),ne.return=te,ne;case P:return K=ed(K,te.mode,ne),K.return=te,K;case W:var we=K._init;return xe(te,we(K._payload),ne)}if(Rt(K)||de(K))return K=ds(K,te.mode,ne,null),K.return=te,K;to(te,K)}return null}function me(te,K,ne,we){var Ee=K!==null?K.key:null;if(typeof ne=="string"&&ne!==""||typeof ne=="number")return Ee!==null?null:O(te,K,""+ne,we);if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case z:return ne.key===Ee?Y(te,K,ne,we):null;case P:return ne.key===Ee?se(te,K,ne,we):null;case W:return Ee=ne._init,me(te,K,Ee(ne._payload),we)}if(Rt(ne)||de(ne))return Ee!==null?null:pe(te,K,ne,we,null);to(te,ne)}return null}function ke(te,K,ne,we,Ee){if(typeof we=="string"&&we!==""||typeof we=="number")return te=te.get(ne)||null,O(K,te,""+we,Ee);if(typeof we=="object"&&we!==null){switch(we.$$typeof){case z:return te=te.get(we.key===null?ne:we.key)||null,Y(K,te,we,Ee);case P:return te=te.get(we.key===null?ne:we.key)||null,se(K,te,we,Ee);case W:var $e=we._init;return ke(te,K,ne,$e(we._payload),Ee)}if(Rt(we)||de(we))return te=te.get(ne)||null,pe(K,te,we,Ee,null);to(K,we)}return null}function Ce(te,K,ne,we){for(var Ee=null,$e=null,De=K,Be=K=0,zt=null;De!==null&&Be<ne.length;Be++){De.index>Be?(zt=De,De=null):zt=De.sibling;var Qe=me(te,De,ne[Be],we);if(Qe===null){De===null&&(De=zt);break}n&&De&&Qe.alternate===null&&i(te,De),K=w(Qe,K,Be),$e===null?Ee=Qe:$e.sibling=Qe,$e=Qe,De=zt}if(Be===ne.length)return l(te,De),ut&&rs(te,Be),Ee;if(De===null){for(;Be<ne.length;Be++)De=xe(te,ne[Be],we),De!==null&&(K=w(De,K,Be),$e===null?Ee=De:$e.sibling=De,$e=De);return ut&&rs(te,Be),Ee}for(De=m(te,De);Be<ne.length;Be++)zt=ke(De,te,Be,ne[Be],we),zt!==null&&(n&&zt.alternate!==null&&De.delete(zt.key===null?Be:zt.key),K=w(zt,K,Be),$e===null?Ee=zt:$e.sibling=zt,$e=zt);return n&&De.forEach(function(Bn){return i(te,Bn)}),ut&&rs(te,Be),Ee}function _e(te,K,ne,we){var Ee=de(ne);if(typeof Ee!="function")throw Error(s(150));if(ne=Ee.call(ne),ne==null)throw Error(s(151));for(var $e=Ee=null,De=K,Be=K=0,zt=null,Qe=ne.next();De!==null&&!Qe.done;Be++,Qe=ne.next()){De.index>Be?(zt=De,De=null):zt=De.sibling;var Bn=me(te,De,Qe.value,we);if(Bn===null){De===null&&(De=zt);break}n&&De&&Bn.alternate===null&&i(te,De),K=w(Bn,K,Be),$e===null?Ee=Bn:$e.sibling=Bn,$e=Bn,De=zt}if(Qe.done)return l(te,De),ut&&rs(te,Be),Ee;if(De===null){for(;!Qe.done;Be++,Qe=ne.next())Qe=xe(te,Qe.value,we),Qe!==null&&(K=w(Qe,K,Be),$e===null?Ee=Qe:$e.sibling=Qe,$e=Qe);return ut&&rs(te,Be),Ee}for(De=m(te,De);!Qe.done;Be++,Qe=ne.next())Qe=ke(De,te,Be,Qe.value,we),Qe!==null&&(n&&Qe.alternate!==null&&De.delete(Qe.key===null?Be:Qe.key),K=w(Qe,K,Be),$e===null?Ee=Qe:$e.sibling=Qe,$e=Qe);return n&&De.forEach(function(C2){return i(te,C2)}),ut&&rs(te,Be),Ee}function wt(te,K,ne,we){if(typeof ne=="object"&&ne!==null&&ne.type===$&&ne.key===null&&(ne=ne.props.children),typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case z:e:{for(var Ee=ne.key,$e=K;$e!==null;){if($e.key===Ee){if(Ee=ne.type,Ee===$){if($e.tag===7){l(te,$e.sibling),K=f($e,ne.props.children),K.return=te,te=K;break e}}else if($e.elementType===Ee||typeof Ee=="object"&&Ee!==null&&Ee.$$typeof===W&&mh(Ee)===$e.type){l(te,$e.sibling),K=f($e,ne.props),K.ref=Ri(te,$e,ne),K.return=te,te=K;break e}l(te,$e);break}else i(te,$e);$e=$e.sibling}ne.type===$?(K=ds(ne.props.children,te.mode,we,ne.key),K.return=te,te=K):(we=So(ne.type,ne.key,ne.props,null,te.mode,we),we.ref=Ri(te,K,ne),we.return=te,te=we)}return C(te);case P:e:{for($e=ne.key;K!==null;){if(K.key===$e)if(K.tag===4&&K.stateNode.containerInfo===ne.containerInfo&&K.stateNode.implementation===ne.implementation){l(te,K.sibling),K=f(K,ne.children||[]),K.return=te,te=K;break e}else{l(te,K);break}else i(te,K);K=K.sibling}K=ed(ne,te.mode,we),K.return=te,te=K}return C(te);case W:return $e=ne._init,wt(te,K,$e(ne._payload),we)}if(Rt(ne))return Ce(te,K,ne,we);if(de(ne))return _e(te,K,ne,we);to(te,ne)}return typeof ne=="string"&&ne!==""||typeof ne=="number"?(ne=""+ne,K!==null&&K.tag===6?(l(te,K.sibling),K=f(K,ne),K.return=te,te=K):(l(te,K),K=Zc(ne,te.mode,we),K.return=te,te=K),C(te)):l(te,K)}return wt}var Rs=hh(!0),ph=hh(!1),ro=_n(null),no=null,$s=null,cc=null;function dc(){cc=$s=no=null}function uc(n){var i=ro.current;ct(ro),n._currentValue=i}function mc(n,i,l){for(;n!==null;){var m=n.alternate;if((n.childLanes&i)!==i?(n.childLanes|=i,m!==null&&(m.childLanes|=i)):m!==null&&(m.childLanes&i)!==i&&(m.childLanes|=i),n===l)break;n=n.return}}function Ds(n,i){no=n,cc=$s=null,n=n.dependencies,n!==null&&n.firstContext!==null&&((n.lanes&i)!==0&&(dr=!0),n.firstContext=null)}function Ar(n){var i=n._currentValue;if(cc!==n)if(n={context:n,memoizedValue:i,next:null},$s===null){if(no===null)throw Error(s(308));$s=n,no.dependencies={lanes:0,firstContext:n}}else $s=$s.next=n;return i}var ns=null;function hc(n){ns===null?ns=[n]:ns.push(n)}function fh(n,i,l,m){var f=i.interleaved;return f===null?(l.next=l,hc(i)):(l.next=f.next,f.next=l),i.interleaved=l,un(n,m)}function un(n,i){n.lanes|=i;var l=n.alternate;for(l!==null&&(l.lanes|=i),l=n,n=n.return;n!==null;)n.childLanes|=i,l=n.alternate,l!==null&&(l.childLanes|=i),l=n,n=n.return;return l.tag===3?l.stateNode:null}var Tn=!1;function pc(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function xh(n,i){n=n.updateQueue,i.updateQueue===n&&(i.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,effects:n.effects})}function mn(n,i){return{eventTime:n,lane:i,tag:0,payload:null,callback:null,next:null}}function An(n,i,l){var m=n.updateQueue;if(m===null)return null;if(m=m.shared,(Ge&2)!==0){var f=m.pending;return f===null?i.next=i:(i.next=f.next,f.next=i),m.pending=i,un(n,l)}return f=m.interleaved,f===null?(i.next=i,hc(m)):(i.next=f.next,f.next=i),m.interleaved=i,un(n,l)}function so(n,i,l){if(i=i.updateQueue,i!==null&&(i=i.shared,(l&4194240)!==0)){var m=i.lanes;m&=n.pendingLanes,l|=m,i.lanes=l,Ll(n,l)}}function gh(n,i){var l=n.updateQueue,m=n.alternate;if(m!==null&&(m=m.updateQueue,l===m)){var f=null,w=null;if(l=l.firstBaseUpdate,l!==null){do{var C={eventTime:l.eventTime,lane:l.lane,tag:l.tag,payload:l.payload,callback:l.callback,next:null};w===null?f=w=C:w=w.next=C,l=l.next}while(l!==null);w===null?f=w=i:w=w.next=i}else f=w=i;l={baseState:m.baseState,firstBaseUpdate:f,lastBaseUpdate:w,shared:m.shared,effects:m.effects},n.updateQueue=l;return}n=l.lastBaseUpdate,n===null?l.firstBaseUpdate=i:n.next=i,l.lastBaseUpdate=i}function io(n,i,l,m){var f=n.updateQueue;Tn=!1;var w=f.firstBaseUpdate,C=f.lastBaseUpdate,O=f.shared.pending;if(O!==null){f.shared.pending=null;var Y=O,se=Y.next;Y.next=null,C===null?w=se:C.next=se,C=Y;var pe=n.alternate;pe!==null&&(pe=pe.updateQueue,O=pe.lastBaseUpdate,O!==C&&(O===null?pe.firstBaseUpdate=se:O.next=se,pe.lastBaseUpdate=Y))}if(w!==null){var xe=f.baseState;C=0,pe=se=Y=null,O=w;do{var me=O.lane,ke=O.eventTime;if((m&me)===me){pe!==null&&(pe=pe.next={eventTime:ke,lane:0,tag:O.tag,payload:O.payload,callback:O.callback,next:null});e:{var Ce=n,_e=O;switch(me=i,ke=l,_e.tag){case 1:if(Ce=_e.payload,typeof Ce=="function"){xe=Ce.call(ke,xe,me);break e}xe=Ce;break e;case 3:Ce.flags=Ce.flags&-65537|128;case 0:if(Ce=_e.payload,me=typeof Ce=="function"?Ce.call(ke,xe,me):Ce,me==null)break e;xe=E({},xe,me);break e;case 2:Tn=!0}}O.callback!==null&&O.lane!==0&&(n.flags|=64,me=f.effects,me===null?f.effects=[O]:me.push(O))}else ke={eventTime:ke,lane:me,tag:O.tag,payload:O.payload,callback:O.callback,next:null},pe===null?(se=pe=ke,Y=xe):pe=pe.next=ke,C|=me;if(O=O.next,O===null){if(O=f.shared.pending,O===null)break;me=O,O=me.next,me.next=null,f.lastBaseUpdate=me,f.shared.pending=null}}while(!0);if(pe===null&&(Y=xe),f.baseState=Y,f.firstBaseUpdate=se,f.lastBaseUpdate=pe,i=f.shared.interleaved,i!==null){f=i;do C|=f.lane,f=f.next;while(f!==i)}else w===null&&(f.shared.lanes=0);as|=C,n.lanes=C,n.memoizedState=xe}}function yh(n,i,l){if(n=i.effects,i.effects=null,n!==null)for(i=0;i<n.length;i++){var m=n[i],f=m.callback;if(f!==null){if(m.callback=null,m=l,typeof f!="function")throw Error(s(191,f));f.call(m)}}}var $i={},Gr=_n($i),Di=_n($i),Bi=_n($i);function ss(n){if(n===$i)throw Error(s(174));return n}function fc(n,i){switch(st(Bi,i),st(Di,n),st(Gr,$i),n=i.nodeType,n){case 9:case 11:i=(i=i.documentElement)?i.namespaceURI:Q(null,"");break;default:n=n===8?i.parentNode:i,i=n.namespaceURI||null,n=n.tagName,i=Q(i,n)}ct(Gr),st(Gr,i)}function Bs(){ct(Gr),ct(Di),ct(Bi)}function vh(n){ss(Bi.current);var i=ss(Gr.current),l=Q(i,n.type);i!==l&&(st(Di,n),st(Gr,l))}function xc(n){Di.current===n&&(ct(Gr),ct(Di))}var ht=_n(0);function ao(n){for(var i=n;i!==null;){if(i.tag===13){var l=i.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||l.data==="$?"||l.data==="$!"))return i}else if(i.tag===19&&i.memoizedProps.revealOrder!==void 0){if((i.flags&128)!==0)return i}else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===n)break;for(;i.sibling===null;){if(i.return===null||i.return===n)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var gc=[];function yc(){for(var n=0;n<gc.length;n++)gc[n]._workInProgressVersionPrimary=null;gc.length=0}var oo=_.ReactCurrentDispatcher,vc=_.ReactCurrentBatchConfig,is=0,pt=null,Tt=null,Dt=null,lo=!1,zi=!1,Oi=0,Yv=0;function Yt(){throw Error(s(321))}function wc(n,i){if(i===null)return!1;for(var l=0;l<i.length&&l<n.length;l++)if(!zr(n[l],i[l]))return!1;return!0}function bc(n,i,l,m,f,w){if(is=w,pt=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,oo.current=n===null||n.memoizedState===null?Jv:Xv,n=l(m,f),zi){w=0;do{if(zi=!1,Oi=0,25<=w)throw Error(s(301));w+=1,Dt=Tt=null,i.updateQueue=null,oo.current=Zv,n=l(m,f)}while(zi)}if(oo.current=mo,i=Tt!==null&&Tt.next!==null,is=0,Dt=Tt=pt=null,lo=!1,i)throw Error(s(300));return n}function jc(){var n=Oi!==0;return Oi=0,n}function Kr(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Dt===null?pt.memoizedState=Dt=n:Dt=Dt.next=n,Dt}function Pr(){if(Tt===null){var n=pt.alternate;n=n!==null?n.memoizedState:null}else n=Tt.next;var i=Dt===null?pt.memoizedState:Dt.next;if(i!==null)Dt=i,Tt=n;else{if(n===null)throw Error(s(310));Tt=n,n={memoizedState:Tt.memoizedState,baseState:Tt.baseState,baseQueue:Tt.baseQueue,queue:Tt.queue,next:null},Dt===null?pt.memoizedState=Dt=n:Dt=Dt.next=n}return Dt}function Fi(n,i){return typeof i=="function"?i(n):i}function kc(n){var i=Pr(),l=i.queue;if(l===null)throw Error(s(311));l.lastRenderedReducer=n;var m=Tt,f=m.baseQueue,w=l.pending;if(w!==null){if(f!==null){var C=f.next;f.next=w.next,w.next=C}m.baseQueue=f=w,l.pending=null}if(f!==null){w=f.next,m=m.baseState;var O=C=null,Y=null,se=w;do{var pe=se.lane;if((is&pe)===pe)Y!==null&&(Y=Y.next={lane:0,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null}),m=se.hasEagerState?se.eagerState:n(m,se.action);else{var xe={lane:pe,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null};Y===null?(O=Y=xe,C=m):Y=Y.next=xe,pt.lanes|=pe,as|=pe}se=se.next}while(se!==null&&se!==w);Y===null?C=m:Y.next=O,zr(m,i.memoizedState)||(dr=!0),i.memoizedState=m,i.baseState=C,i.baseQueue=Y,l.lastRenderedState=m}if(n=l.interleaved,n!==null){f=n;do w=f.lane,pt.lanes|=w,as|=w,f=f.next;while(f!==n)}else f===null&&(l.lanes=0);return[i.memoizedState,l.dispatch]}function Nc(n){var i=Pr(),l=i.queue;if(l===null)throw Error(s(311));l.lastRenderedReducer=n;var m=l.dispatch,f=l.pending,w=i.memoizedState;if(f!==null){l.pending=null;var C=f=f.next;do w=n(w,C.action),C=C.next;while(C!==f);zr(w,i.memoizedState)||(dr=!0),i.memoizedState=w,i.baseQueue===null&&(i.baseState=w),l.lastRenderedState=w}return[w,m]}function wh(){}function bh(n,i){var l=pt,m=Pr(),f=i(),w=!zr(m.memoizedState,f);if(w&&(m.memoizedState=f,dr=!0),m=m.queue,Cc(Nh.bind(null,l,m,n),[n]),m.getSnapshot!==i||w||Dt!==null&&Dt.memoizedState.tag&1){if(l.flags|=2048,Wi(9,kh.bind(null,l,m,f,i),void 0,null),Bt===null)throw Error(s(349));(is&30)!==0||jh(l,i,f)}return f}function jh(n,i,l){n.flags|=16384,n={getSnapshot:i,value:l},i=pt.updateQueue,i===null?(i={lastEffect:null,stores:null},pt.updateQueue=i,i.stores=[n]):(l=i.stores,l===null?i.stores=[n]:l.push(n))}function kh(n,i,l,m){i.value=l,i.getSnapshot=m,Ch(i)&&Sh(n)}function Nh(n,i,l){return l(function(){Ch(i)&&Sh(n)})}function Ch(n){var i=n.getSnapshot;n=n.value;try{var l=i();return!zr(n,l)}catch{return!0}}function Sh(n){var i=un(n,1);i!==null&&Ur(i,n,1,-1)}function _h(n){var i=Kr();return typeof n=="function"&&(n=n()),i.memoizedState=i.baseState=n,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Fi,lastRenderedState:n},i.queue=n,n=n.dispatch=Qv.bind(null,pt,n),[i.memoizedState,n]}function Wi(n,i,l,m){return n={tag:n,create:i,destroy:l,deps:m,next:null},i=pt.updateQueue,i===null?(i={lastEffect:null,stores:null},pt.updateQueue=i,i.lastEffect=n.next=n):(l=i.lastEffect,l===null?i.lastEffect=n.next=n:(m=l.next,l.next=n,n.next=m,i.lastEffect=n)),n}function Lh(){return Pr().memoizedState}function co(n,i,l,m){var f=Kr();pt.flags|=n,f.memoizedState=Wi(1|i,l,void 0,m===void 0?null:m)}function uo(n,i,l,m){var f=Pr();m=m===void 0?null:m;var w=void 0;if(Tt!==null){var C=Tt.memoizedState;if(w=C.destroy,m!==null&&wc(m,C.deps)){f.memoizedState=Wi(i,l,w,m);return}}pt.flags|=n,f.memoizedState=Wi(1|i,l,w,m)}function Eh(n,i){return co(8390656,8,n,i)}function Cc(n,i){return uo(2048,8,n,i)}function Th(n,i){return uo(4,2,n,i)}function Ah(n,i){return uo(4,4,n,i)}function Ph(n,i){if(typeof i=="function")return n=n(),i(n),function(){i(null)};if(i!=null)return n=n(),i.current=n,function(){i.current=null}}function Ih(n,i,l){return l=l!=null?l.concat([n]):null,uo(4,4,Ph.bind(null,i,n),l)}function Sc(){}function Mh(n,i){var l=Pr();i=i===void 0?null:i;var m=l.memoizedState;return m!==null&&i!==null&&wc(i,m[1])?m[0]:(l.memoizedState=[n,i],n)}function Rh(n,i){var l=Pr();i=i===void 0?null:i;var m=l.memoizedState;return m!==null&&i!==null&&wc(i,m[1])?m[0]:(n=n(),l.memoizedState=[n,i],n)}function $h(n,i,l){return(is&21)===0?(n.baseState&&(n.baseState=!1,dr=!0),n.memoizedState=l):(zr(l,i)||(l=mm(),pt.lanes|=l,as|=l,n.baseState=!0),i)}function Gv(n,i){var l=nt;nt=l!==0&&4>l?l:4,n(!0);var m=vc.transition;vc.transition={};try{n(!1),i()}finally{nt=l,vc.transition=m}}function Dh(){return Pr().memoizedState}function Kv(n,i,l){var m=Rn(n);if(l={lane:m,action:l,hasEagerState:!1,eagerState:null,next:null},Bh(n))zh(i,l);else if(l=fh(n,i,l,m),l!==null){var f=rr();Ur(l,n,m,f),Oh(l,i,m)}}function Qv(n,i,l){var m=Rn(n),f={lane:m,action:l,hasEagerState:!1,eagerState:null,next:null};if(Bh(n))zh(i,f);else{var w=n.alternate;if(n.lanes===0&&(w===null||w.lanes===0)&&(w=i.lastRenderedReducer,w!==null))try{var C=i.lastRenderedState,O=w(C,l);if(f.hasEagerState=!0,f.eagerState=O,zr(O,C)){var Y=i.interleaved;Y===null?(f.next=f,hc(i)):(f.next=Y.next,Y.next=f),i.interleaved=f;return}}catch{}finally{}l=fh(n,i,f,m),l!==null&&(f=rr(),Ur(l,n,m,f),Oh(l,i,m))}}function Bh(n){var i=n.alternate;return n===pt||i!==null&&i===pt}function zh(n,i){zi=lo=!0;var l=n.pending;l===null?i.next=i:(i.next=l.next,l.next=i),n.pending=i}function Oh(n,i,l){if((l&4194240)!==0){var m=i.lanes;m&=n.pendingLanes,l|=m,i.lanes=l,Ll(n,l)}}var mo={readContext:Ar,useCallback:Yt,useContext:Yt,useEffect:Yt,useImperativeHandle:Yt,useInsertionEffect:Yt,useLayoutEffect:Yt,useMemo:Yt,useReducer:Yt,useRef:Yt,useState:Yt,useDebugValue:Yt,useDeferredValue:Yt,useTransition:Yt,useMutableSource:Yt,useSyncExternalStore:Yt,useId:Yt,unstable_isNewReconciler:!1},Jv={readContext:Ar,useCallback:function(n,i){return Kr().memoizedState=[n,i===void 0?null:i],n},useContext:Ar,useEffect:Eh,useImperativeHandle:function(n,i,l){return l=l!=null?l.concat([n]):null,co(4194308,4,Ph.bind(null,i,n),l)},useLayoutEffect:function(n,i){return co(4194308,4,n,i)},useInsertionEffect:function(n,i){return co(4,2,n,i)},useMemo:function(n,i){var l=Kr();return i=i===void 0?null:i,n=n(),l.memoizedState=[n,i],n},useReducer:function(n,i,l){var m=Kr();return i=l!==void 0?l(i):i,m.memoizedState=m.baseState=i,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:i},m.queue=n,n=n.dispatch=Kv.bind(null,pt,n),[m.memoizedState,n]},useRef:function(n){var i=Kr();return n={current:n},i.memoizedState=n},useState:_h,useDebugValue:Sc,useDeferredValue:function(n){return Kr().memoizedState=n},useTransition:function(){var n=_h(!1),i=n[0];return n=Gv.bind(null,n[1]),Kr().memoizedState=n,[i,n]},useMutableSource:function(){},useSyncExternalStore:function(n,i,l){var m=pt,f=Kr();if(ut){if(l===void 0)throw Error(s(407));l=l()}else{if(l=i(),Bt===null)throw Error(s(349));(is&30)!==0||jh(m,i,l)}f.memoizedState=l;var w={value:l,getSnapshot:i};return f.queue=w,Eh(Nh.bind(null,m,w,n),[n]),m.flags|=2048,Wi(9,kh.bind(null,m,w,l,i),void 0,null),l},useId:function(){var n=Kr(),i=Bt.identifierPrefix;if(ut){var l=dn,m=cn;l=(m&~(1<<32-Br(m)-1)).toString(32)+l,i=":"+i+"R"+l,l=Oi++,0<l&&(i+="H"+l.toString(32)),i+=":"}else l=Yv++,i=":"+i+"r"+l.toString(32)+":";return n.memoizedState=i},unstable_isNewReconciler:!1},Xv={readContext:Ar,useCallback:Mh,useContext:Ar,useEffect:Cc,useImperativeHandle:Ih,useInsertionEffect:Th,useLayoutEffect:Ah,useMemo:Rh,useReducer:kc,useRef:Lh,useState:function(){return kc(Fi)},useDebugValue:Sc,useDeferredValue:function(n){var i=Pr();return $h(i,Tt.memoizedState,n)},useTransition:function(){var n=kc(Fi)[0],i=Pr().memoizedState;return[n,i]},useMutableSource:wh,useSyncExternalStore:bh,useId:Dh,unstable_isNewReconciler:!1},Zv={readContext:Ar,useCallback:Mh,useContext:Ar,useEffect:Cc,useImperativeHandle:Ih,useInsertionEffect:Th,useLayoutEffect:Ah,useMemo:Rh,useReducer:Nc,useRef:Lh,useState:function(){return Nc(Fi)},useDebugValue:Sc,useDeferredValue:function(n){var i=Pr();return Tt===null?i.memoizedState=n:$h(i,Tt.memoizedState,n)},useTransition:function(){var n=Nc(Fi)[0],i=Pr().memoizedState;return[n,i]},useMutableSource:wh,useSyncExternalStore:bh,useId:Dh,unstable_isNewReconciler:!1};function Fr(n,i){if(n&&n.defaultProps){i=E({},i),n=n.defaultProps;for(var l in n)i[l]===void 0&&(i[l]=n[l]);return i}return i}function _c(n,i,l,m){i=n.memoizedState,l=l(m,i),l=l==null?i:E({},i,l),n.memoizedState=l,n.lanes===0&&(n.updateQueue.baseState=l)}var ho={isMounted:function(n){return(n=n._reactInternals)?Xn(n)===n:!1},enqueueSetState:function(n,i,l){n=n._reactInternals;var m=rr(),f=Rn(n),w=mn(m,f);w.payload=i,l!=null&&(w.callback=l),i=An(n,w,f),i!==null&&(Ur(i,n,f,m),so(i,n,f))},enqueueReplaceState:function(n,i,l){n=n._reactInternals;var m=rr(),f=Rn(n),w=mn(m,f);w.tag=1,w.payload=i,l!=null&&(w.callback=l),i=An(n,w,f),i!==null&&(Ur(i,n,f,m),so(i,n,f))},enqueueForceUpdate:function(n,i){n=n._reactInternals;var l=rr(),m=Rn(n),f=mn(l,m);f.tag=2,i!=null&&(f.callback=i),i=An(n,f,m),i!==null&&(Ur(i,n,m,l),so(i,n,m))}};function Fh(n,i,l,m,f,w,C){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(m,w,C):i.prototype&&i.prototype.isPureReactComponent?!Li(l,m)||!Li(f,w):!0}function Wh(n,i,l){var m=!1,f=Ln,w=i.contextType;return typeof w=="object"&&w!==null?w=Ar(w):(f=cr(i)?es:qt.current,m=i.contextTypes,w=(m=m!=null)?As(n,f):Ln),i=new i(l,w),n.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,i.updater=ho,n.stateNode=i,i._reactInternals=n,m&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=f,n.__reactInternalMemoizedMaskedChildContext=w),i}function Hh(n,i,l,m){n=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(l,m),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(l,m),i.state!==n&&ho.enqueueReplaceState(i,i.state,null)}function Lc(n,i,l,m){var f=n.stateNode;f.props=l,f.state=n.memoizedState,f.refs={},pc(n);var w=i.contextType;typeof w=="object"&&w!==null?f.context=Ar(w):(w=cr(i)?es:qt.current,f.context=As(n,w)),f.state=n.memoizedState,w=i.getDerivedStateFromProps,typeof w=="function"&&(_c(n,i,w,l),f.state=n.memoizedState),typeof i.getDerivedStateFromProps=="function"||typeof f.getSnapshotBeforeUpdate=="function"||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(i=f.state,typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount(),i!==f.state&&ho.enqueueReplaceState(f,f.state,null),io(n,l,f,m),f.state=n.memoizedState),typeof f.componentDidMount=="function"&&(n.flags|=4194308)}function zs(n,i){try{var l="",m=i;do l+=re(m),m=m.return;while(m);var f=l}catch(w){f=`
|
|
39
|
+
Error generating stack: `+w.message+`
|
|
40
|
+
`+w.stack}return{value:n,source:i,stack:f,digest:null}}function Ec(n,i,l){return{value:n,source:null,stack:l??null,digest:i??null}}function Tc(n,i){try{console.error(i.value)}catch(l){setTimeout(function(){throw l})}}var e2=typeof WeakMap=="function"?WeakMap:Map;function Uh(n,i,l){l=mn(-1,l),l.tag=3,l.payload={element:null};var m=i.value;return l.callback=function(){wo||(wo=!0,Vc=m),Tc(n,i)},l}function Vh(n,i,l){l=mn(-1,l),l.tag=3;var m=n.type.getDerivedStateFromError;if(typeof m=="function"){var f=i.value;l.payload=function(){return m(f)},l.callback=function(){Tc(n,i)}}var w=n.stateNode;return w!==null&&typeof w.componentDidCatch=="function"&&(l.callback=function(){Tc(n,i),typeof m!="function"&&(In===null?In=new Set([this]):In.add(this));var C=i.stack;this.componentDidCatch(i.value,{componentStack:C!==null?C:""})}),l}function qh(n,i,l){var m=n.pingCache;if(m===null){m=n.pingCache=new e2;var f=new Set;m.set(i,f)}else f=m.get(i),f===void 0&&(f=new Set,m.set(i,f));f.has(l)||(f.add(l),n=p2.bind(null,n,i,l),i.then(n,n))}function Yh(n){do{var i;if((i=n.tag===13)&&(i=n.memoizedState,i=i!==null?i.dehydrated!==null:!0),i)return n;n=n.return}while(n!==null);return null}function Gh(n,i,l,m,f){return(n.mode&1)===0?(n===i?n.flags|=65536:(n.flags|=128,l.flags|=131072,l.flags&=-52805,l.tag===1&&(l.alternate===null?l.tag=17:(i=mn(-1,1),i.tag=2,An(l,i,1))),l.lanes|=1),n):(n.flags|=65536,n.lanes=f,n)}var t2=_.ReactCurrentOwner,dr=!1;function tr(n,i,l,m){i.child=n===null?ph(i,null,l,m):Rs(i,n.child,l,m)}function Kh(n,i,l,m,f){l=l.render;var w=i.ref;return Ds(i,f),m=bc(n,i,l,m,w,f),l=jc(),n!==null&&!dr?(i.updateQueue=n.updateQueue,i.flags&=-2053,n.lanes&=~f,hn(n,i,f)):(ut&&l&&sc(i),i.flags|=1,tr(n,i,m,f),i.child)}function Qh(n,i,l,m,f){if(n===null){var w=l.type;return typeof w=="function"&&!Xc(w)&&w.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(i.tag=15,i.type=w,Jh(n,i,w,m,f)):(n=So(l.type,null,m,i,i.mode,f),n.ref=i.ref,n.return=i,i.child=n)}if(w=n.child,(n.lanes&f)===0){var C=w.memoizedProps;if(l=l.compare,l=l!==null?l:Li,l(C,m)&&n.ref===i.ref)return hn(n,i,f)}return i.flags|=1,n=Dn(w,m),n.ref=i.ref,n.return=i,i.child=n}function Jh(n,i,l,m,f){if(n!==null){var w=n.memoizedProps;if(Li(w,m)&&n.ref===i.ref)if(dr=!1,i.pendingProps=m=w,(n.lanes&f)!==0)(n.flags&131072)!==0&&(dr=!0);else return i.lanes=n.lanes,hn(n,i,f)}return Ac(n,i,l,m,f)}function Xh(n,i,l){var m=i.pendingProps,f=m.children,w=n!==null?n.memoizedState:null;if(m.mode==="hidden")if((i.mode&1)===0)i.memoizedState={baseLanes:0,cachePool:null,transitions:null},st(Fs,kr),kr|=l;else{if((l&1073741824)===0)return n=w!==null?w.baseLanes|l:l,i.lanes=i.childLanes=1073741824,i.memoizedState={baseLanes:n,cachePool:null,transitions:null},i.updateQueue=null,st(Fs,kr),kr|=n,null;i.memoizedState={baseLanes:0,cachePool:null,transitions:null},m=w!==null?w.baseLanes:l,st(Fs,kr),kr|=m}else w!==null?(m=w.baseLanes|l,i.memoizedState=null):m=l,st(Fs,kr),kr|=m;return tr(n,i,f,l),i.child}function Zh(n,i){var l=i.ref;(n===null&&l!==null||n!==null&&n.ref!==l)&&(i.flags|=512,i.flags|=2097152)}function Ac(n,i,l,m,f){var w=cr(l)?es:qt.current;return w=As(i,w),Ds(i,f),l=bc(n,i,l,m,w,f),m=jc(),n!==null&&!dr?(i.updateQueue=n.updateQueue,i.flags&=-2053,n.lanes&=~f,hn(n,i,f)):(ut&&m&&sc(i),i.flags|=1,tr(n,i,l,f),i.child)}function e0(n,i,l,m,f){if(cr(l)){var w=!0;Qa(i)}else w=!1;if(Ds(i,f),i.stateNode===null)fo(n,i),Wh(i,l,m),Lc(i,l,m,f),m=!0;else if(n===null){var C=i.stateNode,O=i.memoizedProps;C.props=O;var Y=C.context,se=l.contextType;typeof se=="object"&&se!==null?se=Ar(se):(se=cr(l)?es:qt.current,se=As(i,se));var pe=l.getDerivedStateFromProps,xe=typeof pe=="function"||typeof C.getSnapshotBeforeUpdate=="function";xe||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(O!==m||Y!==se)&&Hh(i,C,m,se),Tn=!1;var me=i.memoizedState;C.state=me,io(i,m,C,f),Y=i.memoizedState,O!==m||me!==Y||lr.current||Tn?(typeof pe=="function"&&(_c(i,l,pe,m),Y=i.memoizedState),(O=Tn||Fh(i,l,O,m,me,Y,se))?(xe||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount()),typeof C.componentDidMount=="function"&&(i.flags|=4194308)):(typeof C.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=m,i.memoizedState=Y),C.props=m,C.state=Y,C.context=se,m=O):(typeof C.componentDidMount=="function"&&(i.flags|=4194308),m=!1)}else{C=i.stateNode,xh(n,i),O=i.memoizedProps,se=i.type===i.elementType?O:Fr(i.type,O),C.props=se,xe=i.pendingProps,me=C.context,Y=l.contextType,typeof Y=="object"&&Y!==null?Y=Ar(Y):(Y=cr(l)?es:qt.current,Y=As(i,Y));var ke=l.getDerivedStateFromProps;(pe=typeof ke=="function"||typeof C.getSnapshotBeforeUpdate=="function")||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(O!==xe||me!==Y)&&Hh(i,C,m,Y),Tn=!1,me=i.memoizedState,C.state=me,io(i,m,C,f);var Ce=i.memoizedState;O!==xe||me!==Ce||lr.current||Tn?(typeof ke=="function"&&(_c(i,l,ke,m),Ce=i.memoizedState),(se=Tn||Fh(i,l,se,m,me,Ce,Y)||!1)?(pe||typeof C.UNSAFE_componentWillUpdate!="function"&&typeof C.componentWillUpdate!="function"||(typeof C.componentWillUpdate=="function"&&C.componentWillUpdate(m,Ce,Y),typeof C.UNSAFE_componentWillUpdate=="function"&&C.UNSAFE_componentWillUpdate(m,Ce,Y)),typeof C.componentDidUpdate=="function"&&(i.flags|=4),typeof C.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof C.componentDidUpdate!="function"||O===n.memoizedProps&&me===n.memoizedState||(i.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||O===n.memoizedProps&&me===n.memoizedState||(i.flags|=1024),i.memoizedProps=m,i.memoizedState=Ce),C.props=m,C.state=Ce,C.context=Y,m=se):(typeof C.componentDidUpdate!="function"||O===n.memoizedProps&&me===n.memoizedState||(i.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||O===n.memoizedProps&&me===n.memoizedState||(i.flags|=1024),m=!1)}return Pc(n,i,l,m,w,f)}function Pc(n,i,l,m,f,w){Zh(n,i);var C=(i.flags&128)!==0;if(!m&&!C)return f&&ih(i,l,!1),hn(n,i,w);m=i.stateNode,t2.current=i;var O=C&&typeof l.getDerivedStateFromError!="function"?null:m.render();return i.flags|=1,n!==null&&C?(i.child=Rs(i,n.child,null,w),i.child=Rs(i,null,O,w)):tr(n,i,O,w),i.memoizedState=m.state,f&&ih(i,l,!0),i.child}function t0(n){var i=n.stateNode;i.pendingContext?nh(n,i.pendingContext,i.pendingContext!==i.context):i.context&&nh(n,i.context,!1),fc(n,i.containerInfo)}function r0(n,i,l,m,f){return Ms(),lc(f),i.flags|=256,tr(n,i,l,m),i.child}var Ic={dehydrated:null,treeContext:null,retryLane:0};function Mc(n){return{baseLanes:n,cachePool:null,transitions:null}}function n0(n,i,l){var m=i.pendingProps,f=ht.current,w=!1,C=(i.flags&128)!==0,O;if((O=C)||(O=n!==null&&n.memoizedState===null?!1:(f&2)!==0),O?(w=!0,i.flags&=-129):(n===null||n.memoizedState!==null)&&(f|=1),st(ht,f&1),n===null)return oc(i),n=i.memoizedState,n!==null&&(n=n.dehydrated,n!==null)?((i.mode&1)===0?i.lanes=1:n.data==="$!"?i.lanes=8:i.lanes=1073741824,null):(C=m.children,n=m.fallback,w?(m=i.mode,w=i.child,C={mode:"hidden",children:C},(m&1)===0&&w!==null?(w.childLanes=0,w.pendingProps=C):w=_o(C,m,0,null),n=ds(n,m,l,null),w.return=i,n.return=i,w.sibling=n,i.child=w,i.child.memoizedState=Mc(l),i.memoizedState=Ic,n):Rc(i,C));if(f=n.memoizedState,f!==null&&(O=f.dehydrated,O!==null))return r2(n,i,C,m,O,f,l);if(w){w=m.fallback,C=i.mode,f=n.child,O=f.sibling;var Y={mode:"hidden",children:m.children};return(C&1)===0&&i.child!==f?(m=i.child,m.childLanes=0,m.pendingProps=Y,i.deletions=null):(m=Dn(f,Y),m.subtreeFlags=f.subtreeFlags&14680064),O!==null?w=Dn(O,w):(w=ds(w,C,l,null),w.flags|=2),w.return=i,m.return=i,m.sibling=w,i.child=m,m=w,w=i.child,C=n.child.memoizedState,C=C===null?Mc(l):{baseLanes:C.baseLanes|l,cachePool:null,transitions:C.transitions},w.memoizedState=C,w.childLanes=n.childLanes&~l,i.memoizedState=Ic,m}return w=n.child,n=w.sibling,m=Dn(w,{mode:"visible",children:m.children}),(i.mode&1)===0&&(m.lanes=l),m.return=i,m.sibling=null,n!==null&&(l=i.deletions,l===null?(i.deletions=[n],i.flags|=16):l.push(n)),i.child=m,i.memoizedState=null,m}function Rc(n,i){return i=_o({mode:"visible",children:i},n.mode,0,null),i.return=n,n.child=i}function po(n,i,l,m){return m!==null&&lc(m),Rs(i,n.child,null,l),n=Rc(i,i.pendingProps.children),n.flags|=2,i.memoizedState=null,n}function r2(n,i,l,m,f,w,C){if(l)return i.flags&256?(i.flags&=-257,m=Ec(Error(s(422))),po(n,i,C,m)):i.memoizedState!==null?(i.child=n.child,i.flags|=128,null):(w=m.fallback,f=i.mode,m=_o({mode:"visible",children:m.children},f,0,null),w=ds(w,f,C,null),w.flags|=2,m.return=i,w.return=i,m.sibling=w,i.child=m,(i.mode&1)!==0&&Rs(i,n.child,null,C),i.child.memoizedState=Mc(C),i.memoizedState=Ic,w);if((i.mode&1)===0)return po(n,i,C,null);if(f.data==="$!"){if(m=f.nextSibling&&f.nextSibling.dataset,m)var O=m.dgst;return m=O,w=Error(s(419)),m=Ec(w,m,void 0),po(n,i,C,m)}if(O=(C&n.childLanes)!==0,dr||O){if(m=Bt,m!==null){switch(C&-C){case 4:f=2;break;case 16:f=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:f=32;break;case 536870912:f=268435456;break;default:f=0}f=(f&(m.suspendedLanes|C))!==0?0:f,f!==0&&f!==w.retryLane&&(w.retryLane=f,un(n,f),Ur(m,n,f,-1))}return Jc(),m=Ec(Error(s(421))),po(n,i,C,m)}return f.data==="$?"?(i.flags|=128,i.child=n.child,i=f2.bind(null,n),f._reactRetry=i,null):(n=w.treeContext,jr=Sn(f.nextSibling),br=i,ut=!0,Or=null,n!==null&&(Er[Tr++]=cn,Er[Tr++]=dn,Er[Tr++]=ts,cn=n.id,dn=n.overflow,ts=i),i=Rc(i,m.children),i.flags|=4096,i)}function s0(n,i,l){n.lanes|=i;var m=n.alternate;m!==null&&(m.lanes|=i),mc(n.return,i,l)}function $c(n,i,l,m,f){var w=n.memoizedState;w===null?n.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:m,tail:l,tailMode:f}:(w.isBackwards=i,w.rendering=null,w.renderingStartTime=0,w.last=m,w.tail=l,w.tailMode=f)}function i0(n,i,l){var m=i.pendingProps,f=m.revealOrder,w=m.tail;if(tr(n,i,m.children,l),m=ht.current,(m&2)!==0)m=m&1|2,i.flags|=128;else{if(n!==null&&(n.flags&128)!==0)e:for(n=i.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&s0(n,l,i);else if(n.tag===19)s0(n,l,i);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===i)break e;for(;n.sibling===null;){if(n.return===null||n.return===i)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}m&=1}if(st(ht,m),(i.mode&1)===0)i.memoizedState=null;else switch(f){case"forwards":for(l=i.child,f=null;l!==null;)n=l.alternate,n!==null&&ao(n)===null&&(f=l),l=l.sibling;l=f,l===null?(f=i.child,i.child=null):(f=l.sibling,l.sibling=null),$c(i,!1,f,l,w);break;case"backwards":for(l=null,f=i.child,i.child=null;f!==null;){if(n=f.alternate,n!==null&&ao(n)===null){i.child=f;break}n=f.sibling,f.sibling=l,l=f,f=n}$c(i,!0,l,null,w);break;case"together":$c(i,!1,null,null,void 0);break;default:i.memoizedState=null}return i.child}function fo(n,i){(i.mode&1)===0&&n!==null&&(n.alternate=null,i.alternate=null,i.flags|=2)}function hn(n,i,l){if(n!==null&&(i.dependencies=n.dependencies),as|=i.lanes,(l&i.childLanes)===0)return null;if(n!==null&&i.child!==n.child)throw Error(s(153));if(i.child!==null){for(n=i.child,l=Dn(n,n.pendingProps),i.child=l,l.return=i;n.sibling!==null;)n=n.sibling,l=l.sibling=Dn(n,n.pendingProps),l.return=i;l.sibling=null}return i.child}function n2(n,i,l){switch(i.tag){case 3:t0(i),Ms();break;case 5:vh(i);break;case 1:cr(i.type)&&Qa(i);break;case 4:fc(i,i.stateNode.containerInfo);break;case 10:var m=i.type._context,f=i.memoizedProps.value;st(ro,m._currentValue),m._currentValue=f;break;case 13:if(m=i.memoizedState,m!==null)return m.dehydrated!==null?(st(ht,ht.current&1),i.flags|=128,null):(l&i.child.childLanes)!==0?n0(n,i,l):(st(ht,ht.current&1),n=hn(n,i,l),n!==null?n.sibling:null);st(ht,ht.current&1);break;case 19:if(m=(l&i.childLanes)!==0,(n.flags&128)!==0){if(m)return i0(n,i,l);i.flags|=128}if(f=i.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),st(ht,ht.current),m)break;return null;case 22:case 23:return i.lanes=0,Xh(n,i,l)}return hn(n,i,l)}var a0,Dc,o0,l0;a0=function(n,i){for(var l=i.child;l!==null;){if(l.tag===5||l.tag===6)n.appendChild(l.stateNode);else if(l.tag!==4&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===i)break;for(;l.sibling===null;){if(l.return===null||l.return===i)return;l=l.return}l.sibling.return=l.return,l=l.sibling}},Dc=function(){},o0=function(n,i,l,m){var f=n.memoizedProps;if(f!==m){n=i.stateNode,ss(Gr.current);var w=null;switch(l){case"input":f=Oe(n,f),m=Oe(n,m),w=[];break;case"select":f=E({},f,{value:void 0}),m=E({},m,{value:void 0}),w=[];break;case"textarea":f=Zt(n,f),m=Zt(n,m),w=[];break;default:typeof f.onClick!="function"&&typeof m.onClick=="function"&&(n.onclick=Ya)}rt(l,m);var C;l=null;for(se in f)if(!m.hasOwnProperty(se)&&f.hasOwnProperty(se)&&f[se]!=null)if(se==="style"){var O=f[se];for(C in O)O.hasOwnProperty(C)&&(l||(l={}),l[C]="")}else se!=="dangerouslySetInnerHTML"&&se!=="children"&&se!=="suppressContentEditableWarning"&&se!=="suppressHydrationWarning"&&se!=="autoFocus"&&(o.hasOwnProperty(se)?w||(w=[]):(w=w||[]).push(se,null));for(se in m){var Y=m[se];if(O=f!=null?f[se]:void 0,m.hasOwnProperty(se)&&Y!==O&&(Y!=null||O!=null))if(se==="style")if(O){for(C in O)!O.hasOwnProperty(C)||Y&&Y.hasOwnProperty(C)||(l||(l={}),l[C]="");for(C in Y)Y.hasOwnProperty(C)&&O[C]!==Y[C]&&(l||(l={}),l[C]=Y[C])}else l||(w||(w=[]),w.push(se,l)),l=Y;else se==="dangerouslySetInnerHTML"?(Y=Y?Y.__html:void 0,O=O?O.__html:void 0,Y!=null&&O!==Y&&(w=w||[]).push(se,Y)):se==="children"?typeof Y!="string"&&typeof Y!="number"||(w=w||[]).push(se,""+Y):se!=="suppressContentEditableWarning"&&se!=="suppressHydrationWarning"&&(o.hasOwnProperty(se)?(Y!=null&&se==="onScroll"&<("scroll",n),w||O===Y||(w=[])):(w=w||[]).push(se,Y))}l&&(w=w||[]).push("style",l);var se=w;(i.updateQueue=se)&&(i.flags|=4)}},l0=function(n,i,l,m){l!==m&&(i.flags|=4)};function Hi(n,i){if(!ut)switch(n.tailMode){case"hidden":i=n.tail;for(var l=null;i!==null;)i.alternate!==null&&(l=i),i=i.sibling;l===null?n.tail=null:l.sibling=null;break;case"collapsed":l=n.tail;for(var m=null;l!==null;)l.alternate!==null&&(m=l),l=l.sibling;m===null?i||n.tail===null?n.tail=null:n.tail.sibling=null:m.sibling=null}}function Gt(n){var i=n.alternate!==null&&n.alternate.child===n.child,l=0,m=0;if(i)for(var f=n.child;f!==null;)l|=f.lanes|f.childLanes,m|=f.subtreeFlags&14680064,m|=f.flags&14680064,f.return=n,f=f.sibling;else for(f=n.child;f!==null;)l|=f.lanes|f.childLanes,m|=f.subtreeFlags,m|=f.flags,f.return=n,f=f.sibling;return n.subtreeFlags|=m,n.childLanes=l,i}function s2(n,i,l){var m=i.pendingProps;switch(ic(i),i.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Gt(i),null;case 1:return cr(i.type)&&Ka(),Gt(i),null;case 3:return m=i.stateNode,Bs(),ct(lr),ct(qt),yc(),m.pendingContext&&(m.context=m.pendingContext,m.pendingContext=null),(n===null||n.child===null)&&(eo(i)?i.flags|=4:n===null||n.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,Or!==null&&(Gc(Or),Or=null))),Dc(n,i),Gt(i),null;case 5:xc(i);var f=ss(Bi.current);if(l=i.type,n!==null&&i.stateNode!=null)o0(n,i,l,m,f),n.ref!==i.ref&&(i.flags|=512,i.flags|=2097152);else{if(!m){if(i.stateNode===null)throw Error(s(166));return Gt(i),null}if(n=ss(Gr.current),eo(i)){m=i.stateNode,l=i.type;var w=i.memoizedProps;switch(m[Yr]=i,m[Ii]=w,n=(i.mode&1)!==0,l){case"dialog":lt("cancel",m),lt("close",m);break;case"iframe":case"object":case"embed":lt("load",m);break;case"video":case"audio":for(f=0;f<Ti.length;f++)lt(Ti[f],m);break;case"source":lt("error",m);break;case"img":case"image":case"link":lt("error",m),lt("load",m);break;case"details":lt("toggle",m);break;case"input":Se(m,w),lt("invalid",m);break;case"select":m._wrapperState={wasMultiple:!!w.multiple},lt("invalid",m);break;case"textarea":ar(m,w),lt("invalid",m)}rt(l,w),f=null;for(var C in w)if(w.hasOwnProperty(C)){var O=w[C];C==="children"?typeof O=="string"?m.textContent!==O&&(w.suppressHydrationWarning!==!0&&qa(m.textContent,O,n),f=["children",O]):typeof O=="number"&&m.textContent!==""+O&&(w.suppressHydrationWarning!==!0&&qa(m.textContent,O,n),f=["children",""+O]):o.hasOwnProperty(C)&&O!=null&&C==="onScroll"&<("scroll",m)}switch(l){case"input":F(m),tt(m,w,!0);break;case"textarea":F(m),Et(m);break;case"select":case"option":break;default:typeof w.onClick=="function"&&(m.onclick=Ya)}m=f,i.updateQueue=m,m!==null&&(i.flags|=4)}else{C=f.nodeType===9?f:f.ownerDocument,n==="http://www.w3.org/1999/xhtml"&&(n=ae(l)),n==="http://www.w3.org/1999/xhtml"?l==="script"?(n=C.createElement("div"),n.innerHTML="<script><\/script>",n=n.removeChild(n.firstChild)):typeof m.is=="string"?n=C.createElement(l,{is:m.is}):(n=C.createElement(l),l==="select"&&(C=n,m.multiple?C.multiple=!0:m.size&&(C.size=m.size))):n=C.createElementNS(n,l),n[Yr]=i,n[Ii]=m,a0(n,i,!1,!1),i.stateNode=n;e:{switch(C=ce(l,m),l){case"dialog":lt("cancel",n),lt("close",n),f=m;break;case"iframe":case"object":case"embed":lt("load",n),f=m;break;case"video":case"audio":for(f=0;f<Ti.length;f++)lt(Ti[f],n);f=m;break;case"source":lt("error",n),f=m;break;case"img":case"image":case"link":lt("error",n),lt("load",n),f=m;break;case"details":lt("toggle",n),f=m;break;case"input":Se(n,m),f=Oe(n,m),lt("invalid",n);break;case"option":f=m;break;case"select":n._wrapperState={wasMultiple:!!m.multiple},f=E({},m,{value:void 0}),lt("invalid",n);break;case"textarea":ar(n,m),f=Zt(n,m),lt("invalid",n);break;default:f=m}rt(l,f),O=f;for(w in O)if(O.hasOwnProperty(w)){var Y=O[w];w==="style"?Vt(n,Y):w==="dangerouslySetInnerHTML"?(Y=Y?Y.__html:void 0,Y!=null&&be(n,Y)):w==="children"?typeof Y=="string"?(l!=="textarea"||Y!=="")&&Me(n,Y):typeof Y=="number"&&Me(n,""+Y):w!=="suppressContentEditableWarning"&&w!=="suppressHydrationWarning"&&w!=="autoFocus"&&(o.hasOwnProperty(w)?Y!=null&&w==="onScroll"&<("scroll",n):Y!=null&&M(n,w,Y,C))}switch(l){case"input":F(n),tt(n,m,!1);break;case"textarea":F(n),Et(n);break;case"option":m.value!=null&&n.setAttribute("value",""+je(m.value));break;case"select":n.multiple=!!m.multiple,w=m.value,w!=null?$t(n,!!m.multiple,w,!1):m.defaultValue!=null&&$t(n,!!m.multiple,m.defaultValue,!0);break;default:typeof f.onClick=="function"&&(n.onclick=Ya)}switch(l){case"button":case"input":case"select":case"textarea":m=!!m.autoFocus;break e;case"img":m=!0;break e;default:m=!1}}m&&(i.flags|=4)}i.ref!==null&&(i.flags|=512,i.flags|=2097152)}return Gt(i),null;case 6:if(n&&i.stateNode!=null)l0(n,i,n.memoizedProps,m);else{if(typeof m!="string"&&i.stateNode===null)throw Error(s(166));if(l=ss(Bi.current),ss(Gr.current),eo(i)){if(m=i.stateNode,l=i.memoizedProps,m[Yr]=i,(w=m.nodeValue!==l)&&(n=br,n!==null))switch(n.tag){case 3:qa(m.nodeValue,l,(n.mode&1)!==0);break;case 5:n.memoizedProps.suppressHydrationWarning!==!0&&qa(m.nodeValue,l,(n.mode&1)!==0)}w&&(i.flags|=4)}else m=(l.nodeType===9?l:l.ownerDocument).createTextNode(m),m[Yr]=i,i.stateNode=m}return Gt(i),null;case 13:if(ct(ht),m=i.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(ut&&jr!==null&&(i.mode&1)!==0&&(i.flags&128)===0)uh(),Ms(),i.flags|=98560,w=!1;else if(w=eo(i),m!==null&&m.dehydrated!==null){if(n===null){if(!w)throw Error(s(318));if(w=i.memoizedState,w=w!==null?w.dehydrated:null,!w)throw Error(s(317));w[Yr]=i}else Ms(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;Gt(i),w=!1}else Or!==null&&(Gc(Or),Or=null),w=!0;if(!w)return i.flags&65536?i:null}return(i.flags&128)!==0?(i.lanes=l,i):(m=m!==null,m!==(n!==null&&n.memoizedState!==null)&&m&&(i.child.flags|=8192,(i.mode&1)!==0&&(n===null||(ht.current&1)!==0?At===0&&(At=3):Jc())),i.updateQueue!==null&&(i.flags|=4),Gt(i),null);case 4:return Bs(),Dc(n,i),n===null&&Ai(i.stateNode.containerInfo),Gt(i),null;case 10:return uc(i.type._context),Gt(i),null;case 17:return cr(i.type)&&Ka(),Gt(i),null;case 19:if(ct(ht),w=i.memoizedState,w===null)return Gt(i),null;if(m=(i.flags&128)!==0,C=w.rendering,C===null)if(m)Hi(w,!1);else{if(At!==0||n!==null&&(n.flags&128)!==0)for(n=i.child;n!==null;){if(C=ao(n),C!==null){for(i.flags|=128,Hi(w,!1),m=C.updateQueue,m!==null&&(i.updateQueue=m,i.flags|=4),i.subtreeFlags=0,m=l,l=i.child;l!==null;)w=l,n=m,w.flags&=14680066,C=w.alternate,C===null?(w.childLanes=0,w.lanes=n,w.child=null,w.subtreeFlags=0,w.memoizedProps=null,w.memoizedState=null,w.updateQueue=null,w.dependencies=null,w.stateNode=null):(w.childLanes=C.childLanes,w.lanes=C.lanes,w.child=C.child,w.subtreeFlags=0,w.deletions=null,w.memoizedProps=C.memoizedProps,w.memoizedState=C.memoizedState,w.updateQueue=C.updateQueue,w.type=C.type,n=C.dependencies,w.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),l=l.sibling;return st(ht,ht.current&1|2),i.child}n=n.sibling}w.tail!==null&&vt()>Ws&&(i.flags|=128,m=!0,Hi(w,!1),i.lanes=4194304)}else{if(!m)if(n=ao(C),n!==null){if(i.flags|=128,m=!0,l=n.updateQueue,l!==null&&(i.updateQueue=l,i.flags|=4),Hi(w,!0),w.tail===null&&w.tailMode==="hidden"&&!C.alternate&&!ut)return Gt(i),null}else 2*vt()-w.renderingStartTime>Ws&&l!==1073741824&&(i.flags|=128,m=!0,Hi(w,!1),i.lanes=4194304);w.isBackwards?(C.sibling=i.child,i.child=C):(l=w.last,l!==null?l.sibling=C:i.child=C,w.last=C)}return w.tail!==null?(i=w.tail,w.rendering=i,w.tail=i.sibling,w.renderingStartTime=vt(),i.sibling=null,l=ht.current,st(ht,m?l&1|2:l&1),i):(Gt(i),null);case 22:case 23:return Qc(),m=i.memoizedState!==null,n!==null&&n.memoizedState!==null!==m&&(i.flags|=8192),m&&(i.mode&1)!==0?(kr&1073741824)!==0&&(Gt(i),i.subtreeFlags&6&&(i.flags|=8192)):Gt(i),null;case 24:return null;case 25:return null}throw Error(s(156,i.tag))}function i2(n,i){switch(ic(i),i.tag){case 1:return cr(i.type)&&Ka(),n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 3:return Bs(),ct(lr),ct(qt),yc(),n=i.flags,(n&65536)!==0&&(n&128)===0?(i.flags=n&-65537|128,i):null;case 5:return xc(i),null;case 13:if(ct(ht),n=i.memoizedState,n!==null&&n.dehydrated!==null){if(i.alternate===null)throw Error(s(340));Ms()}return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 19:return ct(ht),null;case 4:return Bs(),null;case 10:return uc(i.type._context),null;case 22:case 23:return Qc(),null;case 24:return null;default:return null}}var xo=!1,Kt=!1,a2=typeof WeakSet=="function"?WeakSet:Set,Ne=null;function Os(n,i){var l=n.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(m){xt(n,i,m)}else l.current=null}function Bc(n,i,l){try{l()}catch(m){xt(n,i,m)}}var c0=!1;function o2(n,i){if(Ql=Ra,n=Fm(),Wl(n)){if("selectionStart"in n)var l={start:n.selectionStart,end:n.selectionEnd};else e:{l=(l=n.ownerDocument)&&l.defaultView||window;var m=l.getSelection&&l.getSelection();if(m&&m.rangeCount!==0){l=m.anchorNode;var f=m.anchorOffset,w=m.focusNode;m=m.focusOffset;try{l.nodeType,w.nodeType}catch{l=null;break e}var C=0,O=-1,Y=-1,se=0,pe=0,xe=n,me=null;t:for(;;){for(var ke;xe!==l||f!==0&&xe.nodeType!==3||(O=C+f),xe!==w||m!==0&&xe.nodeType!==3||(Y=C+m),xe.nodeType===3&&(C+=xe.nodeValue.length),(ke=xe.firstChild)!==null;)me=xe,xe=ke;for(;;){if(xe===n)break t;if(me===l&&++se===f&&(O=C),me===w&&++pe===m&&(Y=C),(ke=xe.nextSibling)!==null)break;xe=me,me=xe.parentNode}xe=ke}l=O===-1||Y===-1?null:{start:O,end:Y}}else l=null}l=l||{start:0,end:0}}else l=null;for(Jl={focusedElem:n,selectionRange:l},Ra=!1,Ne=i;Ne!==null;)if(i=Ne,n=i.child,(i.subtreeFlags&1028)!==0&&n!==null)n.return=i,Ne=n;else for(;Ne!==null;){i=Ne;try{var Ce=i.alternate;if((i.flags&1024)!==0)switch(i.tag){case 0:case 11:case 15:break;case 1:if(Ce!==null){var _e=Ce.memoizedProps,wt=Ce.memoizedState,te=i.stateNode,K=te.getSnapshotBeforeUpdate(i.elementType===i.type?_e:Fr(i.type,_e),wt);te.__reactInternalSnapshotBeforeUpdate=K}break;case 3:var ne=i.stateNode.containerInfo;ne.nodeType===1?ne.textContent="":ne.nodeType===9&&ne.documentElement&&ne.removeChild(ne.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(we){xt(i,i.return,we)}if(n=i.sibling,n!==null){n.return=i.return,Ne=n;break}Ne=i.return}return Ce=c0,c0=!1,Ce}function Ui(n,i,l){var m=i.updateQueue;if(m=m!==null?m.lastEffect:null,m!==null){var f=m=m.next;do{if((f.tag&n)===n){var w=f.destroy;f.destroy=void 0,w!==void 0&&Bc(i,l,w)}f=f.next}while(f!==m)}}function go(n,i){if(i=i.updateQueue,i=i!==null?i.lastEffect:null,i!==null){var l=i=i.next;do{if((l.tag&n)===n){var m=l.create;l.destroy=m()}l=l.next}while(l!==i)}}function zc(n){var i=n.ref;if(i!==null){var l=n.stateNode;switch(n.tag){case 5:n=l;break;default:n=l}typeof i=="function"?i(n):i.current=n}}function d0(n){var i=n.alternate;i!==null&&(n.alternate=null,d0(i)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(i=n.stateNode,i!==null&&(delete i[Yr],delete i[Ii],delete i[tc],delete i[Hv],delete i[Uv])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function u0(n){return n.tag===5||n.tag===3||n.tag===4}function m0(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||u0(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function Oc(n,i,l){var m=n.tag;if(m===5||m===6)n=n.stateNode,i?l.nodeType===8?l.parentNode.insertBefore(n,i):l.insertBefore(n,i):(l.nodeType===8?(i=l.parentNode,i.insertBefore(n,l)):(i=l,i.appendChild(n)),l=l._reactRootContainer,l!=null||i.onclick!==null||(i.onclick=Ya));else if(m!==4&&(n=n.child,n!==null))for(Oc(n,i,l),n=n.sibling;n!==null;)Oc(n,i,l),n=n.sibling}function Fc(n,i,l){var m=n.tag;if(m===5||m===6)n=n.stateNode,i?l.insertBefore(n,i):l.appendChild(n);else if(m!==4&&(n=n.child,n!==null))for(Fc(n,i,l),n=n.sibling;n!==null;)Fc(n,i,l),n=n.sibling}var Wt=null,Wr=!1;function Pn(n,i,l){for(l=l.child;l!==null;)h0(n,i,l),l=l.sibling}function h0(n,i,l){if(qr&&typeof qr.onCommitFiberUnmount=="function")try{qr.onCommitFiberUnmount(Ea,l)}catch{}switch(l.tag){case 5:Kt||Os(l,i);case 6:var m=Wt,f=Wr;Wt=null,Pn(n,i,l),Wt=m,Wr=f,Wt!==null&&(Wr?(n=Wt,l=l.stateNode,n.nodeType===8?n.parentNode.removeChild(l):n.removeChild(l)):Wt.removeChild(l.stateNode));break;case 18:Wt!==null&&(Wr?(n=Wt,l=l.stateNode,n.nodeType===8?ec(n.parentNode,l):n.nodeType===1&&ec(n,l),ji(n)):ec(Wt,l.stateNode));break;case 4:m=Wt,f=Wr,Wt=l.stateNode.containerInfo,Wr=!0,Pn(n,i,l),Wt=m,Wr=f;break;case 0:case 11:case 14:case 15:if(!Kt&&(m=l.updateQueue,m!==null&&(m=m.lastEffect,m!==null))){f=m=m.next;do{var w=f,C=w.destroy;w=w.tag,C!==void 0&&((w&2)!==0||(w&4)!==0)&&Bc(l,i,C),f=f.next}while(f!==m)}Pn(n,i,l);break;case 1:if(!Kt&&(Os(l,i),m=l.stateNode,typeof m.componentWillUnmount=="function"))try{m.props=l.memoizedProps,m.state=l.memoizedState,m.componentWillUnmount()}catch(O){xt(l,i,O)}Pn(n,i,l);break;case 21:Pn(n,i,l);break;case 22:l.mode&1?(Kt=(m=Kt)||l.memoizedState!==null,Pn(n,i,l),Kt=m):Pn(n,i,l);break;default:Pn(n,i,l)}}function p0(n){var i=n.updateQueue;if(i!==null){n.updateQueue=null;var l=n.stateNode;l===null&&(l=n.stateNode=new a2),i.forEach(function(m){var f=x2.bind(null,n,m);l.has(m)||(l.add(m),m.then(f,f))})}}function Hr(n,i){var l=i.deletions;if(l!==null)for(var m=0;m<l.length;m++){var f=l[m];try{var w=n,C=i,O=C;e:for(;O!==null;){switch(O.tag){case 5:Wt=O.stateNode,Wr=!1;break e;case 3:Wt=O.stateNode.containerInfo,Wr=!0;break e;case 4:Wt=O.stateNode.containerInfo,Wr=!0;break e}O=O.return}if(Wt===null)throw Error(s(160));h0(w,C,f),Wt=null,Wr=!1;var Y=f.alternate;Y!==null&&(Y.return=null),f.return=null}catch(se){xt(f,i,se)}}if(i.subtreeFlags&12854)for(i=i.child;i!==null;)f0(i,n),i=i.sibling}function f0(n,i){var l=n.alternate,m=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:if(Hr(i,n),Qr(n),m&4){try{Ui(3,n,n.return),go(3,n)}catch(_e){xt(n,n.return,_e)}try{Ui(5,n,n.return)}catch(_e){xt(n,n.return,_e)}}break;case 1:Hr(i,n),Qr(n),m&512&&l!==null&&Os(l,l.return);break;case 5:if(Hr(i,n),Qr(n),m&512&&l!==null&&Os(l,l.return),n.flags&32){var f=n.stateNode;try{Me(f,"")}catch(_e){xt(n,n.return,_e)}}if(m&4&&(f=n.stateNode,f!=null)){var w=n.memoizedProps,C=l!==null?l.memoizedProps:w,O=n.type,Y=n.updateQueue;if(n.updateQueue=null,Y!==null)try{O==="input"&&w.type==="radio"&&w.name!=null&&We(f,w),ce(O,C);var se=ce(O,w);for(C=0;C<Y.length;C+=2){var pe=Y[C],xe=Y[C+1];pe==="style"?Vt(f,xe):pe==="dangerouslySetInnerHTML"?be(f,xe):pe==="children"?Me(f,xe):M(f,pe,xe,se)}switch(O){case"input":qe(f,w);break;case"textarea":er(f,w);break;case"select":var me=f._wrapperState.wasMultiple;f._wrapperState.wasMultiple=!!w.multiple;var ke=w.value;ke!=null?$t(f,!!w.multiple,ke,!1):me!==!!w.multiple&&(w.defaultValue!=null?$t(f,!!w.multiple,w.defaultValue,!0):$t(f,!!w.multiple,w.multiple?[]:"",!1))}f[Ii]=w}catch(_e){xt(n,n.return,_e)}}break;case 6:if(Hr(i,n),Qr(n),m&4){if(n.stateNode===null)throw Error(s(162));f=n.stateNode,w=n.memoizedProps;try{f.nodeValue=w}catch(_e){xt(n,n.return,_e)}}break;case 3:if(Hr(i,n),Qr(n),m&4&&l!==null&&l.memoizedState.isDehydrated)try{ji(i.containerInfo)}catch(_e){xt(n,n.return,_e)}break;case 4:Hr(i,n),Qr(n);break;case 13:Hr(i,n),Qr(n),f=n.child,f.flags&8192&&(w=f.memoizedState!==null,f.stateNode.isHidden=w,!w||f.alternate!==null&&f.alternate.memoizedState!==null||(Uc=vt())),m&4&&p0(n);break;case 22:if(pe=l!==null&&l.memoizedState!==null,n.mode&1?(Kt=(se=Kt)||pe,Hr(i,n),Kt=se):Hr(i,n),Qr(n),m&8192){if(se=n.memoizedState!==null,(n.stateNode.isHidden=se)&&!pe&&(n.mode&1)!==0)for(Ne=n,pe=n.child;pe!==null;){for(xe=Ne=pe;Ne!==null;){switch(me=Ne,ke=me.child,me.tag){case 0:case 11:case 14:case 15:Ui(4,me,me.return);break;case 1:Os(me,me.return);var Ce=me.stateNode;if(typeof Ce.componentWillUnmount=="function"){m=me,l=me.return;try{i=m,Ce.props=i.memoizedProps,Ce.state=i.memoizedState,Ce.componentWillUnmount()}catch(_e){xt(m,l,_e)}}break;case 5:Os(me,me.return);break;case 22:if(me.memoizedState!==null){y0(xe);continue}}ke!==null?(ke.return=me,Ne=ke):y0(xe)}pe=pe.sibling}e:for(pe=null,xe=n;;){if(xe.tag===5){if(pe===null){pe=xe;try{f=xe.stateNode,se?(w=f.style,typeof w.setProperty=="function"?w.setProperty("display","none","important"):w.display="none"):(O=xe.stateNode,Y=xe.memoizedProps.style,C=Y!=null&&Y.hasOwnProperty("display")?Y.display:null,O.style.display=Ct("display",C))}catch(_e){xt(n,n.return,_e)}}}else if(xe.tag===6){if(pe===null)try{xe.stateNode.nodeValue=se?"":xe.memoizedProps}catch(_e){xt(n,n.return,_e)}}else if((xe.tag!==22&&xe.tag!==23||xe.memoizedState===null||xe===n)&&xe.child!==null){xe.child.return=xe,xe=xe.child;continue}if(xe===n)break e;for(;xe.sibling===null;){if(xe.return===null||xe.return===n)break e;pe===xe&&(pe=null),xe=xe.return}pe===xe&&(pe=null),xe.sibling.return=xe.return,xe=xe.sibling}}break;case 19:Hr(i,n),Qr(n),m&4&&p0(n);break;case 21:break;default:Hr(i,n),Qr(n)}}function Qr(n){var i=n.flags;if(i&2){try{e:{for(var l=n.return;l!==null;){if(u0(l)){var m=l;break e}l=l.return}throw Error(s(160))}switch(m.tag){case 5:var f=m.stateNode;m.flags&32&&(Me(f,""),m.flags&=-33);var w=m0(n);Fc(n,w,f);break;case 3:case 4:var C=m.stateNode.containerInfo,O=m0(n);Oc(n,O,C);break;default:throw Error(s(161))}}catch(Y){xt(n,n.return,Y)}n.flags&=-3}i&4096&&(n.flags&=-4097)}function l2(n,i,l){Ne=n,x0(n)}function x0(n,i,l){for(var m=(n.mode&1)!==0;Ne!==null;){var f=Ne,w=f.child;if(f.tag===22&&m){var C=f.memoizedState!==null||xo;if(!C){var O=f.alternate,Y=O!==null&&O.memoizedState!==null||Kt;O=xo;var se=Kt;if(xo=C,(Kt=Y)&&!se)for(Ne=f;Ne!==null;)C=Ne,Y=C.child,C.tag===22&&C.memoizedState!==null?v0(f):Y!==null?(Y.return=C,Ne=Y):v0(f);for(;w!==null;)Ne=w,x0(w),w=w.sibling;Ne=f,xo=O,Kt=se}g0(n)}else(f.subtreeFlags&8772)!==0&&w!==null?(w.return=f,Ne=w):g0(n)}}function g0(n){for(;Ne!==null;){var i=Ne;if((i.flags&8772)!==0){var l=i.alternate;try{if((i.flags&8772)!==0)switch(i.tag){case 0:case 11:case 15:Kt||go(5,i);break;case 1:var m=i.stateNode;if(i.flags&4&&!Kt)if(l===null)m.componentDidMount();else{var f=i.elementType===i.type?l.memoizedProps:Fr(i.type,l.memoizedProps);m.componentDidUpdate(f,l.memoizedState,m.__reactInternalSnapshotBeforeUpdate)}var w=i.updateQueue;w!==null&&yh(i,w,m);break;case 3:var C=i.updateQueue;if(C!==null){if(l=null,i.child!==null)switch(i.child.tag){case 5:l=i.child.stateNode;break;case 1:l=i.child.stateNode}yh(i,C,l)}break;case 5:var O=i.stateNode;if(l===null&&i.flags&4){l=O;var Y=i.memoizedProps;switch(i.type){case"button":case"input":case"select":case"textarea":Y.autoFocus&&l.focus();break;case"img":Y.src&&(l.src=Y.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(i.memoizedState===null){var se=i.alternate;if(se!==null){var pe=se.memoizedState;if(pe!==null){var xe=pe.dehydrated;xe!==null&&ji(xe)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}Kt||i.flags&512&&zc(i)}catch(me){xt(i,i.return,me)}}if(i===n){Ne=null;break}if(l=i.sibling,l!==null){l.return=i.return,Ne=l;break}Ne=i.return}}function y0(n){for(;Ne!==null;){var i=Ne;if(i===n){Ne=null;break}var l=i.sibling;if(l!==null){l.return=i.return,Ne=l;break}Ne=i.return}}function v0(n){for(;Ne!==null;){var i=Ne;try{switch(i.tag){case 0:case 11:case 15:var l=i.return;try{go(4,i)}catch(Y){xt(i,l,Y)}break;case 1:var m=i.stateNode;if(typeof m.componentDidMount=="function"){var f=i.return;try{m.componentDidMount()}catch(Y){xt(i,f,Y)}}var w=i.return;try{zc(i)}catch(Y){xt(i,w,Y)}break;case 5:var C=i.return;try{zc(i)}catch(Y){xt(i,C,Y)}}}catch(Y){xt(i,i.return,Y)}if(i===n){Ne=null;break}var O=i.sibling;if(O!==null){O.return=i.return,Ne=O;break}Ne=i.return}}var c2=Math.ceil,yo=_.ReactCurrentDispatcher,Wc=_.ReactCurrentOwner,Ir=_.ReactCurrentBatchConfig,Ge=0,Bt=null,St=null,Ht=0,kr=0,Fs=_n(0),At=0,Vi=null,as=0,vo=0,Hc=0,qi=null,ur=null,Uc=0,Ws=1/0,pn=null,wo=!1,Vc=null,In=null,bo=!1,Mn=null,jo=0,Yi=0,qc=null,ko=-1,No=0;function rr(){return(Ge&6)!==0?vt():ko!==-1?ko:ko=vt()}function Rn(n){return(n.mode&1)===0?1:(Ge&2)!==0&&Ht!==0?Ht&-Ht:qv.transition!==null?(No===0&&(No=mm()),No):(n=nt,n!==0||(n=window.event,n=n===void 0?16:bm(n.type)),n)}function Ur(n,i,l,m){if(50<Yi)throw Yi=0,qc=null,Error(s(185));gi(n,l,m),((Ge&2)===0||n!==Bt)&&(n===Bt&&((Ge&2)===0&&(vo|=l),At===4&&$n(n,Ht)),mr(n,m),l===1&&Ge===0&&(i.mode&1)===0&&(Ws=vt()+500,Ja&&En()))}function mr(n,i){var l=n.callbackNode;qy(n,i);var m=Pa(n,n===Bt?Ht:0);if(m===0)l!==null&&cm(l),n.callbackNode=null,n.callbackPriority=0;else if(i=m&-m,n.callbackPriority!==i){if(l!=null&&cm(l),i===1)n.tag===0?Vv(b0.bind(null,n)):ah(b0.bind(null,n)),Fv(function(){(Ge&6)===0&&En()}),l=null;else{switch(hm(m)){case 1:l=Cl;break;case 4:l=dm;break;case 16:l=La;break;case 536870912:l=um;break;default:l=La}l=E0(l,w0.bind(null,n))}n.callbackPriority=i,n.callbackNode=l}}function w0(n,i){if(ko=-1,No=0,(Ge&6)!==0)throw Error(s(327));var l=n.callbackNode;if(Hs()&&n.callbackNode!==l)return null;var m=Pa(n,n===Bt?Ht:0);if(m===0)return null;if((m&30)!==0||(m&n.expiredLanes)!==0||i)i=Co(n,m);else{i=m;var f=Ge;Ge|=2;var w=k0();(Bt!==n||Ht!==i)&&(pn=null,Ws=vt()+500,ls(n,i));do try{m2();break}catch(O){j0(n,O)}while(!0);dc(),yo.current=w,Ge=f,St!==null?i=0:(Bt=null,Ht=0,i=At)}if(i!==0){if(i===2&&(f=Sl(n),f!==0&&(m=f,i=Yc(n,f))),i===1)throw l=Vi,ls(n,0),$n(n,m),mr(n,vt()),l;if(i===6)$n(n,m);else{if(f=n.current.alternate,(m&30)===0&&!d2(f)&&(i=Co(n,m),i===2&&(w=Sl(n),w!==0&&(m=w,i=Yc(n,w))),i===1))throw l=Vi,ls(n,0),$n(n,m),mr(n,vt()),l;switch(n.finishedWork=f,n.finishedLanes=m,i){case 0:case 1:throw Error(s(345));case 2:cs(n,ur,pn);break;case 3:if($n(n,m),(m&130023424)===m&&(i=Uc+500-vt(),10<i)){if(Pa(n,0)!==0)break;if(f=n.suspendedLanes,(f&m)!==m){rr(),n.pingedLanes|=n.suspendedLanes&f;break}n.timeoutHandle=Zl(cs.bind(null,n,ur,pn),i);break}cs(n,ur,pn);break;case 4:if($n(n,m),(m&4194240)===m)break;for(i=n.eventTimes,f=-1;0<m;){var C=31-Br(m);w=1<<C,C=i[C],C>f&&(f=C),m&=~w}if(m=f,m=vt()-m,m=(120>m?120:480>m?480:1080>m?1080:1920>m?1920:3e3>m?3e3:4320>m?4320:1960*c2(m/1960))-m,10<m){n.timeoutHandle=Zl(cs.bind(null,n,ur,pn),m);break}cs(n,ur,pn);break;case 5:cs(n,ur,pn);break;default:throw Error(s(329))}}}return mr(n,vt()),n.callbackNode===l?w0.bind(null,n):null}function Yc(n,i){var l=qi;return n.current.memoizedState.isDehydrated&&(ls(n,i).flags|=256),n=Co(n,i),n!==2&&(i=ur,ur=l,i!==null&&Gc(i)),n}function Gc(n){ur===null?ur=n:ur.push.apply(ur,n)}function d2(n){for(var i=n;;){if(i.flags&16384){var l=i.updateQueue;if(l!==null&&(l=l.stores,l!==null))for(var m=0;m<l.length;m++){var f=l[m],w=f.getSnapshot;f=f.value;try{if(!zr(w(),f))return!1}catch{return!1}}}if(l=i.child,i.subtreeFlags&16384&&l!==null)l.return=i,i=l;else{if(i===n)break;for(;i.sibling===null;){if(i.return===null||i.return===n)return!0;i=i.return}i.sibling.return=i.return,i=i.sibling}}return!0}function $n(n,i){for(i&=~Hc,i&=~vo,n.suspendedLanes|=i,n.pingedLanes&=~i,n=n.expirationTimes;0<i;){var l=31-Br(i),m=1<<l;n[l]=-1,i&=~m}}function b0(n){if((Ge&6)!==0)throw Error(s(327));Hs();var i=Pa(n,0);if((i&1)===0)return mr(n,vt()),null;var l=Co(n,i);if(n.tag!==0&&l===2){var m=Sl(n);m!==0&&(i=m,l=Yc(n,m))}if(l===1)throw l=Vi,ls(n,0),$n(n,i),mr(n,vt()),l;if(l===6)throw Error(s(345));return n.finishedWork=n.current.alternate,n.finishedLanes=i,cs(n,ur,pn),mr(n,vt()),null}function Kc(n,i){var l=Ge;Ge|=1;try{return n(i)}finally{Ge=l,Ge===0&&(Ws=vt()+500,Ja&&En())}}function os(n){Mn!==null&&Mn.tag===0&&(Ge&6)===0&&Hs();var i=Ge;Ge|=1;var l=Ir.transition,m=nt;try{if(Ir.transition=null,nt=1,n)return n()}finally{nt=m,Ir.transition=l,Ge=i,(Ge&6)===0&&En()}}function Qc(){kr=Fs.current,ct(Fs)}function ls(n,i){n.finishedWork=null,n.finishedLanes=0;var l=n.timeoutHandle;if(l!==-1&&(n.timeoutHandle=-1,Ov(l)),St!==null)for(l=St.return;l!==null;){var m=l;switch(ic(m),m.tag){case 1:m=m.type.childContextTypes,m!=null&&Ka();break;case 3:Bs(),ct(lr),ct(qt),yc();break;case 5:xc(m);break;case 4:Bs();break;case 13:ct(ht);break;case 19:ct(ht);break;case 10:uc(m.type._context);break;case 22:case 23:Qc()}l=l.return}if(Bt=n,St=n=Dn(n.current,null),Ht=kr=i,At=0,Vi=null,Hc=vo=as=0,ur=qi=null,ns!==null){for(i=0;i<ns.length;i++)if(l=ns[i],m=l.interleaved,m!==null){l.interleaved=null;var f=m.next,w=l.pending;if(w!==null){var C=w.next;w.next=f,m.next=C}l.pending=m}ns=null}return n}function j0(n,i){do{var l=St;try{if(dc(),oo.current=mo,lo){for(var m=pt.memoizedState;m!==null;){var f=m.queue;f!==null&&(f.pending=null),m=m.next}lo=!1}if(is=0,Dt=Tt=pt=null,zi=!1,Oi=0,Wc.current=null,l===null||l.return===null){At=1,Vi=i,St=null;break}e:{var w=n,C=l.return,O=l,Y=i;if(i=Ht,O.flags|=32768,Y!==null&&typeof Y=="object"&&typeof Y.then=="function"){var se=Y,pe=O,xe=pe.tag;if((pe.mode&1)===0&&(xe===0||xe===11||xe===15)){var me=pe.alternate;me?(pe.updateQueue=me.updateQueue,pe.memoizedState=me.memoizedState,pe.lanes=me.lanes):(pe.updateQueue=null,pe.memoizedState=null)}var ke=Yh(C);if(ke!==null){ke.flags&=-257,Gh(ke,C,O,w,i),ke.mode&1&&qh(w,se,i),i=ke,Y=se;var Ce=i.updateQueue;if(Ce===null){var _e=new Set;_e.add(Y),i.updateQueue=_e}else Ce.add(Y);break e}else{if((i&1)===0){qh(w,se,i),Jc();break e}Y=Error(s(426))}}else if(ut&&O.mode&1){var wt=Yh(C);if(wt!==null){(wt.flags&65536)===0&&(wt.flags|=256),Gh(wt,C,O,w,i),lc(zs(Y,O));break e}}w=Y=zs(Y,O),At!==4&&(At=2),qi===null?qi=[w]:qi.push(w),w=C;do{switch(w.tag){case 3:w.flags|=65536,i&=-i,w.lanes|=i;var te=Uh(w,Y,i);gh(w,te);break e;case 1:O=Y;var K=w.type,ne=w.stateNode;if((w.flags&128)===0&&(typeof K.getDerivedStateFromError=="function"||ne!==null&&typeof ne.componentDidCatch=="function"&&(In===null||!In.has(ne)))){w.flags|=65536,i&=-i,w.lanes|=i;var we=Vh(w,O,i);gh(w,we);break e}}w=w.return}while(w!==null)}C0(l)}catch(Ee){i=Ee,St===l&&l!==null&&(St=l=l.return);continue}break}while(!0)}function k0(){var n=yo.current;return yo.current=mo,n===null?mo:n}function Jc(){(At===0||At===3||At===2)&&(At=4),Bt===null||(as&268435455)===0&&(vo&268435455)===0||$n(Bt,Ht)}function Co(n,i){var l=Ge;Ge|=2;var m=k0();(Bt!==n||Ht!==i)&&(pn=null,ls(n,i));do try{u2();break}catch(f){j0(n,f)}while(!0);if(dc(),Ge=l,yo.current=m,St!==null)throw Error(s(261));return Bt=null,Ht=0,At}function u2(){for(;St!==null;)N0(St)}function m2(){for(;St!==null&&!Dy();)N0(St)}function N0(n){var i=L0(n.alternate,n,kr);n.memoizedProps=n.pendingProps,i===null?C0(n):St=i,Wc.current=null}function C0(n){var i=n;do{var l=i.alternate;if(n=i.return,(i.flags&32768)===0){if(l=s2(l,i,kr),l!==null){St=l;return}}else{if(l=i2(l,i),l!==null){l.flags&=32767,St=l;return}if(n!==null)n.flags|=32768,n.subtreeFlags=0,n.deletions=null;else{At=6,St=null;return}}if(i=i.sibling,i!==null){St=i;return}St=i=n}while(i!==null);At===0&&(At=5)}function cs(n,i,l){var m=nt,f=Ir.transition;try{Ir.transition=null,nt=1,h2(n,i,l,m)}finally{Ir.transition=f,nt=m}return null}function h2(n,i,l,m){do Hs();while(Mn!==null);if((Ge&6)!==0)throw Error(s(327));l=n.finishedWork;var f=n.finishedLanes;if(l===null)return null;if(n.finishedWork=null,n.finishedLanes=0,l===n.current)throw Error(s(177));n.callbackNode=null,n.callbackPriority=0;var w=l.lanes|l.childLanes;if(Yy(n,w),n===Bt&&(St=Bt=null,Ht=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||bo||(bo=!0,E0(La,function(){return Hs(),null})),w=(l.flags&15990)!==0,(l.subtreeFlags&15990)!==0||w){w=Ir.transition,Ir.transition=null;var C=nt;nt=1;var O=Ge;Ge|=4,Wc.current=null,o2(n,l),f0(l,n),Iv(Jl),Ra=!!Ql,Jl=Ql=null,n.current=l,l2(l),By(),Ge=O,nt=C,Ir.transition=w}else n.current=l;if(bo&&(bo=!1,Mn=n,jo=f),w=n.pendingLanes,w===0&&(In=null),Fy(l.stateNode),mr(n,vt()),i!==null)for(m=n.onRecoverableError,l=0;l<i.length;l++)f=i[l],m(f.value,{componentStack:f.stack,digest:f.digest});if(wo)throw wo=!1,n=Vc,Vc=null,n;return(jo&1)!==0&&n.tag!==0&&Hs(),w=n.pendingLanes,(w&1)!==0?n===qc?Yi++:(Yi=0,qc=n):Yi=0,En(),null}function Hs(){if(Mn!==null){var n=hm(jo),i=Ir.transition,l=nt;try{if(Ir.transition=null,nt=16>n?16:n,Mn===null)var m=!1;else{if(n=Mn,Mn=null,jo=0,(Ge&6)!==0)throw Error(s(331));var f=Ge;for(Ge|=4,Ne=n.current;Ne!==null;){var w=Ne,C=w.child;if((Ne.flags&16)!==0){var O=w.deletions;if(O!==null){for(var Y=0;Y<O.length;Y++){var se=O[Y];for(Ne=se;Ne!==null;){var pe=Ne;switch(pe.tag){case 0:case 11:case 15:Ui(8,pe,w)}var xe=pe.child;if(xe!==null)xe.return=pe,Ne=xe;else for(;Ne!==null;){pe=Ne;var me=pe.sibling,ke=pe.return;if(d0(pe),pe===se){Ne=null;break}if(me!==null){me.return=ke,Ne=me;break}Ne=ke}}}var Ce=w.alternate;if(Ce!==null){var _e=Ce.child;if(_e!==null){Ce.child=null;do{var wt=_e.sibling;_e.sibling=null,_e=wt}while(_e!==null)}}Ne=w}}if((w.subtreeFlags&2064)!==0&&C!==null)C.return=w,Ne=C;else e:for(;Ne!==null;){if(w=Ne,(w.flags&2048)!==0)switch(w.tag){case 0:case 11:case 15:Ui(9,w,w.return)}var te=w.sibling;if(te!==null){te.return=w.return,Ne=te;break e}Ne=w.return}}var K=n.current;for(Ne=K;Ne!==null;){C=Ne;var ne=C.child;if((C.subtreeFlags&2064)!==0&&ne!==null)ne.return=C,Ne=ne;else e:for(C=K;Ne!==null;){if(O=Ne,(O.flags&2048)!==0)try{switch(O.tag){case 0:case 11:case 15:go(9,O)}}catch(Ee){xt(O,O.return,Ee)}if(O===C){Ne=null;break e}var we=O.sibling;if(we!==null){we.return=O.return,Ne=we;break e}Ne=O.return}}if(Ge=f,En(),qr&&typeof qr.onPostCommitFiberRoot=="function")try{qr.onPostCommitFiberRoot(Ea,n)}catch{}m=!0}return m}finally{nt=l,Ir.transition=i}}return!1}function S0(n,i,l){i=zs(l,i),i=Uh(n,i,1),n=An(n,i,1),i=rr(),n!==null&&(gi(n,1,i),mr(n,i))}function xt(n,i,l){if(n.tag===3)S0(n,n,l);else for(;i!==null;){if(i.tag===3){S0(i,n,l);break}else if(i.tag===1){var m=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof m.componentDidCatch=="function"&&(In===null||!In.has(m))){n=zs(l,n),n=Vh(i,n,1),i=An(i,n,1),n=rr(),i!==null&&(gi(i,1,n),mr(i,n));break}}i=i.return}}function p2(n,i,l){var m=n.pingCache;m!==null&&m.delete(i),i=rr(),n.pingedLanes|=n.suspendedLanes&l,Bt===n&&(Ht&l)===l&&(At===4||At===3&&(Ht&130023424)===Ht&&500>vt()-Uc?ls(n,0):Hc|=l),mr(n,i)}function _0(n,i){i===0&&((n.mode&1)===0?i=1:(i=Aa,Aa<<=1,(Aa&130023424)===0&&(Aa=4194304)));var l=rr();n=un(n,i),n!==null&&(gi(n,i,l),mr(n,l))}function f2(n){var i=n.memoizedState,l=0;i!==null&&(l=i.retryLane),_0(n,l)}function x2(n,i){var l=0;switch(n.tag){case 13:var m=n.stateNode,f=n.memoizedState;f!==null&&(l=f.retryLane);break;case 19:m=n.stateNode;break;default:throw Error(s(314))}m!==null&&m.delete(i),_0(n,l)}var L0;L0=function(n,i,l){if(n!==null)if(n.memoizedProps!==i.pendingProps||lr.current)dr=!0;else{if((n.lanes&l)===0&&(i.flags&128)===0)return dr=!1,n2(n,i,l);dr=(n.flags&131072)!==0}else dr=!1,ut&&(i.flags&1048576)!==0&&oh(i,Za,i.index);switch(i.lanes=0,i.tag){case 2:var m=i.type;fo(n,i),n=i.pendingProps;var f=As(i,qt.current);Ds(i,l),f=bc(null,i,m,n,f,l);var w=jc();return i.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(i.tag=1,i.memoizedState=null,i.updateQueue=null,cr(m)?(w=!0,Qa(i)):w=!1,i.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,pc(i),f.updater=ho,i.stateNode=f,f._reactInternals=i,Lc(i,m,n,l),i=Pc(null,i,m,!0,w,l)):(i.tag=0,ut&&w&&sc(i),tr(null,i,f,l),i=i.child),i;case 16:m=i.elementType;e:{switch(fo(n,i),n=i.pendingProps,f=m._init,m=f(m._payload),i.type=m,f=i.tag=y2(m),n=Fr(m,n),f){case 0:i=Ac(null,i,m,n,l);break e;case 1:i=e0(null,i,m,n,l);break e;case 11:i=Kh(null,i,m,n,l);break e;case 14:i=Qh(null,i,m,Fr(m.type,n),l);break e}throw Error(s(306,m,""))}return i;case 0:return m=i.type,f=i.pendingProps,f=i.elementType===m?f:Fr(m,f),Ac(n,i,m,f,l);case 1:return m=i.type,f=i.pendingProps,f=i.elementType===m?f:Fr(m,f),e0(n,i,m,f,l);case 3:e:{if(t0(i),n===null)throw Error(s(387));m=i.pendingProps,w=i.memoizedState,f=w.element,xh(n,i),io(i,m,null,l);var C=i.memoizedState;if(m=C.element,w.isDehydrated)if(w={element:m,isDehydrated:!1,cache:C.cache,pendingSuspenseBoundaries:C.pendingSuspenseBoundaries,transitions:C.transitions},i.updateQueue.baseState=w,i.memoizedState=w,i.flags&256){f=zs(Error(s(423)),i),i=r0(n,i,m,l,f);break e}else if(m!==f){f=zs(Error(s(424)),i),i=r0(n,i,m,l,f);break e}else for(jr=Sn(i.stateNode.containerInfo.firstChild),br=i,ut=!0,Or=null,l=ph(i,null,m,l),i.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Ms(),m===f){i=hn(n,i,l);break e}tr(n,i,m,l)}i=i.child}return i;case 5:return vh(i),n===null&&oc(i),m=i.type,f=i.pendingProps,w=n!==null?n.memoizedProps:null,C=f.children,Xl(m,f)?C=null:w!==null&&Xl(m,w)&&(i.flags|=32),Zh(n,i),tr(n,i,C,l),i.child;case 6:return n===null&&oc(i),null;case 13:return n0(n,i,l);case 4:return fc(i,i.stateNode.containerInfo),m=i.pendingProps,n===null?i.child=Rs(i,null,m,l):tr(n,i,m,l),i.child;case 11:return m=i.type,f=i.pendingProps,f=i.elementType===m?f:Fr(m,f),Kh(n,i,m,f,l);case 7:return tr(n,i,i.pendingProps,l),i.child;case 8:return tr(n,i,i.pendingProps.children,l),i.child;case 12:return tr(n,i,i.pendingProps.children,l),i.child;case 10:e:{if(m=i.type._context,f=i.pendingProps,w=i.memoizedProps,C=f.value,st(ro,m._currentValue),m._currentValue=C,w!==null)if(zr(w.value,C)){if(w.children===f.children&&!lr.current){i=hn(n,i,l);break e}}else for(w=i.child,w!==null&&(w.return=i);w!==null;){var O=w.dependencies;if(O!==null){C=w.child;for(var Y=O.firstContext;Y!==null;){if(Y.context===m){if(w.tag===1){Y=mn(-1,l&-l),Y.tag=2;var se=w.updateQueue;if(se!==null){se=se.shared;var pe=se.pending;pe===null?Y.next=Y:(Y.next=pe.next,pe.next=Y),se.pending=Y}}w.lanes|=l,Y=w.alternate,Y!==null&&(Y.lanes|=l),mc(w.return,l,i),O.lanes|=l;break}Y=Y.next}}else if(w.tag===10)C=w.type===i.type?null:w.child;else if(w.tag===18){if(C=w.return,C===null)throw Error(s(341));C.lanes|=l,O=C.alternate,O!==null&&(O.lanes|=l),mc(C,l,i),C=w.sibling}else C=w.child;if(C!==null)C.return=w;else for(C=w;C!==null;){if(C===i){C=null;break}if(w=C.sibling,w!==null){w.return=C.return,C=w;break}C=C.return}w=C}tr(n,i,f.children,l),i=i.child}return i;case 9:return f=i.type,m=i.pendingProps.children,Ds(i,l),f=Ar(f),m=m(f),i.flags|=1,tr(n,i,m,l),i.child;case 14:return m=i.type,f=Fr(m,i.pendingProps),f=Fr(m.type,f),Qh(n,i,m,f,l);case 15:return Jh(n,i,i.type,i.pendingProps,l);case 17:return m=i.type,f=i.pendingProps,f=i.elementType===m?f:Fr(m,f),fo(n,i),i.tag=1,cr(m)?(n=!0,Qa(i)):n=!1,Ds(i,l),Wh(i,m,f),Lc(i,m,f,l),Pc(null,i,m,!0,n,l);case 19:return i0(n,i,l);case 22:return Xh(n,i,l)}throw Error(s(156,i.tag))};function E0(n,i){return lm(n,i)}function g2(n,i,l,m){this.tag=n,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=i,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=m,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Mr(n,i,l,m){return new g2(n,i,l,m)}function Xc(n){return n=n.prototype,!(!n||!n.isReactComponent)}function y2(n){if(typeof n=="function")return Xc(n)?1:0;if(n!=null){if(n=n.$$typeof,n===R)return 11;if(n===H)return 14}return 2}function Dn(n,i){var l=n.alternate;return l===null?(l=Mr(n.tag,i,n.key,n.mode),l.elementType=n.elementType,l.type=n.type,l.stateNode=n.stateNode,l.alternate=n,n.alternate=l):(l.pendingProps=i,l.type=n.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=n.flags&14680064,l.childLanes=n.childLanes,l.lanes=n.lanes,l.child=n.child,l.memoizedProps=n.memoizedProps,l.memoizedState=n.memoizedState,l.updateQueue=n.updateQueue,i=n.dependencies,l.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},l.sibling=n.sibling,l.index=n.index,l.ref=n.ref,l}function So(n,i,l,m,f,w){var C=2;if(m=n,typeof n=="function")Xc(n)&&(C=1);else if(typeof n=="string")C=5;else e:switch(n){case $:return ds(l.children,f,w,i);case V:C=8,f|=8;break;case B:return n=Mr(12,l,i,f|2),n.elementType=B,n.lanes=w,n;case X:return n=Mr(13,l,i,f),n.elementType=X,n.lanes=w,n;case I:return n=Mr(19,l,i,f),n.elementType=I,n.lanes=w,n;case J:return _o(l,f,w,i);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case U:C=10;break e;case D:C=9;break e;case R:C=11;break e;case H:C=14;break e;case W:C=16,m=null;break e}throw Error(s(130,n==null?n:typeof n,""))}return i=Mr(C,l,i,f),i.elementType=n,i.type=m,i.lanes=w,i}function ds(n,i,l,m){return n=Mr(7,n,m,i),n.lanes=l,n}function _o(n,i,l,m){return n=Mr(22,n,m,i),n.elementType=J,n.lanes=l,n.stateNode={isHidden:!1},n}function Zc(n,i,l){return n=Mr(6,n,null,i),n.lanes=l,n}function ed(n,i,l){return i=Mr(4,n.children!==null?n.children:[],n.key,i),i.lanes=l,i.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},i}function v2(n,i,l,m,f){this.tag=i,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=_l(0),this.expirationTimes=_l(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=_l(0),this.identifierPrefix=m,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function td(n,i,l,m,f,w,C,O,Y){return n=new v2(n,i,l,O,Y),i===1?(i=1,w===!0&&(i|=8)):i=0,w=Mr(3,null,null,i),n.current=w,w.stateNode=n,w.memoizedState={element:m,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},pc(w),n}function w2(n,i,l){var m=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:P,key:m==null?null:""+m,children:n,containerInfo:i,implementation:l}}function T0(n){if(!n)return Ln;n=n._reactInternals;e:{if(Xn(n)!==n||n.tag!==1)throw Error(s(170));var i=n;do{switch(i.tag){case 3:i=i.stateNode.context;break e;case 1:if(cr(i.type)){i=i.stateNode.__reactInternalMemoizedMergedChildContext;break e}}i=i.return}while(i!==null);throw Error(s(171))}if(n.tag===1){var l=n.type;if(cr(l))return sh(n,l,i)}return i}function A0(n,i,l,m,f,w,C,O,Y){return n=td(l,m,!0,n,f,w,C,O,Y),n.context=T0(null),l=n.current,m=rr(),f=Rn(l),w=mn(m,f),w.callback=i??null,An(l,w,f),n.current.lanes=f,gi(n,f,m),mr(n,m),n}function Lo(n,i,l,m){var f=i.current,w=rr(),C=Rn(f);return l=T0(l),i.context===null?i.context=l:i.pendingContext=l,i=mn(w,C),i.payload={element:n},m=m===void 0?null:m,m!==null&&(i.callback=m),n=An(f,i,C),n!==null&&(Ur(n,f,C,w),so(n,f,C)),C}function Eo(n){if(n=n.current,!n.child)return null;switch(n.child.tag){case 5:return n.child.stateNode;default:return n.child.stateNode}}function P0(n,i){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var l=n.retryLane;n.retryLane=l!==0&&l<i?l:i}}function rd(n,i){P0(n,i),(n=n.alternate)&&P0(n,i)}function b2(){return null}var I0=typeof reportError=="function"?reportError:function(n){console.error(n)};function nd(n){this._internalRoot=n}To.prototype.render=nd.prototype.render=function(n){var i=this._internalRoot;if(i===null)throw Error(s(409));Lo(n,i,null,null)},To.prototype.unmount=nd.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var i=n.containerInfo;os(function(){Lo(null,n,null,null)}),i[on]=null}};function To(n){this._internalRoot=n}To.prototype.unstable_scheduleHydration=function(n){if(n){var i=xm();n={blockedOn:null,target:n,priority:i};for(var l=0;l<kn.length&&i!==0&&i<kn[l].priority;l++);kn.splice(l,0,n),l===0&&vm(n)}};function sd(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function Ao(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11&&(n.nodeType!==8||n.nodeValue!==" react-mount-point-unstable "))}function M0(){}function j2(n,i,l,m,f){if(f){if(typeof m=="function"){var w=m;m=function(){var se=Eo(C);w.call(se)}}var C=A0(i,m,n,0,null,!1,!1,"",M0);return n._reactRootContainer=C,n[on]=C.current,Ai(n.nodeType===8?n.parentNode:n),os(),C}for(;f=n.lastChild;)n.removeChild(f);if(typeof m=="function"){var O=m;m=function(){var se=Eo(Y);O.call(se)}}var Y=td(n,0,!1,null,null,!1,!1,"",M0);return n._reactRootContainer=Y,n[on]=Y.current,Ai(n.nodeType===8?n.parentNode:n),os(function(){Lo(i,Y,l,m)}),Y}function Po(n,i,l,m,f){var w=l._reactRootContainer;if(w){var C=w;if(typeof f=="function"){var O=f;f=function(){var Y=Eo(C);O.call(Y)}}Lo(i,C,n,f)}else C=j2(l,i,n,f,m);return Eo(C)}pm=function(n){switch(n.tag){case 3:var i=n.stateNode;if(i.current.memoizedState.isDehydrated){var l=xi(i.pendingLanes);l!==0&&(Ll(i,l|1),mr(i,vt()),(Ge&6)===0&&(Ws=vt()+500,En()))}break;case 13:os(function(){var m=un(n,1);if(m!==null){var f=rr();Ur(m,n,1,f)}}),rd(n,1)}},El=function(n){if(n.tag===13){var i=un(n,134217728);if(i!==null){var l=rr();Ur(i,n,134217728,l)}rd(n,134217728)}},fm=function(n){if(n.tag===13){var i=Rn(n),l=un(n,i);if(l!==null){var m=rr();Ur(l,n,i,m)}rd(n,i)}},xm=function(){return nt},gm=function(n,i){var l=nt;try{return nt=n,i()}finally{nt=l}},Fe=function(n,i,l){switch(i){case"input":if(qe(n,l),i=l.name,l.type==="radio"&&i!=null){for(l=n;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll("input[name="+JSON.stringify(""+i)+'][type="radio"]'),i=0;i<l.length;i++){var m=l[i];if(m!==n&&m.form===n.form){var f=Ga(m);if(!f)throw Error(s(90));he(m),qe(m,f)}}}break;case"textarea":er(n,l);break;case"select":i=l.value,i!=null&&$t(n,!!l.multiple,i,!1)}},mt=Kc,Pe=os;var k2={usingClientEntryPoint:!1,Events:[Mi,Es,Ga,or,an,Kc]},Gi={findFiberByHostInstance:Zn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},N2={bundleType:Gi.bundleType,version:Gi.version,rendererPackageName:Gi.rendererPackageName,rendererConfig:Gi.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:_.ReactCurrentDispatcher,findHostInstanceByFiber:function(n){return n=am(n),n===null?null:n.stateNode},findFiberByHostInstance:Gi.findFiberByHostInstance||b2,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 Io=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Io.isDisabled&&Io.supportsFiber)try{Ea=Io.inject(N2),qr=Io}catch{}}return hr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=k2,hr.createPortal=function(n,i){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!sd(i))throw Error(s(200));return w2(n,i,null,l)},hr.createRoot=function(n,i){if(!sd(n))throw Error(s(299));var l=!1,m="",f=I0;return i!=null&&(i.unstable_strictMode===!0&&(l=!0),i.identifierPrefix!==void 0&&(m=i.identifierPrefix),i.onRecoverableError!==void 0&&(f=i.onRecoverableError)),i=td(n,1,!1,null,null,l,!1,m,f),n[on]=i.current,Ai(n.nodeType===8?n.parentNode:n),new nd(i)},hr.findDOMNode=function(n){if(n==null)return null;if(n.nodeType===1)return n;var i=n._reactInternals;if(i===void 0)throw typeof n.render=="function"?Error(s(188)):(n=Object.keys(n).join(","),Error(s(268,n)));return n=am(i),n=n===null?null:n.stateNode,n},hr.flushSync=function(n){return os(n)},hr.hydrate=function(n,i,l){if(!Ao(i))throw Error(s(200));return Po(null,n,i,!0,l)},hr.hydrateRoot=function(n,i,l){if(!sd(n))throw Error(s(405));var m=l!=null&&l.hydratedSources||null,f=!1,w="",C=I0;if(l!=null&&(l.unstable_strictMode===!0&&(f=!0),l.identifierPrefix!==void 0&&(w=l.identifierPrefix),l.onRecoverableError!==void 0&&(C=l.onRecoverableError)),i=A0(i,null,n,1,l??null,f,!1,w,C),n[on]=i.current,Ai(n),m)for(n=0;n<m.length;n++)l=m[n],f=l._getVersion,f=f(l._source),i.mutableSourceEagerHydrationData==null?i.mutableSourceEagerHydrationData=[l,f]:i.mutableSourceEagerHydrationData.push(l,f);return new To(i)},hr.render=function(n,i,l){if(!Ao(i))throw Error(s(200));return Po(null,n,i,!1,l)},hr.unmountComponentAtNode=function(n){if(!Ao(n))throw Error(s(40));return n._reactRootContainer?(os(function(){Po(null,null,n,!1,function(){n._reactRootContainer=null,n[on]=null})}),!0):!1},hr.unstable_batchedUpdates=Kc,hr.unstable_renderSubtreeIntoContainer=function(n,i,l,m){if(!Ao(l))throw Error(s(200));if(n==null||n._reactInternals===void 0)throw Error(s(38));return Po(n,i,l,!1,m)},hr.version="18.3.1-next-f1338f8080-20240426",hr}var W0;function zf(){if(W0)return od.exports;W0=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(r){console.error(r)}}return e(),od.exports=I2(),od.exports}var H0;function M2(){if(H0)return Mo;H0=1;var e=zf();return Mo.createRoot=e.createRoot,Mo.hydrateRoot=e.hydrateRoot,Mo}var R2=M2();const $2=ul(R2);zf();/**
|
|
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 la(){return la=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var s=arguments[r];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e},la.apply(this,arguments)}var Fn;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(Fn||(Fn={}));const U0="popstate";function D2(e){e===void 0&&(e={});function r(a,o){let{pathname:c,search:d,hash:u}=a.location;return Rd("",{pathname:c,search:d,hash:u},o.state&&o.state.usr||null,o.state&&o.state.key||"default")}function s(a,o){return typeof o=="string"?o:Vo(o)}return z2(r,s,null,e)}function kt(e,r){if(e===!1||e===null||typeof e>"u")throw new Error(r)}function cu(e,r){if(!e){typeof console<"u"&&console.warn(r);try{throw new Error(r)}catch{}}}function B2(){return Math.random().toString(36).substr(2,8)}function V0(e,r){return{usr:e.state,key:e.key,idx:r}}function Rd(e,r,s,a){return s===void 0&&(s=null),la({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof r=="string"?si(r):r,{state:s,key:r&&r.key||a||B2()})}function Vo(e){let{pathname:r="/",search:s="",hash:a=""}=e;return s&&s!=="?"&&(r+=s.charAt(0)==="?"?s:"?"+s),a&&a!=="#"&&(r+=a.charAt(0)==="#"?a:"#"+a),r}function si(e){let r={};if(e){let s=e.indexOf("#");s>=0&&(r.hash=e.substr(s),e=e.substr(0,s));let a=e.indexOf("?");a>=0&&(r.search=e.substr(a),e=e.substr(0,a)),e&&(r.pathname=e)}return r}function z2(e,r,s,a){a===void 0&&(a={});let{window:o=document.defaultView,v5Compat:c=!1}=a,d=o.history,u=Fn.Pop,h=null,p=x();p==null&&(p=0,d.replaceState(la({},d.state,{idx:p}),""));function x(){return(d.state||{idx:null}).idx}function g(){u=Fn.Pop;let N=x(),j=N==null?null:N-p;p=N,h&&h({action:u,location:T.location,delta:j})}function b(N,j){u=Fn.Push;let A=Rd(T.location,N,j);p=x()+1;let M=V0(A,p),_=T.createHref(A);try{d.pushState(M,"",_)}catch(z){if(z instanceof DOMException&&z.name==="DataCloneError")throw z;o.location.assign(_)}c&&h&&h({action:u,location:T.location,delta:1})}function v(N,j){u=Fn.Replace;let A=Rd(T.location,N,j);p=x();let M=V0(A,p),_=T.createHref(A);d.replaceState(M,"",_),c&&h&&h({action:u,location:T.location,delta:0})}function k(N){let j=o.location.origin!=="null"?o.location.origin:o.location.href,A=typeof N=="string"?N:Vo(N);return A=A.replace(/ $/,"%20"),kt(j,"No window.location.(origin|href) available to create URL for href: "+A),new URL(A,j)}let T={get action(){return u},get location(){return e(o,d)},listen(N){if(h)throw new Error("A history only accepts one active listener");return o.addEventListener(U0,g),h=N,()=>{o.removeEventListener(U0,g),h=null}},createHref(N){return r(o,N)},createURL:k,encodeLocation(N){let j=k(N);return{pathname:j.pathname,search:j.search,hash:j.hash}},push:b,replace:v,go(N){return d.go(N)}};return T}var q0;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(q0||(q0={}));function O2(e,r,s){return s===void 0&&(s="/"),F2(e,r,s)}function F2(e,r,s,a){let o=typeof r=="string"?si(r):r,c=du(o.pathname||"/",s);if(c==null)return null;let d=Of(e);W2(d);let u=null;for(let h=0;u==null&&h<d.length;++h){let p=ew(c);u=J2(d[h],p)}return u}function Of(e,r,s,a){r===void 0&&(r=[]),s===void 0&&(s=[]),a===void 0&&(a="");let o=(c,d,u)=>{let h={relativePath:u===void 0?c.path||"":u,caseSensitive:c.caseSensitive===!0,childrenIndex:d,route:c};h.relativePath.startsWith("/")&&(kt(h.relativePath.startsWith(a),'Absolute route path "'+h.relativePath+'" nested under path '+('"'+a+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),h.relativePath=h.relativePath.slice(a.length));let p=qn([a,h.relativePath]),x=s.concat(h);c.children&&c.children.length>0&&(kt(c.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+p+'".')),Of(c.children,r,x,p)),!(c.path==null&&!c.index)&&r.push({path:p,score:K2(p,c.index),routesMeta:x})};return e.forEach((c,d)=>{var u;if(c.path===""||!((u=c.path)!=null&&u.includes("?")))o(c,d);else for(let h of Ff(c.path))o(c,d,h)}),r}function Ff(e){let r=e.split("/");if(r.length===0)return[];let[s,...a]=r,o=s.endsWith("?"),c=s.replace(/\?$/,"");if(a.length===0)return o?[c,""]:[c];let d=Ff(a.join("/")),u=[];return u.push(...d.map(h=>h===""?c:[c,h].join("/"))),o&&u.push(...d),u.map(h=>e.startsWith("/")&&h===""?"/":h)}function W2(e){e.sort((r,s)=>r.score!==s.score?s.score-r.score:Q2(r.routesMeta.map(a=>a.childrenIndex),s.routesMeta.map(a=>a.childrenIndex)))}const H2=/^:[\w-]+$/,U2=3,V2=2,q2=1,Y2=10,G2=-2,Y0=e=>e==="*";function K2(e,r){let s=e.split("/"),a=s.length;return s.some(Y0)&&(a+=G2),r&&(a+=V2),s.filter(o=>!Y0(o)).reduce((o,c)=>o+(H2.test(c)?U2:c===""?q2:Y2),a)}function Q2(e,r){return e.length===r.length&&e.slice(0,-1).every((a,o)=>a===r[o])?e[e.length-1]-r[r.length-1]:0}function J2(e,r,s){let{routesMeta:a}=e,o={},c="/",d=[];for(let u=0;u<a.length;++u){let h=a[u],p=u===a.length-1,x=c==="/"?r:r.slice(c.length)||"/",g=X2({path:h.relativePath,caseSensitive:h.caseSensitive,end:p},x),b=h.route;if(!g)return null;Object.assign(o,g.params),d.push({params:o,pathname:qn([c,g.pathname]),pathnameBase:iw(qn([c,g.pathnameBase])),route:b}),g.pathnameBase!=="/"&&(c=qn([c,g.pathnameBase]))}return d}function X2(e,r){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[s,a]=Z2(e.path,e.caseSensitive,e.end),o=r.match(s);if(!o)return null;let c=o[0],d=c.replace(/(.)\/+$/,"$1"),u=o.slice(1);return{params:a.reduce((p,x,g)=>{let{paramName:b,isOptional:v}=x;if(b==="*"){let T=u[g]||"";d=c.slice(0,c.length-T.length).replace(/(.)\/+$/,"$1")}const k=u[g];return v&&!k?p[b]=void 0:p[b]=(k||"").replace(/%2F/g,"/"),p},{}),pathname:c,pathnameBase:d,pattern:e}}function Z2(e,r,s){r===void 0&&(r=!1),s===void 0&&(s=!0),cu(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let a=[],o="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(d,u,h)=>(a.push({paramName:u,isOptional:h!=null}),h?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(a.push({paramName:"*"}),o+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):s?o+="\\/*$":e!==""&&e!=="/"&&(o+="(?:(?=\\/|$))"),[new RegExp(o,r?void 0:"i"),a]}function ew(e){try{return e.split("/").map(r=>decodeURIComponent(r).replace(/\//g,"%2F")).join("/")}catch(r){return cu(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+r+").")),e}}function du(e,r){if(r==="/")return e;if(!e.toLowerCase().startsWith(r.toLowerCase()))return null;let s=r.endsWith("/")?r.length-1:r.length,a=e.charAt(s);return a&&a!=="/"?null:e.slice(s)||"/"}const tw=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,rw=e=>tw.test(e);function nw(e,r){r===void 0&&(r="/");let{pathname:s,search:a="",hash:o=""}=typeof e=="string"?si(e):e,c;if(s)if(rw(s))c=s;else{if(s.includes("//")){let d=s;s=s.replace(/\/\/+/g,"/"),cu(!1,"Pathnames cannot have embedded double slashes - normalizing "+(d+" -> "+s))}s.startsWith("/")?c=G0(s.substring(1),"/"):c=G0(s,r)}else c=r;return{pathname:c,search:aw(a),hash:ow(o)}}function G0(e,r){let s=r.replace(/\/+$/,"").split("/");return e.split("/").forEach(o=>{o===".."?s.length>1&&s.pop():o!=="."&&s.push(o)}),s.length>1?s.join("/"):"/"}function dd(e,r,s,a){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+r+"` field ["+JSON.stringify(a)+"]. Please separate it out to the ")+("`to."+s+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function sw(e){return e.filter((r,s)=>s===0||r.route.path&&r.route.path.length>0)}function uu(e,r){let s=sw(e);return r?s.map((a,o)=>o===s.length-1?a.pathname:a.pathnameBase):s.map(a=>a.pathnameBase)}function mu(e,r,s,a){a===void 0&&(a=!1);let o;typeof e=="string"?o=si(e):(o=la({},e),kt(!o.pathname||!o.pathname.includes("?"),dd("?","pathname","search",o)),kt(!o.pathname||!o.pathname.includes("#"),dd("#","pathname","hash",o)),kt(!o.search||!o.search.includes("#"),dd("#","search","hash",o)));let c=e===""||o.pathname==="",d=c?"/":o.pathname,u;if(d==null)u=s;else{let g=r.length-1;if(!a&&d.startsWith("..")){let b=d.split("/");for(;b[0]==="..";)b.shift(),g-=1;o.pathname=b.join("/")}u=g>=0?r[g]:"/"}let h=nw(o,u),p=d&&d!=="/"&&d.endsWith("/"),x=(c||d===".")&&s.endsWith("/");return!h.pathname.endsWith("/")&&(p||x)&&(h.pathname+="/"),h}const qn=e=>e.join("/").replace(/\/\/+/g,"/"),iw=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),aw=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,ow=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function lw(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const Wf=["post","put","patch","delete"];new Set(Wf);const cw=["get",...Wf];new Set(cw);/**
|
|
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 ca(){return ca=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var s=arguments[r];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e},ca.apply(this,arguments)}const hu=y.createContext(null),dw=y.createContext(null),Kn=y.createContext(null),ml=y.createContext(null),nn=y.createContext({outlet:null,matches:[],isDataRoute:!1}),Hf=y.createContext(null);function uw(e,r){let{relative:s}=r===void 0?{}:r;ii()||kt(!1);let{basename:a,navigator:o}=y.useContext(Kn),{hash:c,pathname:d,search:u}=Vf(e,{relative:s}),h=d;return a!=="/"&&(h=d==="/"?a:qn([a,d])),o.createHref({pathname:h,search:u,hash:c})}function ii(){return y.useContext(ml)!=null}function Qn(){return ii()||kt(!1),y.useContext(ml).location}function Uf(e){y.useContext(Kn).static||y.useLayoutEffect(e)}function Dr(){let{isDataRoute:e}=y.useContext(nn);return e?Sw():mw()}function mw(){ii()||kt(!1);let e=y.useContext(hu),{basename:r,future:s,navigator:a}=y.useContext(Kn),{matches:o}=y.useContext(nn),{pathname:c}=Qn(),d=JSON.stringify(uu(o,s.v7_relativeSplatPath)),u=y.useRef(!1);return Uf(()=>{u.current=!0}),y.useCallback(function(p,x){if(x===void 0&&(x={}),!u.current)return;if(typeof p=="number"){a.go(p);return}let g=mu(p,JSON.parse(d),c,x.relative==="path");e==null&&r!=="/"&&(g.pathname=g.pathname==="/"?r:qn([r,g.pathname])),(x.replace?a.replace:a.push)(g,x.state,x)},[r,a,d,c,e])}const hw=y.createContext(null);function pw(e){let r=y.useContext(nn).outlet;return r&&y.createElement(hw.Provider,{value:e},r)}function Vr(){let{matches:e}=y.useContext(nn),r=e[e.length-1];return r?r.params:{}}function Vf(e,r){let{relative:s}=r===void 0?{}:r,{future:a}=y.useContext(Kn),{matches:o}=y.useContext(nn),{pathname:c}=Qn(),d=JSON.stringify(uu(o,a.v7_relativeSplatPath));return y.useMemo(()=>mu(e,JSON.parse(d),c,s==="path"),[e,d,c,s])}function fw(e,r){return xw(e,r)}function xw(e,r,s,a){ii()||kt(!1);let{navigator:o}=y.useContext(Kn),{matches:c}=y.useContext(nn),d=c[c.length-1],u=d?d.params:{};d&&d.pathname;let h=d?d.pathnameBase:"/";d&&d.route;let p=Qn(),x;if(r){var g;let N=typeof r=="string"?si(r):r;h==="/"||(g=N.pathname)!=null&&g.startsWith(h)||kt(!1),x=N}else x=p;let b=x.pathname||"/",v=b;if(h!=="/"){let N=h.replace(/^\//,"").split("/");v="/"+b.replace(/^\//,"").split("/").slice(N.length).join("/")}let k=O2(e,{pathname:v}),T=bw(k&&k.map(N=>Object.assign({},N,{params:Object.assign({},u,N.params),pathname:qn([h,o.encodeLocation?o.encodeLocation(N.pathname).pathname:N.pathname]),pathnameBase:N.pathnameBase==="/"?h:qn([h,o.encodeLocation?o.encodeLocation(N.pathnameBase).pathname:N.pathnameBase])})),c,s,a);return r&&T?y.createElement(ml.Provider,{value:{location:ca({pathname:"/",search:"",hash:"",state:null,key:"default"},x),navigationType:Fn.Pop}},T):T}function gw(){let e=Cw(),r=lw(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),s=e instanceof Error?e.stack:null,o={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return y.createElement(y.Fragment,null,y.createElement("h2",null,"Unexpected Application Error!"),y.createElement("h3",{style:{fontStyle:"italic"}},r),s?y.createElement("pre",{style:o},s):null,null)}const yw=y.createElement(gw,null);class vw extends y.Component{constructor(r){super(r),this.state={location:r.location,revalidation:r.revalidation,error:r.error}}static getDerivedStateFromError(r){return{error:r}}static getDerivedStateFromProps(r,s){return s.location!==r.location||s.revalidation!=="idle"&&r.revalidation==="idle"?{error:r.error,location:r.location,revalidation:r.revalidation}:{error:r.error!==void 0?r.error:s.error,location:s.location,revalidation:r.revalidation||s.revalidation}}componentDidCatch(r,s){console.error("React Router caught the following error during render",r,s)}render(){return this.state.error!==void 0?y.createElement(nn.Provider,{value:this.props.routeContext},y.createElement(Hf.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function ww(e){let{routeContext:r,match:s,children:a}=e,o=y.useContext(hu);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),y.createElement(nn.Provider,{value:r},a)}function bw(e,r,s,a){var o;if(r===void 0&&(r=[]),s===void 0&&(s=null),a===void 0&&(a=null),e==null){var c;if(!s)return null;if(s.errors)e=s.matches;else if((c=a)!=null&&c.v7_partialHydration&&r.length===0&&!s.initialized&&s.matches.length>0)e=s.matches;else return null}let d=e,u=(o=s)==null?void 0:o.errors;if(u!=null){let x=d.findIndex(g=>g.route.id&&(u==null?void 0:u[g.route.id])!==void 0);x>=0||kt(!1),d=d.slice(0,Math.min(d.length,x+1))}let h=!1,p=-1;if(s&&a&&a.v7_partialHydration)for(let x=0;x<d.length;x++){let g=d[x];if((g.route.HydrateFallback||g.route.hydrateFallbackElement)&&(p=x),g.route.id){let{loaderData:b,errors:v}=s,k=g.route.loader&&b[g.route.id]===void 0&&(!v||v[g.route.id]===void 0);if(g.route.lazy||k){h=!0,p>=0?d=d.slice(0,p+1):d=[d[0]];break}}}return d.reduceRight((x,g,b)=>{let v,k=!1,T=null,N=null;s&&(v=u&&g.route.id?u[g.route.id]:void 0,T=g.route.errorElement||yw,h&&(p<0&&b===0?(_w("route-fallback"),k=!0,N=null):p===b&&(k=!0,N=g.route.hydrateFallbackElement||null)));let j=r.concat(d.slice(0,b+1)),A=()=>{let M;return v?M=T:k?M=N:g.route.Component?M=y.createElement(g.route.Component,null):g.route.element?M=g.route.element:M=x,y.createElement(ww,{match:g,routeContext:{outlet:x,matches:j,isDataRoute:s!=null},children:M})};return s&&(g.route.ErrorBoundary||g.route.errorElement||b===0)?y.createElement(vw,{location:s.location,revalidation:s.revalidation,component:T,error:v,children:A(),routeContext:{outlet:null,matches:j,isDataRoute:!0}}):A()},null)}var qf=(function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e})(qf||{}),Yf=(function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e})(Yf||{});function jw(e){let r=y.useContext(hu);return r||kt(!1),r}function kw(e){let r=y.useContext(dw);return r||kt(!1),r}function Nw(e){let r=y.useContext(nn);return r||kt(!1),r}function Gf(e){let r=Nw(),s=r.matches[r.matches.length-1];return s.route.id||kt(!1),s.route.id}function Cw(){var e;let r=y.useContext(Hf),s=kw(),a=Gf();return r!==void 0?r:(e=s.errors)==null?void 0:e[a]}function Sw(){let{router:e}=jw(qf.UseNavigateStable),r=Gf(Yf.UseNavigateStable),s=y.useRef(!1);return Uf(()=>{s.current=!0}),y.useCallback(function(o,c){c===void 0&&(c={}),s.current&&(typeof o=="number"?e.navigate(o):e.navigate(o,ca({fromRouteId:r},c)))},[e,r])}const K0={};function _w(e,r,s){K0[e]||(K0[e]=!0)}function Lw(e,r){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function Q0(e){let{to:r,replace:s,state:a,relative:o}=e;ii()||kt(!1);let{future:c,static:d}=y.useContext(Kn),{matches:u}=y.useContext(nn),{pathname:h}=Qn(),p=Dr(),x=mu(r,uu(u,c.v7_relativeSplatPath),h,o==="path"),g=JSON.stringify(x);return y.useEffect(()=>p(JSON.parse(g),{replace:s,state:a,relative:o}),[p,g,o,s,a]),null}function Ew(e){return pw(e.context)}function Pt(e){kt(!1)}function Tw(e){let{basename:r="/",children:s=null,location:a,navigationType:o=Fn.Pop,navigator:c,static:d=!1,future:u}=e;ii()&&kt(!1);let h=r.replace(/^\/*/,"/"),p=y.useMemo(()=>({basename:h,navigator:c,static:d,future:ca({v7_relativeSplatPath:!1},u)}),[h,u,c,d]);typeof a=="string"&&(a=si(a));let{pathname:x="/",search:g="",hash:b="",state:v=null,key:k="default"}=a,T=y.useMemo(()=>{let N=du(x,h);return N==null?null:{location:{pathname:N,search:g,hash:b,state:v,key:k},navigationType:o}},[h,x,g,b,v,k,o]);return T==null?null:y.createElement(Kn.Provider,{value:p},y.createElement(ml.Provider,{children:s,value:T}))}function Aw(e){let{children:r,location:s}=e;return fw($d(r),s)}new Promise(()=>{});function $d(e,r){r===void 0&&(r=[]);let s=[];return y.Children.forEach(e,(a,o)=>{if(!y.isValidElement(a))return;let c=[...r,o];if(a.type===y.Fragment){s.push.apply(s,$d(a.props.children,c));return}a.type!==Pt&&kt(!1),!a.props.index||!a.props.children||kt(!1);let d={id:a.props.id||c.join("-"),caseSensitive:a.props.caseSensitive,element:a.props.element,Component:a.props.Component,index:a.props.index,path:a.props.path,loader:a.props.loader,action:a.props.action,errorElement:a.props.errorElement,ErrorBoundary:a.props.ErrorBoundary,hasErrorBoundary:a.props.ErrorBoundary!=null||a.props.errorElement!=null,shouldRevalidate:a.props.shouldRevalidate,handle:a.props.handle,lazy:a.props.lazy};a.props.children&&(d.children=$d(a.props.children,c)),s.push(d)}),s}/**
|
|
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 Dd(){return Dd=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var s=arguments[r];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e},Dd.apply(this,arguments)}function Pw(e,r){if(e==null)return{};var s={},a=Object.keys(e),o,c;for(c=0;c<a.length;c++)o=a[c],!(r.indexOf(o)>=0)&&(s[o]=e[o]);return s}function Iw(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Mw(e,r){return e.button===0&&(!r||r==="_self")&&!Iw(e)}function Bd(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((r,s)=>{let a=e[s];return r.concat(Array.isArray(a)?a.map(o=>[s,o]):[[s,a]])},[]))}function Rw(e,r){let s=Bd(e);return r&&r.forEach((a,o)=>{s.has(o)||r.getAll(o).forEach(c=>{s.append(o,c)})}),s}const $w=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],Dw="6";try{window.__reactRouterVersion=Dw}catch{}const Bw="startTransition",J0=T2[Bw];function zw(e){let{basename:r,children:s,future:a,window:o}=e,c=y.useRef();c.current==null&&(c.current=D2({window:o,v5Compat:!0}));let d=c.current,[u,h]=y.useState({action:d.action,location:d.location}),{v7_startTransition:p}=a||{},x=y.useCallback(g=>{p&&J0?J0(()=>h(g)):h(g)},[h,p]);return y.useLayoutEffect(()=>d.listen(x),[d,x]),y.useEffect(()=>Lw(a),[a]),y.createElement(Tw,{basename:r,children:s,location:u.location,navigationType:u.action,navigator:d,future:a})}const Ow=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Fw=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Re=y.forwardRef(function(r,s){let{onClick:a,relative:o,reloadDocument:c,replace:d,state:u,target:h,to:p,preventScrollReset:x,viewTransition:g}=r,b=Pw(r,$w),{basename:v}=y.useContext(Kn),k,T=!1;if(typeof p=="string"&&Fw.test(p)&&(k=p,Ow))try{let M=new URL(window.location.href),_=p.startsWith("//")?new URL(M.protocol+p):new URL(p),z=du(_.pathname,v);_.origin===M.origin&&z!=null?p=z+_.search+_.hash:T=!0}catch{}let N=uw(p,{relative:o}),j=Ww(p,{replace:d,state:u,target:h,preventScrollReset:x,relative:o,viewTransition:g});function A(M){a&&a(M),M.defaultPrevented||j(M)}return y.createElement("a",Dd({},b,{href:k||N,onClick:T||c?a:A,ref:s,target:h}))});var X0;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(X0||(X0={}));var Z0;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Z0||(Z0={}));function Ww(e,r){let{target:s,replace:a,state:o,preventScrollReset:c,relative:d,viewTransition:u}=r===void 0?{}:r,h=Dr(),p=Qn(),x=Vf(e,{relative:d});return y.useCallback(g=>{if(Mw(g,s)){g.preventDefault();let b=a!==void 0?a:Vo(p)===Vo(x);h(e,{replace:b,state:o,preventScrollReset:c,relative:d,viewTransition:u})}},[p,h,x,a,o,s,e,c,d,u])}function Hw(e){let r=y.useRef(Bd(e)),s=y.useRef(!1),a=Qn(),o=y.useMemo(()=>Rw(a.search,s.current?null:r.current),[a.search]),c=Dr(),d=y.useCallback((u,h)=>{const p=Bd(typeof u=="function"?u(o):u);s.current=!0,c("?"+p,h)},[c,o]);return[o,d]}const ep=e=>{let r;const s=new Set,a=(p,x)=>{const g=typeof p=="function"?p(r):p;if(!Object.is(g,r)){const b=r;r=x??(typeof g!="object"||g===null)?g:Object.assign({},r,g),s.forEach(v=>v(r,b))}},o=()=>r,u={setState:a,getState:o,getInitialState:()=>h,subscribe:p=>(s.add(p),()=>s.delete(p))},h=r=e(a,o,u);return u},Uw=(e=>e?ep(e):ep),Vw=e=>e;function qw(e,r=Vw){const s=Ks.useSyncExternalStore(e.subscribe,Ks.useCallback(()=>r(e.getState()),[e,r]),Ks.useCallback(()=>r(e.getInitialState()),[e,r]));return Ks.useDebugValue(s),s}const tp=e=>{const r=Uw(e),s=a=>qw(r,a);return Object.assign(s,r),s},Yw=(e=>e?tp(e):tp),gs="/api";class ai extends Error{constructor(r,s,a){super(r),this.status=s,this.code=a,this.name="APIError"}}async function le(e,r={}){var o,c;const s=`${gs}${e}`,a=await fetch(s,{...r,headers:{"Content-Type":"application/json",...r.headers}});if(!a.ok){const d=await a.json().catch(()=>({})),u=((o=d.error)==null?void 0:o.message)||d.detail||a.statusText;throw new ai(u,a.status,(c=d.error)==null?void 0:c.code)}if(a.status!==204)return a.json()}async function Kf(){return le("/health")}async function zd(){return le("/projects")}async function ys(e){return le(`/projects/${e}`)}async function Gw(e){return le("/projects",{method:"POST",body:JSON.stringify(e)})}async function Kw(e){return le(`/projects/${e}`,{method:"DELETE"})}async function Qw(e="^e2e-",r=!0){return le("/projects/cleanup",{method:"POST",body:JSON.stringify({pattern:e,dry_run:r})})}async function pu(e){return le(`/projects/${e}/loops`)}async function rp(e,r){return le(`/projects/${e}/loops/${r}`)}async function Qf(e,r){return le(`/projects/${e}/loops/${r}/status`)}async function Od(e,r,s){return le(`/projects/${e}/loops/${r}/start`,{method:"POST",body:JSON.stringify(s||{})})}async function Jw(e,r){return le(`/projects/${e}/loops/${r}/phases`)}async function Xw(e,r){return le(`/projects/${e}/loops/${r}/stop`,{method:"POST"})}async function Zw(e,r){return le(`/projects/${e}/loops/${r}/pause`,{method:"POST"})}async function eb(e,r){return le(`/projects/${e}/loops/${r}/resume`,{method:"POST"})}async function tb(e,r){return le(`/projects/${e}/loops/${r}`,{method:"DELETE"})}async function rb(e,r){return le(`/projects/${e}/loops/${r}/config`)}async function nb(e,r,s){return le(`/projects/${e}/loops/${r}/config`,{method:"PUT",body:JSON.stringify({content:s})})}async function xa(e,r){const s=new URLSearchParams;r!=null&&r.status&&s.set("status",r.status),r!=null&&r.category&&s.set("category",r.category),r!=null&&r.workflow_id&&s.set("workflow_id",r.workflow_id),r!=null&&r.source_step_id&&s.set("source_step_id",r.source_step_id.toString()),r!=null&&r.limit&&s.set("limit",r.limit.toString()),r!=null&&r.offset&&s.set("offset",r.offset.toString());const a=s.toString();return le(`/projects/${e}/items${a?`?${a}`:""}`)}async function sb(e,r){return le(`/projects/${e}/items/${r}`)}async function fu(e,r){return le(`/projects/${e}/items`,{method:"POST",body:JSON.stringify(r)})}async function xu(e,r,s){return le(`/projects/${e}/items/${r}`,{method:"PATCH",body:JSON.stringify(s)})}async function ib(e,r,s){const a=await sb(e,r);return fu(e,{workflow_id:a.workflow_id,source_step_id:a.source_step_id,title:(s==null?void 0:s.title)??(a.title?`${a.title} (copy)`:void 0),content:(s==null?void 0:s.content)??a.content,category:(s==null?void 0:s.category)??a.category,priority:(s==null?void 0:s.priority)??a.priority,dependencies:(s==null?void 0:s.dependencies)??a.dependencies,metadata:a.metadata})}async function Jf(e,r){return le(`/projects/${e}/items/${r}`,{method:"DELETE"})}async function ab(e){return le(`/projects/${e}/items/stats`)}async function ob(e){const r=e?`?path=${encodeURIComponent(e)}`:"";return le(`/filesystem/browse${r}`)}async function np(e,r){return le(`/projects/${e}/loops/${r}/ready-check`)}async function lb(e,r){return le(`/projects/${e}/loops/${r}/ready-check`,{method:"POST"})}async function cb(e,r,s,a){return le(`/projects/${e}/loops/${r}/ready-check/answers`,{method:"POST",body:JSON.stringify({questions:s,answers:a})})}async function db(e,r){return le(`/projects/${e}/runs`)}async function ub(e,r){return le(`/projects/${e}/runs/${r}`)}async function mb(){return le("/templates")}async function hb(e){return le(`/templates/${e}`)}async function pb(e){return le(`/step-prompts/${e}`)}async function fb(){return le("/projects/permission-templates")}async function xb(e,r){return le(`/projects/${e}/loops/${r}/permissions`)}async function sp(e,r,s){return le(`/projects/${e}/loops/${r}/permissions`,{method:"PUT",body:JSON.stringify(s)})}async function gb(e,r){return le(`/projects/${e}/loops/${r}/permissions`,{method:"DELETE"})}async function yb(e,r){return le(`/projects/${e}/loops/${r}/inputs`)}async function vb(e,r,s){var c,d;const a=new FormData;a.append("file",s);const o=await fetch(`${gs}/projects/${e}/loops/${r}/inputs/upload`,{method:"POST",body:a});if(!o.ok){const u=await o.json().catch(()=>({})),h=((c=u.error)==null?void 0:c.message)||u.detail||o.statusText;throw new ai(h,o.status,(d=u.error)==null?void 0:d.code)}return o.json()}async function wb(e,r,s,a,o){return le(`/projects/${e}/loops/${r}/inputs/paste`,{method:"POST",body:JSON.stringify({content:s,filename:a,tag:o})})}async function bb(e,r,s){return le(`/projects/${e}/loops/${r}/inputs/${encodeURIComponent(s)}`,{method:"DELETE"})}async function jb(e,r,s){return le(`/projects/${e}/loops/${r}/preview`,{method:"POST",body:JSON.stringify(s||{})})}async function kb(e,r){const s=new URLSearchParams;r!=null&&r.resource_type&&s.set("resource_type",r.resource_type),(r==null?void 0:r.enabled)!==void 0&&s.set("enabled",r.enabled.toString()),(r==null?void 0:r.include_content)!==void 0&&s.set("include_content",r.include_content.toString());const a=s.toString();return le(`/projects/${e}/resources${a?`?${a}`:""}`)}async function Xf(e){return le(`/projects/${e}/design-doc-files`)}async function Nb(e,r){return le(`/projects/${e}/design-doc-files/${r}`)}async function Cb(e,r){return le(`/projects/${e}/design-doc-files/create?name=${encodeURIComponent(r)}`,{method:"POST"})}async function Sb(e,r){return le(`/projects/${e}/design-doc-files/${r}/backups`)}async function _b(e,r,s,a){return le(`/projects/${e}/design-doc-files/${encodeURIComponent(r)}/diff?left=${encodeURIComponent(s)}&right=${encodeURIComponent(a)}`)}async function Lb(e,r,s){return le(`/projects/${e}/design-doc-files/${encodeURIComponent(r)}/restore`,{method:"POST",body:JSON.stringify({backup_name:s})})}async function ud(e,r){const s=r?`?path=${encodeURIComponent(r)}`:"";return le(`/projects/${e}/files/browse${s}`)}async function Eb(e){const r=e?`?loop_type=${encodeURIComponent(e)}`:"";return le(`/projects/input-templates${r}`)}async function Tb(e){return le(`/projects/input-templates/${encodeURIComponent(e)}`)}async function Ab(e,r,s,a){return le(`/projects/${e}/loops/${r}/inputs/apply-template`,{method:"POST",body:JSON.stringify({template_id:s,custom_filename:a})})}async function Pb(e,r,s){return le(`/projects/${e}/loops/${r}/inputs/validate?loop_type=${encodeURIComponent(s)}`)}async function Zf(e=!1){return le(`/auth/accounts${e?"?include_inactive=true":""}`)}async function Ib(e){const r=e?`?expected_email=${encodeURIComponent(e)}`:"";return le(`/auth/accounts/add${r}`,{method:"POST"})}async function Mb(e){return le(`/auth/flow/${e}`)}async function Rb(e,r){return le(`/auth/accounts/${e}`,{method:"PATCH",body:JSON.stringify(r)})}async function $b(e){return le(`/auth/accounts/${e}`,{method:"DELETE"})}async function Db(e){return le(`/auth/accounts/${e}/set-default`,{method:"POST"})}async function Bb(e){return le(`/auth/accounts/${e}/refresh`,{method:"POST"})}async function zb(e){return le(`/auth/accounts/${e}/refresh-usage`,{method:"POST"})}async function Ob(e){return le(`/auth/accounts/${e}/validate`,{method:"POST"})}async function Fb(){return le("/auth/accounts/refresh-all-usage",{method:"POST"})}async function Wb(e){return le(`/auth/projects/${e}/account`)}async function ip(e,r){return le(`/auth/projects/${e}/account`,{method:"POST",body:JSON.stringify(r)})}async function Hb(e){return le(`/auth/projects/${e}/account`,{method:"DELETE"})}async function Ub(e){return le(`/auth/projects/${e}/effective-account`)}async function Vb(e={}){const r=new URLSearchParams;return e.level&&r.set("level",e.level),e.category&&r.set("category",e.category),e.event&&r.set("event",e.event),e.project_id&&r.set("project_id",e.project_id),e.run_id&&r.set("run_id",e.run_id),e.since&&r.set("since",e.since),e.until&&r.set("until",e.until),e.limit&&r.set("limit",String(e.limit)),e.offset&&r.set("offset",String(e.offset)),le(`/logs?${r}`)}async function qb(){return le("/logs/stats")}async function ap(e,r,s=!1){return le(`/projects/${e}/loops/${r}/resources${s?"?include_content=true":""}`)}async function Yb(e,r,s){return le(`/projects/${e}/loops/${r}/resources`,{method:"POST",body:JSON.stringify(s)})}async function op(e,r,s,a){return le(`/projects/${e}/loops/${r}/resources/${s}`,{method:"PATCH",body:JSON.stringify(a)})}async function Gb(e,r,s){return le(`/projects/${e}/loops/${r}/resources/${s}`,{method:"DELETE"})}async function qo(e,r){const s=new URLSearchParams;r!=null&&r.status&&s.set("status_filter",r.status),r!=null&&r.include_archived&&s.set("include_archived","true"),r!=null&&r.archived_only&&s.set("archived_only","true");const a=s.toString();return le(`/projects/${e}/workflows${a?`?${a}`:""}`)}async function ga(e,r){return le(`/projects/${e}/workflows/${r}`)}async function Kb(e,r){return le(`/projects/${e}/workflows`,{method:"POST",body:JSON.stringify(r)})}async function Qb(e,r,s){return le(`/projects/${e}/workflows/${r}`,{method:"PATCH",body:JSON.stringify(s)})}async function Jb(e,r){return le(`/projects/${e}/workflows/${r}`,{method:"DELETE"})}async function Xb(e,r){return le(`/projects/${e}/workflows/${r}/archive`,{method:"POST"})}async function Zb(e,r){return le(`/projects/${e}/workflows/${r}/restore`,{method:"POST"})}async function e1(e,r){return le(`/projects/${e}/workflows/${r}/start`,{method:"POST"})}async function ex(e,r){return le(`/projects/${e}/workflows/${r}/stop`,{method:"POST"})}async function tx(e,r,s){return le(`/projects/${e}/workflows/${r}/run-specific-step/${s}`,{method:"POST"})}async function t1(e,r,s){return le(`/projects/${e}/workflows/${r}/advance`,{method:"POST",body:JSON.stringify(s||{})})}async function r1(e,r,s){return le(`/projects/${e}/workflows/${r}/steps/${s}/reopen`,{method:"POST"})}async function n1(e,r,s){return le(`/projects/${e}/workflows/${r}/steps`,{method:"POST",body:JSON.stringify(s)})}async function rx(e,r,s,a){return le(`/projects/${e}/workflows/${r}/steps/${s}`,{method:"PATCH",body:JSON.stringify(a)})}async function s1(e,r,s){return le(`/projects/${e}/workflows/${r}/steps/${s}/archive`,{method:"POST"})}async function i1(e,r,s){return le(`/projects/${e}/workflows/${r}/steps/${s}/restore`,{method:"POST"})}async function a1(e,r){return le(`/projects/${e}/workflows/${r}/steps/archived`)}async function nx(e,r,s){return le(`/projects/${e}/workflows/${r}/steps/${s}`,{method:"DELETE"})}async function o1(e,r,s){return le(`/projects/${e}/workflows/${r}/steps/reorder`,{method:"POST",body:JSON.stringify({step_ids:s})})}async function lp(e,r){return le(`/projects/${e}/workflows/${r}/planning`)}async function l1(e,r,s){return le(`/projects/${e}/workflows/${r}/planning/complete`,{method:"POST",body:JSON.stringify(s||{})})}async function c1(e,r,s){return le(`/projects/${e}/workflows/${r}/planning/sessions/${s}`)}async function d1(e,r,s,a=3,o="opus"){return le(`/projects/${e}/workflows/${r}/planning/iterate`,{method:"POST",body:JSON.stringify({prompt:s,iterations:a,model:o})})}function u1(e,r,s,a=0){const o=`${gs}/projects/${e}/workflows/${r}/planning/iterate/stream/${s}`+(a>0?`?after_event_id=${a}`:"");return new EventSource(o)}async function sx(e,r,s,a=0,o=500){const c=new URLSearchParams;a>0&&c.set("after_id",a.toString()),o!==500&&c.set("limit",o.toString());const d=c.toString();return le(`/projects/${e}/workflows/${r}/planning/iterate/${s}/events${d?`?${d}`:""}`)}async function m1(e,r,s){return le(`/projects/${e}/workflows/${r}/planning/iterate/cancel`,{method:"POST",body:JSON.stringify({session_id:s})})}async function Fd(e,r,s,a){return le(`/projects/${e}/workflows/${r}/planning/iterate/${s}/iterations/${a}/diff`)}async function Wo(e,r){return le(`/projects/${e}/workflows/${r}/planning/sessions`)}async function hl(e,r,s){const o=new URLSearchParams().toString();return le(`/projects/${e}/workflows/${r}/resources${o?`?${o}`:""}`)}async function Yo(e,r,s){return le(`/projects/${e}/workflows/${r}/resources`,{method:"POST",body:JSON.stringify(s)})}async function da(e,r,s,a){return le(`/projects/${e}/workflows/${r}/resources/${s}`,{method:"PATCH",body:JSON.stringify(a)})}async function ix(e,r,s){return le(`/projects/${e}/workflows/${r}/resources/${s}`,{method:"DELETE"})}async function h1(e,r,s,a){const c=new URLSearchParams().toString();return le(`/projects/${e}/workflows/${r}/resources/${s}/versions${c?`?${c}`:""}`)}async function p1(e,r,s,a){return le(`/projects/${e}/workflows/${r}/resources/${s}/versions/${a}/restore`,{method:"POST"})}async function ax(e,r,s){return le(`/projects/${e}/workflows/${r}/resources/import/${s}`,{method:"POST"})}async function f1(e,r,s){return le(`/projects/${e}/workflows/${r}/steps/${s}/resources`)}async function x1(e,r,s,a){return le(`/projects/${e}/workflows/${r}/steps/${s}/resources`,{method:"POST",body:JSON.stringify(a)})}async function g1(e,r,s,a){return le(`/projects/${e}/workflows/${r}/steps/${s}/resources/${a}`,{method:"DELETE"})}async function y1(e,r,s,a){return le(`/projects/${e}/workflows/${r}/steps/${s}/resources/disable/${a}`,{method:"POST"})}async function v1(e,r,s,a){return le(`/projects/${e}/workflows/${r}/steps/${s}/resources/disable/${a}`,{method:"DELETE"})}async function w1(e,r,s){return le(`/projects/${e}/workflows/${r}/steps/${s}/preview-prompt`)}async function gu(e,r){const a=new URLSearchParams().toString();return le(`/projects/${e}/project-resources${a?`?${a}`:""}`)}async function b1(e,r){return le(`/projects/${e}/project-resources`,{method:"POST",body:JSON.stringify(r)})}async function cp(e,r,s){return le(`/projects/${e}/project-resources/${r}`,{method:"PATCH",body:JSON.stringify(s)})}async function j1(e,r){return le(`/projects/${e}/project-resources/${r}`,{method:"DELETE"})}async function k1(e){return le(`/projects/${e}/settings`)}async function N1(e,r){return le(`/projects/${e}/settings`,{method:"PATCH",body:JSON.stringify(r)})}async function C1(e){return le(`/projects/${e}/import-formats`)}async function S1(e,r,s,a,o,c){var p,x;const d=new FormData;d.append("file",o);const u=new URLSearchParams({format_id:a,workflow_id:r,source_step_id:s.toString()}),h=await fetch(`${gs}/projects/${e}/import-jsonl?${u}`,{method:"POST",body:d});if(!h.ok){const g=await h.json().catch(()=>({})),b=((p=g.error)==null?void 0:p.message)||g.detail||h.statusText;throw new ai(b,h.status,(x=g.error)==null?void 0:x.code)}return h.json()}function yu(e){return{pending:"Queued",completed:"Ready",claimed:"In Progress",in_progress:"In Progress",processed:"Done",failed:"Failed",skipped:"Skipped",duplicate:"Duplicate",external:"External",rejected:"Rejected"}[e]||e.charAt(0).toUpperCase()+e.slice(1)}function vu(e){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"}[e]||"bg-gray-500/20 text-gray-400"}async function _1(e,r){return le(`/projects/${e}/workflows/${r}/export/preview`)}async function L1(e,r,s={}){var o,c;const a=await fetch(`${gs}/projects/${e}/workflows/${r}/export`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok){const d=await a.json().catch(()=>({})),u=((o=d.error)==null?void 0:o.message)||d.detail||a.statusText;throw new ai(u,a.status,(c=d.error)==null?void 0:c.code)}return a.blob()}async function dp(e,r){var o,c;const s=new FormData;s.append("file",r);const a=await fetch(`${gs}/projects/${e}/workflows/import/preview`,{method:"POST",body:s});if(!a.ok){const d=await a.json().catch(()=>({})),u=((o=d.error)==null?void 0:o.message)||d.detail||a.statusText;throw new ai(u,a.status,(c=d.error)==null?void 0:c.code)}return a.json()}async function E1(e,r,s={}){var d,u,h,p;const a=new FormData;a.append("file",r);const o=new URLSearchParams;s.conflict_resolution&&o.set("conflict_resolution",s.conflict_resolution),s.import_items!==void 0&&o.set("import_items",s.import_items.toString()),s.import_resources!==void 0&&o.set("import_resources",s.import_resources.toString()),s.import_planning!==void 0&&o.set("import_planning",s.import_planning.toString()),s.import_runs!==void 0&&o.set("import_runs",s.import_runs.toString()),(d=s.selected_steps)!=null&&d.length&&o.set("selected_steps",s.selected_steps.join(",")),(u=s.selected_resource_ids)!=null&&u.length&&o.set("selected_resource_ids",s.selected_resource_ids.join(","));const c=await fetch(`${gs}/projects/${e}/workflows/import?${o}`,{method:"POST",body:a});if(!c.ok){const x=await c.json().catch(()=>({})),g=((h=x.error)==null?void 0:h.message)||x.detail||c.statusText;throw new ai(g,c.status,(p=x.error)==null?void 0:p.code)}return c.json()}const sn=Yw(e=>({projects:[],selectedProject:null,projectsLoading:!1,projectsError:null,loops:[],selectedLoop:null,loopsLoading:!1,items:[],itemsLoading:!1,itemsTotal:0,setProjects:r=>e({projects:r}),setSelectedProject:r=>e({selectedProject:r}),setProjectsLoading:r=>e({projectsLoading:r}),setProjectsError:r=>e({projectsError:r}),setLoops:r=>e({loops:r}),setSelectedLoop:r=>e({selectedLoop:r}),setLoopsLoading:r=>e({loopsLoading:r}),setItems:(r,s)=>e({items:r,itemsTotal:s}),setItemsLoading:r=>e({itemsLoading:r}),updateLoop:(r,s)=>e(a=>{var o;return{loops:a.loops.map(c=>c.name===r?{...c,...s}:c),selectedLoop:((o=a.selectedLoop)==null?void 0:o.name)===r?{...a.selectedLoop,...s}:a.selectedLoop}}),addItem:r=>e(s=>({items:[r,...s.items],itemsTotal:s.itemsTotal+1})),loadProjects:async()=>{e({projectsLoading:!0,projectsError:null});try{const r=await zd();e({projects:r,projectsLoading:!1})}catch(r){e({projectsError:r instanceof Error?r.message:"Failed to load projects",projectsLoading:!1})}}}));function T1(){const{slug:e,workflowId:r}=Vr(),s=Qn(),{projects:a,projectsLoading:o,projectsError:c,loadProjects:d}=sn(),[u,h]=y.useState(null),[p,x]=y.useState({});y.useEffect(()=>{d()},[d]),y.useEffect(()=>{e&&h(e)},[e]),y.useEffect(()=>{!u||p[u]||qo(u).then(b=>{x(v=>({...v,[u]:b}))}).catch(()=>{x(b=>({...b,[u]:[]}))})},[u,p]);const g=s.pathname.endsWith("/settings");return t.jsxs("aside",{className:"w-64 bg-gray-800 border-r border-gray-700 flex flex-col",children:[t.jsx("div",{className:"p-4 border-b border-gray-700",children:t.jsxs(Re,{to:"/",className:"flex items-center space-x-2",children:[t.jsx("div",{className:"w-8 h-8 bg-primary-600 rounded-lg flex items-center justify-center",children:t.jsx("span",{className:"text-white font-bold",children:"R"})}),t.jsx("span",{className:"text-xl font-semibold text-white",children:"RalphX"})]})}),t.jsxs("nav",{className:"flex-1 overflow-y-auto p-4",children:[t.jsx("h3",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider mb-3",children:"Projects"}),o&&t.jsx("div",{className:"text-gray-400 text-sm",children:"Loading..."}),c&&t.jsx("div",{className:"text-red-400 text-sm",children:c}),!o&&!c&&a.length===0&&t.jsx("div",{className:"text-gray-500 text-sm",children:"No projects yet"}),t.jsx("ul",{className:"space-y-1",children:a.map(b=>{const v=u===b.slug,k=e===b.slug,N=(p[b.slug]||[]).filter(j=>j.status==="active"||j.status==="draft"||j.status==="paused");return t.jsxs("li",{children:[t.jsxs("div",{className:"flex items-center",children:[t.jsx("button",{onClick:()=>h(v?null:b.slug),className:"p-1 text-gray-500 hover:text-white","aria-label":v?"Collapse":"Expand",children:t.jsx("svg",{className:`w-4 h-4 transition-transform ${v?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),t.jsx(Re,{to:`/projects/${b.slug}`,className:`flex-1 block px-2 py-2 rounded-md text-sm transition-colors ${k&&!r&&!g?"bg-primary-600 text-white":"text-gray-300 hover:bg-gray-700 hover:text-white"}`,children:t.jsx("div",{className:"font-medium",children:b.name})})]}),v&&t.jsxs("div",{className:"ml-6 mt-1 space-y-1",children:[N.length>0?N.slice(0,5).map(j=>{const A=j.steps.find(M=>M.step_number===j.current_step);return t.jsxs(Re,{to:`/projects/${b.slug}/workflows/${j.id}`,className:`block px-2 py-1.5 rounded text-xs transition-colors ${r===j.id?"bg-gray-700 text-white":"text-gray-400 hover:bg-gray-700 hover:text-white"}`,children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${j.status==="active"?"bg-green-400 animate-pulse":"bg-gray-500"}`}),t.jsx("span",{className:"truncate",children:j.name})]}),A&&j.status==="active"&&t.jsxs("div",{className:"ml-4 mt-0.5 text-[10px] text-gray-500 truncate",children:["Step ",j.current_step,": ",A.name]})]},j.id)}):t.jsx("div",{className:"px-2 py-1 text-xs text-gray-500",children:"No active workflows"}),N.length>5&&t.jsxs(Re,{to:`/projects/${b.slug}`,className:"block px-2 py-1 text-xs text-gray-500 hover:text-gray-400",children:["+",N.length-5," more"]}),t.jsx(Re,{to:`/projects/${b.slug}/settings`,className:`block px-2 py-1.5 rounded text-xs transition-colors ${g&&e===b.slug?"bg-gray-700 text-white":"text-gray-500 hover:bg-gray-700 hover:text-gray-300"}`,children:t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxs("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[t.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"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),t.jsx("span",{children:"Settings"})]})})]})]},b.slug)})})]}),t.jsxs("div",{className:"p-4 border-t border-gray-700 space-y-2",children:[t.jsxs(Re,{to:"/logs",className:"flex items-center space-x-2 text-sm text-gray-400 hover:text-white transition-colors",children:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{children:"Logs"})]}),t.jsxs(Re,{to:"/wiki",className:"flex items-center space-x-2 text-sm text-gray-400 hover:text-white transition-colors",children:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{children:"Wiki"})]}),t.jsxs(Re,{to:"/settings",className:"flex items-center space-x-2 text-sm text-gray-400 hover:text-white transition-colors",children:[t.jsxs("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[t.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"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),t.jsx("span",{children:"Settings"})]})]})]})}function A1(){return t.jsxs("div",{className:"flex h-screen bg-gray-900",children:[t.jsx(T1,{}),t.jsx("main",{className:"flex-1 overflow-auto",children:t.jsx(Ew,{})})]})}function P1({initialPath:e,onSelect:r,onCancel:s}){const[a,o]=y.useState(e||""),[c,d]=y.useState([]),[u,h]=y.useState(!1),[p,x]=y.useState(null),[g,b]=y.useState(!0),[v,k]=y.useState(null);y.useEffect(()=>{async function j(){b(!0),k(null);try{const A=await ob(a||void 0);o(A.path),d(A.directories),h(A.canGoUp),x(A.parent)}catch(A){k(A instanceof Error?A.message:"Failed to browse directory")}finally{b(!1)}}j()},[a]);const T=j=>{o(`${a}/${j}`)},N=()=>{p&&o(p)};return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-gray-800 rounded-lg w-full max-w-lg max-h-[80vh] flex flex-col",children:[t.jsxs("div",{className:"p-4 border-b border-gray-700",children:[t.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Directory"}),t.jsx("div",{className:"mt-2 text-sm text-gray-400 font-mono truncate",children:a})]}),t.jsx("div",{className:"flex-1 overflow-auto p-2",children:g?t.jsx("div",{className:"p-4 text-center text-gray-400",children:"Loading..."}):v?t.jsx("div",{className:"p-4 text-center text-red-400",children:v}):t.jsxs("div",{className:"space-y-1",children:[u&&t.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:[t.jsx("svg",{className:"w-5 h-5 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 17l-5-5m0 0l5-5m-5 5h12"})}),t.jsx("span",{className:"text-gray-300",children:".."})]}),c.length===0&&!u?t.jsx("div",{className:"p-4 text-center text-gray-500",children:"No subdirectories"}):c.map(j=>t.jsxs("button",{onClick:()=>T(j),className:"w-full flex items-center space-x-2 px-3 py-2 rounded hover:bg-gray-700 text-left",children:[t.jsx("svg",{className:"w-5 h-5 text-primary-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{className:"text-gray-200",children:j})]},j))]})}),t.jsxs("div",{className:"p-4 border-t border-gray-700 flex justify-end space-x-3",children:[t.jsx("button",{onClick:s,className:"px-4 py-2 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600",children:"Cancel"}),t.jsx("button",{onClick:()=>r(a),className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500",children:"Select This Folder"})]})]})})}function I1({onClose:e,onSuccess:r}){const[s,a]=y.useState(""),[o,c]=y.useState(""),[d,u]=y.useState(!1),[h,p]=y.useState(!1),[x,g]=y.useState(null),b=async k=>{if(k.preventDefault(),!s.trim()){g("Path is required");return}p(!0),g(null);try{await Gw({path:s.trim(),name:o.trim()||void 0}),r(),e()}catch(T){g(T instanceof Error?T.message:"Failed to create project")}finally{p(!1)}},v=k=>{if(a(k),u(!1),!o){const T=k.split("/");c(T[T.length-1]||"")}};return d?t.jsx(P1,{initialPath:s||void 0,onSelect:v,onCancel:()=>u(!1)}):t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-gray-800 rounded-lg w-full max-w-md",children:[t.jsxs("div",{className:"p-4 border-b border-gray-700",children:[t.jsx("h3",{className:"text-lg font-semibold text-white",children:"Add Project"}),t.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Add an existing folder as a RalphX project"})]}),t.jsxs("form",{onSubmit:b,className:"p-4 space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Project Path"}),t.jsxs("div",{className:"flex space-x-2",children:[t.jsx("input",{type:"text",value:s,onChange:k=>a(k.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"}),t.jsx("button",{type:"button",onClick:()=>u(!0),className:"px-3 py-2 bg-gray-700 border border-gray-600 rounded text-gray-300 hover:bg-gray-600",children:"Browse"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Project Name (optional)"}),t.jsx("input",{type:"text",value:o,onChange:k=>c(k.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"}),t.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Leave empty to use the folder name"})]}),x&&t.jsx("div",{className:"p-3 bg-red-900/30 border border-red-800 rounded text-sm text-red-400",children:x}),t.jsxs("div",{className:"flex justify-end space-x-3 pt-2",children:[t.jsx("button",{type:"button",onClick:e,disabled:h,className:"px-4 py-2 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600 disabled:opacity-50",children:"Cancel"}),t.jsx("button",{type:"submit",disabled:h||!s.trim(),className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500 disabled:opacity-50",children:h?"Adding...":"Add Project"})]})]})]})})}function M1({content:e,children:r,position:s="top",delay:a=200,id:o}){const[c,d]=y.useState(!1),[u,h]=y.useState({x:0,y:0}),p=y.useRef(null),x=y.useRef(null),g=y.useRef(null),b=y.useId(),v=o||`tooltip-${b}`,k=()=>{g.current=setTimeout(()=>{d(!0)},a)},T=()=>{g.current&&clearTimeout(g.current),d(!1)};return y.useEffect(()=>{if(c&&p.current&&x.current){const N=p.current.getBoundingClientRect(),j=x.current.getBoundingClientRect();let A=0,M=0;switch(s){case"top":A=N.left+N.width/2-j.width/2,M=N.top-j.height-8;break;case"bottom":A=N.left+N.width/2-j.width/2,M=N.bottom+8;break;case"left":A=N.left-j.width-8,M=N.top+N.height/2-j.height/2;break;case"right":A=N.right+8,M=N.top+N.height/2-j.height/2;break}const _=8;A=Math.max(_,Math.min(A,window.innerWidth-j.width-_)),M=Math.max(_,Math.min(M,window.innerHeight-j.height-_)),h({x:A,y:M})}},[c,s]),y.useEffect(()=>()=>{g.current&&clearTimeout(g.current)},[]),t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:p,onMouseEnter:k,onMouseLeave:T,onFocus:k,onBlur:T,className:"inline-flex","aria-describedby":c?v:void 0,children:r}),c&&t.jsx("div",{ref:x,id:v,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:u.x,top:u.y},children:e})]})}const R1={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"};function xn({content:e,position:r="top",size:s="md",className:a=""}){return t.jsx(M1,{content:e,position:r,children:t.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 ${a}`,"aria-label":"Help",children:t.jsx("svg",{className:R1[s],fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:t.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 $1=[{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 D1({onDismiss:e,storageKey:r="ralphx-onboarding-dismissed"}){const[s,a]=y.useState(!1);y.useEffect(()=>{try{const c=localStorage.getItem(r)==="true";a(c)}catch{}},[r]);const o=()=>{try{localStorage.setItem(r,"true")}catch{}a(!0),e==null||e()};return s?null:t.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:[t.jsxs("div",{className:"flex items-start justify-between mb-4",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold text-white mb-1",children:"Welcome to RalphX"}),t.jsx("p",{className:"text-gray-400",children:"Get started with AI-powered development workflows in a few simple steps."})]}),t.jsx("button",{onClick:o,className:"text-gray-400 hover:text-white p-1","aria-label":"Dismiss getting started guide",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:$1.map((c,d)=>t.jsxs("div",{className:"bg-gray-800/50 rounded-lg p-4 border border-gray-700/50",children:[t.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[t.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:t.jsx("span",{className:"text-sm font-bold",children:d+1})}),t.jsx("svg",{className:"w-5 h-5 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:c.icon})})]}),t.jsx("h3",{className:"text-sm font-medium text-white mb-1",children:c.title}),t.jsx("p",{className:"text-xs text-gray-400",children:c.description})]},c.title))}),t.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-700/50 flex items-center justify-between",children:[t.jsx("p",{className:"text-xs text-gray-500",children:"Need help? Check out the documentation or ask in the community."}),t.jsx("button",{onClick:o,className:"text-xs text-primary-400 hover:text-primary-300",children:"Don't show this again"})]})]})}const Wd={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 Hd({icon:e,title:r,description:s,action:a,children:o}){return t.jsxs("div",{className:"text-center py-12 px-6",children:[e&&t.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-gray-700/50 flex items-center justify-center mb-4",children:typeof e=="string"?t.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:e})}):e}),t.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:r}),s&&t.jsx("p",{className:"text-gray-400 max-w-sm mx-auto mb-6",children:s}),a&&t.jsxs("button",{onClick:a.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:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),t.jsx("span",{children:a.label})]}),o]})}function fs(e){return!e.endsWith("Z")&&!e.includes("+")&&!e.includes("-",10)?new Date(e+"Z"):new Date(e)}function B1(e){return e?fs(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}function z1(e){if(!e)return"";const r=fs(e),s=new Date;return r.toDateString()===s.toDateString()?r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}):r.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function wu(e,r=!1){if(!e)return"";const s=fs(e);return r?s.toLocaleDateString([],{month:"short",day:"numeric",year:"numeric"}):s.toLocaleDateString([],{month:"short",day:"numeric"})}function Wn(e){return e?fs(e).toLocaleString():""}function bu(e,r=""){if(!e)return r;const s=fs(e),o=new Date().getTime()-s.getTime(),c=Math.floor(o/1e3),d=Math.floor(c/60),u=Math.floor(d/60),h=Math.floor(u/24);return c<60?"just now":d<60?`${d}m ago`:u<48?`${u}h ago`:h<7?`${h}d ago`:wu(e)}function O1(){const{projects:e,projectsLoading:r,projectsError:s,loadProjects:a}=sn(),[o,c]=y.useState(null),[d,u]=y.useState(!1),[h,p]=y.useState(!1);return y.useEffect(()=>{Kf().then(c).catch(()=>{c(null),u(!0)})},[]),t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"mb-8",children:[t.jsx("h1",{className:"text-3xl font-bold text-white mb-2",children:"Dashboard"}),t.jsx("p",{className:"text-gray-400",children:"Manage your RalphX projects and workflows"})]}),d&&!o&&t.jsx("div",{className:"card mb-6 bg-red-900/20 border border-red-800",role:"alert",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-red-400",children:"API Unavailable"}),t.jsx("p",{className:"text-sm text-gray-400",children:"Unable to connect to the backend API"})]}),t.jsx("div",{className:"flex items-center space-x-4",children:t.jsx("span",{className:"text-sm text-red-400",children:"offline"})})]})}),o&&t.jsx("div",{className:"card mb-6",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-white",children:"API Status"}),t.jsx("p",{className:"text-sm text-gray-400",children:"Backend health check"})]}),t.jsxs("div",{className:"flex items-center space-x-4",children:[t.jsx("span",{className:`text-sm ${o.status==="healthy"?"text-green-400":"text-red-400"}`,children:o.status}),t.jsxs("span",{className:"text-sm text-gray-500",children:["v",o.version]})]})]})}),t.jsx(D1,{}),h&&t.jsx(I1,{onClose:()=>p(!1),onSuccess:()=>a()}),t.jsxs("div",{className:"mb-6",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h2",{className:"text-xl font-semibold text-white",children:"Projects"}),t.jsxs("button",{onClick:()=>p(!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:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),t.jsx("span",{children:"Add Project"})]})]}),r?t.jsx("div",{className:"text-gray-400","aria-live":"polite",children:"Loading projects..."}):s?t.jsxs("div",{className:"card bg-red-900/20 border border-red-800",role:"alert",children:[t.jsx("p",{className:"text-red-400 mb-2",children:s}),t.jsx("p",{className:"text-sm text-gray-400",children:"Unable to load projects. Check that the API is running."})]}):e.length===0?t.jsx("div",{className:"card",children:t.jsx(Hd,{icon:Wd.folder,title:"No projects yet",description:"Create your first project to start building AI-powered development workflows.",action:{label:"Add Project",onClick:()=>p(!0)},children:t.jsxs("p",{className:"text-xs text-gray-500 mt-4",children:["Or use the CLI: ",t.jsx("code",{className:"bg-gray-700 px-2 py-1 rounded",children:"ralphx add /path/to/project"})]})})}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:e.map(x=>t.jsxs(Re,{to:`/projects/${x.slug}`,className:"card hover:bg-gray-700 transition-colors",children:[t.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:x.name}),t.jsx("p",{className:"text-sm text-gray-400 truncate mb-3",children:x.path}),t.jsxs("div",{className:"text-xs text-gray-500",children:["Added: ",wu(x.created_at)]})]},x.slug))})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs("div",{className:"card",children:[t.jsx("div",{className:"text-3xl font-bold text-primary-400",children:e.length}),t.jsx("div",{className:"text-sm text-gray-400",children:"Total Projects"})]}),t.jsxs("div",{className:"card",children:[t.jsx("div",{className:"text-3xl font-bold text-green-400",children:"0"}),t.jsx("div",{className:"text-sm text-gray-400",children:"Active Workflows"})]}),t.jsxs("div",{className:"card",children:[t.jsx("div",{className:"text-3xl font-bold text-yellow-400",children:"0"}),t.jsx("div",{className:"text-sm text-gray-400",children:"Pending Items"})]})]})]})}/*!
|
|
68
|
+
* sweetalert2 v11.26.17
|
|
69
|
+
* Released under the MIT License.
|
|
70
|
+
*/function ox(e,r,s){if(typeof e=="function"?e===r:e.has(r))return arguments.length<3?r:s;throw new TypeError("Private element is not present on this object")}function F1(e,r){if(r.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function up(e,r){return e.get(ox(e,r))}function W1(e,r,s){F1(e,r),r.set(e,s)}function H1(e,r,s){return e.set(ox(e,r),s),s}const U1=100,Te={},V1=()=>{Te.previousActiveElement instanceof HTMLElement?(Te.previousActiveElement.focus(),Te.previousActiveElement=null):document.body&&document.body.focus()},q1=e=>new Promise(r=>{if(!e)return r();const s=window.scrollX,a=window.scrollY;Te.restoreFocusTimeout=setTimeout(()=>{V1(),r()},U1),window.scrollTo(s,a)}),lx="swal2-",Y1=["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"],oe=Y1.reduce((e,r)=>(e[r]=lx+r,e),{}),G1=["success","warning","info","question","error"],Go=G1.reduce((e,r)=>(e[r]=lx+r,e),{}),cx="SweetAlert2:",ju=e=>e.charAt(0).toUpperCase()+e.slice(1),sr=e=>{console.warn(`${cx} ${typeof e=="object"?e.join(" "):e}`)},vs=e=>{console.error(`${cx} ${e}`)},mp=[],K1=e=>{mp.includes(e)||(mp.push(e),sr(e))},dx=(e,r=null)=>{K1(`"${e}" is deprecated and will be removed in the next major release.${r?` Use "${r}" instead.`:""}`)},pl=e=>typeof e=="function"?e():e,ku=e=>e&&typeof e.toPromise=="function",ya=e=>ku(e)?e.toPromise():Promise.resolve(e),Nu=e=>e&&Promise.resolve(e)===e,ir=()=>document.body.querySelector(`.${oe.container}`),va=e=>{const r=ir();return r?r.querySelector(e):null},_r=e=>va(`.${e}`),Ze=()=>_r(oe.popup),oi=()=>_r(oe.icon),Q1=()=>_r(oe["icon-content"]),ux=()=>_r(oe.title),Cu=()=>_r(oe["html-container"]),mx=()=>_r(oe.image),Su=()=>_r(oe["progress-steps"]),fl=()=>_r(oe["validation-message"]),tn=()=>va(`.${oe.actions} .${oe.confirm}`),li=()=>va(`.${oe.actions} .${oe.cancel}`),ws=()=>va(`.${oe.actions} .${oe.deny}`),J1=()=>_r(oe["input-label"]),ci=()=>va(`.${oe.loader}`),wa=()=>_r(oe.actions),hx=()=>_r(oe.footer),xl=()=>_r(oe["timer-progress-bar"]),_u=()=>_r(oe.close),X1=`
|
|
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
|
+
`,Lu=()=>{const e=Ze();if(!e)return[];const r=e.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])'),s=Array.from(r).sort((c,d)=>{const u=parseInt(c.getAttribute("tabindex")||"0"),h=parseInt(d.getAttribute("tabindex")||"0");return u>h?1:u<h?-1:0}),a=e.querySelectorAll(X1),o=Array.from(a).filter(c=>c.getAttribute("tabindex")!=="-1");return[...new Set(s.concat(o))].filter(c=>xr(c))},Eu=()=>yn(document.body,oe.shown)&&!yn(document.body,oe["toast-shown"])&&!yn(document.body,oe["no-backdrop"]),gl=()=>{const e=Ze();return e?yn(e,oe.toast):!1},Z1=()=>{const e=Ze();return e?e.hasAttribute("data-loading"):!1},Lr=(e,r)=>{if(e.textContent="",r){const a=new DOMParser().parseFromString(r,"text/html"),o=a.querySelector("head");o&&Array.from(o.childNodes).forEach(d=>{e.appendChild(d)});const c=a.querySelector("body");c&&Array.from(c.childNodes).forEach(d=>{d instanceof HTMLVideoElement||d instanceof HTMLAudioElement?e.appendChild(d.cloneNode(!0)):e.appendChild(d)})}},yn=(e,r)=>{if(!r)return!1;const s=r.split(/\s+/);for(let a=0;a<s.length;a++)if(!e.classList.contains(s[a]))return!1;return!0},ej=(e,r)=>{Array.from(e.classList).forEach(s=>{!Object.values(oe).includes(s)&&!Object.values(Go).includes(s)&&!Object.values(r.showClass||{}).includes(s)&&e.classList.remove(s)})},Sr=(e,r,s)=>{if(ej(e,r),!r.customClass)return;const a=r.customClass[s];if(a){if(typeof a!="string"&&!a.forEach){sr(`Invalid type of customClass.${s}! Expected string or iterable object, got "${typeof a}"`);return}Xe(e,a)}},yl=(e,r)=>{if(!r)return null;switch(r){case"select":case"textarea":case"file":return e.querySelector(`.${oe.popup} > .${oe[r]}`);case"checkbox":return e.querySelector(`.${oe.popup} > .${oe.checkbox} input`);case"radio":return e.querySelector(`.${oe.popup} > .${oe.radio} input:checked`)||e.querySelector(`.${oe.popup} > .${oe.radio} input:first-child`);case"range":return e.querySelector(`.${oe.popup} > .${oe.range} input`);default:return e.querySelector(`.${oe.popup} > .${oe.input}`)}},px=e=>{if(e.focus(),e.type!=="file"){const r=e.value;e.value="",e.value=r}},fx=(e,r,s)=>{!e||!r||(typeof r=="string"&&(r=r.split(/\s+/).filter(Boolean)),r.forEach(a=>{Array.isArray(e)?e.forEach(o=>{s?o.classList.add(a):o.classList.remove(a)}):s?e.classList.add(a):e.classList.remove(a)}))},Xe=(e,r)=>{fx(e,r,!0)},$r=(e,r)=>{fx(e,r,!1)},Hn=(e,r)=>{const s=Array.from(e.children);for(let a=0;a<s.length;a++){const o=s[a];if(o instanceof HTMLElement&&yn(o,r))return o}},hs=(e,r,s)=>{s===`${parseInt(`${s}`)}`&&(s=parseInt(s)),s||parseInt(`${s}`)===0?e.style.setProperty(r,typeof s=="number"?`${s}px`:s):e.style.removeProperty(r)},Ot=(e,r="flex")=>{e&&(e.style.display=r)},Qt=e=>{e&&(e.style.display="none")},Tu=(e,r="block")=>{e&&new MutationObserver(()=>{ba(e,e.innerHTML,r)}).observe(e,{childList:!0,subtree:!0})},hp=(e,r,s,a)=>{const o=e.querySelector(r);o&&o.style.setProperty(s,a)},ba=(e,r,s="flex")=>{r?Ot(e,s):Qt(e)},xr=e=>!!(e&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length)),tj=()=>!xr(tn())&&!xr(ws())&&!xr(li()),Ud=e=>e.scrollHeight>e.clientHeight,rj=(e,r)=>{let s=e;for(;s&&s!==r;){if(Ud(s))return!0;s=s.parentElement}return!1},xx=e=>{const r=window.getComputedStyle(e),s=parseFloat(r.getPropertyValue("animation-duration")||"0"),a=parseFloat(r.getPropertyValue("transition-duration")||"0");return s>0||a>0},Au=(e,r=!1)=>{const s=xl();s&&xr(s)&&(r&&(s.style.transition="none",s.style.width="100%"),setTimeout(()=>{s.style.transition=`width ${e/1e3}s linear`,s.style.width="0%"},10))},nj=()=>{const e=xl();if(!e)return;const r=parseInt(window.getComputedStyle(e).width);e.style.removeProperty("transition"),e.style.width="100%";const s=parseInt(window.getComputedStyle(e).width),a=r/s*100;e.style.width=`${a}%`},sj=()=>typeof window>"u"||typeof document>"u",ij=`
|
|
86
|
+
<div aria-labelledby="${oe.title}" aria-describedby="${oe["html-container"]}" class="${oe.popup}" tabindex="-1">
|
|
87
|
+
<button type="button" class="${oe.close}"></button>
|
|
88
|
+
<ul class="${oe["progress-steps"]}"></ul>
|
|
89
|
+
<div class="${oe.icon}"></div>
|
|
90
|
+
<img class="${oe.image}" />
|
|
91
|
+
<h2 class="${oe.title}" id="${oe.title}"></h2>
|
|
92
|
+
<div class="${oe["html-container"]}" id="${oe["html-container"]}"></div>
|
|
93
|
+
<input class="${oe.input}" id="${oe.input}" />
|
|
94
|
+
<input type="file" class="${oe.file}" />
|
|
95
|
+
<div class="${oe.range}">
|
|
96
|
+
<input type="range" />
|
|
97
|
+
<output></output>
|
|
98
|
+
</div>
|
|
99
|
+
<select class="${oe.select}" id="${oe.select}"></select>
|
|
100
|
+
<div class="${oe.radio}"></div>
|
|
101
|
+
<label class="${oe.checkbox}">
|
|
102
|
+
<input type="checkbox" id="${oe.checkbox}" />
|
|
103
|
+
<span class="${oe.label}"></span>
|
|
104
|
+
</label>
|
|
105
|
+
<textarea class="${oe.textarea}" id="${oe.textarea}"></textarea>
|
|
106
|
+
<div class="${oe["validation-message"]}" id="${oe["validation-message"]}"></div>
|
|
107
|
+
<div class="${oe.actions}">
|
|
108
|
+
<div class="${oe.loader}"></div>
|
|
109
|
+
<button type="button" class="${oe.confirm}"></button>
|
|
110
|
+
<button type="button" class="${oe.deny}"></button>
|
|
111
|
+
<button type="button" class="${oe.cancel}"></button>
|
|
112
|
+
</div>
|
|
113
|
+
<div class="${oe.footer}"></div>
|
|
114
|
+
<div class="${oe["timer-progress-bar-container"]}">
|
|
115
|
+
<div class="${oe["timer-progress-bar"]}"></div>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
`.replace(/(^|\n)\s*/g,""),aj=()=>{const e=ir();return e?(e.remove(),$r([document.documentElement,document.body],[oe["no-backdrop"],oe["toast-shown"],oe["has-column"]]),!0):!1},us=()=>{Te.currentInstance&&Te.currentInstance.resetValidationMessage()},oj=()=>{const e=Ze();if(!e)return;const r=Hn(e,oe.input),s=Hn(e,oe.file),a=e.querySelector(`.${oe.range} input`),o=e.querySelector(`.${oe.range} output`),c=Hn(e,oe.select),d=e.querySelector(`.${oe.checkbox} input`),u=Hn(e,oe.textarea);r&&(r.oninput=us),s&&(s.onchange=us),c&&(c.onchange=us),d&&(d.onchange=us),u&&(u.oninput=us),a&&o&&(a.oninput=()=>{us(),o.value=a.value},a.onchange=()=>{us(),o.value=a.value})},lj=e=>{if(typeof e=="string"){const r=document.querySelector(e);if(!r)throw new Error(`Target element "${e}" not found`);return r}return e},cj=e=>{const r=Ze();r&&(r.setAttribute("role",e.toast?"alert":"dialog"),r.setAttribute("aria-live",e.toast?"polite":"assertive"),e.toast||r.setAttribute("aria-modal","true"))},dj=e=>{window.getComputedStyle(e).direction==="rtl"&&(Xe(ir(),oe.rtl),Te.isRTL=!0)},uj=e=>{const r=aj();if(sj()){vs("SweetAlert2 requires document to initialize");return}const s=document.createElement("div");s.className=oe.container,r&&Xe(s,oe["no-transition"]),Lr(s,ij),s.dataset.swal2Theme=e.theme;const a=lj(e.target||"body");a.appendChild(s),e.topLayer&&(s.setAttribute("popover",""),s.showPopover()),cj(e),dj(a),oj()},Pu=(e,r)=>{e instanceof HTMLElement?r.appendChild(e):typeof e=="object"?mj(e,r):e&&Lr(r,e)},mj=(e,r)=>{"jquery"in e?hj(r,e):Lr(r,e.toString())},hj=(e,r)=>{if(e.textContent="",0 in r)for(let s=0;s in r;s++)e.appendChild(r[s].cloneNode(!0));else e.appendChild(r.cloneNode(!0))},pj=(e,r)=>{const s=wa(),a=ci();!s||!a||(!r.showConfirmButton&&!r.showDenyButton&&!r.showCancelButton?Qt(s):Ot(s),Sr(s,r,"actions"),fj(s,a,r),Lr(a,r.loaderHtml||""),Sr(a,r,"loader"))};function fj(e,r,s){const a=tn(),o=ws(),c=li();!a||!o||!c||(hd(a,"confirm",s),hd(o,"deny",s),hd(c,"cancel",s),xj(a,o,c,s),s.reverseButtons&&(s.toast?(e.insertBefore(c,a),e.insertBefore(o,a)):(e.insertBefore(c,r),e.insertBefore(o,r),e.insertBefore(a,r))))}function xj(e,r,s,a){if(!a.buttonsStyling){$r([e,r,s],oe.styled);return}Xe([e,r,s],oe.styled),a.confirmButtonColor&&e.style.setProperty("--swal2-confirm-button-background-color",a.confirmButtonColor),a.denyButtonColor&&r.style.setProperty("--swal2-deny-button-background-color",a.denyButtonColor),a.cancelButtonColor&&s.style.setProperty("--swal2-cancel-button-background-color",a.cancelButtonColor),md(e),md(r),md(s)}function md(e){const r=window.getComputedStyle(e);if(r.getPropertyValue("--swal2-action-button-focus-box-shadow"))return;const s=r.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/,"rgba($1, $2, $3, 0.5)");e.style.setProperty("--swal2-action-button-focus-box-shadow",r.getPropertyValue("--swal2-outline").replace(/ rgba\(.*/,` ${s}`))}function hd(e,r,s){const a=ju(r);ba(e,s[`show${a}Button`],"inline-block"),Lr(e,s[`${r}ButtonText`]||""),e.setAttribute("aria-label",s[`${r}ButtonAriaLabel`]||""),e.className=oe[r],Sr(e,s,`${r}Button`)}const gj=(e,r)=>{const s=_u();s&&(Lr(s,r.closeButtonHtml||""),Sr(s,r,"closeButton"),ba(s,r.showCloseButton),s.setAttribute("aria-label",r.closeButtonAriaLabel||""))},yj=(e,r)=>{const s=ir();s&&(vj(s,r.backdrop),wj(s,r.position),bj(s,r.grow),Sr(s,r,"container"))};function vj(e,r){typeof r=="string"?e.style.background=r:r||Xe([document.documentElement,document.body],oe["no-backdrop"])}function wj(e,r){r&&(r in oe?Xe(e,oe[r]):(sr('The "position" parameter is not valid, defaulting to "center"'),Xe(e,oe.center)))}function bj(e,r){r&&Xe(e,oe[`grow-${r}`])}var ot={innerParams:new WeakMap,domCache:new WeakMap};const jj=["input","file","range","select","radio","checkbox","textarea"],kj=(e,r)=>{const s=Ze();if(!s)return;const a=ot.innerParams.get(e),o=!a||r.input!==a.input;jj.forEach(c=>{const d=Hn(s,oe[c]);d&&(Sj(c,r.inputAttributes),d.className=oe[c],o&&Qt(d))}),r.input&&(o&&Nj(r),_j(r))},Nj=e=>{if(!e.input)return;if(!bt[e.input]){vs(`Unexpected type of input! Expected ${Object.keys(bt).join(" | ")}, got "${e.input}"`);return}const r=gx(e.input);if(!r)return;const s=bt[e.input](r,e);Ot(r),e.inputAutoFocus&&setTimeout(()=>{px(s)})},Cj=e=>{for(let r=0;r<e.attributes.length;r++){const s=e.attributes[r].name;["id","type","value","style"].includes(s)||e.removeAttribute(s)}},Sj=(e,r)=>{const s=Ze();if(!s)return;const a=yl(s,e);if(a){Cj(a);for(const o in r)a.setAttribute(o,r[o])}},_j=e=>{if(!e.input)return;const r=gx(e.input);r&&Sr(r,e,"input")},Iu=(e,r)=>{!e.placeholder&&r.inputPlaceholder&&(e.placeholder=r.inputPlaceholder)},ja=(e,r,s)=>{if(s.inputLabel){const a=document.createElement("label"),o=oe["input-label"];a.setAttribute("for",e.id),a.className=o,typeof s.customClass=="object"&&Xe(a,s.customClass.inputLabel),a.innerText=s.inputLabel,r.insertAdjacentElement("beforebegin",a)}},gx=e=>{const r=Ze();if(r)return Hn(r,oe[e]||oe.input)},Ko=(e,r)=>{["string","number"].includes(typeof r)?e.value=`${r}`:Nu(r)||sr(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof r}"`)},bt={};bt.text=bt.email=bt.password=bt.number=bt.tel=bt.url=bt.search=bt.date=bt["datetime-local"]=bt.time=bt.week=bt.month=(e,r)=>{const s=e;return Ko(s,r.inputValue),ja(s,s,r),Iu(s,r),s.type=r.input,s};bt.file=(e,r)=>{const s=e;return ja(s,s,r),Iu(s,r),s};bt.range=(e,r)=>{const s=e,a=s.querySelector("input"),o=s.querySelector("output");return a&&(Ko(a,r.inputValue),a.type=r.input,ja(a,e,r)),o&&Ko(o,r.inputValue),e};bt.select=(e,r)=>{const s=e;if(s.textContent="",r.inputPlaceholder){const a=document.createElement("option");Lr(a,r.inputPlaceholder),a.value="",a.disabled=!0,a.selected=!0,s.appendChild(a)}return ja(s,s,r),s};bt.radio=e=>{const r=e;return r.textContent="",e};bt.checkbox=(e,r)=>{const s=Ze();if(!s)throw new Error("Popup not found");const a=yl(s,"checkbox");if(!a)throw new Error("Checkbox input not found");a.value="1",a.checked=!!r.inputValue;const c=e.querySelector("span");if(c){const d=r.inputPlaceholder||r.inputLabel;d&&Lr(c,d)}return a};bt.textarea=(e,r)=>{const s=e;Ko(s,r.inputValue),Iu(s,r),ja(s,s,r);const a=o=>parseInt(window.getComputedStyle(o).marginLeft)+parseInt(window.getComputedStyle(o).marginRight);return setTimeout(()=>{if("MutationObserver"in window){const o=Ze();if(!o)return;const c=parseInt(window.getComputedStyle(o).width),d=()=>{if(!document.body.contains(s))return;const u=s.offsetWidth+a(s),h=Ze();h&&(u>c?h.style.width=`${u}px`:hs(h,"width",r.width))};new MutationObserver(d).observe(s,{attributes:!0,attributeFilter:["style"]})}}),s};const Lj=(e,r)=>{const s=Cu();s&&(Tu(s),Sr(s,r,"htmlContainer"),r.html?(Pu(r.html,s),Ot(s,"block")):r.text?(s.textContent=r.text,Ot(s,"block")):Qt(s),kj(e,r))},Ej=(e,r)=>{const s=hx();s&&(Tu(s),ba(s,!!r.footer,"block"),r.footer&&Pu(r.footer,s),Sr(s,r,"footer"))},Tj=(e,r)=>{const s=ot.innerParams.get(e),a=oi();if(!a)return;if(s&&r.icon===s.icon){fp(a,r),pp(a,r);return}if(!r.icon&&!r.iconHtml){Qt(a);return}if(r.icon&&Object.keys(Go).indexOf(r.icon)===-1){vs(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${r.icon}"`),Qt(a);return}Ot(a),fp(a,r),pp(a,r),Xe(a,r.showClass&&r.showClass.icon),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",yx)},pp=(e,r)=>{for(const[s,a]of Object.entries(Go))r.icon!==s&&$r(e,a);Xe(e,r.icon&&Go[r.icon]),Ij(e,r),yx(),Sr(e,r,"icon")},yx=()=>{const e=Ze();if(!e)return;const r=window.getComputedStyle(e).getPropertyValue("background-color"),s=e.querySelectorAll("[class^=swal2-success-circular-line], .swal2-success-fix");for(let a=0;a<s.length;a++)s[a].style.backgroundColor=r},Aj=e=>`
|
|
119
|
+
${e.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
|
+
${e.animation?'<div class="swal2-success-fix"></div>':""}
|
|
123
|
+
${e.animation?'<div class="swal2-success-circular-line-right"></div>':""}
|
|
124
|
+
`,Pj=`
|
|
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
|
+
`,fp=(e,r)=>{if(!r.icon&&!r.iconHtml)return;let s=e.innerHTML,a="";r.iconHtml?a=xp(r.iconHtml):r.icon==="success"?(a=Aj(r),s=s.replace(/ style=".*?"/g,"")):r.icon==="error"?a=Pj:r.icon&&(a=xp({question:"?",warning:"!",info:"i"}[r.icon])),s.trim()!==a.trim()&&Lr(e,a)},Ij=(e,r)=>{if(r.iconColor){e.style.color=r.iconColor,e.style.borderColor=r.iconColor;for(const s of[".swal2-success-line-tip",".swal2-success-line-long",".swal2-x-mark-line-left",".swal2-x-mark-line-right"])hp(e,s,"background-color",r.iconColor);hp(e,".swal2-success-ring","border-color",r.iconColor)}},xp=e=>`<div class="${oe["icon-content"]}">${e}</div>`,Mj=(e,r)=>{const s=mx();if(s){if(!r.imageUrl){Qt(s);return}Ot(s,""),s.setAttribute("src",r.imageUrl),s.setAttribute("alt",r.imageAlt||""),hs(s,"width",r.imageWidth),hs(s,"height",r.imageHeight),s.className=oe.image,Sr(s,r,"image")}};let Mu=!1,vx=0,wx=0,bx=0,jx=0;const Rj=e=>{e.addEventListener("mousedown",Qo),document.body.addEventListener("mousemove",Jo),e.addEventListener("mouseup",Xo),e.addEventListener("touchstart",Qo),document.body.addEventListener("touchmove",Jo),e.addEventListener("touchend",Xo)},$j=e=>{e.removeEventListener("mousedown",Qo),document.body.removeEventListener("mousemove",Jo),e.removeEventListener("mouseup",Xo),e.removeEventListener("touchstart",Qo),document.body.removeEventListener("touchmove",Jo),e.removeEventListener("touchend",Xo)},Qo=e=>{const r=Ze();if(!r)return;const s=oi();if(e.target===r||s&&s.contains(e.target)){Mu=!0;const a=kx(e);vx=a.clientX,wx=a.clientY,bx=parseInt(r.style.insetInlineStart)||0,jx=parseInt(r.style.insetBlockStart)||0,Xe(r,"swal2-dragging")}},Jo=e=>{const r=Ze();if(r&&Mu){let{clientX:s,clientY:a}=kx(e);const o=s-vx;r.style.insetInlineStart=`${bx+(Te.isRTL?-o:o)}px`,r.style.insetBlockStart=`${jx+(a-wx)}px`}},Xo=()=>{const e=Ze();Mu=!1,$r(e,"swal2-dragging")},kx=e=>{let r=0,s=0;return e.type.startsWith("mouse")?(r=e.clientX,s=e.clientY):e.type.startsWith("touch")&&(r=e.touches[0].clientX,s=e.touches[0].clientY),{clientX:r,clientY:s}},Dj=(e,r)=>{const s=ir(),a=Ze();if(!(!s||!a)){if(r.toast){hs(s,"width",r.width),a.style.width="100%";const o=ci();o&&a.insertBefore(o,oi())}else hs(a,"width",r.width);hs(a,"padding",r.padding),r.color&&(a.style.color=r.color),r.background&&(a.style.background=r.background),Qt(fl()),Bj(a,r),r.draggable&&!r.toast?(Xe(a,oe.draggable),Rj(a)):($r(a,oe.draggable),$j(a))}},Bj=(e,r)=>{const s=r.showClass||{};e.className=`${oe.popup} ${xr(e)?s.popup:""}`,r.toast?(Xe([document.documentElement,document.body],oe["toast-shown"]),Xe(e,oe.toast)):Xe(e,oe.modal),Sr(e,r,"popup"),typeof r.customClass=="string"&&Xe(e,r.customClass),r.icon&&Xe(e,oe[`icon-${r.icon}`])},zj=(e,r)=>{const s=Su();if(!s)return;const{progressSteps:a,currentProgressStep:o}=r;if(!a||a.length===0||o===void 0){Qt(s);return}Ot(s),s.textContent="",o>=a.length&&sr("Invalid currentProgressStep parameter, it should be less than progressSteps.length (currentProgressStep like JS arrays starts from 0)"),a.forEach((c,d)=>{const u=Oj(c);if(s.appendChild(u),d===o&&Xe(u,oe["active-progress-step"]),d!==a.length-1){const h=Fj(r);s.appendChild(h)}})},Oj=e=>{const r=document.createElement("li");return Xe(r,oe["progress-step"]),Lr(r,e),r},Fj=e=>{const r=document.createElement("li");return Xe(r,oe["progress-step-line"]),e.progressStepsDistance&&hs(r,"width",e.progressStepsDistance),r},Wj=(e,r)=>{const s=ux();s&&(Tu(s),ba(s,!!(r.title||r.titleText),"block"),r.title&&Pu(r.title,s),r.titleText&&(s.innerText=r.titleText),Sr(s,r,"title"))},Nx=(e,r)=>{var s;Dj(e,r),yj(e,r),zj(e,r),Tj(e,r),Mj(e,r),Wj(e,r),gj(e,r),Lj(e,r),pj(e,r),Ej(e,r);const a=Ze();typeof r.didRender=="function"&&a&&r.didRender(a),(s=Te.eventEmitter)===null||s===void 0||s.emit("didRender",a)},Hj=()=>xr(Ze()),Cx=()=>{var e;return(e=tn())===null||e===void 0?void 0:e.click()},Uj=()=>{var e;return(e=ws())===null||e===void 0?void 0:e.click()},Vj=()=>{var e;return(e=li())===null||e===void 0?void 0:e.click()},di=Object.freeze({cancel:"cancel",backdrop:"backdrop",close:"close",esc:"esc",timer:"timer"}),Sx=e=>{if(e.keydownTarget&&e.keydownHandlerAdded&&e.keydownHandler){const r=e.keydownHandler;e.keydownTarget.removeEventListener("keydown",r,{capture:e.keydownListenerCapture}),e.keydownHandlerAdded=!1}},qj=(e,r,s)=>{if(Sx(e),!r.toast){const a=c=>Gj(r,c,s);e.keydownHandler=a;const o=r.keydownListenerCapture?window:Ze();if(o){e.keydownTarget=o,e.keydownListenerCapture=r.keydownListenerCapture;const c=a;e.keydownTarget.addEventListener("keydown",c,{capture:e.keydownListenerCapture}),e.keydownHandlerAdded=!0}}},Vd=(e,r)=>{var s;const a=Lu();if(a.length){e=e+r,e===-2&&(e=a.length-1),e===a.length?e=0:e===-1&&(e=a.length-1),a[e].focus();return}(s=Ze())===null||s===void 0||s.focus()},_x=["ArrowRight","ArrowDown"],Yj=["ArrowLeft","ArrowUp"],Gj=(e,r,s)=>{e&&(r.isComposing||r.keyCode===229||(e.stopKeydownPropagation&&r.stopPropagation(),r.key==="Enter"?Kj(r,e):r.key==="Tab"?Qj(r):[..._x,...Yj].includes(r.key)?Jj(r.key):r.key==="Escape"&&Xj(r,e,s)))},Kj=(e,r)=>{if(!pl(r.allowEnterKey))return;const s=Ze();if(!s||!r.input)return;const a=yl(s,r.input);if(e.target&&a&&e.target instanceof HTMLElement&&e.target.outerHTML===a.outerHTML){if(["textarea","file"].includes(r.input))return;Cx(),e.preventDefault()}},Qj=e=>{const r=e.target,s=Lu();let a=-1;for(let o=0;o<s.length;o++)if(r===s[o]){a=o;break}e.shiftKey?Vd(a,-1):Vd(a,1),e.stopPropagation(),e.preventDefault()},Jj=e=>{const r=wa(),s=tn(),a=ws(),o=li();if(!r||!s||!a||!o)return;const c=[s,a,o];if(document.activeElement instanceof HTMLElement&&!c.includes(document.activeElement))return;const d=_x.includes(e)?"nextElementSibling":"previousElementSibling";let u=document.activeElement;if(u){for(let h=0;h<r.children.length;h++){if(u=u[d],!u)return;if(u instanceof HTMLButtonElement&&xr(u))break}u instanceof HTMLButtonElement&&u.focus()}},Xj=(e,r,s)=>{e.preventDefault(),pl(r.allowEscapeKey)&&s(di.esc)};var ti={swalPromiseResolve:new WeakMap,swalPromiseReject:new WeakMap};const Zj=()=>{const e=ir();Array.from(document.body.children).forEach(s=>{s.contains(e)||(s.hasAttribute("aria-hidden")&&s.setAttribute("data-previous-aria-hidden",s.getAttribute("aria-hidden")||""),s.setAttribute("aria-hidden","true"))})},Lx=()=>{Array.from(document.body.children).forEach(r=>{r.hasAttribute("data-previous-aria-hidden")?(r.setAttribute("aria-hidden",r.getAttribute("data-previous-aria-hidden")||""),r.removeAttribute("data-previous-aria-hidden")):r.removeAttribute("aria-hidden")})},Ex=typeof window<"u"&&!!window.GestureEvent,e4=()=>{if(Ex&&!yn(document.body,oe.iosfix)){const e=document.body.scrollTop;document.body.style.top=`${e*-1}px`,Xe(document.body,oe.iosfix),t4()}},t4=()=>{const e=ir();if(!e)return;let r;e.ontouchstart=s=>{r=r4(s)},e.ontouchmove=s=>{r&&(s.preventDefault(),s.stopPropagation())}},r4=e=>{const r=e.target,s=ir(),a=Cu();return!s||!a||n4(e)||s4(e)?!1:r===s||!Ud(s)&&r instanceof HTMLElement&&!rj(r,a)&&r.tagName!=="INPUT"&&r.tagName!=="TEXTAREA"&&!(Ud(a)&&a.contains(r))},n4=e=>!!(e.touches&&e.touches.length&&e.touches[0].touchType==="stylus"),s4=e=>e.touches&&e.touches.length>1,i4=()=>{if(yn(document.body,oe.iosfix)){const e=parseInt(document.body.style.top,10);$r(document.body,oe.iosfix),document.body.style.top="",document.body.scrollTop=e*-1}},a4=()=>{const e=document.createElement("div");e.className=oe["scrollbar-measure"],document.body.appendChild(e);const r=e.getBoundingClientRect().width-e.clientWidth;return document.body.removeChild(e),r};let Xs=null;const o4=e=>{Xs===null&&(document.body.scrollHeight>window.innerHeight||e==="scroll")&&(Xs=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right")),document.body.style.paddingRight=`${Xs+a4()}px`)},l4=()=>{Xs!==null&&(document.body.style.paddingRight=`${Xs}px`,Xs=null)};function Tx(e,r,s,a){gl()?gp(e,a):(q1(s).then(()=>gp(e,a)),Sx(Te)),Ex?(r.setAttribute("style","display:none !important"),r.removeAttribute("class"),r.innerHTML=""):r.remove(),Eu()&&(l4(),i4(),Lx()),c4()}function c4(){$r([document.documentElement,document.body],[oe.shown,oe["height-auto"],oe["no-backdrop"],oe["toast-shown"]])}function Un(e){e=u4(e);const r=ti.swalPromiseResolve.get(this),s=d4(this);this.isAwaitingPromise?e.isDismissed||(ka(this),r(e)):s&&r(e)}const d4=e=>{const r=Ze();if(!r)return!1;const s=ot.innerParams.get(e);if(!s||yn(r,s.hideClass.popup))return!1;$r(r,s.showClass.popup),Xe(r,s.hideClass.popup);const a=ir();return $r(a,s.showClass.backdrop),Xe(a,s.hideClass.backdrop),m4(e,r,s),!0};function Ax(e){const r=ti.swalPromiseReject.get(this);ka(this),r&&r(e)}const ka=e=>{e.isAwaitingPromise&&(delete e.isAwaitingPromise,ot.innerParams.get(e)||e._destroy())},u4=e=>typeof e>"u"?{isConfirmed:!1,isDenied:!1,isDismissed:!0}:Object.assign({isConfirmed:!1,isDenied:!1,isDismissed:!1},e),m4=(e,r,s)=>{var a;const o=ir(),c=xx(r);typeof s.willClose=="function"&&s.willClose(r),(a=Te.eventEmitter)===null||a===void 0||a.emit("willClose",r),c&&o?h4(e,r,o,!!s.returnFocus,s.didClose):o&&Tx(e,o,!!s.returnFocus,s.didClose)},h4=(e,r,s,a,o)=>{Te.swalCloseEventFinishedCallback=Tx.bind(null,e,s,a,o);const c=function(d){if(d.target===r){var u;(u=Te.swalCloseEventFinishedCallback)===null||u===void 0||u.call(Te),delete Te.swalCloseEventFinishedCallback,r.removeEventListener("animationend",c),r.removeEventListener("transitionend",c)}};r.addEventListener("animationend",c),r.addEventListener("transitionend",c)},gp=(e,r)=>{setTimeout(()=>{var s;typeof r=="function"&&r.bind(e.params)(),(s=Te.eventEmitter)===null||s===void 0||s.emit("didClose"),e._destroy&&e._destroy()})},ri=e=>{let r=Ze();if(r||new gt,r=Ze(),!r)return;const s=ci();gl()?Qt(oi()):p4(r,e),Ot(s),r.setAttribute("data-loading","true"),r.setAttribute("aria-busy","true"),r.focus()},p4=(e,r)=>{const s=wa(),a=ci();!s||!a||(!r&&xr(tn())&&(r=tn()),Ot(s),r&&(Qt(r),a.setAttribute("data-button-to-replace",r.className),s.insertBefore(a,r)),Xe([e,s],oe.loading))},f4=(e,r)=>{r.input==="select"||r.input==="radio"?w4(e,r):["text","email","number","tel","textarea"].some(s=>s===r.input)&&(ku(r.inputValue)||Nu(r.inputValue))&&(ri(tn()),b4(e,r))},x4=(e,r)=>{const s=e.getInput();if(!s)return null;switch(r.input){case"checkbox":return g4(s);case"radio":return y4(s);case"file":return v4(s);default:return r.inputAutoTrim?s.value.trim():s.value}},g4=e=>e.checked?1:0,y4=e=>e.checked?e.value:null,v4=e=>e.files&&e.files.length?e.getAttribute("multiple")!==null?e.files:e.files[0]:null,w4=(e,r)=>{const s=Ze();if(!s)return;const a=o=>{r.input==="select"?j4(s,Zo(o),r):r.input==="radio"&&k4(s,Zo(o),r)};ku(r.inputOptions)||Nu(r.inputOptions)?(ri(tn()),ya(r.inputOptions).then(o=>{e.hideLoading(),a(o)})):typeof r.inputOptions=="object"?a(r.inputOptions):vs(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof r.inputOptions}`)},b4=(e,r)=>{const s=e.getInput();s&&(Qt(s),ya(r.inputValue).then(a=>{s.value=r.input==="number"?`${parseFloat(a)||0}`:`${a}`,Ot(s),s.focus(),e.hideLoading()}).catch(a=>{vs(`Error in inputValue promise: ${a}`),s.value="",Ot(s),s.focus(),e.hideLoading()}))};function j4(e,r,s){const a=Hn(e,oe.select);if(!a)return;const o=(c,d,u)=>{const h=document.createElement("option");h.value=u,Lr(h,d),h.selected=Px(u,s.inputValue),c.appendChild(h)};r.forEach(c=>{const d=c[0],u=c[1];if(Array.isArray(u)){const h=document.createElement("optgroup");h.label=d,h.disabled=!1,a.appendChild(h),u.forEach(p=>o(h,p[1],p[0]))}else o(a,u,d)}),a.focus()}function k4(e,r,s){const a=Hn(e,oe.radio);if(!a)return;r.forEach(c=>{const d=c[0],u=c[1],h=document.createElement("input"),p=document.createElement("label");h.type="radio",h.name=oe.radio,h.value=d,Px(d,s.inputValue)&&(h.checked=!0);const x=document.createElement("span");Lr(x,u),x.className=oe.label,p.appendChild(h),p.appendChild(x),a.appendChild(p)});const o=a.querySelectorAll("input");o.length&&o[0].focus()}const Zo=e=>{const r=[];return e instanceof Map?e.forEach((s,a)=>{let o=s;typeof o=="object"&&(o=Zo(o)),r.push([a,o])}):Object.keys(e).forEach(s=>{let a=e[s];typeof a=="object"&&(a=Zo(a)),r.push([s,a])}),r},Px=(e,r)=>!!r&&r!==null&&r!==void 0&&r.toString()===e.toString(),N4=e=>{const r=ot.innerParams.get(e);e.disableButtons(),r.input?Ix(e,"confirm"):$u(e,!0)},C4=e=>{const r=ot.innerParams.get(e);e.disableButtons(),r.returnInputValueOnDeny?Ix(e,"deny"):Ru(e,!1)},S4=(e,r)=>{e.disableButtons(),r(di.cancel)},Ix=(e,r)=>{const s=ot.innerParams.get(e);if(!s.input){vs(`The "input" parameter is needed to be set when using returnInputValueOn${ju(r)}`);return}const a=e.getInput(),o=x4(e,s);s.inputValidator?_4(e,o,r):a&&!a.checkValidity()?(e.enableButtons(),e.showValidationMessage(s.validationMessage||a.validationMessage)):r==="deny"?Ru(e,o):$u(e,o)},_4=(e,r,s)=>{const a=ot.innerParams.get(e);e.disableInput(),Promise.resolve().then(()=>ya(a.inputValidator(r,a.validationMessage))).then(c=>{e.enableButtons(),e.enableInput(),c?e.showValidationMessage(c):s==="deny"?Ru(e,r):$u(e,r)})},Ru=(e,r)=>{const s=ot.innerParams.get(e);s.showLoaderOnDeny&&ri(ws()),s.preDeny?(e.isAwaitingPromise=!0,Promise.resolve().then(()=>ya(s.preDeny(r,s.validationMessage))).then(o=>{o===!1?(e.hideLoading(),ka(e)):e.close({isDenied:!0,value:typeof o>"u"?r:o})}).catch(o=>Mx(e,o))):e.close({isDenied:!0,value:r})},yp=(e,r)=>{e.close({isConfirmed:!0,value:r})},Mx=(e,r)=>{e.rejectPromise(r)},$u=(e,r)=>{const s=ot.innerParams.get(e);s.showLoaderOnConfirm&&ri(),s.preConfirm?(e.resetValidationMessage(),e.isAwaitingPromise=!0,Promise.resolve().then(()=>ya(s.preConfirm(r,s.validationMessage))).then(o=>{xr(fl())||o===!1?(e.hideLoading(),ka(e)):yp(e,typeof o>"u"?r:o)}).catch(o=>Mx(e,o))):yp(e,r)};function el(){const e=ot.innerParams.get(this);if(!e)return;const r=ot.domCache.get(this);Qt(r.loader),gl()?e.icon&&Ot(oi()):L4(r),$r([r.popup,r.actions],oe.loading),r.popup.removeAttribute("aria-busy"),r.popup.removeAttribute("data-loading"),r.confirmButton.disabled=!1,r.denyButton.disabled=!1,r.cancelButton.disabled=!1}const L4=e=>{const r=e.loader.getAttribute("data-button-to-replace"),s=r?e.popup.getElementsByClassName(r):[];s.length?Ot(s[0],"inline-block"):tj()&&Qt(e.actions)};function Rx(){const e=ot.innerParams.get(this),r=ot.domCache.get(this);return r?yl(r.popup,e.input):null}function $x(e,r,s){const a=ot.domCache.get(e);r.forEach(o=>{a[o].disabled=s})}function Dx(e,r){const s=Ze();if(!(!s||!e))if(e.type==="radio"){const a=s.querySelectorAll(`[name="${oe.radio}"]`);for(let o=0;o<a.length;o++)a[o].disabled=r}else e.disabled=r}function Bx(){$x(this,["confirmButton","denyButton","cancelButton"],!1)}function zx(){$x(this,["confirmButton","denyButton","cancelButton"],!0)}function Ox(){Dx(this.getInput(),!1)}function Fx(){Dx(this.getInput(),!0)}function Wx(e){const r=ot.domCache.get(this),s=ot.innerParams.get(this);Lr(r.validationMessage,e),r.validationMessage.className=oe["validation-message"],s.customClass&&s.customClass.validationMessage&&Xe(r.validationMessage,s.customClass.validationMessage),Ot(r.validationMessage);const a=this.getInput();a&&(a.setAttribute("aria-invalid","true"),a.setAttribute("aria-describedby",oe["validation-message"]),px(a),Xe(a,oe.inputerror))}function Hx(){const e=ot.domCache.get(this);e.validationMessage&&Qt(e.validationMessage);const r=this.getInput();r&&(r.removeAttribute("aria-invalid"),r.removeAttribute("aria-describedby"),$r(r,oe.inputerror))}const Vn={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:"×",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},E4=["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"],T4={allowEnterKey:void 0},A4=["allowOutsideClick","allowEnterKey","backdrop","draggable","focusConfirm","focusDeny","focusCancel","returnFocus","heightAuto","keydownListenerCapture"],Ux=e=>Object.prototype.hasOwnProperty.call(Vn,e),Vx=e=>E4.indexOf(e)!==-1,qx=e=>T4[e],P4=e=>{Ux(e)||sr(`Unknown parameter "${e}"`)},I4=e=>{A4.includes(e)&&sr(`The parameter "${e}" is incompatible with toasts`)},M4=e=>{const r=qx(e);r&&dx(e,r)},Yx=e=>{e.backdrop===!1&&e.allowOutsideClick&&sr('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`'),e.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(e.theme)&&sr(`Invalid theme "${e.theme}"`);for(const r in e)P4(r),e.toast&&I4(r),M4(r)};function Gx(e){const r=ir(),s=Ze(),a=ot.innerParams.get(this);if(!s||yn(s,a.hideClass.popup)){sr("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 o=R4(e),c=Object.assign({},a,o);Yx(c),r&&(r.dataset.swal2Theme=c.theme),Nx(this,c),ot.innerParams.set(this,c),Object.defineProperties(this,{params:{value:Object.assign({},this.params,e),writable:!1,enumerable:!0}})}const R4=e=>{const r={};return Object.keys(e).forEach(s=>{if(Vx(s)){const a=e;r[s]=a[s]}else sr(`Invalid parameter to update: ${s}`)}),r};function Kx(){var e;const r=ot.domCache.get(this),s=ot.innerParams.get(this);if(!s){Qx(this);return}r.popup&&Te.swalCloseEventFinishedCallback&&(Te.swalCloseEventFinishedCallback(),delete Te.swalCloseEventFinishedCallback),typeof s.didDestroy=="function"&&s.didDestroy(),(e=Te.eventEmitter)===null||e===void 0||e.emit("didDestroy"),$4(this)}const $4=e=>{Qx(e),delete e.params,delete Te.keydownHandler,delete Te.keydownTarget,delete Te.currentInstance},Qx=e=>{e.isAwaitingPromise?(pd(ot,e),e.isAwaitingPromise=!0):(pd(ti,e),pd(ot,e),delete e.isAwaitingPromise,delete e.disableButtons,delete e.enableButtons,delete e.getInput,delete e.disableInput,delete e.enableInput,delete e.hideLoading,delete e.disableLoading,delete e.showValidationMessage,delete e.resetValidationMessage,delete e.close,delete e.closePopup,delete e.closeModal,delete e.closeToast,delete e.rejectPromise,delete e.update,delete e._destroy)},pd=(e,r)=>{for(const s in e)e[s].delete(r)};var D4=Object.freeze({__proto__:null,_destroy:Kx,close:Un,closeModal:Un,closePopup:Un,closeToast:Un,disableButtons:zx,disableInput:Fx,disableLoading:el,enableButtons:Bx,enableInput:Ox,getInput:Rx,handleAwaitingPromise:ka,hideLoading:el,rejectPromise:Ax,resetValidationMessage:Hx,showValidationMessage:Wx,update:Gx});const B4=(e,r,s)=>{e.toast?z4(e,r,s):(F4(r),W4(r),H4(e,r,s))},z4=(e,r,s)=>{r.popup.onclick=()=>{e&&(O4(e)||e.timer||e.input)||s(di.close)}},O4=e=>!!(e.showConfirmButton||e.showDenyButton||e.showCancelButton||e.showCloseButton);let tl=!1;const F4=e=>{e.popup.onmousedown=()=>{e.container.onmouseup=function(r){e.container.onmouseup=()=>{},r.target===e.container&&(tl=!0)}}},W4=e=>{e.container.onmousedown=r=>{r.target===e.container&&r.preventDefault(),e.popup.onmouseup=function(s){e.popup.onmouseup=()=>{},(s.target===e.popup||s.target instanceof HTMLElement&&e.popup.contains(s.target))&&(tl=!0)}}},H4=(e,r,s)=>{r.container.onclick=a=>{if(tl){tl=!1;return}a.target===r.container&&pl(e.allowOutsideClick)&&s(di.backdrop)}},U4=e=>typeof e=="object"&&e.jquery,vp=e=>e instanceof Element||U4(e),V4=e=>{const r={};return typeof e[0]=="object"&&!vp(e[0])?Object.assign(r,e[0]):["title","html","icon"].forEach((s,a)=>{const o=e[a];typeof o=="string"||vp(o)?r[s]=o:o!==void 0&&vs(`Unexpected type of ${s}! Expected "string" or "Element", got ${typeof o}`)}),r};function q4(...e){return new this(...e)}function Y4(e){class r extends this{_main(a,o){return super._main(a,Object.assign({},e,o))}}return r}const G4=()=>Te.timeout&&Te.timeout.getTimerLeft(),Jx=()=>{if(Te.timeout)return nj(),Te.timeout.stop()},Xx=()=>{if(Te.timeout){const e=Te.timeout.start();return Au(e),e}},K4=()=>{const e=Te.timeout;return e&&(e.running?Jx():Xx())},Q4=e=>{if(Te.timeout){const r=Te.timeout.increase(e);return Au(r,!0),r}},J4=()=>!!(Te.timeout&&Te.timeout.isRunning());let wp=!1;const qd={};function X4(e="data-swal-template"){qd[e]=this,wp||(document.body.addEventListener("click",Z4),wp=!0)}const Z4=e=>{for(let r=e.target;r&&r!==document;r=r.parentNode)for(const s in qd){const a=r.getAttribute&&r.getAttribute(s);if(a){qd[s].fire({template:a});return}}};class ek{constructor(){this.events={}}_getHandlersByEventName(r){return typeof this.events[r]>"u"&&(this.events[r]=[]),this.events[r]}on(r,s){const a=this._getHandlersByEventName(r);a.includes(s)||a.push(s)}once(r,s){const a=(...o)=>{this.removeListener(r,a),s.apply(this,o)};this.on(r,a)}emit(r,...s){this._getHandlersByEventName(r).forEach(a=>{try{a.apply(this,s)}catch(o){console.error(o)}})}removeListener(r,s){const a=this._getHandlersByEventName(r),o=a.indexOf(s);o>-1&&a.splice(o,1)}removeAllListeners(r){this.events[r]!==void 0&&(this.events[r].length=0)}reset(){this.events={}}}Te.eventEmitter=new ek;const tk=(e,r)=>{Te.eventEmitter&&Te.eventEmitter.on(e,r)},rk=(e,r)=>{Te.eventEmitter&&Te.eventEmitter.once(e,r)},nk=(e,r)=>{if(Te.eventEmitter){if(!e){Te.eventEmitter.reset();return}r?Te.eventEmitter.removeListener(e,r):Te.eventEmitter.removeAllListeners(e)}};var sk=Object.freeze({__proto__:null,argsToParams:V4,bindClickHandler:X4,clickCancel:Vj,clickConfirm:Cx,clickDeny:Uj,enableLoading:ri,fire:q4,getActions:wa,getCancelButton:li,getCloseButton:_u,getConfirmButton:tn,getContainer:ir,getDenyButton:ws,getFocusableElements:Lu,getFooter:hx,getHtmlContainer:Cu,getIcon:oi,getIconContent:Q1,getImage:mx,getInputLabel:J1,getLoader:ci,getPopup:Ze,getProgressSteps:Su,getTimerLeft:G4,getTimerProgressBar:xl,getTitle:ux,getValidationMessage:fl,increaseTimer:Q4,isDeprecatedParameter:qx,isLoading:Z1,isTimerRunning:J4,isUpdatableParameter:Vx,isValidParameter:Ux,isVisible:Hj,mixin:Y4,off:nk,on:tk,once:rk,resumeTimer:Xx,showLoading:ri,stopTimer:Jx,toggleTimer:K4});class ik{constructor(r,s){this.callback=r,this.remaining=s,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(r){const s=this.running;return s&&this.stop(),this.remaining+=r,s&&this.start(),this.remaining}getTimerLeft(){return this.running&&(this.stop(),this.start()),this.remaining}isRunning(){return this.running}}const Zx=["swal-title","swal-html","swal-footer"],ak=e=>{const r=typeof e.template=="string"?document.querySelector(e.template):e.template;if(!r)return{};const s=r.content;return pk(s),Object.assign(ok(s),lk(s),ck(s),dk(s),uk(s),mk(s),hk(s,Zx))},ok=e=>{const r={};return Array.from(e.querySelectorAll("swal-param")).forEach(a=>{xs(a,["name","value"]);const o=a.getAttribute("name"),c=a.getAttribute("value");!o||!c||(o in Vn&&typeof Vn[o]=="boolean"?r[o]=c!=="false":o in Vn&&typeof Vn[o]=="object"?r[o]=JSON.parse(c):r[o]=c)}),r},lk=e=>{const r={};return Array.from(e.querySelectorAll("swal-function-param")).forEach(a=>{const o=a.getAttribute("name"),c=a.getAttribute("value");!o||!c||(r[o]=new Function(`return ${c}`)())}),r},ck=e=>{const r={};return Array.from(e.querySelectorAll("swal-button")).forEach(a=>{xs(a,["type","color","aria-label"]);const o=a.getAttribute("type");if(!(!o||!["confirm","cancel","deny"].includes(o))){if(r[`${o}ButtonText`]=a.innerHTML,r[`show${ju(o)}Button`]=!0,a.hasAttribute("color")){const c=a.getAttribute("color");c!==null&&(r[`${o}ButtonColor`]=c)}if(a.hasAttribute("aria-label")){const c=a.getAttribute("aria-label");c!==null&&(r[`${o}ButtonAriaLabel`]=c)}}}),r},dk=e=>{const r={},s=e.querySelector("swal-image");return s&&(xs(s,["src","width","height","alt"]),s.hasAttribute("src")&&(r.imageUrl=s.getAttribute("src")||void 0),s.hasAttribute("width")&&(r.imageWidth=s.getAttribute("width")||void 0),s.hasAttribute("height")&&(r.imageHeight=s.getAttribute("height")||void 0),s.hasAttribute("alt")&&(r.imageAlt=s.getAttribute("alt")||void 0)),r},uk=e=>{const r={},s=e.querySelector("swal-icon");return s&&(xs(s,["type","color"]),s.hasAttribute("type")&&(r.icon=s.getAttribute("type")),s.hasAttribute("color")&&(r.iconColor=s.getAttribute("color")),r.iconHtml=s.innerHTML),r},mk=e=>{const r={},s=e.querySelector("swal-input");s&&(xs(s,["type","label","placeholder","value"]),r.input=s.getAttribute("type")||"text",s.hasAttribute("label")&&(r.inputLabel=s.getAttribute("label")),s.hasAttribute("placeholder")&&(r.inputPlaceholder=s.getAttribute("placeholder")),s.hasAttribute("value")&&(r.inputValue=s.getAttribute("value")));const a=Array.from(e.querySelectorAll("swal-input-option"));return a.length&&(r.inputOptions={},a.forEach(o=>{xs(o,["value"]);const c=o.getAttribute("value");if(!c)return;const d=o.innerHTML;r.inputOptions[c]=d})),r},hk=(e,r)=>{const s={};for(const a in r){const o=r[a],c=e.querySelector(o);c&&(xs(c,[]),s[o.replace(/^swal-/,"")]=c.innerHTML.trim())}return s},pk=e=>{const r=Zx.concat(["swal-param","swal-function-param","swal-button","swal-image","swal-icon","swal-input","swal-input-option"]);Array.from(e.children).forEach(s=>{const a=s.tagName.toLowerCase();r.includes(a)||sr(`Unrecognized element <${a}>`)})},xs=(e,r)=>{Array.from(e.attributes).forEach(s=>{r.indexOf(s.name)===-1&&sr([`Unrecognized attribute "${s.name}" on <${e.tagName.toLowerCase()}>.`,`${r.length?`Allowed attributes are: ${r.join(", ")}`:"To set the value, use HTML within the element."}`])})},eg=10,fk=e=>{var r,s;const a=ir(),o=Ze();if(!a||!o)return;typeof e.willOpen=="function"&&e.willOpen(o),(r=Te.eventEmitter)===null||r===void 0||r.emit("willOpen",o);const d=window.getComputedStyle(document.body).overflowY;if(yk(a,o,e),setTimeout(()=>{xk(a,o)},eg),Eu()&&(gk(a,e.scrollbarPadding!==void 0?e.scrollbarPadding:!1,d),Zj()),!gl()&&!Te.previousActiveElement&&(Te.previousActiveElement=document.activeElement),typeof e.didOpen=="function"){const u=e.didOpen;setTimeout(()=>u(o))}(s=Te.eventEmitter)===null||s===void 0||s.emit("didOpen",o)},rl=e=>{const r=Ze();if(!r||e.target!==r)return;const s=ir();s&&(r.removeEventListener("animationend",rl),r.removeEventListener("transitionend",rl),s.style.overflowY="auto",$r(s,oe["no-transition"]))},xk=(e,r)=>{xx(r)?(e.style.overflowY="hidden",r.addEventListener("animationend",rl),r.addEventListener("transitionend",rl)):e.style.overflowY="auto"},gk=(e,r,s)=>{e4(),r&&s!=="hidden"&&o4(s),setTimeout(()=>{e.scrollTop=0})},yk=(e,r,s)=>{var a;(a=s.showClass)!==null&&a!==void 0&&a.backdrop&&Xe(e,s.showClass.backdrop),s.animation?(r.style.setProperty("opacity","0","important"),Ot(r,"grid"),setTimeout(()=>{var o;(o=s.showClass)!==null&&o!==void 0&&o.popup&&Xe(r,s.showClass.popup),r.style.removeProperty("opacity")},eg)):Ot(r,"grid"),Xe([document.documentElement,document.body],oe.shown),s.heightAuto&&s.backdrop&&!s.toast&&Xe([document.documentElement,document.body],oe["height-auto"])};var bp={email:(e,r)=>/^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(e)?Promise.resolve():Promise.resolve(r||"Invalid email address"),url:(e,r)=>/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)$/.test(e)?Promise.resolve():Promise.resolve(r||"Invalid URL")};function vk(e){e.inputValidator||(e.input==="email"&&(e.inputValidator=bp.email),e.input==="url"&&(e.inputValidator=bp.url))}function wk(e){(!e.target||typeof e.target=="string"&&!document.querySelector(e.target)||typeof e.target!="string"&&!e.target.appendChild)&&(sr('Target parameter is not valid, defaulting to "body"'),e.target="body")}function bk(e){vk(e),e.showLoaderOnConfirm&&!e.preConfirm&&sr(`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`),wk(e),typeof e.title=="string"&&(e.title=e.title.split(`
|
|
132
|
+
`).join("<br />")),uj(e)}let Xr;var Ro=new WeakMap;class Nt{constructor(...r){if(W1(this,Ro,Promise.resolve({isConfirmed:!1,isDenied:!1,isDismissed:!0})),typeof window>"u")return;Xr=this;const s=Object.freeze(this.constructor.argsToParams(r));this.params=s,this.isAwaitingPromise=!1,H1(Ro,this,this._main(Xr.params))}_main(r,s={}){if(Yx(Object.assign({},s,r)),Te.currentInstance){const c=ti.swalPromiseResolve.get(Te.currentInstance),{isAwaitingPromise:d}=Te.currentInstance;Te.currentInstance._destroy(),d||c({isDismissed:!0}),Eu()&&Lx()}Te.currentInstance=Xr;const a=kk(r,s);bk(a),Object.freeze(a),Te.timeout&&(Te.timeout.stop(),delete Te.timeout),clearTimeout(Te.restoreFocusTimeout);const o=Nk(Xr);return Nx(Xr,a),ot.innerParams.set(Xr,a),jk(Xr,o,a)}then(r){return up(Ro,this).then(r)}finally(r){return up(Ro,this).finally(r)}}const jk=(e,r,s)=>new Promise((a,o)=>{const c=d=>{e.close({isDismissed:!0,dismiss:d,isConfirmed:!1,isDenied:!1})};ti.swalPromiseResolve.set(e,a),ti.swalPromiseReject.set(e,o),r.confirmButton.onclick=()=>{N4(e)},r.denyButton.onclick=()=>{C4(e)},r.cancelButton.onclick=()=>{S4(e,c)},r.closeButton.onclick=()=>{c(di.close)},B4(s,r,c),qj(Te,s,c),f4(e,s),fk(s),Ck(Te,s,c),Sk(r,s),setTimeout(()=>{r.container.scrollTop=0})}),kk=(e,r)=>{const s=ak(e),a=Object.assign({},Vn,r,s,e);return a.showClass=Object.assign({},Vn.showClass,a.showClass),a.hideClass=Object.assign({},Vn.hideClass,a.hideClass),a.animation===!1&&(a.showClass={backdrop:"swal2-noanimation"},a.hideClass={}),a},Nk=e=>{const r={popup:Ze(),container:ir(),actions:wa(),confirmButton:tn(),denyButton:ws(),cancelButton:li(),loader:ci(),closeButton:_u(),validationMessage:fl(),progressSteps:Su()};return ot.domCache.set(e,r),r},Ck=(e,r,s)=>{const a=xl();Qt(a),r.timer&&(e.timeout=new ik(()=>{s("timer"),delete e.timeout},r.timer),r.timerProgressBar&&a&&(Ot(a),Sr(a,r,"timerProgressBar"),setTimeout(()=>{e.timeout&&e.timeout.running&&Au(r.timer)})))},Sk=(e,r)=>{if(!r.toast){if(!pl(r.allowEnterKey)){dx("allowEnterKey"),Ek();return}_k(e)||Lk(e,r)||Vd(-1,1)}},_k=e=>{const r=Array.from(e.popup.querySelectorAll("[autofocus]"));for(const s of r)if(s instanceof HTMLElement&&xr(s))return s.focus(),!0;return!1},Lk=(e,r)=>r.focusDeny&&xr(e.denyButton)?(e.denyButton.focus(),!0):r.focusCancel&&xr(e.cancelButton)?(e.cancelButton.focus(),!0):r.focusConfirm&&xr(e.confirmButton)?(e.confirmButton.focus(),!0):!1,Ek=()=>{document.activeElement instanceof HTMLElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur()};Nt.prototype.disableButtons=zx;Nt.prototype.enableButtons=Bx;Nt.prototype.getInput=Rx;Nt.prototype.disableInput=Fx;Nt.prototype.enableInput=Ox;Nt.prototype.hideLoading=el;Nt.prototype.disableLoading=el;Nt.prototype.showValidationMessage=Wx;Nt.prototype.resetValidationMessage=Hx;Nt.prototype.close=Un;Nt.prototype.closePopup=Un;Nt.prototype.closeModal=Un;Nt.prototype.closeToast=Un;Nt.prototype.rejectPromise=Ax;Nt.prototype.update=Gx;Nt.prototype._destroy=Kx;Object.assign(Nt,sk);Object.keys(D4).forEach(e=>{Nt[e]=function(...r){if(Xr&&Xr[e])return Xr[e](...r)}});Nt.DismissReason=di;Nt.version="11.26.17";const gt=Nt;gt.default=gt;typeof document<"u"&&(function(e,r){var s=e.createElement("style");if(e.getElementsByTagName("head")[0].appendChild(s),s.styleSheet)s.styleSheet.disabled||(s.styleSheet.cssText=r);else try{s.innerHTML=r}catch{s.innerText=r}})(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 Tk=[{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:t.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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 jp({projectSlug:e,onWorkflowCreated:r}){const s=Dr(),a=y.useRef(null),[o,c]=y.useState(null),[d,u]=y.useState(null),[h,p]=y.useState(null),[x,g]=y.useState("name"),[b,v]=y.useState(""),[k,T]=y.useState(!1),[N,j]=y.useState(""),[A,M]=y.useState(null),_=D=>{p(D),g("name"),v(""),T(!1),j(""),M(null),u(null)},z=()=>{p(null),g("name"),u(null)},P=()=>{b.trim()&&(h!=null&&h.requiresInput?g("input"):V())},$=D=>{var I;const R=(I=D.target.files)==null?void 0:I[0];if(!R)return;const X=new FileReader;X.onload=H=>{var J;const W=(J=H.target)==null?void 0:J.result;j(W),M(R.name)},X.readAsText(R)},V=async()=>{if(!h||!b.trim())return;if(h.requiresInput&&!N.trim()){u(`Please provide your ${h.requiresInput==="design_doc"?"design document":"user stories"}`);return}c(h.templateId),g("creating"),u(null);let D=null;try{if(D=await Kb(e,{template_id:h.templateId,name:b.trim(),config:k?{architecture_first:!0}:void 0}),N.trim()&&h.requiresInput){const R=h.requiresInput==="design_doc"?"design_doc":"input_file",X=h.requiresInput==="design_doc"?"Design Document":"Imported Stories";try{await Yo(e,D.id,{resource_type:R,name:X,content:N.trim(),source:"upload"})}catch(I){console.error("Failed to upload resource:",I),p(null),r==null||r(),s(`/projects/${e}/workflows/${D.id}`);return}}p(null),r==null||r(),s(`/projects/${e}/workflows/${D.id}`)}catch(R){u(R instanceof Error?R.message:"Failed to create workflow"),D||g(h.requiresInput?"input":"name")}finally{c(null)}},B=()=>h&&h.requiresInput?2:1,U=()=>x==="name"?1:2;return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold text-white mb-2",children:"What would you like to do?"}),t.jsx("p",{className:"text-gray-400",children:"Choose how you want to start your project"})]}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:Tk.map(D=>t.jsx("button",{onClick:()=>_(D),disabled:o!==null,className:`p-6 rounded-lg border text-left transition-all group ${D.recommended?"bg-primary-900/20 border-primary-600 hover:border-primary-500":"bg-gray-800 border-gray-700 hover:border-gray-600"} ${o!==null?"opacity-50 cursor-not-allowed":""}`,children:t.jsxs("div",{className:"flex items-start space-x-4",children:[t.jsx("div",{className:`w-12 h-12 rounded-lg flex items-center justify-center flex-shrink-0 ${D.recommended?"bg-primary-600":"bg-gray-700"}`,children:t.jsx("span",{className:D.recommended?"text-white":"text-gray-300",children:D.icon})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("h3",{className:`text-lg font-semibold transition-colors ${D.recommended?"text-white group-hover:text-primary-300":"text-white group-hover:text-gray-200"}`,children:D.title}),D.recommended&&t.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-primary-600 text-primary-100",children:"Recommended"})]}),t.jsx("p",{className:"text-sm text-gray-400 mt-1",children:D.description}),t.jsx("p",{className:"text-xs text-gray-500 mt-2",children:D.stepCount})]}),t.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:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})},D.templateId))}),h&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-gray-800 rounded-lg border border-gray-700 p-6 max-w-lg w-full mx-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-white",children:x==="name"?`Create ${h.title} Workflow`:x==="input"&&h.requiresInput==="design_doc"?"Upload Design Document":x==="input"&&h.requiresInput==="stories"?"Import User Stories":"Creating Workflow..."}),B()>1&&x!=="creating"&&t.jsxs("span",{className:"text-sm text-gray-400",children:["Step ",U()," of ",B()]})]}),x==="name"&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"workflow-name",className:"block text-sm font-medium text-gray-300 mb-1",children:"Workflow Name"}),t.jsx("input",{id:"workflow-name",type:"text",value:b,onChange:D=>v(D.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:D=>{D.key==="Enter"&&b.trim()&&P()}})]}),h.templateId==="build-product"&&t.jsxs("div",{className:"flex items-start space-x-3 p-3 bg-gray-700/50 rounded",children:[t.jsx("input",{id:"new-project",type:"checkbox",checked:k,onChange:D=>T(D.target.checked),className:"mt-1 rounded bg-gray-600 border-gray-500"}),t.jsxs("label",{htmlFor:"new-project",className:"text-sm text-gray-300",children:[t.jsx("span",{className:"font-medium",children:"This is a new project"}),t.jsx("p",{className:"text-gray-400 mt-0.5",children:"Build foundation architecture first by grouping initial stories together"})]})]}),d&&t.jsx("div",{className:"p-3 bg-red-900/30 border border-red-800 rounded text-sm text-red-400",children:d}),t.jsxs("div",{className:"flex justify-end space-x-3 pt-2",children:[t.jsx("button",{onClick:z,className:"px-4 py-2 text-sm text-gray-400 hover:text-white",children:"Cancel"}),t.jsx("button",{onClick:P,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:h.requiresInput?"Next":"Create Workflow"})]})]}),x==="input"&&h.requiresInput&&t.jsxs("div",{className:"space-y-4",children:[t.jsx("p",{className:"text-sm text-gray-400",children:h.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."}),t.jsxs("div",{onClick:()=>{var D;return(D=a.current)==null?void 0:D.click()},className:"border-2 border-dashed border-gray-600 rounded-lg p-6 text-center hover:border-gray-500 cursor-pointer transition-colors",children:[t.jsx("input",{ref:a,type:"file",accept:".md,.txt,.json,.jsonl",onChange:$,className:"hidden"}),t.jsx("svg",{className:"w-8 h-8 mx-auto text-gray-500 mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),A?t.jsx("p",{className:"text-sm text-primary-400",children:A}):t.jsx("p",{className:"text-sm text-gray-400",children:"Click to upload a file (.md, .txt, .json, .jsonl)"})]}),t.jsx("div",{className:"text-center text-sm text-gray-500",children:"or paste below"}),t.jsx("textarea",{value:N,onChange:D=>{j(D.target.value),M(null)},placeholder:h.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"}),h.requiresInput==="stories"&&t.jsx("p",{className:"text-xs text-gray-500",children:"Supports: Plain text (one story per line), Markdown lists, or JSONL format"}),d&&t.jsx("div",{className:"p-3 bg-red-900/30 border border-red-800 rounded text-sm text-red-400",children:d}),t.jsxs("div",{className:"flex justify-between pt-2",children:[t.jsx("button",{onClick:()=>g("name"),className:"px-4 py-2 text-sm text-gray-400 hover:text-white",children:"Back"}),t.jsxs("div",{className:"flex space-x-3",children:[t.jsx("button",{onClick:z,className:"px-4 py-2 text-sm text-gray-400 hover:text-white",children:"Cancel"}),t.jsx("button",{onClick:V,disabled:!N.trim()||o!==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:o?"Creating...":"Start Workflow"})]})]})]}),x==="creating"&&t.jsxs("div",{className:"py-8 text-center",children:[t.jsx("div",{className:"w-12 h-12 border-4 border-primary-600 border-t-transparent rounded-full animate-spin mx-auto mb-4"}),t.jsx("p",{className:"text-gray-300",children:"Creating your workflow..."}),h.requiresInput&&N&&t.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Uploading resources..."})]})]})})]})}function kp({workflow:e,projectSlug:r}){const s=e.steps||[],a=s.filter(v=>v.status==="completed").length,o=s.length,c=o>0?a/o*100:0,d=s.find(v=>v.step_number===e.current_step),u=(d==null?void 0:d.step_type)==="interactive",h=s.some(v=>v.has_active_run===!0),x=e.status==="active"?h?"running":"idle":e.status,g={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:t.jsx("div",{className:"w-3 h-3 rounded-full border-2 border-gray-500"}),active:t.jsx("div",{className:"w-3 h-3 rounded-full bg-green-500 animate-pulse"}),completed:t.jsx("svg",{className:"w-3 h-3 text-green-400",fill:"currentColor",viewBox:"0 0 20 20",children:t.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:t.jsx("svg",{className:"w-3 h-3 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20",children:t.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 t.jsxs(Re,{to:`/projects/${r}/workflows/${e.id}`,className:"block p-5 rounded-lg bg-gray-800 border border-gray-700 hover:border-gray-600 transition-all group",children:[t.jsxs("div",{className:"flex items-start justify-between mb-4",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h3",{className:"text-lg font-semibold text-white group-hover:text-primary-300 transition-colors truncate",children:e.name}),t.jsxs("p",{className:"text-sm text-gray-400 mt-0.5",children:["Step ",e.current_step," of ",o]})]}),t.jsx("span",{className:`text-xs px-2 py-1 rounded ${g[x]||g.draft}`,children:x.charAt(0).toUpperCase()+x.slice(1)})]}),t.jsxs("div",{className:"mb-4",children:[t.jsxs("div",{className:"flex justify-between text-xs text-gray-400 mb-1",children:[t.jsxs("span",{children:[a," of ",o," steps complete"]}),t.jsxs("span",{children:[Math.round(c),"%"]})]}),t.jsx("div",{className:"h-2 bg-gray-700 rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-gradient-to-r from-primary-600 to-primary-400 transition-all duration-500",style:{width:`${c}%`}})})]}),t.jsxs("div",{className:"space-y-2",children:[s.slice(0,4).map(v=>t.jsxs("div",{className:`flex items-center space-x-3 text-sm ${v.step_number===e.current_step?"text-white":v.status==="completed"?"text-gray-400":"text-gray-500"}`,children:[t.jsx("div",{className:"flex-shrink-0",children:b[v.status]||b.pending}),t.jsx("span",{className:"truncate",children:v.name}),v.step_number===e.current_step&&t.jsx("span",{className:"flex-shrink-0 text-xs px-1.5 py-0.5 rounded bg-gray-700 text-gray-300",children:v.has_active_run?"Running":u?"Interactive":"Ready"})]},v.id)),s.length>4&&t.jsxs("div",{className:"text-xs text-gray-500 pl-6",children:["+",s.length-4," more steps"]})]}),d&&e.status==="active"&&t.jsx("div",{className:"mt-4 pt-4 border-t border-gray-700",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-sm text-gray-400",children:u?"Continue planning...":"View progress..."}),t.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:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})})]})}function Ak({projectSlug:e,onClose:r,onImported:s}){const[a,o]=y.useState("upload"),[c,d]=y.useState(null),[u,h]=y.useState(null),[p,x]=y.useState(!1),[g,b]=y.useState(null),v=y.useRef(null),[k,T]=y.useState(new Set),[N,j]=y.useState(new Set),[A,M]=y.useState(!0),[_,z]=y.useState(!1),[P,$]=y.useState("rename");y.useEffect(()=>{u&&(T(new Set(u.steps.map(W=>W.step_number))),j(new Set(u.resources.map(W=>W.id))))},[u]);const V=async W=>{var Z;const J=(Z=W.target.files)==null?void 0:Z[0];if(J){d(J),b(null),x(!0);try{const de=await dp(e,J);h(de),o("preview")}catch(de){b(de instanceof Error?de.message:"Failed to read file")}finally{x(!1)}}},B=async()=>{if(c){o("importing"),b(null);try{const W={conflict_resolution:P,import_items:k.size>0,import_resources:N.size>0,import_planning:A,import_runs:_,selected_steps:Array.from(k),selected_resource_ids:Array.from(N)},J=await E1(e,c,W);s(J)}catch(W){b(W instanceof Error?W.message:"Import failed"),o("preview")}}},U=async W=>{W.preventDefault();const J=W.dataTransfer.files[0];if(J!=null&&J.name.endsWith(".zip")){d(J),b(null),x(!0);try{const Z=await dp(e,J);h(Z),o("preview")}catch(Z){b(Z instanceof Error?Z.message:"Failed to read file")}finally{x(!1)}}else b("Please drop a .ralphx.zip file")},D=W=>{T(J=>{const Z=new Set(J);return Z.has(W)?Z.delete(W):Z.add(W),Z})},R=W=>{j(J=>{const Z=new Set(J);return Z.has(W)?Z.delete(W):Z.add(W),Z})},X=()=>{u&&(k.size===u.steps.length?T(new Set):T(new Set(u.steps.map(W=>W.step_number))))},I=()=>{u&&(N.size===u.resources.length?j(new Set):j(new Set(u.resources.map(W=>W.id))))},H=u?u.steps.filter(W=>k.has(W.step_number)).reduce((W,J)=>W+J.items_count,0):0;return t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:r,onKeyDown:W=>W.key==="Escape"&&r(),role:"dialog","aria-modal":"true","aria-labelledby":"import-workflow-dialog-title",children:t.jsxs("div",{className:"card max-w-lg w-full mx-4 max-h-[90vh] overflow-y-auto",onClick:W=>W.stopPropagation(),children:[t.jsx("h3",{id:"import-workflow-dialog-title",className:"text-xl font-semibold text-white mb-4",children:"Import Workflow"}),t.jsxs("div",{className:"flex items-center justify-center mb-6 text-sm",children:[t.jsx("span",{className:`${a==="upload"?"text-cyan-400 font-medium":"text-gray-500"}`,children:"1. Upload"}),t.jsx("span",{className:"mx-2 text-gray-600",children:"→"}),t.jsx("span",{className:`${a==="preview"?"text-cyan-400 font-medium":"text-gray-500"}`,children:"2. Preview"}),t.jsx("span",{className:"mx-2 text-gray-600",children:"→"}),t.jsx("span",{className:`${a==="importing"?"text-cyan-400 font-medium":"text-gray-500"}`,children:"3. Import"})]}),g&&t.jsx("div",{className:"mb-4 p-3 rounded bg-red-900/30 border border-red-800 text-red-400 text-sm",children:g}),a==="upload"&&t.jsxs(t.Fragment,{children:[t.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 W;return(W=v.current)==null?void 0:W.click()},onDrop:U,onDragOver:W=>W.preventDefault(),children:[t.jsx("input",{ref:v,type:"file",accept:".zip",onChange:V,className:"hidden"}),p?t.jsxs("div",{children:[t.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:t.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"})}),t.jsx("p",{className:"text-gray-400",children:"Reading file..."})]}):t.jsxs("div",{children:[t.jsx("svg",{className:"w-10 h-10 mx-auto text-gray-500 mb-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),t.jsx("p",{className:"text-white font-medium",children:"Drop a workflow export here"}),t.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"or click to browse"}),t.jsx("p",{className:"text-xs text-gray-600 mt-2",children:"Accepts .ralphx.zip files"})]})]}),t.jsx("div",{className:"flex justify-end mt-6",children:t.jsx("button",{onClick:r,className:"px-4 py-2 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 transition-colors",children:"Cancel"})})]}),a==="preview"&&u&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mb-6 p-4 rounded-lg bg-gray-800/50 border border-gray-700",children:[t.jsx("h4",{className:"font-medium text-white mb-2",children:u.workflow_name}),t.jsxs("div",{className:"text-sm text-gray-400",children:[t.jsxs("span",{children:["Exported: ",new Date(u.exported_at).toLocaleDateString()]}),t.jsx("span",{className:"mx-2",children:"•"}),t.jsxs("span",{children:["RalphX ",u.ralphx_version]})]})]}),!u.is_compatible&&t.jsxs("div",{className:"mb-4 p-3 rounded bg-red-900/30 border border-red-800 text-red-400 text-sm",children:[t.jsx("strong",{children:"Compatibility Issues"}),t.jsx("ul",{className:"list-disc list-inside mt-1",children:u.compatibility_notes.map((W,J)=>t.jsx("li",{children:W},J))})]}),u.is_compatible&&u.compatibility_notes.length>0&&t.jsxs("div",{className:"mb-4 p-3 rounded bg-yellow-900/20 border border-yellow-800 text-yellow-400 text-sm",children:[t.jsx("strong",{children:"Notes"}),t.jsx("ul",{className:"list-disc list-inside mt-1",children:u.compatibility_notes.map((W,J)=>t.jsx("li",{children:W},J))})]}),u.potential_secrets_detected&&t.jsx("div",{className:"mb-4 p-3 rounded bg-yellow-900/30 border border-yellow-700 text-yellow-400 text-sm",children:t.jsxs("div",{className:"flex items-start space-x-2",children:[t.jsx("svg",{className:"w-5 h-5 flex-shrink-0 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{children:"This export may contain secrets or credentials."})]})}),t.jsxs("div",{className:"mb-6 space-y-2",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-3",children:"Select what to import:"}),u.steps.length>0&&t.jsxs("div",{className:"space-y-1",children:[t.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:k.size===u.steps.length&&u.steps.length>0,ref:W=>{W&&(W.indeterminate=k.size>0&&k.size<u.steps.length)},onChange:X,className:"w-4 h-4 rounded border-gray-600 bg-gray-800 text-cyan-500 focus:ring-cyan-500"}),t.jsxs("span",{className:"text-gray-300",children:["Steps (",u.steps.length,")"]})]}),t.jsx("div",{className:"ml-7 space-y-1",children:u.steps.map(W=>t.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:k.has(W.step_number),onChange:()=>D(W.step_number),className:"w-4 h-4 rounded border-gray-600 bg-gray-800 text-cyan-500 focus:ring-cyan-500"}),t.jsxs("span",{className:"text-gray-400",children:[W.name," - ",t.jsxs("span",{className:"text-gray-500",children:[W.items_count," items"]})]})]},W.step_number))})]}),u.resources.length>0&&t.jsxs("div",{className:"space-y-1 mt-3",children:[t.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:N.size===u.resources.length&&u.resources.length>0,ref:W=>{W&&(W.indeterminate=N.size>0&&N.size<u.resources.length)},onChange:I,className:"w-4 h-4 rounded border-gray-600 bg-gray-800 text-cyan-500 focus:ring-cyan-500"}),t.jsxs("span",{className:"text-gray-300",children:["Resources (",u.resources.length,")"]})]}),t.jsx("div",{className:"ml-7 space-y-1",children:u.resources.map(W=>t.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:N.has(W.id),onChange:()=>R(W.id),className:"w-4 h-4 rounded border-gray-600 bg-gray-800 text-cyan-500 focus:ring-cyan-500"}),t.jsxs("span",{className:"text-gray-400",children:[W.name,t.jsxs("span",{className:"text-gray-600 text-xs ml-2",children:["(",W.resource_type,")"]})]})]},W.id))})]}),u.has_planning_session&&t.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer mt-3",children:[t.jsx("input",{type:"checkbox",checked:A,onChange:W=>M(W.target.checked),className:"w-4 h-4 rounded border-gray-600 bg-gray-800 text-cyan-500 focus:ring-cyan-500"}),t.jsx("span",{className:"text-gray-300",children:"Planning Session"})]}),u.has_runs&&t.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:_,onChange:W=>z(W.target.checked),className:"w-4 h-4 rounded border-gray-600 bg-gray-800 text-cyan-500 focus:ring-cyan-500"}),t.jsx("span",{className:"text-gray-300",children:"Execution History"})]})]}),t.jsxs("div",{className:"mb-4 text-sm text-gray-500",children:["Will import: ",k.size," step",k.size!==1?"s":""," (",H," items), ",N.size," resource",N.size!==1?"s":"",A&&u.has_planning_session?", planning session":"",_&&u.has_runs?", execution history":""]}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-2",children:"If conflicts occur"}),t.jsxs("select",{value:P,onChange:W=>$(W.target.value),className:"w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-white",children:[t.jsx("option",{value:"rename",children:"Rename (add suffix)"}),t.jsx("option",{value:"skip",children:"Skip conflicting items"}),t.jsx("option",{value:"overwrite",children:"Overwrite existing"})]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("button",{onClick:()=>{o("upload"),d(null),h(null)},className:"px-4 py-2 text-gray-400 hover:text-white transition-colors",children:"Choose different file"}),t.jsxs("div",{className:"flex space-x-3",children:[t.jsx("button",{onClick:r,className:"px-4 py-2 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 transition-colors",children:"Cancel"}),t.jsxs("button",{onClick:B,disabled:!u.is_compatible||k.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:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{children:"Import as New Workflow"})]})]})]})]}),a==="importing"&&t.jsxs("div",{className:"py-8 text-center",children:[t.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:t.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"})}),t.jsx("p",{className:"text-white font-medium",children:"Importing workflow..."}),t.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"This may take a moment"})]})]})})}function Pk(){const{slug:e}=Vr(),r=Dr(),{selectedProject:s,setSelectedProject:a,setLoops:o,setLoopsLoading:c}=sn(),[d,u]=y.useState(null),[h,p]=y.useState([]),[x,g]=y.useState([]),[b,v]=y.useState(!0),[k,T]=y.useState(!1),[N,j]=y.useState(!1),[A,M]=y.useState(!1),[_,z]=y.useState(null),P=y.useCallback(async()=>{if(e){v(!0);try{const I=await qo(e);p(I);const H=await qo(e,{archived_only:!0});g(H)}catch{p([]),g([])}finally{v(!1)}}},[e]),$=y.useCallback(async()=>{if(e){c(!0);try{const I=await pu(e),H=I.filter(J=>!J.workflow_id);T(H.length>0);const W=await Promise.all(I.map(async J=>{try{const Z=await Qf(e,J.name);return{...J,is_running:Z.is_running,current_iteration:Z.current_iteration,current_mode:Z.current_mode}}catch{return{...J,is_running:!1}}}));o(W)}catch{o([])}finally{c(!1)}}},[e,o,c]);y.useEffect(()=>{if(!e)return;a(null),p([]);async function I(){u(null);try{const H=await ys(e);a(H)}catch(H){u(H instanceof Error?H.message:"Failed to load project")}}I(),P(),$()},[e,a,P,$]);const V=async(I,H)=>{if(!(!e||!(await gt.fire({title:"Restore Workflow?",text:`Restore "${H}" 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 Zb(e,I),P()}catch(J){gt.fire({title:"Error",text:J instanceof Error?J.message:"Failed to restore workflow",icon:"error",background:"var(--color-surface)",color:"var(--color-text-primary)"})}},B=async(I,H)=>{if(!(!e||!(await gt.fire({title:"Permanently Delete?",html:`<p>This will permanently delete "<strong>${H}</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 Jb(e,I),P()}catch(J){gt.fire({title:"Error",text:J instanceof Error?J.message:"Failed to delete workflow",icon:"error",background:"var(--color-surface)",color:"var(--color-text-primary)"})}};if(d)return t.jsx("div",{className:"p-6",children:t.jsxs("div",{className:"card bg-red-900/20 border border-red-800",children:[t.jsx("h2",{className:"text-lg font-semibold text-red-400 mb-2",children:"Error"}),t.jsx("p",{className:"text-gray-300",children:d}),t.jsx(Re,{to:"/",className:"btn-secondary mt-4 inline-block",children:"Back to Dashboard"})]})});if(!s)return t.jsx("div",{className:"p-6",children:t.jsx("div",{className:"text-gray-400",children:"Loading project..."})});const U=h.filter(I=>I.status==="active"||I.status==="draft"||I.status==="paused"),D=h.filter(I=>I.status==="completed"),X=!(h.length>0)&&!b;return t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"mb-8",children:[t.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[t.jsx(Re,{to:"/",className:"hover:text-white",children:"Dashboard"}),t.jsx("span",{children:"/"}),t.jsx("span",{className:"text-white",children:s.name})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-3xl font-bold text-white mb-2",children:s.name}),t.jsx("p",{className:"text-gray-400",children:s.path})]}),t.jsxs(Re,{to:`/projects/${e}/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:[t.jsxs("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[t.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"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),t.jsx("span",{children:"Settings"})]})]})]}),s.stats&&t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-8",children:[t.jsxs("div",{className:"card",children:[t.jsx("div",{className:"text-2xl font-bold text-primary-400",children:h.length}),t.jsx("div",{className:"text-sm text-gray-400",children:"Workflows"})]}),t.jsxs("div",{className:"card",children:[t.jsx("div",{className:"text-2xl font-bold text-green-400",children:U.length}),t.jsx("div",{className:"text-sm text-gray-400",children:"Active"})]}),t.jsxs("div",{className:"card",children:[t.jsx("div",{className:"text-2xl font-bold text-yellow-400",children:s.stats.pending_items}),t.jsx("div",{className:"text-sm text-gray-400",children:"Pending Items"})]}),t.jsxs("div",{className:"card",children:[t.jsx("div",{className:"text-2xl font-bold text-blue-400",children:s.stats.completed_items}),t.jsx("div",{className:"text-sm text-gray-400",children:"Completed Items"})]})]}),X&&t.jsx("div",{className:"mb-8 p-6 rounded-xl bg-gradient-to-br from-gray-800 to-gray-900 border border-gray-700",children:t.jsx(jp,{projectSlug:e,onWorkflowCreated:P})}),U.length>0&&t.jsxs("div",{className:"mb-8",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h2",{className:"text-xl font-semibold text-white",children:"Active Workflows"}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.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:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{children:"Import Workflow"})]}),t.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:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),t.jsx("span",{children:"New Workflow"})]})]})]}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:U.map(I=>t.jsx(kp,{workflow:I,projectSlug:e},I.id))})]}),D.length>0&&t.jsx("div",{className:"mb-8",children:t.jsxs("details",{className:"group",children:[t.jsxs("summary",{className:"flex items-center justify-between cursor-pointer mb-4",children:[t.jsxs("h2",{className:"text-xl font-semibold text-white",children:["Completed Workflows",t.jsxs("span",{className:"ml-2 text-sm font-normal text-gray-400",children:["(",D.length,")"]})]}),t.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:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:D.map(I=>t.jsx(kp,{workflow:I,projectSlug:e},I.id))})]})}),x.length>0&&t.jsx("div",{className:"mb-8",children:t.jsxs("details",{className:"group",children:[t.jsxs("summary",{className:"flex items-center justify-between cursor-pointer mb-4",children:[t.jsxs("h2",{className:"text-xl font-semibold text-gray-400",children:[t.jsx("svg",{className:"w-5 h-5 inline-block mr-2 -mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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",t.jsxs("span",{className:"ml-2 text-sm font-normal",children:["(",x.length,")"]})]}),t.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:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),t.jsx("div",{className:"space-y-2",children:x.map(I=>t.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-gray-800/50 border border-gray-700/50",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-400 truncate",children:I.name}),t.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["Archived ",I.archived_at?new Date(I.archived_at).toLocaleDateString():""]})]}),t.jsxs("div",{className:"flex items-center space-x-2 ml-4",children:[t.jsx("button",{onClick:()=>V(I.id,I.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"}),t.jsx("button",{onClick:()=>B(I.id,I.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"})]})]},I.id))})]})}),k&&t.jsx("div",{className:"mb-8 p-4 rounded-lg bg-gray-800 border border-gray-700",children:t.jsxs("div",{className:"flex items-start space-x-3",children:[t.jsx("svg",{className:"w-5 h-5 text-yellow-400 flex-shrink-0 mt-0.5",fill:"currentColor",viewBox:"0 0 20 20",children:t.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"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h3",{className:"text-sm font-medium text-white",children:"Legacy Loops Detected"}),t.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."})]})]})}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[t.jsx(Re,{to:`/projects/${e}/dashboard`,className:"p-4 rounded-lg bg-gray-800 border border-gray-700 hover:border-gray-600 transition-colors group",children:t.jsxs("div",{className:"flex items-center space-x-3",children:[t.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:t.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"})}),t.jsx("span",{className:"text-sm text-gray-300 group-hover:text-white",children:"Project Dashboard"})]})}),t.jsx(Re,{to:`/projects/${e}/runs`,className:"p-4 rounded-lg bg-gray-800 border border-gray-700 hover:border-gray-600 transition-colors group",children:t.jsxs("div",{className:"flex items-center space-x-3",children:[t.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:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),t.jsx("span",{className:"text-sm text-gray-300 group-hover:text-white",children:"Run History"})]})}),t.jsx(Re,{to:`/projects/${e}/settings?tab=resources`,className:"p-4 rounded-lg bg-gray-800 border border-gray-700 hover:border-gray-600 transition-colors group",children:t.jsxs("div",{className:"flex items-center space-x-3",children:[t.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:t.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"})}),t.jsx("span",{className:"text-sm text-gray-300 group-hover:text-white",children:"Shared Resources"})]})}),t.jsx(Re,{to:`/projects/${e}/settings?tab=auth`,className:"p-4 rounded-lg bg-gray-800 border border-gray-700 hover:border-gray-600 transition-colors group",children:t.jsxs("div",{className:"flex items-center space-x-3",children:[t.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:t.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"})}),t.jsx("span",{className:"text-sm text-gray-300 group-hover:text-white",children:"Authentication"})]})})]}),N&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.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:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h2",{className:"text-xl font-semibold text-white",children:"Create New Workflow"}),t.jsx("button",{onClick:()=>j(!1),className:"text-gray-400 hover:text-white",children:t.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsx(jp,{projectSlug:e,onWorkflowCreated:()=>{j(!1),P()}})]})}),A&&t.jsx(Ak,{projectSlug:e,onClose:()=>M(!1),onImported:I=>{z(I),M(!1),P(),r(`/projects/${e}/workflows/${I.workflow_id}`)}}),_&&t.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:t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-green-400 font-medium",children:"Import Complete"}),t.jsxs("p",{className:"text-sm text-gray-300 mt-1",children:['"',_.workflow_name,'" imported successfully']}),t.jsxs("p",{className:"text-xs text-gray-400 mt-1",children:[_.steps_created," steps, ",_.items_imported," items, ",_.resources_created," resources"]}),_.warnings.length>0&&t.jsxs("p",{className:"text-sm text-yellow-400 mt-1",children:[_.warnings.length," warning(s)"]})]}),t.jsx("button",{onClick:()=>z(null),className:"text-gray-400 hover:text-white ml-4",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})]})}function Ik({projectSlug:e,loopName:r,loopType:s,isRunning:a,isPaused:o,onStatusChange:c}){const[d,u]=y.useState(!1),[h,p]=y.useState(null),[x,g]=y.useState(!1),[b,v]=y.useState(null),k=y.useRef(null);y.useEffect(()=>{if(!x)return;const I=H=>{k.current&&!k.current.contains(H.target)&&g(!1)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[x]);const[T,N]=y.useState(void 0),[j,A]=y.useState(void 0),[M,_]=y.useState(!0),[z,P]=y.useState(!1),[$,V]=y.useState(10);y.useEffect(()=>{if(s!=="consumer"||a)return;let I=!0;return Jw(e,r).then(H=>{I&&v(H)}).catch(()=>{I&&v(null)}),()=>{I=!1}},[e,r,s,a]);const B=async I=>{u(!0),p(null);try{await I(),c==null||c()}catch(H){p(H instanceof Error?H.message:"Action failed")}finally{u(!1)}},U=async()=>{(await gt.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(()=>Xw(e,r))},D=async()=>{(await gt.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(()=>Od(e,r))},R=async()=>{const I={};T!==void 0&&(I.phase=T),j&&(I.category=j),I.respect_dependencies=M,I.batch_mode=z,z&&(I.batch_size=$),await B(()=>Od(e,r,I)),g(!1)},X=s==="consumer"||(b==null?void 0:b.source_step_id);return t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("div",{className:"flex items-center space-x-3",children:[!a&&t.jsx(t.Fragment,{children:X&&b&&b.total_items>0?t.jsxs("div",{className:"relative",ref:k,children:[t.jsxs("button",{onClick:()=>g(!x),className:"btn-primary disabled:opacity-50 flex items-center space-x-2","aria-haspopup":"true","aria-expanded":x,"aria-label":"Start loop with options",children:[t.jsx(fd,{}),t.jsx("span",{children:"Start"}),t.jsx(Rk,{})]}),x&&t.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:t.jsxs("div",{className:"space-y-4",children:[b.phases.length>0&&t.jsxs("div",{children:[t.jsx("label",{htmlFor:"phaseSelect",className:"block text-sm font-medium text-gray-300 mb-1",children:"Phase"}),t.jsxs("select",{id:"phaseSelect",value:T??"",onChange:I=>N(I.target.value?parseInt(I.target.value):void 0),className:"w-full bg-gray-700 border border-gray-600 rounded px-3 py-2 text-white text-sm",children:[t.jsx("option",{value:"",children:"All Phases"}),b.phases.map(I=>t.jsxs("option",{value:I.phase_number,children:["Phase ",I.phase_number," (",I.pending_count," pending / ",I.item_count," total)"]},I.phase_number))]})]}),b.categories.length>0&&t.jsxs("div",{children:[t.jsx("label",{htmlFor:"categorySelect",className:"block text-sm font-medium text-gray-300 mb-1",children:"Category"}),t.jsxs("select",{id:"categorySelect",value:j??"",onChange:I=>A(I.target.value||void 0),className:"w-full bg-gray-700 border border-gray-600 rounded px-3 py-2 text-white text-sm",children:[t.jsx("option",{value:"",children:"All Categories"}),b.categories.map(I=>t.jsxs("option",{value:I.name,children:[I.name.toUpperCase()," (",I.pending_count," pending / ",I.item_count," total)"]},I.name))]})]}),b.has_dependencies&&t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("input",{type:"checkbox",id:"respectDeps",checked:M,onChange:I=>_(I.target.checked),className:"rounded bg-gray-700 border-gray-600"}),t.jsx("label",{htmlFor:"respectDeps",className:"text-sm text-gray-300",children:"Respect dependency order"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("input",{type:"checkbox",id:"batchMode",checked:z,onChange:I=>P(I.target.checked),className:"rounded bg-gray-700 border-gray-600"}),t.jsx("label",{htmlFor:"batchMode",className:"text-sm text-gray-300",children:"Batch mode (implement multiple together)"})]}),z&&t.jsxs("div",{className:"ml-6",children:[t.jsx("label",{htmlFor:"batchSizeInput",className:"block text-xs text-gray-400 mb-1",children:"Batch size"}),t.jsx("input",{id:"batchSizeInput",type:"number",min:1,max:50,value:$,onChange:I=>V(Math.min(50,Math.max(1,parseInt(I.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&&t.jsx("div",{className:"space-y-1",children:b.warnings.map((I,H)=>t.jsxs("div",{className:"text-xs text-yellow-400 flex items-start space-x-1",children:[t.jsx($k,{}),t.jsx("span",{children:I})]},H))}),t.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&&t.jsxs("span",{children:[" | ",b.graph_stats.items_with_dependencies," with dependencies"]})]}),t.jsxs("div",{className:"flex justify-end space-x-2 pt-2 border-t border-gray-700",children:[t.jsx("button",{onClick:()=>g(!1),className:"px-3 py-1.5 text-sm text-gray-400 hover:text-white",children:"Cancel"}),t.jsx("button",{onClick:R,disabled:d,className:"px-4 py-1.5 text-sm bg-green-600 hover:bg-green-700 text-white rounded disabled:opacity-50",children:d?"Starting...":"Start Loop"})]})]})})]}):t.jsxs("button",{onClick:D,disabled:d,className:"btn-primary disabled:opacity-50 flex items-center space-x-2",children:[t.jsx(fd,{}),t.jsx("span",{children:"Start"})]})}),a&&!o&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>B(()=>Zw(e,r)),disabled:d,className:"btn-secondary disabled:opacity-50 flex items-center space-x-2",children:[t.jsx(Mk,{}),t.jsx("span",{children:"Pause"})]}),t.jsxs("button",{onClick:U,disabled:d,className:"btn-danger disabled:opacity-50 flex items-center space-x-2",children:[t.jsx(Np,{}),t.jsx("span",{children:"Stop"})]})]}),a&&o&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>B(()=>eb(e,r)),disabled:d,className:"btn-primary disabled:opacity-50 flex items-center space-x-2",children:[t.jsx(fd,{}),t.jsx("span",{children:"Resume"})]}),t.jsxs("button",{onClick:U,disabled:d,className:"btn-danger disabled:opacity-50 flex items-center space-x-2",children:[t.jsx(Np,{}),t.jsx("span",{children:"Stop"})]})]}),d&&t.jsx("span",{className:"text-sm text-gray-400 animate-pulse",children:"Processing..."})]}),h&&t.jsx("div",{className:"mt-2 text-sm text-red-400",role:"alert",children:h})]})}function fd(){return t.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:t.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 Mk(){return t.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:t.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 Np(){return t.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:t.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 Rk(){return t.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:t.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 $k(){return t.jsx("svg",{className:"w-4 h-4 flex-shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:t.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 Dk({value:e,max:r=100,label:s,showPercent:a=!1,size:o="md",color:c="primary"}){const d=Math.min(100,Math.max(0,e/r*100)),u={sm:"h-1",md:"h-2",lg:"h-3"},h={primary:"bg-primary-500",green:"bg-green-500",yellow:"bg-yellow-500",red:"bg-red-500"};return t.jsxs("div",{className:"w-full",children:[(s||a)&&t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s&&t.jsx("span",{className:"text-xs text-gray-400",children:s}),a&&t.jsxs("span",{className:"text-xs text-gray-400",children:[Math.round(d),"%"]})]}),t.jsx("div",{className:`w-full bg-gray-700 rounded-full overflow-hidden ${u[o]}`,children:t.jsx("div",{className:`${u[o]} ${h[c]} rounded-full transition-all duration-300`,style:{width:`${d}%`}})})]})}function tg({url:e,enabled:r=!0,onEvent:s,onError:a,onOpen:o,retryInterval:c=3e3,maxRetries:d=5,maxStoredEvents:u=1e3}){const[h,p]=y.useState([]),[x,g]=y.useState(!1),[b,v]=y.useState(null),k=y.useRef(null),T=y.useRef(0),N=y.useRef(null),j=y.useCallback(()=>{p([])},[]),A=y.useCallback(()=>{N.current&&(clearTimeout(N.current),N.current=null),k.current&&(k.current.close(),k.current=null),g(!1)},[]),M=y.useCallback(()=>{A(),v(null);try{const _=new EventSource(e);k.current=_,_.onopen=()=>{g(!0),v(null),T.current=0,o==null||o()},_.onerror=P=>{_.close(),k.current=null,g(!1),a==null||a(P),!N.current&&(T.current<d?(T.current+=1,v(`Connection lost. Retrying (${T.current}/${d})...`),N.current=setTimeout(()=>{N.current=null,M()},c)):v("Connection failed after maximum retries"))},["connected","status","text","tool_call","tool_result","init","complete","error","heartbeat","info","session_start","disconnected"].forEach(P=>{_.addEventListener(P,$=>{try{const V=JSON.parse($.data),B={type:P,data:V,timestamp:new Date};p(U=>{const D=[...U,B];return D.length>u?D.slice(-u):D}),s==null||s(B)}catch{}})})}catch(_){v(_ instanceof Error?_.message:"Failed to connect")}},[e,A,o,a,s,d,c,u]);return y.useEffect(()=>(r?M():A(),()=>{A()}),[r,M,A]),{events:h,isConnected:x,error:b,connect:M,disconnect:A,clearEvents:j}}function rg({projectSlug:e,loopName:r,sessionId:s,enabled:a=!0,maxEvents:o=500}){const[c,d]=y.useState(!0),[u,h]=y.useState(!1),p=y.useRef(null);let x=`/api/projects/${e}`;s?x+=`/sessions/${s}/tail`:r?x+=`/loops/${r}/stream`:x="";const{events:g,isConnected:b,error:v,connect:k,disconnect:T,clearEvents:N}=tg({url:x,enabled:a&&!u&&!!x});y.useEffect(()=>{c&&p.current&&(p.current.scrollTop=p.current.scrollHeight)},[g,c]);const j=g.slice(-o),A=()=>{u?(h(!1),k()):(h(!0),T())},[M,_]=y.useState("idle"),z=async()=>{const P=j.map($=>Ok($)).join(`
|
|
138
|
+
`);try{await navigator.clipboard.writeText(P),_("success"),setTimeout(()=>_("idle"),2e3)}catch{_("error"),setTimeout(()=>_("idle"),2e3)}};return x?t.jsxs("div",{className:"card flex flex-col h-[500px]",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4 flex-shrink-0",children:[t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx("h3",{className:"text-lg font-semibold text-white",children:"Live Output"}),t.jsx(Bk,{isConnected:b,isPaused:u})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("button",{onClick:()=>d(!c),className:`px-3 py-1 text-sm rounded ${c?"bg-primary-600 text-white":"bg-gray-700 text-gray-300"}`,children:"Auto-scroll"}),t.jsx("button",{onClick:A,className:`px-3 py-1 text-sm rounded ${u?"bg-yellow-600 text-white":"bg-gray-700 text-gray-300"}`,children:u?"Resume":"Pause"}),t.jsx("button",{onClick:z,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"}),t.jsx("button",{onClick:N,className:"px-3 py-1 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600",children:"Clear"})]})]}),v&&t.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:v}),t.jsx("div",{ref:p,className:"flex-1 overflow-auto bg-gray-900 rounded font-mono text-sm",children:j.length===0?t.jsx("div",{className:"p-4 text-gray-500 text-center",children:b?"Waiting for events...":"Not connected"}):t.jsx("div",{className:"p-2 space-y-1",children:j.map((P,$)=>t.jsx(zk,{event:P},$))})}),t.jsxs("div",{className:"mt-2 text-xs text-gray-500 flex-shrink-0",children:[j.length," events",g.length>o&&` (${g.length-o} truncated)`]})]}):t.jsx("div",{className:"card text-center py-8",children:t.jsx("p",{className:"text-gray-400",children:"No session or loop specified"})})}function Bk({isConnected:e,isPaused:r}){return r?t.jsxs("span",{className:"flex items-center space-x-1.5 text-sm text-yellow-400",children:[t.jsx("span",{className:"w-2 h-2 rounded-full bg-yellow-400"}),t.jsx("span",{children:"Paused"})]}):t.jsxs("span",{className:`flex items-center space-x-1.5 text-sm ${e?"text-green-400":"text-gray-400"}`,children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${e?"bg-green-400 animate-pulse":"bg-gray-500"}`}),t.jsx("span",{children:e?"Connected":"Disconnected"})]})}function zk({event:e}){const r=e.timestamp.toLocaleTimeString();switch(e.type){case"text":return t.jsxs("div",{className:"text-gray-200 whitespace-pre-wrap",children:[t.jsx("span",{className:"text-gray-500 mr-2",children:r}),String(e.data.content||"")]});case"tool_call":return t.jsxs("div",{className:"text-blue-400",children:[t.jsx("span",{className:"text-gray-500 mr-2",children:r}),t.jsx("span",{className:"font-semibold",children:"Tool:"})," ",String(e.data.name||"unknown"),e.data.input?t.jsxs("span",{className:"text-gray-400 ml-2",children:[JSON.stringify(e.data.input).slice(0,100),"..."]}):null]});case"tool_result":return t.jsxs("div",{className:"text-green-400",children:[t.jsx("span",{className:"text-gray-500 mr-2",children:r}),t.jsx("span",{className:"font-semibold",children:"Result:"})," ",String(e.data.result||"").slice(0,200),String(e.data.result||"").length>200&&"..."]});case"error":return t.jsxs("div",{className:"text-red-400",children:[t.jsx("span",{className:"text-gray-500 mr-2",children:r}),t.jsx("span",{className:"font-semibold",children:"Error:"})," ",String(e.data.message||"Unknown error")]});case"status":return t.jsxs("div",{className:"text-yellow-400",children:[t.jsx("span",{className:"text-gray-500 mr-2",children:r}),t.jsx("span",{className:"font-semibold",children:"Status:"})," ",String(e.data.status||""),e.data.iteration?` (iteration ${String(e.data.iteration)})`:null]});case"connected":case"session_start":return t.jsxs("div",{className:"text-primary-400",children:[t.jsx("span",{className:"text-gray-500 mr-2",children:r}),t.jsx("span",{className:"font-semibold",children:"Connected"})]});case"complete":return t.jsxs("div",{className:"text-green-400 font-semibold",children:[t.jsx("span",{className:"text-gray-500 mr-2",children:r}),"Session Complete"]});case"heartbeat":return null;case"info":return t.jsxs("div",{className:"text-gray-400",children:[t.jsx("span",{className:"text-gray-500 mr-2",children:r}),String(e.data.message||"")]});default:return t.jsxs("div",{className:"text-gray-500",children:[t.jsx("span",{className:"mr-2",children:r}),"[",e.type,"] ",JSON.stringify(e.data).slice(0,100)]})}}function Ok(e){const r=e.timestamp.toISOString();switch(e.type){case"text":return`[${r}] ${e.data.content}`;case"tool_call":return`[${r}] Tool: ${e.data.name}`;case"tool_result":return`[${r}] Result: ${String(e.data.result).slice(0,500)}`;case"error":return`[${r}] Error: ${e.data.message}`;default:return`[${r}] [${e.type}] ${JSON.stringify(e.data)}`}}/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function ng(e){return typeof e>"u"||e===null}function Fk(e){return typeof e=="object"&&e!==null}function Wk(e){return Array.isArray(e)?e:ng(e)?[]:[e]}function Hk(e,r){var s,a,o,c;if(r)for(c=Object.keys(r),s=0,a=c.length;s<a;s+=1)o=c[s],e[o]=r[o];return e}function Uk(e,r){var s="",a;for(a=0;a<r;a+=1)s+=e;return s}function Vk(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var qk=ng,Yk=Fk,Gk=Wk,Kk=Uk,Qk=Vk,Jk=Hk,Mt={isNothing:qk,isObject:Yk,toArray:Gk,repeat:Kk,isNegativeZero:Qk,extend:Jk};function sg(e,r){var s="",a=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(s+='in "'+e.mark.name+'" '),s+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!r&&e.mark.snippet&&(s+=`
|
|
139
|
+
|
|
140
|
+
`+e.mark.snippet),a+" "+s):a}function ua(e,r){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=r,this.message=sg(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}ua.prototype=Object.create(Error.prototype);ua.prototype.constructor=ua;ua.prototype.toString=function(r){return this.name+": "+sg(this,r)};var nr=ua;function xd(e,r,s,a,o){var c="",d="",u=Math.floor(o/2)-1;return a-r>u&&(c=" ... ",r=a-u+c.length),s-a>u&&(d=" ...",s=a+u-d.length),{str:c+e.slice(r,s).replace(/\t/g,"→")+d,pos:a-r+c.length}}function gd(e,r){return Mt.repeat(" ",r-e.length)+e}function Xk(e,r){if(r=Object.create(r||null),!e.buffer)return null;r.maxLength||(r.maxLength=79),typeof r.indent!="number"&&(r.indent=1),typeof r.linesBefore!="number"&&(r.linesBefore=3),typeof r.linesAfter!="number"&&(r.linesAfter=2);for(var s=/\r?\n|\r|\0/g,a=[0],o=[],c,d=-1;c=s.exec(e.buffer);)o.push(c.index),a.push(c.index+c[0].length),e.position<=c.index&&d<0&&(d=a.length-2);d<0&&(d=a.length-1);var u="",h,p,x=Math.min(e.line+r.linesAfter,o.length).toString().length,g=r.maxLength-(r.indent+x+3);for(h=1;h<=r.linesBefore&&!(d-h<0);h++)p=xd(e.buffer,a[d-h],o[d-h],e.position-(a[d]-a[d-h]),g),u=Mt.repeat(" ",r.indent)+gd((e.line-h+1).toString(),x)+" | "+p.str+`
|
|
141
|
+
`+u;for(p=xd(e.buffer,a[d],o[d],e.position,g),u+=Mt.repeat(" ",r.indent)+gd((e.line+1).toString(),x)+" | "+p.str+`
|
|
142
|
+
`,u+=Mt.repeat("-",r.indent+x+3+p.pos)+`^
|
|
143
|
+
`,h=1;h<=r.linesAfter&&!(d+h>=o.length);h++)p=xd(e.buffer,a[d+h],o[d+h],e.position-(a[d]-a[d+h]),g),u+=Mt.repeat(" ",r.indent)+gd((e.line+h+1).toString(),x)+" | "+p.str+`
|
|
144
|
+
`;return u.replace(/\n$/,"")}var Zk=Xk,eN=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],tN=["scalar","sequence","mapping"];function rN(e){var r={};return e!==null&&Object.keys(e).forEach(function(s){e[s].forEach(function(a){r[String(a)]=s})}),r}function nN(e,r){if(r=r||{},Object.keys(r).forEach(function(s){if(eN.indexOf(s)===-1)throw new nr('Unknown option "'+s+'" is met in definition of "'+e+'" YAML type.')}),this.options=r,this.tag=e,this.kind=r.kind||null,this.resolve=r.resolve||function(){return!0},this.construct=r.construct||function(s){return s},this.instanceOf=r.instanceOf||null,this.predicate=r.predicate||null,this.represent=r.represent||null,this.representName=r.representName||null,this.defaultStyle=r.defaultStyle||null,this.multi=r.multi||!1,this.styleAliases=rN(r.styleAliases||null),tN.indexOf(this.kind)===-1)throw new nr('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var Ut=nN;function Cp(e,r){var s=[];return e[r].forEach(function(a){var o=s.length;s.forEach(function(c,d){c.tag===a.tag&&c.kind===a.kind&&c.multi===a.multi&&(o=d)}),s[o]=a}),s}function sN(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},r,s;function a(o){o.multi?(e.multi[o.kind].push(o),e.multi.fallback.push(o)):e[o.kind][o.tag]=e.fallback[o.tag]=o}for(r=0,s=arguments.length;r<s;r+=1)arguments[r].forEach(a);return e}function Yd(e){return this.extend(e)}Yd.prototype.extend=function(r){var s=[],a=[];if(r instanceof Ut)a.push(r);else if(Array.isArray(r))a=a.concat(r);else if(r&&(Array.isArray(r.implicit)||Array.isArray(r.explicit)))r.implicit&&(s=s.concat(r.implicit)),r.explicit&&(a=a.concat(r.explicit));else throw new nr("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");s.forEach(function(c){if(!(c instanceof Ut))throw new nr("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(c.loadKind&&c.loadKind!=="scalar")throw new nr("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(c.multi)throw new nr("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),a.forEach(function(c){if(!(c instanceof Ut))throw new nr("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var o=Object.create(Yd.prototype);return o.implicit=(this.implicit||[]).concat(s),o.explicit=(this.explicit||[]).concat(a),o.compiledImplicit=Cp(o,"implicit"),o.compiledExplicit=Cp(o,"explicit"),o.compiledTypeMap=sN(o.compiledImplicit,o.compiledExplicit),o};var ig=Yd,ag=new Ut("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),og=new Ut("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),lg=new Ut("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),cg=new ig({explicit:[ag,og,lg]});function iN(e){if(e===null)return!0;var r=e.length;return r===1&&e==="~"||r===4&&(e==="null"||e==="Null"||e==="NULL")}function aN(){return null}function oN(e){return e===null}var dg=new Ut("tag:yaml.org,2002:null",{kind:"scalar",resolve:iN,construct:aN,predicate:oN,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function lN(e){if(e===null)return!1;var r=e.length;return r===4&&(e==="true"||e==="True"||e==="TRUE")||r===5&&(e==="false"||e==="False"||e==="FALSE")}function cN(e){return e==="true"||e==="True"||e==="TRUE"}function dN(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var ug=new Ut("tag:yaml.org,2002:bool",{kind:"scalar",resolve:lN,construct:cN,predicate:dN,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function uN(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function mN(e){return 48<=e&&e<=55}function hN(e){return 48<=e&&e<=57}function pN(e){if(e===null)return!1;var r=e.length,s=0,a=!1,o;if(!r)return!1;if(o=e[s],(o==="-"||o==="+")&&(o=e[++s]),o==="0"){if(s+1===r)return!0;if(o=e[++s],o==="b"){for(s++;s<r;s++)if(o=e[s],o!=="_"){if(o!=="0"&&o!=="1")return!1;a=!0}return a&&o!=="_"}if(o==="x"){for(s++;s<r;s++)if(o=e[s],o!=="_"){if(!uN(e.charCodeAt(s)))return!1;a=!0}return a&&o!=="_"}if(o==="o"){for(s++;s<r;s++)if(o=e[s],o!=="_"){if(!mN(e.charCodeAt(s)))return!1;a=!0}return a&&o!=="_"}}if(o==="_")return!1;for(;s<r;s++)if(o=e[s],o!=="_"){if(!hN(e.charCodeAt(s)))return!1;a=!0}return!(!a||o==="_")}function fN(e){var r=e,s=1,a;if(r.indexOf("_")!==-1&&(r=r.replace(/_/g,"")),a=r[0],(a==="-"||a==="+")&&(a==="-"&&(s=-1),r=r.slice(1),a=r[0]),r==="0")return 0;if(a==="0"){if(r[1]==="b")return s*parseInt(r.slice(2),2);if(r[1]==="x")return s*parseInt(r.slice(2),16);if(r[1]==="o")return s*parseInt(r.slice(2),8)}return s*parseInt(r,10)}function xN(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!Mt.isNegativeZero(e)}var mg=new Ut("tag:yaml.org,2002:int",{kind:"scalar",resolve:pN,construct:fN,predicate:xN,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),gN=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function yN(e){return!(e===null||!gN.test(e)||e[e.length-1]==="_")}function vN(e){var r,s;return r=e.replace(/_/g,"").toLowerCase(),s=r[0]==="-"?-1:1,"+-".indexOf(r[0])>=0&&(r=r.slice(1)),r===".inf"?s===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:r===".nan"?NaN:s*parseFloat(r,10)}var wN=/^[-+]?[0-9]+e/;function bN(e,r){var s;if(isNaN(e))switch(r){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(r){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(r){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(Mt.isNegativeZero(e))return"-0.0";return s=e.toString(10),wN.test(s)?s.replace("e",".e"):s}function jN(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||Mt.isNegativeZero(e))}var hg=new Ut("tag:yaml.org,2002:float",{kind:"scalar",resolve:yN,construct:vN,predicate:jN,represent:bN,defaultStyle:"lowercase"}),pg=cg.extend({implicit:[dg,ug,mg,hg]}),fg=pg,xg=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),gg=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 kN(e){return e===null?!1:xg.exec(e)!==null||gg.exec(e)!==null}function NN(e){var r,s,a,o,c,d,u,h=0,p=null,x,g,b;if(r=xg.exec(e),r===null&&(r=gg.exec(e)),r===null)throw new Error("Date resolve error");if(s=+r[1],a=+r[2]-1,o=+r[3],!r[4])return new Date(Date.UTC(s,a,o));if(c=+r[4],d=+r[5],u=+r[6],r[7]){for(h=r[7].slice(0,3);h.length<3;)h+="0";h=+h}return r[9]&&(x=+r[10],g=+(r[11]||0),p=(x*60+g)*6e4,r[9]==="-"&&(p=-p)),b=new Date(Date.UTC(s,a,o,c,d,u,h)),p&&b.setTime(b.getTime()-p),b}function CN(e){return e.toISOString()}var yg=new Ut("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:kN,construct:NN,instanceOf:Date,represent:CN});function SN(e){return e==="<<"||e===null}var vg=new Ut("tag:yaml.org,2002:merge",{kind:"scalar",resolve:SN}),Du=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
145
|
+
\r`;function _N(e){if(e===null)return!1;var r,s,a=0,o=e.length,c=Du;for(s=0;s<o;s++)if(r=c.indexOf(e.charAt(s)),!(r>64)){if(r<0)return!1;a+=6}return a%8===0}function LN(e){var r,s,a=e.replace(/[\r\n=]/g,""),o=a.length,c=Du,d=0,u=[];for(r=0;r<o;r++)r%4===0&&r&&(u.push(d>>16&255),u.push(d>>8&255),u.push(d&255)),d=d<<6|c.indexOf(a.charAt(r));return s=o%4*6,s===0?(u.push(d>>16&255),u.push(d>>8&255),u.push(d&255)):s===18?(u.push(d>>10&255),u.push(d>>2&255)):s===12&&u.push(d>>4&255),new Uint8Array(u)}function EN(e){var r="",s=0,a,o,c=e.length,d=Du;for(a=0;a<c;a++)a%3===0&&a&&(r+=d[s>>18&63],r+=d[s>>12&63],r+=d[s>>6&63],r+=d[s&63]),s=(s<<8)+e[a];return o=c%3,o===0?(r+=d[s>>18&63],r+=d[s>>12&63],r+=d[s>>6&63],r+=d[s&63]):o===2?(r+=d[s>>10&63],r+=d[s>>4&63],r+=d[s<<2&63],r+=d[64]):o===1&&(r+=d[s>>2&63],r+=d[s<<4&63],r+=d[64],r+=d[64]),r}function TN(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var wg=new Ut("tag:yaml.org,2002:binary",{kind:"scalar",resolve:_N,construct:LN,predicate:TN,represent:EN}),AN=Object.prototype.hasOwnProperty,PN=Object.prototype.toString;function IN(e){if(e===null)return!0;var r=[],s,a,o,c,d,u=e;for(s=0,a=u.length;s<a;s+=1){if(o=u[s],d=!1,PN.call(o)!=="[object Object]")return!1;for(c in o)if(AN.call(o,c))if(!d)d=!0;else return!1;if(!d)return!1;if(r.indexOf(c)===-1)r.push(c);else return!1}return!0}function MN(e){return e!==null?e:[]}var bg=new Ut("tag:yaml.org,2002:omap",{kind:"sequence",resolve:IN,construct:MN}),RN=Object.prototype.toString;function $N(e){if(e===null)return!0;var r,s,a,o,c,d=e;for(c=new Array(d.length),r=0,s=d.length;r<s;r+=1){if(a=d[r],RN.call(a)!=="[object Object]"||(o=Object.keys(a),o.length!==1))return!1;c[r]=[o[0],a[o[0]]]}return!0}function DN(e){if(e===null)return[];var r,s,a,o,c,d=e;for(c=new Array(d.length),r=0,s=d.length;r<s;r+=1)a=d[r],o=Object.keys(a),c[r]=[o[0],a[o[0]]];return c}var jg=new Ut("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:$N,construct:DN}),BN=Object.prototype.hasOwnProperty;function zN(e){if(e===null)return!0;var r,s=e;for(r in s)if(BN.call(s,r)&&s[r]!==null)return!1;return!0}function ON(e){return e!==null?e:{}}var kg=new Ut("tag:yaml.org,2002:set",{kind:"mapping",resolve:zN,construct:ON}),Bu=fg.extend({implicit:[yg,vg],explicit:[wg,bg,jg,kg]}),Gn=Object.prototype.hasOwnProperty,nl=1,Ng=2,Cg=3,sl=4,yd=1,FN=2,Sp=3,WN=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,HN=/[\x85\u2028\u2029]/,UN=/[,\[\]\{\}]/,Sg=/^(?:!|!!|![a-z\-]+!)$/i,_g=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function _p(e){return Object.prototype.toString.call(e)}function en(e){return e===10||e===13}function ps(e){return e===9||e===32}function fr(e){return e===9||e===32||e===10||e===13}function Qs(e){return e===44||e===91||e===93||e===123||e===125}function VN(e){var r;return 48<=e&&e<=57?e-48:(r=e|32,97<=r&&r<=102?r-97+10:-1)}function qN(e){return e===120?2:e===117?4:e===85?8:0}function YN(e){return 48<=e&&e<=57?e-48:-1}function Lp(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
|
|
146
|
+
`:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"
":e===95?" ":e===76?"\u2028":e===80?"\u2029":""}function GN(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function Lg(e,r,s){r==="__proto__"?Object.defineProperty(e,r,{configurable:!0,enumerable:!0,writable:!0,value:s}):e[r]=s}var Eg=new Array(256),Tg=new Array(256);for(var Us=0;Us<256;Us++)Eg[Us]=Lp(Us)?1:0,Tg[Us]=Lp(Us);function KN(e,r){this.input=e,this.filename=r.filename||null,this.schema=r.schema||Bu,this.onWarning=r.onWarning||null,this.legacy=r.legacy||!1,this.json=r.json||!1,this.listener=r.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Ag(e,r){var s={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return s.snippet=Zk(s),new nr(r,s)}function Ie(e,r){throw Ag(e,r)}function il(e,r){e.onWarning&&e.onWarning.call(null,Ag(e,r))}var Ep={YAML:function(r,s,a){var o,c,d;r.version!==null&&Ie(r,"duplication of %YAML directive"),a.length!==1&&Ie(r,"YAML directive accepts exactly one argument"),o=/^([0-9]+)\.([0-9]+)$/.exec(a[0]),o===null&&Ie(r,"ill-formed argument of the YAML directive"),c=parseInt(o[1],10),d=parseInt(o[2],10),c!==1&&Ie(r,"unacceptable YAML version of the document"),r.version=a[0],r.checkLineBreaks=d<2,d!==1&&d!==2&&il(r,"unsupported YAML version of the document")},TAG:function(r,s,a){var o,c;a.length!==2&&Ie(r,"TAG directive accepts exactly two arguments"),o=a[0],c=a[1],Sg.test(o)||Ie(r,"ill-formed tag handle (first argument) of the TAG directive"),Gn.call(r.tagMap,o)&&Ie(r,'there is a previously declared suffix for "'+o+'" tag handle'),_g.test(c)||Ie(r,"ill-formed tag prefix (second argument) of the TAG directive");try{c=decodeURIComponent(c)}catch{Ie(r,"tag prefix is malformed: "+c)}r.tagMap[o]=c}};function Yn(e,r,s,a){var o,c,d,u;if(r<s){if(u=e.input.slice(r,s),a)for(o=0,c=u.length;o<c;o+=1)d=u.charCodeAt(o),d===9||32<=d&&d<=1114111||Ie(e,"expected valid JSON character");else WN.test(u)&&Ie(e,"the stream contains non-printable characters");e.result+=u}}function Tp(e,r,s,a){var o,c,d,u;for(Mt.isObject(s)||Ie(e,"cannot merge mappings; the provided source object is unacceptable"),o=Object.keys(s),d=0,u=o.length;d<u;d+=1)c=o[d],Gn.call(r,c)||(Lg(r,c,s[c]),a[c]=!0)}function Js(e,r,s,a,o,c,d,u,h){var p,x;if(Array.isArray(o))for(o=Array.prototype.slice.call(o),p=0,x=o.length;p<x;p+=1)Array.isArray(o[p])&&Ie(e,"nested arrays are not supported inside keys"),typeof o=="object"&&_p(o[p])==="[object Object]"&&(o[p]="[object Object]");if(typeof o=="object"&&_p(o)==="[object Object]"&&(o="[object Object]"),o=String(o),r===null&&(r={}),a==="tag:yaml.org,2002:merge")if(Array.isArray(c))for(p=0,x=c.length;p<x;p+=1)Tp(e,r,c[p],s);else Tp(e,r,c,s);else!e.json&&!Gn.call(s,o)&&Gn.call(r,o)&&(e.line=d||e.line,e.lineStart=u||e.lineStart,e.position=h||e.position,Ie(e,"duplicated mapping key")),Lg(r,o,c),delete s[o];return r}function zu(e){var r;r=e.input.charCodeAt(e.position),r===10?e.position++:r===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):Ie(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function Lt(e,r,s){for(var a=0,o=e.input.charCodeAt(e.position);o!==0;){for(;ps(o);)o===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),o=e.input.charCodeAt(++e.position);if(r&&o===35)do o=e.input.charCodeAt(++e.position);while(o!==10&&o!==13&&o!==0);if(en(o))for(zu(e),o=e.input.charCodeAt(e.position),a++,e.lineIndent=0;o===32;)e.lineIndent++,o=e.input.charCodeAt(++e.position);else break}return s!==-1&&a!==0&&e.lineIndent<s&&il(e,"deficient indentation"),a}function vl(e){var r=e.position,s;return s=e.input.charCodeAt(r),!!((s===45||s===46)&&s===e.input.charCodeAt(r+1)&&s===e.input.charCodeAt(r+2)&&(r+=3,s=e.input.charCodeAt(r),s===0||fr(s)))}function Ou(e,r){r===1?e.result+=" ":r>1&&(e.result+=Mt.repeat(`
|
|
147
|
+
`,r-1))}function QN(e,r,s){var a,o,c,d,u,h,p,x,g=e.kind,b=e.result,v;if(v=e.input.charCodeAt(e.position),fr(v)||Qs(v)||v===35||v===38||v===42||v===33||v===124||v===62||v===39||v===34||v===37||v===64||v===96||(v===63||v===45)&&(o=e.input.charCodeAt(e.position+1),fr(o)||s&&Qs(o)))return!1;for(e.kind="scalar",e.result="",c=d=e.position,u=!1;v!==0;){if(v===58){if(o=e.input.charCodeAt(e.position+1),fr(o)||s&&Qs(o))break}else if(v===35){if(a=e.input.charCodeAt(e.position-1),fr(a))break}else{if(e.position===e.lineStart&&vl(e)||s&&Qs(v))break;if(en(v))if(h=e.line,p=e.lineStart,x=e.lineIndent,Lt(e,!1,-1),e.lineIndent>=r){u=!0,v=e.input.charCodeAt(e.position);continue}else{e.position=d,e.line=h,e.lineStart=p,e.lineIndent=x;break}}u&&(Yn(e,c,d,!1),Ou(e,e.line-h),c=d=e.position,u=!1),ps(v)||(d=e.position+1),v=e.input.charCodeAt(++e.position)}return Yn(e,c,d,!1),e.result?!0:(e.kind=g,e.result=b,!1)}function JN(e,r){var s,a,o;if(s=e.input.charCodeAt(e.position),s!==39)return!1;for(e.kind="scalar",e.result="",e.position++,a=o=e.position;(s=e.input.charCodeAt(e.position))!==0;)if(s===39)if(Yn(e,a,e.position,!0),s=e.input.charCodeAt(++e.position),s===39)a=e.position,e.position++,o=e.position;else return!0;else en(s)?(Yn(e,a,o,!0),Ou(e,Lt(e,!1,r)),a=o=e.position):e.position===e.lineStart&&vl(e)?Ie(e,"unexpected end of the document within a single quoted scalar"):(e.position++,o=e.position);Ie(e,"unexpected end of the stream within a single quoted scalar")}function XN(e,r){var s,a,o,c,d,u;if(u=e.input.charCodeAt(e.position),u!==34)return!1;for(e.kind="scalar",e.result="",e.position++,s=a=e.position;(u=e.input.charCodeAt(e.position))!==0;){if(u===34)return Yn(e,s,e.position,!0),e.position++,!0;if(u===92){if(Yn(e,s,e.position,!0),u=e.input.charCodeAt(++e.position),en(u))Lt(e,!1,r);else if(u<256&&Eg[u])e.result+=Tg[u],e.position++;else if((d=qN(u))>0){for(o=d,c=0;o>0;o--)u=e.input.charCodeAt(++e.position),(d=VN(u))>=0?c=(c<<4)+d:Ie(e,"expected hexadecimal character");e.result+=GN(c),e.position++}else Ie(e,"unknown escape sequence");s=a=e.position}else en(u)?(Yn(e,s,a,!0),Ou(e,Lt(e,!1,r)),s=a=e.position):e.position===e.lineStart&&vl(e)?Ie(e,"unexpected end of the document within a double quoted scalar"):(e.position++,a=e.position)}Ie(e,"unexpected end of the stream within a double quoted scalar")}function ZN(e,r){var s=!0,a,o,c,d=e.tag,u,h=e.anchor,p,x,g,b,v,k=Object.create(null),T,N,j,A;if(A=e.input.charCodeAt(e.position),A===91)x=93,v=!1,u=[];else if(A===123)x=125,v=!0,u={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=u),A=e.input.charCodeAt(++e.position);A!==0;){if(Lt(e,!0,r),A=e.input.charCodeAt(e.position),A===x)return e.position++,e.tag=d,e.anchor=h,e.kind=v?"mapping":"sequence",e.result=u,!0;s?A===44&&Ie(e,"expected the node content, but found ','"):Ie(e,"missed comma between flow collection entries"),N=T=j=null,g=b=!1,A===63&&(p=e.input.charCodeAt(e.position+1),fr(p)&&(g=b=!0,e.position++,Lt(e,!0,r))),a=e.line,o=e.lineStart,c=e.position,ni(e,r,nl,!1,!0),N=e.tag,T=e.result,Lt(e,!0,r),A=e.input.charCodeAt(e.position),(b||e.line===a)&&A===58&&(g=!0,A=e.input.charCodeAt(++e.position),Lt(e,!0,r),ni(e,r,nl,!1,!0),j=e.result),v?Js(e,u,k,N,T,j,a,o,c):g?u.push(Js(e,null,k,N,T,j,a,o,c)):u.push(T),Lt(e,!0,r),A=e.input.charCodeAt(e.position),A===44?(s=!0,A=e.input.charCodeAt(++e.position)):s=!1}Ie(e,"unexpected end of the stream within a flow collection")}function e5(e,r){var s,a,o=yd,c=!1,d=!1,u=r,h=0,p=!1,x,g;if(g=e.input.charCodeAt(e.position),g===124)a=!1;else if(g===62)a=!0;else return!1;for(e.kind="scalar",e.result="";g!==0;)if(g=e.input.charCodeAt(++e.position),g===43||g===45)yd===o?o=g===43?Sp:FN:Ie(e,"repeat of a chomping mode identifier");else if((x=YN(g))>=0)x===0?Ie(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):d?Ie(e,"repeat of an indentation width identifier"):(u=r+x-1,d=!0);else break;if(ps(g)){do g=e.input.charCodeAt(++e.position);while(ps(g));if(g===35)do g=e.input.charCodeAt(++e.position);while(!en(g)&&g!==0)}for(;g!==0;){for(zu(e),e.lineIndent=0,g=e.input.charCodeAt(e.position);(!d||e.lineIndent<u)&&g===32;)e.lineIndent++,g=e.input.charCodeAt(++e.position);if(!d&&e.lineIndent>u&&(u=e.lineIndent),en(g)){h++;continue}if(e.lineIndent<u){o===Sp?e.result+=Mt.repeat(`
|
|
148
|
+
`,c?1+h:h):o===yd&&c&&(e.result+=`
|
|
149
|
+
`);break}for(a?ps(g)?(p=!0,e.result+=Mt.repeat(`
|
|
150
|
+
`,c?1+h:h)):p?(p=!1,e.result+=Mt.repeat(`
|
|
151
|
+
`,h+1)):h===0?c&&(e.result+=" "):e.result+=Mt.repeat(`
|
|
152
|
+
`,h):e.result+=Mt.repeat(`
|
|
153
|
+
`,c?1+h:h),c=!0,d=!0,h=0,s=e.position;!en(g)&&g!==0;)g=e.input.charCodeAt(++e.position);Yn(e,s,e.position,!1)}return!0}function Ap(e,r){var s,a=e.tag,o=e.anchor,c=[],d,u=!1,h;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=c),h=e.input.charCodeAt(e.position);h!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,Ie(e,"tab characters must not be used in indentation")),!(h!==45||(d=e.input.charCodeAt(e.position+1),!fr(d))));){if(u=!0,e.position++,Lt(e,!0,-1)&&e.lineIndent<=r){c.push(null),h=e.input.charCodeAt(e.position);continue}if(s=e.line,ni(e,r,Cg,!1,!0),c.push(e.result),Lt(e,!0,-1),h=e.input.charCodeAt(e.position),(e.line===s||e.lineIndent>r)&&h!==0)Ie(e,"bad indentation of a sequence entry");else if(e.lineIndent<r)break}return u?(e.tag=a,e.anchor=o,e.kind="sequence",e.result=c,!0):!1}function t5(e,r,s){var a,o,c,d,u,h,p=e.tag,x=e.anchor,g={},b=Object.create(null),v=null,k=null,T=null,N=!1,j=!1,A;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=g),A=e.input.charCodeAt(e.position);A!==0;){if(!N&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,Ie(e,"tab characters must not be used in indentation")),a=e.input.charCodeAt(e.position+1),c=e.line,(A===63||A===58)&&fr(a))A===63?(N&&(Js(e,g,b,v,k,null,d,u,h),v=k=T=null),j=!0,N=!0,o=!0):N?(N=!1,o=!0):Ie(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,A=a;else{if(d=e.line,u=e.lineStart,h=e.position,!ni(e,s,Ng,!1,!0))break;if(e.line===c){for(A=e.input.charCodeAt(e.position);ps(A);)A=e.input.charCodeAt(++e.position);if(A===58)A=e.input.charCodeAt(++e.position),fr(A)||Ie(e,"a whitespace character is expected after the key-value separator within a block mapping"),N&&(Js(e,g,b,v,k,null,d,u,h),v=k=T=null),j=!0,N=!1,o=!1,v=e.tag,k=e.result;else if(j)Ie(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=p,e.anchor=x,!0}else if(j)Ie(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=p,e.anchor=x,!0}if((e.line===c||e.lineIndent>r)&&(N&&(d=e.line,u=e.lineStart,h=e.position),ni(e,r,sl,!0,o)&&(N?k=e.result:T=e.result),N||(Js(e,g,b,v,k,T,d,u,h),v=k=T=null),Lt(e,!0,-1),A=e.input.charCodeAt(e.position)),(e.line===c||e.lineIndent>r)&&A!==0)Ie(e,"bad indentation of a mapping entry");else if(e.lineIndent<r)break}return N&&Js(e,g,b,v,k,null,d,u,h),j&&(e.tag=p,e.anchor=x,e.kind="mapping",e.result=g),j}function r5(e){var r,s=!1,a=!1,o,c,d;if(d=e.input.charCodeAt(e.position),d!==33)return!1;if(e.tag!==null&&Ie(e,"duplication of a tag property"),d=e.input.charCodeAt(++e.position),d===60?(s=!0,d=e.input.charCodeAt(++e.position)):d===33?(a=!0,o="!!",d=e.input.charCodeAt(++e.position)):o="!",r=e.position,s){do d=e.input.charCodeAt(++e.position);while(d!==0&&d!==62);e.position<e.length?(c=e.input.slice(r,e.position),d=e.input.charCodeAt(++e.position)):Ie(e,"unexpected end of the stream within a verbatim tag")}else{for(;d!==0&&!fr(d);)d===33&&(a?Ie(e,"tag suffix cannot contain exclamation marks"):(o=e.input.slice(r-1,e.position+1),Sg.test(o)||Ie(e,"named tag handle cannot contain such characters"),a=!0,r=e.position+1)),d=e.input.charCodeAt(++e.position);c=e.input.slice(r,e.position),UN.test(c)&&Ie(e,"tag suffix cannot contain flow indicator characters")}c&&!_g.test(c)&&Ie(e,"tag name cannot contain such characters: "+c);try{c=decodeURIComponent(c)}catch{Ie(e,"tag name is malformed: "+c)}return s?e.tag=c:Gn.call(e.tagMap,o)?e.tag=e.tagMap[o]+c:o==="!"?e.tag="!"+c:o==="!!"?e.tag="tag:yaml.org,2002:"+c:Ie(e,'undeclared tag handle "'+o+'"'),!0}function n5(e){var r,s;if(s=e.input.charCodeAt(e.position),s!==38)return!1;for(e.anchor!==null&&Ie(e,"duplication of an anchor property"),s=e.input.charCodeAt(++e.position),r=e.position;s!==0&&!fr(s)&&!Qs(s);)s=e.input.charCodeAt(++e.position);return e.position===r&&Ie(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(r,e.position),!0}function s5(e){var r,s,a;if(a=e.input.charCodeAt(e.position),a!==42)return!1;for(a=e.input.charCodeAt(++e.position),r=e.position;a!==0&&!fr(a)&&!Qs(a);)a=e.input.charCodeAt(++e.position);return e.position===r&&Ie(e,"name of an alias node must contain at least one character"),s=e.input.slice(r,e.position),Gn.call(e.anchorMap,s)||Ie(e,'unidentified alias "'+s+'"'),e.result=e.anchorMap[s],Lt(e,!0,-1),!0}function ni(e,r,s,a,o){var c,d,u,h=1,p=!1,x=!1,g,b,v,k,T,N;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,c=d=u=sl===s||Cg===s,a&&Lt(e,!0,-1)&&(p=!0,e.lineIndent>r?h=1:e.lineIndent===r?h=0:e.lineIndent<r&&(h=-1)),h===1)for(;r5(e)||n5(e);)Lt(e,!0,-1)?(p=!0,u=c,e.lineIndent>r?h=1:e.lineIndent===r?h=0:e.lineIndent<r&&(h=-1)):u=!1;if(u&&(u=p||o),(h===1||sl===s)&&(nl===s||Ng===s?T=r:T=r+1,N=e.position-e.lineStart,h===1?u&&(Ap(e,N)||t5(e,N,T))||ZN(e,T)?x=!0:(d&&e5(e,T)||JN(e,T)||XN(e,T)?x=!0:s5(e)?(x=!0,(e.tag!==null||e.anchor!==null)&&Ie(e,"alias node should not have any properties")):QN(e,T,nl===s)&&(x=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):h===0&&(x=u&&Ap(e,N))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&Ie(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),g=0,b=e.implicitTypes.length;g<b;g+=1)if(k=e.implicitTypes[g],k.resolve(e.result)){e.result=k.construct(e.result),e.tag=k.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(Gn.call(e.typeMap[e.kind||"fallback"],e.tag))k=e.typeMap[e.kind||"fallback"][e.tag];else for(k=null,v=e.typeMap.multi[e.kind||"fallback"],g=0,b=v.length;g<b;g+=1)if(e.tag.slice(0,v[g].tag.length)===v[g].tag){k=v[g];break}k||Ie(e,"unknown tag !<"+e.tag+">"),e.result!==null&&k.kind!==e.kind&&Ie(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+k.kind+'", not "'+e.kind+'"'),k.resolve(e.result,e.tag)?(e.result=k.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):Ie(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||x}function i5(e){var r=e.position,s,a,o,c=!1,d;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(d=e.input.charCodeAt(e.position))!==0&&(Lt(e,!0,-1),d=e.input.charCodeAt(e.position),!(e.lineIndent>0||d!==37));){for(c=!0,d=e.input.charCodeAt(++e.position),s=e.position;d!==0&&!fr(d);)d=e.input.charCodeAt(++e.position);for(a=e.input.slice(s,e.position),o=[],a.length<1&&Ie(e,"directive name must not be less than one character in length");d!==0;){for(;ps(d);)d=e.input.charCodeAt(++e.position);if(d===35){do d=e.input.charCodeAt(++e.position);while(d!==0&&!en(d));break}if(en(d))break;for(s=e.position;d!==0&&!fr(d);)d=e.input.charCodeAt(++e.position);o.push(e.input.slice(s,e.position))}d!==0&&zu(e),Gn.call(Ep,a)?Ep[a](e,a,o):il(e,'unknown document directive "'+a+'"')}if(Lt(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,Lt(e,!0,-1)):c&&Ie(e,"directives end mark is expected"),ni(e,e.lineIndent-1,sl,!1,!0),Lt(e,!0,-1),e.checkLineBreaks&&HN.test(e.input.slice(r,e.position))&&il(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&vl(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,Lt(e,!0,-1));return}if(e.position<e.length-1)Ie(e,"end of the stream or a document separator is expected");else return}function Pg(e,r){e=String(e),r=r||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
|
|
154
|
+
`),e.charCodeAt(0)===65279&&(e=e.slice(1)));var s=new KN(e,r),a=e.indexOf("\0");for(a!==-1&&(s.position=a,Ie(s,"null byte is not allowed in input")),s.input+="\0";s.input.charCodeAt(s.position)===32;)s.lineIndent+=1,s.position+=1;for(;s.position<s.length-1;)i5(s);return s.documents}function a5(e,r,s){r!==null&&typeof r=="object"&&typeof s>"u"&&(s=r,r=null);var a=Pg(e,s);if(typeof r!="function")return a;for(var o=0,c=a.length;o<c;o+=1)r(a[o])}function o5(e,r){var s=Pg(e,r);if(s.length!==0){if(s.length===1)return s[0];throw new nr("expected a single document in the stream, but found more")}}var l5=a5,c5=o5,Ig={loadAll:l5,load:c5},Mg=Object.prototype.toString,Rg=Object.prototype.hasOwnProperty,Fu=65279,d5=9,ma=10,u5=13,m5=32,h5=33,p5=34,Gd=35,f5=37,x5=38,g5=39,y5=42,$g=44,v5=45,al=58,w5=61,b5=62,j5=63,k5=64,Dg=91,Bg=93,N5=96,zg=123,C5=124,Og=125,Jt={};Jt[0]="\\0";Jt[7]="\\a";Jt[8]="\\b";Jt[9]="\\t";Jt[10]="\\n";Jt[11]="\\v";Jt[12]="\\f";Jt[13]="\\r";Jt[27]="\\e";Jt[34]='\\"';Jt[92]="\\\\";Jt[133]="\\N";Jt[160]="\\_";Jt[8232]="\\L";Jt[8233]="\\P";var S5=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],_5=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function L5(e,r){var s,a,o,c,d,u,h;if(r===null)return{};for(s={},a=Object.keys(r),o=0,c=a.length;o<c;o+=1)d=a[o],u=String(r[d]),d.slice(0,2)==="!!"&&(d="tag:yaml.org,2002:"+d.slice(2)),h=e.compiledTypeMap.fallback[d],h&&Rg.call(h.styleAliases,u)&&(u=h.styleAliases[u]),s[d]=u;return s}function E5(e){var r,s,a;if(r=e.toString(16).toUpperCase(),e<=255)s="x",a=2;else if(e<=65535)s="u",a=4;else if(e<=4294967295)s="U",a=8;else throw new nr("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+s+Mt.repeat("0",a-r.length)+r}var T5=1,ha=2;function A5(e){this.schema=e.schema||Bu,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=Mt.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=L5(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?ha:T5,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function Pp(e,r){for(var s=Mt.repeat(" ",r),a=0,o=-1,c="",d,u=e.length;a<u;)o=e.indexOf(`
|
|
155
|
+
`,a),o===-1?(d=e.slice(a),a=u):(d=e.slice(a,o+1),a=o+1),d.length&&d!==`
|
|
156
|
+
`&&(c+=s),c+=d;return c}function Kd(e,r){return`
|
|
157
|
+
`+Mt.repeat(" ",e.indent*r)}function P5(e,r){var s,a,o;for(s=0,a=e.implicitTypes.length;s<a;s+=1)if(o=e.implicitTypes[s],o.resolve(r))return!0;return!1}function ol(e){return e===m5||e===d5}function pa(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==Fu||65536<=e&&e<=1114111}function Ip(e){return pa(e)&&e!==Fu&&e!==u5&&e!==ma}function Mp(e,r,s){var a=Ip(e),o=a&&!ol(e);return(s?a:a&&e!==$g&&e!==Dg&&e!==Bg&&e!==zg&&e!==Og)&&e!==Gd&&!(r===al&&!o)||Ip(r)&&!ol(r)&&e===Gd||r===al&&o}function I5(e){return pa(e)&&e!==Fu&&!ol(e)&&e!==v5&&e!==j5&&e!==al&&e!==$g&&e!==Dg&&e!==Bg&&e!==zg&&e!==Og&&e!==Gd&&e!==x5&&e!==y5&&e!==h5&&e!==C5&&e!==w5&&e!==b5&&e!==g5&&e!==p5&&e!==f5&&e!==k5&&e!==N5}function M5(e){return!ol(e)&&e!==al}function ra(e,r){var s=e.charCodeAt(r),a;return s>=55296&&s<=56319&&r+1<e.length&&(a=e.charCodeAt(r+1),a>=56320&&a<=57343)?(s-55296)*1024+a-56320+65536:s}function Fg(e){var r=/^\n* /;return r.test(e)}var Wg=1,Qd=2,Hg=3,Ug=4,Gs=5;function R5(e,r,s,a,o,c,d,u){var h,p=0,x=null,g=!1,b=!1,v=a!==-1,k=-1,T=I5(ra(e,0))&&M5(ra(e,e.length-1));if(r||d)for(h=0;h<e.length;p>=65536?h+=2:h++){if(p=ra(e,h),!pa(p))return Gs;T=T&&Mp(p,x,u),x=p}else{for(h=0;h<e.length;p>=65536?h+=2:h++){if(p=ra(e,h),p===ma)g=!0,v&&(b=b||h-k-1>a&&e[k+1]!==" ",k=h);else if(!pa(p))return Gs;T=T&&Mp(p,x,u),x=p}b=b||v&&h-k-1>a&&e[k+1]!==" "}return!g&&!b?T&&!d&&!o(e)?Wg:c===ha?Gs:Qd:s>9&&Fg(e)?Gs:d?c===ha?Gs:Qd:b?Ug:Hg}function $5(e,r,s,a,o){e.dump=(function(){if(r.length===0)return e.quotingType===ha?'""':"''";if(!e.noCompatMode&&(S5.indexOf(r)!==-1||_5.test(r)))return e.quotingType===ha?'"'+r+'"':"'"+r+"'";var c=e.indent*Math.max(1,s),d=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-c),u=a||e.flowLevel>-1&&s>=e.flowLevel;function h(p){return P5(e,p)}switch(R5(r,u,e.indent,d,h,e.quotingType,e.forceQuotes&&!a,o)){case Wg:return r;case Qd:return"'"+r.replace(/'/g,"''")+"'";case Hg:return"|"+Rp(r,e.indent)+$p(Pp(r,c));case Ug:return">"+Rp(r,e.indent)+$p(Pp(D5(r,d),c));case Gs:return'"'+B5(r)+'"';default:throw new nr("impossible error: invalid scalar style")}})()}function Rp(e,r){var s=Fg(e)?String(r):"",a=e[e.length-1]===`
|
|
158
|
+
`,o=a&&(e[e.length-2]===`
|
|
159
|
+
`||e===`
|
|
160
|
+
`),c=o?"+":a?"":"-";return s+c+`
|
|
161
|
+
`}function $p(e){return e[e.length-1]===`
|
|
162
|
+
`?e.slice(0,-1):e}function D5(e,r){for(var s=/(\n+)([^\n]*)/g,a=(function(){var p=e.indexOf(`
|
|
163
|
+
`);return p=p!==-1?p:e.length,s.lastIndex=p,Dp(e.slice(0,p),r)})(),o=e[0]===`
|
|
164
|
+
`||e[0]===" ",c,d;d=s.exec(e);){var u=d[1],h=d[2];c=h[0]===" ",a+=u+(!o&&!c&&h!==""?`
|
|
165
|
+
`:"")+Dp(h,r),o=c}return a}function Dp(e,r){if(e===""||e[0]===" ")return e;for(var s=/ [^ ]/g,a,o=0,c,d=0,u=0,h="";a=s.exec(e);)u=a.index,u-o>r&&(c=d>o?d:u,h+=`
|
|
166
|
+
`+e.slice(o,c),o=c+1),d=u;return h+=`
|
|
167
|
+
`,e.length-o>r&&d>o?h+=e.slice(o,d)+`
|
|
168
|
+
`+e.slice(d+1):h+=e.slice(o),h.slice(1)}function B5(e){for(var r="",s=0,a,o=0;o<e.length;s>=65536?o+=2:o++)s=ra(e,o),a=Jt[s],!a&&pa(s)?(r+=e[o],s>=65536&&(r+=e[o+1])):r+=a||E5(s);return r}function z5(e,r,s){var a="",o=e.tag,c,d,u;for(c=0,d=s.length;c<d;c+=1)u=s[c],e.replacer&&(u=e.replacer.call(s,String(c),u)),(vn(e,r,u,!1,!1)||typeof u>"u"&&vn(e,r,null,!1,!1))&&(a!==""&&(a+=","+(e.condenseFlow?"":" ")),a+=e.dump);e.tag=o,e.dump="["+a+"]"}function Bp(e,r,s,a){var o="",c=e.tag,d,u,h;for(d=0,u=s.length;d<u;d+=1)h=s[d],e.replacer&&(h=e.replacer.call(s,String(d),h)),(vn(e,r+1,h,!0,!0,!1,!0)||typeof h>"u"&&vn(e,r+1,null,!0,!0,!1,!0))&&((!a||o!=="")&&(o+=Kd(e,r)),e.dump&&ma===e.dump.charCodeAt(0)?o+="-":o+="- ",o+=e.dump);e.tag=c,e.dump=o||"[]"}function O5(e,r,s){var a="",o=e.tag,c=Object.keys(s),d,u,h,p,x;for(d=0,u=c.length;d<u;d+=1)x="",a!==""&&(x+=", "),e.condenseFlow&&(x+='"'),h=c[d],p=s[h],e.replacer&&(p=e.replacer.call(s,h,p)),vn(e,r,h,!1,!1)&&(e.dump.length>1024&&(x+="? "),x+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),vn(e,r,p,!1,!1)&&(x+=e.dump,a+=x));e.tag=o,e.dump="{"+a+"}"}function F5(e,r,s,a){var o="",c=e.tag,d=Object.keys(s),u,h,p,x,g,b;if(e.sortKeys===!0)d.sort();else if(typeof e.sortKeys=="function")d.sort(e.sortKeys);else if(e.sortKeys)throw new nr("sortKeys must be a boolean or a function");for(u=0,h=d.length;u<h;u+=1)b="",(!a||o!=="")&&(b+=Kd(e,r)),p=d[u],x=s[p],e.replacer&&(x=e.replacer.call(s,p,x)),vn(e,r+1,p,!0,!0,!0)&&(g=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,g&&(e.dump&&ma===e.dump.charCodeAt(0)?b+="?":b+="? "),b+=e.dump,g&&(b+=Kd(e,r)),vn(e,r+1,x,!0,g)&&(e.dump&&ma===e.dump.charCodeAt(0)?b+=":":b+=": ",b+=e.dump,o+=b));e.tag=c,e.dump=o||"{}"}function zp(e,r,s){var a,o,c,d,u,h;for(o=s?e.explicitTypes:e.implicitTypes,c=0,d=o.length;c<d;c+=1)if(u=o[c],(u.instanceOf||u.predicate)&&(!u.instanceOf||typeof r=="object"&&r instanceof u.instanceOf)&&(!u.predicate||u.predicate(r))){if(s?u.multi&&u.representName?e.tag=u.representName(r):e.tag=u.tag:e.tag="?",u.represent){if(h=e.styleMap[u.tag]||u.defaultStyle,Mg.call(u.represent)==="[object Function]")a=u.represent(r,h);else if(Rg.call(u.represent,h))a=u.represent[h](r,h);else throw new nr("!<"+u.tag+'> tag resolver accepts not "'+h+'" style');e.dump=a}return!0}return!1}function vn(e,r,s,a,o,c,d){e.tag=null,e.dump=s,zp(e,s,!1)||zp(e,s,!0);var u=Mg.call(e.dump),h=a,p;a&&(a=e.flowLevel<0||e.flowLevel>r);var x=u==="[object Object]"||u==="[object Array]",g,b;if(x&&(g=e.duplicates.indexOf(s),b=g!==-1),(e.tag!==null&&e.tag!=="?"||b||e.indent!==2&&r>0)&&(o=!1),b&&e.usedDuplicates[g])e.dump="*ref_"+g;else{if(x&&b&&!e.usedDuplicates[g]&&(e.usedDuplicates[g]=!0),u==="[object Object]")a&&Object.keys(e.dump).length!==0?(F5(e,r,e.dump,o),b&&(e.dump="&ref_"+g+e.dump)):(O5(e,r,e.dump),b&&(e.dump="&ref_"+g+" "+e.dump));else if(u==="[object Array]")a&&e.dump.length!==0?(e.noArrayIndent&&!d&&r>0?Bp(e,r-1,e.dump,o):Bp(e,r,e.dump,o),b&&(e.dump="&ref_"+g+e.dump)):(z5(e,r,e.dump),b&&(e.dump="&ref_"+g+" "+e.dump));else if(u==="[object String]")e.tag!=="?"&&$5(e,e.dump,r,c,h);else{if(u==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new nr("unacceptable kind of an object to dump "+u)}e.tag!==null&&e.tag!=="?"&&(p=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?p="!"+p:p.slice(0,18)==="tag:yaml.org,2002:"?p="!!"+p.slice(18):p="!<"+p+">",e.dump=p+" "+e.dump)}return!0}function W5(e,r){var s=[],a=[],o,c;for(Jd(e,s,a),o=0,c=a.length;o<c;o+=1)r.duplicates.push(s[a[o]]);r.usedDuplicates=new Array(c)}function Jd(e,r,s){var a,o,c;if(e!==null&&typeof e=="object")if(o=r.indexOf(e),o!==-1)s.indexOf(o)===-1&&s.push(o);else if(r.push(e),Array.isArray(e))for(o=0,c=e.length;o<c;o+=1)Jd(e[o],r,s);else for(a=Object.keys(e),o=0,c=a.length;o<c;o+=1)Jd(e[a[o]],r,s)}function H5(e,r){r=r||{};var s=new A5(r);s.noRefs||W5(e,s);var a=e;return s.replacer&&(a=s.replacer.call({"":a},"",a)),vn(s,0,a,!0,!0)?s.dump+`
|
|
169
|
+
`:""}var U5=H5,V5={dump:U5};function Wu(e,r){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+r+" instead, which is now safe by default.")}}var q5=Ut,Y5=ig,G5=cg,K5=pg,Q5=fg,J5=Bu,X5=Ig.load,Z5=Ig.loadAll,e3=V5.dump,t3=nr,r3={binary:wg,float:hg,map:lg,null:dg,pairs:jg,set:kg,timestamp:yg,bool:ug,int:mg,merge:vg,omap:bg,seq:og,str:ag},n3=Wu("safeLoad","load"),s3=Wu("safeLoadAll","loadAll"),i3=Wu("safeDump","dump"),$o={Type:q5,Schema:Y5,FAILSAFE_SCHEMA:G5,JSON_SCHEMA:K5,CORE_SCHEMA:Q5,DEFAULT_SCHEMA:J5,load:X5,loadAll:Z5,dump:e3,YAMLException:t3,types:r3,safeLoad:n3,safeLoadAll:s3,safeDump:i3};const a3={output:{singular:"item",plural:"items",description:""}},o3={strategy:"fixed"},l3={max_iterations:10,max_runtime_seconds:3600,max_consecutive_errors:3,cooldown_between_iterations:5},Vg={name:"",display_name:"",type:"generator",description:"",item_types:a3,modes:[],mode_selection:o3,limits:l3};function vd(e){var s,a,o,c;const r={...Vg};if(typeof e.name=="string"&&(r.name=e.name),typeof e.display_name=="string"&&(r.display_name=e.display_name),typeof e.description=="string"&&(r.description=e.description),(e.type==="generator"||e.type==="consumer"||e.type==="hybrid")&&(r.type=e.type),e.item_types&&typeof e.item_types=="object"){const d=e.item_types;if(r.item_types={output:{singular:((s=d.output)==null?void 0:s.singular)||"item",plural:((a=d.output)==null?void 0:a.plural)||"items",description:((o=d.output)==null?void 0:o.description)||"",source:(c=d.output)==null?void 0:c.source}},d.input&&typeof d.input=="object"){const u=d.input;r.item_types.input={singular:u.singular||"item",plural:u.plural||"items",description:u.description||"",source:u.source}}}if(e.modes&&typeof e.modes=="object"){const d=e.modes;r.modes=Object.entries(d).map(([u,h])=>{const p=h;return{name:u,description:p.description||"",model:p.model||"claude-sonnet-4-20250514",timeout:typeof p.timeout=="number"?p.timeout:300,tools:Array.isArray(p.tools)?p.tools:[],prompt_template:p.prompt_template||""}})}if(e.mode_selection&&typeof e.mode_selection=="object"){const d=e.mode_selection;r.mode_selection={strategy:d.strategy||"fixed",fixed_mode:d.fixed_mode,weights:d.weights}}if(e.limits&&typeof e.limits=="object"){const d=e.limits;r.limits={max_iterations:typeof d.max_iterations=="number"?d.max_iterations:10,max_runtime_seconds:typeof d.max_runtime_seconds=="number"?d.max_runtime_seconds:3600,max_consecutive_errors:typeof d.max_consecutive_errors=="number"?d.max_consecutive_errors:3,cooldown_between_iterations:typeof d.cooldown_between_iterations=="number"?d.cooldown_between_iterations:5}}return r}function Op(e){const r={name:e.name,display_name:e.display_name,type:e.type};e.description&&(r.description=e.description);const s={output:{singular:e.item_types.output.singular,plural:e.item_types.output.plural}};e.item_types.output.description&&(s.output.description=e.item_types.output.description),e.item_types.input&&(s.input={singular:e.item_types.input.singular,plural:e.item_types.input.plural},e.item_types.input.description&&(s.input.description=e.item_types.input.description),e.item_types.input.source&&(s.input.source=e.item_types.input.source)),r.item_types=s;const a={};for(const c of e.modes)a[c.name]={description:c.description,model:c.model,timeout:c.timeout,prompt_template:c.prompt_template},c.tools.length>0&&(a[c.name].tools=c.tools);r.modes=a;const o={strategy:e.mode_selection.strategy};return e.mode_selection.strategy==="fixed"&&e.mode_selection.fixed_mode&&(o.fixed_mode=e.mode_selection.fixed_mode),e.mode_selection.strategy==="weighted_random"&&e.mode_selection.weights&&(o.weights=e.mode_selection.weights),r.mode_selection=o,r.limits={max_iterations:e.limits.max_iterations,max_runtime_seconds:e.limits.max_runtime_seconds,max_consecutive_errors:e.limits.max_consecutive_errors,cooldown_between_iterations:e.limits.cooldown_between_iterations},r}const gn={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 c3({name:e,displayName:r,type:s,description:a,isNewLoop:o,onChange:c}){const d=u=>{const h={display_name:u};if(o&&!e){const p=u.toLowerCase().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").substring(0,50);h.name=p}c(h)};return t.jsxs("section",{children:[t.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center",children:[t.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"]}),t.jsxs("div",{className:"space-y-4 pl-11",children:[t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"display_name",className:"block text-sm font-medium text-gray-300 mb-1",children:["Display Name ",t.jsx("span",{className:"text-red-400",children:"*"}),t.jsx(xn,{content:gn.displayName.body,size:"sm",className:"ml-1"})]}),t.jsx("input",{id:"display_name",type:"text",value:r,onChange:u=>d(u.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"}),t.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Human-readable name shown in the UI"})]}),t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"name",className:"block text-sm font-medium text-gray-300 mb-1",children:["Slug ",t.jsx("span",{className:"text-red-400",children:"*"}),t.jsx(xn,{content:gn.loopName.body,size:"sm",className:"ml-1"})]}),t.jsx("input",{id:"name",type:"text",value:e,onChange:u=>c({name:u.target.value}),placeholder:"e.g., research",disabled:!o,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 ${o?"":"opacity-60 cursor-not-allowed"}`}),t.jsx("p",{className:"mt-1 text-xs text-gray-500",children:o?"Unique identifier (lowercase letters, numbers, hyphens, underscores)":"Slug cannot be changed after creation"})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:["Loop Type ",t.jsx("span",{className:"text-red-400",children:"*"}),t.jsx(xn,{content:gn.loopType.body,size:"sm",className:"ml-1"})]}),t.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(u=>t.jsxs("button",{type:"button",onClick:()=>c({type:u.value}),className:`p-3 rounded-lg border text-left transition-colors ${s===u.value?"border-primary-500 bg-primary-900/30":"border-gray-600 bg-gray-700 hover:border-gray-500"}`,children:[t.jsx("div",{className:"font-medium text-white",children:u.label}),t.jsx("div",{className:"text-xs text-gray-400 mt-1",children:u.description})]},u.value))})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"description",className:"block text-sm font-medium text-gray-300 mb-1",children:"Description"}),t.jsx("textarea",{id:"description",value:a,onChange:u=>c({description:u.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 Fp({label:e,config:r,showSource:s=!1,availableLoops:a=[],onChange:o}){return t.jsxs("div",{className:"p-4 bg-gray-700/50 rounded-lg border border-gray-600",children:[t.jsx("h5",{className:"text-sm font-medium text-white mb-3",children:e}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-gray-400 mb-1",children:"Singular"}),t.jsx("input",{type:"text",value:r.singular,onChange:c=>o({...r,singular:c.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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-gray-400 mb-1",children:"Plural"}),t.jsx("input",{type:"text",value:r.plural,onChange:c=>o({...r,plural:c.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"})]})]}),t.jsxs("div",{className:"mt-3",children:[t.jsx("label",{className:"block text-xs text-gray-400 mb-1",children:"Description"}),t.jsx("input",{type:"text",value:r.description,onChange:c=>o({...r,description:c.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"})]}),s&&t.jsxs("div",{className:"mt-3",children:[t.jsxs("label",{className:"block text-xs text-gray-400 mb-1",children:["Source Loop",t.jsx(xn,{content:gn.sourceLoop.body,size:"sm",className:"ml-1"})]}),t.jsxs("select",{value:r.source||"",onChange:c=>o({...r,source:c.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:[t.jsx("option",{value:"",children:"Select a source loop..."}),a.map(c=>t.jsx("option",{value:c,children:c},c))]}),t.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Which loop's output items should this loop consume?"})]})]})}function d3({itemTypes:e,loopType:r,availableLoops:s,onChange:a}){const o=r==="consumer"||r==="hybrid",c=p=>{a({...e,output:p})},d=p=>{a({...e,input:p})},u=()=>{a({...e,input:{singular:"item",plural:"items",description:""}})},h=()=>{const{input:p,...x}=e;a({...x,output:e.output})};return t.jsxs("section",{children:[t.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center",children:[t.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",t.jsx(xn,{content:gn.itemTypes.body,size:"sm",className:"ml-2"})]}),t.jsxs("div",{className:"space-y-4 pl-11",children:[t.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."}),o&&t.jsx("div",{children:e.input?t.jsxs("div",{className:"relative",children:[t.jsx(Fp,{label:"Input Item Type",config:e.input,showSource:!0,availableLoops:s,onChange:d}),t.jsx("button",{type:"button",onClick:h,className:"absolute top-2 right-2 text-gray-400 hover:text-red-400",title:"Remove input type",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}):t.jsxs("button",{type:"button",onClick:u,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:[t.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),t.jsx("span",{children:"Add Input Item Type"})]}),t.jsx("p",{className:"text-xs mt-1",children:"Define the items this loop will consume from another loop"})]})}),o&&e.input&&t.jsx("div",{className:"flex justify-center py-2",children:t.jsx("svg",{className:"w-6 h-6 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})})}),t.jsx(Fp,{label:"Output Item Type",config:e.output,onChange:c}),t.jsx("div",{className:"p-3 bg-gray-700/30 rounded-lg border border-gray-600/50",children:t.jsxs("div",{className:"flex items-start space-x-2",children:[t.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:t.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"})}),t.jsxs("div",{className:"text-xs text-gray-400",children:[t.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 Wp=[{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 u3({mode:e,isExpanded:r,onToggle:s,onChange:a,onDelete:o}){var h;const[c,d]=y.useState(!1),u=()=>{c?o():(d(!0),setTimeout(()=>d(!1),3e3))};return t.jsxs("div",{className:"border border-gray-600 rounded-lg bg-gray-700/50 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between p-3 cursor-pointer hover:bg-gray-700/70 transition-colors",onClick:s,children:[t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx("svg",{className:`w-5 h-5 text-gray-400 transition-transform ${r?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-white",children:e.name||t.jsx("span",{className:"text-gray-400 italic",children:"Unnamed mode"})}),t.jsxs("div",{className:"text-xs text-gray-400",children:[((h=Wp.find(p=>p.value===e.model))==null?void 0:h.label)||e.model," · ",e.timeout,"s timeout"]})]})]}),t.jsx("button",{onClick:p=>{p.stopPropagation(),u()},className:`px-2 py-1 text-sm rounded transition-colors ${c?"bg-red-800 text-red-200 hover:bg-red-700":"text-gray-400 hover:text-red-400 hover:bg-gray-600"}`,children:c?"Confirm Delete":"Delete"})]}),r&&t.jsxs("div",{className:"p-4 border-t border-gray-600 space-y-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:["Mode Name ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsx("input",{type:"text",value:e.name,onChange:p=>a({...e,name:p.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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Description"}),t.jsx("input",{type:"text",value:e.description,onChange:p=>a({...e,description:p.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"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Model"}),t.jsx("select",{value:e.model,onChange:p=>a({...e,model:p.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:Wp.map(p=>t.jsx("option",{value:p.value,children:p.label},p.value))})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Timeout (seconds)"}),t.jsx("input",{type:"number",value:e.timeout,onChange:p=>a({...e,timeout:parseInt(p.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"})]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:["Prompt Template ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsx("input",{type:"text",value:e.prompt_template,onChange:p=>a({...e,prompt_template:p.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"}),t.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Path to the prompt template file relative to .ralphx/ directory"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Tools (optional)"}),t.jsx("input",{type:"text",value:e.tools.join(", "),onChange:p=>a({...e,tools:p.target.value.split(",").map(x=>x.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"}),t.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Comma-separated list of tool names available to this mode"})]})]})]})}function m3({modes:e,onChange:r}){const[s,a]=y.useState(e.length===0?null:0),o=y.useCallback((u,h)=>{const p=[...e];p[u]=h,r(p)},[e,r]),c=y.useCallback(u=>{const h=e.filter((p,x)=>x!==u);r(h),s===u?a(h.length>0?0:null):s!==null&&s>u&&a(s-1)},[e,r,s]),d=()=>{const u={name:`mode_${e.length+1}`,description:"",model:"claude-sonnet-4-20250514",timeout:300,tools:[],prompt_template:""};r([...e,u]),a(e.length)};return t.jsxs("section",{children:[t.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center",children:[t.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"]}),t.jsxs("div",{className:"space-y-3 pl-11",children:[t.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."}),e.length===0?t.jsxs("div",{className:"p-4 border-2 border-dashed border-gray-600 rounded-lg text-center",children:[t.jsx("p",{className:"text-gray-400 mb-2",children:"No modes configured"}),t.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"At least one mode is required for the loop to run"})]}):t.jsx("div",{className:"space-y-2",children:e.map((u,h)=>t.jsx(u3,{mode:u,isExpanded:s===h,onToggle:()=>a(s===h?null:h),onChange:p=>o(h,p),onDelete:()=>c(h)},u.name||`unnamed_mode_${h}`))}),t.jsxs("button",{type:"button",onClick:d,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:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),t.jsx("span",{children:"Add Mode"})]})]})]})}function h3({strategy:e,modes:r,onChange:s}){var u;const a=h=>{const p={strategy:h};if(h==="fixed"&&r.length>0&&(p.fixed_mode=r[0].name),h==="weighted_random"){const x={},g=Math.floor(100/r.length);r.forEach(b=>{x[b.name]=g}),p.weights=x}s(p)},o=h=>{s({...e,fixed_mode:h})},c=(h,p)=>{s({...e,weights:{...e.weights,[h]:p}})},d=e.weights?Object.values(e.weights).reduce((h,p)=>h+p,0):0;return t.jsxs("section",{children:[t.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center",children:[t.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"]}),t.jsxs("div",{className:"space-y-4 pl-11",children:[t.jsx("p",{className:"text-sm text-gray-400",children:"Choose how the loop selects which mode to use for each iteration."}),t.jsxs("div",{className:"space-y-3",children:[t.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:[t.jsx("input",{type:"radio",name:"strategy",checked:e.strategy==="fixed",onChange:()=>a("fixed"),className:"mt-1"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-white",children:"Fixed"}),t.jsx("div",{className:"text-xs text-gray-400 mt-1",children:"Always use the same mode for every iteration"}),e.strategy==="fixed"&&r.length>0&&t.jsx("select",{value:e.fixed_mode||((u=r[0])==null?void 0:u.name)||"",onChange:h=>o(h.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:r.map(h=>t.jsx("option",{value:h.name,children:h.name},h.name))})]})]}),t.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:[t.jsx("input",{type:"radio",name:"strategy",checked:e.strategy==="random",onChange:()=>a("random"),className:"mt-1"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-white",children:"Random"}),t.jsx("div",{className:"text-xs text-gray-400 mt-1",children:"Randomly select a mode with equal probability"})]})]}),t.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:[t.jsx("input",{type:"radio",name:"strategy",checked:e.strategy==="weighted_random",onChange:()=>a("weighted_random"),className:"mt-1"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-white",children:"Weighted Random"}),t.jsx("div",{className:"text-xs text-gray-400 mt-1",children:"Randomly select a mode based on specified weights"}),e.strategy==="weighted_random"&&r.length>0&&t.jsxs("div",{className:"mt-3 space-y-2",children:[r.map(h=>{var g;const p=((g=e.weights)==null?void 0:g[h.name])||0,x=d>0?(p/d*100).toFixed(0):0;return t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx("span",{className:"text-sm text-gray-300 w-24 truncate",title:h.name,children:h.name}),t.jsx("input",{type:"range",min:0,max:100,value:p,onChange:b=>c(h.name,parseInt(b.target.value)),className:"flex-1 h-2 bg-gray-600 rounded-lg appearance-none cursor-pointer accent-primary-500"}),t.jsxs("span",{className:"text-sm text-gray-400 w-16 text-right",children:[x,"%"]})]},h.name)}),d!==100&&t.jsx("p",{className:"text-xs text-yellow-400 mt-2",children:"Weights will be normalized to 100%"})]})]})]})]}),r.length===0&&t.jsx("p",{className:"text-sm text-yellow-400",children:"Add at least one mode to configure the selection strategy"})]})]})}function p3({limits:e,onChange:r}){const s=(o,c)=>{r({...e,[o]:c})},a=o=>{if(o<60)return`${o}s`;if(o<3600)return`${Math.floor(o/60)}m`;const c=Math.floor(o/3600),d=Math.floor(o%3600/60);return d>0?`${c}h ${d}m`:`${c}h`};return t.jsxs("section",{children:[t.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center",children:[t.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"]}),t.jsxs("div",{className:"space-y-4 pl-11",children:[t.jsx("p",{className:"text-sm text-gray-400",children:"Set safety limits to prevent runaway loops and manage resource usage."}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"p-4 bg-gray-700/50 rounded-lg border border-gray-600",children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:["Max Iterations",t.jsx(xn,{content:gn.maxIterations.body,size:"sm",className:"ml-1"})]}),t.jsx("input",{type:"number",value:e.max_iterations,onChange:o=>s("max_iterations",parseInt(o.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"}),t.jsx("p",{className:"mt-2 text-xs text-gray-500",children:e.max_iterations===0?"Unlimited iterations":`Loop will stop after ${e.max_iterations} iterations`})]}),t.jsxs("div",{className:"p-4 bg-gray-700/50 rounded-lg border border-gray-600",children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:["Max Runtime",t.jsx(xn,{content:gn.maxRuntime.body,size:"sm",className:"ml-1"})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("input",{type:"number",value:e.max_runtime_seconds,onChange:o=>s("max_runtime_seconds",parseInt(o.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"}),t.jsx("span",{className:"text-sm text-gray-400",children:"seconds"})]}),t.jsx("p",{className:"mt-2 text-xs text-gray-500",children:e.max_runtime_seconds===0?"Unlimited runtime":`Loop will stop after ${a(e.max_runtime_seconds)}`})]}),t.jsxs("div",{className:"p-4 bg-gray-700/50 rounded-lg border border-gray-600",children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:["Max Consecutive Errors",t.jsx(xn,{content:gn.maxErrors.body,size:"sm",className:"ml-1"})]}),t.jsx("input",{type:"number",value:e.max_consecutive_errors,onChange:o=>s("max_consecutive_errors",parseInt(o.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"}),t.jsxs("p",{className:"mt-2 text-xs text-gray-500",children:["Loop stops if ",e.max_consecutive_errors," errors occur in a row"]})]}),t.jsxs("div",{className:"p-4 bg-gray-700/50 rounded-lg border border-gray-600",children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:["Cooldown Between Iterations",t.jsx(xn,{content:gn.cooldown.body,size:"sm",className:"ml-1"})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("input",{type:"number",value:e.cooldown_between_iterations,onChange:o=>s("cooldown_between_iterations",parseInt(o.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"}),t.jsx("span",{className:"text-sm text-gray-400",children:"seconds"})]}),t.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"Wait time between each iteration"})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-2 pt-2",children:[t.jsx("span",{className:"text-sm text-gray-400 mr-2",children:"Quick presets:"}),t.jsx("button",{type:"button",onClick:()=>r({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)"}),t.jsx("button",{type:"button",onClick:()=>r({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)"}),t.jsx("button",{type:"button",onClick:()=>r({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 f3({content:e,error:r,onChange:s}){const[a,o]=y.useState("idle"),c=async()=>{try{await navigator.clipboard.writeText(e),o("copied"),setTimeout(()=>o("idle"),2e3)}catch{o("failed"),setTimeout(()=>o("idle"),2e3)}};return t.jsxs("div",{className:"h-full flex flex-col",children:[r&&t.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:t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),t.jsx("span",{children:r})]})}),t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-gray-700/50 border-b border-gray-700",children:[t.jsx("span",{className:"text-sm text-gray-400",children:"YAML Configuration"}),t.jsx("div",{className:"flex items-center space-x-2",children:t.jsx("button",{type:"button",onClick:c,className:`px-2 py-1 text-xs rounded transition-colors ${a==="copied"?"bg-green-700 text-green-200":a==="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:a==="copied"?"Copied!":a==="failed"?"Failed":"Copy"})})]}),t.jsxs("div",{className:"flex-1 p-4",children:[t.jsx("label",{htmlFor:"yaml-editor",className:"sr-only",children:"YAML Configuration Editor"}),t.jsx("textarea",{id:"yaml-editor",value:e,onChange:d=>s(d.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 ${r?"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":r?"true":"false","aria-describedby":r?"yaml-error":void 0})]}),t.jsx("div",{className:"p-4 bg-gray-700/30 border-t border-gray-700",children:t.jsxs("div",{className:"text-xs text-gray-500",children:[t.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 Hp={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"},x3={generator:"bg-green-600",consumer:"bg-blue-600",hybrid:"bg-purple-600"};function g3({onSelect:e,onClose:r}){const[s,a]=y.useState([]),[o,c]=y.useState(!0),[d,u]=y.useState(null),[h,p]=y.useState(null),[x,g]=y.useState(!1),b=y.useRef(null),v=y.useRef(null),k=y.useCallback(A=>{A.key==="Escape"&&r()},[r]);y.useEffect(()=>{T()},[]),y.useEffect(()=>{var A;return document.addEventListener("keydown",k),(A=v.current)==null||A.focus(),()=>{document.removeEventListener("keydown",k)}},[k]);const T=async()=>{try{c(!0),u(null);const A=await mb();a(A.templates)}catch(A){u(A instanceof Error?A.message:"Failed to load templates")}finally{c(!1)}},N=async A=>{try{p(A),g(!0);const M=await hb(A);e(M.config,M.config_yaml)}catch(M){u(M instanceof Error?M.message:"Failed to load template"),p(null)}finally{g(!1)}},j=()=>{e({},"")};return t.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:t.jsxs("div",{ref:b,className:"bg-gray-800 rounded-lg w-full max-w-3xl max-h-[80vh] flex flex-col",children:[t.jsxs("div",{className:"p-4 border-b border-gray-700 flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h3",{id:"template-selector-title",className:"text-lg font-semibold text-white",children:"Choose a Template"}),t.jsx("p",{className:"text-sm text-gray-400",children:"Start with a pre-configured template or create from scratch"})]}),t.jsx("button",{ref:v,onClick:r,className:"text-gray-400 hover:text-white","aria-label":"Close template selector",children:t.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:o?t.jsx("div",{className:"flex items-center justify-center h-48",role:"status","aria-label":"Loading templates",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary-500"})}):d?t.jsxs("div",{className:"p-4 bg-red-900/30 border border-red-800 rounded text-red-400",role:"alert",children:[d,t.jsx("button",{onClick:T,className:"ml-2 underline hover:no-underline",children:"Retry"})]}):t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[t.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:t.jsxs("div",{className:"flex items-start space-x-3",children:[t.jsx("div",{className:"p-2 rounded-lg bg-gray-700 group-hover:bg-gray-600 transition-colors",children:t.jsx("svg",{className:"w-6 h-6 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h4",{className:"font-medium text-white group-hover:text-primary-400 transition-colors",children:"Start from Scratch"}),t.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Create a custom loop configuration with all fields empty"})]})]})}),s.map(A=>t.jsx("button",{onClick:()=>N(A.name),disabled:x,className:`p-4 border border-gray-700 rounded-lg hover:border-gray-500 hover:bg-gray-700/30 transition-all text-left group ${h===A.name?"border-primary-500 bg-gray-700/50":""} ${x?"opacity-50 cursor-not-allowed":""}`,children:t.jsxs("div",{className:"flex items-start space-x-3",children:[t.jsx("div",{className:"p-2 rounded-lg bg-gray-700 group-hover:bg-gray-600 transition-colors",children:t.jsx("svg",{className:"w-6 h-6 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:Hp[A.category]||Hp.generation})})}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("h4",{className:"font-medium text-white group-hover:text-primary-400 transition-colors",children:A.display_name}),t.jsx("span",{className:`px-2 py-0.5 text-xs rounded ${x3[A.type]||"bg-gray-600"} text-white`,children:A.type})]}),t.jsx("p",{className:"text-sm text-gray-400 mt-1",children:A.description}),h===A.name&&x&&t.jsxs("div",{className:"mt-2 flex items-center text-sm text-primary-400",children:[t.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Loading template..."]})]})]})},A.name))]})}),t.jsx("div",{className:"p-4 border-t border-gray-700",children:t.jsx("p",{className:"text-xs text-gray-500",children:"Templates provide pre-configured settings. You can customize all values after selection."})})]})})}function y3({projectSlug:e,loopName:r,loopType:s}){const[a,o]=y.useState(null),[c,d]=y.useState(!0),[u,h]=y.useState(null),[p,x]=y.useState(null),[g,b]=y.useState(!0),[v,k]=y.useState(null),[T,N]=y.useState([]),[j,A]=y.useState(new Set(["rendered"]));y.useEffect(()=>{s==="consumer"&&xa(e,{status:"pending",limit:10}).then(P=>N(P.items)).catch(()=>{})},[e,s]);const M=y.useCallback(async()=>{d(!0),h(null);try{const P=await jb(e,r,{mode:p||void 0,sample_item_id:v||void 0,include_annotations:g,use_first_pending:!v});o(P)}catch(P){h(P instanceof Error?P.message:"Failed to load preview")}finally{d(!1)}},[e,r,p,v,g]);y.useEffect(()=>{M()},[M]);const _=P=>{A($=>{const V=new Set($);return V.has(P)?V.delete(P):V.add(P),V})},z=P=>{navigator.clipboard.writeText(P)};return c?t.jsx("div",{className:"flex items-center justify-center p-8",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary-500"})}):u?t.jsxs("div",{className:"p-6",children:[t.jsx("div",{className:"p-4 bg-red-900/30 border border-red-800 rounded text-red-400",children:u}),t.jsx("button",{onClick:M,className:"mt-4 px-4 py-2 bg-gray-700 text-white rounded hover:bg-gray-600",children:"Retry"})]}):a?t.jsxs("div",{className:"p-6 space-y-6",children:[t.jsxs("div",{className:"bg-gray-700/50 rounded-lg p-4",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-3",children:"Preview Options"}),t.jsxs("div",{className:"flex flex-wrap gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-gray-400 mb-1",children:"Mode"}),t.jsxs("select",{value:p||"",onChange:P=>x(P.target.value||null),className:"bg-gray-800 text-white text-sm rounded px-3 py-1.5 border border-gray-600",children:[t.jsx("option",{value:"",children:"All Modes"}),a.modes.map(P=>t.jsx("option",{value:P.mode_name,children:P.mode_name},P.mode_name))]})]}),a.loop_type==="consumer"&&T.length>0&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-gray-400 mb-1",children:"Sample Item"}),t.jsxs("select",{value:v||"",onChange:P=>k(P.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:[t.jsx("option",{value:"",children:"Auto (first pending)"}),T.map(P=>t.jsxs("option",{value:P.id,children:[P.content.substring(0,50),"..."]},P.id))]})]}),t.jsx("div",{className:"flex items-center",children:t.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:g,onChange:P=>b(P.target.checked),className:"rounded bg-gray-800 border-gray-600"}),t.jsx("span",{className:"text-sm text-gray-300",children:"Show Section Markers"})]})}),t.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"})]})]}),t.jsxs("div",{className:"bg-gray-700/50 rounded-lg p-4",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-3",children:"Loop Overview"}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-400",children:"Type:"}),t.jsx("span",{className:"ml-2 text-white capitalize",children:a.loop_type})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-400",children:"Strategy:"}),t.jsx("span",{className:"ml-2 text-white",children:a.mode_selection_strategy.replace("_"," ")})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-400",children:"Modes:"}),t.jsx("span",{className:"ml-2 text-white",children:a.modes.length})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-400",children:"Resources:"}),t.jsx("span",{className:"ml-2 text-white",children:a.resources_used.length})]})]}),t.jsx("p",{className:"mt-3 text-sm text-gray-400",children:a.strategy_explanation})]}),a.resources_used.length>0&&t.jsxs("div",{className:"bg-gray-700/50 rounded-lg p-4",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-2",children:"Resources Injected"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:a.resources_used.map(P=>t.jsx("span",{className:"px-2 py-1 text-xs bg-blue-900/30 text-blue-400 rounded",children:P},P))})]}),Object.keys(a.template_variables).length>0&&t.jsxs("div",{className:"bg-gray-700/50 rounded-lg p-4",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-2",children:"Template Variables"}),t.jsx("div",{className:"space-y-1",children:Object.entries(a.template_variables).map(([P,$])=>t.jsxs("div",{className:"flex text-sm",children:[t.jsx("code",{className:"text-yellow-400 font-mono",children:P}),t.jsx("span",{className:"mx-2 text-gray-500",children:"="}),t.jsx("span",{className:"text-gray-300 truncate",children:$})]},P))})]}),a.warnings.length>0&&t.jsxs("div",{className:"bg-yellow-900/20 border border-yellow-800/50 rounded-lg p-4",children:[t.jsx("h4",{className:"text-sm font-medium text-yellow-400 mb-2",children:"Warnings"}),t.jsx("ul",{className:"list-disc list-inside text-sm text-yellow-300 space-y-1",children:a.warnings.map((P,$)=>t.jsx("li",{children:P},$))})]}),a.modes.map(P=>t.jsx(v3,{modePreview:P,expandedSections:j,onToggleSection:_,onCopy:z},P.mode_name)),a.sample_item&&t.jsxs("div",{className:"bg-gray-700/50 rounded-lg p-4",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-2",children:"Sample Item Used"}),t.jsx("pre",{className:"text-xs text-gray-400 bg-gray-900 p-3 rounded overflow-x-auto",children:JSON.stringify(a.sample_item,null,2)})]})]}):null}function v3({modePreview:e,expandedSections:r,onToggleSection:s,onCopy:a}){const o=`rendered-${e.mode_name}`,c=`sections-${e.mode_name}`;return t.jsxs("div",{className:"bg-gray-700/50 rounded-lg overflow-hidden",children:[t.jsxs("div",{className:"p-4 border-b border-gray-600",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-white font-medium",children:e.mode_name}),t.jsxs("p",{className:"text-sm text-gray-400",children:["Model: ",e.model," | Timeout: ",e.timeout,"s | Tools: ",e.tools.length>0?e.tools.join(", "):"None"]})]}),t.jsxs("div",{className:"text-right text-sm",children:[t.jsxs("div",{className:"text-gray-300",children:["~",e.token_estimate.toLocaleString()," tokens"]}),t.jsxs("div",{className:"text-gray-500",children:[e.total_length.toLocaleString()," chars"]})]})]}),e.warnings.length>0&&t.jsx("div",{className:"mt-2 p-2 bg-yellow-900/20 rounded text-sm text-yellow-400",children:e.warnings.join(", ")})]}),t.jsxs("div",{className:"border-b border-gray-600",children:[t.jsxs("button",{onClick:()=>s(c),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:[t.jsxs("span",{children:["Section Breakdown (",e.sections.length," sections)"]}),t.jsx("svg",{className:`w-4 h-4 transition-transform ${r.has(c)?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),r.has(c)&&t.jsx("div",{className:"px-4 pb-4 space-y-2",children:e.sections.map((d,u)=>t.jsxs("div",{className:"p-2 bg-gray-800 rounded text-sm",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsxs("span",{className:"text-gray-400",children:["[",d.position.toUpperCase(),"]"]}),t.jsxs("span",{className:"text-xs text-gray-500",children:[d.source," ",d.source_name&&`(${d.source_name})`]})]}),t.jsxs("div",{className:"text-xs text-gray-500",children:["Lines ",d.start_line,"-",d.end_line," | ",d.content.length," chars"]})]},u))})]}),t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>s(o),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:[t.jsx("span",{children:"Rendered Prompt"}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("button",{onClick:d=>{d.stopPropagation(),a(e.rendered_prompt)},className:"text-xs px-2 py-1 bg-gray-600 hover:bg-gray-500 rounded",children:"Copy"}),t.jsx("svg",{className:`w-4 h-4 transition-transform ${r.has(o)?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),r.has(o)&&t.jsx("div",{className:"p-4",children:t.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:e.rendered_prompt})})]})]})}function w3({projectSlug:e,loopName:r,initialYaml:s,availableLoops:a=[],onClose:o,onSave:c}){const[d,u]=y.useState("visual"),[h,p]=y.useState(Vg),[x,g]=y.useState(""),[b,v]=y.useState(null),[k,T]=y.useState(!1),[N,j]=y.useState(null),[A,M]=y.useState(""),_=!r,[z,P]=y.useState(_&&!s);y.useEffect(()=>{if(s){g(s),M(s);try{const W=$o.load(s);p(vd(W)),v(null)}catch(W){v(W instanceof Error?W.message:"Invalid YAML")}}},[s]);const $=y.useCallback(()=>{try{const W=Op(h),J=$o.dump(W,{indent:2,lineWidth:-1,noRefs:!0,sortKeys:!1});g(J),v(null)}catch(W){console.error("Failed to convert form state to YAML:",W)}},[h]),V=y.useCallback(()=>{if(!x.trim())return v("YAML content is empty"),!1;try{const W=$o.load(x);return typeof W!="object"||W===null?(v("YAML must be an object"),!1):(p(vd(W)),v(null),!0)}catch(W){return v(W instanceof Error?W.message:"Invalid YAML"),!1}},[x]);y.useEffect(()=>{if(d==="visual"){const W=setTimeout($,100);return()=>clearTimeout(W)}},[d,h,$]);const B=W=>{if(W==="yaml"&&d==="visual")$();else if(W==="visual"&&d==="yaml"){if(!V())return}else if(W==="preview"&&d==="yaml"){if(!V())return}else W==="preview"&&d==="visual"&&$();u(W)},U=y.useMemo(()=>x!==A,[x,A]),D=y.useCallback(()=>{if(!h.name.trim())return"Loop name is required";if(!/^[a-z0-9_-]+$/.test(h.name))return"Loop name must contain only lowercase letters, numbers, hyphens, and underscores";if(!h.display_name.trim())return"Display name is required";if(h.modes.length===0)return"At least one mode is required";const W=new Set;for(const J of h.modes){if(!J.name.trim())return"All modes must have a name";if(W.has(J.name))return`Duplicate mode name: "${J.name}". Each mode must have a unique name.`;if(W.add(J.name),!J.prompt_template.trim())return`Mode "${J.name}" must have a prompt template`}return h.mode_selection.strategy==="fixed"&&!h.mode_selection.fixed_mode&&h.modes.length>0?"Fixed strategy requires selecting a mode":null},[h]),R=async()=>{let W;if(d==="visual")try{const Z=Op(h);W=$o.dump(Z,{indent:2,lineWidth:-1,noRefs:!0,sortKeys:!1}),g(W),v(null)}catch{j("Failed to generate YAML from form");return}else{if(!V()){j("Fix YAML errors before saving");return}W=x}const J=D();if(J){j(J);return}T(!0),j(null);try{await c(W)}catch(Z){j(Z instanceof Error?Z.message:"Failed to save")}finally{T(!1)}},X=()=>{U&&!window.confirm("Discard unsaved changes?")||o()},I=y.useCallback(W=>{p(J=>({...J,...W}))},[]),H=y.useCallback((W,J)=>{P(!1),J&&Object.keys(W).length>0&&(g(J),p(vd(W)),v(null))},[]);return z?t.jsx(g3,{onSelect:H,onClose:o}):t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-gray-800 rounded-lg w-full max-w-4xl max-h-[90vh] flex flex-col",children:[t.jsxs("div",{className:"p-4 border-b border-gray-700 flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-white",children:_?"Create New Loop":`Edit Loop: ${r}`}),t.jsxs("p",{className:"text-sm text-gray-400",children:["Project: ",e]})]}),t.jsx("button",{onClick:X,className:"text-gray-400 hover:text-white","aria-label":"Close",children:t.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsxs("div",{className:"flex border-b border-gray-700",children:[t.jsx("button",{onClick:()=>B("visual"),className:`px-6 py-3 text-sm font-medium transition-colors ${d==="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"}),t.jsxs("button",{onClick:()=>B("yaml"),className:`px-6 py-3 text-sm font-medium transition-colors ${d==="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&&t.jsx("span",{className:"ml-2 w-2 h-2 inline-block rounded-full bg-red-500",title:"YAML has errors"})]}),!_&&r&&t.jsx("button",{onClick:()=>B("preview"),className:`px-6 py-3 text-sm font-medium transition-colors ${d==="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"})]}),t.jsx("div",{className:"flex-1 overflow-y-auto",children:d==="visual"?t.jsxs("div",{className:"p-6 space-y-6",children:[t.jsx(c3,{name:h.name,displayName:h.display_name,type:h.type,description:h.description,isNewLoop:_,onChange:W=>I(W)}),t.jsx(d3,{itemTypes:h.item_types,loopType:h.type,availableLoops:a.filter(W=>W!==h.name),onChange:W=>I({item_types:W})}),t.jsx(m3,{modes:h.modes,onChange:W=>I({modes:W})}),t.jsx(h3,{strategy:h.mode_selection,modes:h.modes,onChange:W=>I({mode_selection:W})}),t.jsx(p3,{limits:h.limits,onChange:W=>I({limits:W})})]}):d==="yaml"?t.jsx(f3,{content:x,error:b,onChange:g}):d==="preview"&&r?t.jsx(y3,{projectSlug:e,loopName:r,loopType:h.type}):null}),N&&t.jsx("div",{className:"px-4 pb-2",children:t.jsx("div",{className:"p-3 bg-red-900/30 border border-red-800 rounded text-sm text-red-400",children:N})}),t.jsxs("div",{className:"p-4 border-t border-gray-700 flex items-center justify-between",children:[t.jsx("div",{className:"text-sm text-gray-500",children:U?t.jsx("span",{className:"text-yellow-400",children:"Unsaved changes"}):t.jsx("span",{children:"No changes"})}),t.jsxs("div",{className:"flex space-x-3",children:[t.jsx("button",{onClick:X,disabled:k,className:"px-4 py-2 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600 disabled:opacity-50",children:"Cancel"}),t.jsx("button",{onClick:R,disabled:k||!!b,className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500 disabled:opacity-50",children:k?"Saving...":_?"Create Loop":"Save Changes"})]})]})]})})}const b3={master_design:"Master Design",story_instructions:"Story Instructions",stories:"Stories (JSONL)",guardrails:"Guardrails",reference:"Reference"};function j3({loopType:e,onSelect:r,onCancel:s}){const[a,o]=y.useState([]),[c,d]=y.useState(!0),[u,h]=y.useState(null),[p,x]=y.useState(null),[g,b]=y.useState(null),[v,k]=y.useState(!1);y.useEffect(()=>{T()},[e]);const T=async()=>{d(!0),h(null);try{const A=await Eb(e);o(A),A.length>0&&N(A[0])}catch(A){h(A instanceof Error?A.message:"Failed to load templates")}finally{d(!1)}},N=async A=>{x(A),k(!0);try{const M=await Tb(A.id);b(M.content)}catch{b("Failed to load template content")}finally{k(!1)}},j=()=>{p&&r(p.id)};return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-gray-800 rounded-lg w-full max-w-4xl h-[80vh] flex flex-col",children:[t.jsxs("div",{className:"p-4 border-b border-gray-700 flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-white",children:"Input Templates"}),t.jsxs("p",{className:"text-sm text-gray-400 mt-1",children:["Pre-curated inputs for ",e," loops"]})]}),t.jsx("button",{onClick:s,className:"p-1 text-gray-400 hover:text-white","aria-label":"Close",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:"w-1/3 border-r border-gray-700 overflow-y-auto",children:c?t.jsx("div",{className:"p-4 text-gray-400",children:"Loading templates..."}):u?t.jsx("div",{className:"p-4 text-red-400",children:u}):a.length===0?t.jsxs("div",{className:"p-4 text-gray-400",children:["No templates available for ",e," loops"]}):t.jsx("div",{className:"p-2 space-y-2",children:a.map(A=>t.jsxs("button",{onClick:()=>N(A),className:`w-full text-left p-3 rounded transition-colors ${(p==null?void 0:p.id)===A.id?"bg-primary-600/30 border border-primary-500":"bg-gray-700/50 border border-transparent hover:bg-gray-700"}`,children:[t.jsx("div",{className:"font-medium text-white",children:A.name}),t.jsx("div",{className:"text-sm text-gray-400 mt-1",children:A.description}),t.jsxs("div",{className:"mt-2 flex items-center space-x-2",children:[t.jsx("span",{className:"px-2 py-0.5 text-xs bg-gray-600 rounded",children:b3[A.tag]||A.tag}),t.jsx("span",{className:"text-xs text-gray-500",children:A.filename})]})]},A.id))})}),t.jsxs("div",{className:"flex-1 flex flex-col",children:[t.jsx("div",{className:"p-3 border-b border-gray-700",children:t.jsx("span",{className:"text-sm font-medium text-gray-300",children:"Preview"})}),t.jsx("div",{className:"flex-1 overflow-auto p-4",children:v?t.jsx("div",{className:"text-gray-400",children:"Loading..."}):g?t.jsx("pre",{className:"text-sm text-gray-300 whitespace-pre-wrap font-mono",children:g}):t.jsx("div",{className:"text-gray-400",children:"Select a template to preview"})})]})]}),t.jsxs("div",{className:"p-4 border-t border-gray-700 flex justify-end space-x-3",children:[t.jsx("button",{onClick:s,className:"px-4 py-2 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600",children:"Cancel"}),t.jsx("button",{onClick:j,disabled:!p,className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500 disabled:opacity-50",children:"Apply Template"})]})]})})}const sa=[{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"}],k3=[{value:"system",label:"Use Default",description:"Use the built-in RalphX template",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.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:t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.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:t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.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:t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.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"})})}],wd={loop_template:t.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),design_doc:t.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.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:t.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.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:t.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.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 N3({addForm:e,setAddForm:r,onClose:s,onCreate:a,openFileBrowser:o,otherLoops:c,loopResources:d}){const[u,h]=y.useState("type"),p=sa.find(k=>k.value===e.resource_type),x=e.resource_type==="loop_template"||e.resource_type==="guardrails",g=()=>e.source_type==="system"?!0:e.source_type==="project_file"?!!e.source_path:e.source_type==="loop_ref"?!!e.source_loop&&!!e.source_resource_id:e.source_type==="inline"?!!e.inline_content:!1,b=()=>{u==="config"?h("source"):u==="source"&&h("type")},v=()=>{u==="type"?h("source"):u==="source"&&(e.source_type==="system"?a():h("config"))};return t.jsx("div",{className:"fixed inset-0 bg-black/70 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:t.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:[t.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
|
+
`}),t.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:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-white tracking-tight",children:"Add Resource"}),t.jsx("div",{className:"flex items-center gap-1.5",children:["type","source","config"].map((k,T)=>t.jsx("div",{className:`h-1.5 rounded-full transition-all duration-300 ${k===u?"w-6 bg-blue-500":["type","source","config"].indexOf(u)>T?"w-1.5 bg-blue-500/50":"w-1.5 bg-gray-700"}`},k))})]}),t.jsx("button",{onClick:s,className:"p-1.5 text-gray-500 hover:text-white hover:bg-gray-800 rounded-lg transition-colors",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsxs("div",{className:"p-6",children:[u==="type"&&t.jsxs("div",{className:"step-content",children:[t.jsx("p",{className:"text-gray-400 text-sm mb-5",children:"What are you adding?"}),t.jsx("div",{className:"grid grid-cols-2 gap-3",children:sa.map(k=>t.jsxs("button",{onClick:()=>r({...e,resource_type:k.value}),className:`group relative p-4 rounded-lg text-left transition-all duration-150 ${e.resource_type===k.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:[t.jsx("div",{className:`mb-3 p-2 rounded-lg inline-block ${e.resource_type===k.value?"bg-blue-500/20 text-blue-400":"bg-gray-700/50 text-gray-400 group-hover:text-gray-300"}`,children:wd[k.value]}),t.jsx("div",{className:"font-medium text-white mb-1",children:k.label}),t.jsx("div",{className:"text-xs text-gray-500 leading-relaxed",children:k.description}),e.resource_type===k.value&&t.jsx("div",{className:"absolute top-3 right-3 w-2 h-2 rounded-full bg-blue-500"})]},k.value))})]}),u==="source"&&t.jsxs("div",{className:"step-content",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[t.jsx("div",{className:"p-1.5 rounded bg-blue-500/20 text-blue-400",children:wd[e.resource_type]}),t.jsxs("span",{className:"text-sm text-gray-400",children:[p==null?void 0:p.label," ",t.jsx("span",{className:"text-gray-600",children:"→"})," Choose source"]})]}),t.jsx("div",{className:"grid grid-cols-2 gap-3",children:k3.filter(k=>k.value!=="system"||x).map(k=>t.jsxs("button",{onClick:()=>r({...e,source_type:k.value}),className:`group p-4 rounded-lg text-left transition-all duration-150 ${e.source_type===k.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:[t.jsx("div",{className:`mb-2 ${e.source_type===k.value?"text-blue-400":"text-gray-500 group-hover:text-gray-400"}`,children:k.icon}),t.jsx("div",{className:"font-medium text-white text-sm",children:k.label}),t.jsx("div",{className:"text-xs text-gray-500 mt-0.5",children:k.description})]},k.value))}),e.source_type==="project_file"&&t.jsx("div",{className:"mt-4 pt-4 border-t border-gray-800/50",children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",value:e.source_path,onChange:k=>r({...e,source_path:k.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"}),t.jsx("button",{onClick:o,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"})]})}),e.source_type==="loop_ref"&&t.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-800/50 space-y-3",children:[t.jsxs("select",{value:e.source_loop,onChange:k=>r({...e,source_loop:k.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:[t.jsx("option",{value:"",children:"Select a loop..."}),c.map(k=>t.jsx("option",{value:k.name,children:k.display_name||k.name},k.name))]}),e.source_loop&&d.length>0&&t.jsxs("select",{value:e.source_resource_id||"",onChange:k=>r({...e,source_resource_id:k.target.value?parseInt(k.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:[t.jsx("option",{value:"",children:"Select a resource..."}),d.map(k=>t.jsxs("option",{value:k.id,children:[k.name," (",k.resource_type,")"]},k.id))]})]}),e.source_type==="inline"&&t.jsx("div",{className:"mt-4 pt-4 border-t border-gray-800/50",children:t.jsx("textarea",{value:e.inline_content,onChange:k=>r({...e,inline_content:k.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"})})]}),u==="config"&&t.jsxs("div",{className:"step-content",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[t.jsx("div",{className:"p-1.5 rounded bg-blue-500/20 text-blue-400",children:wd[e.resource_type]}),t.jsxs("span",{className:"text-sm text-gray-400",children:[p==null?void 0:p.label," ",t.jsx("span",{className:"text-gray-600",children:"→"})," Final details"]})]}),t.jsxs("div",{className:"bg-gray-800/30 rounded-lg p-4 border border-gray-700/30 mb-4",children:[t.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wider mb-1",children:"Source"}),t.jsxs("div",{className:"text-white font-mono text-sm",children:[e.source_type==="project_file"&&e.source_path,e.source_type==="loop_ref"&&`${e.source_loop} → resource`,e.source_type==="inline"&&`${e.inline_content.slice(0,50)}...`]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-gray-500 uppercase tracking-wider mb-2",children:"Name (optional)"}),t.jsx("input",{type:"text",value:e.name,onChange:k=>r({...e,name:k.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"})]})]})]}),t.jsxs("div",{className:"px-6 py-4 border-t border-gray-800/50 flex items-center justify-between bg-gray-900/30",children:[t.jsx("button",{onClick:u==="type"?s:b,className:"px-4 py-2 text-gray-400 hover:text-white transition-colors text-sm",children:u==="type"?"Cancel":"← Back"}),u==="config"?t.jsx("button",{onClick:a,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"}):t.jsx("button",{onClick:v,disabled:u==="source"&&!g()&&e.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:u==="source"&&e.source_type==="system"?"Add Resource":"Continue →"})]})]})})}function C3({projectSlug:e,loopName:r,loopType:s}){const[a,o]=y.useState([]),[c,d]=y.useState(!0),[u,h]=y.useState(null),[p,x]=y.useState(!1),[g,b]=y.useState({resource_type:"design_doc",name:"",source_type:"project_file",source_path:"",source_loop:"",source_resource_id:null,inline_content:""}),[v,k]=y.useState(!1),[T,N]=y.useState(""),[j,A]=y.useState([]),[M,_]=y.useState([]),[z,P]=y.useState(!1),[$,V]=y.useState(null),[B,U]=y.useState([]),[D,R]=y.useState([]),[X,I]=y.useState(null),[H,W]=y.useState(""),J=y.useCallback(async()=>{d(!0),h(null);try{const F=await ap(e,r,!0);o(F)}catch(F){h(F instanceof Error?F.message:"Failed to load resources")}finally{d(!1)}},[e,r]);y.useEffect(()=>{J()},[J]),y.useEffect(()=>{async function F(){try{const he=await pu(e);U(he.filter(ue=>ue.name!==r))}catch{}}F()},[e,r]),y.useEffect(()=>{async function F(){if(g.source_loop)try{const he=await ap(e,g.source_loop,!1);R(he)}catch{R([])}else R([])}F()},[e,g.source_loop]);const Z=async()=>{k(!0);try{const F=await ud(e);N(F.relative_path||""),A(F.directories),_(F.files),P(F.canGoUp),V(F.parent)}catch(F){h(F instanceof Error?F.message:"Failed to browse files")}},de=async F=>{try{const he=T?`${T}/${F}`:F,ue=await ud(e,he);N(ue.relative_path||he),A(ue.directories),_(ue.files),P(ue.canGoUp),V(ue.parent)}catch(he){h(he instanceof Error?he.message:"Failed to navigate")}},E=async()=>{if($!==null)try{const F=await ud(e,$||void 0);N(F.relative_path||""),A(F.directories),_(F.files),P(F.canGoUp),V(F.parent)}catch(F){h(F instanceof Error?F.message:"Failed to navigate")}},L=F=>{const he=T?`${T}/${F}`:F;b({...g,source_path:he,name:F.replace(/\.[^/.]+$/,"")}),k(!1)},q=async()=>{const F=sa.find(ue=>ue.value===g.resource_type),he={resource_type:g.resource_type,name:g.name||g.resource_type,injection_position:(F==null?void 0:F.position)||"after_design_doc",source_type:g.source_type};g.source_type==="project_file"?he.source_path=g.source_path:g.source_type==="loop_ref"?(he.source_loop=g.source_loop,he.source_resource_id=g.source_resource_id||void 0):g.source_type==="inline"&&(he.inline_content=g.inline_content);try{await Yb(e,r,he),await J(),x(!1),b({resource_type:"design_doc",name:"",source_type:"project_file",source_path:"",source_loop:"",source_resource_id:null,inline_content:""})}catch(ue){h(ue instanceof Error?ue.message:"Failed to create resource")}},S=async F=>{try{await op(e,r,F.id,{enabled:!F.enabled}),await J()}catch(he){h(he instanceof Error?he.message:"Failed to update")}},G=async F=>{F.source_type==="inline"&&(I(F),W(F.content||""))},re=async()=>{if(X)try{await op(e,r,X.id,{inline_content:H}),await J(),I(null)}catch(F){h(F instanceof Error?F.message:"Failed to save")}},ee=async F=>{if(window.confirm(`Remove "${F.name}"? This won't delete any project files.`))try{await Gb(e,r,F.id),await J()}catch(he){h(he instanceof Error?he.message:"Failed to delete")}},ge=F=>{switch(F.source_type){case"system":return"Using default template";case"project_file":return F.source_path||"From project file";case"loop_ref":return`From loop: ${F.source_loop}`;case"project_resource":return"From project resource";case"inline":return"Custom content";default:return F.source_type}},Le=s==="planning"?["loop_template","design_doc","guardrails"]:s==="implementation"?["loop_template","design_doc","guardrails"]:["loop_template"],ve=F=>a.some(he=>he.resource_type===F&&he.enabled);return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-white",children:"Loop Resources"}),t.jsx("p",{className:"text-sm text-gray-400",children:"Resources are injected into the prompt when this loop runs"})]}),t.jsx("button",{onClick:()=>x(!0),className:"px-3 py-1.5 text-sm bg-primary-600 text-white rounded hover:bg-primary-500",children:"Add Resource"})]}),t.jsxs("div",{className:"p-4 bg-gray-800/50 rounded-lg border border-gray-700",children:[t.jsx("h4",{className:"text-sm font-medium text-white mb-3",children:"Quick Setup"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:Le.map(F=>{const he=sa.find(Oe=>Oe.value===F),ue=ve(F);return t.jsxs("button",{onClick:()=>{ue||(b({resource_type:F,name:"",source_type:F==="loop_template"||F==="guardrails"?"system":"project_file",source_path:"",source_loop:"",source_resource_id:null,inline_content:""}),x(!0))},disabled:ue,className:`flex items-center gap-2 px-3 py-1.5 rounded text-sm transition-all ${ue?"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:[ue?t.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):t.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),t.jsx("span",{children:(he==null?void 0:he.label)||F})]},F)})})]}),u&&t.jsxs("div",{className:"p-3 bg-red-900/30 border border-red-800 rounded text-sm text-red-400",children:[u,t.jsx("button",{onClick:()=>h(null),className:"ml-2 underline",children:"Dismiss"})]}),c?t.jsx("div",{className:"flex items-center justify-center p-8",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary-500"})}):a.length===0?t.jsxs("div",{className:"text-center py-8 text-gray-400 bg-gray-800/30 rounded-lg border border-dashed border-gray-700",children:[t.jsx("p",{className:"mb-2",children:"No resources configured for this loop yet."}),t.jsx("p",{className:"text-sm",children:"Add a loop template and design doc to get started."})]}):t.jsx("div",{className:"space-y-3",children:a.map(F=>{var he;return t.jsx("div",{className:`p-4 rounded-lg border ${F.enabled?"bg-gray-800/50 border-gray-700":"bg-gray-800/20 border-gray-800 opacity-60"}`,children:t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("button",{onClick:()=>S(F),className:`mt-1 w-4 h-4 rounded border flex-shrink-0 ${F.enabled?"bg-green-500 border-green-500":"bg-transparent border-gray-500"}`,title:F.enabled?"Enabled - click to disable":"Disabled - click to enable"}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-white font-medium",children:F.name}),t.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-gray-700 text-gray-400",children:((he=sa.find(ue=>ue.value===F.resource_type))==null?void 0:he.label)||F.resource_type})]}),t.jsx("p",{className:"text-sm text-gray-500 mt-1",children:ge(F)}),F.content&&t.jsxs("p",{className:"text-xs text-gray-600 mt-1 truncate max-w-lg",children:[F.content.slice(0,100),"..."]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[F.source_type==="inline"&&t.jsx("button",{onClick:()=>G(F),className:"px-2 py-1 text-xs bg-gray-700 text-white rounded hover:bg-gray-600",children:"Edit"}),t.jsx("button",{onClick:()=>ee(F),className:"px-2 py-1 text-xs bg-red-900/30 text-red-400 rounded hover:bg-red-900/50",children:"Remove"})]})]})},F.id)})}),p&&t.jsx(N3,{addForm:g,setAddForm:b,onClose:()=>x(!1),onCreate:q,openFileBrowser:Z,otherLoops:B,loopResources:D}),v&&t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",children:t.jsxs("div",{className:"bg-gray-800 rounded-lg w-full max-w-md mx-4",children:[t.jsxs("div",{className:"p-4 border-b border-gray-700 flex justify-between items-center",children:[t.jsx("h4",{className:"font-medium text-white",children:"Select File"}),t.jsx("button",{onClick:()=>k(!1),className:"text-gray-400 hover:text-white",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsxs("div",{className:"p-4",children:[t.jsx("div",{className:"text-sm text-gray-400 mb-2",children:T||"/ (project root)"}),t.jsxs("div",{className:"max-h-64 overflow-y-auto space-y-1",children:[z&&t.jsx("button",{onClick:E,className:"w-full text-left px-3 py-2 bg-gray-700 rounded hover:bg-gray-600 text-gray-300",children:".."}),j.map(F=>t.jsxs("button",{onClick:()=>de(F),className:"w-full text-left px-3 py-2 bg-gray-700 rounded hover:bg-gray-600 text-white",children:[F,"/"]},F)),M.map(F=>t.jsx("button",{onClick:()=>L(F.name),className:"w-full text-left px-3 py-2 bg-gray-700 rounded hover:bg-gray-600 text-white",children:F.name},F.name))]})]})]})}),X&&t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-gray-800 rounded-lg w-full max-w-3xl mx-4 max-h-[90vh] flex flex-col",children:[t.jsxs("div",{className:"p-4 border-b border-gray-700 flex items-center justify-between",children:[t.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Edit: ",X.name]}),t.jsx("button",{onClick:()=>I(null),className:"text-gray-400 hover:text-white",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsx("div",{className:"flex-1 p-4 overflow-y-auto",children:t.jsx("textarea",{value:H,onChange:F=>W(F.target.value),className:"w-full h-80 bg-gray-900 text-white font-mono text-sm p-4 rounded border border-gray-700"})}),t.jsxs("div",{className:"p-4 border-t border-gray-700 flex justify-end gap-2",children:[t.jsx("button",{onClick:()=>I(null),className:"px-4 py-2 text-gray-400 hover:text-white",children:"Cancel"}),t.jsx("button",{onClick:re,className:"px-4 py-2 bg-primary-600 text-white rounded hover:bg-primary-500",children:"Save"})]})]})})]})}function S3({projectSlug:e,loopName:r,onClose:s,onComplete:a}){const[o,c]=y.useState("analyzing"),[d,u]=y.useState([]),[h,p]=y.useState({}),[x,g]=y.useState(""),[b,v]=y.useState(null),[k,T]=y.useState(0),N=y.useCallback(z=>{z.key==="Escape"&&o!=="saving"&&o!=="analyzing"&&s()},[s,o]);y.useEffect(()=>(document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)),[N]),y.useEffect(()=>{let z=!1,P=null;const $=B=>{if(B.status==="ready")return c("ready"),g(B.assessment||"Ready to start"),!0;if(B.status==="questions"){const U=Array.isArray(B.questions)?B.questions:[];if(U.length===0)c("ready"),g(B.assessment||"No clarifications needed");else{c("questions"),u(U),g(B.assessment||"");const D={};U.forEach(R=>{D[R.id]=""}),p(D)}return!0}else return B.status==="analyzing"?!1:(c("error"),v(`Unexpected response status: ${B.status}`),!0)},V=async()=>{try{const B=await lb(e,r);if(z)return;!$(B)&&!z&&(P=setTimeout(V,2e3))}catch(B){if(z)return;c("error"),v(B instanceof Error?B.message:"Failed to run ready check")}};return V(),()=>{z=!0,P&&clearTimeout(P)}},[e,r,k]);const j=(z,P)=>{p($=>({...$,[z]:P}))},A=d.every(z=>{var P;return(P=h[z.id])==null?void 0:P.trim()}),M=async z=>{if(A){c("saving");try{const P=d.map($=>({question_id:$.id,answer:h[$.id]}));await cb(e,r,d,P),a(z)}catch(P){c("error"),v(P instanceof Error?P.message:"Failed to save answers")}}},_=z=>{z.target===z.currentTarget&&o!=="saving"&&o!=="analyzing"&&s()};return t.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:_,children:t.jsxs("div",{className:"bg-gray-800 rounded-lg max-w-2xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[t.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-700",children:[t.jsx("h2",{className:"text-xl font-semibold text-white",children:"Pre-Flight Ready Check"}),o!=="saving"&&o!=="analyzing"&&t.jsx("button",{onClick:s,className:"text-gray-400 hover:text-white text-2xl leading-none","aria-label":"Close modal",children:"×"})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[o==="analyzing"&&t.jsxs("div",{className:"text-center py-8",children:[t.jsx("div",{className:"animate-spin w-8 h-8 border-2 border-primary-500 border-t-transparent rounded-full mx-auto mb-4"}),t.jsx("p",{className:"text-gray-300",children:"Analyzing loop configuration..."}),t.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Claude is reviewing your resources and configuration"})]}),o==="ready"&&t.jsxs("div",{className:"text-center py-8",children:[t.jsx("div",{className:"w-16 h-16 bg-green-500/20 rounded-full flex items-center justify-center mx-auto mb-4",children:t.jsx("svg",{className:"w-8 h-8 text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),t.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"Ready to Start"}),t.jsx("p",{className:"text-gray-400",children:x})]}),o==="questions"&&t.jsxs("div",{className:"space-y-6",children:[x&&t.jsx("div",{className:"bg-gray-700/50 rounded-lg p-4 mb-4",children:t.jsx("p",{className:"text-sm text-gray-300",children:x})}),t.jsxs("p",{className:"text-gray-300",children:["Claude has ",d.length," question",d.length!==1?"s":""," before starting:"]}),d.map((z,P)=>t.jsxs("div",{className:"bg-gray-700/30 rounded-lg p-4",children:[t.jsx("div",{className:"flex items-start gap-3 mb-3",children:t.jsxs("span",{className:"bg-primary-500/20 text-primary-400 px-2 py-0.5 rounded text-sm font-medium",children:[P+1,". ",z.category]})}),t.jsxs("div",{className:"bg-gray-800 rounded p-3 mb-3",children:[t.jsx("p",{className:"text-gray-200",children:z.question}),z.context&&t.jsx("p",{className:"text-sm text-gray-500 mt-2",children:z.context})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Your answer:"}),t.jsx("textarea",{value:h[z.id]||"",onChange:$=>j(z.id,$.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..."})]})]},z.id))]}),o==="saving"&&t.jsxs("div",{className:"text-center py-8",children:[t.jsx("div",{className:"animate-spin w-8 h-8 border-2 border-primary-500 border-t-transparent rounded-full mx-auto mb-4"}),t.jsx("p",{className:"text-gray-300",children:"Saving your answers..."})]}),o==="error"&&t.jsxs("div",{className:"text-center py-8",children:[t.jsx("div",{className:"w-16 h-16 bg-red-500/20 rounded-full flex items-center justify-center mx-auto mb-4",children:t.jsx("svg",{className:"w-8 h-8 text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),t.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"Error"}),t.jsx("p",{className:"text-red-400",children:b}),t.jsxs("div",{className:"mt-4 flex justify-center gap-3",children:[t.jsx("button",{onClick:s,className:"px-4 py-2 bg-gray-700 hover:bg-gray-600 rounded text-white",children:"Close"}),t.jsx("button",{onClick:()=>{v(null),c("analyzing"),T(z=>z+1)},className:"px-4 py-2 bg-primary-600 hover:bg-primary-500 rounded text-white",children:"Retry"})]})]})]}),(o==="questions"||o==="ready")&&t.jsxs("div",{className:"px-6 py-4 border-t border-gray-700 flex justify-end gap-3",children:[o==="ready"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:s,className:"px-4 py-2 text-gray-400 hover:text-white",children:"Close"}),t.jsx("button",{onClick:()=>a(!0),className:"px-4 py-2 bg-primary-600 hover:bg-primary-500 rounded text-white",children:"Start Loop"})]}),o==="questions"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:s,className:"px-4 py-2 text-gray-400 hover:text-white",children:"Cancel"}),t.jsx("button",{onClick:()=>M(!1),disabled:!A,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"}),t.jsx("button",{onClick:()=>M(!0),disabled:!A,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 On={background:"#1f2937",text:"#f3f4f6",confirmButton:"#8b5cf6",cancelButton:"#4b5563",denyButton:"#ef4444"},Hu={background:On.background,color:On.text,confirmButtonColor:On.confirmButton,cancelButtonColor:On.cancelButton,denyButtonColor:On.denyButton},Qi=gt.mixin({toast:!0,position:"bottom-right",showConfirmButton:!1,timer:5e3,timerProgressBar:!0,...Hu,didOpen:e=>{e.onmouseenter=gt.stopTimer,e.onmouseleave=gt.resumeTimer}}),Up=gt.mixin({...Hu,showCancelButton:!0,confirmButtonText:"Confirm",cancelButtonText:"Cancel",reverseButtons:!0}),bd={success:(e,r)=>Qi.fire({icon:"success",title:r||e,text:r?e:void 0}),error:(e,r)=>Qi.fire({icon:"error",title:r||"Error",text:e}),warning:(e,r)=>Qi.fire({icon:"warning",title:r||e,text:r?e:void 0}),info:(e,r)=>Qi.fire({icon:"info",title:r||e,text:r?e:void 0}),loopComplete:(e,r,s)=>{const a={success:"success",stopped:"warning",error:"error"},o={success:"Loop Completed",stopped:"Loop Stopped",error:"Loop Error"};return Qi.fire({icon:a[s],title:o[s],text:`${e} finished at iteration ${r}`})}},qg={simple:(e,r)=>Up.fire({title:e,text:r,icon:"question"}),danger:(e,r)=>Up.fire({title:e,text:r,icon:"warning",confirmButtonColor:On.denyButton,confirmButtonText:"Delete"}),typeToDelete:async(e,r="item")=>(await gt.fire({...Hu,title:`Delete ${r}?`,html:`
|
|
180
|
+
<div style="text-align: left; color: ${On.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 ${r} 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;">${e}</code>
|
|
188
|
+
</p>
|
|
189
|
+
</div>
|
|
190
|
+
`,input:"text",inputPlaceholder:`Type ${r} name to confirm`,inputAttributes:{autocapitalize:"off",autocomplete:"off"},showCancelButton:!0,confirmButtonText:"Delete",confirmButtonColor:On.denyButton,cancelButtonText:"Cancel",reverseButtons:!0,preConfirm:a=>a!==e?(gt.showValidationMessage(`Please type "${e}" to confirm`),!1):!0})).isConfirmed},Vp={master_design:"Master Design",story_instructions:"Story Instructions",stories:"Stories (JSONL)",guardrails:"Guardrails",reference:"Reference"};function _3(){const{slug:e,loopName:r}=Vr(),s=Dr(),{selectedProject:a,setSelectedProject:o,items:c,itemsTotal:d,itemsLoading:u,setItems:h,setItemsLoading:p}=sn(),[x,g]=y.useState(null),[b,v]=y.useState(null),[k,T]=y.useState(null),[N,j]=y.useState(null),[A,M]=y.useState(!1),[_,z]=y.useState(""),[P,$]=y.useState([]),[V,B]=y.useState("overview"),[U,D]=y.useState([]),[R,X]=y.useState(!1),[I,H]=y.useState(!1),[W,J]=y.useState(""),[Z,de]=y.useState(""),[E,L]=y.useState(""),[q,S]=y.useState(!1),[G,re]=y.useState(!1),[ee,ge]=y.useState(null),[je,Le]=y.useState(!1),[ve,F]=y.useState(null),he=y.useRef(null),[ue,Oe]=y.useState(null),[Se,We]=y.useState(!1),[qe,tt]=y.useState(""),[ft,Rt]=y.useState(""),[$t,Zt]=y.useState(0),[ar,er]=y.useState([]),Et=y.useCallback(async()=>{if(!(!e||!r))try{const ce=await Qf(e,r);v(ce)}catch{v({is_running:!1})}},[e,r]),ae=y.useCallback(async(ce=!1)=>{if(!e||!r)return;p(!0);const Ae=ce?0:$t;ce&&Zt(0);try{const ie=await xa(e,{status:qe||void 0,category:ft||void 0,limit:50,offset:Ae});h(Ae===0?ie.items:[...c,...ie.items],ie.total);const Fe=new Set;ie.items.forEach(dt=>{dt.category&&Fe.add(dt.category)}),er(Ae===0?Array.from(Fe).sort():dt=>Array.from(new Set([...dt,...Fe])).sort())}catch{h([],0)}finally{p(!1)}},[e,r,h,p,qe,ft,$t,c]),Q=y.useCallback(async()=>{if(!(!e||!r||!x)){X(!0);try{const ce=await yb(e,r);D(ce);const Ae=x.type==="generator"?"planning":"implementation",ie=await Pb(e,r,Ae);F(ie)}catch{D([]),F(null)}finally{X(!1)}}},[e,r,x]),fe=y.useCallback(async ce=>{if(!(!e||!r)){S(!0),j(null);try{await vb(e,r,ce),await Q()}catch(Ae){j(Ae instanceof Error?Ae.message:"Upload failed")}finally{S(!1)}}},[e,r,Q]),be=y.useCallback(async()=>{if(!(!e||!r||!W||!Z)){re(!0),j(null);try{await wb(e,r,W,Z,E||void 0),J(""),de(""),L(""),H(!1),await Q()}catch(ce){j(ce instanceof Error?ce.message:"Import failed")}finally{re(!1)}}},[e,r,W,Z,E,Q]),Me=y.useCallback(async ce=>{if(!(!e||!r)){Le(!1),j(null);try{await Ab(e,r,ce),await Q()}catch(Ae){j(Ae instanceof Error?Ae.message:"Failed to apply template")}}},[e,r,Q]),Ve=y.useCallback(async ce=>{if(!(!e||!r)&&confirm(`Delete ${ce}?`)){ge(ce),j(null);try{await bb(e,r,ce),await Q()}catch(Ae){j(Ae instanceof Error?Ae.message:"Delete failed")}finally{ge(null)}}},[e,r,Q]);y.useEffect(()=>{if(!e||!r)return;g(null),v(null),h([],0);async function ce(){T(null);try{const[ie,Fe]=await Promise.all([ys(e),rp(e,r)]);o(ie),g(Fe),await Et()}catch(ie){T(ie instanceof Error?ie.message:"Failed to load")}}ce();const Ae=setInterval(Et,3e3);return()=>clearInterval(Ae)},[e,r,o,Et,h]),y.useEffect(()=>{if(!e||!r)return;async function ce(){try{const Ae=await np(e,r);Oe(Ae)}catch{Oe({has_qa:!1,qa_count:0,qa_summary:[]})}}ce()},[e,r]),y.useEffect(()=>{V==="items"?ae(!0):V==="inputs"&&Q()},[V,Q]),y.useEffect(()=>{V==="items"&&e&&r&&ae(!0)},[qe,ft]),y.useEffect(()=>{if(!I)return;const ce=Ae=>{Ae.key==="Escape"&&!G&&H(!1)};return document.addEventListener("keydown",ce),()=>document.removeEventListener("keydown",ce)},[I,G]);const Ye=y.useCallback(async()=>{if(!(!e||!r)){j(null);try{const[ce,Ae]=await Promise.all([rb(e,r),pu(e)]);z(ce.content),$(Ae.map(ie=>ie.name)),M(!0)}catch(ce){j(ce instanceof Error?ce.message:"Failed to load config")}}},[e,r]),Ct=y.useCallback(async ce=>{if(!e||!r)return;await nb(e,r,ce);const Ae=await rp(e,r);g(Ae),M(!1)},[e,r]),Vt=y.useCallback(async()=>{if(!e||!r||!x)return;if(b!=null&&b.is_running){bd.error("Cannot delete a running loop. Stop it first.");return}if(await qg.typeToDelete(r,"loop"))try{await tb(e,r),bd.success(`Loop "${x.display_name}" deleted`),s(`/projects/${e}`)}catch(Ae){bd.error(Ae instanceof Error?Ae.message:"Failed to delete loop")}},[e,r,x,b==null?void 0:b.is_running,s]);if(k)return t.jsx("div",{className:"p-6",children:t.jsxs("div",{className:"card bg-red-900/20 border border-red-800",children:[t.jsx("h2",{className:"text-lg font-semibold text-red-400 mb-2",children:"Error"}),t.jsx("p",{className:"text-gray-300 mb-4",children:k}),t.jsxs(Re,{to:e?`/projects/${e}`:"/",className:"btn-secondary inline-block",children:["Back to ",e?"Project":"Dashboard"]})]})});if(!x||!a)return t.jsx("div",{className:"p-6",children:t.jsx("div",{className:"text-gray-400",children:"Loading..."})});const yt=(b==null?void 0:b.is_running)||!1,rt=(b==null?void 0:b.status)==="paused";return t.jsxs("div",{className:"p-6",children:[A&&t.jsx(w3,{projectSlug:e,loopName:r,initialYaml:_,availableLoops:P,onClose:()=>M(!1),onSave:Ct}),t.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[t.jsx(Re,{to:"/",className:"hover:text-white",children:"Dashboard"}),t.jsx("span",{children:"/"}),t.jsx(Re,{to:`/projects/${e}`,className:"hover:text-white",children:a.name}),t.jsx("span",{children:"/"}),t.jsx("span",{className:"text-white",children:x.display_name})]}),t.jsxs("div",{className:"flex items-center justify-between mb-8",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-3xl font-bold text-white mb-2",children:x.display_name}),t.jsxs("p",{className:"text-gray-400",children:["Type: ",x.type]}),t.jsxs("p",{className:"text-gray-500 text-sm font-mono",children:["ID: ",x.name]})]}),t.jsxs("div",{className:"flex items-center space-x-4",children:[t.jsxs("button",{onClick:Ye,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:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{children:"Edit Config"})]}),t.jsxs("button",{onClick:Vt,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:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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.jsx("span",{children:"Delete"})]}),t.jsx(Ik,{projectSlug:e,loopName:r,isRunning:yt,isPaused:rt,onStatusChange:Et})]})]}),N&&t.jsxs("div",{className:"mb-6 p-3 bg-red-900/30 border border-red-800 rounded flex items-center justify-between",children:[t.jsx("span",{className:"text-sm text-red-400",children:N}),t.jsx("button",{onClick:()=>j(null),className:"text-red-400 hover:text-red-300",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsx("div",{className:"border-b border-gray-700 mb-6",children:t.jsx("nav",{className:"flex space-x-8",children:["overview","items","inputs","resources","runs"].map(ce=>t.jsx("button",{onClick:()=>B(ce),className:`pb-4 px-1 border-b-2 font-medium text-sm transition-colors ${V===ce?"border-primary-500 text-primary-400":"border-transparent text-gray-400 hover:text-gray-300 hover:border-gray-500"}`,children:ce.charAt(0).toUpperCase()+ce.slice(1)},ce))})}),Se&&t.jsx(S3,{projectSlug:e,loopName:r,onClose:()=>We(!1),onComplete:async ce=>{We(!1);try{const Ae=await np(e,r);Oe(Ae)}catch{}if(ce)try{await Od(e,r,{force:!0}),Et()}catch(Ae){j(Ae instanceof Error?Ae.message:"Failed to start loop")}}}),V==="overview"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"card mb-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"text-lg font-semibold text-white",children:"Pre-Flight Check"}),ue!=null&&ue.has_qa?t.jsxs("span",{className:"text-green-400 text-sm flex items-center gap-1",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Complete"]}):t.jsxs("span",{className:"text-yellow-400 text-sm flex items-center gap-1",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"]})]}),ue!=null&&ue.has_qa?t.jsxs("div",{className:"mt-3",children:[t.jsxs("p",{className:"text-sm text-gray-400 mb-2",children:[ue.qa_count," clarification",ue.qa_count!==1?"s":""," recorded",ue.last_updated&&t.jsxs(t.Fragment,{children:[" • Last updated ",wu(ue.last_updated)]})]}),ue.qa_summary.length>0&&t.jsx("ul",{className:"text-sm text-gray-500 space-y-1 mb-3",children:ue.qa_summary.map((ce,Ae)=>t.jsxs("li",{children:["• ",ce]},Ae))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>We(!0),className:"text-sm text-primary-400 hover:text-primary-300",children:"View / Edit"}),t.jsx("button",{onClick:()=>We(!0),className:"text-sm text-gray-400 hover:text-gray-300",children:"Run Again"})]})]}):t.jsxs("div",{className:"mt-3",children:[t.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."}),t.jsx("button",{onClick:()=>We(!0),className:"px-4 py-2 bg-primary-600 hover:bg-primary-500 rounded text-white text-sm",children:"Run Ready Check"})]})]}),t.jsxs("div",{className:"card mb-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{children:t.jsx("h2",{className:"text-lg font-semibold text-white",children:"Status"})}),t.jsx("div",{className:"flex items-center space-x-4",children:t.jsxs("span",{className:`flex items-center space-x-2 ${yt?rt?"text-yellow-400":"text-green-400":"text-gray-400"}`,children:[t.jsx("span",{className:`w-3 h-3 rounded-full ${yt?rt?"bg-yellow-400":"bg-green-400 animate-pulse":"bg-gray-500"}`}),t.jsx("span",{children:yt?rt?"Paused":"Running":"Stopped"})]})})]}),(b==null?void 0:b.current_iteration)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"mt-4",children:t.jsx(Dk,{value:b.current_iteration,max:100,label:`Progress: Iteration ${b.current_iteration}`,showPercent:!0,size:"md",color:yt?rt?"yellow":"green":"primary"})}),t.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm text-gray-400",children:"Iteration"}),t.jsx("div",{className:"text-xl font-semibold text-white",children:b.current_iteration})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm text-gray-400",children:"Mode"}),t.jsx("div",{className:"text-xl font-semibold text-white",children:b.current_mode||"-"})]})]})]})]}),t.jsxs("div",{className:"card mb-6",children:[t.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Modes"}),t.jsx("div",{className:"space-y-2",children:x.modes.map(ce=>t.jsxs("div",{className:`flex items-center justify-between p-3 rounded-md ${(b==null?void 0:b.current_mode)===ce.name?"bg-primary-900/30 border border-primary-600":"bg-gray-700"}`,children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-white",children:ce.name}),t.jsxs("div",{className:"text-sm text-gray-400",children:["Model: ",ce.model]})]}),t.jsxs("div",{className:"text-sm text-gray-400",children:["Timeout: ",ce.timeout,"s"]})]},ce.name))})]}),yt&&t.jsx("div",{className:"mb-6",children:t.jsx(rg,{projectSlug:e,loopName:r,enabled:yt})})]}),V==="items"&&t.jsxs("div",{className:"card",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h2",{className:"text-lg font-semibold text-white",children:"Items"}),t.jsxs("span",{className:"text-sm text-gray-400",children:[d," items"]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4 pb-4 border-b border-gray-700",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("label",{className:"text-sm text-gray-400",children:"Status:"}),t.jsxs("select",{value:qe,onChange:ce=>tt(ce.target.value),className:"px-2 py-1 bg-gray-700 border border-gray-600 rounded text-sm text-white",children:[t.jsx("option",{value:"",children:"All"}),t.jsx("option",{value:"pending",children:"Pending"}),t.jsx("option",{value:"completed",children:"Completed"}),t.jsx("option",{value:"in_progress",children:"In Progress"}),t.jsx("option",{value:"failed",children:"Failed"}),t.jsx("option",{value:"skipped",children:"Skipped"}),t.jsx("option",{value:"dup",children:"Duplicate"}),t.jsx("option",{value:"external",children:"External"})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("label",{className:"text-sm text-gray-400",children:"Category:"}),t.jsxs("select",{value:ft,onChange:ce=>Rt(ce.target.value),className:"px-2 py-1 bg-gray-700 border border-gray-600 rounded text-sm text-white",children:[t.jsx("option",{value:"",children:"All"}),ar.map(ce=>t.jsx("option",{value:ce,children:ce},ce))]})]}),(qe||ft)&&t.jsx("button",{onClick:()=>{tt(""),Rt("")},className:"text-sm text-gray-400 hover:text-white",children:"Clear filters"})]}),u&&c.length===0?t.jsx("div",{className:"text-gray-400",children:"Loading items..."}):c.length===0?t.jsx(Hd,{icon:Wd.inbox,title:"No items yet",description:qe||ft?"No items match the current filters.":"Items generated by this loop will appear here."}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"space-y-2",children:c.map(ce=>t.jsxs("div",{className:"p-3 bg-gray-700 rounded-md",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-gray-500 font-mono",children:ce.id}),t.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${ce.status==="completed"?"bg-green-900 text-green-300":ce.status==="pending"?"bg-yellow-900 text-yellow-300":ce.status==="in_progress"?"bg-blue-900 text-blue-300":ce.status==="failed"?"bg-red-900 text-red-300":"bg-gray-600 text-gray-300"}`,children:ce.status})]}),ce.category&&t.jsx("span",{className:"text-xs text-gray-400",children:ce.category})]}),t.jsx("p",{className:"text-sm text-gray-200 line-clamp-2",children:ce.content})]},ce.id))}),c.length<d&&t.jsx("div",{className:"mt-4 text-center",children:t.jsx("button",{onClick:()=>{Zt(c.length),ae(!1)},disabled:u,className:"px-4 py-2 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 disabled:opacity-50",children:u?"Loading...":`Load More (${c.length} of ${d})`})})]})]}),V==="inputs"&&t.jsxs("div",{className:"space-y-4",children:[ve&&!ve.valid&&t.jsx("div",{className:"p-4 bg-yellow-900/30 border border-yellow-700 rounded-lg",children:t.jsxs("div",{className:"flex items-start space-x-3",children:[t.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:t.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"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"font-medium text-yellow-300",children:"Missing required inputs"}),t.jsx("div",{className:"mt-2 space-y-2",children:ve.missing_tags.map(ce=>t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-yellow-400 text-sm",children:Vp[ce]||ce}),t.jsx("button",{onClick:()=>Le(!0),className:"text-xs px-2 py-1 bg-yellow-800/50 text-yellow-300 rounded hover:bg-yellow-800",children:"Add from Templates"})]},ce))}),t.jsx("p",{className:"text-xs text-yellow-500 mt-2",children:"Add required inputs or use force start to skip validation."})]})]})}),t.jsxs("div",{className:"card",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h2",{className:"text-lg font-semibold text-white",children:"Input Files"}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("button",{onClick:()=>Le(!0),className:"px-3 py-1.5 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 text-sm",children:"Browse Templates"}),t.jsx("button",{onClick:()=>H(!0),className:"px-3 py-1.5 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 text-sm",children:"Paste Content"}),t.jsx("button",{onClick:()=>{var ce;return(ce=he.current)==null?void 0:ce.click()},disabled:q,className:"px-3 py-1.5 bg-primary-600 text-white rounded hover:bg-primary-500 text-sm disabled:opacity-50",children:q?"Uploading...":"Upload File"}),t.jsx("input",{ref:he,type:"file",className:"hidden",accept:".md,.txt,.json,.jsonl",onChange:ce=>{var ie;const Ae=(ie=ce.target.files)==null?void 0:ie[0];Ae&&fe(Ae),ce.target.value=""}})]})]}),R?t.jsx("div",{className:"text-gray-400",children:"Loading..."}):U.length===0?t.jsx(Hd,{icon:Wd.document,title:"No input files",description:"Upload design documents, requirements, or other files for this loop to process.",action:{label:"Browse Templates",onClick:()=>Le(!0)}}):t.jsx("div",{className:"space-y-2",children:U.map(ce=>t.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-700 rounded-md",children:[t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-white",children:ce.name}),t.jsxs("div",{className:"text-xs text-gray-400",children:[(ce.size/1024).toFixed(1)," KB"]})]}),ce.tag&&t.jsx("span",{className:"px-2 py-0.5 text-xs bg-gray-600 text-gray-300 rounded",children:Vp[ce.tag]||ce.tag})]}),t.jsx("button",{onClick:()=>Ve(ce.name),disabled:ee===ce.name,className:"p-1 text-gray-400 hover:text-red-400 disabled:opacity-50",title:"Delete",children:ee===ce.name?t.jsxs("svg",{className:"w-5 h-5 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.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"})]}):t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})})]},ce.name))})]})]}),V==="resources"&&x&&t.jsx("div",{className:"card",children:t.jsx(C3,{projectSlug:e,loopName:r,loopType:x.type==="generator"?"planning":"implementation"})}),V==="runs"&&t.jsxs("div",{className:"card",children:[t.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Run History"}),t.jsx(Re,{to:`/projects/${e}/runs?loop=${r}`,className:"text-primary-400 hover:text-primary-300",children:"View all runs for this loop"})]}),I&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:ce=>{ce.target===ce.currentTarget&&!G&&H(!1)},children:t.jsxs("div",{className:"bg-gray-800 rounded-lg p-6 w-full max-w-lg mx-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Paste Content"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Filename"}),t.jsx("input",{type:"text",value:Z,onChange:ce=>de(ce.target.value),placeholder:"design-doc.md",className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white",disabled:G})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Tag (optional)"}),t.jsxs("select",{value:E,onChange:ce=>L(ce.target.value),className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white",disabled:G,children:[t.jsx("option",{value:"",children:"No tag"}),t.jsx("option",{value:"master_design",children:"Master Design"}),t.jsx("option",{value:"story_instructions",children:"Story Instructions"}),t.jsx("option",{value:"stories",children:"Stories (JSONL)"}),t.jsx("option",{value:"guardrails",children:"Guardrails"}),t.jsx("option",{value:"reference",children:"Reference"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Content"}),t.jsx("textarea",{value:W,onChange:ce=>J(ce.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:G})]})]}),t.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[t.jsx("button",{onClick:()=>H(!1),disabled:G,className:"px-4 py-2 text-gray-400 hover:text-white disabled:opacity-50",children:"Cancel"}),t.jsx("button",{onClick:be,disabled:!W||!Z||G,className:"px-4 py-2 bg-primary-600 text-white rounded hover:bg-primary-500 disabled:opacity-50 disabled:cursor-not-allowed",children:G?"Importing...":"Import"})]})]})}),je&&x&&t.jsx(j3,{loopType:x.type==="generator"?"planning":"implementation",onSelect:Me,onCancel:()=>Le(!1)})]})}function L3({projectSlug:e,item:r,onUpdate:s,terminology:a}){const[o,c]=y.useState(!1),[d,u]=y.useState(!1),[h,p]=y.useState(null),x=(a==null?void 0:a.singular)||r.item_type||"item",g=async v=>{u(!0),p(null);try{await xu(e,r.id,{status:v}),s()}catch(k){p(k instanceof Error?k.message:"Failed to update item")}finally{u(!1)}},b=async()=>{if(window.confirm("Are you sure you want to delete this item?")){u(!0),p(null);try{await Jf(e,r.id),s()}catch(v){p(v instanceof Error?v.message:"Failed to delete item")}finally{u(!1)}}};return t.jsxs("div",{className:"card",children:[t.jsxs("div",{className:"flex items-start justify-between mb-2",children:[t.jsxs("div",{className:"flex items-center flex-wrap gap-2",children:[t.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${vu(r.status)}`,children:yu(r.status)}),r.phase!==void 0&&t.jsxs("span",{className:"text-xs px-2 py-0.5 rounded bg-indigo-900 text-indigo-300",title:"Phase",children:["Phase ",r.phase]}),r.workflow_id&&t.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-gray-700 text-gray-300",title:"Workflow ID",children:r.workflow_id.slice(0,8)}),r.source_step_id&&t.jsxs("span",{className:"text-xs px-2 py-0.5 rounded bg-indigo-900/50 text-indigo-300",title:"Source step",children:["Step ",r.source_step_id]}),r.item_type&&r.item_type!=="item"&&t.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-primary-900 text-primary-300",title:"Item type",children:x}),r.category&&t.jsx("span",{className:"text-xs text-gray-400",children:r.category.toUpperCase()}),r.priority!==void 0&&r.priority>0&&t.jsxs("span",{className:"text-xs text-primary-400",children:["P",r.priority]}),r.dependencies&&r.dependencies.length>0&&t.jsxs("span",{className:"text-xs px-2 py-0.5 rounded bg-gray-700 text-gray-400",title:`Depends on: ${r.dependencies.join(", ")}`,children:[r.dependencies.length," dep",r.dependencies.length>1?"s":""]}),r.claimed_by&&t.jsxs("span",{className:"text-xs px-2 py-0.5 rounded bg-blue-900/50 text-blue-300",title:"Claimed by",children:["Claimed: ",r.claimed_by]}),r.duplicate_of&&t.jsxs("span",{className:"text-xs px-2 py-0.5 rounded bg-orange-900/50 text-orange-300",title:"Duplicate of",children:["Dup of: ",r.duplicate_of]})]}),t.jsx("button",{onClick:()=>c(!o),className:"text-gray-400 hover:text-white","aria-expanded":o,"aria-label":o?"Collapse item details":"Expand item details",children:t.jsx("svg",{className:`w-5 h-5 transition-transform ${o?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}),r.title&&t.jsx("h4",{className:"text-sm font-medium text-white mb-1",children:r.title}),t.jsx("p",{className:`text-sm text-gray-200 ${o?"":"line-clamp-2"}`,children:r.content}),r.skip_reason&&t.jsxs("p",{className:"text-xs text-gray-400 mt-1 italic",children:["Skip reason: ",r.skip_reason]}),o&&t.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-700",children:[r.dependencies&&r.dependencies.length>0&&t.jsxs("div",{className:"mb-4 p-3 bg-gray-700/50 rounded",children:[t.jsx("div",{className:"text-xs font-medium text-gray-400 mb-2",children:"Dependencies"}),t.jsx("div",{className:"flex flex-wrap gap-1",children:r.dependencies.map(v=>t.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-gray-600 text-gray-300",children:v},v))})]}),t.jsxs("div",{className:"text-xs text-gray-500 mb-4 space-y-1",children:[t.jsxs("div",{children:["Created: ",Wn(r.created_at)]}),t.jsxs("div",{children:["Updated: ",Wn(r.updated_at)]}),r.claimed_at&&t.jsxs("div",{children:["Claimed: ",Wn(r.claimed_at)]}),r.processed_at&&t.jsxs("div",{children:["Processed: ",Wn(r.processed_at)]}),t.jsxs("div",{children:["ID: ",r.id]}),r.workflow_id&&t.jsxs("div",{children:["Workflow: ",r.workflow_id]}),r.source_step_id!==void 0&&t.jsxs("div",{children:["Source Step: ",r.source_step_id]}),r.item_type&&t.jsxs("div",{children:["Type: ",x]}),r.phase!==void 0&&t.jsxs("div",{children:["Phase: ",r.phase]}),r.duplicate_of&&t.jsxs("div",{children:["Duplicate of: ",r.duplicate_of]}),r.skip_reason&&t.jsxs("div",{children:["Skip reason: ",r.skip_reason]})]}),h&&t.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:h}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.status!=="completed"&&t.jsx("button",{onClick:()=>g("completed"),disabled:d,className:"px-3 py-1 text-xs rounded bg-green-800 text-green-200 hover:bg-green-700 disabled:opacity-50",children:"Mark Complete"}),r.status!=="rejected"&&t.jsx("button",{onClick:()=>g("rejected"),disabled:d,className:"px-3 py-1 text-xs rounded bg-red-800 text-red-200 hover:bg-red-700 disabled:opacity-50",children:"Reject"}),r.status!=="pending"&&t.jsx("button",{onClick:()=>g("pending"),disabled:d,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"}),t.jsx("button",{onClick:b,disabled:d,className:"px-3 py-1 text-xs rounded bg-gray-700 text-gray-300 hover:bg-gray-600 disabled:opacity-50",children:"Delete"})]})]})]})}function E3({status:e,category:r,categories:s,onStatusChange:a,onCategoryChange:o}){const c=["all","pending","in_progress","completed","rejected"];return t.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Status"}),t.jsx("select",{value:e,onChange:d=>a(d.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:c.map(d=>t.jsx("option",{value:d,children:d==="all"?"All Statuses":d.replace("_"," ")},d))})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Category"}),t.jsxs("select",{value:r,onChange:d=>o(d.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:[t.jsx("option",{value:"",children:"All Categories"}),s.map(d=>t.jsx("option",{value:d,children:d},d))]})]})]})}function T3(){const{slug:e,workflowId:r}=Vr(),{selectedProject:s,setSelectedProject:a}=sn(),[o,c]=y.useState(null),[d,u]=y.useState([]),[h,p]=y.useState(0),[x,g]=y.useState(!0),[b,v]=y.useState(null),[k,T]=y.useState("all"),[N,j]=y.useState(""),[A,M]=y.useState([]),[_,z]=y.useState(0),P=20,[$,V]=y.useState(!1),[B,U]=y.useState(""),[D,R]=y.useState(""),[X,I]=y.useState(!1),H=y.useCallback(async()=>{if(!(!e||!r)){g(!0),v(null);try{const L=await xa(e,{status:k==="all"?void 0:k,category:N||void 0,workflow_id:r,limit:P,offset:_});u(L.items),p(L.total);const q=new Set;L.items.forEach(S=>{S.category&&q.add(S.category)}),M(Array.from(q).sort())}catch(L){v(L instanceof Error?L.message:"Failed to load items")}finally{g(!1)}}},[e,r,k,N,_]);y.useEffect(()=>{async function L(){if(!(!e||!r))try{const[q,S]=await Promise.all([ys(e),ga(e,r)]);a(q),c(S)}catch(q){v(q instanceof Error?q.message:"Failed to load data")}}L()},[e,r,a]),y.useEffect(()=>{H()},[H]);const W=async L=>{if(L.preventDefault(),!e||!r||!o||!B.trim())return;const q=o.steps.find(S=>S.step_number===o.current_step);if(!q){v("No active workflow step found. Cannot add items.");return}I(!0);try{await fu(e,{content:B.trim(),workflow_id:r,source_step_id:q.id,category:D.trim()||void 0}),U(""),R(""),V(!1),H()}catch(S){v(S instanceof Error?S.message:"Failed to add item")}finally{I(!1)}},J=Math.ceil(h/P),Z=Math.floor(_/P)+1,de={pending:d.filter(L=>L.status==="pending").length,in_progress:d.filter(L=>L.status==="in_progress").length,completed:d.filter(L=>L.status==="completed").length},E=h>0?Math.round(de.completed/h*100):0;return x&&!o?t.jsx("div",{className:"p-6",children:t.jsx("div",{className:"text-gray-400",children:"Loading..."})}):t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[t.jsx(Re,{to:"/",className:"hover:text-white",children:"Dashboard"}),t.jsx("span",{children:"/"}),t.jsx(Re,{to:`/projects/${e}`,className:"hover:text-white",children:(s==null?void 0:s.name)||e}),t.jsx("span",{children:"/"}),t.jsx(Re,{to:`/projects/${e}/workflows/${r}`,className:"hover:text-white",children:(o==null?void 0:o.name)||"Workflow"}),t.jsx("span",{children:"/"}),t.jsx("span",{className:"text-white",children:"Work Items"})]}),t.jsxs("div",{className:"flex items-center justify-between mb-6",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-3xl font-bold text-white mb-1",children:"Work Items"}),t.jsxs("p",{className:"text-gray-400",children:[h," item",h!==1?"s":""," in this workflow"]})]}),t.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:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),t.jsx("span",{children:"Add Item"})]})]}),t.jsxs("div",{className:"card mb-6",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("div",{className:"flex items-center space-x-6 text-sm",children:[t.jsxs("span",{className:"text-gray-400",children:[h," total"]}),t.jsx("span",{className:"text-gray-600",children:"|"}),t.jsxs("span",{className:"text-green-400",children:[de.completed," completed"]}),t.jsx("span",{className:"text-gray-600",children:"|"}),t.jsxs("span",{className:"text-yellow-400",children:[de.in_progress," in progress"]}),t.jsx("span",{className:"text-gray-600",children:"|"}),t.jsxs("span",{className:"text-gray-400",children:[de.pending," pending"]})]}),t.jsxs("span",{className:"text-sm text-gray-400",children:[E,"%"]})]}),t.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2",children:t.jsx("div",{className:"bg-green-500 h-2 rounded-full transition-all duration-300",style:{width:`${E}%`}})})]}),$&&t.jsxs("div",{className:"card mb-6",children:[t.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Add New Item"}),t.jsxs("form",{onSubmit:W,className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"new-content",className:"block text-sm font-medium text-gray-300 mb-1",children:"Content"}),t.jsx("textarea",{id:"new-content",value:B,onChange:L=>U(L.target.value),placeholder:"Item content...",rows:3,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white placeholder-gray-400 focus:outline-none focus:border-primary-500"})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"new-category",className:"block text-sm font-medium text-gray-300 mb-1",children:"Category (optional)"}),t.jsx("input",{id:"new-category",type:"text",value:D,onChange:L=>R(L.target.value),placeholder:"e.g., FND, API, UI",className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white placeholder-gray-400 focus:outline-none focus:border-primary-500"})]}),t.jsxs("div",{className:"flex justify-end space-x-3",children:[t.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"}),t.jsx("button",{type:"submit",disabled:X||!B.trim(),className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500 disabled:opacity-50",children:X?"Adding...":"Add Item"})]})]})]}),t.jsx("div",{className:"mb-4",children:t.jsx(E3,{status:k,category:N,categories:A,onStatusChange:L=>{T(L),z(0)},onCategoryChange:L=>{j(L),z(0)}})}),b&&t.jsx("div",{className:"mb-4 p-3 bg-red-900/30 border border-red-800 rounded text-red-400",role:"alert",children:b}),x?t.jsx("div",{className:"text-gray-400","aria-live":"polite",children:"Loading items..."}):d.length===0?t.jsxs("div",{className:"card text-center py-8",children:[t.jsx("p",{className:"text-gray-400",children:"No items found"}),(k!=="all"||N)&&t.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Try changing your filters"})]}):t.jsx("div",{className:"space-y-3",children:d.map(L=>t.jsx(L3,{projectSlug:e,item:L,onUpdate:H},L.id))}),J>1&&t.jsxs("nav",{className:"mt-6 flex items-center justify-between","aria-label":"Pagination",children:[t.jsxs("div",{className:"text-sm text-gray-400",children:["Showing ",_+1,"-",Math.min(_+P,h)," of ",h]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("button",{onClick:()=>z(Math.max(0,_-P)),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"}),t.jsxs("span",{className:"text-sm text-gray-400","aria-current":"page",children:["Page ",Z," of ",J]}),t.jsx("button",{onClick:()=>z(_+P),disabled:_+P>=h,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 A3(){const{slug:e,workflowId:r}=Vr(),{selectedProject:s,setSelectedProject:a}=sn(),[o,c]=y.useState(null),[d,u]=y.useState([]),[h,p]=y.useState([]),[x,g]=y.useState(!0),[b,v]=y.useState(null),[k,T]=y.useState("all"),[N,j]=y.useState(!1),[A,M]=y.useState(!1),[_,z]=y.useState({name:"",resource_type:"guardrail",content:""}),[P,$]=y.useState(!1),[V,B]=y.useState(null),[U,D]=y.useState(""),[R,X]=y.useState(!1),I=y.useCallback(async()=>{if(!(!e||!r)){g(!0),v(null);try{const[G,re,ee,ge]=await Promise.all([ys(e),ga(e,r),hl(e,r),gu(e)]);a(G),c(re),u(ee),p(ge)}catch(G){v(G instanceof Error?G.message:"Failed to load resources")}finally{g(!1)}}},[e,r,a]);y.useEffect(()=>{I()},[I]);const H=k==="all"?d:d.filter(G=>G.resource_type===k),W=async G=>{if(G.preventDefault(),!(!e||!r||!_.name.trim()||!_.content.trim())){$(!0);try{await Yo(e,r,{name:_.name.trim(),resource_type:_.resource_type,content:_.content.trim(),source:"manual"}),z({name:"",resource_type:"guardrail",content:""}),j(!1),I()}catch(re){v(re instanceof Error?re.message:"Failed to add resource")}finally{$(!1)}}},J=async G=>{if(!(!e||!r))try{await ax(e,r,G.id),M(!1),I()}catch(re){v(re instanceof Error?re.message:"Failed to import resource")}},Z=async()=>{if(!(!e||!r||!V)){X(!0);try{await da(e,r,V.id,{content:U}),B(null),I()}catch(G){v(G instanceof Error?G.message:"Failed to save resource")}finally{X(!1)}}},de=async G=>{if(!(!e||!r))try{await da(e,r,G.id,{enabled:!G.enabled}),I()}catch(re){v(re instanceof Error?re.message:"Failed to update resource")}},E=async G=>{if(!(!e||!r)&&confirm(`Delete "${G.name}"? This cannot be undone.`))try{await ix(e,r,G.id),I()}catch(re){v(re instanceof Error?re.message:"Failed to delete resource")}},L=G=>{switch(G){case"design_doc":return"Design Document";case"guardrail":return"Guardrail";case"input_file":return"Input File";case"prompt":return"Prompt";default:return G}},q=G=>{switch(G){case"design_doc":return t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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 t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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 t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}},S=[{key:"all",label:"All"},{key:"design_doc",label:"Design Doc"},{key:"guardrail",label:"Guardrails"},{key:"input_file",label:"Input Files"}];return x?t.jsx("div",{className:"p-6",children:t.jsx("div",{className:"text-gray-400",children:"Loading resources..."})}):t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[t.jsx(Re,{to:"/",className:"hover:text-white",children:"Dashboard"}),t.jsx("span",{children:"/"}),t.jsx(Re,{to:`/projects/${e}`,className:"hover:text-white",children:(s==null?void 0:s.name)||e}),t.jsx("span",{children:"/"}),t.jsx(Re,{to:`/projects/${e}/workflows/${r}`,className:"hover:text-white",children:(o==null?void 0:o.name)||"Workflow"}),t.jsx("span",{children:"/"}),t.jsx("span",{className:"text-white",children:"Resources"})]}),t.jsxs("div",{className:"flex items-center justify-between mb-6",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-3xl font-bold text-white mb-1",children:"Resources"}),t.jsxs("p",{className:"text-gray-400",children:[d.length," resource",d.length!==1?"s":""," for this workflow"]})]}),t.jsxs("div",{className:"flex space-x-3",children:[t.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:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{children:"Import from Library"})]}),t.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:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),t.jsx("span",{children:"Add Resource"})]})]})]}),b&&t.jsx("div",{className:"mb-4 p-3 bg-red-900/30 border border-red-800 rounded text-red-400",children:b}),t.jsx("div",{className:"flex space-x-1 mb-6 border-b border-gray-700",children:S.map(G=>t.jsx("button",{onClick:()=>T(G.key),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${k===G.key?"border-primary-500 text-white":"border-transparent text-gray-400 hover:text-gray-300"}`,children:G.label},G.key))}),H.length===0?t.jsxs("div",{className:"card text-center py-8",children:[t.jsx("p",{className:"text-gray-400",children:"No resources found"}),t.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Add resources to provide context for Claude during execution."})]}):t.jsx("div",{className:"space-y-3",children:H.map(G=>t.jsxs("div",{className:"card flex items-start justify-between",children:[t.jsxs("div",{className:"flex items-start space-x-4",children:[t.jsx("div",{className:`p-2 rounded ${G.enabled?"bg-primary-500/20 text-primary-400":"bg-gray-700 text-gray-500"}`,children:q(G.resource_type)}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-medium text-white",children:G.name}),t.jsxs("div",{className:"flex items-center space-x-4 text-sm text-gray-400 mt-1",children:[t.jsx("span",{children:L(G.resource_type)}),G.source&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-gray-600",children:"|"}),t.jsxs("span",{children:["Source: ",G.source]})]})]}),G.content&&t.jsxs("p",{className:"text-sm text-gray-500 mt-2 line-clamp-2",children:[G.content.slice(0,200),G.content.length>200&&"..."]})]})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("button",{onClick:()=>de(G),className:`px-3 py-1 text-sm rounded ${G.enabled?"bg-green-600/20 text-green-400":"bg-gray-700 text-gray-500"}`,children:G.enabled?"Enabled":"Disabled"}),t.jsx("button",{onClick:()=>{B(G),D(G.content||"")},className:"px-3 py-1 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600",children:"View"}),t.jsx("button",{onClick:()=>E(G),className:"px-3 py-1 text-sm rounded bg-red-900/30 text-red-400 hover:bg-red-900/50",children:"Delete"})]})]},G.id))}),t.jsx("div",{className:"mt-8 p-4 bg-gray-800/50 border border-gray-700 rounded",children:t.jsxs("div",{className:"flex items-start space-x-3",children:[t.jsx("svg",{className:"w-5 h-5 text-yellow-500 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsxs("div",{className:"text-sm text-gray-400",children:[t.jsx("p",{className:"font-medium text-gray-300 mb-1",children:"About Workflow Resources"}),t.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&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-gray-800 rounded-lg p-6 w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[t.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"Add Resource"}),t.jsxs("form",{onSubmit:W,className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Resource Type"}),t.jsxs("select",{value:_.resource_type,onChange:G=>z({..._,resource_type:G.target.value}),className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white",children:[t.jsx("option",{value:"guardrail",children:"Guardrail"}),t.jsx("option",{value:"design_doc",children:"Design Document"}),t.jsx("option",{value:"input_file",children:"Input File"}),t.jsx("option",{value:"prompt",children:"Prompt"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Name"}),t.jsx("input",{type:"text",value:_.name,onChange:G=>z({..._,name:G.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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Content"}),t.jsx("textarea",{value:_.content,onChange:G=>z({..._,content:G.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"})]}),t.jsxs("div",{className:"flex justify-end space-x-3",children:[t.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"}),t.jsx("button",{type:"submit",disabled:P||!_.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:P?"Adding...":"Add Resource"})]})]})]})}),A&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-gray-800 rounded-lg p-6 w-full max-w-lg",children:[t.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"Import from Project Library"}),t.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."}),h.length===0?t.jsxs("div",{className:"text-center py-8",children:[t.jsx("p",{className:"text-gray-400",children:"No shared resources in project library"}),t.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Add resources to the project library in Project Settings."})]}):t.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:h.map(G=>t.jsx("button",{onClick:()=>J(G),className:"w-full p-3 bg-gray-700 rounded hover:bg-gray-600 text-left",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-white font-medium",children:G.name}),t.jsx("p",{className:"text-sm text-gray-400",children:L(G.resource_type)})]}),G.auto_inherit&&t.jsx("span",{className:"text-xs bg-primary-500/20 text-primary-400 px-2 py-1 rounded",children:"Auto-inherit"})]})},G.id))}),t.jsx("div",{className:"flex justify-end mt-4",children:t.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&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-gray-800 rounded-lg p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h2",{className:"text-xl font-bold text-white",children:V.name}),t.jsx("span",{className:"text-sm bg-gray-700 text-gray-400 px-2 py-1 rounded",children:L(V.resource_type)})]}),t.jsx("textarea",{value:U,onChange:G=>D(G.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"}),t.jsxs("div",{className:"flex justify-end space-x-3 mt-4",children:[t.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"}),t.jsx("button",{onClick:Z,disabled:R,className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500 disabled:opacity-50",children:R?"Saving...":"Save Changes"})]})]})})]})}function P3({workflowName:e,onBack:r,onSave:s,saving:a,dirty:o}){return t.jsx("div",{className:"sticky top-0 z-10 bg-gray-900 border-b border-gray-700",children:t.jsxs("div",{className:"flex items-center justify-between px-6 py-4",children:[t.jsxs("div",{className:"flex items-center space-x-4",children:[t.jsxs("button",{onClick:r,className:"flex items-center space-x-2 text-gray-400 hover:text-white transition-colors",children:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 19l-7-7m0 0l7-7m-7 7h18"})}),t.jsx("span",{children:"Back to Workflow"})]}),t.jsx("div",{className:"h-6 w-px bg-gray-700"}),t.jsx("h1",{className:"text-xl font-semibold text-white truncate max-w-md",children:e||"Untitled Workflow"}),o&&t.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"})]}),t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsxs("span",{className:"text-xs text-gray-500",children:[navigator.platform.includes("Mac")?"⌘":"Ctrl","+S to save"]}),t.jsx("button",{onClick:s,disabled:a||!o,className:`flex items-center space-x-2 px-4 py-2 rounded-lg font-medium transition-colors ${o?"bg-primary-600 text-white hover:bg-primary-500":"bg-gray-700 text-gray-400 cursor-not-allowed"} disabled:opacity-50`,children:a?t.jsxs(t.Fragment,{children:[t.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.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"})]}),t.jsx("span",{children:"Saving..."})]}):t.jsxs(t.Fragment,{children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),t.jsx("span",{children:"Save Changes"})]})})]})]})})}function Do(e){return e?Math.ceil(e.length/4):0}function I3(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Bo(e){return e<1e3?`${e}`:`${(e/1e3).toFixed(1)}k`}const qp={design_doc:{label:"Design Doc",color:"text-purple-400 bg-purple-500/10 border-purple-500/30",icon:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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 M3({workflow:e,workflowName:r,onNameChange:s,steps:a,resources:o,onViewResources:c}){var k;const[d,u]=y.useState(null);y.useEffect(()=>{if(!d)return;const T=N=>{N.key==="Escape"&&u(null)};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[d]);const h=o.reduce((T,N)=>{var j;return T+(((j=N.content)==null?void 0:j.length)??0)},0),p=o.reduce((T,N)=>T+Do(N.content),0),x=o.filter(T=>T.enabled),g=o.reduce((T,N)=>(T[N.resource_type]||(T[N.resource_type]=[]),T[N.resource_type].push(N),T),{}),b=Math.min(p/2e5*100,100),v=o.some(T=>T.resource_type==="design_doc"&&T.enabled);return t.jsxs("div",{className:"max-w-3xl space-y-6",children:[t.jsxs("div",{className:"card",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Workflow Name"}),t.jsx("input",{type:"text",value:r,onChange:T=>s(T.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"}),t.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"Give your workflow a clear, descriptive name that reflects its purpose."})]}),t.jsxs("div",{className:"card",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Resources"}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("span",{className:"text-xs text-gray-500",children:[x.length," of ",o.length," enabled"]}),c&&t.jsx("button",{onClick:c,className:"text-xs text-primary-400 hover:text-primary-300",children:"Manage →"})]})]}),o.length===0?t.jsxs("div",{className:"text-center py-6",children:[t.jsx("svg",{className:"w-10 h-10 mx-auto text-gray-600 mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("p",{className:"text-sm text-gray-500",children:"No resources attached"}),c?t.jsx("button",{onClick:c,className:"text-xs text-primary-400 hover:text-primary-300 mt-2",children:"+ Add resources"}):t.jsx("p",{className:"text-xs text-gray-600 mt-1",children:"Add resources in the Resources tab"})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mb-4",children:[t.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-400 mb-1",children:[t.jsx("span",{children:"Context Usage"}),t.jsxs("span",{children:[Bo(p)," tokens (",I3(h),")"]})]}),t.jsx("div",{className:"h-2 bg-gray-700 rounded-full overflow-hidden",children:t.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)}%`}})}),t.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500 mt-1",children:[t.jsxs("span",{children:[b.toFixed(1),"% of ~200k context"]}),b>50&&t.jsx("span",{className:"text-amber-400",children:"Consider trimming resources"})]})]}),t.jsx("div",{className:"space-y-3",children:Object.entries(g).map(([T,N])=>{const j=qp[T]||{label:T,color:"text-gray-400 bg-gray-500/10 border-gray-500/30",icon:t.jsx("span",{className:"w-4 h-4",children:"📄"})},A=N.reduce((M,_)=>M+Do(_.content),0);return t.jsxs("div",{className:"rounded-lg bg-gray-800/50 border border-gray-700 p-3",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`p-1.5 rounded border ${j.color}`,children:j.icon}),t.jsx("span",{className:"text-sm font-medium text-gray-300",children:j.label}),t.jsxs("span",{className:"text-xs text-gray-500",children:["(",N.length,")"]})]}),t.jsxs("span",{className:"text-xs text-gray-500",children:["~",Bo(A)," tokens"]})]}),t.jsx("div",{className:"space-y-1",children:N.map(M=>{const _=Do(M.content);return t.jsxs("button",{onClick:()=>u(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:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[!M.enabled&&t.jsx("span",{className:"text-gray-600",title:"Disabled",children:"●"}),t.jsx("span",{className:"truncate text-left",children:M.name})]}),t.jsxs("span",{className:"text-gray-500 flex-shrink-0 ml-2",children:[Bo(_)," tok"]})]},M.id)})})]},T)})})]})]}),t.jsxs("div",{className:"card",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-3",children:"Step Progress"}),a.length===0?t.jsx("p",{className:"text-sm text-gray-500",children:"No steps configured"}):t.jsx("div",{className:"space-y-2",children:a.map(T=>{const N=T.iterations_target!=null,j=T.iterations_completed??0,A=T.iterations_target??0,M=N&&A>0?Math.min(j/A*100,100):0,_=T.has_active_run;return t.jsxs("div",{className:"rounded-lg bg-gray-800/50 border border-gray-700 p-3",children:[t.jsx("div",{className:"flex items-center justify-between mb-1",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"text-xs text-gray-500",children:[T.step_number,"."]}),t.jsx("span",{className:"text-sm text-gray-300",children:T.name}),t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${T.step_type==="autonomous"?"bg-blue-500/20 text-blue-400":"bg-purple-500/20 text-purple-400"}`,children:T.step_type==="autonomous"?"Auto":"Chat"}),_&&t.jsxs("span",{className:"flex items-center gap-1 text-xs text-emerald-400",children:[t.jsx("span",{className:"w-1.5 h-1.5 bg-emerald-400 rounded-full animate-pulse"}),"Running"]})]})}),t.jsx("div",{className:"flex items-center gap-2 text-xs",children:N?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex-1 h-1.5 bg-gray-700 rounded-full overflow-hidden",children:t.jsx("div",{className:`h-full transition-all ${M>=100?"bg-emerald-500":"bg-blue-500"}`,style:{width:`${M}%`}})}),t.jsxs("span",{className:"text-gray-400",children:[j," / ",A]})]}):t.jsx("span",{className:"text-gray-500",children:j>0?`${j} cycles completed`:"Not started"})})]},T.id)})})]}),t.jsxs("div",{className:"card",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-3",children:"Configuration"}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[v?t.jsx("svg",{className:"w-5 h-5 text-emerald-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}):t.jsx("svg",{className:"w-5 h-5 text-amber-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{className:"text-gray-300",children:"Design Document"})]}),t.jsx("span",{className:`text-sm ${v?"text-emerald-400":"text-amber-400"}`,children:v?"Added":"Missing"})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[a.length>0?t.jsx("svg",{className:"w-5 h-5 text-emerald-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}):t.jsx("svg",{className:"w-5 h-5 text-amber-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{className:"text-gray-300",children:"Steps"})]}),t.jsx("span",{className:`text-sm ${a.length>0?"text-emerald-400":"text-amber-400"}`,children:a.length>0?`${a.length} configured`:"None"})]})]})]}),t.jsxs("div",{className:"rounded-lg bg-gray-800/50 border border-gray-700 p-4",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-2",children:"Getting Started"}),t.jsxs("ul",{className:"text-sm text-gray-400 space-y-2",children:[t.jsxs("li",{className:"flex items-start space-x-2",children:[t.jsx("span",{className:"text-primary-400",children:"1."}),t.jsxs("span",{children:["Add a ",t.jsx("strong",{children:"Design Document"})," in the Resources tab to guide Claude's work"]})]}),t.jsxs("li",{className:"flex items-start space-x-2",children:[t.jsx("span",{className:"text-primary-400",children:"2."}),t.jsxs("span",{children:["Configure your ",t.jsx("strong",{children:"Steps"})," - use Chat steps for planning and Automated steps for execution"]})]}),t.jsxs("li",{className:"flex items-start space-x-2",children:[t.jsx("span",{className:"text-primary-400",children:"3."}),t.jsxs("span",{children:["Add ",t.jsx("strong",{children:"Guidelines"})," to set boundaries and coding standards"]})]}),t.jsxs("li",{className:"flex items-start space-x-2",children:[t.jsx("span",{className:"text-primary-400",children:"4."}),t.jsx("span",{children:"Save your changes and return to the workflow to start execution"})]})]})]}),d&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:T=>{T.target===T.currentTarget&&u(null)},children:t.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:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-white",children:d.name}),t.jsxs("p",{className:"text-xs text-gray-400 mt-0.5",children:[((k=qp[d.resource_type])==null?void 0:k.label)||d.resource_type," • ",Bo(Do(d.content))," tokens",!d.enabled&&" • Disabled"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[c&&t.jsx("button",{onClick:()=>{u(null),c()},className:"px-3 py-1.5 text-sm bg-gray-700 text-gray-300 rounded-lg hover:bg-gray-600",children:"Edit"}),t.jsx("button",{onClick:()=>u(null),className:"p-1.5 text-gray-400 hover:text-white rounded-lg hover:bg-gray-700",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto p-4",children:d.content?t.jsx("pre",{className:"text-sm text-gray-300 whitespace-pre-wrap font-mono leading-relaxed",children:d.content}):t.jsx("p",{className:"text-gray-500 text-center py-8",children:"No content"})})]})})]})}function R3({steps:e,selectedIndex:r,onSelect:s,onAdd:a,onMove:o}){const c=h=>h==="interactive"?"Chat":"Automated",d=h=>h==="interactive"?"bg-violet-900/50 text-violet-400 border-violet-700/50":"bg-emerald-900/50 text-emerald-400 border-emerald-700/50",u=h=>{switch(h){case"completed":return t.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400",title:"Completed"});case"active":return t.jsx("span",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse",title:"Active"});case"pending":default:return t.jsx("span",{className:"w-2 h-2 rounded-full bg-gray-500",title:"Pending"})}};return t.jsxs("div",{className:"flex flex-col h-full",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-300 uppercase tracking-wide",children:"Steps"}),t.jsx("button",{onClick:a,className:"p-1.5 rounded-lg bg-primary-600/20 text-primary-400 hover:bg-primary-600/30 transition-colors",title:"Add Step",children:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2",children:[e.map((h,p)=>{var x;return t.jsxs("div",{onClick:()=>s(p),className:`group relative p-3 rounded-lg border cursor-pointer transition-all ${r===p?"bg-primary-900/30 border-primary-600":"bg-gray-800 border-gray-700 hover:border-gray-600"}`,children:[t.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:t.jsx("span",{className:"text-xs font-medium text-gray-300",children:p+1})}),t.jsxs("div",{className:"ml-2",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[u(h.status),t.jsx("span",{className:"font-medium text-white truncate flex-1",children:h.name||"Untitled Step"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded border ${d(h.step_type)}`,children:c(h.step_type)}),((x=h.config)==null?void 0:x.model)&&h.step_type==="autonomous"&&t.jsx("span",{className:"text-xs text-gray-500",children:h.config.model})]})]}),e.length>1&&t.jsxs("div",{className:`absolute right-2 top-1/2 -translate-y-1/2 flex flex-col ${r===p?"opacity-100":"opacity-0 group-hover:opacity-100"} transition-opacity`,children:[t.jsx("button",{onClick:g=>{g.stopPropagation(),o(p,"up")},disabled:p===0,className:"p-0.5 text-gray-500 hover:text-white disabled:opacity-20 disabled:cursor-not-allowed",title:"Move up",children:t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),t.jsx("button",{onClick:g=>{g.stopPropagation(),o(p,"down")},disabled:p===e.length-1,className:"p-0.5 text-gray-500 hover:text-white disabled:opacity-20 disabled:cursor-not-allowed",title:"Move down",children:t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})]},h.id||`new-${p}`)}),e.length===0&&t.jsx("div",{className:"text-center py-8 text-gray-500 text-sm",children:"No steps yet"})]}),t.jsxs("button",{onClick:a,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:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),t.jsx("span",{className:"text-sm",children:"Add Step"})]})]})}function Yg({isOpen:e,title:r,message:s,details:a,confirmLabel:o="Confirm",cancelLabel:c="Cancel",variant:d="default",typeToConfirm:u,onConfirm:h,onCancel:p}){const x=y.useRef(null),g=y.useRef(null),[b,v]=y.useState("");y.useEffect(()=>{e&&v("")},[e]),y.useEffect(()=>{e&&(u&&g.current?g.current.focus():x.current&&x.current.focus())},[e,u]);const k=!u||b===u;if(y.useEffect(()=>{if(!e)return;const N=j=>{j.key==="Escape"&&p()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e,p]),!e)return null;const T=d==="danger";return t.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&&p()},children:t.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:[t.jsxs("div",{className:"flex items-start gap-4 p-6 pb-4",children:[T?t.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:t.jsx("svg",{className:"w-5 h-5 text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}):t.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-primary-500/20 flex items-center justify-center",children:t.jsx("svg",{className:"w-5 h-5 text-primary-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h3",{className:"text-lg font-semibold text-white",children:r}),t.jsx("p",{className:"mt-1 text-sm text-gray-400",children:s})]})]}),a&&t.jsx("div",{className:"px-6 pb-4",children:t.jsx("div",{className:`p-3 rounded-lg text-sm ${T?"bg-red-900/20 border border-red-800/50 text-red-300":"bg-gray-700 text-gray-300"}`,children:a})}),u&&t.jsxs("div",{className:"px-6 pb-4",children:[t.jsxs("label",{className:"block text-sm text-gray-400 mb-2",children:["Type ",t.jsx("span",{className:"font-mono font-semibold text-white bg-gray-700 px-1.5 py-0.5 rounded",children:u})," to confirm"]}),t.jsx("input",{ref:g,type:"text",value:b,onChange:N=>v(N.target.value),onKeyDown:N=>{N.key==="Enter"&&k&&h()},placeholder:u,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})]}),t.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:[t.jsx("button",{onClick:p,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:c}),t.jsx("button",{ref:x,onClick:h,disabled:!k,className:`px-4 py-2 text-sm font-medium rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${T?"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:o})]})]})})}const $3={generator:["{{existing_stories}}"],consumer:["{{input_item.title}}","{{input_item.content}}"]},D3={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 B3(e,r,s){const a={isValid:!0,missingRequired:[],missingOptional:[],warnings:[]};if(!e||!e.trim())return a;let o,c;s&&s.length>0?(o=s.filter(d=>d.required).map(d=>d.name),c=s.map(d=>d.name)):(o=$3[r]||[],c=D3[r]||[]);for(const d of o)e.includes(d)||(a.missingRequired.push(d),a.isValid=!1);for(const d of c)!o.includes(d)&&!e.includes(d)&&a.missingOptional.push(d);return a.missingRequired.length>0&&a.warnings.push(`Missing required template variable${a.missingRequired.length>1?"s":""}: ${a.missingRequired.join(", ")}. The step may not work correctly.`),a.missingOptional.length>0&&a.missingOptional.length<=2&&a.warnings.push(`Optional variable${a.missingOptional.length>1?"s":""} not used: ${a.missingOptional.join(", ")}`),a}function z3(e,r){if(!e||!e.trim())return!1;const s=e.trim().replace(/\s+/g," "),a=r.trim().replace(/\s+/g," ");return s!==a}const na={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","Edit","Write"],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}}},O3=[{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"}],Vs={max_iterations:100,cooldown_between_iterations:5,max_consecutive_errors:5};function F3(e){var a,o;const r=(a=e.config)==null?void 0:a.loopType,s=(o=e.config)==null?void 0:o.template;return r==="design_doc"||e.step_type==="interactive"?"design_doc":s==="webgen_requirements"?"webgen_requirements":s==="extractgen_requirements"||s==="research"||r==="generator"||r==="planning"?"extractgen_requirements":"implementation"}function W3(e,r){const s=na[r],a=s.defaults,o=e.config||{},c=[];if(o.model&&o.model!==a.model&&c.push(`AI Model (${o.model})`),o.timeout&&o.timeout!==a.timeout&&c.push(`Timeout (${o.timeout}s)`),o.max_iterations!==void 0&&o.max_iterations!==a.max_iterations&&c.push(`Max Iterations (${o.max_iterations})`),o.cooldown_between_iterations!==void 0&&o.cooldown_between_iterations!==a.cooldown_between_iterations&&c.push(`Cooldown (${o.cooldown_between_iterations}s)`),o.max_consecutive_errors!==void 0&&o.max_consecutive_errors!==a.max_consecutive_errors&&c.push(`Max Errors (${o.max_consecutive_errors})`),o.customPrompt&&c.push("Custom AI Instructions"),o.context_from_steps&&o.context_from_steps.length>0&&c.push(`Context from Steps (${o.context_from_steps.length} selected)`),o.allowedTools!==void 0){const d=[...s.defaultTools].sort(),u=[...o.allowedTools].sort();JSON.stringify(u)!==JSON.stringify(d)&&c.push("Tool Selection")}return c}function H3({step:e,projectSlug:r,allSteps:s,onChange:a}){var ar,er,Et,ae,Q,fe,be,Me,Ve,Ye,Ct,Vt,yt,rt,ce,Ae;const o=F3(e),c=na[o],u=(e.iterations_completed||0)>0||(e.items_generated||0)>0,[h,p]=y.useState([]),[x,g]=y.useState(!1),[b,v]=y.useState(!1),[k,T]=y.useState(""),[N,j]=y.useState(!1),[A,M]=y.useState(!1),[_,z]=y.useState(""),[P,$]=y.useState([]),[V,B]=y.useState(!1),[U,D]=y.useState(null),[R,X]=y.useState(!1),[I,H]=y.useState(!1),[W,J]=y.useState(!1),[Z,de]=y.useState(null),[E,L]=y.useState([]),q=!!((ar=e.config)!=null&&ar.customPrompt),S=((er=e.config)==null?void 0:er.customPrompt)||_,G=((Et=e.config)==null?void 0:Et.loopType)||"consumer",re=q?B3(((ae=e.config)==null?void 0:ae.customPrompt)||"",G,P):{isValid:!0,warnings:[]},ee=e.status==="active"&&e.has_active_run,ge=!ee,je=y.useCallback(async()=>{if(e.step_type==="autonomous"&&o!=="design_doc"){B(!0),D(null);try{const ie=await pb(G);z(ie.prompt),$(ie.variables)}catch(ie){D("Failed to load default prompt"),console.error("Error fetching default prompt:",ie)}finally{B(!1)}}},[e.step_type,o,G]);y.useEffect(()=>{je()},[je]);const Le=y.useCallback(async()=>{if(o==="design_doc"){g(!0);try{const ie=await Xf(r);p(ie)}catch(ie){console.error("Failed to load design doc files:",ie)}finally{g(!1)}}},[r,o]);y.useEffect(()=>{Le()},[Le]);const ve=async()=>{if(!(!k.trim()||N)){j(!0);try{const ie=await Cb(r,k.trim());F({design_doc_path:ie.name}),v(!1),T(""),await Le()}catch(ie){console.error("Failed to create file:",ie)}finally{j(!1)}}},F=y.useCallback(ie=>{a({...e,config:{...e.config,...ie}})},[a,e]);y.useEffect(()=>{var ie;(ie=e.config)!=null&&ie.customPrompt&&o==="design_doc"&&F({customPrompt:void 0})},[o,(Q=e.config)==null?void 0:Q.customPrompt,F]);const he=ie=>{var vr,or,an;const Fe=na[ie],dt=mt=>mt==="extractgen_requirements"||mt==="webgen_requirements",Ke=dt(o)&&dt(ie);a({...e,step_type:Fe.step_type,config:{description:(vr=e.config)==null?void 0:vr.description,skippable:(or=e.config)==null?void 0:or.skippable,loopType:Fe.loopType,template:Fe.template,allowedTools:Fe.defaultTools,model:Fe.defaults.model,timeout:Fe.defaults.timeout,max_iterations:Fe.defaults.max_iterations,cooldown_between_iterations:Fe.defaults.cooldown_between_iterations,max_consecutive_errors:Fe.defaults.max_consecutive_errors,customPrompt:void 0,context_from_steps:Ke?(an=e.config)==null?void 0:an.context_from_steps:void 0}})},ue=ie=>{if(u||ie===o)return;const Fe=W3(e,o);Fe.length>0?(L(Fe),de(ie),J(!0)):he(ie)},Oe=()=>{Z&&he(Z),J(!1),de(null),L([])},Se=()=>{J(!1),de(null),L([])},We=ie=>{var Ke;const Fe=((Ke=e.config)==null?void 0:Ke.allowedTools)||[],dt=Fe.includes(ie)?Fe.filter(vr=>vr!==ie):[...Fe,ie];F({allowedTools:dt})},qe=()=>{F({allowedTools:c.defaultTools})},tt=ie=>{ge&&(z3(ie,_)?F({customPrompt:ie}):F({customPrompt:void 0}))},ft=ie=>{ge&&(ie?F({customPrompt:_}):H(!0))},Rt=()=>{F({customPrompt:void 0}),H(!1)},$t=ie=>c.defaultTools.includes(ie),Zt=ie=>{switch(ie){case"chat":return t.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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 t.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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 t.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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 t.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})})}};return t.jsxs("div",{className:"space-y-6 max-w-2xl",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Step Name"}),t.jsx("input",{type:"text",value:e.name,onChange:ie=>a({...e,name:ie.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"})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300",children:"What should this step do?"}),u&&t.jsxs("span",{className:"text-xs text-amber-400 flex items-center gap-1",children:[t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"]})]}),t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:Object.entries(na).map(([ie,Fe])=>t.jsxs("button",{type:"button",onClick:()=>ue(ie),disabled:u,className:`p-4 rounded-lg border text-left transition-colors ${u?o===ie?"bg-gray-800/50 border-gray-600 cursor-not-allowed":"bg-gray-800/30 border-gray-700/50 cursor-not-allowed opacity-50":o===ie?ie==="design_doc"?"bg-violet-900/30 border-violet-600":ie==="extractgen_requirements"?"bg-blue-900/30 border-blue-600":ie==="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:[t.jsx("div",{className:`flex items-center gap-2 mb-2 ${u?"text-gray-500":o===ie?ie==="design_doc"?"text-violet-400":ie==="extractgen_requirements"?"text-blue-400":ie==="webgen_requirements"?"text-cyan-400":"text-emerald-400":"text-gray-400"}`,children:Zt(Fe.icon)}),t.jsx("div",{className:`font-medium text-sm mb-1 ${u?"text-gray-400":"text-white"}`,children:Fe.label}),t.jsx("p",{className:`text-xs ${u?"text-gray-600":o===ie?"text-gray-300":"text-gray-500"}`,children:Fe.description})]},ie))})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Description"}),t.jsx("textarea",{value:((fe=e.config)==null?void 0:fe.description)||"",onChange:ie=>F({description:ie.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?"})]}),t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx("input",{type:"checkbox",id:"skippable",checked:((be=e.config)==null?void 0:be.skippable)||!1,onChange:ie=>F({skippable:ie.target.checked}),className:"w-4 h-4 rounded border-gray-600 bg-gray-700 text-primary-600 focus:ring-primary-500"}),t.jsx("label",{htmlFor:"skippable",className:"text-sm text-gray-300",children:"Allow skipping this step"})]}),o==="design_doc"&&t.jsxs("div",{className:"border-t border-gray-700 pt-6",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Design Document File"}),t.jsx("p",{className:"text-xs text-gray-500 mb-3",children:"Select an existing design document to edit, or create a new one."}),x?t.jsx("div",{className:"text-sm text-gray-400",children:"Loading files..."}):t.jsxs(t.Fragment,{children:[t.jsxs("select",{value:((Me=e.config)==null?void 0:Me.design_doc_path)||"",onChange:ie=>{ie.target.value==="__create__"?v(!0):F({design_doc_path:ie.target.value||void 0})},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:[t.jsx("option",{value:"",children:"(Create new during chat)"}),t.jsx("option",{value:"__create__",children:"+ Create New File..."}),h.map(ie=>t.jsxs("option",{value:ie.name,children:["📄 ",ie.name," (",(ie.size/1024).toFixed(1)," KB)"]},ie.path))]}),((Ve=e.config)==null?void 0:Ve.design_doc_path)&&t.jsx("div",{className:"mt-3 p-3 bg-violet-900/20 border border-violet-700/50 rounded-lg",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("svg",{className:"w-4 h-4 text-violet-400 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsxs("div",{className:"text-xs text-violet-300",children:[t.jsx("strong",{children:"Editing existing file:"})," Changes will save directly to"," ",t.jsxs("code",{className:"bg-violet-900/50 px-1 rounded",children:[".ralphx/resources/design_doc/",e.config.design_doc_path]}),". Original content will be backed up automatically."]})]})}),!((Ye=e.config)!=null&&Ye.design_doc_path)&&t.jsx("div",{className:"mt-3 p-3 bg-gray-800/50 border border-gray-700 rounded-lg",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("svg",{className:"w-4 h-4 text-gray-400 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),t.jsxs("div",{className:"text-xs text-gray-400",children:[t.jsx("strong",{children:"Creating new:"})," A new design document will be created when you complete this step."]})]})})]})]}),b&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:ie=>{ie.target===ie.currentTarget&&(v(!1),T(""))},children:t.jsxs("div",{className:"bg-gray-800 rounded-xl border border-gray-600 p-6 w-full max-w-md mx-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Create New Design Document"}),t.jsxs("div",{className:"mb-4",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"File Name"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:k,onChange:ie=>T(ie.target.value),placeholder:"e.g., API_DESIGN",className:"flex-1 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",autoFocus:!0,onKeyDown:ie=>{ie.key==="Enter"&&ve(),ie.key==="Escape"&&(v(!1),T(""))}}),t.jsx("span",{className:"text-gray-400",children:".md"})]}),t.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Will be saved to .ralphx/resources/design_doc/"})]}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{type:"button",onClick:()=>{v(!1),T("")},className:"px-4 py-2 bg-gray-700 text-gray-300 rounded-lg hover:bg-gray-600",children:"Cancel"}),t.jsx("button",{type:"button",onClick:ve,disabled:!k.trim()||N,className:"px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-500 disabled:opacity-50",children:N?"Creating...":"Create"})]})]})}),e.step_type==="autonomous"&&t.jsxs("div",{className:"border-t border-gray-700 pt-6 space-y-6",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-300 uppercase tracking-wide",children:"Execution Settings"}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"AI Model"}),t.jsxs("select",{value:((Ct=e.config)==null?void 0:Ct.model)||"opus",onChange:ie=>F({model:ie.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:[t.jsx("option",{value:"opus",children:"Opus (Most Capable)"}),t.jsx("option",{value:"sonnet",children:"Sonnet (Balanced)"}),t.jsx("option",{value:"sonnet-1m",children:"Sonnet Extended (1M tokens)"}),t.jsx("option",{value:"haiku",children:"Haiku (Fast)"})]}),((Vt=e.config)==null?void 0:Vt.model)==="sonnet-1m"&&t.jsx("div",{className:"text-amber-400 text-xs mt-2 p-2 bg-amber-900/20 border border-amber-800/50 rounded",children:t.jsxs("div",{className:"flex items-start gap-1.5",children:[t.jsx("svg",{className:"w-4 h-4 flex-shrink-0 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsxs("span",{children:["Extended context is not available to all accounts. Only use this if you have already tested ",t.jsx("code",{className:"bg-amber-900/50 px-1 rounded",children:"--model sonnet"})," with large contexts in Claude Code and confirmed it works."]})]})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Timeout (seconds)"}),t.jsx("input",{type:"number",value:((yt=e.config)==null?void 0:yt.timeout)||600,onChange:ie=>F({timeout:parseInt(ie.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"})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-400",children:"Available Tools"}),t.jsxs("button",{type:"button",onClick:qe,className:"text-xs text-primary-400 hover:text-primary-300 flex items-center gap-1",children:[t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"]})]}),t.jsxs("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-3",children:[t.jsxs("div",{className:"text-xs text-gray-500 mb-3",children:["Template: ",c.label]}),t.jsx("div",{className:"grid grid-cols-2 gap-2",children:O3.map(ie=>{var Ke;const Fe=(((Ke=e.config)==null?void 0:Ke.allowedTools)||[]).includes(ie.id),dt=$t(ie.id);return t.jsxs("label",{className:`flex items-start gap-2 p-2 rounded cursor-pointer hover:bg-gray-700/50 ${Fe?"text-white":"text-gray-500"}`,children:[t.jsx("input",{type:"checkbox",checked:Fe,onChange:()=>We(ie.id),className:"mt-0.5 w-4 h-4 rounded border-gray-600 bg-gray-700 text-primary-600 focus:ring-primary-500"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"text-sm font-medium flex items-center gap-1",children:[ie.label,dt&&t.jsx("span",{className:"text-xs text-primary-400",title:"In template defaults",children:"*"})]}),t.jsx("div",{className:"text-xs text-gray-500 truncate",children:ie.description})]})]},ie.id)})})]})]}),t.jsxs("div",{className:"border-t border-gray-700 pt-6",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-4",children:"Run Cycle Limits"}),t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Max Run Cycles"}),t.jsx("input",{type:"number",value:((rt=e.config)==null?void 0:rt.max_iterations)??"",onChange:ie=>F({max_iterations:ie.target.value?parseInt(ie.target.value):void 0}),placeholder:String(Vs.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"}),t.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Default: ",Vs.max_iterations," (0 = unlimited)"]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Cooldown (sec)"}),t.jsx("input",{type:"number",value:((ce=e.config)==null?void 0:ce.cooldown_between_iterations)??"",onChange:ie=>F({cooldown_between_iterations:ie.target.value?parseInt(ie.target.value):void 0}),placeholder:String(Vs.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"}),t.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Default: ",Vs.cooldown_between_iterations,"s"]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Max Errors"}),t.jsx("input",{type:"number",value:((Ae=e.config)==null?void 0:Ae.max_consecutive_errors)??"",onChange:ie=>F({max_consecutive_errors:ie.target.value?parseInt(ie.target.value):void 0}),placeholder:String(Vs.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"}),t.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Default: ",Vs.max_consecutive_errors]})]})]})]}),(o==="extractgen_requirements"||o==="webgen_requirements")&&(()=>{var dt;const ie=s.filter(Ke=>Ke.id&&Ke.id!==e.id),Fe=((dt=e.config)==null?void 0:dt.context_from_steps)||[];return ie.length===0?null:t.jsxs("div",{className:"border-t border-gray-700 pt-6",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-2",children:"Context from Other Steps"}),t.jsx("p",{className:"text-xs text-gray-500 mb-3",children:"Include work items from other steps as context so this step avoids generating duplicates."}),t.jsx("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-3 space-y-2",children:ie.map(Ke=>{var mt;const vr=Fe.includes(Ke.id),or=(mt=Ke.config)==null?void 0:mt.template,an=or==="extractgen_requirements"?"Extract":or==="webgen_requirements"?"WebGen":or==="implementation"?"Impl":Ke.step_type==="interactive"?"Design":"Step";return t.jsxs("label",{className:`flex items-center gap-3 p-2 rounded cursor-pointer hover:bg-gray-700/50 ${vr?"text-white":"text-gray-400"}`,children:[t.jsx("input",{type:"checkbox",checked:vr,onChange:()=>{const Pe=vr?Fe.filter(et=>et!==Ke.id):[...Fe,Ke.id];F({context_from_steps:Pe.length>0?Pe:void 0})},className:"w-4 h-4 rounded border-gray-600 bg-gray-700 text-primary-600 focus:ring-primary-500"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[Ke.name,t.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-gray-700 text-gray-400 rounded",children:an})]}),Ke.items_generated?t.jsxs("div",{className:"text-xs text-gray-500",children:[Ke.items_generated," items"]}):null]})]},Ke.id)})})]})})(),t.jsxs("div",{className:"border-t border-gray-700 pt-6",children:[t.jsxs("button",{type:"button",onClick:()=>M(!A),className:"w-full flex items-center justify-between text-left",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-300",children:"AI Instructions (Advanced)"}),q&&t.jsx("span",{className:"px-2 py-0.5 bg-amber-900/30 text-amber-400 text-xs rounded-full",children:"customized"})]}),t.jsx("svg",{className:`w-5 h-5 text-gray-400 transition-transform ${A?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),A&&t.jsxs("div",{className:"mt-4 space-y-4",children:[ee&&t.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:[t.jsx("svg",{className:"w-5 h-5 flex-shrink-0 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{children:"Cannot edit while step is running. Stop the step to make changes."})]}),q?t.jsx("div",{className:"p-3 bg-amber-900/20 border border-amber-800/50 rounded-lg",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.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:t.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"})}),t.jsxs("div",{className:"text-amber-400 text-sm",children:[t.jsx("strong",{children:"ADVANCED:"})," Editing these instructions can break the step. Only modify if you understand the template variables below."]})]})}):t.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."]}),t.jsx("div",{className:"flex items-center justify-between",children:t.jsxs("button",{type:"button",onClick:()=>X(!R),className:"text-xs text-primary-400 hover:text-primary-300 flex items-center gap-1",children:[t.jsx("svg",{className:`w-4 h-4 transition-transform ${R?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),R?"Hide":"View"," Template Variables"]})}),R&&t.jsxs("div",{className:"bg-gray-900 border border-gray-700 rounded-lg p-3 text-xs",children:[t.jsx("div",{className:"font-medium text-gray-300 mb-2",children:"Available Template Variables:"}),V?t.jsx("div",{className:"text-gray-500",children:"Loading..."}):P.length>0?t.jsx("div",{className:"space-y-2",children:P.map(ie=>t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("code",{className:`px-1.5 py-0.5 rounded font-mono ${ie.required?"bg-amber-900/30 text-amber-400":"bg-gray-800 text-gray-400"}`,children:ie.name}),t.jsxs("span",{className:"text-gray-500",children:[ie.description,ie.required&&t.jsx("span",{className:"text-amber-400 ml-1",children:"(required)"})]})]},ie.name))}):t.jsx("div",{className:"text-gray-500",children:"No variables available"})]}),U&&t.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:[t.jsx("span",{children:U}),t.jsx("button",{type:"button",onClick:je,className:"text-red-300 hover:text-red-200 underline",children:"Retry"})]}),q&&re.warnings.length>0&&t.jsxs("div",{className:"p-3 bg-amber-900/20 border border-amber-800/50 rounded-lg text-sm",children:[t.jsxs("div",{className:"font-medium text-amber-400 mb-1 flex items-center gap-1",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01"})}),"Validation Warnings:"]}),t.jsx("ul",{className:"text-amber-400/80 space-y-1",children:re.warnings.map((ie,Fe)=>t.jsx("li",{children:ie},Fe))})]}),t.jsx("div",{children:V?t.jsx("div",{className:"h-64 bg-gray-800 border border-gray-700 rounded-lg flex items-center justify-center",children:t.jsx("div",{className:"text-gray-500",children:"Loading default prompt..."})}):t.jsx("textarea",{value:S,onChange:ie=>tt(ie.target.value),readOnly:!q||!ge,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 ${!q||!ge?"border-gray-700 cursor-not-allowed opacity-75":re.isValid?"border-gray-600 focus:border-primary-500":"border-amber-600 focus:border-amber-500"}`,placeholder:"AI instructions for this step..."})}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:q,onChange:ie=>ft(ie.target.checked),disabled:!ge,className:"w-4 h-4 rounded border-gray-600 bg-gray-700 text-primary-600 focus:ring-primary-500 disabled:opacity-50"}),t.jsx("span",{className:`text-sm ${ge?"text-gray-300":"text-gray-500"}`,children:"Use Custom Instructions"})]}),q&&ge&&t.jsxs("button",{type:"button",onClick:()=>H(!0),className:"text-sm text-red-400 hover:text-red-300 flex items-center gap-1",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"]})]}),I&&t.jsxs("div",{className:"p-4 bg-gray-900 border border-gray-600 rounded-lg",children:[t.jsx("div",{className:"text-white mb-3",children:"Reset to default instructions?"}),t.jsx("p",{className:"text-gray-400 text-sm mb-4",children:"This will discard your custom instructions. This action cannot be undone."}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:()=>H(!1),className:"px-3 py-1.5 text-sm text-gray-400 hover:text-white",children:"Cancel"}),t.jsx("button",{type:"button",onClick:Rt,className:"px-3 py-1.5 text-sm bg-red-600 text-white rounded hover:bg-red-500",children:"Reset"})]})]})]})]})]}),W&&Z&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-gray-800 border border-gray-600 rounded-lg p-6 max-w-md mx-4",children:[t.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"Change Step Type?"}),t.jsxs("p",{className:"text-gray-400 text-sm mb-4",children:["Switching to ",t.jsx("strong",{className:"text-white",children:na[Z].label})," will reset the following settings to defaults:"]}),t.jsx("ul",{className:"text-amber-400 text-sm mb-4 list-disc list-inside space-y-1",children:E.map((ie,Fe)=>t.jsx("li",{children:ie},Fe))}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:Se,className:"px-4 py-2 text-gray-400 hover:text-white transition-colors",children:"Cancel"}),t.jsx("button",{type:"button",onClick:Oe,className:"px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-500 transition-colors",children:"Change Type"})]})]})})]})}function U3({projectSlug:e,loopName:r,onClose:s,onSave:a}){var U;const[o,c]=y.useState(!0),[d,u]=y.useState(!1),[h,p]=y.useState(null),[x,g]=y.useState(null),[b,v]=y.useState([]),[k,T]=y.useState(""),[N,j]=y.useState("template"),[A,M]=y.useState(""),[_,z]=y.useState(null),P=y.useCallback(async()=>{c(!0),p(null);try{const[D,R]=await Promise.all([xb(e,r),fb()]);if(g(D),v(R),D.source==="template"&&D.template_id)T(D.template_id),j("template");else if(D.source==="custom")j("custom");else{const X=R.length>0?R[0].id:D.template_id||"";T(X),j("template")}M(JSON.stringify(D.permissions,null,2))}catch(D){p(D instanceof Error?D.message:"Failed to load permissions")}finally{c(!1)}},[e,r]);y.useEffect(()=>{P()},[P]),y.useEffect(()=>{const D=R=>{R.key==="Escape"&&!d&&s()};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[s,d]),y.useEffect(()=>{if(N==="custom")try{JSON.parse(A),z(null)}catch{z("Invalid JSON syntax")}else z(null)},[A,N]);const $=async()=>{u(!0),p(null);try{if(N==="template")await sp(e,r,{template_id:k,permissions:{allow:[]}});else{const D=JSON.parse(A);await sp(e,r,{permissions:D})}a==null||a(),s()}catch(D){p(D instanceof Error?D.message:"Failed to save permissions")}finally{u(!1)}},V=async()=>{if(confirm("Reset to default permissions? This will remove any custom settings.")){u(!0),p(null);try{await gb(e,r),await P()}catch(D){p(D instanceof Error?D.message:"Failed to reset permissions")}finally{u(!1)}}},B=D=>{T(D)};return t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.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:[t.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-700",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold text-white",children:"Edit Loop Permissions"}),t.jsxs("p",{className:"text-sm text-gray-400 mt-1",children:["Configure Claude Code permissions for ",t.jsx("span",{className:"text-primary-400",children:r})]})]}),t.jsx("button",{onClick:s,className:"text-gray-400 hover:text-white","aria-label":"Close",children:t.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:o?t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary-500"})}):h?t.jsx("div",{className:"p-4 bg-red-900/20 border border-red-800 rounded-lg text-red-400",children:h}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"p-4 bg-gray-800 rounded-lg",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-sm text-gray-400",children:"Current Source:"}),t.jsx("span",{className:`ml-2 px-2 py-0.5 rounded text-xs font-medium ${(x==null?void 0:x.source)==="custom"?"bg-purple-500/20 text-purple-400":(x==null?void 0:x.source)==="template"?"bg-blue-500/20 text-blue-400":"bg-gray-700 text-gray-400"}`,children:(x==null?void 0:x.source)==="custom"?"Custom":(x==null?void 0:x.source)==="template"?`Template: ${x==null?void 0:x.template_id}`:"Default"})]}),(x==null?void 0:x.has_custom)&&t.jsx("button",{onClick:V,disabled:d,className:"text-sm text-gray-400 hover:text-red-400",children:"Reset to Default"})]})}),t.jsxs("div",{className:"flex space-x-2",children:[t.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"}),t.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"&&t.jsx("div",{className:"space-y-4",children:b.length===0?t.jsxs("div",{className:"p-4 bg-gray-800/50 rounded-lg text-center text-gray-400",children:[t.jsx("p",{children:"No permission templates available."}),t.jsx("p",{className:"text-sm mt-1",children:"Switch to Custom mode to define permissions manually."})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Select Template"}),t.jsx("select",{value:k,onChange:D=>B(D.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(D=>t.jsx("option",{value:D.id,children:D.name},D.id))})]}),b.find(D=>D.id===k)&&t.jsx("div",{className:"p-4 bg-gray-800/50 rounded-lg",children:t.jsx("p",{className:"text-sm text-gray-400",children:(U=b.find(D=>D.id===k))==null?void 0:U.description})})]})}),N==="custom"&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Permissions JSON"}),t.jsx("textarea",{value:A,onChange:D=>M(D.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": []}'}),_&&t.jsx("p",{className:"mt-1 text-sm text-red-400",children:_})]}),t.jsxs("div",{className:"p-4 bg-gray-800/50 rounded-lg",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-300 mb-2",children:"Common Patterns"}),t.jsxs("div",{className:"text-xs text-gray-500 space-y-1 font-mono",children:[t.jsx("div",{children:"Read(**) - Read any file"}),t.jsx("div",{children:"Write(**) - Write any file"}),t.jsx("div",{children:"Edit(**) - Edit any file"}),t.jsx("div",{children:"Bash(*) - Run any bash command"}),t.jsx("div",{children:"Bash(git *) - Run git commands only"}),t.jsx("div",{children:"WebSearch - Enable web search"})]})]})]})]})}),t.jsxs("div",{className:"flex items-center justify-end space-x-3 p-6 border-t border-gray-700",children:[t.jsx("button",{onClick:s,className:"px-4 py-2 bg-gray-700 text-gray-300 rounded-lg hover:bg-gray-600",children:"Cancel"}),t.jsx("button",{onClick:$,disabled:d||o||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:d?"Saving...":"Save Permissions"})]})]})})}function V3({projectSlug:e,workflowId:r,step:s,allSteps:a,onChange:o,onClone:c,onArchive:d,onError:u}){var re;const[h,p]=y.useState("settings"),[x,g]=y.useState([]),[b,v]=y.useState([]),[k,T]=y.useState(!1),[N,j]=y.useState(!1),[A,M]=y.useState(!1),[_,z]=y.useState({name:"",resource_type:"guardrail",content:""}),[P,$]=y.useState(!1),[V,B]=y.useState(null),[U,D]=y.useState(!1),[R,X]=y.useState(!1),[I,H]=y.useState(!1);y.useEffect(()=>{p("settings")},[s.id]),y.useEffect(()=>{if(!(A||P||R))return;const ge=je=>{je.key==="Escape"&&(A?M(!1):P?$(!1):R&&X(!1))};return window.addEventListener("keydown",ge),()=>window.removeEventListener("keydown",ge)},[A,P,R]);const W=y.useCallback(async()=>{if(s.id){T(!0);try{const[ee,ge]=await Promise.all([hl(e,r),f1(e,r,s.id)]);g(ee),v(ge)}catch(ee){u(ee instanceof Error?ee.message:"Failed to load resources")}finally{T(!1)}}},[e,r,s.id,u]);y.useEffect(()=>{h==="resources"&&s.id&&W()},[h,s.id,W]);const J=async ee=>{if(!(!s.id||N)){j(!0);try{b.find(je=>je.workflow_resource_id===ee.id&&je.mode==="disable")?await v1(e,r,s.id,ee.id):await y1(e,r,s.id,ee.id),await W()}catch(ge){u(ge instanceof Error?ge.message:"Failed to toggle resource")}finally{j(!1)}}},Z=ee=>b.some(ge=>ge.workflow_resource_id===ee&&ge.mode==="disable"),de=async ee=>{if(ee.preventDefault(),!(!s.id||!_.name.trim()||!_.content.trim())&&!N){j(!0);try{await x1(e,r,s.id,{mode:"add",resource_type:_.resource_type,name:_.name.trim(),content:_.content.trim()}),z({name:"",resource_type:"guardrail",content:""}),M(!1),await W()}catch(ge){u(ge instanceof Error?ge.message:"Failed to add step resource")}finally{j(!1)}}},E=async ee=>{if(!(!s.id||N)&&confirm("Delete this step resource?")){j(!0);try{await g1(e,r,s.id,ee.id),await W()}catch(ge){u(ge instanceof Error?ge.message:"Failed to delete step resource")}finally{j(!1)}}},L=async()=>{if(s.id){D(!0);try{const ee=await w1(e,r,s.id);B(ee),$(!0)}catch(ee){u(ee instanceof Error?ee.message:"Failed to load preview")}finally{D(!1)}}},q=ee=>{switch(ee){case"design_doc":return"Design Document";case"guardrail":return"Guideline";case"input_file":return"Input File";case"prompt":return"Prompt";default:return ee}},S=ee=>{switch(ee){case"design_doc":return t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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 t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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 t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}},G=[{key:"settings",label:"Settings"},{key:"resources",label:"Resources",disabled:!s.id||s.step_type!=="autonomous"},{key:"permissions",label:"Permissions",disabled:!s.id||s.step_type!=="autonomous"}];return t.jsxs("div",{className:"card h-full flex flex-col",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4 pb-4 border-b border-gray-700",children:[t.jsxs("div",{children:[t.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Step ",s.step_number,": ",s.name||"Untitled"]}),t.jsxs("p",{className:"text-sm text-gray-400 mt-1",children:[s.step_type==="interactive"?"Chat Step":"Automated Step",((re=s.config)==null?void 0:re.model)&&s.step_type==="autonomous"&&` (${s.config.model})`]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[!s.id&&t.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"}),t.jsx("button",{onClick:c,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"}),t.jsx("button",{onClick:()=>H(!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"})]})]}),s.step_type==="autonomous"&&t.jsx("div",{className:"flex space-x-1 border-b border-gray-700 mb-4",children:G.map(ee=>t.jsx("button",{onClick:()=>!ee.disabled&&p(ee.key),disabled:ee.disabled,className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${h===ee.key?"border-primary-500 text-white":ee.disabled?"border-transparent text-gray-600 cursor-not-allowed":"border-transparent text-gray-400 hover:text-gray-300"}`,children:ee.label},ee.key))}),t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[(h==="settings"||s.step_type==="interactive")&&t.jsx(H3,{step:s,projectSlug:e,allSteps:a,onChange:o}),h==="resources"&&s.step_type==="autonomous"&&s.id&&t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-300",children:"Inherited from Workflow"}),t.jsxs("button",{onClick:L,disabled:U,className:"flex items-center space-x-1 text-sm text-primary-400 hover:text-primary-300 disabled:opacity-50",children:[t.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),t.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"})]}),t.jsx("span",{children:U?"Loading...":"Preview Prompt"})]})]}),k?t.jsx("div",{className:"text-center py-4 text-gray-500",children:"Loading resources..."}):x.length===0?t.jsx("div",{className:"text-center py-4 text-gray-500",children:"No workflow resources. Add resources in the Resources tab."}):t.jsx("div",{className:"space-y-2",children:x.map(ee=>{const ge=Z(ee.id);return t.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border ${ge?"bg-gray-800/50 border-gray-700 opacity-60":"bg-gray-700 border-gray-600"}`,children:[t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx("div",{className:`p-2 rounded ${ge?"bg-gray-700 text-gray-500":"bg-primary-500/20 text-primary-400"}`,children:S(ee.resource_type)}),t.jsxs("div",{children:[t.jsx("div",{className:`font-medium ${ge?"text-gray-500":"text-white"}`,children:ee.name}),t.jsxs("div",{className:"text-xs text-gray-500",children:[q(ee.resource_type),ge&&" — disabled for this step"]})]})]}),t.jsx("button",{onClick:()=>J(ee),disabled:N,className:`px-3 py-1 text-xs rounded transition-colors ${ge?"bg-gray-700 text-gray-400 hover:bg-gray-600":"bg-green-600/20 text-green-400 hover:bg-green-600/30"}`,children:ge?"Enable":"Enabled"})]},ee.id)})})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-300",children:"Step-Specific Resources"}),t.jsxs("button",{onClick:()=>M(!0),className:"flex items-center space-x-1 text-sm text-primary-400 hover:text-primary-300",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),t.jsx("span",{children:"Add Resource"})]})]}),b.filter(ee=>ee.mode==="add").length===0?t.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."}):t.jsx("div",{className:"space-y-2",children:b.filter(ee=>ee.mode==="add").map(ee=>t.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-700 rounded-lg border border-gray-600",children:[t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx("div",{className:"p-2 rounded bg-blue-500/20 text-blue-400",children:S(ee.resource_type||"custom")}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-white",children:ee.name}),t.jsxs("div",{className:"text-xs text-gray-500",children:[q(ee.resource_type||"custom")," — step-specific"]})]})]}),t.jsx("button",{onClick:()=>E(ee),disabled:N,className:"p-1 text-gray-400 hover:text-red-400 disabled:opacity-50",children:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})})]},ee.id))})]})]}),h==="permissions"&&s.step_type==="autonomous"&&s.id&&t.jsx("div",{children:s.loop_name?t.jsxs("div",{className:"space-y-4",children:[t.jsx("p",{className:"text-sm text-gray-400",children:"Configure which tools and file operations Claude can use during this step's execution."}),t.jsxs("button",{type:"button",onClick:()=>X(!0),className:"flex items-center space-x-2 px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-500",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{children:"Edit Claude Code Permissions"})]})]}):t.jsxs("div",{className:"flex items-start space-x-3 p-4 bg-gray-700 rounded-lg",children:[t.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:t.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"})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-300",children:"Permissions can be configured after the step is started for the first time."}),t.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."})]})]})})]}),A&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:ee=>{ee.target===ee.currentTarget&&M(!1)},children:t.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:[t.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Add Step Resource"}),t.jsxs("form",{onSubmit:de,className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Resource Type"}),t.jsxs("select",{value:_.resource_type,onChange:ee=>z({..._,resource_type:ee.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:[t.jsx("option",{value:"guardrail",children:"Guideline"}),t.jsx("option",{value:"design_doc",children:"Design Document"}),t.jsx("option",{value:"input_file",children:"Input File"}),t.jsx("option",{value:"prompt",children:"Prompt"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Name"}),t.jsx("input",{type:"text",value:_.name,onChange:ee=>z({..._,name:ee.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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Content"}),t.jsx("textarea",{value:_.content,onChange:ee=>z({..._,content:ee.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"})]}),t.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[t.jsx("button",{type:"button",onClick:()=>M(!1),className:"px-4 py-2 bg-gray-700 text-gray-300 rounded-lg hover:bg-gray-600",children:"Cancel"}),t.jsx("button",{type:"submit",disabled:!_.name.trim()||!_.content.trim()||N,className:"px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-500 disabled:opacity-50",children:N?"Adding...":"Add Resource"})]})]})]})}),P&&V&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:ee=>{ee.target===ee.currentTarget&&$(!1)},children:t.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:[t.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-600",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-white",children:"Prompt Preview"}),t.jsxs("p",{className:"text-sm text-gray-400 mt-1",children:[V.resources_used.length," resources • ~",V.total_tokens_estimate.toLocaleString()," tokens"]})]}),t.jsx("button",{onClick:()=>$(!1),className:"text-gray-400 hover:text-white",children:t.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-4",children:V.prompt_sections.length===0?t.jsx("div",{className:"text-center py-8 text-gray-500",children:"No resources will be injected for this step."}):V.prompt_sections.map((ee,ge)=>t.jsxs("div",{className:"border border-gray-600 rounded-lg overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-gray-700 border-b border-gray-600",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("span",{className:"text-sm font-medium text-white",children:ee.resource_name}),t.jsx("span",{className:"text-xs bg-gray-600 text-gray-300 px-2 py-0.5 rounded",children:ee.resource_type})]}),t.jsx("span",{className:"text-xs text-gray-500",children:ee.position})]}),t.jsx("pre",{className:"p-4 text-sm text-gray-300 overflow-x-auto bg-gray-900 max-h-64",children:ee.content.length>2e3?ee.content.slice(0,2e3)+`
|
|
191
|
+
... (truncated)`:ee.content})]},ge))}),t.jsx("div",{className:"flex justify-end p-6 border-t border-gray-600",children:t.jsx("button",{onClick:()=>$(!1),className:"px-4 py-2 bg-gray-700 text-gray-300 rounded-lg hover:bg-gray-600",children:"Close"})})]})}),R&&s.loop_name&&t.jsx(U3,{projectSlug:e,loopName:s.loop_name,onClose:()=>X(!1),onSave:()=>{}}),t.jsx(Yg,{isOpen:I,title:`Archive "${s.name}"?`,message:"This step will be moved to the trash and can be recovered later.",details:(s.iterations_completed||0)>0||(s.items_generated||0)>0?`This step has ${s.iterations_completed||0} iterations and ${s.items_generated||0} items generated. These will be preserved.`:void 0,confirmLabel:"Archive Step",variant:"danger",onConfirm:()=>{H(!1),d()},onCancel:()=>H(!1)})]})}function q3({archivedSteps:e,loading:r,onRestore:s,onPermanentlyDelete:a}){const[o,c]=y.useState(!1),[d,u]=y.useState(null),[h,p]=y.useState(null);return!r&&e.length===0?null:t.jsxs("div",{className:"mt-4 border-t border-gray-700 pt-4",children:[t.jsxs("button",{onClick:()=>c(!o),className:"w-full flex items-center justify-between px-2 py-1 text-sm text-gray-400 hover:text-gray-300 transition-colors",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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.jsxs("span",{children:["Trash (",e.length,")"]})]}),t.jsx("svg",{className:`w-4 h-4 transition-transform ${o?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),o&&t.jsx("div",{className:"mt-2 space-y-2",children:r?t.jsx("div",{className:"text-center py-2 text-gray-500 text-sm",children:"Loading..."}):e.map(x=>t.jsxs("div",{className:"flex items-center justify-between py-2 px-3 bg-gray-800/50 rounded",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("span",{className:"text-gray-500 text-xs mr-2",children:["#",x.step_number]}),t.jsx("span",{className:"text-gray-400 text-sm truncate",children:x.name})]}),t.jsxs("div",{className:"flex gap-1 flex-shrink-0 ml-2",children:[t.jsx("button",{onClick:async()=>{p(x.id);try{await s(x)}finally{p(null)}},disabled:h!==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:h===x.id?"Restoring...":"Restore"}),t.jsx("button",{onClick:()=>u(x),disabled:h!==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:h===x.id?"Deleting...":"Delete"})]})]},x.id))}),t.jsx(Yg,{isOpen:d!==null,title:`Permanently delete "${d==null?void 0:d.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(d){const x=d;u(null),p(x.id);try{await a(x)}finally{p(null)}}},onCancel:()=>u(null)})]})}function Y3({projectSlug:e,workflowId:r,steps:s,onStepsChange:a,onError:o}){const[c,d]=y.useState(s.length>0?0:null),[u,h]=y.useState([]),[p,x]=y.useState(!1),g=c!==null?s[c]:null,b=y.useCallback(async()=>{if(r){x(!0);try{const _=await a1(e,r);h(_)}catch(_){console.error("Failed to load archived steps:",_)}finally{x(!1)}}},[e,r]);y.useEffect(()=>{b()},[b]);const v=()=>{const _={id:0,workflow_id:r,step_number:s.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"]}};a([...s,_]),d(s.length)},k=_=>{const z=s[_],P={id:0,workflow_id:r,step_number:s.length+1,name:`${z.name} (Copy)`,step_type:z.step_type,status:"pending",config:{...z.config},iterations_completed:0,items_generated:0};a([...s,P]),d(s.length)},T=async _=>{const z=s[_];if(!z.id){const P=s.filter(($,V)=>V!==_);a(P),c===_?d(P.length>0?Math.max(0,_-1):null):c!==null&&c>_&&d(c-1);return}try{await s1(e,r,z.id);const P=s.filter(($,V)=>V!==_);a(P),h($=>[...$,{...z,archived_at:new Date().toISOString()}]),c===_?d(P.length>0?Math.max(0,_-1):null):c!==null&&c>_&&d(c-1)}catch(P){o(P instanceof Error?P.message:"Failed to archive step")}},N=async _=>{try{const z=await i1(e,r,_.id);h(V=>V.filter(B=>B.id!==_.id));const P=[...s],$=P.findIndex(V=>V.step_number>z.step_number);$===-1?P.push(z):P.splice($,0,z),a(P)}catch(z){o(z instanceof Error?z.message:"Failed to restore step")}},j=async _=>{try{await nx(e,r,_.id),h(z=>z.filter(P=>P.id!==_.id))}catch(z){o(z instanceof Error?z.message:"Failed to delete step")}},A=(_,z)=>{const P=z==="up"?_-1:_+1;if(P<0||P>=s.length)return;const $=[...s],[V]=$.splice(_,1);$.splice(P,0,V),a($),c===_?d(P):c===P&&d(_)},M=_=>{if(c===null)return;const z=[...s];z[c]=_,a(z)};return t.jsxs("div",{className:"flex gap-6 h-[calc(100vh-220px)]",children:[t.jsxs("div",{className:"w-64 flex-shrink-0 flex flex-col",children:[t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(R3,{steps:s,selectedIndex:c,onSelect:d,onAdd:v,onMove:A})}),t.jsx(q3,{archivedSteps:u,loading:p,onRestore:N,onPermanentlyDelete:j})]}),t.jsx("div",{className:"flex-1 min-w-0",children:g?t.jsx(V3,{projectSlug:e,workflowId:r,step:g,allSteps:s,onChange:M,onClone:()=>k(c),onArchive:()=>T(c),onError:o}):t.jsx("div",{className:"h-full flex items-center justify-center card",children:t.jsxs("div",{className:"text-center",children:[t.jsx("svg",{className:"w-16 h-16 mx-auto text-gray-600 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("h3",{className:"text-lg font-medium text-gray-300 mb-2",children:"No Steps Yet"}),t.jsx("p",{className:"text-gray-500 mb-4",children:"Add your first step to define your workflow."}),t.jsx("button",{onClick:v,className:"px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-500",children:"Add First Step"})]})})})]})}function G3({projectSlug:e,workflowId:r,resources:s,projectResources:a,filesystemResources:o=[],onResourcesChange:c,onError:d}){const[u,h]=y.useState(!1),[p,x]=y.useState(!1),[g,b]=y.useState(!1),[v,k]=y.useState(null),[T,N]=y.useState(""),[j,A]=y.useState({name:"",resource_type:"guardrail",content:""});y.useEffect(()=>{if(!(p||g||v!==null))return;const q=S=>{S.key==="Escape"&&(p?(x(!1),A({name:"",resource_type:"guardrail",content:""})):g?b(!1):v&&k(null))};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[p,g,v]);const M=async L=>{if(L.preventDefault(),!(!j.name.trim()||!j.content.trim())&&!u){h(!0);try{await Yo(e,r,{name:j.name.trim(),resource_type:j.resource_type,content:j.content.trim(),source:"manual"}),A({name:"",resource_type:"guardrail",content:""}),x(!1),c()}catch(q){d(q instanceof Error?q.message:"Failed to add resource")}finally{h(!1)}}},_=async L=>{if(!u){h(!0);try{await ax(e,r,L.id),b(!1),c()}catch(q){d(q instanceof Error?q.message:"Failed to import resource")}finally{h(!1)}}},z=async L=>{if(!u){if(!L.content){d("Resource content not available");return}h(!0);try{await Yo(e,r,{name:L.name,resource_type:L.resource_type,content:L.content,source:"imported"}),b(!1),c()}catch(q){d(q instanceof Error?q.message:"Failed to import filesystem resource")}finally{h(!1)}}},P=async L=>{if(!u){h(!0);try{await da(e,r,L.id,{enabled:!L.enabled}),c()}catch(q){d(q instanceof Error?q.message:"Failed to update resource")}finally{h(!1)}}},$=async()=>{if(v&&!u){h(!0);try{await da(e,r,v.id,{content:T}),k(null),c()}catch(L){d(L instanceof Error?L.message:"Failed to save resource")}finally{h(!1)}}},V=async L=>{if(!(u||!(await qg.danger("Delete Resource?",`Are you sure you want to delete "${L.name}"? This cannot be undone.`)).isConfirmed)){h(!0);try{await ix(e,r,L.id),c()}catch(S){d(S instanceof Error?S.message:"Failed to delete resource")}finally{h(!1)}}},B=L=>{switch(L){case"design_doc":return"Design Document";case"guardrail":return"Guideline";case"input_file":return"Input File";case"prompt":return"Prompt";default:return L}},U=L=>{switch(L){case"design_doc":return t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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 t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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 t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})})}},D=new Set(s.filter(L=>L.source_id).map(L=>L.source_id)),R=a.filter(L=>!D.has(L.id)),X=new Set(s.map(L=>L.name.toLowerCase())),I=o.filter(L=>L.enabled&&!X.has(L.name.toLowerCase())),H=s.filter(L=>L.resource_type==="design_doc"),W=s.filter(L=>L.resource_type==="guardrail"),J=s.filter(L=>L.resource_type==="input_file"),Z=s.filter(L=>L.resource_type==="prompt"),de=s.filter(L=>!["design_doc","guardrail","input_file","prompt"].includes(L.resource_type)),E=(L,q,S)=>q.length===0?null:t.jsxs("div",{className:"space-y-3",children:[t.jsxs("h3",{className:"flex items-center gap-2 text-sm font-medium text-gray-300",children:[S,L,t.jsxs("span",{className:"text-gray-500",children:["(",q.length,")"]})]}),t.jsx("div",{className:"space-y-2",children:q.map(G=>t.jsxs("div",{className:"flex items-start space-x-3 p-4 bg-gray-800 rounded-lg border border-gray-700",children:[t.jsx("div",{className:`p-2 rounded ${G.enabled?"bg-primary-500/20 text-primary-400":"bg-gray-700 text-gray-500"}`,children:U(G.resource_type)}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-medium text-white truncate",children:G.name}),t.jsxs("div",{className:"text-xs text-gray-400",children:[B(G.resource_type),G.source&&` • ${G.source}`]}),G.content&&t.jsx("p",{className:"text-xs text-gray-500 mt-1 line-clamp-2",children:G.content.length>150?`${G.content.slice(0,150)}...`:G.content})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("button",{onClick:()=>P(G),disabled:u,className:`px-2 py-1 text-xs rounded disabled:opacity-50 ${G.enabled?"bg-green-600/20 text-green-400":"bg-gray-700 text-gray-500"}`,children:G.enabled?"On":"Off"}),t.jsx("button",{onClick:()=>{k(G),N(G.content||"")},disabled:u,className:"p-1 text-gray-400 hover:text-white disabled:opacity-50",children:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.jsx("button",{onClick:()=>V(G),disabled:u,className:"p-1 text-gray-400 hover:text-red-400 disabled:opacity-50",children:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})})]})]},G.id))})]});return t.jsxs("div",{className:"max-w-4xl",children:[t.jsxs("div",{className:"flex items-center justify-between mb-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-white",children:"Workflow Resources"}),t.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"These resources are available to all steps in this workflow"})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxs("button",{onClick:()=>b(!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:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{children:"Import from Library"})]}),t.jsxs("button",{onClick:()=>x(!0),className:"flex items-center space-x-1 px-3 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-500",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),t.jsx("span",{children:"Add Resource"})]})]})]}),s.length===0?t.jsxs("div",{className:"text-center py-12 card",children:[t.jsx("svg",{className:"w-16 h-16 mx-auto text-gray-600 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("h3",{className:"text-lg font-medium text-gray-300 mb-2",children:"No Resources Yet"}),t.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."}),t.jsxs("div",{className:"flex items-center justify-center space-x-3",children:[t.jsx("button",{onClick:()=>b(!0),className:"px-4 py-2 bg-gray-700 text-gray-300 rounded-lg hover:bg-gray-600",children:"Import from Library"}),t.jsx("button",{onClick:()=>x(!0),className:"px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-500",children:"Add Resource"})]})]}):t.jsxs("div",{className:"space-y-6",children:[E("Design Documents",H,t.jsx("svg",{className:"w-4 h-4 text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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("Guidelines",W,t.jsx("svg",{className:"w-4 h-4 text-violet-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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("Input Files",J,t.jsx("svg",{className:"w-4 h-4 text-emerald-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})),E("Prompts",Z,t.jsx("svg",{className:"w-4 h-4 text-amber-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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("Other",de,t.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h7"})}))]}),p&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:L=>{L.target===L.currentTarget&&(x(!1),A({name:"",resource_type:"guardrail",content:""}))},children:t.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:[t.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Add Resource"}),t.jsxs("form",{onSubmit:M,className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Resource Type"}),t.jsxs("select",{value:j.resource_type,onChange:L=>A({...j,resource_type:L.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:[t.jsx("option",{value:"design_doc",children:"Design Document"}),t.jsx("option",{value:"guardrail",children:"Guideline"}),t.jsx("option",{value:"input_file",children:"Input File"}),t.jsx("option",{value:"prompt",children:"Prompt"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Name"}),t.jsx("input",{type:"text",value:j.name,onChange:L=>A({...j,name:L.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"})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:["Upload File ",t.jsx("span",{className:"text-gray-500 font-normal",children:"(optional)"})]}),t.jsx("div",{className:"flex items-center gap-2",children:t.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:[t.jsx("svg",{className:"w-5 h-5 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),t.jsx("span",{className:"text-sm text-gray-400",children:"Click to upload .md, .txt, or .json"}),t.jsx("input",{type:"file",accept:".md,.txt,.json,.markdown",className:"hidden",onChange:L=>{var S;const q=(S=L.target.files)==null?void 0:S[0];if(q){if(!j.name.trim()){const re=q.name.replace(/\.[^/.]+$/,"");A(ee=>({...ee,name:re}))}const G=new FileReader;G.onload=re=>{var ge;const ee=(ge=re.target)==null?void 0:ge.result;A(je=>({...je,content:ee}))},G.readAsText(q)}L.target.value=""}})]})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Content"}),t.jsx("textarea",{value:j.content,onChange:L=>A({...j,content:L.target.value}),placeholder:"Paste content here or upload a file above...",rows:10,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:border-primary-500 font-mono text-sm resize-none"}),j.content&&t.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[j.content.length.toLocaleString()," characters"]})]}),t.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[t.jsx("button",{type:"button",onClick:()=>{x(!1),A({name:"",resource_type:"guardrail",content:""})},className:"px-4 py-2 bg-gray-700 text-gray-300 rounded-lg hover:bg-gray-600",children:"Cancel"}),t.jsx("button",{type:"submit",disabled:!j.name.trim()||!j.content.trim()||u,className:"px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-500 disabled:opacity-50",children:u?"Adding...":"Add Resource"})]})]})]})}),g&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:L=>{L.target===L.currentTarget&&b(!1)},children:t.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:[t.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Import from Library"}),t.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Select a resource from the project library to import into this workflow."}),R.length===0&&I.length===0?t.jsx("div",{className:"text-center py-8",children:t.jsx("p",{className:"text-gray-400",children:a.length===0&&o.length===0?"No resources available in project library":"All resources are already imported"})}):t.jsxs("div",{className:"space-y-4 max-h-96 overflow-y-auto",children:[I.length>0&&t.jsxs("div",{children:[t.jsxs("h4",{className:"text-sm font-medium text-gray-300 mb-2 flex items-center gap-2",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),"Project Resources"]}),t.jsx("div",{className:"space-y-2",children:I.map(L=>t.jsx("button",{onClick:()=>z(L),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:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h4",{className:"text-white font-medium truncate",children:L.name}),t.jsx("p",{className:"text-sm text-gray-400",children:B(L.resource_type)}),L.content&&t.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[(L.content.length/1024).toFixed(1)," KB"]})]}),t.jsx("span",{className:"text-xs bg-emerald-500/20 text-emerald-400 px-2 py-1 rounded ml-2",children:"File"})]})},L.id))})]}),R.length>0&&t.jsxs("div",{children:[t.jsxs("h4",{className:"text-sm font-medium text-gray-300 mb-2 flex items-center gap-2",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"})}),"Shared Resources"]}),t.jsx("div",{className:"space-y-2",children:R.map(L=>t.jsx("button",{onClick:()=>_(L),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:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-white font-medium",children:L.name}),t.jsx("p",{className:"text-sm text-gray-400",children:B(L.resource_type)})]}),L.auto_inherit&&t.jsx("span",{className:"text-xs bg-primary-500/20 text-primary-400 px-2 py-1 rounded",children:"Auto"})]})},L.id))})]})]}),t.jsx("div",{className:"flex justify-end mt-4",children:t.jsx("button",{onClick:()=>b(!1),className:"px-4 py-2 bg-gray-700 text-gray-300 rounded-lg hover:bg-gray-600",children:"Close"})})]})}),v&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:L=>{L.target===L.currentTarget&&k(null)},children:t.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:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-white",children:v.name}),t.jsx("span",{className:"text-sm bg-gray-700 text-gray-400 px-2 py-1 rounded",children:B(v.resource_type)})]}),t.jsx("textarea",{value:T,onChange:L=>N(L.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"}),t.jsxs("div",{className:"flex justify-end space-x-3 mt-4",children:[t.jsx("button",{onClick:()=>k(null),className:"px-4 py-2 bg-gray-700 text-gray-300 rounded-lg hover:bg-gray-600",children:"Cancel"}),t.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 K3({workflow:e,projectSlug:r,onWorkflowUpdate:s,onError:a}){const o=Dr();return t.jsxs("div",{className:"max-w-2xl space-y-6",children:[t.jsxs("div",{className:"card",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-300 uppercase tracking-wide mb-4",children:"Workflow Information"}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-gray-500 mb-1",children:"Workflow ID"}),t.jsx("div",{className:"text-white font-mono text-sm",children:e.id})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-gray-500 mb-1",children:"Status"}),t.jsx("div",{className:"text-white",children:e.status})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-gray-500 mb-1",children:"Current Step"}),t.jsxs("div",{className:"text-white",children:[e.current_step," of ",e.steps.length]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-gray-500 mb-1",children:"Steps"}),t.jsx("div",{className:"text-white",children:e.steps.length})]})]})]}),t.jsxs("div",{className:"card",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-300 uppercase tracking-wide mb-4",children:"Auto-Advance Rules"}),t.jsx("div",{className:"rounded-lg bg-gray-800 border border-gray-700 p-4",children:t.jsxs("div",{className:"flex items-start space-x-3",children:[t.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:t.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"})}),t.jsxs("div",{children:[t.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."}),t.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".'})]})]})})]}),t.jsxs("div",{className:"card border-red-900/50",children:[t.jsx("h3",{className:"text-sm font-medium text-red-400 uppercase tracking-wide mb-4",children:"Danger Zone"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-white font-medium",children:"Reset Workflow"}),t.jsx("p",{className:"text-sm text-gray-500",children:"Reset the workflow to its initial state. All progress will be lost."})]}),t.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"})]}),t.jsx("div",{className:"border-t border-red-900/30"}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-white font-medium",children:"Archive Workflow"}),t.jsx("p",{className:"text-sm text-gray-500",children:"Move this workflow to the archive. You can restore it later."})]}),t.jsx("button",{onClick:()=>{o(`/projects/${r}/workflows/${e.id}`)},className:"px-4 py-2 bg-gray-700 text-gray-300 rounded-lg hover:bg-gray-600",children:"Archive"})]})]})]}),t.jsxs("div",{className:"rounded-lg bg-gray-800/50 border border-gray-700 p-4",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-2",children:"Tips"}),t.jsxs("ul",{className:"text-sm text-gray-400 space-y-2",children:[t.jsxs("li",{className:"flex items-start space-x-2",children:[t.jsx("span",{className:"text-primary-400",children:"•"}),t.jsxs("span",{children:["Use keyboard shortcut ",t.jsx("kbd",{className:"px-1.5 py-0.5 bg-gray-700 rounded text-xs",children:"Cmd+S"})," to save changes quickly"]})]}),t.jsxs("li",{className:"flex items-start space-x-2",children:[t.jsx("span",{className:"text-primary-400",children:"•"}),t.jsxs("span",{children:["Press ",t.jsx("kbd",{className:"px-1.5 py-0.5 bg-gray-700 rounded text-xs",children:"Esc"})," to return to the workflow detail view"]})]}),t.jsxs("li",{className:"flex items-start space-x-2",children:[t.jsx("span",{className:"text-primary-400",children:"•"}),t.jsx("span",{children:"Add a design document to help Claude understand your project requirements"})]}),t.jsxs("li",{className:"flex items-start space-x-2",children:[t.jsx("span",{className:"text-primary-400",children:"•"}),t.jsx("span",{children:"Configure guidelines to set boundaries and coding standards for Claude"})]})]})]})]})}function Q3(){const{slug:e,workflowId:r}=Vr(),s=Dr(),[a,o]=y.useState(null),[c,d]=y.useState(!0),[u,h]=y.useState(null),[p,x]=y.useState(""),[g,b]=y.useState([]),[v,k]=y.useState([]),[T,N]=y.useState([]),[j,A]=y.useState([]),[M,_]=y.useState("overview"),[z,P]=y.useState(!1),[$,V]=y.useState(!1),B=y.useCallback(async()=>{if(!(!e||!r))try{const I=await ga(e,r);o(I),x(I.name),b([...I.steps]),h(null)}catch(I){h(I instanceof Error?I.message:"Failed to load workflow")}finally{d(!1)}},[e,r]),U=y.useCallback(async()=>{if(!(!e||!r||!a))try{const[I,H,W]=await Promise.all([hl(e,a.id),gu(e),kb(e,{include_content:!0})]);k(I),N(H),A(W)}catch(I){h(I instanceof Error?I.message:"Failed to load resources")}},[e,r,a]);y.useEffect(()=>{B()},[B]),y.useEffect(()=>{a&&U()},[a,U]),y.useEffect(()=>{if(!a)return;const I=p!==a.name,H=JSON.stringify(g)!==JSON.stringify(a.steps);V(I||H)},[a,p,g]),y.useEffect(()=>{const I=H=>{$&&(H.preventDefault(),H.returnValue="")};return window.addEventListener("beforeunload",I),()=>window.removeEventListener("beforeunload",I)},[$]);const D=y.useCallback(async()=>{var I,H,W,J,Z,de,E,L,q,S,G,re,ee,ge,je,Le,ve,F,he,ue,Oe,Se,We,qe,tt,ft,Rt,$t,Zt,ar,er,Et,ae,Q,fe,be,Me,Ve,Ye,Ct,Vt,yt,rt,ce,Ae,ie,Fe,dt;if(!(!a||!e)){P(!0),h(null);try{p!==a.name&&await Qb(e,a.id,{name:p});const Ke=new Set(a.steps.map(mt=>mt.id)),vr=new Set(g.filter(mt=>mt.id).map(mt=>mt.id));for(const mt of a.steps)vr.has(mt.id)||await nx(e,a.id,mt.id);const or=[];for(let mt=0;mt<g.length;mt++){const Pe=g[mt];if(!Pe.id||!Ke.has(Pe.id)){const et={name:Pe.name,step_type:Pe.step_type,description:(I=Pe.config)==null?void 0:I.description,skippable:(H=Pe.config)==null?void 0:H.skippable,loop_type:(W=Pe.config)==null?void 0:W.loopType,template:(J=Pe.config)==null?void 0:J.template};Pe.step_type==="autonomous"&&(et.model=(Z=Pe.config)==null?void 0:Z.model,et.timeout=(de=Pe.config)==null?void 0:de.timeout,et.allowed_tools=(E=Pe.config)==null?void 0:E.allowedTools,et.max_iterations=(L=Pe.config)==null?void 0:L.max_iterations,et.cooldown_between_iterations=(q=Pe.config)==null?void 0:q.cooldown_between_iterations,et.max_consecutive_errors=(S=Pe.config)==null?void 0:S.max_consecutive_errors,(re=(G=Pe.config)==null?void 0:G.context_from_steps)!=null&&re.length&&(et.context_from_steps=Pe.config.context_from_steps));const hi=await n1(e,a.id,et);or.push(hi.id)}else{const et=a.steps.find(Ft=>Ft.id===Pe.id);if(et&&(et.name!==Pe.name||et.step_type!==Pe.step_type||((ee=et.config)==null?void 0:ee.description)!==((ge=Pe.config)==null?void 0:ge.description)||((je=et.config)==null?void 0:je.skippable)!==((Le=Pe.config)==null?void 0:Le.skippable)||((ve=et.config)==null?void 0:ve.loopType)!==((F=Pe.config)==null?void 0:F.loopType)||((he=et.config)==null?void 0:he.template)!==((ue=Pe.config)==null?void 0:ue.template)||((Oe=et.config)==null?void 0:Oe.model)!==((Se=Pe.config)==null?void 0:Se.model)||((We=et.config)==null?void 0:We.timeout)!==((qe=Pe.config)==null?void 0:qe.timeout)||JSON.stringify((tt=et.config)==null?void 0:tt.allowedTools)!==JSON.stringify((ft=Pe.config)==null?void 0:ft.allowedTools)||((Rt=et.config)==null?void 0:Rt.max_iterations)!==(($t=Pe.config)==null?void 0:$t.max_iterations)||((Zt=et.config)==null?void 0:Zt.cooldown_between_iterations)!==((ar=Pe.config)==null?void 0:ar.cooldown_between_iterations)||((er=et.config)==null?void 0:er.max_consecutive_errors)!==((Et=Pe.config)==null?void 0:Et.max_consecutive_errors)||((ae=et.config)==null?void 0:ae.customPrompt)!==((Q=Pe.config)==null?void 0:Q.customPrompt)||JSON.stringify((fe=et.config)==null?void 0:fe.context_from_steps)!==JSON.stringify((be=Pe.config)==null?void 0:be.context_from_steps))){const Ft={name:Pe.name,step_type:Pe.step_type,description:(Me=Pe.config)==null?void 0:Me.description,skippable:(Ve=Pe.config)==null?void 0:Ve.skippable,loop_type:(Ye=Pe.config)==null?void 0:Ye.loopType,template:((Ct=Pe.config)==null?void 0:Ct.template)||""};Pe.step_type==="autonomous"&&(Ft.model=(Vt=Pe.config)==null?void 0:Vt.model,Ft.timeout=(yt=Pe.config)==null?void 0:yt.timeout,Ft.allowed_tools=(rt=Pe.config)==null?void 0:rt.allowedTools,Ft.max_iterations=(ce=Pe.config)==null?void 0:ce.max_iterations,Ft.cooldown_between_iterations=(Ae=Pe.config)==null?void 0:Ae.cooldown_between_iterations,Ft.max_consecutive_errors=(ie=Pe.config)==null?void 0:ie.max_consecutive_errors,((Fe=Pe.config)==null?void 0:Fe.customPrompt)!==void 0&&(Ft.custom_prompt=Pe.config.customPrompt||""),((dt=Pe.config)==null?void 0:dt.context_from_steps)!==void 0&&(Ft.context_from_steps=Pe.config.context_from_steps)),await rx(e,a.id,Pe.id,Ft)}or.push(Pe.id)}}const an=a.steps.map(mt=>mt.id);JSON.stringify(an)!==JSON.stringify(or)&&await o1(e,a.id,or),await B(),V(!1)}catch(Ke){h(Ke instanceof Error?Ke.message:"Failed to save workflow")}finally{P(!1)}}},[a,e,p,g,B]),R=y.useCallback(()=>{$&&!window.confirm("You have unsaved changes. Are you sure you want to leave?")||s(`/projects/${e}/workflows/${r}`)},[$,s,e,r]);if(y.useEffect(()=>{const I=H=>{document.querySelector(".fixed.inset-0.bg-black\\/50")||((H.metaKey||H.ctrlKey)&&H.key==="s"&&(H.preventDefault(),$&&!z&&D()),H.key==="Escape"&&R())};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[$,z,D,R]),c)return t.jsx("div",{className:"p-6",children:t.jsx("div",{className:"text-gray-400",children:"Loading workflow..."})});if(u&&!a)return t.jsx("div",{className:"p-6",children:t.jsxs("div",{className:"card bg-red-900/20 border border-red-800",children:[t.jsx("h2",{className:"text-lg font-semibold text-red-400 mb-2",children:"Error"}),t.jsx("p",{className:"text-gray-300",children:u}),t.jsx(Re,{to:`/projects/${e}`,className:"btn-secondary mt-4 inline-block",children:"Back to Project"})]})});if(!a)return t.jsx("div",{className:"p-6",children:t.jsx("div",{className:"card",children:t.jsx("p",{className:"text-gray-400",children:"Workflow not found"})})});const X=[{key:"overview",label:"Overview"},{key:"steps",label:"Steps"},{key:"resources",label:"Resources"},{key:"settings",label:"Settings"}];return t.jsxs("div",{className:"min-h-screen",children:[t.jsx(P3,{workflowName:p,onBack:R,onSave:D,saving:z,dirty:$}),u&&t.jsx("div",{className:"mx-6 mt-4 p-4 rounded-lg bg-red-900/20 border border-red-800",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("p",{className:"text-red-400 text-sm",children:u}),t.jsx("button",{onClick:()=>h(null),className:"text-red-400 hover:text-red-300",children:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),t.jsx("div",{className:"border-b border-gray-700 px-6",children:t.jsx("nav",{className:"flex space-x-8",children:X.map(I=>t.jsxs("button",{onClick:()=>_(I.key),className:`pb-4 px-1 border-b-2 font-medium text-sm transition-colors ${M===I.key?"border-primary-500 text-primary-400":"border-transparent text-gray-400 hover:text-gray-300 hover:border-gray-500"}`,children:[I.label,I.key==="steps"&&` (${g.length})`,I.key==="resources"&&v.length>0&&` (${v.length})`]},I.key))})}),t.jsxs("div",{className:"p-6",children:[M==="overview"&&t.jsx(M3,{workflow:a,workflowName:p,onNameChange:I=>x(I),steps:g,resources:v,onViewResources:()=>_("resources")}),M==="steps"&&t.jsx(Y3,{projectSlug:e,workflowId:a.id,steps:g,onStepsChange:I=>b(I),onError:I=>h(I)}),M==="resources"&&t.jsx(G3,{projectSlug:e,workflowId:a.id,resources:v,projectResources:T,filesystemResources:j,onResourcesChange:U,onError:I=>h(I)}),M==="settings"&&t.jsx(K3,{workflow:a,projectSlug:e,onWorkflowUpdate:B,onError:I=>h(I)})]})]})}function J3({projectId:e,onAccountChange:r}){const[s,a]=y.useState([]),[o,c]=y.useState(null),[d,u]=y.useState(!0),[h,p]=y.useState(!1),[x,g]=y.useState(null),[b,v]=y.useState("default"),[k,T]=y.useState(!0),N=async()=>{u(!0);try{const[B,U,D]=await Promise.all([Zf(),Wb(e),Ub(e)]);a(B),c(D),U?(v(U.account_id),T(U.allow_fallback)):(v("default"),T(!0)),g(null)}catch{g("Failed to load account settings")}finally{u(!1)}};y.useEffect(()=>{N()},[e]);const j=async B=>{const U=B==="default"?"default":parseInt(B,10);v(U),p(!0),g(null);try{U==="default"?await Hb(e):await ip(e,{account_id:U,allow_fallback:k}),await N(),r==null||r()}catch(D){g(D instanceof Error?D.message:"Failed to update account"),N()}finally{p(!1)}},A=async B=>{if(T(B),b!=="default"){p(!0);try{await ip(e,{account_id:b,allow_fallback:B}),r==null||r()}catch{g("Failed to update fallback setting"),T(!B)}finally{p(!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",z=B=>{if(!B)return"";const U=new Date(B),D=new Date,R=U.toDateString()===D.toDateString(),X=new Date(D);X.setDate(X.getDate()+1);const I=U.toDateString()===X.toDateString(),H=U.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return R?H:I?`tomorrow ${H}`:U.toLocaleDateString([],{month:"short",day:"numeric"})},P=B=>B?t.jsxs("span",{className:`text-xs ${_(B.five_hour)}`,children:["5h: ",Math.round(B.five_hour),"% · 7d: ",Math.round(B.seven_day),"%"]}):null,$=()=>s.find(B=>B.is_default);if(d)return t.jsxs("div",{className:"card animate-pulse",children:[t.jsx("div",{className:"h-6 bg-gray-700 rounded w-1/3 mb-4"}),t.jsx("div",{className:"h-4 bg-gray-700 rounded w-1/2"})]});if(s.length===0)return t.jsxs("div",{className:"card",children:[t.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Claude Account"}),t.jsxs("div",{className:"text-center py-6",children:[t.jsx("svg",{className:"w-10 h-10 text-gray-600 mx-auto mb-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("p",{className:"text-gray-400 mb-3",children:"No Claude accounts connected"}),t.jsx(Re,{to:"/settings",className:"text-primary-400 hover:text-primary-300 text-sm",children:"Connect an account in Settings →"})]})]});const V=$();return t.jsxs("div",{className:"card",children:[t.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Claude Account"}),x&&t.jsxs("div",{className:"mb-4 p-3 bg-red-900/30 border border-red-800 rounded text-red-400 text-sm",children:[x,t.jsx("button",{onClick:()=>g(null),className:"ml-2 text-red-300 hover:text-red-200",children:"×"})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-gray-400 mb-2",children:"Account for this project"}),t.jsxs("select",{value:b,onChange:B=>j(B.target.value),disabled:h,className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white disabled:opacity-50",children:[t.jsxs("option",{value:"default",children:["Use default account",V&&` (${V.email})`]}),s.map(B=>t.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&&t.jsxs("div",{className:"p-3 bg-gray-700/50 rounded border border-gray-600",children:[t.jsx("p",{className:"text-sm text-gray-400 mb-1",children:"Currently using:"}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-white",children:V.email}),V.usage&&P(V.usage)]})]}),t.jsxs("label",{className:"flex items-start space-x-3 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:k,onChange:B=>A(B.target.checked),disabled:h,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"}),t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-300",children:"Allow fallback when account reaches usage limit"}),t.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"})]})]}),o&&t.jsxs("div",{className:"pt-4 border-t border-gray-700",children:[t.jsx("p",{className:"text-sm text-gray-400 mb-2",children:"Effective Account"}),t.jsxs("div",{className:"p-3 bg-gray-800 rounded border border-gray-700",children:[t.jsx("div",{className:"flex items-center justify-between mb-2",children:t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("span",{className:"text-white font-medium",children:o.email}),o.subscription_type&&t.jsxs("span",{className:"text-xs text-gray-500 capitalize",children:["· ",o.subscription_type]})]})}),o.usage&&t.jsxs("div",{className:"flex gap-4 mt-3",children:[t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"text-gray-400 text-xs",children:"5h"}),t.jsxs("span",{className:`text-xs font-medium ${_(o.usage.five_hour)}`,children:[Math.round(o.usage.five_hour),"%"]})]}),t.jsx("div",{className:"h-1.5 bg-gray-600 rounded-full overflow-hidden",children:t.jsx("div",{className:`h-full rounded-full ${M(o.usage.five_hour)}`,style:{width:`${Math.min(100,o.usage.five_hour)}%`}})}),o.usage.five_hour_resets_at&&t.jsxs("p",{className:"text-gray-500 text-xs mt-0.5",children:["resets ",z(o.usage.five_hour_resets_at)]})]}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"text-gray-400 text-xs",children:"7d"}),t.jsxs("span",{className:`text-xs font-medium ${_(o.usage.seven_day)}`,children:[Math.round(o.usage.seven_day),"%"]})]}),t.jsx("div",{className:"h-1.5 bg-gray-600 rounded-full overflow-hidden",children:t.jsx("div",{className:`h-full rounded-full ${M(o.usage.seven_day)}`,style:{width:`${Math.min(100,o.usage.seven_day)}%`}})}),o.usage.seven_day_resets_at&&t.jsxs("p",{className:"text-gray-500 text-xs mt-0.5",children:["resets ",z(o.usage.seven_day_resets_at)]})]})]})]})]}),t.jsx("div",{className:"pt-2",children:t.jsx(Re,{to:"/settings",className:"text-sm text-primary-400 hover:text-primary-300",children:"Manage accounts in Settings →"})})]})]})}function X3(){const{slug:e}=Vr(),[r,s]=Hw(),{selectedProject:a,setSelectedProject:o}=sn(),[c,d]=y.useState([]),[u,h]=y.useState(null),[p,x]=y.useState(!0),[g,b]=y.useState(null),[v,k]=y.useState(!1),T=r.get("tab"),j=T&&["auth","resources","defaults"].includes(T)?T:"auth",[A,M]=y.useState(j),_=re=>{M(re),s({tab:re})},[z,P]=y.useState(!1),[$,V]=y.useState({name:"",resource_type:"guardrail",content:"",description:"",auto_inherit:!0}),[B,U]=y.useState(!1),[D,R]=y.useState(null),[X,I]=y.useState(""),[H,W]=y.useState(!1),J=y.useCallback(async()=>{if(e){x(!0),b(null);try{const[re,ee,ge]=await Promise.all([ys(e),gu(e),k1(e)]);o(re),d(ee),h(ge)}catch(re){b(re instanceof Error?re.message:"Failed to load settings")}finally{x(!1)}}},[e,o]);y.useEffect(()=>{J()},[J]);const Z=async re=>{if(re.preventDefault(),!(!e||!$.name.trim()||!$.content.trim())){U(!0);try{await b1(e,{name:$.name.trim(),resource_type:$.resource_type,content:$.content.trim(),description:$.description.trim()||void 0,auto_inherit:$.auto_inherit}),V({name:"",resource_type:"guardrail",content:"",description:"",auto_inherit:!0}),P(!1),J()}catch(ee){b(ee instanceof Error?ee.message:"Failed to add resource")}finally{U(!1)}}},de=async()=>{if(!(!e||!D)){W(!0);try{await cp(e,D.id,{content:X}),R(null),J()}catch(re){b(re instanceof Error?re.message:"Failed to save resource")}finally{W(!1)}}},E=async re=>{if(e)try{await cp(e,re.id,{auto_inherit:!re.auto_inherit}),J()}catch(ee){b(ee instanceof Error?ee.message:"Failed to update resource")}},L=async re=>{if(e&&confirm(`Delete "${re.name}"? This cannot be undone.`))try{await j1(e,re.id),J()}catch(ee){b(ee instanceof Error?ee.message:"Failed to delete resource")}},q=async(re,ee)=>{if(!(!e||!u)){h({...u,[re]:ee}),k(!0);try{const ge=await N1(e,{[re]:ee});h(ge)}catch(ge){h({...u,[re]:!ee}),b(ge instanceof Error?ge.message:"Failed to save setting")}finally{k(!1)}}},S=re=>{switch(re){case"design_doc":return"Design Document";case"guardrail":return"Guardrail";case"prompt":return"Prompt Template";default:return re}},G=[{key:"auth",label:"Authentication"},{key:"resources",label:"Shared Resources"},{key:"defaults",label:"Defaults"}];return p?t.jsx("div",{className:"p-6",children:t.jsx("div",{className:"text-gray-400",children:"Loading settings..."})}):t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[t.jsx(Re,{to:"/",className:"hover:text-white",children:"Dashboard"}),t.jsx("span",{children:"/"}),t.jsx(Re,{to:`/projects/${e}`,className:"hover:text-white",children:(a==null?void 0:a.name)||e}),t.jsx("span",{children:"/"}),t.jsx("span",{className:"text-white",children:"Settings"})]}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h1",{className:"text-3xl font-bold text-white mb-1",children:"Project Settings"}),t.jsx("p",{className:"text-gray-400",children:"Configure authentication and shared resources for all workflows."})]}),g&&t.jsx("div",{className:"mb-4 p-3 bg-red-900/30 border border-red-800 rounded text-red-400",children:g}),t.jsx("div",{className:"flex space-x-1 mb-6 border-b border-gray-700",children:G.map(re=>t.jsx("button",{onClick:()=>_(re.key),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${A===re.key?"border-primary-500 text-white":"border-transparent text-gray-400 hover:text-gray-300"}`,children:re.label},re.key))}),A==="auth"&&a&&t.jsx("div",{className:"space-y-6",children:t.jsx(J3,{projectId:a.id})}),A==="resources"&&t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-white",children:"Shared Resource Library"}),t.jsx("p",{className:"text-sm text-gray-400",children:"Resources here can be imported into any workflow."})]}),t.jsxs("button",{onClick:()=>P(!0),className:"flex items-center space-x-2 px-4 py-2 bg-primary-600 text-white rounded hover:bg-primary-500",children:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),t.jsx("span",{children:"Add Shared Resource"})]})]}),c.length===0?t.jsxs("div",{className:"card text-center py-8",children:[t.jsx("p",{className:"text-gray-400",children:"No shared resources yet"}),t.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Add resources to the library to share across workflows."})]}):t.jsx("div",{className:"space-y-3",children:c.map(re=>t.jsxs("div",{className:"card flex items-start justify-between",children:[t.jsxs("div",{className:"flex items-start space-x-4",children:[t.jsx("div",{className:"p-2 rounded bg-primary-500/20 text-primary-400",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-medium text-white",children:re.name}),t.jsx("div",{className:"flex items-center space-x-4 text-sm text-gray-400 mt-1",children:t.jsx("span",{children:S(re.resource_type)})}),re.description&&t.jsx("p",{className:"text-sm text-gray-500 mt-2",children:re.description})]})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("button",{onClick:()=>E(re),className:`px-3 py-1 text-sm rounded ${re.auto_inherit?"bg-primary-600/20 text-primary-400":"bg-gray-700 text-gray-500"}`,children:re.auto_inherit?"Auto-inherit":"Manual"}),t.jsx("button",{onClick:()=>{R(re),I(re.content||"")},className:"px-3 py-1 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600",children:"View"}),t.jsx("button",{onClick:()=>L(re),className:"px-3 py-1 text-sm rounded bg-red-900/30 text-red-400 hover:bg-red-900/50",children:"Delete"})]})]},re.id))}),t.jsx("div",{className:"p-4 bg-gray-800/50 border border-gray-700 rounded",children:t.jsxs("div",{className:"flex items-start space-x-3",children:[t.jsx("svg",{className:"w-5 h-5 text-yellow-500 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsxs("div",{className:"text-sm text-gray-400",children:[t.jsx("p",{className:"font-medium text-gray-300 mb-1",children:"About Auto-inherit"}),t.jsx("p",{children:'Resources marked as "auto-inherit" are automatically added to new workflows. This is useful for company-wide guardrails or standards.'})]})]})})]}),A==="defaults"&&t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"card",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h2",{className:"text-lg font-semibold text-white",children:"Default Settings for New Workflows"}),v&&t.jsx("span",{className:"text-sm text-gray-400",children:"Saving..."})]}),t.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"These settings are applied to new workflows by default."}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:(u==null?void 0:u.auto_inherit_guardrails)??!0,onChange:re=>q("auto_inherit_guardrails",re.target.checked),disabled:v,className:"w-4 h-4 rounded bg-gray-700 border-gray-600 text-primary-500 focus:ring-primary-500 cursor-pointer disabled:opacity-50"}),t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-300",children:"Auto-inherit shared guardrails"}),t.jsx("p",{className:"text-xs text-gray-500",children:"New workflows automatically receive guardrails marked as auto-inherit"})]})]}),t.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:(u==null?void 0:u.require_design_doc)??!1,onChange:re=>q("require_design_doc",re.target.checked),disabled:v,className:"w-4 h-4 rounded bg-gray-700 border-gray-600 text-primary-500 focus:ring-primary-500 cursor-pointer disabled:opacity-50"}),t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-300",children:"Require design document before implementation"}),t.jsx("p",{className:"text-xs text-gray-500",children:"Blocks autonomous steps until a design document is attached"})]})]}),t.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:(u==null?void 0:u.architecture_first_mode)??!1,onChange:re=>q("architecture_first_mode",re.target.checked),disabled:v,className:"w-4 h-4 rounded bg-gray-700 border-gray-600 text-primary-500 focus:ring-primary-500 cursor-pointer disabled:opacity-50"}),t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-300",children:"Enable architecture-first mode"}),t.jsx("p",{className:"text-xs text-gray-500",children:"Prioritizes planning and design steps in new workflows"})]})]})]})]}),t.jsx("div",{className:"p-4 bg-gray-800/50 border border-gray-700 rounded",children:t.jsxs("div",{className:"flex items-start space-x-3",children:[t.jsx("svg",{className:"w-5 h-5 text-green-400 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsxs("div",{className:"text-sm text-gray-400",children:[t.jsx("p",{className:"font-medium text-gray-300 mb-1",children:"Settings Auto-Save"}),t.jsx("p",{children:"Changes are saved automatically when you toggle a setting."})]})]})})]}),z&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-gray-800 rounded-lg p-6 w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[t.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"Add Shared Resource"}),t.jsxs("form",{onSubmit:Z,className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Resource Type"}),t.jsxs("select",{value:$.resource_type,onChange:re=>V({...$,resource_type:re.target.value}),className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white",children:[t.jsx("option",{value:"guardrail",children:"Guardrail"}),t.jsx("option",{value:"prompt",children:"Prompt Template"}),t.jsx("option",{value:"design_doc",children:"Design Template"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Name"}),t.jsx("input",{type:"text",value:$.name,onChange:re=>V({...$,name:re.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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Description (optional)"}),t.jsx("input",{type:"text",value:$.description,onChange:re=>V({...$,description:re.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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Content"}),t.jsx("textarea",{value:$.content,onChange:re=>V({...$,content:re.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"})]}),t.jsxs("label",{className:"flex items-center space-x-3",children:[t.jsx("input",{type:"checkbox",checked:$.auto_inherit,onChange:re=>V({...$,auto_inherit:re.target.checked}),className:"w-4 h-4 rounded bg-gray-700 border-gray-600 text-primary-500 focus:ring-primary-500"}),t.jsx("span",{className:"text-gray-300",children:"Auto-add to new workflows"})]}),t.jsxs("div",{className:"flex justify-end space-x-3",children:[t.jsx("button",{type:"button",onClick:()=>P(!1),className:"px-4 py-2 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600",children:"Cancel"}),t.jsx("button",{type:"submit",disabled:B||!$.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:B?"Adding...":"Add Resource"})]})]})]})}),D&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-gray-800 rounded-lg p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h2",{className:"text-xl font-bold text-white",children:D.name}),t.jsx("span",{className:"text-sm bg-gray-700 text-gray-400 px-2 py-1 rounded",children:S(D.resource_type)})]}),t.jsx("textarea",{value:X,onChange:re=>I(re.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"}),t.jsxs("div",{className:"flex justify-end space-x-3 mt-4",children:[t.jsx("button",{onClick:()=>R(null),className:"px-4 py-2 text-sm rounded bg-gray-700 text-gray-300 hover:bg-gray-600",children:"Cancel"}),t.jsx("button",{onClick:de,disabled:H,className:"px-4 py-2 text-sm rounded bg-primary-600 text-white hover:bg-primary-500 disabled:opacity-50",children:H?"Saving...":"Save Changes"})]})]})})]})}function Yp(){const{slug:e}=Vr(),{selectedProject:r,setSelectedProject:s}=sn(),[a,o]=y.useState([]),[c,d]=y.useState(!0),[u,h]=y.useState(null),[p,x]=y.useState(null),[g,b]=y.useState([]),[v,k]=y.useState(!1),[T,N]=y.useState(null),j=y.useCallback(async()=>{if(e){d(!0),h(null);try{const _=await db(e);o(_)}catch(_){h(_ instanceof Error?_.message:"Failed to load runs")}finally{d(!1)}}},[e]);y.useEffect(()=>{if(!e)return;async function _(){try{const z=await ys(e);s(z)}catch{}}_(),j()},[e,s,j]);const A=async _=>{if(p===_){x(null),b([]);return}x(_),k(!0);try{const z=await ub(e,_);b(z.sessions)}catch{b([])}finally{k(!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 t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[t.jsx(Re,{to:"/",className:"hover:text-white",children:"Dashboard"}),t.jsx("span",{children:"/"}),t.jsx(Re,{to:`/projects/${e}`,className:"hover:text-white",children:(r==null?void 0:r.name)||e}),t.jsx("span",{children:"/"}),t.jsx("span",{className:"text-white",children:"Run History"})]}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h1",{className:"text-3xl font-bold text-white mb-1",children:"Run History"}),t.jsxs("p",{className:"text-gray-400",children:[a.length," total runs"]})]}),T&&t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-gray-800 rounded-lg w-full max-w-4xl max-h-[80vh] flex flex-col",children:[t.jsxs("div",{className:"p-4 border-b border-gray-700 flex items-center justify-between",children:[t.jsx("h3",{className:"text-lg font-semibold text-white",children:"Session Output"}),t.jsx("button",{onClick:()=>N(null),className:"text-gray-400 hover:text-white",children:t.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(rg,{projectSlug:e,sessionId:T,enabled:!0})})]})}),u&&t.jsx("div",{className:"mb-4 p-3 bg-red-900/30 border border-red-800 rounded text-red-400",children:u}),c?t.jsx("div",{className:"text-gray-400",children:"Loading runs..."}):a.length===0?t.jsxs("div",{className:"card text-center py-8",children:[t.jsx("p",{className:"text-gray-400",children:"No runs yet"}),t.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Start a loop to create run history"})]}):t.jsx("div",{className:"space-y-2",children:a.map(_=>t.jsxs("div",{className:"card",children:[t.jsxs("div",{className:"flex items-center justify-between cursor-pointer",onClick:()=>A(_.id),children:[t.jsxs("div",{className:"flex items-center space-x-4",children:[t.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${M[_.status]||"bg-gray-600 text-gray-300"}`,children:_.status}),t.jsx("span",{className:"font-medium text-white",children:_.loop_name})]}),t.jsxs("div",{className:"flex items-center space-x-4 text-sm text-gray-400",children:[t.jsxs("span",{children:[_.iterations_completed," iterations"]}),t.jsxs("span",{children:[_.items_processed," items"]}),t.jsx("span",{children:Wn(_.started_at)}),t.jsx("svg",{className:`w-5 h-5 transition-transform ${p===_.id?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),p===_.id&&t.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-700",children:[v?t.jsx("div",{className:"text-gray-400 text-sm",children:"Loading sessions..."}):g.length===0?t.jsx("div",{className:"text-gray-500 text-sm",children:"No sessions recorded"}):t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-sm font-medium text-gray-300 mb-2",children:"Sessions"}),g.map(z=>t.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-700 rounded",children:[t.jsxs("div",{className:"flex items-center space-x-4",children:[t.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${M[z.status]||"bg-gray-600 text-gray-300"}`,children:z.status}),t.jsxs("span",{className:"text-sm text-gray-300",children:["Iteration ",z.iteration]}),z.mode&&t.jsxs("span",{className:"text-sm text-gray-400",children:["Mode: ",z.mode]})]}),t.jsxs("div",{className:"flex items-center space-x-4",children:[z.duration_seconds!==void 0&&t.jsxs("span",{className:"text-sm text-gray-400",children:[z.duration_seconds.toFixed(1),"s"]}),t.jsx("button",{onClick:P=>{P.stopPropagation(),N(z.session_id)},className:"text-xs px-2 py-1 rounded bg-primary-600 text-white hover:bg-primary-500",children:"View Output"})]})]},z.session_id))]}),t.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-600 text-xs text-gray-500",children:[t.jsxs("div",{children:["Run ID: ",_.id]}),_.ended_at&&t.jsxs("div",{children:["Ended: ",Wn(_.ended_at)]})]})]})]},_.id))})]})}function Z3({onAccountChange:e}){const[r,s]=y.useState([]),[a,o]=y.useState(!0),[c,d]=y.useState(null),[u,h]=y.useState(!1),[p,x]=y.useState(null),[g,b]=y.useState(new Set),v=y.useRef(null),k=y.useRef(null),T=y.useRef(new Set),N=y.useRef(!0),j=async(R=!1)=>{try{const X=await Zf(!0);if(s(X),d(null),R){const I=Date.now()/1e3,H=300;X.some(J=>!J.usage||!J.usage_cached_at||I-J.usage_cached_at>H)&&Fb().then(()=>j(!1)).catch(()=>{})}}catch{d("Failed to load accounts")}finally{o(!1)}};y.useEffect(()=>{N.current=!0,j(!0);const R=setInterval(()=>j(!1),3e4);return()=>{N.current=!1,clearInterval(R),v.current&&clearInterval(v.current),k.current&&clearTimeout(k.current)}},[]),y.useEffect(()=>{if(a||r.length===0)return;const R=Date.now()/1e3-300,X=r.filter(I=>!(T.current.has(I.id)||I.last_validated_at&&I.last_validated_at>R||I.is_expired||!I.is_active));X.length!==0&&X.forEach(async I=>{if(T.current.add(I.id),!!N.current){b(H=>new Set(H).add(I.id));try{await Ob(I.id)}catch{}finally{N.current&&(b(H=>{const W=new Set(H);return W.delete(I.id),W}),await j(!1))}}})},[a,r]);const A=async R=>{h(!0),d(null);try{const X=await Ib(R);if(!X.success||!X.flow_id){d(X.error||"Failed to start login"),h(!1);return}const I=X.flow_id;v.current=window.setInterval(async()=>{try{const H=await Mb(I);if(H.status==="completed"&&H.result){v.current&&clearInterval(v.current),k.current&&clearTimeout(k.current);const W=H.result;if(!W.success){d(W.error||"OAuth flow failed"),h(!1);return}W.email_mismatch&&W.message&&d(`⚠️ ${W.message}`),await j(),h(!1),e==null||e()}else H.status==="error"?(v.current&&clearInterval(v.current),k.current&&clearTimeout(k.current),d(H.error||"OAuth flow failed"),h(!1)):H.status==="not_found"&&(v.current&&clearInterval(v.current),k.current&&clearTimeout(k.current),d("OAuth flow expired. Please try again."),h(!1))}catch{}},1e3),k.current=window.setTimeout(()=>{v.current&&clearInterval(v.current),h(!1),d("Account linking timed out. Please try again.")},12e4)}catch{d("Failed to start account linking"),h(!1)}},M=async R=>{const X=r.filter(H=>H.id!==R.id).length>0;if(R.is_default&&X){d("Cannot delete default account. Set another account as default first.");return}const I=R.projects_using>0?`Remove ${R.email}? ${R.projects_using} project(s) will need to use default.`:`Remove ${R.email}?`;if(window.confirm(I)){x(R.id);try{await $b(R.id),await j(),e==null||e()}catch(H){const W=H instanceof Error?H.message:"Failed to remove account";d(W)}finally{x(null)}}},_=async R=>{x(R);try{await Db(R),await j(),e==null||e()}catch{d("Failed to set default account")}finally{x(null)}},z=async R=>{x(R);try{const X=await Bb(R);X.success?await j():d(X.message||"Failed to refresh token")}catch{d("Failed to refresh token")}finally{x(null)}},P=async R=>{x(R);try{await zb(R),await j()}catch{}finally{x(null)}},$=async R=>{x(R.id);try{await Rb(R.id,{is_active:!R.is_active}),await j(),e==null||e()}catch{d("Failed to update account")}finally{x(null)}},V=R=>R>=90?"bg-red-500":R>=71?"bg-yellow-500":"bg-green-500",B=R=>R>=90?"text-red-400":R>=71?"text-yellow-400":"text-green-400",U=R=>{if(!R)return"";const X=new Date(R),I=new Date,H=X.toDateString()===I.toDateString(),W=new Date(I);W.setDate(W.getDate()+1);const J=X.toDateString()===W.toDateString(),Z=X.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return H?Z:J?`tomorrow ${Z}`:X.toLocaleDateString([],{month:"short",day:"numeric"})},D=R=>{if(!R)return"never";const X=Date.now()-R*1e3,I=Math.floor(X/6e4);return I<1?"just now":I<60?`${I}m ago`:`${Math.floor(I/60)}h ago`};return a?t.jsxs("div",{className:"card animate-pulse",children:[t.jsx("div",{className:"h-6 bg-gray-700 rounded w-1/3 mb-4"}),t.jsx("div",{className:"h-4 bg-gray-700 rounded w-1/2"})]}):r.length===0?t.jsx("div",{className:"card",children:t.jsxs("div",{className:"text-center py-8",children:[t.jsx("svg",{className:"w-12 h-12 text-gray-600 mx-auto mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Claude accounts connected"}),t.jsx("p",{className:"text-gray-400 mb-4",children:"Connect your Claude account to start running workflows automatically."}),t.jsx("button",{onClick:()=>A(),disabled:u,className:"px-4 py-2 bg-primary-600 text-white rounded hover:bg-primary-500 disabled:opacity-50",children:u?"Waiting for browser...":"+ Connect Account"})]})}):t.jsxs("div",{className:"card",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h2",{className:"text-lg font-semibold text-white",children:"Claude Accounts"}),t.jsxs("button",{onClick:()=>A(),disabled:u,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:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),t.jsx("span",{children:u?"Waiting...":"Add Account"})]})]}),c&&t.jsxs("div",{className:`mb-4 p-3 rounded text-sm ${c.startsWith("⚠️")?"bg-yellow-900/30 border border-yellow-800 text-yellow-400":"bg-red-900/30 border border-red-800 text-red-400"}`,children:[c,t.jsx("button",{onClick:()=>d(null),className:`ml-2 ${c.startsWith("⚠️")?"text-yellow-300 hover:text-yellow-200":"text-red-300 hover:text-red-200"}`,children:"×"})]}),t.jsx("div",{className:"space-y-3",children:r.map(R=>{var X;return t.jsxs("div",{className:`p-4 rounded-lg border ${R.is_expired?"bg-yellow-900/10 border-yellow-800/50":R.validation_status==="invalid"?"bg-orange-900/10 border-orange-800/50":R.is_active?"bg-gray-700/50 border-gray-600":"bg-gray-800/50 border-gray-700 opacity-60"}`,children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${g.has(R.id)?"bg-blue-500 animate-pulse":R.is_expired||R.validation_status==="invalid"?"bg-yellow-500":R.is_active?"bg-green-500":"bg-gray-500"}`}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("span",{className:"text-white font-medium text-base",children:R.email}),R.is_default&&t.jsx("span",{className:"px-1.5 py-0.5 bg-primary-600/30 text-primary-400 text-xs rounded font-medium",children:"DEFAULT"}),g.has(R.id)&&t.jsx("span",{className:"px-1.5 py-0.5 bg-blue-600/30 text-blue-400 text-xs rounded font-medium",children:"CHECKING..."}),R.validation_status==="invalid"&&!R.is_expired&&!g.has(R.id)&&t.jsx("span",{className:"px-1.5 py-0.5 bg-orange-600/30 text-orange-400 text-xs rounded font-medium",children:"TOKEN INVALID"}),R.is_expired&&t.jsx("span",{className:"px-1.5 py-0.5 bg-yellow-600/30 text-yellow-400 text-xs rounded font-medium",children:"EXPIRED"}),!R.is_active&&t.jsx("span",{className:"px-1.5 py-0.5 bg-gray-600/30 text-gray-400 text-xs rounded font-medium",children:"DISABLED"})]}),t.jsxs("div",{className:"text-gray-400 text-sm mt-0.5 flex items-center gap-2",children:[R.subscription_type?t.jsxs("span",{className:"capitalize font-medium text-gray-300",children:[R.subscription_type,((X=R.rate_limit_tier)==null?void 0:X.includes("20x"))&&" 20x"]}):R.usage?t.jsx("span",{className:"text-gray-400",children:"Claude"}):t.jsx("span",{className:"text-gray-500",children:"Not verified"}),t.jsx("span",{className:"text-gray-600",children:"·"}),t.jsxs("span",{children:[R.projects_using," project",R.projects_using!==1?"s":""]}),R.display_name&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-gray-600",children:"·"}),t.jsx("span",{className:"text-gray-500",children:R.display_name})]})]})]})]}),t.jsxs("div",{className:"flex items-center space-x-1",children:[R.is_expired||R.validation_status==="invalid"&&!g.has(R.id)?t.jsx("button",{onClick:()=>A(R.email),disabled:u,className:`px-2 py-1 text-sm text-white rounded disabled:opacity-50 ${R.is_expired?"bg-yellow-600 hover:bg-yellow-500":"bg-orange-600 hover:bg-orange-500"}`,children:"Re-auth"}):t.jsxs(t.Fragment,{children:[!R.is_default&&R.is_active&&t.jsx("button",{onClick:()=>_(R.id),disabled:p===R.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"}),t.jsx("button",{onClick:()=>z(R.id),disabled:p===R.id,className:"p-1 text-gray-400 hover:text-white hover:bg-gray-600 rounded",title:"Refresh token",children:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.jsx("button",{onClick:()=>A(R.email),disabled:u,className:"px-2 py-1 text-xs text-gray-400 hover:text-white hover:bg-gray-600 rounded",title:"Re-authenticate this account",children:"Re-auth"}),t.jsx("button",{onClick:()=>$(R),disabled:p===R.id,className:"p-1 text-gray-400 hover:text-white hover:bg-gray-600 rounded",title:R.is_active?"Disable account":"Enable account",children:R.is_active?t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 9v6m4-6v6m7-3a9 9 0 11-18 0 9 9 0 0118 0z"})}):t.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[t.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"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})]})})]}),t.jsx("button",{onClick:()=>M(R),disabled:p===R.id,className:"p-1 text-gray-400 hover:text-red-400 hover:bg-red-900/30 rounded",title:"Remove account",children:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})})]})]}),!R.is_expired&&R.validation_status!=="invalid"&&t.jsx("div",{className:"mt-3 pt-3 border-t border-gray-600/50",children:R.usage?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex gap-6",children:[t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"text-gray-400 text-xs font-medium",children:"5-hour limit"}),t.jsxs("span",{className:`text-sm font-semibold ${B(R.usage.five_hour)}`,children:[Math.round(R.usage.five_hour),"% used"]})]}),t.jsx("div",{className:"h-2 bg-gray-600 rounded-full overflow-hidden",children:t.jsx("div",{className:`h-full rounded-full transition-all ${V(R.usage.five_hour)}`,style:{width:`${Math.min(100,R.usage.five_hour)}%`}})}),R.usage.five_hour_resets_at&&t.jsxs("p",{className:"text-gray-500 text-xs mt-1",children:["Resets ",U(R.usage.five_hour_resets_at)]})]}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"text-gray-400 text-xs font-medium",children:"7-day limit"}),t.jsxs("span",{className:`text-sm font-semibold ${B(R.usage.seven_day)}`,children:[Math.round(R.usage.seven_day),"% used"]})]}),t.jsx("div",{className:"h-2 bg-gray-600 rounded-full overflow-hidden",children:t.jsx("div",{className:`h-full rounded-full transition-all ${V(R.usage.seven_day)}`,style:{width:`${Math.min(100,R.usage.seven_day)}%`}})}),R.usage.seven_day_resets_at&&t.jsxs("p",{className:"text-gray-500 text-xs mt-1",children:["Resets ",U(R.usage.seven_day_resets_at)]})]})]}),R.usage_cached_at&&t.jsxs("button",{onClick:()=>P(R.id),disabled:p===R.id,className:"text-gray-500 text-xs mt-2 hover:text-gray-400 flex items-center gap-1",children:[t.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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 ",D(R.usage_cached_at)]})]}):t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-gray-500 text-sm",children:"Usage data not available"}),t.jsxs("button",{onClick:()=>P(R.id),disabled:p===R.id,className:"text-xs text-primary-400 hover:text-primary-300 disabled:opacity-50 flex items-center gap-1",children:[t.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"]})]})}),R.validation_status==="invalid"&&!R.is_expired&&t.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-600/50",children:[t.jsx("p",{className:"text-orange-400 text-sm",children:"Token validation failed. Please re-authenticate to continue using this account."}),R.last_error&&t.jsx("p",{className:"text-gray-500 text-xs mt-1",children:R.last_error})]}),R.last_error&&R.validation_status!=="invalid"&&t.jsx("div",{className:"mt-3 pt-3 border-t border-gray-600/50",children:t.jsx("p",{className:"text-red-400 text-xs",children:R.last_error})})]},R.id)})}),t.jsx("div",{className:"mt-4 p-3 bg-gray-800/50 border border-gray-700 rounded",children:t.jsxs("div",{className:"flex items-start space-x-2",children:[t.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:t.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"})}),t.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 eC(){const{loadProjects:e}=sn(),[r,s]=y.useState(null),[a,o]=y.useState([]),[c,d]=y.useState(!0),[u,h]=y.useState(null),[p,x]=y.useState(null),[g,b]=y.useState(null),[v,k]=y.useState(!1);y.useEffect(()=>{async function j(){d(!0);try{const[A,M]=await Promise.all([Kf().catch(()=>null),zd().catch(()=>[])]);s(A),o(M)}finally{d(!1)}}j()},[]);const T=async j=>{if(window.confirm(`Are you sure you want to remove project "${j}"? This will not delete any files.`)){h(j),x(null);try{await Kw(j),o(a.filter(A=>A.slug!==j)),e()}catch(A){x(A instanceof Error?A.message:"Failed to remove project")}finally{h(null)}}},N=async j=>{k(!0),b(null),x(null);try{const A=await Qw("^e2e-",j);if(b(A),!j&&(A.deleted.length>0||A.failed.length>0)){const M=await zd().catch(()=>[]);o(M),e()}}catch(A){x(A instanceof Error?A.message:"Cleanup failed")}finally{k(!1)}};return t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[t.jsx(Re,{to:"/",className:"hover:text-white",children:"Dashboard"}),t.jsx("span",{children:"/"}),t.jsx("span",{className:"text-white",children:"Settings"})]}),t.jsxs("div",{className:"mb-8",children:[t.jsx("h1",{className:"text-3xl font-bold text-white mb-2",children:"Settings"}),t.jsx("p",{className:"text-gray-400",children:"Manage RalphX configuration and projects"})]}),c?t.jsx("div",{className:"text-gray-400",children:"Loading..."}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"card",children:[t.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"System Information"}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-gray-700",children:[t.jsx("span",{className:"text-gray-400",children:"API Status"}),t.jsx("span",{className:`${(r==null?void 0:r.status)==="healthy"?"text-green-400":"text-red-400"}`,children:(r==null?void 0:r.status)||"unavailable"})]}),t.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-gray-700",children:[t.jsx("span",{className:"text-gray-400",children:"Version"}),t.jsx("span",{className:"text-white font-mono",children:(r==null?void 0:r.version)||"-"})]}),t.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-gray-700",children:[t.jsx("span",{className:"text-gray-400",children:"Workspace"}),t.jsx("span",{className:"text-white font-mono text-sm",children:"~/.ralphx"})]}),t.jsxs("div",{className:"flex items-center justify-between py-2",children:[t.jsx("span",{className:"text-gray-400",children:"Projects Registered"}),t.jsx("span",{className:"text-white",children:a.length})]})]})]}),t.jsx(Z3,{}),t.jsxs("div",{className:"card",children:[t.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Cleanup Test Data"}),t.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."}),t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx("button",{onClick:()=>N(!0),disabled:v,className:"px-4 py-2 rounded bg-gray-700 text-gray-200 hover:bg-gray-600 disabled:opacity-50",children:v?"Scanning...":"Preview Cleanup"}),t.jsx("button",{onClick:()=>N(!1),disabled:v,className:"px-4 py-2 rounded bg-red-800 text-red-200 hover:bg-red-700 disabled:opacity-50",children:v?"Cleaning...":"Clean Up Now"})]}),g&&t.jsxs("div",{className:"mt-4 space-y-2",children:[g.deleted.length>0&&t.jsxs("div",{className:`p-3 rounded ${g.dry_run?"bg-yellow-900/30 border border-yellow-800":"bg-green-900/30 border border-green-800"}`,children:[t.jsx("div",{className:`text-sm font-medium ${g.dry_run?"text-yellow-400":"text-green-400"}`,children:g.dry_run?"Preview (will be deleted):":"Deleted:"}),t.jsx("ul",{className:"text-gray-300 text-sm mt-1 font-mono",children:g.deleted.map(j=>t.jsx("li",{children:j},j))})]}),g.failed&&g.failed.length>0&&t.jsxs("div",{className:"p-3 rounded bg-red-900/30 border border-red-800",children:[t.jsx("div",{className:"text-sm font-medium text-red-400",children:"Failed to delete (check server logs):"}),t.jsx("ul",{className:"text-gray-300 text-sm mt-1 font-mono",children:g.failed.map(j=>t.jsx("li",{children:j},j))})]}),g.deleted.length===0&&(!g.failed||g.failed.length===0)&&t.jsx("div",{className:"p-3 rounded bg-gray-800 border border-gray-700",children:t.jsx("p",{className:"text-gray-400 text-sm",children:"No matching projects found"})})]})]}),t.jsxs("div",{className:"card",children:[t.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Registered Projects"}),p&&t.jsx("div",{className:"mb-4 px-3 py-2 bg-red-900/30 border border-red-800 rounded text-sm text-red-400",children:p}),a.length===0?t.jsx("p",{className:"text-gray-400",children:"No projects registered"}):t.jsx("div",{className:"space-y-2",children:a.map(j=>t.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-700 rounded",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-white",children:j.name}),t.jsx("div",{className:"text-sm text-gray-400 font-mono",children:j.path})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(Re,{to:`/projects/${j.slug}`,className:"px-3 py-1 text-sm rounded bg-primary-600 text-white hover:bg-primary-500",children:"View"}),t.jsx("button",{onClick:()=>T(j.slug),disabled:u===j.slug,className:"px-3 py-1 text-sm rounded bg-red-800 text-red-200 hover:bg-red-700 disabled:opacity-50",children:u===j.slug?"Removing...":"Remove"})]})]},j.slug))})]}),t.jsxs("div",{className:"card",children:[t.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Documentation"}),t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-gray-300 font-medium",children:"Configuration Files"}),t.jsxs("p",{className:"text-gray-400 mt-1",children:["Loop configurations are stored in ",t.jsx("code",{className:"bg-gray-700 px-1 rounded",children:".ralphx/loops/"})," as YAML files."]})]}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-gray-300 font-medium",children:"CLI Commands"}),t.jsxs("ul",{className:"text-gray-400 mt-1 space-y-1 font-mono text-xs",children:[t.jsx("li",{children:"ralphx add <path> - Add a project"}),t.jsx("li",{children:"ralphx list - List projects"}),t.jsx("li",{children:"ralphx run <slug> <loop> - Run a loop"}),t.jsx("li",{children:"ralphx serve - Start the web server"}),t.jsx("li",{children:"ralphx mcp - Start MCP server for Claude Code"})]})]}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-gray-300 font-medium",children:"MCP Integration"}),t.jsx("p",{className:"text-gray-400 mt-1",children:"Add RalphX to Claude Code:"}),t.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"}),t.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'}),t.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Windows: run ",t.jsx("code",{className:"bg-gray-600 px-1 rounded",children:"where.exe ralphx"})," to find path, then use that instead of $(which ralphx)"]})]})]})]})]})]})}const tC={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"},rC={system:"text-gray-400",auth:"text-purple-400",loop:"text-green-400",run:"text-blue-400",iteration:"text-cyan-400"};function nC(){const[e,r]=y.useState([]),[s,a]=y.useState(null),[o,c]=y.useState(!0),[d,u]=y.useState(null),[h,p]=y.useState(""),[x,g]=y.useState(""),[b]=y.useState(100),[v,k]=y.useState(0),[T,N]=y.useState(!1),[j,A]=y.useState(null),[M,_]=y.useState(!1),z=y.useRef(!1),P=y.useRef(!0),$=y.useCallback(async()=>{if(!z.current){z.current=!0,P.current?c(!0):_(!0),u(null);try{const U={limit:b,offset:v};h&&(U.level=h),x&&(U.category=x);const[D,R]=await Promise.all([Vb(U),qb()]);r(D.logs),a(R),P.current=!1}catch(U){u(U instanceof Error?U.message:"Failed to load logs")}finally{c(!1),_(!1),z.current=!1}}},[h,x,b,v]);y.useEffect(()=>{$()},[$]),y.useEffect(()=>{if(!T)return;const U=setInterval($,1e4);return()=>clearInterval(U)},[T,$]);const V=U=>fs(U).toLocaleString(),B=U=>{const D=Math.floor((Date.now()-fs(U).getTime())/1e3);if(D<60)return`${D}s ago`;const R=Math.floor(D/60);if(R<60)return`${R}m ago`;const X=Math.floor(R/60);return X<24?`${X}h ago`:`${Math.floor(X/24)}d ago`};return t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[t.jsx(Re,{to:"/",className:"hover:text-white",children:"Dashboard"}),t.jsx("span",{children:"/"}),t.jsx("span",{className:"text-white",children:"Logs"})]}),t.jsxs("div",{className:"flex items-center justify-between mb-6",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-3xl font-bold text-white mb-1",children:"Logs"}),t.jsxs("p",{className:"text-gray-400",children:[(s==null?void 0:s.total)??0," total entries",s!=null&&s.recent_errors_24h?t.jsxs("span",{className:"text-red-400 ml-2",children:["(",s.recent_errors_24h," errors in last 24h)"]}):null]})]}),t.jsxs("div",{className:"flex items-center space-x-4",children:[M&&t.jsxs("span",{className:"text-sm text-gray-400 flex items-center",children:[t.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.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..."]}),t.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:T,onChange:U=>N(U.target.checked),className:"form-checkbox bg-gray-700 border-gray-600 text-primary-500 rounded"}),t.jsx("span",{className:"text-gray-300 text-sm",children:"Auto-refresh"})]})]})]}),s&&t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-6",children:[t.jsxs("div",{className:"card",children:[t.jsx("div",{className:"text-2xl font-bold text-white",children:s.total}),t.jsx("div",{className:"text-sm text-gray-400",children:"Total Entries"})]}),t.jsxs("div",{className:"card",children:[t.jsx("div",{className:"text-2xl font-bold text-red-400",children:s.by_level.ERROR||0}),t.jsx("div",{className:"text-sm text-gray-400",children:"Errors"})]}),t.jsxs("div",{className:"card",children:[t.jsx("div",{className:"text-2xl font-bold text-yellow-400",children:s.by_level.WARNING||0}),t.jsx("div",{className:"text-sm text-gray-400",children:"Warnings"})]}),t.jsxs("div",{className:"card",children:[t.jsx("div",{className:"text-2xl font-bold text-blue-400",children:s.by_level.INFO||0}),t.jsx("div",{className:"text-sm text-gray-400",children:"Info"})]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-4 mb-4",children:[t.jsxs("select",{value:h,onChange:U=>{p(U.target.value),k(0)},className:"bg-gray-700 border border-gray-600 rounded px-3 py-2 text-white text-sm","aria-label":"Filter by level",children:[t.jsx("option",{value:"",children:"All Levels"}),t.jsx("option",{value:"ERROR",children:"ERROR"}),t.jsx("option",{value:"WARNING",children:"WARNING"}),t.jsx("option",{value:"INFO",children:"INFO"}),t.jsx("option",{value:"DEBUG",children:"DEBUG"})]}),t.jsxs("select",{value:x,onChange:U=>{g(U.target.value),k(0)},className:"bg-gray-700 border border-gray-600 rounded px-3 py-2 text-white text-sm","aria-label":"Filter by category",children:[t.jsx("option",{value:"",children:"All Categories"}),t.jsx("option",{value:"system",children:"system"}),t.jsx("option",{value:"auth",children:"auth"}),t.jsx("option",{value:"loop",children:"loop"}),t.jsx("option",{value:"run",children:"run"}),t.jsx("option",{value:"iteration",children:"iteration"})]}),t.jsx("button",{onClick:()=>$(),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"})]}),d&&t.jsx("div",{className:"mb-4 p-3 bg-red-900/30 border border-red-800 rounded text-red-400",children:d}),o&&e.length===0?t.jsx("div",{className:"text-gray-400",children:"Loading logs..."}):e.length===0?t.jsxs("div",{className:"card text-center py-8",children:[t.jsx("p",{className:"text-gray-400",children:"No logs found"}),t.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Activity will appear here as you use the system"})]}):t.jsx("div",{className:"space-y-1",children:e.map(U=>t.jsxs("div",{className:"card !py-2",children:[t.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:()=>A(j===U.id?null:U.id),onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),A(j===U.id?null:U.id))},children:[t.jsxs("div",{className:"flex items-center space-x-3 flex-1 min-w-0",children:[t.jsx("span",{className:`text-xs px-2 py-0.5 rounded font-medium ${tC[U.level]||"bg-gray-600 text-gray-300"}`,children:U.level}),t.jsxs("span",{className:`text-sm font-mono ${rC[U.category||""]||"text-gray-400"}`,children:[U.category||"unknown",".",U.event||"unknown"]}),t.jsx("span",{className:"text-sm text-gray-300 truncate",children:U.message})]}),t.jsxs("div",{className:"flex items-center space-x-4 text-xs text-gray-500 ml-4",children:[t.jsx("span",{title:V(U.timestamp),children:B(U.timestamp)}),U.metadata&&t.jsx("svg",{className:`w-4 h-4 transition-transform ${j===U.id?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),j===U.id&&t.jsxs("div",{className:"mt-2 pt-2 border-t border-gray-700",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs text-gray-400",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-500",children:"Timestamp:"})," ",V(U.timestamp)]}),U.project_id&&t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-500",children:"Project:"})," ",U.project_id]}),U.run_id&&t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-500",children:"Run:"})," ",U.run_id]})]}),U.metadata&&t.jsxs("div",{className:"mt-2",children:[t.jsx("span",{className:"text-xs text-gray-500",children:"Metadata:"}),t.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))}),e.length>0&&t.jsxs("div",{className:"flex items-center justify-between mt-4",children:[t.jsxs("div",{className:"text-sm text-gray-400",children:["Showing ",v+1," - ",v+e.length," of ",(s==null?void 0:s.total)??e.length]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("button",{onClick:()=>k(Math.max(0,v-b)),disabled:v===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"}),t.jsx("button",{onClick:()=>k(v+b),disabled:e.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 sC={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 iC({step:e,isCurrent:r,projectSlug:s,workflowId:a,onRun:o,onStop:c,onItemsClick:d,isRunning:u}){var $,V,B,U;const h=Dr(),p=(($=e.config)==null?void 0:$.loopType)==="generator",x=((V=e.config)==null?void 0:V.loopType)==="consumer",g=e.input_items,b=g&&g.total>0,v=e.has_active_run===!0,k=(B=e.config)==null?void 0:B.model,T=k?sC[k]||{label:k,color:"text-gray-400"}:null,N=e.has_guardrails,j=(g==null?void 0:g.failed)??0,A=()=>{h(`/projects/${s}/workflows/${a}/steps/${e.step_number}`)},M=()=>v?t.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse shadow-[0_0_8px_var(--color-emerald)]"}):e.status==="completed"?t.jsx("svg",{className:"w-4 h-4 text-cyan-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):e.status==="active"?t.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-400"}):t.jsx("span",{className:"w-2 h-2 rounded-full bg-gray-600"}),z=(e.iterations_completed??0)>0?e.completed_at||e.started_at:null,P=()=>{if(p){const D=e.items_generated??0;return t.jsxs("span",{className:`font-mono ${d&&D>0?"cursor-pointer hover:text-cyan-400":""}`,onClick:R=>{d&&D>0&&(R.stopPropagation(),d())},children:[t.jsx("span",{className:"text-[var(--color-text-primary)] font-semibold",children:D}),t.jsx("span",{className:"text-[var(--color-text-muted)] ml-1",children:"items"})]})}return x&&b?t.jsxs("div",{className:"font-mono text-right",children:[t.jsx("span",{className:"text-[var(--color-text-primary)] font-semibold",children:g.completed}),t.jsxs("span",{className:"text-[var(--color-text-muted)]",children:["/",g.total]}),j>0&&t.jsxs("span",{className:"text-red-400 ml-2",title:`${j} failed`,children:["(",j," err)"]})]}):t.jsx("span",{className:"text-[var(--color-text-muted)]",children:"—"})};return t.jsxs("div",{onClick:A,className:`group relative flex items-center gap-4 px-4 py-3 rounded-lg border cursor-pointer transition-all
|
|
192
|
+
${r?"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
|
+
${v?"border-emerald-500/50 bg-emerald-500/5":""}
|
|
194
|
+
`,children:[t.jsx("div",{className:"flex items-center gap-3 w-8",children:t.jsx(M,{})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"text-xs font-mono text-[var(--color-text-muted)]",children:[e.step_number,"."]}),t.jsx("span",{className:"font-medium text-[var(--color-text-primary)] truncate",children:e.name}),T&&t.jsx("span",{className:`text-[10px] font-mono ${T.color}`,title:`Using ${T.label} model`,children:T.label}),N&&t.jsx("span",{className:"text-[10px] text-amber-400",title:"Has guardrails configured",children:t.jsx("svg",{className:"w-3 h-3 inline",fill:"currentColor",viewBox:"0 0 20 20",children:t.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=e.config)==null?void 0:U.description)&&t.jsx("p",{className:"text-xs text-[var(--color-text-muted)] truncate mt-0.5",children:e.config.description})]}),t.jsx("div",{className:"w-24 text-right text-sm",children:t.jsx(P,{})}),t.jsxs("div",{className:"w-24 text-right text-sm font-mono",children:[t.jsx("span",{className:"text-[var(--color-text-primary)]",children:e.iterations_completed??0}),e.iterations_target?t.jsxs("span",{className:"text-[var(--color-text-muted)]",children:["/",e.iterations_target]}):t.jsx("span",{className:"text-[var(--color-text-muted)] ml-1 text-xs",children:"cyc"})]}),t.jsx("div",{className:"w-24 text-right text-xs text-[var(--color-text-muted)]",children:bu(z,"Never")}),x&&b&&t.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-[var(--color-border)] rounded-b-lg overflow-hidden",children:t.jsx("div",{className:"h-full bg-gradient-to-r from-cyan-500 to-emerald-500 transition-all",style:{width:`${g.completed/g.total*100}%`}})}),t.jsx("div",{className:"w-20 flex justify-end",children:v?c&&t.jsx("button",{onClick:D=>{D.stopPropagation(),c()},disabled:u,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"}):o&&t.jsx("button",{onClick:D=>{D.stopPropagation(),o()},disabled:u,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 aC({steps:e,currentStep:r,projectSlug:s,workflowId:a,onRunStep:o,onStopStep:c,onItemsClick:d,isRunning:u}){return t.jsxs("div",{className:"space-y-2",children:[e.length>0&&t.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:[t.jsx("div",{className:"w-8"}),t.jsx("div",{className:"flex-1",children:"Step"}),t.jsx("div",{className:"w-24 text-right",children:"Output"}),t.jsx("div",{className:"w-24 text-right",children:"Cycles"}),t.jsx("div",{className:"w-24 text-right",children:"Last Run"}),t.jsx("div",{className:"w-20"})]}),e.map(h=>t.jsx(iC,{step:h,isCurrent:h.step_number===r,projectSlug:s,workflowId:a,onRun:o?()=>o(h.step_number):void 0,onStop:c?()=>c(h.step_number):void 0,onItemsClick:d?()=>d(h.id):void 0,isRunning:u},h.id)),e.length===0&&t.jsxs("div",{className:"text-center py-12 text-[var(--color-text-muted)]",children:[t.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:t.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"})}),t.jsx("p",{children:"No steps configured yet."}),t.jsx("p",{className:"text-sm mt-1",children:"Add steps in the workflow editor."})]})]})}function oC(e){return e?Math.ceil(e.length/4):0}function lC(e){return e<1e3?`${e}`:`${(e/1e3).toFixed(1)}k`}function cC(e){const r=e.map(c=>c.name.toLowerCase()),s=e.map(c=>{var d;return(((d=c.config)==null?void 0:d.description)||"").toLowerCase()}),a=[...r,...s].join(" "),o=(c,d)=>new RegExp(`\\b${d}\\b`,"i").test(c);return o(a,"story")||o(a,"stories")||o(a,"prd")||o(a,"user stories")||o(a,"requirements")?"new_product":o(a,"feature")&&(o(a,"implement")||o(a,"build"))?"feature":o(a,"bug")||o(a,"bugs")||o(a,"defect")||o(a,"bugfix")||o(a,"triage")?"bug_fix":o(a,"dependency")||o(a,"tech debt")||o(a,"maintenance")||o(a,"upgrade")?"maintenance":o(a,"ticket")||o(a,"support")||o(a,"customer")||o(a,"resolution")?"support":"generic"}function Gp(e,r=!0){return{new_product:["story","stories"],feature:["task","tasks"],bug_fix:["bug","bugs"],maintenance:["item","items"],support:["ticket","tickets"],generic:["item","items"]}[e][r?1:0]}function dC(e){return{new_product:"discovered",feature:"identified",bug_fix:"triaged",maintenance:"found",support:"received",generic:"generated"}[e]}function uC(e){return{new_product:"implemented",feature:"completed",bug_fix:"fixed",maintenance:"addressed",support:"resolved",generic:"processed"}[e]}function mC(e){var $;const r=e.steps||[],s=cC(r),a=r.filter(V=>{var B;return((B=V.config)==null?void 0:B.loopType)==="generator"}),o=r.filter(V=>{var B;return((B=V.config)==null?void 0:B.loopType)==="consumer"}),c=a.reduce((V,B)=>V+(B.items_generated||0),0),d=o.reduce((V,B)=>{var U;return V+(((U=B.input_items)==null?void 0:U.completed)||0)},0),u=o.reduce((V,B)=>{var U;return V+(((U=B.input_items)==null?void 0:U.total)||0)},0),h=r.reduce((V,B)=>V+(B.iterations_completed||0),0),p=r.some(V=>V.has_active_run),x=r.find(V=>V.has_active_run),g=r.map(V=>V.completed_at||V.started_at).filter(Boolean).sort().reverse()[0];let b;e.status==="completed"?b="complete":c===0?b="discovery":d===0&&u>0?b="ready":d<u?b=d/u>.8?"finishing":"in_progress":c>0&&a.some(V=>V.status!=="completed")?b="discovery":b="complete";const v=Gp(s),k=Gp(s,!1),T=dC(s),N=uC(s);let j,A,M,_,z,P;if(p&&x)(($=x.config)==null?void 0:$.loopType)==="generator"?(j=s==="new_product"?"Discovering":s==="bug_fix"?"Triaging":s==="support"?"Processing":"Generating",A=`${x.name} in progress...`):(j=s==="new_product"?"Building":s==="bug_fix"?"Fixing":s==="support"?"Resolving":"Processing",A=`Working on ${x.name.toLowerCase()}...`),M="text-emerald-400",_="bg-emerald-400 animate-pulse";else if(e.status==="completed")j="Complete",A=`All ${v} ${N}`,M="text-blue-400",_="bg-blue-400";else if(e.status==="draft")j="Ready",A="Workflow not started",M="text-gray-400",_="bg-gray-500";else if(b==="discovery")j="Paused",A=c>0?`${c} ${v} ${T} so far`:`Ready to discover ${v}`,M="text-amber-400",_="bg-amber-400";else if(b==="ready")j="Ready to build",A=`${u} ${v} queued for ${s==="bug_fix"?"fixing":"implementation"}`,M="text-cyan-400",_="bg-cyan-400";else if(b==="in_progress"||b==="finishing"){const V=u-d,B=Math.round(d/u*100);j="Paused",A=`${V} ${V===1?k:v} remaining (${B}% done)`,M="text-amber-400",_="bg-amber-400"}else j="Idle",A="Ready to continue",M="text-gray-400",_="bg-gray-500";return s==="new_product"||s==="feature"?(z={label:d>0?`${v} ${N}`:`${v} ${T}`,value:d>0?`${d}/${u}`:c,subtext:d>0&&u>0?`${Math.round(d/u*100)}%`:void 0},c>0&&d===0&&(P={label:"ready to build",value:u||c})):s==="bug_fix"?(z={label:d>0?"bugs fixed":"bugs triaged",value:d>0?`${d}/${u}`:c},u>0&&(P={label:"remaining",value:u-d})):s==="support"?(z={label:"tickets resolved",value:d>0?`${d}/${u}`:"0"},c>0&&(P={label:"received",value:c})):z={label:d>0?"processed":"generated",value:d>0?`${d}/${u}`:c},{type:s,stage:b,generators:a,consumers:o,totalGenerated:c,totalProcessed:d,totalToProcess:u,totalIterations:h,isRunning:p,runningStep:x,lastActivity:g,primaryMetric:z,secondaryMetric:P,statusMessage:j,statusDetail:A,statusColor:M,dotClass:_}}function hC({workflow:e,resources:r,projectSlug:s,workflowId:a,onResourceUpdate:o}){const[c,d]=y.useState(null),[u,h]=y.useState(null),[p,x]=y.useState(""),[g,b]=y.useState(""),[v,k]=y.useState(!1),[T,N]=y.useState(null),[j,A]=y.useState(!1),[M,_]=y.useState(null),[z,P]=y.useState(null),[$,V]=y.useState([]),[B,U]=y.useState(0),[D,R]=y.useState(!1),[X,I]=y.useState(null),[H,W]=y.useState(!1);y.useEffect(()=>{if(M){const ve=setTimeout(()=>_(null),3e3);return()=>clearTimeout(ve)}},[M]);const J=mC(e),Z=r.filter(ve=>ve.enabled),de=Z.filter(ve=>ve.resource_type==="design_doc"),E=Z.filter(ve=>ve.resource_type==="guardrail"),L=Z.filter(ve=>ve.resource_type==="input_file"||ve.resource_type==="input"),q=Z.filter(ve=>ve.resource_type==="prompt"),S=ve=>new Date(ve).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),G=(ve,F)=>{F.stopPropagation(),h(ve),x(ve.content||""),b(ve.updated_at),N(null),d(null)},re=()=>A(!0),ee=async()=>{if(!(!u||!o)){k(!0),N(null),A(!1);try{await o(u.id,p,g),_({message:"Version saved",type:"success"}),h(null)}catch(ve){const F=ve instanceof Error?ve.message:"Failed to save";F.includes("modified in another session")||F.includes("409")?N("Resource was modified in another session. Please reload."):N(F)}finally{k(!1)}}},ge=async(ve,F)=>{F.stopPropagation(),P(ve),R(!0),I(null),d(null);try{const he=await h1(s,a,ve.id);V(he.versions),U(he.total)}catch(he){console.error("Failed to load versions:",he),V([]),U(0)}finally{R(!1)}},je=async ve=>{if(z){W(!0);try{await p1(s,a,z.id,ve.id),_({message:"Version restored",type:"success"}),P(null),I(null)}catch(F){console.error("Failed to restore version:",F),_({message:"Failed to restore version",type:"error"})}finally{W(!1)}}},Le=({resources:ve,label:F,colorClass:he,icon:ue})=>{if(ve.length===0)return null;const Oe=ve.reduce((We,qe)=>We+oC(qe.content),0),Se=c&&ve.some(We=>We.id===c.id);return t.jsxs("div",{className:"relative",children:[t.jsxs("button",{onClick:()=>d(Se?null:ve[0]),className:`flex items-center gap-3 px-4 py-3 rounded-lg border transition-all hover:border-[var(--color-border-bright)] ${Se?"border-[var(--color-border-bright)] bg-[var(--color-elevated)]":"border-[var(--color-border)] bg-[var(--color-surface)]"}`,children:[t.jsx("span",{className:he,children:ue}),t.jsxs("div",{className:"text-left",children:[t.jsx("div",{className:"text-sm font-medium text-[var(--color-text-primary)]",children:ve.length===1?ve[0].name:F}),t.jsxs("div",{className:"text-xs text-[var(--color-text-muted)] flex items-center gap-2",children:[ve.length>1&&t.jsxs("span",{children:[ve.length," files"]}),t.jsxs("span",{children:[lC(Oe)," tokens"]})]})]}),t.jsx("svg",{className:`w-4 h-4 text-[var(--color-text-muted)] transition-transform ml-2 ${Se?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),Se&&t.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:ve.map(We=>{var qe;return t.jsx("div",{className:"border-b border-[var(--color-border)] last:border-b-0",children:t.jsxs("div",{className:"p-3",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("span",{className:"text-sm font-medium text-[var(--color-text-primary)]",children:We.name}),t.jsxs("div",{className:"flex items-center gap-1",children:[o&&t.jsx("button",{onClick:tt=>G(We,tt),className:"px-2 py-0.5 text-[10px] text-cyan-400 hover:text-cyan-300 hover:bg-cyan-500/10 rounded",children:"Edit"}),t.jsx("button",{onClick:tt=>ge(We,tt),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"})]})]}),t.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:[(We.content||"").slice(0,800),(((qe=We.content)==null?void 0:qe.length)||0)>800?"...":""]})]})},We.id)})})]})};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"card-panel mb-4",children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-4",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${J.dotClass}`}),t.jsx("span",{className:`text-sm font-semibold ${J.statusColor}`,children:J.statusMessage})]}),t.jsx("span",{className:"text-sm text-[var(--color-text-secondary)]",children:J.statusDetail}),J.lastActivity&&t.jsxs("span",{className:"text-xs text-[var(--color-text-muted)] border-l border-[var(--color-border)] pl-4",children:["Last: ",bu(J.lastActivity,"Never")]})]}),t.jsxs("div",{className:"flex items-center gap-6",children:[t.jsxs("div",{className:"text-right",children:[t.jsxs("div",{className:"text-xl font-bold text-[var(--color-text-primary)] font-mono",children:[J.primaryMetric.value,J.primaryMetric.subtext&&t.jsx("span",{className:"text-sm text-[var(--color-text-muted)] ml-1",children:J.primaryMetric.subtext})]}),t.jsx("div",{className:"text-[10px] text-[var(--color-text-muted)] uppercase tracking-wider",children:J.primaryMetric.label})]}),J.secondaryMetric&&t.jsxs("div",{className:"text-right",children:[t.jsx("div",{className:"text-xl font-bold text-[var(--color-text-primary)] font-mono",children:J.secondaryMetric.value}),t.jsx("div",{className:"text-[10px] text-[var(--color-text-muted)] uppercase tracking-wider",children:J.secondaryMetric.label})]}),J.totalIterations>0&&t.jsxs("div",{className:"text-right border-l border-[var(--color-border)] pl-6",children:[t.jsx("div",{className:"text-lg font-bold text-[var(--color-text-secondary)] font-mono",children:J.totalIterations}),t.jsx("div",{className:"text-[10px] text-[var(--color-text-muted)] uppercase tracking-wider",children:"cycles"})]})]})]}),J.totalToProcess>0&&t.jsx("div",{className:"h-1 bg-[var(--color-border)]",children:t.jsx("div",{className:"h-full bg-gradient-to-r from-cyan-500 to-emerald-500 transition-all duration-500",style:{width:`${J.totalProcessed/J.totalToProcess*100}%`}})})]}),Z.length>0&&t.jsxs("div",{className:"mb-6",children:[t.jsx("div",{className:"text-xs font-semibold text-[var(--color-text-muted)] uppercase tracking-wider mb-3",children:"Resources"}),t.jsxs("div",{className:"flex flex-wrap gap-3",children:[t.jsx(Le,{resources:de,label:"Design Docs",colorClass:"text-purple-400",icon:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.jsx(Le,{resources:E,label:"Guidelines",colorClass:"text-amber-400",icon:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.jsx(Le,{resources:L,label:"Inputs",colorClass:"text-blue-400",icon:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.jsx(Le,{resources:q,label:"Prompts",colorClass:"text-emerald-400",icon:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})})]})]}),c&&t.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>d(null)}),u&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.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:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--color-border)]",children:[t.jsxs("h3",{className:"text-lg font-medium text-[var(--color-text-primary)]",children:["Edit: ",u.name]}),t.jsx("button",{onClick:()=>h(null),className:"text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)]",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsxs("div",{className:"p-4 flex-1 overflow-auto",children:[T&&t.jsx("div",{className:"mb-4 p-3 rounded bg-red-900/20 border border-red-800 text-red-400 text-sm",children:T}),t.jsx("textarea",{value:p,onChange:ve=>x(ve.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"})]}),t.jsxs("div",{className:"flex items-center justify-end gap-3 px-4 py-3 border-t border-[var(--color-border)]",children:[t.jsx("button",{onClick:()=>h(null),className:"px-4 py-2 text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)]",children:"Cancel"}),t.jsx("button",{onClick:re,disabled:v||p===(u.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:v?"Saving...":"Save"})]})]})}),j&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-[var(--color-surface)] border border-[var(--color-border)] rounded-lg p-6 max-w-md",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-500/20 flex items-center justify-center",children:t.jsx("svg",{className:"w-5 h-5 text-amber-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.jsx("h3",{className:"text-lg font-medium text-[var(--color-text-primary)]",children:"Save Changes?"})]}),t.jsxs("p",{className:"text-sm text-[var(--color-text-secondary)] mb-6",children:["This will update the resource for ",t.jsx("strong",{children:"ALL steps"})," in this workflow."]}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>A(!1),className:"px-4 py-2 text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)]",children:"Cancel"}),t.jsx("button",{onClick:ee,disabled:v,className:"px-4 py-2 text-sm bg-cyan-600 text-white rounded hover:bg-cyan-500 disabled:opacity-50",children:v?"Saving...":"Save"})]})]})}),z&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.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:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--color-border)]",children:[t.jsxs("h3",{className:"text-lg font-medium text-[var(--color-text-primary)]",children:["History: ",z.name]}),t.jsx("button",{onClick:()=>{P(null),I(null)},className:"text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)]",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsx("div",{className:"flex-1 overflow-auto p-4",children:D?t.jsx("div",{className:"text-center py-8 text-[var(--color-text-muted)]",children:"Loading..."}):$.length===0?t.jsx("div",{className:"text-center py-8 text-[var(--color-text-muted)]",children:"No history yet."}):t.jsxs("div",{className:"space-y-3",children:[$.map(ve=>t.jsxs("div",{className:`p-3 rounded border ${(X==null?void 0:X.id)===ve.id?"border-cyan-500 bg-cyan-500/10":"border-[var(--color-border)] hover:border-[var(--color-border-bright)]"}`,children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("span",{className:"text-sm font-medium text-[var(--color-text-primary)]",children:["Version ",ve.version_number]}),t.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:S(ve.created_at)})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>I((X==null?void 0:X.id)===ve.id?null:ve),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:(X==null?void 0:X.id)===ve.id?"Hide":"Preview"}),t.jsx("button",{onClick:()=>je(ve),disabled:H,className:"px-2 py-1 text-xs text-cyan-400 hover:text-cyan-300 hover:bg-cyan-500/10 rounded disabled:opacity-50",children:H?"Restoring...":"Restore"})]}),(X==null?void 0:X.id)===ve.id&&t.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:ve.content||"(empty)"})]},ve.id)),B>$.length&&t.jsxs("div",{className:"text-center text-xs text-[var(--color-text-muted)] py-2",children:["Showing ",$.length," of ",B]})]})})]})}),M&&t.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 pC({projectSlug:e,item:r,onUpdate:s,onEdit:a,onDuplicate:o}){var N;const[c,d]=y.useState(!1),[u,h]=y.useState(!1),[p,x]=y.useState(null),[g,b]=y.useState(!1),v=async j=>{h(!0),x(null);try{await xu(e,r.id,{status:j}),s()}catch(A){x(A instanceof Error?A.message:"Failed to update item")}finally{h(!1)}},k=async()=>{if(window.confirm("Are you sure you want to delete this item?")){h(!0),x(null);try{await Jf(e,r.id),s()}catch(j){x(j instanceof Error?j.message:"Failed to delete item")}finally{h(!1)}}},T=r.id.includes("-")?r.id.split("-")[0].toUpperCase()+"-"+((N=r.id.split("-")[1])==null?void 0:N.slice(0,3).toUpperCase()):r.id.slice(0,8).toUpperCase();return t.jsxs("div",{className:"border-b border-[var(--color-border)] last:border-b-0",children:[t.jsxs("div",{className:`flex items-center gap-4 px-4 py-3 cursor-pointer hover:bg-[var(--color-elevated)] transition-colors ${c?"bg-[var(--color-elevated)]":""}`,onClick:()=>{c&&b(!1),d(!c)},children:[t.jsx("div",{className:"w-24 flex-shrink-0",children:t.jsx("span",{className:"font-mono text-xs text-[var(--color-text-muted)]",children:T})}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("p",{className:"text-sm text-[var(--color-text-primary)] truncate",children:r.title||r.content.slice(0,80)})}),t.jsx("div",{className:"w-28 flex-shrink-0",children:t.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${vu(r.status)}`,children:yu(r.status)})}),t.jsx("div",{className:"w-20 flex-shrink-0",children:r.category&&t.jsx("span",{className:"text-xs text-[var(--color-text-muted)] uppercase",children:r.category})}),t.jsx("div",{className:"w-20 flex-shrink-0 text-right",children:t.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:bu(r.created_at)})}),t.jsx("div",{className:"w-6 flex-shrink-0",children:t.jsx("svg",{className:`w-4 h-4 text-[var(--color-text-muted)] transition-transform ${c?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}),c&&t.jsxs("div",{className:"px-4 py-4 bg-[var(--color-surface)] border-t border-[var(--color-border)]",children:[t.jsxs("div",{className:"mb-4",children:[t.jsx("h4",{className:"text-xs font-medium text-[var(--color-text-muted)] mb-2 uppercase tracking-wide",children:"Content"}),t.jsx("p",{className:"text-sm text-[var(--color-text-secondary)] whitespace-pre-wrap",children:r.content})]}),r.dependencies&&r.dependencies.length>0&&t.jsxs("div",{className:"mb-4",children:[t.jsx("h4",{className:"text-xs font-medium text-[var(--color-text-muted)] mb-2 uppercase tracking-wide",children:"Dependencies"}),t.jsx("div",{className:"flex flex-wrap gap-1",children:r.dependencies.map(j=>t.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-[var(--color-elevated)] text-[var(--color-text-secondary)]",children:j},j))})]}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4 text-xs",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-[var(--color-text-muted)]",children:"Created:"}),t.jsx("span",{className:"ml-1 text-[var(--color-text-secondary)]",children:Wn(r.created_at)})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-[var(--color-text-muted)]",children:"Updated:"}),t.jsx("span",{className:"ml-1 text-[var(--color-text-secondary)]",children:Wn(r.updated_at)})]}),r.phase!==void 0&&t.jsxs("div",{children:[t.jsx("span",{className:"text-[var(--color-text-muted)]",children:"Phase:"}),t.jsx("span",{className:"ml-1 text-[var(--color-text-secondary)]",children:r.phase})]}),r.priority!==void 0&&r.priority>0&&t.jsxs("div",{children:[t.jsx("span",{className:"text-[var(--color-text-muted)]",children:"Priority:"}),t.jsxs("span",{className:"ml-1 text-[var(--color-text-secondary)]",children:["P",r.priority]})]}),r.claimed_by&&t.jsxs("div",{children:[t.jsx("span",{className:"text-[var(--color-text-muted)]",children:"Claimed by:"}),t.jsx("span",{className:"ml-1 text-[var(--color-text-secondary)]",children:r.claimed_by})]}),r.duplicate_of&&t.jsxs("div",{children:[t.jsx("span",{className:"text-[var(--color-text-muted)]",children:"Duplicate of:"}),t.jsx("span",{className:"ml-1 text-[var(--color-text-secondary)]",children:r.duplicate_of})]})]}),p&&t.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:p}),t.jsx("div",{className:"flex flex-wrap items-center gap-2",children:g?t.jsxs(t.Fragment,{children:[a&&t.jsx("button",{onClick:j=>{j.stopPropagation(),a(r)},disabled:u,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"}),o&&t.jsx("button",{onClick:j=>{j.stopPropagation(),o(r)},disabled:u,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"}),t.jsx("div",{className:"w-px h-6 bg-[var(--color-border)] self-center mx-1"}),r.status!=="processed"&&t.jsx("button",{onClick:j=>{j.stopPropagation(),v("processed")},disabled:u,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"}),r.status!=="skipped"&&t.jsx("button",{onClick:j=>{j.stopPropagation(),v("skipped")},disabled:u,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"}),r.status!=="pending"&&t.jsx("button",{onClick:j=>{j.stopPropagation(),v("pending")},disabled:u,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"}),t.jsx("button",{onClick:j=>{j.stopPropagation(),k()},disabled:u,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"}),t.jsx("div",{className:"w-px h-6 bg-[var(--color-border)] self-center mx-1"}),t.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:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}):t.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 Kp={title:"",content:"",category:"",priority:0,dependencies:[]};function fC({isOpen:e,onClose:r,onSave:s,item:a,mode:o,existingCategories:c=[]}){const[d,u]=y.useState(Kp),[h,p]=y.useState(""),[x,g]=y.useState(!1),[b,v]=y.useState(null);y.useEffect(()=>{e&&(u(a&&(o==="edit"||o==="duplicate")?{title:o==="duplicate"&&a.title?`${a.title} (copy)`:a.title||"",content:a.content,category:a.category||"",priority:a.priority||0,dependencies:a.dependencies||[]}:Kp),p(""),v(null))},[e,a,o]);const k=async M=>{if(M.preventDefault(),v(null),!d.content.trim()){v("Content is required");return}g(!0);try{await s(d),r()}catch(_){v(_ instanceof Error?_.message:"Failed to save")}finally{g(!1)}},T=()=>{const M=h.trim().toUpperCase();M&&!d.dependencies.includes(M)&&(u(_=>({..._,dependencies:[..._.dependencies,M]})),p(""))},N=M=>{u(_=>({..._,dependencies:_.dependencies.filter(z=>z!==M)}))},j=M=>{M.key==="Enter"&&(M.preventDefault(),T())};if(!e)return null;const A=o==="create"?"Create New Item":o==="duplicate"?"Duplicate Item":"Edit Item";return t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[t.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:r}),t.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:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--color-border)]",children:[t.jsx("h2",{className:"text-lg font-semibold text-[var(--color-text-primary)]",children:A}),t.jsx("button",{onClick:r,className:"p-1 hover:bg-[var(--color-border)] rounded transition-colors",children:t.jsx("svg",{className:"w-5 h-5 text-[var(--color-text-muted)]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsxs("form",{onSubmit:k,className:"p-4 space-y-4",children:[b&&t.jsx("div",{className:"p-3 bg-red-500/10 border border-red-500/20 rounded text-red-400 text-sm",children:b}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-[var(--color-text-secondary)] mb-1",children:"Title (optional)"}),t.jsx("input",{type:"text",value:d.title,onChange:M=>u(_=>({..._,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"})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-[var(--color-text-secondary)] mb-1",children:["Content ",t.jsx("span",{className:"text-red-400",children:"*"})]}),t.jsx("textarea",{value:d.content,onChange:M=>u(_=>({..._,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})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-[var(--color-text-secondary)] mb-1",children:"Category"}),t.jsx("input",{type:"text",list:"categories",value:d.category,onChange:M=>u(_=>({..._,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"}),t.jsx("datalist",{id:"categories",children:c.map(M=>t.jsx("option",{value:M},M))})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-[var(--color-text-secondary)] mb-1",children:"Priority"}),t.jsx("input",{type:"number",value:d.priority,onChange:M=>u(_=>({..._,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`}),t.jsx("p",{className:"text-xs text-[var(--color-text-muted)] mt-1",children:"0 = lowest, 100 = highest"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-[var(--color-text-secondary)] mb-1",children:"Dependencies"}),t.jsxs("div",{className:"flex gap-2 mb-2",children:[t.jsx("input",{type:"text",value:h,onChange:M=>p(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"}),t.jsx("button",{type:"button",onClick:T,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"})]}),d.dependencies.length>0&&t.jsx("div",{className:"flex flex-wrap gap-2",children:d.dependencies.map(M=>t.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,t.jsx("button",{type:"button",onClick:()=>N(M),className:"hover:text-blue-200",children:t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},M))})]}),t.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t border-[var(--color-border)]",children:[t.jsx("button",{type:"button",onClick:r,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"}),t.jsx("button",{type:"submit",disabled:x,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:x?"Saving...":o==="create"?"Create":o==="duplicate"?"Duplicate":"Save Changes"})]})]})]})]})}function xC({projectSlug:e,workflowId:r,steps:s,onClose:a,onImported:o}){const[c,d]=y.useState([]),[u,h]=y.useState(""),[p,x]=y.useState(null),[g,b]=y.useState(null),[v,k]=y.useState(!1),[T,N]=y.useState(null),j=y.useRef(null),[A,M]=y.useState(0);y.useEffect(()=>{async function $(){try{const B=await C1(e);d(B);const U=B.find(D=>D.id==="hank_prd");U?h(U.id):B.length>0&&h(B[0].id)}catch{N("Failed to load import formats")}}async function V(){try{const B=await xa(e,{workflow_id:r,limit:1});M(B.total)}catch(B){console.warn("Could not load existing items count:",B)}}$(),V()},[e,r]),y.useEffect(()=>{const $=s.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))});$?x($.id):s.length>0&&x(s[0].id)},[s]);const _=$=>{var B;const V=(B=$.target.files)==null?void 0:B[0];V&&(b(V),N(null))},z=async()=>{if(!g||!u||p===null){N("Please select a file, format, and target step");return}k(!0),N(null);try{const $=await S1(e,r,p,u,g);o($)}catch($){N($ instanceof Error?$.message:"Import failed")}finally{k(!1)}},P=c.find($=>$.id===u);return t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:a,onKeyDown:$=>$.key==="Escape"&&a(),role:"dialog","aria-modal":"true","aria-labelledby":"import-dialog-title",children:t.jsxs("div",{className:"card max-w-lg w-full mx-4 max-h-[90vh] overflow-y-auto",onClick:$=>$.stopPropagation(),children:[t.jsx("h3",{id:"import-dialog-title",className:"text-xl font-semibold text-white mb-4",children:"Import Work Items (JSONL)"}),T&&t.jsx("div",{className:"mb-4 p-3 rounded bg-red-900/30 border border-red-800 text-red-400 text-sm",children:T}),t.jsxs("div",{className:"mb-4",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Import Format"}),t.jsx("select",{value:u,onChange:$=>h($.target.value),className:"w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-white",children:c.map($=>t.jsx("option",{value:$.id,children:$.label},$.id))}),(P==null?void 0:P.description)&&t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:P.description})]}),t.jsxs("div",{className:"mb-4",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Target Step"}),t.jsx("select",{value:p??"",onChange:$=>x(Number($.target.value)),className:"w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-white",children:s.map($=>t.jsxs("option",{value:$.id,children:["Step ",$.step_number,": ",$.name,$.step_type==="autonomous"?" (Consumer)":""]},$.id))}),t.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Items will be available to this step for processing"})]}),A>0&&t.jsx("div",{className:"mb-4 p-4 rounded-lg border bg-gray-800/50 border-gray-700",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.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:t.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"})}),t.jsxs("div",{children:[t.jsxs("p",{className:"text-gray-300",children:["This workflow already has ",A," item",A!==1?"s":"","."]}),t.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."})]})]})}),t.jsxs("div",{className:"mb-6",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"JSONL File"}),t.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 $;return($=j.current)==null?void 0:$.click()},children:[t.jsx("input",{ref:j,type:"file",accept:".jsonl,.json",onChange:_,className:"hidden"}),g?t.jsxs("div",{children:[t.jsx("svg",{className:"w-8 h-8 mx-auto text-green-400 mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("p",{className:"text-white font-medium",children:g.name}),t.jsxs("p",{className:"text-sm text-gray-500",children:[(g.size/1024).toFixed(1)," KB"]})]}):t.jsxs("div",{children:[t.jsx("svg",{className:"w-8 h-8 mx-auto text-gray-500 mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),t.jsx("p",{className:"text-gray-400",children:"Click to select a JSONL file"}),t.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"or drag and drop"})]})]})]}),t.jsxs("div",{className:"flex justify-end space-x-3",children:[t.jsx("button",{onClick:a,className:"px-4 py-2 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 transition-colors",children:"Cancel"}),t.jsx("button",{onClick:z,disabled:v||!g||!u||p===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:v?"Importing...":"Import Items"})]})]})})}const Ji=50,gC=[{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 Gg({projectSlug:e,workflowId:r,sourceStepId:s,steps:a,onImported:o}){const[c,d]=y.useState([]),[u,h]=y.useState(0),[p,x]=y.useState(!0),[g,b]=y.useState(null),[v,k]=y.useState(""),[T,N]=y.useState(""),[j,A]=y.useState(""),[M,_]=y.useState(0),[z,P]=y.useState([]),[$,V]=y.useState(!1),[B,U]=y.useState("create"),[D,R]=y.useState(null),[X,I]=y.useState(!1),H=y.useCallback(async()=>{x(!0),b(null);try{const S=await xa(e,{workflow_id:r,source_step_id:s,status:v||void 0,category:T||void 0,limit:Ji,offset:M*Ji});if(d(S.items),h(S.total),M===0&&S.items.length>0){const G=[...new Set(S.items.map(re=>re.category).filter(Boolean))];P(G.sort())}}catch(S){b(S instanceof Error?S.message:"Failed to load items")}finally{x(!1)}},[e,r,s,v,T,M]);y.useEffect(()=>{H()},[H]),y.useEffect(()=>{_(0)},[v,T]);const W=()=>{R(null),U("create"),V(!0)},J=S=>{R(S),U("edit"),V(!0)},Z=S=>{R(S),U("duplicate"),V(!0)},de=async S=>{const G=(D==null?void 0:D.source_step_id)||s||0;B==="create"?await fu(e,{workflow_id:r,source_step_id:G,title:S.title||void 0,content:S.content,category:S.category||void 0,priority:S.priority||void 0,dependencies:S.dependencies.length>0?S.dependencies:void 0}):B==="edit"&&D?await xu(e,D.id,{title:S.title||void 0,content:S.content,category:S.category||void 0,priority:S.priority,dependencies:S.dependencies}):B==="duplicate"&&D&&await ib(e,D.id,{title:S.title||void 0,content:S.content,category:S.category||void 0,priority:S.priority,dependencies:S.dependencies.length>0?S.dependencies:void 0}),H()},E=j?c.filter(S=>{var G;return((G=S.title)==null?void 0:G.toLowerCase().includes(j.toLowerCase()))||S.content.toLowerCase().includes(j.toLowerCase())||S.id.toLowerCase().includes(j.toLowerCase())}):c,L=Math.ceil(u/Ji),q=c.reduce((S,G)=>(S[G.status]=(S[G.status]||0)+1,S),{});return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-[var(--color-text-primary)]",children:"Work Items"}),t.jsxs("span",{className:"text-sm text-[var(--color-text-muted)]",children:[u," total"]}),t.jsx("button",{onClick:W,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"}),t.jsxs("button",{onClick:()=>I(!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:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"]})]}),t.jsx("div",{className:"flex items-center gap-2",children:Object.entries(q).map(([S,G])=>t.jsxs("button",{onClick:()=>k(v===S?"":S),className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors
|
|
208
|
+
${v===S?"ring-2 ring-offset-1 ring-offset-[var(--color-surface)]":""}
|
|
209
|
+
${vu(S)}`,children:[t.jsx("span",{children:yu(S)}),t.jsx("span",{className:"opacity-75",children:G})]},S))})]}),t.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[t.jsx("div",{className:"flex-1 min-w-[200px] max-w-md",children:t.jsx("input",{type:"text",placeholder:"Search by title, content, or ID...",value:j,onChange:S=>A(S.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`})}),t.jsx("select",{value:v,onChange:S=>k(S.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:gC.map(S=>t.jsx("option",{value:S.value,children:S.label},S.value))}),z.length>0&&t.jsxs("select",{value:T,onChange:S=>N(S.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:[t.jsx("option",{value:"",children:"All Categories"}),z.map(S=>t.jsx("option",{value:S,children:S.toUpperCase()},S))]}),(v||T||j)&&t.jsx("button",{onClick:()=>{k(""),N(""),A("")},className:"px-3 py-2 text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)] transition-colors",children:"Clear filters"})]}),g&&t.jsx("div",{className:"p-4 bg-red-900/20 border border-red-800 rounded-lg text-red-400",children:g}),p&&t.jsx("div",{className:"py-8 text-center text-[var(--color-text-muted)]",children:"Loading items..."}),!p&&E.length>0&&t.jsxs("div",{className:"bg-[var(--color-elevated)] border border-[var(--color-border)] rounded-lg overflow-hidden",children:[t.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:[t.jsx("div",{className:"w-24 flex-shrink-0",children:"ID"}),t.jsx("div",{className:"flex-1",children:"Title"}),t.jsx("div",{className:"w-28 flex-shrink-0",children:"Status"}),t.jsx("div",{className:"w-20 flex-shrink-0",children:"Category"}),t.jsx("div",{className:"w-20 flex-shrink-0 text-right",children:"Created"}),t.jsx("div",{className:"w-6 flex-shrink-0"})]}),E.map(S=>t.jsx(pC,{projectSlug:e,item:S,onUpdate:H,onEdit:J,onDuplicate:Z},S.id))]}),!p&&E.length===0&&t.jsxs("div",{className:"py-12 text-center",children:[t.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-[var(--color-elevated)] flex items-center justify-center",children:t.jsx("svg",{className:"w-8 h-8 text-[var(--color-text-muted)]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.jsx("p",{className:"text-[var(--color-text-muted)]",children:v||T||j?"No items match your filters":"No work items yet"})]}),L>1&&t.jsxs("div",{className:"flex items-center justify-between pt-4",children:[t.jsxs("div",{className:"text-sm text-[var(--color-text-muted)]",children:["Showing ",M*Ji+1,"-",Math.min((M+1)*Ji,u)," of ",u]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>_(S=>Math.max(0,S-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"}),t.jsxs("span",{className:"text-sm text-[var(--color-text-muted)]",children:["Page ",M+1," of ",L]}),t.jsx("button",{onClick:()=>_(S=>Math.min(L-1,S+1)),disabled:M>=L-1,className:`px-3 py-1.5 text-sm bg-[var(--color-elevated)] border border-[var(--color-border)] rounded
|
|
218
|
+
text-[var(--color-text-secondary)] hover:bg-[var(--color-surface)]
|
|
219
|
+
disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:"Next"})]})]}),t.jsx(fC,{isOpen:$,onClose:()=>V(!1),onSave:de,item:D,mode:B,workflowId:r,sourceStepId:s||0,existingCategories:z}),X&&t.jsx(xC,{projectSlug:e,workflowId:r,steps:a,onClose:()=>I(!1),onImported:S=>{I(!1),H(),o==null||o(S)}})]})}function yC({projectSlug:e,workflowId:r,workflowName:s,onClose:a}){const[o,c]=y.useState(null),[d,u]=y.useState(!0),[h,p]=y.useState(!1),[x,g]=y.useState(null),[b,v]=y.useState(!1),[k,T]=y.useState(!0),[N,j]=y.useState(!0);y.useEffect(()=>{async function _(){try{const z=await _1(e,r);c(z)}catch(z){g(z instanceof Error?z.message:"Failed to load export preview")}finally{u(!1)}}_()},[e,r]);const A=async()=>{p(!0),g(null);try{const z=await L1(e,r,{include_runs:b,include_planning:k,strip_secrets:N}),P=URL.createObjectURL(z),$=document.createElement("a");$.href=P,$.download=`workflow-${(o==null?void 0:o.workflow_id)||r}-${new Date().toISOString().slice(0,10)}.ralphx.zip`,document.body.appendChild($),$.click(),document.body.removeChild($),URL.revokeObjectURL(P),a()}catch(_){g(_ instanceof Error?_.message:"Export failed")}finally{p(!1)}},M=_=>_<1024?`${_} B`:_<1024*1024?`${(_/1024).toFixed(1)} KB`:`${(_/(1024*1024)).toFixed(1)} MB`;return t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:a,onKeyDown:_=>_.key==="Escape"&&a(),role:"dialog","aria-modal":"true","aria-labelledby":"export-dialog-title",children:t.jsxs("div",{className:"card max-w-lg w-full mx-4 max-h-[90vh] overflow-y-auto",onClick:_=>_.stopPropagation(),children:[t.jsx("h3",{id:"export-dialog-title",className:"text-xl font-semibold text-white mb-4",children:"Export Workflow"}),x&&t.jsx("div",{className:"mb-4 p-3 rounded bg-red-900/30 border border-red-800 text-red-400 text-sm",children:x}),d?t.jsx("div",{className:"py-8 text-center text-gray-400",children:"Loading export preview..."}):o?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mb-6 p-4 rounded-lg bg-gray-800/50 border border-gray-700",children:[t.jsx("h4",{className:"font-medium text-white mb-2",children:s}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[t.jsx("div",{className:"text-gray-400",children:"Steps:"}),t.jsx("div",{className:"text-white",children:o.steps_count}),t.jsx("div",{className:"text-gray-400",children:"Items:"}),t.jsx("div",{className:"text-white",children:o.items_total}),t.jsx("div",{className:"text-gray-400",children:"Resources:"}),t.jsx("div",{className:"text-white",children:o.resources_count}),t.jsx("div",{className:"text-gray-400",children:"Estimated Size:"}),t.jsx("div",{className:"text-white",children:M(o.estimated_size_bytes)})]})]}),o.potential_secrets_detected&&t.jsx("div",{className:"mb-4 p-3 rounded bg-yellow-900/30 border border-yellow-700 text-yellow-400 text-sm",children:t.jsxs("div",{className:"flex items-start space-x-2",children:[t.jsx("svg",{className:"w-5 h-5 flex-shrink-0 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsxs("div",{children:[t.jsx("strong",{children:"Potential secrets detected!"}),t.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.'})]})]})}),t.jsxs("div",{className:"mb-6 space-y-3",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-300",children:"Export Options"}),t.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:k,onChange:_=>T(_.target.checked),className:"w-4 h-4 rounded border-gray-600 bg-gray-800 text-cyan-500 focus:ring-cyan-500"}),t.jsxs("span",{className:"text-gray-300",children:["Include planning session",o.has_planning_session&&t.jsx("span",{className:"text-gray-500 ml-1",children:"(available)"})]})]}),t.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:b,onChange:_=>v(_.target.checked),className:"w-4 h-4 rounded border-gray-600 bg-gray-800 text-cyan-500 focus:ring-cyan-500"}),t.jsxs("span",{className:"text-gray-300",children:["Include execution history",o.runs_count>0&&t.jsxs("span",{className:"text-gray-500 ml-1",children:["(",o.runs_count," runs)"]})]})]}),t.jsxs("label",{className:"flex items-center space-x-3 cursor-pointer",children:[t.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"}),t.jsx("span",{className:"text-gray-300",children:"Strip potential secrets (recommended)"})]})]}),o.warnings.length>0&&t.jsxs("div",{className:"mb-4 p-3 rounded bg-yellow-900/20 border border-yellow-800 text-sm",children:[t.jsx("h5",{className:"text-yellow-400 font-medium mb-1",children:"Warnings"}),t.jsx("ul",{className:"list-disc list-inside text-yellow-300/80",children:o.warnings.map((_,z)=>t.jsx("li",{children:_},z))})]})]}):null,t.jsxs("div",{className:"flex justify-end space-x-3",children:[t.jsx("button",{onClick:a,className:"px-4 py-2 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 transition-colors",children:"Cancel"}),t.jsx("button",{onClick:A,disabled:d||h||!o,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:h?t.jsxs(t.Fragment,{children:[t.jsx("svg",{className:"w-4 h-4 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{children:"Exporting..."})]}):t.jsxs(t.Fragment,{children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{children:"Export"})]})})]})]})})}function vC(){const{slug:e,workflowId:r}=Vr(),s=Dr(),[a,o]=y.useState(null),[c,d]=y.useState([]),[u,h]=y.useState(!0),[p,x]=y.useState(null),[g,b]=y.useState(!1),[v,k]=y.useState(!1),[T,N]=y.useState(null),[j,A]=y.useState("steps"),[M,_]=y.useState(void 0),z=y.useCallback(async()=>{if(!(!e||!r))try{const[L,q]=await Promise.all([ga(e,r),hl(e,r)]);o(L),d(q),x(null)}catch(L){x(L instanceof Error?L.message:"Failed to load workflow")}finally{h(!1)}},[e,r]);y.useEffect(()=>{z()},[z]),y.useEffect(()=>{if(!a||a.status==="completed"||a.status==="draft")return;const L=setInterval(z,2e3);return()=>clearInterval(L)},[a,z]);const P=async()=>{(await gt.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 $()},$=async()=>{if(!(!e||!r)){b(!0);try{const L=await e1(e,r);o(L)}catch(L){x(L instanceof Error?L.message:"Failed to start workflow")}finally{b(!1)}}},V=async()=>{if(!(!e||!r||!(await gt.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 q=await ex(e,r);o(q)}catch(q){x(q instanceof Error?q.message:"Failed to stop workflow")}finally{b(!1)}}},B=async()=>{if(!(!e||!r||!(await gt.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 Xb(e,r),s(`/projects/${e}/workflows`)}catch(q){x(q instanceof Error?q.message:"Failed to archive workflow"),b(!1)}}},U=async L=>{var G;if(!e||!r)return;const q=((G=((a==null?void 0:a.steps)||[]).find(re=>re.step_number===L))==null?void 0:G.name)||`Step ${L}`;if((await gt.fire({title:"Run Ralph Loop?",text:`Start executing "${q}"?`,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 re=await tx(e,r,L);o(re)}catch(re){x(re instanceof Error?re.message:"Failed to run step")}finally{b(!1)}}},D=async L=>{await V()},R=L=>{_(L),A("items")},X=async(L,q,S)=>{!e||!r||(await da(e,r,L,{content:q,expected_updated_at:S}),await z())};if(u)return t.jsx("div",{className:"p-6",children:t.jsx("div",{className:"text-gray-400",children:"Loading workflow..."})});if(p&&!a)return t.jsx("div",{className:"p-6",children:t.jsxs("div",{className:"card bg-red-900/20 border border-red-800",children:[t.jsx("h2",{className:"text-lg font-semibold text-red-400 mb-2",children:"Error"}),t.jsx("p",{className:"text-gray-300",children:p}),t.jsx(Re,{to:`/projects/${e}/workflows`,className:"btn-secondary mt-4 inline-block",children:"Back to Workflows"})]})});if(!a)return t.jsx("div",{className:"p-6",children:t.jsx("div",{className:"card",children:t.jsx("p",{className:"text-gray-400",children:"Workflow not found"})})});const I=a.steps||[],H=I.some(L=>L.has_active_run===!0),J=a.status==="active"?H?"running":"idle":a.status,Z=a.status!=="completed"&&!H,de=H,E={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 t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"mb-6",children:[t.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[t.jsx(Re,{to:"/",className:"hover:text-white",children:"Dashboard"}),t.jsx("span",{children:"/"}),t.jsx(Re,{to:`/projects/${e}`,className:"hover:text-white",children:e}),t.jsx("span",{children:"/"}),t.jsx(Re,{to:`/projects/${e}/workflows`,className:"hover:text-white",children:"Workflows"}),t.jsx("span",{children:"/"}),t.jsx("span",{className:"text-white",children:a.name})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center space-x-4",children:[t.jsx("h1",{className:"text-3xl font-bold text-white",children:a.name}),t.jsx("span",{className:`px-3 py-1 rounded-full text-sm font-medium text-white ${E[J]}`,children:J.charAt(0).toUpperCase()+J.slice(1)})]}),t.jsxs("div",{className:"flex items-center space-x-3",children:[Z&&t.jsxs("button",{onClick:P,disabled:g,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:[t.jsxs("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[t.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"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})]}),t.jsx("span",{children:"Run Full Workflow Ralph Loops"})]}),de&&t.jsxs("button",{onClick:V,disabled:g,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:[t.jsxs("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"}),t.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"})]}),t.jsx("span",{children:"Stop Workflow"})]}),t.jsxs("button",{onClick:()=>k(!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:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{children:"Export Workflow"})]}),t.jsxs("button",{onClick:()=>s(`/projects/${e}/workflows/${r}/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:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{children:"Edit"})]}),t.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:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{children:"Archive"})]})]})]})]}),p&&a&&t.jsx("div",{className:"mb-6 p-4 rounded-lg bg-red-900/20 border border-red-800",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("p",{className:"text-red-400 text-sm",children:p}),t.jsx("button",{onClick:()=>x(null),className:"text-red-400 hover:text-red-300","aria-label":"Dismiss error",children:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),t.jsxs("div",{className:"flex border-b border-[var(--color-border)] mb-6",children:[t.jsxs("button",{onClick:()=>A("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"&&t.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-cyan-500"})]}),t.jsxs("button",{onClick:()=>{A("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",I.reduce((L,q)=>L+(q.items_generated||0),0)>0&&t.jsx("span",{className:"px-1.5 py-0.5 text-xs rounded-full bg-cyan-500/20 text-cyan-400",children:I.reduce((L,q)=>L+(q.items_generated||0),0)}),j==="items"&&t.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-cyan-500"})]})]}),j==="items"&&t.jsx("div",{className:"card",children:t.jsx(Gg,{projectSlug:e,workflowId:r,sourceStepId:M,steps:I,onImported:L=>{N(L),z()}})}),j==="steps"&&t.jsxs("div",{children:[t.jsx(hC,{workflow:a,resources:c,projectSlug:e,workflowId:r,onResourceUpdate:X}),t.jsx("div",{className:"text-xs font-semibold text-[var(--color-text-muted)] uppercase tracking-wider mb-3",children:"Steps"}),t.jsx(aC,{steps:I,currentStep:a.current_step,projectSlug:e,workflowId:r,onRunStep:U,onStopStep:D,onItemsClick:R,isRunning:g}),a.status==="completed"&&t.jsxs("div",{className:"card text-center py-8 mt-6",children:[t.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-blue-900/30 flex items-center justify-center",children:t.jsx("svg",{className:"w-8 h-8 text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.jsx("h3",{className:"text-xl font-semibold text-white mb-2",children:"Workflow Complete!"}),t.jsx("p",{className:"text-gray-400",children:"All steps have been completed successfully."})]})]}),v&&t.jsx(yC,{projectSlug:e,workflowId:r,workflowName:a.name,onClose:()=>k(!1)}),T&&t.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:t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-green-400 font-medium",children:"Import Complete"}),t.jsxs("p",{className:"text-sm text-gray-300 mt-1",children:["Imported ",T.imported," items",T.skipped>0&&`, skipped ${T.skipped}`]}),T.errors.length>0&&t.jsxs("p",{className:"text-sm text-yellow-400 mt-1",children:[T.errors.length," error(s)"]})]}),t.jsx("button",{onClick:()=>N(null),className:"text-gray-400 hover:text-white ml-4",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})]})}function wC(e,r){const s={};return(e[e.length-1]===""?[...e,""]:e).join((s.padRight?" ":"")+","+(s.padLeft===!1?"":" ")).trim()}const bC=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,jC=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,kC={};function Qp(e,r){return(kC.jsx?jC:bC).test(e)}const NC=/[ \t\n\f\r]/g;function CC(e){return typeof e=="object"?e.type==="text"?Jp(e.value):!1:Jp(e)}function Jp(e){return e.replace(NC,"")===""}class Na{constructor(r,s,a){this.normal=s,this.property=r,a&&(this.space=a)}}Na.prototype.normal={};Na.prototype.property={};Na.prototype.space=void 0;function Kg(e,r){const s={},a={};for(const o of e)Object.assign(s,o.property),Object.assign(a,o.normal);return new Na(s,a,r)}function Xd(e){return e.toLowerCase()}class yr{constructor(r,s){this.attribute=s,this.property=r}}yr.prototype.attribute="";yr.prototype.booleanish=!1;yr.prototype.boolean=!1;yr.prototype.commaOrSpaceSeparated=!1;yr.prototype.commaSeparated=!1;yr.prototype.defined=!1;yr.prototype.mustUseProperty=!1;yr.prototype.number=!1;yr.prototype.overloadedBoolean=!1;yr.prototype.property="";yr.prototype.spaceSeparated=!1;yr.prototype.space=void 0;let SC=0;const He=bs(),_t=bs(),Zd=bs(),ye=bs(),it=bs(),Zs=bs(),Nr=bs();function bs(){return 2**++SC}const eu=Object.freeze(Object.defineProperty({__proto__:null,boolean:He,booleanish:_t,commaOrSpaceSeparated:Nr,commaSeparated:Zs,number:ye,overloadedBoolean:Zd,spaceSeparated:it},Symbol.toStringTag,{value:"Module"})),jd=Object.keys(eu);class Uu extends yr{constructor(r,s,a,o){let c=-1;if(super(r,s),Xp(this,"space",o),typeof a=="number")for(;++c<jd.length;){const d=jd[c];Xp(this,jd[c],(a&eu[d])===eu[d])}}}Uu.prototype.defined=!0;function Xp(e,r,s){s&&(e[r]=s)}function ui(e){const r={},s={};for(const[a,o]of Object.entries(e.properties)){const c=new Uu(a,e.transform(e.attributes||{},a),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(a)&&(c.mustUseProperty=!0),r[a]=c,s[Xd(a)]=a,s[Xd(c.attribute)]=a}return new Na(r,s,e.space)}const Qg=ui({properties:{ariaActiveDescendant:null,ariaAtomic:_t,ariaAutoComplete:null,ariaBusy:_t,ariaChecked:_t,ariaColCount:ye,ariaColIndex:ye,ariaColSpan:ye,ariaControls:it,ariaCurrent:null,ariaDescribedBy:it,ariaDetails:null,ariaDisabled:_t,ariaDropEffect:it,ariaErrorMessage:null,ariaExpanded:_t,ariaFlowTo:it,ariaGrabbed:_t,ariaHasPopup:null,ariaHidden:_t,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:it,ariaLevel:ye,ariaLive:null,ariaModal:_t,ariaMultiLine:_t,ariaMultiSelectable:_t,ariaOrientation:null,ariaOwns:it,ariaPlaceholder:null,ariaPosInSet:ye,ariaPressed:_t,ariaReadOnly:_t,ariaRelevant:null,ariaRequired:_t,ariaRoleDescription:it,ariaRowCount:ye,ariaRowIndex:ye,ariaRowSpan:ye,ariaSelected:_t,ariaSetSize:ye,ariaSort:null,ariaValueMax:ye,ariaValueMin:ye,ariaValueNow:ye,ariaValueText:null,role:null},transform(e,r){return r==="role"?r:"aria-"+r.slice(4).toLowerCase()}});function Jg(e,r){return r in e?e[r]:r}function Xg(e,r){return Jg(e,r.toLowerCase())}const _C=ui({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Zs,acceptCharset:it,accessKey:it,action:null,allow:null,allowFullScreen:He,allowPaymentRequest:He,allowUserMedia:He,alt:null,as:null,async:He,autoCapitalize:null,autoComplete:it,autoFocus:He,autoPlay:He,blocking:it,capture:null,charSet:null,checked:He,cite:null,className:it,cols:ye,colSpan:null,content:null,contentEditable:_t,controls:He,controlsList:it,coords:ye|Zs,crossOrigin:null,data:null,dateTime:null,decoding:null,default:He,defer:He,dir:null,dirName:null,disabled:He,download:Zd,draggable:_t,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:He,formTarget:null,headers:it,height:ye,hidden:Zd,high:ye,href:null,hrefLang:null,htmlFor:it,httpEquiv:it,id:null,imageSizes:null,imageSrcSet:null,inert:He,inputMode:null,integrity:null,is:null,isMap:He,itemId:null,itemProp:it,itemRef:it,itemScope:He,itemType:it,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:He,low:ye,manifest:null,max:null,maxLength:ye,media:null,method:null,min:null,minLength:ye,multiple:He,muted:He,name:null,nonce:null,noModule:He,noValidate:He,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:He,optimum:ye,pattern:null,ping:it,placeholder:null,playsInline:He,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:He,referrerPolicy:null,rel:it,required:He,reversed:He,rows:ye,rowSpan:ye,sandbox:it,scope:null,scoped:He,seamless:He,selected:He,shadowRootClonable:He,shadowRootDelegatesFocus:He,shadowRootMode:null,shape:null,size:ye,sizes:null,slot:null,span:ye,spellCheck:_t,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ye,step:null,style:null,tabIndex:ye,target:null,title:null,translate:null,type:null,typeMustMatch:He,useMap:null,value:_t,width:ye,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:it,axis:null,background:null,bgColor:null,border:ye,borderColor:null,bottomMargin:ye,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:He,declare:He,event:null,face:null,frame:null,frameBorder:null,hSpace:ye,leftMargin:ye,link:null,longDesc:null,lowSrc:null,marginHeight:ye,marginWidth:ye,noResize:He,noHref:He,noShade:He,noWrap:He,object:null,profile:null,prompt:null,rev:null,rightMargin:ye,rules:null,scheme:null,scrolling:_t,standby:null,summary:null,text:null,topMargin:ye,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ye,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:He,disableRemotePlayback:He,prefix:null,property:null,results:ye,security:null,unselectable:null},space:"html",transform:Xg}),LC=ui({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Nr,accentHeight:ye,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ye,amplitude:ye,arabicForm:null,ascent:ye,attributeName:null,attributeType:null,azimuth:ye,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ye,by:null,calcMode:null,capHeight:ye,className:it,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ye,diffuseConstant:ye,direction:null,display:null,dur:null,divisor:ye,dominantBaseline:null,download:He,dx:null,dy:null,edgeMode:null,editable:null,elevation:ye,enableBackground:null,end:null,event:null,exponent:ye,externalResourcesRequired:null,fill:null,fillOpacity:ye,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Zs,g2:Zs,glyphName:Zs,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ye,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ye,horizOriginX:ye,horizOriginY:ye,id:null,ideographic:ye,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ye,k:ye,k1:ye,k2:ye,k3:ye,k4:ye,kernelMatrix:Nr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ye,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ye,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ye,overlineThickness:ye,paintOrder:null,panose1:null,path:null,pathLength:ye,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:it,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ye,pointsAtY:ye,pointsAtZ:ye,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Nr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Nr,rev:Nr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Nr,requiredFeatures:Nr,requiredFonts:Nr,requiredFormats:Nr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ye,specularExponent:ye,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ye,strikethroughThickness:ye,string:null,stroke:null,strokeDashArray:Nr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ye,strokeOpacity:ye,strokeWidth:null,style:null,surfaceScale:ye,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Nr,tabIndex:ye,tableValues:null,target:null,targetX:ye,targetY:ye,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Nr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ye,underlineThickness:ye,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ye,values:null,vAlphabetic:ye,vMathematical:ye,vectorEffect:null,vHanging:ye,vIdeographic:ye,version:null,vertAdvY:ye,vertOriginX:ye,vertOriginY:ye,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ye,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Jg}),Zg=ui({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,r){return"xlink:"+r.slice(5).toLowerCase()}}),ey=ui({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Xg}),ty=ui({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,r){return"xml:"+r.slice(3).toLowerCase()}}),EC={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},TC=/[A-Z]/g,Zp=/-[a-z]/g,AC=/^data[-\w.:]+$/i;function PC(e,r){const s=Xd(r);let a=r,o=yr;if(s in e.normal)return e.property[e.normal[s]];if(s.length>4&&s.slice(0,4)==="data"&&AC.test(r)){if(r.charAt(4)==="-"){const c=r.slice(5).replace(Zp,MC);a="data"+c.charAt(0).toUpperCase()+c.slice(1)}else{const c=r.slice(4);if(!Zp.test(c)){let d=c.replace(TC,IC);d.charAt(0)!=="-"&&(d="-"+d),r="data"+d}}o=Uu}return new o(a,r)}function IC(e){return"-"+e.toLowerCase()}function MC(e){return e.charAt(1).toUpperCase()}const RC=Kg([Qg,_C,Zg,ey,ty],"html"),Vu=Kg([Qg,LC,Zg,ey,ty],"svg");function $C(e){return e.join(" ").trim()}var qs={},kd,ef;function DC(){if(ef)return kd;ef=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,s=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,c=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,d=/^[;\s]*/,u=/^\s+|\s+$/g,h=`
|
|
222
|
+
`,p="/",x="*",g="",b="comment",v="declaration";function k(N,j){if(typeof N!="string")throw new TypeError("First argument must be a string");if(!N)return[];j=j||{};var A=1,M=1;function _(I){var H=I.match(r);H&&(A+=H.length);var W=I.lastIndexOf(h);M=~W?I.length-W:M+I.length}function z(){var I={line:A,column:M};return function(H){return H.position=new P(I),B(),H}}function P(I){this.start=I,this.end={line:A,column:M},this.source=j.source}P.prototype.content=N;function $(I){var H=new Error(j.source+":"+A+":"+M+": "+I);if(H.reason=I,H.filename=j.source,H.line=A,H.column=M,H.source=N,!j.silent)throw H}function V(I){var H=I.exec(N);if(H){var W=H[0];return _(W),N=N.slice(W.length),H}}function B(){V(s)}function U(I){var H;for(I=I||[];H=D();)H!==!1&&I.push(H);return I}function D(){var I=z();if(!(p!=N.charAt(0)||x!=N.charAt(1))){for(var H=2;g!=N.charAt(H)&&(x!=N.charAt(H)||p!=N.charAt(H+1));)++H;if(H+=2,g===N.charAt(H-1))return $("End of comment missing");var W=N.slice(2,H-2);return M+=2,_(W),N=N.slice(H),M+=2,I({type:b,comment:W})}}function R(){var I=z(),H=V(a);if(H){if(D(),!V(o))return $("property missing ':'");var W=V(c),J=I({type:v,property:T(H[0].replace(e,g)),value:W?T(W[0].replace(e,g)):g});return V(d),J}}function X(){var I=[];U(I);for(var H;H=R();)H!==!1&&(I.push(H),U(I));return I}return B(),X()}function T(N){return N?N.replace(u,g):g}return kd=k,kd}var tf;function BC(){if(tf)return qs;tf=1;var e=qs&&qs.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(qs,"__esModule",{value:!0}),qs.default=s;const r=e(DC());function s(a,o){let c=null;if(!a||typeof a!="string")return c;const d=(0,r.default)(a),u=typeof o=="function";return d.forEach(h=>{if(h.type!=="declaration")return;const{property:p,value:x}=h;u?o(p,x,h):x&&(c=c||{},c[p]=x)}),c}return qs}var Xi={},rf;function zC(){if(rf)return Xi;rf=1,Object.defineProperty(Xi,"__esModule",{value:!0}),Xi.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,r=/-([a-z])/g,s=/^[^-]+$/,a=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,c=function(p){return!p||s.test(p)||e.test(p)},d=function(p,x){return x.toUpperCase()},u=function(p,x){return"".concat(x,"-")},h=function(p,x){return x===void 0&&(x={}),c(p)?p:(p=p.toLowerCase(),x.reactCompat?p=p.replace(o,u):p=p.replace(a,u),p.replace(r,d))};return Xi.camelCase=h,Xi}var Zi,nf;function OC(){if(nf)return Zi;nf=1;var e=Zi&&Zi.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},r=e(BC()),s=zC();function a(o,c){var d={};return!o||typeof o!="string"||(0,r.default)(o,function(u,h){u&&h&&(d[(0,s.camelCase)(u,c)]=h)}),d}return a.default=a,Zi=a,Zi}var FC=OC();const WC=ul(FC),ry=ny("end"),qu=ny("start");function ny(e){return r;function r(s){const a=s&&s.position&&s.position[e]||{};if(typeof a.line=="number"&&a.line>0&&typeof a.column=="number"&&a.column>0)return{line:a.line,column:a.column,offset:typeof a.offset=="number"&&a.offset>-1?a.offset:void 0}}}function HC(e){const r=qu(e),s=ry(e);if(r&&s)return{start:r,end:s}}function ia(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?sf(e.position):"start"in e||"end"in e?sf(e):"line"in e||"column"in e?tu(e):""}function tu(e){return af(e&&e.line)+":"+af(e&&e.column)}function sf(e){return tu(e&&e.start)+"-"+tu(e&&e.end)}function af(e){return e&&typeof e=="number"?e:1}class Xt extends Error{constructor(r,s,a){super(),typeof s=="string"&&(a=s,s=void 0);let o="",c={},d=!1;if(s&&("line"in s&&"column"in s?c={place:s}:"start"in s&&"end"in s?c={place:s}:"type"in s?c={ancestors:[s],place:s.position}:c={...s}),typeof r=="string"?o=r:!c.cause&&r&&(d=!0,o=r.message,c.cause=r),!c.ruleId&&!c.source&&typeof a=="string"){const h=a.indexOf(":");h===-1?c.ruleId=a:(c.source=a.slice(0,h),c.ruleId=a.slice(h+1))}if(!c.place&&c.ancestors&&c.ancestors){const h=c.ancestors[c.ancestors.length-1];h&&(c.place=h.position)}const u=c.place&&"start"in c.place?c.place.start:c.place;this.ancestors=c.ancestors||void 0,this.cause=c.cause||void 0,this.column=u?u.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=u?u.line:void 0,this.name=ia(c.place)||"1:1",this.place=c.place||void 0,this.reason=this.message,this.ruleId=c.ruleId||void 0,this.source=c.source||void 0,this.stack=d&&c.cause&&typeof c.cause.stack=="string"?c.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Xt.prototype.file="";Xt.prototype.name="";Xt.prototype.reason="";Xt.prototype.message="";Xt.prototype.stack="";Xt.prototype.column=void 0;Xt.prototype.line=void 0;Xt.prototype.ancestors=void 0;Xt.prototype.cause=void 0;Xt.prototype.fatal=void 0;Xt.prototype.place=void 0;Xt.prototype.ruleId=void 0;Xt.prototype.source=void 0;const Yu={}.hasOwnProperty,UC=new Map,VC=/[A-Z]/g,qC=new Set(["table","tbody","thead","tfoot","tr"]),YC=new Set(["td","th"]),sy="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function GC(e,r){if(!r||r.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const s=r.filePath||void 0;let a;if(r.development){if(typeof r.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");a=rS(s,r.jsxDEV)}else{if(typeof r.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof r.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");a=tS(s,r.jsx,r.jsxs)}const o={Fragment:r.Fragment,ancestors:[],components:r.components||{},create:a,elementAttributeNameCase:r.elementAttributeNameCase||"react",evaluater:r.createEvaluater?r.createEvaluater():void 0,filePath:s,ignoreInvalidStyle:r.ignoreInvalidStyle||!1,passKeys:r.passKeys!==!1,passNode:r.passNode||!1,schema:r.space==="svg"?Vu:RC,stylePropertyNameCase:r.stylePropertyNameCase||"dom",tableCellAlignToStyle:r.tableCellAlignToStyle!==!1},c=iy(o,e,void 0);return c&&typeof c!="string"?c:o.create(e,o.Fragment,{children:c||void 0},void 0)}function iy(e,r,s){if(r.type==="element")return KC(e,r,s);if(r.type==="mdxFlowExpression"||r.type==="mdxTextExpression")return QC(e,r);if(r.type==="mdxJsxFlowElement"||r.type==="mdxJsxTextElement")return XC(e,r,s);if(r.type==="mdxjsEsm")return JC(e,r);if(r.type==="root")return ZC(e,r,s);if(r.type==="text")return eS(e,r)}function KC(e,r,s){const a=e.schema;let o=a;r.tagName.toLowerCase()==="svg"&&a.space==="html"&&(o=Vu,e.schema=o),e.ancestors.push(r);const c=oy(e,r.tagName,!1),d=nS(e,r);let u=Ku(e,r);return qC.has(r.tagName)&&(u=u.filter(function(h){return typeof h=="string"?!CC(h):!0})),ay(e,d,c,r),Gu(d,u),e.ancestors.pop(),e.schema=a,e.create(r,c,d,s)}function QC(e,r){if(r.data&&r.data.estree&&e.evaluater){const a=r.data.estree.body[0];return a.type,e.evaluater.evaluateExpression(a.expression)}fa(e,r.position)}function JC(e,r){if(r.data&&r.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(r.data.estree);fa(e,r.position)}function XC(e,r,s){const a=e.schema;let o=a;r.name==="svg"&&a.space==="html"&&(o=Vu,e.schema=o),e.ancestors.push(r);const c=r.name===null?e.Fragment:oy(e,r.name,!0),d=sS(e,r),u=Ku(e,r);return ay(e,d,c,r),Gu(d,u),e.ancestors.pop(),e.schema=a,e.create(r,c,d,s)}function ZC(e,r,s){const a={};return Gu(a,Ku(e,r)),e.create(r,e.Fragment,a,s)}function eS(e,r){return r.value}function ay(e,r,s,a){typeof s!="string"&&s!==e.Fragment&&e.passNode&&(r.node=a)}function Gu(e,r){if(r.length>0){const s=r.length>1?r:r[0];s&&(e.children=s)}}function tS(e,r,s){return a;function a(o,c,d,u){const p=Array.isArray(d.children)?s:r;return u?p(c,d,u):p(c,d)}}function rS(e,r){return s;function s(a,o,c,d){const u=Array.isArray(c.children),h=qu(a);return r(o,c,d,u,{columnNumber:h?h.column-1:void 0,fileName:e,lineNumber:h?h.line:void 0},void 0)}}function nS(e,r){const s={};let a,o;for(o in r.properties)if(o!=="children"&&Yu.call(r.properties,o)){const c=iS(e,o,r.properties[o]);if(c){const[d,u]=c;e.tableCellAlignToStyle&&d==="align"&&typeof u=="string"&&YC.has(r.tagName)?a=u:s[d]=u}}if(a){const c=s.style||(s.style={});c[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=a}return s}function sS(e,r){const s={};for(const a of r.attributes)if(a.type==="mdxJsxExpressionAttribute")if(a.data&&a.data.estree&&e.evaluater){const c=a.data.estree.body[0];c.type;const d=c.expression;d.type;const u=d.properties[0];u.type,Object.assign(s,e.evaluater.evaluateExpression(u.argument))}else fa(e,r.position);else{const o=a.name;let c;if(a.value&&typeof a.value=="object")if(a.value.data&&a.value.data.estree&&e.evaluater){const u=a.value.data.estree.body[0];u.type,c=e.evaluater.evaluateExpression(u.expression)}else fa(e,r.position);else c=a.value===null?!0:a.value;s[o]=c}return s}function Ku(e,r){const s=[];let a=-1;const o=e.passKeys?new Map:UC;for(;++a<r.children.length;){const c=r.children[a];let d;if(e.passKeys){const h=c.type==="element"?c.tagName:c.type==="mdxJsxFlowElement"||c.type==="mdxJsxTextElement"?c.name:void 0;if(h){const p=o.get(h)||0;d=h+"-"+p,o.set(h,p+1)}}const u=iy(e,c,d);u!==void 0&&s.push(u)}return s}function iS(e,r,s){const a=PC(e.schema,r);if(!(s==null||typeof s=="number"&&Number.isNaN(s))){if(Array.isArray(s)&&(s=a.commaSeparated?wC(s):$C(s)),a.property==="style"){let o=typeof s=="object"?s:aS(e,String(s));return e.stylePropertyNameCase==="css"&&(o=oS(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&a.space?EC[a.property]||a.property:a.attribute,s]}}function aS(e,r){try{return WC(r,{reactCompat:!0})}catch(s){if(e.ignoreInvalidStyle)return{};const a=s,o=new Xt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:a,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=sy+"#cannot-parse-style-attribute",o}}function oy(e,r,s){let a;if(!s)a={type:"Literal",value:r};else if(r.includes(".")){const o=r.split(".");let c=-1,d;for(;++c<o.length;){const u=Qp(o[c])?{type:"Identifier",name:o[c]}:{type:"Literal",value:o[c]};d=d?{type:"MemberExpression",object:d,property:u,computed:!!(c&&u.type==="Literal"),optional:!1}:u}a=d}else a=Qp(r)&&!/^[a-z]/.test(r)?{type:"Identifier",name:r}:{type:"Literal",value:r};if(a.type==="Literal"){const o=a.value;return Yu.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(a);fa(e)}function fa(e,r){const s=new Xt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:r,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=sy+"#cannot-handle-mdx-estrees-without-createevaluater",s}function oS(e){const r={};let s;for(s in e)Yu.call(e,s)&&(r[lS(s)]=e[s]);return r}function lS(e){let r=e.replace(VC,cS);return r.slice(0,3)==="ms-"&&(r="-"+r),r}function cS(e){return"-"+e.toLowerCase()}const Nd={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},dS={};function uS(e,r){const s=dS,a=typeof s.includeImageAlt=="boolean"?s.includeImageAlt:!0,o=typeof s.includeHtml=="boolean"?s.includeHtml:!0;return ly(e,a,o)}function ly(e,r,s){if(mS(e)){if("value"in e)return e.type==="html"&&!s?"":e.value;if(r&&"alt"in e&&e.alt)return e.alt;if("children"in e)return of(e.children,r,s)}return Array.isArray(e)?of(e,r,s):""}function of(e,r,s){const a=[];let o=-1;for(;++o<e.length;)a[o]=ly(e[o],r,s);return a.join("")}function mS(e){return!!(e&&typeof e=="object")}const lf=document.createElement("i");function Qu(e){const r="&"+e+";";lf.innerHTML=r;const s=lf.textContent;return s.charCodeAt(s.length-1)===59&&e!=="semi"||s===r?!1:s}function rn(e,r,s,a){const o=e.length;let c=0,d;if(r<0?r=-r>o?0:o+r:r=r>o?o:r,s=s>0?s:0,a.length<1e4)d=Array.from(a),d.unshift(r,s),e.splice(...d);else for(s&&e.splice(r,s);c<a.length;)d=a.slice(c,c+1e4),d.unshift(r,0),e.splice(...d),c+=1e4,r+=1e4}function Rr(e,r){return e.length>0?(rn(e,e.length,0,r),e):r}const cf={}.hasOwnProperty;function hS(e){const r={};let s=-1;for(;++s<e.length;)pS(r,e[s]);return r}function pS(e,r){let s;for(s in r){const o=(cf.call(e,s)?e[s]:void 0)||(e[s]={}),c=r[s];let d;if(c)for(d in c){cf.call(o,d)||(o[d]=[]);const u=c[d];fS(o[d],Array.isArray(u)?u:u?[u]:[])}}}function fS(e,r){let s=-1;const a=[];for(;++s<r.length;)(r[s].add==="after"?e:a).push(r[s]);rn(e,0,0,a)}function cy(e,r){const s=Number.parseInt(e,r);return s<9||s===11||s>13&&s<32||s>126&&s<160||s>55295&&s<57344||s>64975&&s<65008||(s&65535)===65535||(s&65535)===65534||s>1114111?"�":String.fromCodePoint(s)}function ei(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Zr=Jn(/[A-Za-z]/),Cr=Jn(/[\dA-Za-z]/),xS=Jn(/[#-'*+\--9=?A-Z^-~]/);function ru(e){return e!==null&&(e<32||e===127)}const nu=Jn(/\d/),gS=Jn(/[\dA-Fa-f]/),yS=Jn(/[!-/:-@[-`{-~]/);function ze(e){return e!==null&&e<-2}function gr(e){return e!==null&&(e<0||e===32)}function Je(e){return e===-2||e===-1||e===32}const vS=Jn(new RegExp("\\p{P}|\\p{S}","u")),wS=Jn(/\s/);function Jn(e){return r;function r(s){return s!==null&&s>-1&&e.test(String.fromCharCode(s))}}function mi(e){const r=[];let s=-1,a=0,o=0;for(;++s<e.length;){const c=e.charCodeAt(s);let d="";if(c===37&&Cr(e.charCodeAt(s+1))&&Cr(e.charCodeAt(s+2)))o=2;else if(c<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(c))||(d=String.fromCharCode(c));else if(c>55295&&c<57344){const u=e.charCodeAt(s+1);c<56320&&u>56319&&u<57344?(d=String.fromCharCode(c,u),o=1):d="�"}else d=String.fromCharCode(c);d&&(r.push(e.slice(a,s),encodeURIComponent(d)),a=s+o+1,d=""),o&&(s+=o,o=0)}return r.join("")+e.slice(a)}function at(e,r,s,a){const o=a?a-1:Number.POSITIVE_INFINITY;let c=0;return d;function d(h){return Je(h)?(e.enter(s),u(h)):r(h)}function u(h){return Je(h)&&c++<o?(e.consume(h),u):(e.exit(s),r(h))}}const bS={tokenize:jS};function jS(e){const r=e.attempt(this.parser.constructs.contentInitial,a,o);let s;return r;function a(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),at(e,r,"linePrefix")}function o(u){return e.enter("paragraph"),c(u)}function c(u){const h=e.enter("chunkText",{contentType:"text",previous:s});return s&&(s.next=h),s=h,d(u)}function d(u){if(u===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(u);return}return ze(u)?(e.consume(u),e.exit("chunkText"),c):(e.consume(u),d)}}const kS={tokenize:NS},df={tokenize:CS};function NS(e){const r=this,s=[];let a=0,o,c,d;return u;function u(M){if(a<s.length){const _=s[a];return r.containerState=_[1],e.attempt(_[0].continuation,h,p)(M)}return p(M)}function h(M){if(a++,r.containerState._closeFlow){r.containerState._closeFlow=void 0,o&&A();const _=r.events.length;let z=_,P;for(;z--;)if(r.events[z][0]==="exit"&&r.events[z][1].type==="chunkFlow"){P=r.events[z][1].end;break}j(a);let $=_;for(;$<r.events.length;)r.events[$][1].end={...P},$++;return rn(r.events,z+1,0,r.events.slice(_)),r.events.length=$,p(M)}return u(M)}function p(M){if(a===s.length){if(!o)return b(M);if(o.currentConstruct&&o.currentConstruct.concrete)return k(M);r.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return r.containerState={},e.check(df,x,g)(M)}function x(M){return o&&A(),j(a),b(M)}function g(M){return r.parser.lazy[r.now().line]=a!==s.length,d=r.now().offset,k(M)}function b(M){return r.containerState={},e.attempt(df,v,k)(M)}function v(M){return a++,s.push([r.currentConstruct,r.containerState]),b(M)}function k(M){if(M===null){o&&A(),j(0),e.consume(M);return}return o=o||r.parser.flow(r.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:c}),T(M)}function T(M){if(M===null){N(e.exit("chunkFlow"),!0),j(0),e.consume(M);return}return ze(M)?(e.consume(M),N(e.exit("chunkFlow")),a=0,r.interrupt=void 0,u):(e.consume(M),T)}function N(M,_){const z=r.sliceStream(M);if(_&&z.push(null),M.previous=c,c&&(c.next=M),c=M,o.defineSkip(M.start),o.write(z),r.parser.lazy[M.start.line]){let P=o.events.length;for(;P--;)if(o.events[P][1].start.offset<d&&(!o.events[P][1].end||o.events[P][1].end.offset>d))return;const $=r.events.length;let V=$,B,U;for(;V--;)if(r.events[V][0]==="exit"&&r.events[V][1].type==="chunkFlow"){if(B){U=r.events[V][1].end;break}B=!0}for(j(a),P=$;P<r.events.length;)r.events[P][1].end={...U},P++;rn(r.events,V+1,0,r.events.slice($)),r.events.length=P}}function j(M){let _=s.length;for(;_-- >M;){const z=s[_];r.containerState=z[1],z[0].exit.call(r,e)}s.length=M}function A(){o.write([null]),c=void 0,o=void 0,r.containerState._closeFlow=void 0}}function CS(e,r,s){return at(e,e.attempt(this.parser.constructs.document,r,s),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function uf(e){if(e===null||gr(e)||wS(e))return 1;if(vS(e))return 2}function Ju(e,r,s){const a=[];let o=-1;for(;++o<e.length;){const c=e[o].resolveAll;c&&!a.includes(c)&&(r=c(r,s),a.push(c))}return r}const su={name:"attention",resolveAll:SS,tokenize:_S};function SS(e,r){let s=-1,a,o,c,d,u,h,p,x;for(;++s<e.length;)if(e[s][0]==="enter"&&e[s][1].type==="attentionSequence"&&e[s][1]._close){for(a=s;a--;)if(e[a][0]==="exit"&&e[a][1].type==="attentionSequence"&&e[a][1]._open&&r.sliceSerialize(e[a][1]).charCodeAt(0)===r.sliceSerialize(e[s][1]).charCodeAt(0)){if((e[a][1]._close||e[s][1]._open)&&(e[s][1].end.offset-e[s][1].start.offset)%3&&!((e[a][1].end.offset-e[a][1].start.offset+e[s][1].end.offset-e[s][1].start.offset)%3))continue;h=e[a][1].end.offset-e[a][1].start.offset>1&&e[s][1].end.offset-e[s][1].start.offset>1?2:1;const g={...e[a][1].end},b={...e[s][1].start};mf(g,-h),mf(b,h),d={type:h>1?"strongSequence":"emphasisSequence",start:g,end:{...e[a][1].end}},u={type:h>1?"strongSequence":"emphasisSequence",start:{...e[s][1].start},end:b},c={type:h>1?"strongText":"emphasisText",start:{...e[a][1].end},end:{...e[s][1].start}},o={type:h>1?"strong":"emphasis",start:{...d.start},end:{...u.end}},e[a][1].end={...d.start},e[s][1].start={...u.end},p=[],e[a][1].end.offset-e[a][1].start.offset&&(p=Rr(p,[["enter",e[a][1],r],["exit",e[a][1],r]])),p=Rr(p,[["enter",o,r],["enter",d,r],["exit",d,r],["enter",c,r]]),p=Rr(p,Ju(r.parser.constructs.insideSpan.null,e.slice(a+1,s),r)),p=Rr(p,[["exit",c,r],["enter",u,r],["exit",u,r],["exit",o,r]]),e[s][1].end.offset-e[s][1].start.offset?(x=2,p=Rr(p,[["enter",e[s][1],r],["exit",e[s][1],r]])):x=0,rn(e,a-1,s-a+3,p),s=a+p.length-x-2;break}}for(s=-1;++s<e.length;)e[s][1].type==="attentionSequence"&&(e[s][1].type="data");return e}function _S(e,r){const s=this.parser.constructs.attentionMarkers.null,a=this.previous,o=uf(a);let c;return d;function d(h){return c=h,e.enter("attentionSequence"),u(h)}function u(h){if(h===c)return e.consume(h),u;const p=e.exit("attentionSequence"),x=uf(h),g=!x||x===2&&o||s.includes(h),b=!o||o===2&&x||s.includes(a);return p._open=!!(c===42?g:g&&(o||!b)),p._close=!!(c===42?b:b&&(x||!g)),r(h)}}function mf(e,r){e.column+=r,e.offset+=r,e._bufferIndex+=r}const LS={name:"autolink",tokenize:ES};function ES(e,r,s){let a=0;return o;function o(v){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),c}function c(v){return Zr(v)?(e.consume(v),d):v===64?s(v):p(v)}function d(v){return v===43||v===45||v===46||Cr(v)?(a=1,u(v)):p(v)}function u(v){return v===58?(e.consume(v),a=0,h):(v===43||v===45||v===46||Cr(v))&&a++<32?(e.consume(v),u):(a=0,p(v))}function h(v){return v===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.exit("autolink"),r):v===null||v===32||v===60||ru(v)?s(v):(e.consume(v),h)}function p(v){return v===64?(e.consume(v),x):xS(v)?(e.consume(v),p):s(v)}function x(v){return Cr(v)?g(v):s(v)}function g(v){return v===46?(e.consume(v),a=0,x):v===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.exit("autolink"),r):b(v)}function b(v){if((v===45||Cr(v))&&a++<63){const k=v===45?b:g;return e.consume(v),k}return s(v)}}const wl={partial:!0,tokenize:TS};function TS(e,r,s){return a;function a(c){return Je(c)?at(e,o,"linePrefix")(c):o(c)}function o(c){return c===null||ze(c)?r(c):s(c)}}const dy={continuation:{tokenize:PS},exit:IS,name:"blockQuote",tokenize:AS};function AS(e,r,s){const a=this;return o;function o(d){if(d===62){const u=a.containerState;return u.open||(e.enter("blockQuote",{_container:!0}),u.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(d),e.exit("blockQuoteMarker"),c}return s(d)}function c(d){return Je(d)?(e.enter("blockQuotePrefixWhitespace"),e.consume(d),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),r):(e.exit("blockQuotePrefix"),r(d))}}function PS(e,r,s){const a=this;return o;function o(d){return Je(d)?at(e,c,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d):c(d)}function c(d){return e.attempt(dy,r,s)(d)}}function IS(e){e.exit("blockQuote")}const uy={name:"characterEscape",tokenize:MS};function MS(e,r,s){return a;function a(c){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(c),e.exit("escapeMarker"),o}function o(c){return yS(c)?(e.enter("characterEscapeValue"),e.consume(c),e.exit("characterEscapeValue"),e.exit("characterEscape"),r):s(c)}}const my={name:"characterReference",tokenize:RS};function RS(e,r,s){const a=this;let o=0,c,d;return u;function u(g){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),h}function h(g){return g===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(g),e.exit("characterReferenceMarkerNumeric"),p):(e.enter("characterReferenceValue"),c=31,d=Cr,x(g))}function p(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),c=6,d=gS,x):(e.enter("characterReferenceValue"),c=7,d=nu,x(g))}function x(g){if(g===59&&o){const b=e.exit("characterReferenceValue");return d===Cr&&!Qu(a.sliceSerialize(b))?s(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),r)}return d(g)&&o++<c?(e.consume(g),x):s(g)}}const hf={partial:!0,tokenize:DS},pf={concrete:!0,name:"codeFenced",tokenize:$S};function $S(e,r,s){const a=this,o={partial:!0,tokenize:z};let c=0,d=0,u;return h;function h(P){return p(P)}function p(P){const $=a.events[a.events.length-1];return c=$&&$[1].type==="linePrefix"?$[2].sliceSerialize($[1],!0).length:0,u=P,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),x(P)}function x(P){return P===u?(d++,e.consume(P),x):d<3?s(P):(e.exit("codeFencedFenceSequence"),Je(P)?at(e,g,"whitespace")(P):g(P))}function g(P){return P===null||ze(P)?(e.exit("codeFencedFence"),a.interrupt?r(P):e.check(hf,T,_)(P)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),b(P))}function b(P){return P===null||ze(P)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),g(P)):Je(P)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),at(e,v,"whitespace")(P)):P===96&&P===u?s(P):(e.consume(P),b)}function v(P){return P===null||ze(P)?g(P):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),k(P))}function k(P){return P===null||ze(P)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),g(P)):P===96&&P===u?s(P):(e.consume(P),k)}function T(P){return e.attempt(o,_,N)(P)}function N(P){return e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),j}function j(P){return c>0&&Je(P)?at(e,A,"linePrefix",c+1)(P):A(P)}function A(P){return P===null||ze(P)?e.check(hf,T,_)(P):(e.enter("codeFlowValue"),M(P))}function M(P){return P===null||ze(P)?(e.exit("codeFlowValue"),A(P)):(e.consume(P),M)}function _(P){return e.exit("codeFenced"),r(P)}function z(P,$,V){let B=0;return U;function U(H){return P.enter("lineEnding"),P.consume(H),P.exit("lineEnding"),D}function D(H){return P.enter("codeFencedFence"),Je(H)?at(P,R,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(H):R(H)}function R(H){return H===u?(P.enter("codeFencedFenceSequence"),X(H)):V(H)}function X(H){return H===u?(B++,P.consume(H),X):B>=d?(P.exit("codeFencedFenceSequence"),Je(H)?at(P,I,"whitespace")(H):I(H)):V(H)}function I(H){return H===null||ze(H)?(P.exit("codeFencedFence"),$(H)):V(H)}}}function DS(e,r,s){const a=this;return o;function o(d){return d===null?s(d):(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c)}function c(d){return a.parser.lazy[a.now().line]?s(d):r(d)}}const Cd={name:"codeIndented",tokenize:zS},BS={partial:!0,tokenize:OS};function zS(e,r,s){const a=this;return o;function o(p){return e.enter("codeIndented"),at(e,c,"linePrefix",5)(p)}function c(p){const x=a.events[a.events.length-1];return x&&x[1].type==="linePrefix"&&x[2].sliceSerialize(x[1],!0).length>=4?d(p):s(p)}function d(p){return p===null?h(p):ze(p)?e.attempt(BS,d,h)(p):(e.enter("codeFlowValue"),u(p))}function u(p){return p===null||ze(p)?(e.exit("codeFlowValue"),d(p)):(e.consume(p),u)}function h(p){return e.exit("codeIndented"),r(p)}}function OS(e,r,s){const a=this;return o;function o(d){return a.parser.lazy[a.now().line]?s(d):ze(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),o):at(e,c,"linePrefix",5)(d)}function c(d){const u=a.events[a.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?r(d):ze(d)?o(d):s(d)}}const FS={name:"codeText",previous:HS,resolve:WS,tokenize:US};function WS(e){let r=e.length-4,s=3,a,o;if((e[s][1].type==="lineEnding"||e[s][1].type==="space")&&(e[r][1].type==="lineEnding"||e[r][1].type==="space")){for(a=s;++a<r;)if(e[a][1].type==="codeTextData"){e[s][1].type="codeTextPadding",e[r][1].type="codeTextPadding",s+=2,r-=2;break}}for(a=s-1,r++;++a<=r;)o===void 0?a!==r&&e[a][1].type!=="lineEnding"&&(o=a):(a===r||e[a][1].type==="lineEnding")&&(e[o][1].type="codeTextData",a!==o+2&&(e[o][1].end=e[a-1][1].end,e.splice(o+2,a-o-2),r-=a-o-2,a=o+2),o=void 0);return e}function HS(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function US(e,r,s){let a=0,o,c;return d;function d(g){return e.enter("codeText"),e.enter("codeTextSequence"),u(g)}function u(g){return g===96?(e.consume(g),a++,u):(e.exit("codeTextSequence"),h(g))}function h(g){return g===null?s(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),h):g===96?(c=e.enter("codeTextSequence"),o=0,x(g)):ze(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),h):(e.enter("codeTextData"),p(g))}function p(g){return g===null||g===32||g===96||ze(g)?(e.exit("codeTextData"),h(g)):(e.consume(g),p)}function x(g){return g===96?(e.consume(g),o++,x):o===a?(e.exit("codeTextSequence"),e.exit("codeText"),r(g)):(c.type="codeTextData",p(g))}}class VS{constructor(r){this.left=r?[...r]:[],this.right=[]}get(r){if(r<0||r>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+r+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return r<this.left.length?this.left[r]:this.right[this.right.length-r+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(r,s){const a=s??Number.POSITIVE_INFINITY;return a<this.left.length?this.left.slice(r,a):r>this.left.length?this.right.slice(this.right.length-a+this.left.length,this.right.length-r+this.left.length).reverse():this.left.slice(r).concat(this.right.slice(this.right.length-a+this.left.length).reverse())}splice(r,s,a){const o=s||0;this.setCursor(Math.trunc(r));const c=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return a&&ea(this.left,a),c.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(r){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(r)}pushMany(r){this.setCursor(Number.POSITIVE_INFINITY),ea(this.left,r)}unshift(r){this.setCursor(0),this.right.push(r)}unshiftMany(r){this.setCursor(0),ea(this.right,r.reverse())}setCursor(r){if(!(r===this.left.length||r>this.left.length&&this.right.length===0||r<0&&this.left.length===0))if(r<this.left.length){const s=this.left.splice(r,Number.POSITIVE_INFINITY);ea(this.right,s.reverse())}else{const s=this.right.splice(this.left.length+this.right.length-r,Number.POSITIVE_INFINITY);ea(this.left,s.reverse())}}}function ea(e,r){let s=0;if(r.length<1e4)e.push(...r);else for(;s<r.length;)e.push(...r.slice(s,s+1e4)),s+=1e4}function hy(e){const r={};let s=-1,a,o,c,d,u,h,p;const x=new VS(e);for(;++s<x.length;){for(;s in r;)s=r[s];if(a=x.get(s),s&&a[1].type==="chunkFlow"&&x.get(s-1)[1].type==="listItemPrefix"&&(h=a[1]._tokenizer.events,c=0,c<h.length&&h[c][1].type==="lineEndingBlank"&&(c+=2),c<h.length&&h[c][1].type==="content"))for(;++c<h.length&&h[c][1].type!=="content";)h[c][1].type==="chunkText"&&(h[c][1]._isInFirstContentOfListItem=!0,c++);if(a[0]==="enter")a[1].contentType&&(Object.assign(r,qS(x,s)),s=r[s],p=!0);else if(a[1]._container){for(c=s,o=void 0;c--;)if(d=x.get(c),d[1].type==="lineEnding"||d[1].type==="lineEndingBlank")d[0]==="enter"&&(o&&(x.get(o)[1].type="lineEndingBlank"),d[1].type="lineEnding",o=c);else if(!(d[1].type==="linePrefix"||d[1].type==="listItemIndent"))break;o&&(a[1].end={...x.get(o)[1].start},u=x.slice(o,s),u.unshift(a),x.splice(o,s-o+1,u))}}return rn(e,0,Number.POSITIVE_INFINITY,x.slice(0)),!p}function qS(e,r){const s=e.get(r)[1],a=e.get(r)[2];let o=r-1;const c=[];let d=s._tokenizer;d||(d=a.parser[s.contentType](s.start),s._contentTypeTextTrailing&&(d._contentTypeTextTrailing=!0));const u=d.events,h=[],p={};let x,g,b=-1,v=s,k=0,T=0;const N=[T];for(;v;){for(;e.get(++o)[1]!==v;);c.push(o),v._tokenizer||(x=a.sliceStream(v),v.next||x.push(null),g&&d.defineSkip(v.start),v._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=!0),d.write(x),v._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=void 0)),g=v,v=v.next}for(v=s;++b<u.length;)u[b][0]==="exit"&&u[b-1][0]==="enter"&&u[b][1].type===u[b-1][1].type&&u[b][1].start.line!==u[b][1].end.line&&(T=b+1,N.push(T),v._tokenizer=void 0,v.previous=void 0,v=v.next);for(d.events=[],v?(v._tokenizer=void 0,v.previous=void 0):N.pop(),b=N.length;b--;){const j=u.slice(N[b],N[b+1]),A=c.pop();h.push([A,A+j.length-1]),e.splice(A,2,j)}for(h.reverse(),b=-1;++b<h.length;)p[k+h[b][0]]=k+h[b][1],k+=h[b][1]-h[b][0]-1;return p}const YS={resolve:KS,tokenize:QS},GS={partial:!0,tokenize:JS};function KS(e){return hy(e),e}function QS(e,r){let s;return a;function a(u){return e.enter("content"),s=e.enter("chunkContent",{contentType:"content"}),o(u)}function o(u){return u===null?c(u):ze(u)?e.check(GS,d,c)(u):(e.consume(u),o)}function c(u){return e.exit("chunkContent"),e.exit("content"),r(u)}function d(u){return e.consume(u),e.exit("chunkContent"),s.next=e.enter("chunkContent",{contentType:"content",previous:s}),s=s.next,o}}function JS(e,r,s){const a=this;return o;function o(d){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),at(e,c,"linePrefix")}function c(d){if(d===null||ze(d))return s(d);const u=a.events[a.events.length-1];return!a.parser.constructs.disable.null.includes("codeIndented")&&u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?r(d):e.interrupt(a.parser.constructs.flow,s,r)(d)}}function py(e,r,s,a,o,c,d,u,h){const p=h||Number.POSITIVE_INFINITY;let x=0;return g;function g(j){return j===60?(e.enter(a),e.enter(o),e.enter(c),e.consume(j),e.exit(c),b):j===null||j===32||j===41||ru(j)?s(j):(e.enter(a),e.enter(d),e.enter(u),e.enter("chunkString",{contentType:"string"}),T(j))}function b(j){return j===62?(e.enter(c),e.consume(j),e.exit(c),e.exit(o),e.exit(a),r):(e.enter(u),e.enter("chunkString",{contentType:"string"}),v(j))}function v(j){return j===62?(e.exit("chunkString"),e.exit(u),b(j)):j===null||j===60||ze(j)?s(j):(e.consume(j),j===92?k:v)}function k(j){return j===60||j===62||j===92?(e.consume(j),v):v(j)}function T(j){return!x&&(j===null||j===41||gr(j))?(e.exit("chunkString"),e.exit(u),e.exit(d),e.exit(a),r(j)):x<p&&j===40?(e.consume(j),x++,T):j===41?(e.consume(j),x--,T):j===null||j===32||j===40||ru(j)?s(j):(e.consume(j),j===92?N:T)}function N(j){return j===40||j===41||j===92?(e.consume(j),T):T(j)}}function fy(e,r,s,a,o,c){const d=this;let u=0,h;return p;function p(v){return e.enter(a),e.enter(o),e.consume(v),e.exit(o),e.enter(c),x}function x(v){return u>999||v===null||v===91||v===93&&!h||v===94&&!u&&"_hiddenFootnoteSupport"in d.parser.constructs?s(v):v===93?(e.exit(c),e.enter(o),e.consume(v),e.exit(o),e.exit(a),r):ze(v)?(e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),x):(e.enter("chunkString",{contentType:"string"}),g(v))}function g(v){return v===null||v===91||v===93||ze(v)||u++>999?(e.exit("chunkString"),x(v)):(e.consume(v),h||(h=!Je(v)),v===92?b:g)}function b(v){return v===91||v===92||v===93?(e.consume(v),u++,g):g(v)}}function xy(e,r,s,a,o,c){let d;return u;function u(b){return b===34||b===39||b===40?(e.enter(a),e.enter(o),e.consume(b),e.exit(o),d=b===40?41:b,h):s(b)}function h(b){return b===d?(e.enter(o),e.consume(b),e.exit(o),e.exit(a),r):(e.enter(c),p(b))}function p(b){return b===d?(e.exit(c),h(d)):b===null?s(b):ze(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),at(e,p,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),x(b))}function x(b){return b===d||b===null||ze(b)?(e.exit("chunkString"),p(b)):(e.consume(b),b===92?g:x)}function g(b){return b===d||b===92?(e.consume(b),x):x(b)}}function aa(e,r){let s;return a;function a(o){return ze(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s=!0,a):Je(o)?at(e,a,s?"linePrefix":"lineSuffix")(o):r(o)}}const XS={name:"definition",tokenize:e_},ZS={partial:!0,tokenize:t_};function e_(e,r,s){const a=this;let o;return c;function c(v){return e.enter("definition"),d(v)}function d(v){return fy.call(a,e,u,s,"definitionLabel","definitionLabelMarker","definitionLabelString")(v)}function u(v){return o=ei(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)),v===58?(e.enter("definitionMarker"),e.consume(v),e.exit("definitionMarker"),h):s(v)}function h(v){return gr(v)?aa(e,p)(v):p(v)}function p(v){return py(e,x,s,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(v)}function x(v){return e.attempt(ZS,g,g)(v)}function g(v){return Je(v)?at(e,b,"whitespace")(v):b(v)}function b(v){return v===null||ze(v)?(e.exit("definition"),a.parser.defined.push(o),r(v)):s(v)}}function t_(e,r,s){return a;function a(u){return gr(u)?aa(e,o)(u):s(u)}function o(u){return xy(e,c,s,"definitionTitle","definitionTitleMarker","definitionTitleString")(u)}function c(u){return Je(u)?at(e,d,"whitespace")(u):d(u)}function d(u){return u===null||ze(u)?r(u):s(u)}}const r_={name:"hardBreakEscape",tokenize:n_};function n_(e,r,s){return a;function a(c){return e.enter("hardBreakEscape"),e.consume(c),o}function o(c){return ze(c)?(e.exit("hardBreakEscape"),r(c)):s(c)}}const s_={name:"headingAtx",resolve:i_,tokenize:a_};function i_(e,r){let s=e.length-2,a=3,o,c;return e[a][1].type==="whitespace"&&(a+=2),s-2>a&&e[s][1].type==="whitespace"&&(s-=2),e[s][1].type==="atxHeadingSequence"&&(a===s-1||s-4>a&&e[s-2][1].type==="whitespace")&&(s-=a+1===s?2:4),s>a&&(o={type:"atxHeadingText",start:e[a][1].start,end:e[s][1].end},c={type:"chunkText",start:e[a][1].start,end:e[s][1].end,contentType:"text"},rn(e,a,s-a+1,[["enter",o,r],["enter",c,r],["exit",c,r],["exit",o,r]])),e}function a_(e,r,s){let a=0;return o;function o(x){return e.enter("atxHeading"),c(x)}function c(x){return e.enter("atxHeadingSequence"),d(x)}function d(x){return x===35&&a++<6?(e.consume(x),d):x===null||gr(x)?(e.exit("atxHeadingSequence"),u(x)):s(x)}function u(x){return x===35?(e.enter("atxHeadingSequence"),h(x)):x===null||ze(x)?(e.exit("atxHeading"),r(x)):Je(x)?at(e,u,"whitespace")(x):(e.enter("atxHeadingText"),p(x))}function h(x){return x===35?(e.consume(x),h):(e.exit("atxHeadingSequence"),u(x))}function p(x){return x===null||x===35||gr(x)?(e.exit("atxHeadingText"),u(x)):(e.consume(x),p)}}const o_=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],ff=["pre","script","style","textarea"],l_={concrete:!0,name:"htmlFlow",resolveTo:u_,tokenize:m_},c_={partial:!0,tokenize:p_},d_={partial:!0,tokenize:h_};function u_(e){let r=e.length;for(;r--&&!(e[r][0]==="enter"&&e[r][1].type==="htmlFlow"););return r>1&&e[r-2][1].type==="linePrefix"&&(e[r][1].start=e[r-2][1].start,e[r+1][1].start=e[r-2][1].start,e.splice(r-2,2)),e}function m_(e,r,s){const a=this;let o,c,d,u,h;return p;function p(S){return x(S)}function x(S){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(S),g}function g(S){return S===33?(e.consume(S),b):S===47?(e.consume(S),c=!0,T):S===63?(e.consume(S),o=3,a.interrupt?r:E):Zr(S)?(e.consume(S),d=String.fromCharCode(S),N):s(S)}function b(S){return S===45?(e.consume(S),o=2,v):S===91?(e.consume(S),o=5,u=0,k):Zr(S)?(e.consume(S),o=4,a.interrupt?r:E):s(S)}function v(S){return S===45?(e.consume(S),a.interrupt?r:E):s(S)}function k(S){const G="CDATA[";return S===G.charCodeAt(u++)?(e.consume(S),u===G.length?a.interrupt?r:R:k):s(S)}function T(S){return Zr(S)?(e.consume(S),d=String.fromCharCode(S),N):s(S)}function N(S){if(S===null||S===47||S===62||gr(S)){const G=S===47,re=d.toLowerCase();return!G&&!c&&ff.includes(re)?(o=1,a.interrupt?r(S):R(S)):o_.includes(d.toLowerCase())?(o=6,G?(e.consume(S),j):a.interrupt?r(S):R(S)):(o=7,a.interrupt&&!a.parser.lazy[a.now().line]?s(S):c?A(S):M(S))}return S===45||Cr(S)?(e.consume(S),d+=String.fromCharCode(S),N):s(S)}function j(S){return S===62?(e.consume(S),a.interrupt?r:R):s(S)}function A(S){return Je(S)?(e.consume(S),A):U(S)}function M(S){return S===47?(e.consume(S),U):S===58||S===95||Zr(S)?(e.consume(S),_):Je(S)?(e.consume(S),M):U(S)}function _(S){return S===45||S===46||S===58||S===95||Cr(S)?(e.consume(S),_):z(S)}function z(S){return S===61?(e.consume(S),P):Je(S)?(e.consume(S),z):M(S)}function P(S){return S===null||S===60||S===61||S===62||S===96?s(S):S===34||S===39?(e.consume(S),h=S,$):Je(S)?(e.consume(S),P):V(S)}function $(S){return S===h?(e.consume(S),h=null,B):S===null||ze(S)?s(S):(e.consume(S),$)}function V(S){return S===null||S===34||S===39||S===47||S===60||S===61||S===62||S===96||gr(S)?z(S):(e.consume(S),V)}function B(S){return S===47||S===62||Je(S)?M(S):s(S)}function U(S){return S===62?(e.consume(S),D):s(S)}function D(S){return S===null||ze(S)?R(S):Je(S)?(e.consume(S),D):s(S)}function R(S){return S===45&&o===2?(e.consume(S),W):S===60&&o===1?(e.consume(S),J):S===62&&o===4?(e.consume(S),L):S===63&&o===3?(e.consume(S),E):S===93&&o===5?(e.consume(S),de):ze(S)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(c_,q,X)(S)):S===null||ze(S)?(e.exit("htmlFlowData"),X(S)):(e.consume(S),R)}function X(S){return e.check(d_,I,q)(S)}function I(S){return e.enter("lineEnding"),e.consume(S),e.exit("lineEnding"),H}function H(S){return S===null||ze(S)?X(S):(e.enter("htmlFlowData"),R(S))}function W(S){return S===45?(e.consume(S),E):R(S)}function J(S){return S===47?(e.consume(S),d="",Z):R(S)}function Z(S){if(S===62){const G=d.toLowerCase();return ff.includes(G)?(e.consume(S),L):R(S)}return Zr(S)&&d.length<8?(e.consume(S),d+=String.fromCharCode(S),Z):R(S)}function de(S){return S===93?(e.consume(S),E):R(S)}function E(S){return S===62?(e.consume(S),L):S===45&&o===2?(e.consume(S),E):R(S)}function L(S){return S===null||ze(S)?(e.exit("htmlFlowData"),q(S)):(e.consume(S),L)}function q(S){return e.exit("htmlFlow"),r(S)}}function h_(e,r,s){const a=this;return o;function o(d){return ze(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):s(d)}function c(d){return a.parser.lazy[a.now().line]?s(d):r(d)}}function p_(e,r,s){return a;function a(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(wl,r,s)}}const f_={name:"htmlText",tokenize:x_};function x_(e,r,s){const a=this;let o,c,d;return u;function u(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),h}function h(E){return E===33?(e.consume(E),p):E===47?(e.consume(E),z):E===63?(e.consume(E),M):Zr(E)?(e.consume(E),V):s(E)}function p(E){return E===45?(e.consume(E),x):E===91?(e.consume(E),c=0,k):Zr(E)?(e.consume(E),A):s(E)}function x(E){return E===45?(e.consume(E),v):s(E)}function g(E){return E===null?s(E):E===45?(e.consume(E),b):ze(E)?(d=g,J(E)):(e.consume(E),g)}function b(E){return E===45?(e.consume(E),v):g(E)}function v(E){return E===62?W(E):E===45?b(E):g(E)}function k(E){const L="CDATA[";return E===L.charCodeAt(c++)?(e.consume(E),c===L.length?T:k):s(E)}function T(E){return E===null?s(E):E===93?(e.consume(E),N):ze(E)?(d=T,J(E)):(e.consume(E),T)}function N(E){return E===93?(e.consume(E),j):T(E)}function j(E){return E===62?W(E):E===93?(e.consume(E),j):T(E)}function A(E){return E===null||E===62?W(E):ze(E)?(d=A,J(E)):(e.consume(E),A)}function M(E){return E===null?s(E):E===63?(e.consume(E),_):ze(E)?(d=M,J(E)):(e.consume(E),M)}function _(E){return E===62?W(E):M(E)}function z(E){return Zr(E)?(e.consume(E),P):s(E)}function P(E){return E===45||Cr(E)?(e.consume(E),P):$(E)}function $(E){return ze(E)?(d=$,J(E)):Je(E)?(e.consume(E),$):W(E)}function V(E){return E===45||Cr(E)?(e.consume(E),V):E===47||E===62||gr(E)?B(E):s(E)}function B(E){return E===47?(e.consume(E),W):E===58||E===95||Zr(E)?(e.consume(E),U):ze(E)?(d=B,J(E)):Je(E)?(e.consume(E),B):W(E)}function U(E){return E===45||E===46||E===58||E===95||Cr(E)?(e.consume(E),U):D(E)}function D(E){return E===61?(e.consume(E),R):ze(E)?(d=D,J(E)):Je(E)?(e.consume(E),D):B(E)}function R(E){return E===null||E===60||E===61||E===62||E===96?s(E):E===34||E===39?(e.consume(E),o=E,X):ze(E)?(d=R,J(E)):Je(E)?(e.consume(E),R):(e.consume(E),I)}function X(E){return E===o?(e.consume(E),o=void 0,H):E===null?s(E):ze(E)?(d=X,J(E)):(e.consume(E),X)}function I(E){return E===null||E===34||E===39||E===60||E===61||E===96?s(E):E===47||E===62||gr(E)?B(E):(e.consume(E),I)}function H(E){return E===47||E===62||gr(E)?B(E):s(E)}function W(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),r):s(E)}function J(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),Z}function Z(E){return Je(E)?at(e,de,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):de(E)}function de(E){return e.enter("htmlTextData"),d(E)}}const Xu={name:"labelEnd",resolveAll:w_,resolveTo:b_,tokenize:j_},g_={tokenize:k_},y_={tokenize:N_},v_={tokenize:C_};function w_(e){let r=-1;const s=[];for(;++r<e.length;){const a=e[r][1];if(s.push(e[r]),a.type==="labelImage"||a.type==="labelLink"||a.type==="labelEnd"){const o=a.type==="labelImage"?4:2;a.type="data",r+=o}}return e.length!==s.length&&rn(e,0,e.length,s),e}function b_(e,r){let s=e.length,a=0,o,c,d,u;for(;s--;)if(o=e[s][1],c){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[s][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(d){if(e[s][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(c=s,o.type!=="labelLink")){a=2;break}}else o.type==="labelEnd"&&(d=s);const h={type:e[c][1].type==="labelLink"?"link":"image",start:{...e[c][1].start},end:{...e[e.length-1][1].end}},p={type:"label",start:{...e[c][1].start},end:{...e[d][1].end}},x={type:"labelText",start:{...e[c+a+2][1].end},end:{...e[d-2][1].start}};return u=[["enter",h,r],["enter",p,r]],u=Rr(u,e.slice(c+1,c+a+3)),u=Rr(u,[["enter",x,r]]),u=Rr(u,Ju(r.parser.constructs.insideSpan.null,e.slice(c+a+4,d-3),r)),u=Rr(u,[["exit",x,r],e[d-2],e[d-1],["exit",p,r]]),u=Rr(u,e.slice(d+1)),u=Rr(u,[["exit",h,r]]),rn(e,c,e.length,u),e}function j_(e,r,s){const a=this;let o=a.events.length,c,d;for(;o--;)if((a.events[o][1].type==="labelImage"||a.events[o][1].type==="labelLink")&&!a.events[o][1]._balanced){c=a.events[o][1];break}return u;function u(b){return c?c._inactive?g(b):(d=a.parser.defined.includes(ei(a.sliceSerialize({start:c.end,end:a.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(b),e.exit("labelMarker"),e.exit("labelEnd"),h):s(b)}function h(b){return b===40?e.attempt(g_,x,d?x:g)(b):b===91?e.attempt(y_,x,d?p:g)(b):d?x(b):g(b)}function p(b){return e.attempt(v_,x,g)(b)}function x(b){return r(b)}function g(b){return c._balanced=!0,s(b)}}function k_(e,r,s){return a;function a(g){return e.enter("resource"),e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),o}function o(g){return gr(g)?aa(e,c)(g):c(g)}function c(g){return g===41?x(g):py(e,d,u,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function d(g){return gr(g)?aa(e,h)(g):x(g)}function u(g){return s(g)}function h(g){return g===34||g===39||g===40?xy(e,p,s,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):x(g)}function p(g){return gr(g)?aa(e,x)(g):x(g)}function x(g){return g===41?(e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),e.exit("resource"),r):s(g)}}function N_(e,r,s){const a=this;return o;function o(u){return fy.call(a,e,c,d,"reference","referenceMarker","referenceString")(u)}function c(u){return a.parser.defined.includes(ei(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)))?r(u):s(u)}function d(u){return s(u)}}function C_(e,r,s){return a;function a(c){return e.enter("reference"),e.enter("referenceMarker"),e.consume(c),e.exit("referenceMarker"),o}function o(c){return c===93?(e.enter("referenceMarker"),e.consume(c),e.exit("referenceMarker"),e.exit("reference"),r):s(c)}}const S_={name:"labelStartImage",resolveAll:Xu.resolveAll,tokenize:__};function __(e,r,s){const a=this;return o;function o(u){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(u),e.exit("labelImageMarker"),c}function c(u){return u===91?(e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelImage"),d):s(u)}function d(u){return u===94&&"_hiddenFootnoteSupport"in a.parser.constructs?s(u):r(u)}}const L_={name:"labelStartLink",resolveAll:Xu.resolveAll,tokenize:E_};function E_(e,r,s){const a=this;return o;function o(d){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelLink"),c}function c(d){return d===94&&"_hiddenFootnoteSupport"in a.parser.constructs?s(d):r(d)}}const Sd={name:"lineEnding",tokenize:T_};function T_(e,r){return s;function s(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),at(e,r,"linePrefix")}}const Ho={name:"thematicBreak",tokenize:A_};function A_(e,r,s){let a=0,o;return c;function c(p){return e.enter("thematicBreak"),d(p)}function d(p){return o=p,u(p)}function u(p){return p===o?(e.enter("thematicBreakSequence"),h(p)):a>=3&&(p===null||ze(p))?(e.exit("thematicBreak"),r(p)):s(p)}function h(p){return p===o?(e.consume(p),a++,h):(e.exit("thematicBreakSequence"),Je(p)?at(e,u,"whitespace")(p):u(p))}}const pr={continuation:{tokenize:R_},exit:D_,name:"list",tokenize:M_},P_={partial:!0,tokenize:B_},I_={partial:!0,tokenize:$_};function M_(e,r,s){const a=this,o=a.events[a.events.length-1];let c=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,d=0;return u;function u(v){const k=a.containerState.type||(v===42||v===43||v===45?"listUnordered":"listOrdered");if(k==="listUnordered"?!a.containerState.marker||v===a.containerState.marker:nu(v)){if(a.containerState.type||(a.containerState.type=k,e.enter(k,{_container:!0})),k==="listUnordered")return e.enter("listItemPrefix"),v===42||v===45?e.check(Ho,s,p)(v):p(v);if(!a.interrupt||v===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),h(v)}return s(v)}function h(v){return nu(v)&&++d<10?(e.consume(v),h):(!a.interrupt||d<2)&&(a.containerState.marker?v===a.containerState.marker:v===41||v===46)?(e.exit("listItemValue"),p(v)):s(v)}function p(v){return e.enter("listItemMarker"),e.consume(v),e.exit("listItemMarker"),a.containerState.marker=a.containerState.marker||v,e.check(wl,a.interrupt?s:x,e.attempt(P_,b,g))}function x(v){return a.containerState.initialBlankLine=!0,c++,b(v)}function g(v){return Je(v)?(e.enter("listItemPrefixWhitespace"),e.consume(v),e.exit("listItemPrefixWhitespace"),b):s(v)}function b(v){return a.containerState.size=c+a.sliceSerialize(e.exit("listItemPrefix"),!0).length,r(v)}}function R_(e,r,s){const a=this;return a.containerState._closeFlow=void 0,e.check(wl,o,c);function o(u){return a.containerState.furtherBlankLines=a.containerState.furtherBlankLines||a.containerState.initialBlankLine,at(e,r,"listItemIndent",a.containerState.size+1)(u)}function c(u){return a.containerState.furtherBlankLines||!Je(u)?(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,d(u)):(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,e.attempt(I_,r,d)(u))}function d(u){return a.containerState._closeFlow=!0,a.interrupt=void 0,at(e,e.attempt(pr,r,s),"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u)}}function $_(e,r,s){const a=this;return at(e,o,"listItemIndent",a.containerState.size+1);function o(c){const d=a.events[a.events.length-1];return d&&d[1].type==="listItemIndent"&&d[2].sliceSerialize(d[1],!0).length===a.containerState.size?r(c):s(c)}}function D_(e){e.exit(this.containerState.type)}function B_(e,r,s){const a=this;return at(e,o,"listItemPrefixWhitespace",a.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(c){const d=a.events[a.events.length-1];return!Je(c)&&d&&d[1].type==="listItemPrefixWhitespace"?r(c):s(c)}}const xf={name:"setextUnderline",resolveTo:z_,tokenize:O_};function z_(e,r){let s=e.length,a,o,c;for(;s--;)if(e[s][0]==="enter"){if(e[s][1].type==="content"){a=s;break}e[s][1].type==="paragraph"&&(o=s)}else e[s][1].type==="content"&&e.splice(s,1),!c&&e[s][1].type==="definition"&&(c=s);const d={type:"setextHeading",start:{...e[a][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",c?(e.splice(o,0,["enter",d,r]),e.splice(c+1,0,["exit",e[a][1],r]),e[a][1].end={...e[c][1].end}):e[a][1]=d,e.push(["exit",d,r]),e}function O_(e,r,s){const a=this;let o;return c;function c(p){let x=a.events.length,g;for(;x--;)if(a.events[x][1].type!=="lineEnding"&&a.events[x][1].type!=="linePrefix"&&a.events[x][1].type!=="content"){g=a.events[x][1].type==="paragraph";break}return!a.parser.lazy[a.now().line]&&(a.interrupt||g)?(e.enter("setextHeadingLine"),o=p,d(p)):s(p)}function d(p){return e.enter("setextHeadingLineSequence"),u(p)}function u(p){return p===o?(e.consume(p),u):(e.exit("setextHeadingLineSequence"),Je(p)?at(e,h,"lineSuffix")(p):h(p))}function h(p){return p===null||ze(p)?(e.exit("setextHeadingLine"),r(p)):s(p)}}const F_={tokenize:W_};function W_(e){const r=this,s=e.attempt(wl,a,e.attempt(this.parser.constructs.flowInitial,o,at(e,e.attempt(this.parser.constructs.flow,o,e.attempt(YS,o)),"linePrefix")));return s;function a(c){if(c===null){e.consume(c);return}return e.enter("lineEndingBlank"),e.consume(c),e.exit("lineEndingBlank"),r.currentConstruct=void 0,s}function o(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),r.currentConstruct=void 0,s}}const H_={resolveAll:yy()},U_=gy("string"),V_=gy("text");function gy(e){return{resolveAll:yy(e==="text"?q_:void 0),tokenize:r};function r(s){const a=this,o=this.parser.constructs[e],c=s.attempt(o,d,u);return d;function d(x){return p(x)?c(x):u(x)}function u(x){if(x===null){s.consume(x);return}return s.enter("data"),s.consume(x),h}function h(x){return p(x)?(s.exit("data"),c(x)):(s.consume(x),h)}function p(x){if(x===null)return!0;const g=o[x];let b=-1;if(g)for(;++b<g.length;){const v=g[b];if(!v.previous||v.previous.call(a,a.previous))return!0}return!1}}}function yy(e){return r;function r(s,a){let o=-1,c;for(;++o<=s.length;)c===void 0?s[o]&&s[o][1].type==="data"&&(c=o,o++):(!s[o]||s[o][1].type!=="data")&&(o!==c+2&&(s[c][1].end=s[o-1][1].end,s.splice(c+2,o-c-2),o=c+2),c=void 0);return e?e(s,a):s}}function q_(e,r){let s=0;for(;++s<=e.length;)if((s===e.length||e[s][1].type==="lineEnding")&&e[s-1][1].type==="data"){const a=e[s-1][1],o=r.sliceStream(a);let c=o.length,d=-1,u=0,h;for(;c--;){const p=o[c];if(typeof p=="string"){for(d=p.length;p.charCodeAt(d-1)===32;)u++,d--;if(d)break;d=-1}else if(p===-2)h=!0,u++;else if(p!==-1){c++;break}}if(r._contentTypeTextTrailing&&s===e.length&&(u=0),u){const p={type:s===e.length||h||u<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:c?d:a.start._bufferIndex+d,_index:a.start._index+c,line:a.end.line,column:a.end.column-u,offset:a.end.offset-u},end:{...a.end}};a.end={...p.start},a.start.offset===a.end.offset?Object.assign(a,p):(e.splice(s,0,["enter",p,r],["exit",p,r]),s+=2)}s++}return e}const Y_={42:pr,43:pr,45:pr,48:pr,49:pr,50:pr,51:pr,52:pr,53:pr,54:pr,55:pr,56:pr,57:pr,62:dy},G_={91:XS},K_={[-2]:Cd,[-1]:Cd,32:Cd},Q_={35:s_,42:Ho,45:[xf,Ho],60:l_,61:xf,95:Ho,96:pf,126:pf},J_={38:my,92:uy},X_={[-5]:Sd,[-4]:Sd,[-3]:Sd,33:S_,38:my,42:su,60:[LS,f_],91:L_,92:[r_,uy],93:Xu,95:su,96:FS},Z_={null:[su,H_]},e6={null:[42,95]},t6={null:[]},r6=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:e6,contentInitial:G_,disable:t6,document:Y_,flow:Q_,flowInitial:K_,insideSpan:Z_,string:J_,text:X_},Symbol.toStringTag,{value:"Module"}));function n6(e,r,s){let a={_bufferIndex:-1,_index:0,line:s&&s.line||1,column:s&&s.column||1,offset:s&&s.offset||0};const o={},c=[];let d=[],u=[];const h={attempt:$(z),check:$(P),consume:A,enter:M,exit:_,interrupt:$(P,{interrupt:!0})},p={code:null,containerState:{},defineSkip:T,events:[],now:k,parser:e,previous:null,sliceSerialize:b,sliceStream:v,write:g};let x=r.tokenize.call(p,h);return r.resolveAll&&c.push(r),p;function g(D){return d=Rr(d,D),N(),d[d.length-1]!==null?[]:(V(r,0),p.events=Ju(c,p.events,p),p.events)}function b(D,R){return i6(v(D),R)}function v(D){return s6(d,D)}function k(){const{_bufferIndex:D,_index:R,line:X,column:I,offset:H}=a;return{_bufferIndex:D,_index:R,line:X,column:I,offset:H}}function T(D){o[D.line]=D.column,U()}function N(){let D;for(;a._index<d.length;){const R=d[a._index];if(typeof R=="string")for(D=a._index,a._bufferIndex<0&&(a._bufferIndex=0);a._index===D&&a._bufferIndex<R.length;)j(R.charCodeAt(a._bufferIndex));else j(R)}}function j(D){x=x(D)}function A(D){ze(D)?(a.line++,a.column=1,a.offset+=D===-3?2:1,U()):D!==-1&&(a.column++,a.offset++),a._bufferIndex<0?a._index++:(a._bufferIndex++,a._bufferIndex===d[a._index].length&&(a._bufferIndex=-1,a._index++)),p.previous=D}function M(D,R){const X=R||{};return X.type=D,X.start=k(),p.events.push(["enter",X,p]),u.push(X),X}function _(D){const R=u.pop();return R.end=k(),p.events.push(["exit",R,p]),R}function z(D,R){V(D,R.from)}function P(D,R){R.restore()}function $(D,R){return X;function X(I,H,W){let J,Z,de,E;return Array.isArray(I)?q(I):"tokenize"in I?q([I]):L(I);function L(ee){return ge;function ge(je){const Le=je!==null&&ee[je],ve=je!==null&&ee.null,F=[...Array.isArray(Le)?Le:Le?[Le]:[],...Array.isArray(ve)?ve:ve?[ve]:[]];return q(F)(je)}}function q(ee){return J=ee,Z=0,ee.length===0?W:S(ee[Z])}function S(ee){return ge;function ge(je){return E=B(),de=ee,ee.partial||(p.currentConstruct=ee),ee.name&&p.parser.constructs.disable.null.includes(ee.name)?re():ee.tokenize.call(R?Object.assign(Object.create(p),R):p,h,G,re)(je)}}function G(ee){return D(de,E),H}function re(ee){return E.restore(),++Z<J.length?S(J[Z]):W}}}function V(D,R){D.resolveAll&&!c.includes(D)&&c.push(D),D.resolve&&rn(p.events,R,p.events.length-R,D.resolve(p.events.slice(R),p)),D.resolveTo&&(p.events=D.resolveTo(p.events,p))}function B(){const D=k(),R=p.previous,X=p.currentConstruct,I=p.events.length,H=Array.from(u);return{from:I,restore:W};function W(){a=D,p.previous=R,p.currentConstruct=X,p.events.length=I,u=H,U()}}function U(){a.line in o&&a.column<2&&(a.column=o[a.line],a.offset+=o[a.line]-1)}}function s6(e,r){const s=r.start._index,a=r.start._bufferIndex,o=r.end._index,c=r.end._bufferIndex;let d;if(s===o)d=[e[s].slice(a,c)];else{if(d=e.slice(s,o),a>-1){const u=d[0];typeof u=="string"?d[0]=u.slice(a):d.shift()}c>0&&d.push(e[o].slice(0,c))}return d}function i6(e,r){let s=-1;const a=[];let o;for(;++s<e.length;){const c=e[s];let d;if(typeof c=="string")d=c;else switch(c){case-5:{d="\r";break}case-4:{d=`
|
|
223
|
+
`;break}case-3:{d=`\r
|
|
224
|
+
`;break}case-2:{d=r?" ":" ";break}case-1:{if(!r&&o)continue;d=" ";break}default:d=String.fromCharCode(c)}o=c===-2,a.push(d)}return a.join("")}function a6(e){const a={constructs:hS([r6,...(e||{}).extensions||[]]),content:o(bS),defined:[],document:o(kS),flow:o(F_),lazy:{},string:o(U_),text:o(V_)};return a;function o(c){return d;function d(u){return n6(a,c,u)}}}function o6(e){for(;!hy(e););return e}const gf=/[\0\t\n\r]/g;function l6(){let e=1,r="",s=!0,a;return o;function o(c,d,u){const h=[];let p,x,g,b,v;for(c=r+(typeof c=="string"?c.toString():new TextDecoder(d||void 0).decode(c)),g=0,r="",s&&(c.charCodeAt(0)===65279&&g++,s=void 0);g<c.length;){if(gf.lastIndex=g,p=gf.exec(c),b=p&&p.index!==void 0?p.index:c.length,v=c.charCodeAt(b),!p){r=c.slice(g);break}if(v===10&&g===b&&a)h.push(-3),a=void 0;else switch(a&&(h.push(-5),a=void 0),g<b&&(h.push(c.slice(g,b)),e+=b-g),v){case 0:{h.push(65533),e++;break}case 9:{for(x=Math.ceil(e/4)*4,h.push(-2);e++<x;)h.push(-1);break}case 10:{h.push(-4),e=1;break}default:a=!0,e=1}g=b+1}return u&&(a&&h.push(-5),r&&h.push(r),h.push(null)),h}}const c6=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function d6(e){return e.replace(c6,u6)}function u6(e,r,s){if(r)return r;if(s.charCodeAt(0)===35){const o=s.charCodeAt(1),c=o===120||o===88;return cy(s.slice(c?2:1),c?16:10)}return Qu(s)||e}const vy={}.hasOwnProperty;function m6(e,r,s){return typeof r!="string"&&(s=r,r=void 0),h6(s)(o6(a6(s).document().write(l6()(e,r,!0))))}function h6(e){const r={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:c(ft),autolinkProtocol:B,autolinkEmail:B,atxHeading:c(Se),blockQuote:c(ve),characterEscape:B,characterReference:B,codeFenced:c(F),codeFencedFenceInfo:d,codeFencedFenceMeta:d,codeIndented:c(F,d),codeText:c(he,d),codeTextData:B,data:B,codeFlowValue:B,definition:c(ue),definitionDestinationString:d,definitionLabelString:d,definitionTitleString:d,emphasis:c(Oe),hardBreakEscape:c(We),hardBreakTrailing:c(We),htmlFlow:c(qe,d),htmlFlowData:B,htmlText:c(qe,d),htmlTextData:B,image:c(tt),label:d,link:c(ft),listItem:c($t),listItemValue:b,listOrdered:c(Rt,g),listUnordered:c(Rt),paragraph:c(Zt),reference:S,referenceString:d,resourceDestinationString:d,resourceTitleString:d,setextHeading:c(Se),strong:c(ar),thematicBreak:c(Et)},exit:{atxHeading:h(),atxHeadingSequence:z,autolink:h(),autolinkEmail:Le,autolinkProtocol:je,blockQuote:h(),characterEscapeValue:U,characterReferenceMarkerHexadecimal:re,characterReferenceMarkerNumeric:re,characterReferenceValue:ee,characterReference:ge,codeFenced:h(N),codeFencedFence:T,codeFencedFenceInfo:v,codeFencedFenceMeta:k,codeFlowValue:U,codeIndented:h(j),codeText:h(H),codeTextData:U,data:U,definition:h(),definitionDestinationString:_,definitionLabelString:A,definitionTitleString:M,emphasis:h(),hardBreakEscape:h(R),hardBreakTrailing:h(R),htmlFlow:h(X),htmlFlowData:U,htmlText:h(I),htmlTextData:U,image:h(J),label:de,labelText:Z,lineEnding:D,link:h(W),listItem:h(),listOrdered:h(),listUnordered:h(),paragraph:h(),referenceString:G,resourceDestinationString:E,resourceTitleString:L,resource:q,setextHeading:h(V),setextHeadingLineSequence:$,setextHeadingText:P,strong:h(),thematicBreak:h()}};wy(r,(e||{}).mdastExtensions||[]);const s={};return a;function a(ae){let Q={type:"root",children:[]};const fe={stack:[Q],tokenStack:[],config:r,enter:u,exit:p,buffer:d,resume:x,data:s},be=[];let Me=-1;for(;++Me<ae.length;)if(ae[Me][1].type==="listOrdered"||ae[Me][1].type==="listUnordered")if(ae[Me][0]==="enter")be.push(Me);else{const Ve=be.pop();Me=o(ae,Ve,Me)}for(Me=-1;++Me<ae.length;){const Ve=r[ae[Me][0]];vy.call(Ve,ae[Me][1].type)&&Ve[ae[Me][1].type].call(Object.assign({sliceSerialize:ae[Me][2].sliceSerialize},fe),ae[Me][1])}if(fe.tokenStack.length>0){const Ve=fe.tokenStack[fe.tokenStack.length-1];(Ve[1]||yf).call(fe,void 0,Ve[0])}for(Q.position={start:zn(ae.length>0?ae[0][1].start:{line:1,column:1,offset:0}),end:zn(ae.length>0?ae[ae.length-2][1].end:{line:1,column:1,offset:0})},Me=-1;++Me<r.transforms.length;)Q=r.transforms[Me](Q)||Q;return Q}function o(ae,Q,fe){let be=Q-1,Me=-1,Ve=!1,Ye,Ct,Vt,yt;for(;++be<=fe;){const rt=ae[be];switch(rt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{rt[0]==="enter"?Me++:Me--,yt=void 0;break}case"lineEndingBlank":{rt[0]==="enter"&&(Ye&&!yt&&!Me&&!Vt&&(Vt=be),yt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:yt=void 0}if(!Me&&rt[0]==="enter"&&rt[1].type==="listItemPrefix"||Me===-1&&rt[0]==="exit"&&(rt[1].type==="listUnordered"||rt[1].type==="listOrdered")){if(Ye){let ce=be;for(Ct=void 0;ce--;){const Ae=ae[ce];if(Ae[1].type==="lineEnding"||Ae[1].type==="lineEndingBlank"){if(Ae[0]==="exit")continue;Ct&&(ae[Ct][1].type="lineEndingBlank",Ve=!0),Ae[1].type="lineEnding",Ct=ce}else if(!(Ae[1].type==="linePrefix"||Ae[1].type==="blockQuotePrefix"||Ae[1].type==="blockQuotePrefixWhitespace"||Ae[1].type==="blockQuoteMarker"||Ae[1].type==="listItemIndent"))break}Vt&&(!Ct||Vt<Ct)&&(Ye._spread=!0),Ye.end=Object.assign({},Ct?ae[Ct][1].start:rt[1].end),ae.splice(Ct||be,0,["exit",Ye,rt[2]]),be++,fe++}if(rt[1].type==="listItemPrefix"){const ce={type:"listItem",_spread:!1,start:Object.assign({},rt[1].start),end:void 0};Ye=ce,ae.splice(be,0,["enter",ce,rt[2]]),be++,fe++,Vt=void 0,yt=!0}}}return ae[Q][1]._spread=Ve,fe}function c(ae,Q){return fe;function fe(be){u.call(this,ae(be),be),Q&&Q.call(this,be)}}function d(){this.stack.push({type:"fragment",children:[]})}function u(ae,Q,fe){this.stack[this.stack.length-1].children.push(ae),this.stack.push(ae),this.tokenStack.push([Q,fe||void 0]),ae.position={start:zn(Q.start),end:void 0}}function h(ae){return Q;function Q(fe){ae&&ae.call(this,fe),p.call(this,fe)}}function p(ae,Q){const fe=this.stack.pop(),be=this.tokenStack.pop();if(be)be[0].type!==ae.type&&(Q?Q.call(this,ae,be[0]):(be[1]||yf).call(this,ae,be[0]));else throw new Error("Cannot close `"+ae.type+"` ("+ia({start:ae.start,end:ae.end})+"): it’s not open");fe.position.end=zn(ae.end)}function x(){return uS(this.stack.pop())}function g(){this.data.expectingFirstListItemValue=!0}function b(ae){if(this.data.expectingFirstListItemValue){const Q=this.stack[this.stack.length-2];Q.start=Number.parseInt(this.sliceSerialize(ae),10),this.data.expectingFirstListItemValue=void 0}}function v(){const ae=this.resume(),Q=this.stack[this.stack.length-1];Q.lang=ae}function k(){const ae=this.resume(),Q=this.stack[this.stack.length-1];Q.meta=ae}function T(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function N(){const ae=this.resume(),Q=this.stack[this.stack.length-1];Q.value=ae.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function j(){const ae=this.resume(),Q=this.stack[this.stack.length-1];Q.value=ae.replace(/(\r?\n|\r)$/g,"")}function A(ae){const Q=this.resume(),fe=this.stack[this.stack.length-1];fe.label=Q,fe.identifier=ei(this.sliceSerialize(ae)).toLowerCase()}function M(){const ae=this.resume(),Q=this.stack[this.stack.length-1];Q.title=ae}function _(){const ae=this.resume(),Q=this.stack[this.stack.length-1];Q.url=ae}function z(ae){const Q=this.stack[this.stack.length-1];if(!Q.depth){const fe=this.sliceSerialize(ae).length;Q.depth=fe}}function P(){this.data.setextHeadingSlurpLineEnding=!0}function $(ae){const Q=this.stack[this.stack.length-1];Q.depth=this.sliceSerialize(ae).codePointAt(0)===61?1:2}function V(){this.data.setextHeadingSlurpLineEnding=void 0}function B(ae){const fe=this.stack[this.stack.length-1].children;let be=fe[fe.length-1];(!be||be.type!=="text")&&(be=er(),be.position={start:zn(ae.start),end:void 0},fe.push(be)),this.stack.push(be)}function U(ae){const Q=this.stack.pop();Q.value+=this.sliceSerialize(ae),Q.position.end=zn(ae.end)}function D(ae){const Q=this.stack[this.stack.length-1];if(this.data.atHardBreak){const fe=Q.children[Q.children.length-1];fe.position.end=zn(ae.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&r.canContainEols.includes(Q.type)&&(B.call(this,ae),U.call(this,ae))}function R(){this.data.atHardBreak=!0}function X(){const ae=this.resume(),Q=this.stack[this.stack.length-1];Q.value=ae}function I(){const ae=this.resume(),Q=this.stack[this.stack.length-1];Q.value=ae}function H(){const ae=this.resume(),Q=this.stack[this.stack.length-1];Q.value=ae}function W(){const ae=this.stack[this.stack.length-1];if(this.data.inReference){const Q=this.data.referenceType||"shortcut";ae.type+="Reference",ae.referenceType=Q,delete ae.url,delete ae.title}else delete ae.identifier,delete ae.label;this.data.referenceType=void 0}function J(){const ae=this.stack[this.stack.length-1];if(this.data.inReference){const Q=this.data.referenceType||"shortcut";ae.type+="Reference",ae.referenceType=Q,delete ae.url,delete ae.title}else delete ae.identifier,delete ae.label;this.data.referenceType=void 0}function Z(ae){const Q=this.sliceSerialize(ae),fe=this.stack[this.stack.length-2];fe.label=d6(Q),fe.identifier=ei(Q).toLowerCase()}function de(){const ae=this.stack[this.stack.length-1],Q=this.resume(),fe=this.stack[this.stack.length-1];if(this.data.inReference=!0,fe.type==="link"){const be=ae.children;fe.children=be}else fe.alt=Q}function E(){const ae=this.resume(),Q=this.stack[this.stack.length-1];Q.url=ae}function L(){const ae=this.resume(),Q=this.stack[this.stack.length-1];Q.title=ae}function q(){this.data.inReference=void 0}function S(){this.data.referenceType="collapsed"}function G(ae){const Q=this.resume(),fe=this.stack[this.stack.length-1];fe.label=Q,fe.identifier=ei(this.sliceSerialize(ae)).toLowerCase(),this.data.referenceType="full"}function re(ae){this.data.characterReferenceType=ae.type}function ee(ae){const Q=this.sliceSerialize(ae),fe=this.data.characterReferenceType;let be;fe?(be=cy(Q,fe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):be=Qu(Q);const Me=this.stack[this.stack.length-1];Me.value+=be}function ge(ae){const Q=this.stack.pop();Q.position.end=zn(ae.end)}function je(ae){U.call(this,ae);const Q=this.stack[this.stack.length-1];Q.url=this.sliceSerialize(ae)}function Le(ae){U.call(this,ae);const Q=this.stack[this.stack.length-1];Q.url="mailto:"+this.sliceSerialize(ae)}function ve(){return{type:"blockquote",children:[]}}function F(){return{type:"code",lang:null,meta:null,value:""}}function he(){return{type:"inlineCode",value:""}}function ue(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Oe(){return{type:"emphasis",children:[]}}function Se(){return{type:"heading",depth:0,children:[]}}function We(){return{type:"break"}}function qe(){return{type:"html",value:""}}function tt(){return{type:"image",title:null,url:"",alt:null}}function ft(){return{type:"link",title:null,url:"",children:[]}}function Rt(ae){return{type:"list",ordered:ae.type==="listOrdered",start:null,spread:ae._spread,children:[]}}function $t(ae){return{type:"listItem",spread:ae._spread,checked:null,children:[]}}function Zt(){return{type:"paragraph",children:[]}}function ar(){return{type:"strong",children:[]}}function er(){return{type:"text",value:""}}function Et(){return{type:"thematicBreak"}}}function zn(e){return{line:e.line,column:e.column,offset:e.offset}}function wy(e,r){let s=-1;for(;++s<r.length;){const a=r[s];Array.isArray(a)?wy(e,a):p6(e,a)}}function p6(e,r){let s;for(s in r)if(vy.call(r,s))switch(s){case"canContainEols":{const a=r[s];a&&e[s].push(...a);break}case"transforms":{const a=r[s];a&&e[s].push(...a);break}case"enter":case"exit":{const a=r[s];a&&Object.assign(e[s],a);break}}}function yf(e,r){throw e?new Error("Cannot close `"+e.type+"` ("+ia({start:e.start,end:e.end})+"): a different token (`"+r.type+"`, "+ia({start:r.start,end:r.end})+") is open"):new Error("Cannot close document, a token (`"+r.type+"`, "+ia({start:r.start,end:r.end})+") is still open")}function f6(e){const r=this;r.parser=s;function s(a){return m6(a,{...r.data("settings"),...e,extensions:r.data("micromarkExtensions")||[],mdastExtensions:r.data("fromMarkdownExtensions")||[]})}}function x6(e,r){const s={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(r),!0)};return e.patch(r,s),e.applyData(r,s)}function g6(e,r){const s={type:"element",tagName:"br",properties:{},children:[]};return e.patch(r,s),[e.applyData(r,s),{type:"text",value:`
|
|
225
|
+
`}]}function y6(e,r){const s=r.value?r.value+`
|
|
226
|
+
`:"",a={},o=r.lang?r.lang.split(/\s+/):[];o.length>0&&(a.className=["language-"+o[0]]);let c={type:"element",tagName:"code",properties:a,children:[{type:"text",value:s}]};return r.meta&&(c.data={meta:r.meta}),e.patch(r,c),c=e.applyData(r,c),c={type:"element",tagName:"pre",properties:{},children:[c]},e.patch(r,c),c}function v6(e,r){const s={type:"element",tagName:"del",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function w6(e,r){const s={type:"element",tagName:"em",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function b6(e,r){const s=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",a=String(r.identifier).toUpperCase(),o=mi(a.toLowerCase()),c=e.footnoteOrder.indexOf(a);let d,u=e.footnoteCounts.get(a);u===void 0?(u=0,e.footnoteOrder.push(a),d=e.footnoteOrder.length):d=c+1,u+=1,e.footnoteCounts.set(a,u);const h={type:"element",tagName:"a",properties:{href:"#"+s+"fn-"+o,id:s+"fnref-"+o+(u>1?"-"+u:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(d)}]};e.patch(r,h);const p={type:"element",tagName:"sup",properties:{},children:[h]};return e.patch(r,p),e.applyData(r,p)}function j6(e,r){const s={type:"element",tagName:"h"+r.depth,properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function k6(e,r){if(e.options.allowDangerousHtml){const s={type:"raw",value:r.value};return e.patch(r,s),e.applyData(r,s)}}function by(e,r){const s=r.referenceType;let a="]";if(s==="collapsed"?a+="[]":s==="full"&&(a+="["+(r.label||r.identifier)+"]"),r.type==="imageReference")return[{type:"text",value:"!["+r.alt+a}];const o=e.all(r),c=o[0];c&&c.type==="text"?c.value="["+c.value:o.unshift({type:"text",value:"["});const d=o[o.length-1];return d&&d.type==="text"?d.value+=a:o.push({type:"text",value:a}),o}function N6(e,r){const s=String(r.identifier).toUpperCase(),a=e.definitionById.get(s);if(!a)return by(e,r);const o={src:mi(a.url||""),alt:r.alt};a.title!==null&&a.title!==void 0&&(o.title=a.title);const c={type:"element",tagName:"img",properties:o,children:[]};return e.patch(r,c),e.applyData(r,c)}function C6(e,r){const s={src:mi(r.url)};r.alt!==null&&r.alt!==void 0&&(s.alt=r.alt),r.title!==null&&r.title!==void 0&&(s.title=r.title);const a={type:"element",tagName:"img",properties:s,children:[]};return e.patch(r,a),e.applyData(r,a)}function S6(e,r){const s={type:"text",value:r.value.replace(/\r?\n|\r/g," ")};e.patch(r,s);const a={type:"element",tagName:"code",properties:{},children:[s]};return e.patch(r,a),e.applyData(r,a)}function _6(e,r){const s=String(r.identifier).toUpperCase(),a=e.definitionById.get(s);if(!a)return by(e,r);const o={href:mi(a.url||"")};a.title!==null&&a.title!==void 0&&(o.title=a.title);const c={type:"element",tagName:"a",properties:o,children:e.all(r)};return e.patch(r,c),e.applyData(r,c)}function L6(e,r){const s={href:mi(r.url)};r.title!==null&&r.title!==void 0&&(s.title=r.title);const a={type:"element",tagName:"a",properties:s,children:e.all(r)};return e.patch(r,a),e.applyData(r,a)}function E6(e,r,s){const a=e.all(r),o=s?T6(s):jy(r),c={},d=[];if(typeof r.checked=="boolean"){const x=a[0];let g;x&&x.type==="element"&&x.tagName==="p"?g=x:(g={type:"element",tagName:"p",properties:{},children:[]},a.unshift(g)),g.children.length>0&&g.children.unshift({type:"text",value:" "}),g.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:r.checked,disabled:!0},children:[]}),c.className=["task-list-item"]}let u=-1;for(;++u<a.length;){const x=a[u];(o||u!==0||x.type!=="element"||x.tagName!=="p")&&d.push({type:"text",value:`
|
|
227
|
+
`}),x.type==="element"&&x.tagName==="p"&&!o?d.push(...x.children):d.push(x)}const h=a[a.length-1];h&&(o||h.type!=="element"||h.tagName!=="p")&&d.push({type:"text",value:`
|
|
228
|
+
`});const p={type:"element",tagName:"li",properties:c,children:d};return e.patch(r,p),e.applyData(r,p)}function T6(e){let r=!1;if(e.type==="list"){r=e.spread||!1;const s=e.children;let a=-1;for(;!r&&++a<s.length;)r=jy(s[a])}return r}function jy(e){const r=e.spread;return r??e.children.length>1}function A6(e,r){const s={},a=e.all(r);let o=-1;for(typeof r.start=="number"&&r.start!==1&&(s.start=r.start);++o<a.length;){const d=a[o];if(d.type==="element"&&d.tagName==="li"&&d.properties&&Array.isArray(d.properties.className)&&d.properties.className.includes("task-list-item")){s.className=["contains-task-list"];break}}const c={type:"element",tagName:r.ordered?"ol":"ul",properties:s,children:e.wrap(a,!0)};return e.patch(r,c),e.applyData(r,c)}function P6(e,r){const s={type:"element",tagName:"p",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function I6(e,r){const s={type:"root",children:e.wrap(e.all(r))};return e.patch(r,s),e.applyData(r,s)}function M6(e,r){const s={type:"element",tagName:"strong",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function R6(e,r){const s=e.all(r),a=s.shift(),o=[];if(a){const d={type:"element",tagName:"thead",properties:{},children:e.wrap([a],!0)};e.patch(r.children[0],d),o.push(d)}if(s.length>0){const d={type:"element",tagName:"tbody",properties:{},children:e.wrap(s,!0)},u=qu(r.children[1]),h=ry(r.children[r.children.length-1]);u&&h&&(d.position={start:u,end:h}),o.push(d)}const c={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(r,c),e.applyData(r,c)}function $6(e,r,s){const a=s?s.children:void 0,c=(a?a.indexOf(r):1)===0?"th":"td",d=s&&s.type==="table"?s.align:void 0,u=d?d.length:r.children.length;let h=-1;const p=[];for(;++h<u;){const g=r.children[h],b={},v=d?d[h]:void 0;v&&(b.align=v);let k={type:"element",tagName:c,properties:b,children:[]};g&&(k.children=e.all(g),e.patch(g,k),k=e.applyData(g,k)),p.push(k)}const x={type:"element",tagName:"tr",properties:{},children:e.wrap(p,!0)};return e.patch(r,x),e.applyData(r,x)}function D6(e,r){const s={type:"element",tagName:"td",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}const vf=9,wf=32;function B6(e){const r=String(e),s=/\r?\n|\r/g;let a=s.exec(r),o=0;const c=[];for(;a;)c.push(bf(r.slice(o,a.index),o>0,!0),a[0]),o=a.index+a[0].length,a=s.exec(r);return c.push(bf(r.slice(o),o>0,!1)),c.join("")}function bf(e,r,s){let a=0,o=e.length;if(r){let c=e.codePointAt(a);for(;c===vf||c===wf;)a++,c=e.codePointAt(a)}if(s){let c=e.codePointAt(o-1);for(;c===vf||c===wf;)o--,c=e.codePointAt(o-1)}return o>a?e.slice(a,o):""}function z6(e,r){const s={type:"text",value:B6(String(r.value))};return e.patch(r,s),e.applyData(r,s)}function O6(e,r){const s={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(r,s),e.applyData(r,s)}const F6={blockquote:x6,break:g6,code:y6,delete:v6,emphasis:w6,footnoteReference:b6,heading:j6,html:k6,imageReference:N6,image:C6,inlineCode:S6,linkReference:_6,link:L6,listItem:E6,list:A6,paragraph:P6,root:I6,strong:M6,table:R6,tableCell:D6,tableRow:$6,text:z6,thematicBreak:O6,toml:zo,yaml:zo,definition:zo,footnoteDefinition:zo};function zo(){}const ky=-1,bl=0,oa=1,ll=2,Zu=3,em=4,tm=5,rm=6,Ny=7,Cy=8,jf=typeof self=="object"?self:globalThis,W6=(e,r)=>{const s=(o,c)=>(e.set(c,o),o),a=o=>{if(e.has(o))return e.get(o);const[c,d]=r[o];switch(c){case bl:case ky:return s(d,o);case oa:{const u=s([],o);for(const h of d)u.push(a(h));return u}case ll:{const u=s({},o);for(const[h,p]of d)u[a(h)]=a(p);return u}case Zu:return s(new Date(d),o);case em:{const{source:u,flags:h}=d;return s(new RegExp(u,h),o)}case tm:{const u=s(new Map,o);for(const[h,p]of d)u.set(a(h),a(p));return u}case rm:{const u=s(new Set,o);for(const h of d)u.add(a(h));return u}case Ny:{const{name:u,message:h}=d;return s(new jf[u](h),o)}case Cy:return s(BigInt(d),o);case"BigInt":return s(Object(BigInt(d)),o);case"ArrayBuffer":return s(new Uint8Array(d).buffer,d);case"DataView":{const{buffer:u}=new Uint8Array(d);return s(new DataView(u),d)}}return s(new jf[c](d),o)};return a},kf=e=>W6(new Map,e)(0),Ys="",{toString:H6}={},{keys:U6}=Object,ta=e=>{const r=typeof e;if(r!=="object"||!e)return[bl,r];const s=H6.call(e).slice(8,-1);switch(s){case"Array":return[oa,Ys];case"Object":return[ll,Ys];case"Date":return[Zu,Ys];case"RegExp":return[em,Ys];case"Map":return[tm,Ys];case"Set":return[rm,Ys];case"DataView":return[oa,s]}return s.includes("Array")?[oa,s]:s.includes("Error")?[Ny,s]:[ll,s]},Oo=([e,r])=>e===bl&&(r==="function"||r==="symbol"),V6=(e,r,s,a)=>{const o=(d,u)=>{const h=a.push(d)-1;return s.set(u,h),h},c=d=>{if(s.has(d))return s.get(d);let[u,h]=ta(d);switch(u){case bl:{let x=d;switch(h){case"bigint":u=Cy,x=d.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+h);x=null;break;case"undefined":return o([ky],d)}return o([u,x],d)}case oa:{if(h){let b=d;return h==="DataView"?b=new Uint8Array(d.buffer):h==="ArrayBuffer"&&(b=new Uint8Array(d)),o([h,[...b]],d)}const x=[],g=o([u,x],d);for(const b of d)x.push(c(b));return g}case ll:{if(h)switch(h){case"BigInt":return o([h,d.toString()],d);case"Boolean":case"Number":case"String":return o([h,d.valueOf()],d)}if(r&&"toJSON"in d)return c(d.toJSON());const x=[],g=o([u,x],d);for(const b of U6(d))(e||!Oo(ta(d[b])))&&x.push([c(b),c(d[b])]);return g}case Zu:return o([u,d.toISOString()],d);case em:{const{source:x,flags:g}=d;return o([u,{source:x,flags:g}],d)}case tm:{const x=[],g=o([u,x],d);for(const[b,v]of d)(e||!(Oo(ta(b))||Oo(ta(v))))&&x.push([c(b),c(v)]);return g}case rm:{const x=[],g=o([u,x],d);for(const b of d)(e||!Oo(ta(b)))&&x.push(c(b));return g}}const{message:p}=d;return o([u,{name:h,message:p}],d)};return c},Nf=(e,{json:r,lossy:s}={})=>{const a=[];return V6(!(r||s),!!r,new Map,a)(e),a},cl=typeof structuredClone=="function"?(e,r)=>r&&("json"in r||"lossy"in r)?kf(Nf(e,r)):structuredClone(e):(e,r)=>kf(Nf(e,r));function q6(e,r){const s=[{type:"text",value:"↩"}];return r>1&&s.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(r)}]}),s}function Y6(e,r){return"Back to reference "+(e+1)+(r>1?"-"+r:"")}function G6(e){const r=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=e.options.footnoteBackContent||q6,a=e.options.footnoteBackLabel||Y6,o=e.options.footnoteLabel||"Footnotes",c=e.options.footnoteLabelTagName||"h2",d=e.options.footnoteLabelProperties||{className:["sr-only"]},u=[];let h=-1;for(;++h<e.footnoteOrder.length;){const p=e.footnoteById.get(e.footnoteOrder[h]);if(!p)continue;const x=e.all(p),g=String(p.identifier).toUpperCase(),b=mi(g.toLowerCase());let v=0;const k=[],T=e.footnoteCounts.get(g);for(;T!==void 0&&++v<=T;){k.length>0&&k.push({type:"text",value:" "});let A=typeof s=="string"?s:s(h,v);typeof A=="string"&&(A={type:"text",value:A}),k.push({type:"element",tagName:"a",properties:{href:"#"+r+"fnref-"+b+(v>1?"-"+v:""),dataFootnoteBackref:"",ariaLabel:typeof a=="string"?a:a(h,v),className:["data-footnote-backref"]},children:Array.isArray(A)?A:[A]})}const N=x[x.length-1];if(N&&N.type==="element"&&N.tagName==="p"){const A=N.children[N.children.length-1];A&&A.type==="text"?A.value+=" ":N.children.push({type:"text",value:" "}),N.children.push(...k)}else x.push(...k);const j={type:"element",tagName:"li",properties:{id:r+"fn-"+b},children:e.wrap(x,!0)};e.patch(p,j),u.push(j)}if(u.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:c,properties:{...cl(d),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
|
|
229
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(u,!0)},{type:"text",value:`
|
|
230
|
+
`}]}}const Sy=(function(e){if(e==null)return X6;if(typeof e=="function")return jl(e);if(typeof e=="object")return Array.isArray(e)?K6(e):Q6(e);if(typeof e=="string")return J6(e);throw new Error("Expected function, string, or object as test")});function K6(e){const r=[];let s=-1;for(;++s<e.length;)r[s]=Sy(e[s]);return jl(a);function a(...o){let c=-1;for(;++c<r.length;)if(r[c].apply(this,o))return!0;return!1}}function Q6(e){const r=e;return jl(s);function s(a){const o=a;let c;for(c in e)if(o[c]!==r[c])return!1;return!0}}function J6(e){return jl(r);function r(s){return s&&s.type===e}}function jl(e){return r;function r(s,a,o){return!!(Z6(s)&&e.call(this,s,typeof a=="number"?a:void 0,o||void 0))}}function X6(){return!0}function Z6(e){return e!==null&&typeof e=="object"&&"type"in e}const _y=[],eL=!0,Cf=!1,tL="skip";function rL(e,r,s,a){let o;typeof r=="function"&&typeof s!="function"?(a=s,s=r):o=r;const c=Sy(o),d=a?-1:1;u(e,void 0,[])();function u(h,p,x){const g=h&&typeof h=="object"?h:{};if(typeof g.type=="string"){const v=typeof g.tagName=="string"?g.tagName:typeof g.name=="string"?g.name:void 0;Object.defineProperty(b,"name",{value:"node ("+(h.type+(v?"<"+v+">":""))+")"})}return b;function b(){let v=_y,k,T,N;if((!r||c(h,p,x[x.length-1]||void 0))&&(v=nL(s(h,x)),v[0]===Cf))return v;if("children"in h&&h.children){const j=h;if(j.children&&v[0]!==tL)for(T=(a?j.children.length:-1)+d,N=x.concat(j);T>-1&&T<j.children.length;){const A=j.children[T];if(k=u(A,T,N)(),k[0]===Cf)return k;T=typeof k[1]=="number"?k[1]:T+d}}return v}}}function nL(e){return Array.isArray(e)?e:typeof e=="number"?[eL,e]:e==null?_y:[e]}function Ly(e,r,s,a){let o,c,d;typeof r=="function"&&typeof s!="function"?(c=void 0,d=r,o=s):(c=r,d=s,o=a),rL(e,c,u,o);function u(h,p){const x=p[p.length-1],g=x?x.children.indexOf(h):void 0;return d(h,g,x)}}const iu={}.hasOwnProperty,sL={};function iL(e,r){const s=r||sL,a=new Map,o=new Map,c=new Map,d={...F6,...s.handlers},u={all:p,applyData:oL,definitionById:a,footnoteById:o,footnoteCounts:c,footnoteOrder:[],handlers:d,one:h,options:s,patch:aL,wrap:cL};return Ly(e,function(x){if(x.type==="definition"||x.type==="footnoteDefinition"){const g=x.type==="definition"?a:o,b=String(x.identifier).toUpperCase();g.has(b)||g.set(b,x)}}),u;function h(x,g){const b=x.type,v=u.handlers[b];if(iu.call(u.handlers,b)&&v)return v(u,x,g);if(u.options.passThrough&&u.options.passThrough.includes(b)){if("children"in x){const{children:T,...N}=x,j=cl(N);return j.children=u.all(x),j}return cl(x)}return(u.options.unknownHandler||lL)(u,x,g)}function p(x){const g=[];if("children"in x){const b=x.children;let v=-1;for(;++v<b.length;){const k=u.one(b[v],x);if(k){if(v&&b[v-1].type==="break"&&(!Array.isArray(k)&&k.type==="text"&&(k.value=Sf(k.value)),!Array.isArray(k)&&k.type==="element")){const T=k.children[0];T&&T.type==="text"&&(T.value=Sf(T.value))}Array.isArray(k)?g.push(...k):g.push(k)}}}return g}}function aL(e,r){e.position&&(r.position=HC(e))}function oL(e,r){let s=r;if(e&&e.data){const a=e.data.hName,o=e.data.hChildren,c=e.data.hProperties;if(typeof a=="string")if(s.type==="element")s.tagName=a;else{const d="children"in s?s.children:[s];s={type:"element",tagName:a,properties:{},children:d}}s.type==="element"&&c&&Object.assign(s.properties,cl(c)),"children"in s&&s.children&&o!==null&&o!==void 0&&(s.children=o)}return s}function lL(e,r){const s=r.data||{},a="value"in r&&!(iu.call(s,"hProperties")||iu.call(s,"hChildren"))?{type:"text",value:r.value}:{type:"element",tagName:"div",properties:{},children:e.all(r)};return e.patch(r,a),e.applyData(r,a)}function cL(e,r){const s=[];let a=-1;for(r&&s.push({type:"text",value:`
|
|
231
|
+
`});++a<e.length;)a&&s.push({type:"text",value:`
|
|
232
|
+
`}),s.push(e[a]);return r&&e.length>0&&s.push({type:"text",value:`
|
|
233
|
+
`}),s}function Sf(e){let r=0,s=e.charCodeAt(r);for(;s===9||s===32;)r++,s=e.charCodeAt(r);return e.slice(r)}function _f(e,r){const s=iL(e,r),a=s.one(e,void 0),o=G6(s),c=Array.isArray(a)?{type:"root",children:a}:a||{type:"root",children:[]};return o&&c.children.push({type:"text",value:`
|
|
234
|
+
`},o),c}function dL(e,r){return e&&"run"in e?async function(s,a){const o=_f(s,{file:a,...r});await e.run(o,a)}:function(s,a){return _f(s,{file:a,...e||r})}}function Lf(e){if(e)throw e}var _d,Ef;function uL(){if(Ef)return _d;Ef=1;var e=Object.prototype.hasOwnProperty,r=Object.prototype.toString,s=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(p){return typeof Array.isArray=="function"?Array.isArray(p):r.call(p)==="[object Array]"},c=function(p){if(!p||r.call(p)!=="[object Object]")return!1;var x=e.call(p,"constructor"),g=p.constructor&&p.constructor.prototype&&e.call(p.constructor.prototype,"isPrototypeOf");if(p.constructor&&!x&&!g)return!1;var b;for(b in p);return typeof b>"u"||e.call(p,b)},d=function(p,x){s&&x.name==="__proto__"?s(p,x.name,{enumerable:!0,configurable:!0,value:x.newValue,writable:!0}):p[x.name]=x.newValue},u=function(p,x){if(x==="__proto__")if(e.call(p,x)){if(a)return a(p,x).value}else return;return p[x]};return _d=function h(){var p,x,g,b,v,k,T=arguments[0],N=1,j=arguments.length,A=!1;for(typeof T=="boolean"&&(A=T,T=arguments[1]||{},N=2),(T==null||typeof T!="object"&&typeof T!="function")&&(T={});N<j;++N)if(p=arguments[N],p!=null)for(x in p)g=u(T,x),b=u(p,x),T!==b&&(A&&b&&(c(b)||(v=o(b)))?(v?(v=!1,k=g&&o(g)?g:[]):k=g&&c(g)?g:{},d(T,{name:x,newValue:h(A,k,b)})):typeof b<"u"&&d(T,{name:x,newValue:b}));return T},_d}var mL=uL();const Ld=ul(mL);function au(e){if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function hL(){const e=[],r={run:s,use:a};return r;function s(...o){let c=-1;const d=o.pop();if(typeof d!="function")throw new TypeError("Expected function as last argument, not "+d);u(null,...o);function u(h,...p){const x=e[++c];let g=-1;if(h){d(h);return}for(;++g<o.length;)(p[g]===null||p[g]===void 0)&&(p[g]=o[g]);o=p,x?pL(x,u)(...p):d(null,...p)}}function a(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),r}}function pL(e,r){let s;return a;function a(...d){const u=e.length>d.length;let h;u&&d.push(o);try{h=e.apply(this,d)}catch(p){const x=p;if(u&&s)throw x;return o(x)}u||(h&&h.then&&typeof h.then=="function"?h.then(c,o):h instanceof Error?o(h):c(h))}function o(d,...u){s||(s=!0,r(d,...u))}function c(d){o(null,d)}}const Jr={basename:fL,dirname:xL,extname:gL,join:yL,sep:"/"};function fL(e,r){if(r!==void 0&&typeof r!="string")throw new TypeError('"ext" argument must be a string');Ca(e);let s=0,a=-1,o=e.length,c;if(r===void 0||r.length===0||r.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(c){s=o+1;break}}else a<0&&(c=!0,a=o+1);return a<0?"":e.slice(s,a)}if(r===e)return"";let d=-1,u=r.length-1;for(;o--;)if(e.codePointAt(o)===47){if(c){s=o+1;break}}else d<0&&(c=!0,d=o+1),u>-1&&(e.codePointAt(o)===r.codePointAt(u--)?u<0&&(a=o):(u=-1,a=d));return s===a?a=d:a<0&&(a=e.length),e.slice(s,a)}function xL(e){if(Ca(e),e.length===0)return".";let r=-1,s=e.length,a;for(;--s;)if(e.codePointAt(s)===47){if(a){r=s;break}}else a||(a=!0);return r<0?e.codePointAt(0)===47?"/":".":r===1&&e.codePointAt(0)===47?"//":e.slice(0,r)}function gL(e){Ca(e);let r=e.length,s=-1,a=0,o=-1,c=0,d;for(;r--;){const u=e.codePointAt(r);if(u===47){if(d){a=r+1;break}continue}s<0&&(d=!0,s=r+1),u===46?o<0?o=r:c!==1&&(c=1):o>-1&&(c=-1)}return o<0||s<0||c===0||c===1&&o===s-1&&o===a+1?"":e.slice(o,s)}function yL(...e){let r=-1,s;for(;++r<e.length;)Ca(e[r]),e[r]&&(s=s===void 0?e[r]:s+"/"+e[r]);return s===void 0?".":vL(s)}function vL(e){Ca(e);const r=e.codePointAt(0)===47;let s=wL(e,!r);return s.length===0&&!r&&(s="."),s.length>0&&e.codePointAt(e.length-1)===47&&(s+="/"),r?"/"+s:s}function wL(e,r){let s="",a=0,o=-1,c=0,d=-1,u,h;for(;++d<=e.length;){if(d<e.length)u=e.codePointAt(d);else{if(u===47)break;u=47}if(u===47){if(!(o===d-1||c===1))if(o!==d-1&&c===2){if(s.length<2||a!==2||s.codePointAt(s.length-1)!==46||s.codePointAt(s.length-2)!==46){if(s.length>2){if(h=s.lastIndexOf("/"),h!==s.length-1){h<0?(s="",a=0):(s=s.slice(0,h),a=s.length-1-s.lastIndexOf("/")),o=d,c=0;continue}}else if(s.length>0){s="",a=0,o=d,c=0;continue}}r&&(s=s.length>0?s+"/..":"..",a=2)}else s.length>0?s+="/"+e.slice(o+1,d):s=e.slice(o+1,d),a=d-o-1;o=d,c=0}else u===46&&c>-1?c++:c=-1}return s}function Ca(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const bL={cwd:jL};function jL(){return"/"}function ou(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function kL(e){if(typeof e=="string")e=new URL(e);else if(!ou(e)){const r=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw r.code="ERR_INVALID_ARG_TYPE",r}if(e.protocol!=="file:"){const r=new TypeError("The URL must be of scheme file");throw r.code="ERR_INVALID_URL_SCHEME",r}return NL(e)}function NL(e){if(e.hostname!==""){const a=new TypeError('File URL host must be "localhost" or empty on darwin');throw a.code="ERR_INVALID_FILE_URL_HOST",a}const r=e.pathname;let s=-1;for(;++s<r.length;)if(r.codePointAt(s)===37&&r.codePointAt(s+1)===50){const a=r.codePointAt(s+2);if(a===70||a===102){const o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(r)}const Ed=["history","path","basename","stem","extname","dirname"];class Ey{constructor(r){let s;r?ou(r)?s={path:r}:typeof r=="string"||CL(r)?s={value:r}:s=r:s={},this.cwd="cwd"in s?"":bL.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let a=-1;for(;++a<Ed.length;){const c=Ed[a];c in s&&s[c]!==void 0&&s[c]!==null&&(this[c]=c==="history"?[...s[c]]:s[c])}let o;for(o in s)Ed.includes(o)||(this[o]=s[o])}get basename(){return typeof this.path=="string"?Jr.basename(this.path):void 0}set basename(r){Ad(r,"basename"),Td(r,"basename"),this.path=Jr.join(this.dirname||"",r)}get dirname(){return typeof this.path=="string"?Jr.dirname(this.path):void 0}set dirname(r){Tf(this.basename,"dirname"),this.path=Jr.join(r||"",this.basename)}get extname(){return typeof this.path=="string"?Jr.extname(this.path):void 0}set extname(r){if(Td(r,"extname"),Tf(this.dirname,"extname"),r){if(r.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(r.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Jr.join(this.dirname,this.stem+(r||""))}get path(){return this.history[this.history.length-1]}set path(r){ou(r)&&(r=kL(r)),Ad(r,"path"),this.path!==r&&this.history.push(r)}get stem(){return typeof this.path=="string"?Jr.basename(this.path,this.extname):void 0}set stem(r){Ad(r,"stem"),Td(r,"stem"),this.path=Jr.join(this.dirname||"",r+(this.extname||""))}fail(r,s,a){const o=this.message(r,s,a);throw o.fatal=!0,o}info(r,s,a){const o=this.message(r,s,a);return o.fatal=void 0,o}message(r,s,a){const o=new Xt(r,s,a);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(r){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(r||void 0).decode(this.value)}}function Td(e,r){if(e&&e.includes(Jr.sep))throw new Error("`"+r+"` cannot be a path: did not expect `"+Jr.sep+"`")}function Ad(e,r){if(!e)throw new Error("`"+r+"` cannot be empty")}function Tf(e,r){if(!e)throw new Error("Setting `"+r+"` requires `path` to be set too")}function CL(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const SL=(function(e){const a=this.constructor.prototype,o=a[e],c=function(){return o.apply(c,arguments)};return Object.setPrototypeOf(c,a),c}),_L={}.hasOwnProperty;class nm extends SL{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=hL()}copy(){const r=new nm;let s=-1;for(;++s<this.attachers.length;){const a=this.attachers[s];r.use(...a)}return r.data(Ld(!0,{},this.namespace)),r}data(r,s){return typeof r=="string"?arguments.length===2?(Md("data",this.frozen),this.namespace[r]=s,this):_L.call(this.namespace,r)&&this.namespace[r]||void 0:r?(Md("data",this.frozen),this.namespace=r,this):this.namespace}freeze(){if(this.frozen)return this;const r=this;for(;++this.freezeIndex<this.attachers.length;){const[s,...a]=this.attachers[this.freezeIndex];if(a[0]===!1)continue;a[0]===!0&&(a[0]=void 0);const o=s.call(r,...a);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(r){this.freeze();const s=Fo(r),a=this.parser||this.Parser;return Pd("parse",a),a(String(s),s)}process(r,s){const a=this;return this.freeze(),Pd("process",this.parser||this.Parser),Id("process",this.compiler||this.Compiler),s?o(void 0,s):new Promise(o);function o(c,d){const u=Fo(r),h=a.parse(u);a.run(h,u,function(x,g,b){if(x||!g||!b)return p(x);const v=g,k=a.stringify(v,b);TL(k)?b.value=k:b.result=k,p(x,b)});function p(x,g){x||!g?d(x):c?c(g):s(void 0,g)}}}processSync(r){let s=!1,a;return this.freeze(),Pd("processSync",this.parser||this.Parser),Id("processSync",this.compiler||this.Compiler),this.process(r,o),Pf("processSync","process",s),a;function o(c,d){s=!0,Lf(c),a=d}}run(r,s,a){Af(r),this.freeze();const o=this.transformers;return!a&&typeof s=="function"&&(a=s,s=void 0),a?c(void 0,a):new Promise(c);function c(d,u){const h=Fo(s);o.run(r,h,p);function p(x,g,b){const v=g||r;x?u(x):d?d(v):a(void 0,v,b)}}}runSync(r,s){let a=!1,o;return this.run(r,s,c),Pf("runSync","run",a),o;function c(d,u){Lf(d),o=u,a=!0}}stringify(r,s){this.freeze();const a=Fo(s),o=this.compiler||this.Compiler;return Id("stringify",o),Af(r),o(r,a)}use(r,...s){const a=this.attachers,o=this.namespace;if(Md("use",this.frozen),r!=null)if(typeof r=="function")h(r,s);else if(typeof r=="object")Array.isArray(r)?u(r):d(r);else throw new TypeError("Expected usable value, not `"+r+"`");return this;function c(p){if(typeof p=="function")h(p,[]);else if(typeof p=="object")if(Array.isArray(p)){const[x,...g]=p;h(x,g)}else d(p);else throw new TypeError("Expected usable value, not `"+p+"`")}function d(p){if(!("plugins"in p)&&!("settings"in p))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");u(p.plugins),p.settings&&(o.settings=Ld(!0,o.settings,p.settings))}function u(p){let x=-1;if(p!=null)if(Array.isArray(p))for(;++x<p.length;){const g=p[x];c(g)}else throw new TypeError("Expected a list of plugins, not `"+p+"`")}function h(p,x){let g=-1,b=-1;for(;++g<a.length;)if(a[g][0]===p){b=g;break}if(b===-1)a.push([p,...x]);else if(x.length>0){let[v,...k]=x;const T=a[b][1];au(T)&&au(v)&&(v=Ld(!0,T,v)),a[b]=[p,v,...k]}}}}const LL=new nm().freeze();function Pd(e,r){if(typeof r!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Id(e,r){if(typeof r!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Md(e,r){if(r)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Af(e){if(!au(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Pf(e,r,s){if(!s)throw new Error("`"+e+"` finished async. Use `"+r+"` instead")}function Fo(e){return EL(e)?e:new Ey(e)}function EL(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function TL(e){return typeof e=="string"||AL(e)}function AL(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const PL="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",If=[],Mf={allowDangerousHtml:!0},IL=/^(https?|ircs?|mailto|xmpp)$/i,ML=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Ty(e){const r=RL(e),s=$L(e);return DL(r.runSync(r.parse(s),s),e)}function RL(e){const r=e.rehypePlugins||If,s=e.remarkPlugins||If,a=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Mf}:Mf;return LL().use(f6).use(s).use(dL,a).use(r)}function $L(e){const r=e.children||"",s=new Ey;return typeof r=="string"&&(s.value=r),s}function DL(e,r){const s=r.allowedElements,a=r.allowElement,o=r.components,c=r.disallowedElements,d=r.skipHtml,u=r.unwrapDisallowed,h=r.urlTransform||BL;for(const x of ML)Object.hasOwn(r,x.from)&&(""+x.from+(x.to?"use `"+x.to+"` instead":"remove it")+PL+x.id,void 0);return Ly(e,p),GC(e,{Fragment:t.Fragment,components:o,ignoreInvalidStyle:!0,jsx:t.jsx,jsxs:t.jsxs,passKeys:!0,passNode:!0});function p(x,g,b){if(x.type==="raw"&&b&&typeof g=="number")return d?b.children.splice(g,1):b.children[g]={type:"text",value:x.value},g;if(x.type==="element"){let v;for(v in Nd)if(Object.hasOwn(Nd,v)&&Object.hasOwn(x.properties,v)){const k=x.properties[v],T=Nd[v];(T===null||T.includes(x.tagName))&&(x.properties[v]=h(String(k||""),v,x))}}if(x.type==="element"){let v=s?!s.includes(x.tagName):c?c.includes(x.tagName):!1;if(!v&&a&&typeof g=="number"&&(v=!a(x,g,b)),v&&b&&typeof g=="number")return u&&x.children?b.children.splice(g,1,...x.children):b.children.splice(g,1),g}}}function BL(e){const r=e.indexOf(":"),s=e.indexOf("?"),a=e.indexOf("#"),o=e.indexOf("/");return r===-1||o!==-1&&r>o||s!==-1&&r>s||a!==-1&&r>a||IL.test(e.slice(0,r))?e:""}const zL={tool_use:{icon:"⚙",color:"text-blue-400"},tool_result:{icon:"✓",color:"text-green-400"},content:{icon:"✎",color:"text-gray-400"},iteration_start:{icon:"▶",color:"text-cyan-400"},iteration_complete:{icon:"✔",color:"text-green-400"},error:{icon:"✗",color:"text-red-400"}};function Ay({projectSlug:e,workflowId:r,stepId:s,refreshKey:a,onClonePrompt:o,cloneDisabled:c}){const[d,u]=y.useState([]),[h,p]=y.useState(!0),[x,g]=y.useState(null),[b,v]=y.useState(null),[k,T]=y.useState(null),[N,j]=y.useState(!1),[A,M]=y.useState(new Set),[_,z]=y.useState([]),[P,$]=y.useState(!1),[V,B]=y.useState(null),[U,D]=y.useState(new Set),[R,X]=y.useState(new Set),[I,H]=y.useState(null),[W,J]=y.useState(!1),Z=y.useCallback(async()=>{try{p(!0);const he=(await Wo(e,r)).filter(ue=>ue.step_id===s);u(he),g(null)}catch(F){g(F instanceof Error?F.message:"Failed to load sessions")}finally{p(!1)}},[e,r,s]);y.useEffect(()=>{Z()},[Z,a]);const de=async F=>{if(b===F.id){v(null),T(null),M(new Set),z([]),B(null),D(new Set),X(new Set);return}if(v(F.id),M(new Set),z([]),B(null),D(new Set),X(new Set),F.is_legacy){j(!0);try{const he=await c1(e,r,F.id);T(he)}catch(he){g(he instanceof Error?he.message:"Failed to load session detail")}finally{j(!1)}}else{$(!0);try{const he=await sx(e,r,F.id);z(he)}catch(he){B(he instanceof Error?he.message:"Failed to load events")}finally{$(!1)}}},E=F=>{if(!F)return"Unknown";const he=new Date(F);if(isNaN(he.getTime()))return"Unknown";const Oe=new Date().getTime()-he.getTime(),Se=Math.floor(Oe/6e4),We=Math.floor(Se/60),qe=Math.floor(We/24);return Se<1?"just now":Se<60?`${Se}m ago`:We<24?`${We}h ago`:qe<7?`${qe}d ago`:he.toLocaleDateString()},L=F=>{D(he=>{const ue=new Set(he);return ue.has(F)?ue.delete(F):ue.add(F),ue})},q=F=>{X(he=>{const ue=new Set(he);return ue.has(F)?ue.delete(F):ue.add(F),ue})},S=F=>{if(!F)return"";try{return JSON.stringify(JSON.parse(F),null,2)}catch{return F}},G=F=>zL[F]||{icon:"●",color:"text-gray-500"},re=F=>{const he=G(F.event_type);return F.event_type==="tool_use"?`${he.icon} ${F.tool_name||"tool"}`:F.event_type==="tool_result"?`${he.icon} ${F.tool_name||"result"}`:F.event_type==="content"?`${he.icon} content`:F.event_type==="iteration_start"?`${he.icon} iter ${F.iteration_number}`:F.event_type==="iteration_complete"?`${he.icon} iter ${F.iteration_number} done`:F.event_type==="error"?`${he.icon} error`:`${he.icon} ${F.event_type}`},ee=async(F,he,ue)=>{J(!0);try{const Oe=await Fd(e,r,F,he);H(Oe)}catch{H({iteration_id:he,iteration_number:ue??0,diff_text:null,chars_added:0,chars_removed:0,diff_lines:[]})}finally{J(!1)}},ge=F=>{switch(F){case"add":return"bg-green-900/30 text-green-300";case"remove":return"bg-red-900/30 text-red-300";case"hunk":return"bg-blue-900/30 text-blue-300";default:return"text-gray-400"}},je=F=>{const he=new Map;let ue=0;for(const Oe of F){Oe.event_type==="iteration_start"&&Oe.iteration_number&&(ue=Oe.iteration_number);const Se=Oe.iteration_number||ue||0;he.has(Se)||he.set(Se,[]),he.get(Se).push(Oe)}return he};if(h)return t.jsx("div",{className:"card",children:t.jsxs("div",{className:"flex items-center space-x-2 text-gray-400",children:[t.jsx("div",{className:"animate-spin w-4 h-4 border-2 border-gray-400 border-t-transparent rounded-full"}),t.jsx("span",{children:"Loading session history..."})]})});if(x)return t.jsx("div",{className:"card border-red-800 bg-red-900/20",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("p",{className:"text-red-400",children:x}),t.jsx("button",{onClick:Z,className:"text-sm text-red-400 hover:text-red-300 underline",children:"Retry"})]})});if(d.length===0)return null;const Le=_.filter(F=>F.event_type!=="heartbeat"),ve=je(Le);return t.jsxs("div",{className:"card",children:[t.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[t.jsx("svg",{className:"w-5 h-5 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Planning Sessions"]}),t.jsx("div",{className:"space-y-3",children:d.map((F,he)=>t.jsxs("div",{className:"border border-gray-700 rounded-lg overflow-hidden",children:[t.jsxs("button",{onClick:()=>de(F),className:"w-full px-4 py-3 bg-gray-800/50 hover:bg-gray-800 flex items-center justify-between text-left transition-colors",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[t.jsxs("span",{className:"text-white font-medium",children:["Session ",d.length-he]}),t.jsx("span",{className:"text-gray-500 text-sm",children:E(F.created_at)}),F.is_legacy&&t.jsx("span",{className:"px-2 py-0.5 bg-gray-600/30 text-gray-400 text-xs rounded",children:"Legacy chat"}),!F.is_legacy&&t.jsxs("span",{className:"text-gray-500 text-sm",children:[F.iterations_completed,"/",F.iterations_requested," iterations"]}),t.jsx("span",{className:`px-2 py-0.5 text-xs rounded ${F.run_status==="completed"?"bg-green-600/30 text-green-400":F.run_status==="running"?"bg-yellow-600/30 text-yellow-400":F.run_status==="cancelled"||F.run_status==="error"?"bg-red-600/30 text-red-400":"bg-blue-600/30 text-blue-400"}`,children:F.run_status})]}),F.prompt&&t.jsxs("p",{className:"text-gray-400 text-sm mt-1 truncate",children:['"',F.prompt,F.prompt.length>=100?"...":"",'"']}),!F.is_legacy&&(F.total_chars_added>0||F.total_chars_removed>0)&&t.jsxs("p",{className:"text-sm mt-1 flex items-center gap-2",children:[F.total_chars_added>0&&t.jsxs("span",{className:"text-green-400",children:["+",F.total_chars_added.toLocaleString()," chars"]}),F.total_chars_removed>0&&t.jsxs("span",{className:"text-red-400",children:["-",F.total_chars_removed.toLocaleString()," chars"]})]})]}),t.jsx("svg",{className:`w-5 h-5 text-gray-400 transition-transform flex-shrink-0 ml-2 ${b===F.id?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),b===F.id&&t.jsxs("div",{className:"px-4 py-3 border-t border-gray-700 bg-gray-900/50",children:[F.prompt&&t.jsxs("div",{className:"mb-3",children:[t.jsx("div",{className:"text-xs font-medium text-gray-500 uppercase tracking-wide mb-1",children:"Prompt"}),t.jsx("div",{className:"bg-gray-800/50 rounded-lg p-3 text-gray-300 text-sm whitespace-pre-wrap max-h-48 overflow-y-auto",children:F.prompt})]}),t.jsxs("div",{className:"text-xs text-gray-500 mb-3",children:[!F.is_legacy&&t.jsxs(t.Fragment,{children:[F.iterations_requested," iteration",F.iterations_requested!==1?"s":""," requested · "]}),new Date(F.created_at).toLocaleString()]}),!F.is_legacy&&o&&t.jsx("button",{disabled:c,onClick:()=>o(F.prompt||"",F.iterations_requested),className:"mb-3 px-3 py-1.5 text-xs font-medium bg-gray-700 hover:bg-gray-600 text-gray-200 rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Clone Session"}),F.run_status==="error"&&t.jsx("div",{className:"text-sm p-2 bg-red-900/30 text-red-400 rounded mb-3",children:"Session failed"}),!F.is_legacy&&t.jsxs(t.Fragment,{children:[F.iterations.length>0&&t.jsx("div",{className:"space-y-1 mb-3",children:F.iterations.map(ue=>t.jsxs("div",{className:"flex items-center gap-3 text-sm py-1",children:[t.jsx("span",{className:`${ue.status==="completed"?"text-green-400":ue.status==="failed"?"text-red-400":ue.status==="running"?"text-yellow-400":"text-gray-500"}`,children:ue.status==="completed"?"✓":ue.status==="failed"?"✗":ue.status==="running"?"●":"○"}),t.jsxs("span",{className:"text-gray-300",children:["Iteration ",ue.iteration_number]}),ue.chars_added>0&&t.jsxs("span",{className:"text-green-400 text-xs",children:["+",ue.chars_added]}),ue.chars_removed>0&&t.jsxs("span",{className:"text-red-400 text-xs",children:["-",ue.chars_removed]}),ue.summary&&t.jsx("span",{className:"text-gray-500 text-xs truncate",children:ue.summary}),ue.status==="completed"&&t.jsx("button",{onClick:Oe=>{Oe.stopPropagation(),ee(F.id,ue.id,ue.iteration_number)},disabled:W,className:"ml-auto text-xs px-2 py-0.5 bg-gray-700/50 hover:bg-gray-600/50 text-gray-400 hover:text-gray-200 border border-gray-600 rounded transition-colors flex-shrink-0",children:"View Diff"})]},ue.id))}),F.iterations.length===0&&!P&&t.jsx("div",{className:"text-gray-500 text-sm text-center py-4",children:"No iteration data available"}),P&&t.jsxs("div",{className:"flex items-center space-x-2 text-gray-400 text-sm py-2",children:[t.jsx("div",{className:"animate-spin w-3 h-3 border-2 border-gray-400 border-t-transparent rounded-full"}),t.jsx("span",{children:"Loading events..."})]}),V&&t.jsxs("div",{className:"text-sm text-red-400 py-2",children:["Failed to load events: ",V]}),!P&&!V&&Le.length>0&&b===F.id&&t.jsxs("div",{children:[t.jsxs("div",{className:"text-xs font-medium text-gray-500 uppercase tracking-wide mb-2",children:["Event Log (",Le.length,")"]}),t.jsx("div",{className:"space-y-1 max-h-80 overflow-y-auto",children:Array.from(ve.entries()).map(([ue,Oe])=>t.jsxs("div",{className:"border border-gray-700/50 rounded",children:[t.jsxs("button",{onClick:()=>L(ue),className:"w-full px-3 py-2 flex items-center gap-2 text-sm text-left bg-gray-800/30 hover:bg-gray-800/60 transition-colors",children:[t.jsx("svg",{className:`w-3 h-3 text-gray-500 transition-transform ${U.has(ue)?"rotate-90":""}`,fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{d:"M6 4l8 6-8 6V4z"})}),t.jsxs("span",{className:"text-cyan-400 font-medium",children:["Iteration ",ue||"?"]}),t.jsxs("span",{className:"text-gray-500 text-xs",children:[Oe.filter(Se=>Se.event_type==="tool_use").length," tool calls"]})]}),U.has(ue)&&t.jsx("div",{className:"px-3 py-1 space-y-0.5",children:Oe.filter(Se=>Se.event_type!=="iteration_start"&&Se.event_type!=="iteration_complete").map(Se=>{const We=G(Se.event_type),qe=R.has(Se.id),tt=Se.event_type==="tool_use"||Se.event_type==="tool_result"||Se.event_type==="content"||Se.event_type==="error";return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>tt&&q(Se.id),className:`w-full text-left flex items-center gap-2 py-1 text-xs ${tt?"cursor-pointer hover:bg-gray-800/40":"cursor-default"} rounded px-1`,children:[t.jsx("span",{className:We.color,children:re(Se)}),Se.content&&!qe&&t.jsx("span",{className:"text-gray-600 truncate flex-1",children:Se.content.slice(0,80)}),tt&&t.jsx("svg",{className:`w-3 h-3 text-gray-600 transition-transform flex-shrink-0 ${qe?"rotate-90":""}`,fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{d:"M6 4l8 6-8 6V4z"})})]}),qe&&t.jsxs("div",{className:"ml-5 mb-1",children:[Se.event_type==="tool_use"&&Se.tool_input&&t.jsx("pre",{className:"text-xs text-gray-400 bg-gray-800/50 rounded p-2 max-h-40 overflow-auto whitespace-pre-wrap break-all",children:S(Se.tool_input)}),Se.event_type==="tool_result"&&Se.tool_result&&t.jsx("pre",{className:"text-xs text-gray-400 bg-gray-800/50 rounded p-2 max-h-40 overflow-auto whitespace-pre-wrap break-all",children:Se.tool_result.length>2e3?Se.tool_result.slice(0,2e3)+"...":Se.tool_result}),Se.event_type==="content"&&Se.content&&t.jsx("div",{className:"text-xs text-gray-300 bg-gray-800/50 rounded p-2 max-h-40 overflow-auto prose prose-invert prose-xs max-w-none",children:t.jsx(Ty,{children:Se.content})}),Se.event_type==="error"&&t.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 rounded p-2",children:Se.content||Se.event_data||"Unknown error"})]})]},Se.id)})})]},ue))})]}),!P&&!V&&Le.length===0&&F.iterations.length>0&&b===F.id&&t.jsx("div",{className:"text-gray-500 text-xs text-center py-2",children:"No events recorded"})]}),F.is_legacy&&N&&t.jsxs("div",{className:"flex items-center space-x-2 text-gray-400 py-4",children:[t.jsx("div",{className:"animate-spin w-4 h-4 border-2 border-gray-400 border-t-transparent rounded-full"}),t.jsx("span",{children:"Loading messages..."})]}),F.is_legacy&&k&&t.jsxs("div",{className:"space-y-3 max-h-96 overflow-y-auto",children:[k.messages.map((ue,Oe)=>{const Se=A.has(Oe),We=ue.content.length>500;return t.jsxs("div",{className:`p-3 rounded-lg ${ue.role==="user"?"bg-primary-900/30 border border-primary-800":"bg-gray-800/50 border border-gray-700"}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx("span",{className:`text-xs font-medium ${ue.role==="user"?"text-primary-400":"text-gray-400"}`,children:ue.role==="user"?"You":"Claude"}),ue.timestamp&&t.jsx("span",{className:"text-gray-600 text-xs",children:E(ue.timestamp)})]}),t.jsx("p",{className:"text-gray-300 text-sm whitespace-pre-wrap",children:We&&!Se?ue.content.slice(0,500)+"...":ue.content}),We&&t.jsx("button",{onClick:()=>{M(qe=>{const tt=new Set(qe);return Se?tt.delete(Oe):tt.add(Oe),tt})},className:"text-xs text-primary-400 hover:text-primary-300 mt-1",children:Se?"Show less":`Show more (${(ue.content.length-500).toLocaleString()} more chars)`})]},Oe)}),k.messages.length===0&&t.jsx("div",{className:"text-gray-500 text-sm text-center py-4",children:"No messages in this session"})]})]})]},F.id))}),I&&t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-4",onClick:()=>H(null),children:t.jsxs("div",{className:"bg-gray-800 rounded-lg w-full max-w-3xl max-h-[80vh] flex flex-col",onClick:F=>F.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[t.jsxs("div",{children:[t.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Iteration ",I.iteration_number," Diff"]}),t.jsxs("p",{className:"text-sm text-gray-400 mt-0.5",children:[I.chars_added>0&&t.jsxs("span",{className:"text-green-400 mr-2",children:["+",I.chars_added," chars"]}),I.chars_removed>0&&t.jsxs("span",{className:"text-red-400",children:["-",I.chars_removed," chars"]})]})]}),t.jsx("button",{onClick:()=>H(null),className:"text-gray-400 hover:text-white",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsx("div",{className:"flex-1 overflow-auto p-4",children:I.diff_lines.length>0?t.jsx("pre",{className:"text-xs font-mono leading-relaxed",children:I.diff_lines.map((F,he)=>t.jsx("div",{className:`px-2 py-0.5 ${ge(F.type)}`,children:F.line},he))}):t.jsx("div",{className:"text-gray-500 text-center py-8",children:I.diff_text===null?"Diff not recorded for this iteration. Future iterations include diffs automatically.":"No changes in this iteration"})})]})})]})}function OL({projectSlug:e,workflowId:r,stepId:s,onComplete:a}){const[o,c]=y.useState(""),[d,u]=y.useState(3),[h,p]=y.useState(null),[x,g]=y.useState(!1),[b,v]=y.useState(0),[k,T]=y.useState(0),[N,j]=y.useState([]),[A,M]=y.useState([]),[_,z]=y.useState(null),[P,$]=y.useState(null),[V,B]=y.useState(0),[U,D]=y.useState(""),[R,X]=y.useState(!1),[I,H]=y.useState(!1),[W,J]=y.useState(null),[Z,de]=y.useState(!1),[E,L]=y.useState("diff"),[q,S]=y.useState(null),[G,re]=y.useState(!1),ee=y.useRef(!1),ge=y.useRef(0),je=y.useRef(null),Le=y.useRef(0),ve=y.useRef(null),F=y.useRef(0),he=y.useRef(!0),ue=y.useRef(0),Oe=y.useRef(null),Se=5,We=y.useCallback(()=>{Oe.current&&(clearTimeout(Oe.current),Oe.current=null)},[]),qe=y.useCallback(()=>{We(),Oe.current=setTimeout(async()=>{if(he.current)try{(await Wo(e,r)).find(be=>be.run_status==="running")||(je.current&&(je.current.close(),je.current=null),g(!1),H(!1),B(be=>be+1))}catch{}},9e4)},[e,r,We]);y.useEffect(()=>{const Q=[...A].reverse().find(fe=>fe.id);!(Q!=null&&Q.id)||!h||(re(!0),Fd(e,r,h.id,Q.id).then(fe=>{S(fe),ee.current||L("diff")}).catch(()=>{}).finally(()=>re(!1)))},[A,h,e,r]);const tt=y.useCallback((Q,fe)=>{je.current&&je.current.close();const be=u1(e,r,Q,fe);je.current=be,be.onmessage=Me=>{try{const Ve=JSON.parse(Me.data);if(Ve.type==="heartbeat")return;console.log("[SSE]",Ve.type,Ve),ue.current=0,Ve._event_id&&(F.current=Ve._event_id),$t(Ve),qe()}catch{}},qe(),be.onerror=()=>{if(be.close(),je.current=null,ue.current+=1,ue.current>Se){g(!1),H(!1),z("Lost connection to server after multiple retries"),B(Me=>Me+1);return}setTimeout(async()=>{if(he.current)try{const Me=await Wo(e,r);if(!he.current)return;const Ve=Me.find(Ye=>Ye.run_status==="running");Ve?tt(Ve.id,F.current):(g(!1),H(!1),B(Ye=>Ye+1))}catch{if(!he.current)return;g(!1),H(!1)}},2e3)}},[e,r,qe]),ft=y.useCallback(async()=>{var Q;try{const fe=await lp(e,r);(Q=fe==null?void 0:fe.artifacts)!=null&&Q.design_doc&&$(fe.artifacts.design_doc)}catch{}try{const be=(await Wo(e,r)).find(Me=>Me.run_status==="running");if(be){const Me=be.current_iteration??0;p({id:be.id,workflow_id:r,step_id:be.step_id,prompt:be.prompt||"",iterations_requested:be.iterations_requested,iterations_completed:be.iterations_completed,current_iteration:Me,run_status:"running",is_legacy:!1,status:"active",created_at:be.created_at,updated_at:be.updated_at}),g(!0),T(be.iterations_requested),v(Me),Le.current=Me;const Ve=be.iterations.filter(Ye=>Ye.status==="completed").map(Ye=>({id:Ye.id,iteration:Ye.iteration_number,summary:Ye.summary||"Updated design document",chars_added:Ye.chars_added,chars_removed:Ye.chars_removed}));M(Ve);try{const Ye=await sx(e,r,be.id);Ye.length>0&&(F.current=Ye[Ye.length-1].id)}catch{}tt(be.id,F.current)}}catch{}},[e,r,tt]);y.useEffect(()=>{ft()},[ft]),y.useEffect(()=>(he.current=!0,()=>{he.current=!1,Oe.current&&clearTimeout(Oe.current),je.current&&je.current.close()}),[]),y.useEffect(()=>{ve.current&&(ve.current.scrollTop=ve.current.scrollHeight)},[U]);const Rt=async()=>{if(!(!o.trim()||I)){H(!0),z(null),j([]),M([]),D(""),S(null),ee.current=!1;try{const Q=await d1(e,r,o.trim(),d);p(Q),g(!0),T(d),v(0),F.current=0,ue.current=0,tt(Q.id,0)}catch(Q){z(Q instanceof Error?Q.message:"Failed to start iterations"),g(!1),H(!1)}}},$t=Q=>{switch(Q.type){case"iteration_start":Le.current=Q.iteration||0,v(Q.iteration||0),T(Q.total||0),j([]),D("");break;case"content":Q.text&&D(fe=>fe+Q.text);break;case"tool_use":j(fe=>[...fe,{id:++ge.current,tool:Q.tool||"unknown",input:Q.input,status:"running"}]);break;case"tool_result":j(fe=>fe.map(be=>be.status==="running"&&be.tool===Q.tool?{...be,result:Q.result,status:"completed"}:be));break;case"design_doc_updated":lp(e,r).then(fe=>{var be;(be=fe==null?void 0:fe.artifacts)!=null&&be.design_doc&&$(fe.artifacts.design_doc)}).catch(()=>{}),M(fe=>{const be=fe[fe.length-1];return be&&be.iteration===Le.current?[...fe.slice(0,-1),{...be,chars_added:Q.chars_added||0,chars_removed:Q.chars_removed||0}]:fe});break;case"iteration_complete":M(fe=>[...fe,{id:Q.iteration_id,iteration:Q.iteration||Le.current,summary:Q.summary||"Updated design document",chars_added:0,chars_removed:0}]);break;case"error":Q.fatal&&(We(),z(Q.message||"Execution failed"),g(!1),H(!1));break;case"cancelled":We(),g(!1),H(!1),B(fe=>fe+1);break;case"done":We(),g(!1),H(!1),ft(),B(fe=>fe+1);break}},Zt=async()=>{if(h){try{await m1(e,r,h.id)}catch{}je.current&&(je.current.close(),je.current=null),g(!1),H(!1)}},ar=async()=>{if(!(!P||R)){X(!0);try{await l1(e,r,{design_doc:P}),a()}catch(Q){z(Q instanceof Error?Q.message:"Failed to complete step")}finally{X(!1)}}},er=async Q=>{if(!(!Q.id||!h)){de(!0);try{const fe=await Fd(e,r,h.id,Q.id);J(fe)}catch{J({iteration_id:Q.id,iteration_number:Q.iteration,diff_text:null,chars_added:0,chars_removed:0,diff_lines:[]})}finally{de(!1)}}},Et=Q=>{switch(Q){case"add":return"bg-green-900/30 text-green-300";case"remove":return"bg-red-900/30 text-red-300";case"hunk":return"bg-blue-900/30 text-blue-300";default:return"text-gray-400"}},ae=k>0?Math.round(A.length/k*100):0;return t.jsxs("div",{className:"planning-iteration-panel",style:{display:"flex",gap:"1.5rem"},children:[t.jsxs("div",{style:{flex:"0 0 400px",display:"flex",flexDirection:"column",gap:"1rem",overflow:"hidden"},children:[t.jsxs("div",{className:"card",style:{padding:"1rem"},children:[t.jsx("h3",{style:{margin:"0 0 0.75rem",fontSize:"0.95rem",fontWeight:600},children:"What should Claude focus on?"}),t.jsx("textarea",{value:o,onChange:Q=>c(Q.target.value),placeholder:"Describe the design document you want to create or refine. E.g., 'Research authentication approaches and create a design doc for a JWT-based auth system with refresh tokens.'",disabled:x,style:{width:"100%",minHeight:"120px",padding:"0.75rem",borderRadius:"6px",border:"1px solid var(--border-color, #ddd)",fontFamily:"inherit",fontSize:"0.875rem",resize:"vertical",boxSizing:"border-box"}}),t.jsxs("div",{style:{margin:"0.75rem 0",display:"flex",alignItems:"center",gap:"0.75rem"},children:[t.jsx("label",{style:{fontSize:"0.85rem",fontWeight:500,whiteSpace:"nowrap"},children:"Iterations:"}),t.jsx("input",{type:"range",min:1,max:10,value:d,onChange:Q=>u(parseInt(Q.target.value)),disabled:x,style:{flex:1}}),t.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600,minWidth:"20px",textAlign:"center"},children:d})]}),t.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-muted, #888)",marginBottom:"0.75rem"},children:d===1?"Quick single pass":d<=3?"Good for focused refinement":d<=6?"Thorough research and iteration":"Comprehensive deep dive"}),t.jsx("button",{onClick:Rt,disabled:!o.trim()||x||I,className:"btn btn-primary",style:{width:"100%"},children:I?"Starting...":x?"Running...":`Run ${d} Iteration${d!==1?"s":""}`})]}),x&&t.jsxs("div",{className:"card",style:{padding:"1rem"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.5rem"},children:[t.jsxs("span",{style:{fontSize:"0.85rem",fontWeight:600},children:["Iteration ",b," of ",k]}),t.jsx("button",{onClick:Zt,className:"btn btn-sm",style:{fontSize:"0.75rem",padding:"0.25rem 0.5rem",background:"var(--danger-bg, #fee)",color:"var(--danger-color, #c00)",border:"1px solid var(--danger-border, #fcc)",borderRadius:"4px",cursor:"pointer"},children:"Cancel"})]}),t.jsx("div",{style:{height:"6px",background:"var(--bg-secondary, #f0f0f0)",borderRadius:"3px",overflow:"hidden",marginBottom:"0.75rem"},children:t.jsx("div",{style:{height:"100%",width:`${ae}%`,background:"var(--primary-color, #0066cc)",borderRadius:"3px",transition:"width 0.3s ease"}})}),N.length>0&&t.jsxs("div",{style:{marginBottom:"0.5rem"},children:[t.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,marginBottom:"0.25rem",color:"var(--text-muted, #888)"},children:"Tool Activity"}),t.jsx("div",{style:{maxHeight:"150px",overflow:"auto"},children:N.map(Q=>t.jsxs("div",{style:{fontSize:"0.75rem",padding:"0.2rem 0",display:"flex",alignItems:"center",gap:"0.5rem"},children:[t.jsx("span",{children:Q.status==="completed"?"✓":"●"}),t.jsx("span",{style:{fontWeight:500},children:Q.tool}),Q.input&&t.jsx("span",{style:{color:"var(--text-muted, #888)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:typeof Q.input=="object"?JSON.stringify(Q.input).slice(0,60):String(Q.input).slice(0,60)})]},Q.id))})]}),U&&t.jsxs("div",{style:{marginBottom:"0.5rem"},children:[t.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,marginBottom:"0.25rem",color:"var(--text-muted, #888)"},children:"Claude Response"}),t.jsx("div",{ref:ve,className:"prose prose-invert prose-xs max-w-none",style:{maxHeight:"200px",overflow:"auto",padding:"0.5rem",background:"var(--bg-secondary, #1e2028)",color:"var(--text-primary, #e0e0e0)",borderRadius:"4px",fontSize:"0.75rem",lineHeight:1.5},children:t.jsx(Ty,{children:U})})]}),A.length>0&&t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,marginBottom:"0.25rem",color:"var(--text-muted, #888)"},children:"Completed"}),A.map(Q=>t.jsxs("div",{style:{fontSize:"0.75rem",padding:"0.2rem 0",display:"flex",alignItems:"center",gap:"0.5rem"},children:[t.jsx("span",{style:{color:"green"},children:"✓"}),t.jsxs("span",{children:["Iteration ",Q.iteration]}),Q.chars_added>0&&t.jsxs("span",{style:{color:"green"},children:["+",Q.chars_added]}),Q.chars_removed>0&&t.jsxs("span",{style:{color:"red"},children:["-",Q.chars_removed]}),Q.id&&t.jsx("button",{onClick:()=>er(Q),disabled:Z,style:{fontSize:"0.7rem",padding:"0.1rem 0.4rem",background:"var(--bg-secondary, #2a2a3a)",color:"var(--text-muted, #888)",border:"1px solid var(--border-color, #444)",borderRadius:"3px",cursor:"pointer",marginLeft:"auto"},children:"View Diff"})]},Q.iteration))]})]}),_&&t.jsx("div",{className:"card",style:{padding:"0.75rem",background:"var(--danger-bg, #fee)",border:"1px solid var(--danger-border, #fcc)",color:"var(--danger-color, #c00)",fontSize:"0.85rem"},children:_}),P&&!x&&t.jsx("button",{onClick:ar,disabled:R||x,className:"btn btn-success",style:{width:"100%"},children:R?"Completing...":"Complete Planning Step"}),t.jsx(Ay,{projectSlug:e,workflowId:r,stepId:s,refreshKey:V,onClonePrompt:(Q,fe)=>{o.trim()&&!confirm("Replace current prompt?")||(c(Q),u(Math.max(1,fe||3)))},cloneDisabled:x})]}),t.jsx("div",{style:{flex:1,minWidth:0},children:t.jsxs("div",{className:"card",style:{padding:"1rem",height:"100%",display:"flex",flexDirection:"column"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"0.75rem"},children:[t.jsx("h3",{style:{margin:0,fontSize:"0.95rem",fontWeight:600},children:"Design Document"}),P&&t.jsxs("div",{style:{display:"flex",gap:"2px",background:"var(--bg-secondary, #1e2028)",borderRadius:"6px",padding:"2px"},children:[t.jsx("button",{onClick:()=>{ee.current=!0,L("diff")},style:{padding:"0.25rem 0.6rem",fontSize:"0.75rem",fontWeight:500,borderRadius:"4px",border:"none",cursor:"pointer",background:E==="diff"?"var(--primary-color, #0891b2)":"transparent",color:E==="diff"?"#fff":"var(--text-muted, #888)"},children:"Latest Changes"}),t.jsx("button",{onClick:()=>{ee.current=!0,L("full")},style:{padding:"0.25rem 0.6rem",fontSize:"0.75rem",fontWeight:500,borderRadius:"4px",border:"none",cursor:"pointer",background:E==="full"?"var(--primary-color, #0891b2)":"transparent",color:E==="full"?"#fff":"var(--text-muted, #888)"},children:"Full Document"})]})]}),P?E==="diff"?t.jsx("div",{style:{flex:1,overflow:"auto"},children:G?t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"2rem",color:"var(--text-muted, #888)"},children:[t.jsx("div",{className:"animate-spin",style:{width:"16px",height:"16px",border:"2px solid var(--text-muted, #888)",borderTopColor:"transparent",borderRadius:"50%",marginRight:"0.5rem"}}),"Loading diff..."]}):q&&q.diff_lines.length>0?t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",marginBottom:"0.5rem",fontSize:"0.75rem"},children:[t.jsxs("span",{style:{color:"var(--text-muted, #888)"},children:["Iteration ",q.iteration_number]}),q.chars_added>0&&t.jsxs("span",{style:{color:"#4ade80"},children:["+",q.chars_added," chars"]}),q.chars_removed>0&&t.jsxs("span",{style:{color:"#f87171"},children:["-",q.chars_removed," chars"]})]}),t.jsx("div",{style:{background:"var(--bg-secondary, #1e2028)",borderRadius:"6px",overflow:"hidden"},children:t.jsx("pre",{style:{margin:0,fontSize:"0.75rem",fontFamily:"monospace",lineHeight:1.6},children:q.diff_lines.map((Q,fe)=>t.jsx("div",{className:`px-3 py-0.5 ${Et(Q.type)}`,children:Q.line},fe))})})]}):q&&q.diff_text===null?t.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted, #888)",fontSize:"0.85rem",fontStyle:"italic"},children:"Diff not recorded for this iteration. Future iterations include diffs automatically."}):t.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted, #888)",fontSize:"0.85rem",fontStyle:"italic"},children:"No changes yet. Run iterations to see a diff."})}):t.jsx("div",{style:{flex:1,overflow:"auto",padding:"0.75rem",background:"var(--bg-secondary, #f8f9fa)",borderRadius:"6px",fontFamily:"monospace",fontSize:"0.8rem",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:P}):t.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted, #888)",fontSize:"0.9rem",fontStyle:"italic"},children:"No design document yet. Enter a prompt and run iterations to create one."})]})}),W&&t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-4",onClick:()=>J(null),children:t.jsxs("div",{className:"bg-gray-800 rounded-lg w-full max-w-3xl max-h-[80vh] flex flex-col",onClick:Q=>Q.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[t.jsxs("div",{children:[t.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Iteration ",W.iteration_number," Diff"]}),t.jsxs("p",{className:"text-sm text-gray-400 mt-0.5",children:[W.chars_added>0&&t.jsxs("span",{className:"text-green-400 mr-2",children:["+",W.chars_added," chars"]}),W.chars_removed>0&&t.jsxs("span",{className:"text-red-400",children:["-",W.chars_removed," chars"]})]})]}),t.jsx("button",{onClick:()=>J(null),className:"text-gray-400 hover:text-white",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsx("div",{className:"flex-1 overflow-auto p-4",children:W.diff_lines.length>0?t.jsx("pre",{className:"text-xs font-mono leading-relaxed",children:W.diff_lines.map((Q,fe)=>t.jsx("div",{className:`px-2 py-0.5 ${Et(Q.type)}`,children:Q.line},fe))}):t.jsx("div",{className:"text-gray-500 text-center py-8",children:W.diff_text===null?"Diff not recorded for this iteration. Future iterations include diffs automatically.":"No changes in this iteration"})})]})})]})}let FL=0;function WL(){return Date.now()*1e3+FL++%1e3}function HL({projectSlug:e,loopName:r,enabled:s=!0,pollInterval:a=5e3}){const[o,c]=y.useState({}),[d,u]=y.useState(!0),[h,p]=y.useState(null),x=y.useRef(null),g=y.useRef({runId:null,iteration:null}),b=y.useCallback(async()=>{if(s)try{const N=await fetch(`/api/projects/${e}/loops/${r}/events/grouped`);if(!N.ok)throw new Error(`Failed to fetch events: ${N.statusText}`);const A=(await N.json()).runs||{};c(M=>{const _={...A};for(const[z,P]of Object.entries(M))for(const[$,V]of Object.entries(P.iterations)){if(!V.is_live)continue;const B=_[z];if(!B)continue;const U=B.iterations[Number($)];if(!U){B.iterations[Number($)]=V;continue}const D=new Set(U.events.map(X=>X.id)),R=V.events.filter(X=>!D.has(X.id)&&X.id>1e12);R.length>0&&(U.events=[...U.events,...R]),V.is_live&&(U.is_live=!0)}return _});for(const[M,_]of Object.entries(A))if(_.status==="running"||_.status==="paused"){g.current.runId=M;const z=Object.keys(_.iterations).map(Number);z.length>0&&(g.current.iteration=Math.max(...z));break}p(null)}catch(N){p(N instanceof Error?N.message:"Failed to load events")}finally{u(!1)}},[e,r,s]),v=y.useCallback(N=>{const{type:j,data:A}=N;if(["heartbeat","connected","disconnected","info"].includes(j))return;const M=A.run_id,_=A.iteration;if((!M||_===void 0)&&(!g.current.runId||!g.current.iteration))return;const z=M||g.current.runId,P=_??g.current.iteration;g.current.runId=z,g.current.iteration=P;const $={id:WL(),session_id:A.session_id||"",event_type:j,timestamp:new Date().toISOString(),content:A.content,tool_name:A.name,tool_input:A.input,tool_result:A.result,error_message:A.message};c(V=>{const B={...V};return B[z]||(B[z]={status:"running",loop_name:r,started_at:null,completed_at:null,iterations_completed:0,items_generated:0,iterations:{}}),B[z].iterations[P]||(B[z].iterations[P]={session_id:A.session_id||"",mode:null,status:"active",is_live:!0,events:[]}),B[z].iterations[P].events=[...B[z].iterations[P].events,$],B[z].iterations[P].is_live=!0,j==="status"&&(B[z].status=A.status||B[z].status,g.current.iteration=A.iteration||P),j==="complete"&&(B[z].iterations[P].is_live=!1,B[z].iterations[P].status="completed"),B})},[r]),k=s?`/api/projects/${e}/loops/${r}/stream`:"",{isConnected:T}=tg({url:k,enabled:s&&!!k,onEvent:v,maxStoredEvents:0});return y.useEffect(()=>{b();const N=()=>{x.current=setTimeout(()=>{b(),N()},a)};return N(),()=>{x.current&&clearTimeout(x.current)}},[b,a]),{runs:o,loading:d,error:h,isConnected:T,refresh:b}}function UL(e){let r=0;for(const s of Object.values(e))for(const a of Object.values(s.iterations))r+=a.events.length;return r}function VL(e){let r=0;for(const s of Object.values(e.iterations))r+=s.events.length;return r}function Rf({projectSlug:e,loopName:r,enabled:s=!0}){const{runs:a,loading:o,error:c,isConnected:d,refresh:u}=HL({projectSlug:e,loopName:r,enabled:s}),[h,p]=y.useState(new Set),[x,g]=y.useState(new Set),[b,v]=y.useState(new Set),k=y.useRef(null),T=y.useRef(!1),N=y.useRef(!1),j=y.useRef(0);y.useEffect(()=>{if(T.current||Object.keys(a).length===0)return;T.current=!0;const B=new Set,U=new Set,D=Object.entries(a).sort(([,R],[,X])=>{const I=R.started_at?new Date(R.started_at).getTime():0,H=X.started_at?new Date(X.started_at).getTime():0;return I-H});for(let R=D.length-1;R>=0;R--){const[X,I]=D[R];if(I.status==="running"||I.status==="paused"){B.add(X),Object.entries(I.iterations).forEach(([H,W])=>{W.is_live&&U.add(`${X}-${H}`)});break}}p(B),g(U)},[a]);const A=y.useCallback(()=>{if(!k.current)return;const{scrollTop:B,scrollHeight:U,clientHeight:D}=k.current,R=U-B-D<50;N.current=!R,j.current=B},[]);y.useEffect(()=>{!k.current||N.current||(k.current.scrollTop=k.current.scrollHeight)},[a]);const M=y.useCallback(B=>{p(U=>{const D=new Set(U);return D.has(B)?D.delete(B):D.add(B),D})},[]),_=y.useCallback((B,U)=>{const D=`${B}-${U}`;g(R=>{const X=new Set(R);return X.has(D)?X.delete(D):X.add(D),X})},[]),z=y.useCallback(B=>{v(U=>{const D=new Set(U);return D.has(B)?D.delete(B):D.add(B),D})},[]),P=y.useCallback(()=>{const B=new Set(Object.keys(a)),U=new Set;Object.entries(a).forEach(([D,R])=>{Object.keys(R.iterations).forEach(X=>{U.add(`${D}-${X}`)})}),p(B),g(U)},[a]),$=y.useCallback(()=>{p(new Set),g(new Set),v(new Set)},[]);if(c)return t.jsxs("div",{className:"card-panel p-6",children:[t.jsxs("div",{className:"flex items-center gap-3 text-[var(--color-rose)]",children:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{className:"font-medium",children:c})]}),t.jsx("button",{onClick:u,className:"mt-4 btn-secondary",children:"Retry"})]});const V=Object.entries(a).sort(([,B],[,U])=>{const D=B.started_at?new Date(B.started_at).getTime():0,R=U.started_at?new Date(U.started_at).getTime():0;return D-R});return t.jsxs("div",{className:"card-panel overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-[var(--color-border)] bg-[var(--color-surface)]/50",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 rounded-lg bg-[var(--color-violet)]/20 flex items-center justify-center",children:t.jsx("svg",{className:"w-4 h-4 text-[var(--color-violet)]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold text-[var(--color-text-primary)]",children:"Session Log"}),t.jsx("div",{className:"flex items-center gap-2 text-xs",children:d?t.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--color-emerald)]",children:[t.jsx("span",{className:"status-dot status-dot-running"}),"Live"]}):t.jsx("span",{className:"text-[var(--color-text-muted)]",children:"Disconnected"})})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.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:"Expand All"}),t.jsx("button",{onClick:$,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"})]})]}),t.jsx("div",{ref:k,onScroll:A,className:"max-h-[500px] overflow-y-auto custom-scrollbar",children:o?t.jsxs("div",{className:"flex items-center justify-center py-12 text-[var(--color-text-muted)]",children:[t.jsxs("svg",{className:"w-5 h-5 animate-spin mr-3",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.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?t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-[var(--color-text-muted)]",children:[t.jsx("div",{className:"w-12 h-12 rounded-full bg-[var(--color-elevated)] flex items-center justify-center mb-3",children:t.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.jsx("p",{className:"font-medium",children:"No session history yet"}),t.jsx("p",{className:"text-sm mt-1",children:"Events will appear here when the step runs"})]}):t.jsx("div",{className:"p-3 space-y-1",children:V.map(([B,U],D)=>t.jsx(YL,{runId:B,run:U,isExpanded:h.has(B),expandedIterations:x,expandedEvents:b,onToggleRun:M,onToggleIteration:_,onToggleEvent:z,index:D},B))})}),t.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:[t.jsx("span",{className:"text-[var(--color-cyan)]",children:UL(a)})," events across"," ",t.jsx("span",{className:"text-[var(--color-cyan)]",children:Object.keys(a).length})," runs"]})]})}function qL(e){const r=e.match(/_step(\d+)$/);return r?parseInt(r[1],10):null}function YL({runId:e,run:r,isExpanded:s,expandedIterations:a,expandedEvents:o,onToggleRun:c,onToggleIteration:d,onToggleEvent:u,index:h}){const p=VL(r),x=qL(r.loop_name),g=r.completed_at||r.started_at,b=z1(g),v=()=>{switch(r.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";case"error":return"status-dot-aborted";default:return""}},k=()=>{switch(r.status){case"running":return"badge-running";case"paused":return"badge-pending";case"completed":return"badge-completed";case"aborted":return"badge-aborted";case"error":return"badge-aborted";default:return"badge-pending"}},T=Object.entries(r.iterations).map(([N,j])=>[parseInt(N,10),j]).sort(([N],[j])=>N-j);return t.jsxs("div",{className:`animate-fade-in-up stagger-${Math.min(h+1,5)}`,style:{opacity:0},children:[t.jsxs("button",{onClick:()=>c(e),className:"flex items-center gap-3 w-full py-2.5 px-3 hover:bg-[var(--color-elevated)] rounded-lg transition-colors group",children:[t.jsx("svg",{className:`w-4 h-4 text-[var(--color-text-muted)] transition-transform duration-200 ${s?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),t.jsx("span",{className:`status-dot ${v()}`}),t.jsxs("span",{className:"font-mono text-sm text-[var(--color-text-primary)]",children:["Run #",h+1]}),x&&t.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 ",x]}),t.jsx("span",{className:`badge ${k()} ml-1`,children:r.status}),t.jsxs("span",{className:"ml-auto flex items-center gap-3 font-mono text-xs text-[var(--color-text-muted)]",children:[b&&t.jsx("span",{title:"Last update",children:b}),t.jsxs("span",{className:"text-[var(--color-text-muted)]/60",children:[p," events"]})]})]}),t.jsx("div",{className:`overflow-hidden transition-all duration-300 ${s?"max-h-[3000px] opacity-100":"max-h-0 opacity-0"}`,children:t.jsxs("div",{className:"ml-4 pl-4 border-l-2 border-[var(--color-border)] space-y-0.5",children:[(r.status==="aborted"||r.status==="error")&&r.error_message&&t.jsxs("div",{className:`flex items-start gap-2 px-3 py-2 rounded-lg text-xs font-mono mb-2 ${r.status==="error"?"bg-red-500/10 border border-red-500/20 text-red-400":"bg-amber-500/10 border border-amber-500/20 text-amber-400"}`,children:[t.jsx("svg",{className:"w-3.5 h-3.5 mt-0.5 shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{className:"break-all max-h-24 overflow-y-auto block",children:r.error_message})]}),t.jsxs("div",{className:"flex items-center gap-4 px-3 py-1.5 text-xs font-mono text-[var(--color-text-muted)]",children:[r.started_at&&r.completed_at&&t.jsx("span",{title:"Duration",children:(()=>{const N=new Date(r.completed_at).getTime()-new Date(r.started_at).getTime(),j=Math.floor(N/1e3);return j>=60?`${Math.floor(j/60)}m ${j%60}s`:`${j}s`})()}),t.jsxs("span",{children:[r.iterations_completed," iteration",r.iterations_completed!==1?"s":""]}),r.items_generated>0&&t.jsxs("span",{children:[r.items_generated," items"]})]}),T.map(([N,j])=>t.jsx(GL,{runId:e,iteration:N,data:j,isExpanded:a.has(`${e}-${N}`),expandedEvents:o,onToggle:()=>d(e,N),onToggleEvent:u},`${e}-${N}`))]})})]})}function GL({runId:e,iteration:r,data:s,isExpanded:a,expandedEvents:o,onToggle:c,onToggleEvent:d}){return t.jsxs("div",{children:[t.jsxs("button",{onClick:c,className:"flex items-center gap-2 w-full py-2 px-3 hover:bg-[var(--color-elevated)] rounded-md transition-colors",children:[t.jsx("svg",{className:`w-3.5 h-3.5 text-[var(--color-text-muted)] transition-transform duration-200 ${a?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),s.is_live?t.jsx("span",{className:"status-dot status-dot-running"}):t.jsx("svg",{className:"w-4 h-4 text-[var(--color-emerald)]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),t.jsxs("span",{className:"font-mono text-sm text-[var(--color-text-secondary)]",children:["Iteration ",t.jsx("span",{className:"text-[var(--color-text-primary)]",children:r})]}),s.mode&&t.jsxs("span",{className:"text-xs text-[var(--color-text-muted)]",children:["(",s.mode,")"]}),t.jsxs("span",{className:"ml-auto font-mono text-xs text-[var(--color-text-muted)]",children:[s.events.length," events"]})]}),t.jsx("div",{className:`overflow-hidden transition-all duration-200 ${a?"max-h-[2000px] opacity-100":"max-h-0 opacity-0"}`,children:t.jsx("div",{className:"ml-4 pl-4 border-l border-[var(--color-border)]/50 space-y-0.5 py-1",children:s.events.map((u,h)=>{const p=`${u.id}-${h}`;return t.jsx(KL,{event:u,isExpanded:o.has(u.id),isLive:s.is_live&&h===s.events.length-1,onToggle:()=>d(u.id)},p)})})})]})}const $f={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 KL({event:e,isExpanded:r,isLive:s,onToggle:a}){const o=$f[e.event_type]||$f.text,c=ZL(e,40),d=eE(e),u=y.useRef(null),h=B1(e.timestamp);return y.useEffect(()=>{r&&u.current&&setTimeout(()=>{var p;(p=u.current)==null||p.scrollIntoView({behavior:"smooth",block:"nearest"})},50)},[r]),t.jsxs("div",{children:[t.jsxs("button",{onClick:d?a:void 0,className:`flex items-center gap-2 w-full py-1.5 px-2 rounded text-sm transition-colors ${d?"hover:bg-[var(--color-elevated)] cursor-pointer":"cursor-default"}`,children:[d&&t.jsx("svg",{className:`w-3 h-3 text-[var(--color-text-muted)] transition-transform duration-200 ${r?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),!d&&t.jsx("span",{className:"w-3"}),t.jsx("span",{className:`w-5 h-5 rounded flex items-center justify-center text-xs ${o.bg}`,children:o.icon}),t.jsx("span",{className:`font-mono text-xs ${o.color} truncate flex-1 text-left`,children:e.tool_name||dl(c,35)}),t.jsx("span",{className:"font-mono text-xs text-[var(--color-text-muted)]",children:h}),s&&t.jsx("span",{className:"status-dot status-dot-running ml-1"})]}),d&&t.jsx("div",{ref:u,className:`overflow-hidden transition-all duration-200 ${r?"max-h-96 opacity-100":"max-h-0 opacity-0"}`,children:t.jsx("div",{className:"ml-8 mr-2 mb-2 p-3 bg-[var(--color-deep)] rounded-lg border border-[var(--color-border)]",children:t.jsx(XL,{event:e})})})]})}function QL({content:e}){const r=e.match(/```json\s*([\s\S]*?)```/);if(r){const s=e.slice(0,r.index).trim(),a=r[1].trim(),o=e.slice((r.index||0)+r[0].length).trim();let c=null;try{c=JSON.parse(a)}catch{}const d=c&&typeof c=="object"&&"stories"in c;return t.jsxs("div",{className:"space-y-3",children:[s&&t.jsx("p",{className:"text-sm text-[var(--color-text-secondary)]",children:s}),d?t.jsx(JL,{stories:c.stories}):c?t.jsx("div",{className:"p-3 bg-[var(--color-void)] rounded-lg border border-[var(--color-border)]",children:t.jsx("pre",{className:"text-xs font-mono text-[var(--color-text-secondary)] overflow-auto max-h-48 custom-scrollbar",children:JSON.stringify(c,null,2)})}):t.jsx("div",{className:"p-3 bg-[var(--color-void)] rounded-lg border border-[var(--color-border)]",children:t.jsx("pre",{className:"text-xs font-mono text-[var(--color-text-secondary)] overflow-auto max-h-48 custom-scrollbar whitespace-pre-wrap",children:a})}),o&&t.jsx("p",{className:"text-sm text-[var(--color-text-secondary)]",children:o})]})}return t.jsx("p",{className:"text-sm text-[var(--color-text-secondary)] whitespace-pre-wrap",children:e})}function JL({stories:e}){const[r,s]=y.useState(!1),a=r?e:e.slice(0,2),o=e.length>2;return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("span",{className:"text-xs font-mono text-[var(--color-emerald)] uppercase tracking-wider",children:[e.length," User ",e.length===1?"Story":"Stories"]}),o&&t.jsx("button",{onClick:()=>s(!r),className:"text-xs text-[var(--color-cyan)] hover:underline",children:r?"Show less":`Show all ${e.length}`})]}),t.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto custom-scrollbar",children:a.map((c,d)=>t.jsx("div",{className:"p-3 bg-[var(--color-void)] rounded-lg border border-[var(--color-border)]",children:t.jsxs("div",{className:"flex items-start gap-2",children:[c.id&&t.jsx("span",{className:"px-1.5 py-0.5 text-xs font-mono bg-[var(--color-cyan)]/20 text-[var(--color-cyan)] rounded",children:c.id}),t.jsxs("div",{className:"flex-1 min-w-0",children:[c.title&&t.jsx("div",{className:"font-medium text-sm text-[var(--color-text-primary)] mb-1",children:c.title}),c.content&&t.jsx("p",{className:"text-xs text-[var(--color-text-secondary)] line-clamp-2",children:c.content})]})]})},c.id||d))})]})}function XL({event:e}){const[r,s]=y.useState(!0);switch(e.event_type){case"text":return t.jsx(QL,{content:e.content||""});case"tool_call":return t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("span",{className:"font-mono text-sm font-semibold text-[var(--color-cyan)]",children:e.tool_name})}),e.tool_input&&t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>s(!r),className:"flex items-center gap-1 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] transition-colors",children:[t.jsx("svg",{className:`w-3 h-3 transition-transform ${r?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),r?"Hide":"Show"," Input"]}),r&&t.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(e.tool_input,null,2)})]})]});case"tool_result":return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"font-mono text-sm font-semibold text-[var(--color-emerald)]",children:[e.tool_name," → result"]}),t.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:dl(e.tool_result||"",1e3)})]});case"error":return t.jsx("div",{className:"text-[var(--color-rose)] text-sm font-mono",children:e.error_message||"Unknown error"});default:return t.jsx("pre",{className:"text-xs font-mono text-[var(--color-text-muted)] overflow-auto max-h-48 custom-scrollbar",children:JSON.stringify(e,null,2)})}}function ZL(e,r){return e.tool_name?e.tool_name:e.content?dl(e.content.replace(/\n/g," "),r):e.error_message?dl(e.error_message,r):e.event_type}function dl(e,r){return e?e.length<=r?e:e.slice(0,r)+"...":""}function eE(e){return!!(e.event_type==="text"&&e.content&&e.content.length>40||e.event_type==="tool_call"&&e.tool_input||e.event_type==="tool_result"&&e.tool_result||e.event_type==="error"&&e.error_message)}function tE({projectSlug:e,designDocPath:r,stepStatus:s,onLinkFile:a}){const[o,c]=y.useState(!0),[d,u]=y.useState(null),[h,p]=y.useState(null),[x,g]=y.useState(!0),[b,v]=y.useState([]),[k,T]=y.useState([]),[N,j]=y.useState(!1),[A,M]=y.useState(!1),[_,z]=y.useState(!1),[P,$]=y.useState(null),[V,B]=y.useState(""),[U,D]=y.useState("current"),[R,X]=y.useState(!1),I=y.useCallback(async()=>{if(!r){c(!1);return}try{c(!0),u(null);const[E,L]=await Promise.all([Nb(e,r).catch(()=>null),Sb(e,r).catch(()=>[])]);E?(p(E),g(!0)):g(!1),v(L)}catch(E){u(E instanceof Error?E.message:"Failed to load file info")}finally{c(!1)}},[e,r]),H=y.useCallback(async()=>{try{const E=await Xf(e);T(E)}catch(E){console.error("Failed to load available files:",E)}},[e]);y.useEffect(()=>{I()},[I]),y.useEffect(()=>{r||H()},[r,H]);const W=async()=>{if(!(!r||!V)){X(!0);try{const E=await _b(e,r,V,U);$(E)}catch(E){u(E instanceof Error?E.message:"Failed to generate diff")}finally{X(!1)}}},J=async E=>{if(r)try{await Lb(e,r,E),I()}catch(L){u(L instanceof Error?L.message:"Failed to restore backup")}},Z=E=>E<1024?`${E} B`:`${(E/1024).toFixed(1)} KB`,de=E=>{if(!E)return"Unknown";const L=new Date(E);return isNaN(L.getTime())?"Unknown":L.toLocaleString()};return o?t.jsx("div",{className:"card mb-4",children:t.jsxs("div",{className:"flex items-center space-x-2 text-gray-400",children:[t.jsx("div",{className:"animate-spin w-4 h-4 border-2 border-gray-400 border-t-transparent rounded-full"}),t.jsx("span",{children:"Loading design document info..."})]})}):d&&!h&&r?t.jsx("div",{className:"card mb-4 border-red-800 bg-red-900/20",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"flex items-center space-x-2 text-red-400",children:t.jsxs("span",{children:["Error: ",d]})}),t.jsx("button",{onClick:I,className:"text-sm text-red-400 hover:text-red-300 underline",children:"Retry"})]})}):r?x?t.jsxs("div",{className:"card mb-4",children:[t.jsxs("h3",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[t.jsx("svg",{className:"w-5 h-5 text-primary-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),"Design Document"]}),t.jsxs("div",{className:"p-4 rounded-lg bg-gray-800/50 border border-gray-700",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-white font-medium",children:r}),t.jsxs("p",{className:"text-gray-400 text-sm mt-1",children:[Z((h==null?void 0:h.size)||0)," "," "," Last modified: ",de((h==null?void 0:h.modified)||"")]})]}),t.jsx("div",{className:"flex gap-2",children:t.jsx("button",{onClick:()=>j(!0),className:"px-3 py-1.5 bg-primary-600 text-white rounded text-sm hover:bg-primary-500 transition-colors",children:"View Document"})})]}),b.length>0&&t.jsxs("div",{className:"mt-4",children:[t.jsxs("p",{className:"text-gray-400 text-sm mb-2 flex items-center gap-2",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Version History (",b.length," backup",b.length!==1?"s":"",")"]}),t.jsxs("div",{className:"space-y-1 max-h-32 overflow-y-auto",children:[t.jsxs("div",{className:"flex items-center justify-between px-2 py-1 bg-green-900/20 rounded text-sm",children:[t.jsx("span",{className:"text-green-400",children:"Current"}),t.jsx("span",{className:"text-gray-400",children:Z((h==null?void 0:h.size)||0)}),t.jsx("span",{className:"text-gray-500",children:de((h==null?void 0:h.modified)||"")}),t.jsx("span",{className:"w-6"})]}),b.map((E,L)=>t.jsxs("div",{className:"flex items-center justify-between px-2 py-1 hover:bg-gray-700/50 rounded text-sm",children:[t.jsxs("span",{className:"text-gray-300",children:["Backup #",b.length-L]}),t.jsx("span",{className:"text-gray-400",children:Z(E.size)}),t.jsx("span",{className:"text-gray-500",children:de(E.created)}),t.jsx("button",{onClick:()=>{B(E.name),D("current"),M(!0)},className:"text-cyan-400 hover:text-cyan-300",title:"Compare with current",children:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})})})]},E.name))]}),t.jsx("button",{onClick:()=>M(!0),className:"mt-2 px-3 py-1.5 bg-gray-700 text-gray-300 rounded text-sm hover:bg-gray-600 transition-colors",children:"Compare Versions"})]})]}),N&&(h==null?void 0:h.content)&&t.jsx(rE,{content:h.content,fileName:r,onClose:()=>j(!1)}),A&&t.jsx(nE,{backups:b,currentSize:(h==null?void 0:h.size)||0,diffResult:P,diffLeft:V,diffRight:U,loadingDiff:R,onLeftChange:B,onRightChange:D,onCompare:W,onClose:()=>{M(!1),$(null)}})]}):t.jsxs("div",{className:"card mb-4",children:[t.jsxs("h3",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[t.jsx("svg",{className:"w-5 h-5 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),"Design Document"]}),t.jsxs("div",{className:"p-4 rounded-lg bg-red-900/20 border border-red-800",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("span",{className:"text-red-400 text-xl",children:t.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("p",{className:"text-red-300 font-medium",children:["File not found: ",r]}),t.jsx("p",{className:"text-red-400/70 text-sm mt-1",children:"The linked file no longer exists. It may have been deleted or moved."})]})]}),b.length>0&&t.jsxs("div",{className:"mt-4 flex gap-2 flex-wrap",children:[t.jsxs("select",{className:"px-3 py-2 bg-gray-800 border border-gray-700 rounded text-sm text-gray-200",onChange:E=>{E.target.value&&J(E.target.value)},defaultValue:"",children:[t.jsx("option",{value:"",disabled:!0,children:"Restore from backup..."}),b.map(E=>t.jsxs("option",{value:E.name,children:[E.name," (",Z(E.size),")"]},E.name))]}),t.jsx("button",{onClick:()=>{a==null||a(""),H(),z(!0)},className:"px-3 py-2 bg-gray-700 text-gray-300 rounded hover:bg-gray-600 text-sm",children:"Link Different File"})]})]})]}):t.jsxs("div",{className:"card mb-4",children:[t.jsxs("h3",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[t.jsx("svg",{className:"w-5 h-5 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),"Design Document"]}),t.jsxs("div",{className:"p-4 rounded-lg bg-yellow-900/20 border border-yellow-800",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("span",{className:"text-yellow-400 text-xl",children:t.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-yellow-300 font-medium",children:"No file linked"}),t.jsx("p",{className:"text-yellow-400/70 text-sm mt-1",children:"A new design document will be created when you complete this planning step."})]})]}),s==="pending"&&k.length>0&&t.jsxs("div",{className:"mt-4 relative",children:[t.jsxs("button",{onClick:()=>z(!_),className:"px-3 py-2 bg-yellow-600/30 text-yellow-300 rounded hover:bg-yellow-600/40 transition-colors text-sm flex items-center gap-1",children:["Link Existing File",t.jsx("svg",{className:`w-4 h-4 transition-transform ${_?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),_&&t.jsx("div",{className:"absolute top-full left-0 mt-1 w-64 bg-gray-800 border border-gray-700 rounded-lg shadow-xl z-10 max-h-48 overflow-y-auto",children:k.map(E=>t.jsxs("button",{onClick:()=>{a==null||a(E.name),z(!1)},className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-700 flex items-center gap-2",children:[t.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{className:"flex-1 truncate text-gray-200",children:E.name}),t.jsx("span",{className:"text-gray-500",children:Z(E.size)})]},E.path))})]})]})]})}function rE({content:e,fileName:r,onClose:s}){return y.useEffect(()=>{const a=o=>{o.key==="Escape"&&s()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[s]),t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-4",onClick:s,children:t.jsxs("div",{className:"bg-gray-800 rounded-lg w-full max-w-4xl max-h-[90vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[t.jsx("h3",{className:"text-lg font-semibold text-white",children:r}),t.jsx("button",{onClick:s,className:"text-gray-400 hover:text-white",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsx("div",{className:"flex-1 overflow-auto p-4",children:t.jsx("pre",{className:"text-sm text-gray-300 whitespace-pre-wrap font-mono",children:e})}),t.jsx("div",{className:"p-4 border-t border-gray-700 flex justify-end",children:t.jsx("button",{onClick:s,className:"px-4 py-2 bg-gray-700 text-white rounded hover:bg-gray-600 transition-colors",children:"Close"})})]})})}function nE({backups:e,currentSize:r,diffResult:s,diffLeft:a,diffRight:o,loadingDiff:c,onLeftChange:d,onRightChange:u,onCompare:h,onClose:p}){y.useEffect(()=>{const v=k=>{k.key==="Escape"&&p()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[p]);const x=v=>v<1024?`${v} B`:`${(v/1024).toFixed(1)} KB`,g=v=>{if(!v)return"Unknown";const k=new Date(v);return isNaN(k.getTime())?"Unknown":k.toLocaleString()},b=v=>{switch(v){case"add":return"bg-green-900/30 text-green-300";case"remove":return"bg-red-900/30 text-red-300";case"hunk":return"bg-blue-900/30 text-blue-300";default:return"text-gray-400"}};return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-4",onClick:p,children:t.jsxs("div",{className:"bg-gray-800 rounded-lg w-full max-w-4xl max-h-[90vh] flex flex-col",onClick:v=>v.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[t.jsx("h3",{className:"text-lg font-semibold text-white",children:"Compare Versions"}),t.jsx("button",{onClick:p,className:"text-gray-400 hover:text-white",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsx("div",{className:"p-4 border-b border-gray-700",children:t.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[t.jsxs("div",{className:"flex-1 min-w-[200px]",children:[t.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Left (older)"}),t.jsxs("select",{value:a,onChange:v=>d(v.target.value),className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white",children:[t.jsx("option",{value:"",children:"Select version..."}),e.map((v,k)=>t.jsxs("option",{value:v.name,children:["Backup #",e.length-k," - ",g(v.created)," (",x(v.size),")"]},v.name))]})]}),t.jsx("div",{className:"text-gray-500",children:t.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})})}),t.jsxs("div",{className:"flex-1 min-w-[200px]",children:[t.jsx("label",{className:"block text-sm text-gray-400 mb-1",children:"Right (newer)"}),t.jsxs("select",{value:o,onChange:v=>u(v.target.value),className:"w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded text-white",children:[t.jsxs("option",{value:"current",children:["Current (",x(r),")"]}),e.map((v,k)=>t.jsxs("option",{value:v.name,children:["Backup #",e.length-k," - ",g(v.created)," (",x(v.size),")"]},v.name))]})]}),t.jsx("button",{onClick:h,disabled:!a||c,className:"px-4 py-2 bg-primary-600 text-white rounded hover:bg-primary-500 transition-colors disabled:opacity-50",children:c?"Comparing...":"Compare"})]})}),t.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[!s&&!c&&t.jsx("div",{className:"text-center py-12 text-gray-500",children:"Select two versions and click Compare to see differences"}),c&&t.jsxs("div",{className:"flex items-center justify-center py-12",children:[t.jsx("div",{className:"animate-spin w-6 h-6 border-2 border-primary-400 border-t-transparent rounded-full"}),t.jsx("span",{className:"ml-2 text-gray-400",children:"Generating diff..."})]}),s&&t.jsxs("div",{children:[t.jsxs("div",{className:"mb-4 flex items-center gap-4 text-sm",children:[t.jsxs("span",{className:"text-green-400",children:["+",s.chars_added.toLocaleString()," chars added"]}),t.jsxs("span",{className:"text-red-400",children:["-",s.chars_removed.toLocaleString()," chars removed"]})]}),t.jsx("div",{className:"bg-gray-900 rounded-lg overflow-hidden",children:t.jsx("div",{className:"overflow-x-auto",children:t.jsx("pre",{className:"text-sm font-mono",children:s.diff_lines.map((v,k)=>t.jsx("div",{className:`px-3 py-0.5 ${b(v.type)}`,children:v.line},k))})})})]})]}),t.jsx("div",{className:"p-4 border-t border-gray-700 flex justify-end",children:t.jsx("button",{onClick:p,className:"px-4 py-2 bg-gray-700 text-white rounded hover:bg-gray-600 transition-colors",children:"Close"})})]})})}function sE(){var Z,de,E,L,q;const{slug:e,workflowId:r,stepNumber:s}=Vr(),a=Dr(),[o,c]=y.useState(null),[d,u]=y.useState(!0),[h,p]=y.useState(null),[x,g]=y.useState(!1),[b,v]=y.useState("overview"),[k,T]=y.useState(!1),N=y.useRef(null),j=s?parseInt(s,10):null,A=y.useCallback(async()=>{if(!(!e||!r))try{const S=await ga(e,r);c(S),p(null)}catch(S){p(S instanceof Error?S.message:"Failed to load workflow")}finally{u(!1)}},[e,r]);y.useEffect(()=>{A()},[A]),y.useEffect(()=>()=>{N.current&&clearTimeout(N.current)},[]),y.useEffect(()=>{var ee;if(!o)return;const S=(ee=o.steps)==null?void 0:ee.find(ge=>ge.step_number===j),G=S==null?void 0:S.has_active_run;if(!G&&!k)return;G&&k&&(T(!1),N.current&&(clearTimeout(N.current),N.current=null));const re=setInterval(A,2e3);return()=>clearInterval(re)},[o,j,A,k]);const _=((o==null?void 0:o.steps)||[]).find(S=>S.step_number===j);y.useEffect(()=>{!d&&o&&!_&&a(`/projects/${e}/workflows/${r}`,{replace:!0})},[d,o,_,a,e,r]),y.useEffect(()=>{_!=null&&_.archived_at&&a(`/projects/${e}/workflows/${r}`,{replace:!0})},[_,a,e,r]);const z=async()=>{if(!e||!r||!j)return;const S=(_==null?void 0:_.name)||`Step ${j}`;if((await gt.fire({title:"Run Ralph Loop?",text:`Start executing "${S}"?`,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){g(!0);try{const re=await tx(e,r,j);c(re),T(!0),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{T(!1),N.current=null,A()},15e3)}catch(re){p(re instanceof Error?re.message:"Failed to run step")}finally{g(!1)}}},P=async()=>{if(!(!e||!r||!(await gt.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)){g(!0),T(!1),N.current&&(clearTimeout(N.current),N.current=null);try{const G=await ex(e,r);c(G)}catch(G){p(G instanceof Error?G.message:"Failed to stop step")}finally{g(!1)}}},$=async(S=!1)=>{if(!(!e||!r)){g(!0);try{const G=await t1(e,r,{skip_current:S});c(G)}catch(G){p(G instanceof Error?G.message:"Failed to advance workflow")}finally{g(!1)}}},V=async()=>{if(!e||!r||!_||!o)return;const S=o.steps.filter(G=>G.step_number>_.step_number&&(G.status==="completed"||G.status==="skipped"||G.status==="active"));if(!(S.length>0&&!(await gt.fire({title:"Reopen step?",text:`This will also reset ${S.length} later step${S.length>1?"s":""} back to pending.`,icon:"warning",showCancelButton:!0,confirmButtonText:"Reopen",cancelButtonText:"Cancel",background:"var(--color-surface)",color:"var(--color-text-primary)"})).isConfirmed)){g(!0);try{const G=await r1(e,r,_.id);c(G)}catch(G){p(G instanceof Error?G.message:"Failed to reopen step")}finally{g(!1)}}},B=async S=>{if(!(!e||!r||!_))try{await rx(e,r,_.id,{design_doc_path:S}),A()}catch(G){console.error("Failed to link design doc:",G),p(G instanceof Error?G.message:"Failed to link design doc")}};if(d)return t.jsx("div",{className:"p-6",children:t.jsxs("div",{className:"animate-pulse space-y-4",children:[t.jsx("div",{className:"h-4 w-64 bg-[var(--color-elevated)] rounded"}),t.jsx("div",{className:"h-8 w-96 bg-[var(--color-elevated)] rounded"}),t.jsx("div",{className:"h-64 bg-[var(--color-elevated)] rounded"})]})});if(h&&!o)return t.jsx("div",{className:"p-6",children:t.jsxs("div",{className:"card bg-red-900/20 border border-red-800",children:[t.jsx("h2",{className:"text-lg font-semibold text-red-400 mb-2",children:"Error"}),t.jsx("p",{className:"text-gray-300",children:h}),t.jsx(Re,{to:`/projects/${e}/workflows/${r}`,className:"btn-secondary mt-4 inline-block",children:"Back to Workflow"})]})});if(!o||!_)return null;const U=_.step_type==="interactive",D=_.step_type==="autonomous",R=_.has_active_run===!0||k,X=_.step_number===o.current_step&&_.status==="active",I=U||((Z=_.config)==null?void 0:Z.loopType)==="design_doc",H=_.items_generated||0,W=()=>{if(R)return"bg-green-600";switch(_.status){case"completed":return"bg-blue-600";case"active":return"bg-amber-600";case"skipped":return"bg-gray-600";default:return"bg-gray-600"}},J=()=>{if(R)return"Running";switch(_.status){case"completed":return"Completed";case"active":return"Active";case"skipped":return"Skipped";default:return"Pending"}};return t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"mb-6",children:[t.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[t.jsxs(Re,{to:`/projects/${e}/workflows/${r}`,className:"flex items-center gap-1 hover:text-white transition-colors",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),"Back to Workflow"]}),t.jsx("span",{children:"/"}),t.jsx(Re,{to:"/",className:"hover:text-white",children:"Dashboard"}),t.jsx("span",{children:"/"}),t.jsx(Re,{to:`/projects/${e}`,className:"hover:text-white",children:e}),t.jsx("span",{children:"/"}),t.jsx(Re,{to:`/projects/${e}/workflows/${r}`,className:"hover:text-white",children:o.name}),t.jsx("span",{children:"/"}),t.jsxs("span",{className:"text-white",children:["Step ",_.step_number]})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center space-x-4",children:[t.jsxs("h1",{className:"text-2xl font-bold text-white",children:["Step ",_.step_number,": ",_.name]}),t.jsx("span",{className:`px-3 py-1 rounded-full text-sm font-medium text-white ${W()}`,children:J()}),t.jsx("span",{className:"px-2 py-1 text-xs font-medium bg-[var(--color-elevated)] text-[var(--color-text-muted)] rounded",children:U?"Chat":"Auto"})]}),t.jsxs("div",{className:"flex items-center space-x-3",children:[!R&&o.status!=="completed"&&t.jsxs("button",{onClick:z,disabled:x,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:[t.jsxs("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[t.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"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})]}),t.jsx("span",{children:"Run"})]}),R&&t.jsxs("button",{onClick:P,disabled:x,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:[t.jsxs("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"}),t.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"})]}),t.jsx("span",{children:"Stop"})]}),(_.status==="completed"||_.status==="skipped")&&o.status!=="completed"&&t.jsxs("button",{onClick:V,disabled:x,className:"flex items-center space-x-2 px-4 py-2 border border-gray-600 text-gray-300 rounded hover:bg-gray-700 transition-colors disabled:opacity-50",children:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{children:"Reopen"})]}),t.jsxs("button",{onClick:()=>a(`/projects/${e}/workflows/${r}/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:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{children:"Edit"})]})]})]}),((de=_.config)==null?void 0:de.description)&&t.jsx("p",{className:"mt-2 text-gray-400",children:_.config.description})]}),h&&o&&t.jsx("div",{className:"mb-6 p-4 rounded-lg bg-red-900/20 border border-red-800",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("p",{className:"text-red-400 text-sm",children:h}),t.jsx("button",{onClick:()=>p(null),className:"text-red-400 hover:text-red-300","aria-label":"Dismiss error",children:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),t.jsxs("div",{className:"flex border-b border-[var(--color-border)] mb-6",children:[t.jsxs("button",{onClick:()=>v("overview"),className:`px-4 py-3 text-sm font-medium transition-colors relative
|
|
235
|
+
${b==="overview"?"text-cyan-400":"text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)]"}`,children:["Overview",b==="overview"&&t.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-cyan-500"})]}),D&&t.jsxs("button",{onClick:()=>v("logs"),className:`px-4 py-3 text-sm font-medium transition-colors relative
|
|
236
|
+
${b==="logs"?"text-cyan-400":"text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)]"}`,children:["Logs",R&&t.jsx("span",{className:"ml-2 w-2 h-2 bg-green-500 rounded-full inline-block animate-pulse"}),b==="logs"&&t.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-cyan-500"})]}),!I&&t.jsxs("button",{onClick:()=>v("items"),className:`px-4 py-3 text-sm font-medium transition-colors relative flex items-center gap-2
|
|
237
|
+
${b==="items"?"text-cyan-400":"text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)]"}`,children:["Items",H>0&&t.jsx("span",{className:"px-1.5 py-0.5 text-xs rounded-full bg-cyan-500/20 text-cyan-400",children:H}),b==="items"&&t.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-cyan-500"})]})]}),b==="overview"&&t.jsxs("div",{className:"space-y-6",children:[I&&t.jsx(tE,{projectSlug:e,designDocPath:(E=_.config)==null?void 0:E.design_doc_path,stepStatus:_.status,onLinkFile:B}),t.jsxs("div",{className:"card",children:[t.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Step Configuration"}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wide mb-1",children:"Type"}),t.jsx("div",{className:"text-[var(--color-text-primary)]",children:U?"Interactive (Chat)":"Autonomous (Auto)"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wide mb-1",children:"Status"}),t.jsx("div",{className:"text-[var(--color-text-primary)]",children:J()})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wide mb-1",children:"Iterations"}),t.jsx("div",{className:"text-[var(--color-text-primary)]",children:_.iterations_completed||0})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wide mb-1",children:"Items Generated"}),t.jsx("div",{className:"text-[var(--color-text-primary)]",children:H})]})]}),X&&((L=_.config)==null?void 0:L.skippable)&&t.jsx("div",{className:"mt-4 pt-4 border-t border-[var(--color-border)]",children:t.jsx("button",{onClick:()=>$(!0),disabled:x,className:"text-sm text-gray-400 hover:text-white transition-colors",children:"Skip this step"})})]}),U&&X&&t.jsxs("div",{className:"card",children:[t.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Design Document"}),t.jsx(OL,{projectSlug:e,workflowId:r,stepId:_.id,designDocPath:(q=_.config)==null?void 0:q.design_doc_path,onComplete:A})]}),U&&!X&&t.jsxs("div",{className:"card text-center py-8",children:[_.status==="pending"&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-gray-800 flex items-center justify-center",children:t.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}),t.jsx("p",{className:"text-gray-400",children:"This step hasn't started yet."})]}),_.status==="completed"&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-green-900/30 flex items-center justify-center",children:t.jsx("svg",{className:"w-8 h-8 text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),t.jsx("p",{className:"text-green-400",children:"Step completed!"})]})]}),I&&_.status!=="pending"&&t.jsx(Ay,{projectSlug:e,workflowId:r,stepId:_.id}),D&&_.loop_name&&t.jsxs("div",{className:"card",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h2",{className:"text-lg font-semibold text-white",children:"Session Logs"}),t.jsx("button",{onClick:()=>v("logs"),className:"text-sm text-cyan-400 hover:text-cyan-300 transition-colors",children:"View Full Logs"})]}),t.jsx(Rf,{projectSlug:e,loopName:_.loop_name,enabled:!0})]}),D&&!_.loop_name&&_.status==="pending"&&t.jsxs("div",{className:"card text-center py-8",children:[t.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-gray-800 flex items-center justify-center",children:t.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})})}),t.jsx("p",{className:"text-gray-400",children:"This autonomous step hasn't been configured yet."}),t.jsx("p",{className:"text-gray-500 text-sm mt-2",children:"Run the step to initialize it."})]})]}),b==="logs"&&D&&t.jsx("div",{className:"card",children:_.loop_name?t.jsx(Rf,{projectSlug:e,loopName:_.loop_name,enabled:!0}):t.jsxs("div",{className:"text-center py-12 text-gray-400",children:[t.jsx("div",{className:"w-12 h-12 mx-auto mb-3 rounded-full bg-gray-800 flex items-center justify-center",children:t.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.jsx("p",{children:"No executions yet"}),t.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Run the step to see logs here"})]})}),b==="items"&&!I&&t.jsx("div",{className:"card",children:t.jsx(Gg,{projectSlug:e,workflowId:r,sourceStepId:_.id,steps:(o==null?void 0:o.steps)||[],onImported:()=>A()})})]})}function iE(){var _,z,P;const{slug:e}=Vr(),{selectedProject:r,setSelectedProject:s}=sn(),[a,o]=y.useState([]),[c,d]=y.useState(null),[u,h]=y.useState(!0),[p,x]=y.useState(null),g=y.useCallback(async()=>{if(e){h(!0),x(null);try{const[$,V,B]=await Promise.all([ys(e),qo(e),ab(e)]);s($),o(V),d(B)}catch($){x($ instanceof Error?$.message:"Failed to load dashboard")}finally{h(!1)}}},[e,s]);if(y.useEffect(()=>{g()},[g]),u)return t.jsx("div",{className:"p-6",children:t.jsx("div",{className:"text-gray-400",children:"Loading dashboard..."})});if(p)return t.jsx("div",{className:"p-6",children:t.jsxs("div",{className:"card bg-red-900/20 border border-red-800",children:[t.jsx("h2",{className:"text-lg font-semibold text-red-400 mb-2",children:"Error"}),t.jsx("p",{className:"text-gray-300",children:p}),t.jsx(Re,{to:"/",className:"btn-secondary mt-4 inline-block",children:"Back to Dashboard"})]})});const b=a.map($=>({id:$.id,name:$.name,status:$.status,current_step:$.current_step,total_steps:$.steps.length,progress:$.steps.length>0?Math.round($.steps.filter(V=>V.status==="completed").length/$.steps.length*100):0})),v=b.filter($=>$.status==="active"||$.status==="draft"||$.status==="paused"),k=b.filter($=>$.status==="completed"),T=(c==null?void 0:c.total)||0,N=((_=c==null?void 0:c.by_status)==null?void 0:_.completed)||0,j=((z=c==null?void 0:c.by_status)==null?void 0:z.in_progress)||0,A=((P=c==null?void 0:c.by_status)==null?void 0:P.pending)||0,M=T>0?Math.round(N/T*100):0;return t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-400 mb-2",children:[t.jsx(Re,{to:"/",className:"hover:text-white",children:"Dashboard"}),t.jsx("span",{children:"/"}),t.jsx(Re,{to:`/projects/${e}`,className:"hover:text-white",children:(r==null?void 0:r.name)||e}),t.jsx("span",{children:"/"}),t.jsx("span",{className:"text-white",children:"Project Dashboard"})]}),t.jsxs("div",{className:"flex items-center justify-between mb-8",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-3xl font-bold text-white mb-2",children:"Project Dashboard"}),t.jsx("p",{className:"text-gray-400",children:"Cross-workflow visibility and progress tracking"})]}),t.jsxs(Re,{to:`/projects/${e}`,className:"flex items-center space-x-2 px-4 py-2 bg-gray-700 text-gray-300 rounded hover:bg-gray-600",children:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{children:"Workflows View"})]})]}),t.jsxs("div",{className:"card mb-8",children:[t.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Overall Progress"}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4 mb-4",children:[t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-3xl font-bold text-primary-400",children:a.length}),t.jsx("div",{className:"text-sm text-gray-400",children:"Total Workflows"})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-3xl font-bold text-green-400",children:v.length}),t.jsx("div",{className:"text-sm text-gray-400",children:"Active"})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-3xl font-bold text-blue-400",children:k.length}),t.jsx("div",{className:"text-sm text-gray-400",children:"Completed"})]}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-3xl font-bold text-yellow-400",children:T}),t.jsx("div",{className:"text-sm text-gray-400",children:"Total Items"})]}),t.jsxs("div",{className:"text-center",children:[t.jsxs("div",{className:"text-3xl font-bold text-white",children:[M,"%"]}),t.jsx("div",{className:"text-sm text-gray-400",children:"Items Complete"})]})]}),t.jsx("div",{className:"w-full bg-gray-700 rounded-full h-3",children:t.jsx("div",{className:"bg-gradient-to-r from-primary-600 to-green-500 h-3 rounded-full transition-all duration-500",style:{width:`${M}%`}})})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mb-8",children:[t.jsxs("div",{className:"card",children:[t.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Item Status"}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-gray-300",children:"Completed"}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("div",{className:"w-32 bg-gray-700 rounded-full h-2",children:t.jsx("div",{className:"bg-green-500 h-2 rounded-full",style:{width:`${T>0?N/T*100:0}%`}})}),t.jsx("span",{className:"text-green-400 w-12 text-right",children:N})]})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-gray-300",children:"In Progress"}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("div",{className:"w-32 bg-gray-700 rounded-full h-2",children:t.jsx("div",{className:"bg-yellow-500 h-2 rounded-full",style:{width:`${T>0?j/T*100:0}%`}})}),t.jsx("span",{className:"text-yellow-400 w-12 text-right",children:j})]})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-gray-300",children:"Pending"}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("div",{className:"w-32 bg-gray-700 rounded-full h-2",children:t.jsx("div",{className:"bg-gray-500 h-2 rounded-full",style:{width:`${T>0?A/T*100:0}%`}})}),t.jsx("span",{className:"text-gray-400 w-12 text-right",children:A})]})]})]})]}),t.jsxs("div",{className:"card",children:[t.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Items by Category"}),c!=null&&c.by_category&&Object.keys(c.by_category).length>0?t.jsx("div",{className:"space-y-2",children:Object.entries(c.by_category).sort(([,$],[,V])=>V-$).slice(0,6).map(([$,V])=>t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-gray-300 text-sm font-mono",children:$||"Uncategorized"}),t.jsx("span",{className:"text-primary-400",children:V})]},$))}):t.jsx("p",{className:"text-gray-500 text-sm",children:"No categories yet"})]})]}),t.jsxs("div",{className:"card",children:[t.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Workflow Progress"}),a.length===0?t.jsxs("div",{className:"text-center py-8",children:[t.jsx("p",{className:"text-gray-400",children:"No workflows yet"}),t.jsx(Re,{to:`/projects/${e}`,className:"text-primary-400 hover:text-primary-300 text-sm mt-2 inline-block",children:"Create your first workflow"})]}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-left text-sm text-gray-400 border-b border-gray-700",children:[t.jsx("th",{className:"pb-3 pr-4",children:"Workflow"}),t.jsx("th",{className:"pb-3 pr-4",children:"Status"}),t.jsx("th",{className:"pb-3 pr-4",children:"Step"}),t.jsx("th",{className:"pb-3 pr-4",children:"Progress"}),t.jsx("th",{className:"pb-3"})]})}),t.jsx("tbody",{className:"divide-y divide-gray-700",children:b.map($=>t.jsxs("tr",{className:"hover:bg-gray-800/50",children:[t.jsx("td",{className:"py-3 pr-4",children:t.jsx(Re,{to:`/projects/${e}/workflows/${$.id}`,className:"text-white hover:text-primary-400 font-medium",children:$.name})}),t.jsx("td",{className:"py-3 pr-4",children:t.jsx("span",{className:`px-2 py-1 text-xs rounded ${$.status==="completed"?"bg-green-900/30 text-green-400":$.status==="active"?"bg-blue-900/30 text-blue-400":"bg-gray-700 text-gray-400"}`,children:$.status})}),t.jsxs("td",{className:"py-3 pr-4 text-gray-400 text-sm",children:[$.current_step," / ",$.total_steps]}),t.jsx("td",{className:"py-3 pr-4",children:t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("div",{className:"w-24 bg-gray-700 rounded-full h-2",children:t.jsx("div",{className:`h-2 rounded-full ${$.status==="completed"?"bg-green-500":"bg-primary-500"}`,style:{width:`${$.progress}%`}})}),t.jsxs("span",{className:"text-sm text-gray-400",children:[$.progress,"%"]})]})}),t.jsx("td",{className:"py-3 text-right",children:t.jsx(Re,{to:`/projects/${e}/workflows/${$.id}`,className:"text-primary-400 hover:text-primary-300 text-sm",children:"View"})})]},$.id))})]})})]})]})}function It({title:e,description:r,prompt:s,variant:a="primary"}){const[o,c]=y.useState(!1),[d,u]=y.useState(!1),h=async()=>{await navigator.clipboard.writeText(s),c(!0),setTimeout(()=>c(!1),2e3)},p=a==="primary"?"border-cyan-500/30 hover:border-cyan-500/50":"border-violet-500/30 hover:border-violet-500/50",x=a==="primary"?"bg-cyan-500/10":"bg-violet-500/10";return t.jsxs("div",{className:`rounded-lg border ${p} overflow-hidden transition-colors`,children:[t.jsxs("div",{className:`${x} px-4 py-3 flex items-center justify-between`,children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("svg",{className:"w-4 h-4 text-cyan-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{className:"text-sm font-medium text-gray-200",children:e})]}),t.jsx("button",{onClick:h,className:`flex items-center space-x-1.5 px-3 py-1.5 rounded text-xs font-medium transition-all ${o?"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:o?t.jsxs(t.Fragment,{children:[t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),t.jsx("span",{children:"Copied!"})]}):t.jsxs(t.Fragment,{children:[t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),t.jsx("span",{children:"Copy"})]})})]}),t.jsx("div",{className:"bg-gray-900/70 p-4",children:t.jsx("pre",{className:"text-sm text-gray-300 font-mono whitespace-pre-wrap leading-relaxed",children:s})}),r&&t.jsxs("div",{className:"border-t border-gray-700/50",children:[t.jsxs("button",{onClick:()=>u(!d),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:[t.jsx("span",{children:"What this does"}),t.jsx("svg",{className:`w-4 h-4 transition-transform ${d?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),d&&t.jsx("div",{className:"px-4 pb-3 text-sm text-gray-400",children:r})]})]})}function jt({icon:e,title:r,description:s,children:a,id:o}){return t.jsxs("section",{id:o,className:"mb-10",children:[t.jsxs("div",{className:"flex items-start space-x-3 mb-4",children:[t.jsx("div",{className:"p-2 rounded-lg bg-cyan-500/10 text-cyan-400 mt-0.5",children:e}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold text-white",children:r}),s&&t.jsx("p",{className:"text-sm text-gray-400 mt-1",children:s})]})]}),t.jsx("div",{className:"ml-12",children:a})]})}function Uo({steps:e}){return t.jsx("div",{className:"space-y-4",children:e.map((r,s)=>t.jsxs("div",{className:"flex space-x-4",children:[t.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:t.jsx("span",{className:"text-sm font-semibold text-cyan-400",children:s+1})}),t.jsxs("div",{className:"flex-1 pt-1",children:[t.jsx("h4",{className:"text-sm font-medium text-white mb-1",children:r.title}),t.jsx("div",{className:"text-sm text-gray-400",children:r.description})]})]},s))})}function ms({icon:e,title:r,description:s,color:a="cyan"}){const c={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"}}[a];return t.jsxs("div",{className:`rounded-lg border ${c.border} ${c.bg} p-4 transition-colors`,children:[t.jsx("div",{className:`w-10 h-10 rounded-lg ${c.iconBg} ${c.iconText} flex items-center justify-center mb-3`,children:e}),t.jsx("h3",{className:"text-sm font-semibold text-white mb-1",children:r}),t.jsx("p",{className:"text-xs text-gray-400 leading-relaxed",children:s})]})}function fn({question:e,children:r,defaultOpen:s=!1}){const[a,o]=y.useState(s);return t.jsxs("div",{className:"border border-gray-700/50 rounded-lg overflow-hidden",children:[t.jsxs("button",{onClick:()=>o(!a),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:[t.jsx("span",{className:"text-sm font-medium text-gray-200",children:e}),t.jsx("svg",{className:`w-5 h-5 text-gray-500 transition-transform ${a?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),a&&t.jsx("div",{className:"px-4 py-3 text-sm text-gray-400 border-t border-gray-700/50 bg-gray-900/30",children:r})]})}function Df(){return t.jsxs("div",{className:"space-y-8",children:[t.jsx(jt,{id:"claude-code",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("p",{className:"text-gray-300",children:[t.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."]}),t.jsxs("div",{className:"bg-gray-800/50 rounded-lg p-4 border border-gray-700/50",children:[t.jsx("h4",{className:"text-sm font-medium text-white mb-3",children:"How to install"}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-gray-400 mb-1",children:"macOS / Linux / WSL:"}),t.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"})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-gray-400 mb-1",children:"Windows (PowerShell):"}),t.jsx("div",{className:"bg-gray-900 rounded p-3 font-mono text-sm text-cyan-400",children:"irm https://claude.ai/install.ps1 | iex"})]})]}),t.jsxs("p",{className:"text-xs text-gray-500 mt-3",children:["Visit"," ",t.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."]})]}),t.jsx(Uo,{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!"}]})]})}),t.jsx(jt,{id:"concepts",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsx(ms,{icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"}),t.jsx(ms,{icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"}),t.jsx(ms,{icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"}),t.jsx(ms,{icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})]})}),t.jsx(jt,{id:"first-workflow",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsxs("div",{className:"space-y-4",children:[t.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."}),t.jsx(It,{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:
|
|
238
|
+
1. What project folder should we use?
|
|
239
|
+
2. What do I want to build or accomplish?
|
|
240
|
+
3. Should this be a planning workflow (generate tasks) or implementation workflow (build features)?
|
|
241
|
+
|
|
242
|
+
Then create the project and workflow for me.`})]})})]})}function aE(){return t.jsxs("div",{className:"space-y-8",children:[t.jsx(jt,{id:"planning",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsxs("div",{className:"space-y-4",children:[t.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."}),t.jsx(It,{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
|
|
243
|
+
to build, then set up a workflow that will generate user stories
|
|
244
|
+
and break down the work into manageable tasks.`}),t.jsxs("div",{className:"text-xs text-gray-500",children:[t.jsx("strong",{children:"Best for:"})," New features, product ideas, project kickoffs"]})]})}),t.jsx(jt,{id:"implementation",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsxs("div",{className:"space-y-4",children:[t.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."}),t.jsx(It,{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
|
|
245
|
+
stories/tasks ready. Set up a workflow that will implement them
|
|
246
|
+
one by one, committing code as it goes.`}),t.jsxs("div",{className:"text-xs text-gray-500",children:[t.jsx("strong",{children:"Best for:"})," Building features, fixing bugs, code improvements"]})]})}),t.jsx(jt,{id:"research",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsxs("div",{className:"space-y-4",children:[t.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."}),t.jsx(It,{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
|
|
247
|
+
I want to research, then set up a workflow that will investigate
|
|
248
|
+
it and summarize findings.`}),t.jsxs("div",{className:"text-xs text-gray-500",children:[t.jsx("strong",{children:"Best for:"})," Technology comparisons, library selection, architecture decisions"]})]})}),t.jsx(jt,{id:"documentation",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsxs("div",{className:"space-y-4",children:[t.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."}),t.jsx(It,{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
|
|
249
|
+
code/project needs documentation, then set up a workflow to
|
|
250
|
+
generate docs automatically.`}),t.jsxs("div",{className:"text-xs text-gray-500",children:[t.jsx("strong",{children:"Best for:"})," README files, API documentation, code comments"]})]})}),t.jsx(jt,{id:"custom",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsxs("div",{className:"space-y-4",children:[t.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."}),t.jsx(It,{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
|
|
251
|
+
accomplish: [describe your goal here]
|
|
252
|
+
|
|
253
|
+
Help me figure out what steps and work items would make sense,
|
|
254
|
+
then create the workflow.`,variant:"secondary"})]})})]})}function oE(){return t.jsxs("div",{className:"space-y-8",children:[t.jsx(jt,{id:"dashboard",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{className:"grid gap-4",children:[t.jsxs("div",{className:"bg-gray-800/30 rounded-lg p-4 border border-gray-700/50",children:[t.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-emerald-400 animate-pulse"}),t.jsx("span",{className:"text-sm font-medium text-white",children:"Active Workflow"})]}),t.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."})]}),t.jsxs("div",{className:"bg-gray-800/30 rounded-lg p-4 border border-gray-700/50",children:[t.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-amber-400"}),t.jsx("span",{className:"text-sm font-medium text-white",children:"Paused Workflow"})]}),t.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."})]}),t.jsxs("div",{className:"bg-gray-800/30 rounded-lg p-4 border border-gray-700/50",children:[t.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-gray-500"}),t.jsx("span",{className:"text-sm font-medium text-white",children:"Completed/Draft"})]}),t.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)."})]})]})})}),t.jsx(jt,{id:"management",icon:t.jsxs("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[t.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"}),t.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:t.jsxs("div",{className:"space-y-4",children:[t.jsx(It,{title:"Stop a workflow",description:"Gracefully stops the currently running workflow, finishing any in-progress task.",prompt:"Stop my currently running RalphX workflow gracefully."}),t.jsx(It,{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."}),t.jsx(It,{title:"Check progress",description:"Shows what the workflow has accomplished so far.",prompt:`Show me what my workflow has accomplished so far - list the
|
|
255
|
+
work items and their status.`}),t.jsx(It,{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"})]})}),t.jsx(jt,{id:"troubleshooting",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsxs("div",{className:"space-y-4",children:[t.jsx(It,{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
|
|
256
|
+
by checking the logs and status.`}),t.jsx(It,{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
|
|
257
|
+
or skip it.`}),t.jsx(It,{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
|
|
258
|
+
by checking if all dependencies are installed and the server can start.`})]})}),t.jsx(jt,{id:"faq",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsxs("div",{className:"space-y-3",children:[t.jsx(fn,{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."}),t.jsx(fn,{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."}),t.jsx(fn,{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."}),t.jsx(fn,{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.'}),t.jsx(fn,{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 lE(){return t.jsxs("div",{className:"space-y-8",children:[t.jsx("div",{className:"bg-rose-500/10 border border-rose-500/30 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-start space-x-3",children:[t.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:t.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"})}),t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-rose-300",children:"Security Notice"}),t.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."})]})]})}),t.jsx(jt,{id:"tailscale",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsxs("div",{className:"space-y-4",children:[t.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."}),t.jsx(It,{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.
|
|
259
|
+
Walk me through each step, enable MFA on my Tailscale account,
|
|
260
|
+
and verify it's working securely.`}),t.jsxs("div",{className:"bg-cyan-500/10 border border-cyan-500/30 rounded-lg p-4",children:[t.jsx("h4",{className:"text-sm font-medium text-cyan-300 mb-2",children:"Security Tips for Tailscale"}),t.jsxs("ul",{className:"text-sm text-gray-400 space-y-2",children:[t.jsxs("li",{className:"flex items-start space-x-2",children:[t.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:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),t.jsxs("span",{children:[t.jsx("strong",{children:"Enable MFA"})," on your Tailscale account (strongly recommended)"]})]}),t.jsxs("li",{className:"flex items-start space-x-2",children:[t.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:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),t.jsx("span",{children:"By default, all your devices can connect - that's usually fine for personal use"})]}),t.jsxs("li",{className:"flex items-start space-x-2",children:[t.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:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),t.jsx("span",{children:"If you have many devices, consider ACLs to limit which can access RalphX"})]})]})]})]})}),t.jsx(jt,{id:"cloudflare",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsxs("div",{className:"space-y-4",children:[t.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."}),t.jsx(It,{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
|
|
261
|
+
so only I can access it. Ask me about my domain, set up the tunnel,
|
|
262
|
+
AND configure Cloudflare Access so I need to log in to reach it.`}),t.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/30 rounded-lg p-4",children:[t.jsx("h4",{className:"text-sm font-medium text-amber-300 mb-2",children:"Security Tips for Cloudflare"}),t.jsxs("ul",{className:"text-sm text-gray-400 space-y-2",children:[t.jsxs("li",{className:"flex items-start space-x-2",children:[t.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:t.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"})}),t.jsxs("span",{children:[t.jsx("strong",{children:"ALWAYS set up Cloudflare Access"})," - without it, anyone with your URL can access RalphX"]})]}),t.jsxs("li",{className:"flex items-start space-x-2",children:[t.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:t.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"})}),t.jsx("span",{children:"Use your email as the only allowed login"})]}),t.jsxs("li",{className:"flex items-start space-x-2",children:[t.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:t.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"})}),t.jsx("span",{children:"The prompt above includes auth setup - don't skip it"})]})]})]})]})}),t.jsx(jt,{id:"verify",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsx("div",{className:"space-y-4",children:t.jsx(It,{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.
|
|
263
|
+
Verify I need to authenticate to access RalphX remotely.`})})}),t.jsx(jt,{id:"remote-faq",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsxs("div",{className:"space-y-3",children:[t.jsxs(fn,{question:"Which option should I choose?",children:[t.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.",t.jsx("br",{}),t.jsx("br",{}),t.jsx("strong",{children:"Choose Cloudflare"})," if you want a custom domain (like ralph.yourdomain.com) or need enterprise-grade access controls."]}),t.jsx(fn,{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."}),t.jsx(fn,{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."}),t.jsx(fn,{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 cE(){return t.jsxs("div",{className:"space-y-8",children:[t.jsx(jt,{id:"overview",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("p",{className:"text-gray-300",children:["RalphX lets you ",t.jsx("strong",{className:"text-white",children:"export workflows"})," as portable backup files and ",t.jsx("strong",{className:"text-white",children:"import items"})," from external sources."]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsx(ms,{icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"}),t.jsx(ms,{icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"}),t.jsx(ms,{icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})]})]})}),t.jsx(jt,{id:"export-workflow",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsxs("div",{className:"space-y-4",children:[t.jsx(Uo,{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."}]}),t.jsxs("div",{className:"bg-gray-800/50 rounded-lg p-4 border border-gray-700/50",children:[t.jsx("h4",{className:"text-sm font-medium text-white mb-3",children:"What's included in the export?"}),t.jsxs("ul",{className:"space-y-2 text-sm text-gray-300",children:[t.jsxs("li",{className:"flex items-start space-x-2",children:[t.jsx("span",{className:"text-cyan-400 mt-0.5",children:"•"}),t.jsxs("span",{children:[t.jsx("strong",{className:"text-white",children:"Workflow definition"})," - Name, steps, and configuration"]})]}),t.jsxs("li",{className:"flex items-start space-x-2",children:[t.jsx("span",{className:"text-cyan-400 mt-0.5",children:"•"}),t.jsxs("span",{children:[t.jsx("strong",{className:"text-white",children:"All work items"})," - User stories, tasks, bugs"]})]}),t.jsxs("li",{className:"flex items-start space-x-2",children:[t.jsx("span",{className:"text-cyan-400 mt-0.5",children:"•"}),t.jsxs("span",{children:[t.jsx("strong",{className:"text-white",children:"Resources"})," - Design docs, guardrails, instructions"]})]}),t.jsxs("li",{className:"flex items-start space-x-2",children:[t.jsx("span",{className:"text-cyan-400 mt-0.5",children:"•"}),t.jsxs("span",{children:[t.jsx("strong",{className:"text-white",children:"Planning sessions"})," - Research and planning artifacts"]})]})]})]}),t.jsx("div",{className:"bg-amber-500/10 border border-amber-500/30 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-start space-x-3",children:[t.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:t.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"})}),t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-amber-400",children:"Security Note"}),t.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."})]})]})}),t.jsx(It,{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.'})]})}),t.jsx(jt,{id:"import-workflow",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsxs("div",{className:"space-y-4",children:[t.jsx(Uo,{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."}]}),t.jsxs("div",{className:"bg-gray-800/50 rounded-lg p-4 border border-gray-700/50",children:[t.jsx("h4",{className:"text-sm font-medium text-white mb-3",children:"What happens during import?"}),t.jsxs("ul",{className:"space-y-2 text-sm text-gray-300",children:[t.jsxs("li",{className:"flex items-start space-x-2",children:[t.jsx("span",{className:"text-emerald-400 mt-0.5",children:"•"}),t.jsxs("span",{children:["A ",t.jsx("strong",{className:"text-white",children:"new workflow"})," is created (doesn't overwrite existing)"]})]}),t.jsxs("li",{className:"flex items-start space-x-2",children:[t.jsx("span",{className:"text-emerald-400 mt-0.5",children:"•"}),t.jsxs("span",{children:["All items start fresh with ",t.jsx("strong",{className:"text-white",children:"pending status"})]})]}),t.jsxs("li",{className:"flex items-start space-x-2",children:[t.jsx("span",{className:"text-emerald-400 mt-0.5",children:"•"}),t.jsxs("span",{children:["If the name exists, a ",t.jsx("strong",{className:"text-white",children:"number suffix"})," is added automatically"]})]})]})]}),t.jsx(It,{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."})]})}),t.jsx(jt,{id:"import-items",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"bg-gray-800/50 rounded-lg p-4 border border-gray-700/50",children:t.jsxs("p",{className:"text-sm text-gray-300",children:[t.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."]})}),t.jsx(Uo,{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."}]}),t.jsxs("div",{className:"bg-gray-800/50 rounded-lg p-4 border border-gray-700/50",children:[t.jsx("h4",{className:"text-sm font-medium text-white mb-3",children:"JSONL File Format"}),t.jsx("p",{className:"text-xs text-gray-400 mb-2",children:"Each line is one item. Required: id. Highly recommended: title, content, acceptance_criteria."}),t.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:t.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"]}'})})]}),t.jsx("div",{className:"bg-amber-500/10 border border-amber-500/30 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-start space-x-3",children:[t.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:t.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"})}),t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-amber-400",children:"Acceptance Criteria are Important"}),t.jsxs("p",{className:"text-sm text-gray-300 mt-1",children:["The ",t.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."]})]})]})}),t.jsxs("div",{className:"bg-gray-800/50 rounded-lg p-4 border border-gray-700/50",children:[t.jsx("h4",{className:"text-sm font-medium text-white mb-3",children:"Available Fields"}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[t.jsxs("div",{className:"text-gray-300",children:[t.jsx("code",{className:"text-cyan-400",children:"id"})," - Unique identifier (required)"]}),t.jsxs("div",{className:"text-gray-300",children:[t.jsx("code",{className:"text-cyan-400",children:"title"})," - Short title"]}),t.jsxs("div",{className:"text-gray-300",children:[t.jsx("code",{className:"text-cyan-400",children:"content"})," - Full description"]}),t.jsxs("div",{className:"text-gray-300",children:[t.jsx("code",{className:"text-cyan-400",children:"acceptance_criteria"})," - Array of testable criteria"]}),t.jsxs("div",{className:"text-gray-300",children:[t.jsx("code",{className:"text-cyan-400",children:"priority"})," - 1-5 (1 = highest)"]}),t.jsxs("div",{className:"text-gray-300",children:[t.jsx("code",{className:"text-cyan-400",children:"category"})," - Grouping category"]}),t.jsxs("div",{className:"text-gray-300",children:[t.jsx("code",{className:"text-cyan-400",children:"item_type"})," - story, task, bug"]}),t.jsxs("div",{className:"text-gray-300",children:[t.jsx("code",{className:"text-cyan-400",children:"dependencies"})," - Array of item IDs"]})]})]}),t.jsx("div",{className:"bg-cyan-500/10 border border-cyan-500/30 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-start space-x-3",children:[t.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:t.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"})}),t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-cyan-400",children:"Duplicate Handling"}),t.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."})]})]})}),t.jsx(It,{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.'})]})}),t.jsx(jt,{id:"quick-reference",icon:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-700",children:[t.jsx("th",{className:"text-left py-2 text-gray-400 font-medium",children:"Action"}),t.jsx("th",{className:"text-left py-2 text-gray-400 font-medium",children:"Location"}),t.jsx("th",{className:"text-left py-2 text-gray-400 font-medium",children:"File Type"})]})}),t.jsxs("tbody",{className:"text-gray-300",children:[t.jsxs("tr",{className:"border-b border-gray-800",children:[t.jsx("td",{className:"py-2",children:"Export Workflow"}),t.jsx("td",{className:"py-2",children:"Workflow Detail → Header"}),t.jsx("td",{className:"py-2",children:t.jsx("code",{className:"text-cyan-400",children:".ralphx.zip"})})]}),t.jsxs("tr",{className:"border-b border-gray-800",children:[t.jsx("td",{className:"py-2",children:"Import Workflow"}),t.jsx("td",{className:"py-2",children:"Project Dashboard → Active Workflows"}),t.jsx("td",{className:"py-2",children:t.jsx("code",{className:"text-cyan-400",children:".ralphx.zip"})})]}),t.jsxs("tr",{children:[t.jsx("td",{className:"py-2",children:"Import Items"}),t.jsx("td",{className:"py-2",children:"Workflow Detail → Items Tab"}),t.jsx("td",{className:"py-2",children:t.jsx("code",{className:"text-cyan-400",children:".jsonl"})})]})]})]})})})]})}const Bf=[{id:"getting-started",label:"Getting Started",icon:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})},{id:"use-cases",label:"Use Cases",icon:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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:t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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 dE(){const e=Qn(),r=Dr(),s=()=>{const u=e.hash.replace("#",""),h=Bf.find(p=>p.id===u);return h?h.id:"getting-started"},[a,o]=y.useState(s);y.useEffect(()=>{o(s())},[e.hash]);const c=u=>{o(u),r(`/wiki#${u}`,{replace:!0})},d=()=>{switch(a){case"getting-started":return t.jsx(Df,{});case"use-cases":return t.jsx(aE,{});case"monitoring":return t.jsx(oE,{});case"remote-access":return t.jsx(lE,{});case"backup-import":return t.jsx(cE,{});default:return t.jsx(Df,{})}};return t.jsxs("div",{className:"min-h-screen",children:[t.jsxs("div",{className:"border-b border-gray-700/50 bg-gray-900/30",children:[t.jsx("div",{className:"max-w-4xl mx-auto px-6 py-8",children:t.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[t.jsx("div",{className:"p-2 rounded-lg bg-cyan-500/20",children:t.jsx("svg",{className:"w-6 h-6 text-cyan-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-bold text-white",children:"Wiki"}),t.jsx("p",{className:"text-sm text-gray-400",children:"Learn how to use RalphX with step-by-step guides"})]})]})}),t.jsx("div",{className:"max-w-4xl mx-auto px-6",children:t.jsx("div",{className:"flex space-x-1 overflow-x-auto pb-px",children:Bf.map(u=>t.jsxs("button",{onClick:()=>c(u.id),className:`flex items-center space-x-2 px-4 py-3 text-sm font-medium whitespace-nowrap transition-colors border-b-2 ${a===u.id?"text-cyan-400 border-cyan-400":"text-gray-400 border-transparent hover:text-gray-200 hover:border-gray-600"}`,children:[u.icon,t.jsx("span",{children:u.label})]},u.id))})})]}),t.jsx("div",{className:"max-w-4xl mx-auto px-6 py-8",children:d()})]})}function uE(){return t.jsx(Aw,{children:t.jsxs(Pt,{path:"/",element:t.jsx(A1,{}),children:[t.jsx(Pt,{index:!0,element:t.jsx(O1,{})}),t.jsx(Pt,{path:"projects/:slug",element:t.jsx(Pk,{})}),t.jsx(Pt,{path:"projects/:slug/dashboard",element:t.jsx(iE,{})}),t.jsx(Pt,{path:"projects/:slug/settings",element:t.jsx(X3,{})}),t.jsx(Pt,{path:"projects/:slug/items",element:t.jsx(Q0,{to:"..",replace:!0})}),t.jsx(Pt,{path:"projects/:slug/runs",element:t.jsx(Yp,{})}),t.jsx(Pt,{path:"projects/:slug/loops/:loopName",element:t.jsx(_3,{})}),t.jsx(Pt,{path:"projects/:slug/workflows",element:t.jsx(Q0,{to:"..",replace:!0})}),t.jsx(Pt,{path:"projects/:slug/workflows/:workflowId",element:t.jsx(vC,{})}),t.jsx(Pt,{path:"projects/:slug/workflows/:workflowId/steps/:stepNumber",element:t.jsx(sE,{})}),t.jsx(Pt,{path:"projects/:slug/workflows/:workflowId/edit",element:t.jsx(Q3,{})}),t.jsx(Pt,{path:"projects/:slug/workflows/:workflowId/items",element:t.jsx(T3,{})}),t.jsx(Pt,{path:"projects/:slug/workflows/:workflowId/resources",element:t.jsx(A3,{})}),t.jsx(Pt,{path:"projects/:slug/workflows/:workflowId/runs",element:t.jsx(Yp,{})}),t.jsx(Pt,{path:"wiki",element:t.jsx(dE,{})}),t.jsx(Pt,{path:"logs",element:t.jsx(nC,{})}),t.jsx(Pt,{path:"settings",element:t.jsx(eC,{})})]})})}$2.createRoot(document.getElementById("root")).render(t.jsx(Ks.StrictMode,{children:t.jsx(zw,{children:t.jsx(uE,{})})}));
|
|
264
|
+
//# sourceMappingURL=index-DWvlqOTb.js.map
|