const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TopMenuNodes-BJFWAejp.js","assets/reactflow-vendor-DYfacRG4.js","assets/react-vendor-CMZ2fpGT.js","assets/CustomDrawer-CKyuU-vD.js","assets/index-9ErzGo47.js","assets/react-syntax-highlighter-Ca70WVaL.js","assets/index-ClcHmNCg.css","assets/shallow-D0wo54Jg.js","assets/Stack-1B6MSRlq.js","assets/TopMenuCodePreviewButton-BV0IK1ie.js"])))=>i.map(i=>d[i]);
import{_ as b}from"./react-syntax-highlighter-Ca70WVaL.js";import{j as e}from"./reactflow-vendor-DYfacRG4.js";import{r as f}from"./react-vendor-CMZ2fpGT.js";import{c as y,a as j,S as w}from"./index-9ErzGo47.js";import{c as g,S as k,u as _,a as N,F as O,b as l,f as S,d as z}from"./shallow-D0wo54Jg.js";/**
 * @license @tabler/icons-react v3.18.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var R=g("outline","download","IconDownload",[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 11l5 5l5 -5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]]);/**
 * @license @tabler/icons-react v3.18.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var T=g("outline","folder-open","IconFolderOpen",[["path",{d:"M5 19l2.757 -7.351a1 1 0 0 1 .936 -.649h12.307a1 1 0 0 1 .986 1.164l-.996 5.211a2 2 0 0 1 -1.964 1.625h-14.026a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v2",key:"svg-0"}]]);/**
 * @license @tabler/icons-react v3.18.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var I=g("filled","player-play-filled","IconPlayerPlayFilled",[["path",{d:"M6 4v16a1 1 0 0 0 1.524 .852l13 -8a1 1 0 0 0 0 -1.704l-13 -8a1 1 0 0 0 -1.524 .852z",key:"svg-0"}]]);const M=j("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 px-4 py-2",sm:"h-6 rounded-md px-3",lg:"h-10 rounded-md px-8",icon:"h-8 w-8"}},defaultVariants:{variant:"default",size:"default"}}),u=f.forwardRef(({className:i,variant:m,size:s,asChild:h=!1,isLoading:r=!1,left:d,...t},o)=>{const n=h?w:"button";return e.jsx(n,{className:y(M({variant:m,size:s,className:i})),ref:o,...t,disabled:r||t.disabled,children:r?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(k,{size:s==="default"?"md":s=="sm"?"sm":"lg"}),e.jsx("span",{children:t.children})]}):e.jsxs("div",{className:"flex items-center gap-1",children:[d&&e.jsx("div",{className:"w-4",children:d}),e.jsx("span",{children:t.children})]})})});u.displayName="Button";const P=f.lazy(()=>b(()=>import("./TopMenuNodes-BJFWAejp.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))),C=f.lazy(()=>b(()=>import("./TopMenuCodePreviewButton-BV0IK1ie.js"),__vite__mapDeps([9,1,2,7,4,5,6,3,8])));function E(){const{name:i,setName:m,loadGraph:s}=_(N(o=>({name:o.name,setName:o.setName,loadGraph:o.loadGraph}))),h=()=>{var p;(p=document.getElementById("workflow-download"))==null||p.click();const o=JSON.stringify(l.graph,null,2);console.log("common_app.graph",l.graph);const n=new Blob([o],{type:"application/json"}),c=URL.createObjectURL(n),a=document.createElement("a");a.href=c,a.download=`${i??"nozy_workflow"}.json`,a.click()},r=f.useRef(null),d=o=>{var a;const n=(a=o.target.files)==null?void 0:a[0],c=new FileReader;n&&(c.readAsText(n,"UTF-8"),c.onload=p=>{var x;const v=JSON.parse((x=p.target)==null?void 0:x.result);v.name=n.name.replace(/\.json$/,""),s(v)})},t=z("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",12);return e.jsxs("div",{className:"flex items-center justify-between absolute top-0 left-0 right-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{}),e.jsx("div",{className:"text-sm",onClick:()=>{const o=prompt("Enter a name for this workflow");o&&m(o)},children:i??"Untitled"}),e.jsxs(O,{className:"gap-0",children:[e.jsx(u,{size:"sm",variant:"ghost",title:"Download workflow",onClick:h,children:e.jsx(R,{size:18})}),e.jsx(u,{size:"sm",variant:"ghost",title:"Open workflow",onClick:()=>{var o;(o=r.current)==null||o.click()},children:e.jsx(T,{size:18})}),e.jsx("input",{type:"file",accept:".json",id:"workflow-upload",ref:r,style:{display:"none"},onChange:d})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{}),e.jsx(u,{left:e.jsx(I,{size:15}),onClick:()=>{const o={job_id:t(),nodes:l.graph.nodes,edges:l.graph.edges,values:l.graph.values};console.log("graph",o),S("/queue_job",{method:"POST",body:JSON.stringify(o)})},children:"Run"})]})]})}const V=Object.freeze(Object.defineProperty({__proto__:null,default:E},Symbol.toStringTag,{value:"Module"}));export{u as B,V as T};
