@task-shepherd/agent 1.0.48 → 1.0.49

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.
@@ -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 z0(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 A0(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function M0(e,t){return e.button===0&&(!t||t==="_self")&&!A0(e)}const R0=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],I0="6";try{window.__reactRouterVersion=I0}catch{}const _0="startTransition",Cc=Ph[_0];function L0(e){let{basename:t,children:n,future:r,window:s}=e,i=N.useRef();i.current==null&&(i.current=$g({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(p=>{c&&Cc?Cc(()=>u(p)):u(p)},[u,c]);return N.useLayoutEffect(()=>o.listen(d),[o,d]),N.useEffect(()=>P0(r),[r]),N.createElement(T0,{basename:t,children:n,location:l.location,navigationType:l.action,navigator:o,future:r})}const F0=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",D0=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,xp=N.forwardRef(function(t,n){let{onClick:r,relative:s,reloadDocument:i,replace:o,state:l,target:u,to:c,preventScrollReset:d,viewTransition:p}=t,h=z0(t,R0),{basename:v}=N.useContext(Dn),x,w=!1;if(typeof c=="string"&&D0.test(c)&&(x=c,F0))try{let g=new URL(window.location.href),b=c.startsWith("//")?new URL(g.protocol+c):new URL(c),E=tu(b.pathname,v);b.origin===g.origin&&E!=null?c=E+b.search+b.hash:w=!0}catch{}let k=f0(c,{relative:s}),m=$0(c,{replace:o,state:l,target:u,preventScrollReset:d,relative:s,viewTransition:p});function f(g){r&&r(g),g.defaultPrevented||m(g)}return N.createElement("a",Jo({},h,{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 $0(e,t){let{target:n,replace:r,state:s,preventScrollReset:i,relative:o,viewTransition:l}=t===void 0?{}:t,u=p0(),c=Os(),d=gp(e,{relative:o});return N.useCallback(p=>{if(M0(p,n)){p.preventDefault();let h=r!==void 0?r:Ui(c)===Ui(d);u(e,{replace:h,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 vt(){}function U0(e,t){return typeof e=="function"?e(t):e}function W0(e){return typeof e=="number"&&e>=0&&e!==1/0}function B0(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(En(t.options.mutationKey)!==En(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)||En)(e)}function En(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 wp(e,t)}function wp(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(n=>!wp(e[n],t[n])):!1}function jp(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]=jp(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 bp(e){return new Promise(t=>{setTimeout(t,e)})}function Mc(e){bp(0).then(e)}function H0(){if(typeof AbortController=="function")return new AbortController}function q0(e,t,n){return n.isDataEqual!=null&&n.isDataEqual(e,t)?e:typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?jp(e,t):t}class Q0 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 Q0,Rc=["online","offline"];class V0 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 V0;function K0(e){return Math.min(1e3*2**e,3e4)}function iu(e){return(e??"online")==="online"?Hi.isOnline():!0}class Np{constructor(t){this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}}function Ga(e){return e instanceof Np}function kp(e){let t=!1,n=0,r=!1,s,i,o;const l=new Promise((k,m)=>{i=k,o=m}),u=k=>{r||(v(new Np(k)),e.abort==null||e.abort())},c=()=>{t=!0},d=()=>{t=!1},p=()=>!Zo.isFocused()||e.networkMode!=="always"&&!Hi.isOnline(),h=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=m=>{const f=r||!p();return f&&k(m),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(m){k=Promise.reject(m)}Promise.resolve(k).then(h).catch(m=>{var f,g;if(r)return;const b=(f=e.retry)!=null?f:3,E=(g=e.retryDelay)!=null?g:K0,T=typeof E=="function"?E(n,m):E,C=b===!0||typeof b=="number"&&n<b||typeof b=="function"&&b(n,m);if(t||!C){v(m);return}n++,e.onFail==null||e.onFail(n,m),bp(T).then(()=>{if(p())return x()}).then(()=>{t?v(m):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 G0(){let e=[],t=0,n=d=>{d()},r=d=>{d()};const s=d=>{let p;t++;try{p=d()}finally{t--,t||l()}return p},i=d=>{t?e.push(d):Mc(()=>{n(d)})},o=d=>(...p)=>{i(()=>{d(...p)})},l=()=>{const d=e;e=[],d.length&&Mc(()=>{r(()=>{d.forEach(p=>{n(p)})})})};return{batch:s,batchCalls:o,schedule:i,setNotifyFunction:d=>{n=d},setBatchNotifyFunction:d=>{r=d}}}const qe=G0();class Sp{destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),W0(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 Y0 extends Sp{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||J0(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=q0(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(vt).catch(vt):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||!B0(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=H0(),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 p;this.dispatch({type:"fetch",meta:(p=d.fetchOptions)==null?void 0:p.meta})}const h=v=>{if(Ga(v)&&v.silent||this.dispatch({type:"error",error:v}),!Ga(v)){var x,w,k,m;(x=(w=this.cache.config).onError)==null||x.call(w,v,this),(k=(m=this.cache.config).onSettled)==null||k.call(m,this.state.data,v,this)}this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return this.retryer=kp({fn:d.fetchFn,abort:o==null?void 0:o.abort.bind(o),onSuccess:v=>{var x,w,k,m;if(typeof v>"u"){h(new Error(this.queryHash+" data is undefined"));return}this.setData(v),(x=(w=this.cache.config).onSuccess)==null||x.call(w,v,this),(k=(m=this.cache.config).onSettled)==null||k.call(m,v,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:h,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),qe.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate(t)}),this.cache.notify({query:this,type:"updated",action:t})})}}function J0(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 X0 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 Y0({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(){qe.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){qe.batch(()=>{this.listeners.forEach(({listener:n})=>{n(t)})})}onFocus(){qe.batch(()=>{this.queries.forEach(t=>{t.onFocus()})})}onOnline(){qe.batch(()=>{this.queries.forEach(t=>{t.onOnline()})})}}class Z0 extends Sp{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||ey(),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=kp({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 p,h,v,x;this.dispatch({type:"loading",variables:this.options.variables}),await((p=(h=this.mutationCache.config).onMutate)==null?void 0:p.call(h,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,m,f,g,b,E,T;throw await((w=(k=this.mutationCache.config).onError)==null?void 0:w.call(k,C,this.state.variables,this.state.context,this)),await((m=(f=this.options).onError)==null?void 0:m.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((E=(T=this.options).onSettled)==null?void 0:E.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),qe.batch(()=>{this.observers.forEach(r=>{r.onMutationUpdate(t)}),this.mutationCache.notify({mutation:this,type:"updated",action:t})})}}function ey(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0}}class ty extends ca{constructor(t){super(),this.config=t||{},this.mutations=[],this.mutationId=0}build(t,n,r){const s=new Z0({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(){qe.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){qe.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 qe.batch(()=>n.reduce((r,s)=>r.then(()=>s.continue().catch(vt)),Promise.resolve()))}).then(()=>{this.resuming=void 0}),this.resuming}}function ny(){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",p=(u==null?void 0:u.direction)==="backward",h=((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}})},m=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=m(M);return Promise.resolve(K).then(Ce=>f(T,j,Ce,R))};let b;if(!h.length)b=g([]);else if(d){const T=typeof c<"u",C=T?c:Ic(e.options,h);b=g(h,T,C)}else if(p){const T=typeof c<"u",C=T?c:ry(e.options,h);b=g(h,T,C,!0)}else{x=[];const T=typeof e.options.getNextPageParam>"u";b=(l&&h[0]?l(h[0],0,h):!0)?g([],T,v[0]):Promise.resolve(f([],v[0],h[0]));for(let j=1;j<h.length;j++)b=b.then(R=>{if(l&&h[j]?l(h[j],j,h):!0){const K=T?v[j]:Ic(e.options,R);return g(R,T,K)}return Promise.resolve(f(R,v[j],h[j]))})}return b.then(T=>({pages:T,pageParams:x}))}}}}function Ic(e,t){return e.getNextPageParam==null?void 0:e.getNextPageParam(t[t.length-1],t)}function ry(e,t){return e.getPreviousPageParam==null?void 0:e.getPreviousPageParam(t[0],t)}class sy{constructor(t={}){this.queryCache=t.queryCache||new X0,this.mutationCache=t.mutationCache||new ty,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=U0(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 qe.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;qe.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 qe.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=qe.batch(()=>this.queryCache.findAll(s).map(l=>l.cancel(i)));return Promise.all(o).then(vt).catch(vt)}invalidateQueries(t,n,r){const[s,i]=Gt(t,n,r);return qe.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=qe.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(vt);return i!=null&&i.throwOnError||(l=l.catch(vt)),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(vt).catch(vt)}fetchInfiniteQuery(t,n,r){const s=Ys(t,n,r);return s.behavior=ny(),this.fetchQuery(s)}prefetchInfiniteQuery(t,n,r){return this.fetchInfiniteQuery(t,n,r).then(vt).catch(vt)}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=>En(t)===En(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=>En(t)===En(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 _c=N.createContext(void 0),iy=N.createContext(!1);function ay(e,t){return e||(t&&typeof window<"u"?(window.ReactQueryClientContext||(window.ReactQueryClientContext=_c),window.ReactQueryClientContext):_c)}const oy=({client:e,children:t,context:n,contextSharing:r=!1})=>{N.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]);const s=ay(n,r);return N.createElement(iy.Provider,{value:!n&&r},N.createElement(s.Provider,{value:e},t))};var Cp={exports:{}},ly="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",uy=ly,cy=uy;function Ep(){}function Pp(){}Pp.resetWarningCache=Ep;var dy=function(){function e(r,s,i,o,l,u){if(u!==cy){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:Pp,resetWarningCache:Ep};return n.PropTypes=n,n};Cp.exports=dy();var fy=Cp.exports;const se=br(fy);var py=typeof Element<"u",hy=typeof Map=="function",my=typeof Set=="function",gy=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(hy&&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(my&&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(gy&&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(py&&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 yy=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 vy=br(yy);var xy=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}},wy=xy;const Lc=br(wy);var jy=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 p=t[d],h=n[d];if(i=r?r.call(s,p,h,d):void 0,i===!1||i===void 0&&p!==h)return!1}return!0};const by=br(jy);function ke(){return ke=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},ke.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)"},Ny={rel:["amphtml","canonical","alternate"]},ky={type:["application/ld+json"]},Sy={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"},Cy=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},Ey=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},Py=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 ke({},n,r)},{})},Ty=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},[])},_r=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(p){for(var h,v=Object.keys(p),x=0;x<v.length;x+=1){var w=v[x],k=w.toLowerCase();t.indexOf(k)===-1||h==="rel"&&p[h].toLowerCase()==="canonical"||k==="rel"&&p[k].toLowerCase()==="stylesheet"||(h=k),t.indexOf(w)===-1||w!=="innerHTML"&&w!=="cssText"&&w!=="itemprop"||(h=w)}if(!h||!p[h])return!1;var m=p[h].toLowerCase();return r[h]||(r[h]={}),o[h]||(o[h]={}),!r[h][m]&&(o[h][m]=!0,!0)}).reverse().forEach(function(p){return s.push(p)});for(var l=Object.keys(o),u=0;u<l.length;u+=1){var c=l[u],d=ke({},r[c],o[c]);r[c]=d}return s},[]).reverse()},Oy=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},Tp=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 ke({},e,((n={})[t]=void 0,n))},zy=[B.NOSCRIPT,B.SCRIPT,B.STYLE],Xa=function(e,t){return t===void 0&&(t=!0),t===!1?String(e):String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")},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]}),_.createElement(e,i)})},ot=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),[_.createElement(B.TITLE,o,r)];var r,s,i,o},toString:function(){return function(r,s,i,o){var l=Uc(i),u=Tp(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(p){return!(p==="innerHTML"||p==="cssText")}).reduce(function(p,h){var v=l[h]===void 0?h:h+'="'+Xa(l[h],i)+'"';return p?p+" "+v:v},""),c=l.innerHTML||l.cssText||"",d=zy.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,p=e.metaTags,h=e.scriptTags,v={toComponent:function(){},toString:function(){return""}};if(e.prioritizeSeoTags){var x=function(w){var k=w.linkTags,m=w.scriptTags,f=w.encode,g=Ja(w.metaTags,Sy),b=Ja(k,Ny),E=Ja(m,ky);return{priorityMethods:{toComponent:function(){return[].concat(hi(B.META,g.priority),hi(B.LINK,b.priority),hi(B.SCRIPT,E.priority))},toString:function(){return ot(B.META,g.priority,f)+" "+ot(B.LINK,b.priority,f)+" "+ot(B.SCRIPT,E.priority,f)}},metaTags:g.default,linkTags:b.default,scriptTags:E.default}}(e);v=x.priorityMethods,d=x.linkTags,p=x.metaTags,h=x.scriptTags}return{priority:v,base:ot(B.BASE,t,r),bodyAttributes:ot("bodyAttributes",n,r),htmlAttributes:ot("htmlAttributes",s,r),link:ot(B.LINK,d,r),meta:ot(B.META,p,r),noscript:ot(B.NOSCRIPT,i,r),script:ot(B.SCRIPT,h,r),style:ot(B.STYLE,o,r),title:ot(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:{}}))},Op=_.createContext({}),Ay=se.shape({setHelmet:se.func,helmetInstances:se.shape({get:se.func,add:se.func,remove:se.func})}),My=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 _.createElement(Op.Provider,{value:this.helmetData.value},this.props.children)},t}(N.Component);sr.canUseDOM=My,sr.propTypes={context:se.shape({helmet:se.shape()}),children:se.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,p){return n=p,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 p=i.length-1;p>=0;p-=1)n.removeAttribute(i[p]);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,p=e.titleAttributes;Za(B.BODY,e.bodyAttributes),Za(B.HTML,r),function(w,k){w!==void 0&&document.title!==w&&(document.title=Tp(w)),Za(B.TITLE,k)}(d,p);var h={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(h).forEach(function(w){var k=h[w],m=k.newTags,f=k.oldTags;m.length&&(v[w]=m),f.length&&(x[w]=h[w].oldTags)}),t&&t(),l(e,v,x)},Lr=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!by(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=ke({},c.props);return delete d.context,d}),{baseTag:Ty(["href"],r),bodyAttributes:Ya("bodyAttributes",r),defer:fr(r,"defer"),encode:fr(r,"encodeSpecialCharacters"),htmlAttributes:Ya("htmlAttributes",r),linkTags:_r(B.LINK,["rel","href"],r),metaTags:_r(B.META,["name","charset","http-equiv","property","itemprop"],r),noscriptTags:_r(B.NOSCRIPT,["innerHTML"],r),onChangeClientState:Py(r),scriptTags:_r(B.SCRIPT,["src","innerHTML"],r),styleTags:_r(B.STYLE,["cssText"],r),title:Ey(r),titleAttributes:Ya("titleAttributes",r),prioritizeSeoTags:Oy(r,"prioritizeSeoTags")});sr.canUseDOM?(s=u,Lr&&cancelAnimationFrame(Lr),s.defer?Lr=requestAnimationFrame(function(){Bc(s,function(){Lr=null})}):(Bc(s),Lr=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:Ay.isRequired},Qi.displayName="HelmetDispatcher";var Ry=["children"],Iy=["children"],hn=function(e){function t(){return e.apply(this,arguments)||this}ou(t,e);var n=t.prototype;return n.shouldComponentUpdate=function(r){return!vy($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 ke({},o,((s={})[i.type]=[].concat(o[i.type]||[],[ke({},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 ke({},l,((s={})[o.type]=c,s.titleAttributes=ke({},u),s));case B.BODY:return ke({},l,{bodyAttributes:ke({},u)});case B.HTML:return ke({},l,{htmlAttributes:ke({},u)});default:return ke({},l,((i={})[o.type]=ke({},u),i))}},n.mapArrayTypeChildrenToProps=function(r,s){var i=ke({},s);return Object.keys(r).forEach(function(o){var l;i=ke({},i,((l={})[o]=r[o],l))}),i},n.warnOnInvalidChildren=function(r,s){return Lc(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."),Lc(!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 _.Children.forEach(r,function(l){if(l&&l.props){var u=l.props,c=u.children,d=Fc(u,Ry),p=Object.keys(d).reduce(function(v,x){return v[Cy[x]||x]=d[x],v},{}),h=l.type;switch(typeof h=="symbol"?h=h.toString():i.warnOnInvalidChildren(l,c),h){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:p,nestedChildren:c});break;default:s=i.mapObjectTypeChildren({child:l,newProps:s,newChildProps:p,nestedChildren:c})}}}),this.mapArrayTypeChildrenToProps(o,s)},n.render=function(){var r=this.props,s=r.children,i=Fc(r,Iy),o=ke({},i),l=i.helmetData;return s&&(o=this.mapChildrenToProps(s,o)),!l||l instanceof nl||(l=new nl(l.context,l.instances)),l?_.createElement(Qi,ke({},o,{context:l.value,helmetData:void 0})):_.createElement(Op.Consumer,null,function(u){return _.createElement(Qi,ke({},o,{context:u}))})},t}(N.Component);hn.propTypes={base:se.object,bodyAttributes:se.object,children:se.oneOfType([se.arrayOf(se.node),se.node]),defaultTitle:se.string,defer:se.bool,encodeSpecialCharacters:se.bool,htmlAttributes:se.object,link:se.arrayOf(se.object),meta:se.arrayOf(se.object),noscript:se.arrayOf(se.object),onChangeClientState:se.func,script:se.arrayOf(se.object),style:se.arrayOf(se.object),title:se.string,titleAttributes:se.object,titleTemplate:se.string,prioritizeSeoTags:se.bool,helmetData:se.object},hn.defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1},hn.displayName="Helmet";function _y(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))}_y(`[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 Ly=e=>{switch(e){case"success":return $y;case"error":return Uy;default:return null}},Fy=Array(12).fill(0),Dy=({visible:e})=>_.createElement("div",{className:"sonner-loading-wrapper","data-visible":e},_.createElement("div",{className:"sonner-spinner"},Fy.map((t,n)=>_.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),$y=_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},_.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"})),Uy=_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},_.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,Wy=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 Wy,By=(e,t)=>{let n=(t==null?void 0:t.id)||rl++;return Yt.addToast({title:e,...t,id:n}),n},Hy=By;Object.assign(Hy,{success:Yt.success,error:Yt.error,custom:Yt.custom,message:Yt.message,promise:Yt.promise,dismiss:Yt.dismiss});var qy=3,Qy="32px",Vy=4e3,Ky=356,zp=14,Gy=20,Yy=200,Jy=e=>{let{invert:t,toast:n,interacting:r,setHeights:s,visibleToasts:i,heights:o,index:l,toasts:u,expanded:c,removeToast:d,closeButton:p,style:h,className:v="",descriptionClassName:x="",duration:w,position:k,expandByDefault:m}=e,[f,g]=_.useState(!1),[b,E]=_.useState(!1),[T,C]=_.useState(!1),[j,R]=_.useState(!1),[M,K]=_.useState(0),[G,Ce]=_.useState(0),P=_.useRef(null),q=l===0,Y=l+1<=i,ae=n.type,A=n.className||"",F=n.descriptionClassName||"",U=_.useMemo(()=>o.findIndex(V=>V.toastId===n.id)||0,[o,n.id]),ee=_.useMemo(()=>n.duration||w||Vy,[n.duration,w]),Q=_.useRef(0),X=_.useRef(0),ue=_.useRef(ee),Ae=_.useRef(0),ve=_.useRef(null),[Ge,kt]=k.split("-"),Be=_.useMemo(()=>o.reduce((V,ce,Te)=>Te>=U?V:V+ce.height,0),[o,U]),be=n.invert||t,Er=ae==="loading";X.current=_.useMemo(()=>U*zp+Be,[U,Be]),_.useEffect(()=>{g(!0)},[]),_.useLayoutEffect(()=>{if(!f)return;let V=P.current,ce=V.style.height;V.style.height="auto";let Te=V.getBoundingClientRect().height;V.style.height=ce,Ce(Te),s(ht=>ht.find(St=>St.toastId===n.id)?ht.map(St=>St.toastId===n.id?{...St,height:Te}:St):[{toastId:n.id,height:Te},...ht])},[f,n.title,n.description,s,n.id]);let fe=_.useCallback(()=>{E(!0),K(X.current),s(V=>V.filter(ce=>ce.toastId!==n.id)),setTimeout(()=>{d(n)},Yy)},[n,d,s,X]);return _.useEffect(()=>{if(n.promise&&ae==="loading"||n.duration===1/0)return;let V;return c||r?(()=>{if(Ae.current<Q.current){let ce=new Date().getTime()-Q.current;ue.current=ue.current-ce}Ae.current=new Date().getTime()})():(Q.current=new Date().getTime(),V=setTimeout(()=>{var ce;(ce=n.onAutoClose)==null||ce.call(n,n),fe()},ue.current)),()=>clearTimeout(V)},[c,r,m,n,ee,fe,n.promise,ae]),_.useEffect(()=>{let V=P.current;if(V){let ce=V.getBoundingClientRect().height;return Ce(ce),s(Te=>[{toastId:n.id,height:ce},...Te]),()=>s(Te=>Te.filter(ht=>ht.toastId!==n.id))}},[s,n.id]),_.useEffect(()=>{n.delete&&fe()},[fe,n.delete]),_.createElement("li",{"aria-live":n.important?"assertive":"polite","aria-atomic":"true",role:"status",tabIndex:0,ref:P,className:v+" "+A,"data-sonner-toast":"","data-styled":!n.jsx,"data-mounted":f,"data-promise":!!n.promise,"data-removed":b,"data-visible":Y,"data-y-position":Ge,"data-x-position":kt,"data-index":l,"data-front":q,"data-swiping":T,"data-type":ae,"data-invert":be,"data-swipe-out":j,"data-expanded":!!(c||m&&f),style:{"--index":l,"--toasts-before":l,"--z-index":u.length-l,"--offset":`${b?M:X.current}px`,"--initial-height":m?"auto":`${G}px`,...h,...n.style},onPointerDown:V=>{Er||(K(X.current),V.target.setPointerCapture(V.pointerId),V.target.tagName!=="BUTTON"&&(C(!0),ve.current={x:V.clientX,y:V.clientY}))},onPointerUp:()=>{var V,ce,Te;if(j)return;ve.current=null;let ht=Number(((V=P.current)==null?void 0:V.style.getPropertyValue("--swipe-amount").replace("px",""))||0);if(Math.abs(ht)>=Gy){K(X.current),(ce=n.onDismiss)==null||ce.call(n,n),fe(),R(!0);return}(Te=P.current)==null||Te.style.setProperty("--swipe-amount","0px"),C(!1)},onPointerMove:V=>{var ce;if(!ve.current)return;let Te=V.clientY-ve.current.y,ht=V.clientX-ve.current.x,St=(Ge==="top"?Math.min:Math.max)(0,Te),Wn=V.pointerType==="touch"?10:2;Math.abs(St)>Wn?(ce=P.current)==null||ce.style.setProperty("--swipe-amount",`${Te}px`):Math.abs(ht)>Wn&&(ve.current=null)}},p&&!n.jsx?_.createElement("button",{"aria-label":"Close toast","data-disabled":Er,"data-close-button":!0,onClick:Er?void 0:()=>{var V;fe(),(V=n.onDismiss)==null||V.call(n,n)}},_.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"},_.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),_.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}))):null,n.jsx||_.isValidElement(n.title)?n.jsx||n.title:_.createElement(_.Fragment,null,ae||n.icon||n.promise?_.createElement("div",{"data-icon":""},n.promise?_.createElement(Dy,{visible:ae==="loading"}):null,n.icon||Ly(ae)):null,_.createElement("div",{"data-content":""},_.createElement("div",{"data-title":""},n.title),n.description?_.createElement("div",{"data-description":"",className:x+F},n.description):null),n.cancel?_.createElement("button",{"data-button":!0,"data-cancel":!0,onClick:()=>{var V;fe(),(V=n.cancel)!=null&&V.onClick&&n.cancel.onClick()}},n.cancel.label):null,n.action?_.createElement("button",{"data-button":"",onClick:V=>{var ce;(ce=n.action)==null||ce.onClick(V),!V.defaultPrevented&&fe()}},n.action.label):null))},Xy=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:p,style:h,visibleToasts:v=qy,toastOptions:x}=e,[w,k]=_.useState([]),[m,f]=_.useState([]),[g,b]=_.useState(!1),[E,T]=_.useState(!1),[C,j]=_.useState(c!=="system"?c:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),[R,M]=r.split("-"),K=_.useRef(null),G=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),Ce=_.useCallback(P=>k(q=>q.filter(({id:Y})=>Y!==P.id)),[]);return _.useEffect(()=>Yt.subscribe(P=>{if(P.dismiss){k(q=>q.map(Y=>Y.id===P.id?{...Y,delete:!0}:Y));return}setTimeout(()=>{Dg.flushSync(()=>{k(q=>{let Y=q.findIndex(ae=>ae.id===P.id);return Y!==-1?[...q.slice(0,Y),{...q[Y],...P},...q.slice(Y+1)]:[P,...q]})})})}),[]),_.useEffect(()=>{if(c!=="system"){j(c);return}typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",({matches:P})=>{j(P?"dark":"light")})},[c]),_.useEffect(()=>{w.length<=1&&b(!1)},[w]),_.useEffect(()=>{let P=q=>{var Y,ae;s.every(A=>q[A]||q.code===A)&&(b(!0),(Y=K.current)==null||Y.focus()),q.code==="Escape"&&(document.activeElement===K.current||(ae=K.current)!=null&&ae.contains(document.activeElement))&&b(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[s]),w.length?_.createElement("section",{"aria-label":`Notifications ${G}`,tabIndex:-1},_.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=m[0])==null?void 0:t.height}px`,"--offset":typeof u=="number"?`${u}px`:u||Qy,"--width":`${Ky}px`,"--gap":`${zp}px`,...h},onMouseEnter:()=>b(!0),onMouseMove:()=>b(!0),onMouseLeave:()=>{E||b(!1)},onPointerDown:()=>{T(!0)},onPointerUp:()=>T(!1)},w.map((P,q)=>_.createElement(Jy,{key:P.id,index:q,toast:P,duration:p,className:x==null?void 0:x.className,descriptionClassName:x==null?void 0:x.descriptionClassName,invert:n,visibleToasts:v,closeButton:o,interacting:E,position:r,style:x==null?void 0:x.style,removeToast:Ce,toasts:w,heights:m,setHeights:f,expandByDefault:i,expanded:g})))):null},Zy={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 ev=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),re=(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,...Zy,width:s,height:s,stroke:r,strokeWidth:o?Number(i)*24/Number(s):i,className:`lucide lucide-${ev(e)}`,...u},[...t.map(([d,p])=>N.createElement(d,p)),...(Array.isArray(l)?l:[l])||[]]));return n.displayName=`${e}`,n},eo=re("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]),Jt=re("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=re("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"}]]),tv=re("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),nv=re("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"}]]),rv=re("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"}]]),jr=re("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"}]]),Fr=re("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),Dr=re("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),Mt=re("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]),sv=re("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"}]]),iv=re("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]),Ap=re("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"}]]),Mp=re("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"}]]),av=re("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"}]]),ir=re("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),rs=re("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"}]]),ov=re("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"}]]),lv=re("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=re("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"}]]),uv=re("PlayCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]),pr=re("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),en=re("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=re("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"}]]),cv=re("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"}]]),Vr=re("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"}]]),dv=re("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"}]]),fv=re("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"}]]),pv=re("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"}]]),ss=re("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"}]]),hv=re("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"}]]),mv=re("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"}]]),gv=re("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"}]]),Hc=re("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"}]]),Pn=re("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Rp=re("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]);function Ip(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=Ip(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function yv(){for(var e,t,n=0,r="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=Ip(e))&&(r&&(r+=" "),r+=t);return r}function vv(){for(var e=0,t,n,r="";e<arguments.length;)(t=arguments[e++])&&(n=_p(t))&&(r&&(r+=" "),r+=n);return r}function _p(e){if(typeof e=="string")return e;for(var t,n="",r=0;r<e.length;r++)e[r]&&(t=_p(e[r]))&&(n&&(n+=" "),n+=t);return n}var lu="-";function xv(e){var t=jv(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(),Lp(u,t)||wv(l)}function o(l,u){var c=n[l]||[];return u&&s[l]?[].concat(c,s[l]):c}return{getClassGroupId:i,getConflictingClassGroupIds:o}}function Lp(e,t){var o;if(e.length===0)return t.classGroupId;var n=e[0],r=t.nextPart.get(n),s=r?Lp(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 qc=/^\[(.+)\]$/;function wv(e){if(qc.test(e)){var t=qc.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}}function jv(e){var t=e.theme,n=e.prefix,r={nextPart:new Map,validators:[]},s=Nv(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:Qc(t,s);i.classGroupId=n;return}if(typeof s=="function"){if(bv(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,Qc(t,l),n,r)})})}function Qc(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 bv(e){return e.isThemeGetter}function Nv(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 kv(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 Fp="!";function Sv(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,p=0;p<o.length;p++){var h=o[p];if(u===0){if(h===r&&(n||o.slice(p,p+s)===t)){l.push(o.slice(c,p)),c=p+s;continue}if(h==="/"){d=p;continue}}h==="["?u++:h==="]"&&u--}var v=l.length===0?o:o.substring(c),x=v.startsWith(Fp),w=x?v.substring(1):v,k=d&&d>c?d-c:void 0;return{modifiers:l,hasImportantModifier:x,baseClassName:w,maybePostfixModifierPosition:k}}}function Cv(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 Ev(e){return{cache:kv(e.cacheSize),splitModifiers:Sv(e),...xv(e)}}var Pv=/\s+/;function Tv(e,t){var n=t.splitModifiers,r=t.getClassGroupId,s=t.getConflictingClassGroupIds,i=new Set;return e.trim().split(Pv).map(function(o){var l=n(o),u=l.modifiers,c=l.hasImportantModifier,d=l.baseClassName,p=l.maybePostfixModifierPosition,h=r(p?d.substring(0,p):d),v=!!p;if(!h){if(!p)return{isTailwindClass:!1,originalClassName:o};if(h=r(d),!h)return{isTailwindClass:!1,originalClassName:o};v=!1}var x=Cv(u).join(":"),w=c?x+Fp:x;return{isTailwindClass:!0,modifierId:w,classGroupId:h,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(p){return i.add(l+p)}),!0)}).reverse().map(function(o){return o.originalClassName}).join(" ")}function Ov(){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],p=t.slice(1),h=p.reduce(function(v,x){return x(v)},d());return r=Ev(h),s=r.cache.get,i=r.cache.set,o=u,u(c)}function u(c){var d=s(c);if(d)return d;var p=Tv(c,r);return i(c,p),p}return function(){return o(vv.apply(null,arguments))}}function he(e){var t=function(r){return r[e]||[]};return t.isThemeGetter=!0,t}var Dp=/^\[(?:([a-z-]+):)?(.+)\]$/i,zv=/^\d+\/\d+$/,Av=new Set(["px","full","screen"]),Mv=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Rv=/\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$/,Iv=/^-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/;function gt(e){return Tn(e)||Av.has(e)||zv.test(e)||al(e)}function al(e){return Un(e,"length",Uv)}function _v(e){return Un(e,"size",$p)}function Lv(e){return Un(e,"position",$p)}function Fv(e){return Un(e,"url",Wv)}function Xs(e){return Un(e,"number",Tn)}function Tn(e){return!Number.isNaN(Number(e))}function Dv(e){return e.endsWith("%")&&Tn(e.slice(0,-1))}function $r(e){return Vc(e)||Un(e,"number",Vc)}function ne(e){return Dp.test(e)}function Ur(){return!0}function Qt(e){return Mv.test(e)}function $v(e){return Un(e,"",Bv)}function Un(e,t,n){var r=Dp.exec(e);return r?r[1]?r[1]===t:n(r[2]):!1}function Uv(e){return Rv.test(e)}function $p(){return!1}function Wv(e){return e.startsWith("url(")}function Vc(e){return Number.isInteger(Number(e))}function Bv(e){return Iv.test(e)}function Hv(){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"),p=he("invert"),h=he("gap"),v=he("gradientColorStops"),x=he("gradientColorStopPositions"),w=he("inset"),k=he("margin"),m=he("opacity"),f=he("padding"),g=he("saturate"),b=he("scale"),E=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",ne,t]},G=function(){return[ne,t]},Ce=function(){return["",gt]},P=function(){return["auto",Tn,ne]},q=function(){return["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"]},Y=function(){return["solid","dashed","dotted","double","none"]},ae=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"]},F=function(){return["","0",ne]},U=function(){return["auto","avoid","all","avoid-page","page","left","right","column"]},ee=function(){return[Tn,Xs]},Q=function(){return[Tn,ne]};return{cacheSize:500,theme:{colors:[Ur],spacing:[gt],blur:["none","",Qt,ne],brightness:ee(),borderColor:[e],borderRadius:["none","","full",Qt,ne],borderSpacing:G(),borderWidth:Ce(),contrast:ee(),grayscale:F(),hueRotate:Q(),invert:F(),gap:G(),gradientColorStops:[e],gradientColorStopPositions:[Dv,al],inset:K(),margin:K(),opacity:ee(),padding:G(),saturate:ee(),scale:ee(),sepia:F(),skew:Q(),space:G(),translate:G()},classGroups:{aspect:[{aspect:["auto","square","video",ne]}],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(q(),[ne])}],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",$r]}],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",ne]}],grow:[{grow:F()}],shrink:[{shrink:F()}],order:[{order:["first","last","none",$r]}],"grid-cols":[{"grid-cols":[Ur]}],"col-start-end":[{col:["auto",{span:["full",$r]},ne]}],"col-start":[{"col-start":P()}],"col-end":[{"col-end":P()}],"grid-rows":[{"grid-rows":[Ur]}],"row-start-end":[{row:["auto",{span:[$r]},ne]}],"row-start":[{"row-start":P()}],"row-end":[{"row-end":P()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ne]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ne]}],gap:[{gap:[h]}],"gap-x":[{"gap-x":[h]}],"gap-y":[{"gap-y":[h]}],"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",ne,t]}],"min-w":[{"min-w":["min","max","fit",ne,gt]}],"max-w":[{"max-w":["0","none","full","min","max","fit","prose",{screen:[Qt]},Qt,ne]}],h:[{h:[ne,t,"auto","min","max","fit"]}],"min-h":[{"min-h":["min","max","fit",ne,gt]}],"max-h":[{"max-h":[ne,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:[Ur]}],"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",ne]}],"line-clamp":[{"line-clamp":["none",Tn,Xs]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",ne,gt]}],"list-image":[{"list-image":["none",ne]}],"list-style-type":[{list:["none","disc","decimal",ne]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[m]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[m]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[].concat(Y(),["wavy"])}],"text-decoration-thickness":[{decoration:["auto","from-font",gt]}],"underline-offset":[{"underline-offset":["auto",ne,gt]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],indent:[{indent:G()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ne]}],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",ne]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[m]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[].concat(q(),[Lv])}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",_v]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Fv]}],"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":[m]}],"border-style":[{border:[].concat(Y(),["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":[m]}],"divide-style":[{divide:Y()}],"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(Y())}],"outline-offset":[{"outline-offset":[ne,gt]}],"outline-w":[{outline:[gt]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:Ce()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[m]}],"ring-offset-w":[{"ring-offset":[gt]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Qt,$v]}],"shadow-color":[{shadow:[Ur]}],opacity:[{opacity:[m]}],"mix-blend":[{"mix-blend":ae()}],"bg-blend":[{"bg-blend":ae()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",Qt,ne]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[p]}],saturate:[{saturate:[g]}],sepia:[{sepia:[E]}],"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":[p]}],"backdrop-opacity":[{"backdrop-opacity":[m]}],"backdrop-saturate":[{"backdrop-saturate":[g]}],"backdrop-sepia":[{"backdrop-sepia":[E]}],"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",ne]}],duration:[{duration:Q()}],ease:[{ease:["linear","in","out","in-out",ne]}],delay:[{delay:Q()}],animate:[{animate:["none","spin","ping","pulse","bounce",ne]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[b]}],"scale-x":[{"scale-x":[b]}],"scale-y":[{"scale-y":[b]}],rotate:[{rotate:[$r,ne]}],"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",ne]}],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",ne]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":G()}],"scroll-mx":[{"scroll-mx":G()}],"scroll-my":[{"scroll-my":G()}],"scroll-ms":[{"scroll-ms":G()}],"scroll-me":[{"scroll-me":G()}],"scroll-mt":[{"scroll-mt":G()}],"scroll-mr":[{"scroll-mr":G()}],"scroll-mb":[{"scroll-mb":G()}],"scroll-ml":[{"scroll-ml":G()}],"scroll-p":[{"scroll-p":G()}],"scroll-px":[{"scroll-px":G()}],"scroll-py":[{"scroll-py":G()}],"scroll-ps":[{"scroll-ps":G()}],"scroll-pe":[{"scroll-pe":G()}],"scroll-pt":[{"scroll-pt":G()}],"scroll-pr":[{"scroll-pr":G()}],"scroll-pb":[{"scroll-pb":G()}],"scroll-pl":[{"scroll-pl":G()}],"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",ne]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[gt,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 qv=Ov(Hv);function Qv(...e){return qv(yv(e))}const Vv=[{name:"Dashboard",href:"/",icon:Mp},{name:"Organizations",href:"/organizations",icon:Vr},{name:"Service Mappings",href:"/service-mappings",icon:rs}];function Kv({children:e}){const t=Os(),[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(ov,{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:Vv.map(s=>{const i=t.pathname===s.href||s.href!=="/"&&t.pathname.startsWith(s.href);return a.jsxs(xp,{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 Gv={}.VITE_API_URL||"/api";function Yv(e){const t=e.startsWith("/")?e.slice(1):e;return`${Gv}/${t}`}async function Zs(e,t){const n=Yv(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 Jv(){var M,K,G,Ce;const[e,t]=N.useState([]),[n,r]=N.useState({queued:0,in_progress:0,completed:0,failed:0}),[s,i]=N.useState(!0),[o,l]=N.useState(null),[u,c]=N.useState("all"),[d,p]=N.useState("all"),[h,v]=N.useState(null);N.useEffect(()=>{const P=async()=>{var Y,ae,A,F,U,ee,Q,X;try{i(!0),l(null);const[ue,Ae,ve,Ge]=await Promise.allSettled([Zs(ei.queueQueued),Zs(ei.queueInProgress),Zs(ei.queueCompleted+"?limit=20"),Zs(ei.queueFailed+"?limit=20")]),kt=[],Be={queued:0,in_progress:0,completed:0,failed:0};if(ue.status==="fulfilled"&&ue.value.ok){const be=await ue.value.json();kt.push(...((Y=be.data)==null?void 0:Y.items)||[]),Be.queued=((ae=be.data)==null?void 0:ae.total)||0}if(Ae.status==="fulfilled"&&Ae.value.ok){const be=await Ae.value.json();kt.push(...((A=be.data)==null?void 0:A.items)||[]),Be.in_progress=((F=be.data)==null?void 0:F.total)||0}if(ve.status==="fulfilled"&&ve.value.ok){const be=await ve.value.json();kt.push(...((U=be.data)==null?void 0:U.items)||[]),Be.completed=((ee=be.data)==null?void 0:ee.total)||0}if(Ge.status==="fulfilled"&&Ge.value.ok){const be=await Ge.value.json();kt.push(...((Q=be.data)==null?void 0:Q.items)||[]),Be.failed=((X=be.data)==null?void 0:X.total)||0}t(kt),r(Be)}catch(ue){l(ue instanceof Error?ue.message:"Failed to fetch work queue data")}finally{i(!1)}};P();const q=setInterval(P,1e4);return()=>clearInterval(q)},[]);const x=N.useMemo(()=>{let P=[...e];return u!=="all"&&(P=P.filter(q=>q.status===u)),d!=="all"&&(P=P.filter(q=>q.type===d)),P.sort((q,Y)=>{const ae={in_progress:0,queued:1,failed:2,completed:3},A=ae[q.status]-ae[Y.status];if(A!==0)return A;const F=Y.priority-q.priority;return F!==0?F:new Date(Y.createdAt).getTime()-new Date(q.createdAt).getTime()}),P},[e,u,d]),w=P=>{const q=Math.floor(P/60),Y=Math.floor(q/60);return Y>0?`${Y}h ${q%60}m`:q>0?`${q}m`:`${P}s`},k=P=>{const q=new Date,Y=new Date(P),ae=q.getTime()-Y.getTime(),A=Math.floor(ae/(1e3*60));if(A<1)return"Just now";if(A<60)return`${A}m ago`;const F=Math.floor(A/60);return F<24?`${F}h ago`:`${Math.floor(F/24)}d ago`},m=P=>{switch(P){case"project_review":return"📋";case"code_review":return"🔍";case"story_implementation":return"⚡";case"development_planning":return"📊";default:return"📄"}},f=P=>P>=9?"text-red-600 bg-red-50":P>=7?"text-orange-600 bg-orange-50":P>=5?"text-yellow-600 bg-yellow-50":"text-green-600 bg-green-50",g=P=>P>=9?"Critical":P>=7?"High":P>=5?"Medium":"Low",b=P=>{switch(P){case"completed":return a.jsx(jr,{className:"w-4 h-4 text-green-600"});case"failed":return a.jsx(Jt,{className:"w-4 h-4 text-red-600"});case"in_progress":return a.jsx(ir,{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"})}},E=P=>{switch(P){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"}},T=P=>{switch(P){case"in_progress":return"In Progress";case"queued":return"Queued";case"completed":return"Completed";case"failed":return"Failed";default:return P}},C=P=>{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:m(P.type)}),a.jsxs("div",{children:[a.jsx("h4",{className:"font-medium text-sm",children:P.title}),a.jsx("p",{className:"text-xs text-gray-600",children:P.projectName})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("span",{className:`px-2 py-1 rounded border text-xs font-medium flex items-center gap-1 ${E(P.status)}`,children:[b(P.status),T(P.status)]}),a.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${f(P.priority)}`,children:g(P.priority)}),P.estimatedDuration&&a.jsxs("span",{className:"text-xs text-gray-500 flex items-center gap-1",children:[a.jsx(Mt,{className:"w-3 h-3"}),w(P.estimatedDuration)]}),P.actualDuration&&P.status==="completed"&&a.jsxs("span",{className:"text-xs text-gray-500 flex items-center gap-1",children:[a.jsx(Mt,{className:"w-3 h-3"}),w(Math.round(P.actualDuration/1e3))," actual"]})]})]}),P.description&&a.jsx("p",{className:"text-xs text-gray-600 mb-2 line-clamp-2",children:P.description}),P.progress&&P.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:P.progress.currentStep}),a.jsxs("span",{children:[P.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:`${P.progress.percentage}%`}})})]}),P.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(Jt,{className:"w-4 h-4 text-red-600"}),a.jsx("span",{className:"text-xs text-red-800 font-medium",children:"Work item failed"}),((q=P.metadata)==null?void 0:q.failedAt)&&a.jsxs("span",{className:"text-xs text-red-600",children:["• Failed: ",k(P.metadata.failedAt)]})]}),a.jsx("button",{onClick:Y=>{Y.stopPropagation(),v(P)},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 ",k(P.createdAt)]}),P.assignedTo&&a.jsx("span",{className:"bg-blue-100 text-blue-800 px-2 py-1 rounded",children:P.assignedTo}),P.completedAt&&P.status==="completed"&&a.jsxs("span",{className:"text-green-600",children:["Completed ",k(P.completedAt)]})]})]},P.id)},j=n.queued+n.in_progress+n.completed+n.failed,R=u!=="all"||d!=="all";return s?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(ir,{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..."})]})}):o?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(Jt,{className:"h-6 w-6 mr-2"}),a.jsx("span",{className:"text-sm",children:o})]})}):a.jsxs("div",{className:"rounded-lg border bg-card",children:[a.jsxs("div",{className:"p-6 border-b",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("h3",{className:"text-lg font-medium",children:"Work Queue Status"}),a.jsxs("span",{className:"text-sm text-gray-500",children:[j," total items"]})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx(iv,{className:"w-4 h-4 text-gray-400"}),a.jsx("span",{className:"text-sm text-gray-600 mr-2",children:"Status:"}),a.jsxs("button",{onClick:()=>c("all"),className:`px-3 py-1.5 rounded-full text-xs font-medium transition-colors ${u==="all"?"bg-gray-900 text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:["All (",j,")"]}),a.jsxs("button",{onClick:()=>c("in_progress"),className:`px-3 py-1.5 rounded-full text-xs font-medium transition-colors flex items-center gap-1 ${u==="in_progress"?"bg-blue-600 text-white":"bg-blue-50 text-blue-600 hover:bg-blue-100"}`,children:[a.jsx(uv,{className:"w-3 h-3"}),"In Progress (",n.in_progress,")"]}),a.jsxs("button",{onClick:()=>c("queued"),className:`px-3 py-1.5 rounded-full text-xs font-medium transition-colors flex items-center gap-1 ${u==="queued"?"bg-yellow-600 text-white":"bg-yellow-50 text-yellow-600 hover:bg-yellow-100"}`,children:[a.jsx(lv,{className:"w-3 h-3"}),"Queued (",n.queued,")"]}),a.jsxs("button",{onClick:()=>c("completed"),className:`px-3 py-1.5 rounded-full text-xs font-medium transition-colors flex items-center gap-1 ${u==="completed"?"bg-green-600 text-white":"bg-green-50 text-green-600 hover:bg-green-100"}`,children:[a.jsx(jr,{className:"w-3 h-3"}),"Completed (",n.completed,")"]}),a.jsxs("button",{onClick:()=>c("failed"),className:`px-3 py-1.5 rounded-full text-xs font-medium transition-colors flex items-center gap-1 ${u==="failed"?"bg-red-600 text-white":"bg-red-50 text-red-600 hover:bg-red-100"}`,children:[a.jsx(Jt,{className:"w-3 h-3"}),"Failed (",n.failed,")"]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx("span",{className:"text-sm text-gray-600 ml-6 mr-2",children:"Type:"}),a.jsx("button",{onClick:()=>p("all"),className:`px-3 py-1.5 rounded-full text-xs font-medium transition-colors ${d==="all"?"bg-gray-900 text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:"All Types"}),a.jsx("button",{onClick:()=>p("story_implementation"),className:`px-3 py-1.5 rounded-full text-xs font-medium transition-colors ${d==="story_implementation"?"bg-purple-600 text-white":"bg-purple-50 text-purple-600 hover:bg-purple-100"}`,children:"⚡ Story"}),a.jsx("button",{onClick:()=>p("project_review"),className:`px-3 py-1.5 rounded-full text-xs font-medium transition-colors ${d==="project_review"?"bg-indigo-600 text-white":"bg-indigo-50 text-indigo-600 hover:bg-indigo-100"}`,children:"📋 Review"}),a.jsx("button",{onClick:()=>p("development_planning"),className:`px-3 py-1.5 rounded-full text-xs font-medium transition-colors ${d==="development_planning"?"bg-cyan-600 text-white":"bg-cyan-50 text-cyan-600 hover:bg-cyan-100"}`,children:"📊 Planning"}),a.jsx("button",{onClick:()=>p("code_review"),className:`px-3 py-1.5 rounded-full text-xs font-medium transition-colors ${d==="code_review"?"bg-teal-600 text-white":"bg-teal-50 text-teal-600 hover:bg-teal-100"}`,children:"🔍 Code Review"})]}),R&&a.jsxs("button",{onClick:()=>{c("all"),p("all")},className:"flex items-center gap-1 text-xs text-gray-500 hover:text-gray-700 transition-colors ml-6",children:[a.jsx(Pn,{className:"w-3 h-3"}),"Clear filters"]})]})]}),a.jsxs("div",{className:"p-6",children:[a.jsx("div",{className:"space-y-3",children:x.length===0?a.jsxs("div",{className:"text-center py-8 text-gray-500",children:[a.jsx(Mt,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:R?"No items match the selected filters":"No items in queue"})]}):x.map(P=>C(P))}),x.length>0&&a.jsxs("div",{className:"mt-4 text-center text-sm text-gray-500",children:["Showing ",x.length," of ",j," items"]})]}),h&&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(Jt,{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:()=>v(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:h.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:h.projectName})]}),a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-gray-600",children:"Created:"}),a.jsxs("span",{className:"ml-2",children:[k(h.createdAt)," ago"]})]}),h.completedAt&&a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-gray-600",children:"Failed:"}),a.jsxs("span",{className:"ml-2",children:[k(h.completedAt)," ago"]})]}),h.assignedTo&&a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-gray-600",children:"Assigned to:"}),a.jsx("span",{className:"ml-2",children:h.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(Jt,{className:"w-4 h-4"}),"Error Message"]}),a.jsx("p",{className:"text-red-800 text-sm",children:((M=h.metadata)==null?void 0:M.reason)||((K=h.metadata)==null?void 0:K.failureReason)||((G=h.metadata)==null?void 0:G.error)||"No specific error message available"})]}),((Ce=h.metadata)==null?void 0:Ce.errorHistory)&&h.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 ",h.metadata.errorHistory.length," attempt",h.metadata.errorHistory.length>1?"s":"",":"]}),a.jsx("div",{className:"space-y-2",children:h.metadata.errorHistory.map((P,q)=>a.jsxs("div",{className:"flex items-center justify-between p-2 bg-gray-50 rounded",children:[a.jsxs("span",{children:["Attempt #",P.attemptNumber||q+1]}),a.jsx("span",{className:"text-xs text-gray-500",children:P.timestamp&&k(P.timestamp)})]},q))})]})]}),h.metadata&&Object.keys(h.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(h.metadata,null,2)})]})]})]}),a.jsx("div",{className:"flex justify-end mt-6",children:a.jsx("button",{onClick:()=>v(null),className:"px-4 py-2 bg-gray-100 text-gray-700 rounded hover:bg-gray-200 transition-colors",children:"Close"})})]})})]})}function Xv(){const[e,t]=N.useState(null),[n,r]=N.useState(!0),[s,i]=N.useState(!1);N.useEffect(()=>{const d=async()=>{try{const h=await fetch("/api/smart-polling/metrics");if(h.ok){const v=await h.json();t(v.data)}}catch(h){console.error("Failed to fetch smart polling metrics:",h)}finally{r(!1)}};d();const p=setInterval(d,1e4);return()=>clearInterval(p)},[]);const o=async()=>{i(!0);try{if((await fetch("/api/smart-polling/force",{method:"POST"})).ok){const p=await fetch("/api/smart-polling/metrics");if(p.ok){const h=await p.json();t(h.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 p=new Date(d),v=new Date().getTime()-p.getTime();return v<6e4?`${Math.round(v/1e3)}s ago`:v<36e5?`${Math.round(v/6e4)}m ago`:p.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(jr,{className:"h-4 w-4 text-green-500"}):a.jsx(dv,{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(Rp,{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(en,{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(jr,{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 Zv(){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(hn,{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(nv,{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(hv,{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(gv,{className:"h-8 w-8 text-orange-600"})]}),a.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Currently active"})]})]}),a.jsx(Xv,{}),a.jsx(Jv,{}),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 ex=({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 p=>{p.preventDefault(),u(null),o(!0);try{const h=await fetch(`/api/organizations/${e}/workspaces`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,services:[]})});if(!h.ok){const x=await h.json();throw new Error(x.error||"Failed to create workspace")}const v=await h.json();if(v.success)t(v.data);else throw new Error(v.error||"Failed to create workspace")}catch(h){console.error("Failed to create workspace:",h),u(h instanceof Error?h.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:p=>s({...r,id:p.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:p=>s({...r,name:p.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:p=>s({...r,description:p.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"})]})]})]})},tx=({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,p]=N.useState(null),[h,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(jr,{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(Hc,{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(en,{className:"w-4 h-4 text-blue-500"});case"remove_service":return a.jsx(Hc,{className:"w-4 h-4 text-red-500"});default:return a.jsx(tv,{className:"w-4 h-4 text-gray-500"})}},m=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=>{p(j.name),v({name:j.name,type:j.type,technology:j.technology,port:j.port,description:j.description})},b=()=>{p(null),v({})},E=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(h)}),R=await j.json();if(j.ok&&R.success)p(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(Pn,{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(en,{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(en,{className:"w-4 h-4 mr-2 animate-spin"}),"Analyzing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(en,{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:h.name||"",onChange:M=>v({...h,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:h.type||"backend",onChange:M=>v({...h,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:h.technology||"",onChange:M=>v({...h,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:h.port||"",onChange:M=>v({...h,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:h.description||"",onChange:M=>v({...h,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:E,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(Pn,{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(ss,{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:()=>m(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(en,{className:`w-4 h-4 mr-2 ${s?"animate-spin":""}`}),"Re-analyze"]})})]})]})]})})};function nx(){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,p]=N.useState(new Set),[h,v]=N.useState(new Set),[x,w]=N.useState(null),[k,m]=N.useState(null),[f,g]=N.useState(null),[b,E]=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:""}),[G,Ce]=N.useState(Date.now()),[P,q]=N.useState(null),[Y,ae]=N.useState(null),[A,F]=N.useState(null),[U,ee]=N.useState({}),[Q,X]=N.useState({}),[ue,Ae]=N.useState({}),[ve,Ge]=N.useState(!1),[kt,Be]=N.useState(null),[be,Er]=N.useState([]),[fe,V]=N.useState(new Set),[ce,Te]=N.useState({}),[ht,St]=N.useState(!1),[Wn,fa]=N.useState(!1),[Up,pa]=N.useState([]),[ha,Wp]=N.useState(new Set),[Bp,ma]=N.useState(null),[ga,zs]=N.useState(""),[uu,cu]=N.useState(!1),[wn,ya]=N.useState({}),[Bn,va]=N.useState(new Set);N.useEffect(()=>{As()},[]);const J=(y,S,I)=>{const D={id:Date.now().toString(),type:y,title:S,message:I,timestamp:Date.now()};c(W=>[...W,D]),y==="success"&&setTimeout(()=>{c(W=>W.filter(Z=>Z.id!==D.id))},5e3)},Hp=y=>{c(S=>S.filter(I=>I.id!==y))},As=async()=>{try{const y=await fetch("/api/organizations");if(y.ok){const S=await y.json();t(S.data),Ce(Date.now())}}catch(y){console.error("Failed to fetch organizations:",y)}finally{r(!1)}},jn=async()=>{await As()},xa=()=>{},wa=()=>{},ja=()=>{},qp=async y=>{try{const S=await fetch(`/api/project-mappings/organization/${y}`);if(S.ok){const I=await S.json();pa(I.mappings||[])}}catch(S){console.error("Failed to fetch project mappings:",S)}},Qp=async(y,S,I)=>{if(!ga.trim()){J("error","Invalid Path","Please enter a valid local path");return}cu(!0);try{const D=await fetch("/api/project-mappings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({organizationId:y,projectId:S,localPath:ga,projectName:I})}),W=await D.json();D.ok&&W.success?(pa(Z=>{const de=Z.findIndex(oe=>oe.projectId===S);if(de>=0){const oe=[...Z];return oe[de]=W.mapping,oe}return[...Z,W.mapping]}),ma(null),zs(""),J("success","Mapping Saved",`Successfully mapped "${I}" to local path`)):J("error","Failed to Save Mapping",W.error||"Unknown error")}catch(D){console.error("Failed to save project mapping:",D),J("error","Network Error","Failed to save project mapping")}finally{cu(!1)}},Vp=async(y,S)=>{try{const I=await fetch(`/api/project-mappings/${y}/${S}`,{method:"DELETE"});if(I.ok)pa(D=>D.filter(W=>W.projectId!==S)),J("success","Mapping Removed","Project path mapping has been removed");else{const D=await I.json();J("error","Failed to Remove Mapping",D.error||"Unknown error")}}catch(I){console.error("Failed to remove project mapping:",I),J("error","Network Error","Failed to remove project mapping")}},Kp=y=>Up.find(S=>S.projectId===y),Gp=async y=>{const S=new Set(d);S.has(y)?S.delete(y):(S.add(y),await qp(y)),p(S)},Yp=async(y,S)=>{y.preventDefault();try{const I=await fetch(`/api/organizations/${S}/workspaces`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),D=await I.json();if(I.ok&&D.success&&D.data){if(e){const W=e.organizations.map(Z=>{if(Z.id===S){const de=Z.workspaces||[];return{...Z,workspaces:[...de,D.data],workspaceCount:(Z.workspaceCount||0)+1}}return Z});t({...e,organizations:W})}w(null),E({name:"",id:"",path:"",description:""}),xa(),J("success","Workspace Added",`Successfully added workspace "${b.name}"`)}else J("error","Failed to Add Workspace",D.message||D.error)}catch(I){console.error("Failed to add workspace:",I),J("error","Network Error","Failed to add workspace. Please try again.")}},Jp=async(y,S,I)=>{console.log("🔄 handleUpdateWorkspace called:",{orgId:y,workspaceId:S,updates:I});try{console.log("📡 Making PATCH request to:",`/api/organizations/${y}/workspaces/${S}`);const D=await fetch(`/api/organizations/${y}/workspaces/${S}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)});console.log("📨 Response status:",D.status,D.statusText);const W=await D.json();D.ok?(await jn(),J("success","Workspace Updated","Workspace settings updated successfully")):J("error","Failed to Update Workspace",W.message||W.error)}catch(D){console.error("Failed to update workspace:",D),J("error","Network Error","Failed to update workspace. Please try again.")}},Xp=y=>{ae(y.id),X({name:y.name,type:y.type,technology:y.technology,port:y.port,url:y.url,description:y.description})},Zp=()=>{ae(null),X({})},eh=async(y,S,I)=>{try{const D=await fetch(`/api/organizations/${y}/workspaces/${S}/services/${I}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(Q)}),W=await D.json();if(D.ok&&W.success)await jn(),ae(null),X({}),J("success","Service Updated","Service details updated successfully");else throw new Error(W.error||"Failed to update service")}catch(D){console.error("Failed to update service:",D),J("error","Update Failed",D instanceof Error?D.message:"Failed to update service")}},th=async(y,S,I,D)=>{if(confirm(`Are you sure you want to remove the service "${D}"? This action cannot be undone.`))try{const W=await fetch(`/api/organizations/${y}/workspaces/${S}/services/${I}`,{method:"DELETE"}),Z=await W.json();if(W.ok&&Z.success)await jn(),J("success","Service Removed",`Service "${D}" has been removed`);else throw new Error(Z.error||"Failed to remove service")}catch(W){console.error("Failed to remove service:",W),J("error","Removal Failed",W instanceof Error?W.message:"Failed to remove service")}},nh=async(y,S,I)=>{y.preventDefault();try{const D={...M,port:M.port?parseInt(M.port):void 0,isActive:!0},W=await fetch(`/api/organizations/${S}/workspaces/${I}/services`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)}),Z=await W.json();if(W.ok&&Z.success){if(e){const de=e.organizations.map(oe=>{var z;if(oe.id===S){const $=(z=oe.workspaces)==null?void 0:z.map(H=>{if(H.id===I){const Fe=H.services||[];return{...H,services:[...Fe,Z.data]}}return H});return{...oe,workspaces:$}}return oe});t({...e,organizations:de})}R(null),K({name:"",type:"backend",port:"",url:"",technology:"",description:""}),xa(),J("success","Service Added",`Successfully added service "${D.name}"`)}else J("error","Failed to Add Service",Z.message||Z.error)}catch(D){console.error("Failed to add service:",D),J("error","Network Error","Failed to add service. Please try again.")}},rh=async(y,S,I,D)=>{try{const W=await fetch(`/api/organizations/${y}/workspaces/${S}/services/${I}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:D})}),Z=await W.json();if(W.ok&&Z.success){if(e){const de=e.organizations.map(oe=>{var z;if(oe.id===y){const $=(z=oe.workspaces)==null?void 0:z.map(H=>{var Fe;if(H.id===S){const Wt=(Fe=H.services)==null?void 0:Fe.map(Bt=>Bt.id===I?{...Bt,isActive:D}:Bt);return{...H,services:Wt}}return H});return{...oe,workspaces:$}}return oe});t({...e,organizations:de})}J("success","Service Updated",`Service ${D?"activated":"deactivated"} successfully`)}else J("error","Failed to Update Service",Z.message||Z.error)}catch(W){console.error("Failed to update service:",W),J("error","Network Error","Failed to update service. Please try again.")}},sh=y=>{F(y.id),Ae({name:y.name,apiUrl:y.apiUrl,apiKey:"",enabled:y.enabled})},ih=()=>{F(null),Ae({})},ah=async y=>{Ge(!0);try{const S=await fetch(`/api/organizations/${y}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(ue)}),I=await S.json();if(S.ok&&I.success)await jn(),F(null),Ae({}),J("success","Organization Updated","Organization details updated successfully");else throw new Error(I.error||"Failed to update organization")}catch(S){console.error("Failed to update organization:",S),J("error","Update Failed",S instanceof Error?S.message:"Failed to update organization")}finally{Ge(!1)}},oh=async y=>{Be(y),St(!0);try{const[S,I]=await Promise.all([fetch(`/api/organizations/${y}/workspaces/available`),fetch(`/api/service-mappings/organization/${y}`)]),D=await S.json();if(S.ok&&D.success){Er(D.workspaces||[]);const W=new Set,Z={};if(D.workspaces.forEach(de=>{de.syncedLocally&&de.isActive!==!1?(W.add(de.id),Z[de.id]=de.localPath||de.path||""):Z[de.id]=de.path||""}),V(W),Te(Z),I.ok){const oe=(await I.json()).mappings||[],z={};oe.forEach($=>{z[`${$.workspaceId}:${$.serviceId}`]=$.localPath}),ya(z)}}else J("error","Failed to Fetch Workspaces",D.error||"Could not fetch available workspaces"),Be(null)}catch(S){console.error("Failed to fetch available workspaces:",S),J("error","Network Error","Failed to fetch available workspaces. Please try again."),Be(null)}finally{St(!1)}},lh=async y=>{fa(!0);try{if(fe.size>0){const oe=await fetch(`/api/organizations/${y}/workspaces/sync`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceIds:Array.from(fe)})}),z=await oe.json();if(!oe.ok){J("error","Failed to Sync Workspaces",z.message||z.error),fa(!1);return}for(const $ of fe){const H=be.find(Wt=>Wt.id===$),Fe=ce[$];H&&Fe&&Fe!==H.path&&await fetch(`/api/organizations/${y}/workspaces/${$}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Fe})})}}const S=new Set(fe),I=be.filter(oe=>oe.syncedLocally&&!S.has(oe.id));for(const oe of I)await fetch(`/api/organizations/${y}/workspaces/${oe.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:!1})});let D=0;for(const[oe,z]of Object.entries(wn))if(z&&z.trim()){const[$,H]=oe.split(":");if(!$||!H)continue;let Fe="",Wt="";const Bt=be.find(Ht=>Ht.id===$);if(Bt!=null&&Bt.services){const Ht=Bt.services.find(dh=>dh.id===H);Ht&&(Fe=Ht.name,Wt=Ht.technology||"")}try{(await fetch("/api/service-mappings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({organizationId:y,workspaceId:$,serviceId:H,localPath:z.trim(),serviceName:Fe,technology:Wt})})).ok&&D++}catch(Ht){console.error("Failed to save service mapping:",Ht)}}await jn();const W=fe.size,Z=I.length;let de="";W>0&&Z>0?de=`Saved ${W} workspace(s) and disabled ${Z} workspace(s)`:W>0?de=`Saved ${W} workspace(s)`:Z>0?de=`Disabled ${Z} workspace(s)`:de="No changes made",D>0&&(de+=`, ${D} service path(s) mapped`),J("success","Workspaces Updated",de),Be(null),va(new Set)}catch(S){console.error("Failed to save workspaces:",S),J("error","Network Error","Failed to save workspaces. Please try again.")}finally{fa(!1)}},uh=async y=>{y.preventDefault();try{const S=o.basePath.endsWith("/")?`${o.basePath}graphql`:`${o.basePath}/graphql`,I={name:o.name,apiUrl:S,apiKey:o.apiKey},D=await fetch("/api/organizations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)}),W=await D.json();D.ok?(await As(),i(!1),l({name:"",basePath:"",apiKey:""}),xa(),J("success","Organization Added",`Successfully added "${o.name}"`)):J("error","Failed to Add Organization",W.message||W.error)}catch(S){console.error("Failed to add organization:",S),J("error","Network Error","Failed to connect to server. Please try again.")}},ch=async y=>{if(confirm("Are you sure you want to delete this organization?"))try{const S=await fetch(`/api/organizations/${y}`,{method:"DELETE"}),I=await S.json();S.ok?(await As(),J("success","Organization Deleted",I.message||"Organization deleted successfully")):J("error","Failed to Delete Organization",I.message||I.error)}catch(S){console.error("Failed to delete organization:",S),J("error","Network Error","Failed to delete organization. Please try again.")}};return a.jsxs(a.Fragment,{children:[a.jsx(hn,{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(G).toLocaleTimeString()]})]}),a.jsxs("button",{onClick:jn,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(en,{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(Jt,{className:"h-4 w-4 text-red-600 mt-0.5 flex-shrink-0"}):a.jsx(jr,{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:()=>Hp(y.id),className:"text-current opacity-60 hover:opacity-100 transition-opacity ml-2",children:a.jsx(Pn,{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(Jt,{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:uh,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(Vr,{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,Z,de,oe;const S=((W=y.workerRegistration)==null?void 0:W.registered)||!1,I=((Z=y.workerRegistration)==null?void 0:Z.lastHeartbeat)||y.createdAt,D=(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:ue.name||"",onChange:z=>Ae({...ue,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:ue.apiUrl||"",onChange:z=>Ae({...ue,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:ue.apiKey||"",onChange:z=>Ae({...ue,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:ue.enabled??y.enabled,onChange:z=>Ae({...ue,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:()=>ah(y.id),disabled:ve,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:[ve&&a.jsx(ir,{className:"h-4 w-4 animate-spin"}),ve?"Saving...":"Save"]}),a.jsx("button",{onClick:ih,disabled:ve,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}),I&&a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[D,": ",new Date(I).toLocaleString()]})]})}),A!==y.id&&a.jsx("div",{className:"flex items-start",children:a.jsx("button",{onClick:()=>sh(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(mv,{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(Rp,{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:()=>Gp(y.id),className:"flex items-center gap-2 hover:text-blue-600 transition-colors",children:[d.has(y.id)?a.jsx(Fr,{className:"h-4 w-4"}):a.jsx(Dr,{className:"h-4 w-4"}),a.jsx(Ap,{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:()=>oh(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(Vr,{className:"h-3 w-3 mr-1"}),"Manage"]})})]}),d.has(y.id)&&a.jsxs("div",{className:"mt-2 space-y-2",children:[h.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:P===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:$=>ee({...U,name:$.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:$=>ee({...U,path:$.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:$=>ee({...U,description:$.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:()=>Jp(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(pv,{className:"h-3 w-3"}):a.jsx(fv,{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 $=`${y.id}-${z.id}`,H=new Set(T);H.has($)?H.delete($):H.add($),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(Fr,{className:"h-3 w-3"}):a.jsx(Dr,{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($=>a.jsx("div",{className:"bg-white p-2 rounded border",children:Y===$.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:Q.name||"",onChange:H=>X({...Q,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:Q.type||"backend",onChange:H=>X({...Q,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:Q.technology||"",onChange:H=>X({...Q,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:Q.port||"",onChange:H=>X({...Q,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:Q.url||"",onChange:H=>X({...Q,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:Q.description||"",onChange:H=>X({...Q,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:()=>eh(y.id,z.id,$.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:Zp,className:"px-2 py-1 text-xs bg-gray-600 text-white rounded hover:bg-gray-700",children:a.jsx(Pn,{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:$.name}),a.jsxs("span",{className:"text-gray-500",children:["(",$.type,")"]}),$.port&&a.jsxs("span",{className:"text-gray-400",children:[":",$.port]}),$.technology&&a.jsx("span",{className:"px-1 py-0.5 bg-blue-100 text-blue-700 rounded text-xs",children:$.technology}),$.description&&a.jsxs("span",{className:"text-gray-400 italic",children:["- ",$.description]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:()=>Xp($),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:()=>th(y.id,z.id,$.id,$.name),className:"p-1 text-gray-500 hover:text-red-600 transition-colors",title:"Remove service",children:a.jsx(ss,{className:"h-3 w-3"})}),a.jsx("button",{onClick:()=>rh(y.id,z.id,$.id,!$.isActive),className:`px-1.5 py-0.5 rounded text-xs ${$.isActive?"bg-green-100 text-green-700":"bg-gray-100 text-gray-600"}`,children:$.isActive?"Active":"Inactive"})]})]})},$.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 $=`proj-${y.id}-${z.id}`,H=new Set(ha);H.has($)?H.delete($):H.add($),Wp(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(Fr,{className:"h-3 w-3"}):a.jsx(Dr,{className:"h-3 w-3"}),a.jsx(rs,{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($=>{const H=Kp($.id),Fe=Bp===$.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(sv,{className:"h-3 w-3 text-gray-400"}),a.jsx("span",{className:"font-medium",children:$.name}),$.stage&&a.jsx("span",{className:"px-1 py-0.5 bg-gray-100 text-gray-600 rounded text-xs",children:$.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&&!Fe&&a.jsx("button",{onClick:()=>Vp(y.id,$.id),className:"p-1 text-gray-500 hover:text-red-600 transition-colors",title:"Remove mapping",children:a.jsx(ss,{className:"h-3 w-3"})}),!Fe&&a.jsx("button",{onClick:()=>{ma($.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&&!Fe&&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})}),Fe&&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:()=>Qp(y.id,$.id,$.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(ir,{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(Pn,{className:"h-3 w-3"})})]})]},$.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&&((oe=y.workspaces)==null?void 0:oe.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=>nh(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=>Yp(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=>E({...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=>E({...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=>E({...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=>E({...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),E({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:()=>ch(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(ss,{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(ex,{organizationId:k,onComplete:y=>{var I;if(e){const D=e.organizations.map(W=>{if(W.id===k){const Z=[...W.workspaces||[],y];return{...W,workspaces:Z,workspaceCount:Z.length}}return W});t({...e,organizations:D})}m(null);const S=((I=y.services)==null?void 0:I.length)||0;J("success","Workspace Created",`Successfully created workspace "${y.name}" with ${S} service(s) using wizard`)},onCancel:()=>{m(null)}})})}),f&&a.jsx(tx,{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})}),I=await S.json();if(S.ok&&I.success)J("success","Changes Applied",`Applied ${y.length} improvement(s) to workspace "${f.workspace.name}"`),await jn();else throw new Error(I.error||"Failed to apply changes")}catch(S){console.error("Failed to apply workspace changes:",S),J("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"]})]})]}),kt&&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:()=>Be(null),className:"text-gray-500 hover:text-gray-700",children:a.jsx(Pn,{className:"h-5 w-5"})})]}),ht?a.jsxs("div",{className:"flex items-center justify-center py-12",children:[a.jsx(ir,{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."}),be.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:[be.filter(y=>y.isActive!==!1).length>0&&a.jsx("div",{className:"space-y-2",children:be.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 I=new Set(fe);S.target.checked?I.add(y.id):I.delete(y.id),V(I)},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=>{Te({...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(Fr,{className:"h-4 w-4"}):a.jsx(Dr,{className:"h-4 w-4"}),a.jsx(Vr,{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 I=`${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})]}),wn[I]&&a.jsx(rs,{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:wn[I]||"",onChange:D=>{ya({...wn,[I]:D.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))}),be.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"}),be.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 I=new Set(fe);S.target.checked?I.add(y.id):I.delete(y.id),V(I)},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=>{Te({...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(Fr,{className:"h-4 w-4"}):a.jsx(Dr,{className:"h-4 w-4"}),a.jsx(Vr,{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 I=`${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})]}),wn[I]&&a.jsx(rs,{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:wn[I]||"",onChange:D=>{ya({...wn,[I]:D.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:()=>Be(null),className:"px-4 py-2 text-gray-600 hover:text-gray-800",disabled:Wn,children:"Cancel"}),a.jsx("button",{onClick:()=>lh(kt),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(ir,{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 rx(){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,p]=N.useState(!1),h=async()=>{r(!0),i(null);try{const m=await fetch("/api/service-mappings");if(!m.ok)throw new Error("Failed to fetch service mappings");const f=await m.json();if(f.success)t(f.mappings);else throw new Error("Failed to fetch mappings")}catch(m){i(m instanceof Error?m.message:"Failed to fetch mappings")}finally{r(!1)}};N.useEffect(()=>{h()},[]);const v=async m=>{m.preventDefault(),p(!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 h(),l(!1),c({organizationId:"",workspaceId:"",serviceId:"",localPath:"",serviceName:"",technology:"",notes:""})}catch(f){i(f instanceof Error?f.message:"Failed to save mapping")}finally{p(!1)}},x=async m=>{if(confirm(`Delete mapping for ${m.serviceName||m.serviceId}?`))try{const f=await fetch(`/api/service-mappings/${encodeURIComponent(m.organizationId)}/${encodeURIComponent(m.workspaceId)}/${encodeURIComponent(m.serviceId)}`,{method:"DELETE"}),g=await f.json();if(!f.ok||!g.success)throw new Error(g.error||"Failed to delete mapping");await h()}catch(f){i(f instanceof Error?f.message:"Failed to delete mapping")}},w=m=>new Date(m).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),k=e.reduce((m,f)=>(m[f.organizationId]||(m[f.organizationId]=[]),m[f.organizationId].push(f),m),{});return a.jsxs(a.Fragment,{children:[a.jsx(hn,{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:h,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(en,{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:m=>c({...u,organizationId:m.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:m=>c({...u,workspaceId:m.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:m=>c({...u,serviceId:m.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:m=>c({...u,localPath:m.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:m=>c({...u,serviceName:m.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:m=>c({...u,technology:m.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:m=>c({...u,notes:m.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(rs,{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(([m,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(rv,{className:"h-5 w-5 text-blue-600"}),a.jsxs("h3",{className:"font-medium",children:["Organization: ",m]}),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(cv,{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(av,{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(Ap,{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(ss,{className:"h-4 w-4"})})]})},`${g.organizationId}:${g.workspaceId}:${g.serviceId}`))})]},m))}),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 sx(){return a.jsxs(a.Fragment,{children:[a.jsx(hn,{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(xp,{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(Mp,{className:"h-4 w-4"}),a.jsx("span",{children:"Go Home"})]})]})})]})}function ix(){return a.jsxs(a.Fragment,{children:[a.jsxs(hn,{children:[a.jsx("title",{children:"AI Agent Service Dashboard"}),a.jsx("meta",{name:"description",content:"Analytics dashboard for AI agent service monitoring"})]}),a.jsx(Kv,{children:a.jsxs(O0,{children:[a.jsx(Qr,{path:"/",element:a.jsx(Zv,{})}),a.jsx(Qr,{path:"/organizations",element:a.jsx(nx,{})}),a.jsx(Qr,{path:"/service-mappings",element:a.jsx(rx,{})}),a.jsx(Qr,{path:"*",element:a.jsx(sx,{})})]})})]})}const ax=new sy({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1,staleTime:1e3*60*5}}});to.createRoot(document.getElementById("root")).render(a.jsx(_.StrictMode,{children:a.jsx(sr,{children:a.jsx(oy,{client:ax,children:a.jsxs(L0,{children:[a.jsx(ix,{}),a.jsx(Xy,{position:"top-right"})]})})})}));
69
- //# sourceMappingURL=index-988d535e.js.map
68
+ `);var Ly=e=>{switch(e){case"success":return $y;case"error":return Uy;default:return null}},Fy=Array(12).fill(0),Dy=({visible:e})=>_.createElement("div",{className:"sonner-loading-wrapper","data-visible":e},_.createElement("div",{className:"sonner-spinner"},Fy.map((t,n)=>_.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),$y=_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},_.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"})),Uy=_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},_.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,Wy=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 Wy,By=(e,t)=>{let n=(t==null?void 0:t.id)||rl++;return Yt.addToast({title:e,...t,id:n}),n},Hy=By;Object.assign(Hy,{success:Yt.success,error:Yt.error,custom:Yt.custom,message:Yt.message,promise:Yt.promise,dismiss:Yt.dismiss});var qy=3,Qy="32px",Vy=4e3,Ky=356,zp=14,Gy=20,Yy=200,Jy=e=>{let{invert:t,toast:n,interacting:r,setHeights:s,visibleToasts:i,heights:o,index:l,toasts:u,expanded:c,removeToast:d,closeButton:p,style:h,className:v="",descriptionClassName:x="",duration:w,position:k,expandByDefault:m}=e,[f,g]=_.useState(!1),[b,E]=_.useState(!1),[T,C]=_.useState(!1),[j,R]=_.useState(!1),[M,K]=_.useState(0),[G,Ce]=_.useState(0),P=_.useRef(null),q=l===0,Y=l+1<=i,ae=n.type,A=n.className||"",F=n.descriptionClassName||"",U=_.useMemo(()=>o.findIndex(V=>V.toastId===n.id)||0,[o,n.id]),ee=_.useMemo(()=>n.duration||w||Vy,[n.duration,w]),Q=_.useRef(0),X=_.useRef(0),ue=_.useRef(ee),Ae=_.useRef(0),ve=_.useRef(null),[Ge,kt]=k.split("-"),Be=_.useMemo(()=>o.reduce((V,ce,Te)=>Te>=U?V:V+ce.height,0),[o,U]),be=n.invert||t,Er=ae==="loading";X.current=_.useMemo(()=>U*zp+Be,[U,Be]),_.useEffect(()=>{g(!0)},[]),_.useLayoutEffect(()=>{if(!f)return;let V=P.current,ce=V.style.height;V.style.height="auto";let Te=V.getBoundingClientRect().height;V.style.height=ce,Ce(Te),s(ht=>ht.find(St=>St.toastId===n.id)?ht.map(St=>St.toastId===n.id?{...St,height:Te}:St):[{toastId:n.id,height:Te},...ht])},[f,n.title,n.description,s,n.id]);let fe=_.useCallback(()=>{E(!0),K(X.current),s(V=>V.filter(ce=>ce.toastId!==n.id)),setTimeout(()=>{d(n)},Yy)},[n,d,s,X]);return _.useEffect(()=>{if(n.promise&&ae==="loading"||n.duration===1/0)return;let V;return c||r?(()=>{if(Ae.current<Q.current){let ce=new Date().getTime()-Q.current;ue.current=ue.current-ce}Ae.current=new Date().getTime()})():(Q.current=new Date().getTime(),V=setTimeout(()=>{var ce;(ce=n.onAutoClose)==null||ce.call(n,n),fe()},ue.current)),()=>clearTimeout(V)},[c,r,m,n,ee,fe,n.promise,ae]),_.useEffect(()=>{let V=P.current;if(V){let ce=V.getBoundingClientRect().height;return Ce(ce),s(Te=>[{toastId:n.id,height:ce},...Te]),()=>s(Te=>Te.filter(ht=>ht.toastId!==n.id))}},[s,n.id]),_.useEffect(()=>{n.delete&&fe()},[fe,n.delete]),_.createElement("li",{"aria-live":n.important?"assertive":"polite","aria-atomic":"true",role:"status",tabIndex:0,ref:P,className:v+" "+A,"data-sonner-toast":"","data-styled":!n.jsx,"data-mounted":f,"data-promise":!!n.promise,"data-removed":b,"data-visible":Y,"data-y-position":Ge,"data-x-position":kt,"data-index":l,"data-front":q,"data-swiping":T,"data-type":ae,"data-invert":be,"data-swipe-out":j,"data-expanded":!!(c||m&&f),style:{"--index":l,"--toasts-before":l,"--z-index":u.length-l,"--offset":`${b?M:X.current}px`,"--initial-height":m?"auto":`${G}px`,...h,...n.style},onPointerDown:V=>{Er||(K(X.current),V.target.setPointerCapture(V.pointerId),V.target.tagName!=="BUTTON"&&(C(!0),ve.current={x:V.clientX,y:V.clientY}))},onPointerUp:()=>{var V,ce,Te;if(j)return;ve.current=null;let ht=Number(((V=P.current)==null?void 0:V.style.getPropertyValue("--swipe-amount").replace("px",""))||0);if(Math.abs(ht)>=Gy){K(X.current),(ce=n.onDismiss)==null||ce.call(n,n),fe(),R(!0);return}(Te=P.current)==null||Te.style.setProperty("--swipe-amount","0px"),C(!1)},onPointerMove:V=>{var ce;if(!ve.current)return;let Te=V.clientY-ve.current.y,ht=V.clientX-ve.current.x,St=(Ge==="top"?Math.min:Math.max)(0,Te),Wn=V.pointerType==="touch"?10:2;Math.abs(St)>Wn?(ce=P.current)==null||ce.style.setProperty("--swipe-amount",`${Te}px`):Math.abs(ht)>Wn&&(ve.current=null)}},p&&!n.jsx?_.createElement("button",{"aria-label":"Close toast","data-disabled":Er,"data-close-button":!0,onClick:Er?void 0:()=>{var V;fe(),(V=n.onDismiss)==null||V.call(n,n)}},_.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"},_.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),_.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}))):null,n.jsx||_.isValidElement(n.title)?n.jsx||n.title:_.createElement(_.Fragment,null,ae||n.icon||n.promise?_.createElement("div",{"data-icon":""},n.promise?_.createElement(Dy,{visible:ae==="loading"}):null,n.icon||Ly(ae)):null,_.createElement("div",{"data-content":""},_.createElement("div",{"data-title":""},n.title),n.description?_.createElement("div",{"data-description":"",className:x+F},n.description):null),n.cancel?_.createElement("button",{"data-button":!0,"data-cancel":!0,onClick:()=>{var V;fe(),(V=n.cancel)!=null&&V.onClick&&n.cancel.onClick()}},n.cancel.label):null,n.action?_.createElement("button",{"data-button":"",onClick:V=>{var ce;(ce=n.action)==null||ce.onClick(V),!V.defaultPrevented&&fe()}},n.action.label):null))},Xy=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:p,style:h,visibleToasts:v=qy,toastOptions:x}=e,[w,k]=_.useState([]),[m,f]=_.useState([]),[g,b]=_.useState(!1),[E,T]=_.useState(!1),[C,j]=_.useState(c!=="system"?c:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),[R,M]=r.split("-"),K=_.useRef(null),G=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),Ce=_.useCallback(P=>k(q=>q.filter(({id:Y})=>Y!==P.id)),[]);return _.useEffect(()=>Yt.subscribe(P=>{if(P.dismiss){k(q=>q.map(Y=>Y.id===P.id?{...Y,delete:!0}:Y));return}setTimeout(()=>{Dg.flushSync(()=>{k(q=>{let Y=q.findIndex(ae=>ae.id===P.id);return Y!==-1?[...q.slice(0,Y),{...q[Y],...P},...q.slice(Y+1)]:[P,...q]})})})}),[]),_.useEffect(()=>{if(c!=="system"){j(c);return}typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",({matches:P})=>{j(P?"dark":"light")})},[c]),_.useEffect(()=>{w.length<=1&&b(!1)},[w]),_.useEffect(()=>{let P=q=>{var Y,ae;s.every(A=>q[A]||q.code===A)&&(b(!0),(Y=K.current)==null||Y.focus()),q.code==="Escape"&&(document.activeElement===K.current||(ae=K.current)!=null&&ae.contains(document.activeElement))&&b(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[s]),w.length?_.createElement("section",{"aria-label":`Notifications ${G}`,tabIndex:-1},_.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=m[0])==null?void 0:t.height}px`,"--offset":typeof u=="number"?`${u}px`:u||Qy,"--width":`${Ky}px`,"--gap":`${zp}px`,...h},onMouseEnter:()=>b(!0),onMouseMove:()=>b(!0),onMouseLeave:()=>{E||b(!1)},onPointerDown:()=>{T(!0)},onPointerUp:()=>T(!1)},w.map((P,q)=>_.createElement(Jy,{key:P.id,index:q,toast:P,duration:p,className:x==null?void 0:x.className,descriptionClassName:x==null?void 0:x.descriptionClassName,invert:n,visibleToasts:v,closeButton:o,interacting:E,position:r,style:x==null?void 0:x.style,removeToast:Ce,toasts:w,heights:m,setHeights:f,expandByDefault:i,expanded:g})))):null},Zy={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 ev=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),re=(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,...Zy,width:s,height:s,stroke:r,strokeWidth:o?Number(i)*24/Number(s):i,className:`lucide lucide-${ev(e)}`,...u},[...t.map(([d,p])=>N.createElement(d,p)),...(Array.isArray(l)?l:[l])||[]]));return n.displayName=`${e}`,n},eo=re("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]),Jt=re("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=re("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"}]]),tv=re("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),nv=re("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"}]]),rv=re("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"}]]),jr=re("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"}]]),Fr=re("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),Dr=re("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),Mt=re("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]),sv=re("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"}]]),iv=re("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]),Ap=re("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"}]]),Mp=re("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"}]]),av=re("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"}]]),ir=re("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),rs=re("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"}]]),ov=re("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"}]]),lv=re("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=re("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"}]]),uv=re("PlayCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]),pr=re("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),en=re("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=re("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"}]]),cv=re("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"}]]),Vr=re("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"}]]),dv=re("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"}]]),fv=re("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"}]]),pv=re("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"}]]),ss=re("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"}]]),hv=re("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"}]]),mv=re("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"}]]),gv=re("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"}]]),Hc=re("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"}]]),Pn=re("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Rp=re("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]);function Ip(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=Ip(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function yv(){for(var e,t,n=0,r="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=Ip(e))&&(r&&(r+=" "),r+=t);return r}function vv(){for(var e=0,t,n,r="";e<arguments.length;)(t=arguments[e++])&&(n=_p(t))&&(r&&(r+=" "),r+=n);return r}function _p(e){if(typeof e=="string")return e;for(var t,n="",r=0;r<e.length;r++)e[r]&&(t=_p(e[r]))&&(n&&(n+=" "),n+=t);return n}var lu="-";function xv(e){var t=jv(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(),Lp(u,t)||wv(l)}function o(l,u){var c=n[l]||[];return u&&s[l]?[].concat(c,s[l]):c}return{getClassGroupId:i,getConflictingClassGroupIds:o}}function Lp(e,t){var o;if(e.length===0)return t.classGroupId;var n=e[0],r=t.nextPart.get(n),s=r?Lp(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 qc=/^\[(.+)\]$/;function wv(e){if(qc.test(e)){var t=qc.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}}function jv(e){var t=e.theme,n=e.prefix,r={nextPart:new Map,validators:[]},s=Nv(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:Qc(t,s);i.classGroupId=n;return}if(typeof s=="function"){if(bv(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,Qc(t,l),n,r)})})}function Qc(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 bv(e){return e.isThemeGetter}function Nv(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 kv(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 Fp="!";function Sv(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,p=0;p<o.length;p++){var h=o[p];if(u===0){if(h===r&&(n||o.slice(p,p+s)===t)){l.push(o.slice(c,p)),c=p+s;continue}if(h==="/"){d=p;continue}}h==="["?u++:h==="]"&&u--}var v=l.length===0?o:o.substring(c),x=v.startsWith(Fp),w=x?v.substring(1):v,k=d&&d>c?d-c:void 0;return{modifiers:l,hasImportantModifier:x,baseClassName:w,maybePostfixModifierPosition:k}}}function Cv(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 Ev(e){return{cache:kv(e.cacheSize),splitModifiers:Sv(e),...xv(e)}}var Pv=/\s+/;function Tv(e,t){var n=t.splitModifiers,r=t.getClassGroupId,s=t.getConflictingClassGroupIds,i=new Set;return e.trim().split(Pv).map(function(o){var l=n(o),u=l.modifiers,c=l.hasImportantModifier,d=l.baseClassName,p=l.maybePostfixModifierPosition,h=r(p?d.substring(0,p):d),v=!!p;if(!h){if(!p)return{isTailwindClass:!1,originalClassName:o};if(h=r(d),!h)return{isTailwindClass:!1,originalClassName:o};v=!1}var x=Cv(u).join(":"),w=c?x+Fp:x;return{isTailwindClass:!0,modifierId:w,classGroupId:h,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(p){return i.add(l+p)}),!0)}).reverse().map(function(o){return o.originalClassName}).join(" ")}function Ov(){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],p=t.slice(1),h=p.reduce(function(v,x){return x(v)},d());return r=Ev(h),s=r.cache.get,i=r.cache.set,o=u,u(c)}function u(c){var d=s(c);if(d)return d;var p=Tv(c,r);return i(c,p),p}return function(){return o(vv.apply(null,arguments))}}function he(e){var t=function(r){return r[e]||[]};return t.isThemeGetter=!0,t}var Dp=/^\[(?:([a-z-]+):)?(.+)\]$/i,zv=/^\d+\/\d+$/,Av=new Set(["px","full","screen"]),Mv=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Rv=/\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$/,Iv=/^-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/;function gt(e){return Tn(e)||Av.has(e)||zv.test(e)||al(e)}function al(e){return Un(e,"length",Uv)}function _v(e){return Un(e,"size",$p)}function Lv(e){return Un(e,"position",$p)}function Fv(e){return Un(e,"url",Wv)}function Xs(e){return Un(e,"number",Tn)}function Tn(e){return!Number.isNaN(Number(e))}function Dv(e){return e.endsWith("%")&&Tn(e.slice(0,-1))}function $r(e){return Vc(e)||Un(e,"number",Vc)}function ne(e){return Dp.test(e)}function Ur(){return!0}function Qt(e){return Mv.test(e)}function $v(e){return Un(e,"",Bv)}function Un(e,t,n){var r=Dp.exec(e);return r?r[1]?r[1]===t:n(r[2]):!1}function Uv(e){return Rv.test(e)}function $p(){return!1}function Wv(e){return e.startsWith("url(")}function Vc(e){return Number.isInteger(Number(e))}function Bv(e){return Iv.test(e)}function Hv(){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"),p=he("invert"),h=he("gap"),v=he("gradientColorStops"),x=he("gradientColorStopPositions"),w=he("inset"),k=he("margin"),m=he("opacity"),f=he("padding"),g=he("saturate"),b=he("scale"),E=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",ne,t]},G=function(){return[ne,t]},Ce=function(){return["",gt]},P=function(){return["auto",Tn,ne]},q=function(){return["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"]},Y=function(){return["solid","dashed","dotted","double","none"]},ae=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"]},F=function(){return["","0",ne]},U=function(){return["auto","avoid","all","avoid-page","page","left","right","column"]},ee=function(){return[Tn,Xs]},Q=function(){return[Tn,ne]};return{cacheSize:500,theme:{colors:[Ur],spacing:[gt],blur:["none","",Qt,ne],brightness:ee(),borderColor:[e],borderRadius:["none","","full",Qt,ne],borderSpacing:G(),borderWidth:Ce(),contrast:ee(),grayscale:F(),hueRotate:Q(),invert:F(),gap:G(),gradientColorStops:[e],gradientColorStopPositions:[Dv,al],inset:K(),margin:K(),opacity:ee(),padding:G(),saturate:ee(),scale:ee(),sepia:F(),skew:Q(),space:G(),translate:G()},classGroups:{aspect:[{aspect:["auto","square","video",ne]}],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(q(),[ne])}],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",$r]}],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",ne]}],grow:[{grow:F()}],shrink:[{shrink:F()}],order:[{order:["first","last","none",$r]}],"grid-cols":[{"grid-cols":[Ur]}],"col-start-end":[{col:["auto",{span:["full",$r]},ne]}],"col-start":[{"col-start":P()}],"col-end":[{"col-end":P()}],"grid-rows":[{"grid-rows":[Ur]}],"row-start-end":[{row:["auto",{span:[$r]},ne]}],"row-start":[{"row-start":P()}],"row-end":[{"row-end":P()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ne]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ne]}],gap:[{gap:[h]}],"gap-x":[{"gap-x":[h]}],"gap-y":[{"gap-y":[h]}],"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",ne,t]}],"min-w":[{"min-w":["min","max","fit",ne,gt]}],"max-w":[{"max-w":["0","none","full","min","max","fit","prose",{screen:[Qt]},Qt,ne]}],h:[{h:[ne,t,"auto","min","max","fit"]}],"min-h":[{"min-h":["min","max","fit",ne,gt]}],"max-h":[{"max-h":[ne,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:[Ur]}],"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",ne]}],"line-clamp":[{"line-clamp":["none",Tn,Xs]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",ne,gt]}],"list-image":[{"list-image":["none",ne]}],"list-style-type":[{list:["none","disc","decimal",ne]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[m]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[m]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[].concat(Y(),["wavy"])}],"text-decoration-thickness":[{decoration:["auto","from-font",gt]}],"underline-offset":[{"underline-offset":["auto",ne,gt]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],indent:[{indent:G()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ne]}],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",ne]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[m]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[].concat(q(),[Lv])}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",_v]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Fv]}],"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":[m]}],"border-style":[{border:[].concat(Y(),["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":[m]}],"divide-style":[{divide:Y()}],"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(Y())}],"outline-offset":[{"outline-offset":[ne,gt]}],"outline-w":[{outline:[gt]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:Ce()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[m]}],"ring-offset-w":[{"ring-offset":[gt]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Qt,$v]}],"shadow-color":[{shadow:[Ur]}],opacity:[{opacity:[m]}],"mix-blend":[{"mix-blend":ae()}],"bg-blend":[{"bg-blend":ae()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",Qt,ne]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[p]}],saturate:[{saturate:[g]}],sepia:[{sepia:[E]}],"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":[p]}],"backdrop-opacity":[{"backdrop-opacity":[m]}],"backdrop-saturate":[{"backdrop-saturate":[g]}],"backdrop-sepia":[{"backdrop-sepia":[E]}],"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",ne]}],duration:[{duration:Q()}],ease:[{ease:["linear","in","out","in-out",ne]}],delay:[{delay:Q()}],animate:[{animate:["none","spin","ping","pulse","bounce",ne]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[b]}],"scale-x":[{"scale-x":[b]}],"scale-y":[{"scale-y":[b]}],rotate:[{rotate:[$r,ne]}],"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",ne]}],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",ne]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":G()}],"scroll-mx":[{"scroll-mx":G()}],"scroll-my":[{"scroll-my":G()}],"scroll-ms":[{"scroll-ms":G()}],"scroll-me":[{"scroll-me":G()}],"scroll-mt":[{"scroll-mt":G()}],"scroll-mr":[{"scroll-mr":G()}],"scroll-mb":[{"scroll-mb":G()}],"scroll-ml":[{"scroll-ml":G()}],"scroll-p":[{"scroll-p":G()}],"scroll-px":[{"scroll-px":G()}],"scroll-py":[{"scroll-py":G()}],"scroll-ps":[{"scroll-ps":G()}],"scroll-pe":[{"scroll-pe":G()}],"scroll-pt":[{"scroll-pt":G()}],"scroll-pr":[{"scroll-pr":G()}],"scroll-pb":[{"scroll-pb":G()}],"scroll-pl":[{"scroll-pl":G()}],"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",ne]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[gt,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 qv=Ov(Hv);function Qv(...e){return qv(yv(e))}const Vv=[{name:"Dashboard",href:"/",icon:Mp},{name:"Organizations",href:"/organizations",icon:Vr},{name:"Service Mappings",href:"/service-mappings",icon:rs}];function Kv({children:e}){const t=Os(),[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(ov,{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:Vv.map(s=>{const i=t.pathname===s.href||s.href!=="/"&&t.pathname.startsWith(s.href);return a.jsxs(xp,{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 Gv={}.VITE_API_URL||"/api";function Yv(e){const t=e.startsWith("/")?e.slice(1):e;return`${Gv}/${t}`}async function Zs(e,t){const n=Yv(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 Jv(){var M,K,G,Ce;const[e,t]=N.useState([]),[n,r]=N.useState({queued:0,in_progress:0,completed:0,failed:0}),[s,i]=N.useState(!0),[o,l]=N.useState(null),[u,c]=N.useState("all"),[d,p]=N.useState("all"),[h,v]=N.useState(null);N.useEffect(()=>{const P=async()=>{var Y,ae,A,F,U,ee,Q,X;try{i(!0),l(null);const[ue,Ae,ve,Ge]=await Promise.allSettled([Zs(ei.queueQueued),Zs(ei.queueInProgress),Zs(ei.queueCompleted+"?limit=20"),Zs(ei.queueFailed+"?limit=20")]),kt=[],Be={queued:0,in_progress:0,completed:0,failed:0};if(ue.status==="fulfilled"&&ue.value.ok){const be=await ue.value.json();kt.push(...((Y=be.data)==null?void 0:Y.items)||[]),Be.queued=((ae=be.data)==null?void 0:ae.total)||0}if(Ae.status==="fulfilled"&&Ae.value.ok){const be=await Ae.value.json();kt.push(...((A=be.data)==null?void 0:A.items)||[]),Be.in_progress=((F=be.data)==null?void 0:F.total)||0}if(ve.status==="fulfilled"&&ve.value.ok){const be=await ve.value.json();kt.push(...((U=be.data)==null?void 0:U.items)||[]),Be.completed=((ee=be.data)==null?void 0:ee.total)||0}if(Ge.status==="fulfilled"&&Ge.value.ok){const be=await Ge.value.json();kt.push(...((Q=be.data)==null?void 0:Q.items)||[]),Be.failed=((X=be.data)==null?void 0:X.total)||0}t(kt),r(Be)}catch(ue){l(ue instanceof Error?ue.message:"Failed to fetch work queue data")}finally{i(!1)}};P();const q=setInterval(P,1e4);return()=>clearInterval(q)},[]);const x=N.useMemo(()=>{let P=[...e];return u!=="all"&&(P=P.filter(q=>q.status===u)),d!=="all"&&(P=P.filter(q=>q.type===d)),P.sort((q,Y)=>{const ae={in_progress:0,queued:1,failed:2,completed:3},A=ae[q.status]-ae[Y.status];if(A!==0)return A;const F=Y.priority-q.priority;return F!==0?F:new Date(Y.createdAt).getTime()-new Date(q.createdAt).getTime()}),P},[e,u,d]),w=P=>{const q=Math.floor(P/60),Y=Math.floor(q/60);return Y>0?`${Y}h ${q%60}m`:q>0?`${q}m`:`${P}s`},k=P=>{const q=new Date,Y=new Date(P),ae=q.getTime()-Y.getTime(),A=Math.floor(ae/(1e3*60));if(A<1)return"Just now";if(A<60)return`${A}m ago`;const F=Math.floor(A/60);return F<24?`${F}h ago`:`${Math.floor(F/24)}d ago`},m=P=>{switch(P){case"project_review":return"📋";case"code_review":return"🔍";case"story_implementation":return"⚡";case"development_planning":return"📊";default:return"📄"}},f=P=>P>=9?"text-red-600 bg-red-50":P>=7?"text-orange-600 bg-orange-50":P>=5?"text-yellow-600 bg-yellow-50":"text-green-600 bg-green-50",g=P=>P>=9?"Critical":P>=7?"High":P>=5?"Medium":"Low",b=P=>{switch(P){case"completed":return a.jsx(jr,{className:"w-4 h-4 text-green-600"});case"failed":return a.jsx(Jt,{className:"w-4 h-4 text-red-600"});case"in_progress":return a.jsx(ir,{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"})}},E=P=>{switch(P){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"}},T=P=>{switch(P){case"in_progress":return"In Progress";case"queued":return"Queued";case"completed":return"Completed";case"failed":return"Failed";default:return P}},C=P=>{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:m(P.type)}),a.jsxs("div",{children:[a.jsx("h4",{className:"font-medium text-sm",children:P.title}),a.jsx("p",{className:"text-xs text-gray-600",children:P.projectName})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("span",{className:`px-2 py-1 rounded border text-xs font-medium flex items-center gap-1 ${E(P.status)}`,children:[b(P.status),T(P.status)]}),a.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${f(P.priority)}`,children:g(P.priority)}),P.estimatedDuration&&a.jsxs("span",{className:"text-xs text-gray-500 flex items-center gap-1",children:[a.jsx(Mt,{className:"w-3 h-3"}),w(Math.round(P.estimatedDuration/1e3))]}),P.actualDuration&&P.status==="completed"&&a.jsxs("span",{className:"text-xs text-gray-500 flex items-center gap-1",children:[a.jsx(Mt,{className:"w-3 h-3"}),w(Math.round(P.actualDuration/1e3))," actual"]})]})]}),P.description&&a.jsx("p",{className:"text-xs text-gray-600 mb-2 line-clamp-2",children:P.description}),P.progress&&P.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:P.progress.currentStep}),a.jsxs("span",{children:[P.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:`${P.progress.percentage}%`}})})]}),P.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(Jt,{className:"w-4 h-4 text-red-600"}),a.jsx("span",{className:"text-xs text-red-800 font-medium",children:"Work item failed"}),((q=P.metadata)==null?void 0:q.failedAt)&&a.jsxs("span",{className:"text-xs text-red-600",children:["• Failed: ",k(P.metadata.failedAt)]})]}),a.jsx("button",{onClick:Y=>{Y.stopPropagation(),v(P)},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 ",k(P.createdAt)]}),P.assignedTo&&a.jsx("span",{className:"bg-blue-100 text-blue-800 px-2 py-1 rounded",children:P.assignedTo}),P.completedAt&&P.status==="completed"&&a.jsxs("span",{className:"text-green-600",children:["Completed ",k(P.completedAt)]})]})]},P.id)},j=n.queued+n.in_progress+n.completed+n.failed,R=u!=="all"||d!=="all";return s?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(ir,{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..."})]})}):o?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(Jt,{className:"h-6 w-6 mr-2"}),a.jsx("span",{className:"text-sm",children:o})]})}):a.jsxs("div",{className:"rounded-lg border bg-card",children:[a.jsxs("div",{className:"p-6 border-b",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("h3",{className:"text-lg font-medium",children:"Work Queue Status"}),a.jsxs("span",{className:"text-sm text-gray-500",children:[j," total items"]})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx(iv,{className:"w-4 h-4 text-gray-400"}),a.jsx("span",{className:"text-sm text-gray-600 mr-2",children:"Status:"}),a.jsxs("button",{onClick:()=>c("all"),className:`px-3 py-1.5 rounded-full text-xs font-medium transition-colors ${u==="all"?"bg-gray-900 text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:["All (",j,")"]}),a.jsxs("button",{onClick:()=>c("in_progress"),className:`px-3 py-1.5 rounded-full text-xs font-medium transition-colors flex items-center gap-1 ${u==="in_progress"?"bg-blue-600 text-white":"bg-blue-50 text-blue-600 hover:bg-blue-100"}`,children:[a.jsx(uv,{className:"w-3 h-3"}),"In Progress (",n.in_progress,")"]}),a.jsxs("button",{onClick:()=>c("queued"),className:`px-3 py-1.5 rounded-full text-xs font-medium transition-colors flex items-center gap-1 ${u==="queued"?"bg-yellow-600 text-white":"bg-yellow-50 text-yellow-600 hover:bg-yellow-100"}`,children:[a.jsx(lv,{className:"w-3 h-3"}),"Queued (",n.queued,")"]}),a.jsxs("button",{onClick:()=>c("completed"),className:`px-3 py-1.5 rounded-full text-xs font-medium transition-colors flex items-center gap-1 ${u==="completed"?"bg-green-600 text-white":"bg-green-50 text-green-600 hover:bg-green-100"}`,children:[a.jsx(jr,{className:"w-3 h-3"}),"Completed (",n.completed,")"]}),a.jsxs("button",{onClick:()=>c("failed"),className:`px-3 py-1.5 rounded-full text-xs font-medium transition-colors flex items-center gap-1 ${u==="failed"?"bg-red-600 text-white":"bg-red-50 text-red-600 hover:bg-red-100"}`,children:[a.jsx(Jt,{className:"w-3 h-3"}),"Failed (",n.failed,")"]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx("span",{className:"text-sm text-gray-600 ml-6 mr-2",children:"Type:"}),a.jsx("button",{onClick:()=>p("all"),className:`px-3 py-1.5 rounded-full text-xs font-medium transition-colors ${d==="all"?"bg-gray-900 text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:"All Types"}),a.jsx("button",{onClick:()=>p("story_implementation"),className:`px-3 py-1.5 rounded-full text-xs font-medium transition-colors ${d==="story_implementation"?"bg-purple-600 text-white":"bg-purple-50 text-purple-600 hover:bg-purple-100"}`,children:"⚡ Story"}),a.jsx("button",{onClick:()=>p("project_review"),className:`px-3 py-1.5 rounded-full text-xs font-medium transition-colors ${d==="project_review"?"bg-indigo-600 text-white":"bg-indigo-50 text-indigo-600 hover:bg-indigo-100"}`,children:"📋 Review"}),a.jsx("button",{onClick:()=>p("development_planning"),className:`px-3 py-1.5 rounded-full text-xs font-medium transition-colors ${d==="development_planning"?"bg-cyan-600 text-white":"bg-cyan-50 text-cyan-600 hover:bg-cyan-100"}`,children:"📊 Planning"}),a.jsx("button",{onClick:()=>p("code_review"),className:`px-3 py-1.5 rounded-full text-xs font-medium transition-colors ${d==="code_review"?"bg-teal-600 text-white":"bg-teal-50 text-teal-600 hover:bg-teal-100"}`,children:"🔍 Code Review"})]}),R&&a.jsxs("button",{onClick:()=>{c("all"),p("all")},className:"flex items-center gap-1 text-xs text-gray-500 hover:text-gray-700 transition-colors ml-6",children:[a.jsx(Pn,{className:"w-3 h-3"}),"Clear filters"]})]})]}),a.jsxs("div",{className:"p-6",children:[a.jsx("div",{className:"space-y-3",children:x.length===0?a.jsxs("div",{className:"text-center py-8 text-gray-500",children:[a.jsx(Mt,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:R?"No items match the selected filters":"No items in queue"})]}):x.map(P=>C(P))}),x.length>0&&a.jsxs("div",{className:"mt-4 text-center text-sm text-gray-500",children:["Showing ",x.length," of ",j," items"]})]}),h&&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(Jt,{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:()=>v(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:h.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:h.projectName})]}),a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-gray-600",children:"Created:"}),a.jsxs("span",{className:"ml-2",children:[k(h.createdAt)," ago"]})]}),h.completedAt&&a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-gray-600",children:"Failed:"}),a.jsxs("span",{className:"ml-2",children:[k(h.completedAt)," ago"]})]}),h.assignedTo&&a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-gray-600",children:"Assigned to:"}),a.jsx("span",{className:"ml-2",children:h.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(Jt,{className:"w-4 h-4"}),"Error Message"]}),a.jsx("p",{className:"text-red-800 text-sm",children:((M=h.metadata)==null?void 0:M.reason)||((K=h.metadata)==null?void 0:K.failureReason)||((G=h.metadata)==null?void 0:G.error)||"No specific error message available"})]}),((Ce=h.metadata)==null?void 0:Ce.errorHistory)&&h.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 ",h.metadata.errorHistory.length," attempt",h.metadata.errorHistory.length>1?"s":"",":"]}),a.jsx("div",{className:"space-y-2",children:h.metadata.errorHistory.map((P,q)=>a.jsxs("div",{className:"flex items-center justify-between p-2 bg-gray-50 rounded",children:[a.jsxs("span",{children:["Attempt #",P.attemptNumber||q+1]}),a.jsx("span",{className:"text-xs text-gray-500",children:P.timestamp&&k(P.timestamp)})]},q))})]})]}),h.metadata&&Object.keys(h.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(h.metadata,null,2)})]})]})]}),a.jsx("div",{className:"flex justify-end mt-6",children:a.jsx("button",{onClick:()=>v(null),className:"px-4 py-2 bg-gray-100 text-gray-700 rounded hover:bg-gray-200 transition-colors",children:"Close"})})]})})]})}function Xv(){const[e,t]=N.useState(null),[n,r]=N.useState(!0),[s,i]=N.useState(!1);N.useEffect(()=>{const d=async()=>{try{const h=await fetch("/api/smart-polling/metrics");if(h.ok){const v=await h.json();t(v.data)}}catch(h){console.error("Failed to fetch smart polling metrics:",h)}finally{r(!1)}};d();const p=setInterval(d,1e4);return()=>clearInterval(p)},[]);const o=async()=>{i(!0);try{if((await fetch("/api/smart-polling/force",{method:"POST"})).ok){const p=await fetch("/api/smart-polling/metrics");if(p.ok){const h=await p.json();t(h.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 p=new Date(d),v=new Date().getTime()-p.getTime();return v<6e4?`${Math.round(v/1e3)}s ago`:v<36e5?`${Math.round(v/6e4)}m ago`:p.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(jr,{className:"h-4 w-4 text-green-500"}):a.jsx(dv,{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(Rp,{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(en,{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(jr,{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 Zv(){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(hn,{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(nv,{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(hv,{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(gv,{className:"h-8 w-8 text-orange-600"})]}),a.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Currently active"})]})]}),a.jsx(Xv,{}),a.jsx(Jv,{}),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 ex=({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 p=>{p.preventDefault(),u(null),o(!0);try{const h=await fetch(`/api/organizations/${e}/workspaces`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,services:[]})});if(!h.ok){const x=await h.json();throw new Error(x.error||"Failed to create workspace")}const v=await h.json();if(v.success)t(v.data);else throw new Error(v.error||"Failed to create workspace")}catch(h){console.error("Failed to create workspace:",h),u(h instanceof Error?h.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:p=>s({...r,id:p.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:p=>s({...r,name:p.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:p=>s({...r,description:p.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"})]})]})]})},tx=({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,p]=N.useState(null),[h,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(jr,{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(Hc,{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(en,{className:"w-4 h-4 text-blue-500"});case"remove_service":return a.jsx(Hc,{className:"w-4 h-4 text-red-500"});default:return a.jsx(tv,{className:"w-4 h-4 text-gray-500"})}},m=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=>{p(j.name),v({name:j.name,type:j.type,technology:j.technology,port:j.port,description:j.description})},b=()=>{p(null),v({})},E=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(h)}),R=await j.json();if(j.ok&&R.success)p(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(Pn,{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(en,{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(en,{className:"w-4 h-4 mr-2 animate-spin"}),"Analyzing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(en,{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:h.name||"",onChange:M=>v({...h,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:h.type||"backend",onChange:M=>v({...h,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:h.technology||"",onChange:M=>v({...h,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:h.port||"",onChange:M=>v({...h,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:h.description||"",onChange:M=>v({...h,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:E,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(Pn,{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(ss,{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:()=>m(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(en,{className:`w-4 h-4 mr-2 ${s?"animate-spin":""}`}),"Re-analyze"]})})]})]})]})})};function nx(){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,p]=N.useState(new Set),[h,v]=N.useState(new Set),[x,w]=N.useState(null),[k,m]=N.useState(null),[f,g]=N.useState(null),[b,E]=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:""}),[G,Ce]=N.useState(Date.now()),[P,q]=N.useState(null),[Y,ae]=N.useState(null),[A,F]=N.useState(null),[U,ee]=N.useState({}),[Q,X]=N.useState({}),[ue,Ae]=N.useState({}),[ve,Ge]=N.useState(!1),[kt,Be]=N.useState(null),[be,Er]=N.useState([]),[fe,V]=N.useState(new Set),[ce,Te]=N.useState({}),[ht,St]=N.useState(!1),[Wn,fa]=N.useState(!1),[Up,pa]=N.useState([]),[ha,Wp]=N.useState(new Set),[Bp,ma]=N.useState(null),[ga,zs]=N.useState(""),[uu,cu]=N.useState(!1),[wn,ya]=N.useState({}),[Bn,va]=N.useState(new Set);N.useEffect(()=>{As()},[]);const J=(y,S,I)=>{const D={id:Date.now().toString(),type:y,title:S,message:I,timestamp:Date.now()};c(W=>[...W,D]),y==="success"&&setTimeout(()=>{c(W=>W.filter(Z=>Z.id!==D.id))},5e3)},Hp=y=>{c(S=>S.filter(I=>I.id!==y))},As=async()=>{try{const y=await fetch("/api/organizations");if(y.ok){const S=await y.json();t(S.data),Ce(Date.now())}}catch(y){console.error("Failed to fetch organizations:",y)}finally{r(!1)}},jn=async()=>{await As()},xa=()=>{},wa=()=>{},ja=()=>{},qp=async y=>{try{const S=await fetch(`/api/project-mappings/organization/${y}`);if(S.ok){const I=await S.json();pa(I.mappings||[])}}catch(S){console.error("Failed to fetch project mappings:",S)}},Qp=async(y,S,I)=>{if(!ga.trim()){J("error","Invalid Path","Please enter a valid local path");return}cu(!0);try{const D=await fetch("/api/project-mappings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({organizationId:y,projectId:S,localPath:ga,projectName:I})}),W=await D.json();D.ok&&W.success?(pa(Z=>{const de=Z.findIndex(oe=>oe.projectId===S);if(de>=0){const oe=[...Z];return oe[de]=W.mapping,oe}return[...Z,W.mapping]}),ma(null),zs(""),J("success","Mapping Saved",`Successfully mapped "${I}" to local path`)):J("error","Failed to Save Mapping",W.error||"Unknown error")}catch(D){console.error("Failed to save project mapping:",D),J("error","Network Error","Failed to save project mapping")}finally{cu(!1)}},Vp=async(y,S)=>{try{const I=await fetch(`/api/project-mappings/${y}/${S}`,{method:"DELETE"});if(I.ok)pa(D=>D.filter(W=>W.projectId!==S)),J("success","Mapping Removed","Project path mapping has been removed");else{const D=await I.json();J("error","Failed to Remove Mapping",D.error||"Unknown error")}}catch(I){console.error("Failed to remove project mapping:",I),J("error","Network Error","Failed to remove project mapping")}},Kp=y=>Up.find(S=>S.projectId===y),Gp=async y=>{const S=new Set(d);S.has(y)?S.delete(y):(S.add(y),await qp(y)),p(S)},Yp=async(y,S)=>{y.preventDefault();try{const I=await fetch(`/api/organizations/${S}/workspaces`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),D=await I.json();if(I.ok&&D.success&&D.data){if(e){const W=e.organizations.map(Z=>{if(Z.id===S){const de=Z.workspaces||[];return{...Z,workspaces:[...de,D.data],workspaceCount:(Z.workspaceCount||0)+1}}return Z});t({...e,organizations:W})}w(null),E({name:"",id:"",path:"",description:""}),xa(),J("success","Workspace Added",`Successfully added workspace "${b.name}"`)}else J("error","Failed to Add Workspace",D.message||D.error)}catch(I){console.error("Failed to add workspace:",I),J("error","Network Error","Failed to add workspace. Please try again.")}},Jp=async(y,S,I)=>{console.log("🔄 handleUpdateWorkspace called:",{orgId:y,workspaceId:S,updates:I});try{console.log("📡 Making PATCH request to:",`/api/organizations/${y}/workspaces/${S}`);const D=await fetch(`/api/organizations/${y}/workspaces/${S}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)});console.log("📨 Response status:",D.status,D.statusText);const W=await D.json();D.ok?(await jn(),J("success","Workspace Updated","Workspace settings updated successfully")):J("error","Failed to Update Workspace",W.message||W.error)}catch(D){console.error("Failed to update workspace:",D),J("error","Network Error","Failed to update workspace. Please try again.")}},Xp=y=>{ae(y.id),X({name:y.name,type:y.type,technology:y.technology,port:y.port,url:y.url,description:y.description})},Zp=()=>{ae(null),X({})},eh=async(y,S,I)=>{try{const D=await fetch(`/api/organizations/${y}/workspaces/${S}/services/${I}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(Q)}),W=await D.json();if(D.ok&&W.success)await jn(),ae(null),X({}),J("success","Service Updated","Service details updated successfully");else throw new Error(W.error||"Failed to update service")}catch(D){console.error("Failed to update service:",D),J("error","Update Failed",D instanceof Error?D.message:"Failed to update service")}},th=async(y,S,I,D)=>{if(confirm(`Are you sure you want to remove the service "${D}"? This action cannot be undone.`))try{const W=await fetch(`/api/organizations/${y}/workspaces/${S}/services/${I}`,{method:"DELETE"}),Z=await W.json();if(W.ok&&Z.success)await jn(),J("success","Service Removed",`Service "${D}" has been removed`);else throw new Error(Z.error||"Failed to remove service")}catch(W){console.error("Failed to remove service:",W),J("error","Removal Failed",W instanceof Error?W.message:"Failed to remove service")}},nh=async(y,S,I)=>{y.preventDefault();try{const D={...M,port:M.port?parseInt(M.port):void 0,isActive:!0},W=await fetch(`/api/organizations/${S}/workspaces/${I}/services`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)}),Z=await W.json();if(W.ok&&Z.success){if(e){const de=e.organizations.map(oe=>{var z;if(oe.id===S){const $=(z=oe.workspaces)==null?void 0:z.map(H=>{if(H.id===I){const Fe=H.services||[];return{...H,services:[...Fe,Z.data]}}return H});return{...oe,workspaces:$}}return oe});t({...e,organizations:de})}R(null),K({name:"",type:"backend",port:"",url:"",technology:"",description:""}),xa(),J("success","Service Added",`Successfully added service "${D.name}"`)}else J("error","Failed to Add Service",Z.message||Z.error)}catch(D){console.error("Failed to add service:",D),J("error","Network Error","Failed to add service. Please try again.")}},rh=async(y,S,I,D)=>{try{const W=await fetch(`/api/organizations/${y}/workspaces/${S}/services/${I}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:D})}),Z=await W.json();if(W.ok&&Z.success){if(e){const de=e.organizations.map(oe=>{var z;if(oe.id===y){const $=(z=oe.workspaces)==null?void 0:z.map(H=>{var Fe;if(H.id===S){const Wt=(Fe=H.services)==null?void 0:Fe.map(Bt=>Bt.id===I?{...Bt,isActive:D}:Bt);return{...H,services:Wt}}return H});return{...oe,workspaces:$}}return oe});t({...e,organizations:de})}J("success","Service Updated",`Service ${D?"activated":"deactivated"} successfully`)}else J("error","Failed to Update Service",Z.message||Z.error)}catch(W){console.error("Failed to update service:",W),J("error","Network Error","Failed to update service. Please try again.")}},sh=y=>{F(y.id),Ae({name:y.name,apiUrl:y.apiUrl,apiKey:"",enabled:y.enabled})},ih=()=>{F(null),Ae({})},ah=async y=>{Ge(!0);try{const S=await fetch(`/api/organizations/${y}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(ue)}),I=await S.json();if(S.ok&&I.success)await jn(),F(null),Ae({}),J("success","Organization Updated","Organization details updated successfully");else throw new Error(I.error||"Failed to update organization")}catch(S){console.error("Failed to update organization:",S),J("error","Update Failed",S instanceof Error?S.message:"Failed to update organization")}finally{Ge(!1)}},oh=async y=>{Be(y),St(!0);try{const[S,I]=await Promise.all([fetch(`/api/organizations/${y}/workspaces/available`),fetch(`/api/service-mappings/organization/${y}`)]),D=await S.json();if(S.ok&&D.success){Er(D.workspaces||[]);const W=new Set,Z={};if(D.workspaces.forEach(de=>{de.syncedLocally&&de.isActive!==!1?(W.add(de.id),Z[de.id]=de.localPath||de.path||""):Z[de.id]=de.path||""}),V(W),Te(Z),I.ok){const oe=(await I.json()).mappings||[],z={};oe.forEach($=>{z[`${$.workspaceId}:${$.serviceId}`]=$.localPath}),ya(z)}}else J("error","Failed to Fetch Workspaces",D.error||"Could not fetch available workspaces"),Be(null)}catch(S){console.error("Failed to fetch available workspaces:",S),J("error","Network Error","Failed to fetch available workspaces. Please try again."),Be(null)}finally{St(!1)}},lh=async y=>{fa(!0);try{if(fe.size>0){const oe=await fetch(`/api/organizations/${y}/workspaces/sync`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceIds:Array.from(fe)})}),z=await oe.json();if(!oe.ok){J("error","Failed to Sync Workspaces",z.message||z.error),fa(!1);return}for(const $ of fe){const H=be.find(Wt=>Wt.id===$),Fe=ce[$];H&&Fe&&Fe!==H.path&&await fetch(`/api/organizations/${y}/workspaces/${$}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Fe})})}}const S=new Set(fe),I=be.filter(oe=>oe.syncedLocally&&!S.has(oe.id));for(const oe of I)await fetch(`/api/organizations/${y}/workspaces/${oe.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:!1})});let D=0;for(const[oe,z]of Object.entries(wn))if(z&&z.trim()){const[$,H]=oe.split(":");if(!$||!H)continue;let Fe="",Wt="";const Bt=be.find(Ht=>Ht.id===$);if(Bt!=null&&Bt.services){const Ht=Bt.services.find(dh=>dh.id===H);Ht&&(Fe=Ht.name,Wt=Ht.technology||"")}try{(await fetch("/api/service-mappings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({organizationId:y,workspaceId:$,serviceId:H,localPath:z.trim(),serviceName:Fe,technology:Wt})})).ok&&D++}catch(Ht){console.error("Failed to save service mapping:",Ht)}}await jn();const W=fe.size,Z=I.length;let de="";W>0&&Z>0?de=`Saved ${W} workspace(s) and disabled ${Z} workspace(s)`:W>0?de=`Saved ${W} workspace(s)`:Z>0?de=`Disabled ${Z} workspace(s)`:de="No changes made",D>0&&(de+=`, ${D} service path(s) mapped`),J("success","Workspaces Updated",de),Be(null),va(new Set)}catch(S){console.error("Failed to save workspaces:",S),J("error","Network Error","Failed to save workspaces. Please try again.")}finally{fa(!1)}},uh=async y=>{y.preventDefault();try{const S=o.basePath.endsWith("/")?`${o.basePath}graphql`:`${o.basePath}/graphql`,I={name:o.name,apiUrl:S,apiKey:o.apiKey},D=await fetch("/api/organizations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)}),W=await D.json();D.ok?(await As(),i(!1),l({name:"",basePath:"",apiKey:""}),xa(),J("success","Organization Added",`Successfully added "${o.name}"`)):J("error","Failed to Add Organization",W.message||W.error)}catch(S){console.error("Failed to add organization:",S),J("error","Network Error","Failed to connect to server. Please try again.")}},ch=async y=>{if(confirm("Are you sure you want to delete this organization?"))try{const S=await fetch(`/api/organizations/${y}`,{method:"DELETE"}),I=await S.json();S.ok?(await As(),J("success","Organization Deleted",I.message||"Organization deleted successfully")):J("error","Failed to Delete Organization",I.message||I.error)}catch(S){console.error("Failed to delete organization:",S),J("error","Network Error","Failed to delete organization. Please try again.")}};return a.jsxs(a.Fragment,{children:[a.jsx(hn,{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(G).toLocaleTimeString()]})]}),a.jsxs("button",{onClick:jn,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(en,{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(Jt,{className:"h-4 w-4 text-red-600 mt-0.5 flex-shrink-0"}):a.jsx(jr,{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:()=>Hp(y.id),className:"text-current opacity-60 hover:opacity-100 transition-opacity ml-2",children:a.jsx(Pn,{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(Jt,{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:uh,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(Vr,{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,Z,de,oe;const S=((W=y.workerRegistration)==null?void 0:W.registered)||!1,I=((Z=y.workerRegistration)==null?void 0:Z.lastHeartbeat)||y.createdAt,D=(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:ue.name||"",onChange:z=>Ae({...ue,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:ue.apiUrl||"",onChange:z=>Ae({...ue,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:ue.apiKey||"",onChange:z=>Ae({...ue,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:ue.enabled??y.enabled,onChange:z=>Ae({...ue,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:()=>ah(y.id),disabled:ve,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:[ve&&a.jsx(ir,{className:"h-4 w-4 animate-spin"}),ve?"Saving...":"Save"]}),a.jsx("button",{onClick:ih,disabled:ve,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}),I&&a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[D,": ",new Date(I).toLocaleString()]})]})}),A!==y.id&&a.jsx("div",{className:"flex items-start",children:a.jsx("button",{onClick:()=>sh(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(mv,{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(Rp,{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:()=>Gp(y.id),className:"flex items-center gap-2 hover:text-blue-600 transition-colors",children:[d.has(y.id)?a.jsx(Fr,{className:"h-4 w-4"}):a.jsx(Dr,{className:"h-4 w-4"}),a.jsx(Ap,{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:()=>oh(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(Vr,{className:"h-3 w-3 mr-1"}),"Manage"]})})]}),d.has(y.id)&&a.jsxs("div",{className:"mt-2 space-y-2",children:[h.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:P===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:$=>ee({...U,name:$.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:$=>ee({...U,path:$.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:$=>ee({...U,description:$.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:()=>Jp(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(pv,{className:"h-3 w-3"}):a.jsx(fv,{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 $=`${y.id}-${z.id}`,H=new Set(T);H.has($)?H.delete($):H.add($),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(Fr,{className:"h-3 w-3"}):a.jsx(Dr,{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($=>a.jsx("div",{className:"bg-white p-2 rounded border",children:Y===$.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:Q.name||"",onChange:H=>X({...Q,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:Q.type||"backend",onChange:H=>X({...Q,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:Q.technology||"",onChange:H=>X({...Q,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:Q.port||"",onChange:H=>X({...Q,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:Q.url||"",onChange:H=>X({...Q,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:Q.description||"",onChange:H=>X({...Q,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:()=>eh(y.id,z.id,$.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:Zp,className:"px-2 py-1 text-xs bg-gray-600 text-white rounded hover:bg-gray-700",children:a.jsx(Pn,{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:$.name}),a.jsxs("span",{className:"text-gray-500",children:["(",$.type,")"]}),$.port&&a.jsxs("span",{className:"text-gray-400",children:[":",$.port]}),$.technology&&a.jsx("span",{className:"px-1 py-0.5 bg-blue-100 text-blue-700 rounded text-xs",children:$.technology}),$.description&&a.jsxs("span",{className:"text-gray-400 italic",children:["- ",$.description]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:()=>Xp($),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:()=>th(y.id,z.id,$.id,$.name),className:"p-1 text-gray-500 hover:text-red-600 transition-colors",title:"Remove service",children:a.jsx(ss,{className:"h-3 w-3"})}),a.jsx("button",{onClick:()=>rh(y.id,z.id,$.id,!$.isActive),className:`px-1.5 py-0.5 rounded text-xs ${$.isActive?"bg-green-100 text-green-700":"bg-gray-100 text-gray-600"}`,children:$.isActive?"Active":"Inactive"})]})]})},$.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 $=`proj-${y.id}-${z.id}`,H=new Set(ha);H.has($)?H.delete($):H.add($),Wp(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(Fr,{className:"h-3 w-3"}):a.jsx(Dr,{className:"h-3 w-3"}),a.jsx(rs,{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($=>{const H=Kp($.id),Fe=Bp===$.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(sv,{className:"h-3 w-3 text-gray-400"}),a.jsx("span",{className:"font-medium",children:$.name}),$.stage&&a.jsx("span",{className:"px-1 py-0.5 bg-gray-100 text-gray-600 rounded text-xs",children:$.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&&!Fe&&a.jsx("button",{onClick:()=>Vp(y.id,$.id),className:"p-1 text-gray-500 hover:text-red-600 transition-colors",title:"Remove mapping",children:a.jsx(ss,{className:"h-3 w-3"})}),!Fe&&a.jsx("button",{onClick:()=>{ma($.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&&!Fe&&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})}),Fe&&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:()=>Qp(y.id,$.id,$.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(ir,{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(Pn,{className:"h-3 w-3"})})]})]},$.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&&((oe=y.workspaces)==null?void 0:oe.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=>nh(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=>Yp(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=>E({...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=>E({...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=>E({...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=>E({...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),E({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:()=>ch(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(ss,{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(ex,{organizationId:k,onComplete:y=>{var I;if(e){const D=e.organizations.map(W=>{if(W.id===k){const Z=[...W.workspaces||[],y];return{...W,workspaces:Z,workspaceCount:Z.length}}return W});t({...e,organizations:D})}m(null);const S=((I=y.services)==null?void 0:I.length)||0;J("success","Workspace Created",`Successfully created workspace "${y.name}" with ${S} service(s) using wizard`)},onCancel:()=>{m(null)}})})}),f&&a.jsx(tx,{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})}),I=await S.json();if(S.ok&&I.success)J("success","Changes Applied",`Applied ${y.length} improvement(s) to workspace "${f.workspace.name}"`),await jn();else throw new Error(I.error||"Failed to apply changes")}catch(S){console.error("Failed to apply workspace changes:",S),J("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"]})]})]}),kt&&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:()=>Be(null),className:"text-gray-500 hover:text-gray-700",children:a.jsx(Pn,{className:"h-5 w-5"})})]}),ht?a.jsxs("div",{className:"flex items-center justify-center py-12",children:[a.jsx(ir,{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."}),be.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:[be.filter(y=>y.isActive!==!1).length>0&&a.jsx("div",{className:"space-y-2",children:be.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 I=new Set(fe);S.target.checked?I.add(y.id):I.delete(y.id),V(I)},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=>{Te({...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(Fr,{className:"h-4 w-4"}):a.jsx(Dr,{className:"h-4 w-4"}),a.jsx(Vr,{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 I=`${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})]}),wn[I]&&a.jsx(rs,{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:wn[I]||"",onChange:D=>{ya({...wn,[I]:D.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))}),be.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"}),be.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 I=new Set(fe);S.target.checked?I.add(y.id):I.delete(y.id),V(I)},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=>{Te({...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(Fr,{className:"h-4 w-4"}):a.jsx(Dr,{className:"h-4 w-4"}),a.jsx(Vr,{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 I=`${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})]}),wn[I]&&a.jsx(rs,{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:wn[I]||"",onChange:D=>{ya({...wn,[I]:D.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:()=>Be(null),className:"px-4 py-2 text-gray-600 hover:text-gray-800",disabled:Wn,children:"Cancel"}),a.jsx("button",{onClick:()=>lh(kt),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(ir,{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 rx(){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,p]=N.useState(!1),h=async()=>{r(!0),i(null);try{const m=await fetch("/api/service-mappings");if(!m.ok)throw new Error("Failed to fetch service mappings");const f=await m.json();if(f.success)t(f.mappings);else throw new Error("Failed to fetch mappings")}catch(m){i(m instanceof Error?m.message:"Failed to fetch mappings")}finally{r(!1)}};N.useEffect(()=>{h()},[]);const v=async m=>{m.preventDefault(),p(!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 h(),l(!1),c({organizationId:"",workspaceId:"",serviceId:"",localPath:"",serviceName:"",technology:"",notes:""})}catch(f){i(f instanceof Error?f.message:"Failed to save mapping")}finally{p(!1)}},x=async m=>{if(confirm(`Delete mapping for ${m.serviceName||m.serviceId}?`))try{const f=await fetch(`/api/service-mappings/${encodeURIComponent(m.organizationId)}/${encodeURIComponent(m.workspaceId)}/${encodeURIComponent(m.serviceId)}`,{method:"DELETE"}),g=await f.json();if(!f.ok||!g.success)throw new Error(g.error||"Failed to delete mapping");await h()}catch(f){i(f instanceof Error?f.message:"Failed to delete mapping")}},w=m=>new Date(m).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),k=e.reduce((m,f)=>(m[f.organizationId]||(m[f.organizationId]=[]),m[f.organizationId].push(f),m),{});return a.jsxs(a.Fragment,{children:[a.jsx(hn,{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:h,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(en,{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:m=>c({...u,organizationId:m.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:m=>c({...u,workspaceId:m.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:m=>c({...u,serviceId:m.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:m=>c({...u,localPath:m.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:m=>c({...u,serviceName:m.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:m=>c({...u,technology:m.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:m=>c({...u,notes:m.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(rs,{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(([m,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(rv,{className:"h-5 w-5 text-blue-600"}),a.jsxs("h3",{className:"font-medium",children:["Organization: ",m]}),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(cv,{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(av,{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(Ap,{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(ss,{className:"h-4 w-4"})})]})},`${g.organizationId}:${g.workspaceId}:${g.serviceId}`))})]},m))}),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 sx(){return a.jsxs(a.Fragment,{children:[a.jsx(hn,{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(xp,{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(Mp,{className:"h-4 w-4"}),a.jsx("span",{children:"Go Home"})]})]})})]})}function ix(){return a.jsxs(a.Fragment,{children:[a.jsxs(hn,{children:[a.jsx("title",{children:"AI Agent Service Dashboard"}),a.jsx("meta",{name:"description",content:"Analytics dashboard for AI agent service monitoring"})]}),a.jsx(Kv,{children:a.jsxs(O0,{children:[a.jsx(Qr,{path:"/",element:a.jsx(Zv,{})}),a.jsx(Qr,{path:"/organizations",element:a.jsx(nx,{})}),a.jsx(Qr,{path:"/service-mappings",element:a.jsx(rx,{})}),a.jsx(Qr,{path:"*",element:a.jsx(sx,{})})]})})]})}const ax=new sy({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1,staleTime:1e3*60*5}}});to.createRoot(document.getElementById("root")).render(a.jsx(_.StrictMode,{children:a.jsx(sr,{children:a.jsx(oy,{client:ax,children:a.jsxs(L0,{children:[a.jsx(ix,{}),a.jsx(Xy,{position:"top-right"})]})})})}));
69
+ //# sourceMappingURL=index-e2c560a2.js.map