fifony 0.1.43 → 0.1.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/app/dist/assets/{CommandPalette-M4VAMxCU.js → CommandPalette-CL8p78lG.js} +1 -1
  2. package/app/dist/assets/{KeyboardShortcutsHelp-DkvPUXQq.js → KeyboardShortcutsHelp-CqEFfGcE.js} +1 -1
  3. package/app/dist/assets/OnboardingWizard-BmI50ZUv.js +1 -0
  4. package/app/dist/assets/analytics.lazy-CXGjZabc.js +1 -0
  5. package/app/dist/assets/{api-CkVfYg_m.js → api-CEr_D4e5.js} +1 -1
  6. package/app/dist/assets/{createLucideIcon-Dfk_Hxud.js → createLucideIcon-luywpIq4.js} +1 -1
  7. package/app/dist/assets/index-CEaccpYh.js +96 -0
  8. package/app/dist/assets/index-CzzWGzux.css +1 -0
  9. package/app/dist/assets/vendor-uqBx3VSC.js +9 -0
  10. package/app/dist/index.html +12 -12
  11. package/app/dist/service-worker.js +15 -5
  12. package/dist/agent/pty-daemon.js +3 -2
  13. package/dist/agent/run-local.js +71 -52
  14. package/dist/{agent-RMQTTUEC.js → agent-DFSFG6DG.js} +18 -12
  15. package/dist/{analytics-broadcaster-O6YBP66L.js → analytics-broadcaster-O4AE3RUK.js} +21 -14
  16. package/dist/approve-plan.command-QGQZZXTQ.js +17 -0
  17. package/dist/{chunk-E2EWEYA4.js → chunk-2PRRKBG6.js} +20 -10
  18. package/dist/chunk-5AMWD66T.js +38 -0
  19. package/dist/{chunk-QQQLP3PL.js → chunk-7TXZYZR5.js} +9 -37
  20. package/dist/chunk-AAVROEQC.js +859 -0
  21. package/dist/{chunk-ESWHDHH6.js → chunk-AAZKYWOY.js} +4 -4
  22. package/dist/chunk-EBCSQFPR.js +682 -0
  23. package/dist/{chunk-BRSR26VK.js → chunk-FH7HUPZX.js} +2 -2
  24. package/dist/chunk-HOIOVUHI.js +35 -0
  25. package/dist/{chunk-AILXZ2TD.js → chunk-JRLWLZOD.js} +20 -13
  26. package/dist/{chunk-YRSH2CLW.js → chunk-K36BWMUV.js} +1741 -1216
  27. package/dist/chunk-N4KFNX2G.js +370 -0
  28. package/dist/chunk-PACI3T4I.js +125 -0
  29. package/dist/{chunk-FJNH3G2Z.js → chunk-PI7Y77R3.js} +38 -663
  30. package/dist/{chunk-DVU3CXWA.js → chunk-PXTIWKLQ.js} +2 -1
  31. package/dist/{chunk-SOBLO4YZ.js → chunk-QH6VCTET.js} +316 -127
  32. package/dist/{chunk-MVTGAKQK.js → chunk-QHISYRXJ.js} +2 -2
  33. package/dist/{chunk-42AMQAJG.js → chunk-VM5QAYP5.js} +2 -2
  34. package/dist/cli.js +17 -11
  35. package/dist/create-issue.command-VAKYRECC.js +24 -0
  36. package/dist/{fsm-issue-YGGF7SIL.js → fsm-issue-EHTSKMFN.js} +9 -8
  37. package/dist/fsm-service-7O4AJG2R.js +32 -0
  38. package/dist/{helpers-L7NYO5XS.js → helpers-ON2S7UEF.js} +2 -2
  39. package/dist/{issue-log-broadcaster-WZAHISYB.js → issue-log-broadcaster-FZGVEEIX.js} +20 -13
  40. package/dist/{issues-3QRR7KM6.js → issues-3YNNTB4U.js} +10 -7
  41. package/dist/{log-analyzer-K7MXQB4T.js → log-analyzer-EIX6R6PP.js} +82 -18
  42. package/dist/logger-IFLXTQPS.js +11 -0
  43. package/dist/mcp/server.js +2 -2
  44. package/dist/merge-workspace.command-T2NIGR4M.js +24 -0
  45. package/dist/{parallel-executor-6INE6NDO.js → parallel-executor-DWESCNX3.js} +20 -14
  46. package/dist/queue-workers-V57BYXAY.js +38 -0
  47. package/dist/replan-issue.command-2GQ3QXCR.js +17 -0
  48. package/dist/retry-issue.command-GJBUUYDJ.js +17 -0
  49. package/dist/scheduler-KYILMWLD.js +32 -0
  50. package/dist/{settings-ZAWDCFP2.js → settings-SOTIS6ZD.js} +32 -12
  51. package/dist/settings.resource-JMD3JQOS.js +30 -0
  52. package/dist/{store-M6NCKMZY.js → store-S3NAYZ3S.js} +18 -12
  53. package/dist/{web-push-AX5IIK3P.js → web-push-QCTLS7EJ.js} +3 -3
  54. package/dist/websocket-T2Y3BY4B.js +61 -0
  55. package/dist/{workspace-CJTWFWTJ.js → workspace-OS7GPMCN.js} +7 -6
  56. package/package.json +8 -5
  57. package/app/dist/assets/OnboardingWizard-B7V9hoCR.js +0 -1
  58. package/app/dist/assets/analytics.lazy-zVJdF880.js +0 -1
  59. package/app/dist/assets/index-BpiCi7Ew.css +0 -1
  60. package/app/dist/assets/index-D2INW0zc.js +0 -47
  61. package/app/dist/assets/vendor-BEoYbFV1.js +0 -9
  62. package/dist/queue-workers-XFZK3TT5.js +0 -32
  63. package/dist/replan-issue.command-4UCWYHGZ.js +0 -15
  64. package/dist/scheduler-ZP7GOZDW.js +0 -26
  65. package/dist/settings.resource-5CW456AZ.js +0 -24
@@ -0,0 +1,96 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KeyboardShortcutsHelp-CqEFfGcE.js","assets/rolldown-runtime-Dw2cE7zH.js","assets/vendor-uqBx3VSC.js","assets/CommandPalette-CL8p78lG.js","assets/createLucideIcon-luywpIq4.js","assets/api-CEr_D4e5.js","assets/OnboardingWizard-BmI50ZUv.js","assets/analytics.lazy-CXGjZabc.js"])))=>i.map(i=>d[i]);
2
+ import{n as e,r as t,t as n}from"./rolldown-runtime-Dw2cE7zH.js";import{A as r,C as i,D as a,E as o,F as s,I as c,L as l,M as u,N as d,O as f,P as p,R as m,S as h,T as g,_,a as v,b as y,c as b,d as x,f as S,g as C,h as w,i as T,j as E,k as D,l as O,m as k,n as A,p as j,r as M,s as N,t as P,u as F,v as I,w as L,x as R,y as z}from"./vendor-uqBx3VSC.js";import{a as B,c as V,i as ee,l as te,o as H,r as ne,s as re,t as U,u as ie}from"./api-CEr_D4e5.js";import{t as W}from"./createLucideIcon-luywpIq4.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function ae(e){return{onFetch:(t,n)=>{let r=t.options,a=t.fetchOptions?.meta?.fetchMore?.direction,o=t.state.data?.pages||[],s=t.state.data?.pageParams||[],c={pages:[],pageParams:[]},l=0,u=async()=>{let n=!1,u=e=>{R(e,()=>t.signal,()=>n=!0)},d=L(t.options,t.fetchOptions),f=async(e,r,a)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let o=await d((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:a?`backward`:`forward`,meta:t.options.meta};return u(e),e})()),{maxPages:s}=t.options,c=a?i:h;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(a&&o.length){let e=a===`backward`,t=e?se:oe,n={pages:o,pageParams:s};c=await f(n,t(r,n),e)}else{let t=e??o.length;do{let e=l===0?s[0]??r.initialPageParam:oe(r,c);if(l>0&&e==null)break;c=await f(c,e),l++}while(l<t)}return c};t.options.persister?t.fetchFn=()=>t.options.persister?.(u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=u}}}function oe(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function se(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var ce=class extends s{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new _({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=le(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=le(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=le(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=le(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){y.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>f(t,e))}findAll(e={}){return this.getAll().filter(t=>f(e,t))}notify(e){y.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return y.batch(()=>Promise.all(e.map(e=>e.continue().catch(r))))}};function le(e){return e.options.scope?.id}var ue=class extends s{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??a(r,t),o=this.get(i);return o||(o=new I({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(o)),o}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){y.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>D(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>D(e,t)):t}notify(e){y.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){y.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){y.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},de=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new ue,this.#t=e.mutationCache||new ce,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=p.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=z.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(u(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=g(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return y.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;y.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return y.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},i=y.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(i).then(r).catch(r)}invalidateQueries(e,t={}){return y.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},i=y.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(r)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(i).then(r)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(u(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(r).catch(r)}fetchInfiniteQuery(e){return e.behavior=ae(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(r).catch(r)}ensureInfiniteQueryData(e){return e.behavior=ae(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return z.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(o(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{E(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(o(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{E(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=a(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===d&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},G=t(m(),1),fe=c(),pe=`/dinofffaur.webp`;function me(e){return Array.isArray(e?.settings)?e.settings:Array.isArray(e?.data)?e.data:Array.isArray(e)?e:[]}function he(e,t,n){return(Array.isArray(e)?e.find(e=>e?.id===t):null)?.value??n}function ge(e,t){let n=e&&typeof e==`object`?e:{},r=[...me(n).filter(e=>e?.id!==t.id),t];return Array.isArray(n?.settings)?{...n,settings:r}:{...n,success:n?.success??!0,data:r}}function _e(e,t=[],n=[]){let r=new Map(e.map(e=>[e.id,e]));for(let e of n)r.delete(e);for(let e of t)e?.id&&r.set(e.id,e);return[...r.values()]}function ve(e,t){let n=e&&typeof e==`object`?{...e}:{},r={...n,...t};return Array.isArray(t.issues)?r.issues=t.issues:Array.isArray(t.issuesDelta)&&(r.issues=_e(Array.isArray(n.issues)?n.issues:[],t.issuesDelta,t.issuesRemoved||[])),Array.isArray(t.events)&&(r.events=t.events),r}var ye=null,be=[`(display-mode: fullscreen)`,`(display-mode: standalone)`,`(display-mode: minimal-ui)`,`(display-mode: window-controls-overlay)`];function xe(){if(typeof window>`u`)return`browser`;if(document.referrer.startsWith(`android-app://`))return`twa`;if(window.navigator.standalone===!0)return`standalone`;let e=be.find(e=>window.matchMedia(e).matches);return e?e.slice(15,-1):`browser`}function Se(){return typeof window>`u`?!1:xe()!==`browser`}async function Ce(e){if(!(`serviceWorker`in navigator))return null;let t=await navigator.serviceWorker.getRegistration();return t?.active?new Promise(n=>{let r=new MessageChannel,i=window.setTimeout(()=>n(null),1500);r.port1.onmessage=e=>{window.clearTimeout(i),n(e.data??null)},t.active.postMessage(e,[r.port2])}):null}function we(e){if(ye)try{ye(JSON.stringify(e))}catch{}}var Te=new Set;function Ee(e){if(Te.add(e),ye)try{ye(JSON.stringify({type:`service:log:subscribe`,id:e}))}catch{}}function De(e){if(Te.delete(e),ye)try{ye(JSON.stringify({type:`service:log:unsubscribe`,id:e}))}catch{}}var Oe=new Map;function ke(e){let t=Oe.get(e)??0;if(Oe.set(e,t+1),t===0&&ye)try{ye(JSON.stringify({type:`analytics:subscribe`,topic:e}))}catch{}}function Ae(e){let t=Oe.get(e)??0,n=Math.max(t-1,0);if(Oe.set(e,n),n===0&&ye)try{ye(JSON.stringify({type:`analytics:unsubscribe`,topic:e}))}catch{}}function je(e){let[t,n]=(0,G.useState)(`disconnected`),r=w();return(0,G.useEffect)(()=>{let t=`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/ws`,i=null,a=null,o=!0,s=2e3,c=3e4,l=()=>{try{i=new WebSocket(t)}catch{n(`error`),a=setTimeout(l,s),s=Math.min(s*2,c);return}n(`connecting`);let u=null;i.onopen=()=>{n(`connected`),ye=e=>i.send(e),s=2e3;for(let[e,t]of Oe)if(t>0)try{i.send(JSON.stringify({type:`analytics:subscribe`,topic:e}))}catch{}for(let e of Te)try{i.send(JSON.stringify({type:`service:log:subscribe`,id:e}))}catch{}clearInterval(u),u=setInterval(()=>{try{i.send(JSON.stringify({type:`ping`}))}catch{}},25e3)},i.onmessage=t=>{let n=te(t.data);if(!n)return;if(n.type===`analytics:update`&&n.topic&&n.data){let e={"analytics:tokens":[`token-analytics`],"analytics:lines":[`analytics-lines`],"analytics:kpis":[`analytics-kpis`],"analytics:hourly":[`hourly-analytics`]}[n.topic];e&&r.setQueriesData({queryKey:e},n.data);return}let i=n.type===`connected`||n.type===`state:update`||n.type===`state:delta`;(i||n.type===`issue:transition`)&&r.cancelQueries({queryKey:[`runtime-state`]}),i&&r.setQueriesData({queryKey:[`runtime-state`]},e=>ve(e||{},n)),e&&e(n)},i.onclose=()=>{n(`disconnected`),ye=null,clearInterval(u),o&&(a=setTimeout(l,s),s=Math.min(s*2,c))},i.onerror=()=>{n(`error`)}};return l(),()=>{o=!1,clearTimeout(a),i?.close()}},[r,e]),t}function Me({pollInterval:e=3e3,showAll:t=!1}={}){return j({queryKey:[`runtime-state`,t],queryFn:()=>U.get(t?`/state?all=1`:`/state`),refetchInterval:e,refetchOnWindowFocus:!0})}function Ne({pollInterval:e=1e4}={}){return j({queryKey:[`runtime-status`],queryFn:()=>U.get(`/runtime/status`),refetchInterval:e})}function Pe({pollInterval:e=1e4}={}){return j({queryKey:[`runtime-probe`],queryFn:()=>U.get(`/runtime/probe`),refetchInterval:e})}function Fe({pollInterval:e=15e3}={}){return j({queryKey:[`runtime-doctor`],queryFn:()=>U.get(`/runtime/doctor`),refetchInterval:e})}function Ie(e,t,n=2500){let r=new URLSearchParams;return e&&e!==`all`&&r.set(`kind`,e),t&&t!==`all`&&r.set(`issueId`,t),j({queryKey:[`runtime-events`,e,t],queryFn:()=>U.get(`/events/feed${r.size?`?${r}`:``}`),refetchInterval:n})}function Le({pollInterval:e=15e3}={}){return j({queryKey:[`providers`],queryFn:()=>U.get(`/providers`),refetchInterval:e})}function Re({pollInterval:e=15e3}={}){return j({queryKey:[`parallelism`],queryFn:()=>U.get(`/parallelism`),refetchInterval:e})}var ze=[`claude`,`codex`,`gemini`];function Be(e){if(!e||typeof e!=`object`||!Array.isArray(e.providers))return null;let t=typeof e.collectedAt==`string`?e.collectedAt:null;return{providers:e.providers,collectedAt:t}}function Ve(){return j({queryKey:[`providers-usage`],queryFn:async()=>{let e=await Promise.allSettled(ze.map(e=>U.get(`/providers/${e}/usage`))),t=[],n=[];for(let r of e){if(r.status!==`fulfilled`)continue;let e=Be(r.value);e&&(t.push(...e.providers),e.collectedAt&&n.push(e.collectedAt))}if(t.length>0){let e=n.map(e=>new Date(e).getTime()).filter(e=>Number.isFinite(e)).reduce((e,t)=>Math.max(e,t),0);return{providers:t,collectedAt:e?new Date(e).toISOString():new Date().toISOString()}}try{let e=Be(await U.get(`/providers/usage`));e&&(t=e.providers,e.collectedAt&&n.push(e.collectedAt))}catch{}let r=n.map(e=>new Date(e).getTime()).filter(e=>Number.isFinite(e)).reduce((e,t)=>Math.max(e,t),0);return{providers:t,collectedAt:r?new Date(r).toISOString():new Date().toISOString()}},refetchInterval:3e4})}var He=[`auto`,`light`,`dark`],Ue=`cupcake.bumblebee.emerald.corporate.synthwave.retro.cyberpunk.valentine.halloween.garden.forest.aqua.lofi.pastel.fantasy.wireframe.black.luxury.dracula.cmyk.autumn.business.acid.lemonade.night.coffee.winter.dim.nord.sunset.caramellatte.abyss.silk`.split(`.`),We=[...He,...Ue],Ge=[`settings`],Ke=`ui.theme`,qe=`ui.notifications.enabled`,Je=`ui.issues.stateFilter`,Ye=`ui.issues.completionFilter`,Xe=`ui.events.kind`,Ze=`ui.events.issueId`,Qe=window.matchMedia(`(prefers-color-scheme: dark)`);function $e(e){return e===`auto`?Qe.matches?`dark`:`light`:e}function et(e){return We.includes(e)?e:`auto`}function tt(e,t=!1){return typeof e==`boolean`?e:t}async function nt(e,t){return U.post(`/settings/${encodeURIComponent(e)}`,{scope:`ui`,value:t,source:`user`})}function rt(){return j({queryKey:Ge,queryFn:()=>U.get(`/settings`),staleTime:3e4})}function it(e,t,n={}){let r=w(),i=rt(),a=typeof n.normalize==`function`?n.normalize:e=>e,o=a(he(me(i.data),e,t)),[s,c]=(0,G.useState)(o),l=(0,G.useCallback)(t=>{let n=a(t);c(n);let i={id:e,scope:`ui`,value:n,source:`user`,updatedAt:new Date().toISOString()};r.cancelQueries({queryKey:Ge}),r.setQueryData(Ge,e=>ge(e,i)),U.post(`/settings/${encodeURIComponent(e)}`,{scope:`ui`,value:n,source:`user`}).then(e=>{e?.setting&&r.setQueryData(Ge,t=>ge(t,e.setting))}).catch(()=>{r.invalidateQueries({queryKey:Ge})})},[a,r,e]);return(0,G.useEffect)(()=>{c(e=>Object.is(e,o)?e:o)},[o]),[s,l]}function at(){let e=w(),t=et(he(me(rt().data),Ke,`auto`)),[n,r]=(0,G.useState)(t),i=(0,G.useCallback)(t=>{let n=et(t);r(n);let i={id:Ke,scope:`ui`,value:n,source:`user`,updatedAt:new Date().toISOString()};e.cancelQueries({queryKey:Ge}),e.setQueryData(Ge,e=>ge(e,i)),U.post(`/settings/${encodeURIComponent(Ke)}`,{scope:`ui`,value:n,source:`user`}).then(t=>{t?.setting&&e.setQueryData(Ge,e=>ge(e,t.setting))}).catch(()=>{e.invalidateQueries({queryKey:Ge})})},[e]);return(0,G.useEffect)(()=>{r(e=>e===t?e:t)},[t]),(0,G.useEffect)(()=>{let e=()=>{let e=document.documentElement;return e.classList.add(`theme-transitioning`),e.setAttribute(`data-theme`,$e(n)),setTimeout(()=>e.classList.remove(`theme-transitioning`),350)},t=e();if(n===`auto`){let n=()=>e();return Qe.addEventListener(`change`,n),()=>{clearTimeout(t),Qe.removeEventListener(`change`,n)}}return()=>clearTimeout(t)},[n]),[n,i]}function ot(){return it(qe,!1,{normalize:e=>tt(e,!1)})}function st(){return(0,G.useEffect)(()=>(ke(`analytics:tokens`),()=>Ae(`analytics:tokens`)),[]),j({queryKey:[`token-analytics`],queryFn:()=>U.get(`/analytics/tokens`),staleTime:6e4})}function ct(){return(0,G.useEffect)(()=>(ke(`analytics:lines`),()=>Ae(`analytics:lines`)),[]),j({queryKey:[`analytics-lines`],queryFn:()=>U.get(`/analytics/lines`),staleTime:6e4})}function lt(){return(0,G.useEffect)(()=>(ke(`analytics:kpis`),()=>Ae(`analytics:kpis`)),[]),j({queryKey:[`analytics-kpis`],queryFn:()=>U.get(`/analytics/kpis`),staleTime:6e4})}function ut(e=24){return(0,G.useEffect)(()=>(ke(`analytics:hourly`),()=>Ae(`analytics:hourly`)),[]),j({queryKey:[`hourly-analytics`,e],queryFn:()=>U.get(`/analytics/hourly?hours=${e}`),staleTime:6e4})}function dt(){let[e,t]=(0,G.useState)(()=>navigator.onLine),[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(()=>Se()),[u,d]=(0,G.useState)(()=>xe()),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(null);(0,G.useEffect)(()=>{let e=()=>t(!0),n=()=>t(!1);return window.addEventListener(`online`,e),window.addEventListener(`offline`,n),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,n)}},[]),(0,G.useEffect)(()=>{let e=be.map(e=>window.matchMedia(e)),t=e=>{e.preventDefault(),r(e),a(!0)},n=()=>{r(null),a(!1),l(!0),d(xe())},i=()=>{l(Se()),d(xe())};window.__fifonyInstallPrompt&&(r(window.__fifonyInstallPrompt),a(!0),window.__fifonyInstallPrompt=null),window.addEventListener(`beforeinstallprompt`,t),window.addEventListener(`appinstalled`,n);for(let t of e)t.addEventListener(`change`,i);return()=>{window.removeEventListener(`beforeinstallprompt`,t),window.removeEventListener(`appinstalled`,n);for(let t of e)t.removeEventListener(`change`,i)}},[]),(0,G.useEffect)(()=>{if(!(`serviceWorker`in navigator))return;let e=!1,t=e=>{p(!!e),e&&(e.waiting&&navigator.serviceWorker.controller&&s(!0),e.addEventListener(`updatefound`,()=>{let t=e.installing;t&&t.addEventListener(`statechange`,()=>{t.state===`installed`&&navigator.serviceWorker.controller&&s(!0)})}))},n=()=>{e||(e=!0,window.location.reload())};return Ce({type:`GET_VERSION`}).then(e=>h(e?.version??null)).catch(()=>{}),navigator.serviceWorker.addEventListener(`controllerchange`,n),navigator.serviceWorker.getRegistration().then(t).catch(()=>{}),()=>{navigator.serviceWorker.removeEventListener(`controllerchange`,n)}},[]);let g=(0,G.useCallback)(async()=>!n||(await n.prompt(),(await n.userChoice)?.outcome!==`accepted`)?!1:(r(null),a(!1),!0),[n]),_=(0,G.useCallback)(async()=>{if(!(`serviceWorker`in navigator))return!1;let e=await navigator.serviceWorker.getRegistration();return e?.waiting?(e.waiting.postMessage({type:`SKIP_WAITING`}),!0):!1},[]);return{isOnline:e,canInstall:i&&!c,isInstalled:c,displayMode:u,updateAvailable:o,serviceWorkerSupported:`serviceWorker`in navigator,serviceWorkerRegistered:f,serviceWorkerVersion:m,installApp:g,applyUpdate:_}}var ft=`ui.notifications.events.`,pt=[1e4,5e4,1e5,5e5,1e6],mt=[{id:`running`,state:`Running`,label:`Agent started`,description:`When an agent begins executing an issue.`,icon:`play`,sound:!1,defaultEnabled:!0,group:`execution`},{id:`queued`,state:`Queued`,label:`Issue queued`,description:`When an issue enters the execution queue.`,icon:`clock`,sound:!1,defaultEnabled:!1,group:`execution`},{id:`reviewing`,state:`Reviewing`,label:`Review started`,description:`When an agent begins reviewing changes.`,icon:`eye`,sound:!1,defaultEnabled:!0,group:`review`},{id:`reviewed`,state:`PendingDecision`,label:`Review complete`,description:`When the review step finishes.`,icon:`eye`,sound:!1,defaultEnabled:!0,group:`review`},{id:`done`,state:`Approved`,label:`Issue completed`,description:`When an issue is fully done.`,icon:`check`,sound:!0,defaultEnabled:!0,group:`lifecycle`},{id:`blocked`,state:`Blocked`,label:`Issue blocked`,description:`When an agent gets stuck and needs attention.`,icon:`alert`,sound:!0,defaultEnabled:!0,group:`lifecycle`},{id:`cancelled`,state:`Cancelled`,label:`Issue cancelled`,description:`When an issue is cancelled after failures.`,icon:`x`,sound:!1,defaultEnabled:!0,group:`lifecycle`},{id:`token-milestone`,state:`token-milestone`,label:`Token milestone`,description:`When token usage crosses 10K, 50K, 100K, 500K, or 1M.`,icon:`zap`,sound:!1,defaultEnabled:!0,group:`usage`}],ht=[{id:`execution`,label:`Execution`},{id:`review`,label:`Review`},{id:`lifecycle`,label:`Lifecycle`},{id:`usage`,label:`Usage`}],gt=new Map(mt.map(e=>[e.state,e]));function _t(e){return gt.get(e)??null}function vt(e){return`${ft}${e}`}function yt(e,t){let n=gt.get(t);if(!n)return!1;let r=vt(n.id);return(Array.isArray(e)?e.find(e=>e?.id===r):null)?.value??n.defaultEnabled}function bt(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:String(e)}function xt(){return`Notification`in window?Notification.permission:`unsupported`}function St(e,t,n){if(xt()===`granted`)try{new Notification(e,{body:t,tag:`fifony-${n}`,icon:`/icon.svg`,badge:`/icon.svg`,silent:!1})}catch{}}var Ct=null;function wt(){if(!Ct)try{Ct=new(window.AudioContext||window.webkitAudioContext)}catch{return null}return Ct}var Tt=typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;function Et(e){if(!e||Tt)return;let t=wt();if(!t)return;let n=t.currentTime,r=.08,i=t.createOscillator(),a=t.createGain();i.type=`sine`,i.frequency.value=880,a.gain.setValueAtTime(r,n),a.gain.exponentialRampToValueAtTime(.001,n+.06),i.connect(a),a.connect(t.destination),i.start(n),i.stop(n+.06);let o=t.createOscillator(),s=t.createGain();o.type=`sine`,o.frequency.value=1100,s.gain.setValueAtTime(0,n),s.gain.setValueAtTime(r,n+.07),s.gain.exponentialRampToValueAtTime(.001,n+.15),o.connect(s),s.connect(t.destination),o.start(n+.07),o.stop(n+.15)}var Dt=0;function Ot(){let[e,t]=(0,G.useState)([]),[n,r]=(0,G.useState)(0),i=(0,G.useCallback)(e=>{let n=++Dt,i={id:n,...e,timestamp:Date.now(),read:!1};return t(e=>[i,...e].slice(0,30)),r(e=>e+1),n},[]),a=(0,G.useCallback)(e=>{t(t=>{let n=t.find(t=>t.id===e);return n&&!n.read&&r(e=>Math.max(0,e-1)),t.filter(t=>t.id!==e)})},[]),o=(0,G.useCallback)(()=>{t(e=>e.map(e=>e.read?e:{...e,read:!0})),r(0)},[]);return(0,G.useEffect)(()=>{let e=setInterval(()=>{let e=Date.now()-300*1e3;t(t=>t.filter(t=>!t.read||t.timestamp>e))},3e4);return()=>clearInterval(e)},[]),{notifications:e,unreadCount:n,addNotification:i,dismissNotification:a,markAllRead:o}}function kt(e){let[t,n]=ot(),[r,i]=(0,G.useState)(xt),a=(0,G.useRef)(new Map),o=(0,G.useRef)(new Map),s=Ot(),c=me(rt().data),l=w(),u=(0,G.useCallback)(e=>{n(e)},[n]),d=(0,G.useCallback)(async()=>{if(!(`Notification`in window))return`unsupported`;let e=await Notification.requestPermission();return i(e),e===`granted`&&u(!0),e},[u]),f=mt.map(e=>({...e,enabled:yt(c,e.state),settingId:vt(e.id)})),p=(0,G.useCallback)(async(e,t)=>{await nt(vt(e),t),l.invalidateQueries({queryKey:[`settings`]})},[l]);return(0,G.useEffect)(()=>{if(!t||r!==`granted`||!Array.isArray(e))return;let n=a.current,i=new Map;for(let r of e){i.set(r.id,r.state);let e=n.get(r.id);if(e&&e!==r.state){let e=_t(r.state);if(e&&yt(c,r.state)){let n=`${e.label}: ${r.identifier}`,i=r.title;St(n,i,`${e.id}-${r.id}`),s.addNotification({title:n,body:i,state:r.state,icon:e.icon,issueId:r.id}),e.sound&&Et(t)}}let a=r.tokenUsage?.totalTokens;if(typeof a==`number`&&a>0){o.current.has(r.id)||o.current.set(r.id,new Set);let e=o.current.get(r.id);for(let t of pt)if(a>=t&&!e.has(t)&&(e.add(t),n.size>0&&_t(`token-milestone`)&&yt(c,`token-milestone`))){let e=bt(t),n=`Token milestone: ${e}`,i=`${r.identifier} has used ${e} tokens`;St(n,i,`tokens-${t}-${r.id}`),s.addNotification({title:n,body:i,state:`token-milestone`,icon:`zap`,issueId:r.id})}}}a.current=i},[e,t,r,c,s.addNotification]),{enabled:t,setEnabled:u,permission:r,supported:`Notification`in window,requestPermission:d,eventSettings:f,setEventEnabled:p,...s}}var At=new Map;function jt(e,t){return At.has(e)||At.set(e,new Set),At.get(e).add(t),()=>At.get(e)?.delete(t)}function Mt(e,t){for(let n of At.get(e)??[])n(t)}var Nt=new Set;function Pt(e){for(let t of Nt)t(e)}var Ft=new Map;function It({pollInterval:e=3e3}={}){let[t,n]=(0,G.useState)([]),[r,i]=(0,G.useState)(!0),a=(0,G.useCallback)(async()=>{try{let e=await U.get(`/services`);e?.services&&n(e.services)}catch{}finally{i(!1)}},[]);return(0,G.useEffect)(()=>{a()},[a]),(0,G.useEffect)(()=>{if(!e)return;let t=setInterval(a,e);return()=>clearInterval(t)},[a,e]),(0,G.useEffect)(()=>{let e=({id:e,state:t,running:r,pid:i})=>{if(n(n=>n.map(n=>n.id===e?{...n,state:t,running:r,pid:i??n.pid}:n)),t===`starting`)for(let t of Ft.get(e)??[])t()};return Nt.add(e),()=>Nt.delete(e)},[]),{services:t,loading:r,refresh:a}}var Lt=new Map;function Rt(e,t){return Lt.has(e)||Lt.set(e,new Set),Lt.get(e).add(t),()=>Lt.get(e)?.delete(t)}function zt(e,t){for(let n of Lt.get(e)??[])n(t)}function Bt(e,t=!1){let[n,r]=(0,G.useState)(``),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(null);return(0,G.useEffect)(()=>{if(!t||!e){r(``),a(!1),s(null);return}let n=!0,i=encodeURIComponent(e);U.get(`/issues/${i}/live`).then(e=>{n&&(r(e.logTail??``),s(e),a(!0))}).catch(()=>{n&&a(!1)}),we({type:`issue:log:subscribe`,id:e});let o=Rt(e,e=>{n&&(r(t=>t+e),a(!0))});return()=>{n=!1,we({type:`issue:log:unsubscribe`,id:e}),o(),a(!1),s(null)}},[e,t]),{log:n,connected:i,liveInfo:o}}var Vt=new Set;function Ht(e){for(let t of Vt)t(e)}function Ut(){let[e,t]=(0,G.useState)(null),[n,r]=(0,G.useState)([]),[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(!0),c=(0,G.useCallback)(async()=>{try{let e=await U.get(`/mesh`);e?.graph&&t(e.graph)}catch{}},[]),l=(0,G.useCallback)(async()=>{try{let e=await U.get(`/mesh/traffic?limit=200`);e?.entries&&r(e.entries)}catch{}},[]);(0,G.useCallback)(async()=>{try{let e=await U.get(`/mesh/status`);e&&a(e)}catch{}},[]);let u=(0,G.useCallback)(async()=>{try{await U.post(`/mesh/clear`,{}),r([]),await c()}catch{}},[c]);return(0,G.useEffect)(()=>{(async()=>{try{let e=await U.get(`/mesh/status`);e&&a(e),e?.running&&await Promise.all([c(),l()])}catch{}s(!1)})()},[c,l]),(0,G.useEffect)(()=>{we({type:`mesh:subscribe`});let e=e=>{r(t=>{let n=[...t,e];return n.length>500?n.slice(-500):n}),c()};return Vt.add(e),()=>{Vt.delete(e),we({type:`mesh:unsubscribe`})}},[c]),{graph:e,traffic:n,status:i,loading:o,refresh:c,clearMesh:u,toggleMesh:(0,G.useCallback)(async e=>{try{let n=await U.post(`/mesh/toggle`,{enabled:e});a(t=>({...t,enabled:e,running:n.running,port:n.port})),e?(c(),l()):(t(null),r([]))}catch{}},[c,l])}}var Wt=`system.projectName`;function Gt(e){return typeof e==`string`?e.trim().replace(/\s+/g,` `):``}function Kt(e){let t=typeof e==`string`?e.trim().replace(/[\\/]+$/,``):``;return t?Gt(t.split(/[\\/]+/).filter(Boolean).at(-1)||``):``}function qt(e){return Gt((Array.isArray(e)?e:[]).find(e=>e?.id===Wt)?.value)}function Jt(e){let t=Gt(e);return t?`fifony: ${t}`:`fifony`}function Yt({savedProjectName:e=``,detectedProjectName:t=``}={}){let n=Gt(e),r=Gt(t),i=n||r;return{projectName:i,detectedProjectName:r,source:n?`saved`:r?`detected`:`missing`,requiresManualEntry:!i}}var Xt=Wt;function Zt(e,t={}){let n=qt(e),r=Gt(t?.detectedProjectName)||Kt(t?.sourceRepoUrl||t?.config?.sourceRepo||``),i=Gt(t?.projectName),a=t?.projectNameSource,o=Yt({savedProjectName:n,detectedProjectName:r}),s=o.projectName||i,c=o.source===`missing`?a===`saved`||a===`detected`?a:s?`detected`:`missing`:o.source;return{projectName:s,detectedProjectName:o.detectedProjectName,source:c,queueTitle:Jt(s)}}var K=C(),Qt=(0,G.createContext)(null),$t=[`all`,`info`,`state`,`progress`,`error`,`manual`,`runner`],en=new Set([`recent`,`all`]);function tn(){let e=(0,G.useContext)(Qt);if(!e)throw Error(`useDashboard must be used within DashboardProvider`);return e}function nn({children:e}){let t=rt(),[n,r]=at(),[i,a]=it(Je,`all`,{normalize:e=>e===`all`||ee.includes(e)?e:`all`}),[o,s]=it(Ye,`recent`,{normalize:e=>en.has(e)?e:`recent`}),[c,l]=(0,G.useState)(``),[u,d]=it(Xe,`all`,{normalize:e=>$t.includes(e)?e:`all`}),[f,p]=it(Ze,`all`,{normalize:e=>typeof e==`string`&&e.trim()?e:`all`}),[m,h]=(0,G.useState)(`3`),[g,_]=(0,G.useState)(null),[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(null),[C,T]=(0,G.useState)(!1),[E,D]=(0,G.useState)(null),[O,k]=(0,G.useState)(!1),[A,j]=(0,G.useState)([]),M=dt(),N=w(),P=je((0,G.useCallback)(e=>{if(e?.type===`service:log`){Mt(e.id,e.chunk);return}if(e?.type===`service`&&e.id){Pt(e);return}if(e?.type===`issue:log`){zt(e.id,e.chunk);return}if(e?.type===`mesh:entry`&&e.entry){Ht(e.entry);return}if(e?.type===`issue:transition`&&e.issue){N.setQueriesData({queryKey:[`runtime-state`]},t=>{if(!t||!Array.isArray(t.issues))return t;let n=t.issues.some(t=>t.id===e.issue.id)?t.issues.map(t=>t.id===e.issue.id?e.issue:t):[...t.issues,e.issue];return{...t,issues:n}});return}if(e?.type===`connected`||e?.type===`state:update`){Array.isArray(e.issues)&&N.setQueriesData({queryKey:[`runtime-state`]},t=>t&&{...t,issues:e.issues,metrics:e.metrics??t.metrics,milestones:e.milestones??t.milestones}),Array.isArray(e.events)&&j(e.events);return}if(e?.type===`state:delta`){let t=Array.isArray(e.issuesDelta)?e.issuesDelta:[],n=new Set(Array.isArray(e.issuesRemoved)?e.issuesRemoved:[]);if(t.length>0||n.size>0){let r=new Map(t.map(e=>[e.id,e]));N.setQueriesData({queryKey:[`runtime-state`]},i=>{if(!i)return i;let a=Array.isArray(i.issues)?i.issues:[],o=new Set(a.map(e=>e.id)),s=a.filter(e=>!n.has(e.id)).map(e=>r.has(e.id)?r.get(e.id):e);for(let e of t)o.has(e.id)||s.push(e);return{...i,issues:s,metrics:e.metrics??i.metrics,milestones:e.milestones??i.milestones}})}Array.isArray(e.events)&&j(e.events);return}Array.isArray(e?.events)&&j(e.events)},[N])),F=P===`connected`,I=Me({pollInterval:F?!1:3e3,showAll:o===`all`}),L=Ie(u,f,F?!1:2500),R=Le({pollInterval:F?!1:15e3}),z=Re({pollInterval:F?!1:15e3}),B=I.data||{},V=Array.isArray(B.issues)?B.issues:[],te=B.metrics||{},H=(0,G.useMemo)(()=>Zt(me(t.data),B),[t.data,B]),ne=F||B.config?`ok`:`offline`,re=F?A:L.data?.events||[],ie=(0,G.useMemo)(()=>E&&V.find(e=>e.id===E)||null,[E,V]),W=(0,G.useCallback)(e=>{D(e?.id||null)},[]),ae=(0,G.useMemo)(()=>{let e=c.toLowerCase();return V.filter(t=>!(i!==`all`&&t.state!==i||e&&!`${t.identifier} ${t.title} ${t.description||``}`.toLowerCase().includes(e)))},[V,i,c]),oe=(0,G.useMemo)(()=>[...new Set(V.map(e=>e.id))].sort(),[V]);(0,G.useEffect)(()=>{f!==`all`&&!oe.includes(f)&&p(`all`)},[f,oe,p]);let se=(0,G.useCallback)((e,t=`info`)=>{y(!1),_({message:typeof e==`string`?e:String(e),type:t}),setTimeout(()=>{y(!0),setTimeout(()=>{_(null),y(!1)},250)},3e3)},[]),ce=(0,G.useCallback)((e,t,n)=>{x({x:e??window.innerWidth/2,y:t??window.innerHeight/3,count:n??24})},[]),le=(0,G.useCallback)(()=>x(null),[]),ue=S({mutationFn:e=>U.post(`/issues/create`,e),onSuccess:e=>{e?.issue&&N.setQueriesData({queryKey:[`runtime-state`]},t=>{if(!t)return t;let n=Array.isArray(t.issues)?t.issues:[];return n.some(t=>t.id===e.issue.id)?t:{...t,issues:[...n,e.issue]}}),N.invalidateQueries({queryKey:[`runtime-state`]}),T(!1),se(`Issue created`,`success`),ce()},onError:e=>se(e.message,`error`)}),de=S({mutationFn:({id:e,state:t})=>U.post(`/issues/${encodeURIComponent(e)}/state`,{state:t}),onSuccess:()=>{N.invalidateQueries({queryKey:[`runtime-state`]}),se(`State updated`,`success`)},onError:e=>se(e.message,`error`)}),fe=S({mutationFn:({id:e,feedback:t})=>U.post(`/issues/${encodeURIComponent(e)}/retry`,t?{feedback:t}:void 0),onSuccess:()=>N.invalidateQueries({queryKey:[`runtime-state`]}),onError:e=>se(e.message)}),pe=S({mutationFn:e=>U.post(`/issues/${encodeURIComponent(e)}/cancel`),onSuccess:()=>N.invalidateQueries({queryKey:[`runtime-state`]}),onError:e=>se(e.message)}),he=S({mutationFn:e=>U.post(`/issues/${encodeURIComponent(e)}/delete`),onSuccess:()=>{N.invalidateQueries({queryKey:[`runtime-state`]}),se(`Issue deleted`,`success`)},onError:e=>se(e.message,`error`)}),ge=S({mutationFn:()=>U.post(`/refresh`,{}),onSuccess:()=>N.invalidateQueries(),onError:e=>se(e.message)}),_e=S({mutationFn:()=>U.post(`/config/concurrency`,{concurrency:parseInt(m,10)}),onSuccess:()=>{N.invalidateQueries({queryKey:[`runtime-state`]}),se(`Concurrency updated`,`success`)},onError:e=>se(e.message,`error`)});(0,G.useEffect)(()=>{B.config?.workerConcurrency&&h(String(B.config.workerConcurrency))},[B.config?.workerConcurrency]);let ve=(0,G.useCallback)(()=>k(e=>!e),[]),ye=kt(V),be=(0,G.useRef)(new Map);(0,G.useEffect)(()=>{let e=be.current;for(let t of V){let n=e.get(t.id);if(n&&n!==`Merged`&&t.state===`Merged`){let e=document.querySelector(`[data-issue-id="${t.id}"]`);if(e){let t=e.getBoundingClientRect();ce(t.left+t.width/2,t.top+t.height/2,12)}else ce(void 0,void 0,12)}}let t=new Map;for(let e of V)t.set(e.id,e.state);be.current=t},[V,ce]);let xe=(0,G.useMemo)(()=>({theme:n,setTheme:r,status:ne,wsStatus:P,liveMode:F,data:B,issues:V,filtered:ae,metrics:te,eventsData:re,providers:R,parallelism:z,projectName:H.projectName,queueTitle:H.queueTitle,issueOptions:oe,runtime:I,query:c,setQuery:l,stateFilter:i,setStateFilter:a,completionFilter:o,setCompletionFilter:s,isEventsOpen:O,toggleEvents:ve,setIsEventsOpen:k,eventKind:u,setEventKind:d,eventIssueId:f,setEventIssueId:p,isCreateOpen:C,setIsCreateOpen:T,createIssue:ue,selectedIssue:ie,setSelectedIssue:W,updateState:(e,t)=>de.mutate({id:e,state:t}),retryIssue:(e,t)=>fe.mutate({id:e,feedback:t}),cancelIssue:e=>pe.mutate(e),deleteIssue:e=>he.mutate(e),refresh:()=>ge.mutate(),concurrency:m,setConcurrency:h,saveConcurrency:()=>_e.mutate(),saveConcPending:_e.isPending,pwa:M,notifications:ye,toast:g,toastExiting:v,showToast:se,confetti:b,showConfetti:ce,clearConfetti:le}),[n,ne,P,F,B,V,ae,te,re,R,z,oe,I,H,c,i,o,O,u,f,C,ie,m,g,v,b,M,ye,r,l,a,s,ve,k,d,p,T,W,h,se,ce,le,ue,de,fe,pe,ge,_e]);return(0,K.jsx)(Qt.Provider,{value:xe,children:e})}function rn(e){if(typeof e==`boolean`)return e;if(typeof e==`number`)return e!==0;if(typeof e==`string`){let t=e.trim().toLowerCase();if([`true`,`1`,`yes`,`on`,`completed`].includes(t))return!0;if([`false`,`0`,`no`,`off`,``].includes(t))return!1}return!1}function an(e){return rn((Array.isArray(e)?e.find(e=>e?.id===`ui.onboarding.completed`):null)?.value)}var on=W(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),sn=W(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),cn=W(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),ln=W(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),un=W(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),dn=W(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),fn=W(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),pn=W(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),mn=W(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),hn=W(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),gn=W(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),_n=W(`bug`,[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]),vn=W(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),yn=W(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),bn=W(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),xn=W(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Sn=W(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Cn=W(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),wn=W(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),Tn=W(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),En=W(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),Dn=W(`circle-play`,[[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),On=W(`circle-x`,[[`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`}]]),kn=W(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),An=W(`clipboard-check`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]),jn=W(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Mn=W(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Nn=W(`coins`,[[`path`,{d:`M13.744 17.736a6 6 0 1 1-7.48-7.48`,key:`bq4yh3`}],[`path`,{d:`M15 6h1v4`,key:`11y1tn`}],[`path`,{d:`m6.134 14.768.866-.5 2 3.464`,key:`17snzx`}],[`circle`,{cx:`16`,cy:`8`,r:`6`,key:`14bfc9`}]]),Pn=W(`columns-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),Fn=W(`command`,[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]),In=W(`container`,[[`path`,{d:`M22 7.7c0-.6-.4-1.2-.8-1.5l-6.3-3.9a1.72 1.72 0 0 0-1.7 0l-10.3 6c-.5.2-.9.8-.9 1.4v6.6c0 .5.4 1.2.8 1.5l6.3 3.9a1.72 1.72 0 0 0 1.7 0l10.3-6c.5-.3.9-1 .9-1.5Z`,key:`1t2lqe`}],[`path`,{d:`M10 21.9V14L2.1 9.1`,key:`o7czzq`}],[`path`,{d:`m10 14 11.9-6.9`,key:`zm5e20`}],[`path`,{d:`M14 19.8v-8.1`,key:`159ecu`}],[`path`,{d:`M18 17.5V9.4`,key:`11uown`}]]),Ln=W(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Rn=W(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),zn=W(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),Bn=W(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Vn=W(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Hn=W(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),Un=W(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Wn=W(`flame`,[[`path`,{d:`M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4`,key:`1slcih`}]]),Gn=W(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),Kn=W(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),qn=W(`folder-root`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`circle`,{cx:`12`,cy:`13`,r:`2`,key:`1c1ljs`}],[`path`,{d:`M12 15v5`,key:`11xva1`}]]),Jn=W(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Yn=W(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),Xn=W(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),Zn=W(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),Qn=W(`git-merge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),$n=W(`git-pull-request-arrow`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M5 9v12`,key:`ih889a`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}]]),er=W(`git-pull-request`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]),tr=W(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),nr=W(`hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),rr=W(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),ir=W(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),ar=W(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),or=W(`inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]),sr=W(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),cr=W(`kanban`,[[`path`,{d:`M5 3v14`,key:`9nsxs2`}],[`path`,{d:`M12 3v8`,key:`1h2ygw`}],[`path`,{d:`M19 3v18`,key:`1sk56x`}]]),lr=W(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),ur=W(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),dr=W(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),fr=W(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),pr=W(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),mr=W(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),hr=W(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),q=W(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),gr=W(`loader`,[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]),_r=W(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),vr=W(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),yr=W(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),br=W(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),xr=W(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),Sr=W(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]),Cr=W(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),wr=W(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),Tr=W(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),Er=W(`pencil-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),Dr=W(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),Or=W(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),kr=W(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Ar=W(`radio`,[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),jr=W(`refresh-ccw`,[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]),Mr=W(`refresh-cw`,[[`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`}]]),Nr=W(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]),Pr=W(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Fr=W(`route`,[[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}],[`path`,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,key:`1d8sl`}],[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}]]),Ir=W(`scan`,[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}]]),Lr=W(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Rr=W(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),zr=W(`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`}]]),Br=W(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Vr=W(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Hr=W(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),Ur=W(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),Wr=W(`sliders-vertical`,[[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M12 21v-9`,key:`17s77i`}],[`path`,{d:`M12 8V3`,key:`13r4qs`}],[`path`,{d:`M17 16h4`,key:`h1uq16`}],[`path`,{d:`M19 12V3`,key:`o1uvq1`}],[`path`,{d:`M19 21v-5`,key:`qua636`}],[`path`,{d:`M3 14h4`,key:`bcjad9`}],[`path`,{d:`M5 10V3`,key:`cb8scm`}],[`path`,{d:`M5 21v-7`,key:`1w1uti`}]]),Gr=W(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),Kr=W(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),qr=W(`square-check-big`,[[`path`,{d:`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,key:`2acyp4`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),Jr=W(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Yr=W(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),Xr=W(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),Zr=W(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),Qr=W(`thumbs-up`,[[`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`,key:`emmmcr`}],[`path`,{d:`M7 10v12`,key:`1qc93n`}]]),$r=W(`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`}]]),ei=W(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),ti=W(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]),ni=W(`triangle-alert`,[[`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-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),ri=W(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),ii=W(`volume-2`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]),ai=W(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),oi=W(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),si=W(`wifi`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M2 8.82a15 15 0 0 1 20 0`,key:`dnpr2z`}],[`path`,{d:`M5 12.859a10 10 0 0 1 14 0`,key:`1x1e6c`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}]]),ci=W(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),li=W(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),ui=W(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),di=[{to:`/chat`,label:`Chat`,icon:_r},{to:`/kanban`,label:`Kanban`,icon:cr},{to:`/issues`,label:`Issues`,icon:mr},{to:`/agents`,label:`Agents`,icon:hn},{to:`/analytics`,label:`Analytics`,icon:ti},{to:`/services`,label:`Services`,icon:zr},{to:`/settings`,label:`Settings`,icon:Wr}];function fi({status:e}){return e===`connected`?(0,K.jsxs)(`span`,{className:`relative flex size-2`,children:[(0,K.jsx)(`span`,{className:`animate-ping absolute inline-flex h-full w-full rounded-full bg-success opacity-50`}),(0,K.jsx)(`span`,{className:`relative inline-flex rounded-full size-2 bg-success`})]}):e===`connecting`?(0,K.jsxs)(`span`,{className:`flex items-center gap-0.5 dot-pulse-group`,children:[(0,K.jsx)(`span`,{className:`size-1 rounded-full bg-info`}),(0,K.jsx)(`span`,{className:`size-1 rounded-full bg-info`}),(0,K.jsx)(`span`,{className:`size-1 rounded-full bg-info`})]}):(0,K.jsx)(`span`,{className:`size-2 rounded-full bg-warning animate-pulse-soft`})}function pi({navRef:e,currentPath:t}){let[n,r]=(0,G.useState)({left:0,width:0,opacity:0}),i=(0,G.useCallback)(()=>{if(!e.current)return;let t=e.current.querySelector(`a.active`);if(!t){r(e=>({...e,opacity:0}));return}let n=e.current.getBoundingClientRect(),i=t.getBoundingClientRect();r({left:i.left-n.left,width:i.width,opacity:1})},[e]);return(0,G.useLayoutEffect)(i,[t,i]),(0,G.useEffect)(()=>(window.addEventListener(`resize`,i),()=>window.removeEventListener(`resize`,i)),[i]),(0,K.jsx)(`div`,{className:`nav-indicator`,style:n})}function mi(e){if(!e)return null;let t=e.replace(/\/+$/,``).split(`/`).pop();return!t||t===e?e:t}function hi({issueCount:e,sourceRepo:t,queueTitle:n,updatedAt:r,wsStatus:i,issues:a}){let o=P().location.pathname,s=(0,G.useRef)(null),c=mi(t),l=n||`fifony`,u=c&&l!==Jt(c)?c:null;return(0,K.jsxs)(`div`,{className:`navbar bg-base-100 shadow-sm px-4`,children:[(0,K.jsx)(`div`,{className:`flex-1 min-w-0 gap-2`,children:(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(b,{to:`/`,className:`btn btn-ghost px-2 text-lg sm:text-xl font-bold tracking-tight max-w-full`,title:l,style:{fontFamily:`'Space Grotesk', system-ui, sans-serif`,letterSpacing:`-0.02em`,fontWeight:800},children:(0,K.jsx)(`span`,{className:`truncate`,children:l})}),u&&(0,K.jsx)(`div`,{className:`text-xs opacity-40 hidden lg:block truncate px-2`,children:u})]})}),(0,K.jsx)(`div`,{className:`flex-none hidden md:flex`,children:(0,K.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,K.jsx)(`ul`,{className:`menu menu-horizontal px-1 gap-1`,children:di.map(({to:e,label:t,icon:n})=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(b,{to:e,className:`nav-link ${o.startsWith(e)?`active nav-link-active`:``}`,children:[(0,K.jsx)(n,{className:`size-4`}),t]})},e))}),(0,K.jsx)(pi,{navRef:s,currentPath:o})]})}),(0,K.jsx)(`div`,{className:`flex-none`,children:(0,K.jsx)(`ul`,{className:`menu menu-horizontal px-1 items-center gap-0`,children:(0,K.jsx)(`li`,{className:`hidden md:flex`,children:(0,K.jsx)(`span`,{className:`tooltip tooltip-bottom py-1 px-2`,"data-tip":`Live: ${i}`,children:(0,K.jsx)(`span`,{className:`inline-flex h-6 w-6 items-center justify-center rounded-full border border-base-content/10 bg-base-200/70`,children:(0,K.jsx)(fi,{status:i})})})})})})]})}function gi({onClick:e}){let[t,n]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{let e=setTimeout(()=>n(!0),300);return()=>clearTimeout(e)},[]),(0,K.jsxs)(`button`,{className:`fixed right-6 z-30 btn btn-circle btn-lg btn-primary shadow-lg hover:scale-110 hover:rotate-90 active:scale-95 active:rotate-0 transition-all duration-300 group ${t?`animate-fab-breathe`:`animate-bounce-in`}`,style:{bottom:`calc(env(safe-area-inset-bottom, 0px) + 6rem)`},onClick:e,"aria-label":`Create new issue`,children:[(0,K.jsx)(kr,{className:`size-6 transition-transform duration-300 group-hover:rotate-90`}),(0,K.jsx)(`span`,{className:`absolute -top-8 right-0 text-xs bg-base-300 text-base-content px-2 py-1 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap shadow-md`,children:`New Issue`})]})}function _i(){let e=P().location.pathname;return(0,K.jsx)(`div`,{className:`dock md:hidden`,children:di.map(({to:t,label:n,icon:r})=>{let i=e.startsWith(t);return(0,K.jsxs)(b,{to:t,className:i?`dock-active`:void 0,children:[(0,K.jsx)(r,{className:`size-[1.2em] transition-transform duration-200 ${i?`scale-110`:``}`}),(0,K.jsx)(`span`,{className:`dock-label`,children:n})]},t)})})}var vi=typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;function yi({onDismiss:e,direction:t=`right`,threshold:n=80}){let r=(0,G.useRef)(null),i=(0,G.useRef)(null),a=(0,G.useRef)(!1),o=t===`right`||t===`left`,s=t===`right`||t===`down`?1:-1;return{ref:r,handlers:{onTouchStart:(0,G.useCallback)(e=>{if(e.touches.length!==1)return;let n=r.current;if(n&&t===`right`&&n.scrollLeft>0||n&&t===`down`&&n.scrollTop>0)return;let o=e.touches[0];i.current={x:o.clientX,y:o.clientY},a.current=!1},[t]),onTouchMove:(0,G.useCallback)(e=>{if(!i.current)return;let t=e.touches[0],n=t.clientX-i.current.x,c=t.clientY-i.current.y,l=o?n*s:c*s,u=Math.abs(o?c:n);if(!a.current&&u>Math.abs(o?n:c)){i.current=null;return}if(!a.current){if(l<10)return;a.current=!0}let d=Math.max(0,l),f=r.current;if(!f||vi)return;let p=o?`translateX`:`translateY`;f.style.transform=`${p}(${d}px)`,f.style.opacity=String(Math.max(.3,1-d/300)),f.style.transition=`none`},[o,s]),onTouchEnd:(0,G.useCallback)(()=>{if(!i.current)return;let t=r.current;if(i.current=null,!t){a.current=!1;return}let s=t.style.transform.match(/([-\d.]+)px/);if((s?parseFloat(s[1]):0)>n){let n=o?`translateX`:`translateY`;t.style.transition=`transform 0.2s ease-out, opacity 0.2s ease-out`,t.style.transform=`${n}(100%)`,t.style.opacity=`0`,setTimeout(()=>e(),200)}else t.style.transition=`transform 0.3s cubic-bezier(0.34, 1.3, 0.64, 1), opacity 0.3s ease`,t.style.transform=``,t.style.opacity=``;a.current=!1},[n,o,e])}}}var bi=typeof window<`u`?window.SpeechRecognition||window.webkitSpeechRecognition:null;function xi({language:e=`pt-BR`}={}){let[t,n]=(0,G.useState)(!1),[r,i]=(0,G.useState)(``),a=(0,G.useRef)(null),o=(0,G.useRef)(!1),s=(0,G.useRef)(``),c=!!bi&&typeof window<`u`&&window.isSecureContext,l=(0,G.useCallback)(()=>{let e=a.current;if(e){e.onresult=null,e.onend=null,e.onerror=null,e.onstart=null;try{e.abort()}catch{}a.current=null}},[]),u=(0,G.useCallback)(()=>{if(!bi)return;l(),o.current=!0,s.current=``,i(``),n(!0);function t(){if(!o.current)return;let r=new bi;r.lang=e,r.interimResults=!0,r.continuous=!1,r.maxAlternatives=1,a.current=r,r.onresult=e=>{let t=``,n=``;for(let r=0;r<e.results.length;r++){let i=e.results[r];i.isFinal?n+=i[0].transcript:t+=i[0].transcript}let r=s.current;i((r+(r&&(n||t)?` `:``)+n+(t?(n?` `:``)+t:``)).trimStart())},r.onerror=e=>{e.error===`no-speech`||e.error===`aborted`||(e.error===`not-allowed`||e.error===`service-not-allowed`)&&(o.current=!1,n(!1))},r.onend=()=>{if(a.current=null,!o.current){n(!1);return}i(e=>(s.current=e,e)),setTimeout(t,300)};try{r.start()}catch{o.current&&setTimeout(t,500)}}t()},[l,e]),d=(0,G.useCallback)(()=>{o.current=!1,l(),n(!1)},[l]);return(0,G.useEffect)(()=>()=>{o.current=!1,l()},[l]),{supported:c,listening:t,transcript:r,start:u,stop:d}}var Si=24;function Ci(e){let[t,n]=(0,G.useState)(()=>Array(Si).fill(0)),[r,i]=(0,G.useState)(0),a=(0,G.useRef)(null),o=(0,G.useRef)(null),s=(0,G.useRef)(null),c=(0,G.useRef)(null),l=(0,G.useRef)(null),u=(0,G.useRef)(!1),d=(0,G.useCallback)(()=>{s.current&&cancelAnimationFrame(s.current),l.current&&clearInterval(l.current),o.current&&=(o.current.getTracks().forEach(e=>e.stop()),null),a.current&&a.current.state!==`closed`&&(a.current.close().catch(()=>{}),a.current=null),s.current=null,l.current=null,c.current=null,u.current=!1,n(Array(Si).fill(0)),i(0)},[]);return(0,G.useEffect)(()=>{if(!e){d();return}let t=!1;return c.current=Date.now(),l.current=setInterval(()=>{c.current&&i(Math.floor((Date.now()-c.current)/1e3))},1e3),(async()=>{let e=!0;try{if(navigator.mediaDevices?.getUserMedia){let r=await navigator.mediaDevices.getUserMedia({audio:!0});if(t){r.getTracks().forEach(e=>e.stop());return}o.current=r;let i=new(window.AudioContext||window.webkitAudioContext);a.current=i,i.state===`suspended`&&await i.resume();let c=i.createMediaStreamSource(r),l=i.createAnalyser();l.fftSize=64,l.smoothingTimeConstant=.7,c.connect(l);let u=new Uint8Array(l.frequencyBinCount);e=!1;function d(){if(t)return;l.getByteFrequencyData(u);let e=u.length,r=Math.max(1,Math.floor(e/Si)),i=[];for(let t=0;t<Si;t++)i.push(u[Math.min(t*r,e-1)]/255);n(i),s.current=requestAnimationFrame(d)}s.current=requestAnimationFrame(d)}}catch{}if(e&&!t){u.current=!0;let e=Array.from({length:Si},()=>Math.random()*Math.PI*2),r=Array.from({length:Si},()=>2+Math.random()*4),i=Array.from({length:Si},(e,t)=>{let n=Si/2,r=Math.abs(t-n)/n;return .3+.5*(1-r*r)});function a(){if(t)return;let o=Date.now()/1e3;n(e.map((e,t)=>{let n=Math.sin(o*r[t]+e)*.3+.5,a=Math.sin(o*13.7+t*2.1)*.1;return Math.max(.05,Math.min(1,i[t]*n+a))})),s.current=requestAnimationFrame(a)}s.current=requestAnimationFrame(a)}})(),()=>{t=!0,d()}},[e,d]),{bars:t,elapsed:r}}function wi(e){let t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,`0`)}`}function Ti({active:e,onStop:t}){let{bars:n,elapsed:r}=Ci(e);return e?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-error/8 border border-error/20 animate-fade-in`,children:[(0,K.jsx)(`div`,{className:`size-2 rounded-full bg-error animate-pulse shrink-0`}),(0,K.jsx)(`span`,{className:`font-mono text-xs text-error tabular-nums w-8 shrink-0`,children:wi(r)}),(0,K.jsx)(`div`,{className:`flex items-center gap-px flex-1 h-6`,children:n.map((e,t)=>(0,K.jsx)(`div`,{className:`flex-1 rounded-full bg-error/60 transition-[height] duration-75`,style:{height:`${Math.max(8,e*100)}%`,minWidth:2,maxWidth:4}},t))}),(0,K.jsxs)(`button`,{type:`button`,className:`btn btn-xs btn-error btn-soft gap-1 shrink-0`,onClick:t,children:[(0,K.jsx)(Jr,{className:`size-2.5 fill-current`}),`Stop`]})]}):null}var Ei=[{id:`blank`,label:`Blank`,icon:Un,activeColor:`border-base-content/30 bg-base-content/5 text-base-content`,title:``,description:``},{id:`bug`,label:`Bug Fix`,icon:_n,activeColor:`border-error/50 bg-error/8 text-error`,title:`fix: `,description:`## Problem
3
+
4
+ ## Expected Behavior
5
+
6
+ ## Steps to Reproduce
7
+
8
+ `},{id:`feature`,label:`Feature`,icon:Kr,activeColor:`border-primary/50 bg-primary/8 text-primary`,title:`feat: `,description:`## Goal
9
+
10
+ ## Acceptance Criteria
11
+
12
+ ## Notes
13
+
14
+ `},{id:`refactor`,label:`Refactor`,icon:Mr,activeColor:`border-warning/50 bg-warning/8 text-warning`,title:`refactor: `,description:`## Current State
15
+
16
+ ## Desired State
17
+
18
+ ## Scope
19
+
20
+ `},{id:`docs`,label:`Docs`,icon:mn,activeColor:`border-info/50 bg-info/8 text-info`,title:`docs: `,description:`## What to Document
21
+
22
+ ## Target Audience
23
+
24
+ `},{id:`chore`,label:`Chore`,icon:ci,activeColor:`border-secondary/50 bg-secondary/8 text-secondary`,title:`chore: `,description:`## Task
25
+
26
+ ## Why Now
27
+
28
+ `}];function Di({open:e,onClose:t,onSubmit:n,isLoading:r,onToast:i,defaultValues:a}){let[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(``),[u,d]=(0,G.useState)(`blank`),[f,p]=(0,G.useState)({title:!1,description:!1}),[m,h]=(0,G.useState)([]),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(null),b=(0,G.useRef)(null),x=(0,G.useRef)(null),S=(0,G.useRef)(null),C=(0,G.useRef)(null),w=xi({language:`pt-BR`}),T=w.supported,E=(0,G.useRef)({before:``,after:``}),D=(0,G.useCallback)(e=>{if(w.listening&&v===e){w.stop(),y(null);return}w.listening&&w.stop();let t=e===`title`?b.current:x.current,n=e===`title`?o:c,r=t?.selectionStart??n.length;E.current={before:n.slice(0,r),after:n.slice(r)},y(e),w.start()},[w,v,o,c]);(0,G.useEffect)(()=>{if(!v||!w.transcript)return;let{before:e,after:t}=E.current,n=`${e}${e.length>0&&!e.endsWith(` `)&&!e.endsWith(`
29
+ `)?` `:``}${w.transcript}${t?(t.startsWith(` `)||t.startsWith(`
30
+ `)?``:` `)+t:``}`;v===`title`?s(n):l(n)},[w.transcript,v]),(0,G.useEffect)(()=>{!e&&w.listening&&(w.stop(),y(null))},[e,w]);let O=(0,G.useCallback)(e=>{let t=Ei.find(t=>t.id===e);t&&(d(e),s(t.title),l(t.description),setTimeout(()=>b.current?.focus(),50))},[]),{ref:k,handlers:A}=yi({onDismiss:(0,G.useCallback)(()=>t(),[t]),direction:`right`});(0,G.useEffect)(()=>{e&&(s(a?.title??``),l(a?.description??``),d(a?.issueType??`blank`),h([]),setTimeout(()=>b.current?.focus(),100))},[e]),(0,G.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]);let j=(0,G.useCallback)(async e=>{if(e.length){_(!0);try{let t=await Promise.all(e.map(e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t({name:e.name,data:r.result.split(`,`)[1],type:e.type,preview:r.result}),r.onerror=n,r.readAsDataURL(e)}))),n=await U.post(`/attachments/upload`,{files:t.map(({name:e,data:t,type:n})=>({name:e,data:t,type:n}))});if(n.ok&&n.paths){let r=n.paths.map((n,r)=>({name:e[r]?.name??n,preview:t[r]?.preview,path:n}));h(e=>[...e,...r])}else i?.(n.error||`Upload failed`,`error`)}catch{i?.(`Upload failed`,`error`)}finally{_(!1),C.current&&(C.current.value=``)}}},[i]);(0,G.useEffect)(()=>{if(!e)return;let t=e=>{let t=Array.from(e.clipboardData?.items??[]).filter(e=>e.kind===`file`&&e.type.startsWith(`image/`)).map(e=>e.getAsFile()).filter(Boolean);t.length&&j(t)};return window.addEventListener(`paste`,t),()=>window.removeEventListener(`paste`,t)},[e,j]);let M=e=>j(Array.from(e.target.files??[])),N=e=>{e.preventDefault(),o.trim()&&n({title:o.trim(),description:c.trim(),issueType:u===`blank`?void 0:u,images:m.map(e=>e.path)})},P=async e=>{if(!(!o.trim()&&e===`description`)){p(t=>({...t,[e]:!0}));try{let t=await U.post(`/issues/enhance`,{field:e,title:o.trim(),description:c.trim(),issueType:u,images:m.map(e=>e.path)});if(t.ok&&typeof t.value==`string`&&t.value.trim())e===`title`?s(t.value.trim()):l(t.value.trim()),i?.(`Enhanced ${e}`,`success`);else throw Error(t.error||`No enhanced value returned.`)}catch(e){i?.(e instanceof Error?e.message:`Enhance failed`,`error`)}finally{p(t=>({...t,[e]:!1}))}}};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/30 z-40 transition-opacity duration-200 ${e?`opacity-100`:`opacity-0 pointer-events-none`}`,onClick:t}),(0,K.jsx)(`div`,{ref:k,className:`fixed top-0 right-0 h-full z-50 bg-base-100 shadow-2xl transition-transform duration-300 ease-out
31
+ w-full md:w-[480px] ${e?`translate-x-0`:`translate-x-full`}`,...A,children:(0,K.jsxs)(`form`,{onSubmit:N,className:`flex flex-col h-full`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 sm:px-6 py-3 sm:py-4 border-b border-base-300 shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(dr,{className:`size-5 opacity-60`}),(0,K.jsx)(`h2`,{className:`text-lg font-bold`,children:`New Issue`})]}),(0,K.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost btn-circle`,onClick:t,children:(0,K.jsx)(li,{className:`size-4`})})]}),(0,K.jsxs)(`div`,{ref:S,className:`flex-1 overflow-y-auto px-4 sm:px-6 py-4 sm:py-6 flex flex-col gap-4 drawer-safe-bottom ${e?`stagger-children`:``}`,children:[(0,K.jsx)(`div`,{className:`flex flex-wrap sm:grid sm:grid-cols-3 gap-1.5`,children:Ei.map(e=>{let t=e.icon;return(0,K.jsxs)(`button`,{type:`button`,onClick:()=>O(e.id),className:`flex items-center gap-1.5 px-2.5 py-1.5 sm:py-2 rounded-lg border text-left transition-all duration-150 text-xs sm:text-sm font-medium ${u===e.id?e.activeColor:`border-base-300 text-base-content/50 hover:border-base-content/20 hover:text-base-content/70 hover:bg-base-200/50`}`,children:[(0,K.jsx)(t,{className:`size-3 sm:size-3.5 shrink-0`}),e.label]},e.id)})}),(0,K.jsxs)(`div`,{className:`form-control`,children:[(0,K.jsx)(`label`,{className:`label pb-1`,children:(0,K.jsx)(`span`,{className:`label-text font-medium`,children:`What needs to be done?`})}),(0,K.jsx)(`input`,{ref:b,className:`input input-bordered w-full ${w.listening&&v===`title`?`border-error/50 bg-error/5`:``}`,placeholder:w.listening&&v===`title`?`Listening... speak now`:`Fix the login redirect bug`,value:o,onChange:e=>s(e.target.value),required:!0}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 mt-1.5`,children:[T&&(0,K.jsxs)(`button`,{type:`button`,className:`btn btn-xs gap-1 ${w.listening&&v===`title`?`btn-error`:`btn-ghost opacity-50 hover:opacity-100`}`,onClick:()=>D(`title`),children:[w.listening&&v===`title`?(0,K.jsx)(vr,{className:`size-3`}):(0,K.jsx)(yr,{className:`size-3`}),w.listening&&v===`title`?`Stop`:`Dictate`]}),(0,K.jsxs)(`button`,{type:`button`,className:`btn btn-xs btn-soft btn-secondary gap-1`,onClick:()=>P(`title`),disabled:f.title||r||!o.trim(),children:[f.title?(0,K.jsx)(q,{className:`size-3 animate-spin`}):(0,K.jsx)(Kr,{className:`size-3`}),`Enhance`]})]}),(0,K.jsx)(Ti,{active:w.listening&&v===`title`,onStop:()=>D(`title`)})]}),(0,K.jsxs)(`div`,{className:`form-control`,children:[(0,K.jsx)(`label`,{className:`label pb-1`,children:(0,K.jsx)(`span`,{className:`label-text font-medium`,children:`Context & details`})}),(0,K.jsx)(`textarea`,{ref:x,className:`textarea textarea-bordered w-full min-h-32 sm:min-h-40 resize-none ${w.listening&&v===`description`?`border-error/50 bg-error/5`:``}`,placeholder:w.listening&&v===`description`?`Listening... speak now`:`Describe the problem, expected behavior, acceptance criteria...`,value:c,onChange:e=>l(e.target.value)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 mt-1.5`,children:[T&&(0,K.jsxs)(`button`,{type:`button`,className:`btn btn-xs gap-1 ${w.listening&&v===`description`?`btn-error`:`btn-ghost opacity-50 hover:opacity-100`}`,onClick:()=>D(`description`),children:[w.listening&&v===`description`?(0,K.jsx)(vr,{className:`size-3`}):(0,K.jsx)(yr,{className:`size-3`}),w.listening&&v===`description`?`Stop`:`Dictate`]}),(0,K.jsxs)(`button`,{type:`button`,className:`btn btn-xs btn-soft btn-secondary gap-1`,onClick:()=>P(`description`),disabled:f.description||r||!o.trim(),children:[f.description?(0,K.jsx)(q,{className:`size-3 animate-spin`}):(0,K.jsx)(Kr,{className:`size-3`}),`Enhance`]})]}),(0,K.jsx)(Ti,{active:w.listening&&v===`description`,onStop:()=>D(`description`)})]}),(0,K.jsxs)(`div`,{className:`form-control`,children:[(0,K.jsxs)(`label`,{className:`label justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`label-text font-medium`,children:`Screenshots & Evidence`}),(0,K.jsxs)(`button`,{type:`button`,className:`btn btn-xs btn-soft btn-ghost gap-1`,onClick:()=>C.current?.click(),disabled:g,children:[g?(0,K.jsx)(q,{className:`size-3 animate-spin`}):(0,K.jsx)(Tr,{className:`size-3`}),`Attach`]})]}),(0,K.jsx)(`input`,{ref:C,type:`file`,multiple:!0,accept:`image/*`,className:`hidden`,onChange:M}),m.length>0&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2 mt-1`,children:m.map((e,t)=>(0,K.jsxs)(`div`,{className:`relative group`,children:[e.preview?(0,K.jsx)(`img`,{src:e.preview,alt:e.name,className:`size-16 object-cover rounded-lg border border-base-300`}):(0,K.jsx)(`div`,{className:`size-16 rounded-lg border border-base-300 bg-base-200 flex items-center justify-center`,children:(0,K.jsx)(ar,{className:`size-5 opacity-40`})}),(0,K.jsx)(`button`,{type:`button`,className:`absolute -top-1.5 -right-1.5 size-4 rounded-full bg-error text-error-content flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity`,onClick:()=>h(e=>e.filter((e,n)=>n!==t)),children:(0,K.jsx)(li,{className:`size-2.5`})})]},t))})]}),(0,K.jsxs)(`div`,{className:`bg-base-200 rounded-box p-3 text-xs opacity-60 space-y-1`,children:[(0,K.jsxs)(`p`,{children:[`The issue will be created in `,(0,K.jsx)(`strong`,{children:`Planning`}),` state.`]}),(0,K.jsx)(`p`,{children:`Open it to generate an AI plan, review it, then approve to start execution.`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-4 sm:px-6 py-3 sm:py-4 border-t border-base-300 shrink-0 max-sm:flex-col-reverse`,style:{paddingBottom:`calc(env(safe-area-inset-bottom, 0px) + 0.75rem)`},children:[(0,K.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm sm:btn-md max-sm:w-full`,onClick:t,children:`Cancel`}),(0,K.jsxs)(`button`,{type:`submit`,className:`btn btn-primary btn-sm sm:btn-md gap-1.5 max-sm:w-full`,disabled:r||!o.trim(),children:[r?(0,K.jsx)(q,{className:`size-4 animate-spin`}):(0,K.jsx)(dr,{className:`size-4`}),r?`Creating...`:`Create Issue`]})]})]})})]})}function Oi({onClick:e,hideOnDesktop:t=!1,className:n=``}){return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/30 z-40 ${t?`lg:hidden`:``} ${n}`,onClick:e})}function ki({children:e,closing:t=!1,width:n=`w-full md:w-[40vw] md:min-w-[520px] lg:min-w-[600px]`,className:r=``,...i}){return(0,K.jsx)(`div`,{className:`fixed top-0 right-0 z-50 h-full ${n} bg-base-100 shadow-2xl flex flex-col border-l border-base-300 ${t?`animate-slide-out-right`:`animate-slide-in-right`} ${r}`,...i,children:e})}var Ai=`runtime.workflowConfig`;function ji(e){return!!e&&typeof e==`object`&&typeof e.provider==`string`&&typeof e.model==`string`&&typeof e.effort==`string`}function Mi(e){let t=he(me(e),Ai,null);return!t||typeof t!=`object`?null:ji(t.plan)&&ji(t.execute)&&ji(t.review)?t:null}function Ni(){let e=Mi(rt().data),t=j({queryKey:[`workflow-config`],queryFn:()=>U.get(`/config/workflow`),enabled:!e,staleTime:6e4});return{...t,data:e?{ok:!0,workflow:e,isDefault:!1}:t.data}}var Pi={Planning:dr,PendingApproval:kn,Queued:pr,Running:Dn,Reviewing:Vn,PendingDecision:Tn,Blocked:ni,Approved:Tn,Merged:Qn,Cancelled:On,Archived:On},Fi={Planning:`text-info`,PendingApproval:`text-warning`,Queued:`text-info`,Running:`text-primary`,Reviewing:`text-secondary`,PendingDecision:`text-success`,Blocked:`text-error`,Approved:`text-success`,Merged:`text-success`,Cancelled:`text-neutral`,Archived:`text-neutral`},Ii={Planning:`badge-info`,PendingApproval:`badge-warning`,Queued:`badge-info`,Running:`badge-primary`,Reviewing:`badge-secondary`,PendingDecision:`badge-success`,Blocked:`badge-error`,Approved:`badge-success`,Merged:`badge-success`,Cancelled:`badge-neutral`,Archived:`badge-neutral`},Li={Planning:`bg-info/10 border-info/30`,PendingApproval:`bg-warning/10 border-warning/30`,Queued:`bg-info/10 border-info/30`,Running:`bg-primary/10 border-primary/30`,Reviewing:`bg-secondary/10 border-secondary/30`,PendingDecision:`bg-success/10 border-success/30`,Blocked:`bg-error/10 border-error/30`,Approved:`bg-success/10 border-success/30`,Merged:`bg-success/10 border-success/30`,Cancelled:`bg-neutral/10 border-neutral/30`,Archived:`bg-neutral/10 border-neutral/30`},Ri={bug:`badge-error`,feature:`badge-primary`,refactor:`badge-warning`,docs:`badge-info`,chore:`badge-secondary`},zi=[{id:`overview`,label:`Overview`,icon:sr,color:`text-info`,activeColor:`tab-active text-info`},{id:`planning`,label:`Plan`,icon:dr,color:`text-primary`,activeColor:`tab-active text-primary`},{id:`execution`,label:`Execution`,icon:Zr,color:`text-secondary`,activeColor:`tab-active text-secondary`},{id:`review`,label:`Review`,icon:An,color:`text-success`,activeColor:`tab-active text-success`},{id:`diff`,label:`Diff`,icon:Mn,color:`text-warning`,activeColor:`tab-active text-warning`},{id:`sessions`,label:`Sessions`,icon:Rn,color:`text-primary`,activeColor:`tab-active text-primary`},{id:`routing`,label:`Routing`,icon:Fr,color:`text-accent`,activeColor:`tab-active text-accent`},{id:`events`,label:`Events`,icon:on,color:`text-error`,activeColor:`tab-active text-error`}];function Bi(e){return e===`Planning`||e===`PendingApproval`?`planning`:e===`Reviewing`||e===`PendingDecision`||e===`Cancelled`||e===`Blocked`?`review`:`overview`}function Vi(e){return{PendingApproval:0,Queued:1,Running:2,Reviewing:2,PendingDecision:3,Blocked:3,Approved:4,Merged:5,Cancelled:4}[e]??0}var Hi=[{key:`plan`,label:`Plan`,icon:dr,states:[`Planning`]},{key:`execute`,label:`Execute`,icon:Dn,states:[`PendingApproval`,`Queued`,`Running`]},{key:`review`,label:`Review`,icon:Vn,states:[`Reviewing`,`PendingDecision`]},{key:`ship`,label:`Ship`,icon:Qn,states:[`Approved`,`Merged`]}];function Ui(e){return e.state===`Cancelled`?-1:e.state===`Merged`||e.state===`Approved`?3:e.state===`Reviewing`||e.state===`PendingDecision`?2:[`Running`,`Queued`,`PendingApproval`].includes(e.state)?1:e.state===`Blocked`?e.tokensByPhase?.reviewer?.totalTokens>0?2:1:(e.state,0)}function Wi({issue:e}){let t=Ui(e),n=!!e.mergedAt||e.state===`Merged`;if(e.state===`Cancelled`)return null;let r=Hi[t],i=n?`Shipped`:r?.label;return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5`,children:[i&&(0,K.jsx)(`span`,{className:`text-[10px] shrink-0 font-medium ${n?`text-success`:`text-primary opacity-70`}`,children:i}),(0,K.jsx)(`div`,{className:`flex items-center flex-1 gap-0`,children:Hi.map((e,r)=>{let i=r<t||r===t&&n,a=r===t&&!n;return(0,K.jsxs)(G.Fragment,{children:[r>0&&(0,K.jsx)(`div`,{className:`flex-1 h-px transition-colors duration-300 ${i?`bg-success`:a?`bg-primary/30`:`bg-base-300`}`}),(0,K.jsx)(`div`,{title:e.label,className:[`size-2 rounded-full transition-all duration-300 shrink-0`,i?`bg-success`:``,a?`bg-primary ring-2 ring-primary/25 scale-[1.4]`:``,!i&&!a?`bg-base-300`:``].filter(Boolean).join(` `)})]},e.key)})})]})}var Gi={"Planning→PendingApproval":{label:`Submit Plan`,icon:Tn},"Planning→Cancelled":{label:`Cancel`,icon:On,danger:!0,handler:`cancel`},"PendingApproval→Queued":{label:`Execute`,icon:Dn,shortcut:`⌃↵`,handler:`execute`},"PendingApproval→Planning":{label:`Replan`,icon:Pr,shortcut:`⌃P`,handler:`replan`},"PendingApproval→Cancelled":{label:`Cancel`,icon:On,danger:!0,handler:`cancel`},"Running→Reviewing":{label:`Force Complete`,icon:Vn},"Running→Queued":{label:`Re-queue`,icon:pr},"Running→Blocked":{label:`Mark Blocked`,icon:ni,warning:!0},"Reviewing→PendingDecision":{label:`Force Complete`,icon:Vn},"Reviewing→Queued":{label:`Re-queue`,icon:pr},"Reviewing→Blocked":{label:`Mark Blocked`,icon:ni,warning:!0},"PendingDecision→Approved":{label:`Approve`,icon:Tn,shortcut:`⌃A`},"PendingDecision→Queued":{label:`Request Rework`,icon:Pr,shortcut:`⌃W`,handler:`retry`},"PendingDecision→Planning":{label:`Replan`,icon:Pr,shortcut:`⌃P`,handler:`replan`},"PendingDecision→Cancelled":{label:`Cancel`,icon:On,danger:!0,handler:`cancel`},"Blocked→Queued":{label:`Retry`,icon:Pr,shortcut:`⌃↵`,handler:`retry`},"Blocked→Reviewing":{label:`Force Review`,icon:Vn},"Blocked→Planning":{label:`Replan`,icon:Pr,shortcut:`⌃P`,handler:`replan`},"Blocked→Cancelled":{label:`Cancel`,icon:On,danger:!0,handler:`cancel`},"Approved→Merged":{label:`Merge`,icon:Qn,shortcut:`⌃M`},"Approved→Planning":{label:`Replan`,icon:Pr,shortcut:`⌃P`,handler:`replan`},"Merged→Archived":{label:`Archive`,icon:sn},"Merged→Planning":{label:`Reopen`,icon:Pr},"Cancelled→Archived":{label:`Archive`,icon:sn},"Cancelled→Planning":{label:`Reopen`,icon:Pr}};function Ki(e,t){return Gi[`${e}→${t}`]||{label:t,icon:Pi[t]||kn}}function qi({issue:e,onStateChange:t,onRetry:n,onCancel:r,onReplan:i,onExecute:a}){let[o,s]=(0,G.useState)(!1),c=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(!o)return;let e=e=>{c.current&&!c.current.contains(e.target)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o]),(0,G.useEffect)(()=>{if(!o)return;let e=e=>{e.key===`Escape`&&s(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[o]);let l=V(e.state).filter(t=>t!==e.state),u=l.length>0,d=Pi[e.state]||kn,f=Ii[e.state]||`badge-ghost`,p=(0,G.useCallback)((o,c)=>{switch(s(!1),c){case`cancel`:r?.(e.id);break;case`replan`:i?.(e.id);break;case`retry`:n?.(e.id);break;case`execute`:a?.(e.id);break;default:t?.(e.id,o)}},[e.id,t,n,r,i,a]),m=[],h=[];for(let t of l){let n=Ki(e.state,t),r={target:t,...n};n.danger?h.push(r):m.push(r)}return(0,K.jsxs)(`div`,{className:`relative`,ref:c,children:[(0,K.jsxs)(`button`,{className:`badge ${f} badge-soft badge-sm gap-1 ${u?`cursor-pointer hover:brightness-90 active:scale-95`:``} transition-all select-none`,onClick:()=>u&&s(e=>!e),"aria-haspopup":u?`menu`:void 0,"aria-expanded":o,children:[(0,K.jsx)(d,{className:`size-3`}),(0,K.jsx)(`span`,{children:e.state}),u&&(0,K.jsx)(bn,{className:`size-2.5 opacity-50 transition-transform duration-150 ${o?`rotate-180`:``}`})]}),o&&u&&(0,K.jsxs)(`div`,{role:`menu`,className:`absolute top-full left-0 mt-1.5 z-[60] min-w-[210px] bg-base-100 border border-base-300 rounded-box shadow-xl py-1 animate-fade-in`,children:[(0,K.jsx)(`div`,{className:`px-3 py-1 text-[10px] font-semibold uppercase tracking-wider opacity-35`,children:`Move to`}),m.map(({target:e,label:t,icon:n,shortcut:r,warning:i,handler:a})=>(0,K.jsxs)(`button`,{role:`menuitem`,className:`w-full flex items-center gap-2.5 px-3 py-1.5 text-[13px] hover:bg-base-200 transition-colors text-left ${i?`text-warning`:``}`,onClick:()=>p(e,a),children:[(0,K.jsx)(n,{className:`size-3.5 opacity-50 shrink-0`}),(0,K.jsx)(`span`,{className:`flex-1`,children:t}),r&&(0,K.jsx)(`kbd`,{className:`kbd kbd-xs text-[10px] opacity-30`,children:r})]},e)),h.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`border-t border-base-300 my-1`}),h.map(({target:e,label:t,icon:n,shortcut:r,handler:i})=>(0,K.jsxs)(`button`,{role:`menuitem`,className:`w-full flex items-center gap-2.5 px-3 py-1.5 text-[13px] hover:bg-error/10 transition-colors text-left text-error/80 hover:text-error`,onClick:()=>p(e,i),children:[(0,K.jsx)(n,{className:`size-3.5 shrink-0`}),(0,K.jsx)(`span`,{className:`flex-1`,children:t}),r&&(0,K.jsx)(`kbd`,{className:`kbd kbd-xs text-[10px] opacity-30`,children:r})]},e))]})]})]})}function Ji({title:e,icon:t,children:n,badge:r}){return(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`font-semibold text-sm flex items-center gap-1.5`,children:[t&&(0,K.jsx)(t,{className:`size-4 opacity-50`}),e,r!=null&&(0,K.jsx)(`span`,{className:`badge badge-xs badge-ghost ml-auto`,children:r})]}),(0,K.jsx)(`div`,{children:n})]})}function Yi({label:e,value:t,mono:n}){return t==null||t===``?null:(0,K.jsxs)(`div`,{className:`flex justify-between items-baseline gap-4 py-0.5`,children:[(0,K.jsx)(`span`,{className:`text-xs opacity-50 shrink-0`,children:e}),(0,K.jsx)(`span`,{className:`text-sm text-right truncate ${n?`font-mono text-xs`:``}`,children:t})]})}function Xi({text:e}){let[t,n]=(0,G.useState)(!1),r=(0,G.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},[e]);return(0,K.jsxs)(`button`,{className:`btn btn-xs btn-ghost gap-1 ${t?`text-success`:``}`,onClick:r,title:`Copy to clipboard`,children:[t?(0,K.jsx)(yn,{className:`size-3 animate-bounce-in`}):(0,K.jsx)(Ln,{className:`size-3`}),t?(0,K.jsx)(`span`,{className:`animate-fade-in`,children:`Copied`}):`Copy`]})}function Zi({config:e}){if(!e)return null;let{provider:t,model:n,effort:r}=e;return!t&&!n&&!r?null:(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[t&&(0,K.jsxs)(`span`,{className:`badge badge-xs badge-ghost font-mono gap-1`,children:[(0,K.jsx)(Zr,{className:`size-2.5`}),t]}),n&&(0,K.jsx)(`span`,{className:`badge badge-xs badge-ghost font-mono`,children:n}),r&&(0,K.jsx)(`span`,{className:`badge badge-xs badge-outline`,children:r})]})}var Qi={planner:`Plan`,executor:`Execute`,reviewer:`Review`},$i={planner:`text-info`,executor:`text-primary`,reviewer:`text-secondary`};function ea({tokensByPhase:e,tokensByModel:t}){let n=e?Object.entries(e).filter(([,e])=>e?.totalTokens>0):[],r=t?Object.entries(t).filter(([,e])=>e?.totalTokens>0):[];if(n.length===0&&r.length===0)return null;let i=e=>(e??0).toLocaleString();return(0,K.jsxs)(`div`,{className:`space-y-3`,children:[n.length>0&&(0,K.jsxs)(`div`,{className:`space-y-1`,children:[n.map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`w-14 shrink-0 font-medium ${$i[e]||`text-base-content`}`,children:Qi[e]||e}),(0,K.jsxs)(`span`,{className:`opacity-50`,children:[i(t.totalTokens),` total`]}),(0,K.jsxs)(`span`,{className:`opacity-30 text-[10px]`,children:[i(t.inputTokens),`↑ `,i(t.outputTokens),`↓`]}),t.model&&(0,K.jsx)(`span`,{className:`badge badge-xs badge-ghost font-mono ml-auto`,children:t.model})]},e)),n.length>1&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs border-t border-base-300 pt-1 mt-1`,children:[(0,K.jsx)(`span`,{className:`w-14 shrink-0 font-semibold opacity-60`,children:`Total`}),(0,K.jsx)(`span`,{className:`font-semibold`,children:i(n.reduce((e,[,t])=>e+(t.totalTokens??0),0))})]})]}),r.length>0&&(0,K.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,K.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider opacity-40 mb-1`,children:`by model`}),r.map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`font-mono opacity-70 truncate flex-1`,children:e}),(0,K.jsx)(`span`,{className:`opacity-50 shrink-0`,children:i(t.totalTokens)})]},e))]})]})}function ta({issue:e}){let t=Array.isArray(e.blockedBy)?e.blockedBy:[],n=Object.entries(e.contextReportsByRole??{}).filter(([,e])=>e&&typeof e==`object`).sort(([e],[t])=>e.localeCompare(t));return(0,K.jsxs)(`div`,{className:`space-y-5`,children:[e.mergedReason&&(0,K.jsxs)(`div`,{className:`flex items-start gap-2 bg-success/10 border border-success/20 rounded-box px-3 py-2.5`,children:[(0,K.jsx)(Qn,{className:`size-3.5 text-success shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-success/70 mb-0.5`,children:`Merged`}),(0,K.jsx)(`div`,{className:`text-xs text-success/90`,children:e.mergedReason})]})]}),e.cancelledReason&&(0,K.jsxs)(`div`,{className:`flex items-start gap-2 bg-error/10 border border-error/20 rounded-box px-3 py-2.5`,children:[(0,K.jsx)(Sr,{className:`size-3.5 text-error shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-error/70 mb-0.5`,children:`Cancelled`}),(0,K.jsx)(`div`,{className:`text-xs text-error/90`,children:e.cancelledReason})]})]}),(0,K.jsx)(Ji,{title:`Details`,icon:ur,children:(0,K.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,K.jsx)(Yi,{label:`Attempts`,value:`${e.attempts??0} / ${e.maxAttempts??0}`}),e.branchName&&(0,K.jsx)(Yi,{label:`Branch`,value:e.branchName,mono:!0}),e.baseBranch&&(0,K.jsx)(Yi,{label:`Base branch`,value:e.baseBranch,mono:!0}),e.worktreePath&&(0,K.jsx)(Yi,{label:`Code worktree`,value:e.worktreePath,mono:!0}),e.url&&(0,K.jsx)(Yi,{label:`URL`,value:e.url,mono:!0}),(0,K.jsx)(Yi,{label:`Created`,value:H(e.createdAt)}),e.startedAt&&(0,K.jsx)(Yi,{label:`Started`,value:H(e.startedAt)}),e.completedAt&&(0,K.jsx)(Yi,{label:`Completed`,value:H(e.completedAt)}),e.nextRetryAt&&(0,K.jsx)(Yi,{label:`Next retry`,value:H(e.nextRetryAt)}),(0,K.jsx)(Yi,{label:`Duration`,value:re(e.durationMs)}),e.tokenUsage?.totalTokens>0&&(0,K.jsx)(Yi,{label:`Tokens`,value:`${e.tokenUsage.totalTokens.toLocaleString()}${e.tokenUsage.costUsd?` ($${e.tokenUsage.costUsd.toFixed(4)})`:``}`})]})}),(e.memoryFlushAt||(e.memoryFlushCount??0)>0||n.length>0)&&(0,K.jsxs)(Ji,{title:`Harness Memory`,icon:ur,children:[(0,K.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,K.jsx)(Yi,{label:`Memory flushes`,value:e.memoryFlushCount??0}),e.memoryFlushAt&&(0,K.jsx)(Yi,{label:`Last flush`,value:H(e.memoryFlushAt)}),(0,K.jsx)(Yi,{label:`Context reports`,value:n.length})]}),n.length>0&&(0,K.jsx)(`div`,{className:`mt-3 space-y-2`,children:n.map(([e,t])=>(0,K.jsxs)(`div`,{className:`rounded-xl border border-base-300 bg-base-200/60 px-3 py-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider opacity-55`,children:e}),(0,K.jsxs)(`div`,{className:`mt-1 text-xs opacity-70`,children:[t.selectedHits,`/`,t.totalHits,` context hits selected · limit `,t.maxHits]})]}),t.memoryFlush?.flushedAt?(0,K.jsx)(`div`,{className:`text-[11px] opacity-45`,children:H(t.memoryFlush.flushedAt)}):null]}),(0,K.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(t.layers??[]).map(t=>(0,K.jsxs)(`span`,{className:`badge badge-xs badge-ghost gap-1`,children:[t.name,`:`,t.selectedHitCount,`/`,t.hitCount]},`${e}-${t.name}`))}),(t.stages??[]).length>0&&(0,K.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:t.stages.map(t=>(0,K.jsxs)(`span`,{className:`badge badge-xs badge-outline gap-1`,children:[t.name,typeof t.durationMs==`number`?`${t.durationMs}ms`:null]},`${e}-stage-${t.name}`))})]},e))})]}),t.length>0&&(0,K.jsx)(Ji,{title:`Dependencies`,icon:dn,badge:t.length,children:(0,K.jsx)(`div`,{className:`space-y-0.5`,children:t.map(e=>(0,K.jsx)(`div`,{className:`font-mono text-xs`,children:e},e))})})]})}function na({issueId:e,running:t,startedAt:n,onOutput:r,onLive:i}){let[a,o]=(0,G.useState)(null),s=(0,G.useCallback)(async()=>{try{let t=await U.get(`/issues/${encodeURIComponent(e)}/live`);o(t),r?.(t?.logTail||``),i?.(t)}catch{}},[e,i]);if((0,G.useEffect)(()=>{if(!t){o(null),r?.(null),i?.(null);return}s();let e=setInterval(s,3e3);return()=>clearInterval(e)},[t,s,r,i]),!t||!a)return null;let c=Number.isFinite(Number(a.elapsed))?Number(a.elapsed):n?Math.max(Date.now()-new Date(n).getTime(),0):0,l=Math.floor(c/6e4),u=Math.floor(c%6e4/1e3),d=a.logSize?(a.logSize/1024).toFixed(1):`0`;return(0,K.jsxs)(`div`,{className:`rounded-box border border-primary/30 bg-primary/5 p-3 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`loading loading-spinner loading-xs text-primary`}),(0,K.jsx)(`span`,{className:`text-sm font-semibold text-primary`,children:`Agent running`}),(0,K.jsxs)(`span`,{className:`text-xs opacity-50 ml-auto`,children:[l,`m `,u,`s elapsed`]})]}),(0,K.jsxs)(`div`,{className:`flex gap-3 text-xs opacity-60`,children:[(0,K.jsxs)(`span`,{children:[`Log: `,d,` KB`]}),a.agentPid&&(0,K.jsxs)(`span`,{children:[`PID: `,a.agentPid]}),a.daemonSocketReady&&(0,K.jsx)(`span`,{className:`text-success`,children:`daemon ●`}),a.agentAlive===!1&&a.agentPid&&(0,K.jsx)(`span`,{className:`text-error`,children:`process dead`})]})]})}var ra=[{label:`/usage`,value:`/usage`},{label:`/status`,value:`/status`},{label:`/stats`,value:`/stats session`}];function ia({issueId:e,daemonReady:t}){let[n,r]=(0,G.useState)(``),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(!1),u=(0,G.useRef)(null),d=(0,G.useCallback)(async t=>{let i=(t??n).trim();if(i){a(!0),s(null);try{await U.post(`/issues/${encodeURIComponent(e)}/agent/write`,{text:i}),s({ok:!0,msg:`sent: ${i}`}),r(``),setTimeout(()=>s(null),2500)}catch(e){s({ok:!1,msg:e.message||`failed`}),setTimeout(()=>s(null),4e3)}finally{a(!1)}}},[e,n]),f=(0,G.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),d())},[d]);return c?(0,K.jsxs)(`div`,{className:`rounded-box border border-base-300 bg-base-100 overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 pt-2.5 pb-1 border-b border-base-200 flex-wrap`,children:[(0,K.jsx)(`span`,{className:`text-xs opacity-40 mr-1 shrink-0`,children:`Quick:`}),ra.map(e=>(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost font-mono text-xs h-6 min-h-0 px-2 opacity-60 hover:opacity-100`,onClick:()=>d(e.value),disabled:i,children:e.label},e.value)),(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost text-xs h-6 min-h-0 px-2 opacity-30 hover:opacity-70 ml-auto`,onClick:()=>l(!1),children:`✕`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,K.jsx)(`span`,{className:`text-xs opacity-30 font-mono shrink-0`,children:`>`}),(0,K.jsx)(`input`,{ref:u,type:`text`,className:`input input-xs input-ghost flex-1 font-mono text-xs focus:outline-none px-0 min-w-0`,placeholder:`/insights, /simplify, /frontend-design…`,value:n,onChange:e=>r(e.target.value),onKeyDown:f,disabled:i,spellCheck:!1}),(0,K.jsx)(`button`,{className:`btn btn-xs btn-primary h-7 min-h-0 gap-1 ${i?`btn-disabled`:``}`,onClick:()=>d(),disabled:i||!n.trim(),children:i?(0,K.jsx)(`span`,{className:`loading loading-spinner loading-xs`}):(0,K.jsx)(Rr,{className:`size-3`})})]}),o&&(0,K.jsxs)(`div`,{className:`px-3 pb-2 text-xs font-mono ${o.ok?`text-success`:`text-error`}`,children:[o.ok?`✓`:`✗`,` `,o.msg]}),!t&&(0,K.jsx)(`div`,{className:`px-3 pb-2 text-xs opacity-40 italic`,children:`Daemon socket not detected — write requires PTY daemon mode.`})]}):(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-box border border-base-300 cursor-pointer hover:border-primary/40 hover:bg-primary/5 transition-colors group`,onClick:()=>{l(!0),setTimeout(()=>u.current?.focus(),50)},title:`Send a slash command to the running agent`,children:[(0,K.jsx)(Zr,{className:`size-3.5 opacity-40 group-hover:opacity-70 transition-opacity`}),(0,K.jsx)(`span`,{className:`text-xs opacity-40 group-hover:opacity-70 transition-opacity flex-1`,children:`Send command to agent…`}),ra.map(e=>(0,K.jsx)(`span`,{className:`hidden sm:inline text-xs font-mono opacity-30 group-hover:opacity-60 transition-opacity`,children:e.label},e.value)),(0,K.jsx)(bn,{className:`size-3 opacity-30 group-hover:opacity-60 transition-opacity`})]})}function aa({issue:e,workflowConfig:t}){let n=e.state===`Running`||e.state===`Reviewing`,r=t?.workflow?.execute,[i,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(null),c=(0,G.useCallback)(e=>a(e||``),[]),l=(0,G.useCallback)(e=>s(e),[]),[u,d]=(0,G.useState)(!0),f=(0,G.useRef)(null),p=n?i||e.commandOutputTail||``:e.commandOutputTail||``,m=!!p;return(0,G.useEffect)(()=>{u&&f.current&&(f.current.scrollTop=f.current.scrollHeight)},[p,u]),(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsx)(na,{issueId:e.id,running:n,startedAt:e.startedAt,onOutput:c,onLive:l}),n&&(0,K.jsx)(ia,{issueId:e.id,daemonReady:o?.daemonSocketReady??!1}),r&&(0,K.jsx)(Ji,{title:`Execution Config`,icon:Ur,children:(0,K.jsx)(Zi,{config:r})}),(0,K.jsx)(Ji,{title:`Run Info`,icon:Zr,children:(0,K.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,K.jsx)(Yi,{label:`Exit code`,value:e.commandExitCode??`-`,mono:!0}),(0,K.jsx)(Yi,{label:`Duration`,value:re(e.durationMs)}),e.workspacePath&&(0,K.jsx)(Yi,{label:`Issue workspace root`,value:e.workspacePath,mono:!0}),e.worktreePath&&(0,K.jsx)(Yi,{label:`Issue code checkout`,value:e.worktreePath,mono:!0}),e.workspacePreparedAt&&(0,K.jsx)(Yi,{label:`Workspace prepared at`,value:H(e.workspacePreparedAt)})]})}),e.lastError&&(0,K.jsx)(Ji,{title:`Last Error`,icon:ni,children:(0,K.jsx)(`pre`,{className:`text-xs bg-error/10 rounded-box p-3 overflow-x-auto whitespace-pre-wrap max-h-72 overflow-y-auto`,children:e.lastError})}),m?(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`font-semibold text-sm flex items-center gap-1.5`,children:[(0,K.jsx)(Zr,{className:`size-4 opacity-50`}),` CLI Output`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-1.5 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`checkbox checkbox-xs checkbox-primary`,checked:u,onChange:e=>d(e.target.checked)}),(0,K.jsx)(`span`,{className:`text-xs opacity-50`,children:`Auto-scroll`})]}),(0,K.jsx)(Xi,{text:p})]})]}),(0,K.jsx)(`pre`,{ref:f,className:`text-xs bg-base-200 rounded-box p-3 overflow-x-auto whitespace-pre-wrap max-h-[50vh] overflow-y-auto`,children:p})]}):(0,K.jsx)(`div`,{className:`text-sm opacity-40 text-center py-4`,children:`No command output yet.`}),(e.tokensByPhase||e.tokensByModel)&&(0,K.jsx)(Ji,{title:`Token Usage`,icon:ui,children:(0,K.jsx)(ea,{tokensByPhase:e.tokensByPhase,tokensByModel:e.tokensByModel})}),!e.lastError&&!m&&!e.tokensByPhase&&!e.tokensByModel&&(0,K.jsx)(`div`,{className:`text-sm opacity-40 text-center py-8`,children:`No execution data yet.`})]})}var oa={added:`badge-success`,removed:`badge-error`,modified:`badge-info`};function sa({file:e,isOpen:t,onToggle:n}){return(0,K.jsx)(`div`,{className:`border border-base-300 rounded-box overflow-hidden`,children:(0,K.jsxs)(`button`,{className:`w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-base-200 transition-colors`,onClick:n,children:[(0,K.jsx)(`span`,{className:`text-xs opacity-40 transition-transform`,style:{transform:t?`rotate(90deg)`:``},children:`▶`}),(0,K.jsx)(`span`,{className:`badge badge-xs ${oa[e.status]||`badge-ghost`}`,children:e.status}),(0,K.jsx)(`span`,{className:`font-mono text-xs truncate flex-1`,children:e.path}),(0,K.jsxs)(`span`,{className:`text-xs text-success`,children:[`+`,e.additions]}),(0,K.jsxs)(`span`,{className:`text-xs text-error`,children:[`-`,e.deletions]})]})})}function ca({lines:e}){return!e||e.length===0?null:(0,K.jsx)(`pre`,{className:`text-xs rounded-box p-3 overflow-x-auto max-h-[55vh] overflow-y-auto leading-relaxed bg-base-200 font-mono`,children:e.map((e,t)=>{let n=``;return e.startsWith(`+`)&&!e.startsWith(`+++`)?n=`text-success bg-success/10`:e.startsWith(`-`)&&!e.startsWith(`---`)?n=`text-error bg-error/10`:e.startsWith(`@@`)?n=`text-info opacity-60 text-[10px]`:e.startsWith(`diff `)&&(n=`font-bold opacity-70 border-t border-base-300 pt-2 mt-2`),(0,K.jsx)(`div`,{className:n,children:e||`\xA0`},t)})})}function la({issueId:e}){let[t,n]=(0,G.useState)(null),[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(null),l=(0,G.useCallback)(async()=>{i(!0),o(null);try{n(await U.get(`/issues/${encodeURIComponent(e)}/diff`))}catch(e){o(e.message)}finally{i(!1)}},[e]);if((0,G.useEffect)(()=>{n(null),o(null),c(null)},[e]),(0,G.useEffect)(()=>{l()},[l]),r)return(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-sm opacity-50 py-12`,children:[(0,K.jsx)(`span`,{className:`loading loading-spinner loading-sm`}),` Loading changes...`]});if(a)return(0,K.jsx)(`div`,{className:`text-sm text-error py-4`,children:a});if(!t)return null;let{files:u=[],diff:d=``,message:f,totalAdditions:p=0,totalDeletions:m=0}=t;if(u.length===0)return(0,K.jsx)(`div`,{className:`text-sm opacity-40 text-center py-8`,children:f||`No changes detected.`});let h={};if(d){let e=d.split(/(?=^diff --git )/m);for(let t of e){let e=t.match(/^diff --git a\/(.+?) b\//);e&&(h[e[1]]=t.split(`
32
+ `))}}return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,K.jsxs)(`span`,{className:`opacity-60`,children:[u.length,` file`,u.length===1?``:`s`,` changed`]}),(0,K.jsxs)(`span`,{className:`text-success font-mono text-xs`,children:[`+`,p]}),(0,K.jsxs)(`span`,{className:`text-error font-mono text-xs`,children:[`-`,m]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Xi,{text:d}),(0,K.jsxs)(`button`,{className:`btn btn-xs btn-ghost gap-1`,onClick:l,children:[(0,K.jsx)(Pr,{className:`size-3`}),` Refresh`]})]})]}),(0,K.jsx)(`div`,{className:`space-y-1`,children:u.map(e=>(0,K.jsx)(sa,{file:e,isOpen:s===e.path,onToggle:()=>c(s===e.path?null:e.path)},e.path))}),s&&h[s]&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-xs font-mono opacity-50 mb-1`,children:s}),(0,K.jsx)(ca,{lines:h[s]})]}),!s&&(0,K.jsxs)(`details`,{className:`group`,children:[(0,K.jsxs)(`summary`,{className:`text-xs opacity-50 cursor-pointer select-none list-none flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`transition-transform group-open:rotate-90`,children:`▶`}),`Show full diff`]}),(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(ca,{lines:d.split(`
33
+ `)})})]})]})}var ua=/^(\.fifony|fifony[-_]|WORKFLOW\.local)/;function da(e){return(Array.isArray(e)?e:[]).filter(e=>!ua.test(e))}function fa({issue:e}){let t=da(e.paths);return(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsx)(Ji,{title:`State Machine`,icon:Zn,children:(0,K.jsx)(`div`,{className:`space-y-1`,children:ee.map(t=>{let n=t===e.state,r=Pi[t]||kn,i=ne[t]||[],a=Vi(t)<Vi(e.state);return(0,K.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg px-2 py-1.5 border text-sm ${n?Li[t]+` font-semibold`:a?`border-transparent opacity-40`:`border-transparent opacity-60`}`,children:[(0,K.jsx)(r,{className:`size-4 mt-0.5 shrink-0 ${n?Fi[t]:``}`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{children:t}),n&&(0,K.jsx)(`span`,{className:`badge badge-xs badge-primary`,children:`current`})]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-0.5`,children:i.map(e=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-xs opacity-50`,children:[(0,K.jsx)(ln,{className:`size-2.5`}),e]},e))})]})]},t)})})}),t.length>0&&(0,K.jsx)(Ji,{title:`Paths`,icon:Jn,badge:t.length,children:(0,K.jsx)(`div`,{className:`space-y-0.5`,children:t.map(e=>(0,K.jsx)(`div`,{className:`font-mono text-xs truncate`,children:e},e))})})]})}var pa=[`all`,`info`,`state`,`progress`,`error`,`manual`,`runner`],ma={error:`badge-error`,state:`badge-primary`,progress:`badge-info`,manual:`badge-warning`,runner:`badge-accent`,info:`badge-ghost`},ha={Planning:`border-l-info`,PendingApproval:`border-l-warning`,Queued:`border-l-info`,Running:`border-l-primary`,Reviewing:`border-l-secondary`,PendingDecision:`border-l-success`,Blocked:`border-l-error`,Approved:`border-l-success`,Cancelled:`border-l-neutral`},ga=/([\d,]+)\s+tokens/gi,_a=100;function va(e,t){if(!e)return``;if(!t)return e;let n=[],r=0,i,a=new RegExp(ga.source,`gi`);for(;(i=a.exec(e))!==null;)i.index>r&&n.push(e.slice(r,i.index)),n.push((0,K.jsx)(`strong`,{className:`font-semibold`,children:i[0]},i.index)),r=i.index+i[0].length;return r<e.length&&n.push(e.slice(r)),n.length>0?n:e}function ya(e){if(!e)return null;for(let t of Object.keys(ha))if(e.includes(t))return t;return null}function ba({value:e}){let[,t]=(0,G.useState)(0);return(0,G.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),5e3);return()=>clearInterval(e)},[]),(0,K.jsx)(`span`,{title:H(e),children:ie(e)})}function xa({ev:e}){let t=typeof e.message==`string`&&/tokens/i.test(e.message),n=e.kind===`state`,r=n?ya(e.message):null,i=r?ha[r]:``;return(0,K.jsxs)(`div`,{className:`bg-base-200 rounded-box px-3 py-2 ${n?`border-l-[3px] ${i}`:``}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`opacity-50`,children:(0,K.jsx)(ba,{value:e.at})}),(0,K.jsx)(`span`,{className:`badge badge-xs ${ma[e.kind]||`badge-ghost`}`,children:e.kind||`info`}),n&&(0,K.jsx)(ln,{className:`size-3 opacity-50`}),t&&(0,K.jsx)(ui,{className:`size-3 text-warning`})]}),(0,K.jsx)(`div`,{className:`text-sm mt-0.5`,children:va(e.message,t)})]})}function Sa({issueId:e,events:t}){let[n,r]=(0,G.useState)(`all`),i=(0,G.useRef)(null),[a,o]=(0,G.useState)(!0),[s,c]=(0,G.useState)(!1),l=(0,G.useRef)(0),u=(0,G.useMemo)(()=>Array.isArray(t)?t.filter(t=>t.issueId===e&&(n===`all`||t.kind===n)).slice(0,200):[],[t,e,n]),d=(0,G.useCallback)(()=>{let e=i.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<_a;o(t),t&&c(!1)},[]);(0,G.useEffect)(()=>{u.length>l.current&&u.length>0&&(a&&i.current?requestAnimationFrame(()=>{i.current?.scrollTo({top:i.current.scrollHeight,behavior:`smooth`})}):l.current>0&&c(!0)),l.current=u.length},[u.length,a]);let f=(0,G.useCallback)(()=>{i.current?.scrollTo({top:i.current.scrollHeight,behavior:`smooth`}),c(!1)},[]);return(0,K.jsxs)(`div`,{className:`flex flex-col h-full -mx-6 -my-4`,children:[(0,K.jsxs)(`div`,{className:`px-5 py-2.5 border-b border-base-300 flex items-center gap-2 shrink-0`,children:[(0,K.jsx)(Ur,{className:`size-3.5 opacity-50`}),(0,K.jsx)(`select`,{className:`select select-bordered select-xs`,value:n,onChange:e=>r(e.target.value),"aria-label":`Filter by event kind`,children:pa.map(e=>(0,K.jsx)(`option`,{value:e,children:e===`all`?`All kinds`:e.charAt(0).toUpperCase()+e.slice(1)},e))}),u.length>0&&(0,K.jsx)(`span`,{className:`badge badge-xs badge-neutral ml-auto`,children:u.length})]}),(0,K.jsx)(`div`,{ref:i,className:`flex-1 overflow-y-auto px-5 py-3 relative`,onScroll:d,children:u.length===0?(0,K.jsx)(`div`,{className:`text-sm opacity-40 text-center py-8`,children:`No events for this issue yet.`}):(0,K.jsx)(`div`,{className:`space-y-2`,children:u.map((e,t)=>(0,K.jsx)(xa,{ev:e},`${e.at}-${t}`))})}),s&&(0,K.jsx)(`div`,{className:`absolute bottom-16 left-1/2 -translate-x-1/2 z-10`,children:(0,K.jsxs)(`button`,{type:`button`,className:`btn btn-xs btn-primary rounded-full shadow-lg animate-fade-in-up gap-1`,onClick:f,children:[(0,K.jsx)(bn,{className:`size-3`}),` New events`]})})]})}var Ca={trivial:`badge-ghost`,low:`badge-success`,medium:`badge-warning`,high:`badge-error`};function wa({issue:e,onStateChange:t,workflowConfig:n}){let[r,i]=(0,G.useState)(``),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(0),[y,b]=(0,G.useState)(!1),x=(0,G.useRef)(null),S=e.plan,C=e.state===`Planning`,w=S?.refinements?.length||0,T=Array.isArray(e.planHistory)?e.planHistory:[],E=e.planVersion??0,D=2e3,O=a||e.planningError,k=e.planningStatus===`planning`,A=k||s&&!S,j=k&&l||l,M=A||j,N=C&&!S&&!O&&!A;(0,G.useEffect)(()=>{e.planningError&&o(null)},[e.planningError]),(0,G.useEffect)(()=>{s&&(S||e.planningError)&&c(!1)},[s,S,e.planningError]),(0,G.useEffect)(()=>{l&&(e.planningStatus!==`planning`||e.planningError)&&u(!1)},[l,e.planningStatus,e.planningError]),(0,G.useEffect)(()=>{if(!s)return;let e=setTimeout(()=>{c(!1),o(`Plan generation timed out. The plan may still be generating in the background — check back soon.`)},300*1e3);return()=>clearTimeout(e)},[s]),(0,G.useEffect)(()=>{if(!M){v(0);return}let t=e.planningStartedAt?new Date(e.planningStartedAt).getTime():Date.now(),n=()=>v(Math.floor((Date.now()-t)/1e3));n();let r=setInterval(n,1e3);return()=>clearInterval(r)},[M,e.planningStartedAt]),(0,G.useEffect)(()=>{if(S&&C&&x.current){let e=setTimeout(()=>x.current?.focus(),300);return()=>clearTimeout(e)}},[S,C]);let P=async(t=!1)=>{o(null),c(!0);try{let n=await U.post(`/issues/${encodeURIComponent(e.id)}/plan`,{fast:t});if(!n.ok)throw Error(n.error||`Plan generation failed.`)}catch(e){o(e instanceof Error?e.message:String(e)),c(!1)}},F=async()=>{f(!0);try{await U.post(`/issues/${encodeURIComponent(e.id)}/approve`)}catch(e){o(e instanceof Error?e.message:String(e)),f(!1)}},I=async()=>{if(r.trim()){o(null),u(!0);try{let t=await U.post(`/issues/${encodeURIComponent(e.id)}/plan/refine`,{feedback:r.trim()});if(!t.ok)throw Error(t.error||`Refinement failed.`);i(``)}catch(e){o(e instanceof Error?e.message:String(e)),u(!1)}}},L=async()=>{o(null),m(!0);try{let t=await U.post(`/issues/${encodeURIComponent(e.id)}/replan`);if(!t.ok)throw Error(t.error||`Replan failed.`)}catch(e){o(e instanceof Error?e.message:String(e))}finally{m(!1)}};if(!S&&!A)return C?(0,K.jsxs)(`div`,{className:`space-y-4 py-4`,children:[N&&(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4 py-10`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`loading loading-dots loading-sm text-info`}),(0,K.jsx)(`span`,{className:`text-sm opacity-60`,children:`Queued — waiting for the planner worker...`})]}),(0,K.jsx)(`div`,{className:`text-xs opacity-30`,children:`The plan will be generated automatically shortly.`}),(0,K.jsx)(`div`,{className:`flex items-center gap-2 mt-2`,children:(0,K.jsxs)(`button`,{className:`btn btn-ghost btn-xs gap-1 opacity-50 hover:opacity-100`,onClick:()=>P(!1),children:[(0,K.jsx)(ui,{className:`size-3`}),` Generate now`]})})]}),O&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`alert alert-error text-sm flex-col items-start gap-1`,children:[(0,K.jsxs)(`div`,{className:`font-medium flex items-center gap-1.5`,children:[(0,K.jsx)(ni,{className:`size-4`}),` Plan generation failed`]}),(0,K.jsx)(`div`,{className:`text-xs opacity-80`,children:O})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,K.jsxs)(`button`,{className:`btn btn-primary btn-sm gap-1.5`,onClick:()=>P(!1),children:[(0,K.jsx)(Pr,{className:`size-3.5`}),` Try again`]}),(0,K.jsxs)(`button`,{className:`btn btn-ghost btn-sm gap-1`,onClick:()=>P(!0),children:[(0,K.jsx)(ui,{className:`size-3.5`}),` Fast`]})]})]})]}):(0,K.jsxs)(`div`,{className:`space-y-4 py-4`,children:[(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`div`,{className:`text-sm font-medium opacity-70`,children:`No plan yet`}),(0,K.jsx)(`p`,{className:`text-xs opacity-40`,children:`Generate an AI plan to break this issue into actionable steps.`})]}),O&&(0,K.jsx)(`div`,{className:`alert alert-error text-sm`,children:O})]});if(A&&!S){let e=_>0?re(_*1e3):``;return(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4 py-12`,children:[(0,K.jsx)(gr,{className:`size-8 animate-spin text-primary`}),(0,K.jsx)(`div`,{className:`text-sm opacity-60`,children:`Generating execution plan...`}),(0,K.jsx)(`div`,{className:`text-xs opacity-30`,children:`This may take a few minutes`}),e&&(0,K.jsxs)(`div`,{className:`text-xs font-mono opacity-40`,children:[e,` elapsed`]})]})}return(0,K.jsxs)(`div`,{className:`space-y-5`,children:[M&&(0,K.jsxs)(`div`,{className:`rounded-box border border-primary/30 bg-primary/5 p-3 flex items-center gap-3`,children:[(0,K.jsx)(gr,{className:`size-4 animate-spin text-primary shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-sm text-primary font-medium`,children:A?`Re-generating plan...`:`Refining to v${w+2}...`}),_>0&&(0,K.jsx)(`span`,{className:`text-xs text-primary/60 ml-2 font-mono`,children:re(_*1e3)})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,K.jsxs)(`span`,{className:`badge badge-sm ${Ca[S.estimatedComplexity]||`badge-ghost`}`,children:[S.estimatedComplexity,` complexity`]}),E>0&&(0,K.jsxs)(`span`,{className:`badge badge-sm badge-info badge-soft font-mono`,children:[`Plan v`,E]}),w>0&&(0,K.jsxs)(`span`,{className:`badge badge-sm badge-secondary gap-1`,children:[(0,K.jsx)(Pr,{className:`size-2.5`}),` Refined ×`,w]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[n?.workflow?.plan&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs opacity-60`,children:[(0,K.jsx)(Ur,{className:`size-3 shrink-0`}),(0,K.jsx)(Zi,{config:n.workflow.plan})]}),e.tokensByPhase?.planner?.totalTokens>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs opacity-50`,children:[(0,K.jsx)(ui,{className:`size-3`}),(0,K.jsxs)(`span`,{children:[e.tokensByPhase.planner.totalTokens.toLocaleString(),` tokens`]})]})]}),w>0&&(0,K.jsxs)(`div`,{className:`rounded-box border-l-4 border-secondary bg-secondary/5 px-4 py-3 animate-fade-in`,children:[(0,K.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider opacity-40 mb-1`,children:`Last refinement feedback`}),(0,K.jsxs)(`p`,{className:`text-sm leading-relaxed italic opacity-80`,children:[`“`,S.refinements[w-1].feedback,`”`]}),(0,K.jsxs)(`span`,{className:`text-[10px] opacity-30 mt-1 block`,children:[`v`,S.refinements[w-1].version||w+1,` · `,ie(S.refinements[w-1].at)]})]}),(0,K.jsxs)(`div`,{className:`space-y-5 animate-fade-in`,children:[(0,K.jsx)(Ji,{title:`Summary`,icon:sr,children:(0,K.jsx)(`p`,{className:`text-sm leading-relaxed`,children:S.summary})}),S.phases?.length>0&&(0,K.jsx)(Ji,{title:`Phases (${S.phases.length})`,icon:ur,children:(0,K.jsx)(`div`,{className:`space-y-3`,children:S.phases.map((e,t)=>(0,K.jsxs)(`div`,{className:`border border-base-300 rounded-box overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`bg-base-200 px-3 py-2 flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center size-5 rounded-full bg-primary/15 text-primary text-[10px] font-bold shrink-0`,children:t+1}),(0,K.jsx)(`span`,{className:`text-sm font-semibold`,children:e.phaseName}),e.tasks?.length>0&&(0,K.jsxs)(`span`,{className:`badge badge-xs badge-ghost ml-auto`,children:[e.tasks.length,` tasks`]})]}),e.goal&&(0,K.jsx)(`div`,{className:`px-3 pt-2 text-xs opacity-60`,children:e.goal}),e.tasks?.length>0&&(0,K.jsx)(`div`,{className:`px-3 pb-2 pt-1.5 space-y-1.5`,children:e.tasks.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex gap-2 text-xs`,children:[(0,K.jsxs)(`span`,{className:`opacity-30 shrink-0 font-mono w-4`,children:[e.step,`.`]}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:e.action}),e.details&&(0,K.jsxs)(`span`,{className:`opacity-50 ml-1`,children:[`— `,e.details]})]})]},t))}),e.outputs?.length>0&&(0,K.jsx)(`div`,{className:`px-3 pb-2 flex flex-wrap gap-1`,children:e.outputs.map(e=>(0,K.jsx)(`span`,{className:`badge badge-xs badge-outline opacity-60`,children:e},e))})]},t))})}),(0,K.jsx)(Ji,{title:`Steps (${S.steps.length})`,icon:pr,children:(0,K.jsx)(`div`,{className:`space-y-2`,children:S.steps.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex gap-3 p-3 bg-base-200 rounded-box`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center size-6 rounded-full bg-primary/10 text-primary text-xs font-bold shrink-0`,children:e.step}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-sm font-medium`,children:e.action}),e.details&&(0,K.jsx)(`div`,{className:`text-xs opacity-50 mt-0.5`,children:e.details}),e.files?.length>0&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:e.files.map(e=>(0,K.jsx)(`span`,{className:`badge badge-xs badge-ghost font-mono`,children:e},e))})]})]},t))})})]},`plan-content-${w}`),S.suggestedPaths?.length>0&&(0,K.jsx)(Ji,{title:`Suggested Paths`,icon:Jn,children:(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:S.suggestedPaths.map(e=>(0,K.jsx)(`span`,{className:`badge badge-sm badge-ghost font-mono`,children:e},e))})}),w>0&&(0,K.jsx)(Ji,{title:`Refinements (${w})`,icon:_r,children:(0,K.jsx)(`div`,{className:`space-y-2`,children:(()=>{let e=S.refinements,t=!y&&e.length>2,n=t?e.slice(-2):e;return(0,K.jsxs)(K.Fragment,{children:[t&&(0,K.jsxs)(`button`,{className:`btn btn-ghost btn-xs w-full gap-1 opacity-50`,onClick:()=>b(!0),children:[(0,K.jsx)(bn,{className:`size-3`}),` Show `,e.length-2,` earlier refinement`,e.length-2>1?`s`:``]}),n.map((n,r)=>{let i=t?e.length-2+r:r;return(0,K.jsxs)(`div`,{className:`flex gap-3 p-2.5 bg-base-200 rounded-box text-sm animate-fade-in`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-center size-6 rounded-full bg-secondary/10 text-secondary text-xs font-bold shrink-0`,children:[`v`,n.version||i+2]}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`text-sm leading-relaxed`,children:n.feedback}),(0,K.jsx)(`span`,{className:`text-[10px] opacity-40 mt-1 block`,children:ie(n.at)})]})]},i)}),y&&e.length>2&&(0,K.jsx)(`button`,{className:`btn btn-ghost btn-xs w-full gap-1 opacity-50`,onClick:()=>b(!1),children:`Show less`})]})})()})}),T.length>0&&(0,K.jsxs)(`div`,{className:`border border-base-300 rounded-box overflow-hidden`,children:[(0,K.jsxs)(`button`,{className:`w-full flex items-center justify-between px-3 py-2 bg-base-200 text-sm font-medium hover:bg-base-300 transition-colors`,onClick:()=>g(e=>!e),children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(Pr,{className:`size-3.5 opacity-60`}),`Plan History (`,T.length,` previous)`]}),(0,K.jsx)(bn,{className:`size-3.5 opacity-60 transition-transform ${h?`rotate-180`:``}`})]}),h&&(0,K.jsx)(`div`,{className:`divide-y divide-base-300`,children:T.map((e,t)=>(0,K.jsxs)(`div`,{className:`px-3 py-2.5 space-y-1 text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 opacity-60`,children:[(0,K.jsxs)(`span`,{className:`badge badge-xs badge-ghost font-mono`,children:[`v`,t+1]}),(0,K.jsxs)(`span`,{children:[e.steps?.length??0,` steps`]}),(0,K.jsx)(`span`,{className:`badge badge-xs badge-ghost`,children:e.estimatedComplexity}),(0,K.jsx)(`span`,{className:`ml-auto`,children:ie(e.createdAt)})]}),(0,K.jsx)(`p`,{className:`opacity-70 leading-relaxed line-clamp-2`,children:e.summary})]},t))})]}),C&&S&&(0,K.jsxs)(`div`,{className:`border-t border-base-300 pt-4 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`text-xs font-semibold flex items-center gap-1.5 opacity-70`,children:[(0,K.jsx)(_r,{className:`size-3.5`}),`Refine Plan`]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`textarea`,{ref:x,className:`textarea textarea-bordered w-full text-sm pr-16`,rows:2,placeholder:`Give feedback to refine the plan... e.g. 'Use React instead of Vue for step 3'`,value:r,maxLength:D,onChange:e=>i(e.target.value),disabled:M,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&r.trim()&&(e.preventDefault(),I())}}),(0,K.jsxs)(`span`,{className:`absolute bottom-2 right-3 text-[10px] pointer-events-none ${r.length>D*.9?`text-error`:`opacity-30`}`,children:[r.length,`/`,D]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{className:`btn btn-secondary btn-sm gap-1.5`,onClick:I,disabled:M||!r.trim(),children:j?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(gr,{className:`size-3.5 animate-spin`}),` Generating v`,w+2,`...`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Pr,{className:`size-3.5`}),` Refine Plan`]})}),(0,K.jsx)(`span`,{className:`text-[10px] opacity-30`,children:`Ctrl+Enter to send`})]})]}),O&&(0,K.jsx)(`div`,{className:`alert alert-error text-sm`,children:O}),C&&!M&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pt-3 border-t border-base-300 max-sm:flex-col`,children:[(0,K.jsx)(`button`,{className:`btn btn-primary gap-1.5 max-sm:w-full`,onClick:F,disabled:d||!S,children:d?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(gr,{className:`size-4 animate-spin`}),` Starting...`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Tn,{className:`size-4`}),` Approve & Start`]})}),S&&(0,K.jsx)(`button`,{className:`btn btn-ghost btn-sm gap-1 max-sm:w-full`,onClick:L,disabled:p||M,title:`Archive current plan and generate a new one`,children:p?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(gr,{className:`size-3 animate-spin`}),` Replanning...`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Pr,{className:`size-3`}),` Replan`]})})]})]})}function Ta({issue:e,issueId:t,onStateChange:n,onRetry:r}){let i=w(),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(null),[p,m]=(0,G.useState)(null),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(null),[x,S]=(0,G.useState)(e.testWorkspacePath??null),[C,T]=(0,G.useState)(e.images??[]),[E,D]=(0,G.useState)(!1),O=(0,G.useRef)(null),[k,A]=(0,G.useState)(!1),[j,M]=(0,G.useState)(``),[N,P]=(0,G.useState)(!1),[F,I]=(0,G.useState)(null),[L,R]=(0,G.useState)(!1),z=e.state===`Reviewing`||e.state===`PendingDecision`,B=e.state===`PendingDecision`,V=e.state===`Approved`,ee=e.state===`Merged`,te=!!e.mergedAt||ee,H=e.mergeResult,ne=(0,G.useCallback)(async()=>{c(!0);try{o(await U.get(`/issues/${encodeURIComponent(t)}/diff`))}catch{o(null)}finally{c(!1)}},[t]),re=(0,G.useCallback)(async()=>{try{f(await U.get(`/issues/${encodeURIComponent(t)}/merge-preview`))}catch{f(null)}},[t]);(0,G.useEffect)(()=>{g(!!e.testApplied),S(e.testWorkspacePath??null),o(null),u(null),f(null),m(null),b(null),A(!1),M(``),I(null),T(e.images??[])},[t,e.testApplied,e.testWorkspacePath]),(0,G.useEffect)(()=>{ne()},[ne]);let ie=[`Reviewing`,`PendingDecision`,`Approved`];(0,G.useEffect)(()=>{ie.includes(e.state)&&re()},[re,e.state]),(0,G.useEffect)(()=>{U.get(`/git/status`).then(e=>m(e.isClean!==!1)).catch(()=>m(null))},[t]);let W=(0,G.useCallback)(async e=>{if(e.length){D(!0);try{let n=await Promise.all(e.map(e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t({name:e.name,data:r.result.split(`,`)[1],type:e.type}),r.onerror=n,r.readAsDataURL(e)}))),r=await U.post(`/issues/${encodeURIComponent(t)}/images`,{files:n});r.ok&&r.paths&&T(e=>[...e,...r.paths])}catch{}finally{D(!1),O.current&&(O.current.value=``)}}},[t]);(0,G.useEffect)(()=>{let e=e=>{let t=Array.from(e.clipboardData?.items??[]).filter(e=>e.kind===`file`&&e.type.startsWith(`image/`)).map(e=>e.getAsFile()).filter(Boolean);t.length&&W(t)};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[W]);let ae=a?.files||[],oe=a?.diff||``,se={};if(oe)for(let e of oe.split(/(?=^diff --git )/m)){let t=e.match(/^diff --git a\/(.+?) b\//);t&&(se[t[1]]=e.split(`
34
+ `))}let ce=(0,G.useCallback)(async()=>{v(!0),b(null);try{let t=await U.post(`/issues/${encodeURIComponent(e.id)}/try`);g(!0),S(t?.issue?.testWorkspacePath??e.testWorkspacePath??null),i.invalidateQueries({queryKey:[`runtime-state`]})}catch(e){b(e.message)}finally{v(!1)}},[e.id,e.testWorkspacePath,i]),le=(0,G.useCallback)(async()=>{v(!0),b(null);try{await U.post(`/issues/${encodeURIComponent(e.id)}/revert-try`),g(!1),S(null),i.invalidateQueries({queryKey:[`runtime-state`]})}catch(e){b(e.message)}finally{v(!1)}},[e.id,i]),ue=(0,G.useCallback)(async()=>{P(!0),I(null);try{await U.post(`/issues/${encodeURIComponent(e.id)}/approve-and-merge`),i.invalidateQueries({queryKey:[`runtime-state`]})}catch(e){I(e instanceof Error?e.message:String(e))}finally{P(!1)}},[e.id,i]),de=(0,G.useCallback)(async()=>{n?.(e.id,`Approved`)},[e.id,n]),fe=(0,G.useCallback)(async()=>{r?.(e.id,j||void 0),A(!1),M(``)},[e.id,j,r]),pe=(0,G.useCallback)(async()=>{R(!0);try{await U.post(`/issues/${encodeURIComponent(e.id)}/cancel`),i.invalidateQueries({queryKey:[`runtime-state`]})}catch{}finally{R(!1)}},[e.id,i]);return(0,K.jsxs)(`div`,{className:`space-y-6`,children:[V&&!te&&(!H||H.conflicts===0)&&(0,K.jsxs)(`div`,{className:`alert border border-success/30 bg-success/5 text-sm`,children:[(0,K.jsx)(Tn,{className:`size-4 shrink-0 text-success`}),(0,K.jsx)(`span`,{className:`font-semibold`,children:`Approved — ready to merge`})]}),te&&(0,K.jsxs)(`div`,{className:`alert border text-sm ${H?.conflicts>0?`border-warning/30 bg-warning/5`:`border-success/30 bg-success/5`}`,children:[(0,K.jsx)(Qn,{className:`size-4 shrink-0 ${H?.conflicts>0?`text-warning`:`text-success`}`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`font-semibold`,children:`Merged`}),H&&(0,K.jsxs)(`span`,{className:`opacity-70`,children:[` — `,H.copied,` file`,H.copied===1?``:`s`,` copied`,H.deleted>0?`, ${H.deleted} deleted`:``]}),H?.conflicts>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:`text-xs text-warning font-medium mt-0.5`,children:[`Merge aborted — `,H.conflicts,` file`,H.conflicts===1?``:`s`,` had conflicts.`]}),H.conflictFiles?.length>0&&(0,K.jsx)(`ul`,{className:`text-xs text-warning/80 mt-1 ml-4 list-disc space-y-0.5`,children:H.conflictFiles.map(e=>(0,K.jsx)(`li`,{className:`font-mono`,children:e},e))})]}),(!H?.conflicts||H.conflicts===0)&&(0,K.jsx)(`p`,{className:`text-xs opacity-50 mt-0.5`,children:`The approved branch has been integrated into the current project branch.`})]})]}),!te&&V&&H?.conflicts>0&&(0,K.jsxs)(`div`,{className:`alert border border-warning/30 bg-warning/5 text-sm`,children:[(0,K.jsx)(ni,{className:`size-4 shrink-0 text-warning`}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`span`,{className:`font-semibold`,children:`Merge failed due to conflicts`}),(0,K.jsxs)(`p`,{className:`text-xs opacity-70 mt-0.5`,children:[`The branch `,e.branchName?(0,K.jsx)(`span`,{className:`font-mono`,children:e.branchName}):``,` could not be merged — `,H.conflicts,` file`,H.conflicts===1?``:`s`,` diverged.`]}),H.conflictFiles?.length>0&&(0,K.jsx)(`ul`,{className:`text-xs opacity-60 mt-1 ml-4 list-disc space-y-0.5`,children:H.conflictFiles.map(e=>(0,K.jsx)(`li`,{className:`font-mono`,children:e},e))}),(0,K.jsxs)(`button`,{className:`btn btn-xs btn-warning gap-1 mt-2`,onClick:()=>r?.(e.id),children:[(0,K.jsx)(Pr,{className:`size-3`}),` Requeue for Rework`]})]})]}),e.prUrl&&(0,K.jsxs)(`div`,{className:`alert border border-primary/30 bg-primary/5 text-sm`,children:[(0,K.jsx)(Bn,{className:`size-4 shrink-0 text-primary`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`font-semibold`,children:`Pull request created`}),(0,K.jsx)(`a`,{href:e.prUrl,target:`_blank`,rel:`noreferrer`,className:`block text-xs text-primary hover:underline mt-0.5 font-mono break-all`,children:e.prUrl})]})]}),(0,K.jsxs)(Ji,{title:`Review Changes`,icon:Mn,children:[s?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm opacity-50 py-4`,children:[(0,K.jsx)(`span`,{className:`loading loading-spinner loading-xs`}),` Loading changes...`]}):ae.length>0?(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,K.jsxs)(`span`,{className:`opacity-60`,children:[ae.length,` file`,ae.length===1?``:`s`,` changed`]}),(0,K.jsxs)(`span`,{className:`text-success font-mono text-xs`,children:[`+`,a?.totalAdditions||0]}),(0,K.jsxs)(`span`,{className:`text-error font-mono text-xs`,children:[`-`,a?.totalDeletions||0]})]}),(0,K.jsx)(`div`,{className:`space-y-1`,children:ae.map(e=>(0,K.jsx)(sa,{file:e,isOpen:l===e.path,onToggle:()=>u(l===e.path?null:e.path)},e.path))}),l&&se[l]&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-xs font-mono opacity-50 mb-1`,children:l}),(0,K.jsx)(ca,{lines:se[l]})]}),d?.willConflict&&(0,K.jsxs)(`div`,{className:`alert alert-warning text-xs py-2 gap-1.5`,children:[(0,K.jsx)(ni,{className:`size-3.5 shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`font-semibold`,children:`Merge will conflict`}),(0,K.jsxs)(`span`,{className:`opacity-70`,children:[` — `,d.conflictFiles.length,` file`,d.conflictFiles.length===1?``:`s`]}),d.conflictFiles.length>0&&(0,K.jsx)(`ul`,{className:`mt-1 ml-4 list-disc space-y-0.5 font-mono opacity-80`,children:d.conflictFiles.map(e=>(0,K.jsx)(`li`,{children:e},e))})]})]}),d&&!d.willConflict&&(0,K.jsxs)(`div`,{className:`alert alert-success text-xs py-2 gap-1.5`,children:[(0,K.jsx)(Tn,{className:`size-3.5 shrink-0`}),(0,K.jsx)(`span`,{children:`Merge is clean — no conflicts detected.`})]})]}):(0,K.jsx)(`div`,{className:`text-sm opacity-40 py-4`,children:`No changes detected.`}),p===!1&&(0,K.jsxs)(`div`,{className:`alert alert-warning text-xs py-2 gap-1.5 mt-3`,children:[(0,K.jsx)(ni,{className:`size-3.5 shrink-0`}),(0,K.jsx)(`span`,{children:`Project has uncommitted changes — merge preview and merge will fail until you commit or stash them first.`})]}),e.lastError&&(0,K.jsx)(`pre`,{className:`text-xs bg-error/10 rounded-box p-3 overflow-x-auto whitespace-pre-wrap max-h-40 overflow-y-auto mt-3`,children:e.lastError}),e.commandOutputTail&&!e.lastError&&(0,K.jsx)(`pre`,{className:`text-xs bg-base-200 rounded-box p-3 overflow-x-auto whitespace-pre-wrap max-h-40 overflow-y-auto mt-3`,children:e.commandOutputTail})]}),z&&(0,K.jsxs)(`div`,{className:`collapse collapse-arrow border border-base-300 rounded-box bg-base-100`,children:[(0,K.jsx)(`input`,{type:`checkbox`}),(0,K.jsxs)(`div`,{className:`collapse-title text-sm font-semibold flex items-center gap-1.5 py-3 min-h-0`,children:[(0,K.jsx)(Gn,{className:`size-4 opacity-50`}),`Optional: Create isolated test workspace`]}),(0,K.jsxs)(`div`,{className:`collapse-content space-y-4`,children:[y&&(0,K.jsxs)(`div`,{className:`alert alert-error text-xs py-2 gap-1.5`,children:[(0,K.jsx)(ni,{className:`size-3.5 shrink-0`}),` `,y]}),h?(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`alert alert-info text-xs py-2 gap-1.5`,children:[(0,K.jsx)(Gn,{className:`size-3.5 shrink-0`}),(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`div`,{children:`Isolated test workspace ready. Run your app from there if you want to verify behavior before deciding.`}),x&&(0,K.jsx)(`div`,{className:`font-mono break-all opacity-80`,children:x})]})]}),(0,K.jsxs)(`button`,{className:`btn btn-warning btn-sm btn-soft gap-1.5 w-full`,onClick:le,disabled:_,children:[_?(0,K.jsx)(gr,{className:`size-3.5 animate-spin`}):(0,K.jsx)(Pr,{className:`size-3.5`}),`Remove Test Workspace`]})]}):(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-xs opacity-60`,children:`Create a separate workspace with the issue branch checked out so you can run and inspect it safely before deciding.`}),(0,K.jsxs)(`button`,{className:`btn btn-info btn-sm btn-soft gap-1.5 w-full`,onClick:ce,disabled:_,title:`Create an isolated test workspace`,children:[_?(0,K.jsx)(gr,{className:`size-3.5 animate-spin`}):(0,K.jsx)(Gn,{className:`size-3.5`}),`Create Test Workspace`]})]}),(0,K.jsx)(`div`,{className:`h-0`}),` `]})]}),(0,K.jsxs)(Ji,{title:`Evidence`,icon:ar,children:[(0,K.jsx)(`input`,{ref:O,type:`file`,multiple:!0,accept:`image/*`,className:`hidden`,onChange:e=>W(Array.from(e.target.files??[]))}),C.length>0&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:C.map((e,n)=>{let r=e.split(`/`).pop(),i=`/api/issues/${encodeURIComponent(t)}/images/${encodeURIComponent(r)}`;return(0,K.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,className:`block`,children:(0,K.jsx)(`img`,{src:i,alt:r,className:`size-20 object-cover rounded-lg border border-base-300 hover:opacity-80 transition-opacity`})},n)})}),C.length===0&&(0,K.jsx)(`p`,{className:`text-xs opacity-40`,children:`No screenshots attached. Paste or upload images as evidence.`}),(0,K.jsxs)(`button`,{type:`button`,className:`btn btn-xs btn-soft btn-ghost gap-1 mt-2`,onClick:()=>O.current?.click(),disabled:E,children:[E?(0,K.jsx)(gr,{className:`size-3 animate-spin`}):(0,K.jsx)(Tr,{className:`size-3`}),`Attach Screenshot`]})]}),B&&(0,K.jsx)(Ji,{title:`Decision`,icon:Qr,children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[F&&(0,K.jsxs)(`div`,{className:`alert alert-error text-xs py-2 gap-1.5`,children:[(0,K.jsx)(ni,{className:`size-3.5 shrink-0`}),` `,F]}),(0,K.jsxs)(`button`,{className:`btn btn-success w-full gap-1.5`,onClick:ue,disabled:N,children:[N?(0,K.jsx)(gr,{className:`size-4 animate-spin`}):h?(0,K.jsx)(Nr,{className:`size-4`}):(0,K.jsx)(Qn,{className:`size-4`}),N?`Merging...`:h?`Ship It`:`Approve & Merge`]}),(0,K.jsxs)(`button`,{className:`btn btn-success btn-outline btn-sm w-full gap-1.5`,onClick:de,children:[(0,K.jsx)(Qr,{className:`size-3.5`}),`Approve Only`]}),k?(0,K.jsxs)(`div`,{className:`border border-warning/30 rounded-box p-3 space-y-3 bg-warning/5`,children:[(0,K.jsx)(`textarea`,{className:`textarea textarea-bordered w-full text-sm`,rows:3,placeholder:`Describe what needs to change (sent to the agent)...`,value:j,onChange:e=>M(e.target.value),autoFocus:!0}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{className:`btn btn-ghost btn-sm flex-1`,onClick:()=>{A(!1),M(``)},children:`Cancel`}),(0,K.jsxs)(`button`,{className:`btn btn-warning btn-sm flex-1 gap-1.5`,onClick:fe,children:[(0,K.jsx)(Pr,{className:`size-3.5`}),`Send Rework`]})]})]}):(0,K.jsxs)(`button`,{className:`btn btn-warning btn-outline btn-sm w-full gap-1.5`,onClick:()=>A(!0),children:[(0,K.jsx)(Pr,{className:`size-3.5`}),`Request Rework`]}),(0,K.jsx)(`div`,{className:`pt-2 border-t border-base-300`,children:(0,K.jsxs)(`button`,{className:`btn btn-ghost btn-sm text-error w-full gap-1.5`,onClick:pe,disabled:L,children:[L?(0,K.jsx)(gr,{className:`size-3.5 animate-spin`}):(0,K.jsx)(On,{className:`size-3.5`}),`Cancel Issue`]})})]})}),(0,K.jsx)(Oa,{issue:e})]})}function Ea(e){if(!e)return null;let t=e.trim();if(t.startsWith(`{`))try{let e=JSON.parse(t);if(e?.type===`result`){let t=e.duration_ms?` (${Math.round(e.duration_ms/1e3)}s)`:``;return e.is_error?`CLI exited with error: ${e.subtype||`unknown`}${t}`:`CLI session ended: ${e.subtype||`success`}${t}`}}catch{}return(t.split(`
35
+ `).map(e=>e.trim()).find(Boolean)??``).slice(0,300)||null}function Da({attempt:e,index:t,total:n,preReviewValidation:r}){let[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(!1),c=e.phase||`unknown`,l=c===`review`?`badge-secondary`:c===`execute`?`badge-primary`:c===`crash`?`badge-error`:`badge-ghost`,u=e.insight?.rootCause||Ea(e.error)||e.error,d=e.error&&e.error!==u,f=r&&!r.passed;return(0,K.jsxs)(`div`,{className:`rounded-lg border border-base-300 bg-base-200/40 overflow-hidden text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 bg-base-200 border-b border-base-300`,children:[(0,K.jsxs)(`span`,{className:`text-[10px] font-bold opacity-40 shrink-0`,children:[t+1,`/`,n]}),(0,K.jsx)(`span`,{className:`badge badge-xs ${l} shrink-0`,children:c}),e.insight?.errorType&&(0,K.jsx)(`span`,{className:`badge badge-xs badge-ghost font-mono truncate max-w-[120px]`,title:e.insight.errorType,children:e.insight.errorType}),(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-2 shrink-0`,children:[(0,K.jsxs)(`span`,{className:`font-mono opacity-30`,children:[`v`,e.planVersion,`a`,e.executeAttempt]}),e.timestamp&&(0,K.jsx)(`span`,{className:`opacity-30`,children:new Date(e.timestamp).toLocaleTimeString()})]})]}),(0,K.jsxs)(`div`,{className:`px-3 py-2.5 space-y-2.5`,children:[u&&(0,K.jsx)(`p`,{className:`text-base-content/80 leading-relaxed`,children:u}),f&&(0,K.jsxs)(`div`,{className:`rounded border border-error/30 bg-error/8 overflow-hidden`,children:[(0,K.jsxs)(`button`,{className:`flex items-center gap-2 px-2 py-1.5 w-full text-left hover:bg-error/10 transition-colors`,onClick:()=>s(e=>!e),children:[(0,K.jsx)(ni,{className:`size-3 text-error shrink-0`}),(0,K.jsx)(`span`,{className:`text-[10px] font-semibold text-error/80 flex-1`,children:`Pre-review gate failed`}),(0,K.jsxs)(`span`,{className:`font-mono text-[10px] text-error/50`,children:[`$ `,r.command]}),(0,K.jsx)(`span`,{className:`text-error/40`,children:o?`▴`:`▾`})]}),o&&r.output&&(0,K.jsx)(`pre`,{className:`px-2 pb-2 text-[10px] opacity-70 whitespace-pre-wrap max-h-48 overflow-y-auto leading-relaxed border-t border-error/20`,children:r.output.length>2e3?r.output.slice(-2e3)+`
36
+ …(truncated)`:r.output})]}),e.insight?.suggestion&&(0,K.jsxs)(`div`,{className:`flex gap-1.5 bg-warning/8 border border-warning/25 rounded px-2 py-1.5`,children:[(0,K.jsx)(`span`,{className:`text-warning/70 shrink-0 font-bold mt-px`,children:`→`}),(0,K.jsx)(`p`,{className:`text-[11px] text-warning/85 leading-relaxed`,children:e.insight.suggestion})]}),e.insight?.filesInvolved?.length>0&&(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[10px] opacity-35 mr-0.5 self-center`,children:`files:`}),e.insight.filesInvolved.slice(0,6).map(e=>(0,K.jsx)(`span`,{className:`badge badge-xs badge-ghost font-mono`,children:e.split(`/`).pop()},e)),e.insight.filesInvolved.length>6&&(0,K.jsxs)(`span`,{className:`badge badge-xs badge-ghost opacity-50`,children:[`+`,e.insight.filesInvolved.length-6]})]}),e.insight?.failedCommand&&(0,K.jsxs)(`div`,{className:`font-mono text-[10px] opacity-40 bg-base-300 rounded px-2 py-1 truncate`,title:e.insight.failedCommand,children:[`$ `,e.insight.failedCommand]}),d&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`button`,{className:`text-[10px] opacity-30 hover:opacity-60 transition-opacity flex items-center gap-1`,onClick:()=>a(e=>!e),children:[i?`▴`:`▾`,` raw error output`]}),i&&(0,K.jsx)(`pre`,{className:`mt-1 text-[10px] bg-base-300 rounded p-2 overflow-x-auto whitespace-pre-wrap max-h-40 overflow-y-auto opacity-55 leading-relaxed`,children:e.error})]})]})]})}function Oa({issue:e}){let t=e.previousAttemptSummaries||[],n=e.planHistory||[],r=e.mergeResult?.conflictResolution,i=e.rebaseResult,a=e.toolsUsed?.length||e.skillsUsed?.length||e.agentsUsed?.length,o=e.lastError?{phase:e.lastFailedPhase??`unknown`,error:e.lastError,timestamp:e.updatedAt,planVersion:e.planVersion??1,executeAttempt:e.executeAttempt??1,insight:null,_isCurrent:!0}:null,s=o?[...t,o]:t,c=s.length;return!(c>0||n.length>0||r||i)&&!a?null:(0,K.jsx)(Ji,{title:`History & Insights`,icon:rr,children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[a&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[e.toolsUsed?.length>0&&(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1 items-center`,children:[(0,K.jsx)(ci,{className:`size-3 opacity-40`}),(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide opacity-40`,children:`Tools:`}),e.toolsUsed.map(e=>(0,K.jsx)(`span`,{className:`badge badge-xs badge-outline font-mono`,children:e},e))]}),e.skillsUsed?.length>0&&(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1 items-center`,children:[(0,K.jsx)(ui,{className:`size-3 opacity-40`}),(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide opacity-40`,children:`Skills:`}),e.skillsUsed.map(e=>(0,K.jsx)(`span`,{className:`badge badge-xs badge-primary font-mono`,children:e},e))]}),e.agentsUsed?.length>0&&(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1 items-center`,children:[(0,K.jsx)(hn,{className:`size-3 opacity-40`}),(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide opacity-40`,children:`Agents:`}),e.agentsUsed.map(e=>(0,K.jsx)(`span`,{className:`badge badge-xs badge-secondary font-mono`,children:e},e))]})]}),r&&(0,K.jsxs)(`div`,{className:`alert text-xs py-2 gap-1.5 ${r.resolved?`alert-success`:`alert-warning`}`,children:[(0,K.jsx)(Qn,{className:`size-3.5 shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`font-semibold`,children:r.resolved?`Conflicts auto-resolved by ${r.provider}`:`Conflict resolution attempted (${r.provider}) — ${r.resolvedFiles.length} of ${e.mergeResult?.conflictFiles?.length||`?`} resolved`}),(0,K.jsxs)(`div`,{className:`opacity-60`,children:[Math.round(r.durationMs/1e3),`s · `,r.resolvedAt?new Date(r.resolvedAt).toLocaleTimeString():``]})]})]}),i&&(0,K.jsxs)(`div`,{className:`alert text-xs py-2 gap-1.5 ${i.success?`alert-info`:`alert-warning`}`,children:[(0,K.jsx)(Qn,{className:`size-3.5 shrink-0`}),i.success?`Auto-rebase succeeded — branch was up to date before merge.`:`Auto-rebase failed — ${i.conflictFiles.length} conflict(s): ${i.conflictFiles.join(`, `)}`]}),c>0&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide opacity-40`,children:[`Attempt log · `,c,` attempt`,c===1?``:`s`]}),s.map((t,n)=>(0,K.jsx)(Da,{attempt:t,index:n,total:c,preReviewValidation:t._isCurrent?e.preReviewValidation:null},n))]}),n.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide opacity-40 mb-1.5`,children:[`Plan history · `,n.length,` previous`]}),(0,K.jsx)(`div`,{className:`space-y-1`,children:n.map((e,t)=>(0,K.jsx)(`div`,{className:`bg-base-200 rounded-lg p-2 text-xs`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`span`,{className:`badge badge-xs badge-info`,children:[`v`,t+1]}),(0,K.jsx)(`span`,{className:`truncate flex-1 opacity-70`,children:e.summary}),(0,K.jsxs)(`span`,{className:`opacity-40`,children:[e.steps?.length||0,` steps`]}),(0,K.jsx)(`span`,{className:`badge badge-xs badge-ghost`,children:e.estimatedComplexity})]})},t))})]})]})})}function ka(e){if(!e)return`—`;if(e<1e3)return`${e}ms`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Aa(e){let t=e?.startedAt?Date.parse(e.startedAt):NaN,n=e?.completedAt?Date.parse(e.completedAt):NaN;return!Number.isFinite(t)||!Number.isFinite(n)||n<t?0:n-t}function ja(e){let t={sessionCount:e.length,turnCount:0,totalTokens:0,totalDurationMs:0,byStatus:{},byProvider:{},byRole:{}};for(let n of e){let e=n?.provider||`unknown`,r=n?.role||`unknown`,i=n?.session?.status||`unknown`,a=Array.isArray(n?.session?.turns)?n.session.turns:[];t.byStatus[i]=(t.byStatus[i]||0)+1,t.byProvider[e]=t.byProvider[e]||{sessions:0,turns:0,tokens:0},t.byRole[r]=t.byRole[r]||{sessions:0,turns:0,tokens:0},t.byProvider[e].sessions+=1,t.byRole[r].sessions+=1;for(let n of a){let i=n?.tokenUsage?.totalTokens||0;t.turnCount+=1,t.totalTokens+=i,t.totalDurationMs+=Aa(n),t.byProvider[e].turns+=1,t.byProvider[e].tokens+=i,t.byRole[r].turns+=1,t.byRole[r].tokens+=i}}return t}function Ma({label:e,value:t,icon:n,tone:r=``}){return(0,K.jsxs)(`div`,{className:`rounded-box border border-base-300 bg-base-200/20 px-3 py-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide opacity-45`,children:[n&&(0,K.jsx)(n,{className:`size-3`}),e]}),(0,K.jsx)(`div`,{className:`mt-1 text-sm font-semibold ${r}`,children:t})]})}function Na({title:e,entries:t,formatter:n}){return t.length?(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide opacity-40`,children:e}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(([e,t])=>(0,K.jsxs)(`span`,{className:`badge badge-sm badge-ghost gap-1.5`,children:[(0,K.jsx)(`span`,{className:`font-mono`,children:e}),(0,K.jsx)(`span`,{className:`opacity-60`,children:n(t)})]},e))})]}):null}function Pa({usage:e}){return e?.totalTokens?(0,K.jsxs)(`span`,{className:`badge badge-xs badge-ghost font-mono`,children:[e.totalTokens.toLocaleString(),` tok`]}):null}function Fa({label:e,icon:t,items:n}){return n?.length?(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1 items-center`,children:[(0,K.jsx)(t,{className:`size-3 opacity-40 shrink-0`}),(0,K.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wide opacity-40`,children:[e,`:`]}),n.map((e,t)=>(0,K.jsx)(`span`,{className:`badge badge-xs badge-outline font-mono`,children:e},t))]}):null}function Ia({turn:e}){let[t,n]=(0,G.useState)(!1),r=e.success?`text-success`:`text-error`;return(0,K.jsxs)(`div`,{className:`border border-base-300 rounded-lg overflow-hidden`,children:[(0,K.jsxs)(`button`,{className:`w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-base-200/50 transition-colors`,onClick:()=>n(!t),children:[t?(0,K.jsx)(bn,{className:`size-3 opacity-50`}):(0,K.jsx)(Sn,{className:`size-3 opacity-50`}),(0,K.jsxs)(`span`,{className:`text-xs font-semibold ${r}`,children:[`Turn `,e.turn]}),e.role&&(0,K.jsx)(`span`,{className:`badge badge-xs badge-primary`,children:e.role}),e.model&&(0,K.jsx)(`span`,{className:`badge badge-xs badge-ghost font-mono`,children:e.model}),(0,K.jsx)(`span`,{className:`text-[10px] opacity-40 ml-auto`,children:e.directiveStatus}),(0,K.jsx)(Pa,{usage:e.tokenUsage})]}),t&&(0,K.jsxs)(`div`,{className:`px-3 pb-3 space-y-2 border-t border-base-300 pt-2`,children:[e.directiveSummary&&(0,K.jsx)(`p`,{className:`text-xs opacity-70`,children:e.directiveSummary}),(0,K.jsx)(Fa,{label:`Tools`,icon:ci,items:e.toolsUsed}),(0,K.jsx)(Fa,{label:`Skills`,icon:ui,items:e.skillsUsed}),(0,K.jsx)(Fa,{label:`Agents`,icon:hn,items:e.agentsUsed}),(0,K.jsx)(Fa,{label:`Commands`,icon:Zr,items:e.commandsRun}),e.startedAt&&(0,K.jsxs)(`div`,{className:`text-[10px] opacity-40`,children:[new Date(e.startedAt).toLocaleTimeString(),` → `,new Date(e.completedAt).toLocaleTimeString()]})]})]})}function La({entry:e}){let{session:t,provider:n,role:r,cycle:i}=e,[a,o]=(0,G.useState)(!0),s=(t.turns||[]).reduce((e,t)=>e+Aa(t),0);return(0,K.jsxs)(`div`,{className:`border border-base-300 rounded-box overflow-hidden`,children:[(0,K.jsxs)(`button`,{className:`w-full flex items-center gap-2 px-3 py-2 text-left bg-base-200/30 hover:bg-base-200/50`,onClick:()=>o(!a),children:[a?(0,K.jsx)(bn,{className:`size-3.5`}):(0,K.jsx)(Sn,{className:`size-3.5`}),(0,K.jsx)(Rn,{className:`size-3.5 text-primary`}),(0,K.jsx)(`span`,{className:`text-sm font-semibold`,children:n}),(0,K.jsx)(`span`,{className:`badge badge-xs badge-secondary`,children:r}),i>1&&(0,K.jsxs)(`span`,{className:`badge badge-xs badge-warning`,children:[`cycle `,i]}),(0,K.jsx)(`span`,{className:`badge badge-xs ${t.status===`done`?`badge-success`:t.status===`failed`?`badge-error`:`badge-info`}`,children:t.status}),s>0&&(0,K.jsxs)(`span`,{className:`text-[10px] opacity-40 flex items-center gap-1`,children:[(0,K.jsx)(jn,{className:`size-3`}),ka(s)]}),(0,K.jsxs)(`span`,{className:`text-[10px] opacity-40 ml-auto`,children:[t.turns?.length||0,` turn(s)`]})]}),a&&t.turns?.length>0&&(0,K.jsx)(`div`,{className:`p-2 space-y-1.5`,children:t.turns.map((e,t)=>(0,K.jsx)(Ia,{turn:e},t))})]})}function Ra({issueId:e}){let[t,n]=(0,G.useState)(!0),[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(null);if((0,G.useEffect)(()=>{let t=!1;return n(!0),o(null),U.get(`/issues/${encodeURIComponent(e)}/sessions`).then(e=>{t||i(e)}).catch(e=>{t||o(e.message||String(e))}).finally(()=>{t||n(!1)}),()=>{t=!0}},[e]),t)return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 py-8 justify-center opacity-50`,children:[(0,K.jsx)(gr,{className:`size-4 animate-spin`}),` Loading sessions...`]});if(a)return(0,K.jsxs)(`div`,{className:`alert alert-error text-xs py-2`,children:[`Failed to load sessions: `,a]});let s=r?.sessions||[],c=r?.pipeline,l=ja(s),u=Object.entries(l.byProvider).sort((e,t)=>t[1].tokens-e[1].tokens||t[1].sessions-e[1].sessions),d=Object.entries(l.byRole).sort((e,t)=>t[1].tokens-e[1].tokens||t[1].sessions-e[1].sessions),f=Object.entries(l.byStatus).sort((e,t)=>t[1]-e[1]);return s.length===0?(0,K.jsx)(`div`,{className:`text-center py-8 opacity-40 text-sm`,children:`No execution sessions recorded yet.`}):(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(Ji,{title:`Summary`,icon:jn,children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-4`,children:[(0,K.jsx)(Ma,{label:`Sessions`,icon:Rn,value:l.sessionCount}),(0,K.jsx)(Ma,{label:`Turns`,icon:Zr,value:l.turnCount}),(0,K.jsx)(Ma,{label:`Tokens`,icon:ui,value:l.totalTokens.toLocaleString()}),(0,K.jsx)(Ma,{label:`Runtime`,icon:jn,value:ka(l.totalDurationMs)})]}),(0,K.jsx)(Na,{title:`Status`,entries:f,formatter:e=>`${e} session${e===1?``:`s`}`}),(0,K.jsx)(Na,{title:`Providers`,entries:u,formatter:({sessions:e,tokens:t})=>`${e}s • ${t.toLocaleString()} tok`}),(0,K.jsx)(Na,{title:`Roles`,entries:d,formatter:({sessions:e,tokens:t})=>`${e}s • ${t.toLocaleString()} tok`})]})}),c&&(0,K.jsx)(Ji,{title:`Pipeline`,icon:Rn,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`opacity-50`,children:`Attempt:`}),(0,K.jsx)(`span`,{className:`font-mono`,children:c.attempt}),(0,K.jsx)(`span`,{className:`opacity-50 ml-2`,children:`Cycle:`}),(0,K.jsx)(`span`,{className:`font-mono`,children:c.cycle}),c.history?.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`opacity-50 ml-2`,children:`History:`}),(0,K.jsxs)(`span`,{className:`font-mono`,children:[c.history.length,` entries`]})]})]})}),(0,K.jsx)(Ji,{title:`Sessions (${s.length})`,icon:Rn,children:(0,K.jsx)(`div`,{className:`space-y-2`,children:s.map((e,t)=>(0,K.jsx)(La,{entry:e},e.key||t))})})]})}function za({issue:e,onStateChange:t,onRetry:n,onMerge:r,onPush:i,onReplan:a,replanBusy:o,mergeBusy:s,mergeError:c,mergeNotice:l,mergeMode:u}){let d={paddingBottom:`calc(env(safe-area-inset-bottom, 0px) + 0.75rem)`},f=w(),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(null),_=(0,G.useCallback)(async()=>{m(!0),g(null);try{let t=await U.post(`/issues/${encodeURIComponent(e.id)}/execute`);if(!t.ok)throw Error(t.error||`Execute failed.`);f.invalidateQueries({queryKey:[`runtime-state`]})}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(!1)}},[e.id,f]),v=e.state===`Planning`,y=e.state===`PendingApproval`,b=e.state===`Running`||e.state===`Queued`,x=e.state===`Reviewing`||e.state===`PendingDecision`,S=e.state===`Approved`,C=e.state===`Merged`,T=!!e.mergedAt||C,[E,D]=(0,G.useState)(null);return(0,G.useEffect)(()=>{!S||T||U.get(`/git/status`).then(e=>D(e.isClean!==!1)).catch(()=>D(null))},[S,T]),v?null:y?(0,K.jsxs)(`div`,{className:`px-6 py-3 border-t border-base-300 shrink-0 space-y-1.5`,style:d,children:[h&&(0,K.jsxs)(`div`,{className:`alert alert-error text-xs py-1.5`,children:[(0,K.jsx)(ni,{className:`size-3.5`}),` `,h]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{className:`btn btn-primary btn-sm gap-1.5 flex-1`,onClick:_,disabled:p,children:p?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(gr,{className:`size-4 animate-spin`}),` Starting...`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Dn,{className:`size-4`}),` Execute`]})}),h&&(0,K.jsxs)(`button`,{className:`btn btn-ghost btn-sm gap-1.5`,onClick:a,disabled:o,title:`Re-run planning to fix the issue`,children:[o?(0,K.jsx)(gr,{className:`size-4 animate-spin`}):(0,K.jsx)(Pr,{className:`size-4`}),`Replan`]})]})]}):b?(0,K.jsxs)(`div`,{className:`px-6 py-3 border-t border-base-300 shrink-0 flex items-center justify-center gap-2`,style:d,children:[(0,K.jsx)(`span`,{className:`issue-phase-dot`}),(0,K.jsx)(`span`,{className:`text-sm opacity-50`,children:`Watching...`})]}):x?null:S&&!T?(0,K.jsxs)(`div`,{className:`px-6 py-3 border-t border-base-300 shrink-0 space-y-2`,style:d,children:[E===!1&&(0,K.jsxs)(`div`,{className:`alert alert-warning text-xs py-1.5`,children:[(0,K.jsx)(ni,{className:`size-3.5`}),(0,K.jsx)(`span`,{children:`Project has uncommitted changes — merge will fail. Commit or stash them first.`})]}),c&&(0,K.jsxs)(`div`,{className:`alert alert-error text-sm py-2`,children:[(0,K.jsx)(ni,{className:`size-4`}),` `,c]}),l&&!c&&(0,K.jsxs)(`div`,{className:`alert alert-success text-sm py-2`,children:[(0,K.jsx)(`span`,{className:`size-4`}),` `,l]}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:u===`push-pr`?(0,K.jsxs)(`button`,{className:`btn btn-primary btn-sm gap-1.5 flex-1 ${s?`btn-disabled`:``}`,onClick:()=>i?.(e.id),disabled:s,children:[s?(0,K.jsx)(gr,{className:`size-4 animate-spin`}):(0,K.jsx)(er,{className:`size-4`}),s?`Pushing...`:e.baseBranch?(0,K.jsxs)(K.Fragment,{children:[`Push PR → `,(0,K.jsx)(`span`,{className:`font-mono`,children:e.baseBranch})]}):`Push & Open PR`]}):(0,K.jsxs)(`button`,{className:`btn btn-primary btn-sm gap-1.5 flex-1 ${s?`btn-disabled`:``}`,onClick:()=>r?.(e.id),disabled:s,children:[s?(0,K.jsx)(gr,{className:`size-4 animate-spin`}):(0,K.jsx)(Qn,{className:`size-4`}),s?`Merging...`:e.baseBranch?(0,K.jsxs)(K.Fragment,{children:[`Merge → `,(0,K.jsx)(`span`,{className:`font-mono`,children:e.baseBranch})]}):`Merge to Project`]})})]}):null}function Ba({issue:e,onClose:t,onStateChange:n,onRetry:r,onCancel:i,onDelete:a,events:o,mergeMode:s,tabRef:c}){let l=w(),[u,d]=(0,G.useState)(`overview`),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(null),[b,x]=(0,G.useState)(null),[S,C]=(0,G.useState)(!1),[T,E]=(0,G.useState)(null),D=O(),k=(0,G.useRef)(null),{data:A}=Ni(),j=(0,G.useCallback)(async()=>{if(!(!e?.id||S)){C(!0),E(null);try{let t=await U.post(`/issues/${encodeURIComponent(e.id)}/replan`);if(!t.ok)throw Error(t.error||`Replan failed.`);d(`planning`)}catch(e){E(e instanceof Error?e.message:String(e))}finally{C(!1)}}},[e?.id,S]),M=(0,G.useCallback)(async()=>{if(e?.id)try{let t=await U.post(`/issues/${encodeURIComponent(e.id)}/execute`);if(!t.ok)throw Error(t.error||`Execute failed.`);l.invalidateQueries({queryKey:[`runtime-state`]})}catch{}},[e?.id,l]),N=(0,G.useCallback)(()=>{e?.id&&(a?.(e.id),P())},[e?.id,a]),P=(0,G.useCallback)(()=>{h(!0),setTimeout(()=>{p(!1),h(!1),t()},250)},[t]),{ref:F,handlers:I}=yi({onDismiss:P,direction:`right`});(0,G.useEffect)(()=>{e&&d(Bi(e.state))},[e?.id]),(0,G.useEffect)(()=>{c&&(c.current={get:()=>u,set:e=>d(e)})},[c,u]),(0,G.useEffect)(()=>{_(!1),y(null),x(null),e&&(p(!0),h(!1))},[e?.id,e?.state]);let L=(0,G.useCallback)(async()=>{if(!(!e?.id||g)){_(!0),y(null),x(null);try{let t=await U.post(`/issues/${encodeURIComponent(e.id)}/merge`),n=typeof t?.copied?.length==`number`?t.copied.length:0,r=typeof t?.conflicts?.length==`number`?t.conflicts.length:0,i=Array.isArray(t?.conflicts)?t.conflicts:[];r>0?y(`Merge aborted — ${r} conflict${r===1?``:`s`}: ${i.join(`, `)}`):(x(`Merged ${n} file${n===1?``:`s`} into the project.`),l.invalidateQueries({queryKey:[`runtime-state`]}))}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(!1)}}},[e?.id,g,l]),R=(0,G.useCallback)(async()=>{if(!(!e?.id||g)){_(!0),y(null),x(null);try{let t=await U.post(`/issues/${encodeURIComponent(e.id)}/push`);if(!t.ok)throw Error(t.error||`Push failed.`);t.prUrl?(x(`Branch pushed. PR: ${t.prUrl}`),window.open(t.prUrl,`_blank`,`noopener`)):x(`Branch pushed to origin.`),l.invalidateQueries({queryKey:[`runtime-state`]})}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(!1)}}},[e?.id,g]);if((0,G.useEffect)(()=>{k.current&&k.current.querySelector(`.tab-active`)?.scrollIntoView({behavior:`smooth`,inline:`center`,block:`nearest`})},[u]),!e&&!f||!e)return null;let z=e?.state===`Planning`&&!e?.plan&&!e?.planningError&&e?.planningStatus!==`planning`;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Oi,{onClick:P,className:m?`animate-fade-out`:`animate-fade-in`}),(0,K.jsxs)(`div`,{ref:F,className:`fixed top-0 right-0 z-50 h-full w-full md:w-[40vw] md:min-w-[520px] lg:min-w-[600px] bg-base-100 shadow-2xl flex flex-col ${m?`animate-slide-out-right`:`animate-slide-in-right`}`,onClick:e=>e.stopPropagation(),...I,children:[(0,K.jsxs)(`div`,{className:`px-6 pt-4 pb-0 shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,K.jsx)(`span`,{className:`font-mono text-xs opacity-40 shrink-0`,children:e.identifier}),(0,K.jsx)(qi,{issue:e,onStateChange:n,onRetry:r,onCancel:i,onReplan:j,onExecute:M}),e.baseBranch&&(0,K.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[10px] font-mono opacity-40 shrink-0 border border-base-300 rounded px-1 py-0.5`,children:[(0,K.jsx)(Qn,{className:`size-2.5`}),e.baseBranch]}),T&&(0,K.jsx)(`span`,{className:`text-xs text-error truncate`,children:T})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[(0,K.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost btn-circle opacity-40 hover:opacity-80`,onClick:()=>{t?.(),D({to:`/chat/${e.id}`})},"aria-label":`Chat about issue`,title:`Chat about this issue`,children:(0,K.jsx)(_r,{className:`size-3.5`})}),(0,K.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost btn-circle text-error/40 hover:text-error hover:bg-error/10`,onClick:N,disabled:e.state===`Running`||e.state===`Reviewing`,"aria-label":`Delete issue`,title:`Delete issue permanently`,children:(0,K.jsx)(ei,{className:`size-3.5`})}),(0,K.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost btn-circle shrink-0`,onClick:P,"aria-label":`Close`,children:(0,K.jsx)(li,{className:`size-4`})})]})]}),(0,K.jsxs)(`div`,{className:`flex items-start gap-2 mb-1`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-bold leading-tight flex-1`,children:e.title||`-`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 mt-0.5 flex-wrap justify-end`,children:[e.issueType&&Ri[e.issueType]&&(0,K.jsx)(`span`,{className:`badge badge-sm ${Ri[e.issueType]} badge-soft`,children:e.issueType}),(e.planVersion??0)>0&&(0,K.jsxs)(`span`,{className:`badge badge-sm badge-info badge-soft font-mono`,children:[`Plan v`,e.planVersion]}),(e.executeAttempt??0)>0&&(0,K.jsxs)(`span`,{className:`badge badge-sm badge-ghost font-mono opacity-60`,children:[`exec v`,e.planVersion??1,`a`,e.executeAttempt]})]})]}),e.description&&(0,K.jsx)(`p`,{className:`text-xs opacity-45 leading-relaxed mb-1 line-clamp-2`,children:e.description}),(0,K.jsx)(Wi,{issue:e}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`div`,{ref:k,role:`tablist`,className:`tabs tabs-lift overflow-x-auto flex-nowrap -webkit-overflow-scrolling-touch scrollbar-none`,style:{scrollbarWidth:`none`},children:zi.map(({id:t,label:n,icon:r,color:i,activeColor:a})=>{let o=u===t,s=o?a.replace(`tab-active `,``):i;return(0,K.jsxs)(`a`,{role:`tab`,className:`tab gap-1 text-xs whitespace-nowrap ${o?a:i} ${o?`font-semibold`:``}`,onClick:()=>d(t),children:[(0,K.jsx)(r,{className:`size-3 ${s}`}),n,t===`review`&&(e.state===`Reviewing`||e.state===`PendingDecision`)&&(0,K.jsx)(`span`,{className:`badge badge-xs badge-secondary`,children:`!`}),t===`planning`&&e.planningStatus===`planning`&&(0,K.jsx)(`span`,{className:`loading loading-spinner loading-xs text-info`}),t===`planning`&&z&&(0,K.jsx)(`span`,{className:`loading loading-dots loading-xs text-info opacity-50`})]},t)})}),(0,K.jsx)(`div`,{className:`absolute right-0 top-0 bottom-0 w-6 bg-gradient-to-l from-base-100 to-transparent pointer-events-none md:hidden`})]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto px-6 py-4 min-h-0 drawer-safe-bottom`,children:(0,K.jsxs)(`div`,{className:`animate-fade-in`,children:[u===`overview`&&(0,K.jsx)(ta,{issue:e}),u===`planning`&&(0,K.jsx)(wa,{issue:e,onStateChange:n,workflowConfig:A}),u===`review`&&(0,K.jsx)(Ta,{issue:e,issueId:e.id,onStateChange:n,onRetry:r}),u===`execution`&&(0,K.jsx)(aa,{issue:e,workflowConfig:A}),u===`diff`&&(0,K.jsx)(la,{issueId:e.id}),u===`sessions`&&(0,K.jsx)(Ra,{issueId:e.id}),u===`routing`&&(0,K.jsx)(fa,{issue:e}),u===`events`&&(0,K.jsx)(Sa,{issueId:e.id,events:o})]},u)}),(0,K.jsx)(za,{issue:e,onStateChange:n,onRetry:r,onReplan:j,replanBusy:S,onMerge:L,onPush:R,mergeBusy:g,mergeError:v,mergeNotice:b,mergeMode:s})]})]})}function Va({pwa:e}){return e?e.updateAvailable?(0,K.jsxs)(`div`,{className:`alert alert-info rounded-none border-x-0`,children:[(0,K.jsx)(Mr,{className:`size-4`}),(0,K.jsx)(`span`,{className:`text-sm`,children:`A fresh dashboard build is ready.`}),(0,K.jsx)(`button`,{className:`btn btn-sm btn-primary`,onClick:()=>e.applyUpdate(),children:`Reload app`})]}):e.isOnline?null:(0,K.jsxs)(`div`,{className:`alert alert-warning rounded-none border-x-0`,children:[(0,K.jsx)(oi,{className:`size-4`}),(0,K.jsx)(`span`,{className:`text-sm`,children:`You are offline. The app shell is available, but live runtime data may be stale.`})]}):null}var Ha=[`oklch(0.8 0.18 145)`,`oklch(0.8 0.18 250)`,`oklch(0.85 0.16 85)`,`oklch(0.75 0.18 330)`,`oklch(0.8 0.16 200)`];function Ua(e,t){return Math.random()*(t-e)+e}function Wa({color:e,style:t}){return(0,K.jsx)(`div`,{className:`absolute rounded-full pointer-events-none`,style:{width:t.size,height:t.size,backgroundColor:e,left:t.x,top:t.y,animation:`confetti-fly ${t.duration}ms cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards`,"--tx":t.tx,"--ty":t.ty,"--r":t.r,opacity:.9}})}function Ga({x:e=`50%`,y:t=`50%`,active:n,onDone:r,count:i=24}){let[a,o]=(0,G.useState)([]),s=(0,G.useRef)(r);(0,G.useEffect)(()=>{s.current=r},[r]);let c=(0,G.useCallback)(()=>{let e=Array.from({length:i},(e,t)=>{let n=Math.PI*2*t/i+Ua(-.3,.3),r=Ua(40,120),a=Ua(4,8);return{id:t,color:Ha[t%Ha.length],size:a,x:0,y:0,tx:`${Math.cos(n)*r}px`,ty:`${Math.sin(n)*r-Ua(20,60)}px`,r:`${Ua(-180,180)}deg`,duration:Ua(600,1e3)}});o(e);let t=Math.max(...e.map(e=>e.duration));setTimeout(()=>{o([]),s.current?.()},t+50)},[i]);return(0,G.useEffect)(()=>{n&&c()},[n,c]),a.length===0?null:(0,K.jsx)(`div`,{className:`fixed pointer-events-none z-[100]`,style:{left:e,top:t,transform:`translate(-50%, -50%)`},children:a.map(e=>(0,K.jsx)(Wa,{color:e.color,style:e},e.id))})}var Ka=[`shift`,`alt`,`meta`,`mod`,`ctrl`,`control`],qa={esc:`escape`,return:`enter`,left:`arrowleft`,right:`arrowright`,up:`arrowup`,down:`arrowdown`,ShiftLeft:`shift`,ShiftRight:`shift`,AltLeft:`alt`,AltRight:`alt`,MetaLeft:`meta`,MetaRight:`meta`,OSLeft:`meta`,OSRight:`meta`,ControlLeft:`ctrl`,ControlRight:`ctrl`};function Ja(e){return(qa[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,``)}function Ya(e){return Ka.includes(e)}function Xa(e,t=`,`){return e.toLowerCase().split(t)}function Za(e,t=`+`,n=`>`,r=!1,i,a){let o=[],s=!1;e=e.trim(),e.includes(n)?(s=!0,o=e.toLocaleLowerCase().split(n).map(e=>Ja(e))):o=e.toLocaleLowerCase().split(t).map(e=>Ja(e));let c={alt:o.includes(`alt`),ctrl:o.includes(`ctrl`)||o.includes(`control`),shift:o.includes(`shift`),meta:o.includes(`meta`),mod:o.includes(`mod`),useKey:r},l=o.filter(e=>!Ka.includes(e));return{...c,keys:l,description:i,isSequence:s,hotkey:e,metadata:a}}typeof document<`u`&&(document.addEventListener(`keydown`,e=>{e.code!==void 0&&to([Ja(e.code)])}),document.addEventListener(`keyup`,e=>{e.code!==void 0&&no([Ja(e.code)])})),typeof window<`u`&&(window.addEventListener(`blur`,()=>{Qa.clear()}),window.addEventListener(`contextmenu`,()=>{setTimeout(()=>{Qa.clear()},0)}));var Qa=new Set;function $a(e){return Array.isArray(e)}function eo(e,t=`,`){return($a(e)?e:e.split(t)).every(e=>Qa.has(e.trim().toLowerCase()))}function to(e){let t=Array.isArray(e)?e:[e];Qa.has(`meta`)&&Qa.forEach(e=>{Ya(e)||Qa.delete(e.toLowerCase())}),t.forEach(e=>{Qa.add(e.toLowerCase())})}function no(e){e===`meta`?Qa.clear():(Array.isArray(e)?e:[e]).forEach(e=>{Qa.delete(e.toLowerCase())})}function ro(e,t,n){(typeof n==`function`&&n(e,t)||n===!0)&&e.preventDefault()}function io(e,t,n){return typeof n==`function`?n(e,t):n===!0||n===void 0}var ao=[`input`,`textarea`,`select`,`searchbox`,`slider`,`spinbutton`,`menuitem`,`menuitemcheckbox`,`menuitemradio`,`option`,`radio`,`textbox`];function oo(e){return so(e,ao)}function so(e,t=!1){let{target:n,composed:r}=e,i,a;return co(n)&&r?(i=e.composedPath()[0]&&e.composedPath()[0].tagName,a=e.composedPath()[0]&&e.composedPath()[0].role):(i=n&&n.tagName,a=n&&n.role),$a(t)?!!(i&&t&&t.some(e=>e.toLowerCase()===i.toLowerCase()||e===a)):!!(i&&t&&t)}function co(e){return!!e.tagName&&!e.tagName.startsWith(`-`)&&e.tagName.includes(`-`)}function lo(e,t){return e.length===0&&t?!1:t?e.some(e=>t.includes(e))||e.includes(`*`):!0}var uo=(e,t,n=!1)=>{let{alt:r,meta:i,mod:a,shift:o,ctrl:s,keys:c,useKey:l}=t,{code:u,key:d,ctrlKey:f,metaKey:p,shiftKey:m,altKey:h}=e,g=Ja(u);if(l&&c?.length===1&&c.includes(d.toLowerCase()))return!0;if(!c?.includes(g)&&![`ctrl`,`control`,`unknown`,`meta`,`alt`,`shift`,`os`].includes(g))return!1;if(!n){if(r!==h&&g!==`alt`||o!==m&&g!==`shift`)return!1;if(a){if(!p&&!f)return!1}else if(i!==p&&g!==`meta`&&g!==`os`||s!==f&&g!==`ctrl`&&g!==`control`)return!1}return c&&c.length===1&&c.includes(g)?!0:c&&c.length>0?c.includes(g)?eo(c):!1:!c||c.length===0},fo=(0,G.createContext)(void 0),po=()=>(0,G.useContext)(fo);function mo({addHotkey:e,removeHotkey:t,children:n}){return(0,K.jsx)(fo.Provider,{value:{addHotkey:e,removeHotkey:t},children:n})}function ho(e,t){return e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(e).length===Object.keys(t).length&&Object.keys(e).reduce((n,r)=>n&&ho(e[r],t[r]),!0):e===t}var go=(0,G.createContext)({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),_o=()=>(0,G.useContext)(go),vo=({initiallyActiveScopes:e=[`*`],children:t})=>{let[n,r]=(0,G.useState)(e),[i,a]=(0,G.useState)([]),o=(0,G.useCallback)(e=>{r(t=>t.includes(`*`)?[e]:Array.from(new Set([...t,e])))},[]),s=(0,G.useCallback)(e=>{r(t=>t.filter(t=>t!==e))},[]),c=(0,G.useCallback)(e=>{r(t=>t.includes(e)?t.filter(t=>t!==e):t.includes(`*`)?[e]:Array.from(new Set([...t,e])))},[]),l=(0,G.useCallback)(e=>{a(t=>[...t,e])},[]),u=(0,G.useCallback)(e=>{a(t=>t.filter(t=>!ho(t,e)))},[]);return(0,K.jsx)(go.Provider,{value:{activeScopes:n,hotkeys:i,enableScope:o,disableScope:s,toggleScope:c},children:(0,K.jsx)(mo,{addHotkey:l,removeHotkey:u,children:t})})};function yo(e){let t=(0,G.useRef)(void 0);return ho(t.current,e)||(t.current=e),t.current}var bo=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},xo=typeof window<`u`?G.useLayoutEffect:G.useEffect;function J(e,t,n,r){let i=(0,G.useRef)(null),a=(0,G.useRef)(!1),o=Array.isArray(n)?Array.isArray(r)?void 0:r:n,s=$a(e)?e.join(o?.delimiter):e,c=Array.isArray(n)?n:Array.isArray(r)?r:void 0,l=(0,G.useCallback)(t,c??[]),u=(0,G.useRef)(l);c?u.current=l:u.current=t;let d=yo(o),{activeScopes:f}=_o(),p=po();return xo(()=>{if(d?.enabled===!1||!lo(f,d?.scopes))return;let e=[],t,n=(n,r=!1)=>{if(!(oo(n)&&!so(n,d?.enableOnFormTags))){if(i.current!==null){let e=i.current.getRootNode();if((e instanceof Document||e instanceof ShadowRoot)&&e.activeElement!==i.current&&!i.current.contains(e.activeElement)){bo(n);return}}n.target?.isContentEditable&&!d?.enableOnContentEditable||Xa(s,d?.delimiter).forEach(i=>{if(i.includes(d?.splitKey??`+`)&&i.includes(d?.sequenceSplitKey??`>`)){console.warn(`Hotkey ${i} contains both ${d?.splitKey??`+`} and ${d?.sequenceSplitKey??`>`} which is not supported.`);return}let o=Za(i,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description,d?.metadata);if(o.isSequence){t=setTimeout(()=>{e=[]},d?.sequenceTimeoutMs??1e3);let r=o.useKey?n.key:Ja(n.code);if(Ya(r.toLowerCase()))return;if(e.push(r),r!==o.keys?.[e.length-1]){e=[],t&&clearTimeout(t);return}e.length===o.keys?.length&&(u.current(n,o),t&&clearTimeout(t),e=[])}else if(uo(n,o,d?.ignoreModifiers)||o.keys?.includes(`*`)){if(d?.ignoreEventWhen?.(n)||r&&a.current)return;if(ro(n,o,d?.preventDefault),!io(n,o,d?.enabled)){bo(n);return}u.current(n,o),r||(a.current=!0)}})}},r=e=>{e.code!==void 0&&(to(Ja(e.code)),(d?.keydown===void 0&&d?.keyup!==!0||d?.keydown)&&n(e))},c=e=>{e.code!==void 0&&(no(Ja(e.code)),a.current=!1,d?.keyup&&n(e,!0))},l=i.current||o?.document||document;return l.addEventListener(`keyup`,c,o?.eventListenerOptions),l.addEventListener(`keydown`,r,o?.eventListenerOptions),p&&Xa(s,d?.delimiter).forEach(e=>{p.addHotkey(Za(e,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description,d?.metadata))}),()=>{l.removeEventListener(`keyup`,c,o?.eventListenerOptions),l.removeEventListener(`keydown`,r,o?.eventListenerOptions),p&&Xa(s,d?.delimiter).forEach(e=>{p.removeHotkey(Za(e,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description,d?.metadata))}),e=[],t&&clearTimeout(t)}},[s,d,f]),i}var So=`modulepreload`,Co=function(e){return`/`+e},wo={},To=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=Co(t,n),t in wo)return;wo[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:So,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Eo=(0,G.lazy)(()=>To(()=>import(`./KeyboardShortcutsHelp-CqEFfGcE.js`),__vite__mapDeps([0,1,2]))),Do=(0,G.lazy)(()=>To(()=>import(`./CommandPalette-CL8p78lG.js`),__vite__mapDeps([3,1,2,4])));function Oo({children:e}){let t=P().location.pathname,n=(0,G.useRef)(null),r=(0,G.useRef)(t);return(0,G.useEffect)(()=>{if(r.current===t)return;r.current=t;let e=n.current;if(e){if(document.startViewTransition){document.startViewTransition(()=>{e.style.opacity=`1`});return}e.style.opacity=`0`,e.style.transform=`translateY(4px)`,requestAnimationFrame(()=>{e.style.transition=`opacity 0.15s ease-out, transform 0.15s ease-out`,e.style.opacity=`1`,e.style.transform=`translateY(0)`,e.addEventListener(`transitionend`,()=>{e.style.transition=``},{once:!0})})}},[t]),(0,K.jsx)(`div`,{ref:n,className:`flex-1 flex flex-col min-h-0`,children:e})}function ko(){let e=tn(),t=w(),n=O(),r=P().location.pathname,[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(!1),c=(0,G.useRef)(null),[,l]=(0,G.useState)(0);(0,G.useEffect)(()=>{document.title=e.queueTitle||`fifony`},[e.queueTitle]);let u=!!e.selectedIssue,d=e.isCreateOpen,f=o,p=i,m=(0,G.useCallback)(()=>{if(f){s(!1);return}if(p){a(!1);return}if(d){e.setIsCreateOpen(!1);return}if(u){e.setSelectedIssue(null);return}},[f,p,d,u,e]),h=(0,G.useCallback)(t=>{if(!e.selectedIssue)return;let n=e.issues,r=n.findIndex(t=>t.id===e.selectedIssue.id);if(r<0)return;let i=r+t;i>=0&&i<n.length&&e.setSelectedIssue(n[i])},[e]),g=(0,G.useCallback)(e=>{if(!c.current)return;let t=zi.map(e=>e.id),n=t.indexOf(c.current.get());if(n<0)return;let r=n+e;r>=0&&r<t.length&&(c.current.set(t[r]),l(e=>e+1))},[]),_=(0,G.useCallback)(()=>{let n=e.selectedIssue;if(!n)return;let r=n.state;r===`PendingApproval`?To(async()=>{let{api:e}=await import(`./api-CEr_D4e5.js`).then(e=>e.n);return{api:e}},__vite__mapDeps([5,1])).then(({api:e})=>e.post(`/issues/${encodeURIComponent(n.id)}/execute`)).then(()=>t.invalidateQueries({queryKey:[`runtime-state`]})):r===`PendingDecision`?To(async()=>{let{api:e}=await import(`./api-CEr_D4e5.js`).then(e=>e.n);return{api:e}},__vite__mapDeps([5,1])).then(({api:e})=>e.post(`/issues/${encodeURIComponent(n.id)}/approve-and-merge`)).then(()=>t.invalidateQueries({queryKey:[`runtime-state`]})):r===`Approved`&&!n.mergedAt&&To(async()=>{let{api:e}=await import(`./api-CEr_D4e5.js`).then(e=>e.n);return{api:e}},__vite__mapDeps([5,1])).then(({api:e})=>e.post(`/issues/${encodeURIComponent(n.id)}/merge`)).then(()=>t.invalidateQueries({queryKey:[`runtime-state`]}))},[e,t]),v=!u,y=e.selectedIssue?.state,b=y===`PendingDecision`,x=y===`Reviewing`||y===`PendingDecision`,S=y===`Approved`&&!e.selectedIssue?.mergedAt,C=!!e.selectedIssue?.plan&&![`Running`,`Reviewing`,`Queued`,`Planning`].includes(y);J(`escape`,m,{description:`Close drawer / modal`,metadata:{group:`global`}},[m]),J(`shift+/`,()=>a(e=>!e),{description:`Keyboard shortcuts help`,metadata:{group:`global`}}),J(`mod+k`,()=>s(e=>!e),{preventDefault:!0,enableOnFormTags:!0,description:`Command palette`,metadata:{group:`palette`}}),J(`r`,()=>e.refresh(),{enabled:v,description:`Refresh`,metadata:{group:`global`}},[e,v]),J(`c`,()=>n({to:`/chat`}),{enabled:v&&r!==`/chat`,description:`Chat`,metadata:{group:`navigation`}},[n,v,r]),J(`n`,()=>e.setIsCreateOpen(!0),{enabled:v,description:`New issue`,metadata:{group:`navigation`}},[e,v]),J(`k`,()=>n({to:`/kanban`}),{enabled:v&&r!==`/kanban`,description:`Go to Kanban`,metadata:{group:`navigation`}},[n,v,r]),J(`i`,()=>n({to:`/issues`}),{enabled:v&&r!==`/issues`,description:`Go to Issues`,metadata:{group:`navigation`}},[n,v,r]),J(`a`,()=>n({to:`/agents`}),{enabled:v,description:`Go to Agents`,metadata:{group:`navigation`}},[n,v]),J(`t`,()=>n({to:`/analytics`}),{enabled:v,description:`Go to Analytics`,metadata:{group:`navigation`}},[n,v]),J(`s`,()=>n({to:`/settings`}),{enabled:v,description:`Go to Settings`,metadata:{group:`navigation`}},[n,v]),J(`w`,()=>n({to:`/services`}),{enabled:v,description:`Go to Services`,metadata:{group:`navigation`}},[n,v]),J(`]`,()=>g(1),{enabled:u,description:`Next tab`,metadata:{group:`drawer`}},[g,u]),J(`[`,()=>g(-1),{enabled:u,description:`Previous tab`,metadata:{group:`drawer`}},[g,u]),J(`j`,()=>h(1),{enabled:u,description:`Next issue`,metadata:{group:`drawer`}},[h,u]),J(`k`,()=>h(-1),{enabled:u,description:`Previous issue`,metadata:{group:`drawer`}},[h,u]),J(`mod+enter`,_,{enabled:u,enableOnFormTags:!0,preventDefault:!0,description:`Primary action (Execute / Approve / Merge)`,metadata:{group:`drawer`}},[_,u]),J(`mod+a`,()=>e.updateState(e.selectedIssue.id,`Approved`),{enabled:b,enableOnFormTags:!0,preventDefault:!0,description:`Approve issue`,metadata:{group:`drawer`}},[e,b]),J(`mod+m`,()=>To(async()=>{let{api:e}=await import(`./api-CEr_D4e5.js`).then(e=>e.n);return{api:e}},__vite__mapDeps([5,1])).then(({api:t})=>t.post(`/issues/${encodeURIComponent(e.selectedIssue.id)}/merge`)),{enabled:S,enableOnFormTags:!0,preventDefault:!0,description:`Merge issue`,metadata:{group:`drawer`}},[e,S]),J(`mod+w`,()=>e.retryIssue(e.selectedIssue.id),{enabled:x,enableOnFormTags:!0,preventDefault:!0,description:`Rework issue`,metadata:{group:`drawer`}},[e,x]),J(`mod+p`,()=>To(async()=>{let{api:e}=await import(`./api-CEr_D4e5.js`).then(e=>e.n);return{api:e}},__vite__mapDeps([5,1])).then(({api:t})=>t.post(`/issues/${encodeURIComponent(e.selectedIssue.id)}/replan`)),{enabled:C,enableOnFormTags:!0,preventDefault:!0,description:`Replan issue`,metadata:{group:`drawer`}},[e,C]);let[E,D]=(0,G.useState)(!1),[k,A]=(0,G.useState)(!1),j=(0,G.useRef)(null),M=e.runtime.isLoading&&!e.runtime.data&&!e.runtime.isError;if((0,G.useEffect)(()=>(!E&&!j.current&&(j.current=setTimeout(()=>{A(!0),setTimeout(()=>D(!0),400)},1e3)),()=>{}),[E]),!E&&M)return(0,K.jsx)(Ao,{});if(!E&&k)return(0,K.jsx)(Ao,{fadeOut:!0});if(!E&&!M)return(0,K.jsx)(Ao,{});let N=e.toast?.type||`info`,F=typeof e.toast==`string`?e.toast:e.toast?.message;return(0,K.jsxs)(`div`,{className:`flex flex-col`,style:{minHeight:`100dvh`},children:[e.toast&&(0,K.jsx)(`div`,{className:`toast toast-end toast-top z-50`,children:(0,K.jsxs)(`div`,{className:`alert text-sm shadow-lg ${N===`success`?`alert-success`:N===`error`?`alert-error`:`alert-info`} ${e.toastExiting?`animate-toast-out`:`animate-toast-in`}`,children:[N===`success`?(0,K.jsx)(wn,{className:`size-4`}):N===`error`?(0,K.jsx)(ni,{className:`size-4`}):(0,K.jsx)(sr,{className:`size-4`}),(0,K.jsx)(`span`,{children:F}),(0,K.jsx)(`div`,{className:`toast-progress`})]})}),e.confetti&&(0,K.jsx)(Ga,{x:e.confetti.x,y:e.confetti.y,count:e.confetti.count,active:!0,onDone:()=>e.clearConfetti?.()}),(0,K.jsx)(hi,{issueCount:e.issues.length,queueTitle:e.queueTitle,sourceRepo:e.data.sourceRepoUrl,updatedAt:e.data.updatedAt,wsStatus:e.wsStatus,issues:e.issues}),(0,K.jsx)(Va,{pwa:e.pwa}),(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 pb-20 md:pb-0`,children:[(0,K.jsx)(Oo,{children:(0,K.jsx)(T,{})}),e.runtime.isError&&(0,K.jsx)(`div`,{className:`px-4 pb-4`,children:(0,K.jsx)(`div`,{className:`alert alert-error`,children:String(e.runtime.error?.message||`Runtime unavailable`)})})]}),(0,K.jsx)(gi,{onClick:()=>e.setIsCreateOpen(!0)}),(0,K.jsx)(_i,{}),(0,K.jsx)(Di,{open:e.isCreateOpen,onClose:()=>e.setIsCreateOpen(!1),onSubmit:t=>e.createIssue.mutate(t),isLoading:e.createIssue.isPending,onToast:e.showToast}),(0,K.jsx)(Ba,{issue:e.selectedIssue,onClose:()=>e.setSelectedIssue(null),onStateChange:e.updateState,onRetry:e.retryIssue,onCancel:e.cancelIssue,onDelete:e.deleteIssue,events:e.eventsData,mergeMode:e.data?.config?.mergeMode??`local`,tabRef:c}),i&&(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(Eo,{open:i,onClose:()=>a(!1)})}),o&&(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(Do,{issues:e.issues,onSelect:t=>{e.setSelectedIssue(t),s(!1)},onNavigate:e=>{n({to:e}),s(!1)},onAction:e=>{e(),s(!1)},onClose:()=>s(!1)})})]})}function Ao({fadeOut:e=!1}){return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 bg-base-100 flex flex-col items-center justify-center overflow-hidden`,style:{opacity:e?0:1,transition:`opacity 0.4s ease-out`},children:(0,K.jsxs)(`div`,{className:`relative z-10 flex flex-col items-center gap-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-end gap-4`,children:[(0,K.jsx)(`img`,{src:pe,alt:``,className:`h-20 sm:h-28 object-contain select-none pointer-events-none`,style:{filter:`drop-shadow(0 6px 20px rgba(128, 0, 255, 0.25))`,animation:`splash-dino 0.6s cubic-bezier(0.22, 1, 0.36, 1) both`}}),(0,K.jsx)(`h1`,{className:`text-4xl sm:text-5xl font-bold tracking-tight leading-none pb-1`,style:{fontFamily:`'Space Grotesk', system-ui, sans-serif`,animation:`splash-title 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.15s both`},children:(0,K.jsx)(`span`,{className:`text-primary`,children:`fifony`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-base-content/40`,style:{animation:`splash-subtitle 0.4s ease-out 0.4s both`},children:[(0,K.jsx)(`span`,{className:`loading loading-dots loading-sm`}),(0,K.jsx)(`span`,{className:`text-sm`,children:`Warming up the orchestra...`})]})]})})}function jo({children:e}){let t=rt(),n=an(me(t.data));return t.isLoading&&!t.data?(0,K.jsx)(Ao,{}):t.isError?e:!n&&t.isFetching?(0,K.jsx)(Ao,{}):n?e:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(Ao,{}),children:(0,K.jsx)(Mo,{})})}function Mo(){let e=O(),t=(0,G.useRef)(!1);return(0,G.useEffect)(()=>{t.current||(t.current=!0,e({to:`/onboarding`,replace:!0}))},[e]),(0,K.jsx)(Ao,{})}function No(){return(0,K.jsx)(vo,{children:(0,K.jsx)(nn,{children:P().location.pathname===`/onboarding`?(0,K.jsx)(T,{}):(0,K.jsx)(jo,{children:(0,K.jsx)(ko,{})})})})}function Po(e){return e?e.split(`
37
+ `).slice(1).map(e=>e.trim()).filter(e=>e.startsWith(`at `)).map(e=>{let t=e.match(/^at (.+?) \((.+):(\d+):(\d+)\)$/),n=e.match(/^at (.+):(\d+):(\d+)$/);return t?{fn:t[1],file:t[2],line:t[3],col:t[4]}:n?{fn:null,file:n[1],line:n[2],col:n[3]}:{fn:null,file:e,line:null,col:null}}):[]}function Fo(e){if(!e)return e;try{let t=new URL(e);return t.pathname+(t.searchParams.toString()?`?`+t.searchParams:``)}catch{return e}}function Io({text:e}){let[t,n]=(0,G.useState)(!1);return(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost gap-1 font-mono ${t?`text-success`:`opacity-50 hover:opacity-100`}`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},children:t?`✓ copied`:`copy`})}function Lo({error:e,reset:t}){let[n,r]=(0,G.useState)(!0),[i,a]=(0,G.useState)(!1),o=e?.name||`Error`,s=e?.message||String(e)||`An unexpected error occurred.`,c=e?.stack||``,l=Po(c),u=window.location.pathname,d=new Date().toLocaleTimeString(),f=navigator.userAgent,p=`${o}: ${s}\n\nRoute: ${u}\nTime: ${new Date().toISOString()}\n\n${c}`,m=l.filter(e=>e.file&&!e.file.includes(`node_modules`)&&!e.file.includes(`chunk-`)&&!e.file.includes(`vendor-`))[0]||l[0];return(0,K.jsxs)(`div`,{className:`min-h-screen bg-base-200 flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`bg-error text-error-content px-4 py-2.5 flex items-center gap-3 shrink-0`,children:[(0,K.jsx)(ni,{className:`size-4 shrink-0`}),(0,K.jsxs)(`span`,{className:`font-mono text-sm font-semibold flex-1 truncate`,children:[o,`: `,s]}),(0,K.jsx)(`span`,{className:`text-xs opacity-60 shrink-0`,children:d})]}),(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col lg:flex-row gap-0 min-h-0 overflow-auto`,children:[(0,K.jsxs)(`div`,{className:`flex-1 p-6 space-y-5 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`bg-base-100 rounded-2xl border border-base-300 overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`px-5 py-3 border-b border-base-300 flex items-center justify-between gap-3`,children:[(0,K.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider opacity-40`,children:`Error`}),(0,K.jsx)(Io,{text:p})]}),(0,K.jsxs)(`div`,{className:`p-5 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`span`,{className:`badge badge-error badge-sm mt-0.5 shrink-0 font-mono`,children:o}),(0,K.jsx)(`p`,{className:`font-mono text-sm text-error leading-relaxed break-all`,children:s})]}),m&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-base-content/50`,children:[(0,K.jsx)(`span`,{className:`opacity-40`,children:`at`}),(0,K.jsx)(`span`,{className:`font-mono font-semibold text-base-content/70`,children:m.fn||`<anonymous>`}),(0,K.jsx)(`span`,{className:`opacity-30`,children:`—`}),(0,K.jsx)(`span`,{className:`font-mono`,children:Fo(m.file)}),m.line&&(0,K.jsxs)(`span`,{className:`badge badge-xs badge-ghost font-mono`,children:[`:`,m.line,`:`,m.col]})]})]})]}),(0,K.jsxs)(`div`,{className:`bg-base-100 rounded-2xl border border-base-300 overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`px-5 py-3 border-b border-base-300`,children:(0,K.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider opacity-40`,children:`Context`})}),(0,K.jsx)(`div`,{className:`divide-y divide-base-200`,children:[{label:`Route`,value:u},{label:`Time`,value:new Date().toISOString()},{label:`User Agent`,value:f}].map(({label:e,value:t})=>(0,K.jsxs)(`div`,{className:`px-5 py-2.5 flex items-start gap-4`,children:[(0,K.jsx)(`span`,{className:`text-xs font-semibold opacity-40 w-24 shrink-0 pt-0.5`,children:e}),(0,K.jsx)(`span`,{className:`font-mono text-xs break-all text-base-content/70`,children:t})]},e))})]}),l.length>0&&(0,K.jsxs)(`div`,{className:`bg-base-100 rounded-2xl border border-base-300 overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`px-5 py-3 border-b border-base-300 flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`button`,{className:`flex items-center gap-2 text-xs font-semibold uppercase tracking-wider opacity-40 hover:opacity-70 transition-opacity`,onClick:()=>r(e=>!e),children:[(0,K.jsx)(bn,{className:`size-3.5 transition-transform ${n?`rotate-180`:``}`}),`Stack trace`,(0,K.jsxs)(`span`,{className:`badge badge-xs badge-ghost normal-case tracking-normal font-mono`,children:[l.length,` frames`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost opacity-50 hover:opacity-100 ${i?`btn-active`:``}`,onClick:()=>a(e=>!e),children:`raw`}),(0,K.jsx)(Io,{text:c})]})]}),n&&(i?(0,K.jsx)(`pre`,{className:`px-5 py-4 text-[11px] font-mono leading-relaxed text-base-content/60 overflow-x-auto whitespace-pre-wrap`,children:c}):(0,K.jsx)(`div`,{className:`divide-y divide-base-200`,children:l.map((e,t)=>{let n=e.file&&!e.file.includes(`node_modules`)&&!e.file.includes(`chunk-`)&&!e.file.includes(`vendor-`),r=Fo(e.file);return(0,K.jsxs)(`div`,{className:`px-5 py-2 flex items-start gap-3 ${n?`bg-warning/5`:`opacity-40`}`,children:[(0,K.jsx)(`span`,{className:`font-mono text-[10px] opacity-30 w-5 shrink-0 text-right pt-0.5`,children:t}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[e.fn&&(0,K.jsx)(`span`,{className:`font-mono text-xs font-semibold ${n?`text-warning`:`text-base-content/60`}`,children:e.fn}),n&&(0,K.jsx)(`span`,{className:`badge badge-xs badge-warning badge-soft`,children:`app`})]}),(0,K.jsxs)(`div`,{className:`font-mono text-[10px] text-base-content/40 truncate`,children:[r,e.line&&(0,K.jsxs)(`span`,{className:`text-base-content/60 ml-0.5`,children:[`:`,e.line,`:`,e.col]})]})]})]},t)})}))]})]}),(0,K.jsxs)(`div`,{className:`lg:w-64 p-6 space-y-4 shrink-0`,children:[(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`button`,{className:`btn btn-primary w-full gap-2`,onClick:()=>window.location.reload(),children:[(0,K.jsx)(Pr,{className:`size-4`}),` Reload page`]}),t&&(0,K.jsx)(`button`,{className:`btn btn-ghost w-full gap-2`,onClick:t,children:`Try to recover`}),(0,K.jsx)(`button`,{className:`btn btn-ghost w-full gap-2`,onClick:()=>{window.location.href=`/`},children:`Go home`})]}),(0,K.jsx)(`div`,{className:`divider text-xs opacity-30`,children:`about`}),(0,K.jsxs)(`div`,{className:`space-y-1 text-xs text-base-content/40`,children:[(0,K.jsx)(`p`,{children:`This error was caught by the app's error boundary. The details above will help you identify the root cause.`}),(0,K.jsxs)(`p`,{className:`mt-2`,children:[`App frames are `,(0,K.jsx)(`span`,{className:`text-warning font-semibold`,children:`highlighted`}),`.`]})]})]})]})]})}var Ro=N({component:No,errorComponent:Lo}),zo=[{to:`/settings/project`,label:`Project`,icon:qn},{to:`/settings/agents`,label:`Agents`,icon:pr},{to:`/settings/execution`,label:`Execution`,icon:Rn},{to:`/settings/assets`,label:`Assets`,icon:ri},{to:`/settings/services`,label:`Services`,icon:zr},{to:`/settings/notifications`,label:`Notifications`,icon:pn},{to:`/settings/providers`,label:`Providers`,icon:Ur},{to:`/settings/system`,label:`System`,icon:Br}],Bo=v(`/settings`)({component:Vo});function Vo(){let e=P().location.pathname;return(0,K.jsx)(`div`,{className:`flex-1 flex flex-col min-h-0 px-4 pb-4 pt-3`,children:(0,K.jsxs)(`div`,{className:`max-w-5xl w-full mx-auto flex-1 flex flex-col min-h-0 gap-5`,children:[(0,K.jsx)(`div`,{role:`tablist`,className:`tabs tabs-lift overflow-x-auto flex-nowrap scrollbar-none`,style:{scrollbarWidth:`none`},children:zo.map(({to:t,label:n,icon:r})=>(0,K.jsxs)(b,{to:t,role:`tab`,className:`tab gap-1.5 whitespace-nowrap ${e.startsWith(t)?`tab-active`:``}`,children:[(0,K.jsx)(r,{className:`size-3.5`}),n]},t))}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,K.jsx)(T,{})})]})})}function Ho(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=Ho(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var Uo={value:()=>{}};function Wo(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new Go(n)}function Go(e){this._=e}function Ko(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}Go.prototype=Wo.prototype={constructor:Go,on:function(e,t){var n=this._,r=Ko(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=qo(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=Jo(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Jo(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Go(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function qo(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Jo(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=Uo,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Yo={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function Xo(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),Yo.hasOwnProperty(t)?{space:Yo[t],local:e}:e}function Zo(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function Qo(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function $o(e){var t=Xo(e);return(t.local?Qo:Zo)(t)}function es(){}function ts(e){return e==null?es:function(){return this.querySelector(e)}}function ns(e){typeof e!=`function`&&(e=ts(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new Wc(r,this._parents)}function rs(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function is(){return[]}function as(e){return e==null?is:function(){return this.querySelectorAll(e)}}function os(e){return function(){return rs(e.apply(this,arguments))}}function ss(e){e=typeof e==`function`?os(e):as(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new Wc(r,i)}function cs(e){return function(){return this.matches(e)}}function ls(e){return function(t){return t.matches(e)}}var us=Array.prototype.find;function ds(e){return function(){return us.call(this.children,e)}}function fs(){return this.firstElementChild}function ps(e){return this.select(e==null?fs:ds(typeof e==`function`?e:ls(e)))}var ms=Array.prototype.filter;function hs(){return Array.from(this.children)}function gs(e){return function(){return ms.call(this.children,e)}}function _s(e){return this.selectAll(e==null?hs:gs(typeof e==`function`?e:ls(e)))}function vs(e){typeof e!=`function`&&(e=cs(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new Wc(r,this._parents)}function ys(e){return Array(e.length)}function bs(){return new Wc(this._enter||this._groups.map(ys),this._parents)}function xs(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}xs.prototype={constructor:xs,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Ss(e){return function(){return e}}function Cs(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new xs(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function ws(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new xs(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function Ts(e){return e.__data__}function Es(e,t){if(!arguments.length)return Array.from(this,Ts);var n=t?ws:Cs,r=this._parents,i=this._groups;typeof e!=`function`&&(e=Ss(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=Ds(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new Wc(o,r),o._enter=s,o._exit=c,o}function Ds(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function Os(){return new Wc(this._exit||this._groups.map(ys),this._parents)}function ks(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function As(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new Wc(s,this._parents)}function js(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function Ms(e){e||=Ns;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new Wc(i,this._parents).order()}function Ns(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ps(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Fs(){return Array.from(this)}function Is(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function Ls(){let e=0;for(let t of this)++e;return e}function Rs(){return!this.node()}function zs(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function Bs(e){return function(){this.removeAttribute(e)}}function Vs(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Hs(e,t){return function(){this.setAttribute(e,t)}}function Us(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Ws(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Gs(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Ks(e,t){var n=Xo(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?Vs:Bs:typeof t==`function`?n.local?Gs:Ws:n.local?Us:Hs)(n,t))}function qs(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Js(e){return function(){this.style.removeProperty(e)}}function Ys(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Xs(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Zs(e,t,n){return arguments.length>1?this.each((t==null?Js:typeof t==`function`?Xs:Ys)(e,t,n??``)):Qs(this.node(),e)}function Qs(e,t){return e.style.getPropertyValue(t)||qs(e).getComputedStyle(e,null).getPropertyValue(t)}function $s(e){return function(){delete this[e]}}function ec(e,t){return function(){this[e]=t}}function tc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function nc(e,t){return arguments.length>1?this.each((t==null?$s:typeof t==`function`?tc:ec)(e,t)):this.node()[e]}function rc(e){return e.trim().split(/^|\s+/)}function ic(e){return e.classList||new ac(e)}function ac(e){this._node=e,this._names=rc(e.getAttribute(`class`)||``)}ac.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function oc(e,t){for(var n=ic(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function sc(e,t){for(var n=ic(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function cc(e){return function(){oc(this,e)}}function lc(e){return function(){sc(this,e)}}function uc(e,t){return function(){(t.apply(this,arguments)?oc:sc)(this,e)}}function dc(e,t){var n=rc(e+``);if(arguments.length<2){for(var r=ic(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?uc:t?cc:lc)(n,t))}function fc(){this.textContent=``}function pc(e){return function(){this.textContent=e}}function mc(e){return function(){this.textContent=e.apply(this,arguments)??``}}function hc(e){return arguments.length?this.each(e==null?fc:(typeof e==`function`?mc:pc)(e)):this.node().textContent}function gc(){this.innerHTML=``}function _c(e){return function(){this.innerHTML=e}}function vc(e){return function(){this.innerHTML=e.apply(this,arguments)??``}}function yc(e){return arguments.length?this.each(e==null?gc:(typeof e==`function`?vc:_c)(e)):this.node().innerHTML}function bc(){this.nextSibling&&this.parentNode.appendChild(this)}function xc(){return this.each(bc)}function Sc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Cc(){return this.each(Sc)}function wc(e){var t=typeof e==`function`?e:$o(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Tc(){return null}function Ec(e,t){var n=typeof e==`function`?e:$o(e),r=t==null?Tc:typeof t==`function`?t:ts(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Dc(){var e=this.parentNode;e&&e.removeChild(this)}function Oc(){return this.each(Dc)}function kc(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ac(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function jc(e){return this.select(e?Ac:kc)}function Mc(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function Nc(e){return function(t){e.call(this,t,this.__data__)}}function Pc(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function Fc(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function Ic(e,t,n){return function(){var r=this.__on,i,a=Nc(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function Lc(e,t,n){var r=Pc(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?Ic:Fc,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function Rc(e,t,n){var r=qs(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function zc(e,t){return function(){return Rc(this,e,t)}}function Bc(e,t){return function(){return Rc(this,e,t.apply(this,arguments))}}function Vc(e,t){return this.each((typeof t==`function`?Bc:zc)(e,t))}function*Hc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var Uc=[null];function Wc(e,t){this._groups=e,this._parents=t}function Gc(){return new Wc([[document.documentElement]],Uc)}function Kc(){return this}Wc.prototype=Gc.prototype={constructor:Wc,select:ns,selectAll:ss,selectChild:ps,selectChildren:_s,filter:vs,data:Es,enter:bs,exit:Os,join:ks,merge:As,selection:Kc,order:js,sort:Ms,call:Ps,nodes:Fs,node:Is,size:Ls,empty:Rs,each:zs,attr:Ks,style:Zs,property:nc,classed:dc,text:hc,html:yc,raise:xc,lower:Cc,append:wc,insert:Ec,remove:Oc,clone:jc,datum:Mc,on:Lc,dispatch:Vc,[Symbol.iterator]:Hc};function qc(e){return typeof e==`string`?new Wc([[document.querySelector(e)]],[document.documentElement]):new Wc([[e]],Uc)}function Jc(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Yc(e,t){if(e=Jc(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var Xc={passive:!1},Zc={capture:!0,passive:!1};function Qc(e){e.stopImmediatePropagation()}function $c(e){e.preventDefault(),e.stopImmediatePropagation()}function el(e){var t=e.document.documentElement,n=qc(e).on(`dragstart.drag`,$c,Zc);`onselectstart`in t?n.on(`selectstart.drag`,$c,Zc):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function tl(e,t){var n=e.document.documentElement,r=qc(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,$c,Zc),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var nl=e=>()=>e;function rl(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}rl.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function il(e){return!e.ctrlKey&&!e.button}function al(){return this.parentNode}function ol(e,t){return t??{x:e.x,y:e.y}}function sl(){return navigator.maxTouchPoints||`ontouchstart`in this}function cl(){var e=il,t=al,n=ol,r=sl,i={},a=Wo(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,Xc).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(qc(n.view).on(`mousemove.drag`,m,Zc).on(`mouseup.drag`,h,Zc),el(n.view),Qc(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if($c(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){qc(e.view).on(`mousemove.drag mouseup.drag`,null),tl(e.view,l),$c(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&(Qc(n),c(`start`,n,i[s]))}}function _(e){var t=e.changedTouches,n=t.length,r,a;for(r=0;r<n;++r)(a=i[t[r].identifier])&&($c(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(Qc(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=Yc(l||r,t),p,m,h;if((h=n.call(e,new rl(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=Yc(l||a,t),_=o;break}u.call(r,e,new rl(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:nl(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:nl(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:nl(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:nl(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}function ll(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function ul(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function dl(){}var fl=.7,pl=1/fl,ml=`\\s*([+-]?\\d+)\\s*`,hl=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,gl=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,_l=/^#([0-9a-f]{3,8})$/,vl=RegExp(`^rgb\\(${ml},${ml},${ml}\\)$`),yl=RegExp(`^rgb\\(${gl},${gl},${gl}\\)$`),bl=RegExp(`^rgba\\(${ml},${ml},${ml},${hl}\\)$`),xl=RegExp(`^rgba\\(${gl},${gl},${gl},${hl}\\)$`),Sl=RegExp(`^hsl\\(${hl},${gl},${gl}\\)$`),Cl=RegExp(`^hsla\\(${hl},${gl},${gl},${hl}\\)$`),wl={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};ll(dl,kl,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Tl,formatHex:Tl,formatHex8:El,formatHsl:Dl,formatRgb:Ol,toString:Ol});function Tl(){return this.rgb().formatHex()}function El(){return this.rgb().formatHex8()}function Dl(){return Hl(this).formatHsl()}function Ol(){return this.rgb().formatRgb()}function kl(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=_l.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Al(t):n===3?new Pl(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?jl(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?jl(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=vl.exec(e))?new Pl(t[1],t[2],t[3],1):(t=yl.exec(e))?new Pl(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=bl.exec(e))?jl(t[1],t[2],t[3],t[4]):(t=xl.exec(e))?jl(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Sl.exec(e))?Vl(t[1],t[2]/100,t[3]/100,1):(t=Cl.exec(e))?Vl(t[1],t[2]/100,t[3]/100,t[4]):wl.hasOwnProperty(e)?Al(wl[e]):e===`transparent`?new Pl(NaN,NaN,NaN,0):null}function Al(e){return new Pl(e>>16&255,e>>8&255,e&255,1)}function jl(e,t,n,r){return r<=0&&(e=t=n=NaN),new Pl(e,t,n,r)}function Ml(e){return e instanceof dl||(e=kl(e)),e?(e=e.rgb(),new Pl(e.r,e.g,e.b,e.opacity)):new Pl}function Nl(e,t,n,r){return arguments.length===1?Ml(e):new Pl(e,t,n,r??1)}function Pl(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}ll(Pl,Nl,ul(dl,{brighter(e){return e=e==null?pl:pl**+e,new Pl(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?fl:fl**+e,new Pl(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Pl(zl(this.r),zl(this.g),zl(this.b),Rl(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Fl,formatHex:Fl,formatHex8:Il,formatRgb:Ll,toString:Ll}));function Fl(){return`#${Bl(this.r)}${Bl(this.g)}${Bl(this.b)}`}function Il(){return`#${Bl(this.r)}${Bl(this.g)}${Bl(this.b)}${Bl((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ll(){let e=Rl(this.opacity);return`${e===1?`rgb(`:`rgba(`}${zl(this.r)}, ${zl(this.g)}, ${zl(this.b)}${e===1?`)`:`, ${e})`}`}function Rl(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function zl(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Bl(e){return e=zl(e),(e<16?`0`:``)+e.toString(16)}function Vl(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Wl(e,t,n,r)}function Hl(e){if(e instanceof Wl)return new Wl(e.h,e.s,e.l,e.opacity);if(e instanceof dl||(e=kl(e)),!e)return new Wl;if(e instanceof Wl)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new Wl(o,s,c,e.opacity)}function Ul(e,t,n,r){return arguments.length===1?Hl(e):new Wl(e,t,n,r??1)}function Wl(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}ll(Wl,Ul,ul(dl,{brighter(e){return e=e==null?pl:pl**+e,new Wl(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?fl:fl**+e,new Wl(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new Pl(ql(e>=240?e-240:e+120,i,r),ql(e,i,r),ql(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Wl(Gl(this.h),Kl(this.s),Kl(this.l),Rl(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=Rl(this.opacity);return`${e===1?`hsl(`:`hsla(`}${Gl(this.h)}, ${Kl(this.s)*100}%, ${Kl(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function Gl(e){return e=(e||0)%360,e<0?e+360:e}function Kl(e){return Math.max(0,Math.min(1,e||0))}function ql(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var Jl=e=>()=>e;function Yl(e,t){return function(n){return e+n*t}}function Xl(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function Zl(e){return(e=+e)==1?Ql:function(t,n){return n-t?Xl(t,n,e):Jl(isNaN(t)?n:t)}}function Ql(e,t){var n=t-e;return n?Yl(e,n):Jl(isNaN(e)?t:e)}var $l=(function e(t){var n=Zl(t);function r(e,t){var r=n((e=Nl(e)).r,(t=Nl(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=Ql(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function eu(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function tu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function nu(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=du(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function ru(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function iu(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function au(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=du(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var ou=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,su=new RegExp(ou.source,`g`);function cu(e){return function(){return e}}function lu(e){return function(t){return e(t)+``}}function uu(e,t){var n=ou.lastIndex=su.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=ou.exec(e))&&(i=su.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:iu(r,i)})),n=su.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?lu(c[0].x):cu(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function du(e,t){var n=typeof t,r;return t==null||n===`boolean`?Jl(t):(n===`number`?iu:n===`string`?(r=kl(t))?(t=r,$l):uu:t instanceof kl?$l:t instanceof Date?ru:tu(t)?eu:Array.isArray(t)?nu:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?au:iu)(e,t)}var fu=180/Math.PI,pu={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function mu(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*fu,skewX:Math.atan(c)*fu,scaleX:o,scaleY:s}}var hu;function gu(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?pu:mu(t.a,t.b,t.c,t.d,t.e,t.f)}function _u(e){return e==null||(hu||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),hu.setAttribute(`transform`,e),!(e=hu.transform.baseVal.consolidate()))?pu:(e=e.matrix,mu(e.a,e.b,e.c,e.d,e.e,e.f))}function vu(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:iu(e,i)},{i:c-2,x:iu(r,a)})}else (i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:iu(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:iu(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:iu(e,n)},{i:s-2,x:iu(t,r)})}else (n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var yu=vu(gu,`px, `,`px)`,`deg)`),bu=vu(_u,`, `,`)`,`)`),xu=1e-12;function Su(e){return((e=Math.exp(e))+1/e)/2}function Cu(e){return((e=Math.exp(e))-1/e)/2}function wu(e){return((e=Math.exp(2*e))-1)/(e+1)}var Tu=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<xu)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=Su(y),c=s/(n*g)*(i*wu(t*r+y)-Cu(y));return[a+c*d,o+c*f,s*i/Su(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),Eu=0,Du=0,Ou=0,ku=1e3,Au,ju,Mu=0,Nu=0,Pu=0,Fu=typeof performance==`object`&&performance.now?performance:Date,Iu=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Lu(){return Nu||=(Iu(Ru),Fu.now()+Pu)}function Ru(){Nu=0}function zu(){this._call=this._time=this._next=null}zu.prototype=Bu.prototype={constructor:zu,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?Lu():+n)+(t==null?0:+t),!this._next&&ju!==this&&(ju?ju._next=this:Au=this,ju=this),this._call=e,this._time=n,Gu()},stop:function(){this._call&&(this._call=null,this._time=1/0,Gu())}};function Bu(e,t,n){var r=new zu;return r.restart(e,t,n),r}function Vu(){Lu(),++Eu;for(var e=Au,t;e;)(t=Nu-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Eu}function Hu(){Nu=(Mu=Fu.now())+Pu,Eu=Du=0;try{Vu()}finally{Eu=0,Wu(),Nu=0}}function Uu(){var e=Fu.now(),t=e-Mu;t>ku&&(Pu-=t,Mu=e)}function Wu(){for(var e,t=Au,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Au=n);ju=e,Gu(r)}function Gu(e){Eu||(Du&&=clearTimeout(Du),e-Nu>24?(e<1/0&&(Du=setTimeout(Hu,e-Fu.now()-Pu)),Ou&&=clearInterval(Ou)):(Ou||=(Mu=Fu.now(),setInterval(Uu,ku)),Eu=1,Iu(Hu)))}function Ku(e,t,n){var r=new zu;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var qu=Wo(`start`,`end`,`cancel`,`interrupt`),Ju=[];function Yu(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;$u(e,n,{name:t,index:r,group:i,on:qu,tween:Ju,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function Xu(e,t){var n=Qu(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function Zu(e,t){var n=Qu(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function Qu(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function $u(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Bu(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return Ku(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(Ku(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function ed(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function td(e){return this.each(function(){ed(this,e)})}function nd(e,t){var n,r;return function(){var i=Zu(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function rd(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=Zu(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function id(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=Qu(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?nd:rd)(n,e,t))}function ad(e,t,n){var r=e._id;return e.each(function(){var e=Zu(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return Qu(e,r).value[t]}}function od(e,t){var n;return(typeof t==`number`?iu:t instanceof kl?$l:(n=kl(t))?(t=n,$l):uu)(e,t)}function sd(e){return function(){this.removeAttribute(e)}}function cd(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ld(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function ud(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function dd(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function fd(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function pd(e,t){var n=Xo(e),r=n===`transform`?bu:od;return this.attrTween(e,typeof t==`function`?(n.local?fd:dd)(n,r,ad(this,`attr.`+e,t)):t==null?(n.local?cd:sd)(n):(n.local?ud:ld)(n,r,t))}function md(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function hd(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function gd(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&hd(e,i)),n}return i._value=t,i}function _d(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&md(e,i)),n}return i._value=t,i}function vd(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=Xo(e);return this.tween(n,(r.local?gd:_d)(r,t))}function yd(e,t){return function(){Xu(this,e).delay=+t.apply(this,arguments)}}function bd(e,t){return t=+t,function(){Xu(this,e).delay=t}}function xd(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?yd:bd)(t,e)):Qu(this.node(),t).delay}function Sd(e,t){return function(){Zu(this,e).duration=+t.apply(this,arguments)}}function Cd(e,t){return t=+t,function(){Zu(this,e).duration=t}}function wd(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?Sd:Cd)(t,e)):Qu(this.node(),t).duration}function Td(e,t){if(typeof t!=`function`)throw Error();return function(){Zu(this,e).ease=t}}function Ed(e){var t=this._id;return arguments.length?this.each(Td(t,e)):Qu(this.node(),t).ease}function Dd(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();Zu(this,e).ease=n}}function Od(e){if(typeof e!=`function`)throw Error();return this.each(Dd(this._id,e))}function kd(e){typeof e!=`function`&&(e=cs(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new af(r,this._parents,this._name,this._id)}function Ad(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new af(o,this._parents,this._name,this._id)}function jd(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function Md(e,t,n){var r,i,a=jd(t)?Xu:Zu;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function Nd(e,t){var n=this._id;return arguments.length<2?Qu(this.node(),n).on.on(e):this.each(Md(n,e,t))}function Pd(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Fd(){return this.on(`end.remove`,Pd(this._id))}function Id(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=ts(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,Yu(l[f],t,n,f,l,Qu(u,n)));return new af(a,this._parents,t,n)}function Ld(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=as(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=Qu(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&Yu(p,t,n,h,f,m);a.push(f),o.push(u)}return new af(a,o,t,n)}var Rd=Gc.prototype.constructor;function zd(){return new Rd(this._groups,this._parents)}function Bd(e,t){var n,r,i;return function(){var a=Qs(this,e),o=(this.style.removeProperty(e),Qs(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function Vd(e){return function(){this.style.removeProperty(e)}}function Hd(e,t,n){var r,i=n+``,a;return function(){var o=Qs(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function Ud(e,t,n){var r,i,a;return function(){var o=Qs(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),Qs(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function Wd(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=Zu(this,e),l=c.on,u=c.value[a]==null?s||=Vd(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function Gd(e,t,n){var r=(e+=``)==`transform`?yu:od;return t==null?this.styleTween(e,Bd(e,r)).on(`end.style.`+e,Vd(e)):typeof t==`function`?this.styleTween(e,Ud(e,r,ad(this,`style.`+e,t))).each(Wd(this._id,e)):this.styleTween(e,Hd(e,r,t),n).on(`end.style.`+e,null)}function Kd(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function qd(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&Kd(e,a,n)),r}return a._value=t,a}function Jd(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,qd(e,t,n??``))}function Yd(e){return function(){this.textContent=e}}function Xd(e){return function(){this.textContent=e(this)??``}}function Zd(e){return this.tween(`text`,typeof e==`function`?Xd(ad(this,`text`,e)):Yd(e==null?``:e+``))}function Qd(e){return function(t){this.textContent=e.call(this,t)}}function $d(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Qd(r)),t}return r._value=e,r}function ef(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,$d(e))}function tf(){for(var e=this._name,t=this._id,n=sf(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=Qu(c,t);Yu(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new af(r,this._parents,e,n)}function nf(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=Zu(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var rf=0;function af(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function of(e){return Gc().transition(e)}function sf(){return++rf}var cf=Gc.prototype;af.prototype=of.prototype={constructor:af,select:Id,selectAll:Ld,selectChild:cf.selectChild,selectChildren:cf.selectChildren,filter:kd,merge:Ad,selection:zd,transition:tf,call:cf.call,nodes:cf.nodes,node:cf.node,size:cf.size,empty:cf.empty,each:cf.each,on:Nd,attr:pd,attrTween:vd,style:Gd,styleTween:Jd,text:Zd,textTween:ef,remove:Fd,tween:id,delay:xd,duration:wd,ease:Ed,easeVarying:Od,end:nf,[Symbol.iterator]:cf[Symbol.iterator]};function lf(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var uf={time:null,delay:0,duration:250,ease:lf};function df(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function ff(e){var t,n;e instanceof af?(t=e._id,e=e._name):(t=sf(),(n=uf).time=Lu(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&Yu(c,e,t,l,o,n||df(c,t));return new af(r,this._parents,e,t)}Gc.prototype.interrupt=td,Gc.prototype.transition=ff;var pf=e=>()=>e;function mf(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function hf(e,t,n){this.k=e,this.x=t,this.y=n}hf.prototype={constructor:hf,scale:function(e){return e===1?this:new hf(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new hf(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var gf=new hf(1,0,0);_f.prototype=hf.prototype;function _f(e){for(;!e.__zoom;)if(!(e=e.parentNode))return gf;return e.__zoom}function vf(e){e.stopImmediatePropagation()}function yf(e){e.preventDefault(),e.stopImmediatePropagation()}function bf(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function xf(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute(`viewBox`)?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Sf(){return this.__zoom||gf}function Cf(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function wf(){return navigator.maxTouchPoints||`ontouchstart`in this}function Tf(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function Ef(){var e=bf,t=xf,n=Tf,r=Cf,i=wf,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=Tu,l=Wo(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,Sf).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,Sf),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(gf.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new hf(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new hf(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new hf(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=qc(this.that).datum();l.call(e,this.that,new mf(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=Yc(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],ed(this),s.start();yf(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=qc(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=Yc(t,i),l=t.clientX,u=t.clientY;el(t.view),vf(t),a.mouse=[c,this.__zoom.invert(c)],ed(this),a.start();function d(e){if(yf(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=Yc(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),tl(e.view,a.moved),yf(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=Yc(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);yf(r),s>0?qc(this).transition().duration(s).call(x,d,c,r):qc(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(vf(t),s=0;s<i;++s)c=r[s],l=Yc(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),ed(this),a.start())}}function O(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(yf(e),s=0;s<a;++s)c=i[s],l=Yc(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function k(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(vf(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=Yc(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=qc(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:pf(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:pf(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:pf(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:pf([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}var Df={error001:()=>`[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The React Flow parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`},Of=[[-1/0,-1/0],[1/0,1/0]],kf=[`Enter`,` `,`Escape`],Af={"node.a11yDescription.default":`Press enter or space to select a node. Press delete to remove it and escape to cancel.`,"node.a11yDescription.keyboardDisabled":`Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.`,"node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`,"controls.ariaLabel":`Control Panel`,"controls.zoomIn.ariaLabel":`Zoom In`,"controls.zoomOut.ariaLabel":`Zoom Out`,"controls.fitView.ariaLabel":`Fit View`,"controls.interactive.ariaLabel":`Toggle Interactivity`,"minimap.ariaLabel":`Mini Map`,"handle.ariaLabel":`Handle`},jf;(function(e){e.Strict=`strict`,e.Loose=`loose`})(jf||={});var Mf;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(Mf||={});var Nf;(function(e){e.Partial=`partial`,e.Full=`full`})(Nf||={});var Pf={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},Ff;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(Ff||={});var If;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(If||={});var Y;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(Y||={});var Lf={[Y.Left]:Y.Right,[Y.Right]:Y.Left,[Y.Top]:Y.Bottom,[Y.Bottom]:Y.Top};function Rf(e){return e===null?null:e?`valid`:`invalid`}var zf=e=>`id`in e&&`source`in e&&`target`in e,Bf=e=>`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),Vf=e=>`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),Hf=(e,t=[0,0])=>{let{width:n,height:r}=xp(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},Uf=(e,t={nodeOrigin:[0,0]})=>e.length===0?{x:0,y:0,width:0,height:0}:ip(e.reduce((e,n)=>{let r=typeof n==`string`,i=!t.nodeLookup&&!r?n:void 0;return t.nodeLookup&&(i=r?t.nodeLookup.get(n):Vf(n)?n:t.nodeLookup.get(n.id)),np(e,i?op(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),Wf=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=np(n,op(e)),r=!0)}),r?ip(n):{x:0,y:0,width:0,height:0}},Gf=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s={...pp(t,[n,r,i]),width:t.width/i,height:t.height/i},c=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??null,l=e.height??t.height??t.initialHeight??null,u=cp(s,ap(t)),d=(i??0)*(l??0),f=a&&u>0;(!t.internals.handleBounds||f||u>=d||t.dragging)&&c.push(t)}return c},Kf=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function qf(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{e.measured.width&&e.measured.height&&(t?.includeHiddenNodes||!e.hidden)&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function Jf({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return Promise.resolve(!0);let s=vp(Wf(qf(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),Promise.resolve(!0)}function Yf({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent)if(!s)a?.(`005`,Df.error005());else{let e=s.measured.width,t=s.measured.height;e&&t&&(d=[[c,l],[c+e,l+t]])}else s&&bp(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=bp(d)?Qf(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,Df.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function Xf({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=Kf(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var Zf=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Qf=(e={x:0,y:0},t,n)=>({x:Zf(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Zf(e.y,t[0][1],t[1][1]-(n?.height??0))});function $f(e,t,n){let{width:r,height:i}=xp(n),{x:a,y:o}=n.internals.positionAbsolute;return Qf(e,[[a,o],[a+r,o+i]],t)}var ep=(e,t,n)=>e<t?Zf(Math.abs(e-t),1,t)/t:e>n?-Zf(Math.abs(e-n),1,t)/t:0,tp=(e,t,n=15,r=40)=>[ep(e.x,r,t.width-r)*n,ep(e.y,r,t.height-r)*n],np=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),rp=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),ip=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),ap=(e,t=[0,0])=>{let{x:n,y:r}=Vf(e)?e.internals.positionAbsolute:Hf(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},op=(e,t=[0,0])=>{let{x:n,y:r}=Vf(e)?e.internals.positionAbsolute:Hf(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},sp=(e,t)=>ip(np(rp(e),rp(t))),cp=(e,t)=>{let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},lp=e=>up(e.width)&&up(e.height)&&up(e.x)&&up(e.y),up=e=>!isNaN(e)&&isFinite(e),dp=(e,t)=>{},fp=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),pp=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?fp(s,o):s},mp=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function hp(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function gp(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=hp(e,n),i=hp(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=hp(e.top??e.y??0,n),i=hp(e.bottom??e.y??0,n),a=hp(e.left??e.x??0,t),o=hp(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function _p(e,t,n,r,i,a){let{x:o,y:s}=mp(e,[t,n,r]),{x:c,y:l}=mp({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var vp=(e,t,n,r,i,a)=>{let o=gp(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=Zf(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=_p(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},yp=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function bp(e){return e!=null&&e!==`parent`}function xp(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Sp(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Cp(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function wp(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Tp(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function Ep(e){return{...Af,...e||{}}}function Dp(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=Np(e),s=pp({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?fp(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var Op=e=>({width:e.offsetWidth,height:e.offsetHeight}),kp=e=>e?.getRootNode?.()||window?.document,Ap=[`INPUT`,`SELECT`,`TEXTAREA`];function jp(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?Ap.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var Mp=e=>`clientX`in e,Np=(e,t)=>{let n=Mp(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},Pp=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...Op(t)}})};function Fp({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function Ip(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Lp({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case Y.Left:return[t-Ip(t-r,a),n];case Y.Right:return[t+Ip(r-t,a),n];case Y.Top:return[t,n-Ip(n-i,a)];case Y.Bottom:return[t,n+Ip(i-n,a)]}}function Rp({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:r,targetY:i,targetPosition:a=Y.Top,curvature:o=.25}){let[s,c]=Lp({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=Lp({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=Fp({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function zp({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function Bp({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function Vp({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=np(op(e),op(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),cp({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},ip(a))>0}var Hp=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,Up=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),Wp=(e,t,n={})=>{if(!e.source||!e.target)return Df.error006(),t;let r=n.getEdgeId||Hp,i;return i=zf(e)?{...e}:{...e,id:r(e)},Up(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function Gp({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=zp({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var Kp={[Y.Left]:{x:-1,y:0},[Y.Right]:{x:1,y:0},[Y.Top]:{x:0,y:-1},[Y.Bottom]:{x:0,y:1}},qp=({source:e,sourcePosition:t=Y.Bottom,target:n})=>t===Y.Left||t===Y.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Jp=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function Yp({source:e,sourcePosition:t=Y.Bottom,target:n,targetPosition:r=Y.Top,center:i,offset:a,stepPosition:o}){let s=Kp[t],c=Kp[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=qp({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=zp({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function Xp(e,t,n,r){let i=Math.min(Jp(e,t)/2,Jp(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function Zp({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:r,targetY:i,targetPosition:a=Y.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=Yp({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u}),g=`M${d[0].x} ${d[0].y}`;for(let e=1;e<d.length-1;e++)g+=Xp(d[e-1],d[e],d[e+1],o);return g+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[g,f,p,m,h]}function Qp(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function $p(e){let{sourceNode:t,targetNode:n}=e;if(!Qp(t)||!Qp(n))return null;let r=t.internals.handleBounds||em(t.handles),i=n.internals.handleBounds||em(n.handles),a=nm(r?.source??[],e.sourceHandle),o=nm(e.connectionMode===jf.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,Df.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||Y.Bottom,c=o?.position||Y.Top,l=tm(t,a,s),u=tm(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function em(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function tm(e,t,n=Y.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??xp(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case Y.Top:return{x:i+o/2,y:a};case Y.Right:return{x:i+o,y:a+s/2};case Y.Bottom:return{x:i+o/2,y:a+s};case Y.Left:return{x:i,y:a+s/2}}}function nm(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function rm(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function im(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=rm(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var am=1e3,om=10,sm={nodeOrigin:[0,0],nodeExtent:Of,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},cm={...sm,checkEquality:!0};function lm(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function um(e,t,n){let r=lm(sm,n);for(let n of e.values())if(n.parentId)hm(n,e,t,r);else{let e=Qf(Hf(n,r.nodeOrigin),bp(n.extent)?n.extent:r.nodeExtent,xp(n));n.internals.positionAbsolute=e}}function dm(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function fm(e){return e===`manual`}function pm(e,t,n,r={}){let i=lm(cm,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!fm(i.zIndexMode)?am:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=Qf(Hf(u,i.nodeOrigin),bp(u.extent)?u.extent:i.nodeExtent,xp(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:dm(u,e),z:gm(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&hm(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function mm(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function hm(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=lm(sm,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}mm(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*om),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=_m(e,u,o,s,a&&!fm(c)?am:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function gm(e,t,n){let r=up(e.zIndex)?e.zIndex:0;return fm(n)?r:r+(e.selected?t:0)}function _m(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=xp(e),l=Hf(e,n),u=bp(e.extent)?Qf(l,e.extent,c):l,d=Qf({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=$f(d,c,t));let f=gm(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function vm(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=sp(a.get(n.parentId)?.expandedRect??ap(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=xp(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function ym(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=Op(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=bp(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;e.parentId&&e.extent===`parent`?h=$f(h,s,t.get(e.parentId)):m&&(h=Qf(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:Pp(`source`,r.nodeElement,p,d,e.id),target:Pp(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&hm(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:ap(g,i)}))}}if(f.length>0){let e=vm(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function bm({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r),s=!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2]);return Promise.resolve(s)}function xm(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function Sm(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;xm(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),xm(`target`,s,c,e,i,o),t.set(r.id,r)}}function Cm(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:Cm(n,t):!1}function wm(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function Tm(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!Cm(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function Em({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function Dm({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=fp(a,t);return{x:o.x-a.x,y:o.y-a.y}}function Om({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=qc(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?rp(Wf(s)):null,x=v&&l?Dm({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:fp(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=Yf({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=Em({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=tp(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=Dp(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=Tm(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=Em({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=cl().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=Dp(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=Np(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=Dp(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=Np(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=Np(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!(!d||p)&&(c=!1,d=!1,cancelAnimationFrame(o),s.size>0)){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=Em({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!wm(t,`.${g}`,v))&&(!_||wm(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function km(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())cp(i,ap(e))>0&&r.push(e);return r}var Am=250;function jm(e,t,n,r){let i=[],a=1/0,o=km(e,n,t+Am);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=tm(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function Mm(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...tm(o,c,c.position,!0)}:c}function Nm(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function Pm(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var Fm=()=>!0;function Im(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=Fm,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=kp(e.target),E=0,D,{x:O,y:k}=Np(e),A=Nm(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=Mm(i,A,r,c,t);if(!N)return;let P=Np(e,j),F=!1,I=null,L=!1,R=null;function z(){if(!u||!j)return;let[e,t]=tp(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(z)}let B={...N,nodeId:i,type:A,position:N.position},V=c.get(i),ee={inProgress:!0,isValid:null,from:tm(V,B,Y.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:V,to:P,toHandle:null,toPosition:Lf[B.position],toNode:null,pointer:P};function te(){M=!0,y(ee),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&te();function H(e){if(!M){let{x:t,y:n}=Np(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;te()}if(!x()||!B){ne(e);return}let a=b();P=Np(e,j),D=jm(pp(P,a,!1,[1,1]),n,c,B),F||=(z(),!0);let s=Lm(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});R=s.handleDomNode,I=s.connection,L=Pm(!!D,s.isValid);let u=c.get(i),f=u?tm(u,B,Y.Left,!0):ee.from,p={...ee,from:f,isValid:L,to:s.toHandle&&L?mp({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:Lf[B.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),ee=p}function ne(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||R)&&I&&L&&h?.(I);let{inProgress:t,...n}=ee,r={...n,toPosition:ee.toHandle?ee.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,L=!1,I=null,R=null,T.removeEventListener(`mousemove`,H),T.removeEventListener(`mouseup`,ne),T.removeEventListener(`touchmove`,H),T.removeEventListener(`touchend`,ne)}}T.addEventListener(`mousemove`,H),T.addEventListener(`mouseup`,ne),T.addEventListener(`touchmove`,H),T.addEventListener(`touchend`,ne)}function Lm(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=Fm,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=Np(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=Nm(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===jf.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=Mm(t,e,a,u,n,!0)}return _}var Rm={onPointerDown:Im,isValid:Lm};function zm({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=qc(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&yp()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=Ef().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:Yc}}var Bm=e=>({x:e.x,y:e.y,zoom:e.k}),Vm=({x:e,y:t,zoom:n})=>gf.translate(e,t).scale(n),Hm=(e,t)=>e.target.closest(`.${t}`),Um=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Wm=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Gm=(e,t=0,n=Wm,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},Km=e=>{let t=e.ctrlKey&&yp()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function qm({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(Hm(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=Yc(u),t=d*2**Km(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===Mf.Vertical?0:u.deltaX*f,m=i===Mf.Horizontal?0:u.deltaY*f;!yp()&&u.shiftKey&&i!==Mf.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=Bm(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(u,h),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,s?.(u,h))}}function Jm({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=Hm(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function Ym({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=Bm(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function Xm({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&Um(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,Bm(a.transform))}}function Zm({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&Um(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=Bm(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function Qm({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:s,noPanClassName:c,lib:l,connectionInProgress:u}){return d=>{let f=e||t,p=n&&d.ctrlKey,m=d.type===`wheel`;if(d.button===1&&d.type===`mousedown`&&(Hm(d,`${l}-flow__node`)||Hm(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!i&&!a&&!n||o||u&&!m||Hm(d,s)&&m||Hm(d,c)&&(!m||i&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type===`touchstart`&&d.touches?.length>1)return d.preventDefault(),!1;if(!f&&!i&&!p&&m||!r&&(d.type===`mousedown`||d.type===`touchstart`)||Array.isArray(r)&&!r.includes(d.button)&&d.type===`mousedown`)return!1;let h=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&h}}function $m({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=Ef().scaleExtent([t,n]).translateExtent(r),f=qc(e).call(d);v({x:i.x,y:i.y,zoom:Zf(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let p=f.on(`wheel.zoom`),m=f.on(`dblclick.zoom`);d.wheelDelta(Km);function h(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?du:Tu).transform(Gm(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function g({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:h,panOnScrollSpeed:g,preventScrolling:v,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&_();let O=i&&!S&&!r;d.clickDistance(D?1/0:!up(E)||E<0?0:E);let k=O?qm({zoomPanValues:l,noWheelClassName:e,d3Selection:f,d3Zoom:d,panOnScrollMode:h,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):Jm({noWheelClassName:e,preventScrolling:v,d3ZoomHandler:p});if(f.on(`wheel.zoom`,k,{passive:!1}),!r){let e=Ym({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});d.on(`start`,e);let t=Xm({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});d.on(`zoom`,t);let r=Zm({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});d.on(`end`,r)}let A=Qm({zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});d.filter(A),x?f.on(`dblclick.zoom`,m):f.on(`dblclick.zoom`,null)}function _(){d.on(`zoom`,null)}async function v(e,t,n){let r=Vm(e),i=d?.constrain()(r,t,n);return i&&await h(i),new Promise(e=>e(i))}async function y(e,t){let n=Vm(e);return await h(n,t),new Promise(e=>e(n))}function b(e){if(f){let t=Vm(e),n=f.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&d?.transform(f,t,null,{sync:!0})}}function x(){let e=f?_f(f.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}function S(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?du:Tu).scaleTo(Gm(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function C(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?du:Tu).scaleBy(Gm(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function w(e){d?.scaleExtent(e)}function T(e){d?.translateExtent(e)}function E(e){let t=!up(e)||e<0?0:e;d?.clickDistance(t)}return{update:g,destroy:_,setViewport:y,setViewportConstrained:v,getViewport:x,scaleTo:S,scaleBy:C,setScaleExtent:w,setTranslateExtent:T,syncViewport:b,setClickDistance:E}}var eh;(function(e){e.Line=`line`,e.Handle=`handle`})(eh||={});function th({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function nh(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function rh(e,t){return Math.max(0,t-e)}function ih(e,t){return Math.max(0,e-t)}function ah(e,t,n){return Math.max(0,t-e,e-n)}function oh(e,t){return e?!t:t}function sh(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=ah(E,h,g),j=ah(D,_,v);if(o){let e=0,t=0;c&&w<0?e=rh(y+w+O,o[0][0]):!c&&w>0&&(e=ih(y+E+O,o[1][0])),l&&T<0?t=rh(b+T+k,o[0][1]):!l&&T>0&&(t=ih(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=ih(y+w,s[0][0]):!c&&w<0&&(e=rh(y+E,s[1][0])),l&&T>0?t=ih(b+T,s[0][1]):!l&&T<0&&(t=rh(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=ah(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?ih(b+k+E/C,o[1][1])*C:rh(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?rh(b+E/C,s[1][1])*C:ih(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=ah(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?ih(y+D*C+O,o[1][0])/C:rh(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?rh(y+D*C,s[1][0])/C:ih(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(oh(c,l)?-w:w)/C:w=(oh(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var ch={width:0,height:0,x:0,y:0},lh={...ch,pointerX:0,pointerY:0,aspectRatio:1};function uh(e){return[[0,0],[e.measured.width,e.measured.height]]}function dh(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function fh({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=qc(e),o={controlDirection:nh(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...ch},h={...lh};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:nh(e)};let g,_=null,v=[],y,b,x,S=!1,C=cl().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=Dp(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId),b=y&&g.extent===`parent`?uh(y):void 0),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=dh(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=Dp(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:O,x:k,y:A}=sh(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),j=D!==C,M=O!==w,N=k!==u&&j,P=A!==f&&M;if(!N&&!P&&!j&&!M)return;if((N||P||E[0]===1||E[1]===1)&&(T.x=N?k:m.x,T.y=P?A:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=k-u,t=A-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(O-w)},l.push(n)}if((j||M)&&(T.width=j&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=M&&(!o.resizeDirection||o.resizeDirection===`vertical`)?O:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x<e&&(m.x=e,h.x-=T.x-e);let t=E[1]*(T.height??0);T.y&&T.y<t&&(m.y=t,h.y-=T.y-t)}let F=th({width:m.width,prevWidth:C,height:m.height,prevHeight:w,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),I={...m,direction:F};p?.(e,I)!==!1&&(S=!0,d?.(e,I),r(T,l))}).on(`end`,e=>{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var ph=t(F(),1),mh=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},hh=e=>e?mh(e):mh,{useDebugValue:gh}=G.default,{useSyncExternalStoreWithSelector:_h}=ph.default,vh=e=>e;function yh(e,t=vh,n){let r=_h(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return gh(r),r}var bh=(e,t)=>{let n=hh(e),r=(e,r=t)=>yh(n,e,r);return Object.assign(r,n),r},xh=(e,t)=>e?bh(e,t):bh;function Sh(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}l();var Ch=(0,G.createContext)(null),wh=Ch.Provider,Th=Df.error001();function X(e,t){let n=(0,G.useContext)(Ch);if(n===null)throw Error(Th);return yh(n,e,t)}function Eh(){let e=(0,G.useContext)(Ch);if(e===null)throw Error(Th);return(0,G.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var Dh={display:`none`},Oh={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},kh=`react-flow__node-desc`,Ah=`react-flow__edge-desc`,jh=`react-flow__aria-live`,Mh=e=>e.ariaLiveMessage,Nh=e=>e.ariaLabelConfig;function Ph({rfId:e}){let t=X(Mh);return(0,K.jsx)(`div`,{id:`${jh}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:Oh,children:t})}function Fh({rfId:e,disableKeyboardA11y:t}){let n=X(Nh);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{id:`${kh}-${e}`,style:Dh,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,K.jsx)(`div`,{id:`${Ah}-${e}`,style:Dh,children:n[`edge.a11yDescription.default`]}),!t&&(0,K.jsx)(Ph,{rfId:e})]})}var Ih=(0,G.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>(0,K.jsx)(`div`,{className:Ho([`react-flow__panel`,n,...`${e}`.split(`-`)]),style:r,ref:a,...i,children:t}));Ih.displayName=`Panel`;function Lh({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:(0,K.jsx)(Ih,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev`,children:(0,K.jsx)(`a`,{href:`https://reactflow.dev`,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var Rh=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},zh=e=>e.id;function Bh(e,t){return Sh(e.selectedNodes.map(zh),t.selectedNodes.map(zh))&&Sh(e.selectedEdges.map(zh),t.selectedEdges.map(zh))}function Vh({onSelectionChange:e}){let t=Eh(),{selectedNodes:n,selectedEdges:r}=X(Rh,Bh);return(0,G.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var Hh=e=>!!e.onSelectionChangeHandlers;function Uh({onSelectionChange:e}){let t=X(Hh);return e||t?(0,K.jsx)(Vh,{onSelectionChange:e}):null}var Wh=typeof window<`u`?G.useLayoutEffect:G.useEffect,Gh=[0,0],Kh={x:0,y:0,zoom:1},qh=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],Jh=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),Yh={translateExtent:Of,nodeOrigin:Gh,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function Xh(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=X(Jh,Sh),l=Eh();Wh(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=Yh,s()}),[]);let u=(0,G.useRef)(Yh);return Wh(()=>{for(let s of qh){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:Ep(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},qh.map(t=>e[t])),null}function Zh(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function Qh(e){let[t,n]=(0,G.useState)(e===`system`?null:e);return(0,G.useEffect)(()=>{if(e!==`system`){n(e);return}let t=Zh(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?Zh()?.matches?`dark`:`light`:t}var $h=typeof document<`u`?document:null;function eg(e=null,t={target:$h,actInsideInputWithModifier:!0}){let[n,r]=(0,G.useState)(!1),i=(0,G.useRef)(!1),a=(0,G.useRef)(new Set([])),[o,s]=(0,G.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(`+`,`
38
+ `).replace(`
39
+
40
+ `,`
41
+ +`).split(`
42
+ `));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,G.useEffect)(()=>{let n=t?.target??$h,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&jp(e))return!1;let n=ng(e.code,s);if(a.current.add(e[n]),tg(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=ng(e.code,s);tg(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function tg(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function ng(e,t){return t.includes(e)?`code`:`key`}var rg=()=>{let e=Eh();return(0,G.useMemo)(()=>({zoomIn:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=vp(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return pp(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=mp(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function ig(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)ag(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function ag(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes===`width`)&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes===`height`)&&(t.height=e.dimensions.height))),typeof e.resizing==`boolean`&&(t.resizing=e.resizing);break}}function og(e,t){return ig(e,t)}function sg(e,t){return ig(e,t)}function cg(e,t){return{id:e,type:`select`,selected:t}}function lg(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);!(a.selected===void 0&&!e)&&a.selected!==e&&(n&&(a.selected=e),r.push(cg(a.id,e)))}return r}function ug({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function dg(e){return{id:e.id,type:`remove`}}var fg=e=>Bf(e),pg=e=>zf(e);function mg(e){return(0,G.forwardRef)(e)}function hg(e){let[t,n]=(0,G.useState)(BigInt(0)),[r]=(0,G.useState)(()=>gg(()=>n(e=>e+BigInt(1))));return Wh(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function gg(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var _g=(0,G.createContext)(null);function vg({children:e}){let t=Eh(),n=hg((0,G.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=ug({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=hg((0,G.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(ug({items:s,lookup:o}))},[])),i=(0,G.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,K.jsx)(_g.Provider,{value:i,children:e})}function yg(){let e=(0,G.useContext)(_g);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var bg=e=>!!e.panZoom;function xg(){let e=rg(),t=Eh(),n=yg(),r=X(bg),i=(0,G.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=fg(e)?e:n.get(e.id),a=i.parentId?Cp(i.position,i.measured,i.parentId,n,r):i.position;return ap({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&fg(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&pg(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await Xf({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(dg);o?.(f),c(e)}if(m){let e=d.map(dg);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=lp(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=ap(s?r:a),l=cp(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=lp(e)?e:a(e);if(!r)return!1;let i=cp(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return Uf(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??Tp();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,G.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var Sg=e=>e.selected,Cg=typeof window<`u`?window:void 0;function wg({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=Eh(),{deleteElements:r}=xg(),i=eg(e,{actInsideInputWithModifier:!1}),a=eg(t,{target:Cg});(0,G.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(Sg),edges:e.filter(Sg)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,G.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function Tg(e){let t=Eh();(0,G.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=Op(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,Df.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var Eg={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},Dg=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Og({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:a=Mf.Free,zoomOnDoubleClick:o=!0,panOnDrag:s=!0,defaultViewport:c,translateExtent:l,minZoom:u,maxZoom:d,zoomActivationKeyCode:f,preventScrolling:p=!0,children:m,noWheelClassName:h,noPanClassName:g,onViewportChange:_,isControlledViewport:v,paneClickDistance:y,selectionOnDrag:b}){let x=Eh(),S=(0,G.useRef)(null),{userSelectionActive:C,lib:w,connectionInProgress:T}=X(Dg,Sh),E=eg(f),D=(0,G.useRef)();Tg(S);let O=(0,G.useCallback)(e=>{_?.({x:e[0],y:e[1],zoom:e[2]}),v||x.setState({transform:e})},[_,v]);return(0,G.useEffect)(()=>{if(S.current){D.current=$m({domNode:S.current,minZoom:u,maxZoom:d,translateExtent:l,viewport:c,onDraggingChange:e=>x.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=x.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=x.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=x.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=D.current.getViewport();return x.setState({panZoom:D.current,transform:[e,t,n],domNode:S.current.closest(`.react-flow`)}),()=>{D.current?.destroy()}}},[]),(0,G.useEffect)(()=>{D.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:a,zoomOnDoubleClick:o,panOnDrag:s,zoomActivationKeyPressed:E,preventScrolling:p,noPanClassName:g,userSelectionActive:C,noWheelClassName:h,lib:w,onTransformChange:O,connectionInProgress:T,selectionOnDrag:b,paneClickDistance:y})},[e,t,n,r,i,a,o,s,E,p,g,C,h,w,O,T,b,y]),(0,K.jsx)(`div`,{className:`react-flow__renderer`,ref:S,style:Eg,children:m})}var kg=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Ag(){let{userSelectionActive:e,userSelectionRect:t}=X(kg,Sh);return e&&t?(0,K.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var jg=(e,t)=>n=>{n.target===t.current&&e?.(n)},Mg=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function Ng({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Nf.Full,panOnDrag:r,paneClickDistance:i,selectionOnDrag:a,onSelectionStart:o,onSelectionEnd:s,onPaneClick:c,onPaneContextMenu:l,onPaneScroll:u,onPaneMouseEnter:d,onPaneMouseMove:f,onPaneMouseLeave:p,children:m}){let h=Eh(),{userSelectionActive:g,elementsSelectable:_,dragging:v,connectionInProgress:y}=X(Mg,Sh),b=_&&(e||g),x=(0,G.useRef)(null),S=(0,G.useRef)(),C=(0,G.useRef)(new Set),w=(0,G.useRef)(new Set),T=(0,G.useRef)(!1),E=e=>{if(T.current||y){T.current=!1;return}c?.(e),h.getState().resetSelectedElements(),h.setState({nodesSelectionActive:!1})},D=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}l?.(e)},O=u?e=>u(e):void 0;return(0,K.jsxs)(`div`,{className:Ho([`react-flow__pane`,{draggable:r===!0||Array.isArray(r)&&r.includes(0),dragging:v,selection:e}]),onClick:b?void 0:jg(E,x),onContextMenu:jg(D,x),onWheel:jg(O,x),onPointerEnter:b?void 0:d,onPointerMove:b?e=>{let{userSelectionRect:r,transform:a,nodeLookup:s,edgeLookup:c,connectionLookup:l,triggerNodeChanges:u,triggerEdgeChanges:d,defaultEdgeOptions:f,resetSelectedElements:p}=h.getState();if(!S.current||!r)return;let{x:m,y:g}=Np(e.nativeEvent,S.current),{startX:_,startY:v}=r;if(!T.current){let n=t?0:i;if(Math.hypot(m-_,g-v)<=n)return;p(),o?.(e)}T.current=!0;let y={startX:_,startY:v,x:m<_?m:_,y:g<v?g:v,width:Math.abs(m-_),height:Math.abs(g-v)},b=C.current,x=w.current;C.current=new Set(Gf(s,y,a,n===Nf.Partial,!0).map(e=>e.id)),w.current=new Set;let E=f?.selectable??!0;for(let e of C.current){let t=l.get(e);if(t)for(let{edgeId:e}of t.values()){let t=c.get(e);t&&(t.selectable??E)&&w.current.add(e)}}wp(b,C.current)||u(lg(s,C.current,!0)),wp(x,w.current)||d(lg(c,w.current)),h.setState({userSelectionRect:y,userSelectionActive:!0,nodesSelectionActive:!1})}:f,onPointerUp:b?e=>{e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!g&&e.target===x.current&&h.getState().userSelectionRect&&E?.(e),h.setState({userSelectionActive:!1,userSelectionRect:null}),T.current&&(s?.(e),h.setState({nodesSelectionActive:C.current.size>0})))}:void 0,onPointerDownCapture:b?n=>{let{domNode:r}=h.getState();if(S.current=r?.getBoundingClientRect(),!S.current)return;let i=n.target===x.current;if(!i&&n.target.closest(`.nokey`)||!e||!(a&&i||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),T.current=!1;let{x:o,y:s}=Np(n.nativeEvent,S.current);h.setState({userSelectionRect:{width:0,height:0,startX:o,startY:s,x:o,y:s}}),i||(n.stopPropagation(),n.preventDefault())}:void 0,onClickCapture:b?e=>{T.current&&=(e.stopPropagation(),!1)}:void 0,onPointerLeave:p,ref:x,style:Eg,children:[m,(0,K.jsx)(Ag,{})]})}function Pg({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,Df.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function Fg({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=Eh(),[c,l]=(0,G.useState)(!1),u=(0,G.useRef)();return(0,G.useEffect)(()=>{u.current=Om({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{Pg({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),(0,G.useEffect)(()=>{if(!(t||!e.current||!u.current))return u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o}),()=>{u.current?.destroy()}},[n,r,t,a,e,i,o]),c}var Ig=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function Lg(){let e=Eh();return(0,G.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=Ig(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=fp(t,i));let{position:a,positionAbsolute:s}=Yf({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var Rg=(0,G.createContext)(null),zg=Rg.Provider;Rg.Consumer;var Bg=()=>(0,G.useContext)(Rg),Vg=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Hg=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o,u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===jf.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function Ug({type:e=`source`,position:t=Y.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=Eh(),_=Bg(),{connectOnClick:v,noPanClassName:y,rfId:b}=X(Vg,Sh),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=X(Hg(_,m,e),Sh);_||g.getState().onError?.(`010`,Df.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t}=g.getState();t(Wp(i,e))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=Mp(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();Rm.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)},A=t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=kp(t.target),h=n||c,{connection:v,isValid:y}=Rm.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})};return(0,K.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:Ho([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?A:void 0,ref:p,...f,children:c})}var Wg=(0,G.memo)(mg(Ug));function Gg({data:e,isConnectable:t,sourcePosition:n=Y.Bottom}){return(0,K.jsxs)(K.Fragment,{children:[e?.label,(0,K.jsx)(Wg,{type:`source`,position:n,isConnectable:t})]})}function Kg({data:e,isConnectable:t,targetPosition:n=Y.Top,sourcePosition:r=Y.Bottom}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Wg,{type:`target`,position:n,isConnectable:t}),e?.label,(0,K.jsx)(Wg,{type:`source`,position:r,isConnectable:t})]})}function qg(){return null}function Jg({data:e,isConnectable:t,targetPosition:n=Y.Top}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Wg,{type:`target`,position:n,isConnectable:t}),e?.label]})}var Yg={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Xg={input:Gg,default:Kg,output:Jg,group:qg};function Zg(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var Qg=e=>{let{width:t,height:n,x:r,y:i}=Wf(e.nodeLookup,{filter:e=>!!e.selected});return{width:up(t)?t:null,height:up(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function $g({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=Eh(),{width:i,height:a,transformString:o,userSelectionActive:s}=X(Qg,Sh),c=Lg(),l=(0,G.useRef)(null);(0,G.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(Fg({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,K.jsx)(`div`,{className:Ho([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,K.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(Yg,e.key)&&(e.preventDefault(),c({direction:Yg[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var e_=typeof window<`u`?window:void 0,t_=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function n_({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,defaultViewport:T,translateExtent:E,minZoom:D,maxZoom:O,preventScrolling:k,onSelectionContextMenu:A,noWheelClassName:j,noPanClassName:M,disableKeyboardA11y:N,onViewportChange:P,isControlledViewport:F}){let{nodesSelectionActive:I,userSelectionActive:L}=X(t_,Sh),R=eg(l,{target:e_}),z=eg(h,{target:e_}),B=z||w,V=z||b,ee=u&&B!==!0,te=R||L||ee;return wg({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,K.jsx)(Og,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:V,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!R&&B,defaultViewport:T,translateExtent:E,minZoom:D,maxZoom:O,zoomActivationKeyCode:g,preventScrolling:k,noWheelClassName:j,noPanClassName:M,onViewportChange:P,isControlledViewport:F,paneClickDistance:s,selectionOnDrag:ee,children:(0,K.jsxs)(Ng,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:B,isSelecting:!!te,selectionMode:d,selectionKeyPressed:R,paneClickDistance:s,selectionOnDrag:ee,children:[e,I&&(0,K.jsx)($g,{onSelectionContextMenu:A,noPanClassName:M,disableKeyboardA11y:N})]})})}n_.displayName=`FlowRenderer`;var r_=(0,G.memo)(n_),i_=e=>t=>e?Gf(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function a_(e){return X((0,G.useCallback)(i_(e),[e]),Sh)}var o_=e=>e.updateNodeInternals;function s_(){let e=X(o_),[t]=(0,G.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,G.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function c_({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=Eh(),a=(0,G.useRef)(null),o=(0,G.useRef)(null),s=(0,G.useRef)(e.sourcePosition),c=(0,G.useRef)(e.targetPosition),l=(0,G.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,G.useEffect)(()=>{a.current&&!e.hidden&&(!u||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,G.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,G.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function l_({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=X(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},Sh),S=y.type||`default`,C=g?.[S]||Xg[S];C===void 0&&(v?.(`003`,Df.error003(S)),S=`default`,C=g?.default||Xg.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=Eh(),k=Sp(y),A=c_({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=Fg({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=Lg();if(y.hidden)return null;let N=xp(y),P=Zg(y),F=T||w||t||n||r||i,I=n?e=>n(e,{...b.userNode}):void 0,L=r?e=>r(e,{...b.userNode}):void 0,R=i?e=>i(e,{...b.userNode}):void 0,z=a?e=>a(e,{...b.userNode}):void 0,B=o?e=>o(e,{...b.userNode}):void 0,V=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&Pg({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},ee=t=>{if(!(jp(t.nativeEvent)||m)){if(kf.includes(t.key)&&T)Pg({id:e,store:O,unselect:t.key===`Escape`,nodeRef:A});else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(Yg,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:Yg[t.key],factor:t.shiftKey?4:1})}}},te=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(Gf(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,K.jsx)(`div`,{className:Ho([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:F?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:L,onMouseLeave:R,onContextMenu:z,onClick:V,onDoubleClick:B,onKeyDown:D?ee:void 0,tabIndex:D?0:void 0,onFocus:D?te:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${kh}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,K.jsx)(zg,{value:e,children:(0,K.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var u_=(0,G.memo)(l_),d_=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function f_(e){let{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,onError:a}=X(d_,Sh),o=a_(e.onlyRenderVisibleElements),s=s_();return(0,K.jsx)(`div`,{className:`react-flow__nodes`,style:Eg,children:o.map(o=>(0,K.jsx)(u_,{id:o,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:s,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,nodeClickDistance:e.nodeClickDistance,onError:a},o))})}f_.displayName=`NodeRenderer`;var p_=(0,G.memo)(f_);function m_(e){return X((0,G.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&Vp({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),Sh)}var h_=({color:e=`none`,strokeWidth:t=1})=>(0,K.jsx)(`polyline`,{className:`arrow`,style:{strokeWidth:t,...e&&{stroke:e}},strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`}),g_=({color:e=`none`,strokeWidth:t=1})=>(0,K.jsx)(`polyline`,{className:`arrowclosed`,style:{strokeWidth:t,...e&&{stroke:e,fill:e}},strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`}),__={[If.Arrow]:h_,[If.ArrowClosed]:g_};function v_(e){let t=Eh();return(0,G.useMemo)(()=>Object.prototype.hasOwnProperty.call(__,e)?__[e]:(t.getState().onError?.(`009`,Df.error009(e)),null),[e])}var y_=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=v_(t);return c?(0,K.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,K.jsx)(c,{color:n,strokeWidth:o})}):null},b_=({defaultColor:e,rfId:t})=>{let n=X(e=>e.edges),r=X(e=>e.defaultEdgeOptions),i=(0,G.useMemo)(()=>im(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,K.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,K.jsx)(`defs`,{children:i.map(e=>(0,K.jsx)(y_,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};b_.displayName=`MarkerDefinitions`;var x_=(0,G.memo)(b_);function S_({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,G.useState)({x:1,y:0,width:0,height:0}),p=Ho([`react-flow__edge-textwrapper`,l]),m=(0,G.useRef)(null);return(0,G.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,K.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,K.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,K.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}S_.displayName=`EdgeText`;var C_=(0,G.memo)(S_);function w_({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{...u,d:e,fill:`none`,className:Ho([`react-flow__edge-path`,u.className])}),l?(0,K.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&up(t)&&up(n)?(0,K.jsx)(C_,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function T_({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===Y.Left||e===Y.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function E_({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:r,targetY:i,targetPosition:a=Y.Top}){let[o,s]=T_({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=T_({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=Fp({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function D_(e){return(0,G.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=E_({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s});return(0,K.jsx)(w_,{id:e.isInternal?void 0:t,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var O_=D_({isInternal:!1}),k_=D_({isInternal:!0});O_.displayName=`SimpleBezierEdge`,k_.displayName=`SimpleBezierEdgeInternal`;function A_(e){return(0,G.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=Y.Bottom,targetPosition:m=Y.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=Zp({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition});return(0,K.jsx)(w_,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var j_=A_({isInternal:!1}),M_=A_({isInternal:!0});j_.displayName=`SmoothStepEdge`,M_.displayName=`SmoothStepEdgeInternal`;function N_(e){return(0,G.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,K.jsx)(j_,{...n,id:r,pathOptions:(0,G.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var P_=N_({isInternal:!1}),F_=N_({isInternal:!0});P_.displayName=`StepEdge`,F_.displayName=`StepEdgeInternal`;function I_(e){return(0,G.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=Gp({sourceX:n,sourceY:r,targetX:i,targetY:a});return(0,K.jsx)(w_,{id:e.isInternal?void 0:t,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var L_=I_({isInternal:!1}),R_=I_({isInternal:!0});L_.displayName=`StraightEdge`,R_.displayName=`StraightEdgeInternal`;function z_(e){return(0,G.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=Y.Bottom,targetPosition:s=Y.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=Rp({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature});return(0,K.jsx)(w_,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var B_=z_({isInternal:!1}),V_=z_({isInternal:!0});B_.displayName=`BezierEdge`,V_.displayName=`BezierEdgeInternal`;var H_={default:V_,straight:R_,step:F_,smoothstep:M_,simplebezier:k_},U_={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},W_=(e,t,n)=>n===Y.Left?e-t:n===Y.Right?e+t:e,G_=(e,t,n)=>n===Y.Top?e-t:n===Y.Bottom?e+t:e,K_=`react-flow__edgeupdater`;function q_({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,K.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:Ho([K_,`${K_}-${s}`]),cx:W_(t,r,e),cy:G_(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function J_({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=Eh(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;Rm.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,K.jsxs)(K.Fragment,{children:[(e===!0||e===`source`)&&(0,K.jsx)(q_,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,K.jsx)(q_,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function Y_({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:_,disableKeyboardA11y:v}){let y=X(t=>t.edgeLookup.get(e)),b=X(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||H_[x];S===void 0&&(_?.(`011`,Df.error011(x)),x=`default`,S=h?.default||H_.default);let C=!!(y.focusable||t&&y.focusable===void 0),w=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),T=!!(y.selectable||r&&y.selectable===void 0),E=(0,G.useRef)(null),[D,O]=(0,G.useState)(!1),[k,A]=(0,G.useState)(!1),j=Eh(),{zIndex:M,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R}=X((0,G.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return{zIndex:y.zIndex,...U_};let i=$p({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_});return{zIndex:Bp({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode}),...i||U_}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),Sh),z=(0,G.useMemo)(()=>y.markerStart?`url('#${rm(y.markerStart,m)}')`:void 0,[y.markerStart,m]),B=(0,G.useMemo)(()=>y.markerEnd?`url('#${rm(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||N===null||P===null||F===null||I===null)return null;let V=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=j.getState();T&&(j.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),E.current?.blur()):n([e])),i&&i(t,y)},ee=a?e=>{a(e,{...y})}:void 0,te=o?e=>{o(e,{...y})}:void 0,H=s?e=>{s(e,{...y})}:void 0,ne=c?e=>{c(e,{...y})}:void 0,re=l?e=>{l(e,{...y})}:void 0;return(0,K.jsx)(`svg`,{style:{zIndex:M},children:(0,K.jsxs)(`g`,{className:Ho([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:V,onDoubleClick:ee,onContextMenu:te,onMouseEnter:H,onMouseMove:ne,onMouseLeave:re,onKeyDown:C?t=>{if(!v&&kf.includes(t.key)&&T){let{unselectNodesAndEdges:n,addSelectedEdges:r}=j.getState();t.key===`Escape`?(E.current?.blur(),n({edges:[y]})):r([e])}}:void 0,tabIndex:C?0:void 0,role:y.ariaRole??(C?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":C?`${Ah}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,K.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:T,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:z,markerEnd:B,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,K.jsx)(J_,{edge:y,isReconnectable:w,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,setUpdateHover:O,setReconnecting:A})]})})}var X_=(0,G.memo)(Y_),Z_=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Q_({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=X(Z_,Sh),b=m_(t);return(0,K.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,K.jsx)(x_,{defaultColor:e,rfId:n}),b.map(e=>(0,K.jsx)(X_,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}Q_.displayName=`EdgeRenderer`;var $_=(0,G.memo)(Q_),ev=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function tv({children:e}){return(0,K.jsx)(`div`,{className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:X(ev)},children:e})}function nv(e){let t=xg(),n=(0,G.useRef)(!1);(0,G.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var rv=e=>e.panZoom?.syncViewport;function iv(e){let t=X(rv),n=Eh();return(0,G.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function av(e){return e.connection.inProgress?{...e.connection,to:pp(e.connection.to,e.transform)}:{...e.connection}}function ov(e){return e?t=>e(av(t)):av}function sv(e){return X(ov(e),Sh)}var cv=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function lv({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=X(cv,Sh);return a&&i&&c?(0,K.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,K.jsx)(`g`,{className:Ho([`react-flow__connection`,Rf(s)]),children:(0,K.jsx)(uv,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var uv=({style:e,type:t=Ff.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=sv();if(!i)return;if(n)return(0,K.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:Rf(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case Ff.Bezier:[m]=Rp(h);break;case Ff.SimpleBezier:[m]=E_(h);break;case Ff.Step:[m]=Zp({...h,borderRadius:0});break;case Ff.SmoothStep:[m]=Zp(h);break;default:[m]=Gp(h)}return(0,K.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};uv.displayName=`ConnectionLine`;var dv={};function fv(e=dv){(0,G.useRef)(e),Eh(),(0,G.useEffect)(()=>{},[e])}function pv(){Eh(),(0,G.useRef)(!1),(0,G.useEffect)(()=>{},[])}function mv({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:P,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,zoomOnDoubleClick:R,panOnDrag:z,onPaneClick:B,onPaneMouseEnter:V,onPaneMouseMove:ee,onPaneMouseLeave:te,onPaneScroll:H,onPaneContextMenu:ne,paneClickDistance:re,nodeClickDistance:U,onEdgeContextMenu:ie,onEdgeMouseEnter:W,onEdgeMouseMove:ae,onEdgeMouseLeave:oe,reconnectRadius:se,onReconnect:ce,onReconnectStart:le,onReconnectEnd:ue,noDragClassName:de,noWheelClassName:G,noPanClassName:fe,disableKeyboardA11y:pe,nodeExtent:me,rfId:he,viewport:ge,onViewportChange:_e}){return fv(e),fv(t),pv(),nv(n),iv(ge),(0,K.jsx)(r_,{onPaneClick:B,onPaneMouseEnter:V,onPaneMouseMove:ee,onPaneMouseLeave:te,onPaneContextMenu:ne,onPaneScroll:H,paneClickDistance:re,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:P,zoomOnDoubleClick:R,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,panOnDrag:z,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:de,noWheelClassName:G,noPanClassName:fe,disableKeyboardA11y:pe,onViewportChange:_e,isControlledViewport:!!ge,children:(0,K.jsxs)(tv,{children:[(0,K.jsx)($_,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:ce,onReconnectStart:le,onReconnectEnd:ue,onlyRenderVisibleElements:T,onEdgeContextMenu:ie,onEdgeMouseEnter:W,onEdgeMouseMove:ae,onEdgeMouseLeave:oe,reconnectRadius:se,defaultMarkerColor:M,noPanClassName:fe,disableKeyboardA11y:pe,rfId:he}),(0,K.jsx)(lv,{style:h,type:m,component:g,containerStyle:_}),(0,K.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,K.jsx)(p_,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:U,onlyRenderVisibleElements:T,noPanClassName:fe,noDragClassName:de,disableKeyboardA11y:pe,nodeExtent:me,rfId:he}),(0,K.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}mv.displayName=`GraphView`;var hv=(0,G.memo)(mv),gv=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??Of;Sm(h,g,_);let{nodesInitialized:x}=pm(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=vp(Wf(p,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:Of,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:jf.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...Pf},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:dp,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:Af,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},_v=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>xh((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await Jf({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...gv({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,elevateNodesOnSelect:i,fitViewQueued:a,zIndexMode:o,nodesSelectionActive:s}=m(),{nodesInitialized:c,hasSelectedNodes:l}=pm(e,t,n,{nodeOrigin:r,nodeExtent:d,elevateNodesOnSelect:i,checkEquality:!0,zIndexMode:o}),u=s&&l;a&&c?(h(),p({nodes:e,nodesInitialized:c,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:u})):p({nodes:e,nodesInitialized:c,nodesSelectionActive:u})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();Sm(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=ym(e,n,r,i,a,o,l);d&&(um(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=tm(e,o.fromHandle,Y.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=vm(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(og(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(sg(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){i(e.map(e=>cg(e,!0)));return}i(lg(r,new Set([...e]),!0)),a(lg(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>cg(e,!0)));return}a(lg(n,new Set([...e]))),i(lg(r,new Set,!0))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(cg(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(cg(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,cg(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,cg(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();e[0][0]===o[0][0]&&e[0][1]===o[0][1]&&e[1][0]===o[1][0]&&e[1][1]===o[1][1]||(pm(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return bm({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return Promise.resolve(!1);let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{p({connection:{...Pf}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...gv()})}},Object.is);function vv({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,G.useState)(()=>_v({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,K.jsx)(wh,{value:m,children:(0,K.jsx)(vg,{children:p})})}function yv({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,G.useContext)(Ch)?(0,K.jsx)(K.Fragment,{children:e}):(0,K.jsx)(vv,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var bv={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function xv({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onSelectionChange:k,onSelectionDragStart:A,onSelectionDrag:j,onSelectionDragStop:M,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onBeforeDelete:I,connectionMode:L,connectionLineType:R=Ff.Bezier,connectionLineStyle:z,connectionLineComponent:B,connectionLineContainerStyle:V,deleteKeyCode:ee=`Backspace`,selectionKeyCode:te=`Shift`,selectionOnDrag:H=!1,selectionMode:ne=Nf.Full,panActivationKeyCode:re=`Space`,multiSelectionKeyCode:U=yp()?`Meta`:`Control`,zoomActivationKeyCode:ie=yp()?`Meta`:`Control`,snapToGrid:W,snapGrid:ae,onlyRenderVisibleElements:oe=!1,selectNodesOnDrag:se,nodesDraggable:ce,autoPanOnNodeFocus:le,nodesConnectable:ue,nodesFocusable:de,nodeOrigin:fe=Gh,edgesFocusable:pe,edgesReconnectable:me,elementsSelectable:he=!0,defaultViewport:ge=Kh,minZoom:_e=.5,maxZoom:ve=2,translateExtent:ye=Of,preventScrolling:be=!0,nodeExtent:xe,defaultMarkerColor:Se=`#b1b1b7`,zoomOnScroll:Ce=!0,zoomOnPinch:we=!0,panOnScroll:Te=!1,panOnScrollSpeed:Ee=.5,panOnScrollMode:De=Mf.Free,zoomOnDoubleClick:Oe=!0,panOnDrag:ke=!0,onPaneClick:Ae,onPaneMouseEnter:je,onPaneMouseMove:Me,onPaneMouseLeave:Ne,onPaneScroll:Pe,onPaneContextMenu:Fe,paneClickDistance:Ie=1,nodeClickDistance:Le=0,children:Re,onReconnect:ze,onReconnectStart:Be,onReconnectEnd:Ve,onEdgeContextMenu:He,onEdgeDoubleClick:Ue,onEdgeMouseEnter:We,onEdgeMouseMove:Ge,onEdgeMouseLeave:Ke,reconnectRadius:qe=10,onNodesChange:Je,onEdgesChange:Ye,noDragClassName:Xe=`nodrag`,noWheelClassName:Ze=`nowheel`,noPanClassName:Qe=`nopan`,fitView:$e,fitViewOptions:et,connectOnClick:tt,attributionPosition:nt,proOptions:rt,defaultEdgeOptions:it,elevateNodesOnSelect:at=!0,elevateEdgesOnSelect:ot=!1,disableKeyboardA11y:st=!1,autoPanOnConnect:ct,autoPanOnNodeDrag:lt,autoPanSpeed:ut,connectionRadius:dt,isValidConnection:ft,onError:pt,style:mt,id:ht,nodeDragThreshold:gt,connectionDragThreshold:_t,viewport:vt,onViewportChange:yt,width:bt,height:xt,colorMode:St=`light`,debug:Ct,onScroll:wt,ariaLabelConfig:Tt,zIndexMode:Et=`basic`,...Dt},Ot){let kt=ht||`1`,At=Qh(St),jt=(0,G.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),wt?.(e)},[wt]);return(0,K.jsx)(`div`,{"data-testid":`rf__wrapper`,...Dt,onScroll:jt,style:{...mt,...bv},ref:Ot,className:Ho([`react-flow`,i,At]),id:ht,role:`application`,children:(0,K.jsxs)(yv,{nodes:e,edges:t,width:bt,height:xt,fitView:$e,fitViewOptions:et,minZoom:_e,maxZoom:ve,nodeOrigin:fe,nodeExtent:xe,zIndexMode:Et,children:[(0,K.jsx)(Xh,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:ce,autoPanOnNodeFocus:le,nodesConnectable:ue,nodesFocusable:de,edgesFocusable:pe,edgesReconnectable:me,elementsSelectable:he,elevateNodesOnSelect:at,elevateEdgesOnSelect:ot,minZoom:_e,maxZoom:ve,nodeExtent:xe,onNodesChange:Je,onEdgesChange:Ye,snapToGrid:W,snapGrid:ae,connectionMode:L,translateExtent:ye,connectOnClick:tt,defaultEdgeOptions:it,fitView:$e,fitViewOptions:et,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:j,onSelectionDragStart:A,onSelectionDragStop:M,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:Qe,nodeOrigin:fe,rfId:kt,autoPanOnConnect:ct,autoPanOnNodeDrag:lt,autoPanSpeed:ut,onError:pt,connectionRadius:dt,isValidConnection:ft,selectNodesOnDrag:se,nodeDragThreshold:gt,connectionDragThreshold:_t,onBeforeDelete:I,debug:Ct,ariaLabelConfig:Tt,zIndexMode:Et}),(0,K.jsx)(hv,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:R,connectionLineStyle:z,connectionLineComponent:B,connectionLineContainerStyle:V,selectionKeyCode:te,selectionOnDrag:H,selectionMode:ne,deleteKeyCode:ee,multiSelectionKeyCode:U,panActivationKeyCode:re,zoomActivationKeyCode:ie,onlyRenderVisibleElements:oe,defaultViewport:ge,translateExtent:ye,minZoom:_e,maxZoom:ve,preventScrolling:be,zoomOnScroll:Ce,zoomOnPinch:we,zoomOnDoubleClick:Oe,panOnScroll:Te,panOnScrollSpeed:Ee,panOnScrollMode:De,panOnDrag:ke,onPaneClick:Ae,onPaneMouseEnter:je,onPaneMouseMove:Me,onPaneMouseLeave:Ne,onPaneScroll:Pe,onPaneContextMenu:Fe,paneClickDistance:Ie,nodeClickDistance:Le,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onReconnect:ze,onReconnectStart:Be,onReconnectEnd:Ve,onEdgeContextMenu:He,onEdgeDoubleClick:Ue,onEdgeMouseEnter:We,onEdgeMouseMove:Ge,onEdgeMouseLeave:Ke,reconnectRadius:qe,defaultMarkerColor:Se,noDragClassName:Xe,noWheelClassName:Ze,noPanClassName:Qe,rfId:kt,disableKeyboardA11y:st,nodeExtent:xe,viewport:vt,onViewportChange:yt}),(0,K.jsx)(Uh,{onSelectionChange:k}),Re,(0,K.jsx)(Lh,{proOptions:rt,position:nt}),(0,K.jsx)(Fh,{rfId:kt,disableKeyboardA11y:st})]})})}var Sv=mg(xv);function Cv(e){let[t,n]=(0,G.useState)(e);return[t,n,(0,G.useCallback)(e=>n(t=>og(e,t)),[])]}function wv(e){let[t,n]=(0,G.useState)(e);return[t,n,(0,G.useCallback)(e=>n(t=>sg(e,t)),[])]}Df.error014();function Tv({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,K.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Ho([`react-flow__background-pattern`,n,r])})}function Ev({radius:e,className:t}){return(0,K.jsx)(`circle`,{cx:e,cy:e,r:e,className:Ho([`react-flow__background-pattern`,`dots`,t])})}var Dv;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(Dv||={});var Ov={[Dv.Dots]:1,[Dv.Lines]:1,[Dv.Cross]:6},kv=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Av({id:e,variant:t=Dv.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,G.useRef)(null),{transform:f,patternId:p}=X(kv,Sh),m=r||Ov[t],h=t===Dv.Dots,g=t===Dv.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]||1+x[0]/2,b[1]*f[2]||1+x[1]/2],C=`${p}${e||``}`;return(0,K.jsxs)(`svg`,{className:Ho([`react-flow__background`,l]),style:{...c,...Eg,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,K.jsx)(`pattern`,{id:C,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,K.jsx)(Ev,{radius:y/2,className:u}):(0,K.jsx)(Tv,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,K.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}Av.displayName=`Background`;var jv=(0,G.memo)(Av);function Mv(){return(0,K.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,K.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function Nv(){return(0,K.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,K.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function Pv(){return(0,K.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,K.jsx)(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`})})}function Fv(){return(0,K.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,K.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`})})}function Iv(){return(0,K.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,K.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`})})}function Lv({children:e,className:t,...n}){return(0,K.jsx)(`button`,{type:`button`,className:Ho([`react-flow__controls-button`,t]),...n,children:e})}var Rv=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function zv({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=Eh(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=X(Rv,Sh),{zoomIn:y,zoomOut:b,fitView:x}=xg(),S=()=>{y(),a?.()},C=()=>{b(),o?.()},w=()=>{x(i),s?.()},T=()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)};return(0,K.jsxs)(Ih,{className:Ho([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Lv,{onClick:S,className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,K.jsx)(Mv,{})}),(0,K.jsx)(Lv,{onClick:C,className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,K.jsx)(Nv,{})})]}),n&&(0,K.jsx)(Lv,{className:`react-flow__controls-fitview`,onClick:w,title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,K.jsx)(Pv,{})}),r&&(0,K.jsx)(Lv,{className:`react-flow__controls-interactive`,onClick:T,title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,K.jsx)(Iv,{}):(0,K.jsx)(Fv,{})}),u]})}zv.displayName=`Controls`,(0,G.memo)(zv);function Bv({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,K.jsx)(`rect`,{className:Ho([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var Vv=(0,G.memo)(Bv),Hv=e=>e.nodes.map(e=>e.id),Uv=e=>e instanceof Function?e:()=>e;function Wv({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=Vv,onClick:o}){let s=X(Hv,Sh),c=Uv(t),l=Uv(e),u=Uv(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,K.jsx)(K.Fragment,{children:s.map(e=>(0,K.jsx)(Kv,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function Gv({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=X(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=xp(r);return{node:r,x:i,y:a,width:o,height:s}},Sh);return!l||l.hidden||!Sp(l)?null:(0,K.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var Kv=(0,G.memo)(Gv),qv=(0,G.memo)(Wv),Jv=200,Yv=150,Xv=e=>!e.hidden,Zv=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?sp(Wf(e.nodeLookup,{filter:Xv}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Qv=`react-flow__minimap-desc`;function $v({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:_,inversePan:v,zoomStep:y=1,offsetScale:b=5}){let x=Eh(),S=(0,G.useRef)(null),{boundingRect:C,viewBB:w,rfId:T,panZoom:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=X(Zv,Sh),j=e?.width??Jv,M=e?.height??Yv,N=C.width/j,P=C.height/M,F=Math.max(N,P),I=F*j,L=F*M,R=b*F,z=C.x-(I-C.width)/2-R,B=C.y-(L-C.height)/2-R,V=I+R*2,ee=L+R*2,te=`${Qv}-${T}`,H=(0,G.useRef)(0),ne=(0,G.useRef)();H.current=F,(0,G.useEffect)(()=>{if(S.current&&E)return ne.current=zm({domNode:S.current,panZoom:E,getTransform:()=>x.getState().transform,getViewScale:()=>H.current}),()=>{ne.current?.destroy()}},[E]),(0,G.useEffect)(()=>{ne.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let re=p?e=>{let[t,n]=ne.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,U=m?(0,G.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m(e,n)},[]):void 0,ie=_??A[`minimap.ariaLabel`];return(0,K.jsx)(Ih,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*F:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:Ho([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,K.jsxs)(`svg`,{width:j,height:M,viewBox:`${z} ${B} ${V} ${ee}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":te,ref:S,onClick:re,children:[ie&&(0,K.jsx)(`title`,{id:te,children:ie}),(0,K.jsx)(qv,{onClick:U,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,K.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${z-R},${B-R}h${V+R*2}v${ee+R*2}h${-V-R*2}z
43
+ M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}$v.displayName=`MiniMap`;var ey=(0,G.memo)($v),ty=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,ny={[eh.Line]:`right`,[eh.Handle]:`bottom-right`};function ry({nodeId:e,position:t,variant:n=eh.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=Bg(),y=typeof e==`string`?e:v,b=Eh(),x=(0,G.useRef)(null),S=n===eh.Handle,C=X((0,G.useCallback)(ty(S&&p),[S,p]),Sh),w=(0,G.useRef)(null),T=t??ny[n];return(0,G.useEffect)(()=>{if(!(!x.current||!y))return w.current||=fh({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=vm([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...Cp({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]),(0,K.jsx)(`div`,{className:Ho([`react-flow__resize-control`,`nodrag`,...T.split(`-`),n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,G.memo)(ry);var iy=v(`/services`)({component:Ey});function ay({startedAt:e,running:t}){let[n,r]=(0,G.useState)(0);return(0,G.useEffect)(()=>{if(!t||!e){r(0);return}let n=()=>r(Date.now()-Date.parse(e));n();let i=setInterval(n,1e3);return()=>clearInterval(i)},[t,e]),!t||!e?null:(0,K.jsx)(K.Fragment,{children:re(n)})}var oy=[`#3d3d3d`,`#c0392b`,`#27ae60`,`#d4a017`,`#2980b9`,`#8e44ad`,`#16a085`,`#bdc3c7`],sy=[`#666`,`#e74c3c`,`#2ecc71`,`#f1c40f`,`#3498db`,`#9b59b6`,`#1abc9c`,`#ecf0f1`],cy=[`#1a1a1a`,`#6b0000`,`#004d1a`,`#4d3800`,`#00234d`,`#3a0066`,`#004d40`,`#4a4a4a`],ly=[`#333`,`#c0392b`,`#27ae60`,`#b8860b`,`#1a5276`,`#6c3483`,`#0e6655`,`#7f8c8d`];function uy(e){let t=/\x1b\[([0-9;]*)m/g,n=null,r=null,i=!1,a=!1,o=!1,s=``,c=0,l=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),u=e=>{if(!e)return;let t=l(e),c=[];n&&c.push(`color:${n}`),r&&c.push(`background:${r}`),i&&c.push(`font-weight:700`),a&&c.push(`opacity:0.5`),o&&c.push(`font-style:italic`),s+=c.length?`<span style="${c.join(`;`)}">${t}</span>`:t};for(let s of e.matchAll(t)){u(e.slice(c,s.index)),c=s.index+s[0].length;let t=s[1]===``?[0]:s[1].split(`;`).map(Number),l=0;for(;l<t.length;){let e=t[l++];e===0?(n=r=null,i=a=o=!1):e===1?i=!0:e===2?a=!0:e===3?o=!0:e===22?(i=!1,a=!1):e===23?o=!1:e>=30&&e<=37?n=oy[e-30]:e===38?t[l]===5&&l+1<t.length?l+=2:t[l]===2&&l+3<t.length&&(n=`rgb(${t[l+1]},${t[l+2]},${t[l+3]})`,l+=4):e===39?n=null:e>=40&&e<=47?r=cy[e-40]:e===49?r=null:e>=90&&e<=97?n=sy[e-90]:e>=100&&e<=107&&(r=ly[e-100])}}return u(e.slice(c)),s}function dy(e){let t={running:{dot:`text-success fill-success`,strip:`bg-success`,badge:`badge-success`,label:`Running`,spinning:!1},starting:{dot:`text-warning fill-warning`,strip:`bg-warning`,badge:`badge-warning`,label:`Starting`,spinning:!0},stopping:{dot:`text-warning fill-warning`,strip:`bg-warning/60`,badge:`badge-warning`,label:`Stopping`,spinning:!0},crashed:{dot:`text-error fill-error`,strip:`bg-error`,badge:`badge-error`,label:`Crashed`,spinning:!1},stopped:{dot:`opacity-20`,strip:`bg-base-300`,badge:`badge-ghost opacity-50`,label:`Stopped`,spinning:!1}};return t[e]??t.stopped}var fy=[{label:`Auto`,value:0},{label:`5s`,value:5e3},{label:`10s`,value:1e4},{label:`30s`,value:3e4},{label:`1m`,value:6e4}];function py({id:e,running:t,state:n}){let[r,i]=(0,G.useState)(``),[a,o]=(0,G.useState)(0),[s,c]=(0,G.useState)(`idle`),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(0),p=(0,G.useRef)(null),[m,h]=(0,G.useState)(!0),g=(0,G.useMemo)(()=>r?uy(r):``,[r]),_=!!(r&&r.trim()),v=(0,G.useRef)(0),y=(0,G.useRef)(0),b=(0,G.useRef)(0),[x,S]=(0,G.useState)(null),C=(0,G.useCallback)(async()=>{if(e){c(`loading`),u(null);try{let t=await U.get(`/services/${encodeURIComponent(e)}/log`);i(t.logTail??``),v.current=t.logSize??0,o(t.logSize??0),c(t.logTail?`live`:`idle`)}catch(e){u(e instanceof Error?e.message:`Failed to load logs.`),c(`error`)}}},[e]),w=(0,G.useCallback)(async()=>{if(e)try{let t=await U.get(`/services/${encodeURIComponent(e)}/log?after=${v.current}`);t.text?(i(e=>e+t.text),v.current=t.logSize??v.current,o(t.logSize??v.current),y.current=Date.now(),c(`live`)):(t.logSize??v.current)<v.current&&C()}catch{}},[e,C]);(0,G.useEffect)(()=>{if(i(``),v.current=0,o(0),c(`idle`),b.current=0,y.current=0,S(null),!e)return;C(),Ee(e);let t=jt(e,e=>{i(t=>t+e),v.current+=new TextEncoder().encode(e).length,y.current=Date.now(),b.current++,c(`live`)});return()=>{De(e),t()}},[e,C]),(0,G.useEffect)(()=>{if(!t||!e||d>0)return;let n=setInterval(()=>{S(y.current?(Date.now()-y.current)/1e3:null),(!y.current||Date.now()-y.current>1e4)&&(w(),y.current&&Date.now()-y.current>15e3&&c(`stale`))},5e3);return()=>clearInterval(n)},[t,e,d,w]),(0,G.useEffect)(()=>{if(!d||!e)return;let t=setInterval(w,d);return()=>clearInterval(t)},[d,e,w]),(0,G.useEffect)(()=>{m&&p.current&&(p.current.scrollTop=p.current.scrollHeight)},[g,m]);let T=(0,G.useCallback)(()=>{if(!p.current)return;let{scrollTop:e,scrollHeight:t,clientHeight:n}=p.current;h(e+n>=t-40)},[]),E=x!=null&&x>5?`${Math.round(x)}s ago`:null,D=s===`loading`?(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs opacity-40`,children:[(0,K.jsx)(q,{className:`size-2.5 animate-spin`}),`loading`]}):s===`error`?(0,K.jsx)(`span`,{className:`text-xs text-error/70`,children:`error`}):_&&n===`crashed`?(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-error/70`,children:[(0,K.jsx)(kn,{className:`size-2 fill-current`}),`crash log`]}):s===`stale`?(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-warning/70`,children:[(0,K.jsx)(kn,{className:`size-2 fill-warning animate-pulse`}),`stale`,E?` · ${E}`:``]}):s===`live`?(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-success`,children:[(0,K.jsx)(kn,{className:`size-2 fill-success`}),d>0?`poll ${d/1e3}s`:`ws`,E?` · ${E}`:``]}):_?(0,K.jsx)(`span`,{className:`text-xs opacity-45`,children:`saved log`}):(0,K.jsx)(`span`,{className:`text-xs opacity-25`,children:`no output`});return(0,K.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 bg-base-200/40 border-t border-b border-base-200 shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Zr,{className:`size-3.5 opacity-30`}),(0,K.jsx)(`span`,{className:`text-[10px] font-medium opacity-40 uppercase tracking-widest`,children:`Output`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[D,(0,K.jsx)(`div`,{className:`flex items-center gap-0.5 border border-base-300 rounded overflow-hidden ml-1`,children:fy.map(e=>(0,K.jsx)(`button`,{onClick:()=>f(e.value),className:`px-1.5 py-0.5 text-[10px] font-mono transition-colors ${d===e.value?`bg-primary text-primary-content`:`hover:bg-base-300 opacity-50 hover:opacity-100`}`,children:e.label},e.value))}),(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost opacity-40 hover:opacity-80 px-1.5`,onClick:C,title:`Reload full log`,children:`↺`}),!m&&(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost opacity-40 hover:opacity-80`,onClick:()=>{h(!0),p.current?.scrollTo(0,p.current.scrollHeight)},children:`↓ end`})]})]}),(0,K.jsx)(`pre`,{ref:p,onScroll:T,className:`flex-1 overflow-y-auto p-4 text-xs font-mono whitespace-pre-wrap break-all leading-relaxed bg-base-100 min-h-0`,dangerouslySetInnerHTML:{__html:g||(l?`<span style="color:color-mix(in srgb, currentColor 60%, transparent)">${String(l).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}</span>`:`<span style="opacity:0.2">No output yet. Start the service to see logs here.</span>`)}})]})}function my({serviceId:e,traffic:t,graph:n}){let r=(0,G.useMemo)(()=>t?.length?t.filter(t=>t.sourceServiceId===e||t.targetServiceId===e).slice(-30):[],[t,e]),i=(0,G.useMemo)(()=>n?.edges?.length?{inbound:n.edges.filter(t=>(typeof t.target==`object`?t.target.id:t.target)===e),outbound:n.edges.filter(t=>(typeof t.source==`object`?t.source.id:t.source)===e)}:{inbound:[],outbound:[]},[n,e]);if(!(r.length>0||i.inbound.length>0||i.outbound.length>0))return null;let a=e=>e<300?`text-success`:e<400?`text-warning`:`text-error`;return(0,K.jsxs)(`div`,{className:`border-t border-base-200/60 shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-base-200/30`,children:[(0,K.jsx)(xr,{className:`size-3 opacity-30`}),(0,K.jsx)(`span`,{className:`text-[10px] font-medium opacity-35 uppercase tracking-widest`,children:`Traffic`}),(0,K.jsx)(`span`,{className:`flex-1`}),(0,K.jsxs)(`span`,{className:`text-[10px] opacity-20 tabular-nums`,children:[r.length,` requests`]})]}),(i.inbound.length>0||i.outbound.length>0)&&(0,K.jsxs)(`div`,{className:`px-3 py-2 border-t border-base-200/40 flex flex-wrap gap-x-4 gap-y-1`,children:[i.inbound.map(e=>{let t=typeof e.source==`object`?e.source.id:e.source;return(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px]`,children:[(0,K.jsx)(ln,{className:`size-2.5 opacity-30 rotate-180`}),(0,K.jsx)(`span`,{className:`font-mono opacity-50`,children:t}),(0,K.jsxs)(`span`,{className:`opacity-25`,children:[e.requestCount,`req`]}),e.errorCount>0&&(0,K.jsxs)(`span`,{className:`text-error/70`,children:[e.errorCount,`err`]})]},`in-${t}`)}),i.outbound.map(e=>{let t=typeof e.target==`object`?e.target.id:e.target;return(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px]`,children:[(0,K.jsx)(ln,{className:`size-2.5 opacity-30`}),(0,K.jsx)(`span`,{className:`font-mono opacity-50`,children:t}),(0,K.jsxs)(`span`,{className:`opacity-25`,children:[e.requestCount,`req`]}),e.errorCount>0&&(0,K.jsxs)(`span`,{className:`text-error/70`,children:[e.errorCount,`err`]})]},`out-${t}`)})]}),r.length>0&&(0,K.jsx)(`div`,{className:`max-h-[140px] overflow-y-auto border-t border-base-200/40`,children:r.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-0.5 text-[10px] border-b border-base-content/[0.03] hover:bg-base-200/20`,children:[(0,K.jsx)(`span`,{className:`font-mono opacity-40 w-8 shrink-0`,children:e.method}),(0,K.jsx)(`span`,{className:`font-mono opacity-35 truncate flex-1`,children:e.path}),(0,K.jsx)(`span`,{className:`font-mono shrink-0 ${a(e.statusCode)}`,children:e.statusCode}),(0,K.jsxs)(`span`,{className:`font-mono opacity-30 shrink-0 tabular-nums w-10 text-right`,children:[e.durationMs,`ms`]})]},e.id))})]})}function hy({service:e,onClose:t,onRefresh:n,traffic:r,graph:i}){let[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)({open:!1,defaultValues:null}),[h,g]=(0,G.useState)(null),{createIssue:_,showToast:v}=tn(),y=e.state??(e.running?`running`:`stopped`),b=dy(y),x=y===`running`||y===`starting`,S=(0,G.useCallback)(async()=>{o(!0);try{await U.post(`/services/${e.id}/start`,{}),await n()}finally{o(!1)}},[e.id,n]),C=(0,G.useCallback)(async()=>{o(!0);try{await U.post(`/services/${e.id}/stop`,{}),await n()}finally{o(!1)}},[e.id,n]),w=(0,G.useCallback)(async()=>{c(!0),u(null);try{let t=await U.post(`/services/${e.id}/detect-healthcheck`,{});u(t.found?{found:!0,healthcheck:t.healthcheck}:{found:!1}),t.found&&await n()}catch(e){u(`error`),v(e.message??`Detection failed`,`error`)}finally{c(!1)}},[e.id,n,v]),T=(0,G.useCallback)(async()=>{f(!0),g(null);try{let t=await U.post(`/services/${e.id}/fix`,{});t.hasProblem?g({healthy:!1,title:t.title,description:t.description,issueType:t.issueType}):g({healthy:!0})}catch(e){g({error:e.message??`Analysis failed`})}finally{f(!1)}},[e.id]),E=y===`running`?`text-success`:y===`crashed`?`text-error`:y===`starting`||y===`stopping`?`text-warning`:`opacity-35`,D=!!(h&&!h.healthy),O=!!(D&&(h?.error||y===`crashed`));return(0,K.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[(0,K.jsx)(`div`,{className:`h-px w-full shrink-0 ${b.strip} opacity-60`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 shrink-0`,children:[(0,K.jsx)(kn,{className:`size-1.5 shrink-0 ${b.dot} ${b.spinning?`animate-pulse`:``}`}),(0,K.jsx)(`span`,{className:`font-semibold text-sm truncate flex-1 leading-none`,children:e.name}),e.pid&&y===`running`&&(0,K.jsxs)(`span`,{className:`text-[11px] font-mono opacity-25 tabular-nums shrink-0`,children:[`pid `,e.pid]}),(0,K.jsx)(`span`,{className:`text-[11px] font-medium shrink-0 ${E}`,children:b.spinning?(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(q,{className:`size-3 animate-spin`}),b.label]}):b.label}),x?(0,K.jsxs)(`button`,{className:`btn btn-xs btn-error h-6 min-h-0 gap-1 px-2 shrink-0`,onClick:C,disabled:a,children:[a?(0,K.jsx)(q,{className:`size-3 animate-spin`}):(0,K.jsx)(Jr,{className:`size-3`}),`Stop`]}):(0,K.jsxs)(`button`,{className:`btn btn-xs btn-success h-6 min-h-0 gap-1 px-2 shrink-0`,onClick:S,disabled:a||y===`stopping`,children:[a?(0,K.jsx)(q,{className:`size-3 animate-spin`}):(0,K.jsx)(Or,{className:`size-3`}),`Start`]}),(0,K.jsx)(`button`,{onClick:t,className:`btn btn-ghost btn-xs btn-circle h-6 min-h-0 w-6 opacity-40 hover:opacity-80 shrink-0`,children:(0,K.jsx)(li,{className:`size-3.5`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-t border-base-200/60 shrink-0 min-w-0`,children:[(0,K.jsx)(`code`,{className:`text-[11px] font-mono opacity-50 truncate flex-1 leading-none`,children:e.command}),e.cwd&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] font-mono opacity-30 shrink-0`,children:[(0,K.jsx)(Jn,{className:`size-3`}),e.cwd]}),e.logSize!=null&&e.logSize>0&&(0,K.jsxs)(`span`,{className:`text-[11px] font-mono opacity-25 shrink-0 tabular-nums`,children:[(e.logSize/1024).toFixed(1),`KB`]}),e.running&&e.startedAt&&(0,K.jsx)(`span`,{className:`text-[11px] opacity-30 shrink-0 tabular-nums`,children:(0,K.jsx)(ay,{startedAt:e.startedAt,running:e.running})}),y===`crashed`&&e.crashCount>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] text-error/50 shrink-0`,children:[(0,K.jsx)(ni,{className:`size-3`}),e.crashCount]})]}),(y===`running`||y===`crashed`)&&(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 py-1 border-t border-base-200/60 bg-base-200/20 shrink-0`,children:[(0,K.jsxs)(`button`,{className:`btn btn-xs btn-ghost h-6 min-h-0 gap-1 px-2 text-[11px] opacity-50 hover:opacity-90`,onClick:w,disabled:s||d,children:[s?(0,K.jsx)(q,{className:`size-3 animate-spin`}):(0,K.jsx)(Ir,{className:`size-3`}),s?`Scanning…`:`Detect`]}),l&&l!==`error`&&(l.found?(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] text-success`,children:[(0,K.jsx)(Tn,{className:`size-3`}),l.healthcheck?.endpoint??`port ${l.healthcheck?.port}`]}):(0,K.jsx)(`span`,{className:`text-[11px] opacity-30`,children:`no config detected`})),(0,K.jsx)(`div`,{className:`flex-1`}),(0,K.jsx)(`div`,{className:`w-px h-3 bg-base-content/10 mx-0.5 shrink-0`}),(0,K.jsxs)(`button`,{className:`btn btn-xs btn-ghost h-6 min-h-0 gap-1 px-2 text-[11px] opacity-50 hover:opacity-90`,onClick:T,disabled:d||s,children:[d?(0,K.jsx)(q,{className:`size-3 animate-spin`}):(0,K.jsx)(ci,{className:`size-3`}),d?`Analyzing…`:`Analyze`]}),h?.healthy&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] text-success/70`,children:[(0,K.jsx)(Tn,{className:`size-3 shrink-0`}),`Clean`]})]}),(0,K.jsx)(`div`,{className:`grid shrink-0`,style:{gridTemplateRows:D?`1fr`:`0fr`,transition:`grid-template-rows 220ms cubic-bezier(0.16, 1, 0.3, 1)`},children:(0,K.jsx)(`div`,{className:`overflow-hidden`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2.5 px-3 py-2.5 border-b ${O?`bg-error/5 border-error/20`:`bg-warning/5 border-warning/20`}`,children:[(0,K.jsx)(ni,{className:`size-3.5 shrink-0 mt-0.5 ${O?`text-error`:`text-warning`}`}),(0,K.jsx)(`div`,{className:`flex-1 min-w-0`,children:h?.error?(0,K.jsx)(`p`,{className:`text-xs leading-relaxed opacity-70`,children:h.error}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-sm font-medium leading-snug`,children:h?.title}),h?.description&&(0,K.jsx)(`p`,{className:`text-xs opacity-50 mt-0.5 line-clamp-2 leading-relaxed`,children:h.description})]})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[!h?.error&&h?.title&&(0,K.jsxs)(`button`,{className:`btn btn-xs h-6 min-h-0 gap-1 px-2.5 ${O?`btn-error`:`btn-warning`}`,onClick:()=>m({open:!0,defaultValues:{title:h.title,description:h.description,issueType:h.issueType}}),children:[`Create Issue`,(0,K.jsx)(Sn,{className:`size-3`})]}),(0,K.jsx)(`button`,{className:`btn btn-ghost btn-xs btn-circle h-5 min-h-0 w-5 opacity-30 hover:opacity-70`,onClick:()=>g(null),children:(0,K.jsx)(li,{className:`size-3`})})]})]})})}),(0,K.jsx)(my,{serviceId:e.id,traffic:r,graph:i}),(0,K.jsx)(py,{id:e.id,running:e.running,state:y}),(0,K.jsx)(Di,{open:p.open,onClose:()=>m({open:!1,defaultValues:null}),onSubmit:async e=>{await _.mutateAsync(e),m({open:!1,defaultValues:null})},defaultValues:p.defaultValues,onToast:v})]})}function gy({service:e,onClose:t,onRefresh:n,traffic:r,graph:i}){let[a,o]=(0,G.useState)(!1),s=(0,G.useCallback)(()=>{o(!0),setTimeout(()=>{o(!1),t()},250)},[t]);return(0,G.useEffect)(()=>{let e=e=>{e.key===`Escape`&&s()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[s]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Oi,{onClick:s,className:a?`animate-fade-out`:`animate-fade-in`}),(0,K.jsx)(ki,{closing:a,width:`w-full sm:w-[500px] lg:w-[40vw] lg:min-w-[520px] xl:min-w-[600px]`,onClick:e=>e.stopPropagation(),children:(0,K.jsx)(hy,{service:e,onClose:s,onRefresh:n,traffic:r,graph:i})})]})}function _y(e){return e==null||e<=0?null:e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function vy({service:e,selected:t,onSelect:n,onRefresh:r}){let[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(null),c=e.state??(e.running?`running`:`stopped`),l=dy(c),u=c===`stopped`||c===`crashed`,d=c===`running`||c===`starting`;(0,G.useEffect)(()=>{if(!e.running||!e.port){s(null);return}let t=!1,n=async()=>{try{let n=await U.get(`/services/${encodeURIComponent(e.id)}/health`);t||s(n)}catch{t||s(null)}};n();let r=setInterval(n,3e4);return()=>{t=!0,clearInterval(r)}},[e.id,e.running,e.port]);let f=(0,G.useCallback)(async(t,n)=>{t.stopPropagation(),a(!0);try{await U.post(`/services/${e.id}/${n}`,{}),setTimeout(()=>r?.(),500)}finally{a(!1)}},[e.id,r]),p=_y(e.logSize),m=!e.running||!e.port?null:o?o.healthy?(0,K.jsxs)(`span`,{className:`flex items-center gap-0.5 text-success/70`,title:`Healthy — ${o.latencyMs}ms`,children:[(0,K.jsx)(kn,{className:`size-1.5 fill-current`}),(0,K.jsxs)(`span`,{className:`text-[10px] tabular-nums`,children:[o.latencyMs,`ms`]})]}):(0,K.jsxs)(`span`,{className:`flex items-center gap-0.5 text-error/70`,title:`Unhealthy`,children:[(0,K.jsx)(kn,{className:`size-1.5 fill-current`}),(0,K.jsx)(`span`,{className:`text-[10px]`,children:`down`})]}):(0,K.jsx)(kn,{className:`size-1.5 text-base-content/20 fill-base-content/20`,title:`Checking...`});return(0,K.jsx)(`button`,{type:`button`,onClick:()=>n(e.id),className:`group relative text-left rounded-md border border-base-content/[0.08] bg-base-200/40 transition-all duration-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30
44
+ ${t?`ring-1 ring-primary/30 bg-base-200/70`:`hover:bg-base-200/60`}${c===`crashed`?` border-error/20`:``}`,children:(0,K.jsxs)(`div`,{className:`px-3.5 py-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(kn,{className:`size-1.5 shrink-0 ${l.dot}${l.spinning?` animate-pulse`:``}`}),(0,K.jsx)(`span`,{className:`font-medium text-sm leading-none truncate flex-1 min-w-0`,children:e.name}),u&&(0,K.jsxs)(`span`,{role:`button`,tabIndex:-1,className:`btn btn-xs btn-ghost h-5 min-h-0 gap-1 px-1.5 text-success/70 hover:text-success hover:bg-success/10`,onClick:e=>f(e,`start`),children:[i?(0,K.jsx)(q,{className:`size-3 animate-spin`}):(0,K.jsx)(Or,{className:`size-3`}),`Start`]}),d&&(0,K.jsx)(`span`,{role:`button`,tabIndex:-1,className:`btn btn-xs btn-ghost h-5 min-h-0 px-1 opacity-0 group-hover:opacity-100 hover:bg-base-300/50 transition-opacity`,onClick:e=>f(e,`restart`),title:`Restart`,children:i?(0,K.jsx)(q,{className:`size-3 animate-spin`}):(0,K.jsx)(Pr,{className:`size-2.5 opacity-50`})}),d&&(0,K.jsx)(`span`,{role:`button`,tabIndex:-1,className:`btn btn-xs btn-ghost h-5 min-h-0 px-1 opacity-0 group-hover:opacity-100 text-error/50 hover:text-error hover:bg-error/10 transition-opacity`,onClick:e=>f(e,`stop`),children:i?(0,K.jsx)(q,{className:`size-3 animate-spin`}):(0,K.jsx)(Jr,{className:`size-2.5`})})]}),(0,K.jsx)(`div`,{className:`font-mono text-[11px] opacity-35 truncate mt-1.5 leading-none`,children:e.command}),(c===`running`||c===`starting`||c===`crashed`)&&(0,K.jsxs)(`div`,{className:`flex items-center gap-x-3 gap-y-0.5 flex-wrap text-[11px] tabular-nums opacity-40 mt-2 leading-tight`,children:[e.running&&e.startedAt&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`opacity-60`,children:`up`}),(0,K.jsx)(ay,{startedAt:e.startedAt,running:!0})]}),e.pid&&c===`running`&&(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{className:`opacity-60`,children:`pid`}),` `,e.pid]}),e.port&&(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{className:`opacity-60`,children:`:`}),e.port]}),m,p&&(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{className:`opacity-60`,children:`log`}),` `,p]}),e.crashCount>0&&(0,K.jsxs)(`span`,{className:`text-error/70 flex items-center gap-0.5`,children:[(0,K.jsx)(ni,{className:`size-2.5`}),e.crashCount]}),e.errorCount>0&&(0,K.jsxs)(`span`,{className:`text-error/70 flex items-center gap-0.5`,children:[(0,K.jsx)(ni,{className:`size-2.5`}),e.errorCount,` err`]}),e.autoStart&&(0,K.jsx)(`span`,{className:`opacity-40`,children:`auto`})]})]})})}function yy(){return(0,K.jsx)(`div`,{className:`rounded-md bg-base-200/50 animate-pulse`,children:(0,K.jsxs)(`div`,{className:`px-3.5 py-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,K.jsx)(`div`,{className:`h-3.5 w-24 rounded bg-base-300 flex-1 max-w-[8rem]`}),(0,K.jsx)(`div`,{className:`h-4 w-12 rounded-full bg-base-300 shrink-0`})]}),(0,K.jsx)(`div`,{className:`h-2.5 w-36 rounded bg-base-300 mb-2`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`h-2.5 w-12 rounded bg-base-300`}),(0,K.jsx)(`div`,{className:`h-2.5 w-10 rounded bg-base-300`}),(0,K.jsx)(`div`,{className:`h-2.5 w-14 rounded bg-base-300`})]})]})})}var by=e=>e===`running`||e===`starting`?`#22c55e`:e===`crashed`?`#ef4444`:`#6b7280`;function xy({data:e}){let t=by(e.state);return(0,K.jsxs)(`div`,{className:`relative px-4 py-2.5 rounded-md border bg-base-200/80 min-w-[120px] text-center`,style:{borderColor:`color-mix(in srgb, ${t} 40%, transparent)`},children:[(0,K.jsx)(Wg,{type:`target`,position:Y.Left,className:`!bg-base-content/20 !w-1.5 !h-1.5 !border-0`}),(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-1.5 mb-0.5`,children:[(0,K.jsx)(`div`,{className:`size-2 rounded-full`,style:{backgroundColor:t}}),(0,K.jsx)(`span`,{className:`text-xs font-medium opacity-80`,children:e.name})]}),e.port&&(0,K.jsxs)(`span`,{className:`text-[10px] font-mono opacity-30`,children:[`:`,e.port]}),(0,K.jsx)(Wg,{type:`source`,position:Y.Right,className:`!bg-base-content/20 !w-1.5 !h-1.5 !border-0`})]})}var Sy={service:xy};function Cy(e,t){if(!e?.nodes?.length)return{nodes:[],edges:[]};let n=e.nodes.map((e,t)=>({id:e.id,type:`service`,position:{x:t%4*220+40,y:Math.floor(t/4)*120+40},data:{name:e.name,state:e.state,port:e.port}})),r=e=>e.errorCount>0&&e.errorCount/e.requestCount>.3?`#ef4444`:e.avgLatencyMs>200?`#eab308`:`#22c55e`;return{nodes:n,edges:e.edges.map((e,n)=>{let i=typeof e.source==`object`?e.source.id:e.source,a=typeof e.target==`object`?e.target.id:e.target,o=t&&(typeof t.source==`object`?t.source.id:t.source)===i&&(typeof t.target==`object`?t.target.id:t.target)===a,s=r(e);return{id:`e-${n}`,source:i,target:a,animated:e.requestCount>0,label:`${e.requestCount} req · ${e.avgLatencyMs}ms${e.errorCount>0?` · ${e.errorCount} err`:``}`,labelStyle:{fontSize:10,fill:`currentColor`,opacity:.4},style:{stroke:s,strokeWidth:Math.min(1+Math.log2(1+e.requestCount),5),opacity:o?.9:.4},data:e}})}}function wy({graph:e,onSelectEdge:t,selectedEdge:n}){let{nodes:r,edges:i}=(0,G.useMemo)(()=>Cy(e,n),[e,n]),[a,o,s]=Cv(r),[c,l,u]=wv(i);(0,G.useEffect)(()=>{o(r)},[r,o]),(0,G.useEffect)(()=>{l(i)},[i,l]);let d=(0,G.useCallback)((n,r)=>{let i=e?.edges?.find(e=>{let t=typeof e.source==`object`?e.source.id:e.source,n=typeof e.target==`object`?e.target.id:e.target;return t===r.source&&n===r.target});t?.(i??null)},[e,t]);return!e||!e.nodes.length?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 opacity-20`,children:[(0,K.jsx)(ui,{className:`size-5`}),(0,K.jsx)(`span`,{className:`text-xs`,children:`Start services and trigger inter-service HTTP calls to see the mesh`})]}):(0,K.jsxs)(Sv,{nodes:a,edges:c,onNodesChange:s,onEdgesChange:u,onEdgeClick:d,nodeTypes:Sy,fitView:!0,fitViewOptions:{padding:.3},proOptions:{hideAttribution:!0},className:`[&_.react-flow__edge]:cursor-pointer`,children:[(0,K.jsx)(jv,{gap:20,size:1,color:`currentColor`,className:`opacity-[0.03]`}),(0,K.jsx)(ey,{nodeColor:e=>by(e.data?.state),maskColor:`rgba(0,0,0,0.7)`,className:`!bg-base-200/80 !border-base-content/10 !rounded`,pannable:!0,zoomable:!0})]})}function Ty({entries:e,selectedEdge:t}){let n=(0,G.useRef)(null),r=(0,G.useMemo)(()=>{if(!t)return e;let n=typeof t.source==`object`?t.source.id:t.source,r=typeof t.target==`object`?t.target.id:t.target;return e.filter(e=>e.sourceServiceId===n&&e.targetServiceId===r)},[e,t]).slice(-80);(0,G.useEffect)(()=>{n.current&&(n.current.scrollTop=n.current.scrollHeight)},[r.length]);let i=e=>e<300?`text-success`:e<400?`text-warning`:`text-error`;return r.length===0?(0,K.jsx)(`div`,{className:`flex items-center justify-center h-full opacity-20 text-[11px]`,children:t?`No traffic for this connection`:`No traffic captured yet`}):(0,K.jsx)(`div`,{ref:n,className:`overflow-y-auto flex-1 min-h-0`,children:(0,K.jsxs)(`table`,{className:`w-full text-[11px]`,children:[(0,K.jsx)(`thead`,{className:`sticky top-0 bg-base-200/90 backdrop-blur-sm`,children:(0,K.jsxs)(`tr`,{className:`text-left opacity-40`,children:[(0,K.jsx)(`th`,{className:`px-2 py-1 font-medium`,children:`Source`}),(0,K.jsx)(`th`,{className:`px-2 py-1 font-medium`,children:`Target`}),(0,K.jsx)(`th`,{className:`px-2 py-1 font-medium`,children:`Method`}),(0,K.jsx)(`th`,{className:`px-2 py-1 font-medium`,children:`Path`}),(0,K.jsx)(`th`,{className:`px-2 py-1 font-medium text-right`,children:`Status`}),(0,K.jsx)(`th`,{className:`px-2 py-1 font-medium text-right`,children:`Latency`})]})}),(0,K.jsx)(`tbody`,{children:r.map(e=>(0,K.jsxs)(`tr`,{className:`border-t border-base-content/[0.04] hover:bg-base-200/30`,children:[(0,K.jsx)(`td`,{className:`px-2 py-0.5 font-mono opacity-50 truncate max-w-[100px]`,children:e.sourceServiceId??`?`}),(0,K.jsx)(`td`,{className:`px-2 py-0.5 font-mono opacity-50 truncate max-w-[100px]`,children:e.targetServiceId??`ext`}),(0,K.jsx)(`td`,{className:`px-2 py-0.5 font-mono font-medium opacity-60`,children:e.method}),(0,K.jsx)(`td`,{className:`px-2 py-0.5 font-mono opacity-40 truncate max-w-[200px]`,children:e.path}),(0,K.jsx)(`td`,{className:`px-2 py-0.5 text-right font-mono ${i(e.statusCode)}`,children:e.statusCode}),(0,K.jsxs)(`td`,{className:`px-2 py-0.5 text-right font-mono opacity-40 tabular-nums`,children:[e.durationMs,`ms`]})]},e.id))})]})})}function Ey(){let{liveMode:e}=tn(),{services:t,loading:n,refresh:r}=It({pollInterval:e?!1:15e3}),{graph:i,traffic:a,status:o,clearMesh:s,toggleMesh:c}=Ut(),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(null),p=o?.enabled??!1,m=o?.running??!1,h=t.find(e=>e.id===l)??null;(0,G.useEffect)(()=>{l&&!n&&!h&&u(null)},[l,h,n]);let g=(0,G.useCallback)(e=>{u(t=>t===e?null:e)},[]),_=(0,G.useCallback)(()=>u(null),[]),v=(0,G.useCallback)(async()=>{await Promise.all(t.filter(e=>!e.running).map(e=>U.post(`/services/${e.id}/start`,{}))),await r()},[t,r]),y=(0,G.useCallback)(async()=>{await Promise.all(t.filter(e=>e.running).map(e=>U.post(`/services/${e.id}/stop`,{}))),await r()},[t,r]),b=t.some(e=>e.running),x=t.length>0&&t.every(e=>e.running),S=t.filter(e=>e.running).length,C=e=>e.running||e.state===`starting`||e.state===`crashed`,w=t.filter(C),T=t.filter(e=>!C(e));return(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-base-200 shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,K.jsx)(zr,{className:`size-3.5 opacity-35`}),(0,K.jsx)(`span`,{className:`text-xs font-semibold opacity-55 uppercase tracking-widest`,children:`Services`}),!n&&t.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsxs)(`span`,{className:`text-[11px] opacity-30 tabular-nums`,children:[S,`/`,t.length]}),(0,K.jsx)(`div`,{className:`w-16 h-1 rounded-full bg-base-300 overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full bg-success/60 rounded-full transition-all duration-300`,style:{width:`${S/t.length*100}%`}})})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[o&&(0,K.jsxs)(`label`,{className:`flex items-center gap-1.5 mr-2 cursor-pointer`,title:p?`Mesh proxy is active — capturing inter-service traffic`:`Enable mesh proxy to capture inter-service traffic`,children:[(0,K.jsx)(xr,{className:`size-3 ${m?`text-success/70`:`opacity-25`}`}),(0,K.jsx)(`span`,{className:`text-[10px] opacity-35`,children:`Mesh`}),(0,K.jsx)(`input`,{type:`checkbox`,className:`toggle toggle-xs toggle-success`,checked:p,onChange:e=>c(e.target.checked)})]}),m&&(i?.totalRequests??0)>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 mr-1`,children:[(0,K.jsxs)(`span`,{className:`text-[10px] opacity-25 tabular-nums`,children:[i.totalRequests,` req · `,i.edges?.length??0,` conn`]}),d&&(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost opacity-40 hover:opacity-80 h-4 min-h-0 px-1 text-[10px]`,onClick:()=>f(null),children:`clear filter`}),(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost opacity-25 hover:opacity-60 h-4 min-h-0 px-1`,onClick:s,title:`Clear traffic data`,children:(0,K.jsx)(ei,{className:`size-2.5`})})]}),t.length>0&&!x&&(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost opacity-50 hover:opacity-90`,onClick:v,children:`Start all`}),b&&(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost text-error opacity-50 hover:opacity-90`,onClick:y,children:`Stop all`})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-3`,children:[n&&(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-2`,children:[(0,K.jsx)(yy,{}),(0,K.jsx)(yy,{}),(0,K.jsx)(yy,{}),(0,K.jsx)(yy,{}),(0,K.jsx)(yy,{}),(0,K.jsx)(yy,{})]}),!n&&t.length===0&&(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 px-6 py-16`,children:[(0,K.jsx)(zr,{className:`size-8 opacity-10`}),(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium opacity-60`,children:`No services configured`}),(0,K.jsx)(`p`,{className:`text-xs opacity-35 mt-1`,children:`Add services in Settings to manage them here.`})]})]}),!n&&t.length>0&&(0,K.jsxs)(`div`,{className:`space-y-6`,children:[w.length>0&&(0,K.jsxs)(`section`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2.5 mb-2.5`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-medium opacity-30 uppercase tracking-wider`,children:`Active`}),(0,K.jsx)(`div`,{className:`flex-1 h-px bg-base-content/5`})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-2.5 items-start`,children:w.map(e=>(0,K.jsx)(vy,{service:e,selected:e.id===l,onSelect:g,onRefresh:r},e.id))})]}),T.length>0&&(0,K.jsxs)(`section`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2.5 mb-2.5`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-medium opacity-30 uppercase tracking-wider`,children:`Stopped`}),(0,K.jsx)(`div`,{className:`flex-1 h-px bg-base-content/5`})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-2 items-start`,children:T.map(e=>(0,K.jsx)(vy,{service:e,selected:e.id===l,onSelect:g,onRefresh:r},e.id))})]})]}),m&&t.length>0&&(0,K.jsxs)(`section`,{className:`mt-6`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2.5 mb-2.5`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-medium opacity-30 uppercase tracking-wider`,children:`Mesh`}),(0,K.jsx)(`div`,{className:`flex-1 h-px bg-base-content/5`}),d&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] opacity-40 font-mono`,children:[typeof d.source==`object`?d.source.id:d.source,(0,K.jsx)(ln,{className:`size-2.5`}),typeof d.target==`object`?d.target.id:d.target,(0,K.jsxs)(`span`,{className:`opacity-60`,children:[d.requestCount,`req · `,d.avgLatencyMs,`ms`,d.errorCount>0&&(0,K.jsxs)(`span`,{className:`text-error`,children:[` · `,d.errorCount,`err`]})]})]})]}),(0,K.jsxs)(`div`,{className:`h-[400px] rounded-md border border-base-content/[0.06] bg-base-200/20 relative`,children:[(0,K.jsx)(wy,{graph:i,onSelectEdge:f,selectedEdge:d}),d&&d.topPaths?.length>0&&(0,K.jsx)(`div`,{className:`absolute bottom-2 left-2 bg-base-200/90 backdrop-blur-sm rounded border border-base-content/[0.06] px-2.5 py-1.5 text-[10px]`,children:(0,K.jsx)(`div`,{className:`space-y-0.5`,children:d.topPaths.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 opacity-40 font-mono`,children:[(0,K.jsx)(`span`,{className:`truncate max-w-[180px]`,children:e.path}),(0,K.jsxs)(`span`,{className:`shrink-0`,children:[e.count,`x`]})]},e.path))})})]}),(0,K.jsxs)(`div`,{className:`mt-3 h-[220px] rounded-md border border-base-content/[0.06] bg-base-200/20 flex flex-col overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-base-content/[0.04] shrink-0`,children:[(0,K.jsx)(`span`,{className:`text-[10px] font-medium opacity-25 uppercase tracking-widest`,children:`Traffic`}),(0,K.jsx)(`span`,{className:`flex-1`}),(0,K.jsxs)(`span`,{className:`text-[10px] opacity-20 tabular-nums`,children:[a.length,` entries`]})]}),(0,K.jsx)(Ty,{entries:a,selectedEdge:d})]})]})]}),h&&(0,K.jsx)(gy,{service:h,onClose:_,onRefresh:r,traffic:a,graph:i},h.id)]})}var Dy=(0,G.lazy)(()=>To(()=>import(`./OnboardingWizard-BmI50ZUv.js`),__vite__mapDeps([6,1,5,2])));function Oy(){let e=O(),t=an(me(rt().data));return(0,G.useEffect)(()=>{t&&e({to:`/kanban`,replace:!0})},[t,e]),t?(0,K.jsx)(`div`,{className:`min-h-screen flex items-center justify-center`,children:(0,K.jsx)(`span`,{className:`loading loading-spinner loading-lg`})}):(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(`div`,{className:`min-h-screen flex items-center justify-center`,children:(0,K.jsx)(`span`,{className:`loading loading-spinner loading-lg`})}),children:(0,K.jsx)(Dy,{onComplete:()=>{e({to:`/kanban`,replace:!0})}})})}var ky=v(`/onboarding`)({component:Oy}),Ay=v(`/milestones`)({component:My});function jy(e){return e>=100?`progress-success`:e>=50?`progress-primary`:`progress-warning`}function My(){let e=tn(),[t,n]=(0,G.useState)(``),[r,i]=(0,G.useState)(``),[a,o]=(0,G.useState)(!1),s=(0,G.useMemo)(()=>[...e.milestones].sort((e,t)=>(t.updatedAt||t.createdAt||``).localeCompare(e.updatedAt||e.createdAt||``)),[e.milestones]);return(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 px-4 pb-4 gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between pt-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,style:{fontFamily:`'Space Grotesk', system-ui, sans-serif`},children:`Milestones`}),(0,K.jsx)(`p`,{className:`text-sm opacity-55 mt-1`,children:`Group issues into milestones and track progress automatically.`})]}),(0,K.jsxs)(`button`,{className:`btn btn-sm btn-primary gap-1.5`,onClick:()=>o(e=>!e),children:[a?(0,K.jsx)(li,{className:`size-3.5`}):(0,K.jsx)(kr,{className:`size-3.5`}),a?`Cancel`:`New milestone`]})]}),a&&(0,K.jsx)(`form`,{onSubmit:async a=>{a.preventDefault();let s=t.trim();s&&(await e.createMilestone.mutateAsync({name:s,description:r.trim()||void 0,status:`active`}),n(``),i(``),o(!1))},className:`card bg-base-200 border border-base-300`,children:(0,K.jsxs)(`div`,{className:`card-body gap-3`,children:[(0,K.jsx)(`input`,{className:`input input-bordered w-full`,placeholder:`Milestone name`,value:t,onChange:e=>n(e.target.value),autoFocus:!0}),(0,K.jsx)(`textarea`,{className:`textarea textarea-bordered w-full min-h-20`,placeholder:`Short description (optional)`,value:r,onChange:e=>i(e.target.value)}),(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)(`button`,{className:`btn btn-primary btn-sm`,disabled:e.createMilestone.isPending||!t.trim(),children:e.createMilestone.isPending?`Creating...`:`Create milestone`})})]})}),s.length===0?(0,K.jsx)(`div`,{className:`flex-1 grid place-items-center`,children:(0,K.jsxs)(`div`,{className:`text-center opacity-55`,children:[(0,K.jsx)(Kn,{className:`size-10 mx-auto mb-3 opacity-40`}),(0,K.jsx)(`div`,{className:`font-semibold`,children:`No milestones yet`}),(0,K.jsx)(`p`,{className:`text-sm mt-1`,children:`Create one and start attaching issues to it.`})]})}):(0,K.jsx)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-3`,children:s.map(t=>(0,K.jsx)(b,{to:`/issues`,search:{milestone:t.id},className:`group card bg-base-100 border border-base-300 hover:border-primary/40 hover:bg-base-200/60 transition-colors`,children:(0,K.jsxs)(`div`,{className:`card-body gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`h2`,{className:`card-title text-lg`,children:t.name}),t.description&&(0,K.jsx)(`p`,{className:`text-sm opacity-60 mt-1`,children:t.description})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost opacity-0 group-hover:opacity-40 hover:!opacity-100 text-error transition-opacity`,title:t.issueCount>0?`Remove all issues first`:`Delete milestone`,disabled:t.issueCount>0,onClick:n=>{n.preventDefault(),e.deleteMilestone(t.id)},children:(0,K.jsx)(ei,{className:`size-3.5`})}),(0,K.jsx)(Sn,{className:`size-4 opacity-20 group-hover:opacity-60 transition-opacity mt-0.5`})]})]}),(0,K.jsx)(`progress`,{className:`progress w-full ${jy(t.progress.progressPercent)}`,value:t.progress.progressPercent,max:`100`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-xs opacity-70`,children:[(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,K.jsx)(Xr,{className:`size-3`}),t.issueCount,` issues`]}),(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,K.jsx)(Tn,{className:`size-3`}),t.progress.completedCount,`/`,t.progress.scopeCount,` done`]}),(0,K.jsxs)(`span`,{className:`font-mono`,children:[t.progress.progressPercent,`%`]})]})]})},t.id))})]})}function Ny(e){let[t,n]=(0,G.useState)(()=>Py(e)),r=(0,G.useRef)(null);return(0,G.useEffect)(()=>{if(!e){n(null);return}let t=()=>n(Py(e));t();let i=new Date(e).getTime(),a=()=>Date.now()-i<12e4?1e3:5e3,o=()=>{t(),clearInterval(r.current),r.current=setInterval(o,a())};return r.current=setInterval(o,a()),()=>clearInterval(r.current)},[e]),t}function Py(e){if(!e)return null;let t=new Date(e).getTime();if(Number.isNaN(t))return null;let n=Math.max(0,Date.now()-t);return n<1e3?`0s`:n<6e4?`${Math.floor(n/1e3)}s`:n<36e5?`${Math.floor(n/6e4)}m ${Math.floor(n%6e4/1e3)}s`:`${Math.floor(n/36e5)}h ${Math.floor(n%36e5/6e4)}m`}var Fy={bug:`badge-error`,feature:`badge-primary`,refactor:`badge-warning`,docs:`badge-info`,chore:`badge-secondary`},Iy={Planning:`border-l-info`,PendingApproval:`border-l-warning`,Queued:`border-l-info`,Running:`border-l-primary`,Reviewing:`border-l-secondary`,PendingDecision:`border-l-success/60`,Blocked:`border-l-error`,Approved:`border-l-success`,Merged:`border-l-success`,Cancelled:`border-l-neutral`};function Ly(e){return!e||e===0?null:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function Ry(e){if(!e)return null;let t=e.match(/\d+$/);return t?t[0]:null}function zy(e){if(!e)return null;let t=e.match(/claude-(\w+)-(\d+)-(\d+)/);return t?`${t[1].charAt(0).toUpperCase()+t[1].slice(1)} ${t[2]}.${t[3]}`:e.length<=14?e:e.slice(0,14)}function By(e,t){let n=[{key:`planner`,short:`plan`},{key:`executor`,short:`exec`},{key:`reviewer`,short:`rev`}].filter(t=>(e?.[t.key]?.totalTokens||0)>0).map(n=>({label:n.short,model:zy(e[n.key]?.model||null),effort:t?.[n.key]||t?.default||null})).filter(e=>e.model);return n.length===0?[]:n.every(e=>e.model===n[0].model&&e.effort===n[0].effort)?[{label:null,model:n[0].model,effort:n[0].effort}]:n}function Vy(e){return e?e.reviewer?.totalTokens>0?`reviewing`:e.executor?.totalTokens>0?`executing`:e.planner?.totalTokens>0?`planning`:null:null}function Hy(e){if(e<=0)return`<1m`;let t=Math.floor(e/6e4),n=Math.floor(t/60),r=Math.floor(n/24);return r>0?`${r}d${n%24}h`:n>0?`${n}h${t%60}m`:`${t}m`}function Uy(e){return e.state===`Reviewing`?e.updatedAt:e.state===`PendingDecision`?e.completedAt||e.updatedAt:e.state===`Blocked`?e.updatedAt:null}function Wy(e){let{state:t,planningStatus:n,assignedToWorker:r,startedAt:i,tokenUsage:a,tokensByPhase:o}=e;switch(t){case`Planning`:return n===`planning`?{label:`Writing plan…`,Icon:gr,spin:!0,pulse:!1,color:`text-info`}:e.plan?{label:`Plan ready`,Icon:dr,spin:!1,pulse:!1,color:`text-info/60`}:e.planningError?{label:`Plan failed`,Icon:ni,spin:!1,pulse:!1,color:`text-error`}:{label:`Aguardando…`,Icon:jn,spin:!1,pulse:!0,color:`text-info/50`};case`PendingApproval`:return null;case`Queued`:return r?{label:`Starting…`,Icon:Or,spin:!1,pulse:!0,color:`text-primary/80`}:{label:`In queue`,Icon:pr,spin:!1,pulse:!1,color:`text-base-content/40`};case`Running`:{let e=Vy(o),t=a?.totalTokens>0;return!t&&!i?{label:`Spawning…`,Icon:gr,spin:!0,pulse:!1,color:`text-primary`}:t?e===`reviewing`?{label:`Reviewing…`,Icon:Vn,spin:!1,pulse:!0,color:`text-secondary`}:e===`planning`?{label:`Planning…`,Icon:dr,spin:!1,pulse:!0,color:`text-info`}:{label:`Working…`,Icon:Or,spin:!1,pulse:!0,color:`text-primary`}:{label:`Starting…`,Icon:gr,spin:!0,pulse:!1,color:`text-primary`}}case`Reviewing`:case`PendingDecision`:case`Blocked`:return`stall`;default:return null}}function Gy(e){let[t,n]=(0,G.useState)(()=>e?Math.max(0,Date.now()-new Date(e).getTime()):0);return(0,G.useEffect)(()=>{if(!e)return;let t=new Date(e).getTime(),r=()=>n(Math.max(0,Date.now()-t));r();let i=()=>Date.now()-t<36e5?3e4:12e4,a=setInterval(()=>{r(),clearInterval(a),a=setInterval(r,i())},i());return()=>clearInterval(a)},[e]),t}function Ky({issue:e}){let t=Wy(e),n=Uy(e),r=Gy(t===`stall`?n:null),i=Ny(t&&t!==`stall`&&e.state===`Running`?e.startedAt:null);if(!t)return null;if(t===`stall`){if(!n)return null;let t=e.state===`Blocked`?`text-error/70`:e.state===`PendingDecision`?`text-success/70`:`text-secondary/70`,i=e.state===`Blocked`?`blocked`:e.state===`PendingDecision`?`review complete`:`reviewing`;return(0,K.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] font-medium ${t}`,children:[(0,K.jsx)(jn,{size:10,className:`shrink-0`}),(0,K.jsx)(`span`,{className:`tabular-nums font-mono`,children:Hy(r)}),(0,K.jsxs)(`span`,{className:`opacity-60 font-normal`,children:[`· `,i]})]})}let{label:a,Icon:o,spin:s,pulse:c,color:l}=t;return(0,K.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] ${l}`,children:[o&&(0,K.jsx)(o,{size:10,className:[s?`animate-spin`:``,c?`status-indicator-pulse`:``].filter(Boolean).join(` `)}),(0,K.jsx)(`span`,{className:`font-medium truncate`,children:a}),i&&(0,K.jsx)(`span`,{className:`font-mono opacity-50 tabular-nums shrink-0 ml-0.5`,children:i})]})}function qy({issue:e,onSelect:t,dragHandlers:n,isDragging:r,isSelected:i,onToggleSelect:a,hasSelection:o}){let s=e.state===`Running`,c=e.state===`Planning`,l=e.state===`Approved`||e.state===`Merged`,u=e.state===`Merged`,d=e.state===`Cancelled`,f=e.state===`Blocked`,p=e.planningStatus===`planning`,m=!!e.mergedAt,h=e.mergeResult?.conflicts>0,g=!m&&!u&&!h&&!!e.branchName&&e.state===`Approved`,_=(0,G.useRef)(e.tokenUsage?.totalTokens),[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(!1),S=(0,G.useRef)(e.state);(0,G.useEffect)(()=>{let t=e.tokenUsage?.totalTokens;if(t!=null&&t!==_.current){y(!0);let e=setTimeout(()=>y(!1),300);return _.current=t,()=>clearTimeout(e)}},[e.tokenUsage?.totalTokens]),(0,G.useEffect)(()=>{if(S.current!==`Merged`&&e.state===`Merged`||S.current!==`Approved`&&e.state===`Approved`){x(!0);let t=setTimeout(()=>x(!1),800);return S.current=e.state,()=>clearTimeout(t)}S.current=e.state},[e.state]);let C=Ry(e.identifier),w=Ly(e.tokenUsage?.totalTokens||0),T=e.history?.length||0,E=By(e.tokensByPhase,e.effort),D=n=>{if(n.shiftKey){n.preventDefault(),a?.(e.id);return}if(o){n.preventDefault(),a?.(e.id);return}t?.(e)},O=n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),n.shiftKey||o?a?.(e.id):t?.(e))};return(0,K.jsxs)(`div`,{"data-issue-id":e.id,className:[`card card-compact bg-base-100 border border-l-[3px] relative`,i?`border-primary ring-2 ring-primary/30 border-base-300`:`border-base-300`,Iy[e.state]||``,c?`animate-pulse-soft-border`:``,s?`animate-pulse-border`:``,l?`opacity-70`:``,d?`opacity-45`:``,f?`issue-card-blocked`:``,!l&&!d?`card-interactive`:``,`cursor-pointer`,r?`kanban-card-source-opacity`:``,b?`issue-card-done-flash`:``].filter(Boolean).join(` `),style:{overflow:`hidden`},role:`button`,tabIndex:0,onClick:D,onKeyDown:O,"aria-label":`${i?`Deselect`:`Open`} issue ${e.identifier}`,"aria-selected":i,...n||{},children:[C&&(0,K.jsx)(`div`,{"aria-hidden":`true`,className:`absolute right-0 bottom-0 select-none pointer-events-none font-black leading-none`,style:{fontSize:C.length<=2?`5rem`:C.length<=4?`3.75rem`:`2.75rem`,opacity:d?.12:l?.09:.055,lineHeight:.82,paddingRight:`2px`},children:C}),(i||o)&&(0,K.jsx)(`div`,{className:`absolute top-1.5 left-1.5 z-10`,children:(0,K.jsx)(`div`,{className:`size-5 rounded flex items-center justify-center transition-all ${i?`bg-primary text-primary-content`:`bg-base-300/60 border border-base-content/20`}`,children:i&&(0,K.jsx)(qr,{size:14})})}),(0,K.jsxs)(`div`,{className:`card-body gap-1 p-3 relative`,children:[(0,K.jsx)(`div`,{className:o?`pl-5`:``,children:(0,K.jsx)(Ky,{issue:e})}),(0,K.jsx)(`h3`,{className:[`font-semibold text-sm leading-snug`,d?`line-through opacity-40`:``].filter(Boolean).join(` `),children:e.title}),E.length>0&&(0,K.jsx)(`div`,{className:`flex items-center gap-2 text-[10px] opacity-35 truncate`,children:E.map(e=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 shrink-0`,children:[e.label&&(0,K.jsx)(`span`,{className:`opacity-50 uppercase tracking-wide`,style:{fontSize:`8px`},children:e.label}),(0,K.jsx)(`span`,{children:e.model}),e.effort&&(0,K.jsxs)(`span`,{className:`opacity-60`,children:[`·`,e.effort]})]},e.label??`single`))}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] opacity-40 mt-0.5`,children:[e.issueType&&Fy[e.issueType]&&(0,K.jsx)(`span`,{className:`badge badge-xs ${Fy[e.issueType]} badge-soft shrink-0`,children:e.issueType}),e.planVersion>1&&(0,K.jsxs)(`span`,{className:`badge badge-xs badge-info badge-soft shrink-0 font-mono`,children:[`v`,e.planVersion]}),w&&(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 ${v?`animate-count-bump`:``}`,children:[(0,K.jsx)(ui,{size:9}),w]}),T>0&&(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,K.jsx)(on,{size:9}),T]}),(0,K.jsx)(`span`,{className:`shrink-0`,children:ie(e.createdAt)}),h&&(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-error font-semibold ml-auto shrink-0 opacity-100`,children:[(0,K.jsx)(On,{size:10}),`merge failed`]}),g&&(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-warning font-semibold ml-auto shrink-0 opacity-100 animate-pulse`,children:[(0,K.jsx)($n,{size:10}),`ready to merge`]}),m&&(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-success font-semibold ml-auto shrink-0 opacity-100`,children:[(0,K.jsx)(Qn,{size:10}),`merged`]})]})]}),s&&(0,K.jsx)(`div`,{className:`issue-heartbeat-bar animate-pulse-soft`}),p&&(0,K.jsx)(`div`,{className:`h-[3px] rounded-b-[var(--rounded-box,1rem)] bg-info animate-pulse-soft`}),c&&!p&&!e.plan&&!e.planningError&&(0,K.jsx)(`div`,{className:`h-[2px] rounded-b-[var(--rounded-box,1rem)] bg-info/20 animate-pulse`}),h&&(0,K.jsx)(`div`,{className:`h-[3px] rounded-b-[var(--rounded-box,1rem)] bg-error animate-pulse`}),g&&(0,K.jsx)(`div`,{className:`h-[3px] rounded-b-[var(--rounded-box,1rem)] bg-warning animate-pulse-soft`}),m&&(0,K.jsx)(`div`,{className:`h-[3px] rounded-b-[var(--rounded-box,1rem)] bg-success`})]})}function Jy({icon:e=or,title:t=`Nothing here`,description:n=``,action:r,actionLabel:i=`Action`}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 px-4 opacity-60 animate-fade-in-up`,children:[(0,K.jsx)(e,{className:`size-12 mb-4 opacity-40`}),(0,K.jsx)(`h3`,{className:`text-base font-semibold mb-1`,children:t}),n&&(0,K.jsx)(`p`,{className:`text-sm opacity-70 text-center max-w-xs`,children:n}),r&&(0,K.jsx)(`button`,{className:`btn btn-sm btn-primary mt-4`,onClick:r,children:i})]})}var Yy={Planning:[`Planning`],"Needs Approval":[`PendingApproval`,`PendingDecision`],"In Progress":[`Queued`,`Running`,`Reviewing`],Blocked:[`Blocked`],Done:[`Approved`,`Merged`,`Cancelled`]},Xy=new Set([`Planning`]),Zy=new Set([`PendingApproval`,`PendingDecision`]),Qy=new Set([`Queued`,`Running`,`Reviewing`]),$y=new Set([`Approved`,`Merged`,`Cancelled`]);function eb(e){return Xy.has(e)?`Planning`:Zy.has(e)?`Needs Approval`:Qy.has(e)?`In Progress`:$y.has(e)?`Done`:e}function tb(e){let t=ne[e];if(!t)return new Set;let n=new Set(t.map(e=>eb(e)));return n.delete(eb(e)),n}var nb=300,rb=5;function ib({onStateChange:e}){let[t,n]=(0,G.useState)(null),r=(0,G.useRef)(null),i=(0,G.useRef)({pointerId:null,startX:0,startY:0,isDragging:!1,longPressTimer:null,longPressReady:!1,pointerType:null,issue:null,sourceColumn:null,didDrag:!1}),a=(0,G.useRef)(null),o=(0,G.useRef)(new Map);(0,G.useEffect)(()=>()=>{clearTimeout(i.current.longPressTimer)},[]);let s=(0,G.useCallback)((e,t)=>{let n=r.current;n&&(n.style.left=`${e}px`,n.style.top=`${t}px`)},[]),c=(0,G.useCallback)((e,t)=>{for(let[n,r]of o.current.entries()){let i=r.getBoundingClientRect();if(e>=i.left&&e<=i.right&&t>=i.top&&t<=i.bottom)return n}return null},[]),l=(0,G.useCallback)((e,t,r,a)=>{let o=tb(e.state);i.current.isDragging=!0,n({issueId:e.id,issue:e,sourceColumn:t,validColumns:o,overColumn:null}),s(r,a)},[s]),u=(0,G.useCallback)(()=>{let e=i.current.isDragging;clearTimeout(i.current.longPressTimer),i.current.isDragging=!1,i.current.longPressReady=!1,i.current.pointerId=null,i.current.issue=null,i.current.didDrag=e,e&&requestAnimationFrame(()=>{i.current.didDrag=!1}),n(null)},[]),d=(0,G.useCallback)(n=>{if(t){if(t.validColumns.has(n)){let r=ne[t.issue.state]||[],i=new Set(Yy[n]||[]),a=r.find(e=>i.has(e));a&&e(t.issueId,a)}u()}},[t,e,u]),f=(0,G.useCallback)((e,t)=>{t?o.current.set(e,t):o.current.delete(e)},[]);return{dragState:t,ghostRef:r,boardRef:a,getCardHandlers:(0,G.useCallback)((e,t)=>({onPointerDown:n=>{n.button===0&&(n.target.closest(`a, button`)||(i.current.pointerId=n.pointerId,i.current.startX=n.clientX,i.current.startY=n.clientY,i.current.pointerType=n.pointerType,i.current.issue=e,i.current.sourceColumn=t,i.current.longPressReady=!1,n.pointerType===`touch`&&(i.current.longPressTimer=setTimeout(()=>{i.current.longPressReady=!0,navigator.vibrate&&navigator.vibrate(30),l(e,t,n.clientX,n.clientY)},nb))))}}),[l]),registerColumn:f,onBoardPointerMove:(0,G.useCallback)(e=>{let t=i.current;if(t.pointerId==null||e.pointerId!==t.pointerId)return;let r=e.clientX-t.startX,a=e.clientY-t.startY,o=Math.sqrt(r*r+a*a);if(!t.isDragging)if(t.pointerType===`touch`){if(o>rb&&!t.longPressReady){clearTimeout(t.longPressTimer),t.pointerId=null;return}if(!t.longPressReady)return}else{if(o<rb)return;l(t.issue,t.sourceColumn,e.clientX,e.clientY)}e.preventDefault(),s(e.clientX,e.clientY);let u=c(e.clientX,e.clientY);n(e=>!e||e.overColumn===u?e:{...e,overColumn:u})},[l,s,c]),onBoardPointerUp:(0,G.useCallback)(e=>{let t=i.current;if(t.pointerId==null||e.pointerId!==t.pointerId)return;if(clearTimeout(t.longPressTimer),!t.isDragging){t.pointerId=null;return}let n=c(e.clientX,e.clientY);n?d(n):u()},[c,d,u]),onBoardPointerCancel:(0,G.useCallback)(()=>{u()},[u]),cancelDrag:u,shouldSuppressClick:(0,G.useCallback)(()=>i.current.didDrag||i.current.isDragging,[])}}function ab({count:e,className:t}){let n=(0,G.useRef)(e),[r,i]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{if(n.current!==e){n.current=e,i(!0);let t=setTimeout(()=>i(!1),300);return()=>clearTimeout(t)}},[e]),e===0?null:(0,K.jsx)(`span`,{className:`badge badge-xs ${t} ${r?`animate-count-bump`:``}`,children:e})}var ob=[`Planning`,`In Progress`,`Needs Approval`,`Blocked`,`Done`],sb=new Set([`Planning`]),cb=new Set([`PendingApproval`,`PendingDecision`]),lb=new Set([`Queued`,`Running`,`Reviewing`]),ub=new Set([`Archived`]),db={Planning:`badge-info`,"Needs Approval":`badge-warning`,"In Progress":`badge-primary`,Blocked:`badge-error`,Done:`badge-success`},fb={Planning:{borderTopColor:`color-mix(in oklab, var(--color-info) 40%, transparent)`},"Needs Approval":{borderTopColor:`color-mix(in oklab, var(--color-warning) 40%, transparent)`},"In Progress":{borderTopColor:`color-mix(in oklab, var(--color-primary) 50%, transparent)`},Blocked:{borderTopColor:`color-mix(in oklab, var(--color-error) 40%, transparent)`},Done:{borderTopColor:`color-mix(in oklab, var(--color-success) 40%, transparent)`}},pb={Planning:`var(--color-info)`,"Needs Approval":`var(--color-warning)`,"In Progress":`var(--color-primary)`,Blocked:`var(--color-error)`,Done:`var(--color-success)`},mb={Planning:`var(--color-info)`,"Needs Approval":`var(--color-warning)`,"In Progress":`var(--color-primary)`,Blocked:`var(--color-error)`,Done:`var(--color-success)`},hb={Planning:{icon:dr,desc:`Create an issue to start planning`},"Needs Approval":{icon:Vn,desc:`Issues waiting for your approval`},"In Progress":{icon:Or,desc:`Issues move here when agents start`},Blocked:{icon:ni,desc:`Needs attention`},Done:{icon:wn,desc:`Completed`}},gb={Planning:`AI is generating the execution plan.
45
+ States: Planning`,"Needs Approval":`Waiting for your decision — approve, rework, or replan.
46
+ States: PendingApproval, PendingDecision`,"In Progress":`AI agents are working — executing or reviewing code.
47
+ States: Queued, Running, Reviewing`,Blocked:`Failed or stale — needs retry or manual intervention.
48
+ States: Blocked`,Done:`Completed — ready to merge or already merged.
49
+ States: Approved, Merged, Cancelled`};function _b({delay:e=0}){return(0,K.jsx)(`div`,{className:`skeleton-card h-20 w-full rounded-lg`,style:{animationDelay:`${e}ms`}})}function vb({dragState:e,ghostRef:t}){if(!e)return null;let{issue:n}=e;return(0,K.jsx)(`div`,{ref:t,className:`drag-ghost`,"aria-hidden":`true`,children:(0,K.jsxs)(`div`,{className:`card card-compact bg-base-100 border border-primary border-l-[3px] shadow-2xl p-3 w-56`,children:[(0,K.jsx)(`span`,{className:`font-mono text-xs opacity-50`,children:n.identifier}),(0,K.jsx)(`h3`,{className:`font-semibold text-sm truncate`,children:n.title})]})})}function yb({onCreateIssue:e}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 px-3 animate-fade-in-up`,children:[(0,K.jsx)(`div`,{className:`bg-primary/10 rounded-full p-4 mb-3 animate-pulse-soft`,children:(0,K.jsx)(dr,{className:`size-8 text-primary`})}),(0,K.jsx)(`h3`,{className:`text-sm font-semibold mb-1`,children:`Start here`}),(0,K.jsx)(`p`,{className:`text-xs opacity-50 text-center mb-3`,children:`Create your first issue to begin`}),e&&(0,K.jsxs)(`button`,{className:`btn btn-primary btn-sm gap-1`,onClick:e,children:[(0,K.jsx)(kr,{className:`size-3.5`}),`New Issue`]})]})}function bb({issue:e,onClose:t,onStateChange:n,onSelect:r}){let i=V(e.state).filter(t=>t!==e.state);return(0,G.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/30 z-50 animate-fade-in`,onClick:t}),(0,K.jsxs)(`div`,{className:`fixed bottom-0 left-0 right-0 z-50 bg-base-100 rounded-t-2xl shadow-2xl animate-slide-up-sheet`,style:{paddingBottom:`env(safe-area-inset-bottom)`},onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`div`,{className:`flex justify-center pt-3 pb-1`,children:(0,K.jsx)(`div`,{className:`w-10 h-1 rounded-full bg-base-content/20`})}),(0,K.jsxs)(`div`,{className:`px-4 py-2 border-b border-base-300`,children:[(0,K.jsx)(`span`,{className:`font-mono text-xs opacity-50`,children:e.identifier}),(0,K.jsx)(`h3`,{className:`font-semibold text-sm truncate`,children:e.title})]}),(0,K.jsxs)(`div`,{className:`p-3 space-y-1`,children:[(0,K.jsxs)(`button`,{className:`btn btn-ghost btn-sm w-full justify-start gap-2`,onClick:()=>{r(e),t()},children:[(0,K.jsx)(Vn,{className:`size-4`}),` View Details`]}),i.length>0&&(0,K.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide opacity-40 px-3 pt-2`,children:`Move to`}),i.map(r=>(0,K.jsxs)(`button`,{className:`btn btn-ghost btn-sm w-full justify-start gap-2`,onClick:()=>{n(e.id,r),t()},children:[(0,K.jsx)(ln,{className:`size-4`}),` `,r]},r))]}),(0,K.jsx)(`div`,{className:`p-3 pt-0`,children:(0,K.jsx)(`button`,{className:`btn btn-ghost btn-sm w-full`,onClick:t,children:`Cancel`})})]})]})}function xb({columns:e,activeIndex:t}){return(0,K.jsx)(`div`,{className:`kanban-dots md:hidden`,children:e.map((e,n)=>(0,K.jsx)(`div`,{className:`kanban-dot ${n===t?`active`:``}`,style:{backgroundColor:mb[e]}},e))})}function Sb({col:e,issues:t,empty:n,badgeClass:r,dragState:i,registerColumn:a,getCardHandlers:o,onSelect:s,onCreateIssue:c,lastDroppedId:l,hasRunningAgents:u,totalIssues:d,onLongPress:f,selectedIds:p,onToggleSelect:m,hasSelection:h,focusedIssueId:g}){let _=(0,G.useRef)(null);(0,G.useEffect)(()=>(a(e,_.current),()=>a(e,null)),[e,a]);let v=i!=null,y=i?.overColumn===e,b=i?.sourceColumn===e,x=i?.validColumns?.has(e)??!1,S=v&&!x&&!b,C=t.length===0,w=C&&e!==`Planning`&&d===0,T=t,E=`kanban-column bg-base-200 rounded-box p-3 flex flex-col min-h-0 overflow-hidden`;w&&(E+=` kanban-column-collapsed`),v&&(y&&x?E+=` kanban-column-drop-valid`:y&&!x?E+=` kanban-column-drop-invalid`:S&&(E+=` kanban-column-dimmed`));let D={borderTop:`3px solid transparent`,...fb[e]||{},...w?{alignSelf:`start`}:{}};return(0,K.jsxs)(`div`,{ref:_,className:E,style:D,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsxs)(`h3`,{className:`text-xs font-semibold tracking-wide flex items-center gap-1.5`,style:{color:pb[e],fontFamily:`'Space Grotesk', system-ui, sans-serif`},children:[e,e===`In Progress`&&u&&(0,K.jsx)(`span`,{className:`issue-phase-dot`,title:`Agents working`}),gb[e]&&(0,K.jsx)(`div`,{className:`lg:tooltip lg:tooltip-bottom`,"data-tip":gb[e],children:(0,K.jsx)(sr,{className:`size-3 opacity-30 hover:opacity-60 transition-opacity cursor-help`})})]}),(0,K.jsx)(ab,{count:t.length,className:r})]}),!w&&(0,K.jsx)(`div`,{className:`space-y-2 flex-1 overflow-y-auto kanban-card-list`,children:C?y&&x?(0,K.jsx)(`div`,{className:`kanban-drop-placeholder`}):e===`Planning`&&d===0?(0,K.jsx)(yb,{onCreateIssue:c}):(0,K.jsxs)(`div`,{className:`flex flex-col items-center py-6 opacity-30`,children:[(0,K.jsx)(n.icon,{className:`size-5 mb-1`}),(0,K.jsx)(`span`,{className:`text-[10px]`,children:n.desc})]}):(0,K.jsxs)(`div`,{className:`stagger-children space-y-2`,children:[e===`Done`?(0,K.jsx)(K.Fragment,{children:(()=>{let t=T.filter(e=>e.state===`Approved`),n=T.filter(e=>e.state===`Merged`),r=T.filter(e=>e.state===`Cancelled`),a=t=>{let n=i?.issueId===t.id,r=l===t.id,a=g===t.id;return(0,K.jsx)(`div`,{"data-issue-id":t.id,className:`${n?`kanban-card-dragging-source`:``} ${r?`animate-pop`:``} ${a?`ring-2 ring-primary/50 rounded-lg`:``}`,onContextMenu:e=>{`ontouchstart`in window&&(e.preventDefault(),f?.(t))},children:(0,K.jsx)(qy,{issue:t,onSelect:s,dragHandlers:o(t,e),isDragging:n,isSelected:p?.has(t.id),onToggleSelect:m,hasSelection:h})},t.id)};return(0,K.jsxs)(K.Fragment,{children:[t.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider opacity-40 font-semibold px-1`,children:`Ready to Ship`}),t.map(a)]}),n.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider opacity-40 font-semibold px-1 mt-2`,children:`Shipped`}),n.map(e=>(0,K.jsx)(`div`,{className:`opacity-60`,children:a(e)},e.id))]}),r.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider opacity-40 font-semibold px-1 mt-2`,children:`Cancelled`}),r.map(e=>(0,K.jsx)(`div`,{className:`opacity-40`,children:a(e)},e.id))]})]})})()}):T.map(t=>{let n=i?.issueId===t.id,r=l===t.id,a=g===t.id;return(0,K.jsx)(`div`,{"data-issue-id":t.id,className:`${n?`kanban-card-dragging-source`:``} ${r?`animate-pop`:``} ${a?`ring-2 ring-primary/50 rounded-lg`:``}`,onContextMenu:e=>{`ontouchstart`in window&&(e.preventDefault(),f?.(t))},children:(0,K.jsx)(qy,{issue:t,onSelect:s,dragHandlers:o(t,e),isDragging:n,isSelected:p?.has(t.id),onToggleSelect:m,hasSelection:h})},t.id)}),y&&x&&(0,K.jsx)(`div`,{className:`kanban-drop-placeholder`})]})})]},e)}function Cb(e,t){let n=t.filter(t=>e.has(t.id));if(n.length===0)return[];let r=n.map(e=>{let t=V(e.state);return new Set(t.filter(t=>t!==e.state))});return[...r[0]].filter(e=>r.every(t=>t.has(e)))}function wb({count:e,transitions:t,onBulkAction:n,onClear:r}){return(0,K.jsxs)(`div`,{className:`fixed bottom-4 left-1/2 -translate-x-1/2 z-40 bg-base-100 border border-base-300 rounded-box shadow-2xl px-4 py-2.5 flex items-center gap-3 animate-slide-up-sheet`,role:`toolbar`,"aria-label":`Bulk actions`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:t.map(e=>(0,K.jsxs)(`button`,{className:`btn btn-sm btn-outline gap-1`,onClick:()=>n(e),children:[(0,K.jsx)(ln,{className:`size-3`}),e]},e))}),(0,K.jsx)(`div`,{className:`divider divider-horizontal mx-0`}),(0,K.jsxs)(`span`,{className:`text-sm font-medium whitespace-nowrap opacity-70`,children:[e,` selected`]}),(0,K.jsx)(`button`,{className:`btn btn-sm btn-ghost btn-square`,onClick:r,"aria-label":`Clear selection`,children:(0,K.jsx)(li,{className:`size-4`})})]})}function Tb({issues:e,onStateChange:t,onRetry:n,onCancel:r,onSelect:i,onCreateIssue:a,isLoading:o}){let[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(0),[d,f]=(0,G.useState)(null),[p,m]=(0,G.useState)(()=>new Set),h=(0,G.useRef)(null),[g,_]=(0,G.useState)(-1),[v,y]=(0,G.useState)(-1),b=p.size>0,x=(0,G.useCallback)(e=>{m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),S=(0,G.useCallback)(()=>{m(new Set)},[]);(0,G.useEffect)(()=>{if(!b)return;let t=new Set(e.map(e=>e.id));m(e=>{let n=new Set([...e].filter(e=>t.has(e)));return n.size===e.size?e:n})},[e,b]);let C=(0,G.useMemo)(()=>Cb(p,e),[p,e]),w=(0,G.useCallback)(e=>{for(let n of p)t(n,e);S()},[p,t,S]),T=(0,G.useMemo)(()=>{let t=Object.fromEntries(ob.map(e=>[e,[]]));for(let n of e){if(!n?.identifier||ub.has(n.state))continue;let e;e=sb.has(n.state)?`Planning`:cb.has(n.state)?`Needs Approval`:lb.has(n.state)?`In Progress`:n.state===`Blocked`?`Blocked`:`Done`,t[e].push(n)}for(let e of ob)t[e].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime());return t},[e]),E=(0,G.useMemo)(()=>e.some(e=>e.state===`Running`),[e]),D=(0,G.useCallback)((e,n)=>{c(e);let r=setTimeout(()=>c(null),400);return t(e,n),()=>clearTimeout(r)},[t]),{dragState:O,ghostRef:k,getCardHandlers:A,registerColumn:j,onBoardPointerMove:M,onBoardPointerUp:N,onBoardPointerCancel:P,shouldSuppressClick:F}=ib({onStateChange:D}),I=(0,G.useCallback)(e=>{F()||i?.(e)},[i,F]);(0,G.useEffect)(()=>{let e=h.current;if(!e)return;let t=e.querySelector(`.grid, [class*='grid']`);if(!t)return;let n=()=>{let n=t.children;if(!n.length)return;let r=e.scrollLeft,i=e.clientWidth,a=0,o=1/0;for(let e=0;e<n.length;e++){let t=n[e],s=t.offsetLeft+t.offsetWidth/2,c=r+i/2,l=Math.abs(s-c);l<o&&(o=l,a=e)}u(a)};return e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},[]),(0,G.useRef)(null);let L=(0,G.useCallback)(e=>{f(e)},[]),{selectedIssue:R}=tn(),z=!R,B=(0,G.useRef)(T);B.current=T;let V=(0,G.useCallback)(e=>{_(e),y(0);let t=h.current;t&&(t.querySelector(`[class*='grid']`)?.children[e])?.scrollIntoView({behavior:`smooth`,inline:`center`,block:`nearest`})},[]),ee=(0,G.useCallback)(e=>{if(g<0){_(0),y(0);return}let t=ob[g],n=B.current[t]||[];y(t=>Math.max(0,Math.min(t+e,n.length-1)))},[g]),te=(0,G.useCallback)(()=>{if(g<0||v<0)return;let e=B.current[ob[g]]||[];e[v]&&i?.(e[v])},[g,v,i]);return J(`1`,()=>V(0),{enabled:z,description:`Planning column`,metadata:{group:`kanban`}},[V,z]),J(`2`,()=>V(1),{enabled:z,description:`In Progress column`,metadata:{group:`kanban`}},[V,z]),J(`3`,()=>V(2),{enabled:z,description:`Needs Approval column`,metadata:{group:`kanban`}},[V,z]),J(`4`,()=>V(3),{enabled:z,description:`Blocked column`,metadata:{group:`kanban`}},[V,z]),J(`5`,()=>V(4),{enabled:z,description:`Done column`,metadata:{group:`kanban`}},[V,z]),J(`j`,()=>ee(1),{enabled:z,description:`Next card`,metadata:{group:`kanban`}},[ee,z]),J(`k`,()=>ee(-1),{enabled:z,description:`Previous card`,metadata:{group:`kanban`}},[ee,z]),J(`enter`,te,{enabled:z&&v>=0,description:`Open card`,metadata:{group:`kanban`}},[te,z,v]),J(`escape`,()=>{b?S():(_(-1),y(-1))},{enabled:(b||g>=0)&&z,description:`Clear selection / focus`,metadata:{group:`kanban`}},[b,S,g,z]),(0,G.useEffect)(()=>{if(g<0||v<0)return;let e=h.current;e&&(e.querySelector(`[class*='grid']`)?.children[g]?.querySelectorAll(`[data-issue-id]`))?.[v]?.scrollIntoView({behavior:`smooth`,block:`nearest`})},[g,v]),o?(0,K.jsx)(`div`,{className:`overflow-x-auto pb-2 flex-1 flex flex-col min-h-0`,children:(0,K.jsx)(`div`,{className:`grid gap-3 flex-1 stagger-children`,style:{gridTemplateColumns:`repeat(${ob.length}, minmax(0, 1fr))`,minWidth:`${ob.length*200}px`},children:ob.map((e,t)=>(0,K.jsxs)(`div`,{className:`bg-base-200 rounded-box p-3 flex flex-col gap-2`,children:[(0,K.jsx)(`div`,{className:`skeleton-line h-4 w-20 mb-2`}),(0,K.jsx)(_b,{delay:t*80}),(0,K.jsx)(_b,{delay:t*80+120}),t<2&&(0,K.jsx)(_b,{delay:t*80+240})]},e))})}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{ref:h,className:`overflow-x-auto pb-2 flex-1 flex flex-col min-h-0`,onPointerMove:M,onPointerUp:N,onPointerCancel:P,style:{touchAction:O?`none`:void 0},children:[(0,K.jsx)(`div`,{className:`grid gap-3 flex-1 stagger-children ${O?`kanban-dragging`:``}`,style:{gridTemplateColumns:`repeat(${ob.length}, minmax(0, 1fr))`,minWidth:`${ob.length*200}px`},children:ob.map((t,n)=>{let r=T[t],i=g===n&&v>=0&&v<r.length?r[v]?.id:null;return(0,K.jsx)(Sb,{col:t,issues:r,empty:hb[t],badgeClass:db[t],dragState:O,registerColumn:j,getCardHandlers:A,onSelect:I,onCreateIssue:a,lastDroppedId:s,hasRunningAgents:E,totalIssues:e.length,onLongPress:L,selectedIds:p,onToggleSelect:x,hasSelection:b,focusedIssueId:i},t)})}),(0,K.jsx)(vb,{dragState:O,ghostRef:k})]}),(0,K.jsx)(xb,{columns:ob,activeIndex:l}),d&&(0,K.jsx)(bb,{issue:d,onClose:()=>f(null),onStateChange:D,onSelect:I}),b&&(0,K.jsx)(wb,{count:p.size,transitions:C,onBulkAction:w,onClear:S})]})}function Eb(e){return!e||e===0?`0`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function Db({value:e,format:t=Eb,className:n=``}){let[r,i]=(0,G.useState)(()=>t(e)),a=(0,G.useRef)(e),o=(0,G.useRef)(null);return(0,G.useEffect)(()=>{let n=a.current||0,r=e||0;if(a.current=r,n===r){i(t(r));return}let s=performance.now(),c=e=>{let a=e-s,l=Math.min(a/600,1),u=1-(1-l)**3;i(t(Math.round(n+(r-n)*u))),l<1&&(o.current=requestAnimationFrame(c))};return cancelAnimationFrame(o.current),o.current=requestAnimationFrame(c),()=>cancelAnimationFrame(o.current)},[e,t]),(0,K.jsx)(`span`,{className:`${n} inline-block tabular-nums`,children:r})}function Ob({data:e,height:t=28,cols:n=14,valueKey:r=`totalTokens`,colorClass:i=`text-primary`,showValue:a=!1,className:o=``}){if(!e||e.length===0)return null;let s=e.slice(-n),c=new Date().toISOString().slice(0,10),l=Math.max(...s.map(e=>e[r]||0),1),u=s.length,d=1.5,f=Math.max(2,(100-d*(u-1))/u);return(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 ${o}`,children:[(0,K.jsx)(`svg`,{viewBox:`0 0 100 ${t}`,className:`flex-1`,style:{height:t},preserveAspectRatio:`none`,children:s.map((e,n)=>{let a=e[r]||0,o=Math.max(1.5,a/l*(t-1)),s=n*(f+d),u=e.date===c,p=e.date?new Date(e.date+`T12:00:00`).toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`}):`Day ${n+1}`;return(0,K.jsx)(`rect`,{x:s,y:t-o,width:f,height:o,rx:`0.5`,fill:`currentColor`,className:i,opacity:u?.85:a>0?.4:.12,children:(0,K.jsx)(`title`,{children:`${p}: ${a>999?Eb(a):a}`})},e.date||n)})}),a&&(0,K.jsxs)(`span`,{className:`text-[9px] font-mono opacity-50 shrink-0`,children:[Eb(s[s.length-1]?.[r]||0),`/d`]})]})}function kb({data:e,height:t=28,cols:n=14,className:r=``}){if(!e||e.length===0)return null;let i=e.slice(-n),a=new Date().toISOString().slice(0,10),o=Math.max(...i.map(e=>(e.linesAdded||0)+(e.linesRemoved||0)),1),s=i.length,c=1.5,l=Math.max(2,(100-c*(s-1))/s);return(0,K.jsx)(`div`,{className:`flex items-center gap-1.5 ${r}`,children:(0,K.jsx)(`svg`,{viewBox:`0 0 100 ${t}`,className:`flex-1`,style:{height:t},preserveAspectRatio:`none`,children:i.map((e,n)=>{let r=e.linesAdded||0,i=e.linesRemoved||0,s=r+i,u=Math.max(s>0?1.5:0,s/o*(t-1)),d=s>0?r/s*u:0,f=u-d,p=n*(l+c),m=e.date===a?.85:s>0?.5:.12,h=e.date?new Date(e.date+`T12:00:00`).toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`}):`Day ${n+1}`;return(0,K.jsxs)(`g`,{children:[f>0&&(0,K.jsx)(`rect`,{x:p,y:t-f,width:l,height:f,rx:`0.5`,className:`fill-error`,opacity:m,children:(0,K.jsx)(`title`,{children:`${h}: +${r} / -${i}`})}),d>0&&(0,K.jsx)(`rect`,{x:p,y:t-u,width:l,height:d,rx:`0.5`,className:`fill-success`,opacity:m,children:(0,K.jsx)(`title`,{children:`${h}: +${r} / -${i}`})})]},e.date||n)})})})}function Ab(){let[e,t]=(0,G.useState)(()=>window.innerWidth<768);return(0,G.useEffect)(()=>{let e=window.matchMedia(`(max-width: 767px)`),n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function jb({monthlyTokens:e,monthlyEvents:t,dailyData:n,hasDailyData:r,hasEventData:i,linesDaily:a,hasChurnData:o}){let[s,c]=(0,G.useState)(!1);return(0,K.jsxs)(`div`,{className:`bg-base-200 rounded-box animate-fade-in overflow-hidden`,children:[(0,K.jsxs)(`button`,{className:`flex items-center justify-between w-full px-4 py-2.5 text-left`,onClick:()=>c(!s),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`span`,{className:`text-base font-bold font-mono leading-tight flex items-center gap-1.5`,children:[(0,K.jsx)(ui,{className:`size-3.5 text-primary`}),(0,K.jsx)(Db,{value:e}),(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide opacity-40 font-normal ml-1`,children:`this month`})]}),t>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-xs opacity-50`,children:[(0,K.jsx)(on,{className:`size-3`}),t]})]}),(0,K.jsx)(bn,{className:`size-4 opacity-40 transition-transform ${s?`rotate-180`:``}`})]}),s&&(0,K.jsxs)(`div`,{className:`px-4 pb-3 space-y-3 animate-fade-in border-t border-base-300 pt-3`,children:[r&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wide opacity-40 mb-1 flex items-center gap-1`,children:[(0,K.jsx)(ti,{className:`size-2.5`}),` Tokens / day`]}),(0,K.jsx)(Ob,{data:n,height:32,cols:14,valueKey:`totalTokens`,colorClass:`text-primary`,className:`w-full`})]}),i&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wide opacity-40 mb-1 flex items-center gap-1`,children:[(0,K.jsx)(on,{className:`size-2.5`}),` Events / day`]}),(0,K.jsx)(Ob,{data:n,height:24,cols:14,valueKey:`events`,colorClass:`text-secondary`,className:`w-full`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wide opacity-40 mb-1 flex items-center gap-1`,children:[(0,K.jsx)(Qn,{className:`size-2.5`}),` Lines / day`]}),(0,K.jsx)(kb,{data:a,height:24,cols:14,className:`w-full`})]})]})]})}function Mb({issues:e=[],defaultBranch:t}){let{data:n}=st(),{data:r}=ct({pollInterval:6e4}),i=Ab(),a=B(n?.daily,14),o=new Date().toISOString().slice(0,7),s=a.filter(e=>e.date?.startsWith(o)).reduce((e,t)=>e+(t.totalTokens||0),0),c=a.filter(e=>e.date?.startsWith(o)).reduce((e,t)=>e+(t.events||0),0),l=(()=>{let e=new Map((r?.lines||[]).filter(e=>e.date).map(e=>[e.date,e])),t=[];for(let n=13;n>=0;n--){let r=new Date;r.setDate(r.getDate()-n);let i=r.toISOString().slice(0,10);t.push(e.get(i)??{date:i,linesAdded:0,linesRemoved:0,filesChanged:0})}return t})(),u=a.some(e=>(e.totalTokens||0)>0),d=a.some(e=>(e.events||0)>0),f=l.some(e=>(e.linesAdded||0)>0||(e.linesRemoved||0)>0),p=s>0||u||d,m=(0,G.useRef)(p),[h,g]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{!m.current&&p&&(m.current=!0,g(!0))},[p]),p?i?(0,K.jsx)(jb,{monthlyTokens:s,monthlyEvents:c,dailyData:a,hasDailyData:u,hasEventData:d,linesDaily:l,hasChurnData:f}):(0,K.jsxs)(`div`,{className:`flex items-stretch gap-0 bg-base-200 rounded-box overflow-hidden ${h?`animate-fade-in-up`:`animate-fade-in`}`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col justify-center px-4 py-2.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide opacity-40`,children:`Tokens / month`}),(0,K.jsxs)(`span`,{className:`text-base font-bold font-mono leading-tight flex items-center gap-1.5 mt-0.5`,children:[(0,K.jsx)(ui,{className:`size-3.5 text-primary shrink-0`}),(0,K.jsx)(Db,{value:s})]})]}),u&&(0,K.jsxs)(`div`,{className:`flex flex-col justify-center py-2 px-3 border-l border-base-300 min-w-[120px]`,children:[(0,K.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wide opacity-40 mb-1 flex items-center gap-1`,children:[(0,K.jsx)(ti,{className:`size-2.5`}),` Tokens / day`]}),(0,K.jsx)(Ob,{data:a,height:28,cols:14,valueKey:`totalTokens`,colorClass:`text-primary`})]}),d&&(0,K.jsxs)(`div`,{className:`flex flex-col justify-center py-2 px-3 border-l border-base-300 min-w-[120px]`,children:[(0,K.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wide opacity-40 mb-1 flex items-center gap-1`,children:[(0,K.jsx)(on,{className:`size-2.5`}),` Events / day`]}),(0,K.jsx)(Ob,{data:a,height:28,cols:14,valueKey:`events`,colorClass:`text-secondary`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col justify-center py-2 px-3 border-l border-base-300 min-w-[120px]`,children:[(0,K.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wide opacity-40 mb-1 flex items-center gap-1`,children:[(0,K.jsx)(Qn,{className:`size-2.5`}),` Lines / day`]}),(0,K.jsx)(kb,{data:l,height:28,cols:14})]}),t&&(0,K.jsxs)(`div`,{className:`flex flex-col justify-center px-3 border-l border-base-300`,children:[(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide opacity-40`,children:`Branch`}),(0,K.jsxs)(`span`,{className:`text-xs font-mono font-medium flex items-center gap-1 mt-0.5`,children:[(0,K.jsx)(Zn,{className:`size-3 text-primary shrink-0`}),t]})]})]}):null}var Nb=v(`/kanban`)({component:Pb});function Pb(){let e=tn(),{data:t}=st();return(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 px-3 pb-2 gap-2`,children:[((t?.overall?.totalTokens||0)>0||e.issues.length>0)&&(0,K.jsx)(Mb,{metrics:e.metrics,total:e.issues.length,issues:e.issues,compact:!0,defaultBranch:e.data?.config?.defaultBranch}),(0,K.jsx)(Tb,{issues:e.filtered,onStateChange:e.updateState,onRetry:e.retryIssue,onCancel:e.cancelIssue,onSelect:e.setSelectedIssue,onCreateIssue:()=>e.setIsCreateOpen(!0)})]})}function Fb(e){let{state:t,planningStatus:n,assignedToWorker:r,startedAt:i,tokenUsage:a,tokensByPhase:o}=e;switch(t){case`Planning`:return n===`planning`?{label:`Generating plan...`,icon:gr,color:`text-info`,spin:!0}:e.plan?{label:`Plan ready`,icon:dr,color:`text-info`,spin:!1}:e.planningError?{label:`Plan failed`,icon:ni,color:`text-error`,spin:!1}:{label:`Aguardando scheduler…`,icon:jn,color:`text-info/60`,spin:!1};case`PendingApproval`:return{label:`Ready to queue`,icon:pr,color:`text-warning/70`,spin:!1};case`Queued`:return r?{label:`Worker assigned, starting...`,icon:Or,color:`text-primary`,spin:!1,pulse:!0}:{label:`Waiting for worker slot...`,icon:jn,color:`text-info/70`,spin:!1};case`Running`:{let e=Ib(o),t=a?.totalTokens>0;return!t&&!i?{label:`Spawning agent...`,icon:gr,color:`text-primary`,spin:!0}:t?e===`Reviewing`?{label:`Agent reviewing...`,icon:Vn,color:`text-secondary`,spin:!1,pulse:!0}:e===`Planning`?{label:`Agent planning...`,icon:dr,color:`text-info`,spin:!1,pulse:!0}:{label:`Agent working...`,icon:Or,color:`text-primary`,spin:!1,pulse:!0}:{label:`Starting agent...`,icon:gr,color:`text-primary`,spin:!0}}case`Reviewing`:return Ib(o)===`Reviewing`?{label:`Review in progress...`,icon:Vn,color:`text-secondary`,spin:!1,pulse:!0}:{label:`Reviewing`,icon:Vn,color:`text-secondary/70`,spin:!1};case`PendingDecision`:return{label:`Review complete`,icon:Vn,color:`text-success/70`,spin:!1};case`Blocked`:return{label:e.lastError?`Blocked: error`:e.blockedBy?.length?`Blocked by dependency`:`Needs attention`,icon:ni,color:`text-error`,spin:!1};case`Approved`:return{label:`Approved`,icon:Tn,color:`text-success`,spin:!1};case`Merged`:return{label:`Merged`,icon:Qn,color:`text-success`,spin:!1};case`Cancelled`:return{label:`Cancelled`,icon:On,color:`text-neutral`,spin:!1};default:return{label:t,icon:null,color:`opacity-50`,spin:!1}}}function Ib(e){return e?e.reviewer?.totalTokens>0?`Reviewing`:e.executor?.totalTokens>0?`Executing`:e.planner?.totalTokens>0?`Planning`:null:null}function Lb({issue:e,showElapsed:t=!0,compact:n=!1}){let r=Fb(e),i=r.icon,a=Ny([`Running`,`Queued`,`Planning`,`Reviewing`].includes(e.state)&&t?e.startedAt:null);return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs ${r.color} ${n?``:`font-medium`}`,children:[i&&(0,K.jsx)(i,{size:n?10:12,className:[r.spin?`animate-spin`:``,r.pulse?`status-indicator-pulse`:``].filter(Boolean).join(` `)}),(0,K.jsx)(`span`,{className:n?`truncate max-w-[120px]`:`truncate`,children:r.label}),a&&(0,K.jsx)(`span`,{className:`font-mono opacity-60 tabular-nums shrink-0`,children:a})]})}var Rb={Planning:`badge-info`,PendingApproval:`badge-warning`,Queued:`badge-info`,Running:`badge-primary`,Reviewing:`badge-secondary`,PendingDecision:`badge-success`,Blocked:`badge-error`,Approved:`badge-success`,Merged:`badge-success`,Cancelled:`badge-neutral`},zb={Planning:`border-l-info`,PendingApproval:`border-l-warning`,Queued:`border-l-info`,Running:`border-l-primary`,Reviewing:`border-l-secondary`,PendingDecision:`border-l-success`,Blocked:`border-l-error`,Approved:`border-l-success`,Merged:`border-l-success`,Cancelled:`border-l-neutral`};function Bb(e){return!e||e===0?null:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function Vb({icon:e,label:t,value:n,color:r=``}){return!n&&n!==0?null:(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[10px]`,title:t,children:[(0,K.jsx)(e,{className:`size-2.5 ${r||`opacity-40`}`}),(0,K.jsx)(`span`,{className:`font-mono opacity-70`,children:n})]})}function Hb(e){let t=e.createdAt?new Date(e.createdAt).getTime():0,n=e.startedAt?new Date(e.startedAt).getTime():0,r=e.completedAt?new Date(e.completedAt).getTime():0,i=Date.now();return{leadTimeMs:r?r-t:n?i-t:0,cycleTimeMs:r&&n?r-n:n?i-n:0,waitTimeMs:n?n-t:t?i-t:0}}function Ub({issue:e,onSelect:t}){let n=e.state===`Running`,r=Bb(e.tokenUsage?.totalTokens),i=e.description||``,{leadTimeMs:a,cycleTimeMs:o,waitTimeMs:s}=Hb(e);return e.state===`Approved`||e.state,(0,K.jsx)(`div`,{className:`card bg-base-100 border border-base-300 border-l-[3px] ${zb[e.state]||``} card-interactive cursor-pointer hover:shadow-lg transition-all ${n?`animate-pulse-border`:``}`,role:`button`,tabIndex:0,onClick:()=>t?.(e),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t?.(e))},children:(0,K.jsxs)(`div`,{className:`card-body gap-3 p-4 justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`font-mono text-xs opacity-50`,children:e.identifier}),(0,K.jsx)(`span`,{className:`badge badge-xs ${Rb[e.state]||`badge-ghost`}`,children:e.state})]}),(0,K.jsx)(`span`,{className:`text-xs opacity-40 shrink-0`,children:ie(e.updatedAt)})]}),(0,K.jsx)(`h3`,{className:`font-semibold text-sm leading-snug line-clamp-2`,children:e.title}),i&&(0,K.jsx)(`p`,{className:`text-xs opacity-50 leading-relaxed line-clamp-2 mt-1`,children:i})]}),[`Planning`,`PendingApproval`,`Queued`,`Running`,`Reviewing`,`PendingDecision`,`Blocked`].includes(e.state)&&(0,K.jsx)(`div`,{className:`pt-1`,children:(0,K.jsx)(Lb,{issue:e,showElapsed:!0})}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pt-2 border-t border-base-200`,children:[(0,K.jsx)(Vb,{icon:ir,label:`Wait`,value:s>0?re(s):null}),(0,K.jsx)(Vb,{icon:$r,label:`Cycle`,value:o>0?re(o):null,color:`text-primary`}),(0,K.jsx)(Vb,{icon:jn,label:`Lead`,value:a>0?re(a):null}),(0,K.jsx)(Vb,{icon:ui,label:`Tokens`,value:r,color:`text-warning`}),(0,K.jsx)(Vb,{icon:Nn,label:`Cost`,value:e.tokenUsage?.costUsd?`$${e.tokenUsage.costUsd.toFixed(2)}`:null,color:`text-secondary`}),(0,K.jsx)(Vb,{icon:Pr,label:`Attempts`,value:e.attempts>0?`${e.attempts}/${e.maxAttempts}`:null}),(0,K.jsx)(Vb,{icon:Hn,label:`Files`,value:e.filesChanged||null,color:`text-info`}),e.linesAdded?(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-success`,children:[`+`,e.linesAdded]}):null,e.linesRemoved?(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-error`,children:[`-`,e.linesRemoved]}):null]})]})})}function Wb({issues:e,onStateChange:t,onRetry:n,onCancel:r,onSelect:i,expanded:a=!1,focusedIndex:o=-1}){return e.length===0?(0,K.jsx)(Jy,{icon:fr,title:`No issues found`,description:`Try adjusting your search or filters, or create your first issue to get started.`}):a?(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3 stagger-children`,children:e.map((e,t)=>(0,K.jsx)(`div`,{className:t===o?`ring-2 ring-primary/50 rounded-2xl`:``,children:(0,K.jsx)(Ub,{issue:e,onSelect:i})},e.id))}):(0,K.jsx)(`div`,{className:`space-y-2 stagger-children`,children:e.map((e,t)=>(0,K.jsx)(`div`,{className:t===o?`ring-2 ring-primary/50 rounded-lg`:``,children:(0,K.jsx)(qy,{issue:e,onSelect:i})},e.id))})}var Gb=[{label:`Active`,states:[`Planning`,`PendingApproval`,`Queued`,`Running`]},{label:`Review`,states:[`Reviewing`,`PendingDecision`]},{label:`Waiting`,states:[`Blocked`,`Approved`]},{label:`Final`,states:[`Merged`,`Cancelled`]}];Gb.flatMap(e=>e.states);var Kb=[{value:`bug`,label:`Bug`,color:`badge-error`},{value:`feature`,label:`Feature`,color:`badge-primary`},{value:`refactor`,label:`Refactor`,color:`badge-warning`},{value:`docs`,label:`Docs`,color:`badge-info`},{value:`chore`,label:`Chore`,color:`badge-secondary`}],qb={Planning:`badge-info`,PendingApproval:`badge-warning`,Queued:`badge-info`,Running:`badge-primary`,Reviewing:`badge-secondary`,PendingDecision:`badge-success`,Blocked:`badge-error`,Approved:`badge-success`,Merged:`badge-success`,Cancelled:`badge-neutral`},Jb=[{value:`updated`,label:`Last updated`},{value:`created`,label:`Newest first`},{value:`state`,label:`State`},{value:`tokens`,label:`Most tokens`}],Yb=[{value:`recent`,label:`Active + recent`},{value:`all`,label:`All issues`}],Xb=v(`/issues`)({component:Zb});function Zb(){let e=tn(),[t,n]=(0,G.useState)(!1),[r,i]=(0,G.useState)(`updated`),[a,o]=(0,G.useState)(-1),s=(0,G.useRef)(null),[c,l]=(0,G.useState)(new Set),[u,d]=(0,G.useState)(new Set),f=e=>{d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},p=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},m=e=>{l(t=>{let n=new Set(t);if(e.every(e=>n.has(e)))for(let t of e)n.delete(t);else for(let t of e)n.add(t);return n})},h=c.size>0||u.size>0||e.completionFilter!==`recent`||e.query.length>0,g=(e.data._totalIssues??0)-(e.issues.length??0),_={};for(let t of e.issues)_[t.state]=(_[t.state]||0)+1;let v=(0,G.useMemo)(()=>{let t=e.query.toLowerCase();return e.issues.filter(e=>!(e.state===`Archived`||c.size>0&&!c.has(e.state)||u.size>0&&!u.has(e.issueType||``)||t&&!`${e.identifier} ${e.title} ${e.description||``} ${e.issueType||``}`.toLowerCase().includes(t)))},[e.issues,c,u,e.query]),y=(0,G.useMemo)(()=>[...v].sort((e,t)=>{switch(r){case`created`:return(t.createdAt||``).localeCompare(e.createdAt||``);case`state`:return(e.state||``).localeCompare(t.state||``);case`tokens`:return(t.tokenUsage?.totalTokens||0)-(e.tokenUsage?.totalTokens||0);default:return(t.updatedAt||t.createdAt||``).localeCompare(e.updatedAt||e.createdAt||``)}}),[v,r]),b=()=>{e.setQuery(``),l(new Set),d(new Set),e.setCompletionFilter(`recent`),i(`updated`)},x=!e.selectedIssue,S=(0,G.useRef)(y);S.current=y,J(`slash`,()=>s.current?.focus(),{enabled:x,preventDefault:!0,description:`Focus search`,metadata:{group:`issues`}},[x]),J(`j`,()=>o(e=>{let t=S.current.length;return t===0?-1:Math.min(e+1,t-1)}),{enabled:x,description:`Next issue`,metadata:{group:`issues`}},[x]),J(`k`,()=>o(e=>Math.max(e<=0?0:e-1,0)),{enabled:x,description:`Previous issue`,metadata:{group:`issues`}},[x]),J(`enter`,()=>{let t=S.current[a];t&&e.setSelectedIssue(t)},{enabled:x&&a>=0,description:`Open issue`,metadata:{group:`issues`}},[a,e,x]),J(`f`,()=>n(e=>!e),{enabled:x,description:`Toggle filters`,metadata:{group:`issues`}},[x]),J(`x`,b,{enabled:x,description:`Clear all filters`,metadata:{group:`issues`}},[b,x]),J(`escape`,()=>o(-1),{enabled:a>=0&&x,description:`Clear focus`,metadata:{group:`issues`}},[a,x]);let C=(c.size>0?1:0)+(u.size>0?1:0)+(e.completionFilter===`recent`?0:1),w={Planning:`To Do`,PendingApproval:`To Do`,Queued:`To Do`,Running:`In Progress`,Reviewing:`In Progress`,PendingDecision:`In Review`,Blocked:`Blocked`,Approved:`Done`,Merged:`Done`,Cancelled:`Cancelled`},T={bug:`Bug`,feature:`Story`,refactor:`Task`,docs:`Task`,chore:`Task`},E=(0,G.useCallback)(()=>{let e=e=>{let t=String(e??``).replace(/"/g,`""`);return t.includes(`,`)||t.includes(`"`)||t.includes(`
50
+ `)?`"${t}"`:t},t=[`Summary`,`Issue Type`,`Status`,`Description`,`Created`,`Updated`],n=y.map(t=>[e(t.title),e(T[t.issueType]||`Task`),e(w[t.state]||`To Do`),e(t.description),e(t.createdAt?.slice(0,10)),e(t.updatedAt?.slice(0,10))]),r=[t.join(`,`),...n.map(e=>e.join(`,`))].join(`
51
+ `),i=new Blob([r],{type:`text/csv;charset=utf-8;`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=`fifony-export-${new Date().toISOString().slice(0,10)}.csv`,o.click(),URL.revokeObjectURL(a)},[y]);return(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 px-4 pb-4`,children:[(0,K.jsxs)(`div`,{className:`sticky top-0 z-10 bg-base-100 pt-3 pb-3 border-b border-base-300 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`label`,{className:`input input-bordered input-sm flex items-center gap-2 flex-1`,children:[(0,K.jsx)(Lr,{className:`size-4 opacity-40`}),(0,K.jsx)(`input`,{ref:s,type:`text`,className:`grow`,placeholder:`Search title, ID, type...`,value:e.query,onChange:t=>e.setQuery(t.target.value)}),e.query&&(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost btn-circle`,onClick:()=>e.setQuery(``),children:(0,K.jsx)(li,{className:`size-3`})})]}),(0,K.jsx)(`select`,{className:`select select-bordered select-sm w-auto`,value:r,onChange:e=>i(e.target.value),title:`Sort by`,children:Jb.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,K.jsx)(`button`,{className:`btn btn-sm btn-ghost btn-square`,onClick:E,title:`Export to Jira CSV`,children:(0,K.jsx)(zn,{className:`size-4`})}),(0,K.jsx)(`button`,{className:`btn btn-sm btn-square ${t?`btn-primary`:`btn-ghost`}`,onClick:()=>n(!t),title:`Toggle filters`,children:(0,K.jsx)(Ur,{className:`size-4`})}),C>0&&(0,K.jsx)(`span`,{className:`badge badge-sm badge-primary`,children:C}),(0,K.jsxs)(`div`,{className:`text-xs opacity-40 shrink-0`,children:[y.length,` result`,y.length===1?``:`s`,g>0&&e.completionFilter===`recent`&&(0,K.jsxs)(`span`,{children:[` · `,g,` older hidden`]})]})]}),t&&(0,K.jsxs)(`div`,{className:`bg-base-200 rounded-box p-3 space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-xs font-semibold opacity-50 mb-1.5`,children:`State`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[c.size>0&&(0,K.jsx)(`button`,{className:`badge badge-sm badge-ghost cursor-pointer opacity-60 hover:opacity-100`,onClick:()=>l(new Set),children:`Clear`}),Gb.map(e=>{let t=e.states.every(e=>c.has(e)),n=!t&&e.states.some(e=>c.has(e));return(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`button`,{className:`badge badge-sm cursor-pointer font-semibold transition-all ${t?`badge-primary`:n?`badge-primary badge-outline`:`badge-ghost opacity-50 hover:opacity-80`}`,onClick:()=>m(e.states),title:`Toggle all ${e.label} states`,children:e.label}),e.states.map(e=>{let t=_[e]||0;return(0,K.jsxs)(`button`,{className:`badge badge-sm gap-1 cursor-pointer transition-all ${c.has(e)?qb[e]:`badge-outline opacity-50 hover:opacity-100`}`,onClick:()=>p(e),children:[e,t>0&&(0,K.jsx)(`span`,{className:`font-mono text-[10px]`,children:t})]},e)})]},e.label)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-xs font-semibold opacity-50 mb-1.5`,children:`Type`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[u.size>0&&(0,K.jsx)(`button`,{className:`badge badge-sm badge-ghost cursor-pointer opacity-60 hover:opacity-100`,onClick:()=>d(new Set),children:`Clear`}),Kb.map(t=>{let n=u.has(t.value),r=e.issues.filter(e=>(e.issueType||``)===t.value).length;return(0,K.jsxs)(`button`,{className:`badge badge-sm gap-1 cursor-pointer transition-all ${n?t.color:`badge-outline opacity-50 hover:opacity-100`}`,onClick:()=>f(t.value),children:[t.label,r>0&&(0,K.jsx)(`span`,{className:`font-mono text-[10px]`,children:r})]},t.value)})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-xs font-semibold opacity-50 mb-1.5`,children:`Show`}),(0,K.jsx)(`select`,{className:`select select-bordered select-sm`,value:e.completionFilter,onChange:t=>e.setCompletionFilter(t.target.value),children:Yb.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),h&&(0,K.jsx)(`div`,{className:`flex items-end`,children:(0,K.jsxs)(`button`,{className:`btn btn-sm btn-ghost gap-1`,onClick:b,children:[(0,K.jsx)(li,{className:`size-3`}),`Clear all`]})})]})]}),!t&&h&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,K.jsx)(Yn,{className:`size-3 opacity-40`}),c.size>0&&(0,K.jsxs)(`span`,{className:`badge badge-sm badge-primary gap-1`,children:[c.size,` state`,c.size>1?`s`:``,(0,K.jsx)(`button`,{className:`ml-0.5`,onClick:()=>l(new Set),children:(0,K.jsx)(li,{className:`size-2.5`})})]}),e.completionFilter!==`recent`&&(0,K.jsxs)(`span`,{className:`badge badge-sm badge-ghost gap-1`,children:[`All issues`,(0,K.jsx)(`button`,{className:`ml-0.5`,onClick:()=>e.setCompletionFilter(`recent`),children:(0,K.jsx)(li,{className:`size-2.5`})})]}),(0,K.jsx)(`button`,{className:`text-xs opacity-40 hover:opacity-100 underline`,onClick:b,children:`clear all`})]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto pt-3`,children:(0,K.jsx)(Wb,{issues:y,onStateChange:e.updateState,onRetry:e.retryIssue,onCancel:e.cancelIssue,onSelect:e.setSelectedIssue,expanded:!0,focusedIndex:a})})]})}var Qb=v(`/analytics`)({});function $b({data:e,width:t=80,height:n=24,color:r=`var(--color-accent)`}){if(!e?.length||e.length<2)return null;let i=Math.max(...e,1);return(0,K.jsx)(`svg`,{width:t,height:n,className:`inline-block ml-2 opacity-60`,children:(0,K.jsx)(`polyline`,{fill:`none`,stroke:r,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,points:e.map((r,a)=>`${a/(e.length-1)*t},${n-r/i*(n-2)-1}`).join(` `)})})}var ex={Queued:`badge-info`,Running:`badge-primary`,Reviewing:`badge-secondary`,PendingDecision:`badge-success`,Blocked:`badge-error`,Approved:`badge-success`,Merged:`badge-success`,Cancelled:`badge-neutral`,Planning:`badge-info`},tx={Queued:pr,Running:kn,Reviewing:Vn,PendingDecision:Vn,Blocked:ni,Approved:Tn,Merged:Qn,Cancelled:On};function nx(e){return!e||e===0?`0`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function rx(e){if(!e)return null;let t=e.match(/claude-(\w+)-(\d+)-(\d+)/);return t?`${t[1].charAt(0).toUpperCase()+t[1].slice(1)} ${t[2]}.${t[3]}`:e.length<=16?e:e.slice(0,16)}function ix({issueId:e,issueState:t}){let{log:n,liveInfo:r}=Bt(e,t===`Running`||t===`Reviewing`),[i,a]=(0,G.useState)(!0),o=(0,G.useRef)(null);(0,G.useEffect)(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[n]);let s=r&&Number.isFinite(Number(r.elapsed))?Number(r.elapsed):r?.startedAt?Math.max(Date.now()-new Date(r.startedAt).getTime(),0):0,c=r?.logSize?(r.logSize/1024).toFixed(1):null;return(0,K.jsxs)(`div`,{className:`mt-2 space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-xs opacity-60`,children:[r&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(jn,{className:`size-3`}),re(s)]}),c&&(0,K.jsxs)(`span`,{children:[`Log: `,c,` KB`]}),r.agentPid&&(0,K.jsxs)(`span`,{children:[`PID `,r.agentPid]}),r.agentAlive===!1&&r.agentPid&&(0,K.jsx)(`span`,{className:`text-error`,children:`dead`})]}),(0,K.jsxs)(`button`,{className:`ml-auto flex items-center gap-0.5 opacity-50 hover:opacity-100 transition-opacity`,onClick:()=>a(e=>!e),title:i?`Collapse output`:`Expand output`,children:[i?(0,K.jsx)(Cn,{className:`size-3`}):(0,K.jsx)(bn,{className:`size-3`}),(0,K.jsx)(`span`,{className:`text-[10px]`,children:i?`hide`:`output`})]})]}),i&&(0,K.jsx)(`pre`,{ref:o,className:`text-[11px] bg-base-300 rounded-box p-3 overflow-x-auto whitespace-pre-wrap max-h-72 overflow-y-auto font-mono opacity-80 leading-relaxed break-all w-full max-w-full`,children:n||(0,K.jsx)(`span`,{className:`opacity-30`,children:`Waiting for output…`})})]})}function ax({index:e,issue:t,total:n,workflow:r}){if(!t)return(0,K.jsx)(`div`,{className:`slot-idle rounded-box p-4 flex items-center justify-center opacity-30 transition-opacity duration-300 hover:opacity-40 border-2 border-dashed border-base-300 min-w-0`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(kn,{className:`size-5 animate-pulse-soft`}),`Slot `,e+1,` -- idle`]})});let i=t.state===`Running`,a=t.state===`Planning`,o=t.state===`Reviewing`||t.state===`PendingDecision`?`border-secondary bg-secondary/5`:a?`border-info bg-info/5`:`border-primary bg-primary/5`,s=a?`plan`:t.state===`Reviewing`||t.state===`PendingDecision`?`review`:`execute`,c=r?.[s],l=a?`planner`:t.state===`Reviewing`||t.state===`PendingDecision`?`reviewer`:`executor`,u=t.tokensByPhase?.[l]?.model,d=rx(u||c?.model),f=c?.provider,p=t.effort?.[l]||t.effort?.default||c?.effort;return(0,K.jsxs)(`div`,{className:`border-2 rounded-box p-4 space-y-2 animate-fade-in-scale overflow-hidden min-w-0 w-full ${o} ${i?`slot-active`:``}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[a?(0,K.jsx)(gr,{className:`size-4 animate-spin text-info shrink-0`}):(0,K.jsx)(`span`,{className:`loading loading-spinner loading-sm text-primary shrink-0`}),(0,K.jsx)(`span`,{className:`font-mono text-base font-bold truncate`,children:t.identifier}),(0,K.jsx)(`span`,{className:`badge badge-sm ${ex[t.state]||`badge-ghost`} shrink-0`,children:t.state})]}),(0,K.jsxs)(`span`,{className:`text-xs font-mono opacity-50 shrink-0 bg-base-200 px-2 py-0.5 rounded`,children:[`Slot `,e+1,`/`,n]})]}),(0,K.jsx)(`div`,{className:`text-sm font-medium`,children:t.title}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-xs opacity-60`,children:[(0,K.jsxs)(`span`,{children:[`Attempt `,(t.attempts||0)+1,`/`,t.maxAttempts]}),t.startedAt&&(0,K.jsxs)(`span`,{children:[`started `,ie(t.startedAt)]})]}),(f||d||p)&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[f&&(0,K.jsxs)(`span`,{className:`badge badge-xs badge-ghost font-mono gap-1`,children:[(0,K.jsx)(Zr,{className:`size-2.5`}),f]}),d&&(0,K.jsx)(`span`,{className:`badge badge-xs badge-ghost font-mono`,children:d}),p&&(0,K.jsx)(`span`,{className:`badge badge-xs badge-outline`,children:p})]}),(0,K.jsx)(ix,{issueId:t.id,issueState:t.state})]})}function ox({issue:e}){return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs py-1.5 px-3 rounded-lg bg-base-200`,children:[(0,K.jsx)(tx[e.state]||kn,{className:`size-3 opacity-40 shrink-0`}),(0,K.jsx)(`span`,{className:`font-mono opacity-60 shrink-0`,children:e.identifier}),(0,K.jsx)(`span`,{className:`truncate flex-1`,children:e.title}),(0,K.jsx)(`span`,{className:`badge badge-xs ${ex[e.state]||`badge-ghost`}`,children:e.state}),e.state===`Blocked`&&e.nextRetryAt&&(0,K.jsxs)(`span`,{className:`opacity-40 shrink-0`,children:[`retry `,ie(e.nextRetryAt)]})]})}function sx({issue:e}){return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs py-1.5 px-3 rounded-lg bg-base-200`,children:[(0,K.jsx)(e.state===`Merged`?Qn:e.state===`Approved`?Tn:On,{className:`size-3 shrink-0 ${e.state===`Approved`||e.state===`Merged`?`text-success`:`text-neutral`}`}),(0,K.jsx)(`span`,{className:`font-mono opacity-60 shrink-0`,children:e.identifier}),(0,K.jsx)(`span`,{className:`truncate flex-1 opacity-70`,children:e.title}),e.durationMs&&(0,K.jsx)(`span`,{className:`opacity-40 shrink-0`,children:re(e.durationMs)}),e.completedAt&&(0,K.jsx)(`span`,{className:`opacity-40 shrink-0`,children:ie(e.completedAt)})]})}function cx({running:e,queued:t,concurrency:n,totalTokensToday:r,hourlyTokens:i}){return(0,K.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3 pt-3`,children:[(0,K.jsxs)(`div`,{className:`bg-base-200 rounded-box p-3 flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`bg-primary/10 rounded-btn p-2`,children:(0,K.jsx)(ri,{className:`size-5 text-primary`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`text-2xl font-bold font-mono`,children:[e.length,(0,K.jsxs)(`span`,{className:`text-sm opacity-50`,children:[`/`,n]})]}),(0,K.jsx)(`div`,{className:`text-xs opacity-50`,children:`Active agents`})]})]}),(0,K.jsxs)(`div`,{className:`bg-base-200 rounded-box p-3 flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`bg-info/10 rounded-btn p-2`,children:(0,K.jsx)(pr,{className:`size-5 text-info`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-2xl font-bold font-mono`,children:t.length}),(0,K.jsx)(`div`,{className:`text-xs opacity-50`,children:`Queued`})]})]}),(0,K.jsxs)(`div`,{className:`bg-base-200 rounded-box p-3 flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`bg-accent/10 rounded-btn p-2`,children:(0,K.jsx)(ui,{className:`size-5 text-accent`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-2xl font-bold font-mono`,children:nx(r)}),(0,K.jsxs)(`div`,{className:`text-xs opacity-50 flex items-center gap-1`,children:[`Tokens today`,(0,K.jsx)($b,{data:i})]})]})]}),(0,K.jsxs)(`div`,{className:`bg-base-200 rounded-box p-3 flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`bg-secondary/10 rounded-btn p-2`,children:(0,K.jsx)(Xn,{className:`size-5 text-secondary`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-2xl font-bold font-mono`,children:n}),(0,K.jsx)(`div`,{className:`text-xs opacity-50`,children:`Max parallelism`})]})]})]})}function lx({state:e,providers:t,parallelism:n,onRefresh:r,issues:i=[]}){let a=Array.isArray(e.issues)?e.issues:[],o=Number(e.config?.workerConcurrency)||3,{data:s}=Ni(),c=s?.workflow||null,l=a.filter(e=>e.state===`Planning`&&e.planningStatus===`planning`),u=[...a.filter(e=>e.state===`Running`||e.state===`Reviewing`),...l],d=a.filter(e=>e.state===`PendingApproval`||e.state===`Queued`||e.state===`Blocked`&&e.nextRetryAt||e.state===`Planning`&&e.planningStatus!==`planning`),f=a.filter(e=>e.state===`Approved`||e.state===`Merged`||e.state===`Cancelled`).sort((e,t)=>(t.completedAt||``).localeCompare(e.completedAt||``)).slice(0,10),p=(0,G.useMemo)(()=>{let e=new Date().toISOString().slice(0,10),t=0;for(let n of i)n.tokenUsage?.totalTokens&&(n.completedAt||n.updatedAt||``).slice(0,10)===e&&(t+=n.tokenUsage.totalTokens);return t},[i]),{data:m}=ut(24),h=(0,G.useMemo)(()=>m?.buckets?m.buckets.map(e=>e.tokens||0):[],[m]),g=[];for(let e=0;e<o;e++)g.push(u[e]||null);return(0,K.jsxs)(`div`,{className:`space-y-5 min-w-0 overflow-hidden flex-1`,children:[(0,K.jsx)(cx,{running:u,queued:d,concurrency:o,totalTokensToday:p,hourlyTokens:h}),(0,K.jsxs)(`div`,{className:`space-y-3 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h3`,{className:`font-semibold text-sm flex items-center gap-1.5`,children:[(0,K.jsx)(Rn,{className:`size-4 opacity-50`}),`Active Agents`]}),(0,K.jsxs)(`span`,{className:`text-xs opacity-50`,children:[u.length,`/`,o,` slots`]})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3 min-w-0`,children:g.map((e,t)=>(0,K.jsx)(ax,{index:t,issue:e,total:o,workflow:c},t))})]}),d.length>0&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`h3`,{className:`font-semibold text-sm opacity-70 flex items-center gap-1.5`,children:[(0,K.jsx)(pr,{className:`size-4 opacity-50`}),`Queue`,(0,K.jsx)(`span`,{className:`badge badge-xs badge-ghost`,children:d.length})]}),(0,K.jsxs)(`div`,{className:`space-y-1 stagger-children`,children:[d.slice(0,12).map(e=>(0,K.jsx)(ox,{issue:e},e.id)),d.length>12&&(0,K.jsxs)(`div`,{className:`text-xs opacity-40 pl-3`,children:[`+`,d.length-12,` more`]})]})]}),f.length>0&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`h3`,{className:`font-semibold text-sm opacity-70 flex items-center gap-1.5`,children:[(0,K.jsx)(Tn,{className:`size-4 opacity-50`}),`Recently Completed`,(0,K.jsx)(`span`,{className:`badge badge-xs badge-ghost`,children:f.length})]}),(0,K.jsx)(`div`,{className:`space-y-1 stagger-children`,children:f.map(e=>(0,K.jsx)(sx,{issue:e},e.id))})]}),u.length===0&&d.length===0&&f.length===0&&(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 animate-fade-in-up`,children:[(0,K.jsx)(`div`,{className:`bg-primary/10 rounded-full p-5 mb-4`,children:(0,K.jsx)(Rn,{className:`size-10 text-primary opacity-60`})}),(0,K.jsx)(`h3`,{className:`text-base font-semibold mb-1`,children:`No agents running`}),(0,K.jsx)(`p`,{className:`text-sm opacity-50 text-center max-w-xs`,children:`Approve a plan on an issue to start an agent, or create a new issue from the Kanban board.`})]})]})}var ux=v(`/agents`)({component:dx});function dx(){let e=tn();return(0,K.jsx)(`div`,{className:`flex-1 flex flex-col min-h-0 px-4 pb-4 overflow-y-auto`,children:(0,K.jsx)(lx,{state:e.data,providers:e.providers.data||{},parallelism:e.parallelism.data||{},onRefresh:e.refresh,issues:e.issues})})}var fx=v(`/`)({beforeLoad:()=>{throw x({to:`/chat`})}}),px=v(`/settings/`)({beforeLoad:()=>{throw x({to:`/settings/project`})}});function mx(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var hx=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,gx=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_x={};function vx(e,t){return((t||_x).jsx?gx:hx).test(e)}var yx=/[ \t\n\f\r]/g;function bx(e){return typeof e==`object`?e.type===`text`?xx(e.value):!1:xx(e)}function xx(e){return e.replace(yx,``)===``}var Sx=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};Sx.prototype.normal={},Sx.prototype.property={},Sx.prototype.space=void 0;function Cx(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new Sx(n,r,t)}function wx(e){return e.toLowerCase()}var Tx=class{constructor(e,t){this.attribute=t,this.property=e}};Tx.prototype.attribute=``,Tx.prototype.booleanish=!1,Tx.prototype.boolean=!1,Tx.prototype.commaOrSpaceSeparated=!1,Tx.prototype.commaSeparated=!1,Tx.prototype.defined=!1,Tx.prototype.mustUseProperty=!1,Tx.prototype.number=!1,Tx.prototype.overloadedBoolean=!1,Tx.prototype.property=``,Tx.prototype.spaceSeparated=!1,Tx.prototype.space=void 0;var Ex=e({boolean:()=>Z,booleanish:()=>Ox,commaOrSpaceSeparated:()=>Mx,commaSeparated:()=>jx,number:()=>Q,overloadedBoolean:()=>kx,spaceSeparated:()=>Ax}),Dx=0,Z=Nx(),Ox=Nx(),kx=Nx(),Q=Nx(),Ax=Nx(),jx=Nx(),Mx=Nx();function Nx(){return 2**++Dx}var Px=Object.keys(Ex),Fx=class extends Tx{constructor(e,t,n,r){let i=-1;if(super(e,t),Ix(this,`space`,r),typeof n==`number`)for(;++i<Px.length;){let e=Px[i];Ix(this,Px[i],(n&Ex[e])===Ex[e])}}};Fx.prototype.defined=!0;function Ix(e,t,n){n&&(e[t]=n)}function Lx(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new Fx(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[wx(r)]=r,n[wx(a.attribute)]=r}return new Sx(t,n,e.space)}var Rx=Lx({properties:{ariaActiveDescendant:null,ariaAtomic:Ox,ariaAutoComplete:null,ariaBusy:Ox,ariaChecked:Ox,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:Ax,ariaCurrent:null,ariaDescribedBy:Ax,ariaDetails:null,ariaDisabled:Ox,ariaDropEffect:Ax,ariaErrorMessage:null,ariaExpanded:Ox,ariaFlowTo:Ax,ariaGrabbed:Ox,ariaHasPopup:null,ariaHidden:Ox,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ax,ariaLevel:Q,ariaLive:null,ariaModal:Ox,ariaMultiLine:Ox,ariaMultiSelectable:Ox,ariaOrientation:null,ariaOwns:Ax,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:Ox,ariaReadOnly:Ox,ariaRelevant:null,ariaRequired:Ox,ariaRoleDescription:Ax,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:Ox,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function zx(e,t){return t in e?e[t]:t}function Bx(e,t){return zx(e,t.toLowerCase())}var Vx=Lx({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:jx,acceptCharset:Ax,accessKey:Ax,action:null,allow:null,allowFullScreen:Z,allowPaymentRequest:Z,allowUserMedia:Z,alt:null,as:null,async:Z,autoCapitalize:null,autoComplete:Ax,autoFocus:Z,autoPlay:Z,blocking:Ax,capture:null,charSet:null,checked:Z,cite:null,className:Ax,cols:Q,colSpan:null,content:null,contentEditable:Ox,controls:Z,controlsList:Ax,coords:Q|jx,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Z,defer:Z,dir:null,dirName:null,disabled:Z,download:kx,draggable:Ox,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Z,formTarget:null,headers:Ax,height:Q,hidden:kx,high:Q,href:null,hrefLang:null,htmlFor:Ax,httpEquiv:Ax,id:null,imageSizes:null,imageSrcSet:null,inert:Z,inputMode:null,integrity:null,is:null,isMap:Z,itemId:null,itemProp:Ax,itemRef:Ax,itemScope:Z,itemType:Ax,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Z,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:Z,muted:Z,name:null,nonce:null,noModule:Z,noValidate:Z,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Z,optimum:Q,pattern:null,ping:Ax,placeholder:null,playsInline:Z,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Z,referrerPolicy:null,rel:Ax,required:Z,reversed:Z,rows:Q,rowSpan:Q,sandbox:Ax,scope:null,scoped:Z,seamless:Z,selected:Z,shadowRootClonable:Z,shadowRootDelegatesFocus:Z,shadowRootMode:null,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:Ox,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:Z,useMap:null,value:Ox,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ax,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Z,declare:Z,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:Z,noHref:Z,noShade:Z,noWrap:Z,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:Ox,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Z,disableRemotePlayback:Z,prefix:null,property:null,results:Q,security:null,unselectable:null},space:`html`,transform:Bx}),Hx=Lx({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:Mx,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:Ax,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:Z,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:jx,g2:jx,glyphName:jx,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:Mx,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ax,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Mx,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Mx,rev:Mx,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Mx,requiredFeatures:Mx,requiredFonts:Mx,requiredFormats:Mx,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:Mx,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Mx,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Mx,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:zx}),Ux=Lx({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),Wx=Lx({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Bx}),Gx=Lx({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Kx={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},qx=/[A-Z]/g,Jx=/-[a-z]/g,Yx=/^data[-\w.:]+$/i;function Xx(e,t){let n=wx(t),r=t,i=Tx;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&Yx.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(Jx,Qx);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Jx.test(e)){let n=e.replace(qx,Zx);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Fx}return new i(r,t)}function Zx(e){return`-`+e.toLowerCase()}function Qx(e){return e.charAt(1).toUpperCase()}var $x=Cx([Rx,Vx,Ux,Wx,Gx],`html`),eS=Cx([Rx,Hx,Ux,Wx,Gx],`svg`);function tS(e){return e.join(` `).trim()}var nS=n(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
52
+ `,d=`/`,f=`*`,p=``,m=`comment`,h=`declaration`;function g(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,g=1;function v(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);g=~n?e.length-n:g+e.length}function y(){var e={line:l,column:g};return function(t){return t.position=new b(e),C(),t}}function b(e){this.start=e,this.end={line:l,column:g},this.source=t.source}b.prototype.content=e;function x(n){var r=Error(t.source+`:`+l+`:`+g+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=g,r.source=e,!t.silent)throw r}function S(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function C(){S(i)}function w(e){var t;for(e||=[];t=T();)t!==!1&&e.push(t);return e}function T(){var t=y();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return x(`End of comment missing`);var r=e.slice(2,n-2);return g+=2,v(r),e=e.slice(n),g+=2,t({type:m,comment:r})}}function E(){var e=y(),t=S(a);if(t){if(T(),!S(o))return x(`property missing ':'`);var r=S(s),i=e({type:h,property:_(t[0].replace(n,p)),value:r?_(r[0].replace(n,p)):p});return S(c),i}}function D(){var e=[];w(e);for(var t;t=E();)t!==!1&&(e.push(t),w(e));return e}return C(),D()}function _(e){return e?e.replace(l,p):p}t.exports=g})),rS=n((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.default=r;var n=t(nS());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),iS=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),aS=n(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(rS()),r=iS();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),oS=cS(`end`),sS=cS(`start`);function cS(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function lS(e){let t=sS(e),n=oS(e);if(t&&n)return{start:t,end:n}}function uS(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?fS(e.position):`start`in e||`end`in e?fS(e):`line`in e||`column`in e?dS(e):``}function dS(e){return pS(e&&e.line)+`:`+pS(e&&e.column)}function fS(e){return dS(e&&e.start)+`-`+dS(e&&e.end)}function pS(e){return e&&typeof e==`number`?e:1}var mS=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=uS(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};mS.prototype.file=``,mS.prototype.name=``,mS.prototype.reason=``,mS.prototype.message=``,mS.prototype.stack=``,mS.prototype.column=void 0,mS.prototype.line=void 0,mS.prototype.ancestors=void 0,mS.prototype.cause=void 0,mS.prototype.fatal=void 0,mS.prototype.place=void 0,mS.prototype.ruleId=void 0,mS.prototype.source=void 0;var hS=t(aS(),1),gS={}.hasOwnProperty,_S=new Map,vS=/[A-Z]/g,yS=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),bS=new Set([`td`,`th`]),xS=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function SS(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=NS(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=MS(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?eS:$x,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=CS(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function CS(e,t,n){if(t.type===`element`)return wS(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return TS(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return DS(e,t,n);if(t.type===`mdxjsEsm`)return ES(e,t);if(t.type===`root`)return OS(e,t,n);if(t.type===`text`)return kS(e,t)}function wS(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=eS,e.schema=i),e.ancestors.push(t);let a=zS(e,t.tagName,!1),o=PS(e,t),s=IS(e,t);return yS.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!bx(e):!0})),AS(e,o,a,t),jS(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function TS(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}BS(e,t.position)}function ES(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);BS(e,t.position)}function DS(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=eS,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:zS(e,t.name,!0),o=FS(e,t),s=IS(e,t);return AS(e,o,a,t),jS(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function OS(e,t,n){let r={};return jS(r,IS(e,t)),e.create(t,e.Fragment,r,n)}function kS(e,t){return t.value}function AS(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function jS(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function MS(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function NS(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=sS(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function PS(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&gS.call(t.properties,i)){let a=LS(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&bS.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function FS(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else BS(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else BS(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function IS(e,t){let n=[],r=-1,i=e.passKeys?new Map:_S;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=CS(e,a,o);s!==void 0&&n.push(s)}return n}function LS(e,t,n){let r=Xx(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?mx(n):tS(n)),r.property===`style`){let t=typeof n==`object`?n:RS(e,String(n));return e.stylePropertyNameCase===`css`&&(t=VS(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?Kx[r.property]||r.property:r.attribute,n]}}function RS(e,t){try{return(0,hS.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new mS("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=xS+`#cannot-parse-style-attribute`,r}}function zS(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=vx(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=vx(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return gS.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);BS(e)}function BS(e,t){let n=new mS("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=xS+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function VS(e){let t={},n;for(n in e)gS.call(e,n)&&(t[HS(n)]=e[n]);return t}function HS(e){let t=e.replace(vS,US);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function US(e){return`-`+e.toLowerCase()}var WS={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},GS={};function KS(e,t){let n=t||GS;return qS(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function qS(e,t,n){if(YS(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return JS(e.children,t,n)}return Array.isArray(e)?JS(e,t,n):``}function JS(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=qS(e[i],t,n);return r.join(``)}function YS(e){return!!(e&&typeof e==`object`)}var XS=document.createElement(`i`);function ZS(e){let t=`&`+e+`;`;XS.innerHTML=t;let n=XS.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function QS(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function $S(e,t){return e.length>0?(QS(e,e.length,0,t),e):t}var eC={}.hasOwnProperty;function tC(e){let t={},n=-1;for(;++n<e.length;)nC(t,e[n]);return t}function nC(e,t){let n;for(n in t){let r=(eC.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){eC.call(r,a)||(r[a]=[]);let e=i[a];rC(r[a],Array.isArray(e)?e:e?[e]:[])}}}function rC(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);QS(e,0,0,r)}function iC(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function aC(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var oC=_C(/[A-Za-z]/),sC=_C(/[\dA-Za-z]/),cC=_C(/[#-'*+\--9=?A-Z^-~]/);function lC(e){return e!==null&&(e<32||e===127)}var uC=_C(/\d/),dC=_C(/[\dA-Fa-f]/),fC=_C(/[!-/:-@[-`{-~]/);function $(e){return e!==null&&e<-2}function pC(e){return e!==null&&(e<0||e===32)}function mC(e){return e===-2||e===-1||e===32}var hC=_C(/\p{P}|\p{S}/u),gC=_C(/\s/);function _C(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function vC(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&sC(e.charCodeAt(n+1))&&sC(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function yC(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return mC(r)?(e.enter(n),s(r)):t(r)}function s(r){return mC(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var bC={tokenize:xC};function xC(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),yC(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return $(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var SC={tokenize:wC},CC={tokenize:TC};function wC(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return QS(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(CC,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(CC,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return $(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;QS(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function TC(e,t,n){return yC(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function EC(e){if(e===null||pC(e)||gC(e))return 1;if(hC(e))return 2}function DC(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var OC={name:`attention`,resolveAll:kC,tokenize:AC};function kC(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};jC(d,-c),jC(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=$S(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=$S(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=$S(l,DC(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=$S(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=$S(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,QS(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function AC(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=EC(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=EC(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function jC(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var MC={name:`autolink`,tokenize:NC};function NC(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return oC(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||sC(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||sC(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||lC(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):cC(t)?(e.consume(t),l):n(t)}function u(e){return sC(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||sC(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var PC={partial:!0,tokenize:FC};function FC(e,t,n){return r;function r(t){return mC(t)?yC(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||$(e)?t(e):n(e)}}var IC={continuation:{tokenize:RC},exit:zC,name:`blockQuote`,tokenize:LC};function LC(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return mC(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function RC(e,t,n){let r=this;return i;function i(t){return mC(t)?yC(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(IC,t,n)(r)}}function zC(e){e.exit(`blockQuote`)}var BC={name:`characterEscape`,tokenize:VC};function VC(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return fC(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var HC={name:`characterReference`,tokenize:UC};function UC(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=sC,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=dC,u):(e.enter(`characterReferenceValue`),a=7,o=uC,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===sC&&!ZS(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var WC={partial:!0,tokenize:qC},GC={concrete:!0,name:`codeFenced`,tokenize:KC};function KC(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),mC(t)?yC(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||$(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(WC,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||$(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):mC(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),yC(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||$(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||$(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&mC(t)?yC(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||$(t)?e.check(WC,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||$(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),mC(t)?yC(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),mC(t)?yC(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||$(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function qC(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var JC={name:`codeIndented`,tokenize:XC},YC={partial:!0,tokenize:ZC};function XC(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),yC(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):$(t)?e.attempt(YC,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||$(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function ZC(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):$(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):yC(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):$(e)?i(e):n(e)}}var QC={name:`codeText`,previous:ew,resolve:$C,tokenize:tw};function $C(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function ew(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function tw(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):$(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||$(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var nw=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&rw(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),rw(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),rw(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);rw(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);rw(this.left,t.reverse())}}};function rw(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function iw(e){let t={},n=-1,r,i,a,o,s,c,l,u=new nw(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,aw(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return QS(e,0,1/0,u.slice(0)),!l}function aw(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var ow={resolve:cw,tokenize:lw},sw={partial:!0,tokenize:uw};function cw(e){return iw(e),e}function lw(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):$(t)?e.check(sw,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function uw(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),yC(e,a,`linePrefix`)}function a(i){if(i===null||$(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function dw(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||lC(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||$(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||pC(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||lC(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function fw(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):$(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||$(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!mC(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function pw(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):$(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),yC(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||$(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function mw(e,t){let n;return r;function r(i){return $(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):mC(i)?yC(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var hw={name:`definition`,tokenize:_w},gw={partial:!0,tokenize:vw};function _w(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return fw.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=aC(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return pC(t)?mw(e,l)(t):l(t)}function l(t){return dw(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(gw,d,d)(t)}function d(t){return mC(t)?yC(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||$(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function vw(e,t,n){return r;function r(t){return pC(t)?mw(e,i)(t):n(t)}function i(t){return pw(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return mC(t)?yC(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||$(e)?t(e):n(e)}}var yw={name:`hardBreakEscape`,tokenize:bw};function bw(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return $(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var xw={name:`headingAtx`,resolve:Sw,tokenize:Cw};function Sw(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},QS(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Cw(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||pC(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||$(n)?(e.exit(`atxHeading`),t(n)):mC(n)?yC(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||pC(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var ww=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),Tw=[`pre`,`script`,`style`,`textarea`],Ew={concrete:!0,name:`htmlFlow`,resolveTo:kw,tokenize:Aw},Dw={partial:!0,tokenize:Mw},Ow={partial:!0,tokenize:jw};function kw(e){let t=e.length;for(;t--&&!(e[t][0]===`enter`&&e[t][1].type===`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Aw(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):oC(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):oC(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return oC(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||pC(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Tw.includes(l)?(i=1,r.interrupt?t(s):O(s)):ww.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||sC(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return mC(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||oC(t)?(e.consume(t),b):mC(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||sC(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):mC(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):mC(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||$(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||pC(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||mC(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||$(t)?O(t):mC(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):$(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Dw,R,k)(t)):t===null||$(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(Ow,A,R)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||$(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return Tw.includes(n)?(e.consume(t),L):O(t)}return oC(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||$(t)?(e.exit(`htmlFlowData`),R(t)):(e.consume(t),L)}function R(n){return e.exit(`htmlFlow`),t(n)}}function jw(e,t,n){let r=this;return i;function i(t){return $(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function Mw(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(PC,t,n)}}var Nw={name:`htmlText`,tokenize:Pw};function Pw(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):oC(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):oC(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):$(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):$(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):$(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):$(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return oC(t)?(e.consume(t),S):n(t)}function S(t){return t===45||sC(t)?(e.consume(t),S):C(t)}function C(t){return $(t)?(o=C,N(t)):mC(t)?(e.consume(t),C):M(t)}function w(t){return t===45||sC(t)?(e.consume(t),w):t===47||t===62||pC(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||oC(t)?(e.consume(t),E):$(t)?(o=T,N(t)):mC(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||sC(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):$(t)?(o=D,N(t)):mC(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):$(t)?(o=O,N(t)):mC(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):$(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||pC(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||pC(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return mC(t)?yC(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var Fw={name:`labelEnd`,resolveAll:zw,resolveTo:Bw,tokenize:Vw},Iw={tokenize:Hw},Lw={tokenize:Uw},Rw={tokenize:Ww};function zw(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&QS(e,0,e.length,n),e}function Bw(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=$S(s,e.slice(a+1,a+r+3)),s=$S(s,[[`enter`,u,t]]),s=$S(s,DC(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=$S(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=$S(s,e.slice(o+1)),s=$S(s,[[`exit`,c,t]]),QS(e,a,e.length,s),e}function Vw(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(aC(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(Iw,u,o?u:d)(t):t===91?e.attempt(Lw,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Rw,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function Hw(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return pC(t)?mw(e,a)(t):a(t)}function a(t){return t===41?u(t):dw(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return pC(t)?mw(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?pw(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return pC(t)?mw(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function Uw(e,t,n){let r=this;return i;function i(t){return fw.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(aC(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function Ww(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var Gw={name:`labelStartImage`,resolveAll:Fw.resolveAll,tokenize:Kw};function Kw(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var qw={name:`labelStartLink`,resolveAll:Fw.resolveAll,tokenize:Jw};function Jw(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var Yw={name:`lineEnding`,tokenize:Xw};function Xw(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),yC(e,t,`linePrefix`)}}var Zw={name:`thematicBreak`,tokenize:Qw};function Qw(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||$(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),mC(t)?yC(e,s,`whitespace`)(t):s(t))}}var $w={continuation:{tokenize:rT},exit:aT,name:`list`,tokenize:nT},eT={partial:!0,tokenize:oT},tT={partial:!0,tokenize:iT};function nT(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:uC(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(Zw,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return uC(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(PC,r.interrupt?n:u,e.attempt(eT,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return mC(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function rT(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(PC,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,yC(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!mC(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(tT,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,yC(e,e.attempt($w,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function iT(e,t,n){let r=this;return yC(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function aT(e){e.exit(this.containerState.type)}function oT(e,t,n){let r=this;return yC(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!mC(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var sT={name:`setextUnderline`,resolveTo:cT,tokenize:lT};function cT(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function lT(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),mC(t)?yC(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||$(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var uT={tokenize:dT};function dT(e){let t=this,n=e.attempt(PC,r,e.attempt(this.parser.constructs.flowInitial,i,yC(e,e.attempt(this.parser.constructs.flow,i,e.attempt(ow,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var fT={resolveAll:gT()},pT=hT(`string`),mT=hT(`text`);function hT(e){return{resolveAll:gT(e===`text`?_T:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function gT(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function _T(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var vT=e({attentionMarkers:()=>ET,contentInitial:()=>bT,disable:()=>DT,document:()=>yT,flow:()=>ST,flowInitial:()=>xT,insideSpan:()=>TT,string:()=>CT,text:()=>wT}),yT={42:$w,43:$w,45:$w,48:$w,49:$w,50:$w,51:$w,52:$w,53:$w,54:$w,55:$w,56:$w,57:$w,62:IC},bT={91:hw},xT={[-2]:JC,[-1]:JC,32:JC},ST={35:xw,42:Zw,45:[sT,Zw],60:Ew,61:sT,95:Zw,96:GC,126:GC},CT={38:HC,92:BC},wT={[-5]:Yw,[-4]:Yw,[-3]:Yw,33:Gw,38:HC,42:OC,60:[MC,Nw],91:qw,92:[yw,BC],93:Fw,95:OC,96:QC},TT={null:[OC,fT]},ET={null:[42,95]},DT={null:[]};function OT(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=$S(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=DC(a,l.events,l),l.events):[]}function f(e,t){return AT(p(e),t)}function p(e){return kT(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){$(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&QS(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function kT(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function AT(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
53
+ `;break;case-3:o=`\r
54
+ `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function jT(e){let t={constructs:tC([vT,...(e||{}).extensions||[]]),content:n(bC),defined:[],document:n(SC),flow:n(uT),lazy:{},string:n(pT),text:n(mT)};return t;function n(e){return n;function n(n){return OT(t,e,n)}}}function MT(e){for(;!iw(e););return e}var NT=/[\0\t\n\r]/g;function PT(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(NT.lastIndex=u,c=NT.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var FT=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function IT(e){return e.replace(FT,LT)}function LT(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return iC(n.slice(t?2:1),t?16:10)}return ZS(n)||e}var RT={}.hasOwnProperty;function zT(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),BT(n)(MT(jT(n).document().write(PT()(e,t,!0))))}function BT(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(ue),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(oe),blockQuote:a(re),characterEscape:T,characterReference:T,codeFenced:a(U),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(U,o),codeText:a(ie,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(W),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(ae),hardBreakEscape:a(se),hardBreakTrailing:a(se),htmlFlow:a(ce,o),htmlFlowData:T,htmlText:a(ce,o),htmlTextData:T,image:a(le),label:o,link:a(ue),listItem:a(G),listItemValue:f,listOrdered:a(de,d),listUnordered:a(de),paragraph:a(fe),reference:z,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(oe),strong:a(pe),thematicBreak:a(he)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:ne,autolinkProtocol:H,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:V,characterReferenceMarkerNumeric:V,characterReferenceValue:ee,characterReference:te,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:F,labelText:P,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:B,resourceDestinationString:I,resourceTitleString:L,resource:R,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};HT(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];RT.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||WT).call(a,void 0,e[0])}for(r.position={start:VT(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:VT(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(!(t[1].type===`linePrefix`||t[1].type===`blockQuotePrefix`||t[1].type===`blockQuotePrefixWhitespace`||t[1].type===`blockQuoteMarker`||t[1].type===`listItemIndent`))break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:VT(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||WT).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+uS({start:e.start,end:e.end})+`): it’s not open`);n.position.end=VT(e.end)}function u(){return KS(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=aC(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=me(),n.position={start:VT(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=VT(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=VT(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=IT(t),n.identifier=aC(t).toLowerCase()}function F(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function R(){this.data.inReference=void 0}function z(){this.data.referenceType=`collapsed`}function B(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=aC(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function V(e){this.data.characterReferenceType=e.type}function ee(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=iC(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=ZS(t);let i=this.stack[this.stack.length-1];i.value+=r}function te(e){let t=this.stack.pop();t.position.end=VT(e.end)}function H(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function ne(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function re(){return{type:`blockquote`,children:[]}}function U(){return{type:`code`,lang:null,meta:null,value:``}}function ie(){return{type:`inlineCode`,value:``}}function W(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function ae(){return{type:`emphasis`,children:[]}}function oe(){return{type:`heading`,depth:0,children:[]}}function se(){return{type:`break`}}function ce(){return{type:`html`,value:``}}function le(){return{type:`image`,title:null,url:``,alt:null}}function ue(){return{type:`link`,title:null,url:``,children:[]}}function de(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function G(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function fe(){return{type:`paragraph`,children:[]}}function pe(){return{type:`strong`,children:[]}}function me(){return{type:`text`,value:``}}function he(){return{type:`thematicBreak`}}}function VT(e){return{line:e.line,column:e.column,offset:e.offset}}function HT(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?HT(e,r):UT(e,r)}}function UT(e,t){let n;for(n in t)if(RT.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function WT(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+uS({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+uS({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+uS({start:t.start,end:t.end})+`) is still open`)}function GT(e){let t=this;t.parser=n;function n(n){return zT(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function KT(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function qT(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
55
+ `}]}function JT(e,t){let n=t.value?t.value+`
56
+ `:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function YT(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function XT(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ZT(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=vC(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function QT(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function $T(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function eE(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function tE(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return eE(e,t);let i={src:vC(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function nE(e,t){let n={src:vC(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function rE(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function iE(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return eE(e,t);let i={href:vC(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function aE(e,t){let n={href:vC(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function oE(e,t,n){let r=e.all(t),i=n?sE(n):cE(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
57
+ `}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
58
+ `});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function sE(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=cE(n[r])}return t}function cE(e){return e.spread??e.children.length>1}function lE(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function uE(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function dE(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function fE(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function pE(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=sS(t.children[1]),o=oS(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function mE(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function hE(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var gE=9,_E=32;function vE(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(yE(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(yE(t.slice(i),i>0,!1)),a.join(``)}function yE(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===gE||t===_E;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===gE||t===_E;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function bE(e,t){let n={type:`text`,value:vE(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function xE(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var SE={blockquote:KT,break:qT,code:JT,delete:YT,emphasis:XT,footnoteReference:ZT,heading:QT,html:$T,imageReference:tE,image:nE,inlineCode:rE,linkReference:iE,link:aE,listItem:oE,list:lE,paragraph:uE,root:dE,strong:fE,table:pE,tableCell:hE,tableRow:mE,text:bE,thematicBreak:xE,toml:CE,yaml:CE,definition:CE,footnoteDefinition:CE};function CE(){}var wE=typeof self==`object`?self:globalThis,TE=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(new wE[e](t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(new wE[a](o),i)};return r},EE=e=>TE(new Map,e)(0),DE=``,{toString:OE}={},{keys:kE}=Object,AE=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=OE.call(e).slice(8,-1);switch(n){case`Array`:return[1,DE];case`Object`:return[2,DE];case`Date`:return[3,DE];case`RegExp`:return[4,DE];case`Map`:return[5,DE];case`Set`:return[6,DE];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},jE=([e,t])=>e===0&&(t===`function`||t===`symbol`),ME=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=AE(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+s);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of kE(r))(e||!jE(AE(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);for(let[n,i]of r)(e||!(jE(AE(n))||jE(AE(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!jE(AE(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},NE=(e,{json:t,lossy:n}={})=>{let r=[];return ME(!(t||n),!!t,new Map,r)(e),r},PE=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?EE(NE(e,t)):structuredClone(e):(e,t)=>EE(NE(e,t));function FE(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function IE(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function LE(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||FE,r=e.options.footnoteBackLabel||IE,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=vC(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...PE(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
59
+ `},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
60
+ `}]}}var RE=(function(e){if(e==null)return UE;if(typeof e==`function`)return HE(e);if(typeof e==`object`)return Array.isArray(e)?zE(e):BE(e);if(typeof e==`string`)return VE(e);throw Error(`Expected function, string, or object as test`)});function zE(e){let t=[],n=-1;for(;++n<e.length;)t[n]=RE(e[n]);return HE(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function BE(e){let t=e;return HE(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function VE(e){return HE(t);function t(t){return t&&t.type===e}}function HE(e){return t;function t(t,n,r){return!!(WE(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function UE(){return!0}function WE(e){return typeof e==`object`&&!!e&&`type`in e}function GE(e){return e}var KE=[];function qE(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=RE(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,`name`,{value:`node (`+GE(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=KE,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=JE(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function JE(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?KE:[e]}function YE(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),qE(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var XE={}.hasOwnProperty,ZE={};function QE(e,t){let n=t||ZE,r=new Map,i=new Map,a={all:s,applyData:eD,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...SE,...n.handlers},one:o,options:n,patch:$E,wrap:nD};return YE(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(XE.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=PE(n);return r.children=a.all(e),r}return PE(e)}return(a.options.unknownHandler||tD)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=rD(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=rD(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function $E(e,t){e.position&&(t.position=lS(e))}function eD(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,PE(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function tD(e,t){let n=t.data||{},r=`value`in t&&!(XE.call(n,`hProperties`)||XE.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function nD(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
61
+ `});++r<e.length;)r&&n.push({type:`text`,value:`
62
+ `}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
63
+ `}),n}function rD(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function iD(e,t){let n=QE(e,t),r=n.one(e,void 0),i=LE(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
64
+ `},i)),a}function aD(e,t){return e&&`run`in e?async function(n,r){let i=iD(n,{file:r,...t});await e.run(i,r)}:function(n,r){return iD(n,{file:r,...e||t})}}function oD(e){if(e)throw e}var sD=n(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function cD(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function lD(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?uD(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function uD(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var dD={basename:fD,dirname:pD,extname:mD,join:hD,sep:`/`};function fD(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);vD(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function pD(e){if(vD(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function mD(e){vD(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function hD(...e){let t=-1,n;for(;++t<e.length;)vD(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:gD(n)}function gD(e){vD(e);let t=e.codePointAt(0)===47,n=_D(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function _D(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function vD(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var yD={cwd:bD};function bD(){return`/`}function xD(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function SD(e){if(typeof e==`string`)e=new URL(e);else if(!xD(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return CD(e)}function CD(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var wD=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],TD=class{constructor(e){let t;t=e?xD(e)?{path:e}:typeof e==`string`||kD(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:yD.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<wD.length;){let e=wD[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)wD.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?dD.basename(this.path):void 0}set basename(e){DD(e,`basename`),ED(e,`basename`),this.path=dD.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?dD.dirname(this.path):void 0}set dirname(e){OD(this.basename,`dirname`),this.path=dD.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?dD.extname(this.path):void 0}set extname(e){if(ED(e,`extname`),OD(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=dD.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){xD(e)&&(e=SD(e)),DD(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?dD.basename(this.path,this.extname):void 0}set stem(e){DD(e,`stem`),ED(e,`stem`),this.path=dD.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new mS(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function ED(e,t){if(e&&e.includes(dD.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+dD.sep+"`")}function DD(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function OD(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function kD(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var AD=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),jD=t(sD(),1),MD={}.hasOwnProperty,ND=new class e extends AD{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=lD()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,jD.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(ID(`data`,this.frozen),this.namespace[e]=t,this):MD.call(this.namespace,e)&&this.namespace[e]||void 0:e?(ID(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=zD(e),n=this.parser||this.Parser;return PD(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),PD(`process`,this.parser||this.Parser),FD(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=zD(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);VD(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),PD(`processSync`,this.parser||this.Parser),FD(`processSync`,this.compiler||this.Compiler),this.process(e,r),RD(`processSync`,`process`,t),n;function r(e,r){t=!0,oD(e),n=r}}run(e,t,n){LD(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=zD(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),RD(`runSync`,`run`,n),r;function i(e,t){oD(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=zD(t),r=this.compiler||this.Compiler;return FD(`stringify`,r),LD(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(ID(`use`,this.frozen),e!=null)if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,jD.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];cD(o)&&cD(r)&&(r=(0,jD.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function PD(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function FD(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function ID(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function LD(e){if(!cD(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function RD(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function zD(e){return BD(e)?e:new TD(e)}function BD(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function VD(e){return typeof e==`string`||HD(e)}function HD(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var UD=[],WD={allowDangerousHtml:!0},GD=/^(https?|ircs?|mailto|xmpp)$/i,KD=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function qD(e){let t=JD(e),n=YD(e);return XD(t.runSync(t.parse(n),n),e)}function JD(e){let t=e.rehypePlugins||UD,n=e.remarkPlugins||UD,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...WD}:WD;return ND().use(GT).use(n).use(aD,r).use(t)}function YD(e){let t=e.children||``,n=new TD;return typeof t==`string`?n.value=t:``+t,n}function XD(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||ZD;for(let e of KD)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return YE(e,l),SS(e,{Fragment:K.Fragment,components:i,ignoreInvalidStyle:!0,jsx:K.jsx,jsxs:K.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in WS)if(Object.hasOwn(WS,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=WS[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function ZD(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||GD.test(e.slice(0,t))?e:``}var QD=[`chat-sessions`],$D=e=>[`chat-session`,e];function eO(){let e=w(),[t,n]=(0,G.useState)(null),[r,i]=(0,G.useState)([]),a=j({queryKey:QD,queryFn:()=>U.get(`/chat/sessions`),staleTime:1e4}),o=j({queryKey:$D(t),queryFn:()=>U.get(`/chat/sessions/${encodeURIComponent(t)}`),enabled:!!t,staleTime:5e3}),s=(0,G.useMemo)(()=>{let e=a.data?.sessions;return Array.isArray(e)?e:[]},[a.data]),c=o.data?.session??null,l=(0,G.useMemo)(()=>{let e=c&&Array.isArray(c.turns)?c.turns:[];return r.length===0||e.length>=r.length?e:[...e,...r.slice(e.length)]},[c,r]),u=S({mutationFn:({sessionId:e,message:t})=>U.post(`/chat`,{sessionId:e||void 0,message:t}),onSuccess:r=>{r.sessionId&&r.sessionId!==t&&n(r.sessionId),e.invalidateQueries({queryKey:QD}),r.sessionId&&e.invalidateQueries({queryKey:$D(r.sessionId)})}}),d=S({mutationFn:({sessionId:e,action:t})=>U.post(`/chat/action`,{sessionId:e,action:t})}),f=S({mutationFn:e=>U.post(`/chat/sessions`,e?{name:e}:{}),onSuccess:t=>{t.session?.id&&n(t.session.id),e.invalidateQueries({queryKey:QD})}}),p=S({mutationFn:e=>U.delete(`/chat/sessions/${encodeURIComponent(e)}`),onSuccess:(r,i)=>{t===i&&n(null),e.invalidateQueries({queryKey:QD})}}),m=S({mutationFn:({id:e,name:t})=>U.patch(`/chat/sessions/${encodeURIComponent(e)}`,{name:t}),onSuccess:(t,{id:n})=>{e.invalidateQueries({queryKey:QD}),e.invalidateQueries({queryKey:$D(n)})}}),h=(0,G.useCallback)(e=>{if(!e?.trim())return;let n=e.trim();i(e=>[...e,{role:`user`,content:n,timestamp:new Date().toISOString()}]),u.mutate({sessionId:t,message:n},{onSuccess:e=>{e.response&&i(t=>[...t,{role:`assistant`,content:e.response,actions:e.actions,timestamp:new Date().toISOString()}])}})},[t,u]),g=(0,G.useCallback)(e=>!t||!e?Promise.resolve(null):d.mutateAsync({sessionId:t,action:e}),[t,d]),_=(0,G.useCallback)(e=>f.mutate(e),[f]),v=(0,G.useCallback)(e=>p.mutate(e),[p]),y=(0,G.useCallback)((e,t)=>m.mutate({id:e,name:t}),[m]),b=(0,G.useCallback)(e=>{n(e??null),i([])},[]);return{sessions:s,currentSessionId:t,currentSession:c,messages:l,isLoading:u.isPending,isSending:u.isPending,isSessionsLoading:a.isLoading,isSessionLoading:o.isLoading&&!!t,error:u.error?.message??null,sessionsError:a.error?.message??null,lastResponse:u.data??null,sendMessage:h,executeAction:g,createSession:_,deleteSession:v,renameSession:y,selectSession:b,isExecutingAction:d.isPending,isCreatingSession:f.isPending,isDeletingSession:p.isPending,isRenamingSession:m.isPending,clearError:()=>u.reset()}}var tO={"create-issue":{label:`Create Issue`,icon:kr,btnClass:`btn-success`,hasButton:!0},"start-service":{label:`Start Service`,icon:Or,btnClass:`btn-primary`,hasButton:!0},"stop-service":{label:`Stop Service`,icon:Jr,btnClass:`btn-warning`,hasButton:!0},"restart-service":{label:`Restart Service`,icon:Mr,btnClass:`btn-info`,hasButton:!0},"retry-issue":{label:`Retry`,icon:Pr,btnClass:`btn-warning`,hasButton:!0},"replan-issue":{label:`Replan`,icon:Mr,btnClass:`btn-warning`,hasButton:!0},"approve-issue":{label:`Approve`,icon:wn,btnClass:`btn-success`,hasButton:!0},"merge-issue":{label:`Merge`,icon:Qn,btnClass:`btn-primary`,hasButton:!0},"read-file":{label:`File`,icon:Un,hasButton:!1},"read-service-log":{label:`Service Log`,icon:Zr,hasButton:!1}},nO={task:`badge-primary`,bug:`badge-error`,feature:`badge-info`,chore:`badge-ghost`};function rO({payload:e}){let t=nO[e?.issueType]??`badge-ghost`;return(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[e?.issueType&&(0,K.jsx)(`span`,{className:`badge badge-xs ${t}`,children:e.issueType}),(0,K.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e?.title||`Untitled`})]}),e?.description&&(0,K.jsx)(`p`,{className:`text-xs opacity-60 line-clamp-2 leading-relaxed`,children:e.description})]})}function iO({payload:e}){return(0,K.jsx)(`div`,{className:`text-sm`,children:(0,K.jsx)(`span`,{className:`font-mono text-xs opacity-70`,children:e?.serviceName||e?.name||`service`})})}function aO({payload:e}){return(0,K.jsxs)(`div`,{className:`text-sm`,children:[(0,K.jsx)(`span`,{className:`font-mono text-xs opacity-70`,children:e?.identifier||e?.issueId||e?.id||`issue`}),e?.title&&(0,K.jsx)(`span`,{className:`ml-2 text-xs opacity-50 truncate`,children:e.title})]})}function oO({payload:e}){return(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`div`,{className:`text-xs font-mono opacity-60 truncate`,children:e?.path||e?.filePath||`unknown`}),e?.content&&(0,K.jsx)(`pre`,{className:`text-[11px] leading-relaxed bg-base-200 rounded px-2.5 py-2 overflow-x-auto max-h-48 font-mono`,children:(0,K.jsx)(`code`,{children:e.content})})]})}function sO({payload:e}){return(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`div`,{className:`text-xs font-mono opacity-60`,children:e?.serviceName||e?.name||`service`}),e?.content&&(0,K.jsx)(`pre`,{className:`text-[11px] leading-relaxed bg-base-200 rounded px-2.5 py-2 overflow-x-auto max-h-48 font-mono whitespace-pre-wrap`,children:e.content})]})}function cO(e,t){switch(e){case`create-issue`:return(0,K.jsx)(rO,{payload:t});case`start-service`:case`stop-service`:case`restart-service`:return(0,K.jsx)(iO,{payload:t});case`retry-issue`:case`replan-issue`:case`approve-issue`:case`merge-issue`:return(0,K.jsx)(aO,{payload:t});case`read-file`:return(0,K.jsx)(oO,{payload:t});case`read-service-log`:return(0,K.jsx)(sO,{payload:t});default:return(0,K.jsx)(`div`,{className:`text-xs opacity-50 font-mono`,children:JSON.stringify(t,null,2)})}}function lO({action:e,sessionId:t}){let[n,r]=(0,G.useState)(`idle`),[i,a]=(0,G.useState)(null),o=tO[e?.type];if(!o||e.type===`list-issues`||e.type===`list-services`)return null;let{label:s,icon:c,btnClass:l,hasButton:u}=o,d=(0,G.useCallback)(async()=>{if(!(n===`loading`||n===`success`)){r(`loading`),a(null);try{await U.post(`/chat/action`,{sessionId:t,action:e}),r(`success`)}catch(e){r(`error`),a(e instanceof Error?e.message:String(e))}}},[t,e,n]);return(0,K.jsxs)(`div`,{className:`border border-base-300 rounded-lg overflow-hidden bg-base-100 max-w-md`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-base-200/50 border-b border-base-300`,children:[(0,K.jsx)(c,{className:`size-3.5 opacity-50 shrink-0`}),(0,K.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider opacity-40`,children:s})]}),(0,K.jsx)(`div`,{className:`px-3 py-2`,children:cO(e.type,e.payload)}),u&&(0,K.jsxs)(`div`,{className:`px-3 py-2 border-t border-base-300 flex items-center justify-between gap-2`,children:[n===`error`&&i&&(0,K.jsx)(`span`,{className:`text-[11px] text-error truncate flex-1`,children:i}),n!==`error`&&(0,K.jsx)(`span`,{}),(0,K.jsxs)(`button`,{className:`btn btn-xs ${n===`success`?`btn-ghost text-success`:l} gap-1`,onClick:d,disabled:n===`loading`||n===`success`,children:[n===`loading`&&(0,K.jsx)(gr,{className:`size-3 animate-spin`}),n===`success`&&(0,K.jsx)(yn,{className:`size-3`}),n===`idle`&&(0,K.jsx)(c,{className:`size-3`}),n===`error`&&(0,K.jsx)(Pr,{className:`size-3`}),(0,K.jsx)(`span`,{children:n===`success`?`Done`:n===`error`?`Retry`:s})]})]})]})}var uO=v(`/chat/`)({component:AO}),dO=[{label:`Planning`,states:[`Planning`]},{label:`Needs Approval`,states:[`PendingApproval`]},{label:`In Progress`,states:[`Queued`,`Running`,`Reviewing`]},{label:`Blocked`,states:[`Blocked`]},{label:`Review`,states:[`PendingDecision`]},{label:`Done`,states:[`Approved`,`Merged`,`Cancelled`]}],fO={Planning:`bg-info`,Queued:`bg-info`,Running:`bg-primary animate-pulse`,Reviewing:`bg-secondary animate-pulse`,PendingApproval:`bg-warning`,PendingDecision:`bg-warning`,Blocked:`bg-error`,Merged:`bg-success`,Approved:`bg-success`,Cancelled:`bg-neutral`},pO={Planning:`info`,Queued:`info`,Running:`primary`,Reviewing:`secondary`,PendingApproval:`warning`,PendingDecision:`warning`,Blocked:`error`,Merged:`success`,Approved:`success`,Cancelled:`neutral`},mO=[`Create an issue`,`What's the project status?`,`Check services`,`Show blocked issues`],hO=[`Explain the plan`,`What's blocking this?`,`Retry execution`,`Show the diff`];function gO(e){if(!e)return``;let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=Date.now()-t.getTime();return n<5e3?`just now`:n<6e4?`${Math.round(n/1e3)}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:n<864e5?`${Math.round(n/36e5)}h ago`:`${Math.round(n/864e5)}d ago`}function _O(e,t){if(!t||e.role!==t.role)return!0;let n=new Date(e.timestamp).getTime(),r=new Date(t.timestamp).getTime();return Number.isNaN(n)||Number.isNaN(r)?!1:Math.abs(n-r)>5*6e4}var vO={p:({children:e})=>(0,K.jsx)(`p`,{className:`mb-2 last:mb-0`,children:e}),ul:({children:e})=>(0,K.jsx)(`ul`,{className:`list-disc list-inside mb-2 space-y-0.5`,children:e}),ol:({children:e})=>(0,K.jsx)(`ol`,{className:`list-decimal list-inside mb-2 space-y-0.5`,children:e}),li:({children:e})=>(0,K.jsx)(`li`,{children:e}),strong:({children:e})=>(0,K.jsx)(`strong`,{className:`font-semibold`,children:e}),code:({inline:e,children:t})=>e?(0,K.jsx)(`code`,{className:`bg-base-300/60 px-1 py-0.5 rounded text-[0.85em] font-mono`,children:t}):(0,K.jsx)(`code`,{children:t}),pre:({children:e})=>(0,K.jsx)(`pre`,{className:`my-2 rounded-lg bg-base-300/60 px-3 py-2 text-xs leading-relaxed overflow-x-auto font-mono`,children:e}),h1:({children:e})=>(0,K.jsx)(`h3`,{className:`font-bold text-base mb-1`,children:e}),h2:({children:e})=>(0,K.jsx)(`h3`,{className:`font-bold text-sm mb-1`,children:e}),h3:({children:e})=>(0,K.jsx)(`h4`,{className:`font-semibold text-sm mb-1`,children:e}),blockquote:({children:e})=>(0,K.jsx)(`blockquote`,{className:`border-l-2 border-base-content/20 pl-3 italic opacity-70 mb-2`,children:e}),hr:()=>(0,K.jsx)(`hr`,{className:`border-base-content/10 my-2`}),a:({href:e,children:t})=>(0,K.jsx)(`a`,{href:e,className:`underline opacity-80 hover:opacity-100`,target:`_blank`,rel:`noopener noreferrer`,children:t})};function yO(e){return e?(0,K.jsx)(qD,{components:vO,children:e}):null}function bO(){return(0,K.jsx)(`div`,{className:`flex items-start gap-3 chat-msg-in`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 px-3 py-2.5 rounded-2xl rounded-tl-md bg-base-200/60`,children:[(0,K.jsx)(`span`,{className:`typing-dot size-1.5 rounded-full bg-base-content/40`,style:{animationDelay:`0ms`}}),(0,K.jsx)(`span`,{className:`typing-dot size-1.5 rounded-full bg-base-content/40`,style:{animationDelay:`150ms`}}),(0,K.jsx)(`span`,{className:`typing-dot size-1.5 rounded-full bg-base-content/40`,style:{animationDelay:`300ms`}})]})})}function xO({error:e,onRetry:t}){return(0,K.jsxs)(`div`,{className:`flex items-start gap-2.5 px-3 py-2.5 bg-error/8 border border-error/15 rounded-xl text-sm animate-fade-in max-w-lg`,children:[(0,K.jsx)(ni,{className:`size-3.5 text-error/70 shrink-0 mt-0.5`}),(0,K.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,K.jsx)(`span`,{className:`text-error/70 text-xs leading-relaxed`,children:e})}),t&&(0,K.jsx)(`button`,{className:`btn btn-ghost btn-xs text-error/70 shrink-0`,onClick:t,children:`Retry`})]})}function SO({role:e,content:t,timestamp:n,actions:r,sessionId:i,showTime:a}){let o=e===`user`;return(0,K.jsxs)(`div`,{className:`flex flex-col ${o?`items-end`:`items-start`} gap-0.5 ${o?`chat-msg-out`:`chat-msg-in`}`,children:[(0,K.jsx)(`div`,{className:`max-w-[85%] md:max-w-[70%] text-sm leading-relaxed px-3.5 py-2.5 ${o?`bg-primary text-primary-content rounded-2xl rounded-br-md`:`bg-base-200/60 text-base-content rounded-2xl rounded-tl-md`}`,style:{wordBreak:`break-word`},children:o?t:yO(t)}),!o&&Array.isArray(r)&&r.length>0&&(0,K.jsx)(`div`,{className:`flex flex-col gap-2 mt-1.5 max-w-[85%] md:max-w-[70%]`,children:r.map((e,t)=>(0,K.jsx)(lO,{action:e,sessionId:i},t))}),a&&n&&(0,K.jsx)(`span`,{className:`text-[10px] text-base-content/25 px-1 mt-0.5 select-none`,children:gO(n)})]})}function CO({onSuggestion:e,selectedIssue:t}){let n=t?hO:mO;return(0,K.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center px-5 pb-8`,children:(0,K.jsxs)(`div`,{className:`w-full max-w-md space-y-6 animate-fade-in-up`,children:[t?(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`div`,{className:`text-base-content/40 text-sm`,children:`Discussing`}),(0,K.jsxs)(`div`,{className:`bg-base-200/40 rounded-xl px-4 py-3 border border-base-300/50`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`size-2 rounded-full shrink-0 ${fO[t.state]||`bg-base-content/20`}`}),(0,K.jsx)(`span`,{className:`font-mono text-xs text-base-content/50`,children:t.identifier})]}),(0,K.jsx)(`div`,{className:`text-sm font-medium mt-1 text-base-content/80`,children:t.title}),t.description&&(0,K.jsx)(`div`,{className:`text-xs text-base-content/40 mt-1.5 line-clamp-2 leading-relaxed`,children:t.description})]})]}):(0,K.jsxs)(`div`,{className:`space-y-1 text-center`,children:[(0,K.jsx)(`h2`,{className:`text-xl font-semibold text-base-content/80`,children:`Hey. What are you working on?`}),(0,K.jsx)(`p`,{className:`text-sm text-base-content/35`,children:`Ask about your project, manage issues, or just think out loud.`})]}),(0,K.jsx)(`div`,{className:`flex gap-2 overflow-x-auto pb-1 -mx-1 px-1 no-scrollbar`,children:n.map(t=>(0,K.jsx)(`button`,{className:`chip-suggestion shrink-0 text-xs px-3.5 py-2 rounded-full border border-base-300/60 text-base-content/50 bg-base-100 hover:border-primary/30 hover:text-primary/70 hover:bg-primary/5 transition-all duration-150 active:scale-95 whitespace-nowrap`,onClick:()=>e(t),children:t},t))})]})})}function wO({issue:e,onDeselect:t}){if(!e)return null;let n=pO[e.state]||`neutral`;return(0,K.jsxs)(`div`,{className:`flex items-center gap-2.5 px-4 py-2 shrink-0 animate-fade-in`,style:{background:`color-mix(in oklab, var(--color-${n}) 6%, transparent)`,borderBottom:`1px solid color-mix(in oklab, var(--color-${n}) 15%, transparent)`},children:[(0,K.jsx)(`span`,{className:`size-2 rounded-full shrink-0 ${fO[e.state]||`bg-base-content/20`}`}),(0,K.jsx)(`span`,{className:`text-xs font-mono font-semibold truncate`,style:{color:`var(--color-${n})`},children:e.identifier}),(0,K.jsx)(`span`,{className:`text-xs text-base-content/50 truncate flex-1 min-w-0`,children:e.title}),(0,K.jsx)(`button`,{className:`btn btn-ghost btn-xs btn-circle shrink-0 opacity-40 hover:opacity-80`,onClick:t,"aria-label":`Clear issue context`,children:(0,K.jsx)(li,{className:`size-3`})})]})}function TO({issue:e,isSelected:t,onToggle:n}){let r=fO[e.state]||`bg-base-content/20`;return(0,K.jsxs)(`button`,{className:`w-full flex items-center gap-2 px-2.5 py-1.5 rounded-lg text-left text-xs transition-all duration-150 ${t?`bg-primary/8 text-base-content border-l-2 border-l-primary pl-2`:`text-base-content/60 hover:bg-base-200/60 border-l-2 border-l-transparent`}`,onClick:()=>n(e),title:`${e.identifier}: ${e.title}`,children:[(0,K.jsx)(`span`,{className:`size-1.5 rounded-full shrink-0 ${r}`}),(0,K.jsx)(`span`,{className:`font-mono shrink-0 ${t?`text-primary/70`:`opacity-40`}`,children:e.identifier}),(0,K.jsx)(`span`,{className:`truncate flex-1`,children:e.title})]})}function EO({label:e,issues:t,selectedIssueId:n,onToggle:r,defaultCollapsed:i}){let[a,o]=(0,G.useState)(i??!1);return(0,K.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,K.jsxs)(`button`,{className:`flex items-center gap-1.5 px-2.5 py-1 w-full text-left text-[10px] font-semibold uppercase tracking-wider text-base-content/30 hover:text-base-content/50 transition-colors`,onClick:()=>o(e=>!e),children:[(0,K.jsx)(a?Sn:bn,{className:`size-2.5`}),(0,K.jsx)(`span`,{children:e}),(0,K.jsx)(`span`,{className:`ml-auto font-mono text-base-content/20`,children:t.length})]}),!a&&t.map(e=>(0,K.jsx)(TO,{issue:e,isSelected:e.id===n,onToggle:r},e.id))]})}function DO({issues:e,selectedIssueId:t,onToggle:n,search:r,onSearchChange:i}){let a=(0,G.useMemo)(()=>{let t=r.toLowerCase(),n=t?e.filter(e=>`${e.identifier} ${e.title}`.toLowerCase().includes(t)):e;return dO.map(e=>({...e,issues:n.filter(t=>e.states.includes(t.state)).sort((e,t)=>(t.updatedAt||t.createdAt||``).localeCompare(e.updatedAt||e.createdAt||``))})).filter(e=>e.issues.length>0)},[e,r]),o=e.length;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`px-3 pt-3 pb-1.5 shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`span`,{className:`text-xs font-semibold text-base-content/60`,children:`Issues`}),o>0&&(0,K.jsx)(`span`,{className:`text-[10px] font-mono text-base-content/25 bg-base-200/60 rounded-full px-1.5 py-0.5`,children:o})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Lr,{className:`size-3 absolute left-2.5 top-1/2 -translate-y-1/2 text-base-content/25`}),(0,K.jsx)(`input`,{className:`input input-xs input-bordered w-full pl-7 text-xs bg-base-200/30 border-base-300/50 rounded-lg`,placeholder:`Search...`,value:r,onChange:e=>i(e.target.value)}),r&&(0,K.jsx)(`button`,{className:`absolute right-1.5 top-1/2 -translate-y-1/2 btn btn-ghost btn-xs btn-circle size-4`,onClick:()=>i(``),"aria-label":`Clear search`,children:(0,K.jsx)(li,{className:`size-2.5`})})]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto min-h-0 px-1.5 py-1.5 space-y-2.5`,children:a.length===0?(0,K.jsx)(`div`,{className:`text-xs text-base-content/25 text-center py-8`,children:r?`No matches`:`No issues yet`}):a.map(e=>(0,K.jsx)(EO,{label:e.label,issues:e.issues,selectedIssueId:t,onToggle:n,defaultCollapsed:e.label===`Done`},e.label))})]})}function OO({activeTab:e,setActiveTab:t,issueCount:n}){return(0,K.jsxs)(`div`,{className:`flex border-b border-base-300 bg-base-100 shrink-0 md:hidden`,children:[(0,K.jsxs)(`button`,{className:`flex-1 py-2.5 text-xs font-medium text-center transition-colors relative ${e===`chat`?`text-primary`:`text-base-content/40`}`,onClick:()=>t(`chat`),children:[`Chat`,e===`chat`&&(0,K.jsx)(`span`,{className:`absolute bottom-0 left-1/4 right-1/4 h-0.5 bg-primary rounded-full`})]}),(0,K.jsxs)(`button`,{className:`flex-1 py-2.5 text-xs font-medium text-center transition-colors relative ${e===`issues`?`text-primary`:`text-base-content/40`}`,onClick:()=>t(`issues`),children:[`Issues`,n>0&&(0,K.jsx)(`span`,{className:`ml-1 text-[10px] font-mono text-base-content/25`,children:n}),e===`issues`&&(0,K.jsx)(`span`,{className:`absolute bottom-0 left-1/4 right-1/4 h-0.5 bg-primary rounded-full`})]})]})}function kO({visible:e,onClick:t}){return e?(0,K.jsx)(`button`,{className:`absolute bottom-20 left-1/2 -translate-x-1/2 btn btn-circle btn-sm bg-base-200/80 border-base-300/50 shadow-lg backdrop-blur-sm hover:bg-base-200 transition-all duration-200 z-10 animate-fade-in`,onClick:t,"aria-label":`Scroll to bottom`,children:(0,K.jsx)(cn,{className:`size-3.5 text-base-content/50`})}):null}function AO(){let e=eO(),{issues:t}=tn(),n=w(),[r,i]=(0,G.useState)(``),[a,o]=(0,G.useState)(!0),[s,c]=(0,G.useState)(``),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)(null),[h,g]=(0,G.useState)([]),[_,v]=(0,G.useState)(`chat`),[y,b]=(0,G.useState)(!1),x=(0,G.useRef)(null),S=(0,G.useRef)(null),C=(0,G.useRef)(0),T=(0,G.useMemo)(()=>l?t.find(e=>e.id===l)??null:null,[l,t]),E=e.isSending||d,D=e.error||p;(0,G.useEffect)(()=>{let t=t=>{let n=t.detail?.issueId;n&&n!==l&&(u(n),g([]),m(null),e.selectSession(null),v(`chat`))};return window.addEventListener(`spark:chat:select-issue`,t),()=>window.removeEventListener(`spark:chat:select-issue`,t)},[l,e]);let O=(0,G.useCallback)(()=>{x.current&&x.current.scrollTo({top:x.current.scrollHeight,behavior:`smooth`})},[]);(0,G.useEffect)(()=>{x.current&&e.messages.length!==C.current&&(C.current=e.messages.length,O())},[e.messages.length,O]),(0,G.useEffect)(()=>{E&&O()},[E,O]),(0,G.useEffect)(()=>{S.current?.focus()},[e.currentSessionId]),(0,G.useEffect)(()=>{let e=x.current;if(!e)return;let t=()=>{b(e.scrollHeight-e.scrollTop-e.clientHeight>200)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]);let k=(0,G.useCallback)(t=>{l===t.id?u(null):u(t.id),e.selectSession(null),m(null),g([])},[l,e]),A=(0,G.useCallback)(()=>{u(null),e.selectSession(null),m(null),g([])},[e]),j=(0,G.useCallback)(async t=>{if(!t?.trim()||E)return;let n=t.trim();if(!l){e.sendMessage(n);return}g(e=>[...e,{role:`user`,content:n,timestamp:new Date().toISOString()}]),f(!0),m(null);try{let e=await U.post(`/chat`,{message:n,issueId:l,history:h.filter(e=>e.role===`user`||e.role===`assistant`).map(e=>({role:e.role,content:e.content}))});e.response&&g(t=>[...t,{role:`assistant`,content:e.response,actions:e.actions,timestamp:new Date().toISOString()}])}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(!1)}},[E,l,e,n]),M=(0,G.useCallback)(()=>{let e=r.trim();e&&(i(``),S.current&&(S.current.style.height=`auto`),j(e))},[r,j]),N=(0,G.useCallback)(e=>{E||(v(`chat`),j(e))},[E,j]),P=(0,G.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),M()),e.key===`Escape`&&(e.preventDefault(),S.current?.blur())},[M]),F=(0,G.useCallback)(e=>{i(e.target.value);let t=e.target;t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,120)}px`},[]),I=(0,G.useCallback)(()=>{let t=e.messages;for(let n=t.length-1;n>=0;n--)if(t[n].role===`user`){e.clearError(),m(null),j(t[n].content);return}},[e,j]),[,L]=(0,G.useState)(0);(0,G.useEffect)(()=>{if(e.messages.length===0&&t.length===0)return;let n=setInterval(()=>L(e=>e+1),3e4);return()=>clearInterval(n)},[e.messages.length,t.length]);let R=e.lastResponse?.provider??null,z=l?h:e.messages,B=(0,G.useMemo)(()=>z.map(e=>({role:e.role,content:e.content,timestamp:e.timestamp||e.createdAt||e.updatedAt,actions:e.actions})),[z]),V=B.length>0,ee=(0,G.useCallback)(e=>{k(e),v(`chat`)},[k]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`style`,{children:`
65
+ .chat-msg-in { animation: chatSlideInLeft 220ms ease-out both; }
66
+ .chat-msg-out { animation: chatSlideInRight 220ms ease-out both; }
67
+ @keyframes chatSlideInLeft {
68
+ from { opacity: 0; transform: translateX(-10px); }
69
+ to { opacity: 1; transform: translateX(0); }
70
+ }
71
+ @keyframes chatSlideInRight {
72
+ from { opacity: 0; transform: translateX(10px); }
73
+ to { opacity: 1; transform: translateX(0); }
74
+ }
75
+ .typing-dot {
76
+ animation: typingDot 1.2s ease-in-out infinite;
77
+ }
78
+ @keyframes typingDot {
79
+ 0%, 60%, 100% { opacity: 0.25; transform: scale(0.85); }
80
+ 30% { opacity: 1; transform: scale(1.1); }
81
+ }
82
+ .chip-suggestion:hover {
83
+ transform: translateY(-1px);
84
+ }
85
+ .no-scrollbar::-webkit-scrollbar { display: none; }
86
+ .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
87
+ .chat-input-wrap:focus-within {
88
+ box-shadow: 0 0 0 2px color-mix(in oklab, var(--color-primary) 20%, transparent);
89
+ border-color: color-mix(in oklab, var(--color-primary) 40%, transparent);
90
+ }
91
+ .send-btn:active:not(:disabled) {
92
+ transform: scale(0.88);
93
+ }
94
+ `}),(0,K.jsxs)(`div`,{className:`flex-1 flex min-h-0`,children:[(0,K.jsx)(`aside`,{className:`${a?`w-[240px]`:`w-0`} hidden md:flex flex-col border-r border-base-300/60 bg-base-100 shrink-0 transition-all duration-200 overflow-hidden`,children:(0,K.jsx)(DO,{issues:t,selectedIssueId:l,onToggle:k,search:s,onSearchChange:c})}),(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 min-h-0`,children:[(0,K.jsx)(OO,{activeTab:_,setActiveTab:v,issueCount:t.length}),(0,K.jsxs)(`div`,{className:`hidden md:flex items-center gap-2 px-3 py-1.5 border-b border-base-300/50 shrink-0 bg-base-100`,children:[(0,K.jsx)(`button`,{className:`btn btn-ghost btn-xs btn-square opacity-30 hover:opacity-70`,onClick:()=>o(e=>!e),"aria-label":`Toggle sidebar`,children:a?(0,K.jsx)(Sn,{className:`size-3.5 rotate-180`}):(0,K.jsx)(Sn,{className:`size-3.5`})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-1 min-w-0`,children:[(0,K.jsx)(Kr,{className:`size-3 text-primary/40`}),(0,K.jsx)(`span`,{className:`text-xs font-medium text-base-content/50`,children:`Spark Chat`})]}),R&&(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-base-content/20 shrink-0`,children:[`via `,R]})]}),_===`issues`&&(0,K.jsx)(`div`,{className:`flex-1 flex flex-col min-h-0 md:hidden bg-base-100`,children:(0,K.jsx)(DO,{issues:t,selectedIssueId:l,onToggle:ee,search:s,onSearchChange:c})}),(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 ${_===`chat`?`flex`:`hidden md:flex`}`,children:[(0,K.jsx)(wO,{issue:T,onDeselect:A}),(0,K.jsxs)(`div`,{ref:x,className:`flex-1 overflow-y-auto min-h-0 relative`,children:[(0,K.jsx)(`div`,{className:`max-w-2xl mx-auto px-4 py-4 space-y-3`,children:!V&&!E?(0,K.jsx)(CO,{onSuggestion:N,selectedIssue:T}):V?(0,K.jsxs)(K.Fragment,{children:[B.map((t,n)=>(0,K.jsx)(SO,{role:t.role,content:t.content,timestamp:t.timestamp,actions:t.actions,sessionId:e.currentSessionId,showTime:_O(t,B[n-1])},`${e.currentSessionId}-${n}`)),E&&(0,K.jsx)(bO,{}),D&&(0,K.jsx)(xO,{error:D,onRetry:I})]}):e.isSessionLoading?(0,K.jsx)(`div`,{className:`flex-1 flex items-center justify-center py-20`,children:(0,K.jsx)(gr,{className:`size-5 animate-spin text-base-content/20`})}):(0,K.jsx)(CO,{onSuggestion:N,selectedIssue:T})}),(0,K.jsx)(kO,{visible:y&&V,onClick:O})]}),(0,K.jsx)(`div`,{className:`shrink-0 bg-base-100 border-t border-base-300/40 pb-[env(safe-area-inset-bottom)]`,children:(0,K.jsxs)(`div`,{className:`max-w-2xl mx-auto px-3 py-3`,children:[(0,K.jsxs)(`div`,{className:`chat-input-wrap flex items-end gap-0 bg-base-200/40 border border-base-300/50 rounded-2xl px-3 py-1.5 transition-all duration-200`,children:[(0,K.jsx)(`textarea`,{ref:S,className:`flex-1 bg-transparent border-none outline-none resize-none text-sm leading-relaxed py-1.5 placeholder:text-base-content/25 min-h-[24px]`,rows:1,placeholder:T?`Ask about ${T.identifier}...`:`What can I help with?`,value:r,onChange:F,onKeyDown:P,disabled:E,style:{maxHeight:`120px`}}),(0,K.jsx)(`button`,{className:`send-btn shrink-0 size-8 rounded-xl flex items-center justify-center transition-all duration-150 ml-1 ${r.trim()?`bg-primary text-primary-content hover:brightness-110`:`bg-base-300/50 text-base-content/20`}`,onClick:M,disabled:E||!r.trim(),"aria-label":`Send message`,title:`Send (Enter)`,children:E?(0,K.jsx)(gr,{className:`size-3.5 animate-spin`}):(0,K.jsx)(Rr,{className:`size-3.5`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between mt-1.5 px-1`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-base-content/15`,children:`Enter to send, Shift+Enter for newline`}),R&&(0,K.jsxs)(`span`,{className:`text-[10px] text-base-content/15 md:hidden`,children:[`via `,R]})]})]})})]})]})]})]})}var jO=(0,G.lazy)(()=>To(()=>import(`./OnboardingWizard-BmI50ZUv.js`),__vite__mapDeps([6,1,5,2]))),MO=[`auto`,`light`,`dark`],NO=`cupcake.bumblebee.emerald.corporate.synthwave.retro.cyberpunk.valentine.halloween.garden.forest.aqua.lofi.pastel.fantasy.wireframe.black.luxury.dracula.cmyk.autumn.business.acid.lemonade.night.coffee.winter.dim.nord.sunset.caramellatte.abyss.silk`.split(`.`),PO=[...MO,...NO];function FO(e){return e===`auto`?window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:e}function IO({theme:e,onThemeChange:t}){let n=FO(e),r=[`dark`,`night`,`sunset`,`black`,`synthwave`,`halloween`,`forest`,`luxury`,`dracula`,`business`,`coffee`,`dim`,`abyss`].includes(n);return(0,K.jsx)(`div`,{className:`card bg-base-200`,children:(0,K.jsxs)(`div`,{className:`card-body gap-4 p-6`,children:[(0,K.jsxs)(`h3`,{className:`card-title text-sm flex items-center gap-2`,children:[(0,K.jsx)(Cr,{className:`size-4 opacity-50`}),`Theme`]}),(0,K.jsxs)(`p`,{className:`text-xs opacity-50`,children:[`Current: `,(0,K.jsx)(`span`,{className:`font-semibold`,children:e}),e===`auto`&&(0,K.jsxs)(`span`,{children:[` (resolved to `,n,`)`]}),r?(0,K.jsx)(br,{className:`inline size-3 ml-1`}):(0,K.jsx)(Yr,{className:`inline size-3 ml-1`})]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:PO.map(n=>(0,K.jsx)(`button`,{className:`btn btn-sm ${e===n?`btn-primary`:`btn-soft`}`,onClick:()=>t(n),children:n.charAt(0).toUpperCase()+n.slice(1)},n))})]})})}function LO({status:e,wsStatus:t}){let n=e===`ok`,r=t===`connected`,i=n?`text-success`:`text-warning`,a=n?`Connected`:e===`offline`?`Offline`:`Degraded`,o={connected:`text-success`,connecting:`text-info`,disconnected:`text-warning`,error:`text-error`}[t]||`text-warning`,s=t.charAt(0).toUpperCase()+t.slice(1);return(0,K.jsx)(`div`,{className:`card bg-base-200`,children:(0,K.jsxs)(`div`,{className:`card-body gap-4 p-6`,children:[(0,K.jsxs)(`h3`,{className:`card-title text-sm flex items-center gap-2`,children:[(0,K.jsx)(Ar,{className:`size-4 opacity-50`}),`Connection Status`]}),(0,K.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 p-3 rounded-box bg-base-300`,children:[(0,K.jsxs)(`span`,{className:`relative flex size-5 items-center justify-center`,children:[n&&(0,K.jsx)(`span`,{className:`animate-ping absolute inline-flex size-3 rounded-full bg-success opacity-30`}),(0,K.jsx)(En,{className:`size-5 ${i} relative`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-sm font-medium`,children:`API`}),(0,K.jsx)(`div`,{className:`text-xs ${i}`,children:a})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 p-3 rounded-box bg-base-300`,children:[(0,K.jsxs)(`span`,{className:`relative flex size-5 items-center justify-center`,children:[r&&(0,K.jsx)(`span`,{className:`animate-ping absolute inline-flex size-3 rounded-full bg-success opacity-30`}),r?(0,K.jsx)(si,{className:`size-5 ${o} relative`}):(0,K.jsx)(oi,{className:`size-5 ${o} relative`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-sm font-medium`,children:`WebSocket`}),(0,K.jsx)(`div`,{className:`text-xs ${o}`,children:s})]})]})]})]})})}function RO({pwa:e}){let t=e?.isInstalled?`Installed`:e?.canInstall?`Installable`:`Browser-managed`,n=e?.displayMode?e.displayMode.replaceAll(`-`,` `):`browser`,r=e?.serviceWorkerSupported?e?.serviceWorkerRegistered?`Registered`:`Not registered`:`Unavailable`,i=e?.updateAvailable?`Ready to apply`:`Current`;return(0,K.jsx)(`div`,{className:`card bg-base-200`,children:(0,K.jsxs)(`div`,{className:`card-body gap-4 p-6`,children:[(0,K.jsxs)(`h3`,{className:`card-title text-sm flex items-center gap-2`,children:[(0,K.jsx)(Gr,{className:`size-4 opacity-50`}),`Progressive Web App`]}),(0,K.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,K.jsxs)(`div`,{className:`rounded-box bg-base-300 p-3`,children:[(0,K.jsx)(`div`,{className:`text-xs opacity-50`,children:`Service worker`}),(0,K.jsx)(`div`,{className:`text-sm font-medium mt-1`,children:r})]}),(0,K.jsxs)(`div`,{className:`rounded-box bg-base-300 p-3`,children:[(0,K.jsx)(`div`,{className:`text-xs opacity-50`,children:`Install status`}),(0,K.jsx)(`div`,{className:`text-sm font-medium mt-1`,children:t})]}),(0,K.jsxs)(`div`,{className:`rounded-box bg-base-300 p-3`,children:[(0,K.jsx)(`div`,{className:`text-xs opacity-50`,children:`Display mode`}),(0,K.jsx)(`div`,{className:`text-sm font-medium mt-1 capitalize`,children:n})]}),(0,K.jsxs)(`div`,{className:`rounded-box bg-base-300 p-3`,children:[(0,K.jsx)(`div`,{className:`text-xs opacity-50`,children:`Runtime state`}),(0,K.jsx)(`div`,{className:`text-sm font-medium mt-1`,children:e?.isOnline?`Online`:`Offline shell`})]}),(0,K.jsxs)(`div`,{className:`rounded-box bg-base-300 p-3`,children:[(0,K.jsx)(`div`,{className:`text-xs opacity-50`,children:`App version`}),(0,K.jsx)(`div`,{className:`text-sm font-medium mt-1 font-mono`,children:e?.serviceWorkerVersion??`Unavailable`})]}),(0,K.jsxs)(`div`,{className:`rounded-box bg-base-300 p-3`,children:[(0,K.jsx)(`div`,{className:`text-xs opacity-50`,children:`Update`}),(0,K.jsx)(`div`,{className:`text-sm font-medium mt-1`,children:i})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsxs)(`button`,{className:`btn btn-sm btn-primary gap-1`,onClick:()=>e.installApp(),disabled:!e?.canInstall,children:[(0,K.jsx)(zn,{className:`size-3.5`}),` Install`]}),(0,K.jsxs)(`button`,{className:`btn btn-sm btn-soft gap-1`,onClick:()=>e.applyUpdate(),disabled:!e?.updateAvailable,children:[(0,K.jsx)(Mr,{className:`size-3.5`}),` Apply update`]})]})]})})}function zO({notifications:e}){if(!e?.supported)return(0,K.jsx)(`div`,{className:`card bg-base-200`,children:(0,K.jsxs)(`div`,{className:`card-body gap-4 p-6`,children:[(0,K.jsxs)(`h3`,{className:`card-title text-sm flex items-center gap-2`,children:[(0,K.jsx)(fn,{className:`size-4 opacity-50`}),`Notifications`]}),(0,K.jsx)(`p`,{className:`text-xs opacity-50`,children:`Desktop notifications are not supported in this browser.`})]})});let t=e.permission===`denied`,n=e.permission===`granted`,r=e.eventSettings||[];return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`div`,{className:`card bg-base-200`,children:(0,K.jsxs)(`div`,{className:`card-body gap-4 p-6`,children:[(0,K.jsxs)(`h3`,{className:`card-title text-sm flex items-center gap-2`,children:[(0,K.jsx)(pn,{className:`size-4 opacity-50`}),`Desktop Notifications`]}),(0,K.jsx)(`p`,{className:`text-xs opacity-50`,children:`Get notified when issues change state — reviews needed, agents blocked, work completed.`}),(0,K.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,K.jsxs)(`div`,{className:`rounded-box bg-base-300 p-3`,children:[(0,K.jsx)(`div`,{className:`text-xs opacity-50`,children:`Permission`}),(0,K.jsx)(`div`,{className:`text-sm font-medium mt-1 ${n?`text-success`:t?`text-error`:`text-warning`}`,children:e.permission===`default`?`Not asked yet`:e.permission})]}),(0,K.jsxs)(`div`,{className:`rounded-box bg-base-300 p-3`,children:[(0,K.jsx)(`div`,{className:`text-xs opacity-50`,children:`Status`}),(0,K.jsx)(`div`,{className:`text-sm font-medium mt-1 ${e.enabled?`text-success`:``}`,children:e.enabled?`Enabled`:`Disabled`})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!n&&!t&&(0,K.jsxs)(`button`,{className:`btn btn-sm btn-primary gap-1`,onClick:e.requestPermission,children:[(0,K.jsx)(pn,{className:`size-3.5`}),` Enable notifications`]}),n&&(0,K.jsxs)(`label`,{className:`label cursor-pointer gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm`,children:`Notify on state changes`}),(0,K.jsx)(`input`,{type:`checkbox`,className:`toggle toggle-sm toggle-primary`,checked:e.enabled,onChange:t=>e.setEnabled(t.target.checked)})]}),t&&(0,K.jsx)(`p`,{className:`text-xs text-error`,children:`Notifications were denied. Reset permission in your browser settings to re-enable.`}),n&&e.enabled&&(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost`,onClick:()=>new Notification(`fifony`,{body:`Notifications are working!`,icon:`/icon.svg`}),children:`Send test`})]})]})}),n&&e.enabled&&r.length>0&&(0,K.jsx)(`div`,{className:`card bg-base-200`,children:(0,K.jsxs)(`div`,{className:`card-body gap-4 p-6`,children:[(0,K.jsxs)(`h3`,{className:`card-title text-sm flex items-center gap-2`,children:[(0,K.jsx)(ai,{className:`size-4 opacity-50`}),`Event Types`]}),(0,K.jsx)(`p`,{className:`text-xs opacity-50`,children:`Choose which events trigger notifications.`}),ht.map(t=>{let n=r.filter(e=>e.group===t.id);return n.length===0?null:(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`div`,{className:`text-xs font-semibold opacity-40 uppercase tracking-wider`,children:t.label}),n.map(t=>(0,K.jsxs)(`label`,{className:`flex items-center gap-3 py-2 px-3 rounded-lg hover:bg-base-300 transition-colors cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`toggle toggle-xs toggle-primary`,checked:t.enabled,onChange:n=>e.setEventEnabled(t.id,n.target.checked)}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`text-sm font-medium flex items-center gap-2`,children:[t.label,t.sound&&(0,K.jsx)(ii,{className:`size-3 opacity-30`,title:`Plays sound`})]}),(0,K.jsx)(`div`,{className:`text-xs opacity-40`,children:t.description})]})]},t.id))]},t.id)})]})})]})}function BO(){let[e,t]=(0,G.useState)(!1),n=w();return e?(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(`div`,{className:`min-h-screen flex items-center justify-center`,children:(0,K.jsx)(`span`,{className:`loading loading-spinner loading-lg`})}),children:(0,K.jsx)(jO,{onComplete:()=>{t(!1),n.invalidateQueries({queryKey:Ge})}})}):(0,K.jsx)(`div`,{className:`card bg-base-200`,children:(0,K.jsxs)(`div`,{className:`card-body gap-4 p-6`,children:[(0,K.jsxs)(`h3`,{className:`card-title text-sm flex items-center gap-2`,children:[(0,K.jsx)(ai,{className:`size-4 opacity-50`}),`Setup Wizard`]}),(0,K.jsx)(`p`,{className:`text-xs opacity-50`,children:`Re-run the initial setup wizard to reconfigure providers, effort level, concurrency, and theme.`}),(0,K.jsxs)(`button`,{className:`btn btn-sm btn-primary gap-1 w-fit`,onClick:async()=>{try{await U.post(`/settings/ui.onboarding.completed`,{scope:`ui`,value:!1,source:`user`}),n.setQueryData(Ge,e=>ge(e,{id:`ui.onboarding.completed`,scope:`ui`,value:!1,source:`user`,updatedAt:new Date().toISOString()}))}catch{}t(!0)},children:[(0,K.jsx)(ai,{className:`size-3.5`}),` Re-run Setup Wizard`]})]})})}var VO=v(`/settings/system`)({component:XO}),HO=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform),UO=[`palette`,`navigation`,`global`,`drawer`,`kanban`,`issues`],WO={palette:{label:`Command Palette`,icon:Fn,color:`text-primary`,badge:`badge-primary`},navigation:{label:`Navigation`,icon:tr,color:`text-info`,badge:`badge-info`},global:{label:`Global`,icon:lr,color:`text-secondary`,badge:`badge-secondary`},drawer:{label:`Issue Detail`,icon:wr,color:`text-success`,badge:`badge-success`},kanban:{label:`Kanban Board`,icon:Pn,color:`text-warning`,badge:`badge-warning`},issues:{label:`Issues List`,icon:hr,color:`text-error`,badge:`badge-error`}};function GO(e){return(e||``).replace(/mod/gi,HO?`⌘`:`Ctrl`).replace(/ctrl/gi,`Ctrl`).replace(/alt/gi,`Alt`).replace(/shift/gi,`Shift`).replace(/enter/gi,`↵ Enter`).replace(/escape/gi,`Esc`).replace(/slash/gi,`/`).split(`+`)}function KO(){let{hotkeys:e}=_o(),t=(0,G.useMemo)(()=>{let t=new Map,n=new Set;for(let r of e){let e=r.description,i=r.metadata?.group;if(!e||!i)continue;let a=`${i}:${e}`;n.has(a)||(n.add(a),t.has(i)||t.set(i,[]),t.get(i).push(r))}let r=[];for(let e of UO)t.has(e)&&r.push({group:e,...WO[e],shortcuts:t.get(e)});return r},[e]),n=t.reduce((e,t)=>e+t.shortcuts.length,0);return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h3`,{className:`font-semibold text-sm flex items-center gap-2`,children:[(0,K.jsx)(lr,{className:`size-4 opacity-50`}),`Keyboard Shortcuts`]}),(0,K.jsxs)(`p`,{className:`text-xs opacity-50 mt-0.5`,children:[n,` shortcuts across `,t.length,` contexts. Press `,(0,K.jsx)(`kbd`,{className:`kbd kbd-xs`,children:`Shift`}),`+`,(0,K.jsx)(`kbd`,{className:`kbd kbd-xs`,children:`/`}),` anywhere to see them.`,(0,K.jsx)(`span`,{className:`ml-2 badge badge-ghost badge-xs font-mono`,children:HO?`macOS`:`Linux / Windows`})]})]})}),t.map(({group:e,label:t,icon:n,color:r,badge:i,shortcuts:a})=>(0,K.jsxs)(`div`,{className:`bg-base-300 rounded-box overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`px-4 py-2.5 flex items-center gap-2 border-b border-base-content/10`,children:[(0,K.jsx)(n,{className:`size-3.5 ${r}`}),(0,K.jsx)(`span`,{className:`text-xs font-semibold`,children:t}),(0,K.jsx)(`span`,{className:`badge badge-xs ${i}`,children:a.length})]}),(0,K.jsx)(`div`,{className:`divide-y divide-base-content/5`,children:a.map((e,t)=>{let n=GO(e.hotkey);return(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 hover:bg-base-100/30 transition-colors`,children:[(0,K.jsx)(`span`,{className:`text-xs`,children:e.description}),(0,K.jsx)(`div`,{className:`flex items-center gap-1`,children:n.map((e,t)=>(0,K.jsxs)(`span`,{className:`flex items-center`,children:[t>0&&(0,K.jsx)(`span`,{className:`text-xs opacity-20 mx-0.5`,children:`+`}),(0,K.jsx)(`kbd`,{className:`kbd kbd-xs font-mono`,children:e.trim()})]},t))})]},t)})})]},e)),(0,K.jsxs)(`p`,{className:`text-xs opacity-40`,children:[`Shortcuts are context-aware. `,(0,K.jsx)(`strong`,{children:`Drawer`}),` shortcuts only work when an issue detail is open.`,(0,K.jsx)(`strong`,{children:` Kanban`}),` and `,(0,K.jsx)(`strong`,{children:`Issues`}),` shortcuts work on their respective pages.`]})]})}function qO(){let[e,t]=(0,G.useState)(null),[n,r]=(0,G.useState)(!0),[i,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(``),c=(0,G.useCallback)(async()=>{try{t((await U.get(`/dev-profile`))?.profile??null),s(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{r(!1)}},[]);(0,G.useEffect)(()=>{c();let e=setInterval(c,15e3);return()=>clearInterval(e)},[c]);let l=(0,G.useCallback)(async e=>{a(e);try{t((await U.post(e,{}))?.profile??null),s(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(``)}},[]);return{profile:e,loading:n,error:o,busyAction:i,refresh:c,bootstrap:()=>l(`/dev-profile/bootstrap`),reset:()=>l(`/dev-profile/reset`)}}function JO(){let{profile:e,loading:t,error:n,busyAction:r,bootstrap:i,reset:a}=qO();return(0,K.jsx)(`div`,{className:`card bg-base-200 border border-base-300`,children:(0,K.jsxs)(`div`,{className:`card-body p-4 gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wider opacity-60`,children:`Dev profile`}),(0,K.jsx)(`p`,{className:`mt-1 text-xs opacity-50`,children:`Isolated worktree + separate Fifony state for local harness experimentation.`})]}),t?(0,K.jsx)(q,{className:`size-4 animate-spin opacity-40`}):null]}),e?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,K.jsxs)(`div`,{className:`rounded-xl border border-base-300 bg-base-100/70 px-3 py-2.5`,children:[(0,K.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider opacity-45`,children:`Bootstrapped`}),(0,K.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:e.bootstrapped?`yes`:`no`}),(0,K.jsx)(`div`,{className:`text-xs opacity-50`,children:e.worktreeAttached?`worktree attached`:`worktree missing`})]}),(0,K.jsxs)(`div`,{className:`rounded-xl border border-base-300 bg-base-100/70 px-3 py-2.5`,children:[(0,K.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider opacity-45`,children:`Workspace`}),(0,K.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:e.workspaceExists?`present`:`missing`}),(0,K.jsx)(`div`,{className:`text-xs opacity-50 break-all`,children:e.workspaceRoot})]}),(0,K.jsxs)(`div`,{className:`rounded-xl border border-base-300 bg-base-100/70 px-3 py-2.5`,children:[(0,K.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider opacity-45`,children:`State`}),(0,K.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:e.persistenceExists?`present`:`empty`}),(0,K.jsx)(`div`,{className:`text-xs opacity-50 break-all`,children:e.persistenceRoot})]}),(0,K.jsxs)(`div`,{className:`rounded-xl border border-base-300 bg-base-100/70 px-3 py-2.5`,children:[(0,K.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider opacity-45`,children:`Runbooks`}),(0,K.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:e.bootstrapFiles?.runbooks?.length||0}),(0,K.jsxs)(`div`,{className:`text-xs opacity-50`,children:[e.trashEntries?.length||0,` reset snapshot(s)`]})]})]}),(0,K.jsxs)(`div`,{className:`rounded-xl border border-base-300 bg-base-100/70 px-3 py-2.5`,children:[(0,K.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider opacity-45`,children:`Launch command`}),(0,K.jsx)(`div`,{className:`mt-1 font-mono text-xs break-all opacity-75`,children:e.launchCommand})]})]}):(0,K.jsx)(`div`,{className:`rounded-xl border border-base-300 bg-base-100/70 px-3 py-2.5 text-xs opacity-50`,children:`Dev profile data is not available yet.`}),n?(0,K.jsx)(`div`,{className:`rounded-xl border border-error/20 bg-error/5 px-3 py-2.5 text-xs text-error`,children:n}):null,(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,K.jsxs)(`button`,{className:`btn btn-xs btn-primary gap-1`,onClick:i,disabled:r!==``,children:[r===`/dev-profile/bootstrap`?(0,K.jsx)(q,{className:`size-3 animate-spin`}):(0,K.jsx)(Gn,{className:`size-3`}),`Bootstrap`]}),(0,K.jsxs)(`button`,{className:`btn btn-xs btn-ghost text-error gap-1`,onClick:a,disabled:r!==``,children:[r===`/dev-profile/reset`?(0,K.jsx)(q,{className:`size-3 animate-spin`}):(0,K.jsx)(ei,{className:`size-3`}),`Reset to trash`]})]})]})})}function YO(){let e=Ne(),t=Pe(),n=Fe(),r=e.data?.snapshot??null,i=t.data??null,a=Array.isArray(n.data?.checks)?n.data.checks:[],o=a.filter(e=>e.status===`fail`).length,s=a.filter(e=>e.status===`warn`).length;return e.isLoading&&n.isLoading?(0,K.jsx)(`div`,{className:`grid gap-3 lg:grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)]`,children:[0,1].map(e=>(0,K.jsx)(`div`,{className:`card bg-base-200 border border-base-300 animate-pulse`,children:(0,K.jsxs)(`div`,{className:`card-body p-4 gap-3`,children:[(0,K.jsx)(`div`,{className:`h-4 w-40 rounded bg-base-300`}),(0,K.jsx)(`div`,{className:`h-3 w-full rounded bg-base-300`}),(0,K.jsx)(`div`,{className:`h-3 w-3/4 rounded bg-base-300`}),(0,K.jsx)(`div`,{className:`h-20 rounded bg-base-300`})]})},e))}):(0,K.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)]`,children:[(0,K.jsx)(`div`,{className:`card bg-base-200 border border-base-300`,children:(0,K.jsxs)(`div`,{className:`card-body p-4 gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wider opacity-60`,children:`Runtime health`}),(0,K.jsx)(`p`,{className:`mt-1 text-xs opacity-50`,children:`Operational snapshot for provider, agents, services, and memory flushes.`})]}),(0,K.jsx)(`div`,{className:`badge badge-sm ${r?.ok?`badge-success`:`badge-warning`}`,children:r?.ok?`healthy`:`attention`})]}),r?(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2 xl:grid-cols-3`,children:[(0,K.jsxs)(`div`,{className:`rounded-xl border border-base-300 bg-base-100/70 px-3 py-2.5`,children:[(0,K.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider opacity-45`,children:`Provider`}),(0,K.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:r.providers.configuredProvider}),(0,K.jsxs)(`div`,{className:`text-xs opacity-50`,children:[r.providers.available.filter(e=>e.available).length,` detected`]})]}),(0,K.jsxs)(`div`,{className:`rounded-xl border border-base-300 bg-base-100/70 px-3 py-2.5`,children:[(0,K.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider opacity-45`,children:`Issues`}),(0,K.jsxs)(`div`,{className:`mt-1 text-sm font-medium`,children:[r.issues.running,` running · `,r.issues.reviewing,` reviewing`]}),(0,K.jsxs)(`div`,{className:`text-xs opacity-50`,children:[r.issues.total,` total issues`]})]}),(0,K.jsxs)(`div`,{className:`rounded-xl border border-base-300 bg-base-100/70 px-3 py-2.5`,children:[(0,K.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider opacity-45`,children:`Services`}),(0,K.jsxs)(`div`,{className:`mt-1 text-sm font-medium`,children:[r.services.running,`/`,r.services.total,` running`]}),(0,K.jsxs)(`div`,{className:`text-xs opacity-50`,children:[r.services.crashed,` crashed · `,r.services.starting,` starting`]})]}),(0,K.jsxs)(`div`,{className:`rounded-xl border border-base-300 bg-base-100/70 px-3 py-2.5`,children:[(0,K.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider opacity-45`,children:`Agents`}),(0,K.jsxs)(`div`,{className:`mt-1 text-sm font-medium`,children:[r.agents.active,` active`]}),(0,K.jsxs)(`div`,{className:`text-xs opacity-50`,children:[r.agents.crashed,` crashed · `,r.agents.idle,` idle`]})]}),(0,K.jsxs)(`div`,{className:`rounded-xl border border-base-300 bg-base-100/70 px-3 py-2.5`,children:[(0,K.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider opacity-45`,children:`Memory`}),(0,K.jsxs)(`div`,{className:`mt-1 text-sm font-medium`,children:[r.memory.totalFlushes,` flushes`]}),(0,K.jsxs)(`div`,{className:`text-xs opacity-50`,children:[r.memory.issuesWithFlushes,` issue workspaces seeded`]})]}),(0,K.jsxs)(`div`,{className:`rounded-xl border border-base-300 bg-base-100/70 px-3 py-2.5`,children:[(0,K.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider opacity-45`,children:`Probe`}),(0,K.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:i?.ok?`passing`:`degraded`}),(0,K.jsxs)(`div`,{className:`text-xs opacity-50`,children:[o,` fail · `,s,` warn`]})]})]}):(0,K.jsx)(`div`,{className:`rounded-xl border border-warning/20 bg-warning/5 px-3 py-2.5 text-xs text-warning`,children:`Runtime health data is not available right now.`})]})}),(0,K.jsx)(`div`,{className:`card bg-base-200 border border-base-300`,children:(0,K.jsxs)(`div`,{className:`card-body p-4 gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wider opacity-60`,children:`Doctor`}),(0,K.jsx)(`p`,{className:`mt-1 text-xs opacity-50`,children:`Detailed checks for workspace git, providers, services, agents, and memory.`})]}),n.isFetching?(0,K.jsx)(q,{className:`size-3.5 animate-spin opacity-40`}):null]}),a.length>0?(0,K.jsx)(`div`,{className:`space-y-2`,children:a.map(e=>(0,K.jsx)(`div`,{className:`rounded-xl border px-3 py-2.5 ${e.status===`fail`?`border-error/20 bg-error/5 text-error`:e.status===`warn`?`border-warning/20 bg-warning/5 text-warning`:`border-success/20 bg-success/5 text-success`}`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(`div`,{className:`mt-1 size-2.5 shrink-0 rounded-full bg-current`}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wider`,children:e.title}),(0,K.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-base-content/70`,children:e.summary}),e.suggestedAction?(0,K.jsxs)(`p`,{className:`mt-1 text-[11px] text-base-content/55`,children:[`Action: `,e.suggestedAction]}):null]})]})},e.id))}):(0,K.jsx)(`div`,{className:`rounded-xl border border-base-300 bg-base-100/70 px-3 py-2.5 text-xs opacity-50`,children:`No doctor checks available yet.`})]})})]})}function XO(){let e=tn();return(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsx)(LO,{status:e.status,wsStatus:e.wsStatus}),(0,K.jsx)(RO,{pwa:e.pwa}),(0,K.jsx)(BO,{}),(0,K.jsx)(`div`,{className:`card bg-base-200`,children:(0,K.jsx)(`div`,{className:`card-body p-4 gap-4`,children:(0,K.jsx)(KO,{})})}),(0,K.jsx)(JO,{}),(0,K.jsx)(YO,{}),(0,K.jsx)(IO,{theme:e.theme,onThemeChange:e.setTheme})]})}var ZO=[`variables`];function QO(){return j({queryKey:ZO,queryFn:()=>U.get(`/variables`),staleTime:1e4})}function $O(e){return Array.isArray(e?.variables)?e.variables:[]}function ek(){let e=w();return{upsert:async(t,n,r)=>{let i=`${r}:${t}`,a=await U.put(`/variables/${encodeURIComponent(i)}`,{key:t,value:n,scope:r});e.setQueryData(ZO,e=>{let o=$O(e),s=o.findIndex(e=>e.id===i),c=a?.variable??{id:i,key:t,value:n,scope:r,updatedAt:new Date().toISOString()};if(s>=0){let t=[...o];return t[s]=c,{...e,variables:t}}return{...e,variables:[...o,c]}})},remove:async t=>{await U.delete(`/variables/${encodeURIComponent(t)}`),e.setQueryData(ZO,e=>({...e,variables:$O(e).filter(e=>e.id!==t)}))}}}function tk({icon:e,title:t,description:n,children:r}){return(0,K.jsx)(`div`,{className:`card bg-base-200`,children:(0,K.jsxs)(`div`,{className:`card-body p-4 gap-3`,children:[(0,K.jsxs)(`h3`,{className:`font-semibold text-sm flex items-center gap-2`,children:[e&&(0,K.jsx)(e,{className:`size-4 opacity-50`}),t]}),n&&(0,K.jsx)(`p`,{className:`text-xs opacity-50`,children:n}),r]})})}var nk=v(`/settings/services`)({component:uk}),rk=/^[A-Za-z_][A-Za-z0-9_]*$/;function ik({variable:e,onDelete:t,onUpdate:n}){let[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(e.key),[s,c]=(0,G.useState)(e.value),[l,u]=(0,G.useState)(!1),d=async()=>{if(!(!a.trim()||!rk.test(a.trim()))){u(!0);try{await n(e.key,a.trim(),s,e.scope),i(!1)}finally{u(!1)}}};return r?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5`,children:[(0,K.jsx)(`input`,{className:`input input-xs input-bordered font-mono w-36`,value:a,onChange:e=>o(e.target.value),placeholder:`KEY`}),(0,K.jsx)(`span`,{className:`text-xs opacity-30`,children:`=`}),(0,K.jsx)(`input`,{className:`input input-xs input-bordered font-mono flex-1 min-w-0`,value:s,onChange:e=>c(e.target.value),placeholder:`value`,onKeyDown:e=>{e.key===`Enter`&&d(),e.key===`Escape`&&i(!1)}}),(0,K.jsx)(`button`,{className:`btn btn-xs btn-success btn-square`,onClick:d,disabled:l,children:l?(0,K.jsx)(q,{className:`size-3 animate-spin`}):(0,K.jsx)(yn,{className:`size-3`})}),(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost btn-square`,onClick:()=>i(!1),children:(0,K.jsx)(li,{className:`size-3`})})]}):(0,K.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5 group`,children:[(0,K.jsx)(`span`,{className:`font-mono text-xs text-primary w-36 truncate`,children:e.key}),(0,K.jsx)(`span`,{className:`text-xs opacity-30`,children:`=`}),(0,K.jsx)(`span`,{className:`font-mono text-xs flex-1 min-w-0 truncate opacity-70`,children:e.value||(0,K.jsx)(`span`,{className:`opacity-30 italic`,children:`empty`})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost btn-square`,onClick:()=>i(!0),title:`Edit`,children:(0,K.jsx)(Dr,{className:`size-3`})}),(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost btn-square text-error`,onClick:async()=>{u(!0);try{await t(e.id)}finally{u(!1)}},disabled:l,title:`Delete`,children:l?(0,K.jsx)(q,{className:`size-3 animate-spin`}):(0,K.jsx)(ei,{className:`size-3`})})]})]})}function ak({scope:e,onAdd:t}){let[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(``),f=async()=>{let n=i.trim();if(!n){d(`Key is required.`);return}if(!rk.test(n)){d(`Invalid key "${n}".`);return}d(``),l(!0);try{await t(n,o,e),a(``),s(``),r(!1)}finally{l(!1)}};return n?(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{autoFocus:!0,className:`input input-xs input-bordered font-mono w-36`,value:i,onChange:e=>a(e.target.value),placeholder:`KEY`}),(0,K.jsx)(`span`,{className:`text-xs opacity-30`,children:`=`}),(0,K.jsx)(`input`,{className:`input input-xs input-bordered font-mono flex-1 min-w-0`,value:o,onChange:e=>s(e.target.value),placeholder:`value`,onKeyDown:e=>{e.key===`Enter`&&f(),e.key===`Escape`&&(r(!1),a(``),s(``))}}),(0,K.jsx)(`button`,{className:`btn btn-xs btn-primary btn-square`,onClick:f,disabled:c,children:c?(0,K.jsx)(q,{className:`size-3 animate-spin`}):(0,K.jsx)(yn,{className:`size-3`})}),(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost btn-square`,onClick:()=>{r(!1),a(``),s(``),d(``)},children:(0,K.jsx)(li,{className:`size-3`})})]}),u&&(0,K.jsx)(`p`,{className:`text-xs text-error`,children:u})]}):(0,K.jsxs)(`button`,{className:`btn btn-xs btn-ghost gap-1 opacity-50 hover:opacity-100`,onClick:()=>r(!0),children:[(0,K.jsx)(kr,{className:`size-3`}),` Add variable`]})}function ok({scope:e,variables:t,onUpdate:n,onDelete:r,onAdd:i}){let a=t.filter(t=>t.scope===e);return(0,K.jsxs)(`div`,{className:`space-y-0.5`,children:[a.length===0&&(0,K.jsx)(`p`,{className:`text-xs opacity-30 py-1`,children:`No variables set.`}),a.map(e=>(0,K.jsx)(ik,{variable:e,onDelete:r,onUpdate:n},e.id)),(0,K.jsx)(`div`,{className:`pt-1`,children:(0,K.jsx)(ak,{scope:e,onAdd:i})})]})}var sk={running:`text-success fill-success`,starting:`text-warning fill-warning`,stopping:`text-warning fill-warning`,crashed:`text-error fill-error`,stopped:`text-base-content/20 fill-base-content/20`};function ck({service:e,variables:t,onSave:n,onDelete:r,onVariableUpdate:i,onVariableDelete:a,onVariableAdd:o}){let[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)({name:e.name,command:e.command,cwd:e.cwd||``,autoStart:!!e.autoStart,autoRestart:!!e.autoRestart,maxCrashes:e.maxCrashes??5}),[p,m]=(0,G.useState)(!1),h=sk[e.state??(e.running?`running`:`stopped`)]??`text-base-content/20 fill-base-content/20`,g=t.filter(t=>t.scope===e.id);return(0,G.useEffect)(()=>{s||f({name:e.name,command:e.command,cwd:e.cwd||``,autoStart:!!e.autoStart,autoRestart:!!e.autoRestart,maxCrashes:e.maxCrashes??5})},[e,s]),(0,K.jsx)(`div`,{className:`card bg-base-200`,children:(0,K.jsxs)(`div`,{className:`card-body p-4 gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(kn,{className:`size-2.5 shrink-0 ${h}`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-sm`,children:e.name}),e.cwd&&(0,K.jsx)(`span`,{className:`text-xs opacity-30 font-mono ml-2`,children:e.cwd}),(0,K.jsx)(`div`,{className:`font-mono text-xs opacity-40 truncate mt-0.5`,children:e.command})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[(0,K.jsxs)(`button`,{className:`btn btn-xs btn-ghost gap-1 ${l?`text-primary`:`opacity-50 hover:opacity-100`}`,onClick:()=>u(e=>!e),children:[`Variables`,g.length>0&&(0,K.jsx)(`span`,{className:`badge badge-xs badge-primary`,children:g.length})]}),(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost ${s?`text-primary`:`opacity-50 hover:opacity-100`}`,onClick:()=>c(e=>!e),title:`Edit service`,children:(0,K.jsx)(Dr,{className:`size-3`})}),(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost text-error opacity-50 hover:opacity-100`,onClick:async()=>{confirm(`Remove service "${e.name}"?`)&&await r(e.id)},title:`Delete service`,children:(0,K.jsx)(ei,{className:`size-3`})})]})]}),l&&(0,K.jsxs)(`div`,{className:`pl-5 border-l border-base-content/10 ml-1`,children:[(0,K.jsx)(`p`,{className:`text-xs opacity-40 mb-1.5`,children:`These override global variables for this service.`}),(0,K.jsx)(ok,{scope:e.id,variables:t,onUpdate:i,onDelete:a,onAdd:o})]}),s&&(0,K.jsxs)(`div`,{className:`pl-5 border-l border-base-content/10 ml-1 space-y-2 pt-1`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:[(0,K.jsxs)(`label`,{className:`form-control`,children:[(0,K.jsx)(`div`,{className:`label py-0.5`,children:(0,K.jsx)(`span`,{className:`label-text text-xs`,children:`Name`})}),(0,K.jsx)(`input`,{className:`input input-bordered input-sm`,value:d.name,onChange:e=>f(t=>({...t,name:e.target.value}))})]}),(0,K.jsxs)(`label`,{className:`form-control`,children:[(0,K.jsx)(`div`,{className:`label py-0.5`,children:(0,K.jsx)(`span`,{className:`label-text text-xs`,children:`Working directory`})}),(0,K.jsx)(`input`,{className:`input input-bordered input-sm font-mono text-xs`,value:d.cwd,onChange:e=>f(t=>({...t,cwd:e.target.value})),placeholder:`(project root)`})]})]}),(0,K.jsxs)(`label`,{className:`form-control`,children:[(0,K.jsx)(`div`,{className:`label py-0.5`,children:(0,K.jsx)(`span`,{className:`label-text text-xs`,children:`Command`})}),(0,K.jsx)(`input`,{className:`input input-bordered input-sm font-mono text-xs`,value:d.command,onChange:e=>f(t=>({...t,command:e.target.value})),placeholder:`pnpm dev`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-x-6 gap-y-2`,children:[(0,K.jsxs)(`label`,{className:`label cursor-pointer justify-start gap-2 p-0`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`checkbox checkbox-sm checkbox-primary`,checked:d.autoStart,onChange:e=>f(t=>({...t,autoStart:e.target.checked}))}),(0,K.jsx)(`span`,{className:`label-text text-xs`,children:`Auto-start on boot`})]}),(0,K.jsxs)(`label`,{className:`label cursor-pointer justify-start gap-2 p-0`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`checkbox checkbox-sm checkbox-primary`,checked:d.autoRestart,onChange:e=>f(t=>({...t,autoRestart:e.target.checked}))}),(0,K.jsx)(`span`,{className:`label-text text-xs`,children:`Auto-restart on crash`})]})]}),d.autoRestart&&(0,K.jsxs)(`label`,{className:`form-control w-40`,children:[(0,K.jsx)(`div`,{className:`label py-0.5`,children:(0,K.jsx)(`span`,{className:`label-text text-xs`,children:`Max crashes before giving up`})}),(0,K.jsx)(`input`,{type:`number`,className:`input input-bordered input-sm`,min:1,max:10,value:d.maxCrashes,onChange:e=>f(t=>({...t,maxCrashes:Math.min(10,Math.max(1,Number(e.target.value)||1))}))})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,K.jsxs)(`button`,{className:`btn btn-xs btn-primary gap-1`,onClick:async()=>{if(!(!d.name.trim()||!d.command.trim())){m(!0);try{await n({...e,...d,name:d.name.trim(),command:d.command.trim(),cwd:d.cwd.trim()||void 0,maxCrashes:d.autoRestart?d.maxCrashes:void 0}),c(!1)}finally{m(!1)}}},disabled:p,children:[p?(0,K.jsx)(q,{className:`size-3 animate-spin`}):(0,K.jsx)(yn,{className:`size-3`}),` Save`]}),(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost`,onClick:()=>c(!1),children:`Cancel`})]})]})]})})}function lk({onAdd:e,onCancel:t}){let[n,r]=(0,G.useState)({name:``,command:``,cwd:``,autoStart:!1,autoRestart:!1,maxCrashes:5}),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)([]),[c,l]=(0,G.useState)(!1),u=async()=>{a(!0);try{s((await U.get(`/services/detect`))?.suggestions??[])}finally{a(!1)}},d=e=>{r(t=>({...t,name:e.label,command:e.command,cwd:e.cwd||``})),s([])};return(0,K.jsx)(`div`,{className:`card bg-base-200 border border-primary/20`,children:(0,K.jsxs)(`div`,{className:`card-body p-4 gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-xs font-semibold opacity-60 uppercase tracking-wider`,children:`New service`}),(0,K.jsxs)(`button`,{className:`btn btn-xs btn-ghost gap-1 opacity-60 hover:opacity-100`,onClick:u,disabled:i,children:[i?(0,K.jsx)(q,{className:`size-3 animate-spin`}):(0,K.jsx)(Kr,{className:`size-3`}),`Detect`]})]}),o.length>0&&(0,K.jsxs)(`div`,{className:`rounded-lg border border-primary/20 bg-primary/5 p-2.5 space-y-2`,children:[(0,K.jsx)(`span`,{className:`text-xs opacity-60`,children:`Click to use a detected command:`}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:o.map((e,t)=>(0,K.jsxs)(`button`,{className:`btn btn-xs btn-outline btn-primary gap-1`,onClick:()=>d(e),children:[(0,K.jsx)(kr,{className:`size-3`}),e.label]},t))}),(0,K.jsx)(`button`,{className:`text-xs opacity-40 hover:opacity-70`,onClick:()=>s([]),children:`dismiss`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:[(0,K.jsxs)(`label`,{className:`form-control`,children:[(0,K.jsx)(`div`,{className:`label py-0.5`,children:(0,K.jsx)(`span`,{className:`label-text text-xs`,children:`Name *`})}),(0,K.jsx)(`input`,{className:`input input-bordered input-sm`,value:n.name,onChange:e=>r(t=>({...t,name:e.target.value})),placeholder:`API server`})]}),(0,K.jsxs)(`label`,{className:`form-control`,children:[(0,K.jsx)(`div`,{className:`label py-0.5`,children:(0,K.jsx)(`span`,{className:`label-text text-xs`,children:`Working directory`})}),(0,K.jsx)(`input`,{className:`input input-bordered input-sm font-mono text-xs`,value:n.cwd,onChange:e=>r(t=>({...t,cwd:e.target.value})),placeholder:`(project root)`})]})]}),(0,K.jsxs)(`label`,{className:`form-control`,children:[(0,K.jsx)(`div`,{className:`label py-0.5`,children:(0,K.jsx)(`span`,{className:`label-text text-xs`,children:`Command *`})}),(0,K.jsx)(`input`,{className:`input input-bordered input-sm font-mono text-xs`,value:n.command,onChange:e=>r(t=>({...t,command:e.target.value})),placeholder:`pnpm dev`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-x-6 gap-y-2`,children:[(0,K.jsxs)(`label`,{className:`label cursor-pointer justify-start gap-2 p-0`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`checkbox checkbox-sm checkbox-primary`,checked:n.autoStart,onChange:e=>r(t=>({...t,autoStart:e.target.checked}))}),(0,K.jsx)(`span`,{className:`label-text text-xs`,children:`Auto-start on boot`})]}),(0,K.jsxs)(`label`,{className:`label cursor-pointer justify-start gap-2 p-0`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`checkbox checkbox-sm checkbox-primary`,checked:n.autoRestart,onChange:e=>r(t=>({...t,autoRestart:e.target.checked}))}),(0,K.jsx)(`span`,{className:`label-text text-xs`,children:`Auto-restart on crash`})]})]}),n.autoRestart&&(0,K.jsxs)(`label`,{className:`form-control w-40`,children:[(0,K.jsx)(`div`,{className:`label py-0.5`,children:(0,K.jsx)(`span`,{className:`label-text text-xs`,children:`Max crashes before giving up`})}),(0,K.jsx)(`input`,{type:`number`,className:`input input-bordered input-sm`,min:1,max:10,value:n.maxCrashes,onChange:e=>r(t=>({...t,maxCrashes:Math.min(10,Math.max(1,Number(e.target.value)||1))}))})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`button`,{className:`btn btn-xs btn-primary gap-1`,onClick:async()=>{let t=n.name.trim(),r=n.command.trim();if(!t||!r)return;let i=`${r.replace(/[^a-zA-Z0-9_-]/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``).slice(0,24)}-${Date.now()}`;l(!0);try{await e({id:i,name:t,command:r,cwd:n.cwd.trim()||void 0,autoStart:n.autoStart,autoRestart:n.autoRestart,maxCrashes:n.autoRestart?n.maxCrashes:void 0})}finally{l(!1)}},disabled:c||!n.name.trim()||!n.command.trim(),children:[c?(0,K.jsx)(q,{className:`size-3 animate-spin`}):(0,K.jsx)(kr,{className:`size-3`}),` Add`]}),(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost`,onClick:t,children:`Cancel`})]})]})})}function uk(){let{services:e,loading:t,refresh:n}=It(),r=QO(),i=$O(r.data),{upsert:a,remove:o}=ek(),[s,c]=(0,G.useState)(!1),l=(0,G.useCallback)(async(e,t,n,r)=>{e!==t&&await o(`${r}:${e}`),await a(t,n,r)},[a,o]),u=(0,G.useCallback)(async e=>{await U.put(`/services/${e.id}`,e),await n()},[n]),d=(0,G.useCallback)(async e=>{await U.delete(`/services/${e}`),await n()},[n]),f=(0,G.useCallback)(async e=>{await U.put(`/services/${e.id}`,e),await n(),c(!1)},[n]);return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(tk,{icon:tr,title:`Global variables`,description:`Environment variables injected into every service on start. Per-service variables below take precedence.`,children:r.isLoading?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 opacity-40`,children:[(0,K.jsx)(q,{className:`size-3 animate-spin`}),(0,K.jsx)(`span`,{className:`text-xs`,children:`Loading…`})]}):(0,K.jsx)(ok,{scope:`global`,variables:i,onUpdate:l,onDelete:o,onAdd:a})}),(0,K.jsx)(tk,{icon:zr,title:`Services`,description:`Dev servers and background processes managed by fifony. Start and view logs from the Services page.`,children:t?(0,K.jsx)(`div`,{className:`space-y-2`,children:[0,1].map(e=>(0,K.jsx)(`div`,{className:`h-12 rounded-lg bg-base-300 animate-pulse`},e))}):(0,K.jsxs)(`div`,{className:`space-y-2`,children:[e.length===0&&!s&&(0,K.jsx)(`p`,{className:`text-xs opacity-40`,children:`No services configured yet.`}),e.map(e=>(0,K.jsx)(ck,{service:e,variables:i,onSave:u,onDelete:d,onVariableUpdate:l,onVariableDelete:o,onVariableAdd:a},e.id)),s?(0,K.jsx)(lk,{onAdd:f,onCancel:()=>c(!1)}):(0,K.jsxs)(`button`,{className:`btn btn-xs btn-ghost gap-1 opacity-60 hover:opacity-100`,onClick:()=>c(!0),children:[(0,K.jsx)(kr,{className:`size-3`}),` Add service`]})]})})]})}var dk=v(`/settings/quality`)({beforeLoad:()=>{throw x({to:`/settings/execution`})}});function fk(){let e=w(),t=me(rt().data),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(2),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(2),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(!1),b=(0,G.useRef)(null),x=(0,G.useRef)(null),S=(0,G.useRef)(null),C=(0,G.useRef)(null),T=(0,G.useRef)(2),E=(0,G.useRef)(!1),D=(0,G.useRef)(!1),O=(0,G.useRef)(2);(0,G.useEffect)(()=>{if(n||!t?.length)return;let e=he(t,`runtime.maxReviewAutoRetries`,2),i=he(t,`runtime.enablePlaywrightReview`,!1),o=he(t,`runtime.autoReplanOnStall`,!1),c=he(t,`runtime.autoReplanStallThreshold`,2);a(e??2),s(i??!1),l(o??!1),d(c??2),T.current=e??2,E.current=i??!1,D.current=o??!1,O.current=c??2,r(!0)},[t,n]);let k=(0,G.useCallback)(async(t,n)=>{await U.post(`/settings/${encodeURIComponent(t)}`,{scope:`runtime`,value:n,source:`user`}),e.setQueryData(Ge,e=>ge(e,{id:t,scope:`runtime`,value:n,source:`user`,updatedAt:new Date().toISOString()}))},[e]),A=e=>{e(!0),setTimeout(()=>e(!1),1500)},j=(0,G.useCallback)(e=>{a(e),T.current=e,b.current&&clearTimeout(b.current),b.current=setTimeout(async()=>{try{await k(`runtime.maxReviewAutoRetries`,T.current),A(p)}catch{}},600)},[k]),M=(0,G.useCallback)(e=>{s(e),E.current=e,x.current&&clearTimeout(x.current),x.current=setTimeout(async()=>{try{await k(`runtime.enablePlaywrightReview`,E.current),A(h)}catch{}},600)},[k]),N=(0,G.useCallback)(e=>{l(e),D.current=e,S.current&&clearTimeout(S.current),S.current=setTimeout(async()=>{try{await k(`runtime.autoReplanOnStall`,D.current),A(_)}catch{}},600)},[k]),P=(0,G.useCallback)(e=>{d(e),O.current=e,C.current&&clearTimeout(C.current),C.current=setTimeout(async()=>{try{await k(`runtime.autoReplanStallThreshold`,O.current),A(y)}catch{}},600)},[k]);(0,G.useEffect)(()=>()=>{[b,x,S,C].forEach(e=>{e.current&&clearTimeout(e.current)})},[]);let F=({show:e})=>e?(0,K.jsxs)(`span`,{className:`text-xs text-success flex items-center gap-1 animate-fade-in`,children:[(0,K.jsx)(yn,{className:`size-3`}),` saved`]}):null;return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(tk,{icon:jr,title:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`Max review retries `,(0,K.jsx)(F,{show:f})]}),description:`How many times the reviewer can automatically request rework before escalating to you. Set to 0 to always ask.`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`input`,{type:`range`,className:`range range-sm range-primary w-40`,min:0,max:5,step:1,value:i,onChange:e=>j(Number(e.target.value))}),(0,K.jsx)(`span`,{className:`text-sm font-mono w-4 text-center`,children:i})]}),(0,K.jsx)(`p`,{className:`text-xs opacity-40`,children:i===0?`Every review result goes directly to Pending Decision.`:`Up to ${i} automatic rework cycle${i>1?`s`:``} before escalating to you.`})]}),(0,K.jsx)(tk,{icon:Vn,title:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`Playwright review `,(0,K.jsx)(F,{show:m})]}),description:`Gives the reviewer browser access to verify UI changes live. Requires a dev server running when issues with frontend changes are reviewed.`,children:(0,K.jsxs)(`label`,{className:`label cursor-pointer justify-start gap-3 p-0`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`toggle toggle-sm toggle-primary`,checked:o,onChange:e=>M(e.target.checked)}),(0,K.jsx)(`span`,{className:`label-text text-sm`,children:o?`Enabled`:`Disabled`})]})}),(0,K.jsx)(tk,{icon:Pr,title:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`Auto-replan on stall `,(0,K.jsx)(F,{show:g})]}),description:`When the same error type repeats N times during execution, automatically trigger a replan instead of retrying. Guarded to at most 4 replans total.`,children:(0,K.jsxs)(`label`,{className:`label cursor-pointer justify-start gap-3 p-0`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`toggle toggle-sm toggle-primary`,checked:c,onChange:e=>N(e.target.checked)}),(0,K.jsx)(`span`,{className:`label-text text-sm`,children:c?`Enabled`:`Disabled`})]})}),c&&(0,K.jsxs)(tk,{icon:null,title:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`Stall threshold `,(0,K.jsx)(F,{show:v})]}),description:`How many consecutive same-error attempts trigger a replan.`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`input`,{type:`range`,className:`range range-sm range-primary w-40`,min:2,max:5,step:1,value:u,onChange:e=>P(Number(e.target.value))}),(0,K.jsx)(`span`,{className:`text-sm font-mono w-4 text-center`,children:u})]}),(0,K.jsxs)(`p`,{className:`text-xs opacity-40`,children:[`A replan triggers after `,u,` attempts with the same error type.`]})]})]})}function pk(e){return!e||e===0?`0`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function mk(e){if(!e)return``;let t=new Date(e),n=new Date,r=t.getTime()-n.getTime();if(r<=0)return`now`;let i=Math.floor(r/(1e3*60*60)),a=Math.floor(i/24);if(a>0)return`${a}d ${i%24}h`;let o=Math.floor(r/(1e3*60)%60);return i>0?`${i}h ${o}m`:`${o}m`}function hk({label:e,period:t,icon:n}){let r=t.inputTokens>0&&t.outputTokens>0;return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 p-3 rounded-lg bg-base-100`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-lg bg-base-300`,children:(0,K.jsx)(n,{className:`size-4 opacity-70`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-xs opacity-60`,children:e}),(0,K.jsxs)(`div`,{className:`font-mono font-semibold text-sm`,children:[pk(t.tokensUsed),` tokens`]}),r&&(0,K.jsxs)(`div`,{className:`flex gap-3 mt-0.5`,children:[(0,K.jsxs)(`span`,{className:`text-[10px] opacity-50 flex items-center gap-0.5`,children:[(0,K.jsx)(cn,{className:`size-2.5`}),` `,pk(t.inputTokens)]}),(0,K.jsxs)(`span`,{className:`text-[10px] opacity-50 flex items-center gap-0.5`,children:[(0,K.jsx)(un,{className:`size-2.5`}),` `,pk(t.outputTokens)]})]})]}),(0,K.jsxs)(`div`,{className:`text-right`,children:[(0,K.jsx)(`div`,{className:`text-xs opacity-60`,children:`sessions`}),(0,K.jsx)(`div`,{className:`font-mono text-sm`,children:t.sessions})]})]})}function gk({percentUsed:e,weeklyLimit:t,weeklyUsed:n}){if(e==null)return null;let r=e>=90?`progress-error`:e>=70?`progress-warning`:`progress-primary`,i=Math.max(0,100-e);return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex justify-between text-xs mb-1`,children:[(0,K.jsx)(`span`,{className:`opacity-60`,children:`Weekly quota`}),(0,K.jsxs)(`span`,{className:`font-mono`,children:[pk(n),` / `,pk(t)]})]}),(0,K.jsx)(`progress`,{className:`progress ${r} w-full progress-animated`,value:e,max:100}),(0,K.jsxs)(`div`,{className:`flex justify-between text-[10px] mt-1`,children:[(0,K.jsxs)(`span`,{className:`opacity-50`,children:[e,`% used`]}),(0,K.jsxs)(`span`,{className:`font-semibold ${i<=10?`text-error`:i<=30?`text-warning`:`text-success`}`,children:[i,`% available`]})]})]})}function _k({nextResetAt:e,resetInfo:t}){let n=mk(e),r=e?new Date(e):null,i=r?r.toLocaleDateString(void 0,{weekday:`long`,month:`short`,day:`numeric`}):``;return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs bg-base-100 rounded-lg px-3 py-2`,children:[(0,K.jsx)(vn,{className:`size-3.5 opacity-50 shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`opacity-50`,children:t}),e&&(0,K.jsxs)(`div`,{className:`font-mono font-medium mt-0.5`,children:[`Resets in `,(0,K.jsx)(`span`,{className:`text-primary`,children:n}),(0,K.jsxs)(`span`,{className:`opacity-40`,children:[` — `,i]})]})]})]})}function vk({label:e,limit:t,used:n}){if(t==null)return null;let r=Math.max(0,t-n),i=Math.max(0,100-Math.round(n/t*100));return(0,K.jsxs)(`div`,{className:`flex justify-between items-center text-xs bg-base-100 rounded-lg px-3 py-2`,children:[(0,K.jsx)(`span`,{className:`opacity-60`,children:e}),(0,K.jsxs)(`span`,{className:`font-mono font-semibold ${i<=10?`text-error`:i<=30?`text-warning`:`text-success`}`,children:[pk(r),` available`]})]})}function yk({models:e,currentModel:t}){let[n,r]=(0,G.useState)(!1);return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`space-y-1`,children:(n?e:e.slice(0,4)).map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg text-sm ${e.slug===t?`bg-primary/10 border border-primary/30`:`bg-base-100`}`,children:[(0,K.jsx)(En,{className:`size-3 ${e.slug===t?`text-primary`:`opacity-30`}`}),(0,K.jsx)(`span`,{className:`font-mono text-xs flex-1 truncate`,children:e.displayName||e.slug}),e.slug===t&&(0,K.jsx)(`span`,{className:`badge badge-xs badge-primary`,children:`active`})]},e.slug))}),e.length>4&&(0,K.jsxs)(`button`,{className:`btn btn-xs btn-ghost mt-1 w-full gap-1`,onClick:()=>r(!n),children:[n?(0,K.jsx)(Cn,{className:`size-3`}):(0,K.jsx)(bn,{className:`size-3`}),n?`Show less`:`+${e.length-4} more`]})]})}function bk(e){return e===`global`?`Global`:e===`session`?`Session`:e.replace(/\b\w/g,e=>e.toUpperCase())}function xk(e){return e===`5h`?`5h`:e===`weekly`?`Week`:e===`daily`?`Daily`:e===`session`?`Session`:e}function Sk({entry:e}){Math.max(0,100-e.percentUsed);let t=e.percentUsed>=90?`progress-error`:e.percentUsed>=70?`progress-warning`:`progress-primary`;return(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between text-[10px] mb-0.5`,children:[(0,K.jsxs)(`span`,{className:`opacity-60 truncate`,children:[bk(e.scope),` · `,xk(e.period)]}),(0,K.jsxs)(`span`,{className:`font-mono shrink-0`,children:[e.percentUsed,`%`]})]}),(0,K.jsx)(`progress`,{className:`progress ${t} w-full h-1.5`,value:e.percentUsed,max:100})]})})}function Ck({rateLimits:e}){return!e||e.length===0?null:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h4`,{className:`text-xs font-semibold uppercase tracking-wide opacity-50 mb-2`,children:`Rate limits`}),(0,K.jsx)(`div`,{className:`space-y-2 bg-base-100 rounded-lg p-3`,children:e.map((e,t)=>(0,K.jsx)(Sk,{entry:e},`${e.scope}-${e.period}-${t}`))})]})}function wk({provider:e}){let{name:t,available:n,models:r,currentModel:i,usage:a,resetInfo:o,nextResetAt:s,weeklyLimitEstimate:c,percentUsed:l,version:u,plan:d,account:f,effort:p,rateLimits:m}=e,h=t===`claude`?`Claude Code`:t===`codex`?`Codex CLI`:t,g=t===`claude`?`text-warning`:`text-info`,_=a.last5Hours??a.today;return(0,K.jsx)(`div`,{className:`card bg-base-200`,children:(0,K.jsxs)(`div`,{className:`card-body gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Rn,{className:`size-5 ${g}`}),(0,K.jsx)(`h3`,{className:`card-title text-sm`,children:h}),u&&(0,K.jsxs)(`span`,{className:`badge badge-xs badge-ghost font-mono`,children:[`v`,u]})]}),(0,K.jsx)(`span`,{className:`badge badge-sm ${n?`badge-success`:`badge-error`}`,children:n?`available`:`not found`})]}),(d||f||p)&&(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[d&&(0,K.jsxs)(`span`,{className:`badge badge-xs badge-outline gap-1`,children:[(0,K.jsx)(Hr,{className:`size-2.5`}),` `,d]}),f&&(0,K.jsx)(`span`,{className:`badge badge-xs badge-ghost font-mono truncate max-w-[200px]`,children:f}),p&&(0,K.jsxs)(`span`,{className:`badge badge-xs badge-outline gap-1`,children:[(0,K.jsx)(Xn,{className:`size-2.5`}),` `,p]})]}),i&&(0,K.jsxs)(`div`,{className:`text-xs opacity-60`,children:[`Active model: `,(0,K.jsx)(`span`,{className:`font-mono font-medium opacity-100`,children:i})]}),(0,K.jsx)(gk,{percentUsed:l,weeklyLimit:c,weeklyUsed:a.thisWeek.tokensUsed}),(0,K.jsx)(vk,{label:`This week remaining`,limit:c,used:a.thisWeek.tokensUsed}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h4`,{className:`text-xs font-semibold uppercase tracking-wide opacity-50`,children:`Token usage`}),(0,K.jsx)(hk,{label:`Last 5h`,period:_,icon:jn}),(0,K.jsx)(hk,{label:`Today`,period:a.today,icon:ui}),(0,K.jsx)(hk,{label:`This week`,period:a.thisWeek,icon:nr}),(0,K.jsx)(hk,{label:`All time`,period:a.allTime,icon:jn})]}),(0,K.jsx)(Ck,{rateLimits:m}),(0,K.jsx)(_k,{nextResetAt:s,resetInfo:o}),r.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h4`,{className:`text-xs font-semibold uppercase tracking-wide opacity-50 mb-2`,children:[`Available Models (`,r.length,`)`]}),(0,K.jsx)(yk,{models:r,currentModel:i})]})]})})}function Tk({providersUsage:e}){let t=e?.data,n=t?.providers||[];return e?.isLoading&&!t?(0,K.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[...[,,]].map((e,t)=>(0,K.jsx)(`div`,{className:`skeleton-card h-72`,style:{animationDelay:`${t*100}ms`}},t))}):n.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 gap-2 opacity-50 animate-fade-in-up`,children:[(0,K.jsx)(Rn,{className:`size-8`}),(0,K.jsx)(`p`,{className:`text-sm`,children:`No providers detected`})]}):(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 stagger-children`,children:n.map(e=>(0,K.jsx)(wk,{provider:e},e.name))}),t?.collectedAt&&(0,K.jsxs)(`p`,{className:`text-xs opacity-40 text-center`,children:[`Last collected: `,new Date(t.collectedAt).toLocaleTimeString()]})]})}var Ek=v(`/settings/providers`)({component:Dk});function Dk(){return(0,K.jsx)(Tk,{providersUsage:Ve()})}var Ok=new Set([`main`,`master`]),kk=v(`/settings/project`)({component:Ak});function Ak(){let e=w(),t=rt(),n=me(t.data),[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(`local`),[l,u]=(0,G.useState)(``),[d,f]=(0,G.useState)(null),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(!0),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(``),[x,S]=(0,G.useState)(!1),[C,T]=(0,G.useState)(null),[E,D]=(0,G.useState)(null),[O,k]=(0,G.useState)(!1),[A,j]=(0,G.useState)(null),[M,N]=(0,G.useState)(!1),[P,F]=(0,G.useState)(!1),I=(0,G.useRef)(null),L=(0,G.useRef)(null),R=(0,G.useRef)(null),z=(0,G.useCallback)((t,n,r)=>{e.setQueryData(Ge,e=>ge(e,{id:t,scope:r,value:n,source:`user`,updatedAt:new Date().toISOString()}))},[e]);(0,G.useEffect)(()=>()=>{I.current&&clearTimeout(I.current),L.current&&clearTimeout(L.current)},[]),(0,G.useEffect)(()=>{g(!0),Promise.allSettled([U.get(`/state`),U.get(`/git/status`)]).then(([e,t])=>{let n=e.status===`fulfilled`?e.value:null;if(n&&typeof n==`object`){R.current=n;let e=Gt(n.detectedProjectName||``);!p&&(n.config?.defaultBranch||e)&&m(n.config?.defaultBranch||e)}t.status===`fulfilled`&&t.value&&(f(t.value),t.value.branch&&!p&&m(t.value.branch))}).finally(()=>{g(!1)})},[]),(0,G.useEffect)(()=>{if(r||t.isLoading)return;i(!0);let e=he(n,`runtime.mergeMode`,`local`);(e===`local`||e===`push-pr`)&&c(e);let a=he(n,`runtime.prBaseBranch`,``);typeof a==`string`&&u(a);let s=Zt(n,R.current||{});o(s.projectName||``),!l&&s.projectName&&u(s.detectedProjectName||p||a||``)},[n,t.isLoading,r]);let B=(0,G.useCallback)(async()=>{g(!0);try{let[e,t]=await Promise.all([U.get(`/state`),U.get(`/git/status`)]);R.current=e,e?.config?.defaultBranch&&m(e.config.defaultBranch),t&&(f(t),t.branch&&m(t.branch))}finally{g(!1)}},[]),V=(0,G.useCallback)(e=>{e(!0),setTimeout(()=>e(!1),1400)},[]),ee=(0,G.useCallback)(e=>{I.current&&clearTimeout(I.current);let t=Gt(e);t&&(I.current=setTimeout(async()=>{try{await U.post(`/settings/${encodeURIComponent(Xt)}`,{scope:`system`,value:t,source:`user`}),z(Xt,t,`system`),V(N)}catch{}},600))},[z,V]),te=(0,G.useCallback)((e,t)=>{L.current&&clearTimeout(L.current),L.current=setTimeout(async()=>{try{await U.post(`/settings/runtime.mergeMode`,{scope:`runtime`,value:e,source:`user`}),z(`runtime.mergeMode`,e,`runtime`),await U.post(`/settings/runtime.prBaseBranch`,{scope:`runtime`,value:t.trim(),source:`user`}),z(`runtime.prBaseBranch`,t.trim(),`runtime`),V(F)}catch{}},600)},[z,V]),H=(0,G.useCallback)(()=>{v(!0),b(p||``),T(null),D(null)},[p]),ne=(0,G.useCallback)(async()=>{let e=y.trim();if(!(!(/^[a-zA-Z0-9/_.-]+$/.test(e)&&e.length>0)||e===p)){S(!0),T(null);try{let t=await U.post(`/git/switch`,{branchName:e});if(!t?.ok)throw Error(t?.error||`Failed to switch branch.`);m(e),D({branch:e,created:!!t.created}),v(!1),!l&&s===`push-pr`&&u(e),s||c(`local`),await B(),!s&&l===``&&u(e)}catch(e){T(e instanceof Error?e.message:String(e))}finally{S(!1)}}},[y,p,s,l,B]),re=(0,G.useCallback)(async()=>{k(!0),j(null);try{let e=await U.post(`/git/init`,{});if(!e?.ok)throw Error(e?.error||`Failed to initialize git.`);await B()}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}},[B]),ie=d===null||d.isGit,W=d?.hasCommits===!0,ae=p&&Ok.has(p);return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`div`,{className:`card bg-base-200`,children:(0,K.jsxs)(`div`,{className:`card-body gap-4 p-6`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(qn,{className:`size-4 opacity-50`}),(0,K.jsx)(`h2`,{className:`card-title text-sm`,children:`Project settings`})]}),(0,K.jsx)(`p`,{className:`text-xs opacity-50`,children:`Match your workspace identity and queue naming.`}),(0,K.jsxs)(`label`,{className:`form-control w-full gap-2`,children:[(0,K.jsxs)(`span`,{className:`label-text text-sm font-medium flex items-center gap-2`,children:[`Project name`,M&&(0,K.jsxs)(`span`,{className:`badge badge-success badge-xs gap-1 font-normal`,children:[(0,K.jsx)(yn,{className:`size-3`}),` saved`]})]}),(0,K.jsx)(`input`,{type:`text`,className:`input input-bordered w-full`,value:a,onChange:e=>{o(e.target.value),ee(e.target.value)},placeholder:`Project name`})]})]})}),(0,K.jsx)(`div`,{className:`card bg-base-200`,children:(0,K.jsxs)(`div`,{className:`card-body gap-4 p-6`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ar,{className:`size-4 opacity-50`}),(0,K.jsx)(`h2`,{className:`card-title text-sm`,children:`Working branch`})]}),(0,K.jsx)(`p`,{className:`text-xs opacity-50`,children:`Where issue worktrees are created from. Local operations use this branch.`}),h&&(0,K.jsxs)(`div`,{className:`text-xs text-base-content/60 flex items-center gap-2`,children:[(0,K.jsx)(q,{className:`size-3 animate-spin`}),`Loading git status...`]}),!h&&!ie&&(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`alert alert-warning py-3`,children:[(0,K.jsx)(Qn,{className:`size-4 shrink-0`}),(0,K.jsxs)(`div`,{className:`text-sm`,children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Not a git repository`}),(0,K.jsx)(`p`,{className:`opacity-80 mt-0.5`,children:`fifony requires git and an initial commit to create agent worktrees.`})]})]}),(0,K.jsxs)(`button`,{className:`btn btn-primary gap-2 self-start`,onClick:re,disabled:O,children:[O?(0,K.jsx)(q,{className:`size-4 animate-spin`}):(0,K.jsx)(Qn,{className:`size-4`}),`Initialize git repository`]}),A&&(0,K.jsx)(`p`,{className:`text-xs text-error`,children:A})]}),!h&&ie&&!W&&(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`alert alert-warning py-3`,children:[(0,K.jsx)(Wn,{className:`size-4 shrink-0`}),(0,K.jsxs)(`div`,{className:`text-sm`,children:[(0,K.jsx)(`p`,{className:`font-semibold`,children:`Repository has no commits yet`}),(0,K.jsx)(`p`,{className:`opacity-80 mt-0.5`,children:`Create an initial commit before agent worktrees can be prepared.`})]})]}),(0,K.jsxs)(`button`,{className:`btn btn-primary gap-2 self-start`,onClick:re,disabled:O,children:[O?(0,K.jsx)(q,{className:`size-4 animate-spin`}):(0,K.jsx)(Qn,{className:`size-4`}),`Create initial commit`]})]}),ie&&(0,K.jsxs)(K.Fragment,{children:[_?(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`label`,{className:`input input-bordered flex items-center gap-2 flex-1`,children:[(0,K.jsx)(Zn,{className:`size-3.5 opacity-40`}),(0,K.jsx)(`input`,{type:`text`,className:`grow font-mono text-sm`,value:y,onChange:e=>b(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ne(),e.key===`Escape`&&v(!1)},disabled:x})]}),(0,K.jsx)(`button`,{className:`btn btn-primary`,onClick:ne,disabled:x||!y.trim(),children:x?(0,K.jsx)(q,{className:`size-3 animate-spin`}):`Switch`}),(0,K.jsx)(`button`,{className:`btn btn-ghost`,onClick:()=>v(!1),disabled:x,children:`Cancel`})]}):(0,K.jsx)(`div`,{className:`rounded-box border border-base-300 bg-base-100 px-4 py-3 cursor-pointer hover:border-primary/40 transition-colors group`,onClick:H,role:`button`,tabIndex:0,onKeyDown:e=>e.key===`Enter`&&H(),children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Zn,{className:`size-4 opacity-50 shrink-0`}),(0,K.jsx)(`span`,{className:`text-sm opacity-60`,children:`Current branch:`}),(0,K.jsx)(`span`,{className:`font-mono text-sm font-semibold`,children:p||`—`}),ae&&(0,K.jsx)(`span`,{className:`badge badge-warning badge-sm ml-auto shrink-0`,children:`protected`}),!_&&(0,K.jsx)(Er,{className:`size-3.5 opacity-0 group-hover:opacity-40 ml-auto shrink-0 transition-opacity`})]})}),C&&(0,K.jsx)(`p`,{className:`text-xs text-error`,children:C}),E&&(0,K.jsxs)(`div`,{className:`alert alert-success py-2 text-xs`,children:[(0,K.jsx)(wn,{className:`size-3 shrink-0`}),E.created?`Branch created`:`Branch switched`,`: `,(0,K.jsx)(`span`,{className:`font-mono`,children:E.branch})]}),ae&&(0,K.jsx)(`p`,{className:`text-xs text-warning`,children:`You are on a protected branch. If needed, switch to another branch before running local merges.`})]})]})}),(0,K.jsx)(`div`,{className:`card bg-base-200`,children:(0,K.jsxs)(`div`,{className:`card-body gap-4 p-6`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(er,{className:`size-4 opacity-50`}),(0,K.jsx)(`h2`,{className:`card-title text-sm`,children:`Delivery mode`}),P&&(0,K.jsxs)(`span`,{className:`badge badge-success badge-xs gap-1 font-normal`,children:[(0,K.jsx)(yn,{className:`size-3`}),` saved`]})]}),(0,K.jsx)(`p`,{className:`text-xs opacity-50`,children:`Pick how completed issues are integrated.`}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsxs)(`label`,{className:`flex-1 cursor-pointer rounded-xl border-2 p-3 text-center text-sm font-medium transition-colors ${s===`local`?`border-primary bg-primary/10`:`border-base-300 bg-base-100`}`,children:[(0,K.jsx)(`input`,{type:`radio`,name:`settings-merge-mode`,className:`hidden`,checked:s===`local`,onChange:()=>{c(`local`),te(`local`,l)}}),(0,K.jsx)(Qn,{className:`size-4 mx-auto mb-1 opacity-60`}),`Local merge`]}),(0,K.jsxs)(`label`,{className:`flex-1 cursor-pointer rounded-xl border-2 p-3 text-center text-sm font-medium transition-colors ${s===`push-pr`?`border-primary bg-primary/10`:`border-base-300 bg-base-100`}`,children:[(0,K.jsx)(`input`,{type:`radio`,name:`settings-merge-mode`,className:`hidden`,checked:s===`push-pr`,onChange:()=>{c(`push-pr`),te(`push-pr`,l)}}),(0,K.jsx)(er,{className:`size-4 mx-auto mb-1 opacity-60`}),`Push PR`]})]}),s===`push-pr`&&(0,K.jsxs)(`label`,{className:`form-control w-full gap-2`,children:[(0,K.jsx)(`span`,{className:`label-text text-sm font-medium`,children:`PR base branch`}),(0,K.jsx)(`input`,{type:`text`,className:`input input-bordered w-full text-sm font-mono`,placeholder:p||`main`,value:l,onChange:e=>{u(e.target.value),te(s,e.target.value)}}),(0,K.jsx)(`p`,{className:`text-xs opacity-40`,children:`Branch that PRs target.`})]})]})})]})}function jk(){let[e,t]=(0,G.useState)(!1),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(null);return(0,G.useEffect)(()=>{if(!(`serviceWorker`in navigator)||!(`PushManager`in window)){t(!1);return}t(!0),navigator.serviceWorker.ready.then(e=>{e.pushManager.getSubscription().then(e=>{r(!!e)})})},[]),{supported:e,subscribed:n,subscribing:i,subscribe:(0,G.useCallback)(async()=>{a(!0),s(null);try{let{publicKey:e}=await U.get(`/push/vapid-public-key`);if(!e)throw Error(`Server did not return a VAPID public key`);let t=Mk(e),n=(await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:t})).toJSON();await U.post(`/push/subscribe`,{subscription:{endpoint:n.endpoint,keys:{p256dh:n.keys.p256dh,auth:n.keys.auth}}}),r(!0)}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}},[]),unsubscribe:(0,G.useCallback)(async()=>{a(!0),s(null);try{let e=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(e){let t=e.endpoint;await e.unsubscribe(),await U.post(`/push/unsubscribe`,{endpoint:t})}r(!1)}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}},[]),error:o}}function Mk(e){let t=(e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;++e)r[e]=n.charCodeAt(e);return r}var Nk=v(`/settings/notifications`)({component:Pk});function Pk(){let e=tn(),t=jk();return(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsx)(zO,{notifications:e.notifications}),t.supported&&(0,K.jsxs)(`div`,{className:`bg-base-200 rounded-box p-5`,children:[(0,K.jsxs)(`h3`,{className:`text-sm font-semibold flex items-center gap-2 mb-3`,children:[(0,K.jsx)(pn,{className:`size-4 text-primary`}),`Background Push Notifications`]}),(0,K.jsx)(`p`,{className:`text-xs opacity-60 mb-3`,children:`Receive notifications even when the browser tab is closed. Requires notification permission.`}),t.error&&(0,K.jsx)(`div`,{className:`alert alert-error text-xs py-2 mb-3`,children:t.error}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[t.subscribed?(0,K.jsxs)(`button`,{className:`btn btn-sm btn-warning btn-outline gap-1.5`,onClick:t.unsubscribe,disabled:t.subscribing,children:[t.subscribing?(0,K.jsx)(q,{className:`size-3.5 animate-spin`}):(0,K.jsx)(fn,{className:`size-3.5`}),`Unsubscribe from push`]}):(0,K.jsxs)(`button`,{className:`btn btn-sm btn-primary gap-1.5`,onClick:t.subscribe,disabled:t.subscribing,children:[t.subscribing?(0,K.jsx)(q,{className:`size-3.5 animate-spin`}):(0,K.jsx)(pn,{className:`size-3.5`}),`Enable push notifications`]}),(0,K.jsx)(`span`,{className:`text-xs opacity-40`,children:t.subscribed?`Active — you'll receive push notifications`:`Not subscribed`})]})]})]})}var Fk=v(`/settings/execution`)({component:Ik});function Ik(){let e=w(),t=me(rt().data),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(`fifony-agent:latest`),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(`3`),[f,p]=(0,G.useState)(``),[m,h]=(0,G.useState)(!0),[g,_]=(0,G.useState)(!0),[v,y]=(0,G.useState)(4),[b,x]=(0,G.useState)(!0),[S,C]=(0,G.useState)(!1),[T,E]=(0,G.useState)(!1),[D,O]=(0,G.useState)(!1),[k,A]=(0,G.useState)(!1),[j,M]=(0,G.useState)(!1),[N,P]=(0,G.useState)(!1),[F,I]=(0,G.useState)(!1),[L,R]=(0,G.useState)(!1),[z,B]=(0,G.useState)(!1),V=(0,G.useRef)(null),ee=(0,G.useRef)(null),te=(0,G.useRef)(null),H=(0,G.useRef)(null),ne=(0,G.useRef)(null),re=(0,G.useRef)(null),ie=(0,G.useRef)(null),W=(0,G.useRef)(null),ae=(0,G.useRef)({docker:!1,image:`fifony-agent:latest`,aiJail:!1}),oe=(0,G.useRef)(`3`),se=(0,G.useRef)(``),ce=(0,G.useRef)(!0),le=(0,G.useRef)(!0),ue=(0,G.useRef)(4),de=(0,G.useRef)(!0),fe=(0,G.useRef)(!1);(0,G.useEffect)(()=>{if(n||!t?.length)return;let e=he(t,`runtime.dockerExecution`,!1),i=he(t,`runtime.dockerImage`,`fifony-agent:latest`)||`fifony-agent:latest`,o=he(t,`runtime.sandboxExecution`,!1),c=String(he(t,`runtime.workerConcurrency`,3)),u=he(t,`runtime.testCommand`,``)||``,f=he(t,`runtime.autoReviewApproval`,!0),m=he(t,`runtime.autoApproveTrivialPlans`,!0),g=he(t,`runtime.maxTurns`,4);a(e),s(i),l(o),d(c),p(u);let v=he(t,`runtime.autoCommitBeforeMerge`,!0),b=he(t,`runtime.autoResolveConflicts`,!1);h(f),_(m),y(g),x(v),C(b),ae.current={docker:e,image:i,aiJail:o},oe.current=c,se.current=u,ce.current=f,le.current=m,ue.current=g,de.current=v,fe.current=b,r(!0)},[t,n]);let pe=(0,G.useCallback)(async(t,n,r=`runtime`)=>{await U.post(`/settings/${encodeURIComponent(t)}`,{scope:r,value:n,source:`user`}),e.setQueryData(Ge,e=>ge(e,{id:t,scope:r,value:n,source:`user`,updatedAt:new Date().toISOString()}))},[e]),_e=e=>{e(!0),setTimeout(()=>e(!1),1500)},ve=(0,G.useCallback)(()=>{V.current&&clearTimeout(V.current),V.current=setTimeout(async()=>{try{await pe(`runtime.dockerExecution`,ae.current.docker),await pe(`runtime.dockerImage`,ae.current.image||`fifony-agent:latest`),await pe(`runtime.sandboxExecution`,ae.current.aiJail),_e(E)}catch{}},600)},[pe]),ye=(0,G.useCallback)(e=>{a(e),e&&l(!1),ae.current.docker=e,e&&(ae.current.aiJail=!1),ve()},[ve]),be=(0,G.useCallback)(e=>{l(e),e&&a(!1),ae.current.aiJail=e,e&&(ae.current.docker=!1),ve()},[ve]),xe=(0,G.useCallback)(e=>{s(e),ae.current.image=e,ve()},[ve]),Se=(0,G.useCallback)(t=>{d(t),oe.current=t,ee.current&&clearTimeout(ee.current),ee.current=setTimeout(async()=>{let t=parseInt(oe.current,10);if(!(!t||t<1||t>10))try{await U.post(`/config/concurrency`,{concurrency:t}),e.invalidateQueries({queryKey:[`runtime-state`]}),_e(O)}catch{}},600)},[e]),Ce=(0,G.useCallback)(e=>{p(e),se.current=e,te.current&&clearTimeout(te.current),te.current=setTimeout(async()=>{try{await pe(`runtime.testCommand`,se.current.trim()),_e(A)}catch{}},600)},[pe]),we=(0,G.useCallback)(e=>{h(e),ce.current=e,H.current&&clearTimeout(H.current),H.current=setTimeout(async()=>{try{await pe(`runtime.autoReviewApproval`,ce.current),_e(M)}catch{}},600)},[pe]),Te=(0,G.useCallback)(e=>{_(e),le.current=e,ne.current&&clearTimeout(ne.current),ne.current=setTimeout(async()=>{try{await pe(`runtime.autoApproveTrivialPlans`,le.current),_e(P)}catch{}},600)},[pe]),Ee=(0,G.useCallback)(e=>{y(e),ue.current=e,re.current&&clearTimeout(re.current),re.current=setTimeout(async()=>{let e=Number(ue.current);if(!(!e||e<1))try{await pe(`runtime.maxTurns`,e),_e(I)}catch{}},600)},[pe]),De=(0,G.useCallback)(e=>{x(e),de.current=e,ie.current&&clearTimeout(ie.current),ie.current=setTimeout(async()=>{try{await pe(`runtime.autoCommitBeforeMerge`,de.current),_e(R)}catch{}},600)},[pe]),Oe=(0,G.useCallback)(e=>{C(e),fe.current=e,W.current&&clearTimeout(W.current),W.current=setTimeout(async()=>{try{await pe(`runtime.autoResolveConflicts`,fe.current),_e(B)}catch{}},600)},[pe]);(0,G.useEffect)(()=>()=>{[V,ee,te,H,ne,re,ie,W].forEach(e=>{e.current&&clearTimeout(e.current)})},[]);let ke=({show:e})=>e?(0,K.jsxs)(`span`,{className:`text-xs text-success flex items-center gap-1 animate-fade-in`,children:[(0,K.jsx)(yn,{className:`size-3`}),` saved`]}):null;return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(tk,{icon:In,title:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`Execution Sandbox `,(0,K.jsx)(ke,{show:T})]}),description:`Where agent code runs — directly on your system, in a sandbox, or in a Docker container.`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-2`,children:[(0,K.jsxs)(`label`,{className:`flex items-start gap-2.5 p-3 rounded-lg border cursor-pointer transition-colors ${!i&&!c?`border-base-content/30 bg-base-300`:`border-base-content/10 bg-base-100/50 opacity-60`}`,children:[(0,K.jsx)(`input`,{type:`radio`,className:`radio radio-sm mt-0.5`,checked:!i&&!c,onChange:()=>{a(!1),l(!1),ae.current={...ae.current,docker:!1,aiJail:!1},ve()}}),(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium`,children:`Host`}),(0,K.jsx)(`p`,{className:`text-xs opacity-50 leading-relaxed`,children:`Runs directly on your machine. Full filesystem and network access. Fast, zero overhead. No isolation.`})]})]}),(0,K.jsxs)(`label`,{className:`flex items-start gap-2.5 p-3 rounded-lg border cursor-pointer transition-colors ${c?`border-success/40 bg-success/5`:`border-base-content/10 bg-base-100/50 opacity-60`}`,children:[(0,K.jsx)(`input`,{type:`radio`,className:`radio radio-sm radio-success mt-0.5`,checked:c,onChange:()=>be(!0)}),(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsxs)(`p`,{className:`text-xs font-medium flex items-center gap-1`,children:[(0,K.jsx)(Vr,{className:`size-3 text-success`}),` Sandbox `,(0,K.jsx)(`span`,{className:`badge badge-xs badge-success ml-1`,children:`recommended`})]}),(0,K.jsx)(`p`,{className:`text-xs opacity-50 leading-relaxed`,children:`Lightweight process isolation. Only the issue worktree is writable. Namespace + seccomp + Landlock. Auto-downloads on first use.`})]})]}),(0,K.jsxs)(`label`,{className:`flex items-start gap-2.5 p-3 rounded-lg border cursor-pointer transition-colors ${i?`border-warning/40 bg-warning/5`:`border-base-content/10 bg-base-100/50 opacity-60`}`,children:[(0,K.jsx)(`input`,{type:`radio`,className:`radio radio-sm radio-warning mt-0.5`,checked:i,onChange:()=>ye(!0)}),(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium`,children:`Docker`}),(0,K.jsx)(`p`,{className:`text-xs opacity-50 leading-relaxed`,children:`Full container isolation. Separate kernel namespace. Requires Docker daemon running and a pre-built image.`})]})]})]}),(0,K.jsxs)(`div`,{className:`text-[11px] leading-relaxed opacity-40 mt-3 space-y-1`,children:[(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`strong`,{children:`Host`}),` — agent CLI runs with full system permissions. Changes are limited to the git worktree by convention, not enforcement.`]}),(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`strong`,{children:`Sandbox`}),` — the worktree is the only writable mount. The agent cannot read ~/.ssh, ~/.aws, or anything outside the project. Network access is preserved.`]}),(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`strong`,{children:`Docker`}),` — strongest isolation. Each run gets a fresh container. Slower startup (~2-5s) and requires a configured Docker image.`]})]}),i&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`label`,{className:`form-control w-full`,children:[(0,K.jsx)(`div`,{className:`label py-0.5`,children:(0,K.jsx)(`span`,{className:`label-text text-xs`,children:`Docker image`})}),(0,K.jsx)(`input`,{type:`text`,className:`input input-bordered input-sm w-full font-mono text-xs`,placeholder:`fifony-agent:latest`,value:o,onChange:e=>xe(e.target.value)})]}),(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-xs opacity-60`,children:[(0,K.jsx)(ni,{className:`size-3 shrink-0 mt-0.5 text-warning`}),(0,K.jsxs)(`span`,{children:[`Requires Docker installed and image built:`,` `,(0,K.jsx)(`code`,{className:`font-mono`,children:`docker build -f Dockerfile.agent -t fifony-agent:latest .`})]})]})]})]}),(0,K.jsx)(tk,{icon:Rn,title:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`Worker Concurrency `,(0,K.jsx)(ke,{show:D})]}),description:`Number of issues that run in parallel (1–10). Higher values use more system resources.`,children:(0,K.jsx)(`input`,{className:`input input-bordered input-sm w-24`,type:`number`,min:1,max:10,value:u,onChange:e=>Se(e.target.value)})}),(0,K.jsx)(tk,{icon:null,title:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`Max turns per run `,(0,K.jsx)(ke,{show:F})]}),description:`Maximum number of agent turns before a run is cut off. Higher = more attempts before the agent stops.`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`input`,{type:`range`,className:`range range-sm range-primary w-48`,min:1,max:50,step:1,value:v,onChange:e=>Ee(Number(e.target.value))}),(0,K.jsx)(`span`,{className:`text-sm font-mono w-8 text-center`,children:v})]})}),(0,K.jsx)(tk,{icon:Gn,title:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`Validation command `,(0,K.jsx)(ke,{show:k})]}),description:`Shell command run before merge/push. If it exits non-zero, the issue is blocked. Leave empty to skip.`,children:(0,K.jsx)(`input`,{type:`text`,className:`input input-bordered input-sm w-full font-mono text-xs`,placeholder:`pnpm test`,value:f,onChange:e=>Ce(e.target.value)})}),(0,K.jsx)(tk,{icon:Qn,title:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`Auto-approve after review `,(0,K.jsx)(ke,{show:j})]}),description:m?`Issues automatically move to Approved after the reviewer passes (or when no reviewer is configured).`:`Issues always land in Pending Decision for manual human approval, even after a passing review.`,children:(0,K.jsxs)(`label`,{className:`label cursor-pointer justify-start gap-3 p-0`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`toggle toggle-sm toggle-primary`,checked:m,onChange:e=>we(e.target.checked)}),(0,K.jsx)(`span`,{className:`label-text text-sm`,children:m?`Enabled`:`Disabled`})]})}),(0,K.jsx)(tk,{icon:Qn,title:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`Auto-approve trivial/low plans `,(0,K.jsx)(ke,{show:N})]}),description:g?`Plans with trivial or low complexity skip manual approval and go straight to execution.`:`All plans require manual approval before execution, regardless of complexity.`,children:(0,K.jsxs)(`label`,{className:`label cursor-pointer justify-start gap-3 p-0`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`toggle toggle-sm toggle-primary`,checked:g,onChange:e=>Te(e.target.checked)}),(0,K.jsx)(`span`,{className:`label-text text-sm`,children:g?`Enabled`:`Disabled`})]})}),(0,K.jsx)(tk,{icon:Qn,title:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`Auto-commit before merge `,(0,K.jsx)(ke,{show:L})]}),description:b?`Uncommitted changes in the project are automatically committed before merge so the process isn't blocked.`:`Merge will fail if the project has uncommitted changes. Issues will move to Blocked until you commit manually.`,children:(0,K.jsxs)(`label`,{className:`label cursor-pointer justify-start gap-3 p-0`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`toggle toggle-sm toggle-primary`,checked:b,onChange:e=>De(e.target.checked)}),(0,K.jsx)(`span`,{className:`label-text text-sm`,children:b?`Enabled`:`Disabled`})]})}),(0,K.jsx)(tk,{icon:Qn,title:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`Auto-resolve merge conflicts `,(0,K.jsx)(ke,{show:z})]}),description:S?`When a merge has conflicts, an agent is spawned to resolve them automatically.`:`Merge conflicts will block the issue. You must resolve conflicts manually.`,children:(0,K.jsxs)(`label`,{className:`label cursor-pointer justify-start gap-3 p-0`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`toggle toggle-sm toggle-primary`,checked:S,onChange:e=>Oe(e.target.checked)}),(0,K.jsx)(`span`,{className:`label-text text-sm`,children:S?`Enabled`:`Disabled`})]})}),(0,K.jsx)(fk,{})]})}var Lk=v(`/settings/assets`)({component:Vk}),Rk=25;function zk({onCatalogRefresh:e}){let[t,n]=(0,G.useState)([]),[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(()=>new Set),[l,u]=(0,G.useState)({}),d=(0,G.useRef)(!1),f=(0,G.useCallback)(()=>(o(``),i(!0),U.get(`/reference-repositories`).then(e=>n(e?.repositories||[])).catch(e=>{let t=e?.message||`Failed to load.`;o(t.toLowerCase().includes(`route not found`)?`Backend route not loaded. Start with --dev or run pnpm build:server.`:t)}).finally(()=>i(!1))),[]);(0,G.useEffect)(()=>{d.current||(d.current=!0,f())},[f]);let p=(0,G.useCallback)(async t=>{c(e=>new Set([...e,t])),u(e=>({...e,[t]:``}));try{let n=((await U.post(`/reference-repositories/sync`,{repository:t}))?.results||[]).find(e=>e.id===t);if(n?.action===`failed`){u(e=>({...e,[t]:n.message||`Sync failed.`}));return}await U.post(`/reference-repositories/import`,{repository:t,kind:`all`,global:!1}),await f(),u(e=>({...e,[t]:`Synced.`})),e?.()}catch(e){u(n=>({...n,[t]:e?.message||`Failed.`}))}finally{c(e=>{let n=new Set(e);return n.delete(t),n})}},[f,e]);return(0,K.jsx)(`div`,{className:`card bg-base-200`,children:(0,K.jsxs)(`div`,{className:`card-body gap-3 p-4`,children:[(0,K.jsx)(`h3`,{className:`font-semibold text-sm`,children:`Asset Sources`}),a&&(0,K.jsx)(`div`,{className:`alert alert-warning text-xs py-1`,children:a}),r?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs opacity-60`,children:[(0,K.jsx)(q,{className:`size-3 animate-spin`}),` Loading...`]}):(0,K.jsx)(`div`,{className:`grid grid-cols-2 xl:grid-cols-4 gap-2`,children:t.map(e=>{let t=s.has(e.id),n=e?.artifactCounts??null,r=e?.present&&e?.synced;return(0,K.jsxs)(`div`,{className:`rounded-lg border border-base-300/70 bg-base-100 p-2 flex flex-col gap-1`,children:[(0,K.jsx)(`div`,{className:`font-medium text-xs truncate`,children:e.name}),r&&n?(0,K.jsxs)(`div`,{className:`text-[11px] opacity-60`,children:[n.agents,` agents · `,n.skills,` skills`]}):(0,K.jsx)(`span`,{className:`badge badge-xs badge-warning`,children:`Not synced`}),l[e.id]&&(0,K.jsx)(`p`,{className:`text-[11px] opacity-60 truncate`,children:l[e.id]}),(0,K.jsxs)(`button`,{className:`btn btn-xs btn-outline gap-1 mt-auto`,onClick:()=>p(e.id),disabled:t,children:[t?(0,K.jsx)(q,{className:`size-3 animate-spin`}):(0,K.jsx)(Mr,{className:`size-3`}),t?`Syncing…`:r?`Re-sync`:`Sync`]})]},e.id)})})]})})}function Bk(){let[e,t]=(0,G.useState)([]),[n,r]=(0,G.useState)([]),[i,a]=(0,G.useState)(!0),[o,s]=(0,G.useState)(`agents`),[c,l]=(0,G.useState)(``),[u,d]=(0,G.useState)(1),[f,p]=(0,G.useState)(null),[m,h]=(0,G.useState)([]),[g,_]=(0,G.useState)([]),[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(``),[S,C]=(0,G.useState)(``),w=(0,G.useCallback)(async()=>{a(!0);try{let[e,n]=await Promise.allSettled([U.get(`/catalog/agents`),U.get(`/catalog/skills`)]);t(e.status===`fulfilled`&&e.value?.agents||[]),r(n.status===`fulfilled`&&n.value?.skills||[])}catch{}a(!1)},[]);(0,G.useEffect)(()=>{w()},[w]);let T=o===`agents`?e:n,E=(0,G.useMemo)(()=>{let e=c.trim().toLowerCase();return e?T.filter(t=>[t.name,t.displayName,t.description].filter(Boolean).join(` `).toLowerCase().includes(e)):T},[T,c]),D=Math.max(1,Math.ceil(E.length/Rk)),O=Math.min(u,D),k=E.slice((O-1)*Rk,O*Rk),A=E.length===0?0:(O-1)*Rk+1,j=Math.min(O*Rk,E.length);(0,G.useEffect)(()=>{d(1)},[o,c]),(0,G.useEffect)(()=>{p(null)},[o]);let M=o===`agents`?m:g,N=o===`agents`?h:_,P=m.length+g.length,F=(0,G.useMemo)(()=>f&&T.find(e=>e.name===f)||null,[f,T]),I=(0,G.useCallback)(e=>{N(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[N]),L=(0,G.useCallback)(()=>{N(E.map(e=>e.name))},[E,N]),R=(0,G.useCallback)(()=>{N([])},[N]),z=(0,G.useCallback)(async()=>{if(m.length===0&&g.length===0)return;y(!0),x(``),C(``);let e=[];m.length>0&&e.push({label:`Assets`,run:()=>U.post(`/install/agents`,{agents:m})}),g.length>0&&e.push({label:`Skills`,run:()=>U.post(`/install/skills`,{skills:g})});try{let t=await Promise.allSettled(e.map(e=>e.run())),n=[],r=[];for(let i=0;i<e.length;i++){let a=t[i];if(a.status===`rejected`){r.push(`${e[i].label}: ${a.reason?.message||`Failed`}`);continue}let o=a.value||{};if(o.ok===!1){r.push(`${e[i].label}: ${o.error||`Failed`}`);continue}let s=[`${e[i].label}: ${o.installed?.length||0} installed`];o.skipped?.length&&s.push(`${o.skipped.length} skipped`),o.errors?.length&&s.push(`${o.errors.length} errors`),n.push(s.join(`, `))}r.length>0?C(r.join(` | `)):(x(n.join(` | `)),h([]),_([])),await w()}catch(e){C(e?.message||`Install failed.`)}finally{y(!1)}},[m,g,w]),B=(0,G.useCallback)(async e=>{let t=o===`agents`;y(!0),x(``),C(``);try{let n=t?await U.post(`/install/agents`,{agents:[e.name]}):await U.post(`/install/skills`,{skills:[e.name]});n.ok===!1?C(n.error||`Failed`):x(`${e.displayName||e.name} installed.`),await w()}catch(e){C(e?.message||`Failed.`)}finally{y(!1)}},[o,w]);return i?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,K.jsx)(q,{className:`size-6 animate-spin opacity-30`})}):(0,K.jsxs)(`div`,{className:`card bg-base-200`,children:[(0,K.jsxs)(`div`,{className:`card-body gap-0 p-0`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 p-4 pb-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`flex bg-base-300 rounded-lg p-0.5 text-xs font-medium`,children:[(0,K.jsxs)(`button`,{className:`px-3 py-1 rounded-md transition-colors ${o===`agents`?`bg-base-100 shadow-sm`:`opacity-60 hover:opacity-100`}`,onClick:()=>s(`agents`),children:[(0,K.jsx)(hn,{className:`size-3 inline mr-1 -mt-0.5`}),`Assets (`,e.length,`)`]}),(0,K.jsxs)(`button`,{className:`px-3 py-1 rounded-md transition-colors ${o===`skills`?`bg-base-100 shadow-sm`:`opacity-60 hover:opacity-100`}`,onClick:()=>s(`skills`),children:[(0,K.jsx)(ui,{className:`size-3 inline mr-1 -mt-0.5`}),`Skills (`,n.length,`)`]})]}),(0,K.jsxs)(`label`,{className:`input input-bordered input-sm flex items-center gap-2 flex-1 min-w-[180px]`,children:[(0,K.jsx)(Lr,{className:`size-3.5 opacity-60`}),(0,K.jsx)(`input`,{type:`text`,className:`grow`,placeholder:`Search ${o}...`,value:c,onChange:e=>l(e.target.value)}),c&&(0,K.jsx)(`button`,{className:`btn btn-ghost btn-xs btn-circle`,onClick:()=>l(``),children:(0,K.jsx)(li,{className:`size-3`})})]}),(0,K.jsxs)(`div`,{className:`flex gap-1 text-xs`,children:[(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost`,onClick:L,disabled:E.length===0,children:`All`}),(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost`,onClick:R,disabled:M.length===0,children:`None`})]})]}),E.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] opacity-50`,children:[(0,K.jsxs)(`span`,{children:[A,`–`,j,` of `,E.length]}),D>1&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`button`,{className:`btn btn-ghost btn-xs btn-square`,disabled:O<=1,onClick:()=>d(e=>Math.max(1,e-1)),children:(0,K.jsx)(xn,{className:`size-3`})}),(0,K.jsxs)(`span`,{children:[O,`/`,D]}),(0,K.jsx)(`button`,{className:`btn btn-ghost btn-xs btn-square`,disabled:O>=D,onClick:()=>d(e=>Math.min(D,e+1)),children:(0,K.jsx)(Sn,{className:`size-3`})})]})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-[1fr_1.2fr] min-h-[320px] border-t border-base-300/50`,children:[(0,K.jsx)(`div`,{className:`border-r border-base-300/50 overflow-y-auto max-h-[480px]`,children:k.length===0?(0,K.jsx)(`div`,{className:`flex flex-col items-center justify-center py-12 text-xs opacity-50`,children:T.length===0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{children:[`No `,o,` in catalog.`]}),(0,K.jsx)(`p`,{className:`mt-1`,children:`Sync a source above.`})]}):(0,K.jsxs)(`p`,{children:[`No matches for "`,c,`"`]})}):k.map(e=>{let t=M.includes(e.name);return(0,K.jsxs)(`button`,{className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors border-b border-base-300/30 last:border-b-0
95
+ ${f===e.name?`bg-primary/10`:`hover:bg-base-100/60`}
96
+ `,onClick:()=>p(e.name),children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`checkbox checkbox-xs checkbox-primary shrink-0`,checked:t,onChange:t=>{t.stopPropagation(),I(e.name)},onClick:e=>e.stopPropagation()}),(0,K.jsx)(`span`,{className:`shrink-0`,children:e.emoji||(o===`agents`?`🤖`:`⚡`)}),(0,K.jsx)(`span`,{className:`truncate font-medium flex-1`,children:e.displayName||e.name}),e.source&&(0,K.jsx)(`span`,{className:`badge badge-ghost badge-xs shrink-0 opacity-60`,children:e.source})]},e.name)})}),(0,K.jsx)(`div`,{className:`p-4 overflow-y-auto max-h-[480px]`,children:F?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`span`,{className:`text-2xl`,children:F.emoji||(o===`agents`?`🤖`:`⚡`)}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`h4`,{className:`font-semibold text-sm`,children:F.displayName||F.name}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,K.jsx)(`span`,{className:`text-[11px] opacity-50 font-mono`,children:F.name}),F.source&&(0,K.jsx)(`span`,{className:`badge badge-ghost badge-xs`,children:F.source})]})]})]}),F.description&&(0,K.jsx)(`p`,{className:`text-xs opacity-70 leading-relaxed`,children:F.description}),F.domains?.length>0&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:F.domains.map(e=>(0,K.jsx)(`span`,{className:`badge badge-xs badge-outline`,children:e},e))}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[M.includes(F.name)?(0,K.jsxs)(`button`,{className:`btn btn-xs btn-outline gap-1`,onClick:()=>I(F.name),children:[(0,K.jsx)(yn,{className:`size-3`}),` Selected`]}):(0,K.jsx)(`button`,{className:`btn btn-xs btn-primary gap-1`,onClick:()=>I(F.name),children:`Add to selection`}),(0,K.jsxs)(`button`,{className:`btn btn-xs btn-ghost gap-1`,onClick:()=>B(F),disabled:v,children:[(0,K.jsx)(zn,{className:`size-3`}),`Install now`]})]})]}):(0,K.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full text-xs opacity-40`,children:(0,K.jsx)(`p`,{children:`Select an item to view details`})})})]}),D>1&&(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-2 p-2 border-t border-base-300/50 text-xs`,children:[(0,K.jsxs)(`button`,{className:`btn btn-ghost btn-xs gap-1`,disabled:O<=1,onClick:()=>d(e=>Math.max(1,e-1)),children:[(0,K.jsx)(xn,{className:`size-3`}),` Prev`]}),(0,K.jsxs)(`span`,{className:`opacity-50`,children:[O,` of `,D]}),(0,K.jsxs)(`button`,{className:`btn btn-ghost btn-xs gap-1`,disabled:O>=D,onClick:()=>d(e=>Math.min(D,e+1)),children:[`Next `,(0,K.jsx)(Sn,{className:`size-3`})]})]}),(b||S)&&(0,K.jsxs)(`div`,{className:`px-4 pb-3`,children:[b&&(0,K.jsx)(`p`,{className:`text-xs text-success`,children:b}),S&&(0,K.jsx)(`p`,{className:`text-xs text-error`,children:S})]})]}),P>0&&(0,K.jsxs)(`div`,{className:`sticky bottom-0 bg-base-300 border-t border-base-content/10 px-4 py-2 flex items-center justify-between rounded-b-2xl`,children:[(0,K.jsxs)(`span`,{className:`text-xs opacity-70`,children:[m.length>0&&`${m.length} agent${m.length>1?`s`:``}`,m.length>0&&g.length>0&&`, `,g.length>0&&`${g.length} skill${g.length>1?`s`:``}`,` `,`selected`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{className:`btn btn-xs btn-ghost`,onClick:()=>{h([]),_([])},children:`Clear`}),(0,K.jsxs)(`button`,{className:`btn btn-xs btn-primary gap-1`,onClick:z,disabled:v,children:[v?(0,K.jsx)(q,{className:`size-3 animate-spin`}):(0,K.jsx)(wn,{className:`size-3`}),v?`Installing…`:`Install selected`]})]})]})]})}function Vk(){let[e,t]=(0,G.useState)(0);return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(zk,{onCatalogRefresh:()=>t(e=>e+1)}),(0,K.jsx)(Bk,{},e)]})}var Hk=v(`/settings/appearance`)({beforeLoad:()=>{throw x({to:`/settings/system`})}}),Uk=[`Welcome`,`Setup`,`Pipeline`,`Agents & Skills`,`Preferences`,`Launch`];function Wk(){return Uk}function Gk(){return Uk.length}var Kk=[`Setup`,`Pipeline`,`Agents`,`Preferences`,`Launch`];function qk(){return Kk}var Jk=[{value:`low`,label:`Low`,icon:ui,description:`Quick and light -- fast responses, less thorough`,color:`text-info`},{value:`medium`,label:`Medium`,icon:Xn,description:`Balanced -- good mix of speed and quality`,color:`text-success`},{value:`high`,label:`High`,icon:gn,description:`Thorough -- deeper analysis, takes more time`,color:`text-warning`},{value:`extra-high`,label:`Extra High`,icon:Wn,description:`Maximum depth -- most thorough, slowest`,color:`text-error`}],Yk={codex:Jk,claude:Jk,gemini:Jk.filter(e=>e.value!==`extra-high`)};function Xk(e,t){return Yk[t?.[e]||`codex`]||Jk}var Zk=[{value:`auto`,label:`Auto`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`black`,label:`Black`},{value:`cupcake`,label:`Cupcake`},{value:`night`,label:`Night`},{value:`sunset`,label:`Sunset`}],Qk=[{role:`enhancer`,label:`Enhance`,description:`Improve issue title and description`,icon:Kr,color:`text-warning`},{role:`chatter`,label:`Chat`,description:`Conversational AI for discussions`,icon:_r,color:`text-info`},{role:`planner`,label:`Plan`,description:`Scope the issue and create execution plan`,icon:gn,color:`text-info`},{role:`executor`,label:`Execute`,description:`Implement the plan — write code, run commands`,icon:ui,color:`text-primary`},{role:`reviewer`,label:`Review`,description:`Validate correctness, scope, and quality`,icon:Lr,color:`text-secondary`},{role:`services`,label:`Services`,description:`AI-powered service log analysis`,icon:on,color:`text-success`}],$k=[{key:`enhance`,role:`enhancer`,label:`Enhance`,icon:Kr,description:`Improve issue title and description`,accent:`warning`},{key:`chat`,role:`chatter`,label:`Chat`,icon:_r,description:`Conversational AI for discussions`,accent:`info`},{key:`plan`,role:`planner`,label:`Plan`,icon:gn,description:`Scope the issue and create execution plan`,accent:`info`},{key:`execute`,role:`executor`,label:`Execute`,icon:ui,description:`Implement the plan — write code, run commands`,accent:`primary`},{key:`review`,role:`reviewer`,label:`Review`,icon:Lr,description:`Validate correctness, scope, and quality`,accent:`secondary`},{key:`services`,role:`services`,label:`Services`,icon:on,description:`AI-powered service log analysis`,accent:`success`}],eA={warning:`text-warning`,info:`text-info`,primary:`text-primary`,secondary:`text-secondary`,success:`text-success`};function tA({options:e,value:t,onChange:n}){return(0,K.jsx)(`div`,{className:`flex gap-1 flex-wrap`,children:e.map(e=>{let r=e.value===t,i=e.icon;return(0,K.jsxs)(`button`,{type:`button`,onClick:()=>n(e.value),className:`flex items-center gap-1 px-2.5 py-1 rounded-full text-[11px] font-medium border transition-all ${r?`${e.color} border-current bg-base-300`:`text-base-content/35 border-base-content/10 hover:border-base-content/30 hover:text-base-content/60`}`,children:[(0,K.jsx)(i,{className:`size-2.5`}),e.label]},e.value)})})}function nA(e){return e===`gemini`?Jk.filter(e=>e.value!==`extra-high`):Jk}var rA=v(`/settings/agents`)({component:iA});function iA(){let e=w(),[t,n]=(0,G.useState)(null),[r,i]=(0,G.useState)([]),[a,o]=(0,G.useState)({}),[s,c]=(0,G.useState)(!0),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(!1),p=(0,G.useRef)(null),m=(0,G.useMemo)(()=>(r||[]).filter(e=>e.available),[r]),h=(0,G.useMemo)(()=>{if(!t)return!1;let e=t[$k[0].key]?.provider;return e&&$k.every(n=>t[n.key]?.provider===e)},[t]),g=(0,G.useMemo)(()=>{if(!t)return Jk;let e=$k.map(e=>new Set(nA(t[e.key]?.provider).map(e=>e.value))),n=[...e[0]].filter(t=>e.every(e=>e.has(t))),r=Jk.filter(e=>n.includes(e.value));return r.length>0?r:Jk},[t]),_=(0,G.useMemo)(()=>{if(!t)return`medium`;let e=$k.map(e=>t[e.key]?.effort),n=(e.every(t=>t===e[0])?e[0]:null)||g[0]?.value||`medium`;return g.some(e=>e.value===n)?n:`medium`},[t,g]),v=(0,G.useCallback)(t=>{e.setQueryData(Ge,e=>ge(e,{id:`runtime.workflowConfig`,scope:`runtime`,value:t,source:`user`,updatedAt:new Date().toISOString()})),e.setQueryData([`workflow-config`],{ok:!0,workflow:t,isDefault:!1})},[e]),y=(0,G.useCallback)(async()=>{c(!0);try{let e=await U.get(`/config/workflow?details=1`);n(e.workflow),i(e.providers||[]),o(e.models||{})}catch{}c(!1)},[]);(0,G.useEffect)(()=>{y()},[y]),(0,G.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]);let b=(0,G.useCallback)((e,t)=>{p.current&&clearTimeout(p.current),p.current=setTimeout(async()=>{try{await U.post(`/config/workflow`,{workflow:e}),v(e),u(t),setTimeout(()=>u(null),1500)}catch{}},600)},[v]),x=(0,G.useCallback)((e,t)=>{n(n=>{let r={...n,[e]:t};return b(r,e),r})},[b]),S=(0,G.useCallback)(e=>{if(!e)return;let t=a[e]?.[0]?.id||``;n(n=>{let r={};for(let i of $k){let a=e===`gemini`&&n[i.key]?.effort===`extra-high`?`high`:n[i.key]?.effort||`medium`;r[i.key]={provider:e,model:t,effort:a}}return b(r,`all`),r})},[a,b]),C=(0,G.useCallback)(e=>{e&&n(t=>{let n={};for(let r of $k)n[r.key]={...t[r.key],effort:e};return b(n,`all`),n})},[b]),T=(0,G.useCallback)(async()=>{f(!0);try{let e=await U.get(`/config/workflow?details=1`),t=e.providers||[],r=e.models||{};i(t),o(r);let a=t.filter(e=>e.available),s=a.some(e=>e.name===`claude`),c=a.some(e=>e.name===`codex`),l=r.claude?.[0]?.id||``,d=r.codex?.[0]?.id||``,f=s?`claude`:`codex`,p=s?l:d,m={enhance:{provider:f,model:p,effort:`medium`},chat:{provider:f,model:p,effort:`medium`},plan:{provider:f,model:p,effort:`high`},execute:{provider:c?`codex`:`claude`,model:c?d:l,effort:`medium`},review:{provider:f,model:p,effort:`medium`},services:{provider:f,model:p,effort:`medium`}};n(m),await U.post(`/config/workflow`,{workflow:m}),v(m),u(`all`),setTimeout(()=>u(null),1500)}catch{}f(!1)},[v]);return s||!t?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,K.jsx)(q,{className:`size-6 animate-spin opacity-30`})}):(0,K.jsxs)(`div`,{className:`space-y-5 stagger-children`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Pipeline`}),(0,K.jsx)(`p`,{className:`text-xs opacity-50 mt-0.5`,children:`Provider, model, and thinking depth per stage. Changes are saved automatically.`})]}),(0,K.jsxs)(`button`,{className:`btn btn-ghost btn-sm gap-1 shrink-0`,title:`Reset to auto-detected provider defaults`,onClick:T,disabled:d,children:[d?(0,K.jsx)(q,{className:`size-3 animate-spin`}):(0,K.jsx)(Pr,{className:`size-3`}),`Restore defaults`]})]}),(0,K.jsxs)(`div`,{className:`bg-base-200 rounded-xl p-4 space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:`Apply to all stages`}),(0,K.jsx)(`p`,{className:`text-xs text-base-content/50 mb-2`,children:`Use one CLI and one effort across all 6 stages.`}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:m.map(e=>{let n=e.name||e.id;return(0,K.jsx)(`button`,{type:`button`,className:`btn btn-xs ${h&&t[$k[0].key]?.provider===n?`btn-primary`:`btn-soft`}`,onClick:()=>S(n),children:n},n)})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-[10px] text-base-content/40 mb-2`,children:`Effort (applies to all)`}),(0,K.jsx)(tA,{options:g,value:_,onChange:C})]})]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2 justify-center`,children:r.map(e=>{let t=e.name||e.id,n=e.available!==!1;return(0,K.jsxs)(`span`,{className:`badge gap-1.5 badge-sm ${n?`badge-success`:`badge-ghost opacity-40`}`,children:[n?(0,K.jsx)(Tn,{className:`size-3`}):(0,K.jsx)(On,{className:`size-3`}),(0,K.jsx)(`span`,{className:`font-mono`,children:t}),e.path&&(0,K.jsx)(`span`,{className:`opacity-50 text-[9px] hidden sm:inline`,children:e.path})]},t)})}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-3`,children:$k.map(e=>{let n=e.icon,r=t[e.key]||t.plan,i=a[r.provider]||[],o=nA(r.provider),s=eA[e.accent]||`text-base-content`,c=l===e.key||l===`all`;return(0,K.jsx)(`div`,{className:`bg-base-200 rounded-xl p-4 animate-fade-in`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`size-8 rounded-lg flex items-center justify-center bg-base-300 shrink-0 ${s}`,children:(0,K.jsx)(n,{className:`size-4`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-sm`,children:e.label}),c&&(0,K.jsxs)(`span`,{className:`text-xs text-success flex items-center gap-1 animate-fade-in`,children:[(0,K.jsx)(yn,{className:`size-3`}),` saved`]})]}),(0,K.jsx)(`p`,{className:`text-[11px] text-base-content/40 leading-tight mt-0.5 truncate`,children:e.description})]}),(0,K.jsx)(`select`,{className:`select select-sm select-bordered w-28 shrink-0`,value:r.provider,onChange:t=>{let n=t.target.value,i=a[n]||[],o=n===`gemini`&&r.effort===`extra-high`?`high`:r.effort;x(e.key,{...r,provider:n,model:i[0]?.id||``,effort:o})},children:m.map(e=>{let t=e.name||e.id;return(0,K.jsx)(`option`,{value:t,children:t},t)})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-base-content/40 shrink-0 w-10`,children:`Effort`}),(0,K.jsx)(tA,{options:o,value:r.effort||`medium`,onChange:t=>x(e.key,{...r,effort:t})})]}),i.length>0?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-base-content/40 shrink-0 w-10`,children:`Model`}),(0,K.jsx)(`select`,{className:`select select-xs select-bordered flex-1`,value:r.model,onChange:t=>x(e.key,{...r,model:t.target.value}),children:i.map(e=>(0,K.jsxs)(`option`,{value:e.id,children:[e.label,e.tier?` — ${e.tier}`:``]},e.id))})]}):r.model?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-base-content/40 shrink-0 w-10`,children:`Model`}),(0,K.jsx)(`span`,{className:`text-xs opacity-40`,children:r.model})]}):null]})},e.key)})}),(0,K.jsx)(`p`,{className:`text-[11px] text-base-content/35 text-center`,children:`Pipeline stages: enhance, chat, plan, execute, review, services`})]})}var aA=v(`/chat/$issueId`)({component:oA});function oA(){let{issueId:e}=aA.useParams(),t=O(),{issues:n}=tn();return(0,G.useEffect)(()=>{window.dispatchEvent(new CustomEvent(`spark:chat:select-issue`,{detail:{issueId:e}})),t({to:`/chat`,replace:!0})},[e,t]),null}var sA=Bo.update({id:`/settings`,path:`/settings`,getParentRoute:()=>Ro}),cA=iy.update({id:`/services`,path:`/services`,getParentRoute:()=>Ro}),lA=ky.update({id:`/onboarding`,path:`/onboarding`,getParentRoute:()=>Ro}),uA=Ay.update({id:`/milestones`,path:`/milestones`,getParentRoute:()=>Ro}),dA=Nb.update({id:`/kanban`,path:`/kanban`,getParentRoute:()=>Ro}),fA=Xb.update({id:`/issues`,path:`/issues`,getParentRoute:()=>Ro}),pA=Qb.update({id:`/analytics`,path:`/analytics`,getParentRoute:()=>Ro}).lazy(()=>To(()=>import(`./analytics.lazy-CXGjZabc.js`).then(e=>e.Route),__vite__mapDeps([7,1,5,2,4]))),mA=ux.update({id:`/agents`,path:`/agents`,getParentRoute:()=>Ro}),hA=fx.update({id:`/`,path:`/`,getParentRoute:()=>Ro}),gA=px.update({id:`/`,path:`/`,getParentRoute:()=>sA}),_A=uO.update({id:`/chat/`,path:`/chat/`,getParentRoute:()=>Ro}),vA=VO.update({id:`/system`,path:`/system`,getParentRoute:()=>sA}),yA=nk.update({id:`/services`,path:`/services`,getParentRoute:()=>sA}),bA=dk.update({id:`/quality`,path:`/quality`,getParentRoute:()=>sA}),xA=Ek.update({id:`/providers`,path:`/providers`,getParentRoute:()=>sA}),SA=kk.update({id:`/project`,path:`/project`,getParentRoute:()=>sA}),CA=Nk.update({id:`/notifications`,path:`/notifications`,getParentRoute:()=>sA}),wA=Fk.update({id:`/execution`,path:`/execution`,getParentRoute:()=>sA}),TA=Lk.update({id:`/assets`,path:`/assets`,getParentRoute:()=>sA}),EA=Hk.update({id:`/appearance`,path:`/appearance`,getParentRoute:()=>sA}),DA=rA.update({id:`/agents`,path:`/agents`,getParentRoute:()=>sA}),OA=aA.update({id:`/chat/$issueId`,path:`/chat/$issueId`,getParentRoute:()=>Ro}),kA={SettingsAgentsRoute:DA,SettingsAppearanceRoute:EA,SettingsAssetsRoute:TA,SettingsExecutionRoute:wA,SettingsNotificationsRoute:CA,SettingsProjectRoute:SA,SettingsProvidersRoute:xA,SettingsQualityRoute:bA,SettingsServicesRoute:yA,SettingsSystemRoute:vA,SettingsIndexRoute:gA},AA={IndexRoute:hA,AgentsRoute:mA,AnalyticsRoute:pA,IssuesRoute:fA,KanbanRoute:dA,MilestonesRoute:uA,OnboardingRoute:lA,ServicesRoute:cA,SettingsRoute:sA._addFileChildren(kA),ChatIssueIdRoute:OA,ChatIndexRoute:_A},jA=Ro._addFileChildren(AA)._addFileTypes();window.__fifonyInstallPrompt=null,window.addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),window.__fifonyInstallPrompt=e});var MA=new de({defaultOptions:{queries:{staleTime:2e3,retry:1,refetchOnWindowFocus:!1}}}),NA=M({routeTree:jA,basepath:`/`,defaultPreload:`intent`});(0,fe.createRoot)(document.getElementById(`root`)).render((0,K.jsx)(G.StrictMode,{children:(0,K.jsx)(k,{client:MA,children:(0,K.jsx)(A,{router:NA})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/service-worker.js`,{scope:`/`}).catch(()=>{})});export{st as $,Zn as A,Sn as B,gr as C,er as D,lr as E,jn as F,Xt as G,yn as H,An as I,Gt as J,Zt as K,On as L,Gn as M,Un as N,$n as O,Rn as P,rt as Q,Tn as R,Cr as S,ur as T,hn as U,xn as V,on as W,ct as X,Ge as Y,lt as Z,Vr as _,Gk as a,Mr as b,_o as c,li as d,he as et,ri as f,Kr as g,$r as h,Xk as i,qn as j,Qn as k,Ga as l,ti as m,Qk as n,ge as nt,Wk as o,ni as p,Jt as q,Zk as r,pe as rt,qk as s,Jk as t,me as tt,ui as u,Lr as v,q as w,Er as x,Nr as y,wn as z};