elanous 0.2.8 → 0.2.9

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 (195) hide show
  1. package/apps/pwa/out/404/index.html +1 -1
  2. package/apps/pwa/out/404.html +1 -1
  3. package/apps/pwa/out/_next/static/bFI5EEwg7T6aG88ibX4Zq/_buildManifest.js +1 -0
  4. package/apps/pwa/out/_next/static/chunks/8630-cdfc61e82c653ffc.js +1 -0
  5. package/apps/pwa/out/_next/static/chunks/{8894-7317998f6cb97d8c.js → 8894-e263b332208e3957.js} +1 -1
  6. package/apps/pwa/out/_next/static/chunks/9454-139040d37c79dbc9.js +1 -0
  7. package/apps/pwa/out/_next/static/chunks/app/approvals/page-fb7c2d458f32fcad.js +1 -0
  8. package/apps/pwa/out/_next/static/chunks/app/autopilot/{page-f4d2ecbbae6088d6.js → page-35e2713597dd24d1.js} +1 -1
  9. package/apps/pwa/out/_next/static/chunks/app/board/{page-2053e49930c82748.js → page-918b656f064577ba.js} +1 -1
  10. package/apps/pwa/out/_next/static/chunks/app/botlab/{page-d4b6df905f185055.js → page-f972fc1c00a62e88.js} +1 -1
  11. package/apps/pwa/out/_next/static/chunks/app/bots/{page-a70ba27c33003dd0.js → page-5f30e00693527ebd.js} +1 -1
  12. package/apps/pwa/out/_next/static/chunks/app/chat/page-7fbae173b3c103a7.js +1 -0
  13. package/apps/pwa/out/_next/static/chunks/app/consult/{page-18166f885d831d3e.js → page-3b4edcce364062ea.js} +1 -1
  14. package/apps/pwa/out/_next/static/chunks/app/control/{page-1c9d6cfe68b121c2.js → page-c5794f484c251f44.js} +1 -1
  15. package/apps/pwa/out/_next/static/chunks/app/design-check/page-1130d8eefcd87e76.js +1 -0
  16. package/apps/pwa/out/_next/static/chunks/app/editor/page-973996d584f008c1.js +1 -0
  17. package/apps/pwa/out/_next/static/chunks/app/exec/{page-147a328753d983e2.js → page-016e2bda04eecb1f.js} +1 -1
  18. package/apps/pwa/out/_next/static/chunks/app/field/{page-799395a9df7d95aa.js → page-b4d6d9a3b56f2940.js} +1 -1
  19. package/apps/pwa/out/_next/static/chunks/app/intake/{page-6a8158b71d1fe9d7.js → page-ec49a466121233ba.js} +1 -1
  20. package/apps/pwa/out/_next/static/chunks/app/layout-f72db356744ceade.js +1 -0
  21. package/apps/pwa/out/_next/static/chunks/app/live/page-a6fd9b50d1b85378.js +1 -0
  22. package/apps/pwa/out/_next/static/chunks/app/market/{page-c0c0d19d51342d3e.js → page-8b0402a46a749a3d.js} +1 -1
  23. package/apps/pwa/out/_next/static/chunks/app/missions/[id]/{page-2e002ad8faa43291.js → page-037f83e2a1edc8e2.js} +1 -1
  24. package/apps/pwa/out/_next/static/chunks/app/morning/{page-b672e02e4bec8deb.js → page-adfbd2ba9598e59a.js} +1 -1
  25. package/apps/pwa/out/_next/static/chunks/app/not-found-46fedff57d4bec67.js +1 -0
  26. package/apps/pwa/out/_next/static/chunks/app/observatory/{page-9db2226f38c542fb.js → page-0cf318e9dcee2bbf.js} +1 -1
  27. package/apps/pwa/out/_next/static/chunks/app/ops/checklist/page-899b327cb8b6845c.js +1 -0
  28. package/apps/pwa/out/_next/static/chunks/app/ops/release/page-6c1e6ba743a29dfe.js +1 -0
  29. package/apps/pwa/out/_next/static/chunks/app/{page-70ee65f5f7a151dc.js → page-1a8e4807292f6b17.js} +1 -1
  30. package/apps/pwa/out/_next/static/chunks/app/reflection/page-28deba6bcb834916.js +1 -0
  31. package/apps/pwa/out/_next/static/chunks/app/scheduler/{page-092e1bcf27d751cc.js → page-de68e2205794037d.js} +1 -1
  32. package/apps/pwa/out/_next/static/chunks/app/sessions/{page-eb52580c4b75b905.js → page-c71c33a573230672.js} +1 -1
  33. package/apps/pwa/out/_next/static/chunks/app/settings/devices/{page-7464c1987dd76e6d.js → page-0df30e0c7e50148a.js} +1 -1
  34. package/apps/pwa/out/_next/static/chunks/app/settings/page-4fc56790fe0d2682.js +1 -0
  35. package/apps/pwa/out/_next/static/chunks/app/setup/done/page-59df2aebb38a7c1e.js +1 -0
  36. package/apps/pwa/out/_next/static/chunks/app/setup/{page-085847b088675978.js → page-4647be5dbcbd0795.js} +1 -1
  37. package/apps/pwa/out/_next/static/chunks/app/share/{page-9fe9d38c36999eb4.js → page-e025892bda74b743.js} +1 -1
  38. package/apps/pwa/out/_next/static/chunks/app/showroom/page-a0955de73b89f078.js +1 -0
  39. package/apps/pwa/out/_next/static/chunks/app/tasks/page-369846d2921af584.js +1 -0
  40. package/apps/pwa/out/_next/static/chunks/app/term/{page-295a02b1026b8255.js → page-72cbc1c8cdd0f65d.js} +1 -1
  41. package/apps/pwa/out/_next/static/chunks/app/trace/page-77b28bfb0996d5ea.js +1 -0
  42. package/apps/pwa/out/_next/static/chunks/app/vault/page-3220c4934f49c6c2.js +1 -0
  43. package/apps/pwa/out/_next/static/chunks/app/workflows/chat-ui/page-90670589b87abea8.js +1 -0
  44. package/apps/pwa/out/_next/static/chunks/app/workflows/{page-2e367075ffdbc062.js → page-7df9243ed021a4cc.js} +1 -1
  45. package/apps/pwa/out/_next/static/chunks/app/workspace/{page-647ed2b66c1d49f1.js → page-4498c3853f4f688d.js} +1 -1
  46. package/apps/pwa/out/_next/static/chunks/app/worktrees/page-35bedde6d885f08f.js +1 -0
  47. package/apps/pwa/out/_next/static/css/f92f63a5df0ba229.css +1 -0
  48. package/apps/pwa/out/approvals/index.html +1 -1
  49. package/apps/pwa/out/approvals/index.txt +30 -29
  50. package/apps/pwa/out/autopilot/index.html +1 -1
  51. package/apps/pwa/out/autopilot/index.txt +30 -29
  52. package/apps/pwa/out/board/index.html +1 -1
  53. package/apps/pwa/out/board/index.txt +30 -29
  54. package/apps/pwa/out/botlab/index.html +1 -1
  55. package/apps/pwa/out/botlab/index.txt +27 -26
  56. package/apps/pwa/out/bots/index.html +1 -1
  57. package/apps/pwa/out/bots/index.txt +27 -26
  58. package/apps/pwa/out/chat/index.html +1 -1
  59. package/apps/pwa/out/chat/index.txt +27 -26
  60. package/apps/pwa/out/consult/index.html +1 -1
  61. package/apps/pwa/out/consult/index.txt +30 -29
  62. package/apps/pwa/out/control/index.html +1 -1
  63. package/apps/pwa/out/control/index.txt +30 -29
  64. package/apps/pwa/out/design-check/index.html +1 -1
  65. package/apps/pwa/out/design-check/index.txt +30 -29
  66. package/apps/pwa/out/editor/index.html +1 -1
  67. package/apps/pwa/out/editor/index.txt +30 -29
  68. package/apps/pwa/out/exec/index.html +1 -1
  69. package/apps/pwa/out/exec/index.txt +30 -29
  70. package/apps/pwa/out/field/index.html +1 -1
  71. package/apps/pwa/out/field/index.txt +30 -29
  72. package/apps/pwa/out/healthz +1 -1
  73. package/apps/pwa/out/index.html +1 -1
  74. package/apps/pwa/out/index.txt +27 -26
  75. package/apps/pwa/out/intake/index.html +1 -1
  76. package/apps/pwa/out/intake/index.txt +30 -29
  77. package/apps/pwa/out/live/index.html +1 -1
  78. package/apps/pwa/out/live/index.txt +30 -29
  79. package/apps/pwa/out/market/index.html +1 -1
  80. package/apps/pwa/out/market/index.txt +27 -26
  81. package/apps/pwa/out/missions/placeholder/index.html +1 -1
  82. package/apps/pwa/out/missions/placeholder/index.txt +27 -26
  83. package/apps/pwa/out/morning/index.html +1 -1
  84. package/apps/pwa/out/morning/index.txt +30 -29
  85. package/apps/pwa/out/observatory/index.html +1 -1
  86. package/apps/pwa/out/observatory/index.txt +30 -29
  87. package/apps/pwa/out/ops/checklist/index.html +1 -0
  88. package/apps/pwa/out/ops/checklist/index.txt +30 -0
  89. package/apps/pwa/out/ops/release/index.html +1 -0
  90. package/apps/pwa/out/ops/release/index.txt +30 -0
  91. package/apps/pwa/out/reflection/index.html +1 -1
  92. package/apps/pwa/out/reflection/index.txt +28 -27
  93. package/apps/pwa/out/scheduler/index.html +1 -1
  94. package/apps/pwa/out/scheduler/index.txt +30 -29
  95. package/apps/pwa/out/sessions/index.html +1 -1
  96. package/apps/pwa/out/sessions/index.txt +27 -26
  97. package/apps/pwa/out/settings/devices/index.html +1 -1
  98. package/apps/pwa/out/settings/devices/index.txt +30 -29
  99. package/apps/pwa/out/settings/index.html +1 -1
  100. package/apps/pwa/out/settings/index.txt +30 -29
  101. package/apps/pwa/out/setup/done/index.html +1 -1
  102. package/apps/pwa/out/setup/done/index.txt +30 -29
  103. package/apps/pwa/out/setup/index.html +1 -1
  104. package/apps/pwa/out/setup/index.txt +30 -29
  105. package/apps/pwa/out/share/index.html +1 -1
  106. package/apps/pwa/out/share/index.txt +30 -29
  107. package/apps/pwa/out/showroom/index.html +1 -1
  108. package/apps/pwa/out/showroom/index.txt +27 -26
  109. package/apps/pwa/out/tasks/index.html +1 -1
  110. package/apps/pwa/out/tasks/index.txt +30 -29
  111. package/apps/pwa/out/term/index.html +1 -1
  112. package/apps/pwa/out/term/index.txt +30 -29
  113. package/apps/pwa/out/trace/index.html +1 -1
  114. package/apps/pwa/out/trace/index.txt +30 -29
  115. package/apps/pwa/out/vault/index.html +1 -1
  116. package/apps/pwa/out/vault/index.txt +30 -29
  117. package/apps/pwa/out/workflows/chat-ui/index.html +1 -1
  118. package/apps/pwa/out/workflows/chat-ui/index.txt +30 -29
  119. package/apps/pwa/out/workflows/index.html +1 -1
  120. package/apps/pwa/out/workflows/index.txt +30 -29
  121. package/apps/pwa/out/workspace/index.html +1 -1
  122. package/apps/pwa/out/workspace/index.txt +30 -29
  123. package/apps/pwa/out/worktrees/index.html +1 -1
  124. package/apps/pwa/out/worktrees/index.txt +30 -29
  125. package/graphs/release/recipes.yaml +3 -0
  126. package/graphs/release/release-loop.yaml +3 -1
  127. package/graphs/test-diet/nightly-audit.yaml +18 -0
  128. package/graphs/test-diet/recipes.yaml +3 -0
  129. package/package.json +1 -1
  130. package/plugins/doc-draft/graphs/run-step.ts +1 -1
  131. package/scripts/release-loop/cutoff.ts +20 -2
  132. package/scripts/release-loop/export-check-node.ts +85 -0
  133. package/scripts/release-loop/gate-node.ts +18 -4
  134. package/scripts/release-loop/node-verdict.ts +8 -1
  135. package/scripts/test-diet/lib.ts +1 -0
  136. package/scripts/test-diet/node.ts +56 -14
  137. package/src/auth/setup-link-tokens.fixture.ts +19 -0
  138. package/src/auth/setup-link-tokens.ts +153 -0
  139. package/src/budget/unified-usage.ts +75 -0
  140. package/src/channel-bot-token.ts +37 -10
  141. package/src/chat/index.ts +9 -9
  142. package/src/cli/op-proxy-sync.ts +83 -0
  143. package/src/cli/pr-cli.ts +6 -2
  144. package/src/cli/release-cli.ts +41 -1
  145. package/src/dashboard/dashboard-status-lines.ts +45 -0
  146. package/src/dashboard/first-screen-band.ts +35 -0
  147. package/src/dashboard/index.ts +70 -13
  148. package/src/dashboard/provider-slash-runtime.ts +28 -11
  149. package/src/dashboard/slash-runtime/dashboard-handlers.ts +10 -0
  150. package/src/dashboard/turn-stream-formatter.ts +1 -1
  151. package/src/decisions/decision-cards.ts +1 -1
  152. package/src/index.ts +16 -4
  153. package/src/maturity/feature-maturity.ts +2 -0
  154. package/src/nexus/api/http-server.ts +20 -0
  155. package/src/nexus/api/meta-api.ts +27 -0
  156. package/src/nexus/api/operator.ts +61 -0
  157. package/src/nexus/api/ops-api.ts +139 -0
  158. package/src/nexus/api/ops-seats-sources.ts +65 -0
  159. package/src/nexus/api/ops-seats.ts +114 -0
  160. package/src/nexus/api/public-routes.ts +14 -1
  161. package/src/nexus/api/setup-claim.ts +21 -0
  162. package/src/nexus/config/secrets/file-backend.ts +56 -18
  163. package/src/onboarding/first-run-doctor.ts +54 -0
  164. package/src/release-loop/checklist.ts +5 -64
  165. package/src/release-loop/feature-store.ts +327 -0
  166. package/src/release-loop/manifest.ts +59 -5
  167. package/src/seat-dispatch/ceo-commands.ts +65 -0
  168. package/src/skills/tools/usage-slash.ts +8 -7
  169. package/src/telegram-commands.ts +16 -0
  170. package/src/telegram-run.ts +83 -13
  171. package/src/thinking-line.ts +28 -20
  172. package/src/tui/chat/execution-badge.ts +1 -1
  173. package/src/ux-sim/turn-states.ts +1 -1
  174. package/src/version/packed-revision.json +1 -1
  175. package/apps/pwa/out/_next/static/chunks/4836-3084c58c1725a40b.js +0 -1
  176. package/apps/pwa/out/_next/static/chunks/9454-a3e0953307216c58.js +0 -1
  177. package/apps/pwa/out/_next/static/chunks/app/approvals/page-9aa47b0bc6d570ff.js +0 -1
  178. package/apps/pwa/out/_next/static/chunks/app/chat/page-186fc6952f027acc.js +0 -1
  179. package/apps/pwa/out/_next/static/chunks/app/design-check/page-cbbe03c0da7b081a.js +0 -1
  180. package/apps/pwa/out/_next/static/chunks/app/editor/page-c108ff1fdb665c97.js +0 -1
  181. package/apps/pwa/out/_next/static/chunks/app/layout-9567560270857531.js +0 -1
  182. package/apps/pwa/out/_next/static/chunks/app/live/page-e7ed3d010153d818.js +0 -1
  183. package/apps/pwa/out/_next/static/chunks/app/not-found-1ba4a5d857276334.js +0 -1
  184. package/apps/pwa/out/_next/static/chunks/app/reflection/page-0bb8e43203efb23b.js +0 -1
  185. package/apps/pwa/out/_next/static/chunks/app/settings/page-e573437b0a1c728f.js +0 -1
  186. package/apps/pwa/out/_next/static/chunks/app/setup/done/page-294300625e49e4d3.js +0 -1
  187. package/apps/pwa/out/_next/static/chunks/app/showroom/page-d8ab4d1489223459.js +0 -1
  188. package/apps/pwa/out/_next/static/chunks/app/tasks/page-6141f67f531d8b6a.js +0 -1
  189. package/apps/pwa/out/_next/static/chunks/app/trace/page-1eb9a0e1e054209d.js +0 -1
  190. package/apps/pwa/out/_next/static/chunks/app/vault/page-82efa177a30f3741.js +0 -1
  191. package/apps/pwa/out/_next/static/chunks/app/workflows/chat-ui/page-d0be51cec4f62606.js +0 -1
  192. package/apps/pwa/out/_next/static/chunks/app/worktrees/page-ba058c56e38f2792.js +0 -1
  193. package/apps/pwa/out/_next/static/css/5ef72a618a8994f3.css +0 -1
  194. package/apps/pwa/out/_next/static/lywc8m_HDzH9MKSDQhyEj/_buildManifest.js +0 -1
  195. /package/apps/pwa/out/_next/static/{lywc8m_HDzH9MKSDQhyEj → bFI5EEwg7T6aG88ibX4Zq}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6605],{11161:(e,t,a)=>{Promise.resolve().then(a.bind(a,98012))},50940:(e,t,a)=>{"use strict";a.d(t,{A:()=>r});let r=(0,a(89117).A)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},53220:(e,t,a)=>{"use strict";a.d(t,{V5:()=>s,tV:()=>l});var r=a(94387);class n extends Error{constructor(e,t,a){super(a||t),this.status=e,this.error=t,this.reason=a,this.name="MergeApprovalsApiError"}}function s(e,t){return e instanceof n?401===e.status||"unauthorized"===e.error?{text:"이 기기에 소유자 토큰이 없어 승인 목록을 못 읽었습니다 — 이미 연결된 기기의 설정 › 연결 토큰 만들기 에서 토큰을 만들어, 이 기기의 설정 › 데몬 연결 › 연결 토큰 칸에 붙이면 바로 보입니다.",href:"/app/settings/#bearer-token"}:"gh-failed"===e.error?{text:"데몬이 GitHub 를 읽지 못했습니다(데몬 기계의 gh 로그인\xb7네트워크) — 잠시 뒤 다시 열어 보세요.".concat(e.reason?" 사유: ".concat(e.reason.split("\n")[0].slice(0,160)):"")}:"gh-invalid-response"===e.error?{text:"GitHub 응답을 해석하지 못했습니다 — 잠시 뒤 다시 열어 보세요."}:"approvals-repo-unknown"===e.error?{text:"승인할 저장소를 모릅니다 — 데몬 설정 intake.approvals.repo(예: owner/repo)를 채워 주세요.",href:"/app/settings/"}:e.reason?{text:e.reason}:{text:"".concat(t," (").concat(e.status," ").concat(e.error,")")}:e instanceof TypeError?{text:"데몬에 닿지 못했습니다 — 데몬이 켜져 있는지, 이 기기가 같은 네트워크(tailnet)에 있는지 확인하세요."}:{text:e instanceof Error&&e.message?e.message:t}}function l(e){var t,a;let s=null!=(t=e.fetchImpl)?t:fetch,l=(null!=(a=e.baseUrl)?a:"").replace(/\/+$/,"");async function o(t,a){let r={...a,headers:{"content-type":"application/json",...e.authHeader?{authorization:e.authHeader}:{}}},o=e.client?await e.client.fetchResponse(t,r):await s("".concat(l).concat(t),r),c=await o.json().catch(()=>null);if(!o.ok){var i;let e=c&&"object"==typeof c?c:{};throw new n(o.status,null!=(i=e.error)?i:"request-failed",e.reason)}return c}return{list:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"open";return o("merged"===e?"".concat(r.r5,"?state=merged"):r.r5)},get:e=>o("".concat(r.r5,"/").concat(e)),check:(e,t)=>o("".concat(r.r5,"/").concat(e,"/check"),{method:"POST",body:JSON.stringify({headSha:t})}),merge:(e,t)=>o("".concat(r.r5,"/").concat(e,"/merge"),{method:"POST",body:JSON.stringify({headSha:t})})}}},71807:(e,t,a)=>{"use strict";a.d(t,{In:()=>i,OG:()=>o});var r=a(91269);let n="elanous.pwa.role",s="elanous:pwa-role";function l(){try{let e=window.localStorage.getItem(n);if("owner"===e||"contributor"===e||"general"===e)return e}catch(e){}return"general"}function o(e){try{window.localStorage.setItem(n,e)}catch(e){}"function"==typeof window.dispatchEvent&&window.dispatchEvent(new Event(s))}function c(e){if("function"!=typeof window.addEventListener)return()=>{};window.addEventListener(s,e);let t=t=>{(t.key===n||null===t.key)&&e()};return window.addEventListener("storage",t),()=>{window.removeEventListener(s,e),window.removeEventListener("storage",t)}}function i(){return(0,r.useSyncExternalStore)(c,l,()=>"general")}},89117:(e,t,a)=>{"use strict";a.d(t,{A:()=>i});var r=a(91269);let n=function(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return t.filter((e,t,a)=>!!e&&""!==e.trim()&&a.indexOf(e)===t).join(" ").trim()},s=e=>{let t=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,a)=>a?a.toUpperCase():t.toLowerCase());return t.charAt(0).toUpperCase()+t.slice(1)};var l={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let o=(0,r.createContext)({}),c=(0,r.forwardRef)((e,t)=>{var a,s,c;let{color:i,size:d,strokeWidth:u,absoluteStrokeWidth:m,className:p="",children:h,iconNode:x,...b}=e,{size:f=24,strokeWidth:g=2,absoluteStrokeWidth:N=!1,color:j="currentColor",className:w=""}=null!=(a=(0,r.useContext)(o))?a:{},y=(null!=m?m:N)?24*Number(null!=u?u:g)/Number(null!=d?d:f):null!=u?u:g;return(0,r.createElement)("svg",{ref:t,...l,width:null!=(s=null!=d?d:f)?s:l.width,height:null!=(c=null!=d?d:f)?c:l.height,stroke:null!=i?i:j,strokeWidth:y,className:n("lucide",w,p),...!h&&!(e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0;return!1})(b)&&{"aria-hidden":"true"},...b},[...x.map(e=>{let[t,a]=e;return(0,r.createElement)(t,a)}),...Array.isArray(h)?h:[h]])}),i=(e,t)=>{let a=(0,r.forwardRef)((a,l)=>{let{className:o,...i}=a;return(0,r.createElement)(c,{ref:l,iconNode:t,className:n("lucide-".concat(s(e).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()),"lucide-".concat(e),o),...i})});return a.displayName=s(e),a}},94387:(e,t,a)=>{"use strict";a.d(t,{GM:()=>o,J3:()=>l,WF:()=>r,bR:()=>s,m:()=>c,r5:()=>n});let r="/v1/devices",n="/v1/approvals/merges",s="/v1/templates/capability-preview",l="/v1/idle-nudge/preview",o="/v1/morning-digest/showroom",c="/v1/next-fluent/dispatch"},98012:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>R});var r=a(41121),n=a(91269),s=a(71946),l=a(38317),o=a(38519),c=a(71807),i=a(53220);function d(e,t){return"UNKNOWN"===t&&e<3?3e3:null}async function u(e,t){let a,r=0,n=d(0,"UNKNOWN");for(;null!==n;){var s,l,o;if(await t.sleep(n),t.isActive&&!t.isActive())break;r++;try{a=await e(),null==(l=t.onDetail)||l.call(t,a)}catch(e){}null==(s=t.onAttempt)||s.call(t),n=d(r,null!=(o=null==a?void 0:a.mergeable)?o:"UNKNOWN")}return{attempts:r,...a?{last:a}:{}}}var m=a(50940);function p(e){let{view:t,target:a}=e,[s]=(0,n.useState)(()=>Date.now()),[l,o]=(0,n.useState)(s);(0,n.useEffect)(()=>{let e=window.setInterval(()=>o(Date.now()),100);return()=>window.clearInterval(e)},[]);let c=function(e,t,a){let r="".concat((Math.max(0,e)/1e3).toFixed(1),"초");return{title:"merged"===t?"GitHub 에서 반영된 코드 변경을 읽고 있습니다":a?"GitHub 에서 승인을 기다리는 코드 변경과 #".concat(a," 카드를 읽고 있습니다"):"GitHub 에서 승인을 기다리는 코드 변경을 읽고 있습니다",clock:r,hint:e>=8e3?"평소(2~5초)보다 오래 걸립니다 — GitHub 응답을 기다리는 중이며 멈추지 않았습니다.":null}}(l-s,t,a);return(0,r.jsxs)("section",{role:"status","aria-live":"polite","aria-busy":"true",className:"space-y-3","data-approvals-loading":!0,children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 rounded-xl border border-blue-500/40 bg-blue-500/5 p-4",children:[(0,r.jsx)(m.A,{className:"h-6 w-6 shrink-0 text-blue-500 motion-safe:animate-spin","aria-hidden":!0}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("p",{className:"font-medium",children:c.title}),c.hint&&(0,r.jsx)("p",{className:"mt-1 text-sm text-amber-600 dark:text-amber-400",children:c.hint})]}),(0,r.jsx)("span",{className:"font-mono text-lg tabular-nums text-blue-600 dark:text-blue-300","aria-label":"경과 시간",children:c.clock})]}),(0,r.jsx)("div",{className:"h-1 overflow-hidden rounded-full bg-muted","aria-hidden":!0,children:(0,r.jsx)("div",{className:"h-full w-1/3 rounded-full bg-blue-500 motion-safe:animate-[approvals-slide_1.2s_ease-in-out_infinite]"})}),(0,r.jsx)("style",{children:"@keyframes approvals-slide{0%{transform:translateX(-100%)}100%{transform:translateX(300%)}}"}),[0,1].map(e=>(0,r.jsxs)("div",{className:"space-y-3 rounded-xl border border-border bg-card p-5 motion-safe:animate-pulse","aria-hidden":!0,children:[(0,r.jsx)("div",{className:"h-4 w-2/3 rounded bg-muted"}),(0,r.jsx)("div",{className:"h-3 w-full rounded bg-muted"}),(0,r.jsx)("div",{className:"h-3 w-5/6 rounded bg-muted"})]},e))]})}function h(e){let{view:t,onChange:a}=e,n=(e,n)=>(0,r.jsx)("button",{type:"button",role:"tab","aria-selected":t===e,onClick:()=>a(e),className:"rounded-md px-3 py-1 text-sm ".concat(t===e?"bg-foreground text-background":"bg-muted text-foreground"),children:n});return(0,r.jsxs)("div",{role:"tablist","aria-label":"승인 목록 보기",className:"flex gap-2",children:[n("open","승인 대기"),n("merged","완료")]})}function x(e){let{brief:t,lineage:a,summary:n}=e;return(0,r.jsxs)(r.Fragment,{children:[null!==t?(0,r.jsx)("section",{"aria-label":"승인 요약",className:"mt-3 break-words text-sm leading-relaxed [&_a]:text-blue-600 [&_a]:underline [&_blockquote]:border-l-2 [&_blockquote]:pl-3 [&_h3]:mt-3 [&_h3]:font-semibold [&_li]:ml-5 [&_li]:list-disc [&_p]:my-2 [&_table]:block [&_table]:overflow-x-auto",children:(0,r.jsx)(s.oz,{remarkPlugins:[l.A],components:{a:e=>{let{href:t,children:a}=e;return(0,r.jsx)("a",{href:t,target:"_blank",rel:"noreferrer",children:a})}},children:t})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"mt-3 rounded border border-amber-500/40 bg-amber-500/15 p-3 text-sm text-amber-800 dark:text-amber-300",children:"승인 요약 내용이 없습니다 — GitHub 본문을 보거나 발사자에게 요청하세요"}),(0,r.jsx)("p",{className:"mt-3 whitespace-pre-wrap text-sm",children:n})]}),a&&(0,r.jsxs)("p",{className:"mt-3 text-sm text-muted-foreground",children:["아이디어 원장: ",a]})]})}function b(e){var t;let{gate:a,busy:n,blocked:s,mergeLabel:l,onCheck:o,onMerge:c}=e;return(0,r.jsxs)("div",{className:"mt-3 space-y-2","aria-label":"머지 전 검사",children:["none"===a.status&&(0,r.jsx)("button",{type:"button",onClick:o,disabled:n,className:"rounded-lg border px-3 py-2 text-sm disabled:opacity-50",children:"머지 전 검사 시작"}),"running"===a.status&&(0,r.jsx)("p",{role:"status",className:"text-sm",children:"검사 중…"}),"passed"===a.status&&(0,r.jsxs)("p",{className:"text-sm text-green-700 dark:text-green-400",children:["검사 통과 (",null!=(t=a.os)?t:"unknown",")",a.baseDrifted?" \xb7 검사 뒤 main 이 움직였다 — 머지 때 겹치는 파일이 있으면 다시 검사를 요구한다":""]}),("failed"===a.status||"unmeasured"===a.status)&&(0,r.jsxs)("div",{role:"alert",className:"text-sm text-red-600",children:[(0,r.jsx)("p",{children:"failed"===a.status?"검사 실패":"검사 측정 불가"}),(0,r.jsx)("ul",{className:"list-inside list-disc",children:a.failures.map((e,t)=>(0,r.jsx)("li",{children:e},t))}),(0,r.jsx)("button",{type:"button",onClick:o,disabled:n,className:"mt-2 rounded-lg border px-3 py-2 disabled:opacity-50",children:"머지 전 검사 다시 시작"})]}),(0,r.jsx)("button",{type:"button",onClick:c,disabled:n||s||"passed"!==a.status,className:"rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white disabled:cursor-not-allowed disabled:opacity-50",children:null!=l?l:"승인하고 머지"})]})}function f(e){let{card:t,api:a,attempt:r,onAttempt:s,onUpdate:l}=e,o="UNKNOWN"===t.mergeable&&!t.merged&&"OPEN"===t.state;return(0,n.useEffect)(()=>{if(!o||r>0)return;let e=!0,n=[];return u(()=>a.get(t.number),{sleep:e=>new Promise(t=>{n.push(window.setTimeout(t,e))}),isActive:()=>e,onDetail:a=>{e&&l(a,t.headSha)},onAttempt:()=>{e&&s(t.number)}}),()=>{for(let t of(e=!1,n))window.clearTimeout(t)}},[a,t.number,o,r,s,l]),null}function g(){let e=(0,c.In)(),{client:t}=(0,o.Q)(),a=(0,n.useMemo)(()=>(0,i.tV)({client:t}),[t]),[s,l]=(0,n.useState)([]),[u,m]=(0,n.useState)(!0),[g,N]=(0,n.useState)(null),[j,w]=(0,n.useState)(null),[y,v]=(0,n.useState)({}),[k,S]=(0,n.useState)({}),[C,I]=(0,n.useState)(null),[E,R]=(0,n.useState)("open"),U=(0,n.useCallback)(e=>{S(t=>{var a;return{...t,[e]:(null!=(a=t[e])?a:0)+1}})},[]),O=(0,n.useCallback)((e,t)=>{l(a=>a.map(a=>a.number!==e.number||a.headSha!==t?a:{...e,gate:e.headSha===t?e.gate:{status:"none",failures:[]},merged:a.merged}))},[]);async function L(e){w(e.number),v(t=>({...t,[e.number]:""}));try{let{gate:t}=await a.check(e.number,e.headSha);l(a=>a.map(a=>a.number===e.number&&a.headSha===e.headSha?{...a,gate:t}:a))}catch(t){v(a=>({...a,[e.number]:(0,i.V5)(t,"검사를 시작하지 못했습니다.").text}))}finally{w(null)}}async function A(e){if(window.confirm("#".concat(e.number," ").concat(e.title,"\n현재 확인한 변경을 승인하고 머지할까요?"))){w(e.number),v(t=>({...t,[e.number]:""}));try{await a.merge(e.number,e.headSha),l(t=>t.map(t=>t.number===e.number?{...t,merged:!0,state:"MERGED"}:t))}catch(t){v(a=>({...a,[e.number]:(0,i.V5)(t,"머지하지 못했습니다.").text}))}finally{w(null)}}}return((0,n.useEffect)(()=>{let e=s.filter(e=>"OPEN"===e.state&&("running"===e.gate.status||"passed"===e.gate.status));if("open"!==E||!e.length)return;let t=!0,r=window.setInterval(()=>{for(let r of e)a.get(r.number).then(e=>{t&&O(e,r.headSha)}).catch(e=>{t&&v(t=>({...t,[r.number]:(0,i.V5)(e,"검사 상태를 불러오지 못했습니다.").text}))})},1e4);return()=>{t=!1,window.clearInterval(r)}},[a,s,O,E]),(0,n.useEffect)(()=>{let e=!0,t=Number(new URLSearchParams(window.location.search).get("pr")),r=Number.isSafeInteger(t)&&t>0?t:null;return(m(!0),N(null),I(r),"merged"===E)?(a.list("merged").then(t=>{let{items:a}=t;e&&l(a)}).catch(t=>{e&&N((0,i.V5)(t,"목록을 불러오지 못했습니다."))}).finally(()=>{e&&m(!1)}),()=>{e=!1}):(a.list().then(async t=>{let{items:n}=t;if(!e)return;let s=n.find(e=>e.number===r);if(r&&!s)try{let t=await a.get(r);e&&l([t,...n])}catch(t){e&&N((0,i.V5)(t,"PR 을 불러오지 못했습니다.")),e&&l(n)}else l(r?[...n].sort((e,t)=>Number(t.number===r)-Number(e.number===r)):n)}).catch(t=>{e&&N((0,i.V5)(t,"목록을 불러오지 못했습니다."))}).finally(()=>{e&&m(!1)}),()=>{e=!1})},[a,E]),"owner"===e||"open"!==E||u||s.length||g)?(0,r.jsxs)("main",{className:"mx-auto max-w-3xl space-y-5 p-4 pb-20 text-foreground sm:p-8",children:[(0,r.jsxs)("header",{children:[(0,r.jsx)("h1",{className:"text-2xl font-semibold",children:"코드 변경 승인"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"자동으로 만든 코드 변경(PR)을 확인하고 승인합니다."})]}),(0,r.jsx)(h,{view:E,onChange:e=>{l([]),R(e)}}),u&&(0,r.jsx)(p,{view:E,target:C}),g&&(0,r.jsxs)("p",{role:"alert",className:"text-red-600","data-approvals-error":!0,children:[g.text,g.href&&(0,r.jsxs)(r.Fragment,{children:[" ",(0,r.jsx)("a",{href:g.href,className:"font-semibold underline underline-offset-2","data-approvals-settings":!0,children:"설정 열기 →"})]})]}),!u&&!s.length&&!g&&(0,r.jsx)("p",{children:"merged"===E?"승인해 반영된 코드 변경이 아직 없습니다.":"승인을 기다리는 코드 변경이 없습니다."}),s.map(e=>{var t,n;let s=e.merged||"MERGED"===e.state,l="OPEN"!==e.state&&!s,o=e.draft?"초안 PR 은 머지할 수 없습니다. GitHub에서 초안을 해제한 뒤 다시 확인하세요.":e.checks.failure>0?"실패한 검사가 있습니다.":e.checks.pending>0?"검사가 아직 끝나지 않았습니다.":"CONFLICTING"===e.mergeable?"머지 충돌이 있습니다.":"MERGEABLE"!==e.mergeable?"머지 가능 여부가 아직 확인되지 않았습니다.":"main"!==e.base?"대상 브랜치가 main 이 아닙니다.":"",c=C===e.number,i=null!=(t=k[e.number])?t:0;return(0,r.jsxs)("article",{className:"rounded-xl border bg-card p-5 shadow-sm ".concat(c?"border-blue-500 ring-2 ring-blue-500/30":"border-border"),children:[(0,r.jsx)(f,{card:e,api:a,attempt:i,onAttempt:U,onUpdate:O}),(0,r.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[(0,r.jsxs)("h2",{className:"font-semibold",children:["#",e.number," \xb7 ",e.title]}),(0,r.jsx)("span",{className:"rounded bg-muted px-2 py-1 text-xs",children:s?function(e){if(!e)return"머지됨";let t=new Date(e);if(Number.isNaN(t.getTime()))return"머지됨";let a=new Date(t.getTime()+324e5).toISOString();return"머지됨 ".concat(a.slice(5,10)," ").concat(a.slice(11,16)," KST")}(e.mergedAt):l?"닫힘":e.draft?"초안":"열림"})]}),(0,r.jsx)(x,{brief:e.brief,lineage:e.lineage,summary:e.summary}),(0,r.jsxs)("p",{className:"mt-3 text-sm text-muted-foreground",children:["+",e.additions," 추가 / −",e.deletions," 삭제 \xb7 파일 ",e.changedFiles]}),(0,r.jsxs)("div",{className:"mt-2 flex flex-wrap gap-2 text-xs","aria-label":"검사 상태",children:[(0,r.jsxs)("span",{className:"rounded bg-green-500/15 px-2 py-1",children:["성공 ",e.checks.success]}),(0,r.jsxs)("span",{className:"rounded bg-red-500/15 px-2 py-1",children:["실패 ",e.checks.failure]}),(0,r.jsxs)("span",{className:"rounded bg-yellow-500/15 px-2 py-1",children:["대기 ",e.checks.pending]}),e.checks.success+e.checks.failure+e.checks.pending===0&&(0,r.jsx)("span",{className:"rounded bg-slate-500/15 px-2 py-1",children:"GitHub 검사 없음 — 머지 전 검사는 아래에서 별도로 실행"})]}),(0,r.jsxs)("details",{open:c,className:"mt-3 text-sm",children:[(0,r.jsx)("summary",{className:"cursor-pointer",children:"바뀐 파일 보기"}),(0,r.jsx)("ul",{className:"mt-2 list-inside list-disc break-all",children:e.files.map(e=>(0,r.jsx)("li",{children:e},e))})]}),(0,r.jsxs)("div",{className:"mt-4 flex flex-wrap items-center gap-4",children:[(0,r.jsx)("a",{className:"text-sm text-blue-600 underline",href:e.url,target:"_blank",rel:"noopener noreferrer",children:"GitHub 에서 보기"}),!s&&!l&&(0,r.jsx)(b,{gate:e.gate,busy:null!==j,blocked:!!o,mergeLabel:j===e.number?"머지 중…":"UNKNOWN"!==(n=e.mergeable)?"승인하고 머지":null===d(i,n)?"확인 종료":"확인 중…",onCheck:()=>L(e),onMerge:()=>A(e)})]}),o&&!s&&!l&&(0,r.jsxs)("p",{className:"mt-2 text-sm text-amber-600",children:[o,"UNKNOWN"===e.mergeable&&i>=3?" 자동 확인이 끝났습니다. 최신 상태는 페이지를 새로고침하세요.":""]}),y[e.number]&&(0,r.jsx)("p",{role:"alert",className:"mt-2 text-sm text-red-600",children:y[e.number]})]},e.number)})]}):null}function N(e){return{slides:e.slides.map(e=>{let{image:t,caption:a,include:r}=e;return{image:t,caption:a,include:r}}),caption:{hook:e.caption.hook,body:e.caption.body},hashtags:[...e.hashtags],cover:{text:e.cover.text,sub:e.cover.sub},location:e.location}}class j extends Error{constructor(e,t){super(t),this.status=e,this.name="GraphApprovalsApiError"}}let w={list:"목록을 보려면",decide:"승인하려면",save:"초안을 저장하려면"},y="/app/settings/#bearer-token";function v(e){return e instanceof j&&(401===e.status||403===e.status)}function k(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"decide";return e instanceof j?401===e.status||403===e.status?"".concat(w[t]," 이 기기를 데몬에 연결해야 합니다 — 설정 › 데몬 연결 › 연결 토큰 칸에 토큰을 넣어 주세요."):404===e.status?"이 실행을 찾지 못했습니다. 목록을 다시 확인해 주세요.":409===e.status?"이미 결정된 실행입니다. 목록을 다시 확인해 주세요.":400===e.status?"결정 내용을 확인한 뒤 다시 시도해 주세요.":"승인 요청을 처리하지 못했습니다. 잠시 뒤 다시 시도해 주세요.":e instanceof TypeError?"서버에 연결하지 못했습니다. 연결 상태를 확인해 주세요.":"승인 요청을 처리하지 못했습니다. 잠시 뒤 다시 시도해 주세요."}let S="/v1/graph-approvals";function C(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now(),a="release-loop"===e.graphId?"릴리스 발행":"announce-loop"===e.graphId?"공지":e.graphId,r=Date.parse(e.since),n=Number.isNaN(r)?0:Math.max(0,Math.floor((t-r)/6e4)),s=n<1?"방금 전":n<60?"".concat(n,"분 전"):n<1440?"".concat(Math.floor(n/60),"시간 전"):"".concat(Math.floor(n/1440),"일 전");return{title:a,nodeId:e.nodeId,waiting:s,message:e.message,recent:e.recent.map(e=>"".concat(e.ok&&"fail"!==e.outcome&&"error"!==e.outcome?"✓":"✗"," ").concat(e.nodeId).concat(e.outcome?" \xb7 ".concat(e.outcome):"").concat(e.summary?" \xb7 ".concat(e.summary):""))}}function I(e){var t,a,s,l,o,c,i;let{item:d,api:u,onDecided:m,confirm:p}=e,[h,x]=(0,n.useState)(d.feed),[b,f]=(0,n.useState)(()=>N(d.feed)),[g,j]=(0,n.useState)(!1),[w,S]=(0,n.useState)(0),[C,I]=(0,n.useState)(!1),[E,R]=(0,n.useState)(!1),[U,O]=(0,n.useState)(""),[L,A]=(0,n.useState)(""),[M,_]=(0,n.useState)(!1),D=(e,t)=>{A(k(e,t)),_(v(e))},[G,H]=(0,n.useState)({}),T=(0,n.useRef)(null),P=null!=p?p:e=>window.confirm(e),F=(i=N(h),JSON.stringify(b)!==JSON.stringify(i)),W=(0,n.useMemo)(()=>(function(e,t){let a=[];for(let r of(e.cover.image&&a.push({image:e.cover.image,isCover:!0}),t.slides))r.include&&a.push({image:r.image,caption:r.caption});return a})(h,b),[h,b]),V=W[Math.min(w,Math.max(0,W.length-1))],z=(0,n.useMemo)(()=>[h.cover.image,...h.slides.map(e=>e.image)].filter(e=>!!e),[h]);function J(e){S(t=>Math.max(0,Math.min(W.length-1,t+e)))}function K(e,t){f(a=>({...a,slides:a.slides.map((a,r)=>r===e?{...a,...t}:a)}))}function q(e,t){f(a=>{let r=e+t;if(r<0||r>=a.slides.length)return a;let n=[...a.slides];return[n[e],n[r]]=[n[r],n[e]],{...a,slides:n}})}async function X(){R(!0),A(""),_(!1),O("");try{let e=await u.saveFeedDraft(d.graphId,d.runId,b);return x(e.feed),f(N(e.feed)),O("저장했어요 \xb7 수정 ".concat(e.feed.revision," \xb7 아직 게시 전입니다")),!0}catch(e){return D(e,"save"),!1}finally{R(!1)}}async function $(){if(P("게시할까요? 승인하면 이 초안으로 게시 준비 묶음이 텔레그램으로 갑니다.")&&(!F||await X())){R(!0),A("");try{await u.decide(d.graphId,d.runId,"approved"),m()}catch(e){D(e,"decide")}finally{R(!1)}}}async function B(){if(P("이 게시 초안을 거절할까요?")){R(!0),A("");try{await u.decide(d.graphId,d.runId,"rejected"),m()}catch(e){D(e,"decide")}finally{R(!1)}}}(0,n.useEffect)(()=>{let e=!0,t=[],a="undefined"!=typeof URL&&"function"==typeof URL.createObjectURL;return Promise.all(z.map(async r=>{try{let n=await u.feedMedia(d.graphId,d.runId,r);if(!e||!a)return null;let s=URL.createObjectURL(n);return t.push(s),[r,s]}catch(e){return null}})).then(t=>{e&&H(Object.fromEntries(t.filter(e=>!!e)))}),()=>{e=!1,a&&"function"==typeof URL.revokeObjectURL&&t.forEach(e=>URL.revokeObjectURL(e))}},[u,d.graphId,d.runId,z]);let Q=(null==(t=h.brand)?void 0:t.name)||"브랜드",Z=Q.trim().charAt(0).toUpperCase()||"\xb7",Y=b.hashtags.join(" "),ee=b.cover.text!==(null!=(s=h.cover.renderedText)?s:h.cover.text)||b.cover.sub!==(null!=(l=h.cover.renderedSub)?l:h.cover.sub);return(0,r.jsxs)("article",{"aria-label":"피드 미리보기","data-feed-revision":h.revision,className:"mx-auto w-full max-w-md overflow-hidden rounded-xl border border-border bg-card text-foreground shadow-sm",children:[(0,r.jsxs)("header",{className:"flex items-center gap-3 px-3 py-2",children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted text-sm font-semibold",children:Z}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("p",{className:"truncate text-sm font-semibold",children:Q}),(null==(a=h.brand)?void 0:a.handle)&&(0,r.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:h.brand.handle})]}),(0,r.jsxs)("span",{className:"ml-auto shrink-0 text-xs text-muted-foreground",children:["수정 ",h.revision,F?" \xb7 저장 안 됨":""]})]}),(0,r.jsxs)("div",{className:"relative aspect-[4/5] w-full touch-pan-y select-none overflow-hidden bg-muted",onTouchStart:e=>{var t,a;T.current=null!=(a=null==(t=e.touches[0])?void 0:t.clientX)?a:null},onTouchEnd:e=>{var t;let a=T.current;T.current=null;let r=null==(t=e.changedTouches[0])?void 0:t.clientX;null==a||null==r||40>Math.abs(r-a)||J(r<a?1:-1)},children:[(null==V?void 0:V.image)&&G[V.image]?(0,r.jsx)("img",{src:G[V.image],alt:V.isCover?b.cover.text:null!=(o=V.caption)?o:"",className:"h-full w-full object-cover"}):(0,r.jsx)("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"이미지 불러오는 중"}),W.length>1&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button","aria-label":"이전 장",disabled:0===w,onClick:()=>J(-1),className:"absolute left-2 top-1/2 -translate-y-1/2 rounded-full bg-black/40 px-2 py-1 text-white disabled:opacity-0",children:"‹"}),(0,r.jsx)("button",{type:"button","aria-label":"다음 장",disabled:w>=W.length-1,onClick:()=>J(1),className:"absolute right-2 top-1/2 -translate-y-1/2 rounded-full bg-black/40 px-2 py-1 text-white disabled:opacity-0",children:"›"})]})]}),W.length>1&&(0,r.jsx)("div",{"aria-label":"장 표시",className:"flex justify-center gap-1.5 py-2",children:W.map((e,t)=>(0,r.jsx)("span",{"data-dot":t===w?"on":"off",className:"h-1.5 w-1.5 rounded-full ".concat(t===w?"bg-primary":"bg-muted-foreground/40")},t))}),ee&&(0,r.jsxs)("p",{"data-cover-pending":!0,className:"mx-3 mb-2 rounded border border-dashed border-border px-2 py-1 text-xs text-muted-foreground",children:["커버 문구 변경 — \xab",b.cover.text,b.cover.sub?" \xb7 ".concat(b.cover.sub):"","\xbb \xb7 게시 때 커버를 다시 그립니다"]}),(0,r.jsxs)("div",{className:"space-y-2 px-3 pb-3 text-sm",children:[(0,r.jsxs)("p",{className:"break-words",children:[(0,r.jsx)("span",{className:"font-semibold",children:Q})," ",b.caption.hook]}),b.caption.body&&(C?(0,r.jsx)("p",{className:"whitespace-pre-wrap break-words",children:b.caption.body}):(0,r.jsx)("button",{type:"button",onClick:()=>I(!0),className:"text-muted-foreground",children:"더 보기"})),b.hashtags.length>0&&(0,r.jsx)("p",{className:"flex flex-wrap gap-x-1.5 text-primary",children:b.hashtags.map((e,t)=>(0,r.jsx)("span",{className:"whitespace-nowrap",children:e},"".concat(e,"-").concat(t)))}),b.location&&(0,r.jsxs)("p",{className:"text-xs text-muted-foreground",children:["\uD83D\uDCCD ",b.location]})]}),g&&(0,r.jsxs)("section",{"aria-label":"초안 편집",className:"space-y-3 border-t border-border px-3 py-3 text-sm",children:[(0,r.jsxs)("label",{className:"block",children:["커버 문구",(0,r.jsx)("input",{value:b.cover.text,onChange:e=>f({...b,cover:{...b.cover,text:e.target.value}}),className:"mt-1 w-full rounded border border-border bg-background px-2 py-1"})]}),(0,r.jsxs)("label",{className:"block",children:["커버 부제",(0,r.jsx)("input",{value:b.cover.sub,onChange:e=>f({...b,cover:{...b.cover,sub:e.target.value}}),className:"mt-1 w-full rounded border border-border bg-background px-2 py-1"})]}),(0,r.jsxs)("label",{className:"block",children:["첫 줄",(0,r.jsx)("input",{value:b.caption.hook,onChange:e=>f({...b,caption:{...b.caption,hook:e.target.value}}),className:"mt-1 w-full rounded border border-border bg-background px-2 py-1"})]}),(0,r.jsxs)("label",{className:"block",children:["본문",(0,r.jsx)("textarea",{value:b.caption.body,rows:4,onChange:e=>f({...b,caption:{...b.caption,body:e.target.value}}),className:"mt-1 w-full rounded border border-border bg-background px-2 py-1"})]}),(0,r.jsxs)("label",{className:"block",children:["해시태그(띄어쓰기로 구분)",(0,r.jsx)("input",{value:Y,onChange:e=>f({...b,hashtags:e.target.value.split(/\s+/).filter(Boolean)}),className:"mt-1 w-full rounded border border-border bg-background px-2 py-1"})]}),(0,r.jsxs)("label",{className:"block",children:["위치(비우면 없음)",(0,r.jsx)("input",{value:null!=(c=b.location)?c:"",onChange:e=>f({...b,location:e.target.value.trim()?e.target.value:null}),className:"mt-1 w-full rounded border border-border bg-background px-2 py-1"})]}),(0,r.jsx)("ol",{"aria-label":"사진 순서",className:"space-y-2",children:b.slides.map((e,t)=>(0,r.jsxs)("li",{"data-slide":e.image,className:"rounded border border-border p-2 ".concat(e.include?"":"opacity-50"),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"w-6 shrink-0 text-xs text-muted-foreground",children:t+1}),(0,r.jsx)("input",{"aria-label":"".concat(t+1,"번 사진 설명"),value:e.caption,onChange:e=>K(t,{caption:e.target.value}),className:"min-w-0 flex-1 rounded border border-border bg-background px-2 py-1"})]}),(0,r.jsxs)("div",{className:"mt-2 flex gap-2",children:[(0,r.jsx)("button",{type:"button",disabled:0===t,onClick:()=>q(t,-1),className:"rounded border px-2 py-0.5 disabled:opacity-40",children:"앞으로"}),(0,r.jsx)("button",{type:"button",disabled:t===b.slides.length-1,onClick:()=>q(t,1),className:"rounded border px-2 py-0.5 disabled:opacity-40",children:"뒤로"}),(0,r.jsx)("button",{type:"button",onClick:()=>K(t,{include:!e.include}),className:"rounded border px-2 py-0.5",children:e.include?"빼기":"되살리기"})]})]},e.image))})]}),(U||L)&&(0,r.jsx)("p",{role:L?"alert":"status",className:"px-3 pb-2 text-sm ".concat(L?"text-red-600":"text-muted-foreground"),children:L||U}),L&&M&&(0,r.jsx)("p",{className:"px-3 pb-2 text-sm",children:(0,r.jsx)("a",{href:y,className:"font-medium underline","data-connect-token-link":!0,children:"연결 토큰 칸 열기 →"})}),(0,r.jsxs)("footer",{className:"flex flex-wrap gap-2 border-t border-border px-3 py-3",children:[(0,r.jsx)("button",{type:"button",disabled:E,onClick:()=>j(e=>!e),className:"rounded-lg border px-3 py-2 text-sm disabled:opacity-50",children:g?"편집 닫기":"편집"}),(0,r.jsx)("button",{type:"button",disabled:E||!F,onClick:()=>{X()},className:"rounded-lg border px-3 py-2 text-sm disabled:opacity-50",children:"수정 저장"}),(0,r.jsx)("button",{type:"button",disabled:E,onClick:()=>{$()},className:"rounded-lg bg-blue-600 px-3 py-2 text-sm font-medium text-white disabled:opacity-50",children:"최종 게시"}),(0,r.jsx)("button",{type:"button",disabled:E,onClick:()=>{B()},className:"ml-auto rounded-lg px-3 py-2 text-sm text-muted-foreground disabled:opacity-50",children:"거절"})]})]})}function E(){let e,{client:t}=(0,o.Q)(),a=(0,n.useMemo)(()=>(function(e){var t,a;let r=(null!=(t=e.baseUrl)?t:"").replace(/\/+$/,""),n=null!=(a=e.fetchImpl)?a:fetch;async function s(t,a){let s={...a,headers:{"content-type":"application/json",...e.authHeader?{authorization:e.authHeader}:{}}},l=e.client?await e.client.fetchResponse(t,s):await n("".concat(r).concat(t),s),o=await l.json().catch(()=>null);if(!l.ok){let e=o&&"object"==typeof o&&"error"in o&&"string"==typeof o.error?o.error:"request-failed";throw new j(l.status,e)}return o}return{list:()=>s(S),decide:(e,t,a)=>s("".concat(S,"/").concat(encodeURIComponent(e),"/").concat(encodeURIComponent(t)),{method:"POST",body:JSON.stringify({decision:a})}),saveFeedDraft:(e,t,a)=>s("".concat(S,"/").concat(encodeURIComponent(e),"/").concat(encodeURIComponent(t),"/feed-draft"),{method:"PUT",body:JSON.stringify(a)}),feedMedia:async(t,a,s)=>{let l="".concat(S,"/").concat(encodeURIComponent(t),"/").concat(encodeURIComponent(a),"/media?path=").concat(encodeURIComponent(s)),o={headers:e.authHeader?{authorization:e.authHeader}:{}},c=e.client?await e.client.fetchResponse(l,o):await n("".concat(r).concat(l),o);if(!c.ok)throw new j(c.status,"media-failed");return c.blob()}}})({client:t}),[t]),[s,l]=(0,n.useState)([]),[c,i]=(0,n.useState)(""),[d,u]=(0,n.useState)(!1),[m,p]=(0,n.useState)(!1),h=(0,n.useRef)((e=0,{begin:()=>e+=1,isLatest:t=>t===e})).current,x=(0,n.useCallback)(async()=>{let e=h.begin();try{let t=await a.list();if(!h.isLatest(e))return;l(t.items),i(""),u(!1)}catch(t){h.isLatest(e)&&(i(k(t,"list")),u(v(t)))}},[a,h]);async function b(e,t){if("rejected"!==t||window.confirm("".concat(C(e).title," 실행을 거절할까요?"))){p(!0),i(""),h.begin();try{await a.decide(e.graphId,e.runId,t),await x()}catch(e){i(k(e,"decide")),u(v(e))}finally{p(!1)}}}(0,n.useEffect)(()=>{x();let e=window.setInterval(()=>{x()},3e4);return()=>window.clearInterval(e)},[x]);let f=s.filter(e=>!!e.feed),g=s.filter(e=>!e.feed);return s.length||c?(0,r.jsxs)(r.Fragment,{children:[f.length>0&&(0,r.jsxs)("section",{"aria-label":"게시 대기",className:"mx-auto max-w-3xl space-y-4 px-4 pt-6 text-foreground sm:px-8",children:[(0,r.jsx)("h2",{className:"text-xl font-semibold",children:"게시 대기"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"고쳐서 저장해도 대기열에 남습니다. \xab최종 게시\xbb를 눌러야만 올라갑니다."}),f.map(e=>(0,r.jsx)(I,{item:e,api:a,onDecided:()=>{h.begin(),x()}},"".concat(e.graphId,"/").concat(e.runId)))]}),(g.length>0||c)&&(0,r.jsxs)("section",{"aria-label":"실행 승인",className:"mx-auto max-w-3xl space-y-4 px-4 pt-6 text-foreground sm:px-8",children:[(0,r.jsx)("h2",{className:"text-xl font-semibold",children:"실행 승인"}),c&&(0,r.jsx)("p",{role:"alert",className:"text-sm text-red-600",children:c}),c&&d&&(0,r.jsx)("p",{className:"text-sm",children:(0,r.jsx)("a",{href:y,className:"font-medium underline","data-connect-token-link":!0,children:"연결 토큰 칸 열기 →"})}),g.map(e=>{let t=C(e);return(0,r.jsxs)("article",{className:"rounded-xl border border-border bg-card p-5 shadow-sm",children:[(0,r.jsx)("h3",{className:"font-semibold",children:t.title}),(0,r.jsxs)("p",{className:"mt-1 text-sm text-muted-foreground",children:["멈춘 단계: ",t.nodeId," \xb7 ",t.waiting,"부터 대기 중"]}),(0,r.jsx)("p",{className:"mt-3 whitespace-pre-wrap break-words text-sm",children:t.message}),t.recent.length>0&&(0,r.jsxs)("div",{className:"mt-3 text-sm",children:[(0,r.jsx)("p",{className:"font-medium",children:"최근 단계"}),(0,r.jsx)("ul",{className:"mt-1 space-y-1",children:t.recent.map((e,t)=>(0,r.jsx)("li",{className:"break-words",children:e},t))})]}),(0,r.jsxs)("div",{className:"mt-4 flex gap-2",children:[(0,r.jsx)("button",{type:"button",disabled:m,onClick:()=>{b(e,"approved")},className:"rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white disabled:opacity-50",children:"승인"}),(0,r.jsx)("button",{type:"button",disabled:m,onClick:()=>{b(e,"rejected")},className:"rounded-lg border px-4 py-2 text-sm disabled:opacity-50",children:"거절"})]})]},"".concat(e.graphId,"/").concat(e.runId))})]})]}):null}function R(){return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(E,{}),(0,r.jsx)(g,{})]})}}},e=>{e.O(0,[2330,8519,2367,6725,7358],()=>e(e.s=11161)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8457],{59062:(e,r,t)=>{"use strict";t.d(r,{p:()=>a});var i=t(41121);t(91269);var l=t(94114),n=t(82157);function a(e){let{className:r,type:t,...a}=e;return(0,i.jsx)(l.p,{type:t,"data-slot":"input",className:(0,n.cn)("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",r),...a})}},65761:(e,r,t)=>{Promise.resolve().then(t.bind(t,6090))},67089:(e,r,t)=>{"use strict";t.d(r,{A:()=>i});let i=(0,t(89117).A)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},89117:(e,r,t)=>{"use strict";t.d(r,{A:()=>d});var i=t(91269);let l=function(){for(var e=arguments.length,r=Array(e),t=0;t<e;t++)r[t]=arguments[t];return r.filter((e,r,t)=>!!e&&""!==e.trim()&&t.indexOf(e)===r).join(" ").trim()},n=e=>{let r=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,r,t)=>t?t.toUpperCase():r.toLowerCase());return r.charAt(0).toUpperCase()+r.slice(1)};var a={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let o=(0,i.createContext)({}),s=(0,i.forwardRef)((e,r)=>{var t,n,s;let{color:d,size:u,strokeWidth:c,absoluteStrokeWidth:f,className:p="",children:b,iconNode:h,...g}=e,{size:m=24,strokeWidth:v=2,absoluteStrokeWidth:k=!1,color:w="currentColor",className:x=""}=null!=(t=(0,i.useContext)(o))?t:{},y=(null!=f?f:k)?24*Number(null!=c?c:v)/Number(null!=u?u:m):null!=c?c:v;return(0,i.createElement)("svg",{ref:r,...a,width:null!=(n=null!=u?u:m)?n:a.width,height:null!=(s=null!=u?u:m)?s:a.height,stroke:null!=d?d:w,strokeWidth:y,className:l("lucide",x,p),...!b&&!(e=>{for(let r in e)if(r.startsWith("aria-")||"role"===r||"title"===r)return!0;return!1})(g)&&{"aria-hidden":"true"},...g},[...h.map(e=>{let[r,t]=e;return(0,i.createElement)(r,t)}),...Array.isArray(b)?b:[b]])}),d=(e,r)=>{let t=(0,i.forwardRef)((t,a)=>{let{className:o,...d}=t;return(0,i.createElement)(s,{ref:a,iconNode:r,className:l("lucide-".concat(n(e).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()),"lucide-".concat(e),o),...d})});return t.displayName=n(e),t}}},e=>{e.O(0,[2977,216,6062,4114,2330,1377,8519,3441,2929,6284,8619,6090,2367,6725,7358],()=>e(e.s=65761)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6348],{6015:(e,t,s)=>{"use strict";s.d(t,{n:()=>d});var n=s(91269),r=s(95817),i=s(83026),a=s(37963),l=s(98883),o=class extends a.Q{#e;#t=void 0;#s;#n;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),(0,l.f8)(this.options,t)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),t?.mutationKey&&this.options.mutationKey&&(0,l.EN)(t.mutationKey)!==(0,l.EN)(this.options.mutationKey)?this.reset():this.#s?.state.status==="pending"&&this.#s.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#s?.removeObserver(this)}onMutationUpdate(e){this.#r(),this.#i(e)}getCurrentResult(){return this.#t}reset(){this.#s?.removeObserver(this),this.#s=void 0,this.#r(),this.#i()}mutate(e,t){return this.#n=t,this.#s?.removeObserver(this),this.#s=this.#e.getMutationCache().build(this.#e,this.options),this.#s.addObserver(this),this.#s.execute(e)}#r(){let e=this.#s?.state??(0,r.$)();this.#t={...e,isPending:"pending"===e.status,isSuccess:"success"===e.status,isError:"error"===e.status,isIdle:"idle"===e.status,mutate:this.mutate,reset:this.reset}}#i(e){i.jG.batch(()=>{if(this.#n&&this.hasListeners()){let t=this.#t.variables,s=this.#t.context,n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{this.#n.onSuccess?.(e.data,t,s,n)}catch(e){Promise.reject(e)}try{this.#n.onSettled?.(e.data,null,t,s,n)}catch(e){Promise.reject(e)}}else if(e?.type==="error"){try{this.#n.onError?.(e.error,t,s,n)}catch(e){Promise.reject(e)}try{this.#n.onSettled?.(void 0,e.error,t,s,n)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},c=s(24818);function d(e,t){let s=(0,c.jE)(t),[r]=n.useState(()=>new o(s,e));n.useEffect(()=>{r.setOptions(e)},[r,e]);let a=n.useSyncExternalStore(n.useCallback(e=>r.subscribe(i.jG.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),d=n.useCallback((e,t)=>{r.mutate(e,t).catch(l.lQ)},[r]);if(a.error&&(0,l.GU)(r.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:d,mutateAsync:a.mutate}}},11635:(e,t,s)=>{"use strict";s.d(t,{A:()=>n});let n=(0,s(89117).A)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},29170:(e,t,s)=>{Promise.resolve().then(s.bind(s,82301))},42310:(e,t,s)=>{"use strict";s.d(t,{A:()=>n});let n=(0,s(89117).A)("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"}]])},51215:(e,t,s)=>{"use strict";let n;s.d(t,{cY:()=>d,x8:()=>l});let r={debug:0,info:1,warn:2,error:3},i="/v1/debug-logs/batch",a=null;function l(e){a=e}class o{health(){return{pending:this.queue.length,consecutiveFailures:this.consecutiveFailures,lastOkAt:this.lastOkAt,droppedByCap:this.droppedByCap,fallbackBatches:this.fallbackBatches}}push(e){if(!(r[function(e){let t=e.slice(e.lastIndexOf(".")+1).toLowerCase();return/^(error|exception|crash|fail|failed)$/.test(t)?"error":/^(warn|degraded|timeout)$/.test(t)?"warn":/^(boot|ready|start|begin|open|ok|done|resolve|end|stop|close)$/.test(t)?"info":"debug"}(e.category)]<r[this.minLevel])){if(this.queue.push(e),this.queue.length>500){let e=this.queue.length-500;this.droppedByCap+=e,this.queue.splice(0,e)}if(this.queue.length>=100&&!this.inFlight){null!==this.timer&&(clearTimeout(this.timer),this.timer=null),this.flush();return}null===this.timer&&(this.timer=setTimeout(()=>{this.flush()},this.flushMs))}}async flush(){if(this.timer&&(clearTimeout(this.timer),this.timer=null),this.inFlight||0===this.queue.length)return;let e=this.queue.slice(0,100);this.inFlight=!0;let t=!1,s=JSON.stringify({records:e});try{var n,r;t=await (n=this.fetchFn(s),r=this.postTimeoutMs,new Promise((e,t)=>{let s=setTimeout(()=>t(Error("debug-forward timeout after ".concat(r,"ms"))),r);n.then(t=>{clearTimeout(s),e(t)},e=>{clearTimeout(s),t(e)})}))}catch(e){t=!1}finally{this.inFlight=!1}if(!t){if(this.consecutiveFailures+=1,this.consecutiveFailures>=2&&a)try{await a(JSON.stringify({records:[...e,this.blockedNotice()]}))&&(this.fallbackBatches+=1)}catch(e){}this.wasFailing=!0,this.scheduleRetry();return}let i=this.lastOkAt;this.lastOkAt=Date.now();let l=this.consecutiveFailures;this.consecutiveFailures=0,this.queue.splice(0,e.length),this.wasFailing&&(this.wasFailing=!1,this.queue.push({ts:new Date().toISOString(),category:"pwa.debug-forwarder.recovered",event:"recovered",data:{consecutiveFailures:l,droppedByCap:this.droppedByCap,fallbackBatches:this.fallbackBatches,pending:this.queue.length,previousOkAt:i},source:{platform:"pwa"}})),this.queue.length>0&&null===this.timer&&(this.timer=setTimeout(()=>{this.flush()},this.flushMs))}scheduleRetry(){if(null!==this.timer||0===this.queue.length)return;let e=Math.min(this.flushMs*2**this.consecutiveFailures,3e4);this.timer=setTimeout(()=>{this.flush()},e)}blockedNotice(){return{ts:new Date().toISOString(),category:"pwa.debug-forwarder.http-blocked",event:"http-blocked",data:{consecutiveFailures:this.consecutiveFailures,pending:this.queue.length,droppedByCap:this.droppedByCap,lastOkAt:this.lastOkAt,via:"acp-fallback"},source:{platform:"pwa"}}}beaconFlush(){if(0!==this.queue.length)try{if("undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){let e=this.queue.slice(0,100),t=new Blob([JSON.stringify({records:e})],{type:"application/json"});navigator.sendBeacon(i,t)&&this.queue.splice(0,e.length)}}catch(e){}}get pending(){return this.queue.length}constructor(e=c,t="debug",s=1e4,n=100){this.fetchFn=e,this.minLevel=t,this.postTimeoutMs=s,this.flushMs=n,this.queue=[],this.timer=null,this.inFlight=!1,this.consecutiveFailures=0,this.lastOkAt=null,this.droppedByCap=0,this.fallbackBatches=0,this.wasFailing=!1}}async function c(e){return(await fetch(i,{method:"POST",headers:{"content-type":"application/json"},body:e,keepalive:!0,..."undefined"!=typeof AbortSignal&&"function"==typeof AbortSignal.timeout?{signal:AbortSignal.timeout(1e4)}:{}})).ok}function d(e,t){if("undefined"==typeof console)return;let s=new Date().toISOString();if(void 0!==t){let n="";try{let e=new WeakSet;n=JSON.stringify(t,(t,s)=>{if("bigint"==typeof s)return"".concat(s.toString(),"n");if("function"==typeof s)return"[fn ".concat(s.name||"anon","]");if(s&&"object"==typeof s){if(e.has(s))return"[circular]";e.add(s)}return s})}catch(e){n="[unserializable: ".concat(String(e),"]")}n&&n.length>800&&(n=n.slice(0,797)+"..."),console.debug("[".concat(s,"] ").concat(e," ").concat(n),t),u(s,e,n)}else console.debug("[".concat(s,"] ").concat(e)),u(s,e,void 0)}function u(e,t,s){let r,i=function(){if(void 0!==n)return n;let e=function(){try{let e="off"!==window.localStorage.getItem("elanous.pwa.debug.forward"),t=window.localStorage.getItem("elanous.pwa.debug.forwardLevel");return{forward:e,level:"info"===t||"warn"===t||"error"===t?t:"debug"}}catch(e){return{forward:!0,level:"debug"}}}();if(!e.forward)return n=null,null;let t=new o(c,e.level,1e4,1500);try{window.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&t.beaconFlush()})}catch(e){}return n=t,t}();if(!i)return;let a=t.slice(t.lastIndexOf(".")+1)||t;if(void 0!==s&&""!==s)try{r=JSON.parse(s)}catch(e){r=s}i.push({ts:e,category:t,event:a,...void 0!==r?{data:r}:{},source:{platform:"pwa"}})}},67842:(e,t,s)=>{"use strict";s.d(t,{AF:()=>n});let n={all:["nexus"],health:()=>[...n.all,"health"],snapshot:()=>[...n.all,"snapshot"],tabs:e=>e?[...n.all,"tabs",{kind:e}]:[...n.all,"tabs"],tab:e=>[...n.all,"tab",e],templates:()=>[...n.all,"templates"],template:e=>[...n.all,"template",e],config:()=>[...n.all,"config"],switches:()=>[...n.all,"switches"],switch:e=>[...n.all,"switch",e],secrets:()=>[...n.all,"secrets"],bindingChannels:()=>[...n.all,"bindings","channels"],bindings:e=>[...n.all,"bindings",e],binding:(e,t)=>[...n.all,"binding",e,t],logsTail:(e,t)=>t?[...n.all,"logs",e,{lines:t}]:[...n.all,"logs",e],workflows:()=>[...n.all,"workflows"],workflow:e=>[...n.all,"workflow",e],workflowRun:e=>[...n.all,"workflow-run",e],workflowRuns:()=>[...n.all,"workflow-runs"],pendingApprovals:()=>[...n.all,"workflow-pending-approvals"],platforms:()=>[...n.all,"platforms"],providers:()=>[...n.all,"providers"],worktrees:()=>[...n.all,"worktrees"],designCheck:()=>[...n.all,"design-check"],designPreviews:()=>[...n.all,"design-previews"],designPreview:e=>[...n.all,"design-preview",e],registryCatalog:()=>[...n.all,"registry-catalog"],resolvedView:()=>[...n.all,"resolved-view"]};n.snapshot(),n.tabs(),n.health(),n.snapshot(),n.config(),n.switches()},82301:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>E});var n=s(41121),r=s(93981),i=s(11635);let a=(0,s(89117).A)("circle-dashed",[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]]);var l=s(42310),o=s(99608),c=s(91269),d=s(91514),u=s(42012),h=s(24818),m=s(6015),p=s(67842),g=s(42375);function f(e){let{available:t,declared:s,onPick:r,pendingId:i,previews:a,onPreview:l}=e,{systems:o,themes:c}=function(e){let t=[],s=[];for(let n of e)("design-system"===n.source?t:s).push(n);return{systems:t,themes:s}}(t);return(0,n.jsxs)("div",{className:"space-y-4",children:[o.length>0&&(0,n.jsx)(x,{title:"Design systems",hint:"Web \xb7 copies tokens.css and DESIGN.md into design/system/",items:o,declared:s,onPick:r,pendingId:i,previews:a,onPreview:l}),c.length>0&&(0,n.jsx)(x,{title:"Terminal themes",hint:"One line in DESIGN.md",items:c,declared:s,onPick:r,pendingId:i,previews:a,onPreview:l})]})}function x(e){let{title:t,hint:s,items:r,declared:i,onPick:a,pendingId:l,previews:o,onPreview:c}=e;return(0,n.jsxs)("section",{className:"space-y-2","aria-label":t,children:[(0,n.jsxs)("h3",{className:"flex items-baseline gap-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:[t,(0,n.jsxs)("span",{className:"normal-case tracking-normal",children:[r.length," \xb7 ",s]})]}),(0,n.jsx)("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:r.map(e=>(0,n.jsx)(b,{direction:e,chosen:e.id===i,onPick:a,pending:l===e.id,busy:null!==l,hasPreview:(null==o?void 0:o.has(e.id))===!0&&void 0!==c,onPreview:c},e.id))})]})}function b(e){var t,s,r,a,l,o,c,d,u;let{direction:h,chosen:m,onPick:p,pending:g,busy:f,hasPreview:x,onPreview:b}=e,y=null!=(r=h.swatch.bg)?r:h.isDark?"#111111":"#ffffff",v=null!=(a=h.swatch.fg)?a:h.swatch.text,w=null!=(o=null!=(l=null==(t=h.typography)?void 0:t.display)?l:null==(s=h.typography)?void 0:s.body)?o:null;return(0,n.jsxs)("li",{"data-direction":h.id,"data-direction-id":h.id,className:"flex flex-col gap-2 rounded-md border p-3 text-sm ".concat(m?"border-primary ring-1 ring-primary":""),children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5","aria-hidden":!0,children:[[y,v,h.swatch.accent].map((e,t)=>(0,n.jsx)("span",{className:"h-5 w-5 rounded-full border",style:{backgroundColor:e,borderColor:h.swatch.muted}},t)),h.category&&(0,n.jsx)("span",{className:"ml-auto truncate text-[11px] text-muted-foreground",children:h.category})]}),(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("p",{className:"truncate font-medium",children:null!=(c=h.label)?c:h.id}),(0,n.jsxs)("p",{className:"truncate text-xs text-muted-foreground",children:[(0,n.jsx)("code",{children:h.id}),w?" \xb7 ".concat(w):""]}),(0,n.jsx)("p",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:h.mood})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[x&&(0,n.jsx)("button",{type:"button",onClick:()=>null==b?void 0:b(h.id),className:"self-start rounded-md border px-2.5 py-1 text-xs hover:bg-muted","aria-label":"Preview ".concat(null!=(d=h.label)?d:h.id),children:"Preview"}),m?(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-primary",children:[(0,n.jsx)(i.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Selected"]}):(0,n.jsx)("button",{type:"button",disabled:f,onClick:()=>p(h.id),className:"self-start rounded-md border px-2.5 py-1 text-xs hover:bg-muted disabled:opacity-50","aria-label":"Select ".concat(null!=(u=h.label)?u:h.id),children:g?"Selecting…":"Select"})]})]})}let y=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;function v(e){return e.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function w(e,t){if("undefined"==typeof document)return t;let s=document.getElementById(e);return s&&"value"in s&&"string"==typeof s.value?s.value:t}function k(e){let{onCreate:t,onSelect:s,pending:r,result:i,error:a}=e,[l,o]=(0,c.useState)("url"),[d,u]=(0,c.useState)(""),[h,m]=(0,c.useState)(""),[p,g]=(0,c.useState)(""),f=v(h).filter(e=>y.test(e)),x=v(h).length,b=x>=2&&x<=6&&p.trim().length>0&&f.length===x;return(0,n.jsxs)("section",{className:"rounded-md border p-3","aria-label":"Make my system","data-make-my-system":"",children:[(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,n.jsx)("h3",{className:"text-sm font-medium",children:"Make my system"}),(0,n.jsxs)("div",{className:"flex gap-1",role:"tablist",children:[(0,n.jsx)("button",{type:"button",role:"tab","aria-selected":"url"===l,className:"rounded-md px-2 py-1 text-xs ".concat("url"===l?"bg-muted":""),onClick:()=>o("url"),children:"From a website"}),(0,n.jsx)("button",{type:"button",role:"tab","aria-selected":"colors"===l,className:"rounded-md px-2 py-1 text-xs ".concat("colors"===l?"bg-muted":""),onClick:()=>o("colors"),children:"From colors"})]})]}),(0,n.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Reference, not a copy — logos, names, images and text are not taken."}),"url"===l?(0,n.jsxs)("form",{className:"mt-2 flex flex-col gap-2 sm:flex-row",onSubmit:e=>{e.preventDefault();let s=d.trim();s&&!r&&t({kind:"url",url:s})},children:[(0,n.jsx)("label",{className:"sr-only",htmlFor:"make-system-url",children:"Website URL"}),(0,n.jsx)("input",{id:"make-system-url",type:"url",value:d,disabled:r,placeholder:"https://example.com",onChange:e=>u(e.target.value),className:"min-w-0 flex-1 rounded-md border bg-transparent px-2 py-1.5 text-sm"}),(0,n.jsx)("button",{type:"button",disabled:r,onClick:()=>{let e=w("make-system-url",d).trim();e&&!r&&t({kind:"url",url:e})},className:"rounded-md border px-3 py-1.5 text-sm hover:bg-muted disabled:opacity-50",children:r?"Measuring…":"Make it"})]}):(0,n.jsxs)("form",{className:"mt-2 space-y-2",onSubmit:e=>{e.preventDefault(),b&&!r&&t({kind:"palette",colors:f,id:p.trim()})},children:[(0,n.jsx)("label",{className:"block text-xs text-muted-foreground",htmlFor:"make-system-colors",children:"2–6 colors"}),(0,n.jsx)("input",{id:"make-system-colors",value:h,disabled:r,placeholder:"#f4efe6, #1f3a2e, #c8553d",onChange:e=>m(e.target.value),className:"w-full rounded-md border bg-transparent px-2 py-1.5 text-sm"}),f.length>0&&(0,n.jsx)("ul",{className:"flex gap-1","aria-label":"Color preview",children:f.map(e=>(0,n.jsx)("li",{className:"h-6 w-6 rounded-sm border",style:{backgroundColor:e},title:e},e))}),(0,n.jsx)("label",{className:"block text-xs text-muted-foreground",htmlFor:"make-system-id",children:"id"}),(0,n.jsx)("input",{id:"make-system-id",value:p,disabled:r,placeholder:"stumptowncoffee",onChange:e=>g(e.target.value),className:"w-full rounded-md border bg-transparent px-2 py-1.5 text-sm"}),(0,n.jsx)("button",{type:"button",disabled:r,onClick:()=>{let e=v(w("make-system-colors",h)).filter(e=>y.test(e)),s=w("make-system-id",p).trim();r||e.length<2||e.length>6||0===s.length||t({kind:"palette",colors:e,id:s})},className:"rounded-md border px-3 py-1.5 text-sm hover:bg-muted disabled:opacity-50",children:r?"Measuring…":"Make it"})]}),r&&(0,n.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Measuring…"}),a&&(0,n.jsx)("p",{className:"mt-2 text-sm text-error",role:"alert",children:a}),i&&(0,n.jsxs)("div",{className:"mt-2 space-y-1 text-sm",children:[(0,n.jsxs)("p",{children:["Made ",i.id," — ",i.tokens.length," tokens \xb7 ",i.unread," unread"]}),i.warnings.map(e=>(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:e},e)),(0,n.jsx)("button",{type:"button",onClick:()=>s(i.id),className:"rounded-md border px-2.5 py-1 text-xs hover:bg-muted",children:"Select it"})]})]})}let j={missing:"Missing",declared:"Declared",available:"Not declared"},N={missing:"bg-error/10 text-error",declared:"bg-green-600/10 text-green-700",available:"bg-muted text-muted-foreground"},S={missing:r.A,declared:i.A,available:a};function C(){return(0,d.Qj)()?(0,n.jsx)(M,{}):(0,n.jsxs)("div",{className:"mx-auto max-w-2xl space-y-2 p-6",children:[(0,n.jsx)("h1",{className:"text-xl font-semibold tracking-tight",children:"Design check"}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Connect to a NEXUS daemon to see this repository's craft rulebooks."})]})}function M(){let{data:e,isLoading:t,error:s,refetch:i,isFetching:a}=function(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=(0,d.M1)();return(0,u.I)({queryKey:p.AF.designCheck(),queryFn:()=>s.getDesignCheck(),enabled:null==(e=t.enabled)||e,refetchInterval:3e4})}();return(0,n.jsxs)("div",{className:"mx-auto max-w-3xl space-y-4 p-6",children:[(0,n.jsxs)("header",{className:"flex items-start justify-between gap-4",children:[(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsxs)("h1",{className:"flex items-center gap-2 text-xl font-semibold tracking-tight",children:[(0,n.jsx)(l.A,{className:"h-5 w-5","aria-hidden":!0}),"Design check"]}),(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Craft rulebooks declared by this repository's ",(0,n.jsx)("code",{children:"DESIGN.md"}),"."]})]}),(0,n.jsxs)("button",{type:"button",onClick:()=>void i(),className:"inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1.5 text-sm hover:bg-muted","aria-label":"Refresh design check",children:[(0,n.jsx)(o.A,{className:"h-4 w-4 ".concat(a?"animate-spin":""),"aria-hidden":!0}),"Refresh"]})]}),t&&(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading…"}),s&&(0,n.jsxs)("p",{className:"rounded-md bg-error/10 p-3 text-sm text-error",children:["Could not reach the daemon: ",s instanceof Error?s.message:String(s)]}),e&&!1===e.ok&&(0,n.jsxs)("div",{className:"space-y-2 rounded-md border border-warning/40 bg-warning/5 p-4",children:[(0,n.jsxs)("p",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,n.jsx)(r.A,{className:"h-4 w-4 text-warning","aria-hidden":!0}),"Design check blocked"]}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:function(e,t){switch(e){case"no-repository":return"The daemon is not running inside a git checkout, so there is no DESIGN.md to check.";case"craft-directory":return"elanous's craft rulebook directory could not be read: ".concat(null!=t?t:"(unknown path)");case"design-document":return"This repository has no readable DESIGN.md: ".concat(null!=t?t:"(unknown path)");default:return"The design check is blocked (".concat(e,").")}}(e.blockedOn,e.path)})]}),e&&!0===e.ok&&(0,n.jsx)(F,{data:e})]})}function F(e){let{data:t}=e,s=function(e){let t=new Set(e.unavailableRulebooks),s=new Map;for(let t of e.availableRulebooks)s.set(t,"available");for(let n of e.declaredRulebooks)s.set(n,t.has(n)?"missing":"declared");let n={missing:0,declared:1,available:2};return[...s.entries()].map(e=>{let[t,s]=e;return{name:t,status:s}}).sort((e,t)=>n[e.status]-n[t.status]||e.name.localeCompare(t.name))}(t),r=t.unavailableRulebooks.length;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"rounded-md p-3 text-sm ".concat(r?"bg-error/10 text-error":"bg-green-600/10 text-green-700"),children:r?"".concat(r," declared rulebook").concat(1===r?"":"s"," could not be found."):"All ".concat(t.declaredRulebooks.length," declared rulebook").concat(1===t.declaredRulebooks.length?"":"s"," resolve.")}),(0,n.jsxs)("dl",{className:"grid grid-cols-1 gap-1 text-xs text-muted-foreground sm:grid-cols-2",children:[(0,n.jsxs)("div",{className:"truncate sm:col-span-2",children:[(0,n.jsx)("dt",{className:"inline font-medium",children:"Repository: "}),(0,n.jsxs)("dd",{className:"inline",children:[(0,n.jsx)("code",{children:t.repoRoot}),t.repoSource&&(0,n.jsxs)("span",{className:"ml-1",children:["(","config"===t.repoSource?"harness.defaultRepo":"daemon folder",")"]})]})]}),(0,n.jsxs)("div",{className:"truncate",children:[(0,n.jsx)("dt",{className:"inline font-medium",children:"Document: "}),(0,n.jsx)("dd",{className:"inline",children:(0,n.jsx)("code",{children:t.documentPath})})]}),(0,n.jsxs)("div",{className:"truncate",children:[(0,n.jsx)("dt",{className:"inline font-medium",children:"Rulebooks: "}),(0,n.jsx)("dd",{className:"inline",children:(0,n.jsx)("code",{children:t.craftDirectory})})]})]}),(0,n.jsx)(O,{data:t}),0===s.length?(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"elanous ships no craft rulebooks and this document declares none."}):(0,n.jsx)("ul",{className:"divide-y rounded-md border",children:s.map(e=>{let t=S[e.status];return(0,n.jsxs)("li",{className:"flex items-center justify-between gap-3 px-3 py-2",children:[(0,n.jsxs)("span",{className:"flex items-center gap-2 text-sm",children:[(0,n.jsx)(t,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),(0,n.jsx)("code",{children:e.name})]}),(0,n.jsx)("span",{className:"shrink-0 rounded-full px-2 py-0.5 text-xs ".concat(N[e.status]),children:j[e.status]})]},e.name)})})]})}function O(e){var t,s,r,i;let{data:a}=e,l=function(){let e=(0,d.M1)(),t=(0,h.jE)();return(0,m.n)({mutationFn:t=>e.setDesignDirection(t),onSuccess:()=>t.invalidateQueries({queryKey:p.AF.designCheck()})})}(),o=function(){let e=(0,d.M1)(),t=(0,h.jE)();return(0,m.n)({mutationFn:t=>e.createDesignSystem(t),onSuccess:()=>t.invalidateQueries({queryKey:p.AF.designCheck()})})}(),x=function(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=(0,d.M1)();return(0,u.I)({queryKey:p.AF.designPreviews(),queryFn:()=>s.listDesignPreviews(),enabled:null==(e=t.enabled)||e,refetchInterval:3e4})}(),[b,y]=(0,c.useState)(null),[v,w]=(0,c.useState)(null),j=a.directions;if((0,c.useEffect)(()=>{if(!v||!j)return;let e=document.querySelector('[data-direction-id="'.concat(v.replace(/"/g,""),'"]'));null==e||e.scrollIntoView({block:"nearest"})},[v,j]),!j)return null;let N=l.isPending&&null!=(s=l.variables)?s:null;return(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsx)("h2",{className:"text-sm font-medium",children:"Design direction"}),(0,n.jsx)(k,{pending:o.isPending,result:null!=(r=o.data)?r:null,error:o.isError?function(e){switch(e instanceof g.Iu&&e.body&&"object"==typeof e.body?e.body.reason:void 0){case"bad-url":return"That address is not an http or https URL.";case"bad-id":return"The id may only use lowercase letters, digits, and hyphens.";case"id-taken":return"That id is already taken.";case"extract-failed":return"The page could not be measured.";case"no-colors":return"Give between 2 and 6 colors.";case"busy":return"Another system is being made — wait for it to finish.";default:if(e instanceof g.Iu&&401===e.status)return"Only the owner can make a system — sign in first.";return"Could not make the system: ".concat(e instanceof Error?e.message:String(e))}}(o.error):null,onCreate:e=>{o.mutate(e,{onSuccess:e=>w(e.id)})},onSelect:e=>{w(e),l.mutate(e)}}),j.unavailable&&(0,n.jsxs)("p",{className:"rounded-md bg-error/10 p-2 text-sm text-error",children:["Declared direction ",(0,n.jsx)("code",{children:j.unavailable})," is not registered."]}),null===j.declared&&!j.unavailable&&(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"None declared — pick one below."}),l.isError&&(0,n.jsx)("p",{className:"rounded-md bg-error/10 p-2 text-sm text-error",children:function(e){switch(e instanceof g.Iu&&e.body&&"object"==typeof e.body?e.body.reason:void 0){case"unknown-direction":return"The daemon does not know this direction.";case"no-repository":return"The daemon has no repository to write to (set harness.defaultRepo).";case"conflicting-system-file":return"design/system/ already holds a file the daemon will not overwrite.";case"cannot-read":return"The DESIGN.md could not be read.";case"cannot-write":return"The DESIGN.md could not be written.";default:if(e instanceof g.Iu&&401===e.status)return"Only the owner can pick a direction — sign in first.";return"Could not set the direction: ".concat(e instanceof Error?e.message:String(e))}}(l.error)}),b&&(0,n.jsx)(A,{system:b,onClose:()=>y(null),onSelect:()=>l.mutate(b),selecting:N===b,busy:null!==N,alreadySelected:j.declared===b}),(0,n.jsx)(f,{available:j.available,declared:j.declared,pendingId:N,previews:new Set((null!=(i=null==(t=x.data)?void 0:t.previews)?i:[]).map(e=>e.system)),onPreview:e=>y(e),onPick:e=>l.mutate(e)})]})}function A(e){let{system:t,onClose:s,onSelect:r,selecting:i,busy:a,alreadySelected:l}=e,o=function(e){let t=(0,d.M1)();return(0,u.I)({queryKey:p.AF.designPreview(null!=e?e:""),queryFn:()=>t.getDesignPreview(e),enabled:null!==e&&""!==e})}(t);return(0,n.jsxs)("div",{className:"space-y-2 rounded-md border p-3",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,n.jsxs)("p",{className:"text-sm font-medium",children:["Preview \xb7 ",(0,n.jsx)("code",{children:t})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[l?(0,n.jsx)("span",{className:"text-xs text-primary",children:"Selected"}):(0,n.jsx)("button",{type:"button",disabled:a,onClick:r,className:"rounded-md border px-2.5 py-1 text-xs hover:bg-muted disabled:opacity-50","aria-label":"Select ".concat(t),children:i?"Selecting…":"Select"}),(0,n.jsx)("button",{type:"button",onClick:s,className:"rounded-md border px-2.5 py-1 text-xs hover:bg-muted","aria-label":"Close preview",children:"Close"})]})]}),o.isLoading&&(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading preview…"}),o.isError&&(0,n.jsxs)("p",{className:"text-sm text-error",children:["Could not load the preview: ",o.error instanceof Error?o.error.message:String(o.error)]}),o.data&&(0,n.jsx)("iframe",{sandbox:"",srcDoc:o.data.html,title:"Preview \xb7 ".concat(t),className:"h-80 w-full rounded-md border bg-white"})]})}function E(){return(0,n.jsx)(C,{})}},91514:(e,t,s)=>{"use strict";s.d(t,{M1:()=>c,Qj:()=>d,tI:()=>o});var n=s(41121),r=s(91269),i=s(19855),a=s(24818);let l=(0,r.createContext)(null);function o(e){let{client:t,queryClient:s,defaultStaleTimeMs:o,children:c}=e,d=(0,r.useMemo)(()=>null!=s?s:new i.E({defaultOptions:{queries:{staleTime:null!=o?o:2e3,refetchOnWindowFocus:!1}}}),[s,o]);return(0,n.jsx)(l.Provider,{value:t,children:(0,n.jsx)(a.Ht,{client:d,children:c})})}function c(){let e=(0,r.useContext)(l);if(!e)throw Error("useNexusClient must be used within <NexusProvider>");return e}function d(){return(0,r.useContext)(l)}},91644:(e,t,s)=>{"use strict";s.d(t,{Qb:()=>a,SI:()=>o,dJ:()=>l});let n="elanous:auth-required",r=null,i=!1;function a(e){null===r&&(r=e,window.dispatchEvent(new CustomEvent(n,{detail:{path:e}})))}function l(e){let t=window,s=t=>e(t.detail);return t.addEventListener(n,s),null===r||i||e({path:r}),()=>t.removeEventListener(n,s)}function o(){i=!0}},93981:(e,t,s)=>{"use strict";s.d(t,{A:()=>n});let n=(0,s(89117).A)("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"}]])},99608:(e,t,s)=>{"use strict";s.d(t,{A:()=>n});let n=(0,s(89117).A)("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"}]])}},e=>{e.O(0,[920,6998,2375,2367,6725,7358],()=>e(e.s=29170)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6766],{51215:(e,t,r)=>{"use strict";let n;r.d(t,{cY:()=>c,x8:()=>o});let a={debug:0,info:1,warn:2,error:3},l="/v1/debug-logs/batch",s=null;function o(e){s=e}class i{health(){return{pending:this.queue.length,consecutiveFailures:this.consecutiveFailures,lastOkAt:this.lastOkAt,droppedByCap:this.droppedByCap,fallbackBatches:this.fallbackBatches}}push(e){if(!(a[function(e){let t=e.slice(e.lastIndexOf(".")+1).toLowerCase();return/^(error|exception|crash|fail|failed)$/.test(t)?"error":/^(warn|degraded|timeout)$/.test(t)?"warn":/^(boot|ready|start|begin|open|ok|done|resolve|end|stop|close)$/.test(t)?"info":"debug"}(e.category)]<a[this.minLevel])){if(this.queue.push(e),this.queue.length>500){let e=this.queue.length-500;this.droppedByCap+=e,this.queue.splice(0,e)}if(this.queue.length>=100&&!this.inFlight){null!==this.timer&&(clearTimeout(this.timer),this.timer=null),this.flush();return}null===this.timer&&(this.timer=setTimeout(()=>{this.flush()},this.flushMs))}}async flush(){if(this.timer&&(clearTimeout(this.timer),this.timer=null),this.inFlight||0===this.queue.length)return;let e=this.queue.slice(0,100);this.inFlight=!0;let t=!1,r=JSON.stringify({records:e});try{var n,a;t=await (n=this.fetchFn(r),a=this.postTimeoutMs,new Promise((e,t)=>{let r=setTimeout(()=>t(Error("debug-forward timeout after ".concat(a,"ms"))),a);n.then(t=>{clearTimeout(r),e(t)},e=>{clearTimeout(r),t(e)})}))}catch(e){t=!1}finally{this.inFlight=!1}if(!t){if(this.consecutiveFailures+=1,this.consecutiveFailures>=2&&s)try{await s(JSON.stringify({records:[...e,this.blockedNotice()]}))&&(this.fallbackBatches+=1)}catch(e){}this.wasFailing=!0,this.scheduleRetry();return}let l=this.lastOkAt;this.lastOkAt=Date.now();let o=this.consecutiveFailures;this.consecutiveFailures=0,this.queue.splice(0,e.length),this.wasFailing&&(this.wasFailing=!1,this.queue.push({ts:new Date().toISOString(),category:"pwa.debug-forwarder.recovered",event:"recovered",data:{consecutiveFailures:o,droppedByCap:this.droppedByCap,fallbackBatches:this.fallbackBatches,pending:this.queue.length,previousOkAt:l},source:{platform:"pwa"}})),this.queue.length>0&&null===this.timer&&(this.timer=setTimeout(()=>{this.flush()},this.flushMs))}scheduleRetry(){if(null!==this.timer||0===this.queue.length)return;let e=Math.min(this.flushMs*2**this.consecutiveFailures,3e4);this.timer=setTimeout(()=>{this.flush()},e)}blockedNotice(){return{ts:new Date().toISOString(),category:"pwa.debug-forwarder.http-blocked",event:"http-blocked",data:{consecutiveFailures:this.consecutiveFailures,pending:this.queue.length,droppedByCap:this.droppedByCap,lastOkAt:this.lastOkAt,via:"acp-fallback"},source:{platform:"pwa"}}}beaconFlush(){if(0!==this.queue.length)try{if("undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){let e=this.queue.slice(0,100),t=new Blob([JSON.stringify({records:e})],{type:"application/json"});navigator.sendBeacon(l,t)&&this.queue.splice(0,e.length)}}catch(e){}}get pending(){return this.queue.length}constructor(e=d,t="debug",r=1e4,n=100){this.fetchFn=e,this.minLevel=t,this.postTimeoutMs=r,this.flushMs=n,this.queue=[],this.timer=null,this.inFlight=!1,this.consecutiveFailures=0,this.lastOkAt=null,this.droppedByCap=0,this.fallbackBatches=0,this.wasFailing=!1}}async function d(e){return(await fetch(l,{method:"POST",headers:{"content-type":"application/json"},body:e,keepalive:!0,..."undefined"!=typeof AbortSignal&&"function"==typeof AbortSignal.timeout?{signal:AbortSignal.timeout(1e4)}:{}})).ok}function c(e,t){if("undefined"==typeof console)return;let r=new Date().toISOString();if(void 0!==t){let n="";try{let e=new WeakSet;n=JSON.stringify(t,(t,r)=>{if("bigint"==typeof r)return"".concat(r.toString(),"n");if("function"==typeof r)return"[fn ".concat(r.name||"anon","]");if(r&&"object"==typeof r){if(e.has(r))return"[circular]";e.add(r)}return r})}catch(e){n="[unserializable: ".concat(String(e),"]")}n&&n.length>800&&(n=n.slice(0,797)+"..."),console.debug("[".concat(r,"] ").concat(e," ").concat(n),t),u(r,e,n)}else console.debug("[".concat(r,"] ").concat(e)),u(r,e,void 0)}function u(e,t,r){let a,l=function(){if(void 0!==n)return n;let e=function(){try{let e="off"!==window.localStorage.getItem("elanous.pwa.debug.forward"),t=window.localStorage.getItem("elanous.pwa.debug.forwardLevel");return{forward:e,level:"info"===t||"warn"===t||"error"===t?t:"debug"}}catch(e){return{forward:!0,level:"debug"}}}();if(!e.forward)return n=null,null;let t=new i(d,e.level,1e4,1500);try{window.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&t.beaconFlush()})}catch(e){}return n=t,t}();if(!l)return;let s=t.slice(t.lastIndexOf(".")+1)||t;if(void 0!==r&&""!==r)try{a=JSON.parse(r)}catch(e){a=r}l.push({ts:e,category:t,event:s,...void 0!==a?{data:a}:{},source:{platform:"pwa"}})}},67842:(e,t,r)=>{"use strict";r.d(t,{AF:()=>n});let n={all:["nexus"],health:()=>[...n.all,"health"],snapshot:()=>[...n.all,"snapshot"],tabs:e=>e?[...n.all,"tabs",{kind:e}]:[...n.all,"tabs"],tab:e=>[...n.all,"tab",e],templates:()=>[...n.all,"templates"],template:e=>[...n.all,"template",e],config:()=>[...n.all,"config"],switches:()=>[...n.all,"switches"],switch:e=>[...n.all,"switch",e],secrets:()=>[...n.all,"secrets"],bindingChannels:()=>[...n.all,"bindings","channels"],bindings:e=>[...n.all,"bindings",e],binding:(e,t)=>[...n.all,"binding",e,t],logsTail:(e,t)=>t?[...n.all,"logs",e,{lines:t}]:[...n.all,"logs",e],workflows:()=>[...n.all,"workflows"],workflow:e=>[...n.all,"workflow",e],workflowRun:e=>[...n.all,"workflow-run",e],workflowRuns:()=>[...n.all,"workflow-runs"],pendingApprovals:()=>[...n.all,"workflow-pending-approvals"],platforms:()=>[...n.all,"platforms"],providers:()=>[...n.all,"providers"],worktrees:()=>[...n.all,"worktrees"],designCheck:()=>[...n.all,"design-check"],designPreviews:()=>[...n.all,"design-previews"],designPreview:e=>[...n.all,"design-preview",e],registryCatalog:()=>[...n.all,"registry-catalog"],resolvedView:()=>[...n.all,"resolved-view"]};n.snapshot(),n.tabs(),n.health(),n.snapshot(),n.config(),n.switches()},75814:()=>{},87398:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>tI});var n=r(41121),a=r(91269),l=r(42012),s=r(9050),o=r(91514);let i=/^[a-z0-9]+(-[a-z0-9]+)*$/;var d=r(84081),c=r(81731),u=r(30311),p=r(29565),h=r(86715),m=r(44100),x=r(29910),f=r(96823),g=r(7002),b=r(10793),y=r(67089),v=r(69109),j=r(50940),w=r(36767),k=r(73334),N=r(27810),C=r(95721),S=r(11635),A=r(75791),T=r(58505),E=r(44251);r(39019),r(75814);var M=r(42716);let _=/^\*\/(\d+) \* \* \* \*$/,O=/^0 \*\/(\d+) \* \* \*$/,I=/^(\d+) (\d+) \* \* \*$/,L=/^(\d+) (\d+) \* \* 1-5$/,P=/^(\d+) (\d+) \* \* ([0-6])$/,R=/^(\d+) (\d+) (\d+) \* \*$/,F=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function D(e){return e.toString().padStart(2,"0")}function z(e){let t=e.trim();if(!t)return{text:"(empty expression)",matched:!1};let r=_.exec(t);if(r){let e=Number(r[1]);return{text:"Every ".concat(e," minute").concat(1===e?"":"s"),matched:!0}}let n=O.exec(t);if(n){let e=Number(n[1]);return{text:"Every ".concat(e," hour").concat(1===e?"":"s"),matched:!0}}let a=L.exec(t);if(a)return{text:"Every weekday at ".concat(D(Number(a[2])),":").concat(D(Number(a[1]))),matched:!0};let l=P.exec(t);if(l){let e=F[Number(l[3])];return{text:"Every ".concat(e," at ").concat(D(Number(l[2])),":").concat(D(Number(l[1]))),matched:!0}}let s=I.exec(t);if(s)return{text:"Every day at ".concat(D(Number(s[2])),":").concat(D(Number(s[1]))),matched:!0};let o=R.exec(t);return o?{text:"Day ".concat(Number(o[3])," of every month at ").concat(D(Number(o[2])),":").concat(D(Number(o[1]))),matched:!0}:{text:"Custom: ".concat(t),matched:!1}}let q=[{id:"every-5-min",label:"Every 5 min",expression:"*/5 * * * *"},{id:"every-hour",label:"Hourly",expression:"0 */1 * * *"},{id:"daily-9am",label:"Daily 9am",expression:"0 9 * * *"},{id:"weekdays-9am",label:"Weekdays 9am",expression:"0 9 * * 1-5"},{id:"weekly-mon-9am",label:"Mon 9am",expression:"0 9 * * 1"},{id:"monthly-1st-9am",label:"1st 9am",expression:"0 9 1 * *"}];function W(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"string"==typeof e?e:t}function G(e){return"string"==typeof e.prompt?"prompt":"string"==typeof e.bash?"bash":"string"==typeof e.skill?"skill":"string"==typeof e.cft?"cft":void 0!==e.approval&&"object"==typeof e.approval&&null!==e.approval?"approval":void 0!==e.if&&"object"==typeof e.if&&null!==e.if&&"string"==typeof e.if.condition?"if":void 0!==e.switch&&"object"==typeof e.switch&&null!==e.switch&&"string"==typeof e.switch.value&&Array.isArray(e.switch.cases)?"switch":void 0!==e.iteration&&"object"==typeof e.iteration&&null!==e.iteration&&"string"==typeof e.iteration.items&&"string"==typeof e.iteration.body?"iteration":void 0!==e.classify&&"object"==typeof e.classify&&null!==e.classify&&"string"==typeof e.classify.input&&Array.isArray(e.classify.classes)?"classify":void 0!==e.extract&&"object"==typeof e.extract&&null!==e.extract&&"string"==typeof e.extract.input&&"object"==typeof e.extract.schema?"extract":void 0!==e.set&&"object"==typeof e.set&&null!==e.set&&"object"==typeof e.set.fields?"set":void 0!==e.filter&&"object"==typeof e.filter&&null!==e.filter&&"string"==typeof e.filter.items&&"string"==typeof e.filter.condition?"filter":void 0!==e.template&&"object"==typeof e.template&&null!==e.template&&"string"==typeof e.template.template?"template":void 0!==e.http&&"object"==typeof e.http&&null!==e.http&&"string"==typeof e.http.url?"http":void 0!==e.scheduleTrigger&&"object"==typeof e.scheduleTrigger&&null!==e.scheduleTrigger&&"string"==typeof e.scheduleTrigger.type?"scheduleTrigger":void 0!==e.webhookTrigger&&"object"==typeof e.webhookTrigger&&null!==e.webhookTrigger&&"string"==typeof e.webhookTrigger.path?"webhookTrigger":void 0!==e.discordTrigger&&"object"==typeof e.discordTrigger&&null!==e.discordTrigger&&"string"==typeof e.discordTrigger.kind?"discordTrigger":void 0!==e.telegramTrigger&&"object"==typeof e.telegramTrigger&&null!==e.telegramTrigger&&"string"==typeof e.telegramTrigger.kind?"telegramTrigger":void 0!==e.manualTrigger&&"object"==typeof e.manualTrigger&&null!==e.manualTrigger?"manualTrigger":void 0!==e.chatTrigger&&"object"==typeof e.chatTrigger&&null!==e.chatTrigger&&"string"==typeof e.chatTrigger.path?"chatTrigger":"unknown"}function B(e){let t=e.kind;return"string"==typeof t&&/^[a-z0-9-]+:[a-z0-9-]+$/.test(t)?t:null}function H(e,t){var r;return"unknown"===t&&null!=(r=B(e))?r:t}function $(e){var t;return e?(null!=(t=e.split("\n").find(e=>e.trim().length>0))?t:"").trim().slice(0,64):""}var K=r(45560);function U(e,t){var r;let n=new Set((null!=(r=e.nodes)?r:[]).map(e=>e.id)),a="unknown"===t?"node":t;for(let e=1;e<1e4;e+=1){let t="".concat(a,"-").concat(e);if(!n.has(t))return t}return"".concat(a,"-").concat(Date.now())}function J(e,t,r){var n,a;let l=null!=(n=null==r?void 0:r.id)?n:U(e,t),s=function(e,t){switch(e){case"prompt":return{id:t,prompt:"Describe the desired behaviour…"};case"bash":return{id:t,bash:"echo todo"};case"skill":return{id:t,skill:"omni-digest",arguments:"$ARGUMENTS"};case"cft":return{id:t,cft:"pdca",config:{goal:"TBD",phase:"plan"}};case"approval":return{id:t,approval:{message:"Continue?"}};case"if":return{id:t,if:{condition:"$ARGUMENTS == 'yes'"}};case"switch":return{id:t,switch:{value:"$ARGUMENTS",cases:["a","b"]}};case"iteration":return{id:t,iteration:{items:'["a","b","c"]',body:"echo $index $item"}};case"classify":return{id:t,classify:{input:"$ARGUMENTS",classes:["question","command","other"]}};case"extract":return{id:t,extract:{input:"$ARGUMENTS",schema:{name:"person name",date:"ISO date if present"}}};case"set":return{id:t,set:{fields:{greeting:"Hello $ARGUMENTS"}}};case"filter":return{id:t,filter:{items:'["a","b","c"]',condition:"$item != 'b'"}};case"template":return{id:t,template:{template:"Hello {{ARGUMENTS}}!"}};case"http":return{id:t,http:{method:"GET",url:"https://api.example.com/items",headers:{Accept:"application/json"}}};case"scheduleTrigger":return{id:t,scheduleTrigger:{type:"interval",interval:36e5}};case"webhookTrigger":return{id:t,webhookTrigger:{method:"POST",path:"/hooks/example"}};case"discordTrigger":return{id:t,discordTrigger:{kind:"message"}};case"telegramTrigger":return{id:t,telegramTrigger:{kind:"message"}};case"manualTrigger":return{id:t,manualTrigger:{description:"Run manually"}};case"chatTrigger":return{id:t,chatTrigger:{path:"/chat",sessionMode:"stateless",streaming:!1}};default:return{id:t,bash:"echo placeholder"}}}(t,l);return{...e,nodes:[...null!=(a=e.nodes)?a:[],s]}}function Y(e,t){var r;let n=(null!=(r=e.nodes)?r:[]).filter(e=>e.id!==t).map(e=>{let r=Array.isArray(e.depends_on)?e.depends_on.filter(e=>e!==t):void 0;if(void 0===r)return e;if(0===r.length){let{depends_on:t,...r}=e;return r}return{...e,depends_on:r}});return{...e,nodes:n}}function V(e){if(!e._meta||"object"!=typeof e._meta)return e;let t={...e._meta};if(!("layout"in t))return e;if(delete t.layout,0===Object.keys(t).length){let{_meta:t,...r}=e;return r}return{...e,_meta:t}}function X(e){var t;let r={};for(let t of("string"==typeof e.name&&(r.name=e.name),"string"==typeof e.description&&(r.description=e.description),Object.keys(e)))"name"!==t&&"description"!==t&&"nodes"!==t&&(r[t]=e[t]);return r.nodes=null!=(t=e.nodes)?t:[],(0,K.As)(r,{lineWidth:0,defaultStringType:"PLAIN",singleQuote:!1})}function Q(e){try{let t=(0,K.parse)(e);if(!t||"object"!=typeof t||!Array.isArray(t.nodes))return null;return t}catch(e){return null}}let Z={running:{dot:"#3b82f6",label:"Running"},done:{dot:"#22c55e",label:"Done"},failed:{dot:"#ef4444",label:"Failed"},skipped:{dot:"#9ca3af",label:"Skipped"},awaiting_approval:{dot:"#f59e0b",label:"Awaiting approval"}},ee={all:"\uD83D\uDCE3",modal:"\uD83D\uDDA5",terminal:"⌨",telegram:"\uD83D\uDCF2",discord:"\uD83D\uDCAC",pushcut:"\uD83D\uDD14"};async function et(e){try{let{parse:t}=await Promise.resolve().then(r.bind(r,45560)),n=t(e);if(!n||"object"!=typeof n||!Array.isArray(n.nodes))return null;return n}catch(e){return null}}let er={prompt:"#8b5cf6",bash:"#22c55e",skill:"#f59e0b",cft:"#06b6d4",approval:"#ef4444",if:"#ec4899",switch:"#d946ef",iteration:"#a855f7",classify:"#0ea5e9",extract:"#14b8a6",set:"#84cc16",filter:"#10b981",template:"#f97316",http:"#3b82f6",scheduleTrigger:"#6366f1",webhookTrigger:"#a78bfa",discordTrigger:"#5865f2",telegramTrigger:"#0088cc",manualTrigger:"#64748b",chatTrigger:"#9333ea",unknown:"#9ca3af"};function en(e){let{palette:t,yaml:r,definition:l,editable:s,onChangeYaml:o,onNodeClick:i,nodeStatuses:d,nodeIssues:c,cycleNodeIds:u,focusNodeId:p,focusNonce:h,onRun:m}=e,[x,f]=(0,a.useState)(null!=l?l:null),[g,b]=(0,a.useState)(!1),[y,v]=(0,a.useState)([]);(0,a.useEffect)(()=>{if(l){f(l),b(!1);return}let e=!1;return(async()=>{let t=await et(r);e||(f(t),b(null===t))})(),()=>{e=!0}},[r,l]);let j=(0,a.useCallback)(e=>{var t;if(!o)return;let n=null!=(t=Q(r))?t:x;if(!n)return;let a=e(n);f(a);try{let e=X(a);o(e)}catch(e){}},[o,x,r]),w=(0,a.useMemo)(()=>{if(!x)return null;try{return function(e,t){let{nodes:r,edges:n}=function(e){var t,r,n,a,l,s,o,i,d,c,u,p;let h=[],m=[],x=new Set;for(let f of null!=(t=e.nodes)?t:[]){let e,t;if(!f||"string"!=typeof f.id||0===f.id.length||x.has(f.id))continue;x.add(f.id);let g=G(f),b="";switch(g){case"prompt":b=$(f.prompt);break;case"bash":b=$(f.bash);break;case"skill":b=String(null!=(r=f.skill)?r:"").slice(0,64);break;case"cft":b=String(null!=(n=f.cft)?n:"").slice(0,64);break;case"approval":{let t=f.approval;b=$(null==t?void 0:t.message),"string"==typeof(null==t?void 0:t.delivery)&&t.delivery.length>0&&(e=t.delivery);break}case"if":{let e=null==(a=f.if)?void 0:a.condition;b="string"==typeof e?e.slice(0,64):"";break}case"switch":{let e=f.switch,t=Array.isArray(null==e?void 0:e.cases)?" → ".concat(e.cases.length," case").concat(1===e.cases.length?"":"s"):"";b="".concat((null!=(l=null==e?void 0:e.value)?l:"").slice(0,40)).concat(t);break}case"iteration":{let e=f.iteration;b="over ".concat((null!=(s=null==e?void 0:e.items)?s:"").slice(0,32));break}case"classify":{let e=f.classify,t=Array.isArray(null==e?void 0:e.classes)?e.classes.length:0;b="".concat(t," class").concat(1===t?"":"es"," from ").concat((null!=(o=null==e?void 0:e.input)?o:"").slice(0,24));break}case"extract":{let e=f.extract,t=(null==e?void 0:e.schema)?Object.keys(e.schema).length:0;b="".concat(t," field").concat(1===t?"":"s"," from ").concat((null!=(i=null==e?void 0:e.input)?i:"").slice(0,24));break}case"set":{let e=f.set,t=(null==e?void 0:e.fields)?Object.keys(e.fields).length:0;b="set ".concat(t," field").concat(1===t?"":"s");break}case"filter":{let e=f.filter;b="filter ".concat((null!=(d=null==e?void 0:e.items)?d:"").slice(0,28)," on ").concat((null!=(c=null==e?void 0:e.condition)?c:"").slice(0,24));break}case"template":{let e=f.template,t=$(null==e?void 0:e.template);b="tpl: ".concat(t.slice(0,56));break}case"http":case"scheduleTrigger":case"webhookTrigger":case"discordTrigger":case"telegramTrigger":case"manualTrigger":case"chatTrigger":b=null!=(u=function(e,t){switch(e){case"scheduleTrigger":return function(e){if(!e)return"⏰ schedule";let t=e.type;if("cron"===t){let t=W(e.cron),r=W(e.timezone),n=z(t),a=!1===e.enabled?" \xb7 disabled":"",l="number"==typeof e.max_runs?" \xb7 max ".concat(e.max_runs," runs"):"";return"⏰ ".concat(n.text).concat(r?" ".concat(r):"").concat(l).concat(a)}if("interval"===t){let t="number"==typeof e.interval?e.interval:0,r=!1===e.enabled?" \xb7 disabled":"";if(t>=36e5&&t%36e5==0){let e=t/36e5;return"⏰ Every ".concat(e," hour").concat(1===e?"":"s").concat(r)}if(t>=6e4&&t%6e4==0){let e=t/6e4;return"⏰ Every ".concat(e," minute").concat(1===e?"":"s").concat(r)}let n=Math.max(1,Math.round(t/1e3));return"⏰ Every ".concat(n,"s").concat(r)}return"⏰ schedule"}(t.scheduleTrigger);case"webhookTrigger":return function(e){if(!e)return"\uD83D\uDD17 webhook";let t=W(e.method,"POST"),r=W(e.path),n=e.auth&&"object"==typeof e.auth?e.auth:null,a=n?" \xb7 ".concat(W(n.type)):"";return"\uD83D\uDD17 ".concat(t," ").concat(r).concat(a)}(t.webhookTrigger);case"http":return function(e){if(!e)return"\uD83C\uDF10 http";let t=W(e.method,"GET"),r=W(e.url),n="number"==typeof e.timeout?" \xb7 ".concat(Math.round(e.timeout/1e3),"s"):"";return"\uD83C\uDF10 ".concat(t," ").concat(r.slice(0,48)).concat(n)}(t.http);case"discordTrigger":return function(e){if(!e)return"\uD83D\uDCAC discord";let t=W(e.kind,"message"),r=[],n=W(e.channel);return n&&r.push("#".concat(n)),W(e.user)&&r.push("@".concat(W(e.user))),W(e.pattern)&&r.push("/".concat(W(e.pattern),"/")),r.push(t),"\uD83D\uDCAC ".concat(r.join(" \xb7 "))}(t.discordTrigger);case"telegramTrigger":var r=t.telegramTrigger;if(!r)return"✈️ telegram";let n=W(r.kind,"message"),a=[];return W(r.chat)&&a.push("@".concat(W(r.chat))),"command"===n&&W(r.command)&&a.push("/".concat(W(r.command))),W(r.user)&&a.push("from:".concat(W(r.user))),W(r.pattern)&&a.push("/".concat(W(r.pattern),"/")),a.push(n),"✈️ ".concat(a.join(" \xb7 "));case"manualTrigger":var l=t.manualTrigger;let s=W(null==l?void 0:l.description);return s?"▶ ".concat(s):"▶ Manual \xb7 explicit run";case"chatTrigger":return function(e){if(!e)return"\uD83D\uDCAD Chat";let t=W(e.path,"/chat"),r="per-session"===e.sessionMode?" \xb7 per-session":"",n=!0===e.streaming?" \xb7 streaming":"";return"\uD83D\uDCAD Chat: ".concat(t).concat(r).concat(n)}(t.chatTrigger);default:return null}}(g,f))?u:"";break;default:b=""}if("unknown"===g&&B(f)){let e=f.inputs,t=e&&"object"==typeof e?Object.values(e).find(e=>"string"==typeof e&&""!==e.trim()):void 0;b=t?$(t):""}if("if"===g)t=["then","else"];else if("switch"===g){let e=null==(p=f.switch)?void 0:p.cases;Array.isArray(e)&&(t=[...e.filter(e=>"string"==typeof e&&e.length>0),"default"])}for(let r of(h.push({id:f.id,variant:g,badge:H(f,g),label:f.id,preview:b,hasWhen:"string"==typeof f.when&&""!==f.when.trim(),..."string"==typeof f.trigger_rule?{triggerRule:f.trigger_rule}:{},hasToolPolicy:Array.isArray(f.allowed_tools)||Array.isArray(f.denied_tools),...void 0!==e?{approvalDelivery:e}:{},...t?{branches:t}:{}}),Array.isArray(f.depends_on)?f.depends_on:[]))"string"==typeof r&&0!==r.length&&m.push({id:"".concat(r,"->").concat(f.id),source:r,target:f.id})}return{nodes:h,edges:m}}(e),a=function(e){var t,r,n;let a=null!=(t=e.direction)?t:"LR",l=new M.Ay.graphlib.Graph;for(let t of(l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:a,ranksep:null!=(r=e.rankSep)?r:"LR"===a?100:80,nodesep:null!=(n=e.nodeSep)?n:"LR"===a?40:60,marginx:20,marginy:20}),e.nodes))l.setNode(t.id,{width:200,height:64});for(let t of e.edges)l.setEdge(t.source,t.target);M.Ay.layout(l);let s=e.nodes.map(e=>{var t,r,n,a;let s=l.node(e.id),o=(null!=(t=null==s?void 0:s.x)?t:0)-100,i=(null!=(r=null==s?void 0:s.y)?r:0)-32;return{...e,position:{x:o,y:i},width:null!=(n=null==s?void 0:s.width)?n:200,height:null!=(a=null==s?void 0:s.height)?a:64}}),o=0,i=0;for(let e of s)o=Math.max(o,e.position.x+e.width),i=Math.max(i,e.position.y+e.height);return{nodes:s,edges:e.edges,bounds:{width:o,height:i}}}({nodes:r,edges:n}),l=function(e){let t=e._meta;if(!t||"object"!=typeof t)return{};let r=t.layout;if(!r||"object"!=typeof r)return{};let n={};for(let[e,t]of Object.entries(r))t&&"object"==typeof t&&"number"==typeof t.x&&"number"==typeof t.y&&(n[e]={x:t.x,y:t.y});return n}(e);if(0===Object.keys(l).length)return a;let s=0,o=0;return{nodes:a.nodes.map(e=>{let t=l[e.id],r=null!=t?t:e.position,n={...e,position:r};return s=Math.max(s,r.x+e.width),o=Math.max(o,r.y+e.height),n}),edges:a.edges,bounds:{width:s,height:o}}}(x)}catch(e){return null}},[x]),k=(0,a.useMemo)(()=>w?w.nodes.map(e=>{var t,r;let n=null!=(t=null==u?void 0:u.has(e.id))&&t,a=null==c?void 0:c[e.id],l=null==d?void 0:d[e.id],s=(r=null==l?void 0:l.status)?"workflow-node-status workflow-node-status-".concat(r):"workflow-node-status";return{id:e.id,type:"workflow",position:e.position,data:{raw:e,statusEntry:l,issues:a,inCycle:n},className:s,style:{background:"var(--surface, #0f1117)",color:"var(--text-primary, #e5e7eb)",border:n?"2px dashed #ef4444":"1.5px solid ".concat(er[e.variant]),borderRadius:8,padding:0,width:e.width,fontSize:11,textAlign:"left"}}}):[],[w,d,c,u]),N=(0,a.useMemo)(()=>({workflow:ec}),[]),C=(0,a.useMemo)(()=>w?w.edges.map(e=>{let t=(null==u?void 0:u.has(e.source))===!0&&u.has(e.target);return{id:e.id,source:e.source,target:e.target,animated:!1,style:t?{stroke:"#ef4444",strokeWidth:2,strokeDasharray:"6 4"}:{stroke:"var(--text-tertiary, #6b7280)",strokeWidth:1.5}}}):[],[w,u]),S=(0,a.useCallback)(e=>{s&&e.source&&e.target&&j(t=>(function(e,t,r){var n;if(t===r)return e;let a=(null!=(n=e.nodes)?n:[]).map(e=>{if(e.id!==r)return e;let n=Array.isArray(e.depends_on)?[...e.depends_on]:[];return n.includes(t)?e:(n.push(t),{...e,depends_on:n})});return{...e,nodes:a}})(t,e.source,e.target))},[s,j]),A=(0,a.useCallback)(e=>{if(!s)return;let t=e.filter(e=>"remove"===e.type);if(t.length>0)return void j(e=>t.reduce((e,t)=>Y(e,t.id),e));let r=e.filter(e=>"position"===e.type&&!1===e.dragging&&void 0!==e.position);0!==r.length&&j(e=>r.reduce((e,t)=>(function(e,t,r){var n,a;if(!(null!=(n=e.nodes)?n:[]).find(e=>e.id===t))return e;let l=e._meta&&"object"==typeof e._meta?{...e._meta}:{},s=l.layout&&"object"==typeof l.layout?{...l.layout}:{},o=new Set((null!=(a=e.nodes)?a:[]).map(e=>e.id));for(let e of Object.keys(s))o.has(e)||delete s[e];return s[t]={x:Math.round(r.x),y:Math.round(r.y)},l.layout=s,{...e,_meta:l}})(e,t.id,t.position),e))},[s,j]),E=(0,a.useCallback)(e=>{if(!s)return;let t=e.filter(e=>"remove"===e.type);0!==t.length&&j(e=>t.reduce((e,t)=>{var r;let[n,a]=t.id.split("->");if(!n||!a)return e;let l=(null!=(r=e.nodes)?r:[]).map(e=>{if(e.id!==a||!Array.isArray(e.depends_on))return e;let t=e.depends_on.filter(e=>e!==n);if(t.length===e.depends_on.length)return e;if(0===t.length){let{depends_on:t,...r}=e;return r}return{...e,depends_on:t}});return{...e,nodes:l}},e))},[s,j]),[_,O]=(0,a.useState)(!1),I=(0,a.useCallback)(e=>{j(t=>J(t,e)),O(!1)},[j]),L=(0,a.useCallback)(e=>{j(t=>e.core?J(t,e.kind):{...t,nodes:[...t.nodes,{id:U(t,"unknown"),kind:e.kind,inputs:{}}]})},[j]);var P,R=(0,a.useMemo)(()=>{if(!s)return[];let e=[];return e.push({key:"n",handler:()=>O(e=>!e)}),e.push({key:"t",shift:!0,alt:!0,handler:()=>j(e=>V(e))}),e.push({key:"Escape",handler:()=>O(!1),preventDefault:!1}),e.push({key:"d",metaOrCtrl:!0,handler:()=>{let e=y[0];e&&j(t=>(function(e,t){var r,n;let a=(null!=(r=e.nodes)?r:[]).find(e=>e.id===t);if(!a)return e;let l=U(e,G(a)),{id:s,depends_on:o,...i}=a,d={...i,id:l};return{...e,nodes:[...null!=(n=e.nodes)?n:[],d]}})(t,e))}}),e.push({key:"F2",handler:()=>{let e=y[0];e&&i&&i(e)}}),m&&e.push({key:"Enter",metaOrCtrl:!0,handler:()=>m()}),e},[s,j,o,i,m,y]),F={enabled:!0===s};let D=null==(P=null==F?void 0:F.enabled)||P;return((0,a.useEffect)(()=>{if(!D||0===R.length)return;let e=e=>{if(!function(e){if(!e||!e.tagName)return!1;let t=e.tagName.toLowerCase();return"input"===t||"textarea"===t||e.isContentEditable}(e.target)){for(let t of R)if(function(e,t){if(e.key.toLowerCase()!==t.key.toLowerCase())return!1;if(e.metaOrCtrl){if(!(t.metaKey||t.ctrlKey))return!1}else if(void 0!==e.meta&&e.meta!==t.metaKey||void 0!==e.ctrl&&e.ctrl!==t.ctrlKey)return!1;return(void 0===e.alt||e.alt===t.altKey)&&(void 0===e.shift||e.shift===t.shiftKey)}(t,e)){!1!==t.preventDefault&&e.preventDefault(),t.handler(e);return}}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[D,R]),g)?(0,n.jsx)("div",{className:"flex h-full items-center justify-center text-[11px] text-text-tertiary",children:"YAML parse failed — switch to YAML view to fix."}):x?0===k.length?(0,n.jsxs)("div",{className:"relative flex h-full items-center justify-center text-[11px] text-text-tertiary",children:[s&&(0,n.jsx)(ea,{palette:t,onAdd:L}),s?"No nodes yet — pick a variant from the palette.":"No nodes yet — switch to YAML view to add one."]}):(0,n.jsxs)("div",{className:"relative h-full w-full",children:[s&&(0,n.jsx)(ea,{palette:t,onAdd:L}),s&&(0,n.jsx)(ei,{onTidy:()=>j(e=>V(e))}),s&&_&&(0,n.jsx)(ed,{onPick:I,onClose:()=>O(!1)}),(0,n.jsxs)(T.Gc,{nodes:k,edges:C,nodeTypes:N,nodesDraggable:null!=s&&s,nodesConnectable:null!=s&&s,elementsSelectable:null!=s&&s,deleteKeyCode:s?["Backspace","Delete"]:null,onConnect:s?S:void 0,onNodesChange:s?A:void 0,onEdgesChange:s?E:void 0,onNodeClick:i?(e,t)=>i(t.id):void 0,onSelectionChange:e=>{let{nodes:t}=e;return v(t.map(e=>e.id))},proOptions:{hideAttribution:!0},connectionLineComponent:s?el:void 0,fitView:!0,children:[(0,n.jsx)(T.VS,{variant:T._5.Dots,gap:16,size:1}),(0,n.jsx)(T.H2,{showInteractive:!1}),void 0!==p&&(0,n.jsx)(es,{focusNodeId:null!=p?p:null,focusNonce:null!=h?h:0}),(0,n.jsx)(eo,{selectedIds:y})]})]}):(0,n.jsx)("div",{className:"flex h-full items-center justify-center text-[11px] text-text-tertiary",children:"Parsing…"})}function ea(e){let{palette:t,onAdd:r}=e,a=[{v:"prompt",label:"+ prompt"},{v:"bash",label:"+ bash"},{v:"skill",label:"+ skill"},{v:"cft",label:"+ cft"},{v:"approval",label:"+ approval"},{v:"if",label:"+ if"},{v:"switch",label:"+ switch"},{v:"iteration",label:"+ loop"},{v:"classify",label:"+ classify"},{v:"extract",label:"+ extract"},{v:"set",label:"+ set"},{v:"filter",label:"+ filter"},{v:"template",label:"+ template"},{v:"http",label:"+ http"},{v:"scheduleTrigger",label:"+ schedule"},{v:"webhookTrigger",label:"+ webhook"}];return(0,n.jsx)("div",{className:"absolute left-3 top-3 z-10 flex flex-col gap-1 rounded-md border border-border bg-surface-elevated p-1 shadow-md",children:(null!=t?t:a.map(e=>{let{v:t}=e;return{graph:"workflow",kind:t,core:!0,plugin:null,description:""}})).map(e=>{var t,l;return(0,n.jsxs)("button",{type:"button",onClick:()=>r(e),className:"rounded px-2 py-0.5 text-left text-[10px] text-text-tertiary transition-colors hover:bg-surface hover:text-text-primary",style:{minWidth:80},children:[null!=(l=null==(t=a.find(t=>{let{v:r}=t;return r===e.kind}))?void 0:t.label)?l:"+ ".concat(e.kind),e.plugin&&(0,n.jsx)("span",{className:"ml-1 rounded bg-accent/15 px-1 text-accent",children:e.plugin})]},e.kind)})})}function el(e){let{fromX:t,fromY:r,toX:a,toY:l}=e;return(0,n.jsxs)("g",{className:"workflow-edge-pending",children:[(0,n.jsx)("path",{d:"M ".concat(t,",").concat(r," C ").concat(t+60,",").concat(r," ").concat(a-60,",").concat(l," ").concat(a,",").concat(l),fill:"none",stroke:"var(--accent, #8b5cf6)",strokeWidth:1.8,strokeDasharray:"4 3"}),(0,n.jsx)("circle",{cx:a,cy:l,r:4,fill:"var(--accent, #8b5cf6)"})]})}function es(e){let{focusNodeId:t,focusNonce:r}=e,n=(0,T.VH)();return(0,a.useEffect)(()=>{if(!t)return;let e=setTimeout(()=>{n.fitView({nodes:[{id:t}],duration:300,padding:.3})},0);return()=>{clearTimeout(e)}},[t,r,n]),null}function eo(e){let{selectedIds:t}=e,r=(0,T.VH)(),n=t.join(",");return(0,a.useEffect)(()=>{if(t.length<=1)return;let e=setTimeout(()=>{r.fitView({nodes:t.map(e=>({id:e})),duration:300,padding:.25})},0);return()=>{clearTimeout(e)}},[n,r]),null}function ei(e){let{onTidy:t}=e;return(0,n.jsx)("button",{type:"button",onClick:t,title:"Tidy-up auto-layout (Shift+Alt+T)",className:"absolute right-3 top-3 z-10 rounded-md border border-border bg-surface-elevated px-2 py-1 text-[10px] text-text-tertiary shadow-md hover:bg-surface hover:text-text-primary",children:"✨ Tidy"})}function ed(e){let{onPick:t,onClose:r}=e,[l,s]=(0,a.useState)(""),o=[{v:"prompt",label:"prompt",help:"Run an LLM prompt with the run context."},{v:"bash",label:"bash",help:"Run a shell snippet."},{v:"skill",label:"skill",help:"Invoke a registered skill (e.g. omni-digest)."},{v:"cft",label:"cft",help:"Run a CFT (e.g. pdca, swot)."},{v:"approval",label:"approval",help:"Pause for human approval."},{v:"if",label:"if",help:"Branch on a boolean condition (then / else)."},{v:"switch",label:"switch",help:"N-way branch on an expression value."},{v:"iteration",label:"iteration",help:"Run a bash body for each element of an array."},{v:"classify",label:"classify",help:"LLM picks one class label from a list."},{v:"extract",label:"extract",help:"LLM fills a JSON schema from free text."},{v:"set",label:"set",help:"Build a record of derived values."},{v:"filter",label:"filter",help:"Keep array elements where a condition holds."},{v:"template",label:"template",help:"{{var}} substitution into a string template."},{v:"http",label:"http",help:"HTTP request (GET/POST/...). Parsed JSON output."},{v:"scheduleTrigger",label:"schedule",help:"Cron / interval trigger (daemon-side dispatch v2)."},{v:"webhookTrigger",label:"webhook",help:"HTTP entry point (daemon-side dispatch v2)."}].filter(e=>e.label.includes(l.toLowerCase())||e.help.toLowerCase().includes(l.toLowerCase()));return(0,n.jsxs)("div",{className:"absolute right-0 top-0 z-20 flex h-full w-72 flex-col border-l border-border bg-surface-elevated shadow-xl",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[(0,n.jsx)("span",{className:"text-xs font-semibold",children:"Add node"}),(0,n.jsx)("button",{type:"button",onClick:r,className:"text-[11px] text-text-tertiary hover:text-text-primary",title:"Close (Esc)",children:"✕"})]}),(0,n.jsx)("div",{className:"border-b border-border px-3 py-2",children:(0,n.jsx)("input",{type:"text",value:l,onChange:e=>s(e.target.value),placeholder:"Search variants…",autoFocus:!0,className:"w-full rounded-md border border-border bg-surface px-2 py-1 text-xs"})}),(0,n.jsxs)("ul",{className:"flex-1 overflow-y-auto px-2 py-2",children:[0===o.length&&(0,n.jsx)("li",{className:"px-2 py-1 text-[11px] text-text-tertiary",children:"No matches."}),o.map(e=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button",onClick:()=>t(e.v),className:"flex w-full flex-col items-start gap-0.5 rounded px-2 py-1.5 text-left text-[11px] hover:bg-surface",children:[(0,n.jsx)("span",{className:"inline-block rounded px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wider text-white",style:{background:er[e.v]},children:e.label}),(0,n.jsx)("span",{className:"text-text-tertiary",children:e.help})]})},e.v))]})]})}function ec(e){let{data:t}=e,{raw:r,statusEntry:a,issues:l}=t,s=(0,T.Pj)(e=>e.transform[2]<.7),o=r.branches;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(T.h7,{type:"target",position:E.yX.Left}),s?(0,n.jsx)(eu,{raw:r,statusEntry:a}):function(e,t,r){var a,l,s,o;let i=t?Z[t.status]:null,d=(s=e.approvalDelivery)&&null!=(o=ee[s])?o:null,c=t?"Last run: ".concat(null!=(a=null==i?void 0:i.label)?a:t.status)+(void 0!==t.durationMs?" \xb7 ".concat(t.durationMs,"ms"):"")+(t.error?" \xb7 ".concat(t.error):"")+(t.reason?" \xb7 ".concat(t.reason):""):void 0,u=null!=(l=null==r?void 0:r.length)?l:0,p=u>0?"".concat(u," validation issue").concat(1===u?"":"s",":\n")+r.map(e=>"\xb7 ".concat(e.message)).join("\n"):void 0;return(0,n.jsxs)("div",{style:{padding:"6px 8px"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:2},children:[(0,n.jsx)("span",{style:{display:"inline-block",padding:"0 5px",borderRadius:3,fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:.4,background:er[e.variant],color:"white"},children:e.badge}),(0,n.jsx)("span",{style:{fontWeight:500,fontSize:11},children:e.id}),i&&(0,n.jsx)("span",{"aria-label":c,title:c,style:{display:"inline-block",width:8,height:8,borderRadius:"50%",background:i.dot,flexShrink:0,boxShadow:(null==t?void 0:t.status)==="running"?"0 0 0 2px ".concat(i.dot,"33"):void 0}}),u>0&&(0,n.jsx)("span",{"aria-label":p,title:p,style:{fontSize:10,color:"#ef4444",fontWeight:700,flexShrink:0},children:"⚠"}),d&&(0,n.jsx)("span",{"aria-label":"delivery: ".concat(e.approvalDelivery),title:"Delivery: ".concat(e.approvalDelivery),style:{fontSize:10,marginLeft:"auto",flexShrink:0},children:d})]}),e.preview&&(0,n.jsx)("div",{style:{fontSize:10,opacity:.75,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.preview}),(e.hasWhen||e.triggerRule||e.hasToolPolicy)&&(0,n.jsxs)("div",{style:{display:"flex",gap:4,marginTop:3,fontSize:9,opacity:.7},children:[e.hasWhen&&(0,n.jsx)("span",{children:"when"}),e.triggerRule&&(0,n.jsx)("span",{children:e.triggerRule}),e.hasToolPolicy&&(0,n.jsx)("span",{children:"tools"})]})]})}(r,a,l),o&&o.length>0?o.map((e,t)=>{let r=(t+1)/(o.length+1)*100;return(0,n.jsx)(T.h7,{type:"source",position:E.yX.Right,id:e,style:{top:"".concat(r,"%")},children:(0,n.jsx)("span",{"aria-hidden":!0,style:{position:"absolute",right:14,top:-2,fontSize:8,color:"var(--text-tertiary, #6b7280)",pointerEvents:"none",whiteSpace:"nowrap"},children:e})},e)}):(0,n.jsx)(T.h7,{type:"source",position:E.yX.Right})]})}function eu(e){let{raw:t,statusEntry:r}=e,a=r?Z[r.status]:null;return(0,n.jsxs)("div",{style:{padding:"4px 8px",display:"flex",alignItems:"center",gap:6},children:[(0,n.jsx)("span",{style:{display:"inline-block",padding:"0 5px",borderRadius:3,fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:.4,background:er[t.variant],color:"white"},children:t.badge}),(0,n.jsx)("span",{style:{fontSize:11,fontWeight:500},children:t.id}),a&&(0,n.jsx)("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",background:a.dot,marginLeft:"auto"}})]})}E.rN;var ep=r(72754),eh=r(79167),em=r(93981),ex=r(99608),ef=r(67770);function eg(e){var t;let{result:r,onApply:a,onRefine:l,onCancel:s}=e,o=null!=(t=r.yaml)?t:"";return(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 px-4 py-6",role:"dialog","aria-modal":"true",onClick:s,children:(0,n.jsxs)("div",{className:"flex max-h-[80vh] w-full max-w-3xl flex-col gap-3 rounded-lg border border-border bg-surface-elevated p-4 shadow-xl",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("header",{className:"flex items-center justify-between",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"rounded bg-surface px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-text-tertiary",children:"Synth preview"}),r.workflowName&&(0,n.jsx)("span",{className:"font-mono text-sm font-medium text-text-primary",children:r.workflowName}),r.repaired&&(0,n.jsx)("span",{className:"rounded-full border border-warning/30 bg-warning/10 px-2 py-0.5 text-[10px] text-warning",children:"self-repaired"})]}),(0,n.jsx)("button",{type:"button",onClick:s,className:"rounded p-1 text-text-tertiary hover:bg-surface hover:text-text-primary","aria-label":"Cancel",children:(0,n.jsx)(ep.A,{className:"h-4 w-4"})})]}),r.triggerSummary&&(0,n.jsxs)("div",{className:"rounded-md border border-accent/30 bg-accent/10 px-3 py-2 text-xs text-accent",children:[(0,n.jsx)("span",{className:"font-medium",children:"Trigger: "}),r.triggerSummary]}),!r.ok&&r.error&&(0,n.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-error/40 bg-error/10 px-3 py-2 text-xs text-error",children:[(0,n.jsx)(em.A,{className:"mt-0.5 h-4 w-4 shrink-0"}),(0,n.jsx)("span",{children:r.error})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto rounded-md border border-border bg-surface",children:(0,n.jsx)("pre",{className:"m-0 whitespace-pre p-3 font-mono text-[11px] leading-relaxed text-text-primary",children:o||"(no yaml — synth failed)"})}),(0,n.jsxs)("footer",{className:"flex items-center justify-between gap-2",children:[(0,n.jsx)("span",{className:"text-[11px] text-text-tertiary",children:"Apply writes the YAML into the editor draft. Save (panel footer) commits to disk."}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("button",{type:"button",onClick:l,className:"flex items-center gap-1 rounded-md border border-border px-3 py-1 text-[11px] text-text-secondary hover:bg-surface",children:[(0,n.jsx)(ex.A,{className:"h-3 w-3"}),"Refine"]}),(0,n.jsx)("button",{type:"button",onClick:s,className:"rounded-md border border-border px-3 py-1 text-[11px] text-text-secondary hover:bg-surface",children:"Cancel"}),(0,n.jsxs)("button",{type:"button",onClick:()=>{o&&a(o,r.workflowName)},disabled:!r.ok||!o,className:"flex items-center gap-1 rounded-md bg-accent px-3 py-1 text-[11px] font-medium text-primary-foreground hover:bg-accent-hover disabled:opacity-50",children:[(0,n.jsx)(ef.A,{className:"h-3 w-3"}),"Apply"]})]})]})]})})}function eb(e){let{currentYaml:t,skills:r,onGenerated:l,onClose:s}=e,[o,i]=(0,a.useState)(""),[d,c]=(0,a.useState)(""),[u,p]=(0,a.useState)(null),h=(0,A.up)(),m=(0,A.hM)(),x=!!(t&&t.trim().length>0),f=h.error instanceof Error?h.error.message:m.error instanceof Error?m.error.message:h.isError||m.isError?"generation failed":null;return(0,n.jsxs)("div",{className:"border-b border-border bg-surface-elevated",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(b.A,{className:"h-4 w-4 text-accent"}),(0,n.jsx)("span",{className:"text-xs font-medium",children:x?"Refine workflow with AI":"Generate workflow from text"})]}),(0,n.jsx)("button",{type:"button",onClick:s,className:"rounded p-1 text-text-tertiary hover:bg-surface hover:text-text-primary","aria-label":"Close NL prompt",children:(0,n.jsx)(ep.A,{className:"h-3 w-3"})})]}),(0,n.jsxs)("div",{className:"px-3 pb-3",children:[(0,n.jsx)("textarea",{value:o,onChange:e=>i(e.target.value),placeholder:x?'How should this workflow change? e.g. "add a slack notification at the end"':'Describe the workflow. e.g. "Research the latest Apple Silicon benchmarks, summarize, and push to my iPhone."',rows:3,spellCheck:!1,className:"w-full resize-none rounded-md border border-border bg-surface px-2 py-1.5 text-xs leading-snug focus:border-accent focus:outline-none"}),(0,n.jsxs)("div",{className:"mt-2 flex items-center justify-between gap-2",children:[(0,n.jsxs)("select",{value:d,onChange:e=>c(e.target.value),className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-text-secondary focus:border-accent focus:outline-none",title:"LLM provider (default = your user-config)",children:[(0,n.jsx)("option",{value:"",children:"Default provider"}),(0,n.jsx)("option",{value:"anthropic",children:"anthropic"}),(0,n.jsx)("option",{value:"openai",children:"openai"}),(0,n.jsx)("option",{value:"grok",children:"grok"}),(0,n.jsx)("option",{value:"gemini",children:"gemini"}),(0,n.jsx)("option",{value:"local",children:"local"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("button",{type:"button",onClick:()=>{if(!o.trim()||m.isPending)return;let e={intent:o.trim(),preview:!0};x&&t&&(e.context="current yaml:\n".concat(t)),m.mutate(e,{onSuccess:e=>p(e)})},disabled:!o.trim()||m.isPending||h.isPending,className:"flex items-center gap-1 rounded-md border border-accent/40 bg-accent/10 px-3 py-1 text-[11px] font-medium text-accent hover:bg-accent/20 disabled:opacity-50",title:"Trigger-aware synth via R3 native skill (cron \xb7 webhook \xb7 discord \xb7 telegram \xb7 manual \xb7 chat all supported)",children:m.isPending?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(j.A,{className:"h-3 w-3 animate-spin"}),"Synthing…"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eh.A,{className:"h-3 w-3"}),"Synth (trigger-aware)"]})}),(0,n.jsx)("button",{type:"button",onClick:()=>{if(!o.trim()||h.isPending)return;let e={prompt:o.trim()};d&&(e.provider=d),r&&r.length>0&&(e.skills=r),x&&t&&(e.currentYaml=t),h.mutate(e,{onSuccess:e=>{l(e)}})},disabled:!o.trim()||h.isPending||m.isPending,className:"flex items-center gap-1 rounded-md bg-accent px-3 py-1 text-[11px] font-medium text-primary-foreground hover:bg-accent-hover disabled:opacity-50",children:h.isPending?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(j.A,{className:"h-3 w-3 animate-spin"}),"Generating…"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(b.A,{className:"h-3 w-3"}),x?"Refine":"Generate"]})})]})]}),f&&(0,n.jsxs)("div",{className:"mt-2 flex items-start gap-1.5 rounded-md border border-error/40 bg-error/10 px-2 py-1 text-[11px] text-error",children:[(0,n.jsx)(em.A,{className:"mt-0.5 h-3 w-3 shrink-0"}),(0,n.jsx)("span",{children:f})]}),u&&(0,n.jsx)(eg,{result:u,onApply:(e,t)=>{p(null),l({yaml:e,warnings:[],raw:e,definition:void 0})},onRefine:()=>p(null),onCancel:()=>p(null)}),h.data&&h.data.warnings.length>0&&(0,n.jsx)("ul",{className:"mt-2 max-h-24 overflow-y-auto rounded-md border border-warning/40 bg-warning/10 px-2 py-1 text-[11px] text-warning",children:h.data.warnings.slice(0,5).map((e,t)=>(0,n.jsxs)("li",{className:"flex items-start gap-1",children:[(0,n.jsx)(em.A,{className:"mt-0.5 h-3 w-3 shrink-0"}),(0,n.jsx)("span",{children:e})]},t))})]})]})}let ey={valid:"bg-success/10 text-success border-success/30",warning:"bg-warning/10 text-warning border-warning/30",error:"bg-error/10 text-error border-error/30"};function ev(e){let{variantLabel:t,validationStatus:r=null,validationMessage:a,children:l}=e;return(0,n.jsxs)("div",{className:"rounded-md border border-border bg-surface-elevated",children:[(0,n.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[(0,n.jsx)("span",{className:"rounded bg-surface px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-text-tertiary",children:t}),r&&(0,n.jsx)("span",{className:"rounded-full border px-2 py-0.5 text-[10px] ".concat(ey[r]),role:"status",children:null!=a?a:r})]}),(0,n.jsx)("div",{className:"grid grid-cols-1 gap-2 px-3 py-3 md:grid-cols-2",children:l})]})}function ej(e){let{label:t,full:r,hint:a,children:l}=e;return(0,n.jsxs)("label",{className:"flex flex-col gap-1 ".concat(r?"md:col-span-2":""),children:[(0,n.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-text-tertiary",children:t}),l,a&&(0,n.jsx)("span",{className:"text-[10px] text-text-tertiary",children:a})]})}function ew(e){let t=null==e?void 0:e.scheduleTrigger;return t&&"object"==typeof t?{type:"cron"===t.type?"cron":"interval",cron:"string"==typeof t.cron?t.cron:void 0,interval:"number"==typeof t.interval?t.interval:void 0,timezone:"string"==typeof t.timezone?t.timezone:void 0,jitter_seconds:"number"==typeof t.jitter_seconds?t.jitter_seconds:void 0,max_runs:"number"==typeof t.max_runs?t.max_runs:void 0,enabled:"boolean"==typeof t.enabled?t.enabled:void 0}:{type:"interval",interval:36e5}}function ek(e){var t,r,l,s,o,i;let{definition:d,nodeId:c,onChange:u}=e,p=(null!=(t=d.nodes)?t:[]).find(e=>e.id===c),h=ew(p),[m,x]=(0,a.useState)(h.type),[f,g]=(0,a.useState)(null!=(r=h.cron)?r:"0 9 * * *"),[b,y]=(0,a.useState)(String(null!=(l=h.interval)?l:36e5)),[v,j]=(0,a.useState)(null!=(s=h.timezone)?s:"Asia/Seoul"),[w,k]=(0,a.useState)(String(null!=(o=h.jitter_seconds)?o:"")),[N,C]=(0,a.useState)(String(null!=(i=h.max_runs)?i:"")),[S,A]=(0,a.useState)(!1!==h.enabled);(0,a.useEffect)(()=>{let e=ew(p);x(e.type),e.cron&&g(e.cron),"number"==typeof e.interval&&y(String(e.interval)),e.timezone&&j(e.timezone),k("number"==typeof e.jitter_seconds?String(e.jitter_seconds):""),C("number"==typeof e.max_runs?String(e.max_runs):""),A(!1!==e.enabled)},[c,p]);let T=(0,a.useCallback)(()=>{let e=Number(b),t=""===w?void 0:Number(w),r=""===N?void 0:Number(N);return{type:m,cron:"cron"===m?f.trim():void 0,interval:"interval"===m&&Number.isFinite(e)?e:void 0,timezone:v.trim()||void 0,jitter_seconds:Number.isFinite(t)?t:void 0,max_runs:Number.isFinite(r)?r:void 0,enabled:S}},[m,f,b,v,w,N,S]),E=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(p)return E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{u(function(e,t,r){var n;let a={type:r.type};"cron"===r.type&&r.cron&&(a.cron=r.cron),"interval"===r.type&&"number"==typeof r.interval&&(a.interval=r.interval),r.timezone&&(a.timezone=r.timezone),"number"==typeof r.jitter_seconds&&(a.jitter_seconds=r.jitter_seconds),"number"==typeof r.max_runs&&(a.max_runs=r.max_runs),"boolean"==typeof r.enabled&&(a.enabled=r.enabled);let l=(null!=(n=e.nodes)?n:[]).map(e=>e.id===t?{...e,scheduleTrigger:a}:e);return{...e,nodes:l}}(d,c,T()))},500),()=>{E.current&&clearTimeout(E.current)}},[p,c,d,T,u]);let M="cron"===m?z(f):null,_=Number(b)/1e3,O=S&&("cron"!==m||(null==M?void 0:M.matched))?"valid":"warning",I=S?"cron"===m?(null==M?void 0:M.matched)?"cron ok":"custom cron":Number.isFinite(_)&&_>0?"every ".concat(_,"s"):"interval invalid":"disabled";return(0,n.jsxs)(ev,{variantLabel:"Schedule",validationStatus:O,validationMessage:I,children:[(0,n.jsx)(ej,{label:"type",children:(0,n.jsxs)("select",{value:m,onChange:e=>x(e.target.value),className:"w-full rounded-md border border-border bg-surface px-2 py-1 text-xs",children:[(0,n.jsx)("option",{value:"cron",children:"cron"}),(0,n.jsx)("option",{value:"interval",children:"interval"})]})}),(0,n.jsx)(ej,{label:"enabled",children:(0,n.jsxs)("label",{className:"flex items-center gap-2 text-xs",children:[(0,n.jsx)("input",{type:"checkbox",checked:S,onChange:e=>A(e.target.checked)}),(0,n.jsx)("span",{className:"text-text-tertiary",children:S?"on":"off"})]})}),"cron"===m&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ej,{label:"presets",full:!0,children:(0,n.jsx)("div",{className:"flex flex-wrap gap-1",children:q.map(e=>(0,n.jsx)("button",{type:"button",onClick:()=>g(e.expression),"data-preset":e.id,className:"rounded-md border border-border px-2 py-0.5 font-mono text-[10px] text-text-tertiary hover:bg-surface",children:e.label},e.id))})}),(0,n.jsx)(ej,{label:"cron expression",full:!0,hint:null==M?void 0:M.text,children:(0,n.jsx)("input",{value:f,onChange:e=>g(e.target.value),spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})})]}),"interval"===m&&(0,n.jsx)(ej,{label:"interval (ms)",hint:"= ".concat(_||"?","s"),children:(0,n.jsx)("input",{type:"number",min:1e3,value:b,onChange:e=>y(e.target.value),className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),(0,n.jsx)(ej,{label:"timezone (IANA)",hint:"e.g. Asia/Seoul \xb7 UTC \xb7 America/Los_Angeles",children:(0,n.jsx)("input",{value:v,onChange:e=>j(e.target.value),spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),(0,n.jsx)(ej,{label:"jitter (seconds \xb7 optional)",children:(0,n.jsx)("input",{type:"number",min:0,value:w,onChange:e=>k(e.target.value),placeholder:"e.g. 30",className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),(0,n.jsx)(ej,{label:"max runs (optional)",children:(0,n.jsx)("input",{type:"number",min:1,step:1,value:N,onChange:e=>C(e.target.value),placeholder:"unlimited",className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})})]})}let eN=["GET","POST","PUT","PATCH","DELETE"];function eC(e){let t=null==e?void 0:e.webhookTrigger;if(!t||"object"!=typeof t)return{method:"POST",path:"/hooks/example",auth:"none"};let r=eN.includes(t.method)?t.method:"POST",n="string"==typeof t.path?t.path:"/hooks/example",a=t.auth&&"object"==typeof t.auth?t.auth:null;return a&&"bearer"===a.type?{method:r,path:n,auth:"bearer",token:"string"==typeof a.token?a.token:""}:a&&"basic"===a.type?{method:r,path:n,auth:"basic",username:"string"==typeof a.username?a.username:"",password:"string"==typeof a.password?a.password:""}:{method:r,path:n,auth:"none"}}function eS(e){var t,r,l,s;let{definition:o,nodeId:i,onChange:d}=e,c=(null!=(t=o.nodes)?t:[]).find(e=>e.id===i),u=eC(c),[p,h]=(0,a.useState)(u.method),[m,x]=(0,a.useState)(u.path),[f,g]=(0,a.useState)(u.auth),[b,y]=(0,a.useState)(null!=(r=u.token)?r:""),[v,j]=(0,a.useState)(null!=(l=u.username)?l:""),[w,k]=(0,a.useState)(null!=(s=u.password)?s:"");(0,a.useEffect)(()=>{var e,t,r;let n=eC(c);h(n.method),x(n.path),g(n.auth),y(null!=(e=n.token)?e:""),j(null!=(t=n.username)?t:""),k(null!=(r=n.password)?r:"")},[i,c]);let N=(0,a.useCallback)(()=>({method:p,path:m,auth:f,token:b,username:v,password:w}),[p,m,f,b,v,w]),C=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(c)return C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{d(function(e,t,r){var n,a,l;let s={method:r.method,path:r.path};"bearer"===r.auth&&r.token?s.auth={type:"bearer",token:r.token}:"basic"===r.auth&&(r.username||r.password)&&(s.auth={type:"basic",username:null!=(n=r.username)?n:"",password:null!=(a=r.password)?a:""});let o=(null!=(l=e.nodes)?l:[]).map(e=>e.id===t?{...e,webhookTrigger:s}:e);return{...e,nodes:o}}(o,i,N()))},500),()=>{C.current&&clearTimeout(C.current)}},[c,i,o,N,d]);let S=m.trim()?m.startsWith("/")?/\s/.test(m)?{ok:!1,message:"no whitespace in path"}:{ok:!0,message:"path ok"}:{ok:!1,message:"path must start with '/'"}:{ok:!1,message:"path required"},A=S.ok?"valid":"error",T="".concat(p," ").concat(m);return(0,n.jsxs)(ev,{variantLabel:"Webhook",validationStatus:A,validationMessage:S.message,children:[(0,n.jsx)(ej,{label:"method",children:(0,n.jsx)("select",{value:p,onChange:e=>h(e.target.value),className:"w-full rounded-md border border-border bg-surface px-2 py-1 text-xs",children:eN.map(e=>(0,n.jsx)("option",{value:e,children:e},e))})}),(0,n.jsx)(ej,{label:"path",hint:"URL: ".concat(T),children:(0,n.jsx)("input",{value:m,onChange:e=>x(e.target.value),placeholder:"/hooks/deploy",spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),(0,n.jsx)(ej,{label:"auth",full:!0,children:(0,n.jsx)("div",{className:"flex gap-2 text-xs",children:["none","bearer","basic"].map(e=>(0,n.jsxs)("label",{className:"flex items-center gap-1",children:[(0,n.jsx)("input",{type:"radio",name:"webhook-auth",checked:f===e,onChange:()=>g(e)}),(0,n.jsx)("span",{className:"text-text-tertiary",children:e})]},e))})}),"bearer"===f&&(0,n.jsx)(ej,{label:"token",full:!0,children:(0,n.jsx)("input",{type:"password",value:b,onChange:e=>y(e.target.value),placeholder:"bearer token",spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),"basic"===f&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ej,{label:"username",children:(0,n.jsx)("input",{value:v,onChange:e=>j(e.target.value),spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),(0,n.jsx)(ej,{label:"password",children:(0,n.jsx)("input",{type:"password",value:w,onChange:e=>k(e.target.value),spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})})]})]})}let eA=["GET","POST","PUT","PATCH","DELETE","HEAD"];function eT(e){let t=null==e?void 0:e.http;if(!t||"object"!=typeof t)return{method:"GET",url:"https://api.example.com/items",headers:[],body:"",auth:"none",timeoutMs:3e4};let r=eA.includes(t.method)?t.method:"GET",n="string"==typeof t.url?t.url:"",a=Object.entries(t.headers&&"object"==typeof t.headers?t.headers:{}).filter(e=>{let[,t]=e;return"string"==typeof t}).map(e=>{let[t,r]=e;return{key:t,value:r}}),l="string"==typeof t.body?t.body:"",s="number"==typeof t.timeout?t.timeout:3e4,o=t.auth&&"object"==typeof t.auth?t.auth:null;return o&&"bearer"===o.type?{method:r,url:n,headers:a,body:l,auth:"bearer",token:"string"==typeof o.token?o.token:"",timeoutMs:s}:o&&"basic"===o.type?{method:r,url:n,headers:a,body:l,auth:"basic",username:"string"==typeof o.username?o.username:"",password:"string"==typeof o.password?o.password:"",timeoutMs:s}:{method:r,url:n,headers:a,body:l,auth:"none",timeoutMs:s}}function eE(e){var t,r,l,s;let{definition:o,nodeId:i,onChange:d}=e,c=(null!=(t=o.nodes)?t:[]).find(e=>e.id===i),u=eT(c),[p,h]=(0,a.useState)(u.method),[m,x]=(0,a.useState)(u.url),[f,g]=(0,a.useState)(u.headers),[b,y]=(0,a.useState)(u.body),[v,j]=(0,a.useState)(u.auth),[w,k]=(0,a.useState)(null!=(r=u.token)?r:""),[N,C]=(0,a.useState)(null!=(l=u.username)?l:""),[S,A]=(0,a.useState)(null!=(s=u.password)?s:""),[T,E]=(0,a.useState)(u.timeoutMs);(0,a.useEffect)(()=>{var e,t,r;let n=eT(c);h(n.method),x(n.url),g(n.headers),y(n.body),j(n.auth),k(null!=(e=n.token)?e:""),C(null!=(t=n.username)?t:""),A(null!=(r=n.password)?r:""),E(n.timeoutMs)},[i,c]);let M=(0,a.useCallback)(()=>({method:p,url:m,headers:f,body:b,auth:v,token:w,username:N,password:S,timeoutMs:T}),[p,m,f,b,v,w,N,S,T]),_=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(c)return _.current&&clearTimeout(_.current),_.current=setTimeout(()=>{d(function(e,t,r){var n,a,l;let s={method:r.method,url:r.url};if(r.headers.length>0){let e={};for(let t of r.headers)t.key.trim()&&(e[t.key.trim()]=t.value);Object.keys(e).length>0&&(s.headers=e)}r.body.trim()&&(s.body=r.body),"bearer"===r.auth&&r.token?s.auth={type:"bearer",token:r.token}:"basic"===r.auth&&(r.username||r.password)&&(s.auth={type:"basic",username:null!=(n=r.username)?n:"",password:null!=(a=r.password)?a:""}),r.timeoutMs&&3e4!==r.timeoutMs&&(s.timeout=r.timeoutMs);let o=(null!=(l=e.nodes)?l:[]).map(e=>e.id===t?{...e,http:s}:e);return{...e,nodes:o}}(o,i,M()))},500),()=>{_.current&&clearTimeout(_.current)}},[c,i,o,M,d]);let O=function(e){if(!e.trim())return{ok:!1,message:"url required"};try{return new URL(e),{ok:!0,message:"url ok"}}catch(e){return{ok:!1,message:"invalid URL"}}}(m),I=O.ok?"valid":"error",L=(e,t,r)=>{g(n=>n.map((n,a)=>a===e?{key:t,value:r}:n))};return(0,n.jsxs)(ev,{variantLabel:"HTTP",validationStatus:I,validationMessage:O.message,children:[(0,n.jsx)(ej,{label:"method",children:(0,n.jsx)("select",{value:p,onChange:e=>h(e.target.value),className:"w-full rounded-md border border-border bg-surface px-2 py-1 text-xs",children:eA.map(e=>(0,n.jsx)("option",{value:e,children:e},e))})}),(0,n.jsx)(ej,{label:"timeout (ms)",hint:"= ".concat(Math.round(T/1e3),"s"),children:(0,n.jsx)("input",{type:"number",min:1e3,max:12e4,step:1e3,value:T,onChange:e=>E(Number(e.target.value)),className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),(0,n.jsx)(ej,{label:"url",full:!0,hint:"supports $ARGUMENTS variable",children:(0,n.jsx)("input",{value:m,onChange:e=>x(e.target.value),placeholder:"https://api.example.com/items",spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),(0,n.jsx)(ej,{label:"headers",full:!0,children:(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[f.map((e,t)=>(0,n.jsxs)("div",{className:"flex gap-1",children:[(0,n.jsx)("input",{value:e.key,onChange:r=>L(t,r.target.value,e.value),placeholder:"Accept",spellCheck:!1,className:"flex-1 rounded-md border border-border bg-surface px-2 py-0.5 font-mono text-[11px]"}),(0,n.jsx)("input",{value:e.value,onChange:r=>L(t,e.key,r.target.value),placeholder:"application/json",spellCheck:!1,className:"flex-1 rounded-md border border-border bg-surface px-2 py-0.5 font-mono text-[11px]"}),(0,n.jsx)("button",{type:"button",onClick:()=>g(e=>e.filter((e,r)=>r!==t)),className:"rounded px-1.5 text-[11px] text-text-tertiary hover:bg-error/10 hover:text-error","aria-label":"Remove header",children:"\xd7"})]},t)),(0,n.jsx)("button",{type:"button",onClick:()=>g(e=>[...e,{key:"",value:""}]),className:"self-start rounded-md border border-border px-2 py-0.5 text-[10px] text-text-tertiary hover:bg-surface",children:"+ header"})]})}),(0,n.jsx)(ej,{label:"body (string)",full:!0,hint:"GET"===p||"HEAD"===p?"usually empty for GET/HEAD":"JSON / raw text",children:(0,n.jsx)("textarea",{value:b,onChange:e=>y(e.target.value),rows:3,spellCheck:!1,className:"w-full resize-none rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),(0,n.jsx)(ej,{label:"auth",full:!0,children:(0,n.jsx)("div",{className:"flex gap-2 text-xs",children:["none","bearer","basic"].map(e=>(0,n.jsxs)("label",{className:"flex items-center gap-1",children:[(0,n.jsx)("input",{type:"radio",name:"http-auth",checked:v===e,onChange:()=>j(e)}),(0,n.jsx)("span",{className:"text-text-tertiary",children:e})]},e))})}),"bearer"===v&&(0,n.jsx)(ej,{label:"token",full:!0,children:(0,n.jsx)("input",{type:"password",value:w,onChange:e=>k(e.target.value),spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),"basic"===v&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ej,{label:"username",children:(0,n.jsx)("input",{value:N,onChange:e=>C(e.target.value),spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),(0,n.jsx)(ej,{label:"password",children:(0,n.jsx)("input",{type:"password",value:S,onChange:e=>A(e.target.value),spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})})]})]})}let eM=["message","mention","reaction"];function e_(e){let t=null==e?void 0:e.discordTrigger;return t&&"object"==typeof t?{kind:eM.includes(t.kind)?t.kind:"message",channel:"string"==typeof t.channel?t.channel:void 0,user:"string"==typeof t.user?t.user:void 0,pattern:"string"==typeof t.pattern?t.pattern:void 0}:{kind:"message"}}function eO(e){if(!e)return{ok:!0,message:"no filter"};try{return new RegExp(e),{ok:!0,message:"pattern ok"}}catch(e){return{ok:!1,message:"invalid regex"}}}function eI(e){var t,r,l,s;let{definition:o,nodeId:i,onChange:d}=e,c=(null!=(t=o.nodes)?t:[]).find(e=>e.id===i),u=e_(c),[p,h]=(0,a.useState)(u.kind),[m,x]=(0,a.useState)(null!=(r=u.channel)?r:""),[f,g]=(0,a.useState)(null!=(l=u.user)?l:""),[b,y]=(0,a.useState)(null!=(s=u.pattern)?s:"");(0,a.useEffect)(()=>{var e,t,r;let n=e_(c);h(n.kind),x(null!=(e=n.channel)?e:""),g(null!=(t=n.user)?t:""),y(null!=(r=n.pattern)?r:"")},[i,c]);let v=(0,a.useCallback)(()=>({kind:p,channel:m,user:f,pattern:b}),[p,m,f,b]),j=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(c)return j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{d(function(e,t,r){var n,a,l,s;let o={kind:r.kind};(null==(n=r.channel)?void 0:n.trim())&&(o.channel=r.channel.trim()),(null==(a=r.user)?void 0:a.trim())&&(o.user=r.user.trim()),(null==(l=r.pattern)?void 0:l.trim())&&(o.pattern=r.pattern.trim());let i=(null!=(s=e.nodes)?s:[]).map(e=>e.id===t?{...e,discordTrigger:o}:e);return{...e,nodes:i}}(o,i,v()))},500),()=>{j.current&&clearTimeout(j.current)}},[c,i,o,v,d]);let w=eO(b),k=[m&&"#".concat(m),f&&"@".concat(f),b&&"/".concat(b,"/")].filter(Boolean).join(" \xb7 "),N=w.ok?"valid":"error",C=w.ok?k||"no filters":w.message;return(0,n.jsxs)(ev,{variantLabel:"Discord",validationStatus:N,validationMessage:C,children:[(0,n.jsx)(ej,{label:"kind",children:(0,n.jsx)("select",{value:p,onChange:e=>h(e.target.value),className:"w-full rounded-md border border-border bg-surface px-2 py-1 text-xs",children:eM.map(e=>(0,n.jsx)("option",{value:e,children:e},e))})}),(0,n.jsx)(ej,{label:"channel (name or id)",hint:"e.g. ops \xb7 1234567890",children:(0,n.jsx)("input",{value:m,onChange:e=>x(e.target.value),placeholder:"ops",spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),(0,n.jsx)(ej,{label:"user (regex \xb7 optional)",hint:"match by username — e.g. .* \xb7 admin",children:(0,n.jsx)("input",{value:f,onChange:e=>g(e.target.value),placeholder:".*",spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),(0,n.jsx)(ej,{label:"pattern (regex \xb7 optional)",full:!0,hint:"match message body — e.g. ^배포",children:(0,n.jsx)("input",{value:b,onChange:e=>y(e.target.value),placeholder:"^deploy",spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})})]})}let eL=["message","command","callback_query"];function eP(e){let t=null==e?void 0:e.telegramTrigger;return t&&"object"==typeof t?{kind:eL.includes(t.kind)?t.kind:"message",chat:"string"==typeof t.chat?t.chat:void 0,user:"string"==typeof t.user?t.user:void 0,command:"string"==typeof t.command?t.command:void 0,pattern:"string"==typeof t.pattern?t.pattern:void 0}:{kind:"message"}}function eR(e){var t,r,l,s,o;let{definition:i,nodeId:d,onChange:c}=e,u=(null!=(t=i.nodes)?t:[]).find(e=>e.id===d),p=eP(u),[h,m]=(0,a.useState)(p.kind),[x,f]=(0,a.useState)(null!=(r=p.chat)?r:""),[g,b]=(0,a.useState)(null!=(l=p.user)?l:""),[y,v]=(0,a.useState)(null!=(s=p.command)?s:""),[j,w]=(0,a.useState)(null!=(o=p.pattern)?o:"");(0,a.useEffect)(()=>{var e,t,r,n;let a=eP(u);m(a.kind),f(null!=(e=a.chat)?e:""),b(null!=(t=a.user)?t:""),v(null!=(r=a.command)?r:""),w(null!=(n=a.pattern)?n:"")},[d,u]);let k=(0,a.useCallback)(()=>({kind:h,chat:x,user:g,command:y,pattern:j}),[h,x,g,y,j]),N=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(u)return N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{c(function(e,t,r){var n,a,l,s,o;let i={kind:r.kind};(null==(n=r.chat)?void 0:n.trim())&&(i.chat=r.chat.trim()),(null==(a=r.user)?void 0:a.trim())&&(i.user=r.user.trim()),"command"===r.kind&&(null==(l=r.command)?void 0:l.trim())&&(i.command=r.command.trim()),(null==(s=r.pattern)?void 0:s.trim())&&(i.pattern=r.pattern.trim());let d=(null!=(o=e.nodes)?o:[]).map(e=>e.id===t?{...e,telegramTrigger:i}:e);return{...e,nodes:d}}(i,d,k()))},500),()=>{N.current&&clearTimeout(N.current)}},[u,d,i,k,c]);let C=eO(j),S=[x&&"@".concat(x),g&&"from:".concat(g),"command"===h&&y&&"/".concat(y),j&&"/".concat(j,"/")].filter(Boolean).join(" \xb7 "),A=C.ok?"valid":"error",T=C.ok?S||"no filters":C.message;return(0,n.jsxs)(ev,{variantLabel:"Telegram",validationStatus:A,validationMessage:T,children:[(0,n.jsx)(ej,{label:"kind",children:(0,n.jsx)("select",{value:h,onChange:e=>m(e.target.value),className:"w-full rounded-md border border-border bg-surface px-2 py-1 text-xs",children:eL.map(e=>(0,n.jsx)("option",{value:e,children:e},e))})}),(0,n.jsx)(ej,{label:"chat (id or @group)",hint:"e.g. @my_group \xb7 -1001234567890",children:(0,n.jsx)("input",{value:x,onChange:e=>f(e.target.value),placeholder:"@my_group",spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),"command"===h&&(0,n.jsx)(ej,{label:"command",hint:"match telegram /command (no slash)",full:!0,children:(0,n.jsx)("input",{value:y,onChange:e=>v(e.target.value),placeholder:"summary",spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),(0,n.jsx)(ej,{label:"user (regex \xb7 optional)",hint:"match by username or id",children:(0,n.jsx)("input",{value:g,onChange:e=>b(e.target.value),placeholder:".*",spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),(0,n.jsx)(ej,{label:"pattern (regex \xb7 optional)",full:!0,hint:"match message body — e.g. ^배포",children:(0,n.jsx)("input",{value:j,onChange:e=>w(e.target.value),placeholder:"^summarize",spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})})]})}function eF(e){let t=null==e?void 0:e.manualTrigger;return t&&"object"==typeof t?{description:"string"==typeof t.description?t.description:void 0}:{}}function eD(e){var t,r;let{definition:l,nodeId:s,onChange:o}=e,i=(null!=(t=l.nodes)?t:[]).find(e=>e.id===s),d=eF(i),[c,u]=(0,a.useState)(null!=(r=d.description)?r:"");(0,a.useEffect)(()=>{var e;u(null!=(e=eF(i).description)?e:"")},[s,i]);let p=(0,a.useCallback)(()=>({description:c}),[c]),h=(0,a.useRef)(null);return(0,a.useEffect)(()=>{if(i)return h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{o(function(e,t,r){var n,a;let l={};(null==(n=r.description)?void 0:n.trim())&&(l.description=r.description.trim());let s=(null!=(a=e.nodes)?a:[]).map(e=>e.id===t?{...e,manualTrigger:l}:e);return{...e,nodes:s}}(l,s,p()))},500),()=>{h.current&&clearTimeout(h.current)}},[i,s,l,p,o]),(0,n.jsxs)(ev,{variantLabel:"Manual",validationStatus:"valid",validationMessage:"explicit run only",children:[(0,n.jsx)(ej,{label:"description (optional)",full:!0,hint:"rendered on the node card \xb7 helps remind future-you why this workflow runs manually",children:(0,n.jsx)("input",{value:c,onChange:e=>u(e.target.value),placeholder:"e.g. Build then deploy on demand",spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 text-xs"})}),(0,n.jsx)(ej,{label:"behaviour",full:!0,children:(0,n.jsxs)("p",{className:"rounded-md border border-border bg-surface px-2 py-1.5 text-[11px] leading-snug text-text-tertiary",children:["The daemon never auto-subscribes to a Manual trigger. Run it via",(0,n.jsx)("code",{className:"mx-1 rounded bg-surface-elevated px-1 font-mono",children:"elanous wf run <name>"}),"or the PWA ",(0,n.jsx)("span",{className:"font-semibold",children:"▶ Run now"})," button (Group D dry-run)."]})})]})}function ez(e){let t=null==e?void 0:e.chatTrigger;if(!t||"object"!=typeof t)return{path:"/chat",auth:"none",sessionMode:"stateless",streaming:!1};let r="string"==typeof t.path?t.path:"/chat",n=t.auth&&"object"==typeof t.auth?t.auth:null,a=n&&"bearer"===n.type?"bearer":"none",l=n&&"bearer"===n.type&&"string"==typeof n.token?n.token:"";return{path:r,auth:a,token:l,sessionMode:"per-session"===t.sessionMode?"per-session":"stateless",streaming:!0===t.streaming}}function eq(e){var t,r;let{definition:l,nodeId:s,onChange:o}=e,i=(null!=(t=l.nodes)?t:[]).find(e=>e.id===s),d=ez(i),[c,u]=(0,a.useState)(d.path),[p,h]=(0,a.useState)(d.auth),[m,x]=(0,a.useState)(null!=(r=d.token)?r:""),[f,g]=(0,a.useState)(d.sessionMode),[b,y]=(0,a.useState)(d.streaming);(0,a.useEffect)(()=>{var e;let t=ez(i);u(t.path),h(t.auth),x(null!=(e=t.token)?e:""),g(t.sessionMode),y(t.streaming)},[s,i]);let v=(0,a.useCallback)(()=>({path:c,auth:p,token:m,sessionMode:f,streaming:b}),[c,p,m,f,b]),j=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(i)return j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{o(function(e,t,r){var n;let a={path:r.path};"bearer"===r.auth&&r.token&&(a.auth={type:"bearer",token:r.token}),"stateless"!==r.sessionMode&&(a.sessionMode=r.sessionMode),r.streaming&&(a.streaming=!0);let l=(null!=(n=e.nodes)?n:[]).map(e=>e.id===t?{...e,chatTrigger:a}:e);return{...e,nodes:l}}(l,s,v()))},500),()=>{j.current&&clearTimeout(j.current)}},[i,s,l,v,o]);let w=c.trim()?c.startsWith("/")?/\s/.test(c)?{ok:!1,message:"no whitespace in path"}:{ok:!0,message:"path ok"}:{ok:!1,message:"path must start with '/'"}:{ok:!1,message:"path required"},k=w.ok?"valid":"error";return(0,n.jsxs)(ev,{variantLabel:"Chat",validationStatus:k,validationMessage:w.message,children:[(0,n.jsx)(ej,{label:"path",hint:"POST /v1/workflows/<name>".concat(c),children:(0,n.jsx)("input",{value:c,onChange:e=>u(e.target.value),placeholder:"/chat",spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),(0,n.jsx)(ej,{label:"session mode",children:(0,n.jsxs)("select",{value:f,onChange:e=>g(e.target.value),className:"w-full rounded-md border border-border bg-surface px-2 py-1 text-xs",children:[(0,n.jsx)("option",{value:"stateless",children:"stateless"}),(0,n.jsx)("option",{value:"per-session",children:"per-session"})]})}),(0,n.jsx)(ej,{label:"auth",full:!0,children:(0,n.jsx)("div",{className:"flex gap-2 text-xs",children:["none","bearer"].map(e=>(0,n.jsxs)("label",{className:"flex items-center gap-1",children:[(0,n.jsx)("input",{type:"radio",name:"chat-auth",checked:p===e,onChange:()=>h(e)}),(0,n.jsx)("span",{className:"text-text-tertiary",children:e})]},e))})}),"bearer"===p&&(0,n.jsx)(ej,{label:"token",full:!0,children:(0,n.jsx)("input",{type:"password",value:m,onChange:e=>x(e.target.value),placeholder:"bearer token",spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),(0,n.jsx)(ej,{label:"streaming response",full:!0,children:(0,n.jsxs)("label",{className:"flex items-center gap-2 text-xs",children:[(0,n.jsx)("input",{type:"checkbox",checked:b,onChange:e=>y(e.target.checked)}),(0,n.jsx)("span",{className:"text-text-tertiary",children:"stream the last-node output as SSE (v2 daemon wire — flag persisted now)"})]})}),(0,n.jsx)(ej,{label:"v2 follow-ups",full:!0,children:(0,n.jsx)("p",{className:"rounded-md border border-border bg-surface px-2 py-1.5 text-[11px] leading-snug text-text-tertiary",children:"v1 = webhook mode minimal. Hosted chat page \xb7 AI memory \xb7 file upload \xb7 multi-response Chat nodes are deferred to v2 (BACKLOG follow-up \xb7 per n8n ChatTrigger 961 LOC reference)."})})]})}let eW=new Set(["type","title","description","default","enum","format","writeOnly","x-multiline","properties","required","items","minLength","maxLength","pattern","minimum","maximum","minItems","maxItems"]),eG=new Set(["string","number","integer","boolean","object","array"]);function eB(e){return null===e||"object"!=typeof e||Array.isArray(e)?null:e}function eH(e){let t=e.type;return"string"==typeof t&&eG.has(t)?t:null}function e$(e,t){return e?"".concat(e,".").concat(t):t}function eK(e,t,r){let[n,...a]=t.split("."),l={...e};if(0===a.length)return void 0===r?delete l[n]:l[n]=r,l;let s=l[n],o=null===s||"object"!=typeof s||Array.isArray(s)?{}:s;return l[n]=eK(o,a.join("."),r),l}function eU(e,t){if(""!==t){if("number"===e.type||"integer"===e.type){let e=Number(t);return Number.isFinite(e)?e:t}return t}}function eJ(e){let{schema:t,value:r,onChange:l}=e,s=(0,a.useMemo)(()=>(function(e){let t=[],r=[],n=new Set;return!function e(a,l,s,o){let i=eB(a);if(!i||n.has(i))return void r.push(l||"(root)");for(let e of(n.add(i),Object.keys(i)))eW.has(e)||r.push(e$(l,e));let d=eH(i);void 0===i.type||d||r.push(e$(l,"type"));let c=null!=d?d:void 0===i.type?eB(i.properties)||Array.isArray(i.required)?"object":void 0!==i.items?"array":null:null;if(l&&c&&t.push({path:l,type:c,label:"string"==typeof i.title?i.title:l.split(".").at(-1),..."string"==typeof i.description?{description:i.description}:{},required:o,...Object.hasOwn(i,"default")?{default:i.default}:{},...Array.isArray(i.enum)?{enum:[...i.enum]}:{},multiline:function(e,t,r){var n;if("textarea"===t.format||"multiline"===t.format||"markdown"===t.format||!0===t["x-multiline"])return!0;if("string"!==e||Array.isArray(t.enum)||"password"===t.format||"secret"===t.format||!0===t.writeOnly)return!1;let a=null!=(n=r.split(".").at(-1))?n:"",l="string"==typeof t.title?t.title:"";return/markdown|body|text/i.test(a)||/markdown|본문/i.test(l)}(c,i,l),secret:"password"===i.format||"secret"===i.format||!0===i.writeOnly}),s<6){if(("object"===d||void 0===i.type)&&eB(i.properties)){let t=new Set(Array.isArray(i.required)?i.required:[]);for(let[r,n]of Object.entries(i.properties))e(n,e$(l,r),s+1,t.has(r))}("array"===d||void 0===i.type)&&void 0!==i.items&&e(i.items,"".concat(l,"[]"),s+1,!1)}n.delete(i)}(e,"",0,!1),{fields:t,unsupported:r}})(t),[t]),{leaves:o,arrays:i}=(0,a.useMemo)(()=>(function(e){let t=[],r=[];for(let n of e)n.path.includes("[]")||("array"===n.type?r.push(n):"object"!==n.type&&t.push(n));return{leaves:t,arrays:r}})(s.fields),[s]),d=(0,a.useMemo)(()=>(function(e,t){let r=[],n=new Set;return!function e(t,a,l,s){let o=eB(t);if(!o||n.has(o))return;n.add(o);let i=eH(o);if(i&&!("object"===i?null!==eB(a):"array"===i?Array.isArray(a):"integer"===i?"number"==typeof a&&Number.isInteger(a):"number"===i?"number"==typeof a&&Number.isFinite(a):typeof a===i)){r.push({path:l,message:"Must be ".concat("integer"===i?"an integer":"a ".concat(i),".")}),n.delete(o);return}if(Array.isArray(o.enum)&&!o.enum.some(e=>(function e(t,r){if(t===r)return!0;if(Array.isArray(t)||Array.isArray(r))return Array.isArray(t)&&Array.isArray(r)&&t.length===r.length&&t.every((t,n)=>e(t,r[n]));let n=eB(t),a=eB(r);if(!n||!a)return!1;let l=Object.keys(n);return l.length===Object.keys(a).length&&l.every(t=>Object.hasOwn(a,t)&&e(n[t],a[t]))})(e,a))&&r.push({path:l,message:"Must be one of the allowed values."}),"string"==typeof a){let e=Array.from(a).length;if("number"==typeof o.minLength&&e<o.minLength&&r.push({path:l,message:"Must have at least ".concat(o.minLength," characters.")}),"number"==typeof o.maxLength&&e>o.maxLength&&r.push({path:l,message:"Must have at most ".concat(o.maxLength," characters.")}),"string"==typeof o.pattern)try{new RegExp(o.pattern).test(a)||r.push({path:l,message:"Does not match the required pattern."})}catch(e){}}"number"==typeof a&&("number"==typeof o.minimum&&a<o.minimum&&r.push({path:l,message:"Must be at least ".concat(o.minimum,".")}),"number"==typeof o.maximum&&a>o.maximum&&r.push({path:l,message:"Must be at most ".concat(o.maximum,".")})),Array.isArray(a)&&("number"==typeof o.minItems&&a.length<o.minItems&&r.push({path:l,message:"Must have at least ".concat(o.minItems," items.")}),"number"==typeof o.maxItems&&a.length>o.maxItems&&r.push({path:l,message:"Must have at most ".concat(o.maxItems," items.")}));let d=eB(a);if(d&&("object"===i||void 0===o.type)){if(Array.isArray(o.required))for(let e of o.required)"string"!=typeof e||Object.hasOwn(d,e)&&void 0!==d[e]||r.push({path:e$(l,e),message:"Required."});if(s<6){let t=eB(o.properties);if(t)for(let[r,n]of Object.entries(t))Object.hasOwn(d,r)&&void 0!==d[r]&&e(n,d[r],e$(l,r),s+1)}}s<6&&("array"===i||void 0===o.type)&&Array.isArray(a)&&void 0!==o.items&&a.forEach((t,r)=>e(o.items,t,"".concat(l,"[").concat(r,"]"),s+1)),n.delete(o)}(e,t,"",0),r})(t,r),[t,r]);return(0,n.jsxs)("div",{className:"col-span-full flex flex-col gap-2","data-schema-form":!0,children:[s.unsupported.length>0&&(0,n.jsxs)("p",{className:"text-[11px] text-warning","data-schema-unsupported":!0,children:["이 노드의 설정 일부는 폼이 다루지 않습니다(",s.unsupported.slice(0,3).join(", "),s.unsupported.length>3?" 외 ".concat(s.unsupported.length-3):"",") — YAML 에서 고치세요."]}),i.length>0&&(0,n.jsxs)("p",{className:"text-[11px] text-text-tertiary",children:["목록 칸(",i.map(e=>e.label).join(", "),")은 YAML 에서 고치세요."]}),o.map(e=>{var t,a;let s,o=function(e,t){let r=e;for(let e of t.split(".")){if(null===r||"object"!=typeof r||Array.isArray(r))return;r=r[e]}return r}(r,e.path),i="schema-".concat(e.path),c=(t=e.path,null==(a=d.find(e=>e.path===t))?void 0:a.message),u="".concat(e.label).concat(e.required?" *":""),p="w-full rounded-md border border-border bg-surface px-2 py-1 text-xs";return s="boolean"===e.type?(0,n.jsx)("input",{id:i,type:"checkbox",checked:!0===o,onChange:t=>l(eK(r,e.path,t.target.checked))}):e.enum&&e.enum.length>0?(0,n.jsxs)("select",{id:i,className:p,value:void 0===o?"":String(o),onChange:t=>{let n=e.enum.find(e=>String(e)===t.target.value);l(eK(r,e.path,""===t.target.value?void 0:n))},children:[(0,n.jsx)("option",{value:"",children:"(비움)"}),e.enum.map(e=>(0,n.jsx)("option",{value:String(e),children:String(e)},String(e)))]}):e.multiline?(0,n.jsx)("textarea",{id:i,rows:4,className:"".concat(p," font-mono"),value:"string"==typeof o?o:void 0===o?"":String(o),onChange:t=>l(eK(r,e.path,eU(e,t.target.value)))}):(0,n.jsx)("input",{id:i,type:e.secret?"password":"number"===e.type||"integer"===e.type?"number":"text",autoComplete:e.secret?"off":void 0,className:p,placeholder:void 0!==e.default?String(e.default):void 0,value:void 0===o?"":String(o),onChange:t=>l(eK(r,e.path,eU(e,t.target.value)))}),(0,n.jsxs)("div",{className:"flex flex-col gap-0.5","data-schema-field":e.path,children:[(0,n.jsx)("label",{htmlFor:i,className:"text-[11px] text-text-secondary",children:u}),s,e.description&&(0,n.jsx)("span",{className:"text-[10px] text-text-tertiary",children:e.description}),c&&(0,n.jsx)("span",{className:"text-[11px] text-error",role:"alert","data-schema-error":e.path,children:c})]},e.path)})]})}function eY(e){var t,r,l,s;let{definition:o,nodeId:i,skills:d,onChange:c,onClose:u,onDelete:p,palette:h}=e,m=(0,a.useMemo)(()=>{var e,t;return null!=(t=(null!=(e=o.nodes)?e:[]).find(e=>e.id===i))?t:null},[o,i]),x=(0,a.useMemo)(()=>m?G(m):"unknown",[m]),[f,g]=(0,a.useState)(null!=(t=null==m?void 0:m.id)?t:""),[b,y]=(0,a.useState)("string"==typeof(null==m?void 0:m.bash)?m.bash:""),[j,w]=(0,a.useState)("string"==typeof(null==m?void 0:m.prompt)?m.prompt:""),[k,N]=(0,a.useState)("string"==typeof(null==m?void 0:m.skill)?m.skill:""),[C,S]=(0,a.useState)("string"==typeof(null==m?void 0:m.arguments)?m.arguments:""),[A,T]=(0,a.useState)("string"==typeof(null==m?void 0:m.cft)?m.cft:""),E=(null==m?void 0:m.approval)&&"object"==typeof m.approval?m.approval:null,[M,_]=(0,a.useState)(null!=(r=null==E?void 0:E.message)?r:""),[O,I]=(0,a.useState)(null!=(l=null==E?void 0:E.delivery)?l:"modal"),[L,P]=(0,a.useState)("string"==typeof(null==m?void 0:m.when)?m.when:""),[R,F]=(0,a.useState)(Array.isArray(null==m?void 0:m.depends_on)?[...m.depends_on]:[]);(0,a.useEffect)(()=>{var e,t;if(!m)return;g(m.id),y("string"==typeof m.bash?m.bash:""),w("string"==typeof m.prompt?m.prompt:""),N("string"==typeof m.skill?m.skill:""),S("string"==typeof m.arguments?m.arguments:""),T("string"==typeof m.cft?m.cft:"");let r=m.approval&&"object"==typeof m.approval?m.approval:null;_(null!=(e=null==r?void 0:r.message)?e:""),I(null!=(t=null==r?void 0:r.delivery)?t:"modal"),P("string"==typeof m.when?m.when:""),F(Array.isArray(m.depends_on)?[...m.depends_on]:[])},[i,m]);let D=(0,a.useMemo)(()=>{var e,t;let r="string"==typeof(null==m?void 0:m.kind)?m.kind:null;return r&&null!=(t=null==h||null==(e=h.find(e=>e.kind===r&&e.schema))?void 0:e.schema)?t:null},[m,h]),z=(0,a.useMemo)(()=>{let e=null==m?void 0:m.inputs;return e&&"object"==typeof e&&!Array.isArray(e)?e:{}},[m]),[q,W]=(0,a.useState)(z);(0,a.useEffect)(()=>{W(z)},[i,z]),(0,a.useEffect)(()=>{if(!m||!D||JSON.stringify(q)===JSON.stringify(z))return;let e=setTimeout(()=>{var e;c({...o,nodes:(null!=(e=o.nodes)?e:[]).map(e=>e.id===i?{...e,inputs:q}:e)})},500);return()=>clearTimeout(e)},[q,z,D,m,i,o,c]);let B=(0,a.useCallback)(()=>{var e,t;if(!m)return{};let r={};if(f!==m.id&&/^[a-z0-9]+(-[a-z0-9]+)*$/.test(f)&&(r.id=f),"bash"===x&&b!==m.bash&&(r.bash=b),"prompt"===x&&j!==m.prompt&&(r.prompt=j),"skill"===x&&(k!==m.skill&&(r.skill=k),C!==(null!=(e=m.arguments)?e:"")&&(r.arguments=C)),"cft"===x&&A!==m.cft&&(r.cft=A),"approval"===x){let e=null!=E?E:{message:"",delivery:"modal"};(M!==e.message||O!==(null!=(t=e.delivery)?t:"modal"))&&(r.approval={message:M,delivery:O})}L!==("string"==typeof m.when?m.when:"")&&(r.when=L.trim()?L:null);let n=Array.isArray(m.depends_on)?m.depends_on:[];return(R.length!==n.length||R.some((e,t)=>n[t]!==e))&&(r.depends_on=R),r},[m,x,E,f,b,j,k,C,A,M,O,L,R]),$=(0,a.useRef)(null);if((0,a.useEffect)(()=>{if(m)return $.current&&clearTimeout($.current),$.current=setTimeout(()=>{let e=B();if(0===Object.keys(e).length)return;let t=function(e,t,r){var n,a;if(!(null!=(n=e.nodes)?n:[]).find(e=>e.id===t))return e;let l=e,s=t;r.id&&r.id!==t&&(s=(l=function(e,t,r){var n,a;if(t===r||new Set((null!=(n=e.nodes)?n:[]).map(e=>e.id)).has(r))return e;let l=(null!=(a=e.nodes)?a:[]).map(e=>{let n=e;return e.id===t&&(n={...n,id:r}),Array.isArray(n.depends_on)&&(n={...n,depends_on:n.depends_on.map(e=>e===t?r:e)}),n});return{...e,nodes:l}}(e,t,r.id))===e?t:r.id);let o=(null!=(a=l.nodes)?a:[]).map(e=>{if(e.id!==s)return e;let t={...e},n=G(e),a=["bash","prompt","skill","cft","approval"].find(e=>void 0!==r[e]);return a&&a!==n&&"unknown"!==n&&(delete t[n],"skill"===n&&delete t.arguments,"cft"===n&&delete t.config),void 0!==r.bash&&(t.bash=r.bash),void 0!==r.prompt&&(t.prompt=r.prompt),void 0!==r.skill&&(t.skill=r.skill),void 0!==r.arguments&&(t.arguments=r.arguments),void 0!==r.cft&&(t.cft=r.cft),void 0!==r.config&&(t.config=r.config),void 0!==r.approval&&(t.approval=r.approval),null===r.when?delete t.when:"string"==typeof r.when&&(t.when=r.when),void 0!==r.depends_on&&(0===r.depends_on.length?delete t.depends_on:t.depends_on=[...r.depends_on]),t});return{...l,nodes:o}}(o,i,e);t!==o&&c(t)},500),()=>{$.current&&clearTimeout($.current)}},[m,i,o,B,c]),!m)return(0,n.jsx)("div",{className:"border-t border-border bg-surface-elevated px-3 py-3 text-[11px] text-text-tertiary",children:"Node not found — it may have been deleted."});if("scheduleTrigger"===x||"webhookTrigger"===x||"http"===x||"discordTrigger"===x||"telegramTrigger"===x||"manualTrigger"===x||"chatTrigger"===x)return(0,n.jsxs)("div",{className:"border-t border-border bg-surface-elevated",children:[(0,n.jsxs)("header",{className:"flex items-center justify-between px-3 py-2",children:[(0,n.jsx)("span",{className:"font-mono text-xs text-text-primary",children:i}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsxs)("button",{type:"button",onClick:p,className:"flex items-center gap-1 rounded px-2 py-0.5 text-[11px] text-error hover:bg-error/10",title:"Delete this node",children:[(0,n.jsx)(v.A,{className:"h-3 w-3"}),"Delete"]}),(0,n.jsx)("button",{type:"button",onClick:u,className:"rounded p-1 text-text-tertiary hover:bg-surface","aria-label":"Close node editor",children:(0,n.jsx)(ep.A,{className:"h-3 w-3"})})]})]}),(0,n.jsxs)("div",{className:"px-3 pb-3",children:["scheduleTrigger"===x&&(0,n.jsx)(ek,{definition:o,nodeId:i,onChange:c}),"webhookTrigger"===x&&(0,n.jsx)(eS,{definition:o,nodeId:i,onChange:c}),"http"===x&&(0,n.jsx)(eE,{definition:o,nodeId:i,onChange:c}),"discordTrigger"===x&&(0,n.jsx)(eI,{definition:o,nodeId:i,onChange:c}),"telegramTrigger"===x&&(0,n.jsx)(eR,{definition:o,nodeId:i,onChange:c}),"manualTrigger"===x&&(0,n.jsx)(eD,{definition:o,nodeId:i,onChange:c}),"chatTrigger"===x&&(0,n.jsx)(eq,{definition:o,nodeId:i,onChange:c})]})]});let K=(null!=(s=o.nodes)?s:[]).filter(e=>e.id!==i);return(0,n.jsxs)("div",{className:"border-t border-border bg-surface-elevated",children:[(0,n.jsxs)("header",{className:"flex items-center justify-between px-3 py-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"rounded bg-surface px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-text-tertiary",children:m?H(m,x):x}),(0,n.jsx)("span",{className:"font-mono text-xs text-text-primary",children:i})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsxs)("button",{type:"button",onClick:p,className:"flex items-center gap-1 rounded px-2 py-0.5 text-[11px] text-error hover:bg-error/10",title:"Delete this node",children:[(0,n.jsx)(v.A,{className:"h-3 w-3"}),"Delete"]}),(0,n.jsx)("button",{type:"button",onClick:u,className:"rounded p-1 text-text-tertiary hover:bg-surface","aria-label":"Close node editor",children:(0,n.jsx)(ep.A,{className:"h-3 w-3"})})]})]}),(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-2 px-3 pb-3 md:grid-cols-2",children:[(0,n.jsx)(eV,{label:"id",children:(0,n.jsx)("input",{value:f,onChange:e=>g(e.target.value),spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),(0,n.jsx)(eV,{label:"when (gating expression)",children:(0,n.jsx)("input",{value:L,onChange:e=>P(e.target.value),placeholder:"e.g. \"$prev.output == 'ok'\"",spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),D&&(0,n.jsx)(eJ,{schema:D,value:q,onChange:W}),"bash"===x&&(0,n.jsx)(eV,{label:"bash",full:!0,children:(0,n.jsx)("textarea",{value:b,onChange:e=>y(e.target.value),rows:4,spellCheck:!1,className:"w-full resize-none rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),"prompt"===x&&(0,n.jsx)(eV,{label:"prompt",full:!0,children:(0,n.jsx)("textarea",{value:j,onChange:e=>w(e.target.value),rows:4,spellCheck:!1,className:"w-full resize-none rounded-md border border-border bg-surface px-2 py-1 text-xs"})}),"skill"===x&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(eV,{label:"skill",children:[(0,n.jsx)("input",{value:k,onChange:e=>N(e.target.value),list:"workflow-skill-options",spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"}),d&&d.length>0&&(0,n.jsx)("datalist",{id:"workflow-skill-options",children:d.map(e=>(0,n.jsx)("option",{value:e},e))})]}),(0,n.jsx)(eV,{label:"arguments",full:!0,children:(0,n.jsx)("textarea",{value:C,onChange:e=>S(e.target.value),rows:3,spellCheck:!1,className:"w-full resize-none rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})})]}),"cft"===x&&(0,n.jsx)(eV,{label:"cft",full:!0,children:(0,n.jsx)("input",{value:A,onChange:e=>T(e.target.value),spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-xs"})}),"approval"===x&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eV,{label:"message",full:!0,children:(0,n.jsx)("textarea",{value:M,onChange:e=>_(e.target.value),rows:2,spellCheck:!1,className:"w-full resize-none rounded-md border border-border bg-surface px-2 py-1 text-xs"})}),(0,n.jsx)(eV,{label:"delivery channel",children:(0,n.jsxs)("select",{value:O,onChange:e=>I(e.target.value),className:"w-full rounded-md border border-border bg-surface px-2 py-1 text-xs",children:[(0,n.jsx)("option",{value:"all",children:"all (race)"}),(0,n.jsx)("option",{value:"modal",children:"modal (PWA)"}),(0,n.jsx)("option",{value:"terminal",children:"terminal"}),(0,n.jsx)("option",{value:"telegram",children:"telegram"}),(0,n.jsx)("option",{value:"discord",children:"discord"}),(0,n.jsx)("option",{value:"pushcut",children:"pushcut"})]})})]}),(0,n.jsx)(eV,{label:"depends_on",full:!0,children:(0,n.jsx)(eX,{value:R,options:K.map(e=>e.id),onChange:F})})]})]})}function eV(e){let{label:t,full:r,children:a}=e;return(0,n.jsxs)("label",{className:"flex flex-col gap-1 ".concat(r?"md:col-span-2":""),children:[(0,n.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-text-tertiary",children:t}),a]})}function eX(e){let{value:t,options:r,onChange:a}=e;return 0===r.length?(0,n.jsx)("span",{className:"text-[11px] text-text-tertiary",children:"No other nodes to depend on."}):(0,n.jsx)("div",{className:"flex flex-wrap gap-1",children:r.map(e=>{let r=t.includes(e);return(0,n.jsx)("button",{type:"button",onClick:()=>{t.includes(e)?a(t.filter(t=>t!==e)):a([...t,e])},className:"rounded-md border px-2 py-0.5 font-mono text-[10px] transition-colors ".concat(r?"border-accent bg-accent/15 text-accent":"border-border text-text-tertiary hover:bg-surface"),children:e},e)})})}var eQ=r(40807);let eZ={running:"Running",orphaned:"Orphaned",done:"Done",failed:"Failed",unknown:"Unknown"},e0={running:"bg-info/10 text-info ring-info/30",orphaned:"bg-text-tertiary/10 text-text-tertiary ring-border",done:"bg-success/10 text-success ring-success/30",failed:"bg-error/10 text-error ring-error/30",unknown:"bg-surface-elevated text-text-tertiary ring-border"};function e1(e){let{onSelect:t,selectedRunId:r,enabled:l}=e,s=(0,A.b_)({enabled:null==l||l}),[o,i]=(0,a.useState)("all"),d=(0,a.useMemo)(()=>{var e,t;let r=null!=(t=null==(e=s.data)?void 0:e.runs)?t:[];return"all"===o?r:r.filter(e=>e.status===o)},[s.data,o]),c=(0,a.useMemo)(()=>{var e,t;let r={all:0,running:0,orphaned:0,done:0,failed:0};for(let n of null!=(t=null==(e=s.data)?void 0:e.runs)?t:[])r.all+=1,n.status in r&&(r[n.status]+=1);return r},[s.data]);return s.isLoading?(0,n.jsxs)("div",{className:"flex h-full items-center justify-center text-[11px] text-text-tertiary",children:[(0,n.jsx)(j.A,{className:"mr-1.5 h-3 w-3 animate-spin"}),"loading runs…"]}):s.error?(0,n.jsxs)("div",{className:"flex h-full items-center justify-center text-[11px] text-error",children:[(0,n.jsx)(y.A,{className:"mr-1.5 h-3 w-3"}),"failed to load runs: ",s.error.message]}):(0,n.jsxs)("div",{className:"flex h-full flex-col",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2",children:[(0,n.jsx)(g.A,{className:"h-3.5 w-3.5 text-text-tertiary"}),(0,n.jsx)("span",{className:"text-xs font-medium",children:"Recent runs"}),(0,n.jsxs)("span",{className:"text-[10px] text-text-tertiary",children:["(",c.all,")"]}),(0,n.jsx)("div",{className:"ml-auto flex items-center gap-1",children:["all","running","done","failed","orphaned"].map(e=>(0,n.jsx)(e2,{label:"all"===e?"all":eZ[e],count:c[e],active:o===e,onClick:()=>i(e)},e))})]}),0===d.length?(0,n.jsx)("div",{className:"flex flex-1 items-center justify-center text-[11px] text-text-tertiary",children:"all"===o?"No runs yet — pick a workflow + click Run to start one.":"No ".concat(eZ[o].toLowerCase()," runs.")}):(0,n.jsx)("ul",{className:"flex-1 overflow-y-auto",children:d.map(e=>(0,n.jsx)(e3,{run:e,selected:e.runId===r,onSelect:()=>t(e.runId,e.workflowName)},e.runId))})]})}function e2(e){let{label:t,count:r,active:a,onClick:l}=e;return(0,n.jsxs)("button",{type:"button",onClick:l,className:"rounded-md px-1.5 py-0.5 text-[10px] transition-colors ".concat(a?"bg-primary/15 text-primary ring-1 ring-primary/30":"text-text-tertiary hover:bg-surface-elevated"),children:[t,r>0&&(0,n.jsx)("span",{className:"ml-1 opacity-70",children:r})]})}function e3(e){let{run:t,selected:r,onSelect:a}=e;return(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button",onClick:a,className:"flex w-full items-center gap-2 border-b border-border px-3 py-2 text-left text-[11px] transition-colors hover:bg-surface-elevated ".concat(r?"bg-primary/10":""),children:[(0,n.jsx)(e5,{status:t.status}),(0,n.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)(d.A,{className:"h-3 w-3 shrink-0 text-text-tertiary"}),(0,n.jsx)("span",{className:"truncate font-medium",children:t.workflowName})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2 text-[9px] text-text-tertiary",children:[(0,n.jsx)("span",{className:"font-mono",children:t.runId.slice(0,22)}),(0,n.jsx)("span",{children:"\xb7"}),(0,n.jsx)("span",{children:function(e){let t=Date.now()-e;return t<6e4?"".concat(Math.max(1,Math.floor(t/1e3)),"s ago"):t<36e5?"".concat(Math.floor(t/6e4),"m ago"):t<864e5?"".concat(Math.floor(t/36e5),"h ago"):"".concat(Math.floor(t/864e5),"d ago")}(t.startedAt)}),t.arguments&&t.arguments.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{children:"\xb7"}),(0,n.jsx)("span",{className:"truncate italic",children:t.arguments.slice(0,30)})]})]})]}),(0,n.jsx)("span",{className:"shrink-0 rounded px-1.5 py-0.5 text-[9px] font-medium uppercase ring-1 ".concat(e0[t.status]),children:eZ[t.status]})]})})}function e5(e){let{status:t}=e;return"running"===t?(0,n.jsx)(j.A,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-info"}):"done"===t?(0,n.jsx)(S.A,{className:"h-3.5 w-3.5 shrink-0 text-success"}):"failed"===t?(0,n.jsx)(y.A,{className:"h-3.5 w-3.5 shrink-0 text-error"}):"orphaned"===t?(0,n.jsx)(eQ.A,{className:"h-3.5 w-3.5 shrink-0 text-text-tertiary"}):(0,n.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-full bg-text-tertiary/30"})}function e4(e){var t,r;let{runId:l,message:s,onDismiss:o,onResolved:i}=e,[d,c]=(0,a.useState)(""),u=(0,A.Yk)(),p=(0,A.Ux)(),h=u.isPending||p.isPending;(0,a.useEffect)(()=>{let e=e=>{"Escape"!==e.key||h||o()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[h,o]);let m=async()=>{try{await u.mutateAsync({runId:l,response:d.trim()?d:void 0}),null==i||i("approved")}catch(e){}},x=async()=>{try{await p.mutateAsync({runId:l,reason:d.trim()?d:void 0}),null==i||i("rejected")}catch(e){}};return(0,n.jsx)("div",{role:"dialog","aria-modal":"true","aria-labelledby":"approval-modal-title",className:"fixed inset-0 z-50 flex items-end justify-center bg-black/40 backdrop-blur-sm sm:items-center",children:(0,n.jsxs)("div",{className:"w-full max-w-md rounded-t-2xl border border-border bg-surface shadow-xl sm:rounded-lg",children:[(0,n.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[(0,n.jsxs)("h2",{id:"approval-modal-title",className:"flex items-center gap-2 text-sm font-semibold",children:[(0,n.jsx)(y.A,{className:"h-4 w-4 text-warning"}),"Approval needed"]}),(0,n.jsx)("button",{type:"button",onClick:o,disabled:h,"aria-label":"Close approval modal",className:"rounded-md p-1 text-text-tertiary hover:bg-surface-elevated disabled:opacity-50",children:(0,n.jsx)(ep.A,{className:"h-3.5 w-3.5"})})]}),(0,n.jsxs)("div",{className:"space-y-2 px-4 py-3",children:[(0,n.jsxs)("div",{className:"text-[10px] uppercase tracking-wide text-text-tertiary",children:["run \xb7 ",(0,n.jsx)("span",{className:"font-mono",children:l.slice(0,28)})]}),(0,n.jsx)("p",{className:"whitespace-pre-wrap text-[13px] leading-snug",children:s}),(0,n.jsxs)("label",{className:"block pt-2 text-[10px] uppercase tracking-wide text-text-tertiary",children:["Response (optional \xb7 captured into ",(0,n.jsx)("code",{className:"font-mono",children:"$node.output"})," when capture_response: true)"]}),(0,n.jsx)("textarea",{value:d,onChange:e=>c(e.target.value),placeholder:"LGTM / type a reason for rejection / leave empty for bare approval",rows:3,disabled:h,className:"w-full resize-none rounded-md border border-border bg-surface-elevated px-2 py-1.5 font-mono text-[11px] focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-50"}),(u.error||p.error)&&(0,n.jsx)("p",{className:"text-[11px] text-error",children:(null!=(t=u.error)?t:p.error)instanceof Error?(null!=(r=u.error)?r:p.error).message:"request failed"})]}),(0,n.jsxs)("footer",{className:"flex items-center justify-end gap-2 border-t border-border px-4 py-3",children:[(0,n.jsxs)("button",{type:"button",onClick:x,disabled:h,className:"flex items-center gap-1 rounded-md border border-error/40 px-3 py-1.5 text-[11px] text-error hover:bg-error/10 disabled:opacity-50",children:[p.isPending?(0,n.jsx)(j.A,{className:"h-3 w-3 animate-spin"}):(0,n.jsx)(y.A,{className:"h-3 w-3"}),"Reject"]}),(0,n.jsxs)("button",{type:"button",onClick:m,disabled:h,className:"flex items-center gap-1 rounded-md bg-primary px-3 py-1.5 text-[11px] font-medium text-primary-foreground hover:bg-accent-hover disabled:opacity-50",children:[u.isPending?(0,n.jsx)(j.A,{className:"h-3 w-3 animate-spin"}):(0,n.jsx)(S.A,{className:"h-3 w-3"}),"Approve"]})]})]})})}let e6="elanous.workflows.layout",e9={leftCollapsed:!1,rightCollapsed:!1,canvasOnly:!1,leftWidthPx:240,rightWidthPx:320};function e8(e,t){return Number.isFinite(e)?e<160?160:e>640?640:Math.round(e):t}let e7={project:"Project",global:"Global",builtin:"Built-in"};function te(){let{palette:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,o.Qj)()?(0,n.jsx)(tr,{palette:e}):(0,n.jsx)(tt,{})}function tt(){return(0,n.jsxs)("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 py-10 text-center",children:[(0,n.jsx)(d.A,{className:"h-8 w-8 text-text-tertiary"}),(0,n.jsx)("h2",{className:"text-base font-semibold",children:"Workflows"}),(0,n.jsx)("p",{className:"max-w-md text-sm text-text-tertiary",children:"Daemon 연결이 설정되지 않았습니다. Settings 에서 Base URL 을 입력하면 워크플로우 목록이 표시됩니다."}),(0,n.jsx)("a",{href:"/app/settings/",className:"rounded-md border border-border px-3 py-1 text-sm text-text-primary hover:bg-surface-elevated",children:"Settings"})]})}function tr(e){var t,r,l,s,o,N,C,S,T,E,M,_;let{palette:O}=e,I=(0,A.mP)(),[L,P]=(0,a.useState)(null),[R,F]=(0,a.useState)(""),[D,z]=(0,a.useState)(""),[q,W]=(0,a.useState)(null),[G,B]=(0,a.useState)(!1),[H,$]=(0,a.useState)(""),[K,U]=(0,a.useState)(null),[J,V]=(0,a.useState)("graph"),[Z,ee]=(0,a.useState)(!1),[et,er]=(0,a.useState)(!1),[ea,el]=(0,a.useState)(null),[es,eo]=(0,a.useState)(null),ei=(0,A.j3)(null!=L?L:"",{enabled:!!L&&!G}),ed=(0,A.yM)(),ec=(0,A.oE)(),eu=(0,A.xd)(),ep=(0,A.XL)(),eh=(0,A.b_)(),em=(0,a.useMemo)(()=>{var e,t,r;return L&&(null==(e=eh.data)?void 0:e.runs)&&null!=(r=null==(t=function(e,t){let r=null;for(let n of e)n.workflowName===t&&(!r||n.startedAt>r.startedAt)&&(r=n);return r}(eh.data.runs,L))?void 0:t.runId)?r:null},[L,null==(t=eh.data)?void 0:t.runs]),ex=null!=q?q:em,ef=(0,A.uz)(ex),eg=(0,a.useMemo)(()=>{var e;if(null==(e=ef.data)?void 0:e.events)return function(e){let t={};for(let n of e)if(n.nodeId)switch(n.type){case"node_start":t[n.nodeId]||(t[n.nodeId]={status:"running"});break;case"node_done":{let e=n.result;if(null==e?void 0:e.ok)t[n.nodeId]={status:"done",durationMs:e.durationMs};else{let r={status:"failed"};(null==e?void 0:e.durationMs)!==void 0&&(r.durationMs=e.durationMs),(null==e?void 0:e.error)&&(r.error=e.error),t[n.nodeId]=r}break}case"node_skipped":{let e={status:"skipped"};n.reason&&(e.reason=n.reason),t[n.nodeId]=e;break}case"approval_pending":t[n.nodeId]={status:"awaiting_approval"};break;case"approval_resolved":var r;(null==(r=t[n.nodeId])?void 0:r.status)==="awaiting_approval"&&delete t[n.nodeId]}return t}(ef.data.events)},[null==(r=ef.data)?void 0:r.events]),ey=(0,A.zD)();(0,A.Ck)();let ev=(0,a.useMemo)(()=>{var e,t,r;return null!=(r=(null!=(t=null==(e=ey.data)?void 0:e.pending)?t:[]).find(e=>e.runId===q))?r:null},[ey.data,q]),ej=null!=(T=null==(l=ey.data)?void 0:l.pending.length)?T:0,[ew,ek]=(0,a.useState)(new Set);(0,a.useEffect)(()=>{ek(new Set)},[q]),(0,a.useEffect)(()=>{var e;G||(null==(e=ei.data)?void 0:e.yaml)!==void 0&&F(ei.data.yaml)},[null==(s=ei.data)?void 0:s.yaml,G]);let eN=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(!R.trim())return;let e=setTimeout(()=>{var e;null==(e=eN.current)||e.abort();let t=new AbortController;eN.current=t,eu.mutateAsync({yaml:R,signal:t.signal}).catch(()=>void 0)},600);return()=>{var t;clearTimeout(e),null==(t=eN.current)||t.abort()}},[R]);let eC=(0,a.useMemo)(()=>{var e,t;let r={project:[],global:[],builtin:[]};for(let n of null!=(t=null==(e=I.data)?void 0:e.workflows)?t:[])r[n.source].push(n);return r},[null==(o=I.data)?void 0:o.workflows]),eS=null==(N=eu.data)?void 0:N.validation,eA=eS&&!eS.ok?eS.issues:[],eT=(0,a.useMemo)(()=>R.trim()?Q(R):null,[R]),eE=(0,a.useMemo)(()=>{if(eT&&0!==eA.length)return function(e,t){let r={},n=[];for(let a of e){let e=function(e,t){if("string"!=typeof e)return null;let r=/^nodes\[(\d+)\]/.exec(e);if(!r)return null;let n=Number.parseInt(r[1],10);if(!Number.isFinite(n)||n<0)return null;let a=Array.isArray(t.nodes)?t.nodes:[];if(n>=a.length)return null;let l=a[n];return l&&"string"==typeof l.id&&0!==l.id.length?l.id:null}(a.path,t);e?(r[e]||(r[e]=[]),r[e].push(a)):n.push(a)}return{byNodeId:r,rootIssues:n}}(eA,eT).byNodeId},[eT,eA]),eM=(0,a.useMemo)(()=>{if(!eT)return;let e=function(e){var t,r;let n=Array.isArray(e.nodes)?e.nodes:[],a=new Set,l=new Map;for(let e of n)e&&"string"==typeof e.id&&0!==e.id.length&&a.add(e.id);for(let e of n)if(e&&"string"==typeof e.id&&0!==e.id.length)for(let r of Array.isArray(e.depends_on)?e.depends_on:[]){if("string"!=typeof r||0===r.length||!a.has(r))continue;let n=null!=(t=l.get(r))?t:[];n.push(e.id),l.set(r,n)}let s=new Set,o=new Map,i=[];for(let e of a)(null!=(r=o.get(e))?r:0)===0&&function e(t){var r,n;for(let a of(o.set(t,1),i.push(t),null!=(r=l.get(t))?r:[])){let t=null!=(n=o.get(a))?n:0;if(1===t){let e=i.lastIndexOf(a);if(e>=0)for(let t=e;t<i.length;t++)s.add(i[t])}else 0===t&&e(a)}o.set(t,2),i.pop()}(e);return s}(eT);return e.size>0?e:void 0},[eT]),e_=e=>{P(e),B(!1),W(null),el(null)},eO=async()=>{if(U(null),G){let e=H.trim()?i.test(H.trim())?null:"이름은 소문자\xb7숫자와 하이픈(-)만 쓸 수 있습니다. 예: weekly-report":"워크플로 이름을 먼저 적어 주세요.";if(e)return void U(e)}let e=G?H.trim():L;if(!e)return;let t=G?function(e,t){let r=/^name:[^\n]*$/m;return r.test(e)?e.replace(r,"name: ".concat(t)):"name: ".concat(t,"\n").concat(e)}(R,e):R;t!==R&&F(t);try{await ed.mutateAsync({name:e,body:{yaml:t,scope:"project"}}),B(!1),P(e)}catch(e){U(function(e){var t,r,n,a;let l="object"==typeof e&&null!==e&&"status"in e?Number(e.status):NaN,s="object"==typeof e&&null!==e&&"body"in e?e.body:void 0,o=s&&"object"==typeof s&&"reason"in s&&"string"==typeof s.reason?s.reason:"",i=s&&"object"==typeof s&&"validation"in s&&null!=(n=null==(t=s.validation)?void 0:t.issues)?n:[];return 401===l||403===l?"저장 권한이 없습니다. 설정에서 연결 토큰을 확인해 주세요.":/name mismatch/i.test(o)?"이름 칸과 워크플로 이름이 달라 저장하지 못했습니다. 다시 저장해 주세요.":i.length?"저장하지 못했습니다: ".concat(String(null!=(a=null==(r=i[0])?void 0:r.message)?a:"").slice(0,120)):409===l?"같은 이름의 워크플로가 이미 있습니다. 다른 이름을 적어 주세요.":"저장하지 못했습니다. 잠시 뒤 다시 시도해 주세요."}(e))}},eI=async()=>{if(L)try{let e=await ep.mutateAsync({name:L,args:D});W(e.runId)}catch(e){}},eL=async()=>{var e,t;if(!L||(null==(e=ei.data)?void 0:e.source)==="builtin")return;let r=(null==(t=ei.data)?void 0:t.source)==="global"?"global":"project";try{await ec.mutateAsync({name:L,scope:r}),P(null),F("")}catch(e){}},eP=(null==(C=ei.data)?void 0:C.source)==="builtin",eR=eu.isPending?"pending":eS?eS.ok?"ok":"error":"idle",eF=function(){let[e,t]=(0,a.useState)(()=>e9),r=(0,a.useRef)(!1);(0,a.useEffect)(()=>{t(function(){try{var e,t,r;let n=window.localStorage.getItem(e6);if(!n)return{...e9};return(e=JSON.parse(n))&&"object"==typeof e?{leftCollapsed:"boolean"==typeof e.leftCollapsed?e.leftCollapsed:e9.leftCollapsed,rightCollapsed:"boolean"==typeof e.rightCollapsed?e.rightCollapsed:e9.rightCollapsed,canvasOnly:"boolean"==typeof e.canvasOnly?e.canvasOnly:e9.canvasOnly,leftWidthPx:e8(null!=(t=e.leftWidthPx)?t:e9.leftWidthPx,e9.leftWidthPx),rightWidthPx:e8(null!=(r=e.rightWidthPx)?r:e9.rightWidthPx,e9.rightWidthPx)}:{...e9}}catch(e){return{...e9}}}()),r.current=!0},[]),(0,a.useEffect)(()=>{if(r.current)try{window.localStorage.setItem(e6,JSON.stringify(e))}catch(e){}},[e]);let n=(0,a.useCallback)(()=>{t(e=>({...e,leftCollapsed:!e.leftCollapsed}))},[]),l=(0,a.useCallback)(()=>{t(e=>({...e,rightCollapsed:!e.rightCollapsed}))},[]),s=(0,a.useCallback)(()=>{t(e=>({...e,canvasOnly:!e.canvasOnly}))},[]),o=(0,a.useCallback)(e=>{t(t=>({...t,leftWidthPx:e8(e,t.leftWidthPx)}))},[]),i=(0,a.useCallback)(e=>{t(t=>({...t,rightWidthPx:e8(e,t.rightWidthPx)}))},[]),d=(0,a.useCallback)(()=>{t({...e9})},[]);return(0,a.useMemo)(()=>({...e,toggleLeft:n,toggleRight:l,toggleCanvasOnly:s,setLeftWidth:o,setRightWidth:i,reset:d}),[e,n,l,s,o,i,d])}(),eD=!eF.canvasOnly,ez=!eF.canvasOnly,eq=eF.leftCollapsed?40:eF.leftWidthPx,eW=eF.rightCollapsed?40:eF.rightWidthPx;(0,a.useEffect)(()=>{let e=e=>{var t;if("\\"!==e.key||!(e.metaKey||e.ctrlKey))return;let r=e.target,n=null==r||null==(t=r.tagName)?void 0:t.toLowerCase();"input"===n||"textarea"===n||null!=r&&r.isContentEditable||(e.preventDefault(),eF.toggleCanvasOnly())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[eF]);let eG=(0,a.useCallback)((e,t)=>{let r="left"===e?eF.leftWidthPx:eF.rightWidthPx,n="left"===e?eF.setLeftWidth:eF.setRightWidth,a="left"===e?1:-1;try{t.target.setPointerCapture(t.pointerId)}catch(e){}let l=e=>{n(r+a*(e.clientX-t.clientX))},s=()=>{window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",s);try{t.target.releasePointerCapture(t.pointerId)}catch(e){}};window.addEventListener("pointermove",l),window.addEventListener("pointerup",s)},[eF]);return(0,n.jsxs)("div",{className:"flex h-full flex-col",children:[(0,n.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(d.A,{className:"h-4 w-4 text-text-tertiary"}),(0,n.jsx)("h1",{className:"text-sm font-semibold",children:"Workflows"}),(0,n.jsxs)("span",{className:"text-xs text-text-tertiary",children:[null!=(E=null==(S=I.data)?void 0:S.workflows.length)?E:0," declared"]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("button",{type:"button",onClick:eF.toggleLeft,title:eF.leftCollapsed?"Show workflow list":"Collapse workflow list",className:"flex items-center gap-1 rounded-md border border-border px-2 py-1 text-[11px] text-text-tertiary hover:bg-surface-elevated",children:eF.leftCollapsed?(0,n.jsx)(c.A,{className:"h-3 w-3"}):(0,n.jsx)(u.A,{className:"h-3 w-3"})}),(0,n.jsx)("button",{type:"button",onClick:eF.toggleCanvasOnly,title:eF.canvasOnly?"Exit canvas-only (Cmd+\\)":"Canvas-only mode (Cmd+\\)",className:"flex items-center gap-1 rounded-md border px-2 py-1 text-[11px] transition-colors ".concat(eF.canvasOnly?"border-accent/50 bg-accent/15 text-accent":"border-border text-text-tertiary hover:bg-surface-elevated"),children:eF.canvasOnly?(0,n.jsx)(p.A,{className:"h-3 w-3"}):(0,n.jsx)(h.A,{className:"h-3 w-3"})}),(0,n.jsx)("button",{type:"button",onClick:eF.toggleRight,title:eF.rightCollapsed?"Show run panel":"Collapse run panel",className:"flex items-center gap-1 rounded-md border border-border px-2 py-1 text-[11px] text-text-tertiary hover:bg-surface-elevated",children:eF.rightCollapsed?(0,n.jsx)(m.A,{className:"h-3 w-3"}):(0,n.jsx)(x.A,{className:"h-3 w-3"})}),ej>0&&(0,n.jsxs)("button",{type:"button",onClick:()=>{var e;if(ev&&ew.has(ev.runId))return void(ev&&ek(e=>{let t=new Set(e);return t.delete(ev.runId),t}));let t=null==(e=ey.data)?void 0:e.pending[0];t&&t.runId!==q&&W(t.runId)},title:ev&&ew.has(ev.runId)?"Re-open approval modal for this run":"".concat(ej," run(s) waiting on approval — click to view"),className:"relative flex items-center gap-1 rounded-md border border-warning/40 bg-warning/10 px-2 py-1 text-[11px] text-warning hover:bg-warning/20",children:[(0,n.jsx)(f.A,{className:"h-3 w-3"}),(0,n.jsx)("span",{children:ej}),(0,n.jsx)("span",{className:"absolute -right-1 -top-1 h-2 w-2 animate-pulse rounded-full bg-warning ring-2 ring-surface"})]}),(0,n.jsxs)("button",{type:"button",onClick:()=>ee(e=>!e),className:"flex items-center gap-1 rounded-md border px-2 py-1 text-[11px] transition-colors ".concat(Z?"border-primary/40 bg-primary/15 text-primary":"border-border text-text-tertiary hover:bg-surface-elevated"),children:[(0,n.jsx)(g.A,{className:"h-3 w-3"}),Z?"Editor":"All runs"]}),(0,n.jsxs)("button",{type:"button",onClick:()=>er(e=>!e),title:et?"Hide AI prompt":"Describe a workflow in plain text",className:"flex items-center gap-1 rounded-md border px-2 py-1 text-[11px] transition-colors ".concat(et?"border-accent/50 bg-accent/15 text-accent":"border-border text-text-tertiary hover:bg-surface-elevated"),children:[(0,n.jsx)(b.A,{className:"h-3 w-3"}),"AI"]}),(0,n.jsx)("button",{type:"button",onClick:()=>{B(!0),P(null),$(""),F("name: my-workflow\ndescription: |\n Use when: …\n Triggers: …\n Does: …\n NOT for: …\n\nprovider: claude\nmodel: sonnet\n\nnodes:\n - id: first\n bash: echo hello\n"),W(null),el(null)},className:"rounded-md bg-primary px-3 py-1 text-xs font-medium text-primary-foreground hover:bg-accent-hover transition-colors",children:"+ New"})]})]}),(0,n.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[eD&&(0,n.jsx)("aside",{style:{width:eq},className:"shrink-0 overflow-y-auto border-r border-border",children:eF.leftCollapsed?(0,n.jsx)("button",{type:"button",onClick:eF.toggleLeft,title:"Expand workflow list",className:"flex h-full w-full items-center justify-center text-text-tertiary hover:bg-surface-elevated",children:(0,n.jsx)(c.A,{className:"h-4 w-4"})}):["project","global","builtin"].map(e=>(0,n.jsx)(tn,{label:e7[e],entries:eC[e],selected:L,onSelect:e_},e))}),eD&&!eF.leftCollapsed&&(0,n.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize workflow list",onPointerDown:e=>eG("left",{clientX:e.clientX,pointerId:e.pointerId,target:e.currentTarget}),className:"w-1 shrink-0 cursor-col-resize bg-transparent hover:bg-accent/30"}),(0,n.jsx)("section",{className:"flex flex-1 flex-col overflow-hidden min-w-0",children:Z?(0,n.jsx)(e1,{selectedRunId:q,onSelect:(e,t)=>{W(e),P(t),B(!1),ee(!1)}}):(0,n.jsxs)(n.Fragment,{children:[et&&(0,n.jsx)(eb,{currentYaml:R,onClose:()=>er(!1),onGenerated:e=>{var t;e.yaml&&(F(e.yaml),(null==(t=e.definition)?void 0:t.name)&&(B(!0),P(null),$(e.definition.name),W(null)))}}),G&&(0,n.jsxs)("div",{className:"border-b border-border px-3 py-2",children:[(0,n.jsx)("label",{className:"block text-[10px] uppercase tracking-wide text-text-tertiary",children:"Workflow name (kebab-case)"}),(0,n.jsx)("input",{type:"text",value:H,onChange:e=>$(e.target.value),placeholder:"my-workflow",className:"w-full rounded-md border border-border bg-surface px-2 py-1 text-sm font-mono",autoFocus:!0})]}),!G&&L&&(0,n.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("span",{className:"text-sm font-medium",children:L}),eP&&(0,n.jsx)("span",{className:"rounded bg-surface-elevated px-1.5 py-0.5 text-[10px] text-text-tertiary",children:"read-only (built-in)"}),(0,n.jsx)(ta,{mode:J,onChange:V})]}),(0,n.jsx)("div",{className:"flex items-center gap-2",children:(0,n.jsx)(tl,{status:eR})})]}),"graph"===J&&R.trim()?(0,n.jsxs)("div",{className:"flex flex-1 flex-col overflow-hidden bg-surface",children:[(0,n.jsx)("div",{className:ea?"flex-1 min-h-[180px] overflow-hidden":"flex-1 overflow-hidden",children:(0,n.jsx)(en,{palette:O,yaml:R,editable:!eP,onChangeYaml:F,onNodeClick:eP?void 0:e=>el(e),nodeStatuses:eg,nodeIssues:eE,cycleNodeIds:eM,focusNodeId:null!=(M=null==es?void 0:es.id)?M:null,focusNonce:null!=(_=null==es?void 0:es.nonce)?_:0,onRun:L&&!G?eI:void 0})}),ea&&!eP&&(()=>{let e=Q(R);return e?(0,n.jsx)(eY,{definition:e,nodeId:ea,palette:O,onChange:e=>F(X(e)),onClose:()=>el(null),onDelete:()=>{F(X(Y(e,ea))),el(null)}}):null})()]}):(0,n.jsx)("textarea",{value:R,onChange:e=>F(e.target.value),readOnly:eP,placeholder:"Select a workflow on the left or click + New to start",spellCheck:!1,className:"flex-1 resize-none border-0 bg-surface px-3 py-2 font-mono text-xs leading-snug focus:outline-none"}),eA.length>0&&(0,n.jsx)("ul",{className:"max-h-32 overflow-y-auto border-t border-border bg-surface-elevated px-3 py-2 text-[11px]",children:eA.slice(0,8).map((e,t)=>{var r,a;let l=eT&&null!=(a=eE&&(null==(r=Object.entries(eE).find(t=>{let[,r]=t;return r.includes(e)}))?void 0:r[0]))?a:null,s=!!l;return(0,n.jsxs)("li",{className:"flex items-start gap-1.5 text-error ".concat(s?"cursor-pointer hover:bg-surface":""),...s?{onClick:()=>{V("graph"),eo(e=>{var t;return{id:l,nonce:(null!=(t=null==e?void 0:e.nonce)?t:0)+1}})},role:"button",tabIndex:0}:{},title:s?'Jump to node "'.concat(l,'"'):void 0,children:[(0,n.jsx)(y.A,{className:"mt-0.5 h-3 w-3 shrink-0"}),(0,n.jsxs)("span",{children:[(0,n.jsx)("span",{className:"font-mono text-text-tertiary",children:e.path||"(root)"})," ",e.message]})]},t)})}),(0,n.jsxs)("footer",{className:"flex items-center justify-end gap-2 border-t border-border px-3 py-2",children:[K&&(0,n.jsx)("p",{role:"alert",className:"mr-auto text-[11px] text-error",children:K}),L&&!eP&&!G&&(0,n.jsxs)("button",{type:"button",onClick:eL,className:"flex items-center gap-1 rounded-md border border-error/40 px-2 py-1 text-[11px] text-error hover:bg-error/10",children:[(0,n.jsx)(v.A,{className:"h-3 w-3"}),"Delete"]}),(0,n.jsxs)("button",{type:"button",onClick:eO,disabled:!L&&!G||eP||ed.isPending,className:"flex items-center gap-1 rounded-md bg-primary px-3 py-1 text-[11px] font-medium text-primary-foreground hover:bg-accent-hover disabled:opacity-50",children:[ed.isPending?(0,n.jsx)(j.A,{className:"h-3 w-3 animate-spin"}):(0,n.jsx)(w.A,{className:"h-3 w-3"}),"Save"]})]})]})}),ez&&!eF.rightCollapsed&&(0,n.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize run panel",onPointerDown:e=>eG("right",{clientX:e.clientX,pointerId:e.pointerId,target:e.currentTarget}),className:"w-1 shrink-0 cursor-col-resize bg-transparent hover:bg-accent/30"}),ez&&(0,n.jsx)("aside",{style:{width:eW},className:"flex shrink-0 flex-col overflow-hidden border-l border-border",children:eF.rightCollapsed?(0,n.jsx)("button",{type:"button",onClick:eF.toggleRight,title:"Expand run panel",className:"flex h-full w-full items-center justify-center text-text-tertiary hover:bg-surface-elevated",children:(0,n.jsx)(m.A,{className:"h-4 w-4"})}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"border-b border-border px-3 py-2",children:[(0,n.jsx)("label",{className:"block text-[10px] uppercase tracking-wide text-text-tertiary",children:"Arguments"}),(0,n.jsx)("input",{type:"text",value:D,onChange:e=>z(e.target.value),placeholder:"passed as $ARGUMENTS",className:"w-full rounded-md border border-border bg-surface px-2 py-1 text-xs"}),(0,n.jsxs)("button",{type:"button",onClick:eI,disabled:!L||G||ep.isPending,className:"mt-2 flex w-full items-center justify-center gap-1 rounded-md bg-accent px-2 py-1.5 text-[11px] font-medium text-primary-foreground hover:bg-accent-hover disabled:opacity-50",children:[ep.isPending?(0,n.jsx)(j.A,{className:"h-3 w-3 animate-spin"}):(0,n.jsx)(k.A,{className:"h-3 w-3"}),"Run"]})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto px-3 py-2 text-[11px]",children:[!q&&(0,n.jsx)("p",{className:"text-text-tertiary",children:"No active run. Press Run to start."}),q&&ef.data&&(0,n.jsx)(ts,{runId:q,events:ef.data.events,ok:ef.data.ok,outputs:ef.data.outputs})]})]})})]}),ev&&!ew.has(ev.runId)&&(0,n.jsx)(e4,{runId:ev.runId,message:ev.message,onDismiss:()=>ek(e=>{let t=new Set(e);return t.add(ev.runId),t})})]})}function tn(e){let{label:t,entries:r,selected:a,onSelect:l}=e;return 0===r.length?null:(0,n.jsxs)("div",{className:"border-b border-border",children:[(0,n.jsx)("h2",{className:"px-3 py-1.5 text-[10px] font-medium uppercase tracking-wide text-text-tertiary",children:t}),(0,n.jsx)("ul",{children:r.map(e=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button",onClick:()=>l(e.name),className:["block w-full px-3 py-1.5 text-left text-xs transition-colors",a===e.name?"bg-accent/15 text-text-primary":"text-text-secondary hover:bg-surface-elevated"].join(" "),title:e.path,children:[(0,n.jsx)("div",{className:"font-medium",children:e.name}),(0,n.jsxs)("div",{className:"truncate text-[10px] text-text-tertiary",children:[e.nodeCount," node",1===e.nodeCount?"":"s"]})]})},e.path))})]})}function ta(e){let{mode:t,onChange:r}=e;return(0,n.jsxs)("div",{className:"flex items-center rounded-md border border-border text-[10px]",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>r("yaml"),className:"flex items-center gap-1 px-2 py-0.5 ".concat("yaml"===t?"bg-surface-elevated text-text-primary":"text-text-tertiary"),children:[(0,n.jsx)(N.A,{className:"h-3 w-3"}),"YAML"]}),(0,n.jsxs)("button",{type:"button",onClick:()=>r("graph"),className:"flex items-center gap-1 px-2 py-0.5 ".concat("graph"===t?"bg-surface-elevated text-text-primary":"text-text-tertiary"),children:[(0,n.jsx)(C.A,{className:"h-3 w-3"}),"Graph"]})]})}function tl(e){let{status:t}=e;return"pending"===t?(0,n.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-text-tertiary",children:[(0,n.jsx)(j.A,{className:"h-3 w-3 animate-spin"}),"validating"]}):"ok"===t?(0,n.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-success",children:[(0,n.jsx)(S.A,{className:"h-3 w-3"}),"valid"]}):"error"===t?(0,n.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-error",children:[(0,n.jsx)(y.A,{className:"h-3 w-3"}),"invalid"]}):null}function ts(e){let{runId:t,events:r,ok:a,outputs:l}=e;return(0,n.jsxs)("div",{className:"space-y-2 font-mono",children:[(0,n.jsxs)("div",{className:"text-[10px] text-text-tertiary",children:["runId: ",t]}),(0,n.jsx)("ul",{className:"space-y-1",children:r.map((e,t)=>{var r,a;return(0,n.jsxs)("li",{className:"flex items-start gap-1.5",children:[(0,n.jsx)("span",{className:"mt-0.5 h-1.5 w-1.5 rounded-full bg-text-tertiary"}),(0,n.jsxs)("span",{className:"break-all",children:[(0,n.jsx)("span",{className:"text-text-tertiary",children:e.type}),e.nodeId&&(0,n.jsx)("span",{className:"ml-1",children:e.nodeId}),e.reason&&(0,n.jsxs)("span",{className:"ml-1 text-text-tertiary",children:["— ",e.reason]}),e.error&&(0,n.jsxs)("span",{className:"ml-1 text-error",children:["— ",e.error]}),(null==(r=e.result)?void 0:r.ok)===!1&&(0,n.jsxs)("span",{className:"ml-1 text-error",children:["— ",null!=(a=e.result.error)?a:"failed"]})]})]},t)})}),!0===a&&(0,n.jsxs)("div",{className:"rounded-md bg-success/10 px-2 py-1 text-[10px] text-success",children:["completed \xb7 ",Object.keys(l).length," node output",1===Object.keys(l).length?"":"s"]}),!1===a&&(0,n.jsx)("div",{className:"rounded-md bg-error/10 px-2 py-1 text-[10px] text-error",children:"failed"}),Object.keys(l).length>0&&(0,n.jsx)(to,{outputs:l})]})}function to(e){let{outputs:t}=e;return(0,n.jsxs)("details",{className:"mt-2 rounded-md border border-border bg-surface-elevated",children:[(0,n.jsxs)("summary",{className:"cursor-pointer select-none px-2 py-1 text-[10px] font-semibold text-text-tertiary",children:["Outputs (",Object.keys(t).length,")"]}),(0,n.jsx)("ul",{className:"space-y-1 px-2 pb-2 pt-1 font-mono text-[10px]",children:Object.entries(t).map(e=>{let[t,r]=e;return(0,n.jsxs)("li",{className:"rounded bg-surface px-2 py-1",children:[(0,n.jsx)("div",{className:"text-[9px] uppercase tracking-wide text-text-tertiary",children:t}),(0,n.jsx)("pre",{className:"mt-0.5 max-h-40 overflow-auto whitespace-pre-wrap break-all",children:function(e){if(null==e)return"(no output)";if("string"==typeof e)return e.length>4096?"".concat(e.slice(0,4096),"\n…(truncated \xb7 ").concat(e.length," chars)"):e;try{let t=JSON.stringify(e,null,2);return t.length>4096?"".concat(t.slice(0,4096),"\n…(truncated \xb7 ").concat(t.length," chars)"):t}catch(t){return String(e)}}(r)})]},t)})})]})}var ti=r(24818),td=r(6015),tc=r(42375);let tu=["agent","gate","git","judge","observe","hitl","subgraph"],tp=["prompt","bash","skill","cft","approval","if","switch","iteration","classify","extract","set","filter","template","http","showroom","task","scheduleTrigger","webhookTrigger","discordTrigger","telegramTrigger","manualTrigger","chatTrigger"];function th(e){return(0,K.jh)(e.contents)?e.contents:null}function tm(e){return(0,K.jn)(e)?e:null}function tx(e){let t=tm(e);return t&&("string"==typeof t.value||"number"==typeof t.value)?String(t.value):void 0}function tf(e,t){return e.items.find(e=>tx(e.key)===t)}function tg(e,t){var r;let n=null==(r=tf(e,t))?void 0:r.value;return(0,K.oP)(n)?n:null}function tb(e){return(0,K.jh)(e)?e:null}function ty(e,t){var r;let n=tm(null==(r=tf(e,t))?void 0:r.value);return n&&("string"==typeof n.value||"number"==typeof n.value)?String(n.value):void 0}function tv(e,t){return(function(e){let t=th(e);if(!t)return[];let r=tg(t,"nodes");return r?r.items.flatMap(e=>{let t=tb(e);return t?[t]:[]}):[]})(e).find(e=>ty(e,"node_id")===t)}function tj(e,t,r){var n;let a=tm(null==(n=tf(e,t))?void 0:n.value);if(a){a.value=r;return}e.set(t,r)}function tw(e){let t=(0,K.Tp)(e,{keepSourceTokens:!0});return t.src=e,t.removed=[],t}function tk(e){var t;return null!=(t=e.removed)?t:[]}function tN(e){let t=th(e),r=t?tg(t,"edges"):null;return r?r.items.flatMap(e=>{let t=tb(e);return t?[t]:[]}):[]}function tC(e,t){return(null==e?void 0:e.range)?e.range[1]:t}function tS(e){var t;let r=null!=(t=e.src)?t:"";if(!r)return e.toString();let n=[],a=t=>{if((0,K.oP)(t))return void t.items.forEach((e,l)=>{if((0,K.jh)(e)&&!e.range){var s,o;let a=tC(l>0?t.items[l-1]:null,tC(t,r.length)),i=e.items.map(e=>{var t;let r=e.key instanceof K.CA||e.key instanceof K.Rw?"":String(null!=(t=e.key.value)?t:e.key),n=e.value,a=n&&"object"==typeof n&&"value"in n?String(n.value):String(e.value);return" ".concat(r,": ").concat(a)}),d=null!=(o=null==(s=i[0])?void 0:s.slice(2))?o:"";n.push({start:a,end:a,text:"\n- ".concat(d).concat(i.length>1?"\n".concat(i.slice(1).join("\n")):"")})}else a(e)});if((0,K.jh)(t))for(let l of t.items){let s=tx(l.key);if((0,K.jh)(l.value)||(0,K.oP)(l.value)){if(!l.value.range&&t.range&&s){let e=t.range[1],r=(0,K.jh)(l.value)?"".concat(s,":\n").concat(l.value.toString().replace(/\n$/,"").split("\n").map(e=>" ".concat(e)).join("\n")):"".concat(s,": ").concat(l.value.toString().trim());n.push({start:e,end:e,text:"\n".concat(r)})}else a(l.value);continue}let o=tm(l.value);if(!s||!o)continue;if(!o.range&&t.range){let e=t.range[1];n.push({start:e,end:e,text:"\n".concat(s,": ").concat(o.toString())});continue}if(!o.range)continue;let i=r.slice(o.range[0],o.range[1]),d=e.createNode(o.value).toString();i!==d&&n.push({start:o.range[0],end:o.range[1],text:d})}};for(let[t,r]of(a(e.contents),tk(e)))n.push({start:t,end:r,text:""});tk(e).length=0;let l=r;for(let e of n.sort((e,t)=>t.start-e.start||t.end-e.end))l="".concat(l.slice(0,e.start)).concat(e.text).concat(l.slice(e.end));return l}let tA={agent:"#3b82f6",gate:"#f59e0b",git:"#10b981",judge:"#a855f7",observe:"#06b6d4",hitl:"#f43f5e",subgraph:"#8b5cf6"},tT={run:function(e){var t;let{data:r}=e;return(0,n.jsxs)("div",{className:"min-w-[190px] rounded-lg border border-border bg-surface px-3 py-2 shadow-sm",style:{borderLeft:"4px solid ".concat(null!=(t=tA[r.kind])?t:"#64748b"),height:r.height},children:[r.inputHandles.map((e,t)=>(0,n.jsx)(T.h7,{id:e,type:"target",position:E.yX.Left,className:"!pointer-events-none",style:{top:"".concat((t+1)/(r.inputHandles.length+1)*100,"%")}},e)),(0,n.jsxs)("div",{className:"flex items-center gap-1 text-[10px] text-text-tertiary",children:[(0,n.jsx)("span",{children:r.kind}),r.entry&&(0,n.jsx)("span",{className:"rounded bg-success/15 px-1 text-success",children:"entry"}),r.terminal&&(0,n.jsx)("span",{className:"rounded bg-accent/15 px-1 text-accent",children:"terminal"})]}),(0,n.jsx)("div",{className:"font-mono text-xs font-semibold text-text-primary",children:r.label}),(0,n.jsxs)("div",{className:"max-w-[170px] truncate text-[10px] text-text-tertiary",title:r.recipe,children:[r.recipe," \xb7 max ",r.maxVisits]}),r.outcomes.length>0&&(0,n.jsx)("div",{className:"max-w-[170px] truncate text-[10px] text-text-tertiary",title:r.outcomes.join(" \xb7 "),children:r.outcomes.join(" \xb7 ")}),r.outputHandles.map((e,t)=>(0,n.jsx)(T.h7,{id:e,type:"source",position:E.yX.Right,className:"!pointer-events-none",style:{top:"".concat((t+1)/(r.outputHandles.length+1)*100,"%")}},e))]})}},tE={labelStyle:{fill:"var(--text-primary, #334155)",fontSize:12},labelBgStyle:{fill:"var(--surface, #fff)"}};function tM(e){if(e instanceof tc.Iu){var t;let r=e.body;return(null==r||null==(t=r.errors)?void 0:t.map(e=>e.message).filter(Boolean).join(" \xb7 "))||(null==r?void 0:r.reason)||"저장 검증 실패 (".concat(e.status,")")}return e instanceof Error?e.message:"저장에 실패했습니다."}function t_(){var e,t,r,s,i,d,c,u,p,h,m,x;let{palette:f}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},g=(0,o.M1)(),b=(0,ti.jE)(),[y,v]=(0,a.useState)(null),[j,w]=(0,a.useState)(null),[k,N]=(0,a.useState)(null),[C,S]=(0,a.useState)("note"),[A,E]=(0,a.useState)(tu[0]),[_,O]=(0,a.useState)("read-only"),[I,L]=(0,a.useState)(""),[P,R]=(0,a.useState)("pass"),[F,D]=(0,a.useState)(""),[z,q]=(0,a.useState)(null),[W,G]=(0,a.useState)([]),[B,H]=(0,a.useState)(null),$=(0,l.I)({queryKey:["run-graphs"],queryFn:()=>g.getRunGraphs()}),U=(0,l.I)({queryKey:["graph-kinds","harness"],queryFn:()=>g.getGraphKinds("harness"),enabled:!f,retry:!1}),J=null!=(h=null!=f?f:(null==(e=U.data)?void 0:e.kinds.length)?U.data.kinds:null)?h:tu.map(e=>({graph:"harness",kind:e,plugin:null,description:"",schema:{},core:!0})),Y=J.some(e=>e.kind===A)?A:null!=(m=null==(t=J[0])?void 0:t.kind)?m:A,V=null!=(x=null!=y?y:null==(s=$.data)||null==(r=s.graphs[0])?void 0:r.id)?x:null,X=null==(i=$.data)?void 0:i.graphs.find(e=>e.id===V),Q=(0,l.I)({queryKey:["run-graph",V],queryFn:()=>g.getRunGraph(V),enabled:null!==V}),Z=(null==X?void 0:X.editable)===!0&&"mine"===X.source&&(null==(d=Q.data)?void 0:d.id)===V&&"mine"===Q.data.source&&!0===Q.data.editable,ee=(0,l.I)({queryKey:["run-graph-yaml",Z?V:null],queryFn:()=>g.getRunGraphYaml(V),enabled:Z&&null!==V}),et=Z?j===V?k:(null==(c=ee.data)?void 0:c.id)===V&&"mine"===ee.data.source&&ee.data.editable?ee.data.yaml:null:null,er=(0,a.useMemo)(()=>Q.data&&Q.data.id===V?function(e){let t=e.edges.flatMap((e,t)=>e.map?Object.entries(e.map).map(r=>{let[n,a]=r;return{id:"".concat(t,":").concat(e.from,":").concat(n),source:e.from,target:a,label:n,data:{on:e.on},type:"straight"}}):e.to?[{id:"".concat(t,":").concat(e.from,":").concat(e.to),source:e.from,target:e.to,type:"smoothstep"}]:[]);for(let r of e.nodes){let e=t.filter(e=>e.source===r.node_id),n=t.filter(e=>e.target===r.node_id);e.forEach((e,t)=>{e.sourceHandle="out-".concat(t)}),n.forEach((e,t)=>{e.targetHandle="in-".concat(t)})}let r=new M.Ay.graphlib.Graph;for(let n of(r.setDefaultEdgeLabel(()=>({})),r.setGraph({rankdir:"LR",ranksep:110,nodesep:55,marginx:25,marginy:25}),e.nodes)){let e=Math.max(1,t.filter(e=>e.source===n.node_id).length,t.filter(e=>e.target===n.node_id).length);r.setNode(n.node_id,{width:190,height:Math.max(90,(e+1)*26)})}for(let e of t)r.setEdge(e.source,e.target);M.Ay.layout(r);let n=new Set(e.terminal_nodes);return{nodes:e.nodes.map(a=>{let l=r.node(a.node_id),s=t.filter(e=>e.source===a.node_id),o=t.filter(e=>e.target===a.node_id);return{id:a.node_id,position:{x:l.x-95,y:l.y-l.height/2},data:{label:a.node_id,kind:a.kind,recipe:a.recipe,maxVisits:a.max_visits,entry:e.entry_node===a.node_id,terminal:n.has(a.node_id),outcomes:s.filter(e=>"string"==typeof e.label).map(e=>e.label),inputHandles:o.map(e=>e.targetHandle),outputHandles:s.map(e=>e.sourceHandle),height:l.height}}}),edges:t}}(Q.data):null,[Q.data,V]),en=(0,a.useMemo)(()=>{var e;return null!=(e=null==er?void 0:er.nodes.map(e=>({...e,type:"run"})))?e:[]},[er]);function ea(e){if(Z&&V&&null!==et&&!es.isPending)try{let t=e(et);w(V),N(t),q(null),G([]),H(null)}catch(e){q(tM(e))}}let el=(0,td.n)({mutationFn:()=>g.cloneRunGraph(V,"".concat(V,"-mine")),onSuccess:async e=>{w(null),N(null),q(null),H(null),G([]),await b.invalidateQueries({queryKey:["run-graphs"]}),v(e.id)}}),es=(0,td.n)({mutationFn:async e=>{let{savingId:t,savingYaml:r}=e,n=await g.validateGraph("harness",r);return(G(n.ignoredKeys),!n.ok||n.errors.length>0)?void H(n.errors.map(e=>e.message).join(" \xb7 ")||"그래프 검증에 실패했습니다."):(H(null),g.putRunGraphYaml(t,r))},onSuccess:async e=>{e&&(q(null),w(null),await b.invalidateQueries({queryKey:["run-graph",e.id]}),await b.invalidateQueries({queryKey:["run-graph-yaml",e.id]}))},onError:e=>q(tM(e))});return(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[(0,n.jsxs)("aside",{className:"w-56 shrink-0 overflow-y-auto border-r border-border","aria-label":"실행 그래프 목록",children:[(0,n.jsx)("h2",{className:"px-3 py-3 text-xs font-semibold",children:"실행 그래프"}),$.isLoading&&(0,n.jsx)("p",{className:"px-3 text-xs text-text-tertiary",children:"불러오는 중…"}),$.isError&&(0,n.jsx)("p",{role:"alert",className:"px-3 text-xs text-error",children:"그래프 목록을 불러오지 못했습니다."}),(null==(u=$.data)?void 0:u.graphs.length)===0&&(0,n.jsx)("p",{className:"px-3 text-xs text-text-tertiary",children:"그래프가 없습니다."}),(0,n.jsx)("ul",{children:null==(p=$.data)?void 0:p.graphs.map(e=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button",onClick:()=>{v(e.id),q(null),H(null),G([])},disabled:es.isPending||el.isPending,"aria-current":V===e.id?"true":void 0,className:"w-full px-3 py-2 text-left text-xs hover:bg-surface-elevated ".concat(V===e.id?"bg-accent/15 text-text-primary":"text-text-secondary"),children:[(0,n.jsx)("span",{className:"block font-mono",children:e.id}),(0,n.jsxs)("span",{className:"text-[10px] text-text-tertiary",children:[e.nodeCount," nodes \xb7 ","mine"===e.source?"내 그래프":"core"," \xb7 ",e.editable?"편집":"읽기 전용"]})]})},e.id))})]}),(0,n.jsxs)("section",{className:"relative flex min-w-0 flex-1 flex-col bg-surface","aria-label":"실행 그래프 캔버스",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2",children:[X&&!X.editable&&(0,n.jsx)("button",{type:"button",onClick:()=>el.mutate(),disabled:el.isPending,className:"rounded border border-border px-2 py-1 text-xs",children:"복제해서 고치기"}),Z&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("label",{className:"text-[10px] text-text-tertiary",children:["kind",(0,n.jsx)("select",{"aria-label":"노드 kind",value:Y,onChange:e=>E(e.target.value),className:"ml-1 text-xs",children:J.map(e=>{var t;return(0,n.jsxs)("option",{value:e.kind,children:[e.kind,e.plugin?" \xb7 ".concat(e.plugin):""]},"".concat(null!=(t=e.plugin)?t:"core",":").concat(e.kind))})})]}),(0,n.jsx)("input",{"aria-label":"노드 id",value:C,onChange:e=>S(e.target.value),className:"w-24 rounded border border-border px-1 text-xs"}),(0,n.jsx)("input",{"aria-label":"recipe",value:_,onChange:e=>O(e.target.value),className:"w-28 rounded border border-border px-1 text-xs"}),(0,n.jsx)("button",{type:"button",className:"rounded border border-border px-2 py-1 text-xs",onClick:()=>ea(e=>{let t=tw(e);return!function(e,t){var r;let n=th(e);if(!n)throw Error("graph yaml root is not a map");let a=tg(n,"nodes");if(a||(n.set("nodes",[]),a=tg(n,"nodes")),!a)throw Error("nodes is not a sequence");if(tv(e,t.nodeId))throw Error("node already exists: ".concat(t.nodeId));let l=new K.CA;l.set("node_id",t.nodeId),l.set("kind",t.kind),l.set("recipe",t.recipe),l.set("max_visits",null!=(r=t.maxVisits)?r:1),a.add(l)}(t,{nodeId:C,kind:Y,recipe:_}),tS(t)}),children:"노드 추가"}),(0,n.jsx)("button",{type:"button",className:"rounded border border-border px-2 py-1 text-xs",onClick:()=>ea(e=>{let t=tw(e);return!function(e,t){let r=th(e),n=r?tg(r,"nodes"):null;if(!n)return;let a=n.items.findIndex(e=>{let r=tb(e);return!!r&&ty(r,"node_id")===t});a>=0&&(function(e,t){var r;let n=null==t?void 0:t.range;n&&tk(e).push([n[0],null!=(r=n[2])?r:n[1]])}(e,n.items[a]),n.delete(a))}(t,C),tS(t)}),children:"노드 삭제"}),(0,n.jsx)("button",{type:"button",className:"rounded border border-border px-2 py-1 text-xs",onClick:()=>ea(e=>{let t=tw(e),r=tv(t,C);if(!r)throw Error("node not found: ".concat(C));tj(r,"kind",Y);let n=tv(t,C);if(!n)throw Error("node not found: ".concat(C));return tj(n,"recipe",_),tS(t)}),children:"kind/recipe"}),(0,n.jsx)("input",{"aria-label":"간선 from",value:I,onChange:e=>L(e.target.value),placeholder:"from",className:"w-20 rounded border border-border px-1 text-xs"}),(0,n.jsx)("input",{"aria-label":"간선 결과",value:P,onChange:e=>R(e.target.value),placeholder:"결과",className:"w-16 rounded border border-border px-1 text-xs"}),(0,n.jsx)("input",{"aria-label":"간선 to",value:F,onChange:e=>D(e.target.value),placeholder:"to",className:"w-20 rounded border border-border px-1 text-xs"}),(0,n.jsx)("button",{type:"button",className:"rounded border border-border px-2 py-1 text-xs",onClick:()=>ea(e=>{let t=tw(e);return!function(e,t){let r=th(e);if(!r)throw Error("graph yaml root is not a map");let n=tg(r,"edges");if(n||(r.set("edges",[]),n=tg(r,"edges")),!n)throw Error("edges is not a sequence");let a=tN(e).find(e=>ty(e,"from")===t.from&&tf(e,"map"));a||((a=new K.CA).set("from",t.from),n.add(a)),(function(e){var t;let r=null==(t=tf(e,"map"))?void 0:t.value;if((0,K.jh)(r))return r;let n=new K.CA;return e.set("map",n),n})(a).set(t.outcome,t.to)}(t,{from:I,outcome:P,to:F}),tS(t)}),children:"간선 추가"}),(0,n.jsx)("button",{type:"button",className:"rounded border border-border px-2 py-1 text-xs",onClick:()=>ea(e=>{let t=tw(e);return!function(e,t,r){for(let c of tN(e)){var n,a,l,s,o,i,d;if(ty(c,"from")!==t)continue;let u=null==(n=tf(c,"map"))?void 0:n.value;if(!(0,K.jh)(u))continue;let p=u.items.findIndex(e=>tx(e.key)===r);if(p>=0){let t=u.items[p],r=null!=(i=null==(a=t.key.range)?void 0:a[0])?i:null==(l=t.value.range)?void 0:l[0],n=null!=(d=null==(s=t.value.range)?void 0:s[2])?d:null==(o=t.value.range)?void 0:o[1];void 0!==r&&void 0!==n&&tk(e).push([r,n]),u.delete(p)}}}(t,I,P),tS(t)}),children:"간선 삭제"}),(0,n.jsx)("button",{type:"button",onClick:()=>{Z&&V&&null!==et&&es.mutate({savingId:V,savingYaml:et})},disabled:null===et||es.isPending,className:"rounded bg-accent px-2 py-1 text-xs text-white",children:"저장"})]})]}),!f&&U.isError&&(0,n.jsx)("p",{role:"status",className:"px-3 py-1 text-xs text-warning",children:"어휘 목록을 불러오지 못해 코어 팔레트를 표시합니다."}),(B||z)&&(0,n.jsx)("p",{role:"alert",className:"px-3 py-1 text-xs text-error",children:B||z}),W.length>0&&(0,n.jsxs)("p",{role:"status",className:"px-3 py-1 text-xs text-warning",children:["무시되는 키: ",W.join(" \xb7 ")]}),el.isError&&(0,n.jsx)("p",{role:"alert",className:"px-3 py-1 text-xs text-error",children:tM(el.error)}),Q.isError&&(0,n.jsx)("p",{role:"alert",className:"p-4 text-xs text-error",children:"그래프를 불러오지 못했습니다."}),Q.isLoading&&(0,n.jsx)("p",{className:"p-4 text-xs text-text-tertiary",children:"불러오는 중…"}),er&&(0,n.jsxs)(T.Gc,{nodes:en,edges:er.edges,nodeTypes:tT,fitView:!0,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:Z,edgesReconnectable:!1,deleteKeyCode:null,nodesFocusable:Z,edgesFocusable:!1,defaultEdgeOptions:tE,className:"!bg-surface",children:[(0,n.jsx)(T.VS,{}),(0,n.jsx)(T.H2,{showInteractive:!1})]},null!=V?V:"")]})]})}function tO(){let e="harness"===(0,s.useSearchParams)().get("mode")?"harness":"workflow",t=(0,o.Qj)(),r=(0,l.I)({queryKey:["graph-kinds",e],queryFn:()=>t.getGraphKinds(e),enabled:null!==t,retry:!1}),i=(0,a.useMemo)(()=>{var t;return(null==(t=r.data)?void 0:t.kinds.length)?r.data.kinds:("harness"===e?tu:tp).map(t=>({graph:e,kind:t,plugin:null,description:"",schema:{},core:!0}))},[r.data,e]),d=r.isError||r.isSuccess&&!r.data.kinds.length;return(0,n.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,n.jsxs)("header",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-border px-4 py-2",children:[(0,n.jsx)("h1",{className:"text-sm font-semibold",children:"편집기"}),(0,n.jsx)("nav",{"aria-label":"그래프 편집 모드",className:"flex gap-1",children:["workflow","harness"].map(t=>(0,n.jsx)("a",{href:"/app/editor/?mode=".concat(t),"aria-current":e===t?"page":void 0,className:"rounded px-3 py-1 text-xs ".concat(e===t?"bg-accent/15 text-text-primary":"text-text-tertiary hover:bg-surface-elevated"),children:"workflow"===t?"워크플로":"실행 그래프"},t))})]}),(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[t&&(0,n.jsxs)("div",{className:"border-b border-border px-3 py-2 text-xs","aria-label":"노드 팔레트",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsx)("strong",{children:"노드 팔레트"}),i.map(e=>{var t;return(0,n.jsxs)("span",{title:e.description,className:"rounded border border-border px-2 py-0.5",children:[e.kind," ",e.plugin&&(0,n.jsx)("small",{className:"rounded bg-accent/15 px-1 text-accent",children:e.plugin})]},"".concat(null!=(t=e.plugin)?t:"core",":").concat(e.kind))})]}),d&&(0,n.jsx)("p",{role:"status",className:"mt-1 text-warning",children:"어휘 목록을 불러오지 못해 코어 팔레트를 표시합니다."})]}),"workflow"===e?(0,n.jsx)(te,{palette:i}):t?(0,n.jsx)(t_,{palette:i}):(0,n.jsx)("p",{className:"p-4 text-sm text-text-tertiary",children:"Daemon 연결이 설정되지 않았습니다. Settings 에서 Base URL 을 입력하세요."})]})]})}function tI(){return(0,n.jsx)(a.Suspense,{fallback:(0,n.jsx)("p",{className:"p-4 text-sm",children:"편집기를 불러오는 중…"}),children:(0,n.jsx)(tO,{})})}},88512:(e,t,r)=>{Promise.resolve().then(r.bind(r,87398))},91514:(e,t,r)=>{"use strict";r.d(t,{M1:()=>d,Qj:()=>c,tI:()=>i});var n=r(41121),a=r(91269),l=r(19855),s=r(24818);let o=(0,a.createContext)(null);function i(e){let{client:t,queryClient:r,defaultStaleTimeMs:i,children:d}=e,c=(0,a.useMemo)(()=>null!=r?r:new l.E({defaultOptions:{queries:{staleTime:null!=i?i:2e3,refetchOnWindowFocus:!1}}}),[r,i]);return(0,n.jsx)(o.Provider,{value:t,children:(0,n.jsx)(s.Ht,{client:c,children:d})})}function d(){let e=(0,a.useContext)(o);if(!e)throw Error("useNexusClient must be used within <NexusProvider>");return e}function c(){return(0,a.useContext)(o)}},91644:(e,t,r)=>{"use strict";r.d(t,{Qb:()=>s,SI:()=>i,dJ:()=>o});let n="elanous:auth-required",a=null,l=!1;function s(e){null===a&&(a=e,window.dispatchEvent(new CustomEvent(n,{detail:{path:e}})))}function o(e){let t=window,r=t=>e(t.detail);return t.addEventListener(n,r),null===a||l||e({path:a}),()=>t.removeEventListener(n,r)}function i(){l=!0}}},e=>{e.O(0,[9668,6987,920,6998,5609,2982,2375,5791,2367,6725,7358],()=>e(e.s=88512)),_N_E=e.O()}]);