@hanzo/ui 5.3.19 → 5.3.22

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 (229) hide show
  1. package/dist/3d/button.js +298 -1
  2. package/dist/3d/button.mjs +273 -1
  3. package/dist/3d/card.js +234 -1
  4. package/dist/3d/card.mjs +207 -1
  5. package/dist/3d/carousel.js +371 -1
  6. package/dist/3d/carousel.mjs +344 -1
  7. package/dist/3d/grid.js +362 -1
  8. package/dist/3d/grid.mjs +337 -1
  9. package/dist/3d/index.js +1518 -1
  10. package/dist/3d/index.mjs +1472 -1
  11. package/dist/3d/marquee.js +352 -1
  12. package/dist/3d/marquee.mjs +327 -1
  13. package/dist/3d/pin.js +46 -1
  14. package/dist/3d/pin.mjs +24 -1
  15. package/dist/accordion.js +80 -1
  16. package/dist/accordion.mjs +55 -1
  17. package/dist/alert-dialog.js +220 -1
  18. package/dist/alert-dialog.mjs +187 -1
  19. package/dist/alert.js +68 -1
  20. package/dist/alert.mjs +64 -1
  21. package/dist/animation/animated-background.js +424 -1
  22. package/dist/animation/animated-background.mjs +418 -1
  23. package/dist/animation/animated-beam.js +119 -1
  24. package/dist/animation/animated-beam.mjs +97 -1
  25. package/dist/animation/animated-cursor.js +275 -1
  26. package/dist/animation/animated-cursor.mjs +270 -1
  27. package/dist/animation/animated-icon.js +357 -2
  28. package/dist/animation/animated-icon.mjs +351 -2
  29. package/dist/animation/animated-list.js +339 -1
  30. package/dist/animation/animated-list.mjs +333 -1
  31. package/dist/animation/animated-number.js +283 -1
  32. package/dist/animation/animated-number.mjs +277 -1
  33. package/dist/animation/animated-testimonials.js +97 -1
  34. package/dist/animation/animated-testimonials.mjs +75 -1
  35. package/dist/animation/animated-tooltip.js +67 -1
  36. package/dist/animation/animated-tooltip.mjs +45 -1
  37. package/dist/animation/apple-cards-carousel.js +308 -1
  38. package/dist/animation/apple-cards-carousel.mjs +285 -1
  39. package/dist/animation/apple-hello-effect.js +60 -1
  40. package/dist/animation/apple-hello-effect.mjs +38 -1
  41. package/dist/animation/index.js +1952 -2
  42. package/dist/animation/index.mjs +1921 -2
  43. package/dist/avatar.js +71 -1
  44. package/dist/avatar.mjs +47 -1
  45. package/dist/badge.js +66 -1
  46. package/dist/badge.mjs +40 -1
  47. package/dist/blocks/index.js +1665 -2
  48. package/dist/blocks/index.mjs +1626 -2
  49. package/dist/breadcrumb.js +107 -1
  50. package/dist/breadcrumb.mjs +99 -1
  51. package/dist/calendar.js +189 -1
  52. package/dist/calendar.mjs +164 -1
  53. package/dist/carousel.js +278 -1
  54. package/dist/carousel.mjs +249 -1
  55. package/dist/checkbox.js +60 -1
  56. package/dist/checkbox.mjs +35 -1
  57. package/dist/code/block.js +226 -2
  58. package/dist/code/block.mjs +203 -2
  59. package/dist/code/compare.js +445 -5
  60. package/dist/code/compare.mjs +422 -5
  61. package/dist/code/diff.js +430 -12
  62. package/dist/code/diff.mjs +406 -11
  63. package/dist/code/editor.js +243 -1
  64. package/dist/code/editor.mjs +218 -1
  65. package/dist/code/explorer.js +291 -1
  66. package/dist/code/explorer.mjs +268 -1
  67. package/dist/code/index.js +2515 -26
  68. package/dist/code/index.mjs +2472 -24
  69. package/dist/code/preview.js +364 -6
  70. package/dist/code/preview.mjs +341 -6
  71. package/dist/code/snippet.js +274 -2
  72. package/dist/code/snippet.mjs +250 -2
  73. package/dist/code/tabs.js +75 -1
  74. package/dist/code/tabs.mjs +53 -1
  75. package/dist/code/terminal.js +437 -3
  76. package/dist/code/terminal.mjs +414 -3
  77. package/dist/collapsible.js +33 -1
  78. package/dist/collapsible.mjs +9 -1
  79. package/dist/command.js +262 -1
  80. package/dist/command.mjs +232 -1
  81. package/dist/context-menu.js +207 -1
  82. package/dist/context-menu.mjs +171 -1
  83. package/dist/device/index.js +3 -1
  84. package/dist/device/index.mjs +2 -0
  85. package/dist/dialog.js +151 -1
  86. package/dist/dialog.mjs +121 -1
  87. package/dist/dock/basic.js +174 -1
  88. package/dist/dock/basic.mjs +151 -1
  89. package/dist/dock/index.js +628 -1
  90. package/dist/dock/index.mjs +601 -1
  91. package/dist/dock/limelight-nav.js +295 -1
  92. package/dist/dock/limelight-nav.mjs +274 -1
  93. package/dist/dock/macos.js +141 -1
  94. package/dist/dock/macos.mjs +118 -1
  95. package/dist/dock/menu.js +70 -1
  96. package/dist/dock/menu.mjs +48 -1
  97. package/dist/dock/message.js +144 -1
  98. package/dist/dock/message.mjs +122 -1
  99. package/dist/drawer.js +115 -1
  100. package/dist/drawer.mjs +103 -1
  101. package/dist/dropdown-menu.js +202 -1
  102. package/dist/dropdown-menu.mjs +166 -1
  103. package/dist/finance/AdvancedChart.js +48 -2
  104. package/dist/finance/AdvancedChart.mjs +46 -2
  105. package/dist/finance/CompanyProfile.js +48 -2
  106. package/dist/finance/CompanyProfile.mjs +46 -2
  107. package/dist/finance/CryptoScreener.js +45 -2
  108. package/dist/finance/CryptoScreener.mjs +43 -2
  109. package/dist/finance/Financials.js +52 -2
  110. package/dist/finance/Financials.mjs +50 -2
  111. package/dist/finance/ForexScreener.js +46 -2
  112. package/dist/finance/ForexScreener.mjs +44 -2
  113. package/dist/finance/MarketOverview.js +104 -2
  114. package/dist/finance/MarketOverview.mjs +102 -2
  115. package/dist/finance/NewsTimeline.js +44 -2
  116. package/dist/finance/NewsTimeline.mjs +42 -2
  117. package/dist/finance/OrderEntry.js +131 -1
  118. package/dist/finance/OrderEntry.mjs +129 -1
  119. package/dist/finance/OrdersHistory.js +64 -1
  120. package/dist/finance/OrdersHistory.mjs +62 -1
  121. package/dist/finance/PositionsList.js +80 -1
  122. package/dist/finance/PositionsList.mjs +78 -1
  123. package/dist/finance/StockScreener.js +46 -2
  124. package/dist/finance/StockScreener.mjs +44 -2
  125. package/dist/finance/SymbolInfo.js +46 -2
  126. package/dist/finance/SymbolInfo.mjs +44 -2
  127. package/dist/finance/TechnicalAnalysis.js +54 -2
  128. package/dist/finance/TechnicalAnalysis.mjs +52 -2
  129. package/dist/finance/TickerTape.js +56 -2
  130. package/dist/finance/TickerTape.mjs +54 -2
  131. package/dist/finance/TradingPanel.js +191 -1
  132. package/dist/finance/TradingPanel.mjs +189 -1
  133. package/dist/finance/index.js +930 -2
  134. package/dist/finance/index.mjs +914 -2
  135. package/dist/form/index.js +155 -1
  136. package/dist/form/index.mjs +125 -1
  137. package/dist/form.js +172 -1
  138. package/dist/form.mjs +142 -1
  139. package/dist/hover-card.js +58 -1
  140. package/dist/hover-card.mjs +34 -1
  141. package/dist/index.js +8467 -192
  142. package/dist/index.mjs +8087 -192
  143. package/dist/input-otp.js +79 -1
  144. package/dist/input-otp.mjs +54 -1
  145. package/dist/lib/utils.js +28 -1
  146. package/dist/lib/utils.mjs +24 -1
  147. package/dist/navigation/index.js +98 -1
  148. package/dist/navigation/index.mjs +79 -1
  149. package/dist/navigation-menu.js +149 -1
  150. package/dist/navigation-menu.mjs +116 -1
  151. package/dist/pattern/grid-pattern.js +326 -3
  152. package/dist/pattern/grid-pattern.mjs +303 -3
  153. package/dist/pattern/index.js +326 -3
  154. package/dist/pattern/index.mjs +303 -3
  155. package/dist/popover.js +63 -1
  156. package/dist/popover.mjs +37 -1
  157. package/dist/primitives/index.js +8467 -192
  158. package/dist/primitives/index.mjs +8087 -192
  159. package/dist/primitives-export.js +8467 -192
  160. package/dist/primitives-export.mjs +8087 -192
  161. package/dist/progress.js +62 -1
  162. package/dist/progress.mjs +37 -1
  163. package/dist/project/gantt.js +65 -1
  164. package/dist/project/gantt.mjs +43 -1
  165. package/dist/project/index.js +636 -1
  166. package/dist/project/index.mjs +611 -1
  167. package/dist/project/kanban.js +597 -1
  168. package/dist/project/kanban.mjs +572 -1
  169. package/dist/project/list.js +35 -1
  170. package/dist/project/list.mjs +12 -1
  171. package/dist/radio-group.js +68 -1
  172. package/dist/radio-group.mjs +45 -1
  173. package/dist/resizable.js +72 -1
  174. package/dist/resizable.mjs +48 -1
  175. package/dist/scroll-area.js +89 -1
  176. package/dist/scroll-area.mjs +66 -1
  177. package/dist/select.js +140 -1
  178. package/dist/select.mjs +111 -1
  179. package/dist/separator.js +59 -1
  180. package/dist/separator.mjs +34 -1
  181. package/dist/sheet.js +148 -1
  182. package/dist/sheet.mjs +117 -1
  183. package/dist/skeleton.js +32 -1
  184. package/dist/skeleton.mjs +27 -1
  185. package/dist/slider.js +99 -1
  186. package/dist/slider.mjs +73 -1
  187. package/dist/sonner.js +34 -1
  188. package/dist/sonner.mjs +29 -1
  189. package/dist/switch.js +62 -1
  190. package/dist/switch.mjs +37 -1
  191. package/dist/table.js +110 -1
  192. package/dist/table.mjs +101 -1
  193. package/dist/tabs.js +82 -1
  194. package/dist/tabs.mjs +57 -1
  195. package/dist/tailwind/index.js +2023 -1
  196. package/dist/tailwind/index.mjs +2011 -1
  197. package/dist/textarea.js +78 -1
  198. package/dist/textarea.mjs +56 -1
  199. package/dist/toggle-group.js +118 -1
  200. package/dist/toggle-group.mjs +93 -1
  201. package/dist/toggle.js +71 -1
  202. package/dist/toggle.mjs +48 -1
  203. package/dist/tooltip.js +67 -1
  204. package/dist/tooltip.mjs +40 -1
  205. package/dist/types/index.js +57 -1
  206. package/dist/types/index.mjs +51 -1
  207. package/dist/ui/announcement.js +129 -1
  208. package/dist/ui/announcement.mjs +107 -1
  209. package/dist/ui/avatar-group.js +88 -1
  210. package/dist/ui/avatar-group.mjs +65 -1
  211. package/dist/ui/banner.js +85 -1
  212. package/dist/ui/banner.mjs +62 -1
  213. package/dist/ui/cursor.js +78 -1
  214. package/dist/ui/cursor.mjs +56 -1
  215. package/dist/ui/index.js +475 -1
  216. package/dist/ui/index.mjs +442 -1
  217. package/dist/ui/marquee.js +74 -1
  218. package/dist/ui/marquee.mjs +52 -1
  219. package/dist/ui/pill.js +85 -1
  220. package/dist/ui/pill.mjs +62 -1
  221. package/dist/ui/spinner.js +28 -1
  222. package/dist/ui/spinner.mjs +26 -1
  223. package/dist/ui/tags.js +101 -1
  224. package/dist/ui/tags.mjs +79 -1
  225. package/dist/ui/ticker.js +73 -1
  226. package/dist/ui/ticker.mjs +51 -1
  227. package/dist/util/index.js +457 -1
  228. package/dist/util/index.mjs +399 -1
  229. package/package.json +1 -1
