@task-shepherd/agent 1.0.44 → 1.0.45
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.
- package/dist/cli/index.js +1 -1
- package/dist/graphql/introspection.json +3571 -225
- package/dist/index.js +1 -1
- package/dist/meta.json +74 -17
- package/package.json +1 -1
- package/web/dist/assets/{index-dce01df3.js → index-964c5c2c.js} +2 -2
- package/web/dist/assets/{index-dce01df3.js.map → index-964c5c2c.js.map} +1 -1
- package/web/dist/index.html +1 -1
|
@@ -65,5 +65,5 @@ Error generating stack: `+i.message+`
|
|
|
65
65
|
*
|
|
66
66
|
* @license MIT
|
|
67
67
|
*/function Jo(){return Jo=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Jo.apply(this,arguments)}function M0(e,t){if(e==null)return{};var n={},r=Object.keys(e),s,i;for(i=0;i<r.length;i++)s=r[i],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}function R0(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function L0(e,t){return e.button===0&&(!t||t==="_self")&&!R0(e)}const I0=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],_0="6";try{window.__reactRouterVersion=_0}catch{}const F0="startTransition",Cc=Oh[F0];function D0(e){let{basename:t,children:n,future:r,window:s}=e,i=N.useRef();i.current==null&&(i.current=Wg({window:s,v5Compat:!0}));let o=i.current,[l,u]=N.useState({action:o.action,location:o.location}),{v7_startTransition:c}=r||{},d=N.useCallback(h=>{c&&Cc?Cc(()=>u(h)):u(h)},[u,c]);return N.useLayoutEffect(()=>o.listen(d),[o,d]),N.useEffect(()=>O0(r),[r]),N.createElement(z0,{basename:t,children:n,location:l.location,navigationType:l.action,navigator:o,future:r})}const $0=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",U0=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,jp=N.forwardRef(function(t,n){let{onClick:r,relative:s,reloadDocument:i,replace:o,state:l,target:u,to:c,preventScrollReset:d,viewTransition:h}=t,m=M0(t,I0),{basename:v}=N.useContext(Dn),x,w=!1;if(typeof c=="string"&&U0.test(c)&&(x=c,$0))try{let g=new URL(window.location.href),b=c.startsWith("//")?new URL(g.protocol+c):new URL(c),P=tu(b.pathname,v);b.origin===g.origin&&P!=null?c=P+b.search+b.hash:w=!0}catch{}let k=h0(c,{relative:s}),p=W0(c,{replace:o,state:l,target:u,preventScrollReset:d,relative:s,viewTransition:h});function f(g){r&&r(g),g.defaultPrevented||p(g)}return N.createElement("a",Jo({},m,{href:x||k,onClick:w||i?r:f,ref:n,target:u}))});var Ec;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Ec||(Ec={}));var Pc;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Pc||(Pc={}));function W0(e,t){let{target:n,replace:r,state:s,preventScrollReset:i,relative:o,viewTransition:l}=t===void 0?{}:t,u=m0(),c=Ts(),d=vp(e,{relative:o});return N.useCallback(h=>{if(L0(h,n)){h.preventDefault();let m=r!==void 0?r:Ui(c)===Ui(d);u(e,{replace:m,state:s,preventScrollReset:i,relative:o,viewTransition:l})}},[c,u,d,r,s,n,e,i,o,l])}class ca{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){const n={listener:t};return this.listeners.add(n),this.onSubscribe(),()=>{this.listeners.delete(n),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}}const ru=typeof window>"u"||"Deno"in window;function mt(){}function B0(e,t){return typeof e=="function"?e(t):e}function H0(e){return typeof e=="number"&&e>=0&&e!==1/0}function q0(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Ys(e,t,n){return da(e)?typeof t=="function"?{...n,queryKey:e,queryFn:t}:{...t,queryKey:e}:e}function Gt(e,t,n){return da(e)?[{...t,queryKey:e},n]:[e||{},t]}function Tc(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:i,queryKey:o,stale:l}=e;if(da(o)){if(r){if(t.queryHash!==su(o,t.options))return!1}else if(!Bi(t.queryKey,o))return!1}if(n!=="all"){const u=t.isActive();if(n==="active"&&!u||n==="inactive"&&u)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||typeof s<"u"&&s!==t.state.fetchStatus||i&&!i(t))}function Oc(e,t){const{exact:n,fetching:r,predicate:s,mutationKey:i}=e;if(da(i)){if(!t.options.mutationKey)return!1;if(n){if(Cn(t.options.mutationKey)!==Cn(i))return!1}else if(!Bi(t.options.mutationKey,i))return!1}return!(typeof r=="boolean"&&t.state.status==="loading"!==r||s&&!s(t))}function su(e,t){return((t==null?void 0:t.queryKeyHashFn)||Cn)(e)}function Cn(e){return JSON.stringify(e,(t,n)=>Xo(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function Bi(e,t){return bp(e,t)}function bp(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(n=>!bp(e[n],t[n])):!1}function Np(e,t){if(e===t)return e;const n=zc(e)&&zc(t);if(n||Xo(e)&&Xo(t)){const r=n?e.length:Object.keys(e).length,s=n?t:Object.keys(t),i=s.length,o=n?[]:{};let l=0;for(let u=0;u<i;u++){const c=n?u:s[u];o[c]=Np(e[c],t[c]),o[c]===e[c]&&l++}return r===i&&l===r?e:o}return t}function zc(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Xo(e){if(!Ac(e))return!1;const t=e.constructor;if(typeof t>"u")return!0;const n=t.prototype;return!(!Ac(n)||!n.hasOwnProperty("isPrototypeOf"))}function Ac(e){return Object.prototype.toString.call(e)==="[object Object]"}function da(e){return Array.isArray(e)}function kp(e){return new Promise(t=>{setTimeout(t,e)})}function Mc(e){kp(0).then(e)}function Q0(){if(typeof AbortController=="function")return new AbortController}function V0(e,t,n){return n.isDataEqual!=null&&n.isDataEqual(e,t)?e:typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?Np(e,t):t}class K0 extends ca{constructor(){super(),this.setup=t=>{if(!ru&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),window.addEventListener("focus",n,!1),()=>{window.removeEventListener("visibilitychange",n),window.removeEventListener("focus",n)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){if(!this.hasListeners()){var t;(t=this.cleanup)==null||t.call(this),this.cleanup=void 0}}setEventListener(t){var n;this.setup=t,(n=this.cleanup)==null||n.call(this),this.cleanup=t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()})}setFocused(t){this.focused!==t&&(this.focused=t,this.onFocus())}onFocus(){this.listeners.forEach(({listener:t})=>{t()})}isFocused(){return typeof this.focused=="boolean"?this.focused:typeof document>"u"?!0:[void 0,"visible","prerender"].includes(document.visibilityState)}}const Zo=new K0,Rc=["online","offline"];class G0 extends ca{constructor(){super(),this.setup=t=>{if(!ru&&window.addEventListener){const n=()=>t();return Rc.forEach(r=>{window.addEventListener(r,n,!1)}),()=>{Rc.forEach(r=>{window.removeEventListener(r,n)})}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){if(!this.hasListeners()){var t;(t=this.cleanup)==null||t.call(this),this.cleanup=void 0}}setEventListener(t){var n;this.setup=t,(n=this.cleanup)==null||n.call(this),this.cleanup=t(r=>{typeof r=="boolean"?this.setOnline(r):this.onOnline()})}setOnline(t){this.online!==t&&(this.online=t,this.onOnline())}onOnline(){this.listeners.forEach(({listener:t})=>{t()})}isOnline(){return typeof this.online=="boolean"?this.online:typeof navigator>"u"||typeof navigator.onLine>"u"?!0:navigator.onLine}}const Hi=new G0;function Y0(e){return Math.min(1e3*2**e,3e4)}function iu(e){return(e??"online")==="online"?Hi.isOnline():!0}class Sp{constructor(t){this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}}function Ga(e){return e instanceof Sp}function Cp(e){let t=!1,n=0,r=!1,s,i,o;const l=new Promise((k,p)=>{i=k,o=p}),u=k=>{r||(v(new Sp(k)),e.abort==null||e.abort())},c=()=>{t=!0},d=()=>{t=!1},h=()=>!Zo.isFocused()||e.networkMode!=="always"&&!Hi.isOnline(),m=k=>{r||(r=!0,e.onSuccess==null||e.onSuccess(k),s==null||s(),i(k))},v=k=>{r||(r=!0,e.onError==null||e.onError(k),s==null||s(),o(k))},x=()=>new Promise(k=>{s=p=>{const f=r||!h();return f&&k(p),f},e.onPause==null||e.onPause()}).then(()=>{s=void 0,r||e.onContinue==null||e.onContinue()}),w=()=>{if(r)return;let k;try{k=e.fn()}catch(p){k=Promise.reject(p)}Promise.resolve(k).then(m).catch(p=>{var f,g;if(r)return;const b=(f=e.retry)!=null?f:3,P=(g=e.retryDelay)!=null?g:Y0,T=typeof P=="function"?P(n,p):P,C=b===!0||typeof b=="number"&&n<b||typeof b=="function"&&b(n,p);if(t||!C){v(p);return}n++,e.onFail==null||e.onFail(n,p),kp(T).then(()=>{if(h())return x()}).then(()=>{t?v(p):w()})})};return iu(e.networkMode)?w():x().then(w),{promise:l,cancel:u,continue:()=>(s==null?void 0:s())?l:Promise.resolve(),cancelRetry:c,continueRetry:d}}const au=console;function J0(){let e=[],t=0,n=d=>{d()},r=d=>{d()};const s=d=>{let h;t++;try{h=d()}finally{t--,t||l()}return h},i=d=>{t?e.push(d):Mc(()=>{n(d)})},o=d=>(...h)=>{i(()=>{d(...h)})},l=()=>{const d=e;e=[],d.length&&Mc(()=>{r(()=>{d.forEach(h=>{n(h)})})})};return{batch:s,batchCalls:o,schedule:i,setNotifyFunction:d=>{n=d},setBatchNotifyFunction:d=>{r=d}}}const We=J0();class Ep{destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),H0(this.cacheTime)&&(this.gcTimeout=setTimeout(()=>{this.optionalRemove()},this.cacheTime))}updateCacheTime(t){this.cacheTime=Math.max(this.cacheTime||0,t??(ru?1/0:5*60*1e3))}clearGcTimeout(){this.gcTimeout&&(clearTimeout(this.gcTimeout),this.gcTimeout=void 0)}}class X0 extends Ep{constructor(t){super(),this.abortSignalConsumed=!1,this.defaultOptions=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.cache=t.cache,this.logger=t.logger||au,this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.initialState=t.state||Z0(this.options),this.state=this.initialState,this.scheduleGc()}get meta(){return this.options.meta}setOptions(t){this.options={...this.defaultOptions,...t},this.updateCacheTime(this.options.cacheTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.cache.remove(this)}setData(t,n){const r=V0(this.state.data,t,this.options);return this.dispatch({data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){this.dispatch({type:"setState",state:t,setStateOptions:n})}cancel(t){var n;const r=this.promise;return(n=this.retryer)==null||n.cancel(t),r?r.then(mt).catch(mt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.initialState)}isActive(){return this.observers.some(t=>t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||this.observers.some(t=>t.getCurrentResult().isStale)}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!q0(this.state.dataUpdatedAt,t)}onFocus(){var t;const n=this.observers.find(r=>r.shouldFetchOnWindowFocus());n&&n.refetch({cancelRefetch:!1}),(t=this.retryer)==null||t.continue()}onOnline(){var t;const n=this.observers.find(r=>r.shouldFetchOnReconnect());n&&n.refetch({cancelRefetch:!1}),(t=this.retryer)==null||t.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.cache.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(this.retryer&&(this.abortSignalConsumed?this.retryer.cancel({revert:!0}):this.retryer.cancelRetry()),this.scheduleGc()),this.cache.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.dispatch({type:"invalidate"})}fetch(t,n){var r,s;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&n!=null&&n.cancelRefetch)this.cancel({silent:!0});else if(this.promise){var i;return(i=this.retryer)==null||i.continueRetry(),this.promise}}if(t&&this.setOptions(t),!this.options.queryFn){const v=this.observers.find(x=>x.options.queryFn);v&&this.setOptions(v.options)}const o=Q0(),l={queryKey:this.queryKey,pageParam:void 0,meta:this.meta},u=v=>{Object.defineProperty(v,"signal",{enumerable:!0,get:()=>{if(o)return this.abortSignalConsumed=!0,o.signal}})};u(l);const c=()=>this.options.queryFn?(this.abortSignalConsumed=!1,this.options.queryFn(l)):Promise.reject("Missing queryFn for queryKey '"+this.options.queryHash+"'"),d={fetchOptions:n,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:c};if(u(d),(r=this.options.behavior)==null||r.onFetch(d),this.revertState=this.state,this.state.fetchStatus==="idle"||this.state.fetchMeta!==((s=d.fetchOptions)==null?void 0:s.meta)){var h;this.dispatch({type:"fetch",meta:(h=d.fetchOptions)==null?void 0:h.meta})}const m=v=>{if(Ga(v)&&v.silent||this.dispatch({type:"error",error:v}),!Ga(v)){var x,w,k,p;(x=(w=this.cache.config).onError)==null||x.call(w,v,this),(k=(p=this.cache.config).onSettled)==null||k.call(p,this.state.data,v,this)}this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return this.retryer=Cp({fn:d.fetchFn,abort:o==null?void 0:o.abort.bind(o),onSuccess:v=>{var x,w,k,p;if(typeof v>"u"){m(new Error(this.queryHash+" data is undefined"));return}this.setData(v),(x=(w=this.cache.config).onSuccess)==null||x.call(w,v,this),(k=(p=this.cache.config).onSettled)==null||k.call(p,v,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:m,onFail:(v,x)=>{this.dispatch({type:"failed",failureCount:v,error:x})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:d.options.retry,retryDelay:d.options.retryDelay,networkMode:d.options.networkMode}),this.promise=this.retryer.promise,this.promise}dispatch(t){const n=r=>{var s,i;switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:(s=t.meta)!=null?s:null,fetchStatus:iu(this.options.networkMode)?"fetching":"paused",...!r.dataUpdatedAt&&{error:null,status:"loading"}};case"success":return{...r,data:t.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:(i=t.dataUpdatedAt)!=null?i:Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const o=t.error;return Ga(o)&&o.revert&&this.revertState?{...this.revertState,fetchStatus:"idle"}:{...r,error:o,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),We.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate(t)}),this.cache.notify({query:this,type:"updated",action:t})})}}function Z0(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=typeof t<"u",r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"loading",fetchStatus:"idle"}}class ey extends ca{constructor(t){super(),this.config=t||{},this.queries=[],this.queriesMap={}}build(t,n,r){var s;const i=n.queryKey,o=(s=n.queryHash)!=null?s:su(i,n);let l=this.get(o);return l||(l=new X0({cache:this,logger:t.getLogger(),queryKey:i,queryHash:o,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(i)}),this.add(l)),l}add(t){this.queriesMap[t.queryHash]||(this.queriesMap[t.queryHash]=t,this.queries.push(t),this.notify({type:"added",query:t}))}remove(t){const n=this.queriesMap[t.queryHash];n&&(t.destroy(),this.queries=this.queries.filter(r=>r!==t),n===t&&delete this.queriesMap[t.queryHash],this.notify({type:"removed",query:t}))}clear(){We.batch(()=>{this.queries.forEach(t=>{this.remove(t)})})}get(t){return this.queriesMap[t]}getAll(){return this.queries}find(t,n){const[r]=Gt(t,n);return typeof r.exact>"u"&&(r.exact=!0),this.queries.find(s=>Tc(r,s))}findAll(t,n){const[r]=Gt(t,n);return Object.keys(r).length>0?this.queries.filter(s=>Tc(r,s)):this.queries}notify(t){We.batch(()=>{this.listeners.forEach(({listener:n})=>{n(t)})})}onFocus(){We.batch(()=>{this.queries.forEach(t=>{t.onFocus()})})}onOnline(){We.batch(()=>{this.queries.forEach(t=>{t.onOnline()})})}}class ty extends Ep{constructor(t){super(),this.defaultOptions=t.defaultOptions,this.mutationId=t.mutationId,this.mutationCache=t.mutationCache,this.logger=t.logger||au,this.observers=[],this.state=t.state||ny(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options={...this.defaultOptions,...t},this.updateCacheTime(this.options.cacheTime)}get meta(){return this.options.meta}setState(t){this.dispatch({type:"setState",state:t})}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.mutationCache.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.observers=this.observers.filter(n=>n!==t),this.scheduleGc(),this.mutationCache.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.observers.length||(this.state.status==="loading"?this.scheduleGc():this.mutationCache.remove(this))}continue(){var t,n;return(t=(n=this.retryer)==null?void 0:n.continue())!=null?t:this.execute()}async execute(){const t=()=>{var C;return this.retryer=Cp({fn:()=>this.options.mutationFn?this.options.mutationFn(this.state.variables):Promise.reject("No mutationFn found"),onFail:(j,R)=>{this.dispatch({type:"failed",failureCount:j,error:R})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:(C=this.options.retry)!=null?C:0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode}),this.retryer.promise},n=this.state.status==="loading";try{var r,s,i,o,l,u,c,d;if(!n){var h,m,v,x;this.dispatch({type:"loading",variables:this.options.variables}),await((h=(m=this.mutationCache.config).onMutate)==null?void 0:h.call(m,this.state.variables,this));const j=await((v=(x=this.options).onMutate)==null?void 0:v.call(x,this.state.variables));j!==this.state.context&&this.dispatch({type:"loading",context:j,variables:this.state.variables})}const C=await t();return await((r=(s=this.mutationCache.config).onSuccess)==null?void 0:r.call(s,C,this.state.variables,this.state.context,this)),await((i=(o=this.options).onSuccess)==null?void 0:i.call(o,C,this.state.variables,this.state.context)),await((l=(u=this.mutationCache.config).onSettled)==null?void 0:l.call(u,C,null,this.state.variables,this.state.context,this)),await((c=(d=this.options).onSettled)==null?void 0:c.call(d,C,null,this.state.variables,this.state.context)),this.dispatch({type:"success",data:C}),C}catch(C){try{var w,k,p,f,g,b,P,T;throw await((w=(k=this.mutationCache.config).onError)==null?void 0:w.call(k,C,this.state.variables,this.state.context,this)),await((p=(f=this.options).onError)==null?void 0:p.call(f,C,this.state.variables,this.state.context)),await((g=(b=this.mutationCache.config).onSettled)==null?void 0:g.call(b,void 0,C,this.state.variables,this.state.context,this)),await((P=(T=this.options).onSettled)==null?void 0:P.call(T,void 0,C,this.state.variables,this.state.context)),C}finally{this.dispatch({type:"error",error:C})}}}dispatch(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"loading":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!iu(this.options.networkMode),status:"loading",variables:t.variables};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"};case"setState":return{...r,...t.state}}};this.state=n(this.state),We.batch(()=>{this.observers.forEach(r=>{r.onMutationUpdate(t)}),this.mutationCache.notify({mutation:this,type:"updated",action:t})})}}function ny(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0}}class ry extends ca{constructor(t){super(),this.config=t||{},this.mutations=[],this.mutationId=0}build(t,n,r){const s=new ty({mutationCache:this,logger:t.getLogger(),mutationId:++this.mutationId,options:t.defaultMutationOptions(n),state:r,defaultOptions:n.mutationKey?t.getMutationDefaults(n.mutationKey):void 0});return this.add(s),s}add(t){this.mutations.push(t),this.notify({type:"added",mutation:t})}remove(t){this.mutations=this.mutations.filter(n=>n!==t),this.notify({type:"removed",mutation:t})}clear(){We.batch(()=>{this.mutations.forEach(t=>{this.remove(t)})})}getAll(){return this.mutations}find(t){return typeof t.exact>"u"&&(t.exact=!0),this.mutations.find(n=>Oc(t,n))}findAll(t){return this.mutations.filter(n=>Oc(t,n))}notify(t){We.batch(()=>{this.listeners.forEach(({listener:n})=>{n(t)})})}resumePausedMutations(){var t;return this.resuming=((t=this.resuming)!=null?t:Promise.resolve()).then(()=>{const n=this.mutations.filter(r=>r.state.isPaused);return We.batch(()=>n.reduce((r,s)=>r.then(()=>s.continue().catch(mt)),Promise.resolve()))}).then(()=>{this.resuming=void 0}),this.resuming}}function sy(){return{onFetch:e=>{e.fetchFn=()=>{var t,n,r,s,i,o;const l=(t=e.fetchOptions)==null||(n=t.meta)==null?void 0:n.refetchPage,u=(r=e.fetchOptions)==null||(s=r.meta)==null?void 0:s.fetchMore,c=u==null?void 0:u.pageParam,d=(u==null?void 0:u.direction)==="forward",h=(u==null?void 0:u.direction)==="backward",m=((i=e.state.data)==null?void 0:i.pages)||[],v=((o=e.state.data)==null?void 0:o.pageParams)||[];let x=v,w=!1;const k=T=>{Object.defineProperty(T,"signal",{enumerable:!0,get:()=>{var C;if((C=e.signal)!=null&&C.aborted)w=!0;else{var j;(j=e.signal)==null||j.addEventListener("abort",()=>{w=!0})}return e.signal}})},p=e.options.queryFn||(()=>Promise.reject("Missing queryFn for queryKey '"+e.options.queryHash+"'")),f=(T,C,j,R)=>(x=R?[C,...x]:[...x,C],R?[j,...T]:[...T,j]),g=(T,C,j,R)=>{if(w)return Promise.reject("Cancelled");if(typeof j>"u"&&!C&&T.length)return Promise.resolve(T);const M={queryKey:e.queryKey,pageParam:j,meta:e.options.meta};k(M);const K=p(M);return Promise.resolve(K).then(se=>f(T,j,se,R))};let b;if(!m.length)b=g([]);else if(d){const T=typeof c<"u",C=T?c:Lc(e.options,m);b=g(m,T,C)}else if(h){const T=typeof c<"u",C=T?c:iy(e.options,m);b=g(m,T,C,!0)}else{x=[];const T=typeof e.options.getNextPageParam>"u";b=(l&&m[0]?l(m[0],0,m):!0)?g([],T,v[0]):Promise.resolve(f([],v[0],m[0]));for(let j=1;j<m.length;j++)b=b.then(R=>{if(l&&m[j]?l(m[j],j,m):!0){const K=T?v[j]:Lc(e.options,R);return g(R,T,K)}return Promise.resolve(f(R,v[j],m[j]))})}return b.then(T=>({pages:T,pageParams:x}))}}}}function Lc(e,t){return e.getNextPageParam==null?void 0:e.getNextPageParam(t[t.length-1],t)}function iy(e,t){return e.getPreviousPageParam==null?void 0:e.getPreviousPageParam(t[0],t)}class ay{constructor(t={}){this.queryCache=t.queryCache||new ey,this.mutationCache=t.mutationCache||new ry,this.logger=t.logger||au,this.defaultOptions=t.defaultOptions||{},this.queryDefaults=[],this.mutationDefaults=[],this.mountCount=0}mount(){this.mountCount++,this.mountCount===1&&(this.unsubscribeFocus=Zo.subscribe(()=>{Zo.isFocused()&&(this.resumePausedMutations(),this.queryCache.onFocus())}),this.unsubscribeOnline=Hi.subscribe(()=>{Hi.isOnline()&&(this.resumePausedMutations(),this.queryCache.onOnline())}))}unmount(){var t,n;this.mountCount--,this.mountCount===0&&((t=this.unsubscribeFocus)==null||t.call(this),this.unsubscribeFocus=void 0,(n=this.unsubscribeOnline)==null||n.call(this),this.unsubscribeOnline=void 0)}isFetching(t,n){const[r]=Gt(t,n);return r.fetchStatus="fetching",this.queryCache.findAll(r).length}isMutating(t){return this.mutationCache.findAll({...t,fetching:!0}).length}getQueryData(t,n){var r;return(r=this.queryCache.find(t,n))==null?void 0:r.state.data}ensureQueryData(t,n,r){const s=Ys(t,n,r),i=this.getQueryData(s.queryKey);return i?Promise.resolve(i):this.fetchQuery(s)}getQueriesData(t){return this.getQueryCache().findAll(t).map(({queryKey:n,state:r})=>{const s=r.data;return[n,s]})}setQueryData(t,n,r){const s=this.queryCache.find(t),i=s==null?void 0:s.state.data,o=B0(n,i);if(typeof o>"u")return;const l=Ys(t),u=this.defaultQueryOptions(l);return this.queryCache.build(this,u).setData(o,{...r,manual:!0})}setQueriesData(t,n,r){return We.batch(()=>this.getQueryCache().findAll(t).map(({queryKey:s})=>[s,this.setQueryData(s,n,r)]))}getQueryState(t,n){var r;return(r=this.queryCache.find(t,n))==null?void 0:r.state}removeQueries(t,n){const[r]=Gt(t,n),s=this.queryCache;We.batch(()=>{s.findAll(r).forEach(i=>{s.remove(i)})})}resetQueries(t,n,r){const[s,i]=Gt(t,n,r),o=this.queryCache,l={type:"active",...s};return We.batch(()=>(o.findAll(s).forEach(u=>{u.reset()}),this.refetchQueries(l,i)))}cancelQueries(t,n,r){const[s,i={}]=Gt(t,n,r);typeof i.revert>"u"&&(i.revert=!0);const o=We.batch(()=>this.queryCache.findAll(s).map(l=>l.cancel(i)));return Promise.all(o).then(mt).catch(mt)}invalidateQueries(t,n,r){const[s,i]=Gt(t,n,r);return We.batch(()=>{var o,l;if(this.queryCache.findAll(s).forEach(c=>{c.invalidate()}),s.refetchType==="none")return Promise.resolve();const u={...s,type:(o=(l=s.refetchType)!=null?l:s.type)!=null?o:"active"};return this.refetchQueries(u,i)})}refetchQueries(t,n,r){const[s,i]=Gt(t,n,r),o=We.batch(()=>this.queryCache.findAll(s).filter(u=>!u.isDisabled()).map(u=>{var c;return u.fetch(void 0,{...i,cancelRefetch:(c=i==null?void 0:i.cancelRefetch)!=null?c:!0,meta:{refetchPage:s.refetchPage}})}));let l=Promise.all(o).then(mt);return i!=null&&i.throwOnError||(l=l.catch(mt)),l}fetchQuery(t,n,r){const s=Ys(t,n,r),i=this.defaultQueryOptions(s);typeof i.retry>"u"&&(i.retry=!1);const o=this.queryCache.build(this,i);return o.isStaleByTime(i.staleTime)?o.fetch(i):Promise.resolve(o.state.data)}prefetchQuery(t,n,r){return this.fetchQuery(t,n,r).then(mt).catch(mt)}fetchInfiniteQuery(t,n,r){const s=Ys(t,n,r);return s.behavior=sy(),this.fetchQuery(s)}prefetchInfiniteQuery(t,n,r){return this.fetchInfiniteQuery(t,n,r).then(mt).catch(mt)}resumePausedMutations(){return this.mutationCache.resumePausedMutations()}getQueryCache(){return this.queryCache}getMutationCache(){return this.mutationCache}getLogger(){return this.logger}getDefaultOptions(){return this.defaultOptions}setDefaultOptions(t){this.defaultOptions=t}setQueryDefaults(t,n){const r=this.queryDefaults.find(s=>Cn(t)===Cn(s.queryKey));r?r.defaultOptions=n:this.queryDefaults.push({queryKey:t,defaultOptions:n})}getQueryDefaults(t){if(!t)return;const n=this.queryDefaults.find(r=>Bi(t,r.queryKey));return n==null?void 0:n.defaultOptions}setMutationDefaults(t,n){const r=this.mutationDefaults.find(s=>Cn(t)===Cn(s.mutationKey));r?r.defaultOptions=n:this.mutationDefaults.push({mutationKey:t,defaultOptions:n})}getMutationDefaults(t){if(!t)return;const n=this.mutationDefaults.find(r=>Bi(t,r.mutationKey));return n==null?void 0:n.defaultOptions}defaultQueryOptions(t){if(t!=null&&t._defaulted)return t;const n={...this.defaultOptions.queries,...this.getQueryDefaults(t==null?void 0:t.queryKey),...t,_defaulted:!0};return!n.queryHash&&n.queryKey&&(n.queryHash=su(n.queryKey,n)),typeof n.refetchOnReconnect>"u"&&(n.refetchOnReconnect=n.networkMode!=="always"),typeof n.useErrorBoundary>"u"&&(n.useErrorBoundary=!!n.suspense),n}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...this.defaultOptions.mutations,...this.getMutationDefaults(t==null?void 0:t.mutationKey),...t,_defaulted:!0}}clear(){this.queryCache.clear(),this.mutationCache.clear()}}const Ic=N.createContext(void 0),oy=N.createContext(!1);function ly(e,t){return e||(t&&typeof window<"u"?(window.ReactQueryClientContext||(window.ReactQueryClientContext=Ic),window.ReactQueryClientContext):Ic)}const uy=({client:e,children:t,context:n,contextSharing:r=!1})=>{N.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]);const s=ly(n,r);return N.createElement(oy.Provider,{value:!n&&r},N.createElement(s.Provider,{value:e},t))};var Pp={exports:{}},cy="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",dy=cy,fy=dy;function Tp(){}function Op(){}Op.resetWarningCache=Tp;var py=function(){function e(r,s,i,o,l,u){if(u!==fy){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}e.isRequired=e;function t(){return e}var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:Op,resetWarningCache:Tp};return n.PropTypes=n,n};Pp.exports=py();var hy=Pp.exports;const te=jr(hy);var my=typeof Element<"u",gy=typeof Map=="function",yy=typeof Set=="function",vy=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function pi(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var n,r,s;if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(!pi(e[r],t[r]))return!1;return!0}var i;if(gy&&e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(i=e.entries();!(r=i.next()).done;)if(!t.has(r.value[0]))return!1;for(i=e.entries();!(r=i.next()).done;)if(!pi(r.value[1],t.get(r.value[0])))return!1;return!0}if(yy&&e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(i=e.entries();!(r=i.next()).done;)if(!t.has(r.value[0]))return!1;return!0}if(vy&&ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf&&typeof e.valueOf=="function"&&typeof t.valueOf=="function")return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString&&typeof e.toString=="function"&&typeof t.toString=="function")return e.toString()===t.toString();if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,s[r]))return!1;if(my&&e instanceof Element)return!1;for(r=n;r--!==0;)if(!((s[r]==="_owner"||s[r]==="__v"||s[r]==="__o")&&e.$$typeof)&&!pi(e[s[r]],t[s[r]]))return!1;return!0}return e!==e&&t!==t}var xy=function(t,n){try{return pi(t,n)}catch(r){if((r.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw r}};const wy=jr(xy);var jy=function(e,t,n,r,s,i,o,l){if(!e){var u;if(t===void 0)u=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,s,i,o,l],d=0;u=new Error(t.replace(/%s/g,function(){return c[d++]})),u.name="Invariant Violation"}throw u.framesToPop=1,u}},by=jy;const _c=jr(by);var Ny=function(t,n,r,s){var i=r?r.call(s,t,n):void 0;if(i!==void 0)return!!i;if(t===n)return!0;if(typeof t!="object"||!t||typeof n!="object"||!n)return!1;var o=Object.keys(t),l=Object.keys(n);if(o.length!==l.length)return!1;for(var u=Object.prototype.hasOwnProperty.bind(n),c=0;c<o.length;c++){var d=o[c];if(!u(d))return!1;var h=t[d],m=n[d];if(i=r?r.call(s,h,m,d):void 0,i===!1||i===void 0&&h!==m)return!1}return!0};const ky=jr(Ny);function Ne(){return Ne=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ne.apply(this,arguments)}function ou(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,el(e,t)}function el(e,t){return el=Object.setPrototypeOf||function(n,r){return n.__proto__=r,n},el(e,t)}function Fc(e,t){if(e==null)return{};var n,r,s={},i=Object.keys(e);for(r=0;r<i.length;r++)t.indexOf(n=i[r])>=0||(s[n]=e[n]);return s}var B={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title",FRAGMENT:"Symbol(react.fragment)"},Sy={rel:["amphtml","canonical","alternate"]},Cy={type:["application/ld+json"]},Ey={charset:"",name:["robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},Dc=Object.keys(B).map(function(e){return B[e]}),qi={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},Py=Object.keys(qi).reduce(function(e,t){return e[qi[t]]=t,e},{}),fr=function(e,t){for(var n=e.length-1;n>=0;n-=1){var r=e[n];if(Object.prototype.hasOwnProperty.call(r,t))return r[t]}return null},Ty=function(e){var t=fr(e,B.TITLE),n=fr(e,"titleTemplate");if(Array.isArray(t)&&(t=t.join("")),n&&t)return n.replace(/%s/g,function(){return t});var r=fr(e,"defaultTitle");return t||r||void 0},Oy=function(e){return fr(e,"onChangeClientState")||function(){}},Ya=function(e,t){return t.filter(function(n){return n[e]!==void 0}).map(function(n){return n[e]}).reduce(function(n,r){return Ne({},n,r)},{})},zy=function(e,t){return t.filter(function(n){return n[B.BASE]!==void 0}).map(function(n){return n[B.BASE]}).reverse().reduce(function(n,r){if(!n.length)for(var s=Object.keys(r),i=0;i<s.length;i+=1){var o=s[i].toLowerCase();if(e.indexOf(o)!==-1&&r[o])return n.concat(r)}return n},[])},Lr=function(e,t,n){var r={};return n.filter(function(s){return!!Array.isArray(s[e])||(s[e]!==void 0&&console&&typeof console.warn=="function"&&console.warn("Helmet: "+e+' should be of type "Array". Instead found type "'+typeof s[e]+'"'),!1)}).map(function(s){return s[e]}).reverse().reduce(function(s,i){var o={};i.filter(function(h){for(var m,v=Object.keys(h),x=0;x<v.length;x+=1){var w=v[x],k=w.toLowerCase();t.indexOf(k)===-1||m==="rel"&&h[m].toLowerCase()==="canonical"||k==="rel"&&h[k].toLowerCase()==="stylesheet"||(m=k),t.indexOf(w)===-1||w!=="innerHTML"&&w!=="cssText"&&w!=="itemprop"||(m=w)}if(!m||!h[m])return!1;var p=h[m].toLowerCase();return r[m]||(r[m]={}),o[m]||(o[m]={}),!r[m][p]&&(o[m][p]=!0,!0)}).reverse().forEach(function(h){return s.push(h)});for(var l=Object.keys(o),u=0;u<l.length;u+=1){var c=l[u],d=Ne({},r[c],o[c]);r[c]=d}return s},[]).reverse()},Ay=function(e,t){if(Array.isArray(e)&&e.length){for(var n=0;n<e.length;n+=1)if(e[n][t])return!0}return!1},zp=function(e){return Array.isArray(e)?e.join(""):e},Ja=function(e,t){return Array.isArray(e)?e.reduce(function(n,r){return function(s,i){for(var o=Object.keys(s),l=0;l<o.length;l+=1)if(i[o[l]]&&i[o[l]].includes(s[o[l]]))return!0;return!1}(r,t)?n.priority.push(r):n.default.push(r),n},{priority:[],default:[]}):{default:e}},$c=function(e,t){var n;return Ne({},e,((n={})[t]=void 0,n))},My=[B.NOSCRIPT,B.SCRIPT,B.STYLE],Xa=function(e,t){return t===void 0&&(t=!0),t===!1?String(e):String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},Uc=function(e){return Object.keys(e).reduce(function(t,n){var r=e[n]!==void 0?n+'="'+e[n]+'"':""+n;return t?t+" "+r:r},"")},Wc=function(e,t){return t===void 0&&(t={}),Object.keys(e).reduce(function(n,r){return n[qi[r]||r]=e[r],n},t)},hi=function(e,t){return t.map(function(n,r){var s,i=((s={key:r})["data-rh"]=!0,s);return Object.keys(n).forEach(function(o){var l=qi[o]||o;l==="innerHTML"||l==="cssText"?i.dangerouslySetInnerHTML={__html:n.innerHTML||n.cssText}:i[l]=n[o]}),I.createElement(e,i)})},st=function(e,t,n){switch(e){case B.TITLE:return{toComponent:function(){return s=t.titleAttributes,(i={key:r=t.title})["data-rh"]=!0,o=Wc(s,i),[I.createElement(B.TITLE,o,r)];var r,s,i,o},toString:function(){return function(r,s,i,o){var l=Uc(i),u=zp(s);return l?"<"+r+' data-rh="true" '+l+">"+Xa(u,o)+"</"+r+">":"<"+r+' data-rh="true">'+Xa(u,o)+"</"+r+">"}(e,t.title,t.titleAttributes,n)}};case"bodyAttributes":case"htmlAttributes":return{toComponent:function(){return Wc(t)},toString:function(){return Uc(t)}};default:return{toComponent:function(){return hi(e,t)},toString:function(){return function(r,s,i){return s.reduce(function(o,l){var u=Object.keys(l).filter(function(h){return!(h==="innerHTML"||h==="cssText")}).reduce(function(h,m){var v=l[m]===void 0?m:m+'="'+Xa(l[m],i)+'"';return h?h+" "+v:v},""),c=l.innerHTML||l.cssText||"",d=My.indexOf(r)===-1;return o+"<"+r+' data-rh="true" '+u+(d?"/>":">"+c+"</"+r+">")},"")}(e,t,n)}}}},tl=function(e){var t=e.baseTag,n=e.bodyAttributes,r=e.encode,s=e.htmlAttributes,i=e.noscriptTags,o=e.styleTags,l=e.title,u=l===void 0?"":l,c=e.titleAttributes,d=e.linkTags,h=e.metaTags,m=e.scriptTags,v={toComponent:function(){},toString:function(){return""}};if(e.prioritizeSeoTags){var x=function(w){var k=w.linkTags,p=w.scriptTags,f=w.encode,g=Ja(w.metaTags,Ey),b=Ja(k,Sy),P=Ja(p,Cy);return{priorityMethods:{toComponent:function(){return[].concat(hi(B.META,g.priority),hi(B.LINK,b.priority),hi(B.SCRIPT,P.priority))},toString:function(){return st(B.META,g.priority,f)+" "+st(B.LINK,b.priority,f)+" "+st(B.SCRIPT,P.priority,f)}},metaTags:g.default,linkTags:b.default,scriptTags:P.default}}(e);v=x.priorityMethods,d=x.linkTags,h=x.metaTags,m=x.scriptTags}return{priority:v,base:st(B.BASE,t,r),bodyAttributes:st("bodyAttributes",n,r),htmlAttributes:st("htmlAttributes",s,r),link:st(B.LINK,d,r),meta:st(B.META,h,r),noscript:st(B.NOSCRIPT,i,r),script:st(B.SCRIPT,m,r),style:st(B.STYLE,o,r),title:st(B.TITLE,{title:u,titleAttributes:c},r)}},Js=[],nl=function(e,t){var n=this;t===void 0&&(t=typeof document<"u"),this.instances=[],this.value={setHelmet:function(r){n.context.helmet=r},helmetInstances:{get:function(){return n.canUseDOM?Js:n.instances},add:function(r){(n.canUseDOM?Js:n.instances).push(r)},remove:function(r){var s=(n.canUseDOM?Js:n.instances).indexOf(r);(n.canUseDOM?Js:n.instances).splice(s,1)}}},this.context=e,this.canUseDOM=t,t||(e.helmet=tl({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))},Ap=I.createContext({}),Ry=te.shape({setHelmet:te.func,helmetInstances:te.shape({get:te.func,add:te.func,remove:te.func})}),Ly=typeof document<"u",sr=function(e){function t(n){var r;return(r=e.call(this,n)||this).helmetData=new nl(r.props.context,t.canUseDOM),r}return ou(t,e),t.prototype.render=function(){return I.createElement(Ap.Provider,{value:this.helmetData.value},this.props.children)},t}(N.Component);sr.canUseDOM=Ly,sr.propTypes={context:te.shape({helmet:te.shape()}),children:te.node.isRequired},sr.defaultProps={context:{}},sr.displayName="HelmetProvider";var qn=function(e,t){var n,r=document.head||document.querySelector(B.HEAD),s=r.querySelectorAll(e+"[data-rh]"),i=[].slice.call(s),o=[];return t&&t.length&&t.forEach(function(l){var u=document.createElement(e);for(var c in l)Object.prototype.hasOwnProperty.call(l,c)&&(c==="innerHTML"?u.innerHTML=l.innerHTML:c==="cssText"?u.styleSheet?u.styleSheet.cssText=l.cssText:u.appendChild(document.createTextNode(l.cssText)):u.setAttribute(c,l[c]===void 0?"":l[c]));u.setAttribute("data-rh","true"),i.some(function(d,h){return n=h,u.isEqualNode(d)})?i.splice(n,1):o.push(u)}),i.forEach(function(l){return l.parentNode.removeChild(l)}),o.forEach(function(l){return r.appendChild(l)}),{oldTags:i,newTags:o}},Za=function(e,t){var n=document.getElementsByTagName(e)[0];if(n){for(var r=n.getAttribute("data-rh"),s=r?r.split(","):[],i=[].concat(s),o=Object.keys(t),l=0;l<o.length;l+=1){var u=o[l],c=t[u]||"";n.getAttribute(u)!==c&&n.setAttribute(u,c),s.indexOf(u)===-1&&s.push(u);var d=i.indexOf(u);d!==-1&&i.splice(d,1)}for(var h=i.length-1;h>=0;h-=1)n.removeAttribute(i[h]);s.length===i.length?n.removeAttribute("data-rh"):n.getAttribute("data-rh")!==o.join(",")&&n.setAttribute("data-rh",o.join(","))}},Bc=function(e,t){var n=e.baseTag,r=e.htmlAttributes,s=e.linkTags,i=e.metaTags,o=e.noscriptTags,l=e.onChangeClientState,u=e.scriptTags,c=e.styleTags,d=e.title,h=e.titleAttributes;Za(B.BODY,e.bodyAttributes),Za(B.HTML,r),function(w,k){w!==void 0&&document.title!==w&&(document.title=zp(w)),Za(B.TITLE,k)}(d,h);var m={baseTag:qn(B.BASE,n),linkTags:qn(B.LINK,s),metaTags:qn(B.META,i),noscriptTags:qn(B.NOSCRIPT,o),scriptTags:qn(B.SCRIPT,u),styleTags:qn(B.STYLE,c)},v={},x={};Object.keys(m).forEach(function(w){var k=m[w],p=k.newTags,f=k.oldTags;p.length&&(v[w]=p),f.length&&(x[w]=m[w].oldTags)}),t&&t(),l(e,v,x)},Ir=null,Qi=function(e){function t(){for(var r,s=arguments.length,i=new Array(s),o=0;o<s;o++)i[o]=arguments[o];return(r=e.call.apply(e,[this].concat(i))||this).rendered=!1,r}ou(t,e);var n=t.prototype;return n.shouldComponentUpdate=function(r){return!ky(r,this.props)},n.componentDidUpdate=function(){this.emitChange()},n.componentWillUnmount=function(){this.props.context.helmetInstances.remove(this),this.emitChange()},n.emitChange=function(){var r,s,i=this.props.context,o=i.setHelmet,l=null,u=(r=i.helmetInstances.get().map(function(c){var d=Ne({},c.props);return delete d.context,d}),{baseTag:zy(["href"],r),bodyAttributes:Ya("bodyAttributes",r),defer:fr(r,"defer"),encode:fr(r,"encodeSpecialCharacters"),htmlAttributes:Ya("htmlAttributes",r),linkTags:Lr(B.LINK,["rel","href"],r),metaTags:Lr(B.META,["name","charset","http-equiv","property","itemprop"],r),noscriptTags:Lr(B.NOSCRIPT,["innerHTML"],r),onChangeClientState:Oy(r),scriptTags:Lr(B.SCRIPT,["src","innerHTML"],r),styleTags:Lr(B.STYLE,["cssText"],r),title:Ty(r),titleAttributes:Ya("titleAttributes",r),prioritizeSeoTags:Ay(r,"prioritizeSeoTags")});sr.canUseDOM?(s=u,Ir&&cancelAnimationFrame(Ir),s.defer?Ir=requestAnimationFrame(function(){Bc(s,function(){Ir=null})}):(Bc(s),Ir=null)):tl&&(l=tl(u)),o(l)},n.init=function(){this.rendered||(this.rendered=!0,this.props.context.helmetInstances.add(this),this.emitChange())},n.render=function(){return this.init(),null},t}(N.Component);Qi.propTypes={context:Ry.isRequired},Qi.displayName="HelmetDispatcher";var Iy=["children"],_y=["children"],pn=function(e){function t(){return e.apply(this,arguments)||this}ou(t,e);var n=t.prototype;return n.shouldComponentUpdate=function(r){return!wy($c(this.props,"helmetData"),$c(r,"helmetData"))},n.mapNestedChildrenToProps=function(r,s){if(!s)return null;switch(r.type){case B.SCRIPT:case B.NOSCRIPT:return{innerHTML:s};case B.STYLE:return{cssText:s};default:throw new Error("<"+r.type+" /> elements are self-closing and can not contain children. Refer to our API for more information.")}},n.flattenArrayTypeChildren=function(r){var s,i=r.child,o=r.arrayTypeChildren;return Ne({},o,((s={})[i.type]=[].concat(o[i.type]||[],[Ne({},r.newChildProps,this.mapNestedChildrenToProps(i,r.nestedChildren))]),s))},n.mapObjectTypeChildren=function(r){var s,i,o=r.child,l=r.newProps,u=r.newChildProps,c=r.nestedChildren;switch(o.type){case B.TITLE:return Ne({},l,((s={})[o.type]=c,s.titleAttributes=Ne({},u),s));case B.BODY:return Ne({},l,{bodyAttributes:Ne({},u)});case B.HTML:return Ne({},l,{htmlAttributes:Ne({},u)});default:return Ne({},l,((i={})[o.type]=Ne({},u),i))}},n.mapArrayTypeChildrenToProps=function(r,s){var i=Ne({},s);return Object.keys(r).forEach(function(o){var l;i=Ne({},i,((l={})[o]=r[o],l))}),i},n.warnOnInvalidChildren=function(r,s){return _c(Dc.some(function(i){return r.type===i}),typeof r.type=="function"?"You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information.":"Only elements types "+Dc.join(", ")+" are allowed. Helmet does not support rendering <"+r.type+"> elements. Refer to our API for more information."),_c(!s||typeof s=="string"||Array.isArray(s)&&!s.some(function(i){return typeof i!="string"}),"Helmet expects a string as a child of <"+r.type+">. Did you forget to wrap your children in braces? ( <"+r.type+">{``}</"+r.type+"> ) Refer to our API for more information."),!0},n.mapChildrenToProps=function(r,s){var i=this,o={};return I.Children.forEach(r,function(l){if(l&&l.props){var u=l.props,c=u.children,d=Fc(u,Iy),h=Object.keys(d).reduce(function(v,x){return v[Py[x]||x]=d[x],v},{}),m=l.type;switch(typeof m=="symbol"?m=m.toString():i.warnOnInvalidChildren(l,c),m){case B.FRAGMENT:s=i.mapChildrenToProps(c,s);break;case B.LINK:case B.META:case B.NOSCRIPT:case B.SCRIPT:case B.STYLE:o=i.flattenArrayTypeChildren({child:l,arrayTypeChildren:o,newChildProps:h,nestedChildren:c});break;default:s=i.mapObjectTypeChildren({child:l,newProps:s,newChildProps:h,nestedChildren:c})}}}),this.mapArrayTypeChildrenToProps(o,s)},n.render=function(){var r=this.props,s=r.children,i=Fc(r,_y),o=Ne({},i),l=i.helmetData;return s&&(o=this.mapChildrenToProps(s,o)),!l||l instanceof nl||(l=new nl(l.context,l.instances)),l?I.createElement(Qi,Ne({},o,{context:l.value,helmetData:void 0})):I.createElement(Ap.Consumer,null,function(u){return I.createElement(Qi,Ne({},o,{context:u}))})},t}(N.Component);pn.propTypes={base:te.object,bodyAttributes:te.object,children:te.oneOfType([te.arrayOf(te.node),te.node]),defaultTitle:te.string,defer:te.bool,encodeSpecialCharacters:te.bool,htmlAttributes:te.object,link:te.arrayOf(te.object),meta:te.arrayOf(te.object),noscript:te.arrayOf(te.object),onChangeClientState:te.func,script:te.arrayOf(te.object),style:te.arrayOf(te.object),title:te.string,titleAttributes:te.object,titleTemplate:te.string,prioritizeSeoTags:te.bool,helmetData:te.object},pn.defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1},pn.displayName="Helmet";function Fy(e,{insertAt:t}={}){if(!e||typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}Fy(`[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 6px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999}[data-sonner-toaster][data-x-position=right]{right:max(var(--offset),env(safe-area-inset-right))}[data-sonner-toaster][data-x-position=left]{left:max(var(--offset),env(safe-area-inset-left))}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translate(-50%)}[data-sonner-toaster][data-y-position=top]{top:max(var(--offset),env(safe-area-inset-top))}[data-sonner-toaster][data-y-position=bottom]{bottom:max(var(--offset),env(safe-area-inset-bottom))}[data-sonner-toast]{--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;will-change:transform,opacity,height;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}[data-sonner-toast][data-y-position=top]{top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}[data-sonner-toast] [data-description]{font-weight:400;line-height:1.4;color:inherit}[data-sonner-toast] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:-3px;margin-right:4px}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast] [data-icon]>*{flex-shrink:0}[data-sonner-toast] [data-icon] svg{margin-left:-1px}[data-sonner-toast] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:auto;border:none;cursor:pointer;outline:none;transition:opacity .4s,box-shadow .2s}[data-sonner-toast] [data-button]:focus-visible{box-shadow:0 0 0 2px #0006}[data-sonner-toast] [data-button]:first-of-type{margin-left:auto}[data-sonner-toast] [data-cancel]{color:var(--color);background:var(--border-color)}[data-sonner-toast] [data-close-button]{position:absolute;left:0;top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;background:var(--gray1);color:var(--gray12);border:1px solid var(--gray4);transform:translate(-35%,-35%);border-radius:50%;opacity:0;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast]:hover [data-close-button]{opacity:1}[data-sonner-toast]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]:before{content:"";position:absolute;left:0;right:0;height:100%}[data-sonner-toast][data-y-position=top][data-swiping=true]:before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]:before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]:before{content:"";position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast]:after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y: translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y: translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]:before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount, 0px));transition:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation:swipe-out .2s ease-out forwards}@keyframes swipe-out{0%{transform:translateY(calc(var(--lift) * var(--offset) + var(--swipe-amount)));opacity:1}to{transform:translateY(calc(var(--lift) * var(--offset) + var(--swipe-amount) + var(--lift) * -100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;--mobile-offset: 16px;right:var(--mobile-offset);left:var(--mobile-offset);width:100%}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - 32px)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset)}[data-sonner-toaster][data-y-position=bottom]{bottom:20px}[data-sonner-toaster][data-y-position=top]{top:20px}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset);right:var(--mobile-offset);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-rich-colors=true] [data-sonner-toast][data-type=success],[data-rich-colors=true] [data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true] [data-sonner-toast][data-type=error],[data-rich-colors=true] [data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}
|
|
68
|
-
`);var Dy=e=>{switch(e){case"success":return Wy;case"error":return By;default:return null}},$y=Array(12).fill(0),Uy=({visible:e})=>I.createElement("div",{className:"sonner-loading-wrapper","data-visible":e},I.createElement("div",{className:"sonner-spinner"},$y.map((t,n)=>I.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),Wy=I.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},I.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),By=I.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},I.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),rl=0,Hy=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,s=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:rl++;return this.toasts.find(i=>i.id===s)?this.toasts=this.toasts.map(i=>i.id===s?(this.publish({...i,...e,id:s,title:n}),{...i,...e,id:s,title:n}):i):this.addToast({title:n,...r,id:s}),s},this.dismiss=e=>(e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.promise=(e,t)=>{let n=this.create({...t,promise:e,type:"loading",message:t.loading});return(e instanceof Promise?e:e()).then(r=>{let s=typeof t.success=="function"?t.success(r):t.success;this.create({id:n,type:"success",message:s})}).catch(r=>{let s=typeof t.error=="function"?t.error(r):t.error;this.create({id:n,type:"error",message:s})}),n},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||rl++;this.publish({jsx:e(n),id:n,...t})},this.subscribers=[],this.toasts=[]}},Yt=new Hy,qy=(e,t)=>{let n=(t==null?void 0:t.id)||rl++;return Yt.addToast({title:e,...t,id:n}),n},Qy=qy;Object.assign(Qy,{success:Yt.success,error:Yt.error,custom:Yt.custom,message:Yt.message,promise:Yt.promise,dismiss:Yt.dismiss});var Vy=3,Ky="32px",Gy=4e3,Yy=356,Mp=14,Jy=20,Xy=200,Zy=e=>{let{invert:t,toast:n,interacting:r,setHeights:s,visibleToasts:i,heights:o,index:l,toasts:u,expanded:c,removeToast:d,closeButton:h,style:m,className:v="",descriptionClassName:x="",duration:w,position:k,expandByDefault:p}=e,[f,g]=I.useState(!1),[b,P]=I.useState(!1),[T,C]=I.useState(!1),[j,R]=I.useState(!1),[M,K]=I.useState(0),[E,se]=I.useState(0),q=I.useRef(null),ae=l===0,Z=l+1<=i,oe=n.type,A=n.className||"",$=n.descriptionClassName||"",U=I.useMemo(()=>o.findIndex(Q=>Q.toastId===n.id)||0,[o,n.id]),re=I.useMemo(()=>n.duration||w||Gy,[n.duration,w]),V=I.useRef(0),ee=I.useRef(0),be=I.useRef(re),Qe=I.useRef(0),Ee=I.useRef(null),[jt,Os]=k.split("-"),Ot=I.useMemo(()=>o.reduce((Q,ce,Pe)=>Pe>=U?Q:Q+ce.height,0),[o,U]),bt=n.invert||t,Cr=oe==="loading";ee.current=I.useMemo(()=>U*Mp+Ot,[U,Ot]),I.useEffect(()=>{g(!0)},[]),I.useLayoutEffect(()=>{if(!f)return;let Q=q.current,ce=Q.style.height;Q.style.height="auto";let Pe=Q.getBoundingClientRect().height;Q.style.height=ce,se(Pe),s(dt=>dt.find(Nt=>Nt.toastId===n.id)?dt.map(Nt=>Nt.toastId===n.id?{...Nt,height:Pe}:Nt):[{toastId:n.id,height:Pe},...dt])},[f,n.title,n.description,s,n.id]);let fe=I.useCallback(()=>{P(!0),K(ee.current),s(Q=>Q.filter(ce=>ce.toastId!==n.id)),setTimeout(()=>{d(n)},Xy)},[n,d,s,ee]);return I.useEffect(()=>{if(n.promise&&oe==="loading"||n.duration===1/0)return;let Q;return c||r?(()=>{if(Qe.current<V.current){let ce=new Date().getTime()-V.current;be.current=be.current-ce}Qe.current=new Date().getTime()})():(V.current=new Date().getTime(),Q=setTimeout(()=>{var ce;(ce=n.onAutoClose)==null||ce.call(n,n),fe()},be.current)),()=>clearTimeout(Q)},[c,r,p,n,re,fe,n.promise,oe]),I.useEffect(()=>{let Q=q.current;if(Q){let ce=Q.getBoundingClientRect().height;return se(ce),s(Pe=>[{toastId:n.id,height:ce},...Pe]),()=>s(Pe=>Pe.filter(dt=>dt.toastId!==n.id))}},[s,n.id]),I.useEffect(()=>{n.delete&&fe()},[fe,n.delete]),I.createElement("li",{"aria-live":n.important?"assertive":"polite","aria-atomic":"true",role:"status",tabIndex:0,ref:q,className:v+" "+A,"data-sonner-toast":"","data-styled":!n.jsx,"data-mounted":f,"data-promise":!!n.promise,"data-removed":b,"data-visible":Z,"data-y-position":jt,"data-x-position":Os,"data-index":l,"data-front":ae,"data-swiping":T,"data-type":oe,"data-invert":bt,"data-swipe-out":j,"data-expanded":!!(c||p&&f),style:{"--index":l,"--toasts-before":l,"--z-index":u.length-l,"--offset":`${b?M:ee.current}px`,"--initial-height":p?"auto":`${E}px`,...m,...n.style},onPointerDown:Q=>{Cr||(K(ee.current),Q.target.setPointerCapture(Q.pointerId),Q.target.tagName!=="BUTTON"&&(C(!0),Ee.current={x:Q.clientX,y:Q.clientY}))},onPointerUp:()=>{var Q,ce,Pe;if(j)return;Ee.current=null;let dt=Number(((Q=q.current)==null?void 0:Q.style.getPropertyValue("--swipe-amount").replace("px",""))||0);if(Math.abs(dt)>=Jy){K(ee.current),(ce=n.onDismiss)==null||ce.call(n,n),fe(),R(!0);return}(Pe=q.current)==null||Pe.style.setProperty("--swipe-amount","0px"),C(!1)},onPointerMove:Q=>{var ce;if(!Ee.current)return;let Pe=Q.clientY-Ee.current.y,dt=Q.clientX-Ee.current.x,Nt=(jt==="top"?Math.min:Math.max)(0,Pe),Wn=Q.pointerType==="touch"?10:2;Math.abs(Nt)>Wn?(ce=q.current)==null||ce.style.setProperty("--swipe-amount",`${Pe}px`):Math.abs(dt)>Wn&&(Ee.current=null)}},h&&!n.jsx?I.createElement("button",{"aria-label":"Close toast","data-disabled":Cr,"data-close-button":!0,onClick:Cr?void 0:()=>{var Q;fe(),(Q=n.onDismiss)==null||Q.call(n,n)}},I.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},I.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),I.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}))):null,n.jsx||I.isValidElement(n.title)?n.jsx||n.title:I.createElement(I.Fragment,null,oe||n.icon||n.promise?I.createElement("div",{"data-icon":""},n.promise?I.createElement(Uy,{visible:oe==="loading"}):null,n.icon||Dy(oe)):null,I.createElement("div",{"data-content":""},I.createElement("div",{"data-title":""},n.title),n.description?I.createElement("div",{"data-description":"",className:x+$},n.description):null),n.cancel?I.createElement("button",{"data-button":!0,"data-cancel":!0,onClick:()=>{var Q;fe(),(Q=n.cancel)!=null&&Q.onClick&&n.cancel.onClick()}},n.cancel.label):null,n.action?I.createElement("button",{"data-button":"",onClick:Q=>{var ce;(ce=n.action)==null||ce.onClick(Q),!Q.defaultPrevented&&fe()}},n.action.label):null))},ev=e=>{var t;let{invert:n,position:r="bottom-right",hotkey:s=["altKey","KeyT"],expand:i,closeButton:o,className:l,offset:u,theme:c="light",richColors:d,duration:h,style:m,visibleToasts:v=Vy,toastOptions:x}=e,[w,k]=I.useState([]),[p,f]=I.useState([]),[g,b]=I.useState(!1),[P,T]=I.useState(!1),[C,j]=I.useState(c!=="system"?c:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),[R,M]=r.split("-"),K=I.useRef(null),E=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),se=I.useCallback(q=>k(ae=>ae.filter(({id:Z})=>Z!==q.id)),[]);return I.useEffect(()=>Yt.subscribe(q=>{if(q.dismiss){k(ae=>ae.map(Z=>Z.id===q.id?{...Z,delete:!0}:Z));return}setTimeout(()=>{Ug.flushSync(()=>{k(ae=>{let Z=ae.findIndex(oe=>oe.id===q.id);return Z!==-1?[...ae.slice(0,Z),{...ae[Z],...q},...ae.slice(Z+1)]:[q,...ae]})})})}),[]),I.useEffect(()=>{if(c!=="system"){j(c);return}typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",({matches:q})=>{j(q?"dark":"light")})},[c]),I.useEffect(()=>{w.length<=1&&b(!1)},[w]),I.useEffect(()=>{let q=ae=>{var Z,oe;s.every(A=>ae[A]||ae.code===A)&&(b(!0),(Z=K.current)==null||Z.focus()),ae.code==="Escape"&&(document.activeElement===K.current||(oe=K.current)!=null&&oe.contains(document.activeElement))&&b(!1)};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)},[s]),w.length?I.createElement("section",{"aria-label":`Notifications ${E}`,tabIndex:-1},I.createElement("ol",{tabIndex:-1,ref:K,className:l,"data-sonner-toaster":!0,"data-theme":C,"data-rich-colors":d,"data-y-position":R,"data-x-position":M,style:{"--front-toast-height":`${(t=p[0])==null?void 0:t.height}px`,"--offset":typeof u=="number"?`${u}px`:u||Ky,"--width":`${Yy}px`,"--gap":`${Mp}px`,...m},onMouseEnter:()=>b(!0),onMouseMove:()=>b(!0),onMouseLeave:()=>{P||b(!1)},onPointerDown:()=>{T(!0)},onPointerUp:()=>T(!1)},w.map((q,ae)=>I.createElement(Zy,{key:q.id,index:ae,toast:q,duration:h,className:x==null?void 0:x.className,descriptionClassName:x==null?void 0:x.descriptionClassName,invert:n,visibleToasts:v,closeButton:o,interacting:P,position:r,style:x==null?void 0:x.style,removeToast:se,toasts:w,heights:p,setHeights:f,expandByDefault:i,expanded:g})))):null},tv={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const nv=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ne=(e,t)=>{const n=N.forwardRef(({color:r="currentColor",size:s=24,strokeWidth:i=2,absoluteStrokeWidth:o,children:l,...u},c)=>N.createElement("svg",{ref:c,...tv,width:s,height:s,stroke:r,strokeWidth:o?Number(i)*24/Number(s):i,className:`lucide lucide-${nv(e)}`,...u},[...t.map(([d,h])=>N.createElement(d,h)),...(Array.isArray(l)?l:[l])||[]]));return n.displayName=`${e}`,n},eo=ne("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]),Ct=ne("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),sl=ne("AlertTriangle",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"c3ski4"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),rv=ne("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),sv=ne("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]),iv=ne("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]),zn=ne("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["polyline",{points:"22 4 12 14.01 9 11.01",key:"6xbx8j"}]]),_r=ne("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),Fr=ne("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),Mt=ne("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]),av=ne("FileCode",[["path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}],["path",{d:"m10 13-2 2 2 2",key:"17smn8"}],["path",{d:"m14 17 2-2-2-2",key:"14mezr"}]]),Rp=ne("FolderOpen",[["path",{d:"m6 14 1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2h3.93a2 2 0 0 1 1.66.9l.82 1.2a2 2 0 0 0 1.66.9H18a2 2 0 0 1 2 2v2",key:"1nmvlm"}]]),Lp=ne("Home",[["path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"y5dka4"}],["polyline",{points:"9 22 9 12 15 12 15 22",key:"e2us08"}]]),ov=ne("Layers",[["polygon",{points:"12 2 2 7 12 12 22 7 12 2",key:"1b0ttc"}],["polyline",{points:"2 17 12 22 22 17",key:"imjtdl"}],["polyline",{points:"2 12 12 17 22 12",key:"5dexcv"}]]),En=ne("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),ns=ne("MapPin",[["path",{d:"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z",key:"2oe9fu"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]),lv=ne("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]),Hc=ne("PauseCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]),mi=ne("PenSquare",[["path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1qinfi"}],["path",{d:"M18.5 2.5a2.12 2.12 0 0 1 3 3L12 15l-4 1 1-4Z",key:"w2jsv5"}]]),qc=ne("PlayCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]),pr=ne("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),Zt=ne("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),gi=ne("Save",[["path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z",key:"1owoqh"}],["polyline",{points:"17 21 17 13 7 13 7 21",key:"1md35c"}],["polyline",{points:"7 3 7 8 15 8",key:"8nz8an"}]]),uv=ne("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]),Qr=ne("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),cv=ne("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]),dv=ne("ToggleLeft",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]]),fv=ne("ToggleRight",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"16",cy:"12",r:"2",key:"4ma0v8"}]]),rs=ne("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),pv=ne("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]),hv=ne("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),mv=ne("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]),Qc=ne("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),ir=ne("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Ip=ne("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]);function _p(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(n=_p(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function gv(){for(var e,t,n=0,r="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=_p(e))&&(r&&(r+=" "),r+=t);return r}function yv(){for(var e=0,t,n,r="";e<arguments.length;)(t=arguments[e++])&&(n=Fp(t))&&(r&&(r+=" "),r+=n);return r}function Fp(e){if(typeof e=="string")return e;for(var t,n="",r=0;r<e.length;r++)e[r]&&(t=Fp(e[r]))&&(n&&(n+=" "),n+=t);return n}var lu="-";function vv(e){var t=wv(e),n=e.conflictingClassGroups,r=e.conflictingClassGroupModifiers,s=r===void 0?{}:r;function i(l){var u=l.split(lu);return u[0]===""&&u.length!==1&&u.shift(),Dp(u,t)||xv(l)}function o(l,u){var c=n[l]||[];return u&&s[l]?[].concat(c,s[l]):c}return{getClassGroupId:i,getConflictingClassGroupIds:o}}function Dp(e,t){var o;if(e.length===0)return t.classGroupId;var n=e[0],r=t.nextPart.get(n),s=r?Dp(e.slice(1),r):void 0;if(s)return s;if(t.validators.length!==0){var i=e.join(lu);return(o=t.validators.find(function(l){var u=l.validator;return u(i)}))==null?void 0:o.classGroupId}}var Vc=/^\[(.+)\]$/;function xv(e){if(Vc.test(e)){var t=Vc.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}}function wv(e){var t=e.theme,n=e.prefix,r={nextPart:new Map,validators:[]},s=bv(Object.entries(e.classGroups),n);return s.forEach(function(i){var o=i[0],l=i[1];il(l,r,o,t)}),r}function il(e,t,n,r){e.forEach(function(s){if(typeof s=="string"){var i=s===""?t:Kc(t,s);i.classGroupId=n;return}if(typeof s=="function"){if(jv(s)){il(s(r),t,n,r);return}t.validators.push({validator:s,classGroupId:n});return}Object.entries(s).forEach(function(o){var l=o[0],u=o[1];il(u,Kc(t,l),n,r)})})}function Kc(e,t){var n=e;return t.split(lu).forEach(function(r){n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n}function jv(e){return e.isThemeGetter}function bv(e,t){return t?e.map(function(n){var r=n[0],s=n[1],i=s.map(function(o){return typeof o=="string"?t+o:typeof o=="object"?Object.fromEntries(Object.entries(o).map(function(l){var u=l[0],c=l[1];return[t+u,c]})):o});return[r,i]}):e}function Nv(e){if(e<1)return{get:function(){},set:function(){}};var t=0,n=new Map,r=new Map;function s(i,o){n.set(i,o),t++,t>e&&(t=0,r=n,n=new Map)}return{get:function(o){var l=n.get(o);if(l!==void 0)return l;if((l=r.get(o))!==void 0)return s(o,l),l},set:function(o,l){n.has(o)?n.set(o,l):s(o,l)}}}var $p="!";function kv(e){var t=e.separator||":",n=t.length===1,r=t[0],s=t.length;return function(o){for(var l=[],u=0,c=0,d,h=0;h<o.length;h++){var m=o[h];if(u===0){if(m===r&&(n||o.slice(h,h+s)===t)){l.push(o.slice(c,h)),c=h+s;continue}if(m==="/"){d=h;continue}}m==="["?u++:m==="]"&&u--}var v=l.length===0?o:o.substring(c),x=v.startsWith($p),w=x?v.substring(1):v,k=d&&d>c?d-c:void 0;return{modifiers:l,hasImportantModifier:x,baseClassName:w,maybePostfixModifierPosition:k}}}function Sv(e){if(e.length<=1)return e;var t=[],n=[];return e.forEach(function(r){var s=r[0]==="[";s?(t.push.apply(t,n.sort().concat([r])),n=[]):n.push(r)}),t.push.apply(t,n.sort()),t}function Cv(e){return{cache:Nv(e.cacheSize),splitModifiers:kv(e),...vv(e)}}var Ev=/\s+/;function Pv(e,t){var n=t.splitModifiers,r=t.getClassGroupId,s=t.getConflictingClassGroupIds,i=new Set;return e.trim().split(Ev).map(function(o){var l=n(o),u=l.modifiers,c=l.hasImportantModifier,d=l.baseClassName,h=l.maybePostfixModifierPosition,m=r(h?d.substring(0,h):d),v=!!h;if(!m){if(!h)return{isTailwindClass:!1,originalClassName:o};if(m=r(d),!m)return{isTailwindClass:!1,originalClassName:o};v=!1}var x=Sv(u).join(":"),w=c?x+$p:x;return{isTailwindClass:!0,modifierId:w,classGroupId:m,originalClassName:o,hasPostfixModifier:v}}).reverse().filter(function(o){if(!o.isTailwindClass)return!0;var l=o.modifierId,u=o.classGroupId,c=o.hasPostfixModifier,d=l+u;return i.has(d)?!1:(i.add(d),s(u,c).forEach(function(h){return i.add(l+h)}),!0)}).reverse().map(function(o){return o.originalClassName}).join(" ")}function Tv(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,s,i,o=l;function l(c){var d=t[0],h=t.slice(1),m=h.reduce(function(v,x){return x(v)},d());return r=Cv(m),s=r.cache.get,i=r.cache.set,o=u,u(c)}function u(c){var d=s(c);if(d)return d;var h=Pv(c,r);return i(c,h),h}return function(){return o(yv.apply(null,arguments))}}function he(e){var t=function(r){return r[e]||[]};return t.isThemeGetter=!0,t}var Up=/^\[(?:([a-z-]+):)?(.+)\]$/i,Ov=/^\d+\/\d+$/,zv=new Set(["px","full","screen"]),Av=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Mv=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Rv=/^-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/;function pt(e){return Pn(e)||zv.has(e)||Ov.test(e)||al(e)}function al(e){return Un(e,"length",$v)}function Lv(e){return Un(e,"size",Wp)}function Iv(e){return Un(e,"position",Wp)}function _v(e){return Un(e,"url",Uv)}function Xs(e){return Un(e,"number",Pn)}function Pn(e){return!Number.isNaN(Number(e))}function Fv(e){return e.endsWith("%")&&Pn(e.slice(0,-1))}function Dr(e){return Gc(e)||Un(e,"number",Gc)}function X(e){return Up.test(e)}function $r(){return!0}function Qt(e){return Av.test(e)}function Dv(e){return Un(e,"",Wv)}function Un(e,t,n){var r=Up.exec(e);return r?r[1]?r[1]===t:n(r[2]):!1}function $v(e){return Mv.test(e)}function Wp(){return!1}function Uv(e){return e.startsWith("url(")}function Gc(e){return Number.isInteger(Number(e))}function Wv(e){return Rv.test(e)}function Bv(){var e=he("colors"),t=he("spacing"),n=he("blur"),r=he("brightness"),s=he("borderColor"),i=he("borderRadius"),o=he("borderSpacing"),l=he("borderWidth"),u=he("contrast"),c=he("grayscale"),d=he("hueRotate"),h=he("invert"),m=he("gap"),v=he("gradientColorStops"),x=he("gradientColorStopPositions"),w=he("inset"),k=he("margin"),p=he("opacity"),f=he("padding"),g=he("saturate"),b=he("scale"),P=he("sepia"),T=he("skew"),C=he("space"),j=he("translate"),R=function(){return["auto","contain","none"]},M=function(){return["auto","hidden","clip","visible","scroll"]},K=function(){return["auto",X,t]},E=function(){return[X,t]},se=function(){return["",pt]},q=function(){return["auto",Pn,X]},ae=function(){return["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"]},Z=function(){return["solid","dashed","dotted","double","none"]},oe=function(){return["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-lighter"]},A=function(){return["start","end","center","between","around","evenly","stretch"]},$=function(){return["","0",X]},U=function(){return["auto","avoid","all","avoid-page","page","left","right","column"]},re=function(){return[Pn,Xs]},V=function(){return[Pn,X]};return{cacheSize:500,theme:{colors:[$r],spacing:[pt],blur:["none","",Qt,X],brightness:re(),borderColor:[e],borderRadius:["none","","full",Qt,X],borderSpacing:E(),borderWidth:se(),contrast:re(),grayscale:$(),hueRotate:V(),invert:$(),gap:E(),gradientColorStops:[e],gradientColorStopPositions:[Fv,al],inset:K(),margin:K(),opacity:re(),padding:E(),saturate:re(),scale:re(),sepia:$(),skew:V(),space:E(),translate:E()},classGroups:{aspect:[{aspect:["auto","square","video",X]}],container:["container"],columns:[{columns:[Qt]}],"break-after":[{"break-after":U()}],"break-before":[{"break-before":U()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none"]}],clear:[{clear:["left","right","both","none"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[].concat(ae(),[X])}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:R()}],"overscroll-x":[{"overscroll-x":R()}],"overscroll-y":[{"overscroll-y":R()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[w]}],"inset-x":[{"inset-x":[w]}],"inset-y":[{"inset-y":[w]}],start:[{start:[w]}],end:[{end:[w]}],top:[{top:[w]}],right:[{right:[w]}],bottom:[{bottom:[w]}],left:[{left:[w]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Dr]}],basis:[{basis:K()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",X]}],grow:[{grow:$()}],shrink:[{shrink:$()}],order:[{order:["first","last","none",Dr]}],"grid-cols":[{"grid-cols":[$r]}],"col-start-end":[{col:["auto",{span:["full",Dr]},X]}],"col-start":[{"col-start":q()}],"col-end":[{"col-end":q()}],"grid-rows":[{"grid-rows":[$r]}],"row-start-end":[{row:["auto",{span:[Dr]},X]}],"row-start":[{"row-start":q()}],"row-end":[{"row-end":q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",X]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",X]}],gap:[{gap:[m]}],"gap-x":[{"gap-x":[m]}],"gap-y":[{"gap-y":[m]}],"justify-content":[{justify:["normal"].concat(A())}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal"].concat(A(),["baseline"])}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[].concat(A(),["baseline"])}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[f]}],px:[{px:[f]}],py:[{py:[f]}],ps:[{ps:[f]}],pe:[{pe:[f]}],pt:[{pt:[f]}],pr:[{pr:[f]}],pb:[{pb:[f]}],pl:[{pl:[f]}],m:[{m:[k]}],mx:[{mx:[k]}],my:[{my:[k]}],ms:[{ms:[k]}],me:[{me:[k]}],mt:[{mt:[k]}],mr:[{mr:[k]}],mb:[{mb:[k]}],ml:[{ml:[k]}],"space-x":[{"space-x":[C]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[C]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit",X,t]}],"min-w":[{"min-w":["min","max","fit",X,pt]}],"max-w":[{"max-w":["0","none","full","min","max","fit","prose",{screen:[Qt]},Qt,X]}],h:[{h:[X,t,"auto","min","max","fit"]}],"min-h":[{"min-h":["min","max","fit",X,pt]}],"max-h":[{"max-h":[X,t,"min","max","fit"]}],"font-size":[{text:["base",Qt,al]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Xs]}],"font-family":[{font:[$r]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractons"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",X]}],"line-clamp":[{"line-clamp":["none",Pn,Xs]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",X,pt]}],"list-image":[{"list-image":["none",X]}],"list-style-type":[{list:["none","disc","decimal",X]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[p]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[p]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[].concat(Z(),["wavy"])}],"text-decoration-thickness":[{decoration:["auto","from-font",pt]}],"underline-offset":[{"underline-offset":["auto",X,pt]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],indent:[{indent:E()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",X]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",X]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[p]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[].concat(ae(),[Iv])}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Lv]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},_v]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[x]}],"gradient-via-pos":[{via:[x]}],"gradient-to-pos":[{to:[x]}],"gradient-from":[{from:[v]}],"gradient-via":[{via:[v]}],"gradient-to":[{to:[v]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[p]}],"border-style":[{border:[].concat(Z(),["hidden"])}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[p]}],"divide-style":[{divide:Z()}],"border-color":[{border:[s]}],"border-color-x":[{"border-x":[s]}],"border-color-y":[{"border-y":[s]}],"border-color-t":[{"border-t":[s]}],"border-color-r":[{"border-r":[s]}],"border-color-b":[{"border-b":[s]}],"border-color-l":[{"border-l":[s]}],"divide-color":[{divide:[s]}],"outline-style":[{outline:[""].concat(Z())}],"outline-offset":[{"outline-offset":[X,pt]}],"outline-w":[{outline:[pt]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:se()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[p]}],"ring-offset-w":[{"ring-offset":[pt]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Qt,Dv]}],"shadow-color":[{shadow:[$r]}],opacity:[{opacity:[p]}],"mix-blend":[{"mix-blend":oe()}],"bg-blend":[{"bg-blend":oe()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",Qt,X]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[h]}],saturate:[{saturate:[g]}],sepia:[{sepia:[P]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[d]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[p]}],"backdrop-saturate":[{"backdrop-saturate":[g]}],"backdrop-sepia":[{"backdrop-sepia":[P]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",X]}],duration:[{duration:V()}],ease:[{ease:["linear","in","out","in-out",X]}],delay:[{delay:V()}],animate:[{animate:["none","spin","ping","pulse","bounce",X]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[b]}],"scale-x":[{"scale-x":[b]}],"scale-y":[{"scale-y":[b]}],rotate:[{rotate:[Dr,X]}],"translate-x":[{"translate-x":[j]}],"translate-y":[{"translate-y":[j]}],"skew-x":[{"skew-x":[T]}],"skew-y":[{"skew-y":[T]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",X]}],accent:[{accent:["auto",e]}],appearance:["appearance-none"],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",X]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":E()}],"scroll-mx":[{"scroll-mx":E()}],"scroll-my":[{"scroll-my":E()}],"scroll-ms":[{"scroll-ms":E()}],"scroll-me":[{"scroll-me":E()}],"scroll-mt":[{"scroll-mt":E()}],"scroll-mr":[{"scroll-mr":E()}],"scroll-mb":[{"scroll-mb":E()}],"scroll-ml":[{"scroll-ml":E()}],"scroll-p":[{"scroll-p":E()}],"scroll-px":[{"scroll-px":E()}],"scroll-py":[{"scroll-py":E()}],"scroll-ps":[{"scroll-ps":E()}],"scroll-pe":[{"scroll-pe":E()}],"scroll-pt":[{"scroll-pt":E()}],"scroll-pr":[{"scroll-pr":E()}],"scroll-pb":[{"scroll-pb":E()}],"scroll-pl":[{"scroll-pl":E()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","pinch-zoom","manipulation",{pan:["x","left","right","y","up","down"]}]}],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",X]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[pt,Xs]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}}var Hv=Tv(Bv);function qv(...e){return Hv(gv(e))}const Qv=[{name:"Dashboard",href:"/",icon:Lp},{name:"Organizations",href:"/organizations",icon:Qr},{name:"Service Mappings",href:"/service-mappings",icon:ns}];function Vv({children:e}){const t=Ts(),[n,r]=N.useState(null);return N.useEffect(()=>{fetch("/api/health").then(s=>s.json()).then(s=>r({version:s.version,environment:s.environment})).catch(()=>r(null))},[]),a.jsxs("div",{className:"min-h-screen bg-background",style:{minHeight:"100vh",backgroundColor:"#ffffff"},children:[a.jsx("header",{className:"border-b border-border bg-card",style:{backgroundColor:"#f8f9fa",borderBottom:"1px solid #e0e0e0"},children:a.jsx("div",{className:"flex h-16 items-center px-6",children:a.jsxs("div",{className:"flex items-center space-x-4",children:[a.jsx(lv,{className:"h-6 w-6 md:hidden"}),a.jsx("h1",{className:"text-xl font-semibold text-foreground",style:{color:"#000000",fontSize:"1.25rem",fontWeight:"600"},children:"AI Agent Service"})]})})}),a.jsxs("div",{className:"flex",children:[a.jsx("aside",{className:"hidden w-64 border-r border-border bg-card md:block",children:a.jsx("nav",{className:"space-y-1 p-4",children:Qv.map(s=>{const i=t.pathname===s.href||s.href!=="/"&&t.pathname.startsWith(s.href);return a.jsxs(jp,{to:s.href,className:qv("flex items-center space-x-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors",i?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[a.jsx(s.icon,{className:"h-5 w-5"}),a.jsx("span",{children:s.name})]},s.name)})})}),a.jsx("main",{className:"flex-1 p-6",children:a.jsx("div",{className:"mx-auto max-w-7xl",children:e})})]}),a.jsx("footer",{className:"border-t border-border bg-card px-6 py-3",style:{backgroundColor:"#f8f9fa",borderTop:"1px solid #e0e0e0"},children:a.jsxs("div",{className:"flex justify-between items-center text-xs text-gray-500",children:[a.jsx("span",{children:"AI Agent Service"}),n&&a.jsxs("span",{children:["v",n.version]})]})})]})}const Kv={}.VITE_API_URL||"/api";function Gv(e){const t=e.startsWith("/")?e.slice(1):e;return`${Kv}/${t}`}async function Zs(e,t){const n=Gv(e);try{const r=await fetch(n,{...t,headers:{"Content-Type":"application/json",...t==null?void 0:t.headers}});if(!r.ok)throw new Error(`API request failed: ${r.status} ${r.statusText}`);return r}catch(r){throw console.error(`API request error for ${e}:`,r),r}}const ei={health:"health",ready:"ready",analysis:"analysis",analysisStatus:e=>`analysis/${e}`,queueQueued:"queue/queued",queueInProgress:"queue/in-progress",queueCompleted:"queue/completed",queueFailed:"queue/failed",workItemsHealth:"work-items/health",workItemsErrors:"work-items/errors",workItemsLogs:"work-items/logs",errorsRecent:"errors/recent",workspaceDiscover:"workspace/discover",workspaceList:"workspace/list",workspaceStats:e=>e?`workspace/stats/${e}`:"workspace/stats",websocketStatus:"websocket/status",websocketActivity:"websocket/activity",websocketWorker:"websocket/worker",websocketReconnect:"websocket/reconnect",usageStats:"usage/stats",usageHistory:"usage/history",usageRateLimit:"usage/rate-limit",analyticsProjects:"analytics/projects",analyticsStats:"analytics/stats",analyticsOperations:"analytics/operations"};function Yv(){var j,R,M,K;const[e,t]=N.useState(null),[n,r]=N.useState(null),[s,i]=N.useState(null),[o,l]=N.useState(null),[u,c]=N.useState(!0),[d,h]=N.useState(null),[m,v]=N.useState("queued"),[x,w]=N.useState(null);N.useEffect(()=>{const E=async()=>{try{c(!0),h(null);const[q,ae,Z,oe]=await Promise.allSettled([Zs(ei.queueQueued),Zs(ei.queueInProgress),Zs(ei.queueCompleted+"?limit=10"),Zs(ei.queueFailed+"?limit=10")]);if(q.status==="fulfilled"&&q.value.ok){const A=await q.value.json();t(A.data)}if(ae.status==="fulfilled"&&ae.value.ok){const A=await ae.value.json();r(A.data)}if(Z.status==="fulfilled"&&Z.value.ok){const A=await Z.value.json();i(A.data)}if(oe.status==="fulfilled"&&oe.value.ok){const A=await oe.value.json();l(A.data)}}catch(q){h(q instanceof Error?q.message:"Failed to fetch work queue data")}finally{c(!1)}};E();const se=setInterval(E,1e4);return()=>clearInterval(se)},[]);const k=E=>{const se=Math.floor(E/60),q=Math.floor(se/60);return q>0?`${q}h ${se%60}m`:se>0?`${se}m`:`${E}s`},p=E=>{const se=new Date,q=new Date(E),ae=se.getTime()-q.getTime(),Z=Math.floor(ae/(1e3*60));if(Z<1)return"Just now";if(Z<60)return`${Z}m ago`;const oe=Math.floor(Z/60);return oe<24?`${oe}h ago`:`${Math.floor(oe/24)}d ago`},f=E=>{switch(E){case"project_review":return"📋";case"code_review":return"🔍";case"story_implementation":return"⚡";case"development_planning":return"📊";default:return"📄"}},g=E=>E>=9?"text-red-600 bg-red-50":E>=7?"text-orange-600 bg-orange-50":E>=5?"text-yellow-600 bg-yellow-50":"text-green-600 bg-green-50",b=E=>E>=9?"Critical":E>=7?"High":E>=5?"Medium":"Low",P=E=>{switch(E){case"completed":return a.jsx(zn,{className:"w-4 h-4 text-green-600"});case"failed":return a.jsx(Ct,{className:"w-4 h-4 text-red-600"});case"in_progress":return a.jsx(En,{className:"w-4 h-4 text-blue-600 animate-spin"});case"queued":return a.jsx(Mt,{className:"w-4 h-4 text-yellow-600"});default:return a.jsx(Mt,{className:"w-4 h-4 text-gray-400"})}},T=E=>{switch(E){case"completed":return"text-green-600 bg-green-50 border-green-200";case"failed":return"text-red-600 bg-red-50 border-red-200";case"in_progress":return"text-blue-600 bg-blue-50 border-blue-200";case"queued":return"text-yellow-600 bg-yellow-50 border-yellow-200";default:return"text-gray-600 bg-gray-50 border-gray-200"}},C=(E,se)=>{var q;return a.jsxs("div",{className:"border rounded-lg p-4 hover:bg-gray-50 transition-colors",children:[a.jsxs("div",{className:"flex items-start justify-between mb-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-lg",children:f(E.type)}),a.jsxs("div",{children:[a.jsx("h4",{className:"font-medium text-sm",children:E.title}),a.jsx("p",{className:"text-xs text-gray-600",children:E.projectName})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[se==="completed"&&a.jsxs("span",{className:`px-2 py-1 rounded border text-xs font-medium flex items-center gap-1 ${T(E.status)}`,children:[P(E.status),E.status==="completed"?"Success":E.status==="failed"?"Failed":E.status]}),a.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${g(E.priority)}`,children:b(E.priority)}),E.estimatedDuration&&a.jsxs("span",{className:"text-xs text-gray-500 flex items-center gap-1",children:[a.jsx(Mt,{className:"w-3 h-3"}),k(E.estimatedDuration)]}),E.actualDuration&&se==="completed"&&a.jsxs("span",{className:"text-xs text-gray-500 flex items-center gap-1",children:[a.jsx(Mt,{className:"w-3 h-3"}),k(Math.round(E.actualDuration/1e3))," actual"]})]})]}),E.description&&a.jsx("p",{className:"text-xs text-gray-600 mb-2 line-clamp-2",children:E.description}),E.progress&&E.status==="in_progress"&&a.jsxs("div",{className:"mb-2",children:[a.jsxs("div",{className:"flex justify-between text-xs text-gray-600 mb-1",children:[a.jsx("span",{children:E.progress.currentStep}),a.jsxs("span",{children:[E.progress.percentage,"%"]})]}),a.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2",children:a.jsx("div",{className:"bg-blue-600 h-2 rounded-full transition-all duration-300",style:{width:`${E.progress.percentage}%`}})})]}),E.status==="failed"&&a.jsxs("div",{className:"mb-2 p-2 bg-red-50 rounded border border-red-200 flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ct,{className:"w-4 h-4 text-red-600"}),a.jsx("span",{className:"text-xs text-red-800 font-medium",children:"Work item failed"}),((q=E.metadata)==null?void 0:q.failedAt)&&a.jsxs("span",{className:"text-xs text-red-600",children:["• Failed: ",p(E.metadata.failedAt)]})]}),a.jsx("button",{onClick:ae=>{ae.stopPropagation(),w(E)},className:"px-2 py-1 text-xs bg-red-100 text-red-700 hover:bg-red-200 rounded transition-colors",children:"View Details"})]}),a.jsxs("div",{className:"flex justify-between items-center text-xs text-gray-500",children:[a.jsxs("span",{children:["Created ",p(E.createdAt)]}),E.assignedTo&&a.jsx("span",{className:"bg-blue-100 text-blue-800 px-2 py-1 rounded",children:E.assignedTo}),E.completedAt&&a.jsxs("span",{className:"text-green-600",children:["Completed ",p(E.completedAt)]})]})]},`${se}-${E.id}`)};return u?a.jsx("div",{className:"rounded-lg border bg-card p-6",children:a.jsxs("div",{className:"flex items-center justify-center py-8",children:[a.jsx(En,{className:"h-8 w-8 animate-spin text-blue-600"}),a.jsx("span",{className:"ml-2 text-sm text-gray-600",children:"Loading work queue..."})]})}):d?a.jsx("div",{className:"rounded-lg border bg-card p-6",children:a.jsxs("div",{className:"flex items-center justify-center py-8 text-red-600",children:[a.jsx(Ct,{className:"h-6 w-6 mr-2"}),a.jsx("span",{className:"text-sm",children:d})]})}):a.jsxs("div",{className:"rounded-lg border bg-card",children:[a.jsxs("div",{className:"p-6 border-b",children:[a.jsx("h3",{className:"text-lg font-medium mb-4",children:"Work Queue Status"}),a.jsxs("div",{className:"flex space-x-1 bg-gray-100 rounded-lg p-1",children:[a.jsxs("button",{onClick:()=>v("queued"),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-md text-sm font-medium transition-colors ${m==="queued"?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:[a.jsx(Hc,{className:"w-4 h-4"}),"Queued (",(e==null?void 0:e.total)||0,")"]}),a.jsxs("button",{onClick:()=>v("progress"),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-md text-sm font-medium transition-colors ${m==="progress"?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:[a.jsx(qc,{className:"w-4 h-4"}),"In Progress (",(n==null?void 0:n.total)||0,")"]}),a.jsxs("button",{onClick:()=>v("completed"),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-md text-sm font-medium transition-colors ${m==="completed"?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:[a.jsx(zn,{className:"w-4 h-4"}),"Recent (",(s==null?void 0:s.total)||0,")"]}),a.jsxs("button",{onClick:()=>v("failed"),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-md text-sm font-medium transition-colors ${m==="failed"?"bg-white text-red-600 shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:[a.jsx(Ct,{className:"w-4 h-4"}),"Failed (",(o==null?void 0:o.total)||0,")"]})]})]}),a.jsxs("div",{className:"p-6",children:[m==="queued"&&(e==null?void 0:e.estimatedWaitTime)&&a.jsx("div",{className:"mb-4 p-3 bg-yellow-50 rounded-lg border border-yellow-200",children:a.jsxs("p",{className:"text-sm text-yellow-800",children:[a.jsx(Mt,{className:"w-4 h-4 inline mr-1"}),"Estimated wait time: ",k(e.estimatedWaitTime)]})}),m==="progress"&&(n==null?void 0:n.totalEstimatedRemaining)&&a.jsx("div",{className:"mb-4 p-3 bg-blue-50 rounded-lg border border-blue-200",children:a.jsxs("p",{className:"text-sm text-blue-800",children:[a.jsx(En,{className:"w-4 h-4 inline mr-1"}),"Estimated remaining time: ",k(n.totalEstimatedRemaining)]})}),a.jsxs("div",{className:"space-y-3",children:[m==="queued"&&a.jsx(a.Fragment,{children:(e==null?void 0:e.items.length)===0?a.jsxs("div",{className:"text-center py-8 text-gray-500",children:[a.jsx(Hc,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:"No items in queue"})]}):e==null?void 0:e.items.map(E=>C(E,"queued"))}),m==="progress"&&a.jsx(a.Fragment,{children:(n==null?void 0:n.items.length)===0?a.jsxs("div",{className:"text-center py-8 text-gray-500",children:[a.jsx(qc,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:"No items in progress"})]}):n==null?void 0:n.items.map(E=>C(E,"progress"))}),m==="completed"&&a.jsx(a.Fragment,{children:(s==null?void 0:s.items.length)===0?a.jsxs("div",{className:"text-center py-8 text-gray-500",children:[a.jsx(zn,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:"No completed items"})]}):s==null?void 0:s.items.map(E=>C(E,"completed"))}),m==="failed"&&a.jsx(a.Fragment,{children:(o==null?void 0:o.items.length)===0?a.jsxs("div",{className:"text-center py-8 text-gray-500",children:[a.jsx(Ct,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:"No failed items"})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"mb-4 p-3 bg-red-50 rounded-lg border border-red-200",children:a.jsxs("p",{className:"text-sm text-red-800",children:[a.jsx(Ct,{className:"w-4 h-4 inline mr-1"}),(o==null?void 0:o.total)||0," work items have failed and may need attention"]})}),o==null?void 0:o.items.map(E=>C(E,"failed"))]})})]}),m==="completed"&&(s==null?void 0:s.hasMore)&&a.jsx("div",{className:"mt-4 text-center",children:a.jsx("button",{className:"px-4 py-2 text-sm text-blue-600 hover:text-blue-800 hover:bg-blue-50 rounded-lg transition-colors",children:"Load more completed items"})})]}),x&&a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-white rounded-lg p-6 max-w-2xl w-full mx-4 max-h-[80vh] overflow-y-auto",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ct,{className:"w-5 h-5 text-red-600"}),a.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Error Details"})]}),a.jsx("button",{onClick:()=>w(null),className:"text-gray-400 hover:text-gray-600 transition-colors",children:a.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"border rounded-lg p-4 bg-gray-50",children:[a.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:"Work Item Information"}),a.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-gray-600",children:"Type:"}),a.jsx("span",{className:"ml-2",children:x.type})]}),a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-gray-600",children:"Status:"}),a.jsx("span",{className:"ml-2 text-red-600",children:"Failed"})]}),a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-gray-600",children:"Project:"}),a.jsx("span",{className:"ml-2",children:x.projectName})]}),a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-gray-600",children:"Created:"}),a.jsxs("span",{className:"ml-2",children:[p(x.createdAt)," ago"]})]}),x.completedAt&&a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-gray-600",children:"Failed:"}),a.jsxs("span",{className:"ml-2",children:[p(x.completedAt)," ago"]})]}),x.assignedTo&&a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-gray-600",children:"Assigned to:"}),a.jsx("span",{className:"ml-2",children:x.assignedTo})]})]})]}),a.jsxs("div",{className:"border rounded-lg p-4 bg-red-50 border-red-200",children:[a.jsxs("h3",{className:"font-medium text-red-900 mb-2 flex items-center gap-2",children:[a.jsx(Ct,{className:"w-4 h-4"}),"Error Message"]}),a.jsx("p",{className:"text-red-800 text-sm",children:((j=x.metadata)==null?void 0:j.reason)||((R=x.metadata)==null?void 0:R.failureReason)||((M=x.metadata)==null?void 0:M.error)||"No specific error message available"})]}),((K=x.metadata)==null?void 0:K.errorHistory)&&x.metadata.errorHistory.length>0&&a.jsxs("div",{className:"border rounded-lg p-4",children:[a.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:"Attempt History"}),a.jsxs("div",{className:"text-sm text-gray-600",children:[a.jsxs("p",{className:"mb-2",children:["This work item failed after ",x.metadata.errorHistory.length," attempt",x.metadata.errorHistory.length>1?"s":"",":"]}),a.jsx("div",{className:"space-y-2",children:x.metadata.errorHistory.map((E,se)=>a.jsxs("div",{className:"flex items-center justify-between p-2 bg-gray-50 rounded",children:[a.jsxs("span",{children:["Attempt #",E.attemptNumber||se+1]}),a.jsx("span",{className:"text-xs text-gray-500",children:E.timestamp&&p(E.timestamp)})]},se))})]})]}),x.metadata&&Object.keys(x.metadata).length>0&&a.jsxs("div",{className:"border rounded-lg p-4",children:[a.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:"Additional Information"}),a.jsxs("details",{className:"text-sm",children:[a.jsx("summary",{className:"cursor-pointer text-gray-600 hover:text-gray-800",children:"View raw metadata"}),a.jsx("pre",{className:"mt-2 text-xs bg-gray-50 p-2 rounded overflow-x-auto",children:JSON.stringify(x.metadata,null,2)})]})]})]}),a.jsx("div",{className:"flex justify-end mt-6",children:a.jsx("button",{onClick:()=>w(null),className:"px-4 py-2 bg-gray-100 text-gray-700 rounded hover:bg-gray-200 transition-colors",children:"Close"})})]})})]})}function Jv(){const[e,t]=N.useState(null),[n,r]=N.useState(!0),[s,i]=N.useState(!1);N.useEffect(()=>{const d=async()=>{try{const m=await fetch("/api/smart-polling/metrics");if(m.ok){const v=await m.json();t(v.data)}}catch(m){console.error("Failed to fetch smart polling metrics:",m)}finally{r(!1)}};d();const h=setInterval(d,1e4);return()=>clearInterval(h)},[]);const o=async()=>{i(!0);try{if((await fetch("/api/smart-polling/force",{method:"POST"})).ok){const h=await fetch("/api/smart-polling/metrics");if(h.ok){const m=await h.json();t(m.data)}}}catch(d){console.error("Failed to force polling:",d)}finally{i(!1)}},l=d=>d<1e3?`${d}ms`:d<6e4?`${Math.round(d/1e3)}s`:`${Math.round(d/6e4)}m`,u=d=>{if(!d)return"Never";const h=new Date(d),v=new Date().getTime()-h.getTime();return v<6e4?`${Math.round(v/1e3)}s ago`:v<36e5?`${Math.round(v/6e4)}m ago`:h.toLocaleTimeString()},c=d=>d.isPolling?d.consecutiveErrors>=3?a.jsx(sl,{className:"h-4 w-4 text-red-500"}):d.consecutiveErrors>0?a.jsx(Mt,{className:"h-4 w-4 text-yellow-500"}):a.jsx(zn,{className:"h-4 w-4 text-green-500"}):a.jsx(cv,{className:"h-4 w-4 text-gray-500"});return n||!e?a.jsxs("div",{className:"rounded-lg border bg-card",children:[a.jsx("div",{className:"border-b border-border p-4",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(eo,{className:"h-5 w-5"}),a.jsx("h3",{className:"text-lg font-medium",children:"Smart Polling Status"})]})}),a.jsx("div",{className:"p-6",children:a.jsx("div",{className:"animate-pulse",children:a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"h-4 bg-muted rounded"}),a.jsx("div",{className:"h-4 bg-muted rounded w-3/4"}),a.jsx("div",{className:"h-4 bg-muted rounded w-1/2"})]})})})]}):a.jsxs("div",{className:"rounded-lg border bg-card",children:[a.jsx("div",{className:"border-b border-border p-4",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(eo,{className:"h-5 w-5"}),a.jsx("h3",{className:"text-lg font-medium",children:"Smart Polling Status"}),a.jsxs("div",{className:"ml-auto flex items-center gap-4 text-sm text-muted-foreground",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500"}),"Active: ",e.activePolling,"/",e.totalOrganizations]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Ip,{className:"h-3 w-3"}),"Avg: ",l(e.averageInterval)]}),a.jsxs("button",{onClick:o,disabled:s,className:"flex items-center gap-1 px-2 py-1 text-xs bg-blue-500 hover:bg-blue-600 disabled:bg-blue-300 text-white rounded transition-colors",title:"Force immediate polling for all organizations",children:[a.jsx(Zt,{className:`h-3 w-3 ${s?"animate-spin":""}`}),s?"Polling...":"Force Poll"]})]})]})}),a.jsxs("div",{className:"p-6",children:[a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-6",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"text-2xl font-bold text-blue-600",children:e.totalPolls}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Polls"})]}),a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"text-2xl font-bold text-green-600",children:e.totalClaimedWork}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"Work Claimed"})]}),a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"text-2xl font-bold text-red-600",children:e.totalErrors}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Errors"})]}),a.jsxs("div",{className:"text-center",children:[a.jsxs("div",{className:"text-2xl font-bold text-purple-600",children:[(e.errorRate*100).toFixed(1),"%"]}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"Error Rate"})]})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-3",children:"Organization Status"}),e.organizationStats.length===0?a.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[a.jsx(eo,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:"No organizations configured"})]}):e.organizationStats.map(d=>a.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted/50",children:[a.jsx("div",{className:"flex-shrink-0",children:c(d)}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx("p",{className:"font-medium truncate",children:d.organizationName}),a.jsx("span",{className:`text-xs px-2 py-1 rounded ${d.isPolling?"bg-green-100 text-green-700":"bg-gray-100 text-gray-700"}`,children:d.isPolling?"Polling":"Stopped"})]}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2 text-xs text-muted-foreground",children:[a.jsxs("div",{children:[a.jsx("span",{className:"font-medium",children:"Interval:"})," ",l(d.currentInterval)]}),a.jsxs("div",{children:[a.jsx("span",{className:"font-medium",children:"Last Poll:"})," ",u(d.lastPollAt)]}),a.jsxs("div",{children:[a.jsx("span",{className:"font-medium",children:"Work Claimed:"})," ",d.claimedWorkCount]}),a.jsxs("div",{className:d.consecutiveErrors>0?"text-red-600":"",children:[a.jsx("span",{className:"font-medium",children:"Errors:"})," ",d.totalErrors,d.consecutiveErrors>0&&` (${d.consecutiveErrors} consecutive)`]})]})]}),a.jsxs("div",{className:"flex-shrink-0 text-right",children:[a.jsx("div",{className:"text-sm font-medium",children:d.totalPolls}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"polls"})]})]},d.organizationId))]}),a.jsxs("div",{className:"mt-6 p-3 bg-muted/30 rounded-lg",children:[a.jsx("div",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Status Indicators"}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2 text-xs",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(zn,{className:"h-3 w-3 text-green-500"}),a.jsx("span",{children:"Healthy polling"})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Mt,{className:"h-3 w-3 text-yellow-500"}),a.jsx("span",{children:"Some errors"})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(sl,{className:"h-3 w-3 text-red-500"}),a.jsx("span",{children:"Multiple failures"})]})]})]})]})]})}function Xv(){const[e,t]=N.useState(null),[n,r]=N.useState(!0);N.useEffect(()=>{const i=async()=>{try{const l=await fetch("/api/queue/stats");if(l.ok){const u=await l.json();t({queued:u.queued,inProgress:u.inProgress,completedToday:u.completed,completedThisWeek:u.completed,averageCompletionTime:u.averageCompletionTime*1e3,successRate:u.successRate,activeAgents:u.workers,totalProcessed:u.total})}}catch(l){console.error("Failed to fetch queue stats:",l)}finally{r(!1)}};i();const o=setInterval(i,3e4);return()=>clearInterval(o)},[]);const s=i=>i<1e3?`${i}ms`:i<6e4?`${(i/1e3).toFixed(1)}s`:`${(i/6e4).toFixed(1)}m`;return a.jsxs(a.Fragment,{children:[a.jsx(pn,{children:a.jsx("title",{children:"Dashboard - AI Agent Service"})}),a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Dashboard"}),a.jsx("p",{className:"text-muted-foreground",children:"Overview of your AI Agent Service performance"})]}),a.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[a.jsxs("div",{className:"rounded-lg border bg-card p-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Total Tasks"}),a.jsx("div",{className:"text-2xl font-bold text-blue-600",children:n?"-":(e==null?void 0:e.totalProcessed)||0})]}),a.jsx(sv,{className:"h-8 w-8 text-blue-600"})]}),a.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"All time"})]}),a.jsxs("div",{className:"rounded-lg border bg-card p-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Success Rate"}),a.jsx("div",{className:"text-2xl font-bold text-green-600",children:n?"-":`${Math.round(((e==null?void 0:e.successRate)||0)*100)}%`})]}),a.jsx(pv,{className:"h-8 w-8 text-green-600"})]}),a.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Overall performance"})]}),a.jsxs("div",{className:"rounded-lg border bg-card p-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Avg Completion Time"}),a.jsx("div",{className:"text-2xl font-bold text-purple-600",children:n?"-":s((e==null?void 0:e.averageCompletionTime)||0)})]}),a.jsx(Mt,{className:"h-8 w-8 text-purple-600"})]}),a.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Per task"})]}),a.jsxs("div",{className:"rounded-lg border bg-card p-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Active Agents"}),a.jsx("div",{className:"text-2xl font-bold text-orange-600",children:n?"-":(e==null?void 0:e.activeAgents)||0})]}),a.jsx(mv,{className:"h-8 w-8 text-orange-600"})]}),a.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Currently active"})]})]}),a.jsx(Jv,{}),a.jsx(Yv,{}),a.jsxs("div",{className:"rounded-lg border bg-card p-6",children:[a.jsx("h3",{className:"text-lg font-medium mb-4",children:"Welcome to AI Agent Service"}),a.jsx("p",{className:"text-muted-foreground",children:"This dashboard provides insights into your AI agent performance across multiple Task Shepherd organizations. Visit the Organizations page to manage connections and the Analytics page for detailed metrics."})]})]})]})}const Zv=({organizationId:e,onComplete:t,onCancel:n})=>{const[r,s]=N.useState({id:"",name:"",description:""}),[i,o]=N.useState(!1),[l,u]=N.useState(null),c=async h=>{h.preventDefault(),u(null),o(!0);try{const m=await fetch(`/api/organizations/${e}/workspaces`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,services:[]})});if(!m.ok){const x=await m.json();throw new Error(x.error||"Failed to create workspace")}const v=await m.json();if(v.success)t(v.data);else throw new Error(v.error||"Failed to create workspace")}catch(m){console.error("Failed to create workspace:",m),u(m instanceof Error?m.message:"Failed to create workspace")}finally{o(!1)}},d=r.id.trim()&&r.name.trim();return a.jsxs("div",{className:"max-w-2xl mx-auto bg-white rounded-lg shadow-lg",children:[a.jsx("div",{className:"px-6 py-4 border-b border-gray-200",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Register Workspace"}),a.jsx("button",{onClick:n,className:"text-gray-400 hover:text-gray-600",children:a.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),a.jsxs("form",{onSubmit:c,className:"p-6 space-y-6",children:[l&&a.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:a.jsx("p",{className:"text-sm text-red-700",children:l})}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"id",className:"block text-sm font-medium text-gray-700 mb-1",children:["Workspace ID ",a.jsx("span",{className:"text-red-500",children:"*"})]}),a.jsx("input",{type:"text",id:"id",value:r.id,onChange:h=>s({...r,id:h.target.value}),className:"block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500",placeholder:"my-workspace",required:!0}),a.jsx("p",{className:"mt-1 text-sm text-gray-500",children:'A unique identifier for this workspace (e.g., "my-app", "project-name")'})]}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"name",className:"block text-sm font-medium text-gray-700 mb-1",children:["Workspace Name ",a.jsx("span",{className:"text-red-500",children:"*"})]}),a.jsx("input",{type:"text",id:"name",value:r.name,onChange:h=>s({...r,name:h.target.value}),className:"block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500",placeholder:"My Workspace",required:!0}),a.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"A human-readable name for the workspace"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"description",className:"block text-sm font-medium text-gray-700 mb-1",children:"Description"}),a.jsx("textarea",{id:"description",value:r.description,onChange:h=>s({...r,description:h.target.value}),rows:3,className:"block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500",placeholder:"Optional description of this workspace"}),a.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Optional description of what this workspace contains"})]}),a.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:[a.jsx("h3",{className:"text-sm font-medium text-blue-800 mb-2",children:"Note"}),a.jsx("p",{className:"text-sm text-blue-700",children:"The agent will handle mapping this workspace to a local path. You can manage services and additional workspace configuration through the main Task Shepherd UI after registration."})]}),a.jsxs("div",{className:"flex justify-end space-x-3 pt-4 border-t border-gray-200",children:[a.jsx("button",{type:"button",onClick:n,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50",children:"Cancel"}),a.jsx("button",{type:"submit",disabled:!d||i,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",children:i?"Creating...":"Register Workspace"})]})]})]})},ex=({organizationId:e,workspace:t,onClose:n,onApplyChanges:r})=>{var C;const[s,i]=N.useState(!1),[o,l]=N.useState(null),[u,c]=N.useState(new Set),[d,h]=N.useState(null),[m,v]=N.useState({}),x=async()=>{i(!0);try{const j=await fetch(`/api/organizations/${e}/workspaces/${t.id}/analyze`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!j.ok)throw new Error("Failed to analyze workspace");const R=await j.json();if(R.success)l(R.data);else throw new Error(R.error||"Analysis failed")}catch(j){console.error("Workspace analysis failed:",j),alert(j instanceof Error?j.message:"Failed to analyze workspace")}finally{i(!1)}},w=j=>{switch(j){case"found":return a.jsx(zn,{className:"w-4 h-4 text-green-500"});case"outdated":return a.jsx(sl,{className:"w-4 h-4 text-yellow-500"});case"missing":return a.jsx(Qc,{className:"w-4 h-4 text-red-500"});default:return null}},k=j=>{switch(j){case"add_service":return a.jsx(pr,{className:"w-4 h-4 text-green-500"});case"update_service":return a.jsx(Zt,{className:"w-4 h-4 text-blue-500"});case"remove_service":return a.jsx(Qc,{className:"w-4 h-4 text-red-500"});default:return a.jsx(rv,{className:"w-4 h-4 text-gray-500"})}},p=j=>{const R=new Set(u);R.has(j)?R.delete(j):R.add(j),c(R)},f=()=>{if(!o||u.size===0)return;const j=Array.from(u).map(R=>o.improvements[R]);r==null||r(j),n()},g=j=>{h(j.name),v({name:j.name,type:j.type,technology:j.technology,port:j.port,description:j.description})},b=()=>{h(null),v({})},P=async()=>{if(d)try{const j=await fetch(`/api/organizations/${e}/workspaces/${t.id}/services/${d}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)}),R=await j.json();if(j.ok&&R.success)h(null),v({}),await x();else throw new Error(R.error||"Failed to update service")}catch(j){console.error("Failed to update service:",j),alert(j instanceof Error?j.message:"Failed to update service")}},T=async j=>{if(confirm(`Are you sure you want to remove the service "${j}"? This action cannot be undone.`))try{const R=await fetch(`/api/organizations/${e}/workspaces/${t.id}/services/${j}`,{method:"DELETE"}),M=await R.json();if(R.ok&&M.success)await x();else throw new Error(M.error||"Failed to remove service")}catch(R){console.error("Failed to remove service:",R),alert(R instanceof Error?R.message:"Failed to remove service")}};return a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50",children:a.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-6xl w-full max-h-[90vh] overflow-hidden",children:[a.jsxs("div",{className:"px-6 py-4 border-b border-gray-200",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h1",{className:"text-2xl font-bold text-gray-900",children:["Analyze Workspace: ",t.name]}),a.jsx("button",{onClick:n,className:"text-gray-400 hover:text-gray-600",children:a.jsx(ir,{className:"w-6 h-6"})})]}),a.jsx("p",{className:"mt-2 text-sm text-gray-600",children:"Analyze the current workspace configuration and discover improvements"})]}),a.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-140px)]",children:[!o&&a.jsxs("div",{className:"text-center py-12",children:[a.jsxs("div",{className:"mb-6",children:[a.jsx("div",{className:"w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center mx-auto mb-4",children:a.jsx(Zt,{className:"w-8 h-8 text-blue-600"})}),a.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"Ready to Analyze Workspace"}),a.jsx("p",{className:"text-gray-600 mb-6 max-w-md mx-auto",children:"This will scan the workspace directory and compare it with your current configuration to suggest improvements."}),a.jsx("div",{className:"bg-gray-50 rounded-lg p-4 mb-6",children:a.jsxs("div",{className:"text-sm text-gray-700",children:[a.jsxs("div",{children:[a.jsx("strong",{children:"Workspace:"})," ",t.name]}),a.jsxs("div",{children:[a.jsx("strong",{children:"Path:"})," ",a.jsx("code",{className:"font-mono text-xs",children:t.path})]}),a.jsxs("div",{children:[a.jsx("strong",{children:"Current services:"})," ",((C=t.services)==null?void 0:C.length)||0]})]})})]}),a.jsx("button",{onClick:x,disabled:s,className:"inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",children:s?a.jsxs(a.Fragment,{children:[a.jsx(Zt,{className:"w-4 h-4 mr-2 animate-spin"}),"Analyzing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Zt,{className:"w-4 h-4 mr-2"}),"Start Analysis"]})})]}),o&&a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:[a.jsx("h3",{className:"text-lg font-medium text-blue-900 mb-2",children:"Analysis Summary"}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-blue-800 font-medium",children:"Current Services"}),a.jsxs("div",{className:"text-blue-600",children:[o.currentServices.length," configured"]})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-blue-800 font-medium",children:"Discovered Services"}),a.jsxs("div",{className:"text-blue-600",children:[o.discoveredServices.length," found"]})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-blue-800 font-medium",children:"Improvements"}),a.jsxs("div",{className:"text-blue-600",children:[o.improvements.length," suggested"]})]})]})]}),a.jsxs("div",{className:"bg-white border border-gray-200 rounded-lg p-4",children:[a.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Current Services Status"}),o.currentServices.length>0?a.jsx("div",{className:"space-y-2",children:o.currentServices.map((j,R)=>a.jsx("div",{className:"p-3 bg-gray-50 rounded-lg border",children:d===j.name?a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Name"}),a.jsx("input",{type:"text",value:m.name||"",onChange:M=>v({...m,name:M.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Type"}),a.jsxs("select",{value:m.type||"backend",onChange:M=>v({...m,type:M.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",children:[a.jsx("option",{value:"backend",children:"Backend"}),a.jsx("option",{value:"frontend",children:"Frontend"}),a.jsx("option",{value:"database",children:"Database"}),a.jsx("option",{value:"cache",children:"Cache"}),a.jsx("option",{value:"queue",children:"Queue"}),a.jsx("option",{value:"api",children:"API"}),a.jsx("option",{value:"service",children:"Service"}),a.jsx("option",{value:"other",children:"Other"})]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Technology"}),a.jsx("input",{type:"text",value:m.technology||"",onChange:M=>v({...m,technology:M.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"e.g., Node.js, Python"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Port"}),a.jsx("input",{type:"number",value:m.port||"",onChange:M=>v({...m,port:M.target.value?parseInt(M.target.value):void 0}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"3000"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Description"}),a.jsx("input",{type:"text",value:m.description||"",onChange:M=>v({...m,description:M.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"Optional description"})]}),a.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[a.jsxs("button",{onClick:P,className:"inline-flex items-center px-3 py-1 text-xs bg-green-600 text-white rounded hover:bg-green-700",children:[a.jsx(gi,{className:"h-3 w-3 mr-1"}),"Save"]}),a.jsxs("button",{onClick:b,className:"inline-flex items-center px-3 py-1 text-xs bg-gray-600 text-white rounded hover:bg-gray-700",children:[a.jsx(ir,{className:"h-3 w-3 mr-1"}),"Cancel"]})]})]}):a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[w(j.status),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium",children:j.name}),a.jsxs("div",{className:"text-sm text-gray-600",children:[j.type," ",j.technology&&`• ${j.technology}`," ",j.port&&`• Port ${j.port}`,j.description&&` • ${j.description}`]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:()=>g(j),className:"p-1 text-gray-500 hover:text-orange-600 transition-colors",title:"Edit service",children:a.jsx(mi,{className:"h-3 w-3"})}),a.jsx("button",{onClick:()=>T(j.name),className:"p-1 text-gray-500 hover:text-red-600 transition-colors",title:"Remove service",children:a.jsx(rs,{className:"h-3 w-3"})}),a.jsx("span",{className:`px-2 py-1 text-xs rounded-full ${j.status==="found"?"bg-green-100 text-green-800":j.status==="outdated"?"bg-yellow-100 text-yellow-800":"bg-red-100 text-red-800"}`,children:j.status})]})]})},R))}):a.jsx("p",{className:"text-gray-600",children:"No services currently configured"})]}),o.improvements.length>0&&a.jsxs("div",{className:"bg-white border border-gray-200 rounded-lg p-4",children:[a.jsxs("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:["Suggested Improvements (",o.improvements.length,")"]}),a.jsx("div",{className:"space-y-3",children:o.improvements.map((j,R)=>a.jsxs("div",{className:"flex items-start gap-3 p-3 border border-gray-200 rounded-lg hover:bg-gray-50",children:[a.jsx("input",{type:"checkbox",id:`improvement-${R}`,checked:u.has(R),onChange:()=>p(R),className:"mt-1 h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[k(j.type),a.jsx("span",{className:"font-medium",children:j.service}),a.jsx("span",{className:`px-2 py-1 text-xs rounded-full ${j.type==="add_service"?"bg-green-100 text-green-800":j.type==="update_service"?"bg-blue-100 text-blue-800":j.type==="remove_service"?"bg-red-100 text-red-800":"bg-gray-100 text-gray-800"}`,children:j.type.replace("_"," ")})]}),a.jsx("p",{className:"text-sm text-gray-700 mb-1",children:j.description}),a.jsx("p",{className:"text-xs text-gray-500",children:j.action})]})]},R))}),u.size>0&&a.jsx("div",{className:"mt-4 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-sm text-blue-800",children:[u.size," improvement(s) selected"]}),a.jsx("button",{onClick:f,className:"px-3 py-1 text-sm bg-blue-600 text-white rounded hover:bg-blue-700",children:"Apply Selected"})]})})]}),o.recommendations.length>0&&a.jsxs("div",{className:"bg-green-50 border border-green-200 rounded-lg p-4",children:[a.jsx("h3",{className:"text-sm font-medium text-green-800 mb-2",children:"Recommendations"}),a.jsx("ul",{className:"space-y-1",children:o.recommendations.map((j,R)=>a.jsxs("li",{className:"text-sm text-green-700",children:["• ",j]},R))})]}),o.warnings.length>0&&a.jsxs("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-4",children:[a.jsx("h3",{className:"text-sm font-medium text-yellow-800 mb-2",children:"Warnings"}),a.jsx("ul",{className:"space-y-1",children:o.warnings.map((j,R)=>a.jsxs("li",{className:"text-sm text-yellow-700",children:["• ",j]},R))})]}),a.jsx("div",{className:"text-center pt-4 border-t border-gray-200",children:a.jsxs("button",{onClick:x,disabled:s,className:"inline-flex items-center px-3 py-2 text-sm text-gray-600 bg-gray-100 border border-gray-300 rounded-md hover:bg-gray-200 disabled:opacity-50",children:[a.jsx(Zt,{className:`w-4 h-4 mr-2 ${s?"animate-spin":""}`}),"Re-analyze"]})})]})]})]})})};function tx(){const[e,t]=N.useState(null),[n,r]=N.useState(!0),[s,i]=N.useState(!1),[o,l]=N.useState({name:"",basePath:"",apiKey:""}),[u,c]=N.useState([]),[d,h]=N.useState(new Set),[m,v]=N.useState(new Set),[x,w]=N.useState(null),[k,p]=N.useState(null),[f,g]=N.useState(null),[b,P]=N.useState({name:"",id:"",path:"",description:""}),[T,C]=N.useState(new Set),[j,R]=N.useState(null),[M,K]=N.useState({name:"",type:"backend",port:"",url:"",technology:"",description:""}),[E,se]=N.useState(Date.now()),[q,ae]=N.useState(null),[Z,oe]=N.useState(null),[A,$]=N.useState(null),[U,re]=N.useState({}),[V,ee]=N.useState({}),[be,Qe]=N.useState({}),[Ee,jt]=N.useState(!1),[Os,Ot]=N.useState(null),[bt,Cr]=N.useState([]),[fe,Q]=N.useState(new Set),[ce,Pe]=N.useState({}),[dt,Nt]=N.useState(!1),[Wn,fa]=N.useState(!1),[Bp,pa]=N.useState([]),[ha,Hp]=N.useState(new Set),[qp,ma]=N.useState(null),[ga,zs]=N.useState(""),[uu,cu]=N.useState(!1),[xn,ya]=N.useState({}),[Bn,va]=N.useState(new Set);N.useEffect(()=>{As()},[]);const G=(y,S,L)=>{const F={id:Date.now().toString(),type:y,title:S,message:L,timestamp:Date.now()};c(W=>[...W,F]),y==="success"&&setTimeout(()=>{c(W=>W.filter(Y=>Y.id!==F.id))},5e3)},Qp=y=>{c(S=>S.filter(L=>L.id!==y))},As=async()=>{try{const y=await fetch("/api/organizations");if(y.ok){const S=await y.json();t(S.data),se(Date.now())}}catch(y){console.error("Failed to fetch organizations:",y)}finally{r(!1)}},wn=async()=>{await As()},xa=()=>{},wa=()=>{},ja=()=>{},Vp=async y=>{try{const S=await fetch(`/api/project-mappings/organization/${y}`);if(S.ok){const L=await S.json();pa(L.mappings||[])}}catch(S){console.error("Failed to fetch project mappings:",S)}},Kp=async(y,S,L)=>{if(!ga.trim()){G("error","Invalid Path","Please enter a valid local path");return}cu(!0);try{const F=await fetch("/api/project-mappings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({organizationId:y,projectId:S,localPath:ga,projectName:L})}),W=await F.json();F.ok&&W.success?(pa(Y=>{const de=Y.findIndex(le=>le.projectId===S);if(de>=0){const le=[...Y];return le[de]=W.mapping,le}return[...Y,W.mapping]}),ma(null),zs(""),G("success","Mapping Saved",`Successfully mapped "${L}" to local path`)):G("error","Failed to Save Mapping",W.error||"Unknown error")}catch(F){console.error("Failed to save project mapping:",F),G("error","Network Error","Failed to save project mapping")}finally{cu(!1)}},Gp=async(y,S)=>{try{const L=await fetch(`/api/project-mappings/${y}/${S}`,{method:"DELETE"});if(L.ok)pa(F=>F.filter(W=>W.projectId!==S)),G("success","Mapping Removed","Project path mapping has been removed");else{const F=await L.json();G("error","Failed to Remove Mapping",F.error||"Unknown error")}}catch(L){console.error("Failed to remove project mapping:",L),G("error","Network Error","Failed to remove project mapping")}},Yp=y=>Bp.find(S=>S.projectId===y),Jp=async y=>{const S=new Set(d);S.has(y)?S.delete(y):(S.add(y),await Vp(y)),h(S)},Xp=async(y,S)=>{y.preventDefault();try{const L=await fetch(`/api/organizations/${S}/workspaces`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),F=await L.json();if(L.ok&&F.success&&F.data){if(e){const W=e.organizations.map(Y=>{if(Y.id===S){const de=Y.workspaces||[];return{...Y,workspaces:[...de,F.data],workspaceCount:(Y.workspaceCount||0)+1}}return Y});t({...e,organizations:W})}w(null),P({name:"",id:"",path:"",description:""}),xa(),G("success","Workspace Added",`Successfully added workspace "${b.name}"`)}else G("error","Failed to Add Workspace",F.message||F.error)}catch(L){console.error("Failed to add workspace:",L),G("error","Network Error","Failed to add workspace. Please try again.")}},Zp=async(y,S,L)=>{console.log("🔄 handleUpdateWorkspace called:",{orgId:y,workspaceId:S,updates:L});try{console.log("📡 Making PATCH request to:",`/api/organizations/${y}/workspaces/${S}`);const F=await fetch(`/api/organizations/${y}/workspaces/${S}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(L)});console.log("📨 Response status:",F.status,F.statusText);const W=await F.json();F.ok?(await wn(),G("success","Workspace Updated","Workspace settings updated successfully")):G("error","Failed to Update Workspace",W.message||W.error)}catch(F){console.error("Failed to update workspace:",F),G("error","Network Error","Failed to update workspace. Please try again.")}},eh=y=>{oe(y.id),ee({name:y.name,type:y.type,technology:y.technology,port:y.port,url:y.url,description:y.description})},th=()=>{oe(null),ee({})},nh=async(y,S,L)=>{try{const F=await fetch(`/api/organizations/${y}/workspaces/${S}/services/${L}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(V)}),W=await F.json();if(F.ok&&W.success)await wn(),oe(null),ee({}),G("success","Service Updated","Service details updated successfully");else throw new Error(W.error||"Failed to update service")}catch(F){console.error("Failed to update service:",F),G("error","Update Failed",F instanceof Error?F.message:"Failed to update service")}},rh=async(y,S,L,F)=>{if(confirm(`Are you sure you want to remove the service "${F}"? This action cannot be undone.`))try{const W=await fetch(`/api/organizations/${y}/workspaces/${S}/services/${L}`,{method:"DELETE"}),Y=await W.json();if(W.ok&&Y.success)await wn(),G("success","Service Removed",`Service "${F}" has been removed`);else throw new Error(Y.error||"Failed to remove service")}catch(W){console.error("Failed to remove service:",W),G("error","Removal Failed",W instanceof Error?W.message:"Failed to remove service")}},sh=async(y,S,L)=>{y.preventDefault();try{const F={...M,port:M.port?parseInt(M.port):void 0,isActive:!0},W=await fetch(`/api/organizations/${S}/workspaces/${L}/services`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)}),Y=await W.json();if(W.ok&&Y.success){if(e){const de=e.organizations.map(le=>{var z;if(le.id===S){const D=(z=le.workspaces)==null?void 0:z.map(H=>{if(H.id===L){const Ie=H.services||[];return{...H,services:[...Ie,Y.data]}}return H});return{...le,workspaces:D}}return le});t({...e,organizations:de})}R(null),K({name:"",type:"backend",port:"",url:"",technology:"",description:""}),xa(),G("success","Service Added",`Successfully added service "${F.name}"`)}else G("error","Failed to Add Service",Y.message||Y.error)}catch(F){console.error("Failed to add service:",F),G("error","Network Error","Failed to add service. Please try again.")}},ih=async(y,S,L,F)=>{try{const W=await fetch(`/api/organizations/${y}/workspaces/${S}/services/${L}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:F})}),Y=await W.json();if(W.ok&&Y.success){if(e){const de=e.organizations.map(le=>{var z;if(le.id===y){const D=(z=le.workspaces)==null?void 0:z.map(H=>{var Ie;if(H.id===S){const Wt=(Ie=H.services)==null?void 0:Ie.map(Bt=>Bt.id===L?{...Bt,isActive:F}:Bt);return{...H,services:Wt}}return H});return{...le,workspaces:D}}return le});t({...e,organizations:de})}G("success","Service Updated",`Service ${F?"activated":"deactivated"} successfully`)}else G("error","Failed to Update Service",Y.message||Y.error)}catch(W){console.error("Failed to update service:",W),G("error","Network Error","Failed to update service. Please try again.")}},ah=y=>{$(y.id),Qe({name:y.name,apiUrl:y.apiUrl,apiKey:"",enabled:y.enabled})},oh=()=>{$(null),Qe({})},lh=async y=>{jt(!0);try{const S=await fetch(`/api/organizations/${y}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(be)}),L=await S.json();if(S.ok&&L.success)await wn(),$(null),Qe({}),G("success","Organization Updated","Organization details updated successfully");else throw new Error(L.error||"Failed to update organization")}catch(S){console.error("Failed to update organization:",S),G("error","Update Failed",S instanceof Error?S.message:"Failed to update organization")}finally{jt(!1)}},uh=async y=>{Ot(y),Nt(!0);try{const[S,L]=await Promise.all([fetch(`/api/organizations/${y}/workspaces/available`),fetch(`/api/service-mappings/organization/${y}`)]),F=await S.json();if(S.ok&&F.success){Cr(F.workspaces||[]);const W=new Set,Y={};if(F.workspaces.forEach(de=>{de.syncedLocally&&de.isActive!==!1?(W.add(de.id),Y[de.id]=de.localPath||de.path||""):Y[de.id]=de.path||""}),Q(W),Pe(Y),L.ok){const le=(await L.json()).mappings||[],z={};le.forEach(D=>{z[`${D.workspaceId}:${D.serviceId}`]=D.localPath}),ya(z)}}else G("error","Failed to Fetch Workspaces",F.error||"Could not fetch available workspaces"),Ot(null)}catch(S){console.error("Failed to fetch available workspaces:",S),G("error","Network Error","Failed to fetch available workspaces. Please try again."),Ot(null)}finally{Nt(!1)}},ch=async y=>{fa(!0);try{if(fe.size>0){const le=await fetch(`/api/organizations/${y}/workspaces/sync`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceIds:Array.from(fe)})}),z=await le.json();if(!le.ok){G("error","Failed to Sync Workspaces",z.message||z.error),fa(!1);return}for(const D of fe){const H=bt.find(Wt=>Wt.id===D),Ie=ce[D];H&&Ie&&Ie!==H.path&&await fetch(`/api/organizations/${y}/workspaces/${D}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Ie})})}}const S=new Set(fe),L=bt.filter(le=>le.syncedLocally&&!S.has(le.id));for(const le of L)await fetch(`/api/organizations/${y}/workspaces/${le.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:!1})});let F=0;for(const[le,z]of Object.entries(xn))if(z&&z.trim()){const[D,H]=le.split(":");if(!D||!H)continue;let Ie="",Wt="";const Bt=bt.find(Ht=>Ht.id===D);if(Bt!=null&&Bt.services){const Ht=Bt.services.find(ph=>ph.id===H);Ht&&(Ie=Ht.name,Wt=Ht.technology||"")}try{(await fetch("/api/service-mappings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({organizationId:y,workspaceId:D,serviceId:H,localPath:z.trim(),serviceName:Ie,technology:Wt})})).ok&&F++}catch(Ht){console.error("Failed to save service mapping:",Ht)}}await wn();const W=fe.size,Y=L.length;let de="";W>0&&Y>0?de=`Saved ${W} workspace(s) and disabled ${Y} workspace(s)`:W>0?de=`Saved ${W} workspace(s)`:Y>0?de=`Disabled ${Y} workspace(s)`:de="No changes made",F>0&&(de+=`, ${F} service path(s) mapped`),G("success","Workspaces Updated",de),Ot(null),va(new Set)}catch(S){console.error("Failed to save workspaces:",S),G("error","Network Error","Failed to save workspaces. Please try again.")}finally{fa(!1)}},dh=async y=>{y.preventDefault();try{const S=o.basePath.endsWith("/")?`${o.basePath}graphql`:`${o.basePath}/graphql`,L={name:o.name,apiUrl:S,apiKey:o.apiKey},F=await fetch("/api/organizations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(L)}),W=await F.json();F.ok?(await As(),i(!1),l({name:"",basePath:"",apiKey:""}),xa(),G("success","Organization Added",`Successfully added "${o.name}"`)):G("error","Failed to Add Organization",W.message||W.error)}catch(S){console.error("Failed to add organization:",S),G("error","Network Error","Failed to connect to server. Please try again.")}},fh=async y=>{if(confirm("Are you sure you want to delete this organization?"))try{const S=await fetch(`/api/organizations/${y}`,{method:"DELETE"}),L=await S.json();S.ok?(await As(),G("success","Organization Deleted",L.message||"Organization deleted successfully")):G("error","Failed to Delete Organization",L.message||L.error)}catch(S){console.error("Failed to delete organization:",S),G("error","Network Error","Failed to delete organization. Please try again.")}};return a.jsxs(a.Fragment,{children:[a.jsx(pn,{children:a.jsx("title",{children:"Organizations - AI Agent Service"})}),a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Organizations"}),a.jsx("p",{className:"text-muted-foreground",children:"Manage Task Shepherd organizations and API connections"})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[a.jsx(Mt,{className:"h-4 w-4"}),a.jsxs("span",{children:["Last updated: ",new Date(E).toLocaleTimeString()]})]}),a.jsxs("button",{onClick:wn,disabled:n,className:"inline-flex items-center px-3 py-2 text-sm text-gray-600 border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50",children:[a.jsx(Zt,{className:`h-4 w-4 mr-2 ${n?"animate-spin":""}`}),"Refresh"]}),a.jsxs("button",{onClick:()=>{i(!0)},className:"inline-flex items-center px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2",children:[a.jsx(pr,{className:"h-4 w-4 mr-2"}),"Add Organization"]})]})]}),u.filter(y=>!(y.type==="success"&&y.title==="Connection Test")).length>0&&a.jsx("div",{className:"space-y-2",children:u.filter(y=>!(y.type==="success"&&y.title==="Connection Test")).map(y=>a.jsxs("div",{className:`flex items-start justify-between p-3 rounded-md border text-sm ${y.type==="error"?"border-red-200 bg-red-50 text-red-800":"border-green-200 bg-green-50 text-green-800"}`,children:[a.jsxs("div",{className:"flex items-start space-x-2",children:[y.type==="error"?a.jsx(Ct,{className:"h-4 w-4 text-red-600 mt-0.5 flex-shrink-0"}):a.jsx(zn,{className:"h-4 w-4 text-green-600 mt-0.5 flex-shrink-0"}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium",children:y.title}),a.jsx("p",{className:"opacity-90",children:y.message}),y.type==="error"&&a.jsx("p",{className:"text-xs mt-1 opacity-75",children:"Check your API URL format and ensure the Agent API key is valid for this organization."})]})]}),a.jsx("button",{onClick:()=>Qp(y.id),className:"text-current opacity-60 hover:opacity-100 transition-opacity ml-2",children:a.jsx(ir,{className:"h-3 w-3"})})]},y.id))}),!n&&e&&a.jsx("div",{className:"rounded-lg border bg-card p-6",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Ct,{className:`h-5 w-5 ${e.setupCompleted?"text-green-600":"text-yellow-600"}`}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium",children:e.setupCompleted?"Setup Complete":"Setup Required"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:e.setupCompleted?`You have ${e.organizations.length} organization(s) configured.`:"Add your first organization to get started with Task Shepherd integration."})]})]})}),s&&a.jsxs("div",{className:"rounded-lg border bg-card p-6",children:[a.jsx("h3",{className:"text-lg font-medium mb-4",children:"Add New Organization"}),a.jsxs("form",{onSubmit:dh,className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"name",className:"block text-sm font-medium mb-2",children:"Organization Name"}),a.jsx("input",{type:"text",id:"name",value:o.name,onChange:y=>l({...o,name:y.target.value}),onFocus:wa,onBlur:ja,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"e.g. My Company",required:!0}),a.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"A friendly name to identify this Task Shepherd instance"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"basePath",className:"block text-sm font-medium mb-2",children:"API Base Path"}),a.jsx("input",{type:"url",id:"basePath",value:o.basePath,onChange:y=>l({...o,basePath:y.target.value}),onFocus:wa,onBlur:ja,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"https://myorg.taskshepherd.com/api",required:!0}),a.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Base API path (GraphQL will be appended automatically: /api → /api/graphql)"}),o.basePath&&a.jsxs("p",{className:"text-xs text-blue-600 mt-1",children:["GraphQL URL will be: ",a.jsx("code",{children:o.basePath.endsWith("/")?`${o.basePath}graphql`:`${o.basePath}/graphql`})]})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"apiKey",className:"block text-sm font-medium mb-2",children:"Agent API Key"}),a.jsx("input",{type:"password",id:"apiKey",value:o.apiKey,onChange:y=>l({...o,apiKey:y.target.value}),onFocus:wa,onBlur:ja,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"tks_agent_...",required:!0}),a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Generate an ",a.jsx("strong",{children:"Agent API key"})," from your Task Shepherd organization settings → API Keys → Create Agent Key"]})]}),a.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[a.jsx("button",{type:"button",onClick:()=>{i(!1),l({name:"",basePath:"",apiKey:""}),c([])},className:"px-4 py-2 text-gray-600 border border-gray-300 rounded-md hover:bg-gray-50",children:"Cancel"}),a.jsx("button",{type:"submit",className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700",children:"Add Organization"})]})]})]}),n?a.jsx("div",{className:"text-center py-12",children:a.jsx("div",{className:"text-muted-foreground",children:"Loading organizations..."})}):(e==null?void 0:e.organizations.length)===0?a.jsxs("div",{className:"text-center py-12",children:[a.jsx(Qr,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-medium mb-2",children:"No Organizations Configured"}),a.jsx("p",{className:"text-muted-foreground mb-4",children:"Add your first organization to start using the AI Agent Service with Task Shepherd."}),a.jsxs("button",{onClick:()=>{i(!0)},className:"inline-flex items-center px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700",children:[a.jsx(pr,{className:"h-4 w-4 mr-2"}),"Add Organization"]})]}):a.jsx("div",{className:"grid gap-4",children:e==null?void 0:e.organizations.map(y=>{var W,Y,de,le;const S=((W=y.workerRegistration)==null?void 0:W.registered)||!1,L=((Y=y.workerRegistration)==null?void 0:Y.lastHeartbeat)||y.createdAt,F=(de=y.workerRegistration)!=null&&de.lastHeartbeat?"Last heartbeat":"Created";return a.jsxs("div",{className:"rounded-lg border bg-card p-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("div",{className:"flex-1",children:A===y.id?a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Name"}),a.jsx("input",{type:"text",value:be.name||"",onChange:z=>Qe({...be,name:z.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"API URL"}),a.jsx("input",{type:"text",value:be.apiUrl||"",onChange:z=>Qe({...be,apiUrl:z.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"API Key"}),a.jsx("input",{type:"password",value:be.apiKey||"",onChange:z=>Qe({...be,apiKey:z.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Leave empty to keep current key"})]}),a.jsxs("div",{className:"flex items-center",children:[a.jsx("input",{type:"checkbox",id:`enabled-${y.id}`,checked:be.enabled??y.enabled,onChange:z=>Qe({...be,enabled:z.target.checked}),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),a.jsx("label",{htmlFor:`enabled-${y.id}`,className:"ml-2 block text-sm text-gray-700",children:"Enabled"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:()=>lh(y.id),disabled:Ee,className:"inline-flex items-center gap-2 px-3 py-1.5 bg-blue-600 text-white text-sm rounded hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",children:[Ee&&a.jsx(En,{className:"h-4 w-4 animate-spin"}),Ee?"Saving...":"Save"]}),a.jsx("button",{onClick:oh,disabled:Ee,className:"px-3 py-1.5 bg-gray-200 text-gray-700 text-sm rounded hover:bg-gray-300 disabled:opacity-50 disabled:cursor-not-allowed",children:"Cancel"})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h3",{className:"font-medium",children:y.name}),a.jsxs("div",{className:`flex items-center gap-1 text-sm ${S?"text-green-600":"text-yellow-600"}`,children:[a.jsx("div",{className:`w-2 h-2 rounded-full ${S?"bg-green-600 animate-pulse":"bg-yellow-600"}`}),S?"Connected":"Not Connected"]})]}),a.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:y.apiUrl}),L&&a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[F,": ",new Date(L).toLocaleString()]})]})}),A!==y.id&&a.jsx("div",{className:"flex items-start",children:a.jsx("button",{onClick:()=>ah(y),className:"p-2 text-gray-500 hover:text-blue-600 transition-colors",title:"Edit organization",children:a.jsx(mi,{className:"h-5 w-5"})})})]}),a.jsx("div",{className:"mt-4",children:!A&&a.jsxs(a.Fragment,{children:[S&&y.workerRegistration&&a.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-100",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(hv,{className:"h-4 w-4 text-gray-500"}),a.jsx("span",{className:"text-sm font-medium",children:"Worker Details"})]}),a.jsxs("div",{className:"space-y-1",children:[y.workerRegistration.workerId&&a.jsxs("p",{className:"text-xs text-gray-600",children:["Worker ID: ",a.jsx("code",{className:"text-xs font-mono bg-gray-100 px-1 rounded",children:y.workerRegistration.workerId})]}),y.workerRegistration.capabilities&&y.workerRegistration.capabilities.length>0&&a.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:y.workerRegistration.capabilities.map(z=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 text-xs bg-blue-100 text-blue-700 rounded",children:[a.jsx(Ip,{className:"h-3 w-3"}),z.replace("_"," ").toLowerCase()]},z))})]})]}),S&&a.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-100",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("button",{onClick:()=>Jp(y.id),className:"flex items-center gap-2 hover:text-blue-600 transition-colors",children:[d.has(y.id)?a.jsx(_r,{className:"h-4 w-4"}):a.jsx(Fr,{className:"h-4 w-4"}),a.jsx(Rp,{className:"h-4 w-4 text-gray-500"}),a.jsxs("span",{className:"text-sm font-medium",children:["Workspaces ",y.workspaceCount!==void 0&&`(${y.workspaceCount})`]})]}),a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("button",{onClick:()=>uh(y.id),className:"inline-flex items-center px-2 py-1 text-xs text-blue-600 border border-blue-200 rounded-md hover:bg-blue-50",children:[a.jsx(Qr,{className:"h-3 w-3 mr-1"}),"Manage"]})})]}),d.has(y.id)&&a.jsxs("div",{className:"mt-2 space-y-2",children:[m.has(y.id)?a.jsx("div",{className:"text-sm text-gray-500 text-center py-2",children:"Loading workspaces..."}):y.workspaces&&y.workspaces.length>0?y.workspaces.map(z=>a.jsxs("div",{className:"bg-gray-50 p-3 rounded-md",children:[a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsx("div",{className:"flex-1",children:q===z.id?a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Name"}),a.jsx("input",{type:"text",value:U.name||"",onChange:D=>re({...U,name:D.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Path"}),a.jsx("input",{type:"text",value:U.path||"",onChange:D=>re({...U,path:D.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Description"}),a.jsx("input",{type:"text",value:U.description||"",onChange:D=>re({...U,description:D.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"Optional description"})]}),a.jsxs("p",{className:"text-xs text-gray-500",children:["ID: ",a.jsx("code",{className:"font-mono",children:z.id})]})]}):a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h4",{className:"text-sm font-medium",children:z.name}),a.jsx("span",{className:`px-1.5 py-0.5 text-xs rounded ${z.isActive?"bg-green-100 text-green-700":"bg-gray-200 text-gray-600"}`,children:z.isActive?"Active":"Inactive"})]}),z.description&&a.jsx("p",{className:"text-xs text-gray-600 mt-1",children:z.description}),a.jsxs("div",{className:"mt-1 space-y-0.5",children:[a.jsxs("p",{className:"text-xs text-gray-500",children:["ID: ",a.jsx("code",{className:"font-mono",children:z.id})]}),a.jsxs("p",{className:"text-xs text-gray-500",children:["Path: ",a.jsx("code",{className:"font-mono",children:z.path})]}),z.projectCount!==void 0&&a.jsxs("p",{className:"text-xs text-gray-500",children:["Projects: ",z.projectCount]})]})]})}),a.jsx("div",{className:"flex items-center gap-1",children:a.jsx("button",{onClick:()=>Zp(y.id,z.id,{isActive:!z.isActive}),className:`p-1 transition-colors ${z.isActive?"text-green-500 hover:text-red-600":"text-gray-400 hover:text-green-600"}`,title:z.isActive?"Deactivate workspace":"Activate workspace",children:z.isActive?a.jsx(fv,{className:"h-3 w-3"}):a.jsx(dv,{className:"h-3 w-3"})})})]}),a.jsxs("div",{className:"mt-2 pt-2 border-t border-gray-200",children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsxs("button",{onClick:()=>{const D=`${y.id}-${z.id}`,H=new Set(T);H.has(D)?H.delete(D):H.add(D),C(H)},className:"flex items-center gap-1 text-xs text-gray-600 hover:text-blue-600",children:[T.has(`${y.id}-${z.id}`)?a.jsx(_r,{className:"h-3 w-3"}):a.jsx(Fr,{className:"h-3 w-3"}),"Services ",z.services?`(${z.services.length})`:"(0)"]}),a.jsx("button",{onClick:()=>{R({orgId:y.id,workspaceId:z.id})},className:"text-xs text-green-600 hover:text-green-700",children:a.jsx(pr,{className:"h-3 w-3"})})]}),T.has(`${y.id}-${z.id}`)&&a.jsx("div",{className:"space-y-1 ml-4",children:z.services&&z.services.length>0?z.services.map(D=>a.jsx("div",{className:"bg-white p-2 rounded border",children:Z===D.id?a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Name"}),a.jsx("input",{type:"text",value:V.name||"",onChange:H=>ee({...V,name:H.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Type"}),a.jsxs("select",{value:V.type||"backend",onChange:H=>ee({...V,type:H.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",children:[a.jsx("option",{value:"backend",children:"Backend"}),a.jsx("option",{value:"frontend",children:"Frontend"}),a.jsx("option",{value:"database",children:"Database"}),a.jsx("option",{value:"cache",children:"Cache"}),a.jsx("option",{value:"queue",children:"Queue"}),a.jsx("option",{value:"api",children:"API"}),a.jsx("option",{value:"service",children:"Service"}),a.jsx("option",{value:"other",children:"Other"})]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Technology"}),a.jsx("input",{type:"text",value:V.technology||"",onChange:H=>ee({...V,technology:H.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"e.g., Node.js, Python"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Port"}),a.jsx("input",{type:"number",value:V.port||"",onChange:H=>ee({...V,port:H.target.value?parseInt(H.target.value):void 0}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"3000"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"URL"}),a.jsx("input",{type:"url",value:V.url||"",onChange:H=>ee({...V,url:H.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"http://localhost:3000"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Description"}),a.jsx("input",{type:"text",value:V.description||"",onChange:H=>ee({...V,description:H.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"Optional description"})]}),a.jsxs("div",{className:"flex items-center justify-end gap-1 pt-1",children:[a.jsx("button",{onClick:()=>nh(y.id,z.id,D.id),className:"px-2 py-1 text-xs bg-green-600 text-white rounded hover:bg-green-700",children:a.jsx(gi,{className:"h-3 w-3"})}),a.jsx("button",{onClick:th,className:"px-2 py-1 text-xs bg-gray-600 text-white rounded hover:bg-gray-700",children:a.jsx(ir,{className:"h-3 w-3"})})]})]}):a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:"font-medium",children:D.name}),a.jsxs("span",{className:"text-gray-500",children:["(",D.type,")"]}),D.port&&a.jsxs("span",{className:"text-gray-400",children:[":",D.port]}),D.technology&&a.jsx("span",{className:"px-1 py-0.5 bg-blue-100 text-blue-700 rounded text-xs",children:D.technology}),D.description&&a.jsxs("span",{className:"text-gray-400 italic",children:["- ",D.description]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:()=>eh(D),className:"p-1 text-gray-500 hover:text-orange-600 transition-colors",title:"Edit service",children:a.jsx(mi,{className:"h-3 w-3"})}),a.jsx("button",{onClick:()=>rh(y.id,z.id,D.id,D.name),className:"p-1 text-gray-500 hover:text-red-600 transition-colors",title:"Remove service",children:a.jsx(rs,{className:"h-3 w-3"})}),a.jsx("button",{onClick:()=>ih(y.id,z.id,D.id,!D.isActive),className:`px-1.5 py-0.5 rounded text-xs ${D.isActive?"bg-green-100 text-green-700":"bg-gray-100 text-gray-600"}`,children:D.isActive?"Active":"Inactive"})]})]})},D.id)):a.jsx("div",{className:"text-xs text-gray-500",children:"No services configured"})})]}),z.projects&&z.projects.length>0&&a.jsxs("div",{className:"mt-2 pt-2 border-t border-gray-200",children:[a.jsx("div",{className:"flex items-center justify-between mb-1",children:a.jsxs("button",{onClick:()=>{const D=`proj-${y.id}-${z.id}`,H=new Set(ha);H.has(D)?H.delete(D):H.add(D),Hp(H)},className:"flex items-center gap-1 text-xs text-gray-600 hover:text-purple-600",children:[ha.has(`proj-${y.id}-${z.id}`)?a.jsx(_r,{className:"h-3 w-3"}):a.jsx(Fr,{className:"h-3 w-3"}),a.jsx(ns,{className:"h-3 w-3 text-purple-500"}),"Projects (",z.projects.length,")"]})}),ha.has(`proj-${y.id}-${z.id}`)&&a.jsx("div",{className:"space-y-1 ml-4",children:z.projects.map(D=>{const H=Yp(D.id),Ie=qp===D.id;return a.jsxs("div",{className:`bg-white p-2 rounded border ${H?"border-purple-300":"border-gray-200"}`,children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx(av,{className:"h-3 w-3 text-gray-400"}),a.jsx("span",{className:"font-medium",children:D.name}),D.stage&&a.jsx("span",{className:"px-1 py-0.5 bg-gray-100 text-gray-600 rounded text-xs",children:D.stage}),H&&a.jsx("span",{className:"px-1 py-0.5 bg-purple-100 text-purple-700 rounded text-xs",children:"Mapped"})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[H&&!Ie&&a.jsx("button",{onClick:()=>Gp(y.id,D.id),className:"p-1 text-gray-500 hover:text-red-600 transition-colors",title:"Remove mapping",children:a.jsx(rs,{className:"h-3 w-3"})}),!Ie&&a.jsx("button",{onClick:()=>{ma(D.id),zs((H==null?void 0:H.localPath)||"")},className:"p-1 text-gray-500 hover:text-purple-600 transition-colors",title:H?"Edit path":"Set local path",children:a.jsx(mi,{className:"h-3 w-3"})})]})]}),H&&!Ie&&a.jsx("div",{className:"mt-1 text-xs text-purple-600",children:a.jsx("code",{className:"bg-purple-50 px-1 rounded",children:H.localPath})}),Ie&&a.jsxs("div",{className:"mt-2 flex gap-1",children:[a.jsx("input",{type:"text",value:ga,onChange:Wt=>zs(Wt.target.value),placeholder:"/path/to/local/project",className:"flex-1 text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-purple-500"}),a.jsx("button",{onClick:()=>Kp(y.id,D.id,D.name),disabled:uu,className:"px-2 py-1 text-xs bg-purple-600 text-white rounded hover:bg-purple-700 disabled:opacity-50",children:uu?a.jsx(En,{className:"h-3 w-3 animate-spin"}):a.jsx(gi,{className:"h-3 w-3"})}),a.jsx("button",{onClick:()=>{ma(null),zs("")},className:"px-2 py-1 text-xs bg-gray-200 text-gray-700 rounded hover:bg-gray-300",children:a.jsx(ir,{className:"h-3 w-3"})})]})]},D.id)})})]})]},z.id)):a.jsx("div",{className:"text-sm text-gray-500 text-center py-2",children:'No workspaces configured. Click "Manage" to import from Task Shepherd.'}),(j==null?void 0:j.orgId)===y.id&&((le=y.workspaces)==null?void 0:le.some(z=>z.id===j.workspaceId))&&a.jsxs("div",{className:"bg-green-50 p-3 rounded-md border border-green-200",children:[a.jsx("h5",{className:"text-sm font-medium mb-2",children:"Add New Service"}),a.jsxs("form",{onSubmit:z=>sh(z,j.orgId,j.workspaceId),className:"space-y-2",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsx("input",{type:"text",placeholder:"Service Name",value:M.name,onChange:z=>K({...M,name:z.target.value}),className:"text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-green-500",required:!0}),a.jsxs("select",{value:M.type,onChange:z=>K({...M,type:z.target.value}),className:"text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-green-500",required:!0,children:[a.jsx("option",{value:"backend",children:"Backend"}),a.jsx("option",{value:"frontend",children:"Frontend"}),a.jsx("option",{value:"database",children:"Database"}),a.jsx("option",{value:"cache",children:"Cache"}),a.jsx("option",{value:"queue",children:"Queue"}),a.jsx("option",{value:"api",children:"API"}),a.jsx("option",{value:"service",children:"Service"}),a.jsx("option",{value:"other",children:"Other"})]})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[a.jsx("input",{type:"number",placeholder:"Port",value:M.port,onChange:z=>K({...M,port:z.target.value}),className:"text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-green-500"}),a.jsx("input",{type:"text",placeholder:"Technology (e.g., Node.js)",value:M.technology,onChange:z=>K({...M,technology:z.target.value}),className:"text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-green-500"}),a.jsx("input",{type:"url",placeholder:"URL (optional)",value:M.url,onChange:z=>K({...M,url:z.target.value}),className:"text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-green-500"})]}),a.jsx("input",{type:"text",placeholder:"Description (optional)",value:M.description,onChange:z=>K({...M,description:z.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-green-500"}),a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx("button",{type:"button",onClick:()=>{R(null),K({name:"",type:"backend",port:"",url:"",technology:"",description:""})},className:"px-2 py-1 text-xs text-gray-600 border border-gray-300 rounded hover:bg-gray-50",children:"Cancel"}),a.jsx("button",{type:"submit",className:"px-2 py-1 text-xs bg-green-600 text-white rounded hover:bg-green-700",children:"Add Service"})]})]})]}),x===y.id&&a.jsxs("div",{className:"bg-blue-50 p-3 rounded-md border border-blue-200",children:[a.jsx("h5",{className:"text-sm font-medium mb-2",children:"Add New Workspace"}),a.jsxs("form",{onSubmit:z=>Xp(z,y.id),className:"space-y-2",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsx("input",{type:"text",placeholder:"Workspace Name",value:b.name,onChange:z=>P({...b,name:z.target.value}),className:"text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",required:!0}),a.jsx("input",{type:"text",placeholder:"Workspace ID",value:b.id,onChange:z=>P({...b,id:z.target.value}),className:"text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",required:!0})]}),a.jsx("input",{type:"text",placeholder:"Path (e.g., /home/user/projects/workspace)",value:b.path,onChange:z=>P({...b,path:z.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",required:!0}),a.jsx("input",{type:"text",placeholder:"Description (optional)",value:b.description,onChange:z=>P({...b,description:z.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500"}),a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx("button",{type:"button",onClick:()=>{w(null),P({name:"",id:"",path:"",description:""})},className:"px-2 py-1 text-xs text-gray-600 border border-gray-300 rounded hover:bg-gray-50",children:"Cancel"}),a.jsx("button",{type:"submit",className:"px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700",children:"Add Workspace"})]})]})]})]})]})]})}),a.jsx("div",{className:"flex items-center gap-2 mt-4",children:y.id!=="default"&&a.jsxs("button",{onClick:()=>fh(y.id),className:"inline-flex items-center px-3 py-1 text-sm text-red-600 border border-red-200 rounded-md hover:bg-red-50",children:[a.jsx(rs,{className:"h-3 w-3 mr-1"}),"Delete"]})})]},y.id)})}),k&&a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50",children:a.jsx("div",{className:"bg-white rounded-lg shadow-xl max-w-6xl w-full max-h-[90vh] overflow-hidden",children:a.jsx(Zv,{organizationId:k,onComplete:y=>{var L;if(e){const F=e.organizations.map(W=>{if(W.id===k){const Y=[...W.workspaces||[],y];return{...W,workspaces:Y,workspaceCount:Y.length}}return W});t({...e,organizations:F})}p(null);const S=((L=y.services)==null?void 0:L.length)||0;G("success","Workspace Created",`Successfully created workspace "${y.name}" with ${S} service(s) using wizard`)},onCancel:()=>{p(null)}})})}),f&&a.jsx(ex,{organizationId:f.orgId,workspace:f.workspace,onClose:()=>{g(null)},onApplyChanges:async y=>{console.log("🔧 Applying workspace analysis changes:",y);try{const S=await fetch(`/api/organizations/${f.orgId}/workspaces/${f.workspace.id}/apply-improvements`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({improvements:y})}),L=await S.json();if(S.ok&&L.success)G("success","Changes Applied",`Applied ${y.length} improvement(s) to workspace "${f.workspace.name}"`),await wn();else throw new Error(L.error||"Failed to apply changes")}catch(S){console.error("Failed to apply workspace changes:",S),G("error","Failed to Apply Changes",S instanceof Error?S.message:"Failed to apply workspace improvements")}}}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"rounded-lg border bg-green-50 p-6",children:[a.jsx("h3",{className:"text-lg font-medium mb-4",children:"Getting Your Task Shepherd API Information"}),a.jsxs("div",{className:"space-y-3 text-sm text-green-900",children:[a.jsxs("p",{children:[a.jsx("strong",{children:"Step 1:"})," Open your Task Shepherd frontend in a browser"]}),a.jsxs("p",{children:[a.jsx("strong",{children:"Step 2:"})," Copy the URL up to ",a.jsx("code",{children:"/api"})]}),a.jsxs("div",{className:"bg-green-100 p-3 rounded-md font-mono text-xs",children:[a.jsx("p",{children:a.jsx("strong",{children:"Example:"})}),a.jsxs("p",{children:["• Frontend URL: ",a.jsx("code",{children:"https://myorg.taskshepherd.com"})]}),a.jsxs("p",{children:["• API Base Path: ",a.jsx("code",{children:"https://myorg.taskshepherd.com/api"})]})]}),a.jsxs("p",{children:[a.jsx("strong",{children:"Step 3:"})," Generate an ",a.jsx("strong",{children:"Agent API key"})," from Organization Settings → API Keys → Create Agent Key"]})]})]}),Os&&a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-white rounded-lg p-6 max-w-4xl w-full max-h-[90vh] overflow-y-auto m-4",children:[a.jsxs("div",{className:"flex justify-between items-center mb-4",children:[a.jsx("h2",{className:"text-xl font-semibold",children:"Manage Workspaces"}),a.jsx("button",{onClick:()=>Ot(null),className:"text-gray-500 hover:text-gray-700",children:a.jsx(ir,{className:"h-5 w-5"})})]}),dt?a.jsxs("div",{className:"flex items-center justify-center py-12",children:[a.jsx(En,{className:"h-8 w-8 animate-spin text-blue-600"}),a.jsx("span",{className:"ml-2 text-gray-600",children:"Loading available workspaces..."})]}):a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-gray-600",children:"Select workspaces to sync from Task Shepherd and configure local paths for each."}),bt.length===0?a.jsx("div",{className:"text-center py-8 text-gray-500",children:"No workspaces available in this organization"}):a.jsxs("div",{className:"space-y-4",children:[bt.filter(y=>y.isActive!==!1).length>0&&a.jsx("div",{className:"space-y-2",children:bt.filter(y=>y.isActive!==!1).map(y=>a.jsx("div",{className:`border rounded-lg p-4 ${fe.has(y.id)?"border-blue-500 bg-blue-50":"border-gray-200"}`,children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("input",{type:"checkbox",checked:fe.has(y.id),onChange:S=>{const L=new Set(fe);S.target.checked?L.add(y.id):L.delete(y.id),Q(L)},className:"mt-1"}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium",children:y.name}),y.description&&a.jsx("p",{className:"text-sm text-gray-600",children:y.description})]}),y.syncedLocally&&a.jsx("span",{className:"text-xs px-2 py-1 bg-green-100 text-green-700 rounded",children:"Already Synced"})]}),a.jsxs("div",{className:"mt-2",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Local Path"}),a.jsx("input",{type:"text",value:ce[y.id]||"",onChange:S=>{Pe({...ce,[y.id]:S.target.value})},placeholder:y.path||"Enter local directory path",className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-blue-500 text-sm",disabled:!fe.has(y.id)}),a.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Suggested path: ",y.path||"Not specified"]})]}),y.services&&y.services.length>0&&a.jsxs("div",{className:"mt-3 border-t pt-3",children:[a.jsxs("button",{type:"button",onClick:()=>{const S=new Set(Bn);S.has(y.id)?S.delete(y.id):S.add(y.id),va(S)},className:"flex items-center gap-2 text-sm font-medium text-gray-700 hover:text-gray-900",disabled:!fe.has(y.id),children:[Bn.has(y.id)?a.jsx(_r,{className:"h-4 w-4"}):a.jsx(Fr,{className:"h-4 w-4"}),a.jsx(Qr,{className:"h-4 w-4"}),y.services.length," Service",y.services.length!==1?"s":""]}),Bn.has(y.id)&&a.jsx("div",{className:"mt-2 space-y-2 pl-6",children:y.services.map(S=>{const L=`${y.id}:${S.id}`;return a.jsxs("div",{className:"border rounded p-2 bg-gray-50",children:[a.jsxs("div",{className:"flex items-start justify-between mb-1",children:[a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-sm",children:S.name}),S.technology&&a.jsx("span",{className:"ml-2 text-xs px-1.5 py-0.5 bg-purple-100 text-purple-700 rounded",children:S.technology})]}),xn[L]&&a.jsx(ns,{className:"h-3 w-3 text-green-500"})]}),S.description&&a.jsx("p",{className:"text-xs text-gray-500 mb-2",children:S.description}),a.jsx("input",{type:"text",value:xn[L]||"",onChange:F=>{ya({...xn,[L]:F.target.value})},placeholder:"Service local path (optional, inherits from workspace)",className:"w-full px-2 py-1 border border-gray-300 rounded text-xs focus:outline-none focus:ring-1 focus:ring-blue-500",disabled:!fe.has(y.id)}),a.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Leave empty to use workspace path"})]},S.id)})})]}),(!y.services||y.services.length===0)&&a.jsx("p",{className:"text-sm text-gray-500 mt-2 italic",children:"No services defined"})]})]})},y.id))}),bt.filter(y=>y.isActive===!1).length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-sm font-medium text-gray-500",children:"Inactive Workspaces"}),bt.filter(y=>y.isActive===!1).map(y=>a.jsx("div",{className:`border rounded-lg p-4 opacity-60 ${fe.has(y.id)?"border-blue-500 bg-blue-50":"border-gray-200"}`,children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("input",{type:"checkbox",checked:fe.has(y.id),onChange:S=>{const L=new Set(fe);S.target.checked?L.add(y.id):L.delete(y.id),Q(L)},className:"mt-1"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"flex items-center justify-between mb-2",children:a.jsxs("div",{children:[a.jsxs("h3",{className:"font-medium flex items-center gap-2",children:[y.name,a.jsx("span",{className:"text-xs px-2 py-1 bg-gray-100 text-gray-600 rounded",children:"Inactive"})]}),y.description&&a.jsx("p",{className:"text-sm text-gray-600",children:y.description})]})}),a.jsxs("div",{className:"mt-2",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Local Path"}),a.jsx("input",{type:"text",value:ce[y.id]||"",onChange:S=>{Pe({...ce,[y.id]:S.target.value})},placeholder:y.path||"Enter local directory path",className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-blue-500 text-sm",disabled:!fe.has(y.id)}),a.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Suggested path: ",y.path||"Not specified"]})]}),y.services&&y.services.length>0&&a.jsxs("div",{className:"mt-3 border-t pt-3",children:[a.jsxs("button",{type:"button",onClick:()=>{const S=new Set(Bn);S.has(y.id)?S.delete(y.id):S.add(y.id),va(S)},className:"flex items-center gap-2 text-sm font-medium text-gray-700 hover:text-gray-900",disabled:!fe.has(y.id),children:[Bn.has(y.id)?a.jsx(_r,{className:"h-4 w-4"}):a.jsx(Fr,{className:"h-4 w-4"}),a.jsx(Qr,{className:"h-4 w-4"}),y.services.length," Service",y.services.length!==1?"s":""]}),Bn.has(y.id)&&a.jsx("div",{className:"mt-2 space-y-2 pl-6",children:y.services.map(S=>{const L=`${y.id}:${S.id}`;return a.jsxs("div",{className:"border rounded p-2 bg-gray-50",children:[a.jsxs("div",{className:"flex items-start justify-between mb-1",children:[a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-sm",children:S.name}),S.technology&&a.jsx("span",{className:"ml-2 text-xs px-1.5 py-0.5 bg-purple-100 text-purple-700 rounded",children:S.technology})]}),xn[L]&&a.jsx(ns,{className:"h-3 w-3 text-green-500"})]}),S.description&&a.jsx("p",{className:"text-xs text-gray-500 mb-2",children:S.description}),a.jsx("input",{type:"text",value:xn[L]||"",onChange:F=>{ya({...xn,[L]:F.target.value})},placeholder:"Service local path (optional, inherits from workspace)",className:"w-full px-2 py-1 border border-gray-300 rounded text-xs focus:outline-none focus:ring-1 focus:ring-blue-500",disabled:!fe.has(y.id)}),a.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Leave empty to use workspace path"})]},S.id)})})]}),(!y.services||y.services.length===0)&&a.jsx("p",{className:"text-sm text-gray-500 mt-2 italic",children:"No services defined"})]})]})},y.id))]})]}),a.jsxs("div",{className:"flex justify-end gap-2 mt-6 pt-4 border-t",children:[a.jsx("button",{onClick:()=>Ot(null),className:"px-4 py-2 text-gray-600 hover:text-gray-800",disabled:Wn,children:"Cancel"}),a.jsx("button",{onClick:()=>ch(Os),disabled:Wn,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:Wn?a.jsxs(a.Fragment,{children:[a.jsx(En,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):a.jsxs(a.Fragment,{children:[a.jsx(gi,{className:"h-4 w-4"}),"Save"]})})]})]})]})}),a.jsxs("div",{className:"rounded-lg border bg-blue-50 p-6",children:[a.jsx("h3",{className:"text-lg font-medium mb-4",children:"About Organization & Workspace Management"}),a.jsxs("div",{className:"space-y-2 text-sm text-blue-900",children:[a.jsxs("p",{children:["• ",a.jsx("strong",{children:"Organizations"})," represent different Task Shepherd instances you want to connect to"]}),a.jsxs("p",{children:["• Each organization needs an ",a.jsx("strong",{children:"Agent API key"})," (not a user API key) generated from the Task Shepherd organization settings"]}),a.jsxs("p",{children:["• ",a.jsx("strong",{children:"Workspaces"})," are collections of related projects within an organization"]}),a.jsxs("p",{children:["• Click ",a.jsx("strong",{children:"Manage"})," to select and sync workspaces from Task Shepherd with custom local paths"]}),a.jsx("p",{children:"• You can activate/deactivate workspaces to control which ones the agent works with"}),a.jsx("p",{children:"• The agent will automatically sync workspaces and accept work assignments from configured organizations"})]})]})]})]})]})}function nx(){const[e,t]=N.useState([]),[n,r]=N.useState(!0),[s,i]=N.useState(null),[o,l]=N.useState(!1),[u,c]=N.useState({organizationId:"",workspaceId:"",serviceId:"",localPath:"",serviceName:"",technology:"",notes:""}),[d,h]=N.useState(!1),m=async()=>{r(!0),i(null);try{const p=await fetch("/api/service-mappings");if(!p.ok)throw new Error("Failed to fetch service mappings");const f=await p.json();if(f.success)t(f.mappings);else throw new Error("Failed to fetch mappings")}catch(p){i(p instanceof Error?p.message:"Failed to fetch mappings")}finally{r(!1)}};N.useEffect(()=>{m()},[]);const v=async p=>{p.preventDefault(),h(!0),i(null);try{const f=await fetch("/api/service-mappings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)}),g=await f.json();if(!f.ok||!g.success)throw new Error(g.error||"Failed to save mapping");await m(),l(!1),c({organizationId:"",workspaceId:"",serviceId:"",localPath:"",serviceName:"",technology:"",notes:""})}catch(f){i(f instanceof Error?f.message:"Failed to save mapping")}finally{h(!1)}},x=async p=>{if(confirm(`Delete mapping for ${p.serviceName||p.serviceId}?`))try{const f=await fetch(`/api/service-mappings/${encodeURIComponent(p.organizationId)}/${encodeURIComponent(p.workspaceId)}/${encodeURIComponent(p.serviceId)}`,{method:"DELETE"}),g=await f.json();if(!f.ok||!g.success)throw new Error(g.error||"Failed to delete mapping");await m()}catch(f){i(f instanceof Error?f.message:"Failed to delete mapping")}},w=p=>new Date(p).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),k=e.reduce((p,f)=>(p[f.organizationId]||(p[f.organizationId]=[]),p[f.organizationId].push(f),p),{});return a.jsxs(a.Fragment,{children:[a.jsx(pn,{children:a.jsx("title",{children:"Service Mappings - AI Agent Service"})}),a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Service Mappings"}),a.jsx("p",{className:"text-muted-foreground",children:"Map backend services to local filesystem paths for multi-repo workspaces"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:m,disabled:n,className:"inline-flex items-center gap-2 px-4 py-2 rounded-md border bg-white hover:bg-gray-50 disabled:opacity-50",children:[a.jsx(Zt,{className:`h-4 w-4 ${n?"animate-spin":""}`}),"Refresh"]}),a.jsxs("button",{onClick:()=>l(!0),className:"inline-flex items-center gap-2 px-4 py-2 rounded-md bg-blue-600 text-white hover:bg-blue-700",children:[a.jsx(pr,{className:"h-4 w-4"}),"Add Mapping"]})]})]}),s&&a.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg text-red-700",children:s}),o&&a.jsxs("div",{className:"rounded-lg border bg-card p-6",children:[a.jsx("h3",{className:"text-lg font-medium mb-4",children:"Add Service Mapping"}),a.jsxs("form",{onSubmit:v,className:"space-y-4",children:[a.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium mb-1",children:"Organization ID *"}),a.jsx("input",{type:"text",value:u.organizationId,onChange:p=>c({...u,organizationId:p.target.value}),required:!0,className:"w-full px-3 py-2 border rounded-md",placeholder:"org-..."})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium mb-1",children:"Workspace ID *"}),a.jsx("input",{type:"text",value:u.workspaceId,onChange:p=>c({...u,workspaceId:p.target.value}),required:!0,className:"w-full px-3 py-2 border rounded-md",placeholder:"workspace-..."})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium mb-1",children:"Service ID *"}),a.jsx("input",{type:"text",value:u.serviceId,onChange:p=>c({...u,serviceId:p.target.value}),required:!0,className:"w-full px-3 py-2 border rounded-md",placeholder:"service-..."})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium mb-1",children:"Local Path *"}),a.jsx("input",{type:"text",value:u.localPath,onChange:p=>c({...u,localPath:p.target.value}),required:!0,className:"w-full px-3 py-2 border rounded-md",placeholder:"/path/to/service"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium mb-1",children:"Service Name"}),a.jsx("input",{type:"text",value:u.serviceName,onChange:p=>c({...u,serviceName:p.target.value}),className:"w-full px-3 py-2 border rounded-md",placeholder:"My Service"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium mb-1",children:"Technology"}),a.jsxs("select",{value:u.technology,onChange:p=>c({...u,technology:p.target.value}),className:"w-full px-3 py-2 border rounded-md",children:[a.jsx("option",{value:"",children:"Select..."}),a.jsx("option",{value:"NODEJS",children:"Node.js"}),a.jsx("option",{value:"REACT",children:"React"}),a.jsx("option",{value:"PYTHON",children:"Python"}),a.jsx("option",{value:"GO",children:"Go"}),a.jsx("option",{value:"RUST",children:"Rust"}),a.jsx("option",{value:"JAVA",children:"Java"}),a.jsx("option",{value:"OTHER",children:"Other"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium mb-1",children:"Notes"}),a.jsx("textarea",{value:u.notes,onChange:p=>c({...u,notes:p.target.value}),className:"w-full px-3 py-2 border rounded-md",rows:2,placeholder:"Optional notes about this mapping..."})]}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx("button",{type:"button",onClick:()=>l(!1),className:"px-4 py-2 rounded-md border hover:bg-gray-50",children:"Cancel"}),a.jsx("button",{type:"submit",disabled:d,className:"px-4 py-2 rounded-md bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50",children:d?"Saving...":"Save Mapping"})]})]})]}),n?a.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading mappings..."}):e.length===0?a.jsxs("div",{className:"rounded-lg border bg-card p-12 text-center",children:[a.jsx(ns,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),a.jsx("h3",{className:"text-lg font-medium mb-2",children:"No Service Mappings"}),a.jsx("p",{className:"text-muted-foreground mb-4",children:"Service mappings allow the agent to find local paths for multi-repo workspace services."}),a.jsxs("button",{onClick:()=>l(!0),className:"inline-flex items-center gap-2 px-4 py-2 rounded-md bg-blue-600 text-white hover:bg-blue-700",children:[a.jsx(pr,{className:"h-4 w-4"}),"Add First Mapping"]})]}):a.jsx("div",{className:"space-y-6",children:Object.entries(k).map(([p,f])=>a.jsxs("div",{className:"rounded-lg border bg-card",children:[a.jsx("div",{className:"px-6 py-4 border-b bg-gray-50 rounded-t-lg",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(iv,{className:"h-5 w-5 text-blue-600"}),a.jsxs("h3",{className:"font-medium",children:["Organization: ",p]}),a.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",f.length," mapping",f.length!==1?"s":"",")"]})]})}),a.jsx("div",{className:"divide-y",children:f.map(g=>a.jsx("div",{className:"px-6 py-4 hover:bg-gray-50",children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(uv,{className:"h-4 w-4 text-purple-600"}),a.jsx("span",{className:"font-medium",children:g.serviceName||g.serviceId}),g.technology&&a.jsx("span",{className:"px-2 py-0.5 text-xs bg-blue-100 text-blue-700 rounded",children:g.technology})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(ov,{className:"h-4 w-4"}),a.jsxs("span",{children:["Workspace: ",g.workspaceId.slice(0,8),"..."]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Rp,{className:"h-4 w-4"}),a.jsx("span",{className:"font-mono",children:g.localPath})]})]}),g.notes&&a.jsx("p",{className:"text-sm text-muted-foreground italic",children:g.notes}),a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Mapped: ",w(g.mappedAt)]})]}),a.jsx("button",{onClick:()=>x(g),className:"p-2 text-red-600 hover:bg-red-50 rounded",title:"Delete mapping",children:a.jsx(rs,{className:"h-4 w-4"})})]})},`${g.organizationId}:${g.workspaceId}:${g.serviceId}`))})]},p))}),a.jsxs("div",{className:"rounded-lg border bg-blue-50 p-6",children:[a.jsx("h3",{className:"text-lg font-medium text-blue-900 mb-2",children:"About Service Mappings"}),a.jsx("p",{className:"text-blue-800 text-sm mb-4",children:"Service mappings are used by the agent to locate local source code for multi-repo workspaces. When processing work, the agent checks service mappings first, then falls back to workspace mappings."}),a.jsxs("ul",{className:"text-sm text-blue-700 space-y-1 list-disc list-inside",children:[a.jsx("li",{children:"Each mapping links a backend service ID to a local filesystem path"}),a.jsx("li",{children:"Service mappings take priority over workspace mappings"}),a.jsx("li",{children:"Use for multi-repo workspaces where services are in different directories"}),a.jsx("li",{children:"The agent can only process work for mapped services"})]})]})]})]})}function rx(){return a.jsxs(a.Fragment,{children:[a.jsx(pn,{children:a.jsx("title",{children:"404 - Page Not Found"})}),a.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] text-center",children:a.jsxs("div",{className:"space-y-4",children:[a.jsx("h1",{className:"text-4xl font-bold",children:"404"}),a.jsx("h2",{className:"text-xl text-muted-foreground",children:"Page Not Found"}),a.jsx("p",{className:"text-muted-foreground max-w-md",children:"The page you're looking for doesn't exist or has been moved."}),a.jsxs(jp,{to:"/",className:"inline-flex items-center space-x-2 rounded-lg bg-primary px-4 py-2 text-primary-foreground hover:bg-primary/90",children:[a.jsx(Lp,{className:"h-4 w-4"}),a.jsx("span",{children:"Go Home"})]})]})})]})}function sx(){return a.jsxs(a.Fragment,{children:[a.jsxs(pn,{children:[a.jsx("title",{children:"AI Agent Service Dashboard"}),a.jsx("meta",{name:"description",content:"Analytics dashboard for AI agent service monitoring"})]}),a.jsx(Vv,{children:a.jsxs(A0,{children:[a.jsx(qr,{path:"/",element:a.jsx(Xv,{})}),a.jsx(qr,{path:"/organizations",element:a.jsx(tx,{})}),a.jsx(qr,{path:"/service-mappings",element:a.jsx(nx,{})}),a.jsx(qr,{path:"*",element:a.jsx(rx,{})})]})})]})}const ix=new ay({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1,staleTime:1e3*60*5}}});to.createRoot(document.getElementById("root")).render(a.jsx(I.StrictMode,{children:a.jsx(sr,{children:a.jsx(uy,{client:ix,children:a.jsxs(D0,{children:[a.jsx(sx,{}),a.jsx(ev,{position:"top-right"})]})})})}));
|
|
69
|
-
//# sourceMappingURL=index-
|
|
68
|
+
`);var Dy=e=>{switch(e){case"success":return Wy;case"error":return By;default:return null}},$y=Array(12).fill(0),Uy=({visible:e})=>I.createElement("div",{className:"sonner-loading-wrapper","data-visible":e},I.createElement("div",{className:"sonner-spinner"},$y.map((t,n)=>I.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),Wy=I.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},I.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),By=I.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},I.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),rl=0,Hy=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,s=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:rl++;return this.toasts.find(i=>i.id===s)?this.toasts=this.toasts.map(i=>i.id===s?(this.publish({...i,...e,id:s,title:n}),{...i,...e,id:s,title:n}):i):this.addToast({title:n,...r,id:s}),s},this.dismiss=e=>(e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.promise=(e,t)=>{let n=this.create({...t,promise:e,type:"loading",message:t.loading});return(e instanceof Promise?e:e()).then(r=>{let s=typeof t.success=="function"?t.success(r):t.success;this.create({id:n,type:"success",message:s})}).catch(r=>{let s=typeof t.error=="function"?t.error(r):t.error;this.create({id:n,type:"error",message:s})}),n},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||rl++;this.publish({jsx:e(n),id:n,...t})},this.subscribers=[],this.toasts=[]}},Yt=new Hy,qy=(e,t)=>{let n=(t==null?void 0:t.id)||rl++;return Yt.addToast({title:e,...t,id:n}),n},Qy=qy;Object.assign(Qy,{success:Yt.success,error:Yt.error,custom:Yt.custom,message:Yt.message,promise:Yt.promise,dismiss:Yt.dismiss});var Vy=3,Ky="32px",Gy=4e3,Yy=356,Mp=14,Jy=20,Xy=200,Zy=e=>{let{invert:t,toast:n,interacting:r,setHeights:s,visibleToasts:i,heights:o,index:l,toasts:u,expanded:c,removeToast:d,closeButton:h,style:m,className:v="",descriptionClassName:x="",duration:w,position:k,expandByDefault:p}=e,[f,g]=I.useState(!1),[b,P]=I.useState(!1),[T,C]=I.useState(!1),[j,R]=I.useState(!1),[M,K]=I.useState(0),[E,se]=I.useState(0),q=I.useRef(null),ae=l===0,Z=l+1<=i,oe=n.type,A=n.className||"",$=n.descriptionClassName||"",U=I.useMemo(()=>o.findIndex(Q=>Q.toastId===n.id)||0,[o,n.id]),re=I.useMemo(()=>n.duration||w||Gy,[n.duration,w]),V=I.useRef(0),ee=I.useRef(0),be=I.useRef(re),Qe=I.useRef(0),Ee=I.useRef(null),[jt,Os]=k.split("-"),Ot=I.useMemo(()=>o.reduce((Q,ce,Pe)=>Pe>=U?Q:Q+ce.height,0),[o,U]),bt=n.invert||t,Cr=oe==="loading";ee.current=I.useMemo(()=>U*Mp+Ot,[U,Ot]),I.useEffect(()=>{g(!0)},[]),I.useLayoutEffect(()=>{if(!f)return;let Q=q.current,ce=Q.style.height;Q.style.height="auto";let Pe=Q.getBoundingClientRect().height;Q.style.height=ce,se(Pe),s(dt=>dt.find(Nt=>Nt.toastId===n.id)?dt.map(Nt=>Nt.toastId===n.id?{...Nt,height:Pe}:Nt):[{toastId:n.id,height:Pe},...dt])},[f,n.title,n.description,s,n.id]);let fe=I.useCallback(()=>{P(!0),K(ee.current),s(Q=>Q.filter(ce=>ce.toastId!==n.id)),setTimeout(()=>{d(n)},Xy)},[n,d,s,ee]);return I.useEffect(()=>{if(n.promise&&oe==="loading"||n.duration===1/0)return;let Q;return c||r?(()=>{if(Qe.current<V.current){let ce=new Date().getTime()-V.current;be.current=be.current-ce}Qe.current=new Date().getTime()})():(V.current=new Date().getTime(),Q=setTimeout(()=>{var ce;(ce=n.onAutoClose)==null||ce.call(n,n),fe()},be.current)),()=>clearTimeout(Q)},[c,r,p,n,re,fe,n.promise,oe]),I.useEffect(()=>{let Q=q.current;if(Q){let ce=Q.getBoundingClientRect().height;return se(ce),s(Pe=>[{toastId:n.id,height:ce},...Pe]),()=>s(Pe=>Pe.filter(dt=>dt.toastId!==n.id))}},[s,n.id]),I.useEffect(()=>{n.delete&&fe()},[fe,n.delete]),I.createElement("li",{"aria-live":n.important?"assertive":"polite","aria-atomic":"true",role:"status",tabIndex:0,ref:q,className:v+" "+A,"data-sonner-toast":"","data-styled":!n.jsx,"data-mounted":f,"data-promise":!!n.promise,"data-removed":b,"data-visible":Z,"data-y-position":jt,"data-x-position":Os,"data-index":l,"data-front":ae,"data-swiping":T,"data-type":oe,"data-invert":bt,"data-swipe-out":j,"data-expanded":!!(c||p&&f),style:{"--index":l,"--toasts-before":l,"--z-index":u.length-l,"--offset":`${b?M:ee.current}px`,"--initial-height":p?"auto":`${E}px`,...m,...n.style},onPointerDown:Q=>{Cr||(K(ee.current),Q.target.setPointerCapture(Q.pointerId),Q.target.tagName!=="BUTTON"&&(C(!0),Ee.current={x:Q.clientX,y:Q.clientY}))},onPointerUp:()=>{var Q,ce,Pe;if(j)return;Ee.current=null;let dt=Number(((Q=q.current)==null?void 0:Q.style.getPropertyValue("--swipe-amount").replace("px",""))||0);if(Math.abs(dt)>=Jy){K(ee.current),(ce=n.onDismiss)==null||ce.call(n,n),fe(),R(!0);return}(Pe=q.current)==null||Pe.style.setProperty("--swipe-amount","0px"),C(!1)},onPointerMove:Q=>{var ce;if(!Ee.current)return;let Pe=Q.clientY-Ee.current.y,dt=Q.clientX-Ee.current.x,Nt=(jt==="top"?Math.min:Math.max)(0,Pe),Wn=Q.pointerType==="touch"?10:2;Math.abs(Nt)>Wn?(ce=q.current)==null||ce.style.setProperty("--swipe-amount",`${Pe}px`):Math.abs(dt)>Wn&&(Ee.current=null)}},h&&!n.jsx?I.createElement("button",{"aria-label":"Close toast","data-disabled":Cr,"data-close-button":!0,onClick:Cr?void 0:()=>{var Q;fe(),(Q=n.onDismiss)==null||Q.call(n,n)}},I.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},I.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),I.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}))):null,n.jsx||I.isValidElement(n.title)?n.jsx||n.title:I.createElement(I.Fragment,null,oe||n.icon||n.promise?I.createElement("div",{"data-icon":""},n.promise?I.createElement(Uy,{visible:oe==="loading"}):null,n.icon||Dy(oe)):null,I.createElement("div",{"data-content":""},I.createElement("div",{"data-title":""},n.title),n.description?I.createElement("div",{"data-description":"",className:x+$},n.description):null),n.cancel?I.createElement("button",{"data-button":!0,"data-cancel":!0,onClick:()=>{var Q;fe(),(Q=n.cancel)!=null&&Q.onClick&&n.cancel.onClick()}},n.cancel.label):null,n.action?I.createElement("button",{"data-button":"",onClick:Q=>{var ce;(ce=n.action)==null||ce.onClick(Q),!Q.defaultPrevented&&fe()}},n.action.label):null))},ev=e=>{var t;let{invert:n,position:r="bottom-right",hotkey:s=["altKey","KeyT"],expand:i,closeButton:o,className:l,offset:u,theme:c="light",richColors:d,duration:h,style:m,visibleToasts:v=Vy,toastOptions:x}=e,[w,k]=I.useState([]),[p,f]=I.useState([]),[g,b]=I.useState(!1),[P,T]=I.useState(!1),[C,j]=I.useState(c!=="system"?c:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),[R,M]=r.split("-"),K=I.useRef(null),E=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),se=I.useCallback(q=>k(ae=>ae.filter(({id:Z})=>Z!==q.id)),[]);return I.useEffect(()=>Yt.subscribe(q=>{if(q.dismiss){k(ae=>ae.map(Z=>Z.id===q.id?{...Z,delete:!0}:Z));return}setTimeout(()=>{Ug.flushSync(()=>{k(ae=>{let Z=ae.findIndex(oe=>oe.id===q.id);return Z!==-1?[...ae.slice(0,Z),{...ae[Z],...q},...ae.slice(Z+1)]:[q,...ae]})})})}),[]),I.useEffect(()=>{if(c!=="system"){j(c);return}typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",({matches:q})=>{j(q?"dark":"light")})},[c]),I.useEffect(()=>{w.length<=1&&b(!1)},[w]),I.useEffect(()=>{let q=ae=>{var Z,oe;s.every(A=>ae[A]||ae.code===A)&&(b(!0),(Z=K.current)==null||Z.focus()),ae.code==="Escape"&&(document.activeElement===K.current||(oe=K.current)!=null&&oe.contains(document.activeElement))&&b(!1)};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)},[s]),w.length?I.createElement("section",{"aria-label":`Notifications ${E}`,tabIndex:-1},I.createElement("ol",{tabIndex:-1,ref:K,className:l,"data-sonner-toaster":!0,"data-theme":C,"data-rich-colors":d,"data-y-position":R,"data-x-position":M,style:{"--front-toast-height":`${(t=p[0])==null?void 0:t.height}px`,"--offset":typeof u=="number"?`${u}px`:u||Ky,"--width":`${Yy}px`,"--gap":`${Mp}px`,...m},onMouseEnter:()=>b(!0),onMouseMove:()=>b(!0),onMouseLeave:()=>{P||b(!1)},onPointerDown:()=>{T(!0)},onPointerUp:()=>T(!1)},w.map((q,ae)=>I.createElement(Zy,{key:q.id,index:ae,toast:q,duration:h,className:x==null?void 0:x.className,descriptionClassName:x==null?void 0:x.descriptionClassName,invert:n,visibleToasts:v,closeButton:o,interacting:P,position:r,style:x==null?void 0:x.style,removeToast:se,toasts:w,heights:p,setHeights:f,expandByDefault:i,expanded:g})))):null},tv={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const nv=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ne=(e,t)=>{const n=N.forwardRef(({color:r="currentColor",size:s=24,strokeWidth:i=2,absoluteStrokeWidth:o,children:l,...u},c)=>N.createElement("svg",{ref:c,...tv,width:s,height:s,stroke:r,strokeWidth:o?Number(i)*24/Number(s):i,className:`lucide lucide-${nv(e)}`,...u},[...t.map(([d,h])=>N.createElement(d,h)),...(Array.isArray(l)?l:[l])||[]]));return n.displayName=`${e}`,n},eo=ne("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]),Ct=ne("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),sl=ne("AlertTriangle",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"c3ski4"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),rv=ne("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),sv=ne("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]),iv=ne("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]),zn=ne("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["polyline",{points:"22 4 12 14.01 9 11.01",key:"6xbx8j"}]]),_r=ne("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),Fr=ne("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),Mt=ne("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]),av=ne("FileCode",[["path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}],["path",{d:"m10 13-2 2 2 2",key:"17smn8"}],["path",{d:"m14 17 2-2-2-2",key:"14mezr"}]]),Rp=ne("FolderOpen",[["path",{d:"m6 14 1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2h3.93a2 2 0 0 1 1.66.9l.82 1.2a2 2 0 0 0 1.66.9H18a2 2 0 0 1 2 2v2",key:"1nmvlm"}]]),Lp=ne("Home",[["path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"y5dka4"}],["polyline",{points:"9 22 9 12 15 12 15 22",key:"e2us08"}]]),ov=ne("Layers",[["polygon",{points:"12 2 2 7 12 12 22 7 12 2",key:"1b0ttc"}],["polyline",{points:"2 17 12 22 22 17",key:"imjtdl"}],["polyline",{points:"2 12 12 17 22 12",key:"5dexcv"}]]),En=ne("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),ns=ne("MapPin",[["path",{d:"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z",key:"2oe9fu"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]),lv=ne("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]),Hc=ne("PauseCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]),mi=ne("PenSquare",[["path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1qinfi"}],["path",{d:"M18.5 2.5a2.12 2.12 0 0 1 3 3L12 15l-4 1 1-4Z",key:"w2jsv5"}]]),qc=ne("PlayCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]),pr=ne("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),Zt=ne("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),gi=ne("Save",[["path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z",key:"1owoqh"}],["polyline",{points:"17 21 17 13 7 13 7 21",key:"1md35c"}],["polyline",{points:"7 3 7 8 15 8",key:"8nz8an"}]]),uv=ne("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]),Qr=ne("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),cv=ne("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]),dv=ne("ToggleLeft",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]]),fv=ne("ToggleRight",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"16",cy:"12",r:"2",key:"4ma0v8"}]]),rs=ne("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),pv=ne("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]),hv=ne("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),mv=ne("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]),Qc=ne("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),ir=ne("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Ip=ne("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]);function _p(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(n=_p(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function gv(){for(var e,t,n=0,r="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=_p(e))&&(r&&(r+=" "),r+=t);return r}function yv(){for(var e=0,t,n,r="";e<arguments.length;)(t=arguments[e++])&&(n=Fp(t))&&(r&&(r+=" "),r+=n);return r}function Fp(e){if(typeof e=="string")return e;for(var t,n="",r=0;r<e.length;r++)e[r]&&(t=Fp(e[r]))&&(n&&(n+=" "),n+=t);return n}var lu="-";function vv(e){var t=wv(e),n=e.conflictingClassGroups,r=e.conflictingClassGroupModifiers,s=r===void 0?{}:r;function i(l){var u=l.split(lu);return u[0]===""&&u.length!==1&&u.shift(),Dp(u,t)||xv(l)}function o(l,u){var c=n[l]||[];return u&&s[l]?[].concat(c,s[l]):c}return{getClassGroupId:i,getConflictingClassGroupIds:o}}function Dp(e,t){var o;if(e.length===0)return t.classGroupId;var n=e[0],r=t.nextPart.get(n),s=r?Dp(e.slice(1),r):void 0;if(s)return s;if(t.validators.length!==0){var i=e.join(lu);return(o=t.validators.find(function(l){var u=l.validator;return u(i)}))==null?void 0:o.classGroupId}}var Vc=/^\[(.+)\]$/;function xv(e){if(Vc.test(e)){var t=Vc.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}}function wv(e){var t=e.theme,n=e.prefix,r={nextPart:new Map,validators:[]},s=bv(Object.entries(e.classGroups),n);return s.forEach(function(i){var o=i[0],l=i[1];il(l,r,o,t)}),r}function il(e,t,n,r){e.forEach(function(s){if(typeof s=="string"){var i=s===""?t:Kc(t,s);i.classGroupId=n;return}if(typeof s=="function"){if(jv(s)){il(s(r),t,n,r);return}t.validators.push({validator:s,classGroupId:n});return}Object.entries(s).forEach(function(o){var l=o[0],u=o[1];il(u,Kc(t,l),n,r)})})}function Kc(e,t){var n=e;return t.split(lu).forEach(function(r){n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n}function jv(e){return e.isThemeGetter}function bv(e,t){return t?e.map(function(n){var r=n[0],s=n[1],i=s.map(function(o){return typeof o=="string"?t+o:typeof o=="object"?Object.fromEntries(Object.entries(o).map(function(l){var u=l[0],c=l[1];return[t+u,c]})):o});return[r,i]}):e}function Nv(e){if(e<1)return{get:function(){},set:function(){}};var t=0,n=new Map,r=new Map;function s(i,o){n.set(i,o),t++,t>e&&(t=0,r=n,n=new Map)}return{get:function(o){var l=n.get(o);if(l!==void 0)return l;if((l=r.get(o))!==void 0)return s(o,l),l},set:function(o,l){n.has(o)?n.set(o,l):s(o,l)}}}var $p="!";function kv(e){var t=e.separator||":",n=t.length===1,r=t[0],s=t.length;return function(o){for(var l=[],u=0,c=0,d,h=0;h<o.length;h++){var m=o[h];if(u===0){if(m===r&&(n||o.slice(h,h+s)===t)){l.push(o.slice(c,h)),c=h+s;continue}if(m==="/"){d=h;continue}}m==="["?u++:m==="]"&&u--}var v=l.length===0?o:o.substring(c),x=v.startsWith($p),w=x?v.substring(1):v,k=d&&d>c?d-c:void 0;return{modifiers:l,hasImportantModifier:x,baseClassName:w,maybePostfixModifierPosition:k}}}function Sv(e){if(e.length<=1)return e;var t=[],n=[];return e.forEach(function(r){var s=r[0]==="[";s?(t.push.apply(t,n.sort().concat([r])),n=[]):n.push(r)}),t.push.apply(t,n.sort()),t}function Cv(e){return{cache:Nv(e.cacheSize),splitModifiers:kv(e),...vv(e)}}var Ev=/\s+/;function Pv(e,t){var n=t.splitModifiers,r=t.getClassGroupId,s=t.getConflictingClassGroupIds,i=new Set;return e.trim().split(Ev).map(function(o){var l=n(o),u=l.modifiers,c=l.hasImportantModifier,d=l.baseClassName,h=l.maybePostfixModifierPosition,m=r(h?d.substring(0,h):d),v=!!h;if(!m){if(!h)return{isTailwindClass:!1,originalClassName:o};if(m=r(d),!m)return{isTailwindClass:!1,originalClassName:o};v=!1}var x=Sv(u).join(":"),w=c?x+$p:x;return{isTailwindClass:!0,modifierId:w,classGroupId:m,originalClassName:o,hasPostfixModifier:v}}).reverse().filter(function(o){if(!o.isTailwindClass)return!0;var l=o.modifierId,u=o.classGroupId,c=o.hasPostfixModifier,d=l+u;return i.has(d)?!1:(i.add(d),s(u,c).forEach(function(h){return i.add(l+h)}),!0)}).reverse().map(function(o){return o.originalClassName}).join(" ")}function Tv(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,s,i,o=l;function l(c){var d=t[0],h=t.slice(1),m=h.reduce(function(v,x){return x(v)},d());return r=Cv(m),s=r.cache.get,i=r.cache.set,o=u,u(c)}function u(c){var d=s(c);if(d)return d;var h=Pv(c,r);return i(c,h),h}return function(){return o(yv.apply(null,arguments))}}function he(e){var t=function(r){return r[e]||[]};return t.isThemeGetter=!0,t}var Up=/^\[(?:([a-z-]+):)?(.+)\]$/i,Ov=/^\d+\/\d+$/,zv=new Set(["px","full","screen"]),Av=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Mv=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Rv=/^-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/;function pt(e){return Pn(e)||zv.has(e)||Ov.test(e)||al(e)}function al(e){return Un(e,"length",$v)}function Lv(e){return Un(e,"size",Wp)}function Iv(e){return Un(e,"position",Wp)}function _v(e){return Un(e,"url",Uv)}function Xs(e){return Un(e,"number",Pn)}function Pn(e){return!Number.isNaN(Number(e))}function Fv(e){return e.endsWith("%")&&Pn(e.slice(0,-1))}function Dr(e){return Gc(e)||Un(e,"number",Gc)}function X(e){return Up.test(e)}function $r(){return!0}function Qt(e){return Av.test(e)}function Dv(e){return Un(e,"",Wv)}function Un(e,t,n){var r=Up.exec(e);return r?r[1]?r[1]===t:n(r[2]):!1}function $v(e){return Mv.test(e)}function Wp(){return!1}function Uv(e){return e.startsWith("url(")}function Gc(e){return Number.isInteger(Number(e))}function Wv(e){return Rv.test(e)}function Bv(){var e=he("colors"),t=he("spacing"),n=he("blur"),r=he("brightness"),s=he("borderColor"),i=he("borderRadius"),o=he("borderSpacing"),l=he("borderWidth"),u=he("contrast"),c=he("grayscale"),d=he("hueRotate"),h=he("invert"),m=he("gap"),v=he("gradientColorStops"),x=he("gradientColorStopPositions"),w=he("inset"),k=he("margin"),p=he("opacity"),f=he("padding"),g=he("saturate"),b=he("scale"),P=he("sepia"),T=he("skew"),C=he("space"),j=he("translate"),R=function(){return["auto","contain","none"]},M=function(){return["auto","hidden","clip","visible","scroll"]},K=function(){return["auto",X,t]},E=function(){return[X,t]},se=function(){return["",pt]},q=function(){return["auto",Pn,X]},ae=function(){return["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"]},Z=function(){return["solid","dashed","dotted","double","none"]},oe=function(){return["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-lighter"]},A=function(){return["start","end","center","between","around","evenly","stretch"]},$=function(){return["","0",X]},U=function(){return["auto","avoid","all","avoid-page","page","left","right","column"]},re=function(){return[Pn,Xs]},V=function(){return[Pn,X]};return{cacheSize:500,theme:{colors:[$r],spacing:[pt],blur:["none","",Qt,X],brightness:re(),borderColor:[e],borderRadius:["none","","full",Qt,X],borderSpacing:E(),borderWidth:se(),contrast:re(),grayscale:$(),hueRotate:V(),invert:$(),gap:E(),gradientColorStops:[e],gradientColorStopPositions:[Fv,al],inset:K(),margin:K(),opacity:re(),padding:E(),saturate:re(),scale:re(),sepia:$(),skew:V(),space:E(),translate:E()},classGroups:{aspect:[{aspect:["auto","square","video",X]}],container:["container"],columns:[{columns:[Qt]}],"break-after":[{"break-after":U()}],"break-before":[{"break-before":U()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none"]}],clear:[{clear:["left","right","both","none"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[].concat(ae(),[X])}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:R()}],"overscroll-x":[{"overscroll-x":R()}],"overscroll-y":[{"overscroll-y":R()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[w]}],"inset-x":[{"inset-x":[w]}],"inset-y":[{"inset-y":[w]}],start:[{start:[w]}],end:[{end:[w]}],top:[{top:[w]}],right:[{right:[w]}],bottom:[{bottom:[w]}],left:[{left:[w]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Dr]}],basis:[{basis:K()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",X]}],grow:[{grow:$()}],shrink:[{shrink:$()}],order:[{order:["first","last","none",Dr]}],"grid-cols":[{"grid-cols":[$r]}],"col-start-end":[{col:["auto",{span:["full",Dr]},X]}],"col-start":[{"col-start":q()}],"col-end":[{"col-end":q()}],"grid-rows":[{"grid-rows":[$r]}],"row-start-end":[{row:["auto",{span:[Dr]},X]}],"row-start":[{"row-start":q()}],"row-end":[{"row-end":q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",X]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",X]}],gap:[{gap:[m]}],"gap-x":[{"gap-x":[m]}],"gap-y":[{"gap-y":[m]}],"justify-content":[{justify:["normal"].concat(A())}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal"].concat(A(),["baseline"])}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[].concat(A(),["baseline"])}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[f]}],px:[{px:[f]}],py:[{py:[f]}],ps:[{ps:[f]}],pe:[{pe:[f]}],pt:[{pt:[f]}],pr:[{pr:[f]}],pb:[{pb:[f]}],pl:[{pl:[f]}],m:[{m:[k]}],mx:[{mx:[k]}],my:[{my:[k]}],ms:[{ms:[k]}],me:[{me:[k]}],mt:[{mt:[k]}],mr:[{mr:[k]}],mb:[{mb:[k]}],ml:[{ml:[k]}],"space-x":[{"space-x":[C]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[C]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit",X,t]}],"min-w":[{"min-w":["min","max","fit",X,pt]}],"max-w":[{"max-w":["0","none","full","min","max","fit","prose",{screen:[Qt]},Qt,X]}],h:[{h:[X,t,"auto","min","max","fit"]}],"min-h":[{"min-h":["min","max","fit",X,pt]}],"max-h":[{"max-h":[X,t,"min","max","fit"]}],"font-size":[{text:["base",Qt,al]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Xs]}],"font-family":[{font:[$r]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractons"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",X]}],"line-clamp":[{"line-clamp":["none",Pn,Xs]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",X,pt]}],"list-image":[{"list-image":["none",X]}],"list-style-type":[{list:["none","disc","decimal",X]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[p]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[p]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[].concat(Z(),["wavy"])}],"text-decoration-thickness":[{decoration:["auto","from-font",pt]}],"underline-offset":[{"underline-offset":["auto",X,pt]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],indent:[{indent:E()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",X]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",X]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[p]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[].concat(ae(),[Iv])}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Lv]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},_v]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[x]}],"gradient-via-pos":[{via:[x]}],"gradient-to-pos":[{to:[x]}],"gradient-from":[{from:[v]}],"gradient-via":[{via:[v]}],"gradient-to":[{to:[v]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[p]}],"border-style":[{border:[].concat(Z(),["hidden"])}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[p]}],"divide-style":[{divide:Z()}],"border-color":[{border:[s]}],"border-color-x":[{"border-x":[s]}],"border-color-y":[{"border-y":[s]}],"border-color-t":[{"border-t":[s]}],"border-color-r":[{"border-r":[s]}],"border-color-b":[{"border-b":[s]}],"border-color-l":[{"border-l":[s]}],"divide-color":[{divide:[s]}],"outline-style":[{outline:[""].concat(Z())}],"outline-offset":[{"outline-offset":[X,pt]}],"outline-w":[{outline:[pt]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:se()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[p]}],"ring-offset-w":[{"ring-offset":[pt]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Qt,Dv]}],"shadow-color":[{shadow:[$r]}],opacity:[{opacity:[p]}],"mix-blend":[{"mix-blend":oe()}],"bg-blend":[{"bg-blend":oe()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",Qt,X]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[h]}],saturate:[{saturate:[g]}],sepia:[{sepia:[P]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[d]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[p]}],"backdrop-saturate":[{"backdrop-saturate":[g]}],"backdrop-sepia":[{"backdrop-sepia":[P]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",X]}],duration:[{duration:V()}],ease:[{ease:["linear","in","out","in-out",X]}],delay:[{delay:V()}],animate:[{animate:["none","spin","ping","pulse","bounce",X]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[b]}],"scale-x":[{"scale-x":[b]}],"scale-y":[{"scale-y":[b]}],rotate:[{rotate:[Dr,X]}],"translate-x":[{"translate-x":[j]}],"translate-y":[{"translate-y":[j]}],"skew-x":[{"skew-x":[T]}],"skew-y":[{"skew-y":[T]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",X]}],accent:[{accent:["auto",e]}],appearance:["appearance-none"],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",X]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":E()}],"scroll-mx":[{"scroll-mx":E()}],"scroll-my":[{"scroll-my":E()}],"scroll-ms":[{"scroll-ms":E()}],"scroll-me":[{"scroll-me":E()}],"scroll-mt":[{"scroll-mt":E()}],"scroll-mr":[{"scroll-mr":E()}],"scroll-mb":[{"scroll-mb":E()}],"scroll-ml":[{"scroll-ml":E()}],"scroll-p":[{"scroll-p":E()}],"scroll-px":[{"scroll-px":E()}],"scroll-py":[{"scroll-py":E()}],"scroll-ps":[{"scroll-ps":E()}],"scroll-pe":[{"scroll-pe":E()}],"scroll-pt":[{"scroll-pt":E()}],"scroll-pr":[{"scroll-pr":E()}],"scroll-pb":[{"scroll-pb":E()}],"scroll-pl":[{"scroll-pl":E()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","pinch-zoom","manipulation",{pan:["x","left","right","y","up","down"]}]}],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",X]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[pt,Xs]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}}var Hv=Tv(Bv);function qv(...e){return Hv(gv(e))}const Qv=[{name:"Dashboard",href:"/",icon:Lp},{name:"Organizations",href:"/organizations",icon:Qr},{name:"Service Mappings",href:"/service-mappings",icon:ns}];function Vv({children:e}){const t=Ts(),[n,r]=N.useState(null);return N.useEffect(()=>{fetch("/api/health").then(s=>s.json()).then(s=>r({version:s.version,environment:s.environment})).catch(()=>r(null))},[]),a.jsxs("div",{className:"min-h-screen bg-background",style:{minHeight:"100vh",backgroundColor:"#ffffff"},children:[a.jsx("header",{className:"border-b border-border bg-card",style:{backgroundColor:"#f8f9fa",borderBottom:"1px solid #e0e0e0"},children:a.jsx("div",{className:"flex h-16 items-center px-6",children:a.jsxs("div",{className:"flex items-center space-x-4",children:[a.jsx(lv,{className:"h-6 w-6 md:hidden"}),a.jsx("h1",{className:"text-xl font-semibold text-foreground",style:{color:"#000000",fontSize:"1.25rem",fontWeight:"600"},children:"AI Agent Service"})]})})}),a.jsxs("div",{className:"flex",children:[a.jsx("aside",{className:"hidden w-64 border-r border-border bg-card md:block",children:a.jsx("nav",{className:"space-y-1 p-4",children:Qv.map(s=>{const i=t.pathname===s.href||s.href!=="/"&&t.pathname.startsWith(s.href);return a.jsxs(jp,{to:s.href,className:qv("flex items-center space-x-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors",i?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[a.jsx(s.icon,{className:"h-5 w-5"}),a.jsx("span",{children:s.name})]},s.name)})})}),a.jsx("main",{className:"flex-1 p-6",children:a.jsx("div",{className:"mx-auto max-w-7xl",children:e})})]}),a.jsx("footer",{className:"border-t border-border bg-card px-6 py-3",style:{backgroundColor:"#f8f9fa",borderTop:"1px solid #e0e0e0"},children:a.jsxs("div",{className:"flex justify-between items-center text-xs text-gray-500",children:[a.jsx("span",{children:"AI Agent Service"}),n&&a.jsxs("span",{children:["v",n.version]})]})})]})}const Kv={}.VITE_API_URL||"/api";function Gv(e){const t=e.startsWith("/")?e.slice(1):e;return`${Kv}/${t}`}async function Zs(e,t){const n=Gv(e);try{const r=await fetch(n,{...t,headers:{"Content-Type":"application/json",...t==null?void 0:t.headers}});if(!r.ok)throw new Error(`API request failed: ${r.status} ${r.statusText}`);return r}catch(r){throw console.error(`API request error for ${e}:`,r),r}}const ei={health:"health",ready:"ready",analysis:"analysis",analysisStatus:e=>`analysis/${e}`,queueQueued:"queue/queued",queueInProgress:"queue/in-progress",queueCompleted:"queue/completed",queueFailed:"queue/failed",workItemsHealth:"work-items/health",workItemsErrors:"work-items/errors",workItemsLogs:"work-items/logs",errorsRecent:"errors/recent",workspaceDiscover:"workspace/discover",workspaceList:"workspace/list",workspaceStats:e=>e?`workspace/stats/${e}`:"workspace/stats",websocketStatus:"websocket/status",websocketActivity:"websocket/activity",websocketWorker:"websocket/worker",websocketReconnect:"websocket/reconnect",usageStats:"usage/stats",usageHistory:"usage/history",usageRateLimit:"usage/rate-limit",analyticsProjects:"analytics/projects",analyticsStats:"analytics/stats",analyticsOperations:"analytics/operations"};function Yv(){var j,R,M,K;const[e,t]=N.useState(null),[n,r]=N.useState(null),[s,i]=N.useState(null),[o,l]=N.useState(null),[u,c]=N.useState(!0),[d,h]=N.useState(null),[m,v]=N.useState("queued"),[x,w]=N.useState(null);N.useEffect(()=>{const E=async()=>{try{c(!0),h(null);const[q,ae,Z,oe]=await Promise.allSettled([Zs(ei.queueQueued),Zs(ei.queueInProgress),Zs(ei.queueCompleted+"?limit=10"),Zs(ei.queueFailed+"?limit=10")]);if(q.status==="fulfilled"&&q.value.ok){const A=await q.value.json();t(A.data)}if(ae.status==="fulfilled"&&ae.value.ok){const A=await ae.value.json();r(A.data)}if(Z.status==="fulfilled"&&Z.value.ok){const A=await Z.value.json();i(A.data)}if(oe.status==="fulfilled"&&oe.value.ok){const A=await oe.value.json();l(A.data)}}catch(q){h(q instanceof Error?q.message:"Failed to fetch work queue data")}finally{c(!1)}};E();const se=setInterval(E,1e4);return()=>clearInterval(se)},[]);const k=E=>{const se=Math.floor(E/60),q=Math.floor(se/60);return q>0?`${q}h ${se%60}m`:se>0?`${se}m`:`${E}s`},p=E=>{const se=new Date,q=new Date(E),ae=se.getTime()-q.getTime(),Z=Math.floor(ae/(1e3*60));if(Z<1)return"Just now";if(Z<60)return`${Z}m ago`;const oe=Math.floor(Z/60);return oe<24?`${oe}h ago`:`${Math.floor(oe/24)}d ago`},f=E=>{switch(E){case"project_review":return"📋";case"code_review":return"🔍";case"story_implementation":return"⚡";case"development_planning":return"📊";default:return"📄"}},g=E=>E>=9?"text-red-600 bg-red-50":E>=7?"text-orange-600 bg-orange-50":E>=5?"text-yellow-600 bg-yellow-50":"text-green-600 bg-green-50",b=E=>E>=9?"Critical":E>=7?"High":E>=5?"Medium":"Low",P=E=>{switch(E){case"completed":return a.jsx(zn,{className:"w-4 h-4 text-green-600"});case"failed":return a.jsx(Ct,{className:"w-4 h-4 text-red-600"});case"in_progress":return a.jsx(En,{className:"w-4 h-4 text-blue-600 animate-spin"});case"queued":return a.jsx(Mt,{className:"w-4 h-4 text-yellow-600"});default:return a.jsx(Mt,{className:"w-4 h-4 text-gray-400"})}},T=E=>{switch(E){case"completed":return"text-green-600 bg-green-50 border-green-200";case"failed":return"text-red-600 bg-red-50 border-red-200";case"in_progress":return"text-blue-600 bg-blue-50 border-blue-200";case"queued":return"text-yellow-600 bg-yellow-50 border-yellow-200";default:return"text-gray-600 bg-gray-50 border-gray-200"}},C=(E,se)=>{var q;return a.jsxs("div",{className:"border rounded-lg p-4 hover:bg-gray-50 transition-colors",children:[a.jsxs("div",{className:"flex items-start justify-between mb-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-lg",children:f(E.type)}),a.jsxs("div",{children:[a.jsx("h4",{className:"font-medium text-sm",children:E.title}),a.jsx("p",{className:"text-xs text-gray-600",children:E.projectName})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[se==="completed"&&a.jsxs("span",{className:`px-2 py-1 rounded border text-xs font-medium flex items-center gap-1 ${T(E.status)}`,children:[P(E.status),E.status==="completed"?"Success":E.status==="failed"?"Failed":E.status]}),a.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${g(E.priority)}`,children:b(E.priority)}),E.estimatedDuration&&a.jsxs("span",{className:"text-xs text-gray-500 flex items-center gap-1",children:[a.jsx(Mt,{className:"w-3 h-3"}),k(E.estimatedDuration)]}),E.actualDuration&&se==="completed"&&a.jsxs("span",{className:"text-xs text-gray-500 flex items-center gap-1",children:[a.jsx(Mt,{className:"w-3 h-3"}),k(Math.round(E.actualDuration/1e3))," actual"]})]})]}),E.description&&a.jsx("p",{className:"text-xs text-gray-600 mb-2 line-clamp-2",children:E.description}),E.progress&&E.status==="in_progress"&&a.jsxs("div",{className:"mb-2",children:[a.jsxs("div",{className:"flex justify-between text-xs text-gray-600 mb-1",children:[a.jsx("span",{children:E.progress.currentStep}),a.jsxs("span",{children:[E.progress.percentage,"%"]})]}),a.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2",children:a.jsx("div",{className:"bg-blue-600 h-2 rounded-full transition-all duration-300",style:{width:`${E.progress.percentage}%`}})})]}),E.status==="failed"&&a.jsxs("div",{className:"mb-2 p-2 bg-red-50 rounded border border-red-200 flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ct,{className:"w-4 h-4 text-red-600"}),a.jsx("span",{className:"text-xs text-red-800 font-medium",children:"Work item failed"}),((q=E.metadata)==null?void 0:q.failedAt)&&a.jsxs("span",{className:"text-xs text-red-600",children:["• Failed: ",p(E.metadata.failedAt)]})]}),a.jsx("button",{onClick:ae=>{ae.stopPropagation(),w(E)},className:"px-2 py-1 text-xs bg-red-100 text-red-700 hover:bg-red-200 rounded transition-colors",children:"View Details"})]}),a.jsxs("div",{className:"flex justify-between items-center text-xs text-gray-500",children:[a.jsxs("span",{children:["Created ",p(E.createdAt)]}),E.assignedTo&&a.jsx("span",{className:"bg-blue-100 text-blue-800 px-2 py-1 rounded",children:E.assignedTo}),E.completedAt&&a.jsxs("span",{className:"text-green-600",children:["Completed ",p(E.completedAt)]})]})]},`${se}-${E.id}`)};return u?a.jsx("div",{className:"rounded-lg border bg-card p-6",children:a.jsxs("div",{className:"flex items-center justify-center py-8",children:[a.jsx(En,{className:"h-8 w-8 animate-spin text-blue-600"}),a.jsx("span",{className:"ml-2 text-sm text-gray-600",children:"Loading work queue..."})]})}):d?a.jsx("div",{className:"rounded-lg border bg-card p-6",children:a.jsxs("div",{className:"flex items-center justify-center py-8 text-red-600",children:[a.jsx(Ct,{className:"h-6 w-6 mr-2"}),a.jsx("span",{className:"text-sm",children:d})]})}):a.jsxs("div",{className:"rounded-lg border bg-card",children:[a.jsxs("div",{className:"p-6 border-b",children:[a.jsx("h3",{className:"text-lg font-medium mb-4",children:"Work Queue Status"}),a.jsxs("div",{className:"flex space-x-1 bg-gray-100 rounded-lg p-1",children:[a.jsxs("button",{onClick:()=>v("queued"),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-md text-sm font-medium transition-colors ${m==="queued"?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:[a.jsx(Hc,{className:"w-4 h-4"}),"Queued (",(e==null?void 0:e.total)||0,")"]}),a.jsxs("button",{onClick:()=>v("progress"),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-md text-sm font-medium transition-colors ${m==="progress"?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:[a.jsx(qc,{className:"w-4 h-4"}),"In Progress (",(n==null?void 0:n.total)||0,")"]}),a.jsxs("button",{onClick:()=>v("completed"),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-md text-sm font-medium transition-colors ${m==="completed"?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:[a.jsx(zn,{className:"w-4 h-4"}),"Recent (",(s==null?void 0:s.total)||0,")"]}),a.jsxs("button",{onClick:()=>v("failed"),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-md text-sm font-medium transition-colors ${m==="failed"?"bg-white text-red-600 shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:[a.jsx(Ct,{className:"w-4 h-4"}),"Failed (",(o==null?void 0:o.total)||0,")"]})]})]}),a.jsxs("div",{className:"p-6",children:[m==="queued"&&(e==null?void 0:e.estimatedWaitTime)&&a.jsx("div",{className:"mb-4 p-3 bg-yellow-50 rounded-lg border border-yellow-200",children:a.jsxs("p",{className:"text-sm text-yellow-800",children:[a.jsx(Mt,{className:"w-4 h-4 inline mr-1"}),"Estimated wait time: ",k(e.estimatedWaitTime)]})}),m==="progress"&&(n==null?void 0:n.totalEstimatedRemaining)&&a.jsx("div",{className:"mb-4 p-3 bg-blue-50 rounded-lg border border-blue-200",children:a.jsxs("p",{className:"text-sm text-blue-800",children:[a.jsx(En,{className:"w-4 h-4 inline mr-1"}),"Estimated remaining time: ",k(n.totalEstimatedRemaining)]})}),a.jsxs("div",{className:"space-y-3",children:[m==="queued"&&a.jsx(a.Fragment,{children:(e==null?void 0:e.items.length)===0?a.jsxs("div",{className:"text-center py-8 text-gray-500",children:[a.jsx(Hc,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:"No items in queue"})]}):e==null?void 0:e.items.map(E=>C(E,"queued"))}),m==="progress"&&a.jsx(a.Fragment,{children:(n==null?void 0:n.items.length)===0?a.jsxs("div",{className:"text-center py-8 text-gray-500",children:[a.jsx(qc,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:"No items in progress"})]}):n==null?void 0:n.items.map(E=>C(E,"progress"))}),m==="completed"&&a.jsx(a.Fragment,{children:(s==null?void 0:s.items.length)===0?a.jsxs("div",{className:"text-center py-8 text-gray-500",children:[a.jsx(zn,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:"No completed items"})]}):s==null?void 0:s.items.map(E=>C(E,"completed"))}),m==="failed"&&a.jsx(a.Fragment,{children:(o==null?void 0:o.items.length)===0?a.jsxs("div",{className:"text-center py-8 text-gray-500",children:[a.jsx(Ct,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:"No failed items"})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"mb-4 p-3 bg-red-50 rounded-lg border border-red-200",children:a.jsxs("p",{className:"text-sm text-red-800",children:[a.jsx(Ct,{className:"w-4 h-4 inline mr-1"}),(o==null?void 0:o.total)||0," work items have failed and may need attention"]})}),o==null?void 0:o.items.map(E=>C(E,"failed"))]})})]}),m==="completed"&&(s==null?void 0:s.hasMore)&&a.jsx("div",{className:"mt-4 text-center",children:a.jsx("button",{className:"px-4 py-2 text-sm text-blue-600 hover:text-blue-800 hover:bg-blue-50 rounded-lg transition-colors",children:"Load more completed items"})})]}),x&&a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-white rounded-lg p-6 max-w-2xl w-full mx-4 max-h-[80vh] overflow-y-auto",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ct,{className:"w-5 h-5 text-red-600"}),a.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Error Details"})]}),a.jsx("button",{onClick:()=>w(null),className:"text-gray-400 hover:text-gray-600 transition-colors",children:a.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"border rounded-lg p-4 bg-gray-50",children:[a.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:"Work Item Information"}),a.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-gray-600",children:"Type:"}),a.jsx("span",{className:"ml-2",children:x.type})]}),a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-gray-600",children:"Status:"}),a.jsx("span",{className:"ml-2 text-red-600",children:"Failed"})]}),a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-gray-600",children:"Project:"}),a.jsx("span",{className:"ml-2",children:x.projectName})]}),a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-gray-600",children:"Created:"}),a.jsxs("span",{className:"ml-2",children:[p(x.createdAt)," ago"]})]}),x.completedAt&&a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-gray-600",children:"Failed:"}),a.jsxs("span",{className:"ml-2",children:[p(x.completedAt)," ago"]})]}),x.assignedTo&&a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-gray-600",children:"Assigned to:"}),a.jsx("span",{className:"ml-2",children:x.assignedTo})]})]})]}),a.jsxs("div",{className:"border rounded-lg p-4 bg-red-50 border-red-200",children:[a.jsxs("h3",{className:"font-medium text-red-900 mb-2 flex items-center gap-2",children:[a.jsx(Ct,{className:"w-4 h-4"}),"Error Message"]}),a.jsx("p",{className:"text-red-800 text-sm",children:((j=x.metadata)==null?void 0:j.reason)||((R=x.metadata)==null?void 0:R.failureReason)||((M=x.metadata)==null?void 0:M.error)||"No specific error message available"})]}),((K=x.metadata)==null?void 0:K.errorHistory)&&x.metadata.errorHistory.length>0&&a.jsxs("div",{className:"border rounded-lg p-4",children:[a.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:"Attempt History"}),a.jsxs("div",{className:"text-sm text-gray-600",children:[a.jsxs("p",{className:"mb-2",children:["This work item failed after ",x.metadata.errorHistory.length," attempt",x.metadata.errorHistory.length>1?"s":"",":"]}),a.jsx("div",{className:"space-y-2",children:x.metadata.errorHistory.map((E,se)=>a.jsxs("div",{className:"flex items-center justify-between p-2 bg-gray-50 rounded",children:[a.jsxs("span",{children:["Attempt #",E.attemptNumber||se+1]}),a.jsx("span",{className:"text-xs text-gray-500",children:E.timestamp&&p(E.timestamp)})]},se))})]})]}),x.metadata&&Object.keys(x.metadata).length>0&&a.jsxs("div",{className:"border rounded-lg p-4",children:[a.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:"Additional Information"}),a.jsxs("details",{className:"text-sm",children:[a.jsx("summary",{className:"cursor-pointer text-gray-600 hover:text-gray-800",children:"View raw metadata"}),a.jsx("pre",{className:"mt-2 text-xs bg-gray-50 p-2 rounded overflow-x-auto",children:JSON.stringify(x.metadata,null,2)})]})]})]}),a.jsx("div",{className:"flex justify-end mt-6",children:a.jsx("button",{onClick:()=>w(null),className:"px-4 py-2 bg-gray-100 text-gray-700 rounded hover:bg-gray-200 transition-colors",children:"Close"})})]})})]})}function Jv(){const[e,t]=N.useState(null),[n,r]=N.useState(!0),[s,i]=N.useState(!1);N.useEffect(()=>{const d=async()=>{try{const m=await fetch("/api/smart-polling/metrics");if(m.ok){const v=await m.json();t(v.data)}}catch(m){console.error("Failed to fetch smart polling metrics:",m)}finally{r(!1)}};d();const h=setInterval(d,1e4);return()=>clearInterval(h)},[]);const o=async()=>{i(!0);try{if((await fetch("/api/smart-polling/force",{method:"POST"})).ok){const h=await fetch("/api/smart-polling/metrics");if(h.ok){const m=await h.json();t(m.data)}}}catch(d){console.error("Failed to force polling:",d)}finally{i(!1)}},l=d=>d<1e3?`${d}ms`:d<6e4?`${Math.round(d/1e3)}s`:`${Math.round(d/6e4)}m`,u=d=>{if(!d)return"Never";const h=new Date(d),v=new Date().getTime()-h.getTime();return v<6e4?`${Math.round(v/1e3)}s ago`:v<36e5?`${Math.round(v/6e4)}m ago`:h.toLocaleTimeString()},c=d=>d.isPolling?d.consecutiveErrors>=3?a.jsx(sl,{className:"h-4 w-4 text-red-500"}):d.consecutiveErrors>0?a.jsx(Mt,{className:"h-4 w-4 text-yellow-500"}):a.jsx(zn,{className:"h-4 w-4 text-green-500"}):a.jsx(cv,{className:"h-4 w-4 text-gray-500"});return n||!e?a.jsxs("div",{className:"rounded-lg border bg-card",children:[a.jsx("div",{className:"border-b border-border p-4",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(eo,{className:"h-5 w-5"}),a.jsx("h3",{className:"text-lg font-medium",children:"Smart Polling Status"})]})}),a.jsx("div",{className:"p-6",children:a.jsx("div",{className:"animate-pulse",children:a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"h-4 bg-muted rounded"}),a.jsx("div",{className:"h-4 bg-muted rounded w-3/4"}),a.jsx("div",{className:"h-4 bg-muted rounded w-1/2"})]})})})]}):a.jsxs("div",{className:"rounded-lg border bg-card",children:[a.jsx("div",{className:"border-b border-border p-4",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(eo,{className:"h-5 w-5"}),a.jsx("h3",{className:"text-lg font-medium",children:"Smart Polling Status"}),a.jsxs("div",{className:"ml-auto flex items-center gap-4 text-sm text-muted-foreground",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500"}),"Active: ",e.activePolling,"/",e.totalOrganizations]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Ip,{className:"h-3 w-3"}),"Avg: ",l(e.averageInterval)]}),a.jsxs("button",{onClick:o,disabled:s,className:"flex items-center gap-1 px-2 py-1 text-xs bg-blue-500 hover:bg-blue-600 disabled:bg-blue-300 text-white rounded transition-colors",title:"Force immediate polling for all organizations",children:[a.jsx(Zt,{className:`h-3 w-3 ${s?"animate-spin":""}`}),s?"Polling...":"Force Poll"]})]})]})}),a.jsxs("div",{className:"p-6",children:[a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-6",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"text-2xl font-bold text-blue-600",children:e.totalPolls}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Polls"})]}),a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"text-2xl font-bold text-green-600",children:e.totalClaimedWork}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"Work Claimed"})]}),a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"text-2xl font-bold text-red-600",children:e.totalErrors}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Errors"})]}),a.jsxs("div",{className:"text-center",children:[a.jsxs("div",{className:"text-2xl font-bold text-purple-600",children:[(e.errorRate*100).toFixed(1),"%"]}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"Error Rate"})]})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-3",children:"Organization Status"}),e.organizationStats.length===0?a.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[a.jsx(eo,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:"No organizations configured"})]}):e.organizationStats.map(d=>a.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted/50",children:[a.jsx("div",{className:"flex-shrink-0",children:c(d)}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx("p",{className:"font-medium truncate",children:d.organizationName}),a.jsx("span",{className:`text-xs px-2 py-1 rounded ${d.isPolling?"bg-green-100 text-green-700":"bg-gray-100 text-gray-700"}`,children:d.isPolling?"Polling":"Stopped"})]}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2 text-xs text-muted-foreground",children:[a.jsxs("div",{children:[a.jsx("span",{className:"font-medium",children:"Interval:"})," ",l(d.currentInterval)]}),a.jsxs("div",{children:[a.jsx("span",{className:"font-medium",children:"Last Poll:"})," ",u(d.lastPollAt)]}),a.jsxs("div",{children:[a.jsx("span",{className:"font-medium",children:"Work Claimed:"})," ",d.claimedWorkCount]}),a.jsxs("div",{className:d.consecutiveErrors>0?"text-red-600":"",children:[a.jsx("span",{className:"font-medium",children:"Errors:"})," ",d.totalErrors,d.consecutiveErrors>0&&` (${d.consecutiveErrors} consecutive)`]})]})]}),a.jsxs("div",{className:"flex-shrink-0 text-right",children:[a.jsx("div",{className:"text-sm font-medium",children:d.totalPolls}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"polls"})]})]},d.organizationId))]}),a.jsxs("div",{className:"mt-6 p-3 bg-muted/30 rounded-lg",children:[a.jsx("div",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Status Indicators"}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2 text-xs",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(zn,{className:"h-3 w-3 text-green-500"}),a.jsx("span",{children:"Healthy polling"})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Mt,{className:"h-3 w-3 text-yellow-500"}),a.jsx("span",{children:"Some errors"})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(sl,{className:"h-3 w-3 text-red-500"}),a.jsx("span",{children:"Multiple failures"})]})]})]})]})]})}function Xv(){const[e,t]=N.useState(null),[n,r]=N.useState(!0);N.useEffect(()=>{const i=async()=>{try{const l=await fetch("/api/queue/stats");if(l.ok){const u=await l.json();t({queued:u.queued,inProgress:u.inProgress,completedToday:u.completed,completedThisWeek:u.completed,averageCompletionTime:u.averageCompletionTime*1e3,successRate:u.successRate,activeAgents:u.workers,totalProcessed:u.total})}}catch(l){console.error("Failed to fetch queue stats:",l)}finally{r(!1)}};i();const o=setInterval(i,3e4);return()=>clearInterval(o)},[]);const s=i=>i<1e3?`${i}ms`:i<6e4?`${(i/1e3).toFixed(1)}s`:`${(i/6e4).toFixed(1)}m`;return a.jsxs(a.Fragment,{children:[a.jsx(pn,{children:a.jsx("title",{children:"Dashboard - AI Agent Service"})}),a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Dashboard"}),a.jsx("p",{className:"text-muted-foreground",children:"Overview of your AI Agent Service performance"})]}),a.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[a.jsxs("div",{className:"rounded-lg border bg-card p-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Total Tasks"}),a.jsx("div",{className:"text-2xl font-bold text-blue-600",children:n?"-":(e==null?void 0:e.totalProcessed)||0})]}),a.jsx(sv,{className:"h-8 w-8 text-blue-600"})]}),a.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"All time"})]}),a.jsxs("div",{className:"rounded-lg border bg-card p-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Success Rate"}),a.jsx("div",{className:"text-2xl font-bold text-green-600",children:n?"-":`${Math.round(((e==null?void 0:e.successRate)||0)*100)}%`})]}),a.jsx(pv,{className:"h-8 w-8 text-green-600"})]}),a.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Overall performance"})]}),a.jsxs("div",{className:"rounded-lg border bg-card p-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Avg Completion Time"}),a.jsx("div",{className:"text-2xl font-bold text-purple-600",children:n?"-":s((e==null?void 0:e.averageCompletionTime)||0)})]}),a.jsx(Mt,{className:"h-8 w-8 text-purple-600"})]}),a.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Per task"})]}),a.jsxs("div",{className:"rounded-lg border bg-card p-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Active Agents"}),a.jsx("div",{className:"text-2xl font-bold text-orange-600",children:n?"-":(e==null?void 0:e.activeAgents)||0})]}),a.jsx(mv,{className:"h-8 w-8 text-orange-600"})]}),a.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Currently active"})]})]}),a.jsx(Jv,{}),a.jsx(Yv,{}),a.jsxs("div",{className:"rounded-lg border bg-card p-6",children:[a.jsx("h3",{className:"text-lg font-medium mb-4",children:"Welcome to AI Agent Service"}),a.jsx("p",{className:"text-muted-foreground",children:"This dashboard provides insights into your AI agent performance across multiple Task Shepherd organizations. Visit the Organizations page to manage connections and the Analytics page for detailed metrics."})]})]})]})}const Zv=({organizationId:e,onComplete:t,onCancel:n})=>{const[r,s]=N.useState({id:"",name:"",description:""}),[i,o]=N.useState(!1),[l,u]=N.useState(null),c=async h=>{h.preventDefault(),u(null),o(!0);try{const m=await fetch(`/api/organizations/${e}/workspaces`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,services:[]})});if(!m.ok){const x=await m.json();throw new Error(x.error||"Failed to create workspace")}const v=await m.json();if(v.success)t(v.data);else throw new Error(v.error||"Failed to create workspace")}catch(m){console.error("Failed to create workspace:",m),u(m instanceof Error?m.message:"Failed to create workspace")}finally{o(!1)}},d=r.id.trim()&&r.name.trim();return a.jsxs("div",{className:"max-w-2xl mx-auto bg-white rounded-lg shadow-lg",children:[a.jsx("div",{className:"px-6 py-4 border-b border-gray-200",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Register Workspace"}),a.jsx("button",{onClick:n,className:"text-gray-400 hover:text-gray-600",children:a.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),a.jsxs("form",{onSubmit:c,className:"p-6 space-y-6",children:[l&&a.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:a.jsx("p",{className:"text-sm text-red-700",children:l})}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"id",className:"block text-sm font-medium text-gray-700 mb-1",children:["Workspace ID ",a.jsx("span",{className:"text-red-500",children:"*"})]}),a.jsx("input",{type:"text",id:"id",value:r.id,onChange:h=>s({...r,id:h.target.value}),className:"block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500",placeholder:"my-workspace",required:!0}),a.jsx("p",{className:"mt-1 text-sm text-gray-500",children:'A unique identifier for this workspace (e.g., "my-app", "project-name")'})]}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"name",className:"block text-sm font-medium text-gray-700 mb-1",children:["Workspace Name ",a.jsx("span",{className:"text-red-500",children:"*"})]}),a.jsx("input",{type:"text",id:"name",value:r.name,onChange:h=>s({...r,name:h.target.value}),className:"block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500",placeholder:"My Workspace",required:!0}),a.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"A human-readable name for the workspace"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"description",className:"block text-sm font-medium text-gray-700 mb-1",children:"Description"}),a.jsx("textarea",{id:"description",value:r.description,onChange:h=>s({...r,description:h.target.value}),rows:3,className:"block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500",placeholder:"Optional description of this workspace"}),a.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Optional description of what this workspace contains"})]}),a.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:[a.jsx("h3",{className:"text-sm font-medium text-blue-800 mb-2",children:"Note"}),a.jsx("p",{className:"text-sm text-blue-700",children:"The agent will handle mapping this workspace to a local path. You can manage services and additional workspace configuration through the main Task Shepherd UI after registration."})]}),a.jsxs("div",{className:"flex justify-end space-x-3 pt-4 border-t border-gray-200",children:[a.jsx("button",{type:"button",onClick:n,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50",children:"Cancel"}),a.jsx("button",{type:"submit",disabled:!d||i,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",children:i?"Creating...":"Register Workspace"})]})]})]})},ex=({organizationId:e,workspace:t,onClose:n,onApplyChanges:r})=>{var C;const[s,i]=N.useState(!1),[o,l]=N.useState(null),[u,c]=N.useState(new Set),[d,h]=N.useState(null),[m,v]=N.useState({}),x=async()=>{i(!0);try{const j=await fetch(`/api/organizations/${e}/workspaces/${t.id}/analyze`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!j.ok)throw new Error("Failed to analyze workspace");const R=await j.json();if(R.success)l(R.data);else throw new Error(R.error||"Analysis failed")}catch(j){console.error("Workspace analysis failed:",j),alert(j instanceof Error?j.message:"Failed to analyze workspace")}finally{i(!1)}},w=j=>{switch(j){case"found":return a.jsx(zn,{className:"w-4 h-4 text-green-500"});case"outdated":return a.jsx(sl,{className:"w-4 h-4 text-yellow-500"});case"missing":return a.jsx(Qc,{className:"w-4 h-4 text-red-500"});default:return null}},k=j=>{switch(j){case"add_service":return a.jsx(pr,{className:"w-4 h-4 text-green-500"});case"update_service":return a.jsx(Zt,{className:"w-4 h-4 text-blue-500"});case"remove_service":return a.jsx(Qc,{className:"w-4 h-4 text-red-500"});default:return a.jsx(rv,{className:"w-4 h-4 text-gray-500"})}},p=j=>{const R=new Set(u);R.has(j)?R.delete(j):R.add(j),c(R)},f=()=>{if(!o||u.size===0)return;const j=Array.from(u).map(R=>o.improvements[R]);r==null||r(j),n()},g=j=>{h(j.name),v({name:j.name,type:j.type,technology:j.technology,port:j.port,description:j.description})},b=()=>{h(null),v({})},P=async()=>{if(d)try{const j=await fetch(`/api/organizations/${e}/workspaces/${t.id}/services/${d}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)}),R=await j.json();if(j.ok&&R.success)h(null),v({}),await x();else throw new Error(R.error||"Failed to update service")}catch(j){console.error("Failed to update service:",j),alert(j instanceof Error?j.message:"Failed to update service")}},T=async j=>{if(confirm(`Are you sure you want to remove the service "${j}"? This action cannot be undone.`))try{const R=await fetch(`/api/organizations/${e}/workspaces/${t.id}/services/${j}`,{method:"DELETE"}),M=await R.json();if(R.ok&&M.success)await x();else throw new Error(M.error||"Failed to remove service")}catch(R){console.error("Failed to remove service:",R),alert(R instanceof Error?R.message:"Failed to remove service")}};return a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50",children:a.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-6xl w-full max-h-[90vh] overflow-hidden",children:[a.jsxs("div",{className:"px-6 py-4 border-b border-gray-200",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h1",{className:"text-2xl font-bold text-gray-900",children:["Analyze Workspace: ",t.name]}),a.jsx("button",{onClick:n,className:"text-gray-400 hover:text-gray-600",children:a.jsx(ir,{className:"w-6 h-6"})})]}),a.jsx("p",{className:"mt-2 text-sm text-gray-600",children:"Analyze the current workspace configuration and discover improvements"})]}),a.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-140px)]",children:[!o&&a.jsxs("div",{className:"text-center py-12",children:[a.jsxs("div",{className:"mb-6",children:[a.jsx("div",{className:"w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center mx-auto mb-4",children:a.jsx(Zt,{className:"w-8 h-8 text-blue-600"})}),a.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"Ready to Analyze Workspace"}),a.jsx("p",{className:"text-gray-600 mb-6 max-w-md mx-auto",children:"This will scan the workspace directory and compare it with your current configuration to suggest improvements."}),a.jsx("div",{className:"bg-gray-50 rounded-lg p-4 mb-6",children:a.jsxs("div",{className:"text-sm text-gray-700",children:[a.jsxs("div",{children:[a.jsx("strong",{children:"Workspace:"})," ",t.name]}),a.jsxs("div",{children:[a.jsx("strong",{children:"Path:"})," ",a.jsx("code",{className:"font-mono text-xs",children:t.path})]}),a.jsxs("div",{children:[a.jsx("strong",{children:"Current services:"})," ",((C=t.services)==null?void 0:C.length)||0]})]})})]}),a.jsx("button",{onClick:x,disabled:s,className:"inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",children:s?a.jsxs(a.Fragment,{children:[a.jsx(Zt,{className:"w-4 h-4 mr-2 animate-spin"}),"Analyzing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Zt,{className:"w-4 h-4 mr-2"}),"Start Analysis"]})})]}),o&&a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:[a.jsx("h3",{className:"text-lg font-medium text-blue-900 mb-2",children:"Analysis Summary"}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-blue-800 font-medium",children:"Current Services"}),a.jsxs("div",{className:"text-blue-600",children:[o.currentServices.length," configured"]})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-blue-800 font-medium",children:"Discovered Services"}),a.jsxs("div",{className:"text-blue-600",children:[o.discoveredServices.length," found"]})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-blue-800 font-medium",children:"Improvements"}),a.jsxs("div",{className:"text-blue-600",children:[o.improvements.length," suggested"]})]})]})]}),a.jsxs("div",{className:"bg-white border border-gray-200 rounded-lg p-4",children:[a.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Current Services Status"}),o.currentServices.length>0?a.jsx("div",{className:"space-y-2",children:o.currentServices.map((j,R)=>a.jsx("div",{className:"p-3 bg-gray-50 rounded-lg border",children:d===j.name?a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Name"}),a.jsx("input",{type:"text",value:m.name||"",onChange:M=>v({...m,name:M.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Type"}),a.jsxs("select",{value:m.type||"backend",onChange:M=>v({...m,type:M.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",children:[a.jsx("option",{value:"backend",children:"Backend"}),a.jsx("option",{value:"frontend",children:"Frontend"}),a.jsx("option",{value:"database",children:"Database"}),a.jsx("option",{value:"cache",children:"Cache"}),a.jsx("option",{value:"queue",children:"Queue"}),a.jsx("option",{value:"api",children:"API"}),a.jsx("option",{value:"service",children:"Service"}),a.jsx("option",{value:"other",children:"Other"})]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Technology"}),a.jsx("input",{type:"text",value:m.technology||"",onChange:M=>v({...m,technology:M.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"e.g., Node.js, Python"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Port"}),a.jsx("input",{type:"number",value:m.port||"",onChange:M=>v({...m,port:M.target.value?parseInt(M.target.value):void 0}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"3000"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Description"}),a.jsx("input",{type:"text",value:m.description||"",onChange:M=>v({...m,description:M.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"Optional description"})]}),a.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[a.jsxs("button",{onClick:P,className:"inline-flex items-center px-3 py-1 text-xs bg-green-600 text-white rounded hover:bg-green-700",children:[a.jsx(gi,{className:"h-3 w-3 mr-1"}),"Save"]}),a.jsxs("button",{onClick:b,className:"inline-flex items-center px-3 py-1 text-xs bg-gray-600 text-white rounded hover:bg-gray-700",children:[a.jsx(ir,{className:"h-3 w-3 mr-1"}),"Cancel"]})]})]}):a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[w(j.status),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium",children:j.name}),a.jsxs("div",{className:"text-sm text-gray-600",children:[j.type," ",j.technology&&`• ${j.technology}`," ",j.port&&`• Port ${j.port}`,j.description&&` • ${j.description}`]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:()=>g(j),className:"p-1 text-gray-500 hover:text-orange-600 transition-colors",title:"Edit service",children:a.jsx(mi,{className:"h-3 w-3"})}),a.jsx("button",{onClick:()=>T(j.name),className:"p-1 text-gray-500 hover:text-red-600 transition-colors",title:"Remove service",children:a.jsx(rs,{className:"h-3 w-3"})}),a.jsx("span",{className:`px-2 py-1 text-xs rounded-full ${j.status==="found"?"bg-green-100 text-green-800":j.status==="outdated"?"bg-yellow-100 text-yellow-800":"bg-red-100 text-red-800"}`,children:j.status})]})]})},R))}):a.jsx("p",{className:"text-gray-600",children:"No services currently configured"})]}),o.improvements.length>0&&a.jsxs("div",{className:"bg-white border border-gray-200 rounded-lg p-4",children:[a.jsxs("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:["Suggested Improvements (",o.improvements.length,")"]}),a.jsx("div",{className:"space-y-3",children:o.improvements.map((j,R)=>a.jsxs("div",{className:"flex items-start gap-3 p-3 border border-gray-200 rounded-lg hover:bg-gray-50",children:[a.jsx("input",{type:"checkbox",id:`improvement-${R}`,checked:u.has(R),onChange:()=>p(R),className:"mt-1 h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[k(j.type),a.jsx("span",{className:"font-medium",children:j.service}),a.jsx("span",{className:`px-2 py-1 text-xs rounded-full ${j.type==="add_service"?"bg-green-100 text-green-800":j.type==="update_service"?"bg-blue-100 text-blue-800":j.type==="remove_service"?"bg-red-100 text-red-800":"bg-gray-100 text-gray-800"}`,children:j.type.replace("_"," ")})]}),a.jsx("p",{className:"text-sm text-gray-700 mb-1",children:j.description}),a.jsx("p",{className:"text-xs text-gray-500",children:j.action})]})]},R))}),u.size>0&&a.jsx("div",{className:"mt-4 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-sm text-blue-800",children:[u.size," improvement(s) selected"]}),a.jsx("button",{onClick:f,className:"px-3 py-1 text-sm bg-blue-600 text-white rounded hover:bg-blue-700",children:"Apply Selected"})]})})]}),o.recommendations.length>0&&a.jsxs("div",{className:"bg-green-50 border border-green-200 rounded-lg p-4",children:[a.jsx("h3",{className:"text-sm font-medium text-green-800 mb-2",children:"Recommendations"}),a.jsx("ul",{className:"space-y-1",children:o.recommendations.map((j,R)=>a.jsxs("li",{className:"text-sm text-green-700",children:["• ",j]},R))})]}),o.warnings.length>0&&a.jsxs("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-4",children:[a.jsx("h3",{className:"text-sm font-medium text-yellow-800 mb-2",children:"Warnings"}),a.jsx("ul",{className:"space-y-1",children:o.warnings.map((j,R)=>a.jsxs("li",{className:"text-sm text-yellow-700",children:["• ",j]},R))})]}),a.jsx("div",{className:"text-center pt-4 border-t border-gray-200",children:a.jsxs("button",{onClick:x,disabled:s,className:"inline-flex items-center px-3 py-2 text-sm text-gray-600 bg-gray-100 border border-gray-300 rounded-md hover:bg-gray-200 disabled:opacity-50",children:[a.jsx(Zt,{className:`w-4 h-4 mr-2 ${s?"animate-spin":""}`}),"Re-analyze"]})})]})]})]})})};function tx(){const[e,t]=N.useState(null),[n,r]=N.useState(!0),[s,i]=N.useState(!1),[o,l]=N.useState({name:"",basePath:"",apiKey:""}),[u,c]=N.useState([]),[d,h]=N.useState(new Set),[m,v]=N.useState(new Set),[x,w]=N.useState(null),[k,p]=N.useState(null),[f,g]=N.useState(null),[b,P]=N.useState({name:"",id:"",path:"",description:""}),[T,C]=N.useState(new Set),[j,R]=N.useState(null),[M,K]=N.useState({name:"",type:"backend",port:"",url:"",technology:"",description:""}),[E,se]=N.useState(Date.now()),[q,ae]=N.useState(null),[Z,oe]=N.useState(null),[A,$]=N.useState(null),[U,re]=N.useState({}),[V,ee]=N.useState({}),[be,Qe]=N.useState({}),[Ee,jt]=N.useState(!1),[Os,Ot]=N.useState(null),[bt,Cr]=N.useState([]),[fe,Q]=N.useState(new Set),[ce,Pe]=N.useState({}),[dt,Nt]=N.useState(!1),[Wn,fa]=N.useState(!1),[Bp,pa]=N.useState([]),[ha,Hp]=N.useState(new Set),[qp,ma]=N.useState(null),[ga,zs]=N.useState(""),[uu,cu]=N.useState(!1),[xn,ya]=N.useState({}),[Bn,va]=N.useState(new Set);N.useEffect(()=>{As()},[]);const G=(y,S,L)=>{const F={id:Date.now().toString(),type:y,title:S,message:L,timestamp:Date.now()};c(W=>[...W,F]),y==="success"&&setTimeout(()=>{c(W=>W.filter(Y=>Y.id!==F.id))},5e3)},Qp=y=>{c(S=>S.filter(L=>L.id!==y))},As=async()=>{try{const y=await fetch("/api/organizations");if(y.ok){const S=await y.json();t(S.data),se(Date.now())}}catch(y){console.error("Failed to fetch organizations:",y)}finally{r(!1)}},wn=async()=>{await As()},xa=()=>{},wa=()=>{},ja=()=>{},Vp=async y=>{try{const S=await fetch(`/api/project-mappings/organization/${y}`);if(S.ok){const L=await S.json();pa(L.mappings||[])}}catch(S){console.error("Failed to fetch project mappings:",S)}},Kp=async(y,S,L)=>{if(!ga.trim()){G("error","Invalid Path","Please enter a valid local path");return}cu(!0);try{const F=await fetch("/api/project-mappings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({organizationId:y,projectId:S,localPath:ga,projectName:L})}),W=await F.json();F.ok&&W.success?(pa(Y=>{const de=Y.findIndex(le=>le.projectId===S);if(de>=0){const le=[...Y];return le[de]=W.mapping,le}return[...Y,W.mapping]}),ma(null),zs(""),G("success","Mapping Saved",`Successfully mapped "${L}" to local path`)):G("error","Failed to Save Mapping",W.error||"Unknown error")}catch(F){console.error("Failed to save project mapping:",F),G("error","Network Error","Failed to save project mapping")}finally{cu(!1)}},Gp=async(y,S)=>{try{const L=await fetch(`/api/project-mappings/${y}/${S}`,{method:"DELETE"});if(L.ok)pa(F=>F.filter(W=>W.projectId!==S)),G("success","Mapping Removed","Project path mapping has been removed");else{const F=await L.json();G("error","Failed to Remove Mapping",F.error||"Unknown error")}}catch(L){console.error("Failed to remove project mapping:",L),G("error","Network Error","Failed to remove project mapping")}},Yp=y=>Bp.find(S=>S.projectId===y),Jp=async y=>{const S=new Set(d);S.has(y)?S.delete(y):(S.add(y),await Vp(y)),h(S)},Xp=async(y,S)=>{y.preventDefault();try{const L=await fetch(`/api/organizations/${S}/workspaces`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),F=await L.json();if(L.ok&&F.success&&F.data){if(e){const W=e.organizations.map(Y=>{if(Y.id===S){const de=Y.workspaces||[];return{...Y,workspaces:[...de,F.data],workspaceCount:(Y.workspaceCount||0)+1}}return Y});t({...e,organizations:W})}w(null),P({name:"",id:"",path:"",description:""}),xa(),G("success","Workspace Added",`Successfully added workspace "${b.name}"`)}else G("error","Failed to Add Workspace",F.message||F.error)}catch(L){console.error("Failed to add workspace:",L),G("error","Network Error","Failed to add workspace. Please try again.")}},Zp=async(y,S,L)=>{console.log("🔄 handleUpdateWorkspace called:",{orgId:y,workspaceId:S,updates:L});try{console.log("📡 Making PATCH request to:",`/api/organizations/${y}/workspaces/${S}`);const F=await fetch(`/api/organizations/${y}/workspaces/${S}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(L)});console.log("📨 Response status:",F.status,F.statusText);const W=await F.json();F.ok?(await wn(),G("success","Workspace Updated","Workspace settings updated successfully")):G("error","Failed to Update Workspace",W.message||W.error)}catch(F){console.error("Failed to update workspace:",F),G("error","Network Error","Failed to update workspace. Please try again.")}},eh=y=>{oe(y.id),ee({name:y.name,type:y.type,technology:y.technology,port:y.port,url:y.url,description:y.description})},th=()=>{oe(null),ee({})},nh=async(y,S,L)=>{try{const F=await fetch(`/api/organizations/${y}/workspaces/${S}/services/${L}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(V)}),W=await F.json();if(F.ok&&W.success)await wn(),oe(null),ee({}),G("success","Service Updated","Service details updated successfully");else throw new Error(W.error||"Failed to update service")}catch(F){console.error("Failed to update service:",F),G("error","Update Failed",F instanceof Error?F.message:"Failed to update service")}},rh=async(y,S,L,F)=>{if(confirm(`Are you sure you want to remove the service "${F}"? This action cannot be undone.`))try{const W=await fetch(`/api/organizations/${y}/workspaces/${S}/services/${L}`,{method:"DELETE"}),Y=await W.json();if(W.ok&&Y.success)await wn(),G("success","Service Removed",`Service "${F}" has been removed`);else throw new Error(Y.error||"Failed to remove service")}catch(W){console.error("Failed to remove service:",W),G("error","Removal Failed",W instanceof Error?W.message:"Failed to remove service")}},sh=async(y,S,L)=>{y.preventDefault();try{const F={...M,port:M.port?parseInt(M.port):void 0,isActive:!0},W=await fetch(`/api/organizations/${S}/workspaces/${L}/services`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)}),Y=await W.json();if(W.ok&&Y.success){if(e){const de=e.organizations.map(le=>{var z;if(le.id===S){const D=(z=le.workspaces)==null?void 0:z.map(H=>{if(H.id===L){const Ie=H.services||[];return{...H,services:[...Ie,Y.data]}}return H});return{...le,workspaces:D}}return le});t({...e,organizations:de})}R(null),K({name:"",type:"backend",port:"",url:"",technology:"",description:""}),xa(),G("success","Service Added",`Successfully added service "${F.name}"`)}else G("error","Failed to Add Service",Y.message||Y.error)}catch(F){console.error("Failed to add service:",F),G("error","Network Error","Failed to add service. Please try again.")}},ih=async(y,S,L,F)=>{try{const W=await fetch(`/api/organizations/${y}/workspaces/${S}/services/${L}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:F})}),Y=await W.json();if(W.ok&&Y.success){if(e){const de=e.organizations.map(le=>{var z;if(le.id===y){const D=(z=le.workspaces)==null?void 0:z.map(H=>{var Ie;if(H.id===S){const Wt=(Ie=H.services)==null?void 0:Ie.map(Bt=>Bt.id===L?{...Bt,isActive:F}:Bt);return{...H,services:Wt}}return H});return{...le,workspaces:D}}return le});t({...e,organizations:de})}G("success","Service Updated",`Service ${F?"activated":"deactivated"} successfully`)}else G("error","Failed to Update Service",Y.message||Y.error)}catch(W){console.error("Failed to update service:",W),G("error","Network Error","Failed to update service. Please try again.")}},ah=y=>{$(y.id),Qe({name:y.name,apiUrl:y.apiUrl,apiKey:"",enabled:y.enabled})},oh=()=>{$(null),Qe({})},lh=async y=>{jt(!0);try{const S=await fetch(`/api/organizations/${y}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(be)}),L=await S.json();if(S.ok&&L.success)await wn(),$(null),Qe({}),G("success","Organization Updated","Organization details updated successfully");else throw new Error(L.error||"Failed to update organization")}catch(S){console.error("Failed to update organization:",S),G("error","Update Failed",S instanceof Error?S.message:"Failed to update organization")}finally{jt(!1)}},uh=async y=>{Ot(y),Nt(!0);try{const[S,L]=await Promise.all([fetch(`/api/organizations/${y}/workspaces/available`),fetch(`/api/service-mappings/organization/${y}`)]),F=await S.json();if(S.ok&&F.success){Cr(F.workspaces||[]);const W=new Set,Y={};if(F.workspaces.forEach(de=>{de.syncedLocally&&de.isActive!==!1?(W.add(de.id),Y[de.id]=de.localPath||de.path||""):Y[de.id]=de.path||""}),Q(W),Pe(Y),L.ok){const le=(await L.json()).mappings||[],z={};le.forEach(D=>{z[`${D.workspaceId}:${D.serviceId}`]=D.localPath}),ya(z)}}else G("error","Failed to Fetch Workspaces",F.error||"Could not fetch available workspaces"),Ot(null)}catch(S){console.error("Failed to fetch available workspaces:",S),G("error","Network Error","Failed to fetch available workspaces. Please try again."),Ot(null)}finally{Nt(!1)}},ch=async y=>{fa(!0);try{if(fe.size>0){const le=await fetch(`/api/organizations/${y}/workspaces/sync`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceIds:Array.from(fe)})}),z=await le.json();if(!le.ok){G("error","Failed to Sync Workspaces",z.message||z.error),fa(!1);return}for(const D of fe){const H=bt.find(Wt=>Wt.id===D),Ie=ce[D];H&&Ie&&Ie!==H.path&&await fetch(`/api/organizations/${y}/workspaces/${D}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Ie})})}}const S=new Set(fe),L=bt.filter(le=>le.syncedLocally&&!S.has(le.id));for(const le of L)await fetch(`/api/organizations/${y}/workspaces/${le.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:!1})});let F=0;for(const[le,z]of Object.entries(xn))if(z&&z.trim()){const[D,H]=le.split(":");if(!D||!H)continue;let Ie="",Wt="";const Bt=bt.find(Ht=>Ht.id===D);if(Bt!=null&&Bt.services){const Ht=Bt.services.find(ph=>ph.id===H);Ht&&(Ie=Ht.name,Wt=Ht.technology||"")}try{(await fetch("/api/service-mappings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({organizationId:y,workspaceId:D,serviceId:H,localPath:z.trim(),serviceName:Ie,technology:Wt})})).ok&&F++}catch(Ht){console.error("Failed to save service mapping:",Ht)}}await wn();const W=fe.size,Y=L.length;let de="";W>0&&Y>0?de=`Saved ${W} workspace(s) and disabled ${Y} workspace(s)`:W>0?de=`Saved ${W} workspace(s)`:Y>0?de=`Disabled ${Y} workspace(s)`:de="No changes made",F>0&&(de+=`, ${F} service path(s) mapped`),G("success","Workspaces Updated",de),Ot(null),va(new Set)}catch(S){console.error("Failed to save workspaces:",S),G("error","Network Error","Failed to save workspaces. Please try again.")}finally{fa(!1)}},dh=async y=>{y.preventDefault();try{const S=o.basePath.endsWith("/")?`${o.basePath}graphql`:`${o.basePath}/graphql`,L={name:o.name,apiUrl:S,apiKey:o.apiKey},F=await fetch("/api/organizations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(L)}),W=await F.json();F.ok?(await As(),i(!1),l({name:"",basePath:"",apiKey:""}),xa(),G("success","Organization Added",`Successfully added "${o.name}"`)):G("error","Failed to Add Organization",W.message||W.error)}catch(S){console.error("Failed to add organization:",S),G("error","Network Error","Failed to connect to server. Please try again.")}},fh=async y=>{if(confirm("Are you sure you want to delete this organization?"))try{const S=await fetch(`/api/organizations/${y}`,{method:"DELETE"}),L=await S.json();S.ok?(await As(),G("success","Organization Deleted",L.message||"Organization deleted successfully")):G("error","Failed to Delete Organization",L.message||L.error)}catch(S){console.error("Failed to delete organization:",S),G("error","Network Error","Failed to delete organization. Please try again.")}};return a.jsxs(a.Fragment,{children:[a.jsx(pn,{children:a.jsx("title",{children:"Organizations - AI Agent Service"})}),a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Organizations"}),a.jsx("p",{className:"text-muted-foreground",children:"Manage Task Shepherd organizations and API connections"})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[a.jsx(Mt,{className:"h-4 w-4"}),a.jsxs("span",{children:["Last updated: ",new Date(E).toLocaleTimeString()]})]}),a.jsxs("button",{onClick:wn,disabled:n,className:"inline-flex items-center px-3 py-2 text-sm text-gray-600 border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50",children:[a.jsx(Zt,{className:`h-4 w-4 mr-2 ${n?"animate-spin":""}`}),"Refresh"]}),a.jsxs("button",{onClick:()=>{i(!0)},className:"inline-flex items-center px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2",children:[a.jsx(pr,{className:"h-4 w-4 mr-2"}),"Add Organization"]})]})]}),u.filter(y=>!(y.type==="success"&&y.title==="Connection Test")).length>0&&a.jsx("div",{className:"space-y-2",children:u.filter(y=>!(y.type==="success"&&y.title==="Connection Test")).map(y=>a.jsxs("div",{className:`flex items-start justify-between p-3 rounded-md border text-sm ${y.type==="error"?"border-red-200 bg-red-50 text-red-800":"border-green-200 bg-green-50 text-green-800"}`,children:[a.jsxs("div",{className:"flex items-start space-x-2",children:[y.type==="error"?a.jsx(Ct,{className:"h-4 w-4 text-red-600 mt-0.5 flex-shrink-0"}):a.jsx(zn,{className:"h-4 w-4 text-green-600 mt-0.5 flex-shrink-0"}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium",children:y.title}),a.jsx("p",{className:"opacity-90",children:y.message}),y.type==="error"&&a.jsx("p",{className:"text-xs mt-1 opacity-75",children:"Check your API URL format and ensure the Agent API key is valid for this organization."})]})]}),a.jsx("button",{onClick:()=>Qp(y.id),className:"text-current opacity-60 hover:opacity-100 transition-opacity ml-2",children:a.jsx(ir,{className:"h-3 w-3"})})]},y.id))}),!n&&e&&a.jsx("div",{className:"rounded-lg border bg-card p-6",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Ct,{className:`h-5 w-5 ${e.setupCompleted?"text-green-600":"text-yellow-600"}`}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium",children:e.setupCompleted?"Setup Complete":"Setup Required"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:e.setupCompleted?`You have ${e.organizations.length} organization(s) configured.`:"Add your first organization to get started with Task Shepherd integration."})]})]})}),s&&a.jsxs("div",{className:"rounded-lg border bg-card p-6",children:[a.jsx("h3",{className:"text-lg font-medium mb-4",children:"Add New Organization"}),a.jsxs("form",{onSubmit:dh,className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"name",className:"block text-sm font-medium mb-2",children:"Organization Name"}),a.jsx("input",{type:"text",id:"name",value:o.name,onChange:y=>l({...o,name:y.target.value}),onFocus:wa,onBlur:ja,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"e.g. My Company",required:!0}),a.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"A friendly name to identify this Task Shepherd instance"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"basePath",className:"block text-sm font-medium mb-2",children:"API Base Path"}),a.jsx("input",{type:"url",id:"basePath",value:o.basePath,onChange:y=>l({...o,basePath:y.target.value}),onFocus:wa,onBlur:ja,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"https://myorg.taskshepherd.com/api",required:!0}),a.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Base API path (GraphQL will be appended automatically: /api → /api/graphql)"}),o.basePath&&a.jsxs("p",{className:"text-xs text-blue-600 mt-1",children:["GraphQL URL will be: ",a.jsx("code",{children:o.basePath.endsWith("/")?`${o.basePath}graphql`:`${o.basePath}/graphql`})]})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"apiKey",className:"block text-sm font-medium mb-2",children:"Agent API Key"}),a.jsx("input",{type:"password",id:"apiKey",value:o.apiKey,onChange:y=>l({...o,apiKey:y.target.value}),onFocus:wa,onBlur:ja,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"tks_agent_...",required:!0}),a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Generate an ",a.jsx("strong",{children:"Agent API key"})," from your Task Shepherd organization settings → API Keys → Create Agent Key"]})]}),a.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[a.jsx("button",{type:"button",onClick:()=>{i(!1),l({name:"",basePath:"",apiKey:""}),c([])},className:"px-4 py-2 text-gray-600 border border-gray-300 rounded-md hover:bg-gray-50",children:"Cancel"}),a.jsx("button",{type:"submit",className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700",children:"Add Organization"})]})]})]}),n?a.jsx("div",{className:"text-center py-12",children:a.jsx("div",{className:"text-muted-foreground",children:"Loading organizations..."})}):(e==null?void 0:e.organizations.length)===0?a.jsxs("div",{className:"text-center py-12",children:[a.jsx(Qr,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-medium mb-2",children:"No Organizations Configured"}),a.jsx("p",{className:"text-muted-foreground mb-4",children:"Add your first organization to start using the AI Agent Service with Task Shepherd."}),a.jsxs("button",{onClick:()=>{i(!0)},className:"inline-flex items-center px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700",children:[a.jsx(pr,{className:"h-4 w-4 mr-2"}),"Add Organization"]})]}):a.jsx("div",{className:"grid gap-4",children:e==null?void 0:e.organizations.map(y=>{var W,Y,de,le;const S=((W=y.workerRegistration)==null?void 0:W.registered)||!1,L=((Y=y.workerRegistration)==null?void 0:Y.lastHeartbeat)||y.createdAt,F=(de=y.workerRegistration)!=null&&de.lastHeartbeat?"Last heartbeat":"Created";return a.jsxs("div",{className:"rounded-lg border bg-card p-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("div",{className:"flex-1",children:A===y.id?a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Name"}),a.jsx("input",{type:"text",value:be.name||"",onChange:z=>Qe({...be,name:z.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"API URL"}),a.jsx("input",{type:"text",value:be.apiUrl||"",onChange:z=>Qe({...be,apiUrl:z.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"API Key"}),a.jsx("input",{type:"password",value:be.apiKey||"",onChange:z=>Qe({...be,apiKey:z.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Leave empty to keep current key"})]}),a.jsxs("div",{className:"flex items-center",children:[a.jsx("input",{type:"checkbox",id:`enabled-${y.id}`,checked:be.enabled??y.enabled,onChange:z=>Qe({...be,enabled:z.target.checked}),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),a.jsx("label",{htmlFor:`enabled-${y.id}`,className:"ml-2 block text-sm text-gray-700",children:"Enabled"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:()=>lh(y.id),disabled:Ee,className:"inline-flex items-center gap-2 px-3 py-1.5 bg-blue-600 text-white text-sm rounded hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",children:[Ee&&a.jsx(En,{className:"h-4 w-4 animate-spin"}),Ee?"Saving...":"Save"]}),a.jsx("button",{onClick:oh,disabled:Ee,className:"px-3 py-1.5 bg-gray-200 text-gray-700 text-sm rounded hover:bg-gray-300 disabled:opacity-50 disabled:cursor-not-allowed",children:"Cancel"})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h3",{className:"font-medium",children:y.name}),a.jsxs("div",{className:`flex items-center gap-1 text-sm ${S?"text-green-600":"text-yellow-600"}`,children:[a.jsx("div",{className:`w-2 h-2 rounded-full ${S?"bg-green-600 animate-pulse":"bg-yellow-600"}`}),S?"Connected":"Not Connected"]})]}),a.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:y.apiUrl}),L&&a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[F,": ",new Date(L).toLocaleString()]})]})}),A!==y.id&&a.jsx("div",{className:"flex items-start",children:a.jsx("button",{onClick:()=>ah(y),className:"p-2 text-gray-500 hover:text-blue-600 transition-colors",title:"Edit organization",children:a.jsx(mi,{className:"h-5 w-5"})})})]}),a.jsx("div",{className:"mt-4",children:!A&&a.jsxs(a.Fragment,{children:[S&&y.workerRegistration&&a.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-100",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(hv,{className:"h-4 w-4 text-gray-500"}),a.jsx("span",{className:"text-sm font-medium",children:"Worker Details"})]}),a.jsxs("div",{className:"space-y-1",children:[y.workerRegistration.workerId&&a.jsxs("p",{className:"text-xs text-gray-600",children:["Worker ID: ",a.jsx("code",{className:"text-xs font-mono bg-gray-100 px-1 rounded",children:y.workerRegistration.workerId})]}),y.workerRegistration.capabilities&&y.workerRegistration.capabilities.length>0&&a.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:y.workerRegistration.capabilities.map(z=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 text-xs bg-blue-100 text-blue-700 rounded",children:[a.jsx(Ip,{className:"h-3 w-3"}),z.replace("_"," ").toLowerCase()]},z))})]})]}),S&&a.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-100",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("button",{onClick:()=>Jp(y.id),className:"flex items-center gap-2 hover:text-blue-600 transition-colors",children:[d.has(y.id)?a.jsx(_r,{className:"h-4 w-4"}):a.jsx(Fr,{className:"h-4 w-4"}),a.jsx(Rp,{className:"h-4 w-4 text-gray-500"}),a.jsxs("span",{className:"text-sm font-medium",children:["Workspaces ",y.workspaceCount!==void 0&&`(${y.workspaceCount})`]})]}),a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("button",{onClick:()=>uh(y.id),className:"inline-flex items-center px-2 py-1 text-xs text-blue-600 border border-blue-200 rounded-md hover:bg-blue-50",children:[a.jsx(Qr,{className:"h-3 w-3 mr-1"}),"Manage"]})})]}),d.has(y.id)&&a.jsxs("div",{className:"mt-2 space-y-2",children:[m.has(y.id)?a.jsx("div",{className:"text-sm text-gray-500 text-center py-2",children:"Loading workspaces..."}):y.workspaces&&y.workspaces.length>0?y.workspaces.map(z=>a.jsxs("div",{className:"bg-gray-50 p-3 rounded-md",children:[a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsx("div",{className:"flex-1",children:q===z.id?a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Name"}),a.jsx("input",{type:"text",value:U.name||"",onChange:D=>re({...U,name:D.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Path"}),a.jsx("input",{type:"text",value:U.path||"",onChange:D=>re({...U,path:D.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Description"}),a.jsx("input",{type:"text",value:U.description||"",onChange:D=>re({...U,description:D.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"Optional description"})]}),a.jsxs("p",{className:"text-xs text-gray-500",children:["ID: ",a.jsx("code",{className:"font-mono",children:z.id})]})]}):a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h4",{className:"text-sm font-medium",children:z.name}),a.jsx("span",{className:`px-1.5 py-0.5 text-xs rounded ${z.isActive?"bg-green-100 text-green-700":"bg-gray-200 text-gray-600"}`,children:z.isActive?"Active":"Inactive"})]}),z.description&&a.jsx("p",{className:"text-xs text-gray-600 mt-1",children:z.description}),a.jsxs("div",{className:"mt-1 space-y-0.5",children:[a.jsxs("p",{className:"text-xs text-gray-500",children:["ID: ",a.jsx("code",{className:"font-mono",children:z.id})]}),a.jsxs("p",{className:"text-xs text-gray-500",children:["Path: ",a.jsx("code",{className:"font-mono",children:z.path})]}),z.projectCount!==void 0&&a.jsxs("p",{className:"text-xs text-gray-500",children:["Projects: ",z.projectCount]})]})]})}),a.jsx("div",{className:"flex items-center gap-1",children:a.jsx("button",{onClick:()=>Zp(y.id,z.id,{isActive:!z.isActive}),className:`p-1 transition-colors ${z.isActive?"text-green-500 hover:text-red-600":"text-gray-400 hover:text-green-600"}`,title:z.isActive?"Deactivate workspace":"Activate workspace",children:z.isActive?a.jsx(fv,{className:"h-3 w-3"}):a.jsx(dv,{className:"h-3 w-3"})})})]}),a.jsxs("div",{className:"mt-2 pt-2 border-t border-gray-200",children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsxs("button",{onClick:()=>{const D=`${y.id}-${z.id}`,H=new Set(T);H.has(D)?H.delete(D):H.add(D),C(H)},className:"flex items-center gap-1 text-xs text-gray-600 hover:text-blue-600",children:[T.has(`${y.id}-${z.id}`)?a.jsx(_r,{className:"h-3 w-3"}):a.jsx(Fr,{className:"h-3 w-3"}),"Services ",z.services?`(${z.services.length})`:"(0)"]}),a.jsx("button",{onClick:()=>{R({orgId:y.id,workspaceId:z.id})},className:"text-xs text-green-600 hover:text-green-700",children:a.jsx(pr,{className:"h-3 w-3"})})]}),T.has(`${y.id}-${z.id}`)&&a.jsx("div",{className:"space-y-1 ml-4",children:z.services&&z.services.length>0?z.services.map(D=>a.jsx("div",{className:"bg-white p-2 rounded border",children:Z===D.id?a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Name"}),a.jsx("input",{type:"text",value:V.name||"",onChange:H=>ee({...V,name:H.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Type"}),a.jsxs("select",{value:V.type||"backend",onChange:H=>ee({...V,type:H.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",children:[a.jsx("option",{value:"backend",children:"Backend"}),a.jsx("option",{value:"frontend",children:"Frontend"}),a.jsx("option",{value:"database",children:"Database"}),a.jsx("option",{value:"cache",children:"Cache"}),a.jsx("option",{value:"queue",children:"Queue"}),a.jsx("option",{value:"api",children:"API"}),a.jsx("option",{value:"service",children:"Service"}),a.jsx("option",{value:"other",children:"Other"})]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Technology"}),a.jsx("input",{type:"text",value:V.technology||"",onChange:H=>ee({...V,technology:H.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"e.g., Node.js, Python"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Port"}),a.jsx("input",{type:"number",value:V.port||"",onChange:H=>ee({...V,port:H.target.value?parseInt(H.target.value):void 0}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"3000"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"URL"}),a.jsx("input",{type:"url",value:V.url||"",onChange:H=>ee({...V,url:H.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"http://localhost:3000"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Description"}),a.jsx("input",{type:"text",value:V.description||"",onChange:H=>ee({...V,description:H.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"Optional description"})]}),a.jsxs("div",{className:"flex items-center justify-end gap-1 pt-1",children:[a.jsx("button",{onClick:()=>nh(y.id,z.id,D.id),className:"px-2 py-1 text-xs bg-green-600 text-white rounded hover:bg-green-700",children:a.jsx(gi,{className:"h-3 w-3"})}),a.jsx("button",{onClick:th,className:"px-2 py-1 text-xs bg-gray-600 text-white rounded hover:bg-gray-700",children:a.jsx(ir,{className:"h-3 w-3"})})]})]}):a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:"font-medium",children:D.name}),a.jsxs("span",{className:"text-gray-500",children:["(",D.type,")"]}),D.port&&a.jsxs("span",{className:"text-gray-400",children:[":",D.port]}),D.technology&&a.jsx("span",{className:"px-1 py-0.5 bg-blue-100 text-blue-700 rounded text-xs",children:D.technology}),D.description&&a.jsxs("span",{className:"text-gray-400 italic",children:["- ",D.description]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:()=>eh(D),className:"p-1 text-gray-500 hover:text-orange-600 transition-colors",title:"Edit service",children:a.jsx(mi,{className:"h-3 w-3"})}),a.jsx("button",{onClick:()=>rh(y.id,z.id,D.id,D.name),className:"p-1 text-gray-500 hover:text-red-600 transition-colors",title:"Remove service",children:a.jsx(rs,{className:"h-3 w-3"})}),a.jsx("button",{onClick:()=>ih(y.id,z.id,D.id,!D.isActive),className:`px-1.5 py-0.5 rounded text-xs ${D.isActive?"bg-green-100 text-green-700":"bg-gray-100 text-gray-600"}`,children:D.isActive?"Active":"Inactive"})]})]})},D.id)):a.jsx("div",{className:"text-xs text-gray-500",children:"No services configured"})})]}),z.projects&&z.projects.length>0&&a.jsxs("div",{className:"mt-2 pt-2 border-t border-gray-200",children:[a.jsx("div",{className:"flex items-center justify-between mb-1",children:a.jsxs("button",{onClick:()=>{const D=`proj-${y.id}-${z.id}`,H=new Set(ha);H.has(D)?H.delete(D):H.add(D),Hp(H)},className:"flex items-center gap-1 text-xs text-gray-600 hover:text-purple-600",children:[ha.has(`proj-${y.id}-${z.id}`)?a.jsx(_r,{className:"h-3 w-3"}):a.jsx(Fr,{className:"h-3 w-3"}),a.jsx(ns,{className:"h-3 w-3 text-purple-500"}),"Projects (",z.projects.length,")"]})}),ha.has(`proj-${y.id}-${z.id}`)&&a.jsx("div",{className:"space-y-1 ml-4",children:z.projects.map(D=>{const H=Yp(D.id),Ie=qp===D.id;return a.jsxs("div",{className:`bg-white p-2 rounded border ${H?"border-purple-300":"border-gray-200"}`,children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx(av,{className:"h-3 w-3 text-gray-400"}),a.jsx("span",{className:"font-medium",children:D.name}),D.stage&&a.jsx("span",{className:"px-1 py-0.5 bg-gray-100 text-gray-600 rounded text-xs",children:D.stage}),H&&a.jsx("span",{className:"px-1 py-0.5 bg-purple-100 text-purple-700 rounded text-xs",children:"Mapped"})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[H&&!Ie&&a.jsx("button",{onClick:()=>Gp(y.id,D.id),className:"p-1 text-gray-500 hover:text-red-600 transition-colors",title:"Remove mapping",children:a.jsx(rs,{className:"h-3 w-3"})}),!Ie&&a.jsx("button",{onClick:()=>{ma(D.id),zs((H==null?void 0:H.localPath)||"")},className:"p-1 text-gray-500 hover:text-purple-600 transition-colors",title:H?"Edit path":"Set local path",children:a.jsx(mi,{className:"h-3 w-3"})})]})]}),H&&!Ie&&a.jsx("div",{className:"mt-1 text-xs text-purple-600",children:a.jsx("code",{className:"bg-purple-50 px-1 rounded",children:H.localPath})}),Ie&&a.jsxs("div",{className:"mt-2 flex gap-1",children:[a.jsx("input",{type:"text",value:ga,onChange:Wt=>zs(Wt.target.value),placeholder:"/path/to/local/project",className:"flex-1 text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-purple-500"}),a.jsx("button",{onClick:()=>Kp(y.id,D.id,D.name),disabled:uu,className:"px-2 py-1 text-xs bg-purple-600 text-white rounded hover:bg-purple-700 disabled:opacity-50",children:uu?a.jsx(En,{className:"h-3 w-3 animate-spin"}):a.jsx(gi,{className:"h-3 w-3"})}),a.jsx("button",{onClick:()=>{ma(null),zs("")},className:"px-2 py-1 text-xs bg-gray-200 text-gray-700 rounded hover:bg-gray-300",children:a.jsx(ir,{className:"h-3 w-3"})})]})]},D.id)})})]})]},z.id)):a.jsx("div",{className:"text-sm text-gray-500 text-center py-2",children:'No workspaces configured. Click "Manage" to import from Task Shepherd.'}),(j==null?void 0:j.orgId)===y.id&&((le=y.workspaces)==null?void 0:le.some(z=>z.id===j.workspaceId))&&a.jsxs("div",{className:"bg-green-50 p-3 rounded-md border border-green-200",children:[a.jsx("h5",{className:"text-sm font-medium mb-2",children:"Add New Service"}),a.jsxs("form",{onSubmit:z=>sh(z,j.orgId,j.workspaceId),className:"space-y-2",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsx("input",{type:"text",placeholder:"Service Name",value:M.name,onChange:z=>K({...M,name:z.target.value}),className:"text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-green-500",required:!0}),a.jsxs("select",{value:M.type,onChange:z=>K({...M,type:z.target.value}),className:"text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-green-500",required:!0,children:[a.jsx("option",{value:"backend",children:"Backend"}),a.jsx("option",{value:"frontend",children:"Frontend"}),a.jsx("option",{value:"database",children:"Database"}),a.jsx("option",{value:"cache",children:"Cache"}),a.jsx("option",{value:"queue",children:"Queue"}),a.jsx("option",{value:"api",children:"API"}),a.jsx("option",{value:"service",children:"Service"}),a.jsx("option",{value:"other",children:"Other"})]})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[a.jsx("input",{type:"number",placeholder:"Port",value:M.port,onChange:z=>K({...M,port:z.target.value}),className:"text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-green-500"}),a.jsx("input",{type:"text",placeholder:"Technology (e.g., Node.js)",value:M.technology,onChange:z=>K({...M,technology:z.target.value}),className:"text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-green-500"}),a.jsx("input",{type:"url",placeholder:"URL (optional)",value:M.url,onChange:z=>K({...M,url:z.target.value}),className:"text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-green-500"})]}),a.jsx("input",{type:"text",placeholder:"Description (optional)",value:M.description,onChange:z=>K({...M,description:z.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-green-500"}),a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx("button",{type:"button",onClick:()=>{R(null),K({name:"",type:"backend",port:"",url:"",technology:"",description:""})},className:"px-2 py-1 text-xs text-gray-600 border border-gray-300 rounded hover:bg-gray-50",children:"Cancel"}),a.jsx("button",{type:"submit",className:"px-2 py-1 text-xs bg-green-600 text-white rounded hover:bg-green-700",children:"Add Service"})]})]})]}),x===y.id&&a.jsxs("div",{className:"bg-blue-50 p-3 rounded-md border border-blue-200",children:[a.jsx("h5",{className:"text-sm font-medium mb-2",children:"Add New Workspace"}),a.jsxs("form",{onSubmit:z=>Xp(z,y.id),className:"space-y-2",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsx("input",{type:"text",placeholder:"Workspace Name",value:b.name,onChange:z=>P({...b,name:z.target.value}),className:"text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",required:!0}),a.jsx("input",{type:"text",placeholder:"Workspace ID",value:b.id,onChange:z=>P({...b,id:z.target.value}),className:"text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",required:!0})]}),a.jsx("input",{type:"text",placeholder:"Path (e.g., /home/user/projects/workspace)",value:b.path,onChange:z=>P({...b,path:z.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",required:!0}),a.jsx("input",{type:"text",placeholder:"Description (optional)",value:b.description,onChange:z=>P({...b,description:z.target.value}),className:"w-full text-xs px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500"}),a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx("button",{type:"button",onClick:()=>{w(null),P({name:"",id:"",path:"",description:""})},className:"px-2 py-1 text-xs text-gray-600 border border-gray-300 rounded hover:bg-gray-50",children:"Cancel"}),a.jsx("button",{type:"submit",className:"px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700",children:"Add Workspace"})]})]})]})]})]})]})}),a.jsx("div",{className:"flex items-center gap-2 mt-4",children:a.jsxs("button",{onClick:()=>fh(y.id),className:"inline-flex items-center px-3 py-1 text-sm text-red-600 border border-red-200 rounded-md hover:bg-red-50",children:[a.jsx(rs,{className:"h-3 w-3 mr-1"}),"Delete"]})})]},y.id)})}),k&&a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50",children:a.jsx("div",{className:"bg-white rounded-lg shadow-xl max-w-6xl w-full max-h-[90vh] overflow-hidden",children:a.jsx(Zv,{organizationId:k,onComplete:y=>{var L;if(e){const F=e.organizations.map(W=>{if(W.id===k){const Y=[...W.workspaces||[],y];return{...W,workspaces:Y,workspaceCount:Y.length}}return W});t({...e,organizations:F})}p(null);const S=((L=y.services)==null?void 0:L.length)||0;G("success","Workspace Created",`Successfully created workspace "${y.name}" with ${S} service(s) using wizard`)},onCancel:()=>{p(null)}})})}),f&&a.jsx(ex,{organizationId:f.orgId,workspace:f.workspace,onClose:()=>{g(null)},onApplyChanges:async y=>{console.log("🔧 Applying workspace analysis changes:",y);try{const S=await fetch(`/api/organizations/${f.orgId}/workspaces/${f.workspace.id}/apply-improvements`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({improvements:y})}),L=await S.json();if(S.ok&&L.success)G("success","Changes Applied",`Applied ${y.length} improvement(s) to workspace "${f.workspace.name}"`),await wn();else throw new Error(L.error||"Failed to apply changes")}catch(S){console.error("Failed to apply workspace changes:",S),G("error","Failed to Apply Changes",S instanceof Error?S.message:"Failed to apply workspace improvements")}}}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"rounded-lg border bg-green-50 p-6",children:[a.jsx("h3",{className:"text-lg font-medium mb-4",children:"Getting Your Task Shepherd API Information"}),a.jsxs("div",{className:"space-y-3 text-sm text-green-900",children:[a.jsxs("p",{children:[a.jsx("strong",{children:"Step 1:"})," Open your Task Shepherd frontend in a browser"]}),a.jsxs("p",{children:[a.jsx("strong",{children:"Step 2:"})," Copy the URL up to ",a.jsx("code",{children:"/api"})]}),a.jsxs("div",{className:"bg-green-100 p-3 rounded-md font-mono text-xs",children:[a.jsx("p",{children:a.jsx("strong",{children:"Example:"})}),a.jsxs("p",{children:["• Frontend URL: ",a.jsx("code",{children:"https://myorg.taskshepherd.com"})]}),a.jsxs("p",{children:["• API Base Path: ",a.jsx("code",{children:"https://myorg.taskshepherd.com/api"})]})]}),a.jsxs("p",{children:[a.jsx("strong",{children:"Step 3:"})," Generate an ",a.jsx("strong",{children:"Agent API key"})," from Organization Settings → API Keys → Create Agent Key"]})]})]}),Os&&a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-white rounded-lg p-6 max-w-4xl w-full max-h-[90vh] overflow-y-auto m-4",children:[a.jsxs("div",{className:"flex justify-between items-center mb-4",children:[a.jsx("h2",{className:"text-xl font-semibold",children:"Manage Workspaces"}),a.jsx("button",{onClick:()=>Ot(null),className:"text-gray-500 hover:text-gray-700",children:a.jsx(ir,{className:"h-5 w-5"})})]}),dt?a.jsxs("div",{className:"flex items-center justify-center py-12",children:[a.jsx(En,{className:"h-8 w-8 animate-spin text-blue-600"}),a.jsx("span",{className:"ml-2 text-gray-600",children:"Loading available workspaces..."})]}):a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-gray-600",children:"Select workspaces to sync from Task Shepherd and configure local paths for each."}),bt.length===0?a.jsx("div",{className:"text-center py-8 text-gray-500",children:"No workspaces available in this organization"}):a.jsxs("div",{className:"space-y-4",children:[bt.filter(y=>y.isActive!==!1).length>0&&a.jsx("div",{className:"space-y-2",children:bt.filter(y=>y.isActive!==!1).map(y=>a.jsx("div",{className:`border rounded-lg p-4 ${fe.has(y.id)?"border-blue-500 bg-blue-50":"border-gray-200"}`,children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("input",{type:"checkbox",checked:fe.has(y.id),onChange:S=>{const L=new Set(fe);S.target.checked?L.add(y.id):L.delete(y.id),Q(L)},className:"mt-1"}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium",children:y.name}),y.description&&a.jsx("p",{className:"text-sm text-gray-600",children:y.description})]}),y.syncedLocally&&a.jsx("span",{className:"text-xs px-2 py-1 bg-green-100 text-green-700 rounded",children:"Already Synced"})]}),a.jsxs("div",{className:"mt-2",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Local Path"}),a.jsx("input",{type:"text",value:ce[y.id]||"",onChange:S=>{Pe({...ce,[y.id]:S.target.value})},placeholder:y.path||"Enter local directory path",className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-blue-500 text-sm",disabled:!fe.has(y.id)}),a.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Suggested path: ",y.path||"Not specified"]})]}),y.services&&y.services.length>0&&a.jsxs("div",{className:"mt-3 border-t pt-3",children:[a.jsxs("button",{type:"button",onClick:()=>{const S=new Set(Bn);S.has(y.id)?S.delete(y.id):S.add(y.id),va(S)},className:"flex items-center gap-2 text-sm font-medium text-gray-700 hover:text-gray-900",disabled:!fe.has(y.id),children:[Bn.has(y.id)?a.jsx(_r,{className:"h-4 w-4"}):a.jsx(Fr,{className:"h-4 w-4"}),a.jsx(Qr,{className:"h-4 w-4"}),y.services.length," Service",y.services.length!==1?"s":""]}),Bn.has(y.id)&&a.jsx("div",{className:"mt-2 space-y-2 pl-6",children:y.services.map(S=>{const L=`${y.id}:${S.id}`;return a.jsxs("div",{className:"border rounded p-2 bg-gray-50",children:[a.jsxs("div",{className:"flex items-start justify-between mb-1",children:[a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-sm",children:S.name}),S.technology&&a.jsx("span",{className:"ml-2 text-xs px-1.5 py-0.5 bg-purple-100 text-purple-700 rounded",children:S.technology})]}),xn[L]&&a.jsx(ns,{className:"h-3 w-3 text-green-500"})]}),S.description&&a.jsx("p",{className:"text-xs text-gray-500 mb-2",children:S.description}),a.jsx("input",{type:"text",value:xn[L]||"",onChange:F=>{ya({...xn,[L]:F.target.value})},placeholder:"Service local path (optional, inherits from workspace)",className:"w-full px-2 py-1 border border-gray-300 rounded text-xs focus:outline-none focus:ring-1 focus:ring-blue-500",disabled:!fe.has(y.id)}),a.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Leave empty to use workspace path"})]},S.id)})})]}),(!y.services||y.services.length===0)&&a.jsx("p",{className:"text-sm text-gray-500 mt-2 italic",children:"No services defined"})]})]})},y.id))}),bt.filter(y=>y.isActive===!1).length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-sm font-medium text-gray-500",children:"Inactive Workspaces"}),bt.filter(y=>y.isActive===!1).map(y=>a.jsx("div",{className:`border rounded-lg p-4 opacity-60 ${fe.has(y.id)?"border-blue-500 bg-blue-50":"border-gray-200"}`,children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("input",{type:"checkbox",checked:fe.has(y.id),onChange:S=>{const L=new Set(fe);S.target.checked?L.add(y.id):L.delete(y.id),Q(L)},className:"mt-1"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"flex items-center justify-between mb-2",children:a.jsxs("div",{children:[a.jsxs("h3",{className:"font-medium flex items-center gap-2",children:[y.name,a.jsx("span",{className:"text-xs px-2 py-1 bg-gray-100 text-gray-600 rounded",children:"Inactive"})]}),y.description&&a.jsx("p",{className:"text-sm text-gray-600",children:y.description})]})}),a.jsxs("div",{className:"mt-2",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Local Path"}),a.jsx("input",{type:"text",value:ce[y.id]||"",onChange:S=>{Pe({...ce,[y.id]:S.target.value})},placeholder:y.path||"Enter local directory path",className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-blue-500 text-sm",disabled:!fe.has(y.id)}),a.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Suggested path: ",y.path||"Not specified"]})]}),y.services&&y.services.length>0&&a.jsxs("div",{className:"mt-3 border-t pt-3",children:[a.jsxs("button",{type:"button",onClick:()=>{const S=new Set(Bn);S.has(y.id)?S.delete(y.id):S.add(y.id),va(S)},className:"flex items-center gap-2 text-sm font-medium text-gray-700 hover:text-gray-900",disabled:!fe.has(y.id),children:[Bn.has(y.id)?a.jsx(_r,{className:"h-4 w-4"}):a.jsx(Fr,{className:"h-4 w-4"}),a.jsx(Qr,{className:"h-4 w-4"}),y.services.length," Service",y.services.length!==1?"s":""]}),Bn.has(y.id)&&a.jsx("div",{className:"mt-2 space-y-2 pl-6",children:y.services.map(S=>{const L=`${y.id}:${S.id}`;return a.jsxs("div",{className:"border rounded p-2 bg-gray-50",children:[a.jsxs("div",{className:"flex items-start justify-between mb-1",children:[a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-sm",children:S.name}),S.technology&&a.jsx("span",{className:"ml-2 text-xs px-1.5 py-0.5 bg-purple-100 text-purple-700 rounded",children:S.technology})]}),xn[L]&&a.jsx(ns,{className:"h-3 w-3 text-green-500"})]}),S.description&&a.jsx("p",{className:"text-xs text-gray-500 mb-2",children:S.description}),a.jsx("input",{type:"text",value:xn[L]||"",onChange:F=>{ya({...xn,[L]:F.target.value})},placeholder:"Service local path (optional, inherits from workspace)",className:"w-full px-2 py-1 border border-gray-300 rounded text-xs focus:outline-none focus:ring-1 focus:ring-blue-500",disabled:!fe.has(y.id)}),a.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Leave empty to use workspace path"})]},S.id)})})]}),(!y.services||y.services.length===0)&&a.jsx("p",{className:"text-sm text-gray-500 mt-2 italic",children:"No services defined"})]})]})},y.id))]})]}),a.jsxs("div",{className:"flex justify-end gap-2 mt-6 pt-4 border-t",children:[a.jsx("button",{onClick:()=>Ot(null),className:"px-4 py-2 text-gray-600 hover:text-gray-800",disabled:Wn,children:"Cancel"}),a.jsx("button",{onClick:()=>ch(Os),disabled:Wn,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:Wn?a.jsxs(a.Fragment,{children:[a.jsx(En,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):a.jsxs(a.Fragment,{children:[a.jsx(gi,{className:"h-4 w-4"}),"Save"]})})]})]})]})}),a.jsxs("div",{className:"rounded-lg border bg-blue-50 p-6",children:[a.jsx("h3",{className:"text-lg font-medium mb-4",children:"About Organization & Workspace Management"}),a.jsxs("div",{className:"space-y-2 text-sm text-blue-900",children:[a.jsxs("p",{children:["• ",a.jsx("strong",{children:"Organizations"})," represent different Task Shepherd instances you want to connect to"]}),a.jsxs("p",{children:["• Each organization needs an ",a.jsx("strong",{children:"Agent API key"})," (not a user API key) generated from the Task Shepherd organization settings"]}),a.jsxs("p",{children:["• ",a.jsx("strong",{children:"Workspaces"})," are collections of related projects within an organization"]}),a.jsxs("p",{children:["• Click ",a.jsx("strong",{children:"Manage"})," to select and sync workspaces from Task Shepherd with custom local paths"]}),a.jsx("p",{children:"• You can activate/deactivate workspaces to control which ones the agent works with"}),a.jsx("p",{children:"• The agent will automatically sync workspaces and accept work assignments from configured organizations"})]})]})]})]})]})}function nx(){const[e,t]=N.useState([]),[n,r]=N.useState(!0),[s,i]=N.useState(null),[o,l]=N.useState(!1),[u,c]=N.useState({organizationId:"",workspaceId:"",serviceId:"",localPath:"",serviceName:"",technology:"",notes:""}),[d,h]=N.useState(!1),m=async()=>{r(!0),i(null);try{const p=await fetch("/api/service-mappings");if(!p.ok)throw new Error("Failed to fetch service mappings");const f=await p.json();if(f.success)t(f.mappings);else throw new Error("Failed to fetch mappings")}catch(p){i(p instanceof Error?p.message:"Failed to fetch mappings")}finally{r(!1)}};N.useEffect(()=>{m()},[]);const v=async p=>{p.preventDefault(),h(!0),i(null);try{const f=await fetch("/api/service-mappings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)}),g=await f.json();if(!f.ok||!g.success)throw new Error(g.error||"Failed to save mapping");await m(),l(!1),c({organizationId:"",workspaceId:"",serviceId:"",localPath:"",serviceName:"",technology:"",notes:""})}catch(f){i(f instanceof Error?f.message:"Failed to save mapping")}finally{h(!1)}},x=async p=>{if(confirm(`Delete mapping for ${p.serviceName||p.serviceId}?`))try{const f=await fetch(`/api/service-mappings/${encodeURIComponent(p.organizationId)}/${encodeURIComponent(p.workspaceId)}/${encodeURIComponent(p.serviceId)}`,{method:"DELETE"}),g=await f.json();if(!f.ok||!g.success)throw new Error(g.error||"Failed to delete mapping");await m()}catch(f){i(f instanceof Error?f.message:"Failed to delete mapping")}},w=p=>new Date(p).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),k=e.reduce((p,f)=>(p[f.organizationId]||(p[f.organizationId]=[]),p[f.organizationId].push(f),p),{});return a.jsxs(a.Fragment,{children:[a.jsx(pn,{children:a.jsx("title",{children:"Service Mappings - AI Agent Service"})}),a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Service Mappings"}),a.jsx("p",{className:"text-muted-foreground",children:"Map backend services to local filesystem paths for multi-repo workspaces"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:m,disabled:n,className:"inline-flex items-center gap-2 px-4 py-2 rounded-md border bg-white hover:bg-gray-50 disabled:opacity-50",children:[a.jsx(Zt,{className:`h-4 w-4 ${n?"animate-spin":""}`}),"Refresh"]}),a.jsxs("button",{onClick:()=>l(!0),className:"inline-flex items-center gap-2 px-4 py-2 rounded-md bg-blue-600 text-white hover:bg-blue-700",children:[a.jsx(pr,{className:"h-4 w-4"}),"Add Mapping"]})]})]}),s&&a.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg text-red-700",children:s}),o&&a.jsxs("div",{className:"rounded-lg border bg-card p-6",children:[a.jsx("h3",{className:"text-lg font-medium mb-4",children:"Add Service Mapping"}),a.jsxs("form",{onSubmit:v,className:"space-y-4",children:[a.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium mb-1",children:"Organization ID *"}),a.jsx("input",{type:"text",value:u.organizationId,onChange:p=>c({...u,organizationId:p.target.value}),required:!0,className:"w-full px-3 py-2 border rounded-md",placeholder:"org-..."})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium mb-1",children:"Workspace ID *"}),a.jsx("input",{type:"text",value:u.workspaceId,onChange:p=>c({...u,workspaceId:p.target.value}),required:!0,className:"w-full px-3 py-2 border rounded-md",placeholder:"workspace-..."})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium mb-1",children:"Service ID *"}),a.jsx("input",{type:"text",value:u.serviceId,onChange:p=>c({...u,serviceId:p.target.value}),required:!0,className:"w-full px-3 py-2 border rounded-md",placeholder:"service-..."})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium mb-1",children:"Local Path *"}),a.jsx("input",{type:"text",value:u.localPath,onChange:p=>c({...u,localPath:p.target.value}),required:!0,className:"w-full px-3 py-2 border rounded-md",placeholder:"/path/to/service"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium mb-1",children:"Service Name"}),a.jsx("input",{type:"text",value:u.serviceName,onChange:p=>c({...u,serviceName:p.target.value}),className:"w-full px-3 py-2 border rounded-md",placeholder:"My Service"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium mb-1",children:"Technology"}),a.jsxs("select",{value:u.technology,onChange:p=>c({...u,technology:p.target.value}),className:"w-full px-3 py-2 border rounded-md",children:[a.jsx("option",{value:"",children:"Select..."}),a.jsx("option",{value:"NODEJS",children:"Node.js"}),a.jsx("option",{value:"REACT",children:"React"}),a.jsx("option",{value:"PYTHON",children:"Python"}),a.jsx("option",{value:"GO",children:"Go"}),a.jsx("option",{value:"RUST",children:"Rust"}),a.jsx("option",{value:"JAVA",children:"Java"}),a.jsx("option",{value:"OTHER",children:"Other"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium mb-1",children:"Notes"}),a.jsx("textarea",{value:u.notes,onChange:p=>c({...u,notes:p.target.value}),className:"w-full px-3 py-2 border rounded-md",rows:2,placeholder:"Optional notes about this mapping..."})]}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx("button",{type:"button",onClick:()=>l(!1),className:"px-4 py-2 rounded-md border hover:bg-gray-50",children:"Cancel"}),a.jsx("button",{type:"submit",disabled:d,className:"px-4 py-2 rounded-md bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50",children:d?"Saving...":"Save Mapping"})]})]})]}),n?a.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading mappings..."}):e.length===0?a.jsxs("div",{className:"rounded-lg border bg-card p-12 text-center",children:[a.jsx(ns,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),a.jsx("h3",{className:"text-lg font-medium mb-2",children:"No Service Mappings"}),a.jsx("p",{className:"text-muted-foreground mb-4",children:"Service mappings allow the agent to find local paths for multi-repo workspace services."}),a.jsxs("button",{onClick:()=>l(!0),className:"inline-flex items-center gap-2 px-4 py-2 rounded-md bg-blue-600 text-white hover:bg-blue-700",children:[a.jsx(pr,{className:"h-4 w-4"}),"Add First Mapping"]})]}):a.jsx("div",{className:"space-y-6",children:Object.entries(k).map(([p,f])=>a.jsxs("div",{className:"rounded-lg border bg-card",children:[a.jsx("div",{className:"px-6 py-4 border-b bg-gray-50 rounded-t-lg",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(iv,{className:"h-5 w-5 text-blue-600"}),a.jsxs("h3",{className:"font-medium",children:["Organization: ",p]}),a.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",f.length," mapping",f.length!==1?"s":"",")"]})]})}),a.jsx("div",{className:"divide-y",children:f.map(g=>a.jsx("div",{className:"px-6 py-4 hover:bg-gray-50",children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(uv,{className:"h-4 w-4 text-purple-600"}),a.jsx("span",{className:"font-medium",children:g.serviceName||g.serviceId}),g.technology&&a.jsx("span",{className:"px-2 py-0.5 text-xs bg-blue-100 text-blue-700 rounded",children:g.technology})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(ov,{className:"h-4 w-4"}),a.jsxs("span",{children:["Workspace: ",g.workspaceId.slice(0,8),"..."]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Rp,{className:"h-4 w-4"}),a.jsx("span",{className:"font-mono",children:g.localPath})]})]}),g.notes&&a.jsx("p",{className:"text-sm text-muted-foreground italic",children:g.notes}),a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Mapped: ",w(g.mappedAt)]})]}),a.jsx("button",{onClick:()=>x(g),className:"p-2 text-red-600 hover:bg-red-50 rounded",title:"Delete mapping",children:a.jsx(rs,{className:"h-4 w-4"})})]})},`${g.organizationId}:${g.workspaceId}:${g.serviceId}`))})]},p))}),a.jsxs("div",{className:"rounded-lg border bg-blue-50 p-6",children:[a.jsx("h3",{className:"text-lg font-medium text-blue-900 mb-2",children:"About Service Mappings"}),a.jsx("p",{className:"text-blue-800 text-sm mb-4",children:"Service mappings are used by the agent to locate local source code for multi-repo workspaces. When processing work, the agent checks service mappings first, then falls back to workspace mappings."}),a.jsxs("ul",{className:"text-sm text-blue-700 space-y-1 list-disc list-inside",children:[a.jsx("li",{children:"Each mapping links a backend service ID to a local filesystem path"}),a.jsx("li",{children:"Service mappings take priority over workspace mappings"}),a.jsx("li",{children:"Use for multi-repo workspaces where services are in different directories"}),a.jsx("li",{children:"The agent can only process work for mapped services"})]})]})]})]})}function rx(){return a.jsxs(a.Fragment,{children:[a.jsx(pn,{children:a.jsx("title",{children:"404 - Page Not Found"})}),a.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] text-center",children:a.jsxs("div",{className:"space-y-4",children:[a.jsx("h1",{className:"text-4xl font-bold",children:"404"}),a.jsx("h2",{className:"text-xl text-muted-foreground",children:"Page Not Found"}),a.jsx("p",{className:"text-muted-foreground max-w-md",children:"The page you're looking for doesn't exist or has been moved."}),a.jsxs(jp,{to:"/",className:"inline-flex items-center space-x-2 rounded-lg bg-primary px-4 py-2 text-primary-foreground hover:bg-primary/90",children:[a.jsx(Lp,{className:"h-4 w-4"}),a.jsx("span",{children:"Go Home"})]})]})})]})}function sx(){return a.jsxs(a.Fragment,{children:[a.jsxs(pn,{children:[a.jsx("title",{children:"AI Agent Service Dashboard"}),a.jsx("meta",{name:"description",content:"Analytics dashboard for AI agent service monitoring"})]}),a.jsx(Vv,{children:a.jsxs(A0,{children:[a.jsx(qr,{path:"/",element:a.jsx(Xv,{})}),a.jsx(qr,{path:"/organizations",element:a.jsx(tx,{})}),a.jsx(qr,{path:"/service-mappings",element:a.jsx(nx,{})}),a.jsx(qr,{path:"*",element:a.jsx(rx,{})})]})})]})}const ix=new ay({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1,staleTime:1e3*60*5}}});to.createRoot(document.getElementById("root")).render(a.jsx(I.StrictMode,{children:a.jsx(sr,{children:a.jsx(uy,{client:ix,children:a.jsxs(D0,{children:[a.jsx(sx,{}),a.jsx(ev,{position:"top-right"})]})})})}));
|
|
69
|
+
//# sourceMappingURL=index-964c5c2c.js.map
|