(()=>{"use strict";var e={338(e,s,t){var i=t(795);s.H=i.createRoot,i.hydrateRoot},795(e){e.exports=window.ReactDOM}},s={},t=function t(i){var n=s[i];if(void 0!==n)return n.exports;var o=s[i]={exports:{}};return e[i](o,o.exports,t),o.exports}(338);const i=window.React,n=window.ReactJSXRuntime,o=["Upload","Preview","Customize","Embed"];function d(){const[e,s]=(0,i.useState)(1),[t,d]=(0,i.useState)(""),[r,a]=(0,i.useState)(""),[l,c]=(0,i.useState)(""),[u,h]=(0,i.useState)("studio"),[p,w]=(0,i.useState)(!1),[m,x]=(0,i.useState)(""),v=(0,i.useMemo)(()=>`[modelora_viewer id="${m||"123"}" preset="${u}"]`,[u,m]);return(0,n.jsxs)("main",{className:"modelora-admin-app",children:[(0,n.jsxs)("header",{className:"modelora-admin-header",children:[(0,n.jsx)("h1",{children:"Modelora"}),(0,n.jsx)("p",{children:o.map((e,s)=>`${s+1}. ${e}`).join("  /  ")})]}),1===e&&(0,n.jsxs)("section",{className:"modelora-step-card",children:[(0,n.jsx)("h2",{children:"Upload"}),(0,n.jsx)("p",{children:"Drag and drop your model or click browse."}),(0,n.jsx)("input",{type:"file",accept:".glb,.gltf,.fbx,.obj,.stl,.usdz",onChange:function(e){const t=e.target.files?.[0];if(!t)return;const i=t.name.split(".").pop()?.toLowerCase()||"",n=t.size/1024/1024,o=Number(window.modeloraAdminData?.maxUploadMb||50);if(!["glb","gltf","fbx","obj","stl","usdz"].includes(i))return void c(window.modeloraAdminData?.i18n?.unsupported||"Unsupported file type");if(n>o)return void c(window.modeloraAdminData?.i18n?.largeFile||"File is too large");w(!0),c("");const r=new FormData;r.append("file",t),fetch((window.modeloraAdminData?.restUrl||"")+"models/upload",{method:"POST",headers:{"X-WP-Nonce":window.modeloraAdminData?.nonce||""},body:r}).then(e=>e.json()).then(e=>{w(!1),e.success?(a(t.name),d(e.url),x(e.model_id),s(2)):c(e.message||"Upload failed")}).catch(()=>{w(!1),c("Network error during upload")})},disabled:p}),p&&(0,n.jsx)("p",{style:{marginTop:10,color:"#6d7c8f"},children:"Uploading... please wait."}),l?(0,n.jsx)("p",{className:"modelora-error",children:l}):null]}),2===e&&(0,n.jsxs)("section",{className:"modelora-step-card",children:[(0,n.jsx)("h2",{children:"Preview"}),(0,n.jsx)("p",{children:r}),(0,n.jsx)("div",{className:"modelora-preview-box",children:(0,n.jsx)("model-viewer",{src:t,"camera-controls":!0,"touch-action":"pan-y",style:{width:"100%",height:360}})}),(0,n.jsxs)("div",{className:"modelora-row",children:[(0,n.jsx)("button",{className:"button",onClick:()=>s(1),children:"Back"}),(0,n.jsx)("button",{className:"button button-primary",onClick:()=>s(3),children:"Continue"})]})]}),3===e&&(0,n.jsxs)("section",{className:"modelora-step-card",children:[(0,n.jsx)("h2",{children:"Customize"}),(0,n.jsxs)("label",{children:["Environment preset",(0,n.jsxs)("select",{value:u,onChange:e=>h(e.target.value),children:[(0,n.jsx)("option",{value:"studio",children:"Studio"}),(0,n.jsx)("option",{value:"outdoor",children:"Outdoor"}),(0,n.jsx)("option",{value:"dark",children:"Dark"})]})]}),(0,n.jsxs)("div",{className:"modelora-row",children:[(0,n.jsx)("button",{className:"button",onClick:()=>s(2),children:"Back"}),(0,n.jsx)("button",{className:"button button-primary",onClick:()=>s(4),children:"Continue"})]})]}),4===e&&(0,n.jsxs)("section",{className:"modelora-step-card",children:[(0,n.jsx)("h2",{children:"Embed"}),(0,n.jsx)("p",{children:"Use Gutenberg block, Elementor widget, or shortcode."}),(0,n.jsx)("textarea",{value:v,rows:3,readOnly:!0,style:{width:"100%"}})]})]})}const r=document.getElementById("modelora-admin-root");r&&(0,t.H)(r).render((0,n.jsx)(d,{}))})();

