@miadi/stateloom-web 0.1.4 → 0.1.5
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.
- package/package.json +1 -1
- package/server/.next/BUILD_ID +1 -1
- package/server/.next/build-manifest.json +2 -2
- package/server/.next/server/app/_global-error.html +2 -2
- package/server/.next/server/app/_global-error.rsc +1 -1
- package/server/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/server/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/server/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/server/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/server/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/server/.next/server/app/_not-found.html +1 -1
- package/server/.next/server/app/_not-found.rsc +1 -1
- package/server/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/server/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/server/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/server/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/server/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/server/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/server/.next/server/app/index.html +1 -1
- package/server/.next/server/app/index.rsc +2 -2
- package/server/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/server/.next/server/app/index.segments/_full.segment.rsc +2 -2
- package/server/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/server/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/server/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/server/.next/server/app/page_client-reference-manifest.js +1 -1
- package/server/.next/server/chunks/ssr/[root-of-the-server]__edbb995c._.js +1 -1
- package/server/.next/server/pages/404.html +1 -1
- package/server/.next/server/pages/500.html +2 -2
- package/server/.next/static/chunks/{c8da5c76cf5bb070.js → 8ff30b68acab2d20.js} +1 -1
- package/server/package-lock.json +2 -2
- package/server/package.json +1 -1
- package/server/src/components/DocSwitcher.tsx +8 -2
- package/server/stateloom-web.json +2 -2
- package/server/tsconfig.tsbuildinfo +1 -1
- /package/server/.next/static/{yHDbm89IPqExJUSbiWtnD → MpwR1y8jNIjcY-QAij3pD}/_buildManifest.js +0 -0
- /package/server/.next/static/{yHDbm89IPqExJUSbiWtnD → MpwR1y8jNIjcY-QAij3pD}/_clientMiddlewareManifest.json +0 -0
- /package/server/.next/static/{yHDbm89IPqExJUSbiWtnD → MpwR1y8jNIjcY-QAij3pD}/_ssgManifest.js +0 -0
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
3:I[51858,["/_next/static/chunks/7a768100bec00db1.js"],"MetadataBoundary"]
|
|
4
4
|
4:"$Sreact.suspense"
|
|
5
5
|
5:I[49310,["/_next/static/chunks/7a768100bec00db1.js"],"IconMark"]
|
|
6
|
-
0:{"buildId":"
|
|
6
|
+
0:{"buildId":"MpwR1y8jNIjcY-QAij3pD","rsc":["$","$1","h",{"children":[null,["$","$L2",null,{"children":[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover, user-scalable=no, interactive-widget=resizes-content"}],["$","meta","2",{"name":"theme-color","content":"#030712"}],["$","meta","3",{"name":"color-scheme","content":"dark"}]]}],["$","div",null,{"hidden":true,"children":["$","$L3",null,{"children":["$","$4",null,{"name":"Next.Metadata","children":[["$","title","0",{"children":"SMCraft Designer"}],["$","meta","1",{"name":"description","content":"Visual State Machine Designer"}],["$","link","2",{"rel":"icon","href":"/favicon.ico?favicon.0b3bf435.ico","sizes":"256x256","type":"image/x-icon"}],["$","$L5","3",{}]]}]}]}],null]}],"loading":null,"isPartial":false}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
2:I[88287,["/_next/static/chunks/7a768100bec00db1.js"],"default"]
|
|
3
3
|
3:I[74895,["/_next/static/chunks/7a768100bec00db1.js"],"default"]
|
|
4
4
|
:HL["/_next/static/chunks/1cbe108679f9af04.css","style"]
|
|
5
|
-
0:{"buildId":"
|
|
5
|
+
0:{"buildId":"MpwR1y8jNIjcY-QAij3pD","rsc":["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/chunks/1cbe108679f9af04.css","precedence":"next"}]],["$","html",null,{"lang":"en","className":"dark","children":["$","body",null,{"className":"antialiased","children":[["$","script",null,{"dangerouslySetInnerHTML":{"__html":"try{var s=parseFloat(localStorage.getItem(\"stateloom.uiScale.v1\"));if(s>=0.75&&s<=1.75)document.documentElement.style.fontSize=(16*s)+\"px\"}catch(e){}"}}],["$","$L2",null,{"parallelRouterKey":"children","template":["$","$L3",null,{}],"notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]]}]]}]}]]}],"loading":null,"isPartial":false}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
:HL["/_next/static/chunks/1cbe108679f9af04.css","style"]
|
|
2
|
-
0:{"buildId":"
|
|
2
|
+
0:{"buildId":"MpwR1y8jNIjcY-QAij3pD","tree":{"name":"","paramType":null,"paramKey":"","hasRuntimePrefetch":false,"slots":{"children":{"name":"__PAGE__","paramType":null,"paramKey":"__PAGE__","hasRuntimePrefetch":false,"slots":null,"isRootLayout":false}},"isRootLayout":true},"staleTime":300}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
globalThis.__RSC_MANIFEST = globalThis.__RSC_MANIFEST || {};
|
|
2
|
-
globalThis.__RSC_MANIFEST["/page"] = {"moduleLoading":{"prefix":"","crossOrigin":null},"clientModules":{"[project]/web/node_modules/next/dist/esm/client/components/layout-router.js <module evaluation>":{"id":88287,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/client/components/layout-router.js":{"id":88287,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/client/components/render-from-template-context.js <module evaluation>":{"id":74895,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/client/components/render-from-template-context.js":{"id":74895,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/client/components/client-page.js <module evaluation>":{"id":83380,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/client/components/client-page.js":{"id":83380,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/client/components/client-segment.js <module evaluation>":{"id":8719,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/client/components/client-segment.js":{"id":8719,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/client/components/http-access-fallback/error-boundary.js <module evaluation>":{"id":24163,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/client/components/http-access-fallback/error-boundary.js":{"id":24163,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/lib/metadata/generate/icon-mark.js <module evaluation>":{"id":49310,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/lib/metadata/generate/icon-mark.js":{"id":49310,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/lib/framework/boundary-components.js <module evaluation>":{"id":51858,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/lib/framework/boundary-components.js":{"id":51858,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/client/components/builtin/global-error.js <module evaluation>":{"id":52576,"name":"*","chunks":[],"async":false},"[project]/web/node_modules/next/dist/client/components/builtin/global-error.js":{"id":52576,"name":"*","chunks":[],"async":false},"[project]/web/src/app/page.tsx <module evaluation>":{"id":63052,"name":"*","chunks":["/_next/static/chunks/aea5b1716c68391c.js","/_next/static/chunks/
|
|
2
|
+
globalThis.__RSC_MANIFEST["/page"] = {"moduleLoading":{"prefix":"","crossOrigin":null},"clientModules":{"[project]/web/node_modules/next/dist/esm/client/components/layout-router.js <module evaluation>":{"id":88287,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/client/components/layout-router.js":{"id":88287,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/client/components/render-from-template-context.js <module evaluation>":{"id":74895,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/client/components/render-from-template-context.js":{"id":74895,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/client/components/client-page.js <module evaluation>":{"id":83380,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/client/components/client-page.js":{"id":83380,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/client/components/client-segment.js <module evaluation>":{"id":8719,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/client/components/client-segment.js":{"id":8719,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/client/components/http-access-fallback/error-boundary.js <module evaluation>":{"id":24163,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/client/components/http-access-fallback/error-boundary.js":{"id":24163,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/lib/metadata/generate/icon-mark.js <module evaluation>":{"id":49310,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/lib/metadata/generate/icon-mark.js":{"id":49310,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/lib/framework/boundary-components.js <module evaluation>":{"id":51858,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/esm/lib/framework/boundary-components.js":{"id":51858,"name":"*","chunks":["/_next/static/chunks/7a768100bec00db1.js"],"async":false},"[project]/web/node_modules/next/dist/client/components/builtin/global-error.js <module evaluation>":{"id":52576,"name":"*","chunks":[],"async":false},"[project]/web/node_modules/next/dist/client/components/builtin/global-error.js":{"id":52576,"name":"*","chunks":[],"async":false},"[project]/web/src/app/page.tsx <module evaluation>":{"id":63052,"name":"*","chunks":["/_next/static/chunks/aea5b1716c68391c.js","/_next/static/chunks/8ff30b68acab2d20.js"],"async":false},"[project]/web/src/app/page.tsx":{"id":63052,"name":"*","chunks":["/_next/static/chunks/aea5b1716c68391c.js","/_next/static/chunks/8ff30b68acab2d20.js"],"async":false}},"ssrModuleMapping":{"88287":{"*":{"id":47492,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__385c85a7._.js","server/chunks/ssr/2374f_next_dist_0c464f98._.js"],"async":false}},"74895":{"*":{"id":14433,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__385c85a7._.js","server/chunks/ssr/2374f_next_dist_0c464f98._.js"],"async":false}},"83380":{"*":{"id":24449,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__385c85a7._.js","server/chunks/ssr/2374f_next_dist_0c464f98._.js"],"async":false}},"8719":{"*":{"id":54833,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__385c85a7._.js","server/chunks/ssr/2374f_next_dist_0c464f98._.js"],"async":false}},"24163":{"*":{"id":13588,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__385c85a7._.js","server/chunks/ssr/2374f_next_dist_0c464f98._.js"],"async":false}},"49310":{"*":{"id":13578,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__385c85a7._.js","server/chunks/ssr/2374f_next_dist_0c464f98._.js"],"async":false}},"51858":{"*":{"id":33121,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__385c85a7._.js","server/chunks/ssr/2374f_next_dist_0c464f98._.js"],"async":false}},"52576":{"*":{"id":61905,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__61a0b842._.js"],"async":false}},"63052":{"*":{"id":95421,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__2b35b711._.js","server/chunks/ssr/[root-of-the-server]__edbb995c._.js"],"async":false}}},"edgeSSRModuleMapping":{},"rscModuleMapping":{"88287":{"*":{"id":86309,"name":"*","chunks":[],"async":false}},"74895":{"*":{"id":6660,"name":"*","chunks":[],"async":false}},"83380":{"*":{"id":52093,"name":"*","chunks":[],"async":false}},"8719":{"*":{"id":56801,"name":"*","chunks":[],"async":false}},"24163":{"*":{"id":51240,"name":"*","chunks":[],"async":false}},"49310":{"*":{"id":67168,"name":"*","chunks":[],"async":false}},"51858":{"*":{"id":15798,"name":"*","chunks":[],"async":false}},"52576":{"*":{"id":63741,"name":"*","chunks":[],"async":false}},"63052":{"*":{"id":48277,"name":"*","chunks":[],"async":false}}},"edgeRscModuleMapping":{},"entryCSSFiles":{"[project]/web/src/app/favicon.ico":[],"[project]/web/node_modules/next/dist/client/components/builtin/global-error":[],"[project]/web/src/app/layout":[{"path":"static/chunks/1cbe108679f9af04.css","inlined":false}],"[project]/web/src/app/page":[{"path":"static/chunks/1cbe108679f9af04.css","inlined":false}]},"entryJSFiles":{"[project]/web/src/app/favicon.ico":["static/chunks/7a768100bec00db1.js"],"[project]/web/node_modules/next/dist/client/components/builtin/global-error":[],"[project]/web/src/app/layout":[],"[project]/web/src/app/page":["static/chunks/aea5b1716c68391c.js","static/chunks/8ff30b68acab2d20.js"]}}
|
|
@@ -3,7 +3,7 @@ module.exports=[92509,(a,b,c)=>{b.exports=a.x("url",()=>require("url"))},21517,(
|
|
|
3
3
|
${f}
|
|
4
4
|
\`\`\`
|
|
5
5
|
`:`${f}
|
|
6
|
-
`)],{type:`${bD[a]};charset=utf-8`})}else{let b=function(a={}){let b="u"<typeof document?null:document.getElementById(bz);if(!b)return null;let c=function(a){let b=a.querySelector(":scope > g");if(!b)return null;try{let a=b.getBBox();return a.width>0&&a.height>0?a:null}catch{return null}}(b);if(!c)return null;let d=a.padding??48,e=a.background??bA,f=Math.round(c.x-d),g=Math.round(c.y-d),h=Math.round(c.width+2*d),i=Math.round(c.height+2*d),j=b.cloneNode(!0);j.removeAttribute("id"),j.removeAttribute("class"),j.removeAttribute("style"),j.setAttribute("xmlns","http://www.w3.org/2000/svg"),j.setAttribute("width",String(h)),j.setAttribute("height",String(i)),j.setAttribute("viewBox",`${f} ${g} ${h} ${i}`),j.setAttribute("font-family","ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif"),function a(b){for(let c of Array.from(b.children)){if("transparent"===c.getAttribute("fill")||"transparent"===c.getAttribute("stroke")){c.remove();continue}c.removeAttribute("class"),c.removeAttribute("style"),a(c)}}(j);let k=j.querySelector(":scope > g");k?.removeAttribute("transform");let l=document.createElementNS("http://www.w3.org/2000/svg","rect");return l.setAttribute("x",String(f)),l.setAttribute("y",String(g)),l.setAttribute("width",String(h)),l.setAttribute("height",String(i)),l.setAttribute("fill",e),j.insertBefore(l,j.firstChild),new XMLSerializer().serializeToString(j)}(c);if(!b)throw Error("nothing on the board to export yet");g="svg"===a?new Blob([b],{type:`${bD.svg};charset=utf-8`}):await (f=c.scale??2,new Promise((c,d)=>{let e=b.match(/width="(\d+)"\s+height="(\d+)"/),g=e?Number(e[1]):1200,h=e?Number(e[2]):800,i=URL.createObjectURL(new Blob([b],{type:"image/svg+xml;charset=utf-8"})),j=new Image;j.onload=()=>{URL.revokeObjectURL(i);let b=document.createElement("canvas");b.width=Math.max(1,Math.round(g*f)),b.height=Math.max(1,Math.round(h*f));let e=b.getContext("2d");e?(e.fillStyle=bA,e.fillRect(0,0,b.width,b.height),e.drawImage(j,0,0,b.width,b.height),b.toBlob(a=>a?c(a):d(Error("the canvas produced no image")),bD[a],"jpeg"===a?.92:void 0)):d(Error("this browser gave no 2d context to draw into"))},j.onerror=()=>{URL.revokeObjectURL(i),d(Error("the browser could not read the serialized board"))},j.src=i}))}let h=function({doc:a,machine:b,format:c,at:d}){let e,f,g=Q(b??"")||Q(a?(a.split(/[/\\]/).pop()??a).replace(/\.smdf\.json$/i,"").replace(/\.json$/i,""):"")||"statemachine",h=a&&(e=a.match(/(?:^|[/\\-])ep(?:isode)?-?(\d{2,4})(?:[/\\-]|$)/i))?`ep${e[1]}`:null,i=h?`${h}--`:"";return`${i}${g}--${(f=a=>String(a).padStart(2,"0"))(d.getFullYear()%100)+f(d.getMonth()+1)+f(d.getDate())+f(d.getHours())+f(d.getMinutes())+f(d.getSeconds())}.${c}`}({doc:b.docPath??b.fileName??null,machine:b.definition?.settings?.name??null,format:bE[a]??String(a),at:(void 0)??new Date}),i=URL.createObjectURL(g),j=document.createElement("a");return j.href=i,j.download=h,j.click(),URL.revokeObjectURL(i),h}let bG="stateloom.layout.v1:";async function bH(){try{let{requestedDoc:b,docQuery:c}=await a.A(65614),d=await fetch(`/api/file${c(b())}`,{cache:"no-store"});if(d.ok){let a=(await d.json())?.path;if("string"==typeof a&&a.length>0)return a}}catch{}return bv.getState().fileName??"untitled"}function bI(){let a,b,c=bv(a=>a.definition),d=bv(a=>a.layout),e=bv(a=>a.selection),f=bv(a=>a.select),g=bv(a=>a.clearSelection),j=bv(a=>a.setStatePosition),k=bv(a=>a.drawMode),l=bv(a=>a.drawSource),m=bv(a=>a.setDrawSource),n=bv(a=>a.setDrawMode),o=bv(a=>a.addTransition),p=bv(a=>a.showContextMenu),q=bv(a=>a.removeState),r=bv(a=>a.undo),s=bv(a=>a.redo),t=bv(a=>a.errors),u=bv(a=>a.navigationPath),v=bv(a=>a.navigateInto),w=bv(a=>a.navigateUp),y=bv(a=>a.activeStates),z=bv(a=>a.viewport),A=bv(a=>a.setViewport);a=(0,i.useRef)(!1),b=(0,i.useRef)(null),(0,i.useEffect)(()=>{let c=!1,d=null;(async()=>{let d=await bH();if(c)return;b.current=d;let e=null;e&&bv.getState().hydrateLayout(e.positions,e.viewport),a.current=!0})();let e=bv.subscribe((c,e)=>{a.current&&b.current&&(c.layout!==e.layout||c.viewport!==e.viewport)&&(d&&clearTimeout(d),d=setTimeout(()=>{let a=bv.getState();b.current,function(a,b){let c={};for(let[d,e]of Object.entries(a)){let a=b[d];a&&(e.x!==a.x||e.y!==a.y||e.width!==a.width||e.height!==a.height)&&(c[d]=e)};}(a.layout.positions,x(a.definition)),a.viewport},300))});return()=>{c=!0,d&&clearTimeout(d),e()}},[]);let B=u.slice(1);return(0,h.jsx)($,{definition:c,positions:d.positions,path:B,rootLabel:u[0],viewport:z,onViewportChange:A,selection:{kind:"state"===e.kind||"transition"===e.kind?e.kind:null,id:e.id},activeStates:y,errorElements:t.flatMap(a=>a.element?[a.element]:[]),drawMode:"transition"===k?"transition":"select",drawSource:l,svgId:bz,pinchOwner:bw,emptyHint:"Right-click to add a state, or load a .smdf.json file",onSelect:(a,b)=>{"state"!==a||"transition"!==k||l?f(a,b):m(b)},onClearSelection:g,onStateMove:j,onNavigateInto:v,onNavigateTo:a=>w(a),onContextMenu:(a,b,c)=>p(a,b,"state"===c.kind?{kind:"state",id:c.id}:{kind:"canvas"}),onCreateTransition:(a,b,c)=>{o(a,{event:c,nextState:b}),m(null),n("select")},onCancelDraw:()=>{n("select"),m(null)},onDeleteState:a=>{q(a),g()},onUndo:r,onRedo:s})}function bJ({label:a,actions:b,onChange:c}){let d=(a,d)=>c(b.map((b,c)=>c===a?{...b,...d}:b));return(0,h.jsxs)("div",{children:[(0,h.jsxs)("div",{className:"flex items-center justify-between",children:[(0,h.jsx)("span",{className:"text-xs font-medium text-gray-500",children:a}),(0,h.jsx)("button",{onClick:()=>c([...b,{action:"code",code:""}]),className:"text-xs text-blue-500 hover:text-blue-400",children:"+ action"})]}),b.map((a,e)=>(0,h.jsxs)("div",{className:"flex items-start gap-1 mt-1",children:[(0,h.jsxs)("select",{className:"bg-gray-800 border border-gray-700 rounded px-1 py-0.5 text-xs text-gray-200",value:a.action,onChange:a=>d(e,{action:a.target.value}),children:[(0,h.jsx)("option",{value:"code",children:"Code"}),(0,h.jsx)("option",{value:"timerStart",children:"Timer Start"}),(0,h.jsx)("option",{value:"timerStop",children:"Timer Stop"})]}),"code"===a.action?(0,h.jsx)("textarea",{className:"flex-1 bg-gray-800 border border-gray-700 rounded px-1 py-0.5 text-xs text-gray-200 h-10 font-mono",value:a.code??"",placeholder:"// action code...",onChange:a=>d(e,{code:a.target.value})}):(0,h.jsx)("input",{className:"flex-1 bg-gray-800 border border-gray-700 rounded px-1 py-0.5 text-xs text-gray-200",value:a.name??"",placeholder:"Timer name",onChange:a=>d(e,{name:a.target.value})}),(0,h.jsx)("button",{onClick:()=>c(b.filter((a,b)=>b!==e)),className:"text-red-600 hover:text-red-400 text-xs mt-0.5",children:"✕"})]},e)),0===b.length&&(0,h.jsx)("span",{className:"text-xs text-gray-700 italic",children:"none"})]})}function bK(){let a=bv(a=>a.definition),b=bv(a=>a.selection),c=bv(a=>a.updateState),d=bv(a=>a.removeState);bv(a=>a.addAction),bv(a=>a.removeAction);let e=bv(a=>a.updateTransition),f=bv(a=>a.removeTransition);if(!b.kind||!b.id)return(0,h.jsx)("div",{className:"p-3 text-xs text-gray-500",children:"Select a state or transition to edit its properties."});let g=(a,b)=>{if(a.name===b)return a;for(let c of a.states??[]){let a=g(c,b);if(a)return a}return null};if("state"===b.kind){let e=g(a.state,b.id);if(!e)return(0,h.jsx)("div",{className:"p-3 text-gray-500 text-xs",children:"State not found"});let i=e.onEntry?.actions??[],j=e.onExit?.actions??[];return(0,h.jsxs)("div",{className:"p-3 space-y-3 text-sm md:overflow-y-auto md:max-h-[calc(100vh-160px)]",children:[(0,h.jsxs)("h3",{className:"text-xs font-semibold text-gray-400",children:["State: ",e.name]}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Name"}),(0,h.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:e.name,onChange:a=>c(b.id,{name:a.target.value})})]}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Kind"}),(0,h.jsxs)("select",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:e.kind??"normal",onChange:a=>c(b.id,{kind:a.target.value}),children:[(0,h.jsx)("option",{value:"normal",children:"Normal"}),(0,h.jsx)("option",{value:"final",children:"Final"}),(0,h.jsx)("option",{value:"history",children:"History"})]})]}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Description"}),(0,h.jsx)("textarea",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 h-12",value:e.description??"",onChange:a=>c(b.id,{description:a.target.value||void 0})})]}),(0,h.jsx)(bJ,{label:"▸ onEntry Actions",actions:i,onChange:a=>c(b.id,{onEntry:{actions:a}})}),(0,h.jsx)(bJ,{label:"◂ onExit Actions",actions:j,onChange:a=>c(b.id,{onExit:{actions:a}})}),(0,h.jsxs)("div",{children:[(0,h.jsx)("span",{className:"text-xs font-medium text-gray-500",children:"Transitions"}),(e.transitions??[]).map((a,c)=>(0,h.jsxs)("div",{className:"flex items-center gap-1 text-xs text-gray-400 py-1 border-b border-gray-800/50",children:[(0,h.jsxs)("span",{className:"flex-1",children:[a.event," → ",a.nextState??"(internal)"]}),a.condition&&(0,h.jsxs)("span",{className:"text-gray-600",children:["[",a.condition,"]"]}),(0,h.jsx)("button",{onClick:()=>f(b.id,c),className:"text-red-600 hover:text-red-400",children:"✕"})]},c)),(e.transitions?.length??0)===0&&(0,h.jsx)("span",{className:"text-xs text-gray-700 italic",children:"none"})]}),(0,h.jsx)("button",{onClick:()=>d(b.id),className:"text-red-500 hover:text-red-400 text-xs mt-2",children:"🗑 Delete State"})]})}if("transition"===b.kind){let[c,d]=b.id.split(":"),i=parseInt(d,10),j=g(a.state,c),k=j?.transitions?.[i];if(!k)return(0,h.jsx)("div",{className:"p-3 text-gray-500 text-xs",children:"Transition not found"});let l=bs(a),m=(function a(b){let c=[b];for(let d of b.states??[])c.push(...a(d));return c})(a.state).map(a=>a.name).filter(a=>"Root"!==a);return(0,h.jsxs)("div",{className:"p-3 space-y-3 text-sm",children:[(0,h.jsx)("h3",{className:"text-xs font-semibold text-gray-400",children:"Transition"}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Event"}),(0,h.jsx)("select",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:k.event,onChange:a=>e(c,i,{event:a.target.value}),children:l.map(a=>(0,h.jsx)("option",{value:a,children:a},a))})]}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Target State"}),(0,h.jsxs)("select",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:k.nextState??"",onChange:a=>e(c,i,{nextState:a.target.value||void 0}),children:[(0,h.jsx)("option",{value:"",children:"(internal transition)"}),m.map(a=>(0,h.jsx)("option",{value:a,children:a},a))]})]}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Condition (guard)"}),(0,h.jsx)("textarea",{rows:3,className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200 resize-y leading-snug",value:k.condition??"",onChange:a=>e(c,i,{condition:a.target.value||void 0})})]}),(0,h.jsx)("button",{onClick:()=>f(c,i),className:"text-red-500 hover:text-red-400 text-xs",children:"🗑 Delete Transition"})]})}return null}let bL=["string","int","float","bool","object"];function bM(){let a=bv(a=>a.definition),b=bv(a=>a.addEvent),c=bv(a=>a.updateEvent),d=bv(a=>a.removeEvent),e=bv(a=>a.addParameter),f=bv(a=>a.removeParameter),g=bv(a=>a.updateParameter),j=bv(a=>a.updateEventSource),k=bv(a=>a.select),l=bv(a=>a.selection),[m,n]=(0,i.useState)(""),[o,p]=(0,i.useState)(null),[q,r]=(0,i.useState)(null);return(0,h.jsxs)("div",{className:"p-3 text-sm",children:[a.events.map((a,b)=>(0,h.jsxs)("div",{className:"mb-3",children:[(0,h.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,h.jsx)("span",{className:"text-xs font-semibold text-gray-500",children:"Source:"}),(0,h.jsx)("input",{className:"flex-1 bg-transparent border-b border-gray-700 text-xs text-gray-300 px-1 py-0.5 focus:border-blue-500 outline-none",value:a.name,onChange:a=>j(b,{name:a.target.value})}),void 0!==a.feeder&&(0,h.jsx)("input",{className:"w-24 bg-transparent border-b border-gray-700 text-xs text-gray-400 px-1 py-0.5 focus:border-blue-500 outline-none",value:a.feeder??"",placeholder:"Feeder...",onChange:a=>j(b,{feeder:a.target.value||void 0})}),void 0===a.feeder&&(0,h.jsx)("button",{className:"text-xs text-gray-600 hover:text-gray-400",title:"Add feeder class",onClick:()=>j(b,{feeder:`${a.name}Feeder`}),children:"+feeder"})]}),(0,h.jsx)("div",{className:"-mx-1 overflow-x-auto px-1",children:(0,h.jsxs)("table",{className:"w-full text-xs",children:[(0,h.jsx)("thead",{children:(0,h.jsxs)("tr",{className:"text-gray-600 border-b border-gray-800",children:[(0,h.jsx)("th",{className:"text-left py-1 font-medium",children:"ID"}),(0,h.jsx)("th",{className:"text-left py-1 font-medium",children:"Description"}),(0,h.jsx)("th",{className:"text-left py-1 font-medium",children:"Params"}),(0,h.jsx)("th",{className:"w-6"})]})}),(0,h.jsx)("tbody",{children:(a.events??[]).map(a=>(0,h.jsxs)(i.Fragment,{children:[(0,h.jsxs)("tr",{className:`border-b border-gray-800/50 hover:bg-gray-800/30 cursor-pointer ${"event"===l.kind&&l.id===a.id?"bg-blue-900/30":""}`,onClick:()=>{k("event",a.id),p(o===a.id?null:a.id)},children:[(0,h.jsx)("td",{className:"py-1 pr-1",children:q===a.id?(0,h.jsx)("input",{autoFocus:!0,className:"w-full bg-gray-800 border border-gray-700 rounded px-1 text-gray-200",value:a.id,onChange:b=>c(a.id,{id:b.target.value}),onBlur:()=>r(null),onKeyDown:a=>"Enter"===a.key&&r(null),onClick:a=>a.stopPropagation()}):(0,h.jsx)("span",{className:"text-gray-300",onDoubleClick:b=>{b.stopPropagation(),r(a.id)},children:a.id})}),(0,h.jsx)("td",{className:"py-1 pr-1 text-gray-500 truncate max-w-[80px]",children:a.description??"—"}),(0,h.jsx)("td",{className:"py-1 text-gray-500",children:(a.parameters?.length??0)>0?a.parameters.map(a=>`${a.name}:${a.type}`).join(", "):"—"}),(0,h.jsx)("td",{className:"py-1",children:(0,h.jsx)("button",{onClick:b=>{b.stopPropagation(),d(a.id)},className:"text-red-600 hover:text-red-400",children:"✕"})})]}),o===a.id&&(0,h.jsx)("tr",{children:(0,h.jsx)("td",{colSpan:4,className:"py-2 px-1 bg-gray-900/50",children:(0,h.jsxs)("div",{className:"space-y-2",children:[(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-gray-600",children:"Description"}),(0,h.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-0.5 text-gray-200 mt-0.5",value:a.description??"",onChange:b=>c(a.id,{description:b.target.value||void 0})})]}),(0,h.jsxs)("div",{children:[(0,h.jsx)("span",{className:"text-gray-600",children:"Parameters"}),(a.parameters??[]).map((b,c)=>(0,h.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,h.jsx)("input",{className:"flex-1 bg-gray-800 border border-gray-700 rounded px-1 py-0.5 text-gray-200",value:b.name,placeholder:"name",onChange:b=>g(a.id,c,{name:b.target.value})}),(0,h.jsx)("select",{className:"bg-gray-800 border border-gray-700 rounded px-1 py-0.5 text-gray-200",value:b.type,onChange:b=>g(a.id,c,{type:b.target.value}),children:bL.map(a=>(0,h.jsx)("option",{value:a,children:a},a))}),(0,h.jsx)("button",{onClick:()=>f(a.id,c),className:"text-red-600 hover:text-red-400",children:"✕"})]},c)),(0,h.jsx)("button",{className:"text-blue-500 hover:text-blue-400 mt-1",onClick:()=>e(a.id,{name:"param",type:"string"}),children:"+ parameter"})]}),(0,h.jsxs)("div",{className:"mt-1",children:[(0,h.jsx)("span",{className:"text-gray-600",children:"Generated method:"}),(0,h.jsxs)("code",{className:"block bg-gray-800 rounded px-2 py-1 text-green-400 mt-0.5 font-mono",children:["on_",a.id.toLowerCase(),"(context",(a.parameters??[]).map(a=>`, ${a.name}: ${a.type}`).join(""),")"]})]})]})})})]},a.id))})]})})]},b)),(0,h.jsxs)("div",{className:"flex gap-1 mt-2",children:[(0,h.jsx)("input",{className:"flex-1 bg-gray-800 border border-gray-700 rounded px-2 py-1 text-gray-200",placeholder:"New event ID...",value:m,onChange:a=>n(a.target.value),onKeyDown:a=>{"Enter"===a.key&&m.trim()&&(b({id:m.trim()}),n(""))}}),(0,h.jsx)("button",{onClick:()=>{m.trim()&&(b({id:m.trim()}),n(""))},className:"bg-blue-600 hover:bg-blue-500 text-white px-2 py-1 rounded",children:"+"})]})]})}function bN(){let a=bv(a=>a.definition.settings),b=bv(a=>a.definition.settings.context),c=bv(a=>a.updateSettings);return(0,h.jsxs)("div",{className:"p-3 space-y-3 text-sm",children:[(0,h.jsx)("h3",{className:"text-xs font-semibold text-gray-400",children:"Machine Settings"}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Namespace"}),(0,h.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:a.namespace,onChange:a=>c({namespace:a.target.value})})]}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Name"}),(0,h.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:a.name??"",onChange:a=>c({name:a.target.value||void 0})})]}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Description"}),(0,h.jsx)("textarea",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 h-12",value:a.description??"",onChange:a=>c({description:a.target.value||void 0})})]}),(0,h.jsxs)("label",{className:"flex items-center gap-2 text-sm text-gray-300",children:[(0,h.jsx)("input",{type:"checkbox",checked:a.asynchronous,onChange:a=>c({asynchronous:a.target.checked}),className:"rounded bg-gray-800 border-gray-600"}),"Asynchronous"]}),(0,h.jsx)("hr",{className:"border-gray-800"}),(0,h.jsx)("h4",{className:"text-xs font-semibold text-gray-500",children:"Context"}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Context Class"}),(0,h.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200",value:b?.class??"",placeholder:"e.g. MyStateMachineContext",onChange:a=>c({context:{...b,class:a.target.value||void 0}})})]}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Base Class"}),(0,h.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200",value:b?.baseClass??"",placeholder:"e.g. Context",onChange:a=>c({context:{...b,baseClass:a.target.value||void 0}})})]}),(0,h.jsx)("hr",{className:"border-gray-800"}),(0,h.jsx)("h4",{className:"text-xs font-semibold text-gray-500",children:"Imports"}),(0,h.jsx)("textarea",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 h-16 font-mono",value:(a.imports??[]).join("\n"),placeholder:"One import per line",onChange:a=>c({imports:a.target.value?a.target.value.split("\n"):[]})}),(0,h.jsx)("hr",{className:"border-gray-800"}),(0,h.jsx)("h4",{className:"text-xs font-semibold text-gray-500",children:"Object References"}),(0,h.jsx)("textarea",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 h-12 font-mono",value:(a.objects??[]).map(a=>`${a.instance}: ${a.class}`).join("\n"),placeholder:"instance: Class (one per line)",onChange:a=>{c({objects:a.target.value.split("\n").filter(a=>a.includes(":")).map(a=>{let[b,c]=a.split(":").map(a=>a.trim());return{instance:b,class:c}})})}}),(0,h.jsx)("hr",{className:"border-gray-800"}),(0,h.jsx)("h4",{className:"text-xs font-semibold text-gray-500",children:"Code Generation"}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Target Language"}),(0,h.jsxs)("select",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200",value:a.targetLanguage??"python",onChange:a=>c({targetLanguage:a.target.value}),children:[(0,h.jsx)("option",{value:"python",children:"Python"}),(0,h.jsx)("option",{value:"typescript",children:"TypeScript"}),(0,h.jsx)("option",{value:"csharp",children:"C#"})]})]})]})}function bO(){let a=bv(a=>a.errors),b=bv(a=>a.validate),c=bv(a=>a.select);return(0,h.jsxs)("div",{className:"p-3",children:[(0,h.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,h.jsxs)("h3",{className:"text-xs font-semibold text-gray-400",children:["Validation ",a.length>0&&(0,h.jsxs)("span",{className:"text-red-500",children:["(",a.length,")"]})]}),(0,h.jsx)("button",{onClick:()=>b(),className:"text-xs bg-gray-700 hover:bg-gray-600 text-gray-300 px-2 py-0.5 rounded",children:"Re-check"})]}),0===a.length?(0,h.jsxs)("div",{className:"flex items-center gap-2 text-green-500 text-xs",children:[(0,h.jsx)("span",{children:"✓"}),(0,h.jsx)("span",{children:"Definition is valid"})]}):(0,h.jsx)("div",{className:"space-y-0.5",children:a.map((a,b)=>(0,h.jsxs)("div",{className:`flex items-start gap-1.5 text-[13px] py-2.5 border-b border-gray-800/50 md:text-xs md:py-1 ${a.element?"cursor-pointer hover:bg-gray-800/30":""}`,onClick:()=>{a.element&&c("state",a.element)},title:a.element?`Click to select "${a.element}"`:void 0,children:[(0,h.jsx)("span",{className:`font-mono text-[10px] mt-0.5 ${"error"===a.severity?"text-red-600":"text-yellow-600"}`,children:a.ruleId}),(0,h.jsx)("span",{className:`flex-1 ${"error"===a.severity?"text-red-400":"text-yellow-400"}`,children:a.message}),a.element&&(0,h.jsxs)("span",{className:"text-gray-600 text-[10px]",children:["→ ",a.element]})]},b))})]})}var bP=a.i(41455);function bQ(){let a=(0,bP.useRequestedDoc)(),[b,c]=(0,i.useState)(!1),[d,e]=(0,i.useState)(""),[f,g]=(0,i.useState)(null),[j,k]=(0,i.useState)([]),[l,m]=(0,i.useState)(null);(0,i.useEffect)(()=>{if(!b)return;let a=!0;return m(null),fetch("/api/docs",{cache:"no-store"}).then(a=>a.ok?a.json():Promise.reject(Error(`HTTP ${a.status}`))).then(b=>{a&&(g(b.docs??[]),k(b.roots??[]))}).catch(b=>{a&&(g([]),m(b.message))}),()=>{a=!1}},[b]);let n=a=>{c(!1),e(""),(0,bP.navigateToDoc)(a)},o=new Set((f??[]).map(a=>a.path)),p=b?(function(){try{let a=[];for(let b=0;b<window.localStorage.length;b++){let c=window.localStorage.key(b);c?.startsWith(bG)&&a.push(c.slice(bG.length))}return a.sort()}catch{return[]}})().filter(b=>b.startsWith("/")&&b!==a&&!o.has(b)):[],q=(f??[]).filter(b=>b.path!==a),r=d.trim().toLowerCase(),s=r?q.filter(a=>a.path.toLowerCase().includes(r)):q,t="block w-full truncate rounded px-1.5 py-1 text-left text-xs text-gray-300 hover:bg-gray-800";return(0,h.jsxs)("span",{className:"relative inline-flex",children:[(0,h.jsx)("button",{onClick:()=>c(a=>!a),className:"toolbar-btn",title:a?`Document: ${a}`:"Switch document",children:"⇄"}),b&&(0,h.jsxs)("div",{className:"absolute left-0 top-full z-50 mt-1 w-80 rounded border border-gray-700 bg-gray-900 p-2 shadow-lg",children:[(0,h.jsx)("div",{className:"mb-1 text-[10px] uppercase tracking-wide text-gray-500",children:"switch document"}),(0,h.jsxs)("form",{onSubmit:a=>{a.preventDefault();let b=d.trim();if(b){if(1===s.length)return n(s[0].path);if(b.startsWith("/"))return n(b)}},className:"mb-1 flex gap-1",children:[(0,h.jsx)("input",{value:d,onChange:a=>e(a.target.value),placeholder:null===f?"loading…":"filter, or /absolute/path.json",className:"min-w-0 flex-1 rounded border border-gray-700 bg-gray-950 px-1.5 py-1 text-xs text-gray-200 placeholder:text-gray-600"}),(0,h.jsx)("button",{type:"submit",className:"toolbar-btn",title:"Open",children:"→"})]}),(0,h.jsxs)("div",{className:"max-h-64 overflow-y-auto",children:[a&&(0,h.jsx)("button",{onClick:()=>n(null),className:t,title:"Return to the default project file",children:"⌂ default document"}),s.map(a=>(0,h.jsxs)("button",{onClick:()=>n(a.path),className:t,title:a.path,children:[a.name,(0,h.jsx)("span",{className:"ml-1 text-[10px] text-gray-600",children:a.dir})]},a.path)),p.length>0&&(0,h.jsxs)("div",{className:"mt-1 border-t border-gray-800 pt-1",children:[(0,h.jsx)("div",{className:"px-1.5 pb-0.5 text-[10px] uppercase tracking-wide text-gray-600",children:"recent"}),p.map(a=>(0,h.jsxs)("button",{onClick:()=>n(a),className:t,title:a,children:[a.split("/").pop(),(0,h.jsx)("span",{className:"ml-1 text-[10px] text-gray-600",children:a})]},a))]}),null!==f&&0===s.length&&0===p.length&&(0,h.jsx)("div",{className:"px-1.5 py-1 text-[11px] text-gray-500",children:r?"nothing matches":"no other documents here"})]}),j.length>0&&(0,h.jsxs)("div",{className:"mt-1 truncate border-t border-gray-800 pt-1 text-[10px] text-gray-600",children:["paths are as the server sees them: ",j.join(", ")]}),l&&(0,h.jsxs)("div",{className:"mt-1 text-[10px] text-gray-600",children:["this server does not list documents (",l,") — type a path"]})]})]})}function bR(){let a=bv(a=>a.presence),[b,c]=(0,i.useState)(!1);if(0===a.length)return null;let d=new Map;for(let b of a)d.set(b.role,(d.get(b.role)??0)+1);let e=[...d].map(([a,b])=>b>1?`${a} \xd7${b}`:a).join(" · ");return(0,h.jsxs)("span",{className:"relative inline-flex",children:[(0,h.jsxs)("button",{onClick:()=>c(a=>!a),className:"toolbar-btn inline-flex items-center gap-1.5",title:`Connected: ${e}`,"aria-expanded":b,"aria-label":`${a.length} connected: ${e}`,children:[(0,h.jsx)("span",{className:"flex -space-x-1",children:a.slice(0,4).map(a=>(0,h.jsx)("span",{className:"inline-block h-2 w-2 rounded-full ring-1 ring-gray-900",style:{backgroundColor:a.color??s(a.clientId)}},a.clientId))}),(0,h.jsx)("span",{className:"tabular-nums",children:a.length})]}),b&&(0,h.jsxs)("div",{className:"absolute left-0 top-full z-50 mt-1 max-h-64 w-56 overflow-y-auto rounded border border-gray-700 bg-gray-900 p-2 shadow-lg",children:[(0,h.jsxs)("div",{className:"mb-1 text-[10px] uppercase tracking-wide text-gray-500",children:["connected · ",e]}),a.map(a=>(0,h.jsxs)("div",{className:"flex items-center gap-1.5 rounded px-1 py-1 text-xs text-gray-300",title:a.clientId,children:[(0,h.jsx)("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full",style:{backgroundColor:a.color??s(a.clientId)}}),(0,h.jsx)("span",{className:"shrink-0",children:a.role}),a.name&&(0,h.jsx)("span",{className:"truncate text-gray-500",children:a.name})]},a.clientId))]})]})}function bS(){let a=bv(a=>a.definition),b=bv(a=>a.fileName),c=bv(a=>a.docPath),d=bv(a=>a.dirty),e=bv(a=>a.loadFromJson),f=bv(a=>a.exportJson),g=bv(a=>a.addState),j=bv(a=>a.validate),k=bv(a=>a.showCodePreview),l=bv(a=>a.setShowCodePreview),m=bv(a=>a.setGeneratedCode),n=bv(a=>a.drawMode),o=bv(a=>a.setDrawMode),p=bv(a=>a.arrangeLayout),q=bv(a=>a.undo),r=bv(a=>a.redo),s=bv(a=>a.undoStack),t=bv(a=>a.redoStack),u=bv(a=>a.remoteStatus),v=bv(a=>a.remoteMessage),w=bv(a=>a.setRemoteStatus),x=bv(a=>a.setRemoteMtime),y=bv(a=>a.applyRemote),z=(0,bP.useRequestedDoc)(),A=(0,i.useRef)(null),[B,C]=(0,i.useState)(!1),[D,E]=(0,i.useState)(""),[F,G]=(0,i.useState)(!1),[H,I]=(0,i.useState)("png"),[J,K]=(0,i.useState)(!1),[L,M]=(0,i.useState)(null),[N,O]=(0,i.useState)(null),P=async()=>{let a=f();G(!0);try{let b=await fetch(`/api/file${(0,bP.docQuery)(z)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:a})});if(b.ok){let a=await b.json();x(a.mtime),bv.setState({dirty:!1}),w("synced",null)}else{let a=await b.json().catch(()=>({error:"unknown"}));w("error",`Save failed: ${a.error??b.statusText}`)}}catch(a){w("error",`Save failed: ${a}`)}finally{G(!1)}},Q=async()=>{K(!0),M(null);try{let d=await bF(H,{definition:a,docPath:c,fileName:b});O(d)}catch(a){M(a instanceof Error?a.message:String(a))}finally{K(!1)}},R=async()=>{try{let a=await fetch(`/api/file${(0,bP.docQuery)(z)}`,{cache:"no-store"});if(!a.ok)return void w("error","Reload failed");let b=await a.json();b.exists&&b.content?y(b.content,b.mtime,b.path.split("/").pop()):w("idle",`No file at ${b.path}`)}catch(a){w("error",`Reload failed: ${a}`)}},S=()=>{D.trim()&&(g(null,{name:D.trim(),kind:"normal"}),E(""),C(!1))},[T,U]=(0,i.useState)("python"),V=async()=>{try{let a=await fetch("/api/rispec",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(a.ok){let b=await a.json();m(b.rispec)}else{let b=await a.json().catch(()=>({error:"Unknown"}));m(`# RISE rispec generation failed
|
|
6
|
+
`)],{type:`${bD[a]};charset=utf-8`})}else{let b=function(a={}){let b="u"<typeof document?null:document.getElementById(bz);if(!b)return null;let c=function(a){let b=a.querySelector(":scope > g");if(!b)return null;try{let a=b.getBBox();return a.width>0&&a.height>0?a:null}catch{return null}}(b);if(!c)return null;let d=a.padding??48,e=a.background??bA,f=Math.round(c.x-d),g=Math.round(c.y-d),h=Math.round(c.width+2*d),i=Math.round(c.height+2*d),j=b.cloneNode(!0);j.removeAttribute("id"),j.removeAttribute("class"),j.removeAttribute("style"),j.setAttribute("xmlns","http://www.w3.org/2000/svg"),j.setAttribute("width",String(h)),j.setAttribute("height",String(i)),j.setAttribute("viewBox",`${f} ${g} ${h} ${i}`),j.setAttribute("font-family","ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif"),function a(b){for(let c of Array.from(b.children)){if("transparent"===c.getAttribute("fill")||"transparent"===c.getAttribute("stroke")){c.remove();continue}c.removeAttribute("class"),c.removeAttribute("style"),a(c)}}(j);let k=j.querySelector(":scope > g");k?.removeAttribute("transform");let l=document.createElementNS("http://www.w3.org/2000/svg","rect");return l.setAttribute("x",String(f)),l.setAttribute("y",String(g)),l.setAttribute("width",String(h)),l.setAttribute("height",String(i)),l.setAttribute("fill",e),j.insertBefore(l,j.firstChild),new XMLSerializer().serializeToString(j)}(c);if(!b)throw Error("nothing on the board to export yet");g="svg"===a?new Blob([b],{type:`${bD.svg};charset=utf-8`}):await (f=c.scale??2,new Promise((c,d)=>{let e=b.match(/width="(\d+)"\s+height="(\d+)"/),g=e?Number(e[1]):1200,h=e?Number(e[2]):800,i=URL.createObjectURL(new Blob([b],{type:"image/svg+xml;charset=utf-8"})),j=new Image;j.onload=()=>{URL.revokeObjectURL(i);let b=document.createElement("canvas");b.width=Math.max(1,Math.round(g*f)),b.height=Math.max(1,Math.round(h*f));let e=b.getContext("2d");e?(e.fillStyle=bA,e.fillRect(0,0,b.width,b.height),e.drawImage(j,0,0,b.width,b.height),b.toBlob(a=>a?c(a):d(Error("the canvas produced no image")),bD[a],"jpeg"===a?.92:void 0)):d(Error("this browser gave no 2d context to draw into"))},j.onerror=()=>{URL.revokeObjectURL(i),d(Error("the browser could not read the serialized board"))},j.src=i}))}let h=function({doc:a,machine:b,format:c,at:d}){let e,f,g=Q(b??"")||Q(a?(a.split(/[/\\]/).pop()??a).replace(/\.smdf\.json$/i,"").replace(/\.json$/i,""):"")||"statemachine",h=a&&(e=a.match(/(?:^|[/\\-])ep(?:isode)?-?(\d{2,4})(?:[/\\-]|$)/i))?`ep${e[1]}`:null,i=h?`${h}--`:"";return`${i}${g}--${(f=a=>String(a).padStart(2,"0"))(d.getFullYear()%100)+f(d.getMonth()+1)+f(d.getDate())+f(d.getHours())+f(d.getMinutes())+f(d.getSeconds())}.${c}`}({doc:b.docPath??b.fileName??null,machine:b.definition?.settings?.name??null,format:bE[a]??String(a),at:(void 0)??new Date}),i=URL.createObjectURL(g),j=document.createElement("a");return j.href=i,j.download=h,j.click(),URL.revokeObjectURL(i),h}let bG="stateloom.layout.v1:";async function bH(){try{let{requestedDoc:b,docQuery:c}=await a.A(65614),d=await fetch(`/api/file${c(b())}`,{cache:"no-store"});if(d.ok){let a=(await d.json())?.path;if("string"==typeof a&&a.length>0)return a}}catch{}return bv.getState().fileName??"untitled"}function bI(){let a,b,c=bv(a=>a.definition),d=bv(a=>a.layout),e=bv(a=>a.selection),f=bv(a=>a.select),g=bv(a=>a.clearSelection),j=bv(a=>a.setStatePosition),k=bv(a=>a.drawMode),l=bv(a=>a.drawSource),m=bv(a=>a.setDrawSource),n=bv(a=>a.setDrawMode),o=bv(a=>a.addTransition),p=bv(a=>a.showContextMenu),q=bv(a=>a.removeState),r=bv(a=>a.undo),s=bv(a=>a.redo),t=bv(a=>a.errors),u=bv(a=>a.navigationPath),v=bv(a=>a.navigateInto),w=bv(a=>a.navigateUp),y=bv(a=>a.activeStates),z=bv(a=>a.viewport),A=bv(a=>a.setViewport);a=(0,i.useRef)(!1),b=(0,i.useRef)(null),(0,i.useEffect)(()=>{let c=!1,d=null;(async()=>{let d=await bH();if(c)return;b.current=d;let e=null;e&&bv.getState().hydrateLayout(e.positions,e.viewport),a.current=!0})();let e=bv.subscribe((c,e)=>{a.current&&b.current&&(c.layout!==e.layout||c.viewport!==e.viewport)&&(d&&clearTimeout(d),d=setTimeout(()=>{let a=bv.getState();b.current,function(a,b){let c={};for(let[d,e]of Object.entries(a)){let a=b[d];a&&(e.x!==a.x||e.y!==a.y||e.width!==a.width||e.height!==a.height)&&(c[d]=e)};}(a.layout.positions,x(a.definition)),a.viewport},300))});return()=>{c=!0,d&&clearTimeout(d),e()}},[]);let B=u.slice(1);return(0,h.jsx)($,{definition:c,positions:d.positions,path:B,rootLabel:u[0],viewport:z,onViewportChange:A,selection:{kind:"state"===e.kind||"transition"===e.kind?e.kind:null,id:e.id},activeStates:y,errorElements:t.flatMap(a=>a.element?[a.element]:[]),drawMode:"transition"===k?"transition":"select",drawSource:l,svgId:bz,pinchOwner:bw,emptyHint:"Right-click to add a state, or load a .smdf.json file",onSelect:(a,b)=>{"state"!==a||"transition"!==k||l?f(a,b):m(b)},onClearSelection:g,onStateMove:j,onNavigateInto:v,onNavigateTo:a=>w(a),onContextMenu:(a,b,c)=>p(a,b,"state"===c.kind?{kind:"state",id:c.id}:{kind:"canvas"}),onCreateTransition:(a,b,c)=>{o(a,{event:c,nextState:b}),m(null),n("select")},onCancelDraw:()=>{n("select"),m(null)},onDeleteState:a=>{q(a),g()},onUndo:r,onRedo:s})}function bJ({label:a,actions:b,onChange:c}){let d=(a,d)=>c(b.map((b,c)=>c===a?{...b,...d}:b));return(0,h.jsxs)("div",{children:[(0,h.jsxs)("div",{className:"flex items-center justify-between",children:[(0,h.jsx)("span",{className:"text-xs font-medium text-gray-500",children:a}),(0,h.jsx)("button",{onClick:()=>c([...b,{action:"code",code:""}]),className:"text-xs text-blue-500 hover:text-blue-400",children:"+ action"})]}),b.map((a,e)=>(0,h.jsxs)("div",{className:"flex items-start gap-1 mt-1",children:[(0,h.jsxs)("select",{className:"bg-gray-800 border border-gray-700 rounded px-1 py-0.5 text-xs text-gray-200",value:a.action,onChange:a=>d(e,{action:a.target.value}),children:[(0,h.jsx)("option",{value:"code",children:"Code"}),(0,h.jsx)("option",{value:"timerStart",children:"Timer Start"}),(0,h.jsx)("option",{value:"timerStop",children:"Timer Stop"})]}),"code"===a.action?(0,h.jsx)("textarea",{className:"flex-1 bg-gray-800 border border-gray-700 rounded px-1 py-0.5 text-xs text-gray-200 h-10 font-mono",value:a.code??"",placeholder:"// action code...",onChange:a=>d(e,{code:a.target.value})}):(0,h.jsx)("input",{className:"flex-1 bg-gray-800 border border-gray-700 rounded px-1 py-0.5 text-xs text-gray-200",value:a.name??"",placeholder:"Timer name",onChange:a=>d(e,{name:a.target.value})}),(0,h.jsx)("button",{onClick:()=>c(b.filter((a,b)=>b!==e)),className:"text-red-600 hover:text-red-400 text-xs mt-0.5",children:"✕"})]},e)),0===b.length&&(0,h.jsx)("span",{className:"text-xs text-gray-700 italic",children:"none"})]})}function bK(){let a=bv(a=>a.definition),b=bv(a=>a.selection),c=bv(a=>a.updateState),d=bv(a=>a.removeState);bv(a=>a.addAction),bv(a=>a.removeAction);let e=bv(a=>a.updateTransition),f=bv(a=>a.removeTransition);if(!b.kind||!b.id)return(0,h.jsx)("div",{className:"p-3 text-xs text-gray-500",children:"Select a state or transition to edit its properties."});let g=(a,b)=>{if(a.name===b)return a;for(let c of a.states??[]){let a=g(c,b);if(a)return a}return null};if("state"===b.kind){let e=g(a.state,b.id);if(!e)return(0,h.jsx)("div",{className:"p-3 text-gray-500 text-xs",children:"State not found"});let i=e.onEntry?.actions??[],j=e.onExit?.actions??[];return(0,h.jsxs)("div",{className:"p-3 space-y-3 text-sm md:overflow-y-auto md:max-h-[calc(100vh-160px)]",children:[(0,h.jsxs)("h3",{className:"text-xs font-semibold text-gray-400",children:["State: ",e.name]}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Name"}),(0,h.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:e.name,onChange:a=>c(b.id,{name:a.target.value})})]}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Kind"}),(0,h.jsxs)("select",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:e.kind??"normal",onChange:a=>c(b.id,{kind:a.target.value}),children:[(0,h.jsx)("option",{value:"normal",children:"Normal"}),(0,h.jsx)("option",{value:"final",children:"Final"}),(0,h.jsx)("option",{value:"history",children:"History"})]})]}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Description"}),(0,h.jsx)("textarea",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 h-12",value:e.description??"",onChange:a=>c(b.id,{description:a.target.value||void 0})})]}),(0,h.jsx)(bJ,{label:"▸ onEntry Actions",actions:i,onChange:a=>c(b.id,{onEntry:{actions:a}})}),(0,h.jsx)(bJ,{label:"◂ onExit Actions",actions:j,onChange:a=>c(b.id,{onExit:{actions:a}})}),(0,h.jsxs)("div",{children:[(0,h.jsx)("span",{className:"text-xs font-medium text-gray-500",children:"Transitions"}),(e.transitions??[]).map((a,c)=>(0,h.jsxs)("div",{className:"flex items-center gap-1 text-xs text-gray-400 py-1 border-b border-gray-800/50",children:[(0,h.jsxs)("span",{className:"flex-1",children:[a.event," → ",a.nextState??"(internal)"]}),a.condition&&(0,h.jsxs)("span",{className:"text-gray-600",children:["[",a.condition,"]"]}),(0,h.jsx)("button",{onClick:()=>f(b.id,c),className:"text-red-600 hover:text-red-400",children:"✕"})]},c)),(e.transitions?.length??0)===0&&(0,h.jsx)("span",{className:"text-xs text-gray-700 italic",children:"none"})]}),(0,h.jsx)("button",{onClick:()=>d(b.id),className:"text-red-500 hover:text-red-400 text-xs mt-2",children:"🗑 Delete State"})]})}if("transition"===b.kind){let[c,d]=b.id.split(":"),i=parseInt(d,10),j=g(a.state,c),k=j?.transitions?.[i];if(!k)return(0,h.jsx)("div",{className:"p-3 text-gray-500 text-xs",children:"Transition not found"});let l=bs(a),m=(function a(b){let c=[b];for(let d of b.states??[])c.push(...a(d));return c})(a.state).map(a=>a.name).filter(a=>"Root"!==a);return(0,h.jsxs)("div",{className:"p-3 space-y-3 text-sm",children:[(0,h.jsx)("h3",{className:"text-xs font-semibold text-gray-400",children:"Transition"}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Event"}),(0,h.jsx)("select",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:k.event,onChange:a=>e(c,i,{event:a.target.value}),children:l.map(a=>(0,h.jsx)("option",{value:a,children:a},a))})]}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Target State"}),(0,h.jsxs)("select",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:k.nextState??"",onChange:a=>e(c,i,{nextState:a.target.value||void 0}),children:[(0,h.jsx)("option",{value:"",children:"(internal transition)"}),m.map(a=>(0,h.jsx)("option",{value:a,children:a},a))]})]}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Condition (guard)"}),(0,h.jsx)("textarea",{rows:3,className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200 resize-y leading-snug",value:k.condition??"",onChange:a=>e(c,i,{condition:a.target.value||void 0})})]}),(0,h.jsx)("button",{onClick:()=>f(c,i),className:"text-red-500 hover:text-red-400 text-xs",children:"🗑 Delete Transition"})]})}return null}let bL=["string","int","float","bool","object"];function bM(){let a=bv(a=>a.definition),b=bv(a=>a.addEvent),c=bv(a=>a.updateEvent),d=bv(a=>a.removeEvent),e=bv(a=>a.addParameter),f=bv(a=>a.removeParameter),g=bv(a=>a.updateParameter),j=bv(a=>a.updateEventSource),k=bv(a=>a.select),l=bv(a=>a.selection),[m,n]=(0,i.useState)(""),[o,p]=(0,i.useState)(null),[q,r]=(0,i.useState)(null);return(0,h.jsxs)("div",{className:"p-3 text-sm",children:[a.events.map((a,b)=>(0,h.jsxs)("div",{className:"mb-3",children:[(0,h.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,h.jsx)("span",{className:"text-xs font-semibold text-gray-500",children:"Source:"}),(0,h.jsx)("input",{className:"flex-1 bg-transparent border-b border-gray-700 text-xs text-gray-300 px-1 py-0.5 focus:border-blue-500 outline-none",value:a.name,onChange:a=>j(b,{name:a.target.value})}),void 0!==a.feeder&&(0,h.jsx)("input",{className:"w-24 bg-transparent border-b border-gray-700 text-xs text-gray-400 px-1 py-0.5 focus:border-blue-500 outline-none",value:a.feeder??"",placeholder:"Feeder...",onChange:a=>j(b,{feeder:a.target.value||void 0})}),void 0===a.feeder&&(0,h.jsx)("button",{className:"text-xs text-gray-600 hover:text-gray-400",title:"Add feeder class",onClick:()=>j(b,{feeder:`${a.name}Feeder`}),children:"+feeder"})]}),(0,h.jsx)("div",{className:"-mx-1 overflow-x-auto px-1",children:(0,h.jsxs)("table",{className:"w-full text-xs",children:[(0,h.jsx)("thead",{children:(0,h.jsxs)("tr",{className:"text-gray-600 border-b border-gray-800",children:[(0,h.jsx)("th",{className:"text-left py-1 font-medium",children:"ID"}),(0,h.jsx)("th",{className:"text-left py-1 font-medium",children:"Description"}),(0,h.jsx)("th",{className:"text-left py-1 font-medium",children:"Params"}),(0,h.jsx)("th",{className:"w-6"})]})}),(0,h.jsx)("tbody",{children:(a.events??[]).map(a=>(0,h.jsxs)(i.Fragment,{children:[(0,h.jsxs)("tr",{className:`border-b border-gray-800/50 hover:bg-gray-800/30 cursor-pointer ${"event"===l.kind&&l.id===a.id?"bg-blue-900/30":""}`,onClick:()=>{k("event",a.id),p(o===a.id?null:a.id)},children:[(0,h.jsx)("td",{className:"py-1 pr-1",children:q===a.id?(0,h.jsx)("input",{autoFocus:!0,className:"w-full bg-gray-800 border border-gray-700 rounded px-1 text-gray-200",value:a.id,onChange:b=>c(a.id,{id:b.target.value}),onBlur:()=>r(null),onKeyDown:a=>"Enter"===a.key&&r(null),onClick:a=>a.stopPropagation()}):(0,h.jsx)("span",{className:"text-gray-300",onDoubleClick:b=>{b.stopPropagation(),r(a.id)},children:a.id})}),(0,h.jsx)("td",{className:"py-1 pr-1 text-gray-500 truncate max-w-[80px]",children:a.description??"—"}),(0,h.jsx)("td",{className:"py-1 text-gray-500",children:(a.parameters?.length??0)>0?a.parameters.map(a=>`${a.name}:${a.type}`).join(", "):"—"}),(0,h.jsx)("td",{className:"py-1",children:(0,h.jsx)("button",{onClick:b=>{b.stopPropagation(),d(a.id)},className:"text-red-600 hover:text-red-400",children:"✕"})})]}),o===a.id&&(0,h.jsx)("tr",{children:(0,h.jsx)("td",{colSpan:4,className:"py-2 px-1 bg-gray-900/50",children:(0,h.jsxs)("div",{className:"space-y-2",children:[(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-gray-600",children:"Description"}),(0,h.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-0.5 text-gray-200 mt-0.5",value:a.description??"",onChange:b=>c(a.id,{description:b.target.value||void 0})})]}),(0,h.jsxs)("div",{children:[(0,h.jsx)("span",{className:"text-gray-600",children:"Parameters"}),(a.parameters??[]).map((b,c)=>(0,h.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,h.jsx)("input",{className:"flex-1 bg-gray-800 border border-gray-700 rounded px-1 py-0.5 text-gray-200",value:b.name,placeholder:"name",onChange:b=>g(a.id,c,{name:b.target.value})}),(0,h.jsx)("select",{className:"bg-gray-800 border border-gray-700 rounded px-1 py-0.5 text-gray-200",value:b.type,onChange:b=>g(a.id,c,{type:b.target.value}),children:bL.map(a=>(0,h.jsx)("option",{value:a,children:a},a))}),(0,h.jsx)("button",{onClick:()=>f(a.id,c),className:"text-red-600 hover:text-red-400",children:"✕"})]},c)),(0,h.jsx)("button",{className:"text-blue-500 hover:text-blue-400 mt-1",onClick:()=>e(a.id,{name:"param",type:"string"}),children:"+ parameter"})]}),(0,h.jsxs)("div",{className:"mt-1",children:[(0,h.jsx)("span",{className:"text-gray-600",children:"Generated method:"}),(0,h.jsxs)("code",{className:"block bg-gray-800 rounded px-2 py-1 text-green-400 mt-0.5 font-mono",children:["on_",a.id.toLowerCase(),"(context",(a.parameters??[]).map(a=>`, ${a.name}: ${a.type}`).join(""),")"]})]})]})})})]},a.id))})]})})]},b)),(0,h.jsxs)("div",{className:"flex gap-1 mt-2",children:[(0,h.jsx)("input",{className:"flex-1 bg-gray-800 border border-gray-700 rounded px-2 py-1 text-gray-200",placeholder:"New event ID...",value:m,onChange:a=>n(a.target.value),onKeyDown:a=>{"Enter"===a.key&&m.trim()&&(b({id:m.trim()}),n(""))}}),(0,h.jsx)("button",{onClick:()=>{m.trim()&&(b({id:m.trim()}),n(""))},className:"bg-blue-600 hover:bg-blue-500 text-white px-2 py-1 rounded",children:"+"})]})]})}function bN(){let a=bv(a=>a.definition.settings),b=bv(a=>a.definition.settings.context),c=bv(a=>a.updateSettings);return(0,h.jsxs)("div",{className:"p-3 space-y-3 text-sm",children:[(0,h.jsx)("h3",{className:"text-xs font-semibold text-gray-400",children:"Machine Settings"}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Namespace"}),(0,h.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:a.namespace,onChange:a=>c({namespace:a.target.value})})]}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Name"}),(0,h.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:a.name??"",onChange:a=>c({name:a.target.value||void 0})})]}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Description"}),(0,h.jsx)("textarea",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 h-12",value:a.description??"",onChange:a=>c({description:a.target.value||void 0})})]}),(0,h.jsxs)("label",{className:"flex items-center gap-2 text-sm text-gray-300",children:[(0,h.jsx)("input",{type:"checkbox",checked:a.asynchronous,onChange:a=>c({asynchronous:a.target.checked}),className:"rounded bg-gray-800 border-gray-600"}),"Asynchronous"]}),(0,h.jsx)("hr",{className:"border-gray-800"}),(0,h.jsx)("h4",{className:"text-xs font-semibold text-gray-500",children:"Context"}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Context Class"}),(0,h.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200",value:b?.class??"",placeholder:"e.g. MyStateMachineContext",onChange:a=>c({context:{...b,class:a.target.value||void 0}})})]}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Base Class"}),(0,h.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200",value:b?.baseClass??"",placeholder:"e.g. Context",onChange:a=>c({context:{...b,baseClass:a.target.value||void 0}})})]}),(0,h.jsx)("hr",{className:"border-gray-800"}),(0,h.jsx)("h4",{className:"text-xs font-semibold text-gray-500",children:"Imports"}),(0,h.jsx)("textarea",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 h-16 font-mono",value:(a.imports??[]).join("\n"),placeholder:"One import per line",onChange:a=>c({imports:a.target.value?a.target.value.split("\n"):[]})}),(0,h.jsx)("hr",{className:"border-gray-800"}),(0,h.jsx)("h4",{className:"text-xs font-semibold text-gray-500",children:"Object References"}),(0,h.jsx)("textarea",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 h-12 font-mono",value:(a.objects??[]).map(a=>`${a.instance}: ${a.class}`).join("\n"),placeholder:"instance: Class (one per line)",onChange:a=>{c({objects:a.target.value.split("\n").filter(a=>a.includes(":")).map(a=>{let[b,c]=a.split(":").map(a=>a.trim());return{instance:b,class:c}})})}}),(0,h.jsx)("hr",{className:"border-gray-800"}),(0,h.jsx)("h4",{className:"text-xs font-semibold text-gray-500",children:"Code Generation"}),(0,h.jsxs)("label",{className:"block",children:[(0,h.jsx)("span",{className:"text-xs text-gray-500",children:"Target Language"}),(0,h.jsxs)("select",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200",value:a.targetLanguage??"python",onChange:a=>c({targetLanguage:a.target.value}),children:[(0,h.jsx)("option",{value:"python",children:"Python"}),(0,h.jsx)("option",{value:"typescript",children:"TypeScript"}),(0,h.jsx)("option",{value:"csharp",children:"C#"})]})]})]})}function bO(){let a=bv(a=>a.errors),b=bv(a=>a.validate),c=bv(a=>a.select);return(0,h.jsxs)("div",{className:"p-3",children:[(0,h.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,h.jsxs)("h3",{className:"text-xs font-semibold text-gray-400",children:["Validation ",a.length>0&&(0,h.jsxs)("span",{className:"text-red-500",children:["(",a.length,")"]})]}),(0,h.jsx)("button",{onClick:()=>b(),className:"text-xs bg-gray-700 hover:bg-gray-600 text-gray-300 px-2 py-0.5 rounded",children:"Re-check"})]}),0===a.length?(0,h.jsxs)("div",{className:"flex items-center gap-2 text-green-500 text-xs",children:[(0,h.jsx)("span",{children:"✓"}),(0,h.jsx)("span",{children:"Definition is valid"})]}):(0,h.jsx)("div",{className:"space-y-0.5",children:a.map((a,b)=>(0,h.jsxs)("div",{className:`flex items-start gap-1.5 text-[13px] py-2.5 border-b border-gray-800/50 md:text-xs md:py-1 ${a.element?"cursor-pointer hover:bg-gray-800/30":""}`,onClick:()=>{a.element&&c("state",a.element)},title:a.element?`Click to select "${a.element}"`:void 0,children:[(0,h.jsx)("span",{className:`font-mono text-[10px] mt-0.5 ${"error"===a.severity?"text-red-600":"text-yellow-600"}`,children:a.ruleId}),(0,h.jsx)("span",{className:`flex-1 ${"error"===a.severity?"text-red-400":"text-yellow-400"}`,children:a.message}),a.element&&(0,h.jsxs)("span",{className:"text-gray-600 text-[10px]",children:["→ ",a.element]})]},b))})]})}var bP=a.i(41455);function bQ(){let a=(0,bP.useRequestedDoc)(),[b,c]=(0,i.useState)(!1),[d,e]=(0,i.useState)(""),[f,g]=(0,i.useState)(null),[j,k]=(0,i.useState)([]),[l,m]=(0,i.useState)(null),[n,o]=(0,i.useState)(null);(0,i.useEffect)(()=>{if(!b)return;let a=!0;return o(null),fetch("/api/docs",{cache:"no-store"}).then(a=>a.ok?a.json():Promise.reject(Error(`HTTP ${a.status}`))).then(b=>{a&&(g(b.docs??[]),k(b.roots??[]),m(b.current??null))}).catch(b=>{a&&(g([]),o(b.message))}),()=>{a=!1}},[b]);let p=a=>{c(!1),e(""),(0,bP.navigateToDoc)(a)},q=new Set((f??[]).map(a=>a.path)),r=b?(function(){try{let a=[];for(let b=0;b<window.localStorage.length;b++){let c=window.localStorage.key(b);c?.startsWith(bG)&&a.push(c.slice(bG.length))}return a.sort()}catch{return[]}})().filter(b=>b.startsWith("/")&&b!==a&&!q.has(b)):[],s=a??l,t=(f??[]).filter(a=>a.path!==s),u=d.trim().toLowerCase(),v=u?t.filter(a=>a.path.toLowerCase().includes(u)):t,w="block w-full truncate rounded px-1.5 py-1 text-left text-xs text-gray-300 hover:bg-gray-800";return(0,h.jsxs)("span",{className:"relative inline-flex",children:[(0,h.jsx)("button",{onClick:()=>c(a=>!a),className:"toolbar-btn",title:a?`Document: ${a}`:"Switch document",children:"⇄"}),b&&(0,h.jsxs)("div",{className:"absolute left-0 top-full z-50 mt-1 w-80 rounded border border-gray-700 bg-gray-900 p-2 shadow-lg",children:[(0,h.jsx)("div",{className:"mb-1 text-[10px] uppercase tracking-wide text-gray-500",children:"switch document"}),(0,h.jsxs)("form",{onSubmit:a=>{a.preventDefault();let b=d.trim();if(b){if(1===v.length)return p(v[0].path);if(b.startsWith("/"))return p(b)}},className:"mb-1 flex gap-1",children:[(0,h.jsx)("input",{value:d,onChange:a=>e(a.target.value),placeholder:null===f?"loading…":"filter, or /absolute/path.json",className:"min-w-0 flex-1 rounded border border-gray-700 bg-gray-950 px-1.5 py-1 text-xs text-gray-200 placeholder:text-gray-600"}),(0,h.jsx)("button",{type:"submit",className:"toolbar-btn",title:"Open",children:"→"})]}),(0,h.jsxs)("div",{className:"max-h-64 overflow-y-auto",children:[a&&(0,h.jsx)("button",{onClick:()=>p(null),className:w,title:"Return to the default project file",children:"⌂ default document"}),v.map(a=>(0,h.jsxs)("button",{onClick:()=>p(a.path),className:w,title:a.path,children:[a.name,(0,h.jsx)("span",{className:"ml-1 text-[10px] text-gray-600",children:a.dir})]},a.path)),r.length>0&&(0,h.jsxs)("div",{className:"mt-1 border-t border-gray-800 pt-1",children:[(0,h.jsx)("div",{className:"px-1.5 pb-0.5 text-[10px] uppercase tracking-wide text-gray-600",children:"recent"}),r.map(a=>(0,h.jsxs)("button",{onClick:()=>p(a),className:w,title:a,children:[a.split("/").pop(),(0,h.jsx)("span",{className:"ml-1 text-[10px] text-gray-600",children:a})]},a))]}),null!==f&&0===v.length&&0===r.length&&(0,h.jsx)("div",{className:"px-1.5 py-1 text-[11px] text-gray-500",children:u?"nothing matches":"no other documents here"})]}),j.length>0&&(0,h.jsxs)("div",{className:"mt-1 truncate border-t border-gray-800 pt-1 text-[10px] text-gray-600",children:["paths are as the server sees them: ",j.join(", ")]}),n&&(0,h.jsxs)("div",{className:"mt-1 text-[10px] text-gray-600",children:["this server does not list documents (",n,") — type a path"]})]})]})}function bR(){let a=bv(a=>a.presence),[b,c]=(0,i.useState)(!1);if(0===a.length)return null;let d=new Map;for(let b of a)d.set(b.role,(d.get(b.role)??0)+1);let e=[...d].map(([a,b])=>b>1?`${a} \xd7${b}`:a).join(" · ");return(0,h.jsxs)("span",{className:"relative inline-flex",children:[(0,h.jsxs)("button",{onClick:()=>c(a=>!a),className:"toolbar-btn inline-flex items-center gap-1.5",title:`Connected: ${e}`,"aria-expanded":b,"aria-label":`${a.length} connected: ${e}`,children:[(0,h.jsx)("span",{className:"flex -space-x-1",children:a.slice(0,4).map(a=>(0,h.jsx)("span",{className:"inline-block h-2 w-2 rounded-full ring-1 ring-gray-900",style:{backgroundColor:a.color??s(a.clientId)}},a.clientId))}),(0,h.jsx)("span",{className:"tabular-nums",children:a.length})]}),b&&(0,h.jsxs)("div",{className:"absolute left-0 top-full z-50 mt-1 max-h-64 w-56 overflow-y-auto rounded border border-gray-700 bg-gray-900 p-2 shadow-lg",children:[(0,h.jsxs)("div",{className:"mb-1 text-[10px] uppercase tracking-wide text-gray-500",children:["connected · ",e]}),a.map(a=>(0,h.jsxs)("div",{className:"flex items-center gap-1.5 rounded px-1 py-1 text-xs text-gray-300",title:a.clientId,children:[(0,h.jsx)("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full",style:{backgroundColor:a.color??s(a.clientId)}}),(0,h.jsx)("span",{className:"shrink-0",children:a.role}),a.name&&(0,h.jsx)("span",{className:"truncate text-gray-500",children:a.name})]},a.clientId))]})]})}function bS(){let a=bv(a=>a.definition),b=bv(a=>a.fileName),c=bv(a=>a.docPath),d=bv(a=>a.dirty),e=bv(a=>a.loadFromJson),f=bv(a=>a.exportJson),g=bv(a=>a.addState),j=bv(a=>a.validate),k=bv(a=>a.showCodePreview),l=bv(a=>a.setShowCodePreview),m=bv(a=>a.setGeneratedCode),n=bv(a=>a.drawMode),o=bv(a=>a.setDrawMode),p=bv(a=>a.arrangeLayout),q=bv(a=>a.undo),r=bv(a=>a.redo),s=bv(a=>a.undoStack),t=bv(a=>a.redoStack),u=bv(a=>a.remoteStatus),v=bv(a=>a.remoteMessage),w=bv(a=>a.setRemoteStatus),x=bv(a=>a.setRemoteMtime),y=bv(a=>a.applyRemote),z=(0,bP.useRequestedDoc)(),A=(0,i.useRef)(null),[B,C]=(0,i.useState)(!1),[D,E]=(0,i.useState)(""),[F,G]=(0,i.useState)(!1),[H,I]=(0,i.useState)("png"),[J,K]=(0,i.useState)(!1),[L,M]=(0,i.useState)(null),[N,O]=(0,i.useState)(null),P=async()=>{let a=f();G(!0);try{let b=await fetch(`/api/file${(0,bP.docQuery)(z)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:a})});if(b.ok){let a=await b.json();x(a.mtime),bv.setState({dirty:!1}),w("synced",null)}else{let a=await b.json().catch(()=>({error:"unknown"}));w("error",`Save failed: ${a.error??b.statusText}`)}}catch(a){w("error",`Save failed: ${a}`)}finally{G(!1)}},Q=async()=>{K(!0),M(null);try{let d=await bF(H,{definition:a,docPath:c,fileName:b});O(d)}catch(a){M(a instanceof Error?a.message:String(a))}finally{K(!1)}},R=async()=>{try{let a=await fetch(`/api/file${(0,bP.docQuery)(z)}`,{cache:"no-store"});if(!a.ok)return void w("error","Reload failed");let b=await a.json();b.exists&&b.content?y(b.content,b.mtime,b.path.split("/").pop()):w("idle",`No file at ${b.path}`)}catch(a){w("error",`Reload failed: ${a}`)}},S=()=>{D.trim()&&(g(null,{name:D.trim(),kind:"normal"}),E(""),C(!1))},[T,U]=(0,i.useState)("python"),V=async()=>{try{let a=await fetch("/api/rispec",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(a.ok){let b=await a.json();m(b.rispec)}else{let b=await a.json().catch(()=>({error:"Unknown"}));m(`# RISE rispec generation failed
|
|
7
7
|
${b.error}`)}}catch(a){m(`# RISE rispec generation failed
|
|
8
8
|
${a}`)}l(!0)},W=async()=>{let a=f();try{let b=await fetch("/api/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({definition:a,language:T})});if(b.ok){let a=await b.json();m(a.code)}else{let c=await b.json().catch(()=>({error:"Unknown error"}));m(`// Code generation failed: ${c.error}
|
|
9
9
|
// Showing definition JSON as fallback:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><!--
|
|
1
|
+
<!DOCTYPE html><!--MpwR1y8jNIjcY_QAij3pD--><html lang="en" class="dark"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover, user-scalable=no, interactive-widget=resizes-content"/><link rel="stylesheet" href="/_next/static/chunks/1cbe108679f9af04.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/662d1b0ce457c16b.js"/><script src="/_next/static/chunks/5e1795a806bd6c51.js" async=""></script><script src="/_next/static/chunks/96818f5620f039a1.js" async=""></script><script src="/_next/static/chunks/turbopack-34fc7de1568e2a7f.js" async=""></script><script src="/_next/static/chunks/7a768100bec00db1.js" async=""></script><meta name="robots" content="noindex"/><title>404: This page could not be found.</title><meta name="theme-color" content="#030712"/><meta name="color-scheme" content="dark"/><title>SMCraft Designer</title><meta name="description" content="Visual State Machine Designer"/><link rel="icon" href="/favicon.ico?favicon.0b3bf435.ico" sizes="256x256" type="image/x-icon"/><script src="/_next/static/chunks/a6dad97d9634a72d.js" noModule=""></script></head><body class="antialiased"><div hidden=""><!--$--><!--/$--></div><script>try{var s=parseFloat(localStorage.getItem("stateloom.uiScale.v1"));if(s>=0.75&&s<=1.75)document.documentElement.style.fontSize=(16*s)+"px"}catch(e){}</script><div style="font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found.</h2></div></div></div><!--$--><!--/$--><script src="/_next/static/chunks/662d1b0ce457c16b.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[88287,[\"/_next/static/chunks/7a768100bec00db1.js\"],\"default\"]\n3:I[74895,[\"/_next/static/chunks/7a768100bec00db1.js\"],\"default\"]\n4:I[51858,[\"/_next/static/chunks/7a768100bec00db1.js\"],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n7:I[51858,[\"/_next/static/chunks/7a768100bec00db1.js\"],\"ViewportBoundary\"]\n9:I[51858,[\"/_next/static/chunks/7a768100bec00db1.js\"],\"MetadataBoundary\"]\nb:I[52576,[\"/_next/static/chunks/7a768100bec00db1.js\"],\"default\"]\n:HL[\"/_next/static/chunks/1cbe108679f9af04.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"MpwR1y8jNIjcY-QAij3pD\",\"c\":[\"\",\"_not-found\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],[[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/chunks/1cbe108679f9af04.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"className\":\"dark\",\"children\":[\"$\",\"body\",null,{\"className\":\"antialiased\",\"children\":[[\"$\",\"script\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"try{var s=parseFloat(localStorage.getItem(\\\"stateloom.uiScale.v1\\\"));if(s\u003e=0.75\u0026\u0026s\u003c=1.75)document.documentElement.style.fontSize=(16*s)+\\\"px\\\"}catch(e){}\"}}],[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":404}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],[]],\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}]}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":\"$0:f:0:1:0:props:children:1:props:children:props:children:1:props:notFound:0:1:props:style\",\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":\"$0:f:0:1:0:props:children:1:props:children:props:children:1:props:notFound:0:1:props:children:props:children:1:props:style\",\"children\":404}],[\"$\",\"div\",null,{\"style\":\"$0:f:0:1:0:props:children:1:props:children:props:children:1:props:notFound:0:1:props:children:props:children:2:props:style\",\"children\":[\"$\",\"h2\",null,{\"style\":\"$0:f:0:1:0:props:children:1:props:children:props:children:1:props:notFound:0:1:props:children:props:children:2:props:children:props:style\",\"children\":\"This page could not be found.\"}]}]]}]}]],null,[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,false]},null,false,false]},null,false,false],[\"$\",\"$1\",\"h\",{\"children\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],[\"$\",\"$L7\",null,{\"children\":\"$L8\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$L9\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$La\"}]}]}],null]}],false]],\"m\":\"$undefined\",\"G\":[\"$b\",\"$undefined\"],\"S\":true}\n"])</script><script>self.__next_f.push([1,"8:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover, user-scalable=no, interactive-widget=resizes-content\"}],[\"$\",\"meta\",\"2\",{\"name\":\"theme-color\",\"content\":\"#030712\"}],[\"$\",\"meta\",\"3\",{\"name\":\"color-scheme\",\"content\":\"dark\"}]]\n"])</script><script>self.__next_f.push([1,"c:I[49310,[\"/_next/static/chunks/7a768100bec00db1.js\"],\"IconMark\"]\n6:null\na:[[\"$\",\"title\",\"0\",{\"children\":\"SMCraft Designer\"}],[\"$\",\"meta\",\"1\",{\"name\":\"description\",\"content\":\"Visual State Machine Designer\"}],[\"$\",\"link\",\"2\",{\"rel\":\"icon\",\"href\":\"/favicon.ico?favicon.0b3bf435.ico\",\"sizes\":\"256x256\",\"type\":\"image/x-icon\"}],[\"$\",\"$Lc\",\"3\",{}]]\n"])</script></body></html>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
<!DOCTYPE html><!--
|
|
2
|
-
@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">500</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">Internal Server Error.</h2></div></div></div><!--$--><!--/$--><script src="/_next/static/chunks/662d1b0ce457c16b.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[88287,[\"/_next/static/chunks/7a768100bec00db1.js\"],\"default\"]\n3:I[74895,[\"/_next/static/chunks/7a768100bec00db1.js\"],\"default\"]\n4:I[51858,[\"/_next/static/chunks/7a768100bec00db1.js\"],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n7:I[51858,[\"/_next/static/chunks/7a768100bec00db1.js\"],\"ViewportBoundary\"]\n9:I[51858,[\"/_next/static/chunks/7a768100bec00db1.js\"],\"MetadataBoundary\"]\nb:I[52576,[\"/_next/static/chunks/7a768100bec00db1.js\"],\"default\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"
|
|
1
|
+
<!DOCTYPE html><!--MpwR1y8jNIjcY_QAij3pD--><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/662d1b0ce457c16b.js"/><script src="/_next/static/chunks/5e1795a806bd6c51.js" async=""></script><script src="/_next/static/chunks/96818f5620f039a1.js" async=""></script><script src="/_next/static/chunks/turbopack-34fc7de1568e2a7f.js" async=""></script><script src="/_next/static/chunks/7a768100bec00db1.js" async=""></script><title>500: Internal Server Error.</title><link rel="icon" href="/favicon.ico?favicon.0b3bf435.ico" sizes="256x256" type="image/x-icon"/><script src="/_next/static/chunks/a6dad97d9634a72d.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}
|
|
2
|
+
@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">500</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">Internal Server Error.</h2></div></div></div><!--$--><!--/$--><script src="/_next/static/chunks/662d1b0ce457c16b.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[88287,[\"/_next/static/chunks/7a768100bec00db1.js\"],\"default\"]\n3:I[74895,[\"/_next/static/chunks/7a768100bec00db1.js\"],\"default\"]\n4:I[51858,[\"/_next/static/chunks/7a768100bec00db1.js\"],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n7:I[51858,[\"/_next/static/chunks/7a768100bec00db1.js\"],\"ViewportBoundary\"]\n9:I[51858,[\"/_next/static/chunks/7a768100bec00db1.js\"],\"MetadataBoundary\"]\nb:I[52576,[\"/_next/static/chunks/7a768100bec00db1.js\"],\"default\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"MpwR1y8jNIjcY-QAij3pD\",\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"__PAGE__\",{}]}],[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[\"$\",\"title\",null,{\"children\":\"500: Internal Server Error.\"}]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"lineHeight\":\"48px\"},\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}\\n@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"paddingRight\":23,\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\"},\"children\":\"500\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"28px\"},\"children\":\"Internal Server Error.\"}]}]]}]}]}]]}],null,[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,false]},null,false,false],[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$L7\",null,{\"children\":\"$L8\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$L9\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$La\"}]}]}],null]}],false]],\"m\":\"$undefined\",\"G\":[\"$b\",\"$undefined\"],\"S\":true}\n"])</script><script>self.__next_f.push([1,"8:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"c:I[49310,[\"/_next/static/chunks/7a768100bec00db1.js\"],\"IconMark\"]\n6:null\na:[[\"$\",\"link\",\"0\",{\"rel\":\"icon\",\"href\":\"/favicon.ico?favicon.0b3bf435.ico\",\"sizes\":\"256x256\",\"type\":\"image/x-icon\"}],[\"$\",\"$Lc\",\"1\",{}]]\n"])</script></body></html>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
${i}
|
|
3
3
|
\`\`\`
|
|
4
4
|
`:`${i}
|
|
5
|
-
`)],{type:`${tS[e]};charset=utf-8`})}else{let t=function(e={}){let t="u"<typeof document?null:document.getElementById(tw);if(!t)return null;let n=function(e){let t=e.querySelector(":scope > g");if(!t)return null;try{let e=t.getBBox();return e.width>0&&e.height>0?e:null}catch{return null}}(t);if(!n)return null;let r=e.padding??48,s=e.background??tk,i=Math.round(n.x-r),a=Math.round(n.y-r),o=Math.round(n.width+2*r),l=Math.round(n.height+2*r),c=t.cloneNode(!0);c.removeAttribute("id"),c.removeAttribute("class"),c.removeAttribute("style"),c.setAttribute("xmlns","http://www.w3.org/2000/svg"),c.setAttribute("width",String(o)),c.setAttribute("height",String(l)),c.setAttribute("viewBox",`${i} ${a} ${o} ${l}`),c.setAttribute("font-family","ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif"),function e(t){for(let n of Array.from(t.children)){if("transparent"===n.getAttribute("fill")||"transparent"===n.getAttribute("stroke")){n.remove();continue}n.removeAttribute("class"),n.removeAttribute("style"),e(n)}}(c);let d=c.querySelector(":scope > g");d?.removeAttribute("transform");let h=document.createElementNS("http://www.w3.org/2000/svg","rect");return h.setAttribute("x",String(i)),h.setAttribute("y",String(a)),h.setAttribute("width",String(o)),h.setAttribute("height",String(l)),h.setAttribute("fill",s),c.insertBefore(h,c.firstChild),new XMLSerializer().serializeToString(c)}(n);if(!t)throw Error("nothing on the board to export yet");a="svg"===e?new Blob([t],{type:`${tS.svg};charset=utf-8`}):await (i=n.scale??2,new Promise((n,r)=>{let s=t.match(/width="(\d+)"\s+height="(\d+)"/),a=s?Number(s[1]):1200,o=s?Number(s[2]):800,l=URL.createObjectURL(new Blob([t],{type:"image/svg+xml;charset=utf-8"})),c=new Image;c.onload=()=>{URL.revokeObjectURL(l);let t=document.createElement("canvas");t.width=Math.max(1,Math.round(a*i)),t.height=Math.max(1,Math.round(o*i));let s=t.getContext("2d");s?(s.fillStyle=tk,s.fillRect(0,0,t.width,t.height),s.drawImage(c,0,0,t.width,t.height),t.toBlob(e=>e?n(e):r(Error("the canvas produced no image")),tS[e],"jpeg"===e?.92:void 0)):r(Error("this browser gave no 2d context to draw into"))},c.onerror=()=>{URL.revokeObjectURL(l),r(Error("the browser could not read the serialized board"))},c.src=l}))}let o=function({doc:e,machine:t,format:n,at:r}){let s,i,a=H(t??"")||H(e?(e.split(/[/\\]/).pop()??e).replace(/\.smdf\.json$/i,"").replace(/\.json$/i,""):"")||"statemachine",o=e&&(s=e.match(/(?:^|[/\\-])ep(?:isode)?-?(\d{2,4})(?:[/\\-]|$)/i))?`ep${s[1]}`:null,l=o?`${o}--`:"";return`${l}${a}--${(i=e=>String(e).padStart(2,"0"))(r.getFullYear()%100)+i(r.getMonth()+1)+i(r.getDate())+i(r.getHours())+i(r.getMinutes())+i(r.getSeconds())}.${n}`}({doc:t.docPath??t.fileName??null,machine:t.definition?.settings?.name??null,format:t_[e]??String(e),at:(void 0)??new Date}),l=URL.createObjectURL(a),c=document.createElement("a");return c.href=l,c.download=o,c.click(),URL.revokeObjectURL(l),o}let tE="stateloom.layout.v1:";async function tR(){try{let{requestedDoc:t,docQuery:n}=await e.A(32058),r=await fetch(`/api/file${n(t())}`,{cache:"no-store"});if(r.ok){let e=(await r.json())?.path;if("string"==typeof e&&e.length>0)return e}}catch{}return tx.getState().fileName??"untitled"}function tO(){let e,t,n=tx(e=>e.definition),r=tx(e=>e.layout),s=tx(e=>e.selection),i=tx(e=>e.select),a=tx(e=>e.clearSelection),c=tx(e=>e.setStatePosition),d=tx(e=>e.drawMode),h=tx(e=>e.drawSource),u=tx(e=>e.setDrawSource),p=tx(e=>e.setDrawMode),f=tx(e=>e.addTransition),m=tx(e=>e.showContextMenu),g=tx(e=>e.removeState),x=tx(e=>e.undo),y=tx(e=>e.redo),b=tx(e=>e.errors),v=tx(e=>e.navigationPath),w=tx(e=>e.navigateInto),k=tx(e=>e.navigateUp),j=tx(e=>e.activeStates),S=tx(e=>e.viewport),_=tx(e=>e.setViewport);e=(0,l.useRef)(!1),t=(0,l.useRef)(null),(0,l.useEffect)(()=>{let n=!1,r=null;(async()=>{let r=await tR();if(n)return;t.current=r;let s=function(e){try{let t=window.localStorage.getItem(`${tE}${e}`);if(!t)return null;let n=JSON.parse(t),r={};for(let[e,t]of Object.entries(n?.positions??{}))t&&"object"==typeof t&&Number.isFinite(t.x)&&Number.isFinite(t.y)&&Number.isFinite(t.width)&&Number.isFinite(t.height)&&(r[e]=t);return{positions:r,viewport:function(e,t=I){return e?{x:Number.isFinite(e.x)?e.x:0,y:Number.isFinite(e.y)?e.y:0,scale:B(e.scale??1,t)}:{...L}}(n?.viewport)}}catch{return null}}(r);s&&tx.getState().hydrateLayout(s.positions,s.viewport),e.current=!0})();let s=tx.subscribe((n,s)=>{e.current&&t.current&&(n.layout!==s.layout||n.viewport!==s.viewport)&&(r&&clearTimeout(r),r=setTimeout(()=>{let e=tx.getState();!function(e,t,n){try{window.localStorage.setItem(`${tE}${e}`,JSON.stringify({positions:t,viewport:n,savedAt:Date.now()}))}catch{}}(t.current,function(e,t){let n={};for(let[r,s]of Object.entries(e)){let e=t[r];e&&(s.x!==e.x||s.y!==e.y||s.width!==e.width||s.height!==e.height)&&(n[r]=s)}return n}(e.layout.positions,N(e.definition)),e.viewport)},300))});return()=>{n=!0,r&&clearTimeout(r),s()}},[]);let C=v.slice(1);return(0,o.jsx)(Z,{definition:n,positions:r.positions,path:C,rootLabel:v[0],viewport:S,onViewportChange:_,selection:{kind:"state"===s.kind||"transition"===s.kind?s.kind:null,id:s.id},activeStates:j,errorElements:b.flatMap(e=>e.element?[e.element]:[]),drawMode:"transition"===d?"transition":"select",drawSource:h,svgId:tw,pinchOwner:ty,emptyHint:window.matchMedia?.("(pointer: coarse)").matches?"Press and hold to add a state, or load a .smdf.json file":"Right-click to add a state, or load a .smdf.json file",onSelect:(e,t)=>{"state"!==e||"transition"!==d||h?i(e,t):u(t)},onClearSelection:a,onStateMove:c,onNavigateInto:w,onNavigateTo:e=>k(e),onContextMenu:(e,t,n)=>m(e,t,"state"===n.kind?{kind:"state",id:n.id}:{kind:"canvas"}),onCreateTransition:(e,t,n)=>{f(e,{event:n,nextState:t}),u(null),p("select")},onCancelDraw:()=>{p("select"),u(null)},onDeleteState:e=>{g(e),a()},onUndo:x,onRedo:y})}function tM({label:e,actions:t,onChange:n}){let r=(e,r)=>n(t.map((t,n)=>n===e?{...t,...r}:t));return(0,o.jsxs)("div",{children:[(0,o.jsxs)("div",{className:"flex items-center justify-between",children:[(0,o.jsx)("span",{className:"text-xs font-medium text-gray-500",children:e}),(0,o.jsx)("button",{onClick:()=>n([...t,{action:"code",code:""}]),className:"text-xs text-blue-500 hover:text-blue-400",children:"+ action"})]}),t.map((e,s)=>(0,o.jsxs)("div",{className:"flex items-start gap-1 mt-1",children:[(0,o.jsxs)("select",{className:"bg-gray-800 border border-gray-700 rounded px-1 py-0.5 text-xs text-gray-200",value:e.action,onChange:e=>r(s,{action:e.target.value}),children:[(0,o.jsx)("option",{value:"code",children:"Code"}),(0,o.jsx)("option",{value:"timerStart",children:"Timer Start"}),(0,o.jsx)("option",{value:"timerStop",children:"Timer Stop"})]}),"code"===e.action?(0,o.jsx)("textarea",{className:"flex-1 bg-gray-800 border border-gray-700 rounded px-1 py-0.5 text-xs text-gray-200 h-10 font-mono",value:e.code??"",placeholder:"// action code...",onChange:e=>r(s,{code:e.target.value})}):(0,o.jsx)("input",{className:"flex-1 bg-gray-800 border border-gray-700 rounded px-1 py-0.5 text-xs text-gray-200",value:e.name??"",placeholder:"Timer name",onChange:e=>r(s,{name:e.target.value})}),(0,o.jsx)("button",{onClick:()=>n(t.filter((e,t)=>t!==s)),className:"text-red-600 hover:text-red-400 text-xs mt-0.5",children:"✕"})]},s)),0===t.length&&(0,o.jsx)("span",{className:"text-xs text-gray-700 italic",children:"none"})]})}function tA(){let e=tx(e=>e.definition),t=tx(e=>e.selection),n=tx(e=>e.updateState),r=tx(e=>e.removeState);tx(e=>e.addAction),tx(e=>e.removeAction);let s=tx(e=>e.updateTransition),i=tx(e=>e.removeTransition);if(!t.kind||!t.id)return(0,o.jsx)("div",{className:"p-3 text-xs text-gray-500",children:"Select a state or transition to edit its properties."});let a=(e,t)=>{if(e.name===t)return e;for(let n of e.states??[]){let e=a(n,t);if(e)return e}return null};if("state"===t.kind){let s=a(e.state,t.id);if(!s)return(0,o.jsx)("div",{className:"p-3 text-gray-500 text-xs",children:"State not found"});let l=s.onEntry?.actions??[],c=s.onExit?.actions??[];return(0,o.jsxs)("div",{className:"p-3 space-y-3 text-sm md:overflow-y-auto md:max-h-[calc(100vh-160px)]",children:[(0,o.jsxs)("h3",{className:"text-xs font-semibold text-gray-400",children:["State: ",s.name]}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Name"}),(0,o.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:s.name,onChange:e=>n(t.id,{name:e.target.value})})]}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Kind"}),(0,o.jsxs)("select",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:s.kind??"normal",onChange:e=>n(t.id,{kind:e.target.value}),children:[(0,o.jsx)("option",{value:"normal",children:"Normal"}),(0,o.jsx)("option",{value:"final",children:"Final"}),(0,o.jsx)("option",{value:"history",children:"History"})]})]}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Description"}),(0,o.jsx)("textarea",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 h-12",value:s.description??"",onChange:e=>n(t.id,{description:e.target.value||void 0})})]}),(0,o.jsx)(tM,{label:"▸ onEntry Actions",actions:l,onChange:e=>n(t.id,{onEntry:{actions:e}})}),(0,o.jsx)(tM,{label:"◂ onExit Actions",actions:c,onChange:e=>n(t.id,{onExit:{actions:e}})}),(0,o.jsxs)("div",{children:[(0,o.jsx)("span",{className:"text-xs font-medium text-gray-500",children:"Transitions"}),(s.transitions??[]).map((e,n)=>(0,o.jsxs)("div",{className:"flex items-center gap-1 text-xs text-gray-400 py-1 border-b border-gray-800/50",children:[(0,o.jsxs)("span",{className:"flex-1",children:[e.event," → ",e.nextState??"(internal)"]}),e.condition&&(0,o.jsxs)("span",{className:"text-gray-600",children:["[",e.condition,"]"]}),(0,o.jsx)("button",{onClick:()=>i(t.id,n),className:"text-red-600 hover:text-red-400",children:"✕"})]},n)),(s.transitions?.length??0)===0&&(0,o.jsx)("span",{className:"text-xs text-gray-700 italic",children:"none"})]}),(0,o.jsx)("button",{onClick:()=>r(t.id),className:"text-red-500 hover:text-red-400 text-xs mt-2",children:"🗑 Delete State"})]})}if("transition"===t.kind){let[n,r]=t.id.split(":"),l=parseInt(r,10),c=a(e.state,n),d=c?.transitions?.[l];if(!d)return(0,o.jsx)("div",{className:"p-3 text-gray-500 text-xs",children:"Transition not found"});let h=tf(e),u=(function e(t){let n=[t];for(let r of t.states??[])n.push(...e(r));return n})(e.state).map(e=>e.name).filter(e=>"Root"!==e);return(0,o.jsxs)("div",{className:"p-3 space-y-3 text-sm",children:[(0,o.jsx)("h3",{className:"text-xs font-semibold text-gray-400",children:"Transition"}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Event"}),(0,o.jsx)("select",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:d.event,onChange:e=>s(n,l,{event:e.target.value}),children:h.map(e=>(0,o.jsx)("option",{value:e,children:e},e))})]}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Target State"}),(0,o.jsxs)("select",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:d.nextState??"",onChange:e=>s(n,l,{nextState:e.target.value||void 0}),children:[(0,o.jsx)("option",{value:"",children:"(internal transition)"}),u.map(e=>(0,o.jsx)("option",{value:e,children:e},e))]})]}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Condition (guard)"}),(0,o.jsx)("textarea",{rows:3,className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200 resize-y leading-snug",value:d.condition??"",onChange:e=>s(n,l,{condition:e.target.value||void 0})})]}),(0,o.jsx)("button",{onClick:()=>i(n,l),className:"text-red-500 hover:text-red-400 text-xs",children:"🗑 Delete Transition"})]})}return null}let tT=["string","int","float","bool","object"];function t$(){let e=tx(e=>e.definition),t=tx(e=>e.addEvent),n=tx(e=>e.updateEvent),r=tx(e=>e.removeEvent),s=tx(e=>e.addParameter),i=tx(e=>e.removeParameter),a=tx(e=>e.updateParameter),c=tx(e=>e.updateEventSource),d=tx(e=>e.select),h=tx(e=>e.selection),[u,p]=(0,l.useState)(""),[f,m]=(0,l.useState)(null),[g,x]=(0,l.useState)(null);return(0,o.jsxs)("div",{className:"p-3 text-sm",children:[e.events.map((e,t)=>(0,o.jsxs)("div",{className:"mb-3",children:[(0,o.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,o.jsx)("span",{className:"text-xs font-semibold text-gray-500",children:"Source:"}),(0,o.jsx)("input",{className:"flex-1 bg-transparent border-b border-gray-700 text-xs text-gray-300 px-1 py-0.5 focus:border-blue-500 outline-none",value:e.name,onChange:e=>c(t,{name:e.target.value})}),void 0!==e.feeder&&(0,o.jsx)("input",{className:"w-24 bg-transparent border-b border-gray-700 text-xs text-gray-400 px-1 py-0.5 focus:border-blue-500 outline-none",value:e.feeder??"",placeholder:"Feeder...",onChange:e=>c(t,{feeder:e.target.value||void 0})}),void 0===e.feeder&&(0,o.jsx)("button",{className:"text-xs text-gray-600 hover:text-gray-400",title:"Add feeder class",onClick:()=>c(t,{feeder:`${e.name}Feeder`}),children:"+feeder"})]}),(0,o.jsx)("div",{className:"-mx-1 overflow-x-auto px-1",children:(0,o.jsxs)("table",{className:"w-full text-xs",children:[(0,o.jsx)("thead",{children:(0,o.jsxs)("tr",{className:"text-gray-600 border-b border-gray-800",children:[(0,o.jsx)("th",{className:"text-left py-1 font-medium",children:"ID"}),(0,o.jsx)("th",{className:"text-left py-1 font-medium",children:"Description"}),(0,o.jsx)("th",{className:"text-left py-1 font-medium",children:"Params"}),(0,o.jsx)("th",{className:"w-6"})]})}),(0,o.jsx)("tbody",{children:(e.events??[]).map(e=>(0,o.jsxs)(l.Fragment,{children:[(0,o.jsxs)("tr",{className:`border-b border-gray-800/50 hover:bg-gray-800/30 cursor-pointer ${"event"===h.kind&&h.id===e.id?"bg-blue-900/30":""}`,onClick:()=>{d("event",e.id),m(f===e.id?null:e.id)},children:[(0,o.jsx)("td",{className:"py-1 pr-1",children:g===e.id?(0,o.jsx)("input",{autoFocus:!0,className:"w-full bg-gray-800 border border-gray-700 rounded px-1 text-gray-200",value:e.id,onChange:t=>n(e.id,{id:t.target.value}),onBlur:()=>x(null),onKeyDown:e=>"Enter"===e.key&&x(null),onClick:e=>e.stopPropagation()}):(0,o.jsx)("span",{className:"text-gray-300",onDoubleClick:t=>{t.stopPropagation(),x(e.id)},children:e.id})}),(0,o.jsx)("td",{className:"py-1 pr-1 text-gray-500 truncate max-w-[80px]",children:e.description??"—"}),(0,o.jsx)("td",{className:"py-1 text-gray-500",children:(e.parameters?.length??0)>0?e.parameters.map(e=>`${e.name}:${e.type}`).join(", "):"—"}),(0,o.jsx)("td",{className:"py-1",children:(0,o.jsx)("button",{onClick:t=>{t.stopPropagation(),r(e.id)},className:"text-red-600 hover:text-red-400",children:"✕"})})]}),f===e.id&&(0,o.jsx)("tr",{children:(0,o.jsx)("td",{colSpan:4,className:"py-2 px-1 bg-gray-900/50",children:(0,o.jsxs)("div",{className:"space-y-2",children:[(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-gray-600",children:"Description"}),(0,o.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-0.5 text-gray-200 mt-0.5",value:e.description??"",onChange:t=>n(e.id,{description:t.target.value||void 0})})]}),(0,o.jsxs)("div",{children:[(0,o.jsx)("span",{className:"text-gray-600",children:"Parameters"}),(e.parameters??[]).map((t,n)=>(0,o.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,o.jsx)("input",{className:"flex-1 bg-gray-800 border border-gray-700 rounded px-1 py-0.5 text-gray-200",value:t.name,placeholder:"name",onChange:t=>a(e.id,n,{name:t.target.value})}),(0,o.jsx)("select",{className:"bg-gray-800 border border-gray-700 rounded px-1 py-0.5 text-gray-200",value:t.type,onChange:t=>a(e.id,n,{type:t.target.value}),children:tT.map(e=>(0,o.jsx)("option",{value:e,children:e},e))}),(0,o.jsx)("button",{onClick:()=>i(e.id,n),className:"text-red-600 hover:text-red-400",children:"✕"})]},n)),(0,o.jsx)("button",{className:"text-blue-500 hover:text-blue-400 mt-1",onClick:()=>s(e.id,{name:"param",type:"string"}),children:"+ parameter"})]}),(0,o.jsxs)("div",{className:"mt-1",children:[(0,o.jsx)("span",{className:"text-gray-600",children:"Generated method:"}),(0,o.jsxs)("code",{className:"block bg-gray-800 rounded px-2 py-1 text-green-400 mt-0.5 font-mono",children:["on_",e.id.toLowerCase(),"(context",(e.parameters??[]).map(e=>`, ${e.name}: ${e.type}`).join(""),")"]})]})]})})})]},e.id))})]})})]},t)),(0,o.jsxs)("div",{className:"flex gap-1 mt-2",children:[(0,o.jsx)("input",{className:"flex-1 bg-gray-800 border border-gray-700 rounded px-2 py-1 text-gray-200",placeholder:"New event ID...",value:u,onChange:e=>p(e.target.value),onKeyDown:e=>{"Enter"===e.key&&u.trim()&&(t({id:u.trim()}),p(""))}}),(0,o.jsx)("button",{onClick:()=>{u.trim()&&(t({id:u.trim()}),p(""))},className:"bg-blue-600 hover:bg-blue-500 text-white px-2 py-1 rounded",children:"+"})]})]})}function tP(){let e=tx(e=>e.definition.settings),t=tx(e=>e.definition.settings.context),n=tx(e=>e.updateSettings);return(0,o.jsxs)("div",{className:"p-3 space-y-3 text-sm",children:[(0,o.jsx)("h3",{className:"text-xs font-semibold text-gray-400",children:"Machine Settings"}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Namespace"}),(0,o.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:e.namespace,onChange:e=>n({namespace:e.target.value})})]}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Name"}),(0,o.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:e.name??"",onChange:e=>n({name:e.target.value||void 0})})]}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Description"}),(0,o.jsx)("textarea",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 h-12",value:e.description??"",onChange:e=>n({description:e.target.value||void 0})})]}),(0,o.jsxs)("label",{className:"flex items-center gap-2 text-sm text-gray-300",children:[(0,o.jsx)("input",{type:"checkbox",checked:e.asynchronous,onChange:e=>n({asynchronous:e.target.checked}),className:"rounded bg-gray-800 border-gray-600"}),"Asynchronous"]}),(0,o.jsx)("hr",{className:"border-gray-800"}),(0,o.jsx)("h4",{className:"text-xs font-semibold text-gray-500",children:"Context"}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Context Class"}),(0,o.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200",value:t?.class??"",placeholder:"e.g. MyStateMachineContext",onChange:e=>n({context:{...t,class:e.target.value||void 0}})})]}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Base Class"}),(0,o.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200",value:t?.baseClass??"",placeholder:"e.g. Context",onChange:e=>n({context:{...t,baseClass:e.target.value||void 0}})})]}),(0,o.jsx)("hr",{className:"border-gray-800"}),(0,o.jsx)("h4",{className:"text-xs font-semibold text-gray-500",children:"Imports"}),(0,o.jsx)("textarea",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 h-16 font-mono",value:(e.imports??[]).join("\n"),placeholder:"One import per line",onChange:e=>n({imports:e.target.value?e.target.value.split("\n"):[]})}),(0,o.jsx)("hr",{className:"border-gray-800"}),(0,o.jsx)("h4",{className:"text-xs font-semibold text-gray-500",children:"Object References"}),(0,o.jsx)("textarea",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 h-12 font-mono",value:(e.objects??[]).map(e=>`${e.instance}: ${e.class}`).join("\n"),placeholder:"instance: Class (one per line)",onChange:e=>{n({objects:e.target.value.split("\n").filter(e=>e.includes(":")).map(e=>{let[t,n]=e.split(":").map(e=>e.trim());return{instance:t,class:n}})})}}),(0,o.jsx)("hr",{className:"border-gray-800"}),(0,o.jsx)("h4",{className:"text-xs font-semibold text-gray-500",children:"Code Generation"}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Target Language"}),(0,o.jsxs)("select",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200",value:e.targetLanguage??"python",onChange:e=>n({targetLanguage:e.target.value}),children:[(0,o.jsx)("option",{value:"python",children:"Python"}),(0,o.jsx)("option",{value:"typescript",children:"TypeScript"}),(0,o.jsx)("option",{value:"csharp",children:"C#"})]})]})]})}function tI(){let e=tx(e=>e.errors),t=tx(e=>e.validate),n=tx(e=>e.select);return(0,o.jsxs)("div",{className:"p-3",children:[(0,o.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,o.jsxs)("h3",{className:"text-xs font-semibold text-gray-400",children:["Validation ",e.length>0&&(0,o.jsxs)("span",{className:"text-red-500",children:["(",e.length,")"]})]}),(0,o.jsx)("button",{onClick:()=>t(),className:"text-xs bg-gray-700 hover:bg-gray-600 text-gray-300 px-2 py-0.5 rounded",children:"Re-check"})]}),0===e.length?(0,o.jsxs)("div",{className:"flex items-center gap-2 text-green-500 text-xs",children:[(0,o.jsx)("span",{children:"✓"}),(0,o.jsx)("span",{children:"Definition is valid"})]}):(0,o.jsx)("div",{className:"space-y-0.5",children:e.map((e,t)=>(0,o.jsxs)("div",{className:`flex items-start gap-1.5 text-[13px] py-2.5 border-b border-gray-800/50 md:text-xs md:py-1 ${e.element?"cursor-pointer hover:bg-gray-800/30":""}`,onClick:()=>{e.element&&n("state",e.element)},title:e.element?`Click to select "${e.element}"`:void 0,children:[(0,o.jsx)("span",{className:`font-mono text-[10px] mt-0.5 ${"error"===e.severity?"text-red-600":"text-yellow-600"}`,children:e.ruleId}),(0,o.jsx)("span",{className:`flex-1 ${"error"===e.severity?"text-red-400":"text-yellow-400"}`,children:e.message}),e.element&&(0,o.jsxs)("span",{className:"text-gray-600 text-[10px]",children:["→ ",e.element]})]},t))})]})}var tL=e.i(76800);function tB(){let e=(0,tL.useRequestedDoc)(),[t,n]=(0,l.useState)(!1),[r,s]=(0,l.useState)(""),[i,a]=(0,l.useState)(null),[c,d]=(0,l.useState)([]),[h,u]=(0,l.useState)(null);(0,l.useEffect)(()=>{if(!t)return;let e=!0;return u(null),fetch("/api/docs",{cache:"no-store"}).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(t=>{e&&(a(t.docs??[]),d(t.roots??[]))}).catch(t=>{e&&(a([]),u(t.message))}),()=>{e=!1}},[t]);let p=e=>{n(!1),s(""),(0,tL.navigateToDoc)(e)},f=new Set((i??[]).map(e=>e.path)),m=t?(function(){try{let e=[];for(let t=0;t<window.localStorage.length;t++){let n=window.localStorage.key(t);n?.startsWith(tE)&&e.push(n.slice(tE.length))}return e.sort()}catch{return[]}})().filter(t=>t.startsWith("/")&&t!==e&&!f.has(t)):[],g=(i??[]).filter(t=>t.path!==e),x=r.trim().toLowerCase(),y=x?g.filter(e=>e.path.toLowerCase().includes(x)):g,b="block w-full truncate rounded px-1.5 py-1 text-left text-xs text-gray-300 hover:bg-gray-800";return(0,o.jsxs)("span",{className:"relative inline-flex",children:[(0,o.jsx)("button",{onClick:()=>n(e=>!e),className:"toolbar-btn",title:e?`Document: ${e}`:"Switch document",children:"⇄"}),t&&(0,o.jsxs)("div",{className:"absolute left-0 top-full z-50 mt-1 w-80 rounded border border-gray-700 bg-gray-900 p-2 shadow-lg",children:[(0,o.jsx)("div",{className:"mb-1 text-[10px] uppercase tracking-wide text-gray-500",children:"switch document"}),(0,o.jsxs)("form",{onSubmit:e=>{e.preventDefault();let t=r.trim();if(t){if(1===y.length)return p(y[0].path);if(t.startsWith("/"))return p(t)}},className:"mb-1 flex gap-1",children:[(0,o.jsx)("input",{value:r,onChange:e=>s(e.target.value),placeholder:null===i?"loading…":"filter, or /absolute/path.json",className:"min-w-0 flex-1 rounded border border-gray-700 bg-gray-950 px-1.5 py-1 text-xs text-gray-200 placeholder:text-gray-600"}),(0,o.jsx)("button",{type:"submit",className:"toolbar-btn",title:"Open",children:"→"})]}),(0,o.jsxs)("div",{className:"max-h-64 overflow-y-auto",children:[e&&(0,o.jsx)("button",{onClick:()=>p(null),className:b,title:"Return to the default project file",children:"⌂ default document"}),y.map(e=>(0,o.jsxs)("button",{onClick:()=>p(e.path),className:b,title:e.path,children:[e.name,(0,o.jsx)("span",{className:"ml-1 text-[10px] text-gray-600",children:e.dir})]},e.path)),m.length>0&&(0,o.jsxs)("div",{className:"mt-1 border-t border-gray-800 pt-1",children:[(0,o.jsx)("div",{className:"px-1.5 pb-0.5 text-[10px] uppercase tracking-wide text-gray-600",children:"recent"}),m.map(e=>(0,o.jsxs)("button",{onClick:()=>p(e),className:b,title:e,children:[e.split("/").pop(),(0,o.jsx)("span",{className:"ml-1 text-[10px] text-gray-600",children:e})]},e))]}),null!==i&&0===y.length&&0===m.length&&(0,o.jsx)("div",{className:"px-1.5 py-1 text-[11px] text-gray-500",children:x?"nothing matches":"no other documents here"})]}),c.length>0&&(0,o.jsxs)("div",{className:"mt-1 truncate border-t border-gray-800 pt-1 text-[10px] text-gray-600",children:["paths are as the server sees them: ",c.join(", ")]}),h&&(0,o.jsxs)("div",{className:"mt-1 text-[10px] text-gray-600",children:["this server does not list documents (",h,") — type a path"]})]})]})}function tD(){let e=tx(e=>e.presence),[t,n]=(0,l.useState)(!1);if(0===e.length)return null;let r=new Map;for(let t of e)r.set(t.role,(r.get(t.role)??0)+1);let s=[...r].map(([e,t])=>t>1?`${e} \xd7${t}`:e).join(" · ");return(0,o.jsxs)("span",{className:"relative inline-flex",children:[(0,o.jsxs)("button",{onClick:()=>n(e=>!e),className:"toolbar-btn inline-flex items-center gap-1.5",title:`Connected: ${s}`,"aria-expanded":t,"aria-label":`${e.length} connected: ${s}`,children:[(0,o.jsx)("span",{className:"flex -space-x-1",children:e.slice(0,4).map(e=>(0,o.jsx)("span",{className:"inline-block h-2 w-2 rounded-full ring-1 ring-gray-900",style:{backgroundColor:e.color??y(e.clientId)}},e.clientId))}),(0,o.jsx)("span",{className:"tabular-nums",children:e.length})]}),t&&(0,o.jsxs)("div",{className:"absolute left-0 top-full z-50 mt-1 max-h-64 w-56 overflow-y-auto rounded border border-gray-700 bg-gray-900 p-2 shadow-lg",children:[(0,o.jsxs)("div",{className:"mb-1 text-[10px] uppercase tracking-wide text-gray-500",children:["connected · ",s]}),e.map(e=>(0,o.jsxs)("div",{className:"flex items-center gap-1.5 rounded px-1 py-1 text-xs text-gray-300",title:e.clientId,children:[(0,o.jsx)("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full",style:{backgroundColor:e.color??y(e.clientId)}}),(0,o.jsx)("span",{className:"shrink-0",children:e.role}),e.name&&(0,o.jsx)("span",{className:"truncate text-gray-500",children:e.name})]},e.clientId))]})]})}function tF(){let e=tx(e=>e.definition),t=tx(e=>e.fileName),n=tx(e=>e.docPath),r=tx(e=>e.dirty),s=tx(e=>e.loadFromJson),i=tx(e=>e.exportJson),a=tx(e=>e.addState),c=tx(e=>e.validate),d=tx(e=>e.showCodePreview),h=tx(e=>e.setShowCodePreview),u=tx(e=>e.setGeneratedCode),p=tx(e=>e.drawMode),f=tx(e=>e.setDrawMode),m=tx(e=>e.arrangeLayout),g=tx(e=>e.undo),x=tx(e=>e.redo),y=tx(e=>e.undoStack),b=tx(e=>e.redoStack),v=tx(e=>e.remoteStatus),w=tx(e=>e.remoteMessage),k=tx(e=>e.setRemoteStatus),j=tx(e=>e.setRemoteMtime),N=tx(e=>e.applyRemote),S=(0,tL.useRequestedDoc)(),_=(0,l.useRef)(null),[C,E]=(0,l.useState)(!1),[R,O]=(0,l.useState)(""),[M,A]=(0,l.useState)(!1),[T,$]=(0,l.useState)("png"),[P,I]=(0,l.useState)(!1),[L,B]=(0,l.useState)(null),[D,F]=(0,l.useState)(null),q=async()=>{let e=i();A(!0);try{let t=await fetch(`/api/file${(0,tL.docQuery)(S)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:e})});if(t.ok){let e=await t.json();j(e.mtime),tx.setState({dirty:!1}),k("synced",null)}else{let e=await t.json().catch(()=>({error:"unknown"}));k("error",`Save failed: ${e.error??t.statusText}`)}}catch(e){k("error",`Save failed: ${e}`)}finally{A(!1)}},U=async()=>{I(!0),B(null);try{let r=await tC(T,{definition:e,docPath:n,fileName:t});F(r)}catch(e){B(e instanceof Error?e.message:String(e))}finally{I(!1)}},H=async()=>{try{let e=await fetch(`/api/file${(0,tL.docQuery)(S)}`,{cache:"no-store"});if(!e.ok)return void k("error","Reload failed");let t=await e.json();t.exists&&t.content?N(t.content,t.mtime,t.path.split("/").pop()):k("idle",`No file at ${t.path}`)}catch(e){k("error",`Reload failed: ${e}`)}},J=()=>{R.trim()&&(a(null,{name:R.trim(),kind:"normal"}),O(""),E(!1))},[Y,V]=(0,l.useState)("python"),X=async()=>{try{let e=await fetch("/api/rispec",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(e.ok){let t=await e.json();u(t.rispec)}else{let t=await e.json().catch(()=>({error:"Unknown"}));u(`# RISE rispec generation failed
|
|
5
|
+
`)],{type:`${tS[e]};charset=utf-8`})}else{let t=function(e={}){let t="u"<typeof document?null:document.getElementById(tw);if(!t)return null;let n=function(e){let t=e.querySelector(":scope > g");if(!t)return null;try{let e=t.getBBox();return e.width>0&&e.height>0?e:null}catch{return null}}(t);if(!n)return null;let r=e.padding??48,s=e.background??tk,i=Math.round(n.x-r),a=Math.round(n.y-r),o=Math.round(n.width+2*r),l=Math.round(n.height+2*r),c=t.cloneNode(!0);c.removeAttribute("id"),c.removeAttribute("class"),c.removeAttribute("style"),c.setAttribute("xmlns","http://www.w3.org/2000/svg"),c.setAttribute("width",String(o)),c.setAttribute("height",String(l)),c.setAttribute("viewBox",`${i} ${a} ${o} ${l}`),c.setAttribute("font-family","ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif"),function e(t){for(let n of Array.from(t.children)){if("transparent"===n.getAttribute("fill")||"transparent"===n.getAttribute("stroke")){n.remove();continue}n.removeAttribute("class"),n.removeAttribute("style"),e(n)}}(c);let d=c.querySelector(":scope > g");d?.removeAttribute("transform");let h=document.createElementNS("http://www.w3.org/2000/svg","rect");return h.setAttribute("x",String(i)),h.setAttribute("y",String(a)),h.setAttribute("width",String(o)),h.setAttribute("height",String(l)),h.setAttribute("fill",s),c.insertBefore(h,c.firstChild),new XMLSerializer().serializeToString(c)}(n);if(!t)throw Error("nothing on the board to export yet");a="svg"===e?new Blob([t],{type:`${tS.svg};charset=utf-8`}):await (i=n.scale??2,new Promise((n,r)=>{let s=t.match(/width="(\d+)"\s+height="(\d+)"/),a=s?Number(s[1]):1200,o=s?Number(s[2]):800,l=URL.createObjectURL(new Blob([t],{type:"image/svg+xml;charset=utf-8"})),c=new Image;c.onload=()=>{URL.revokeObjectURL(l);let t=document.createElement("canvas");t.width=Math.max(1,Math.round(a*i)),t.height=Math.max(1,Math.round(o*i));let s=t.getContext("2d");s?(s.fillStyle=tk,s.fillRect(0,0,t.width,t.height),s.drawImage(c,0,0,t.width,t.height),t.toBlob(e=>e?n(e):r(Error("the canvas produced no image")),tS[e],"jpeg"===e?.92:void 0)):r(Error("this browser gave no 2d context to draw into"))},c.onerror=()=>{URL.revokeObjectURL(l),r(Error("the browser could not read the serialized board"))},c.src=l}))}let o=function({doc:e,machine:t,format:n,at:r}){let s,i,a=H(t??"")||H(e?(e.split(/[/\\]/).pop()??e).replace(/\.smdf\.json$/i,"").replace(/\.json$/i,""):"")||"statemachine",o=e&&(s=e.match(/(?:^|[/\\-])ep(?:isode)?-?(\d{2,4})(?:[/\\-]|$)/i))?`ep${s[1]}`:null,l=o?`${o}--`:"";return`${l}${a}--${(i=e=>String(e).padStart(2,"0"))(r.getFullYear()%100)+i(r.getMonth()+1)+i(r.getDate())+i(r.getHours())+i(r.getMinutes())+i(r.getSeconds())}.${n}`}({doc:t.docPath??t.fileName??null,machine:t.definition?.settings?.name??null,format:t_[e]??String(e),at:(void 0)??new Date}),l=URL.createObjectURL(a),c=document.createElement("a");return c.href=l,c.download=o,c.click(),URL.revokeObjectURL(l),o}let tE="stateloom.layout.v1:";async function tR(){try{let{requestedDoc:t,docQuery:n}=await e.A(32058),r=await fetch(`/api/file${n(t())}`,{cache:"no-store"});if(r.ok){let e=(await r.json())?.path;if("string"==typeof e&&e.length>0)return e}}catch{}return tx.getState().fileName??"untitled"}function tO(){let e,t,n=tx(e=>e.definition),r=tx(e=>e.layout),s=tx(e=>e.selection),i=tx(e=>e.select),a=tx(e=>e.clearSelection),c=tx(e=>e.setStatePosition),d=tx(e=>e.drawMode),h=tx(e=>e.drawSource),u=tx(e=>e.setDrawSource),p=tx(e=>e.setDrawMode),f=tx(e=>e.addTransition),m=tx(e=>e.showContextMenu),g=tx(e=>e.removeState),x=tx(e=>e.undo),y=tx(e=>e.redo),b=tx(e=>e.errors),v=tx(e=>e.navigationPath),w=tx(e=>e.navigateInto),k=tx(e=>e.navigateUp),j=tx(e=>e.activeStates),S=tx(e=>e.viewport),_=tx(e=>e.setViewport);e=(0,l.useRef)(!1),t=(0,l.useRef)(null),(0,l.useEffect)(()=>{let n=!1,r=null;(async()=>{let r=await tR();if(n)return;t.current=r;let s=function(e){try{let t=window.localStorage.getItem(`${tE}${e}`);if(!t)return null;let n=JSON.parse(t),r={};for(let[e,t]of Object.entries(n?.positions??{}))t&&"object"==typeof t&&Number.isFinite(t.x)&&Number.isFinite(t.y)&&Number.isFinite(t.width)&&Number.isFinite(t.height)&&(r[e]=t);return{positions:r,viewport:function(e,t=I){return e?{x:Number.isFinite(e.x)?e.x:0,y:Number.isFinite(e.y)?e.y:0,scale:B(e.scale??1,t)}:{...L}}(n?.viewport)}}catch{return null}}(r);s&&tx.getState().hydrateLayout(s.positions,s.viewport),e.current=!0})();let s=tx.subscribe((n,s)=>{e.current&&t.current&&(n.layout!==s.layout||n.viewport!==s.viewport)&&(r&&clearTimeout(r),r=setTimeout(()=>{let e=tx.getState();!function(e,t,n){try{window.localStorage.setItem(`${tE}${e}`,JSON.stringify({positions:t,viewport:n,savedAt:Date.now()}))}catch{}}(t.current,function(e,t){let n={};for(let[r,s]of Object.entries(e)){let e=t[r];e&&(s.x!==e.x||s.y!==e.y||s.width!==e.width||s.height!==e.height)&&(n[r]=s)}return n}(e.layout.positions,N(e.definition)),e.viewport)},300))});return()=>{n=!0,r&&clearTimeout(r),s()}},[]);let C=v.slice(1);return(0,o.jsx)(Z,{definition:n,positions:r.positions,path:C,rootLabel:v[0],viewport:S,onViewportChange:_,selection:{kind:"state"===s.kind||"transition"===s.kind?s.kind:null,id:s.id},activeStates:j,errorElements:b.flatMap(e=>e.element?[e.element]:[]),drawMode:"transition"===d?"transition":"select",drawSource:h,svgId:tw,pinchOwner:ty,emptyHint:window.matchMedia?.("(pointer: coarse)").matches?"Press and hold to add a state, or load a .smdf.json file":"Right-click to add a state, or load a .smdf.json file",onSelect:(e,t)=>{"state"!==e||"transition"!==d||h?i(e,t):u(t)},onClearSelection:a,onStateMove:c,onNavigateInto:w,onNavigateTo:e=>k(e),onContextMenu:(e,t,n)=>m(e,t,"state"===n.kind?{kind:"state",id:n.id}:{kind:"canvas"}),onCreateTransition:(e,t,n)=>{f(e,{event:n,nextState:t}),u(null),p("select")},onCancelDraw:()=>{p("select"),u(null)},onDeleteState:e=>{g(e),a()},onUndo:x,onRedo:y})}function tM({label:e,actions:t,onChange:n}){let r=(e,r)=>n(t.map((t,n)=>n===e?{...t,...r}:t));return(0,o.jsxs)("div",{children:[(0,o.jsxs)("div",{className:"flex items-center justify-between",children:[(0,o.jsx)("span",{className:"text-xs font-medium text-gray-500",children:e}),(0,o.jsx)("button",{onClick:()=>n([...t,{action:"code",code:""}]),className:"text-xs text-blue-500 hover:text-blue-400",children:"+ action"})]}),t.map((e,s)=>(0,o.jsxs)("div",{className:"flex items-start gap-1 mt-1",children:[(0,o.jsxs)("select",{className:"bg-gray-800 border border-gray-700 rounded px-1 py-0.5 text-xs text-gray-200",value:e.action,onChange:e=>r(s,{action:e.target.value}),children:[(0,o.jsx)("option",{value:"code",children:"Code"}),(0,o.jsx)("option",{value:"timerStart",children:"Timer Start"}),(0,o.jsx)("option",{value:"timerStop",children:"Timer Stop"})]}),"code"===e.action?(0,o.jsx)("textarea",{className:"flex-1 bg-gray-800 border border-gray-700 rounded px-1 py-0.5 text-xs text-gray-200 h-10 font-mono",value:e.code??"",placeholder:"// action code...",onChange:e=>r(s,{code:e.target.value})}):(0,o.jsx)("input",{className:"flex-1 bg-gray-800 border border-gray-700 rounded px-1 py-0.5 text-xs text-gray-200",value:e.name??"",placeholder:"Timer name",onChange:e=>r(s,{name:e.target.value})}),(0,o.jsx)("button",{onClick:()=>n(t.filter((e,t)=>t!==s)),className:"text-red-600 hover:text-red-400 text-xs mt-0.5",children:"✕"})]},s)),0===t.length&&(0,o.jsx)("span",{className:"text-xs text-gray-700 italic",children:"none"})]})}function tA(){let e=tx(e=>e.definition),t=tx(e=>e.selection),n=tx(e=>e.updateState),r=tx(e=>e.removeState);tx(e=>e.addAction),tx(e=>e.removeAction);let s=tx(e=>e.updateTransition),i=tx(e=>e.removeTransition);if(!t.kind||!t.id)return(0,o.jsx)("div",{className:"p-3 text-xs text-gray-500",children:"Select a state or transition to edit its properties."});let a=(e,t)=>{if(e.name===t)return e;for(let n of e.states??[]){let e=a(n,t);if(e)return e}return null};if("state"===t.kind){let s=a(e.state,t.id);if(!s)return(0,o.jsx)("div",{className:"p-3 text-gray-500 text-xs",children:"State not found"});let l=s.onEntry?.actions??[],c=s.onExit?.actions??[];return(0,o.jsxs)("div",{className:"p-3 space-y-3 text-sm md:overflow-y-auto md:max-h-[calc(100vh-160px)]",children:[(0,o.jsxs)("h3",{className:"text-xs font-semibold text-gray-400",children:["State: ",s.name]}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Name"}),(0,o.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:s.name,onChange:e=>n(t.id,{name:e.target.value})})]}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Kind"}),(0,o.jsxs)("select",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:s.kind??"normal",onChange:e=>n(t.id,{kind:e.target.value}),children:[(0,o.jsx)("option",{value:"normal",children:"Normal"}),(0,o.jsx)("option",{value:"final",children:"Final"}),(0,o.jsx)("option",{value:"history",children:"History"})]})]}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Description"}),(0,o.jsx)("textarea",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 h-12",value:s.description??"",onChange:e=>n(t.id,{description:e.target.value||void 0})})]}),(0,o.jsx)(tM,{label:"▸ onEntry Actions",actions:l,onChange:e=>n(t.id,{onEntry:{actions:e}})}),(0,o.jsx)(tM,{label:"◂ onExit Actions",actions:c,onChange:e=>n(t.id,{onExit:{actions:e}})}),(0,o.jsxs)("div",{children:[(0,o.jsx)("span",{className:"text-xs font-medium text-gray-500",children:"Transitions"}),(s.transitions??[]).map((e,n)=>(0,o.jsxs)("div",{className:"flex items-center gap-1 text-xs text-gray-400 py-1 border-b border-gray-800/50",children:[(0,o.jsxs)("span",{className:"flex-1",children:[e.event," → ",e.nextState??"(internal)"]}),e.condition&&(0,o.jsxs)("span",{className:"text-gray-600",children:["[",e.condition,"]"]}),(0,o.jsx)("button",{onClick:()=>i(t.id,n),className:"text-red-600 hover:text-red-400",children:"✕"})]},n)),(s.transitions?.length??0)===0&&(0,o.jsx)("span",{className:"text-xs text-gray-700 italic",children:"none"})]}),(0,o.jsx)("button",{onClick:()=>r(t.id),className:"text-red-500 hover:text-red-400 text-xs mt-2",children:"🗑 Delete State"})]})}if("transition"===t.kind){let[n,r]=t.id.split(":"),l=parseInt(r,10),c=a(e.state,n),d=c?.transitions?.[l];if(!d)return(0,o.jsx)("div",{className:"p-3 text-gray-500 text-xs",children:"Transition not found"});let h=tf(e),u=(function e(t){let n=[t];for(let r of t.states??[])n.push(...e(r));return n})(e.state).map(e=>e.name).filter(e=>"Root"!==e);return(0,o.jsxs)("div",{className:"p-3 space-y-3 text-sm",children:[(0,o.jsx)("h3",{className:"text-xs font-semibold text-gray-400",children:"Transition"}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Event"}),(0,o.jsx)("select",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:d.event,onChange:e=>s(n,l,{event:e.target.value}),children:h.map(e=>(0,o.jsx)("option",{value:e,children:e},e))})]}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Target State"}),(0,o.jsxs)("select",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:d.nextState??"",onChange:e=>s(n,l,{nextState:e.target.value||void 0}),children:[(0,o.jsx)("option",{value:"",children:"(internal transition)"}),u.map(e=>(0,o.jsx)("option",{value:e,children:e},e))]})]}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Condition (guard)"}),(0,o.jsx)("textarea",{rows:3,className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200 resize-y leading-snug",value:d.condition??"",onChange:e=>s(n,l,{condition:e.target.value||void 0})})]}),(0,o.jsx)("button",{onClick:()=>i(n,l),className:"text-red-500 hover:text-red-400 text-xs",children:"🗑 Delete Transition"})]})}return null}let tT=["string","int","float","bool","object"];function t$(){let e=tx(e=>e.definition),t=tx(e=>e.addEvent),n=tx(e=>e.updateEvent),r=tx(e=>e.removeEvent),s=tx(e=>e.addParameter),i=tx(e=>e.removeParameter),a=tx(e=>e.updateParameter),c=tx(e=>e.updateEventSource),d=tx(e=>e.select),h=tx(e=>e.selection),[u,p]=(0,l.useState)(""),[f,m]=(0,l.useState)(null),[g,x]=(0,l.useState)(null);return(0,o.jsxs)("div",{className:"p-3 text-sm",children:[e.events.map((e,t)=>(0,o.jsxs)("div",{className:"mb-3",children:[(0,o.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,o.jsx)("span",{className:"text-xs font-semibold text-gray-500",children:"Source:"}),(0,o.jsx)("input",{className:"flex-1 bg-transparent border-b border-gray-700 text-xs text-gray-300 px-1 py-0.5 focus:border-blue-500 outline-none",value:e.name,onChange:e=>c(t,{name:e.target.value})}),void 0!==e.feeder&&(0,o.jsx)("input",{className:"w-24 bg-transparent border-b border-gray-700 text-xs text-gray-400 px-1 py-0.5 focus:border-blue-500 outline-none",value:e.feeder??"",placeholder:"Feeder...",onChange:e=>c(t,{feeder:e.target.value||void 0})}),void 0===e.feeder&&(0,o.jsx)("button",{className:"text-xs text-gray-600 hover:text-gray-400",title:"Add feeder class",onClick:()=>c(t,{feeder:`${e.name}Feeder`}),children:"+feeder"})]}),(0,o.jsx)("div",{className:"-mx-1 overflow-x-auto px-1",children:(0,o.jsxs)("table",{className:"w-full text-xs",children:[(0,o.jsx)("thead",{children:(0,o.jsxs)("tr",{className:"text-gray-600 border-b border-gray-800",children:[(0,o.jsx)("th",{className:"text-left py-1 font-medium",children:"ID"}),(0,o.jsx)("th",{className:"text-left py-1 font-medium",children:"Description"}),(0,o.jsx)("th",{className:"text-left py-1 font-medium",children:"Params"}),(0,o.jsx)("th",{className:"w-6"})]})}),(0,o.jsx)("tbody",{children:(e.events??[]).map(e=>(0,o.jsxs)(l.Fragment,{children:[(0,o.jsxs)("tr",{className:`border-b border-gray-800/50 hover:bg-gray-800/30 cursor-pointer ${"event"===h.kind&&h.id===e.id?"bg-blue-900/30":""}`,onClick:()=>{d("event",e.id),m(f===e.id?null:e.id)},children:[(0,o.jsx)("td",{className:"py-1 pr-1",children:g===e.id?(0,o.jsx)("input",{autoFocus:!0,className:"w-full bg-gray-800 border border-gray-700 rounded px-1 text-gray-200",value:e.id,onChange:t=>n(e.id,{id:t.target.value}),onBlur:()=>x(null),onKeyDown:e=>"Enter"===e.key&&x(null),onClick:e=>e.stopPropagation()}):(0,o.jsx)("span",{className:"text-gray-300",onDoubleClick:t=>{t.stopPropagation(),x(e.id)},children:e.id})}),(0,o.jsx)("td",{className:"py-1 pr-1 text-gray-500 truncate max-w-[80px]",children:e.description??"—"}),(0,o.jsx)("td",{className:"py-1 text-gray-500",children:(e.parameters?.length??0)>0?e.parameters.map(e=>`${e.name}:${e.type}`).join(", "):"—"}),(0,o.jsx)("td",{className:"py-1",children:(0,o.jsx)("button",{onClick:t=>{t.stopPropagation(),r(e.id)},className:"text-red-600 hover:text-red-400",children:"✕"})})]}),f===e.id&&(0,o.jsx)("tr",{children:(0,o.jsx)("td",{colSpan:4,className:"py-2 px-1 bg-gray-900/50",children:(0,o.jsxs)("div",{className:"space-y-2",children:[(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-gray-600",children:"Description"}),(0,o.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-0.5 text-gray-200 mt-0.5",value:e.description??"",onChange:t=>n(e.id,{description:t.target.value||void 0})})]}),(0,o.jsxs)("div",{children:[(0,o.jsx)("span",{className:"text-gray-600",children:"Parameters"}),(e.parameters??[]).map((t,n)=>(0,o.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,o.jsx)("input",{className:"flex-1 bg-gray-800 border border-gray-700 rounded px-1 py-0.5 text-gray-200",value:t.name,placeholder:"name",onChange:t=>a(e.id,n,{name:t.target.value})}),(0,o.jsx)("select",{className:"bg-gray-800 border border-gray-700 rounded px-1 py-0.5 text-gray-200",value:t.type,onChange:t=>a(e.id,n,{type:t.target.value}),children:tT.map(e=>(0,o.jsx)("option",{value:e,children:e},e))}),(0,o.jsx)("button",{onClick:()=>i(e.id,n),className:"text-red-600 hover:text-red-400",children:"✕"})]},n)),(0,o.jsx)("button",{className:"text-blue-500 hover:text-blue-400 mt-1",onClick:()=>s(e.id,{name:"param",type:"string"}),children:"+ parameter"})]}),(0,o.jsxs)("div",{className:"mt-1",children:[(0,o.jsx)("span",{className:"text-gray-600",children:"Generated method:"}),(0,o.jsxs)("code",{className:"block bg-gray-800 rounded px-2 py-1 text-green-400 mt-0.5 font-mono",children:["on_",e.id.toLowerCase(),"(context",(e.parameters??[]).map(e=>`, ${e.name}: ${e.type}`).join(""),")"]})]})]})})})]},e.id))})]})})]},t)),(0,o.jsxs)("div",{className:"flex gap-1 mt-2",children:[(0,o.jsx)("input",{className:"flex-1 bg-gray-800 border border-gray-700 rounded px-2 py-1 text-gray-200",placeholder:"New event ID...",value:u,onChange:e=>p(e.target.value),onKeyDown:e=>{"Enter"===e.key&&u.trim()&&(t({id:u.trim()}),p(""))}}),(0,o.jsx)("button",{onClick:()=>{u.trim()&&(t({id:u.trim()}),p(""))},className:"bg-blue-600 hover:bg-blue-500 text-white px-2 py-1 rounded",children:"+"})]})]})}function tP(){let e=tx(e=>e.definition.settings),t=tx(e=>e.definition.settings.context),n=tx(e=>e.updateSettings);return(0,o.jsxs)("div",{className:"p-3 space-y-3 text-sm",children:[(0,o.jsx)("h3",{className:"text-xs font-semibold text-gray-400",children:"Machine Settings"}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Namespace"}),(0,o.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:e.namespace,onChange:e=>n({namespace:e.target.value})})]}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Name"}),(0,o.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-gray-200",value:e.name??"",onChange:e=>n({name:e.target.value||void 0})})]}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Description"}),(0,o.jsx)("textarea",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 h-12",value:e.description??"",onChange:e=>n({description:e.target.value||void 0})})]}),(0,o.jsxs)("label",{className:"flex items-center gap-2 text-sm text-gray-300",children:[(0,o.jsx)("input",{type:"checkbox",checked:e.asynchronous,onChange:e=>n({asynchronous:e.target.checked}),className:"rounded bg-gray-800 border-gray-600"}),"Asynchronous"]}),(0,o.jsx)("hr",{className:"border-gray-800"}),(0,o.jsx)("h4",{className:"text-xs font-semibold text-gray-500",children:"Context"}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Context Class"}),(0,o.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200",value:t?.class??"",placeholder:"e.g. MyStateMachineContext",onChange:e=>n({context:{...t,class:e.target.value||void 0}})})]}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Base Class"}),(0,o.jsx)("input",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200",value:t?.baseClass??"",placeholder:"e.g. Context",onChange:e=>n({context:{...t,baseClass:e.target.value||void 0}})})]}),(0,o.jsx)("hr",{className:"border-gray-800"}),(0,o.jsx)("h4",{className:"text-xs font-semibold text-gray-500",children:"Imports"}),(0,o.jsx)("textarea",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 h-16 font-mono",value:(e.imports??[]).join("\n"),placeholder:"One import per line",onChange:e=>n({imports:e.target.value?e.target.value.split("\n"):[]})}),(0,o.jsx)("hr",{className:"border-gray-800"}),(0,o.jsx)("h4",{className:"text-xs font-semibold text-gray-500",children:"Object References"}),(0,o.jsx)("textarea",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 h-12 font-mono",value:(e.objects??[]).map(e=>`${e.instance}: ${e.class}`).join("\n"),placeholder:"instance: Class (one per line)",onChange:e=>{n({objects:e.target.value.split("\n").filter(e=>e.includes(":")).map(e=>{let[t,n]=e.split(":").map(e=>e.trim());return{instance:t,class:n}})})}}),(0,o.jsx)("hr",{className:"border-gray-800"}),(0,o.jsx)("h4",{className:"text-xs font-semibold text-gray-500",children:"Code Generation"}),(0,o.jsxs)("label",{className:"block",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Target Language"}),(0,o.jsxs)("select",{className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200",value:e.targetLanguage??"python",onChange:e=>n({targetLanguage:e.target.value}),children:[(0,o.jsx)("option",{value:"python",children:"Python"}),(0,o.jsx)("option",{value:"typescript",children:"TypeScript"}),(0,o.jsx)("option",{value:"csharp",children:"C#"})]})]})]})}function tI(){let e=tx(e=>e.errors),t=tx(e=>e.validate),n=tx(e=>e.select);return(0,o.jsxs)("div",{className:"p-3",children:[(0,o.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,o.jsxs)("h3",{className:"text-xs font-semibold text-gray-400",children:["Validation ",e.length>0&&(0,o.jsxs)("span",{className:"text-red-500",children:["(",e.length,")"]})]}),(0,o.jsx)("button",{onClick:()=>t(),className:"text-xs bg-gray-700 hover:bg-gray-600 text-gray-300 px-2 py-0.5 rounded",children:"Re-check"})]}),0===e.length?(0,o.jsxs)("div",{className:"flex items-center gap-2 text-green-500 text-xs",children:[(0,o.jsx)("span",{children:"✓"}),(0,o.jsx)("span",{children:"Definition is valid"})]}):(0,o.jsx)("div",{className:"space-y-0.5",children:e.map((e,t)=>(0,o.jsxs)("div",{className:`flex items-start gap-1.5 text-[13px] py-2.5 border-b border-gray-800/50 md:text-xs md:py-1 ${e.element?"cursor-pointer hover:bg-gray-800/30":""}`,onClick:()=>{e.element&&n("state",e.element)},title:e.element?`Click to select "${e.element}"`:void 0,children:[(0,o.jsx)("span",{className:`font-mono text-[10px] mt-0.5 ${"error"===e.severity?"text-red-600":"text-yellow-600"}`,children:e.ruleId}),(0,o.jsx)("span",{className:`flex-1 ${"error"===e.severity?"text-red-400":"text-yellow-400"}`,children:e.message}),e.element&&(0,o.jsxs)("span",{className:"text-gray-600 text-[10px]",children:["→ ",e.element]})]},t))})]})}var tL=e.i(76800);function tB(){let e=(0,tL.useRequestedDoc)(),[t,n]=(0,l.useState)(!1),[r,s]=(0,l.useState)(""),[i,a]=(0,l.useState)(null),[c,d]=(0,l.useState)([]),[h,u]=(0,l.useState)(null),[p,f]=(0,l.useState)(null);(0,l.useEffect)(()=>{if(!t)return;let e=!0;return f(null),fetch("/api/docs",{cache:"no-store"}).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(t=>{e&&(a(t.docs??[]),d(t.roots??[]),u(t.current??null))}).catch(t=>{e&&(a([]),f(t.message))}),()=>{e=!1}},[t]);let m=e=>{n(!1),s(""),(0,tL.navigateToDoc)(e)},g=new Set((i??[]).map(e=>e.path)),x=t?(function(){try{let e=[];for(let t=0;t<window.localStorage.length;t++){let n=window.localStorage.key(t);n?.startsWith(tE)&&e.push(n.slice(tE.length))}return e.sort()}catch{return[]}})().filter(t=>t.startsWith("/")&&t!==e&&!g.has(t)):[],y=e??h,b=(i??[]).filter(e=>e.path!==y),v=r.trim().toLowerCase(),w=v?b.filter(e=>e.path.toLowerCase().includes(v)):b,k="block w-full truncate rounded px-1.5 py-1 text-left text-xs text-gray-300 hover:bg-gray-800";return(0,o.jsxs)("span",{className:"relative inline-flex",children:[(0,o.jsx)("button",{onClick:()=>n(e=>!e),className:"toolbar-btn",title:e?`Document: ${e}`:"Switch document",children:"⇄"}),t&&(0,o.jsxs)("div",{className:"absolute left-0 top-full z-50 mt-1 w-80 rounded border border-gray-700 bg-gray-900 p-2 shadow-lg",children:[(0,o.jsx)("div",{className:"mb-1 text-[10px] uppercase tracking-wide text-gray-500",children:"switch document"}),(0,o.jsxs)("form",{onSubmit:e=>{e.preventDefault();let t=r.trim();if(t){if(1===w.length)return m(w[0].path);if(t.startsWith("/"))return m(t)}},className:"mb-1 flex gap-1",children:[(0,o.jsx)("input",{value:r,onChange:e=>s(e.target.value),placeholder:null===i?"loading…":"filter, or /absolute/path.json",className:"min-w-0 flex-1 rounded border border-gray-700 bg-gray-950 px-1.5 py-1 text-xs text-gray-200 placeholder:text-gray-600"}),(0,o.jsx)("button",{type:"submit",className:"toolbar-btn",title:"Open",children:"→"})]}),(0,o.jsxs)("div",{className:"max-h-64 overflow-y-auto",children:[e&&(0,o.jsx)("button",{onClick:()=>m(null),className:k,title:"Return to the default project file",children:"⌂ default document"}),w.map(e=>(0,o.jsxs)("button",{onClick:()=>m(e.path),className:k,title:e.path,children:[e.name,(0,o.jsx)("span",{className:"ml-1 text-[10px] text-gray-600",children:e.dir})]},e.path)),x.length>0&&(0,o.jsxs)("div",{className:"mt-1 border-t border-gray-800 pt-1",children:[(0,o.jsx)("div",{className:"px-1.5 pb-0.5 text-[10px] uppercase tracking-wide text-gray-600",children:"recent"}),x.map(e=>(0,o.jsxs)("button",{onClick:()=>m(e),className:k,title:e,children:[e.split("/").pop(),(0,o.jsx)("span",{className:"ml-1 text-[10px] text-gray-600",children:e})]},e))]}),null!==i&&0===w.length&&0===x.length&&(0,o.jsx)("div",{className:"px-1.5 py-1 text-[11px] text-gray-500",children:v?"nothing matches":"no other documents here"})]}),c.length>0&&(0,o.jsxs)("div",{className:"mt-1 truncate border-t border-gray-800 pt-1 text-[10px] text-gray-600",children:["paths are as the server sees them: ",c.join(", ")]}),p&&(0,o.jsxs)("div",{className:"mt-1 text-[10px] text-gray-600",children:["this server does not list documents (",p,") — type a path"]})]})]})}function tD(){let e=tx(e=>e.presence),[t,n]=(0,l.useState)(!1);if(0===e.length)return null;let r=new Map;for(let t of e)r.set(t.role,(r.get(t.role)??0)+1);let s=[...r].map(([e,t])=>t>1?`${e} \xd7${t}`:e).join(" · ");return(0,o.jsxs)("span",{className:"relative inline-flex",children:[(0,o.jsxs)("button",{onClick:()=>n(e=>!e),className:"toolbar-btn inline-flex items-center gap-1.5",title:`Connected: ${s}`,"aria-expanded":t,"aria-label":`${e.length} connected: ${s}`,children:[(0,o.jsx)("span",{className:"flex -space-x-1",children:e.slice(0,4).map(e=>(0,o.jsx)("span",{className:"inline-block h-2 w-2 rounded-full ring-1 ring-gray-900",style:{backgroundColor:e.color??y(e.clientId)}},e.clientId))}),(0,o.jsx)("span",{className:"tabular-nums",children:e.length})]}),t&&(0,o.jsxs)("div",{className:"absolute left-0 top-full z-50 mt-1 max-h-64 w-56 overflow-y-auto rounded border border-gray-700 bg-gray-900 p-2 shadow-lg",children:[(0,o.jsxs)("div",{className:"mb-1 text-[10px] uppercase tracking-wide text-gray-500",children:["connected · ",s]}),e.map(e=>(0,o.jsxs)("div",{className:"flex items-center gap-1.5 rounded px-1 py-1 text-xs text-gray-300",title:e.clientId,children:[(0,o.jsx)("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full",style:{backgroundColor:e.color??y(e.clientId)}}),(0,o.jsx)("span",{className:"shrink-0",children:e.role}),e.name&&(0,o.jsx)("span",{className:"truncate text-gray-500",children:e.name})]},e.clientId))]})]})}function tF(){let e=tx(e=>e.definition),t=tx(e=>e.fileName),n=tx(e=>e.docPath),r=tx(e=>e.dirty),s=tx(e=>e.loadFromJson),i=tx(e=>e.exportJson),a=tx(e=>e.addState),c=tx(e=>e.validate),d=tx(e=>e.showCodePreview),h=tx(e=>e.setShowCodePreview),u=tx(e=>e.setGeneratedCode),p=tx(e=>e.drawMode),f=tx(e=>e.setDrawMode),m=tx(e=>e.arrangeLayout),g=tx(e=>e.undo),x=tx(e=>e.redo),y=tx(e=>e.undoStack),b=tx(e=>e.redoStack),v=tx(e=>e.remoteStatus),w=tx(e=>e.remoteMessage),k=tx(e=>e.setRemoteStatus),j=tx(e=>e.setRemoteMtime),N=tx(e=>e.applyRemote),S=(0,tL.useRequestedDoc)(),_=(0,l.useRef)(null),[C,E]=(0,l.useState)(!1),[R,O]=(0,l.useState)(""),[M,A]=(0,l.useState)(!1),[T,$]=(0,l.useState)("png"),[P,I]=(0,l.useState)(!1),[L,B]=(0,l.useState)(null),[D,F]=(0,l.useState)(null),q=async()=>{let e=i();A(!0);try{let t=await fetch(`/api/file${(0,tL.docQuery)(S)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:e})});if(t.ok){let e=await t.json();j(e.mtime),tx.setState({dirty:!1}),k("synced",null)}else{let e=await t.json().catch(()=>({error:"unknown"}));k("error",`Save failed: ${e.error??t.statusText}`)}}catch(e){k("error",`Save failed: ${e}`)}finally{A(!1)}},U=async()=>{I(!0),B(null);try{let r=await tC(T,{definition:e,docPath:n,fileName:t});F(r)}catch(e){B(e instanceof Error?e.message:String(e))}finally{I(!1)}},H=async()=>{try{let e=await fetch(`/api/file${(0,tL.docQuery)(S)}`,{cache:"no-store"});if(!e.ok)return void k("error","Reload failed");let t=await e.json();t.exists&&t.content?N(t.content,t.mtime,t.path.split("/").pop()):k("idle",`No file at ${t.path}`)}catch(e){k("error",`Reload failed: ${e}`)}},J=()=>{R.trim()&&(a(null,{name:R.trim(),kind:"normal"}),O(""),E(!1))},[Y,V]=(0,l.useState)("python"),X=async()=>{try{let e=await fetch("/api/rispec",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(e.ok){let t=await e.json();u(t.rispec)}else{let t=await e.json().catch(()=>({error:"Unknown"}));u(`# RISE rispec generation failed
|
|
6
6
|
${t.error}`)}}catch(e){u(`# RISE rispec generation failed
|
|
7
7
|
${e}`)}h(!0)},z=async()=>{let e=i();try{let t=await fetch("/api/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({definition:e,language:Y})});if(t.ok){let e=await t.json();u(e.code)}else{let n=await t.json().catch(()=>({error:"Unknown error"}));u(`// Code generation failed: ${n.error}
|
|
8
8
|
// Showing definition JSON as fallback:
|
package/server/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miadi/stateloom-web-source",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@miadi/stateloom-web-source",
|
|
9
|
-
"version": "0.1.
|
|
9
|
+
"version": "0.1.5",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@miadi/stateloom-canvas": "file:../bridge-canvas",
|
|
12
12
|
"@miadi/stateloom-client": "file:../bridge-client",
|