sparkecoder 0.1.44 → 0.1.46

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 (184) hide show
  1. package/README.md +1 -1
  2. package/dist/agent/index.d.ts +2 -2
  3. package/dist/agent/index.js +153 -4
  4. package/dist/agent/index.js.map +1 -1
  5. package/dist/cli.js +209 -22
  6. package/dist/cli.js.map +1 -1
  7. package/dist/db/index.js +11 -3
  8. package/dist/db/index.js.map +1 -1
  9. package/dist/{index-D2eLXP9V.d.ts → index-DJ5qNs1Z.d.ts} +9 -5
  10. package/dist/index.d.ts +3 -3
  11. package/dist/index.js +210 -21
  12. package/dist/index.js.map +1 -1
  13. package/dist/{search-D3Wtf7TJ.d.ts → search-BOYIUmDp.d.ts} +1 -1
  14. package/dist/server/index.js +208 -21
  15. package/dist/server/index.js.map +1 -1
  16. package/dist/tools/index.d.ts +2 -2
  17. package/dist/tools/index.js +11 -3
  18. package/dist/tools/index.js.map +1 -1
  19. package/package.json +1 -1
  20. package/web/.next/BUILD_ID +1 -1
  21. package/web/.next/standalone/web/.next/BUILD_ID +1 -1
  22. package/web/.next/standalone/web/.next/build-manifest.json +2 -2
  23. package/web/.next/standalone/web/.next/prerender-manifest.json +3 -3
  24. package/web/.next/standalone/web/.next/server/app/(main)/page.js.nft.json +1 -1
  25. package/web/.next/standalone/web/.next/server/app/(main)/page_client-reference-manifest.js +1 -1
  26. package/web/.next/standalone/web/.next/server/app/(main)/session/[id]/page.js.nft.json +1 -1
  27. package/web/.next/standalone/web/.next/server/app/(main)/session/[id]/page_client-reference-manifest.js +1 -1
  28. package/web/.next/standalone/web/.next/server/app/_global-error.html +2 -2
  29. package/web/.next/standalone/web/.next/server/app/_global-error.rsc +1 -1
  30. package/web/.next/standalone/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  31. package/web/.next/standalone/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  32. package/web/.next/standalone/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  33. package/web/.next/standalone/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  34. package/web/.next/standalone/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  35. package/web/.next/standalone/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  36. package/web/.next/standalone/web/.next/server/app/_not-found.html +1 -1
  37. package/web/.next/standalone/web/.next/server/app/_not-found.rsc +3 -3
  38. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  39. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  40. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
  41. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  42. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  43. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  44. package/web/.next/standalone/web/.next/server/app/docs/installation/page_client-reference-manifest.js +1 -1
  45. package/web/.next/standalone/web/.next/server/app/docs/installation.html +2 -2
  46. package/web/.next/standalone/web/.next/server/app/docs/installation.rsc +4 -4
  47. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_full.segment.rsc +4 -4
  48. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_head.segment.rsc +1 -1
  49. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_index.segment.rsc +3 -3
  50. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_tree.segment.rsc +2 -2
  51. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/docs/installation/__PAGE__.segment.rsc +2 -2
  52. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/docs/installation.segment.rsc +1 -1
  53. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/docs.segment.rsc +2 -2
  54. package/web/.next/standalone/web/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  55. package/web/.next/standalone/web/.next/server/app/docs/skills/page_client-reference-manifest.js +1 -1
  56. package/web/.next/standalone/web/.next/server/app/docs/skills.html +2 -2
  57. package/web/.next/standalone/web/.next/server/app/docs/skills.rsc +4 -4
  58. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_full.segment.rsc +4 -4
  59. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_head.segment.rsc +1 -1
  60. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_index.segment.rsc +3 -3
  61. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_tree.segment.rsc +2 -2
  62. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/docs/skills/__PAGE__.segment.rsc +1 -1
  63. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/docs/skills.segment.rsc +1 -1
  64. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/docs.segment.rsc +2 -2
  65. package/web/.next/standalone/web/.next/server/app/docs/tools/page_client-reference-manifest.js +1 -1
  66. package/web/.next/standalone/web/.next/server/app/docs/tools.html +2 -2
  67. package/web/.next/standalone/web/.next/server/app/docs/tools.rsc +4 -4
  68. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_full.segment.rsc +4 -4
  69. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_head.segment.rsc +1 -1
  70. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_index.segment.rsc +3 -3
  71. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_tree.segment.rsc +2 -2
  72. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/docs/tools/__PAGE__.segment.rsc +2 -2
  73. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/docs/tools.segment.rsc +1 -1
  74. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/docs.segment.rsc +2 -2
  75. package/web/.next/standalone/web/.next/server/app/docs.html +2 -2
  76. package/web/.next/standalone/web/.next/server/app/docs.rsc +4 -4
  77. package/web/.next/standalone/web/.next/server/app/docs.segments/_full.segment.rsc +4 -4
  78. package/web/.next/standalone/web/.next/server/app/docs.segments/_head.segment.rsc +1 -1
  79. package/web/.next/standalone/web/.next/server/app/docs.segments/_index.segment.rsc +3 -3
  80. package/web/.next/standalone/web/.next/server/app/docs.segments/_tree.segment.rsc +2 -2
  81. package/web/.next/standalone/web/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +2 -2
  82. package/web/.next/standalone/web/.next/server/app/docs.segments/docs.segment.rsc +2 -2
  83. package/web/.next/standalone/web/.next/server/app/embed/[id]/page.js.nft.json +1 -1
  84. package/web/.next/standalone/web/.next/server/app/embed/[id]/page_client-reference-manifest.js +1 -1
  85. package/web/.next/standalone/web/.next/server/app/index.html +1 -1
  86. package/web/.next/standalone/web/.next/server/app/index.rsc +5 -5
  87. package/web/.next/standalone/web/.next/server/app/index.segments/!KG1haW4p/__PAGE__.segment.rsc +2 -2
  88. package/web/.next/standalone/web/.next/server/app/index.segments/!KG1haW4p.segment.rsc +2 -2
  89. package/web/.next/standalone/web/.next/server/app/index.segments/_full.segment.rsc +5 -5
  90. package/web/.next/standalone/web/.next/server/app/index.segments/_head.segment.rsc +1 -1
  91. package/web/.next/standalone/web/.next/server/app/index.segments/_index.segment.rsc +3 -3
  92. package/web/.next/standalone/web/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  93. package/web/.next/standalone/web/.next/server/chunks/[root-of-the-server]__36edac7c._.js +1 -1
  94. package/web/.next/standalone/web/.next/server/chunks/ssr/{2374f_85c176b8._.js → 2374f_13da7b2a._.js} +1 -1
  95. package/web/.next/standalone/web/.next/server/chunks/ssr/{2374f_3eca1553._.js → 2374f_1de2f628._.js} +1 -1
  96. package/web/.next/standalone/web/.next/server/chunks/ssr/{2374f_8b8baaa3._.js → 2374f_2bfcd3a2._.js} +1 -1
  97. package/web/.next/standalone/web/.next/server/chunks/ssr/{2374f_0146c9df._.js → 2374f_40c1da73._.js} +1 -1
  98. package/web/.next/standalone/web/.next/server/chunks/ssr/{2374f_b30bed04._.js → 2374f_41d07cce._.js} +1 -1
  99. package/web/.next/standalone/web/.next/server/chunks/ssr/{2374f_4d1accac._.js → 2374f_6d8e5e94._.js} +1 -1
  100. package/web/.next/standalone/web/.next/server/chunks/ssr/{2374f_c99180da._.js → 2374f_88aa1671._.js} +1 -1
  101. package/web/.next/standalone/web/.next/server/chunks/ssr/{2374f_147b1db0._.js → 2374f_9f2fae06._.js} +1 -1
  102. package/web/.next/standalone/web/.next/server/chunks/ssr/{2374f_98432ce4._.js → 2374f_ac79ddf4._.js} +1 -1
  103. package/web/.next/standalone/web/.next/server/chunks/ssr/{2374f_36dd81aa._.js → 2374f_c8f8a326._.js} +1 -1
  104. package/web/.next/standalone/web/.next/server/chunks/ssr/{2374f_bcffd98c._.js → 2374f_dd21a4e9._.js} +1 -1
  105. package/web/.next/standalone/web/.next/server/chunks/ssr/{2374f_dde5cdd9._.js → 2374f_e5142825._.js} +1 -1
  106. package/web/.next/standalone/web/.next/server/chunks/ssr/{2374f_4b3676c4._.js → 2374f_ec658806._.js} +1 -1
  107. package/web/.next/standalone/web/.next/server/chunks/ssr/{2374f_f5998fca._.js → 2374f_f3c65774._.js} +1 -1
  108. package/web/.next/standalone/web/.next/server/chunks/ssr/[root-of-the-server]__43405ad6._.js +3 -0
  109. package/web/.next/standalone/web/.next/server/chunks/ssr/{[root-of-the-server]__adf39cf8._.js → [root-of-the-server]__a87e1c27._.js} +6 -4
  110. package/web/.next/standalone/web/.next/server/chunks/ssr/[root-of-the-server]__be5e2967._.js +1 -1
  111. package/web/.next/standalone/web/.next/server/chunks/ssr/[root-of-the-server]__de76483d._.js +1 -1
  112. package/web/.next/standalone/web/.next/server/chunks/ssr/{web_76f53fe7._.js → web_273500a6._.js} +2 -2
  113. package/web/.next/standalone/web/.next/server/chunks/ssr/{web_76ccf09f._.js → web_2b3a5919._.js} +2 -2
  114. package/web/.next/standalone/web/.next/server/chunks/ssr/{web_633d8a33._.js → web_329773d1._.js} +2 -2
  115. package/web/.next/standalone/web/.next/server/chunks/ssr/{web_248fc1f2._.js → web_38156da8._.js} +2 -2
  116. package/web/.next/standalone/web/.next/server/chunks/ssr/web_8305f089._.js +7 -0
  117. package/web/.next/standalone/web/.next/server/chunks/ssr/web_src_app_(main)_page_tsx_5ac4794b._.js +1 -1
  118. package/web/.next/standalone/web/.next/server/chunks/ssr/web_src_components_sessions-sidebar_tsx_92510070._.js +1 -1
  119. package/web/.next/standalone/web/.next/server/pages/404.html +1 -1
  120. package/web/.next/standalone/web/.next/server/pages/500.html +2 -2
  121. package/web/.next/standalone/web/.next/server/server-reference-manifest.js +1 -1
  122. package/web/.next/standalone/web/.next/server/server-reference-manifest.json +1 -1
  123. package/web/.next/standalone/web/.next/static/{static/chunks/194b3ed8e8d9c0e9.js → chunks/294ebe8457006bce.js} +3 -3
  124. package/web/.next/standalone/web/.next/static/chunks/{23aa98f6e3d7e0e4.js → 7e48d04fbd6dd7a6.js} +5 -3
  125. package/web/.next/standalone/web/.next/static/{static/chunks/1e9fdac31c7fd474.js → chunks/81685e5e8be4eac9.js} +3 -3
  126. package/web/.next/{static/chunks/3425251cd978da61.js → standalone/web/.next/static/chunks/8d3efc76109d2efc.js} +1 -1
  127. package/web/.next/standalone/web/.next/static/chunks/96ec96279ada0efe.js +1 -0
  128. package/web/.next/standalone/web/.next/static/chunks/b31b0765abe0c427.js +1 -0
  129. package/web/.next/standalone/web/.next/static/{static/chunks/c06faa5848e3b0b3.js → chunks/b7d722dab2a7ecc0.js} +1 -1
  130. package/web/.next/standalone/web/.next/static/chunks/cc6d43f798bbe415.js +5 -0
  131. package/web/.next/standalone/web/.next/static/chunks/de300ff10b63be85.css +1 -0
  132. package/web/.next/standalone/web/.next/static/chunks/de71e63276f488bb.js +7 -0
  133. package/web/.next/standalone/web/.next/static/{chunks/194b3ed8e8d9c0e9.js → static/chunks/294ebe8457006bce.js} +3 -3
  134. package/web/.next/standalone/web/.next/static/static/chunks/{23aa98f6e3d7e0e4.js → 7e48d04fbd6dd7a6.js} +5 -3
  135. package/web/.next/{static/chunks/1e9fdac31c7fd474.js → standalone/web/.next/static/static/chunks/81685e5e8be4eac9.js} +3 -3
  136. package/web/.next/standalone/web/.next/static/{chunks/3425251cd978da61.js → static/chunks/8d3efc76109d2efc.js} +1 -1
  137. package/web/.next/standalone/web/.next/static/static/chunks/96ec96279ada0efe.js +1 -0
  138. package/web/.next/standalone/web/.next/static/static/chunks/b31b0765abe0c427.js +1 -0
  139. package/web/.next/{static/chunks/c06faa5848e3b0b3.js → standalone/web/.next/static/static/chunks/b7d722dab2a7ecc0.js} +1 -1
  140. package/web/.next/standalone/web/.next/static/static/chunks/cc6d43f798bbe415.js +5 -0
  141. package/web/.next/standalone/web/.next/static/static/chunks/de300ff10b63be85.css +1 -0
  142. package/web/.next/standalone/web/.next/static/static/chunks/de71e63276f488bb.js +7 -0
  143. package/web/.next/standalone/web/src/app/(main)/page.tsx +2 -2
  144. package/web/.next/standalone/web/src/app/api/config/route.ts +3 -2
  145. package/web/.next/standalone/web/src/components/chat-interface.tsx +324 -37
  146. package/web/.next/standalone/web/src/components/sessions-sidebar.tsx +1 -1
  147. package/web/.next/standalone/web/src/lib/api.ts +3 -0
  148. package/web/.next/standalone/web/src/lib/config.ts +2 -1
  149. package/web/.next/static/chunks/{194b3ed8e8d9c0e9.js → 294ebe8457006bce.js} +3 -3
  150. package/web/.next/static/chunks/{23aa98f6e3d7e0e4.js → 7e48d04fbd6dd7a6.js} +5 -3
  151. package/web/.next/{standalone/web/.next/static/chunks/1e9fdac31c7fd474.js → static/chunks/81685e5e8be4eac9.js} +3 -3
  152. package/web/.next/{standalone/web/.next/static/static/chunks/3425251cd978da61.js → static/chunks/8d3efc76109d2efc.js} +1 -1
  153. package/web/.next/static/chunks/96ec96279ada0efe.js +1 -0
  154. package/web/.next/static/chunks/b31b0765abe0c427.js +1 -0
  155. package/web/.next/{standalone/web/.next/static/chunks/c06faa5848e3b0b3.js → static/chunks/b7d722dab2a7ecc0.js} +1 -1
  156. package/web/.next/static/chunks/cc6d43f798bbe415.js +5 -0
  157. package/web/.next/static/chunks/de300ff10b63be85.css +1 -0
  158. package/web/.next/static/chunks/de71e63276f488bb.js +7 -0
  159. package/web/.next/standalone/web/.next/server/chunks/ssr/[root-of-the-server]__9d3fe3b4._.js +0 -3
  160. package/web/.next/standalone/web/.next/server/chunks/ssr/web_631133e0._.js +0 -7
  161. package/web/.next/standalone/web/.next/static/chunks/2110d26bc24ed542.js +0 -1
  162. package/web/.next/standalone/web/.next/static/chunks/4fe97b7866eacdcf.js +0 -7
  163. package/web/.next/standalone/web/.next/static/chunks/7c000de1a1357775.css +0 -1
  164. package/web/.next/standalone/web/.next/static/chunks/a895d50f76a48e6e.js +0 -1
  165. package/web/.next/standalone/web/.next/static/chunks/dccaa0e6b27241a5.js +0 -5
  166. package/web/.next/standalone/web/.next/static/static/chunks/2110d26bc24ed542.js +0 -1
  167. package/web/.next/standalone/web/.next/static/static/chunks/4fe97b7866eacdcf.js +0 -7
  168. package/web/.next/standalone/web/.next/static/static/chunks/7c000de1a1357775.css +0 -1
  169. package/web/.next/standalone/web/.next/static/static/chunks/a895d50f76a48e6e.js +0 -1
  170. package/web/.next/standalone/web/.next/static/static/chunks/dccaa0e6b27241a5.js +0 -5
  171. package/web/.next/static/chunks/2110d26bc24ed542.js +0 -1
  172. package/web/.next/static/chunks/4fe97b7866eacdcf.js +0 -7
  173. package/web/.next/static/chunks/7c000de1a1357775.css +0 -1
  174. package/web/.next/static/chunks/a895d50f76a48e6e.js +0 -1
  175. package/web/.next/static/chunks/dccaa0e6b27241a5.js +0 -5
  176. /package/web/.next/standalone/web/.next/static/{mUwpFRyqjpPrLQ3DS2i5G → _0-MmiObGsO5iLpf0Qgmw}/_buildManifest.js +0 -0
  177. /package/web/.next/standalone/web/.next/static/{mUwpFRyqjpPrLQ3DS2i5G → _0-MmiObGsO5iLpf0Qgmw}/_clientMiddlewareManifest.json +0 -0
  178. /package/web/.next/standalone/web/.next/static/{mUwpFRyqjpPrLQ3DS2i5G → _0-MmiObGsO5iLpf0Qgmw}/_ssgManifest.js +0 -0
  179. /package/web/.next/standalone/web/.next/static/static/{mUwpFRyqjpPrLQ3DS2i5G → _0-MmiObGsO5iLpf0Qgmw}/_buildManifest.js +0 -0
  180. /package/web/.next/standalone/web/.next/static/static/{mUwpFRyqjpPrLQ3DS2i5G → _0-MmiObGsO5iLpf0Qgmw}/_clientMiddlewareManifest.json +0 -0
  181. /package/web/.next/standalone/web/.next/static/static/{mUwpFRyqjpPrLQ3DS2i5G → _0-MmiObGsO5iLpf0Qgmw}/_ssgManifest.js +0 -0
  182. /package/web/.next/static/{mUwpFRyqjpPrLQ3DS2i5G → _0-MmiObGsO5iLpf0Qgmw}/_buildManifest.js +0 -0
  183. /package/web/.next/static/{mUwpFRyqjpPrLQ3DS2i5G → _0-MmiObGsO5iLpf0Qgmw}/_clientMiddlewareManifest.json +0 -0
  184. /package/web/.next/static/{mUwpFRyqjpPrLQ3DS2i5G → _0-MmiObGsO5iLpf0Qgmw}/_ssgManifest.js +0 -0
@@ -4,8 +4,10 @@ ${e.themeCSS}`),void 0!==e.fontFamily&&(r+=`
4
4
  :root { --mermaid-font-family: ${e.fontFamily}}`),void 0!==e.altFontFamily&&(r+=`
5
5
  :root { --mermaid-alt-font-family: ${e.altFontFamily}}`),t instanceof Map){let n=e.htmlLabels??e.flowchart?.htmlLabels?["> *","span"]:["rect","polygon","ellipse","circle","path"];t.forEach(e=>{(0,su.default)(e.styles)||n.forEach(t=>{r+=ai(e.id,t,e.styles)}),(0,su.default)(e.textStyles)||(r+=ai(e.id,"tspan",(e?.textStyles||[]).map(e=>e.replace("color","fill"))))})}return r},"createCssStyles"),ao=(0,nW.__name)((e,t,r,n)=>{var s,i,a;let o=aa(e,r),l=(0,nG.styles_default)(t,o,e.themeVariables);return so((a=function e(t,r,n,s,i,a,o,l,c){for(var u,d,h,p,m,f,g=0,x=0,y=o,v=0,b=0,w=0,k=1,j=1,N=1,S=0,C="",A=i,_=a,T=s,E=C;j;)switch(w=S,S=st()){case 40:if(108!=w&&58==n0(E,y-1)){-1!=(m=E+=nQ(ss(S),"&","&\f"),f=nJ(g?l[g-1]:0),m.indexOf("&\f",f))&&(N=-1);break}case 34:case 39:case 91:E+=ss(S);break;case 9:case 10:case 13:case 32:E+=function(e){for(;n9=sr();)if(n9<33)st();else break;return sn(e)>2||sn(n9)>3?"":" "}(w);break;case 92:E+=function(e,t){for(var r;--t&&st()&&!(n9<48)&&!(n9>102)&&(!(n9>57)||!(n9<65))&&(!(n9>70)||!(n9<97)););return r=n8+(t<6&&32==sr()&&32==st()),n1(n7,e,r)}(n8-1,7);continue;case 47:switch(sr()){case 42:case 47:n5((u=function(e,t){for(;st();)if(e+n9===57)break;else if(e+n9===84&&47===sr())break;return"/*"+n1(n7,t,n8-1)+"*"+nZ(47===e?e:st())}(st(),n8),d=r,h=n,p=c,se(u,d,h,nK,nZ(n9),n1(u,2,-2),0,p)),c),(5==sn(w||1)||5==sn(sr()||1))&&n2(E)&&" "!==n1(E,-1,void 0)&&(E+=" ");break;default:E+="/"}break;case 123*k:l[g++]=n2(E)*N;case 125*k:case 59:case 0:switch(S){case 0:case 125:j=0;case 59+x:-1==N&&(E=nQ(E,/\f/g,"")),b>0&&(n2(E)-y||0===k&&47===w)&&n5(b>32?sa(E+";",s,n,y-1,c):sa(nQ(E," ","")+";",s,n,y-2,c),c);break;case 59:E+=";";default:if(n5(T=si(E,r,n,g,x,i,l,C,A=[],_=[],y,a),a),123===S)if(0===x)e(E,r,T,T,A,a,y,l,_);else{switch(v){case 99:if(110===n0(E,3))break;case 108:if(97===n0(E,2))break;default:x=0;case 100:case 109:case 115:}x?e(t,T,T,s&&n5(si(t,T,T,0,0,i,l,C,i,A=[],y,_),_),i,_,y,l,s?A:_):e(E,T,T,T,[""],_,0,l,_)}}g=x=b=0,k=N=1,C=E="",y=o;break;case 58:y=1+n2(E),b=w;default:if(k<1){if(123==S)--k;else if(125==S&&0==k++&&125==(n9=n8>0?n0(n7,--n8):0,n6--,10===n9&&(n6=1,n3--),n9))continue}switch(E+=nZ(S),S*k){case 38:N=x>0?1:(E+="\f",-1);break;case 44:l[g++]=(n2(E)-1)*N,N=1;break;case 64:45===sr()&&(E+=ss(st())),v=sr(),x=y=n2(C=E+=function(e){for(;!sn(sr());)st();return n1(n7,e,n8)}(n8)),S++;break;case 45:45===w&&2==n2(E)&&(k=0)}}return a}("",null,null,null,[""],(i=s=`${n}{${l}}`,n3=n6=1,n4=n2(n7=i),n8=0,s=[]),0,[0],s),n7="",a),sl)},"createUserStyles"),al=(0,nW.__name)((e="",t,r)=>{let n=e;return r||t||(n=n.replace(/marker-end="url\([\d+./:=?A-Za-z-]*?#/g,'marker-end="url(#')),n=(n=(0,nU.decodeEntities)(n)).replace(/<br>/g,"<br/>")},"cleanUpSvgCode"),ac=(0,nW.__name)((e="",t)=>{let r=t?.viewBox?.baseVal?.height?t.viewBox.baseVal.height+"px":"100%",n=ae(`<body style="margin:0">${e}</body>`);return`<iframe style="width:100%;height:${r};border:0;margin:0;" src="data:text/html;charset=UTF-8;base64,${n}" sandbox="allow-top-navigation-by-user-activation allow-popups">
6
6
  The "iframe" tag is not supported by your browser.
7
- </iframe>`},"putIntoIFrame"),au=(0,nW.__name)((e,t,r,n,s)=>{let i=e.append("div");i.attr("id",r),n&&i.attr("style",n);let a=i.append("svg").attr("id",t).attr("width","100%").attr("xmlns","http://www.w3.org/2000/svg");return s&&a.attr("xmlns:xlink",s),a.append("g"),e},"appendDivSvgG");function ad(e,t){return e.append("iframe").attr("id",t).attr("style","width: 100%; height: 100%;").attr("sandbox","")}(0,nW.__name)(ad,"sandboxedIframe");var ah=(0,nW.__name)((e,t,r,n)=>{e.getElementById(t)?.remove(),e.getElementById(r)?.remove(),e.getElementById(n)?.remove()},"removeExistingElements"),ap=(0,nW.__name)(async function(e,t,r){let n,s;iJ();let i=an(t);t=i.code;let a=(0,nG.getConfig)();nW.log.debug(a),t.length>(a?.maxTextSize??5e4)&&(t="graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa");let o="#"+e,l="i"+e,c="#"+l,u="d"+e,d="#"+u,h=(0,nW.__name)(()=>{let e=m?c:d,t=(0,nH.select)(e).node();t&&"remove"in t&&t.remove()},"removeTempElements"),p=(0,nH.select)("body"),m="sandbox"===a.securityLevel,f="loose"===a.securityLevel,g=a.fontFamily;if(void 0!==r){if(r&&(r.innerHTML=""),m){let e=ad((0,nH.select)(r),l);(p=(0,nH.select)(e.nodes()[0].contentDocument.body)).node().style.margin=0}else p=(0,nH.select)(r);au(p,e,u,`font-family: ${g}`,"http://www.w3.org/1999/xlink")}else{if(ah(document,e,u,l),m){let e=ad((0,nH.select)("body"),l);(p=(0,nH.select)(e.nodes()[0].contentDocument.body)).node().style.margin=0}else p=(0,nH.select)("body");au(p,e,u)}try{n=await i1.fromText(t,{title:i.title})}catch(e){if(a.suppressErrorRendering)throw h(),e;n=await i1.fromText("error"),s=e}let x=p.select(d).node(),y=n.type,v=x.firstChild,b=v.firstChild,w=ao(a,y,n.renderer.getClasses?.(t,n),o),k=document.createElement("style");k.innerHTML=w,v.insertBefore(k,b);try{await n.renderer.draw(t,e,nz.package_default.version,n)}catch(r){throw a.suppressErrorRendering?h():io.draw(t,e,nz.package_default.version),r}ag(y,p.select(`${d} svg`),n.db.getAccTitle?.(),n.db.getAccDescription?.()),p.select(`[id="${e}"]`).selectAll("foreignobject > *").attr("xmlns","http://www.w3.org/1999/xhtml");let j=p.select(d).node().innerHTML;if(nW.log.debug("config.arrowMarkerAbsolute",a.arrowMarkerAbsolute),j=al(j,m,(0,nG.evaluate)(a.arrowMarkerAbsolute)),m?j=ac(j,p.select(d+" svg").node()):f||(j=sc.default.sanitize(j,{ADD_TAGS:at,ADD_ATTR:ar,HTML_INTEGRATION_POINTS:{foreignobject:!0}})),i5(),s)throw s;return h(),{diagramType:y,svg:j,bindFunctions:n.db.bindFunctions}},"render");function am(e={}){let t=(0,nG.assignWithDepth_default)({},e);t?.fontFamily&&!t.themeVariables?.fontFamily&&(t.themeVariables||(t.themeVariables={}),t.themeVariables.fontFamily=t.fontFamily),(0,nG.saveConfigFromInitialize)(t),t?.theme&&t.theme in nG.themes_default?t.themeVariables=nG.themes_default[t.theme].getThemeVariables(t.themeVariables):t&&(t.themeVariables=nG.themes_default.default.getThemeVariables(t.themeVariables));let r="object"==typeof t?(0,nG.setSiteConfig)(t):(0,nG.getSiteConfig)();(0,nW.setLogLevel)(r.logLevel),iJ()}(0,nW.__name)(am,"initialize");var af=(0,nW.__name)((e,t={})=>{let{code:r}=i7(e);return i1.fromText(r,t)},"getDiagramFromText");function ag(e,t,r,n){iQ(t,e),i0(t,r,n,t.attr("id"))}(0,nW.__name)(ag,"addA11yInfo");var ax=Object.freeze({render:ap,parse:as,getDiagramFromText:af,initialize:am,getConfig:nG.getConfig,setConfig:nG.setConfig,getSiteConfig:nG.getSiteConfig,updateSiteConfig:nG.updateSiteConfig,reset:(0,nW.__name)(()=>{(0,nG.reset)()},"reset"),globalReset:(0,nW.__name)(()=>{(0,nG.reset)(nG.defaultConfig)},"globalReset"),defaultConfig:nG.defaultConfig});(0,nW.setLogLevel)((0,nG.getConfig)().logLevel),(0,nG.reset)((0,nG.getConfig)());var ay=(0,nW.__name)((e,t,r)=>{nW.log.warn(e),(0,nU.isDetailedError)(e)?(r&&r(e.str,e.hash),t.push({...e,message:e.str,error:e})):(r&&r(e),e instanceof Error&&t.push({str:e.message,message:e.message,hash:e.name,error:e}))},"handleError"),av=(0,nW.__name)(async function(e={querySelector:".mermaid"}){try{await ab(e)}catch(t){if((0,nU.isDetailedError)(t)&&nW.log.error(t.str),aR.parseError&&aR.parseError(t),!e.suppressErrors)throw nW.log.error("Use the suppressErrors option to suppress these errors"),t}},"run"),ab=(0,nW.__name)(async function({postRenderCallback:e,querySelector:t,nodes:r}={querySelector:".mermaid"}){let n,s,i=ax.getConfig();if(nW.log.debug(`${!e?"No ":""}Callback function found`),r)n=r;else if(t)n=document.querySelectorAll(t);else throw Error("Nodes and querySelector are both undefined");nW.log.debug(`Found ${n.length} diagrams`),i?.startOnLoad!==void 0&&(nW.log.debug("Start On Load: "+i?.startOnLoad),ax.updateSiteConfig({startOnLoad:i?.startOnLoad}));let a=new nU.utils_default.InitIDGenerator(i.deterministicIds,i.deterministicIDSeed),o=[];for(let t of Array.from(n)){if(nW.log.info("Rendering diagram: "+t.id),t.getAttribute("data-processed"))continue;t.setAttribute("data-processed","true");let r=`mermaid-${a.next()}`;s=t.innerHTML,s=(0,nq.dedent)(nU.utils_default.entityDecode(s)).trim().replace(/<br\s*\/?>/gi,"<br/>");let n=nU.utils_default.detectInit(s);n&&nW.log.debug("Detected early reinit: ",n);try{let{svg:n,bindFunctions:i}=await aE(r,s,t);t.innerHTML=n,e&&await e(r),i&&i(t)}catch(e){ay(e,o,aR.parseError)}}if(o.length>0)throw o[0]},"runThrowsErrors"),aw=(0,nW.__name)(function(e){ax.initialize(e)},"initialize"),ak=(0,nW.__name)(async function(e,t,r){nW.log.warn("mermaid.init is deprecated. Please use run instead."),e&&aw(e);let n={postRenderCallback:r,querySelector:".mermaid"};"string"==typeof t?n.querySelector=t:t&&(t instanceof HTMLElement?n.nodes=[t]:n.nodes=t),await av(n)},"init"),aj=(0,nW.__name)(async(e,{lazyLoad:t=!0}={})=>{iJ(),(0,nG.registerLazyLoadedDiagrams)(...e),!1===t&&await iZ()},"registerExternalDiagrams"),aN=(0,nW.__name)(function(){if(aR.startOnLoad){let{startOnLoad:e}=ax.getConfig();e&&aR.run().catch(e=>nW.log.error("Mermaid failed to initialize",e))}},"contentLoaded");"u">typeof document&&window.addEventListener("load",aN,!1);var aS=(0,nW.__name)(function(e){aR.parseError=e},"setParseErrorHandler"),aC=[],aA=!1,a_=(0,nW.__name)(async()=>{if(!aA){for(aA=!0;aC.length>0;){let e=aC.shift();if(e)try{await e()}catch(e){nW.log.error("Error executing queue",e)}}aA=!1}},"executeQueue"),aT=(0,nW.__name)(async(e,t)=>new Promise((r,n)=>{let s=(0,nW.__name)(()=>new Promise((s,i)=>{ax.parse(e,t).then(e=>{s(e),r(e)},e=>{nW.log.error("Error parsing",e),aR.parseError?.(e),i(e),n(e)})}),"performCall");aC.push(s),a_().catch(n)}),"parse"),aE=(0,nW.__name)((e,t,r)=>new Promise((n,s)=>{let i=(0,nW.__name)(()=>new Promise((i,a)=>{ax.render(e,t,r).then(e=>{i(e),n(e)},e=>{nW.log.error("Error parsing",e),aR.parseError?.(e),a(e),s(e)})}),"performCall");aC.push(i),a_().catch(s)}),"render"),aP=(0,nW.__name)(()=>Object.keys(nG.detectors).map(e=>({id:e})),"getRegisteredDiagramsMetadata"),aR={startOnLoad:!0,mermaidAPI:ax,parse:aT,render:aE,init:ak,run:av,registerExternalDiagrams:aj,registerLayoutLoaders:n$.registerLayoutLoaders,initialize:aw,parseError:void 0,contentLoaded:aN,setParseErrorHandler:aS,detectType:nG.detectType,registerIconPacks:nV.registerIconPacks,getRegisteredDiagramsMetadata:aP},aM={startOnLoad:!1,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:!0},aI=function(e={}){let t=!1,r={...aM,...e.config},n={initialize(n){r={...aM,...e.config,...n},aR.initialize(r),t=!0},render:async(e,n)=>(t||(aR.initialize(r),t=!0),await aR.render(e,n))};return{name:"mermaid",type:"diagram",language:"mermaid",getMermaid:e=>(e&&n.initialize(e),n)}}();(0,T.default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);let aL=(0,T.default)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);var aD=e.i(77589),aD=aD,aO=e.i(349416),az=e.i(773340),aF=e.i(991106),aB=aF;let a$=({className:e,from:t,...r})=>(0,v.jsx)("div",{className:(0,k.cn)("group flex w-full max-w-[95%] flex-col gap-2 transition-all duration-200","user"===t?"is-user ml-auto justify-end":"is-assistant",e),...r}),aV=({children:e,className:t,...r})=>(0,v.jsx)("div",{className:(0,k.cn)("is-user:dark flex w-fit min-w-0 max-w-full flex-col gap-2 overflow-hidden text-sm","group-[.is-user]:ml-auto group-[.is-user]:rounded-2xl group-[.is-user]:rounded-br-md group-[.is-user]:bg-primary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-primary-foreground group-[.is-user]:shadow-sm","group-[.is-assistant]:text-foreground",t),...r,children:e}),aU=({className:e,children:t,...r})=>(0,v.jsx)("div",{className:(0,k.cn)("flex items-center gap-1",e),...r,children:t}),aG=({tooltip:e,children:t,label:r,variant:n="ghost",size:s="icon-sm",...i})=>{let a=(0,v.jsxs)(A.Button,{size:s,type:"button",variant:n,...i,children:[t,(0,v.jsx)("span",{className:"sr-only",children:r||e})]});return e?(0,v.jsx)(_.TooltipProvider,{children:(0,v.jsxs)(_.Tooltip,{children:[(0,v.jsx)(_.TooltipTrigger,{asChild:!0,children:a}),(0,v.jsx)(_.TooltipContent,{children:(0,v.jsx)("p",{children:e})})]})}):a},aW=({url:e,isOpen:t,onClose:r,onConfirm:n})=>{let[s,i]=(0,b.useState)(!1);if((0,b.useEffect)(()=>{i(!0)},[]),!s||!t)return null;let a=(()=>{try{return new URL(e).hostname}catch{return e}})();return(0,az.createPortal)((0,v.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:r,onKeyDown:e=>"Escape"===e.key&&r(),children:(0,v.jsxs)("div",{className:"relative mx-4 max-w-md rounded-lg bg-background p-6 shadow-lg",onClick:e=>e.stopPropagation(),children:[(0,v.jsxs)("button",{className:"absolute right-3 top-3 rounded-sm p-1 text-muted-foreground hover:bg-muted hover:text-foreground",onClick:r,type:"button",children:[(0,v.jsx)(aO.XIcon,{className:"h-4 w-4"}),(0,v.jsx)("span",{className:"sr-only",children:"Close"})]}),(0,v.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 text-lg font-semibold",children:[(0,v.jsx)(aD.default,{className:"h-5 w-5"}),(0,v.jsx)("span",{children:"External Link"})]}),(0,v.jsx)("p",{className:"text-sm text-muted-foreground",children:"You are about to visit an external website:"}),(0,v.jsx)("p",{className:"break-all rounded bg-muted px-3 py-2 text-sm font-mono",children:a}),(0,v.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,v.jsx)(A.Button,{variant:"outline",onClick:r,children:"Cancel"}),(0,v.jsx)(A.Button,{onClick:n,children:"Continue"})]})]})]})}),document.body)},aq=(0,b.memo)(({className:e,linkSafety:t,...r})=>(0,v.jsx)(aB.j,{className:(0,k.cn)("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),plugins:{code:nn,mermaid:aI,math:nO,cjk:eg},linkSafety:{enabled:t?.enabled??!0,onLinkCheck:t?.onLinkCheck,renderModal:t?.renderModal??aW},...r}),(e,t)=>e.children===t.children);aq.displayName="MessageResponse";var aH=e.i(241416),aK=e.i(465488),aX=e.i(995945),aY=e.i(309945),aJ=Symbol("radix.slottable");function aZ(e){return b.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===aJ}var aQ=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{var r,n;let s,i,a,o=(n=r=`Primitive.${t}`,(s=b.forwardRef((e,t)=>{let{children:r,...n}=e;if(b.isValidElement(r)){var s;let e,i,a=(s=r,(i=(e=Object.getOwnPropertyDescriptor(s.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.ref:(i=(e=Object.getOwnPropertyDescriptor(s,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.props.ref:s.props.ref||s.ref),o=function(e,t){let r={...t};for(let n in t){let s=e[n],i=t[n];/^on[A-Z]/.test(n)?s&&i?r[n]=(...e)=>{let t=i(...e);return s(...e),t}:s&&(r[n]=s):"style"===n?r[n]={...s,...i}:"className"===n&&(r[n]=[s,i].filter(Boolean).join(" "))}return{...e,...r}}(n,r.props);return r.type!==b.Fragment&&(o.ref=t?(0,aY.composeRefs)(t,a):a),b.cloneElement(r,o)}return b.Children.count(r)>1?b.Children.only(null):null})).displayName=`${n}.SlotClone`,i=s,(a=b.forwardRef((e,t)=>{let{children:r,...n}=e,s=b.Children.toArray(r),a=s.find(aZ);if(a){let e=a.props.children,r=s.map(t=>t!==a?t:b.Children.count(e)>1?b.Children.only(null):b.isValidElement(e)?e.props.children:null);return(0,v.jsx)(i,{...n,ref:t,children:b.isValidElement(e)?b.cloneElement(e,void 0,r):null})}return(0,v.jsx)(i,{...n,ref:t,children:r})})).displayName=`${r}.Slot`,a),l=b.forwardRef((e,r)=>{let{asChild:n,...s}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,v.jsx)(n?o:t,{...s,ref:r})});return l.displayName=`Primitive.${t}`,{...e,[t]:l}},{}),a0=e.i(395509),a1=e.i(610559),a2="Collapsible",[a5,a3]=function(e,t=[]){let r=[],n=()=>{let t=r.map(e=>b.createContext(e));return function(r){let n=r?.[e]||t;return b.useMemo(()=>({[`__scope${e}`]:{...r,[e]:n}}),[r,n])}};return n.scopeName=e,[function(t,n){let s=b.createContext(n),i=r.length;r=[...r,n];let a=t=>{let{scope:r,children:n,...a}=t,o=r?.[e]?.[i]||s,l=b.useMemo(()=>a,Object.values(a));return(0,v.jsx)(o.Provider,{value:l,children:n})};return a.displayName=t+"Provider",[a,function(r,a){let o=a?.[e]?.[i]||s,l=b.useContext(o);if(l)return l;if(void 0!==n)return n;throw Error(`\`${r}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let r=()=>{let r=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let n=r.reduce((t,{useScope:r,scopeName:n})=>{let s=r(e)[`__scope${n}`];return{...t,...s}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:n}),[n])}};return r.scopeName=t.scopeName,r}(n,...t)]}(a2),[a6,a4]=a5(a2),a8=b.forwardRef((e,t)=>{let{__scopeCollapsible:r,open:n,defaultOpen:s,disabled:i,onOpenChange:a,...o}=e,[l,c]=(0,aK.useControllableState)({prop:n,defaultProp:s??!1,onChange:a,caller:a2});return(0,v.jsx)(a6,{scope:r,disabled:i,contentId:(0,a1.useId)(),open:l,onOpenToggle:b.useCallback(()=>c(e=>!e),[c]),children:(0,v.jsx)(aQ.div,{"data-state":on(l),"data-disabled":i?"":void 0,...o,ref:t})})});a8.displayName=a2;var a9="CollapsibleTrigger",a7=b.forwardRef((e,t)=>{let{__scopeCollapsible:r,...n}=e,s=a4(a9,r);return(0,v.jsx)(aQ.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":on(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...n,ref:t,onClick:(0,aH.composeEventHandlers)(e.onClick,s.onOpenToggle)})});a7.displayName=a9;var oe="CollapsibleContent",ot=b.forwardRef((e,t)=>{let{forceMount:r,...n}=e,s=a4(oe,e.__scopeCollapsible);return(0,v.jsx)(a0.Presence,{present:r||s.open,children:({present:e})=>(0,v.jsx)(or,{...n,ref:t,present:e})})});ot.displayName=oe;var or=b.forwardRef((e,t)=>{let{__scopeCollapsible:r,present:n,children:s,...i}=e,a=a4(oe,r),[o,l]=b.useState(n),c=b.useRef(null),u=(0,aY.useComposedRefs)(t,c),d=b.useRef(0),h=d.current,p=b.useRef(0),m=p.current,f=a.open||o,g=b.useRef(f),x=b.useRef(void 0);return b.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,aX.useLayoutEffect)(()=>{let e=c.current;if(e){x.current=x.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=x.current.transitionDuration,e.style.animationName=x.current.animationName),l(n)}},[a.open,n]),(0,v.jsx)(aQ.div,{"data-state":on(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!f,...i,ref:u,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:f&&s})});function on(e){return e?"open":"closed"}function os({...e}){return(0,v.jsx)(a8,{"data-slot":"collapsible",...e})}function oi({...e}){return(0,v.jsx)(a7,{"data-slot":"collapsible-trigger",...e})}function oa({...e}){return(0,v.jsx)(ot,{"data-slot":"collapsible-content",...e})}let oo=(0,T.default)("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);var ol=e.i(100536);let oc=(0,T.default)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var ou=e.i(191729),ou=ou;let od=(0,T.default)("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]),oh=(0,T.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var op=e.i(553880);e.i(196582);let om=(0,T.default)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),of=({token:e})=>{let t,r,n;return(0,v.jsx)("span",{className:"dark:!bg-[var(--shiki-dark-bg)] dark:!text-[var(--shiki-dark)]",style:{color:e.color,backgroundColor:e.bgColor,...e.htmlStyle,fontStyle:(t=e.fontStyle)&&1&t?"italic":void 0,fontWeight:(r=e.fontStyle)&&2&r?"bold":void 0,textDecoration:(n=e.fontStyle)&&4&n?"underline":void 0},children:e.content})},og=({keyedLine:e,showLineNumbers:t})=>(0,v.jsx)("span",{className:t?ok:"block",children:0===e.tokens.length?"\n":e.tokens.map(({token:e,key:t})=>(0,v.jsx)(of,{token:e},t))}),ox=(0,b.createContext)({code:""}),oy=new Map,ov=new Map,ob=new Map;function ow(e,t,r){let n,s,i=(n=e.slice(0,100),s=e.length>100?e.slice(-100):"",`${t}:${e.length}:${n}:${s}`),a=ov.get(i);return a||(r&&(ob.has(i)||ob.set(i,new Set),ob.get(i)?.add(r)),(e=>{let t=oy.get(e);if(t)return t;let r=r9({themes:["github-light","github-dark"],langs:[e]});return oy.set(e,r),r})(t).then(r=>{let n=r.getLoadedLanguages().includes(t)?t:"text",s=r.codeToTokens(e,{lang:n,themes:{light:"github-light",dark:"github-dark"}}),a={tokens:s.tokens,fg:s.fg??"",bg:s.bg??""};ov.set(i,a);let o=ob.get(i);if(o){for(let e of o)e(a);ob.delete(i)}}).catch(e=>{console.error("Failed to highlight code:",e),ob.delete(i)}),null)}let ok=(0,k.cn)("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-8","before:mr-4","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),oj=(0,b.memo)(({tokenized:e,showLineNumbers:t,className:r})=>{let n=(0,b.useMemo)(()=>({backgroundColor:e.bg,color:e.fg}),[e.bg,e.fg]),s=(0,b.useMemo)(()=>e.tokens.map((e,t)=>({key:`line-${t}`,tokens:e.map((e,r)=>({token:e,key:`line-${t}-${r}`}))})),[e.tokens]);return(0,v.jsx)("pre",{className:(0,k.cn)("dark:!bg-[var(--shiki-dark-bg)] dark:!text-[var(--shiki-dark)] m-0 p-4 text-sm",r),style:n,children:(0,v.jsx)("code",{className:(0,k.cn)("font-mono text-sm",t&&"[counter-increment:line_0] [counter-reset:line]"),children:s.map(e=>(0,v.jsx)(og,{keyedLine:e,showLineNumbers:t},e.key))})})},(e,t)=>e.tokenized===t.tokenized&&e.showLineNumbers===t.showLineNumbers&&e.className===t.className),oN=({className:e,language:t,style:r,...n})=>(0,v.jsx)("div",{className:(0,k.cn)("group relative w-full overflow-hidden rounded-md border bg-background text-foreground",e),"data-language":t,style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...r},...n}),oS=({children:e,className:t,...r})=>(0,v.jsx)("div",{className:(0,k.cn)("flex items-center justify-between bg-muted/80 px-3 py-2 text-muted-foreground text-xs",t),...r,children:e}),oC=({children:e,className:t,...r})=>(0,v.jsx)("div",{className:(0,k.cn)("flex items-center gap-2",t),...r,children:e}),oA=({children:e,className:t,...r})=>(0,v.jsx)("span",{className:(0,k.cn)("font-mono",t),...r,children:e}),o_=({code:e,language:t,showLineNumbers:r=!1})=>{let n=(0,b.useMemo)(()=>({tokens:e.split("\n").map(e=>""===e?[]:[{content:e,color:"inherit"}]),fg:"inherit",bg:"transparent"}),[e]),[s,i]=(0,b.useState)(()=>ow(e,t)??n);return(0,b.useEffect)(()=>{i(ow(e,t)??n),ow(e,t,i)},[e,t,n]),(0,v.jsx)("div",{className:"relative overflow-auto",children:(0,v.jsx)(oj,{showLineNumbers:r,tokenized:s})})},oT=({code:e,language:t,showLineNumbers:r=!1,className:n,children:s,...i})=>(0,v.jsx)(ox.Provider,{value:{code:e},children:(0,v.jsxs)(oN,{className:n,language:t,...i,children:[s,(0,v.jsx)(o_,{code:e,language:t,showLineNumbers:r})]})}),oE=({className:e,...t})=>(0,v.jsx)(os,{className:(0,k.cn)("group not-prose mb-4 w-full max-w-full overflow-hidden rounded-md border",e),...t}),oP=({className:e,title:t,type:r,state:n,toolName:s,...i})=>{let a,o="dynamic-tool"===r?s:r.split("-").slice(1).join("-");return(0,v.jsxs)(oi,{className:(0,k.cn)("flex w-full items-center justify-between gap-4 p-3",e),...i,children:[(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)(od,{className:"size-4 text-muted-foreground"}),(0,v.jsx)("span",{className:"font-medium text-sm",children:t??o}),(a={"input-streaming":(0,v.jsx)(oc,{className:"size-4"}),"input-available":(0,v.jsx)(ou.default,{className:"size-4 animate-pulse"}),"approval-requested":(0,v.jsx)(ou.default,{className:"size-4 text-yellow-600"}),"approval-responded":(0,v.jsx)(oo,{className:"size-4 text-blue-600"}),"output-available":(0,v.jsx)(oo,{className:"size-4 text-green-600"}),"output-error":(0,v.jsx)(oh,{className:"size-4 text-red-600"}),"output-denied":(0,v.jsx)(oh,{className:"size-4 text-orange-600"})},(0,v.jsxs)(C,{className:"gap-1.5 rounded-full text-xs",variant:"secondary",children:[a[n],{"input-streaming":"Pending","input-available":"Running","approval-requested":"Awaiting Approval","approval-responded":"Responded","output-available":"Completed","output-error":"Error","output-denied":"Denied"}[n]]}))]}),(0,v.jsx)(ol.ChevronDownIcon,{className:"size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})},oR=({className:e,...t})=>(0,v.jsx)(oa,{className:(0,k.cn)("data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...t}),oM=({className:e,input:t,...r})=>(0,v.jsxs)("div",{className:(0,k.cn)("space-y-2 overflow-hidden p-4 max-w-full",e),...r,children:[(0,v.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:"Parameters"}),(0,v.jsx)("div",{className:"rounded-md bg-muted/50 overflow-x-auto max-w-full",children:(0,v.jsx)(oT,{code:JSON.stringify(t,null,2),language:"json"})})]}),oI=({className:e,output:t,errorText:r,...n})=>{if(!(t||r))return null;let s=(0,v.jsx)("div",{children:t});return"object"!=typeof t||(0,b.isValidElement)(t)?"string"==typeof t&&(s=(0,v.jsx)(oT,{code:t,language:"json"})):s=(0,v.jsx)(oT,{code:JSON.stringify(t,null,2),language:"json"}),(0,v.jsxs)("div",{className:(0,k.cn)("space-y-2 p-4 max-w-full overflow-hidden",e),...n,children:[(0,v.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:r?"Error":"Result"}),(0,v.jsxs)("div",{className:(0,k.cn)("overflow-x-auto rounded-md text-xs max-w-full [&_table]:w-full",r?"bg-destructive/10 text-destructive":"bg-muted/50 text-foreground"),children:[r&&(0,v.jsx)("div",{children:r}),s]})]})},oL=({className:e,...t})=>(0,v.jsx)("div",{className:(0,k.cn)("flex flex-col overflow-hidden rounded-lg border bg-background shadow-sm",e),...t}),oD=({className:e,...t})=>(0,v.jsx)("div",{className:(0,k.cn)("flex items-center justify-between border-b bg-muted/50 px-4 py-3",e),...t}),oO=({className:e,...t})=>(0,v.jsx)("p",{className:(0,k.cn)("font-medium text-foreground text-sm",e),...t}),oz=({className:e,...t})=>(0,v.jsx)("p",{className:(0,k.cn)("text-muted-foreground text-sm",e),...t}),oF=({className:e,...t})=>(0,v.jsx)("div",{className:(0,k.cn)("flex items-center gap-1",e),...t}),oB=({tooltip:e,label:t,icon:r,children:n,className:s,size:i="sm",variant:a="ghost",...o})=>{let l=(0,v.jsxs)(A.Button,{className:(0,k.cn)("size-8 p-0 text-muted-foreground hover:text-foreground",s),size:i,type:"button",variant:a,...o,children:[r?(0,v.jsx)(r,{className:"size-4"}):n,(0,v.jsx)("span",{className:"sr-only",children:t||e})]});return e?(0,v.jsx)(_.TooltipProvider,{children:(0,v.jsxs)(_.Tooltip,{children:[(0,v.jsx)(_.TooltipTrigger,{asChild:!0,children:l}),(0,v.jsx)(_.TooltipContent,{children:(0,v.jsx)("p",{children:e})})]})}):l},o$=({className:e,...t})=>(0,v.jsx)("div",{className:(0,k.cn)("flex-1 overflow-auto p-4",e),...t}),oV=(0,N.cva)("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function oU({className:e,variant:t,...r}){return(0,v.jsx)("div",{"data-slot":"alert",role:"alert",className:(0,k.cn)(oV({variant:t}),e),...r})}let oG=(0,b.createContext)(null),oW=()=>{let e=(0,b.useContext)(oG);if(!e)throw Error("Confirmation components must be used within Confirmation");return e},oq=({className:e,approval:t,state:r,...n})=>t&&"input-streaming"!==r&&"input-available"!==r?(0,v.jsx)(oG.Provider,{value:{approval:t,state:r},children:(0,v.jsx)(oU,{className:(0,k.cn)("flex flex-col gap-2",e),...n})}):null,oH=({children:e})=>{let{state:t}=oW();return"approval-requested"!==t?null:e},oK=({className:e,...t})=>{let{state:r}=oW();return"approval-requested"!==r?null:(0,v.jsx)("div",{className:(0,k.cn)("flex items-center justify-end gap-2 self-end",e),...t})},oX=e=>(0,v.jsx)(A.Button,{className:"h-8 px-3 text-sm",type:"button",...e}),oY=({size:e=16})=>(0,v.jsxs)("svg",{height:e,strokeLinejoin:"round",style:{color:"currentcolor"},viewBox:"0 0 16 16",width:e,children:[(0,v.jsx)("title",{children:"Loader"}),(0,v.jsxs)("g",{clipPath:"url(#clip0_2393_1490)",children:[(0,v.jsx)("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),(0,v.jsx)("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),(0,v.jsx)("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),(0,v.jsx)("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),(0,v.jsx)("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),(0,v.jsx)("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),(0,v.jsx)("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),(0,v.jsx)("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),(0,v.jsx)("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),(0,v.jsx)("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),(0,v.jsx)("defs",{children:(0,v.jsx)("clipPath",{id:"clip0_2393_1490",children:(0,v.jsx)("rect",{fill:"white",height:"16",width:"16"})})})]}),oJ=({className:e,size:t=16,...r})=>(0,v.jsx)("div",{className:(0,k.cn)("inline-flex animate-spin items-center justify-center",e),...r,children:(0,v.jsx)(oY,{size:t})}),oZ=(0,T.default)("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]);var aB=aF;let oQ=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],o0=new Set(oQ),o1=(e,t,r)=>r>t?t:r<e?e:r,o2={test:e=>"number"==typeof e,parse:parseFloat,transform:e=>e},o5={...o2,transform:e=>o1(0,1,e)},o3={...o2,default:1},o6=e=>Math.round(1e5*e)/1e5,o4=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu,o8=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,o9=(e,t)=>r=>!!("string"==typeof r&&o8.test(r)&&r.startsWith(e)||t&&null!=r&&Object.prototype.hasOwnProperty.call(r,t)),o7=(e,t,r)=>n=>{if("string"!=typeof n)return n;let[s,i,a,o]=n.match(o4);return{[e]:parseFloat(s),[t]:parseFloat(i),[r]:parseFloat(a),alpha:void 0!==o?parseFloat(o):1}},le={...o2,transform:e=>Math.round(o1(0,255,e))},lt={test:o9("rgb","red"),parse:o7("red","green","blue"),transform:({red:e,green:t,blue:r,alpha:n=1})=>"rgba("+le.transform(e)+", "+le.transform(t)+", "+le.transform(r)+", "+o6(o5.transform(n))+")"},lr={test:o9("#"),parse:function(e){let t="",r="",n="",s="";return e.length>5?(t=e.substring(1,3),r=e.substring(3,5),n=e.substring(5,7),s=e.substring(7,9)):(t=e.substring(1,2),r=e.substring(2,3),n=e.substring(3,4),s=e.substring(4,5),t+=t,r+=r,n+=n,s+=s),{red:parseInt(t,16),green:parseInt(r,16),blue:parseInt(n,16),alpha:s?parseInt(s,16)/255:1}},transform:lt.transform},ln=e=>({test:t=>"string"==typeof t&&t.endsWith(e)&&1===t.split(" ").length,parse:parseFloat,transform:t=>`${t}${e}`}),ls=ln("deg"),li=ln("%"),la=ln("px"),lo=ln("vh"),ll=ln("vw"),lc={...li,parse:e=>li.parse(e)/100,transform:e=>li.transform(100*e)},lu={test:o9("hsl","hue"),parse:o7("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:r,alpha:n=1})=>"hsla("+Math.round(e)+", "+li.transform(o6(t))+", "+li.transform(o6(r))+", "+o6(o5.transform(n))+")"},ld={test:e=>lt.test(e)||lr.test(e)||lu.test(e),parse:e=>lt.test(e)?lt.parse(e):lu.test(e)?lu.parse(e):lr.parse(e),transform:e=>"string"==typeof e?e:e.hasOwnProperty("red")?lt.transform(e):lu.transform(e),getAnimatableNone:e=>{let t=ld.parse(e);return t.alpha=0,ld.transform(t)}},lh=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu,lp="number",lm="color",lf=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function lg(e){let t=e.toString(),r=[],n={color:[],number:[],var:[]},s=[],i=0,a=t.replace(lf,e=>(ld.test(e)?(n.color.push(i),s.push(lm),r.push(ld.parse(e))):e.startsWith("var(")?(n.var.push(i),s.push("var"),r.push(e)):(n.number.push(i),s.push(lp),r.push(parseFloat(e))),++i,"${}")).split("${}");return{values:r,split:a,indexes:n,types:s}}function lx(e){return lg(e).values}function ly(e){let{split:t,types:r}=lg(e),n=t.length;return e=>{let s="";for(let i=0;i<n;i++)if(s+=t[i],void 0!==e[i]){let t=r[i];t===lp?s+=o6(e[i]):t===lm?s+=ld.transform(e[i]):s+=e[i]}return s}}let lv=e=>"number"==typeof e?0:ld.test(e)?ld.getAnimatableNone(e):e,lb={test:function(e){return isNaN(e)&&"string"==typeof e&&(e.match(o4)?.length||0)+(e.match(lh)?.length||0)>0},parse:lx,createTransformer:ly,getAnimatableNone:function(e){let t=lx(e);return ly(e)(t.map(lv))}},lw=new Set(["brightness","contrast","saturate","opacity"]);function lk(e){let[t,r]=e.slice(0,-1).split("(");if("drop-shadow"===t)return e;let[n]=r.match(o4)||[];if(!n)return e;let s=r.replace(n,""),i=+!!lw.has(t);return n!==r&&(i*=100),t+"("+i+s+")"}let lj=/\b([a-z-]*)\(.*?\)/gu,lN={...lb,getAnimatableNone:e=>{let t=e.match(lj);return t?t.map(lk).join(" "):e}},lS={...o2,transform:Math.round},lC={borderWidth:la,borderTopWidth:la,borderRightWidth:la,borderBottomWidth:la,borderLeftWidth:la,borderRadius:la,borderTopLeftRadius:la,borderTopRightRadius:la,borderBottomRightRadius:la,borderBottomLeftRadius:la,width:la,maxWidth:la,height:la,maxHeight:la,top:la,right:la,bottom:la,left:la,inset:la,insetBlock:la,insetBlockStart:la,insetBlockEnd:la,insetInline:la,insetInlineStart:la,insetInlineEnd:la,padding:la,paddingTop:la,paddingRight:la,paddingBottom:la,paddingLeft:la,paddingBlock:la,paddingBlockStart:la,paddingBlockEnd:la,paddingInline:la,paddingInlineStart:la,paddingInlineEnd:la,margin:la,marginTop:la,marginRight:la,marginBottom:la,marginLeft:la,marginBlock:la,marginBlockStart:la,marginBlockEnd:la,marginInline:la,marginInlineStart:la,marginInlineEnd:la,fontSize:la,backgroundPositionX:la,backgroundPositionY:la,rotate:ls,rotateX:ls,rotateY:ls,rotateZ:ls,scale:o3,scaleX:o3,scaleY:o3,scaleZ:o3,skew:ls,skewX:ls,skewY:ls,distance:la,translateX:la,translateY:la,translateZ:la,x:la,y:la,z:la,perspective:la,transformPerspective:la,opacity:o5,originX:lc,originY:lc,originZ:la,zIndex:lS,fillOpacity:o5,strokeOpacity:o5,numOctaves:lS},lA={...lC,color:ld,backgroundColor:ld,outlineColor:ld,fill:ld,stroke:ld,borderColor:ld,borderTopColor:ld,borderRightColor:ld,borderBottomColor:ld,borderLeftColor:ld,filter:lN,WebkitFilter:lN},l_=e=>lA[e],lT=()=>({translate:0,scale:1,origin:0,originPoint:0}),lE=()=>({x:lT(),y:lT()}),lP=()=>({min:0,max:0}),lR=()=>({x:lP(),y:lP()}),lM=e=>!!(e&&e.getVelocity),lI=new Set(["width","height","top","left","right","bottom",...oQ]),lL=e=>t=>t.test(e),lD=[o2,la,li,ls,ll,lo,{test:e=>"auto"===e,parse:e=>e}],lO=e=>lD.find(lL(e)),lz=()=>{},lF=()=>{};ek.default;let lB=e=>t=>"string"==typeof t&&t.startsWith(e),l$=lB("--"),lV=lB("var(--"),lU=e=>!!lV(e)&&lG.test(e.split("/*")[0].trim()),lG=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function lW(e){return"string"==typeof e&&e.split("/*")[0].includes("var(--")}let lq=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u,lH=e=>180*e/Math.PI,lK=e=>lY(lH(Math.atan2(e[1],e[0]))),lX={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:lK,rotateZ:lK,skewX:e=>lH(Math.atan(e[1])),skewY:e=>lH(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},lY=e=>((e%=360)<0&&(e+=360),e),lJ=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),lZ=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),lQ={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:lJ,scaleY:lZ,scale:e=>(lJ(e)+lZ(e))/2,rotateX:e=>lY(lH(Math.atan2(e[6],e[5]))),rotateY:e=>lY(lH(Math.atan2(-e[2],e[0]))),rotateZ:lK,rotate:lK,skewX:e=>lH(Math.atan(e[4])),skewY:e=>lH(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function l0(e){return+!!e.includes("scale")}function l1(e,t){let r,n;if(!e||"none"===e)return l0(t);let s=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);if(s)r=lQ,n=s;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=lX,n=t}if(!n)return l0(t);let i=r[t],a=n[1].split(",").map(l2);return"function"==typeof i?i(a):a[i]}function l2(e){return parseFloat(e.trim())}let l5=e=>e===o2||e===la,l3=new Set(["x","y","z"]),l6=oQ.filter(e=>!l3.has(e)),l4={width:({x:e},{paddingLeft:t="0",paddingRight:r="0"})=>e.max-e.min-parseFloat(t)-parseFloat(r),height:({y:e},{paddingTop:t="0",paddingBottom:r="0"})=>e.max-e.min-parseFloat(t)-parseFloat(r),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>l1(t,"x"),y:(e,{transform:t})=>l1(t,"y")};l4.translateX=l4.x,l4.translateY=l4.y;let l8=e=>e,l9={},l7=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function ce(e,t){let r=!1,n=!0,s={delta:0,timestamp:0,isProcessing:!1},i=()=>r=!0,a=l7.reduce((e,r)=>(e[r]=function(e,t){let r=new Set,n=new Set,s=!1,i=!1,a=new WeakSet,o={delta:0,timestamp:0,isProcessing:!1},l=0;function c(t){a.has(t)&&(u.schedule(t),e()),l++,t(o)}let u={schedule:(e,t=!1,i=!1)=>{let o=i&&s?r:n;return t&&a.add(e),o.has(e)||o.add(e),e},cancel:e=>{n.delete(e),a.delete(e)},process:e=>{if(o=e,s){i=!0;return}s=!0,[r,n]=[n,r],r.forEach(c),t,l=0,r.clear(),s=!1,i&&(i=!1,u.process(e))}};return u}(i,t?r:void 0),e),{}),{setup:o,read:l,resolveKeyframes:c,preUpdate:u,update:d,preRender:h,render:p,postRender:m}=a,f=()=>{let i=l9.useManualTiming?s.timestamp:performance.now();r=!1,l9.useManualTiming||(s.delta=n?1e3/60:Math.max(Math.min(i-s.timestamp,40),1)),s.timestamp=i,s.isProcessing=!0,o.process(s),l.process(s),c.process(s),u.process(s),d.process(s),h.process(s),p.process(s),m.process(s),s.isProcessing=!1,r&&t&&(n=!1,e(f))};return{schedule:l7.reduce((t,i)=>{let o=a[i];return t[i]=(t,i=!1,a=!1)=>(!r&&(r=!0,n=!0,s.isProcessing||e(f)),o.schedule(t,i,a)),t},{}),cancel:e=>{for(let t=0;t<l7.length;t++)a[l7[t]].cancel(e)},state:s,steps:a}}let{schedule:ct,cancel:cr,state:cn,steps:cs}=ce("u">typeof requestAnimationFrame?requestAnimationFrame:l8,!0),ci=new Set,ca=!1,co=!1,cl=!1;function cc(){if(co){let e=Array.from(ci).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),r=new Map;t.forEach(e=>{let t,n=(t=[],l6.forEach(r=>{let n=e.getValue(r);void 0!==n&&(t.push([r,n.get()]),n.set(+!!r.startsWith("scale")))}),t);n.length&&(r.set(e,n),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=r.get(e);t&&t.forEach(([t,r])=>{e.getValue(t)?.set(r)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{void 0!==e.suspendedScrollY&&window.scrollTo(0,e.suspendedScrollY)})}co=!1,ca=!1,ci.forEach(e=>e.complete(cl)),ci.clear()}function cu(){ci.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(co=!0)})}class cd{constructor(e,t,r,n,s,i=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=r,this.motionValue=n,this.element=s,this.isAsync=i}scheduleResolve(){this.state="scheduled",this.isAsync?(ci.add(this),ca||(ca=!0,ct.read(cu),ct.resolveKeyframes(cc))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:r,motionValue:n}=this;if(null===e[0]){let s=n?.get(),i=e[e.length-1];if(void 0!==s)e[0]=s;else if(r&&t){let n=r.readValue(t,i);null!=n&&(e[0]=n)}void 0===e[0]&&(e[0]=i),n&&void 0===s&&n.set(e[0])}for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),ci.delete(this)}cancel(){"scheduled"===this.state&&(ci.delete(this),this.state="pending")}resume(){"pending"===this.state&&this.scheduleResolve()}}function ch(e,t){let r=l_(e);return r!==lN&&(r=lb),r.getAnimatableNone?r.getAnimatableNone(t):void 0}let cp=new Set(["auto","none","0"]);class cm extends cd{constructor(e,t,r,n,s){super(e,t,r,n,s,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:r}=this;if(!t||!t.current)return;super.readKeyframes();for(let r=0;r<e.length;r++){let n=e[r];if("string"==typeof n&&lU(n=n.trim())){let s=function e(t,r,n=1){lF(n<=4,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");let[s,i]=function(e){let t=lq.exec(e);if(!t)return[,];let[,r,n,s]=t;return[`--${r??n}`,s]}(t);if(!s)return;let a=window.getComputedStyle(r).getPropertyValue(s);if(a){let e=a.trim();return/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e)?parseFloat(e):e}return lU(i)?e(i,r,n+1):i}(n,t.current);void 0!==s&&(e[r]=s),r===e.length-1&&(this.finalKeyframe=n)}}if(this.resolveNoneKeyframes(),!lI.has(r)||2!==e.length)return;let[n,s]=e,i=lO(n),a=lO(s);if(lW(n)!==lW(s)&&l4[r]){this.needsMeasurement=!0;return}if(i!==a)if(l5(i)&&l5(a))for(let t=0;t<e.length;t++){let r=e[t];"string"==typeof r&&(e[t]=parseFloat(r))}else l4[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,r=[];for(let t=0;t<e.length;t++)(null===e[t]||function(e){if("number"==typeof e)return 0===e;if(null===e)return!0;return"none"===e||"0"===e||/^0[^.\s]+$/u.test(e)}(e[t]))&&r.push(t);r.length&&function(e,t,r){let n,s=0;for(;s<e.length&&!n;){let t=e[s];"string"==typeof t&&!cp.has(t)&&lg(t).values.length&&(n=e[s]),s++}if(n&&r)for(let s of t)e[s]=ch(r,n)}(e,r,t)}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:r}=this;if(!e||!e.current)return;"height"===r&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=l4[r](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;let n=t[t.length-1];void 0!==n&&e.getValue(r,n).jump(n,!1)}measureEndState(){let{element:e,name:t,unresolvedKeyframes:r}=this;if(!e||!e.current)return;let n=e.getValue(t);n&&n.jump(this.measuredOrigin,!1);let s=r.length-1,i=r[s];r[s]=l4[t](e.measureViewportBox(),window.getComputedStyle(e.current)),null!==i&&void 0===this.finalKeyframe&&(this.finalKeyframe=i),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,r])=>{e.getValue(t).set(r)}),this.resolveNoneKeyframes()}}function cf(e,t){-1===e.indexOf(t)&&e.push(t)}function cg(e,t){let r=e.indexOf(t);r>-1&&e.splice(r,1)}class cx{constructor(){this.subscriptions=[]}add(e){return cf(this.subscriptions,e),()=>cg(this.subscriptions,e)}notify(e,t,r){let n=this.subscriptions.length;if(n)if(1===n)this.subscriptions[0](e,t,r);else for(let s=0;s<n;s++){let n=this.subscriptions[s];n&&n(e,t,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}let{schedule:cy}=ce(queueMicrotask,!1);function cv(){n=void 0}let cb={now:()=>(void 0===n&&cb.set(cn.isProcessing||l9.useManualTiming?cn.timestamp:performance.now()),n),set:e=>{n=e,queueMicrotask(cv)}};class cw{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=cb.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=cb.now(),null===this.canTrackVelocity&&void 0!==e&&(this.canTrackVelocity=!isNaN(parseFloat(this.current)))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,t){this.events[e]||(this.events[e]=new cx);let r=this.events[e].add(t);return"change"===e?()=>{r(),ct.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,r){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-r}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return d&&d.push(this),this.current}getPrevious(){return this.prev}getVelocity(){var e;let t=cb.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||t-this.updatedAt>30)return 0;let r=Math.min(this.updatedAt-this.prevUpdatedAt,30);return e=parseFloat(this.current)-parseFloat(this.prevFrameValue),r?1e3/r*e:0}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function ck(e,t){return new cw(e,t)}let cj=[...lD,ld,lb],cN={current:null},cS={current:!1},cC="u">typeof window,cA=new WeakMap;function c_(e){return null!==e&&"object"==typeof e&&"function"==typeof e.start}function cT(e){return"string"==typeof e||Array.isArray(e)}let cE=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],cP=["initial",...cE];function cR(e){return c_(e.animate)||cP.some(t=>cT(e[t]))}function cM(e){return!!(cR(e)||e.variants)}function cI(e){let t=[{},{}];return e?.values.forEach((e,r)=>{t[0][r]=e.get(),t[1][r]=e.getVelocity()}),t}function cL(e,t,r,n){if("function"==typeof t){let[s,i]=cI(n);t=t(void 0!==r?r:e.custom,s,i)}if("string"==typeof t&&(t=e.variants&&e.variants[t]),"function"==typeof t){let[s,i]=cI(n);t=t(void 0!==r?r:e.custom,s,i)}return t}let cD=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"],cO={};class cz{scrapeMotionValuesFromProps(e,t,r){return{}}constructor({parent:e,props:t,presenceContext:r,reducedMotionConfig:n,blockInitialAnimation:s,visualState:i},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=cd,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=cb.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,ct.render(this.render,!1,!0))};const{latestValues:o,renderState:l}=i;this.latestValues=o,this.baseTarget={...o},this.initialValues=t.initial?{...o}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=r,this.depth=e?e.depth+1:0,this.reducedMotionConfig=n,this.options=a,this.blockInitialAnimation=!!s,this.isControllingVariants=cR(t),this.isVariantNode=cM(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:c,...u}=this.scrapeMotionValuesFromProps(t,{},this);for(const e in u){const t=u[e];void 0!==o[e]&&lM(t)&&t.set(o[e])}}mount(e){this.current=e,cA.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),"never"===this.reducedMotionConfig?this.shouldReduceMotion=!1:"always"===this.reducedMotionConfig?this.shouldReduceMotion=!0:(cS.current||function(){if(cS.current=!0,cC)if(window.matchMedia){let e=window.matchMedia("(prefers-reduced-motion)"),t=()=>cN.current=e.matches;e.addEventListener("change",t),t()}else cN.current=!1}(),this.shouldReduceMotion=cN.current),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){for(let e in this.projection&&this.projection.unmount(),cr(this.notifyUpdate),cr(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this),this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){let r;this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();let n=o0.has(e);n&&this.onBindTransform&&this.onBindTransform();let s=t.on("change",t=>{this.latestValues[e]=t,this.props.onUpdate&&ct.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});"u">typeof window&&window.MotionCheckAppearSync&&(r=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{s(),r&&r(),t.owner&&t.stop()})}sortNodePosition(e){return this.current&&this.sortInstanceNodePosition&&this.type===e.type?this.sortInstanceNodePosition(this.current,e.current):0}updateFeatures(){let e="animation";for(e in cO){let t=cO[e];if(!t)continue;let{isEnabled:r,Feature:n}=t;if(!this.features[e]&&n&&r(this.props)&&(this.features[e]=new n(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):lR()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<cD.length;t++){let r=cD[t];this.propEventSubscriptions[r]&&(this.propEventSubscriptions[r](),delete this.propEventSubscriptions[r]);let n=e["on"+r];n&&(this.propEventSubscriptions[r]=this.on(r,n))}this.prevMotionValues=function(e,t,r){for(let n in t){let s=t[n],i=r[n];if(lM(s))e.addValue(n,s);else if(lM(i))e.addValue(n,ck(s,{owner:e}));else if(i!==s)if(e.hasValue(n)){let t=e.getValue(n);!0===t.liveStyle?t.jump(s):t.hasAnimated||t.set(s)}else{let t=e.getStaticValue(n);e.addValue(n,ck(void 0!==t?t:s,{owner:e}))}}for(let n in r)void 0===t[n]&&e.removeValue(n);return t}(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){let t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){let r=this.values.get(e);t!==r&&(r&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let r=this.values.get(e);return void 0===r&&void 0!==t&&(r=ck(null===t?void 0:t,{owner:this}),this.addValue(e,r)),r}readValue(e,t){let r=void 0===this.latestValues[e]&&this.current?this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options):this.latestValues[e];if(null!=r){let n,s;if("string"==typeof r&&(n=r,/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(n)||(s=r,/^0[^.\s]+$/u.test(s))))r=parseFloat(r);else{let n;n=r,!cj.find(lL(n))&&lb.test(t)&&(r=ch(e,t))}this.setBaseTarget(e,lM(r)?r.get():r)}return lM(r)?r.get():r}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){let t,{initial:r}=this.props;if("string"==typeof r||"object"==typeof r){let n=cL(this.props,r,this.presenceContext?.custom);n&&(t=n[e])}if(r&&void 0!==t)return t;let n=this.getBaseTargetFromProps(this.props,e);return void 0===n||lM(n)?void 0!==this.initialValues[e]&&void 0===t?void 0:this.baseTarget[e]:n}on(e,t){return this.events[e]||(this.events[e]=new cx),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){cy.render(this.render)}}class cF extends cz{constructor(){super(...arguments),this.KeyframeResolver=cm}sortInstanceNodePosition(e,t){return 2&e.compareDocumentPosition(t)?1:-1}getBaseTargetFromProps(e,t){let r=e.style;return r?r[t]:void 0}removeValueFromRenderState(e,{vars:t,style:r}){delete t[e],delete r[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;lM(e)&&(this.childSubscription=e.on("change",e=>{this.current&&(this.current.textContent=`${e}`)}))}}function cB(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}let c$=(e,t)=>t&&"number"==typeof e?t.transform(e):e,cV={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},cU=oQ.length;function cG(e,t,r){let{style:n,vars:s,transformOrigin:i}=e,a=!1,o=!1;for(let e in t){let r=t[e];if(o0.has(e)){a=!0;continue}if(l$(e)){s[e]=r;continue}{let t=c$(r,lC[e]);e.startsWith("origin")?(o=!0,i[e]=t):n[e]=t}}if(!t.transform&&(a||r?n.transform=function(e,t,r){let n="",s=!0;for(let i=0;i<cU;i++){let a=oQ[i],o=e[a];if(void 0===o)continue;let l=!0;if("number"==typeof o)l=o===+!!a.startsWith("scale");else{let e=parseFloat(o);l=a.startsWith("scale")?1===e:0===e}if(!l||r){let e=c$(o,lC[a]);if(!l){s=!1;let t=cV[a]||a;n+=`${t}(${e}) `}r&&(t[a]=e)}}return n=n.trim(),r?n=r(t,s?"":n):s&&(n="none"),n}(t,e.transform,r):n.transform&&(n.transform="none")),o){let{originX:e="50%",originY:t="50%",originZ:r=0}=i;n.transformOrigin=`${e} ${t} ${r}`}}let cW={offset:"stroke-dashoffset",array:"stroke-dasharray"},cq={offset:"strokeDashoffset",array:"strokeDasharray"},cH=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function cK(e,{attrX:t,attrY:r,attrScale:n,pathLength:s,pathSpacing:i=1,pathOffset:a=0,...o},l,c,u){if(cG(e,o,c),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:h}=e;for(let e of(d.transform&&(h.transform=d.transform,delete d.transform),(h.transform||d.transformOrigin)&&(h.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),h.transform&&(h.transformBox=u?.transformBox??"fill-box",delete d.transformBox),cH))void 0!==d[e]&&(h[e]=d[e],delete d[e]);void 0!==t&&(d.x=t),void 0!==r&&(d.y=r),void 0!==n&&(d.scale=n),void 0!==s&&function(e,t,r=1,n=0,s=!0){e.pathLength=1;let i=s?cW:cq;e[i.offset]=`${-n}`,e[i.array]=`${t} ${r}`}(d,s,i,a,!1)}let cX=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),cY=e=>"string"==typeof e&&"svg"===e.toLowerCase();function cJ(e,{style:t,vars:r},n,s){let i,a=e.style;for(i in t)a[i]=t[i];for(i in s?.applyProjectionStyles(a,n),r)a.setProperty(i,r[i])}function cZ(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}let cQ={correct:(e,t)=>{if(!t.target)return e;if("string"==typeof e)if(!la.test(e))return e;else e=parseFloat(e);let r=cZ(e,t.target.x),n=cZ(e,t.target.y);return`${r}% ${n}%`}},c0=(e,t,r)=>e+(t-e)*r,c1={borderRadius:{...cQ,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:cQ,borderTopRightRadius:cQ,borderBottomLeftRadius:cQ,borderBottomRightRadius:cQ,boxShadow:{correct:(e,{treeScale:t,projectionDelta:r})=>{let n=lb.parse(e);if(n.length>5)return e;let s=lb.createTransformer(e),i=+("number"!=typeof n[0]),a=r.x.scale*t.x,o=r.y.scale*t.y;n[0+i]/=a,n[1+i]/=o;let l=c0(a,o,.5);return"number"==typeof n[2+i]&&(n[2+i]/=l),"number"==typeof n[3+i]&&(n[3+i]/=l),s(n)}}};function c2(e,{layout:t,layoutId:r}){return o0.has(e)||e.startsWith("origin")||(t||void 0!==r)&&(!!c1[e]||"opacity"===e)}function c5(e,t,r){let n=e.style,s=t?.style,i={};if(!n)return i;for(let t in n)(lM(n[t])||s&&lM(s[t])||c2(t,e)||r?.getValue(t)?.liveStyle!==void 0)&&(i[t]=n[t]);return i}function c3(e,t,r){let n=c5(e,t,r);for(let r in e)(lM(e[r])||lM(t[r]))&&(n[-1!==oQ.indexOf(r)?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r]=e[r]);return n}class c6 extends cF{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=lR}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(o0.has(t)){let e=l_(t);return e&&e.default||0}return t=cX.has(t)?t:cB(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,r){return c3(e,t,r)}build(e,t,r){cK(e,t,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(e,t,r,n){for(let r in cJ(e,t,void 0,n),t.attrs)e.setAttribute(cX.has(r)?r:cB(r),t.attrs[r])}mount(e){this.isSVGTag=cY(e.tagName),super.mount(e)}}function c4({top:e,left:t,right:r,bottom:n}){return{x:{min:t,max:r},y:{min:e,max:n}}}function c8(e){return void 0===e||1===e}function c9({scale:e,scaleX:t,scaleY:r}){return!c8(e)||!c8(t)||!c8(r)}function c7(e){return c9(e)||ue(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function ue(e){var t,r;return(t=e.x)&&"0%"!==t||(r=e.y)&&"0%"!==r}function ut(e,t,r,n,s){return void 0!==s&&(e=n+s*(e-n)),n+r*(e-n)+t}function ur(e,t=0,r=1,n,s){e.min=ut(e.min,t,r,n,s),e.max=ut(e.max,t,r,n,s)}function un(e,{x:t,y:r}){ur(e.x,t.translate,t.scale,t.originPoint),ur(e.y,r.translate,r.scale,r.originPoint)}function us(e,t){e.min=e.min+t,e.max=e.max+t}function ui(e,t,r,n,s=.5){let i=c0(e.min,e.max,s);ur(e,t,r,i,n)}function ua(e,t){ui(e.x,t.x,t.scaleX,t.scale,t.originX),ui(e.y,t.y,t.scaleY,t.scale,t.originY)}function uo(e,t){return c4(function(e,t){if(!t)return e;let r=t({x:e.left,y:e.top}),n=t({x:e.right,y:e.bottom});return{top:r.y,left:r.x,bottom:n.y,right:n.x}}(e.getBoundingClientRect(),t))}class ul extends cF{constructor(){super(...arguments),this.type="html",this.renderInstance=cJ}readValueFromInstance(e,t){if(o0.has(t))return this.projection?.isProjecting?l0(t):((e,t)=>{let{transform:r="none"}=getComputedStyle(e);return l1(r,t)})(e,t);{let r=window.getComputedStyle(e),n=(l$(t)?r.getPropertyValue(t):r[t])||0;return"string"==typeof n?n.trim():n}}measureInstanceViewportBox(e,{transformPagePoint:t}){return uo(e,t)}build(e,t,r){cG(e,t,r.transformTemplate)}scrapeMotionValuesFromProps(e,t,r){return c5(e,t,r)}}let uc=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function uu(e){if("string"!=typeof e||e.includes("-"));else if(uc.indexOf(e)>-1||/[A-Z]/u.test(e))return!0;return!1}let ud=(0,b.createContext)({}),uh=(0,b.createContext)({strict:!1}),up=(0,b.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"}),um=(0,b.createContext)({});function uf(e){return Array.isArray(e)?e.join(" "):e}let ug=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function ux(e,t,r){for(let n in t)lM(t[n])||c2(n,r)||(e[n]=t[n])}let uy=()=>({...ug(),attrs:{}}),uv=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function ub(e){return e.startsWith("while")||e.startsWith("drag")&&"draggable"!==e||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||uv.has(e)}let uw=e=>!ub(e);try{g=(()=>{let e=Error("Cannot find module '@emotion/is-prop-valid'");throw e.code="MODULE_NOT_FOUND",e})().default,"function"==typeof g&&(uw=e=>e.startsWith("on")?!ub(e):g(e))}catch{}function uk(e){return lM(e)?e.get():e}let uj=(0,b.createContext)(null),uN=e=>(t,r)=>{let n,s=(0,b.useContext)(um),i=(0,b.useContext)(uj),a=()=>(function({scrapeMotionValuesFromProps:e,createRenderState:t},r,n,s){return{latestValues:function(e,t,r,n){let s={},i=n(e,{});for(let e in i)s[e]=uk(i[e]);let{initial:a,animate:o}=e,l=cR(e),c=cM(e);t&&c&&!l&&!1!==e.inherit&&(void 0===a&&(a=t.initial),void 0===o&&(o=t.animate));let u=!!r&&!1===r.initial,d=(u=u||!1===a)?o:a;if(d&&"boolean"!=typeof d&&!c_(d)){let t=Array.isArray(d)?d:[d];for(let r=0;r<t.length;r++){let n=cL(e,t[r]);if(n){let{transitionEnd:e,transition:t,...r}=n;for(let e in r){let t=r[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}null!==t&&(s[e]=t)}for(let t in e)s[t]=e[t]}}}return s}(r,n,s,e),renderState:t()}})(e,t,s,i);return r?a():(null===(n=(0,b.useRef)(null)).current&&(n.current=a()),n.current)},uS=uN({scrapeMotionValuesFromProps:c5,createRenderState:ug}),uC=uN({scrapeMotionValuesFromProps:c3,createRenderState:uy}),uA="u">typeof window,u_={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},uT=!1;function uE(){return!function(){if(uT)return;let e={};for(let t in u_)e[t]={isEnabled:e=>u_[t].some(t=>!!e[t])};cO=e,uT=!0}(),cO}let uP=Symbol.for("motionComponentSymbol"),uR="data-"+cB("framerAppearId"),uM=(0,b.createContext)({});function uI(e){return e&&"object"==typeof e&&Object.prototype.hasOwnProperty.call(e,"current")}let uL=uA?b.useLayoutEffect:b.useEffect;function uD(e,{forwardMotionProps:t=!1,type:r}={},n,s){n&&function(e){let t=uE();for(let r in e)t[r]={...t[r],...e[r]};cO=t}(n);let i=r?"svg"===r:uu(e),a=i?uC:uS;function o(r,n){var o;let l,c,u,d={...(0,b.useContext)(up),...r,layoutId:function({layoutId:e}){let t=(0,b.useContext)(ud).id;return t&&void 0!==e?t+"-"+e:e}(r)},{isStatic:h}=d,p=function(e){let{initial:t,animate:r}=function(e,t){if(cR(e)){let{initial:t,animate:r}=e;return{initial:!1===t||cT(t)?t:void 0,animate:cT(r)?r:void 0}}return!1!==e.inherit?t:{}}(e,(0,b.useContext)(um));return(0,b.useMemo)(()=>({initial:t,animate:r}),[uf(t),uf(r)])}(r),m=a(r,h);if(!h&&uA){(0,b.useContext)(uh).strict;let t=function(e){let{drag:t,layout:r}=uE();if(!t&&!r)return{};let n={...t,...r};return{MeasureLayout:t?.isEnabled(e)||r?.isEnabled(e)?n.MeasureLayout:void 0,ProjectionNode:n.ProjectionNode}}(d);l=t.MeasureLayout,p.visualElement=function(e,t,r,n,s,i){let{visualElement:a}=(0,b.useContext)(um),o=(0,b.useContext)(uh),l=(0,b.useContext)(uj),c=(0,b.useContext)(up).reducedMotion,u=(0,b.useRef)(null),d=(0,b.useRef)(!1);n=n||o.renderer,!u.current&&n&&(u.current=n(e,{visualState:t,parent:a,props:r,presenceContext:l,blockInitialAnimation:!!l&&!1===l.initial,reducedMotionConfig:c,isSVG:i}),d.current&&u.current&&(u.current.manuallyAnimateOnMount=!0));let h=u.current,p=(0,b.useContext)(uM);h&&!h.projection&&s&&("html"===h.type||"svg"===h.type)&&function(e,t,r,n){let{layoutId:s,layout:i,drag:a,dragConstraints:o,layoutScroll:l,layoutRoot:c,layoutCrossfade:u}=t;e.projection=new r(e.latestValues,t["data-framer-portal-id"]?void 0:function e(t){if(t)return!1!==t.options.allowProjection?t.projection:e(t.parent)}(e.parent)),e.projection.setOptions({layoutId:s,layout:i,alwaysMeasureLayout:!!a||o&&uI(o),visualElement:e,animationType:"string"==typeof i?i:"both",initialPromotionConfig:n,crossfade:u,layoutScroll:l,layoutRoot:c})}(u.current,r,s,p);let m=(0,b.useRef)(!1);(0,b.useInsertionEffect)(()=>{h&&m.current&&h.update(r,l)});let f=r[uR],g=(0,b.useRef)(!!f&&!window.MotionHandoffIsComplete?.(f)&&window.MotionHasOptimisedAnimation?.(f));return uL(()=>{d.current=!0,h&&(m.current=!0,window.MotionIsMounted=!0,h.updateFeatures(),h.scheduleRenderMicrotask(),g.current&&h.animationState&&h.animationState.animateChanges())}),(0,b.useEffect)(()=>{h&&(!g.current&&h.animationState&&h.animationState.animateChanges(),g.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(f)}),g.current=!1),h.enteringChildren=void 0)}),h}(e,m,d,s,t.ProjectionNode,i)}return(0,v.jsxs)(um.Provider,{value:p,children:[l&&p.visualElement?(0,v.jsx)(l,{visualElement:p.visualElement,...d}):null,function(e,t,r,{latestValues:n},s,i=!1,a){let o=(a??uu(e)?function(e,t,r,n){let s=(0,b.useMemo)(()=>{let r=uy();return cK(r,t,cY(n),e.transformTemplate,e.style),{...r.attrs,style:{...r.style}}},[t]);if(e.style){let t={};ux(t,e.style,e),s.style={...t,...s.style}}return s}:function(e,t){let r,n,s={},i=(r=e.style||{},ux(n={},r,e),Object.assign(n,function({transformTemplate:e},t){return(0,b.useMemo)(()=>{let r=ug();return cG(r,t,e),Object.assign({},r.vars,r.style)},[t])}(e,t)),n);return e.drag&&!1!==e.dragListener&&(s.draggable=!1,i.userSelect=i.WebkitUserSelect=i.WebkitTouchCallout="none",i.touchAction=!0===e.drag?"none":`pan-${"x"===e.drag?"y":"x"}`),void 0===e.tabIndex&&(e.onTap||e.onTapStart||e.whileTap)&&(s.tabIndex=0),s.style=i,s})(t,n,s,e),l=function(e,t,r){let n={};for(let s in e)("values"!==s||"object"!=typeof e.values)&&(uw(s)||!0===r&&ub(s)||!t&&!ub(s)||e.draggable&&s.startsWith("onDrag"))&&(n[s]=e[s]);return n}(t,"string"==typeof e,i),c=e!==b.Fragment?{...l,...o,ref:r}:{},{children:u}=t,d=(0,b.useMemo)(()=>lM(u)?u.get():u,[u]);return(0,b.createElement)(e,{...c,children:d})}(e,r,(o=p.visualElement,c=(0,b.useRef)(n),(0,b.useInsertionEffect)(()=>{c.current=n}),u=(0,b.useRef)(null),(0,b.useCallback)(e=>{e&&m.onMount?.(e),o&&(e?o.mount(e):o.unmount());let t=c.current;if("function"==typeof t)if(e){let r=t(e);"function"==typeof r&&(u.current=r)}else u.current?(u.current(),u.current=null):t(e);else t&&(t.current=e)},[o])),m,h,t,i)]})}o.displayName=`motion.${"string"==typeof e?e:`create(${e.displayName??e.name??""})`}`;let l=(0,b.forwardRef)(o);return l[uP]=e,l}class uO{constructor(e){this.isMounted=!1,this.node=e}update(){}}function uz(e,t,r){let n=e.getProps();return cL(n,t,void 0!==r?r:n.custom,e)}function uF(e,t){return e?.[t]??e?.default??e}let uB=e=>Array.isArray(e);function u$(e,t){let r=e.getValue("willChange");if(lM(r)&&r.add)return r.add(t);if(!r&&l9.WillChange){let r=new l9.WillChange("auto");e.addValue("willChange",r),r.add(t)}}let uV=e=>1e3*e,uU=(e,t)=>r=>t(e(r)),uG=(...e)=>e.reduce(uU),uW={layout:0,mainThread:0,waapi:0};function uq(e,t,r){return(r<0&&(r+=1),r>1&&(r-=1),r<1/6)?e+(t-e)*6*r:r<.5?t:r<2/3?e+(t-e)*(2/3-r)*6:e}function uH(e,t){return r=>r>0?t:e}let uK=(e,t,r)=>{let n=e*e,s=r*(t*t-n)+n;return s<0?0:Math.sqrt(s)},uX=[lr,lt,lu];function uY(e){let t=uX.find(t=>t.test(e));if(lz(!!t,`'${e}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!t)return!1;let r=t.parse(e);return t===lu&&(r=function({hue:e,saturation:t,lightness:r,alpha:n}){e/=360,r/=100;let s=0,i=0,a=0;if(t/=100){let n=r<.5?r*(1+t):r+t-r*t,o=2*r-n;s=uq(o,n,e+1/3),i=uq(o,n,e),a=uq(o,n,e-1/3)}else s=i=a=r;return{red:Math.round(255*s),green:Math.round(255*i),blue:Math.round(255*a),alpha:n}}(r)),r}let uJ=(e,t)=>{let r=uY(e),n=uY(t);if(!r||!n)return uH(e,t);let s={...r};return e=>(s.red=uK(r.red,n.red,e),s.green=uK(r.green,n.green,e),s.blue=uK(r.blue,n.blue,e),s.alpha=c0(r.alpha,n.alpha,e),lt.transform(s))},uZ=new Set(["none","hidden"]);function uQ(e,t){return r=>c0(e,t,r)}function u0(e){return"number"==typeof e?uQ:"string"==typeof e?lU(e)?uH:ld.test(e)?uJ:u5:Array.isArray(e)?u1:"object"==typeof e?ld.test(e)?uJ:u2:uH}function u1(e,t){let r=[...e],n=r.length,s=e.map((e,r)=>u0(e)(e,t[r]));return e=>{for(let t=0;t<n;t++)r[t]=s[t](e);return r}}function u2(e,t){let r={...e,...t},n={};for(let s in r)void 0!==e[s]&&void 0!==t[s]&&(n[s]=u0(e[s])(e[s],t[s]));return e=>{for(let t in n)r[t]=n[t](e);return r}}let u5=(e,t)=>{let r=lb.createTransformer(t),n=lg(e),s=lg(t);if(!(n.indexes.var.length===s.indexes.var.length&&n.indexes.color.length===s.indexes.color.length&&n.indexes.number.length>=s.indexes.number.length))return lz(!0,`Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),uH(e,t);if(uZ.has(e)&&!s.values.length||uZ.has(t)&&!n.values.length)return uZ.has(e)?r=>r<=0?e:t:r=>r>=1?t:e;return uG(u1(function(e,t){let r=[],n={color:0,var:0,number:0};for(let s=0;s<t.values.length;s++){let i=t.types[s],a=e.indexes[i][n[i]],o=e.values[a]??0;r[s]=o,n[i]++}return r}(n,s),s.values),r)};function u3(e,t,r){return"number"==typeof e&&"number"==typeof t&&"number"==typeof r?c0(e,t,r):u0(e)(e,t)}let u6=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>ct.update(t,e),stop:()=>cr(t),now:()=>cn.isProcessing?cn.timestamp:cb.now()}},u4=(e,t,r=10)=>{let n="",s=Math.max(Math.round(t/r),2);for(let t=0;t<s;t++)n+=Math.round(1e4*e(t/(s-1)))/1e4+", ";return`linear(${n.substring(0,n.length-2)})`};function u8(e){let t=0,r=e.next(t);for(;!r.done&&t<2e4;)t+=50,r=e.next(t);return t>=2e4?1/0:t}function u9(e,t,r){var n,s;let i=Math.max(t-5,0);return n=r-e(i),(s=t-i)?1e3/s*n:0}let u7=.01,de=2,dt=.005,dr=.5;function dn(e,t){return e*Math.sqrt(1-t*t)}let ds=["duration","bounce"],di=["stiffness","damping","mass"];function da(e,t){return t.some(t=>void 0!==e[t])}function dl(e=.3,t=.3){let r,n="object"!=typeof e?{visualDuration:e,keyframes:[0,1],bounce:t}:e,{restSpeed:s,restDelta:i}=n,a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],l={done:!1,value:a},{stiffness:c,damping:u,mass:d,duration:h,velocity:p,isResolvedFromDuration:m}=function(e){let t={velocity:0,stiffness:100,damping:10,mass:1,isResolvedFromDuration:!1,...e};if(!da(e,di)&&da(e,ds))if(e.visualDuration){let r=2*Math.PI/(1.2*e.visualDuration),n=r*r,s=2*o1(.05,1,1-(e.bounce||0))*Math.sqrt(n);t={...t,mass:1,stiffness:n,damping:s}}else{let r=function({duration:e=800,bounce:t=.3,velocity:r=0,mass:n=1}){let s,i;lz(e<=uV(10),"Spring duration must be 10 seconds or less","spring-duration-limit");let a=1-t;a=o1(.05,1,a),e=o1(.01,10,e/1e3),a<1?(s=t=>{let n=t*a,s=n*e;return .001-(n-r)/dn(t,a)*Math.exp(-s)},i=t=>{let n=t*a*e,i=Math.pow(a,2)*Math.pow(t,2)*e,o=Math.exp(-n),l=dn(Math.pow(t,2),a);return(n*r+r-i)*o*(-s(t)+.001>0?-1:1)/l}):(s=t=>-.001+Math.exp(-t*e)*((t-r)*e+1),i=t=>e*e*(r-t)*Math.exp(-t*e));let o=function(e,t,r){let n=r;for(let r=1;r<12;r++)n-=e(n)/t(n);return n}(s,i,5/e);if(e=uV(e),isNaN(o))return{stiffness:100,damping:10,duration:e};{let t=Math.pow(o,2)*n;return{stiffness:t,damping:2*a*Math.sqrt(n*t),duration:e}}}(e);(t={...t,...r,mass:1}).isResolvedFromDuration=!0}return t}({...n,velocity:-((n.velocity||0)/1e3)}),f=p||0,g=u/(2*Math.sqrt(c*d)),x=o-a,y=Math.sqrt(c/d)/1e3,v=5>Math.abs(x);if(s||(s=v?u7:de),i||(i=v?dt:dr),g<1){let e=dn(y,g);r=t=>o-Math.exp(-g*y*t)*((f+g*y*x)/e*Math.sin(e*t)+x*Math.cos(e*t))}else if(1===g)r=e=>o-Math.exp(-y*e)*(x+(f+y*x)*e);else{let e=y*Math.sqrt(g*g-1);r=t=>{let r=Math.exp(-g*y*t),n=Math.min(e*t,300);return o-r*((f+g*y*x)*Math.sinh(n)+e*x*Math.cosh(n))/e}}let b={calculatedDuration:m&&h||null,next:e=>{let t=r(e);if(m)l.done=e>=h;else{let n=0===e?f:0;g<1&&(n=0===e?uV(f):u9(r,e,t));let a=Math.abs(o-t)<=i;l.done=Math.abs(n)<=s&&a}return l.value=l.done?o:t,l},toString:()=>{let e=Math.min(u8(b),2e4),t=u4(t=>b.next(e*t).value,e,30);return e+"ms "+t},toTransition:()=>{}};return b}function dc({keyframes:e,velocity:t=0,power:r=.8,timeConstant:n=325,bounceDamping:s=10,bounceStiffness:i=500,modifyTarget:a,min:o,max:l,restDelta:c=.5,restSpeed:u}){let d,h,p=e[0],m={done:!1,value:p},f=r*t,g=p+f,x=void 0===a?g:a(g);x!==g&&(f=x-p);let y=e=>-f*Math.exp(-e/n),v=e=>x+y(e),b=e=>{let t=y(e),r=v(e);m.done=Math.abs(t)<=c,m.value=m.done?x:r},w=e=>{let t;if(t=m.value,void 0!==o&&t<o||void 0!==l&&t>l){var r;d=e,h=dl({keyframes:[m.value,(r=m.value,void 0===o?l:void 0===l||Math.abs(o-r)<Math.abs(l-r)?o:l)],velocity:u9(v,e,m.value),damping:s,stiffness:i,restDelta:c,restSpeed:u})}};return w(0),{calculatedDuration:null,next:e=>{let t=!1;return(h||void 0!==d||(t=!0,b(e),w(e)),void 0!==d&&e>=d)?h.next(e-d):(t||b(e),m)}}}dl.applyToOptions=e=>{let t=function(e,t=100,r){let n=r({...e,keyframes:[0,t]}),s=Math.min(u8(n),2e4);return{type:"keyframes",ease:e=>n.next(s*e).value/t,duration:s/1e3}}(e,100,dl);return e.ease=t.ease,e.duration=uV(t.duration),e.type="keyframes",e};let du=(e,t,r)=>(((1-3*r+3*t)*e+(3*r-6*t))*e+3*t)*e;function dd(e,t,r,n){return e===t&&r===n?l8:s=>0===s||1===s?s:du(function(e,t,r,n,s){let i,a,o=0;do(i=du(a=t+(r-t)/2,n,s)-e)>0?r=a:t=a;while(Math.abs(i)>1e-7&&++o<12)return a}(s,0,1,e,r),t,n)}let dh=dd(.42,0,1,1),dp=dd(0,0,.58,1),dm=dd(.42,0,.58,1),df=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,dg=e=>t=>1-e(1-t),dx=dd(.33,1.53,.69,.99),dy=dg(dx),dv=df(dy),db=e=>(e*=2)<1?.5*dy(e):.5*(2-Math.pow(2,-10*(e-1))),dw=e=>1-Math.sin(Math.acos(e)),dk=dg(dw),dj=df(dw),dN=e=>Array.isArray(e)&&"number"==typeof e[0],dS={linear:l8,easeIn:dh,easeInOut:dm,easeOut:dp,circIn:dw,circInOut:dj,circOut:dk,backIn:dy,backInOut:dv,backOut:dx,anticipate:db},dC=e=>{if(dN(e)){lF(4===e.length,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");let[t,r,n,s]=e;return dd(t,r,n,s)}return"string"==typeof e?(lF(void 0!==dS[e],`Invalid easing type '${e}'`,"invalid-easing-type"),dS[e]):e},dA=(e,t,r)=>{let n=t-e;return 0===n?1:(r-e)/n};function d_({duration:e=300,keyframes:t,times:r,ease:n="easeInOut"}){var s;let i,a=Array.isArray(n)&&"number"!=typeof n[0]?n.map(dC):dC(n),o={done:!1,value:t[0]},l=function(e,t,{clamp:r=!0,ease:n,mixer:s}={}){let i=e.length;if(lF(i===t.length,"Both input and output ranges must be the same length","range-length"),1===i)return()=>t[0];if(2===i&&t[0]===t[1])return()=>t[1];let a=e[0]===e[1];e[0]>e[i-1]&&(e=[...e].reverse(),t=[...t].reverse());let o=function(e,t,r){let n=[],s=r||l9.mix||u3,i=e.length-1;for(let r=0;r<i;r++){let i=s(e[r],e[r+1]);t&&(i=uG(Array.isArray(t)?t[r]||l8:t,i)),n.push(i)}return n}(t,n,s),l=o.length,c=r=>{if(a&&r<e[0])return t[0];let n=0;if(l>1)for(;n<e.length-2&&!(r<e[n+1]);n++);let s=dA(e[n],e[n+1],r);return o[n](s)};return r?t=>c(o1(e[0],e[i-1],t)):c}((s=r&&r.length===t.length?r:(!function(e,t){let r=e[e.length-1];for(let n=1;n<=t;n++){let s=dA(0,t,n);e.push(c0(r,1,s))}}(i=[0],t.length-1),i),s.map(t=>t*e)),t,{ease:Array.isArray(a)?a:t.map(()=>a||dm).splice(0,t.length-1)});return{calculatedDuration:e,next:t=>(o.value=l(t),o.done=t>=e,o)}}let dT=e=>null!==e;function dE(e,{repeat:t,repeatType:r="loop"},n,s=1){let i=e.filter(dT),a=s<0||t&&"loop"!==r&&t%2==1?0:i.length-1;return a&&void 0!==n?n:i[a]}let dP={decay:dc,inertia:dc,tween:d_,keyframes:d_,spring:dl};function dR(e){"string"==typeof e.type&&(e.type=dP[e.type])}class dM{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}}let dI=e=>e/100;class dL extends dM{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==cb.now()&&this.tick(cb.now()),this.isStopped=!0,"idle"!==this.state&&(this.teardown(),this.options.onStop?.())},uW.mainThread++,this.options=e,this.initAnimation(),this.play(),!1===e.autoplay&&this.pause()}initAnimation(){let{options:e}=this;dR(e);let{type:t=d_,repeat:r=0,repeatDelay:n=0,repeatType:s,velocity:i=0}=e,{keyframes:a}=e,o=t||d_;o!==d_&&"number"!=typeof a[0]&&(this.mixKeyframes=uG(dI,u3(a[0],a[1])),a=[0,100]);let l=o({...e,keyframes:a});"mirror"===s&&(this.mirroredGenerator=o({...e,keyframes:[...a].reverse(),velocity:-i})),null===l.calculatedDuration&&(l.calculatedDuration=u8(l));let{calculatedDuration:c}=l;this.calculatedDuration=c,this.resolvedDuration=c+n,this.totalDuration=this.resolvedDuration*(r+1)-n,this.generator=l}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;null!==this.holdTime?this.currentTime=this.holdTime:this.currentTime=t}tick(e,t=!1){let{generator:r,totalDuration:n,mixKeyframes:s,mirroredGenerator:i,resolvedDuration:a,calculatedDuration:o}=this;if(null===this.startTime)return r.next(0);let{delay:l=0,keyframes:c,repeat:u,repeatType:d,repeatDelay:h,type:p,onUpdate:m,finalKeyframe:f}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-n/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-l*(this.playbackSpeed>=0?1:-1),x=this.playbackSpeed>=0?g<0:g>n;this.currentTime=Math.max(g,0),"finished"===this.state&&null===this.holdTime&&(this.currentTime=n);let y=this.currentTime,v=r;if(u){let e=Math.min(this.currentTime,n)/a,t=Math.floor(e),r=e%1;!r&&e>=1&&(r=1),1===r&&t--,(t=Math.min(t,u+1))%2&&("reverse"===d?(r=1-r,h&&(r-=h/a)):"mirror"===d&&(v=i)),y=o1(0,1,r)*a}let b=x?{done:!1,value:c[0]}:v.next(y);s&&(b.value=s(b.value));let{done:w}=b;x||null===o||(w=this.playbackSpeed>=0?this.currentTime>=n:this.currentTime<=0);let k=null===this.holdTime&&("finished"===this.state||"running"===this.state&&w);return k&&p!==dc&&(b.value=dE(c,this.options,f,this.speed)),m&&m(b.value),k&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return this.calculatedDuration/1e3}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+e/1e3}get time(){return this.currentTime/1e3}set time(e){e=uV(e),this.currentTime=e,null===this.startTime||null!==this.holdTime||0===this.playbackSpeed?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(cb.now());let t=this.playbackSpeed!==e;this.playbackSpeed=e,t&&(this.time=this.currentTime/1e3)}play(){if(this.isStopped)return;let{driver:e=u6,startTime:t}=this.options;this.driver||(this.driver=e(e=>this.tick(e))),this.options.onPlay?.();let r=this.driver.now();"finished"===this.state?(this.updateFinished(),this.startTime=r):null!==this.holdTime?this.startTime=r-this.holdTime:this.startTime||(this.startTime=t??r),"finished"===this.state&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(cb.now()),this.holdTime=this.currentTime}complete(){"running"!==this.state&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null,uW.mainThread--}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function dD(e){let t;return()=>(void 0===t&&(t=e()),t)}let dO=dD(()=>void 0!==window.ScrollTimeline),dz={},dF=(u=dD(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(e){return!1}return!0}),()=>dz.linearEasing??u()),dB=([e,t,r,n])=>`cubic-bezier(${e}, ${t}, ${r}, ${n})`,d$={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:dB([0,.65,.55,1]),circOut:dB([.55,0,1,.45]),backIn:dB([.31,.01,.66,-.59]),backOut:dB([.33,1.53,.69,.99])};function dV(e){return"function"==typeof e&&"applyToOptions"in e}class dU extends dM{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;const{element:t,name:r,keyframes:n,pseudoElement:s,allowFlatten:i=!1,finalKeyframe:a,onComplete:o}=e;this.isPseudoElement=!!s,this.allowFlatten=i,this.options=e,lF("string"!=typeof e.type,'Mini animate() doesn\'t support "type" as a string.',"mini-spring");const l=function({type:e,...t}){return dV(e)&&dF()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}(e);this.animation=function(e,t,r,{delay:n=0,duration:s=300,repeat:i=0,repeatType:a="loop",ease:o="easeOut",times:l}={},c){let u={[t]:r};l&&(u.offset=l);let d=function e(t,r){if(t)return"function"==typeof t?dF()?u4(t,r):"ease-out":dN(t)?dB(t):Array.isArray(t)?t.map(t=>e(t,r)||d$.easeOut):d$[t]}(o,s);Array.isArray(d)&&(u.easing=d);let h={delay:n,duration:s,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:i+1,direction:"reverse"===a?"alternate":"normal"};c&&(h.pseudoElement=c);let p=e.animate(u,h);return p}(t,r,n,l,s),!1===l.autoplay&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!s){let e=dE(n,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(e):r.startsWith("--")?t.style.setProperty(r,e):t.style[r]=e,this.animation.cancel()}o?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),"finished"===this.state&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch(e){}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;"idle"!==e&&"finished"!==e&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){return Number(this.animation.effect?.getComputedTiming?.().duration||0)/1e3}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+e/1e3}get time(){return(Number(this.animation.currentTime)||0)/1e3}set time(e){this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=uV(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return null!==this.finishedTime?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,observe:t}){return(this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&dO())?(this.animation.timeline=e,l8):t(this)}}let dG={anticipate:db,backInOut:dv,circInOut:dj};class dW extends dU{constructor(e){!function(e){"string"==typeof e.ease&&e.ease in dG&&(e.ease=dG[e.ease])}(e),dR(e),super(e),void 0!==e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:r,onComplete:n,element:s,...i}=this.options;if(!t)return;if(void 0!==e)return void t.set(e);let a=new dL({...i,autoplay:!1}),o=Math.max(10,cb.now()-this.startTime),l=o1(0,10,o-10);t.setWithVelocity(a.sample(Math.max(0,o-l)).value,a.sample(o).value,l),a.stop()}}let dq=(e,t)=>"zIndex"!==t&&!!("number"==typeof e||Array.isArray(e)||"string"==typeof e&&(lb.test(e)||"0"===e)&&!e.startsWith("url("));function dH(e){e.duration=0,e.type="keyframes"}let dK=new Set(["opacity","clipPath","filter","transform"]),dX=dD(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));class dY extends dM{constructor({autoplay:e=!0,delay:t=0,type:r="keyframes",repeat:n=0,repeatDelay:s=0,repeatType:i="loop",keyframes:a,name:o,motionValue:l,element:c,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=cb.now();const d={autoplay:e,delay:t,type:r,repeat:n,repeatDelay:s,repeatType:i,name:o,motionValue:l,element:c,...u},h=c?.KeyframeResolver||cd;this.keyframeResolver=new h(a,(e,t,r)=>this.onKeyframesResolved(e,t,d,!r),o,l,c),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,r,n){this.keyframeResolver=void 0;let{name:s,type:i,velocity:a,delay:o,isHandoff:l,onUpdate:c}=r;this.resolvedAt=cb.now(),!function(e,t,r,n){let s=e[0];if(null===s)return!1;if("display"===t||"visibility"===t)return!0;let i=e[e.length-1],a=dq(s,t),o=dq(i,t);return lz(a===o,`You are trying to animate ${t} from "${s}" to "${i}". "${a?i:s}" is not an animatable value.`,"value-not-animatable"),!!a&&!!o&&(function(e){let t=e[0];if(1===e.length)return!0;for(let r=0;r<e.length;r++)if(e[r]!==t)return!0}(e)||("spring"===r||dV(r))&&n)}(e,s,i,a)&&((l9.instantAnimations||!o)&&c?.(dE(e,r,t)),e[0]=e[e.length-1],dH(r),r.repeat=0);let u={startTime:n?this.resolvedAt&&this.resolvedAt-this.createdAt>40?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...r,keyframes:e},d=!l&&function(e){let{motionValue:t,name:r,repeatDelay:n,repeatType:s,damping:i,type:a}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;let{onUpdate:o,transformTemplate:l}=t.owner.getProps();return dX()&&r&&dK.has(r)&&("transform"!==r||!l)&&!o&&!n&&"mirror"!==s&&0!==i&&"inertia"!==a}(u),h=u.motionValue?.owner?.current,p=d?new dW({...u,element:h}):new dL(u);p.finished.then(()=>{this.notifyFinished()}).catch(l8),this.pendingTimeline&&(this.stopTimeline=p.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=p}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),cl=!0,cu(),cc(),cl=!1),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}let dJ={type:"spring",stiffness:500,damping:25,restSpeed:10},dZ={type:"keyframes",duration:.8},dQ={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},d0=e=>null!==e,d1=(e,t,r,n={},s,i)=>a=>{let o=uF(n,e)||{},l=o.delay||n.delay||0,{elapsed:c=0}=n;c-=uV(l);let u={keyframes:Array.isArray(r)?r:[null,r],ease:"easeOut",velocity:t.getVelocity(),...o,delay:-c,onUpdate:e=>{t.set(e),o.onUpdate&&o.onUpdate(e)},onComplete:()=>{a(),o.onComplete&&o.onComplete()},name:e,motionValue:t,element:i?void 0:s};!function({when:e,delay:t,delayChildren:r,staggerChildren:n,staggerDirection:s,repeat:i,repeatType:a,repeatDelay:o,from:l,elapsed:c,...u}){return!!Object.keys(u).length}(o)&&Object.assign(u,((e,{keyframes:t})=>t.length>2?dZ:o0.has(e)?e.startsWith("scale")?{type:"spring",stiffness:550,damping:0===t[1]?2*Math.sqrt(550):30,restSpeed:10}:dJ:dQ)(e,u)),u.duration&&(u.duration=uV(u.duration)),u.repeatDelay&&(u.repeatDelay=uV(u.repeatDelay)),void 0!==u.from&&(u.keyframes[0]=u.from);let d=!1;if(!1!==u.type&&(0!==u.duration||u.repeatDelay)||(dH(u),0===u.delay&&(d=!0)),(l9.instantAnimations||l9.skipAnimations)&&(d=!0,dH(u),u.delay=0),u.allowFlatten=!o.type&&!o.ease,d&&!i&&void 0!==t.get()){let e=function(e,{repeat:t,repeatType:r="loop"},n){let s=e.filter(d0),i=t&&"loop"!==r&&t%2==1?0:s.length-1;return s[i]}(u.keyframes,o);if(void 0!==e)return void ct.update(()=>{u.onUpdate(e),u.onComplete()})}return o.isSync?new dL(u):new dY(u)};function d2(e,t,{delay:r=0,transitionOverride:n,type:s}={}){let{transition:i=e.getDefaultTransition(),transitionEnd:a,...o}=t;n&&(i=n);let l=[],c=s&&e.animationState&&e.animationState.getState()[s];for(let t in o){let n=e.getValue(t,e.latestValues[t]??null),s=o[t];if(void 0===s||c&&function({protectedKeys:e,needsAnimating:t},r){let n=e.hasOwnProperty(r)&&!0!==t[r];return t[r]=!1,n}(c,t))continue;let a={delay:r,...uF(i||{},t)},u=n.get();if(void 0!==u&&!n.isAnimating&&!Array.isArray(s)&&s===u&&!a.velocity)continue;let d=!1;if(window.MotionHandoffAnimation){let r=e.props[uR];if(r){let e=window.MotionHandoffAnimation(r,t,ct);null!==e&&(a.startTime=e,d=!0)}}u$(e,t),n.start(d1(t,n,s,e.shouldReduceMotion&&lI.has(t)?{type:!1}:a,e,d));let h=n.animation;h&&l.push(h)}return a&&Promise.all(l).then(()=>{ct.update(()=>{a&&function(e,t){let{transitionEnd:r={},transition:n={},...s}=uz(e,t)||{};for(let t in s={...s,...r}){var i;let r=uB(i=s[t])?i[i.length-1]||0:i;e.hasValue(t)?e.getValue(t).set(r):e.addValue(t,ck(r))}}(e,a)})}),l}function d5(e,t,r,n=0,s=1){let i=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),a=e.size,o=(a-1)*n;return"function"==typeof r?r(i,a):1===s?i*n:o-i*n}function d3(e,t,r={}){let n=uz(e,t,"exit"===r.type?e.presenceContext?.custom:void 0),{transition:s=e.getDefaultTransition()||{}}=n||{};r.transitionOverride&&(s=r.transitionOverride);let i=n?()=>Promise.all(d2(e,n,r)):()=>Promise.resolve(),a=e.variantChildren&&e.variantChildren.size?(n=0)=>{let{delayChildren:i=0,staggerChildren:a,staggerDirection:o}=s;return function(e,t,r=0,n=0,s=0,i=1,a){let o=[];for(let l of e.variantChildren)l.notify("AnimationStart",t),o.push(d3(l,t,{...a,delay:r+("function"==typeof n?0:n)+d5(e.variantChildren,l,n,s,i)}).then(()=>l.notify("AnimationComplete",t)));return Promise.all(o)}(e,t,n,i,a,o,r)}:()=>Promise.resolve(),{when:o}=s;if(!o)return Promise.all([i(),a(r.delay)]);{let[e,t]="beforeChildren"===o?[i,a]:[a,i];return e().then(()=>t())}}let d6=cP.length;function d4(e,t){if(!Array.isArray(t))return!1;let r=t.length;if(r!==e.length)return!1;for(let n=0;n<r;n++)if(t[n]!==e[n])return!1;return!0}let d8=[...cE].reverse(),d9=cE.length;function d7(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function he(){return{animate:d7(!0),whileInView:d7(),whileHover:d7(),whileTap:d7(),whileDrag:d7(),whileFocus:d7(),exit:d7()}}let ht=0;function hr(e){return[e("x"),e("y")]}let hn=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function hs(e){return hn.has(e.tagName)||!0===e.isContentEditable}function hi(e,t,r,n={passive:!0}){return e.addEventListener(t,r,n),()=>e.removeEventListener(t,r)}let ha={x:!1,y:!1};function ho(e){return e.max-e.min}function hl(e,t,r,n=.5){e.origin=n,e.originPoint=c0(t.min,t.max,e.origin),e.scale=ho(r)/ho(t),e.translate=c0(r.min,r.max,e.origin)-e.originPoint,(e.scale>=.9999&&e.scale<=1.0001||isNaN(e.scale))&&(e.scale=1),(e.translate>=-.01&&e.translate<=.01||isNaN(e.translate))&&(e.translate=0)}function hc(e,t,r,n){hl(e.x,t.x,r.x,n?n.originX:void 0),hl(e.y,t.y,r.y,n?n.originY:void 0)}function hu(e,t,r){e.min=r.min+t.min,e.max=e.min+ho(t)}function hd(e,t,r){e.min=t.min-r.min,e.max=e.min+ho(t)}function hh(e,t,r){hd(e.x,t.x,r.x),hd(e.y,t.y,r.y)}let hp=e=>"mouse"===e.pointerType?"number"!=typeof e.button||e.button<=0:!1!==e.isPrimary;function hm(e){return{point:{x:e.pageX,y:e.pageY}}}function hf(e,t,r,n){return hi(e,t,e=>hp(e)&&r(e,hm(e)),n)}let hg=({current:e})=>e?e.ownerDocument.defaultView:null,hx=(e,t)=>Math.abs(e-t),hy=new Set(["auto","scroll"]);class hv{constructor(e,t,{transformPagePoint:r,contextWindow:n=window,dragSnapToOrigin:s=!1,distanceThreshold:i=3,element:a}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{var e,t;if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let r=hk(this.lastMoveEventInfo,this.history),n=null!==this.startEvent,s=(e=r.offset,t={x:0,y:0},Math.sqrt(hx(e.x,t.x)**2+hx(e.y,t.y)**2)>=this.distanceThreshold);if(!n&&!s)return;let{point:i}=r,{timestamp:a}=cn;this.history.push({...i,timestamp:a});let{onStart:o,onMove:l}=this.handlers;n||(o&&o(this.lastMoveEvent,r),this.startEvent=this.lastMoveEvent),l&&l(this.lastMoveEvent,r)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastMoveEventInfo=hb(t,this.transformPagePoint),ct.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:r,onSessionEnd:n,resumeAnimation:s}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&s&&s(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let i=hk("pointercancel"===e.type?this.lastMoveEventInfo:hb(t,this.transformPagePoint),this.history);this.startEvent&&r&&r(e,i),n&&n(e,i)},!hp(e))return;this.dragSnapToOrigin=s,this.handlers=t,this.transformPagePoint=r,this.distanceThreshold=i,this.contextWindow=n||window;const o=hb(hm(e),this.transformPagePoint),{point:l}=o,{timestamp:c}=cn;this.history=[{...l,timestamp:c}];const{onSessionStart:u}=t;u&&u(e,hk(o,this.history)),this.removeListeners=uG(hf(this.contextWindow,"pointermove",this.handlePointerMove),hf(this.contextWindow,"pointerup",this.handlePointerUp),hf(this.contextWindow,"pointercancel",this.handlePointerUp)),a&&this.startScrollTracking(a)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(hy.has(e.overflowX)||hy.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0,passive:!0}),window.addEventListener("scroll",this.onWindowScroll,{passive:!0}),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let r=e===window,n=r?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},s={x:n.x-t.x,y:n.y-t.y};(0!==s.x||0!==s.y)&&(r?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=s.x,this.lastMoveEventInfo.point.y+=s.y):this.history.length>0&&(this.history[0].x-=s.x,this.history[0].y-=s.y),this.scrollPositions.set(e,n),ct.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),cr(this.updatePoint)}}function hb(e,t){return t?{point:t(e.point)}:e}function hw(e,t){return{x:e.x-t.x,y:e.y-t.y}}function hk({point:e},t){return{point:e,delta:hw(e,hj(t)),offset:hw(e,t[0]),velocity:function(e,t){if(e.length<2)return{x:0,y:0};let r=e.length-1,n=null,s=hj(e);for(;r>=0&&(n=e[r],!(s.timestamp-n.timestamp>uV(.1)));)r--;if(!n)return{x:0,y:0};let i=(s.timestamp-n.timestamp)/1e3;if(0===i)return{x:0,y:0};let a={x:(s.x-n.x)/i,y:(s.y-n.y)/i};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}(t,.1)}}function hj(e){return e[e.length-1]}function hN(e,t,r){return{min:void 0!==t?e.min+t:void 0,max:void 0!==r?e.max+r-(e.max-e.min):void 0}}function hS(e,t){let r=t.min-e.min,n=t.max-e.max;return t.max-t.min<e.max-e.min&&([r,n]=[n,r]),{min:r,max:n}}function hC(e,t,r){return{min:hA(e,t),max:hA(e,r)}}function hA(e,t){return"number"==typeof e?e:e[t]||0}let h_=new WeakMap;class hT{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=lR(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:r}={}){let{presenceContext:n}=this.visualElement;if(n&&!1===n.isPresent)return;let s=e=>{t?(this.stopAnimation(),this.snapToCursor(hm(e).point)):this.pauseAnimation()},i=(e,t)=>{this.stopAnimation();let{drag:r,dragPropagation:n,onDragStart:s}=this.getProps();if(r&&!n&&(this.openDragLock&&this.openDragLock(),this.openDragLock=function(e){if("x"===e||"y"===e)if(ha[e])return null;else return ha[e]=!0,()=>{ha[e]=!1};return ha.x||ha.y?null:(ha.x=ha.y=!0,()=>{ha.x=ha.y=!1})}(r),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),hr(e=>{let t=this.getAxisMotionValue(e).get()||0;if(li.test(t)){let{projection:r}=this.visualElement;if(r&&r.layout){let n=r.layout.layoutBox[e];n&&(t=ho(n)*(parseFloat(t)/100))}}this.originPoint[e]=t}),s&&ct.postRender(()=>s(e,t)),u$(this.visualElement,"transform");let{animationState:i}=this.visualElement;i&&i.setActive("whileDrag",!0)},a=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:r,dragDirectionLock:n,onDirectionLock:s,onDrag:i}=this.getProps();if(!r&&!this.openDragLock)return;let{offset:a}=t;if(n&&null===this.currentDirection){this.currentDirection=function(e,t=10){let r=null;return Math.abs(e.y)>t?r="y":Math.abs(e.x)>t&&(r="x"),r}(a),null!==this.currentDirection&&s&&s(this.currentDirection);return}this.updateAxis("x",t.point,a),this.updateAxis("y",t.point,a),this.visualElement.render(),i&&i(e,t)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},l=()=>hr(e=>"paused"===this.getAnimationState(e)&&this.getAxisMotionValue(e).animation?.play()),{dragSnapToOrigin:c}=this.getProps();this.panSession=new hv(e,{onSessionStart:s,onStart:i,onMove:a,onSessionEnd:o,resumeAnimation:l},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:r,contextWindow:hg(this.visualElement),element:this.visualElement.current})}stop(e,t){let r=e||this.latestPointerEvent,n=t||this.latestPanInfo,s=this.isDragging;if(this.cancel(),!s||!n||!r)return;let{velocity:i}=n;this.startAnimation(i);let{onDragEnd:a}=this.getProps();a&&ct.postRender(()=>a(r,n))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,r){let{drag:n}=this.getProps();if(!r||!hE(e,n,this.currentDirection))return;let s=this.getAxisMotionValue(e),i=this.originPoint[e]+r[e];this.constraints&&this.constraints[e]&&(i=function(e,{min:t,max:r},n){return void 0!==t&&e<t?e=n?c0(t,e,n.min):Math.max(e,t):void 0!==r&&e>r&&(e=n?c0(r,e,n.max):Math.min(e,r)),e}(i,this.constraints[e],this.elastic[e])),s.set(i)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,n=this.constraints;e&&uI(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&r?this.constraints=function(e,{top:t,left:r,bottom:n,right:s}){return{x:hN(e.x,r,s),y:hN(e.y,t,n)}}(r.layoutBox,e):this.constraints=!1,this.elastic=function(e=.35){return!1===e?e=0:!0===e&&(e=.35),{x:hC(e,"left","right"),y:hC(e,"top","bottom")}}(t),n!==this.constraints&&r&&this.constraints&&!this.hasMutatedConstraints&&hr(e=>{var t,n;let s;!1!==this.constraints&&this.getAxisMotionValue(e)&&(this.constraints[e]=(t=r.layoutBox[e],n=this.constraints[e],s={},void 0!==n.min&&(s.min=n.min-t.min),void 0!==n.max&&(s.max=n.max-t.min),s))})}resolveRefConstraints(){var e;let{dragConstraints:t,onMeasureDragConstraints:r}=this.getProps();if(!t||!uI(t))return!1;let n=t.current;lF(null!==n,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");let{projection:s}=this.visualElement;if(!s||!s.layout)return!1;let i=function(e,t,r){let n=uo(e,r),{scroll:s}=t;return s&&(us(n.x,s.offset.x),us(n.y,s.offset.y)),n}(n,s.root,this.visualElement.getTransformPagePoint()),a=(e=s.layout.layoutBox,{x:hS(e.x,i.x),y:hS(e.y,i.y)});if(r){let e=r(function({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}(a));this.hasMutatedConstraints=!!e,e&&(a=c4(e))}return a}startAnimation(e){let{drag:t,dragMomentum:r,dragElastic:n,dragTransition:s,dragSnapToOrigin:i,onDragTransitionEnd:a}=this.getProps(),o=this.constraints||{};return Promise.all(hr(a=>{if(!hE(a,t,this.currentDirection))return;let l=o&&o[a]||{};i&&(l={min:0,max:0});let c={type:"inertia",velocity:r?e[a]:0,bounceStiffness:n?200:1e6,bounceDamping:n?40:1e7,timeConstant:750,restDelta:1,restSpeed:10,...s,...l};return this.startAxisValueAnimation(a,c)})).then(a)}startAxisValueAnimation(e,t){let r=this.getAxisMotionValue(e);return u$(this.visualElement,e),r.start(d1(e,r,0,t,this.visualElement,!1))}stopAnimation(){hr(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){hr(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`,r=this.visualElement.getProps();return r[t]||this.visualElement.getValue(e,(r.initial?r.initial[e]:void 0)||0)}snapToCursor(e){hr(t=>{let{drag:r}=this.getProps();if(!hE(t,r,this.currentDirection))return;let{projection:n}=this.visualElement,s=this.getAxisMotionValue(t);if(n&&n.layout){let{min:r,max:i}=n.layout.layoutBox[t],a=s.get()||0;s.set(e[t]-c0(r,i,.5)+a)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:r}=this.visualElement;if(!uI(t)||!r||!this.constraints)return;this.stopAnimation();let n={x:0,y:0};hr(e=>{let t=this.getAxisMotionValue(e);if(t&&!1!==this.constraints){var r,s;let i,a,o,l=t.get();n[e]=(r={min:l,max:l},s=this.constraints[e],i=.5,a=ho(r),(o=ho(s))>a?i=dA(s.min,s.max-a,r.min):a>o&&(i=dA(r.min,r.max-o,s.min)),o1(0,1,i))}});let{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.resolveConstraints(),hr(t=>{if(!hE(t,e,null))return;let r=this.getAxisMotionValue(t),{min:s,max:i}=this.constraints[t];r.set(c0(s,i,n[t]))})}addListeners(){if(!this.visualElement.current)return;h_.set(this.visualElement,this);let e=this.visualElement.current,t=hf(e,"pointerdown",t=>{let{drag:r,dragListener:n=!0}=this.getProps(),s=t.target,i=s!==e&&hs(s);r&&n&&!i&&this.start(t)}),r=()=>{let{dragConstraints:e}=this.getProps();uI(e)&&e.current&&(this.constraints=this.resolveRefConstraints())},{projection:n}=this.visualElement,s=n.addEventListener("measure",r);n&&!n.layout&&(n.root&&n.root.updateScroll(),n.updateLayout()),ct.read(r);let i=hi(window,"resize",()=>this.scalePositionWithinConstraints()),a=n.addEventListener("didUpdate",({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(hr(t=>{let r=this.getAxisMotionValue(t);r&&(this.originPoint[t]+=e[t].translate,r.set(r.get()+e[t].translate))}),this.visualElement.render())});return()=>{i(),t(),s(),a&&a()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:r=!1,dragPropagation:n=!1,dragConstraints:s=!1,dragElastic:i=.35,dragMomentum:a=!0}=e;return{...e,drag:t,dragDirectionLock:r,dragPropagation:n,dragConstraints:s,dragElastic:i,dragMomentum:a}}}function hE(e,t,r){return(!0===t||t===e)&&(null===r||r===e)}let hP=e=>(t,r)=>{e&&ct.postRender(()=>e(t,r))},hR={hasAnimatedSinceResize:!0,hasEverUpdated:!1};var hM=b;let hI=!1;class hL extends hM.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:r,layoutId:n}=this.props,{projection:s}=e;s&&(t.group&&t.group.add(s),r&&r.register&&n&&r.register(s),hI&&s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),hR.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:r,drag:n,isPresent:s}=this.props,{projection:i}=r;return i&&(i.isPresent=s,e.layoutDependency!==t&&i.setOptions({...i.options,layoutDependency:t}),hI=!0,n||e.layoutDependency!==t||void 0===t||e.isPresent!==s?i.willUpdate():this.safeToRemove(),e.isPresent!==s&&(s?i.promote():i.relegate()||ct.postRender(()=>{let e=i.getStack();e&&e.members.length||this.safeToRemove()}))),null}componentDidUpdate(){let{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),cy.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:r}=this.props,{projection:n}=e;hI=!0,n&&(n.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(n),r&&r.deregister&&r.deregister(n))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}}function hD(e){let[t,r]=function(e=!0){let t=(0,b.useContext)(uj);if(null===t)return[!0,null];let{isPresent:r,onExitComplete:n,register:s}=t,i=(0,b.useId)();(0,b.useEffect)(()=>{if(e)return s(i)},[e]);let a=(0,b.useCallback)(()=>e&&n&&n(i),[i,n,e]);return!r&&n?[!1,a]:[!0]}(),n=(0,hM.useContext)(ud);return(0,v.jsx)(hL,{...e,layoutGroup:n,switchLayoutGroup:(0,hM.useContext)(uM),isPresent:t,safeToRemove:r})}function hO(e,t,r,n,s){return e-=t,e=n+1/r*(e-n),void 0!==s&&(e=n+1/s*(e-n)),e}function hz(e,t,[r,n,s],i,a){!function(e,t=0,r=1,n=.5,s,i=e,a=e){if(li.test(t)&&(t=parseFloat(t),t=c0(a.min,a.max,t/100)-a.min),"number"!=typeof t)return;let o=c0(i.min,i.max,n);e===i&&(o-=t),e.min=hO(e.min,t,r,o,s),e.max=hO(e.max,t,r,o,s)}(e,t[r],t[n],t[s],t.scale,i,a)}let hF=["x","scaleX","originX"],hB=["y","scaleY","originY"];function h$(e,t,r,n){hz(e.x,t,hF,r?r.x:void 0,n?n.x:void 0),hz(e.y,t,hB,r?r.y:void 0,n?n.y:void 0)}function hV(e,t){e.min=t.min,e.max=t.max}function hU(e,t){hV(e.x,t.x),hV(e.y,t.y)}function hG(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function hW(e){return 0===e.translate&&1===e.scale}function hq(e){return hW(e.x)&&hW(e.y)}function hH(e,t){return e.min===t.min&&e.max===t.max}function hK(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function hX(e,t){return hK(e.x,t.x)&&hK(e.y,t.y)}function hY(e){return ho(e.x)/ho(e.y)}function hJ(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}let hZ=["TopLeft","TopRight","BottomLeft","BottomRight"],hQ=hZ.length,h0=e=>"string"==typeof e?parseFloat(e):e,h1=e=>"number"==typeof e||la.test(e);function h2(e,t){return void 0!==e[t]?e[t]:e.borderRadius}let h5=h6(0,.5,dk),h3=h6(.5,.95,l8);function h6(e,t,r){return n=>n<e?0:n>t?1:r(dA(e,t,n))}function h4(e){return"object"==typeof e&&null!==e}function h8(e){return h4(e)&&"ownerSVGElement"in e}let h9=(e,t)=>e.depth-t.depth;class h7{constructor(){this.children=[],this.isDirty=!1}add(e){cf(this.children,e),this.isDirty=!0}remove(e){cg(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(h9),this.isDirty=!1,this.children.forEach(e)}}class pe{constructor(){this.members=[]}add(e){cf(this.members,e),e.scheduleRender()}remove(e){if(cg(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){let t,r=this.members.findIndex(t=>e===t);if(0===r)return!1;for(let e=r;e>=0;e--){let r=this.members[e];if(!1!==r.isPresent){t=r;break}}return!!t&&(this.promote(t),!0)}promote(e,t){let r=this.lead;if(e!==r&&(this.prevLead=r,this.lead=e,e.show(),r)){r.instance&&r.scheduleRender(),e.scheduleRender();let n=r.options.layoutDependency,s=e.options.layoutDependency;(void 0===n||void 0===s||n!==s)&&(e.resumeFrom=r,t&&(e.resumeFrom.preserveOpacity=!0),r.snapshot&&(e.snapshot=r.snapshot,e.snapshot.latestValues=r.animationValues||r.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0));let{crossfade:i}=e.options;!1===i&&r.hide()}}exitAnimationComplete(){this.members.forEach(e=>{let{options:t,resumingFrom:r}=e;t.onExitComplete&&t.onExitComplete(),r&&r.options.onExitComplete&&r.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}let pt=["","X","Y","Z"],pr=0;function pn(e,t,r,n){let{latestValues:s}=t;s[e]&&(r[e]=s[e],t.setStaticValue(e,0),n&&(n[e]=0))}function ps({attachResizeListener:e,defaultParent:t,measureScroll:r,checkIsScrollRoot:n,resetTransform:s}){return class{constructor(e={},r=t?.()){this.id=pr++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(po),this.nodes.forEach(pm),this.nodes.forEach(pf),this.nodes.forEach(pl)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=r?r.root||r:this,this.path=r?[...r.path,r]:[],this.parent=r,this.depth=r?r.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new h7)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new cx),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let r=this.eventHandlers.get(e);r&&r.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=h8(t)&&!(h8(t)&&"svg"===t.tagName),this.instance=t;let{layoutId:r,layout:n,visualElement:s}=this.options;if(s&&!s.current&&s.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(n||r)&&(this.isLayoutDirty=!0),e){let r,n=0,s=()=>this.root.updateBlockedByResize=!1;ct.read(()=>{n=window.innerWidth}),e(t,()=>{let e=window.innerWidth;if(e!==n){let t,i;n=e,this.root.updateBlockedByResize=!0,r&&r(),t=cb.now(),i=({timestamp:e})=>{let r=e-t;r>=250&&(cr(i),s(r-250))},ct.setup(i,!0),r=()=>cr(i),hR.hasAnimatedSinceResize&&(hR.hasAnimatedSinceResize=!1,this.nodes.forEach(pp))}})}r&&this.root.registerSharedNode(r,this),!1!==this.options.animate&&s&&(r||n)&&this.addEventListener("didUpdate",({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:r,layout:n})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let i=this.options.transition||s.getDefaultTransition()||pw,{onLayoutAnimationStart:a,onLayoutAnimationComplete:o}=s.getProps(),l=!this.targetLayout||!hX(this.targetLayout,n),c=!t&&r;if(this.options.layoutRoot||this.resumeFrom||c||t&&(l||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...uF(i,"layout"),onPlay:a,onComplete:o};(s.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,c)}else t||pp(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=n})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),cr(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){!this.isUpdateBlocked()&&(this.isUpdating=!0,this.nodes&&this.nodes.forEach(pg),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&function e(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;let{visualElement:r}=t.options;if(!r)return;let n=r.props[uR];if(window.MotionHasOptimisedAnimation(n,"transform")){let{layout:e,layoutId:r}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",ct,!(e||r))}let{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&e(s)}(this),this.root.isUpdating||this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,t.updateScroll("snapshot"),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:r}=this.options;if(void 0===t&&!r)return;let n=this.getTransformTemplate();this.prevTransformTemplateValue=n?n(this.latestValues,""):void 0,this.updateSnapshot(),e&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(pu);return}if(this.animationId<=this.animationCommitId)return void this.nodes.forEach(pd);this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(ph),this.nodes.forEach(pi),this.nodes.forEach(pa)):this.nodes.forEach(pd),this.clearAllSnapshots();let e=cb.now();cn.delta=o1(0,1e3/60,e-cn.timestamp),cn.timestamp=e,cn.isProcessing=!0,cs.update.process(cn),cs.preRender.process(cn),cs.render.process(cn),cn.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,cy.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(pc),this.sharedNodes.forEach(px)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,ct.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){ct.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),!this.snapshot||ho(this.snapshot.measuredBox.x)||ho(this.snapshot.measuredBox.y)||(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected=lR(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify("LayoutMeasure",this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e="measure"){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=n(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:r(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!s)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!hq(this.projectionDelta),r=this.getTransformTemplate(),n=r?r(this.latestValues,""):void 0,i=n!==this.prevTransformTemplateValue;e&&this.instance&&(t||c7(this.latestValues)||i)&&(s(this.instance,n),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){var t;let r=this.measurePageBox(),n=this.removeElementScroll(r);return e&&(n=this.removeTransform(n)),pN((t=n).x),pN(t.y),{animationId:this.root.animationId,measuredBox:r,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return lR();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(pC))){let{scroll:e}=this.root;e&&(us(t.x,e.offset.x),us(t.y,e.offset.y))}return t}removeElementScroll(e){let t=lR();if(hU(t,e),this.scroll?.wasRoot)return t;for(let r=0;r<this.path.length;r++){let n=this.path[r],{scroll:s,options:i}=n;n!==this.root&&s&&i.layoutScroll&&(s.wasRoot&&hU(t,e),us(t.x,s.offset.x),us(t.y,s.offset.y))}return t}applyTransform(e,t=!1){let r=lR();hU(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&ua(r,{x:-n.scroll.offset.x,y:-n.scroll.offset.y}),c7(n.latestValues)&&ua(r,n.latestValues)}return c7(this.latestValues)&&ua(r,this.latestValues),r}removeTransform(e){let t=lR();hU(t,e);for(let e=0;e<this.path.length;e++){let r=this.path[e];if(!r.instance||!c7(r.latestValues))continue;c9(r.latestValues)&&r.updateSnapshot();let n=lR();hU(n,r.measurePageBox()),h$(t,r.latestValues,r.snapshot?r.snapshot.layoutBox:void 0,n)}return c7(this.latestValues)&&h$(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:void 0===e.crossfade||e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==cn.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=t.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=t.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=t.isSharedProjectionDirty);let r=!!this.resumingFrom||this!==t;if(!(e||r&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:n,layoutId:s}=this.options;if(!this.layout||!(n||s))return;this.resolvedRelativeTargetAt=cn.timestamp;let i=this.getClosestProjectingParent();if(i&&this.linkedParentVersion!==i.layoutVersion&&!i.options.layoutRoot&&this.removeRelativeTarget(),this.targetDelta||this.relativeTarget||(i&&i.layout?this.createRelativeTarget(i,this.layout.layoutBox,i.layout.layoutBox):this.removeRelativeTarget()),this.relativeTarget||this.targetDelta){if(this.target||(this.target=lR(),this.targetWithTransforms=lR()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target){var a,o,l;this.forceRelativeParentToResolveTarget(),a=this.target,o=this.relativeTarget,l=this.relativeParent.target,hu(a.x,o.x,l.x),hu(a.y,o.y,l.y)}else this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):hU(this.target,this.layout.layoutBox),un(this.target,this.targetDelta)):hU(this.target,this.layout.layoutBox);this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,i&&!!i.resumingFrom==!!this.resumingFrom&&!i.options.layoutScroll&&i.target&&1!==this.animationProgress?this.createRelativeTarget(i,this.target,i.target):this.relativeParent=this.relativeTarget=void 0)}}getClosestProjectingParent(){if(!(!this.parent||c9(this.parent.latestValues)||ue(this.parent.latestValues)))if(this.parent.isProjecting())return this.parent;else return this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,r){this.relativeParent=e,this.linkedParentVersion=e.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=lR(),this.relativeTargetOrigin=lR(),hh(this.relativeTargetOrigin,t,r),hU(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,r=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(r=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(r=!1),this.resolvedRelativeTargetAt===cn.timestamp&&(r=!1),r)return;let{layout:n,layoutId:s}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(n||s))return;hU(this.layoutCorrected,this.layout.layoutBox);let i=this.treeScale.x,a=this.treeScale.y;!function(e,t,r,n=!1){let s,i,a=r.length;if(a){t.x=t.y=1;for(let o=0;o<a;o++){i=(s=r[o]).projectionDelta;let{visualElement:a}=s.options;(!a||!a.props.style||"contents"!==a.props.style.display)&&(n&&s.options.layoutScroll&&s.scroll&&s!==s.root&&ua(e,{x:-s.scroll.offset.x,y:-s.scroll.offset.y}),i&&(t.x*=i.x.scale,t.y*=i.y.scale,un(e,i)),n&&c7(s.latestValues)&&ua(e,s.latestValues))}t.x<1.0000000000001&&t.x>.999999999999&&(t.x=1),t.y<1.0000000000001&&t.y>.999999999999&&(t.y=1)}}(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(1!==this.treeScale.x||1!==this.treeScale.y)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=lR());let{target:o}=e;if(!o){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}this.projectionDelta&&this.prevProjectionDelta?(hG(this.prevProjectionDelta.x,this.projectionDelta.x),hG(this.prevProjectionDelta.y,this.projectionDelta.y)):this.createProjectionDeltas(),hc(this.projectionDelta,this.layoutCorrected,o,this.latestValues),this.treeScale.x===i&&this.treeScale.y===a&&hJ(this.projectionDelta.x,this.prevProjectionDelta.x)&&hJ(this.projectionDelta.y,this.prevProjectionDelta.y)||(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",o))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=lE(),this.projectionDelta=lE(),this.projectionDeltaWithTransform=lE()}setAnimationOrigin(e,t=!1){let r,n=this.snapshot,s=n?n.latestValues:{},i={...this.latestValues},a=lE();this.relativeParent&&this.relativeParent.options.layoutRoot||(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let o=lR(),l=(n?n.source:void 0)!==(this.layout?this.layout.source:void 0),c=this.getStack(),u=!c||c.members.length<=1,d=!!(l&&!u&&!0===this.options.crossfade&&!this.path.some(pb));this.animationProgress=0,this.mixTargetDelta=t=>{let n=t/1e3;if(py(a.x,e.x,n),py(a.y,e.y,n),this.setTargetDelta(a),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout){var c,h,p,m,f,g;hh(o,this.layout.layoutBox,this.relativeParent.layout.layoutBox),p=this.relativeTarget,m=this.relativeTargetOrigin,f=o,g=n,pv(p.x,m.x,f.x,g),pv(p.y,m.y,f.y,g),r&&(c=this.relativeTarget,h=r,hH(c.x,h.x)&&hH(c.y,h.y))&&(this.isProjectionDirty=!1),r||(r=lR()),hU(r,this.relativeTarget)}l&&(this.animationValues=i,function(e,t,r,n,s,i){s?(e.opacity=c0(0,r.opacity??1,h5(n)),e.opacityExit=c0(t.opacity??1,0,h3(n))):i&&(e.opacity=c0(t.opacity??1,r.opacity??1,n));for(let s=0;s<hQ;s++){let i=`border${hZ[s]}Radius`,a=h2(t,i),o=h2(r,i);(void 0!==a||void 0!==o)&&(a||(a=0),o||(o=0),0===a||0===o||h1(a)===h1(o)?(e[i]=Math.max(c0(h0(a),h0(o),n),0),(li.test(o)||li.test(a))&&(e[i]+="%")):e[i]=o)}(t.rotate||r.rotate)&&(e.rotate=c0(t.rotate||0,r.rotate||0,n))}(i,s,this.latestValues,n,d,u)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(1e3*!!this.options.layoutRoot)}startAnimation(e){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(cr(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ct.update(()=>{var t,r,n;let s;hR.hasAnimatedSinceResize=!0,uW.layout++,this.motionValue||(this.motionValue=ck(0)),this.currentAnimation=(t=this.motionValue,r=[0,1e3],n={...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onStop:()=>{uW.layout--},onComplete:()=>{uW.layout--,e.onComplete&&e.onComplete(),this.completeAnimation()}},(s=lM(t)?t:ck(t)).start(d1("",s,r,n)),s.animation),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(1e3),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,target:r,layout:n,latestValues:s}=e;if(t&&r&&n){if(this!==e&&this.layout&&n&&pS(this.options.animationType,this.layout.layoutBox,n.layoutBox)){r=this.target||lR();let t=ho(this.layout.layoutBox.x);r.x.min=e.target.x.min,r.x.max=r.x.min+t;let n=ho(this.layout.layoutBox.y);r.y.min=e.target.y.min,r.y.max=r.y.min+n}hU(t,r),ua(t,s),hc(this.projectionDeltaWithTransform,this.layoutCorrected,t,s)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new pe),this.sharedNodes.get(e).add(t);let r=t.options.initialPromotionConfig;t.promote({transition:r?r.transition:void 0,preserveFollowOpacity:r&&r.shouldPreserveFollowOpacity?r.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return!e||e.lead===this}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:r}={}){let n=this.getStack();n&&n.promote(this,r),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return!!e&&e.relegate(this)}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:r}=e;if((r.z||r.rotate||r.rotateX||r.rotateY||r.rotateZ||r.skewX||r.skewY)&&(t=!0),!t)return;let n={};r.z&&pn("z",e,n,this.animationValues);for(let t=0;t<pt.length;t++)pn(`rotate${pt[t]}`,e,n,this.animationValues),pn(`skew${pt[t]}`,e,n,this.animationValues);for(let t in e.render(),n)e.setStaticValue(t,n[t]),this.animationValues&&(this.animationValues[t]=n[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility="hidden";return}let r=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility="",e.opacity="",e.pointerEvents=uk(t?.pointerEvents)||"",e.transform=r?r(this.latestValues,""):"none";return}let n=this.getLead();if(!this.projectionDelta||!this.layout||!n.target){this.options.layoutId&&(e.opacity=void 0!==this.latestValues.opacity?this.latestValues.opacity:1,e.pointerEvents=uk(t?.pointerEvents)||""),this.hasProjected&&!c7(this.latestValues)&&(e.transform=r?r({},""):"none",this.hasProjected=!1);return}e.visibility="";let s=n.animationValues||n.latestValues;this.applyTransformsToTarget();let i=function(e,t,r){let n="",s=e.x.translate/t.x,i=e.y.translate/t.y,a=r?.z||0;if((s||i||a)&&(n=`translate3d(${s}px, ${i}px, ${a}px) `),(1!==t.x||1!==t.y)&&(n+=`scale(${1/t.x}, ${1/t.y}) `),r){let{transformPerspective:e,rotate:t,rotateX:s,rotateY:i,skewX:a,skewY:o}=r;e&&(n=`perspective(${e}px) ${n}`),t&&(n+=`rotate(${t}deg) `),s&&(n+=`rotateX(${s}deg) `),i&&(n+=`rotateY(${i}deg) `),a&&(n+=`skewX(${a}deg) `),o&&(n+=`skewY(${o}deg) `)}let o=e.x.scale*t.x,l=e.y.scale*t.y;return(1!==o||1!==l)&&(n+=`scale(${o}, ${l})`),n||"none"}(this.projectionDeltaWithTransform,this.treeScale,s);r&&(i=r(s,i)),e.transform=i;let{x:a,y:o}=this.projectionDelta;for(let t in e.transformOrigin=`${100*a.origin}% ${100*o.origin}% 0`,n.animationValues?e.opacity=n===this?s.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:s.opacityExit:e.opacity=n===this?void 0!==s.opacity?s.opacity:"":void 0!==s.opacityExit?s.opacityExit:0,c1){if(void 0===s[t])continue;let{correct:r,applyTo:a,isCSSVariable:o}=c1[t],l="none"===i?s[t]:r(s[t],n);if(a){let t=a.length;for(let r=0;r<t;r++)e[a[r]]=l}else o?this.options.visualElement.renderState.vars[t]=l:e[t]=l}this.options.layoutId&&(e.pointerEvents=n===this?uk(t?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(pu),this.root.sharedNodes.clear()}}}function pi(e){e.updateLayout()}function pa(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){let{layoutBox:r,measuredBox:n}=e.layout,{animationType:s}=e.options,i=t.source!==e.layout.source;"size"===s?hr(e=>{let n=i?t.measuredBox[e]:t.layoutBox[e],s=ho(n);n.min=r[e].min,n.max=n.min+s}):pS(s,t.layoutBox,r)&&hr(n=>{let s=i?t.measuredBox[n]:t.layoutBox[n],a=ho(r[n]);s.max=s.min+a,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[n].max=e.relativeTarget[n].min+a)});let a=lE();hc(a,r,t.layoutBox);let o=lE();i?hc(o,e.applyTransform(n,!0),t.measuredBox):hc(o,r,t.layoutBox);let l=!hq(a),c=!1;if(!e.resumeFrom){let n=e.getClosestProjectingParent();if(n&&!n.resumeFrom){let{snapshot:s,layout:i}=n;if(s&&i){let a=lR();hh(a,t.layoutBox,s.layoutBox);let o=lR();hh(o,r,i.layoutBox),hX(a,o)||(c=!0),n.options.layoutRoot&&(e.relativeTarget=o,e.relativeTargetOrigin=a,e.relativeParent=n)}}}e.notifyListeners("didUpdate",{layout:r,snapshot:t,delta:o,layoutDelta:a,hasLayoutChanged:l,hasRelativeLayoutChanged:c})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function po(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function pl(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function pc(e){e.clearSnapshot()}function pu(e){e.clearMeasurements()}function pd(e){e.isLayoutDirty=!1}function ph(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function pp(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function pm(e){e.resolveTargetDelta()}function pf(e){e.calcProjection()}function pg(e){e.resetSkewAndRotation()}function px(e){e.removeLeadSnapshot()}function py(e,t,r){e.translate=c0(t.translate,0,r),e.scale=c0(t.scale,1,r),e.origin=t.origin,e.originPoint=t.originPoint}function pv(e,t,r,n){e.min=c0(t.min,r.min,n),e.max=c0(t.max,r.max,n)}function pb(e){return e.animationValues&&void 0!==e.animationValues.opacityExit}let pw={duration:.45,ease:[.4,0,.1,1]},pk=e=>"u">typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),pj=pk("applewebkit/")&&!pk("chrome/")?Math.round:l8;function pN(e){e.min=pj(e.min),e.max=pj(e.max)}function pS(e,t,r){return"position"===e||"preserve-aspect"===e&&!(.2>=Math.abs(hY(t)-hY(r)))}function pC(e){return e!==e.root&&e.scroll?.wasRoot}let pA=ps({attachResizeListener:(e,t)=>hi(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),p_={current:void 0},pT=ps({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!p_.current){let e=new pA({});e.mount(window),e.setOptions({layoutScroll:!0}),p_.current=e}return p_.current},resetTransform:(e,t)=>{e.style.transform=void 0!==t?t:"none"},checkIsScrollRoot:e=>"fixed"===window.getComputedStyle(e).position});function pE(e,t){let r=function(e,t,r){if(null==e)return[];if(e instanceof EventTarget)return[e];if("string"==typeof e){let t=document,r=(void 0)??t.querySelectorAll(e);return r?Array.from(r):[]}return Array.from(e).filter(e=>null!=e)}(e),n=new AbortController;return[r,{passive:!0,...t,signal:n.signal},()=>n.abort()]}function pP(e){return!("touch"===e.pointerType||ha.x||ha.y)}function pR(e,t,r){let{props:n}=e;e.animationState&&n.whileHover&&e.animationState.setActive("whileHover","Start"===r);let s=n["onHover"+r];s&&ct.postRender(()=>s(t,hm(t)))}let pM=(e,t)=>!!t&&(e===t||pM(e,t.parentElement)),pI=new WeakSet;function pL(e){return t=>{"Enter"===t.key&&e(t)}}function pD(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}function pO(e){return hp(e)&&!(ha.x||ha.y)}function pz(e,t,r){let{props:n}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&n.whileTap&&e.animationState.setActive("whileTap","Start"===r);let s=n["onTap"+("End"===r?"":r)];s&&ct.postRender(()=>s(t,hm(t)))}let pF=new WeakMap,pB=new WeakMap,p$=e=>{let t=pF.get(e.target);t&&t(e)},pV=e=>{e.forEach(p$)},pU={some:0,all:1},pG=function(e,t){if("u"<typeof Proxy)return uD;let r=new Map,n=(r,n)=>uD(r,n,e,t);return new Proxy((e,t)=>n(e,t),{get:(s,i)=>"create"===i?n:(r.has(i)||r.set(i,uD(i,void 0,e,t)),r.get(i))})}({animation:{Feature:class extends uO{constructor(e){super(e),e.animationState||(e.animationState=function(e){let t=t=>Promise.all(t.map(({animation:t,options:r})=>(function(e,t,r={}){let n;if(e.notify("AnimationStart",t),Array.isArray(t))n=Promise.all(t.map(t=>d3(e,t,r)));else if("string"==typeof t)n=d3(e,t,r);else{let s="function"==typeof t?uz(e,t,r.custom):t;n=Promise.all(d2(e,s,r))}return n.then(()=>{e.notify("AnimationComplete",t)})})(e,t,r))),r=he(),n=!0,s=t=>(r,n)=>{let s=uz(e,n,"exit"===t?e.presenceContext?.custom:void 0);if(s){let{transition:e,transitionEnd:t,...n}=s;r={...r,...n,...t}}return r};function i(i){let{props:a}=e,o=function e(t){if(!t)return;if(!t.isControllingVariants){let r=t.parent&&e(t.parent)||{};return void 0!==t.props.initial&&(r.initial=t.props.initial),r}let r={};for(let e=0;e<d6;e++){let n=cP[e],s=t.props[n];(cT(s)||!1===s)&&(r[n]=s)}return r}(e.parent)||{},l=[],c=new Set,u={},d=1/0;for(let t=0;t<d9;t++){var h,p;let m=d8[t],f=r[m],g=void 0!==a[m]?a[m]:o[m],x=cT(g),y=m===i?f.isActive:null;!1===y&&(d=t);let v=g===o[m]&&g!==a[m]&&x;if(v&&n&&e.manuallyAnimateOnMount&&(v=!1),f.protectedKeys={...u},!f.isActive&&null===y||!g&&!f.prevProp||c_(g)||"boolean"==typeof g)continue;let b=(h=f.prevProp,"string"==typeof(p=g)?p!==h:!!Array.isArray(p)&&!d4(p,h)),w=b||m===i&&f.isActive&&!v&&x||t>d&&x,k=!1,j=Array.isArray(g)?g:[g],N=j.reduce(s(m),{});!1===y&&(N={});let{prevResolvedValues:S={}}=f,C={...S,...N},A=t=>{w=!0,c.has(t)&&(k=!0,c.delete(t)),f.needsAnimating[t]=!0;let r=e.getValue(t);r&&(r.liveStyle=!1)};for(let e in C){let t=N[e],r=S[e];if(!u.hasOwnProperty(e))(uB(t)&&uB(r)?d4(t,r):t===r)?void 0!==t&&c.has(e)?A(e):f.protectedKeys[e]=!0:null!=t?A(e):c.add(e)}f.prevProp=g,f.prevResolvedValues=N,f.isActive&&(u={...u,...N}),n&&e.blockInitialAnimation&&(w=!1);let _=v&&b,T=!_||k;w&&T&&l.push(...j.map(t=>{let r={type:m};if("string"==typeof t&&n&&!_&&e.manuallyAnimateOnMount&&e.parent){let{parent:n}=e,s=uz(n,t);if(n.enteringChildren&&s){let{delayChildren:t}=s.transition||{};r.delay=d5(n.enteringChildren,e,t)}}return{animation:t,options:r}}))}if(c.size){let t={};if("boolean"!=typeof a.initial){let r=uz(e,Array.isArray(a.initial)?a.initial[0]:a.initial);r&&r.transition&&(t.transition=r.transition)}c.forEach(r=>{let n=e.getBaseTarget(r),s=e.getValue(r);s&&(s.liveStyle=!0),t[r]=n??null}),l.push({animation:t})}let m=!!l.length;return n&&(!1===a.initial||a.initial===a.animate)&&!e.manuallyAnimateOnMount&&(m=!1),n=!1,m?t(l):Promise.resolve()}return{animateChanges:i,setActive:function(t,n){if(r[t].isActive===n)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,n)),r[t].isActive=n;let s=i(t);for(let e in r)r[e].protectedKeys={};return s},setAnimateFunction:function(r){t=r(e)},getState:()=>r,reset:()=>{r=he()}}}(e))}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();c_(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}},exit:{Feature:class extends uO{constructor(){super(...arguments),this.id=ht++}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===r)return;let n=this.node.animationState.setActive("exit",!e);t&&!e&&n.then(()=>{t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}},inView:{Feature:class extends uO{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var e;let t;this.unmount();let{viewport:r={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:a}=r,o={root:n?n.current:void 0,rootMargin:s,threshold:"number"==typeof i?i:pU[i]},l=e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,a&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",t);let{onViewportEnter:r,onViewportLeave:n}=this.node.getProps(),s=t?r:n;s&&s(e)};return e=this.node.current,t=function({root:e,...t}){let r=e||document;pB.has(r)||pB.set(r,{});let n=pB.get(r),s=JSON.stringify(t);return n[s]||(n[s]=new IntersectionObserver(pV,{root:e,...t})),n[s]}(o),pF.set(e,l),t.observe(e),()=>{pF.delete(e),t.unobserve(e)}}mount(){this.startObserver()}update(){if("u"<typeof IntersectionObserver)return;let{props:e,prevProps:t}=this.node;["amount","margin","root"].some(function({viewport:e={}},{viewport:t={}}={}){return r=>e[r]!==t[r]}(e,t))&&this.startObserver()}unmount(){}}},tap:{Feature:class extends uO{mount(){let{current:e}=this.node;e&&(this.unmount=function(e,t,r={}){let[n,s,i]=pE(e,r),a=e=>{let n=e.currentTarget;if(!pO(e))return;pI.add(n);let i=t(n,e),a=(e,t)=>{window.removeEventListener("pointerup",o),window.removeEventListener("pointercancel",l),pI.has(n)&&pI.delete(n),pO(e)&&"function"==typeof i&&i(e,{success:t})},o=e=>{a(e,n===window||n===document||r.useGlobalTarget||pM(n,e.target))},l=e=>{a(e,!1)};window.addEventListener("pointerup",o,s),window.addEventListener("pointercancel",l,s)};return n.forEach(e=>{(r.useGlobalTarget?window:e).addEventListener("pointerdown",a,s),h4(e)&&"offsetHeight"in e&&(e.addEventListener("focus",e=>((e,t)=>{let r=e.currentTarget;if(!r)return;let n=pL(()=>{if(pI.has(r))return;pD(r,"down");let e=pL(()=>{pD(r,"up")});r.addEventListener("keyup",e,t),r.addEventListener("blur",()=>pD(r,"cancel"),t)});r.addEventListener("keydown",n,t),r.addEventListener("blur",()=>r.removeEventListener("keydown",n),t)})(e,s)),hs(e)||e.hasAttribute("tabindex")||(e.tabIndex=0))}),i}(e,(e,t)=>(pz(this.node,t,"Start"),(e,{success:t})=>pz(this.node,e,t?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}},focus:{Feature:class extends uO{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch(t){e=!0}e&&this.node.animationState&&(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){this.isActive&&this.node.animationState&&(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=uG(hi(this.node.current,"focus",()=>this.onFocus()),hi(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}},hover:{Feature:class extends uO{mount(){let{current:e}=this.node;e&&(this.unmount=function(e,t,r={}){let[n,s,i]=pE(e,r),a=e=>{if(!pP(e))return;let{target:r}=e,n=t(r,e);if("function"!=typeof n||!r)return;let i=e=>{pP(e)&&(n(e),r.removeEventListener("pointerleave",i))};r.addEventListener("pointerleave",i,s)};return n.forEach(e=>{e.addEventListener("pointerenter",a,s)}),i}(e,(e,t)=>(pR(this.node,t,"Start"),e=>pR(this.node,e,"End"))))}unmount(){}}},pan:{Feature:class extends uO{constructor(){super(...arguments),this.removePointerDownListener=l8}onPointerDown(e){this.session=new hv(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:hg(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:r,onPanEnd:n}=this.node.getProps();return{onSessionStart:hP(e),onStart:hP(t),onMove:r,onEnd:(e,t)=>{delete this.session,n&&ct.postRender(()=>n(e,t))}}}mount(){this.removePointerDownListener=hf(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}},drag:{Feature:class extends uO{constructor(e){super(e),this.removeGroupControls=l8,this.removeListeners=l8,this.controls=new hT(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||l8}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},ProjectionNode:pT,MeasureLayout:hD},layout:{ProjectionNode:pT,MeasureLayout:hD}},(e,t)=>t.isSVG??uu(e)?new c6(t):new ul(t,{allowProjection:e!==b.Fragment})),pW=(0,b.memo)(({children:e,as:t="p",className:r,duration:n=2,spread:s=2})=>{let i=pG.create(t),a=(0,b.useMemo)(()=>(e?.length??0)*s,[e,s]);return(0,v.jsx)(i,{animate:{backgroundPosition:"0% center"},className:(0,k.cn)("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",r),initial:{backgroundPosition:"100% center"},style:{"--spread":`${a}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:1/0,duration:n,ease:"linear"},children:e})}),pq=(0,b.createContext)(null),pH=(0,b.memo)(({className:e,isStreaming:t=!1,open:r,defaultOpen:n=!0,onOpenChange:s,duration:i,children:a,...o})=>{let[l,c]=(0,aK.useControllableState)({prop:r,defaultProp:n,onChange:s}),[u,d]=(0,aK.useControllableState)({prop:i,defaultProp:void 0}),[h,p]=(0,b.useState)(!1),[m,f]=(0,b.useState)(null);return(0,b.useEffect)(()=>{t?null===m&&f(Date.now()):null!==m&&(d(Math.ceil((Date.now()-m)/1e3)),f(null))},[t,m,d]),(0,b.useEffect)(()=>{if(n&&!t&&l&&!h){let e=setTimeout(()=>{c(!1),p(!0)},1e3);return()=>clearTimeout(e)}},[t,l,n,c,h]),(0,v.jsx)(pq.Provider,{value:{isStreaming:t,isOpen:l,setIsOpen:c,duration:u},children:(0,v.jsx)(os,{className:(0,k.cn)("not-prose mb-4",e),onOpenChange:e=>{c(e)},open:l,...o,children:a})})}),pK=(e,t)=>e||0===t?(0,v.jsx)(pW,{duration:1,children:"Thinking..."}):void 0===t?(0,v.jsx)("p",{children:"Thought for a few seconds"}):(0,v.jsxs)("p",{children:["Thought for ",t," seconds"]}),pX=(0,b.memo)(({className:e,children:t,getThinkingMessage:r=pK,...n})=>{let{isStreaming:s,isOpen:i,duration:a}=(()=>{let e=(0,b.useContext)(pq);if(!e)throw Error("Reasoning components must be used within Reasoning");return e})();return(0,v.jsx)(oi,{className:(0,k.cn)("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:t??(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(oZ,{className:"size-4"}),r(s,a),(0,v.jsx)(ol.ChevronDownIcon,{className:(0,k.cn)("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),pY=(0,b.memo)(({className:e,children:t,...r})=>(0,v.jsx)(oa,{className:(0,k.cn)("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...r,children:(0,v.jsx)(aB.j,{plugins:{code:nn,mermaid:aI,math:nO,cjk:eg},linkSafety:{enabled:!0,renderModal:aW},...r,children:t})}));pH.displayName="Reasoning",pX.displayName="ReasoningTrigger",pY.displayName="ReasoningContent";var pJ=/[\\\/_+.#"@\[\(\{&]/,pZ=/[\\\/_+.#"@\[\(\{&]/g,pQ=/[\s-]/,p0=/[\s-]/g;function p1(e){return e.toLowerCase().replace(p0," ")}var p2=e.i(7631),p5=e.i(408744),p3='[cmdk-group=""]',p6='[cmdk-group-items=""]',p4='[cmdk-item=""]',p8=`${p4}:not([aria-disabled="true"])`,p9="cmdk-item-select",p7="data-value",me=(e,t,r)=>{var n;return n=e,function e(t,r,n,s,i,a,o){if(a===r.length)return i===t.length?1:.99;var l=`${i},${a}`;if(void 0!==o[l])return o[l];for(var c,u,d,h,p=s.charAt(a),m=n.indexOf(p,i),f=0;m>=0;)(c=e(t,r,n,s,m+1,a+1,o))>f&&(m===i?c*=1:pJ.test(t.charAt(m-1))?(c*=.8,(d=t.slice(i,m-1).match(pZ))&&i>0&&(c*=Math.pow(.999,d.length))):pQ.test(t.charAt(m-1))?(c*=.9,(h=t.slice(i,m-1).match(p0))&&i>0&&(c*=Math.pow(.999,h.length))):(c*=.17,i>0&&(c*=Math.pow(.999,m-i))),t.charAt(m)!==r.charAt(a)&&(c*=.9999)),(c<.1&&n.charAt(m-1)===s.charAt(a+1)||s.charAt(a+1)===s.charAt(a)&&n.charAt(m-1)!==s.charAt(a))&&.1*(u=e(t,r,n,s,m+1,a+2,o))>c&&(c=.1*u),c>f&&(f=c),m=n.indexOf(p,m+1);return o[l]=f,f}(n=r&&r.length>0?`${n+" "+r.join(" ")}`:n,t,p1(n),p1(t),0,0,{})},mt=b.createContext(void 0),mr=b.createContext(void 0),mn=b.createContext(void 0),ms=b.forwardRef((e,t)=>{let r=mm(()=>{var t,r;return{search:"",value:null!=(r=null!=(t=e.value)?t:e.defaultValue)?r:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=mm(()=>new Set),s=mm(()=>new Map),i=mm(()=>new Map),a=mm(()=>new Set),o=mh(e),{label:l,children:c,value:u,onValueChange:d,filter:h,shouldFilter:p,loop:m,disablePointerSelection:f=!1,vimBindings:g=!0,...x}=e,y=(0,a1.useId)(),v=(0,a1.useId)(),w=(0,a1.useId)(),k=b.useRef(null),j=mx();mp(()=>{if(void 0!==u){let e=u.trim();r.current.value=e,N.emit()}},[u]),mp(()=>{j(6,E)},[]);let N=b.useMemo(()=>({subscribe:e=>(a.current.add(e),()=>a.current.delete(e)),snapshot:()=>r.current,setState:(e,t,n)=>{var s,i,a,l;if(!Object.is(r.current[e],t)){if(r.current[e]=t,"search"===e)T(),A(),j(1,_);else if("value"===e){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let e=document.getElementById(w);e?e.focus():null==(s=document.getElementById(y))||s.focus()}if(j(7,()=>{var e;r.current.selectedItemId=null==(e=P())?void 0:e.id,N.emit()}),n||j(5,E),(null==(i=o.current)?void 0:i.value)!==void 0){null==(l=(a=o.current).onValueChange)||l.call(a,null!=t?t:"");return}}N.emit()}},emit:()=>{a.current.forEach(e=>e())}}),[]),S=b.useMemo(()=>({value:(e,t,n)=>{var s;t!==(null==(s=i.current.get(e))?void 0:s.value)&&(i.current.set(e,{value:t,keywords:n}),r.current.filtered.items.set(e,C(t,n)),j(2,()=>{A(),N.emit()}))},item:(e,t)=>(n.current.add(e),t&&(s.current.has(t)?s.current.get(t).add(e):s.current.set(t,new Set([e]))),j(3,()=>{T(),A(),r.current.value||_(),N.emit()}),()=>{i.current.delete(e),n.current.delete(e),r.current.filtered.items.delete(e);let t=P();j(4,()=>{T(),(null==t?void 0:t.getAttribute("id"))===e&&_(),N.emit()})}),group:e=>(s.current.has(e)||s.current.set(e,new Set),()=>{i.current.delete(e),s.current.delete(e)}),filter:()=>o.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>o.current.disablePointerSelection,listId:y,inputId:w,labelId:v,listInnerRef:k}),[]);function C(e,t){var n,s;let i=null!=(s=null==(n=o.current)?void 0:n.filter)?s:me;return e?i(e,r.current.search,t):0}function A(){if(!r.current.search||!1===o.current.shouldFilter)return;let e=r.current.filtered.items,t=[];r.current.filtered.groups.forEach(r=>{let n=s.current.get(r),i=0;n.forEach(t=>{i=Math.max(e.get(t),i)}),t.push([r,i])});let n=k.current;R().sort((t,r)=>{var n,s;let i=t.getAttribute("id"),a=r.getAttribute("id");return(null!=(n=e.get(a))?n:0)-(null!=(s=e.get(i))?s:0)}).forEach(e=>{let t=e.closest(p6);t?t.appendChild(e.parentElement===t?e:e.closest(`${p6} > *`)):n.appendChild(e.parentElement===n?e:e.closest(`${p6} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{var t;let r=null==(t=k.current)?void 0:t.querySelector(`${p3}[${p7}="${encodeURIComponent(e[0])}"]`);null==r||r.parentElement.appendChild(r)})}function _(){let e=R().find(e=>"true"!==e.getAttribute("aria-disabled")),t=null==e?void 0:e.getAttribute(p7);N.setState("value",t||void 0)}function T(){var e,t,a,l;if(!r.current.search||!1===o.current.shouldFilter){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let c=0;for(let s of n.current){let n=C(null!=(t=null==(e=i.current.get(s))?void 0:e.value)?t:"",null!=(l=null==(a=i.current.get(s))?void 0:a.keywords)?l:[]);r.current.filtered.items.set(s,n),n>0&&c++}for(let[e,t]of s.current)for(let n of t)if(r.current.filtered.items.get(n)>0){r.current.filtered.groups.add(e);break}r.current.filtered.count=c}function E(){var e,t,r;let n=P();n&&((null==(e=n.parentElement)?void 0:e.firstChild)===n&&(null==(r=null==(t=n.closest(p3))?void 0:t.querySelector('[cmdk-group-heading=""]'))||r.scrollIntoView({block:"nearest"})),n.scrollIntoView({block:"nearest"}))}function P(){var e;return null==(e=k.current)?void 0:e.querySelector(`${p4}[aria-selected="true"]`)}function R(){var e;return Array.from((null==(e=k.current)?void 0:e.querySelectorAll(p8))||[])}function M(e){let t=R()[e];t&&N.setState("value",t.getAttribute(p7))}function I(e){var t;let r=P(),n=R(),s=n.findIndex(e=>e===r),i=n[s+e];null!=(t=o.current)&&t.loop&&(i=s+e<0?n[n.length-1]:s+e===n.length?n[0]:n[s+e]),i&&N.setState("value",i.getAttribute(p7))}function L(e){let t=P(),r=null==t?void 0:t.closest(p3),n;for(;r&&!n;)n=null==(r=e>0?function(e,t){let r=e.nextElementSibling;for(;r;){if(r.matches(t))return r;r=r.nextElementSibling}}(r,p3):function(e,t){let r=e.previousElementSibling;for(;r;){if(r.matches(t))return r;r=r.previousElementSibling}}(r,p3))?void 0:r.querySelector(p8);n?N.setState("value",n.getAttribute(p7)):I(e)}let D=()=>M(R().length-1),O=e=>{e.preventDefault(),e.metaKey?D():e.altKey?L(1):I(1)},z=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?L(-1):I(-1)};return b.createElement(p5.Primitive.div,{ref:t,tabIndex:-1,...x,"cmdk-root":"",onKeyDown:e=>{var t;null==(t=x.onKeyDown)||t.call(x,e);let r=e.nativeEvent.isComposing||229===e.keyCode;if(!(e.defaultPrevented||r))switch(e.key){case"n":case"j":g&&e.ctrlKey&&O(e);break;case"ArrowDown":O(e);break;case"p":case"k":g&&e.ctrlKey&&z(e);break;case"ArrowUp":z(e);break;case"Home":e.preventDefault(),M(0);break;case"End":e.preventDefault(),D();break;case"Enter":{e.preventDefault();let t=P();if(t){let e=new Event(p9);t.dispatchEvent(e)}}}}},b.createElement("label",{"cmdk-label":"",htmlFor:S.inputId,id:S.labelId,style:mv},l),my(e,e=>b.createElement(mr.Provider,{value:N},b.createElement(mt.Provider,{value:S},e))))}),mi=b.forwardRef((e,t)=>{var r,n;let s=(0,a1.useId)(),i=b.useRef(null),a=b.useContext(mn),o=b.useContext(mt),l=mh(e),c=null!=(n=null==(r=l.current)?void 0:r.forceMount)?n:null==a?void 0:a.forceMount;mp(()=>{if(!c)return o.item(s,null==a?void 0:a.id)},[c]);let u=mg(s,i,[e.value,e.children,i],e.keywords),d=b.useContext(mr),h=mf(e=>e.value&&e.value===u.current),p=mf(e=>!!c||!1===o.filter()||!e.search||e.filtered.items.get(s)>0);function m(){var e,t;f(),null==(t=(e=l.current).onSelect)||t.call(e,u.current)}function f(){d.setState("value",u.current,!0)}if(b.useEffect(()=>{let t=i.current;if(!(!t||e.disabled))return t.addEventListener(p9,m),()=>t.removeEventListener(p9,m)},[p,e.onSelect,e.disabled]),!p)return null;let{disabled:g,value:x,onSelect:y,forceMount:v,keywords:w,...k}=e;return b.createElement(p5.Primitive.div,{ref:(0,aY.composeRefs)(i,t),...k,id:s,"cmdk-item":"",role:"option","aria-disabled":!!g,"aria-selected":!!h,"data-disabled":!!g,"data-selected":!!h,onPointerMove:g||o.getDisablePointerSelection()?void 0:f,onClick:g?void 0:m},e.children)}),ma=b.forwardRef((e,t)=>{let{heading:r,children:n,forceMount:s,...i}=e,a=(0,a1.useId)(),o=b.useRef(null),l=b.useRef(null),c=(0,a1.useId)(),u=b.useContext(mt),d=mf(e=>!!s||!1===u.filter()||!e.search||e.filtered.groups.has(a));mp(()=>u.group(a),[]),mg(a,o,[e.value,e.heading,l]);let h=b.useMemo(()=>({id:a,forceMount:s}),[s]);return b.createElement(p5.Primitive.div,{ref:(0,aY.composeRefs)(o,t),...i,"cmdk-group":"",role:"presentation",hidden:!d||void 0},r&&b.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},r),my(e,e=>b.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?c:void 0},b.createElement(mn.Provider,{value:h},e))))}),mo=b.forwardRef((e,t)=>{let{alwaysRender:r,...n}=e,s=b.useRef(null),i=mf(e=>!e.search);return r||i?b.createElement(p5.Primitive.div,{ref:(0,aY.composeRefs)(s,t),...n,"cmdk-separator":"",role:"separator"}):null}),ml=b.forwardRef((e,t)=>{let{onValueChange:r,...n}=e,s=null!=e.value,i=b.useContext(mr),a=mf(e=>e.search),o=mf(e=>e.selectedItemId),l=b.useContext(mt);return b.useEffect(()=>{null!=e.value&&i.setState("search",e.value)},[e.value]),b.createElement(p5.Primitive.input,{ref:t,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":o,id:l.inputId,type:"text",value:s?e.value:a,onChange:e=>{s||i.setState("search",e.target.value),null==r||r(e.target.value)}})}),mc=b.forwardRef((e,t)=>{let{children:r,label:n="Suggestions",...s}=e,i=b.useRef(null),a=b.useRef(null),o=mf(e=>e.selectedItemId),l=b.useContext(mt);return b.useEffect(()=>{if(a.current&&i.current){let e=a.current,t=i.current,r,n=new ResizeObserver(()=>{r=requestAnimationFrame(()=>{let r=e.offsetHeight;t.style.setProperty("--cmdk-list-height",r.toFixed(1)+"px")})});return n.observe(e),()=>{cancelAnimationFrame(r),n.unobserve(e)}}},[]),b.createElement(p5.Primitive.div,{ref:(0,aY.composeRefs)(i,t),...s,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":o,"aria-label":n,id:l.listId},my(e,e=>b.createElement("div",{ref:(0,aY.composeRefs)(a,l.listInnerRef),"cmdk-list-sizer":""},e)))}),mu=b.forwardRef((e,t)=>{let{open:r,onOpenChange:n,overlayClassName:s,contentClassName:i,container:a,...o}=e;return b.createElement(p2.Root,{open:r,onOpenChange:n},b.createElement(p2.Portal,{container:a},b.createElement(p2.Overlay,{"cmdk-overlay":"",className:s}),b.createElement(p2.Content,{"aria-label":e.label,"cmdk-dialog":"",className:i},b.createElement(ms,{ref:t,...o}))))}),md=Object.assign(ms,{List:mc,Item:mi,Input:ml,Group:ma,Separator:mo,Dialog:mu,Empty:b.forwardRef((e,t)=>mf(e=>0===e.filtered.count)?b.createElement(p5.Primitive.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Loading:b.forwardRef((e,t)=>{let{progress:r,children:n,label:s="Loading...",...i}=e;return b.createElement(p5.Primitive.div,{ref:t,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s},my(e,e=>b.createElement("div",{"aria-hidden":!0},e)))})});function mh(e){let t=b.useRef(e);return mp(()=>{t.current=e}),t}var mp="u"<typeof window?b.useEffect:b.useLayoutEffect;function mm(e){let t=b.useRef();return void 0===t.current&&(t.current=e()),t}function mf(e){let t=b.useContext(mr),r=()=>e(t.snapshot());return b.useSyncExternalStore(t.subscribe,r,r)}function mg(e,t,r,n=[]){let s=b.useRef(),i=b.useContext(mt);return mp(()=>{var a;let o=(()=>{var e;for(let t of r){if("string"==typeof t)return t.trim();if("object"==typeof t&&"current"in t)return t.current?null==(e=t.current.textContent)?void 0:e.trim():s.current}})(),l=n.map(e=>e.trim());i.value(e,o,l),null==(a=t.current)||a.setAttribute(p7,o),s.current=o}),s}var mx=()=>{let[e,t]=b.useState(),r=mm(()=>new Map);return mp(()=>{r.current.forEach(e=>e()),r.current=new Map},[e]),(e,n)=>{r.current.set(e,n),t({})}};function my({asChild:e,children:t},r){let n;return e&&b.isValidElement(t)?b.cloneElement("function"==typeof(n=t.type)?n(t.props):"render"in n?n.render(t.props):t,{ref:t.ref},r(t.props.children)):r(t)}var mv={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};let mb=(0,T.default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);var mw=e.i(836191);function mk({className:e,...t}){return(0,v.jsx)(md,{"data-slot":"command",className:(0,k.cn)("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...t})}function mj({className:e,...t}){return(0,v.jsx)(md.List,{"data-slot":"command-list",className:(0,k.cn)("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...t})}function mN({...e}){return(0,v.jsx)(md.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function mS({className:e,...t}){return(0,v.jsx)(md.Group,{"data-slot":"command-group",className:(0,k.cn)("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...t})}function mC({className:e,...t}){return(0,v.jsx)(md.Item,{"data-slot":"command-item",className:(0,k.cn)("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}var mA=Symbol("radix.slottable");function m_(e){return b.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===mA}var mT=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{var r,n;let s,i,a,o=(n=r=`Primitive.${t}`,(s=b.forwardRef((e,t)=>{let{children:r,...n}=e;if(b.isValidElement(r)){var s;let e,i,a=(s=r,(i=(e=Object.getOwnPropertyDescriptor(s.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.ref:(i=(e=Object.getOwnPropertyDescriptor(s,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.props.ref:s.props.ref||s.ref),o=function(e,t){let r={...t};for(let n in t){let s=e[n],i=t[n];/^on[A-Z]/.test(n)?s&&i?r[n]=(...e)=>{let t=i(...e);return s(...e),t}:s&&(r[n]=s):"style"===n?r[n]={...s,...i}:"className"===n&&(r[n]=[s,i].filter(Boolean).join(" "))}return{...e,...r}}(n,r.props);return r.type!==b.Fragment&&(o.ref=t?(0,aY.composeRefs)(t,a):a),b.cloneElement(r,o)}return b.Children.count(r)>1?b.Children.only(null):null})).displayName=`${n}.SlotClone`,i=s,(a=b.forwardRef((e,t)=>{let{children:r,...n}=e,s=b.Children.toArray(r),a=s.find(m_);if(a){let e=a.props.children,r=s.map(t=>t!==a?t:b.Children.count(e)>1?b.Children.only(null):b.isValidElement(e)?e.props.children:null);return(0,v.jsx)(i,{...n,ref:t,children:b.isValidElement(e)?b.cloneElement(e,void 0,r):null})}return(0,v.jsx)(i,{...n,ref:t,children:r})})).displayName=`${r}.Slot`,a),l=b.forwardRef((e,r)=>{let{asChild:n,...s}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,v.jsx)(n?o:t,{...s,ref:r})});return l.displayName=`Primitive.${t}`,{...e,[t]:l}},{}),mE=e.i(736180),mP=e.i(542899),mR=e.i(272741),mM=e.i(721648),mI=e.i(498101),mL=e.i(874057),mD=e.i(383044);function mO(e){var t;let r,n=(t=e,(r=b.forwardRef((e,t)=>{let{children:r,...n}=e;if(b.isValidElement(r)){var s;let e,i,a=(s=r,(i=(e=Object.getOwnPropertyDescriptor(s.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.ref:(i=(e=Object.getOwnPropertyDescriptor(s,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.props.ref:s.props.ref||s.ref),o=function(e,t){let r={...t};for(let n in t){let s=e[n],i=t[n];/^on[A-Z]/.test(n)?s&&i?r[n]=(...e)=>{let t=i(...e);return s(...e),t}:s&&(r[n]=s):"style"===n?r[n]={...s,...i}:"className"===n&&(r[n]=[s,i].filter(Boolean).join(" "))}return{...e,...r}}(n,r.props);return r.type!==b.Fragment&&(o.ref=t?(0,aY.composeRefs)(t,a):a),b.cloneElement(r,o)}return b.Children.count(r)>1?b.Children.only(null):null})).displayName=`${t}.SlotClone`,r),s=b.forwardRef((e,t)=>{let{children:r,...s}=e,i=b.Children.toArray(r),a=i.find(mF);if(a){let e=a.props.children,r=i.map(t=>t!==a?t:b.Children.count(e)>1?b.Children.only(null):b.isValidElement(e)?e.props.children:null);return(0,v.jsx)(n,{...s,ref:t,children:b.isValidElement(e)?b.cloneElement(e,void 0,r):null})}return(0,v.jsx)(n,{...s,ref:t,children:r})});return s.displayName=`${e}.Slot`,s}var mz=Symbol("radix.slottable");function mF(e){return b.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===mz}var mB=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let r=mO(`Primitive.${t}`),n=b.forwardRef((e,n)=>{let{asChild:s,...i}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,v.jsx)(s?r:t,{...i,ref:n})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),m$=Symbol("radix.slottable");function mV(e){return b.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===m$}var mU=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{var r,n;let s,i,a,o=(n=r=`Primitive.${t}`,(s=b.forwardRef((e,t)=>{let{children:r,...n}=e;if(b.isValidElement(r)){var s;let e,i,a=(s=r,(i=(e=Object.getOwnPropertyDescriptor(s.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.ref:(i=(e=Object.getOwnPropertyDescriptor(s,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.props.ref:s.props.ref||s.ref),o=function(e,t){let r={...t};for(let n in t){let s=e[n],i=t[n];/^on[A-Z]/.test(n)?s&&i?r[n]=(...e)=>{let t=i(...e);return s(...e),t}:s&&(r[n]=s):"style"===n?r[n]={...s,...i}:"className"===n&&(r[n]=[s,i].filter(Boolean).join(" "))}return{...e,...r}}(n,r.props);return r.type!==b.Fragment&&(o.ref=t?(0,aY.composeRefs)(t,a):a),b.cloneElement(r,o)}return b.Children.count(r)>1?b.Children.only(null):null})).displayName=`${n}.SlotClone`,i=s,(a=b.forwardRef((e,t)=>{let{children:r,...n}=e,s=b.Children.toArray(r),a=s.find(mV);if(a){let e=a.props.children,r=s.map(t=>t!==a?t:b.Children.count(e)>1?b.Children.only(null):b.isValidElement(e)?e.props.children:null);return(0,v.jsx)(i,{...n,ref:t,children:b.isValidElement(e)?b.cloneElement(e,void 0,r):null})}return(0,v.jsx)(i,{...n,ref:t,children:r})})).displayName=`${r}.Slot`,a),l=b.forwardRef((e,r)=>{let{asChild:n,...s}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,v.jsx)(n?o:t,{...s,ref:r})});return l.displayName=`Primitive.${t}`,{...e,[t]:l}},{}),mG=e.i(897462),mW="rovingFocusGroup.onEntryFocus",mq={bubbles:!1,cancelable:!0},mH="RovingFocusGroup",[mK,mX,mY]=(0,mE.createCollection)(mH),[mJ,mZ]=function(e,t=[]){let r=[],n=()=>{let t=r.map(e=>b.createContext(e));return function(r){let n=r?.[e]||t;return b.useMemo(()=>({[`__scope${e}`]:{...r,[e]:n}}),[r,n])}};return n.scopeName=e,[function(t,n){let s=b.createContext(n),i=r.length;r=[...r,n];let a=t=>{let{scope:r,children:n,...a}=t,o=r?.[e]?.[i]||s,l=b.useMemo(()=>a,Object.values(a));return(0,v.jsx)(o.Provider,{value:l,children:n})};return a.displayName=t+"Provider",[a,function(r,a){let o=a?.[e]?.[i]||s,l=b.useContext(o);if(l)return l;if(void 0!==n)return n;throw Error(`\`${r}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let r=()=>{let r=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let n=r.reduce((t,{useScope:r,scopeName:n})=>{let s=r(e)[`__scope${n}`];return{...t,...s}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:n}),[n])}};return r.scopeName=t.scopeName,r}(n,...t)]}(mH,[mY]),[mQ,m0]=mJ(mH),m1=b.forwardRef((e,t)=>(0,v.jsx)(mK.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,v.jsx)(mK.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,v.jsx)(m2,{...e,ref:t})})}));m1.displayName=mH;var m2=b.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:r,orientation:n,loop:s=!1,dir:i,currentTabStopId:a,defaultCurrentTabStopId:o,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...d}=e,h=b.useRef(null),p=(0,aY.useComposedRefs)(t,h),m=(0,mP.useDirection)(i),[f,g]=(0,aK.useControllableState)({prop:a,defaultProp:o??null,onChange:l,caller:mH}),[x,y]=b.useState(!1),w=(0,mG.useCallbackRef)(c),k=mX(r),j=b.useRef(!1),[N,S]=b.useState(0);return b.useEffect(()=>{let e=h.current;if(e)return e.addEventListener(mW,w),()=>e.removeEventListener(mW,w)},[w]),(0,v.jsx)(mQ,{scope:r,orientation:n,dir:m,loop:s,currentTabStopId:f,onItemFocus:b.useCallback(e=>g(e),[g]),onItemShiftTab:b.useCallback(()=>y(!0),[]),onFocusableItemAdd:b.useCallback(()=>S(e=>e+1),[]),onFocusableItemRemove:b.useCallback(()=>S(e=>e-1),[]),children:(0,v.jsx)(mU.div,{tabIndex:x||0===N?-1:0,"data-orientation":n,...d,ref:p,style:{outline:"none",...e.style},onMouseDown:(0,aH.composeEventHandlers)(e.onMouseDown,()=>{j.current=!0}),onFocus:(0,aH.composeEventHandlers)(e.onFocus,e=>{let t=!j.current;if(e.target===e.currentTarget&&t&&!x){let t=new CustomEvent(mW,mq);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=k().filter(e=>e.focusable);m4([e.find(e=>e.active),e.find(e=>e.id===f),...e].filter(Boolean).map(e=>e.ref.current),u)}}j.current=!1}),onBlur:(0,aH.composeEventHandlers)(e.onBlur,()=>y(!1))})})}),m5="RovingFocusGroupItem",m3=b.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:r,focusable:n=!0,active:s=!1,tabStopId:i,children:a,...o}=e,l=(0,a1.useId)(),c=i||l,u=m0(m5,r),d=u.currentTabStopId===c,h=mX(r),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:f}=u;return b.useEffect(()=>{if(n)return p(),()=>m()},[n,p,m]),(0,v.jsx)(mK.ItemSlot,{scope:r,id:c,focusable:n,active:s,children:(0,v.jsx)(mU.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...o,ref:t,onMouseDown:(0,aH.composeEventHandlers)(e.onMouseDown,e=>{n?u.onItemFocus(c):e.preventDefault()}),onFocus:(0,aH.composeEventHandlers)(e.onFocus,()=>u.onItemFocus(c)),onKeyDown:(0,aH.composeEventHandlers)(e.onKeyDown,e=>{if("Tab"===e.key&&e.shiftKey)return void u.onItemShiftTab();if(e.target!==e.currentTarget)return;let t=function(e,t,r){var n;let s=(n=e.key,"rtl"!==r?n:"ArrowLeft"===n?"ArrowRight":"ArrowRight"===n?"ArrowLeft":n);if(!("vertical"===t&&["ArrowLeft","ArrowRight"].includes(s))&&!("horizontal"===t&&["ArrowUp","ArrowDown"].includes(s)))return m6[s]}(e,u.orientation,u.dir);if(void 0!==t){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let s=h().filter(e=>e.focusable).map(e=>e.ref.current);if("last"===t)s.reverse();else if("prev"===t||"next"===t){var r,n;"prev"===t&&s.reverse();let i=s.indexOf(e.currentTarget);s=u.loop?(r=s,n=i+1,r.map((e,t)=>r[(n+t)%r.length])):s.slice(i+1)}setTimeout(()=>m4(s))}}),children:"function"==typeof a?a({isCurrentTabStop:d,hasTabStop:null!=f}):a})})});m3.displayName=m5;var m6={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function m4(e,t=!1){let r=document.activeElement;for(let n of e)if(n===r||(n.focus({preventScroll:t}),document.activeElement!==r))return}var m8=e.i(567706),m9=e.i(883944),m7=["Enter"," "],fe=["ArrowUp","PageDown","End"],ft=["ArrowDown","PageUp","Home",...fe],fr={ltr:[...m7,"ArrowRight"],rtl:[...m7,"ArrowLeft"]},fn={ltr:["ArrowLeft"],rtl:["ArrowRight"]},fs="Menu",[fi,fa,fo]=(0,mE.createCollection)(fs),[fl,fc]=function(e,t=[]){let r=[],n=()=>{let t=r.map(e=>b.createContext(e));return function(r){let n=r?.[e]||t;return b.useMemo(()=>({[`__scope${e}`]:{...r,[e]:n}}),[r,n])}};return n.scopeName=e,[function(t,n){let s=b.createContext(n),i=r.length;r=[...r,n];let a=t=>{let{scope:r,children:n,...a}=t,o=r?.[e]?.[i]||s,l=b.useMemo(()=>a,Object.values(a));return(0,v.jsx)(o.Provider,{value:l,children:n})};return a.displayName=t+"Provider",[a,function(r,a){let o=a?.[e]?.[i]||s,l=b.useContext(o);if(l)return l;if(void 0!==n)return n;throw Error(`\`${r}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let r=()=>{let r=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let n=r.reduce((t,{useScope:r,scopeName:n})=>{let s=r(e)[`__scope${n}`];return{...t,...s}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:n}),[n])}};return r.scopeName=t.scopeName,r}(n,...t)]}(fs,[fo,mL.createPopperScope,mZ]),fu=(0,mL.createPopperScope)(),fd=mZ(),[fh,fp]=fl(fs),[fm,ff]=fl(fs),fg=b.forwardRef((e,t)=>{let{__scopeMenu:r,...n}=e,s=fu(r);return(0,v.jsx)(mL.Anchor,{...s,...n,ref:t})});fg.displayName="MenuAnchor";var fx="MenuPortal",[fy,fv]=fl(fx,{forceMount:void 0}),fb="MenuContent",[fw,fk]=fl(fb),fj=b.forwardRef((e,t)=>{let r=fv(fb,e.__scopeMenu),{forceMount:n=r.forceMount,...s}=e,i=fp(fb,e.__scopeMenu),a=ff(fb,e.__scopeMenu);return(0,v.jsx)(fi.Provider,{scope:e.__scopeMenu,children:(0,v.jsx)(a0.Presence,{present:n||i.open,children:(0,v.jsx)(fi.Slot,{scope:e.__scopeMenu,children:a.modal?(0,v.jsx)(fN,{...s,ref:t}):(0,v.jsx)(fS,{...s,ref:t})})})})}),fN=b.forwardRef((e,t)=>{let r=fp(fb,e.__scopeMenu),n=b.useRef(null),s=(0,aY.useComposedRefs)(t,n);return b.useEffect(()=>{let e=n.current;if(e)return(0,m8.hideOthers)(e)},[]),(0,v.jsx)(fA,{...e,ref:s,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:(0,aH.composeEventHandlers)(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),fS=b.forwardRef((e,t)=>{let r=fp(fb,e.__scopeMenu);return(0,v.jsx)(fA,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),fC=mO("MenuContent.ScrollLock"),fA=b.forwardRef((e,t)=>{let{__scopeMenu:r,loop:n=!1,trapFocus:s,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:p,disableOutsideScroll:m,...f}=e,g=fp(fb,r),x=ff(fb,r),y=fu(r),w=fd(r),k=fa(r),[j,N]=b.useState(null),S=b.useRef(null),C=(0,aY.useComposedRefs)(t,S,g.onContentChange),A=b.useRef(0),_=b.useRef(""),T=b.useRef(0),E=b.useRef(null),P=b.useRef("right"),R=b.useRef(0),M=m?m9.RemoveScroll:b.Fragment;b.useEffect(()=>()=>window.clearTimeout(A.current),[]),(0,mM.useFocusGuards)();let I=b.useCallback(e=>{var t,r;return P.current===E.current?.side&&(t=e,!!(r=E.current?.area)&&function(e,t){let{x:r,y:n}=e,s=!1;for(let e=0,i=t.length-1;e<t.length;i=e++){let a=t[e],o=t[i],l=a.x,c=a.y,u=o.x,d=o.y;c>n!=d>n&&r<(u-l)*(n-c)/(d-c)+l&&(s=!s)}return s}({x:t.clientX,y:t.clientY},r))},[]);return(0,v.jsx)(fw,{scope:r,searchRef:_,onItemEnter:b.useCallback(e=>{I(e)&&e.preventDefault()},[I]),onItemLeave:b.useCallback(e=>{I(e)||(S.current?.focus(),N(null))},[I]),onTriggerLeave:b.useCallback(e=>{I(e)&&e.preventDefault()},[I]),pointerGraceTimerRef:T,onPointerGraceIntentChange:b.useCallback(e=>{E.current=e},[]),children:(0,v.jsx)(M,{...m?{as:fC,allowPinchZoom:!0}:void 0,children:(0,v.jsx)(mI.FocusScope,{asChild:!0,trapped:s,onMountAutoFocus:(0,aH.composeEventHandlers)(i,e=>{e.preventDefault(),S.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:(0,v.jsx)(mR.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:o,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:p,children:(0,v.jsx)(m1,{asChild:!0,...w,dir:x.dir,orientation:"vertical",loop:n,currentTabStopId:j,onCurrentTabStopIdChange:N,onEntryFocus:(0,aH.composeEventHandlers)(l,e=>{x.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,v.jsx)(mL.Content,{role:"menu","aria-orientation":"vertical","data-state":fQ(g.open),"data-radix-menu-content":"",dir:x.dir,...y,...f,ref:C,style:{outline:"none",...f.style},onKeyDown:(0,aH.composeEventHandlers)(f.onKeyDown,e=>{let t=e.target.closest("[data-radix-menu-content]")===e.currentTarget,r=e.ctrlKey||e.altKey||e.metaKey,n=1===e.key.length;if(t){var s;let t,i,a,o,l,c;"Tab"===e.key&&e.preventDefault(),!r&&n&&(s=e.key,t=_.current+s,i=k().filter(e=>!e.disabled),a=document.activeElement,o=i.find(e=>e.ref.current===a)?.textValue,l=function(e,t,r){var n;let s=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=r?e.indexOf(r):-1,a=(n=Math.max(i,0),e.map((t,r)=>e[(n+r)%e.length]));1===s.length&&(a=a.filter(e=>e!==r));let o=a.find(e=>e.toLowerCase().startsWith(s.toLowerCase()));return o!==r?o:void 0}(i.map(e=>e.textValue),t,o),c=i.find(e=>e.textValue===l)?.ref.current,function e(t){_.current=t,window.clearTimeout(A.current),""!==t&&(A.current=window.setTimeout(()=>e(""),1e3))}(t),c&&setTimeout(()=>c.focus()))}let i=S.current;if(e.target!==i||!ft.includes(e.key))return;e.preventDefault();let a=k().filter(e=>!e.disabled).map(e=>e.ref.current);fe.includes(e.key)&&a.reverse(),function(e){let t=document.activeElement;for(let r of e)if(r===t||(r.focus(),document.activeElement!==t))return}(a)}),onBlur:(0,aH.composeEventHandlers)(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(A.current),_.current="")}),onPointerMove:(0,aH.composeEventHandlers)(e.onPointerMove,f2(e=>{let t=e.target,r=R.current!==e.clientX;e.currentTarget.contains(t)&&r&&(P.current=e.clientX>R.current?"right":"left",R.current=e.clientX)}))})})})})})})});fj.displayName=fb;var f_=b.forwardRef((e,t)=>{let{__scopeMenu:r,...n}=e;return(0,v.jsx)(mB.div,{role:"group",...n,ref:t})});f_.displayName="MenuGroup";var fT=b.forwardRef((e,t)=>{let{__scopeMenu:r,...n}=e;return(0,v.jsx)(mB.div,{...n,ref:t})});fT.displayName="MenuLabel";var fE="MenuItem",fP="menu.itemSelect",fR=b.forwardRef((e,t)=>{let{disabled:r=!1,onSelect:n,...s}=e,i=b.useRef(null),a=ff(fE,e.__scopeMenu),o=fk(fE,e.__scopeMenu),l=(0,aY.useComposedRefs)(t,i),c=b.useRef(!1);return(0,v.jsx)(fM,{...s,ref:l,disabled:r,onClick:(0,aH.composeEventHandlers)(e.onClick,()=>{let e=i.current;if(!r&&e){let t=new CustomEvent(fP,{bubbles:!0,cancelable:!0});e.addEventListener(fP,e=>n?.(e),{once:!0}),e&&az.flushSync(()=>e.dispatchEvent(t)),t.defaultPrevented?c.current=!1:a.onClose()}}),onPointerDown:t=>{e.onPointerDown?.(t),c.current=!0},onPointerUp:(0,aH.composeEventHandlers)(e.onPointerUp,e=>{c.current||e.currentTarget?.click()}),onKeyDown:(0,aH.composeEventHandlers)(e.onKeyDown,e=>{let t=""!==o.searchRef.current;r||t&&" "===e.key||m7.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});fR.displayName=fE;var fM=b.forwardRef((e,t)=>{let{__scopeMenu:r,disabled:n=!1,textValue:s,...i}=e,a=fk(fE,r),o=fd(r),l=b.useRef(null),c=(0,aY.useComposedRefs)(t,l),[u,d]=b.useState(!1),[h,p]=b.useState("");return b.useEffect(()=>{let e=l.current;e&&p((e.textContent??"").trim())},[i.children]),(0,v.jsx)(fi.ItemSlot,{scope:r,disabled:n,textValue:s??h,children:(0,v.jsx)(m3,{asChild:!0,...o,focusable:!n,children:(0,v.jsx)(mB.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...i,ref:c,onPointerMove:(0,aH.composeEventHandlers)(e.onPointerMove,f2(e=>{n?a.onItemLeave(e):(a.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:(0,aH.composeEventHandlers)(e.onPointerLeave,f2(e=>a.onItemLeave(e))),onFocus:(0,aH.composeEventHandlers)(e.onFocus,()=>d(!0)),onBlur:(0,aH.composeEventHandlers)(e.onBlur,()=>d(!1))})})})}),fI=b.forwardRef((e,t)=>{let{checked:r=!1,onCheckedChange:n,...s}=e;return(0,v.jsx)(fV,{scope:e.__scopeMenu,checked:r,children:(0,v.jsx)(fR,{role:"menuitemcheckbox","aria-checked":f0(r)?"mixed":r,...s,ref:t,"data-state":f1(r),onSelect:(0,aH.composeEventHandlers)(s.onSelect,()=>n?.(!!f0(r)||!r),{checkForDefaultPrevented:!1})})})});fI.displayName="MenuCheckboxItem";var fL="MenuRadioGroup",[fD,fO]=fl(fL,{value:void 0,onValueChange:()=>{}}),fz=b.forwardRef((e,t)=>{let{value:r,onValueChange:n,...s}=e,i=(0,mG.useCallbackRef)(n);return(0,v.jsx)(fD,{scope:e.__scopeMenu,value:r,onValueChange:i,children:(0,v.jsx)(f_,{...s,ref:t})})});fz.displayName=fL;var fF="MenuRadioItem",fB=b.forwardRef((e,t)=>{let{value:r,...n}=e,s=fO(fF,e.__scopeMenu),i=r===s.value;return(0,v.jsx)(fV,{scope:e.__scopeMenu,checked:i,children:(0,v.jsx)(fR,{role:"menuitemradio","aria-checked":i,...n,ref:t,"data-state":f1(i),onSelect:(0,aH.composeEventHandlers)(n.onSelect,()=>s.onValueChange?.(r),{checkForDefaultPrevented:!1})})})});fB.displayName=fF;var f$="MenuItemIndicator",[fV,fU]=fl(f$,{checked:!1}),fG=b.forwardRef((e,t)=>{let{__scopeMenu:r,forceMount:n,...s}=e,i=fU(f$,r);return(0,v.jsx)(a0.Presence,{present:n||f0(i.checked)||!0===i.checked,children:(0,v.jsx)(mB.span,{...s,ref:t,"data-state":f1(i.checked)})})});fG.displayName=f$;var fW=b.forwardRef((e,t)=>{let{__scopeMenu:r,...n}=e;return(0,v.jsx)(mB.div,{role:"separator","aria-orientation":"horizontal",...n,ref:t})});fW.displayName="MenuSeparator";var fq=b.forwardRef((e,t)=>{let{__scopeMenu:r,...n}=e,s=fu(r);return(0,v.jsx)(mL.Arrow,{...s,...n,ref:t})});fq.displayName="MenuArrow";var[fH,fK]=fl("MenuSub"),fX="MenuSubTrigger",fY=b.forwardRef((e,t)=>{let r=fp(fX,e.__scopeMenu),n=ff(fX,e.__scopeMenu),s=fK(fX,e.__scopeMenu),i=fk(fX,e.__scopeMenu),a=b.useRef(null),{pointerGraceTimerRef:o,onPointerGraceIntentChange:l}=i,c={__scopeMenu:e.__scopeMenu},u=b.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return b.useEffect(()=>u,[u]),b.useEffect(()=>{let e=o.current;return()=>{window.clearTimeout(e),l(null)}},[o,l]),(0,v.jsx)(fg,{asChild:!0,...c,children:(0,v.jsx)(fM,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":s.contentId,"data-state":fQ(r.open),...e,ref:(0,aY.composeRefs)(t,s.onTriggerChange),onClick:t=>{e.onClick?.(t),e.disabled||t.defaultPrevented||(t.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:(0,aH.composeEventHandlers)(e.onPointerMove,f2(t=>{i.onItemEnter(t),!t.defaultPrevented&&(e.disabled||r.open||a.current||(i.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{r.onOpenChange(!0),u()},100)))})),onPointerLeave:(0,aH.composeEventHandlers)(e.onPointerLeave,f2(e=>{u();let t=r.content?.getBoundingClientRect();if(t){let n=r.content?.dataset.side,s="right"===n,a=t[s?"left":"right"],l=t[s?"right":"left"];i.onPointerGraceIntentChange({area:[{x:e.clientX+(s?-5:5),y:e.clientY},{x:a,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:a,y:t.bottom}],side:n}),window.clearTimeout(o.current),o.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(e),e.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:(0,aH.composeEventHandlers)(e.onKeyDown,t=>{let s=""!==i.searchRef.current;e.disabled||s&&" "===t.key||fr[n.dir].includes(t.key)&&(r.onOpenChange(!0),r.content?.focus(),t.preventDefault())})})})});fY.displayName=fX;var fJ="MenuSubContent",fZ=b.forwardRef((e,t)=>{let r=fv(fb,e.__scopeMenu),{forceMount:n=r.forceMount,...s}=e,i=fp(fb,e.__scopeMenu),a=ff(fb,e.__scopeMenu),o=fK(fJ,e.__scopeMenu),l=b.useRef(null),c=(0,aY.useComposedRefs)(t,l);return(0,v.jsx)(fi.Provider,{scope:e.__scopeMenu,children:(0,v.jsx)(a0.Presence,{present:n||i.open,children:(0,v.jsx)(fi.Slot,{scope:e.__scopeMenu,children:(0,v.jsx)(fA,{id:o.contentId,"aria-labelledby":o.triggerId,...s,ref:c,align:"start",side:"rtl"===a.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{a.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:(0,aH.composeEventHandlers)(e.onFocusOutside,e=>{e.target!==o.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:(0,aH.composeEventHandlers)(e.onEscapeKeyDown,e=>{a.onClose(),e.preventDefault()}),onKeyDown:(0,aH.composeEventHandlers)(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),r=fn[a.dir].includes(e.key);t&&r&&(i.onOpenChange(!1),o.trigger?.focus(),e.preventDefault())})})})})})});function fQ(e){return e?"open":"closed"}function f0(e){return"indeterminate"===e}function f1(e){return f0(e)?"indeterminate":e?"checked":"unchecked"}function f2(e){return t=>"mouse"===t.pointerType?e(t):void 0}fZ.displayName=fJ;var f5="DropdownMenu",[f3,f6]=function(e,t=[]){let r=[],n=()=>{let t=r.map(e=>b.createContext(e));return function(r){let n=r?.[e]||t;return b.useMemo(()=>({[`__scope${e}`]:{...r,[e]:n}}),[r,n])}};return n.scopeName=e,[function(t,n){let s=b.createContext(n),i=r.length;r=[...r,n];let a=t=>{let{scope:r,children:n,...a}=t,o=r?.[e]?.[i]||s,l=b.useMemo(()=>a,Object.values(a));return(0,v.jsx)(o.Provider,{value:l,children:n})};return a.displayName=t+"Provider",[a,function(r,a){let o=a?.[e]?.[i]||s,l=b.useContext(o);if(l)return l;if(void 0!==n)return n;throw Error(`\`${r}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let r=()=>{let r=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let n=r.reduce((t,{useScope:r,scopeName:n})=>{let s=r(e)[`__scope${n}`];return{...t,...s}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:n}),[n])}};return r.scopeName=t.scopeName,r}(n,...t)]}(f5,[fc]),f4=fc(),[f8,f9]=f3(f5),f7="DropdownMenuTrigger";b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,disabled:n=!1,...s}=e,i=f9(f7,r),a=f4(r);return(0,v.jsx)(fg,{asChild:!0,...a,children:(0,v.jsx)(mT.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":n?"":void 0,disabled:n,...s,ref:(0,aY.composeRefs)(t,i.triggerRef),onPointerDown:(0,aH.composeEventHandlers)(e.onPointerDown,e=>{!n&&0===e.button&&!1===e.ctrlKey&&(i.onOpenToggle(),i.open||e.preventDefault())}),onKeyDown:(0,aH.composeEventHandlers)(e.onKeyDown,e=>{!n&&(["Enter"," "].includes(e.key)&&i.onOpenToggle(),"ArrowDown"===e.key&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(e.key)&&e.preventDefault())})})})}).displayName=f7;var ge="DropdownMenuContent";b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f9(ge,r),i=f4(r),a=b.useRef(!1);return(0,v.jsx)(fj,{id:s.contentId,"aria-labelledby":s.triggerId,...i,...n,ref:t,onCloseAutoFocus:(0,aH.composeEventHandlers)(e.onCloseAutoFocus,e=>{a.current||s.triggerRef.current?.focus(),a.current=!1,e.preventDefault()}),onInteractOutside:(0,aH.composeEventHandlers)(e.onInteractOutside,e=>{let t=e.detail.originalEvent,r=0===t.button&&!0===t.ctrlKey,n=2===t.button||r;(!s.modal||n)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})}).displayName=ge,b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(f_,{...s,...n,ref:t})}).displayName="DropdownMenuGroup",b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(fT,{...s,...n,ref:t})}).displayName="DropdownMenuLabel",b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(fR,{...s,...n,ref:t})}).displayName="DropdownMenuItem",b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(fI,{...s,...n,ref:t})}).displayName="DropdownMenuCheckboxItem",b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(fz,{...s,...n,ref:t})}).displayName="DropdownMenuRadioGroup",b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(fB,{...s,...n,ref:t})}).displayName="DropdownMenuRadioItem",b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(fG,{...s,...n,ref:t})}).displayName="DropdownMenuItemIndicator",b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(fW,{...s,...n,ref:t})}).displayName="DropdownMenuSeparator",b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(fq,{...s,...n,ref:t})}).displayName="DropdownMenuArrow",b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(fY,{...s,...n,ref:t})}).displayName="DropdownMenuSubTrigger",b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(fZ,{...s,...n,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})}).displayName="DropdownMenuSubContent";var gt=Symbol("radix.slottable");function gr(e){return b.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===gt}var gn=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{var r,n;let s,i,a,o=(n=r=`Primitive.${t}`,(s=b.forwardRef((e,t)=>{let{children:r,...n}=e;if(b.isValidElement(r)){var s;let e,i,a=(s=r,(i=(e=Object.getOwnPropertyDescriptor(s.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.ref:(i=(e=Object.getOwnPropertyDescriptor(s,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.props.ref:s.props.ref||s.ref),o=function(e,t){let r={...t};for(let n in t){let s=e[n],i=t[n];/^on[A-Z]/.test(n)?s&&i?r[n]=(...e)=>{let t=i(...e);return s(...e),t}:s&&(r[n]=s):"style"===n?r[n]={...s,...i}:"className"===n&&(r[n]=[s,i].filter(Boolean).join(" "))}return{...e,...r}}(n,r.props);return r.type!==b.Fragment&&(o.ref=t?(0,aY.composeRefs)(t,a):a),b.cloneElement(r,o)}return b.Children.count(r)>1?b.Children.only(null):null})).displayName=`${n}.SlotClone`,i=s,(a=b.forwardRef((e,t)=>{let{children:r,...n}=e,s=b.Children.toArray(r),a=s.find(gr);if(a){let e=a.props.children,r=s.map(t=>t!==a?t:b.Children.count(e)>1?b.Children.only(null):b.isValidElement(e)?e.props.children:null);return(0,v.jsx)(i,{...n,ref:t,children:b.isValidElement(e)?b.cloneElement(e,void 0,r):null})}return(0,v.jsx)(i,{...n,ref:t,children:r})})).displayName=`${r}.Slot`,a),l=b.forwardRef((e,r)=>{let{asChild:n,...s}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,v.jsx)(n?o:t,{...s,ref:r})});return l.displayName=`Primitive.${t}`,{...e,[t]:l}},{}),gs="HoverCard",[gi,ga]=function(e,t=[]){let r=[],n=()=>{let t=r.map(e=>b.createContext(e));return function(r){let n=r?.[e]||t;return b.useMemo(()=>({[`__scope${e}`]:{...r,[e]:n}}),[r,n])}};return n.scopeName=e,[function(t,n){let s=b.createContext(n),i=r.length;r=[...r,n];let a=t=>{let{scope:r,children:n,...a}=t,o=r?.[e]?.[i]||s,l=b.useMemo(()=>a,Object.values(a));return(0,v.jsx)(o.Provider,{value:l,children:n})};return a.displayName=t+"Provider",[a,function(r,a){let o=a?.[e]?.[i]||s,l=b.useContext(o);if(l)return l;if(void 0!==n)return n;throw Error(`\`${r}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let r=()=>{let r=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let n=r.reduce((t,{useScope:r,scopeName:n})=>{let s=r(e)[`__scope${n}`];return{...t,...s}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:n}),[n])}};return r.scopeName=t.scopeName,r}(n,...t)]}(gs,[mL.createPopperScope]),go=(0,mL.createPopperScope)(),[gl,gc]=gi(gs),gu="HoverCardTrigger";b.forwardRef((e,t)=>{let{__scopeHoverCard:r,...n}=e,s=gc(gu,r),i=go(r);return(0,v.jsx)(mL.Anchor,{asChild:!0,...i,children:(0,v.jsx)(gn.a,{"data-state":s.open?"open":"closed",...n,ref:t,onPointerEnter:(0,aH.composeEventHandlers)(e.onPointerEnter,gf(s.onOpen)),onPointerLeave:(0,aH.composeEventHandlers)(e.onPointerLeave,gf(s.onClose)),onFocus:(0,aH.composeEventHandlers)(e.onFocus,s.onOpen),onBlur:(0,aH.composeEventHandlers)(e.onBlur,s.onClose),onTouchStart:(0,aH.composeEventHandlers)(e.onTouchStart,e=>e.preventDefault())})})}).displayName=gu;var[gd,gh]=gi("HoverCardPortal",{forceMount:void 0}),gp="HoverCardContent";b.forwardRef((e,t)=>{let r=gh(gp,e.__scopeHoverCard),{forceMount:n=r.forceMount,...s}=e,i=gc(gp,e.__scopeHoverCard);return(0,v.jsx)(a0.Presence,{present:n||i.open,children:(0,v.jsx)(gm,{"data-state":i.open?"open":"closed",...s,onPointerEnter:(0,aH.composeEventHandlers)(e.onPointerEnter,gf(i.onOpen)),onPointerLeave:(0,aH.composeEventHandlers)(e.onPointerLeave,gf(i.onClose)),ref:t})})}).displayName=gp;var gm=b.forwardRef((e,t)=>{let{__scopeHoverCard:r,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:i,onInteractOutside:a,...o}=e,l=gc(gp,r),c=go(r),u=b.useRef(null),d=(0,aY.useComposedRefs)(t,u),[h,p]=b.useState(!1);return b.useEffect(()=>{if(h){let e=document.body;return y=e.style.userSelect||e.style.webkitUserSelect,e.style.userSelect="none",e.style.webkitUserSelect="none",()=>{e.style.userSelect=y,e.style.webkitUserSelect=y}}},[h]),b.useEffect(()=>{if(u.current){let e=()=>{p(!1),l.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(l.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",e),()=>{document.removeEventListener("pointerup",e),l.hasSelectionRef.current=!1,l.isPointerDownOnContentRef.current=!1}}},[l.isPointerDownOnContentRef,l.hasSelectionRef]),b.useEffect(()=>{u.current&&(function(e){let t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;r.nextNode();)t.push(r.currentNode);return t})(u.current).forEach(e=>e.setAttribute("tabindex","-1"))}),(0,v.jsx)(mR.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:a,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:(0,aH.composeEventHandlers)(i,e=>{e.preventDefault()}),onDismiss:l.onDismiss,children:(0,v.jsx)(mL.Content,{...c,...o,onPointerDown:(0,aH.composeEventHandlers)(o.onPointerDown,e=>{e.currentTarget.contains(e.target)&&p(!0),l.hasSelectionRef.current=!1,l.isPointerDownOnContentRef.current=!0}),ref:d,style:{...o.style,userSelect:h?"text":void 0,WebkitUserSelect:h?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})});function gf(e){return t=>"touch"===t.pointerType?void 0:e()}b.forwardRef((e,t)=>{let{__scopeHoverCard:r,...n}=e,s=go(r);return(0,v.jsx)(mL.Arrow,{...s,...n,ref:t})}).displayName="HoverCardArrow";var gg=e.i(77982);function gx({className:e,...t}){return(0,v.jsx)("div",{"data-slot":"input-group",role:"group",className:(0,k.cn)("group/input-group border-input dark:bg-input/30 relative flex w-full items-center rounded-md border shadow-xs transition-[color,box-shadow] outline-none","h-9 min-w-0 has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-[3px]","has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",e),...t})}let gy=(0,N.cva)("text-muted-foreground flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*='size-'])]:size-4 [&>kbd]:rounded-[calc(var(--radius)-5px)] group-data-[disabled=true]/input-group:opacity-50",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]","block-start":"order-first w-full justify-start px-3 pt-3 [.border-b]:pb-3 group-has-[>input]/input-group:pt-2.5","block-end":"order-last w-full justify-start px-3 pb-3 [.border-t]:pt-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function gv({className:e,align:t="inline-start",...r}){return(0,v.jsx)("div",{role:"group","data-slot":"input-group-addon","data-align":t,className:(0,k.cn)(gy({align:t}),e),onClick:e=>{e.target.closest("button")||e.currentTarget.parentElement?.querySelector("input")?.focus()},...r})}let gb=(0,N.cva)("text-sm shadow-none flex gap-2 items-center",{variants:{size:{xs:"h-6 gap-1 px-2 rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-3.5 has-[>svg]:px-2",sm:"h-8 px-2.5 gap-1.5 rounded-md has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function gw({className:e,type:t="button",variant:r="ghost",size:n="xs",...s}){return(0,v.jsx)(A.Button,{type:t,"data-size":n,variant:r,className:(0,k.cn)(gb({size:n}),e),...s})}let gk=(0,T.default)("corner-down-left",[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]]),gj=(0,T.default)("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);var gN=e.i(675182),gN=gN,gS=e.i(257868),gS=gS;let gC=(0,T.default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),gA=(e=21)=>{let t="",r=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&r[e]];return t},g_=(0,b.createContext)(null),gT=(0,b.createContext)(null),gE=(0,b.createContext)(null),gP=()=>{let e=(0,b.useContext)(gT),t=(0,b.useContext)(gE)??e;if(!t)throw Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return t},gR=(0,b.createContext)(null),gM=({className:e,accept:t,multiple:r,globalDrop:n,syncHiddenInput:s,maxFiles:i,maxFileSize:a,onError:o,onSubmit:l,children:c,...u})=>{let d=(0,b.useContext)(g_),h=!!d,p=(0,b.useRef)(null),m=(0,b.useRef)(null),[f,g]=(0,b.useState)([]),x=h?d.attachments.files:f,[y,w]=(0,b.useState)([]),j=(0,b.useRef)(x);j.current=x;let N=(0,b.useCallback)(()=>{p.current?.click()},[]),S=(0,b.useCallback)(e=>!t||""===t.trim()||t.split(",").map(e=>e.trim()).filter(Boolean).some(t=>{if(t.endsWith("/*")){let r=t.slice(0,-1);return e.type.startsWith(r)}return e.type===t}),[t]),C=(0,b.useCallback)(e=>{let t=Array.from(e),r=t.filter(e=>S(e));if(t.length&&0===r.length)return void o?.({code:"accept",message:"No files match the accepted types."});let n=r.filter(e=>!a||e.size<=a);r.length>0&&0===n.length?o?.({code:"max_file_size",message:"All files exceed the maximum size."}):g(e=>{let t="number"==typeof i?Math.max(0,i-e.length):void 0,r="number"==typeof t?n.slice(0,t):n;"number"==typeof t&&n.length>t&&o?.({code:"max_files",message:"Too many files. Some were not added."});let s=[];for(let e of r)s.push({id:gA(),type:"file",url:URL.createObjectURL(e),mediaType:e.type,filename:e.name});return e.concat(s)})},[S,i,a,o]),A=(0,b.useCallback)(e=>g(t=>{let r=t.find(t=>t.id===e);return r?.url&&URL.revokeObjectURL(r.url),t.filter(t=>t.id!==e)}),[]),_=(0,b.useCallback)(e=>{let t=Array.from(e),r=t.filter(e=>S(e));if(t.length&&0===r.length)return void o?.({code:"accept",message:"No files match the accepted types."});let n=r.filter(e=>!a||e.size<=a);if(r.length>0&&0===n.length)return void o?.({code:"max_file_size",message:"All files exceed the maximum size."});let s=x.length,l="number"==typeof i?Math.max(0,i-s):void 0,c="number"==typeof l?n.slice(0,l):n;"number"==typeof l&&n.length>l&&o?.({code:"max_files",message:"Too many files. Some were not added."}),c.length>0&&d?.attachments.add(c)},[S,a,i,o,x.length,d]),T=(0,b.useCallback)(()=>h?d?.attachments.clear():g(e=>{for(let t of e)t.url&&URL.revokeObjectURL(t.url);return[]}),[h,d]),E=(0,b.useCallback)(()=>w([]),[]),P=h?_:C,R=h?d.attachments.remove:A,M=h?d.attachments.openFileDialog:N,I=(0,b.useCallback)(()=>{T(),E()},[T,E]);(0,b.useEffect)(()=>{h&&d.__registerFileInput(p,()=>p.current?.click())},[h,d]),(0,b.useEffect)(()=>{s&&p.current&&0===x.length&&(p.current.value="")},[x,s]),(0,b.useEffect)(()=>{let e=m.current;if(!e||n)return;let t=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},r=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&P(e.dataTransfer.files)};return e.addEventListener("dragover",t),e.addEventListener("drop",r),()=>{e.removeEventListener("dragover",t),e.removeEventListener("drop",r)}},[P,n]),(0,b.useEffect)(()=>{if(!n)return;let e=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},t=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&P(e.dataTransfer.files)};return document.addEventListener("dragover",e),document.addEventListener("drop",t),()=>{document.removeEventListener("dragover",e),document.removeEventListener("drop",t)}},[P,n]),(0,b.useEffect)(()=>()=>{if(!h)for(let e of j.current)e.url&&URL.revokeObjectURL(e.url)},[h]);let L=async e=>{try{let t=await fetch(e),r=await t.blob();return new Promise(e=>{let t=new FileReader;t.onloadend=()=>e(t.result),t.onerror=()=>e(null),t.readAsDataURL(r)})}catch{return null}},D=(0,b.useMemo)(()=>({files:x.map(e=>({...e,id:e.id})),add:P,remove:R,clear:T,openFileDialog:M,fileInputRef:p}),[x,P,R,T,M]),O=(0,b.useMemo)(()=>({sources:y,add:e=>{let t=Array.isArray(e)?e:[e];w(e=>e.concat(t.map(e=>({...e,id:gA()}))))},remove:e=>{w(t=>t.filter(t=>t.id!==e))},clear:E}),[y,E]),z=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("input",{accept:t,"aria-label":"Upload files",className:"hidden",multiple:r,onChange:e=>{e.currentTarget.files&&P(e.currentTarget.files),e.currentTarget.value=""},ref:p,title:"Upload files",type:"file"}),(0,v.jsx)("form",{className:(0,k.cn)("w-full",e),onSubmit:e=>{e.preventDefault();let t=e.currentTarget,r=h?d.textInput.value:new FormData(t).get("message")||"";h||t.reset(),Promise.all(x.map(async({id:e,...t})=>{if(t.url?.startsWith("blob:")){let e=await L(t.url);return{...t,url:e??t.url}}return t})).then(t=>{try{let n=l({text:r,files:t},e);n instanceof Promise?n.then(()=>{I(),h&&d.textInput.clear()}).catch(()=>{}):(I(),h&&d.textInput.clear())}catch{}}).catch(()=>{})},ref:m,...u,children:(0,v.jsx)(gx,{className:"overflow-hidden",children:c})})]}),F=(0,v.jsx)(gR.Provider,{value:O,children:z});return(0,v.jsx)(gE.Provider,{value:D,children:F})},gI=({className:e,...t})=>(0,v.jsx)("div",{className:(0,k.cn)("contents",e),...t}),gL=({className:e,...t})=>(0,v.jsx)(gv,{align:"block-end",className:(0,k.cn)("order-first flex-wrap gap-1",e),...t}),gD=({className:e,...t})=>(0,v.jsx)(gv,{align:"block-end",className:(0,k.cn)("justify-between gap-1",e),...t}),gO=({className:e,variant:t="default",size:r="icon-sm",status:n,onStop:s,onClick:i,children:a,...o})=>{let l="submitted"===n||"streaming"===n,c=(0,v.jsx)(gk,{className:"size-4"});return"submitted"===n?c=(0,v.jsx)(gN.default,{className:"size-4 animate-spin"}):"streaming"===n?c=(0,v.jsx)(gC,{className:"size-4"}):"error"===n&&(c=(0,v.jsx)(aO.XIcon,{className:"size-4"})),(0,v.jsx)(gw,{"aria-label":l?"Stop":"Submit",className:(0,k.cn)(e),onClick:e=>{if(l&&s){e.preventDefault(),s();return}i?.(e)},size:r,type:l&&s?"button":"submit",variant:t,...o,children:a??c})},gz=(0,T.default)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),gF=(0,T.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]),gB=(0,T.default)("music-2",[["circle",{cx:"8",cy:"18",r:"4",key:"1fc0mg"}],["path",{d:"M12 18V2l7 4",key:"g04rme"}]]),g$=(0,T.default)("paperclip",[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]),gV=(0,T.default)("video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]),gU=e=>{if("source-document"===e.type)return"source";let t=e.mediaType??"";return t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":t.startsWith("application/")||t.startsWith("text/")?"document":"unknown"},gG=(0,b.createContext)(null),gW=(0,b.createContext)(null),gq=()=>{let e=(0,b.useContext)(gW);if(!e)throw Error("Attachment components must be used within <Attachment>");return e},gH=({variant:e="grid",className:t,children:r,...n})=>{let s=(0,b.useMemo)(()=>({variant:e}),[e]);return(0,v.jsx)(gG.Provider,{value:s,children:(0,v.jsx)("div",{className:(0,k.cn)("flex items-start","list"===e?"flex-col gap-2":"flex-wrap gap-2","grid"===e&&"ml-auto w-fit",t),...n,children:r})})},gK=({data:e,onRemove:t,className:r,children:n,...s})=>{let{variant:i}=(0,b.useContext)(gG)??{variant:"grid"},a=gU(e),o=(0,b.useMemo)(()=>({data:e,mediaCategory:a,onRemove:t,variant:i}),[e,a,t,i]);return(0,v.jsx)(gW.Provider,{value:o,children:(0,v.jsx)("div",{className:(0,k.cn)("group relative","grid"===i&&"size-24 overflow-hidden rounded-lg","inline"===i&&["flex h-8 cursor-pointer select-none items-center gap-1.5","rounded-md border border-border px-1.5","font-medium text-sm transition-all","hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50"],"list"===i&&["flex w-full items-center gap-3 rounded-lg border p-3","hover:bg-accent/50"],r),...s,children:n})})},gX=({fallbackIcon:e,className:t,...r})=>{let{data:n,mediaCategory:s,variant:i}=gq(),a="inline"===i?"size-3":"size-4";return(0,v.jsx)("div",{className:(0,k.cn)("flex shrink-0 items-center justify-center overflow-hidden","grid"===i&&"size-full bg-muted","inline"===i&&"size-5 rounded bg-background","list"===i&&"size-12 rounded bg-muted",t),...r,children:(()=>{let t;if("image"===s&&"file"===n.type&&n.url){let e,t;return e=n.url,t=n.filename,"grid"===i?(0,v.jsx)("img",{alt:t||"Image",className:"size-full object-cover",height:96,src:e,width:96}):(0,v.jsx)("img",{alt:t||"Image",className:"size-full rounded object-cover",height:20,src:e,width:20})}return"video"===s&&"file"===n.type&&n.url?(0,v.jsx)("video",{className:"size-full object-cover",muted:!0,src:n.url}):e??(t=({image:gj,video:gV,audio:gB,source:gF,document:gz,unknown:g$})[s],(0,v.jsx)(t,{className:(0,k.cn)(a,"text-muted-foreground")}))})()})},gY=({showMediaType:e=!1,className:t,...r})=>{let{data:n,variant:s}=gq(),i=(e=>{if("source-document"===e.type)return e.title||e.filename||"Source";let t=gU(e);return e.filename||("image"===t?"Image":"Attachment")})(n);return"grid"===s?null:(0,v.jsxs)("div",{className:(0,k.cn)("min-w-0 flex-1",t),...r,children:[(0,v.jsx)("span",{className:"block truncate",children:i}),e&&n.mediaType&&(0,v.jsx)("span",{className:"block truncate text-muted-foreground text-xs",children:n.mediaType})]})},gJ=({label:e="Remove",className:t,children:r,...n})=>{let{onRemove:s,variant:i}=gq();return s?(0,v.jsxs)(A.Button,{"aria-label":e,className:(0,k.cn)("grid"===i&&["absolute top-2 right-2 size-6 rounded-full p-0","bg-background/80 backdrop-blur-sm","opacity-0 transition-opacity group-hover:opacity-100","hover:bg-background","[&>svg]:size-3"],"inline"===i&&["size-5 rounded p-0","opacity-0 transition-opacity group-hover:opacity-100","[&>svg]:size-2.5"],"list"===i&&["size-8 shrink-0 rounded p-0","[&>svg]:size-4"],t),onClick:e=>{e.stopPropagation(),s()},type:"button",variant:"ghost",...n,children:[r??(0,v.jsx)(aO.XIcon,{}),(0,v.jsx)("span",{className:"sr-only",children:e})]}):null};var gZ=e.i(772857);let gQ=({className:e,children:t,...r})=>(0,v.jsxs)(gZ.ScrollArea,{className:"w-full overflow-x-auto whitespace-nowrap",...r,children:[(0,v.jsx)("div",{className:(0,k.cn)("flex w-max flex-nowrap items-center gap-2",e),children:t}),(0,v.jsx)(gZ.ScrollBar,{className:"hidden",orientation:"horizontal"})]}),g0=({suggestion:e,onClick:t,className:r,variant:n="outline",size:s="sm",children:i,...a})=>(0,v.jsx)(A.Button,{className:(0,k.cn)("cursor-pointer rounded-full px-4 transition-all duration-200","hover:scale-[1.02] hover:shadow-md hover:border-primary/50",r),onClick:()=>{t?.(e)},size:s,type:"button",variant:n,...a,children:i||e});var g1=e.i(524741);let g2=(0,T.default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),g5=(0,T.default)("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]),g3=(0,T.default)("list-todo",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]),g6={pending:oc,in_progress:g5,completed:g2,cancelled:oh},g4={pending:"text-muted-foreground",in_progress:"text-primary",completed:"text-green-500",cancelled:"text-muted-foreground/50"};function g8({todosData:e,isLoading:t,className:r}){let[n,s]=(0,b.useState)(!1);if(!e||0===e.todos.length)return null;let{todos:i,stats:a,nextTodo:o}=e,l=[...i].sort((e,t)=>{let r={in_progress:0,pending:1,completed:2,cancelled:3};return(r[e.status]??4)-(r[t.status]??4)}),c=a.total>0?Math.round(a.completed/a.total*100):0;return(0,v.jsxs)("div",{className:(0,k.cn)("rounded-lg border bg-card/50 backdrop-blur-sm overflow-hidden",r),children:[(0,v.jsxs)("button",{onClick:()=>s(!n),className:"flex items-center justify-between w-full px-3 py-2 hover:bg-muted/50 transition-colors",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,v.jsx)(g3,{className:"size-4 text-primary shrink-0"}),!n&&o?(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,v.jsx)(g5,{className:"size-3.5 text-primary shrink-0"}),(0,v.jsx)("span",{className:"text-sm truncate",children:o.content})]}):(0,v.jsx)("span",{className:"font-medium text-sm",children:"Tasks"}),(0,v.jsxs)("span",{className:"text-xs text-muted-foreground shrink-0",children:[a.completed,"/",a.total]})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,v.jsx)("div",{className:"w-16 h-1.5 bg-muted rounded-full overflow-hidden",children:(0,v.jsx)("div",{className:"h-full bg-primary transition-all duration-300",style:{width:`${c}%`}})}),n?(0,v.jsx)(ol.ChevronDownIcon,{className:"size-4 text-muted-foreground"}):(0,v.jsx)(aL,{className:"size-4 text-muted-foreground"})]})]}),n&&(0,v.jsxs)("div",{className:"border-t",children:[o&&(0,v.jsxs)("div",{className:"px-3 py-2 bg-primary/5 border-b flex items-center gap-2",children:[(0,v.jsx)(g5,{className:"size-4 text-primary shrink-0"}),(0,v.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,v.jsx)("span",{className:"text-xs text-primary font-medium uppercase tracking-wide",children:"Current"}),(0,v.jsx)("p",{className:"text-sm font-medium truncate",children:o.content})]})]}),(0,v.jsx)("div",{className:"max-h-[200px] overflow-auto",children:l.map(e=>{let t=g6[e.status]||oc,r=g4[e.status]||"text-muted-foreground",n=e.id===o?.id;return(0,v.jsxs)(_.Tooltip,{children:[(0,v.jsx)(_.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)("div",{className:(0,k.cn)("flex items-start gap-2 px-3 py-1.5 hover:bg-muted/30 transition-colors cursor-default",n&&"bg-primary/5"),children:[(0,v.jsx)(t,{className:(0,k.cn)("size-4 mt-0.5 shrink-0",r)}),(0,v.jsx)("span",{className:(0,k.cn)("text-sm flex-1 min-w-0 truncate","cancelled"===e.status&&"line-through text-muted-foreground/50","completed"===e.status&&"text-muted-foreground"),children:e.content})]})}),(0,v.jsxs)(_.TooltipContent,{side:"left",className:"max-w-xs",children:[(0,v.jsx)("p",{className:"text-sm",children:e.content}),(0,v.jsx)("p",{className:"text-xs text-muted-foreground capitalize mt-1",children:e.status.replace("_"," ")})]})]},e.id)})}),(0,v.jsxs)("div",{className:"px-3 py-1.5 border-t bg-muted/30 flex items-center gap-3 text-xs text-muted-foreground",children:[a.inProgress>0&&(0,v.jsxs)("span",{className:"flex items-center gap-1",children:[(0,v.jsx)(g5,{className:"size-3 text-primary"}),a.inProgress," active"]}),a.pending>0&&(0,v.jsxs)("span",{className:"flex items-center gap-1",children:[(0,v.jsx)(oc,{className:"size-3"}),a.pending," pending"]}),a.completed>0&&(0,v.jsxs)("span",{className:"flex items-center gap-1",children:[(0,v.jsx)(g2,{className:"size-3 text-green-500"}),a.completed," done"]})]})]})]})}var g9=e.i(739963),g7=e.i(300739);let xe=(0,T.default)("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"}]]),xt=(0,T.default)("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"}]]),xr=(0,T.default)("file-code",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]),xn=(0,T.default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);var xs=e.i(719583),xi=e.i(816187);let xa=(0,T.default)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),xo=(0,T.default)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);var xl=e.i(220563);let xc=(0,T.default)("file",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]]),xu=(0,T.default)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);var xd=e.i(707387),xh=e.i(529757),xp=e.i(865259),xm=e.i(634066);let xf=(0,T.default)("file-plus",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]),xg=(0,b.memo)(({line:e,type:t})=>(0,v.jsxs)("div",{className:(0,k.cn)("font-mono text-xs leading-5 px-2","add"===t?"bg-green-500/10":"remove"===t?"bg-red-500/10":"","add"===t?"text-green-600 dark:text-green-400":"remove"===t?"text-red-600 dark:text-red-400":"text-muted-foreground"),children:[(0,v.jsx)("span",{className:"select-none w-4 inline-block",children:"add"===t?"+":"remove"===t?"-":" "}),(0,v.jsx)("span",{className:"whitespace-pre-wrap break-all",children:e||" "})]}));function xx({input:e,output:t,status:r,streamingArgsText:n,liveContent:s,liveOldString:i,liveNewString:a,className:o}){let[l,c]=(0,b.useState)(!0),u=e?.path||"",d=u.split("/").pop()||"file",h=e?.mode||t?.mode||"full",p={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",php:"php",swift:"swift",kt:"kotlin",scala:"scala",sh:"bash",bash:"bash",zsh:"bash",fish:"bash",ps1:"powershell",sql:"sql",html:"html",htm:"html",css:"css",scss:"scss",sass:"sass",less:"less",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",md:"markdown",markdown:"markdown",txt:"plaintext",toml:"toml",ini:"ini",cfg:"ini",conf:"ini",dockerfile:"dockerfile",makefile:"makefile"}[u.split(".").pop()?.toLowerCase()||""]||"plaintext",m=(0,b.useMemo)(()=>{if(!n)return null;try{return JSON.parse(n)}catch{let e=n.match(/"content"\s*:\s*"((?:[^"\\]|\\[\s\S])*)(?:"|$)/);if(e)try{return{content:JSON.parse(`"${e[1]}"`)}}catch{return{content:e[1]}}let t=n.match(/"old_string"\s*:\s*"((?:[^"\\]|\\[\s\S])*)(?:"|$)/),r=n.match(/"new_string"\s*:\s*"((?:[^"\\]|\\[\s\S])*)(?:"|$)/);if(t||r)return{old_string:t?t[1]:void 0,new_string:r?r[1]:void 0};return null}},[n]),f=s||e?.content||m?.content||"",g=i||e?.old_string||m?.old_string||"",x=a||e?.new_string||m?.new_string||"",y="streaming"===r||"pending"===r||"running"===r&&!!(s||i||a),w="completed"===r,j="error"===r||t?.success===!1,N=w&&t?.success?oo:j?oh:y?xr:xc,S=w&&t?.success?"text-green-600 dark:text-green-500":j?"text-red-600 dark:text-red-500":y?"text-blue-600 dark:text-blue-500":"text-muted-foreground",_="str_replace"===h?xn:t?.action==="created"?xf:xr;return(0,v.jsxs)("div",{className:(0,k.cn)("rounded-lg border overflow-hidden bg-background",o),children:[(0,v.jsxs)("button",{onClick:()=>c(!l),className:"flex items-center justify-between w-full px-3 py-2.5 bg-muted/50 hover:bg-muted/70 transition-colors",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(N,{className:(0,k.cn)("size-4 shrink-0",S)}),(0,v.jsx)(_,{className:"size-3.5 text-muted-foreground shrink-0"}),(0,v.jsx)(C,{variant:"outline",className:"text-xs shrink-0",children:"write_file"}),(0,v.jsx)("span",{className:"font-medium text-sm truncate",children:d}),"str_replace"===h&&(0,v.jsx)(C,{variant:"secondary",className:"text-xs shrink-0",children:"edit"}),t?.action==="created"&&(0,v.jsx)(C,{variant:"secondary",className:"text-xs shrink-0",children:"new"}),y&&(0,v.jsx)("span",{className:"text-xs text-muted-foreground animate-pulse",children:"streaming..."})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[t?.success&&void 0!==t.lineDelta&&(0,v.jsxs)("span",{className:(0,k.cn)("text-xs font-mono",t.lineDelta>=0?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"),children:[t.lineDelta>=0?"+":"",t.lineDelta]}),l?(0,v.jsx)(ol.ChevronDownIcon,{className:"size-4 text-muted-foreground"}):(0,v.jsx)(aL,{className:"size-4 text-muted-foreground"})]})]}),l&&(0,v.jsxs)("div",{className:"border-t",children:[(0,v.jsxs)("div",{className:"px-3 py-1.5 bg-muted/30 border-b flex items-center justify-between",children:[(0,v.jsx)("span",{className:"text-xs text-muted-foreground font-mono truncate",children:u}),f&&(0,v.jsx)(A.Button,{variant:"ghost",size:"icon",className:"size-6",onClick:()=>navigator.clipboard.writeText(f),children:(0,v.jsx)(om,{className:"size-3"})})]}),"str_replace"===h?(0,v.jsxs)("div",{className:"max-h-[200px] overflow-auto",children:[g&&(0,v.jsxs)("div",{className:"border-b",children:[(0,v.jsx)("div",{className:"px-3 py-1 bg-red-500/5 border-b text-xs text-red-600 dark:text-red-400 font-medium",children:"Removed"}),(0,v.jsx)("div",{className:"py-1",children:g.split("\n").map((e,t)=>(0,v.jsx)(xg,{line:e,type:"remove"},`old-${t}`))})]}),x&&(0,v.jsxs)("div",{children:[(0,v.jsx)("div",{className:"px-3 py-1 bg-green-500/5 border-b text-xs text-green-600 dark:text-green-400 font-medium",children:"Added"}),(0,v.jsx)("div",{className:"py-1",children:x.split("\n").map((e,t)=>(0,v.jsx)(xg,{line:e,type:"add"},`new-${t}`))})]}),!g&&!x&&y&&(0,v.jsx)("div",{className:"px-3 py-4 text-center text-muted-foreground text-sm",children:(0,v.jsx)("span",{className:"animate-pulse",children:"Receiving changes..."})})]}):(0,v.jsx)("div",{className:"max-h-[200px] overflow-auto",children:f?(0,v.jsx)(oT,{code:f,language:p,showLineNumbers:!0}):y?(0,v.jsx)("div",{className:"px-3 py-4 text-center text-muted-foreground text-sm",children:(0,v.jsx)("span",{className:"animate-pulse",children:"Writing file..."})}):null}),(t?.success===!0||t?.success===!1||j)&&(0,v.jsx)("div",{className:(0,k.cn)("px-3 py-2 border-t text-xs flex items-center gap-2",t?.success===!0?"bg-green-500/5 text-green-600 dark:text-green-400":"bg-red-500/5 text-red-600 dark:text-red-400"),children:t?.success===!0?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(oo,{className:"size-3.5"}),(0,v.jsx)("span",{children:"str_replace"===h?`Replaced ${t.linesRemoved||0} → ${t.linesAdded||0} lines`:`${"created"===t.action?"Created":"Updated"} (${t.lineCount||0} lines)`})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(oh,{className:"size-3.5"}),(0,v.jsx)("span",{children:t?.error||"Failed to write file"})]})})]})]})}xg.displayName="DiffLine";var xy=e.i(416667),xy=xy;let xv=(0,T.default)("scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);function xb({input:e,output:t,status:r,className:n}){var s;let[i,a]=(0,b.useState)(!0),o=e?.path||t?.relativePath||t?.path||"",l=o.split("/").pop()||"file",c={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",php:"php",swift:"swift",kt:"kotlin",scala:"scala",sh:"bash",bash:"bash",zsh:"bash",fish:"bash",ps1:"powershell",sql:"sql",html:"html",htm:"html",css:"css",scss:"scss",sass:"sass",less:"less",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",md:"markdown",markdown:"markdown",txt:"plaintext",toml:"toml",ini:"ini",cfg:"ini",conf:"ini",dockerfile:"dockerfile",makefile:"makefile"}[o.split(".").pop()?.toLowerCase()||""]||"plaintext",u=t?.content||"",d="pending"===r||"streaming"===r||"running"===r,h="completed"===r&&t?.success===!0,p="error"===r||t?.success===!1,m=(0,b.useMemo)(()=>e?.startLine&&e?.endLine?`lines ${e.startLine}-${e.endLine}`:e?.startLine?`from line ${e.startLine}`:e?.endLine?`to line ${e.endLine}`:null,[e?.startLine,e?.endLine]),f=h?oo:p?xy.default:xc;return(0,v.jsxs)("div",{className:(0,k.cn)("rounded-lg border overflow-hidden bg-background",n),children:[(0,v.jsxs)("button",{onClick:()=>a(!i),className:"flex items-center justify-between w-full px-3 py-2.5 bg-muted/50 hover:bg-muted/70 transition-colors",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(f,{className:(0,k.cn)("size-4 shrink-0",h?"text-green-600 dark:text-green-500":p?"text-red-600 dark:text-red-500":"text-muted-foreground")}),(0,v.jsx)(gz,{className:"size-3.5 text-muted-foreground shrink-0"}),(0,v.jsx)("span",{className:"font-medium text-sm truncate",children:l}),m&&(0,v.jsx)(C,{variant:"outline",className:"text-xs shrink-0",children:m}),t?.wasTruncated&&(0,v.jsxs)(C,{variant:"secondary",className:"text-xs shrink-0 gap-1",children:[(0,v.jsx)(xv,{className:"size-3"}),"truncated"]}),d&&(0,v.jsx)("span",{className:"text-xs text-muted-foreground animate-pulse",children:"reading..."})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[t?.lineCount!==void 0&&(0,v.jsxs)("span",{className:"text-xs text-muted-foreground",children:[t.lineCount," lines"]}),i?(0,v.jsx)(ol.ChevronDownIcon,{className:"size-4 text-muted-foreground"}):(0,v.jsx)(aL,{className:"size-4 text-muted-foreground"})]})]}),i&&(0,v.jsxs)("div",{className:"border-t",children:[(0,v.jsxs)("div",{className:"px-3 py-1.5 bg-muted/30 border-b flex items-center justify-between",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)("span",{className:"text-xs text-muted-foreground font-mono truncate",children:o}),t?.sizeBytes!==void 0&&(0,v.jsxs)("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:["(",(s=t.sizeBytes)<1024?`${s} B`:s<1048576?`${(s/1024).toFixed(1)} KB`:`${(s/1024/1024).toFixed(2)} MB`,")"]})]}),u&&(0,v.jsx)(A.Button,{variant:"ghost",size:"icon",className:"size-6",onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(u)},children:(0,v.jsx)(om,{className:"size-3"})})]}),(0,v.jsx)("div",{className:"max-h-[200px] overflow-auto",children:d?(0,v.jsx)("div",{className:"px-3 py-8 text-center text-muted-foreground text-sm",children:(0,v.jsx)("span",{className:"animate-pulse",children:"Reading file..."})}):p?(0,v.jsxs)("div",{className:"px-3 py-4 text-red-600 dark:text-red-400 text-sm flex items-start gap-2",children:[(0,v.jsx)(xy.default,{className:"size-4 mt-0.5 shrink-0"}),(0,v.jsx)("span",{children:t?.error||"Failed to read file"})]}):u?(0,v.jsx)(oT,{code:u,language:c,showLineNumbers:!0}):(0,v.jsx)("div",{className:"px-3 py-4 text-muted-foreground text-sm italic",children:"File is empty"})}),t?.wasTruncated&&(0,v.jsxs)("div",{className:"px-3 py-2 border-t bg-amber-500/5 text-xs text-amber-600 dark:text-amber-400 flex items-center gap-2",children:[(0,v.jsx)(xv,{className:"size-3.5"}),(0,v.jsx)("span",{children:"Content was truncated. Use startLine/endLine to read specific sections."})]})]})]})}let xw=(0,T.default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),xk=(0,T.default)("radio",[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);var ou=ou;let xj=(0,T.default)("circle-stop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);function xN({input:e,output:t,status:r,terminalId:n,liveOutput:s,className:i}){let[a,o]=(0,b.useState)(!0),l=(0,b.useRef)(null);(0,b.useEffect)(()=>{l.current&&(l.current.scrollTop=l.current.scrollHeight)},[s,t?.output]);let c=e?.command||"",u=e?.background||!1,d=e?.kill===!0,h=e?.id&&(e?.input!==void 0||e?.key!==void 0),p=e?.id&&!e?.command&&!e?.kill&&!h,m="pending"===r||"streaming"===r||"running"===r,f=m&&n&&void 0!==s,g="completed"===r,x="error"===r||t?.success===!1,y=t?.exitCode,w=(()=>{if(f)return s||"";if(t){let e=t.output||t.stdout||"",r=t.stderr||"";return r?e+(e?"\n":"")+r:e}return""})(),j=c.length>50?c.slice(0,50)+"...":c,{Icon:N,color:S,label:_}=(()=>{if(d)return{Icon:xj,color:"text-amber-600 dark:text-amber-500",label:t?.status==="stopped"?"Stopped":"Stopping..."};if(h){let t=e?.key?`key: ${e.key}`:`input: "${e?.input?.slice(0,20)}..."`;return{Icon:xw,color:"text-purple-600 dark:text-purple-500",label:m?"Sending...":t}}return p?{Icon:xw,color:"text-blue-600 dark:text-blue-500",label:"Logs"}:f?{Icon:xk,color:"text-green-600 dark:text-green-500 animate-pulse",label:"Live"}:m?{Icon:ou.default,color:"text-muted-foreground animate-pulse",label:"Executing..."}:g&&0===y?{Icon:oo,color:"text-green-600 dark:text-green-500",label:"Completed"}:g&&0!==y?{Icon:oh,color:"text-red-600 dark:text-red-500",label:`Exit ${y}`}:x?{Icon:oh,color:"text-red-600 dark:text-red-500",label:"Error"}:{Icon:xw,color:"text-muted-foreground",label:""}})();return(0,v.jsxs)("div",{className:(0,k.cn)("rounded-lg border overflow-hidden bg-background",i),children:[(0,v.jsxs)("button",{onClick:()=>o(!a),className:"flex items-center justify-between w-full px-3 py-2.5 bg-muted/50 hover:bg-muted/70 transition-colors",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(N,{className:(0,k.cn)("size-4 shrink-0",S)}),(0,v.jsx)(xw,{className:"size-3.5 text-muted-foreground shrink-0"}),(0,v.jsx)("code",{className:"font-mono text-sm truncate",title:c,children:j||(d?`kill ${e?.id}`:p?`logs ${e?.id}`:"bash")}),u&&(0,v.jsx)(C,{variant:"secondary",className:"text-xs shrink-0",children:"background"}),f&&(0,v.jsxs)(C,{variant:"secondary",className:"text-xs shrink-0 bg-green-500/10 text-green-600 dark:text-green-400 gap-1",children:[(0,v.jsx)(xk,{className:"size-2 animate-pulse"}),"live"]}),_&&!f&&(0,v.jsx)("span",{className:(0,k.cn)("text-xs shrink-0",S),children:_})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[void 0!==y&&g&&(0,v.jsxs)(C,{variant:0===y?"secondary":"destructive",className:(0,k.cn)("text-xs",0===y?"bg-green-500/10 text-green-600 dark:text-green-400":""),children:["exit ",y]}),a?(0,v.jsx)(ol.ChevronDownIcon,{className:"size-4 text-muted-foreground"}):(0,v.jsx)(aL,{className:"size-4 text-muted-foreground"})]})]}),a&&(0,v.jsxs)("div",{className:"border-t",children:[c&&(0,v.jsxs)("div",{className:"px-3 py-1.5 bg-muted/30 border-b flex items-center justify-between",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)("span",{className:"text-muted-foreground text-xs",children:"$"}),(0,v.jsx)("code",{className:"text-xs font-mono truncate",children:c})]}),(0,v.jsx)(A.Button,{variant:"ghost",size:"icon",className:"size-6",onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(c)},children:(0,v.jsx)(om,{className:"size-3"})})]}),(0,v.jsxs)("div",{ref:l,className:"bg-zinc-950 dark:bg-zinc-950 relative max-h-[300px] overflow-auto",children:[(0,v.jsxs)("pre",{className:"px-3 py-2 text-xs font-mono text-zinc-300 whitespace-pre-wrap break-all min-h-[40px]",children:[w||(0,v.jsx)("span",{className:"text-muted-foreground italic",children:m?"Waiting for output...":"(no output)"}),f&&(0,v.jsx)("span",{className:"inline-block w-2 h-4 bg-green-500 animate-pulse ml-0.5"})]}),w&&(0,v.jsx)(A.Button,{variant:"ghost",size:"icon",className:"absolute top-1 right-1 size-6 text-zinc-500 hover:text-zinc-300 bg-zinc-900/80",onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(w)},children:(0,v.jsx)(om,{className:"size-3"})})]}),t?.error&&(0,v.jsxs)("div",{className:"px-3 py-2 border-t bg-red-500/5 text-red-600 dark:text-red-400 text-xs flex items-start gap-2",children:[(0,v.jsx)(oh,{className:"size-3.5 mt-0.5 shrink-0"}),(0,v.jsx)("span",{children:t.error})]}),t?.message&&!t?.error&&(0,v.jsx)("div",{className:"px-3 py-2 border-t bg-muted/30 text-muted-foreground text-xs",children:t.message})]})]})}let xS=(0,T.default)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),xC=(0,T.default)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]);var xA=e.i(481298),xA=xA,gN=gN;let x_=(e,t)=>e?e.length>t?e.slice(0,t)+"...":e:"";function xT({open:e,onOpenChange:t,title:r="Explore Agent",steps:n,status:s,query:i}){let a=(0,b.useRef)(null),o=(0,b.useRef)(null),l="running"===s,c="completed"===s;return(0,b.useEffect)(()=>{o.current&&l&&o.current.scrollIntoView({behavior:"smooth",block:"end"})},[n,l]),(0,v.jsx)(mw.Dialog,{open:e,onOpenChange:t,children:(0,v.jsxs)(mw.DialogContent,{className:"sm:max-w-xl max-h-[80vh] flex flex-col gap-0 p-0 overflow-hidden",children:[(0,v.jsxs)("div",{className:"px-4 py-3 border-b flex items-center gap-3",children:[(0,v.jsx)("div",{className:"shrink-0",children:l?(0,v.jsx)(gN.default,{className:"size-4 text-blue-500 animate-spin"}):c?(0,v.jsx)(oo,{className:"size-4 text-green-500"}):(0,v.jsx)(oh,{className:"size-4 text-red-500"})}),(0,v.jsx)(mw.DialogHeader,{className:"flex-1 space-y-0",children:(0,v.jsx)(mw.DialogTitle,{className:"text-sm font-medium",children:l?"SparkeCoder is exploring...":c?"Exploration complete":"Exploration failed"})}),(0,v.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums",children:[n.length," steps"]})]}),i&&(0,v.jsx)("div",{className:"px-4 py-2 border-b bg-muted/30",children:(0,v.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,v.jsx)(mb,{className:"size-3 shrink-0"}),(0,v.jsx)("span",{className:"truncate",title:i,children:x_(i,80)})]})}),(0,v.jsx)("div",{ref:a,className:"flex-1 overflow-auto bg-zinc-950 font-mono text-xs",children:0===n.length?(0,v.jsxs)("div",{className:"flex items-center justify-center py-12 text-zinc-500",children:[(0,v.jsx)(gN.default,{className:"size-4 animate-spin mr-2"}),"Initializing..."]}):(0,v.jsxs)("div",{className:"py-2",children:[n.map((e,t)=>(0,v.jsx)(xE,{step:e},e.id||t)),(0,v.jsx)("div",{ref:o}),l&&(0,v.jsxs)("div",{className:"px-3 py-1 flex items-center gap-2 text-zinc-500",children:[(0,v.jsx)(gN.default,{className:"size-3 animate-spin"}),(0,v.jsx)("span",{className:"animate-pulse",children:"_"})]})]})}),(0,v.jsxs)("div",{className:"px-4 py-2 border-t bg-zinc-950 flex items-center gap-2",children:[(0,v.jsx)("div",{className:(0,k.cn)("size-2 rounded-full",l&&"bg-blue-500 animate-pulse",c&&"bg-green-500","error"===s&&"bg-red-500")}),(0,v.jsx)("span",{className:"text-xs text-zinc-500",children:l?"Running":c?"Done":"Failed"})]})]})})}function xE({step:e}){let t=(e=>{switch(e){case"grep":return mb;case"glob":case"list_dir":return xS;case"read_file":return gz;default:return xw}})(e.toolName);if("tool_call"===e.type){let r=function(e){try{if(null==e)return"";if("string"==typeof e)return e;return JSON.stringify(e)}catch{return String(e)}}(e.toolInput);return(0,v.jsxs)("div",{className:"px-3 py-0.5 hover:bg-zinc-900/50 flex items-start gap-2",children:[(0,v.jsx)(aL,{className:"size-3 text-blue-400 mt-0.5 shrink-0"}),(0,v.jsx)(t,{className:"size-3 text-blue-400 mt-0.5 shrink-0"}),(0,v.jsx)("span",{className:"text-blue-400",children:e.toolName}),r&&(0,v.jsx)("span",{className:"text-zinc-600 truncate",children:x_(r,60)})]})}return"tool_result"===e.type?(0,v.jsxs)("div",{className:"px-3 py-0.5 hover:bg-zinc-900/50 flex items-start gap-2",children:[(0,v.jsx)(oo,{className:"size-3 text-green-500 mt-0.5 shrink-0"}),(0,v.jsx)("span",{className:"text-zinc-500 truncate",children:x_(e.content,80)})]}):"thought"===e.type?(0,v.jsxs)("div",{className:"px-3 py-0.5 hover:bg-zinc-900/50 flex items-start gap-2",children:[(0,v.jsx)(xC,{className:"size-3 text-amber-400 mt-0.5 shrink-0"}),(0,v.jsx)("span",{className:"text-zinc-400 italic",children:x_(e.content,80)})]}):(0,v.jsx)("div",{className:"px-3 py-0.5 hover:bg-zinc-900/50 flex items-start gap-2",children:(0,v.jsx)("span",{className:"text-zinc-300",children:x_(e.content,100)})})}let xP=(e,t)=>e?e.length>t?e.slice(0,t)+"...":e:"";function xR({input:e,output:t,status:r,steps:n=[],className:s}){let[i,a]=(0,b.useState)(!1),[o,l]=(0,b.useState)(!1),[c,u]=(0,b.useState)(!1),d=(0,b.useRef)(null),h="pending"===r||"streaming"===r||"running"===r,p="completed"===r,m="error"===r||t?.success===!1,f=(0,b.useMemo)(()=>(e=>{let t=e.filter(e=>"tool_call"===e.type),r=new Set;for(let e of t)if("read_file"===e.toolName&&e.toolInput){let t=e.toolInput;t.path&&r.add(t.path)}return{toolCallCount:t.length,filesExplored:r.size}})(n),[n]);(0,b.useEffect)(()=>{d.current&&h&&i&&(d.current.scrollTop=d.current.scrollHeight)},[n,h,i]);let g=e?.query||"",x=(e=>{if(0===e.length)return null;let t=e[e.length-1];return"tool_call"===t.type&&t.toolName?{type:"tool",name:t.toolName}:"thought"===t.type||"text"===t.type?{type:"text",content:xP(t.content,40)}:null})(n),y=(0,b.useMemo)(()=>t?"string"==typeof t?t:t.result?t.result:t.formattedResult?t.formattedResult:t.summary?t.summary:t.text?String(t.text):t.content?String(t.content):"":"",[t]),w=(e=>{if(!e)return"";let t=e.split("\n")[0].trim(),r=t.match(/^[^.!?]+[.!?]/);return r?r[0]:xP(t,100)})(y),j=y.length>200;return(0,v.jsxs)("div",{className:(0,k.cn)("rounded-lg border overflow-hidden bg-background",s),children:[(0,v.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2.5",children:[(0,v.jsx)("div",{className:"shrink-0",children:h?(0,v.jsxs)("div",{className:"relative",children:[(0,v.jsx)(xC,{className:"size-4 text-blue-500"}),(0,v.jsx)("span",{className:"absolute -top-0.5 -right-0.5 size-2 bg-blue-500 rounded-full animate-pulse"})]}):p&&!m?(0,v.jsx)(oo,{className:"size-4 text-green-500"}):m?(0,v.jsx)(oh,{className:"size-4 text-red-500"}):(0,v.jsx)(mb,{className:"size-4 text-muted-foreground"})}),(0,v.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,v.jsx)("div",{className:"text-sm",children:h?(0,v.jsx)("span",{className:"text-foreground",children:"SparkeCoder is exploring the codebase"}):p&&!m?(0,v.jsx)("span",{className:"text-foreground",children:"Exploration complete"}):m?(0,v.jsx)("span",{className:"text-red-500",children:"Exploration failed"}):(0,v.jsx)("span",{className:"text-muted-foreground",children:"Exploring..."})}),h&&x&&(0,v.jsx)("div",{className:"text-xs text-muted-foreground truncate mt-0.5",children:"tool"===x.type?(0,v.jsx)("span",{className:"font-mono",children:x.name}):(0,v.jsx)("span",{className:"italic",children:x.content})}),p&&!m&&(0,v.jsxs)("div",{className:"text-xs text-muted-foreground mt-0.5",children:[f.toolCallCount," actions · ",f.filesExplored," files explored"]})]}),(0,v.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[(0,v.jsxs)(A.Button,{variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs gap-1.5",onClick:()=>u(!0),children:[(0,v.jsx)(xA.default,{className:"size-3"}),"View Progress"]}),(0,v.jsx)("button",{onClick:()=>a(!i),className:"p-1 hover:bg-muted rounded transition-colors",children:i?(0,v.jsx)(ol.ChevronDownIcon,{className:"size-4 text-muted-foreground"}):(0,v.jsx)(aL,{className:"size-4 text-muted-foreground"})})]})]}),i&&(0,v.jsxs)("div",{className:"border-t",children:[(0,v.jsx)("div",{className:"px-3 py-2 bg-muted/30 border-b",children:(0,v.jsxs)("div",{className:"flex items-start gap-2",children:[(0,v.jsx)(mb,{className:"size-3 text-muted-foreground mt-0.5 shrink-0"}),(0,v.jsx)("p",{className:"text-xs text-muted-foreground truncate",title:g,children:xP(g,100)})]})}),y&&(0,v.jsxs)("div",{className:"border-b",children:[(0,v.jsx)("div",{className:"px-3 py-2",children:o?(0,v.jsx)("div",{className:"text-sm text-foreground whitespace-pre-wrap break-words max-h-[300px] overflow-auto",children:y}):(0,v.jsx)("p",{className:"text-sm text-muted-foreground",children:w})}),j&&(0,v.jsx)("button",{onClick:()=>l(!o),className:"w-full px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/50 flex items-center justify-center gap-1 border-t",children:o?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(ol.ChevronDownIcon,{className:"size-3"}),"Show less"]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(aL,{className:"size-3"}),"Show full result"]})})]}),m&&t&&(0,v.jsx)("div",{className:"px-3 py-2 text-xs text-red-400 border-b",children:t.error||"Exploration failed"}),n.length>0&&(0,v.jsxs)("div",{ref:d,className:"max-h-[100px] overflow-auto bg-zinc-950/50",children:[n.slice(-6).map((e,t)=>(0,v.jsx)(xM,{step:e},e.id||t)),n.length>6&&(0,v.jsxs)("div",{className:"px-3 py-1 text-xs text-zinc-500",children:["+",n.length-6," more steps"]})]})]}),(0,v.jsx)(xT,{open:c,onOpenChange:u,title:"Explore Agent",description:"Exploring your codebase to find relevant information",query:g,steps:n,status:h?"running":m?"error":"completed"})]})}function xM({step:e}){let t=(e=>{switch(e){case"grep":return mb;case"glob":case"list_dir":return xS;case"read_file":return gz;default:return xw}})(e.toolName);return(0,v.jsxs)("div",{className:"px-3 py-1 text-xs font-mono border-b border-zinc-800/50 last:border-0 flex items-center gap-2",children:["tool_call"===e.type&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(t,{className:"size-2.5 text-blue-400 shrink-0"}),(0,v.jsx)("span",{className:"text-blue-400 truncate",children:e.toolName})]}),"tool_result"===e.type&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(oo,{className:"size-2.5 text-green-400 shrink-0"}),(0,v.jsx)("span",{className:"text-zinc-500 truncate",children:xP(e.content,50)})]}),"text"===e.type&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(xC,{className:"size-2.5 text-purple-400 shrink-0"}),(0,v.jsx)("span",{className:"text-zinc-400 truncate",children:xP(e.content,50)})]}),"thought"===e.type&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(xC,{className:"size-2.5 text-amber-400 shrink-0"}),(0,v.jsx)("span",{className:"text-zinc-500 italic truncate",children:xP(e.content,50)})]})]})}var gS=gS;let xI=(0,T.default)("trash",[["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);var ou=ou;let xL={pending:oc,in_progress:g5,completed:oo,cancelled:oh},xD={pending:"text-muted-foreground",in_progress:"text-blue-600 dark:text-blue-400",completed:"text-green-600 dark:text-green-400",cancelled:"text-muted-foreground/50"},xO={add:"Add Tasks",list:"List Tasks",mark:"Update Task",clear:"Clear Tasks"},xz=({action:e})=>{switch(e){case"add":return(0,v.jsx)(gS.default,{className:"size-3.5"});case"list":default:return(0,v.jsx)(g3,{className:"size-3.5"});case"mark":return(0,v.jsx)(oo,{className:"size-3.5"});case"clear":return(0,v.jsx)(xI,{className:"size-3.5"})}};function xF({input:e,output:t,status:r,className:n}){let[s,i]=(0,b.useState)(!0),a=e?.action||"list",o="pending"===r||"streaming"===r||"running"===r,l="completed"===r,c="error"===r||t?.success===!1,u=l&&t?.success?oo:c?oh:o?ou.default:g3,d=l&&t?.success?"text-green-600 dark:text-green-500":c?"text-red-600 dark:text-red-500":o?"text-muted-foreground animate-pulse":"text-muted-foreground",h=e=>{let t=xL[e.status]||oc,r=xD[e.status]||"text-muted-foreground";return(0,v.jsxs)("div",{className:"flex items-start gap-2 py-1",children:[(0,v.jsx)(t,{className:(0,k.cn)("size-4 mt-0.5 shrink-0",r)}),(0,v.jsx)("span",{className:(0,k.cn)("text-sm","cancelled"===e.status&&"line-through text-muted-foreground/50","completed"===e.status&&"text-muted-foreground"),children:e.content})]},e.id)};return(0,v.jsxs)("div",{className:(0,k.cn)("rounded-lg border overflow-hidden bg-background",n),children:[(0,v.jsxs)("button",{onClick:()=>i(!s),className:"flex items-center justify-between w-full px-3 py-2.5 bg-muted/50 hover:bg-muted/70 transition-colors",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(u,{className:(0,k.cn)("size-4 shrink-0",d)}),(0,v.jsx)(xz,{action:a}),(0,v.jsx)("span",{className:"font-medium text-sm",children:xO[a]||a}),o&&(0,v.jsx)("span",{className:"text-xs text-muted-foreground animate-pulse",children:"running..."})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[t?.stats&&(0,v.jsx)("div",{className:"flex items-center gap-1.5 text-xs",children:(0,v.jsxs)("span",{className:"text-muted-foreground",children:[t.stats.completed,"/",t.stats.total]})}),t?.itemsAdded!==void 0&&(0,v.jsxs)(C,{variant:"secondary",className:"text-xs bg-green-500/10 text-green-600 dark:text-green-400",children:["+",t.itemsAdded]}),t?.itemsRemoved!==void 0&&(0,v.jsxs)(C,{variant:"secondary",className:"text-xs",children:["cleared ",t.itemsRemoved]}),s?(0,v.jsx)(ol.ChevronDownIcon,{className:"size-4 text-muted-foreground"}):(0,v.jsx)(aL,{className:"size-4 text-muted-foreground"})]})]}),s&&(0,v.jsxs)("div",{className:"border-t",children:[t?.stats&&(0,v.jsxs)("div",{className:"px-3 py-2 bg-muted/30 border-b flex items-center gap-4 text-xs",children:[(0,v.jsxs)("div",{className:"flex items-center gap-1",children:[(0,v.jsx)(oc,{className:"size-3 text-muted-foreground"}),(0,v.jsxs)("span",{children:[t.stats.pending," pending"]})]}),(0,v.jsxs)("div",{className:"flex items-center gap-1",children:[(0,v.jsx)(g5,{className:"size-3 text-blue-500"}),(0,v.jsxs)("span",{children:[t.stats.inProgress," active"]})]}),(0,v.jsxs)("div",{className:"flex items-center gap-1",children:[(0,v.jsx)(oo,{className:"size-3 text-green-500"}),(0,v.jsxs)("span",{children:[t.stats.completed," done"]})]})]}),t?.items&&t.items.length>0&&(0,v.jsx)("div",{className:"px-3 py-2 max-h-[200px] overflow-auto",children:t.items.map(h)}),t?.item&&!t.items&&(0,v.jsx)("div",{className:"px-3 py-2",children:h(t.item)}),"add"===a&&e?.items&&!t?.items&&(0,v.jsx)("div",{className:"px-3 py-2 max-h-[200px] overflow-auto",children:e.items.map((e,t)=>(0,v.jsxs)("div",{className:"flex items-start gap-2 py-1 text-muted-foreground",children:[(0,v.jsx)(oc,{className:"size-4 mt-0.5 shrink-0"}),(0,v.jsx)("span",{className:"text-sm",children:e.content})]},t))}),"list"===a&&t?.items?.length===0&&(0,v.jsx)("div",{className:"px-3 py-4 text-center text-muted-foreground text-sm",children:"No tasks yet"}),t?.error&&(0,v.jsxs)("div",{className:"px-3 py-2 border-t bg-red-500/5 text-red-600 dark:text-red-400 text-xs flex items-start gap-2",children:[(0,v.jsx)(oh,{className:"size-3.5 mt-0.5 shrink-0"}),(0,v.jsx)("span",{children:t.error})]})]})]})}let xB=(0,T.default)("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"}]]);var ou=ou;let x$=(0,T.default)("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]);function xV({input:e,output:t,status:r,className:n}){let[s,i]=(0,b.useState)(!0),a=e?.action||"list",o=e?.skillName||t?.skillName,l="pending"===r||"streaming"===r||"running"===r,c="completed"===r,u="error"===r||t?.success===!1,d=c&&t?.success?oo:u?oh:l?ou.default:xB,h=c&&t?.success?"text-green-600 dark:text-green-500":u?"text-red-600 dark:text-red-500":l?"text-muted-foreground animate-pulse":"text-muted-foreground",p="load"===a?o?`Load: ${o}`:"Load Skill":"List Skills";return(0,v.jsxs)("div",{className:(0,k.cn)("rounded-lg border overflow-hidden bg-background",n),children:[(0,v.jsxs)("button",{onClick:()=>i(!s),className:"flex items-center justify-between w-full px-3 py-2.5 bg-muted/50 hover:bg-muted/70 transition-colors",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(d,{className:(0,k.cn)("size-4 shrink-0",h)}),"list"===a?(0,v.jsx)(x$,{className:"size-3.5 text-muted-foreground"}):(0,v.jsx)(xC,{className:"size-3.5 text-muted-foreground"}),(0,v.jsx)("span",{className:"font-medium text-sm truncate",children:p}),l&&(0,v.jsx)("span",{className:"text-xs text-muted-foreground animate-pulse",children:"loading..."})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[t?.skillCount!==void 0&&(0,v.jsxs)(C,{variant:"secondary",className:"text-xs",children:[t.skillCount," skills"]}),t?.contentLength!==void 0&&(0,v.jsxs)(C,{variant:"secondary",className:"text-xs",children:[Math.round(t.contentLength/1e3),"k chars"]}),s?(0,v.jsx)(ol.ChevronDownIcon,{className:"size-4 text-muted-foreground"}):(0,v.jsx)(aL,{className:"size-4 text-muted-foreground"})]})]}),s&&(0,v.jsxs)("div",{className:"border-t",children:[t?.skills&&t.skills.length>0&&(0,v.jsx)("div",{className:"max-h-[200px] overflow-auto",children:t.skills.map((e,r)=>(0,v.jsxs)("div",{className:(0,k.cn)("px-3 py-2 flex items-start gap-2",r<t.skills.length-1&&"border-b"),children:[(0,v.jsx)(xB,{className:"size-4 mt-0.5 shrink-0 text-muted-foreground"}),(0,v.jsxs)("div",{className:"min-w-0",children:[(0,v.jsx)("div",{className:"font-medium text-sm",children:e.name}),e.description&&(0,v.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:e.description})]})]},e.name))}),"load"===a&&t?.success&&t.skillName&&(0,v.jsxs)("div",{className:"px-3 py-2 bg-muted/30",children:[(0,v.jsxs)("div",{className:"flex items-center justify-between",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)(xC,{className:"size-4 text-green-600 dark:text-green-400"}),(0,v.jsx)("span",{className:"font-medium text-sm",children:t.skillName})]}),t.content&&(0,v.jsx)(A.Button,{variant:"ghost",size:"icon",className:"size-6",onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(t.content)},children:(0,v.jsx)(om,{className:"size-3"})})]}),t.description&&(0,v.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:t.description})]}),t?.content&&(0,v.jsx)("div",{className:"max-h-[150px] overflow-auto border-t",children:(0,v.jsxs)("pre",{className:"px-3 py-2 text-xs font-mono text-muted-foreground whitespace-pre-wrap",children:[t.content.slice(0,500),t.content.length>500&&"..."]})}),t?.availableSkills&&t.availableSkills.length>0&&(0,v.jsx)("div",{className:"px-3 py-2 bg-muted/30 border-t",children:(0,v.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Available: ",t.availableSkills.join(", ")]})}),"list"===a&&t?.skills?.length===0&&(0,v.jsx)("div",{className:"px-3 py-4 text-center text-muted-foreground text-sm",children:"No skills available"}),t?.error&&(0,v.jsxs)("div",{className:"px-3 py-2 border-t bg-red-500/5 text-red-600 dark:text-red-400 text-xs flex items-start gap-2",children:[(0,v.jsx)(oh,{className:"size-3.5 mt-0.5 shrink-0"}),(0,v.jsx)("span",{children:t.error})]})]})]})}var xy=xy;let xU=(0,T.default)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),xG=(0,T.default)("search-code",[["path",{d:"m13 13.5 2-2.5-2-2.5",key:"1rvxrh"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}],["path",{d:"M9 8.5 7 11l2 2.5",key:"6ffwbx"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);function xW({severity:e,className:t}){switch(e){case"error":return(0,v.jsx)(xy.default,{className:(0,k.cn)("text-red-500",t)});case"warning":return(0,v.jsx)(xt,{className:(0,k.cn)("text-yellow-500",t)});case"info":return(0,v.jsx)(xU,{className:(0,k.cn)("text-blue-500",t)});default:return(0,v.jsx)(xU,{className:(0,k.cn)("text-muted-foreground",t)})}}function xq({file:e,isExpanded:t,onToggle:r}){let n=e.errors>0,s=e.warnings>0;return(0,v.jsxs)("div",{className:"border-b last:border-b-0",children:[(0,v.jsxs)("button",{onClick:r,className:"flex items-center justify-between w-full px-3 py-2 hover:bg-muted/50 transition-colors text-left",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(xc,{className:"size-3.5 text-muted-foreground shrink-0"}),(0,v.jsx)("span",{className:"font-mono text-sm truncate",children:e.relativePath}),n&&(0,v.jsxs)(C,{variant:"destructive",className:"text-xs gap-1",children:[(0,v.jsx)(xy.default,{className:"size-3"}),e.errors]}),s&&(0,v.jsxs)(C,{variant:"secondary",className:"text-xs gap-1 bg-yellow-500/10 text-yellow-600 dark:text-yellow-400",children:[(0,v.jsx)(xt,{className:"size-3"}),e.warnings]})]}),t?(0,v.jsx)(ol.ChevronDownIcon,{className:"size-4 text-muted-foreground shrink-0"}):(0,v.jsx)(aL,{className:"size-4 text-muted-foreground shrink-0"})]}),t&&e.diagnostics.length>0&&(0,v.jsx)("div",{className:"bg-muted/30 px-3 py-2 space-y-1",children:e.diagnostics.map((e,t)=>(0,v.jsxs)("div",{className:(0,k.cn)("flex items-start gap-2 px-2 py-1.5 rounded text-sm","error"===e.severity&&"bg-red-500/5","warning"===e.severity&&"bg-yellow-500/5"),children:[(0,v.jsx)(xW,{severity:e.severity,className:"size-4 mt-0.5 shrink-0"}),(0,v.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,v.jsxs)("span",{className:"font-mono text-xs text-muted-foreground shrink-0",children:[e.line,":",e.column]}),e.source&&(0,v.jsx)(C,{variant:"outline",className:"text-xs",children:e.source}),e.code&&(0,v.jsxs)("span",{className:"text-xs text-muted-foreground font-mono",children:["[",e.code,"]"]})]}),(0,v.jsx)("p",{className:"text-sm mt-0.5 break-words",children:e.message})]})]},t))})]})}function xH({input:e,output:t,status:r,className:n}){let[s,i]=(0,b.useState)(!0),[a,o]=(0,b.useState)(new Set),l="pending"===r||"streaming"===r||"running"===r||"completed"===r&&!t,c="completed"===r&&t?.success===!0,u="error"===r||t?.success===!1,d=t?.totalErrors??0,h=t?.totalWarnings??0,p=d>0||h>0,m=t?.files?.length??0,f=(0,b.useMemo)(()=>e.paths&&0!==e.paths.length?1===e.paths.length?e.paths[0]:`${e.paths.length} paths`:"all files",[e.paths]),g=(0,b.useMemo)(()=>t?.files?.filter(e=>e.errors>0)||[],[t?.files]);(0,b.useMemo)(()=>{g.length>0&&0===a.size&&o(new Set(g.slice(0,5).map(e=>e.path)))},[g]);let x=p?xy.default:c?oo:u?xy.default:xG,y=p?"text-red-500":c?"text-green-500":u?"text-red-500":"text-muted-foreground";return(0,v.jsxs)("div",{className:(0,k.cn)("rounded-lg border overflow-hidden bg-background",n),children:[(0,v.jsxs)("button",{onClick:()=>i(!s),className:"flex items-center justify-between w-full px-3 py-2.5 bg-muted/50 hover:bg-muted/70 transition-colors",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(x,{className:(0,k.cn)("size-4 shrink-0",y)}),(0,v.jsx)("span",{className:"font-medium text-sm",children:"Linter"}),(0,v.jsxs)("span",{className:"text-xs text-muted-foreground truncate",children:[c?"checked":"checking"," ",f]}),l&&(0,v.jsx)("span",{className:"text-xs text-muted-foreground animate-pulse",children:"analyzing..."})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[c&&(0,v.jsxs)(v.Fragment,{children:[d>0&&(0,v.jsxs)(C,{variant:"destructive",className:"text-xs gap-1",children:[(0,v.jsx)(xy.default,{className:"size-3"}),d," error",1!==d?"s":""]}),h>0&&(0,v.jsxs)(C,{variant:"secondary",className:"text-xs gap-1 bg-yellow-500/10 text-yellow-600 dark:text-yellow-400",children:[(0,v.jsx)(xt,{className:"size-3"}),h," warning",1!==h?"s":""]}),!p&&(0,v.jsxs)(C,{variant:"secondary",className:"text-xs gap-1 bg-green-500/10 text-green-600 dark:text-green-400",children:[(0,v.jsx)(oo,{className:"size-3"}),"No issues"]})]}),s?(0,v.jsx)(ol.ChevronDownIcon,{className:"size-4 text-muted-foreground"}):(0,v.jsx)(aL,{className:"size-4 text-muted-foreground"})]})]}),s&&(0,v.jsxs)("div",{className:"border-t",children:[l?(0,v.jsxs)("div",{className:"px-3 py-8 text-center text-muted-foreground text-sm",children:[(0,v.jsx)(xG,{className:"size-6 mx-auto mb-2 animate-pulse"}),(0,v.jsx)("span",{children:"Analyzing files for lint errors..."})]}):u&&t?.error?(0,v.jsxs)("div",{className:"px-3 py-4 text-red-600 dark:text-red-400 text-sm flex items-start gap-2",children:[(0,v.jsx)(xy.default,{className:"size-4 mt-0.5 shrink-0"}),(0,v.jsx)("span",{children:t.error})]}):t?.files&&t.files.length>0?(0,v.jsx)("div",{className:"max-h-[400px] overflow-y-auto",children:t.files.map(e=>(0,v.jsx)(xq,{file:e,isExpanded:a.has(e.path),onToggle:()=>{var t;return t=e.path,void o(e=>{let r=new Set(e);return r.has(t)?r.delete(t):r.add(t),r})}},e.path))}):(0,v.jsx)("div",{className:"px-3 py-4 text-sm",children:t?.message?(0,v.jsxs)("div",{className:"flex items-center gap-2 text-green-600 dark:text-green-400",children:[(0,v.jsx)(oo,{className:"size-4"}),(0,v.jsx)("span",{children:t.message})]}):(0,v.jsx)("div",{className:"text-muted-foreground italic",children:"No files analyzed yet."})}),c&&m>0&&(0,v.jsxs)("div",{className:"px-3 py-2 border-t bg-muted/30 text-xs text-muted-foreground",children:["Checked ",m," file",1!==m?"s":"",p&&(0,v.jsxs)("span",{children:[" • ",(0,v.jsxs)("span",{className:d>0?"text-red-500":"",children:[d," error",1!==d?"s":""]})," • ",(0,v.jsxs)("span",{className:h>0?"text-yellow-500":"",children:[h," warning",1!==h?"s":""]})]})]})]})]})}let xK=(0,T.default)("loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]),xX=(0,T.default)("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]),xY=(0,T.default)("mic-off",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M16.95 16.95A7 7 0 0 1 5 12v-2",key:"cqa7eg"}],["path",{d:"M18.89 13.23A7 7 0 0 0 19 12v-2",key:"16hl24"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}]]),xJ=({className:e,onTranscriptionChange:t,onInterimTranscription:r,onAudioRecorded:n,lang:s="en-US",disabled:i,...a})=>{let[o,l]=(0,b.useState)(!1),[c,u]=(0,b.useState)(!1),[d,h]=(0,b.useState)("none"),p=(0,b.useRef)(null),m=(0,b.useRef)(null),f=(0,b.useRef)([]),g=(0,b.useRef)("");(0,b.useEffect)(()=>{h("SpeechRecognition"in window||"webkitSpeechRecognition"in window?"speech-recognition":"MediaRecorder"in window&&"mediaDevices"in navigator?"media-recorder":"none")},[]),(0,b.useEffect)(()=>{if("speech-recognition"!==d)return;let e=new(window.SpeechRecognition||window.webkitSpeechRecognition);return e.continuous=!0,e.interimResults=!0,e.lang=s,e.onstart=()=>{l(!0),g.current=""},e.onend=()=>{l(!1),r?.("")},e.onresult=e=>{let n="",s="";for(let t=e.resultIndex;t<e.results.length;t++){let r=e.results[t],i=r[0]?.transcript??"";r.isFinal?s+=i:n+=i}s&&(g.current+=s,t?.(s),r?.("")),n&&r?.(n)},e.onerror=e=>{console.error("Speech recognition error:",e.error),l(!1),r?.("")},p.current=e,()=>{p.current&&p.current.abort()}},[d,s,t,r]);let x=(0,b.useCallback)(async()=>{if(!n)return void console.warn("SpeechInput: onAudioRecorded callback is required for MediaRecorder fallback");try{let e=await navigator.mediaDevices.getUserMedia({audio:!0}),r=new MediaRecorder(e);f.current=[],r.ondataavailable=e=>{e.data.size>0&&f.current.push(e.data)},r.onstop=async()=>{for(let t of e.getTracks())t.stop();let r=new Blob(f.current,{type:"audio/webm"});if(r.size>0){u(!0);try{let e=await n(r);e&&t?.(e)}catch(e){console.error("Transcription error:",e)}finally{u(!1)}}},r.onerror=t=>{for(let r of(console.error("MediaRecorder error:",t),l(!1),e.getTracks()))r.stop()},m.current=r,r.start(),l(!0)}catch(e){console.error("Failed to start MediaRecorder:",e),l(!1)}},[n,t]),y=(0,b.useCallback)(()=>{m.current?.state==="recording"&&m.current.stop(),l(!1)},[]),w=(0,b.useCallback)(()=>{if("speech-recognition"===d&&p.current)if(o)p.current.stop();else try{p.current.start()}catch(e){console.warn("Speech recognition start error:",e)}else"media-recorder"===d&&(o?y():x())},[d,o,x,y]),j=i||"none"===d||"speech-recognition"===d&&!p.current||"media-recorder"===d&&!n||c;return"none"===d?(0,v.jsx)(A.Button,{type:"button",className:(0,k.cn)("relative rounded-full opacity-50 cursor-not-allowed",e),disabled:!0,title:"Speech recognition not supported in this browser",...a,children:(0,v.jsx)(xY,{className:"size-4"})}):(0,v.jsxs)("div",{className:"relative inline-flex items-center justify-center",children:[o&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("span",{className:"absolute inset-0 rounded-full bg-red-500/20 animate-ping"}),(0,v.jsx)("span",{className:"absolute inset-0 rounded-full bg-red-500/10 animate-ping",style:{animationDelay:"0.2s"}})]}),(0,v.jsxs)(A.Button,{type:"button",className:(0,k.cn)("relative z-10 rounded-full transition-all duration-200",o?"bg-red-500 text-white hover:bg-red-600 shadow-lg shadow-red-500/25":"hover:bg-muted",e),disabled:j,onClick:w,title:o?"Stop recording":"Start voice input",variant:o?"default":"ghost",...a,children:[c&&(0,v.jsx)(xK,{className:"size-4 animate-spin"}),!c&&o&&(0,v.jsxs)("div",{className:"relative",children:[(0,v.jsx)(xX,{className:"size-4"}),(0,v.jsx)("span",{className:"absolute -top-0.5 -right-0.5 size-2 bg-white rounded-full animate-pulse"})]}),!(c||o)&&(0,v.jsx)(xX,{className:"size-4"})]})]})};function xZ(e){var t;let r,n=(t=e,(r=b.forwardRef((e,t)=>{let{children:r,...n}=e;if(b.isValidElement(r)){var s;let e,i,a=(s=r,(i=(e=Object.getOwnPropertyDescriptor(s.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.ref:(i=(e=Object.getOwnPropertyDescriptor(s,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.props.ref:s.props.ref||s.ref),o=function(e,t){let r={...t};for(let n in t){let s=e[n],i=t[n];/^on[A-Z]/.test(n)?s&&i?r[n]=(...e)=>{let t=i(...e);return s(...e),t}:s&&(r[n]=s):"style"===n?r[n]={...s,...i}:"className"===n&&(r[n]=[s,i].filter(Boolean).join(" "))}return{...e,...r}}(n,r.props);return r.type!==b.Fragment&&(o.ref=t?(0,aY.composeRefs)(t,a):a),b.cloneElement(r,o)}return b.Children.count(r)>1?b.Children.only(null):null})).displayName=`${t}.SlotClone`,r),s=b.forwardRef((e,t)=>{let{children:r,...s}=e,i=b.Children.toArray(r),a=i.find(x0);if(a){let e=a.props.children,r=i.map(t=>t!==a?t:b.Children.count(e)>1?b.Children.only(null):b.isValidElement(e)?e.props.children:null);return(0,v.jsx)(n,{...s,ref:t,children:b.isValidElement(e)?b.cloneElement(e,void 0,r):null})}return(0,v.jsx)(n,{...s,ref:t,children:r})});return s.displayName=`${e}.Slot`,s}var xQ=Symbol("radix.slottable");function x0(e){return b.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===xQ}var x1=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let r=xZ(`Primitive.${t}`),n=b.forwardRef((e,n)=>{let{asChild:s,...i}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,v.jsx)(s?r:t,{...i,ref:n})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),x2="Popover",[x5,x3]=function(e,t=[]){let r=[],n=()=>{let t=r.map(e=>b.createContext(e));return function(r){let n=r?.[e]||t;return b.useMemo(()=>({[`__scope${e}`]:{...r,[e]:n}}),[r,n])}};return n.scopeName=e,[function(t,n){let s=b.createContext(n),i=r.length;r=[...r,n];let a=t=>{let{scope:r,children:n,...a}=t,o=r?.[e]?.[i]||s,l=b.useMemo(()=>a,Object.values(a));return(0,v.jsx)(o.Provider,{value:l,children:n})};return a.displayName=t+"Provider",[a,function(r,a){let o=a?.[e]?.[i]||s,l=b.useContext(o);if(l)return l;if(void 0!==n)return n;throw Error(`\`${r}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let r=()=>{let r=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let n=r.reduce((t,{useScope:r,scopeName:n})=>{let s=r(e)[`__scope${n}`];return{...t,...s}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:n}),[n])}};return r.scopeName=t.scopeName,r}(n,...t)]}(x2,[mL.createPopperScope]),x6=(0,mL.createPopperScope)(),[x4,x8]=x5(x2),x9=e=>{let{__scopePopover:t,children:r,open:n,defaultOpen:s,onOpenChange:i,modal:a=!1}=e,o=x6(t),l=b.useRef(null),[c,u]=b.useState(!1),[d,h]=(0,aK.useControllableState)({prop:n,defaultProp:s??!1,onChange:i,caller:x2});return(0,v.jsx)(mL.Root,{...o,children:(0,v.jsx)(x4,{scope:t,contentId:(0,a1.useId)(),triggerRef:l,open:d,onOpenChange:h,onOpenToggle:b.useCallback(()=>h(e=>!e),[h]),hasCustomAnchor:c,onCustomAnchorAdd:b.useCallback(()=>u(!0),[]),onCustomAnchorRemove:b.useCallback(()=>u(!1),[]),modal:a,children:r})})};x9.displayName=x2;var x7="PopoverAnchor",ye=b.forwardRef((e,t)=>{let{__scopePopover:r,...n}=e,s=x8(x7,r),i=x6(r),{onCustomAnchorAdd:a,onCustomAnchorRemove:o}=s;return b.useEffect(()=>(a(),()=>o()),[a,o]),(0,v.jsx)(mL.Anchor,{...i,...n,ref:t})});ye.displayName=x7;var yt="PopoverTrigger";b.forwardRef((e,t)=>{let{__scopePopover:r,...n}=e,s=x8(yt,r),i=x6(r),a=(0,aY.useComposedRefs)(t,s.triggerRef),o=(0,v.jsx)(x1.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":yp(s.open),...n,ref:a,onClick:(0,aH.composeEventHandlers)(e.onClick,s.onOpenToggle)});return s.hasCustomAnchor?o:(0,v.jsx)(mL.Anchor,{asChild:!0,...i,children:o})}).displayName=yt;var yr="PopoverPortal",[yn,ys]=x5(yr,{forceMount:void 0}),yi=e=>{let{__scopePopover:t,forceMount:r,children:n,container:s}=e,i=x8(yr,t);return(0,v.jsx)(yn,{scope:t,forceMount:r,children:(0,v.jsx)(a0.Presence,{present:r||i.open,children:(0,v.jsx)(mD.Portal,{asChild:!0,container:s,children:n})})})};yi.displayName=yr;var ya="PopoverContent",yo=b.forwardRef((e,t)=>{let r=ys(ya,e.__scopePopover),{forceMount:n=r.forceMount,...s}=e,i=x8(ya,e.__scopePopover);return(0,v.jsx)(a0.Presence,{present:n||i.open,children:i.modal?(0,v.jsx)(yc,{...s,ref:t}):(0,v.jsx)(yu,{...s,ref:t})})});yo.displayName=ya;var yl=xZ("PopoverContent.RemoveScroll"),yc=b.forwardRef((e,t)=>{let r=x8(ya,e.__scopePopover),n=b.useRef(null),s=(0,aY.useComposedRefs)(t,n),i=b.useRef(!1);return b.useEffect(()=>{let e=n.current;if(e)return(0,m8.hideOthers)(e)},[]),(0,v.jsx)(m9.RemoveScroll,{as:yl,allowPinchZoom:!0,children:(0,v.jsx)(yd,{...e,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:(0,aH.composeEventHandlers)(e.onCloseAutoFocus,e=>{e.preventDefault(),i.current||r.triggerRef.current?.focus()}),onPointerDownOutside:(0,aH.composeEventHandlers)(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,r=0===t.button&&!0===t.ctrlKey;i.current=2===t.button||r},{checkForDefaultPrevented:!1}),onFocusOutside:(0,aH.composeEventHandlers)(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),yu=b.forwardRef((e,t)=>{let r=x8(ya,e.__scopePopover),n=b.useRef(!1),s=b.useRef(!1);return(0,v.jsx)(yd,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(n.current||r.triggerRef.current?.focus(),t.preventDefault()),n.current=!1,s.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(n.current=!0,"pointerdown"===t.detail.originalEvent.type&&(s.current=!0));let i=t.target;r.triggerRef.current?.contains(i)&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&s.current&&t.preventDefault()}})}),yd=b.forwardRef((e,t)=>{let{__scopePopover:r,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...d}=e,h=x8(ya,r),p=x6(r);return(0,mM.useFocusGuards)(),(0,v.jsx)(mI.FocusScope,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:i,children:(0,v.jsx)(mR.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:u,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1),children:(0,v.jsx)(mL.Content,{"data-state":yp(h.open),role:"dialog",id:h.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),yh="PopoverClose";function yp(e){return e?"open":"closed"}function ym({...e}){return(0,v.jsx)(x9,{"data-slot":"popover",...e})}function yf({className:e,align:t="center",sideOffset:r=4,...n}){return(0,v.jsx)(yi,{children:(0,v.jsx)(yo,{"data-slot":"popover-content",align:t,sideOffset:r,className:(0,k.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...n})})}function yg({...e}){return(0,v.jsx)(ye,{"data-slot":"popover-anchor",...e})}b.forwardRef((e,t)=>{let{__scopePopover:r,...n}=e,s=x8(yh,r);return(0,v.jsx)(x1.button,{type:"button",...n,ref:t,onClick:(0,aH.composeEventHandlers)(e.onClick,()=>s.onOpenChange(!1))})}).displayName=yh,b.forwardRef((e,t)=>{let{__scopePopover:r,...n}=e,s=x6(r);return(0,v.jsx)(mL.Arrow,{...s,...n,ref:t})}).displayName="PopoverArrow";let yx=(0,T.default)("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]),yy=(0,T.default)("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),yv=(0,b.createContext)(null),yb=/@([\w./-]+\/?)/g,yw=[{id:"help",name:"help",description:"Ask about available features",icon:(0,v.jsx)(yy,{className:"size-4"}),prompt:"What commands and features are available? How can you help me?"},{id:"terminal",name:"terminal",description:"Open a new terminal",icon:(0,v.jsx)(xw,{className:"size-4"}),prompt:"Please open a new terminal session for me."},{id:"explain",name:"explain",description:"Explain a file or code",icon:(0,v.jsx)(xc,{className:"size-4"}),prompt:"Please explain this code: "},{id:"fix",name:"fix",description:"Fix a bug or issue",icon:(0,v.jsx)(yx,{className:"size-4"}),prompt:"Please help me fix this issue: "},{id:"refactor",name:"refactor",description:"Refactor code",icon:(0,v.jsx)(yx,{className:"size-4"}),prompt:"Please refactor this code to be cleaner and more maintainable: "},{id:"test",name:"test",description:"Write tests",icon:(0,v.jsx)(yx,{className:"size-4"}),prompt:"Please write tests for: "}];function yk({children:e}){let t=(0,b.useCallback)(e=>{let t,r=[],n=RegExp(yb.source,"g");for(;null!==(t=n.exec(e));){let e=t[1],n=e.endsWith("/");r.push({id:`mention-${t.index}`,type:n?"folder":"file",path:n?e.slice(0,-1):e,name:e.split("/").pop()?.replace(/\/$/,"")||e})}return r},[]),r=(0,b.useCallback)(()=>{},[]),n=(0,b.useMemo)(()=>({extractMentions:t,clear:r}),[t,r]);return(0,v.jsx)(yv.Provider,{value:n,children:e})}function yj({sessionId:e,value:t,onChange:r,onSlashCommand:n,slashCommands:s=yw,showHighlights:i=!0,className:a,onKeyDown:o,disabled:l,...c}){let u=(0,b.useRef)(null),d=(0,b.useRef)(null),[h,p]=(0,b.useState)(null),[m,f]=(0,b.useState)(0),[g,x]=(0,b.useState)({top:0,left:0}),[y,w]=(0,b.useState)(!1),j=gP(),{files:N,isLoading:S}=function({sessionId:e,query:t,enabled:r=!0,limit:n=20,debounceMs:s=150}){let[i,a]=(0,b.useState)([]),[o,l]=(0,b.useState)(!1),[c,u]=(0,b.useState)(null),[d,h]=(0,b.useState)(null),p=(0,b.useRef)(null),m=(0,b.useRef)(null),f=(0,b.useCallback)(async t=>{m.current&&m.current.abort(),m.current=new AbortController;try{l(!0),u(null);let r=await (0,g1.getWorkspaceFiles)(e,t,n);a(r.files),h(r.workingDirectory),r.error&&u(r.error)}catch(e){e instanceof Error&&"AbortError"!==e.name&&(u(e.message),a([]))}finally{l(!1)}},[e,n]);return(0,b.useEffect)(()=>r&&e?(p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{f(t)},s),()=>{p.current&&clearTimeout(p.current)}):void a([]),[t,r,e,s,f]),(0,b.useEffect)(()=>()=>{m.current&&m.current.abort(),p.current&&clearTimeout(p.current)},[]),{files:i,isLoading:o,error:c,workingDirectory:d}}({sessionId:e,query:h?.type==="file"?h.query:"",enabled:h?.type==="file",limit:15}),C=(0,b.useMemo)(()=>{if(h?.type!=="command")return[];let e=h.query.toLowerCase();return s.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e))},[h,s]),A=h?.type==="file"?N:C,_=null!==h&&(A.length>0||S),T=(0,b.useCallback)(()=>{let e=u.current;if(!e||!h)return;let r=document.createElement("div"),n=window.getComputedStyle(e);["fontFamily","fontSize","fontWeight","lineHeight","padding","paddingLeft","paddingTop","border","borderWidth","boxSizing","whiteSpace","wordWrap","wordBreak"].forEach(e=>{r.style[e]=n[e]}),r.style.position="absolute",r.style.visibility="hidden",r.style.height="auto",r.style.width=`${e.clientWidth}px`,r.style.overflow="hidden",r.textContent=t.substring(0,h.startIndex);let s=document.createElement("span");s.textContent="|",r.appendChild(s),document.body.appendChild(r);let i=e.getBoundingClientRect(),a=s.getBoundingClientRect(),o=r.getBoundingClientRect(),l=a.left-o.left,c=a.top-o.top+parseInt(n.lineHeight),d=e.scrollTop;document.body.removeChild(r),x({left:Math.min(l,i.width-250),top:c-d+4})},[h,t]);(0,b.useEffect)(()=>{T()},[T]);let E=(0,b.useCallback)((e,t)=>{if(0===t)return void p(null);let r=e.slice(0,t),n=r.match(/@([^\s@]*)$/);if(n){p({type:"file",query:n[1],startIndex:t-n[0].length,endIndex:t}),f(0);return}let s=r.match(/(?:^|\s)\/([^\s]*)$/);if(s){p({type:"command",query:s[1],startIndex:t-s[1].length-1,endIndex:t}),f(0);return}p(null)},[]),P=(0,b.useCallback)(e=>{let t=e.target.value,n=e.target.selectionStart??0;r(t),E(t,n)},[r,E]),R=(0,b.useCallback)(e=>{if(h&&u.current){if("file"===h.type&&"path"in e){let n=t.slice(0,h.startIndex),s=t.slice(h.endIndex),i=`@${e.path}${"folder"===e.type?"/":""} `;r(n+i+s),setTimeout(()=>{if(u.current){let e=h.startIndex+i.length;u.current.selectionStart=e,u.current.selectionEnd=e,u.current.focus()}},0)}else if("command"===h.type&&"description"in e){if(e.action)e.action(),n?.(e),r((t.slice(0,h.startIndex)+t.slice(h.endIndex)).trim());else if(e.prompt){let n=t.slice(0,h.startIndex),s=t.slice(h.endIndex);r(n+e.prompt+s),setTimeout(()=>{if(u.current){let t=h.startIndex+e.prompt.length;u.current.selectionStart=t,u.current.selectionEnd=t,u.current.focus()}},0)}else n?.(e),r((t.slice(0,h.startIndex)+t.slice(h.endIndex)).trim());setTimeout(()=>{u.current?.focus()},0)}p(null)}},[h,t,r,n]),M=(0,b.useCallback)(e=>{if(o?.(e),!e.defaultPrevented){if(_)switch(e.key){case"ArrowDown":e.preventDefault(),f(e=>(e+1)%A.length);return;case"ArrowUp":e.preventDefault(),f(e=>(e-1+A.length)%A.length);return;case"Tab":case"Enter":A.length>0&&(e.preventDefault(),R(A[m]));return;case"Escape":e.preventDefault(),p(null);return}if("Enter"===e.key){if(y||e.nativeEvent.isComposing||e.shiftKey)return;e.preventDefault();let t=e.currentTarget,r=t.form||t.closest("form");if(r){let e=r.querySelector('button[type="submit"]');if(e?.disabled)return;e?e.click():r.requestSubmit()}}if("Backspace"===e.key&&""===t&&j.files.length>0){e.preventDefault();let t=j.files.at(-1);t&&j.remove(t.id)}}},[_,A,m,R,o,y,t,j]),I=(0,b.useCallback)(e=>{let t=e.clipboardData?.items;if(!t)return;let r=[];for(let e of t)if("file"===e.kind){let t=e.getAsFile();t&&r.push(t)}r.length>0&&(e.preventDefault(),j.add(r))},[j]),L=(0,b.useCallback)(()=>{let e=u.current;e&&E(t,e.selectionStart??0)},[t,E]),D=(0,b.useCallback)(()=>{u.current&&d.current&&(d.current.scrollTop=u.current.scrollTop)},[]);return(0,v.jsxs)("div",{className:"relative w-full",children:[(0,v.jsxs)(ym,{open:_,onOpenChange:()=>p(null),children:[(0,v.jsx)(yg,{style:{position:"absolute",left:g.left,top:g.top,width:0,height:0}}),(0,v.jsx)(yf,{align:"start",side:"top",className:"w-64 p-0",onOpenAutoFocus:e=>e.preventDefault(),children:(0,v.jsx)(mk,{children:(0,v.jsxs)(mj,{children:[S&&h?.type==="file"&&(0,v.jsx)("div",{className:"p-2 text-sm text-muted-foreground text-center",children:"Loading..."}),!S&&0===A.length&&(0,v.jsx)(mN,{children:h?.type==="file"?"No files found":"No commands found"}),h?.type==="file"&&N.length>0&&(0,v.jsx)(mS,{heading:"Files & Folders",children:N.map((e,t)=>(0,v.jsxs)(mC,{onSelect:()=>R(e),className:(0,k.cn)("cursor-pointer",t===m&&"bg-accent"),children:["folder"===e.type?(0,v.jsx)(xS,{className:"mr-2 size-4 text-blue-500"}):(0,v.jsx)(xc,{className:"mr-2 size-4 text-muted-foreground"}),(0,v.jsx)("span",{className:"truncate",children:e.path})]},e.path))}),h?.type==="command"&&C.length>0&&(0,v.jsx)(mS,{heading:"Commands",children:C.map((e,t)=>(0,v.jsxs)(mC,{onSelect:()=>R(e),className:(0,k.cn)("cursor-pointer",t===m&&"bg-accent"),children:[e.icon||(0,v.jsx)(yx,{className:"mr-2 size-4"}),(0,v.jsxs)("div",{className:"flex flex-col ml-2",children:[(0,v.jsxs)("span",{className:"font-medium",children:["/",e.name]}),(0,v.jsx)("span",{className:"text-xs text-muted-foreground",children:e.description})]})]},e.id))})]})})})]}),i&&(0,v.jsx)("div",{ref:d,"aria-hidden":"true",className:"absolute inset-0 pointer-events-none overflow-hidden whitespace-pre-wrap break-words px-3 py-3 text-sm",style:{color:"transparent"},children:(()=>{let e,r=[],n=RegExp(yb.source,"g"),s=0;for(;null!==(e=n.exec(t));)e.index>s&&r.push((0,v.jsx)("span",{children:t.slice(s,e.index)},`text-${s}`)),r.push((0,v.jsx)("mark",{className:"bg-primary/20 text-transparent rounded-sm",children:e[0]},`mention-${e.index}`)),s=e.index+e[0].length;return s<t.length&&r.push((0,v.jsx)("span",{children:t.slice(s)},`text-${s}`)),r.push((0,v.jsx)("span",{children:"\n"},"trailing")),r})()}),(0,v.jsx)("textarea",{ref:u,name:"message","data-slot":"input-group-control",value:t,onChange:P,onKeyDown:M,onClick:L,onScroll:D,onPaste:I,onCompositionStart:()=>w(!0),onCompositionEnd:()=>w(!1),disabled:l,className:(0,k.cn)("flex-1 w-full resize-none rounded-none border-0 py-3 px-3 text-sm shadow-none","placeholder:text-muted-foreground focus-visible:ring-0 focus-visible:outline-none","disabled:cursor-not-allowed disabled:opacity-50","bg-transparent dark:bg-transparent",a),...c})]})}function yN(){let{toggleSidebar:e,isMobile:t}=(0,xh.useSidebar)();return t?(0,v.jsxs)(A.Button,{size:"icon",variant:"ghost",onClick:e,className:"size-7 shrink-0",children:[(0,v.jsx)(xl.PanelLeft,{className:"size-4"}),(0,v.jsx)("span",{className:"sr-only",children:"Toggle sidebar"})]}):null}function yS(){let e=gP();return 0===e.files.length?null:(0,v.jsx)(gH,{variant:"inline",children:e.files.map(t=>(0,v.jsxs)(gK,{data:t,onRemove:()=>e.remove(t.id),children:[(0,v.jsx)(gX,{}),(0,v.jsx)(gY,{}),(0,v.jsx)(gJ,{})]},t.id))})}function yC({input:e,isRunning:t,onStop:r}){let n=gP(),s=e.trim()||n.files.length>0;return(0,v.jsx)(gO,{disabled:!t&&!s,status:t?"streaming":"ready",onStop:r,className:"bg-primary hover:bg-primary/90 transition-colors"})}function yA({session:e,isEmbed:t=!1}){let{toggleSidebar:r}=(0,xh.useSidebar)(),[n,s]=(0,b.useState)([]),[i,a]=(0,b.useState)(""),[o,l]=(0,b.useState)(""),[c,u]=(0,b.useState)(!1),[d,h]=(0,b.useState)(!1),[p,m]=(0,b.useState)([]),[f,g]=(0,b.useState)([]),[x,y]=(0,b.useState)(!1),[j,N]=(0,b.useState)(null),[S,T]=(0,b.useState)(""),[E,P]=(0,b.useState)(""),[R,M]=(0,b.useState)(!1),[I,L]=(0,b.useState)([]),[D,O]=(0,b.useState)([]),[z,F]=(0,b.useState)(null),[B,W]=(0,b.useState)([]),[q,H]=(0,b.useState)(!1),K=(0,b.useRef)(""),X=(0,b.useRef)(""),Y=(0,b.useRef)([]),[J,Z]=(0,b.useState)(!1),Q=(0,b.useRef)(null),ee=(0,b.useRef)(null),et=(0,b.useRef)(!1),er=(0,b.useRef)(!1),en=(0,b.useRef)(new Map),[es,ei]=(0,b.useState)(e.model),[ea,eo]=(0,b.useState)(e.name||""),[el,ec]=(0,b.useState)(!1),[eu,ed]=(0,b.useState)(null),[eh,ep]=(0,b.useState)(e.config||{}),[em,ef]=(0,b.useState)(!1),eg=(0,b.useRef)(null),[ex,ey]=(0,b.useState)(null),[ev,eb]=(0,b.useState)(!1),[ew,ek]=(0,b.useState)(!1);(0,b.useEffect)(()=>{(0,g9.getConfig)().then(ed)},[]),(0,b.useEffect)(()=>{let e=localStorage.getItem("sparkecoder-dismissed-version");(0,g1.checkVersion)().then(t=>{t.updateAvailable&&t.latestVersion!==e&&ey(t)}).catch(e=>{console.error("Failed to check version:",e)})},[]),(0,b.useEffect)(()=>{ei(e.model),eo(e.name||""),ep(e.config||{})},[e.id,e.model,e.name,e.config]),(0,b.useEffect)(()=>{el&&eg.current&&(eg.current.focus(),eg.current.select())},[el]);let ej=async t=>{ei(t);try{await (0,g1.updateSession)(e.id,{model:t}),(0,g7.mutateSessions)()}catch(t){console.error("Failed to update model:",t),ei(e.model)}},eN=async()=>{ec(!1);let t=ea.trim()||"Session";if(t!==e.name)try{await (0,g1.updateSession)(e.id,{name:t}),(0,g7.mutateSessions)()}catch(t){console.error("Failed to update name:",t),eo(e.name||"")}},eS=async()=>{if(ex?.updateCommand&&!c){ek(!0);try{let e=`Run this update command:
7
+ </iframe>`},"putIntoIFrame"),au=(0,nW.__name)((e,t,r,n,s)=>{let i=e.append("div");i.attr("id",r),n&&i.attr("style",n);let a=i.append("svg").attr("id",t).attr("width","100%").attr("xmlns","http://www.w3.org/2000/svg");return s&&a.attr("xmlns:xlink",s),a.append("g"),e},"appendDivSvgG");function ad(e,t){return e.append("iframe").attr("id",t).attr("style","width: 100%; height: 100%;").attr("sandbox","")}(0,nW.__name)(ad,"sandboxedIframe");var ah=(0,nW.__name)((e,t,r,n)=>{e.getElementById(t)?.remove(),e.getElementById(r)?.remove(),e.getElementById(n)?.remove()},"removeExistingElements"),ap=(0,nW.__name)(async function(e,t,r){let n,s;iJ();let i=an(t);t=i.code;let a=(0,nG.getConfig)();nW.log.debug(a),t.length>(a?.maxTextSize??5e4)&&(t="graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa");let o="#"+e,l="i"+e,c="#"+l,u="d"+e,d="#"+u,h=(0,nW.__name)(()=>{let e=m?c:d,t=(0,nH.select)(e).node();t&&"remove"in t&&t.remove()},"removeTempElements"),p=(0,nH.select)("body"),m="sandbox"===a.securityLevel,f="loose"===a.securityLevel,g=a.fontFamily;if(void 0!==r){if(r&&(r.innerHTML=""),m){let e=ad((0,nH.select)(r),l);(p=(0,nH.select)(e.nodes()[0].contentDocument.body)).node().style.margin=0}else p=(0,nH.select)(r);au(p,e,u,`font-family: ${g}`,"http://www.w3.org/1999/xlink")}else{if(ah(document,e,u,l),m){let e=ad((0,nH.select)("body"),l);(p=(0,nH.select)(e.nodes()[0].contentDocument.body)).node().style.margin=0}else p=(0,nH.select)("body");au(p,e,u)}try{n=await i1.fromText(t,{title:i.title})}catch(e){if(a.suppressErrorRendering)throw h(),e;n=await i1.fromText("error"),s=e}let x=p.select(d).node(),y=n.type,v=x.firstChild,b=v.firstChild,w=ao(a,y,n.renderer.getClasses?.(t,n),o),k=document.createElement("style");k.innerHTML=w,v.insertBefore(k,b);try{await n.renderer.draw(t,e,nz.package_default.version,n)}catch(r){throw a.suppressErrorRendering?h():io.draw(t,e,nz.package_default.version),r}ag(y,p.select(`${d} svg`),n.db.getAccTitle?.(),n.db.getAccDescription?.()),p.select(`[id="${e}"]`).selectAll("foreignobject > *").attr("xmlns","http://www.w3.org/1999/xhtml");let j=p.select(d).node().innerHTML;if(nW.log.debug("config.arrowMarkerAbsolute",a.arrowMarkerAbsolute),j=al(j,m,(0,nG.evaluate)(a.arrowMarkerAbsolute)),m?j=ac(j,p.select(d+" svg").node()):f||(j=sc.default.sanitize(j,{ADD_TAGS:at,ADD_ATTR:ar,HTML_INTEGRATION_POINTS:{foreignobject:!0}})),i5(),s)throw s;return h(),{diagramType:y,svg:j,bindFunctions:n.db.bindFunctions}},"render");function am(e={}){let t=(0,nG.assignWithDepth_default)({},e);t?.fontFamily&&!t.themeVariables?.fontFamily&&(t.themeVariables||(t.themeVariables={}),t.themeVariables.fontFamily=t.fontFamily),(0,nG.saveConfigFromInitialize)(t),t?.theme&&t.theme in nG.themes_default?t.themeVariables=nG.themes_default[t.theme].getThemeVariables(t.themeVariables):t&&(t.themeVariables=nG.themes_default.default.getThemeVariables(t.themeVariables));let r="object"==typeof t?(0,nG.setSiteConfig)(t):(0,nG.getSiteConfig)();(0,nW.setLogLevel)(r.logLevel),iJ()}(0,nW.__name)(am,"initialize");var af=(0,nW.__name)((e,t={})=>{let{code:r}=i7(e);return i1.fromText(r,t)},"getDiagramFromText");function ag(e,t,r,n){iQ(t,e),i0(t,r,n,t.attr("id"))}(0,nW.__name)(ag,"addA11yInfo");var ax=Object.freeze({render:ap,parse:as,getDiagramFromText:af,initialize:am,getConfig:nG.getConfig,setConfig:nG.setConfig,getSiteConfig:nG.getSiteConfig,updateSiteConfig:nG.updateSiteConfig,reset:(0,nW.__name)(()=>{(0,nG.reset)()},"reset"),globalReset:(0,nW.__name)(()=>{(0,nG.reset)(nG.defaultConfig)},"globalReset"),defaultConfig:nG.defaultConfig});(0,nW.setLogLevel)((0,nG.getConfig)().logLevel),(0,nG.reset)((0,nG.getConfig)());var ay=(0,nW.__name)((e,t,r)=>{nW.log.warn(e),(0,nU.isDetailedError)(e)?(r&&r(e.str,e.hash),t.push({...e,message:e.str,error:e})):(r&&r(e),e instanceof Error&&t.push({str:e.message,message:e.message,hash:e.name,error:e}))},"handleError"),av=(0,nW.__name)(async function(e={querySelector:".mermaid"}){try{await ab(e)}catch(t){if((0,nU.isDetailedError)(t)&&nW.log.error(t.str),aR.parseError&&aR.parseError(t),!e.suppressErrors)throw nW.log.error("Use the suppressErrors option to suppress these errors"),t}},"run"),ab=(0,nW.__name)(async function({postRenderCallback:e,querySelector:t,nodes:r}={querySelector:".mermaid"}){let n,s,i=ax.getConfig();if(nW.log.debug(`${!e?"No ":""}Callback function found`),r)n=r;else if(t)n=document.querySelectorAll(t);else throw Error("Nodes and querySelector are both undefined");nW.log.debug(`Found ${n.length} diagrams`),i?.startOnLoad!==void 0&&(nW.log.debug("Start On Load: "+i?.startOnLoad),ax.updateSiteConfig({startOnLoad:i?.startOnLoad}));let a=new nU.utils_default.InitIDGenerator(i.deterministicIds,i.deterministicIDSeed),o=[];for(let t of Array.from(n)){if(nW.log.info("Rendering diagram: "+t.id),t.getAttribute("data-processed"))continue;t.setAttribute("data-processed","true");let r=`mermaid-${a.next()}`;s=t.innerHTML,s=(0,nq.dedent)(nU.utils_default.entityDecode(s)).trim().replace(/<br\s*\/?>/gi,"<br/>");let n=nU.utils_default.detectInit(s);n&&nW.log.debug("Detected early reinit: ",n);try{let{svg:n,bindFunctions:i}=await aE(r,s,t);t.innerHTML=n,e&&await e(r),i&&i(t)}catch(e){ay(e,o,aR.parseError)}}if(o.length>0)throw o[0]},"runThrowsErrors"),aw=(0,nW.__name)(function(e){ax.initialize(e)},"initialize"),ak=(0,nW.__name)(async function(e,t,r){nW.log.warn("mermaid.init is deprecated. Please use run instead."),e&&aw(e);let n={postRenderCallback:r,querySelector:".mermaid"};"string"==typeof t?n.querySelector=t:t&&(t instanceof HTMLElement?n.nodes=[t]:n.nodes=t),await av(n)},"init"),aj=(0,nW.__name)(async(e,{lazyLoad:t=!0}={})=>{iJ(),(0,nG.registerLazyLoadedDiagrams)(...e),!1===t&&await iZ()},"registerExternalDiagrams"),aN=(0,nW.__name)(function(){if(aR.startOnLoad){let{startOnLoad:e}=ax.getConfig();e&&aR.run().catch(e=>nW.log.error("Mermaid failed to initialize",e))}},"contentLoaded");"u">typeof document&&window.addEventListener("load",aN,!1);var aS=(0,nW.__name)(function(e){aR.parseError=e},"setParseErrorHandler"),aC=[],aA=!1,a_=(0,nW.__name)(async()=>{if(!aA){for(aA=!0;aC.length>0;){let e=aC.shift();if(e)try{await e()}catch(e){nW.log.error("Error executing queue",e)}}aA=!1}},"executeQueue"),aT=(0,nW.__name)(async(e,t)=>new Promise((r,n)=>{let s=(0,nW.__name)(()=>new Promise((s,i)=>{ax.parse(e,t).then(e=>{s(e),r(e)},e=>{nW.log.error("Error parsing",e),aR.parseError?.(e),i(e),n(e)})}),"performCall");aC.push(s),a_().catch(n)}),"parse"),aE=(0,nW.__name)((e,t,r)=>new Promise((n,s)=>{let i=(0,nW.__name)(()=>new Promise((i,a)=>{ax.render(e,t,r).then(e=>{i(e),n(e)},e=>{nW.log.error("Error parsing",e),aR.parseError?.(e),a(e),s(e)})}),"performCall");aC.push(i),a_().catch(s)}),"render"),aP=(0,nW.__name)(()=>Object.keys(nG.detectors).map(e=>({id:e})),"getRegisteredDiagramsMetadata"),aR={startOnLoad:!0,mermaidAPI:ax,parse:aT,render:aE,init:ak,run:av,registerExternalDiagrams:aj,registerLayoutLoaders:n$.registerLayoutLoaders,initialize:aw,parseError:void 0,contentLoaded:aN,setParseErrorHandler:aS,detectType:nG.detectType,registerIconPacks:nV.registerIconPacks,getRegisteredDiagramsMetadata:aP},aM={startOnLoad:!1,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:!0},aI=function(e={}){let t=!1,r={...aM,...e.config},n={initialize(n){r={...aM,...e.config,...n},aR.initialize(r),t=!0},render:async(e,n)=>(t||(aR.initialize(r),t=!0),await aR.render(e,n))};return{name:"mermaid",type:"diagram",language:"mermaid",getMermaid:e=>(e&&n.initialize(e),n)}}();(0,T.default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);let aL=(0,T.default)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);var aD=e.i(77589),aD=aD,aO=e.i(349416),az=e.i(773340),aF=e.i(991106),aB=aF;let a$=({className:e,from:t,...r})=>(0,v.jsx)("div",{className:(0,k.cn)("group flex w-full max-w-[95%] flex-col gap-2 transition-all duration-200","user"===t?"is-user ml-auto justify-end":"is-assistant",e),...r}),aV=({children:e,className:t,...r})=>(0,v.jsx)("div",{className:(0,k.cn)("is-user:dark flex w-fit min-w-0 max-w-full flex-col gap-2 overflow-hidden text-sm","group-[.is-user]:ml-auto group-[.is-user]:rounded-2xl group-[.is-user]:rounded-br-md group-[.is-user]:bg-primary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-primary-foreground group-[.is-user]:shadow-sm","group-[.is-assistant]:text-foreground",t),...r,children:e}),aU=({className:e,children:t,...r})=>(0,v.jsx)("div",{className:(0,k.cn)("flex items-center gap-1",e),...r,children:t}),aG=({tooltip:e,children:t,label:r,variant:n="ghost",size:s="icon-sm",...i})=>{let a=(0,v.jsxs)(A.Button,{size:s,type:"button",variant:n,...i,children:[t,(0,v.jsx)("span",{className:"sr-only",children:r||e})]});return e?(0,v.jsx)(_.TooltipProvider,{children:(0,v.jsxs)(_.Tooltip,{children:[(0,v.jsx)(_.TooltipTrigger,{asChild:!0,children:a}),(0,v.jsx)(_.TooltipContent,{children:(0,v.jsx)("p",{children:e})})]})}):a},aW=({url:e,isOpen:t,onClose:r,onConfirm:n})=>{let[s,i]=(0,b.useState)(!1);if((0,b.useEffect)(()=>{i(!0)},[]),!s||!t)return null;let a=(()=>{try{return new URL(e).hostname}catch{return e}})();return(0,az.createPortal)((0,v.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:r,onKeyDown:e=>"Escape"===e.key&&r(),children:(0,v.jsxs)("div",{className:"relative mx-4 max-w-md rounded-lg bg-background p-6 shadow-lg",onClick:e=>e.stopPropagation(),children:[(0,v.jsxs)("button",{className:"absolute right-3 top-3 rounded-sm p-1 text-muted-foreground hover:bg-muted hover:text-foreground",onClick:r,type:"button",children:[(0,v.jsx)(aO.XIcon,{className:"h-4 w-4"}),(0,v.jsx)("span",{className:"sr-only",children:"Close"})]}),(0,v.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 text-lg font-semibold",children:[(0,v.jsx)(aD.default,{className:"h-5 w-5"}),(0,v.jsx)("span",{children:"External Link"})]}),(0,v.jsx)("p",{className:"text-sm text-muted-foreground",children:"You are about to visit an external website:"}),(0,v.jsx)("p",{className:"break-all rounded bg-muted px-3 py-2 text-sm font-mono",children:a}),(0,v.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,v.jsx)(A.Button,{variant:"outline",onClick:r,children:"Cancel"}),(0,v.jsx)(A.Button,{onClick:n,children:"Continue"})]})]})]})}),document.body)},aq=(0,b.memo)(({className:e,linkSafety:t,...r})=>(0,v.jsx)(aB.j,{className:(0,k.cn)("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),plugins:{code:nn,mermaid:aI,math:nO,cjk:eg},linkSafety:{enabled:t?.enabled??!0,onLinkCheck:t?.onLinkCheck,renderModal:t?.renderModal??aW},...r}),(e,t)=>e.children===t.children);aq.displayName="MessageResponse";var aH=e.i(241416),aK=e.i(465488),aX=e.i(995945),aY=e.i(309945),aJ=Symbol("radix.slottable");function aZ(e){return b.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===aJ}var aQ=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{var r,n;let s,i,a,o=(n=r=`Primitive.${t}`,(s=b.forwardRef((e,t)=>{let{children:r,...n}=e;if(b.isValidElement(r)){var s;let e,i,a=(s=r,(i=(e=Object.getOwnPropertyDescriptor(s.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.ref:(i=(e=Object.getOwnPropertyDescriptor(s,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.props.ref:s.props.ref||s.ref),o=function(e,t){let r={...t};for(let n in t){let s=e[n],i=t[n];/^on[A-Z]/.test(n)?s&&i?r[n]=(...e)=>{let t=i(...e);return s(...e),t}:s&&(r[n]=s):"style"===n?r[n]={...s,...i}:"className"===n&&(r[n]=[s,i].filter(Boolean).join(" "))}return{...e,...r}}(n,r.props);return r.type!==b.Fragment&&(o.ref=t?(0,aY.composeRefs)(t,a):a),b.cloneElement(r,o)}return b.Children.count(r)>1?b.Children.only(null):null})).displayName=`${n}.SlotClone`,i=s,(a=b.forwardRef((e,t)=>{let{children:r,...n}=e,s=b.Children.toArray(r),a=s.find(aZ);if(a){let e=a.props.children,r=s.map(t=>t!==a?t:b.Children.count(e)>1?b.Children.only(null):b.isValidElement(e)?e.props.children:null);return(0,v.jsx)(i,{...n,ref:t,children:b.isValidElement(e)?b.cloneElement(e,void 0,r):null})}return(0,v.jsx)(i,{...n,ref:t,children:r})})).displayName=`${r}.Slot`,a),l=b.forwardRef((e,r)=>{let{asChild:n,...s}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,v.jsx)(n?o:t,{...s,ref:r})});return l.displayName=`Primitive.${t}`,{...e,[t]:l}},{}),a0=e.i(395509),a1=e.i(610559),a2="Collapsible",[a5,a3]=function(e,t=[]){let r=[],n=()=>{let t=r.map(e=>b.createContext(e));return function(r){let n=r?.[e]||t;return b.useMemo(()=>({[`__scope${e}`]:{...r,[e]:n}}),[r,n])}};return n.scopeName=e,[function(t,n){let s=b.createContext(n),i=r.length;r=[...r,n];let a=t=>{let{scope:r,children:n,...a}=t,o=r?.[e]?.[i]||s,l=b.useMemo(()=>a,Object.values(a));return(0,v.jsx)(o.Provider,{value:l,children:n})};return a.displayName=t+"Provider",[a,function(r,a){let o=a?.[e]?.[i]||s,l=b.useContext(o);if(l)return l;if(void 0!==n)return n;throw Error(`\`${r}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let r=()=>{let r=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let n=r.reduce((t,{useScope:r,scopeName:n})=>{let s=r(e)[`__scope${n}`];return{...t,...s}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:n}),[n])}};return r.scopeName=t.scopeName,r}(n,...t)]}(a2),[a6,a4]=a5(a2),a8=b.forwardRef((e,t)=>{let{__scopeCollapsible:r,open:n,defaultOpen:s,disabled:i,onOpenChange:a,...o}=e,[l,c]=(0,aK.useControllableState)({prop:n,defaultProp:s??!1,onChange:a,caller:a2});return(0,v.jsx)(a6,{scope:r,disabled:i,contentId:(0,a1.useId)(),open:l,onOpenToggle:b.useCallback(()=>c(e=>!e),[c]),children:(0,v.jsx)(aQ.div,{"data-state":on(l),"data-disabled":i?"":void 0,...o,ref:t})})});a8.displayName=a2;var a9="CollapsibleTrigger",a7=b.forwardRef((e,t)=>{let{__scopeCollapsible:r,...n}=e,s=a4(a9,r);return(0,v.jsx)(aQ.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":on(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...n,ref:t,onClick:(0,aH.composeEventHandlers)(e.onClick,s.onOpenToggle)})});a7.displayName=a9;var oe="CollapsibleContent",ot=b.forwardRef((e,t)=>{let{forceMount:r,...n}=e,s=a4(oe,e.__scopeCollapsible);return(0,v.jsx)(a0.Presence,{present:r||s.open,children:({present:e})=>(0,v.jsx)(or,{...n,ref:t,present:e})})});ot.displayName=oe;var or=b.forwardRef((e,t)=>{let{__scopeCollapsible:r,present:n,children:s,...i}=e,a=a4(oe,r),[o,l]=b.useState(n),c=b.useRef(null),u=(0,aY.useComposedRefs)(t,c),d=b.useRef(0),h=d.current,p=b.useRef(0),m=p.current,f=a.open||o,g=b.useRef(f),x=b.useRef(void 0);return b.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,aX.useLayoutEffect)(()=>{let e=c.current;if(e){x.current=x.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=x.current.transitionDuration,e.style.animationName=x.current.animationName),l(n)}},[a.open,n]),(0,v.jsx)(aQ.div,{"data-state":on(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!f,...i,ref:u,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:f&&s})});function on(e){return e?"open":"closed"}function os({...e}){return(0,v.jsx)(a8,{"data-slot":"collapsible",...e})}function oi({...e}){return(0,v.jsx)(a7,{"data-slot":"collapsible-trigger",...e})}function oa({...e}){return(0,v.jsx)(ot,{"data-slot":"collapsible-content",...e})}let oo=(0,T.default)("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);var ol=e.i(100536);let oc=(0,T.default)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var ou=e.i(191729),ou=ou;let od=(0,T.default)("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]),oh=(0,T.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var op=e.i(553880);e.i(196582);let om=(0,T.default)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),of=({token:e})=>{let t,r,n;return(0,v.jsx)("span",{className:"dark:!bg-[var(--shiki-dark-bg)] dark:!text-[var(--shiki-dark)]",style:{color:e.color,backgroundColor:e.bgColor,...e.htmlStyle,fontStyle:(t=e.fontStyle)&&1&t?"italic":void 0,fontWeight:(r=e.fontStyle)&&2&r?"bold":void 0,textDecoration:(n=e.fontStyle)&&4&n?"underline":void 0},children:e.content})},og=({keyedLine:e,showLineNumbers:t})=>(0,v.jsx)("span",{className:t?ok:"block",children:0===e.tokens.length?"\n":e.tokens.map(({token:e,key:t})=>(0,v.jsx)(of,{token:e},t))}),ox=(0,b.createContext)({code:""}),oy=new Map,ov=new Map,ob=new Map;function ow(e,t,r){let n,s,i=(n=e.slice(0,100),s=e.length>100?e.slice(-100):"",`${t}:${e.length}:${n}:${s}`),a=ov.get(i);return a||(r&&(ob.has(i)||ob.set(i,new Set),ob.get(i)?.add(r)),(e=>{let t=oy.get(e);if(t)return t;let r=r9({themes:["github-light","github-dark"],langs:[e]});return oy.set(e,r),r})(t).then(r=>{let n=r.getLoadedLanguages().includes(t)?t:"text",s=r.codeToTokens(e,{lang:n,themes:{light:"github-light",dark:"github-dark"}}),a={tokens:s.tokens,fg:s.fg??"",bg:s.bg??""};ov.set(i,a);let o=ob.get(i);if(o){for(let e of o)e(a);ob.delete(i)}}).catch(e=>{console.error("Failed to highlight code:",e),ob.delete(i)}),null)}let ok=(0,k.cn)("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-8","before:mr-4","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),oj=(0,b.memo)(({tokenized:e,showLineNumbers:t,className:r})=>{let n=(0,b.useMemo)(()=>({backgroundColor:e.bg,color:e.fg}),[e.bg,e.fg]),s=(0,b.useMemo)(()=>e.tokens.map((e,t)=>({key:`line-${t}`,tokens:e.map((e,r)=>({token:e,key:`line-${t}-${r}`}))})),[e.tokens]);return(0,v.jsx)("pre",{className:(0,k.cn)("dark:!bg-[var(--shiki-dark-bg)] dark:!text-[var(--shiki-dark)] m-0 p-4 text-sm",r),style:n,children:(0,v.jsx)("code",{className:(0,k.cn)("font-mono text-sm",t&&"[counter-increment:line_0] [counter-reset:line]"),children:s.map(e=>(0,v.jsx)(og,{keyedLine:e,showLineNumbers:t},e.key))})})},(e,t)=>e.tokenized===t.tokenized&&e.showLineNumbers===t.showLineNumbers&&e.className===t.className),oN=({className:e,language:t,style:r,...n})=>(0,v.jsx)("div",{className:(0,k.cn)("group relative w-full overflow-hidden rounded-md border bg-background text-foreground",e),"data-language":t,style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...r},...n}),oS=({children:e,className:t,...r})=>(0,v.jsx)("div",{className:(0,k.cn)("flex items-center justify-between bg-muted/80 px-3 py-2 text-muted-foreground text-xs",t),...r,children:e}),oC=({children:e,className:t,...r})=>(0,v.jsx)("div",{className:(0,k.cn)("flex items-center gap-2",t),...r,children:e}),oA=({children:e,className:t,...r})=>(0,v.jsx)("span",{className:(0,k.cn)("font-mono",t),...r,children:e}),o_=({code:e,language:t,showLineNumbers:r=!1})=>{let n=(0,b.useMemo)(()=>({tokens:e.split("\n").map(e=>""===e?[]:[{content:e,color:"inherit"}]),fg:"inherit",bg:"transparent"}),[e]),[s,i]=(0,b.useState)(()=>ow(e,t)??n);return(0,b.useEffect)(()=>{i(ow(e,t)??n),ow(e,t,i)},[e,t,n]),(0,v.jsx)("div",{className:"relative overflow-auto",children:(0,v.jsx)(oj,{showLineNumbers:r,tokenized:s})})},oT=({code:e,language:t,showLineNumbers:r=!1,className:n,children:s,...i})=>(0,v.jsx)(ox.Provider,{value:{code:e},children:(0,v.jsxs)(oN,{className:n,language:t,...i,children:[s,(0,v.jsx)(o_,{code:e,language:t,showLineNumbers:r})]})}),oE=({className:e,...t})=>(0,v.jsx)(os,{className:(0,k.cn)("group not-prose mb-4 w-full max-w-full overflow-hidden rounded-md border",e),...t}),oP=({className:e,title:t,type:r,state:n,toolName:s,...i})=>{let a,o="dynamic-tool"===r?s:r.split("-").slice(1).join("-");return(0,v.jsxs)(oi,{className:(0,k.cn)("flex w-full items-center justify-between gap-4 p-3",e),...i,children:[(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)(od,{className:"size-4 text-muted-foreground"}),(0,v.jsx)("span",{className:"font-medium text-sm",children:t??o}),(a={"input-streaming":(0,v.jsx)(oc,{className:"size-4"}),"input-available":(0,v.jsx)(ou.default,{className:"size-4 animate-pulse"}),"approval-requested":(0,v.jsx)(ou.default,{className:"size-4 text-yellow-600"}),"approval-responded":(0,v.jsx)(oo,{className:"size-4 text-blue-600"}),"output-available":(0,v.jsx)(oo,{className:"size-4 text-green-600"}),"output-error":(0,v.jsx)(oh,{className:"size-4 text-red-600"}),"output-denied":(0,v.jsx)(oh,{className:"size-4 text-orange-600"})},(0,v.jsxs)(C,{className:"gap-1.5 rounded-full text-xs",variant:"secondary",children:[a[n],{"input-streaming":"Pending","input-available":"Running","approval-requested":"Awaiting Approval","approval-responded":"Responded","output-available":"Completed","output-error":"Error","output-denied":"Denied"}[n]]}))]}),(0,v.jsx)(ol.ChevronDownIcon,{className:"size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})},oR=({className:e,...t})=>(0,v.jsx)(oa,{className:(0,k.cn)("data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...t}),oM=({className:e,input:t,...r})=>(0,v.jsxs)("div",{className:(0,k.cn)("space-y-2 overflow-hidden p-4 max-w-full",e),...r,children:[(0,v.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:"Parameters"}),(0,v.jsx)("div",{className:"rounded-md bg-muted/50 overflow-x-auto max-w-full",children:(0,v.jsx)(oT,{code:JSON.stringify(t,null,2),language:"json"})})]}),oI=({className:e,output:t,errorText:r,...n})=>{if(!(t||r))return null;let s=(0,v.jsx)("div",{children:t});return"object"!=typeof t||(0,b.isValidElement)(t)?"string"==typeof t&&(s=(0,v.jsx)(oT,{code:t,language:"json"})):s=(0,v.jsx)(oT,{code:JSON.stringify(t,null,2),language:"json"}),(0,v.jsxs)("div",{className:(0,k.cn)("space-y-2 p-4 max-w-full overflow-hidden",e),...n,children:[(0,v.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:r?"Error":"Result"}),(0,v.jsxs)("div",{className:(0,k.cn)("overflow-x-auto rounded-md text-xs max-w-full [&_table]:w-full",r?"bg-destructive/10 text-destructive":"bg-muted/50 text-foreground"),children:[r&&(0,v.jsx)("div",{children:r}),s]})]})},oL=({className:e,...t})=>(0,v.jsx)("div",{className:(0,k.cn)("flex flex-col overflow-hidden rounded-lg border bg-background shadow-sm",e),...t}),oD=({className:e,...t})=>(0,v.jsx)("div",{className:(0,k.cn)("flex items-center justify-between border-b bg-muted/50 px-4 py-3",e),...t}),oO=({className:e,...t})=>(0,v.jsx)("p",{className:(0,k.cn)("font-medium text-foreground text-sm",e),...t}),oz=({className:e,...t})=>(0,v.jsx)("p",{className:(0,k.cn)("text-muted-foreground text-sm",e),...t}),oF=({className:e,...t})=>(0,v.jsx)("div",{className:(0,k.cn)("flex items-center gap-1",e),...t}),oB=({tooltip:e,label:t,icon:r,children:n,className:s,size:i="sm",variant:a="ghost",...o})=>{let l=(0,v.jsxs)(A.Button,{className:(0,k.cn)("size-8 p-0 text-muted-foreground hover:text-foreground",s),size:i,type:"button",variant:a,...o,children:[r?(0,v.jsx)(r,{className:"size-4"}):n,(0,v.jsx)("span",{className:"sr-only",children:t||e})]});return e?(0,v.jsx)(_.TooltipProvider,{children:(0,v.jsxs)(_.Tooltip,{children:[(0,v.jsx)(_.TooltipTrigger,{asChild:!0,children:l}),(0,v.jsx)(_.TooltipContent,{children:(0,v.jsx)("p",{children:e})})]})}):l},o$=({className:e,...t})=>(0,v.jsx)("div",{className:(0,k.cn)("flex-1 overflow-auto p-4",e),...t}),oV=(0,N.cva)("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function oU({className:e,variant:t,...r}){return(0,v.jsx)("div",{"data-slot":"alert",role:"alert",className:(0,k.cn)(oV({variant:t}),e),...r})}let oG=(0,b.createContext)(null),oW=()=>{let e=(0,b.useContext)(oG);if(!e)throw Error("Confirmation components must be used within Confirmation");return e},oq=({className:e,approval:t,state:r,...n})=>t&&"input-streaming"!==r&&"input-available"!==r?(0,v.jsx)(oG.Provider,{value:{approval:t,state:r},children:(0,v.jsx)(oU,{className:(0,k.cn)("flex flex-col gap-2",e),...n})}):null,oH=({children:e})=>{let{state:t}=oW();return"approval-requested"!==t?null:e},oK=({className:e,...t})=>{let{state:r}=oW();return"approval-requested"!==r?null:(0,v.jsx)("div",{className:(0,k.cn)("flex items-center justify-end gap-2 self-end",e),...t})},oX=e=>(0,v.jsx)(A.Button,{className:"h-8 px-3 text-sm",type:"button",...e}),oY=({size:e=16})=>(0,v.jsxs)("svg",{height:e,strokeLinejoin:"round",style:{color:"currentcolor"},viewBox:"0 0 16 16",width:e,children:[(0,v.jsx)("title",{children:"Loader"}),(0,v.jsxs)("g",{clipPath:"url(#clip0_2393_1490)",children:[(0,v.jsx)("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),(0,v.jsx)("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),(0,v.jsx)("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),(0,v.jsx)("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),(0,v.jsx)("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),(0,v.jsx)("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),(0,v.jsx)("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),(0,v.jsx)("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),(0,v.jsx)("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),(0,v.jsx)("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),(0,v.jsx)("defs",{children:(0,v.jsx)("clipPath",{id:"clip0_2393_1490",children:(0,v.jsx)("rect",{fill:"white",height:"16",width:"16"})})})]}),oJ=({className:e,size:t=16,...r})=>(0,v.jsx)("div",{className:(0,k.cn)("inline-flex animate-spin items-center justify-center",e),...r,children:(0,v.jsx)(oY,{size:t})}),oZ=(0,T.default)("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]);var aB=aF;let oQ=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],o0=new Set(oQ),o1=(e,t,r)=>r>t?t:r<e?e:r,o2={test:e=>"number"==typeof e,parse:parseFloat,transform:e=>e},o5={...o2,transform:e=>o1(0,1,e)},o3={...o2,default:1},o6=e=>Math.round(1e5*e)/1e5,o4=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu,o8=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,o9=(e,t)=>r=>!!("string"==typeof r&&o8.test(r)&&r.startsWith(e)||t&&null!=r&&Object.prototype.hasOwnProperty.call(r,t)),o7=(e,t,r)=>n=>{if("string"!=typeof n)return n;let[s,i,a,o]=n.match(o4);return{[e]:parseFloat(s),[t]:parseFloat(i),[r]:parseFloat(a),alpha:void 0!==o?parseFloat(o):1}},le={...o2,transform:e=>Math.round(o1(0,255,e))},lt={test:o9("rgb","red"),parse:o7("red","green","blue"),transform:({red:e,green:t,blue:r,alpha:n=1})=>"rgba("+le.transform(e)+", "+le.transform(t)+", "+le.transform(r)+", "+o6(o5.transform(n))+")"},lr={test:o9("#"),parse:function(e){let t="",r="",n="",s="";return e.length>5?(t=e.substring(1,3),r=e.substring(3,5),n=e.substring(5,7),s=e.substring(7,9)):(t=e.substring(1,2),r=e.substring(2,3),n=e.substring(3,4),s=e.substring(4,5),t+=t,r+=r,n+=n,s+=s),{red:parseInt(t,16),green:parseInt(r,16),blue:parseInt(n,16),alpha:s?parseInt(s,16)/255:1}},transform:lt.transform},ln=e=>({test:t=>"string"==typeof t&&t.endsWith(e)&&1===t.split(" ").length,parse:parseFloat,transform:t=>`${t}${e}`}),ls=ln("deg"),li=ln("%"),la=ln("px"),lo=ln("vh"),ll=ln("vw"),lc={...li,parse:e=>li.parse(e)/100,transform:e=>li.transform(100*e)},lu={test:o9("hsl","hue"),parse:o7("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:r,alpha:n=1})=>"hsla("+Math.round(e)+", "+li.transform(o6(t))+", "+li.transform(o6(r))+", "+o6(o5.transform(n))+")"},ld={test:e=>lt.test(e)||lr.test(e)||lu.test(e),parse:e=>lt.test(e)?lt.parse(e):lu.test(e)?lu.parse(e):lr.parse(e),transform:e=>"string"==typeof e?e:e.hasOwnProperty("red")?lt.transform(e):lu.transform(e),getAnimatableNone:e=>{let t=ld.parse(e);return t.alpha=0,ld.transform(t)}},lh=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu,lp="number",lm="color",lf=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function lg(e){let t=e.toString(),r=[],n={color:[],number:[],var:[]},s=[],i=0,a=t.replace(lf,e=>(ld.test(e)?(n.color.push(i),s.push(lm),r.push(ld.parse(e))):e.startsWith("var(")?(n.var.push(i),s.push("var"),r.push(e)):(n.number.push(i),s.push(lp),r.push(parseFloat(e))),++i,"${}")).split("${}");return{values:r,split:a,indexes:n,types:s}}function lx(e){return lg(e).values}function ly(e){let{split:t,types:r}=lg(e),n=t.length;return e=>{let s="";for(let i=0;i<n;i++)if(s+=t[i],void 0!==e[i]){let t=r[i];t===lp?s+=o6(e[i]):t===lm?s+=ld.transform(e[i]):s+=e[i]}return s}}let lv=e=>"number"==typeof e?0:ld.test(e)?ld.getAnimatableNone(e):e,lb={test:function(e){return isNaN(e)&&"string"==typeof e&&(e.match(o4)?.length||0)+(e.match(lh)?.length||0)>0},parse:lx,createTransformer:ly,getAnimatableNone:function(e){let t=lx(e);return ly(e)(t.map(lv))}},lw=new Set(["brightness","contrast","saturate","opacity"]);function lk(e){let[t,r]=e.slice(0,-1).split("(");if("drop-shadow"===t)return e;let[n]=r.match(o4)||[];if(!n)return e;let s=r.replace(n,""),i=+!!lw.has(t);return n!==r&&(i*=100),t+"("+i+s+")"}let lj=/\b([a-z-]*)\(.*?\)/gu,lN={...lb,getAnimatableNone:e=>{let t=e.match(lj);return t?t.map(lk).join(" "):e}},lS={...o2,transform:Math.round},lC={borderWidth:la,borderTopWidth:la,borderRightWidth:la,borderBottomWidth:la,borderLeftWidth:la,borderRadius:la,borderTopLeftRadius:la,borderTopRightRadius:la,borderBottomRightRadius:la,borderBottomLeftRadius:la,width:la,maxWidth:la,height:la,maxHeight:la,top:la,right:la,bottom:la,left:la,inset:la,insetBlock:la,insetBlockStart:la,insetBlockEnd:la,insetInline:la,insetInlineStart:la,insetInlineEnd:la,padding:la,paddingTop:la,paddingRight:la,paddingBottom:la,paddingLeft:la,paddingBlock:la,paddingBlockStart:la,paddingBlockEnd:la,paddingInline:la,paddingInlineStart:la,paddingInlineEnd:la,margin:la,marginTop:la,marginRight:la,marginBottom:la,marginLeft:la,marginBlock:la,marginBlockStart:la,marginBlockEnd:la,marginInline:la,marginInlineStart:la,marginInlineEnd:la,fontSize:la,backgroundPositionX:la,backgroundPositionY:la,rotate:ls,rotateX:ls,rotateY:ls,rotateZ:ls,scale:o3,scaleX:o3,scaleY:o3,scaleZ:o3,skew:ls,skewX:ls,skewY:ls,distance:la,translateX:la,translateY:la,translateZ:la,x:la,y:la,z:la,perspective:la,transformPerspective:la,opacity:o5,originX:lc,originY:lc,originZ:la,zIndex:lS,fillOpacity:o5,strokeOpacity:o5,numOctaves:lS},lA={...lC,color:ld,backgroundColor:ld,outlineColor:ld,fill:ld,stroke:ld,borderColor:ld,borderTopColor:ld,borderRightColor:ld,borderBottomColor:ld,borderLeftColor:ld,filter:lN,WebkitFilter:lN},l_=e=>lA[e],lT=()=>({translate:0,scale:1,origin:0,originPoint:0}),lE=()=>({x:lT(),y:lT()}),lP=()=>({min:0,max:0}),lR=()=>({x:lP(),y:lP()}),lM=e=>!!(e&&e.getVelocity),lI=new Set(["width","height","top","left","right","bottom",...oQ]),lL=e=>t=>t.test(e),lD=[o2,la,li,ls,ll,lo,{test:e=>"auto"===e,parse:e=>e}],lO=e=>lD.find(lL(e)),lz=()=>{},lF=()=>{};ek.default;let lB=e=>t=>"string"==typeof t&&t.startsWith(e),l$=lB("--"),lV=lB("var(--"),lU=e=>!!lV(e)&&lG.test(e.split("/*")[0].trim()),lG=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function lW(e){return"string"==typeof e&&e.split("/*")[0].includes("var(--")}let lq=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u,lH=e=>180*e/Math.PI,lK=e=>lY(lH(Math.atan2(e[1],e[0]))),lX={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:lK,rotateZ:lK,skewX:e=>lH(Math.atan(e[1])),skewY:e=>lH(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},lY=e=>((e%=360)<0&&(e+=360),e),lJ=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),lZ=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),lQ={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:lJ,scaleY:lZ,scale:e=>(lJ(e)+lZ(e))/2,rotateX:e=>lY(lH(Math.atan2(e[6],e[5]))),rotateY:e=>lY(lH(Math.atan2(-e[2],e[0]))),rotateZ:lK,rotate:lK,skewX:e=>lH(Math.atan(e[4])),skewY:e=>lH(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function l0(e){return+!!e.includes("scale")}function l1(e,t){let r,n;if(!e||"none"===e)return l0(t);let s=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);if(s)r=lQ,n=s;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=lX,n=t}if(!n)return l0(t);let i=r[t],a=n[1].split(",").map(l2);return"function"==typeof i?i(a):a[i]}function l2(e){return parseFloat(e.trim())}let l5=e=>e===o2||e===la,l3=new Set(["x","y","z"]),l6=oQ.filter(e=>!l3.has(e)),l4={width:({x:e},{paddingLeft:t="0",paddingRight:r="0"})=>e.max-e.min-parseFloat(t)-parseFloat(r),height:({y:e},{paddingTop:t="0",paddingBottom:r="0"})=>e.max-e.min-parseFloat(t)-parseFloat(r),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>l1(t,"x"),y:(e,{transform:t})=>l1(t,"y")};l4.translateX=l4.x,l4.translateY=l4.y;let l8=e=>e,l9={},l7=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function ce(e,t){let r=!1,n=!0,s={delta:0,timestamp:0,isProcessing:!1},i=()=>r=!0,a=l7.reduce((e,r)=>(e[r]=function(e,t){let r=new Set,n=new Set,s=!1,i=!1,a=new WeakSet,o={delta:0,timestamp:0,isProcessing:!1},l=0;function c(t){a.has(t)&&(u.schedule(t),e()),l++,t(o)}let u={schedule:(e,t=!1,i=!1)=>{let o=i&&s?r:n;return t&&a.add(e),o.has(e)||o.add(e),e},cancel:e=>{n.delete(e),a.delete(e)},process:e=>{if(o=e,s){i=!0;return}s=!0,[r,n]=[n,r],r.forEach(c),t,l=0,r.clear(),s=!1,i&&(i=!1,u.process(e))}};return u}(i,t?r:void 0),e),{}),{setup:o,read:l,resolveKeyframes:c,preUpdate:u,update:d,preRender:h,render:p,postRender:m}=a,f=()=>{let i=l9.useManualTiming?s.timestamp:performance.now();r=!1,l9.useManualTiming||(s.delta=n?1e3/60:Math.max(Math.min(i-s.timestamp,40),1)),s.timestamp=i,s.isProcessing=!0,o.process(s),l.process(s),c.process(s),u.process(s),d.process(s),h.process(s),p.process(s),m.process(s),s.isProcessing=!1,r&&t&&(n=!1,e(f))};return{schedule:l7.reduce((t,i)=>{let o=a[i];return t[i]=(t,i=!1,a=!1)=>(!r&&(r=!0,n=!0,s.isProcessing||e(f)),o.schedule(t,i,a)),t},{}),cancel:e=>{for(let t=0;t<l7.length;t++)a[l7[t]].cancel(e)},state:s,steps:a}}let{schedule:ct,cancel:cr,state:cn,steps:cs}=ce("u">typeof requestAnimationFrame?requestAnimationFrame:l8,!0),ci=new Set,ca=!1,co=!1,cl=!1;function cc(){if(co){let e=Array.from(ci).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),r=new Map;t.forEach(e=>{let t,n=(t=[],l6.forEach(r=>{let n=e.getValue(r);void 0!==n&&(t.push([r,n.get()]),n.set(+!!r.startsWith("scale")))}),t);n.length&&(r.set(e,n),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=r.get(e);t&&t.forEach(([t,r])=>{e.getValue(t)?.set(r)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{void 0!==e.suspendedScrollY&&window.scrollTo(0,e.suspendedScrollY)})}co=!1,ca=!1,ci.forEach(e=>e.complete(cl)),ci.clear()}function cu(){ci.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(co=!0)})}class cd{constructor(e,t,r,n,s,i=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=r,this.motionValue=n,this.element=s,this.isAsync=i}scheduleResolve(){this.state="scheduled",this.isAsync?(ci.add(this),ca||(ca=!0,ct.read(cu),ct.resolveKeyframes(cc))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:r,motionValue:n}=this;if(null===e[0]){let s=n?.get(),i=e[e.length-1];if(void 0!==s)e[0]=s;else if(r&&t){let n=r.readValue(t,i);null!=n&&(e[0]=n)}void 0===e[0]&&(e[0]=i),n&&void 0===s&&n.set(e[0])}for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),ci.delete(this)}cancel(){"scheduled"===this.state&&(ci.delete(this),this.state="pending")}resume(){"pending"===this.state&&this.scheduleResolve()}}function ch(e,t){let r=l_(e);return r!==lN&&(r=lb),r.getAnimatableNone?r.getAnimatableNone(t):void 0}let cp=new Set(["auto","none","0"]);class cm extends cd{constructor(e,t,r,n,s){super(e,t,r,n,s,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:r}=this;if(!t||!t.current)return;super.readKeyframes();for(let r=0;r<e.length;r++){let n=e[r];if("string"==typeof n&&lU(n=n.trim())){let s=function e(t,r,n=1){lF(n<=4,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");let[s,i]=function(e){let t=lq.exec(e);if(!t)return[,];let[,r,n,s]=t;return[`--${r??n}`,s]}(t);if(!s)return;let a=window.getComputedStyle(r).getPropertyValue(s);if(a){let e=a.trim();return/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e)?parseFloat(e):e}return lU(i)?e(i,r,n+1):i}(n,t.current);void 0!==s&&(e[r]=s),r===e.length-1&&(this.finalKeyframe=n)}}if(this.resolveNoneKeyframes(),!lI.has(r)||2!==e.length)return;let[n,s]=e,i=lO(n),a=lO(s);if(lW(n)!==lW(s)&&l4[r]){this.needsMeasurement=!0;return}if(i!==a)if(l5(i)&&l5(a))for(let t=0;t<e.length;t++){let r=e[t];"string"==typeof r&&(e[t]=parseFloat(r))}else l4[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,r=[];for(let t=0;t<e.length;t++)(null===e[t]||function(e){if("number"==typeof e)return 0===e;if(null===e)return!0;return"none"===e||"0"===e||/^0[^.\s]+$/u.test(e)}(e[t]))&&r.push(t);r.length&&function(e,t,r){let n,s=0;for(;s<e.length&&!n;){let t=e[s];"string"==typeof t&&!cp.has(t)&&lg(t).values.length&&(n=e[s]),s++}if(n&&r)for(let s of t)e[s]=ch(r,n)}(e,r,t)}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:r}=this;if(!e||!e.current)return;"height"===r&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=l4[r](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;let n=t[t.length-1];void 0!==n&&e.getValue(r,n).jump(n,!1)}measureEndState(){let{element:e,name:t,unresolvedKeyframes:r}=this;if(!e||!e.current)return;let n=e.getValue(t);n&&n.jump(this.measuredOrigin,!1);let s=r.length-1,i=r[s];r[s]=l4[t](e.measureViewportBox(),window.getComputedStyle(e.current)),null!==i&&void 0===this.finalKeyframe&&(this.finalKeyframe=i),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,r])=>{e.getValue(t).set(r)}),this.resolveNoneKeyframes()}}function cf(e,t){-1===e.indexOf(t)&&e.push(t)}function cg(e,t){let r=e.indexOf(t);r>-1&&e.splice(r,1)}class cx{constructor(){this.subscriptions=[]}add(e){return cf(this.subscriptions,e),()=>cg(this.subscriptions,e)}notify(e,t,r){let n=this.subscriptions.length;if(n)if(1===n)this.subscriptions[0](e,t,r);else for(let s=0;s<n;s++){let n=this.subscriptions[s];n&&n(e,t,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}let{schedule:cy}=ce(queueMicrotask,!1);function cv(){n=void 0}let cb={now:()=>(void 0===n&&cb.set(cn.isProcessing||l9.useManualTiming?cn.timestamp:performance.now()),n),set:e=>{n=e,queueMicrotask(cv)}};class cw{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=cb.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=cb.now(),null===this.canTrackVelocity&&void 0!==e&&(this.canTrackVelocity=!isNaN(parseFloat(this.current)))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,t){this.events[e]||(this.events[e]=new cx);let r=this.events[e].add(t);return"change"===e?()=>{r(),ct.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,r){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-r}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return d&&d.push(this),this.current}getPrevious(){return this.prev}getVelocity(){var e;let t=cb.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||t-this.updatedAt>30)return 0;let r=Math.min(this.updatedAt-this.prevUpdatedAt,30);return e=parseFloat(this.current)-parseFloat(this.prevFrameValue),r?1e3/r*e:0}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function ck(e,t){return new cw(e,t)}let cj=[...lD,ld,lb],cN={current:null},cS={current:!1},cC="u">typeof window,cA=new WeakMap;function c_(e){return null!==e&&"object"==typeof e&&"function"==typeof e.start}function cT(e){return"string"==typeof e||Array.isArray(e)}let cE=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],cP=["initial",...cE];function cR(e){return c_(e.animate)||cP.some(t=>cT(e[t]))}function cM(e){return!!(cR(e)||e.variants)}function cI(e){let t=[{},{}];return e?.values.forEach((e,r)=>{t[0][r]=e.get(),t[1][r]=e.getVelocity()}),t}function cL(e,t,r,n){if("function"==typeof t){let[s,i]=cI(n);t=t(void 0!==r?r:e.custom,s,i)}if("string"==typeof t&&(t=e.variants&&e.variants[t]),"function"==typeof t){let[s,i]=cI(n);t=t(void 0!==r?r:e.custom,s,i)}return t}let cD=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"],cO={};class cz{scrapeMotionValuesFromProps(e,t,r){return{}}constructor({parent:e,props:t,presenceContext:r,reducedMotionConfig:n,blockInitialAnimation:s,visualState:i},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=cd,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=cb.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,ct.render(this.render,!1,!0))};const{latestValues:o,renderState:l}=i;this.latestValues=o,this.baseTarget={...o},this.initialValues=t.initial?{...o}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=r,this.depth=e?e.depth+1:0,this.reducedMotionConfig=n,this.options=a,this.blockInitialAnimation=!!s,this.isControllingVariants=cR(t),this.isVariantNode=cM(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:c,...u}=this.scrapeMotionValuesFromProps(t,{},this);for(const e in u){const t=u[e];void 0!==o[e]&&lM(t)&&t.set(o[e])}}mount(e){this.current=e,cA.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),"never"===this.reducedMotionConfig?this.shouldReduceMotion=!1:"always"===this.reducedMotionConfig?this.shouldReduceMotion=!0:(cS.current||function(){if(cS.current=!0,cC)if(window.matchMedia){let e=window.matchMedia("(prefers-reduced-motion)"),t=()=>cN.current=e.matches;e.addEventListener("change",t),t()}else cN.current=!1}(),this.shouldReduceMotion=cN.current),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){for(let e in this.projection&&this.projection.unmount(),cr(this.notifyUpdate),cr(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this),this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){let r;this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();let n=o0.has(e);n&&this.onBindTransform&&this.onBindTransform();let s=t.on("change",t=>{this.latestValues[e]=t,this.props.onUpdate&&ct.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});"u">typeof window&&window.MotionCheckAppearSync&&(r=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{s(),r&&r(),t.owner&&t.stop()})}sortNodePosition(e){return this.current&&this.sortInstanceNodePosition&&this.type===e.type?this.sortInstanceNodePosition(this.current,e.current):0}updateFeatures(){let e="animation";for(e in cO){let t=cO[e];if(!t)continue;let{isEnabled:r,Feature:n}=t;if(!this.features[e]&&n&&r(this.props)&&(this.features[e]=new n(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):lR()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<cD.length;t++){let r=cD[t];this.propEventSubscriptions[r]&&(this.propEventSubscriptions[r](),delete this.propEventSubscriptions[r]);let n=e["on"+r];n&&(this.propEventSubscriptions[r]=this.on(r,n))}this.prevMotionValues=function(e,t,r){for(let n in t){let s=t[n],i=r[n];if(lM(s))e.addValue(n,s);else if(lM(i))e.addValue(n,ck(s,{owner:e}));else if(i!==s)if(e.hasValue(n)){let t=e.getValue(n);!0===t.liveStyle?t.jump(s):t.hasAnimated||t.set(s)}else{let t=e.getStaticValue(n);e.addValue(n,ck(void 0!==t?t:s,{owner:e}))}}for(let n in r)void 0===t[n]&&e.removeValue(n);return t}(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){let t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){let r=this.values.get(e);t!==r&&(r&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let r=this.values.get(e);return void 0===r&&void 0!==t&&(r=ck(null===t?void 0:t,{owner:this}),this.addValue(e,r)),r}readValue(e,t){let r=void 0===this.latestValues[e]&&this.current?this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options):this.latestValues[e];if(null!=r){let n,s;if("string"==typeof r&&(n=r,/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(n)||(s=r,/^0[^.\s]+$/u.test(s))))r=parseFloat(r);else{let n;n=r,!cj.find(lL(n))&&lb.test(t)&&(r=ch(e,t))}this.setBaseTarget(e,lM(r)?r.get():r)}return lM(r)?r.get():r}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){let t,{initial:r}=this.props;if("string"==typeof r||"object"==typeof r){let n=cL(this.props,r,this.presenceContext?.custom);n&&(t=n[e])}if(r&&void 0!==t)return t;let n=this.getBaseTargetFromProps(this.props,e);return void 0===n||lM(n)?void 0!==this.initialValues[e]&&void 0===t?void 0:this.baseTarget[e]:n}on(e,t){return this.events[e]||(this.events[e]=new cx),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){cy.render(this.render)}}class cF extends cz{constructor(){super(...arguments),this.KeyframeResolver=cm}sortInstanceNodePosition(e,t){return 2&e.compareDocumentPosition(t)?1:-1}getBaseTargetFromProps(e,t){let r=e.style;return r?r[t]:void 0}removeValueFromRenderState(e,{vars:t,style:r}){delete t[e],delete r[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;lM(e)&&(this.childSubscription=e.on("change",e=>{this.current&&(this.current.textContent=`${e}`)}))}}function cB(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}let c$=(e,t)=>t&&"number"==typeof e?t.transform(e):e,cV={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},cU=oQ.length;function cG(e,t,r){let{style:n,vars:s,transformOrigin:i}=e,a=!1,o=!1;for(let e in t){let r=t[e];if(o0.has(e)){a=!0;continue}if(l$(e)){s[e]=r;continue}{let t=c$(r,lC[e]);e.startsWith("origin")?(o=!0,i[e]=t):n[e]=t}}if(!t.transform&&(a||r?n.transform=function(e,t,r){let n="",s=!0;for(let i=0;i<cU;i++){let a=oQ[i],o=e[a];if(void 0===o)continue;let l=!0;if("number"==typeof o)l=o===+!!a.startsWith("scale");else{let e=parseFloat(o);l=a.startsWith("scale")?1===e:0===e}if(!l||r){let e=c$(o,lC[a]);if(!l){s=!1;let t=cV[a]||a;n+=`${t}(${e}) `}r&&(t[a]=e)}}return n=n.trim(),r?n=r(t,s?"":n):s&&(n="none"),n}(t,e.transform,r):n.transform&&(n.transform="none")),o){let{originX:e="50%",originY:t="50%",originZ:r=0}=i;n.transformOrigin=`${e} ${t} ${r}`}}let cW={offset:"stroke-dashoffset",array:"stroke-dasharray"},cq={offset:"strokeDashoffset",array:"strokeDasharray"},cH=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function cK(e,{attrX:t,attrY:r,attrScale:n,pathLength:s,pathSpacing:i=1,pathOffset:a=0,...o},l,c,u){if(cG(e,o,c),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:h}=e;for(let e of(d.transform&&(h.transform=d.transform,delete d.transform),(h.transform||d.transformOrigin)&&(h.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),h.transform&&(h.transformBox=u?.transformBox??"fill-box",delete d.transformBox),cH))void 0!==d[e]&&(h[e]=d[e],delete d[e]);void 0!==t&&(d.x=t),void 0!==r&&(d.y=r),void 0!==n&&(d.scale=n),void 0!==s&&function(e,t,r=1,n=0,s=!0){e.pathLength=1;let i=s?cW:cq;e[i.offset]=`${-n}`,e[i.array]=`${t} ${r}`}(d,s,i,a,!1)}let cX=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),cY=e=>"string"==typeof e&&"svg"===e.toLowerCase();function cJ(e,{style:t,vars:r},n,s){let i,a=e.style;for(i in t)a[i]=t[i];for(i in s?.applyProjectionStyles(a,n),r)a.setProperty(i,r[i])}function cZ(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}let cQ={correct:(e,t)=>{if(!t.target)return e;if("string"==typeof e)if(!la.test(e))return e;else e=parseFloat(e);let r=cZ(e,t.target.x),n=cZ(e,t.target.y);return`${r}% ${n}%`}},c0=(e,t,r)=>e+(t-e)*r,c1={borderRadius:{...cQ,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:cQ,borderTopRightRadius:cQ,borderBottomLeftRadius:cQ,borderBottomRightRadius:cQ,boxShadow:{correct:(e,{treeScale:t,projectionDelta:r})=>{let n=lb.parse(e);if(n.length>5)return e;let s=lb.createTransformer(e),i=+("number"!=typeof n[0]),a=r.x.scale*t.x,o=r.y.scale*t.y;n[0+i]/=a,n[1+i]/=o;let l=c0(a,o,.5);return"number"==typeof n[2+i]&&(n[2+i]/=l),"number"==typeof n[3+i]&&(n[3+i]/=l),s(n)}}};function c2(e,{layout:t,layoutId:r}){return o0.has(e)||e.startsWith("origin")||(t||void 0!==r)&&(!!c1[e]||"opacity"===e)}function c5(e,t,r){let n=e.style,s=t?.style,i={};if(!n)return i;for(let t in n)(lM(n[t])||s&&lM(s[t])||c2(t,e)||r?.getValue(t)?.liveStyle!==void 0)&&(i[t]=n[t]);return i}function c3(e,t,r){let n=c5(e,t,r);for(let r in e)(lM(e[r])||lM(t[r]))&&(n[-1!==oQ.indexOf(r)?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r]=e[r]);return n}class c6 extends cF{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=lR}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(o0.has(t)){let e=l_(t);return e&&e.default||0}return t=cX.has(t)?t:cB(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,r){return c3(e,t,r)}build(e,t,r){cK(e,t,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(e,t,r,n){for(let r in cJ(e,t,void 0,n),t.attrs)e.setAttribute(cX.has(r)?r:cB(r),t.attrs[r])}mount(e){this.isSVGTag=cY(e.tagName),super.mount(e)}}function c4({top:e,left:t,right:r,bottom:n}){return{x:{min:t,max:r},y:{min:e,max:n}}}function c8(e){return void 0===e||1===e}function c9({scale:e,scaleX:t,scaleY:r}){return!c8(e)||!c8(t)||!c8(r)}function c7(e){return c9(e)||ue(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function ue(e){var t,r;return(t=e.x)&&"0%"!==t||(r=e.y)&&"0%"!==r}function ut(e,t,r,n,s){return void 0!==s&&(e=n+s*(e-n)),n+r*(e-n)+t}function ur(e,t=0,r=1,n,s){e.min=ut(e.min,t,r,n,s),e.max=ut(e.max,t,r,n,s)}function un(e,{x:t,y:r}){ur(e.x,t.translate,t.scale,t.originPoint),ur(e.y,r.translate,r.scale,r.originPoint)}function us(e,t){e.min=e.min+t,e.max=e.max+t}function ui(e,t,r,n,s=.5){let i=c0(e.min,e.max,s);ur(e,t,r,i,n)}function ua(e,t){ui(e.x,t.x,t.scaleX,t.scale,t.originX),ui(e.y,t.y,t.scaleY,t.scale,t.originY)}function uo(e,t){return c4(function(e,t){if(!t)return e;let r=t({x:e.left,y:e.top}),n=t({x:e.right,y:e.bottom});return{top:r.y,left:r.x,bottom:n.y,right:n.x}}(e.getBoundingClientRect(),t))}class ul extends cF{constructor(){super(...arguments),this.type="html",this.renderInstance=cJ}readValueFromInstance(e,t){if(o0.has(t))return this.projection?.isProjecting?l0(t):((e,t)=>{let{transform:r="none"}=getComputedStyle(e);return l1(r,t)})(e,t);{let r=window.getComputedStyle(e),n=(l$(t)?r.getPropertyValue(t):r[t])||0;return"string"==typeof n?n.trim():n}}measureInstanceViewportBox(e,{transformPagePoint:t}){return uo(e,t)}build(e,t,r){cG(e,t,r.transformTemplate)}scrapeMotionValuesFromProps(e,t,r){return c5(e,t,r)}}let uc=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function uu(e){if("string"!=typeof e||e.includes("-"));else if(uc.indexOf(e)>-1||/[A-Z]/u.test(e))return!0;return!1}let ud=(0,b.createContext)({}),uh=(0,b.createContext)({strict:!1}),up=(0,b.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"}),um=(0,b.createContext)({});function uf(e){return Array.isArray(e)?e.join(" "):e}let ug=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function ux(e,t,r){for(let n in t)lM(t[n])||c2(n,r)||(e[n]=t[n])}let uy=()=>({...ug(),attrs:{}}),uv=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function ub(e){return e.startsWith("while")||e.startsWith("drag")&&"draggable"!==e||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||uv.has(e)}let uw=e=>!ub(e);try{g=(()=>{let e=Error("Cannot find module '@emotion/is-prop-valid'");throw e.code="MODULE_NOT_FOUND",e})().default,"function"==typeof g&&(uw=e=>e.startsWith("on")?!ub(e):g(e))}catch{}function uk(e){return lM(e)?e.get():e}let uj=(0,b.createContext)(null),uN=e=>(t,r)=>{let n,s=(0,b.useContext)(um),i=(0,b.useContext)(uj),a=()=>(function({scrapeMotionValuesFromProps:e,createRenderState:t},r,n,s){return{latestValues:function(e,t,r,n){let s={},i=n(e,{});for(let e in i)s[e]=uk(i[e]);let{initial:a,animate:o}=e,l=cR(e),c=cM(e);t&&c&&!l&&!1!==e.inherit&&(void 0===a&&(a=t.initial),void 0===o&&(o=t.animate));let u=!!r&&!1===r.initial,d=(u=u||!1===a)?o:a;if(d&&"boolean"!=typeof d&&!c_(d)){let t=Array.isArray(d)?d:[d];for(let r=0;r<t.length;r++){let n=cL(e,t[r]);if(n){let{transitionEnd:e,transition:t,...r}=n;for(let e in r){let t=r[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}null!==t&&(s[e]=t)}for(let t in e)s[t]=e[t]}}}return s}(r,n,s,e),renderState:t()}})(e,t,s,i);return r?a():(null===(n=(0,b.useRef)(null)).current&&(n.current=a()),n.current)},uS=uN({scrapeMotionValuesFromProps:c5,createRenderState:ug}),uC=uN({scrapeMotionValuesFromProps:c3,createRenderState:uy}),uA="u">typeof window,u_={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},uT=!1;function uE(){return!function(){if(uT)return;let e={};for(let t in u_)e[t]={isEnabled:e=>u_[t].some(t=>!!e[t])};cO=e,uT=!0}(),cO}let uP=Symbol.for("motionComponentSymbol"),uR="data-"+cB("framerAppearId"),uM=(0,b.createContext)({});function uI(e){return e&&"object"==typeof e&&Object.prototype.hasOwnProperty.call(e,"current")}let uL=uA?b.useLayoutEffect:b.useEffect;function uD(e,{forwardMotionProps:t=!1,type:r}={},n,s){n&&function(e){let t=uE();for(let r in e)t[r]={...t[r],...e[r]};cO=t}(n);let i=r?"svg"===r:uu(e),a=i?uC:uS;function o(r,n){var o;let l,c,u,d={...(0,b.useContext)(up),...r,layoutId:function({layoutId:e}){let t=(0,b.useContext)(ud).id;return t&&void 0!==e?t+"-"+e:e}(r)},{isStatic:h}=d,p=function(e){let{initial:t,animate:r}=function(e,t){if(cR(e)){let{initial:t,animate:r}=e;return{initial:!1===t||cT(t)?t:void 0,animate:cT(r)?r:void 0}}return!1!==e.inherit?t:{}}(e,(0,b.useContext)(um));return(0,b.useMemo)(()=>({initial:t,animate:r}),[uf(t),uf(r)])}(r),m=a(r,h);if(!h&&uA){(0,b.useContext)(uh).strict;let t=function(e){let{drag:t,layout:r}=uE();if(!t&&!r)return{};let n={...t,...r};return{MeasureLayout:t?.isEnabled(e)||r?.isEnabled(e)?n.MeasureLayout:void 0,ProjectionNode:n.ProjectionNode}}(d);l=t.MeasureLayout,p.visualElement=function(e,t,r,n,s,i){let{visualElement:a}=(0,b.useContext)(um),o=(0,b.useContext)(uh),l=(0,b.useContext)(uj),c=(0,b.useContext)(up).reducedMotion,u=(0,b.useRef)(null),d=(0,b.useRef)(!1);n=n||o.renderer,!u.current&&n&&(u.current=n(e,{visualState:t,parent:a,props:r,presenceContext:l,blockInitialAnimation:!!l&&!1===l.initial,reducedMotionConfig:c,isSVG:i}),d.current&&u.current&&(u.current.manuallyAnimateOnMount=!0));let h=u.current,p=(0,b.useContext)(uM);h&&!h.projection&&s&&("html"===h.type||"svg"===h.type)&&function(e,t,r,n){let{layoutId:s,layout:i,drag:a,dragConstraints:o,layoutScroll:l,layoutRoot:c,layoutCrossfade:u}=t;e.projection=new r(e.latestValues,t["data-framer-portal-id"]?void 0:function e(t){if(t)return!1!==t.options.allowProjection?t.projection:e(t.parent)}(e.parent)),e.projection.setOptions({layoutId:s,layout:i,alwaysMeasureLayout:!!a||o&&uI(o),visualElement:e,animationType:"string"==typeof i?i:"both",initialPromotionConfig:n,crossfade:u,layoutScroll:l,layoutRoot:c})}(u.current,r,s,p);let m=(0,b.useRef)(!1);(0,b.useInsertionEffect)(()=>{h&&m.current&&h.update(r,l)});let f=r[uR],g=(0,b.useRef)(!!f&&!window.MotionHandoffIsComplete?.(f)&&window.MotionHasOptimisedAnimation?.(f));return uL(()=>{d.current=!0,h&&(m.current=!0,window.MotionIsMounted=!0,h.updateFeatures(),h.scheduleRenderMicrotask(),g.current&&h.animationState&&h.animationState.animateChanges())}),(0,b.useEffect)(()=>{h&&(!g.current&&h.animationState&&h.animationState.animateChanges(),g.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(f)}),g.current=!1),h.enteringChildren=void 0)}),h}(e,m,d,s,t.ProjectionNode,i)}return(0,v.jsxs)(um.Provider,{value:p,children:[l&&p.visualElement?(0,v.jsx)(l,{visualElement:p.visualElement,...d}):null,function(e,t,r,{latestValues:n},s,i=!1,a){let o=(a??uu(e)?function(e,t,r,n){let s=(0,b.useMemo)(()=>{let r=uy();return cK(r,t,cY(n),e.transformTemplate,e.style),{...r.attrs,style:{...r.style}}},[t]);if(e.style){let t={};ux(t,e.style,e),s.style={...t,...s.style}}return s}:function(e,t){let r,n,s={},i=(r=e.style||{},ux(n={},r,e),Object.assign(n,function({transformTemplate:e},t){return(0,b.useMemo)(()=>{let r=ug();return cG(r,t,e),Object.assign({},r.vars,r.style)},[t])}(e,t)),n);return e.drag&&!1!==e.dragListener&&(s.draggable=!1,i.userSelect=i.WebkitUserSelect=i.WebkitTouchCallout="none",i.touchAction=!0===e.drag?"none":`pan-${"x"===e.drag?"y":"x"}`),void 0===e.tabIndex&&(e.onTap||e.onTapStart||e.whileTap)&&(s.tabIndex=0),s.style=i,s})(t,n,s,e),l=function(e,t,r){let n={};for(let s in e)("values"!==s||"object"!=typeof e.values)&&(uw(s)||!0===r&&ub(s)||!t&&!ub(s)||e.draggable&&s.startsWith("onDrag"))&&(n[s]=e[s]);return n}(t,"string"==typeof e,i),c=e!==b.Fragment?{...l,...o,ref:r}:{},{children:u}=t,d=(0,b.useMemo)(()=>lM(u)?u.get():u,[u]);return(0,b.createElement)(e,{...c,children:d})}(e,r,(o=p.visualElement,c=(0,b.useRef)(n),(0,b.useInsertionEffect)(()=>{c.current=n}),u=(0,b.useRef)(null),(0,b.useCallback)(e=>{e&&m.onMount?.(e),o&&(e?o.mount(e):o.unmount());let t=c.current;if("function"==typeof t)if(e){let r=t(e);"function"==typeof r&&(u.current=r)}else u.current?(u.current(),u.current=null):t(e);else t&&(t.current=e)},[o])),m,h,t,i)]})}o.displayName=`motion.${"string"==typeof e?e:`create(${e.displayName??e.name??""})`}`;let l=(0,b.forwardRef)(o);return l[uP]=e,l}class uO{constructor(e){this.isMounted=!1,this.node=e}update(){}}function uz(e,t,r){let n=e.getProps();return cL(n,t,void 0!==r?r:n.custom,e)}function uF(e,t){return e?.[t]??e?.default??e}let uB=e=>Array.isArray(e);function u$(e,t){let r=e.getValue("willChange");if(lM(r)&&r.add)return r.add(t);if(!r&&l9.WillChange){let r=new l9.WillChange("auto");e.addValue("willChange",r),r.add(t)}}let uV=e=>1e3*e,uU=(e,t)=>r=>t(e(r)),uG=(...e)=>e.reduce(uU),uW={layout:0,mainThread:0,waapi:0};function uq(e,t,r){return(r<0&&(r+=1),r>1&&(r-=1),r<1/6)?e+(t-e)*6*r:r<.5?t:r<2/3?e+(t-e)*(2/3-r)*6:e}function uH(e,t){return r=>r>0?t:e}let uK=(e,t,r)=>{let n=e*e,s=r*(t*t-n)+n;return s<0?0:Math.sqrt(s)},uX=[lr,lt,lu];function uY(e){let t=uX.find(t=>t.test(e));if(lz(!!t,`'${e}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!t)return!1;let r=t.parse(e);return t===lu&&(r=function({hue:e,saturation:t,lightness:r,alpha:n}){e/=360,r/=100;let s=0,i=0,a=0;if(t/=100){let n=r<.5?r*(1+t):r+t-r*t,o=2*r-n;s=uq(o,n,e+1/3),i=uq(o,n,e),a=uq(o,n,e-1/3)}else s=i=a=r;return{red:Math.round(255*s),green:Math.round(255*i),blue:Math.round(255*a),alpha:n}}(r)),r}let uJ=(e,t)=>{let r=uY(e),n=uY(t);if(!r||!n)return uH(e,t);let s={...r};return e=>(s.red=uK(r.red,n.red,e),s.green=uK(r.green,n.green,e),s.blue=uK(r.blue,n.blue,e),s.alpha=c0(r.alpha,n.alpha,e),lt.transform(s))},uZ=new Set(["none","hidden"]);function uQ(e,t){return r=>c0(e,t,r)}function u0(e){return"number"==typeof e?uQ:"string"==typeof e?lU(e)?uH:ld.test(e)?uJ:u5:Array.isArray(e)?u1:"object"==typeof e?ld.test(e)?uJ:u2:uH}function u1(e,t){let r=[...e],n=r.length,s=e.map((e,r)=>u0(e)(e,t[r]));return e=>{for(let t=0;t<n;t++)r[t]=s[t](e);return r}}function u2(e,t){let r={...e,...t},n={};for(let s in r)void 0!==e[s]&&void 0!==t[s]&&(n[s]=u0(e[s])(e[s],t[s]));return e=>{for(let t in n)r[t]=n[t](e);return r}}let u5=(e,t)=>{let r=lb.createTransformer(t),n=lg(e),s=lg(t);if(!(n.indexes.var.length===s.indexes.var.length&&n.indexes.color.length===s.indexes.color.length&&n.indexes.number.length>=s.indexes.number.length))return lz(!0,`Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),uH(e,t);if(uZ.has(e)&&!s.values.length||uZ.has(t)&&!n.values.length)return uZ.has(e)?r=>r<=0?e:t:r=>r>=1?t:e;return uG(u1(function(e,t){let r=[],n={color:0,var:0,number:0};for(let s=0;s<t.values.length;s++){let i=t.types[s],a=e.indexes[i][n[i]],o=e.values[a]??0;r[s]=o,n[i]++}return r}(n,s),s.values),r)};function u3(e,t,r){return"number"==typeof e&&"number"==typeof t&&"number"==typeof r?c0(e,t,r):u0(e)(e,t)}let u6=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>ct.update(t,e),stop:()=>cr(t),now:()=>cn.isProcessing?cn.timestamp:cb.now()}},u4=(e,t,r=10)=>{let n="",s=Math.max(Math.round(t/r),2);for(let t=0;t<s;t++)n+=Math.round(1e4*e(t/(s-1)))/1e4+", ";return`linear(${n.substring(0,n.length-2)})`};function u8(e){let t=0,r=e.next(t);for(;!r.done&&t<2e4;)t+=50,r=e.next(t);return t>=2e4?1/0:t}function u9(e,t,r){var n,s;let i=Math.max(t-5,0);return n=r-e(i),(s=t-i)?1e3/s*n:0}let u7=.01,de=2,dt=.005,dr=.5;function dn(e,t){return e*Math.sqrt(1-t*t)}let ds=["duration","bounce"],di=["stiffness","damping","mass"];function da(e,t){return t.some(t=>void 0!==e[t])}function dl(e=.3,t=.3){let r,n="object"!=typeof e?{visualDuration:e,keyframes:[0,1],bounce:t}:e,{restSpeed:s,restDelta:i}=n,a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],l={done:!1,value:a},{stiffness:c,damping:u,mass:d,duration:h,velocity:p,isResolvedFromDuration:m}=function(e){let t={velocity:0,stiffness:100,damping:10,mass:1,isResolvedFromDuration:!1,...e};if(!da(e,di)&&da(e,ds))if(e.visualDuration){let r=2*Math.PI/(1.2*e.visualDuration),n=r*r,s=2*o1(.05,1,1-(e.bounce||0))*Math.sqrt(n);t={...t,mass:1,stiffness:n,damping:s}}else{let r=function({duration:e=800,bounce:t=.3,velocity:r=0,mass:n=1}){let s,i;lz(e<=uV(10),"Spring duration must be 10 seconds or less","spring-duration-limit");let a=1-t;a=o1(.05,1,a),e=o1(.01,10,e/1e3),a<1?(s=t=>{let n=t*a,s=n*e;return .001-(n-r)/dn(t,a)*Math.exp(-s)},i=t=>{let n=t*a*e,i=Math.pow(a,2)*Math.pow(t,2)*e,o=Math.exp(-n),l=dn(Math.pow(t,2),a);return(n*r+r-i)*o*(-s(t)+.001>0?-1:1)/l}):(s=t=>-.001+Math.exp(-t*e)*((t-r)*e+1),i=t=>e*e*(r-t)*Math.exp(-t*e));let o=function(e,t,r){let n=r;for(let r=1;r<12;r++)n-=e(n)/t(n);return n}(s,i,5/e);if(e=uV(e),isNaN(o))return{stiffness:100,damping:10,duration:e};{let t=Math.pow(o,2)*n;return{stiffness:t,damping:2*a*Math.sqrt(n*t),duration:e}}}(e);(t={...t,...r,mass:1}).isResolvedFromDuration=!0}return t}({...n,velocity:-((n.velocity||0)/1e3)}),f=p||0,g=u/(2*Math.sqrt(c*d)),x=o-a,y=Math.sqrt(c/d)/1e3,v=5>Math.abs(x);if(s||(s=v?u7:de),i||(i=v?dt:dr),g<1){let e=dn(y,g);r=t=>o-Math.exp(-g*y*t)*((f+g*y*x)/e*Math.sin(e*t)+x*Math.cos(e*t))}else if(1===g)r=e=>o-Math.exp(-y*e)*(x+(f+y*x)*e);else{let e=y*Math.sqrt(g*g-1);r=t=>{let r=Math.exp(-g*y*t),n=Math.min(e*t,300);return o-r*((f+g*y*x)*Math.sinh(n)+e*x*Math.cosh(n))/e}}let b={calculatedDuration:m&&h||null,next:e=>{let t=r(e);if(m)l.done=e>=h;else{let n=0===e?f:0;g<1&&(n=0===e?uV(f):u9(r,e,t));let a=Math.abs(o-t)<=i;l.done=Math.abs(n)<=s&&a}return l.value=l.done?o:t,l},toString:()=>{let e=Math.min(u8(b),2e4),t=u4(t=>b.next(e*t).value,e,30);return e+"ms "+t},toTransition:()=>{}};return b}function dc({keyframes:e,velocity:t=0,power:r=.8,timeConstant:n=325,bounceDamping:s=10,bounceStiffness:i=500,modifyTarget:a,min:o,max:l,restDelta:c=.5,restSpeed:u}){let d,h,p=e[0],m={done:!1,value:p},f=r*t,g=p+f,x=void 0===a?g:a(g);x!==g&&(f=x-p);let y=e=>-f*Math.exp(-e/n),v=e=>x+y(e),b=e=>{let t=y(e),r=v(e);m.done=Math.abs(t)<=c,m.value=m.done?x:r},w=e=>{let t;if(t=m.value,void 0!==o&&t<o||void 0!==l&&t>l){var r;d=e,h=dl({keyframes:[m.value,(r=m.value,void 0===o?l:void 0===l||Math.abs(o-r)<Math.abs(l-r)?o:l)],velocity:u9(v,e,m.value),damping:s,stiffness:i,restDelta:c,restSpeed:u})}};return w(0),{calculatedDuration:null,next:e=>{let t=!1;return(h||void 0!==d||(t=!0,b(e),w(e)),void 0!==d&&e>=d)?h.next(e-d):(t||b(e),m)}}}dl.applyToOptions=e=>{let t=function(e,t=100,r){let n=r({...e,keyframes:[0,t]}),s=Math.min(u8(n),2e4);return{type:"keyframes",ease:e=>n.next(s*e).value/t,duration:s/1e3}}(e,100,dl);return e.ease=t.ease,e.duration=uV(t.duration),e.type="keyframes",e};let du=(e,t,r)=>(((1-3*r+3*t)*e+(3*r-6*t))*e+3*t)*e;function dd(e,t,r,n){return e===t&&r===n?l8:s=>0===s||1===s?s:du(function(e,t,r,n,s){let i,a,o=0;do(i=du(a=t+(r-t)/2,n,s)-e)>0?r=a:t=a;while(Math.abs(i)>1e-7&&++o<12)return a}(s,0,1,e,r),t,n)}let dh=dd(.42,0,1,1),dp=dd(0,0,.58,1),dm=dd(.42,0,.58,1),df=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,dg=e=>t=>1-e(1-t),dx=dd(.33,1.53,.69,.99),dy=dg(dx),dv=df(dy),db=e=>(e*=2)<1?.5*dy(e):.5*(2-Math.pow(2,-10*(e-1))),dw=e=>1-Math.sin(Math.acos(e)),dk=dg(dw),dj=df(dw),dN=e=>Array.isArray(e)&&"number"==typeof e[0],dS={linear:l8,easeIn:dh,easeInOut:dm,easeOut:dp,circIn:dw,circInOut:dj,circOut:dk,backIn:dy,backInOut:dv,backOut:dx,anticipate:db},dC=e=>{if(dN(e)){lF(4===e.length,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");let[t,r,n,s]=e;return dd(t,r,n,s)}return"string"==typeof e?(lF(void 0!==dS[e],`Invalid easing type '${e}'`,"invalid-easing-type"),dS[e]):e},dA=(e,t,r)=>{let n=t-e;return 0===n?1:(r-e)/n};function d_({duration:e=300,keyframes:t,times:r,ease:n="easeInOut"}){var s;let i,a=Array.isArray(n)&&"number"!=typeof n[0]?n.map(dC):dC(n),o={done:!1,value:t[0]},l=function(e,t,{clamp:r=!0,ease:n,mixer:s}={}){let i=e.length;if(lF(i===t.length,"Both input and output ranges must be the same length","range-length"),1===i)return()=>t[0];if(2===i&&t[0]===t[1])return()=>t[1];let a=e[0]===e[1];e[0]>e[i-1]&&(e=[...e].reverse(),t=[...t].reverse());let o=function(e,t,r){let n=[],s=r||l9.mix||u3,i=e.length-1;for(let r=0;r<i;r++){let i=s(e[r],e[r+1]);t&&(i=uG(Array.isArray(t)?t[r]||l8:t,i)),n.push(i)}return n}(t,n,s),l=o.length,c=r=>{if(a&&r<e[0])return t[0];let n=0;if(l>1)for(;n<e.length-2&&!(r<e[n+1]);n++);let s=dA(e[n],e[n+1],r);return o[n](s)};return r?t=>c(o1(e[0],e[i-1],t)):c}((s=r&&r.length===t.length?r:(!function(e,t){let r=e[e.length-1];for(let n=1;n<=t;n++){let s=dA(0,t,n);e.push(c0(r,1,s))}}(i=[0],t.length-1),i),s.map(t=>t*e)),t,{ease:Array.isArray(a)?a:t.map(()=>a||dm).splice(0,t.length-1)});return{calculatedDuration:e,next:t=>(o.value=l(t),o.done=t>=e,o)}}let dT=e=>null!==e;function dE(e,{repeat:t,repeatType:r="loop"},n,s=1){let i=e.filter(dT),a=s<0||t&&"loop"!==r&&t%2==1?0:i.length-1;return a&&void 0!==n?n:i[a]}let dP={decay:dc,inertia:dc,tween:d_,keyframes:d_,spring:dl};function dR(e){"string"==typeof e.type&&(e.type=dP[e.type])}class dM{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}}let dI=e=>e/100;class dL extends dM{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==cb.now()&&this.tick(cb.now()),this.isStopped=!0,"idle"!==this.state&&(this.teardown(),this.options.onStop?.())},uW.mainThread++,this.options=e,this.initAnimation(),this.play(),!1===e.autoplay&&this.pause()}initAnimation(){let{options:e}=this;dR(e);let{type:t=d_,repeat:r=0,repeatDelay:n=0,repeatType:s,velocity:i=0}=e,{keyframes:a}=e,o=t||d_;o!==d_&&"number"!=typeof a[0]&&(this.mixKeyframes=uG(dI,u3(a[0],a[1])),a=[0,100]);let l=o({...e,keyframes:a});"mirror"===s&&(this.mirroredGenerator=o({...e,keyframes:[...a].reverse(),velocity:-i})),null===l.calculatedDuration&&(l.calculatedDuration=u8(l));let{calculatedDuration:c}=l;this.calculatedDuration=c,this.resolvedDuration=c+n,this.totalDuration=this.resolvedDuration*(r+1)-n,this.generator=l}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;null!==this.holdTime?this.currentTime=this.holdTime:this.currentTime=t}tick(e,t=!1){let{generator:r,totalDuration:n,mixKeyframes:s,mirroredGenerator:i,resolvedDuration:a,calculatedDuration:o}=this;if(null===this.startTime)return r.next(0);let{delay:l=0,keyframes:c,repeat:u,repeatType:d,repeatDelay:h,type:p,onUpdate:m,finalKeyframe:f}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-n/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-l*(this.playbackSpeed>=0?1:-1),x=this.playbackSpeed>=0?g<0:g>n;this.currentTime=Math.max(g,0),"finished"===this.state&&null===this.holdTime&&(this.currentTime=n);let y=this.currentTime,v=r;if(u){let e=Math.min(this.currentTime,n)/a,t=Math.floor(e),r=e%1;!r&&e>=1&&(r=1),1===r&&t--,(t=Math.min(t,u+1))%2&&("reverse"===d?(r=1-r,h&&(r-=h/a)):"mirror"===d&&(v=i)),y=o1(0,1,r)*a}let b=x?{done:!1,value:c[0]}:v.next(y);s&&(b.value=s(b.value));let{done:w}=b;x||null===o||(w=this.playbackSpeed>=0?this.currentTime>=n:this.currentTime<=0);let k=null===this.holdTime&&("finished"===this.state||"running"===this.state&&w);return k&&p!==dc&&(b.value=dE(c,this.options,f,this.speed)),m&&m(b.value),k&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return this.calculatedDuration/1e3}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+e/1e3}get time(){return this.currentTime/1e3}set time(e){e=uV(e),this.currentTime=e,null===this.startTime||null!==this.holdTime||0===this.playbackSpeed?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(cb.now());let t=this.playbackSpeed!==e;this.playbackSpeed=e,t&&(this.time=this.currentTime/1e3)}play(){if(this.isStopped)return;let{driver:e=u6,startTime:t}=this.options;this.driver||(this.driver=e(e=>this.tick(e))),this.options.onPlay?.();let r=this.driver.now();"finished"===this.state?(this.updateFinished(),this.startTime=r):null!==this.holdTime?this.startTime=r-this.holdTime:this.startTime||(this.startTime=t??r),"finished"===this.state&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(cb.now()),this.holdTime=this.currentTime}complete(){"running"!==this.state&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null,uW.mainThread--}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function dD(e){let t;return()=>(void 0===t&&(t=e()),t)}let dO=dD(()=>void 0!==window.ScrollTimeline),dz={},dF=(u=dD(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(e){return!1}return!0}),()=>dz.linearEasing??u()),dB=([e,t,r,n])=>`cubic-bezier(${e}, ${t}, ${r}, ${n})`,d$={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:dB([0,.65,.55,1]),circOut:dB([.55,0,1,.45]),backIn:dB([.31,.01,.66,-.59]),backOut:dB([.33,1.53,.69,.99])};function dV(e){return"function"==typeof e&&"applyToOptions"in e}class dU extends dM{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;const{element:t,name:r,keyframes:n,pseudoElement:s,allowFlatten:i=!1,finalKeyframe:a,onComplete:o}=e;this.isPseudoElement=!!s,this.allowFlatten=i,this.options=e,lF("string"!=typeof e.type,'Mini animate() doesn\'t support "type" as a string.',"mini-spring");const l=function({type:e,...t}){return dV(e)&&dF()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}(e);this.animation=function(e,t,r,{delay:n=0,duration:s=300,repeat:i=0,repeatType:a="loop",ease:o="easeOut",times:l}={},c){let u={[t]:r};l&&(u.offset=l);let d=function e(t,r){if(t)return"function"==typeof t?dF()?u4(t,r):"ease-out":dN(t)?dB(t):Array.isArray(t)?t.map(t=>e(t,r)||d$.easeOut):d$[t]}(o,s);Array.isArray(d)&&(u.easing=d);let h={delay:n,duration:s,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:i+1,direction:"reverse"===a?"alternate":"normal"};c&&(h.pseudoElement=c);let p=e.animate(u,h);return p}(t,r,n,l,s),!1===l.autoplay&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!s){let e=dE(n,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(e):r.startsWith("--")?t.style.setProperty(r,e):t.style[r]=e,this.animation.cancel()}o?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),"finished"===this.state&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch(e){}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;"idle"!==e&&"finished"!==e&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){return Number(this.animation.effect?.getComputedTiming?.().duration||0)/1e3}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+e/1e3}get time(){return(Number(this.animation.currentTime)||0)/1e3}set time(e){this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=uV(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return null!==this.finishedTime?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,observe:t}){return(this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&dO())?(this.animation.timeline=e,l8):t(this)}}let dG={anticipate:db,backInOut:dv,circInOut:dj};class dW extends dU{constructor(e){!function(e){"string"==typeof e.ease&&e.ease in dG&&(e.ease=dG[e.ease])}(e),dR(e),super(e),void 0!==e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:r,onComplete:n,element:s,...i}=this.options;if(!t)return;if(void 0!==e)return void t.set(e);let a=new dL({...i,autoplay:!1}),o=Math.max(10,cb.now()-this.startTime),l=o1(0,10,o-10);t.setWithVelocity(a.sample(Math.max(0,o-l)).value,a.sample(o).value,l),a.stop()}}let dq=(e,t)=>"zIndex"!==t&&!!("number"==typeof e||Array.isArray(e)||"string"==typeof e&&(lb.test(e)||"0"===e)&&!e.startsWith("url("));function dH(e){e.duration=0,e.type="keyframes"}let dK=new Set(["opacity","clipPath","filter","transform"]),dX=dD(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));class dY extends dM{constructor({autoplay:e=!0,delay:t=0,type:r="keyframes",repeat:n=0,repeatDelay:s=0,repeatType:i="loop",keyframes:a,name:o,motionValue:l,element:c,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=cb.now();const d={autoplay:e,delay:t,type:r,repeat:n,repeatDelay:s,repeatType:i,name:o,motionValue:l,element:c,...u},h=c?.KeyframeResolver||cd;this.keyframeResolver=new h(a,(e,t,r)=>this.onKeyframesResolved(e,t,d,!r),o,l,c),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,r,n){this.keyframeResolver=void 0;let{name:s,type:i,velocity:a,delay:o,isHandoff:l,onUpdate:c}=r;this.resolvedAt=cb.now(),!function(e,t,r,n){let s=e[0];if(null===s)return!1;if("display"===t||"visibility"===t)return!0;let i=e[e.length-1],a=dq(s,t),o=dq(i,t);return lz(a===o,`You are trying to animate ${t} from "${s}" to "${i}". "${a?i:s}" is not an animatable value.`,"value-not-animatable"),!!a&&!!o&&(function(e){let t=e[0];if(1===e.length)return!0;for(let r=0;r<e.length;r++)if(e[r]!==t)return!0}(e)||("spring"===r||dV(r))&&n)}(e,s,i,a)&&((l9.instantAnimations||!o)&&c?.(dE(e,r,t)),e[0]=e[e.length-1],dH(r),r.repeat=0);let u={startTime:n?this.resolvedAt&&this.resolvedAt-this.createdAt>40?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...r,keyframes:e},d=!l&&function(e){let{motionValue:t,name:r,repeatDelay:n,repeatType:s,damping:i,type:a}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;let{onUpdate:o,transformTemplate:l}=t.owner.getProps();return dX()&&r&&dK.has(r)&&("transform"!==r||!l)&&!o&&!n&&"mirror"!==s&&0!==i&&"inertia"!==a}(u),h=u.motionValue?.owner?.current,p=d?new dW({...u,element:h}):new dL(u);p.finished.then(()=>{this.notifyFinished()}).catch(l8),this.pendingTimeline&&(this.stopTimeline=p.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=p}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),cl=!0,cu(),cc(),cl=!1),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}let dJ={type:"spring",stiffness:500,damping:25,restSpeed:10},dZ={type:"keyframes",duration:.8},dQ={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},d0=e=>null!==e,d1=(e,t,r,n={},s,i)=>a=>{let o=uF(n,e)||{},l=o.delay||n.delay||0,{elapsed:c=0}=n;c-=uV(l);let u={keyframes:Array.isArray(r)?r:[null,r],ease:"easeOut",velocity:t.getVelocity(),...o,delay:-c,onUpdate:e=>{t.set(e),o.onUpdate&&o.onUpdate(e)},onComplete:()=>{a(),o.onComplete&&o.onComplete()},name:e,motionValue:t,element:i?void 0:s};!function({when:e,delay:t,delayChildren:r,staggerChildren:n,staggerDirection:s,repeat:i,repeatType:a,repeatDelay:o,from:l,elapsed:c,...u}){return!!Object.keys(u).length}(o)&&Object.assign(u,((e,{keyframes:t})=>t.length>2?dZ:o0.has(e)?e.startsWith("scale")?{type:"spring",stiffness:550,damping:0===t[1]?2*Math.sqrt(550):30,restSpeed:10}:dJ:dQ)(e,u)),u.duration&&(u.duration=uV(u.duration)),u.repeatDelay&&(u.repeatDelay=uV(u.repeatDelay)),void 0!==u.from&&(u.keyframes[0]=u.from);let d=!1;if(!1!==u.type&&(0!==u.duration||u.repeatDelay)||(dH(u),0===u.delay&&(d=!0)),(l9.instantAnimations||l9.skipAnimations)&&(d=!0,dH(u),u.delay=0),u.allowFlatten=!o.type&&!o.ease,d&&!i&&void 0!==t.get()){let e=function(e,{repeat:t,repeatType:r="loop"},n){let s=e.filter(d0),i=t&&"loop"!==r&&t%2==1?0:s.length-1;return s[i]}(u.keyframes,o);if(void 0!==e)return void ct.update(()=>{u.onUpdate(e),u.onComplete()})}return o.isSync?new dL(u):new dY(u)};function d2(e,t,{delay:r=0,transitionOverride:n,type:s}={}){let{transition:i=e.getDefaultTransition(),transitionEnd:a,...o}=t;n&&(i=n);let l=[],c=s&&e.animationState&&e.animationState.getState()[s];for(let t in o){let n=e.getValue(t,e.latestValues[t]??null),s=o[t];if(void 0===s||c&&function({protectedKeys:e,needsAnimating:t},r){let n=e.hasOwnProperty(r)&&!0!==t[r];return t[r]=!1,n}(c,t))continue;let a={delay:r,...uF(i||{},t)},u=n.get();if(void 0!==u&&!n.isAnimating&&!Array.isArray(s)&&s===u&&!a.velocity)continue;let d=!1;if(window.MotionHandoffAnimation){let r=e.props[uR];if(r){let e=window.MotionHandoffAnimation(r,t,ct);null!==e&&(a.startTime=e,d=!0)}}u$(e,t),n.start(d1(t,n,s,e.shouldReduceMotion&&lI.has(t)?{type:!1}:a,e,d));let h=n.animation;h&&l.push(h)}return a&&Promise.all(l).then(()=>{ct.update(()=>{a&&function(e,t){let{transitionEnd:r={},transition:n={},...s}=uz(e,t)||{};for(let t in s={...s,...r}){var i;let r=uB(i=s[t])?i[i.length-1]||0:i;e.hasValue(t)?e.getValue(t).set(r):e.addValue(t,ck(r))}}(e,a)})}),l}function d5(e,t,r,n=0,s=1){let i=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),a=e.size,o=(a-1)*n;return"function"==typeof r?r(i,a):1===s?i*n:o-i*n}function d3(e,t,r={}){let n=uz(e,t,"exit"===r.type?e.presenceContext?.custom:void 0),{transition:s=e.getDefaultTransition()||{}}=n||{};r.transitionOverride&&(s=r.transitionOverride);let i=n?()=>Promise.all(d2(e,n,r)):()=>Promise.resolve(),a=e.variantChildren&&e.variantChildren.size?(n=0)=>{let{delayChildren:i=0,staggerChildren:a,staggerDirection:o}=s;return function(e,t,r=0,n=0,s=0,i=1,a){let o=[];for(let l of e.variantChildren)l.notify("AnimationStart",t),o.push(d3(l,t,{...a,delay:r+("function"==typeof n?0:n)+d5(e.variantChildren,l,n,s,i)}).then(()=>l.notify("AnimationComplete",t)));return Promise.all(o)}(e,t,n,i,a,o,r)}:()=>Promise.resolve(),{when:o}=s;if(!o)return Promise.all([i(),a(r.delay)]);{let[e,t]="beforeChildren"===o?[i,a]:[a,i];return e().then(()=>t())}}let d6=cP.length;function d4(e,t){if(!Array.isArray(t))return!1;let r=t.length;if(r!==e.length)return!1;for(let n=0;n<r;n++)if(t[n]!==e[n])return!1;return!0}let d8=[...cE].reverse(),d9=cE.length;function d7(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function he(){return{animate:d7(!0),whileInView:d7(),whileHover:d7(),whileTap:d7(),whileDrag:d7(),whileFocus:d7(),exit:d7()}}let ht=0;function hr(e){return[e("x"),e("y")]}let hn=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function hs(e){return hn.has(e.tagName)||!0===e.isContentEditable}function hi(e,t,r,n={passive:!0}){return e.addEventListener(t,r,n),()=>e.removeEventListener(t,r)}let ha={x:!1,y:!1};function ho(e){return e.max-e.min}function hl(e,t,r,n=.5){e.origin=n,e.originPoint=c0(t.min,t.max,e.origin),e.scale=ho(r)/ho(t),e.translate=c0(r.min,r.max,e.origin)-e.originPoint,(e.scale>=.9999&&e.scale<=1.0001||isNaN(e.scale))&&(e.scale=1),(e.translate>=-.01&&e.translate<=.01||isNaN(e.translate))&&(e.translate=0)}function hc(e,t,r,n){hl(e.x,t.x,r.x,n?n.originX:void 0),hl(e.y,t.y,r.y,n?n.originY:void 0)}function hu(e,t,r){e.min=r.min+t.min,e.max=e.min+ho(t)}function hd(e,t,r){e.min=t.min-r.min,e.max=e.min+ho(t)}function hh(e,t,r){hd(e.x,t.x,r.x),hd(e.y,t.y,r.y)}let hp=e=>"mouse"===e.pointerType?"number"!=typeof e.button||e.button<=0:!1!==e.isPrimary;function hm(e){return{point:{x:e.pageX,y:e.pageY}}}function hf(e,t,r,n){return hi(e,t,e=>hp(e)&&r(e,hm(e)),n)}let hg=({current:e})=>e?e.ownerDocument.defaultView:null,hx=(e,t)=>Math.abs(e-t),hy=new Set(["auto","scroll"]);class hv{constructor(e,t,{transformPagePoint:r,contextWindow:n=window,dragSnapToOrigin:s=!1,distanceThreshold:i=3,element:a}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{var e,t;if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let r=hk(this.lastMoveEventInfo,this.history),n=null!==this.startEvent,s=(e=r.offset,t={x:0,y:0},Math.sqrt(hx(e.x,t.x)**2+hx(e.y,t.y)**2)>=this.distanceThreshold);if(!n&&!s)return;let{point:i}=r,{timestamp:a}=cn;this.history.push({...i,timestamp:a});let{onStart:o,onMove:l}=this.handlers;n||(o&&o(this.lastMoveEvent,r),this.startEvent=this.lastMoveEvent),l&&l(this.lastMoveEvent,r)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastMoveEventInfo=hb(t,this.transformPagePoint),ct.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:r,onSessionEnd:n,resumeAnimation:s}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&s&&s(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let i=hk("pointercancel"===e.type?this.lastMoveEventInfo:hb(t,this.transformPagePoint),this.history);this.startEvent&&r&&r(e,i),n&&n(e,i)},!hp(e))return;this.dragSnapToOrigin=s,this.handlers=t,this.transformPagePoint=r,this.distanceThreshold=i,this.contextWindow=n||window;const o=hb(hm(e),this.transformPagePoint),{point:l}=o,{timestamp:c}=cn;this.history=[{...l,timestamp:c}];const{onSessionStart:u}=t;u&&u(e,hk(o,this.history)),this.removeListeners=uG(hf(this.contextWindow,"pointermove",this.handlePointerMove),hf(this.contextWindow,"pointerup",this.handlePointerUp),hf(this.contextWindow,"pointercancel",this.handlePointerUp)),a&&this.startScrollTracking(a)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(hy.has(e.overflowX)||hy.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0,passive:!0}),window.addEventListener("scroll",this.onWindowScroll,{passive:!0}),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let r=e===window,n=r?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},s={x:n.x-t.x,y:n.y-t.y};(0!==s.x||0!==s.y)&&(r?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=s.x,this.lastMoveEventInfo.point.y+=s.y):this.history.length>0&&(this.history[0].x-=s.x,this.history[0].y-=s.y),this.scrollPositions.set(e,n),ct.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),cr(this.updatePoint)}}function hb(e,t){return t?{point:t(e.point)}:e}function hw(e,t){return{x:e.x-t.x,y:e.y-t.y}}function hk({point:e},t){return{point:e,delta:hw(e,hj(t)),offset:hw(e,t[0]),velocity:function(e,t){if(e.length<2)return{x:0,y:0};let r=e.length-1,n=null,s=hj(e);for(;r>=0&&(n=e[r],!(s.timestamp-n.timestamp>uV(.1)));)r--;if(!n)return{x:0,y:0};let i=(s.timestamp-n.timestamp)/1e3;if(0===i)return{x:0,y:0};let a={x:(s.x-n.x)/i,y:(s.y-n.y)/i};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}(t,.1)}}function hj(e){return e[e.length-1]}function hN(e,t,r){return{min:void 0!==t?e.min+t:void 0,max:void 0!==r?e.max+r-(e.max-e.min):void 0}}function hS(e,t){let r=t.min-e.min,n=t.max-e.max;return t.max-t.min<e.max-e.min&&([r,n]=[n,r]),{min:r,max:n}}function hC(e,t,r){return{min:hA(e,t),max:hA(e,r)}}function hA(e,t){return"number"==typeof e?e:e[t]||0}let h_=new WeakMap;class hT{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=lR(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:r}={}){let{presenceContext:n}=this.visualElement;if(n&&!1===n.isPresent)return;let s=e=>{t?(this.stopAnimation(),this.snapToCursor(hm(e).point)):this.pauseAnimation()},i=(e,t)=>{this.stopAnimation();let{drag:r,dragPropagation:n,onDragStart:s}=this.getProps();if(r&&!n&&(this.openDragLock&&this.openDragLock(),this.openDragLock=function(e){if("x"===e||"y"===e)if(ha[e])return null;else return ha[e]=!0,()=>{ha[e]=!1};return ha.x||ha.y?null:(ha.x=ha.y=!0,()=>{ha.x=ha.y=!1})}(r),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),hr(e=>{let t=this.getAxisMotionValue(e).get()||0;if(li.test(t)){let{projection:r}=this.visualElement;if(r&&r.layout){let n=r.layout.layoutBox[e];n&&(t=ho(n)*(parseFloat(t)/100))}}this.originPoint[e]=t}),s&&ct.postRender(()=>s(e,t)),u$(this.visualElement,"transform");let{animationState:i}=this.visualElement;i&&i.setActive("whileDrag",!0)},a=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:r,dragDirectionLock:n,onDirectionLock:s,onDrag:i}=this.getProps();if(!r&&!this.openDragLock)return;let{offset:a}=t;if(n&&null===this.currentDirection){this.currentDirection=function(e,t=10){let r=null;return Math.abs(e.y)>t?r="y":Math.abs(e.x)>t&&(r="x"),r}(a),null!==this.currentDirection&&s&&s(this.currentDirection);return}this.updateAxis("x",t.point,a),this.updateAxis("y",t.point,a),this.visualElement.render(),i&&i(e,t)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},l=()=>hr(e=>"paused"===this.getAnimationState(e)&&this.getAxisMotionValue(e).animation?.play()),{dragSnapToOrigin:c}=this.getProps();this.panSession=new hv(e,{onSessionStart:s,onStart:i,onMove:a,onSessionEnd:o,resumeAnimation:l},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:r,contextWindow:hg(this.visualElement),element:this.visualElement.current})}stop(e,t){let r=e||this.latestPointerEvent,n=t||this.latestPanInfo,s=this.isDragging;if(this.cancel(),!s||!n||!r)return;let{velocity:i}=n;this.startAnimation(i);let{onDragEnd:a}=this.getProps();a&&ct.postRender(()=>a(r,n))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,r){let{drag:n}=this.getProps();if(!r||!hE(e,n,this.currentDirection))return;let s=this.getAxisMotionValue(e),i=this.originPoint[e]+r[e];this.constraints&&this.constraints[e]&&(i=function(e,{min:t,max:r},n){return void 0!==t&&e<t?e=n?c0(t,e,n.min):Math.max(e,t):void 0!==r&&e>r&&(e=n?c0(r,e,n.max):Math.min(e,r)),e}(i,this.constraints[e],this.elastic[e])),s.set(i)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,n=this.constraints;e&&uI(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&r?this.constraints=function(e,{top:t,left:r,bottom:n,right:s}){return{x:hN(e.x,r,s),y:hN(e.y,t,n)}}(r.layoutBox,e):this.constraints=!1,this.elastic=function(e=.35){return!1===e?e=0:!0===e&&(e=.35),{x:hC(e,"left","right"),y:hC(e,"top","bottom")}}(t),n!==this.constraints&&r&&this.constraints&&!this.hasMutatedConstraints&&hr(e=>{var t,n;let s;!1!==this.constraints&&this.getAxisMotionValue(e)&&(this.constraints[e]=(t=r.layoutBox[e],n=this.constraints[e],s={},void 0!==n.min&&(s.min=n.min-t.min),void 0!==n.max&&(s.max=n.max-t.min),s))})}resolveRefConstraints(){var e;let{dragConstraints:t,onMeasureDragConstraints:r}=this.getProps();if(!t||!uI(t))return!1;let n=t.current;lF(null!==n,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");let{projection:s}=this.visualElement;if(!s||!s.layout)return!1;let i=function(e,t,r){let n=uo(e,r),{scroll:s}=t;return s&&(us(n.x,s.offset.x),us(n.y,s.offset.y)),n}(n,s.root,this.visualElement.getTransformPagePoint()),a=(e=s.layout.layoutBox,{x:hS(e.x,i.x),y:hS(e.y,i.y)});if(r){let e=r(function({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}(a));this.hasMutatedConstraints=!!e,e&&(a=c4(e))}return a}startAnimation(e){let{drag:t,dragMomentum:r,dragElastic:n,dragTransition:s,dragSnapToOrigin:i,onDragTransitionEnd:a}=this.getProps(),o=this.constraints||{};return Promise.all(hr(a=>{if(!hE(a,t,this.currentDirection))return;let l=o&&o[a]||{};i&&(l={min:0,max:0});let c={type:"inertia",velocity:r?e[a]:0,bounceStiffness:n?200:1e6,bounceDamping:n?40:1e7,timeConstant:750,restDelta:1,restSpeed:10,...s,...l};return this.startAxisValueAnimation(a,c)})).then(a)}startAxisValueAnimation(e,t){let r=this.getAxisMotionValue(e);return u$(this.visualElement,e),r.start(d1(e,r,0,t,this.visualElement,!1))}stopAnimation(){hr(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){hr(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`,r=this.visualElement.getProps();return r[t]||this.visualElement.getValue(e,(r.initial?r.initial[e]:void 0)||0)}snapToCursor(e){hr(t=>{let{drag:r}=this.getProps();if(!hE(t,r,this.currentDirection))return;let{projection:n}=this.visualElement,s=this.getAxisMotionValue(t);if(n&&n.layout){let{min:r,max:i}=n.layout.layoutBox[t],a=s.get()||0;s.set(e[t]-c0(r,i,.5)+a)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:r}=this.visualElement;if(!uI(t)||!r||!this.constraints)return;this.stopAnimation();let n={x:0,y:0};hr(e=>{let t=this.getAxisMotionValue(e);if(t&&!1!==this.constraints){var r,s;let i,a,o,l=t.get();n[e]=(r={min:l,max:l},s=this.constraints[e],i=.5,a=ho(r),(o=ho(s))>a?i=dA(s.min,s.max-a,r.min):a>o&&(i=dA(r.min,r.max-o,s.min)),o1(0,1,i))}});let{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.resolveConstraints(),hr(t=>{if(!hE(t,e,null))return;let r=this.getAxisMotionValue(t),{min:s,max:i}=this.constraints[t];r.set(c0(s,i,n[t]))})}addListeners(){if(!this.visualElement.current)return;h_.set(this.visualElement,this);let e=this.visualElement.current,t=hf(e,"pointerdown",t=>{let{drag:r,dragListener:n=!0}=this.getProps(),s=t.target,i=s!==e&&hs(s);r&&n&&!i&&this.start(t)}),r=()=>{let{dragConstraints:e}=this.getProps();uI(e)&&e.current&&(this.constraints=this.resolveRefConstraints())},{projection:n}=this.visualElement,s=n.addEventListener("measure",r);n&&!n.layout&&(n.root&&n.root.updateScroll(),n.updateLayout()),ct.read(r);let i=hi(window,"resize",()=>this.scalePositionWithinConstraints()),a=n.addEventListener("didUpdate",({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(hr(t=>{let r=this.getAxisMotionValue(t);r&&(this.originPoint[t]+=e[t].translate,r.set(r.get()+e[t].translate))}),this.visualElement.render())});return()=>{i(),t(),s(),a&&a()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:r=!1,dragPropagation:n=!1,dragConstraints:s=!1,dragElastic:i=.35,dragMomentum:a=!0}=e;return{...e,drag:t,dragDirectionLock:r,dragPropagation:n,dragConstraints:s,dragElastic:i,dragMomentum:a}}}function hE(e,t,r){return(!0===t||t===e)&&(null===r||r===e)}let hP=e=>(t,r)=>{e&&ct.postRender(()=>e(t,r))},hR={hasAnimatedSinceResize:!0,hasEverUpdated:!1};var hM=b;let hI=!1;class hL extends hM.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:r,layoutId:n}=this.props,{projection:s}=e;s&&(t.group&&t.group.add(s),r&&r.register&&n&&r.register(s),hI&&s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),hR.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:r,drag:n,isPresent:s}=this.props,{projection:i}=r;return i&&(i.isPresent=s,e.layoutDependency!==t&&i.setOptions({...i.options,layoutDependency:t}),hI=!0,n||e.layoutDependency!==t||void 0===t||e.isPresent!==s?i.willUpdate():this.safeToRemove(),e.isPresent!==s&&(s?i.promote():i.relegate()||ct.postRender(()=>{let e=i.getStack();e&&e.members.length||this.safeToRemove()}))),null}componentDidUpdate(){let{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),cy.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:r}=this.props,{projection:n}=e;hI=!0,n&&(n.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(n),r&&r.deregister&&r.deregister(n))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}}function hD(e){let[t,r]=function(e=!0){let t=(0,b.useContext)(uj);if(null===t)return[!0,null];let{isPresent:r,onExitComplete:n,register:s}=t,i=(0,b.useId)();(0,b.useEffect)(()=>{if(e)return s(i)},[e]);let a=(0,b.useCallback)(()=>e&&n&&n(i),[i,n,e]);return!r&&n?[!1,a]:[!0]}(),n=(0,hM.useContext)(ud);return(0,v.jsx)(hL,{...e,layoutGroup:n,switchLayoutGroup:(0,hM.useContext)(uM),isPresent:t,safeToRemove:r})}function hO(e,t,r,n,s){return e-=t,e=n+1/r*(e-n),void 0!==s&&(e=n+1/s*(e-n)),e}function hz(e,t,[r,n,s],i,a){!function(e,t=0,r=1,n=.5,s,i=e,a=e){if(li.test(t)&&(t=parseFloat(t),t=c0(a.min,a.max,t/100)-a.min),"number"!=typeof t)return;let o=c0(i.min,i.max,n);e===i&&(o-=t),e.min=hO(e.min,t,r,o,s),e.max=hO(e.max,t,r,o,s)}(e,t[r],t[n],t[s],t.scale,i,a)}let hF=["x","scaleX","originX"],hB=["y","scaleY","originY"];function h$(e,t,r,n){hz(e.x,t,hF,r?r.x:void 0,n?n.x:void 0),hz(e.y,t,hB,r?r.y:void 0,n?n.y:void 0)}function hV(e,t){e.min=t.min,e.max=t.max}function hU(e,t){hV(e.x,t.x),hV(e.y,t.y)}function hG(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function hW(e){return 0===e.translate&&1===e.scale}function hq(e){return hW(e.x)&&hW(e.y)}function hH(e,t){return e.min===t.min&&e.max===t.max}function hK(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function hX(e,t){return hK(e.x,t.x)&&hK(e.y,t.y)}function hY(e){return ho(e.x)/ho(e.y)}function hJ(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}let hZ=["TopLeft","TopRight","BottomLeft","BottomRight"],hQ=hZ.length,h0=e=>"string"==typeof e?parseFloat(e):e,h1=e=>"number"==typeof e||la.test(e);function h2(e,t){return void 0!==e[t]?e[t]:e.borderRadius}let h5=h6(0,.5,dk),h3=h6(.5,.95,l8);function h6(e,t,r){return n=>n<e?0:n>t?1:r(dA(e,t,n))}function h4(e){return"object"==typeof e&&null!==e}function h8(e){return h4(e)&&"ownerSVGElement"in e}let h9=(e,t)=>e.depth-t.depth;class h7{constructor(){this.children=[],this.isDirty=!1}add(e){cf(this.children,e),this.isDirty=!0}remove(e){cg(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(h9),this.isDirty=!1,this.children.forEach(e)}}class pe{constructor(){this.members=[]}add(e){cf(this.members,e),e.scheduleRender()}remove(e){if(cg(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){let t,r=this.members.findIndex(t=>e===t);if(0===r)return!1;for(let e=r;e>=0;e--){let r=this.members[e];if(!1!==r.isPresent){t=r;break}}return!!t&&(this.promote(t),!0)}promote(e,t){let r=this.lead;if(e!==r&&(this.prevLead=r,this.lead=e,e.show(),r)){r.instance&&r.scheduleRender(),e.scheduleRender();let n=r.options.layoutDependency,s=e.options.layoutDependency;(void 0===n||void 0===s||n!==s)&&(e.resumeFrom=r,t&&(e.resumeFrom.preserveOpacity=!0),r.snapshot&&(e.snapshot=r.snapshot,e.snapshot.latestValues=r.animationValues||r.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0));let{crossfade:i}=e.options;!1===i&&r.hide()}}exitAnimationComplete(){this.members.forEach(e=>{let{options:t,resumingFrom:r}=e;t.onExitComplete&&t.onExitComplete(),r&&r.options.onExitComplete&&r.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}let pt=["","X","Y","Z"],pr=0;function pn(e,t,r,n){let{latestValues:s}=t;s[e]&&(r[e]=s[e],t.setStaticValue(e,0),n&&(n[e]=0))}function ps({attachResizeListener:e,defaultParent:t,measureScroll:r,checkIsScrollRoot:n,resetTransform:s}){return class{constructor(e={},r=t?.()){this.id=pr++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(po),this.nodes.forEach(pm),this.nodes.forEach(pf),this.nodes.forEach(pl)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=r?r.root||r:this,this.path=r?[...r.path,r]:[],this.parent=r,this.depth=r?r.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new h7)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new cx),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let r=this.eventHandlers.get(e);r&&r.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=h8(t)&&!(h8(t)&&"svg"===t.tagName),this.instance=t;let{layoutId:r,layout:n,visualElement:s}=this.options;if(s&&!s.current&&s.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(n||r)&&(this.isLayoutDirty=!0),e){let r,n=0,s=()=>this.root.updateBlockedByResize=!1;ct.read(()=>{n=window.innerWidth}),e(t,()=>{let e=window.innerWidth;if(e!==n){let t,i;n=e,this.root.updateBlockedByResize=!0,r&&r(),t=cb.now(),i=({timestamp:e})=>{let r=e-t;r>=250&&(cr(i),s(r-250))},ct.setup(i,!0),r=()=>cr(i),hR.hasAnimatedSinceResize&&(hR.hasAnimatedSinceResize=!1,this.nodes.forEach(pp))}})}r&&this.root.registerSharedNode(r,this),!1!==this.options.animate&&s&&(r||n)&&this.addEventListener("didUpdate",({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:r,layout:n})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let i=this.options.transition||s.getDefaultTransition()||pw,{onLayoutAnimationStart:a,onLayoutAnimationComplete:o}=s.getProps(),l=!this.targetLayout||!hX(this.targetLayout,n),c=!t&&r;if(this.options.layoutRoot||this.resumeFrom||c||t&&(l||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...uF(i,"layout"),onPlay:a,onComplete:o};(s.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,c)}else t||pp(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=n})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),cr(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){!this.isUpdateBlocked()&&(this.isUpdating=!0,this.nodes&&this.nodes.forEach(pg),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&function e(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;let{visualElement:r}=t.options;if(!r)return;let n=r.props[uR];if(window.MotionHasOptimisedAnimation(n,"transform")){let{layout:e,layoutId:r}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",ct,!(e||r))}let{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&e(s)}(this),this.root.isUpdating||this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,t.updateScroll("snapshot"),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:r}=this.options;if(void 0===t&&!r)return;let n=this.getTransformTemplate();this.prevTransformTemplateValue=n?n(this.latestValues,""):void 0,this.updateSnapshot(),e&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(pu);return}if(this.animationId<=this.animationCommitId)return void this.nodes.forEach(pd);this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(ph),this.nodes.forEach(pi),this.nodes.forEach(pa)):this.nodes.forEach(pd),this.clearAllSnapshots();let e=cb.now();cn.delta=o1(0,1e3/60,e-cn.timestamp),cn.timestamp=e,cn.isProcessing=!0,cs.update.process(cn),cs.preRender.process(cn),cs.render.process(cn),cn.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,cy.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(pc),this.sharedNodes.forEach(px)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,ct.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){ct.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),!this.snapshot||ho(this.snapshot.measuredBox.x)||ho(this.snapshot.measuredBox.y)||(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected=lR(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify("LayoutMeasure",this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e="measure"){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=n(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:r(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!s)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!hq(this.projectionDelta),r=this.getTransformTemplate(),n=r?r(this.latestValues,""):void 0,i=n!==this.prevTransformTemplateValue;e&&this.instance&&(t||c7(this.latestValues)||i)&&(s(this.instance,n),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){var t;let r=this.measurePageBox(),n=this.removeElementScroll(r);return e&&(n=this.removeTransform(n)),pN((t=n).x),pN(t.y),{animationId:this.root.animationId,measuredBox:r,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return lR();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(pC))){let{scroll:e}=this.root;e&&(us(t.x,e.offset.x),us(t.y,e.offset.y))}return t}removeElementScroll(e){let t=lR();if(hU(t,e),this.scroll?.wasRoot)return t;for(let r=0;r<this.path.length;r++){let n=this.path[r],{scroll:s,options:i}=n;n!==this.root&&s&&i.layoutScroll&&(s.wasRoot&&hU(t,e),us(t.x,s.offset.x),us(t.y,s.offset.y))}return t}applyTransform(e,t=!1){let r=lR();hU(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&ua(r,{x:-n.scroll.offset.x,y:-n.scroll.offset.y}),c7(n.latestValues)&&ua(r,n.latestValues)}return c7(this.latestValues)&&ua(r,this.latestValues),r}removeTransform(e){let t=lR();hU(t,e);for(let e=0;e<this.path.length;e++){let r=this.path[e];if(!r.instance||!c7(r.latestValues))continue;c9(r.latestValues)&&r.updateSnapshot();let n=lR();hU(n,r.measurePageBox()),h$(t,r.latestValues,r.snapshot?r.snapshot.layoutBox:void 0,n)}return c7(this.latestValues)&&h$(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:void 0===e.crossfade||e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==cn.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=t.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=t.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=t.isSharedProjectionDirty);let r=!!this.resumingFrom||this!==t;if(!(e||r&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:n,layoutId:s}=this.options;if(!this.layout||!(n||s))return;this.resolvedRelativeTargetAt=cn.timestamp;let i=this.getClosestProjectingParent();if(i&&this.linkedParentVersion!==i.layoutVersion&&!i.options.layoutRoot&&this.removeRelativeTarget(),this.targetDelta||this.relativeTarget||(i&&i.layout?this.createRelativeTarget(i,this.layout.layoutBox,i.layout.layoutBox):this.removeRelativeTarget()),this.relativeTarget||this.targetDelta){if(this.target||(this.target=lR(),this.targetWithTransforms=lR()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target){var a,o,l;this.forceRelativeParentToResolveTarget(),a=this.target,o=this.relativeTarget,l=this.relativeParent.target,hu(a.x,o.x,l.x),hu(a.y,o.y,l.y)}else this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):hU(this.target,this.layout.layoutBox),un(this.target,this.targetDelta)):hU(this.target,this.layout.layoutBox);this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,i&&!!i.resumingFrom==!!this.resumingFrom&&!i.options.layoutScroll&&i.target&&1!==this.animationProgress?this.createRelativeTarget(i,this.target,i.target):this.relativeParent=this.relativeTarget=void 0)}}getClosestProjectingParent(){if(!(!this.parent||c9(this.parent.latestValues)||ue(this.parent.latestValues)))if(this.parent.isProjecting())return this.parent;else return this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,r){this.relativeParent=e,this.linkedParentVersion=e.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=lR(),this.relativeTargetOrigin=lR(),hh(this.relativeTargetOrigin,t,r),hU(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,r=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(r=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(r=!1),this.resolvedRelativeTargetAt===cn.timestamp&&(r=!1),r)return;let{layout:n,layoutId:s}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(n||s))return;hU(this.layoutCorrected,this.layout.layoutBox);let i=this.treeScale.x,a=this.treeScale.y;!function(e,t,r,n=!1){let s,i,a=r.length;if(a){t.x=t.y=1;for(let o=0;o<a;o++){i=(s=r[o]).projectionDelta;let{visualElement:a}=s.options;(!a||!a.props.style||"contents"!==a.props.style.display)&&(n&&s.options.layoutScroll&&s.scroll&&s!==s.root&&ua(e,{x:-s.scroll.offset.x,y:-s.scroll.offset.y}),i&&(t.x*=i.x.scale,t.y*=i.y.scale,un(e,i)),n&&c7(s.latestValues)&&ua(e,s.latestValues))}t.x<1.0000000000001&&t.x>.999999999999&&(t.x=1),t.y<1.0000000000001&&t.y>.999999999999&&(t.y=1)}}(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(1!==this.treeScale.x||1!==this.treeScale.y)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=lR());let{target:o}=e;if(!o){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}this.projectionDelta&&this.prevProjectionDelta?(hG(this.prevProjectionDelta.x,this.projectionDelta.x),hG(this.prevProjectionDelta.y,this.projectionDelta.y)):this.createProjectionDeltas(),hc(this.projectionDelta,this.layoutCorrected,o,this.latestValues),this.treeScale.x===i&&this.treeScale.y===a&&hJ(this.projectionDelta.x,this.prevProjectionDelta.x)&&hJ(this.projectionDelta.y,this.prevProjectionDelta.y)||(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",o))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=lE(),this.projectionDelta=lE(),this.projectionDeltaWithTransform=lE()}setAnimationOrigin(e,t=!1){let r,n=this.snapshot,s=n?n.latestValues:{},i={...this.latestValues},a=lE();this.relativeParent&&this.relativeParent.options.layoutRoot||(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let o=lR(),l=(n?n.source:void 0)!==(this.layout?this.layout.source:void 0),c=this.getStack(),u=!c||c.members.length<=1,d=!!(l&&!u&&!0===this.options.crossfade&&!this.path.some(pb));this.animationProgress=0,this.mixTargetDelta=t=>{let n=t/1e3;if(py(a.x,e.x,n),py(a.y,e.y,n),this.setTargetDelta(a),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout){var c,h,p,m,f,g;hh(o,this.layout.layoutBox,this.relativeParent.layout.layoutBox),p=this.relativeTarget,m=this.relativeTargetOrigin,f=o,g=n,pv(p.x,m.x,f.x,g),pv(p.y,m.y,f.y,g),r&&(c=this.relativeTarget,h=r,hH(c.x,h.x)&&hH(c.y,h.y))&&(this.isProjectionDirty=!1),r||(r=lR()),hU(r,this.relativeTarget)}l&&(this.animationValues=i,function(e,t,r,n,s,i){s?(e.opacity=c0(0,r.opacity??1,h5(n)),e.opacityExit=c0(t.opacity??1,0,h3(n))):i&&(e.opacity=c0(t.opacity??1,r.opacity??1,n));for(let s=0;s<hQ;s++){let i=`border${hZ[s]}Radius`,a=h2(t,i),o=h2(r,i);(void 0!==a||void 0!==o)&&(a||(a=0),o||(o=0),0===a||0===o||h1(a)===h1(o)?(e[i]=Math.max(c0(h0(a),h0(o),n),0),(li.test(o)||li.test(a))&&(e[i]+="%")):e[i]=o)}(t.rotate||r.rotate)&&(e.rotate=c0(t.rotate||0,r.rotate||0,n))}(i,s,this.latestValues,n,d,u)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(1e3*!!this.options.layoutRoot)}startAnimation(e){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(cr(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ct.update(()=>{var t,r,n;let s;hR.hasAnimatedSinceResize=!0,uW.layout++,this.motionValue||(this.motionValue=ck(0)),this.currentAnimation=(t=this.motionValue,r=[0,1e3],n={...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onStop:()=>{uW.layout--},onComplete:()=>{uW.layout--,e.onComplete&&e.onComplete(),this.completeAnimation()}},(s=lM(t)?t:ck(t)).start(d1("",s,r,n)),s.animation),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(1e3),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,target:r,layout:n,latestValues:s}=e;if(t&&r&&n){if(this!==e&&this.layout&&n&&pS(this.options.animationType,this.layout.layoutBox,n.layoutBox)){r=this.target||lR();let t=ho(this.layout.layoutBox.x);r.x.min=e.target.x.min,r.x.max=r.x.min+t;let n=ho(this.layout.layoutBox.y);r.y.min=e.target.y.min,r.y.max=r.y.min+n}hU(t,r),ua(t,s),hc(this.projectionDeltaWithTransform,this.layoutCorrected,t,s)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new pe),this.sharedNodes.get(e).add(t);let r=t.options.initialPromotionConfig;t.promote({transition:r?r.transition:void 0,preserveFollowOpacity:r&&r.shouldPreserveFollowOpacity?r.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return!e||e.lead===this}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:r}={}){let n=this.getStack();n&&n.promote(this,r),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return!!e&&e.relegate(this)}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:r}=e;if((r.z||r.rotate||r.rotateX||r.rotateY||r.rotateZ||r.skewX||r.skewY)&&(t=!0),!t)return;let n={};r.z&&pn("z",e,n,this.animationValues);for(let t=0;t<pt.length;t++)pn(`rotate${pt[t]}`,e,n,this.animationValues),pn(`skew${pt[t]}`,e,n,this.animationValues);for(let t in e.render(),n)e.setStaticValue(t,n[t]),this.animationValues&&(this.animationValues[t]=n[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility="hidden";return}let r=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility="",e.opacity="",e.pointerEvents=uk(t?.pointerEvents)||"",e.transform=r?r(this.latestValues,""):"none";return}let n=this.getLead();if(!this.projectionDelta||!this.layout||!n.target){this.options.layoutId&&(e.opacity=void 0!==this.latestValues.opacity?this.latestValues.opacity:1,e.pointerEvents=uk(t?.pointerEvents)||""),this.hasProjected&&!c7(this.latestValues)&&(e.transform=r?r({},""):"none",this.hasProjected=!1);return}e.visibility="";let s=n.animationValues||n.latestValues;this.applyTransformsToTarget();let i=function(e,t,r){let n="",s=e.x.translate/t.x,i=e.y.translate/t.y,a=r?.z||0;if((s||i||a)&&(n=`translate3d(${s}px, ${i}px, ${a}px) `),(1!==t.x||1!==t.y)&&(n+=`scale(${1/t.x}, ${1/t.y}) `),r){let{transformPerspective:e,rotate:t,rotateX:s,rotateY:i,skewX:a,skewY:o}=r;e&&(n=`perspective(${e}px) ${n}`),t&&(n+=`rotate(${t}deg) `),s&&(n+=`rotateX(${s}deg) `),i&&(n+=`rotateY(${i}deg) `),a&&(n+=`skewX(${a}deg) `),o&&(n+=`skewY(${o}deg) `)}let o=e.x.scale*t.x,l=e.y.scale*t.y;return(1!==o||1!==l)&&(n+=`scale(${o}, ${l})`),n||"none"}(this.projectionDeltaWithTransform,this.treeScale,s);r&&(i=r(s,i)),e.transform=i;let{x:a,y:o}=this.projectionDelta;for(let t in e.transformOrigin=`${100*a.origin}% ${100*o.origin}% 0`,n.animationValues?e.opacity=n===this?s.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:s.opacityExit:e.opacity=n===this?void 0!==s.opacity?s.opacity:"":void 0!==s.opacityExit?s.opacityExit:0,c1){if(void 0===s[t])continue;let{correct:r,applyTo:a,isCSSVariable:o}=c1[t],l="none"===i?s[t]:r(s[t],n);if(a){let t=a.length;for(let r=0;r<t;r++)e[a[r]]=l}else o?this.options.visualElement.renderState.vars[t]=l:e[t]=l}this.options.layoutId&&(e.pointerEvents=n===this?uk(t?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(pu),this.root.sharedNodes.clear()}}}function pi(e){e.updateLayout()}function pa(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){let{layoutBox:r,measuredBox:n}=e.layout,{animationType:s}=e.options,i=t.source!==e.layout.source;"size"===s?hr(e=>{let n=i?t.measuredBox[e]:t.layoutBox[e],s=ho(n);n.min=r[e].min,n.max=n.min+s}):pS(s,t.layoutBox,r)&&hr(n=>{let s=i?t.measuredBox[n]:t.layoutBox[n],a=ho(r[n]);s.max=s.min+a,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[n].max=e.relativeTarget[n].min+a)});let a=lE();hc(a,r,t.layoutBox);let o=lE();i?hc(o,e.applyTransform(n,!0),t.measuredBox):hc(o,r,t.layoutBox);let l=!hq(a),c=!1;if(!e.resumeFrom){let n=e.getClosestProjectingParent();if(n&&!n.resumeFrom){let{snapshot:s,layout:i}=n;if(s&&i){let a=lR();hh(a,t.layoutBox,s.layoutBox);let o=lR();hh(o,r,i.layoutBox),hX(a,o)||(c=!0),n.options.layoutRoot&&(e.relativeTarget=o,e.relativeTargetOrigin=a,e.relativeParent=n)}}}e.notifyListeners("didUpdate",{layout:r,snapshot:t,delta:o,layoutDelta:a,hasLayoutChanged:l,hasRelativeLayoutChanged:c})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function po(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function pl(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function pc(e){e.clearSnapshot()}function pu(e){e.clearMeasurements()}function pd(e){e.isLayoutDirty=!1}function ph(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function pp(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function pm(e){e.resolveTargetDelta()}function pf(e){e.calcProjection()}function pg(e){e.resetSkewAndRotation()}function px(e){e.removeLeadSnapshot()}function py(e,t,r){e.translate=c0(t.translate,0,r),e.scale=c0(t.scale,1,r),e.origin=t.origin,e.originPoint=t.originPoint}function pv(e,t,r,n){e.min=c0(t.min,r.min,n),e.max=c0(t.max,r.max,n)}function pb(e){return e.animationValues&&void 0!==e.animationValues.opacityExit}let pw={duration:.45,ease:[.4,0,.1,1]},pk=e=>"u">typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),pj=pk("applewebkit/")&&!pk("chrome/")?Math.round:l8;function pN(e){e.min=pj(e.min),e.max=pj(e.max)}function pS(e,t,r){return"position"===e||"preserve-aspect"===e&&!(.2>=Math.abs(hY(t)-hY(r)))}function pC(e){return e!==e.root&&e.scroll?.wasRoot}let pA=ps({attachResizeListener:(e,t)=>hi(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),p_={current:void 0},pT=ps({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!p_.current){let e=new pA({});e.mount(window),e.setOptions({layoutScroll:!0}),p_.current=e}return p_.current},resetTransform:(e,t)=>{e.style.transform=void 0!==t?t:"none"},checkIsScrollRoot:e=>"fixed"===window.getComputedStyle(e).position});function pE(e,t){let r=function(e,t,r){if(null==e)return[];if(e instanceof EventTarget)return[e];if("string"==typeof e){let t=document,r=(void 0)??t.querySelectorAll(e);return r?Array.from(r):[]}return Array.from(e).filter(e=>null!=e)}(e),n=new AbortController;return[r,{passive:!0,...t,signal:n.signal},()=>n.abort()]}function pP(e){return!("touch"===e.pointerType||ha.x||ha.y)}function pR(e,t,r){let{props:n}=e;e.animationState&&n.whileHover&&e.animationState.setActive("whileHover","Start"===r);let s=n["onHover"+r];s&&ct.postRender(()=>s(t,hm(t)))}let pM=(e,t)=>!!t&&(e===t||pM(e,t.parentElement)),pI=new WeakSet;function pL(e){return t=>{"Enter"===t.key&&e(t)}}function pD(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}function pO(e){return hp(e)&&!(ha.x||ha.y)}function pz(e,t,r){let{props:n}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&n.whileTap&&e.animationState.setActive("whileTap","Start"===r);let s=n["onTap"+("End"===r?"":r)];s&&ct.postRender(()=>s(t,hm(t)))}let pF=new WeakMap,pB=new WeakMap,p$=e=>{let t=pF.get(e.target);t&&t(e)},pV=e=>{e.forEach(p$)},pU={some:0,all:1},pG=function(e,t){if("u"<typeof Proxy)return uD;let r=new Map,n=(r,n)=>uD(r,n,e,t);return new Proxy((e,t)=>n(e,t),{get:(s,i)=>"create"===i?n:(r.has(i)||r.set(i,uD(i,void 0,e,t)),r.get(i))})}({animation:{Feature:class extends uO{constructor(e){super(e),e.animationState||(e.animationState=function(e){let t=t=>Promise.all(t.map(({animation:t,options:r})=>(function(e,t,r={}){let n;if(e.notify("AnimationStart",t),Array.isArray(t))n=Promise.all(t.map(t=>d3(e,t,r)));else if("string"==typeof t)n=d3(e,t,r);else{let s="function"==typeof t?uz(e,t,r.custom):t;n=Promise.all(d2(e,s,r))}return n.then(()=>{e.notify("AnimationComplete",t)})})(e,t,r))),r=he(),n=!0,s=t=>(r,n)=>{let s=uz(e,n,"exit"===t?e.presenceContext?.custom:void 0);if(s){let{transition:e,transitionEnd:t,...n}=s;r={...r,...n,...t}}return r};function i(i){let{props:a}=e,o=function e(t){if(!t)return;if(!t.isControllingVariants){let r=t.parent&&e(t.parent)||{};return void 0!==t.props.initial&&(r.initial=t.props.initial),r}let r={};for(let e=0;e<d6;e++){let n=cP[e],s=t.props[n];(cT(s)||!1===s)&&(r[n]=s)}return r}(e.parent)||{},l=[],c=new Set,u={},d=1/0;for(let t=0;t<d9;t++){var h,p;let m=d8[t],f=r[m],g=void 0!==a[m]?a[m]:o[m],x=cT(g),y=m===i?f.isActive:null;!1===y&&(d=t);let v=g===o[m]&&g!==a[m]&&x;if(v&&n&&e.manuallyAnimateOnMount&&(v=!1),f.protectedKeys={...u},!f.isActive&&null===y||!g&&!f.prevProp||c_(g)||"boolean"==typeof g)continue;let b=(h=f.prevProp,"string"==typeof(p=g)?p!==h:!!Array.isArray(p)&&!d4(p,h)),w=b||m===i&&f.isActive&&!v&&x||t>d&&x,k=!1,j=Array.isArray(g)?g:[g],N=j.reduce(s(m),{});!1===y&&(N={});let{prevResolvedValues:S={}}=f,C={...S,...N},A=t=>{w=!0,c.has(t)&&(k=!0,c.delete(t)),f.needsAnimating[t]=!0;let r=e.getValue(t);r&&(r.liveStyle=!1)};for(let e in C){let t=N[e],r=S[e];if(!u.hasOwnProperty(e))(uB(t)&&uB(r)?d4(t,r):t===r)?void 0!==t&&c.has(e)?A(e):f.protectedKeys[e]=!0:null!=t?A(e):c.add(e)}f.prevProp=g,f.prevResolvedValues=N,f.isActive&&(u={...u,...N}),n&&e.blockInitialAnimation&&(w=!1);let _=v&&b,T=!_||k;w&&T&&l.push(...j.map(t=>{let r={type:m};if("string"==typeof t&&n&&!_&&e.manuallyAnimateOnMount&&e.parent){let{parent:n}=e,s=uz(n,t);if(n.enteringChildren&&s){let{delayChildren:t}=s.transition||{};r.delay=d5(n.enteringChildren,e,t)}}return{animation:t,options:r}}))}if(c.size){let t={};if("boolean"!=typeof a.initial){let r=uz(e,Array.isArray(a.initial)?a.initial[0]:a.initial);r&&r.transition&&(t.transition=r.transition)}c.forEach(r=>{let n=e.getBaseTarget(r),s=e.getValue(r);s&&(s.liveStyle=!0),t[r]=n??null}),l.push({animation:t})}let m=!!l.length;return n&&(!1===a.initial||a.initial===a.animate)&&!e.manuallyAnimateOnMount&&(m=!1),n=!1,m?t(l):Promise.resolve()}return{animateChanges:i,setActive:function(t,n){if(r[t].isActive===n)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,n)),r[t].isActive=n;let s=i(t);for(let e in r)r[e].protectedKeys={};return s},setAnimateFunction:function(r){t=r(e)},getState:()=>r,reset:()=>{r=he()}}}(e))}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();c_(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}},exit:{Feature:class extends uO{constructor(){super(...arguments),this.id=ht++}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===r)return;let n=this.node.animationState.setActive("exit",!e);t&&!e&&n.then(()=>{t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}},inView:{Feature:class extends uO{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var e;let t;this.unmount();let{viewport:r={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:a}=r,o={root:n?n.current:void 0,rootMargin:s,threshold:"number"==typeof i?i:pU[i]},l=e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,a&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",t);let{onViewportEnter:r,onViewportLeave:n}=this.node.getProps(),s=t?r:n;s&&s(e)};return e=this.node.current,t=function({root:e,...t}){let r=e||document;pB.has(r)||pB.set(r,{});let n=pB.get(r),s=JSON.stringify(t);return n[s]||(n[s]=new IntersectionObserver(pV,{root:e,...t})),n[s]}(o),pF.set(e,l),t.observe(e),()=>{pF.delete(e),t.unobserve(e)}}mount(){this.startObserver()}update(){if("u"<typeof IntersectionObserver)return;let{props:e,prevProps:t}=this.node;["amount","margin","root"].some(function({viewport:e={}},{viewport:t={}}={}){return r=>e[r]!==t[r]}(e,t))&&this.startObserver()}unmount(){}}},tap:{Feature:class extends uO{mount(){let{current:e}=this.node;e&&(this.unmount=function(e,t,r={}){let[n,s,i]=pE(e,r),a=e=>{let n=e.currentTarget;if(!pO(e))return;pI.add(n);let i=t(n,e),a=(e,t)=>{window.removeEventListener("pointerup",o),window.removeEventListener("pointercancel",l),pI.has(n)&&pI.delete(n),pO(e)&&"function"==typeof i&&i(e,{success:t})},o=e=>{a(e,n===window||n===document||r.useGlobalTarget||pM(n,e.target))},l=e=>{a(e,!1)};window.addEventListener("pointerup",o,s),window.addEventListener("pointercancel",l,s)};return n.forEach(e=>{(r.useGlobalTarget?window:e).addEventListener("pointerdown",a,s),h4(e)&&"offsetHeight"in e&&(e.addEventListener("focus",e=>((e,t)=>{let r=e.currentTarget;if(!r)return;let n=pL(()=>{if(pI.has(r))return;pD(r,"down");let e=pL(()=>{pD(r,"up")});r.addEventListener("keyup",e,t),r.addEventListener("blur",()=>pD(r,"cancel"),t)});r.addEventListener("keydown",n,t),r.addEventListener("blur",()=>r.removeEventListener("keydown",n),t)})(e,s)),hs(e)||e.hasAttribute("tabindex")||(e.tabIndex=0))}),i}(e,(e,t)=>(pz(this.node,t,"Start"),(e,{success:t})=>pz(this.node,e,t?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}},focus:{Feature:class extends uO{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch(t){e=!0}e&&this.node.animationState&&(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){this.isActive&&this.node.animationState&&(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=uG(hi(this.node.current,"focus",()=>this.onFocus()),hi(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}},hover:{Feature:class extends uO{mount(){let{current:e}=this.node;e&&(this.unmount=function(e,t,r={}){let[n,s,i]=pE(e,r),a=e=>{if(!pP(e))return;let{target:r}=e,n=t(r,e);if("function"!=typeof n||!r)return;let i=e=>{pP(e)&&(n(e),r.removeEventListener("pointerleave",i))};r.addEventListener("pointerleave",i,s)};return n.forEach(e=>{e.addEventListener("pointerenter",a,s)}),i}(e,(e,t)=>(pR(this.node,t,"Start"),e=>pR(this.node,e,"End"))))}unmount(){}}},pan:{Feature:class extends uO{constructor(){super(...arguments),this.removePointerDownListener=l8}onPointerDown(e){this.session=new hv(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:hg(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:r,onPanEnd:n}=this.node.getProps();return{onSessionStart:hP(e),onStart:hP(t),onMove:r,onEnd:(e,t)=>{delete this.session,n&&ct.postRender(()=>n(e,t))}}}mount(){this.removePointerDownListener=hf(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}},drag:{Feature:class extends uO{constructor(e){super(e),this.removeGroupControls=l8,this.removeListeners=l8,this.controls=new hT(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||l8}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},ProjectionNode:pT,MeasureLayout:hD},layout:{ProjectionNode:pT,MeasureLayout:hD}},(e,t)=>t.isSVG??uu(e)?new c6(t):new ul(t,{allowProjection:e!==b.Fragment})),pW=(0,b.memo)(({children:e,as:t="p",className:r,duration:n=2,spread:s=2})=>{let i=pG.create(t),a=(0,b.useMemo)(()=>(e?.length??0)*s,[e,s]);return(0,v.jsx)(i,{animate:{backgroundPosition:"0% center"},className:(0,k.cn)("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",r),initial:{backgroundPosition:"100% center"},style:{"--spread":`${a}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:1/0,duration:n,ease:"linear"},children:e})}),pq=(0,b.createContext)(null),pH=(0,b.memo)(({className:e,isStreaming:t=!1,open:r,defaultOpen:n=!0,onOpenChange:s,duration:i,children:a,...o})=>{let[l,c]=(0,aK.useControllableState)({prop:r,defaultProp:n,onChange:s}),[u,d]=(0,aK.useControllableState)({prop:i,defaultProp:void 0}),[h,p]=(0,b.useState)(!1),[m,f]=(0,b.useState)(null);return(0,b.useEffect)(()=>{t?null===m&&f(Date.now()):null!==m&&(d(Math.ceil((Date.now()-m)/1e3)),f(null))},[t,m,d]),(0,b.useEffect)(()=>{if(n&&!t&&l&&!h){let e=setTimeout(()=>{c(!1),p(!0)},1e3);return()=>clearTimeout(e)}},[t,l,n,c,h]),(0,v.jsx)(pq.Provider,{value:{isStreaming:t,isOpen:l,setIsOpen:c,duration:u},children:(0,v.jsx)(os,{className:(0,k.cn)("not-prose mb-4",e),onOpenChange:e=>{c(e)},open:l,...o,children:a})})}),pK=(e,t)=>e||0===t?(0,v.jsx)(pW,{duration:1,children:"Thinking..."}):void 0===t?(0,v.jsx)("p",{children:"Thought for a few seconds"}):(0,v.jsxs)("p",{children:["Thought for ",t," seconds"]}),pX=(0,b.memo)(({className:e,children:t,getThinkingMessage:r=pK,...n})=>{let{isStreaming:s,isOpen:i,duration:a}=(()=>{let e=(0,b.useContext)(pq);if(!e)throw Error("Reasoning components must be used within Reasoning");return e})();return(0,v.jsx)(oi,{className:(0,k.cn)("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:t??(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(oZ,{className:"size-4"}),r(s,a),(0,v.jsx)(ol.ChevronDownIcon,{className:(0,k.cn)("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),pY=(0,b.memo)(({className:e,children:t,...r})=>(0,v.jsx)(oa,{className:(0,k.cn)("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...r,children:(0,v.jsx)(aB.j,{plugins:{code:nn,mermaid:aI,math:nO,cjk:eg},linkSafety:{enabled:!0,renderModal:aW},...r,children:t})}));pH.displayName="Reasoning",pX.displayName="ReasoningTrigger",pY.displayName="ReasoningContent";var pJ=/[\\\/_+.#"@\[\(\{&]/,pZ=/[\\\/_+.#"@\[\(\{&]/g,pQ=/[\s-]/,p0=/[\s-]/g;function p1(e){return e.toLowerCase().replace(p0," ")}var p2=e.i(7631),p5=e.i(408744),p3='[cmdk-group=""]',p6='[cmdk-group-items=""]',p4='[cmdk-item=""]',p8=`${p4}:not([aria-disabled="true"])`,p9="cmdk-item-select",p7="data-value",me=(e,t,r)=>{var n;return n=e,function e(t,r,n,s,i,a,o){if(a===r.length)return i===t.length?1:.99;var l=`${i},${a}`;if(void 0!==o[l])return o[l];for(var c,u,d,h,p=s.charAt(a),m=n.indexOf(p,i),f=0;m>=0;)(c=e(t,r,n,s,m+1,a+1,o))>f&&(m===i?c*=1:pJ.test(t.charAt(m-1))?(c*=.8,(d=t.slice(i,m-1).match(pZ))&&i>0&&(c*=Math.pow(.999,d.length))):pQ.test(t.charAt(m-1))?(c*=.9,(h=t.slice(i,m-1).match(p0))&&i>0&&(c*=Math.pow(.999,h.length))):(c*=.17,i>0&&(c*=Math.pow(.999,m-i))),t.charAt(m)!==r.charAt(a)&&(c*=.9999)),(c<.1&&n.charAt(m-1)===s.charAt(a+1)||s.charAt(a+1)===s.charAt(a)&&n.charAt(m-1)!==s.charAt(a))&&.1*(u=e(t,r,n,s,m+1,a+2,o))>c&&(c=.1*u),c>f&&(f=c),m=n.indexOf(p,m+1);return o[l]=f,f}(n=r&&r.length>0?`${n+" "+r.join(" ")}`:n,t,p1(n),p1(t),0,0,{})},mt=b.createContext(void 0),mr=b.createContext(void 0),mn=b.createContext(void 0),ms=b.forwardRef((e,t)=>{let r=mm(()=>{var t,r;return{search:"",value:null!=(r=null!=(t=e.value)?t:e.defaultValue)?r:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=mm(()=>new Set),s=mm(()=>new Map),i=mm(()=>new Map),a=mm(()=>new Set),o=mh(e),{label:l,children:c,value:u,onValueChange:d,filter:h,shouldFilter:p,loop:m,disablePointerSelection:f=!1,vimBindings:g=!0,...x}=e,y=(0,a1.useId)(),v=(0,a1.useId)(),w=(0,a1.useId)(),k=b.useRef(null),j=mx();mp(()=>{if(void 0!==u){let e=u.trim();r.current.value=e,N.emit()}},[u]),mp(()=>{j(6,E)},[]);let N=b.useMemo(()=>({subscribe:e=>(a.current.add(e),()=>a.current.delete(e)),snapshot:()=>r.current,setState:(e,t,n)=>{var s,i,a,l;if(!Object.is(r.current[e],t)){if(r.current[e]=t,"search"===e)T(),A(),j(1,_);else if("value"===e){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let e=document.getElementById(w);e?e.focus():null==(s=document.getElementById(y))||s.focus()}if(j(7,()=>{var e;r.current.selectedItemId=null==(e=P())?void 0:e.id,N.emit()}),n||j(5,E),(null==(i=o.current)?void 0:i.value)!==void 0){null==(l=(a=o.current).onValueChange)||l.call(a,null!=t?t:"");return}}N.emit()}},emit:()=>{a.current.forEach(e=>e())}}),[]),S=b.useMemo(()=>({value:(e,t,n)=>{var s;t!==(null==(s=i.current.get(e))?void 0:s.value)&&(i.current.set(e,{value:t,keywords:n}),r.current.filtered.items.set(e,C(t,n)),j(2,()=>{A(),N.emit()}))},item:(e,t)=>(n.current.add(e),t&&(s.current.has(t)?s.current.get(t).add(e):s.current.set(t,new Set([e]))),j(3,()=>{T(),A(),r.current.value||_(),N.emit()}),()=>{i.current.delete(e),n.current.delete(e),r.current.filtered.items.delete(e);let t=P();j(4,()=>{T(),(null==t?void 0:t.getAttribute("id"))===e&&_(),N.emit()})}),group:e=>(s.current.has(e)||s.current.set(e,new Set),()=>{i.current.delete(e),s.current.delete(e)}),filter:()=>o.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>o.current.disablePointerSelection,listId:y,inputId:w,labelId:v,listInnerRef:k}),[]);function C(e,t){var n,s;let i=null!=(s=null==(n=o.current)?void 0:n.filter)?s:me;return e?i(e,r.current.search,t):0}function A(){if(!r.current.search||!1===o.current.shouldFilter)return;let e=r.current.filtered.items,t=[];r.current.filtered.groups.forEach(r=>{let n=s.current.get(r),i=0;n.forEach(t=>{i=Math.max(e.get(t),i)}),t.push([r,i])});let n=k.current;R().sort((t,r)=>{var n,s;let i=t.getAttribute("id"),a=r.getAttribute("id");return(null!=(n=e.get(a))?n:0)-(null!=(s=e.get(i))?s:0)}).forEach(e=>{let t=e.closest(p6);t?t.appendChild(e.parentElement===t?e:e.closest(`${p6} > *`)):n.appendChild(e.parentElement===n?e:e.closest(`${p6} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{var t;let r=null==(t=k.current)?void 0:t.querySelector(`${p3}[${p7}="${encodeURIComponent(e[0])}"]`);null==r||r.parentElement.appendChild(r)})}function _(){let e=R().find(e=>"true"!==e.getAttribute("aria-disabled")),t=null==e?void 0:e.getAttribute(p7);N.setState("value",t||void 0)}function T(){var e,t,a,l;if(!r.current.search||!1===o.current.shouldFilter){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let c=0;for(let s of n.current){let n=C(null!=(t=null==(e=i.current.get(s))?void 0:e.value)?t:"",null!=(l=null==(a=i.current.get(s))?void 0:a.keywords)?l:[]);r.current.filtered.items.set(s,n),n>0&&c++}for(let[e,t]of s.current)for(let n of t)if(r.current.filtered.items.get(n)>0){r.current.filtered.groups.add(e);break}r.current.filtered.count=c}function E(){var e,t,r;let n=P();n&&((null==(e=n.parentElement)?void 0:e.firstChild)===n&&(null==(r=null==(t=n.closest(p3))?void 0:t.querySelector('[cmdk-group-heading=""]'))||r.scrollIntoView({block:"nearest"})),n.scrollIntoView({block:"nearest"}))}function P(){var e;return null==(e=k.current)?void 0:e.querySelector(`${p4}[aria-selected="true"]`)}function R(){var e;return Array.from((null==(e=k.current)?void 0:e.querySelectorAll(p8))||[])}function M(e){let t=R()[e];t&&N.setState("value",t.getAttribute(p7))}function I(e){var t;let r=P(),n=R(),s=n.findIndex(e=>e===r),i=n[s+e];null!=(t=o.current)&&t.loop&&(i=s+e<0?n[n.length-1]:s+e===n.length?n[0]:n[s+e]),i&&N.setState("value",i.getAttribute(p7))}function L(e){let t=P(),r=null==t?void 0:t.closest(p3),n;for(;r&&!n;)n=null==(r=e>0?function(e,t){let r=e.nextElementSibling;for(;r;){if(r.matches(t))return r;r=r.nextElementSibling}}(r,p3):function(e,t){let r=e.previousElementSibling;for(;r;){if(r.matches(t))return r;r=r.previousElementSibling}}(r,p3))?void 0:r.querySelector(p8);n?N.setState("value",n.getAttribute(p7)):I(e)}let D=()=>M(R().length-1),O=e=>{e.preventDefault(),e.metaKey?D():e.altKey?L(1):I(1)},z=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?L(-1):I(-1)};return b.createElement(p5.Primitive.div,{ref:t,tabIndex:-1,...x,"cmdk-root":"",onKeyDown:e=>{var t;null==(t=x.onKeyDown)||t.call(x,e);let r=e.nativeEvent.isComposing||229===e.keyCode;if(!(e.defaultPrevented||r))switch(e.key){case"n":case"j":g&&e.ctrlKey&&O(e);break;case"ArrowDown":O(e);break;case"p":case"k":g&&e.ctrlKey&&z(e);break;case"ArrowUp":z(e);break;case"Home":e.preventDefault(),M(0);break;case"End":e.preventDefault(),D();break;case"Enter":{e.preventDefault();let t=P();if(t){let e=new Event(p9);t.dispatchEvent(e)}}}}},b.createElement("label",{"cmdk-label":"",htmlFor:S.inputId,id:S.labelId,style:mv},l),my(e,e=>b.createElement(mr.Provider,{value:N},b.createElement(mt.Provider,{value:S},e))))}),mi=b.forwardRef((e,t)=>{var r,n;let s=(0,a1.useId)(),i=b.useRef(null),a=b.useContext(mn),o=b.useContext(mt),l=mh(e),c=null!=(n=null==(r=l.current)?void 0:r.forceMount)?n:null==a?void 0:a.forceMount;mp(()=>{if(!c)return o.item(s,null==a?void 0:a.id)},[c]);let u=mg(s,i,[e.value,e.children,i],e.keywords),d=b.useContext(mr),h=mf(e=>e.value&&e.value===u.current),p=mf(e=>!!c||!1===o.filter()||!e.search||e.filtered.items.get(s)>0);function m(){var e,t;f(),null==(t=(e=l.current).onSelect)||t.call(e,u.current)}function f(){d.setState("value",u.current,!0)}if(b.useEffect(()=>{let t=i.current;if(!(!t||e.disabled))return t.addEventListener(p9,m),()=>t.removeEventListener(p9,m)},[p,e.onSelect,e.disabled]),!p)return null;let{disabled:g,value:x,onSelect:y,forceMount:v,keywords:w,...k}=e;return b.createElement(p5.Primitive.div,{ref:(0,aY.composeRefs)(i,t),...k,id:s,"cmdk-item":"",role:"option","aria-disabled":!!g,"aria-selected":!!h,"data-disabled":!!g,"data-selected":!!h,onPointerMove:g||o.getDisablePointerSelection()?void 0:f,onClick:g?void 0:m},e.children)}),ma=b.forwardRef((e,t)=>{let{heading:r,children:n,forceMount:s,...i}=e,a=(0,a1.useId)(),o=b.useRef(null),l=b.useRef(null),c=(0,a1.useId)(),u=b.useContext(mt),d=mf(e=>!!s||!1===u.filter()||!e.search||e.filtered.groups.has(a));mp(()=>u.group(a),[]),mg(a,o,[e.value,e.heading,l]);let h=b.useMemo(()=>({id:a,forceMount:s}),[s]);return b.createElement(p5.Primitive.div,{ref:(0,aY.composeRefs)(o,t),...i,"cmdk-group":"",role:"presentation",hidden:!d||void 0},r&&b.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},r),my(e,e=>b.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?c:void 0},b.createElement(mn.Provider,{value:h},e))))}),mo=b.forwardRef((e,t)=>{let{alwaysRender:r,...n}=e,s=b.useRef(null),i=mf(e=>!e.search);return r||i?b.createElement(p5.Primitive.div,{ref:(0,aY.composeRefs)(s,t),...n,"cmdk-separator":"",role:"separator"}):null}),ml=b.forwardRef((e,t)=>{let{onValueChange:r,...n}=e,s=null!=e.value,i=b.useContext(mr),a=mf(e=>e.search),o=mf(e=>e.selectedItemId),l=b.useContext(mt);return b.useEffect(()=>{null!=e.value&&i.setState("search",e.value)},[e.value]),b.createElement(p5.Primitive.input,{ref:t,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":o,id:l.inputId,type:"text",value:s?e.value:a,onChange:e=>{s||i.setState("search",e.target.value),null==r||r(e.target.value)}})}),mc=b.forwardRef((e,t)=>{let{children:r,label:n="Suggestions",...s}=e,i=b.useRef(null),a=b.useRef(null),o=mf(e=>e.selectedItemId),l=b.useContext(mt);return b.useEffect(()=>{if(a.current&&i.current){let e=a.current,t=i.current,r,n=new ResizeObserver(()=>{r=requestAnimationFrame(()=>{let r=e.offsetHeight;t.style.setProperty("--cmdk-list-height",r.toFixed(1)+"px")})});return n.observe(e),()=>{cancelAnimationFrame(r),n.unobserve(e)}}},[]),b.createElement(p5.Primitive.div,{ref:(0,aY.composeRefs)(i,t),...s,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":o,"aria-label":n,id:l.listId},my(e,e=>b.createElement("div",{ref:(0,aY.composeRefs)(a,l.listInnerRef),"cmdk-list-sizer":""},e)))}),mu=b.forwardRef((e,t)=>{let{open:r,onOpenChange:n,overlayClassName:s,contentClassName:i,container:a,...o}=e;return b.createElement(p2.Root,{open:r,onOpenChange:n},b.createElement(p2.Portal,{container:a},b.createElement(p2.Overlay,{"cmdk-overlay":"",className:s}),b.createElement(p2.Content,{"aria-label":e.label,"cmdk-dialog":"",className:i},b.createElement(ms,{ref:t,...o}))))}),md=Object.assign(ms,{List:mc,Item:mi,Input:ml,Group:ma,Separator:mo,Dialog:mu,Empty:b.forwardRef((e,t)=>mf(e=>0===e.filtered.count)?b.createElement(p5.Primitive.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Loading:b.forwardRef((e,t)=>{let{progress:r,children:n,label:s="Loading...",...i}=e;return b.createElement(p5.Primitive.div,{ref:t,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s},my(e,e=>b.createElement("div",{"aria-hidden":!0},e)))})});function mh(e){let t=b.useRef(e);return mp(()=>{t.current=e}),t}var mp="u"<typeof window?b.useEffect:b.useLayoutEffect;function mm(e){let t=b.useRef();return void 0===t.current&&(t.current=e()),t}function mf(e){let t=b.useContext(mr),r=()=>e(t.snapshot());return b.useSyncExternalStore(t.subscribe,r,r)}function mg(e,t,r,n=[]){let s=b.useRef(),i=b.useContext(mt);return mp(()=>{var a;let o=(()=>{var e;for(let t of r){if("string"==typeof t)return t.trim();if("object"==typeof t&&"current"in t)return t.current?null==(e=t.current.textContent)?void 0:e.trim():s.current}})(),l=n.map(e=>e.trim());i.value(e,o,l),null==(a=t.current)||a.setAttribute(p7,o),s.current=o}),s}var mx=()=>{let[e,t]=b.useState(),r=mm(()=>new Map);return mp(()=>{r.current.forEach(e=>e()),r.current=new Map},[e]),(e,n)=>{r.current.set(e,n),t({})}};function my({asChild:e,children:t},r){let n;return e&&b.isValidElement(t)?b.cloneElement("function"==typeof(n=t.type)?n(t.props):"render"in n?n.render(t.props):t,{ref:t.ref},r(t.props.children)):r(t)}var mv={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};let mb=(0,T.default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);var mw=e.i(836191);function mk({className:e,...t}){return(0,v.jsx)(md,{"data-slot":"command",className:(0,k.cn)("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...t})}function mj({className:e,...t}){return(0,v.jsx)(md.List,{"data-slot":"command-list",className:(0,k.cn)("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...t})}function mN({...e}){return(0,v.jsx)(md.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function mS({className:e,...t}){return(0,v.jsx)(md.Group,{"data-slot":"command-group",className:(0,k.cn)("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...t})}function mC({className:e,...t}){return(0,v.jsx)(md.Item,{"data-slot":"command-item",className:(0,k.cn)("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}var mA=Symbol("radix.slottable");function m_(e){return b.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===mA}var mT=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{var r,n;let s,i,a,o=(n=r=`Primitive.${t}`,(s=b.forwardRef((e,t)=>{let{children:r,...n}=e;if(b.isValidElement(r)){var s;let e,i,a=(s=r,(i=(e=Object.getOwnPropertyDescriptor(s.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.ref:(i=(e=Object.getOwnPropertyDescriptor(s,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.props.ref:s.props.ref||s.ref),o=function(e,t){let r={...t};for(let n in t){let s=e[n],i=t[n];/^on[A-Z]/.test(n)?s&&i?r[n]=(...e)=>{let t=i(...e);return s(...e),t}:s&&(r[n]=s):"style"===n?r[n]={...s,...i}:"className"===n&&(r[n]=[s,i].filter(Boolean).join(" "))}return{...e,...r}}(n,r.props);return r.type!==b.Fragment&&(o.ref=t?(0,aY.composeRefs)(t,a):a),b.cloneElement(r,o)}return b.Children.count(r)>1?b.Children.only(null):null})).displayName=`${n}.SlotClone`,i=s,(a=b.forwardRef((e,t)=>{let{children:r,...n}=e,s=b.Children.toArray(r),a=s.find(m_);if(a){let e=a.props.children,r=s.map(t=>t!==a?t:b.Children.count(e)>1?b.Children.only(null):b.isValidElement(e)?e.props.children:null);return(0,v.jsx)(i,{...n,ref:t,children:b.isValidElement(e)?b.cloneElement(e,void 0,r):null})}return(0,v.jsx)(i,{...n,ref:t,children:r})})).displayName=`${r}.Slot`,a),l=b.forwardRef((e,r)=>{let{asChild:n,...s}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,v.jsx)(n?o:t,{...s,ref:r})});return l.displayName=`Primitive.${t}`,{...e,[t]:l}},{}),mE=e.i(736180),mP=e.i(542899),mR=e.i(272741),mM=e.i(721648),mI=e.i(498101),mL=e.i(874057),mD=e.i(383044);function mO(e){var t;let r,n=(t=e,(r=b.forwardRef((e,t)=>{let{children:r,...n}=e;if(b.isValidElement(r)){var s;let e,i,a=(s=r,(i=(e=Object.getOwnPropertyDescriptor(s.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.ref:(i=(e=Object.getOwnPropertyDescriptor(s,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.props.ref:s.props.ref||s.ref),o=function(e,t){let r={...t};for(let n in t){let s=e[n],i=t[n];/^on[A-Z]/.test(n)?s&&i?r[n]=(...e)=>{let t=i(...e);return s(...e),t}:s&&(r[n]=s):"style"===n?r[n]={...s,...i}:"className"===n&&(r[n]=[s,i].filter(Boolean).join(" "))}return{...e,...r}}(n,r.props);return r.type!==b.Fragment&&(o.ref=t?(0,aY.composeRefs)(t,a):a),b.cloneElement(r,o)}return b.Children.count(r)>1?b.Children.only(null):null})).displayName=`${t}.SlotClone`,r),s=b.forwardRef((e,t)=>{let{children:r,...s}=e,i=b.Children.toArray(r),a=i.find(mF);if(a){let e=a.props.children,r=i.map(t=>t!==a?t:b.Children.count(e)>1?b.Children.only(null):b.isValidElement(e)?e.props.children:null);return(0,v.jsx)(n,{...s,ref:t,children:b.isValidElement(e)?b.cloneElement(e,void 0,r):null})}return(0,v.jsx)(n,{...s,ref:t,children:r})});return s.displayName=`${e}.Slot`,s}var mz=Symbol("radix.slottable");function mF(e){return b.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===mz}var mB=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let r=mO(`Primitive.${t}`),n=b.forwardRef((e,n)=>{let{asChild:s,...i}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,v.jsx)(s?r:t,{...i,ref:n})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),m$=Symbol("radix.slottable");function mV(e){return b.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===m$}var mU=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{var r,n;let s,i,a,o=(n=r=`Primitive.${t}`,(s=b.forwardRef((e,t)=>{let{children:r,...n}=e;if(b.isValidElement(r)){var s;let e,i,a=(s=r,(i=(e=Object.getOwnPropertyDescriptor(s.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.ref:(i=(e=Object.getOwnPropertyDescriptor(s,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.props.ref:s.props.ref||s.ref),o=function(e,t){let r={...t};for(let n in t){let s=e[n],i=t[n];/^on[A-Z]/.test(n)?s&&i?r[n]=(...e)=>{let t=i(...e);return s(...e),t}:s&&(r[n]=s):"style"===n?r[n]={...s,...i}:"className"===n&&(r[n]=[s,i].filter(Boolean).join(" "))}return{...e,...r}}(n,r.props);return r.type!==b.Fragment&&(o.ref=t?(0,aY.composeRefs)(t,a):a),b.cloneElement(r,o)}return b.Children.count(r)>1?b.Children.only(null):null})).displayName=`${n}.SlotClone`,i=s,(a=b.forwardRef((e,t)=>{let{children:r,...n}=e,s=b.Children.toArray(r),a=s.find(mV);if(a){let e=a.props.children,r=s.map(t=>t!==a?t:b.Children.count(e)>1?b.Children.only(null):b.isValidElement(e)?e.props.children:null);return(0,v.jsx)(i,{...n,ref:t,children:b.isValidElement(e)?b.cloneElement(e,void 0,r):null})}return(0,v.jsx)(i,{...n,ref:t,children:r})})).displayName=`${r}.Slot`,a),l=b.forwardRef((e,r)=>{let{asChild:n,...s}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,v.jsx)(n?o:t,{...s,ref:r})});return l.displayName=`Primitive.${t}`,{...e,[t]:l}},{}),mG=e.i(897462),mW="rovingFocusGroup.onEntryFocus",mq={bubbles:!1,cancelable:!0},mH="RovingFocusGroup",[mK,mX,mY]=(0,mE.createCollection)(mH),[mJ,mZ]=function(e,t=[]){let r=[],n=()=>{let t=r.map(e=>b.createContext(e));return function(r){let n=r?.[e]||t;return b.useMemo(()=>({[`__scope${e}`]:{...r,[e]:n}}),[r,n])}};return n.scopeName=e,[function(t,n){let s=b.createContext(n),i=r.length;r=[...r,n];let a=t=>{let{scope:r,children:n,...a}=t,o=r?.[e]?.[i]||s,l=b.useMemo(()=>a,Object.values(a));return(0,v.jsx)(o.Provider,{value:l,children:n})};return a.displayName=t+"Provider",[a,function(r,a){let o=a?.[e]?.[i]||s,l=b.useContext(o);if(l)return l;if(void 0!==n)return n;throw Error(`\`${r}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let r=()=>{let r=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let n=r.reduce((t,{useScope:r,scopeName:n})=>{let s=r(e)[`__scope${n}`];return{...t,...s}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:n}),[n])}};return r.scopeName=t.scopeName,r}(n,...t)]}(mH,[mY]),[mQ,m0]=mJ(mH),m1=b.forwardRef((e,t)=>(0,v.jsx)(mK.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,v.jsx)(mK.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,v.jsx)(m2,{...e,ref:t})})}));m1.displayName=mH;var m2=b.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:r,orientation:n,loop:s=!1,dir:i,currentTabStopId:a,defaultCurrentTabStopId:o,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...d}=e,h=b.useRef(null),p=(0,aY.useComposedRefs)(t,h),m=(0,mP.useDirection)(i),[f,g]=(0,aK.useControllableState)({prop:a,defaultProp:o??null,onChange:l,caller:mH}),[x,y]=b.useState(!1),w=(0,mG.useCallbackRef)(c),k=mX(r),j=b.useRef(!1),[N,S]=b.useState(0);return b.useEffect(()=>{let e=h.current;if(e)return e.addEventListener(mW,w),()=>e.removeEventListener(mW,w)},[w]),(0,v.jsx)(mQ,{scope:r,orientation:n,dir:m,loop:s,currentTabStopId:f,onItemFocus:b.useCallback(e=>g(e),[g]),onItemShiftTab:b.useCallback(()=>y(!0),[]),onFocusableItemAdd:b.useCallback(()=>S(e=>e+1),[]),onFocusableItemRemove:b.useCallback(()=>S(e=>e-1),[]),children:(0,v.jsx)(mU.div,{tabIndex:x||0===N?-1:0,"data-orientation":n,...d,ref:p,style:{outline:"none",...e.style},onMouseDown:(0,aH.composeEventHandlers)(e.onMouseDown,()=>{j.current=!0}),onFocus:(0,aH.composeEventHandlers)(e.onFocus,e=>{let t=!j.current;if(e.target===e.currentTarget&&t&&!x){let t=new CustomEvent(mW,mq);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=k().filter(e=>e.focusable);m4([e.find(e=>e.active),e.find(e=>e.id===f),...e].filter(Boolean).map(e=>e.ref.current),u)}}j.current=!1}),onBlur:(0,aH.composeEventHandlers)(e.onBlur,()=>y(!1))})})}),m5="RovingFocusGroupItem",m3=b.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:r,focusable:n=!0,active:s=!1,tabStopId:i,children:a,...o}=e,l=(0,a1.useId)(),c=i||l,u=m0(m5,r),d=u.currentTabStopId===c,h=mX(r),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:f}=u;return b.useEffect(()=>{if(n)return p(),()=>m()},[n,p,m]),(0,v.jsx)(mK.ItemSlot,{scope:r,id:c,focusable:n,active:s,children:(0,v.jsx)(mU.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...o,ref:t,onMouseDown:(0,aH.composeEventHandlers)(e.onMouseDown,e=>{n?u.onItemFocus(c):e.preventDefault()}),onFocus:(0,aH.composeEventHandlers)(e.onFocus,()=>u.onItemFocus(c)),onKeyDown:(0,aH.composeEventHandlers)(e.onKeyDown,e=>{if("Tab"===e.key&&e.shiftKey)return void u.onItemShiftTab();if(e.target!==e.currentTarget)return;let t=function(e,t,r){var n;let s=(n=e.key,"rtl"!==r?n:"ArrowLeft"===n?"ArrowRight":"ArrowRight"===n?"ArrowLeft":n);if(!("vertical"===t&&["ArrowLeft","ArrowRight"].includes(s))&&!("horizontal"===t&&["ArrowUp","ArrowDown"].includes(s)))return m6[s]}(e,u.orientation,u.dir);if(void 0!==t){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let s=h().filter(e=>e.focusable).map(e=>e.ref.current);if("last"===t)s.reverse();else if("prev"===t||"next"===t){var r,n;"prev"===t&&s.reverse();let i=s.indexOf(e.currentTarget);s=u.loop?(r=s,n=i+1,r.map((e,t)=>r[(n+t)%r.length])):s.slice(i+1)}setTimeout(()=>m4(s))}}),children:"function"==typeof a?a({isCurrentTabStop:d,hasTabStop:null!=f}):a})})});m3.displayName=m5;var m6={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function m4(e,t=!1){let r=document.activeElement;for(let n of e)if(n===r||(n.focus({preventScroll:t}),document.activeElement!==r))return}var m8=e.i(567706),m9=e.i(883944),m7=["Enter"," "],fe=["ArrowUp","PageDown","End"],ft=["ArrowDown","PageUp","Home",...fe],fr={ltr:[...m7,"ArrowRight"],rtl:[...m7,"ArrowLeft"]},fn={ltr:["ArrowLeft"],rtl:["ArrowRight"]},fs="Menu",[fi,fa,fo]=(0,mE.createCollection)(fs),[fl,fc]=function(e,t=[]){let r=[],n=()=>{let t=r.map(e=>b.createContext(e));return function(r){let n=r?.[e]||t;return b.useMemo(()=>({[`__scope${e}`]:{...r,[e]:n}}),[r,n])}};return n.scopeName=e,[function(t,n){let s=b.createContext(n),i=r.length;r=[...r,n];let a=t=>{let{scope:r,children:n,...a}=t,o=r?.[e]?.[i]||s,l=b.useMemo(()=>a,Object.values(a));return(0,v.jsx)(o.Provider,{value:l,children:n})};return a.displayName=t+"Provider",[a,function(r,a){let o=a?.[e]?.[i]||s,l=b.useContext(o);if(l)return l;if(void 0!==n)return n;throw Error(`\`${r}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let r=()=>{let r=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let n=r.reduce((t,{useScope:r,scopeName:n})=>{let s=r(e)[`__scope${n}`];return{...t,...s}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:n}),[n])}};return r.scopeName=t.scopeName,r}(n,...t)]}(fs,[fo,mL.createPopperScope,mZ]),fu=(0,mL.createPopperScope)(),fd=mZ(),[fh,fp]=fl(fs),[fm,ff]=fl(fs),fg=b.forwardRef((e,t)=>{let{__scopeMenu:r,...n}=e,s=fu(r);return(0,v.jsx)(mL.Anchor,{...s,...n,ref:t})});fg.displayName="MenuAnchor";var fx="MenuPortal",[fy,fv]=fl(fx,{forceMount:void 0}),fb="MenuContent",[fw,fk]=fl(fb),fj=b.forwardRef((e,t)=>{let r=fv(fb,e.__scopeMenu),{forceMount:n=r.forceMount,...s}=e,i=fp(fb,e.__scopeMenu),a=ff(fb,e.__scopeMenu);return(0,v.jsx)(fi.Provider,{scope:e.__scopeMenu,children:(0,v.jsx)(a0.Presence,{present:n||i.open,children:(0,v.jsx)(fi.Slot,{scope:e.__scopeMenu,children:a.modal?(0,v.jsx)(fN,{...s,ref:t}):(0,v.jsx)(fS,{...s,ref:t})})})})}),fN=b.forwardRef((e,t)=>{let r=fp(fb,e.__scopeMenu),n=b.useRef(null),s=(0,aY.useComposedRefs)(t,n);return b.useEffect(()=>{let e=n.current;if(e)return(0,m8.hideOthers)(e)},[]),(0,v.jsx)(fA,{...e,ref:s,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:(0,aH.composeEventHandlers)(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),fS=b.forwardRef((e,t)=>{let r=fp(fb,e.__scopeMenu);return(0,v.jsx)(fA,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),fC=mO("MenuContent.ScrollLock"),fA=b.forwardRef((e,t)=>{let{__scopeMenu:r,loop:n=!1,trapFocus:s,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:p,disableOutsideScroll:m,...f}=e,g=fp(fb,r),x=ff(fb,r),y=fu(r),w=fd(r),k=fa(r),[j,N]=b.useState(null),S=b.useRef(null),C=(0,aY.useComposedRefs)(t,S,g.onContentChange),A=b.useRef(0),_=b.useRef(""),T=b.useRef(0),E=b.useRef(null),P=b.useRef("right"),R=b.useRef(0),M=m?m9.RemoveScroll:b.Fragment;b.useEffect(()=>()=>window.clearTimeout(A.current),[]),(0,mM.useFocusGuards)();let I=b.useCallback(e=>{var t,r;return P.current===E.current?.side&&(t=e,!!(r=E.current?.area)&&function(e,t){let{x:r,y:n}=e,s=!1;for(let e=0,i=t.length-1;e<t.length;i=e++){let a=t[e],o=t[i],l=a.x,c=a.y,u=o.x,d=o.y;c>n!=d>n&&r<(u-l)*(n-c)/(d-c)+l&&(s=!s)}return s}({x:t.clientX,y:t.clientY},r))},[]);return(0,v.jsx)(fw,{scope:r,searchRef:_,onItemEnter:b.useCallback(e=>{I(e)&&e.preventDefault()},[I]),onItemLeave:b.useCallback(e=>{I(e)||(S.current?.focus(),N(null))},[I]),onTriggerLeave:b.useCallback(e=>{I(e)&&e.preventDefault()},[I]),pointerGraceTimerRef:T,onPointerGraceIntentChange:b.useCallback(e=>{E.current=e},[]),children:(0,v.jsx)(M,{...m?{as:fC,allowPinchZoom:!0}:void 0,children:(0,v.jsx)(mI.FocusScope,{asChild:!0,trapped:s,onMountAutoFocus:(0,aH.composeEventHandlers)(i,e=>{e.preventDefault(),S.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:(0,v.jsx)(mR.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:o,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:p,children:(0,v.jsx)(m1,{asChild:!0,...w,dir:x.dir,orientation:"vertical",loop:n,currentTabStopId:j,onCurrentTabStopIdChange:N,onEntryFocus:(0,aH.composeEventHandlers)(l,e=>{x.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,v.jsx)(mL.Content,{role:"menu","aria-orientation":"vertical","data-state":fQ(g.open),"data-radix-menu-content":"",dir:x.dir,...y,...f,ref:C,style:{outline:"none",...f.style},onKeyDown:(0,aH.composeEventHandlers)(f.onKeyDown,e=>{let t=e.target.closest("[data-radix-menu-content]")===e.currentTarget,r=e.ctrlKey||e.altKey||e.metaKey,n=1===e.key.length;if(t){var s;let t,i,a,o,l,c;"Tab"===e.key&&e.preventDefault(),!r&&n&&(s=e.key,t=_.current+s,i=k().filter(e=>!e.disabled),a=document.activeElement,o=i.find(e=>e.ref.current===a)?.textValue,l=function(e,t,r){var n;let s=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=r?e.indexOf(r):-1,a=(n=Math.max(i,0),e.map((t,r)=>e[(n+r)%e.length]));1===s.length&&(a=a.filter(e=>e!==r));let o=a.find(e=>e.toLowerCase().startsWith(s.toLowerCase()));return o!==r?o:void 0}(i.map(e=>e.textValue),t,o),c=i.find(e=>e.textValue===l)?.ref.current,function e(t){_.current=t,window.clearTimeout(A.current),""!==t&&(A.current=window.setTimeout(()=>e(""),1e3))}(t),c&&setTimeout(()=>c.focus()))}let i=S.current;if(e.target!==i||!ft.includes(e.key))return;e.preventDefault();let a=k().filter(e=>!e.disabled).map(e=>e.ref.current);fe.includes(e.key)&&a.reverse(),function(e){let t=document.activeElement;for(let r of e)if(r===t||(r.focus(),document.activeElement!==t))return}(a)}),onBlur:(0,aH.composeEventHandlers)(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(A.current),_.current="")}),onPointerMove:(0,aH.composeEventHandlers)(e.onPointerMove,f2(e=>{let t=e.target,r=R.current!==e.clientX;e.currentTarget.contains(t)&&r&&(P.current=e.clientX>R.current?"right":"left",R.current=e.clientX)}))})})})})})})});fj.displayName=fb;var f_=b.forwardRef((e,t)=>{let{__scopeMenu:r,...n}=e;return(0,v.jsx)(mB.div,{role:"group",...n,ref:t})});f_.displayName="MenuGroup";var fT=b.forwardRef((e,t)=>{let{__scopeMenu:r,...n}=e;return(0,v.jsx)(mB.div,{...n,ref:t})});fT.displayName="MenuLabel";var fE="MenuItem",fP="menu.itemSelect",fR=b.forwardRef((e,t)=>{let{disabled:r=!1,onSelect:n,...s}=e,i=b.useRef(null),a=ff(fE,e.__scopeMenu),o=fk(fE,e.__scopeMenu),l=(0,aY.useComposedRefs)(t,i),c=b.useRef(!1);return(0,v.jsx)(fM,{...s,ref:l,disabled:r,onClick:(0,aH.composeEventHandlers)(e.onClick,()=>{let e=i.current;if(!r&&e){let t=new CustomEvent(fP,{bubbles:!0,cancelable:!0});e.addEventListener(fP,e=>n?.(e),{once:!0}),e&&az.flushSync(()=>e.dispatchEvent(t)),t.defaultPrevented?c.current=!1:a.onClose()}}),onPointerDown:t=>{e.onPointerDown?.(t),c.current=!0},onPointerUp:(0,aH.composeEventHandlers)(e.onPointerUp,e=>{c.current||e.currentTarget?.click()}),onKeyDown:(0,aH.composeEventHandlers)(e.onKeyDown,e=>{let t=""!==o.searchRef.current;r||t&&" "===e.key||m7.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});fR.displayName=fE;var fM=b.forwardRef((e,t)=>{let{__scopeMenu:r,disabled:n=!1,textValue:s,...i}=e,a=fk(fE,r),o=fd(r),l=b.useRef(null),c=(0,aY.useComposedRefs)(t,l),[u,d]=b.useState(!1),[h,p]=b.useState("");return b.useEffect(()=>{let e=l.current;e&&p((e.textContent??"").trim())},[i.children]),(0,v.jsx)(fi.ItemSlot,{scope:r,disabled:n,textValue:s??h,children:(0,v.jsx)(m3,{asChild:!0,...o,focusable:!n,children:(0,v.jsx)(mB.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...i,ref:c,onPointerMove:(0,aH.composeEventHandlers)(e.onPointerMove,f2(e=>{n?a.onItemLeave(e):(a.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:(0,aH.composeEventHandlers)(e.onPointerLeave,f2(e=>a.onItemLeave(e))),onFocus:(0,aH.composeEventHandlers)(e.onFocus,()=>d(!0)),onBlur:(0,aH.composeEventHandlers)(e.onBlur,()=>d(!1))})})})}),fI=b.forwardRef((e,t)=>{let{checked:r=!1,onCheckedChange:n,...s}=e;return(0,v.jsx)(fV,{scope:e.__scopeMenu,checked:r,children:(0,v.jsx)(fR,{role:"menuitemcheckbox","aria-checked":f0(r)?"mixed":r,...s,ref:t,"data-state":f1(r),onSelect:(0,aH.composeEventHandlers)(s.onSelect,()=>n?.(!!f0(r)||!r),{checkForDefaultPrevented:!1})})})});fI.displayName="MenuCheckboxItem";var fL="MenuRadioGroup",[fD,fO]=fl(fL,{value:void 0,onValueChange:()=>{}}),fz=b.forwardRef((e,t)=>{let{value:r,onValueChange:n,...s}=e,i=(0,mG.useCallbackRef)(n);return(0,v.jsx)(fD,{scope:e.__scopeMenu,value:r,onValueChange:i,children:(0,v.jsx)(f_,{...s,ref:t})})});fz.displayName=fL;var fF="MenuRadioItem",fB=b.forwardRef((e,t)=>{let{value:r,...n}=e,s=fO(fF,e.__scopeMenu),i=r===s.value;return(0,v.jsx)(fV,{scope:e.__scopeMenu,checked:i,children:(0,v.jsx)(fR,{role:"menuitemradio","aria-checked":i,...n,ref:t,"data-state":f1(i),onSelect:(0,aH.composeEventHandlers)(n.onSelect,()=>s.onValueChange?.(r),{checkForDefaultPrevented:!1})})})});fB.displayName=fF;var f$="MenuItemIndicator",[fV,fU]=fl(f$,{checked:!1}),fG=b.forwardRef((e,t)=>{let{__scopeMenu:r,forceMount:n,...s}=e,i=fU(f$,r);return(0,v.jsx)(a0.Presence,{present:n||f0(i.checked)||!0===i.checked,children:(0,v.jsx)(mB.span,{...s,ref:t,"data-state":f1(i.checked)})})});fG.displayName=f$;var fW=b.forwardRef((e,t)=>{let{__scopeMenu:r,...n}=e;return(0,v.jsx)(mB.div,{role:"separator","aria-orientation":"horizontal",...n,ref:t})});fW.displayName="MenuSeparator";var fq=b.forwardRef((e,t)=>{let{__scopeMenu:r,...n}=e,s=fu(r);return(0,v.jsx)(mL.Arrow,{...s,...n,ref:t})});fq.displayName="MenuArrow";var[fH,fK]=fl("MenuSub"),fX="MenuSubTrigger",fY=b.forwardRef((e,t)=>{let r=fp(fX,e.__scopeMenu),n=ff(fX,e.__scopeMenu),s=fK(fX,e.__scopeMenu),i=fk(fX,e.__scopeMenu),a=b.useRef(null),{pointerGraceTimerRef:o,onPointerGraceIntentChange:l}=i,c={__scopeMenu:e.__scopeMenu},u=b.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return b.useEffect(()=>u,[u]),b.useEffect(()=>{let e=o.current;return()=>{window.clearTimeout(e),l(null)}},[o,l]),(0,v.jsx)(fg,{asChild:!0,...c,children:(0,v.jsx)(fM,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":s.contentId,"data-state":fQ(r.open),...e,ref:(0,aY.composeRefs)(t,s.onTriggerChange),onClick:t=>{e.onClick?.(t),e.disabled||t.defaultPrevented||(t.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:(0,aH.composeEventHandlers)(e.onPointerMove,f2(t=>{i.onItemEnter(t),!t.defaultPrevented&&(e.disabled||r.open||a.current||(i.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{r.onOpenChange(!0),u()},100)))})),onPointerLeave:(0,aH.composeEventHandlers)(e.onPointerLeave,f2(e=>{u();let t=r.content?.getBoundingClientRect();if(t){let n=r.content?.dataset.side,s="right"===n,a=t[s?"left":"right"],l=t[s?"right":"left"];i.onPointerGraceIntentChange({area:[{x:e.clientX+(s?-5:5),y:e.clientY},{x:a,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:a,y:t.bottom}],side:n}),window.clearTimeout(o.current),o.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(e),e.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:(0,aH.composeEventHandlers)(e.onKeyDown,t=>{let s=""!==i.searchRef.current;e.disabled||s&&" "===t.key||fr[n.dir].includes(t.key)&&(r.onOpenChange(!0),r.content?.focus(),t.preventDefault())})})})});fY.displayName=fX;var fJ="MenuSubContent",fZ=b.forwardRef((e,t)=>{let r=fv(fb,e.__scopeMenu),{forceMount:n=r.forceMount,...s}=e,i=fp(fb,e.__scopeMenu),a=ff(fb,e.__scopeMenu),o=fK(fJ,e.__scopeMenu),l=b.useRef(null),c=(0,aY.useComposedRefs)(t,l);return(0,v.jsx)(fi.Provider,{scope:e.__scopeMenu,children:(0,v.jsx)(a0.Presence,{present:n||i.open,children:(0,v.jsx)(fi.Slot,{scope:e.__scopeMenu,children:(0,v.jsx)(fA,{id:o.contentId,"aria-labelledby":o.triggerId,...s,ref:c,align:"start",side:"rtl"===a.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{a.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:(0,aH.composeEventHandlers)(e.onFocusOutside,e=>{e.target!==o.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:(0,aH.composeEventHandlers)(e.onEscapeKeyDown,e=>{a.onClose(),e.preventDefault()}),onKeyDown:(0,aH.composeEventHandlers)(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),r=fn[a.dir].includes(e.key);t&&r&&(i.onOpenChange(!1),o.trigger?.focus(),e.preventDefault())})})})})})});function fQ(e){return e?"open":"closed"}function f0(e){return"indeterminate"===e}function f1(e){return f0(e)?"indeterminate":e?"checked":"unchecked"}function f2(e){return t=>"mouse"===t.pointerType?e(t):void 0}fZ.displayName=fJ;var f5="DropdownMenu",[f3,f6]=function(e,t=[]){let r=[],n=()=>{let t=r.map(e=>b.createContext(e));return function(r){let n=r?.[e]||t;return b.useMemo(()=>({[`__scope${e}`]:{...r,[e]:n}}),[r,n])}};return n.scopeName=e,[function(t,n){let s=b.createContext(n),i=r.length;r=[...r,n];let a=t=>{let{scope:r,children:n,...a}=t,o=r?.[e]?.[i]||s,l=b.useMemo(()=>a,Object.values(a));return(0,v.jsx)(o.Provider,{value:l,children:n})};return a.displayName=t+"Provider",[a,function(r,a){let o=a?.[e]?.[i]||s,l=b.useContext(o);if(l)return l;if(void 0!==n)return n;throw Error(`\`${r}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let r=()=>{let r=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let n=r.reduce((t,{useScope:r,scopeName:n})=>{let s=r(e)[`__scope${n}`];return{...t,...s}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:n}),[n])}};return r.scopeName=t.scopeName,r}(n,...t)]}(f5,[fc]),f4=fc(),[f8,f9]=f3(f5),f7="DropdownMenuTrigger";b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,disabled:n=!1,...s}=e,i=f9(f7,r),a=f4(r);return(0,v.jsx)(fg,{asChild:!0,...a,children:(0,v.jsx)(mT.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":n?"":void 0,disabled:n,...s,ref:(0,aY.composeRefs)(t,i.triggerRef),onPointerDown:(0,aH.composeEventHandlers)(e.onPointerDown,e=>{!n&&0===e.button&&!1===e.ctrlKey&&(i.onOpenToggle(),i.open||e.preventDefault())}),onKeyDown:(0,aH.composeEventHandlers)(e.onKeyDown,e=>{!n&&(["Enter"," "].includes(e.key)&&i.onOpenToggle(),"ArrowDown"===e.key&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(e.key)&&e.preventDefault())})})})}).displayName=f7;var ge="DropdownMenuContent";b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f9(ge,r),i=f4(r),a=b.useRef(!1);return(0,v.jsx)(fj,{id:s.contentId,"aria-labelledby":s.triggerId,...i,...n,ref:t,onCloseAutoFocus:(0,aH.composeEventHandlers)(e.onCloseAutoFocus,e=>{a.current||s.triggerRef.current?.focus(),a.current=!1,e.preventDefault()}),onInteractOutside:(0,aH.composeEventHandlers)(e.onInteractOutside,e=>{let t=e.detail.originalEvent,r=0===t.button&&!0===t.ctrlKey,n=2===t.button||r;(!s.modal||n)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})}).displayName=ge,b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(f_,{...s,...n,ref:t})}).displayName="DropdownMenuGroup",b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(fT,{...s,...n,ref:t})}).displayName="DropdownMenuLabel",b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(fR,{...s,...n,ref:t})}).displayName="DropdownMenuItem",b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(fI,{...s,...n,ref:t})}).displayName="DropdownMenuCheckboxItem",b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(fz,{...s,...n,ref:t})}).displayName="DropdownMenuRadioGroup",b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(fB,{...s,...n,ref:t})}).displayName="DropdownMenuRadioItem",b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(fG,{...s,...n,ref:t})}).displayName="DropdownMenuItemIndicator",b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(fW,{...s,...n,ref:t})}).displayName="DropdownMenuSeparator",b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(fq,{...s,...n,ref:t})}).displayName="DropdownMenuArrow",b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(fY,{...s,...n,ref:t})}).displayName="DropdownMenuSubTrigger",b.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,...n}=e,s=f4(r);return(0,v.jsx)(fZ,{...s,...n,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})}).displayName="DropdownMenuSubContent";var gt=Symbol("radix.slottable");function gr(e){return b.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===gt}var gn=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{var r,n;let s,i,a,o=(n=r=`Primitive.${t}`,(s=b.forwardRef((e,t)=>{let{children:r,...n}=e;if(b.isValidElement(r)){var s;let e,i,a=(s=r,(i=(e=Object.getOwnPropertyDescriptor(s.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.ref:(i=(e=Object.getOwnPropertyDescriptor(s,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.props.ref:s.props.ref||s.ref),o=function(e,t){let r={...t};for(let n in t){let s=e[n],i=t[n];/^on[A-Z]/.test(n)?s&&i?r[n]=(...e)=>{let t=i(...e);return s(...e),t}:s&&(r[n]=s):"style"===n?r[n]={...s,...i}:"className"===n&&(r[n]=[s,i].filter(Boolean).join(" "))}return{...e,...r}}(n,r.props);return r.type!==b.Fragment&&(o.ref=t?(0,aY.composeRefs)(t,a):a),b.cloneElement(r,o)}return b.Children.count(r)>1?b.Children.only(null):null})).displayName=`${n}.SlotClone`,i=s,(a=b.forwardRef((e,t)=>{let{children:r,...n}=e,s=b.Children.toArray(r),a=s.find(gr);if(a){let e=a.props.children,r=s.map(t=>t!==a?t:b.Children.count(e)>1?b.Children.only(null):b.isValidElement(e)?e.props.children:null);return(0,v.jsx)(i,{...n,ref:t,children:b.isValidElement(e)?b.cloneElement(e,void 0,r):null})}return(0,v.jsx)(i,{...n,ref:t,children:r})})).displayName=`${r}.Slot`,a),l=b.forwardRef((e,r)=>{let{asChild:n,...s}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,v.jsx)(n?o:t,{...s,ref:r})});return l.displayName=`Primitive.${t}`,{...e,[t]:l}},{}),gs="HoverCard",[gi,ga]=function(e,t=[]){let r=[],n=()=>{let t=r.map(e=>b.createContext(e));return function(r){let n=r?.[e]||t;return b.useMemo(()=>({[`__scope${e}`]:{...r,[e]:n}}),[r,n])}};return n.scopeName=e,[function(t,n){let s=b.createContext(n),i=r.length;r=[...r,n];let a=t=>{let{scope:r,children:n,...a}=t,o=r?.[e]?.[i]||s,l=b.useMemo(()=>a,Object.values(a));return(0,v.jsx)(o.Provider,{value:l,children:n})};return a.displayName=t+"Provider",[a,function(r,a){let o=a?.[e]?.[i]||s,l=b.useContext(o);if(l)return l;if(void 0!==n)return n;throw Error(`\`${r}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let r=()=>{let r=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let n=r.reduce((t,{useScope:r,scopeName:n})=>{let s=r(e)[`__scope${n}`];return{...t,...s}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:n}),[n])}};return r.scopeName=t.scopeName,r}(n,...t)]}(gs,[mL.createPopperScope]),go=(0,mL.createPopperScope)(),[gl,gc]=gi(gs),gu="HoverCardTrigger";b.forwardRef((e,t)=>{let{__scopeHoverCard:r,...n}=e,s=gc(gu,r),i=go(r);return(0,v.jsx)(mL.Anchor,{asChild:!0,...i,children:(0,v.jsx)(gn.a,{"data-state":s.open?"open":"closed",...n,ref:t,onPointerEnter:(0,aH.composeEventHandlers)(e.onPointerEnter,gf(s.onOpen)),onPointerLeave:(0,aH.composeEventHandlers)(e.onPointerLeave,gf(s.onClose)),onFocus:(0,aH.composeEventHandlers)(e.onFocus,s.onOpen),onBlur:(0,aH.composeEventHandlers)(e.onBlur,s.onClose),onTouchStart:(0,aH.composeEventHandlers)(e.onTouchStart,e=>e.preventDefault())})})}).displayName=gu;var[gd,gh]=gi("HoverCardPortal",{forceMount:void 0}),gp="HoverCardContent";b.forwardRef((e,t)=>{let r=gh(gp,e.__scopeHoverCard),{forceMount:n=r.forceMount,...s}=e,i=gc(gp,e.__scopeHoverCard);return(0,v.jsx)(a0.Presence,{present:n||i.open,children:(0,v.jsx)(gm,{"data-state":i.open?"open":"closed",...s,onPointerEnter:(0,aH.composeEventHandlers)(e.onPointerEnter,gf(i.onOpen)),onPointerLeave:(0,aH.composeEventHandlers)(e.onPointerLeave,gf(i.onClose)),ref:t})})}).displayName=gp;var gm=b.forwardRef((e,t)=>{let{__scopeHoverCard:r,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:i,onInteractOutside:a,...o}=e,l=gc(gp,r),c=go(r),u=b.useRef(null),d=(0,aY.useComposedRefs)(t,u),[h,p]=b.useState(!1);return b.useEffect(()=>{if(h){let e=document.body;return y=e.style.userSelect||e.style.webkitUserSelect,e.style.userSelect="none",e.style.webkitUserSelect="none",()=>{e.style.userSelect=y,e.style.webkitUserSelect=y}}},[h]),b.useEffect(()=>{if(u.current){let e=()=>{p(!1),l.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(l.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",e),()=>{document.removeEventListener("pointerup",e),l.hasSelectionRef.current=!1,l.isPointerDownOnContentRef.current=!1}}},[l.isPointerDownOnContentRef,l.hasSelectionRef]),b.useEffect(()=>{u.current&&(function(e){let t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;r.nextNode();)t.push(r.currentNode);return t})(u.current).forEach(e=>e.setAttribute("tabindex","-1"))}),(0,v.jsx)(mR.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:a,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:(0,aH.composeEventHandlers)(i,e=>{e.preventDefault()}),onDismiss:l.onDismiss,children:(0,v.jsx)(mL.Content,{...c,...o,onPointerDown:(0,aH.composeEventHandlers)(o.onPointerDown,e=>{e.currentTarget.contains(e.target)&&p(!0),l.hasSelectionRef.current=!1,l.isPointerDownOnContentRef.current=!0}),ref:d,style:{...o.style,userSelect:h?"text":void 0,WebkitUserSelect:h?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})});function gf(e){return t=>"touch"===t.pointerType?void 0:e()}b.forwardRef((e,t)=>{let{__scopeHoverCard:r,...n}=e,s=go(r);return(0,v.jsx)(mL.Arrow,{...s,...n,ref:t})}).displayName="HoverCardArrow";var gg=e.i(77982);function gx({className:e,...t}){return(0,v.jsx)("div",{"data-slot":"input-group",role:"group",className:(0,k.cn)("group/input-group border-input dark:bg-input/30 relative flex w-full items-center rounded-md border shadow-xs transition-[color,box-shadow] outline-none","h-9 min-w-0 has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-[3px]","has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",e),...t})}let gy=(0,N.cva)("text-muted-foreground flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*='size-'])]:size-4 [&>kbd]:rounded-[calc(var(--radius)-5px)] group-data-[disabled=true]/input-group:opacity-50",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]","block-start":"order-first w-full justify-start px-3 pt-3 [.border-b]:pb-3 group-has-[>input]/input-group:pt-2.5","block-end":"order-last w-full justify-start px-3 pb-3 [.border-t]:pt-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function gv({className:e,align:t="inline-start",...r}){return(0,v.jsx)("div",{role:"group","data-slot":"input-group-addon","data-align":t,className:(0,k.cn)(gy({align:t}),e),onClick:e=>{e.target.closest("button")||e.currentTarget.parentElement?.querySelector("input")?.focus()},...r})}let gb=(0,N.cva)("text-sm shadow-none flex gap-2 items-center",{variants:{size:{xs:"h-6 gap-1 px-2 rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-3.5 has-[>svg]:px-2",sm:"h-8 px-2.5 gap-1.5 rounded-md has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function gw({className:e,type:t="button",variant:r="ghost",size:n="xs",...s}){return(0,v.jsx)(A.Button,{type:t,"data-size":n,variant:r,className:(0,k.cn)(gb({size:n}),e),...s})}let gk=(0,T.default)("corner-down-left",[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]]),gj=(0,T.default)("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);var gN=e.i(675182),gN=gN,gS=e.i(257868),gS=gS;let gC=(0,T.default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),gA=(e=21)=>{let t="",r=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&r[e]];return t},g_=(0,b.createContext)(null),gT=(0,b.createContext)(null),gE=(0,b.createContext)(null),gP=()=>{let e=(0,b.useContext)(gT),t=(0,b.useContext)(gE)??e;if(!t)throw Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return t},gR=(0,b.createContext)(null),gM=({className:e,accept:t,multiple:r,globalDrop:n,syncHiddenInput:s,maxFiles:i,maxFileSize:a,onError:o,onSubmit:l,children:c,...u})=>{let d=(0,b.useContext)(g_),h=!!d,p=(0,b.useRef)(null),m=(0,b.useRef)(null),[f,g]=(0,b.useState)([]),x=h?d.attachments.files:f,[y,w]=(0,b.useState)([]),j=(0,b.useRef)(x);j.current=x;let N=(0,b.useCallback)(()=>{p.current?.click()},[]),S=(0,b.useCallback)(e=>!t||""===t.trim()||t.split(",").map(e=>e.trim()).filter(Boolean).some(t=>{if(t.endsWith("/*")){let r=t.slice(0,-1);return e.type.startsWith(r)}return e.type===t}),[t]),C=(0,b.useCallback)(e=>{let t=Array.from(e),r=t.filter(e=>S(e));if(t.length&&0===r.length)return void o?.({code:"accept",message:"No files match the accepted types."});let n=r.filter(e=>!a||e.size<=a);r.length>0&&0===n.length?o?.({code:"max_file_size",message:"All files exceed the maximum size."}):g(e=>{let t="number"==typeof i?Math.max(0,i-e.length):void 0,r="number"==typeof t?n.slice(0,t):n;"number"==typeof t&&n.length>t&&o?.({code:"max_files",message:"Too many files. Some were not added."});let s=[];for(let e of r)s.push({id:gA(),type:"file",url:URL.createObjectURL(e),mediaType:e.type,filename:e.name});return e.concat(s)})},[S,i,a,o]),A=(0,b.useCallback)(e=>g(t=>{let r=t.find(t=>t.id===e);return r?.url&&URL.revokeObjectURL(r.url),t.filter(t=>t.id!==e)}),[]),_=(0,b.useCallback)(e=>{let t=Array.from(e),r=t.filter(e=>S(e));if(t.length&&0===r.length)return void o?.({code:"accept",message:"No files match the accepted types."});let n=r.filter(e=>!a||e.size<=a);if(r.length>0&&0===n.length)return void o?.({code:"max_file_size",message:"All files exceed the maximum size."});let s=x.length,l="number"==typeof i?Math.max(0,i-s):void 0,c="number"==typeof l?n.slice(0,l):n;"number"==typeof l&&n.length>l&&o?.({code:"max_files",message:"Too many files. Some were not added."}),c.length>0&&d?.attachments.add(c)},[S,a,i,o,x.length,d]),T=(0,b.useCallback)(()=>h?d?.attachments.clear():g(e=>{for(let t of e)t.url&&URL.revokeObjectURL(t.url);return[]}),[h,d]),E=(0,b.useCallback)(()=>w([]),[]),P=h?_:C,R=h?d.attachments.remove:A,M=h?d.attachments.openFileDialog:N,I=(0,b.useCallback)(()=>{T(),E()},[T,E]);(0,b.useEffect)(()=>{h&&d.__registerFileInput(p,()=>p.current?.click())},[h,d]),(0,b.useEffect)(()=>{s&&p.current&&0===x.length&&(p.current.value="")},[x,s]),(0,b.useEffect)(()=>{let e=m.current;if(!e||n)return;let t=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},r=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&P(e.dataTransfer.files)};return e.addEventListener("dragover",t),e.addEventListener("drop",r),()=>{e.removeEventListener("dragover",t),e.removeEventListener("drop",r)}},[P,n]),(0,b.useEffect)(()=>{if(!n)return;let e=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},t=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&P(e.dataTransfer.files)};return document.addEventListener("dragover",e),document.addEventListener("drop",t),()=>{document.removeEventListener("dragover",e),document.removeEventListener("drop",t)}},[P,n]),(0,b.useEffect)(()=>()=>{if(!h)for(let e of j.current)e.url&&URL.revokeObjectURL(e.url)},[h]);let L=async e=>{try{let t=await fetch(e),r=await t.blob();return new Promise(e=>{let t=new FileReader;t.onloadend=()=>e(t.result),t.onerror=()=>e(null),t.readAsDataURL(r)})}catch{return null}},D=(0,b.useMemo)(()=>({files:x.map(e=>({...e,id:e.id})),add:P,remove:R,clear:T,openFileDialog:M,fileInputRef:p}),[x,P,R,T,M]),O=(0,b.useMemo)(()=>({sources:y,add:e=>{let t=Array.isArray(e)?e:[e];w(e=>e.concat(t.map(e=>({...e,id:gA()}))))},remove:e=>{w(t=>t.filter(t=>t.id!==e))},clear:E}),[y,E]),z=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("input",{accept:t,"aria-label":"Upload files",className:"hidden",multiple:r,onChange:e=>{e.currentTarget.files&&P(e.currentTarget.files),e.currentTarget.value=""},ref:p,title:"Upload files",type:"file"}),(0,v.jsx)("form",{className:(0,k.cn)("w-full",e),onSubmit:e=>{e.preventDefault();let t=e.currentTarget,r=h?d.textInput.value:new FormData(t).get("message")||"";h||t.reset(),Promise.all(x.map(async({id:e,...t})=>{if(t.url?.startsWith("blob:")){let e=await L(t.url);return{...t,url:e??t.url}}return t})).then(t=>{try{let n=l({text:r,files:t},e);n instanceof Promise?n.then(()=>{I(),h&&d.textInput.clear()}).catch(()=>{}):(I(),h&&d.textInput.clear())}catch{}}).catch(()=>{})},ref:m,...u,children:(0,v.jsx)(gx,{className:"overflow-hidden",children:c})})]}),F=(0,v.jsx)(gR.Provider,{value:O,children:z});return(0,v.jsx)(gE.Provider,{value:D,children:F})},gI=({className:e,...t})=>(0,v.jsx)("div",{className:(0,k.cn)("contents",e),...t}),gL=({className:e,...t})=>(0,v.jsx)(gv,{align:"block-end",className:(0,k.cn)("order-first flex-wrap gap-1",e),...t}),gD=({className:e,...t})=>(0,v.jsx)(gv,{align:"block-end",className:(0,k.cn)("justify-between gap-1",e),...t}),gO=({className:e,variant:t="default",size:r="icon-sm",status:n,onStop:s,onClick:i,children:a,...o})=>{let l="submitted"===n||"streaming"===n,c=(0,v.jsx)(gk,{className:"size-4"});return"submitted"===n?c=(0,v.jsx)(gN.default,{className:"size-4 animate-spin"}):"streaming"===n?c=(0,v.jsx)(gC,{className:"size-4"}):"error"===n&&(c=(0,v.jsx)(aO.XIcon,{className:"size-4"})),(0,v.jsx)(gw,{"aria-label":l?"Stop":"Submit",className:(0,k.cn)(e),onClick:e=>{if(l&&s){e.preventDefault(),s();return}i?.(e)},size:r,type:l&&s?"button":"submit",variant:t,...o,children:a??c})},gz=(0,T.default)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),gF=(0,T.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]),gB=(0,T.default)("music-2",[["circle",{cx:"8",cy:"18",r:"4",key:"1fc0mg"}],["path",{d:"M12 18V2l7 4",key:"g04rme"}]]),g$=(0,T.default)("paperclip",[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]),gV=(0,T.default)("video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]),gU=e=>{if("source-document"===e.type)return"source";let t=e.mediaType??"";return t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":t.startsWith("application/")||t.startsWith("text/")?"document":"unknown"},gG=(0,b.createContext)(null),gW=(0,b.createContext)(null),gq=()=>{let e=(0,b.useContext)(gW);if(!e)throw Error("Attachment components must be used within <Attachment>");return e},gH=({variant:e="grid",className:t,children:r,...n})=>{let s=(0,b.useMemo)(()=>({variant:e}),[e]);return(0,v.jsx)(gG.Provider,{value:s,children:(0,v.jsx)("div",{className:(0,k.cn)("flex items-start","list"===e?"flex-col gap-2":"flex-wrap gap-2","grid"===e&&"ml-auto w-fit",t),...n,children:r})})},gK=({data:e,onRemove:t,className:r,children:n,...s})=>{let{variant:i}=(0,b.useContext)(gG)??{variant:"grid"},a=gU(e),o=(0,b.useMemo)(()=>({data:e,mediaCategory:a,onRemove:t,variant:i}),[e,a,t,i]);return(0,v.jsx)(gW.Provider,{value:o,children:(0,v.jsx)("div",{className:(0,k.cn)("group relative","grid"===i&&"size-24 overflow-hidden rounded-lg","inline"===i&&["flex h-8 cursor-pointer select-none items-center gap-1.5","rounded-md border border-border px-1.5","font-medium text-sm transition-all","hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50"],"list"===i&&["flex w-full items-center gap-3 rounded-lg border p-3","hover:bg-accent/50"],r),...s,children:n})})},gX=({fallbackIcon:e,className:t,...r})=>{let{data:n,mediaCategory:s,variant:i}=gq(),a="inline"===i?"size-3":"size-4";return(0,v.jsx)("div",{className:(0,k.cn)("flex shrink-0 items-center justify-center overflow-hidden","grid"===i&&"size-full bg-muted","inline"===i&&"size-5 rounded bg-background","list"===i&&"size-12 rounded bg-muted",t),...r,children:(()=>{let t;if("image"===s&&"file"===n.type&&n.url){let e,t;return e=n.url,t=n.filename,"grid"===i?(0,v.jsx)("img",{alt:t||"Image",className:"size-full object-cover",height:96,src:e,width:96}):(0,v.jsx)("img",{alt:t||"Image",className:"size-full rounded object-cover",height:20,src:e,width:20})}return"video"===s&&"file"===n.type&&n.url?(0,v.jsx)("video",{className:"size-full object-cover",muted:!0,src:n.url}):e??(t=({image:gj,video:gV,audio:gB,source:gF,document:gz,unknown:g$})[s],(0,v.jsx)(t,{className:(0,k.cn)(a,"text-muted-foreground")}))})()})},gY=({showMediaType:e=!1,className:t,...r})=>{let{data:n,variant:s}=gq(),i=(e=>{if("source-document"===e.type)return e.title||e.filename||"Source";let t=gU(e);return e.filename||("image"===t?"Image":"Attachment")})(n);return"grid"===s?null:(0,v.jsxs)("div",{className:(0,k.cn)("min-w-0 flex-1",t),...r,children:[(0,v.jsx)("span",{className:"block truncate",children:i}),e&&n.mediaType&&(0,v.jsx)("span",{className:"block truncate text-muted-foreground text-xs",children:n.mediaType})]})},gJ=({label:e="Remove",className:t,children:r,...n})=>{let{onRemove:s,variant:i}=gq();return s?(0,v.jsxs)(A.Button,{"aria-label":e,className:(0,k.cn)("grid"===i&&["absolute top-2 right-2 size-6 rounded-full p-0","bg-background/80 backdrop-blur-sm","opacity-0 transition-opacity group-hover:opacity-100","hover:bg-background","[&>svg]:size-3"],"inline"===i&&["size-5 rounded p-0","opacity-0 transition-opacity group-hover:opacity-100","[&>svg]:size-2.5"],"list"===i&&["size-8 shrink-0 rounded p-0","[&>svg]:size-4"],t),onClick:e=>{e.stopPropagation(),s()},type:"button",variant:"ghost",...n,children:[r??(0,v.jsx)(aO.XIcon,{}),(0,v.jsx)("span",{className:"sr-only",children:e})]}):null};var gZ=e.i(772857);let gQ=({className:e,children:t,...r})=>(0,v.jsxs)(gZ.ScrollArea,{className:"w-full overflow-x-auto whitespace-nowrap",...r,children:[(0,v.jsx)("div",{className:(0,k.cn)("flex w-max flex-nowrap items-center gap-2",e),children:t}),(0,v.jsx)(gZ.ScrollBar,{className:"hidden",orientation:"horizontal"})]}),g0=({suggestion:e,onClick:t,className:r,variant:n="outline",size:s="sm",children:i,...a})=>(0,v.jsx)(A.Button,{className:(0,k.cn)("cursor-pointer rounded-full px-4 transition-all duration-200","hover:scale-[1.02] hover:shadow-md hover:border-primary/50",r),onClick:()=>{t?.(e)},size:s,type:"button",variant:n,...a,children:i||e});var g1=e.i(524741);let g2=(0,T.default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),g5=(0,T.default)("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]),g3=(0,T.default)("list-todo",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]),g6={pending:oc,in_progress:g5,completed:g2,cancelled:oh},g4={pending:"text-muted-foreground",in_progress:"text-primary",completed:"text-green-500",cancelled:"text-muted-foreground/50"};function g8({todosData:e,isLoading:t,className:r}){let[n,s]=(0,b.useState)(!1);if(!e||0===e.todos.length)return null;let{todos:i,stats:a,nextTodo:o}=e,l=[...i].sort((e,t)=>{let r={in_progress:0,pending:1,completed:2,cancelled:3};return(r[e.status]??4)-(r[t.status]??4)}),c=a.total>0?Math.round(a.completed/a.total*100):0;return(0,v.jsxs)("div",{className:(0,k.cn)("rounded-lg border bg-card/50 backdrop-blur-sm overflow-hidden",r),children:[(0,v.jsxs)("button",{onClick:()=>s(!n),className:"flex items-center justify-between w-full px-3 py-2 hover:bg-muted/50 transition-colors",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,v.jsx)(g3,{className:"size-4 text-primary shrink-0"}),!n&&o?(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,v.jsx)(g5,{className:"size-3.5 text-primary shrink-0"}),(0,v.jsx)("span",{className:"text-sm truncate",children:o.content})]}):(0,v.jsx)("span",{className:"font-medium text-sm",children:"Tasks"}),(0,v.jsxs)("span",{className:"text-xs text-muted-foreground shrink-0",children:[a.completed,"/",a.total]})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,v.jsx)("div",{className:"w-16 h-1.5 bg-muted rounded-full overflow-hidden",children:(0,v.jsx)("div",{className:"h-full bg-primary transition-all duration-300",style:{width:`${c}%`}})}),n?(0,v.jsx)(ol.ChevronDownIcon,{className:"size-4 text-muted-foreground"}):(0,v.jsx)(aL,{className:"size-4 text-muted-foreground"})]})]}),n&&(0,v.jsxs)("div",{className:"border-t",children:[o&&(0,v.jsxs)("div",{className:"px-3 py-2 bg-primary/5 border-b flex items-center gap-2",children:[(0,v.jsx)(g5,{className:"size-4 text-primary shrink-0"}),(0,v.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,v.jsx)("span",{className:"text-xs text-primary font-medium uppercase tracking-wide",children:"Current"}),(0,v.jsx)("p",{className:"text-sm font-medium truncate",children:o.content})]})]}),(0,v.jsx)("div",{className:"max-h-[200px] overflow-auto",children:l.map(e=>{let t=g6[e.status]||oc,r=g4[e.status]||"text-muted-foreground",n=e.id===o?.id;return(0,v.jsxs)(_.Tooltip,{children:[(0,v.jsx)(_.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)("div",{className:(0,k.cn)("flex items-start gap-2 px-3 py-1.5 hover:bg-muted/30 transition-colors cursor-default",n&&"bg-primary/5"),children:[(0,v.jsx)(t,{className:(0,k.cn)("size-4 mt-0.5 shrink-0",r)}),(0,v.jsx)("span",{className:(0,k.cn)("text-sm flex-1 min-w-0 truncate","cancelled"===e.status&&"line-through text-muted-foreground/50","completed"===e.status&&"text-muted-foreground"),children:e.content})]})}),(0,v.jsxs)(_.TooltipContent,{side:"left",className:"max-w-xs",children:[(0,v.jsx)("p",{className:"text-sm",children:e.content}),(0,v.jsx)("p",{className:"text-xs text-muted-foreground capitalize mt-1",children:e.status.replace("_"," ")})]})]},e.id)})}),(0,v.jsxs)("div",{className:"px-3 py-1.5 border-t bg-muted/30 flex items-center gap-3 text-xs text-muted-foreground",children:[a.inProgress>0&&(0,v.jsxs)("span",{className:"flex items-center gap-1",children:[(0,v.jsx)(g5,{className:"size-3 text-primary"}),a.inProgress," active"]}),a.pending>0&&(0,v.jsxs)("span",{className:"flex items-center gap-1",children:[(0,v.jsx)(oc,{className:"size-3"}),a.pending," pending"]}),a.completed>0&&(0,v.jsxs)("span",{className:"flex items-center gap-1",children:[(0,v.jsx)(g2,{className:"size-3 text-green-500"}),a.completed," done"]})]})]})]})}var g9=e.i(739963),g7=e.i(300739);let xe=(0,T.default)("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"}]]),xt=(0,T.default)("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"}]]),xr=(0,T.default)("file-code",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]),xn=(0,T.default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);var xs=e.i(719583),xi=e.i(816187);let xa=(0,T.default)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),xo=(0,T.default)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);var xl=e.i(220563);let xc=(0,T.default)("file",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]]),xu=(0,T.default)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);var xd=e.i(707387),xh=e.i(51846),xh=xh,xp=e.i(101513),xp=xp;let xm=(0,T.default)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]),xf=(0,T.default)("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);var xg=e.i(904781);let xx=(0,T.default)("monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);var xy=e.i(529757),xv=e.i(865259),xb=e.i(634066);let xw=(0,T.default)("file-plus",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]),xk=(0,b.memo)(({line:e,type:t})=>(0,v.jsxs)("div",{className:(0,k.cn)("font-mono text-xs leading-5 px-2","add"===t?"bg-green-500/10":"remove"===t?"bg-red-500/10":"","add"===t?"text-green-600 dark:text-green-400":"remove"===t?"text-red-600 dark:text-red-400":"text-muted-foreground"),children:[(0,v.jsx)("span",{className:"select-none w-4 inline-block",children:"add"===t?"+":"remove"===t?"-":" "}),(0,v.jsx)("span",{className:"whitespace-pre-wrap break-all",children:e||" "})]}));function xj({input:e,output:t,status:r,streamingArgsText:n,liveContent:s,liveOldString:i,liveNewString:a,className:o}){let[l,c]=(0,b.useState)(!0),u=e?.path||"",d=u.split("/").pop()||"file",h=e?.mode||t?.mode||"full",p={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",php:"php",swift:"swift",kt:"kotlin",scala:"scala",sh:"bash",bash:"bash",zsh:"bash",fish:"bash",ps1:"powershell",sql:"sql",html:"html",htm:"html",css:"css",scss:"scss",sass:"sass",less:"less",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",md:"markdown",markdown:"markdown",txt:"plaintext",toml:"toml",ini:"ini",cfg:"ini",conf:"ini",dockerfile:"dockerfile",makefile:"makefile"}[u.split(".").pop()?.toLowerCase()||""]||"plaintext",m=(0,b.useMemo)(()=>{if(!n)return null;try{return JSON.parse(n)}catch{let e=n.match(/"content"\s*:\s*"((?:[^"\\]|\\[\s\S])*)(?:"|$)/);if(e)try{return{content:JSON.parse(`"${e[1]}"`)}}catch{return{content:e[1]}}let t=n.match(/"old_string"\s*:\s*"((?:[^"\\]|\\[\s\S])*)(?:"|$)/),r=n.match(/"new_string"\s*:\s*"((?:[^"\\]|\\[\s\S])*)(?:"|$)/);if(t||r)return{old_string:t?t[1]:void 0,new_string:r?r[1]:void 0};return null}},[n]),f=s||e?.content||m?.content||"",g=i||e?.old_string||m?.old_string||"",x=a||e?.new_string||m?.new_string||"",y="streaming"===r||"pending"===r||"running"===r&&!!(s||i||a),w="completed"===r,j="error"===r||t?.success===!1,N=w&&t?.success?oo:j?oh:y?xr:xc,S=w&&t?.success?"text-green-600 dark:text-green-500":j?"text-red-600 dark:text-red-500":y?"text-blue-600 dark:text-blue-500":"text-muted-foreground",_="str_replace"===h?xn:t?.action==="created"?xw:xr;return(0,v.jsxs)("div",{className:(0,k.cn)("rounded-lg border overflow-hidden bg-background",o),children:[(0,v.jsxs)("button",{onClick:()=>c(!l),className:"flex items-center justify-between w-full px-3 py-2.5 bg-muted/50 hover:bg-muted/70 transition-colors",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(N,{className:(0,k.cn)("size-4 shrink-0",S)}),(0,v.jsx)(_,{className:"size-3.5 text-muted-foreground shrink-0"}),(0,v.jsx)(C,{variant:"outline",className:"text-xs shrink-0",children:"write_file"}),(0,v.jsx)("span",{className:"font-medium text-sm truncate",children:d}),"str_replace"===h&&(0,v.jsx)(C,{variant:"secondary",className:"text-xs shrink-0",children:"edit"}),t?.action==="created"&&(0,v.jsx)(C,{variant:"secondary",className:"text-xs shrink-0",children:"new"}),y&&(0,v.jsx)("span",{className:"text-xs text-muted-foreground animate-pulse",children:"streaming..."})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[t?.success&&void 0!==t.lineDelta&&(0,v.jsxs)("span",{className:(0,k.cn)("text-xs font-mono",t.lineDelta>=0?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"),children:[t.lineDelta>=0?"+":"",t.lineDelta]}),l?(0,v.jsx)(ol.ChevronDownIcon,{className:"size-4 text-muted-foreground"}):(0,v.jsx)(aL,{className:"size-4 text-muted-foreground"})]})]}),l&&(0,v.jsxs)("div",{className:"border-t",children:[(0,v.jsxs)("div",{className:"px-3 py-1.5 bg-muted/30 border-b flex items-center justify-between",children:[(0,v.jsx)("span",{className:"text-xs text-muted-foreground font-mono truncate",children:u}),f&&(0,v.jsx)(A.Button,{variant:"ghost",size:"icon",className:"size-6",onClick:()=>navigator.clipboard.writeText(f),children:(0,v.jsx)(om,{className:"size-3"})})]}),"str_replace"===h?(0,v.jsxs)("div",{className:"max-h-[200px] overflow-auto",children:[g&&(0,v.jsxs)("div",{className:"border-b",children:[(0,v.jsx)("div",{className:"px-3 py-1 bg-red-500/5 border-b text-xs text-red-600 dark:text-red-400 font-medium",children:"Removed"}),(0,v.jsx)("div",{className:"py-1",children:g.split("\n").map((e,t)=>(0,v.jsx)(xk,{line:e,type:"remove"},`old-${t}`))})]}),x&&(0,v.jsxs)("div",{children:[(0,v.jsx)("div",{className:"px-3 py-1 bg-green-500/5 border-b text-xs text-green-600 dark:text-green-400 font-medium",children:"Added"}),(0,v.jsx)("div",{className:"py-1",children:x.split("\n").map((e,t)=>(0,v.jsx)(xk,{line:e,type:"add"},`new-${t}`))})]}),!g&&!x&&y&&(0,v.jsx)("div",{className:"px-3 py-4 text-center text-muted-foreground text-sm",children:(0,v.jsx)("span",{className:"animate-pulse",children:"Receiving changes..."})})]}):(0,v.jsx)("div",{className:"max-h-[200px] overflow-auto",children:f?(0,v.jsx)(oT,{code:f,language:p,showLineNumbers:!0}):y?(0,v.jsx)("div",{className:"px-3 py-4 text-center text-muted-foreground text-sm",children:(0,v.jsx)("span",{className:"animate-pulse",children:"Writing file..."})}):null}),(t?.success===!0||t?.success===!1||j)&&(0,v.jsx)("div",{className:(0,k.cn)("px-3 py-2 border-t text-xs flex items-center gap-2",t?.success===!0?"bg-green-500/5 text-green-600 dark:text-green-400":"bg-red-500/5 text-red-600 dark:text-red-400"),children:t?.success===!0?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(oo,{className:"size-3.5"}),(0,v.jsx)("span",{children:"str_replace"===h?`Replaced ${t.linesRemoved||0} → ${t.linesAdded||0} lines`:`${"created"===t.action?"Created":"Updated"} (${t.lineCount||0} lines)`})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(oh,{className:"size-3.5"}),(0,v.jsx)("span",{children:t?.error||"Failed to write file"})]})})]})]})}xk.displayName="DiffLine";var xN=e.i(416667),xN=xN;let xS=(0,T.default)("scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);function xC({input:e,output:t,status:r,className:n}){var s;let[i,a]=(0,b.useState)(!0),o=e?.path||t?.relativePath||t?.path||"",l=o.split("/").pop()||"file",c={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",php:"php",swift:"swift",kt:"kotlin",scala:"scala",sh:"bash",bash:"bash",zsh:"bash",fish:"bash",ps1:"powershell",sql:"sql",html:"html",htm:"html",css:"css",scss:"scss",sass:"sass",less:"less",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",md:"markdown",markdown:"markdown",txt:"plaintext",toml:"toml",ini:"ini",cfg:"ini",conf:"ini",dockerfile:"dockerfile",makefile:"makefile"}[o.split(".").pop()?.toLowerCase()||""]||"plaintext",u=t?.content||"",d="pending"===r||"streaming"===r||"running"===r,h="completed"===r&&t?.success===!0,p="error"===r||t?.success===!1,m=(0,b.useMemo)(()=>e?.startLine&&e?.endLine?`lines ${e.startLine}-${e.endLine}`:e?.startLine?`from line ${e.startLine}`:e?.endLine?`to line ${e.endLine}`:null,[e?.startLine,e?.endLine]),f=h?oo:p?xN.default:xc;return(0,v.jsxs)("div",{className:(0,k.cn)("rounded-lg border overflow-hidden bg-background",n),children:[(0,v.jsxs)("button",{onClick:()=>a(!i),className:"flex items-center justify-between w-full px-3 py-2.5 bg-muted/50 hover:bg-muted/70 transition-colors",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(f,{className:(0,k.cn)("size-4 shrink-0",h?"text-green-600 dark:text-green-500":p?"text-red-600 dark:text-red-500":"text-muted-foreground")}),(0,v.jsx)(gz,{className:"size-3.5 text-muted-foreground shrink-0"}),(0,v.jsx)("span",{className:"font-medium text-sm truncate",children:l}),m&&(0,v.jsx)(C,{variant:"outline",className:"text-xs shrink-0",children:m}),t?.wasTruncated&&(0,v.jsxs)(C,{variant:"secondary",className:"text-xs shrink-0 gap-1",children:[(0,v.jsx)(xS,{className:"size-3"}),"truncated"]}),d&&(0,v.jsx)("span",{className:"text-xs text-muted-foreground animate-pulse",children:"reading..."})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[t?.lineCount!==void 0&&(0,v.jsxs)("span",{className:"text-xs text-muted-foreground",children:[t.lineCount," lines"]}),i?(0,v.jsx)(ol.ChevronDownIcon,{className:"size-4 text-muted-foreground"}):(0,v.jsx)(aL,{className:"size-4 text-muted-foreground"})]})]}),i&&(0,v.jsxs)("div",{className:"border-t",children:[(0,v.jsxs)("div",{className:"px-3 py-1.5 bg-muted/30 border-b flex items-center justify-between",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)("span",{className:"text-xs text-muted-foreground font-mono truncate",children:o}),t?.sizeBytes!==void 0&&(0,v.jsxs)("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:["(",(s=t.sizeBytes)<1024?`${s} B`:s<1048576?`${(s/1024).toFixed(1)} KB`:`${(s/1024/1024).toFixed(2)} MB`,")"]})]}),u&&(0,v.jsx)(A.Button,{variant:"ghost",size:"icon",className:"size-6",onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(u)},children:(0,v.jsx)(om,{className:"size-3"})})]}),(0,v.jsx)("div",{className:"max-h-[200px] overflow-auto",children:d?(0,v.jsx)("div",{className:"px-3 py-8 text-center text-muted-foreground text-sm",children:(0,v.jsx)("span",{className:"animate-pulse",children:"Reading file..."})}):p?(0,v.jsxs)("div",{className:"px-3 py-4 text-red-600 dark:text-red-400 text-sm flex items-start gap-2",children:[(0,v.jsx)(xN.default,{className:"size-4 mt-0.5 shrink-0"}),(0,v.jsx)("span",{children:t?.error||"Failed to read file"})]}):u?(0,v.jsx)(oT,{code:u,language:c,showLineNumbers:!0}):(0,v.jsx)("div",{className:"px-3 py-4 text-muted-foreground text-sm italic",children:"File is empty"})}),t?.wasTruncated&&(0,v.jsxs)("div",{className:"px-3 py-2 border-t bg-amber-500/5 text-xs text-amber-600 dark:text-amber-400 flex items-center gap-2",children:[(0,v.jsx)(xS,{className:"size-3.5"}),(0,v.jsx)("span",{children:"Content was truncated. Use startLine/endLine to read specific sections."})]})]})]})}let xA=(0,T.default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),x_=(0,T.default)("radio",[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);var ou=ou;let xT=(0,T.default)("circle-stop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);function xE({input:e,output:t,status:r,terminalId:n,liveOutput:s,className:i}){let[a,o]=(0,b.useState)(!0),l=(0,b.useRef)(null);(0,b.useEffect)(()=>{l.current&&(l.current.scrollTop=l.current.scrollHeight)},[s,t?.output]);let c=e?.command||"",u=e?.background||!1,d=e?.kill===!0,h=e?.id&&(e?.input!==void 0||e?.key!==void 0),p=e?.id&&!e?.command&&!e?.kill&&!h,m="pending"===r||"streaming"===r||"running"===r,f=m&&n&&void 0!==s,g="completed"===r,x="error"===r||t?.success===!1,y=t?.exitCode,w=(()=>{if(f)return s||"";if(t){let e=t.output||t.stdout||"",r=t.stderr||"";return r?e+(e?"\n":"")+r:e}return""})(),j=c.length>50?c.slice(0,50)+"...":c,{Icon:N,color:S,label:_}=(()=>{if(d)return{Icon:xT,color:"text-amber-600 dark:text-amber-500",label:t?.status==="stopped"?"Stopped":"Stopping..."};if(h){let t=e?.key?`key: ${e.key}`:`input: "${e?.input?.slice(0,20)}..."`;return{Icon:xA,color:"text-purple-600 dark:text-purple-500",label:m?"Sending...":t}}return p?{Icon:xA,color:"text-blue-600 dark:text-blue-500",label:"Logs"}:f?{Icon:x_,color:"text-green-600 dark:text-green-500 animate-pulse",label:"Live"}:m?{Icon:ou.default,color:"text-muted-foreground animate-pulse",label:"Executing..."}:g&&0===y?{Icon:oo,color:"text-green-600 dark:text-green-500",label:"Completed"}:g&&0!==y?{Icon:oh,color:"text-red-600 dark:text-red-500",label:`Exit ${y}`}:x?{Icon:oh,color:"text-red-600 dark:text-red-500",label:"Error"}:{Icon:xA,color:"text-muted-foreground",label:""}})();return(0,v.jsxs)("div",{className:(0,k.cn)("rounded-lg border overflow-hidden bg-background",i),children:[(0,v.jsxs)("button",{onClick:()=>o(!a),className:"flex items-center justify-between w-full px-3 py-2.5 bg-muted/50 hover:bg-muted/70 transition-colors",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(N,{className:(0,k.cn)("size-4 shrink-0",S)}),(0,v.jsx)(xA,{className:"size-3.5 text-muted-foreground shrink-0"}),(0,v.jsx)("code",{className:"font-mono text-sm truncate",title:c,children:j||(d?`kill ${e?.id}`:p?`logs ${e?.id}`:"bash")}),u&&(0,v.jsx)(C,{variant:"secondary",className:"text-xs shrink-0",children:"background"}),f&&(0,v.jsxs)(C,{variant:"secondary",className:"text-xs shrink-0 bg-green-500/10 text-green-600 dark:text-green-400 gap-1",children:[(0,v.jsx)(x_,{className:"size-2 animate-pulse"}),"live"]}),_&&!f&&(0,v.jsx)("span",{className:(0,k.cn)("text-xs shrink-0",S),children:_})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[void 0!==y&&g&&(0,v.jsxs)(C,{variant:0===y?"secondary":"destructive",className:(0,k.cn)("text-xs",0===y?"bg-green-500/10 text-green-600 dark:text-green-400":""),children:["exit ",y]}),a?(0,v.jsx)(ol.ChevronDownIcon,{className:"size-4 text-muted-foreground"}):(0,v.jsx)(aL,{className:"size-4 text-muted-foreground"})]})]}),a&&(0,v.jsxs)("div",{className:"border-t",children:[c&&(0,v.jsxs)("div",{className:"px-3 py-1.5 bg-muted/30 border-b flex items-center justify-between",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)("span",{className:"text-muted-foreground text-xs",children:"$"}),(0,v.jsx)("code",{className:"text-xs font-mono truncate",children:c})]}),(0,v.jsx)(A.Button,{variant:"ghost",size:"icon",className:"size-6",onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(c)},children:(0,v.jsx)(om,{className:"size-3"})})]}),(0,v.jsxs)("div",{ref:l,className:"bg-zinc-950 dark:bg-zinc-950 relative max-h-[300px] overflow-auto",children:[(0,v.jsxs)("pre",{className:"px-3 py-2 text-xs font-mono text-zinc-300 whitespace-pre-wrap break-all min-h-[40px]",children:[w||(0,v.jsx)("span",{className:"text-muted-foreground italic",children:m?"Waiting for output...":"(no output)"}),f&&(0,v.jsx)("span",{className:"inline-block w-2 h-4 bg-green-500 animate-pulse ml-0.5"})]}),w&&(0,v.jsx)(A.Button,{variant:"ghost",size:"icon",className:"absolute top-1 right-1 size-6 text-zinc-500 hover:text-zinc-300 bg-zinc-900/80",onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(w)},children:(0,v.jsx)(om,{className:"size-3"})})]}),t?.error&&(0,v.jsxs)("div",{className:"px-3 py-2 border-t bg-red-500/5 text-red-600 dark:text-red-400 text-xs flex items-start gap-2",children:[(0,v.jsx)(oh,{className:"size-3.5 mt-0.5 shrink-0"}),(0,v.jsx)("span",{children:t.error})]}),t?.message&&!t?.error&&(0,v.jsx)("div",{className:"px-3 py-2 border-t bg-muted/30 text-muted-foreground text-xs",children:t.message})]})]})}let xP=(0,T.default)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),xR=(0,T.default)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]);var xM=e.i(481298),xM=xM,gN=gN;let xI=(e,t)=>e?e.length>t?e.slice(0,t)+"...":e:"";function xL({open:e,onOpenChange:t,title:r="Explore Agent",steps:n,status:s,query:i}){let a=(0,b.useRef)(null),o=(0,b.useRef)(null),l="running"===s,c="completed"===s;return(0,b.useEffect)(()=>{o.current&&l&&o.current.scrollIntoView({behavior:"smooth",block:"end"})},[n,l]),(0,v.jsx)(mw.Dialog,{open:e,onOpenChange:t,children:(0,v.jsxs)(mw.DialogContent,{className:"sm:max-w-xl max-h-[80vh] flex flex-col gap-0 p-0 overflow-hidden",children:[(0,v.jsxs)("div",{className:"px-4 py-3 border-b flex items-center gap-3",children:[(0,v.jsx)("div",{className:"shrink-0",children:l?(0,v.jsx)(gN.default,{className:"size-4 text-blue-500 animate-spin"}):c?(0,v.jsx)(oo,{className:"size-4 text-green-500"}):(0,v.jsx)(oh,{className:"size-4 text-red-500"})}),(0,v.jsx)(mw.DialogHeader,{className:"flex-1 space-y-0",children:(0,v.jsx)(mw.DialogTitle,{className:"text-sm font-medium",children:l?"SparkeCoder is exploring...":c?"Exploration complete":"Exploration failed"})}),(0,v.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums",children:[n.length," steps"]})]}),i&&(0,v.jsx)("div",{className:"px-4 py-2 border-b bg-muted/30",children:(0,v.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,v.jsx)(mb,{className:"size-3 shrink-0"}),(0,v.jsx)("span",{className:"truncate",title:i,children:xI(i,80)})]})}),(0,v.jsx)("div",{ref:a,className:"flex-1 overflow-auto bg-zinc-950 font-mono text-xs",children:0===n.length?(0,v.jsxs)("div",{className:"flex items-center justify-center py-12 text-zinc-500",children:[(0,v.jsx)(gN.default,{className:"size-4 animate-spin mr-2"}),"Initializing..."]}):(0,v.jsxs)("div",{className:"py-2",children:[n.map((e,t)=>(0,v.jsx)(xD,{step:e},e.id||t)),(0,v.jsx)("div",{ref:o}),l&&(0,v.jsxs)("div",{className:"px-3 py-1 flex items-center gap-2 text-zinc-500",children:[(0,v.jsx)(gN.default,{className:"size-3 animate-spin"}),(0,v.jsx)("span",{className:"animate-pulse",children:"_"})]})]})}),(0,v.jsxs)("div",{className:"px-4 py-2 border-t bg-zinc-950 flex items-center gap-2",children:[(0,v.jsx)("div",{className:(0,k.cn)("size-2 rounded-full",l&&"bg-blue-500 animate-pulse",c&&"bg-green-500","error"===s&&"bg-red-500")}),(0,v.jsx)("span",{className:"text-xs text-zinc-500",children:l?"Running":c?"Done":"Failed"})]})]})})}function xD({step:e}){let t=(e=>{switch(e){case"grep":return mb;case"glob":case"list_dir":return xP;case"read_file":return gz;default:return xA}})(e.toolName);if("tool_call"===e.type){let r=function(e){try{if(null==e)return"";if("string"==typeof e)return e;return JSON.stringify(e)}catch{return String(e)}}(e.toolInput);return(0,v.jsxs)("div",{className:"px-3 py-0.5 hover:bg-zinc-900/50 flex items-start gap-2",children:[(0,v.jsx)(aL,{className:"size-3 text-blue-400 mt-0.5 shrink-0"}),(0,v.jsx)(t,{className:"size-3 text-blue-400 mt-0.5 shrink-0"}),(0,v.jsx)("span",{className:"text-blue-400",children:e.toolName}),r&&(0,v.jsx)("span",{className:"text-zinc-600 truncate",children:xI(r,60)})]})}return"tool_result"===e.type?(0,v.jsxs)("div",{className:"px-3 py-0.5 hover:bg-zinc-900/50 flex items-start gap-2",children:[(0,v.jsx)(oo,{className:"size-3 text-green-500 mt-0.5 shrink-0"}),(0,v.jsx)("span",{className:"text-zinc-500 truncate",children:xI(e.content,80)})]}):"thought"===e.type?(0,v.jsxs)("div",{className:"px-3 py-0.5 hover:bg-zinc-900/50 flex items-start gap-2",children:[(0,v.jsx)(xR,{className:"size-3 text-amber-400 mt-0.5 shrink-0"}),(0,v.jsx)("span",{className:"text-zinc-400 italic",children:xI(e.content,80)})]}):(0,v.jsx)("div",{className:"px-3 py-0.5 hover:bg-zinc-900/50 flex items-start gap-2",children:(0,v.jsx)("span",{className:"text-zinc-300",children:xI(e.content,100)})})}let xO=(e,t)=>e?e.length>t?e.slice(0,t)+"...":e:"";function xz({input:e,output:t,status:r,steps:n=[],className:s}){let[i,a]=(0,b.useState)(!1),[o,l]=(0,b.useState)(!1),[c,u]=(0,b.useState)(!1),d=(0,b.useRef)(null),h="pending"===r||"streaming"===r||"running"===r,p="completed"===r,m="error"===r||t?.success===!1,f=(0,b.useMemo)(()=>(e=>{let t=e.filter(e=>"tool_call"===e.type),r=new Set;for(let e of t)if("read_file"===e.toolName&&e.toolInput){let t=e.toolInput;t.path&&r.add(t.path)}return{toolCallCount:t.length,filesExplored:r.size}})(n),[n]);(0,b.useEffect)(()=>{d.current&&h&&i&&(d.current.scrollTop=d.current.scrollHeight)},[n,h,i]);let g=e?.query||"",x=(e=>{if(0===e.length)return null;let t=e[e.length-1];return"tool_call"===t.type&&t.toolName?{type:"tool",name:t.toolName}:"thought"===t.type||"text"===t.type?{type:"text",content:xO(t.content,40)}:null})(n),y=(0,b.useMemo)(()=>t?"string"==typeof t?t:t.result?t.result:t.formattedResult?t.formattedResult:t.summary?t.summary:t.text?String(t.text):t.content?String(t.content):"":"",[t]),w=(e=>{if(!e)return"";let t=e.split("\n")[0].trim(),r=t.match(/^[^.!?]+[.!?]/);return r?r[0]:xO(t,100)})(y),j=y.length>200;return(0,v.jsxs)("div",{className:(0,k.cn)("rounded-lg border overflow-hidden bg-background",s),children:[(0,v.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2.5",children:[(0,v.jsx)("div",{className:"shrink-0",children:h?(0,v.jsxs)("div",{className:"relative",children:[(0,v.jsx)(xR,{className:"size-4 text-blue-500"}),(0,v.jsx)("span",{className:"absolute -top-0.5 -right-0.5 size-2 bg-blue-500 rounded-full animate-pulse"})]}):p&&!m?(0,v.jsx)(oo,{className:"size-4 text-green-500"}):m?(0,v.jsx)(oh,{className:"size-4 text-red-500"}):(0,v.jsx)(mb,{className:"size-4 text-muted-foreground"})}),(0,v.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,v.jsx)("div",{className:"text-sm",children:h?(0,v.jsx)("span",{className:"text-foreground",children:"SparkeCoder is exploring the codebase"}):p&&!m?(0,v.jsx)("span",{className:"text-foreground",children:"Exploration complete"}):m?(0,v.jsx)("span",{className:"text-red-500",children:"Exploration failed"}):(0,v.jsx)("span",{className:"text-muted-foreground",children:"Exploring..."})}),h&&x&&(0,v.jsx)("div",{className:"text-xs text-muted-foreground truncate mt-0.5",children:"tool"===x.type?(0,v.jsx)("span",{className:"font-mono",children:x.name}):(0,v.jsx)("span",{className:"italic",children:x.content})}),p&&!m&&(0,v.jsxs)("div",{className:"text-xs text-muted-foreground mt-0.5",children:[f.toolCallCount," actions · ",f.filesExplored," files explored"]})]}),(0,v.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[(0,v.jsxs)(A.Button,{variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs gap-1.5",onClick:()=>u(!0),children:[(0,v.jsx)(xM.default,{className:"size-3"}),"View Progress"]}),(0,v.jsx)("button",{onClick:()=>a(!i),className:"p-1 hover:bg-muted rounded transition-colors",children:i?(0,v.jsx)(ol.ChevronDownIcon,{className:"size-4 text-muted-foreground"}):(0,v.jsx)(aL,{className:"size-4 text-muted-foreground"})})]})]}),i&&(0,v.jsxs)("div",{className:"border-t",children:[(0,v.jsx)("div",{className:"px-3 py-2 bg-muted/30 border-b",children:(0,v.jsxs)("div",{className:"flex items-start gap-2",children:[(0,v.jsx)(mb,{className:"size-3 text-muted-foreground mt-0.5 shrink-0"}),(0,v.jsx)("p",{className:"text-xs text-muted-foreground truncate",title:g,children:xO(g,100)})]})}),y&&(0,v.jsxs)("div",{className:"border-b",children:[(0,v.jsx)("div",{className:"px-3 py-2",children:o?(0,v.jsx)("div",{className:"text-sm text-foreground whitespace-pre-wrap break-words max-h-[300px] overflow-auto",children:y}):(0,v.jsx)("p",{className:"text-sm text-muted-foreground",children:w})}),j&&(0,v.jsx)("button",{onClick:()=>l(!o),className:"w-full px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/50 flex items-center justify-center gap-1 border-t",children:o?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(ol.ChevronDownIcon,{className:"size-3"}),"Show less"]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(aL,{className:"size-3"}),"Show full result"]})})]}),m&&t&&(0,v.jsx)("div",{className:"px-3 py-2 text-xs text-red-400 border-b",children:t.error||"Exploration failed"}),n.length>0&&(0,v.jsxs)("div",{ref:d,className:"max-h-[100px] overflow-auto bg-zinc-950/50",children:[n.slice(-6).map((e,t)=>(0,v.jsx)(xF,{step:e},e.id||t)),n.length>6&&(0,v.jsxs)("div",{className:"px-3 py-1 text-xs text-zinc-500",children:["+",n.length-6," more steps"]})]})]}),(0,v.jsx)(xL,{open:c,onOpenChange:u,title:"Explore Agent",description:"Exploring your codebase to find relevant information",query:g,steps:n,status:h?"running":m?"error":"completed"})]})}function xF({step:e}){let t=(e=>{switch(e){case"grep":return mb;case"glob":case"list_dir":return xP;case"read_file":return gz;default:return xA}})(e.toolName);return(0,v.jsxs)("div",{className:"px-3 py-1 text-xs font-mono border-b border-zinc-800/50 last:border-0 flex items-center gap-2",children:["tool_call"===e.type&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(t,{className:"size-2.5 text-blue-400 shrink-0"}),(0,v.jsx)("span",{className:"text-blue-400 truncate",children:e.toolName})]}),"tool_result"===e.type&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(oo,{className:"size-2.5 text-green-400 shrink-0"}),(0,v.jsx)("span",{className:"text-zinc-500 truncate",children:xO(e.content,50)})]}),"text"===e.type&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(xR,{className:"size-2.5 text-purple-400 shrink-0"}),(0,v.jsx)("span",{className:"text-zinc-400 truncate",children:xO(e.content,50)})]}),"thought"===e.type&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(xR,{className:"size-2.5 text-amber-400 shrink-0"}),(0,v.jsx)("span",{className:"text-zinc-500 italic truncate",children:xO(e.content,50)})]})]})}var gS=gS;let xB=(0,T.default)("trash",[["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);var ou=ou;let x$={pending:oc,in_progress:g5,completed:oo,cancelled:oh},xV={pending:"text-muted-foreground",in_progress:"text-blue-600 dark:text-blue-400",completed:"text-green-600 dark:text-green-400",cancelled:"text-muted-foreground/50"},xU={add:"Add Tasks",list:"List Tasks",mark:"Update Task",clear:"Clear Tasks"},xG=({action:e})=>{switch(e){case"add":return(0,v.jsx)(gS.default,{className:"size-3.5"});case"list":default:return(0,v.jsx)(g3,{className:"size-3.5"});case"mark":return(0,v.jsx)(oo,{className:"size-3.5"});case"clear":return(0,v.jsx)(xB,{className:"size-3.5"})}};function xW({input:e,output:t,status:r,className:n}){let[s,i]=(0,b.useState)(!0),a=e?.action||"list",o="pending"===r||"streaming"===r||"running"===r,l="completed"===r,c="error"===r||t?.success===!1,u=l&&t?.success?oo:c?oh:o?ou.default:g3,d=l&&t?.success?"text-green-600 dark:text-green-500":c?"text-red-600 dark:text-red-500":o?"text-muted-foreground animate-pulse":"text-muted-foreground",h=e=>{let t=x$[e.status]||oc,r=xV[e.status]||"text-muted-foreground";return(0,v.jsxs)("div",{className:"flex items-start gap-2 py-1",children:[(0,v.jsx)(t,{className:(0,k.cn)("size-4 mt-0.5 shrink-0",r)}),(0,v.jsx)("span",{className:(0,k.cn)("text-sm","cancelled"===e.status&&"line-through text-muted-foreground/50","completed"===e.status&&"text-muted-foreground"),children:e.content})]},e.id)};return(0,v.jsxs)("div",{className:(0,k.cn)("rounded-lg border overflow-hidden bg-background",n),children:[(0,v.jsxs)("button",{onClick:()=>i(!s),className:"flex items-center justify-between w-full px-3 py-2.5 bg-muted/50 hover:bg-muted/70 transition-colors",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(u,{className:(0,k.cn)("size-4 shrink-0",d)}),(0,v.jsx)(xG,{action:a}),(0,v.jsx)("span",{className:"font-medium text-sm",children:xU[a]||a}),o&&(0,v.jsx)("span",{className:"text-xs text-muted-foreground animate-pulse",children:"running..."})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[t?.stats&&(0,v.jsx)("div",{className:"flex items-center gap-1.5 text-xs",children:(0,v.jsxs)("span",{className:"text-muted-foreground",children:[t.stats.completed,"/",t.stats.total]})}),t?.itemsAdded!==void 0&&(0,v.jsxs)(C,{variant:"secondary",className:"text-xs bg-green-500/10 text-green-600 dark:text-green-400",children:["+",t.itemsAdded]}),t?.itemsRemoved!==void 0&&(0,v.jsxs)(C,{variant:"secondary",className:"text-xs",children:["cleared ",t.itemsRemoved]}),s?(0,v.jsx)(ol.ChevronDownIcon,{className:"size-4 text-muted-foreground"}):(0,v.jsx)(aL,{className:"size-4 text-muted-foreground"})]})]}),s&&(0,v.jsxs)("div",{className:"border-t",children:[t?.stats&&(0,v.jsxs)("div",{className:"px-3 py-2 bg-muted/30 border-b flex items-center gap-4 text-xs",children:[(0,v.jsxs)("div",{className:"flex items-center gap-1",children:[(0,v.jsx)(oc,{className:"size-3 text-muted-foreground"}),(0,v.jsxs)("span",{children:[t.stats.pending," pending"]})]}),(0,v.jsxs)("div",{className:"flex items-center gap-1",children:[(0,v.jsx)(g5,{className:"size-3 text-blue-500"}),(0,v.jsxs)("span",{children:[t.stats.inProgress," active"]})]}),(0,v.jsxs)("div",{className:"flex items-center gap-1",children:[(0,v.jsx)(oo,{className:"size-3 text-green-500"}),(0,v.jsxs)("span",{children:[t.stats.completed," done"]})]})]}),t?.items&&t.items.length>0&&(0,v.jsx)("div",{className:"px-3 py-2 max-h-[200px] overflow-auto",children:t.items.map(h)}),t?.item&&!t.items&&(0,v.jsx)("div",{className:"px-3 py-2",children:h(t.item)}),"add"===a&&e?.items&&!t?.items&&(0,v.jsx)("div",{className:"px-3 py-2 max-h-[200px] overflow-auto",children:e.items.map((e,t)=>(0,v.jsxs)("div",{className:"flex items-start gap-2 py-1 text-muted-foreground",children:[(0,v.jsx)(oc,{className:"size-4 mt-0.5 shrink-0"}),(0,v.jsx)("span",{className:"text-sm",children:e.content})]},t))}),"list"===a&&t?.items?.length===0&&(0,v.jsx)("div",{className:"px-3 py-4 text-center text-muted-foreground text-sm",children:"No tasks yet"}),t?.error&&(0,v.jsxs)("div",{className:"px-3 py-2 border-t bg-red-500/5 text-red-600 dark:text-red-400 text-xs flex items-start gap-2",children:[(0,v.jsx)(oh,{className:"size-3.5 mt-0.5 shrink-0"}),(0,v.jsx)("span",{children:t.error})]})]})]})}let xq=(0,T.default)("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"}]]);var ou=ou;let xH=(0,T.default)("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]);function xK({input:e,output:t,status:r,className:n}){let[s,i]=(0,b.useState)(!0),a=e?.action||"list",o=e?.skillName||t?.skillName,l="pending"===r||"streaming"===r||"running"===r,c="completed"===r,u="error"===r||t?.success===!1,d=c&&t?.success?oo:u?oh:l?ou.default:xq,h=c&&t?.success?"text-green-600 dark:text-green-500":u?"text-red-600 dark:text-red-500":l?"text-muted-foreground animate-pulse":"text-muted-foreground",p="load"===a?o?`Load: ${o}`:"Load Skill":"List Skills";return(0,v.jsxs)("div",{className:(0,k.cn)("rounded-lg border overflow-hidden bg-background",n),children:[(0,v.jsxs)("button",{onClick:()=>i(!s),className:"flex items-center justify-between w-full px-3 py-2.5 bg-muted/50 hover:bg-muted/70 transition-colors",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(d,{className:(0,k.cn)("size-4 shrink-0",h)}),"list"===a?(0,v.jsx)(xH,{className:"size-3.5 text-muted-foreground"}):(0,v.jsx)(xR,{className:"size-3.5 text-muted-foreground"}),(0,v.jsx)("span",{className:"font-medium text-sm truncate",children:p}),l&&(0,v.jsx)("span",{className:"text-xs text-muted-foreground animate-pulse",children:"loading..."})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[t?.skillCount!==void 0&&(0,v.jsxs)(C,{variant:"secondary",className:"text-xs",children:[t.skillCount," skills"]}),t?.contentLength!==void 0&&(0,v.jsxs)(C,{variant:"secondary",className:"text-xs",children:[Math.round(t.contentLength/1e3),"k chars"]}),s?(0,v.jsx)(ol.ChevronDownIcon,{className:"size-4 text-muted-foreground"}):(0,v.jsx)(aL,{className:"size-4 text-muted-foreground"})]})]}),s&&(0,v.jsxs)("div",{className:"border-t",children:[t?.skills&&t.skills.length>0&&(0,v.jsx)("div",{className:"max-h-[200px] overflow-auto",children:t.skills.map((e,r)=>(0,v.jsxs)("div",{className:(0,k.cn)("px-3 py-2 flex items-start gap-2",r<t.skills.length-1&&"border-b"),children:[(0,v.jsx)(xq,{className:"size-4 mt-0.5 shrink-0 text-muted-foreground"}),(0,v.jsxs)("div",{className:"min-w-0",children:[(0,v.jsx)("div",{className:"font-medium text-sm",children:e.name}),e.description&&(0,v.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:e.description})]})]},e.name))}),"load"===a&&t?.success&&t.skillName&&(0,v.jsxs)("div",{className:"px-3 py-2 bg-muted/30",children:[(0,v.jsxs)("div",{className:"flex items-center justify-between",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)(xR,{className:"size-4 text-green-600 dark:text-green-400"}),(0,v.jsx)("span",{className:"font-medium text-sm",children:t.skillName})]}),t.content&&(0,v.jsx)(A.Button,{variant:"ghost",size:"icon",className:"size-6",onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(t.content)},children:(0,v.jsx)(om,{className:"size-3"})})]}),t.description&&(0,v.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:t.description})]}),t?.content&&(0,v.jsx)("div",{className:"max-h-[150px] overflow-auto border-t",children:(0,v.jsxs)("pre",{className:"px-3 py-2 text-xs font-mono text-muted-foreground whitespace-pre-wrap",children:[t.content.slice(0,500),t.content.length>500&&"..."]})}),t?.availableSkills&&t.availableSkills.length>0&&(0,v.jsx)("div",{className:"px-3 py-2 bg-muted/30 border-t",children:(0,v.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Available: ",t.availableSkills.join(", ")]})}),"list"===a&&t?.skills?.length===0&&(0,v.jsx)("div",{className:"px-3 py-4 text-center text-muted-foreground text-sm",children:"No skills available"}),t?.error&&(0,v.jsxs)("div",{className:"px-3 py-2 border-t bg-red-500/5 text-red-600 dark:text-red-400 text-xs flex items-start gap-2",children:[(0,v.jsx)(oh,{className:"size-3.5 mt-0.5 shrink-0"}),(0,v.jsx)("span",{children:t.error})]})]})]})}var xN=xN;let xX=(0,T.default)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),xY=(0,T.default)("search-code",[["path",{d:"m13 13.5 2-2.5-2-2.5",key:"1rvxrh"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}],["path",{d:"M9 8.5 7 11l2 2.5",key:"6ffwbx"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);function xJ({severity:e,className:t}){switch(e){case"error":return(0,v.jsx)(xN.default,{className:(0,k.cn)("text-red-500",t)});case"warning":return(0,v.jsx)(xt,{className:(0,k.cn)("text-yellow-500",t)});case"info":return(0,v.jsx)(xX,{className:(0,k.cn)("text-blue-500",t)});default:return(0,v.jsx)(xX,{className:(0,k.cn)("text-muted-foreground",t)})}}function xZ({file:e,isExpanded:t,onToggle:r}){let n=e.errors>0,s=e.warnings>0;return(0,v.jsxs)("div",{className:"border-b last:border-b-0",children:[(0,v.jsxs)("button",{onClick:r,className:"flex items-center justify-between w-full px-3 py-2 hover:bg-muted/50 transition-colors text-left",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(xc,{className:"size-3.5 text-muted-foreground shrink-0"}),(0,v.jsx)("span",{className:"font-mono text-sm truncate",children:e.relativePath}),n&&(0,v.jsxs)(C,{variant:"destructive",className:"text-xs gap-1",children:[(0,v.jsx)(xN.default,{className:"size-3"}),e.errors]}),s&&(0,v.jsxs)(C,{variant:"secondary",className:"text-xs gap-1 bg-yellow-500/10 text-yellow-600 dark:text-yellow-400",children:[(0,v.jsx)(xt,{className:"size-3"}),e.warnings]})]}),t?(0,v.jsx)(ol.ChevronDownIcon,{className:"size-4 text-muted-foreground shrink-0"}):(0,v.jsx)(aL,{className:"size-4 text-muted-foreground shrink-0"})]}),t&&e.diagnostics.length>0&&(0,v.jsx)("div",{className:"bg-muted/30 px-3 py-2 space-y-1",children:e.diagnostics.map((e,t)=>(0,v.jsxs)("div",{className:(0,k.cn)("flex items-start gap-2 px-2 py-1.5 rounded text-sm","error"===e.severity&&"bg-red-500/5","warning"===e.severity&&"bg-yellow-500/5"),children:[(0,v.jsx)(xJ,{severity:e.severity,className:"size-4 mt-0.5 shrink-0"}),(0,v.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,v.jsxs)("span",{className:"font-mono text-xs text-muted-foreground shrink-0",children:[e.line,":",e.column]}),e.source&&(0,v.jsx)(C,{variant:"outline",className:"text-xs",children:e.source}),e.code&&(0,v.jsxs)("span",{className:"text-xs text-muted-foreground font-mono",children:["[",e.code,"]"]})]}),(0,v.jsx)("p",{className:"text-sm mt-0.5 break-words",children:e.message})]})]},t))})]})}function xQ({input:e,output:t,status:r,className:n}){let[s,i]=(0,b.useState)(!0),[a,o]=(0,b.useState)(new Set),l="pending"===r||"streaming"===r||"running"===r||"completed"===r&&!t,c="completed"===r&&t?.success===!0,u="error"===r||t?.success===!1,d=t?.totalErrors??0,h=t?.totalWarnings??0,p=d>0||h>0,m=t?.files?.length??0,f=(0,b.useMemo)(()=>e.paths&&0!==e.paths.length?1===e.paths.length?e.paths[0]:`${e.paths.length} paths`:"all files",[e.paths]),g=(0,b.useMemo)(()=>t?.files?.filter(e=>e.errors>0)||[],[t?.files]);(0,b.useMemo)(()=>{g.length>0&&0===a.size&&o(new Set(g.slice(0,5).map(e=>e.path)))},[g]);let x=p?xN.default:c?oo:u?xN.default:xY,y=p?"text-red-500":c?"text-green-500":u?"text-red-500":"text-muted-foreground";return(0,v.jsxs)("div",{className:(0,k.cn)("rounded-lg border overflow-hidden bg-background",n),children:[(0,v.jsxs)("button",{onClick:()=>i(!s),className:"flex items-center justify-between w-full px-3 py-2.5 bg-muted/50 hover:bg-muted/70 transition-colors",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(x,{className:(0,k.cn)("size-4 shrink-0",y)}),(0,v.jsx)("span",{className:"font-medium text-sm",children:"Linter"}),(0,v.jsxs)("span",{className:"text-xs text-muted-foreground truncate",children:[c?"checked":"checking"," ",f]}),l&&(0,v.jsx)("span",{className:"text-xs text-muted-foreground animate-pulse",children:"analyzing..."})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[c&&(0,v.jsxs)(v.Fragment,{children:[d>0&&(0,v.jsxs)(C,{variant:"destructive",className:"text-xs gap-1",children:[(0,v.jsx)(xN.default,{className:"size-3"}),d," error",1!==d?"s":""]}),h>0&&(0,v.jsxs)(C,{variant:"secondary",className:"text-xs gap-1 bg-yellow-500/10 text-yellow-600 dark:text-yellow-400",children:[(0,v.jsx)(xt,{className:"size-3"}),h," warning",1!==h?"s":""]}),!p&&(0,v.jsxs)(C,{variant:"secondary",className:"text-xs gap-1 bg-green-500/10 text-green-600 dark:text-green-400",children:[(0,v.jsx)(oo,{className:"size-3"}),"No issues"]})]}),s?(0,v.jsx)(ol.ChevronDownIcon,{className:"size-4 text-muted-foreground"}):(0,v.jsx)(aL,{className:"size-4 text-muted-foreground"})]})]}),s&&(0,v.jsxs)("div",{className:"border-t",children:[l?(0,v.jsxs)("div",{className:"px-3 py-8 text-center text-muted-foreground text-sm",children:[(0,v.jsx)(xY,{className:"size-6 mx-auto mb-2 animate-pulse"}),(0,v.jsx)("span",{children:"Analyzing files for lint errors..."})]}):u&&t?.error?(0,v.jsxs)("div",{className:"px-3 py-4 text-red-600 dark:text-red-400 text-sm flex items-start gap-2",children:[(0,v.jsx)(xN.default,{className:"size-4 mt-0.5 shrink-0"}),(0,v.jsx)("span",{children:t.error})]}):t?.files&&t.files.length>0?(0,v.jsx)("div",{className:"max-h-[400px] overflow-y-auto",children:t.files.map(e=>(0,v.jsx)(xZ,{file:e,isExpanded:a.has(e.path),onToggle:()=>{var t;return t=e.path,void o(e=>{let r=new Set(e);return r.has(t)?r.delete(t):r.add(t),r})}},e.path))}):(0,v.jsx)("div",{className:"px-3 py-4 text-sm",children:t?.message?(0,v.jsxs)("div",{className:"flex items-center gap-2 text-green-600 dark:text-green-400",children:[(0,v.jsx)(oo,{className:"size-4"}),(0,v.jsx)("span",{children:t.message})]}):(0,v.jsx)("div",{className:"text-muted-foreground italic",children:"No files analyzed yet."})}),c&&m>0&&(0,v.jsxs)("div",{className:"px-3 py-2 border-t bg-muted/30 text-xs text-muted-foreground",children:["Checked ",m," file",1!==m?"s":"",p&&(0,v.jsxs)("span",{children:[" • ",(0,v.jsxs)("span",{className:d>0?"text-red-500":"",children:[d," error",1!==d?"s":""]})," • ",(0,v.jsxs)("span",{className:h>0?"text-yellow-500":"",children:[h," warning",1!==h?"s":""]})]})]})]})]})}let x0=(0,T.default)("loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]),x1=(0,T.default)("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]),x2=(0,T.default)("mic-off",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M16.95 16.95A7 7 0 0 1 5 12v-2",key:"cqa7eg"}],["path",{d:"M18.89 13.23A7 7 0 0 0 19 12v-2",key:"16hl24"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}]]),x5=({className:e,onTranscriptionChange:t,onInterimTranscription:r,onAudioRecorded:n,lang:s="en-US",disabled:i,...a})=>{let[o,l]=(0,b.useState)(!1),[c,u]=(0,b.useState)(!1),[d,h]=(0,b.useState)("none"),p=(0,b.useRef)(null),m=(0,b.useRef)(null),f=(0,b.useRef)([]),g=(0,b.useRef)("");(0,b.useEffect)(()=>{h("SpeechRecognition"in window||"webkitSpeechRecognition"in window?"speech-recognition":"MediaRecorder"in window&&"mediaDevices"in navigator?"media-recorder":"none")},[]),(0,b.useEffect)(()=>{if("speech-recognition"!==d)return;let e=new(window.SpeechRecognition||window.webkitSpeechRecognition);return e.continuous=!0,e.interimResults=!0,e.lang=s,e.onstart=()=>{l(!0),g.current=""},e.onend=()=>{l(!1),r?.("")},e.onresult=e=>{let n="",s="";for(let t=e.resultIndex;t<e.results.length;t++){let r=e.results[t],i=r[0]?.transcript??"";r.isFinal?s+=i:n+=i}s&&(g.current+=s,t?.(s),r?.("")),n&&r?.(n)},e.onerror=e=>{console.error("Speech recognition error:",e.error),l(!1),r?.("")},p.current=e,()=>{p.current&&p.current.abort()}},[d,s,t,r]);let x=(0,b.useCallback)(async()=>{if(!n)return void console.warn("SpeechInput: onAudioRecorded callback is required for MediaRecorder fallback");try{let e=await navigator.mediaDevices.getUserMedia({audio:!0}),r=new MediaRecorder(e);f.current=[],r.ondataavailable=e=>{e.data.size>0&&f.current.push(e.data)},r.onstop=async()=>{for(let t of e.getTracks())t.stop();let r=new Blob(f.current,{type:"audio/webm"});if(r.size>0){u(!0);try{let e=await n(r);e&&t?.(e)}catch(e){console.error("Transcription error:",e)}finally{u(!1)}}},r.onerror=t=>{for(let r of(console.error("MediaRecorder error:",t),l(!1),e.getTracks()))r.stop()},m.current=r,r.start(),l(!0)}catch(e){console.error("Failed to start MediaRecorder:",e),l(!1)}},[n,t]),y=(0,b.useCallback)(()=>{m.current?.state==="recording"&&m.current.stop(),l(!1)},[]),w=(0,b.useCallback)(()=>{if("speech-recognition"===d&&p.current)if(o)p.current.stop();else try{p.current.start()}catch(e){console.warn("Speech recognition start error:",e)}else"media-recorder"===d&&(o?y():x())},[d,o,x,y]),j=i||"none"===d||"speech-recognition"===d&&!p.current||"media-recorder"===d&&!n||c;return"none"===d?(0,v.jsx)(A.Button,{type:"button",className:(0,k.cn)("relative rounded-full opacity-50 cursor-not-allowed",e),disabled:!0,title:"Speech recognition not supported in this browser",...a,children:(0,v.jsx)(x2,{className:"size-4"})}):(0,v.jsxs)("div",{className:"relative inline-flex items-center justify-center",children:[o&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("span",{className:"absolute inset-0 rounded-full bg-red-500/20 animate-ping"}),(0,v.jsx)("span",{className:"absolute inset-0 rounded-full bg-red-500/10 animate-ping",style:{animationDelay:"0.2s"}})]}),(0,v.jsxs)(A.Button,{type:"button",className:(0,k.cn)("relative z-10 rounded-full transition-all duration-200",o?"bg-red-500 text-white hover:bg-red-600 shadow-lg shadow-red-500/25":"hover:bg-muted",e),disabled:j,onClick:w,title:o?"Stop recording":"Start voice input",variant:o?"default":"ghost",...a,children:[c&&(0,v.jsx)(x0,{className:"size-4 animate-spin"}),!c&&o&&(0,v.jsxs)("div",{className:"relative",children:[(0,v.jsx)(x1,{className:"size-4"}),(0,v.jsx)("span",{className:"absolute -top-0.5 -right-0.5 size-2 bg-white rounded-full animate-pulse"})]}),!(c||o)&&(0,v.jsx)(x1,{className:"size-4"})]})]})};function x3(e){var t;let r,n=(t=e,(r=b.forwardRef((e,t)=>{let{children:r,...n}=e;if(b.isValidElement(r)){var s;let e,i,a=(s=r,(i=(e=Object.getOwnPropertyDescriptor(s.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.ref:(i=(e=Object.getOwnPropertyDescriptor(s,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.props.ref:s.props.ref||s.ref),o=function(e,t){let r={...t};for(let n in t){let s=e[n],i=t[n];/^on[A-Z]/.test(n)?s&&i?r[n]=(...e)=>{let t=i(...e);return s(...e),t}:s&&(r[n]=s):"style"===n?r[n]={...s,...i}:"className"===n&&(r[n]=[s,i].filter(Boolean).join(" "))}return{...e,...r}}(n,r.props);return r.type!==b.Fragment&&(o.ref=t?(0,aY.composeRefs)(t,a):a),b.cloneElement(r,o)}return b.Children.count(r)>1?b.Children.only(null):null})).displayName=`${t}.SlotClone`,r),s=b.forwardRef((e,t)=>{let{children:r,...s}=e,i=b.Children.toArray(r),a=i.find(x4);if(a){let e=a.props.children,r=i.map(t=>t!==a?t:b.Children.count(e)>1?b.Children.only(null):b.isValidElement(e)?e.props.children:null);return(0,v.jsx)(n,{...s,ref:t,children:b.isValidElement(e)?b.cloneElement(e,void 0,r):null})}return(0,v.jsx)(n,{...s,ref:t,children:r})});return s.displayName=`${e}.Slot`,s}var x6=Symbol("radix.slottable");function x4(e){return b.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===x6}var x8=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let r=x3(`Primitive.${t}`),n=b.forwardRef((e,n)=>{let{asChild:s,...i}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,v.jsx)(s?r:t,{...i,ref:n})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),x9="Popover",[x7,ye]=function(e,t=[]){let r=[],n=()=>{let t=r.map(e=>b.createContext(e));return function(r){let n=r?.[e]||t;return b.useMemo(()=>({[`__scope${e}`]:{...r,[e]:n}}),[r,n])}};return n.scopeName=e,[function(t,n){let s=b.createContext(n),i=r.length;r=[...r,n];let a=t=>{let{scope:r,children:n,...a}=t,o=r?.[e]?.[i]||s,l=b.useMemo(()=>a,Object.values(a));return(0,v.jsx)(o.Provider,{value:l,children:n})};return a.displayName=t+"Provider",[a,function(r,a){let o=a?.[e]?.[i]||s,l=b.useContext(o);if(l)return l;if(void 0!==n)return n;throw Error(`\`${r}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let r=()=>{let r=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let n=r.reduce((t,{useScope:r,scopeName:n})=>{let s=r(e)[`__scope${n}`];return{...t,...s}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:n}),[n])}};return r.scopeName=t.scopeName,r}(n,...t)]}(x9,[mL.createPopperScope]),yt=(0,mL.createPopperScope)(),[yr,yn]=x7(x9),ys=e=>{let{__scopePopover:t,children:r,open:n,defaultOpen:s,onOpenChange:i,modal:a=!1}=e,o=yt(t),l=b.useRef(null),[c,u]=b.useState(!1),[d,h]=(0,aK.useControllableState)({prop:n,defaultProp:s??!1,onChange:i,caller:x9});return(0,v.jsx)(mL.Root,{...o,children:(0,v.jsx)(yr,{scope:t,contentId:(0,a1.useId)(),triggerRef:l,open:d,onOpenChange:h,onOpenToggle:b.useCallback(()=>h(e=>!e),[h]),hasCustomAnchor:c,onCustomAnchorAdd:b.useCallback(()=>u(!0),[]),onCustomAnchorRemove:b.useCallback(()=>u(!1),[]),modal:a,children:r})})};ys.displayName=x9;var yi="PopoverAnchor",ya=b.forwardRef((e,t)=>{let{__scopePopover:r,...n}=e,s=yn(yi,r),i=yt(r),{onCustomAnchorAdd:a,onCustomAnchorRemove:o}=s;return b.useEffect(()=>(a(),()=>o()),[a,o]),(0,v.jsx)(mL.Anchor,{...i,...n,ref:t})});ya.displayName=yi;var yo="PopoverTrigger";b.forwardRef((e,t)=>{let{__scopePopover:r,...n}=e,s=yn(yo,r),i=yt(r),a=(0,aY.useComposedRefs)(t,s.triggerRef),o=(0,v.jsx)(x8.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":yv(s.open),...n,ref:a,onClick:(0,aH.composeEventHandlers)(e.onClick,s.onOpenToggle)});return s.hasCustomAnchor?o:(0,v.jsx)(mL.Anchor,{asChild:!0,...i,children:o})}).displayName=yo;var yl="PopoverPortal",[yc,yu]=x7(yl,{forceMount:void 0}),yd=e=>{let{__scopePopover:t,forceMount:r,children:n,container:s}=e,i=yn(yl,t);return(0,v.jsx)(yc,{scope:t,forceMount:r,children:(0,v.jsx)(a0.Presence,{present:r||i.open,children:(0,v.jsx)(mD.Portal,{asChild:!0,container:s,children:n})})})};yd.displayName=yl;var yh="PopoverContent",yp=b.forwardRef((e,t)=>{let r=yu(yh,e.__scopePopover),{forceMount:n=r.forceMount,...s}=e,i=yn(yh,e.__scopePopover);return(0,v.jsx)(a0.Presence,{present:n||i.open,children:i.modal?(0,v.jsx)(yf,{...s,ref:t}):(0,v.jsx)(yg,{...s,ref:t})})});yp.displayName=yh;var ym=x3("PopoverContent.RemoveScroll"),yf=b.forwardRef((e,t)=>{let r=yn(yh,e.__scopePopover),n=b.useRef(null),s=(0,aY.useComposedRefs)(t,n),i=b.useRef(!1);return b.useEffect(()=>{let e=n.current;if(e)return(0,m8.hideOthers)(e)},[]),(0,v.jsx)(m9.RemoveScroll,{as:ym,allowPinchZoom:!0,children:(0,v.jsx)(yx,{...e,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:(0,aH.composeEventHandlers)(e.onCloseAutoFocus,e=>{e.preventDefault(),i.current||r.triggerRef.current?.focus()}),onPointerDownOutside:(0,aH.composeEventHandlers)(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,r=0===t.button&&!0===t.ctrlKey;i.current=2===t.button||r},{checkForDefaultPrevented:!1}),onFocusOutside:(0,aH.composeEventHandlers)(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),yg=b.forwardRef((e,t)=>{let r=yn(yh,e.__scopePopover),n=b.useRef(!1),s=b.useRef(!1);return(0,v.jsx)(yx,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(n.current||r.triggerRef.current?.focus(),t.preventDefault()),n.current=!1,s.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(n.current=!0,"pointerdown"===t.detail.originalEvent.type&&(s.current=!0));let i=t.target;r.triggerRef.current?.contains(i)&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&s.current&&t.preventDefault()}})}),yx=b.forwardRef((e,t)=>{let{__scopePopover:r,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...d}=e,h=yn(yh,r),p=yt(r);return(0,mM.useFocusGuards)(),(0,v.jsx)(mI.FocusScope,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:i,children:(0,v.jsx)(mR.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:u,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1),children:(0,v.jsx)(mL.Content,{"data-state":yv(h.open),role:"dialog",id:h.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),yy="PopoverClose";function yv(e){return e?"open":"closed"}function yb({...e}){return(0,v.jsx)(ys,{"data-slot":"popover",...e})}function yw({className:e,align:t="center",sideOffset:r=4,...n}){return(0,v.jsx)(yd,{children:(0,v.jsx)(yp,{"data-slot":"popover-content",align:t,sideOffset:r,className:(0,k.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...n})})}function yk({...e}){return(0,v.jsx)(ya,{"data-slot":"popover-anchor",...e})}b.forwardRef((e,t)=>{let{__scopePopover:r,...n}=e,s=yn(yy,r);return(0,v.jsx)(x8.button,{type:"button",...n,ref:t,onClick:(0,aH.composeEventHandlers)(e.onClick,()=>s.onOpenChange(!1))})}).displayName=yy,b.forwardRef((e,t)=>{let{__scopePopover:r,...n}=e,s=yt(r);return(0,v.jsx)(mL.Arrow,{...s,...n,ref:t})}).displayName="PopoverArrow";let yj=(0,T.default)("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]),yN=(0,T.default)("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),yS=(0,b.createContext)(null),yC=/@([\w./-]+\/?)/g,yA=[{id:"help",name:"help",description:"Ask about available features",icon:(0,v.jsx)(yN,{className:"size-4"}),prompt:"What commands and features are available? How can you help me?"},{id:"terminal",name:"terminal",description:"Open a new terminal",icon:(0,v.jsx)(xA,{className:"size-4"}),prompt:"Please open a new terminal session for me."},{id:"explain",name:"explain",description:"Explain a file or code",icon:(0,v.jsx)(xc,{className:"size-4"}),prompt:"Please explain this code: "},{id:"fix",name:"fix",description:"Fix a bug or issue",icon:(0,v.jsx)(yj,{className:"size-4"}),prompt:"Please help me fix this issue: "},{id:"refactor",name:"refactor",description:"Refactor code",icon:(0,v.jsx)(yj,{className:"size-4"}),prompt:"Please refactor this code to be cleaner and more maintainable: "},{id:"test",name:"test",description:"Write tests",icon:(0,v.jsx)(yj,{className:"size-4"}),prompt:"Please write tests for: "}];function y_({children:e}){let t=(0,b.useCallback)(e=>{let t,r=[],n=RegExp(yC.source,"g");for(;null!==(t=n.exec(e));){let e=t[1],n=e.endsWith("/");r.push({id:`mention-${t.index}`,type:n?"folder":"file",path:n?e.slice(0,-1):e,name:e.split("/").pop()?.replace(/\/$/,"")||e})}return r},[]),r=(0,b.useCallback)(()=>{},[]),n=(0,b.useMemo)(()=>({extractMentions:t,clear:r}),[t,r]);return(0,v.jsx)(yS.Provider,{value:n,children:e})}function yT({sessionId:e,value:t,onChange:r,onSlashCommand:n,slashCommands:s=yA,showHighlights:i=!0,className:a,onKeyDown:o,disabled:l,...c}){let u=(0,b.useRef)(null),d=(0,b.useRef)(null),[h,p]=(0,b.useState)(null),[m,f]=(0,b.useState)(0),[g,x]=(0,b.useState)({top:0,left:0}),[y,w]=(0,b.useState)(!1),j=gP(),{files:N,isLoading:S}=function({sessionId:e,query:t,enabled:r=!0,limit:n=20,debounceMs:s=150}){let[i,a]=(0,b.useState)([]),[o,l]=(0,b.useState)(!1),[c,u]=(0,b.useState)(null),[d,h]=(0,b.useState)(null),p=(0,b.useRef)(null),m=(0,b.useRef)(null),f=(0,b.useCallback)(async t=>{m.current&&m.current.abort(),m.current=new AbortController;try{l(!0),u(null);let r=await (0,g1.getWorkspaceFiles)(e,t,n);a(r.files),h(r.workingDirectory),r.error&&u(r.error)}catch(e){e instanceof Error&&"AbortError"!==e.name&&(u(e.message),a([]))}finally{l(!1)}},[e,n]);return(0,b.useEffect)(()=>r&&e?(p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{f(t)},s),()=>{p.current&&clearTimeout(p.current)}):void a([]),[t,r,e,s,f]),(0,b.useEffect)(()=>()=>{m.current&&m.current.abort(),p.current&&clearTimeout(p.current)},[]),{files:i,isLoading:o,error:c,workingDirectory:d}}({sessionId:e,query:h?.type==="file"?h.query:"",enabled:h?.type==="file",limit:15}),C=(0,b.useMemo)(()=>{if(h?.type!=="command")return[];let e=h.query.toLowerCase();return s.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e))},[h,s]),A=h?.type==="file"?N:C,_=null!==h&&(A.length>0||S),T=(0,b.useCallback)(()=>{let e=u.current;if(!e||!h)return;let r=document.createElement("div"),n=window.getComputedStyle(e);["fontFamily","fontSize","fontWeight","lineHeight","padding","paddingLeft","paddingTop","border","borderWidth","boxSizing","whiteSpace","wordWrap","wordBreak"].forEach(e=>{r.style[e]=n[e]}),r.style.position="absolute",r.style.visibility="hidden",r.style.height="auto",r.style.width=`${e.clientWidth}px`,r.style.overflow="hidden",r.textContent=t.substring(0,h.startIndex);let s=document.createElement("span");s.textContent="|",r.appendChild(s),document.body.appendChild(r);let i=e.getBoundingClientRect(),a=s.getBoundingClientRect(),o=r.getBoundingClientRect(),l=a.left-o.left,c=a.top-o.top+parseInt(n.lineHeight),d=e.scrollTop;document.body.removeChild(r),x({left:Math.min(l,i.width-250),top:c-d+4})},[h,t]);(0,b.useEffect)(()=>{T()},[T]);let E=(0,b.useCallback)((e,t)=>{if(0===t)return void p(null);let r=e.slice(0,t),n=r.match(/@([^\s@]*)$/);if(n){p({type:"file",query:n[1],startIndex:t-n[0].length,endIndex:t}),f(0);return}let s=r.match(/(?:^|\s)\/([^\s]*)$/);if(s){p({type:"command",query:s[1],startIndex:t-s[1].length-1,endIndex:t}),f(0);return}p(null)},[]),P=(0,b.useCallback)(e=>{let t=e.target.value,n=e.target.selectionStart??0;r(t),E(t,n)},[r,E]),R=(0,b.useCallback)(e=>{if(h&&u.current){if("file"===h.type&&"path"in e){let n=t.slice(0,h.startIndex),s=t.slice(h.endIndex),i=`@${e.path}${"folder"===e.type?"/":""} `;r(n+i+s),setTimeout(()=>{if(u.current){let e=h.startIndex+i.length;u.current.selectionStart=e,u.current.selectionEnd=e,u.current.focus()}},0)}else if("command"===h.type&&"description"in e){if(e.action)e.action(),n?.(e),r((t.slice(0,h.startIndex)+t.slice(h.endIndex)).trim());else if(e.prompt){let n=t.slice(0,h.startIndex),s=t.slice(h.endIndex);r(n+e.prompt+s),setTimeout(()=>{if(u.current){let t=h.startIndex+e.prompt.length;u.current.selectionStart=t,u.current.selectionEnd=t,u.current.focus()}},0)}else n?.(e),r((t.slice(0,h.startIndex)+t.slice(h.endIndex)).trim());setTimeout(()=>{u.current?.focus()},0)}p(null)}},[h,t,r,n]),M=(0,b.useCallback)(e=>{if(o?.(e),!e.defaultPrevented){if(_)switch(e.key){case"ArrowDown":e.preventDefault(),f(e=>(e+1)%A.length);return;case"ArrowUp":e.preventDefault(),f(e=>(e-1+A.length)%A.length);return;case"Tab":case"Enter":A.length>0&&(e.preventDefault(),R(A[m]));return;case"Escape":e.preventDefault(),p(null);return}if("Enter"===e.key){if(y||e.nativeEvent.isComposing||e.shiftKey)return;e.preventDefault();let t=e.currentTarget,r=t.form||t.closest("form");if(r){let e=r.querySelector('button[type="submit"]');if(e?.disabled)return;e?e.click():r.requestSubmit()}}if("Backspace"===e.key&&""===t&&j.files.length>0){e.preventDefault();let t=j.files.at(-1);t&&j.remove(t.id)}}},[_,A,m,R,o,y,t,j]),I=(0,b.useCallback)(e=>{let t=e.clipboardData?.items;if(!t)return;let r=[];for(let e of t)if("file"===e.kind){let t=e.getAsFile();t&&r.push(t)}r.length>0&&(e.preventDefault(),j.add(r))},[j]),L=(0,b.useCallback)(()=>{let e=u.current;e&&E(t,e.selectionStart??0)},[t,E]),D=(0,b.useCallback)(()=>{u.current&&d.current&&(d.current.scrollTop=u.current.scrollTop)},[]);return(0,v.jsxs)("div",{className:"relative w-full",children:[(0,v.jsxs)(yb,{open:_,onOpenChange:()=>p(null),children:[(0,v.jsx)(yk,{style:{position:"absolute",left:g.left,top:g.top,width:0,height:0}}),(0,v.jsx)(yw,{align:"start",side:"top",className:"w-64 p-0",onOpenAutoFocus:e=>e.preventDefault(),children:(0,v.jsx)(mk,{children:(0,v.jsxs)(mj,{children:[S&&h?.type==="file"&&(0,v.jsx)("div",{className:"p-2 text-sm text-muted-foreground text-center",children:"Loading..."}),!S&&0===A.length&&(0,v.jsx)(mN,{children:h?.type==="file"?"No files found":"No commands found"}),h?.type==="file"&&N.length>0&&(0,v.jsx)(mS,{heading:"Files & Folders",children:N.map((e,t)=>(0,v.jsxs)(mC,{onSelect:()=>R(e),className:(0,k.cn)("cursor-pointer",t===m&&"bg-accent"),children:["folder"===e.type?(0,v.jsx)(xP,{className:"mr-2 size-4 text-blue-500"}):(0,v.jsx)(xc,{className:"mr-2 size-4 text-muted-foreground"}),(0,v.jsx)("span",{className:"truncate",children:e.path})]},e.path))}),h?.type==="command"&&C.length>0&&(0,v.jsx)(mS,{heading:"Commands",children:C.map((e,t)=>(0,v.jsxs)(mC,{onSelect:()=>R(e),className:(0,k.cn)("cursor-pointer",t===m&&"bg-accent"),children:[e.icon||(0,v.jsx)(yj,{className:"mr-2 size-4"}),(0,v.jsxs)("div",{className:"flex flex-col ml-2",children:[(0,v.jsxs)("span",{className:"font-medium",children:["/",e.name]}),(0,v.jsx)("span",{className:"text-xs text-muted-foreground",children:e.description})]})]},e.id))})]})})})]}),i&&(0,v.jsx)("div",{ref:d,"aria-hidden":"true",className:"absolute inset-0 pointer-events-none overflow-hidden whitespace-pre-wrap break-words px-3 py-3 text-sm",style:{color:"transparent"},children:(()=>{let e,r=[],n=RegExp(yC.source,"g"),s=0;for(;null!==(e=n.exec(t));)e.index>s&&r.push((0,v.jsx)("span",{children:t.slice(s,e.index)},`text-${s}`)),r.push((0,v.jsx)("mark",{className:"bg-primary/20 text-transparent rounded-sm",children:e[0]},`mention-${e.index}`)),s=e.index+e[0].length;return s<t.length&&r.push((0,v.jsx)("span",{children:t.slice(s)},`text-${s}`)),r.push((0,v.jsx)("span",{children:"\n"},"trailing")),r})()}),(0,v.jsx)("textarea",{ref:u,name:"message","data-slot":"input-group-control",value:t,onChange:P,onKeyDown:M,onClick:L,onScroll:D,onPaste:I,onCompositionStart:()=>w(!0),onCompositionEnd:()=>w(!1),disabled:l,className:(0,k.cn)("flex-1 w-full resize-none rounded-none border-0 py-3 px-3 text-sm shadow-none","placeholder:text-muted-foreground focus-visible:ring-0 focus-visible:outline-none","disabled:cursor-not-allowed disabled:opacity-50","bg-transparent dark:bg-transparent",a),...c})]})}let yE=/\s*<devtools-context>[\s\S]*?<\/devtools-context>\s*/;function yP(){let{toggleSidebar:e,isMobile:t}=(0,xy.useSidebar)();return t?(0,v.jsxs)(A.Button,{size:"icon",variant:"ghost",onClick:e,className:"size-7 shrink-0",children:[(0,v.jsx)(xl.PanelLeft,{className:"size-4"}),(0,v.jsx)("span",{className:"sr-only",children:"Toggle sidebar"})]}):null}function yR(){let e=gP();return 0===e.files.length?null:(0,v.jsx)(gH,{variant:"inline",children:e.files.map(t=>(0,v.jsxs)(gK,{data:t,onRemove:()=>e.remove(t.id),children:[(0,v.jsx)(gX,{}),(0,v.jsx)(gY,{}),(0,v.jsx)(gJ,{})]},t.id))})}function yM({input:e,isRunning:t,onStop:r,hasExtraContent:n}){let s=gP(),i=e.trim()||s.files.length>0||!!n;return t&&i?(0,v.jsxs)("div",{className:"flex items-center gap-1",children:[(0,v.jsx)(gO,{disabled:!1,status:"ready",className:"bg-primary hover:bg-primary/90 transition-colors"}),(0,v.jsx)(gO,{disabled:!1,status:"streaming",onStop:r,className:"bg-destructive/80 hover:bg-destructive transition-colors"})]}):(0,v.jsx)(gO,{disabled:!t&&!i,status:t?"streaming":"ready",onStop:r,className:"bg-primary hover:bg-primary/90 transition-colors"})}function yI({session:e,isEmbed:t=!1}){let{toggleSidebar:r}=(0,xy.useSidebar)(),[n,s]=(0,b.useState)([]),[i,a]=(0,b.useState)(""),[o,l]=(0,b.useState)(""),[c,u]=(0,b.useState)(null),[d,h]=(0,b.useState)(!1),[p,m]=(0,b.useState)([]),[f,g]=(0,b.useState)(null),[x,y]=(0,b.useState)(""),[j,N]=(0,b.useState)(!0),[S,T]=(0,b.useState)(!1),[E,P]=(0,b.useState)([]),[R,M]=(0,b.useState)([]),[I,L]=(0,b.useState)(!1),[D,O]=(0,b.useState)(null),[z,F]=(0,b.useState)(""),[B,W]=(0,b.useState)(""),[q,H]=(0,b.useState)(!1),[K,X]=(0,b.useState)([]),[Y,J]=(0,b.useState)([]),[Z,Q]=(0,b.useState)(null),[ee,et]=(0,b.useState)([]),[er,en]=(0,b.useState)(!1),es=(0,b.useRef)(""),ei=(0,b.useRef)(""),ea=(0,b.useRef)([]),[eo,el]=(0,b.useState)(!1),ec=(0,b.useRef)(null),eu=(0,b.useRef)(null),ed=(0,b.useRef)(!1),eh=(0,b.useRef)(!1),ep=(0,b.useRef)(new Map),[em,ef]=(0,b.useState)(e.model),[eg,ex]=(0,b.useState)(e.name||""),[ey,ev]=(0,b.useState)(!1),[eb,ew]=(0,b.useState)(null),[ek,ej]=(0,b.useState)(e.config||{}),[eN,eS]=(0,b.useState)(!1),eC=(0,b.useRef)(null),[eA,e_]=(0,b.useState)(null),[eT,eE]=(0,b.useState)(!1),[eP,eR]=(0,b.useState)(!1);(0,b.useEffect)(()=>{(0,g9.getConfig)().then(ew)},[]),(0,b.useEffect)(()=>{let e=localStorage.getItem("sparkecoder-dismissed-version");(0,g1.checkVersion)().then(t=>{t.updateAvailable&&t.latestVersion!==e&&e_(t)}).catch(e=>{console.error("Failed to check version:",e)})},[]),(0,b.useEffect)(()=>{ef(e.model),ex(e.name||""),ej(e.config||{})},[e.id,e.model,e.name,e.config]),(0,b.useEffect)(()=>{ey&&eC.current&&(eC.current.focus(),eC.current.select())},[ey]);let eM=async t=>{ef(t);try{await (0,g1.updateSession)(e.id,{model:t}),(0,g7.mutateSessions)()}catch(t){console.error("Failed to update model:",t),ef(e.model)}},eI=async()=>{ev(!1);let t=eg.trim()||"Session";if(t!==e.name)try{await (0,g1.updateSession)(e.id,{name:t}),(0,g7.mutateSessions)()}catch(t){console.error("Failed to update name:",t),ex(e.name||"")}},eL=async()=>{if(eA?.updateCommand&&!d){eR(!0);try{let e=`Run this update command:
8
8
 
9
- ${ex.updateCommand}`;eE(e),eb(!0)}catch(e){console.error("Failed to start update:",e)}finally{ek(!1)}}},eC=e=>e&&"object"==typeof e&&"type"in e&&"value"in e&&("json"===e.type||"text"===e.type)?e.value:e,eA=e=>{let t=[],r=new Map;for(let t of e)if("tool"===t.role&&Array.isArray(t.content)){for(let e of t.content)if("tool-result"===e.type){let t=e.output??e.result;r.set(e.toolCallId,eC(t))}}let n=0;for(let s of e){if("user"===s.role){let e="",r=[];if("string"==typeof s.content)e=s.content;else if(Array.isArray(s.content))for(let t of s.content)"text"===t.type&&"text"in t?e+=t.text:"image"===t.type&&"image"in t?r.push({type:"image",data:t.image,mediaType:t.mediaType}):"file"===t.type&&"data"in t&&r.push({type:"file",data:t.data,mediaType:t.mediaType});t.push({id:s.id,type:"user-message",content:e,messageSequence:n,attachments:r.length>0?r:void 0})}else if("assistant"===s.role){if("string"==typeof s.content)s.content.trim()&&t.push({id:s.id,type:"assistant-text",content:s.content});else if(Array.isArray(s.content))for(let e=0;e<s.content.length;e++){let n=s.content[e];if("reasoning"===n.type&&n.text?.trim())t.push({id:`${s.id}-reasoning-${e}`,type:"reasoning",content:n.text});else if("text"===n.type&&n.text?.trim())t.push({id:`${s.id}-text-${e}`,type:"assistant-text",content:n.text});else if("tool-call"===n.type){let i=r.get(n.toolCallId),a=i?.rejected===!0||i?.status==="rejected";t.push({id:`${s.id}-tool-${e}`,type:"tool-call",toolCall:{toolCallId:n.toolCallId,toolName:n.toolName,input:n.input??n.args,output:i,status:a?"rejected":void 0!==i?"completed":"pending"}})}}}n++}return t},e_=async(t,r)=>{let n=B.find(e=>e.messageSequence===t);if(!n)return void console.error("No checkpoint found for message sequence:",t);if(window.confirm("Revert to before this message? This will undo all file changes and delete messages from this point.")){H(!0);try{await (0,g1.revertToCheckpoint)(e.id,n.id);let[t,i]=await Promise.all([(0,g1.getSessionMessages)(e.id),(0,g1.getSessionCheckpoints)(e.id).catch(()=>({checkpoints:[]}))]),o=[...t].sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime()),l=eA(o);s(l),W(i.checkpoints||[]),T(""),P(""),L([]),K.current="",X.current="",Y.current=[],r&&a(r)}catch(e){console.error("Failed to revert:",e),alert("Failed to revert: "+(e instanceof Error?e.message:"Unknown error"))}finally{H(!1)}}},eT=t=>{if("tool-progress"===t.type){if("bash"===t.toolName&&"started"===t.data.status){let e="string"==typeof t.data.terminalId?t.data.terminalId:void 0;if(!e)return;if(Y.current=Y.current.map(t=>"bash"!==t.toolName||t.terminalId||"running"!==t.status&&"streaming"!==t.status?t:{...t,terminalId:e,liveOutput:""}),L([...Y.current]),!en.current.has(e)){let t=(0,g1.streamTerminal)(e,t=>{Y.current=Y.current.map(r=>r.terminalId===e?{...r,liveOutput:(r.liveOutput||"")+t}:r),L([...Y.current])},()=>{en.current.delete(e)});en.current.set(e,t)}}if("write_file"===t.toolName){let e=t.data;console.log("[FRONTEND] tool-progress received:",t.toolName,e.status,e.isChunked?`chunk=${e.chunkIndex}/${e.chunkCount}`:"",`contentLength=${e.content?.length||0}`,"currentToolCalls:",Y.current.length);let r=Y.current.find(e=>"write_file"===e.toolName&&("running"===e.status||"streaming"===e.status));if("started"===e.status){if(r)Y.current=Y.current.map(e=>"write_file"===e.toolName&&("running"===e.status||"streaming"===e.status)?{...e,liveContent:"",liveOldString:"",liveNewString:""}:e);else{console.log("[FRONTEND] Creating placeholder write_file tool call for:",e.path);let t={toolCallId:`write_file_pending_${Date.now()}`,toolName:"write_file",input:{path:e.relativePath||e.path,mode:e.mode||"full"},status:"streaming",liveContent:"",liveOldString:"",liveNewString:""};Y.current=[...Y.current,t],console.log("[FRONTEND] After adding placeholder, toolCallsRef.current:",Y.current.length)}L([...Y.current])}else if("content"===e.status){if(console.log("[FRONTEND] Received content for write_file, length:",e.content?.length||0,"existingWriteFile:",!!r),r)console.log("[FRONTEND] Updating existing write_file with content"),Y.current=Y.current.map(t=>{if("write_file"===t.toolName&&("running"===t.status||"streaming"===t.status))if("str_replace"===e.mode)return{...t,liveOldString:e.oldString||"",liveNewString:e.newString||""};else{let r=e.isChunked||void 0!==e.chunkIndex||void 0!==e.chunkCount,n=e.content||"";return{...t,liveContent:r?(t.liveContent||"")+n:n}}return t});else{console.log("[FRONTEND] Creating placeholder with content");let t={toolCallId:`write_file_pending_${Date.now()}`,toolName:"write_file",input:{path:e.relativePath||e.path,mode:e.mode||"full"},status:"streaming",liveContent:"str_replace"!==e.mode&&e.content||"",liveOldString:"str_replace"===e.mode&&e.oldString||"",liveNewString:"str_replace"===e.mode&&e.newString||""};Y.current=[...Y.current,t]}L([...Y.current])}}if("explore_agent"===t.toolName){let e=t.data;console.log("[FRONTEND] Explore agent tool-progress:",e.status,e.stepType||"");let r=Y.current.find(e=>"explore_agent"===e.toolName&&("running"===e.status||"streaming"===e.status));if("started"===e.status){if(r)Y.current=Y.current.map(e=>"explore_agent"===e.toolName&&("running"===e.status||"streaming"===e.status)?{...e,exploreSteps:[]}:e);else{let e={toolCallId:`explore_agent_pending_${Date.now()}`,toolName:"explore_agent",input:{},status:"streaming",exploreSteps:[]};Y.current=[...Y.current,e]}L([...Y.current])}else if("step"===e.status&&e.stepType){let t={id:`step_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,type:e.stepType,content:e.stepContent||"",toolName:e.toolName,toolInput:e.toolInput,toolOutput:e.toolOutput,timestamp:Date.now()};Y.current=Y.current.map(e=>"explore_agent"===e.toolName&&("running"===e.status||"streaming"===e.status)?{...e,exploreSteps:[...e.exploreSteps||[],t]}:e),L([...Y.current])}}return}switch(t.type){case"start":case"data-session":case"text-start":case"text-end":break;case"data-stream-id":N(t.streamId),ee.current=t.streamId;break;case"data-user-message":t.data?.content&&!er.current&&s(e=>{let r="",n=[],s=t.data.content;if("string"==typeof s)r=s;else if(Array.isArray(s))for(let e of s)"text"===e.type&&e.text?r+=e.text:"image"===e.type&&e.image?n.push({type:"image",data:e.image,mediaType:e.mediaType}):"file"===e.type&&e.data&&n.push({type:"file",data:e.data,mediaType:e.mediaType});return e.some(e=>"user-message"===e.type&&e.content===r)?e:[...e,{id:t.data.id||`user-${Date.now()}`,type:"user-message",content:r,attachments:n.length>0?n:void 0}]});break;case"text-delta":K.current+=t.delta,T(K.current);break;case"reasoning-start":M(!0),X.current="",P("");break;case"reasoning-delta":X.current+=t.delta,P(X.current);break;case"reasoning-end":if(M(!1),X.current.trim()){let e={id:`reasoning-${Date.now()}`,type:"reasoning",content:X.current};s(t=>[...t,e])}X.current="",P("");break;case"tool-input-start":if(K.current.trim()){let e={id:`text-${Date.now()}`,type:"assistant-text",content:K.current};s(t=>[...t,e]),K.current="",T("")}let r={toolCallId:t.toolCallId,toolName:t.toolName,input:{},status:"streaming",streamingArgsText:""};Y.current=[...Y.current,r],L([...Y.current]);break;case"tool-input-delta":Y.current=Y.current.map(e=>e.toolCallId!==t.toolCallId?e:{...e,streamingArgsText:(e.streamingArgsText||"")+t.argsTextDelta}),L([...Y.current]);break;case"tool-input-available":let n=Y.current.find(e=>e.toolCallId===t.toolCallId),i="write_file"===t.toolName?Y.current.find(e=>"write_file"===e.toolName&&e.toolCallId.startsWith("write_file_pending_")&&"streaming"===e.status):void 0,a="explore_agent"===t.toolName?Y.current.find(e=>"explore_agent"===e.toolName&&e.toolCallId.startsWith("explore_agent_pending_")&&"streaming"===e.status):void 0;if(K.current.trim()){let e={id:`text-${Date.now()}`,type:"assistant-text",content:K.current};s(t=>[...t,e]),K.current="",T("")}let o={toolCallId:t.toolCallId,toolName:t.toolName,input:t.input,status:"running",streamingArgsText:n?.streamingArgsText,liveContent:i?.liveContent,liveOldString:i?.liveOldString,liveNewString:i?.liveNewString,exploreSteps:a?.exploreSteps};i?Y.current=Y.current.map(e=>e.toolCallId===i.toolCallId?o:e):a?Y.current=Y.current.map(e=>e.toolCallId===a.toolCallId?o:e):n?Y.current=Y.current.map(e=>e.toolCallId!==t.toolCallId?e:o):Y.current=[...Y.current,o],L([...Y.current]);break;case"tool-output-available":let l=Y.current.find(e=>e.toolCallId===t.toolCallId);if(l?.terminalId){let e=en.current.get(l.terminalId);e&&(e(),en.current.delete(l.terminalId))}let c=eC(t.output),d=c?.rejected===!0||c?.status==="rejected",h=Y.current.find(e=>e.toolCallId===t.toolCallId);Y.current=Y.current.filter(e=>e.toolCallId!==t.toolCallId),L([...Y.current]);let p={id:`tool-${t.toolCallId}`,type:"tool-call",toolCall:{toolCallId:t.toolCallId,toolName:h?.toolName||"unknown",input:h?.input||{},output:c,status:d?"rejected":"completed"}};s(e=>{let r=e.findIndex(e=>"tool-call"===e.type&&e.toolCall?.toolCallId===t.toolCallId);if(r>=0){let t=[...e];return t[r]=p,t}return[...e,p]});break;case"data-approval-required":O(e=>e.some(e=>e.id===t.data.id)?e:[...e,t.data]);break;case"finish-step":if(K.current.trim()){let e={id:`text-${Date.now()}`,type:"assistant-text",content:K.current};s(t=>[...t,e]),K.current="",T("")}break;case"finish":T(""),P(""),M(!1),L([]),N(null),K.current="",X.current="",Y.current=[],Q.current=null,et.current=!1,er.current=!1,u(!1),y(!1),Promise.all([(0,g1.getSessionMessages)(e.id),(0,g1.getSessionCheckpoints)(e.id).catch(()=>({checkpoints:[]}))]).then(([e,t])=>{s(eA([...e].sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime()))),W(t.checkpoints||[])}).catch(()=>{});break;case"abort":if(X.current.trim()){let e={id:`reasoning-${Date.now()}`,type:"reasoning",content:X.current};s(t=>[...t,e])}if(K.current.trim()){let e={id:`text-${Date.now()}`,type:"assistant-text",content:K.current+" [stopped]"};s(t=>[...t,e])}T(""),P(""),M(!1),L([]),N(null),K.current="",X.current="",Y.current=[],Q.current=null,et.current=!1,er.current=!1,u(!1),y(!1);break;case"error":console.error("Agent error:",t.errorText),Q.current=null,u(!1),y(!1)}};(0,b.useEffect)(()=>{let t=!1;(async()=>{Z(!0),s([]),T(""),P(""),L([]),O([]),u(!1),y(!1),N(null),K.current="",X.current="",Y.current=[];try{let[r,n]=await Promise.all([(0,g1.getSessionMessages)(e.id),(0,g1.getSessionCheckpoints)(e.id).catch(()=>({checkpoints:[]}))]);if(t)return;let i=[...r].sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime()),a=eA(i);s(a),W(n.checkpoints||[]);let o=await (0,g1.getActiveStream)(e.id);if(t)return;o.hasActiveStream&&o.stream&&(console.log("Found active stream, connecting...",o.stream.streamId),er.current=!1,y(!0),u(!0),N(o.stream.streamId),Q.current=(0,g1.watchStream)(e.id,eT,{streamId:o.stream.streamId,onStreamId:e=>N(e)}))}catch(e){t||console.error("Failed to load messages:",e)}finally{t||Z(!1)}})();let r=en.current;return()=>{t=!0,Q.current&&(Q.current(),Q.current=null),r.forEach(e=>e()),r.clear()}},[e.id]),(0,b.useEffect)(()=>{let t=!1,r=e.id,n=async()=>{try{let e=await (0,g1.getPendingApprovals)(r);if(t)return;O(e)}catch{}};n();let s=setInterval(n,2e3);return()=>{t=!0,clearInterval(s)}},[e.id]),(0,b.useEffect)(()=>{let t=!1,r=e.id,n=async()=>{try{let e=await (0,g1.getSessionTodos)(r);if(t)return;F(e)}catch{}};n();let s=setInterval(n,c?1e3:5e3);return()=>{t=!0,clearInterval(s)}},[e.id,c]),(0,b.useEffect)(()=>{let e="1"===new URLSearchParams(window.location.search).get("debugSSE");if(h(e),!e)return;window.__sparkeSseDebug=!0;let t=e=>{let t=e.detail,r=[t?.label,t?.toolName].filter(Boolean).join(" "),n=t?.type?`${t.type}${r?` ${r}`:""} (${t?.size??0}b)`:"unknown";m(e=>[...e.slice(-49),n])},r=e=>{let t=e.detail,r=`parse-error: ${t?.error||"unknown"} (${t?.size??0}b)`;g(e=>[...e.slice(-49),r])};return window.addEventListener("sparke:sse-event",t),window.addEventListener("sparke:sse-parse-error",r),()=>{window.removeEventListener("sparke:sse-event",t),window.removeEventListener("sparke:sse-parse-error",r),window.__sparkeSseDebug=!1}},[]),(0,b.useEffect)(()=>{let t=!1,r=e.id,n=setInterval(async()=>{if(!c&&!et.current)try{let e=await (0,g1.getActiveStream)(r);if(t)return;if(e.hasActiveStream&&e.stream){let n=e.stream.streamId;if(n!==ee.current){if(console.log("New active stream detected, connecting...",n),et.current=!0,er.current=!1,X.current.trim()){let e={id:`reasoning-${Date.now()}`,type:"reasoning",content:X.current};s(t=>[...t,e]),X.current="",P("")}if(K.current.trim()){let e={id:`text-${Date.now()}`,type:"assistant-text",content:K.current};s(t=>[...t,e]),K.current="",T("")}for(let e of Y.current){let t={id:`tool-${e.toolCallId}`,type:"tool-call",toolCall:e};s(r=>r.some(t=>"tool-call"===t.type&&t.toolCall?.toolCallId===e.toolCallId)?r:[...r,t])}Y.current=[],L([]),M(!1);try{let e=await (0,g1.getSessionMessages)(r);if(t){et.current=!1;return}let n=[...e].sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime()),i=eA(n);s(i)}catch(e){console.error("Failed to refresh messages:",e)}if(t){et.current=!1;return}y(!0),u(!0),N(n),ee.current=n,Q.current=(0,g1.watchStream)(r,eT,{streamId:n,onStreamId:e=>{N(e),ee.current=e}}),et.current=!1}}}catch(e){console.error("Failed to check for new stream:",e),et.current=!1}},1e3);return()=>{t=!0,clearInterval(n)}},[e.id,c]),(0,b.useEffect)(()=>{let t=!1,r=e.id,n=setInterval(async()=>{if(!c)try{let e=await (0,g1.getPendingInput)(r);if(t||c)return;e.hasPendingInput&&e.text&&(a(t=>t.trim()?t+"\n\n"+e.text:e.text||""),setTimeout(()=>{let e=document.querySelector('textarea[placeholder*="Ask SparkECoder"]');e&&(e.focus(),e.selectionStart=e.value.length,e.selectionEnd=e.value.length)},100))}catch(e){}},500);return()=>{t=!0,clearInterval(n)}},[e.id,c]);let eE=async(t,r)=>{if(!t.trim()&&(!r||0===r.length)||c)return;let n=t;try{let r=await (0,g1.getDevtoolsContext)(e.id);if(r.connected&&r.context){let e=r.context;n=`[Sparkecode Devtools connected - User is currently viewing: ${e.pageName} (${e.path})]
9
+ ${eA.updateCommand}`;e$(e),eE(!0)}catch(e){console.error("Failed to start update:",e)}finally{eR(!1)}}},eD=e=>e&&"object"==typeof e&&"type"in e&&"value"in e&&("json"===e.type||"text"===e.type)?e.value:e,eO=e=>{let t=[],r=new Map;for(let t of e)if("tool"===t.role&&Array.isArray(t.content)){for(let e of t.content)if("tool-result"===e.type){let t=e.output??e.result;r.set(e.toolCallId,eD(t))}}let n=0;for(let s of e){if("user"===s.role){let e="",r=[];if("string"==typeof s.content)e=s.content;else if(Array.isArray(s.content))for(let t of s.content)"text"===t.type&&"text"in t?e+=t.text:"image"===t.type&&"image"in t?r.push({type:"image",data:t.image,mediaType:t.mediaType}):"file"===t.type&&"data"in t&&r.push({type:"file",data:t.data,mediaType:t.mediaType});t.push({id:s.id,type:"user-message",content:e,messageSequence:n,attachments:r.length>0?r:void 0})}else if("assistant"===s.role){if("string"==typeof s.content)s.content.trim()&&t.push({id:s.id,type:"assistant-text",content:s.content});else if(Array.isArray(s.content))for(let e=0;e<s.content.length;e++){let n=s.content[e];if("reasoning"===n.type&&n.text?.trim())t.push({id:`${s.id}-reasoning-${e}`,type:"reasoning",content:n.text});else if("text"===n.type&&n.text?.trim())t.push({id:`${s.id}-text-${e}`,type:"assistant-text",content:n.text});else if("tool-call"===n.type){let i=r.get(n.toolCallId),a=i?.rejected===!0||i?.status==="rejected";t.push({id:`${s.id}-tool-${e}`,type:"tool-call",toolCall:{toolCallId:n.toolCallId,toolName:n.toolName,input:n.input??n.args,output:i,status:a?"rejected":void 0!==i?"completed":"pending"}})}}}n++}return t},ez=async(t,r)=>{let n=ee.find(e=>e.messageSequence===t);if(!n)return void console.error("No checkpoint found for message sequence:",t);if(window.confirm("Revert to before this message? This will undo all file changes and delete messages from this point.")){en(!0);try{await (0,g1.revertToCheckpoint)(e.id,n.id);let[t,i]=await Promise.all([(0,g1.getSessionMessages)(e.id),(0,g1.getSessionCheckpoints)(e.id).catch(()=>({checkpoints:[]}))]),o=[...t].sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime()),l=eO(o);s(l),et(i.checkpoints||[]),F(""),W(""),X([]),es.current="",ei.current="",ea.current=[],r&&a(r)}catch(e){console.error("Failed to revert:",e),alert("Failed to revert: "+(e instanceof Error?e.message:"Unknown error"))}finally{en(!1)}}},eF=t=>{if("tool-progress"===t.type){if("bash"===t.toolName&&"started"===t.data.status){let e="string"==typeof t.data.terminalId?t.data.terminalId:void 0;if(!e)return;if(ea.current=ea.current.map(t=>"bash"!==t.toolName||t.terminalId||"running"!==t.status&&"streaming"!==t.status?t:{...t,terminalId:e,liveOutput:""}),X([...ea.current]),!ep.current.has(e)){let t=(0,g1.streamTerminal)(e,t=>{ea.current=ea.current.map(r=>r.terminalId===e?{...r,liveOutput:(r.liveOutput||"")+t}:r),X([...ea.current])},()=>{ep.current.delete(e)});ep.current.set(e,t)}}if("write_file"===t.toolName){let e=t.data;console.log("[FRONTEND] tool-progress received:",t.toolName,e.status,e.isChunked?`chunk=${e.chunkIndex}/${e.chunkCount}`:"",`contentLength=${e.content?.length||0}`,"currentToolCalls:",ea.current.length);let r=ea.current.find(e=>"write_file"===e.toolName&&("running"===e.status||"streaming"===e.status));if("started"===e.status){if(r)ea.current=ea.current.map(e=>"write_file"===e.toolName&&("running"===e.status||"streaming"===e.status)?{...e,liveContent:"",liveOldString:"",liveNewString:""}:e);else{console.log("[FRONTEND] Creating placeholder write_file tool call for:",e.path);let t={toolCallId:`write_file_pending_${Date.now()}`,toolName:"write_file",input:{path:e.relativePath||e.path,mode:e.mode||"full"},status:"streaming",liveContent:"",liveOldString:"",liveNewString:""};ea.current=[...ea.current,t],console.log("[FRONTEND] After adding placeholder, toolCallsRef.current:",ea.current.length)}X([...ea.current])}else if("content"===e.status){if(console.log("[FRONTEND] Received content for write_file, length:",e.content?.length||0,"existingWriteFile:",!!r),r)console.log("[FRONTEND] Updating existing write_file with content"),ea.current=ea.current.map(t=>{if("write_file"===t.toolName&&("running"===t.status||"streaming"===t.status))if("str_replace"===e.mode)return{...t,liveOldString:e.oldString||"",liveNewString:e.newString||""};else{let r=e.isChunked||void 0!==e.chunkIndex||void 0!==e.chunkCount,n=e.content||"";return{...t,liveContent:r?(t.liveContent||"")+n:n}}return t});else{console.log("[FRONTEND] Creating placeholder with content");let t={toolCallId:`write_file_pending_${Date.now()}`,toolName:"write_file",input:{path:e.relativePath||e.path,mode:e.mode||"full"},status:"streaming",liveContent:"str_replace"!==e.mode&&e.content||"",liveOldString:"str_replace"===e.mode&&e.oldString||"",liveNewString:"str_replace"===e.mode&&e.newString||""};ea.current=[...ea.current,t]}X([...ea.current])}}if("explore_agent"===t.toolName){let e=t.data;console.log("[FRONTEND] Explore agent tool-progress:",e.status,e.stepType||"");let r=ea.current.find(e=>"explore_agent"===e.toolName&&("running"===e.status||"streaming"===e.status));if("started"===e.status){if(r)ea.current=ea.current.map(e=>"explore_agent"===e.toolName&&("running"===e.status||"streaming"===e.status)?{...e,exploreSteps:[]}:e);else{let e={toolCallId:`explore_agent_pending_${Date.now()}`,toolName:"explore_agent",input:{},status:"streaming",exploreSteps:[]};ea.current=[...ea.current,e]}X([...ea.current])}else if("step"===e.status&&e.stepType){let t={id:`step_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,type:e.stepType,content:e.stepContent||"",toolName:e.toolName,toolInput:e.toolInput,toolOutput:e.toolOutput,timestamp:Date.now()};ea.current=ea.current.map(e=>"explore_agent"===e.toolName&&("running"===e.status||"streaming"===e.status)?{...e,exploreSteps:[...e.exploreSteps||[],t]}:e),X([...ea.current])}}return}switch(t.type){case"start":case"data-session":case"text-start":case"text-end":break;case"data-stream-id":O(t.streamId),eu.current=t.streamId;break;case"data-user-message":t.data?.content&&!eh.current&&s(e=>{let r="",n=[],s=t.data.content;if("string"==typeof s)r=s;else if(Array.isArray(s))for(let e of s)"text"===e.type&&e.text?r+=e.text:"image"===e.type&&e.image?n.push({type:"image",data:e.image,mediaType:e.mediaType}):"file"===e.type&&e.data&&n.push({type:"file",data:e.data,mediaType:e.mediaType});return e.some(e=>"user-message"===e.type&&e.content===r)?e:[...e,{id:t.data.id||`user-${Date.now()}`,type:"user-message",content:r,attachments:n.length>0?n:void 0}]});break;case"text-delta":es.current+=t.delta,F(es.current);break;case"reasoning-start":H(!0),ei.current="",W("");break;case"reasoning-delta":ei.current+=t.delta,W(ei.current);break;case"reasoning-end":if(H(!1),ei.current.trim()){let e={id:`reasoning-${Date.now()}`,type:"reasoning",content:ei.current};s(t=>[...t,e])}ei.current="",W("");break;case"tool-input-start":if(es.current.trim()){let e={id:`text-${Date.now()}`,type:"assistant-text",content:es.current};s(t=>[...t,e]),es.current="",F("")}let r={toolCallId:t.toolCallId,toolName:t.toolName,input:{},status:"streaming",streamingArgsText:""};ea.current=[...ea.current,r],X([...ea.current]);break;case"tool-input-delta":ea.current=ea.current.map(e=>e.toolCallId!==t.toolCallId?e:{...e,streamingArgsText:(e.streamingArgsText||"")+t.argsTextDelta}),X([...ea.current]);break;case"tool-input-available":let n=ea.current.find(e=>e.toolCallId===t.toolCallId),i="write_file"===t.toolName?ea.current.find(e=>"write_file"===e.toolName&&e.toolCallId.startsWith("write_file_pending_")&&"streaming"===e.status):void 0,a="explore_agent"===t.toolName?ea.current.find(e=>"explore_agent"===e.toolName&&e.toolCallId.startsWith("explore_agent_pending_")&&"streaming"===e.status):void 0;if(es.current.trim()){let e={id:`text-${Date.now()}`,type:"assistant-text",content:es.current};s(t=>[...t,e]),es.current="",F("")}let o={toolCallId:t.toolCallId,toolName:t.toolName,input:t.input,status:"running",streamingArgsText:n?.streamingArgsText,liveContent:i?.liveContent,liveOldString:i?.liveOldString,liveNewString:i?.liveNewString,exploreSteps:a?.exploreSteps};i?ea.current=ea.current.map(e=>e.toolCallId===i.toolCallId?o:e):a?ea.current=ea.current.map(e=>e.toolCallId===a.toolCallId?o:e):n?ea.current=ea.current.map(e=>e.toolCallId!==t.toolCallId?e:o):ea.current=[...ea.current,o],X([...ea.current]);break;case"tool-output-available":let l=ea.current.find(e=>e.toolCallId===t.toolCallId);if(l?.terminalId){let e=ep.current.get(l.terminalId);e&&(e(),ep.current.delete(l.terminalId))}let c=eD(t.output),u=c?.rejected===!0||c?.status==="rejected",d=ea.current.find(e=>e.toolCallId===t.toolCallId);ea.current=ea.current.filter(e=>e.toolCallId!==t.toolCallId),X([...ea.current]);let p={id:`tool-${t.toolCallId}`,type:"tool-call",toolCall:{toolCallId:t.toolCallId,toolName:d?.toolName||"unknown",input:d?.input||{},output:c,status:u?"rejected":"completed"}};s(e=>{let r=e.findIndex(e=>"tool-call"===e.type&&e.toolCall?.toolCallId===t.toolCallId);if(r>=0){let t=[...e];return t[r]=p,t}return[...e,p]});break;case"data-approval-required":J(e=>e.some(e=>e.id===t.data.id)?e:[...e,t.data]);break;case"finish-step":if(es.current.trim()){let e={id:`text-${Date.now()}`,type:"assistant-text",content:es.current};s(t=>[...t,e]),es.current="",F("")}break;case"finish":F(""),W(""),H(!1),X([]),O(null),es.current="",ei.current="",ea.current=[],ec.current=null,ed.current=!1,eh.current=!1,h(!1),L(!1),Promise.all([(0,g1.getSessionMessages)(e.id),(0,g1.getSessionCheckpoints)(e.id).catch(()=>({checkpoints:[]}))]).then(([e,t])=>{s(eO([...e].sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime()))),et(t.checkpoints||[])}).catch(()=>{});break;case"abort":if(ei.current.trim()){let e={id:`reasoning-${Date.now()}`,type:"reasoning",content:ei.current};s(t=>[...t,e])}if(es.current.trim()){let e={id:`text-${Date.now()}`,type:"assistant-text",content:es.current+" [stopped]"};s(t=>[...t,e])}F(""),W(""),H(!1),X([]),O(null),es.current="",ei.current="",ea.current=[],ec.current=null,ed.current=!1,eh.current=!1,h(!1),L(!1);break;case"error":console.error("Agent error:",t.errorText),ec.current=null,h(!1),L(!1)}};(0,b.useEffect)(()=>{let t=!1;(async()=>{el(!0),s([]),F(""),W(""),X([]),J([]),h(!1),L(!1),O(null),es.current="",ei.current="",ea.current=[];try{let[r,n]=await Promise.all([(0,g1.getSessionMessages)(e.id),(0,g1.getSessionCheckpoints)(e.id).catch(()=>({checkpoints:[]}))]);if(t)return;let i=[...r].sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime()),a=eO(i);s(a),et(n.checkpoints||[]);let o=await (0,g1.getActiveStream)(e.id);if(t)return;o.hasActiveStream&&o.stream&&(console.log("Found active stream, connecting...",o.stream.streamId),eh.current=!1,L(!0),h(!0),O(o.stream.streamId),ec.current=(0,g1.watchStream)(e.id,eF,{streamId:o.stream.streamId,onStreamId:e=>O(e)}))}catch(e){t||console.error("Failed to load messages:",e)}finally{t||el(!1)}})();let r=ep.current;return()=>{t=!0,ec.current&&(ec.current(),ec.current=null),r.forEach(e=>e()),r.clear()}},[e.id]),(0,b.useEffect)(()=>{let t=!1,r=e.id,n=async()=>{try{let e=await (0,g1.getPendingApprovals)(r);if(t)return;J(e)}catch{}};n();let s=setInterval(n,2e3);return()=>{t=!0,clearInterval(s)}},[e.id]),(0,b.useEffect)(()=>{let t=!1,r=e.id,n=async()=>{try{let e=await (0,g1.getSessionTodos)(r);if(t)return;Q(e)}catch{}};n();let s=setInterval(n,d?1e3:5e3);return()=>{t=!0,clearInterval(s)}},[e.id,d]),(0,b.useEffect)(()=>{let e="1"===new URLSearchParams(window.location.search).get("debugSSE");if(T(e),!e)return;window.__sparkeSseDebug=!0;let t=e=>{let t=e.detail,r=[t?.label,t?.toolName].filter(Boolean).join(" "),n=t?.type?`${t.type}${r?` ${r}`:""} (${t?.size??0}b)`:"unknown";P(e=>[...e.slice(-49),n])},r=e=>{let t=e.detail,r=`parse-error: ${t?.error||"unknown"} (${t?.size??0}b)`;M(e=>[...e.slice(-49),r])};return window.addEventListener("sparke:sse-event",t),window.addEventListener("sparke:sse-parse-error",r),()=>{window.removeEventListener("sparke:sse-event",t),window.removeEventListener("sparke:sse-parse-error",r),window.__sparkeSseDebug=!1}},[]),(0,b.useEffect)(()=>{let t=!1,r=e.id,n=setInterval(async()=>{if(!d&&!ed.current)try{let e=await (0,g1.getActiveStream)(r);if(t)return;if(e.hasActiveStream&&e.stream){let n=e.stream.streamId;if(n!==eu.current){if(console.log("New active stream detected, connecting...",n),ed.current=!0,eh.current=!1,ei.current.trim()){let e={id:`reasoning-${Date.now()}`,type:"reasoning",content:ei.current};s(t=>[...t,e]),ei.current="",W("")}if(es.current.trim()){let e={id:`text-${Date.now()}`,type:"assistant-text",content:es.current};s(t=>[...t,e]),es.current="",F("")}for(let e of ea.current){let t={id:`tool-${e.toolCallId}`,type:"tool-call",toolCall:e};s(r=>r.some(t=>"tool-call"===t.type&&t.toolCall?.toolCallId===e.toolCallId)?r:[...r,t])}ea.current=[],X([]),H(!1);try{let e=await (0,g1.getSessionMessages)(r);if(t){ed.current=!1;return}let n=[...e].sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime()),i=eO(n);s(i)}catch(e){console.error("Failed to refresh messages:",e)}if(t){ed.current=!1;return}L(!0),h(!0),O(n),eu.current=n,ec.current=(0,g1.watchStream)(r,eF,{streamId:n,onStreamId:e=>{O(e),eu.current=e}}),ed.current=!1}}}catch(e){console.error("Failed to check for new stream:",e),ed.current=!1}},1e3);return()=>{t=!0,clearInterval(n)}},[e.id,d]),(0,b.useEffect)(()=>{let t=!1,r=e.id,n=setInterval(async()=>{if(!d)try{let e=await (0,g1.getPendingInput)(r);if(t||d)return;e.hasPendingInput&&e.text&&(u(t=>t&&t.trim()?t+"\n\n"+e.text:e.text||""),setTimeout(()=>{let e=document.querySelector('textarea[placeholder*="SparkECoder"], textarea[placeholder*="queue"]');e&&(e.focus(),e.selectionStart=e.value.length,e.selectionEnd=e.value.length)},100))}catch(e){}},500);return()=>{t=!0,clearInterval(n)}},[e.id,d]);let eB=async(t,r,n)=>{let i=!!(n&&n.trim());if(!t.trim()&&(!r||0===r.length)&&!i)return;let a=t;if(n&&n.trim()){let e=`<sparkecoder-user-selected-elements>
10
+ ${n.trim()}
11
+ </sparkecoder-user-selected-elements>`;a=`${e}
10
12
 
11
- `+t}}catch{}let i=r?.map(e=>({type:e.type,data:e.data,mediaType:e.mediaType,filename:e.filename})),o={id:`user-${Date.now()}`,type:"user-message",content:t||"",attachments:i};s(e=>[...e,o]),a(""),u(!0),y(!1),er.current=!0,T(""),P(""),M(!1),L([]),K.current="",X.current="",Y.current=[],Q.current=(0,g1.runAgent)(e.id,n||"Please analyze the attached files.",eT,{onStreamId:e=>N(e),attachments:r})},eP=async e=>{if(c)return;let t=!!e.text?.trim(),r=!!e.files?.length;if(!t&&!r)return;let n=[];if(r&&e.files.length>0){for(let t of e.files)if(t.url)try{let e=await fetch(t.url),r=await e.blob(),s=await new Promise(e=>{let t=new FileReader;t.onloadend=()=>e(t.result),t.readAsDataURL(r)}),i=t.mediaType||r.type||"application/octet-stream",a=i.startsWith("image/");n.push({type:a?"image":"file",data:s,mediaType:i,filename:t.filename})}catch(e){console.error("Failed to process attachment:",e)}}eE(e.text||"",n.length>0?n:void 0)},eR=async()=>{try{await (0,g1.abortStream)(e.id)}catch(e){console.error("Failed to abort stream:",e)}if(Q.current&&(Q.current(),Q.current=null),X.current.trim()){let e={id:`reasoning-${Date.now()}`,type:"reasoning",content:X.current};s(t=>[...t,e])}if(K.current.trim()){let e={id:`text-${Date.now()}`,type:"assistant-text",content:K.current+" [stopped]"};s(t=>[...t,e])}T(""),P(""),M(!1),L([]),N(null),K.current="",X.current="",Y.current=[],et.current=!1,u(!1),y(!1)},eM=async t=>{O(e=>e.filter(e=>e.id!==t.id));try{await (0,g1.approveExecution)(e.id,t.toolCallId)}catch(e){console.error("Failed to approve:",e)}},eI=async t=>{O(e=>e.filter(e=>e.id!==t.id));try{await (0,g1.rejectExecution)(e.id,t.toolCallId,"User rejected")}catch(e){console.error("Failed to reject:",e)}},eL=async t=>{O(e=>e.filter(e=>e.id!==t.id));try{await (0,g1.approveExecution)(e.id,t.toolCallId);let r=await (0,g1.updateToolApproval)(e.id,t.toolName,!1,eh);ep(r.config||{})}catch(e){console.error("Failed to approve and disable:",e)}},eD=async(t,r)=>{try{let n=await (0,g1.updateToolApproval)(e.id,t,!r,eh);ep(n.config||{})}catch(e){console.error("Failed to update tool approval:",e)}},eO=e=>({ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",php:"php",swift:"swift",kt:"kotlin",scala:"scala",sh:"bash",bash:"bash",zsh:"bash",fish:"bash",ps1:"powershell",sql:"sql",html:"html",htm:"html",css:"css",scss:"scss",sass:"sass",less:"less",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",md:"markdown",markdown:"markdown",txt:"plaintext",toml:"toml",ini:"ini",cfg:"ini",conf:"ini",dockerfile:"dockerfile",makefile:"makefile"})[e.split(".").pop()?.toLowerCase()||""]||"plaintext";return(0,v.jsxs)("div",{className:(0,k.cn)("flex flex-col h-full bg-background min-w-0 overflow-x-hidden",t&&"embed-mode text-[13px]"),children:[t&&(0,v.jsxs)("div",{className:"border-b border-border/50 px-2 py-1.5 flex items-center justify-between bg-card/50",children:[(0,v.jsx)(A.Button,{size:"icon",variant:"ghost",onClick:r,className:"size-6",children:(0,v.jsx)(xl.PanelLeft,{className:"size-3.5"})}),(0,v.jsx)("span",{className:"text-[11px] text-muted-foreground truncate max-w-[120px] font-medium",children:ea||"Session"}),(0,v.jsx)(A.Button,{size:"icon",variant:"ghost",onClick:()=>ef(!0),className:"size-6",children:(0,v.jsx)(xi.Settings,{className:"size-3.5"})})]}),!t&&(0,v.jsxs)("div",{className:"border-b border-border/50 px-3 sm:px-4 py-2 flex items-center justify-between bg-card/50 backdrop-blur-sm",children:[(0,v.jsxs)("div",{className:"min-w-0 flex items-center gap-2 sm:gap-3",children:[(0,v.jsx)(yN,{}),(0,v.jsx)("div",{className:"flex items-center gap-1.5",children:el?(0,v.jsxs)("form",{onSubmit:e=>{e.preventDefault(),eN()},className:"flex items-center gap-1",children:[(0,v.jsx)(gg.Input,{ref:eg,value:ea,onChange:e=>eo(e.target.value),onBlur:eN,className:"h-7 text-sm font-semibold w-40 px-2",placeholder:"Session name"}),(0,v.jsx)(A.Button,{type:"submit",size:"icon",variant:"ghost",className:"size-6 text-muted-foreground hover:text-foreground",children:(0,v.jsx)(xs.Check,{className:"size-3.5"})})]}):(0,v.jsx)(_.TooltipProvider,{children:(0,v.jsxs)(_.Tooltip,{children:[(0,v.jsx)(_.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)("button",{onClick:()=>ec(!0),className:"flex items-center gap-1.5 group hover:bg-muted/50 rounded px-1.5 py-0.5 -mx-1.5 transition-colors",children:[(0,v.jsx)("h2",{className:"font-semibold text-foreground truncate max-w-[200px]",children:ea||"Untitled Session"}),(0,v.jsx)(xn,{className:"size-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]})}),(0,v.jsx)(_.TooltipContent,{children:"Click to rename"})]})})}),(0,v.jsx)(_.TooltipProvider,{children:(0,v.jsxs)(_.Tooltip,{children:[(0,v.jsx)(_.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-md bg-muted/30 text-xs text-muted-foreground max-w-[200px]",children:[(0,v.jsx)(xo,{className:"size-3.5 shrink-0"}),(0,v.jsx)("span",{className:"truncate font-mono",children:e.workingDirectory.split("/").pop()||e.workingDirectory})]})}),(0,v.jsx)(_.TooltipContent,{side:"bottom",className:"max-w-md",children:(0,v.jsx)("p",{className:"font-mono text-xs",children:e.workingDirectory})})]})})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[x&&(0,v.jsx)(_.TooltipProvider,{children:(0,v.jsxs)(_.Tooltip,{children:[(0,v.jsx)(_.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)(C,{variant:"outline",className:"gap-1.5 text-xs border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 cursor-help",children:[(0,v.jsx)("span",{className:"size-1.5 rounded-full bg-current animate-pulse"}),"Watching"]})}),(0,v.jsx)(_.TooltipContent,{children:"Watching stream from another client"})]})}),(0,v.jsx)(_.TooltipProvider,{children:(0,v.jsxs)(_.Tooltip,{children:[(0,v.jsx)(_.TooltipTrigger,{asChild:!0,children:(0,v.jsx)(C,{variant:c?"default":"secondary",className:`cursor-help ${c?"bg-primary/90":""}`,children:c?x?"streaming":"running":e.status})}),(0,v.jsx)(_.TooltipContent,{children:c?x?"Receiving streamed response":"Agent is processing":`Session is ${e.status}`})]})}),(0,v.jsx)(_.TooltipProvider,{children:(0,v.jsxs)(_.Tooltip,{children:[(0,v.jsx)(_.TooltipTrigger,{asChild:!0,children:(0,v.jsx)(A.Button,{size:"icon",variant:"ghost",className:"size-7 hover:bg-accent transition-colors",onClick:()=>ef(!0),children:(0,v.jsx)(xi.Settings,{className:"size-4"})})}),(0,v.jsx)(_.TooltipContent,{children:"Session Settings"})]})})]})]}),(0,v.jsx)(mw.Dialog,{open:em,onOpenChange:ef,children:(0,v.jsxs)(mw.DialogContent,{className:"sm:max-w-md",children:[(0,v.jsx)(mw.DialogHeader,{children:(0,v.jsxs)(mw.DialogTitle,{className:"flex items-center gap-2",children:[(0,v.jsx)("div",{className:"size-8 rounded-lg bg-muted flex items-center justify-center",children:(0,v.jsx)(xi.Settings,{className:"size-4"})}),"Session Settings"]})}),(0,v.jsxs)("div",{className:"space-y-4 pt-2",children:[(0,v.jsxs)("div",{className:"space-y-2",children:[(0,v.jsx)(xm.Label,{className:"text-sm font-medium",children:"Model"}),(0,v.jsxs)(op.Select,{value:es,onValueChange:ej,disabled:c,children:[(0,v.jsx)(op.SelectTrigger,{className:"w-full",children:(0,v.jsx)(op.SelectValue,{placeholder:"Select model"})}),(0,v.jsx)(op.SelectContent,{children:eu?.availableModels.map(e=>(0,v.jsx)(op.SelectItem,{value:e.id,children:(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)("span",{children:e.name}),(0,v.jsx)("span",{className:"text-xs text-muted-foreground",children:e.provider})]})},e.id))})]}),c&&(0,v.jsx)("p",{className:"text-xs text-muted-foreground",children:"Cannot change model while agent is running"})]}),(0,v.jsxs)("div",{className:"space-y-2",children:[(0,v.jsx)(xm.Label,{className:"flex items-center gap-2 text-sm font-medium",children:"Tool Approvals"}),(0,v.jsx)("p",{className:"text-xs text-muted-foreground -mt-0.5",children:"Toggle on to require approval before tool executes"}),(0,v.jsx)("div",{className:"space-y-1 rounded-lg border p-2.5 bg-muted/30",children:eu?.availableTools.map(e=>{var t;let r=(t=e.id,eh.toolApprovals?.[t]!==void 0?eh.toolApprovals[t]:"bash"===t);return(0,v.jsxs)("div",{className:"flex items-center justify-between py-1.5 hover:bg-muted/50 rounded px-2 -mx-1 transition-colors",children:[(0,v.jsxs)("div",{className:"space-y-0",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)("span",{className:"text-sm font-medium",children:e.name}),e.dangerous&&(0,v.jsx)("span",{className:"text-[10px] bg-amber-500/20 text-amber-600 dark:text-amber-400 px-1.5 py-0.5 rounded font-medium",children:"risky"})]}),(0,v.jsx)("p",{className:"text-[11px] text-muted-foreground",children:e.description})]}),(0,v.jsx)(xp.Switch,{checked:r,onCheckedChange:()=>eD(e.id,r)})]},e.id)})})]}),(0,v.jsx)("p",{className:"text-xs text-muted-foreground",children:"These settings only apply to this session. Changes take effect for future tool calls."})]})]})}),!t&&ex?.updateAvailable&&!ev&&(0,v.jsxs)("div",{className:"px-4 py-2 border-b border-amber-500/30 bg-amber-500/10 flex items-center justify-between gap-3",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(xu,{className:"size-4 text-amber-600 dark:text-amber-400 shrink-0"}),(0,v.jsxs)("span",{className:"text-sm text-amber-700 dark:text-amber-300",children:["Update available: ",(0,v.jsxs)("strong",{children:["v",ex.latestVersion]}),(0,v.jsxs)("span",{className:"text-amber-600/70 dark:text-amber-400/70 ml-1",children:["(current: v",ex.currentVersion,")"]})]})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,v.jsx)(A.Button,{size:"sm",variant:"outline",className:"h-7 text-xs border-amber-500/50 bg-amber-500/20 hover:bg-amber-500/30 text-amber-700 dark:text-amber-300",onClick:eS,disabled:ew,children:ew?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(xe,{className:"size-3 mr-1.5 animate-spin"}),"Creating..."]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(xu,{className:"size-3 mr-1.5"}),"Update Now"]})}),(0,v.jsx)(_.TooltipProvider,{children:(0,v.jsxs)(_.Tooltip,{children:[(0,v.jsx)(_.TooltipTrigger,{asChild:!0,children:(0,v.jsx)(A.Button,{size:"icon",variant:"ghost",className:"size-6 text-amber-600 dark:text-amber-400 hover:bg-amber-500/20",onClick:()=>{eb(!0),ex?.latestVersion&&localStorage.setItem("sparkecoder-dismissed-version",ex.latestVersion)},children:(0,v.jsx)(xd.X,{className:"size-3.5"})})}),(0,v.jsx)(_.TooltipContent,{children:"Dismiss (won't show again for this version)"})]})})]})]}),!t&&z&&z.todos&&z.todos.length>0&&(0,v.jsx)("div",{className:"px-4 py-2 border-b border-border/50 bg-muted/20",children:(0,v.jsx)(g8,{todosData:z})}),D.length>0&&(0,v.jsx)("div",{className:(0,k.cn)("p-4 border-b border-border space-y-3",t&&"p-2 space-y-2"),children:D.map(e=>{let t=e.input;return(0,v.jsxs)(oq,{approval:{id:e.id,approved:!1},state:"approval-requested",children:[(0,v.jsx)(oH,{children:(0,v.jsxs)("div",{className:"flex items-start gap-3",children:[(0,v.jsx)("div",{className:"size-8 rounded-lg bg-amber-500/20 flex items-center justify-center shrink-0",children:(0,v.jsx)(xt,{className:"size-4 text-amber-500"})}),(0,v.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,v.jsx)("p",{className:"font-medium text-sm",children:"Approval Required"}),(0,v.jsx)("p",{className:"text-sm text-muted-foreground mt-0.5",children:(0,v.jsx)("code",{className:"bg-muted px-1.5 py-0.5 rounded font-mono text-foreground",children:e.toolName})}),(0,v.jsx)("div",{className:"mt-3 rounded-lg border bg-muted/30 overflow-hidden",children:Object.entries(t).map(([e,t])=>(0,v.jsxs)("div",{className:"flex border-b border-border/50 last:border-b-0",children:[(0,v.jsx)("div",{className:"px-3 py-2 bg-muted/50 text-xs font-medium text-muted-foreground w-24 shrink-0",children:e}),(0,v.jsx)("div",{className:"px-3 py-2 text-xs font-mono flex-1 min-w-0 overflow-auto max-h-24",children:"string"==typeof t?(0,v.jsx)("span",{className:"whitespace-pre-wrap break-words",children:t}):(0,v.jsx)("span",{className:"text-muted-foreground",children:JSON.stringify(t)})})]},e))})]})]})}),(0,v.jsxs)(oK,{children:[(0,v.jsx)(oX,{variant:"outline",onClick:()=>eI(e),children:"Reject"}),(0,v.jsx)(oX,{variant:"ghost",onClick:()=>eL(e),className:"text-muted-foreground hover:text-foreground",children:"Don't ask again"}),(0,v.jsx)(oX,{variant:"default",onClick:()=>eM(e),children:"Approve"})]})]},e.id)})}),(0,v.jsxs)($,{className:(0,k.cn)("flex-1 p-4",t&&"p-2"),children:[(0,v.jsxs)(V,{className:(0,k.cn)("max-w-3xl mx-auto w-full",t&&"max-w-none"),children:[J&&(0,v.jsx)("div",{className:"flex justify-center py-12",children:(0,v.jsx)(oJ,{size:24})}),!J&&0===n.length&&!S&&(0,v.jsx)(U,{icon:(0,v.jsxs)("div",{className:"relative overflow-hidden rounded-2xl size-16 shadow-lg ring-1 ring-white/10",children:[(0,v.jsx)(w.default,{src:"/sparke-coder.png",alt:"SparkECoder",width:64,height:64,className:"absolute inset-0 size-full object-cover",priority:!0}),c&&(0,v.jsx)("video",{src:"/sparkecode.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"absolute inset-0 size-full object-cover"})]}),title:"Start a conversation",description:"Ask SparkECoder to help you with coding tasks"}),n.filter(e=>!("tool-call"===e.type&&e.toolCall&&(D.some(t=>t.toolCallId===e.toolCall?.toolCallId)||I.some(t=>t.toolCallId===e.toolCall?.toolCallId||t.toolName===e.toolCall?.toolName&&("streaming"===t.status||"running"===t.status))))&&!0).map(e=>{if("user-message"===e.type){let t=void 0!==e.messageSequence&&B.some(t=>t.messageSequence===e.messageSequence);return(0,v.jsxs)(a$,{from:"user",children:[(0,v.jsxs)(aV,{children:[e.attachments&&e.attachments.length>0&&(0,v.jsx)("div",{className:"flex flex-wrap gap-2 mb-2",children:e.attachments.map((e,t)=>(0,v.jsx)("div",{className:"relative",children:"image"===e.type?(0,v.jsx)("div",{className:"relative rounded-lg overflow-hidden border border-border/50 max-w-[200px]",children:(0,v.jsx)("img",{src:e.data.startsWith("data:")?e.data:`data:${e.mediaType||"image/png"};base64,${e.data}`,alt:e.filename||"Image attachment",className:"max-w-full h-auto max-h-[150px] object-contain"})}):(0,v.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-muted/50 border border-border/50",children:[(0,v.jsx)(xc,{className:"h-4 w-4 text-muted-foreground"}),(0,v.jsx)("span",{className:"text-sm text-muted-foreground truncate max-w-[150px]",children:e.filename||"File"})]})},t))}),e.content&&(0,v.jsx)("p",{className:"whitespace-pre-wrap",children:e.content})]}),t&&!c&&(0,v.jsx)(aU,{className:"justify-end mt-1",children:(0,v.jsx)(_.TooltipProvider,{children:(0,v.jsxs)(_.Tooltip,{children:[(0,v.jsx)(_.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)(A.Button,{variant:"ghost",size:"sm",onClick:()=>e_(e.messageSequence,e.content),disabled:q,className:"h-6 px-2 text-xs text-muted-foreground hover:text-destructive gap-1",children:[(0,v.jsx)(xa,{className:"h-3 w-3"}),"Revert"]})}),(0,v.jsx)(_.TooltipContent,{children:(0,v.jsx)("p",{children:"Revert to before this message (undo all changes after)"})})]})})})]},e.id)}if("reasoning"===e.type)return(0,v.jsxs)(pH,{isStreaming:!1,defaultOpen:!1,children:[(0,v.jsx)(pX,{}),(0,v.jsx)(pY,{children:e.content||""})]},e.id);if("assistant-text"===e.type)return(0,v.jsx)(a$,{from:"assistant",children:(0,v.jsxs)("div",{className:"flex gap-3",children:[(0,v.jsx)("div",{className:"relative overflow-hidden rounded-lg size-8 shadow-sm ring-1 ring-white/10 shrink-0",children:(0,v.jsx)(w.default,{src:"/sparke-coder.png",alt:"SparkECoder",width:32,height:32,className:"absolute inset-0 size-full object-cover"})}),(0,v.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,v.jsx)(aV,{children:(0,v.jsx)(aq,{children:e.content||""})}),(0,v.jsx)(aU,{children:(0,v.jsx)(aG,{label:"Copy",onClick:()=>navigator.clipboard.writeText(e.content||""),children:(0,v.jsx)(om,{className:"size-3"})})})]})]})},e.id);if("tool-call"===e.type&&e.toolCall){let t=e.toolCall,r=`tool-${t.toolName}`;if("write_file"===t.toolName)return(0,v.jsx)(xx,{input:t.input,output:t.output,status:t.status,streamingArgsText:t.streamingArgsText,liveContent:t.liveContent,liveOldString:t.liveOldString,liveNewString:t.liveNewString},e.id);if("read_file"===t.toolName)return(0,v.jsx)(xb,{input:t.input,output:t.output,status:t.status},e.id);if("bash"===t.toolName)return(0,v.jsx)(xN,{input:t.input,output:t.output,status:t.status,terminalId:t.terminalId,liveOutput:t.liveOutput},e.id);if("explore_agent"===t.toolName)return(0,v.jsx)(xR,{input:t.input,output:t.output,status:t.status,steps:t.exploreSteps},e.id);if("todo"===t.toolName)return(0,v.jsx)(xF,{input:t.input,output:t.output,status:t.status},e.id);if("load_skill"===t.toolName)return(0,v.jsx)(xV,{input:t.input,output:t.output,status:t.status},e.id);if("linter"===t.toolName)return(0,v.jsx)(xH,{input:t.input,output:t.output,status:t.status},e.id);let n="completed"!==t.status;return(0,v.jsxs)(oE,{defaultOpen:n,children:[(0,v.jsx)(oP,{type:r,state:function(e){switch(e){case"pending":case"streaming":default:return"input-streaming";case"running":return"input-available";case"completed":return"output-available";case"rejected":return"output-denied";case"error":return"output-error"}}(t.status),title:t.toolName}),(0,v.jsxs)(oR,{children:[(0,v.jsx)(oM,{input:t.input}),(e=>{let t=e.output,r=e.input;if("bash"===e.toolName)return(0,v.jsx)(xN,{input:e.input,output:e.output,status:e.status,terminalId:e.terminalId,liveOutput:e.liveOutput,className:"mt-2"});if("explore_agent"===e.toolName)return(0,v.jsx)(xR,{input:e.input,output:e.output,status:e.status,steps:e.exploreSteps,className:"mt-2"});if("todo"===e.toolName)return(0,v.jsx)(xF,{input:e.input,output:e.output,status:e.status,className:"mt-2"});if("load_skill"===e.toolName)return(0,v.jsx)(xV,{input:e.input,output:e.output,status:e.status,className:"mt-2"});if("write_file"===e.toolName&&r){let e=r.path||"file",n=r.mode||"full",s=e.split("/").pop()||"file",i=eO(e);if("str_replace"===n){let e=r.old_string||"",n=r.new_string||"";return(0,v.jsxs)("div",{className:"mt-2 max-w-full overflow-hidden space-y-2",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,v.jsx)(xr,{className:"size-4 text-muted-foreground"}),(0,v.jsx)("span",{className:"font-medium",children:s}),(0,v.jsx)(C,{variant:"secondary",className:"text-xs",children:"str_replace"})]}),(0,v.jsxs)("div",{className:"rounded-md border overflow-hidden",children:[(0,v.jsxs)("div",{className:"bg-red-500/10 border-b p-2",children:[(0,v.jsx)("div",{className:"text-xs text-red-500 mb-1",children:"- Remove:"}),(0,v.jsx)("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words text-red-400",children:e.length>500?e.slice(0,500)+"...":e})]}),(0,v.jsxs)("div",{className:"bg-green-500/10 p-2",children:[(0,v.jsx)("div",{className:"text-xs text-green-500 mb-1",children:"+ Add:"}),(0,v.jsx)("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words text-green-400",children:n.length>500?n.slice(0,500)+"...":n})]})]}),t&&(0,v.jsxs)("div",{className:`text-xs flex items-center gap-1 ${t.success?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:[(0,v.jsx)("span",{children:t.success?"✓":"✗"}),(0,v.jsx)("span",{children:t.success?`Replaced (${void 0!==t.lineDelta?(t.lineDelta>=0?"+":"")+t.lineDelta+" lines":"done"})`:t.error||"Failed"})]})]})}let a=r.content||"";return(0,v.jsxs)("div",{className:"mt-2 max-w-full overflow-hidden",children:[(0,v.jsxs)(oL,{children:[(0,v.jsxs)(oD,{children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(xr,{className:"size-4 text-muted-foreground shrink-0"}),(0,v.jsx)(oO,{className:"truncate",children:s}),(0,v.jsx)(oz,{className:"truncate text-xs hidden sm:block",children:e})]}),(0,v.jsx)(oF,{children:(0,v.jsx)(oB,{icon:om,label:"Copy",onClick:()=>navigator.clipboard.writeText(a)})})]}),a&&(0,v.jsx)(o$,{className:"p-0 max-h-[300px] overflow-auto",children:(0,v.jsx)(oT,{code:a,language:i,showLineNumbers:!0,children:(0,v.jsx)(oS,{className:"sr-only",children:(0,v.jsx)(oC,{children:(0,v.jsx)(oA,{children:s})})})})})]}),t&&(0,v.jsxs)("div",{className:`mt-2 text-xs flex items-center gap-1 ${t.success?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:[(0,v.jsx)("span",{children:t.success?"✓":"✗"}),(0,v.jsx)("span",{children:t.success?`File ${t.action||"written"} successfully`:t.error||"Failed"})]})]})}if("read_file"===e.toolName&&t){let e=r?.path||"file",n=t.content||JSON.stringify(t,null,2),s=e.split("/").pop()||"file",i=eO(e);return(0,v.jsx)("div",{className:"mt-2 max-w-full overflow-hidden",children:(0,v.jsxs)(oL,{children:[(0,v.jsxs)(oD,{children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(xr,{className:"size-4 text-muted-foreground shrink-0"}),(0,v.jsx)(oO,{className:"truncate",children:s}),(0,v.jsx)(oz,{className:"truncate text-xs hidden sm:block",children:e})]}),(0,v.jsx)(oF,{children:(0,v.jsx)(oB,{icon:om,label:"Copy",onClick:()=>navigator.clipboard.writeText(n)})})]}),(0,v.jsx)(o$,{className:"p-0 max-h-[300px] overflow-auto",children:(0,v.jsx)(oT,{code:n,language:i,showLineNumbers:!0,children:(0,v.jsx)(oS,{className:"sr-only",children:(0,v.jsx)(oC,{children:(0,v.jsx)(oA,{children:s})})})})})]})})}return t?(0,v.jsx)(oI,{output:(0,v.jsxs)("pre",{className:"text-xs overflow-x-auto max-w-full whitespace-pre-wrap break-words",children:[JSON.stringify(t,null,2).slice(0,500),JSON.stringify(t).length>500?"...":""]}),errorText:"error"===e.status?"Tool execution failed":void 0}):null})(t)]})]},e.id)}return null}),c&&!S&&!E&&0===I.length&&(0,v.jsxs)("div",{className:"flex gap-3 items-center",children:[(0,v.jsx)("div",{className:"relative overflow-hidden rounded-lg size-8 shadow-sm ring-1 ring-white/10 shrink-0",children:(0,v.jsx)("video",{src:"/sparkecode.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"absolute inset-0 size-full object-cover"})}),(0,v.jsx)("span",{className:"text-sm text-muted-foreground",children:"Thinking..."})]}),c&&(R||E)&&(0,v.jsxs)(pH,{isStreaming:R,defaultOpen:!0,children:[(0,v.jsx)(pX,{}),(0,v.jsx)(pY,{children:E})]}),c&&S&&(0,v.jsx)(a$,{from:"assistant",children:(0,v.jsxs)("div",{className:"flex gap-3",children:[(0,v.jsx)("div",{className:"relative overflow-hidden rounded-lg size-8 shadow-sm ring-1 ring-white/10 shrink-0",children:(0,v.jsx)("video",{src:"/sparkecode.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"absolute inset-0 size-full object-cover"})}),(0,v.jsx)("div",{className:"flex-1 min-w-0",children:(0,v.jsxs)(aV,{children:[(0,v.jsx)(aq,{children:S}),(0,v.jsx)("span",{className:"inline-block w-2 h-4 bg-primary animate-pulse ml-1"})]})})]})}),c&&I.map(e=>"write_file"===e.toolName?(0,v.jsx)(xx,{input:e.input,output:e.output,status:e.status,streamingArgsText:e.streamingArgsText,liveContent:e.liveContent,liveOldString:e.liveOldString,liveNewString:e.liveNewString},e.toolCallId):"read_file"===e.toolName?(0,v.jsx)(xb,{input:e.input,output:e.output,status:e.status},e.toolCallId):"bash"===e.toolName?(0,v.jsx)(xN,{input:e.input,output:e.output,status:e.status,terminalId:e.terminalId,liveOutput:e.liveOutput},e.toolCallId):"explore_agent"===e.toolName?(0,v.jsx)(xR,{input:e.input,output:e.output,status:e.status,steps:e.exploreSteps},e.toolCallId):"todo"===e.toolName?(0,v.jsx)(xF,{input:e.input,output:e.output,status:e.status},e.toolCallId):"load_skill"===e.toolName?(0,v.jsx)(xV,{input:e.input,output:e.output,status:e.status},e.toolCallId):"linter"===e.toolName?(0,v.jsx)(xH,{input:e.input,output:e.output,status:e.status},e.toolCallId):(0,v.jsxs)(oE,{defaultOpen:!0,children:[(0,v.jsx)(oP,{type:`tool-${e.toolName}`,state:"streaming"===e.status?"input-streaming":"input-available",title:e.toolName}),(0,v.jsxs)(oR,{children:[(0,v.jsx)(oM,{input:e.input}),(0,v.jsxs)("div",{className:"flex items-center gap-2 p-3 text-muted-foreground",children:[(0,v.jsx)(oJ,{size:14}),(0,v.jsx)("span",{className:"text-sm",children:"streaming"===e.status?"Receiving...":"Executing..."})]})]})]},e.toolCallId)),c&&!S&&0===I.length&&(0,v.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,v.jsx)(oJ,{size:16}),(0,v.jsx)("span",{className:"text-sm",children:"Thinking..."})]})]}),(0,v.jsx)(G,{})]}),d&&(0,v.jsxs)("div",{className:"fixed bottom-28 right-4 w-80 max-h-80 overflow-auto border bg-background/95 shadow-lg rounded-md text-xs",children:[(0,v.jsx)("div",{className:"px-3 py-2 border-b font-mono text-muted-foreground",children:"SSE Debug"}),(0,v.jsxs)("div",{className:"px-3 py-2 space-y-1",children:[0===p.length&&0===f.length&&(0,v.jsx)("div",{className:"text-muted-foreground",children:"No events yet"}),p.map((e,t)=>(0,v.jsx)("div",{className:"font-mono",children:e},`evt-${t}`)),f.map((e,t)=>(0,v.jsx)("div",{className:"font-mono text-red-600",children:e},`err-${t}`))]})]}),(0,v.jsx)("div",{className:(0,k.cn)("border-t border-border/50 p-4 pb-6 bg-card/30",t&&"p-2 pb-2"),children:(0,v.jsxs)("div",{className:(0,k.cn)("max-w-3xl mx-auto",t&&"max-w-none"),children:[!t&&!J&&0===n.length&&!S&&!c&&(0,v.jsx)(gQ,{className:"mb-3",children:['Create a hello.txt file with "Hello, World!"',"List files in the current directory","Show the current git status"].map(e=>(0,v.jsx)(g0,{suggestion:e,onClick:e=>{a(e)}},e))}),(0,v.jsx)(yk,{children:(0,v.jsxs)(gM,{onSubmit:eP,className:"shadow-sm",globalDrop:!0,multiple:!0,children:[(0,v.jsx)(gL,{children:(0,v.jsx)(yS,{})}),(0,v.jsx)(gI,{children:(0,v.jsxs)("div",{className:"relative w-full",children:[(0,v.jsx)(yj,{sessionId:e.id,value:i+(o?(!i||i.endsWith(" ")||i.endsWith("\n")?"":" ")+o:""),onChange:e=>{o&&l(""),a(e)},placeholder:"Ask SparkECoder... (@ to mention files, / for commands)",disabled:c,autoFocus:!0,className:(0,k.cn)("min-h-[80px] focus:ring-2 focus:ring-primary/20 transition-all field-sizing-content max-h-48",o&&"caret-red-500",t&&"min-h-[40px] text-sm max-h-24")}),o&&(0,v.jsxs)("div",{className:"absolute bottom-2 right-2 flex items-center gap-1.5 text-xs text-red-500 bg-background/80 backdrop-blur-sm px-2 py-1 rounded-full",children:[(0,v.jsx)("span",{className:"size-2 bg-red-500 rounded-full animate-pulse"}),"Listening..."]})]})}),(0,v.jsxs)(gD,{className:t?"py-1":void 0,children:[!t&&(0,v.jsx)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:(0,v.jsx)("span",{className:"hidden sm:inline",children:"Type @ to mention files, / for commands"})}),(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)(xJ,{size:"icon",className:"size-9",onTranscriptionChange:e=>{a(t=>{let r=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(r?" ":"")+e})},onInterimTranscription:e=>{l(e)},disabled:c}),(0,v.jsx)(yC,{input:i+o,isRunning:c,onStop:eR})]})]})]})})]})})]})}e.s(["ChatInterface",()=>yA],557355)}]);
13
+ ${a}`}let o=a,l=r?.map(e=>({type:e.type,data:e.data,mediaType:e.mediaType,filename:e.filename})),c={id:`user-${Date.now()}`,type:"user-message",content:t||(i?"Selected elements attached":""),attachments:l};s(e=>[...e,c]),h(!0),L(!1),eh.current=!0,F(""),W(""),H(!1),X([]),es.current="",ei.current="",ea.current=[],ec.current=(0,g1.runAgent)(e.id,o||"Please analyze the attached files.",eF,{onStreamId:e=>O(e),attachments:r})},e$=async(e,t)=>{let r=!!(c&&c.trim());if(e.trim()||t&&0!==t.length||r){if(d){let r;return void(r={id:`q-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,text:e,attachments:t,selectedElements:c},m(e=>[...e,r]),a(""),u(null))}a(""),u(null),await eB(e,t,c)}},eV=async e=>{let t=!!e.text?.trim(),r=!!e.files?.length,n=!!(c&&c.trim());if(!t&&!r&&!n)return;let s=[];if(r&&e.files.length>0){for(let t of e.files)if(t.url)try{let e=await fetch(t.url),r=await e.blob(),n=await new Promise(e=>{let t=new FileReader;t.onloadend=()=>e(t.result),t.readAsDataURL(r)}),i=t.mediaType||r.type||"application/octet-stream",a=i.startsWith("image/");s.push({type:a?"image":"file",data:n,mediaType:i,filename:t.filename})}catch(e){console.error("Failed to process attachment:",e)}}e$(e.text||"",s.length>0?s:void 0)},eU=async()=>{try{await (0,g1.abortStream)(e.id)}catch(e){console.error("Failed to abort stream:",e)}if(ec.current&&(ec.current(),ec.current=null),ei.current.trim()){let e={id:`reasoning-${Date.now()}`,type:"reasoning",content:ei.current};s(t=>[...t,e])}if(es.current.trim()){let e={id:`text-${Date.now()}`,type:"assistant-text",content:es.current+" [stopped]"};s(t=>[...t,e])}F(""),W(""),H(!1),X([]),O(null),es.current="",ei.current="",ea.current=[],ed.current=!1,h(!1),L(!1)},eG=(0,b.useRef)(d),eW=(0,b.useRef)(!1);(0,b.useEffect)(()=>{let e=eG.current;if(eG.current=d,e&&!d&&p.length>0){if(eW.current){eW.current=!1;return}let e=setTimeout(()=>{m(e=>{if(0===e.length)return e;let[t,...r]=e;return eB(t.text,t.attachments,t.selectedElements),r})},300);return()=>clearTimeout(e)}},[d,p.length]);let eq=e=>{m(t=>t.map(t=>t.id===e?{...t,text:x}:t)),g(null),y("")},eH=async e=>{let t=p.find(t=>t.id===e);t&&(m(t=>t.filter(t=>t.id!==e)),d?(eW.current=!0,await eU(),setTimeout(()=>{eB(t.text,t.attachments,t.selectedElements)},500)):eB(t.text,t.attachments,t.selectedElements))},eK=async t=>{J(e=>e.filter(e=>e.id!==t.id));try{await (0,g1.approveExecution)(e.id,t.toolCallId)}catch(e){console.error("Failed to approve:",e)}},eX=async t=>{J(e=>e.filter(e=>e.id!==t.id));try{await (0,g1.rejectExecution)(e.id,t.toolCallId,"User rejected")}catch(e){console.error("Failed to reject:",e)}},eY=async t=>{J(e=>e.filter(e=>e.id!==t.id));try{await (0,g1.approveExecution)(e.id,t.toolCallId);let r=await (0,g1.updateToolApproval)(e.id,t.toolName,!1,ek);ej(r.config||{})}catch(e){console.error("Failed to approve and disable:",e)}},eJ=async(t,r)=>{try{let n=await (0,g1.updateToolApproval)(e.id,t,!r,ek);ej(n.config||{})}catch(e){console.error("Failed to update tool approval:",e)}},eZ=e=>({ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",php:"php",swift:"swift",kt:"kotlin",scala:"scala",sh:"bash",bash:"bash",zsh:"bash",fish:"bash",ps1:"powershell",sql:"sql",html:"html",htm:"html",css:"css",scss:"scss",sass:"sass",less:"less",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",md:"markdown",markdown:"markdown",txt:"plaintext",toml:"toml",ini:"ini",cfg:"ini",conf:"ini",dockerfile:"dockerfile",makefile:"makefile"})[e.split(".").pop()?.toLowerCase()||""]||"plaintext";return(0,v.jsxs)("div",{className:(0,k.cn)("flex flex-col h-full bg-background min-w-0 overflow-x-hidden",t&&"embed-mode text-[13px]"),children:[t&&(0,v.jsxs)("div",{className:"border-b border-border/50 px-2 py-1.5 flex items-center justify-between bg-card/50",children:[(0,v.jsx)(A.Button,{size:"icon",variant:"ghost",onClick:r,className:"size-6",children:(0,v.jsx)(xl.PanelLeft,{className:"size-3.5"})}),(0,v.jsx)("span",{className:"text-[11px] text-muted-foreground truncate max-w-[120px] font-medium",children:eg||"Session"}),(0,v.jsx)(A.Button,{size:"icon",variant:"ghost",onClick:()=>eS(!0),className:"size-6",children:(0,v.jsx)(xi.Settings,{className:"size-3.5"})})]}),!t&&(0,v.jsxs)("div",{className:"border-b border-border/50 px-3 sm:px-4 py-2 flex items-center justify-between bg-card/50 backdrop-blur-sm",children:[(0,v.jsxs)("div",{className:"min-w-0 flex items-center gap-2 sm:gap-3",children:[(0,v.jsx)(yP,{}),(0,v.jsx)("div",{className:"flex items-center gap-1.5",children:ey?(0,v.jsxs)("form",{onSubmit:e=>{e.preventDefault(),eI()},className:"flex items-center gap-1",children:[(0,v.jsx)(gg.Input,{ref:eC,value:eg,onChange:e=>ex(e.target.value),onBlur:eI,className:"h-7 text-sm font-semibold w-40 px-2",placeholder:"Session name"}),(0,v.jsx)(A.Button,{type:"submit",size:"icon",variant:"ghost",className:"size-6 text-muted-foreground hover:text-foreground",children:(0,v.jsx)(xs.Check,{className:"size-3.5"})})]}):(0,v.jsx)(_.TooltipProvider,{children:(0,v.jsxs)(_.Tooltip,{children:[(0,v.jsx)(_.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)("button",{onClick:()=>ev(!0),className:"flex items-center gap-1.5 group hover:bg-muted/50 rounded px-1.5 py-0.5 -mx-1.5 transition-colors",children:[(0,v.jsx)("h2",{className:"font-semibold text-foreground truncate max-w-[200px]",children:eg||"Untitled Session"}),(0,v.jsx)(xn,{className:"size-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]})}),(0,v.jsx)(_.TooltipContent,{children:"Click to rename"})]})})}),(0,v.jsx)(_.TooltipProvider,{children:(0,v.jsxs)(_.Tooltip,{children:[(0,v.jsx)(_.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-md bg-muted/30 text-xs text-muted-foreground max-w-[200px]",children:[(0,v.jsx)(xo,{className:"size-3.5 shrink-0"}),(0,v.jsx)("span",{className:"truncate font-mono",children:e.workingDirectory.split("/").pop()||e.workingDirectory})]})}),(0,v.jsx)(_.TooltipContent,{side:"bottom",className:"max-w-md",children:(0,v.jsx)("p",{className:"font-mono text-xs",children:e.workingDirectory})})]})})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[I&&(0,v.jsx)(_.TooltipProvider,{children:(0,v.jsxs)(_.Tooltip,{children:[(0,v.jsx)(_.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)(C,{variant:"outline",className:"gap-1.5 text-xs border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 cursor-help",children:[(0,v.jsx)("span",{className:"size-1.5 rounded-full bg-current animate-pulse"}),"Watching"]})}),(0,v.jsx)(_.TooltipContent,{children:"Watching stream from another client"})]})}),(0,v.jsx)(_.TooltipProvider,{children:(0,v.jsxs)(_.Tooltip,{children:[(0,v.jsx)(_.TooltipTrigger,{asChild:!0,children:(0,v.jsx)(C,{variant:d?"default":"secondary",className:`cursor-help ${d?"bg-primary/90":""}`,children:d?I?"streaming":"running":e.status})}),(0,v.jsx)(_.TooltipContent,{children:d?I?"Receiving streamed response":"Agent is processing":`Session is ${e.status}`})]})}),(0,v.jsx)(_.TooltipProvider,{children:(0,v.jsxs)(_.Tooltip,{children:[(0,v.jsx)(_.TooltipTrigger,{asChild:!0,children:(0,v.jsx)(A.Button,{size:"icon",variant:"ghost",className:"size-7 hover:bg-accent transition-colors",onClick:()=>eS(!0),children:(0,v.jsx)(xi.Settings,{className:"size-4"})})}),(0,v.jsx)(_.TooltipContent,{children:"Session Settings"})]})})]})]}),(0,v.jsx)(mw.Dialog,{open:eN,onOpenChange:eS,children:(0,v.jsxs)(mw.DialogContent,{className:"sm:max-w-md",children:[(0,v.jsx)(mw.DialogHeader,{children:(0,v.jsxs)(mw.DialogTitle,{className:"flex items-center gap-2",children:[(0,v.jsx)("div",{className:"size-8 rounded-lg bg-muted flex items-center justify-center",children:(0,v.jsx)(xi.Settings,{className:"size-4"})}),"Session Settings"]})}),(0,v.jsxs)("div",{className:"space-y-4 pt-2",children:[(0,v.jsxs)("div",{className:"space-y-2",children:[(0,v.jsx)(xb.Label,{className:"text-sm font-medium",children:"Model"}),(0,v.jsxs)(op.Select,{value:em,onValueChange:eM,disabled:d,children:[(0,v.jsx)(op.SelectTrigger,{className:"w-full",children:(0,v.jsx)(op.SelectValue,{placeholder:"Select model"})}),(0,v.jsx)(op.SelectContent,{children:eb?.availableModels.map(e=>(0,v.jsx)(op.SelectItem,{value:e.id,children:(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)("span",{children:e.name}),(0,v.jsx)("span",{className:"text-xs text-muted-foreground",children:e.provider})]})},e.id))})]}),d&&(0,v.jsx)("p",{className:"text-xs text-muted-foreground",children:"Cannot change model while agent is running"})]}),(0,v.jsxs)("div",{className:"space-y-2",children:[(0,v.jsx)(xb.Label,{className:"flex items-center gap-2 text-sm font-medium",children:"Tool Approvals"}),(0,v.jsx)("p",{className:"text-xs text-muted-foreground -mt-0.5",children:"Toggle on to require approval before tool executes"}),(0,v.jsx)("div",{className:"space-y-1 rounded-lg border p-2.5 bg-muted/30",children:eb?.availableTools.map(e=>{var t;let r=(t=e.id,ek.toolApprovals?.[t]!==void 0?ek.toolApprovals[t]:"bash"===t);return(0,v.jsxs)("div",{className:"flex items-center justify-between py-1.5 hover:bg-muted/50 rounded px-2 -mx-1 transition-colors",children:[(0,v.jsxs)("div",{className:"space-y-0",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)("span",{className:"text-sm font-medium",children:e.name}),e.dangerous&&(0,v.jsx)("span",{className:"text-[10px] bg-amber-500/20 text-amber-600 dark:text-amber-400 px-1.5 py-0.5 rounded font-medium",children:"risky"})]}),(0,v.jsx)("p",{className:"text-[11px] text-muted-foreground",children:e.description})]}),(0,v.jsx)(xv.Switch,{checked:r,onCheckedChange:()=>eJ(e.id,r)})]},e.id)})})]}),(0,v.jsx)("p",{className:"text-xs text-muted-foreground",children:"These settings only apply to this session. Changes take effect for future tool calls."})]})]})}),!t&&eA?.updateAvailable&&!eT&&(0,v.jsxs)("div",{className:"px-4 py-2 border-b border-amber-500/30 bg-amber-500/10 flex items-center justify-between gap-3",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(xu,{className:"size-4 text-amber-600 dark:text-amber-400 shrink-0"}),(0,v.jsxs)("span",{className:"text-sm text-amber-700 dark:text-amber-300",children:["Update available: ",(0,v.jsxs)("strong",{children:["v",eA.latestVersion]}),(0,v.jsxs)("span",{className:"text-amber-600/70 dark:text-amber-400/70 ml-1",children:["(current: v",eA.currentVersion,")"]})]})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,v.jsx)(A.Button,{size:"sm",variant:"outline",className:"h-7 text-xs border-amber-500/50 bg-amber-500/20 hover:bg-amber-500/30 text-amber-700 dark:text-amber-300",onClick:eL,disabled:eP,children:eP?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(xe,{className:"size-3 mr-1.5 animate-spin"}),"Creating..."]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(xu,{className:"size-3 mr-1.5"}),"Update Now"]})}),(0,v.jsx)(_.TooltipProvider,{children:(0,v.jsxs)(_.Tooltip,{children:[(0,v.jsx)(_.TooltipTrigger,{asChild:!0,children:(0,v.jsx)(A.Button,{size:"icon",variant:"ghost",className:"size-6 text-amber-600 dark:text-amber-400 hover:bg-amber-500/20",onClick:()=>{eE(!0),eA?.latestVersion&&localStorage.setItem("sparkecoder-dismissed-version",eA.latestVersion)},children:(0,v.jsx)(xd.X,{className:"size-3.5"})})}),(0,v.jsx)(_.TooltipContent,{children:"Dismiss (won't show again for this version)"})]})})]})]}),!t&&Z&&Z.todos&&Z.todos.length>0&&(0,v.jsx)("div",{className:"px-4 py-2 border-b border-border/50 bg-muted/20",children:(0,v.jsx)(g8,{todosData:Z})}),Y.length>0&&(0,v.jsx)("div",{className:(0,k.cn)("p-4 border-b border-border space-y-3",t&&"p-2 space-y-2"),children:Y.map(e=>{let t=e.input;return(0,v.jsxs)(oq,{approval:{id:e.id,approved:!1},state:"approval-requested",children:[(0,v.jsx)(oH,{children:(0,v.jsxs)("div",{className:"flex items-start gap-3",children:[(0,v.jsx)("div",{className:"size-8 rounded-lg bg-amber-500/20 flex items-center justify-center shrink-0",children:(0,v.jsx)(xt,{className:"size-4 text-amber-500"})}),(0,v.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,v.jsx)("p",{className:"font-medium text-sm",children:"Approval Required"}),(0,v.jsx)("p",{className:"text-sm text-muted-foreground mt-0.5",children:(0,v.jsx)("code",{className:"bg-muted px-1.5 py-0.5 rounded font-mono text-foreground",children:e.toolName})}),(0,v.jsx)("div",{className:"mt-3 rounded-lg border bg-muted/30 overflow-hidden",children:Object.entries(t).map(([e,t])=>(0,v.jsxs)("div",{className:"flex border-b border-border/50 last:border-b-0",children:[(0,v.jsx)("div",{className:"px-3 py-2 bg-muted/50 text-xs font-medium text-muted-foreground w-24 shrink-0",children:e}),(0,v.jsx)("div",{className:"px-3 py-2 text-xs font-mono flex-1 min-w-0 overflow-auto max-h-24",children:"string"==typeof t?(0,v.jsx)("span",{className:"whitespace-pre-wrap break-words",children:t}):(0,v.jsx)("span",{className:"text-muted-foreground",children:JSON.stringify(t)})})]},e))})]})]})}),(0,v.jsxs)(oK,{children:[(0,v.jsx)(oX,{variant:"outline",onClick:()=>eX(e),children:"Reject"}),(0,v.jsx)(oX,{variant:"ghost",onClick:()=>eY(e),className:"text-muted-foreground hover:text-foreground",children:"Don't ask again"}),(0,v.jsx)(oX,{variant:"default",onClick:()=>eK(e),children:"Approve"})]})]},e.id)})}),(0,v.jsxs)($,{className:(0,k.cn)("flex-1 p-4",t&&"p-2"),children:[(0,v.jsxs)(V,{className:(0,k.cn)("max-w-3xl mx-auto w-full",t&&"max-w-none"),children:[eo&&(0,v.jsx)("div",{className:"flex justify-center py-12",children:(0,v.jsx)(oJ,{size:24})}),!eo&&0===n.length&&!z&&(0,v.jsx)(U,{icon:(0,v.jsxs)("div",{className:"relative overflow-hidden rounded-2xl size-16 shadow-lg ring-1 ring-white/10",children:[(0,v.jsx)(w.default,{src:"/sparke-coder.png",alt:"SparkECoder",width:64,height:64,className:"absolute inset-0 size-full object-cover",priority:!0}),d&&(0,v.jsx)("video",{src:"/sparkecode.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"absolute inset-0 size-full object-cover"})]}),title:"Start a conversation",description:"Ask SparkECoder to help you with coding tasks"}),n.filter(e=>!("tool-call"===e.type&&e.toolCall&&(Y.some(t=>t.toolCallId===e.toolCall?.toolCallId)||K.some(t=>t.toolCallId===e.toolCall?.toolCallId||t.toolName===e.toolCall?.toolName&&("streaming"===t.status||"running"===t.status))))&&!0).map(e=>{if("user-message"===e.type){let t,r,n=void 0!==e.messageSequence&&ee.some(t=>t.messageSequence===e.messageSequence);return(0,v.jsxs)(a$,{from:"user",children:[(0,v.jsxs)(aV,{children:[e.attachments&&e.attachments.length>0&&(0,v.jsx)("div",{className:"flex flex-wrap gap-2 mb-2",children:e.attachments.map((e,t)=>(0,v.jsx)("div",{className:"relative",children:"image"===e.type?(0,v.jsx)("div",{className:"relative rounded-lg overflow-hidden border border-border/50 max-w-[200px]",children:(0,v.jsx)("img",{src:e.data.startsWith("data:")?e.data:`data:${e.mediaType||"image/png"};base64,${e.data}`,alt:e.filename||"Image attachment",className:"max-w-full h-auto max-h-[150px] object-contain"})}):(0,v.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-muted/50 border border-border/50",children:[(0,v.jsx)(xc,{className:"h-4 w-4 text-muted-foreground"}),(0,v.jsx)("span",{className:"text-sm text-muted-foreground truncate max-w-[150px]",children:e.filename||"File"})]})},t))}),e.content&&(t=e.content.replace(yE,"").trim(),r=function(e){let t=e.match(/<devtools-context>([\s\S]*?)<\/devtools-context>/);if(!t)return null;let r=t[1],n=r.match(/<page\s+url="([^"]*)"\s+path="([^"]*)"\s+name="([^"]*)"/),s=r.match(/<viewport\s+width="([^"]*)"\s+height="([^"]*)"(?:\s+dpr="([^"]*)")?/);return n?{url:n[1],path:n[2],pageName:n[3],viewportWidth:s?.[1],viewportHeight:s?.[2],dpr:s?.[3]}:null}(e.content),(0,v.jsxs)(v.Fragment,{children:[t&&(0,v.jsx)("p",{className:"whitespace-pre-wrap",children:t}),r&&(0,v.jsxs)("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-muted-foreground/60",children:[(0,v.jsx)(xx,{className:"h-3 w-3"}),(0,v.jsx)("span",{children:r.path}),r.viewportWidth&&r.viewportHeight&&(0,v.jsxs)("span",{className:"text-muted-foreground/40",children:[r.viewportWidth,"x",r.viewportHeight]})]})]}))]}),n&&!d&&(0,v.jsx)(aU,{className:"justify-end mt-1",children:(0,v.jsx)(_.TooltipProvider,{children:(0,v.jsxs)(_.Tooltip,{children:[(0,v.jsx)(_.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)(A.Button,{variant:"ghost",size:"sm",onClick:()=>ez(e.messageSequence,e.content),disabled:er,className:"h-6 px-2 text-xs text-muted-foreground hover:text-destructive gap-1",children:[(0,v.jsx)(xa,{className:"h-3 w-3"}),"Revert"]})}),(0,v.jsx)(_.TooltipContent,{children:(0,v.jsx)("p",{children:"Revert to before this message (undo all changes after)"})})]})})})]},e.id)}if("reasoning"===e.type)return(0,v.jsxs)(pH,{isStreaming:!1,defaultOpen:!1,children:[(0,v.jsx)(pX,{}),(0,v.jsx)(pY,{children:e.content||""})]},e.id);if("assistant-text"===e.type)return(0,v.jsx)(a$,{from:"assistant",children:(0,v.jsxs)("div",{className:"flex gap-3",children:[(0,v.jsx)("div",{className:"relative overflow-hidden rounded-lg size-8 shadow-sm ring-1 ring-white/10 shrink-0",children:(0,v.jsx)(w.default,{src:"/sparke-coder.png",alt:"SparkECoder",width:32,height:32,className:"absolute inset-0 size-full object-cover"})}),(0,v.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,v.jsx)(aV,{children:(0,v.jsx)(aq,{children:e.content||""})}),(0,v.jsx)(aU,{children:(0,v.jsx)(aG,{label:"Copy",onClick:()=>navigator.clipboard.writeText(e.content||""),children:(0,v.jsx)(om,{className:"size-3"})})})]})]})},e.id);if("tool-call"===e.type&&e.toolCall){let t=e.toolCall,r=`tool-${t.toolName}`;if("write_file"===t.toolName)return(0,v.jsx)(xj,{input:t.input,output:t.output,status:t.status,streamingArgsText:t.streamingArgsText,liveContent:t.liveContent,liveOldString:t.liveOldString,liveNewString:t.liveNewString},e.id);if("read_file"===t.toolName)return(0,v.jsx)(xC,{input:t.input,output:t.output,status:t.status},e.id);if("bash"===t.toolName)return(0,v.jsx)(xE,{input:t.input,output:t.output,status:t.status,terminalId:t.terminalId,liveOutput:t.liveOutput},e.id);if("explore_agent"===t.toolName)return(0,v.jsx)(xz,{input:t.input,output:t.output,status:t.status,steps:t.exploreSteps},e.id);if("todo"===t.toolName)return(0,v.jsx)(xW,{input:t.input,output:t.output,status:t.status},e.id);if("load_skill"===t.toolName)return(0,v.jsx)(xK,{input:t.input,output:t.output,status:t.status},e.id);if("linter"===t.toolName)return(0,v.jsx)(xQ,{input:t.input,output:t.output,status:t.status},e.id);let n="completed"!==t.status;return(0,v.jsxs)(oE,{defaultOpen:n,children:[(0,v.jsx)(oP,{type:r,state:function(e){switch(e){case"pending":case"streaming":default:return"input-streaming";case"running":return"input-available";case"completed":return"output-available";case"rejected":return"output-denied";case"error":return"output-error"}}(t.status),title:t.toolName}),(0,v.jsxs)(oR,{children:[(0,v.jsx)(oM,{input:t.input}),(e=>{let t=e.output,r=e.input;if("bash"===e.toolName)return(0,v.jsx)(xE,{input:e.input,output:e.output,status:e.status,terminalId:e.terminalId,liveOutput:e.liveOutput,className:"mt-2"});if("explore_agent"===e.toolName)return(0,v.jsx)(xz,{input:e.input,output:e.output,status:e.status,steps:e.exploreSteps,className:"mt-2"});if("todo"===e.toolName)return(0,v.jsx)(xW,{input:e.input,output:e.output,status:e.status,className:"mt-2"});if("load_skill"===e.toolName)return(0,v.jsx)(xK,{input:e.input,output:e.output,status:e.status,className:"mt-2"});if("write_file"===e.toolName&&r){let e=r.path||"file",n=r.mode||"full",s=e.split("/").pop()||"file",i=eZ(e);if("str_replace"===n){let e=r.old_string||"",n=r.new_string||"";return(0,v.jsxs)("div",{className:"mt-2 max-w-full overflow-hidden space-y-2",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,v.jsx)(xr,{className:"size-4 text-muted-foreground"}),(0,v.jsx)("span",{className:"font-medium",children:s}),(0,v.jsx)(C,{variant:"secondary",className:"text-xs",children:"str_replace"})]}),(0,v.jsxs)("div",{className:"rounded-md border overflow-hidden",children:[(0,v.jsxs)("div",{className:"bg-red-500/10 border-b p-2",children:[(0,v.jsx)("div",{className:"text-xs text-red-500 mb-1",children:"- Remove:"}),(0,v.jsx)("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words text-red-400",children:e.length>500?e.slice(0,500)+"...":e})]}),(0,v.jsxs)("div",{className:"bg-green-500/10 p-2",children:[(0,v.jsx)("div",{className:"text-xs text-green-500 mb-1",children:"+ Add:"}),(0,v.jsx)("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words text-green-400",children:n.length>500?n.slice(0,500)+"...":n})]})]}),t&&(0,v.jsxs)("div",{className:`text-xs flex items-center gap-1 ${t.success?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:[(0,v.jsx)("span",{children:t.success?"✓":"✗"}),(0,v.jsx)("span",{children:t.success?`Replaced (${void 0!==t.lineDelta?(t.lineDelta>=0?"+":"")+t.lineDelta+" lines":"done"})`:t.error||"Failed"})]})]})}let a=r.content||"";return(0,v.jsxs)("div",{className:"mt-2 max-w-full overflow-hidden",children:[(0,v.jsxs)(oL,{children:[(0,v.jsxs)(oD,{children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(xr,{className:"size-4 text-muted-foreground shrink-0"}),(0,v.jsx)(oO,{className:"truncate",children:s}),(0,v.jsx)(oz,{className:"truncate text-xs hidden sm:block",children:e})]}),(0,v.jsx)(oF,{children:(0,v.jsx)(oB,{icon:om,label:"Copy",onClick:()=>navigator.clipboard.writeText(a)})})]}),a&&(0,v.jsx)(o$,{className:"p-0 max-h-[300px] overflow-auto",children:(0,v.jsx)(oT,{code:a,language:i,showLineNumbers:!0,children:(0,v.jsx)(oS,{className:"sr-only",children:(0,v.jsx)(oC,{children:(0,v.jsx)(oA,{children:s})})})})})]}),t&&(0,v.jsxs)("div",{className:`mt-2 text-xs flex items-center gap-1 ${t.success?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:[(0,v.jsx)("span",{children:t.success?"✓":"✗"}),(0,v.jsx)("span",{children:t.success?`File ${t.action||"written"} successfully`:t.error||"Failed"})]})]})}if("read_file"===e.toolName&&t){let e=r?.path||"file",n=t.content||JSON.stringify(t,null,2),s=e.split("/").pop()||"file",i=eZ(e);return(0,v.jsx)("div",{className:"mt-2 max-w-full overflow-hidden",children:(0,v.jsxs)(oL,{children:[(0,v.jsxs)(oD,{children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(xr,{className:"size-4 text-muted-foreground shrink-0"}),(0,v.jsx)(oO,{className:"truncate",children:s}),(0,v.jsx)(oz,{className:"truncate text-xs hidden sm:block",children:e})]}),(0,v.jsx)(oF,{children:(0,v.jsx)(oB,{icon:om,label:"Copy",onClick:()=>navigator.clipboard.writeText(n)})})]}),(0,v.jsx)(o$,{className:"p-0 max-h-[300px] overflow-auto",children:(0,v.jsx)(oT,{code:n,language:i,showLineNumbers:!0,children:(0,v.jsx)(oS,{className:"sr-only",children:(0,v.jsx)(oC,{children:(0,v.jsx)(oA,{children:s})})})})})]})})}return t?(0,v.jsx)(oI,{output:(0,v.jsxs)("pre",{className:"text-xs overflow-x-auto max-w-full whitespace-pre-wrap break-words",children:[JSON.stringify(t,null,2).slice(0,500),JSON.stringify(t).length>500?"...":""]}),errorText:"error"===e.status?"Tool execution failed":void 0}):null})(t)]})]},e.id)}return null}),d&&!z&&!B&&0===K.length&&(0,v.jsxs)("div",{className:"flex gap-3 items-center",children:[(0,v.jsx)("div",{className:"relative overflow-hidden rounded-lg size-8 shadow-sm ring-1 ring-white/10 shrink-0",children:(0,v.jsx)("video",{src:"/sparkecode.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"absolute inset-0 size-full object-cover"})}),(0,v.jsx)("span",{className:"text-sm text-muted-foreground",children:"Thinking..."})]}),d&&(q||B)&&(0,v.jsxs)(pH,{isStreaming:q,defaultOpen:!0,children:[(0,v.jsx)(pX,{}),(0,v.jsx)(pY,{children:B})]}),d&&z&&(0,v.jsx)(a$,{from:"assistant",children:(0,v.jsxs)("div",{className:"flex gap-3",children:[(0,v.jsx)("div",{className:"relative overflow-hidden rounded-lg size-8 shadow-sm ring-1 ring-white/10 shrink-0",children:(0,v.jsx)("video",{src:"/sparkecode.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"absolute inset-0 size-full object-cover"})}),(0,v.jsx)("div",{className:"flex-1 min-w-0",children:(0,v.jsxs)(aV,{children:[(0,v.jsx)(aq,{children:z}),(0,v.jsx)("span",{className:"inline-block w-2 h-4 bg-primary animate-pulse ml-1"})]})})]})}),d&&K.map(e=>"write_file"===e.toolName?(0,v.jsx)(xj,{input:e.input,output:e.output,status:e.status,streamingArgsText:e.streamingArgsText,liveContent:e.liveContent,liveOldString:e.liveOldString,liveNewString:e.liveNewString},e.toolCallId):"read_file"===e.toolName?(0,v.jsx)(xC,{input:e.input,output:e.output,status:e.status},e.toolCallId):"bash"===e.toolName?(0,v.jsx)(xE,{input:e.input,output:e.output,status:e.status,terminalId:e.terminalId,liveOutput:e.liveOutput},e.toolCallId):"explore_agent"===e.toolName?(0,v.jsx)(xz,{input:e.input,output:e.output,status:e.status,steps:e.exploreSteps},e.toolCallId):"todo"===e.toolName?(0,v.jsx)(xW,{input:e.input,output:e.output,status:e.status},e.toolCallId):"load_skill"===e.toolName?(0,v.jsx)(xK,{input:e.input,output:e.output,status:e.status},e.toolCallId):"linter"===e.toolName?(0,v.jsx)(xQ,{input:e.input,output:e.output,status:e.status},e.toolCallId):(0,v.jsxs)(oE,{defaultOpen:!0,children:[(0,v.jsx)(oP,{type:`tool-${e.toolName}`,state:"streaming"===e.status?"input-streaming":"input-available",title:e.toolName}),(0,v.jsxs)(oR,{children:[(0,v.jsx)(oM,{input:e.input}),(0,v.jsxs)("div",{className:"flex items-center gap-2 p-3 text-muted-foreground",children:[(0,v.jsx)(oJ,{size:14}),(0,v.jsx)("span",{className:"text-sm",children:"streaming"===e.status?"Receiving...":"Executing..."})]})]})]},e.toolCallId)),d&&!z&&0===K.length&&(0,v.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,v.jsx)(oJ,{size:16}),(0,v.jsx)("span",{className:"text-sm",children:"Thinking..."})]})]}),(0,v.jsx)(G,{})]}),S&&(0,v.jsxs)("div",{className:"fixed bottom-28 right-4 w-80 max-h-80 overflow-auto border bg-background/95 shadow-lg rounded-md text-xs",children:[(0,v.jsx)("div",{className:"px-3 py-2 border-b font-mono text-muted-foreground",children:"SSE Debug"}),(0,v.jsxs)("div",{className:"px-3 py-2 space-y-1",children:[0===E.length&&0===R.length&&(0,v.jsx)("div",{className:"text-muted-foreground",children:"No events yet"}),E.map((e,t)=>(0,v.jsx)("div",{className:"font-mono",children:e},`evt-${t}`)),R.map((e,t)=>(0,v.jsx)("div",{className:"font-mono text-red-600",children:e},`err-${t}`))]})]}),(0,v.jsx)("div",{className:(0,k.cn)("border-t border-border/50 p-4 pb-6 bg-card/30",t&&"p-2 pb-2"),children:(0,v.jsxs)("div",{className:(0,k.cn)("max-w-3xl mx-auto",t&&"max-w-none"),children:[!t&&!eo&&0===n.length&&!z&&!d&&(0,v.jsx)(gQ,{className:"mb-3",children:['Create a hello.txt file with "Hello, World!"',"List files in the current directory","Show the current git status"].map(e=>(0,v.jsx)(g0,{suggestion:e,onClick:e=>{a(e)}},e))}),p.length>0&&(0,v.jsxs)("div",{className:(0,k.cn)("mb-2 rounded-lg border border-border/60 bg-muted/20 overflow-hidden",t&&"mb-1"),children:[(0,v.jsxs)("button",{type:"button",onClick:()=>N(e=>!e),className:(0,k.cn)("w-full flex items-center justify-between px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/30 transition-colors",t&&"px-2 py-1"),children:[(0,v.jsxs)("div",{className:"flex items-center gap-1.5",children:[j?(0,v.jsx)(xh.default,{className:"size-3"}):(0,v.jsx)(xp.default,{className:"size-3"}),(0,v.jsxs)("span",{className:"font-medium",children:[p.length," Queued"]})]}),(0,v.jsx)("span",{className:"text-[10px]",children:"Stop ^C"})]}),j&&(0,v.jsx)("div",{className:"border-t border-border/40 divide-y divide-border/30",children:p.map((e,r)=>(0,v.jsxs)("div",{className:(0,k.cn)("flex items-start gap-2 px-3 py-2 group",t&&"px-2 py-1.5 gap-1.5"),children:[(0,v.jsx)("span",{className:"text-[10px] text-muted-foreground/60 pt-0.5 w-4 shrink-0 text-center",children:r+1}),(0,v.jsxs)("div",{className:"flex-1 min-w-0",children:[f===e.id?(0,v.jsxs)("div",{className:"flex items-center gap-1",children:[(0,v.jsx)("input",{type:"text",value:x,onChange:e=>y(e.target.value),onKeyDown:t=>{"Enter"===t.key&&eq(e.id),"Escape"===t.key&&g(null)},className:(0,k.cn)("flex-1 bg-background border border-border rounded px-2 py-0.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary/30",t&&"text-[11px]"),autoFocus:!0}),(0,v.jsx)("button",{type:"button",onClick:()=>eq(e.id),className:"p-0.5 text-primary hover:text-primary/80",children:(0,v.jsx)(xs.Check,{className:"size-3"})})]}):(0,v.jsx)("p",{className:(0,k.cn)("text-xs text-foreground truncate",t&&"text-[11px]"),children:e.text||"Selected elements attached"}),e.attachments&&e.attachments.length>0&&(0,v.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[e.attachments.length," file",e.attachments.length>1?"s":""]}),e.selectedElements&&(0,v.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"+ selected elements"})]}),(0,v.jsxs)("div",{className:(0,k.cn)("flex items-center gap-0.5 shrink-0 transition-opacity",t?"opacity-100":"opacity-0 group-hover:opacity-100"),children:[(0,v.jsx)("button",{type:"button",onClick:()=>{g(e.id),y(e.text)},className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/50",title:"Edit",children:(0,v.jsx)(xn,{className:"size-3"})}),r>0&&(0,v.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.id,void m(e=>{let r=e.findIndex(e=>e.id===t);if(-1===r)return e;let n=r-1;if(n<0||n>=e.length)return e;let s=[...e];return[s[r],s[n]]=[s[n],s[r]],s})},className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/50",title:"Move up",children:(0,v.jsx)(xf,{className:"size-3"})}),(0,v.jsx)("button",{type:"button",onClick:()=>eH(e.id),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/50",title:"Send now",children:(0,v.jsx)(xm,{className:"size-3"})}),(0,v.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.id,void m(e=>e.filter(e=>e.id!==t))},className:"p-1 rounded text-muted-foreground hover:text-destructive hover:bg-muted/50",title:"Remove",children:(0,v.jsx)(xg.Trash2,{className:"size-3"})})]})]},e.id))})]}),(0,v.jsx)(y_,{children:(0,v.jsxs)(gM,{onSubmit:eV,className:"shadow-sm",globalDrop:!0,multiple:!0,children:[(0,v.jsxs)(gL,{children:[c&&(0,v.jsxs)("div",{className:(0,k.cn)("mb-2 flex items-center justify-between rounded-md border border-border/60 bg-muted/40 px-2 py-1 text-xs",t&&"mb-1"),children:[(0,v.jsxs)("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,v.jsx)("span",{className:"size-1.5 rounded-full bg-primary/70"}),(0,v.jsx)("span",{children:"Selected elements attached"})]}),(0,v.jsx)("button",{type:"button",onClick:()=>u(null),className:"rounded-sm p-1 text-muted-foreground hover:text-foreground","aria-label":"Remove selected elements",children:(0,v.jsx)(xd.X,{className:"size-3.5"})})]}),(0,v.jsx)(yR,{})]}),(0,v.jsx)(gI,{children:(0,v.jsxs)("div",{className:"relative w-full",children:[(0,v.jsx)(yT,{sessionId:e.id,value:i+(o?(!i||i.endsWith(" ")||i.endsWith("\n")?"":" ")+o:""),onChange:e=>{o&&l(""),a(e)},placeholder:d?"Type to queue a message...":"Ask SparkECoder... (@ to mention files, / for commands)",disabled:!1,autoFocus:!0,className:(0,k.cn)("min-h-[80px] focus:ring-2 focus:ring-primary/20 transition-all field-sizing-content max-h-48",o&&"caret-red-500",t&&"min-h-[40px] text-sm max-h-24")}),o&&(0,v.jsxs)("div",{className:"absolute bottom-2 right-2 flex items-center gap-1.5 text-xs text-red-500 bg-background/80 backdrop-blur-sm px-2 py-1 rounded-full",children:[(0,v.jsx)("span",{className:"size-2 bg-red-500 rounded-full animate-pulse"}),"Listening..."]})]})}),(0,v.jsxs)(gD,{className:t?"py-1":void 0,children:[!t&&(0,v.jsx)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:(0,v.jsx)("span",{className:"hidden sm:inline",children:"Type @ to mention files, / for commands"})}),(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)(x5,{size:"icon",className:"size-9",onTranscriptionChange:e=>{a(t=>{let r=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(r?" ":"")+e})},onInterimTranscription:e=>{l(e)},disabled:d}),(0,v.jsx)(yM,{input:i+o,isRunning:d,onStop:eU,hasExtraContent:!!(c&&c.trim())})]})]})]})})]})})]})}e.s(["ChatInterface",()=>yI],557355)}]);