package/dist/code/diff.js CHANGED
@@ -1,12 +1,430 @@
1
- 'use strict';var a=require('react'),classVarianceAuthority=require('class-variance-authority'),lucideReact=require('lucide-react'),shiki=require('shiki'),utils=require('@hanzo/ui/lib/utils'),badge=require('@hanzo/ui/badge'),button=require('@hanzo/ui/button'),skeleton=require('@hanzo/ui/skeleton'),toggleGroup=require('@hanzo/ui/toggle-group'),jsxRuntime=require('react/jsx-runtime');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var a__namespace=/*#__PURE__*/_interopNamespace(a);var ee=Object.defineProperty;var x=(f,p)=>ee(f,"name",{value:p,configurable:true});var me=classVarianceAuthority.cva("relative overflow-hidden rounded-lg border bg-muted/50",{variants:{theme:{dark:"bg-slate-950 border-slate-800",light:"bg-slate-50 border-slate-200",github:"bg-white border-slate-200","github-dark":"bg-slate-900 border-slate-700"},size:{sm:"text-xs",default:"text-sm",lg:"text-base"}},defaultVariants:{theme:"dark",size:"default"}}),C=a__namespace.memo(({change:f,showLineNumbers:p,isUnified:g=false,highlightedContent:u})=>{let l=x(()=>{let i="group relative flex min-h-[1.5rem] items-center py-0.5";if(g)switch(f.type){case "add":return utils.cn(i,"bg-green-500/10 border-l-2 border-l-green-500");case "remove":return utils.cn(i,"bg-red-500/10 border-l-2 border-l-red-500");default:return utils.cn(i,"hover:bg-muted/50")}return utils.cn(i,"hover:bg-muted/50")},"getLineClasses"),o=x(()=>{if(!g)return null;switch(f.type){case "add":return jsxRuntime.jsx(lucideReact.Plus,{className:"h-3 w-3 text-green-500 mr-2 flex-shrink-0"});case "remove":return jsxRuntime.jsx(lucideReact.Minus,{className:"h-3 w-3 text-red-500 mr-2 flex-shrink-0"});default:return jsxRuntime.jsx("span",{className:"w-3 mr-2 flex-shrink-0"})}},"getLinePrefix");return jsxRuntime.jsx("div",{className:l(),children:jsxRuntime.jsxs("div",{className:"flex items-center px-4 w-full",children:[p&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 mr-4",children:g?jsxRuntime.jsx("span",{className:"inline-block w-8 select-none text-right text-xs text-muted-foreground",children:f.lineNumber}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"inline-block w-8 select-none text-right text-xs text-muted-foreground",children:f.oldLineNumber||""}),jsxRuntime.jsx("span",{className:"inline-block w-8 select-none text-right text-xs text-muted-foreground",children:f.newLineNumber||""})]})}),o(),jsxRuntime.jsx("div",{className:"flex-1 overflow-x-auto font-mono",dangerouslySetInnerHTML:{__html:u||f.content}})]})})});C.displayName="DiffLine";function B(f,p){let g=f.split(`
2
- `),u=p.split(`
3
- `),l=[],o=0,i=0,h=1;for(;o<g.length||i<u.length;){let N=g[o],v=u[i];o>=g.length?(l.push({type:"add",lineNumber:h++,content:v,newLineNumber:i+1}),i++):i>=u.length?(l.push({type:"remove",lineNumber:h++,content:N,oldLineNumber:o+1}),o++):N===v?(l.push({type:"unchanged",lineNumber:h++,content:N,oldLineNumber:o+1,newLineNumber:i+1}),o++,i++):(l.push({type:"remove",lineNumber:h++,content:N,oldLineNumber:o+1}),l.push({type:"add",lineNumber:h++,content:v,newLineNumber:i+1}),o++,i++);}return l}x(B,"generateDiff");var ce=a__namespace.forwardRef(({className:f,theme:p,size:g,oldCode:u,newCode:l,language:o="text",filename:i,oldFilename:h,newFilename:N,showLineNumbers:v=true,showCopyButton:_=true,maxHeight:A="500px",defaultView:U="unified",collapseUnchanged:k=false,contextLines:y=3,...F},J)=>{let[L,K]=a__namespace.useState(U),[D,S]=a__namespace.useState(false),[Q,T]=a__namespace.useState(true),[R,H]=a__namespace.useState(""),[M,V]=a__namespace.useState(""),[m,P]=a__namespace.useState([]),$={dark:"github-dark",light:"github-light",github:"github-light","github-dark":"github-dark"};a__namespace.useEffect(()=>{x(async()=>{T(true);try{let[n,t]=await Promise.all([shiki.codeToHtml(u,{lang:o,theme:$[p||"dark"]}),shiki.codeToHtml(l,{lang:o,theme:$[p||"dark"]})]),r=x(c=>{let E=document.createElement("div");return E.innerHTML=c,E.querySelector("code")?.innerHTML||c},"extractContent");H(r(n)),V(r(t));let b=B(u,l);P(b);}catch(n){console.error("Failed to highlight code:",n),H(u),V(l),P(B(u,l));}finally{T(false);}},"highlightCode")();},[u,l,o,p]);let W=a__namespace.useCallback(async()=>{try{let s=L==="unified"?m.map(n=>`${n.type==="add"?"+":n.type==="remove"?"-":" "}${n.content}`).join(`
4
- `):`--- ${h||"old"}
5
- +++ ${N||"new"}
6
- ${u}
7
-
8
- ${l}`;await navigator.clipboard.writeText(s),S(!0),setTimeout(()=>S(!1),2e3);}catch(s){console.error("Failed to copy diff:",s);}},[m,L,u,l,h,N]),X=a__namespace.useMemo(()=>{if(!k)return m;let s=[],n=0;for(;n<m.length;){let t=m[n];if(t.type!=="unchanged"){s.push(t),n++;continue}let r=n;for(;n<m.length&&m[n].type==="unchanged";)n++;let b=n-r;if(b<=y*2)for(let c=r;c<n;c++)s.push(m[c]);else {for(let c=r;c<r+y;c++)s.push(m[c]);s.push({type:"unchanged",lineNumber:-1,content:`... ${b-y*2} unchanged lines ...`});for(let c=n-y;c<n;c++)s.push(m[c]);}}return s},[m,k,y]),I=a__namespace.useMemo(()=>{let s=m.filter(t=>t.type==="add").length,n=m.filter(t=>t.type==="remove").length;return {additions:s,deletions:n}},[m]),Y=x(()=>{let s=R.split(`
9
- `),n=M.split(`
10
- `);return jsxRuntime.jsx("div",{className:"font-mono",children:X.map((t,r)=>{if(t.lineNumber===-1)return jsxRuntime.jsx("div",{className:"flex items-center justify-center py-2 text-muted-foreground bg-muted/30",children:jsxRuntime.jsx("span",{className:"text-xs",children:t.content})},r);let b=t.content;return t.type==="add"&&t.newLineNumber?b=n[t.newLineNumber-1]||t.content:(t.type==="remove"&&t.oldLineNumber||t.type==="unchanged"&&t.oldLineNumber)&&(b=s[t.oldLineNumber-1]||t.content),jsxRuntime.jsx(C,{change:t,showLineNumbers:v,isUnified:true,highlightedContent:b},r)})})},"renderUnifiedView"),Z=x(()=>{let s=R.split(`
11
- `),n=M.split(`
12
- `);return jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-0",children:[jsxRuntime.jsxs("div",{className:"border-r",children:[jsxRuntime.jsx("div",{className:"border-b px-4 py-2 bg-red-500/10",children:jsxRuntime.jsx("span",{className:"text-sm font-medium text-red-600 dark:text-red-400",children:h||i||"Old"})}),jsxRuntime.jsx("div",{className:"font-mono",children:s.map((t,r)=>jsxRuntime.jsx(C,{change:{type:"remove",lineNumber:r+1,content:t,oldLineNumber:r+1},showLineNumbers:v,highlightedContent:t},`old-${r}`))})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"border-b px-4 py-2 bg-green-500/10",children:jsxRuntime.jsx("span",{className:"text-sm font-medium text-green-600 dark:text-green-400",children:N||i||"New"})}),jsxRuntime.jsx("div",{className:"font-mono",children:n.map((t,r)=>jsxRuntime.jsx(C,{change:{type:"add",lineNumber:r+1,content:t,newLineNumber:r+1},showLineNumbers:v,highlightedContent:t},`new-${r}`))})]})]})},"renderSplitView");return jsxRuntime.jsxs("div",{ref:J,className:utils.cn(me({theme:p,size:g,className:f})),...F,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.GitCompare,{className:"h-4 w-4 text-muted-foreground"}),i&&jsxRuntime.jsx("span",{className:"text-sm font-medium",children:i}),o&&jsxRuntime.jsx(badge.Badge,{variant:"secondary",className:"text-xs",children:o})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[jsxRuntime.jsxs("span",{className:"flex items-center gap-1",children:[jsxRuntime.jsx(lucideReact.Plus,{className:"h-3 w-3 text-green-500"}),I.additions]}),jsxRuntime.jsxs("span",{className:"flex items-center gap-1",children:[jsxRuntime.jsx(lucideReact.Minus,{className:"h-3 w-3 text-red-500"}),I.deletions]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs(toggleGroup.ToggleGroup,{type:"single",value:L,onValueChange:s=>s&&K(s),size:"sm",children:[jsxRuntime.jsx(toggleGroup.ToggleGroupItem,{value:"unified","aria-label":"Unified view",children:jsxRuntime.jsx(lucideReact.Square,{className:"h-3 w-3"})}),jsxRuntime.jsx(toggleGroup.ToggleGroupItem,{value:"split","aria-label":"Split view",children:jsxRuntime.jsx(lucideReact.SplitSquareHorizontal,{className:"h-3 w-3"})})]}),_&&jsxRuntime.jsxs(button.Button,{variant:"ghost",size:"sm",onClick:W,className:"h-8 w-8 p-0",children:[D?jsxRuntime.jsx(lucideReact.Check,{className:"h-3.5 w-3.5 text-green-500"}):jsxRuntime.jsx(lucideReact.Copy,{className:"h-3.5 w-3.5"}),jsxRuntime.jsx("span",{className:"sr-only",children:D?"Copied":"Copy diff"})]})]})]}),jsxRuntime.jsx("div",{className:"overflow-auto",style:{maxHeight:A},children:Q?jsxRuntime.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:10}).map((s,n)=>jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[v&&jsxRuntime.jsx(skeleton.Skeleton,{className:"h-4 w-8"}),jsxRuntime.jsx(skeleton.Skeleton,{className:"h-4 flex-1"})]},n))}):L==="unified"?Y():Z()})]})});ce.displayName="CodeDiff";exports.CodeDiff=ce;exports.codeDiffVariants=me;
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var React = require('react');
5
+ var classVarianceAuthority = require('class-variance-authority');
6
+ var lucideReact = require('lucide-react');
7
+ var shiki = require('shiki');
8
+ var utils = require('@hanzo/ui/lib/utils');
9
+ var badge = require('@hanzo/ui/badge');
10
+ var button = require('@hanzo/ui/button');
11
+ var skeleton = require('@hanzo/ui/skeleton');
12
+ var toggleGroup = require('@hanzo/ui/toggle-group');
13
+ var jsxRuntime = require('react/jsx-runtime');
14
+
15
+ function _interopNamespace(e) {
16
+ if (e && e.__esModule) return e;
17
+ var n = Object.create(null);
18
+ if (e) {
19
+ Object.keys(e).forEach(function (k) {
20
+ if (k !== 'default') {
21
+ var d = Object.getOwnPropertyDescriptor(e, k);
22
+ Object.defineProperty(n, k, d.get ? d : {
23
+ enumerable: true,
24
+ get: function () { return e[k]; }
25
+ });
26
+ }
27
+ });
28
+ }
29
+ n.default = e;
30
+ return Object.freeze(n);
31
+ }
32
+
33
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
34
+
35
+ var __defProp = Object.defineProperty;
36
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
37
+ var codeDiffVariants = classVarianceAuthority.cva(
38
+ "relative overflow-hidden rounded-lg border bg-muted/50",
39
+ {
40
+ variants: {
41
+ theme: {
42
+ dark: "bg-slate-950 border-slate-800",
43
+ light: "bg-slate-50 border-slate-200",
44
+ github: "bg-white border-slate-200",
45
+ "github-dark": "bg-slate-900 border-slate-700"
46
+ },
47
+ size: {
48
+ sm: "text-xs",
49
+ default: "text-sm",
50
+ lg: "text-base"
51
+ }
52
+ },
53
+ defaultVariants: {
54
+ theme: "dark",
55
+ size: "default"
56
+ }
57
+ }
58
+ );
59
+ var DiffLine = React__namespace.memo(
60
+ ({
61
+ change,
62
+ showLineNumbers,
63
+ isUnified = false,
64
+ highlightedContent
65
+ }) => {
66
+ const getLineClasses = /* @__PURE__ */ __name(() => {
67
+ const base = "group relative flex min-h-[1.5rem] items-center py-0.5";
68
+ if (isUnified) {
69
+ switch (change.type) {
70
+ case "add":
71
+ return utils.cn(base, "bg-green-500/10 border-l-2 border-l-green-500");
72
+ case "remove":
73
+ return utils.cn(base, "bg-red-500/10 border-l-2 border-l-red-500");
74
+ default:
75
+ return utils.cn(base, "hover:bg-muted/50");
76
+ }
77
+ }
78
+ return utils.cn(base, "hover:bg-muted/50");
79
+ }, "getLineClasses");
80
+ const getLinePrefix = /* @__PURE__ */ __name(() => {
81
+ if (!isUnified) return null;
82
+ switch (change.type) {
83
+ case "add":
84
+ return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "h-3 w-3 text-green-500 mr-2 flex-shrink-0" });
85
+ case "remove":
86
+ return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Minus, { className: "h-3 w-3 text-red-500 mr-2 flex-shrink-0" });
87
+ default:
88
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-3 mr-2 flex-shrink-0" });
89
+ }
90
+ }, "getLinePrefix");
91
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: getLineClasses(), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center px-4 w-full", children: [
92
+ showLineNumbers && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2 mr-4", children: !isUnified ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
93
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-block w-8 select-none text-right text-xs text-muted-foreground", children: change.oldLineNumber || "" }),
94
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-block w-8 select-none text-right text-xs text-muted-foreground", children: change.newLineNumber || "" })
95
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-block w-8 select-none text-right text-xs text-muted-foreground", children: change.lineNumber }) }),
96
+ getLinePrefix(),
97
+ /* @__PURE__ */ jsxRuntime.jsx(
98
+ "div",
99
+ {
100
+ className: "flex-1 overflow-x-auto font-mono",
101
+ dangerouslySetInnerHTML: {
102
+ __html: highlightedContent || change.content
103
+ }
104
+ }
105
+ )
106
+ ] }) });
107
+ }
108
+ );
109
+ DiffLine.displayName = "DiffLine";
110
+ function generateDiff(oldCode, newCode) {
111
+ const oldLines = oldCode.split("\n");
112
+ const newLines = newCode.split("\n");
113
+ const changes = [];
114
+ let oldIndex = 0;
115
+ let newIndex = 0;
116
+ let lineNumber = 1;
117
+ while (oldIndex < oldLines.length || newIndex < newLines.length) {
118
+ const oldLine = oldLines[oldIndex];
119
+ const newLine = newLines[newIndex];
120
+ if (oldIndex >= oldLines.length) {
121
+ changes.push({
122
+ type: "add",
123
+ lineNumber: lineNumber++,
124
+ content: newLine,
125
+ newLineNumber: newIndex + 1
126
+ });
127
+ newIndex++;
128
+ } else if (newIndex >= newLines.length) {
129
+ changes.push({
130
+ type: "remove",
131
+ lineNumber: lineNumber++,
132
+ content: oldLine,
133
+ oldLineNumber: oldIndex + 1
134
+ });
135
+ oldIndex++;
136
+ } else if (oldLine === newLine) {
137
+ changes.push({
138
+ type: "unchanged",
139
+ lineNumber: lineNumber++,
140
+ content: oldLine,
141
+ oldLineNumber: oldIndex + 1,
142
+ newLineNumber: newIndex + 1
143
+ });
144
+ oldIndex++;
145
+ newIndex++;
146
+ } else {
147
+ changes.push({
148
+ type: "remove",
149
+ lineNumber: lineNumber++,
150
+ content: oldLine,
151
+ oldLineNumber: oldIndex + 1
152
+ });
153
+ changes.push({
154
+ type: "add",
155
+ lineNumber: lineNumber++,
156
+ content: newLine,
157
+ newLineNumber: newIndex + 1
158
+ });
159
+ oldIndex++;
160
+ newIndex++;
161
+ }
162
+ }
163
+ return changes;
164
+ }
165
+ __name(generateDiff, "generateDiff");
166
+ var CodeDiff = React__namespace.forwardRef(
167
+ ({
168
+ className,
169
+ theme,
170
+ size,
171
+ oldCode,
172
+ newCode,
173
+ language = "text",
174
+ filename,
175
+ oldFilename,
176
+ newFilename,
177
+ showLineNumbers = true,
178
+ showCopyButton = true,
179
+ maxHeight = "500px",
180
+ defaultView = "unified",
181
+ collapseUnchanged = false,
182
+ contextLines = 3,
183
+ ...props
184
+ }, ref) => {
185
+ const [view, setView] = React__namespace.useState(defaultView);
186
+ const [copied, setCopied] = React__namespace.useState(false);
187
+ const [isLoading, setIsLoading] = React__namespace.useState(true);
188
+ const [highlightedOldCode, setHighlightedOldCode] = React__namespace.useState("");
189
+ const [highlightedNewCode, setHighlightedNewCode] = React__namespace.useState("");
190
+ const [changes, setChanges] = React__namespace.useState([]);
191
+ const themeMap = {
192
+ dark: "github-dark",
193
+ light: "github-light",
194
+ github: "github-light",
195
+ "github-dark": "github-dark"
196
+ };
197
+ React__namespace.useEffect(() => {
198
+ const highlightCode = /* @__PURE__ */ __name(async () => {
199
+ setIsLoading(true);
200
+ try {
201
+ const [oldHighlighted, newHighlighted] = await Promise.all([
202
+ shiki.codeToHtml(oldCode, {
203
+ lang: language,
204
+ theme: themeMap[theme || "dark"]
205
+ }),
206
+ shiki.codeToHtml(newCode, {
207
+ lang: language,
208
+ theme: themeMap[theme || "dark"]
209
+ })
210
+ ]);
211
+ const extractContent = /* @__PURE__ */ __name((html) => {
212
+ const tempDiv = document.createElement("div");
213
+ tempDiv.innerHTML = html;
214
+ const codeElement = tempDiv.querySelector("code");
215
+ return codeElement?.innerHTML || html;
216
+ }, "extractContent");
217
+ setHighlightedOldCode(extractContent(oldHighlighted));
218
+ setHighlightedNewCode(extractContent(newHighlighted));
219
+ const diffChanges = generateDiff(oldCode, newCode);
220
+ setChanges(diffChanges);
221
+ } catch (error) {
222
+ console.error("Failed to highlight code:", error);
223
+ setHighlightedOldCode(oldCode);
224
+ setHighlightedNewCode(newCode);
225
+ setChanges(generateDiff(oldCode, newCode));
226
+ } finally {
227
+ setIsLoading(false);
228
+ }
229
+ }, "highlightCode");
230
+ highlightCode();
231
+ }, [oldCode, newCode, language, theme]);
232
+ const copyToClipboard = React__namespace.useCallback(async () => {
233
+ try {
234
+ const diffText = view === "unified" ? changes.map((change) => {
235
+ const prefix = change.type === "add" ? "+" : change.type === "remove" ? "-" : " ";
236
+ return `${prefix}${change.content}`;
237
+ }).join("\n") : `--- ${oldFilename || "old"}
238
+ +++ ${newFilename || "new"}
239
+ ${oldCode}
240
+
241
+ ${newCode}`;
242
+ await navigator.clipboard.writeText(diffText);
243
+ setCopied(true);
244
+ setTimeout(() => setCopied(false), 2e3);
245
+ } catch (error) {
246
+ console.error("Failed to copy diff:", error);
247
+ }
248
+ }, [changes, view, oldCode, newCode, oldFilename, newFilename]);
249
+ const filteredChanges = React__namespace.useMemo(() => {
250
+ if (!collapseUnchanged) return changes;
251
+ const result = [];
252
+ let i = 0;
253
+ while (i < changes.length) {
254
+ const change = changes[i];
255
+ if (change.type !== "unchanged") {
256
+ result.push(change);
257
+ i++;
258
+ continue;
259
+ }
260
+ const unchangedStart = i;
261
+ while (i < changes.length && changes[i].type === "unchanged") {
262
+ i++;
263
+ }
264
+ const unchangedCount = i - unchangedStart;
265
+ if (unchangedCount <= contextLines * 2) {
266
+ for (let j = unchangedStart; j < i; j++) {
267
+ result.push(changes[j]);
268
+ }
269
+ } else {
270
+ for (let j = unchangedStart; j < unchangedStart + contextLines; j++) {
271
+ result.push(changes[j]);
272
+ }
273
+ result.push({
274
+ type: "unchanged",
275
+ lineNumber: -1,
276
+ content: `... ${unchangedCount - contextLines * 2} unchanged lines ...`
277
+ });
278
+ for (let j = i - contextLines; j < i; j++) {
279
+ result.push(changes[j]);
280
+ }
281
+ }
282
+ }
283
+ return result;
284
+ }, [changes, collapseUnchanged, contextLines]);
285
+ const stats = React__namespace.useMemo(() => {
286
+ const additions = changes.filter((c) => c.type === "add").length;
287
+ const deletions = changes.filter((c) => c.type === "remove").length;
288
+ return { additions, deletions };
289
+ }, [changes]);
290
+ const renderUnifiedView = /* @__PURE__ */ __name(() => {
291
+ const oldLines = highlightedOldCode.split("\n");
292
+ const newLines = highlightedNewCode.split("\n");
293
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-mono", children: filteredChanges.map((change, index) => {
294
+ if (change.lineNumber === -1) {
295
+ return /* @__PURE__ */ jsxRuntime.jsx(
296
+ "div",
297
+ {
298
+ className: "flex items-center justify-center py-2 text-muted-foreground bg-muted/30",
299
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs", children: change.content })
300
+ },
301
+ index
302
+ );
303
+ }
304
+ let highlightedContent = change.content;
305
+ if (change.type === "add" && change.newLineNumber) {
306
+ highlightedContent = newLines[change.newLineNumber - 1] || change.content;
307
+ } else if (change.type === "remove" && change.oldLineNumber) {
308
+ highlightedContent = oldLines[change.oldLineNumber - 1] || change.content;
309
+ } else if (change.type === "unchanged" && change.oldLineNumber) {
310
+ highlightedContent = oldLines[change.oldLineNumber - 1] || change.content;
311
+ }
312
+ return /* @__PURE__ */ jsxRuntime.jsx(
313
+ DiffLine,
314
+ {
315
+ change,
316
+ showLineNumbers,
317
+ isUnified: true,
318
+ highlightedContent
319
+ },
320
+ index
321
+ );
322
+ }) });
323
+ }, "renderUnifiedView");
324
+ const renderSplitView = /* @__PURE__ */ __name(() => {
325
+ const oldLines = highlightedOldCode.split("\n");
326
+ const newLines = highlightedNewCode.split("\n");
327
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-0", children: [
328
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-r", children: [
329
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-b px-4 py-2 bg-red-500/10", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium text-red-600 dark:text-red-400", children: oldFilename || filename || "Old" }) }),
330
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-mono", children: oldLines.map((line, index) => /* @__PURE__ */ jsxRuntime.jsx(
331
+ DiffLine,
332
+ {
333
+ change: {
334
+ type: "remove",
335
+ lineNumber: index + 1,
336
+ content: line,
337
+ oldLineNumber: index + 1
338
+ },
339
+ showLineNumbers,
340
+ highlightedContent: line
341
+ },
342
+ `old-${index}`
343
+ )) })
344
+ ] }),
345
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
346
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-b px-4 py-2 bg-green-500/10", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium text-green-600 dark:text-green-400", children: newFilename || filename || "New" }) }),
347
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-mono", children: newLines.map((line, index) => /* @__PURE__ */ jsxRuntime.jsx(
348
+ DiffLine,
349
+ {
350
+ change: {
351
+ type: "add",
352
+ lineNumber: index + 1,
353
+ content: line,
354
+ newLineNumber: index + 1
355
+ },
356
+ showLineNumbers,
357
+ highlightedContent: line
358
+ },
359
+ `new-${index}`
360
+ )) })
361
+ ] })
362
+ ] });
363
+ }, "renderSplitView");
364
+ return /* @__PURE__ */ jsxRuntime.jsxs(
365
+ "div",
366
+ {
367
+ ref,
368
+ className: utils.cn(codeDiffVariants({ theme, size, className })),
369
+ ...props,
370
+ children: [
371
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between border-b px-4 py-2", children: [
372
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4", children: [
373
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
374
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.GitCompare, { className: "h-4 w-4 text-muted-foreground" }),
375
+ filename && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: filename }),
376
+ language && /* @__PURE__ */ jsxRuntime.jsx(badge.Badge, { variant: "secondary", className: "text-xs", children: language })
377
+ ] }),
378
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
379
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-1", children: [
380
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "h-3 w-3 text-green-500" }),
381
+ stats.additions
382
+ ] }),
383
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-1", children: [
384
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Minus, { className: "h-3 w-3 text-red-500" }),
385
+ stats.deletions
386
+ ] })
387
+ ] })
388
+ ] }),
389
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
390
+ /* @__PURE__ */ jsxRuntime.jsxs(
391
+ toggleGroup.ToggleGroup,
392
+ {
393
+ type: "single",
394
+ value: view,
395
+ onValueChange: (value) => value && setView(value),
396
+ size: "sm",
397
+ children: [
398
+ /* @__PURE__ */ jsxRuntime.jsx(toggleGroup.ToggleGroupItem, { value: "unified", "aria-label": "Unified view", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Square, { className: "h-3 w-3" }) }),
399
+ /* @__PURE__ */ jsxRuntime.jsx(toggleGroup.ToggleGroupItem, { value: "split", "aria-label": "Split view", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.SplitSquareHorizontal, { className: "h-3 w-3" }) })
400
+ ]
401
+ }
402
+ ),
403
+ showCopyButton && /* @__PURE__ */ jsxRuntime.jsxs(
404
+ button.Button,
405
+ {
406
+ variant: "ghost",
407
+ size: "sm",
408
+ onClick: copyToClipboard,
409
+ className: "h-8 w-8 p-0",
410
+ children: [
411
+ copied ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-3.5 w-3.5 text-green-500" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { className: "h-3.5 w-3.5" }),
412
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: copied ? "Copied" : "Copy diff" })
413
+ ]
414
+ }
415
+ )
416
+ ] })
417
+ ] }),
418
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-auto", style: { maxHeight }, children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 space-y-2", children: Array.from({ length: 10 }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4", children: [
419
+ showLineNumbers && /* @__PURE__ */ jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 w-8" }),
420
+ /* @__PURE__ */ jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 flex-1" })
421
+ ] }, i)) }) : view === "unified" ? renderUnifiedView() : renderSplitView() })
422
+ ]
423
+ }
424
+ );
425
+ }
426
+ );
427
+ CodeDiff.displayName = "CodeDiff";
428
+
429
+ exports.CodeDiff = CodeDiff;
430
+ exports.codeDiffVariants = codeDiffVariants;