r3f-frame-profiler 1.0.1 → 1.0.3

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 (128) hide show
  1. package/dist/cjs/index.js +1 -2
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/esm/index.js +7 -12485
  4. package/dist/esm/index.js.map +1 -1
  5. package/dist/index-D_LaF0YP.cjs +2 -0
  6. package/dist/index-D_LaF0YP.cjs.map +1 -0
  7. package/dist/index-o5zvhDta.js +4406 -0
  8. package/dist/index-o5zvhDta.js.map +1 -0
  9. package/dist/report-generator-BCq_enQo.js +283 -0
  10. package/dist/report-generator-BCq_enQo.js.map +1 -0
  11. package/dist/report-generator-BsoP53qp.cjs +61 -0
  12. package/dist/report-generator-BsoP53qp.cjs.map +1 -0
  13. package/dist/types/FrameProfiler.d.ts +2 -0
  14. package/dist/types/FrameProfiler.d.ts.map +1 -0
  15. package/dist/types/collectors/frame-time-collector.d.ts +41 -0
  16. package/dist/types/collectors/frame-time-collector.d.ts.map +1 -0
  17. package/dist/types/collectors/gpu-collector.d.ts +32 -0
  18. package/dist/types/collectors/gpu-collector.d.ts.map +1 -0
  19. package/dist/types/collectors/hot-path-detector.d.ts +42 -0
  20. package/dist/types/collectors/hot-path-detector.d.ts.map +1 -0
  21. package/dist/types/collectors/index.d.ts +7 -0
  22. package/dist/types/collectors/index.d.ts.map +1 -0
  23. package/dist/types/collectors/memory-collector.d.ts +49 -0
  24. package/dist/types/collectors/memory-collector.d.ts.map +1 -0
  25. package/dist/types/collectors/scene-collector.d.ts +47 -0
  26. package/dist/types/collectors/scene-collector.d.ts.map +1 -0
  27. package/dist/types/components/ReactProfiler.d.ts +12 -0
  28. package/dist/types/components/ReactProfiler.d.ts.map +1 -0
  29. package/dist/types/core/alert-system.d.ts +37 -0
  30. package/dist/types/core/alert-system.d.ts.map +1 -0
  31. package/dist/types/core/auto-instrumentation.d.ts +33 -0
  32. package/dist/types/core/auto-instrumentation.d.ts.map +1 -0
  33. package/dist/types/core/budget-manager.d.ts +78 -0
  34. package/dist/types/core/budget-manager.d.ts.map +1 -0
  35. package/dist/types/core/data-export.d.ts +24 -0
  36. package/dist/types/core/data-export.d.ts.map +1 -0
  37. package/dist/types/core/index.d.ts +4 -0
  38. package/dist/types/core/index.d.ts.map +1 -0
  39. package/dist/types/core/monitor-state.d.ts +21 -0
  40. package/dist/types/core/monitor-state.d.ts.map +1 -0
  41. package/dist/types/core/profiler.d.ts +83 -0
  42. package/dist/types/core/profiler.d.ts.map +1 -0
  43. package/dist/types/core/react-monitor.d.ts +51 -0
  44. package/dist/types/core/react-monitor.d.ts.map +1 -0
  45. package/dist/types/core/report-generator.d.ts +83 -0
  46. package/dist/types/core/report-generator.d.ts.map +1 -0
  47. package/dist/types/hooks/index.d.ts +17 -0
  48. package/dist/types/hooks/index.d.ts.map +1 -0
  49. package/dist/types/hooks/useAlerts.d.ts +11 -0
  50. package/dist/types/hooks/useAlerts.d.ts.map +1 -0
  51. package/dist/types/hooks/useBudgetChecker.d.ts +6 -0
  52. package/dist/types/hooks/useBudgetChecker.d.ts.map +1 -0
  53. package/dist/types/hooks/useFrameHistory.d.ts +2 -0
  54. package/dist/types/hooks/useFrameHistory.d.ts.map +1 -0
  55. package/dist/types/hooks/useFrameTime.d.ts +3 -0
  56. package/dist/types/hooks/useFrameTime.d.ts.map +1 -0
  57. package/dist/types/hooks/useGPUStats.d.ts +3 -0
  58. package/dist/types/hooks/useGPUStats.d.ts.map +1 -0
  59. package/dist/types/hooks/useHotPath.d.ts +3 -0
  60. package/dist/types/hooks/useHotPath.d.ts.map +1 -0
  61. package/dist/types/hooks/useMemoryHistory.d.ts +5 -0
  62. package/dist/types/hooks/useMemoryHistory.d.ts.map +1 -0
  63. package/dist/types/hooks/useMemoryStats.d.ts +3 -0
  64. package/dist/types/hooks/useMemoryStats.d.ts.map +1 -0
  65. package/dist/types/hooks/useMetricsCollector.d.ts +31 -0
  66. package/dist/types/hooks/useMetricsCollector.d.ts.map +1 -0
  67. package/dist/types/hooks/usePerformanceBudget.d.ts +20 -0
  68. package/dist/types/hooks/usePerformanceBudget.d.ts.map +1 -0
  69. package/dist/types/hooks/useProfiler.d.ts +5 -0
  70. package/dist/types/hooks/useProfiler.d.ts.map +1 -0
  71. package/dist/types/hooks/useR3FProfiler.d.ts +2 -0
  72. package/dist/types/hooks/useR3FProfiler.d.ts.map +1 -0
  73. package/dist/types/hooks/useR3FProfilerCollector.d.ts +2 -0
  74. package/dist/types/hooks/useR3FProfilerCollector.d.ts.map +1 -0
  75. package/dist/types/hooks/useR3FStatsCollector.d.ts +2 -0
  76. package/dist/types/hooks/useR3FStatsCollector.d.ts.map +1 -0
  77. package/dist/types/hooks/useReactProfiler.d.ts +3 -0
  78. package/dist/types/hooks/useReactProfiler.d.ts.map +1 -0
  79. package/dist/types/hooks/useReportMetric.d.ts +19 -0
  80. package/dist/types/hooks/useReportMetric.d.ts.map +1 -0
  81. package/dist/types/hooks/useSceneStats.d.ts +3 -0
  82. package/dist/types/hooks/useSceneStats.d.ts.map +1 -0
  83. package/dist/types/index.d.ts +5 -0
  84. package/dist/types/index.d.ts.map +1 -0
  85. package/dist/types/ui/PerformanceMonitor.d.ts +7 -0
  86. package/dist/types/ui/PerformanceMonitor.d.ts.map +1 -0
  87. package/dist/types/ui/components/AlertBadge.d.ts +9 -0
  88. package/dist/types/ui/components/AlertBadge.d.ts.map +1 -0
  89. package/dist/types/ui/components/MetricCard.d.ts +14 -0
  90. package/dist/types/ui/components/MetricCard.d.ts.map +1 -0
  91. package/dist/types/ui/components/SimpleChart.d.ts +13 -0
  92. package/dist/types/ui/components/SimpleChart.d.ts.map +1 -0
  93. package/dist/types/ui/components/Tabs.d.ts +15 -0
  94. package/dist/types/ui/components/Tabs.d.ts.map +1 -0
  95. package/dist/types/ui/components/index.d.ts +5 -0
  96. package/dist/types/ui/components/index.d.ts.map +1 -0
  97. package/dist/types/ui/panels/BudgetPanel.d.ts +2 -0
  98. package/dist/types/ui/panels/BudgetPanel.d.ts.map +1 -0
  99. package/dist/types/ui/panels/FramePanel.d.ts +2 -0
  100. package/dist/types/ui/panels/FramePanel.d.ts.map +1 -0
  101. package/dist/types/ui/panels/FrameTimePanel.d.ts +2 -0
  102. package/dist/types/ui/panels/FrameTimePanel.d.ts.map +1 -0
  103. package/dist/types/ui/panels/GPUPanel.d.ts +2 -0
  104. package/dist/types/ui/panels/GPUPanel.d.ts.map +1 -0
  105. package/dist/types/ui/panels/HotPathPanel.d.ts +2 -0
  106. package/dist/types/ui/panels/HotPathPanel.d.ts.map +1 -0
  107. package/dist/types/ui/panels/MemoryPanel.d.ts +2 -0
  108. package/dist/types/ui/panels/MemoryPanel.d.ts.map +1 -0
  109. package/dist/types/ui/panels/ReactPanel.d.ts +2 -0
  110. package/dist/types/ui/panels/ReactPanel.d.ts.map +1 -0
  111. package/dist/types/ui/panels/ScenePanel.d.ts +2 -0
  112. package/dist/types/ui/panels/ScenePanel.d.ts.map +1 -0
  113. package/dist/types/ui/panels/index.d.ts +9 -0
  114. package/dist/types/ui/panels/index.d.ts.map +1 -0
  115. package/dist/types/ui/styles/theme.d.ts +76 -0
  116. package/dist/types/ui/styles/theme.d.ts.map +1 -0
  117. package/dist/types/ui/visualizations/FrameGraph.d.ts +10 -0
  118. package/dist/types/ui/visualizations/FrameGraph.d.ts.map +1 -0
  119. package/dist/types/ui/visualizations/MemoryChart.d.ts +10 -0
  120. package/dist/types/ui/visualizations/MemoryChart.d.ts.map +1 -0
  121. package/dist/types/ui/visualizations/PerformanceChart.d.ts +16 -0
  122. package/dist/types/ui/visualizations/PerformanceChart.d.ts.map +1 -0
  123. package/dist/types/ui/visualizations/TimelineView.d.ts +7 -0
  124. package/dist/types/ui/visualizations/TimelineView.d.ts.map +1 -0
  125. package/dist/types/ui/visualizations/index.d.ts +5 -0
  126. package/dist/types/ui/visualizations/index.d.ts.map +1 -0
  127. package/package.json +14 -7
  128. package/README.md +0 -60
