`},{id:"styles.css",name:"styles.css",content:`:root { --ink: #2A211B; --bronze: #B4632A; } body { margin: 0; font-family: "Work Sans", sans-serif; color: var(--ink); }`},{id:"app.js",name:"app.js",content:`import { renderInvoices } from './invoices.js'; const app = document.getElementById('app'); renderInvoices(app);`},{id:"invoices.ts",name:"invoices.ts",content:`export type Invoice = { id: string; client: string; amount: number; status: 'draft' | 'sent' | 'paid'; }; export const total = (rows: Invoice[]): number => rows.reduce((sum, row) => sum + row.amount, 0);`},{id:"InvoiceList.jsx",name:"InvoiceList.jsx",content:`export default function InvoiceList({ invoices }) { return ( ); }`}],Lv=[{ext:".html",badge:"html"},{ext:".css",badge:"css"},{ext:".js",badge:"js"},{ext:".ts",badge:"ts"},{ext:".jsx",badge:"jsx"}],sv=i(r=>(Lv.find(o=>r.endsWith(o.ext))||{badge:"file"}).badge,"badgeFor"),fv=i(r=>!!r.trim()&&!/\s/.test(r.trim())&&Lv.some(o=>r.trim().endsWith(o.ext)),"isValidName"),mb=i(()=>s.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",focusable:"false",children:s.jsx("path",{d:"M4 20h4l10.5-10.5a2.1 2.1 0 0 0-3-3L5 17v3z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})}),"PencilIcon"),vb=i(()=>s.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",focusable:"false",children:s.jsx("path",{d:"M5 7h14M10 7V5h4v2M7 7l1 13h8l1-13",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})}),"TrashIcon");function pb(){const[r,o]=N.useState(af),[h,f]=N.useState(af[0].id),[m,v]=N.useState(af[0].content),[S,R]=N.useState("saved"),[w,M]=N.useState(null),[T,p]=N.useState(""),[A,q]=N.useState(null),[Y,L]=N.useState(!1),[H,Z]=N.useState(""),[K,J]=N.useState(""),ae=N.useRef(null),ee=N.useMemo(()=>r.find(k=>k.id===h)||r[0]||null,[r,h]);N.useEffect(()=>()=>clearTimeout(ae.current),[]);const de=i(k=>{ee&&o($=>$.map(O=>O.id===ee.id?{...O,content:k}:O))},"commitDraft"),V=i(k=>{clearTimeout(ae.current),R("saving"),ae.current=setTimeout(()=>{de(k),R("saved")},700)},"scheduleAutosave"),ue=i(k=>{const $=k.target.value;v($),V($)},"handleEdit"),re=i(k=>{clearTimeout(ae.current),de(m),R("saved");const $=r.find(O=>O.id===k);$&&(f(k),v($.content),M(null),q(null),J(""))},"selectFile"),be=i(k=>{q(null),L(!1),J(""),M(k.id),p(k.name)},"startRename"),ze=i(k=>{if(k.preventDefault(),!w)return;const $=T.trim();if(!fv($)){J("Use a name ending in .html, .css, .js, .ts or .jsx without spaces.");return}if(r.some(O=>O.id!==w&&O.name===$)){J("A file with that name already exists.");return}o(O=>O.map(X=>X.id===w?{...X,name:$}:X)),M(null),J(""),R("saved")},"confirmRename"),je=i(()=>{if(!A)return;const k=r.filter($=>$.id!==A);if(clearTimeout(ae.current),o(k),q(null),A===h){const $=k[0]||null;f($?$.id:null),v($?$.content:"")}R("saved")},"confirmDelete"),De=i(k=>{k.preventDefault();const $=H.trim();if(!fv($)){J("Use a name ending in .html, .css, .js, .ts or .jsx without spaces.");return}if(r.some(X=>X.name===$)){J("A file with that name already exists.");return}const O={id:$,name:$,content:""};o(X=>[...X,O]),f(O.id),v(""),L(!1),Z(""),J(""),R("saved")},"confirmCreate");return s.jsx("section",{className:"wfep-root","aria-label":"Project files and code editor",children:s.jsxs("div",{className:"wfep-panel",children:[s.jsxs("div",{className:"wfep-explorer","aria-label":"File explorer",children:[s.jsxs("div",{className:"wfep-explorer__head",children:[s.jsxs("p",{className:"wfep-label",children:["Files · ",r.length]}),s.jsx("button",{type:"button",className:"wfep-new","aria-expanded":Y,"aria-controls":"wfep-create",onClick:i(()=>{L(k=>!k),M(null),q(null),J("")},"onClick"),children:"+ New file"})]}),Y&&s.jsxs("form",{className:"wfep-inline",id:"wfep-create",onSubmit:De,children:[s.jsx("label",{className:"wfep-label",htmlFor:"wfep-create-name",children:"Name"}),s.jsx("input",{id:"wfep-create-name",className:"wfep-input",value:H,onChange:i(k=>Z(k.target.value),"onChange"),placeholder:"about.jsx",autoFocus:!0,autoComplete:"off"}),s.jsx("button",{type:"submit",className:"wfep-mini wfep-mini--fill",children:"Create"}),s.jsx("button",{type:"button",className:"wfep-mini",onClick:i(()=>{L(!1),J("")},"onClick"),children:"Cancel"}),K&&s.jsx("span",{className:"wfep-error",role:"alert",children:K})]}),r.length===0?s.jsx("p",{className:"wfep-label",role:"status",children:"No files yet — create the first one."}):s.jsx("ul",{className:"wfep-list",children:r.map(k=>s.jsxs("li",{className:"wfep-row"+(k.id===h?" is-selected":""),children:[s.jsxs("div",{className:"wfep-row__main",children:[s.jsxs("button",{type:"button",className:"wfep-row__select","aria-pressed":k.id===h,onClick:i(()=>re(k.id),"onClick"),children:[s.jsx("span",{className:"wfep-badge",children:sv(k.name)}),s.jsx("span",{className:"wfep-row__name",children:k.name})]}),s.jsxs("span",{className:"wfep-row__actions",children:[s.jsx("button",{type:"button",className:"wfep-icon","aria-label":"Rename "+k.name,"aria-expanded":w===k.id,"aria-controls":"wfep-rename-"+k.id,onClick:i(()=>be(k),"onClick"),children:s.jsx(mb,{})}),s.jsx("button",{type:"button",className:"wfep-icon wfep-icon--danger","aria-label":"Delete "+k.name,"aria-expanded":A===k.id,"aria-controls":"wfep-delete-"+k.id,onClick:i(()=>{M(null),J(""),q($=>$===k.id?null:k.id)},"onClick"),children:s.jsx(vb,{})})]})]}),w===k.id&&s.jsxs("form",{className:"wfep-inline",id:"wfep-rename-"+k.id,onSubmit:ze,children:[s.jsx("label",{className:"wfep-label",htmlFor:"wfep-rename-input-"+k.id,children:"New name"}),s.jsx("input",{id:"wfep-rename-input-"+k.id,className:"wfep-input",value:T,onChange:i($=>p($.target.value),"onChange"),autoFocus:!0,autoComplete:"off"}),s.jsx("button",{type:"submit",className:"wfep-mini wfep-mini--fill",children:"Rename"}),s.jsx("button",{type:"button",className:"wfep-mini",onClick:i(()=>{M(null),J("")},"onClick"),children:"Cancel"}),K&&s.jsx("span",{className:"wfep-error",role:"alert",children:K})]}),A===k.id&&s.jsxs("div",{className:"wfep-inline",id:"wfep-delete-"+k.id,children:[s.jsxs("span",{children:["Delete ",k.name,"?"]}),s.jsx("button",{type:"button",className:"wfep-mini wfep-mini--danger",onClick:je,children:"Delete"}),s.jsx("button",{type:"button",className:"wfep-mini",onClick:i(()=>q(null),"onClick"),children:"Cancel"})]})]},k.id))})]}),s.jsxs("div",{className:"wfep-editor","aria-label":"Code editor",children:[s.jsxs("div",{className:"wfep-editor__head",children:[s.jsx("p",{className:"wfep-label",children:"Code editor"}),s.jsx("span",{className:"wfep-editor__file",children:ee?ee.name:"No file selected"})]}),s.jsxs("div",{className:"wfep-surface",children:[s.jsx("textarea",{className:"wfep-code",value:m,onChange:ue,readOnly:!ee,spellCheck:"false","aria-label":ee?"Edit "+ee.name:"No file open",placeholder:ee?"":"Select or create a file to start editing."}),s.jsxs("div",{className:"wfep-status","data-state":S,role:"status","aria-live":"polite",children:[s.jsxs("span",{children:[s.jsx("span",{className:"wfep-status__dot","aria-hidden":"true"}),S==="saving"?"Saving draft":"Draft saved"]}),s.jsx("span",{children:ee?sv(ee.name):"idle"})]})]})]})]})})}i(pb,"WorkspaceFileEditorPanel");function yb(r,o,h){xu.useLayoutEffect(()=>{const f=r.current;if(!f||!o.length)return;let m=0;const v=new WeakSet,S=typeof ResizeObserver=="function"?new ResizeObserver(p):null,R="data-spatial-region",w=i((Y,L)=>{try{return[...Y.querySelectorAll(L)]}catch{return[]}},"query"),M=o.flatMap(Y=>Y.queries.map(L=>matchMedia(L.when)));function T(Y){S&&!v.has(Y)&&(S.observe(Y),v.add(Y))}i(T,"observe");function p(){m||(m=requestAnimationFrame(A))}i(p,"schedule");function A(){m=0;const Y=new Map,L=window.innerWidth,H=Lae.getAttribute("data-spatial-section")===Z.section);for(const ae of Z.reserve_for)for(const ee of w(f,'[data-spatial-page-region="1"]['+R+"]").filter(de=>de.getAttribute(R)===ae)){T(ee);const de=Y.get(ee)||{"inline-start":0,"inline-end":0,"block-start":0,"block-end":0};if(Y.set(ee,de),K.participation!=="persistent")continue;const V=ee.getBoundingClientRect(),ue=getComputedStyle(ee).direction==="rtl";for(const re of J)for(const be of w(re,Z.selector)){T(be);const ze=getComputedStyle(be);if(!["fixed","absolute"].includes(ze.position)||!be.getClientRects().length||ze.visibility==="hidden"||be.closest('[hidden],[inert],[data-presentation-state="closed"]'))continue;const je=be.getBoundingClientRect();let De=K.edge;const k=i(me=>Number.parseFloat(me)===0,"zero"),$=k(ze.insetInlineStart),O=k(ze.insetInlineEnd),X=k(ze.insetBlockStart),W=k(ze.insetBlockEnd);if($&&O&&X!==W?De=X?"block-start":"block-end":X&&W&&$!==O&&(De=$?"inline-start":"inline-end"),je.right<=V.left||je.left>=V.right||!(ze.position==="fixed"&&De.startsWith("inline"))&&(je.bottom<=V.top||je.top>=V.bottom))continue;const se=De==="inline-start"?ue?V.right-je.left:je.right-V.left:De==="inline-end"?ue?je.right-V.left:V.right-je.left:De==="block-start"?je.bottom-(ze.position==="fixed"?Math.max(0,V.top+window.scrollY):V.top):(ze.position==="fixed"?window.innerHeight:V.bottom)-je.top;de[De]=Math.max(de[De],Math.max(0,Math.min(se,De.startsWith("inline")?V.width:V.height)))}}}for(const[Z,K]of Y)for(const[J,ae]of Object.entries(K)){const ee="--page-reserved-"+J,de=Math.ceil(ae*100)/100+"px";Z.style.getPropertyValue(ee)!==de&&Z.style.setProperty(ee,de)}}i(A,"update"),T(f);const q=new MutationObserver(p);q.observe(f,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["class","style","hidden","inert","data-presentation-state"]}),window.addEventListener("resize",p),window.addEventListener("scroll",p,{passive:!0}),f.addEventListener("transitionend",p),f.addEventListener("animationend",p);for(const Y of M)Y.addEventListener("change",p);return A(),()=>{cancelAnimationFrame(m),S==null||S.disconnect(),q.disconnect(),window.removeEventListener("resize",p),window.removeEventListener("scroll",p),f.removeEventListener("transitionend",p),f.removeEventListener("animationend",p);for(const Y of M)Y.removeEventListener("change",p)}},[r,o,h])}i(yb,"usePageSpatialAllocation");const gb=[{section:"WorkspaceHeaderSlot",selector:"header.app-header",participation:"persistent",edge:"block-start",profiles:{mobile:{participation:"persistent",edge:"block-start"},tablet:{participation:"persistent",edge:"block-start"},desktop:{participation:"persistent",edge:"block-start"}},queries:[],reserve_for:["spatial-content-1"]}],bb={version:1,tablet_min:768,desktop_min:1024};function Sb(){const r=xu.useRef(null);return yb(r,gb,bb),s.jsxs("div",{className:"ai-root",ref:r,"data-spatial-shell":"1",children:[s.jsx("div",{id:"workspaceheaderslot",className:"ai-slot-workspaceheaderslot","data-spatial-slot":"1","data-spatial-section":"WorkspaceHeaderSlot","data-spatial-owner":"AppHeader",children:s.jsx(z1,{activePage:"AI development workspace"})}),s.jsx("div",{"data-spatial-page-region":"1","data-spatial-region":"spatial-content-1",children:s.jsxs("div",{className:"ai-layout-1",children:[s.jsx("div",{id:"workspaceprojectcontext",className:"ai-slot-workspaceprojectcontext","data-spatial-slot":"1","data-spatial-section":"WorkspaceProjectContext",children:s.jsx(W1,{})}),s.jsx("div",{"data-spatial-page-region":"1","data-spatial-region":"workspace-panels",children:s.jsxs("div",{className:"ai-layout-2",children:[s.jsx("div",{id:"workspacechatpanel",className:"ai-slot-workspacechatpanel","data-spatial-slot":"1","data-spatial-section":"WorkspaceChatPanel",children:s.jsx(hb,{})}),s.jsx("div",{id:"workspacepreviewpanel",className:"ai-slot-workspacepreviewpanel","data-spatial-slot":"1","data-spatial-section":"WorkspacePreviewPanel",children:s.jsx(ub,{})}),s.jsx("div",{id:"workspacefileeditorpanel",className:"ai-slot-workspacefileeditorpanel","data-spatial-slot":"1","data-spatial-section":"WorkspaceFileEditorPanel",children:s.jsx(pb,{})})]})}),s.jsx("div",{id:"workspacepublishband",className:"ai-slot-workspacepublishband","data-spatial-slot":"1","data-spatial-section":"WorkspacePublishBand",children:s.jsx(q1,{})}),s.jsx("div",{id:"workspacefooterslot",className:"ai-slot-workspacefooterslot","data-spatial-slot":"1","data-spatial-section":"WorkspaceFooterSlot",children:s.jsx(U1,{})})]})})]})}i(Sb,"AIDevelopmentWorkspacePage");Vy.createRoot(document.getElementById("root")).render(xu.createElement(h1,null,xu.createElement(Sb)));