Files

19 lines
52 KiB
JavaScript

import Ne,{useState,useRef,useCallback,useEffect}from'react';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {WebGL3DEngine}from'@z-os/core';var Ae=0;function X(){return `mesh-${Date.now().toString(36)}-${(++Ae).toString(36)}`}function q(){return `geo-${Date.now().toString(36)}-${(++Ae).toString(36)}`}var Ze={r:180,g:180,b:180,a:1};function Q(h="Material"){return {id:X(),name:h,color:Ze,ambient:.3,diffuse:.7,specular:.5,shininess:32,opacity:1,wireframe:false,doubleSided:false}}function Se(h={}){let{width:e=1,height:t=1,depth:i=1}=h,n=e/2,s=t/2,r=i/2,c=new Float32Array([-n,-s,r,n,-s,r,n,s,r,-n,s,r,n,-s,-r,-n,-s,-r,-n,s,-r,n,s,-r,-n,s,r,n,s,r,n,s,-r,-n,s,-r,-n,-s,-r,n,-s,-r,n,-s,r,-n,-s,r,n,-s,r,n,-s,-r,n,s,-r,n,s,r,-n,-s,-r,-n,-s,r,-n,s,r,-n,s,-r]),o=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0]),a=new Float32Array([0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1]),d=new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]),g=[],u=[];for(let x=0;x<6;x++){let p=x*4;g.push({a:p,b:p+1}),g.push({a:p+1,b:p+2}),g.push({a:p+2,b:p+3}),g.push({a:p+3,b:p});let m={x:o[p*3],y:o[p*3+1],z:o[p*3+2]};u.push({vertices:[p,p+1,p+2,p+3],normal:m});}let l={id:q(),vertices:c,normals:o,uvs:a,indices:d,vertexCount:24,edges:g,faces:u};return {id:X(),name:"Cube",geometry:l,material:Q(),transform:{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},visible:true,locked:false,parentId:null}}function Ce(h={}){let{radius:e=.5,segments:t=16,rings:i=12}=h,n=[],s=[],r=[],c=[];for(let u=0;u<=i;u++){let l=u/i,x=l*Math.PI;for(let p=0;p<=t;p++){let m=p/t,f=m*Math.PI*2,v=-e*Math.cos(f)*Math.sin(x),y=e*Math.cos(x),z=e*Math.sin(f)*Math.sin(x);n.push(v,y,z),s.push(v/e,y/e,z/e),r.push(m,1-l);}}for(let u=0;u<i;u++)for(let l=0;l<t;l++){let x=l+(t+1)*u,p=l+(t+1)*(u+1),m=l+1+(t+1)*(u+1),f=l+1+(t+1)*u;u!==0&&c.push(x,p,f),u!==i-1&&c.push(p,m,f);}let o=[],a=new Set;for(let u=0;u<c.length;u+=3){let l=[c[u],c[u+1],c[u+2]];for(let x=0;x<3;x++){let p=Math.min(l[x],l[(x+1)%3]),m=Math.max(l[x],l[(x+1)%3]),f=`${p}-${m}`;a.has(f)||(a.add(f),o.push({a:p,b:m}));}}let d=[];for(let u=0;u<c.length;u+=3){let l=[c[u],c[u+1],c[u+2]],x={x:s[c[u]*3],y:s[c[u]*3+1],z:s[c[u]*3+2]};d.push({vertices:l,normal:x});}let g={id:q(),vertices:new Float32Array(n),normals:new Float32Array(s),uvs:new Float32Array(r),indices:new Uint16Array(c),vertexCount:n.length/3,edges:o,faces:d};return {id:X(),name:"Sphere",geometry:g,material:Q(),transform:{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},visible:true,locked:false,parentId:null}}function Ee(h={}){let{radiusTop:e=.5,radiusBottom:t=.5,height:i=1,segments:n=32}=h,s=[],r=[],c=[],o=[],a=i/2;for(let m=0;m<=n;m++){let f=m/n,v=f*Math.PI*2,y=Math.cos(v),z=Math.sin(v);s.push(y*e,a,z*e),r.push(y,0,z),c.push(f,0),s.push(y*t,-a,z*t),r.push(y,0,z),c.push(f,1);}for(let m=0;m<n;m++){let f=m*2,v=m*2+1,y=(m+1)*2+1,z=(m+1)*2;o.push(f,v,z,v,y,z);}let d=s.length/3;s.push(0,a,0),r.push(0,1,0),c.push(.5,.5);for(let m=0;m<=n;m++){let f=m/n*Math.PI*2;s.push(Math.cos(f)*e,a,Math.sin(f)*e),r.push(0,1,0),c.push(Math.cos(f)*.5+.5,Math.sin(f)*.5+.5);}for(let m=0;m<n;m++)o.push(d,d+m+1,d+m+2);let g=s.length/3;s.push(0,-a,0),r.push(0,-1,0),c.push(.5,.5);for(let m=0;m<=n;m++){let f=m/n*Math.PI*2;s.push(Math.cos(f)*t,-a,Math.sin(f)*t),r.push(0,-1,0),c.push(Math.cos(f)*.5+.5,Math.sin(f)*.5+.5);}for(let m=0;m<n;m++)o.push(g,g+m+2,g+m+1);let u=[],l=new Set;for(let m=0;m<o.length;m+=3){let f=[o[m],o[m+1],o[m+2]];for(let v=0;v<3;v++){let y=Math.min(f[v],f[(v+1)%3]),z=Math.max(f[v],f[(v+1)%3]),A=`${y}-${z}`;l.has(A)||(l.add(A),u.push({a:y,b:z}));}}let x=[];for(let m=0;m<o.length;m+=3){let f=[o[m],o[m+1],o[m+2]],v={x:r[o[m]*3],y:r[o[m]*3+1],z:r[o[m]*3+2]};x.push({vertices:f,normal:v});}let p={id:q(),vertices:new Float32Array(s),normals:new Float32Array(r),uvs:new Float32Array(c),indices:new Uint16Array(o),vertexCount:s.length/3,edges:u,faces:x};return {id:X(),name:"Cylinder",geometry:p,material:Q(),transform:{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},visible:true,locked:false,parentId:null}}function qe(h={}){let{width:e=2,height:t=2,widthSegments:i=1,heightSegments:n=1}=h,s=e/2,r=t/2,c=i,o=n,a=[],d=[],g=[],u=[];for(let f=0;f<=o;f++){let v=f/o;for(let y=0;y<=c;y++){let z=y/c;a.push(z*e-s,0,v*t-r),d.push(0,1,0),g.push(z,1-v);}}for(let f=0;f<o;f++)for(let v=0;v<c;v++){let y=v+(c+1)*f,z=v+(c+1)*(f+1),A=v+1+(c+1)*(f+1),E=v+1+(c+1)*f;u.push(y,z,E,z,A,E);}let l=[],x=new Set;for(let f=0;f<u.length;f+=3){let v=[u[f],u[f+1],u[f+2]];for(let y=0;y<3;y++){let z=Math.min(v[y],v[(y+1)%3]),A=Math.max(v[y],v[(y+1)%3]),E=`${z}-${A}`;x.has(E)||(x.add(E),l.push({a:z,b:A}));}}let p=[];for(let f=0;f<u.length;f+=3){let v=[u[f],u[f+1],u[f+2]];p.push({vertices:v,normal:{x:0,y:1,z:0}});}let m={id:q(),vertices:new Float32Array(a),normals:new Float32Array(d),uvs:new Float32Array(g),indices:new Uint16Array(u),vertexCount:a.length/3,edges:l,faces:p};return {id:X(),name:"Plane",geometry:m,material:Q(),transform:{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},visible:true,locked:false,parentId:null}}function Qe(h={}){let{radius:e=.5,tube:t=.2,radialSegments:i=16,tubularSegments:n=32}=h,s=[],r=[],c=[],o=[];for(let l=0;l<=i;l++)for(let x=0;x<=n;x++){let p=x/n*Math.PI*2,m=l/i*Math.PI*2,f=(e+t*Math.cos(m))*Math.cos(p),v=t*Math.sin(m),y=(e+t*Math.cos(m))*Math.sin(p);s.push(f,v,y);let z=e*Math.cos(p),A=e*Math.sin(p),E=f-z,k=v,I=y-A,W=Math.sqrt(E*E+k*k+I*I);r.push(E/W,k/W,I/W),c.push(x/n,l/i);}for(let l=0;l<i;l++)for(let x=0;x<n;x++){let p=(n+1)*l+x,m=(n+1)*(l+1)+x,f=(n+1)*(l+1)+x+1,v=(n+1)*l+x+1;o.push(p,m,v,m,f,v);}let a=[],d=new Set;for(let l=0;l<o.length;l+=3){let x=[o[l],o[l+1],o[l+2]];for(let p=0;p<3;p++){let m=Math.min(x[p],x[(p+1)%3]),f=Math.max(x[p],x[(p+1)%3]),v=`${m}-${f}`;d.has(v)||(d.add(v),a.push({a:m,b:f}));}}let g=[];for(let l=0;l<o.length;l+=3){let x=[o[l],o[l+1],o[l+2]],p={x:r[o[l]*3],y:r[o[l]*3+1],z:r[o[l]*3+2]};g.push({vertices:x,normal:p});}let u={id:q(),vertices:new Float32Array(s),normals:new Float32Array(r),uvs:new Float32Array(c),indices:new Uint16Array(o),vertexCount:s.length/3,edges:a,faces:g};return {id:X(),name:"Torus",geometry:u,material:Q(),transform:{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},visible:true,locked:false,parentId:null}}function Je(h={}){let{radiusBottom:e=.5,height:t=1,segments:i=32}=h;return Ee({radiusTop:0,radiusBottom:e,height:t,segments:i})}function ge(h,e){switch(h){case "cube":return Se(e);case "sphere":return Ce(e);case "cylinder":return Ee(e);case "plane":return qe(e);case "torus":return Qe(e);case "cone":return Je(e);case "icosphere":return Ce({...e,segments:8,rings:4});default:return Se()}}var tt=[{id:"select",label:"Select",shortcut:"Q"},{id:"move",label:"Move",shortcut:"G"},{id:"rotate",label:"Rotate",shortcut:"R"},{id:"scale",label:"Scale",shortcut:"S"}],nt=[{type:"cube",label:"Cube"},{type:"sphere",label:"Sphere"},{type:"cylinder",label:"Cylinder"},{type:"cone",label:"Cone"},{type:"plane",label:"Plane"},{type:"torus",label:"Torus"}];function Pe({tool:h,editMode:e,shadingMode:t,snapToGrid:i,onToolChange:n,onEditModeChange:s,onShadingModeChange:r,onSnapToGridChange:c,onAddPrimitive:o,onUndo:a,onRedo:d,canUndo:g,canRedo:u}){let[l,x]=useState(false);return jsxs("div",{className:"flex items-center gap-1 px-2 py-1 bg-black/40 border-b border-white/10",children:[jsxs("div",{className:"flex items-center gap-0.5 mr-2",children:[jsx("button",{onClick:a,disabled:!g,className:"p-1.5 rounded hover:bg-white/10 disabled:opacity-30 disabled:cursor-not-allowed",title:"Undo (Ctrl+Z)",children:jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M3 10h10a5 5 0 0 1 5 5v2M3 10l4 4M3 10l4-4"})})}),jsx("button",{onClick:d,disabled:!u,className:"p-1.5 rounded hover:bg-white/10 disabled:opacity-30 disabled:cursor-not-allowed",title:"Redo (Ctrl+Shift+Z)",children:jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21 10H11a5 5 0 0 0-5 5v2M21 10l-4 4M21 10l-4-4"})})})]}),jsx("div",{className:"w-px h-5 bg-white/20 mx-1"}),jsx("div",{className:"flex items-center gap-0.5",children:tt.map(p=>jsx("button",{onClick:()=>n(p.id),className:`px-2 py-1 text-xs rounded transition-colors ${h===p.id?"bg-blue-500/80 text-white":"hover:bg-white/10 text-white/70"}`,title:`${p.label} (${p.shortcut})`,children:p.label},p.id))}),jsx("div",{className:"w-px h-5 bg-white/20 mx-1"}),jsx("button",{onClick:()=>s(e==="object"?"edit":"object"),className:`px-2 py-1 text-xs rounded transition-colors ${e==="edit"?"bg-orange-500/80 text-white":"hover:bg-white/10 text-white/70"}`,title:"Toggle Edit Mode (Tab)",children:e==="object"?"Object Mode":"Edit Mode"}),jsx("div",{className:"w-px h-5 bg-white/20 mx-1"}),jsxs("div",{className:"relative",children:[jsxs("button",{onClick:()=>x(!l),className:"px-2 py-1 text-xs rounded hover:bg-white/10 text-white/70 flex items-center gap-1",children:[jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M12 5v14M5 12h14"})}),"Add",jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M6 9l6 6 6-6"})})]}),l&&jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-40",onClick:()=>x(false)}),jsxs("div",{className:"absolute top-full left-0 mt-1 py-1 bg-gray-800 border border-white/20 rounded-lg shadow-xl z-50 min-w-32",children:[jsx("div",{className:"px-2 py-1 text-xs text-white/50 uppercase tracking-wider",children:"Mesh"}),nt.map(p=>jsx("button",{onClick:()=>{o(p.type),x(false);},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-white/10 text-white/80",children:p.label},p.type))]})]})]}),jsx("div",{className:"flex-1"}),jsxs("select",{value:t,onChange:p=>r(p.target.value),className:"px-2 py-1 text-xs bg-transparent border border-white/20 rounded text-white/70",children:[jsx("option",{value:"solid",children:"Solid"}),jsx("option",{value:"wireframe",children:"Wireframe"}),jsx("option",{value:"material",children:"Material"})]}),jsxs("label",{className:"flex items-center gap-1.5 px-2 text-xs text-white/70 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:i,onChange:p=>c(p.target.checked),className:"w-3 h-3"}),"Snap"]})]})}function Ve({meshes:h,selection:e,onSelect:t,onToggleVisibility:i,onToggleLock:n,onRename:s,onDelete:r}){let[c,o]=Ne.useState(null),[a,d]=Ne.useState(""),g=l=>{o(l.id),d(l.name);},u=l=>{a.trim()&&s(l,a.trim()),o(null);};return jsxs("div",{className:"flex flex-col h-full bg-black/30",children:[jsx("div",{className:"px-3 py-2 border-b border-white/10 text-xs font-medium text-white/60 uppercase tracking-wider",children:"Outliner"}),jsxs("div",{className:"flex-1 overflow-y-auto",children:[jsxs("div",{className:"px-2 py-1.5 text-sm text-white/50 flex items-center gap-2",children:[jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M12 2a10 10 0 0 1 0 20"})]}),"Scene"]}),jsx("div",{className:"pl-2",children:h.length===0?jsxs("div",{className:"px-4 py-8 text-center text-white/30 text-xs",children:["No objects in scene.",jsx("br",{}),"Press Shift+A to add."]}):h.map(l=>{let x=e.selectedObjects.includes(l.id),p=e.activeObject===l.id;return jsxs("div",{onClick:m=>t(l.id,m.shiftKey),onDoubleClick:()=>g(l),className:`group flex items-center gap-1 px-2 py-1 cursor-pointer rounded-sm mx-1 ${p?"bg-blue-500/50":x?"bg-blue-500/30":"hover:bg-white/5"}`,children:[jsx("div",{className:"w-4 h-4 flex items-center justify-center text-white/40",children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})})}),c===l.id?jsx("input",{type:"text",value:a,onChange:m=>d(m.target.value),onBlur:()=>u(l.id),onKeyDown:m=>{m.key==="Enter"&&u(l.id),m.key==="Escape"&&o(null);},className:"flex-1 px-1 py-0 text-sm bg-black/50 border border-blue-500 rounded outline-none",autoFocus:true,onClick:m=>m.stopPropagation()}):jsx("span",{className:`flex-1 text-sm truncate ${l.visible?"text-white/80":"text-white/30"}`,children:l.name}),jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{onClick:m=>{m.stopPropagation(),i(l.id);},className:`p-0.5 rounded hover:bg-white/10 ${l.visible?"text-white/50":"text-white/20"}`,title:l.visible?"Hide":"Show",children:l.visible?jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),jsx("circle",{cx:"12",cy:"12",r:"3"})]}):jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"}),jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}),jsx("button",{onClick:m=>{m.stopPropagation(),n(l.id);},className:`p-0.5 rounded hover:bg-white/10 ${l.locked?"text-orange-400":"text-white/30"}`,title:l.locked?"Unlock":"Lock",children:l.locked?jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}):jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),jsx("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]})}),jsx("button",{onClick:m=>{m.stopPropagation(),r(l.id);},className:"p-0.5 rounded hover:bg-red-500/30 text-white/30 hover:text-red-400",title:"Delete",children:jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]})]},l.id)})})]}),jsxs("div",{className:"px-3 py-1.5 border-t border-white/10 text-xs text-white/40",children:[h.length," object",h.length!==1?"s":"",e.selectedObjects.length>0&&jsxs("span",{children:[" | ",e.selectedObjects.length," selected"]})]})]})}function pe({label:h,value:e,onChange:t,step:i=.1}){let n=(s,r)=>{let c=parseFloat(r);isNaN(c)||t({...e,[s]:c});};return jsxs("div",{className:"space-y-1",children:[jsx("label",{className:"text-xs text-white/50 uppercase tracking-wider",children:h}),jsxs("div",{className:"flex gap-1",children:[jsx("div",{className:"flex-1",children:jsxs("div",{className:"flex items-center gap-1",children:[jsx("span",{className:"text-xs text-red-400 w-3",children:"X"}),jsx("input",{type:"number",value:e.x.toFixed(3),onChange:s=>n("x",s.target.value),step:i,className:"w-full px-2 py-1 text-xs bg-black/30 border border-white/10 rounded focus:border-blue-500 outline-none"})]})}),jsx("div",{className:"flex-1",children:jsxs("div",{className:"flex items-center gap-1",children:[jsx("span",{className:"text-xs text-green-400 w-3",children:"Y"}),jsx("input",{type:"number",value:e.y.toFixed(3),onChange:s=>n("y",s.target.value),step:i,className:"w-full px-2 py-1 text-xs bg-black/30 border border-white/10 rounded focus:border-blue-500 outline-none"})]})}),jsx("div",{className:"flex-1",children:jsxs("div",{className:"flex items-center gap-1",children:[jsx("span",{className:"text-xs text-blue-400 w-3",children:"Z"}),jsx("input",{type:"number",value:e.z.toFixed(3),onChange:s=>n("z",s.target.value),step:i,className:"w-full px-2 py-1 text-xs bg-black/30 border border-white/10 rounded focus:border-blue-500 outline-none"})]})})]})]})}function J({label:h,value:e,onChange:t,min:i=0,max:n=1,step:s=.01}){return jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("label",{className:"text-xs text-white/50",children:h}),jsx("span",{className:"text-xs text-white/70",children:e.toFixed(2)})]}),jsx("input",{type:"range",value:e,onChange:r=>t(parseFloat(r.target.value)),min:i,max:n,step:s,className:"w-full h-1 bg-white/10 rounded appearance-none cursor-pointer"})]})}function ot({color:h,onChange:e}){let t=`#${Math.round(h.r).toString(16).padStart(2,"0")}${Math.round(h.g).toString(16).padStart(2,"0")}${Math.round(h.b).toString(16).padStart(2,"0")}`,i=n=>{let s=parseInt(n.slice(1,3),16),r=parseInt(n.slice(3,5),16),c=parseInt(n.slice(5,7),16);!isNaN(s)&&!isNaN(r)&&!isNaN(c)&&e({r:s,g:r,b:c,a:h.a});};return jsxs("div",{className:"flex items-center gap-2",children:[jsx("input",{type:"color",value:t,onChange:n=>i(n.target.value),className:"w-8 h-8 rounded border border-white/20 cursor-pointer"}),jsx("input",{type:"text",value:t,onChange:n=>i(n.target.value),className:"flex-1 px-2 py-1 text-xs bg-black/30 border border-white/10 rounded focus:border-blue-500 outline-none"})]})}function Re({selectedMesh:h,onUpdateTransform:e,onUpdateMaterial:t}){let[i,n]=useState({transform:true,material:true,geometry:false}),s=r=>{n(c=>({...c,[r]:!c[r]}));};return h?jsxs("div",{className:"flex flex-col h-full bg-black/30",children:[jsx("div",{className:"px-3 py-2 border-b border-white/10 text-xs font-medium text-white/60 uppercase tracking-wider",children:"Properties"}),jsxs("div",{className:"flex-1 overflow-y-auto",children:[jsxs("div",{className:"px-3 py-2 border-b border-white/5",children:[jsx("div",{className:"text-sm font-medium text-white/90",children:h.name}),jsxs("div",{className:"text-xs text-white/40",children:[h.geometry.vertexCount," vertices"]})]}),jsxs("div",{className:"border-b border-white/5",children:[jsxs("button",{onClick:()=>s("transform"),className:"w-full px-3 py-2 flex items-center justify-between hover:bg-white/5",children:[jsx("span",{className:"text-xs font-medium text-white/70",children:"Transform"}),jsx("svg",{className:`w-4 h-4 text-white/40 transition-transform ${i.transform?"rotate-180":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M6 9l6 6 6-6"})})]}),i.transform&&jsxs("div",{className:"px-3 pb-3 space-y-3",children:[jsx(pe,{label:"Position",value:h.transform.position,onChange:r=>e({position:r})}),jsx(pe,{label:"Rotation",value:{x:h.transform.rotation.x*180/Math.PI,y:h.transform.rotation.y*180/Math.PI,z:h.transform.rotation.z*180/Math.PI},onChange:r=>e({rotation:{x:r.x*Math.PI/180,y:r.y*Math.PI/180,z:r.z*Math.PI/180}}),step:1}),jsx(pe,{label:"Scale",value:h.transform.scale,onChange:r=>e({scale:r})})]})]}),jsxs("div",{className:"border-b border-white/5",children:[jsxs("button",{onClick:()=>s("material"),className:"w-full px-3 py-2 flex items-center justify-between hover:bg-white/5",children:[jsx("span",{className:"text-xs font-medium text-white/70",children:"Material"}),jsx("svg",{className:`w-4 h-4 text-white/40 transition-transform ${i.material?"rotate-180":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M6 9l6 6 6-6"})})]}),i.material&&jsxs("div",{className:"px-3 pb-3 space-y-3",children:[jsxs("div",{className:"space-y-1",children:[jsx("label",{className:"text-xs text-white/50",children:"Color"}),jsx(ot,{color:h.material.color,onChange:r=>t({color:r})})]}),jsx(J,{label:"Ambient",value:h.material.ambient,onChange:r=>t({ambient:r})}),jsx(J,{label:"Diffuse",value:h.material.diffuse,onChange:r=>t({diffuse:r})}),jsx(J,{label:"Specular",value:h.material.specular,onChange:r=>t({specular:r})}),jsx(J,{label:"Shininess",value:h.material.shininess,onChange:r=>t({shininess:r}),min:1,max:128,step:1}),jsx(J,{label:"Opacity",value:h.material.opacity,onChange:r=>t({opacity:r})})]})]}),jsxs("div",{className:"border-b border-white/5",children:[jsxs("button",{onClick:()=>s("geometry"),className:"w-full px-3 py-2 flex items-center justify-between hover:bg-white/5",children:[jsx("span",{className:"text-xs font-medium text-white/70",children:"Geometry"}),jsx("svg",{className:`w-4 h-4 text-white/40 transition-transform ${i.geometry?"rotate-180":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M6 9l6 6 6-6"})})]}),i.geometry&&jsxs("div",{className:"px-3 pb-3 space-y-2 text-xs",children:[jsxs("div",{className:"flex justify-between text-white/60",children:[jsx("span",{children:"Vertices"}),jsx("span",{className:"text-white/80",children:h.geometry.vertexCount})]}),jsxs("div",{className:"flex justify-between text-white/60",children:[jsx("span",{children:"Edges"}),jsx("span",{className:"text-white/80",children:h.geometry.edges.length})]}),jsxs("div",{className:"flex justify-between text-white/60",children:[jsx("span",{children:"Faces"}),jsx("span",{className:"text-white/80",children:h.geometry.faces.length})]}),jsxs("div",{className:"flex justify-between text-white/60",children:[jsx("span",{children:"Triangles"}),jsx("span",{className:"text-white/80",children:h.geometry.indices.length/3})]})]})]})]})]}):jsxs("div",{className:"flex flex-col h-full bg-black/30",children:[jsx("div",{className:"px-3 py-2 border-b border-white/10 text-xs font-medium text-white/60 uppercase tracking-wider",children:"Properties"}),jsx("div",{className:"flex-1 flex items-center justify-center",children:jsxs("div",{className:"text-center text-white/30 text-xs px-4",children:["No object selected.",jsx("br",{}),"Select an object to view properties."]})})]})}function ee(h,e){let t={x:h.x*e.scale.x,y:h.y*e.scale.y,z:h.z*e.scale.z},{rotation:i}=e,n=Math.cos(i.x),s=Math.sin(i.x);t={x:t.x,y:t.y*n-t.z*s,z:t.y*s+t.z*n};let r=Math.cos(i.y),c=Math.sin(i.y);t={x:t.x*r+t.z*c,y:t.y,z:-t.x*c+t.z*r};let o=Math.cos(i.z),a=Math.sin(i.z);return t={x:t.x*o-t.y*a,y:t.x*a+t.y*o,z:t.z},{x:t.x+e.position.x,y:t.y+e.position.y,z:t.z+e.position.z}}var te=class{meshes=new Map;setMeshes(e){this.meshes.clear();for(let t of e)this.meshes.set(t.id,t);}generateRenderData(e,t,i){let n=[],s=[],r=[],c=[];for(let o of e.selectedObjects){let a=this.meshes.get(o);if(!a)continue;let d=this.getBoundingBox(a);this.addBoundingBoxLines(d,c);}if(i&&e.activeObject){let o=this.meshes.get(e.activeObject);if(o){if(t==="vertex")for(let a of e.selectedVertices){let d={x:o.geometry.vertices[a*3],y:o.geometry.vertices[a*3+1],z:o.geometry.vertices[a*3+2]},g=ee(d,o.transform);n.push(g.x,g.y,g.z);}if(t==="edge")for(let[a,d]of e.selectedEdges){let g={x:o.geometry.vertices[a*3],y:o.geometry.vertices[a*3+1],z:o.geometry.vertices[a*3+2]},u={x:o.geometry.vertices[d*3],y:o.geometry.vertices[d*3+1],z:o.geometry.vertices[d*3+2]},l=ee(g,o.transform),x=ee(u,o.transform);s.push(l.x,l.y,l.z,x.x,x.y,x.z);}if(t==="face")for(let a of e.selectedFaces){let d=o.geometry.faces[a];if(d)for(let g of d.vertices){let u={x:o.geometry.vertices[g*3],y:o.geometry.vertices[g*3+1],z:o.geometry.vertices[g*3+2]},l=ee(u,o.transform);r.push(l.x,l.y,l.z);}}}}return {vertices:new Float32Array(n),edges:new Float32Array(s),faceHighlights:new Float32Array(r),outlineVertices:new Float32Array(c)}}getBoundingBox(e){let{vertices:t}=e.geometry,{transform:i}=e,n=1/0,s=1/0,r=1/0,c=-1/0,o=-1/0,a=-1/0;for(let d=0;d<e.geometry.vertexCount;d++){let g={x:t[d*3],y:t[d*3+1],z:t[d*3+2]},u=ee(g,i);n=Math.min(n,u.x),s=Math.min(s,u.y),r=Math.min(r,u.z),c=Math.max(c,u.x),o=Math.max(o,u.y),a=Math.max(a,u.z);}return {min:{x:n,y:s,z:r},max:{x:c,y:o,z:a}}}addBoundingBoxLines(e,t){let{min:i,max:n}=e;t.push(i.x,i.y,i.z,n.x,i.y,i.z),t.push(n.x,i.y,i.z,n.x,i.y,n.z),t.push(n.x,i.y,n.z,i.x,i.y,n.z),t.push(i.x,i.y,n.z,i.x,i.y,i.z),t.push(i.x,n.y,i.z,n.x,n.y,i.z),t.push(n.x,n.y,i.z,n.x,n.y,n.z),t.push(n.x,n.y,n.z,i.x,n.y,n.z),t.push(i.x,n.y,n.z,i.x,n.y,i.z),t.push(i.x,i.y,i.z,i.x,n.y,i.z),t.push(n.x,i.y,i.z,n.x,n.y,i.z),t.push(n.x,i.y,n.z,n.x,n.y,n.z),t.push(i.x,i.y,n.z,i.x,n.y,n.z);}};var D={x:{r:1,g:.2,b:.2},y:{r:.2,g:1,b:.2},z:{r:.2,g:.4,b:1},highlight:{r:1,g:1,b:.2}},ne=class{moveGizmo=null;rotateGizmo=null;scaleGizmo=null;generateGizmoLines(e,t,i){if(!t.visible||e==="select")return {vertices:[],colors:[]};let n=Math.max(.5,i*.1),{position:s,activeAxis:r}=t,c=[],o=[];switch(e){case "move":this.addMoveGizmo(s,n,r,c,o);break;case "rotate":this.addRotateGizmo(s,n,r,c,o);break;case "scale":this.addScaleGizmo(s,n,r,c,o);break}return {vertices:c,colors:o}}addMoveGizmo(e,t,i,n,s){let r=[{axis:"x",dir:{x:1,y:0,z:0}},{axis:"y",dir:{x:0,y:1,z:0}},{axis:"z",dir:{x:0,y:0,z:1}}];for(let{axis:u,dir:l}of r){let x=i===u?D.highlight:D[u];n.push(e.x,e.y,e.z),n.push(e.x+l.x*t,e.y+l.y*t,e.z+l.z*t),s.push(x.r,x.g,x.b,x.r,x.g,x.b);let p={x:e.x+l.x*t,y:e.y+l.y*t,z:e.z+l.z*t},m=t*.15,f=u==="y"?{x:1,y:0,z:0}:{x:0,y:1,z:0};n.push(p.x,p.y,p.z),n.push(p.x-l.x*m+f.x*m*.3,p.y-l.y*m+f.y*m*.3,p.z-l.z*m+f.z*m*.3),s.push(x.r,x.g,x.b,x.r,x.g,x.b),n.push(p.x,p.y,p.z),n.push(p.x-l.x*m-f.x*m*.3,p.y-l.y*m-f.y*m*.3,p.z-l.z*m-f.z*m*.3),s.push(x.r,x.g,x.b,x.r,x.g,x.b);}let c=t*.3,o=t*.2,a=i==="xy"?D.highlight:{r:.8,g:.8,b:.2};n.push(e.x+o,e.y+o,e.z),n.push(e.x+o+c,e.y+o,e.z),s.push(a.r,a.g,a.b,a.r,a.g,a.b),n.push(e.x+o+c,e.y+o,e.z),n.push(e.x+o+c,e.y+o+c,e.z),s.push(a.r,a.g,a.b,a.r,a.g,a.b),n.push(e.x+o+c,e.y+o+c,e.z),n.push(e.x+o,e.y+o+c,e.z),s.push(a.r,a.g,a.b,a.r,a.g,a.b),n.push(e.x+o,e.y+o+c,e.z),n.push(e.x+o,e.y+o,e.z),s.push(a.r,a.g,a.b,a.r,a.g,a.b);let d=i==="xz"?D.highlight:{r:.8,g:.2,b:.8};n.push(e.x+o,e.y,e.z+o),n.push(e.x+o+c,e.y,e.z+o),s.push(d.r,d.g,d.b,d.r,d.g,d.b),n.push(e.x+o+c,e.y,e.z+o),n.push(e.x+o+c,e.y,e.z+o+c),s.push(d.r,d.g,d.b,d.r,d.g,d.b),n.push(e.x+o+c,e.y,e.z+o+c),n.push(e.x+o,e.y,e.z+o+c),s.push(d.r,d.g,d.b,d.r,d.g,d.b),n.push(e.x+o,e.y,e.z+o+c),n.push(e.x+o,e.y,e.z+o),s.push(d.r,d.g,d.b,d.r,d.g,d.b);let g=i==="yz"?D.highlight:{r:.2,g:.8,b:.8};n.push(e.x,e.y+o,e.z+o),n.push(e.x,e.y+o+c,e.z+o),s.push(g.r,g.g,g.b,g.r,g.g,g.b),n.push(e.x,e.y+o+c,e.z+o),n.push(e.x,e.y+o+c,e.z+o+c),s.push(g.r,g.g,g.b,g.r,g.g,g.b),n.push(e.x,e.y+o+c,e.z+o+c),n.push(e.x,e.y+o,e.z+o+c),s.push(g.r,g.g,g.b,g.r,g.g,g.b),n.push(e.x,e.y+o,e.z+o+c),n.push(e.x,e.y+o,e.z+o),s.push(g.r,g.g,g.b,g.r,g.g,g.b);}addRotateGizmo(e,t,i,n,s){let c=i==="x"?D.highlight:D.x;for(let d=0;d<32;d++){let g=d/32*Math.PI*2,u=(d+1)/32*Math.PI*2;n.push(e.x,e.y+Math.cos(g)*t,e.z+Math.sin(g)*t),n.push(e.x,e.y+Math.cos(u)*t,e.z+Math.sin(u)*t),s.push(c.r,c.g,c.b,c.r,c.g,c.b);}let o=i==="y"?D.highlight:D.y;for(let d=0;d<32;d++){let g=d/32*Math.PI*2,u=(d+1)/32*Math.PI*2;n.push(e.x+Math.cos(g)*t,e.y,e.z+Math.sin(g)*t),n.push(e.x+Math.cos(u)*t,e.y,e.z+Math.sin(u)*t),s.push(o.r,o.g,o.b,o.r,o.g,o.b);}let a=i==="z"?D.highlight:D.z;for(let d=0;d<32;d++){let g=d/32*Math.PI*2,u=(d+1)/32*Math.PI*2;n.push(e.x+Math.cos(g)*t,e.y+Math.sin(g)*t,e.z),n.push(e.x+Math.cos(u)*t,e.y+Math.sin(u)*t,e.z),s.push(a.r,a.g,a.b,a.r,a.g,a.b);}}addScaleGizmo(e,t,i,n,s){let r=[{axis:"x",dir:{x:1,y:0,z:0}},{axis:"y",dir:{x:0,y:1,z:0}},{axis:"z",dir:{x:0,y:0,z:1}}];for(let{axis:g,dir:u}of r){let l=i===g?D.highlight:D[g];n.push(e.x,e.y,e.z),n.push(e.x+u.x*t,e.y+u.y*t,e.z+u.z*t),s.push(l.r,l.g,l.b,l.r,l.g,l.b);let x=t*.1,p={x:e.x+u.x*t,y:e.y+u.y*t,z:e.z+u.z*t},m=[[-1,-1,-1],[1,-1,-1],[1,1,-1],[-1,1,-1],[-1,-1,1],[1,-1,1],[1,1,1],[-1,1,1]],f=[[0,1],[1,2],[2,3],[3,0],[4,5],[5,6],[6,7],[7,4],[0,4],[1,5],[2,6],[3,7]];for(let[v,y]of f){let z=m[v],A=m[y];n.push(p.x+z[0]*x,p.y+z[1]*x,p.z+z[2]*x,p.x+A[0]*x,p.y+A[1]*x,p.z+A[2]*x),s.push(l.r,l.g,l.b,l.r,l.g,l.b);}}let c=i===null?D.highlight:{r:.8,g:.8,b:.8},o=t*.15,a=[[0,1],[1,2],[2,3],[3,0],[4,5],[5,6],[6,7],[7,4],[0,4],[1,5],[2,6],[3,7]],d=[[-1,-1,-1],[1,-1,-1],[1,1,-1],[-1,1,-1],[-1,-1,1],[1,-1,1],[1,1,1],[-1,1,1]];for(let[g,u]of a){let l=d[g],x=d[u];n.push(e.x+l[0]*o,e.y+l[1]*o,e.z+l[2]*o,e.x+x[0]*o,e.y+x[1]*o,e.z+x[2]*o),s.push(c.r,c.g,c.b,c.r,c.g,c.b);}}hitTestGizmo(e,t,i,n){if(e==="select")return null;let s=Math.max(.5,n*.1),r=s*.15,c=[{axis:"x",dir:{x:1,y:0,z:0}},{axis:"y",dir:{x:0,y:1,z:0}},{axis:"z",dir:{x:0,y:0,z:1}}],o=null,a=r;for(let{axis:d,dir:g}of c){let u=this.distanceToLine(i.origin,i.direction,t,{x:t.x+g.x*s,y:t.y+g.y*s,z:t.z+g.z*s});u<a&&(a=u,o=d);}return o}distanceToLine(e,t,i,n){let s={x:e.x-i.x,y:e.y-i.y,z:e.z-i.z},r={x:n.x-i.x,y:n.y-i.y,z:n.z-i.z},c=t.x*t.x+t.y*t.y+t.z*t.z,o=t.x*r.x+t.y*r.y+t.z*r.z,a=r.x*r.x+r.y*r.y+r.z*r.z,d=t.x*s.x+t.y*s.y+t.z*s.z,g=r.x*s.x+r.y*s.y+r.z*s.z,u=c*a-o*o;if(Math.abs(u)<1e-4)return 1/0;let l=(o*g-a*d)/u,x=Math.max(0,Math.min(1,(c*g-o*d)/u)),p={x:e.x+t.x*l,y:e.y+t.y*l,z:e.z+t.z*l},m={x:i.x+r.x*x,y:i.y+r.y*x,z:i.z+r.z*x},f=p.x-m.x,v=p.y-m.y,y=p.z-m.z;return Math.sqrt(f*f+v*v+y*y)}};var ie=class{gridSize;gridDivisions;constructor(e=10,t=10){this.gridSize=e,this.gridDivisions=t;}generateGrid(){let e=[],t=[],i=this.gridSize/this.gridDivisions,n=this.gridSize/2;for(let s=0;s<=this.gridDivisions;s++){let r=-n+s*i,c=Math.abs(r)<.001;e.push(-n,0,r),e.push(n,0,r),c?t.push(.2,.2,.6,.2,.2,.6):t.push(.3,.3,.3,.3,.3,.3),e.push(r,0,-n),e.push(r,0,n),c?t.push(.6,.2,.2,.6,.2,.2):t.push(.3,.3,.3,.3,.3,.3);}return {vertices:new Float32Array(e),colors:new Float32Array(t)}}generateAxes(e=1){let t=[],i=[];return t.push(0,0,0),t.push(e,0,0),i.push(1,.2,.2,1,.2,.2),t.push(0,0,0),t.push(0,e,0),i.push(.2,1,.2,.2,1,.2),t.push(0,0,0),t.push(0,0,e),i.push(.2,.4,1,.2,.4,1),{vertices:new Float32Array(t),colors:new Float32Array(i)}}generateCornerAxes(e=.5){let t=[],i=[];return t.push(0,0,0,e,0,0),i.push(1,.3,.3,1,.3,.3),t.push(0,0,0,0,e,0),i.push(.3,1,.3,.3,1,.3),t.push(0,0,0,0,0,e),i.push(.3,.5,1,.3,.5,1),{lines:{vertices:t,colors:i},labels:{x:"X",y:"Y",z:"Z"}}}setSize(e){this.gridSize=e;}setDivisions(e){this.gridDivisions=e;}};var at=`
attribute vec3 aPosition;
attribute vec3 aColor;
uniform mat4 uViewProjection;
varying vec3 vColor;
void main() {
vColor = aColor;
gl_Position = uViewProjection * vec4(aPosition, 1.0);
gl_PointSize = 8.0;
}
`,ct=`
precision mediump float;
varying vec3 vColor;
void main() {
gl_FragColor = vec4(vColor, 1.0);
}
`,se=class{engine;gl;canvas;lineProgram=null;lineUniforms={};lineAttributes={};lineVBO=null;lineColorVBO=null;selectionRenderer;gizmoRenderer;gridRenderer;meshes=[];selection={selectedObjects:[],selectedVertices:[],selectedEdges:[],selectedFaces:[],activeObject:null};gizmoState={visible:false,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1},activeAxis:null,dragging:false};showGrid=true;showAxes=true;constructor(e,t,i){this.canvas=e,this.engine=new WebGL3DEngine(e,{width:t,height:i,antialias:true,alpha:false,depth:true});let n=e.getContext("webgl");if(!n)throw new Error("WebGL not available");this.gl=n,this.selectionRenderer=new te,this.gizmoRenderer=new ne,this.gridRenderer=new ie(20,20),this.initLineShaders(),this.initDefaultScene();}initLineShaders(){let{gl:e}=this,t=e.createShader(e.VERTEX_SHADER);e.shaderSource(t,at),e.compileShader(t);let i=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(i,ct),e.compileShader(i),this.lineProgram=e.createProgram(),e.attachShader(this.lineProgram,t),e.attachShader(this.lineProgram,i),e.linkProgram(this.lineProgram),e.deleteShader(t),e.deleteShader(i),this.lineUniforms={viewProjection:e.getUniformLocation(this.lineProgram,"uViewProjection")},this.lineAttributes={position:e.getAttribLocation(this.lineProgram,"aPosition"),color:e.getAttribLocation(this.lineProgram,"aColor")},this.lineVBO=e.createBuffer(),this.lineColorVBO=e.createBuffer();}initDefaultScene(){let e=this.engine.createScene("Main");this.engine.addAmbientLight(e,{r:255,g:255,b:255,a:1},.4),this.engine.addDirectionalLight(e,{x:1,y:-1,z:-0.5},{r:255,g:255,b:255,a:1},.8),e.background={r:45,g:45,b:50,a:1},e.camera.position={x:5,y:4,z:5},e.camera.target={x:0,y:0,z:0};}getWebGLEngine(){return this.engine}getScene(){return this.engine.getActiveScene()}getCamera(){return this.engine.getActiveScene()?.camera}getMeshes(){return this.meshes}getMesh(e){return this.meshes.find(t=>t.id===e)}addMesh(e){this.meshes.push(e),this.selectionRenderer.setMeshes(this.meshes),this.syncMeshesToEngine();}removeMesh(e){this.meshes=this.meshes.filter(t=>t.id!==e),this.selection.selectedObjects=this.selection.selectedObjects.filter(t=>t!==e),this.selection.activeObject===e&&(this.selection.activeObject=null),this.selectionRenderer.setMeshes(this.meshes),this.syncMeshesToEngine();}updateMesh(e,t){let i=this.meshes.find(n=>n.id===e);i&&(Object.assign(i,t),this.syncMeshesToEngine());}duplicateMesh(e){let t=this.meshes.find(n=>n.id===e);if(!t)return null;let i={...t,id:`mesh-${Date.now().toString(36)}-${Math.random().toString(36).substring(2,7)}`,name:`${t.name}.001`,geometry:{...t.geometry,id:`geo-${Date.now().toString(36)}`},material:{...t.material,id:`mat-${Date.now().toString(36)}`},transform:{position:{...t.transform.position,x:t.transform.position.x+1},rotation:{...t.transform.rotation},scale:{...t.transform.scale}}};return this.addMesh(i),i}getSelection(){return this.selection}setSelection(e){Object.assign(this.selection,e),this.updateGizmoPosition();}selectObject(e,t=false){t?this.selection.selectedObjects.includes(e)||this.selection.selectedObjects.push(e):this.selection.selectedObjects=[e],this.selection.activeObject=e,this.updateGizmoPosition();}deselectAll(){this.selection={selectedObjects:[],selectedVertices:[],selectedEdges:[],selectedFaces:[],activeObject:null},this.gizmoState.visible=false;}updateGizmoPosition(){if(this.selection.selectedObjects.length===0){this.gizmoState.visible=false;return}let e=0,t=0,i=0,n=0;for(let s of this.selection.selectedObjects){let r=this.meshes.find(c=>c.id===s);r&&(e+=r.transform.position.x,t+=r.transform.position.y,i+=r.transform.position.z,n++);}n>0&&(this.gizmoState.position={x:e/n,y:t/n,z:i/n},this.gizmoState.visible=true);}getGizmoState(){return this.gizmoState}setGizmoState(e){Object.assign(this.gizmoState,e);}resize(e,t){this.engine.resize(e,t);}start(e){this.engine.start(t=>{e?.(t);});}stop(){this.engine.stop();}render(e,t,i){if(!this.engine.getActiveScene())return;let{gl:s}=this;this.renderOverlays(e,t,i);}renderOverlays(e,t,i){let n=this.engine.getActiveScene();if(!n||!this.lineProgram)return;let{gl:s}=this,r=n.camera,c=this.buildViewProjectionMatrix(r);if(s.useProgram(this.lineProgram),s.uniformMatrix4fv(this.lineUniforms.viewProjection,false,c),s.disable(s.DEPTH_TEST),this.showGrid){let a=this.gridRenderer.generateGrid();this.drawLines(a.vertices,a.colors);}if(this.showAxes){s.enable(s.DEPTH_TEST);let a=this.gridRenderer.generateAxes(1);this.drawLines(a.vertices,a.colors),s.disable(s.DEPTH_TEST);}let o=this.selectionRenderer.generateRenderData(this.selection,t,i);if(o.outlineVertices.length>0){let a=new Float32Array(o.outlineVertices.length);for(let d=0;d<a.length;d+=3)a[d]=1,a[d+1]=.6,a[d+2]=.2;this.drawLines(o.outlineVertices,a);}if(o.vertices.length>0){let a=new Float32Array(o.vertices.length);for(let d=0;d<a.length;d+=3)a[d]=1,a[d+1]=1,a[d+2]=.2;this.drawPoints(o.vertices,a);}if(o.edges.length>0){let a=new Float32Array(o.edges.length);for(let d=0;d<a.length;d+=3)a[d]=1,a[d+1]=1,a[d+2]=.2;this.drawLines(o.edges,a);}if(this.gizmoState.visible){let a=Math.sqrt(Math.pow(r.position.x-this.gizmoState.position.x,2)+Math.pow(r.position.y-this.gizmoState.position.y,2)+Math.pow(r.position.z-this.gizmoState.position.z,2)),d=this.gizmoRenderer.generateGizmoLines(e,this.gizmoState,a);d.vertices.length>0&&this.drawLines(new Float32Array(d.vertices),new Float32Array(d.colors));}s.enable(s.DEPTH_TEST);}drawLines(e,t){let{gl:i}=this;e.length!==0&&(i.bindBuffer(i.ARRAY_BUFFER,this.lineVBO),i.bufferData(i.ARRAY_BUFFER,e,i.DYNAMIC_DRAW),i.enableVertexAttribArray(this.lineAttributes.position),i.vertexAttribPointer(this.lineAttributes.position,3,i.FLOAT,false,0,0),i.bindBuffer(i.ARRAY_BUFFER,this.lineColorVBO),i.bufferData(i.ARRAY_BUFFER,t,i.DYNAMIC_DRAW),i.enableVertexAttribArray(this.lineAttributes.color),i.vertexAttribPointer(this.lineAttributes.color,3,i.FLOAT,false,0,0),i.drawArrays(i.LINES,0,e.length/3));}drawPoints(e,t){let{gl:i}=this;e.length!==0&&(i.bindBuffer(i.ARRAY_BUFFER,this.lineVBO),i.bufferData(i.ARRAY_BUFFER,e,i.DYNAMIC_DRAW),i.enableVertexAttribArray(this.lineAttributes.position),i.vertexAttribPointer(this.lineAttributes.position,3,i.FLOAT,false,0,0),i.bindBuffer(i.ARRAY_BUFFER,this.lineColorVBO),i.bufferData(i.ARRAY_BUFFER,t,i.DYNAMIC_DRAW),i.enableVertexAttribArray(this.lineAttributes.color),i.vertexAttribPointer(this.lineAttributes.color,3,i.FLOAT,false,0,0),i.drawArrays(i.POINTS,0,e.length/3));}buildViewProjectionMatrix(e){let t=this.normalize({x:e.position.x-e.target.x,y:e.position.y-e.target.y,z:e.position.z-e.target.z}),i=this.normalize(this.cross(e.up,t)),n=this.cross(t,i),s=new Float32Array([i.x,n.x,t.x,0,i.y,n.y,t.y,0,i.z,n.z,t.z,0,-this.dot(i,e.position),-this.dot(n,e.position),-this.dot(t,e.position),1]),r=this.engine.getState(),c=r.width/r.height,o;if(e.type==="perspective"){let a=1/Math.tan(e.fov/2),d=1/(e.near-e.far);o=new Float32Array([a/c,0,0,0,0,a,0,0,0,0,(e.near+e.far)*d,-1,0,0,e.near*e.far*d*2,0]);}else {let a=e.zoom*c,d=e.zoom;o=new Float32Array([1/a,0,0,0,0,1/d,0,0,0,0,-2/(e.far-e.near),0,0,0,-(e.far+e.near)/(e.far-e.near),1]);}return this.multiplyMatrices(o,s)}normalize(e){let t=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z);return t>0?{x:e.x/t,y:e.y/t,z:e.z/t}:{x:0,y:0,z:0}}cross(e,t){return {x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}dot(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}multiplyMatrices(e,t){let i=new Float32Array(16);for(let n=0;n<4;n++)for(let s=0;s<4;s++)i[n*4+s]=e[n*4+0]*t[0+s]+e[n*4+1]*t[4+s]+e[n*4+2]*t[8+s]+e[n*4+3]*t[12+s];return i}syncMeshesToEngine(){let e=this.engine.getActiveScene();if(e){e.meshes=[];for(let t of this.meshes){if(!t.visible)continue;let i={id:t.geometry.id,vertices:t.geometry.vertices,normals:t.geometry.normals,uvs:t.geometry.uvs,indices:t.geometry.indices,vertexCount:t.geometry.vertexCount},n=this.engine.createMesh(i,t.material,t.transform);n.id=t.id,n.name=t.name,n.visible=t.visible,e.meshes.push(n);}}}setGridVisible(e){this.showGrid=e;}setAxesVisible(e){this.showAxes=e;}getState(){return this.engine.getState()}subscribe(e){return this.engine.subscribe(e)}destroy(){let{gl:e}=this;this.lineProgram&&e.deleteProgram(this.lineProgram),this.lineVBO&&e.deleteBuffer(this.lineVBO),this.lineColorVBO&&e.deleteBuffer(this.lineColorVBO),this.engine.destroy();}};function re(h,e){return {x:h.x-e.x,y:h.y-e.y,z:h.z-e.z}}function Oe(h,e){return {x:h.x+e.x,y:h.y+e.y,z:h.z+e.z}}function lt(h,e){return {x:h.x*e,y:h.y*e,z:h.z*e}}function oe(h,e){return h.x*e.x+h.y*e.y+h.z*e.z}function ae(h,e){return {x:h.y*e.z-h.z*e.y,y:h.z*e.x-h.x*e.z,z:h.x*e.y-h.y*e.x}}function fe(h){let e=Math.sqrt(h.x*h.x+h.y*h.y+h.z*h.z);return e===0?{x:0,y:0,z:0}:{x:h.x/e,y:h.y/e,z:h.z/e}}function ye(h,e){let t={x:h.x*e.scale.x,y:h.y*e.scale.y,z:h.z*e.scale.z},{rotation:i}=e,n=Math.cos(i.x),s=Math.sin(i.x);t={x:t.x,y:t.y*n-t.z*s,z:t.y*s+t.z*n};let r=Math.cos(i.y),c=Math.sin(i.y);t={x:t.x*r+t.z*c,y:t.y,z:-t.x*c+t.z*r};let o=Math.cos(i.z),a=Math.sin(i.z);return t={x:t.x*o-t.y*a,y:t.x*a+t.y*o,z:t.z},Oe(t,e.position)}function ke(h,e,t,i,n){let s=h/t*2-1,r=1-e/i*2,c=n.position,o=fe(re(n.target,n.position)),a=fe(ae(o,n.up)),d=ae(a,o),g;if(n.type==="perspective"){let u=Math.tan(n.fov/2),l=t/i;g=fe({x:o.x+a.x*s*u*l+d.x*r*u,y:o.y+a.y*s*u*l+d.y*r*u,z:o.z+a.z*s*u*l+d.z*r*u});}else {let u=n.zoom*2*(t/i),l=n.zoom*2;return {origin:{x:c.x+a.x*s*u/2+d.x*r*l/2,y:c.y+a.y*s*u/2+d.y*r*l/2,z:c.z+a.z*s*u/2+d.z*r*l/2},direction:o}}return {origin:c,direction:g}}function dt(h,e,t,i){let s=re(t,e),r=re(i,e),c=ae(h.direction,r),o=oe(s,c);if(o>-1e-6&&o<1e-6)return {hit:false,distance:1/0,point:{x:0,y:0,z:0}};let a=1/o,d=re(h.origin,e),g=a*oe(d,c);if(g<0||g>1)return {hit:false,distance:1/0,point:{x:0,y:0,z:0}};let u=ae(d,s),l=a*oe(h.direction,u);if(l<0||g+l>1)return {hit:false,distance:1/0,point:{x:0,y:0,z:0}};let x=a*oe(r,u);if(x>1e-6){let p=Oe(h.origin,lt(h.direction,x));return {hit:true,distance:x,point:p}}return {hit:false,distance:1/0,point:{x:0,y:0,z:0}}}function ht(h,e){if(!e.visible)return null;let{geometry:t,transform:i}=e,{vertices:n,indices:s}=t,r=null,c=1/0;for(let o=0;o<s.length;o+=3){let a=s[o],d=s[o+1],g=s[o+2],u={x:n[a*3],y:n[a*3+1],z:n[a*3+2]},l={x:n[d*3],y:n[d*3+1],z:n[d*3+2]},x={x:n[g*3],y:n[g*3+1],z:n[g*3+2]},p=ye(u,i),m=ye(l,i),f=ye(x,i),v=dt(h,p,m,f);v.hit&&v.distance<c&&(c=v.distance,r={meshId:e.id,distance:v.distance,point:v.point,faceIndex:Math.floor(o/3)});}return r}function Te(h,e){let t=null,i=1/0;for(let n of e){let s=ht(h,n);s&&s.distance<i&&(i=s.distance,t=s);}return t}function je({engine:h,tool:e,editMode:t,selectionMode:i,shadingMode:n,onEngineReady:s,onSelect:r}){let c=useRef(null),o=useRef(null),a=useRef(null),[d,g]=useState({distance:8,theta:Math.PI/4,phi:Math.PI/3,target:{x:0,y:0,z:0}}),u=useRef(false),l=useRef(false),x=useRef({x:0,y:0});useEffect(()=>{let y=c.current,z=o.current;if(!y||!z)return;let A=z.getBoundingClientRect(),E=new se(y,A.width,A.height);a.current=E,E.start(),s(E);let k=new ResizeObserver(I=>{for(let W of I){let{width:K,height:G}=W.contentRect;K>0&&G>0&&E.resize(K,G);}});return k.observe(z),()=>{k.disconnect(),E.destroy(),a.current=null;}},[s]),useEffect(()=>{if(!a.current)return;let y=a.current.getScene();if(!y)return;let{distance:z,theta:A,phi:E,target:k}=d,I=Math.max(.1,Math.min(Math.PI-.1,E));y.camera.position={x:k.x+z*Math.sin(I)*Math.sin(A),y:k.y+z*Math.cos(I),z:k.z+z*Math.sin(I)*Math.cos(A)},y.camera.target=k;},[d]),useEffect(()=>{if(!a.current)return;let z=setInterval(()=>{a.current&&a.current.render(e,i,t==="edit");},16);return ()=>clearInterval(z)},[e,i,t]);let p=useCallback(y=>{let z=c.current;if(!(!z||!a.current)){if(z.setPointerCapture(y.pointerId),x.current={x:y.clientX,y:y.clientY},y.button===1||y.button===0&&y.shiftKey){y.altKey?l.current=true:u.current=true;return}if(y.button===0&&e==="select"){let A=z.getBoundingClientRect(),E=y.clientX-A.left,k=y.clientY-A.top,I=a.current.getCamera();if(!I)return;let W=ke(E,k,A.width,A.height,I),K=a.current.getMeshes(),G=Te(W,K);G?r(G.meshId,y.ctrlKey||y.metaKey):!y.ctrlKey&&!y.metaKey&&r(null,false);}}},[e,r]),m=useCallback(y=>{if(!u.current&&!l.current)return;let z=y.clientX-x.current.x,A=y.clientY-x.current.y;if(x.current={x:y.clientX,y:y.clientY},u.current)g(E=>({...E,theta:E.theta-z*.005,phi:Math.max(.1,Math.min(Math.PI-.1,E.phi+A*.005))}));else if(l.current){let E=d.distance*.001;g(k=>({...k,target:{x:k.target.x-z*E,y:k.target.y+A*E,z:k.target.z}}));}},[d.distance]),f=useCallback(y=>{let z=c.current;z&&z.releasePointerCapture(y.pointerId),u.current=false,l.current=false;},[]),v=useCallback(y=>{y.preventDefault();let z=y.deltaY*.01;g(A=>({...A,distance:Math.max(1,Math.min(100,A.distance+z))}));},[]);return jsxs("div",{ref:o,className:"relative w-full h-full bg-gray-900",children:[jsx("canvas",{ref:c,onPointerDown:p,onPointerMove:m,onPointerUp:f,onPointerCancel:f,onWheel:v,className:"w-full h-full cursor-crosshair",style:{touchAction:"none"}}),jsx("div",{className:"absolute top-2 left-2 text-xs text-white/50",children:"Perspective"}),jsxs("div",{className:"absolute top-2 right-2 text-xs text-white/40 font-mono",children:[h?.getState().fps??0," FPS"]})]})}function De({tool:h,selection:e,cameraRotation:t}){let{theta:i,phi:n}=t,s=20,r={x:Math.cos(i)*s,y:-Math.sin(n)*Math.sin(i)*s},c={x:0,y:-Math.cos(n)*s},o={x:Math.sin(i)*s,y:Math.sin(n)*Math.cos(i)*s};return jsxs(Fragment,{children:[jsx("div",{className:"absolute bottom-4 left-4 w-16 h-16",children:jsxs("svg",{viewBox:"-30 -30 60 60",className:"w-full h-full",children:[jsx("line",{x1:"0",y1:"0",x2:r.x,y2:r.y,stroke:"#ef4444",strokeWidth:"2"}),jsx("text",{x:r.x*1.3,y:r.y*1.3,fill:"#ef4444",fontSize:"8",textAnchor:"middle",dominantBaseline:"middle",children:"X"}),jsx("line",{x1:"0",y1:"0",x2:c.x,y2:c.y,stroke:"#22c55e",strokeWidth:"2"}),jsx("text",{x:c.x*1.3,y:c.y*1.3-5,fill:"#22c55e",fontSize:"8",textAnchor:"middle",dominantBaseline:"middle",children:"Y"}),jsx("line",{x1:"0",y1:"0",x2:o.x,y2:o.y,stroke:"#3b82f6",strokeWidth:"2"}),jsx("text",{x:o.x*1.3,y:o.y*1.3,fill:"#3b82f6",fontSize:"8",textAnchor:"middle",dominantBaseline:"middle",children:"Z"}),jsx("circle",{cx:"0",cy:"0",r:"2",fill:"white",opacity:"0.5"})]})}),jsxs("div",{className:"absolute bottom-4 right-4 px-2 py-1 bg-black/50 rounded text-xs text-white/70",children:[h==="select"&&"Select (Q)",h==="move"&&"Move (G)",h==="rotate"&&"Rotate (R)",h==="scale"&&"Scale (S)"]}),e.selectedObjects.length>0&&jsxs("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 px-3 py-1 bg-blue-500/80 rounded text-xs text-white",children:[e.selectedObjects.length," object",e.selectedObjects.length!==1?"s":""," selected"]})]})}function Le({meshes:h,selection:e,editMode:t,selectionMode:i,fps:n,triangles:s}){let r=h.reduce((a,d)=>a+d.geometry.vertexCount,0),c=h.reduce((a,d)=>a+d.geometry.faces.length,0);return jsxs("div",{className:"flex items-center justify-between px-3 py-1 bg-black/40 border-t border-white/10 text-xs text-white/60",children:[jsx("div",{className:"flex-1 truncate",children:t==="object"?e.selectedObjects.length===0?"Click to select | Shift+A to add | Tab for edit mode":"G move | R rotate | S scale | X delete | D duplicate":i==="vertex"?"Click vertices to select | E extrude | G move":i==="edge"?"Click edges to select | Ctrl+R loop cut":"Click faces to select | E extrude | I inset"}),t==="edit"&&jsxs("div",{className:"flex items-center gap-3 mx-4",children:[jsx("button",{className:`px-2 py-0.5 rounded ${i==="vertex"?"bg-blue-500/50 text-white":"text-white/50"}`,children:"Vertex"}),jsx("button",{className:`px-2 py-0.5 rounded ${i==="edge"?"bg-blue-500/50 text-white":"text-white/50"}`,children:"Edge"}),jsx("button",{className:`px-2 py-0.5 rounded ${i==="face"?"bg-blue-500/50 text-white":"text-white/50"}`,children:"Face"})]}),jsxs("div",{className:"flex items-center gap-4 text-white/40 font-mono",children:[jsxs("span",{children:["Objs: ",h.length]}),jsxs("span",{children:["Verts: ",r.toLocaleString()]}),jsxs("span",{children:["Faces: ",c.toLocaleString()]}),jsxs("span",{children:["Tris: ",s.toLocaleString()]}),jsxs("span",{className:"text-green-400/60",children:[n," FPS"]})]})]})}function pt({className:h=""}){let[e,t]=useState(null),[i,n]=useState([]),[s,r]=useState({selectedObjects:[],selectedVertices:[],selectedEdges:[],selectedFaces:[],activeObject:null}),[c,o]=useState("select"),[a,d]=useState("object"),[g,u]=useState("vertex"),[l,x]=useState("solid"),[p,m]=useState(false),[f,v]=useState(.25),[y,z]=useState(true),[A,E]=useState(true),[k,I]=useState(0),[W,K]=useState(0),[G,Ge]=useState([]),[B,he]=useState(-1),[Be,ft]=useState({theta:Math.PI/4,phi:Math.PI/3}),S=useRef(null),We=useCallback(w=>{t(w),S.current=w,w.subscribe(C=>{I(C.fps),K(C.triangles);});let b=ge("cube");b.name="Cube",w.addMesh(b),n([b]);},[]),N=useCallback(()=>{S.current&&(n([...S.current.getMeshes()]),r(S.current.getSelection()));},[]),ve=useCallback((w,b)=>{S.current&&(w?S.current.selectObject(w,b):b||S.current.deselectAll(),N());},[N]),ue=useCallback(w=>{if(!S.current)return;let b=ge(w);b.name=w.charAt(0).toUpperCase()+w.slice(1);let C=i.find(L=>L.id===s.activeObject);C&&(b.transform.position={x:C.transform.position.x+2,y:C.transform.position.y,z:C.transform.position.z}),S.current.addMesh(b),S.current.selectObject(b.id),N(),we({type:"add",description:`Add ${b.name}`,execute:()=>{S.current?.addMesh(b),S.current?.selectObject(b.id),N();},undo:()=>{S.current?.removeMesh(b.id),N();}});},[i,s.activeObject,N]),ze=useCallback(()=>{if(!S.current)return;let w=[...s.selectedObjects],b=w.map(C=>S.current?.getMesh(C)).filter(C=>!!C);for(let C of w)S.current.removeMesh(C);N(),we({type:"delete",description:`Delete ${w.length} object(s)`,execute:()=>{for(let C of w)S.current?.removeMesh(C);N();},undo:()=>{for(let C of b)S.current?.addMesh(C);N();}});},[s.selectedObjects,N]),Me=useCallback(()=>{if(!S.current)return;let w=[];for(let b of s.selectedObjects){let C=S.current.duplicateMesh(b);C&&w.push(C);}w.length>0&&(S.current.setSelection({selectedObjects:w.map(b=>b.id),activeObject:w[0].id}),N());},[s.selectedObjects,N]),$e=useCallback(w=>{if(!S.current)return;let b=S.current.getMesh(w);b&&(S.current.updateMesh(w,{visible:!b.visible}),N());},[N]),He=useCallback(w=>{if(!S.current)return;let b=S.current.getMesh(w);b&&(S.current.updateMesh(w,{locked:!b.locked}),N());},[N]),_e=useCallback((w,b)=>{S.current&&(S.current.updateMesh(w,{name:b}),N());},[N]),Ue=useCallback(w=>{S.current&&(S.current.removeMesh(w),N());},[N]),Ye=useCallback(w=>{if(!S.current||!s.activeObject)return;let b=S.current.getMesh(s.activeObject);b&&(S.current.updateMesh(s.activeObject,{transform:{...b.transform,...w}}),N());},[s.activeObject,N]),Ke=useCallback(w=>{if(!S.current||!s.activeObject)return;let b=S.current.getMesh(s.activeObject);b&&(S.current.updateMesh(s.activeObject,{material:{...b.material,...w}}),N());},[s.activeObject,N]),we=useCallback(w=>{Ge(b=>{let C=b.slice(0,B+1);return C.push(w),C}),he(b=>b+1);},[B]),me=useCallback(()=>{if(B<0)return;G[B].undo(),he(b=>b-1);},[G,B]),xe=useCallback(()=>{if(B>=G.length-1)return;G[B+1].execute(),he(b=>b+1);},[G,B]);useEffect(()=>{let w=b=>{if(b.target instanceof HTMLInputElement||b.target instanceof HTMLTextAreaElement)return;let C=b.key.toLowerCase();if(C==="q"&&o("select"),C==="g"&&o("move"),C==="r"&&o("rotate"),C==="s"&&!b.ctrlKey&&!b.metaKey&&o("scale"),C==="tab"&&(b.preventDefault(),d(L=>L==="object"?"edit":"object")),a==="edit"&&(C==="1"&&u("vertex"),C==="2"&&u("edge"),C==="3"&&u("face")),(C==="x"||C==="delete")&&ze(),C==="d"&&(b.ctrlKey||b.metaKey)&&(b.preventDefault(),Me()),C==="z"&&(b.ctrlKey||b.metaKey)&&(b.preventDefault(),b.shiftKey?xe():me()),C==="a"&&b.shiftKey&&(b.preventDefault(),ue("cube")),C==="a"&&!b.shiftKey&&(b.preventDefault(),S.current)){let L=i.filter(U=>U.visible&&!U.locked).map(U=>U.id);S.current.setSelection({selectedObjects:L,activeObject:L[0]??null}),N();}if(C==="."&&S.current&&s.activeObject){let L=S.current.getMesh(s.activeObject);if(L){let U=S.current.getScene();U&&(U.camera.target={...L.transform.position});}}C==="n"&&E(L=>!L),C==="t"&&z(L=>!L);};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[a,i,s,ze,Me,me,xe,ue,N]);let Xe=s.activeObject?i.find(w=>w.id===s.activeObject)??null:null;return jsxs("div",{className:`flex flex-col h-full bg-gray-900 text-white ${h}`,children:[jsx(Pe,{tool:c,editMode:a,shadingMode:l,snapToGrid:p,onToolChange:o,onEditModeChange:d,onShadingModeChange:x,onSnapToGridChange:m,onAddPrimitive:ue,onUndo:me,onRedo:xe,canUndo:B>=0,canRedo:B<G.length-1}),jsxs("div",{className:"flex-1 flex overflow-hidden",children:[y&&jsx("div",{className:"w-56 border-r border-white/10 flex-shrink-0",children:jsx(Ve,{meshes:i,selection:s,onSelect:ve,onToggleVisibility:$e,onToggleLock:He,onRename:_e,onDelete:Ue})}),jsxs("div",{className:"flex-1 relative",children:[jsx(je,{engine:e,tool:c,editMode:a,selectionMode:g,shadingMode:l,onEngineReady:We,onSelect:ve}),jsx(De,{tool:c,selection:s,cameraRotation:Be})]}),A&&jsx("div",{className:"w-64 border-l border-white/10 flex-shrink-0",children:jsx(Re,{selectedMesh:Xe,onUpdateTransform:Ye,onUpdateMaterial:Ke})})]}),jsx(Le,{meshes:i,selection:s,editMode:a,selectionMode:g,fps:k,triangles:W})]})}function on(){return jsxs("svg",{viewBox:"0 0 64 64",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("defs",{children:jsxs("linearGradient",{id:"zmodel-grad",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[jsx("stop",{offset:"0%",stopColor:"#6366f1"}),jsx("stop",{offset:"100%",stopColor:"#8b5cf6"})]})}),jsx("rect",{width:"64",height:"64",rx:"14",fill:"url(#zmodel-grad)"}),jsxs("g",{stroke:"white",strokeWidth:"2",fill:"none",opacity:"0.9",children:[jsx("path",{d:"M20 24 L44 24 L44 48 L20 48 Z"}),jsx("path",{d:"M28 16 L52 16 L52 40 L28 40",strokeDasharray:"2 2",opacity:"0.5"}),jsx("path",{d:"M20 24 L28 16"}),jsx("path",{d:"M44 24 L52 16"}),jsx("path",{d:"M44 48 L52 40"}),jsx("path",{d:"M20 48 L28 40",strokeDasharray:"2 2",opacity:"0.5"})]}),jsxs("g",{strokeWidth:"2",children:[jsx("line",{x1:"12",y1:"52",x2:"20",y2:"52",stroke:"#ef4444"}),jsx("line",{x1:"12",y1:"52",x2:"12",y2:"44",stroke:"#22c55e"}),jsx("line",{x1:"12",y1:"52",x2:"8",y2:"56",stroke:"#3b82f6"})]})]})}var rn=pt;
export{pt as ZModelApp,on as ZModelIcon,rn as default};//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map