@@ -0,0 +1,2 @@
1
+ "use strict";const f=require("react"),Y=require("@react-three/fiber"),H=require("three"),t=require("react/jsx-runtime");class ce{data=new Map;frameCount=0;enabled=!1;maxHistorySize=240;listeners=new Set;reportGenerator=null;constructor(){this.updateEnabledState(),typeof window<"u"&&(window.addEventListener("storage",()=>{this.updateEnabledState()}),Promise.resolve().then(()=>require("./report-generator-BsoP53qp.cjs")).then(({reportGenerator:e})=>{this.reportGenerator=e}))}updateEnabledState(){if(typeof window>"u"){this.enabled=!1;return}const e=new URLSearchParams(window.location.search);this.enabled=e.get("debug")==="1"||localStorage.getItem("debug")==="true"}isEnabled(){return this.enabled}profile(e,r){if(!this.enabled)return r();const s=performance.now(),o=r(),c=performance.now()-s;return this.record(e,c),o}async profileAsync(e,r){if(!this.enabled)return r();const s=performance.now(),o=await r(),c=performance.now()-s;return this.record(e,c),o}record(e,r){if(!this.enabled)return;this.data.has(e)||this.data.set(e,{total:0,calls:0,max:0,times:[]});const s=this.data.get(e);if(s.total+=r,s.calls+=1,s.max=Math.max(s.max,r),s.times.push(r),typeof window<"u"&&window.__hotPathDetector)try{window.__hotPathDetector.recordCall(e,r)}catch{}if(s.times.length>this.maxHistorySize){const o=s.times.shift();s.total-=o,s.calls-=1}this.frameCount+=1,this.frameCount>this.maxHistorySize&&(this.frameCount=this.maxHistorySize)}wrap(e,r){if(!this.enabled)return r;const s=this;return((...o)=>s.profile(e,()=>r(...o)))}wrapAsync(e,r){if(!this.enabled)return r;const s=this;return(async(...o)=>s.profileAsync(e,()=>r(...o)))}getData(){if(!this.enabled)return null;const e=Array.from(this.data.entries()).map(([o,i])=>({name:o,total:i.total,avg:i.calls>0?i.total/i.calls:0,max:i.max,calls:i.calls})),r=e.reduce((o,i)=>o+i.total,0);return{entries:e.map(o=>({...o,percentage:r>0?o.total/r*100:0,avg:isFinite(o.avg)?o.avg:0})),totalTime:r,calls:Math.max(...e.map(o=>o.calls),0),frames:this.frameCount}}getRawData(){return this.enabled?this.data:null}reset(){this.data.clear(),this.frameCount=0,this.notifyListeners()}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notifyListeners(){const e=this.getData();this.listeners.forEach(r=>r(e))}notify(){this.notifyListeners()}setMaxHistorySize(e){this.maxHistorySize=e}async generateReport(){const{reportGenerator:e}=await Promise.resolve().then(()=>require("./report-generator-BsoP53qp.cjs"));return e.generateMarkdownReport()}async copyReportToClipboard(){const{reportGenerator:e}=await Promise.resolve().then(()=>require("./report-generator-BsoP53qp.cjs"));await e.copyReportToClipboard()}recordFrameStats(e,r,s){!isFinite(e)||!isFinite(r)||e>1e3||r<=0||(this.reportGenerator?this.reportGenerator.recordFrame(e,r,s):Promise.resolve().then(()=>require("./report-generator-BsoP53qp.cjs")).then(({reportGenerator:o})=>{this.reportGenerator=o,this.reportGenerator.recordFrame(e,r,s)}))}recordMetricForReport(e,r){Promise.resolve().then(()=>require("./report-generator-BsoP53qp.cjs")).then(({reportGenerator:s})=>{s.recordMetric(e,r)})}}const D=new ce;typeof window<"u"&&Promise.resolve().then(async()=>{try{const{hotPathDetector:n}=await Promise.resolve().then(()=>Ve);window.__hotPathDetector=n}catch{}});const re=(n,e)=>D.profile(n,e),J=()=>D.isEnabled(),se=(n,e)=>{D.recordMetricForReport(n,e)},de=Object.freeze(Object.defineProperty({__proto__:null,isProfilerEnabled:J,profile:re,profiler:D,reportMetric:se},Symbol.toStringTag,{value:"Module"})),ue=()=>{const n=f.useRef(performance.now());return Y.useFrame(()=>{if(D.isEnabled()){const e=performance.now(),r=e-n.current;n.current=e,D.record("Frame",r),D.notify()}else n.current=performance.now()}),null};class me{renderer=null;lastStats=null;frameStartTime=0;setRenderer(e){this.renderer=e}getStats(){if(!this.renderer)return null;const e=this.renderer.info,r=e.memory,s=e.render,o="points"in s?s.points:0,i="lines"in s?s.lines:0;let c=0,l=0;if(r.textures&&this.renderer)try{c=r.textures*2*1024*1024}catch{c=r.textures*1024*1024}if(r.geometries&&this.renderer)try{l=(this.renderer.info.render.triangles||0)*100,l+=r.geometries*10*1024}catch{l=r.geometries*100*1024}const m={drawCalls:s.calls||0,triangles:s.triangles||0,points:o||0,lines:i||0,textures:r.textures||0,geometries:r.geometries||0,programs:e.programs?.length||0,memory:{textures:c,geometries:l,programs:0,total:c+l},frameTime:performance.now()-this.frameStartTime,timestamp:performance.now()};return this.lastStats=m,m}startFrame(){this.frameStartTime=performance.now()}endFrame(){}getLastStats(){return this.lastStats}reset(){this.lastStats=null}}const I=new me;class ge{scene=null;setScene(e){this.scene=e}getStats(){if(!this.scene)return null;const e={total:0,meshes:0,lights:0,cameras:0,groups:0,other:0},r={total:0,byType:{}},s={total:0,totalSize:0,byFormat:{},environment:0,system:0},o={total:0,vertices:0,faces:0},i={meshes:0,total:0},c=new Set,l=new Set,m=new Set,a=new Set,j=p=>{if(!p||p.userData&&(p.userData.rapier||p.userData.physics||p.userData.type==="RigidBody"||p.userData.__r3f||p.userData.__reactInternalInstance||p.userData.internal===!0||p.userData.helper===!0))return!0;if(p.name){const u=p.name.toLowerCase();if(u.includes("__rapier")||u.includes("__physics")||u.includes("__r3f")||u.includes("__internal")||u.startsWith("_helper")||u.startsWith("_internal")||u.includes("__internal")||u.startsWith("_")||u.includes("collider")||u.includes("rigidbody")||u.includes("helper")||u.includes("debug"))return!0}return!!(p.type==="RigidBody"||p.isRigidBody||p.type&&p.type.includes("Helper"))},y=p=>{if(!(p instanceof H.Mesh||p.isMesh))return!1;const u=p;return!(!u.geometry||!u.material||j(p))},d=p=>!(!(p instanceof H.Light||p.isLight)||j(p)||p.type&&p.type.includes("Helper")),h=(p,u=0,S=!1)=>{if(!p)return;const R=j(p)||S;if(p instanceof H.Mesh||p.isMesh){const g=p;if(y(p)&&!a.has(g)){if(a.add(g),e.meshes++,p.visible&&i.meshes++,R||(e.total++,p.visible&&i.total++),g.geometry&&!m.has(g.geometry)){m.add(g.geometry),o.total++;const z=g.geometry;if(z.attributes&&z.attributes.position){const M=z.attributes.position.count||0;o.vertices+=M,z.index?o.faces+=Math.floor(z.index.count/3):o.faces+=Math.floor(M/3)}}g.material&&(Array.isArray(g.material)?g.material:[g.material]).forEach(M=>{if(M&&!c.has(M)){c.add(M),r.total++;const B=M.type||M.constructor.name||"Unknown";r.byType[B]=(r.byType[B]||0)+1,["map","normalMap","roughnessMap","metalnessMap","aoMap","emissiveMap","bumpMap","displacementMap","alphaMap","envMap","lightMap","specularMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","sheenColorMap","sheenRoughnessMap","transmissionMap","thicknessMap","iridescenceMap","iridescenceThicknessMap"].forEach(x=>{const w=M[x];if(w&&w instanceof H.Texture&&!l.has(w)){l.add(w),s.total++;const k=this.estimateTextureSize(w);s.totalSize+=k;const A=w.format?.toString()||"unknown";s.byFormat[A]=(s.byFormat[A]||0)+1,(x==="envMap"||w.name?.toLowerCase().includes("env")||w.name?.toLowerCase().includes("environment"))&&s.environment++,(x==="lightMap"||w.name?.toLowerCase().includes("lightmap")||w.name?.toLowerCase().includes("system"))&&s.system++}}),Object.keys(M).forEach(x=>{const w=M[x];if(w&&w instanceof H.Texture&&!l.has(w)){l.add(w),s.total++;const k=this.estimateTextureSize(w);s.totalSize+=k;const A=w.format?.toString()||"unknown";s.byFormat[A]=(s.byFormat[A]||0)+1,(x==="envMap"||w.name?.toLowerCase().includes("env")||w.name?.toLowerCase().includes("environment"))&&s.environment++,(x==="lightMap"||w.name?.toLowerCase().includes("lightmap")||w.name?.toLowerCase().includes("system"))&&s.system++}})}})}}else p instanceof H.Light||p.isLight?d(p)&&e.lights++:p instanceof H.Camera||p.isCamera?!R&&!p.type?.includes("Helper")&&e.cameras++:p.type==="Group"||p.isGroup?R||e.groups++:R||e.other++;u<20&&p.children&&p.children.length>0&&p.children.forEach(g=>{g&&h(g,u+1,R)})};this.scene.children.forEach(p=>{p&&h(p,0,!1)});const T=e.meshes>0?o.vertices/e.meshes:0,C=e.meshes>0?o.faces/e.meshes:0;return{objects:e,materials:r,textures:s,geometries:o,visible:i,complexity:{averageVerticesPerMesh:T,averageFacesPerMesh:C,totalDrawCalls:e.meshes},timestamp:performance.now()}}estimateTextureSize(e){if(!e.image)return 0;const r=e.image;if(!r)return 0;const s=r.width||1,o=r.height||1;let i=4;try{const c=Number(e.format);isNaN(c)||(c===1022&&(i=3),c===1021&&(i=1),c===1020&&(i=1))}catch{}return s*o*i}reset(){}}const oe=new ge;class pe{renderer=null;lastStats=null;history=[];historySize=60;startTime=0;warmupPeriod=1e4;setRenderer(e){this.renderer=e,this.startTime===0&&(this.startTime=performance.now())}getStats(){const e=this.getJSHeapStats(),r=this.getGPUMemoryStats(),s=this.detectLeaks();if(!e&&!r)return null;const o={jsHeap:e||{used:0,total:0,limit:0,percentage:0},gpuMemory:r||{textures:0,geometries:0,total:0},leaks:s,timestamp:performance.now()};return this.lastStats=o,o}getJSHeapStats(){if(typeof performance>"u"||!performance.memory)return null;const e=performance.memory,r=e.usedJSHeapSize,s=e.totalJSHeapSize,o=e.jsHeapSizeLimit,i=o>0?r/o*100:0;return this.addToHistory(r),{used:r,total:s,limit:o,percentage:Math.min(100,Math.max(0,i))}}getGPUMemoryStats(){if(!this.renderer)return null;const e=this.renderer.info,r=e.memory,s=e.render;let o=0,i=0;if(r.textures&&this.renderer)try{o=r.textures*2*1024*1024}catch{o=r.textures*1024*1024}if(r.geometries&&this.renderer)try{i=(s.triangles||0)*100,i+=r.geometries*10*1024}catch{i=r.geometries*100*1024}return{textures:o,geometries:i,total:o+i}}addToHistory(e){const r=performance.now();this.history.push({timestamp:r,used:e}),this.history.length>this.historySize&&this.history.shift()}detectLeaks(){if(performance.now()-this.startTime<this.warmupPeriod)return{detected:!1,growthRate:0,trend:"stable"};if(this.history.length<20)return{detected:!1,growthRate:0,trend:"stable"};const r=this.history.slice(-10),s=this.history.slice(-30),o=r[0],i=r[r.length-1],c=(i.timestamp-o.timestamp)/1e3,l=i.used-o.used,m=c>0?l/c:0,a=s[0],j=s[s.length-1],y=(j.timestamp-a.timestamp)/1e3,d=j.used-a.used,h=y>0?d/y:0,T=(m+h)/2,C=33*1024,p=m>0&&h>0,u=T>C&&p;let S="stable";return Math.abs(T)<2048?S="stable":T>0?S="increasing":S="decreasing",{detected:u,growthRate:T,trend:S}}getLastStats(){return this.lastStats}reset(){this.lastStats=null,this.history=[],this.startTime=0}}const O=new pe;class he{phases=new Map;timeline=[];frameStartTime=0;lastFrameTime=0;currentInterval=0;lastBreakdown=null;maxTimelineEntries=100;startFrame(){const e=performance.now();this.lastFrameTime>0&&(this.currentInterval=e-this.lastFrameTime),this.lastFrameTime=e,this.frameStartTime=e,this.phases.clear(),this.timeline=[]}startPhase(e){const r=performance.now();this.phases.set(e,{start:r})}endPhase(e){const r=this.phases.get(e);if(!r)return;const s=performance.now();r.end=s;const o=s-r.start;this.timeline.push({name:e,start:r.start,end:s,duration:o})}endFrame(){const r=performance.now()-this.frameStartTime,s=this.currentInterval>0?this.currentInterval:r>0?r:16.66,o={react:this.getPhaseDuration("react"),update:this.getPhaseDuration("update"),physics:this.getPhaseDuration("physics"),render:this.getPhaseDuration("render"),postProcess:this.getPhaseDuration("postProcess"),other:0},i=Object.values(o).reduce((l,m)=>l+m,0);o.other=Math.max(0,r-i);const c={total:r,interval:s,phases:o,timeline:[...this.timeline].slice(-this.maxTimelineEntries),timestamp:this.frameStartTime};return this.lastBreakdown=c,c}getPhaseDuration(e){const r=this.phases.get(e);return!r||r.end===void 0?0:r.end-r.start}measure(e,r){this.startPhase(e);try{return r()}finally{this.endPhase(e)}}async measureAsync(e,r){this.startPhase(e);try{return await r()}finally{this.endPhase(e)}}getLastBreakdown(){return this.lastBreakdown}reset(){this.phases.clear(),this.timeline=[],this.lastBreakdown=null}}const F=new he;class fe{enabled=!1;reactPhaseStart=0;isReactRendering=!1;isUpdating=!1;isPhysicsRunning=!1;isRendering=!1;mutationObserver=null;enable(){this.enabled||(this.enabled=!0,this.setupReactInstrumentation(),this.setupThreeJSInstrumentation(),this.setupPhysicsInstrumentation())}disable(){this.enabled&&(this.enabled=!1,this.cleanup())}setupReactInstrumentation(){if(typeof window>"u")return;const e=document.getElementById("root")||document.body;if(e&&(this.mutationObserver=new MutationObserver(()=>{this.isReactRendering||this.startReactPhase()}),this.mutationObserver.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!1})),performance.mark){const r=performance.mark;performance.mark=((s,o)=>((s.includes("react")||s.includes("React"))&&(this.isReactRendering||this.startReactPhase()),r.call(performance,s,o)))}}setupThreeJSInstrumentation(){}setupPhysicsInstrumentation(){}startFrame(){this.enabled&&F.startFrame()}startReactPhase(){!this.enabled||this.isReactRendering||(this.isReactRendering=!0,this.reactPhaseStart=performance.now(),F.startPhase("react"))}endReactPhase(){!this.enabled||!this.isReactRendering||(this.isReactRendering=!1,F.endPhase("react"))}onReactRender(e){this.enabled&&(this.isReactRendering||this.startReactPhase(),setTimeout(()=>{this.isReactRendering&&performance.now()-this.reactPhaseStart>e&&this.endReactPhase()},0))}startUpdatePhase(){!this.enabled||this.isUpdating||(this.isUpdating=!0,F.startPhase("update"))}endUpdatePhase(){!this.enabled||!this.isUpdating||(this.isUpdating=!1,F.endPhase("update"))}startPhysicsPhase(){!this.enabled||this.isPhysicsRunning||(this.isPhysicsRunning=!0,F.startPhase("physics"))}endPhysicsPhase(){!this.enabled||!this.isPhysicsRunning||(this.isPhysicsRunning=!1,F.endPhase("physics"))}startRenderPhase(){!this.enabled||this.isRendering||(this.isRendering=!0,F.startPhase("render"))}endRenderPhase(){!this.enabled||!this.isRendering||(this.isRendering=!1,F.endPhase("render"),F.endFrame())}cleanup(){this.isReactRendering=!1,this.isUpdating=!1,this.isPhysicsRunning=!1,this.isRendering=!1,this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null)}isActive(){return this.enabled}}const W=new fe;class ye{isPaused=!1;listeners=new Set;STORAGE_KEY="r3f-profiler-paused";constructor(){this.loadPauseState()}loadPauseState(){try{const e=localStorage.getItem(this.STORAGE_KEY);e!==null&&(this.isPaused=e==="true")}catch(e){console.warn("Failed to load pause state:",e)}}savePauseState(){try{localStorage.setItem(this.STORAGE_KEY,String(this.isPaused))}catch(e){console.warn("Failed to save pause state:",e)}}pause(){this.isPaused||(this.isPaused=!0,this.savePauseState(),this.notifyListeners())}resume(){this.isPaused&&(this.isPaused=!1,this.savePauseState(),this.notifyListeners())}toggle(){this.isPaused?this.resume():this.pause()}getPaused(){return this.isPaused}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notifyListeners(){this.listeners.forEach(e=>{try{e(this.isPaused)}catch(r){console.error("Error in monitor state listener:",r)}})}}const P=new ye,xe=()=>{const{gl:n,scene:e}=Y.useThree();return f.useEffect(()=>{n&&(I.setRenderer(n),O.setRenderer(n))},[n]),f.useEffect(()=>{e&&oe.setScene(e)},[e]),f.useEffect(()=>(W.enable(),()=>{W.disable()}),[]),Y.useFrame((r,s)=>{n&&!P.getPaused()&&(F.startFrame(),W.startUpdatePhase(),W.endUpdatePhase(),W.startRenderPhase(),I.startFrame(),requestAnimationFrame(()=>{if(!P.getPaused()){W.endRenderPhase();const o=F.endFrame();if(I.endFrame(),I.getStats(),O.getStats(),o){const i=o.interval||o.total,c=Math.max(i,.001),l=1e3/c,m=l>500&&o.total<16?0:l;let a;typeof performance<"u"&&performance.memory&&(a=performance.memory.usedJSHeapSize/(1024*1024)),D.isEnabled()&&D.recordFrameStats(m,c,a)}}}))}),null},be={colors:{background:"rgba(15, 15, 15, 0.95)",surface:"rgba(26, 26, 26, 0.98)",surfaceElevated:"rgba(35, 35, 35, 0.98)",text:"#ffffff",textSecondary:"rgba(255, 255, 255, 0.7)",textTertiary:"rgba(255, 255, 255, 0.5)",border:"rgba(255, 255, 255, 0.1)",borderLight:"rgba(255, 255, 255, 0.05)",primary:"#3b82f6",primaryHover:"#2563eb",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4",accent:"#8b5cf6"},shadows:{md:"0 4px 6px rgba(0, 0, 0, 0.4)",xl:"0 20px 25px rgba(0, 0, 0, 0.6)"},borderRadius:{sm:"4px",md:"8px",lg:"12px"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px"},typography:{fontFamilyMono:'"SF Mono", "Monaco", "Inconsolata", "Roboto Mono", "Source Code Pro", monospace',fontSize:{xs:"10px",sm:"12px",md:"14px",lg:"16px"}},transitions:{fast:"150ms ease",normal:"250ms ease"},zIndex:{base:1e4}},$=be;function ee(n,e){return n<=e.good?$.colors.success:n<=e.warning?$.colors.warning:$.colors.error}function v(n,e=2){return n.toFixed(e)}const b=({label:n,value:e,unit:r,trend:s,status:o,color:i,icon:c,onClick:l,className:m=""})=>{const a=$;let j=i;!j&&o&&(j=o==="good"?a.colors.success:o==="warning"?a.colors.warning:a.colors.error);const y=typeof e=="number"?e.toLocaleString():e,d=r?` ${r}`:"";return t.jsxs("div",{onClick:l,className:m,style:{backgroundColor:a.colors.surface,border:`1px solid ${a.colors.border}`,borderRadius:a.borderRadius.md,padding:a.spacing.md,cursor:l?"pointer":"default",transition:a.transitions.fast,position:"relative",overflow:"hidden"},onMouseEnter:h=>{l&&(h.currentTarget.style.backgroundColor=a.colors.surfaceElevated,h.currentTarget.style.transform="translateY(-2px)",h.currentTarget.style.boxShadow=a.shadows.md)},onMouseLeave:h=>{l&&(h.currentTarget.style.backgroundColor=a.colors.surface,h.currentTarget.style.transform="translateY(0)",h.currentTarget.style.boxShadow="none")},children:[c&&t.jsx("div",{style:{position:"absolute",top:a.spacing.sm,right:a.spacing.sm,opacity:.3},children:c}),t.jsx("div",{style:{fontSize:a.typography.fontSize.sm,color:a.colors.textSecondary,marginBottom:a.spacing.xs,fontWeight:500},children:n}),t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:a.spacing.xs},children:[t.jsx("div",{style:{fontSize:a.typography.fontSize.lg,fontWeight:"bold",color:j||a.colors.text,fontFamily:a.typography.fontFamilyMono},children:y}),r&&t.jsx("div",{style:{fontSize:a.typography.fontSize.sm,color:a.colors.textTertiary},children:d}),s&&t.jsx("div",{style:{fontSize:a.typography.fontSize.xs,color:s==="up"?a.colors.error:s==="down"?a.colors.success:a.colors.textTertiary,marginLeft:"auto"},children:s==="up"?"↑":s==="down"?"↓":"→"})]}),j&&t.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2px",backgroundColor:j}})]})},ve=({tabs:n,activeTab:e,onTabChange:r,className:s=""})=>{const o=$;return t.jsx("div",{className:s,style:{position:"relative"},children:t.jsx("div",{style:{display:"flex",gap:o.spacing.xs,borderBottom:`1px solid ${o.colors.border}`,paddingBottom:o.spacing.xs},children:n.map(i=>{const c=i.id===e;return t.jsxs("button",{onClick:()=>r(i.id),style:{display:"flex",alignItems:"center",gap:o.spacing.xs,padding:`${o.spacing.sm} ${o.spacing.md}`,backgroundColor:"transparent",border:"none",color:c?o.colors.primary:o.colors.textSecondary,fontSize:o.typography.fontSize.sm,fontWeight:c?600:400,cursor:"pointer",position:"relative",transition:o.transitions.fast,borderRadius:`${o.borderRadius.sm} ${o.borderRadius.sm} 0 0`},onMouseEnter:l=>{c||(l.currentTarget.style.color=o.colors.text,l.currentTarget.style.backgroundColor=o.colors.surfaceElevated)},onMouseLeave:l=>{c||(l.currentTarget.style.color=o.colors.textSecondary,l.currentTarget.style.backgroundColor="transparent")},children:[i.icon&&t.jsx("span",{style:{display:"flex",alignItems:"center"},children:i.icon}),t.jsx("span",{children:i.label}),i.badge!==void 0&&t.jsx("span",{style:{backgroundColor:c?o.colors.primary:o.colors.surfaceElevated,color:c?o.colors.text:o.colors.textSecondary,borderRadius:o.borderRadius.sm,padding:`2px ${o.spacing.xs}`,fontSize:o.typography.fontSize.xs,fontWeight:600,minWidth:"18px",textAlign:"center"},children:i.badge}),c&&t.jsx("div",{style:{position:"absolute",bottom:-1,left:0,right:0,height:"2px",backgroundColor:o.colors.primary}})]},i.id)})})})},E=({severity:n,count:e,children:r,onClick:s})=>{const o=$,c={info:o.colors.info,warning:o.colors.warning,error:o.colors.error}[n];return t.jsxs("div",{onClick:s,style:{display:"inline-flex",alignItems:"center",gap:o.spacing.xs,padding:`${o.spacing.xs} ${o.spacing.sm}`,backgroundColor:`${c}20`,color:c,borderRadius:o.borderRadius.md,fontSize:o.typography.fontSize.xs,fontWeight:600,cursor:s?"pointer":"default",border:`1px solid ${c}40`,transition:o.transitions.fast},onMouseEnter:l=>{s&&(l.currentTarget.style.backgroundColor=`${c}30`)},onMouseLeave:l=>{s&&(l.currentTarget.style.backgroundColor=`${c}20`)},children:[t.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:c}}),e!==void 0&&e>0&&t.jsx("span",{children:e}),r]})};function q(){const[n,e]=f.useState(null);return f.useEffect(()=>{const r=()=>{if(!P.getPaused()){const c=D.getData();e(c)}},s=D.subscribe(c=>{P.getPaused()||e(c)});r();const o=setInterval(()=>{D.isEnabled()&&!P.getPaused()&&r()},100),i=P.subscribe(c=>{c||r()});return()=>{s(),i(),clearInterval(o)}},[]),n}const _=120;function G(){const n=q(),[e,r]=f.useState([]),s=f.useRef(0),o=f.useRef(null);return f.useEffect(()=>{if(!n||n.frames===0){r([]),s.current=0;return}const i=()=>{if(P.getPaused())return;const l=F.getLastBreakdown();if(l&&l.total>0){r(m=>{const a=m.length>0?m[m.length-1]:null;if(a===null||Math.abs(l.total-a)>.1){const j=[...m,l.total];return j.length>_?j.slice(-_):j}return m});return}if(n&&n.frames>0){const m=n.totalTime/n.frames;if(n.frames>s.current){const a=n.frames-s.current;s.current=n.frames,r(j=>{const y=[...j],d=Math.min(a,10);for(let h=0;h<d;h++)y.push(m);return y.length>_?y.slice(-_):y})}}};o.current=window.setInterval(i,16);const c=P.subscribe(l=>{!l&&n&&n.frames>0&&i()});return()=>{o.current!==null&&clearInterval(o.current),c()}},[n]),e}function ne(){const[n,e]=f.useState(null),r=f.useRef(null);return f.useEffect(()=>{const s=()=>{if(!P.getPaused()){const i=F.getLastBreakdown();i&&e(i)}};s(),r.current=window.setInterval(s,100);const o=P.subscribe(i=>{i||s()});return()=>{r.current!==null&&clearInterval(r.current),o()}},[]),n}const Se=({width:n=600,height:e=200,showGrid:r=!0,showLabels:s=!0,maxValue:o,minValue:i})=>{const c=G(),l=$,m=typeof n=="string"&&n.includes("%"),a=m?"100%":typeof n=="number"?n:600,{normalizedData:j,chartMax:y,chartMin:d}=f.useMemo(()=>{if(c.length===0)return{normalizedData:[],chartMax:0,chartMin:0};const g=o??Math.max(...c),z=i??Math.min(...c),M=g-z||1;return{normalizedData:c.map(V=>{const x=(V-z)/M*e;return Math.max(0,Math.min(e,x))}),chartMax:g,chartMin:z}},[c,o,i,e]);if(c.length===0)return t.jsx("div",{style:{width:a,height:e,display:"flex",alignItems:"center",justifyContent:"center",color:l.colors.textTertiary,fontSize:l.typography.fontSize.sm,border:`1px solid ${l.colors.border}`,borderRadius:l.borderRadius.md},children:"No frame data available"});const h=m?600:typeof a=="number"?a:600,T=h/(c.length-1||1),C=j.map((g,z)=>{const M=z*T;return`${z===0?"M":"L"} ${M} ${e-g}`}).join(" "),p=`${C} L ${h} ${e} L 0 ${e} Z`,S=e-(16.67-d)/(y-d||1)*e,R=m?"100%":a;return t.jsx("div",{style:{position:"relative",width:a},children:t.jsxs("svg",{width:R,height:e,style:{display:"block"},viewBox:m?`0 0 600 ${e}`:void 0,preserveAspectRatio:m?"none":void 0,children:[r&&t.jsx("g",{opacity:.2,children:[0,.25,.5,.75,1].map(g=>{const z=e*g;return t.jsx("line",{x1:0,y1:z,x2:h,y2:z,stroke:l.colors.border,strokeWidth:1},g)})}),S>=0&&S<=e&&t.jsx("line",{x1:0,y1:S,x2:h,y2:S,stroke:l.colors.success,strokeWidth:2,strokeDasharray:"4 4",opacity:.5}),t.jsx("path",{d:p,fill:l.colors.primary,fillOpacity:.2}),t.jsx("path",{d:C,fill:"none",stroke:l.colors.primary,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),j.map((g,z)=>{const B=c[z]>16.67;return t.jsx("circle",{cx:z*T,cy:e-g,r:B?3:2,fill:B?l.colors.error:l.colors.primary},z)}),s&&t.jsxs("g",{children:[t.jsxs("text",{x:h-4,y:12,fill:l.colors.textSecondary,fontSize:l.typography.fontSize.xs,textAnchor:"end",children:[v(y,2),"ms"]}),t.jsxs("text",{x:h-4,y:e-4,fill:l.colors.textSecondary,fontSize:l.typography.fontSize.xs,textAnchor:"end",children:[v(d,2),"ms"]}),S>=0&&S<=e&&t.jsx("text",{x:4,y:S-4,fill:l.colors.success,fontSize:l.typography.fontSize.xs,fontWeight:600,children:"60 FPS"})]})]})})},je=({width:n=800,height:e=300,timeWindow:r=10})=>{const s=G(),o=$,i=typeof n=="string"&&n.includes("%"),c=i?"100%":typeof n=="number"?n:800,l=f.useMemo(()=>{const S=performance.now(),R=s.slice(-Math.floor(r*60));return R.map((z,M)=>({timestamp:S-(R.length-M)*16.666666666666668,frameTime:z,fps:z>0?1e3/z:0}))},[s,r]);if(l.length===0)return t.jsx("div",{style:{width:c,height:e,display:"flex",alignItems:"center",justifyContent:"center",color:o.colors.textTertiary,fontSize:o.typography.fontSize.sm,border:`1px solid ${o.colors.border}`,borderRadius:o.borderRadius.md,backgroundColor:o.colors.surface},children:"No timeline data available"});const m=Math.max(...l.map(S=>S.frameTime),50),a=Math.min(...l.map(S=>S.frameTime),0),j=Math.max(...l.map(S=>S.fps),60),y=Math.min(...l.map(S=>S.fps),0),d=e/2,h=i?800:typeof c=="number"?c:800,T=h/(l.length-1||1),C=l.map((S,R)=>{const g=d-(S.frameTime-a)/(m-a||1)*d,z=R*T;return`${R===0?"M":"L"} ${z} ${g}`}).join(" "),p=l.map((S,R)=>{const g=d-(S.fps-y)/(j-y||1)*d,z=R*T;return`${R===0?"M":"L"} ${z} ${g+d}`}).join(" "),u=i?"100%":c;return t.jsxs("div",{style:{width:c,height:e,backgroundColor:"transparent",borderRadius:o.borderRadius.md},children:[t.jsxs("div",{style:{fontSize:o.typography.fontSize.sm,fontWeight:600,color:o.colors.text,marginBottom:o.spacing.sm},children:["Timeline (",r,"s window)"]}),t.jsx("div",{style:{width:"100%",height:e,position:"relative",overflow:"hidden"},children:t.jsxs("svg",{width:u,height:e,style:{display:"block"},viewBox:i?`0 0 800 ${e}`:void 0,preserveAspectRatio:i?"none":void 0,children:[t.jsx("g",{opacity:.1,children:[0,.25,.5,.75,1].map(S=>{const R=e*S;return t.jsx("line",{x1:0,y1:R,x2:h,y2:R,stroke:o.colors.border,strokeWidth:1},S)})}),t.jsx("line",{x1:0,y1:d,x2:h,y2:d,stroke:o.colors.border,strokeWidth:2}),t.jsxs("g",{children:[t.jsx("text",{x:4,y:12,fill:o.colors.textSecondary,fontSize:o.typography.fontSize.xs,fontWeight:600,children:"Frame Time (ms)"}),t.jsx("path",{d:C,fill:"none",stroke:o.colors.error,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("line",{x1:0,y1:d-(16.67-a)/(m-a||1)*d,x2:h,y2:d-(16.67-a)/(m-a||1)*d,stroke:o.colors.success,strokeWidth:1,strokeDasharray:"2 2",opacity:.5})]}),t.jsxs("g",{children:[t.jsx("text",{x:4,y:d+12,fill:o.colors.textSecondary,fontSize:o.typography.fontSize.xs,fontWeight:600,children:"FPS"}),t.jsx("path",{d:p,fill:"none",stroke:o.colors.success,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("line",{x1:0,y1:d+d-(60-y)/(j-y||1)*d,x2:h,y2:d+d-(60-y)/(j-y||1)*d,stroke:o.colors.success,strokeWidth:1,strokeDasharray:"2 2",opacity:.5})]}),t.jsxs("g",{children:[t.jsxs("text",{x:h-4,y:12,fill:o.colors.textTertiary,fontSize:o.typography.fontSize.xs,textAnchor:"end",children:[v(m,1),"ms"]}),t.jsxs("text",{x:h-4,y:d-4,fill:o.colors.textTertiary,fontSize:o.typography.fontSize.xs,textAnchor:"end",children:[v(a,1),"ms"]}),t.jsxs("text",{x:h-4,y:d+12,fill:o.colors.textTertiary,fontSize:o.typography.fontSize.xs,textAnchor:"end",children:[v(j,0)," FPS"]}),t.jsxs("text",{x:h-4,y:e-4,fill:o.colors.textTertiary,fontSize:o.typography.fontSize.xs,textAnchor:"end",children:[v(y,0)," FPS"]})]})]})})]})};function we(){const[n,e]=f.useState([]);return f.useEffect(()=>{const r=()=>{if(!P.getPaused()){const i=O.getStats();i&&e(c=>[...c,{...i,time:Date.now()}].slice(-120))}};r();const s=setInterval(r,1e3),o=P.subscribe(i=>{i||r()});return()=>{clearInterval(s),o()}},[]),n}const Re=({width:n="100%",height:e=200,showGrid:r=!0,showLabels:s=!0,timeWindow:o=60,metric:i="both"})=>{const c=we(),l=$,m=f.useMemo(()=>{const p=Date.now()-o*1e3,u=c.filter(B=>B.time>=p);if(u.length===0)return{jsHeapData:[],gpuMemoryData:[],maxValue:0,minValue:0};const S=u.map(B=>B.jsHeap.used),R=u.map(B=>B.gpuMemory.total),g=[...S,...R].filter(B=>B>0),z=g.length>0?Math.max(...g):0,M=g.length>0?Math.min(...g):0;return{jsHeapData:S,gpuMemoryData:R,maxValue:z||1,minValue:M}},[c,o]);if(m.jsHeapData.length===0&&m.gpuMemoryData.length===0)return t.jsx("div",{style:{width:n,height:e,display:"flex",alignItems:"center",justifyContent:"center",color:l.colors.textTertiary,fontSize:l.typography.fontSize.sm,border:`1px solid ${l.colors.border}`,borderRadius:l.borderRadius.md,backgroundColor:l.colors.surface},children:"No memory data available"});const a=800,j=a/(Math.max(m.jsHeapData.length,m.gpuMemoryData.length)-1||1),y=m.maxValue-m.minValue||1,d=m.jsHeapData.map((C,p)=>{const u=e-(C-m.minValue)/y*e,S=p*j;return`${p===0?"M":"L"} ${S} ${u}`}).join(" "),h=m.gpuMemoryData.map((C,p)=>{const u=e-(C-m.minValue)/y*e,S=p*j;return`${p===0?"M":"L"} ${S} ${u}`}).join(" "),T=C=>C<1024?`${v(C,0)} B`:C<1024*1024?`${v(C/1024,1)} KB`:C<1024*1024*1024?`${v(C/(1024*1024),1)} MB`:`${v(C/(1024*1024*1024),2)} GB`;return t.jsx("div",{style:{position:"relative",width:n,height:e},children:t.jsxs("svg",{width:"100%",height:e,viewBox:`0 0 ${a} ${e}`,preserveAspectRatio:"none",style:{display:"block"},children:[r&&t.jsx("g",{opacity:.2,children:[0,.25,.5,.75,1].map(C=>{const p=e*C;return t.jsx("line",{x1:0,y1:p,x2:a,y2:p,stroke:l.colors.border,strokeWidth:1},C)})}),i==="jsHeap"||i==="both"?t.jsxs(t.Fragment,{children:[t.jsx("path",{d:`${d} L ${a} ${e} L 0 ${e} Z`,fill:l.colors.primary,fillOpacity:.1}),t.jsx("path",{d,fill:"none",stroke:l.colors.primary,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})]}):null,i==="gpuMemory"||i==="both"?t.jsxs(t.Fragment,{children:[t.jsx("path",{d:`${h} L ${a} ${e} L 0 ${e} Z`,fill:l.colors.accent,fillOpacity:.1}),t.jsx("path",{d:h,fill:"none",stroke:l.colors.accent,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})]}):null,s&&t.jsxs("g",{children:[t.jsx("text",{x:a-4,y:12,fill:l.colors.textSecondary,fontSize:l.typography.fontSize.xs,textAnchor:"end",children:T(m.maxValue)}),t.jsx("text",{x:a-4,y:e-4,fill:l.colors.textSecondary,fontSize:l.typography.fontSize.xs,textAnchor:"end",children:T(m.minValue)}),i==="both"&&t.jsxs(t.Fragment,{children:[t.jsx("text",{x:4,y:12,fill:l.colors.primary,fontSize:l.typography.fontSize.xs,children:"JS Heap"}),t.jsx("text",{x:4,y:e-4,fill:l.colors.accent,fontSize:l.typography.fontSize.xs,children:"GPU Memory"})]})]})]})})},Ce=()=>{const n=q(),e=G(),r=ne(),s=$,o=f.useMemo(()=>!n||!n.entries?[]:[...n.entries].sort((y,d)=>d.total-y.total),[n]),i=f.useMemo(()=>r?r.interval||r.total:!n||n.totalTime||n.frames===0?0:n.totalTime/n.frames,[r,n]),c=f.useMemo(()=>r?r.total:!n||n.frames===0?0:n.totalTime/n.frames,[r,n]),l=f.useMemo(()=>i>0?1e3/i:0,[i]),m=f.useMemo(()=>c<=16.67?"good":c<=33.33?"warning":"error",[c]),a=f.useMemo(()=>e.length>0?e:c>0?[c]:[],[e,c]),j=f.useMemo(()=>a.length===0?33:Math.max(...a,20),[a]);return!n||n.entries.length===0?t.jsx("div",{style:{padding:s.spacing.lg,textAlign:"center",color:s.colors.textSecondary,fontSize:s.typography.fontSize.sm},children:"Aucune donnée profilée pour le moment."}):t.jsxs("div",{style:{padding:s.spacing.md},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:s.spacing.md,marginBottom:s.spacing.lg},children:[t.jsx(b,{label:"FPS",value:v(l,1),status:l>=60?"good":l>=30?"warning":"error"}),t.jsx(b,{label:"Frame Time",value:v(c,2),unit:"ms",status:m}),t.jsx(b,{label:"Total Time",value:v(n.totalTime,2),unit:"ms"}),t.jsx(b,{label:"Frames",value:n.frames})]}),t.jsxs("div",{style:{backgroundColor:s.colors.surface,borderRadius:s.borderRadius.md,padding:s.spacing.md,marginBottom:s.spacing.lg,border:`1px solid ${s.colors.border}`,overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:s.spacing.sm},children:[t.jsx("div",{style:{fontSize:s.typography.fontSize.sm,fontWeight:600,color:s.colors.text},children:"Frame Time History"}),t.jsxs("div",{style:{fontSize:s.typography.fontSize.xs,color:s.colors.textSecondary,fontFamily:s.typography.fontFamilyMono},children:[a.length," frames"]})]}),t.jsx(Se,{width:"100%",height:100,showGrid:!0,showLabels:!0,maxValue:j}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:s.spacing.xs,fontSize:s.typography.fontSize.xs,color:s.colors.textTertiary},children:[t.jsx("div",{children:"Target: <16.67ms (60 FPS)"}),t.jsxs("div",{style:{color:ee(c,{good:16.67,warning:33.33})},children:["Current: ",v(c,2),"ms (work)"]})]})]}),t.jsx("div",{style:{backgroundColor:s.colors.surface,borderRadius:s.borderRadius.md,padding:s.spacing.md,marginBottom:s.spacing.lg,border:`1px solid ${s.colors.border}`,overflow:"hidden"},children:t.jsx(je,{width:"100%",height:200,timeWindow:10})}),t.jsx("div",{style:{backgroundColor:s.colors.surface,borderRadius:s.borderRadius.md,border:`1px solid ${s.colors.border}`,overflow:"hidden"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{backgroundColor:s.colors.surfaceElevated,borderBottom:`1px solid ${s.colors.border}`},children:[t.jsx("th",{style:{textAlign:"left",padding:s.spacing.md,color:s.colors.textSecondary,fontSize:s.typography.fontSize.sm,fontWeight:600},children:"Hook"}),t.jsx("th",{style:{textAlign:"right",padding:s.spacing.md,color:s.colors.textSecondary,fontSize:s.typography.fontSize.sm,fontWeight:600},children:"Total (ms)"}),t.jsx("th",{style:{textAlign:"right",padding:s.spacing.md,color:s.colors.textSecondary,fontSize:s.typography.fontSize.sm,fontWeight:600},children:"Avg (ms)"}),t.jsx("th",{style:{textAlign:"right",padding:s.spacing.md,color:s.colors.textSecondary,fontSize:s.typography.fontSize.sm,fontWeight:600},children:"Max (ms)"}),t.jsx("th",{style:{textAlign:"right",padding:s.spacing.md,color:s.colors.textSecondary,fontSize:s.typography.fontSize.sm,fontWeight:600},children:"%"})]})}),t.jsx("tbody",{children:o.map((y,d)=>{const h=ee(y.avg,{good:5,warning:10});return t.jsxs("tr",{style:{borderBottom:d<o.length-1?`1px solid ${s.colors.borderLight}`:"none",transition:s.transitions.fast},onMouseEnter:T=>{T.currentTarget.style.backgroundColor=s.colors.surfaceElevated},onMouseLeave:T=>{T.currentTarget.style.backgroundColor="transparent"},children:[t.jsx("td",{style:{padding:s.spacing.md,color:s.colors.text,fontFamily:s.typography.fontFamilyMono,fontSize:s.typography.fontSize.sm},children:y.name}),t.jsx("td",{style:{textAlign:"right",padding:s.spacing.md,color:s.colors.text,fontFamily:s.typography.fontFamilyMono,fontSize:s.typography.fontSize.sm},children:v(y.total,2)}),t.jsx("td",{style:{textAlign:"right",padding:s.spacing.md,color:h,fontFamily:s.typography.fontFamilyMono,fontSize:s.typography.fontSize.sm,fontWeight:600},children:v(y.avg,3)}),t.jsx("td",{style:{textAlign:"right",padding:s.spacing.md,color:s.colors.text,fontFamily:s.typography.fontFamilyMono,fontSize:s.typography.fontSize.sm},children:v(y.max,3)}),t.jsxs("td",{style:{textAlign:"right",padding:s.spacing.md,color:s.colors.textSecondary,fontFamily:s.typography.fontFamilyMono,fontSize:s.typography.fontSize.sm},children:[v(y.percentage,1),"%"]})]},y.name)})})]})})]})};function K(){const[n,e]=f.useState(null),r=f.useRef(null);return f.useEffect(()=>{const s=()=>{if(!P.getPaused()){const i=I.getStats();i&&e(i)}};s(),r.current=window.setInterval(s,100);const o=P.subscribe(i=>{i||s()});return()=>{r.current!==null&&clearInterval(r.current),o()}},[]),n}const ze=()=>{const n=K(),e=$,r=f.useMemo(()=>n?n.drawCalls<=100?"good":n.drawCalls<=500?"warning":"error":"neutral",[n]),s=f.useMemo(()=>n?n.triangles<=1e5?"good":n.triangles<=5e5?"warning":"error":"neutral",[n]);if(!n)return t.jsx("div",{style:{padding:e.spacing.lg,textAlign:"center",color:e.colors.textSecondary,fontSize:e.typography.fontSize.sm},children:"Aucune donnée GPU disponible. Assurez-vous que le composant est à l'intérieur d'un Canvas R3F."});const o=i=>i===0?"0 B":i<1024?`${v(i,0)} B`:i<1024*1024?`${v(i/1024,2)} KB`:`${v(i/(1024*1024),2)} MB`;return t.jsxs("div",{style:{padding:e.spacing.md},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:e.spacing.md,marginBottom:e.spacing.lg},children:[t.jsx(b,{label:"Draw Calls",value:n.drawCalls.toLocaleString(),status:r}),t.jsx(b,{label:"Triangles",value:n.triangles.toLocaleString(),status:s}),t.jsx(b,{label:"Points",value:n.points.toLocaleString()}),t.jsx(b,{label:"Lines",value:n.lines.toLocaleString()})]}),t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,marginBottom:e.spacing.lg,border:`1px solid ${e.colors.border}`},children:[t.jsx("div",{style:{fontSize:e.typography.fontSize.md,fontWeight:600,color:e.colors.text,marginBottom:e.spacing.md},children:"GPU Memory"}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))",gap:e.spacing.md},children:[t.jsx(b,{label:"Textures",value:o(n.memory.textures)}),t.jsx(b,{label:"Geometries",value:o(n.memory.geometries)}),t.jsx(b,{label:"Programs",value:o(n.memory.programs)}),t.jsx(b,{label:"Total",value:o(n.memory.total),color:n.memory.total>100*1024*1024?e.colors.warning:e.colors.success})]})]}),t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,border:`1px solid ${e.colors.border}`},children:[t.jsx("div",{style:{fontSize:e.typography.fontSize.md,fontWeight:600,color:e.colors.text,marginBottom:e.spacing.md},children:"Resources"}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))",gap:e.spacing.md},children:[t.jsx(b,{label:"Textures",value:n.textures}),t.jsx(b,{label:"Geometries",value:n.geometries}),t.jsx(b,{label:"Programs",value:n.programs})]})]})]})};function Te(){const[n,e]=f.useState(null),r=f.useRef(null);return f.useEffect(()=>{const s=()=>{if(!P.getPaused()){const i=oe.getStats();i&&e(i)}};s(),r.current=window.setInterval(s,500);const o=P.subscribe(i=>{i||s()});return()=>{r.current!==null&&clearInterval(r.current),o()}},[]),n}const Me=()=>{const n=Te(),e=$;if(!n)return t.jsx("div",{style:{padding:e.spacing.lg,textAlign:"center",color:e.colors.textSecondary,fontSize:e.typography.fontSize.sm},children:"Aucune donnée de scène disponible. Assurez-vous que le composant est à l'intérieur d'un Canvas R3F."});const r=s=>s<1024?`${v(s,0)} B`:s<1024*1024?`${v(s/1024,2)} KB`:`${v(s/(1024*1024),2)} MB`;return t.jsxs("div",{style:{padding:e.spacing.md},children:[t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,marginBottom:e.spacing.lg,border:`1px solid ${e.colors.border}`},children:[t.jsx("div",{style:{fontSize:e.typography.fontSize.md,fontWeight:600,color:e.colors.text,marginBottom:e.spacing.md},children:"Objects"}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))",gap:e.spacing.md},children:[t.jsx(b,{label:"Total",value:n.objects.total.toLocaleString()}),t.jsx(b,{label:"Meshes",value:n.objects.meshes.toLocaleString()}),t.jsx(b,{label:"Lights",value:n.objects.lights.toLocaleString()}),t.jsx(b,{label:"Cameras",value:n.objects.cameras.toLocaleString()}),t.jsx(b,{label:"Groups",value:n.objects.groups.toLocaleString()}),t.jsx(b,{label:"Visible",value:n.visible.total.toLocaleString(),color:n.visible.total===n.objects.total?e.colors.success:e.colors.warning})]})]}),t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,marginBottom:e.spacing.lg,border:`1px solid ${e.colors.border}`},children:[t.jsxs("div",{style:{fontSize:e.typography.fontSize.md,fontWeight:600,color:e.colors.text,marginBottom:e.spacing.md},children:["Materials (",n.materials.total,")"]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:e.spacing.sm},children:Object.entries(n.materials.byType).map(([s,o])=>t.jsxs("div",{style:{backgroundColor:e.colors.surfaceElevated,padding:`${e.spacing.xs} ${e.spacing.sm}`,borderRadius:e.borderRadius.sm,fontSize:e.typography.fontSize.xs,color:e.colors.textSecondary,fontFamily:e.typography.fontFamilyMono},children:[s,": ",o]},s))})]}),n.textures.total>0&&t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,marginBottom:e.spacing.lg,border:`1px solid ${e.colors.border}`},children:[t.jsx("div",{style:{fontSize:e.typography.fontSize.md,fontWeight:600,color:e.colors.text,marginBottom:e.spacing.md},children:"Textures"}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:e.spacing.md},children:[t.jsx(b,{label:"Total",value:n.textures.total.toLocaleString()}),t.jsx(b,{label:"Total Size",value:r(n.textures.totalSize)}),n.textures.environment>0&&t.jsx(b,{label:"Environment",value:n.textures.environment.toLocaleString(),color:e.colors.info}),n.textures.system>0&&t.jsx(b,{label:"System",value:n.textures.system.toLocaleString(),color:e.colors.warning})]})]}),t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,marginBottom:e.spacing.lg,border:`1px solid ${e.colors.border}`},children:[t.jsx("div",{style:{fontSize:e.typography.fontSize.md,fontWeight:600,color:e.colors.text,marginBottom:e.spacing.md},children:"Geometries"}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:e.spacing.md},children:[t.jsx(b,{label:"Total",value:n.geometries.total.toLocaleString()}),t.jsx(b,{label:"Vertices",value:n.geometries.vertices.toLocaleString()}),t.jsx(b,{label:"Faces",value:n.geometries.faces.toLocaleString()})]})]}),t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,border:`1px solid ${e.colors.border}`},children:[t.jsx("div",{style:{fontSize:e.typography.fontSize.md,fontWeight:600,color:e.colors.text,marginBottom:e.spacing.md},children:"Complexity"}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:e.spacing.md},children:[t.jsx(b,{label:"Avg Vertices/Mesh",value:v(n.complexity.averageVerticesPerMesh,0)}),t.jsx(b,{label:"Avg Faces/Mesh",value:v(n.complexity.averageFacesPerMesh,0)}),t.jsx(b,{label:"Est. Draw Calls",value:n.complexity.totalDrawCalls.toLocaleString()})]})]})]})};function X(){const[n,e]=f.useState(null),r=f.useRef(null);return f.useEffect(()=>{const s=()=>{if(!P.getPaused()){const i=O.getStats();i&&e(i)}};s(),r.current=window.setInterval(s,1e3);const o=P.subscribe(i=>{i||s()});return()=>{r.current!==null&&clearInterval(r.current),o()}},[]),n}const Pe=()=>{const n=X(),e=$,r=i=>i===0?"0 B":i<1024?`${v(i,0)} B`:i<1024*1024?`${v(i/1024,2)} KB`:i<1024*1024*1024?`${v(i/(1024*1024),2)} MB`:`${v(i/(1024*1024*1024),2)} GB`,s=f.useMemo(()=>{if(!n)return"neutral";const i=n.jsHeap.percentage;return i<50?"good":i<80?"warning":"error"},[n]),o=f.useMemo(()=>n?n.leaks.detected?"error":"good":"neutral",[n]);return n?t.jsxs("div",{style:{padding:e.spacing.md},children:[n.jsHeap.limit>0&&t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,marginBottom:e.spacing.lg,border:`1px solid ${e.colors.border}`},children:[t.jsx("div",{style:{fontSize:e.typography.fontSize.sm,fontWeight:600,color:e.colors.text,marginBottom:e.spacing.sm},children:"JavaScript Heap Memory"}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:e.spacing.md,marginBottom:e.spacing.md},children:[t.jsx(b,{label:"Used",value:r(n.jsHeap.used),status:s}),t.jsx(b,{label:"Total",value:r(n.jsHeap.total)}),t.jsx(b,{label:"Limit",value:r(n.jsHeap.limit)}),t.jsx(b,{label:"Usage",value:`${v(n.jsHeap.percentage,1)}%`,status:s})]}),t.jsx("div",{style:{width:"100%",height:"8px",backgroundColor:e.colors.border,borderRadius:e.borderRadius.sm,overflow:"hidden",marginTop:e.spacing.sm},children:t.jsx("div",{style:{width:`${Math.min(100,n.jsHeap.percentage)}%`,height:"100%",backgroundColor:n.jsHeap.percentage<=50?e.colors.success:n.jsHeap.percentage<=80?e.colors.warning:e.colors.error,transition:e.transitions.normal}})})]}),n.gpuMemory.total>0&&t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,marginBottom:e.spacing.lg,border:`1px solid ${e.colors.border}`},children:[t.jsx("div",{style:{fontSize:e.typography.fontSize.sm,fontWeight:600,color:e.colors.text,marginBottom:e.spacing.sm},children:"GPU Memory (Estimated)"}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))",gap:e.spacing.sm},children:[t.jsx(b,{label:"Textures",value:r(n.gpuMemory.textures)}),t.jsx(b,{label:"Geometries",value:r(n.gpuMemory.geometries)}),t.jsx(b,{label:"Total",value:r(n.gpuMemory.total)})]}),t.jsx("div",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textTertiary,marginTop:e.spacing.sm},children:"Note: GPU memory is an estimation based on resource counts. Actual usage may vary."})]}),t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,marginBottom:e.spacing.lg,border:`1px solid ${e.colors.border}`,overflow:"hidden"},children:[t.jsx("div",{style:{fontSize:e.typography.fontSize.sm,fontWeight:600,color:e.colors.text,marginBottom:e.spacing.sm},children:"Memory Evolution (Last 60s)"}),t.jsx(Re,{width:"100%",height:150,timeWindow:60,metric:"both",showGrid:!0,showLabels:!0})]}),t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,border:`1px solid ${e.colors.border}`},children:[t.jsx("div",{style:{fontSize:e.typography.fontSize.sm,fontWeight:600,color:e.colors.text,marginBottom:e.spacing.sm},children:"Memory Leak Detection"}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:e.spacing.sm,marginBottom:e.spacing.sm},children:[t.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",backgroundColor:o==="good"?e.colors.success:e.colors.error}}),t.jsx("div",{style:{color:e.colors.text,fontSize:e.typography.fontSize.sm},children:n.leaks.detected?"Potential leak detected":"No leaks detected"})]}),t.jsxs("div",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textSecondary,fontFamily:e.typography.fontFamilyMono},children:[t.jsxs("div",{children:["Growth Rate: ",r(Math.abs(n.leaks.growthRate)),"/s"]}),t.jsxs("div",{children:["Trend: ",n.leaks.trend]})]})]})]}):t.jsx("div",{style:{padding:e.spacing.lg,textAlign:"center",color:e.colors.textSecondary,fontSize:e.typography.fontSize.sm},children:"Aucune donnée de mémoire disponible. Les stats de mémoire JS nécessitent Chrome."})},ke=()=>{const n=ne(),e=$,r=l=>l<.1?`${v(l*1e3,0)} μs`:l<1?`${v(l,2)} ms`:`${v(l,2)} ms`,s=(l,m)=>m===0?"0%":`${v(l/m*100,1)}%`,o=f.useMemo(()=>n?n.total<=16.67?"good":n.total<=33.33?"warning":"error":"neutral",[n]);if(!n)return t.jsx("div",{style:{padding:e.spacing.lg,textAlign:"center",color:e.colors.textSecondary,fontSize:e.typography.fontSize.sm},children:"Aucune donnée de breakdown de frame disponible. Le frame breakdown nécessite une instrumentation du code."});const i=[{name:"React",value:n.phases.react,color:e.colors.primary},{name:"Update",value:n.phases.update,color:e.colors.info},{name:"Physics",value:n.phases.physics,color:e.colors.warning},{name:"Render",value:n.phases.render,color:e.colors.success},{name:"Post-Process",value:n.phases.postProcess,color:e.colors.accent},{name:"Other",value:n.phases.other,color:e.colors.textSecondary}].filter(l=>l.value>0),c=Math.max(...i.map(l=>l.value),n.total);return t.jsxs("div",{style:{padding:e.spacing.md},children:[t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,marginBottom:e.spacing.lg,border:`1px solid ${e.colors.border}`},children:[t.jsx("div",{style:{fontSize:e.typography.fontSize.sm,fontWeight:600,color:e.colors.text,marginBottom:e.spacing.sm},children:"Total Frame Time"}),t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:e.spacing.sm,marginBottom:e.spacing.sm},children:[t.jsx(b,{label:"Frame Time",value:r(n.total),status:o}),t.jsxs("div",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textSecondary},children:["(",v(1e3/n.total,1)," FPS)"]})]})]}),t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,marginBottom:e.spacing.lg,border:`1px solid ${e.colors.border}`},children:[t.jsx("div",{style:{fontSize:e.typography.fontSize.sm,fontWeight:600,color:e.colors.text,marginBottom:e.spacing.sm},children:"Phase Breakdown"}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))",gap:e.spacing.sm,marginBottom:e.spacing.md},children:i.map(l=>t.jsx(b,{label:l.name,value:r(l.value)},l.name))}),t.jsxs("div",{style:{marginTop:e.spacing.md},children:[t.jsx("div",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textSecondary,marginBottom:e.spacing.sm},children:"Timeline (Waterfall)"}),t.jsx("div",{style:{position:"relative",height:"200px",backgroundColor:e.colors.background,borderRadius:e.borderRadius.sm,border:`1px solid ${e.colors.border}`,padding:e.spacing.xs},children:i.map((l,m)=>{const a=l.value/c*100,j=i.slice(0,m).reduce((y,d)=>y+d.value/c*100,0);return t.jsx("div",{style:{position:"absolute",left:`${j}%`,width:`${a}%`,height:"30px",backgroundColor:l.color,borderRadius:e.borderRadius.sm,display:"flex",alignItems:"center",justifyContent:"center",fontSize:e.typography.fontSize.xs,color:e.colors.background,fontWeight:600,marginTop:`${m*35}px`,opacity:.8,border:`1px solid ${e.colors.border}`},title:`${l.name}: ${r(l.value)} (${s(l.value,n.total)})`,children:a>5&&`${l.name}: ${r(l.value)}`},l.name)})})]})]}),n.timeline.length>0&&t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,border:`1px solid ${e.colors.border}`},children:[t.jsx("div",{style:{fontSize:e.typography.fontSize.sm,fontWeight:600,color:e.colors.text,marginBottom:e.spacing.sm},children:"Timeline Details"}),t.jsx("div",{style:{maxHeight:"200px",overflowY:"auto",fontSize:e.typography.fontSize.xs,fontFamily:e.typography.fontFamilyMono,color:e.colors.textSecondary},children:n.timeline.slice(-20).reverse().map((l,m)=>t.jsxs("div",{style:{padding:e.spacing.xs,borderBottom:`1px solid ${e.colors.border}`,display:"flex",justifyContent:"space-between"},children:[t.jsx("span",{children:l.name}),t.jsx("span",{children:r(l.duration)})]},m))})]})]})};class $e{budget=null;violations=[];maxHistorySize=100;listeners=new Set;STORAGE_KEY="r3f-profiler-budget";constructor(){this.loadBudget()}loadBudget(){try{const e=localStorage.getItem(this.STORAGE_KEY);if(e){const r=JSON.parse(e);this.isValidBudget(r)&&(this.budget=r)}}catch(e){console.warn("Failed to load saved budget from localStorage:",e)}}saveBudget(){try{this.budget?localStorage.setItem(this.STORAGE_KEY,JSON.stringify(this.budget)):localStorage.removeItem(this.STORAGE_KEY)}catch(e){console.warn("Failed to save budget to localStorage:",e)}}isValidBudget(e){return!e||typeof e!="object"?!1:e.fps&&typeof e.fps.min=="number"||e.frameTime&&typeof e.frameTime.max=="number"||e.memory&&(typeof e.memory.max=="number"||e.memory.jsHeap)||e.gpu&&(e.gpu.drawCalls||e.gpu.triangles)}setBudget(e){!e||!e.fps&&!e.frameTime&&!e.memory&&!e.gpu?this.budget=null:this.budget=e,this.violations=[],this.saveBudget(),this.notifyListeners()}getBudget(){return this.budget}checkBudget(e){if(!this.budget)return[];const r=[];return this.budget.fps?.min!==void 0&&e.fps!==void 0&&e.fps<this.budget.fps.min&&r.push({id:`fps-${Date.now()}-${Math.random()}`,metric:"fps",current:e.fps,budget:this.budget.fps.min,severity:e.fps<this.budget.fps.min*.7?"error":"warning",timestamp:performance.now(),message:`FPS is ${e.fps.toFixed(1)} (budget: ${this.budget.fps.min} FPS)`}),this.budget.frameTime?.max!==void 0&&e.frameTime!==void 0&&e.frameTime>this.budget.frameTime.max&&r.push({id:`frameTime-${Date.now()}-${Math.random()}`,metric:"frameTime",current:e.frameTime,budget:this.budget.frameTime.max,severity:e.frameTime>this.budget.frameTime.max*1.5?"error":"warning",timestamp:performance.now(),message:`Frame time is ${e.frameTime.toFixed(2)}ms (budget: ${this.budget.frameTime.max}ms)`}),this.budget.memory&&(this.budget.memory.max!==void 0&&e.memory?.used!==void 0&&e.memory.used>this.budget.memory.max&&r.push({id:`memory-${Date.now()}-${Math.random()}`,metric:"memory",current:e.memory.used,budget:this.budget.memory.max,severity:e.memory.used>this.budget.memory.max*1.2?"error":"warning",timestamp:performance.now(),message:`Memory usage is ${(e.memory.used/(1024*1024)).toFixed(2)}MB (budget: ${(this.budget.memory.max/(1024*1024)).toFixed(2)}MB)`}),this.budget.memory.jsHeap?.maxPercentage!==void 0&&e.memory?.jsHeapPercentage!==void 0&&e.memory.jsHeapPercentage>this.budget.memory.jsHeap.maxPercentage&&r.push({id:`jsHeap-${Date.now()}-${Math.random()}`,metric:"jsHeap",current:e.memory.jsHeapPercentage,budget:this.budget.memory.jsHeap.maxPercentage,severity:e.memory.jsHeapPercentage>this.budget.memory.jsHeap.maxPercentage*1.1?"error":"warning",timestamp:performance.now(),message:`JS Heap usage is ${e.memory.jsHeapPercentage.toFixed(1)}% (budget: ${this.budget.memory.jsHeap.maxPercentage}%)`})),this.budget.gpu&&(this.budget.gpu.drawCalls?.max!==void 0&&e.gpu?.drawCalls!==void 0&&e.gpu.drawCalls>this.budget.gpu.drawCalls.max&&r.push({id:`drawCalls-${Date.now()}-${Math.random()}`,metric:"drawCalls",current:e.gpu.drawCalls,budget:this.budget.gpu.drawCalls.max,severity:e.gpu.drawCalls>this.budget.gpu.drawCalls.max*1.5?"error":"warning",timestamp:performance.now(),message:`Draw calls: ${e.gpu.drawCalls} (budget: ${this.budget.gpu.drawCalls.max})`}),this.budget.gpu.triangles?.max!==void 0&&e.gpu?.triangles!==void 0&&e.gpu.triangles>this.budget.gpu.triangles.max&&r.push({id:`triangles-${Date.now()}-${Math.random()}`,metric:"triangles",current:e.gpu.triangles,budget:this.budget.gpu.triangles.max,severity:e.gpu.triangles>this.budget.gpu.triangles.max*1.5?"error":"warning",timestamp:performance.now(),message:`Triangles: ${e.gpu.triangles.toLocaleString()} (budget: ${this.budget.gpu.triangles.max.toLocaleString()})`})),r.length>0&&(this.violations.push(...r),this.violations.length>this.maxHistorySize&&(this.violations=this.violations.slice(-this.maxHistorySize)),this.notifyListeners()),r}getViolations(){return[...this.violations]}getRecentViolations(e=60){const r=performance.now()-e*1e3;return this.violations.filter(s=>s.timestamp>=r)}getViolationsByMetric(e){return this.violations.filter(r=>r.metric===e)}clearViolations(){this.violations=[],this.notifyListeners()}getRecommendedBudget(e){const r={};return e.fps!==void 0&&(r.fps={min:Math.max(30,Math.floor(e.fps*.9))}),e.frameTime!==void 0&&(r.frameTime={max:Math.ceil(e.frameTime*1.1)}),e.memory?.used!==void 0&&(r.memory={max:Math.ceil(e.memory.used*1.2),jsHeap:{maxPercentage:80}}),e.gpu&&(r.gpu={},e.gpu.drawCalls!==void 0&&(r.gpu.drawCalls={max:Math.ceil(e.gpu.drawCalls*1.2)}),e.gpu.triangles!==void 0&&(r.gpu.triangles={max:Math.ceil(e.gpu.triangles*1.2)})),r}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notifyListeners(){const e=this.getRecentViolations(60);this.listeners.forEach(r=>{try{r(e)}catch(s){console.error("Error in budget violation listener:",s)}})}reset(){this.budget=null,this.violations=[],this.listeners.clear(),localStorage.removeItem(this.STORAGE_KEY)}}const L=new $e;function Be(){const[n,e]=f.useState(null),[r,s]=f.useState([]);return f.useEffect(()=>{e(L.getBudget()),s(L.getRecentViolations(60));const m=L.subscribe(a=>{s(a),e(L.getBudget())});return()=>{m()}},[]),{budget:n,violations:r,setBudget:m=>{L.setBudget(m),e(m),s([])},clearViolations:()=>{L.clearViolations(),s([])},clearBudget:()=>{L.setBudget({}),e(null),s([])},getRecommendedBudget:m=>L.getRecommendedBudget(m)}}class Fe{alerts=[];maxAlerts=50;listeners=new Set;soundEnabled=!1;createFromViolation(e){return{id:`alert-${e.id}`,type:"budget",severity:e.severity,title:`Budget Violation: ${e.metric}`,message:e.message,timestamp:e.timestamp,dismissed:!1,data:{violation:e}}}createAlert(e,r,s,o,i){const c={id:`alert-${Date.now()}-${Math.random()}`,type:e,severity:r,title:s,message:o,timestamp:performance.now(),dismissed:!1,data:i};return this.addAlert(c),c}addAlert(e){if(e.type==="budget"&&e.data?.violation){const r=e.data.violation;this.alerts=this.alerts.filter(s=>!(s.type==="budget"&&s.data?.violation&&s.data.violation.metric===r.metric))}this.alerts.push(e),this.alerts.length>this.maxAlerts&&(this.alerts=this.alerts.slice(-this.maxAlerts)),this.soundEnabled&&e.severity==="error"&&this.playAlertSound(),this.notifyListeners()}getAlerts(e=!1){return e?[...this.alerts]:this.alerts.filter(r=>!r.dismissed)}getActiveAlerts(){return this.alerts.filter(e=>!e.dismissed)}getAlertsBySeverity(e){return this.alerts.filter(r=>!r.dismissed&&r.severity===e)}getAlertsByType(e){return this.alerts.filter(r=>!r.dismissed&&r.type===e)}dismissAlert(e){const r=this.alerts.find(s=>s.id===e);r&&(r.dismissed=!0,this.notifyListeners())}dismissAll(){this.alerts.forEach(e=>{e.dismissed=!0}),this.notifyListeners()}removeAlert(e){this.alerts=this.alerts.filter(r=>r.id!==e),this.notifyListeners()}clearAlerts(){this.alerts=[],this.notifyListeners()}setSoundEnabled(e){this.soundEnabled=e}isSoundEnabled(){return this.soundEnabled}playAlertSound(){try{const e=new(window.AudioContext||window.webkitAudioContext),r=e.createOscillator(),s=e.createGain();r.connect(s),s.connect(e.destination),r.frequency.value=800,r.type="sine",s.gain.setValueAtTime(.3,e.currentTime),s.gain.exponentialRampToValueAtTime(.01,e.currentTime+.1),r.start(e.currentTime),r.stop(e.currentTime+.1)}catch(e){console.debug("Could not play alert sound:",e)}}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notifyListeners(){const e=this.getActiveAlerts();this.listeners.forEach(r=>{try{r(e)}catch(s){console.error("Error in alert listener:",s)}})}reset(){this.alerts=[],this.listeners.clear(),this.soundEnabled=!1}}const te=new Fe;function De(){const n=G(),e=q(),r=K(),s=X(),o=f.useRef(null);f.useEffect(()=>{const i=()=>{if(!L.getBudget())return;let l=0,m=0;e&&e.totalTime>0&&e.frames>0?(m=e.totalTime/e.frames,l=1e3/m):n.length>0?(m=n.reduce((y,d)=>y+d,0)/n.length,l=m>0?1e3/m:0):r&&r.frameTime>0&&(m=r.frameTime,l=m>0?1e3/m:0);const a={fps:l,frameTime:m,memory:s?{used:s.jsHeap.used,jsHeapPercentage:s.jsHeap.percentage}:void 0,gpu:r?{drawCalls:r.drawCalls,triangles:r.triangles}:void 0};L.checkBudget(a).forEach(y=>{te.getAlerts().find(h=>h.type==="budget"&&h.data?.violation&&h.data.violation.id===y.id)||te.createFromViolation(y)})};return o.current=window.setInterval(i,1e3),i(),()=>{o.current!==null&&clearInterval(o.current)}},[n,e,r,s])}const Le=()=>{const{budget:n,violations:e,setBudget:r,clearViolations:s,clearBudget:o,getRecommendedBudget:i}=Be(),c=G(),l=K(),m=X(),a=$;De();const[j,y]=f.useState(!1),[d,h]=f.useState(n||{}),T=f.useMemo(()=>{const g=c.length>0?c.reduce((M,B)=>M+B,0)/c.length:0;return{fps:g>0?1e3/g:0,frameTime:g,memory:m?{used:m.jsHeap.used,jsHeapPercentage:m.jsHeap.percentage}:void 0,gpu:l?{drawCalls:l.drawCalls,triangles:l.triangles}:void 0}},[c,l,m]),C=g=>g===0?"0 B":g<1024?`${v(g,0)} B`:g<1024*1024?`${v(g/1024,2)} KB`:g<1024*1024*1024?`${v(g/(1024*1024),2)} MB`:`${v(g/(1024*1024*1024),2)} GB`,p=()=>{r(d),y(!1)},u=()=>{const g=i(T);h(g),r(g),y(!1)},S=()=>{h(n||{}),y(!1)},R=f.useMemo(()=>{const g=e.filter(M=>M.severity==="error").length,z=e.filter(M=>M.severity==="warning").length;return{errors:g,warnings:z}},[e]);return t.jsxs("div",{style:{padding:a.spacing.md},children:[t.jsxs("div",{style:{backgroundColor:a.colors.surface,borderRadius:a.borderRadius.md,padding:a.spacing.md,marginBottom:a.spacing.lg,border:`1px solid ${a.colors.border}`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:a.spacing.md},children:[t.jsx("div",{style:{fontSize:a.typography.fontSize.sm,fontWeight:600,color:a.colors.text},children:"Budget Status"}),t.jsxs("div",{style:{display:"flex",gap:a.spacing.sm,alignItems:"center"},children:[R.errors>0&&t.jsx(E,{severity:"error",count:R.errors}),R.warnings>0&&t.jsx(E,{severity:"warning",count:R.warnings}),!n&&t.jsx("div",{style:{fontSize:a.typography.fontSize.xs,color:a.colors.textSecondary},children:"No budget configured"})]})]}),n?t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:a.spacing.sm},children:[n.fps&&t.jsx(b,{label:"FPS Min",value:n.fps.min,unit:"FPS"}),n.frameTime&&t.jsx(b,{label:"Frame Time Max",value:`${n.frameTime.max.toFixed(2)}ms`}),n.memory?.max&&t.jsx(b,{label:"Memory Max",value:C(n.memory.max)}),n.gpu?.drawCalls?.max&&t.jsx(b,{label:"Draw Calls Max",value:n.gpu.drawCalls.max.toLocaleString()}),n.gpu?.triangles?.max&&t.jsx(b,{label:"Triangles Max",value:n.gpu.triangles.max.toLocaleString()})]}):t.jsx("div",{style:{padding:a.spacing.md,textAlign:"center",color:a.colors.textSecondary,fontSize:a.typography.fontSize.sm},children:"Configure a budget to start monitoring performance thresholds"})]}),t.jsxs("div",{style:{backgroundColor:a.colors.surface,borderRadius:a.borderRadius.md,padding:a.spacing.md,marginBottom:a.spacing.lg,border:`1px solid ${a.colors.border}`},children:[t.jsx("div",{style:{fontSize:a.typography.fontSize.sm,fontWeight:600,color:a.colors.text,marginBottom:a.spacing.md},children:"Budget Configuration"}),j?t.jsxs("div",{children:[t.jsxs("div",{style:{display:"grid",gap:a.spacing.sm,marginBottom:a.spacing.md},children:[t.jsxs("div",{children:[t.jsx("label",{style:{display:"block",fontSize:a.typography.fontSize.xs,color:a.colors.textSecondary,marginBottom:a.spacing.xs},children:"FPS Minimum"}),t.jsx("input",{type:"number",value:d.fps?.min||"",onChange:g=>h({...d,fps:{min:parseInt(g.target.value)||0}}),placeholder:"60",style:{width:"100%",padding:a.spacing.sm,backgroundColor:a.colors.background,border:`1px solid ${a.colors.border}`,borderRadius:a.borderRadius.sm,color:a.colors.text,fontSize:a.typography.fontSize.sm}})]}),t.jsxs("div",{children:[t.jsx("label",{style:{display:"block",fontSize:a.typography.fontSize.xs,color:a.colors.textSecondary,marginBottom:a.spacing.xs},children:"Frame Time Maximum (ms)"}),t.jsx("input",{type:"number",value:d.frameTime?.max||"",onChange:g=>h({...d,frameTime:{max:parseFloat(g.target.value)||0}}),placeholder:"16.67",step:"0.1",style:{width:"100%",padding:a.spacing.sm,backgroundColor:a.colors.background,border:`1px solid ${a.colors.border}`,borderRadius:a.borderRadius.sm,color:a.colors.text,fontSize:a.typography.fontSize.sm}})]}),t.jsxs("div",{children:[t.jsx("label",{style:{display:"block",fontSize:a.typography.fontSize.xs,color:a.colors.textSecondary,marginBottom:a.spacing.xs},children:"Memory Maximum (MB)"}),t.jsx("input",{type:"number",value:d.memory?.max?d.memory.max/(1024*1024):"",onChange:g=>h({...d,memory:{...d.memory,max:(parseFloat(g.target.value)||0)*1024*1024}}),placeholder:"512",step:"1",style:{width:"100%",padding:a.spacing.sm,backgroundColor:a.colors.background,border:`1px solid ${a.colors.border}`,borderRadius:a.borderRadius.sm,color:a.colors.text,fontSize:a.typography.fontSize.sm}})]}),t.jsxs("div",{children:[t.jsx("label",{style:{display:"block",fontSize:a.typography.fontSize.xs,color:a.colors.textSecondary,marginBottom:a.spacing.xs},children:"Draw Calls Maximum"}),t.jsx("input",{type:"number",value:d.gpu?.drawCalls?.max||"",onChange:g=>h({...d,gpu:{...d.gpu,drawCalls:{max:parseInt(g.target.value)||0}}}),placeholder:"100",style:{width:"100%",padding:a.spacing.sm,backgroundColor:a.colors.background,border:`1px solid ${a.colors.border}`,borderRadius:a.borderRadius.sm,color:a.colors.text,fontSize:a.typography.fontSize.sm}})]}),t.jsxs("div",{children:[t.jsx("label",{style:{display:"block",fontSize:a.typography.fontSize.xs,color:a.colors.textSecondary,marginBottom:a.spacing.xs},children:"Triangles Maximum"}),t.jsx("input",{type:"number",value:d.gpu?.triangles?.max||"",onChange:g=>h({...d,gpu:{...d.gpu,triangles:{max:parseInt(g.target.value)||0}}}),placeholder:"100000",style:{width:"100%",padding:a.spacing.sm,backgroundColor:a.colors.background,border:`1px solid ${a.colors.border}`,borderRadius:a.borderRadius.sm,color:a.colors.text,fontSize:a.typography.fontSize.sm}})]})]}),t.jsxs("div",{style:{display:"flex",gap:a.spacing.sm},children:[t.jsx("button",{onClick:p,style:{padding:`${a.spacing.sm} ${a.spacing.md}`,backgroundColor:a.colors.success,color:a.colors.background,border:"none",borderRadius:a.borderRadius.sm,cursor:"pointer",fontSize:a.typography.fontSize.sm,fontWeight:600},children:"Save"}),t.jsx("button",{onClick:S,style:{padding:`${a.spacing.sm} ${a.spacing.md}`,backgroundColor:"transparent",color:a.colors.textSecondary,border:`1px solid ${a.colors.border}`,borderRadius:a.borderRadius.sm,cursor:"pointer",fontSize:a.typography.fontSize.sm,fontWeight:600},children:"Cancel"})]})]}):t.jsxs("div",{style:{display:"flex",gap:a.spacing.sm,flexWrap:"wrap"},children:[t.jsx("button",{onClick:()=>y(!0),style:{padding:`${a.spacing.sm} ${a.spacing.md}`,backgroundColor:a.colors.primary,color:a.colors.background,border:"none",borderRadius:a.borderRadius.sm,cursor:"pointer",fontSize:a.typography.fontSize.sm,fontWeight:600,transition:a.transitions.fast},onMouseEnter:g=>{g.currentTarget.style.backgroundColor=a.colors.primaryHover},onMouseLeave:g=>{g.currentTarget.style.backgroundColor=a.colors.primary},children:n?"Edit Budget":"Set Budget"}),!n&&t.jsx("button",{onClick:u,style:{padding:`${a.spacing.sm} ${a.spacing.md}`,backgroundColor:"transparent",color:a.colors.primary,border:`1px solid ${a.colors.primary}`,borderRadius:a.borderRadius.sm,cursor:"pointer",fontSize:a.typography.fontSize.sm,fontWeight:600,transition:a.transitions.fast},onMouseEnter:g=>{g.currentTarget.style.backgroundColor=`${a.colors.primary}20`},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="transparent"},children:"Use Recommended"}),n&&t.jsx("button",{onClick:()=>{window.confirm("Are you sure you want to delete the current budget?")&&o()},style:{padding:`${a.spacing.sm} ${a.spacing.md}`,backgroundColor:"transparent",color:a.colors.error,border:`1px solid ${a.colors.error}`,borderRadius:a.borderRadius.sm,cursor:"pointer",fontSize:a.typography.fontSize.sm,fontWeight:600,transition:a.transitions.fast},onMouseEnter:g=>{g.currentTarget.style.backgroundColor=`${a.colors.error}20`},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="transparent"},children:"Delete Budget"})]})]}),e.length>0&&t.jsxs("div",{style:{backgroundColor:a.colors.surface,borderRadius:a.borderRadius.md,padding:a.spacing.md,border:`1px solid ${a.colors.border}`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:a.spacing.md},children:[t.jsxs("div",{style:{fontSize:a.typography.fontSize.sm,fontWeight:600,color:a.colors.text},children:["Recent Violations (",e.length,")"]}),t.jsx("button",{onClick:s,style:{padding:`${a.spacing.xs} ${a.spacing.sm}`,backgroundColor:"transparent",color:a.colors.textSecondary,border:"none",cursor:"pointer",fontSize:a.typography.fontSize.xs},children:"Clear"})]}),t.jsx("div",{style:{maxHeight:"200px",overflowY:"auto",fontSize:a.typography.fontSize.xs,fontFamily:a.typography.fontFamilyMono},children:e.slice(-10).reverse().map(g=>t.jsxs("div",{style:{padding:a.spacing.sm,borderBottom:`1px solid ${a.colors.border}`,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{color:g.severity==="error"?a.colors.error:a.colors.warning,fontWeight:600},children:g.metric}),t.jsx("div",{style:{color:a.colors.textSecondary,marginTop:a.spacing.xs},children:g.message})]}),t.jsx(E,{severity:g.severity})]},g.id))})]})]})};class Ae{componentStats=new Map;recentRenders=[];totalRenders=0;maxRecentRenders=100;slowThreshold=16;frequentThreshold=10;onRenderCallback=(e,r,s,o,i,c)=>{const l=this.getComponentName(e),m=performance.now(),a={id:e,name:l,phase:r,actualDuration:s,baseDuration:o,startTime:i,commitTime:c,timestamp:m};this.recentRenders.push(a),this.recentRenders.length>this.maxRecentRenders&&this.recentRenders.shift(),this.updateComponentStats(l,a),W.onReactRender(s),this.totalRenders++};getComponentName(e){return e.split(":")[0]||e}updateComponentStats(e,r){let s=this.componentStats.get(e);s||(s={name:e,renderCount:0,totalDuration:0,averageDuration:0,maxDuration:0,minDuration:1/0,lastRenderTime:0,phases:{mount:0,update:0}},this.componentStats.set(e,s)),s.renderCount++,s.totalDuration+=r.actualDuration,s.averageDuration=s.totalDuration/s.renderCount,s.maxDuration=Math.max(s.maxDuration,r.actualDuration),s.minDuration=Math.min(s.minDuration,r.actualDuration),s.lastRenderTime=r.timestamp,r.phase==="mount"?s.phases.mount++:s.phases.update++}getPerformanceData(){const e=new Map(this.componentStats),r=Array.from(e.values()).filter(c=>c.averageDuration>this.slowThreshold).sort((c,l)=>l.averageDuration-c.averageDuration),s=performance.now(),o=1e3,i=Array.from(e.values()).filter(c=>s-c.lastRenderTime>o?!1:c.renderCount/(o/1e3)>this.frequentThreshold).sort((c,l)=>l.renderCount-c.renderCount);return{components:e,recentRenders:[...this.recentRenders],totalRenders:this.totalRenders,slowComponents:r,frequentRenders:i,timestamp:performance.now()}}getComponentStats(e){return this.componentStats.get(e)||null}getSlowComponents(){return this.getPerformanceData().slowComponents}getFrequentRenders(){return this.getPerformanceData().frequentRenders}reset(){this.componentStats.clear(),this.recentRenders=[],this.totalRenders=0}}const Ee=new Ae;function He(){const[n,e]=f.useState(null);return f.useEffect(()=>{const r=()=>{if(!P.getPaused()){const i=Ee.getPerformanceData();e(i)}};r();const s=setInterval(r,500),o=P.subscribe(i=>{i||r()});return()=>{clearInterval(s),o()}},[]),n}const We=()=>{const n=He(),e=$,r=o=>o<.1?`${v(o*1e3,0)} μs`:o<1?`${v(o,2)} ms`:`${v(o,2)} ms`,s=f.useMemo(()=>n?Array.from(n.components.values()).sort((o,i)=>i.totalDuration-o.totalDuration):[],[n]);return n?t.jsxs("div",{style:{padding:e.spacing.md},children:[t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,marginBottom:e.spacing.lg,border:`1px solid ${e.colors.border}`},children:[t.jsx("div",{style:{fontSize:e.typography.fontSize.sm,fontWeight:600,color:e.colors.text,marginBottom:e.spacing.sm},children:"Overview"}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))",gap:e.spacing.sm},children:[t.jsx(b,{label:"Total Renders",value:n.totalRenders.toLocaleString()}),t.jsx(b,{label:"Components",value:n.components.size.toLocaleString()}),t.jsx(b,{label:"Slow Components",value:n.slowComponents.length.toLocaleString(),status:n.slowComponents.length>0?"warning":"good"}),t.jsx(b,{label:"Frequent Renders",value:n.frequentRenders.length.toLocaleString(),status:n.frequentRenders.length>0?"warning":"good"})]})]}),n.slowComponents.length>0&&t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,marginBottom:e.spacing.lg,border:`1px solid ${e.colors.warning}40`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:e.spacing.sm,marginBottom:e.spacing.sm},children:[t.jsx(E,{severity:"warning",count:n.slowComponents.length}),t.jsx("div",{style:{fontSize:e.typography.fontSize.sm,fontWeight:600,color:e.colors.text},children:"Slow Components (avg > 16ms)"})]}),t.jsx("div",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textSecondary,fontFamily:e.typography.fontFamilyMono},children:n.slowComponents.slice(0,5).map(o=>t.jsxs("div",{style:{marginBottom:e.spacing.xs},children:[o.name,": ",r(o.averageDuration)," avg (",o.renderCount," renders)"]},o.name))})]}),n.frequentRenders.length>0&&t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,marginBottom:e.spacing.lg,border:`1px solid ${e.colors.warning}40`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:e.spacing.sm,marginBottom:e.spacing.sm},children:[t.jsx(E,{severity:"warning",count:n.frequentRenders.length}),t.jsx("div",{style:{fontSize:e.typography.fontSize.sm,fontWeight:600,color:e.colors.text},children:"Frequent Renders (> 10 renders/sec)"})]}),t.jsx("div",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textSecondary,fontFamily:e.typography.fontFamilyMono},children:n.frequentRenders.slice(0,5).map(o=>t.jsxs("div",{style:{marginBottom:e.spacing.xs},children:[o.name,": ",o.renderCount," renders"]},o.name))})]}),t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,border:`1px solid ${e.colors.border}`},children:[t.jsxs("div",{style:{fontSize:e.typography.fontSize.sm,fontWeight:600,color:e.colors.text,marginBottom:e.spacing.sm},children:["Components (",s.length,")"]}),t.jsx("div",{style:{maxHeight:"400px",overflowY:"auto"},children:s.length===0?t.jsx("div",{style:{padding:e.spacing.md,textAlign:"center",color:e.colors.textSecondary,fontSize:e.typography.fontSize.sm},children:"No components profiled yet"}):t.jsx(Ie,{components:s,formatTime:r})})]})]}):t.jsx("div",{style:{padding:e.spacing.lg,textAlign:"center",color:e.colors.textSecondary,fontSize:e.typography.fontSize.sm},children:"Aucune donnée React disponible. Enveloppez vos composants avec <ReactProfiler> pour commencer le monitoring."})},Ie=({components:n,formatTime:e})=>{const r=$;return t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:r.typography.fontSize.xs,fontFamily:r.typography.fontFamilyMono},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{borderBottom:`1px solid ${r.colors.border}`},children:[t.jsx("th",{style:{textAlign:"left",padding:r.spacing.sm,color:r.colors.textSecondary,fontWeight:600},children:"Component"}),t.jsx("th",{style:{textAlign:"right",padding:r.spacing.sm,color:r.colors.textSecondary,fontWeight:600},children:"Renders"}),t.jsx("th",{style:{textAlign:"right",padding:r.spacing.sm,color:r.colors.textSecondary,fontWeight:600},children:"Avg Time"}),t.jsx("th",{style:{textAlign:"right",padding:r.spacing.sm,color:r.colors.textSecondary,fontWeight:600},children:"Max Time"}),t.jsx("th",{style:{textAlign:"right",padding:r.spacing.sm,color:r.colors.textSecondary,fontWeight:600},children:"Total Time"})]})}),t.jsx("tbody",{children:n.map(s=>{const o=s.averageDuration>16,i=s.renderCount>10;return t.jsxs("tr",{style:{borderBottom:`1px solid ${r.colors.border}`,backgroundColor:o||i?`${r.colors.warning}10`:"transparent"},children:[t.jsx("td",{style:{padding:r.spacing.sm,color:r.colors.text,fontWeight:o||i?600:400},children:s.name}),t.jsx("td",{style:{textAlign:"right",padding:r.spacing.sm,color:r.colors.textSecondary},children:s.renderCount.toLocaleString()}),t.jsx("td",{style:{textAlign:"right",padding:r.spacing.sm,color:o?r.colors.warning:r.colors.textSecondary,fontWeight:o?600:400},children:e(s.averageDuration)}),t.jsx("td",{style:{textAlign:"right",padding:r.spacing.sm,color:r.colors.textSecondary},children:e(s.maxDuration)}),t.jsx("td",{style:{textAlign:"right",padding:r.spacing.sm,color:r.colors.textSecondary},children:e(s.totalDuration)})]},s.name)})})]})};class Ge{functionCalls=new Map;callHistory=[];maxHistorySize=1e3;hotPathThreshold=5;frequencyThreshold=10;recordCall(e,r,s){const o=performance.now();let i=this.functionCalls.get(e);i||(i={name:e,duration:0,timestamp:o,callCount:0,averageDuration:0,maxDuration:0,stack:s||[]},this.functionCalls.set(e,i)),i.callCount++,i.duration+=r,i.averageDuration=i.duration/i.callCount,i.maxDuration=Math.max(i.maxDuration,r),i.timestamp=o,this.callHistory.push({name:e,duration:r,timestamp:o}),this.callHistory.length>this.maxHistorySize&&this.callHistory.shift()}analyze(e){const r=performance.now(),s=5e3,o=r-s,i=this.callHistory.filter(d=>d.timestamp>=o),c=new Map;i.forEach(d=>{const h=c.get(d.name)||0;c.set(d.name,h+1)});const l=new Map;c.forEach((d,h)=>{l.set(h,d/s*1e3)});const m=[],a=[],j=[];this.functionCalls.forEach((d,h)=>{const T=l.get(h)||0,C=d.averageDuration>this.hotPathThreshold,p=T>this.frequencyThreshold;if(C||p){const S=d.averageDuration>16?"high":d.averageDuration>8?"medium":"low",R=[];C&&R.push(`Optimize ${h} - average duration: ${d.averageDuration.toFixed(2)}ms`),p&&R.push(`Reduce calls to ${h} - ${T.toFixed(1)} calls/sec`),d.maxDuration>d.averageDuration*2&&R.push(`Investigate performance spikes in ${h} - max: ${d.maxDuration.toFixed(2)}ms`);const g={id:`hotpath-${h}-${Date.now()}`,path:[h],totalDuration:d.duration,averageDuration:d.averageDuration,callCount:d.callCount,frequency:T,impact:S,recommendations:R};m.push(g),C&&j.push(g)}a.push(d)}),a.sort((d,h)=>h.duration-d.duration);const y=[];return j.length>0&&y.push(`Found ${j.length} performance bottlenecks`),m.length>5&&y.push("Consider optimizing multiple hot paths simultaneously"),e&&e.forEach(d=>{d.avg>this.hotPathThreshold&&y.push(`Hook "${d.name}" takes ${d.avg.toFixed(2)}ms on average`)}),{hotPaths:m.sort((d,h)=>h.averageDuration-d.averageDuration),topFunctions:a.slice(0,10),bottlenecks:j.sort((d,h)=>h.averageDuration-d.averageDuration),recommendations:y,timestamp:r}}detectCallChain(e){const r=new Map;this.callHistory.forEach(o=>{const i=o.name;let c=r.get(i);c||(c={path:[o.name],duration:0,count:0},r.set(i,c)),c.duration+=o.duration,c.count++});const s=[];return r.forEach((o,i)=>{const c=o.duration/o.count;c>this.hotPathThreshold&&s.push({id:`chain-${i}-${Date.now()}`,path:o.path,totalDuration:o.duration,averageDuration:c,callCount:o.count,frequency:o.count/5,impact:c>16?"high":c>8?"medium":"low",recommendations:[`Optimize call chain: ${o.path.join(" -> ")}`]})}),s}reset(){this.functionCalls.clear(),this.callHistory=[]}getTopFunctions(e=10){return Array.from(this.functionCalls.values()).sort((r,s)=>s.duration-r.duration).slice(0,e)}}const ae=new Ge,Ve=Object.freeze(Object.defineProperty({__proto__:null,hotPathDetector:ae},Symbol.toStringTag,{value:"Module"}));function _e(){const[n,e]=f.useState(null),r=q();return f.useEffect(()=>{const s=()=>{if(!P.getPaused()){const c=ae.analyze(r?.entries);e(c)}};s();const o=setInterval(s,2e3),i=P.subscribe(c=>{c||s()});return()=>{clearInterval(o),i()}},[r]),n}const Oe=()=>{const n=_e(),e=$,r=o=>o<.1?`${v(o*1e3,0)} μs`:o<1?`${v(o,2)} ms`:`${v(o,2)} ms`,s={high:e.colors.error,medium:e.colors.warning,low:e.colors.info};return n?t.jsxs("div",{style:{padding:e.spacing.md},children:[t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,marginBottom:e.spacing.lg,border:`1px solid ${e.colors.border}`},children:[t.jsx("div",{style:{fontSize:e.typography.fontSize.sm,fontWeight:600,color:e.colors.text,marginBottom:e.spacing.sm},children:"Overview"}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))",gap:e.spacing.sm},children:[t.jsx(b,{label:"Hot Paths",value:n.hotPaths.length.toLocaleString(),status:n.hotPaths.length>0?"warning":"good"}),t.jsx(b,{label:"Bottlenecks",value:n.bottlenecks.length.toLocaleString(),status:n.bottlenecks.length>0?"error":"good"}),t.jsx(b,{label:"Top Functions",value:n.topFunctions.length.toLocaleString()})]})]}),n.recommendations.length>0&&t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,marginBottom:e.spacing.lg,border:`1px solid ${e.colors.warning}40`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:e.spacing.sm,marginBottom:e.spacing.sm},children:[t.jsx(E,{severity:"warning"}),t.jsx("div",{style:{fontSize:e.typography.fontSize.sm,fontWeight:600,color:e.colors.text},children:"Recommendations"})]}),t.jsx("div",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textSecondary,fontFamily:e.typography.fontFamilyMono},children:n.recommendations.map((o,i)=>t.jsxs("div",{style:{marginBottom:e.spacing.xs},children:["• ",o]},i))})]}),n.bottlenecks.length>0&&t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,marginBottom:e.spacing.lg,border:`1px solid ${e.colors.error}40`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:e.spacing.sm,marginBottom:e.spacing.sm},children:[t.jsx(E,{severity:"error",count:n.bottlenecks.length}),t.jsx("div",{style:{fontSize:e.typography.fontSize.sm,fontWeight:600,color:e.colors.text},children:"Performance Bottlenecks"})]}),t.jsx("div",{style:{maxHeight:"300px",overflowY:"auto"},children:n.bottlenecks.map(o=>t.jsxs("div",{style:{padding:e.spacing.sm,borderBottom:`1px solid ${e.colors.border}`,backgroundColor:`${s[o.impact]}10`},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:e.spacing.xs},children:[t.jsx("div",{style:{fontSize:e.typography.fontSize.sm,fontWeight:600,color:s[o.impact],fontFamily:e.typography.fontFamilyMono},children:o.path.join(" -> ")}),t.jsxs("div",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textSecondary},children:[r(o.averageDuration)," avg"]})]}),t.jsxs("div",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textSecondary,marginBottom:e.spacing.xs},children:[o.callCount.toLocaleString()," calls • ",o.frequency.toFixed(1)," calls/sec"]}),o.recommendations.length>0&&t.jsx("div",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textTertiary,fontStyle:"italic"},children:o.recommendations[0]})]},o.id))})]}),n.hotPaths.length>0&&t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,marginBottom:e.spacing.lg,border:`1px solid ${e.colors.border}`},children:[t.jsxs("div",{style:{fontSize:e.typography.fontSize.sm,fontWeight:600,color:e.colors.text,marginBottom:e.spacing.sm},children:["Hot Paths (",n.hotPaths.length,")"]}),t.jsx("div",{style:{maxHeight:"400px",overflowY:"auto"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:e.typography.fontSize.xs,fontFamily:e.typography.fontFamilyMono},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{borderBottom:`1px solid ${e.colors.border}`},children:[t.jsx("th",{style:{textAlign:"left",padding:e.spacing.sm,color:e.colors.textSecondary,fontWeight:600},children:"Path"}),t.jsx("th",{style:{textAlign:"right",padding:e.spacing.sm,color:e.colors.textSecondary,fontWeight:600},children:"Avg Time"}),t.jsx("th",{style:{textAlign:"right",padding:e.spacing.sm,color:e.colors.textSecondary,fontWeight:600},children:"Calls"}),t.jsx("th",{style:{textAlign:"right",padding:e.spacing.sm,color:e.colors.textSecondary,fontWeight:600},children:"Freq/sec"}),t.jsx("th",{style:{textAlign:"center",padding:e.spacing.sm,color:e.colors.textSecondary,fontWeight:600},children:"Impact"})]})}),t.jsx("tbody",{children:n.hotPaths.map(o=>t.jsxs("tr",{style:{borderBottom:`1px solid ${e.colors.border}`,backgroundColor:`${s[o.impact]}10`},children:[t.jsx("td",{style:{padding:e.spacing.sm,color:e.colors.text},children:o.path.join(" -> ")}),t.jsx("td",{style:{textAlign:"right",padding:e.spacing.sm,color:s[o.impact],fontWeight:600},children:r(o.averageDuration)}),t.jsx("td",{style:{textAlign:"right",padding:e.spacing.sm,color:e.colors.textSecondary},children:o.callCount.toLocaleString()}),t.jsx("td",{style:{textAlign:"right",padding:e.spacing.sm,color:e.colors.textSecondary},children:v(o.frequency,1)}),t.jsx("td",{style:{textAlign:"center",padding:e.spacing.sm},children:t.jsx(E,{severity:o.impact==="high"?"error":o.impact==="medium"?"warning":"info"})})]},o.id))})]})})]}),n.topFunctions.length>0&&t.jsxs("div",{style:{backgroundColor:e.colors.surface,borderRadius:e.borderRadius.md,padding:e.spacing.md,border:`1px solid ${e.colors.border}`},children:[t.jsx("div",{style:{fontSize:e.typography.fontSize.sm,fontWeight:600,color:e.colors.text,marginBottom:e.spacing.sm},children:"Top Functions (by total duration)"}),t.jsx("div",{style:{maxHeight:"300px",overflowY:"auto",fontSize:e.typography.fontSize.xs,fontFamily:e.typography.fontFamilyMono,color:e.colors.textSecondary},children:n.topFunctions.map((o,i)=>t.jsxs("div",{style:{padding:e.spacing.sm,borderBottom:`1px solid ${e.colors.border}`,display:"flex",justifyContent:"space-between"},children:[t.jsxs("span",{children:[i+1,". ",o.name]}),t.jsxs("span",{children:[r(o.averageDuration)," avg (",o.callCount.toLocaleString()," calls)"]})]},o.name))})]})]}):t.jsx("div",{style:{padding:e.spacing.lg,textAlign:"center",color:e.colors.textSecondary,fontSize:e.typography.fontSize.sm},children:"Aucune analyse de hot path disponible. Les hot paths sont détectés automatiquement à partir des données du profiler."})},qe=({position:n="top-right",defaultTab:e="frames",collapsed:r=!1})=>{const[s,o]=f.useState(!1),[i,c]=f.useState(e),[l,m]=f.useState(r),[a,j]=f.useState(P.getPaused()),[y,d]=f.useState(!1),[h,T]=f.useState(null),C=f.useRef(null),p=f.useRef(null),u=$,S="r3f-profiler-state";f.useEffect(()=>{const x=localStorage.getItem(S);if(x)try{const k=JSON.parse(x);k.position&&typeof k.position.x=="number"&&typeof k.position.y=="number"&&T({x:k.position.x,y:k.position.y}),typeof k.collapsed=="boolean"&&m(k.collapsed),typeof k.activeTab=="string"&&k.activeTab&&c(k.activeTab)}catch(k){console.warn("Failed to load saved profiler state:",k)}const w=P.subscribe(k=>{j(k)});return()=>{w()}},[]);const R=f.useCallback(x=>{try{const w=localStorage.getItem(S),A={...w?JSON.parse(w):{},...x};localStorage.setItem(S,JSON.stringify(A))}catch(w){console.warn("Failed to save profiler state:",w)}},[]),g=f.useCallback((x,w)=>{R({position:{x,y:w}})},[R]),z=f.useCallback(x=>{if(!x.target.closest("button")&&(d(!0),p.current)){const w=p.current.getBoundingClientRect();C.current={x:x.clientX-w.left,y:x.clientY-w.top}}},[]);if(f.useEffect(()=>{if(!y)return;const x=k=>{if(!C.current||!p.current)return;const Z=p.current.getBoundingClientRect(),ie=window.innerWidth,le=window.innerHeight;let U=k.clientX-C.current.x,N=k.clientY-C.current.y;U=Math.max(0,Math.min(U,ie-Z.width)),N=Math.max(0,Math.min(N,le-Z.height));const Q={x:U,y:N};T(Q),R({position:Q})},w=()=>{d(!1),C.current=null};return window.addEventListener("mousemove",x),window.addEventListener("mouseup",w),()=>{window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",w)}},[y,g]),f.useEffect(()=>{const x=()=>J();o(x());const w=()=>{o(x())};return window.addEventListener("storage",w),()=>{window.removeEventListener("storage",w)}},[]),!s)return null;const M=[{id:"frames",label:"Frames"},{id:"gpu",label:"GPU"},{id:"scene",label:"Scene"},{id:"memory",label:"Memory"},{id:"frame-time",label:"Frame Time"},{id:"budget",label:"Budget"},{id:"react",label:"React"},{id:"hot-path",label:"Hot Path"}],V=h?{left:`${h.x}px`,top:`${h.y}px`,right:"auto",bottom:"auto"}:{"top-left":{top:u.spacing.md,left:u.spacing.md,right:"auto",bottom:"auto"},"top-right":{top:u.spacing.md,right:u.spacing.md,left:"auto",bottom:"auto"},"bottom-left":{bottom:u.spacing.md,left:u.spacing.md,right:"auto",top:"auto"},"bottom-right":{bottom:u.spacing.md,right:u.spacing.md,left:"auto",top:"auto"}}[n];return t.jsxs("div",{ref:p,style:{position:"fixed",...V,width:l?"auto":"600px",maxWidth:l?"auto":"90vw",maxHeight:"80vh",backgroundColor:u.colors.background,backdropFilter:"blur(10px)",borderRadius:u.borderRadius.lg,boxShadow:u.shadows.xl,border:`1px solid ${u.colors.border}`,zIndex:u.zIndex.base,display:"flex",flexDirection:"column",overflow:"hidden",transition:y?"none":u.transitions.normal,userSelect:y?"none":"auto"},children:[t.jsxs("div",{onMouseDown:z,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:u.spacing.md,borderBottom:`1px solid ${u.colors.border}`,backgroundColor:u.colors.surface,cursor:y?"grabbing":"grab",userSelect:"none"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:u.spacing.sm,flex:1},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:u.spacing.xs,color:u.colors.textTertiary,fontSize:u.typography.fontSize.xs},children:t.jsx("span",{children:"⋮⋮"})}),t.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:u.colors.success,boxShadow:`0 0 8px ${u.colors.success}`}}),t.jsx("h2",{style:{margin:0,fontSize:u.typography.fontSize.lg,fontWeight:600,color:u.colors.text},children:"Performance Monitor"})]}),t.jsxs("div",{style:{display:"flex",gap:u.spacing.xs,alignItems:"center"},children:[a&&t.jsx("div",{style:{fontSize:u.typography.fontSize.xs,color:u.colors.warning,fontFamily:u.typography.fontFamilyMono,padding:`0 ${u.spacing.xs}`},children:"PAUSED"}),t.jsx("button",{onClick:()=>{P.toggle()},style:{background:"transparent",border:"none",color:a?u.colors.warning:u.colors.textSecondary,cursor:"pointer",padding:u.spacing.xs,borderRadius:u.borderRadius.sm,transition:u.transitions.fast,display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:x=>{x.currentTarget.style.backgroundColor=u.colors.surfaceElevated,x.currentTarget.style.color=a?u.colors.warning:u.colors.text},onMouseLeave:x=>{x.currentTarget.style.backgroundColor="transparent",x.currentTarget.style.color=a?u.colors.warning:u.colors.textSecondary},title:a?"Resume":"Pause",children:a?"▶":"⏸"}),t.jsx("button",{onClick:async()=>{const{profiler:x}=await Promise.resolve().then(()=>de);await x.copyReportToClipboard(),alert("📊 Performance report copied to clipboard!")},style:{background:"transparent",border:"none",color:u.colors.textSecondary,cursor:"pointer",padding:u.spacing.xs,borderRadius:u.borderRadius.sm,transition:u.transitions.fast,display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:x=>{x.currentTarget.style.backgroundColor=u.colors.surfaceElevated,x.currentTarget.style.color=u.colors.success},onMouseLeave:x=>{x.currentTarget.style.backgroundColor="transparent",x.currentTarget.style.color=u.colors.textSecondary},title:"Copy Performance Report (for AI analysis)",children:"📊"}),t.jsx("button",{onClick:()=>{const x=!l;m(x),R({collapsed:x})},style:{background:"transparent",border:"none",color:u.colors.textSecondary,cursor:"pointer",padding:u.spacing.xs,borderRadius:u.borderRadius.sm,transition:u.transitions.fast,display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:x=>{x.currentTarget.style.backgroundColor=u.colors.surfaceElevated,x.currentTarget.style.color=u.colors.text},onMouseLeave:x=>{x.currentTarget.style.backgroundColor="transparent",x.currentTarget.style.color=u.colors.textSecondary},title:l?"Expand":"Collapse",children:l?"◀":"▼"})]})]}),!l&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{padding:`0 ${u.spacing.md}`,backgroundColor:u.colors.surface},children:t.jsx(ve,{tabs:M,activeTab:i,onTabChange:x=>{c(x),R({activeTab:x})}})}),t.jsxs("div",{style:{flex:1,overflow:"auto",backgroundColor:u.colors.background},children:[i==="frames"&&t.jsx(Ce,{}),i==="gpu"&&t.jsx(ze,{}),i==="scene"&&t.jsx(Me,{}),i==="memory"&&t.jsx(Pe,{}),i==="frame-time"&&t.jsx(ke,{}),i==="budget"&&t.jsx(Le,{}),i==="react"&&t.jsx(We,{}),i==="hot-path"&&t.jsx(Oe,{})]})]})]})};exports.PerformanceMonitor=qe;exports.ProfilerDataCollector=ue;exports.R3FStatsCollector=xe;exports.isProfilerEnabled=J;exports.profile=re;exports.profiler=D;exports.reportMetric=se;
2
+ //# sourceMappingURL=index-D_LaF0YP.cjs.map